Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes
Moderator: Moderators
-
- Posts: 6
- Joined: Wed Jul 29, 2020 12:11 am
Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes
I'm working with Gradius NES and recently swapped it to the MMC3 mapper and expanded the ROM, adding code to initialize the banks and properly update the CHR banks with the mapper change.
The game runs perfectly in almost every emulator but will no longer boot with the QuickNes core, just staying a totally black screen.
I'm not sure if I'm missing something about initialization that QuickNes does differently or doing something that QuickNes doesn't support and hoped maybe someone here had an idea before I drove myself crazy going in circles trying to make it work.
At first I thought maybe QuickNES initialized the swappable banks differently so I moved the reset vector to point at the static banks and initialize the banks there but that still didn't seem to help.
The game runs perfectly in almost every emulator but will no longer boot with the QuickNes core, just staying a totally black screen.
I'm not sure if I'm missing something about initialization that QuickNes does differently or doing something that QuickNes doesn't support and hoped maybe someone here had an idea before I drove myself crazy going in circles trying to make it work.
At first I thought maybe QuickNES initialized the swappable banks differently so I moved the reset vector to point at the static banks and initialize the banks there but that still didn't seem to help.
Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes
How big is your expanded PRG?
-
- Posts: 6
- Joined: Wed Jul 29, 2020 12:11 am
Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes
I expanded it from 2 16kb pages to 4 16kb pages.
Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes
And your init stub fits in the last 8KB?
-
- Posts: 6
- Joined: Wed Jul 29, 2020 12:11 am
Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes
Well, I moved the reset vector from $8010 to $FFC0 so it was in the last 8 kb. But space in Gradius was extremely limited so I switch out the second bank with one of the newly added banks and then jump to an initialization routine there that finishes setting up everything else
So the reset routine basically looks like this
#org $FFC0
Boot:
SEI
CLD
LDA #$07
STA $8000
LDA #$02
STA $8001
JSR Init ;routine in bank 2 that does the rest of the added initialization, sets the other prg bank and all the chr banks
LDA #$07
STA $8000
LDA #$01
STA $8001
JMP $8010 ;game's original reset routine
So the reset routine basically looks like this
#org $FFC0
Boot:
SEI
CLD
LDA #$07
STA $8000
LDA #$02
STA $8001
JSR Init ;routine in bank 2 that does the rest of the added initialization, sets the other prg bank and all the chr banks
LDA #$07
STA $8000
LDA #$01
STA $8001
JMP $8010 ;game's original reset routine
Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes
No, that looks plausible. When you're testing in Mesen, have you turned on all the recommended-for-developers options in Options / Emulation/ Advanced ?
-
- Posts: 260
- Joined: Mon Jan 23, 2012 11:27 pm
Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes
What's the address for Init? Does that sub initialize the stack? Are you possibly wiping your return from jsr address?
-
- Posts: 6
- Joined: Wed Jul 29, 2020 12:11 am
Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes
I toggled all of the options in Mesen's advanced settings and it made no difference, still works fine there.
Init is $A000, just right at the start of the swapped in bank, and all it does is initialize the banks like this
#org $A000
Init:
LDA #$06
STA $8000
LDA #$00
STA $8001
LDA #$00
STA $8000
LDA #$00
STA $8001
;repeated for the other chr banks
RTS
And considering it works on Mesen, FCEUX, Bizhawk with Emuhawk core, etc I don't think it's anything like that.
Init is $A000, just right at the start of the swapped in bank, and all it does is initialize the banks like this
#org $A000
Init:
LDA #$06
STA $8000
LDA #$00
STA $8001
LDA #$00
STA $8000
LDA #$00
STA $8001
;repeated for the other chr banks
RTS
And considering it works on Mesen, FCEUX, Bizhawk with Emuhawk core, etc I don't think it's anything like that.
-
- Posts: 6
- Joined: Wed Jul 29, 2020 12:11 am
Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes
Well, I figured it out but still a little uncertain why it worked on everything but QuickNES.
Later in the boot when I replaced the game's routine for changing CHR banks to work with MMC3 I used a JMP ($7FF0) to jump to an address stored in WRAM. Moving that to RAM made it work on QuickNES.
I guess indirect jumps from WRAM are allowed in everything but QuickNES? But not sure if that means most things are inaccurate in allowing that or that's an issue with QuickNES
Later in the boot when I replaced the game's routine for changing CHR banks to work with MMC3 I used a JMP ($7FF0) to jump to an address stored in WRAM. Moving that to RAM made it work on QuickNES.
I guess indirect jumps from WRAM are allowed in everything but QuickNES? But not sure if that means most things are inaccurate in allowing that or that's an issue with QuickNES
Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes
WRAM jumps should be totally fine, aka a quicknes issue. Try on hw for ground truth.
edit: A thought, did you remember to enable WRAM and give it writing perms before writing there? And keep it enabled for reading at least?
edit: A thought, did you remember to enable WRAM and give it writing perms before writing there? And keep it enabled for reading at least?
-
- Posts: 6
- Joined: Wed Jul 29, 2020 12:11 am
Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes
Oh, you are absolutely correct. I hadn't even considered that since it was working on all the other emulators but apparently as it says in the wiki about the A001 register "Many emulators choose not to implement them as part of iNES Mapper 4 to avoid an incompatibility with the MMC6"
Storing $80 to A001 during my init made it work with WRAM again, thanks for the assist.
Storing $80 to A001 during my init made it work with WRAM again, thanks for the assist.