Bank switching - How Do you handle this in NESASM?

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

Post Reply
User avatar
rychan
Posts: 65
Joined: Wed Jun 21, 2017 1:51 pm
Contact:

Bank switching - How Do you handle this in NESASM?

Post 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?
Probably The "Most Filthy Casual" NES ASM Developer https://refreshgames.co.uk/
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

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

Post 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.
User avatar
rychan
Posts: 65
Joined: Wed Jun 21, 2017 1:51 pm
Contact:

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

Post by rychan »

Ah, so I don't need to set it out as 2 16kb banks then? just one solid 32kb bank.
Probably The "Most Filthy Casual" NES ASM Developer https://refreshgames.co.uk/
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

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

Post 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.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

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

Post by tepples »

That and DMC playback addresses start at $C000.
User avatar
rychan
Posts: 65
Joined: Wed Jun 21, 2017 1:51 pm
Contact:

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

Post 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!
Probably The "Most Filthy Casual" NES ASM Developer https://refreshgames.co.uk/
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

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

Post 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.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
rychan
Posts: 65
Joined: Wed Jun 21, 2017 1:51 pm
Contact:

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

Post 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?
Probably The "Most Filthy Casual" NES ASM Developer https://refreshgames.co.uk/
zzo38
Posts: 1096
Joined: Mon Feb 07, 2011 12:46 pm

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

Post 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.
(Free Hero Mesh - FOSS puzzle game engine)
User avatar
rychan
Posts: 65
Joined: Wed Jun 21, 2017 1:51 pm
Contact:

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

Post 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 :)
Probably The "Most Filthy Casual" NES ASM Developer https://refreshgames.co.uk/
Post Reply