Using unused nametable RAM as a general RAM deposit?

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Using unused nametable RAM as a general RAM deposit?

Post by FrankenGraphics »

As the title says, and generally speaking - is this viable, or a no-go?
I know it'd be slow and squeezed as you'd need to go through the PPU to get it, but anyway.
The automatic PPUADDR increase is at least something, and the PPUDATA register is read/write.
Are there any precedents to study?
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Using unused nametable RAM as a general RAM deposit?

Post by dougeff »

As usual, I feel this is a "asking about A, but I should be asking about B" question.

How much RAM do you need?

Why not use $6000-7fff? WRAM.

What is the actual issue you are facing?
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Using unused nametable RAM as a general RAM deposit?

Post by FrankenGraphics »

There's not really an "issue"- I'm trying to get a fuller understanding in order to map what i can actually do, if needed, and to be able to accurately choose a suitable mapper in regards to features and pricing.
Some sort of games, like previously discussed, may require relatively massive amounts of volatile data: Generated+persistent worlds, fully alterable/destructible worlds, and simulations (with generated, persistent objects), or a combination of said types.

The reason these types of games don't come aplenty on the NES is because developers stayed within conventions.
Last edited by FrankenGraphics on Sat Feb 03, 2018 8:31 am, edited 1 time in total.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Using unused nametable RAM as a general RAM deposit?

Post by tepples »

Two precedents:
  • Games like Super Mario Bros., Vs. Super Mario Bros., and Milon's Secret Castle store some data in CHR ROM that wouldn't fit in PRG ROM.
  • RacerMate Challenge II board has a lot of CHR RAM, 32K of it battery-backed.
dougeff wrote:As usual, I feel this is a "asking about A, but I should be asking about B" question.
AKA the XY problem of people forgetting to describe the goal that a step is intended to achieve. Sometimes one has to be vague about the goal out of confidentiality or humility, but a useful "vaguebook" or "subtweet" post at least includes a suggestion of a goal.
dougeff wrote:Why not use $6000-7fff? WRAM.
Extra component to buy ($), footprint on the PCB ($), and assemble (time, which is $).
dougeff wrote:What is the actual issue you are facing?
It probably involves a board with a bunch of otherwise unused extra CHR RAM, such as UNROM 512 or GTROM. This appears to have become more common with self-flashability, as it's cheaper than adding a WRAM and a battery to the board.
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Using unused nametable RAM as a general RAM deposit?

Post by FrankenGraphics »

It probably involves a board with a bunch of otherwise unused extra CHR RAM, such as UNROM 512 or GTROM.
Yes, these are the two candidates i'm looking at more closely currently.

”Inherent Smile” from this years’ compo stores quite a bit of data in chr-rom. That’s sort of the origin why i started looking into unused nt-ram when i realized this resource is there anyway with certain mappers. And for games not needing 4-screen mode as much as it may need ram for variables, that’s interesting considering the price of manufacture compared to wram additions, plus if fROM, a saving alternative to battery backing.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Using unused nametable RAM as a general RAM deposit?

Post by dougeff »

The problem with using VRAM as RAM is...

1. it's slow. You have to wait till v-blank or turn rendering off to access it.

2. It might cripple your ability to scroll, if you are using nametable VRAM.

3. It's non-standard to the official NES games. If you are doing something beyond what actual games did, why not just make a modern game?
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Using unused nametable RAM as a general RAM deposit?

Post by tokumaru »

I don't see any problems in using VRAM as general RAM, if the limited access is not a problem.
dougeff wrote:3. It's non-standard to the official NES games.
This is bullshit. If there was no innovation, every NES game ever would look like Balloon Fight, and there'd be no mappers using the cartridge port's signals in creative ways.

Also, there have been cases of NES games from back in the day using video memory for other purposes, such as SMB and some CNROM games storing miscellaneous data in CHR-ROM or battery-backed CHR-RAM being used to save games.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Using unused nametable RAM as a general RAM deposit?

Post by lidnariq »

The only major problem with using PPU RAM for a generic store is that DPCM collides even worse with reads from the PPU than with the controllers.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Using unused nametable RAM as a general RAM deposit?

Post by dougeff »

