Page 1 of 1

Bank switching - How Do you handle this in NESASM?

Posted: Sun Jul 30, 2017 1:49 pm
by rychan
So, I've got my Mapper #0 ROM showing up with 2 x 16k banks of PRG-ROM and 1 x 8kb bank of CHR-ROM inside Shiru's NES Space Checker, with the intention that I put all my level code into the second bank, whilst retaining the game code in bank #0, but I have no clue as to how bankswitching works on the NES.

I've used multiple 16kb banks on the gameboy with GBDK which kept the process fairly simple but can't figure out, or find, resources on how the NES would handle it all.

Do I need to write to a register somewhere to flip banks? Is the second bank just already present or is there something else at play?

Re: Bank switching - How Do you handle this in NESASM?

Posted: Sun Jul 30, 2017 1:53 pm
by lidnariq
Mapper 0 ('NROM') is "no" bankswitching.

The first 16 KiB of the provided PRG is mapped from $8000-$BFFF. The last 16KiB of the provided PRG is mapped from $C000-$FFFF. These locations cannot be changed at runtime.

This is basically identical to a 32KiB gameboy game.

Re: Bank switching - How Do you handle this in NESASM?

Posted: Sun Jul 30, 2017 2:02 pm
by rychan
Ah, so I don't need to set it out as 2 16kb banks then? just one solid 32kb bank.

Re: Bank switching - How Do you handle this in NESASM?

Posted: Sun Jul 30, 2017 2:06 pm
by thefox
rychan wrote:Ah, so I don't need to set it out as 2 16kb banks then? just one solid 32kb bank.
Right. The reason NES Space Checker displays everything as 16 KB banks is that the iNES ROM file format header stores the ROM size as a multiple of 16 KB.

Re: Bank switching - How Do you handle this in NESASM?

Posted: Sun Jul 30, 2017 3:10 pm
by tepples
That and DMC playback addresses start at $C000.

Re: Bank switching - How Do you handle this in NESASM?

Posted: Mon Jul 31, 2017 6:12 am
by rychan
Ahh, that's cool tepples, so I can just overflow the data without the unnecessary extra bank making. I'll expereiment with this tonight!

Re: Bank switching - How Do you handle this in NESASM?

Posted: Mon Jul 31, 2017 7:02 am
by thefox
Actually, in NESASM specifically you're forced to split everything into 8 KB banks, even though really it's a continuous 32 KB bank with no bankswitching needed. It's a limitation of the assembler.

Re: Bank switching - How Do you handle this in NESASM?

Posted: Mon Jul 31, 2017 4:24 pm
by rychan
Is there anyway to get around this limitation? I've made a bunch of attempts tonight to no avail, aside from grey screens of course.

Should I try another assembler perhaps?

Re: Bank switching - How Do you handle this in NESASM?

Posted: Mon Jul 31, 2017 5:16 pm
by zzo38
rychan wrote:Is there anyway to get around this limitation? I've made a bunch of attempts tonight to no avail, aside from grey screens of course.
Not in plain NESASM, although in Unofficial-MagicKit you can predefine the consecutive 8K banks with the same name, and then when you go from one bank to the next one will automatically do. Bank numbers in the assembler will still be 8K though.

Other assemblers will also avoid this limitation.

Re: Bank switching - How Do you handle this in NESASM?

Posted: Fri Aug 04, 2017 1:05 am
by rychan
Cool, I think I've found a way around it last night / this morning, whatever 1am really classes itself as anyway :) Thanks again for all your kind help, it's a fun struggle this ASM coding :)