Merge pull request #759 from GrahamClemo/add-squirrel

Add squirrel language support to TIC-80
This commit is contained in:
Vadim Grigoruk 2018-10-18 10:00:45 +03:00 committed by GitHub
commit b397f1bc2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 1673 additions and 4 deletions

View File

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

View File

@ -0,0 +1 @@
0x78, 0xda, 0x63, 0x5c, 0xc0, 0xc4, 0x40, 0x08, 0xfc, 0xfb, 0x0f, 0x04, 0x4a, 0x4a, 0x4a, 0xfd, 0x1d, 0x1d, 0x1d, 0xfd, 0x20, 0x1a, 0xc8, 0xed, 0xff, 0xff, 0x01, 0x8e, 0xff, 0xff, 0x7f, 0xff, 0x4e, 0x49, 0xe9, 0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b, 0x6e, 0x1e, 0xa5, 0x85, 0x89, 0x91, 0xb5, 0xe7, 0x2e, 0xd5, 0xea, 0xb4, 0x4e, 0x5d, 0x98, 0xbb, 0x4a, 0xe7, 0xd2, 0xaa, 0x99, 0xb9, 0x87, 0x4e, 0xdd, 0xba, 0x12, 0x77, 0xef, 0xdd, 0x35, 0x00, 0x34, 0x53, 0x38, 0x01,

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

BIN
demos/squirreldemo.tic Normal file

Binary file not shown.

View File

@ -27,6 +27,7 @@
#define TIC_BUILD_WITH_FENNEL 1
#define TIC_BUILD_WITH_JS 1
#define TIC_BUILD_WITH_WREN 1
#define TIC_BUILD_WITH_SQUIRREL 1
#if defined(__APPLE__)
// TODO: this disables macos config

View File

@ -131,6 +131,11 @@ typedef struct
#if defined(TIC_BUILD_WITH_WREN)
struct WrenVM* wren;
#endif
#if defined(TIC_BUILD_WITH_SQUIRREL)
struct SQVM* squirrel;
#endif
};
struct
@ -171,6 +176,10 @@ s32 drawSpriteFont(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 heig
s32 drawFixedSpriteFont(tic_mem* memory, u8 index, s32 x, s32 y, s32 width, s32 height, u8 chromakey, s32 scale, bool alt);
void parseCode(const tic_script_config* config, const char* start, u8* color, const tic_code_theme* theme);
#if defined(TIC_BUILD_WITH_SQUIRREL)
const tic_script_config* getSquirrelScriptConfig();
#endif
#if defined(TIC_BUILD_WITH_LUA)
const tic_script_config* getLuaScriptConfig();

1606
src/squirrelapi.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -59,6 +59,7 @@
#define PROJECT_MOON_EXT ".moon"
#define PROJECT_JS_EXT ".js"
#define PROJECT_WREN_EXT ".wren"
#define PROJECT_SQUIRREL_EXT ".nut"
typedef enum
{

View File

@ -574,6 +574,10 @@ void tic_close(tic_mem* memory)
machine->state.initialized = false;
#if defined(TIC_BUILD_WITH_SQUIRREL)
getSquirrelScriptConfig()->close(memory);
#endif
#if defined(TIC_BUILD_WITH_LUA)
getLuaScriptConfig()->close(memory);
@ -1619,12 +1623,19 @@ static const tic_script_config* getScriptConfig(const char* code)
return getWrenScriptConfig();
#endif
#if defined(TIC_BUILD_WITH_SQUIRREL)
if (compareMetatag(code, "script", "squirrel", getSquirrelScriptConfig()->singleComment))
return getSquirrelScriptConfig();
#endif
#if defined(TIC_BUILD_WITH_LUA)
return getLuaScriptConfig();
#elif defined(TIC_BUILD_WITH_JS)
return getJsScriptConfig();
#elif defined(TIC_BUILD_WITH_WREN)
return getWrenScriptConfig();
#elif defined(TIC_BUILD_WITH_SQUIRREL)
return getSquirrelScriptConfig();
#endif
}