It is currently Mon Oct 15, 2018 10:23 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Aug 02, 2018 8:16 am 
Offline
User avatar

Joined: Sun Apr 08, 2018 11:45 pm
Posts: 15
Location: Southern California
After reading this thread: viewtopic.php?f=10&t=11151

We ended up porting our ASM3 project to ca65 using this example, and lately I've been trying to figure out what it takes to make the step from a simple NROM game to something larger that requires bank management. While trying to figure out what that would look like, I noticed this:

Code:
; 32k block for PRG in CFG
PRG:    start = $8000,  size = $8000, type = ro, file = %O, fill = yes, fillval = $00;


Code:
; NES Header specifies 2 16k PRG banks
.segment "HEADER"
; <snipped>
.byte $02 ; 16k PRG bank count


Is it going to cause problems once I have more than 16kb of code and data? Like, if I have a big lookup table that starts in the first 16kb and spills in to the next, is it going to have problems when I read across that boundary?


Top
 Profile  
 
PostPosted: Thu Aug 02, 2018 8:24 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6875
Location: Canada
The iNES header format counts the size of PRG data in the file in 16k chunks, but it's not directly related to how things are banked.

(I probably shouldn't have called it "bank" in the comment in my example, in retrospect, that was inheriting bad terminology.)

Actual memory mapping on the NES varies from mapper to mapper. Some do have 16k banks, but others use 8k or 32k. The PRG size specified in the header doesn't affect this, but the mapper number does.

There's a big list here:
http://wiki.nesdev.com/w/index.php/Mapper

The discrete logic category tend to be the simplest.


Top
 Profile  
 
PostPosted: Thu Aug 02, 2018 8:37 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20656
Location: NE Indiana, USA (NTSC)
You'd normally make a separate memory area for each 16K bank. The linker will fail and print a diagnostic if you try to put more than 16K of arrays into one 16K memory area. See the config files and code in snrom_template (which covers SGROM, SNROM, UNROM, and UOROM), as well as Programming UNROM.

Or you can switch the whole 32K space, but it takes a bit of extra care to pass control from one bank to another. See example in bnrom template (which covers BNROM, AMROM, ANROM, and AOROM).

A third way is the "linear" trick used in The Curse of Possum Hollow to allocate three-fourths of a 4 Mbit (512 KiB) ROM as one continuous space, so long as no single array is larger than 8K (unless accessed sequentially with occasional renormalization). It needs a mapper that can switch 8K pages, such as MMC3, and those tend to be a bit more expensive to put in a cartridge if you aren't already using the interval timer for raster effects.


Top
 Profile  
 
PostPosted: Thu Aug 02, 2018 12:28 pm 
Offline
User avatar

Joined: Sun Apr 08, 2018 11:45 pm
Posts: 15
Location: Southern California
That's exactly what I'm trying to figure out. I'll check out those links, thanks!
:beer:


Top
 Profile  
 
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: Google Adsense [Bot], tokumaru, yaros 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