It is currently Sun Dec 17, 2017 12:52 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Tue Sep 15, 2015 8:19 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2983
Location: Tampere, Finland
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.

Attachment:
nes-hardware-sprite-visualizer-1.png
nes-hardware-sprite-visualizer-1.png [ 14.38 KiB | Viewed 2606 times ]

Attachment:
nes-hardware-sprite-visualizer-2.png
nes-hardware-sprite-visualizer-2.png [ 19.51 KiB | Viewed 2606 times ]

Attachment:
nes-hardware-sprite-visualizer-3.png
nes-hardware-sprite-visualizer-3.png [ 16.24 KiB | Viewed 2606 times ]

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Tue Sep 15, 2015 12:26 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1870
Location: DIGDUG
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


Top
 Profile  
 
PostPosted: Tue Sep 15, 2015 12:32 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2983
Location: Tampere, Finland
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: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Tue Sep 15, 2015 4:19 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5899
Location: Canada
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...


Attachments:
File comment: Simple FCEUX lua script for visualizing sprites.
sprites.lua [695 Bytes]
Downloaded 83 times


Last edited by rainwarrior on Tue Sep 15, 2015 5:57 pm, edited 1 time in total.
Top
 Profile  
 
PostPosted: Tue Sep 15, 2015 5:39 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19353
Location: NE Indiana, USA (NTSC)
I wonder why it couldn't snoop $2000 (or $2000+8n where 0 <= n < $400) to see the 8x16 bit.


Top
 Profile  
 
PostPosted: Tue Sep 15, 2015 6:04 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5899
Location: Canada
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.)


Top
 Profile  
 
PostPosted: Tue Oct 18, 2016 1:26 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10169
Location: Rio de Janeiro - Brazil
Just for posterity's sake, I'm posting my own script for visualizing sprites in FCEUX:
Attachment:
nes-sprites.lua [4.72 KiB]
Downloaded 101 times

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.


Top
 Profile  
 
PostPosted: Tue Oct 18, 2016 2:43 pm 
Offline

Joined: Sun May 03, 2015 8:19 pm
Posts: 92
I like how it gives you the sprite info when you hover it. Very nice!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group