If there was no innovation, every NES game ever would look like Balloon Fight
I just mean...
If 10k of RAM isn't enough, then maybe NES isn't the best platform. SNES has standard 128k RAM, and you can still use mode zero if you REALLY want it to look like an NES game.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
MottZilla
Posts: 2837
Joined: Wed Dec 06, 2006 8:18 pm

Re: Using unused nametable RAM as a general RAM deposit?

Post by MottZilla »

Some games read the Nametables contents for collision/game logic, so you could certainly use it for whatever you want. Is it really a good idea? That will depend on your specific situation. In general it's hard to see a reason to store random information in NameTables. If you had a non-scrolling game then that might work but in that case are you really going to be that short on RAM that an extra 1KB is going to help? Again maybe in your specific situation the answer is yes.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Using unused nametable RAM as a general RAM deposit?

Post by lidnariq »

dougeff wrote:If 10k of RAM isn't enough, then maybe NES isn't the best platform.
But that's literally not the starting position here.

The starting position is "So, we're using GTROM or UNROM512 or maybe even just a single-screen game without scrolling and there's extra RAM that we have no use for stored behind the PPU. Is there a reason we shouldn't make use of it?"
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Using unused nametable RAM as a general RAM deposit?

Post by tokumaru »

dougeff wrote:If 10k of RAM isn't enough
Maybe 10k is more than enough, but 2k isn't, and a little bit (maybe not so little in the case of GTROM) of limited access RAM that is already available is a better option than adding a whole new chip.
SNES has standard 128k RAM, and you can still use mode zero if you REALLY want it to look like an NES game.
That's no fun. When you stumble on a system's limitations you don't immediately deem it unusable and move on to more powerful hardware, you first think of clever ways to make things work under the current setup. That's one of the most interesting aspects of retro programming, IMO.

Also, retro programmers often pick specific consoles for a reason (nostalgia, popularity, availability, cost, challenge, etc.), so it makes little sense to say "just pick another console" as soon as something appears slightly harder or unusual to code.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Using unused nametable RAM as a general RAM deposit?

Post by tepples »

dougeff wrote:then maybe NES isn't the best platform. SNES has standard 128k RAM, and you can still use mode zero if you REALLY want it to look like an NES game.
As you and I both wrote elsewhere, people who spend money on a Super NES Game Pak expect the graphics to look no less detailed than those of launch title Super Mario World. I doubt there is much interest in Super NES games that use only the increased RAM, not the increased graphical capability.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Using unused nametable RAM as a general RAM deposit?

Post by rainwarrior »

I would say, though it's not great for random access, or continual access, it's actually a very practical place for a battery backed save or perhaps data for a larger dynamic world that you can swap out during screen transitions.

If you're going to use CHR-RAM, the price difference between 8k and 32k SRAM is basically nothing, so at that point you have free 4-screen if you want it, and up to 20k of "inconvenient" storage, depending on how much mapper you want to dedicate to accessing it. Even without any CHR mapping there's still nearly 4k of extended nametable memory. Probably much better to battery back that than add a separate PRG-RAM chip.

(Sorry that this is a bit redundant, just it didn't seem like anyone had explicitly spelled this out in the thread yet.)
FrankenGraphics wrote:The reason these types of games don't come aplenty on the NES is because developers stayed within conventions.
I disagree with this. It's not "conventions" its real economic problems, many of which don't apply to us now (like the price of 32k SRAM). Even if the hardware prices were comparable to now, there's still all the constraints that come with commercial development that make this entirely an unfair comparison.

If anything, I think many developers were chomping at the bit to do this kind of thing. It's what drove the development of things like the FDS or 64DD, which were repeatedly market failures. Even SimCity was developed and cancelled. They wanted to make these games, but really couldn't. This thing you are calling avoidance by "convention" was actually a problem many tried to solve and failed in that commercial environment.
Rahsennor
Posts: 479
Joined: Thu Aug 20, 2015 3:09 am

Re: Using unused nametable RAM as a general RAM deposit?

Post by Rahsennor »

Wrecking Balls was going to (and if I ever get out of this hole I've fallen into, eventually will) use battery-backed CHR-RAM to store custom board layouts. It already uses CHR-RAM anyway, the graphics are so simple the second nametable is unused, the board layouts are tiny and they only need to be accessed at the start of a round, when rendering is off to fill the nametable anyway.
Post Reply