diff --git a/Lua/boilerplate.lua b/Lua/boilerplate.lua index 50c02d4..6e47f28 100755 --- a/Lua/boilerplate.lua +++ b/Lua/boilerplate.lua @@ -27,23 +27,24 @@ if bizstring then else local unimplemented = function() error('unimplemented', 2) end local ram = 0x80000000 + local rom = 0x90000000 -- might be wrong for upper 32MB of 64MB roms? R1 = function(addr) return m64p.memory:read(addr+ram, 'u8') end R2 = function(addr) return m64p.memory:read(addr+ram, 'u16') end R3 = unimplemented R4 = function(addr) return m64p.memory:read(addr+ram, 'u32') end - RF = function(addr) return m64p.memory.read(addr+ram, 'float') end + RF = function(addr) return m64p.memory:read(addr+ram, 'float') end W1 = function(addr, value) m64p.memory:write(addr+ram, 'u8', value) end W2 = function(addr, value) m64p.memory:write(addr+ram, 'u16', value) end W3 = unimplemented W4 = function(addr, value) m64p.memory:write(addr+ram, 'u32', value) end - WF = function(addr, value) m64p.memory.write(addr+ram, 'float', value) end + WF = function(addr, value) m64p.memory:write(addr+ram, 'float', value) end - X1 = unimplemented - X2 = unimplemented + X1 = function(addr) return m64p.memory:read(addr+rom, 'u8') end + X2 = function(addr) return m64p.memory:read(addr+rom, 'u16') end X3 = unimplemented - X4 = unimplemented - XF = unimplemented + X4 = function(addr) return m64p.memory:read(addr+rom, 'u32') end + XF = function(addr) return m64p.memory:read(addr+rom, 'float') end end local H1 = function(self, value) @@ -129,6 +130,10 @@ end function hex(i) -- convenience function for use in console + if i == nil then + print('nil') + return + end if i > 0xFFFFFFFF then print('warning: truncated') end diff --git a/Lua/oneshot.lua b/Lua/oneshot.lua index b9bf41d..6a00aa5 100755 --- a/Lua/oneshot.lua +++ b/Lua/oneshot.lua @@ -84,7 +84,11 @@ else -- great spin attack -- this one's a bit odd; it goes off an event flag local addr = a.week_event_reg.addr + 23 - W1(addr, bit.bor(R1(addr), 0x02)) + if bit then + W1(addr, bit.bor(R1(addr), 0x02)) + else + W1(addr, R1(addr) | 0x02) + end end set(a.magic_level, 2)