Special functions should have common formatting #503
This commit is contained in:
parent
607515947c
commit
e0cc606d2c
14
src/jsapi.c
14
src/jsapi.c
|
@ -899,14 +899,12 @@ static void callJavascriptTick(tic_mem* tic)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void callJavascriptScanline(tic_mem* memory, s32 row, void* data)
|
static void callJavascriptScanlineName(tic_mem* memory, s32 row, void* data, const char* name)
|
||||||
{
|
{
|
||||||
tic_machine* machine = (tic_machine*)memory;
|
tic_machine* machine = (tic_machine*)memory;
|
||||||
duk_context* duk = machine->js;
|
duk_context* duk = machine->js;
|
||||||
|
|
||||||
const char* ScanlineFunc = ApiKeywords[1];
|
if(duk_get_global_string(duk, name))
|
||||||
|
|
||||||
if(duk_get_global_string(duk, ScanlineFunc))
|
|
||||||
{
|
{
|
||||||
duk_push_int(duk, row);
|
duk_push_int(duk, row);
|
||||||
|
|
||||||
|
@ -917,6 +915,14 @@ static void callJavascriptScanline(tic_mem* memory, s32 row, void* data)
|
||||||
duk_pop(duk);
|
duk_pop(duk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void callJavascriptScanline(tic_mem* memory, s32 row, void* data)
|
||||||
|
{
|
||||||
|
callJavascriptScanlineName(memory, row, data, ApiKeywords[1]);
|
||||||
|
|
||||||
|
// try to call old scanline
|
||||||
|
callJavascriptScanlineName(memory, row, data, "scanline");
|
||||||
|
}
|
||||||
|
|
||||||
static void callJavascriptOverlap(tic_mem* memory, void* data)
|
static void callJavascriptOverlap(tic_mem* memory, void* data)
|
||||||
{
|
{
|
||||||
tic_machine* machine = (tic_machine*)memory;
|
tic_machine* machine = (tic_machine*)memory;
|
||||||
|
|
16
src/luaapi.c
16
src/luaapi.c
|
@ -1335,17 +1335,15 @@ static void callLuaTick(tic_mem* tic)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void callLuaScanline(tic_mem* memory, s32 row, void* data)
|
static void callLuaScanlineName(tic_mem* memory, s32 row, void* data, const char* name)
|
||||||
{
|
{
|
||||||
tic_machine* machine = (tic_machine*)memory;
|
tic_machine* machine = (tic_machine*)memory;
|
||||||
lua_State* lua = machine->lua;
|
lua_State* lua = machine->lua;
|
||||||
|
|
||||||
if (lua)
|
if (lua)
|
||||||
{
|
{
|
||||||
const char* ScanlineFunc = ApiKeywords[1];
|
lua_getglobal(lua, name);
|
||||||
|
if(lua_isfunction(lua, -1))
|
||||||
lua_getglobal(lua, ScanlineFunc);
|
|
||||||
if(lua_isfunction(lua, -1))
|
|
||||||
{
|
{
|
||||||
lua_pushinteger(lua, row);
|
lua_pushinteger(lua, row);
|
||||||
if(lua_pcall(lua, 1, 0, 0) != LUA_OK)
|
if(lua_pcall(lua, 1, 0, 0) != LUA_OK)
|
||||||
|
@ -1355,6 +1353,14 @@ static void callLuaScanline(tic_mem* memory, s32 row, void* data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void callLuaScanline(tic_mem* memory, s32 row, void* data)
|
||||||
|
{
|
||||||
|
callLuaScanlineName(memory, row, data, ApiKeywords[1]);
|
||||||
|
|
||||||
|
// try to call old scanline
|
||||||
|
callLuaScanlineName(memory, row, data, "scanline");
|
||||||
|
}
|
||||||
|
|
||||||
static void callLuaOverlap(tic_mem* memory, void* data)
|
static void callLuaOverlap(tic_mem* memory, void* data)
|
||||||
{
|
{
|
||||||
tic_machine* machine = (tic_machine*)memory;
|
tic_machine* machine = (tic_machine*)memory;
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#define SFX_DEF_SPEED (1 << SFX_SPEED_BITS)
|
#define SFX_DEF_SPEED (1 << SFX_SPEED_BITS)
|
||||||
|
|
||||||
#define API_KEYWORDS {"TIC", "scanline", "OVR", "print", "cls", "pix", "line", "rect", "rectb", \
|
#define API_KEYWORDS {"TIC", "SCN", "OVR", "print", "cls", "pix", "line", "rect", "rectb", \
|
||||||
"spr", "btn", "btnp", "sfx", "map", "mget", "mset", "peek", "poke", "peek4", "poke4", \
|
"spr", "btn", "btnp", "sfx", "map", "mget", "mset", "peek", "poke", "peek4", "poke4", \
|
||||||
"memcpy", "memset", "trace", "pmem", "time", "exit", "font", "mouse", "circ", "circb", "tri", "textri", \
|
"memcpy", "memset", "trace", "pmem", "time", "exit", "font", "mouse", "circ", "circb", "tri", "textri", \
|
||||||
"clip", "music", "sync", "reset", "key", "keyp"}
|
"clip", "music", "sync", "reset", "key", "keyp"}
|
||||||
|
|
Loading…
Reference in New Issue