Skip to content

Commit

Permalink
scan tic80 binary folder for shared modules
Browse files Browse the repository at this point in the history
  • Loading branch information
nesbox committed May 2, 2024
1 parent b52bd73 commit 73b68f4
Show file tree
Hide file tree
Showing 34 changed files with 524 additions and 432 deletions.
17 changes: 12 additions & 5 deletions cmake/core.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ macro(MACRO_CORE SCRIPT DEFINE BUILD_DEPRECATED)
${TIC80CORE_DIR}/tools.c
${TIC80CORE_DIR}/zip.c
${TIC80CORE_DIR}/tilesheet.c
${TIC80CORE_DIR}/script.c
)

if(${BUILD_DEPRECATED})
Expand All @@ -28,6 +29,17 @@ macro(MACRO_CORE SCRIPT DEFINE BUILD_DEPRECATED)
target_link_directories(tic80core${SCRIPT} PRIVATE ${SYSROOT_PATH}/usr/local/lib)
endif()

if(WIN32)
add_library(dlfcn STATIC ${THIRDPARTY_DIR}/dlfcn/src/dlfcn.c)

target_include_directories(dlfcn
INTERFACE
${THIRDPARTY_DIR}/dirent/include
${THIRDPARTY_DIR}/dlfcn/src)

target_link_libraries(tic80core${SCRIPT} PUBLIC dlfcn)
endif()

target_include_directories(tic80core${SCRIPT}
PRIVATE
${THIRDPARTY_DIR}/moonscript
Expand All @@ -39,7 +51,6 @@ macro(MACRO_CORE SCRIPT DEFINE BUILD_DEPRECATED)

target_link_libraries(tic80core${SCRIPT} PRIVATE blipbuf zlib)


if(BUILD_STATIC)
if(BUILD_WITH_LUA)
# !TODO: make it PRIVATE
Expand Down Expand Up @@ -88,10 +99,6 @@ macro(MACRO_CORE SCRIPT DEFINE BUILD_DEPRECATED)

target_link_libraries(tic80core${SCRIPT} PRIVATE runtime)

elseif(WIN32)
target_include_directories(tic80core${SCRIPT} PRIVATE ${THIRDPARTY_DIR}/dlfcn/src)
add_library(dlfcn STATIC ${THIRDPARTY_DIR}/dlfcn/src/dlfcn.c)
target_link_libraries(tic80core${SCRIPT} PRIVATE dlfcn)
endif()

if(${BUILD_DEPRECATED})
Expand Down
10 changes: 4 additions & 6 deletions cmake/sdl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ if(BUILD_SDL AND BUILD_PLAYER AND NOT RPI)
${CMAKE_SOURCE_DIR}/src)

if(MINGW)
target_link_libraries(player-sdl mingw32)
target_link_libraries(player-sdl PRIVATE mingw32)
target_link_options(player-sdl PRIVATE -static)
endif()

target_link_libraries(player-sdl tic80core SDL2main)
target_link_libraries(player-sdl PRIVATE tic80core SDL2main)

if(BUILD_STATIC)
target_link_libraries(player-sdl SDL2-static)
target_link_libraries(player-sdl PRIVATE SDL2-static)
else()
target_link_libraries(player-sdl SDL2)
target_link_libraries(player-sdl PRIVATE SDL2)
endif()
endif()

Expand Down Expand Up @@ -147,8 +147,6 @@ if(BUILD_SDL)

add_library(tic80 SHARED ${TIC80_SRC})

target_link_libraries(tic80)

else()
add_executable(tic80 ${TIC80_SRC})
endif()
Expand Down
5 changes: 0 additions & 5 deletions cmake/studio.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,11 @@ endif()

set(TIC80_OUTPUT tic80)


add_library(tic80studio STATIC
${TIC80STUDIO_SRC}
${DEMO_CARTS_OUT}
${CMAKE_SOURCE_DIR}/build/assets/cart.png.dat)

if(WIN32)
target_include_directories(tic80studio PRIVATE ${THIRDPARTY_DIR}/dirent/include)
endif()

target_include_directories(tic80studio PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

target_link_libraries(tic80studio PUBLIC tic80core PRIVATE zip wave_writer argparse giflib png)
Expand Down
3 changes: 3 additions & 0 deletions include/tic80_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
// # ifndef TARGET_OS_IPHONE
# undef __TIC_MACOSX__
# define __TIC_MACOSX__ 1
# define MODULE_EXT ".dylib"
// # endif /* TARGET_OS_IPHONE */
#endif /* defined(__APPLE__) */

#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
# undef __TIC_WINDOWS__
# define __TIC_WINDOWS__ 1
# define MODULE_EXT ".dll"
#endif

#if defined(ANDROID) || defined(__ANDROID__)
Expand All @@ -43,6 +45,7 @@
#elif (defined(linux) || defined(__linux) || defined(__linux__))
# undef __TIC_LINUX__
# define __TIC_LINUX__ 1
# define MODULE_EXT ".so"
#endif

#ifndef TIC80_API
Expand Down
65 changes: 5 additions & 60 deletions src/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
#include "tic.h"
#include "time.h"

#define MAX_SUPPORTED_LANGS (16)

// convenience macros to loop languages
#define FOREACH_LANG(lang) for(const tic_script_config *lang = Languages, *end = lang + MAX_SUPPORTED_LANGS; lang != end && lang->id; lang++)

typedef struct { u8 index; tic_flip flip; tic_rotate rotate; } RemapResult;
typedef void(*RemapFunc)(void*, s32 x, s32 y, RemapResult* result);

Expand Down Expand Up @@ -75,55 +70,6 @@ typedef struct
void* data;
} tic_blit_callback;

typedef struct
{
u8 id;
const char* name;
const char* fileExtension;
const char* projectComment;
struct
{
bool(*init)(tic_mem* memory, const char* code);
void(*close)(tic_mem* memory);

tic_tick tick;
tic_boot boot;
tic_blit_callback callback;
};

const tic_outline_item* (*getOutline)(const char* code, s32* size);
void (*eval)(tic_mem* tic, const char* code);

const char* blockCommentStart;
const char* blockCommentEnd;
const char* blockCommentStart2;
const char* blockCommentEnd2;
const char* blockStringStart;
const char* blockStringEnd;
const char* stdStringStartEnd;
const char* singleComment;
const char* blockEnd;

const char* const * keywords;
s32 keywordsCount;

tic_lang_isalnum lang_isalnum;
bool useStructuredEdition;

s32 api_keywordsCount;
const char** api_keywords;

struct tic_demo
{
const u8* data;
s32 size;
const char* name;
} demo, mark, *demos;

} tic_script_config;

extern tic_script_config Languages[];

