(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
05-07-24 09:51 AM
0 users currently in ROM Hacking.
Acmlm's Board - I3 Archive - ROM Hacking - Question about NES Bank Switching New poll | |
Add to favorites | Next newer thread | Next older thread
User Post
spel werdz rite









Since: 11-19-05

Last post: 6288 days
Last view: 6287 days
Posted on 06-24-06 01:34 PM Link | Quote
Okay, I finally learned how to expand the Super Mario Bros. ROM, I can work it with 128kb.
Anyways, my knowledge of 6502 is limited. I've picked up some tutorials that talk about switching which bank the emulator loads slightly, but I still don't get it. So if someone could offer a more in depth explanation of how to switch banks in NES, please tell me and I'll be thankful you did.
AP

Waddle Dee


 





Since: 11-17-05

Last post: 6526 days
Last view: 6526 days
Posted on 06-24-06 04:11 PM Link | Quote
NES games switch banks with Mappers, which are extra chips inside cartridges. They can switch PRG-ROM banks and/or CHR-ROM banks in different sizes; PRG banks are switched in either groups of 32K banks, 16K banks, and/or 8K banks at the $8000-$FFFF CPU memory space; CHR banks are switched in either groups of 8K, 4K, 2K, and/or 1K banks at the $0000-$1FFF PPU memory space. Some mappers have CHR-RAM instead of CHR-ROM, so games with CHR-RAM have their GFX imbedded inside PRG-ROM. Some also support extra battery-backable PRG-RAM at (usually) $6000-$7FFF, IRQ generators powered by scanline (or CPU cycle) counters used to acheive raster effects (usually split screen effects for status bars), nametable mirroring, and even extra sound channels. Mappers usually have their registers at the $8000-$FFFF memory range, but some mappers have their registers at around $4018-4FFF, $5000-$5FFF, or $6000-$7FFF.

This page contains some pages that explain how to use some of the mappers' registers; this document also explains the registers of some mappers and which banks are automatically switched on power-up, but keep in mind that the former is more accurate in register info than the latter. (MMC3, a common mapper, always switches the last 8K bank to $E000-$FFFF on power-up; it's not known which banks get switched to $8000-$DFFF). However, some mappers have bus conflicts; those are explained here.

For SMB, you'll have to put some of the reset routine into a fixed bank (one that always gets switched to an area at power-up) and set up the mapper registers. You might have to enable PRG-RAM, write some code there from a bank, and JMP to PRG-RAM; from there you'll have to set up other banks needed and JMP back to the regular reset routine. If you're using a mapper with a fixed bank that can't be swapped (such as MMC3), you'll have to replace some data with the new reset routine, and you could relocate this data to somewhere at PRG-RAM. Keep in mind that you'll have to find out what accesses that data, so you'll have to modify code that needs the data. More on reset routines can be found here. Examples of popular mappers include Nintendo MMC1, used by Metroid and Zelda, and the MMC3, used by SMB2, SMB3, and Kirby's Adventure. If this sounds a bit confusing for you, you might want to read some more documents about the NES (such as IRQs, the PPU, etc.).


(edited by AP on 06-24-06 03:12 PM)
(edited by AP on 06-24-06 05:53 PM)
(edited by AP on 06-24-06 06:01 PM)
(edited by AP on 06-25-06 05:10 PM)
d4s

Shyguy








Since: 12-01-05

Last post: 6409 days
Last view: 6307 days
Posted on 06-24-06 04:15 PM Link | Quote
this doesnt depend on the emulator, but on the mapper the game uses.
i might be talking out of my ass, cause i never coded anything serious on the nes, but afaik smb doesnt use any mapper at all.
that means you'd have to hack in support for a mapper.
i assume you mean you want to have 128kb of prg-rom, right?
mmc1 would be fine if you dont need anything but bankswitching.

to control the mapper, you'd first have to set the mirroring to vertical and prg and chr rom size (i assume using 8kb chr and 32k prg banks would be the easiest, cause thats what the games original size is).

it is probably very hard to convert a game that originally didnt use a mapper and if i was doing it, i would most likely copy the complete program code to every 32k bank, so i dont have to dig into the games code too deep.

if you just want to switch chr-rom (graphics) around, that probably alot easier.

also, be sure to look around for existing hacks of super mario bros, perhaps someone already did the work.

you can read up more about the mmc1 here: http://nesdev.parodius.com/mmc1.txt


[edit]
aww, ap beat me to it. O,o


(edited by d4s on 06-24-06 03:17 PM)
spel werdz rite









Since: 11-19-05

Last post: 6288 days
Last view: 6287 days
Posted on 06-24-06 04:29 PM Link | Quote
Alright, thank you both. I will look into what you said and see if I can do what I want to do.
never-obsolete

Paragoomba








Since: 05-14-06
From: AZ

Last post: 6289 days
Last view: 6289 days
Posted on 06-24-06 06:04 PM Link | Quote
Originally posted by spel werdz rite

Anyways, my knowledge of 6502 is limited.



you may need to learn more 6502 assembly because bank-switching only gets the code/data to be "visible" to the nes. it doesn't make the game use the new stuff, you'll have to code the routines yourself.

Originally posted by d4s

it is probably very hard to convert a game that originally didnt use a mapper



actually, depending on space in the unhacked rom, it might be easier. if you're modifiying a game to use a different mapper, it has to support all the same options as the one it originally had did or else you're gonna have to do quite a few bank-switching asm hacks to get the same net effect. if the game has nrom board you just have to make sure the original banks are swapped in when the game accesses them. and of course, as AP said, move the vector table/interrupt handlers and bank-switching code to a fixed bank.

what mapper did you have in mind, or what were you looking to accomplish?


(edited by never-obsolete on 06-24-06 09:50 PM)
Add to favorites | Next newer thread | Next older thread
Acmlm's Board - I3 Archive - ROM Hacking - Question about NES Bank Switching |


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.014 seconds; used 373.19 kB (max 447.12 kB)