Bank Switching
Moderator: Moderators
-
- Posts: 2158
- Joined: Sun Jun 05, 2005 2:04 pm
- Location: Minneapolis, Minnesota, United States
- Contact:
Oh, I suppose you're right about the small routine thing. Yeah, I agree that that'd be alot better.
But when you're working on a project such as the one I'm working on, you NEED bankswitching. I'm working on a HUGE RPG, and when you get sucked into a battle, you'll want to switch banks, of course. And there'll be banks with enemy data in them that you'll want to copy data to RAM from, so bankswitching is absolutely neccisary.
Okay, I'm sorry, but really didn't understand what you guys were talking about by a copy of the same code in each bank in the same place when using 32k PRG banks. When you switch 32k PRG banks, is it like, you switch from bank 0 and 1 to 2 and 3 or something? Or like 0 and 1 to 4 and 5, or something like that? And you said that with SUROM they use one of the extra CHR bits to switch banks. How can you just manipulate the registers to use the CHR bits to bank switch? That doesn't make any sense. Please explain, if you will .
But when you're working on a project such as the one I'm working on, you NEED bankswitching. I'm working on a HUGE RPG, and when you get sucked into a battle, you'll want to switch banks, of course. And there'll be banks with enemy data in them that you'll want to copy data to RAM from, so bankswitching is absolutely neccisary.
Okay, I'm sorry, but really didn't understand what you guys were talking about by a copy of the same code in each bank in the same place when using 32k PRG banks. When you switch 32k PRG banks, is it like, you switch from bank 0 and 1 to 2 and 3 or something? Or like 0 and 1 to 4 and 5, or something like that? And you said that with SUROM they use one of the extra CHR bits to switch banks. How can you just manipulate the registers to use the CHR bits to bank switch? That doesn't make any sense. Please explain, if you will .
You switch from any bank, to any bank. The point to having code at the same address is so you can just jump or JSR to it from any bank. What I did in that code on one program was keep track of the current bank, push it on the stack, set the new bank and JSR to the (banked) subroutine, then comes back, restores the old bank, and RTS's back to wherever.Celius wrote: Okay, I'm sorry, but really didn't understand what you guys were talking about by a copy of the same code in each bank in the same place when using 32k PRG banks. When you switch 32k PRG banks, is it like, you switch from bank 0 and 1 to 2 and 3 or something? Or like 0 and 1 to 4 and 5, or something like that?
It's just a matter of wiring on the board. They hooked one of the pins from the mapper up to the PRG instead of CHR chip, bankswitching output bits are just latched bits (basically one bit of memory) that could be hooked up to whatever.And you said that with SUROM they use one of the extra CHR bits to switch banks. How can you just manipulate the registers to use the CHR bits to bank switch? That doesn't make any sense. Please explain, if you will .
-
- Posts: 2158
- Joined: Sun Jun 05, 2005 2:04 pm
- Location: Minneapolis, Minnesota, United States
- Contact:
Okay, so when using 32k banks, you can have 512k of PRG right? Because this is neccissary for my project. And it's just for bankswitching right? Like you still have 16k banks, but you switch 32k at a time? Or what?
And how would you code a game that runs with SUROM to use the 2 CHR bits to do bankswitching?
EDIT: Also, I don't know if JSRing to banks is that neccissary. I think that having a routine like this:
I'd have that at the beggining of every bank, so I could jmp to it with a specific value in A so it would switch banks. But I should have a routine that takes saved High/Low adresses and jumps to them. That'd be helpful.
And how would you code a game that runs with SUROM to use the 2 CHR bits to do bankswitching?
EDIT: Also, I don't know if JSRing to banks is that neccissary. I think that having a routine like this:
Code: Select all
.org $8000
jmp +
ldx #5
;This is a routine that was jumped to with the value #$02 in A
- sta $E000
lsr a
dex
bne -
+
;whatever code you want here
There was also a pirate MMC3 variant that uses the CHR bankswitcher to switch which 512k the MMC3 sees, so it can have up to 1024k PRG (with 8k chr ram). Fceu emulates it on standard mmc3, other emulators don't.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
SUROM is needed for 512kb. No matter if you use 32kb or 16kb banks. If you use 32kb, the lowest bankswitching bit is "forced" to be zero, no matter how it actually is. So switch the 32kb bank 2 (or 3, no matter) in $8000-$ffff will switch the 16kb bank 2 in $8000-$bfff and 16kb bank 3 in $c000-$fffff. In my opinion, using 32kb bank is crazy in most cases, except if you're doing very tricky tricks, and I'll think to only use 16kb banks if I were you. I really ask how most Rare games does to use only 32kb bankswitching.
But, it's up to you to plan your own bankswitching strategies to get a larger rom. You don't have to think the most tricky it is, the best it is, because it isn't. If using SOROM, a particular bit in MMC1 reg 2 or reg 3 sets the MSB of bankswitching, so you'll need to upload 2 MMC1 regs when bankswitching. It isn't very complicated. Also, you won't need destroy a Dragon Warrior 3 or 4 card to get a real SUROM board fortunately. You can modify a simple Zelda cart to have a SUROM configuration.
But, it's up to you to plan your own bankswitching strategies to get a larger rom. You don't have to think the most tricky it is, the best it is, because it isn't. If using SOROM, a particular bit in MMC1 reg 2 or reg 3 sets the MSB of bankswitching, so you'll need to upload 2 MMC1 regs when bankswitching. It isn't very complicated. Also, you won't need destroy a Dragon Warrior 3 or 4 card to get a real SUROM board fortunately. You can modify a simple Zelda cart to have a SUROM configuration.
Useless, lumbering half-wits don't scare us.
GNROM, BNROM, and the Color Dreams board also have 32 KB PRG bankswitching. As long as you're not using DMC, it's easy to work around the bankswitching limitation using jump tables in RAM or jump tables duplicated through the last 1 KB of each PRG bank.Bregalad wrote:In my opinion, using 32kb bank is crazy in most cases, except if you're doing very tricky tricks, and I'll think to only use 16kb banks if I were you. I really ask how most Rare games does to use only 32kb bankswitching.
Yeah, it is do-able, but it still is much easier to work with one hardwired bank, I think. 32kb banks maybe allow you to place all data and code related together in the same bank.
For example, you'll have 32kb with all maps and all code that do something with the maps, 32kb with all music and you music replay code, 32kb with all text of the games and all programm that shows text, etc...
If you want more than 32kb, you'll have to be very tricky.
In a standard configuration, you'd rather have data in the bankswitched part and code in the hardwired place, OR have both code and data bankswitched.
For example, you'll have 32kb with all maps and all code that do something with the maps, 32kb with all music and you music replay code, 32kb with all text of the games and all programm that shows text, etc...
If you want more than 32kb, you'll have to be very tricky.
In a standard configuration, you'd rather have data in the bankswitched part and code in the hardwired place, OR have both code and data bankswitched.
Useless, lumbering half-wits don't scare us.
Read this again :Celius wrote:Thanks for replies. But I'm just wondering if 32k banks are neccissary for SUROM? Do you NEED 32k banks for SUROM? If not, how would you CODE MMC1 to use the CHR bits for bankswitching?
If you don't understand ask about what you don't understand and don't just re-ask the whole question.--------------------------------------------------------------------------------
SUROM is needed for 512kb. No matter if you use 32kb or 16kb banks. If you use 32kb, the lowest bankswitching bit is "forced" to be zero, no matter how it actually is. So switch the 32kb bank 2 (or 3, no matter) in $8000-$ffff will switch the 16kb bank 2 in $8000-$bfff and 16kb bank 3 in $c000-$fffff. In my opinion, using 32kb bank is crazy in most cases, except if you're doing very tricky tricks, and I'll think to only use 16kb banks if I were you. I really ask how most Rare games does to use only 32kb bankswitching.
Any I don't see what you mean by coding the MMC1. You just have to make sure to understand that one bits of the MMC1 registers that normally apply to CHR selection bits is the upper bit of the PRG-ROM selection value, and if you want more deail read the wiki or hack Dragon Warrior 3.
Useless, lumbering half-wits don't scare us.
-
- Posts: 2158
- Joined: Sun Jun 05, 2005 2:04 pm
- Location: Minneapolis, Minnesota, United States
- Contact:
Okay, I'm going to ask my question, hopefully for the last time, but way clearer.
How is one supposed to code a game that runs with SUROM, and have it run on an emulator? I know you can rewire it on an actual cartridge, but how do you make it run via an emulator? How do you tell the ROM to use the CHR bit for PRG bankswitching? You can't just magicly have the ROM use the CHR bit for switching PRG banks, you have to do something to the ROM to have it do that. What is that something?
How is one supposed to code a game that runs with SUROM, and have it run on an emulator? I know you can rewire it on an actual cartridge, but how do you make it run via an emulator? How do you tell the ROM to use the CHR bit for PRG bankswitching? You can't just magicly have the ROM use the CHR bit for switching PRG banks, you have to do something to the ROM to have it do that. What is that something?
You make the PRG ROM 512KB long. Seriously, this is how most (if not all) emulators support the NES-SUROM board when presented as iNES mapper 1.Celius wrote:How do you tell the ROM to use the CHR bit for PRG bankswitching?
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
P.S. If you don't get this note, let me know and I'll write you another.