diff options
Diffstat (limited to 'include/global.h')
-rw-r--r-- | include/global.h | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/include/global.h b/include/global.h index c976abd2d..090ba7ce4 100644 --- a/include/global.h +++ b/include/global.h @@ -61,6 +61,12 @@ #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) >= (b) ? (a) : (b)) +// Extracts the upper 16 bits of a 32-bit number +#define HIHALF(n) (((n) & 0xFFFF0000) >> 16) + +// Extracts the lower 16 bits of a 32-bit number +#define LOHALF(n) ((n) & 0xFFFF) + // There are many quirks in the source code which have overarching behavioral differences from // a number of other files. For example, diploma.c seems to declare rodata before each use while // other files declare out of order and must be at the beginning. There are also a number of @@ -79,6 +85,14 @@ #define T2_READ_32(ptr) ((ptr)[0] + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24)) #define T2_READ_PTR(ptr) (void*) T2_READ_32(ptr) +#define S16TOPOSFLOAT(val) \ +({ \ + s16 v = (val); \ + float f = (float)v; \ + if(v < 0) f += 65536.0f; \ + f; \ +}) + // Invalid Versions show as "----------" in Gen 4 and Gen 5's summary screen. // In Gens 6 and 7, invalid versions instead show "a distant land" in the summary screen. // In Gen 4 only, migrated Pokemon with Diamond, Pearl, or Platinum's ID show as "----------". @@ -222,7 +236,7 @@ struct Time struct Pokedex { /*0x00*/ u8 order; - /*0x01*/ u8 unknown1; + /*0x01*/ u8 mode; /*0x02*/ u8 nationalMagic; // must equal 0xDA in order to have National mode /*0x03*/ u8 unknown2; /*0x04*/ u32 unownPersonality; // set when you first see Unown @@ -293,7 +307,7 @@ struct Apprentice u32 checksum; }; -struct UnknownPokemonStruct +struct BattleTowerPokemon { u16 species; u16 heldItem; @@ -330,7 +344,7 @@ struct EmeraldBattleTowerRecord /*0x10*/ u16 greeting[6]; /*0x1C*/ u16 speechWon[6]; /*0x28*/ u16 speechLost[6]; - /*0x34*/ struct UnknownPokemonStruct party[4]; + /*0x34*/ struct BattleTowerPokemon party[4]; /*0xE4*/ u8 language; /*0xE8*/ u32 checksum; }; @@ -345,7 +359,7 @@ struct BattleTowerEReaderTrainer /*0x10*/ u16 greeting[6]; /*0x1C*/ u16 farewellPlayerLost[6]; /*0x28*/ u16 farewellPlayerWon[6]; - /*0x34*/ struct UnknownPokemonStruct party[3]; + /*0x34*/ struct BattleTowerPokemon party[3]; /*0xB8*/ u32 checksum; }; @@ -881,7 +895,7 @@ struct SaveBlock1 /*0x24*/ struct WarpData warp4; /*0x2C*/ u16 savedMusic; /*0x2E*/ u8 weather; - /*0x2F*/ u8 filler_2F; + /*0x2F*/ u8 weatherCycleStage; /*0x30*/ u8 flashLevel; /*0x32*/ u16 mapLayoutId; /*0x34*/ u16 mapView[0x100]; |