MCPcopy Create free account
hub / github.com/TASEmulators/fceux / memory_getregister

Function memory_getregister

src/lua-engine.cpp:2000–2031  ·  view source on GitHub ↗

DEFINE_LUA_FUNCTION(memory_getregister, "cpu_dot_registername_string")

Source from the content-addressed store, hash-verified

1998
1999//DEFINE_LUA_FUNCTION(memory_getregister, "cpu_dot_registername_string")
2000static int memory_getregister(lua_State *L)
2001{
2002 const char* qualifiedRegisterName = luaL_checkstring(L,1);
2003 lua_settop(L,0);
2004 for(size_t cpu = 0; cpu < sizeof(cpuToRegisterMaps)/sizeof(*cpuToRegisterMaps); cpu++)
2005 {
2006 cpuToRegisterMap ctrm = cpuToRegisterMaps[cpu];
2007 int cpuNameLen = strlen(ctrm.cpuName);
2008 if(!strnicmp(qualifiedRegisterName, ctrm.cpuName, cpuNameLen))
2009 {
2010 qualifiedRegisterName += cpuNameLen;
2011 for(int reg = 0; ctrm.rpmap[reg].dataSize; reg++)
2012 {
2013 registerPointerMap rpm = ctrm.rpmap[reg];
2014 if(!stricmp(qualifiedRegisterName, rpm.registerName))
2015 {
2016 switch(rpm.dataSize)
2017 { default:
2018 case 1: lua_pushinteger(L, *(unsigned char*)rpm.pointer); break;
2019 case 2: lua_pushinteger(L, *(unsigned short*)rpm.pointer); break;
2020 case 4: lua_pushinteger(L, *(unsigned long*)rpm.pointer); break;
2021 }
2022 return 1;
2023 }
2024 }
2025 lua_pushnil(L);
2026 return 1;
2027 }
2028 }
2029 lua_pushnil(L);
2030 return 1;
2031}
2032//DEFINE_LUA_FUNCTION(memory_setregister, "cpu_dot_registername_string,value")
2033static int memory_setregister(lua_State *L)
2034{

Callers

nothing calls this directly

Calls 3

lua_settopFunction · 0.85
lua_pushintegerFunction · 0.85
lua_pushnilFunction · 0.85

Tested by

no test coverage detected