View Single Post
Old August 10th, 2008 (2:53 PM). Edited July 5th, 2009 by IIMarckus.
IIMarckus's Avatar
IIMarckus IIMarckus is offline
    Join Date: Oct 2007
    Posts: 402
    Originally Posted by FHJoker View Post
    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.

    Explanation of mapheaders
    __________________ /

    If you want me, please contact me by email. [email protected]

    If you want to hack Pokémon RBY or GSC, read, read, and read some more. This has tons of valuable information.

    Pokémon Red disassembly project

    Rules that should be rethought: 25charlimit, bumping.
    Bad posts are bad posts, regardless of how many words are in them or how old the thread is.
    Good posts are good posts, regardless of how old the thread is—and brevity is underrated.