User File #637843303974403704

Upload All User Files

#637843303974403704 - Skipp and Friends Status Display

Skipp_status_display.lua
126 downloads
Uploaded 3/31/2022 1:33 PM by Dacicus (see all 26)
Shows some useful information on screen.
local addr_sk_hp, addr_we_hp, addr_ap_hp = 0x8B, 0x8C, 0x8D

local addr_sk_fly, addr_sk_boom = 0x8E, 0x91
local addr_we_gun, addr_we_barrier = 0x8F, 0x92
local addr_ap_key, addr_ap_yell = 0x90, 0x93

local addr_sk_x_lo, addr_sk_x_hi, addr_sk_y_lo, addr_sk_y_hi = 0x9A, 0x9D, 0xA0, 0xA3
local addr_we_x_lo, addr_we_x_hi, addr_we_y_lo, addr_we_y_hi = 0x9B, 0x9E, 0xA1, 0xA4
local addr_ap_x_lo, addr_ap_x_hi, addr_ap_y_lo, addr_ap_y_hi = 0x9C, 0x9F, 0xA2, 0xA5

local addr_sk_invinc_timer, addr_barrier_timer, addr_ap_invinc_timer = 0x0D54, 0x0D55, 0x0D56
local addr_sk_push_timer, addr_we_push_timer, addr_ap_push_timer = 0x0D48, 0x0D49, 0x0D4A

local addr_sk_state, addr_sk_state_timer, addr_sk_exit, addr_sk_facing = 0xAF, 0xB2, 0x0D5A, 0x0D5D
local addr_we_state, addr_we_state_timer, addr_we_exit, addr_we_facing = 0xB0, 0xB3, 0x0D5B, 0x0D5E
local addr_ap_state, addr_ap_state_timer, addr_ap_exit, addr_ap_facing = 0xB1, 0xB4, 0x0D5C, 0x0D5F

local addr_level = 0x0711
local addr_boss_x, addr_boss_y, addr_boss_hp, addr_boss_inv = 0x37, 0x39, 0x48, 0x49
local level

memory.usememorydomain("WRAM")
client.SetGameExtraPadding(0, 0, 0, 64)
gui.defaultPixelFont("fceux")

local function do_end()
  client.SetGameExtraPadding(0, 0, 0, 0)
end

event.onexit(do_end)

local function get_pos(lo, hi)
  return memory.read_u8(lo) + memory.read_u8(hi) * 0x100
end

local function get_exit(val)
  if (val == 1) then
    return "Y"
  elseif (val == 0) then
    return "N"
  else
    return "?"
  end
end

local function get_dir(val)
  if (val == 1) then
    return "U"
  elseif (val == 2) then
    return "R"
  elseif (val == 3) then
    return "D"
  elseif (val == 128) then
    return "L"
  else
    return "?"
  end
end

local function draw_skipp_info()
  local x = get_pos(addr_sk_x_lo, addr_sk_x_hi)
  local y = get_pos(addr_sk_y_lo, addr_sk_y_hi)
  local st = memory.read_u8(addr_sk_state)
  local st_timer = memory.read_u8(addr_sk_state_timer)
  local dir = get_dir(memory.read_u8(addr_sk_facing))
  local ex = get_exit(memory.read_u8(addr_sk_exit))
  local push = memory.read_u8(addr_sk_push_timer)
  local invinc = memory.read_u8(addr_sk_invinc_timer)

  gui.pixelText(8, 224, string.format("(%04X, %04X)", x, y))
  gui.pixelText(8, 234, string.format("Facing: %s", dir))
  gui.pixelText(8, 244, string.format("Exit: %s", ex))
  gui.pixelText(8, 254, string.format("State: %02X %02X", st, st_timer))
  gui.pixelText(8, 264, string.format("Push: %02X", push))
  gui.pixelText(8, 274, string.format("Invinc: %02X", invinc))
end

local function draw_wedge_info()
  local x = get_pos(addr_we_x_lo, addr_we_x_hi)
  local y = get_pos(addr_we_y_lo, addr_we_y_hi)
  local st = memory.read_u8(addr_we_state)
  local st_timer = memory.read_u8(addr_we_state_timer)
  local dir = get_dir(memory.read_u8(addr_we_facing))
  local ex = get_exit(memory.read_u8(addr_we_exit))
  local bar_timer = memory.read_u8(addr_barrier_timer)
  local push = memory.read_u8(addr_we_push_timer)

  gui.pixelText(90, 224, string.format("(%04X, %04X)", x, y))
  gui.pixelText(90, 234, string.format("Facing: %s", dir))
  gui.pixelText(90, 244, string.format("Exit: %s", ex))
  gui.pixelText(90, 254, string.format("State: %02X %02X", st, st_timer))
  gui.pixelText(90, 264, string.format("Push: %02X", push))
  gui.pixelText(90, 274, string.format("Barrier: %02X", bar_timer))
end

local function draw_apple_info()
  local x = get_pos(addr_ap_x_lo, addr_ap_x_hi)
  local y = get_pos(addr_ap_y_lo, addr_ap_y_hi)
  local st = memory.read_u8(addr_ap_state)
  local st_timer = memory.read_u8(addr_ap_state_timer)
  local dir = get_dir(memory.read_u8(addr_ap_facing))
  local ex = get_exit(memory.read_u8(addr_ap_exit))
  local push = memory.read_u8(addr_ap_push_timer)
  local invinc = memory.read_u8(addr_ap_invinc_timer)

  gui.pixelText(172, 224, string.format("(%04X, %04X)", x, y))
  gui.pixelText(172, 234, string.format("Facing: %s", dir))
  gui.pixelText(172, 244, string.format("Exit: %s", ex))
  gui.pixelText(172, 254, string.format("State: %02X %02X", st, st_timer))
  gui.pixelText(172, 264, string.format("Push: %02X", push))
  gui.pixelText(172, 274, string.format("Invinc: %02X", invinc))
end

local function draw_boss_info()
  local x = memory.read_u16_le(addr_boss_x)
  local y = memory.read_u16_le(addr_boss_y)
  local hp = memory.read_u8(addr_boss_hp)
  local inv = memory.read_u8(addr_boss_inv)
  local exit_x = bit.band(x + 0x0200, 0xFF00)
  local exit_y = bit.band(y + 0x0300, 0xFF00)

  gui.pixelText(172, 224, string.format("(%04X, %04X)", x, y))
  gui.pixelText(172, 234, string.format("HP: %s", hp))
  gui.pixelText(172, 244, string.format("Invinc: %s", inv))
  gui.pixelText(172, 264, string.format("Exit:\n(%04X, %04X)", exit_x, exit_y))
end

while true do
  level = memory.read_u8(addr_level)
  draw_skipp_info()
  if level < 8 then
    draw_wedge_info()
    draw_apple_info()
  else
    draw_boss_info()
  end
  emu.frameadvance()
end