Originally posted by: 3GenGames
Well you have to remember the last bank in the ROM is fixed somewhere, either lower or top 16KB. You need to put all the bankswitching code, NMI, etc. there. Could you post your source possibly? I'll fix it up so it works and show you what's wrong with it.
ETA: More detailed programming MMC1 info:
You need to have a mini boot routine (16 bytes is what you should shoot for. I have a 15 byte routine that returns the bank boot I am going to add below) that resets the mapper by writing >=128 to >=$8000. That will force all MMC1 chips to make the last 16KB be in the $C000 range to execute from, so you can just JMP [$FFFC] to the reset routine in the main bank to make sure it boots correctly. You CAN make the lower $8000 page be executed from, but that's not used or very very useful because when an NMI,IRQ, or RESET occur, the 6502 looks for them at locations $FFFA-$FFFF, so you NEED to have those there all the time. I hope that makes sense. But some MMC1's boot with the 16KB fixed at $C000 first, but ones like the original MMC1 are random and not reliable to assume that. On MMC1B2 I know the boot isn't random like the MMC1 no revision, MMC1B2 boots in the 16KB in the $C000 range. But to make sure it really works on all MMC1's and emus, make sure you have a little reset routine at the end of each 16KB bank.
(Code is for NESASM3, you really should make this a macro to use it.)
.org $FFF0
.db $00
MMC1GlitchBoot:
SEI
LDA #$80+(BANK(MMC1GlitchBoot)/2)
RTIBank14:
STA $8040
JMP [$FFFC]
.dw RTIBank+1 ;NMI
.dw MMC1GlitchBoot ;Reset
.dw RTIBank+1 ;IRQ
Code Comments:
I dunno WHY an IRQ would fire, but just in case I store to $8040 to reset the MMC1, but the $40 is used to also be the instruction for an RTI, so nothing bad will happen if an IRQ happens during reset.
On the LDA, I used that to determine what bank it booted in. It's not needed, just an extra feature.
Any Q's and you can ask. If you use this code....just use it.
Originally posted by: KHAN Games
Here you are.
Awesome. Thanks for the help, I finally got it working.
I think where I was going wrong was that you have to put in exactly double the amount of banks that it says in the inesheader, even if the banks are blank you still have to "declare" them and to number them all in order. I thought that they were just "declaring" them in the examples for clarity. As well, for this mapper I had to specify the chr even though I'm just using one.
It's the one nerdynights tutorial that I didn't find completely clear (though I haven't looked at the sound ones). I'm sure this will sound stupid now, but you know how he says you have to divide the bank numbers by two for the NESASM number? I thought he meant divide the address... so I was using half of $E000 and half of $C000 and trying tons of variations, and then I thought the mirroring might be damaging it etc.
]]>