Created
January 22, 2022 03:17
-
-
Save karmic64/4ac064fc34828cf9b4e9d055089422d3 to your computer and use it in GitHub Desktop.
Xevious (NES) Mesen Lua script that shows bombable objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- xevious NES Mesen "show bombable objects" Lua script | |
-- coded by karmic, july 10 2021 | |
-- slightly improved jan 21 2022 | |
function read(addr) | |
return emu.read(addr, emu.memType.cpuDebug) | |
end | |
function readbeword(addr) | |
lo = read(addr+1) | |
hi = read(addr) | |
comb = lo | (hi << 8) | |
if hi >= 0x80 then | |
return 0 - ((comb ~ 0xffff) + 1) | |
else | |
return comb | |
end | |
end | |
function drawrect(x, y, width, height, color) | |
emu.drawRectangle(x, y, width, height, color, false, 0) | |
end | |
function main() | |
emu.clearScreen() | |
-- game must be in main game mode | |
if read(0x10) ~= 2 then return end | |
-- magenta, moving enemies | |
for obj = 0,7 do | |
if read(0x500 + (obj*0x10)) ~= 0 then | |
x = read(0x504 + (obj*0x10)) | |
y = readbeword(0x506 + (obj*0x10)) + 1 | |
drawrect(x, y, 0x10, 0x10, 0xff00ff) | |
end | |
end | |
-- cyan, stationary and hidden targets | |
for obj = 0,0x0f do | |
if read(0x300 + (obj*0x8)) ~= 0 then | |
x = read(0x303 + (obj*0x8)) | |
y = readbeword(0x301 + (obj*0x8)) + 1 | |
drawrect(x, y, 0x10, 0x10, 0x00ffff) | |
end | |
end | |
end | |
emu.addEventCallback(main, emu.eventType.startFrame) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment