Merge branch 'master' into sdl_extract
This commit is contained in:
@@ -46,6 +46,7 @@ typedef enum
|
||||
LuaScript,
|
||||
MoonScript,
|
||||
JavaScript,
|
||||
WrenScript,
|
||||
} ScriptLang;
|
||||
|
||||
#if defined(__WINDOWS__) || defined(__LINUX__) || defined(__MACOSX__)
|
||||
@@ -73,6 +74,7 @@ static const char* ExeExt = ".exe";
|
||||
static const char DefaultLuaTicPath[] = TIC_LOCAL "default.tic";
|
||||
static const char DefaultMoonTicPath[] = TIC_LOCAL "default_moon.tic";
|
||||
static const char DefaultJSTicPath[] = TIC_LOCAL "default_js.tic";
|
||||
static const char DefaultWrenTicPath[] = TIC_LOCAL "default_wren.tic";
|
||||
|
||||
static const char* getName(const char* name, const char* ext)
|
||||
{
|
||||
@@ -417,7 +419,10 @@ static void* getDemoCart(Console* console, ScriptLang script, s32* size)
|
||||
strcpy(path, DefaultMoonTicPath);
|
||||
break;
|
||||
case JavaScript:
|
||||
strcpy(path, DefaultJSTicPath);
|
||||
strcpy(path, DefaultJSTicPath);
|
||||
break;
|
||||
case WrenScript:
|
||||
strcpy(path, DefaultWrenTicPath);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -442,6 +447,11 @@ static void* getDemoCart(Console* console, ScriptLang script, s32* size)
|
||||
#include "../bin/assets/moondemo.tic.dat"
|
||||
};
|
||||
|
||||
static const u8 WrenDemoRom[] =
|
||||
{
|
||||
#include "../bin/assets/wrendemo.tic.dat"
|
||||
};
|
||||
|
||||
const u8* demo = NULL;
|
||||
s32 romSize = 0;
|
||||
|
||||
@@ -459,6 +469,10 @@ static void* getDemoCart(Console* console, ScriptLang script, s32* size)
|
||||
demo = JsDemoRom;
|
||||
romSize = sizeof JsDemoRom;
|
||||
break;
|
||||
case WrenScript:
|
||||
demo = WrenDemoRom;
|
||||
romSize = sizeof WrenDemoRom;
|
||||
break;
|
||||
}
|
||||
|
||||
u8* data = NULL;
|
||||
@@ -491,6 +505,8 @@ static void onConsoleLoadDemoCommandConfirmed(Console* console, const char* para
|
||||
data = getDemoCart(console, MoonScript, &size);
|
||||
else if(strcmp(param, DefaultJSTicPath) == 0)
|
||||
data = getDemoCart(console, JavaScript, &size);
|
||||
else if(strcmp(param, DefaultWrenTicPath) == 0)
|
||||
data = getDemoCart(console, WrenScript, &size);
|
||||
|
||||
const char* name = getCartName(param);
|
||||
|
||||
@@ -530,12 +546,12 @@ static bool hasExt(const char* name, const char* ext)
|
||||
|
||||
static bool hasProjectExt(const char* name)
|
||||
{
|
||||
return hasExt(name, PROJECT_LUA_EXT) || hasExt(name, PROJECT_MOON_EXT) || hasExt(name, PROJECT_JS_EXT);
|
||||
return hasExt(name, PROJECT_LUA_EXT) || hasExt(name, PROJECT_MOON_EXT) || hasExt(name, PROJECT_JS_EXT) || hasExt(name, PROJECT_WREN_EXT);
|
||||
}
|
||||
|
||||
static const char* projectComment(const char* name)
|
||||
{
|
||||
return hasExt(name, PROJECT_JS_EXT) ? "//" : "--";
|
||||
return hasExt(name, PROJECT_JS_EXT) || hasExt(name, PROJECT_WREN_EXT) ? "//" : "--";
|
||||
}
|
||||
|
||||
static void buf2str(const void* data, s32 size, char* ptr, bool flip)
|
||||
@@ -925,6 +941,9 @@ static void onConsoleLoadCommandConfirmed(Console* console, const char* param)
|
||||
if(!fsExistsFile(console->fs, name))
|
||||
name = getName(param, PROJECT_JS_EXT);
|
||||
|
||||
if(!fsExistsFile(console->fs, name))
|
||||
name = getName(param, PROJECT_WREN_EXT);
|
||||
|
||||
void* data = fsLoadFile(console->fs, name, &size);
|
||||
|
||||
if(data)
|
||||
@@ -1053,6 +1072,8 @@ static void onConsoleNewCommandConfirmed(Console* console, const char* param)
|
||||
loadDemo(console, MoonScript);
|
||||
else if(strcmp(param, "js") == 0 || strcmp(param, "javascript") == 0)
|
||||
loadDemo(console, JavaScript);
|
||||
else if(strcmp(param, "wren") == 0)
|
||||
loadDemo(console, WrenScript);
|
||||
else
|
||||
{
|
||||
printError(console, "\nunknown parameter: ");
|
||||
@@ -1317,6 +1338,10 @@ static void onConsoleConfigCommand(Console* console, const char* param)
|
||||
{
|
||||
onConsoleLoadDemoCommand(console, DefaultJSTicPath);
|
||||
}
|
||||
else if(strcmp(param, "default wren") == 0)
|
||||
{
|
||||
onConsoleLoadDemoCommand(console, DefaultWrenTicPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
printError(console, "\nunknown parameter: ");
|
||||
|
||||
@@ -28,7 +28,11 @@
|
||||
|
||||
#define SFX_DEF_SPEED (1 << SFX_SPEED_BITS)
|
||||
|
||||
#define API_KEYWORDS {"TIC", "SCN", "OVR", "print", "cls", "pix", "line", "rect", "rectb", \
|
||||
#define TIC_FN "TIC"
|
||||
#define SCN_FN "SCN"
|
||||
#define OVR_FN "OVR"
|
||||
|
||||
#define API_KEYWORDS {TIC_FN, SCN_FN, OVR_FN, "print", "cls", "pix", "line", "rect", "rectb", \
|
||||
"spr", "btn", "btnp", "sfx", "map", "mget", "mset", "peek", "poke", "peek4", "poke4", \
|
||||
"memcpy", "memset", "trace", "pmem", "time", "exit", "font", "mouse", "circ", "circb", "tri", "textri", \
|
||||
"clip", "music", "sync", "reset", "key", "keyp"}
|
||||
@@ -121,6 +125,7 @@ typedef struct
|
||||
{
|
||||
struct duk_hthread* js;
|
||||
struct lua_State* lua;
|
||||
struct WrenVM* wren;
|
||||
};
|
||||
|
||||
blip_buffer_t* blip;
|
||||
@@ -159,3 +164,4 @@ void parseCode(const tic_script_config* config, const char* start, u8* color, co
|
||||
const tic_script_config* getLuaScriptConfig();
|
||||
const tic_script_config* getMoonScriptConfig();
|
||||
const tic_script_config* getJsScriptConfig();
|
||||
const tic_script_config* getWrenScriptConfig();
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
#define PROJECT_LUA_EXT ".lua"
|
||||
#define PROJECT_MOON_EXT ".moon"
|
||||
#define PROJECT_JS_EXT ".js"
|
||||
#define PROJECT_WREN_EXT ".wren"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
@@ -395,6 +395,7 @@ static bool addMenuItem(const char* name, const char* info, s32 id, void* ptr, b
|
||||
|| hasExt(name, PROJECT_LUA_EXT)
|
||||
|| hasExt(name, PROJECT_MOON_EXT)
|
||||
|| hasExt(name, PROJECT_JS_EXT)
|
||||
|| hasExt(name, PROJECT_WREN_EXT)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
|
||||
@@ -561,6 +561,7 @@ void tic_close(tic_mem* memory)
|
||||
getLuaScriptConfig()->close(memory);
|
||||
getMoonScriptConfig()->close(memory);
|
||||
getJsScriptConfig()->close(memory);
|
||||
getWrenScriptConfig()->close(memory);
|
||||
|
||||
blip_delete(machine->blip);
|
||||
|
||||
@@ -1528,10 +1529,16 @@ static bool isJavascript(const char* code)
|
||||
|| compareMetatag(code, "script", "javascript", getJsScriptConfig()->singleComment);
|
||||
}
|
||||
|
||||
static bool isWren(const char* code)
|
||||
{
|
||||
return compareMetatag(code, "script", "wren", getWrenScriptConfig()->singleComment);
|
||||
}
|
||||
|
||||
static const tic_script_config* getScriptConfig(const char* code)
|
||||
{
|
||||
if(isMoonscript(code)) return getMoonScriptConfig();
|
||||
if(isJavascript(code)) return getJsScriptConfig();
|
||||
if(isWren(code)) return getWrenScriptConfig();
|
||||
return getLuaScriptConfig();
|
||||
}
|
||||
|
||||
|
||||
1370
src/wrenapi.c
Normal file
1370
src/wrenapi.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user