lua write callbacks: adding optional third parameter to retrieve the value written, added Sprites.lua script to visualize sprites (requires and demonstrates feature just added)
This commit is contained in:
parent
2873344ce8
commit
f947ef06e7
|
@ -0,0 +1,45 @@
|
||||||
|
-- Simple sprite visualizer
|
||||||
|
-- Draws a box around all sprites on screen.
|
||||||
|
-- rainwarrior 8/23/2016
|
||||||
|
|
||||||
|
sprite_color = "#FF00FF" -- change to customize color
|
||||||
|
|
||||||
|
sprite_height_last = 8
|
||||||
|
sprite_height = 8
|
||||||
|
|
||||||
|
function oam_dma(a,s,v)
|
||||||
|
local oam = v * 256
|
||||||
|
for i=1,64 do
|
||||||
|
local is = (i-1) * 4
|
||||||
|
local x0 = memory.readbyte(oam + is + 3)
|
||||||
|
local x1 = x0 + 7
|
||||||
|
local y0 = memory.readbyte(oam + is + 0) + 1
|
||||||
|
local y1 = y0 + (sprite_height_last - 1)
|
||||||
|
gui.box(x0,y0,x1,y1,"",sprite_color)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ppu_ctrl(a,s,v)
|
||||||
|
if AND(v,0x20) == 0 then
|
||||||
|
sprite_height = 8
|
||||||
|
else
|
||||||
|
sprite_height = 16
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function frame_end()
|
||||||
|
-- information about sprite height will be behind by 1 frame
|
||||||
|
-- (or potentially wrong if changed before the end of the frame)
|
||||||
|
-- in most games this doesn't change from frame to frame, though
|
||||||
|
sprite_height_last = sprite_height
|
||||||
|
end
|
||||||
|
|
||||||
|
-- main
|
||||||
|
|
||||||
|
memory.registerwrite(0x4014,1,oam_dma)
|
||||||
|
memory.registerwrite(0x2000,1,ppu_ctrl)
|
||||||
|
emu.registerafter(frame_end)
|
||||||
|
|
||||||
|
while (true) do
|
||||||
|
emu.frameadvance()
|
||||||
|
end
|
|
@ -1976,7 +1976,8 @@ static void CallRegisteredLuaMemHook_LuaMatch(unsigned int address, int size, un
|
||||||
//RefreshScriptSpeedStatus();
|
//RefreshScriptSpeedStatus();
|
||||||
lua_pushinteger(L, address);
|
lua_pushinteger(L, address);
|
||||||
lua_pushinteger(L, size);
|
lua_pushinteger(L, size);
|
||||||
int errorcode = lua_pcall(L, 2, 0, 0);
|
lua_pushinteger(L, value);
|
||||||
|
int errorcode = lua_pcall(L, 3, 0, 0);
|
||||||
luaRunning /*info.running*/ = wasRunning;
|
luaRunning /*info.running*/ = wasRunning;
|
||||||
//RefreshScriptSpeedStatus();
|
//RefreshScriptSpeedStatus();
|
||||||
if (errorcode)
|
if (errorcode)
|
||||||
|
|
Loading…
Reference in New Issue