From 40b3cb2f8ad5592c3ea0afec15465d31fc9c8abf Mon Sep 17 00:00:00 2001 From: Graham Clemo Date: Sun, 14 Oct 2018 19:11:30 +0100 Subject: [PATCH] Fixed API changes --- CMakeLists.txt | 42 +++++++++++++++++++++++++++++++++++++++--- src/squirrelapi.c | 21 +++++++++++++++++++-- src/tic.c | 2 +- 3 files changed, 59 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7daf625..12e4f2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.9) -project(TIC-80 C) +project(TIC-80 C CXX) message("Building for target : ${CMAKE_SYSTEM_NAME}") if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID) @@ -133,6 +133,40 @@ target_include_directories(wren PRIVATE 3rd-party/wren-0.1.0/src/include) target_include_directories(wren PRIVATE 3rd-party/wren-0.1.0/src/optional) target_include_directories(wren PRIVATE 3rd-party/wren-0.1.0/src/vm) +################################ +# SQUIRREL +################################ + +set(SQUIRREL_DIR 3rd-party/squirrel3.1) +set(SQUIRREL_SRC + ${SQUIRREL_DIR}/squirrel/sqapi.cpp + ${SQUIRREL_DIR}/squirrel/sqbaselib.cpp + ${SQUIRREL_DIR}/squirrel/sqclass.cpp + ${SQUIRREL_DIR}/squirrel/sqcompiler.cpp + ${SQUIRREL_DIR}/squirrel/sqdebug.cpp + ${SQUIRREL_DIR}/squirrel/sqfuncstate.cpp + ${SQUIRREL_DIR}/squirrel/sqlexer.cpp + ${SQUIRREL_DIR}/squirrel/sqmem.cpp + ${SQUIRREL_DIR}/squirrel/sqobject.cpp + ${SQUIRREL_DIR}/squirrel/sqstate.cpp + ${SQUIRREL_DIR}/squirrel/sqtable.cpp + ${SQUIRREL_DIR}/squirrel/sqvm.cpp + ${SQUIRREL_DIR}/sqstdlib/sqstdaux.cpp + ${SQUIRREL_DIR}/sqstdlib/sqstdblob.cpp + ${SQUIRREL_DIR}/sqstdlib/sqstdio.cpp + ${SQUIRREL_DIR}/sqstdlib/sqstdmath.cpp + ${SQUIRREL_DIR}/sqstdlib/sqstdrex.cpp + ${SQUIRREL_DIR}/sqstdlib/sqstdstream.cpp + ${SQUIRREL_DIR}/sqstdlib/sqstdstring.cpp + ${SQUIRREL_DIR}/sqstdlib/sqstdsystem.cpp +) + +add_library(squirrel STATIC ${SQUIRREL_SRC}) +set_target_properties(squirrel PROPERTIES LINKER_LANGUAGE CXX) +target_include_directories(squirrel PRIVATE 3rd-party/squirrel3.1/include) +target_include_directories(squirrel PRIVATE 3rd-party/squirrel3.1/squirrel) +target_include_directories(squirrel PRIVATE 3rd-party/squirrel3.1/sqstdlib) + ################################ # GIFLIB ################################ @@ -162,6 +196,7 @@ set(TIC80CORE_SRC ${TIC80CORE_DIR}/jsapi.c ${TIC80CORE_DIR}/luaapi.c ${TIC80CORE_DIR}/wrenapi.c + ${TIC80CORE_DIR}/squirrelapi.c ${TIC80CORE_DIR}/ext/gif.c 3rd-party/blip-buf/blip_buf.c # TODO: link it as lib? 3rd-party/duktape-2.2.0/src/duktape.c # TODO: link it as lib? @@ -175,11 +210,12 @@ target_include_directories(tic80core PRIVATE 3rd-party/duktape-2.2.0/src) target_include_directories(tic80core PRIVATE 3rd-party/lua-5.3.1/src) target_include_directories(tic80core PRIVATE 3rd-party/giflib-5.1.4/lib) target_include_directories(tic80core PRIVATE 3rd-party/wren-0.1.0/src/include) +target_include_directories(tic80core PRIVATE 3rd-party/squirrel3.1/include) target_include_directories(tic80core PRIVATE 3rd-party/moonscript) target_include_directories(tic80core PRIVATE 3rd-party/fennel) -add_dependencies(tic80core lua lpeg wren giflib) -target_link_libraries(tic80core lua lpeg wren giflib) +add_dependencies(tic80core lua lpeg wren squirrel giflib) +target_link_libraries(tic80core lua lpeg wren squirrel giflib) ################################ # SDL2 diff --git a/src/squirrelapi.c b/src/squirrelapi.c index c68fd10..b5642bc 100644 --- a/src/squirrelapi.c +++ b/src/squirrelapi.c @@ -1028,6 +1028,7 @@ static SQInteger squirrel_font(HSQUIRRELVM vm) s32 height = TIC_SPRITESIZE; u8 chromakey = 0; bool fixed = false; + bool alt = false; s32 scale = 1; if(top >= 4) @@ -1053,6 +1054,14 @@ static SQInteger squirrel_font(HSQUIRRELVM vm) if(top >= 9) { scale = getSquirrelNumber(vm, 9); + + if (top >= 10) + { + SQBool b = SQFalse; + sq_getbool(vm, 10, &b); + alt = (b != SQFalse); + } + } } } @@ -1065,7 +1074,7 @@ static SQInteger squirrel_font(HSQUIRRELVM vm) return 1; } - s32 size = drawText(memory, text, x, y, width, height, chromakey, scale, fixed ? drawSpriteFont : drawFixedSpriteFont); + s32 size = drawText(memory, text, x, y, width, height, chromakey, scale, fixed ? drawSpriteFont : drawFixedSpriteFont, alt); sq_pushinteger(vm, size); return 1; @@ -1086,6 +1095,7 @@ static SQInteger squirrel_print(HSQUIRRELVM vm) s32 y = 0; s32 color = TIC_PALETTE_SIZE-1; bool fixed = false; + bool alt = false; s32 scale = 1; const char* text = printString(vm, 2); @@ -1108,6 +1118,13 @@ static SQInteger squirrel_print(HSQUIRRELVM vm) if(top >= 7) { scale = getSquirrelNumber(vm, 7); + + if (top >= 8) + { + SQBool b = SQFalse; + sq_getbool(vm, 8, &b); + alt = (b != SQFalse); + } } } } @@ -1119,7 +1136,7 @@ static SQInteger squirrel_print(HSQUIRRELVM vm) return 1; } - s32 size = memory->api.text_ex(memory, text ? text : "nil", x, y, color, fixed, scale); + s32 size = memory->api.text_ex(memory, text ? text : "nil", x, y, color, fixed, scale, alt); sq_pushinteger(vm, size); diff --git a/src/tic.c b/src/tic.c index 0358ef0..2c746c2 100644 --- a/src/tic.c +++ b/src/tic.c @@ -575,7 +575,7 @@ void tic_close(tic_mem* memory) machine->state.initialized = false; #if defined(TIC_BUILD_WITH_SQUIRREL) - getSquirrelScriptConfig()->close(tic); + getSquirrelScriptConfig()->close(memory); #endif #if defined(TIC_BUILD_WITH_LUA)