BNROM - emulation vs real NES

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

User avatar
toggle switch
Posts: 139
Joined: Fri Sep 30, 2016 8:57 pm

BNROM - emulation vs real NES

Post by toggle switch »

can anybody elucidate the known differences between BNROM on an emulator (FCEUX, but willing to try others) vs on a real NES?
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: BNROM - emulation vs real NES

Post by lidnariq »

Only differences should be:
Some implementations of mapper 34 conflate NINA-001 and BNROM; this should only matter if your code writes to $7FFD,E,F and needs a bankswitch to not occur.
Some implementations don't enforce bus conflicts.

BNROM is so simple that I'd be inclined to suspect uncharted 2A07/2C07 territory instead.
User avatar
toggle switch
Posts: 139
Joined: Fri Sep 30, 2016 8:57 pm

Re: BNROM - emulation vs real NES

Post by toggle switch »

i believe i use

Code: Select all

noBusConflict:
    lda #$01
    sta noBusConflict+1 
for all bankswitches. that should avoid all bus conflicts, right?
BNROM is so simple that I'd be inclined to suspect uncharted 2A07/2C07 territory instead.
what do you mean by this?
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: BNROM - emulation vs real NES

Post by tepples »

Slight timing differences between NTSC chipset (2A03/2C02) and the PAL chipset (2A07/2C07) can affect mapper compatibility in edge cases. This includes not only the number of dots per CPU cycle (3 vs. 3.2) but also what fraction of time the M2 is high vs. low, when /PRGSEL goes high or low relative to other signals, etc. But the only difference between BNROM and AMROM is nametable mirroring, and several games for PAL NES are on AxROM.

Other differences to look into include initial RAM contents and initial bank number. Recent versions of FCEUX allow for different RAM preloads ($00, $FF, and random).
User avatar
toggle switch
Posts: 139
Joined: Fri Sep 30, 2016 8:57 pm

Re: BNROM - emulation vs real NES

Post by toggle switch »

RAM gets re-written to all zeroes at reset.

and all the banks contain the same reset code, which switches to bank 0 after the first vBlank.
Slight timing differences between NTSC chipset (2A03/2C02) and the PAL chipset (2A07/2C07) can affect mapper compatibility in edge cases. This includes not only the number of dots per CPU cycle (3 vs. 3.2) but also what fraction of time the M2 is high vs. low, when /PRGSEL goes high or low relative to other signals, etc. But the only difference between BNROM and AMROM is nametable mirroring, and several games for PAL NES are on AxROM.
the problem i'm having is that

1) the audio plays normally. it needs to be switched into during an NMI. so that code is running correctly, every frame, bankswitches and all. controllers (start button, mainly) also being read and responding.
2) the graphics don't display at all.
3) the whole thing resets at a time when it should not.

i would think it was just a problem with my code (likely) but it seems to be working on emulators and an AVS, and on PAL emulation. i can't test my NTSC machine because it gives me a blinking light, but the PAL machine is causing problems. wouldn't be surprised if the NTSC gave trouble too though.
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: BNROM - emulation vs real NES

Post by rainwarrior »

You can verify that your ROM isn't writing the NINA registers with a breakpoint.

I would also recommend putting a read/write breakpoint on all regions where memory access is unexpected. (e.g. $0800-1FFF, $2008-$3FFF, $4020-$7FFF)

The behaviour of FCEUX for the "open bus" regions where nothing is connected is especially different from a real NES (though Nintendulator gets this stuff correct). A well behaved program wouldn't be reading or writing there, though, under normal circumstances.

A lot of emulators will stick WRAM at $6000-7FFF at nearly all times, which can also mess with this area that's supposed to be open bus. Similarly flash carts might do something that modifies this behaviour as well.

Oh, and put FCEUX on "New PPU" mode if you haven't. This is much more accurate PPU behaviour.
User avatar
toggle switch
Posts: 139
Joined: Fri Sep 30, 2016 8:57 pm

Re: BNROM - emulation vs real NES

Post by toggle switch »

hmm. everything works fine in nintendulator, and in new PPU mode in FCEUX.

i wonder if there isn't some strange PAL/powerpak/BNROM problem happening. i guess i'll make sure i'm not reading/writing from any strange addresses, but i don't see how or why i would be doing that.
User avatar
gauauu
Posts: 779
Joined: Sat Jan 09, 2016 9:21 pm
Location: Central Illinois, USA
Contact:

Re: BNROM - emulation vs real NES

Post by gauauu »

I'd definitely recommend trying a few other emulators. If you can find one that reproduces the problem, you'll have a lot easier time debugging. (Particularly if that emulator had a debugger)

Edit: you beat me to it
na_th_an
Posts: 558
Joined: Mon May 27, 2013 9:40 am

Re: BNROM - emulation vs real NES

Post by na_th_an »

