Expansion ROM what is it? ($4020..$5FFF)

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
Petruza
Posts: 311
Joined: Mon Dec 22, 2008 10:45 pm
Location: Argentina

Expansion ROM what is it? ($4020..$5FFF)

Post by Petruza » Thu Jun 25, 2015 7:08 pm

I've seen that the memory region $4020..$5FFF is labeled as Expansion ROM.
But haven't seen any description of what expansion ROM is.
Searching for "expansion" won't yield significant results in the wiki or in this forum. (other than referring to expansion audio or expansion port)
The iNES header does not specify presence or absence of such ROM.

So what is it? is it mapper-specific?
Is it a general-purpose ROM that can be supplied in the cart?
How do you know if a cart has expansion ROM?

User avatar
rainwarrior
Posts: 7824
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Expansion ROM what is it? ($4020..$5FFF)

Post by rainwarrior » Thu Jun 25, 2015 7:38 pm

Where have you seen this terminology?

That region can be used by various mappers in different ways, but it's not necessarily ROM. With most mappers it's nothing. With some mappers, it may be ROM, RAM, or control registers.

This might help: http://wiki.nesdev.com/w/index.php/CPU_memory_map

lidnariq
Posts: 9500
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Expansion ROM what is it? ($4020..$5FFF)

Post by lidnariq » Thu Jun 25, 2015 8:24 pm

With the exception of the NROM-368 proposal, no mapper has ever put ROM in that region. And only the MMC5 has put RAM in a portion of it.

User avatar
Petruza
Posts: 311
Joined: Mon Dec 22, 2008 10:45 pm
Location: Argentina

Re: Expansion ROM what is it? ($4020..$5FFF)

Post by Petruza » Fri Jun 26, 2015 5:55 am

rainwarrior wrote:Where have you seen this terminology?
In two different docs both named NES documentation by Patrick Diskin and Jeremy Chadwick
rainwarrior wrote:This might help: http://wiki.nesdev.com/w/index.php/CPU_memory_map
Yes I had seen that, but it just labels $4020..$FFFF as Cartridge space: PRG ROM, PRG RAM, and mapper registers not specifying exactly what's below $6000.
lidnariq wrote:With the exception of the NROM-368 proposal, no mapper has ever put ROM in that region. And only the MMC5 has put RAM in a portion of it.
So except for NROM-368 and MMC5 my emu could just ignore this memory area completely and get away with it?

lidnariq
Posts: 9500
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Expansion ROM what is it? ($4020..$5FFF)

Post by lidnariq » Fri Jun 26, 2015 10:30 am

Mmm, I didn't say that no mapper put nothing there.
A bunch of mappers put registers there, q.v. nesdevwiki:Category:Mappers using $4020-$5FFF

User avatar
Petruza
Posts: 311
Joined: Mon Dec 22, 2008 10:45 pm
Location: Argentina

Re: Expansion ROM what is it? ($4020..$5FFF)

Post by Petruza » Fri Jun 26, 2015 2:17 pm

Oh, that link explains it better!

By the way, I'm only testing mapper 0 games, and Brush Roller tries to write a 0 to $4800, is this right?
Many other games do work, and the CPU passed the Kevtris test so I'm pretty sure it does not mess addresses up.

lidnariq
Posts: 9500
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Expansion ROM what is it? ($4020..$5FFF)

Post by lidnariq » Fri Jun 26, 2015 2:40 pm

Hard to know. Without access to the physical hardware, we can't tell if it was supposed to do anything, and even if it didn't in the released cartridge, without talking to the developer it's hard to know what it ever was supposed to do.

The only thing we can say is that the game seems to work fine without doing anything in response.

zzo38
Posts: 1067
Joined: Mon Feb 07, 2011 12:46 pm

Re: Expansion ROM what is it? ($4020..$5FFF)

Post by zzo38 » Sat Jun 27, 2015 11:45 am

There are other possible reasons that a program writes to addresses that there is nothing mapped into:
  • For debugging purposes; a debugger might be programmed to breakpoint on writes to those addresses (some unofficial opcodes might also be used for debugging purposes in some games)
  • For timing purposes; using up an exact number of bytes and an exact number of cycles
  • Compatibility with another mapper the game is also designed to work on
  • Use with specialized kinds of Famiclone hardware or specialized kinds of emulators
  • To support later patching
  • As an explicit side-effect of some other code (for example the music engine (but not the NSF) in Attribute Zone will write something both to $00,X and to $4000,X and expect unmapped addresses to do nothing)
What exactly is mapped to actually the entire address space (except the APU registers possibly???) is done by the cartridge, although some things are internally mapped ($0000-$3FFF) and if the cartridge maps stuff there it cannot override the internal mapping.

For example, some believe (I don't know whether or not it is true) that MMC5 maps a write-only register over some of the PPU registers in order to determine how tall the sprites are. Famizork also mirrors mapper registers at $1xxx and $3xxx (as well as $5xxx and $7xxx), not only because this simplifies the hardware, but also to speed up bankswitching.
[url=gopher://zzo38computer.org/].[/url]

User avatar
rainwarrior
Posts: 7824
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Expansion ROM what is it? ($4020..$5FFF)

Post by rainwarrior » Sat Jun 27, 2015 2:05 pm

Occasionally you get strange memory accesses due to a bug in the software, like Low G Man which accidentally ended up relying on the open bus behaviour from out of bounds reads.

User avatar
thefox
Posts: 3141
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: Expansion ROM what is it? ($4020..$5FFF)

Post by thefox » Sat Jun 27, 2015 10:21 pm

Adventures of Lolo has a bunch of leftover FDS audio register writes in its sound initialization code:

Code: Select all

        lda     #$80
        sta     $4089
        ldx     #$1F
LDD32:  lda     #$00
        sta     $4040,x
        lda     #$3F
        sta     $4060,x
        dex
        bpl     LDD32
        lda     #$00
        sta     $4089
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi

Post Reply