typedef enum
{
tic_tiles_texture,
Expand Down Expand Up @@ -845,8 +791,8 @@ TIC_API_LIST(TIC_API_DEF)
struct tic_mem
{
tic80 product;
tic_ram* ram;
tic_cartridge cart;
tic_ram* ram;
tic_cartridge cart;

tic_ram* base_ram;

Expand Down Expand Up @@ -883,16 +829,15 @@ void tic_core_tick_end(tic_mem* memory);
void tic_core_synth_sound(tic_mem* tic);
void tic_core_blit(tic_mem* tic);
void tic_core_blit_ex(tic_mem* tic, tic_blit_callback clb);
const tic_script_config* tic_core_script_config(tic_mem* memory);

#define VBANK(tic, bank) \
bool MACROVAR(_bank_) = tic_api_vbank(tic, bank); \
SCOPE(tic_api_vbank(tic, MACROVAR(_bank_)))

#define SYNTAX_CONFIG SyntaxConfig
#define SCRIPT_CONFIG ScriptConfig

#if defined(TIC_RUNTIME_STATIC)
#define EXPORT_CONFIG(X) CONCAT(X, SYNTAX_CONFIG)
#define EXPORT_SCRIPT(X) CONCAT(X, SCRIPT_CONFIG)
#else
#define EXPORT_CONFIG(X) SYNTAX_CONFIG
#define EXPORT_SCRIPT(X) SCRIPT_CONFIG
#endif
2 changes: 1 addition & 1 deletion src/api/fennel.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static const u8 DemoRom[] =
#include "../build/assets/fenneldemo.tic.dat"
};

const tic_script_config EXPORT_CONFIG(Fennel) =
const tic_script EXPORT_SCRIPT(Fennel) =
{
.id = 14,
.name = "fennel",
Expand Down
2 changes: 1 addition & 1 deletion src/api/janet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ static const u8 MarkRom[] =
#include "../build/assets/janetmark.tic.dat"
};

JANET_API const tic_script_config EXPORT_CONFIG(Janet) =
JANET_API const tic_script EXPORT_SCRIPT(Janet) =
{
.id = 18,
.name = "janet",
Expand Down
2 changes: 1 addition & 1 deletion src/api/js.c
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ static const u8 MarkRom[] =
#include "../build/assets/jsmark.tic.dat"
};

const tic_script_config EXPORT_CONFIG(Js) =
const tic_script EXPORT_SCRIPT(Js) =
{
.id = 12,
.name = "js",
Expand Down
2 changes: 1 addition & 1 deletion src/api/lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -1895,7 +1895,7 @@ static const u8 DemoCar[] =
#include "../build/assets/car.tic.dat"
};

const tic_script_config EXPORT_CONFIG(Lua) =
const tic_script EXPORT_SCRIPT(Lua) =
{
.id = 10,
.name = "lua",
Expand Down
2 changes: 1 addition & 1 deletion src/api/moonscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static const u8 MarkRom[] =
#include "../build/assets/moonmark.tic.dat"
};

const tic_script_config EXPORT_CONFIG(Moon) =
const tic_script EXPORT_SCRIPT(Moon) =
{
.id = 13,
.name = "moon",
Expand Down
2 changes: 1 addition & 1 deletion src/api/mruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@ static const u8 MarkRom[] =
#include "../build/assets/rubymark.tic.dat"
};

const tic_script_config EXPORT_CONFIG(Ruby) =
const tic_script EXPORT_SCRIPT(Ruby) =
{
.id = 11,
.name = "ruby",
Expand Down
2 changes: 1 addition & 1 deletion src/api/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@ static const u8 MarkRom[] =
#include "../build/assets/pythonmark.tic.dat"
};

PK_EXPORT const tic_script_config EXPORT_CONFIG(Python) =
PK_EXPORT const tic_script EXPORT_SCRIPT(Python) =
{
.id = 20,
.name = "python",
Expand Down
2 changes: 1 addition & 1 deletion src/api/scheme.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ static const u8 MarkRom[] =
#include "../build/assets/schememark.tic.dat"
};

const tic_script_config EXPORT_CONFIG(Scheme) =
const tic_script EXPORT_SCRIPT(Scheme) =
{
.id = 19,
.name = "scheme",
Expand Down
2 changes: 1 addition & 1 deletion src/api/squirrel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,7 @@ static const u8 MarkRom[] =
#include "../build/assets/squirrelmark.tic.dat"
};

const tic_script_config EXPORT_CONFIG(Squirrel) =
const tic_script EXPORT_SCRIPT(Squirrel) =
{
.id = 15,
.name = "squirrel",
Expand Down
2 changes: 1 addition & 1 deletion src/api/wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ static const u8 MarkRom[] =
#include "../build/assets/wasmmark.tic.dat"
};

const tic_script_config EXPORT_CONFIG(Wasm) =
const tic_script EXPORT_SCRIPT(Wasm) =
{
.id = 17,
.name = "wasm",
Expand Down
2 changes: 1 addition & 1 deletion src/api/wren.c
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ static const u8 MarkRom[] =
#include "../build/assets/wrenmark.tic.dat"
};

const tic_script_config EXPORT_CONFIG(Wren) =
const tic_script EXPORT_SCRIPT(Wren) =
{
.id = 16,
.name = "wren",
Expand Down

0 comments on commit 73b68f4

Please sign in to comment.