Neslib, which works correctly in PAL in real hardware and with bankswitching (I've tested GNROM-like and UNROM), starts by setting to 0 all PPU_MASK & PPU_CTRL, then waits for a full frame:

Code: Select all

initPPU:
    bit PPU_STATUS
@1:
    bit PPU_STATUS
    bpl @1
@2:
    bit PPU_STATUS
    bpl @2
Then clears the palette, then clears VRAM, then clears RAM, sets SP, and then initializes the library. And only after everything has been set up, the NMI is enabled. Some extra stuff is performed before my code (which pages in PRG-ROM 0 / CHR-ROM 0 or whatever the startup configuration should be) even runs.

Maybe you are attempting to do things too early? (Just a guess from somebody not very literate, mind you)
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: BNROM - emulation vs real NES

Post by FrankenGraphics »

toggle switch wrote:i can't test my NTSC machine because it gives me a blinking ligh
If you're willing to let your unit go under the knife, desoldering, lifting or grounding pin 4 on the lockout chip is not only good for region unlocking but also increases the reliability considerably even if the consoles' connector is somewhat corroded or dirty.
toggle switch wrote:2) the graphics don't display at all.
To elaborate this, the screen is black but probably ought to be gray (ie $00) or rarely some other random colour if not initialized (which it is here) so i think it is displaying *something* (after all, there are 10 blacks)?

...general question: the floodfill (ie "universal background colour") is still filling the screen with bg rendering turned off, right?
rainwarrior wrote:the behaviour of FCEUX for the "open bus" regions where nothing is connected is especially different from a real NES (though Nintendulator gets this stuff correct
Graphics are displaying in nintendulator. fwiw the game behaves quite differently in both fceux and nintendulator in PAL mode (fceux: music ok but ingame movement jittery. nintendulator: music off but movement correct).
na_th_an wrote:Neslib, which works correctly in PAL in real hardware and with bankswitching (I've tested GNROM-like and UNROM) [...] Maybe you are attempting to do things too early?
i've written some really sloppy inits on powerpak/pal +nrom/unrom and they're fine, for what it is worth. Without proper warmup the worst i've gotten is a bit of a rolling picture. toggle switchs' CNROM version of the game ran fine on powerpak/pal and i believe the init is the same on the BNROM version.
User avatar
toggle switch
Posts: 139
Joined: Fri Sep 30, 2016 8:57 pm

Re: BNROM - emulation vs real NES

Post by toggle switch »

Graphics are displaying in nintendulator. fwiw the game behaves quite differently in both fceux and nintendulator in PAL mode (fceux: music ok but ingame movement jittery. nintendulator: music off but movement correct).
hmm, can't replicate this. nintendulator works fine for me, both music and movement. fceux looks a bit janky with the movement but i think it's not really intended as a PAL emulator and maybe needs some kinks worked out - i don't think the movement jitter is an issue with my code, i don't see how it could be. either way, neither one displays behavior that currently is bothering me.
User avatar
gauauu
Posts: 779
Joined: Sat Jan 09, 2016 9:21 pm
Location: Central Illinois, USA
Contact:

Re: BNROM - emulation vs real NES

Post by gauauu »

If it makes you feel any better, I just tried my big project (which eventually will target GTROM, but I've been testing with BNROM) on my powerpak and it didn't work right -- just a black screen with some weird graphical artifacts in the middle.

I do some things (larger number of banks, 4 nametables) that the emulators tend to support but aren't traditional BNROM features, so that may have something to do with it. I haven't spent any time debugging or testing further, but just thought it would be worth noting. (although it's just as likely that my issue is completely different than yours and I'm doing something dumb also.)
User avatar
toggle switch
Posts: 139
Joined: Fri Sep 30, 2016 8:57 pm

Re: BNROM - emulation vs real NES

Post by toggle switch »

bummer! mostly, i'm frustrated by my inability to test it properly. once i have that 'working' i'll feel a bit better cause i'll have the chance to fix it.

the only thing i can think is that i'm not sure if emulators start you off on a random bank? does anybody know of one that does? i'm pretty certain jumping to bank 0 happens pretty much immediately, but still.
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: BNROM - emulation vs real NES

Post by lidnariq »

Most emulators seem to boot (not by design, but because of how uninitialized memory works on modern machines) from bank 0.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: BNROM - emulation vs real NES

Post by tepples »

gauauu wrote:I do some things (larger number of banks, 4 nametables) that the emulators tend to support but aren't traditional BNROM features, so that may have something to do with it.
PowerPak and FCEUX have no trouble supporting oversize BNROM (up to PowerPak's maximum of 4 Mbit) since second quarter 2011 when I released BNTest. Haunted: Halloween '85 and Lizard both use a 4 Mbit BNROM, as did early builds of the first volume of Action 53 before the specialized mapper was added to support STREEMERZ as the flagship title. The 4-screen I haven't tried though.
Post Reply