From 45848c7591dbcf165d7ca3090fd54cc2fcd0ef0c Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 27 Jul 2010 03:40:59 +0000 Subject: [PATCH] emulua: add rom.gethash --- src/lua-engine.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index a678d63e..ae00397d 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -1199,6 +1199,13 @@ void CallRegisteredLuaLoadFunctions(int savestateNumber, const LuaSaveData& save static int rom_readbyte(lua_State *L) { lua_pushinteger(L, FCEU_ReadRomByte(luaL_checkinteger(L,1))); return 1; } static int rom_readbytesigned(lua_State *L) { lua_pushinteger(L, (signed char)FCEU_ReadRomByte(luaL_checkinteger(L,1))); return 1; } +static int rom_gethash(lua_State *L) { + const char *type = luaL_checkstring(L, 1); + if(!type) lua_pushstring(L, ""); + else if(!stricmp(type,"md5")) lua_pushstring(L, md5_asciistr(GameInfo->MD5)); + else lua_pushstring(L, ""); + return 1; +} static int memory_readbyte(lua_State *L) { lua_pushinteger(L, FCEU_CheatGetByte(luaL_checkinteger(L,1))); return 1; } static int memory_writebyte(lua_State *L) { FCEU_CheatSetByte(luaL_checkinteger(L,1), luaL_checkinteger(L,2)); return 0; } static int memory_readbyterange(lua_State *L) { @@ -4672,6 +4679,8 @@ static const struct luaL_reg romlib [] = { {"readbytesigned", rom_readbytesigned}, // alternate naming scheme for unsigned {"readbyteunsigned", rom_readbyte}, + + {"gethash", rom_gethash}, {NULL,NULL} };