News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Confused about GB pointers  (Read 335 times)


  • Jr. Member
  • **
  • Posts: 1
    • View Profile
Confused about GB pointers
« on: July 08, 2021, 07:15:40 am »

I'm working a text-editing a gameboy game, and I'm stuck with a pointer... I've read some RHDN documents about it, but I still don't get it: specifically, I know where the pointer points, where the text right before the pointer is, but I can't seem to locate the pointer itself.

In other words: I understand how to create a pointer, but not how to locate an existing pointer.

Any idea?

Thanks for reading!


  • Hero Member
  • *****
  • Posts: 4885
  • The cat screams with the voice of a man.
    • View Profile
Re: Confused about GB pointers
« Reply #1 on: July 08, 2021, 08:10:30 pm »
Why not name the game you're working on?
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!


  • Hero Member
  • *****
  • Posts: 3179
    • View Profile
Re: Confused about GB pointers
« Reply #2 on: July 09, 2021, 08:12:46 am »
Yeah game name helps just in case someone did want to go see what they can find themselves.

Pointers can come in a variety of flavours.
On the GB/GBC you are likely dealing with things as seen in memory, but there are probably a few mathematical ones in there. Later systems/systems with file systems might use file level pointers.

GB/GBC memory

Note that this can change depending upon the ROM -- the memory bank controllers that make it so GB/GBC games don't have to be tiny ( ) variously appear and get changed in memory. To that end other approaches that might look at file level or at stricter ROM layouts might focus on those. Here bank level is what you probably want to play with.

Many can find pointers just by looking -- they might be an obvious number (if you know the start location, which might not be the start of the text/line and instead have some formatting associated with it, and the thing in memory then you can find things more easily by calculating what it should be), they are often just before or just after the thing they are dealing with, corruption might be used, inference with relative numbers (if you have a list of say section lengths then a list of numbers with relative jumps by those amounts is probably worth investigating*, for stuff like the GBA then pointers generally start with 08 and be of the form 08XXXXXX so a field of things with 08 generally 4 bytes apart tends to be pointers (though could be graphics, music, levels and more, though values of the pointers also tends to give the game away -- text tending to be rather random in its lengths compared to simple tiled graphics and more of it needing pointers).

*this is backwards to how I normally do it where I have what it is obviously a pointer section but need to work out the mathematical relationship, however relative search in this manner could yield something. Will be troubled if there are unexpected gaps in the pointers (seen some things that align to odd locations, though not expecting that for the GB/GBC), the pointers include formatting (high bits signifying something but wiped out by a boolean operation maybe, or simply 2 bytes pointer, 1 byte formatting, 2 bytes pointer for the next bit...) or are one of the things I normally use maths in these scenarios (relative pointers are a combination of the location of the pointer and the value the pointer has, think move 5 paces north where someone 5 paces south of you will have to move 10 to land at the same point, will not be revealed by this as the differences in the differences to expected if normal pointers is what I am looking at for that).

You can also go for tracing. If you know where the text is in the ROM then your debugger will hopefully have a nice ROM level break on read (if not find where it appears in the system memory, if it is on screen it is probably still visible in memory). Go to before it appears on screen and set the break to that location, it will be read as part of things and part of that will be the console being told to read this location, find what influenced that location read (likely only a few instructions before) and that is most likely your pointer or a direct descendant of it. Compression can mean you have a step or two more.


  • Jr. Member
  • **
  • Posts: 91
  • Gameboy Color Rules!
    • View Profile
Re: Confused about GB pointers
« Reply #3 on: July 11, 2021, 04:56:04 pm »
Gb pointers are usually located at the same bank where the text is.

once you know your text offset and calculate your pointer.
then you move at the bank Start offset and do a hex search for the pointer.

I'll write you an example.
Imagine your text is at $106091

so your text is at bank 26

the bank 26 start at the offset $104000

0x106091-0x104000+0x4000=0x6091 > 9160 pointer

You move to 104000 and search the hex string 9160.

it should be between 104000 and 107FFF