NES RAM upgrade

Discuss hardware-related topics, such as development cartridges, CopyNES, PowerPak, EPROMs, or whatever.

Moderator: Moderators

VGdevOnSNES
Posts: 13
Joined: Fri Apr 02, 2021 11:15 pm

NES RAM upgrade

Post by VGdevOnSNES »

I've thought we could upgrade the RAM of the NES.

There's 2KB of SRAM (labeled as WRAM) on the NES PCB.
A lot of people created custom PCBs to upgrade their NES.
I thought we could use 8KB, but we actually can use 16KB, which is EIGHT times more than 2KB.

Here's how we can map the RAM in the CPU BUS:

Addresses $0000-$1FFF will be used for first half the the 16KB RAM.
Addresses $3000-$3FFF will be used for the third quarter the the RAM.
Addresses $5000-$5FFF will be used for the last quarter of the RAM... But there's a problem. Games like Castlevania 3 will map RAM there. But i had an idea which is mapping that RAM on the 16 previous pages on the bus, that are in the range of addresses $4020-$4FFF, which are avaible for the program.
The cartridge's RAM will be mapped 16 pages before, and it will still be able to use the already provided WRAM.
Addresses $6000-$7FFF will still be used by the cartridge's WRAM, why would you map RAM to somewhere that is used by most of the games that provide RAM?

Oh, and if you want a name suggestion for the custom NES, we can call it NES-201.
Last edited by VGdevOnSNES on Thu Apr 22, 2021 5:54 pm, edited 1 time in total.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: NES RAM upgrade

Post by lidnariq »

Indeed, you could do this, and a few things actually did - the VRTech upgraded famiclones have 8KB of RAM instead of 2, and the NES Test Station has 4KB.

Arguably the CopyNES does this too - it replaces the RAM mirror in addresses $1xxx and PPU mirrors in $3xxx with its own BIOS (in ROM).

One problem is that you never could buy 16KByte SRAMs. RAMs practically always came as some power of 4 bits - e.g. 2KB RAM = 4⁷ bits. Another problem is that there's plenty of other things, not just MMC5, that put things in the $5xxx region. https://wiki.nesdev.com/w/index.php/Cat ... 4020-$5FFF

But the problem is that now this thing isn't a NES. Games can't use the extra capabilities without making two versions - one for a "real" NES, and one for this upgrade.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: NES RAM upgrade

Post by tokumaru »

While this is a moderately simple upgrade, the vast majority of NES consoles in existence will continue to have only 2KB of RAM, as only a handful of enthusiasts would actually mod their console this way. As a result, there would be very little incentive for game publishers and programmers to support this expansion in any meaningful way.

From a business standpoint, it makes much more sense to include any extra RAM needed by an unconventional game in the cartridge itself, since that's supported by 100% of the consoles still in use.

As for the name, I don't think this upgrade is significant enough to deserve something as big as "Mega"... Most casual players wouldn't even notice any difference between a game using 2KB of RAM and one using 18KB, and would be confused by the lack of any noticeable upgrades in this so called "Mega" version of the system.
VGdevOnSNES
Posts: 13
Joined: Fri Apr 02, 2021 11:15 pm

Re: NES RAM upgrade

Post by VGdevOnSNES »

lidnariq wrote: Wed Apr 21, 2021 4:53 pm One problem is that you never could buy 16KByte SRAMs. RAMs practically always came as some power of 4 bits - e.g. 2KB RAM = 4⁷ bits. Another problem is that there's plenty of other things, not just MMC5, that put things in the $5xxx region.
Actually, i can just buy 1 8KB SRAM, and 2 4KB SRAMs. OR 4 4KB SRAMs.
The 8KB SRAM can just get mapped from address $0000 to $1FFF, if i can't get a 8KB SRAM, then i use 2 4KB SRAMs instead. Map the first one to addresses $0000-$0FFF, and the second one to $1000-$1FFF.
The other two 4KB SRAMs can just be mapped, one to $3000-$3FFF, and the other to $5000-$5FFF, that simplifies the mapping, better than mapping a whole "16KB RAM" to different regions.
Also, the problem with the $5xxx region is not a problem for me, i just thought that NOW, they map THEIR content to the actual addresses in pages $50-$5F, and the SRAM replaced by that will just be moved from the $5xxx region to the $4xxx region.
That's surely the best way to make a 16KB NES console. Maybe we will be able to port games from C64 machines, etc, to that new NES!
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: NES RAM upgrade

