From f8266d257ec1bd02449cfe9ae01aefa018098835 Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Wed, 8 Jan 2025 17:33:16 +0100 Subject: [PATCH] rom_header sync --- src/rom_header.s | 14 ++++------ src/rom_header_gf.c | 62 +++++++++++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/src/rom_header.s b/src/rom_header.s index 9d063c7d5..18979415c 100644 --- a/src/rom_header.s +++ b/src/rom_header.s @@ -1,19 +1,16 @@ @ Note: ROM header data is empty space here. -@ It's populated by gbafix using data provided in the Makefile. +@ It's populated by gbafix using data provided in the Makefile. - .global Start -Start: +Start:: b Init - .global RomHeaderNintendoLogo -RomHeaderNintendoLogo: +RomHeaderNintendoLogo:: .space 156 RomHeaderGameTitle: .space 12 - .global RomHeaderGameCode -RomHeaderGameCode: +RomHeaderGameCode:: .space 4 RomHeaderMakerCode: @@ -31,8 +28,7 @@ RomHeaderDeviceType: RomHeaderReserved1: .space 7 - .global RomHeaderSoftwareVersion -RomHeaderSoftwareVersion: +RomHeaderSoftwareVersion:: .byte 0 RomHeaderChecksum: diff --git a/src/rom_header_gf.c b/src/rom_header_gf.c index b57f7c476..535a1e128 100644 --- a/src/rom_header_gf.c +++ b/src/rom_header_gf.c @@ -1,13 +1,21 @@ #include "global.h" -#include "data.h" -#include "pokemon_icon.h" -#include "decoration.h" #include "battle_main.h" +#include "data.h" +#include "decoration.h" #include "item.h" #include "move.h" #include "pokeball.h" -#include "pokedex.h" +#include "pokemon_icon.h" +// The purpose of this struct is for outside applications to be +// able to access parts of the ROM or its save file, like a public API. +// In vanilla, it was used by Colosseum and XD to access Pokémon graphics. +// +// If this struct is rearranged in any way, it defeats the purpose of +// having it at all. Applications like PKHex or streaming HUDs may find +// these values useful, so there's some potential benefit to keeping it. +// If there's a compilation problem below, just comment out the assignment +// instead of changing this struct. struct GFRomHeader { u32 version; @@ -18,7 +26,7 @@ struct GFRomHeader const struct CompressedSpritePalette * monNormalPalettes; const struct CompressedSpritePalette * monShinyPalettes; const u8 *const * monIcons; - const u8 * monIconPaletteIds; + const u8 *monIconPaletteIds; const struct SpritePalette * monIconPalettes; const u8 (* monSpeciesNames)[]; const u8 (* moveNames)[]; @@ -30,10 +38,10 @@ struct GFRomHeader u32 seen2Offset; u32 pokedexVar; u32 pokedexFlag; - u32 mysteryGiftFlag; + u32 mysteryEventFlag; u32 pokedexCount; u8 playerNameLength; - u8 unk2; + u8 trainerNameLength; u8 pokemonNameLength1; u8 pokemonNameLength2; u8 unk5; @@ -57,8 +65,8 @@ struct GFRomHeader u32 trainerIdOffset; u32 playerNameOffset; u32 playerGenderOffset; - u32 unkFlagOffset; - u32 unkFlagOffset2; + u32 frontierStatusOffset; + u32 frontierStatusOffset2; u32 externalEventFlagsOffset; u32 externalEventDataOffset; u32 unk18; @@ -80,9 +88,11 @@ struct GFRomHeader u8 pcItemsCount; u32 pcItemsOffset; u32 giftRibbonsOffset; +#if FREE_ENIGMA_BERRY == FALSE u32 enigmaBerryOffset; u32 enigmaBerrySize; - const u8 * moveDescriptions; +#endif //FREE_ENIGMA_BERRY + const u8 *moveDescriptions; u32 unk20; }; @@ -97,27 +107,27 @@ static const struct GFRomHeader sGFRomHeader = { #else .gameName = "pokemon green version", #endif - // .monFrontPics = gMonFrontPicTable, - // .monBackPics = gMonBackPicTable, - // .monNormalPalettes = gMonPaletteTable, - // .monShinyPalettes = gMonShinyPaletteTable, - // .monIcons = gMonIconTable, - // .monIconPaletteIds = gMonIconPaletteIndices, + //.monFrontPics = gMonFrontPicTable, // Handled in gSpeciesInfo + //.monBackPics = gMonBackPicTable, // Handled in gSpeciesInfo + //.monNormalPalettes = gMonPaletteTable, // Handled in gSpeciesInfo + //.monShinyPalettes = gMonShinyPaletteTable, // Handled in gSpeciesInfo + //.monIcons = gMonIconTable, + //.monIconPaletteIds = gMonIconPaletteIndices, .monIconPalettes = gMonIconPaletteTable, - // .monSpeciesNames = gSpeciesNames, - // .moveNames = gMoveNames, + //.monSpeciesNames = gSpeciesNames, // Handled in gSpeciesInfo + //.moveNames = gMoveNames, // Handled in gMovesInfo .decorations = gDecorations, .flagsOffset = offsetof(struct SaveBlock1, flags), .varsOffset = offsetof(struct SaveBlock1, vars), .pokedexOffset = offsetof(struct SaveBlock2, pokedex), .seen1Offset = offsetof(struct SaveBlock1, dexSeen), - .seen2Offset = offsetof(struct SaveBlock1, dexSeen), + .seen2Offset = offsetof(struct SaveBlock1, dexSeen), // dex flags are combined, just provide the same pointer .pokedexVar = VAR_0x403C - VARS_START, .pokedexFlag = FLAG_0x838, - .mysteryGiftFlag = FLAG_SYS_MYSTERY_GIFT_ENABLED, + .mysteryEventFlag = FLAG_SYS_MYSTERY_GIFT_ENABLED, .pokedexCount = NATIONAL_DEX_COUNT, .playerNameLength = PLAYER_NAME_LENGTH, - .unk2 = 10, + .trainerNameLength = TRAINER_NAME_LENGTH, .pokemonNameLength1 = POKEMON_NAME_LENGTH, .pokemonNameLength2 = POKEMON_NAME_LENGTH, // Two of the below 12s are likely move/ability name length, given their presence in this header @@ -142,14 +152,14 @@ static const struct GFRomHeader sGFRomHeader = { .trainerIdOffset = offsetof(struct SaveBlock2, playerTrainerId), .playerNameOffset = offsetof(struct SaveBlock2, playerName), .playerGenderOffset = offsetof(struct SaveBlock2, playerGender), - .unkFlagOffset = offsetof(struct SaveBlock2, unkFlag2), - .unkFlagOffset2 = offsetof(struct SaveBlock2, unkFlag2), + .frontierStatusOffset = offsetof(struct SaveBlock2, unkFlag2), + .frontierStatusOffset2 = offsetof(struct SaveBlock2, unkFlag2), .externalEventFlagsOffset = offsetof(struct SaveBlock1, externalEventFlags), .externalEventDataOffset = offsetof(struct SaveBlock1, externalEventData), .unk18 = 0x00000000, .speciesInfo = gSpeciesInfo, - // .abilityNames = gAbilityNames, - // .abilityDescriptions = gAbilityDescriptionPointers, + //.abilityNames = gAbilityNames, //handled in gAbilitiesInfo + //.abilityDescriptions = gAbilityDescriptionPointers, //handled in gAbilitiesInfo .items = gItemsInfo, .moves = gMovesInfo, .ballGfx = gBallSpriteSheets, @@ -165,8 +175,10 @@ static const struct GFRomHeader sGFRomHeader = { .pcItemsCount = PC_ITEMS_COUNT, .pcItemsOffset = offsetof(struct SaveBlock1, pcItems), .giftRibbonsOffset = offsetof(struct SaveBlock1, giftRibbons), +#if FREE_ENIGMA_BERRY == FALSE .enigmaBerryOffset = offsetof(struct SaveBlock1, enigmaBerry), .enigmaBerrySize = sizeof(struct EnigmaBerry), +#endif //FREE_ENIGMA_BERRY .moveDescriptions = NULL, .unk20 = 0xFFFFFFFF, // 0x00000000 in Emerald };