Skip to content

Instantly share code, notes, and snippets.

@y-ack
Last active June 1, 2022 02:07
Show Gist options
  • Save y-ack/b17cd4a25b673dcfc7303ad8f5c60770 to your computer and use it in GitHub Desktop.
Save y-ack/b17cd4a25b673dcfc7303ad8f5c60770 to your computer and use it in GitHub Desktop.
aifa, try to remember some of the basics of pushback... (pushback accumulator visualization scripts)
-- fbneo (Game > Lua Scripting > New Lua Script Window)
read_u16 = memory.readword
colors = {
meter_insufficient = 0x5080F8FF,
meter_sufficient = 0x58C058FF,
bg_fill = 0x001830C0,
bg_outline = 0xFFFFFF80,
threshold = 0xB1FFEEFF,
text = 0xFFFFFFF0
}
if emu.romname() == "landmakrj" then
PUSHBACK_REQS_ADDR = 0x953d0
else
PUSHBACK_REQS_ADDR = 0x953d0 + 0x400
end
P1_PUSHBACK_TALLY = 0x401fa4 + 0x7c
P2_PUSHBACK_TALLY = 0x40204c + 0x7c
P1_PUSHER_BOARD_OFS = 0x40714c
P2_PUSHER_BOARD_OFS = 0x40714e
GAME_STATE_ADDR = 0x401f74
P1_METER_X = 17
P2_METER_X = 185
METER_Y = 216
METER_HEIGHT = 8
function draw_meter(x,y,value,threshold)
local fill_color = colors.meter_insufficient
if value >= threshold then fill_color = colors.meter_sufficient end
gui.drawbox(x,y,x+117,y+METER_HEIGHT,colors.bg_fill,colors.bg_outline)
gui.drawbox(x,y,x+value+1,y+METER_HEIGHT,fill_color,0x00000000)
gui.drawline(x+threshold+1,y,x+threshold+1,y+METER_HEIGHT,colors.threshold)
gui.drawtext(x+48,y+1,string.format("%2d/%2d",value,threshold), colors.text)
end
function main()
p1_pushback = read_u16(P1_PUSHBACK_TALLY)
p1_pusher = read_u16(P1_PUSHER_BOARD_OFS)
p1_pushback_req = 2 + read_u16(PUSHBACK_REQS_ADDR + (p1_pusher / 16)*2)
p2_pushback = read_u16(P2_PUSHBACK_TALLY)
p2_pusher = read_u16(P2_PUSHER_BOARD_OFS)
p2_pushback_req = 2 + read_u16(PUSHBACK_REQS_ADDR + (p2_pusher / 16)*2)
--
gui.clearuncommitted()
if read_u16(GAME_STATE_ADDR) == 0xFFFF then
draw_meter(P1_METER_X,METER_Y,p1_pushback, p1_pushback_req)
draw_meter(P2_METER_X,METER_Y,p2_pushback, p2_pushback_req)
end
end
gui.register(main)
-- mame (mame -console romname)
cpu = manager.machine.devices[":maincpu"]
mem = cpu.spaces["program"]
gui = manager.machine.screens[":screen"]
colors = {
meter_insufficient = 0xFF5080F8,
meter_sufficient = 0xFF58C058,
bg_fill = 0xC0001830,
bg_outline = 0x80FFFFFF,
threshold = 0xFFB1FFEE,
text = 0xF0FFFFFF
}
if emu.romname() == "landmakrj" then
PUSHBACK_REQS_ADDR = 0x953d0
else
PUSHBACK_REQS_ADDR = 0x953d0 + 0x400
end
P1_PUSHBACK_TALLY = 0x401fa4 + 0x7c
P2_PUSHBACK_TALLY = 0x40204c + 0x7c
P1_PUSHER_BOARD_OFS = 0x40714c
P2_PUSHER_BOARD_OFS = 0x40714e
GAME_STATE_ADDR = 0x401f74
P1_METER_X = 17
P2_METER_X = 185
METER_Y = 216
METER_HEIGHT = 7
function draw_meter(x,y,value,threshold)
local fill_color = colors.meter_insufficient
if value >= threshold then fill_color = colors.meter_sufficient end
gui:draw_box(x,y,x+117,y+METER_HEIGHT,colors.bg_outline,colors.bg_fill)
gui:draw_box(x,y,x+value,y+METER_HEIGHT,0x00000000,fill_color)
gui:draw_line(x+threshold,y,x+threshold,y+METER_HEIGHT,colors.threshold)
gui:draw_text(x+50,y,string.format("%2d/%2d",value,threshold), colors.text)
end
function main()
p1_pushback = mem:read_u16(P1_PUSHBACK_TALLY)
p1_pusher = mem:read_u16(P1_PUSHER_BOARD_OFS)
p1_pushback_req = 2 + mem:read_u16(PUSHBACK_REQS_ADDR + (p1_pusher >> 4)*2)
p2_pushback = mem:read_u16(P2_PUSHBACK_TALLY)
p2_pusher = mem:read_u16(P2_PUSHER_BOARD_OFS)
p2_pushback_req = 2 + mem:read_u16(PUSHBACK_REQS_ADDR + (p2_pusher >> 4)*2)
--
if mem:read_u16(GAME_STATE_ADDR) == 0xFFFF then
draw_meter(P1_METER_X,METER_Y,p1_pushback, p1_pushback_req)
draw_meter(P2_METER_X,METER_Y,p2_pushback, p2_pushback_req)
end
end
emu.register_frame_done(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment