It is currently Sun Oct 22, 2017 2:06 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Tue Jan 13, 2009 4:25 pm 
Offline
User avatar

Joined: Wed Dec 06, 2006 8:18 pm
Posts: 2801
So I'm working on my emulator and I found that some games (Mega Man 1, Duck Tales) are like NES games using the background layer to make a status bar, unlike other games that use the window layer.

Does anyone know the specific rules to mid-frame updates? Right now I have it worked out to a point that it works ok, but I'm not sure it's perfect. It seems to me like the amount of lines rendered so far affects what part of the screen is drawn when you change the scroll value though, unlike on NES. So anyone with a good explanation of how it works I'd be interested in hearing it. What I have right now works but sometimes its off by a few lines.


Top
 Profile  
 
PostPosted: Tue Jan 13, 2009 5:03 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
MottZilla wrote:
So I'm working on my emulator and I found that some games (Mega Man 1, Duck Tales) are like NES games using the background layer to make a status bar, unlike other games that use the window layer.

You might want to try SMB Deluxe too.

Quote:
It seems to me like the amount of lines rendered so far affects what part of the screen is drawn when you change the scroll value though, unlike on NES.

I don't know about the 8-bit Game Boy, but it might be acting like the Game Boy Advance or Nintendo DS in "text" mode. The GBA video hardware maintains a register VCOUNT, and it acts as if it moves an internal pointer to (BG_OFFSET.x, BG_OFFSET.y + VCOUNT) before each scanline. So if you start rendering the screen with BG_OFFSET.y=3 then set BG_OFFSET.y=23 at the end of scanline 15, then the screen will draw map lines 3-18 in screen lines 0-15, and then map lines 39+ in screen lines 16+.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2009 8:14 pm 
Offline

Joined: Thu Aug 28, 2008 1:17 am
Posts: 591
I did a split screen mutliscroller and don't remember there being a specific time frame on the scanline interrupt to write the reg changes. I assume they are latched at the end of the scanline like some other display systems. Or at least latched at some point in the scanline <_<


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2009 9:54 pm 
Offline

Joined: Tue Mar 28, 2006 5:04 am
Posts: 4
On the CGB the BG scroll registers are latched per tile, but there is some pipelining or something going on, so the scroll values for a tile are latched some time before it is drawn (around 16 clock cycles IIRC).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2009 10:58 pm 
Offline
User avatar

Joined: Wed Dec 06, 2006 8:18 pm
Posts: 2801
It's not the timing that is the issue I'm most interested in though. It's the mechanics of what gets rendered and why. Or more specifically what part of the BG gets rendered.

What tepples said seems similar to what I did to get the scroll values for most games looking correct. When you change the scroll it seems the lines rendered is taken into effect on the next line draw at your new scroll location. But as I was saying, any sort of concrete knowledge on this subject would be nice. Loopy de-mystified the NES and scrolling, but there is no such thing for GB so I just sort of made similar guesses and worked it out to the point I have it now, which still isn't perfect. But ofcourse I still have lingering CPU bugs that could be causing them.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 31, 2009 7:09 pm 
Offline
User avatar

Joined: Sat Jan 31, 2009 6:25 pm
Posts: 4
I don't know how it works from the hardware side of things, but it's basically as you say that that lines rendered are taken into account.

Another thing is that if you change SCX during the line in VRAM mode then the lower 3 bits of horizontal scroll value can't be changed until next line so that all tiles are 8 pixels wide. So you have to align the horizontal scroll 0-7 pixels a bit earlier. You can still change the most significant 5 bits though.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 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