+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  Pointer Tables for the NES
Pages: [1]
Author Topic: Pointer Tables for the NES  (Read 2 times)
Kagemusha
Guest
« on: April 29, 2008, 05:28:42 pm »

I'm looking to relocate some text in a ROM bank that's already swapped in and I can do that by changing the pointers to the new location, right? I guess what I'm looking for is the game's pointer table, but I've never messed (as in never hacked them) with pointers before and there's a gap or two in my knowledge. I've calculated pointers before by subtracting a bank address from the text offset and then I would find the pointer in RAM etc. Can anyone guide me to locate the pointer table (I think that's what I'm looking for)? Although I've heard that some games might not store their tables conventially, but I'm sure the games I'm working on are standard fare.
Karatorian
Guest
« Reply #1 on: April 29, 2008, 06:25:14 pm »

Usually a pointer table is simply a series of pointers stored one after another. While they can sometimes point to arbitrary locations, they usually point to areas nearby each other. This results in something that looks like this:

Code:
00028010  00 82 09 82  5C 82 BD 82   D9 82 30 83  53 83 D1 83   ....\\.....0.S...
00028020  FF 83 5E 84  78 84 94 84   CF 84 08 85  27 85 80 85   ..^.x.......'...
00028030  95 85 9C 85  EF 85 4C 86   7B 86 D9 86  2A 87 73 87   ......L.{...*.s.
00028040  AD 87 CE 87  18 88 33 88   60 88 A4 88  D9 88 24 89   ......3.`.....$.

Notice how the even bytes are all over the place, but the odd bytes are in a fairly restricted range? That's because they all point to to data that's within a fairly small range.

Also, pointer tables are usually stored near the data they point at. So, check before and after the data you're looking at and see if there's a table there. However, this isn't always the case, so the tables could be anywhere.

As you apparently know where the data you're looking for is located, you can find the pointer table by calculating the address of the start of one or several peices of the text and do a hex search for that value. If the pointers are stored in a straight forward manner, you should be able to find the table. You're likely to get several false positives though, so keep searching until you've located what looks like a pointer table.

Once you think you've found the table, edit it and see what happens. Best of luck.
Kagemusha
Guest
« Reply #2 on: April 29, 2008, 07:05:48 pm »

Thanks, I've found the game's main table, but I can't find what I'm looking for.

There's this one string that's just floating around in the ROM all on its own. I can't find the pointer in the ROM although I've found it in RAM. I don't know what's going on with this string, but I believe it is used multiple times in the game as it is asking for a confirmation of purchase which all shops use. It also uses the $66 to hold its position and the rest of the text uses $68.

What to do when a pointer isn't stored in a straight-forward manner?
« Last Edit: April 29, 2008, 10:10:44 pm by Pennywise »
Karatorian
Guest
« Reply #3 on: April 29, 2008, 10:14:21 pm »

Hmm, it sounds like it's address might be somehow hardcoded into the shop routine. In which case, the code proably sets up the pointer you're finding in RAM with a sequence something like this:
Code:
    lda #pointer_low_byte
    sta $ram_location
    lda #pointer_high_byte
    sta $ram_location+1
Of course, it could also store the high byte and then the low byte. Plus, it might be more complex than that.

What exactly do you mean by "hold it's position"? Do you mean that that's the address in RAM where the pointer is loaded to so that the text engine can find the string?

If that's the case, something really odd seems to be going on. It's almost sounds as if that particular string has it's own special routine. Is there anything unusual about the string that'd require special treatment that the standard text rendering routine couldn't handle?
Kagemusha
Guest
« Reply #4 on: April 29, 2008, 10:42:40 pm »

Quote from: Karatorian on April 29, 2008, 10:14:21 pm
What exactly do you mean by "hold it's position"? Do you mean that that's the address in RAM where the pointer is loaded to so that the text engine can find the string?

Yeah, that's it. From what I've seen most of the text is loaded in RAM at $68, but this particular string is loaded at $66 in RAM.

Quote from: Karatorian on April 29, 2008, 10:14:21 pm
If that's the case, something really odd seems to be going on. It's almost sounds as if that particular string has it's own special routine. Is there anything unusual about the string that'd require special treatment that the standard text rendering routine couldn't handle?

Yeah, it seems that way to me and the DTE routine doesn't work with this one. I really don't understand why the programmers would put a single string in the middle of the ROM with it's own routine. Unless it was some last minute thing where someone forgot to put that part of the game in or something. The only thing different about the string is that it's used throughout the game. Actually, now that I think about it, two strings are being loaded at the same time. It goes something like this:

Item bought (Not part of the string)
Is this okay?
Yes
No

Edit: You're right. It's hardcoded.
« Last Edit: April 30, 2008, 08:33:07 am by Pennywise »
Karatorian
Guest
« Reply #5 on: April 30, 2008, 07:28:32 pm »

Chances are the special routine is used so that the item bought display can use the RAM, etc. dedicated to the standard text engine.
Kagemusha
Guest
« Reply #6 on: April 30, 2008, 07:33:25 pm »

Yeah, that occured to me last night and that's probably what's going on.
Kagemusha
Guest
« Reply #7 on: May 07, 2008, 07:29:40 pm »

I'd like to mess around with another game while I'm at it, but I can't find the pointers for it. The game itself only has text in an intro and if it has an ending, there should be a few more strings floating around. I think the intro only has five or six strings. I thought that the game might not have pointers and the text is like fixed-length, but I tried changing the start and end of some strings, but that didn't work. So I guess the game has some sort of pointer system. The game's Final Mission, BTW.
KingMike
Guest
« Reply #8 on: May 07, 2008, 09:47:26 pm »

Ah yes, it's SCAT/Action in New York with a different intro.
Kagemusha
Guest
« Reply #9 on: May 07, 2008, 09:57:13 pm »

That be the one. Besides the intro bring different (and possibly the ending if there is one), the difficulty of the japanese version is much harder.

I did a little tracing and I think I found the ASM that tells the game where to load the pointer in RAM. It's

Code:
LDA ($20),Y @ $9FEB = #$00

That offset is where the first string starts, but nothing that's loaded at $20 in RAM resembles what I think I'm looking for.
« Last Edit: May 08, 2008, 08:27:17 pm by Pennywise »
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC