It is currently Mon May 20, 2019 8:13 am

All times are UTC - 7 hours

Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Timing of microcomputers
PostPosted: Thu Apr 11, 2019 7:00 am 

Joined: Tue Feb 06, 2018 5:32 pm
Posts: 5
Location: Upstate NY, USA
I bought a book "The Z80 Microprocessor: Architecture, Interfacing, Programming , and Design" by Ramesh Gaonkar and am almost done reading it. A question I have regarding development of SNES, GB/GBC and early 8-bit microcomputers which I am trying to get into, is How do we know how much "work can be done" until a frame is drawn and work involving the memory-mapped video chip must be momentarily paused?

To take the Gameboy as an example that doesn't get into television details, is it that there are "X" T-states that are available before an interrupt fires signalling the beginning of the screen draw, and then "Y" more T-states until it is safe to touch video chip memory registers again?

Sorry for the very basic question, I have been reading Pandocs and Fullsnes, but coming from basic modern PC development I am unfamiliar with the fundamental operation of 8- and 16-bit computers and unable to comprehend the details of those documents. I was thinking I could begin with just trying to output some graphics and then move on to audio once I understand more.

PostPosted: Thu Apr 11, 2019 7:50 am 

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21387
Location: NE Indiana, USA (NTSC)
The Game Boy PPU takes 456 T-states per scanline. Of these, the background uses about 170 T-states (one for each dot, plus a few more to set up scrolling), and each sprite on the scanline uses about 9 T-states.[1] This totals anywhere from 170 to 291 T-states, the rest being considered horizontal blanking. Each frame has 144 scanlines, and there are 10 vertical blanking scanlines between one frame and the next, for a total of 154 scanlines or 70224 T-states per frame.

Have you been reading the original Pan Docs or the expanded Pan Docs that the gbdev community has been maintaining? The latter has a table of how long each "mode" lasts.

[1] These can vary based on the background's X scroll and each sprite's X position.

Pin Eight | Twitter | GitHub | Patreon

PostPosted: Thu Apr 11, 2019 8:22 am 

Joined: Sun Mar 27, 2016 7:56 pm
Posts: 214
Generally the interrupt is at the end of the drawing period, not the beginning. The interrupt is at the start of V-blank, the period of time between frames where nothing is being drawn and video memory is safe to access.

PostPosted: Thu Apr 11, 2019 1:48 pm 
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 4071
Location: A world gone mad
And to answer the question more directly: what you as a programmer end up caring about most of the time is "how many CPU cycles do I have available within this period of time (ex. VBlank)".

The answer is very rarely documented in official documentation, in my experience -- the info you usually get pertains purely to hardware, like "blah blah happens at some particular clock rate, which correlates with blah blah Hz".

Usually people have figured this out in numerous ways through reverse engineering and extensive tests (once able to run code on whatever the device is). Like for the NES/Famicom, I semi-recently demanded this be documented because it's super important.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours

Who is online

Users browsing this forum: No registered users and 2 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