Using Pointers Effectively
Using Pointers Effectively
An Appendix to the MadHacker's Guide to NES Pointers
By Gideon Zhi
OK people, this is the first time I've ever written any kind of FAQ, so bear with me. This guide assumes you've read the MadHacker's Guide to NES Pointers. I will be using the terminology used in above stated Guide. Note that this is NOT a guide to using pointers! I feel that the MadHacker has done an excellentjob on his guide and that I do not need to rewrite it. It shall therefore be assumed that you know HOW to use pointers. All this document contains are strategies for using them efficiently in order to conserve that much needed space in your NES game.
Pointers in Lists
The easiest way to describe how to use pointers in lists is to use an example. So, I'll be using the Chaos World (Japanese) ROM that I am currently hacking English text into.
Like many Role-Playing Games, Chaos World has numerous monsters, spells, and items. This is where efficient use of pointers can really shine. Say, for instance, you have two spells: Volt and L-Volt. The spell names, plus the message end characters, take up a total of 12 characters in your ROM. That's a lot of space! What if you could reduce that to... say, 6 characters? And what if you could do that with many of your spells and monsters? You can, using pointers! Here's the example. We've got the same two spells: Volt and L-Volt. We also have two pointers pointing at the first character in each.
Pointer1 --> Volt
Pointer2 --> L-Volt
Everything clear so far? Now, as the MadHacker says, "More than 1 pointer can point to the same place in the ROM." Now, from here on, I'm going to be using * as my break character/Empty Space character. So whenever you see * immediately after a string, it's a break character. Any other place and it's empty space. Anyway, our ROM probably looks like this:
Volt*L-Volt*
Now what we do is we totally omit Volt, replacing it with L-Volt. It'll now look like this:
L-Volt******
Now we point Pointer1 (originally for Volt) at the V, like so:
L-Volt******
...and we point Pointer2 (originally for L-Volt) at the L, like so:
L-Volt******
They both share the same text and message end characters, but the pointer that goes to Volt points to a part later in the string. We therefore have two spells in one! This works great for monsters, too! Example: Spider and P-Spider:
Pointer1, for Spider
Pointer2, for P-Spider
P - S pider (Empty space omitted)
Note that this can be used in a multitude of situations, including dialogue. But with dialogue, you can get into some messy stuff like control codes that can screw everything up... so if it were me, I'd just limit it to lists. All that space saved... and with no ASM modifications!
That about wraps it up! Hope this was informative.
Thanks go out to the MadHacker for the ultimate document in NES pointers!