Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake dylib #1

Merged
merged 2 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
29 changes: 29 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
File renamed without changes.
12 changes: 6 additions & 6 deletions serum-decode.cpp → src/serum-decode.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "serum-decode.h"
#include "zip_file.hpp"
#include "miniz/zip_file.hpp"
#include <stdio.h>
#include <stdlib.h>

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -567,4 +568,3 @@ LIB_API(void) Serum_Colorize(UINT8* frame, int width, int height, UINT8* palette
lasthei = hei;
}
}

15 changes: 7 additions & 8 deletions serum-decode.h → src/serum-decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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