It is currently Sun Oct 22, 2017 7:49 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: basic mirroring question
PostPosted: Fri Feb 11, 2005 12:03 am 
Offline
User avatar

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
i really dont understand how mirroring is performed, i have read about lines A11 and A10 in NinTech, but how this apply to rom control info header i dont know. I mean SMB runs OK to me, but CART.NES has scrolling problems, same as galaga and galaxian, some games work and other doesnt work. Im not using loopy logic for drawing graph, but yes i use "flip bits" of nametable when the ppu needs to draw the "next" name table of scrolling. I flip the low bitin Horizontal and second bit in vertical scrolling. I have tried using pointers and really mirroring name tables, which make some roms to work but errors in other roms.

Please help :(

_________________
ANes


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 11, 2005 12:40 am 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
Each nametable is 1k. There's addressing space for 4 nametables:

$2000
$2400
$2800
$2C00

The game selects which of the 4 addressing spaces it's going to use through the low 2 bits of the $2000 register (this can also be selected by careful $2006 writes). Conceptually, these addressing spaces are layed out in a box shape:

Code:
----------------
| $2000 | $2400 |
----------------
| $2800 | $2C00 |
----------------


Each nametable is a "screen"'s worth of images. When the game scrolls off of one nametable, it will scroll into another nametable. For example... Super Mario Bros. starts with the screen at $2000. As the game scrolls to the right, the screen starts scrolling into $2400... and as it scrolls out the right side of $2400, it wraps around back to the left side of $2000


However... there are only two actual nametables on the NES... not 4 (Hereon... the two nametables will be referred to as nametable 'A' and nametable 'B'). So games employ mirroring to have those 2 nametables cover all 4 spaces. So while the concept is the same for the addressing space ($2400 exists to the right of $2000, and $2800 exists below $2000)... implimentation is slightly different. Rather than having 4 nametables of space... each area shares a nametable with another area (which area shares with what depends on the mirroring mode)

For the two typical mirroring modes:

Horizontal Mirroring:
$2000 uses nametable A
$2400 uses nametable A
$2800 uses nametable B
$2C00 uses nametable B


Vertical Mirroring:
$2000 -> nametable A
$2400 -> nametable B
$2800 -> nametable A
$2C00 -> nametable B


So in Horizontal mirroring mode... the nametable at $2000 uses the same memory as the nametable at $2400. So when the game writes to the nametable at $2000... it's also changing what's at $2400. Likewise when the game draws what's at $2000... it's drawing exactly what's at $2400... since $2000 and $2400 both point to the same nametable.


That aside.. the simplest way to handle mirroring modes (imo) is to keep 4 pointers... each of which represent the addressing areas ($2000,$2400,$2800, and $2C00). Also keep 2k of memory* which holds the actual nametable data (what the pointers will point to).

*(you might actually want to keep 4k for when you do 4-screen mirroring later)

When you do your drawing and PPU writing (through the $2007 reg)... never write to your nametable buffer directly... but rather use the pointers so that the current mirroring mode takes effect. This way when the game switches mirroring modes, all your emu has to do is change a few pointers.


Top
 Profile  
 
 Post subject: thanks
PostPosted: Fri Feb 11, 2005 1:21 am 
Offline
User avatar

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
thanks disch

_________________
ANes


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: tepples and 6 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