This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Loading Code from CHR ROM

Loading Code from CHR ROM
by on (#50774)
I never thought anyone would be crazy enough to do this, but while messing around I found out that Bart Vs Space Mutants actually has code in the CHR-ROM which is copied into RAM. I noticed this when I was wanting to make a code to adjust how many hits you could take before dieing. I found out that the code is in CHR-ROM and therefore can't make a Game Genie code to do exactly what I wanted. I just wanted to share this oddity and ask if anyone else has heard of another game doing this or see some good reason why they might want to do it. I know some games do store overflowwed data in CHR-ROM like SMB1, but actual code seems funny to me. I know I've heard of self modifying code which could be useful I guess and in that case I guess it wouldn't matter if you stored it in CHR-ROM.

Incase anyone here is interested in the codes I made here they are:

Next Level on Death.

Infinite Lives
(wasn't working properly)

If you use the Next Level on Death code, if you die on the final level, you lose. No idea if you can beat the final level and win with the code on or not. Infinite Lives seems to be the most useful code which strangely I couldn't find any such code for that before so I had to make it/find it.

by on (#50776)
I do that and I don't think it's that crazy if you're short on PRG-ROM and have some free CHR space. That is a consequence to the fact you have to make both ROMs a power of two in size.

by on (#50778)
I don't think that storing code in CHR-ROM is crazy, what is crazy is that the NES has only 2KB of RAM, so there isn't a lot of space for the code.

by on (#50788)
But see that's why I think storing code in CHR-ROM is crazy, because you only have 2K of RAM to begin with and now you're going to start copying code into it? I mean I can understand I suppose in a big game you might not need alot of RAM at some parts and maybe it makes sense or something. I suppose the reason they did it had to be what you say with being short on PRG-ROM while having alot of extra CHR-ROM that they didn't want to go to waste.

by on (#50790)
In a scrolling engine, there's usually a transfer buffer containing a block of data ready to be copied to a nametable. Such a buffer might be on the order of 128 bytes in an NTSC game. This area is in use only between when the main program decides to render graphics and when the vblank routine copies it into RAM.

If a program has a time during which no VRAM updates are expected, it can copy code from CHR ROM to the transfer buffer and run it. The developers of Bart vs. the Space Mutants (1991) were likely aware of Game Genie (released in Canada in 1990).

by on (#50792)
If you're going to use self-modified code in RAM anyways, I see no reason not to store it's initial state in CHR-ROM instead of PRG-ROM. Self modified code can be much faster than if/else statement in some cases. I do that for sprite cycling, if I would be testing frame parity for each mazed sprite to know if I should move forward or backward in the buffer, I would loose a lot of CPU time each time, as opposed as just change a few instructions in RAM.

by on (#50796)
Bregalad wrote:
If you're going to use self-modified code in RAM anyways, I see no reason not to store it's initial state in CHR-ROM instead of PRG-ROM.

Just make sure to load the code with video rendering and sample playback turned off.

by on (#50797)
tepples wrote:
The developers of Bart vs. the Space Mutants (1991) were likely aware of Game Genie (released in Canada in 1990).

So you think they did it to be cruel bastards? I wouldn't put that past them. That could definitely be the case.

by on (#50800)
Well if you're trying to get infinite lives on real hardware you could always do something like this:

by on (#50810)
If I really want it I can just modify the CHR-ROM and use the PowerPAK. But the hope was to come up with a Game Genie code since it is the standard for NES cheat codes.

by on (#50815)
Have you tried GAXVKSVV + GAOTESVK ?

by on (#50822)
I have seen how you can make yourself have unlimited hits before but I wasn't interested in that other than for testing and exploring things. Being unkillable is far less interesting than just balancing the odds by giving you unlimited lives. I just don't understand how they figured you should have 3 lives and no continues for the entire game. It'd be different if the control scheme didn't suck. Atleast with unlimited lives you would be able to try again where you failed until you succeed.

by on (#50823)
What problem did you have with your infinite lives code?

by on (#50824)
I got the effect of infinite lives but because I didn't pay attention the code actually had two effects atleast which gave you infinite lives but also made the "goal" count never go down.

by on (#50825)
This is the best I could do:


It will make you lose a life in 4 hits instead of 2 hits.
Leaving out ALAVVI will make you die in 5 hits, but it may have side effects, I couldn't follow all the game's insane code very well.

This code group breaks the Bart-head hit counter. I've not tested it thoroughly, either.