Okay! So after some checking, I've figured out this must be the place to post my first post on this forum. I couldn't find the answer anywhere so here goes.
I'm running the BizHawk version 1.12.0 and emulating Sonic The Hedgehog for Genesis. At the moment my goal is to always force Sonic to face left, despite the input of left and right. There is but one hinch in my plan as of yet that bugs me, the fact that he is not consistently facing left.
After some thinking and digging I've concluded that it's because it's updating after I've written to memory. But before the frame is emulated, I therefore tried using emu.registerbefore() to fix this...
So first of all I should probably ask: will it actually fix it? If so, I'll have to ask what is wrong, because I cannot for the life of me get it to work. I'm starting to think that the emulator does not support it? This is the error message I get:
LuaInterface.LuaScriptException: [string "main"]:5: attempt to call field 'registerbefore' (a nil value)
It does not happen if I put it after the while true loop (but then again I suppose it never runs then)
Here is the code (feel free to ignore the updateSonicFacing() in the while loop, but it's there to represent my earlier attempt)
Language: lua
local function updateSonicFacing()
memory.writebyte(0xFFD022, bit.bor(memory.readbyte(0xFFD022), 0x01))
end
emu.registerbefore(updateSonicFacing)
--Here it begins
memory.writebyte(0xFFFE1C, 0x1) -- Allows lives to be set
local timer = 60
while true do
-- Forces 4 lives
if memory.readbyte(0xFFFE12) < 0x4 then
memory.writebyte(0xFFFE12, 0x4)
end
updateSonicFacing()
timer = timer - 1
emu.frameadvance()
end