Post by lidnariq »

VGdevOnSNES wrote: Wed Apr 21, 2021 6:54 pm
lidnariq wrote: Wed Apr 21, 2021 4:53 pm RAMs practically always came as some power of 4 bits - e.g. 2KB RAM = 4⁷ bits.
Actually, i can just buy 1 8KB SRAM, and 2 4KB SRAMs. OR 4 4KB SRAMs.
4KB SRAMs are extremely rare for the same reason. 2KByte = 16kbit = 4⁷ bits. 8KByte = 64kbit = 4⁸ bits.
Also, the problem with the $5xxx region is not a problem for me, i just thought that NOW, they map THEIR content to the actual addresses in pages $50-$5F, and the SRAM replaced by that will just be moved from the $5xxx region to the $4xxx region.
And how do you know when to do this?
That's surely the best way to make a 16KB NES console. Maybe we will be able to port games from C64 machines, etc, to that new NES!
No. The C64 makes it practical to address all the video memory at any time; the NES doesn't. Basically nothing beyond game logic can be shared.

Furthermore, as Tokumaru says, we already have a standard way for the game to get extra RAM, and that's to put it on the cartridge.
Fiskbit
Posts: 891
Joined: Sat Nov 18, 2017 9:15 pm

Re: NES RAM upgrade

Post by Fiskbit »

While I encourage you to do this kind of thing for fun, I don't think this adds all that much value. Cartridges that need more RAM can simply include RAM themselves, and bankswapping to get to more RAM is not a significant enough restriction to sacrifice compatibility. How is this a better solution than the existing one? Any place where you map RAM above $4020 is also going to cause incompatibility with some mappers, and RAM at other locations will likely break some badly-behaved games.

Are you planning to make anything that uses this RAM? I'm a bit skeptical people would be interested in developing for this specific console variant, since outside of whatever emulator support you might be able to provide, no one's going to be able to play it.

(There is an official console, the FamicomBox, that does have additional RAM at $0800-1FFF, but AFAIK, none of the games released for it use that RAM.)
User avatar
Gilbert
Posts: 564
Joined: Sun Dec 12, 2010 10:27 pm
Location: Hong Kong
Contact:

Re: NES RAM upgrade

Post by Gilbert »

As everyone already mentioned it would be better if the RAM is contained in the cartridge whenever needed anyway.
Also, as the usual practice of cartridge games is to run code from ROM, extra RAM is rarely necessary, besides uses such as (destructible) game maps (Sim City, etc., but in these cases you need the RAM to be on the cartridge if you need to save anyway), decompression buffers (may not even be necessary considering we can have VERY large ROM size for cheap now), etc.

