• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Basic Hexadecimal/ASM Knowledge/Concepts for Beginning ROM Hackers

Did this help you?

  • No

    Votes: 0 0.0%
  • I don't know

    Votes: 0 0.0%

  • Total voters
    2

PoK3Matr1x

A ROM Hackerino ( ͡° ͜ʖ ͡°)
30
Posts
9
Years
  • So, you want to make a ROM hack. I will assume that you are a beginner and may need some help with one of the most crucial things for hacking.
    It is what we call Hexadecimal (Other Names: hex, base 16), It is used by programmers because it is one form on how a computer reads data.
    So without futher ado, here is some knowledge on Hexadecimal.

    POINTERS

    Pointers are used by all computers, and is simply a variable that holds a hexadecimal address in the memory. Basically meaning it holds the location of a specific memory location, So if you wanted to call data from a specific location in memory you would need a pointer.
    Well, how do you calculate pointers?
    So say for example, you put an ASM routine at 0x845840. What you do is put a space in between every 2 numbers, so you would get 84 58 40.
    Then simply swap the first and last numbers, giving you 40 58 84, then add an 08 at the end. Giving you 40 58 84 08!
    And simply put the pointer where you need it! (I have heard for making pointers, the location has to end with 0, 4, 8 or C, I am not exactly sure, but i have heard this is the case for certain things at least, e.g. 800000 = 00 00 80 08, 800004 = 04 00 80 08, 800008 = 80 00 08 08, 80000C = 0C 00 80 08 so i just like to play it safe and place things at a location that ends with 0.) For

    FREE SPACE BYTES

    This is a simpler one. Free Space starts at 0x800000. It should be full of FF bytes until the end of the ROM (although starting at D00000 there is alot of hex code that i would strongly recommend you leave alone) But, the FF bytes after 0x800000 can be overwritten with your own data, allowing you to add new features without overwriting existing data, which would be BAD. Keep in mind, do a paste insert, not a paste write as that changes the filesize, therefore screwing up the rom.

    DATA TO NOT CHANGE

    Do NOT change any of the ROM's used (not free space) hex data unless required.
    This can result in errors. But under all circumstances, you should not have to change any of the occupied hex (because you have free space)
    And if you do have to for some reason, DO NOT change ANY of the data at the beginning of the ROM! This can result in the following
    - game won't load
    - bad checksum (still playable by emulators, but on a real GBA would not play)
    - severe corruption
    - general havoc on your ROM.

    ASSEMBLY LANGUAGE

    Yes, ASM and Hex both go very well together in ROM hacking, and you can pull off almost anything as long as it is in the limitations of the GBA and the game
    itself. So, without too much rambling on, Pokemon FR/LG and R/S/E were programmed in C. we know this because of a build path hidden in FR/LG 1.0, containing a part saying malloc.c, Yet we still tend to use ASM over C, C is used in Pokemon ROM Hacking quite rarely, only for really advanced stuff like making an entirely new intro sequence! On the other hand, We have a more versatile, yet primitive Programming Language that all computers, new and old use, called Assembly,
    It is a low-level programming language, which is known to be more difficult than modern languages due to numerous factors, but you can do certain things easier with ASM than other languages. You can access the memory of the hardware using ASM easier, which may be one reason why it is so popular amongst hackers, because writing code that accesses memory easier and more efficently, is a HUGE advantage considering a hardware's memory is crucial to a surprisingly wide array of things, Now, I am not EXACTLY sure on the relative easiness to access memory using ASM compared to other languages, I just heard that from one of my family members who works in IT, But it does make sense, considering the fact that ASM is code that DIRECTLY uses the functions of the processor itself, But other languages dont do that, What the other languages do is that they have their own formatting and functions, (one example compare C++ or C# to ASM), Which are formatting and functions unique to that language, that are compiled into readable data, but ASM uses the formatting and functions of the computer itself, Meaning that adding new features and even hijacking existing routines in the ROM itself, are done using ASM due to its general advantages, such as directly accessing the memory and processor with ease, and it can access MORE, rather than being harder and more limited. Infact, many viruses are written in ASM, due to it directly accessing the processors features and memory. Also, for making a pointer to an ASM Routine, remember to add +1 to the pointer (Which is called a thumb entrypoint) So if you placed a routine at 842800, you would get 842801, giving you 01 28 84 08. Remember, It may look like it is very primitive and useless, But ASM can do some great things other wise even more difficult!
    So to compile ASM, simply use HackMews thumb.bat, put the asm file over it, open it with a hex editor, copy everything and put it in free space and change pointers and bytes as needed.



    RESOURCES

    I recommend HxD for hex editing.
    If you need to convert hex to decimal or decimal to hex, simply google hex to decimal converter, or decimal to hex converter.
    If you want to learn more, look at Hexadecimal on Wikipedia and look at the many sites that have tutorials for understanding hex.

    I may update this every now and then with new parts, and more detail.
     
    Last edited:
    3,044
    Posts
    9
    Years
  • And, if you want to convert your decimal to hexadecimal, and vice-versa. Use the Windows Calculator. Click on View and change it to 'programmers'
    And, click on Hex and Dec if you want to change your decimal to hex/hex to decimal. (its on the left side)

    Ex. Click on Dec. I'll type 200. Click the Hex button on the left side, and it will become C8. There.

    I hope you understood all that.
     

    PokéMew1

    Pokémon Fuchsia
    484
    Posts
    10
    Years
  • And, if you want to convert your decimal to hexadecimal, and vice-versa. Use the Windows Calculator. Click on View and change it to 'programmers'
    And, click on Hex and Dec if you want to change your decimal to hex/hex to decimal. (its on the left side)

    Ex. Click on Dec. I'll type 200. Click the Hex button on the left side, and it will become C8. There.

    I hope you understood all that.

    Heh, I was wondering how to convert hex to dec in the windows calc, thanks :3

    But about the tutorial, as you call it. I like the idea of a thread like this, but so far you've only covered the extremely basic stuff :/
    I look forward to seeing updates in the future with further hex knowledge :)
     
    Back
    Top