Thread: [Discussion] ROM Hacking Discussions
View Single Post
Old September 5th, 2011 (10:00 AM).
IIMarckus's Avatar
IIMarckus IIMarckus is offline
    Join Date: Oct 2007
    Posts: 402
    Originally Posted by Sawakita View Post
    These are some enlightening advices, thank you. I'll try to follow them when I'll get around starting that project.
    I'm not sure I understood right the thing about putting [address x 2], though. Could you clarify it a bit?
    It is just there for sorting purposes.

    Say you have a line of code like this:
    ld a,1
    ld hl,$1234
    jr z,−5
    If you’re partially or fully emulating the processor, you probably won’t be diassembling from beginning to end, but rather following jumps, so you need some way to sort the text file later. One way is to prefix each instruction with its address, then sort the file after you’re done disassembling (e.g., by running it through the Unix program “sort -u”).
    10000 ld a,1
    10001 nop
    10002 ld hl,$1234
    10003 jr z,−5
    But if you do that, you won’t see that the load to hl needs a label beforehand. So you could double the number you prefix with, and subtract 1 to force labels to appear in the right location.
    20000 ld a,1
    20002 nop
    20004 ld hl,$1234
    20006 jr z,addr00_2712
    20003 addr00_2712:
    Now this can be sorted and things will appear in the right places.
    __________________ /

    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.