It would be more reasonable if we add more (bank-switchable) RAM to the FDS (well, that's technically done in game copiers already), so that supported games could use the extra RAM if detected (It would be even better if they make the CHR-RAM bank-switchable so that tile animations are more doable). We cannot add RAM to a floppy disk disk card, and a number of FDS games suffer from frequent disk access, so this is a welcome change, provided there are STILL people caring to develop new games (or hack/update old games) for it.

This is similar to how the CD-ROM2 system of the PC-Engine evolved. Nearly nothing else has changed except the amount of RAM available. There are three generations:
  1. Ordinary CD-ROM2: Only 64 kb (0.5 Mbit) of work RAM available.
  2. Super CD-ROM2: 256 kb (2 Mbit) of work RAM available.
  3. Arcade Card CD-ROM2: MASSIVE 2304 kb (18 Mbit!) of RAM* available.
There are ordinary CD-ROM2 games that can utilise the extra RAM when a Super system is detected, and Super CD-ROM2 that also provide enhancements when a Arcade Card system is detected.

*Unfortunately, RAM bank-switchable to the main memory map is still 256 kb. The extra 2048 kb were DRAM which had to be copied to other RAM banks (or transferred to VRAM) to work, most possibly because of cost.
VGdevOnSNES
Posts: 13
Joined: Fri Apr 02, 2021 11:15 pm

Re: NES RAM upgrade

Post by VGdevOnSNES »

You don't seem to talk about it, but have you ever seen a game map RAM to $0800-$1FFF region or to $3000-$3FFF region? That actually is the context of that project.
Fiskbit
Posts: 891
Joined: Sat Nov 18, 2017 9:15 pm

Re: NES RAM upgrade

Post by Fiskbit »

A game can only map itself to portions of the address space that are open bus (ie where nothing else responds). $0800-1FFF and $3000-3FFF are not open bus; the former mirrors $0000-07FF and the latter mirrors $2000-2007. If the cartridge were to try to respond there, it would have a bus conflict with the RAM or PPU, which can be bad for the hardware and will result in the value being corrupted. On a stock console, only $4018-FFFF are available for cartridge use.
User avatar
krzysiobal
Posts: 1037
Joined: Sun Jun 12, 2011 12:06 pm
Location: Poland
Contact:

Re: NES RAM upgrade

Post by krzysiobal »

The only "SAFE" region is $0000-$1fff. You can do it by just replacing the 2kB RAM wih 8kB and connecting its upper adress lines to to the bus (A11, A12).
All other regions need some kind of modification of the PCB and 74139' decodeer and stilll, you can't add anything above $4017 because you don't know if game reuses that for its purpose. If you *really* need 16kB you can add it at $0000-$3fff (minus the aight bytes at $2000-$2007) but that requires taking all address lines for decoding and changing the PPU decoder as well.

Other idea might be to make RAM banking at $000-$7ff. For example $000-$3ff always sticked to the first page and $400-$7ff bankable. This way you can have even 512 kB of RAM
VGdevOnSNES
Posts: 13
Joined: Fri Apr 02, 2021 11:15 pm

Re: NES RAM upgrade

Post by VGdevOnSNES »

Fiskbit wrote: Wed Apr 21, 2021 10:37 pm A game can only map itself to portions of the address space that are open bus (ie where nothing else responds). $0800-1FFF and $3000-3FFF are not open bus; the former mirrors $0000-07FF and the latter mirrors $2000-2007. If the cartridge were to try to respond there, it would have a bus conflict with the RAM or PPU, which can be bad for the hardware and will result in the value being corrupted. On a stock console, only $4018-FFFF are available for cartridge use.
So, the only way to map real RAM to $0800-$1FFF is actually by adding it to the board.
Maybe we also can map onboard RAM to $3000-$3FFF since they are not open bus, i don't map anything to $2008-$2FFF since there can be conflict with the 8 PPU registers.
The actual problem that we can face to, is the forced mirroring. I don't know if that is used in SNES for addresses $0000-$1FFF in banks $00-$3F & $80-$BF, but that would make this project impossible.
The NES doesn't seem to do that. I'm sure we can map at least 12KB of onboard RAM to addresses $0000-$1FFF & $3000-$3FFF, because it would really be bizarre if we can't.
Also, you CAN'T map anything to $4018-$401F, that is reserved for the unfinished fonctionnalities of the 2A0(3/7) chip.
krzysiobal wrote: Thu Apr 22, 2021 1:15 am The only "SAFE" region is $0000-$1fff. You can do it by just replacing the 2kB RAM wih 8kB and connecting its upper adress lines to to the bus (A11, A12).
All other regions need some kind of modification of the PCB and 74139' decodeer and stilll, you can't add anything above $4017 because you don't know if game reuses that for its purpose. If you *really* need 16kB you can add it at $0000-$3fff (minus the aight bytes at $2000-$2007) but that requires taking all address lines for decoding and changing the PPU decoder as well.

Other idea might be to make RAM banking at $000-$7ff. For example $000-$3ff always sticked to the first page and $400-$7ff bankable. This way you can have even 512 kB of RAM
$0800-$1FFF is surely safe to map onboard RAM to. Addresses $3000-$3FFF could also be used by onboard RAM, because it would be really bizarre if we can't map anything there. Also, you HAVE TO create a custom PCB for a custom NES. Why would you modify the original one, anyway? Also, i decided to take out the 4KB RAM in pages $50-$5F. But instead, i will take your idea of RAM banking. Well, doing that to just 4 pages of the BUS is not very elegant. We can even take 8 pages of the BUS, and that could be the remaining place of not open-bus addresses, that is, addresses $2800-$2FFF. But there's a problem. We would actually need a register to change the RAM bank, but i have an idea: use page $21 of the BUS for registers that can control the banking of that special RAM. Using that will let us use up to 512KB RAM!!! That's literally half a Megabyte! 512KB is literally 8 times bigger than the whole BUS...

Here's now my guess about the mapping of the RAM:

$0000-$1FFF is truly and surely usable for 8KB RAM.
$3000-$3FFF is maybe, but not quite sure usable for 4KB RAM.
and for $2100-$21xx & $2800-$2FFF, i'm not sure at all.

The conclusion if this works:

12 KB of RAM will be directly accessible
512 KB of RAM will be accessible using banking.
VGdevOnSNES
Posts: 13
Joined: Fri Apr 02, 2021 11:15 pm

Re: NES RAM upgrade

Post by VGdevOnSNES »

I made this so you can see visually how it would be, you acn see every signe byte, every byte takes 3²px.
User avatar
krzysiobal
Posts: 1037
Joined: Sun Jun 12, 2011 12:06 pm
Location: Poland
Contact:

Re: NES RAM upgrade

Post by krzysiobal »

VGdevOnSNES wrote: Thu Apr 22, 2021 3:03 am Also, you HAVE TO create a custom PCB for a custom NES. Why would you modify the original one, anyway?
No you don't. Reprojecting whole PCB, ordering it in factory, desoldering chips and soldering them to new one is waste of money and time just for a such minor change.

If you agree to have banked RAM only at $0000-$7ff, you can just desolder the old RAM, project a small add-on board with bigger ram (512 kB) and small controller (CPLD or 74xx logic) and put it in in place of the old RAM.
All signals coming to the RAM slot (A0..A10, R/W, /CS) are enough for making it. You can also add "enable" registers to have backward compatiblity. For example:

Code: Select all

---------------+-------------+------------+
($3fc == $AA)  |             |            |
     &&        | $000..$3ff  | $400-$7ff  |
($3fd == $55)  |             |            |
---------------+-------------+------------+
     false     |non switchable 2kB of RAM |
---------------+-------------+------------+
     true      | fixed to    | switchable |
               | first bank  |            |
---------------+-------------+------------+

$3fc: [AAAA AAAA] backward compatibility register 1 (cleared on powerup)
$3fd: [BBBB BBBB] backward compatibility register 2 (cleared on powerup)
$3fe: [RRRR RRRR] select 1kb RAM bank at $400-$7ff (lowest 8 bits)
$3ff: [.... ...R] select 1kb RAM bank at $400-$7ff (9th bit))
EPM3064 is perfect choice, it has EXACTLY as many free pins as you would need. If for some reason you would need more, there is a trick that allows you even to reuse the JTAG pins as I/Os. Probably you won't even need reset pin as this CPLD's registers are initialized to 00 on power up but in case you would need, you can detect the toggling of A0 as RESET.

