Emulating 32 KB PRG RAM

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
ZeroDivisionGuy
Posts: 11
Joined: Sat May 15, 2021 4:38 pm

Emulating 32 KB PRG RAM

Post by ZeroDivisionGuy » Sun May 16, 2021 4:42 am

I want to emulate 32 KB of PRG RAM instead of 8 on FCEUX, Mesen or something else. How can i do that? What mapper do i need?
That RAM should be mapped from $4020 through $BFFF.

(I use only 16 KB of ROM, so the space beetween $4020 through $BFFF is free.)

User avatar
Ben Boldt
Posts: 856
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: Emulating 32 KB PRG RAM

Post by Ben Boldt » Sun May 16, 2021 9:41 am

It will be unusual to find a mapper that uses $4000-5FFF for RAM or ROM. Refer here for mappers that support large PRG-RAMs:
https://wiki.nesdev.com/w/index.php/Cat ... ge_PRG_RAM

Is there any reason you want a 32 kilobyte contiguous chunk of RAM instead of doing bankswitching? That would probably open up your options.

MMC5 has 5 8-kilobyte banks in mode 3:
6000-7FFF Always RAM
8000-9FFF Configurable to RAM or ROM
A000-BFFF Configurable to RAM or ROM
C000-DFFF Configurable to RAM or ROM
E000-FFFF Always ROM

Also: 5C00-5FFF can be configured as RAM.

This would allow a couple close options for you:
RAM from $5C00-BFFF (25 kilobytes) and ROM from $C000-FFFF (16 kilobytes)
RAM from $5C00-DFFF (33 kilobytes) and ROM from $E000-FFFF (8 kilobytes)

I am not aware of any other mapper that can map RAM to such a large area. If you are okay with bankswitching, that can vastly increase the space and probably allow you to use simpler mappers. MMC1 would be a very good candidate but you would have to use RAM only in the range $6000-7FFF and bankswitch it to get the full 32 kilobytes.

User avatar
ZeroDivisionGuy
Posts: 11
Joined: Sat May 15, 2021 4:38 pm

Re: Emulating 32 KB PRG RAM

Post by ZeroDivisionGuy » Sun May 16, 2021 11:26 am

Ben Boldt wrote:
Sun May 16, 2021 9:41 am
It will be unusual to find a mapper that uses $4000-5FFF for RAM or ROM. Refer here for mappers that support large PRG-RAMs:
https://wiki.nesdev.com/w/index.php/Cat ... ge_PRG_RAM

Is there any reason you want a 32 kilobyte contiguous chunk of RAM instead of doing bankswitching? That would probably open up your options.
Yes. It's for testing purposes.

User avatar
Dwedit
Posts: 4462
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Emulating 32 KB PRG RAM

Post by Dwedit » Sun May 16, 2021 3:09 pm

If you want to create something that has never existed on any cartridge (RAM available at 4020-5FFF region), you can modify an emulator yourself. You can even expand the base console RAM from 2K to 8K, and remove the memory mirroring.

But what kind of project needs this?
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

Myself086
Posts: 74
Joined: Sat Nov 10, 2018 2:49 pm

Re: Emulating 32 KB PRG RAM

Post by Myself086 » Sun May 16, 2021 3:12 pm

Dwedit wrote:
Sun May 16, 2021 3:09 pm
But what kind of project needs this?
viewtopic.php?f=22&t=23010

User avatar
Dwedit
Posts: 4462
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Emulating 32 KB PRG RAM

Post by Dwedit » Sun May 16, 2021 4:50 pm

Sounds like you need to make your own mapper, using a customized version of the emulator.

But there's a reason why mappers that use the 4xxx range are basically nonexistant.

A cartridge decoding 4020+ to be RAM would need to look at 11 address bits, and run combinational logic (AND, OR, NAND, etc) on it to see if it is in range or not, then generate the 'chip enable' bits that the RAM chip would need to see.
If you were making something like this today, you'd use a CPLD chip to check 11 bits.

It would be a lot of hardware for an NROM-like mapper, but with RAM. Hence why nobody wanted to build cartridges that would check the 4020-4FFF page (one exception, the Famicom Disk System).

Decoding 5000+ would require only 4 address bits rather than 11 address bits. And even that was too much for most mappers.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

User avatar
Quietust
Posts: 1785
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Emulating 32 KB PRG RAM

Post by Quietust » Sun May 16, 2021 6:10 pm

For what it's worth, the Famicom Disk System puts RAM at $6000-$DFFF (and its BIOS at $E000-$FFFF), and it also provides subroutines for commonly-performed actions like disk I/O.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

User avatar
Ben Boldt
Posts: 856
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: Emulating 32 KB PRG RAM

Post by Ben Boldt » Sun May 16, 2021 6:30 pm

ZeroDivisionGuy wrote:
Sun May 16, 2021 11:26 am
Ben Boldt wrote:
Sun May 16, 2021 9:41 am
Is there any reason you want a 32 kilobyte contiguous chunk of RAM instead of doing bankswitching? That would probably open up your options.
Yes. It's for testing purposes.
It might be worth thinking about how to design your OS with bankswitching in mind. That will make it much more expandable, which usually becomes an important thing with OSs. The OS or the resident program could be in charge of bankswitching; that's a design choice. If you use the MMC5, a scheme like this might be reasonable:
  • $0000-0800 (2k NES internal RAM) - dedicated to the OS.
  • $6000-7FFF (8k RAM) - dedicated for resident program's read/write RAM.
  • $8000-BFFF (16k RAM) - dedicated for resident program's program data.
  • $C000-FFFF (16k ROM) - dedicated to OS program code.
Each of these regions being bankswitchable with MMC5. Also the MMC5 provides graphics and audio upgrades and a hardware 8x8->16 bit multiplier to the NES. It would be a great choice for an OS meant to run in an emulator.

How do you plan to load software? Would you be thinking about the Family Basic tape drive? I don't think FDS can work with your application because that occupies the cartridge slot and already has its own OS like Quietust pointed out. Famicom network system has some potential if you were to create a special card and load your programs over a network connection. But we don't know enough about Famicom network system to be able to do something like that yet. (Hopefully we do someday though.)

User avatar
Jarhmander
Formerly ~J-@D!~
Posts: 522
Joined: Sun Mar 12, 2006 12:36 am
Location: Rive nord de Montréal

Re: Emulating 32 KB PRG RAM

Post by Jarhmander » Tue May 18, 2021 5:19 am

Ben Boldt wrote:
Sun May 16, 2021 6:30 pm
If you use the MMC5, a scheme like this might be reasonable:
  • $0000-0800 (2k NES internal RAM) - dedicated to the OS.
    ...
Well, you can't make such "clean" memory segmentation, because both the OS and the programs needs to access zero page (indirection!) and the stack.
((λ (x) (x x)) (λ (x) (x x)))

User avatar
Ben Boldt
Posts: 856
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: Emulating 32 KB PRG RAM

Post by Ben Boldt » Tue May 18, 2021 6:48 am

Good point.

Post Reply