using CHRAM to save games?

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

Moderator: Moderators

User avatar
olddb
Posts: 188
Joined: Thu Oct 26, 2017 12:29 pm
Contact:

using CHRAM to save games?

Post by olddb »

Any examples of games using CHRAM to save games?
Any emulator supports this?
Is the diode NPN decoding logic needed in this setup?
-Thank you
...
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: using CHRAM to save games?

Post by tepples »

RacerMate Challenge 2 does this, and this game inspired the addition of battery-backed CHR RAM to the definition of the NES 2.0 header. As kevtris wrote:
As for battery backed CHR RAM, the Racermate cartridge has 64K of CHR RAM total: 32K is battery backed, and 32K of it is not. They store all the stats and such in it. Why you would do such a thing, I do not have a clue... but they did! I traced out the circuit myself and couldn't believe it.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: using CHRAM to save games?

Post by lidnariq »

olddb wrote: Sat Oct 17, 2020 5:20 pm Is the diode NPN decoding logic needed in this setup?
You always need something to guarantee that the RAM is firmly disabled when the console is off or the cartridge is removed from the console. This can be the same NPN pass transistor that's been used elsewhere, but it might also be some very low power logic (RacerMate Challenge uses a 74HCT32) or an extra chip enable on the RAM.
User avatar
krzysiobal
Posts: 1037
Joined: Sun Jun 12, 2011 12:06 pm
Location: Poland
Contact:

Re: using CHRAM to save games?

Post by krzysiobal »

olddb wrote: Sat Oct 17, 2020 5:20 pm Any examples of games using CHRAM to save games?
Princess Maker
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: using CHRAM to save games?

Post by rainwarrior »

Upsides:

1. Cheaper to manufacture than a PRG-RAM save.

Downsides:

1. Only a few actively maintained emulators support it, though at least there's some popular ones in that set.

2. Access to it is very slow, so either your working set of game state that you wanna save has to fit in the < 2k main RAM, or you have to fetch only what you need from it during blanking periods. Inconvenient, but at least it's not as bad as using flash ROM saves, where you can't use it as a working set at all and main RAM is your only source of data to save.

3. DPCM conflicts with reads, so you shouldn't play samples while accessing it. (Minor issue?)
User avatar
Ben Boldt
Posts: 1149
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: using CHRAM to save games?

Post by Ben Boldt »

Would battery-backed CHR-RAM like this be any less susceptible to corruption when turning off the power without holding reset?
User avatar
krzysiobal
Posts: 1037
Joined: Sun Jun 12, 2011 12:06 pm
Location: Poland
Contact:

Re: using CHRAM to save games?

Post by krzysiobal »

Ben Boldt wrote: Sun Oct 18, 2020 1:18 pm Would battery-backed CHR-RAM like this be any less susceptible to corruption when turning off the power without holding reset?
Yea, I started thinking about this aswell. Corruption woud occur when PPU/WE goes down. It happens only when CPU does write to $2007.
So theoretically, when voltage goes down and CPU starts executing garbage opcodes and unfortunately reaches write opcode,
in whole range of $0000-$ffff there are 1024 addresses that would trigger that ($2007, $200F, 2017, ... , $3fff). Chance is 1,56%
But PPU address pointer must also points to $0000-$1fff, which has chance of 50%.
So theoretically 0,78%

Considering corruption of WRAM at $6000-$7fff, it would happen witch chance of 8192/65536 = 12,5%.
User avatar
olddb
Posts: 188
Joined: Thu Oct 26, 2017 12:29 pm
Contact:

Re: using CHRAM to save games?

Post by olddb »

krzysiobal wrote: Sun Oct 18, 2020 1:52 pm But PPU address pointer must also points to $0000-$1fff, which has chance of 50%.
So theoretically 0,78%
You wouldn't use the whole $2000 area as save space though, right?
So chances are even lower?
...
User avatar
Ben Boldt
Posts: 1149
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: using CHRAM to save games?

Post by Ben Boldt »

olddb wrote: Sun Oct 18, 2020 5:00 pm
krzysiobal wrote: Sun Oct 18, 2020 1:52 pm But PPU address pointer must also points to $0000-$1fff, which has chance of 50%.
So theoretically 0,78%
You wouldn't use the whole $2000 area as save space though, right?
So chances are even lower?
As I understand, it is only possible to write to VRAM when sprites are not fetching, for example during V-Blank or if sprites are disabled. (I base this on what I read about how Indiana Jones does mid-frame pallette writes on the title screen.) That might further reduce possibility of random writes. Please correct me if I am wrong on this: I understand writing to the pallettes is a different thing than writing to VRAM.

Also, I think that the save data would probably be on its own VRAM bank, so it may need to have that bank selected when powering off in order to corrupt it. I am not familiar with the game but it might not select that bank to update the save data very frequently, and it seems pretty difficult to accidentally select the correct VRAM bank and also write to the VRAM.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: using CHRAM to save games?

Post by rainwarrior »

Ben Boldt wrote: Sun Oct 18, 2020 6:55 pmAlso, I think that the save data would probably be on its own VRAM bank, so it may need to have that bank selected when powering off in order to corrupt it. I am not familiar with the game but it might not select that bank to update the save data very frequently, and it seems pretty difficult to accidentally select the correct VRAM bank and also write to the VRAM.
Wouldn't the latch selecting the bank would have to be guaranteed stable during power off to make this assumption?

Though various mappers had "write protect" modes for their save RAM, so it's probably at least somewhat helpful.
User avatar
Ben Boldt
Posts: 1149
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: using CHRAM to save games?

Post by Ben Boldt »

rainwarrior wrote: Sun Oct 18, 2020 7:50 pm Wouldn't the latch selecting the bank would have to be guaranteed stable during power off to make this assumption?
Yes and your suggestion is correct that I don't know that. It would need to at least be guaranteed to degrade into a bank not used for saving. If it does something random, it still helps the odds of not being on the right bank though.

I am not sure the sequencing of the PPU when losing bias; maybe it stops allowing writes earlier than the CPU loses its mind. Would be interesting to find out.
User avatar
aquasnake
Posts: 515
Joined: Fri Sep 13, 2019 11:22 pm

Re: using CHRAM to save games?

Post by aquasnake »

In some early NES systems, this mapped address space (VRAM / ciram and chr-ram) can only be written indirectly by CPU and cannot be read out.

In the later stage, famiclone CPU can read cram.

In order to be strict with the programming habit, it is not recommended to use CPU to read out cram.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: using CHRAM to save games?

Post by rainwarrior »

aquasnake wrote: Sun Oct 18, 2020 11:45 pmIn some early NES systems, this mapped address space (VRAM / ciram and chr-ram) can only be written indirectly by CPU and cannot be read out.
This is not true. I think you're thinking of OAM, not CHR? $2004 reads don't work on some PPU revisions. $2007 reads work on all. Even Super Mario Bros. relies on this.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: using CHRAM to save games?

Post by lidnariq »

Or maybe you're thinking of palette readback? That's the other thing that was added at the same time that OAM readback was.
User avatar
krzysiobal
Posts: 1037
Joined: Sun Jun 12, 2011 12:06 pm
Location: Poland
Contact:

Re: using CHRAM to save games?

Post by krzysiobal »

aquasnake wrote: Sun Oct 18, 2020 11:45 pm In some early NES systems, this mapped address space (VRAM / ciram and chr-ram) can only be written indirectly by CPU and cannot be read out.
If this was true then many games wouldnt work. For example Flipull - it stores levels in CHR-ROM.
Post Reply