View Single Post

August 10th, 2008 (2:53 PM). Edited July 5th, 2009 by IIMarckus.
 IIMarckus [email protected] Join Date: Oct 2007 Gender: Posts: 402

Quote originally posted by FHJoker:
I am a little confused by definition what is a mapheader and a pointer.
A pointer is a numerical reference to data or a piece of code. The game uses pointers to know where data is located.

If the offset ≥ 4000, then we can get its pointer by ((offset % 0x4000) + 0x4000). Say our offset is 0x034BB1:

0x034BB1 % 0x4000 = 0x0BB1
0x0BB1 + 0x4000 = 0x4BB1

In the game it’s generally little‐endian: 0xB14B, but in documentation and the like I would recommend using normal big‐endian numbers.

Three‐byte pointers use the bank number as well. You get the byte number by rounding down to the nearest 0x4000 and dividing by 0x4000.

0x034BB1 → 0x034000
0x034000 ÷ 0x4000 = 0x0D

To calculate a pointer to a given offset, take the offset (say, 0x135276), modulus divide by 4000 (modulus division gives the remainder instead of the quotient, and is usually the “MOD” or “%” key on a calculator), add 0x4000, and switch bytes to get the two‐byte pointer. Then take the original offset and divide by 0x4000 to get your bank number, if needed.