add lua functions emu.gamecode and emu.smallgamecode for game-specific hacks in scripts

re #130
This commit is contained in:
zeromus 2018-10-31 21:29:06 -04:00
parent 56895a11aa
commit ad7b80ec87
1 changed files with 14 additions and 1 deletions

View File

@ -1759,7 +1759,18 @@ DEFINE_LUA_FUNCTION(emu_frameadvance, "")
return StepEmulationAtSpeed(L, info.speedMode, true); return StepEmulationAtSpeed(L, info.speedMode, true);
} }
DEFINE_LUA_FUNCTION(emu_gamecode, "")
{
char tmp[5] = {gameInfo.header.gameCode[0],gameInfo.header.gameCode[1],gameInfo.header.gameCode[2],gameInfo.header.gameCode[3],0};
lua_pushstring(L,tmp);
return 1;
}
DEFINE_LUA_FUNCTION(emu_smallgamecode, "")
{
char tmp[4] = {gameInfo.header.gameCode[0],gameInfo.header.gameCode[1],gameInfo.header.gameCode[2],0};
lua_pushstring(L,tmp);
return 1;
}
DEFINE_LUA_FUNCTION(emu_pause, "") DEFINE_LUA_FUNCTION(emu_pause, "")
{ {
driver->EMU_PauseEmulation(true); driver->EMU_PauseEmulation(true);
@ -4798,6 +4809,8 @@ static const struct luaL_reg styluslib [] =
static const struct luaL_reg emulib [] = static const struct luaL_reg emulib [] =
{ {
{"frameadvance", emu_frameadvance}, {"frameadvance", emu_frameadvance},
{"gamecode", emu_gamecode},
{"smallgamecode", emu_smallgamecode},
{"speedmode", emu_speedmode}, {"speedmode", emu_speedmode},
{"wait", emu_wait}, {"wait", emu_wait},
{"pause", emu_pause}, {"pause", emu_pause},