Last active
March 30, 2021 09:35
-
-
Save infval/9bb97bae2c42ac9e449cafd34d2e8b68 to your computer and use it in GitHub Desktop.
Puggsy (U) | Free Player (Camera) | Lua, BizHawk, Sega Mega Drive / Genesis
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
-- For BizHawk | |
local player_x_addr = 0x06E0 | |
local player_y_addr = 0x06E2 | |
local cam_x_addr = 0x05BA | |
local cam_y_addr = 0x05BC | |
local invincibility_addr = 0x0728 | |
local step = 1 | |
local prev_keys = {} | |
local prev_mouse = {} | |
local state = 0 | |
gui.addmessage("[Script] Free Player") | |
while true do | |
local x = mainmemory.read_u16_be(player_x_addr) | |
local y = mainmemory.read_u16_be(player_y_addr) | |
local keys = input.get() | |
local mouse = input.getmouse() | |
if keys["Delete"] then | |
mainmemory.write_u16_be(player_x_addr, x - step) | |
elseif keys["PageDown"] then | |
mainmemory.write_u16_be(player_x_addr, x + step) | |
end | |
if keys["Home"] then | |
mainmemory.write_u16_be(player_y_addr, y - step) | |
elseif keys["End"] then | |
mainmemory.write_u16_be(player_y_addr, y + step) | |
end | |
if keys["Insert"] and not prev_keys["Insert"] then | |
if step > 1 then | |
step = step - 1 | |
gui.addmessage("Velocity = "..tostring(step)) | |
end | |
elseif keys["PageUp"] and not prev_keys["PageUp"] then | |
if step < 32 then | |
step = step + 1 | |
gui.addmessage("Velocity = "..tostring(step)) | |
end | |
end | |
if mouse["Middle"] and not prev_mouse["Middle"] then | |
state = (state + 1) % 3 | |
gui.clearGraphics() | |
end | |
if state > 0 then | |
-- Clear player | |
for i = 0, 0x280 - 1, 2 do | |
memory.write_u16_be(0x8000 + i, 0, "VRAM") | |
end | |
mainmemory.write_u16_be(invincibility_addr, 0x0010) | |
if state == 2 then | |
local screen_x = x - mainmemory.read_u16_be(cam_x_addr) - 10 | |
local screen_y = y - mainmemory.read_u16_be(cam_y_addr) | |
gui.drawRectangle(screen_x, screen_y, 24, 40) | |
end | |
end | |
prev_keys = keys | |
prev_mouse = mouse | |
emu.frameadvance() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment