Skip to content

Commit

Permalink
Merge branch 'feature/sdl2'
Browse files Browse the repository at this point in the history
  • Loading branch information
carstene1ns committed Oct 24, 2023
2 parents f087242 + 98b64b1 commit 427e5ad
Show file tree
Hide file tree
Showing 33 changed files with 392 additions and 203 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defaults:

jobs:
linux-gcc:
name: Build (Ubuntu 20.04 LTS x86_64, GCC)
name: Build (Ubuntu 20.04 LTS x86_64, GCC, SDL1.2)
runs-on: ubuntu-20.04
steps:
- name: Install dependencies
Expand All @@ -30,30 +30,30 @@ jobs:
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build OpenJazz (normal)
run: |
make
ls -l OpenJazz
linux-clang:
name: Build (Ubuntu 20.04 LTS x86_64, Clang)
name: Build (Ubuntu 20.04 LTS x86_64, Clang, SDL2)
runs-on: ubuntu-20.04
steps:
- name: Install dependencies
run: |
sudo apt-get update -yqq
sudo apt-get install -yqq build-essential cmake ninja-build clang-10 \
libsdl1.2-dev asciidoctor w3m
libsdl2-dev asciidoctor w3m
- name: Prepare Environment
run: |
echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build OpenJazz (slim)
run: |
Expand Down Expand Up @@ -90,26 +90,25 @@ jobs:
install: |
base-devel dos2unix w3m
pacboy: |
toolchain:p cmake:p ninja:p SDL:p asciidoctor:p
toolchain:p cmake:p ninja:p SDL2:p asciidoctor:p
- name: Prepare Environment
run: |
echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build OpenJazz
run: |
export LDFLAGS="-static"
export PKG_CONFIG="pkg-config --static"
cmake -G Ninja -B build . -DCMAKE_BUILD_TYPE=Release
cmake --build build
- name: Prepare artifact
run: |
cmake --install build --prefix $PWD
cp /mingw64/bin/SDL2.dll dist/
asciidoctor -o OpenJazzManual.html -a oj_version=${SHORT_SHA} res/unix/OpenJazz.6.adoc
w3m -dump -cols 2147483647 -s OpenJazzManual.html > dist/Manual.txt
cp README.md dist/README.txt
Expand Down Expand Up @@ -140,7 +139,7 @@ jobs:
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build OpenJazz
run: |
Expand Down Expand Up @@ -181,7 +180,7 @@ jobs:
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build OpenJazz
run: |
Expand Down Expand Up @@ -231,7 +230,7 @@ jobs:
../autobuilder/build -v libsdl1.2debian # todo: cache?
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build OpenJazz
run: |
Expand Down Expand Up @@ -267,7 +266,7 @@ jobs:
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build OpenJazz
run: |
Expand Down
5 changes: 2 additions & 3 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Building OpenJazz

