Hex and Binary

From Final Fantasy Hacktics Wiki
Revision as of 22:48, 2 December 2014 by Xifanie (talk | contribs) (Created page with " =Binary= Binary has two possible values: *TRUE (1) *FALSE (0) 0x Represents an hexadecimal value Bytes, Half-Words, Words are composed of so many flags (a flag is a boole...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Binary

Binary has two possible values:

  • TRUE (1)
  • FALSE (0)
0x Represents an hexadecimal value

Bytes, Half-Words, Words are composed of so many flags (a flag is a boolean value, TRUE or FALSE):

  • Boolean: 0 or 1 (1 bit)
  • Nibble: 0x0 to 0xF (4 bits)
    unsigned: 0 to +15
    signed: -8 to +7
  • Byte: 0x00 to 0xFF (8 bits)
    unsigned: 0 to +255
    signed: -128 to +127
  • Half-Word: 0x0000 to 0xFFFF (16 bits)
    unsigned: 0 to +65535
    signed: -32768 to +65535
  • Word: 0x00000000 to 0xFFFFFFFF (32 bits)
    unsigned: 0 to +4294967295
    signed: -2147483648 to +2147483647

Byte Order

Now you have to understand that MIPS r3000 will swap the bytes when handling Half-Words and Words.

What does this mean?

If the game wants to fetch a Half-Word, in the game's memory that value might be written as:

78 5A

But because the game is trying to read a Half-Word through opcode instructions (see ASM Hacking), it will be stored in the registers as 0x00005A78. Registers are 32bit and are used to hold values that will be computed by the game. They are loaded, altered, compared, and saved back as necessary.

Similarly, if the game wanted to load a Word:

9C B5 06 80

The value loaded would be 0x8006B59C.

Now if you see these values in the game's memory through a Hex Editor or an emulator's Memory Viewer:

59 00 C8 00 74 01 66 01 12 00 B7 01 32 00

You can simply guess the format and say those all look like Half-Words, you'd likely be right. But be careful, it depends on the way the game loads and saves values that determines if they are Bytes/Half-Words/Words, and not what you, yourself see in just Hex.

Unsigned VS signed