Number of possible CHR banks

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

User avatar
raydempsey
Posts: 160
Joined: Sat May 31, 2014 4:12 pm

Number of possible CHR banks

Post by raydempsey » Mon Jun 30, 2014 12:07 pm

I am new at this and I was wondering how many CHR banks are possible to be able to swap through? Also, I have a .chr file that I use to draw tiles and I would like to make it bigger so it will hold more banks than just the 256 sprite and 256 background. I compile using NESASM3 if that makes a difference.

User avatar
Quietust
Posts: 1642
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Number of possible CHR banks

Post by Quietust » Mon Jun 30, 2014 12:16 pm

It all depends on the mapper - the NES-CNROM-* board (iNES mapper 3) can support up to 32KB, the MMC1 (mapper 1) can handle up to 128KB natively, and the MMC5 (mapper 5) can handle 1MB. If you're designing your own mapper, you can theoretically make it as big as you want, but a standard .NES file (non-V2) will max out at just below 2MB.
Last edited by Quietust on Mon Jun 30, 2014 12:17 pm, edited 1 time in total.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

User avatar
koitsu
Posts: 4218
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Number of possible CHR banks

Post by koitsu » Mon Jun 30, 2014 12:16 pm

Depends on the mapper used. You didn't disclose that for whatever reason. :-)

User avatar
tokumaru
Posts: 11909
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Number of possible CHR banks

Post by tokumaru » Mon Jun 30, 2014 12:50 pm

If you're still deciding what mapper you're gonna use, you have to consider the type of CHR switching you want to do. If you want to swap the whole 8KB at once, CNROM is the best option. With just one mapper write you select a different 8KB page of CHR (you can have up to 4 pages, or 32KB). CNROM doesn't expand PRG-ROM at all though, it's still limited to 32KB. More complex mappers will allow you to swap CHR in smaller pieces. For example, the MMC1 has 2 4KB slots (so you can swap sprites and background independently), MMC3 has 2 2KB slots and 4 1KB slots, and more complex mappers can do 8 1KB slots, which is as fine as it gets.

If you don't need instantaneous CHR bankswitching, you should also consider CHR-RAM. CHR-RAM means that the 8KB used for tiles are empty when the program starts, and the program is free to write whatever it needs to it (using $2006/$2007, just like with name table and palette writes). This will allow you to rewrite any portion of the pattern tables you want, down to a single byte if you want to. The disadvantage of CHR-RAM is that updating it takes time (the time used for LDA'ing and STA'ing each byte times the number of bytes), while CHR-ROM bankswitching is instantaneous. This means that CHR-RAM updates are not suited for a complex title screen with more than 512 tiles, only instantaneous bankwitching halfway through the screen will give you that. However, if you plan to update the tiles only between levels and can afford to go a couple of frames with rendering turned off, CHR-RAM is a great (and simple) option.

User avatar
raydempsey
Posts: 160
Joined: Sat May 31, 2014 4:12 pm

Re: Number of possible CHR banks

Post by raydempsey » Mon Jun 30, 2014 1:36 pm

I am relatively new to this so I used the Nerdy Nights tutorials to get going. I am doing great at the programming part but there are a lot of things about how the Nintendo really works that I'm still learning. In the Nerdy Nights tutorials, they have the following settings as the first lines of code. I have continued to use this setting and I have a better-than-vague sense of what they actually do. The comments are obvious but I still haven't figured out how to make the game save. (I realize it has something to do with the ability to write in the $6000-$7FFF range)

.inesprg 1 ; 1x 16KB PRG code
.ineschr 1 ; 1x 8KB CHR data
.inesmap 0 ; mapper 0 = NROM, no bank swapping
.inesmir 3 ; background mirroring

QUESTIONS FOR EVERYBODY:

How do I allow writing onto $6000-$7FFF?
Is there a list of what every .inesmap number stands for?
Is there a way to gauge how much PRG memory my code takes up as a whole and how many cycles it took to run per frame?
How can I expand the size of the CHR file I use so that it will hold more than the original 4KB of tile data?

Thanks everyone.

tepples
Posts: 22171
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Number of possible CHR banks

Post by tepples » Mon Jun 30, 2014 1:49 pm

