Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2012-09-09 22:56:38

theoblivinator
Member
From: Iowa
Registered: 2012-08-20
Post 21/98

Pointer to Offset Calculator?

This is probably a very stupid question.

So pointers aren't my strongest point in hacking right now. I kinda understand how to take an offset and calculate a pointer for that offset. But I can not go the other way, at all.

Is there a tutorial or formula that can be used to take a two byte pointer and calculate the offset it is pointing too?

For instance the pointer for Bulbasaurs's Evolution and moveset is B3 69. How do I convert that to an offset? I know the offset is 0x429B3 because someone stated that, but I want to know how to calculate it.

Any help?

Offline

#2 2012-09-09 23:06:15

515/700

Re: Pointer to Offset Calculator?

16‐bit values are stored little‐endian in the ROM. So the bytes $B3 $69 represent the 16‐bit pointer $69B3.

Given a bank and 16‐bit pointer, you calculate the offset like so:
offset = bank × $4000 + pointer − $4000

Given an offset, you can calculate the pointer like so:
bank = offset ÷ $4000
pointer = offset % $4000 + $4000

#3 2012-09-09 23:12:56

theoblivinator
Member
From: Iowa
Registered: 2012-08-20
Post 22/98

Re: Pointer to Offset Calculator?

Thank you very much for a quick response. That formula was exactly what I was looking for.

Offline

Board footer

Powered by FluxBB