Needed:
- SDL 1.2.x library (https://libsdl.org/).
- SDL 2.x or SDL 1.2.x (deprecated) library (https://libsdl.org/)

Optional:
- SDL_net 1.2.x library (https://www.libsdl.org/projects/SDL_net/)
- SDL_net library (https://www.libsdl.org/projects/SDL_net/)
- CMake (https://cmake.org/)

OpenJazz ships a basic Makefile that may be used and adapted to the specific
Expand Down Expand Up @@ -40,5 +40,4 @@ Some ports have their own options, see (Platforms)[PLATFORMS.md] for details.

### advanced options

~~- `HOMEDIR` - use the user's home directory for data files~~ default on unix
- `FULLSCREEN_ONLY` - disable window mode, useful for console ports
29 changes: 18 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED OFF)
include(Platform-Helpers)

# Endianess check

if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
include(TestBigEndian)
test_big_endian(PLATFORM_BIGENDIAN)
if(PLATFORM_BIGENDIAN)
add_compile_definitions(WORDS_BIGENDIAN=1)
endif()
include(TestBigEndian)
test_big_endian(PLATFORM_BIGENDIAN)
if(PLATFORM_BIGENDIAN)
add_compile_definitions(WORDS_BIGENDIAN=1)
endif()

# OpenJazz
Expand Down Expand Up @@ -130,7 +127,7 @@ target_include_directories(OpenJazz PUBLIC src)
option(SCALE "Allow scaling" ${OJ_SCALE})
if(SCALE)
target_compile_definitions(OpenJazz PRIVATE SCALE)
set(OJ_SCALE_LIBS scale2x)
set(OJ_LIBS_SCALE scale2x)
endif()

# path to game data
Expand All @@ -142,8 +139,17 @@ endif()

# libraries

find_package(SDL REQUIRED)
target_include_directories(OpenJazz PRIVATE ${SDL_INCLUDE_DIR})
if(LEGACY_SDL)
find_package(SDL REQUIRED)
target_include_directories(OpenJazz PRIVATE ${SDL_INCLUDE_DIR})
set(OJ_LIBS_SDL ${SDL_LIBRARY})
set(OJ_SDL "SDL1.2 (legacy)")
else()
find_package(SDL2 REQUIRED)
target_include_directories(OpenJazz PRIVATE ${SDL2_INCLUDE_DIRS})
set(OJ_LIBS_SDL ${SDL2_LIBRARIES})
set(OJ_SDL "SDL2")
endif()

# bundled libraries

Expand Down Expand Up @@ -176,7 +182,7 @@ if(NETWORK)
endif()

target_link_libraries(OpenJazz
argparse miniz psmplug ${OJ_SCALE_LIBS} ${SDL_LIBRARY} ${OJ_LIBS_NET} ${OJ_LIBS_HOST})
argparse miniz psmplug ${OJ_LIBS_SCALE} ${OJ_LIBS_SDL} ${OJ_LIBS_NET} ${OJ_LIBS_HOST})

# platform stuff

Expand Down Expand Up @@ -332,6 +338,7 @@ message(STATUS "")
message(STATUS "OpenJazz")
message(STATUS "========")
message(STATUS "Target system: ${OJ_HOST}")
message(STATUS "Platform abstraction: ${OJ_SDL}")
if(ROMFS)
message(STATUS "RomFS: Embedding directory \"${ROMFS_PATH}\"")
endif()
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ ifeq ($(OS),Windows_NT)
LIBS += -lws2_32
endif

# SDL
CXXFLAGS += $(shell sdl-config --cflags)
LIBS += $(shell sdl-config --libs)
# SDL1.2 or SDL2
SDLCONFIG ?= sdl-config
CXXFLAGS += $(shell $(SDLCONFIG) --cflags)
LIBS += $(shell $(SDLCONFIG) --libs)

LIBS += -lm

Expand Down
12 changes: 6 additions & 6 deletions PLATFORMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Use a cross-compiler, enable specific platform code with option:

## Embedded Linux systems

* Pandora: ´-DPANDORA=ON´
* GP2X Canoo: ´-DCAANOO=ON´
* GP2X Wiz: ´-DWIZ=ON´
* GP2X: ´-DGP2X=ON´
* Dingoo: ´-DDINGOO=ON´
* GameShell: ´-DGAMESHELL=ON´
* Pandora: `-DPANDORA=ON`
* GP2X Canoo: `-DCAANOO=ON`
* GP2X Wiz: `-DWIZ=ON`
* GP2X: `-DGP2X=ON`
* Dingoo: `-DDINGOO=ON`
* GameShell: `-DGAMESHELL=ON`

## RISC OS

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

OpenJazz can be compiled on a wide range of operating systems, including
Windows, macOS, GNU/Linux and BSD flavors. Also ports are available for some
homebrew platforms, for example Wii and PSP. See [Platforms](PLATFORMS.md) for
homebrew platforms, consoles and handhelds. See [Platforms](PLATFORMS.md) for
details.

To play, you will need the files from one of the original games.
Expand Down Expand Up @@ -62,7 +62,8 @@ command line argument.

## Authors

Original author: Alister Thomson (alister_j_t at yahoo dot com),
Original author: Alister Thomson (alister_j_t at yahoo dot com)

[Additional Authors](res/unix/OpenJazz.6.adoc#authors) (See manual)

## Homepage
Expand Down
10 changes: 8 additions & 2 deletions builds/cmake/Platform-Helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ option(GP2X "Build for GP2X" OFF) # arm-open2x-linux
option(DINGOO "Build for Dingoo" OFF) # mipsel-linux*
option(GAMESHELL "Build for GameShell" OFF) # armv7l-unknown-linux-gnueabihf
option(RISCOS "Build for RISC OS" OFF) # arm-unknown-riscos
# "Official" Toolchain files define these

# Official/Homebrew Toolchain files define these
if(NINTENDO_3DS)
set(3DS ON)
set(OJ_HOST "3DS")
list(APPEND PLATFORM_LIST ${OJ_HOST})
set(OJ_SCALE OFF)
option(ROMFS "Embedd a directory in the executable" OFF)
option(ROMFS "Embed a directory in the executable" OFF)
set(ROMFS_PATH "romfs" CACHE PATH "Directory to include in executable as romfs:/ path")
set(ROMFS_ARG "NO_ROMFS_IGNORE_ME")
if(ROMFS)
Expand Down Expand Up @@ -111,4 +112,9 @@ endif()

if(${OJ_HOST} STREQUAL "Unknown")
set(OJ_HOST ${CMAKE_SYSTEM_NAME})
set(OJ_ALLOW_NEW_SDL TRUE)
endif()

# choose SDL library for Linux/Windows/Mac/etc., but not homebrew platforms
include(CMakeDependentOption)
cmake_dependent_option(LEGACY_SDL "Build for SDL 1.2" OFF "OJ_ALLOW_NEW_SDL" ON)
5 changes: 3 additions & 2 deletions licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ emulators.
The Simple DirectMedia Layer library source code is available from:
https://www.libsdl.org/

This library is distributed under the terms of the GNU LGPL license:
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
Version 1.2 of this library is distributed under the terms of the GNU LGPL
license: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html

Version 2 uses the zlib license: https://www.libsdl.org/license.php


================================================================================
Expand Down
4 changes: 2 additions & 2 deletions res/unix/OpenJazz.6.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Alireza Nejati:: Menu plasma effect
newspaz:: Bug fixes, enemy improvements
Carsten Teibes (carstene1ns)::
Maintenance, bug fixes, documentation +
Integrating the ports (Wii, 3DS, PSP, PSVita, ...) +
Integrating the ports (Wii, 3DS, PSP, PSVita, SDL2, ...) +
Additional coding (logger, CLI, ...) +
Modernizing +
UI improvements
Expand All @@ -144,4 +144,4 @@ pocketinsanity:: PocketPC port
Ricerind:: Mac OS X port
Slaanesh:: GP32 port
GPF:: Dreamcast port
Cameron Cawley (ccawley2011):: RISC OS port
Cameron Cawley (ccawley2011):: RISC OS, SDL2 port
1 change: 1 addition & 0 deletions src/OpenJazz.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@

#define E_NONE 0

#define MAX_PALETTE_COLORS 256

// Macros

Expand Down
6 changes: 3 additions & 3 deletions src/io/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,10 @@ void File::loadPalette (SDL_Color* palette, bool rle) {
unsigned char* buffer;
int count;

if (rle) buffer = loadRLE(768);
else buffer = loadBlock(768);
if (rle) buffer = loadRLE(MAX_PALETTE_COLORS * 3);
else buffer = loadBlock(MAX_PALETTE_COLORS * 3);

for (count = 0; count < 256; count++) {
for (count = 0; count < MAX_PALETTE_COLORS; count++) {

// Palette entries are 6-bit
// Shift them upwards to 8-bit, and fill in the lower 2 bits
Expand Down
12 changes: 6 additions & 6 deletions src/io/gfx/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Font::Font (const char* fileName) {

} else characters[count] = createSurface(blank, 3, 1);

SDL_SetColorKey(characters[count], SDL_SRCCOLORKEY, 0);
enableColorKey(characters[count], 0);

}

Expand Down Expand Up @@ -172,7 +172,7 @@ Font::Font (unsigned char* pixels, bool big) {

characters[count] = createSurface(chrPixels, 8, lineHeight);

if (big) SDL_SetColorKey(characters[count], SDL_SRCCOLORKEY, 31);
if (big) enableColorKey(characters[count], 31);

}

Expand Down Expand Up @@ -285,7 +285,7 @@ Font::Font (bool bonus) {
pixels = file->loadPixels(width * height);

characters[count] = createSurface(pixels, width, height);
SDL_SetColorKey(characters[count], SDL_SRCCOLORKEY, 254);
enableColorKey(characters[count], 254);

delete[] pixels;

Expand All @@ -301,7 +301,7 @@ Font::Font (bool bonus) {
pixels = new unsigned char[3];
memset(pixels, 254, 3);
characters[nCharacters] = createSurface(pixels, 3, 1);
SDL_SetColorKey(characters[nCharacters], SDL_SRCCOLORKEY, 254);
enableColorKey(characters[nCharacters], 254);
delete[] pixels;


Expand Down Expand Up @@ -533,15 +533,15 @@ void Font::showNumber (int n, int x, int y) {
*/
void Font::mapPalette (int start, int length, int newStart, int newLength) {

SDL_Color palette[256];
SDL_Color palette[MAX_PALETTE_COLORS];
int count;

for (count = 0; count < length; count++)
palette[count].r = palette[count].g = palette[count].b =
(count * newLength / length) + newStart;

for (count = 0; count < nCharacters; count++)
SDL_SetPalette(characters[count], SDL_LOGPAL, palette, start, length);
setLogicalPalette(characters[count], palette, start, length);

}

Expand Down
Loading

0 comments on commit 427e5ad

Please sign in to comment.