+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  Help me figure out the whole pointer thing.
Pages: [1] 2 3 4
Author Topic: Help me figure out the whole pointer thing.  (Read 2 times)
Rai
Guest
« on: March 23, 2008, 05:24:05 pm »

I don't know what it is lol but no matter how many docs I read I never quite understood pointers. What are they for how will they help? I don't know. Would pointers even help me with what I need help with?

See basically I'm trying to figure out how to space into the game. An example is how in Fire Emblem NES, a project I'm interested in, there's only four spaces for Marth's name, therefore I can't insert "Marth". Would points help me add an extra space in the game, so I could put "Marth"?
KaioShin
Guest
« Reply #1 on: March 23, 2008, 05:40:17 pm »

You asked this 4 times already, again and again. You'll still get the same answers. Before people start to flame or anything I'm going to answer your question, if no one else has anything productive to add, don't post.

Think of addresses, like house numbers. Every house contains one letter of our text.

House 1: T
House 2: E
House 3: S
House 4: T
House 5: X

X is a special code that tells us the word is complete. You see that the information in those houses forms the word TEST this way.
The pointer points to one of those house numbers. It shows where the our text starts.
So the original pointer will point to House 1.
You can now change it to House 2 and the text displayed in the game will be 'EST'.

So, you have text that is longer than the original Japanese one. All you have to do is change the pointer to words after the one that you change to point to an address later in memory.
Neil
Guest
« Reply #2 on: March 23, 2008, 05:51:11 pm »

The short answer is: It depends on what type of "space" you're short on.

There's screen real estate and there's text storage space. If you don't have space on the screen for another letter, you'll need to bark up another tree.

Pointers tell the game where text is located. The idea behind the pointer table is this: Text is never the same length. The sentences "The king's throne room is just through these doors." and "Mind your manners in front of the King." are two different lengths. They might be spoken by two different guards watching the left and right side of the door to the kings throne room, but that doesn't necessarily mean the lines of text are stored next to each other in the ROM. Pointer tables act like a table of contents that allows the game to know where the text is, and more importantly for you, to be able to increase the length of the original text. With pointers you can move text around to different locations in the ROM (how far depends on the console's hardware and how the game is programmed).
Rai
Guest
« Reply #3 on: March 23, 2008, 05:58:54 pm »

Quote from: Neil on March 23, 2008, 05:51:11 pm
The short answer is: It depends on what type of "space" you're short on.

There's screen real estate and there's text storage space. If you don't have space on the screen for another letter, you'll need to bark up another tree.

Pointers tell the game where text is located. The idea behind the pointer table is this: Text is never the same length. The sentences "The king's throne room is just through these doors." and "Mind your manners in front of the King." are two different lengths. They might be spoken by two different guards watching the left and right side of the door to the kings throne room, but that doesn't necessarily mean the lines of text are stored next to each other in the ROM. Pointer tables act like a table of contents that allows the game to know where the text is, and more importantly for you, to be able to increase the length of the original text. With pointers you can move text around to different locations in the ROM (how far depends on the console's hardware and how the game is programmed).
Ah, I see, so I could basically move delete one byte and move it next to Marth's name to make space? Sounds kind of complicated. Is simply expanding the rom space possible?
Iriliane
Guest
« Reply #4 on: March 23, 2008, 07:00:34 pm »

I'm somewhat familiar with Fire Emblem for NES and yes pointers will help you. I'd recommend reading MadHacker's guide to pointers as it should explain how to find them and manipulate them. I'll give a brief explanation here anyways.

Pointers point to the start of a string. For example let's say you had a set of 5 animal names stored as such:

Code:
1   2         3        4       5
Bat#Crocodile#Aligator#Giraffe#Dog#
Each of the numbers represents the location a pointer points to and the # represents an end of string.

