Created
December 31, 2016 06:11
-
-
Save taotao54321/182914486479fe175c9ef96242c5da3c to your computer and use it in GitHub Desktop.
NES Star Soldier (J) hitbox display for FCEUX
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
---------------------------------------------------------------------- | |
-- NES Star Soldier (J) hitbox display for FCEUX | |
---------------------------------------------------------------------- | |
---------------------------------------------------------------------- | |
-- util | |
---------------------------------------------------------------------- | |
local function array_append(ary, o) | |
ary[#ary+1] = o | |
end | |
local function mem_read_u8(addr) | |
return memory.readbyte(addr) | |
end | |
---------------------------------------------------------------------- | |
-- main | |
---------------------------------------------------------------------- | |
local OBJ_N = 24 | |
local BULLET_N = 8 | |
local SHOT_N = 15 | |
local HERO_HIT_OBJ = 14 | |
local HERO_HIT_BULLET = 12 | |
local OBJ_HIT_OBJ = 14 | |
local OBJ_HIT_SHOT = 12 | |
local BULLET_HIT = 6 | |
local SHOT_HIT = 6 | |
local COLOR_HERO_OBJ = "#00FFFF" | |
local COLOR_HERO_BULLET = "#FFFF00" | |
local COLOR_OBJ_OBJ = "#00FFFF" | |
local COLOR_OBJ_SHOT = "#FFFF00" | |
local COLOR_BULLET = "#FFFF00" | |
local COLOR_SHOT = "#00FF00" | |
local function get_info() | |
local info = {} | |
info.hero_x = mem_read_u8(0x3A) | |
info.hero_y = mem_read_u8(0x3B) | |
info.objs = {} | |
for i = 1, OBJ_N do | |
if mem_read_u8(0x0400+i-1) ~= 0 then | |
local obj = {} | |
obj.x = mem_read_u8(0x0418+i-1) | |
obj.y = mem_read_u8(0x0430+i-1) | |
array_append(info.objs, obj) | |
end | |
end | |
info.bullets = {} | |
for i = 1, BULLET_N do | |
if mem_read_u8(0x0648+i-1) ~= 0 then | |
local bullet = {} | |
bullet.x = mem_read_u8(0x0650+i-1) | |
bullet.y = mem_read_u8(0x0658+i-1) | |
array_append(info.bullets, bullet) | |
end | |
end | |
info.shots = {} | |
for i = 1, SHOT_N do | |
if mem_read_u8(0x061B+i-1) ~= 0 then | |
local shot = {} | |
shot.x = mem_read_u8(0x062A+i-1) | |
shot.y = mem_read_u8(0x0639+i-1) | |
array_append(info.shots, shot) | |
end | |
end | |
return info | |
end | |
local function square(x, y, l, color) | |
gui.drawbox(x, y, x+l, y+l, "clear", color) | |
end | |
local function draw() | |
local info = get_info() | |
square(info.hero_x, info.hero_y, HERO_HIT_BULLET, COLOR_HERO_BULLET) | |
square(info.hero_x, info.hero_y, HERO_HIT_OBJ, COLOR_HERO_OBJ) | |
for _, obj in ipairs(info.objs) do | |
square(obj.x, obj.y, OBJ_HIT_SHOT, COLOR_OBJ_SHOT) | |
square(obj.x, obj.y, OBJ_HIT_OBJ, COLOR_OBJ_OBJ) | |
end | |
for _, bullet in ipairs(info.bullets) do | |
square(bullet.x, bullet.y, BULLET_HIT, COLOR_BULLET) | |
end | |
for _, shot in ipairs(info.shots) do | |
square(shot.x, shot.y, SHOT_HIT, COLOR_SHOT) | |
end | |
end | |
local function main() | |
emu.registerafter(draw) | |
end | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment