Merge branch 'squirrel'

This commit is contained in:
Vadim Grigoruk 2018-10-18 10:01:32 +03:00
commit 52b77e7e87
2 changed files with 53 additions and 6 deletions

View File

@ -137,7 +137,7 @@ target_include_directories(wren PRIVATE 3rd-party/wren-0.1.0/src/vm)
# SQUIRREL # SQUIRREL
################################ ################################
set(SQUIRREL_DIR 3rd-party/squirrel3.1) set(SQUIRREL_DIR 3rd-party/squirrel)
set(SQUIRREL_SRC set(SQUIRREL_SRC
${SQUIRREL_DIR}/squirrel/sqapi.cpp ${SQUIRREL_DIR}/squirrel/sqapi.cpp
${SQUIRREL_DIR}/squirrel/sqbaselib.cpp ${SQUIRREL_DIR}/squirrel/sqbaselib.cpp
@ -163,9 +163,9 @@ set(SQUIRREL_SRC
add_library(squirrel STATIC ${SQUIRREL_SRC}) add_library(squirrel STATIC ${SQUIRREL_SRC})
set_target_properties(squirrel PROPERTIES LINKER_LANGUAGE CXX) 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/squirrel/include)
target_include_directories(squirrel PRIVATE 3rd-party/squirrel3.1/squirrel) target_include_directories(squirrel PRIVATE 3rd-party/squirrel/squirrel)
target_include_directories(squirrel PRIVATE 3rd-party/squirrel3.1/sqstdlib) target_include_directories(squirrel PRIVATE 3rd-party/squirrel/sqstdlib)
################################ ################################
# GIFLIB # GIFLIB
@ -210,7 +210,7 @@ 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/lua-5.3.1/src)
target_include_directories(tic80core PRIVATE 3rd-party/giflib-5.1.4/lib) 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/wren-0.1.0/src/include)
target_include_directories(tic80core PRIVATE 3rd-party/squirrel3.1/include) target_include_directories(tic80core PRIVATE 3rd-party/squirrel/include)
target_include_directories(tic80core PRIVATE 3rd-party/moonscript) target_include_directories(tic80core PRIVATE 3rd-party/moonscript)
target_include_directories(tic80core PRIVATE 3rd-party/fennel) target_include_directories(tic80core PRIVATE 3rd-party/fennel)

View File

@ -73,6 +73,10 @@ typedef enum
WrenScript, WrenScript,
#endif #endif
#if defined(TIC_BUILD_WITH_SQUIRREL)
SquirrelScript,
#endif
} ScriptLang; } ScriptLang;
#if defined(__TIC_WINDOWS__) || defined(__TIC_LINUX__) || defined(__TIC_MACOSX__) #if defined(__TIC_WINDOWS__) || defined(__TIC_LINUX__) || defined(__TIC_MACOSX__)
@ -119,6 +123,9 @@ static const char DefaultJSTicPath[] = TIC_LOCAL "default_js.tic";
static const char DefaultWrenTicPath[] = TIC_LOCAL "default_wren.tic"; static const char DefaultWrenTicPath[] = TIC_LOCAL "default_wren.tic";
#endif #endif
#if defined(TIC_BUILD_WITH_SQUIRREL)
static const char DefaultSquirrelTicPath[] = TIC_LOCAL "default_squirrel.tic";
#endif
static const char* getName(const char* name, const char* ext) static const char* getName(const char* name, const char* ext)
{ {
@ -486,6 +493,10 @@ static void* getDemoCart(Console* console, ScriptLang script, s32* size)
#if defined(TIC_BUILD_WITH_WREN) #if defined(TIC_BUILD_WITH_WREN)
case WrenScript: strcpy(path, DefaultWrenTicPath); break; case WrenScript: strcpy(path, DefaultWrenTicPath); break;
#endif #endif
#if defined(TIC_BUILD_WITH_SQUIRREL)
case SquirrelScript: strcpy(path, DefaultSquirrelTicPath); break;
#endif
} }
void* data = fsLoadRootFile(console->fs, path, size); void* data = fsLoadRootFile(console->fs, path, size);
@ -570,6 +581,20 @@ static void* getDemoCart(Console* console, ScriptLang script, s32* size)
} }
break; break;
#endif #endif
#if defined(TIC_BUILD_WITH_SQUIRREL)
case SquirrelScript:
{
static const u8 SquirrelDemoRom[] =
{
#include "../bin/assets/squirreldemo.tic.dat"
};
demo = SquirrelDemoRom;
romSize = sizeof SquirrelDemoRom;
}
break;
#endif
} }
u8* data = NULL; u8* data = NULL;
@ -622,6 +647,11 @@ static void onConsoleLoadDemoCommandConfirmed(Console* console, const char* para
data = getDemoCart(console, WrenScript, &size); data = getDemoCart(console, WrenScript, &size);
#endif #endif
#if defined(TIC_BUILD_WITH_SQUIRREL)
if(strcmp(param, DefaultSquirrelTicPath) == 0)
data = getDemoCart(console, SquirrelScript, &size);
#endif
const char* name = getCartName(param); const char* name = getCartName(param);
setCartName(console, name); setCartName(console, name);
@ -1228,6 +1258,14 @@ static void onConsoleNewCommandConfirmed(Console* console, const char* param)
} }
#endif #endif
#if defined(TIC_BUILD_WITH_SQUIRREL)
if(strcmp(param, "squirrel") == 0)
{
loadDemo(console, SquirrelScript);
done = true;
}
#endif
if(!done) if(!done)
{ {
printError(console, "\nunknown parameter: "); printError(console, "\nunknown parameter: ");
@ -1526,6 +1564,13 @@ static void onConsoleConfigCommand(Console* console, const char* param)
} }
#endif #endif
#if defined(TIC_BUILD_WITH_SQUIRREL)
else if(strcmp(param, "default squirrel") == 0)
{
onConsoleLoadDemoCommand(console, DefaultSquirrelTicPath);
}
#endif
else else
{ {
printError(console, "\nunknown parameter: "); printError(console, "\nunknown parameter: ");
@ -2738,6 +2783,8 @@ static void tick(Console* console)
loadDemo(console, JavaScript); loadDemo(console, JavaScript);
#elif defined(TIC_BUILD_WITH_WREN) #elif defined(TIC_BUILD_WITH_WREN)
loadDemo(console, WrenScript); loadDemo(console, WrenScript);
#elif defined(TIC_BUILD_WITH_SQUIRREL)
loadDemo(console, SquirrelScript);
#endif #endif
printBack(console, "\n hello! type "); printBack(console, "\n hello! type ");