It is currently Mon Nov 20, 2017 4:13 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Jun 17, 2011 1:43 pm 
Offline

Joined: Sat May 28, 2011 10:30 am
Posts: 97
I have no idea how much code I can put into vblank without causing trouble. Are there any rules of thumb or guidelines that would give me an idea?


Top
 Profile  
 
PostPosted: Fri Jun 17, 2011 2:11 pm 
Offline
NESICIDE developer
User avatar

Joined: Mon Oct 13, 2008 7:55 pm
Posts: 1049
Location: Minneapolis, MN
shawnleblanc wrote:
I have no idea how much code I can put into vblank without causing trouble. Are there any rules of thumb or guidelines that would give me an idea?


About 2273 CPU cycles. Depending on your instruction mix that's either a chunk of code (1136 2-cycle opcodes) or a little bit of code (324 7-cycle opcodes). So, I guess that isn't very helpful. You'll be somewhere between 324 and 1136, roughly.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2011 2:24 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3950
262 total scanlines, 240 are visible.
1 scanline is the pre-vblank scanline and you can't use it unless you have IRQs or other timed code to know when that scanline is coming.
1 scanline is the pre-render scanline, you can use it as extra vblank time if you turn off the screen, then do a complete set of scroll writes after turning the screen back on.

If you just use the normal vblank lines, that's 21 scanlines at 341 PPU cycles (113.666 CPU cycles) each, for 2387 total CPU cycles. Of course, there's also the NMI interrupt triggering, and all your other code to get ready to start spitting out graphics, so there's less time than that actually available for your graphics display loop.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2011 4:26 pm 
Offline
User avatar

Joined: Wed Oct 15, 2008 11:50 am
Posts: 939
One thing I do is to set a breakpoint at the end of my VBlank routine in Nintendulator. It has this nice feature in e debugger that shows you what scan line and pixel you are on.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2011 5:06 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10114
Location: Rio de Janeiro - Brazil
qbradq wrote:
One thing I do is to set a breakpoint at the end of my VBlank routine in Nintendulator. It has this nice feature in e debugger that shows you what scan line and pixel you are on.

I'd like to second this suggestion.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2011 7:48 pm 
Offline
NESICIDE developer
User avatar

Joined: Mon Oct 13, 2008 7:55 pm
Posts: 1049
Location: Minneapolis, MN
tokumaru wrote:
qbradq wrote:
One thing I do is to set a breakpoint at the end of my VBlank routine in Nintendulator. It has this nice feature in e debugger that shows you what scan line and pixel you are on.

I'd like to second this suggestion.


I'll put an alternative out there:

Image

I set up the red execution marker in the nesyar source over its entire NMI routine, and the green marker over the jsr to the sound routine. The Execution Visualizer shows me where each marked code region is executing in the PPU frame and how many CPU cycles it took last time it ran. It's a bit hard to see in the image but the area to the right of the quotile shield is HBLANK (the red/green stretches into it. The image is 341x262 (or 341x312) pixels big, so you can see it covers the entire PPU clock domain and shows where the CPU is doing whatever you marked to see. I can add eight different marked regions and see where they are in relation to each other or how long they are taking. Plan is to add min/max/avg also to cycle counts. In the image, the top left (0,0) is the screen pixel (0,0), so VBLANK time is at the bottom (where it's all red). Obviously nesyar eats into the screen time a bit in NMI but only to do sound updates.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 18, 2011 1:21 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2981
Location: Tampere, Finland
Yet another option is to use NintendulatorDX with code like this:

Code:
nmi:
  sta $4020 ; Start the timer.

  ; TODO: Do the vblank updates here.

  sta $4030 ; Stop the timer.

  rti

Then you can see the number of cycles taken by the vblank updates in the debugging window. As long as the "max" value is less than ~2270, you're in the good.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 18, 2011 8:38 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19236
Location: NE Indiana, USA (NTSC)
cpow wrote:
Plan is to add min/max/avg also to cycle counts.

With sparklines?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 18, 2011 11:23 am 
Offline
User avatar

Joined: Wed Oct 15, 2008 11:50 am
Posts: 939
Dang CPOW! That's awesome! Is that something you wrote? Where can I get it?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 18, 2011 11:36 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
Aww cpow, reminding me of my Apple IIGS days where you'd change the system border colour to something of your choice at the start of your routine, then back to whatever it was previously at the end, effectively using the border as a way to tell how much CPU time something took. :-) So happy.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 18, 2011 1:07 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7271
Location: Chexbres, VD, Switzerland
koitsu wrote:
Aww cpow, reminding me of my Apple IIGS days where you'd change the system border colour to something of your choice at the start of your routine, then back to whatever it was previously at the end, effectively using the border as a way to tell how much CPU time something took. :-) So happy.

You can do that on the NES with the $2001 register.

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 18, 2011 2:26 pm 
Offline
NESICIDE developer
User avatar

Joined: Mon Oct 13, 2008 7:55 pm
Posts: 1049
Location: Minneapolis, MN
qbradq wrote:
Dang CPOW! That's awesome! Is that something you wrote? Where can I get it?


It's part of NESICIDE, which is something I wrote, yes. :D


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 18, 2011 2:32 pm 
Offline
NESICIDE developer
User avatar

Joined: Mon Oct 13, 2008 7:55 pm
Posts: 1049
Location: Minneapolis, MN
tepples wrote:
cpow wrote:
Plan is to add min/max/avg also to cycle counts.

With sparklines?


Funny you should mention that tepples! I attended Edward Tufte's "Information Design" seminar last year. As part of that I got signed copies of all four of his books and a poster. I am a strong believer in techniques for visualization of information. Sparklines are so obviously useful, concise, and unencumbered with need for prior knowledge of the visualization technique.

I could probably whip up a sparkline control in Qt pretty quick...so now that you've planted the idea, expect to see it. :D


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 18, 2011 3:23 pm 
Offline
NESICIDE developer
User avatar

Joined: Mon Oct 13, 2008 7:55 pm
Posts: 1049
Location: Minneapolis, MN
qbradq wrote:
Dang CPOW! That's awesome! Is that something you wrote? Where can I get it?


It just struck me that you might have been referring to the game visual, not the tool. No, I did not write nesyar. That was authored by clueless. Haven't seen him around in a while though.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 18, 2011 5:24 pm 
Offline
User avatar

Joined: Wed Oct 15, 2008 11:50 am
Posts: 939
I was referring to the visualization. Can I run any ROM with timer writes in that or does it have to be a NESICIDE project?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

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