This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

No. of PRG banks must be power of 2 in some emulators?

No. of PRG banks must be power of 2 in some emulators?
by on (#50522)
I haven't seen this mentioned in the available documentation, the wiki, nor this website. But I noticed when messing around with MMC1 that my rom will only work if the number of my PRG banks specified in my iNES header is a power of 2.

This only seems to be the case in FCEUXDSP and Nintendulator. JNES and Nestopia seem to be fine with (non powers of 2) numbers of PRG banks.
Re: No. of PRG banks must be power of 2 in some emulators?
by on (#50523)
ZomCoder wrote:
I haven't seen this mentioned in the available documentation, the wiki, nor this website. But I noticed when messing around with MMC1 that my rom will only work if the number of my PRG banks specified in my iNES header is a power of 2.

PRG ROM chips in actual NES games are a power of 2 bytes in size. Some CHR ROM images have unused space at the end (e.g. Smash TV, Tetris 2, and a few early CNROM games that used the diode based copy protection), but PRG is more likely to have its unused space in the middle.

by on (#50525)
That makes sense. I was experimenting with a simple MMC1 setup, placing 16k dummy PRG roms between the first PRG bank and the last PRG bank (where my code resides). I suppose the power of 2 is because every time you add an address line, you effectively double the amount of addressable memory, thus it is natural for chips to reflect this. I wonder why Nestopia's developers decided to not bother about this point?

by on (#50529)
Firebug's mapper document states that UNROM, MMC1, and MMC3 use the last 16 KiB of PRG for the fixed bank, and some emulators follow this. Other emulators may have an overly literal interpretation of the mappers' low-level behavior, which forces the bank bits to 15 (UNROM/UOROM) or 62-63 (MMC3). This interpretation would cause e.g. bank 15 of an UOROM not to fall in allocated ROM space. But a compromise interpretation would result in a ROM loader that replicates the last bank up to the next power of 2 when loading the ROM image. For example, a 96 KiB UNROM would be loaded as if the banks were arranged 0, 1, 2, 3, 4, 5, 5, 5.

by on (#50534)
The only Nintendo boards I know of with a discrete ROM decoder are MMC3 EPROM boards for development. They allowed 4x 1M PRG and 2x 1M CHR EPROM so a game's PRG could be 3M, but as soon as it went to a consumer board I believe it had to fit into a single 2^n ROM.

by on (#50819)
I'm working on my first NES game and while it runs in FCEUX, it won't run on anything else (Nestopia, Nintendulator, Nessie says wrong size). It's 64 kb. Is there anything wrong with the header or cfg?

Code:
.BYTE 4Eh, 45h, 53h, 1Ah
.BYTE 02h ; how many prg banks
.BYTE 00h ; how many chr banks (zero means chr ram)
.BYTE 10h ; lower nybble of mapper in bits 4-7
.BYTE 00h ; upper nybble of mapper in bits 4-7
.BYTE 00h ; how many ram banks
.BYTE 00h
.BYTE 00h ; unofficial flags
.BYTE 00h
.WORD 0000h,0000h


Code:
MEMORY {
ZP:  start = $00, size = $FF, type = rw, define=yes;
STACK: start = $100, size = $100, type = rw;
RAM: start = $200, size=$600, type = rw;
HEADER: start = $7FF0, size = $10, file = %O ,fill = yes;
ROM0: start = $8000, size = $4000, file = %O, fill = yes;
ROM1: start = $8000, size = $4000, file = %O, fill = yes;
ROM2: start = $8000, size = $8000, file = %O ,fill = yes;


}

SEGMENTS {
HEADER:   load = HEADER, type = ro,define=yes;
STARTUP:  load = ROM2, start=$C000, type = ro,define=yes;
CODE:     load = ROM2, start=$C000, type = ro,define=yes;
DATA:     load = ROM2, start=$E000, type = ro,define=yes;
VECTORS:  load = ROM2, start = $FFF4, type = ro,define=yes;

CHARS:    load = ROM0, start = $8000, type = ro, define=yes;

OAMBUF:      load = RAM, start = $0200, type = bss, define = yes;
BUFFER:      load = RAM, start = $0300, type = bss, define = yes;
ACTIONBUF:   load = RAM, start = $0400, type = bss, define = yes;
OBJECTS:   load = RAM, start = $0500, type = bss, define = yes;
VARS:      load = RAM, start = $0700, type = bss, define = yes;

BANKCODE: load = ROM1, type = ro;
ZEROPAGE: load = ZP,              type = zp;
}


by on (#50820)
strat wrote:
I'm working on my first NES game and while it runs in FCEUX, it won't run on anything else (Nestopia, Nintendulator, Nessie says wrong size). It's 64 kb. Is there anything wrong with the header or cfg?

Code:
.BYTE 4Eh, 45h, 53h, 1Ah
.BYTE 02h ; how many prg banks

The iNES header always expresses PRG size in 16384 byte units. This means the emulator expects 32768 bytes of PRG data, not 65536 bytes as you appear to intend. Different emulators attempt to correct different header defects, which may be why you see different behaviors in different emulators

by on (#50821)
Oh, Nestopia says 48kb of prg rom. Can't figure out how to change it for some reason...

by on (#50827)
Whoops, it's the oldest gotcha in the book. The old I included the header from another folder trick.