Switching CHR-ROM to CHR-RAM

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
Zoldark
Posts: 72
Joined: Sat Oct 28, 2017 10:18 am
Contact:

Switching CHR-ROM to CHR-RAM

Post by Zoldark »

This is probably a stupid question but I can't figure it out. How do you switch CHR-ROM to use it as CHR-RAM inside of a NES ROM?

Especially If you don't have it's source all you have is the compiled ROM is it even possible?
Don't buy FamicomNes games WillyNilly Check the Mapper first
https://www.nesdev.org/wiki/Mapper
https://nescartdb.com/
I feel like I said something wrong even if I didn't I don't know for sure and I always feel bad about it.
gzip
Posts: 23
Joined: Sat Mar 13, 2021 2:29 pm
Contact:

Re: Switching CHR-ROM to CHR-RAM

Post by gzip »

You have to move the tile data from CHR-ROM to PRG-ROM (which means you need to have enough free space, or expand the rom to add space), and then copy it into CHR-RAM on init. See:
https://www.nesdev.org/wiki/CHR_ROM_vs. ... to_CHR_RAM
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Switching CHR-ROM to CHR-RAM

Post by tokumaru »

This will not work for all games, since some of them rely on the instantaneousness of CHR-ROM bank switching. Unlike CHR-ROM bank switching, which is practically instantaneous, CHR-RAM updates take time, because the CPU has to actively transfer each byte of CHR data from PRG-ROM (or from RAM) to CHR-RAM, and this can only be done when the PPU is not rendering (i.e. during vblank or forced blanking).

Some games will use multiple tilesets on the same frame, maybe to draw a status bar or some other effect. Others will switch CHR banks frequently in order to animate the player character or the background. These absolutely cannot be hacked to work with 8KB of CHR-RAM. If you can use more than 8KB (say, 32KB) and keep the mapper, (or use a similar one) you can copy all CHR banks that the game will use during specific periods in advance and keep the CHR switching just as it was with CHR-ROM.
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Switching CHR-ROM to CHR-RAM

Post by Dwedit »

What game are you trying to do this for?
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Zoldark
Posts: 72
Joined: Sat Oct 28, 2017 10:18 am
Contact:

Re: Switching CHR-ROM to CHR-RAM

Post by Zoldark »

gzip wrote: Sun Apr 30, 2023 7:21 am You have to move the tile data from CHR-ROM to PRG-ROM (which means you need to have enough free space, or expand the rom to add space), and then copy it into CHR-RAM on init. See:
https://www.nesdev.org/wiki/CHR_ROM_vs. ... to_CHR_RAM
tokumaru wrote: Sun Apr 30, 2023 7:46 am This will not work for all games, since some of them rely on the instantaneousness of CHR-ROM bank switching. Unlike CHR-ROM bank switching, which is practically instantaneous, CHR-RAM updates take time, because the CPU has to actively transfer each byte of CHR data from PRG-ROM (or from RAM) to CHR-RAM, and this can only be done when the PPU is not rendering (i.e. during vblank or forced blanking).

Some games will use multiple tilesets on the same frame, maybe to draw a status bar or some other effect. Others will switch CHR banks frequently in order to animate the player character or the background. These absolutely cannot be hacked to work with 8KB of CHR-RAM. If you can use more than 8KB (say, 32KB) and keep the mapper, (or use a similar one) you can copy all CHR banks that the game will use during specific periods in advance and keep the CHR switching just as it was with CHR-ROM.
Okay, I guess I'll have to use a Disassembler to change the games code.

I am just trying to change the game from NROM-128 to an expanded 256kb MMC1 with CHR-RAM. When I change the Header to iNES 2.0 the game functions the same as it does on NROM except that the background and Character Sprites display as some Grabbed Graphic's instead what they should be. I guess cause there is no actual CHR-RAM or PRG-ROM I read somewhere long ago that CHR-ROM is actually PRG-ROM or something like that IDK for sure.

I hadn't actually expanded the Rom yet, I was going wait til I figured out how to fix it to use CHR-RAM but maybe I should do that first.

Anyway, Thanks for the info every bit helps. :beer:
Dwedit wrote: Sun Apr 30, 2023 9:43 am What game are you trying to do this for?
It's a Demo called Hell.nes by Gimmick it's the Second version of the two NES Hellraiser Demo's the other being a 256kb MMC1 Intro called HellRaiser311.nes

http://nesworld.com/homebrew/hell.nes
http://nesworld.com/homebrew/hellraiser311.nes
Don't buy FamicomNes games WillyNilly Check the Mapper first
https://www.nesdev.org/wiki/Mapper
https://nescartdb.com/
I feel like I said something wrong even if I didn't I don't know for sure and I always feel bad about it.
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Switching CHR-ROM to CHR-RAM

Post by Dwedit »