Assuming you wanted to alphabetize them (There'd be no benefit to doing so but it makes for a decent example.)
Just moving around the strings wouldn't work since the pointers still point to the same place. It would look something like this:
Code:
1   2         3        4       5
Aligator#Bat#Crocodile#Dog#Giraffe#

If we were to try to call pointer 2 (Which is supposed to call "Crocodile") we'd end up with the string "ator". If we call pointer 1 (which is supposed to call "Bat") it would now call "Aligator". So we have to move the pointers to their proper positions.

Code:
3        1   2         5   4
Aligator#Bat#Crocodile#Dog#Giraffe#
After doing this the pointers will again call the appropriate strings.


Alternatively, as a more useful example, say in your game you had two monster names "Wolf" and "Grey Wolf" and they were stored as such:

Code:
1    2
Wolf#Grey Wolf#

You could save space using pointers by repointing it as such:
Code:
2    1
Grey Wolf#
« Last Edit: March 23, 2008, 07:15:39 pm by Iriliane »
Rai
Guest
« Reply #5 on: March 23, 2008, 07:48:17 pm »

Sweet well I'll take a look at that guy and see if it helps. That post also helped me get a good understanding of pointers. Hopefully the madhacker thing will help me find them though.
weissvulf
Guest
« Reply #6 on: March 23, 2008, 08:36:45 pm »

I just started modifying the text pointers to reproportion the available text space on a CD game I'm working on.  I was able to locate the pointer tables by counting the length of text entries and then doing a relative search with the resulting values.

I'm not sure what method MadHacker's guide uses, but if it doesn't work for you, I could try to describe how I found my tables in better detail incase it helps Smiley
InVerse
Guest
« Reply #7 on: March 23, 2008, 09:10:10 pm »

You know, I was thinking the other day that it would be nice to have a more "modernized" pointer document. While the information in Mad Hacker's is still solid, to the best of my knowledge, the presentation is quite horrid by today's standards. Gil Galad wrote an appendix to Mad Hacker's guide, but I believe that simply added additional information and didn't re-present any of the original information. AnusP's 'Advanced Hacking Tutorial" is just as ancient as Mad Hacker's Guide. (They both turn 10 years old this year.) Gideon's "Using Pointers Effectively" guide is narrowly focused and short, while his Gameboy pointer doc is narrowly focused, short and assholish. (That's not a slam on Gideon, he intentionally made it that way.) XCalibur's pointer doc is decent, for what it is, but not comprehensive enough to serve as the main pointer tutorial, which leaves Duo's PSX Pointer doc, which again is narrowly focused.

A well written pointer document could serve the community well. I've contemplated writing one in the past, but always balked because I wouldn't really be adding any new information, simply presenting existing information in a more easily understood fashion. Of course, aside from my NES Title Screen Hacking doc, I can't really claim to have developed any of the techniques described in any other tutorials I've written, so I don't suppose that's a particularly valid excuse. Does anyone else think that it would be a good idea to put together a new pointer guide?
RedComet
Guest
« Reply #8 on: March 23, 2008, 09:28:30 pm »

It certainly can't hurt, especially if it's as easy to follow as your Relative Searching doc is. (Yes, I did read it. I just haven't had the time to go back over it and the other doc with a fine tooth comb. Sorry. Sad)
Jigglysaint
Guest
« Reply #9 on: March 23, 2008, 10:25:52 pm »

If a document is made, then perhaps a short section as to how pointers act the way they do.  From what I've seen on the NES, there are 2 spots in ram that are needed for a pointer to work.  You load the first byte in ram using an indexed value.  Then you save it to a spot on the ram map, usually zero page.  Then you do the same for the next value, and save it to the spot next to it in ram.  Then you do can perform and indirect opcode, which takes the values you loaded, then uses it to point to the data you wish to obtain, then it's loaded into memory in which it can be performed.  Pointers can be stored either as two byte pairs, or as seperate arrays, like in Megaman 4.  There is practically zero difference between a pointer defined as data and pointers that are used in opcodes to write to and values from the ram.

NES pointers are simple when you understand how ram works.  Depending on where in ram you wish to read or write to, the pointer will look different.  Standard pointers usually go from $0080 to $FFBF.  This is used to reference the switchable banks in ram.  $8000 to $BFFF are switchable using bankswapping routines.  From $C000 to $FFFF is the main program bank, which almost never changes.  In there, references to this section of ram go from $00C0 to $FFFF as far as pointers go.

Yeah, that's a crappy explanation but really untill you understand the function of ram, ASM and pointers will be pretty hard to figure out.  I litterally went from n00b to ASM hacking in a matter of weeks once I understood how ram on the NES was mapped out.
ded302
Guest
« Reply #10 on: March 23, 2008, 11:20:31 pm »

When I figured out how pointers worked it helped me with asm hacking a lot.  I did an experiment with a Famicom game called Shinsenden.  First I found out the text routine was in bank 15 which is loaded into memory at the C000-FFFF range and there was a few bytes of free space at the end of bank 15.  I used the free space and modified the text routine to use a custom pointer system to swap a specified bank into the 8000-BFFF range and read a text byte from that bank.
Rai
Guest
« Reply #11 on: March 24, 2008, 11:16:52 am »

Well I reread a few docs, such as the MadHacker thing and I'm still confused as hell on how to find them. I keep putting what I'd interpret to be the pointers, but then when I find and modify them, nothing happens. I've tried several calculations and interpretations, but nothing. Madhackers guide was especially confusing(What the heck was 28210? Certainly not the offset where "Nothing" or "here" was located).
« Last Edit: March 24, 2008, 11:37:18 am by Rai »
KingMike
Guest
« Reply #12 on: March 24, 2008, 11:48:10 am »

Yes, $28210 is the ROM address where that text string is located.
(28210 in hexadecimal, and FF1 uses DTE for the dialouge, so if you don't have a DTE table, look on somewhere like Zophar's Domain)
Rai
Guest
« Reply #13 on: March 24, 2008, 12:25:39 pm »

I'm thinking I should just give up though. I've tried a bunch of techniques, take the hex of the start text and decrease it to 2 hex values and flip it. Take the hex of the start text, subtract 200 THEN flip it. I just don't think this is ever going to make sense to me. FOR INSTANCE, in Fire Emblem: Monshou no Nazo 0x71A3C, is the "hex" offset of the starting text(Unless they perhaps wanted me to use "465468" the decimal value). I decreased it to 2 values, 1A and 3C, then I flipped them. But then however, I search for the pointers, modify them and nothing happens.

I'm trying to find the pointers for the text...
Quote
マルス王子
タリス城から
シーダ様がこられました

I've already expanded the rom, but that means nothing if I can't calculate the pointers.

Followed most tuts and I figured out a pointer of 3C18 and guess whaT? Didn't work and I did exactly what the tuts said.
« Last Edit: March 24, 2008, 02:01:24 pm by Rai »
RedComet
Guest
« Reply #14 on: March 24, 2008, 03:39:47 pm »

Quote from: Rai on March 24, 2008, 12:25:39 pm
I'm thinking I should just give up though. I've tried a bunch of techniques, take the hex of the start text and decrease it to 2 hex values and flip it. Take the hex of the start text, subtract 200 THEN flip it. I just don't think this is ever going to make sense to me. FOR INSTANCE, in Fire Emblem: Monshou no Nazo 0x71A3C, is the "hex" offset of the starting text(Unless they perhaps wanted me to use "465468" the decimal value). I decreased it to 2 values, 1A and 3C, then I flipped them. But then however, I search for the pointers, modify them and nothing happens.

I'm trying to find the pointers for the text...
Quote
マルス王子
タリス城から
シーダ様がこられました

I've already expanded the rom, but that means nothing if I can't calculate the pointers.

Followed most tuts and I figured out a pointer of 3C18 and guess whaT? Didn't work and I did exactly what the tuts said.

You have to take the $10 byte header that NES ROMs have into account. So, using your example, you'd take $71A3C and subtract $10 from that leaving you with $71A2C. Then you take the last byte and search the ROM for that, so you're searching for $2C. Note that you're not searching for $2C1A. That $1A most likely won't be in the pointer. Instead it'll probably be something like $2CXA where X is between 8 and F.

EDIT: Ooops. It seems this is an SNES game. I was under the impression you were working on the NES version. Anyway, it's practically the same.

Do yourself a favor when dealing with SNES ROMS. Before you begin searching for pointers, open the ROM in a hex editor and jump ahead to the end of the file. Look at the offset. Does it end in $200? If so, you've got a header, remove the first $200 bytes of the ROM, otherwise don't do anything. The header in SNES ROMs is useless and you're better off removing it.

Anyway, take the lowest byte of the string address $71A3C. In this case that would be $3C. Search the ROM for this value and test each potential pointer. By potential pointer I mean a pair of bytes that are "$3CXA", where X is any value between 0 and F. Alternatively you could find the pointers by doing a quick ASM trace, though I'm willing to bed that's out of your league at this point (no offense).
« Last Edit: March 24, 2008, 03:54:06 pm by RedComet »
Pages: [1] 2 3 4  


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