BizHawk Lua script for visualizing NES hardware sprites
-
thefox
- Posts: 3134
- Joined: Mon Jan 03, 2005 10:36 am
- Location: the universe
BizHawk Lua script for visualizing NES hardware sprites
I wrote a small Lua script for visualizing NES hardware sprites (8x8/8x16) in BizHawk. It's a nice way to figure out how and where games utilize sprites and what kind of special tricks they pull off with them. Playing some games with this script enabled can also be educational for people who are new to NES development.
Get it at https://gist.github.com/fo-fo/771a49e7b49cf8daa182
NOTE: You need to enable the NesHawk core in BizHawk. QuickNES core doesn't support event.onmemorywrite.
Get it at https://gist.github.com/fo-fo/771a49e7b49cf8daa182
NOTE: You need to enable the NesHawk core in BizHawk. QuickNES core doesn't support event.onmemorywrite.
You do not have the required permissions to view the files attached to this post.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
-
dougeff
- Posts: 3080
- Joined: Fri May 08, 2015 7:17 pm
Re: BizHawk Lua script for visualizing NES hardware sprites
Good work. Do you think this would work in FCEUX? The bizhawk website says that its NES core is based on FCEUX code.
nesdoug.com -- blog/tutorial on programming for the NES
-
thefox
- Posts: 3134
- Joined: Mon Jan 03, 2005 10:36 am
- Location: the universe
Re: BizHawk Lua script for visualizing NES hardware sprites
Nope, doesn't work in FCEUX because it's not possible to read OAM in FCEUX Lua scripts (as far as I know). It would be possible to work around that by hooking the OAM DMA register writes (and then reading the OAM data from RAM) but the whole script would need to be modified.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
-
rainwarrior
- Posts: 8764
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
Re: BizHawk Lua script for visualizing NES hardware sprites
Here's a simple FCEUX lua script that does the basic job, i.e. draws 64 boxes whenever $4014 is written.
You'd have to customize it per-game, it's set up for a "STA $4014" and 8x8 sprites. FCEUX lua/breakpoints could really use access to the value being written; maybe I should try to add that...
Edit: Lua scripts were later disallowed on this forum. Can't find the original, but am uploading the most recent version I have of this script in a ZIP, which was included in FCEUX 2.2.3 and due to lua feature improvements is now able to listen to $2000 writes without having to know which register it came from.
You'd have to customize it per-game, it's set up for a "STA $4014" and 8x8 sprites. FCEUX lua/breakpoints could really use access to the value being written; maybe I should try to add that...
Edit: Lua scripts were later disallowed on this forum. Can't find the original, but am uploading the most recent version I have of this script in a ZIP, which was included in FCEUX 2.2.3 and due to lua feature improvements is now able to listen to $2000 writes without having to know which register it came from.
You do not have the required permissions to view the files attached to this post.
Last edited by rainwarrior on Tue Jun 12, 2018 12:56 pm, edited 3 times in total.
-
rainwarrior
- Posts: 8764
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
Re: BizHawk Lua script for visualizing NES hardware sprites
It could, in theory, but there are a number of complications.
1. Still don't know what register to read back for the write (A, X, Y?)
2. $4014 is written only once per frame. $2000 is often written several times per-frame with differing values. The last one before OAM DMA might not be the correct one. You might need a way to trigger the drawing at the end of vblank or some other time besides when $4014 is written, etc. etc.
So... go ahead and write a more complicated script to try and solve the problem generically, if you like. I spent maybe 10 minutes on this script, trying to solve that harder problem would probably take hours, and it's simply not worth my time. (Super easy to just customize the simple script per-game, anyway. Would rather spend 1 minute altering the script 10 times, than all day 1 time.)
1. Still don't know what register to read back for the write (A, X, Y?)
2. $4014 is written only once per frame. $2000 is often written several times per-frame with differing values. The last one before OAM DMA might not be the correct one. You might need a way to trigger the drawing at the end of vblank or some other time besides when $4014 is written, etc. etc.
So... go ahead and write a more complicated script to try and solve the problem generically, if you like. I spent maybe 10 minutes on this script, trying to solve that harder problem would probably take hours, and it's simply not worth my time. (Super easy to just customize the simple script per-game, anyway. Would rather spend 1 minute altering the script 10 times, than all day 1 time.)
-
tokumaru
- Posts: 12668
- Joined: Sat Feb 12, 2005 9:43 pm
- Location: Rio de Janeiro - Brazil
Re: BizHawk Lua script for visualizing NES hardware sprites
Just for posterity's sake, I'm posting my own script for visualizing sprites in FCEUX:
You can hover the cursor over the sprites to get more information about them. I'm using a hack to detect which values are written to the PPU registers, because the latest stable version of FCEUX doesn't yet pass the written value to the callback function. Anyway, the script only works for sprites copied to OAM by sprite DMA, starting from $00, since $2003 and $2004 are completely ignored. There might be bugs.
You do not have the required permissions to view the files attached to this post.
-
hackfresh
- Posts: 101
- Joined: Sun May 03, 2015 8:19 pm
Re: BizHawk Lua script for visualizing NES hardware sprites
I like how it gives you the sprite info when you hover it. Very nice!
-
qalle
- Posts: 50
- Joined: Wed Aug 16, 2017 12:15 am
Re: BizHawk Lua script for visualizing NES hardware sprites
"The extension lua has been deactivated and can no longer be displayed." I've attached the program as a zip file. BTW: it's useful, thanks!
You do not have the required permissions to view the files attached to this post.
-
sdm
- Posts: 461
- Joined: Tue Apr 11, 2006 4:08 am
- Location: Poland
Re: BizHawk Lua script for visualizing NES hardware sprites
I have a problem running LUA scripts in FCEUX on Windows XP, it works correctly on Win7. Is there anything to do if there is no chance on XP?
What are other methods (other emulators) with the ability to preview sprites in a similar way?
What are other methods (other emulators) with the ability to preview sprites in a similar way?
You do not have the required permissions to view the files attached to this post.
-
Dacicus
- Posts: 46
- Joined: Sat Dec 20, 2008 4:59 pm
Re: BizHawk Lua script for visualizing NES hardware sprites
Do you have that DLL in the FCEUX directory? It should have been included in the zip file with FCEUX, if you got it from the official FCEUX site.sdm wrote: Tue Dec 03, 2019 2:34 amI have a problem running LUA scripts in FCEUX on Windows XP, it works correctly on Win7.
-
sdm
- Posts: 461
- Joined: Tue Apr 11, 2006 4:08 am
- Location: Poland
Re: BizHawk Lua script for visualizing NES hardware sprites
Yes. Everything is as it should be. I can't run it on Windows XP Pro, everything works on Win7.
-
knight0fdragon
- Posts: 26
- Joined: Wed Sep 25, 2019 9:11 am
Re: BizHawk Lua script for visualizing NES hardware sprites
Is your windows 7 64 bit? You are probably using the 64 bit lua dll when you need the 32 bit one for windows XP
-
sdm
- Posts: 461
- Joined: Tue Apr 11, 2006 4:08 am
- Location: Poland
Re: BizHawk Lua script for visualizing NES hardware sprites
I download/use "FCEUX 2.2.3 win32 Binary". I used both x32 and x64 Win 7 and both work ok. Only not on XP.
-
knight0fdragon
- Posts: 26
- Joined: Wed Sep 25, 2019 9:11 am
Re: BizHawk Lua script for visualizing NES hardware sprites
Does your Windows/Firewall/Antivirus have a security setting blocking unknown dlls?