hellraiser311 is already using CHR-RAM.

"Hell.nes" is a trivial Mapper 0 NES example program where a sprite moves around when you press directions. Do you really need to hack this one for CHR-RAM support? If you wanted to, you'd highjack the boot coode, expand the PRG 32K by mirroring the existing 16K of PRG, output the 8K of CHR data into CHR-RAM, then proceed with the program. But why would you bother with an example program like that...
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Zoldark
Posts: 72
Joined: Sat Oct 28, 2017 10:18 am
Contact:

Re: Switching CHR-ROM to CHR-RAM

Post by Zoldark »

Dwedit wrote: Sun Apr 30, 2023 10:36 am hellraiser311 is already using CHR-RAM.

"Hell.nes" is a trivial Mapper 0 NES example program where a sprite moves around when you press directions. Do you really need to hack this one for CHR-RAM support? If you wanted to, you'd highjack the boot coode, expand the PRG 32K by mirroring the existing 16K of PRG, output the 8K of CHR data into CHR-RAM, then proceed with the program. But why would you bother with an example program like that...
I believe you are correct, so I changed it back to NROM and just Expanded it to 32kb of PRG with the 8kb of CHR and that works fine for my NROM PCB, but I was hoping to be able to fit both Demo's on a 512kb MMC1 PCB that AFAIK is with out CHR-ROM but is supposedly made for holding two MMC1 games at the same time. I haven't even gotten it yet.

Maybe I just need to find a 512kb MMC1 PCB that has CHR-ROM as my old MMC1 PCB has 256kb PRG plus 128kb of CHR, Or just modify it myself.

I guess I'll just have to have them on two Separate carts until I get my Everdrive, it should be arriving soon.

Edit: I was just looking at images of the Board I ordered and it say's it's SGROM and SXROM so they both could have 8kb of either CHR-RAM or CHR-ROM. https://www.nesdev.org/wiki/SxROM I hope that it has CHR-ROM. I just want to test the limits of the PCB, I Probably won't be getting anymore of them though and there is only like 8 of them left. https://www.aliexpress.us/item/3256804354939967.html
Don't buy FamicomNes games WillyNilly Check the Mapper first
https://www.nesdev.org/wiki/Mapper
https://nescartdb.com/
I feel like I said something wrong even if I didn't I don't know for sure and I always feel bad about it.
Zoldark
Posts: 72
Joined: Sat Oct 28, 2017 10:18 am
Contact:

Re: Switching CHR-ROM to CHR-RAM

Post by Zoldark »

I actually got refunded on that PCB I order, decided I didn't want or need it.

However I also found out that the HellRaiser311.nes Intro doesn't work on real Hardware at least it didn't work when I flashed it on my 256kb MMC1 SKROM PCB.

This is off topic but I have been wondering. Is there anyway to tell what hardware a Rom is Using? Besides from the fact of it being just on MMC1? Like if it is using SKROM, SGROM, or what?
Don't buy FamicomNes games WillyNilly Check the Mapper first
https://www.nesdev.org/wiki/Mapper
https://nescartdb.com/
I feel like I said something wrong even if I didn't I don't know for sure and I always feel bad about it.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Switching CHR-ROM to CHR-RAM

Post by calima »

No, because there are multiple options that can work. Enough PRG, enough CHR (-RAM if needed), enough RAM.
gzip
Posts: 23
Joined: Sat Mar 13, 2021 2:29 pm
Contact:

Re: Switching CHR-ROM to CHR-RAM

Post by gzip »

256k PRG-ROM + CHR-RAM + PRG-RAM + Battery = SNROM
SKROM uses CHR-ROM so that wouldn't work. SOROM, SUROM, and SXROM are all 512k PRG.
gzip
Posts: 23
Joined: Sat Mar 13, 2021 2:29 pm
Contact:

Re: Switching CHR-ROM to CHR-RAM

Post by gzip »

I wrote your intro rom to an SNROM board and it works on real hardware.
Zoldark
Posts: 72
Joined: Sat Oct 28, 2017 10:18 am
Contact:

Re: Switching CHR-ROM to CHR-RAM

Post by Zoldark »

gzip wrote: Fri May 19, 2023 12:01 am 256k PRG-ROM + CHR-RAM + PRG-RAM + Battery = SNROM
SKROM uses CHR-ROM so that wouldn't work. SOROM, SUROM, and SXROM are all 512k PRG.
gzip wrote: Fri May 19, 2023 12:31 pm I wrote your intro rom to an SNROM board and it works on real hardware.
That is awesome, Thank you.. Now I just have to find me a SNROM Board.
Don't buy FamicomNes games WillyNilly Check the Mapper first
https://www.nesdev.org/wiki/Mapper
https://nescartdb.com/
I feel like I said something wrong even if I didn't I don't know for sure and I always feel bad about it.
Post Reply