Page 1 of 1

Questions about banking

Posted: Sun Aug 13, 2006 10:54 am
by visy
I'm using mapper 0 for my test demo, which works fine.

I have some difficulty understanding the relation of the banks and the ROM-sizes. The numbering of banks also confuses me.

Mapper 0 documentation states that it's PRG-ROM may be 16k or 32k.

I've laid out my program like this:

Code: Select all

  .inesprg 1
  .ineschr 1
  .inesmir 0
  .inesmap 0

  .bank 2

  .org $0000
  .incbin "demo.chr" ;8kb of CHR-ROM

  .bank 0  
  .org $8000
  .incbin "song.bin" ;nerdtracker 2 tune, about 7kb

RESET:

  ;  code goes here

nmi:
  ; nmi routine here

irq: ; blank

  .bank 1

  .org $FFFA
  ; pointers to reset, irq & nmi here

Now, I'd like to add a DPCM sample to $c000 by stating

Code: Select all

  .org $c000
  .incbin "sample.dmc" ;4kb of sample data
after the irq routine. This, however, screws up the program. My code isn't that long, and it doesn't overlap $c000.

Also, say that I would like to have another 16k of CHR-ROM. What is the best way to change between the different roms in code? (I've tested MMC1 and got it to work to some degree).

EDIT: Also, if I remove the song incbin, the rom doesn't work. I'm doing something fundamentaly wrong here, but I really don't know what. Help is much appriciated.

Posted: Sun Aug 13, 2006 11:35 am
by Quietust
If you're using NESASM (which you really shouldn't be, since it sucks), $C000 starts at bank 1. Also, you should set your .inesprg count to 2.

Posted: Sun Aug 13, 2006 11:38 am
by visy
Yes, I am using NESASM, and I concur, it does suck.

What is the most convenient assembler for NES work?

Posted: Sun Aug 13, 2006 11:42 am
by Memblers
I've never understood NESASM's banking, so I don't know whats going on there. The way the code looks, (.org $8000 followed by .org $FFFA) would usually make a 32kB ROM (then the emu would complain when you loaded it, since you have it set to 1 PRG bank). When there's one PRG bank (16kB), it gets placed at $8000-$BFFF and $C000-$FFFF, mirrored. You could just align it after the NSF and put the DPCM sample at $D000 (same as $9000 if it's 16kB PRG).

Mapper 3 (CNROM) is good for simple CHR-ROM switching. Let's you chose from 4 different 8kB pages. Just write the page number to ROM like this (compensates for bus conflicts):

Code: Select all

label:
 lda #1
 sta label+1  ; writes 1 to the 1 in ROM

Posted: Sun Aug 13, 2006 12:55 pm
by tepples
visy wrote:What is the most convenient assembler for NES work?
CA65, once you've made or found a proper link script.

Posted: Sun Aug 13, 2006 1:29 pm
by visy
After few hours of hacking, I managed to get TASM working. Thank you all for help.