diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..84c048a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..618ff73 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.9) + +project(serum VERSION 0.1.0 DESCRIPTION "Cross-platform library for decoding Serum files, a colorization format for pinball ROMs.") + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_VISIBILITY_PRESET hidden) + +include(GNUInstallDirs) + +add_library(serum SHARED + src/miniz/zip_file.hpp + src/serum-decode.h + src/serum-decode.cpp + ) + +set_target_properties(serum PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION 1 + ) + +target_include_directories(serum PUBLIC + src + ) + +install(TARGETS serum + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/README.md b/README.md index ecb86a6..998b34a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,16 @@ # libserum -This is the code for the cross platform library that decode Serum files (colorization files for pinball ROMs) +This is a cross-platform library for decoding Serum files, a colorization format for pinball ROMs. -It uses Thomas Fussel miniz-cpp zip de/compression code available here https://github.com/tfussell/miniz-cpp +## License +The code in this directory and all sub-directories is licenced under GPLv2 (or later), except if a different license is +mentioned in a file's header or in a sub-directory. Be aware of the fact that your own enhancements of libserum need to +be licenced under a compatible licence. + +Due to complicated dependency management on different platforms, these libraries are included as source code copy: +* [miniz-cpp](https://github.com/tfussell/miniz-cpp) by Thomas Fussel + +## Compiling +```shell +cmake -DCMAKE_BUILD_TYPE=Release -B build/Release +cmake --build build/Release +``` diff --git a/zip_file.hpp b/src/miniz/zip_file.hpp similarity index 100% rename from zip_file.hpp rename to src/miniz/zip_file.hpp diff --git a/serum-decode.cpp b/src/serum-decode.cpp similarity index 96% rename from serum-decode.cpp rename to src/serum-decode.cpp index cecc593..b443497 100644 --- a/serum-decode.cpp +++ b/src/serum-decode.cpp @@ -1,5 +1,5 @@ #include "serum-decode.h" -#include "zip_file.hpp" +#include "miniz/zip_file.hpp" #include #include @@ -209,7 +209,8 @@ UINT32 crc32_fast_mask(UINT8* source, UINT8* mask, UINT n, UINT8 ShapeMode) // c } return ~crc; } -LIB_API(bool) Serum_Load(const char* altcolorpath, const char* romname) + +SERUM_API(bool) Serum_Load(const char* altcolorpath, const char* romname) { if (!crc32_ready) CRC32encode(); @@ -334,12 +335,11 @@ LIB_API(bool) Serum_Load(const char* altcolorpath, const char* romname) return true; } -LIB_API(void) Serum_Dispose(void) +SERUM_API(void) Serum_Dispose(void) { Serum_free(); } - int Identify_Frame(UINT8* frame) { // check if the generated frame is the same as one we have in the crom ( @@ -483,6 +483,7 @@ void Check_Sprites(UINT8* Frame, int quelleframe, UINT8* pquelsprite, UINT16* pf *pquelsprite = 255; return; } + void Colorize_Frame(UINT8* frame, int IDfound) { UINT32 ti; @@ -516,7 +517,7 @@ void Copy_Frame_Palette(int nofr, UINT8* dpal) memcpy(dpal, &cpal[nofr * 64 * 3], 64 * 3); } -LIB_API(void) Serum_Colorize(UINT8* frame, int width, int height, UINT8* palette) +SERUM_API(void) Serum_Colorize(UINT8* frame, int width, int height, UINT8* palette) { //byte[][] planes = new byte[6][]; //for (int i = 0; i < 6; i++) planes[i] = new byte[FWidth * FHeight / 8]; @@ -567,4 +568,3 @@ LIB_API(void) Serum_Colorize(UINT8* frame, int width, int height, UINT8* palette lasthei = hei; } } - diff --git a/serum-decode.h b/src/serum-decode.h similarity index 59% rename from serum-decode.h rename to src/serum-decode.h index 3d01d8e..db11e69 100644 --- a/serum-decode.h +++ b/src/serum-decode.h @@ -3,15 +3,15 @@ #if defined DLL_EXPORTS #if defined WIN32 -#define LIB_API(RetType) extern "C" __declspec(dllexport) RetType +#define SERUM_API(RetType) extern "C" __declspec(dllexport) RetType #else -#define LIB_API(RetType) extern "C" RetType __attribute__((visibility("default"))) +#define SERUM_API(RetType) extern "C" RetType __attribute__((visibility("default"))) #endif #else #if defined WIN32 -#define LIB_API(RetType) extern "C" __declspec(dllimport) RetType +#define SERUM_API(RetType) extern "C" __declspec(dllimport) RetType #else -#define LIB_API(RetType) extern "C" RetType +#define SERUM_API(RetType) extern "C" RetType #endif #endif @@ -28,9 +28,8 @@ const int MAX_SPRITES_PER_FRAME = 32; // maximum amount of sprites to look for p const int MAX_COLOR_ROTATIONS = 8; // maximum amount of color rotations per frame const int MAX_SPRITE_DETECT_AREAS = 4; // maximum number of areas to detect the sprite -LIB_API(bool) Serum_Load(const char* altcolorpath, const char* romname); -LIB_API(void) Serum_Dispose(void); -LIB_API(void) Serum_Colorize(UINT8* frame, int width, int height, UINT8* palette); - +SERUM_API(bool) Serum_Load(const char* altcolorpath, const char* romname); +SERUM_API(void) Serum_Dispose(void); +SERUM_API(void) Serum_Colorize(UINT8* frame, int width, int height, UINT8* palette); #endif \ No newline at end of file