raydempsey wrote:I still haven't figured out how to make the game save.
What are you trying to save? If it can be squeezed into 32 bits, I can help you design a password system.
How do I allow writing onto $6000-$7FFF?
By adding a 6264 SRAM, 7420 decoder, and various diodes onto the board. The .inesmir 3 tells the emulator to include these components.
Is there a list of what every .inesmap number stands for?
See the grid or list.
Is there a way to gauge how much PRG memory my code takes up as a whole
Open it in a hex editor and see where the 00 00 00s start.
and how many cycles it took to run per frame?
A debugging emulator such as FCEUX should let you put a breakpoint on your "wait for vertical blanking" subroutine. It may show you the current scanline number (1 scanline = 113.67 cycles) or the number of cycles since the last breakpoint (helpful with breakpoints at the start and end of vblank wait).
How can I expand the size of the CHR file I use so that it will hold more than the original 4KB of tile data?
That depends on several things. First, how are you creating this CHR file? Second, how you organize the tile data in CHR ROM depends on what you want to display at the same time. Show mock screenshots throughout the game and we might be able to recommend something. Third, you can include extra CHR ROM as extra banks after the PRG ROM, but how you actually use the data in those banks depends on the mapper you choose.

User avatar
raydempsey
Posts: 160
Joined: Sat May 31, 2014 4:12 pm

Re: Number of possible CHR banks

Post by raydempsey » Mon Jun 30, 2014 4:00 pm

What I am trying to save is only 16 bytes. I have set inesmir 3 in the beginning and I have tried making writes to $6000-$600F. The hex editor confirms that the writes are not being made. Only setting inesmir to 3 is apparently not enough.

Ideally, I'd like to swap out only 128 background tiles at a time (I think 2KB worth) and have the largest CHR file to work with.

tepples
Posts: 22171
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Number of possible CHR banks

Post by tepples » Mon Jun 30, 2014 4:15 pm

raydempsey wrote:What I am trying to save is only 16 bytes. I have set inesmir 3 in the beginning and I have tried making writes to $6000-$600F. The hex editor confirms that the writes are not being made. Only setting inesmir to 3 is apparently not enough.
Which emulator are you using? I can see three reasons why saves might not be saved:
  • Some emulators might not support saving with mapper 0, despite that configuration having been used for Family BASIC.
  • You may first need to tell the emulator where to put the .sav file. Some emulators assume that the folder containing the ROM is read-only, such as when the ROM is in a shared folder that multiple users on your computer can read but not write, or when it's on a CD or DVD.
  • Some emulators name .sav files based on a hash of the ROM contents, which makes your saves inaccessible after you have rebuilt your program. I ran into this with Mednafen.
Ideally, I'd like to swap out only 128 background tiles at a time (I think 2KB worth) and have the largest CHR file to work with.
How quickly do you want to swap these tiles out? Do you need to swap them continuously, like the moving grass in Super Mario Bros. 2 and spinning coins and ? blocks in Super Mario Bros. 3, or are you swapping only between screens?

User avatar
raydempsey
Posts: 160
Joined: Sat May 31, 2014 4:12 pm

Re: Number of possible CHR banks

Post by raydempsey » Wed Jul 02, 2014 10:43 am

I am using FCEUX 2.2.2. No .sav file is being created. I believe the issue lies with mapper 0. What number should I set inesmap to instead?

What site would you recommend for learning about the advantages, disadvantages, and capacities of these mappers.

User avatar
koitsu
Posts: 4218
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Number of possible CHR banks

Post by koitsu » Wed Jul 02, 2014 11:41 am

There is no official or unofficial resource for such comparisons. You will need to investigate each by hand and see which meets your needs. Your game/thing = your code = your design = your choice = your responsibility. (I say that respectfully, not judgementally) Tepples' question at the bottom of his post didn't get answered either, and the answer to that would help narrow down your choices.

I can provide the following:

http://wiki.nesdev.com/w/index.php/Mapper
http://wiki.nesdev.com/w/index.php/Comp ... do_mappers
http://wiki.nesdev.com/w/index.php/List_of_mappers

Please note the 2nd link is a comparison of the Nintendo-branded mappers; there are lots of others (Konami, Namco, etc.) which are available and were used in commercial games legitimately which you can use.

