Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
dtothefourth
Posts: 6
Joined: Wed Jul 29, 2020 12:11 am

Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes

Post by dtothefourth »

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.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes

Post by lidnariq »

How big is your expanded PRG?
dtothefourth
Posts: 6
Joined: Wed Jul 29, 2020 12:11 am

Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes

Post by dtothefourth »

I expanded it from 2 16kb pages to 4 16kb pages.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes

Post by lidnariq »

And your init stub fits in the last 8KB?
dtothefourth
Posts: 6
Joined: Wed Jul 29, 2020 12:11 am

Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes

Post by dtothefourth »

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
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes

Post by lidnariq »

No, that looks plausible. When you're testing in Mesen, have you turned on all the recommended-for-developers options in Options / Emulation/ Advanced ?
FrankWDoom
Posts: 260
Joined: Mon Jan 23, 2012 11:27 pm

Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes

Post by FrankWDoom »

What's the address for Init? Does that sub initialize the stack? Are you possibly wiping your return from jsr address?
dtothefourth
Posts: 6
Joined: Wed Jul 29, 2020 12:11 am

Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes

Post by dtothefourth »

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.
dtothefourth
Posts: 6
Joined: Wed Jul 29, 2020 12:11 am

Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes

Post by dtothefourth »

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
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes

Post by calima »

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?
dtothefourth
Posts: 6
Joined: Wed Jul 29, 2020 12:11 am

Re: Expanded ROM works in Mesen, Emuhawk, FCEUX but not QuickNes

Post by dtothefourth »

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.
Post Reply