Using this approach you can add even more:
* other banking modes (likes whole 2kB banking) or some kind of auto switch to allow more thank 256bytes of zeropage
* hardware multipler
* battery backup the RAM
* RTC clock
* floppy controler
* fill mode or something like that used for OAM
* ....
Attachments
adapt.jpg
pcb.png
sch.png
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: NES RAM upgrade

Post by lidnariq »

VGdevOnSNES wrote: Thu Apr 22, 2021 3:03 am Maybe we also can map onboard RAM to $3000-$3FFF since they are not open bus, i don't map anything to $2008-$2FFF since there can be conflict with the 8 PPU registers.
$2008-$2FFF and $3000-$3FFF are the exact same.
Also, you CAN'T map anything to $4018-$401F, that is reserved for the unfinished fonctionnalities of the 2A0(3/7) chip.
.... where did you get that idea? $4018-$401F doesn't have anything unless someone's physically changed the state of pin 30.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: NES RAM upgrade

Post by tepples »

lidnariq wrote: Wed Apr 21, 2021 4:53 pm But the problem is that now this thing isn't a NES. Games can't use the extra capabilities without making two versions - one for a "real" NES, and one for this upgrade.
Some Game Boy games have an adaptive engine that enables some software features when the game is run on Game Boy Color. These features rely on hardware present only in the GBC, such as a faster CPU, bankswitched work RAM, bankswitched VRAM, and DMA to VRAM. A routine in the boot ROM sets a register that disables these features if the game's header doesn't have the GBC awareness bit set.

Please leave the "Mega" for Sega Genesis.
Post Reply