I tend to advocate use of MMC3 (iNES mapper #4) as it provides fine-grained control over CHR bank swapping (down to regions as small as 1KByte) and doesn't involve a lot of "bit shifting" + "repeated writes" to accomplish a task (i.e. a single sta statement can do swapping, rather than for example MMC1 where you need to issue several stas to accomplish swapping), plus is well-supported by mainstream emulators and hardware kits (PowerPak, etc.).

tepples
Posts: 22171
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Number of possible CHR banks

Post by tepples » Wed Jul 02, 2014 11:42 am

raydempsey wrote:What site would you recommend for learning about the advantages, disadvantages, and capacities of these mappers.
You could play with the mapper wizard. Some of the availability recommendations are out of date, as I made it two years ago when retrousb.com was still selling ReproPak and before infiniteneslives.com started selling its own boards.

lidnariq
Posts: 9889
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Number of possible CHR banks

Post by lidnariq » Wed Jul 02, 2014 12:08 pm

I've also made a summary page on the wiki of all the remotely-well-documented mappers here:
nesdevwiki:User:Lidnariq/MMC3 Variants

I'm happy to move it from a userpage, but don't know where else on the wiki it'd belong instead.

User avatar
raydempsey
Posts: 160
Joined: Sat May 31, 2014 4:12 pm

Re: Number of possible CHR banks

Post by raydempsey » Wed Jul 02, 2014 1:25 pm

I have experimented by changing the inesmap value from 0 to 119, still won't allow me to write to $6000. When the time comes, I want to swap out as few tiles as possible when CHR bank switching. NES-TQROM sounds like I could accomplish what I want with bank switching but is there a mapper that is considering the best when it comes to bank switching?

tepples
Posts: 22171
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Number of possible CHR banks

Post by tepples » Wed Jul 02, 2014 2:39 pm

raydempsey wrote:I am using FCEUX 2.2.2.
What do you have in Config > Directories > Battery Saves?

User avatar
koitsu
Posts: 4218
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Number of possible CHR banks

Post by koitsu » Wed Jul 02, 2014 2:44 pm

lidnariq wrote:I've also made a summary page on the wiki of all the remotely-well-documented mappers here:
nesdevwiki:User:Lidnariq/MMC3 Variants

I'm happy to move it from a userpage, but don't know where else on the wiki it'd belong instead.
Sections "MMC3-like mappers with simple banking" and "MMC3-like mappers with outer banks" should probably go into a new page called "MMC3 variants" and that page should be linked to in the main MMC3 page (under References / See also) -- but before doing that, keep reading.

Section "Not-particularly-MMC3-like ASIC mappers" and "Discrete logic mappers" I have no idea what to do with.

Hrm... honestly what's needed is a table-ised page (a single page, not split across multiple pages) of all the mappers (in order of iNES mapper # and using the sortable table capability so people can sort by field) and all their capabilities/etc. summarised like what you've done throughout all those sections/tables. Words like "MMC3" in "bank style" need to become links to the MMC3 document/relevant mapper, etc. so that people can cross-reference what's what. Some of the formatting needs to be made consistent (ex. 16 + 16F vs. 16+16F (note spacing), same for TLSROM,TKSROM (again spacing)). The columns "PRG bank size" and "CHR bank size" should also have their unit specified in the column (ex. PRG bank size (kB)) else they're just arbitrary numbers.

Although I'll say this: I have no idea what "F" or "R" means, ex. 16+16F vs. 16F+16 vs. 2+6R, so a legend may be needed as well.

For ridiculous mappers that are designed by crazy idiots and consist of 9 billion things intermixed: best to just make a separate page for those mappers (or use the hopefully-existing iNES_Mapper_XXX wiki page) and clarify things there with a single row in the table saying "See {link to thingus}".

The page needs to be clear/concise to people who want a general overview of overall capabilities and not something with insane amounts of detail; what you have in "Comments" works great for a sort of "extra capabilities" line, ex. "Scanline IRQ, expansion audio", and that shouldn't get too out of control (mapper 5 / MMC5 is a good example of where it gets ridiculous). For example, I wouldn't want the page to end up looking like this clusterfuck on Wikipedia where you totally lose track of where you are + there are multiple tables for multiple things where one program is in one table but not another due to negligence on the part of the editor. TL;DR -- One mapper per row, one table. If you want me to start the page + design the existing template/layout, I can do that.

Post Reply