Lua: add emu.framecount and other alternative names of existing functions.
This commit is contained in:
parent
f0a1983112
commit
cc55d175a6
|
@ -470,12 +470,12 @@ static int memory_readbytesigned(lua_State *L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// memory.register(int address, function func)
|
// memory.registerwrite(int address, function func)
|
||||||
//
|
//
|
||||||
// Calls the given function when the indicated memory address is
|
// Calls the given function when the indicated memory address is
|
||||||
// written to. No args are given to the function. The write has already
|
// written to. No args are given to the function. The write has already
|
||||||
// occurred, so the new address is readable.
|
// occurred, so the new address is readable.
|
||||||
static int memory_register(lua_State *L) {
|
static int memory_registerwrite(lua_State *L) {
|
||||||
|
|
||||||
// Check args
|
// Check args
|
||||||
unsigned int addr = luaL_checkinteger(L, 1);
|
unsigned int addr = luaL_checkinteger(L, 1);
|
||||||
|
@ -950,10 +950,10 @@ static int savestate_load(lua_State *L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// int movie.framecount()
|
// int emu.framecount()
|
||||||
//
|
//
|
||||||
// Gets the frame counter for the movie, or nil if no movie running.
|
// Gets the frame counter
|
||||||
int movie_framecount(lua_State *L) {
|
int emu_framecount(lua_State *L) {
|
||||||
|
|
||||||
lua_pushinteger(L, FCEUMOV_GetFrame());
|
lua_pushinteger(L, FCEUMOV_GetFrame());
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1047,19 +1047,19 @@ static int movie_length (lua_State *L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//emu.getreadonly
|
//movie.readonly
|
||||||
//
|
//
|
||||||
//returns true is emulator is in read-only mode, false if it is in read+wrte
|
//returns true is emulator is in read-only mode, false if it is in read+write
|
||||||
static int emu_getreadonly (lua_State *L) {
|
static int movie_getreadonly (lua_State *L) {
|
||||||
lua_pushboolean(L, FCEUI_GetMovieToggleReadOnly());
|
lua_pushboolean(L, FCEUI_GetMovieToggleReadOnly());
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//emu.setreadonly
|
//movie.setreadonly
|
||||||
//
|
//
|
||||||
//Sets readonly / read+write status
|
//Sets readonly / read+write status
|
||||||
static int emu_setreadonly (lua_State *L) {
|
static int movie_setreadonly (lua_State *L) {
|
||||||
bool which = (lua_toboolean( L, 1 ) == 1);
|
bool which = (lua_toboolean( L, 1 ) == 1);
|
||||||
FCEUI_SetMovieToggleReadOnly(which);
|
FCEUI_SetMovieToggleReadOnly(which);
|
||||||
|
|
||||||
|
@ -1198,8 +1198,8 @@ static uint16 gui_getcolour(lua_State *L, int offset) {
|
||||||
two = temp; \
|
two = temp; \
|
||||||
}
|
}
|
||||||
|
|
||||||
// gui.drawpixel(x,y,colour)
|
// gui.pixel(x,y,colour)
|
||||||
static int gui_drawpixel(lua_State *L) {
|
static int gui_pixel(lua_State *L) {
|
||||||
|
|
||||||
int x = luaL_checkinteger(L, 1);
|
int x = luaL_checkinteger(L, 1);
|
||||||
int y = luaL_checkinteger(L,2);
|
int y = luaL_checkinteger(L,2);
|
||||||
|
@ -1216,8 +1216,8 @@ static int gui_drawpixel(lua_State *L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// gui.drawline(x1,y1,x2,y2,type colour)
|
// gui.line(x1,y1,x2,y2,type colour)
|
||||||
static int gui_drawline(lua_State *L) {
|
static int gui_line(lua_State *L) {
|
||||||
|
|
||||||
int x1,y1,x2,y2;
|
int x1,y1,x2,y2;
|
||||||
uint8 colour;
|
uint8 colour;
|
||||||
|
@ -1285,8 +1285,8 @@ static int gui_drawline(lua_State *L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// gui.drawbox(x1, y1, x2, y2, colour)
|
// gui.box(x1, y1, x2, y2, colour)
|
||||||
static int gui_drawbox(lua_State *L) {
|
static int gui_box(lua_State *L) {
|
||||||
|
|
||||||
int x1,y1,x2,y2;
|
int x1,y1,x2,y2;
|
||||||
uint8 colour;
|
uint8 colour;
|
||||||
|
@ -2060,7 +2060,7 @@ static int emu_exec_time(lua_State *L)
|
||||||
static int emu_exec_time(lua_State *L) { return 0; }
|
static int emu_exec_time(lua_State *L) { return 0; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const struct luaL_reg fceulib [] = {
|
static const struct luaL_reg emulib [] = {
|
||||||
|
|
||||||
{"poweron", emu_poweron},
|
{"poweron", emu_poweron},
|
||||||
{"softreset", emu_softreset},
|
{"softreset", emu_softreset},
|
||||||
|
@ -2072,10 +2072,9 @@ static const struct luaL_reg fceulib [] = {
|
||||||
{"exec_time", emu_exec_time},
|
{"exec_time", emu_exec_time},
|
||||||
{"setrenderplanes", emu_setrenderplanes},
|
{"setrenderplanes", emu_setrenderplanes},
|
||||||
{"message", emu_message},
|
{"message", emu_message},
|
||||||
|
{"framecount", emu_framecount},
|
||||||
{"lagcount", emu_lagcount},
|
{"lagcount", emu_lagcount},
|
||||||
{"lagged", emu_lagged},
|
{"lagged", emu_lagged},
|
||||||
{"getreadonly", emu_getreadonly},
|
|
||||||
{"setreadonly", emu_setreadonly},
|
|
||||||
{"registerbefore", emu_registerbefore},
|
{"registerbefore", emu_registerbefore},
|
||||||
{"registerafter", emu_registerafter},
|
{"registerafter", emu_registerafter},
|
||||||
{"registerexit", emu_registerexit},
|
{"registerexit", emu_registerexit},
|
||||||
|
@ -2085,6 +2084,8 @@ static const struct luaL_reg fceulib [] = {
|
||||||
static const struct luaL_reg romlib [] = {
|
static const struct luaL_reg romlib [] = {
|
||||||
{"readbyte", rom_readbyte},
|
{"readbyte", rom_readbyte},
|
||||||
{"readbytesigned", rom_readbytesigned},
|
{"readbytesigned", rom_readbytesigned},
|
||||||
|
// alternate naming scheme for unsigned
|
||||||
|
{"readbyteunsigned", rom_readbyte},
|
||||||
{NULL,NULL}
|
{NULL,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2095,18 +2096,23 @@ static const struct luaL_reg memorylib [] = {
|
||||||
{"readbyterange", memory_readbyterange},
|
{"readbyterange", memory_readbyterange},
|
||||||
{"readbytesigned", memory_readbytesigned},
|
{"readbytesigned", memory_readbytesigned},
|
||||||
{"writebyte", memory_writebyte},
|
{"writebyte", memory_writebyte},
|
||||||
|
// alternate naming scheme for unsigned
|
||||||
|
{"readbyteunsigned", memory_readbyte},
|
||||||
|
|
||||||
{"register", memory_register},
|
// memory hooks
|
||||||
|
{"registerwrite", memory_registerwrite},
|
||||||
|
// alternate names
|
||||||
|
{"register", memory_registerwrite},
|
||||||
|
|
||||||
{NULL,NULL}
|
{NULL,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct luaL_reg joypadlib[] = {
|
static const struct luaL_reg joypadlib[] = {
|
||||||
{"read", joypad_read},
|
|
||||||
{"get", joypad_read},
|
{"get", joypad_read},
|
||||||
{"write", joypad_set},
|
|
||||||
{"set", joypad_set},
|
{"set", joypad_set},
|
||||||
|
// alternative names
|
||||||
|
{"read", joypad_read},
|
||||||
|
{"write", joypad_set},
|
||||||
{NULL,NULL}
|
{NULL,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2117,6 +2123,8 @@ static const struct luaL_reg zapperlib[] = {
|
||||||
|
|
||||||
static const struct luaL_reg inputlib[] = {
|
static const struct luaL_reg inputlib[] = {
|
||||||
{"get", input_get},
|
{"get", input_get},
|
||||||
|
// alternative names
|
||||||
|
{"read", input_get},
|
||||||
{NULL,NULL}
|
{NULL,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2131,18 +2139,24 @@ static const struct luaL_reg savestatelib[] = {
|
||||||
|
|
||||||
static const struct luaL_reg movielib[] = {
|
static const struct luaL_reg movielib[] = {
|
||||||
|
|
||||||
{"framecount", movie_framecount},
|
{"framecount", emu_framecount}, // for those familiar with other emulators that have movie.framecount() instead of emulatorname.framecount()
|
||||||
{"mode", movie_mode},
|
{"mode", movie_mode},
|
||||||
{"rerecordcounting", movie_rerecordcounting},
|
{"rerecordcounting", movie_rerecordcounting},
|
||||||
{"stop", movie_stop},
|
{"stop", movie_stop},
|
||||||
{"active", movie_active},
|
{"active", movie_active},
|
||||||
{"length", movie_length},
|
{"length", movie_length},
|
||||||
{"rerecordcount", movie_rerecordcount},
|
{"rerecordcount", movie_rerecordcount},
|
||||||
{"getname", movie_getname},
|
{"name", movie_getname},
|
||||||
|
{"readonly", movie_getreadonly},
|
||||||
|
{"setreadonly", movie_setreadonly},
|
||||||
{"playbeginning", movie_playbeginning},
|
{"playbeginning", movie_playbeginning},
|
||||||
// {"record", movie_record},
|
// {"record", movie_record},
|
||||||
// {"playback", movie_playback},
|
// {"playback", movie_playback},
|
||||||
|
|
||||||
|
// alternative names
|
||||||
|
{"close", movie_stop},
|
||||||
|
{"getname", movie_getname},
|
||||||
|
{"getreadonly", movie_getreadonly},
|
||||||
{NULL,NULL}
|
{NULL,NULL}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -2150,9 +2164,9 @@ static const struct luaL_reg movielib[] = {
|
||||||
|
|
||||||
static const struct luaL_reg guilib[] = {
|
static const struct luaL_reg guilib[] = {
|
||||||
|
|
||||||
{"drawpixel", gui_drawpixel},
|
{"pixel", gui_pixel},
|
||||||
{"drawline", gui_drawline},
|
{"line", gui_line},
|
||||||
{"drawbox", gui_drawbox},
|
{"box", gui_box},
|
||||||
{"text", gui_text},
|
{"text", gui_text},
|
||||||
|
|
||||||
{"gdscreenshot", gui_gdscreenshot},
|
{"gdscreenshot", gui_gdscreenshot},
|
||||||
|
@ -2162,8 +2176,18 @@ static const struct luaL_reg guilib[] = {
|
||||||
{"register", gui_register},
|
{"register", gui_register},
|
||||||
|
|
||||||
{"popup", gui_popup},
|
{"popup", gui_popup},
|
||||||
|
// alternative names
|
||||||
|
{"drawtext", gui_text},
|
||||||
|
{"drawbox", gui_box},
|
||||||
|
{"drawline", gui_line},
|
||||||
|
{"drawpixel", gui_pixel},
|
||||||
|
{"setpixel", gui_pixel},
|
||||||
|
{"writepixel", gui_pixel},
|
||||||
|
{"rect", gui_box},
|
||||||
|
{"drawrect", gui_box},
|
||||||
|
{"drawimage", gui_gdoverlay},
|
||||||
|
{"image", gui_gdoverlay},
|
||||||
{NULL,NULL}
|
{NULL,NULL}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void HandleCallbackError(lua_State* L)
|
void HandleCallbackError(lua_State* L)
|
||||||
|
@ -2312,8 +2336,8 @@ int FCEU_LoadLuaCode(const char *filename) {
|
||||||
L = lua_open();
|
L = lua_open();
|
||||||
luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
|
|
||||||
luaL_register(L, "emu", fceulib); // added for better cross-emulator compatibility
|
luaL_register(L, "emu", emulib); // added for better cross-emulator compatibility
|
||||||
luaL_register(L, "FCEU", fceulib); // kept for backward compatibility
|
luaL_register(L, "FCEU", emulib); // kept for backward compatibility
|
||||||
luaL_register(L, "memory", memorylib);
|
luaL_register(L, "memory", memorylib);
|
||||||
luaL_register(L, "rom", romlib);
|
luaL_register(L, "rom", romlib);
|
||||||
luaL_register(L, "joypad", joypadlib);
|
luaL_register(L, "joypad", joypadlib);
|
||||||
|
|
Loading…
Reference in New Issue