diff --git a/data/data.s b/data/data.s index 39482338e..30c0fdce9 100644 --- a/data/data.s +++ b/data/data.s @@ -1011,7 +1011,7 @@ gUnknown_80B7DF8: .fill 8, 1, 0 .global gVectorDirections -gVectorDirections: @ GBA=080B7E3C | NDS=0208772C +gVectorDirections: @ R=080B7E3C | B=0208772C .4byte 0, 1 @N .4byte 1, 1 @NE .4byte 1, 0 @E diff --git a/data/data_810AC60.s b/data/data_810AC60.s index b87dba061..bf01dd647 100644 --- a/data/data_810AC60.s +++ b/data/data_810AC60.s @@ -65,7 +65,7 @@ gIsTypePhysicalTable: @ 810AC7C .byte 0x00 .global gUnknown_810AC90 -gUnknown_810AC90: @ 810AC90 +gUnknown_810AC90: @ R=810AC90 | B=020C3498 .byte 0x02, 0x00, 0x00, 0x00 .byte 0x04, 0x00, 0x00, 0x00 .byte 0x06, 0x00, 0x00, 0x00 diff --git a/include/code_801B3C0.h b/include/code_801B3C0.h index 8195284cd..191275b7f 100644 --- a/include/code_801B3C0.h +++ b/include/code_801B3C0.h @@ -9,15 +9,15 @@ // size: 0x94 typedef struct unkStruct_203B230 { - s32 state; + /* 0x0 */ s32 state; /* 0x4 */ Item item; - s32 unk8; - s32 unkC; - STATUSTEXTS(unk10); - u32 unk20; - u32 unk24; - WindowTemplates unk28; - MenuInputStructSub unk88; + /* 0x8 */ s32 unk8; + /* 0xC */ s32 unkC; + /* 0x10 */ STATUSTEXTS(unk10); + /* 0x20 */ u32 unk20; + /* 0x24 */ u32 unk24; + /* 0x28 */ WindowTemplates unk28; + /* 0x88 */ MenuInputStructSub unk88; } unkStruct_203B230; bool8 InitItemDescriptionWindow(Item *item); diff --git a/include/data_serializer.h b/include/data_serializer.h index 4398a28d0..83c9f3d46 100644 --- a/include/data_serializer.h +++ b/include/data_serializer.h @@ -4,10 +4,10 @@ // size: 0x10 typedef struct DataSerializer { - u8 *stream; - u8 *end; // Exclusive end of the stream - u32 count; // Used to count bits between ReadBits functions, or count bytes between ReadBytes functions - u32 unkC; // Seems to be a temporary 32 bit storage + /* 0x0 */ u8 *stream; + /* 0x4 */ u8 *end; // Exclusive end of the stream + /* 0x8 */ u32 count; // Used to count bits between ReadBits functions, or count bytes between ReadBytes functions + /* 0xC */ u32 unkC; // Seems to be a temporary 32 bit storage } DataSerializer; -#endif // GUARD_DATA_SERIALIZER_H \ No newline at end of file +#endif // GUARD_DATA_SERIALIZER_H diff --git a/include/items.h b/include/items.h index 46510507b..46fb9b2ad 100644 --- a/include/items.h +++ b/include/items.h @@ -83,7 +83,7 @@ s32 SaveTeamInventory(u8 *, u32 size); s32 GetItemPossessionCount(u8 id); s32 WriteHighDecimal(s32, u8 *strbuf, u8); -u32 sub_80913E0(Item* slot, u32 a2, STATUSTEXTS(statuses)); +u32 sub_80913E0(Item* slot, u32 windowId, STATUSTEXTS(statuses)); u8 sub_8091E94(s32 a0, s32 a1, s32 a2); static inline void ZeroOutItem(Item *item) diff --git a/include/kecleon_bros1.h b/include/kecleon_bros1.h index 688143194..4a93bc4b1 100644 --- a/include/kecleon_bros1.h +++ b/include/kecleon_bros1.h @@ -1,73 +1,6 @@ #ifndef GUARD_KECLEON_BROS1_H #define GUARD_KECLEON_BROS1_H -#include "items.h" -#include "structs/menu.h" -#include "structs/str_mon_portrait.h" -#include "structs/str_text.h" - -enum KecleonStoreStates -{ - KECLEON_STORE_INIT = 0, - KECLEON_STORE_MAIN_MENU, - KECLEON_STORE_INFO, - KECLEON_STORE_UNK3, - KECLEON_STORE_EXIT, - KECLEON_STORE_NO_STORE_ITEMS, - KECLEON_STORE_NO_MONEY, - KECLEON_STORE_TOO_MUCH_MONEY, - KECLEON_STORE_NO_ITEMS_TO_SELL, - KECLEON_STORE_NO_ITEMS, - KECLEON_STORE_TOO_MANY_ITEMS, - KECLEON_STORE_UNK11, - KECLEON_STORE_NOT_ENOUGH_MONEY, - KECLEON_STORE_CANT_SELL_ITEM, - KECLEON_STORE_SELL_ITEM_TOO_MUCH_MONEY, - KECLEON_STORE_UNK15, - KECLEON_STORE_BUY_ITEM_MENU, - KECLEON_STORE_BUY_ITEM_RECEIPT, - KECLEON_STORE_UNK18, - KECLEON_STORE_UNK19, - KECLEON_STORE_UNK20, - KECLEON_STORE_BUY_ITEM_INFO, - KECLEON_STORE_BUY_ITEM, - KECLEON_STORE_UNK23, - KECLEON_STORE_SELL_ITEM_MENU, - KECLEON_STORE_SELL_ITEM_RECEIPT, - KECLEON_STORE_UNK26, - KECLEON_STORE_UNK27, - KECLEON_STORE_UNK28, - KECLEON_STORE_SELL_ITEM_INFO, - KECLEON_STORE_SELL_ITEM, - KECLEON_STORE_SELL_ALL_ITEMS, - KECLEON_STORE_SELL_ALL_ITEMS_RECEIPT, -}; - -// size: 0x148 -typedef struct KecleonBrosWork1 -{ - /* 0x0 */ u32 mode; // Corresponds to the enum: KecleonBrosMode - /* 0x4 */ bool8 isKecleonItemShop; // FALSE indicates it is Kecleon TM Shop - /* 0x8 */ u32 currState; - /* 0xC */ u32 fallbackState; - /* 0x10 */ s32 itemSellPrice; - /* 0x14 */ u32 numInventoryItemToSell; - /* 0x18 */ s32 inventoryItemSellPrice; - /* 0x1C */ Item soldItem; - /* 0x20 */ u8 itemShopItemIndex; - /* 0x21 */ u8 wareShopItemIndex; - /* 0x24 */ u32 soldItemInventoryIndex; - /* 0x28 */ u32 menuAction1; - /* 0x2C */ u32 menuAction2; - /* 0x30 */ u32 menuAction3; - /* 0x34 */ MenuItem menuItems[8]; - u16 unk74[8]; - /* 0x84 */ MenuStruct menu; - /* 0xD4 */ MonPortraitMsg monPortrait; - MonPortraitMsg *monPortraitPtr; - WindowTemplates unkE8; -} KecleonBrosWork1; - // mode corresponds to the enum: KecleonBrosMode bool8 CreateKecleonBros(u32 mode); void DeleteKecleonBros(void); diff --git a/include/kecleon_bros3.h b/include/kecleon_bros3.h index 26fbb85fa..bfced0287 100644 --- a/include/kecleon_bros3.h +++ b/include/kecleon_bros3.h @@ -4,7 +4,7 @@ #include "structs/menu.h" #include "structs/str_text.h" -u8 sub_801A20C(u32); +bool8 sub_801A20C(u32); u32 sub_801A2A8(bool8); u8 sub_801A37C(void); void sub_801A398(bool8); diff --git a/include/kecleon_bros4.h b/include/kecleon_bros4.h index 500cd3c03..bb5a1822f 100644 --- a/include/kecleon_bros4.h +++ b/include/kecleon_bros4.h @@ -1,17 +1,7 @@ #ifndef GUARD_KECLEON_BROS4_H #define GUARD_KECLEON_BROS4_H -#include "constants/item.h" -#include "structs/menu.h" -#include "structs/struct_sub80095e4.h" - -// size: 0xF4 -typedef struct unkStruct_203B224 -{ - u32 unk0; - u32 unk4[INVENTORY_SIZE]; - /* 0x54 */ struct_Sub80095E4_2 unk54; -} unkStruct_203B224; +#include "structs/str_position.h" bool8 sub_801A5D8(u32, s32, DungeonPos *, u32); u32 sub_801A6E8(bool8); diff --git a/include/menu_input.h b/include/menu_input.h index 615919427..4e69a1f95 100644 --- a/include/menu_input.h +++ b/include/menu_input.h @@ -7,7 +7,7 @@ u32 sub_8012A64(MenuInputStructSub *r0, s32 r1); s32 GetKeyPress(MenuInputStruct *r0); s32 sub_8012AE8(void); -void sub_8012BC4(u32 x, u32 y, s32 n, s32 len, u32 color, u32 param_6); +void sub_8012BC4(u32 x, u32 y, s32 n, s32 len, u32 color, u32 windowId); void sub_8012C60(u32 x, u32 y, u32 param_3, u32 color, u32 param_5); void sub_8012CAC(WindowTemplate *param_1, const MenuItem *param_2); void sub_8012D08(WindowTemplate *param_1, s32 param_2); diff --git a/include/pokemon.h b/include/pokemon.h index 17db80602..3b5e0c5d2 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -30,10 +30,10 @@ typedef struct unkStruct_808E218 HiddenPower unk0[3]; } unkStruct_808E218; -extern unkStruct_203B45C *gRecruitedPokemonRef; +extern RecruitedMon *gRecruitedPokemonRef; void LoadMonsterParameters(void); -unkStruct_203B45C *GetRecruitedPokemon(void); +RecruitedMon *GetRecruitedPokemon(void); void InitializeRecruitedPokemon(void); diff --git a/include/save.h b/include/save.h index dc7c3409a..bdae6ffc4 100644 --- a/include/save.h +++ b/include/save.h @@ -53,7 +53,7 @@ struct UnkStruct_sub_8011DAC struct UnkStruct_203B184 { /* 0x0 */ TeamInventory *MoneyItems; - /* 0x4 */ unkStruct_203B45C *recruitedPokemon; + /* 0x4 */ RecruitedMon *recruitedPokemon; /* 0x8 */ unkStruct_203B480 *unk8; /* 0xC */ unkStruct_203B484 *unkC; /* 0x10 */ u32 *unk10; diff --git a/include/sprite.h b/include/sprite.h index ca132e295..ecb160733 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -37,7 +37,7 @@ void BlinkSavingIcon(void); void CopySpritesToOam(void); void DoAxFrame_800558C(axdata *, s32 spriteX, s32 spriteY, u32, u32 paletteNum, unkStruct_2039DB0 *spriteMasks); void InitSprites(void); -void nullsub_7(s16 *); +void nullsub_7(DungeonPos *); void nullsub_8(u32); void nullsub_9(void); void nullsub_10(bool8); diff --git a/include/structs/dungeon_entity.h b/include/structs/dungeon_entity.h index 6ad7f56e4..0d7d4fded 100644 --- a/include/structs/dungeon_entity.h +++ b/include/structs/dungeon_entity.h @@ -47,7 +47,7 @@ typedef struct ActionContainer /* 0x14 */ DungeonPos itemTargetPosition; } ActionContainer; -// size: 0x4 +// size: R=0x4 | B=0x3 typedef struct HiddenPower { /* 0x0 */ s16 hiddenPowerBasePower; @@ -183,11 +183,11 @@ typedef struct Unk_Entity_x184 /* 0x19e - 0x1a */ u8 unk1A; } Unk_Entity_x184; -// size: 0x24 +// size: R=0x24 | B=0x19? typedef struct Moves { - /* 0x0 */ Move moves[MAX_MON_MOVES]; - /* 0x20 */ u8 struggleMoveFlags; + /* R=0x0 | B=0x0 */ Move moves[MAX_MON_MOVES]; + /* R=0x20 | B=0x18 */ u8 struggleMoveFlags; } Moves; // size: 0x208 diff --git a/include/structs/menu.h b/include/structs/menu.h index f80753285..381287a2b 100644 --- a/include/structs/menu.h +++ b/include/structs/menu.h @@ -5,40 +5,38 @@ #include "structs/str_text.h" #include "structs/str_position.h" -// size: 0xC +// size: R=0xC | NDS=0xA? typedef struct MenuInputStructSub { - u8 unk0; - /* 0x1 */ u8 a_button; - /* 0x2 */ u8 b_button; - /* 0x3 */ u8 dpad_right; - /* 0x4 */ u8 dpad_left; - /* 0x5 */ u8 unk5; - u8 fill6[2]; - u16 unk8; - s16 unkA; + /* R=0x0 | B=0x0 */ u8 unk0; + /* R=0x1 | B=0x1 */ u8 a_button; + /* R=0x2 | B=0x2 */ u8 b_button; + /* R=0x3 | B=0x3 */ u8 dpad_right; + /* R=0x4 | B=0x4 */ u8 dpad_left; + /* R=0x5 | B=0x5 */ u8 unk5; + /* R=0x8 | B=0x6 */ DungeonPos unk8; } MenuInputStructSub; -// size: 0x34 +// size: R=0x34 | NDS=0x32? typedef struct MenuInputStruct { - s32 unk0; - u16 unk4; - s16 firstEntryY; - DungeonPos unk8; - s16 unkC; // Maybe DungeonPos - s16 unkE; - u32 unk10; - DungeonPos unk14; + /* 0x0 */ s32 unk0; + /* 0x4 */ u16 unk4; + /* 0x6 */ s16 firstEntryY; + /* 0x8 */ DungeonPos unk8; + /* 0xC */ s16 unkC; // Maybe DungeonPos + /* 0xE */ s16 unkE; + /* 0x10 */ u32 unk10; + /* 0x14 */ DungeonPos unk14; /* 0x18 */ s16 menuIndex; - s16 unk1A; - s16 unk1C; - s16 unk1E; - s16 unk20; - s16 unk22; - u16 unk24; - u16 unk26; - MenuInputStructSub unk28; + /* 0x1A */ s16 unk1A; + /* 0x1C */ s16 unk1C; + /* 0x1E */ s16 unk1E; + /* 0x20 */ s16 unk20; + /* 0x22 */ s16 unk22; + /* 0x24 */ u16 unk24; + /* 0x26 */ u16 unk26; + /* 0x28 */ MenuInputStructSub unk28; } MenuInputStruct; // size: 0x8 @@ -48,19 +46,19 @@ typedef struct MenuItem s32 menuAction; } MenuItem; -// size: 0x50 +// size: R=0x50 | B=0x4C? typedef struct MenuStruct { - const u8 *unk0; // header text? + /* 0x0 */ const u8 *unk0; // header text? /* 0x4 */ const MenuItem *menuItems; - const u32 *menuTextColorArray; - u16 *unkC; + /* 0x8 */ const u32 *menuTextColorArray; + /* 0xC */ u16 *unkC; /* 0x10 */ s32 index; /* 0x14 */ MenuInputStruct input; /* 0x48 */ s32 menuAction; - bool8 unk4C; - bool8 unk4D; - bool8 unk4E; + /* 0x4C */ bool8 unk4C; + /* 0x4D */ bool8 unk4D; + /* 0x4E */ bool8 unk4E; } MenuStruct; // size: 0x30. Seems to be info for a NumericUpDown diff --git a/include/structs/str_dungeon.h b/include/structs/str_dungeon.h index 426e03d83..dd12783b3 100644 --- a/include/structs/str_dungeon.h +++ b/include/structs/str_dungeon.h @@ -159,6 +159,7 @@ typedef struct ItemSpawns s16 itemValues[NUMBER_OF_ITEM_IDS]; } ItemSpawns; +// size: R=0x8 | B=0x6 typedef struct UnkDungeonGlobal_unk1CD98 { u16 unk0; // species and level diff --git a/include/structs/str_dungeon_location.h b/include/structs/str_dungeon_location.h index 8a67d6df7..78274b7cc 100644 --- a/include/structs/str_dungeon_location.h +++ b/include/structs/str_dungeon_location.h @@ -1,7 +1,7 @@ #ifndef GUARD_STR_DUNGEON_LOCATION_H #define GUARD_STR_DUNGEON_LOCATION_H -// size: 0x4 +// size: R=0x4 | B=0x2 typedef struct DungeonLocation { /* 0x0 */ u8 id; diff --git a/include/structs/str_iq_skill_flags.h b/include/structs/str_iq_skill_flags.h index a310c07a8..fd34c0b0e 100644 --- a/include/structs/str_iq_skill_flags.h +++ b/include/structs/str_iq_skill_flags.h @@ -3,9 +3,10 @@ #define NUM_PICKED_IQ_SKILLS 3 +// size: R=0x4 | B=0x3 typedef struct IqSkillFlags { - u8 flags[NUM_PICKED_IQ_SKILLS]; + /* 0x0 */ u8 flags[NUM_PICKED_IQ_SKILLS]; } IqSkillFlags; -#endif +#endif // GUARD_STR_IQ_SKILL_FLAGS_H diff --git a/include/structs/str_items.h b/include/structs/str_items.h index 44085fd76..dc8f20af3 100644 --- a/include/structs/str_items.h +++ b/include/structs/str_items.h @@ -3,7 +3,7 @@ #include "constants/item.h" -// size: 0x20 +// size: R=0x20 | B=? typedef struct ItemDataEntry { /* 0x0 */ u8 *name; @@ -25,6 +25,23 @@ typedef struct ItemDataEntry } ItemDataEntry; // size: 0x4 +typedef struct Gummi +{ + /* 0x0 */ s16 boostAmount; + /* 0x2 */ u16 flags; +} Gummi; + +// size: R=0xC | B=0x9? +typedef struct unkStruct_8090F58 +{ + /* 0x0 */ u32 unk0; + /* 0x4 */ u8 unk4; + /* 0x5 */ u8 unk5; + /* 0x6 */ s16 unk6; + /* 0x8 */ u8 unk8; +} unkStruct_8090F58; + +// size: R=0x4 | B=0x3 typedef struct Item { /* 0x0 */ u8 flags; @@ -32,39 +49,22 @@ typedef struct Item /* 0x2 */ u8 id; } Item; -// size: 0x4 +// size: R=0x4 | B=0x2 typedef struct BulkItem { /* 0x0 */ u8 id; /* 0x1 */ u8 quantity; } BulkItem; -// size: 0x4 -typedef struct Gummi -{ - /* 0x0 */ s16 boostAmount; - /* 0x2 */ u16 flags; -} Gummi; - -// size: 0xC -typedef struct unkStruct_8090F58 -{ - u32 unk0; - u8 unk4; - u8 unk5; - s16 unk6; - u8 unk8; -} unkStruct_8090F58; - -// size: 0x268 +// size: R=0x268 | B=0x23C typedef struct TeamInventory { - /* 0x0 */ Item teamItems[INVENTORY_SIZE]; - /* 0x50 */ u16 teamStorage[STORAGE_SIZE]; - /* 0x230 */ BulkItem kecleonShopItems[MAX_KECLEON_ITEM_SHOP_ITEMS]; - /* 0x250 */ BulkItem kecleonWareItems[MAX_KECLEON_WARE_SHOP_ITEMS]; - /* 0x260 */ s32 teamMoney; - /* 0x264 */ s32 teamSavings; + /* R=0x0 | B=0x0 */ Item teamItems[INVENTORY_SIZE]; + /* R=0x50 | B=0x3C */ u16 teamStorage[STORAGE_SIZE]; + /* R=0x230 | B=0x21C */ BulkItem kecleonShopItems[MAX_KECLEON_ITEM_SHOP_ITEMS]; + /* R=0x250 | B=0x22C */ BulkItem kecleonWareItems[MAX_KECLEON_WARE_SHOP_ITEMS]; + /* R=0x260 | B=0x234 */ s32 teamMoney; + /* R=0x264 | B=0x238 */ s32 teamSavings; } TeamInventory; // TODO: These should be in constants/ diff --git a/include/structs/str_mon_portrait.h b/include/structs/str_mon_portrait.h index 98f82848d..dc92df3fd 100644 --- a/include/structs/str_mon_portrait.h +++ b/include/structs/str_mon_portrait.h @@ -8,26 +8,26 @@ // size: 0x8 typedef struct PortraitGfxSub { - const RGB *pal; - const u8 *gfx; + /* 0x0 */ const RGB *pal; + /* 0x4 */ const u8 *gfx; } PortraitGfxSub; -// size: variable +// size: 0x68 typedef struct PortraitGfx { // NOTE: The actual number of sprites is different depending on pokemon. For example, starters have 12 sprites, while most legendaries only 1. Unused sprites are set as NULL, NULL. - PortraitGfxSub sprites[12]; + /* 0x0 */ PortraitGfxSub sprites[13]; } PortraitGfx; -// size: 0xC +// size: 0x10 typedef struct MonPortraitMsg { - OpenedFile *faceFile; - PortraitGfx *faceData; - DungeonPos pos; - u8 spriteId; // Which mon's sprite to use. For example Kecleon has multiple sprites depending on whether it's green or purple. - bool8 flip; // Whether the mon's sprite is flipped. - u8 unkE; + /* 0x0 */ OpenedFile *faceFile; + /* 0x4 */ PortraitGfx *faceData; + /* 0x8 */ DungeonPos pos; + /* 0xC */ u8 spriteId; // Which mon's sprite to use. For example Kecleon has multiple sprites depending on whether it's green or purple. + /* 0xD */ bool8 flip; // Whether the mon's sprite is flipped. + /* 0xE */ u8 unkE; } MonPortraitMsg; #endif // GUARD_STR_MON_PORTRAIT_H diff --git a/include/structs/str_moves.h b/include/structs/str_moves.h index 68b63ca97..c98e8fa38 100644 --- a/include/structs/str_moves.h +++ b/include/structs/str_moves.h @@ -3,7 +3,7 @@ #include "constants/move.h" -// size: 0x24 +// size: R=0x24 | B=? typedef struct MoveDataEntry { /* 0x0 */ u8 *name; @@ -29,14 +29,14 @@ typedef struct MoveDataEntry /* 0x20 */ u8 *useText; // The text displayed when this move is used. } MoveDataEntry; -// size: 0x8 +// size: R=0x8 | B=0x6 typedef struct Move { - u8 moveFlags; - u8 moveFlags2; - u16 id; - u8 PP; - u8 ginseng; // How much the move is boosted by Ginsengs. + /* 0x0 */ u8 moveFlags; + /* 0x1 */ u8 moveFlags2; + /* 0x2 */ u16 id; + /* 0x4 */ u8 PP; + /* 0x5 */ u8 ginseng; // How much the move is boosted by Ginsengs. } Move; #endif // GUARD_STR_MOVES_H \ No newline at end of file diff --git a/include/structs/str_pokemon.h b/include/structs/str_pokemon.h index 8a7d7e1a2..625048138 100644 --- a/include/structs/str_pokemon.h +++ b/include/structs/str_pokemon.h @@ -14,30 +14,30 @@ typedef struct Offense /* 0x2 */ u8 def[2]; // Def, SpDef } Offense; -// size: 0x4 +// size: R=0x4 | B=0x1 typedef struct unkPokeSubStruct_C { - u8 level; + /* 0x0 */ u8 level; } unkPokeSubStruct_C; -// size: 0x58 +// size: R=0x58 | B=0x40 typedef struct PokemonStruct1 { - u16 unk0; // Probably a union: Sometimes ldrh and sometimes ldrb. Recruited?? "sub_80954CC" only loads 2 bits of info - /* 0x2 */ bool8 isTeamLeader; - /* 0x3 */ u8 level; - /* 0x4 */ DungeonLocation dungeonLocation; - /* 0x8 */ s16 speciesNum; - unkPokeSubStruct_C unkC[2]; - /* 0x14 */ s16 IQ; - /* 0x16 */ s16 pokeHP; - /* 0x18 */ Offense offense; - /* 0x1C */ u32 currExp; - /* 0x20 */ IqSkillFlags IQSkills; - /* 0x24 */ u8 tacticIndex; - /* 0x28 */ BulkItem heldItem; - /* 0x2C */ Move moves[MAX_MON_MOVES]; - /* 0x4C */ u8 name[POKEMON_NAME_LENGTH]; + /* R=0x0 | B=0x0 */ u16 unk0; // Probably a union: Sometimes ldrh and sometimes ldrb. Recruited?? Only 2 bits are serialized + /* R=0x2 | B=0x2 */ bool8 isTeamLeader; + /* R=0x3 | B=0x3 */ u8 level; + /* R=0x4 | B=0x4 */ DungeonLocation dungeonLocation; + /* R=0x8 | B=0x6 */ s16 speciesNum; + /* R=0xC | B=0x8 */ unkPokeSubStruct_C unkC[2]; + /* R=0x14 | B=0xA */ s16 IQ; + /* R=0x16 | B=0xC */ s16 pokeHP; + /* R=0x18 | B=0xE */ Offense offense; + /* R=0x1C | B=0x14 */ u32 currExp; + /* R=0x20 | B=0x18 */ IqSkillFlags IQSkills; + /* R=0x24 | B=0x1B */ u8 tacticIndex; + /* R=0x28 | B=0x1C */ BulkItem heldItem; + /* R=0x2C | B=0x1E */ Move moves[MAX_MON_MOVES]; + /* R=0x4C | B=0x36 */ u8 name[POKEMON_NAME_LENGTH]; } PokemonStruct1; // size: 0x4 @@ -47,45 +47,38 @@ typedef struct EvolveStage /* 0x2 */ u8 level; } EvolveStage; -// size: 0x24 -typedef struct unkStruct_8094184 -{ - /* 0x0 */ Move moves[MAX_MON_MOVES]; - u8 unk20; -} unkStruct_8094184; - -// size: 0x64 +// size: R=0x64 | B=0x54 typedef struct PokemonStruct2 { - u16 unk0; // corresponds to unk0 in PokemonStruct - /* 0x2 */ bool8 isTeamLeader; - /* 0x3 */ u8 level; - /* 0x4 */ DungeonLocation dungeonLocation; - /* 0x8 */ s16 IQ; - s16 unkA; - u16 unkC; - /* 0xE */ s16 speciesNum; - u16 unk10; // pokeHP - u16 unk12; // pokeHP - /* 0x14 */ Offense offense; // offense (other offset) - /* 0x18 */ u32 currExp; - /* 0x1C */ Moves moves; - /* 0x40 */ Item itemSlot; // heldItem - /* 0x44 */ FixedPoint belly; - /* 0x48 */ FixedPoint maxBelly; - /* 0x4C */ IqSkillFlags IQSkills; - /* 0x50 */ u8 tacticIndex; - /* 0x54 */ HiddenPower hiddenPower; - /* 0x58 */ u8 name[POKEMON_NAME_LENGTH]; // name (other offset) + /* R=0x0 | B=0x0 */ u16 unk0; // corresponds to unk0 in PokemonStruct. Only 2 bits are serialized + /* R=0x2 | B=0x2 */ bool8 isTeamLeader; + /* R=0x3 | B=0x3 */ u8 level; + /* R=0x4 | B=0x4 */ DungeonLocation dungeonLocation; + /* R=0x8 | B=0x6 */ s16 IQ; + /* R=0xA | B=0x8 */ s16 unkA; + /* R=0xC | B=0xA */ u16 unkC; + /* R=0xE | B=0xC */ s16 speciesNum; + /* R=0x10 | B=0xE */ u16 unk10; // pokeHP + /* R=0x12 | B=0x10 */ u16 unk12; // pokeHP + /* R=0x14 | B=0x12 */ Offense offense; // offense (other offset) + /* R=0x18 | B=0x18 */ u32 currExp; + /* R=0x1C | B=0x1C */ Moves moves; + /* R=0x40 | B=0x36 */ Item itemSlot; // heldItem + /* R=0x44 | B=0x3A */ FixedPoint belly; + /* R=0x48 | B=0x3E */ FixedPoint maxBelly; + /* R=0x4C | B=0x42 */ IqSkillFlags IQSkills; + /* R=0x50 | B=0x45 */ u8 tacticIndex; + /* R=0x54 | B=0x46 */ HiddenPower hiddenPower; + /* R=0x58 | B=0x4A */ u8 name[POKEMON_NAME_LENGTH]; // name (other offset) } PokemonStruct2; -// size: 0x90E8 -typedef struct unkStruct_203B45C +// size: R=0x90E8 | B=0x6990 +typedef struct RecruitedMon { - /* 0x0 */ PokemonStruct1 pokemon[NUM_MONSTERS]; - /* 0x8DF8 */ PokemonStruct2 pokemon2[4]; - /* 0x8F88 */ PokemonStruct1 team[MAX_TEAM_MEMBERS]; -} unkStruct_203B45C; + /* R=0x0 | B=0x0 */ PokemonStruct1 pokemon[NUM_MONSTERS]; + /* R=0x8DF8 | B=0x6740 */ PokemonStruct2 pokemon2[4]; + /* R=0x8F88 | B=0x6890 */ PokemonStruct1 team[MAX_TEAM_MEMBERS]; +} RecruitedMon; // size: 0x4 typedef struct PreEvolution diff --git a/include/structs/struct_sub80095e4.h b/include/structs/struct_sub80095e4.h index 94da41810..7b8ecb595 100644 --- a/include/structs/struct_sub80095e4.h +++ b/include/structs/struct_sub80095e4.h @@ -8,21 +8,21 @@ #include "text_3.h" // Struct related with sub_80095E4 +// size: R=0x9C | B=? typedef struct struct_Sub80095E4 { /* 0x0 */ MenuInputStruct input; - u32 unk34; - WindowTemplate *unk38; - WindowTemplates windows; - // size: 0x9C + /* 0x34 */ u32 unk34; + /* 0x38 */ WindowTemplate *unk38; + /* 0x3C */ WindowTemplates windows; } struct_Sub80095E4; -// Has 1 additional array. -// size: 0xA0 +// Has 1 additional array +// size: R=0xA0 | B=0x9C? typedef struct struct_Sub80095E4_2 { /* 0x0 */ struct_Sub80095E4 s0; // s as in 'struct' ; decided to go against unk as to not have `->unk0->unk3C` - WindowHeader unk9C; + /* 0x9C */ WindowHeader unk9C; } struct_Sub80095E4_2; // Note: In order to get matching ASM, this macro had to be created. @@ -33,16 +33,16 @@ typedef struct struct_Sub80095E4_2 s16 newE; \ s16 a0 = (_a0); \ UNUSED s32 a0_ = a0; \ - UNUSED s16 oldE = (ptr).windows.id[(ptr).unk34].height; \ + UNUSED s16 oldE = (ptr).windows.id[(ptr).unk34].height; \ a0_ = 0; \ new10 = a0 + 2; \ newE = a0; \ \ - (ptr).windows.id[(ptr).unk34].height = newE; \ - (ptr).windows.id[(ptr).unk34].unk10 = a0 + 2; \ + (ptr).windows.id[(ptr).unk34].height = newE; \ + (ptr).windows.id[(ptr).unk34].unk10 = a0 + 2; \ \ ResetUnusedInputStruct(); \ - ShowWindows(&(ptr).windows, TRUE, TRUE); \ + ShowWindows(&(ptr).windows, TRUE, TRUE); \ } #define SUB_80095E4_CALL(ptr) \ diff --git a/include/text_2.h b/include/text_2.h index 54a65a6c7..4e0d7e3bb 100644 --- a/include/text_2.h +++ b/include/text_2.h @@ -5,7 +5,7 @@ void AddDoubleUnderScoreHighlight(u32 windowId, s32 x, s32 y, s32 width, u32 color); void AddUnderScoreHighlight(u32 windowId, s32 x, s32 y, s32 width, u32 color); -void CallPrepareTextbox_8008C54(u32 strId); +void CallPrepareTextbox_8008C54(u32 windowId); void DisplayMonPortraitSprite(s32 a0, const u8 *compressedData, s32 a2); void DisplayMonPortraitSpriteFlipped(s32 a0, const u8 *compressedData, s32 a1); const unkChar *GetCharacter(s32 chr); @@ -16,9 +16,9 @@ void sub_8007B7C(u32 a0, s32 x, s32 y, s32 a3, u32 color); void sub_8007E20(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 *a5, u32 a6); void sub_80087EC(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); void sub_80089AC(const WindowTemplate *r4, DungeonPos *r5_Str); -u32 xxx_call_draw_char(s32 x, s32 y, u32 a2, u32 color, u32 a4); +u32 xxx_call_draw_char(s32 x, s32 y, u32 chr, u32 color, u32 windowId); bool8 xxx_call_update_bg_vram(void); -u32 xxx_draw_char(Window *windows, s32 x, s32 y, u32 a3, u32 color, u32 windowId); -const u8 *xxx_get_next_char_from_string(const u8 *a1, u32 *a0); +u32 xxx_draw_char(Window *windows, s32 x, s32 y, u32 chr, u32 color, u32 windowId); +const u8 *xxx_get_next_char_from_string(const u8 *a1, u32 *dstChr); #endif // GUARD_TEXT_2_H diff --git a/src/code_80118A4.c b/src/code_80118A4.c index c3ea2761e..ff581110d 100644 --- a/src/code_80118A4.c +++ b/src/code_80118A4.c @@ -10,10 +10,10 @@ extern const u16 gUnknown_80D4144[8]; -EWRAM_DATA u32 gUnknown_202DE1C = {0}; // GBA=202DE1C | NDS=02134218 -EWRAM_DATA s16 gUnknown_202DE20 = {0}; // GBA=202DE20 | NDS=0213420C -EWRAM_DATA s16 gUnknown_202DE22 = {0}; // GBA=202DE22 | NDS=02134210 -EWRAM_DATA s16 gUnknown_202DE24 = {0}; // GBA=202DE24 | NDS=02134214 +EWRAM_DATA u32 gUnknown_202DE1C = {0}; // R=202DE1C | B=2134218 +EWRAM_DATA s16 gUnknown_202DE20 = {0}; // R=202DE20 | B=213420C +EWRAM_DATA s16 gUnknown_202DE22 = {0}; // R=202DE22 | B=2134210 +EWRAM_DATA s16 gUnknown_202DE24 = {0}; // R=202DE24 | B=2134214 void sub_8011760(void) { @@ -148,6 +148,7 @@ void xxx_call_play_fanfare_se(u16 songIndex, u16 volume) PlayFanfareSE(songIndex, volume); } +// arm9.bin::020186c8 void PlaySound(u16 songIndex) { PlayFanfareSE(songIndex, MAX_VOLUME); diff --git a/src/code_801B3C0.c b/src/code_801B3C0.c index 0bc81bdac..869febe5c 100644 --- a/src/code_801B3C0.c +++ b/src/code_801B3C0.c @@ -20,10 +20,11 @@ static void sub_801B480(void); static void sub_801B51C(void); static void sub_801B590(void); +// arm9.bin::02027658 bool8 InitItemDescriptionWindow(Item *item) { ResetSprites(TRUE); - sUnknown_203B230 = MemoryAlloc(sizeof(unkStruct_203B230),8); + sUnknown_203B230 = MemoryAlloc(sizeof(unkStruct_203B230), 8); sUnknown_203B230->item = *item; sub_801317C(&sUnknown_203B230->unk88); sUnknown_203B230->unk24 = 0; @@ -34,6 +35,7 @@ bool8 InitItemDescriptionWindow(Item *item) return TRUE; } +// arm9.bin::020275F8 u32 sub_801B410(void) { switch (sUnknown_203B230->state) { @@ -53,6 +55,7 @@ u32 sub_801B410(void) return 0; } +// arm9.bin::020275C4 void FreeItemDescriptionWindow(void) { if (sUnknown_203B230 != NULL) { @@ -61,12 +64,14 @@ void FreeItemDescriptionWindow(void) } } +// arm9.bin::020275A8 static void sub_801B46C(u32 newState) { sUnknown_203B230->state = newState; sub_801B480(); } +// arm9.bin::02027490 static void sub_801B480(void) { switch (sUnknown_203B230->state) { diff --git a/src/code_803D0D8.c b/src/code_803D0D8.c index d3d4082fa..5f03d3472 100644 --- a/src/code_803D0D8.c +++ b/src/code_803D0D8.c @@ -11,6 +11,7 @@ static EWRAM_INIT u8 sUnknown_203B408 = {1}; #include "data/code_803D0D8.h" +// arm9.bin::02059A08 u8 sub_803D0D8() { return sUnknown_203B408; @@ -21,16 +22,19 @@ UNUSED static void sub_803D0E4(u8 a0) sUnknown_203B408 = a0; } +// arm9.bin::020599F8 u8 sub_803D0F0(u8 r0) { return sUnknown_80F42F0[r0]; } +// arm9.bin::020599E8 u8 sub_803D100(u8 r0) { return sUnknown_80F42D0[r0]; } +// arm9.bin::02059908 u8 sub_803D110(u8 *param_1, u8 *param_2, s32 size) { s32 index1; @@ -73,6 +77,7 @@ u8 sub_803D110(u8 *param_1, u8 *param_2, s32 size) return 1; } +// arm9.bin::0205986C void sub_803D1A8(u8 *param_1, u8 *param_2, s32 size) { s32 index; @@ -98,6 +103,7 @@ void sub_803D1A8(u8 *param_1, u8 *param_2, s32 size) } } +// arm9.bin::02059778 bool8 sub_803D204(u8 *buffer,unkStruct_203B480 *param_2) { s32 innerIndex; @@ -136,10 +142,11 @@ bool8 sub_803D204(u8 *buffer,unkStruct_203B480 *param_2) return FALSE; } +// arm9.bin::020596B0 void sub_803D2C0(u8 *buffer, unkStruct_203B480 *mail) { u8 checksum; - int index; + s32 index; u8 local_c0 [34]; u8 buffer1 [PASSWORD_BUFFER_SIZE]; u8 buffer2 [PASSWORD_BUFFER_SIZE]; @@ -168,10 +175,11 @@ void sub_803D2C0(u8 *buffer, unkStruct_203B480 *mail) MemoryCopy8(buffer,buffer2,sizeof(buffer2)); } +// arm9.bin::020595BC bool8 DecodeWonderMailPassword(u8* buffer, WonderMail *mail) { s32 innerIndex; - int index; + s32 index; u8 checksum; u8 local_70 [16]; u8 local_60 [24]; @@ -190,8 +198,6 @@ bool8 DecodeWonderMailPassword(u8* buffer, WonderMail *mail) local_60[index] = password[innerIndex]; } - - if (sub_803D110(local_60,local_70,24) != 0) { for(index = 1; index < 0xF; index++) @@ -208,6 +214,7 @@ bool8 DecodeWonderMailPassword(u8* buffer, WonderMail *mail) return FALSE; } +// arm9.bin::020594F4 void sub_803D414(u8 *buffer,WonderMail *mail) { u8 checksum; @@ -240,6 +247,11 @@ void sub_803D414(u8 *buffer,WonderMail *mail) MemoryCopy8(buffer,auStack_44,sizeof(auStack_44)); } + +// File boundary? + + + void sub_803D4AC(void) { gDungeon->unk1C570.id = 0x63; diff --git a/src/code_8092334.c b/src/code_8092334.c index c335e247a..8fe0f624d 100644 --- a/src/code_8092334.c +++ b/src/code_8092334.c @@ -24,6 +24,7 @@ s16 sub_8094828(u16 moveID, u8 id) // New file here +// arm9.bin::02064998 void InitBitReader(DataSerializer *r0, u8 *buffer, s32 bufLen) { r0->stream = buffer; @@ -32,6 +33,7 @@ void InitBitReader(DataSerializer *r0, u8 *buffer, s32 bufLen) r0->end = buffer + bufLen; } +// arm9.bin::0206496C void InitBitWriter(DataSerializer *r0, u8 *buffer, s32 bufLen) { r0->stream = buffer; @@ -41,10 +43,12 @@ void InitBitWriter(DataSerializer *r0, u8 *buffer, s32 bufLen) MemoryClear8(buffer, bufLen); } +// arm9.bin::02064968 void FinishBitSerializer(DataSerializer *seri) { } +// arm9.bin::020648D0 void WriteBits(DataSerializer *r0, void *src, s32 numBits) { s32 curBit; @@ -92,6 +96,7 @@ UNUSED void sub_80948E4(DataSerializer *seri, void *src, s32 numBytes) } } +// arm9.bin::0206482C void ReadBits(DataSerializer *r0, void *dst, s32 numBits) { s32 curBit; diff --git a/src/code_809447C.c b/src/code_809447C.c index 943b06e63..b4ca77d67 100644 --- a/src/code_809447C.c +++ b/src/code_809447C.c @@ -11,12 +11,14 @@ #include "text_util.h" #include "strings.h" +// arm9.bin::02064154 void ReadBellyBits(DataSerializer *r0, FixedPoint *dst) { ReadBits(r0, &dst->unk0, 16); ReadBits(r0, &dst->unk2, 16); } +// arm9.bin::02064124 void WriteBellyBits(DataSerializer *r0, FixedPoint *src) { WriteBits(r0, &src->unk0, 16); diff --git a/src/code_80958E8.c b/src/code_80958E8.c index 52dec177c..619ddaa62 100644 --- a/src/code_80958E8.c +++ b/src/code_80958E8.c @@ -1428,6 +1428,7 @@ u32 SaveMailInfo(u8 *r0, u32 size) return backup.count; } +// arm9.bin::020662A0 void ReadWonderMailBits(DataSerializer *a, WonderMail *b) { ReadBits(a, &b->mailType, 4); @@ -1443,6 +1444,7 @@ void ReadWonderMailBits(DataSerializer *a, WonderMail *b) ReadDungeonLocationBits(a, &b->unk4.dungeon); } +// arm9.bin::020661E4 void WriteWonderMailBits(DataSerializer *a, WonderMail *b) { WriteBits(a, &b->mailType, 4); diff --git a/src/code_8097DD0.c b/src/code_8097DD0.c index bda6f1f61..33e21b66c 100644 --- a/src/code_8097DD0.c +++ b/src/code_8097DD0.c @@ -13,6 +13,7 @@ static bool8 AreStatusesTheSame(const StatusText *status1, const StatusText *sta } } +// arm9.bin::02069774 s32 PrepareStatusStringArrays(const char *str, STATUSTEXTS(statuses)) { s32 i, j; diff --git a/src/code_809A560.c b/src/code_809A560.c index 9d57f7f31..2a404dae0 100644 --- a/src/code_809A560.c +++ b/src/code_809A560.c @@ -19,6 +19,7 @@ #include "kangaskhan_storage1.h" #include "kangaskhan_storage2.h" #include "kecleon_bros1.h" +#include "kecleon_bros4.h" #include "main_loops.h" #include "memory.h" #include "personality_test1.h" @@ -713,8 +714,6 @@ u8 sub_801FB50(); void sub_80155F0(); s32 sub_80160D8(); void ResetTextbox_809B294(); -u8 sub_801A5D8(); -s32 sub_801A6E8(s32); s32 sub_801A8AC(); void sub_801A928(); s32 sub_8016080(); @@ -1864,7 +1863,7 @@ bool8 sub_809B648(void) if (gUnknown_3001B64->unk420 == 1) { ResetTextbox_809B294(); ShowWindows(NULL, 1, 1); - if (sub_801A5D8(0,0,0,10)) { + if (sub_801A5D8(0,0,NULL,10)) { return 1; } else { @@ -1873,7 +1872,7 @@ bool8 sub_809B648(void) } } else { - switch(sub_801A6E8(1)) { + switch(sub_801A6E8(TRUE)) { case 3: { s32 itemArrayId = sub_801A8AC(); s32 itemId = gTeamInventoryRef->teamItems[itemArrayId].id; diff --git a/src/common_strings.c b/src/common_strings.c index 0c88c5ac0..6988d33ec 100644 --- a/src/common_strings.c +++ b/src/common_strings.c @@ -158,6 +158,7 @@ ALIGNED(4) const u8* const gCommonKangStorage[KANG_MODE_COUNT][KANG_DLG_MAX] = } }; +// NDS=020A7614 ALIGNED(4) const u8* const gCommonKecleonBros[KECLEON_BROS_MODE_COUNT][KECLEON_DLG_MAX] = { [KECLEON_BROS_MODE_ITEMS_AWAKE] = { diff --git a/src/data/items.h b/src/data/items.h index 51e536dfe..2a2055bba 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -1,4 +1,5 @@ // LUT for money item stack size -> money amount +// NDS=020C359C const s32 gUnknown_810A3F0[100] = { 4, 6, 10, 14, 22, 26, 34, 38, 46, 58, 62, 74, 82, 86, 94, 106, 118, 122, 134, 142, diff --git a/src/data/pokemon_3.h b/src/data/pokemon_3.h index 4bd1c9eff..0455b84b0 100644 --- a/src/data/pokemon_3.h +++ b/src/data/pokemon_3.h @@ -13,23 +13,24 @@ const u8 gInvalidDungeonIDs[11] = DUNGEON_OUT_ON_RESCUE }; -const u8 gInvalidItemIDs[0x10] = +// NDS=020C3448 +const u8 gInvalidItemIDs[0x10] = { - ITEM_G_MACHINE_6, - ITEM_G_MACHINE_7, - ITEM_G_MACHINE_8, - ITEM_TM_SPIN_SLASH, - ITEM_SWITCH_BOX, - ITEM_ALERT_SPECS, - ITEM_POSSESS_ORB, - ITEM_REVIVER_ORB, - ITEM_TM_EXCAVATE, - ITEM_TOSS_ORB, - ITEM_RING_D, - ITEM_RING_E, - ITEM_RING_F, - ITEM_OBSERVER_ORB, - ITEM_BEATUP_ORB, + ITEM_G_MACHINE_6, + ITEM_G_MACHINE_7, + ITEM_G_MACHINE_8, + ITEM_TM_SPIN_SLASH, + ITEM_SWITCH_BOX, + ITEM_ALERT_SPECS, + ITEM_POSSESS_ORB, + ITEM_REVIVER_ORB, + ITEM_TM_EXCAVATE, + ITEM_TOSS_ORB, + ITEM_RING_D, + ITEM_RING_E, + ITEM_RING_F, + ITEM_OBSERVER_ORB, + ITEM_BEATUP_ORB, NUMBER_OF_ITEM_IDS }; diff --git a/src/dungeon.c b/src/dungeon.c index 133d4d790..c11ef3ac7 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -161,12 +161,14 @@ u8 sub_80902C8(u8 dungeon) return gUnknown_81077E8[dungeon]; } +// arm9.bin::0205ECA0 void WriteDungeonLocationBits(DataSerializer* r0, DungeonLocation* src) { WriteBits(r0, &src->id, 7); WriteBits(r0, &src->floor, 7); } +// arm9.bin::0205EC64 void ReadDungeonLocationBits(DataSerializer* r0, DungeonLocation* dst) { dst->id = 0; diff --git a/src/felicity_bank.c b/src/felicity_bank.c index 1724fb33d..582673074 100644 --- a/src/felicity_bank.c +++ b/src/felicity_bank.c @@ -409,22 +409,24 @@ static void sub_8016B48(u8 action) sub_80073E0(sFelicityBankWork->unk64.unk14); } -static void CreateFelicityMoneySavingsHeader(u32 param_1) +// arm9.bin::0201FB54 +static void CreateFelicityMoneySavingsHeader(u32 windowId) { - CallPrepareTextbox_8008C54(param_1); - sub_80073B8(param_1); - PrintStringOnWindow(16, 4, sDisplayMoney, param_1, 0); - sub_8012BC4(96, 4, gTeamInventoryRef->teamMoney, 5, 5, param_1); - PrintStringOnWindow(112, 4, sDisplaySavings, param_1, 0); - sub_8012BC4(200, 4, gTeamInventoryRef->teamSavings, 7, 5, param_1); - sub_80073E0(param_1); + CallPrepareTextbox_8008C54(windowId); + sub_80073B8(windowId); + PrintStringOnWindow(16, 4, sDisplayMoney, windowId, 0); + sub_8012BC4(96, 4, gTeamInventoryRef->teamMoney, 5, 5, windowId); + PrintStringOnWindow(112, 4, sDisplaySavings, windowId, 0); + sub_8012BC4(200, 4, gTeamInventoryRef->teamSavings, 7, 5, windowId); + sub_80073E0(windowId); } -void DrawTeamMoneyBox(u32 param_1) +// arm9.bin::0201FAE8 +void DrawTeamMoneyBox(u32 windowId) { - CallPrepareTextbox_8008C54(param_1); - sub_80073B8(param_1); - PrintStringOnWindow(6, 0, sMoney, param_1, 0); - sub_8012BC4(42, 12, gTeamInventoryRef->teamMoney, 5, 5, param_1); - sub_80073E0(param_1); + CallPrepareTextbox_8008C54(windowId); + sub_80073B8(windowId); + PrintStringOnWindow(6, 0, sMoney, windowId, 0); + sub_8012BC4(42, 12, gTeamInventoryRef->teamMoney, 5, 5, windowId); + sub_80073E0(windowId); } diff --git a/src/input.c b/src/input.c index fcd037b06..62932bb15 100644 --- a/src/input.c +++ b/src/input.c @@ -5,13 +5,13 @@ #define JUNK_INIT 0x4A14C1 #define JUNK_UPDATE 0x54A1C41 -EWRAM_DATA Inputs gRealInputs = {0}; // GBA=20255F0 | NDS=20F5CC0 -static EWRAM_DATA UnusedInputStruct sUnusedInputsRelated = {0}; // GBA=2025600 | NDS=020F5CD0 -static EWRAM_DATA u32 sUnusedScrambledInputJunk[3] = {0}; // GBA=202562C | NDS=020F5C88 -static EWRAM_DATA Inputs sBufferedInputs = {0}; // GBA=2025638 | NDS=020F5C90 -static EWRAM_DATA Inputs sCurrentInputs = {0}; // GBA=2025648 | NDS=020F5CB0 -static EWRAM_DATA Inputs sPrevInputs = {0}; // GBA=2025658 | NDS=020F5CA0 -static EWRAM_DATA InputTimers sInputTimers = {0}; // GBA=2025668 | NDS=020F5C8C +EWRAM_DATA Inputs gRealInputs = {0}; // R=20255F0 | B=20F5CC0 +static EWRAM_DATA UnusedInputStruct sUnusedInputsRelated = {0}; // R=2025600 | B=020F5CD0 +static EWRAM_DATA u32 sUnusedScrambledInputJunk[3] = {0}; // R=202562C | B=020F5C88 +static EWRAM_DATA Inputs sBufferedInputs = {0}; // R=2025638 | B=020F5C90 +static EWRAM_DATA Inputs sCurrentInputs = {0}; // R=2025648 | B=020F5CB0 +static EWRAM_DATA Inputs sPrevInputs = {0}; // R=2025658 | B=020F5CA0 +static EWRAM_DATA InputTimers sInputTimers = {0}; // R=2025668 | B=020F5C8C // arm9.bin::0200754C void InitInput(void) diff --git a/src/items.c b/src/items.c index 55bd9c62c..89e887a17 100644 --- a/src/items.c +++ b/src/items.c @@ -24,11 +24,17 @@ extern u32 gUnknown_81097E8[4]; // some sort of lookup table (16, 18, 20, 22) extern u32 gUnknown_81097F8[4]; // some sort of lookup table (17, 19, 21, 23) extern u8 gUnknown_8108F64[0x3f][32]; // some sort of bit lookup table extern u8 gInvalidItemIDs[0x10]; +extern const u8 gUnknown_8109770[]; +extern const u8 gUnknown_8109778[]; +extern const u8 gUnknown_810977C[]; +extern const u8 gUnknown_8109784[]; +extern const u8 gUnknown_810978C[]; +extern const u16* gUnknown_8108E58[]; -EWRAM_DATA OpenedFile *gItemParametersFile = {0}; -EWRAM_DATA ItemDataEntry *gItemParametersData = {0}; -EWRAM_DATA TeamInventory gTeamInventory = {0}; -EWRAM_INIT TeamInventory *gTeamInventoryRef = {NULL}; +EWRAM_DATA OpenedFile *gItemParametersFile = {NULL}; +EWRAM_DATA ItemDataEntry *gItemParametersData = {NULL}; // NDS=0213BEF0 +EWRAM_DATA TeamInventory gTeamInventory = {0}; // NDS=0213BEF8 +EWRAM_INIT TeamInventory *gTeamInventoryRef = {NULL}; // NDS=020EAF98 extern void SortKecleonShopInventory(); bool8 AddKecleonWareItem(u8); @@ -37,40 +43,40 @@ bool8 AddKecleonWareItem(u8); static void sub_8090F58(u8 *, u8 *, Item *, const unkStruct_8090F58 *); +// arm9.bin::020610C0 void LoadItemParameters(void) { - gTeamInventoryRef = &gTeamInventory; - gItemParametersFile = OpenFileAndGetFileDataPtr(gItemParaFileName,&gSystemFileArchive); - gItemParametersData = (ItemDataEntry *) gItemParametersFile->data; + gTeamInventoryRef = &gTeamInventory; + gItemParametersFile = OpenFileAndGetFileDataPtr(gItemParaFileName, &gSystemFileArchive); + gItemParametersData = (ItemDataEntry *) gItemParametersFile->data; + // More in NDS including loading to vram and UnusedGetSir0Ptr() } +// arm9.bin::020610b4 TeamInventory *GetMoneyItemsInfo(void) { return &gTeamInventory; } +// arm9.bin::02061034 void InitializeMoneyItems(void) { - s32 i; + s32 i; - for(i = 0; i < INVENTORY_SIZE; i++) - { - gTeamInventoryRef->teamItems[i].flags = 0; - } + for (i = 0; i < INVENTORY_SIZE; i++) + gTeamInventoryRef->teamItems[i].flags = 0; - for(i = 0; i < STORAGE_SIZE; i++) - { - gTeamInventoryRef->teamStorage[i] = 0; - } + for (i = 0; i < STORAGE_SIZE; i++) + gTeamInventoryRef->teamStorage[i] = 0; - for(i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS; i++) - { - InitKecleonShopItem(i); - } - gTeamInventoryRef->teamMoney = 0; - gTeamInventoryRef->teamSavings = 0; + for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS; i++) + InitKecleonShopItem(i); + + gTeamInventoryRef->teamMoney = 0; + gTeamInventoryRef->teamSavings = 0; } +// arm9.bin::02060FE4 s32 GetNumberOfFilledInventorySlots(void) { s32 i; @@ -86,6 +92,7 @@ s32 GetNumberOfFilledInventorySlots(void) return count; } +// arm9.bin::02060FB0 bool8 IsThrowableItem(u8 id) { if ((GetItemCategory(id) != CATEGORY_THROWN_LINE) && (GetItemCategory(id) != CATEGORY_THROWN_ARC)) @@ -94,6 +101,7 @@ bool8 IsThrowableItem(u8 id) return TRUE; } +// arm9.bin::02060F04 void ItemIdToSlot(Item *slot, u8 id, u8 makeSticky) { if (id != ITEM_NOTHING) { @@ -122,6 +130,7 @@ void ItemIdToSlot(Item *slot, u8 id, u8 makeSticky) } } +// arm9.bin::02060E80 void xxx_init_helditem_8090B08(BulkItem *held, u8 id) { u32 uVar2; @@ -145,6 +154,7 @@ void xxx_init_helditem_8090B08(BulkItem *held, u8 id) } } +// arm9.bin::02060DF0 void HeldItemToSlot(Item *slot, BulkItem *held) { u8 is_throwable; @@ -169,117 +179,110 @@ void HeldItemToSlot(Item *slot, BulkItem *held) } } -void SlotToHeldItem(BulkItem *held,Item *slot) +// arm9.bin::02060DC0 +void SlotToHeldItem(BulkItem *held, Item *slot) { - if ((slot->flags & ITEM_FLAG_EXISTS) != 0) { - held->id = slot->id; - held->quantity = slot->quantity; - } - else { - held->id = ITEM_NOTHING; - } + if ((slot->flags & ITEM_FLAG_EXISTS) != 0) { + held->id = slot->id; + held->quantity = slot->quantity; + } + else + held->id = ITEM_NOTHING; } +// arm9.bin::02060DA8 u8 GetItemCategory(u8 index) { return gItemParametersData[index].category; } +// arm9.bin::02060D44 s32 GetStackBuyValue(Item *param_1) { - if (param_1->id == ITEM_POKE) { - return GetMoneyValue(param_1); - } - else { - if (IsThrowableItem(param_1->id)) { - return gItemParametersData[param_1->id].buyPrice * param_1->quantity; - } - else { - return gItemParametersData[param_1->id].buyPrice; - } - } + if (param_1->id == ITEM_POKE) + return GetMoneyValue(param_1); + else if (IsThrowableItem(param_1->id)) + return gItemParametersData[param_1->id].buyPrice * param_1->quantity; + else + return gItemParametersData[param_1->id].buyPrice; } +// arm9.bin::02060CE0 s32 GetStackSellValue(Item *param_1) { - if (param_1->id == ITEM_POKE) { - return GetMoneyValue(param_1); - } - else { - if (IsThrowableItem(param_1->id)) { - return gItemParametersData[param_1->id].sellPrice * param_1->quantity; - } - else { - return gItemParametersData[param_1->id].sellPrice; - } - } + if (param_1->id == ITEM_POKE) + return GetMoneyValue(param_1); + else if (IsThrowableItem(param_1->id)) + return gItemParametersData[param_1->id].sellPrice * param_1->quantity; + else + return gItemParametersData[param_1->id].sellPrice; } +// arm9.bin::02060C7C s32 GetStackBuyPrice(Item *param_1) { - if (!CanSellItem(param_1->id)) { - return 0; - } - else { - if (IsThrowableItem(param_1->id)) { - return gItemParametersData[param_1->id].buyPrice * param_1->quantity; - } - else { - return gItemParametersData[param_1->id].buyPrice; - } - } + if (!CanSellItem(param_1->id)) + return 0; + else if (IsThrowableItem(param_1->id)) + return gItemParametersData[param_1->id].buyPrice * param_1->quantity; + else + return gItemParametersData[param_1->id].buyPrice; } +// arm9.bin::02060C18 s32 GetStackSellPrice(Item *param_1) { - if (!CanSellItem(param_1->id)) { - return 0; - } - else { - if (IsThrowableItem(param_1->id)) { - return gItemParametersData[param_1->id].sellPrice * param_1->quantity; - } - else { - return gItemParametersData[param_1->id].sellPrice; - } - } + if (!CanSellItem(param_1->id)) + return 0; + else if (IsThrowableItem(param_1->id)) + return gItemParametersData[param_1->id].sellPrice * param_1->quantity; + else + return gItemParametersData[param_1->id].sellPrice; } +// arm9.bin::02060C00 s32 GetItemBuyPrice(u8 id) { return gItemParametersData[id].buyPrice; } +// arm9.bin::02060BE8 s32 GetItemSellPrice(u8 id) { return gItemParametersData[id].sellPrice; } +// arm9.bin::02060BD0 s32 GetItemOrder(u8 id) { return gItemParametersData[id].order; } +// arm9.bin::02060BB8 s32 GetItemPalette(u8 id) { return gItemParametersData[id].palette; } +// arm9.bin::02060BA0 u32 GetItemActionType(u8 id) { return gItemParametersData[id].actionType; } +// arm9.bin::02060B84 u32 GetSpawnAmountRange(u8 id, u32 rangeIndex) { return gItemParametersData[id].spawnAmountRange[rangeIndex]; } +// arm9.bin::02060B6C u8 *GetItemDescription(u8 id) { return gItemParametersData[id].description; } +// arm9.bin::02060B50 bool8 TestItemAIFlag(u8 id, u32 aiFlag) { return gItemParametersData[id].aiFlags[aiFlag]; @@ -288,30 +291,26 @@ bool8 TestItemAIFlag(u8 id, u32 aiFlag) // a2 is always NULL // This func probably appends the quantity of 1, but I haven't checked // If it appends quantity, we can rename the func +// arm9.bin::02060AEC void BufferItemName(u8* dest, u8 id, struct unkStruct_8090F58* a2) { - char acStack104 [80]; - Item unkItem; + u8 acStack104[80]; // 85 in NDS + Item unkItem; - strncpy(acStack104, gItemParametersData[id].name, 80); - ItemIdToSlot(&unkItem, id, 0); - unkItem.quantity = 1; - sub_8090F58(dest, acStack104, &unkItem, a2); + strncpy(acStack104, gItemParametersData[id].name, 80); + ItemIdToSlot(&unkItem, id, 0); + unkItem.quantity = 1; + sub_8090F58(dest, acStack104, &unkItem, a2); } -extern const u8 gUnknown_8109770[]; -extern const u8 gUnknown_8109778[]; -extern const u8 gUnknown_810977C[]; -extern const u8 gUnknown_8109784[]; -extern const u8 gUnknown_810978C[]; - -void sub_8090E14(u8* ext_buffer, Item* slot, const struct unkStruct_8090F58* a3) { +// arm9.bin::020608CC +void sub_8090E14(u8* ext_buffer, Item* slot, const struct unkStruct_8090F58* a3) +{ s32 unk8 = 0; - u8 buffer[80]; + u8 buffer[80]; // 84 in NDS - if (a3) { + if (a3) unk8 = a3->unk8 != 0; - } if (GetItemCategory(slot->id) == CATEGORY_THROWN_LINE) { // I feel like these labels might actually be there... @@ -365,10 +364,12 @@ void sub_8090E14(u8* ext_buffer, Item* slot, const struct unkStruct_8090F58* a3) return; } -static void sub_8090F58(u8* a1, u8 *a2, Item *slot, const struct unkStruct_8090F58* a4) { +// arm9.bin::020607E4 +static void sub_8090F58(u8* a1, u8 *a2, Item *slot, const struct unkStruct_8090F58* a4) +{ u32 unk0; s32 value; - u8 buffer[40]; + u8 buffer[40]; // 44 in NDS if (!a4) { strncpy(a1, a2, 80); @@ -406,6 +407,7 @@ static void sub_8090F58(u8* a1, u8 *a2, Item *slot, const struct unkStruct_8090F } } +// arm9.bin::020606E0 s32 WriteHighDecimal(s32 a1, u8 *strbuf, u8 a3) { s32 i, count; @@ -448,6 +450,7 @@ s32 WriteHighDecimal(s32 a1, u8 *strbuf, u8 a3) return count; } +// arm9.bin::02060614 void FillInventoryGaps() { // fill inventory gaps @@ -481,24 +484,30 @@ void FillInventoryGaps() } } +// arm9.bin::020605A4 s32 FindItemInInventory(u8 id) { - s32 i; - for (i = 0; i < INVENTORY_SIZE; i++) { - if ((gTeamInventoryRef->teamItems[i].flags & ITEM_FLAG_EXISTS) && (gTeamInventoryRef->teamItems[i].id == id)) { - return i; + s32 i; + + for (i = 0; i < INVENTORY_SIZE; i++) { + if ((gTeamInventoryRef->teamItems[i].flags & ITEM_FLAG_EXISTS) + && gTeamInventoryRef->teamItems[i].id == id) { + return i; + } } - } - return -1; + + return -1; } +// arm9.bin::02060540 s32 GetItemCountInInventory(u8 id) { s32 i; s32 count = 0; for (i = 0; i < INVENTORY_SIZE; i++) { - if (ItemExists(&gTeamInventoryRef->teamItems[i]) && gTeamInventoryRef->teamItems[i].id == id) { + if (ItemExists(&gTeamInventoryRef->teamItems[i]) + && gTeamInventoryRef->teamItems[i].id == id) { count++; } } @@ -506,6 +515,7 @@ s32 GetItemCountInInventory(u8 id) return count; } +// arm9.bin::0206049C s32 GetItemPossessionCount(u8 id) { s32 count = GetItemCountInInventory(id); @@ -524,37 +534,44 @@ s32 GetItemPossessionCount(u8 id) return count; } +// arm9.bin::0206042C void ShiftItemsDownFrom(s32 start) { - s32 i, j; - for (i = start, j = start + 1; i < INVENTORY_SIZE - 1; i++, j++) { - gTeamInventoryRef->teamItems[i] = gTeamInventoryRef->teamItems[j]; - } - gTeamInventoryRef->teamItems[INVENTORY_SIZE - 1].id = ITEM_NOTHING; - gTeamInventoryRef->teamItems[INVENTORY_SIZE - 1].flags = 0; + s32 i, j; + + for (i = start, j = start + 1; i < INVENTORY_SIZE - 1; i++, j++) + gTeamInventoryRef->teamItems[i] = gTeamInventoryRef->teamItems[j]; + + gTeamInventoryRef->teamItems[INVENTORY_SIZE - 1].id = ITEM_NOTHING; + gTeamInventoryRef->teamItems[INVENTORY_SIZE - 1].flags = 0; } +// arm9.bin::02060400 void ClearItemSlotAt(u32 index) { - gTeamInventoryRef->teamItems[index].id = ITEM_NOTHING; - gTeamInventoryRef->teamItems[index].flags = 0; + gTeamInventoryRef->teamItems[index].id = ITEM_NOTHING; + gTeamInventoryRef->teamItems[index].flags = 0; } +// arm9.bin::020603D4 bool8 sub_809124C(u8 id, u8 param_3) { - Item temp; - ItemIdToSlot(&temp, id, param_3); - return AddItemToInventory(&temp); + Item temp; + + ItemIdToSlot(&temp, id, param_3); + return AddItemToInventory(&temp); } +// arm9.bin::020603B0 bool8 AddHeldItemToInventory(BulkItem* slot) { - Item temp; + Item temp; - HeldItemToSlot(&temp, slot); - return AddItemToInventory(&temp); + HeldItemToSlot(&temp, slot); + return AddItemToInventory(&temp); } +// arm9.bin::02060330 bool8 AddItemToInventory(const Item* slot) { s32 i; @@ -569,6 +586,7 @@ bool8 AddItemToInventory(const Item* slot) return TRUE; } +// arm9.bin::02060178 void ConvertMoneyItemToMoney(void) { s32 i, j; @@ -606,167 +624,167 @@ void ConvertMoneyItemToMoney(void) FillInventoryGaps(); } +// arm9.bin::02060134 void AddToTeamMoney(s32 amount) { - s32 clamped_money; - gTeamInventoryRef->teamMoney += amount; + s32 clamped_money; - // clamp money - clamped_money = MAX_TEAM_MONEY; - if (gTeamInventoryRef->teamMoney <= MAX_TEAM_MONEY) { - if (gTeamInventoryRef->teamMoney >= 0) { - return; + gTeamInventoryRef->teamMoney += amount; + + // clamp money + clamped_money = MAX_TEAM_MONEY; + + if (gTeamInventoryRef->teamMoney <= MAX_TEAM_MONEY) { + if (gTeamInventoryRef->teamMoney >= 0) + return; + + clamped_money = 0; } - clamped_money = 0; - } - gTeamInventoryRef->teamMoney = clamped_money; + + gTeamInventoryRef->teamMoney = clamped_money; } +// arm9.bin::0206011C u16 GetItemMoveID(u8 index) { - return gItemParametersData[index].moveID; + return gItemParametersData[index].moveID; } -u32 sub_80913E0(Item* slot, u32 a2, STATUSTEXTS(statuses)) +// arm9.bin::0205FFA0 +u32 sub_80913E0(Item* slot, u32 windowId, STATUSTEXTS(statuses)) { - u8 buffer88[88]; // some struct + u8 buffer88[88]; // some struct - GetItemDescription(slot->id); - BufferItemName(buffer88, slot->id, NULL); - if (slot->id == ITEM_TM_USED_TM) { - // empty TM - BufferItemName(gFormatBuffer_Items[0], (u8)(slot->quantity + 125), NULL); - } - sub_80073B8(a2); - PrintFormattedStringOnWindow(16, 0, buffer88, a2, 0); + GetItemDescription(slot->id); + BufferItemName(buffer88, slot->id, NULL); - PrintFormattedStringOnWindow(8, 24, GetItemDescription(slot->id), a2, 0); - if (GetItemCategory(slot->id) == CATEGORY_TMS_HMS) { - Move *buffer8 = (Move*) (buffer88 + 80); // field in struct - u16 move = GetItemMoveID(slot->id); - u8 moves_data; - const u8* typestring; - u32 result; + if (slot->id == ITEM_TM_USED_TM) { + // empty TM + BufferItemName(gFormatBuffer_Items[0], (u8)(slot->quantity + 125), NULL); + } - InitPokemonMove(buffer8, move); - AddDoubleUnderScoreHighlight(a2, 4, 82, 200, COLOR_WHITE_2); - PrintFormattedStringOnWindow(4, 84, gTextType, a2, 0); - moves_data = GetMoveType(buffer8); - typestring = GetUnformattedTypeString(moves_data); - PrintFormattedStringOnWindow(64, 84, typestring, a2, 0); - result = GetMoveBasePP(buffer8); - gFormatArgs[0] = result; - PrintFormattedStringOnWindow(128, 84, gText_PP_Value0, a2, 0); - } + sub_80073B8(windowId); + PrintFormattedStringOnWindow(16, 0, buffer88, windowId, 0); + PrintFormattedStringOnWindow(8, 24, GetItemDescription(slot->id), windowId, 0); - sub_80073E0(a2); - return PrepareStatusStringArrays(GetItemDescription(slot->id), statuses); + if (GetItemCategory(slot->id) == CATEGORY_TMS_HMS) { + Move *buffer8 = (Move*) (buffer88 + 80); // field in struct + u16 move = GetItemMoveID(slot->id); + u8 moves_data; + const u8* typestring; + u32 result; + + InitPokemonMove(buffer8, move); + AddDoubleUnderScoreHighlight(windowId, 4, 82, 200, COLOR_WHITE_2); + PrintFormattedStringOnWindow(4, 84, gTextType, windowId, 0); + moves_data = GetMoveType(buffer8); + typestring = GetUnformattedTypeString(moves_data); + PrintFormattedStringOnWindow(64, 84, typestring, windowId, 0); + result = GetMoveBasePP(buffer8); + gFormatArgs[0] = result; + PrintFormattedStringOnWindow(128, 84, gText_PP_Value0, windowId, 0); + } + + sub_80073E0(windowId); + return PrepareStatusStringArrays(GetItemDescription(slot->id), statuses); } +// arm9.bin::0205FF28 bool8 CanSellItem(u32 id) { - u8 id_; - id = (u8)id; - id_ = id; + u8 id_; + id = (u8)id; + id_ = id; - if (id != ITEM_NOTHING - && id != ITEM_POKE - && id != ITEM_ROCK_PART - && id != ITEM_ICE_PART - && id != ITEM_STEEL_PART - && id != ITEM_MUSIC_BOX - && GetItemSellPrice(id_) - && GetItemBuyPrice(id_)) - return TRUE; + if (id != ITEM_NOTHING + && id != ITEM_POKE + && id != ITEM_ROCK_PART + && id != ITEM_ICE_PART + && id != ITEM_STEEL_PART + && id != ITEM_MUSIC_BOX + && GetItemSellPrice(id_) + && GetItemBuyPrice(id_)) + return TRUE; return FALSE; } +// arm9.bin::0205FEFC bool8 IsNotMoneyOrUsedTMItem(u8 id) { - if (id == ITEM_NOTHING) { - return FALSE; - } - else if (id == ITEM_POKE) { - return FALSE; - } - else if (id == ITEM_TM_USED_TM) { - return FALSE; - } - return TRUE; + if (id == ITEM_NOTHING) + return FALSE; + if (id == ITEM_POKE) + return FALSE; + if (id == ITEM_TM_USED_TM) + return FALSE; + return TRUE; } +// arm9.bin::0205FEAC bool8 IsNotSpecialItem(u8 id) { - if (id == ITEM_NOTHING) { - return FALSE; - } - else if (id == ITEM_POKE) { - return FALSE; - } - else if (id == ITEM_ROCK_PART) { - return FALSE; - } - else if (id == ITEM_ICE_PART) { - return FALSE; - } - else if (id == ITEM_STEEL_PART) { - return FALSE; - } - else if (id == ITEM_MUSIC_BOX) { - return FALSE; - } - return TRUE; + if (id == ITEM_NOTHING) + return FALSE; + if (id == ITEM_POKE) + return FALSE; + if (id == ITEM_ROCK_PART) + return FALSE; + if (id == ITEM_ICE_PART) + return FALSE; + if (id == ITEM_STEEL_PART) + return FALSE; + if (id == ITEM_MUSIC_BOX) + return FALSE; + return TRUE; } +// arm9.bin::0205FE78 bool8 IsEdibleItem(u8 id) { - if (!((GetItemCategory(id) == CATEGORY_BERRIES_SEEDS_VITAMINS) || (GetItemCategory(id) == CATEGORY_FOOD_GUMMIES))) { - return FALSE; - } - return TRUE; + if (!(GetItemCategory(id) == CATEGORY_BERRIES_SEEDS_VITAMINS + || GetItemCategory(id) == CATEGORY_FOOD_GUMMIES)) { + return FALSE; + } + return TRUE; } +// arm9.bin::0205FE10 bool8 IsHMItem(u8 id) { - if (id == ITEM_HM_CUT) { - return TRUE; - } - else if (id == ITEM_HM_FLY) { - return TRUE; - } - else if (id == ITEM_HM_SURF) { - return TRUE; - } - else if (id == ITEM_HM_STRENGTH) { - return TRUE; - } - else if (id == ITEM_HM_FLASH) { - return TRUE; - } - else if (id == ITEM_HM_ROCK_SMASH) { - return TRUE; - } - else if (id == ITEM_HM_WATERFALL) { - return TRUE; - } - else if (id == ITEM_HM_DIVE) { - return TRUE; - } - return FALSE; + if (id == ITEM_HM_CUT) + return TRUE; + if (id == ITEM_HM_FLY) + return TRUE; + if (id == ITEM_HM_SURF) + return TRUE; + if (id == ITEM_HM_STRENGTH) + return TRUE; + if (id == ITEM_HM_FLASH) + return TRUE; + if (id == ITEM_HM_ROCK_SMASH) + return TRUE; + if (id == ITEM_HM_WATERFALL) + return TRUE; + if (id == ITEM_HM_DIVE) + return TRUE; + return FALSE; } +// arm9.bin::0205FDFC u32 GetMoneyValue(Item* slot) { - return gUnknown_810A3F0[slot->quantity]; + return gUnknown_810A3F0[slot->quantity]; } +// arm9.bin::0205FDE8 u32 GetMoneyValueHeld(BulkItem* slot) { - // potentially different slot type (used for held item) - return gUnknown_810A3F0[slot->quantity]; + // potentially different slot type (used for held item) + return gUnknown_810A3F0[slot->quantity]; } +// arm9.bin::0205FC30 void GetGummiItemStatBoost(PokemonStruct1* pokemon, u8 id, bool8 checkBoostFlags, Gummi *gummi) { // item stat buff? @@ -861,337 +879,383 @@ void GetGummiItemStatBoost(PokemonStruct1* pokemon, u8 id, bool8 checkBoostFlags } } +// arm9.bin::0205FC10 bool8 IsGummiItem(u8 id) { - if (id < ITEM_WHITE_GUMMI) { - return FALSE; - } - if (id > ITEM_SILVER_GUMMI) { - return FALSE; - } - return TRUE; + if (id < ITEM_WHITE_GUMMI) + return FALSE; + if (id > ITEM_SILVER_GUMMI) + return FALSE; + return TRUE; } +// arm9.bin::0205FBA4 bool8 HasGummiItem(void) { s32 i; + for (i = 0; i < INVENTORY_SIZE; i++) { - if (ItemExists(&gTeamInventoryRef->teamItems[i]) && IsGummiItem(gTeamInventoryRef->teamItems[i].id)) { + if (ItemExists(&gTeamInventoryRef->teamItems[i]) + && IsGummiItem(gTeamInventoryRef->teamItems[i].id)) { return TRUE; } } + return FALSE; } +// arm9.bin::0205FB18 void MoveToStorage(Item* slot) { - if (IsThrowableItem(slot->id)) { - gTeamInventoryRef->teamStorage[slot->id] += slot->quantity; - } - else { - gTeamInventoryRef->teamStorage[slot->id]++; - } + if (IsThrowableItem(slot->id)) + gTeamInventoryRef->teamStorage[slot->id] += slot->quantity; + else + gTeamInventoryRef->teamStorage[slot->id]++; - if (gTeamInventoryRef->teamStorage[slot->id] > 999) { - gTeamInventoryRef->teamStorage[slot->id] = 999; - } + if (gTeamInventoryRef->teamStorage[slot->id] > 999) + gTeamInventoryRef->teamStorage[slot->id] = 999; } +// arm9.bin::0205FAE4 s32 CountKecleonShopItems(void) { - s32 i; - s32 counter = 0; - for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS; i++) { - if (gTeamInventoryRef->kecleonShopItems[i].id) { - counter++; + s32 i; + s32 counter = 0; + + for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS; i++) { + if (gTeamInventoryRef->kecleonShopItems[i].id) + counter++; } - } - return counter; + + return counter; } +// arm9.bin::0205FAC0 void InitKecleonShopItem(u8 index) { - BulkItem* shopItem; + BulkItem* shopItem; - shopItem = &gTeamInventoryRef->kecleonShopItems[index]; - shopItem->id = ITEM_NOTHING; - shopItem->quantity = 0; + shopItem = &gTeamInventoryRef->kecleonShopItems[index]; + shopItem->id = ITEM_NOTHING; + shopItem->quantity = 0; } +// arm9.bin::0205FAA8 BulkItem* GetKecleonShopItem(u8 i) { - return &gTeamInventoryRef->kecleonShopItems[i]; + return &gTeamInventoryRef->kecleonShopItems[i]; } +// arm9.bin::0205FA20 void FillKecleonShopGaps(void) { - s32 slot_checking = 0; - s32 last_filled = 0; + s32 slot_checking = 0; + s32 last_filled = 0; - do { - while (slot_checking < MAX_KECLEON_ITEM_SHOP_ITEMS) { - if (gTeamInventoryRef->kecleonShopItems[slot_checking].id) { - break; - } - // find next empty slot - slot_checking++; - } + do { + while (slot_checking < MAX_KECLEON_ITEM_SHOP_ITEMS) { + if (gTeamInventoryRef->kecleonShopItems[slot_checking].id) + break; - if (slot_checking == MAX_KECLEON_ITEM_SHOP_ITEMS) { - break; - } + // find next empty slot + slot_checking++; + } - if (slot_checking > last_filled) { - // shift it down - gTeamInventoryRef->kecleonShopItems[last_filled] = gTeamInventoryRef->kecleonShopItems[slot_checking]; - } - slot_checking++; - last_filled++; - } while (1); + if (slot_checking == MAX_KECLEON_ITEM_SHOP_ITEMS) + break; - // clear out the rest of the slots - for (; last_filled < MAX_KECLEON_ITEM_SHOP_ITEMS; last_filled++) { - InitKecleonShopItem(last_filled); - } + if (slot_checking > last_filled) { + // shift it down + gTeamInventoryRef->kecleonShopItems[last_filled] = gTeamInventoryRef->kecleonShopItems[slot_checking]; + } + slot_checking++; + last_filled++; + } while (TRUE); + + // clear out the rest of the slots + for (; last_filled < MAX_KECLEON_ITEM_SHOP_ITEMS; last_filled++) + InitKecleonShopItem(last_filled); } -void SortKecleonShopInventory(void) { - s32 i; +// arm9.bin::0205F94C +void SortKecleonShopInventory(void) +{ + s32 i; - for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS - 1; i++) { - s32 j; - for (j = i + 1; j < MAX_KECLEON_ITEM_SHOP_ITEMS; j++) { - s32 order_i = GetItemOrder(gTeamInventoryRef->kecleonShopItems[i].id); - s32 order_j = GetItemOrder(gTeamInventoryRef->kecleonShopItems[j].id); - if (order_i > order_j || (order_i == order_j && gTeamInventoryRef->kecleonShopItems[i].quantity < gTeamInventoryRef->kecleonShopItems[j].quantity)) { - BulkItem str_i = gTeamInventoryRef->kecleonShopItems[i]; - gTeamInventoryRef->kecleonShopItems[i] = gTeamInventoryRef->kecleonShopItems[j]; - gTeamInventoryRef->kecleonShopItems[j] = str_i; - } + for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS - 1; i++) { + s32 j; + + for (j = i + 1; j < MAX_KECLEON_ITEM_SHOP_ITEMS; j++) { + s32 order_i = GetItemOrder(gTeamInventoryRef->kecleonShopItems[i].id); + s32 order_j = GetItemOrder(gTeamInventoryRef->kecleonShopItems[j].id); + + if (order_i > order_j || (order_i == order_j && gTeamInventoryRef->kecleonShopItems[i].quantity < gTeamInventoryRef->kecleonShopItems[j].quantity)) { + BulkItem str_i = gTeamInventoryRef->kecleonShopItems[i]; + gTeamInventoryRef->kecleonShopItems[i] = gTeamInventoryRef->kecleonShopItems[j]; + gTeamInventoryRef->kecleonShopItems[j] = str_i; + } + } } - } } -void ChooseKecleonShopInventory(u8 index) { - u32 data[4]; - s32 i; +// arm9.bin::0205F8B8 +void ChooseKecleonShopInventory(u8 index) +{ + u32 data[4]; + s32 i; - memcpy(data, gUnknown_81097E8, 4 * sizeof(u32)); - for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS; i++) { - InitKecleonShopItem(i); - } - for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS; i++) { - s32 rand_1 = RandInt(9999); - s32 rand_2 = RandInt(9999); - AddKecleonShopItem(sub_8091E94(data[index], rand_1, rand_2)); - } - SortKecleonShopInventory(); - ChooseKecleonWareInventory(index); -} + memcpy(data, gUnknown_81097E8, 4 * sizeof(u32)); -bool8 AddKecleonShopItem(u8 itemIndex) { - BulkItem held; - s32 i; + for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS; i++) + InitKecleonShopItem(i); - xxx_init_helditem_8090B08(&held, itemIndex); // initialize - for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS; i++) { - if (!gTeamInventoryRef->kecleonShopItems[i].id) { - gTeamInventoryRef->kecleonShopItems[i] = held; - return FALSE; + for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS; i++) { + s32 rand_1 = RandInt(9999); + s32 rand_2 = RandInt(9999); + + AddKecleonShopItem(sub_8091E94(data[index], rand_1, rand_2)); } - } - return TRUE; + + SortKecleonShopInventory(); + ChooseKecleonWareInventory(index); } -u32 CountKecleonWareItems(void) { - s32 i; - u32 count = 0; - for (i = 0; i < MAX_KECLEON_WARE_SHOP_ITEMS; i++) { - if (gTeamInventoryRef->kecleonWareItems[i].id) { - count++; +// arm9.bin::0205F850 +bool8 AddKecleonShopItem(u8 itemIndex) +{ + BulkItem held; + s32 i; + + xxx_init_helditem_8090B08(&held, itemIndex); // initialize + + for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS; i++) { + if (!gTeamInventoryRef->kecleonShopItems[i].id) { + gTeamInventoryRef->kecleonShopItems[i] = held; + return FALSE; + } } - } - return count; + + return TRUE; } -void InitKecleonWareItem(u8 index) { - BulkItem* wareItem = &gTeamInventoryRef->kecleonWareItems[index]; - wareItem->id = ITEM_NOTHING; - wareItem->quantity = 0; +// arm9.bin::0205f81C +u32 CountKecleonWareItems(void) +{ + s32 i; + u32 count = 0; + + for (i = 0; i < MAX_KECLEON_WARE_SHOP_ITEMS; i++) { + if (gTeamInventoryRef->kecleonWareItems[i].id) + count++; + } + + return count; } -BulkItem* GetKecleonWareItem(u8 index) { +// arm9.bin::0205F7F8 +void InitKecleonWareItem(u8 index) +{ + BulkItem* wareItem = &gTeamInventoryRef->kecleonWareItems[index]; + wareItem->id = ITEM_NOTHING; + wareItem->quantity = 0; +} + +// arm9.bin::0205F7E0 +BulkItem* GetKecleonWareItem(u8 index) +{ return &gTeamInventoryRef->kecleonWareItems[index]; } -void FillKecleonWareGaps(void) { - s32 slot_checking = 0; - s32 last_filled = 0; - - do { - while (slot_checking < MAX_KECLEON_WARE_SHOP_ITEMS) { - if (gTeamInventoryRef->kecleonWareItems[slot_checking].id != ITEM_NOTHING) { - break; - } - slot_checking++; - } - - if (slot_checking == MAX_KECLEON_WARE_SHOP_ITEMS) { - break; - } - - if (slot_checking > last_filled) { - // shift it down - gTeamInventoryRef->kecleonWareItems[last_filled] = gTeamInventoryRef->kecleonWareItems[slot_checking]; - } - slot_checking++; - last_filled++; - } while (1); - - // clear out the rest of the slots - for (; last_filled < MAX_KECLEON_WARE_SHOP_ITEMS; last_filled++) { - InitKecleonWareItem(last_filled); - } -} - -void SortKecleonWareInventory(void) { - s32 i; - - for (i = 0; i < MAX_KECLEON_WARE_SHOP_ITEMS - 1; i++) { - s32 j; - for (j = i + 1; j < MAX_KECLEON_WARE_SHOP_ITEMS; j++) { - s32 order_i = GetItemOrder(gTeamInventoryRef->kecleonWareItems[i].id); - s32 order_j = GetItemOrder(gTeamInventoryRef->kecleonWareItems[j].id); - if (order_i > order_j || (order_i == order_j && gTeamInventoryRef->kecleonWareItems[i].quantity < gTeamInventoryRef->kecleonWareItems[j].quantity)) { - BulkItem str_i = gTeamInventoryRef->kecleonWareItems[i]; - gTeamInventoryRef->kecleonWareItems[i] = gTeamInventoryRef->kecleonWareItems[j]; - gTeamInventoryRef->kecleonWareItems[j] = str_i; - } - } - } -} - -void ChooseKecleonWareInventory(u8 index) { - u32 data[MAX_KECLEON_WARE_SHOP_ITEMS]; - s32 i; - - memcpy(data, gUnknown_81097F8, 4 * sizeof(u32)); - for (i = 0; i < MAX_KECLEON_WARE_SHOP_ITEMS; i++) { - InitKecleonWareItem(i); - } - for (i = 0; i < MAX_KECLEON_WARE_SHOP_ITEMS; i++) { - s32 rand_1 = RandInt(9999); - s32 rand_2 = RandInt(9999); - AddKecleonWareItem(sub_8091E94(data[index], rand_1, rand_2)); - } - SortKecleonWareInventory(); -} - -bool8 AddKecleonWareItem(u8 itemIndex) { - BulkItem held; - s32 i; - - xxx_init_helditem_8090B08(&held, itemIndex); // initialize - for (i = 0; i < MAX_KECLEON_WARE_SHOP_ITEMS; i++) { - if (!gTeamInventoryRef->kecleonWareItems[i].id) { - gTeamInventoryRef->kecleonWareItems[i] = held; - return FALSE; - } - } - return TRUE; -} - -s32 SaveTeamInventory(u8* unk0, u32 size) +// arm9.bin::0205F758 +void FillKecleonWareGaps(void) { - DataSerializer unk; - s32 i; + s32 slot_checking = 0; + s32 last_filled = 0; - InitBitWriter(&unk, unk0, size); - for (i = 0; i < INVENTORY_SIZE; i++) { - WriteItemSlotBits(&unk, &gTeamInventoryRef->teamItems[i]); - } - for (i = 0; i < STORAGE_SIZE; i++) { - WriteBits(&unk, &gTeamInventoryRef->teamStorage[i], 10); - } - for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS; i++) { - WriteHeldItemBits(&unk, &gTeamInventoryRef->kecleonShopItems[i]); - } - for (i = 0; i < MAX_KECLEON_WARE_SHOP_ITEMS; i++) { - WriteHeldItemBits(&unk, &gTeamInventoryRef->kecleonWareItems[i]); - } - WriteBits(&unk, &gTeamInventoryRef->teamMoney, 24); - WriteBits(&unk, &gTeamInventoryRef->teamSavings, 24); + do { + while (slot_checking < MAX_KECLEON_WARE_SHOP_ITEMS) { + if (gTeamInventoryRef->kecleonWareItems[slot_checking].id != ITEM_NOTHING) + break; - FinishBitSerializer(&unk); - return unk.count; + slot_checking++; + } + + if (slot_checking == MAX_KECLEON_WARE_SHOP_ITEMS) + break; + + if (slot_checking > last_filled) { + // shift it down + gTeamInventoryRef->kecleonWareItems[last_filled] = gTeamInventoryRef->kecleonWareItems[slot_checking]; + } + slot_checking++; + last_filled++; + } while (TRUE); + + // clear out the rest of the slots + for (; last_filled < MAX_KECLEON_WARE_SHOP_ITEMS; last_filled++) + InitKecleonWareItem(last_filled); } -s32 RestoreTeamInventory(u8 *unk0, u32 size) +// arm9.bin::0205F684 +void SortKecleonWareInventory(void) { - DataSerializer unk; s32 i; - InitBitReader(&unk, unk0, size); - for (i = 0; i < INVENTORY_SIZE; i++) { - ReadItemSlotBits(&unk, &gTeamInventoryRef->teamItems[i]); - } - for (i = 0; i < STORAGE_SIZE; i++) { - ReadBits(&unk, &gTeamInventoryRef->teamStorage[i], 10); - } - for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS; i++) { - ReadHeldItemBits(&unk, &gTeamInventoryRef->kecleonShopItems[i]); - } - for (i = 0; i < MAX_KECLEON_WARE_SHOP_ITEMS; i++) { - ReadHeldItemBits(&unk, &gTeamInventoryRef->kecleonWareItems[i]); - } - ReadBits(&unk, &gTeamInventoryRef->teamMoney, 24); - ReadBits(&unk, &gTeamInventoryRef->teamSavings, 24); + for (i = 0; i < MAX_KECLEON_WARE_SHOP_ITEMS - 1; i++) { + s32 j; - FinishBitSerializer(&unk); - return unk.count; + for (j = i + 1; j < MAX_KECLEON_WARE_SHOP_ITEMS; j++) { + s32 order_i = GetItemOrder(gTeamInventoryRef->kecleonWareItems[i].id); + s32 order_j = GetItemOrder(gTeamInventoryRef->kecleonWareItems[j].id); + + if (order_i > order_j || (order_i == order_j && gTeamInventoryRef->kecleonWareItems[i].quantity < gTeamInventoryRef->kecleonWareItems[j].quantity)) { + BulkItem str_i = gTeamInventoryRef->kecleonWareItems[i]; + gTeamInventoryRef->kecleonWareItems[i] = gTeamInventoryRef->kecleonWareItems[j]; + gTeamInventoryRef->kecleonWareItems[j] = str_i; + } + } + } } +// arm9.bin::0205F5F8 +void ChooseKecleonWareInventory(u8 index) +{ + u32 data[MAX_KECLEON_WARE_SHOP_ITEMS]; + s32 i; + + memcpy(data, gUnknown_81097F8, 4 * sizeof(u32)); + + for (i = 0; i < MAX_KECLEON_WARE_SHOP_ITEMS; i++) + InitKecleonWareItem(i); + + for (i = 0; i < MAX_KECLEON_WARE_SHOP_ITEMS; i++) { + s32 rand_1 = RandInt(9999); + s32 rand_2 = RandInt(9999); + + AddKecleonWareItem(sub_8091E94(data[index], rand_1, rand_2)); + } + + SortKecleonWareInventory(); +} + +// arm9.bin::0205F590 +bool8 AddKecleonWareItem(u8 itemIndex) +{ + BulkItem held; + s32 i; + + xxx_init_helditem_8090B08(&held, itemIndex); // initialize + + for (i = 0; i < MAX_KECLEON_WARE_SHOP_ITEMS; i++) { + if (!gTeamInventoryRef->kecleonWareItems[i].id) { + gTeamInventoryRef->kecleonWareItems[i] = held; + return FALSE; + } + } + + return TRUE; +} + +// arm9.bin::0205F474 +s32 SaveTeamInventory(u8* unk0, u32 size) +{ + DataSerializer seri; + s32 i; + + InitBitWriter(&seri, unk0, size); + + for (i = 0; i < INVENTORY_SIZE; i++) + WriteItemSlotBits(&seri, &gTeamInventoryRef->teamItems[i]); + + for (i = 0; i < STORAGE_SIZE; i++) + WriteBits(&seri, &gTeamInventoryRef->teamStorage[i], 10); + + for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS; i++) + WriteHeldItemBits(&seri, &gTeamInventoryRef->kecleonShopItems[i]); + + for (i = 0; i < MAX_KECLEON_WARE_SHOP_ITEMS; i++) + WriteHeldItemBits(&seri, &gTeamInventoryRef->kecleonWareItems[i]); + + WriteBits(&seri, &gTeamInventoryRef->teamMoney, 24); + WriteBits(&seri, &gTeamInventoryRef->teamSavings, 24); + + FinishBitSerializer(&seri); + return seri.count; +} + +// arm9.bin::0205F358 +s32 RestoreTeamInventory(u8 *unk0, u32 size) +{ + DataSerializer seri; + s32 i; + + InitBitReader(&seri, unk0, size); + + for (i = 0; i < INVENTORY_SIZE; i++) + ReadItemSlotBits(&seri, &gTeamInventoryRef->teamItems[i]); + + for (i = 0; i < STORAGE_SIZE; i++) + ReadBits(&seri, &gTeamInventoryRef->teamStorage[i], 10); + + for (i = 0; i < MAX_KECLEON_ITEM_SHOP_ITEMS; i++) + ReadHeldItemBits(&seri, &gTeamInventoryRef->kecleonShopItems[i]); + + for (i = 0; i < MAX_KECLEON_WARE_SHOP_ITEMS; i++) + ReadHeldItemBits(&seri, &gTeamInventoryRef->kecleonWareItems[i]); + + ReadBits(&seri, &gTeamInventoryRef->teamMoney, 24); + ReadBits(&seri, &gTeamInventoryRef->teamSavings, 24); + + FinishBitSerializer(&seri); + return seri.count; +} + +// arm9.bin::0205F328 void ReadHeldItemBits(DataSerializer *a1, BulkItem *item) { - ReadBits(a1, &item->id, 8); - ReadBits(a1, &item->quantity, 7); + ReadBits(a1, &item->id, 8); + ReadBits(a1, &item->quantity, 7); } +// arm9.bin::0205F2F8 void WriteHeldItemBits(DataSerializer *a1, BulkItem *item) { - WriteBits(a1, &item->id, 8); - WriteBits(a1, &item->quantity, 7); + WriteBits(a1, &item->id, 8); + WriteBits(a1, &item->quantity, 7); } +// arm9.bin::0205F2B8 void ReadItemSlotBits(DataSerializer *a1, Item *slot) { - ReadBits(a1, &slot->flags, 8); - ReadBits(a1, &slot->quantity, 7); - ReadBits(a1, &slot->id, 8); + ReadBits(a1, &slot->flags, 8); + ReadBits(a1, &slot->quantity, 7); + ReadBits(a1, &slot->id, 8); } +// arm9.bin::0205F278 void WriteItemSlotBits(DataSerializer *a1, Item *slot) { - WriteBits(a1, &slot->flags, 8); - WriteBits(a1, &slot->quantity, 7); - WriteBits(a1, &slot->id, 8); + WriteBits(a1, &slot->flags, 8); + WriteBits(a1, &slot->quantity, 7); + WriteBits(a1, &slot->id, 8); } -const char *sub_8091E50(u8 index) +#if (GAME_VERSION == VERSION_RED) +UNUSED static const u8 *sub_8091E50(u8 index) { return gUnknown_810AF50[index]; } +#endif +// arm9.bin::0205F240 u8 xxx_bit_lut_lookup_8091E50(u8 i0, u8 i1) { - if (i0 > 0x3e) - return 0; - else + if (i0 > 0x3e) + return 0; return (gUnknown_8108F64[i0][i1 >> 3] >> (i1 & 7)) & 1; } -extern const u16* gUnknown_8108E58[]; - +// arm9.bin::0205F0C8 u8 sub_8091E94(s32 a0, s32 a1, s32 a2) { s32 id, i, arrId; @@ -1249,6 +1313,7 @@ u8 sub_8091E94(s32 a0, s32 a1, s32 a2) return ret; } +// arm9.bin::0205EFAC void ClearAllItems_8091FB4(void) { s32 i; @@ -1277,19 +1342,19 @@ void ClearAllItems_8091FB4(void) } } +// arm9.bin::0205EF6C bool8 IsInvalidItemReward(u8 itemID) { - s32 index; - - if (itemID >= NUMBER_OF_ITEM_IDS) - return TRUE; - else { - index = 0; - while (gInvalidItemIDs[index] != NUMBER_OF_ITEM_IDS){ - if (gInvalidItemIDs[index] == itemID) + if (itemID >= NUMBER_OF_ITEM_IDS) return TRUE; - index++; - }; - return FALSE; - } + else { + s32 index = 0; + + while (gInvalidItemIDs[index] != NUMBER_OF_ITEM_IDS) { + if (gInvalidItemIDs[index] == itemID) + return TRUE; + index++; + } + return FALSE; + } } diff --git a/src/kecleon_bros1.c b/src/kecleon_bros1.c index 1c9f8da32..91f891d89 100644 --- a/src/kecleon_bros1.c +++ b/src/kecleon_bros1.c @@ -1,5 +1,8 @@ #include "global.h" #include "globaldata.h" +#include "structs/menu.h" +#include "structs/str_mon_portrait.h" +#include "structs/str_text.h" #include "code_80118A4.h" #include "code_801B3C0.h" #include "code_8099360.h" @@ -17,7 +20,80 @@ #include "string_format.h" #include "text_1.h" -static EWRAM_INIT KecleonBrosWork1 *sKecleonBrosWork1 = {NULL}; +enum KecleonStoreStates +{ + KECLEON_STORE_INIT = 0, + KECLEON_STORE_MAIN_MENU, + KECLEON_STORE_INFO, + KECLEON_STORE_UNK3, + KECLEON_STORE_EXIT, + KECLEON_STORE_NO_STORE_ITEMS, + KECLEON_STORE_NO_MONEY, + KECLEON_STORE_TOO_MUCH_MONEY, + KECLEON_STORE_NO_ITEMS_TO_SELL, + KECLEON_STORE_NO_ITEMS, + KECLEON_STORE_TOO_MANY_ITEMS, + KECLEON_STORE_UNK11, + KECLEON_STORE_NOT_ENOUGH_MONEY, + KECLEON_STORE_CANT_SELL_ITEM, + KECLEON_STORE_SELL_ITEM_TOO_MUCH_MONEY, + KECLEON_STORE_UNK15, + KECLEON_STORE_BUY_ITEM_MENU, + KECLEON_STORE_BUY_ITEM_RECEIPT, + KECLEON_STORE_UNK18, + KECLEON_STORE_UNK19, + KECLEON_STORE_UNK20, + KECLEON_STORE_BUY_ITEM_INFO, + KECLEON_STORE_BUY_ITEM, + KECLEON_STORE_UNK23, + KECLEON_STORE_SELL_ITEM_MENU, + KECLEON_STORE_SELL_ITEM_RECEIPT, + KECLEON_STORE_UNK26, + KECLEON_STORE_UNK27, + KECLEON_STORE_UNK28, + KECLEON_STORE_SELL_ITEM_INFO, + KECLEON_STORE_SELL_ITEM, + KECLEON_STORE_SELL_ALL_ITEMS, + KECLEON_STORE_SELL_ALL_ITEMS_RECEIPT, +}; + +enum MenuActions +{ + CANCEL_ACTION = 1, + BUY_ACTION, + SELL_ACTION, + SELL_ALL_ACTION, + YES_ACTION, + NO_ACTION, + INFO_ACTION +}; + +// size: R=0x148 | B=0x144 +typedef struct KecleonBrosWork1 +{ + /* 0x0 */ u32 mode; // Corresponds to the enum: KecleonBrosMode + /* 0x4 */ bool8 isKecleonItemShop; // FALSE indicates it is Kecleon TM Shop + /* 0x8 */ u32 currState; + /* 0xC */ u32 fallbackState; + /* 0x10 */ s32 itemSellPrice; + /* 0x14 */ u32 numInventoryItemToSell; + /* 0x18 */ s32 inventoryItemSellPrice; + /* 0x1C */ Item soldItem; + /* 0x20 */ u8 itemShopItemIndex; // TODO: 0x1F + /* 0x21 */ u8 wareShopItemIndex; + /* 0x24 */ u32 soldItemInventoryIndex; + /* 0x28 */ u32 menuAction1; + /* 0x2C */ u32 menuAction2; + /* 0x30 */ u32 menuAction3; + /* 0x34 */ MenuItem menuItems[8]; + /* 0x74 */ u16 unk74[8]; + /* 0x84 */ MenuStruct menu; + /* 0xD4 */ MonPortraitMsg monPortrait; // This seems to start 4 bytes earlier on NDS. I think MenuStruct is shorter + /* 0xE4 */ MonPortraitMsg *monPortraitPtr; + /* 0xE8 */ WindowTemplates unkE8; +} KecleonBrosWork1; + +static EWRAM_INIT KecleonBrosWork1 *sKecleonBrosWork1 = {NULL}; // NDS=020EAD7C #include "data/kecleon_bros1.h" @@ -44,16 +120,7 @@ static void ProceedToKecleonBros1FallbackState(void); static void KecleonCalcSellPriceForAllItems(void); static void SetKecleonPortraitSpriteId(bool32 angrySprite); -enum MenuActions { - CANCEL_ACTION = 1, - BUY_ACTION, - SELL_ACTION, - SELL_ALL_ACTION, - YES_ACTION, - NO_ACTION, - INFO_ACTION -}; - +// arm9.bin::020252B0 bool8 CreateKecleonBros(u32 mode) { u8 *monName; @@ -114,6 +181,7 @@ bool8 CreateKecleonBros(u32 mode) return TRUE; } +// arm9.bin::020251A4 u32 KecleonBrosCallback(void) { switch (sKecleonBrosWork1->currState) { @@ -159,6 +227,7 @@ u32 KecleonBrosCallback(void) return 0; } +// arm9.bin::02025160 void DeleteKecleonBros(void) { if (sKecleonBrosWork1 != NULL) { @@ -168,6 +237,7 @@ void DeleteKecleonBros(void) } } +// arm9.bin::02025138 static void SetKecleonBrosState(u32 newState) { sKecleonBrosWork1->currState = newState; @@ -175,6 +245,7 @@ static void SetKecleonBrosState(u32 newState) UpdateKecleonStoreDialogue(); } +// arm9.bin::02024F44 static void sub_8018D30(void) { s32 i; @@ -215,6 +286,7 @@ static void sub_8018D30(void) ShowWindows(&sKecleonBrosWork1->unkE8, TRUE, TRUE); } +// arm9.bin::02024500 static void UpdateKecleonStoreDialogue(void) { switch (sKecleonBrosWork1->currState) { @@ -337,7 +409,7 @@ static void UpdateKecleonStoreDialogue(void) sub_8090E14(gFormatBuffer_Items[0], &sKecleonBrosWork1->soldItem, 0); gFormatArgs[0] = sKecleonBrosWork1->itemSellPrice; SetKecleonPortraitSpriteId(FALSE); - CreateMenuDialogueBoxAndPortrait(gCommonKecleonBros[sKecleonBrosWork1->mode][KECLEON_DLG_05], 0, 5,sKecleonBrosWork1->menuItems, NULL, 4, 0, sKecleonBrosWork1->monPortraitPtr, 12); + CreateMenuDialogueBoxAndPortrait(gCommonKecleonBros[sKecleonBrosWork1->mode][KECLEON_DLG_05], 0, 5, sKecleonBrosWork1->menuItems, NULL, 4, 0, sKecleonBrosWork1->monPortraitPtr, 12); break; case KECLEON_STORE_BUY_ITEM_RECEIPT: if (CountKecleonItems() == 0) { @@ -421,6 +493,7 @@ static void UpdateKecleonStoreDialogue(void) } } +// arm9.bin::020243AC static void BuildKecleonBrosMainMenu(void) { s32 i; @@ -467,6 +540,7 @@ static void BuildKecleonBrosMainMenu(void) } } +// arm9.bin::020242B0 static void BuildKecleonBrosBuyItemMenu(void) { s32 i; @@ -501,6 +575,7 @@ static void BuildKecleonBrosBuyItemMenu(void) } } +// arm9.bin::020241B4 static void BuildKecleonBrosSellItemMenu(void) { s32 i; @@ -535,6 +610,7 @@ static void BuildKecleonBrosSellItemMenu(void) } } +// arm9.bin::02024150 static void BuildKecleonBrosYesNoMenu(void) { s32 loopMax = 0; @@ -550,6 +626,7 @@ static void BuildKecleonBrosYesNoMenu(void) sKecleonBrosWork1->menuItems[loopMax].menuAction = CANCEL_ACTION; } +// arm9.bin::02023FB8 static void HandleKecleonBrosMainMenu(void) { s32 menuAction; @@ -598,6 +675,7 @@ static void HandleKecleonBrosMainMenu(void) } } +// arm9.bin::02023EEC static void HandleKecleonBrosBuyItemYesNoMenu(void) { s32 menuAction; @@ -629,6 +707,7 @@ static void HandleKecleonBrosBuyItemYesNoMenu(void) } } +// arm9.bin::02023E6C static void HandleKecleonBrosSellItemYesNoMenu(void) { s32 menuAction; @@ -649,6 +728,7 @@ static void HandleKecleonBrosSellItemYesNoMenu(void) } } +// arm9.bin::02023D98 static void HandleKecleonBrosSellAllItemsMenu(void) { s32 slotIndex; @@ -678,6 +758,7 @@ static void HandleKecleonBrosSellAllItemsMenu(void) } } +// arm9.bin::02023BC0 static void sub_80199CC(void) { u32 menuAction; @@ -734,6 +815,7 @@ static void sub_80199CC(void) } } +// arm9.bin::02023A90 static void sub_8019B08(void) { switch (sub_801A6E8(TRUE)) { @@ -763,6 +845,7 @@ static void sub_8019B08(void) } } +// arm9.bin::02023990 static void HandleKecleonBrosBuyItemMenu(void) { s32 menuAction; @@ -795,6 +878,7 @@ static void HandleKecleonBrosBuyItemMenu(void) } } +// arm9.bin::02023880 static void HandleKecleonBrosSellItemMenu(void) { s32 menuAction; @@ -826,6 +910,7 @@ static void HandleKecleonBrosSellItemMenu(void) } } +// arm9.bin::02023844 static void sub_8019D30(void) { switch (sub_801B410()) { @@ -840,6 +925,7 @@ static void sub_8019D30(void) } } +// arm9.bin::02023808 static void sub_8019D4C(void) { switch (sub_801B410()) { @@ -854,6 +940,7 @@ static void sub_8019D4C(void) } } +// arm9.bin::020237D4 static void ProceedToKecleonBros1FallbackState(void) { s32 temp; @@ -862,6 +949,7 @@ static void ProceedToKecleonBros1FallbackState(void) SetKecleonBrosState(sKecleonBrosWork1->fallbackState); } +// arm9.bin::020237A0 static u32 CountKecleonItems(void) { if (sKecleonBrosWork1->isKecleonItemShop) @@ -870,6 +958,7 @@ static u32 CountKecleonItems(void) return CountKecleonWareItems(); } +// arm9.bin::02023700 static void KecleonCalcSellPriceForAllItems(void) { s32 sellPrice; @@ -889,6 +978,7 @@ static void KecleonCalcSellPriceForAllItems(void) } } +// arm9.bin::020236B8 static void SetKecleonPortraitSpriteId(bool32 angrySprite) { if (sKecleonBrosWork1->isKecleonItemShop) { diff --git a/src/kecleon_bros2.c b/src/kecleon_bros2.c index 221c25649..3f592ba4b 100644 --- a/src/kecleon_bros2.c +++ b/src/kecleon_bros2.c @@ -19,6 +19,7 @@ static EWRAM_INIT u16 gUnknown_203B218 = {0}; static void sub_801A064(void); +// arm9.bin::020258B0 bool8 sub_8019E40(u32 r0) { if (CountKecleonShopItems() == 0) @@ -40,6 +41,7 @@ bool8 sub_8019E40(u32 r0) return TRUE; } +// arm9.bin::020257BC u32 sub_8019EDC(bool8 r0) { Item slot; @@ -77,11 +79,13 @@ u32 sub_8019EDC(bool8 r0) } } +// arm9.bin::02025798 u8 sub_8019FB0(void) { return (gUnknown_203B214->s0.input.unk1E * gUnknown_203B214->s0.input.unk1C) + (u8)gUnknown_203B214->s0.input.menuIndex; } +// arm9.bin::02025738 void sub_8019FCC(bool8 r0) { ResetUnusedInputStruct(); @@ -94,6 +98,7 @@ void sub_8019FCC(bool8 r0) AddMenuCursorSprite(&gUnknown_203B214->s0.input); } +// arm9.bin::020256A8 void sub_801A010(void) { if (gUnknown_203B214 != NULL) { @@ -116,6 +121,7 @@ static void sub_801A064(void) SUB_80095E4_CALL(gUnknown_203B214->s0); } +// arm9.bin::02025480 void sub_801A0D8(void) { BulkItem *heldItem; diff --git a/src/kecleon_bros3.c b/src/kecleon_bros3.c index f71eee4c4..0fc0ff788 100644 --- a/src/kecleon_bros3.c +++ b/src/kecleon_bros3.c @@ -19,10 +19,11 @@ static EWRAM_INIT u16 gUnknown_203B220 = {0}; static void sub_801A430(void); -u8 sub_801A20C(u32 r0) +// arm9.bin::02025DDC +bool8 sub_801A20C(u32 r0) { if (CountKecleonWareItems() == 0) - return 0; + return FALSE; gUnknown_203B21C = MemoryAlloc(sizeof(*gUnknown_203B21C), 8); gUnknown_203B21C->s0.unk34 = r0; @@ -78,11 +79,13 @@ u32 sub_801A2A8(bool8 r0) } } +// arm9.bin::02025CC4 u8 sub_801A37C(void) { return (gUnknown_203B21C->s0.input.unk1E * gUnknown_203B21C->s0.input.unk1C) + gUnknown_203B21C->s0.input.menuIndex; } +// arm9.bin::02025C64 void sub_801A398(bool8 r0) { ResetUnusedInputStruct(); @@ -95,6 +98,7 @@ void sub_801A398(bool8 r0) AddMenuCursorSprite(&gUnknown_203B21C->s0.input); } +// arm9.bin::02025BD4 void sub_801A3DC(void) { if (gUnknown_203B21C != NULL) { @@ -117,6 +121,7 @@ static void sub_801A430(void) SUB_80095E4_CALL(gUnknown_203B21C->s0); } +// arm9.bin::020259AC void sub_801A4A4(void) { BulkItem *heldItem; diff --git a/src/kecleon_bros4.c b/src/kecleon_bros4.c index 9dfd45c8a..4206997dd 100644 --- a/src/kecleon_bros4.c +++ b/src/kecleon_bros4.c @@ -1,6 +1,9 @@ #include "global.h" #include "globaldata.h" #include "constants/input.h" +#include "constants/item.h" +#include "structs/menu.h" +#include "structs/struct_sub80095e4.h" #include "code_800D090.h" #include "code_80118A4.h" #include "code_8099360.h" @@ -13,6 +16,14 @@ #include "text_1.h" #include "text_2.h" +// size: R=0xF4 | B=0xF0 +typedef struct unkStruct_203B224 +{ + /* 0x0 */ u32 unk0; + /* 0x4 */ u32 unk4[INVENTORY_SIZE]; + /* 0x54 */ struct_Sub80095E4_2 unk54; +} unkStruct_203B224; + static EWRAM_INIT unkStruct_203B224 *gUnknown_203B224 = {NULL}; static EWRAM_INIT u16 gUnknown_203B228 = {0}; static EWRAM_INIT u16 gUnknown_203B22A = {0}; @@ -24,6 +35,7 @@ static void SortInventoryItems(void); static void sub_801A998(void); static s32 sub_801AE24(u32); +// arm9.bin::02026BE4 bool8 sub_801A5D8(u32 param_1, s32 param_2, DungeonPos *param_3, u32 param_4) { if (GetNumberOfFilledInventorySlots() == 0) @@ -57,6 +69,7 @@ bool8 sub_801A5D8(u32 param_1, s32 param_2, DungeonPos *param_3, u32 param_4) return TRUE; } +// arm9.bin::02026954 u32 sub_801A6E8(bool8 param_1) { s32 index; @@ -139,11 +152,13 @@ u32 sub_801A6E8(bool8 param_1) } } +// arm9.bin::02026934 s32 sub_801A8AC(void) { return (gUnknown_203B224->unk54.s0.input.unk1E * gUnknown_203B224->unk54.s0.input.unk1C) + gUnknown_203B224->unk54.s0.input.menuIndex; } +// arm9.bin::020268C0 void sub_801A8D0(bool8 r0) { sub_8099690(1); @@ -158,6 +173,7 @@ void sub_801A8D0(bool8 r0) AddMenuCursorSprite(&gUnknown_203B224->unk54.s0.input); } +// arm9.bin::02026818 void sub_801A928(void) { if (gUnknown_203B224 != NULL) { @@ -182,6 +198,7 @@ static void sub_801A998(void) ShowWindows(&gUnknown_203B224->unk54.s0.windows, TRUE, TRUE); } +// arm9.bin::020262DC void sub_801A9E0(void) { s32 teamItemIndex; @@ -292,6 +309,7 @@ void sub_801A9E0(void) sub_80073E0(gUnknown_203B224->unk54.s0.unk34); } +// arm9.bin::02026234 void sub_801AD34(u32 param_1) { CallPrepareTextbox_8008C54(param_1); diff --git a/src/memory.c b/src/memory.c index 56f94f0dc..62c8502c1 100644 --- a/src/memory.c +++ b/src/memory.c @@ -101,6 +101,7 @@ UNUSED static void MemoryClear32(u32 *dest, s32 size) CpuClear(dest, size); } +// arm9.bin::02010BD8 void MemoryFill8(void *dest, u8 value, s32 size) { u8 *cur = dest; @@ -111,6 +112,7 @@ void MemoryFill8(void *dest, u8 value, s32 size) } } +// arm9.bin::02010BC0 void MemoryFill16(u16 *dest, u16 value, s32 size) { while (size > 0) { @@ -119,6 +121,7 @@ void MemoryFill16(u16 *dest, u16 value, s32 size) } } +#if (GAME_VERSION == VERSION_RED) UNUSED static void MemoryFill32(u32 *dest, u32 value, s32 size) { while (size > 0) { @@ -126,6 +129,7 @@ UNUSED static void MemoryFill32(u32 *dest, u32 value, s32 size) *dest++ = value; } } +#endif // arm9.bin::02010BB4 void MemoryCopy8(void *dest, void *src, s32 size) @@ -455,6 +459,7 @@ error: heap, size, atb, group); } +// arm9.bin::02010DE0 void *MemoryAlloc(s32 size, s32 group) { return DoAlloc(&sMainHeapDescriptor, size, group); diff --git a/src/menu_input.c b/src/menu_input.c index 2ca0ab553..92269690e 100644 --- a/src/menu_input.c +++ b/src/menu_input.c @@ -160,10 +160,11 @@ s32 sub_8012AE8(void) return INPUT_NONE; } -void sub_8012BC4(u32 x, u32 y, s32 n, s32 len, u32 color, u32 a5) +// arm9.bin::0201C4A0 +void sub_8012BC4(u32 x, u32 y, s32 n, s32 len, u32 color, u32 windowId) { s32 iVar1; - u32 uVar2; + u32 chr; const unkChar *iVar3; s32 counter; s32 *piVar3; @@ -195,10 +196,10 @@ void sub_8012BC4(u32 x, u32 y, s32 n, s32 len, u32 color, u32 a5) do { iVar1 = *piVar4; piVar4++; - uVar2 = ReturnIntFromChar2(iVar1 + 0x30); - iVar3 = GetCharacter(uVar2); + chr = ReturnIntFromChar2(iVar1 + 0x30); + iVar3 = GetCharacter(chr); total_x += iVar3->unk6; - xxx_call_draw_char(x - total_x, y, uVar2, color, a5); + xxx_call_draw_char(x - total_x, y, chr, color, windowId); counter++; if (counter >= len) break; @@ -273,6 +274,7 @@ void sub_8012D34(WindowTemplate *param_1, s32 param_2) } +// arm9.bin::0201C26C void sub_8012D60(MenuStruct *param_1, const MenuItem *menuItems, const u32 *colorArray, u16 *param_4, s32 menuAction, s32 index) { const u8 *textPtr; @@ -560,6 +562,7 @@ static void sub_8013134(MenuInputStruct *param_1, u32 menuItemCounter, u32 windo sub_801317C(¶m_1->unk28); } +// arm9.bin::0201BD28 void sub_801317C(MenuInputStructSub *param_1) { param_1->unk0 = 0; @@ -567,17 +570,19 @@ void sub_801317C(MenuInputStructSub *param_1) param_1->b_button = 0; param_1->dpad_left = 0; param_1->dpad_right = 0; - param_1->unk8 = -1; - param_1->unkA = -1; + param_1->unk8.x = -1; + param_1->unk8.y = -1; nullsub_7(¶m_1->unk8); ResetUnusedInputStruct(); } +// arm9.bin::0201BD18 void AddMenuCursorSprite(MenuInputStruct *param_1) { AddMenuCursorSprite_(param_1, 0); } +// arm9.bin::0201B978 void AddMenuCursorSprite_(MenuInputStruct *a0, u8 *a1) { struct SpriteOAM sp = {0}; @@ -611,12 +616,15 @@ void AddMenuCursorSprite_(MenuInputStruct *a0, u8 *a1) sub_801332C(&a0->unk14); a0->unk24++; + + // More here in NDS } void nullsub_34(MenuInputStructSub *a0, s32 a1) { } +// arm9.bin::0201B490 static void sub_801332C(DungeonPos *a0) { struct SpriteOAM sp = {0}; @@ -640,6 +648,7 @@ static void sub_801332C(DungeonPos *a0) AddSprite(&sp, 0xFF, NULL, NULL); } +// arm9.bin::0201B1C0 static void sub_8013470(MenuInputStruct *a0) { struct SpriteOAM sp = {0}; @@ -694,6 +703,7 @@ void sub_8013660(MenuInputStruct *param_1) } } +// arm9.bin::0201B14C void UpdateMenuCursorSpriteCoords(MenuInputStruct *param_1) { s32 index; @@ -811,6 +821,7 @@ void sub_80137F8(MenuInputStruct *param_1, u32 param_2) param_1->unk10 = param_2 << 8; } +// arm9.bin::0201AF70 s32 GetMenuEntryYCoord(MenuInputStruct *menu, s32 entryId) { s32 firstY = menu->firstEntryY; @@ -1191,13 +1202,11 @@ void sub_8013F84(void) AddSprite(&SStack_18,0x100,0,0x0); } +// arm9.bin::0201A100 void sub_80140B4(WindowTemplates *a0) { s32 i; - for(i = 0; i < 4; i++) - { + for (i = 0; i < 4; i++) a0->id[i] = gUnknown_80D47C8[i]; - } } - diff --git a/src/moves.c b/src/moves.c index 36772cb40..482670f8c 100644 --- a/src/moves.c +++ b/src/moves.c @@ -1472,6 +1472,7 @@ void unk_CopyMoves4To8AndClearFlag2Unk4(Move *destMoves, Move *srcMoves) destMoves[movesCopied++].moveFlags = 0; } +// arm9.bin::02061E58 void unk_CopyMoves4To8(Move *destMoves, Move *srcMoves) { s32 movesCopied; @@ -1488,6 +1489,7 @@ void unk_CopyMoves4To8(Move *destMoves, Move *srcMoves) destMoves[movesCopied++].moveFlags = 0; } +// arm9.bin::02061DC0 void sub_8094060(Move *srcMoves, Move *destMoves) { s32 i, j; @@ -1512,6 +1514,7 @@ void sub_8094060(Move *srcMoves, Move *destMoves) destMoves[j++].moveFlags = 0; } +// arm9.bin::02061D80 static void WritePoke1MoveBits(DataSerializer *r0, Move *move) { WriteBits(r0, &move->moveFlags, 4); @@ -1519,6 +1522,7 @@ static void WritePoke1MoveBits(DataSerializer *r0, Move *move) WriteBits(r0, &move->PP, 7); } +// arm9.bin::02061D40 static void ReadPoke1MoveBits(DataSerializer *r0, Move *move) { ReadBits(r0, &move->moveFlags, 4); @@ -1526,6 +1530,7 @@ static void ReadPoke1MoveBits(DataSerializer *r0, Move *move) ReadBits(r0, &move->PP, 7); } +// arm9.bin::02061D08 void WritePoke1MovesBits(DataSerializer *r0, Move *moveSet) { s32 i; @@ -1534,6 +1539,7 @@ void WritePoke1MovesBits(DataSerializer *r0, Move *moveSet) WritePoke1MoveBits(r0, &moveSet[i]); } +// arm9.bin::02061CD0 void ReadPoke1MovesBits(DataSerializer *r0, Move *moveSet) { s32 i; @@ -1542,6 +1548,7 @@ void ReadPoke1MovesBits(DataSerializer *r0, Move *moveSet) ReadPoke1MoveBits(r0, &moveSet[i]); } +// arm9.bin::02061C70 static void WritePoke2MoveBits(DataSerializer *r0, Move *move) { WriteBits(r0, &move->moveFlags, 4); @@ -1551,7 +1558,8 @@ static void WritePoke2MoveBits(DataSerializer *r0, Move *move) WriteBits(r0, &move->ginseng, 7); } -void WritePoke2MovesBits(DataSerializer *r0, struct Moves *r1) +// arm9.bin::02061C28 +void WritePoke2MovesBits(DataSerializer *r0, Moves *r1) { s32 i; @@ -1561,6 +1569,7 @@ void WritePoke2MovesBits(DataSerializer *r0, struct Moves *r1) WriteBits(r0, &r1->struggleMoveFlags, 8); } +// arm9.bin::02061BB0 static void ReadPoke2MoveBits(DataSerializer *r0, Move *move) { memset(move, 0, sizeof(Move)); @@ -1571,7 +1580,8 @@ static void ReadPoke2MoveBits(DataSerializer *r0, Move *move) ReadBits(r0, &move->ginseng, 7); } -void ReadPoke2MovesBits(DataSerializer *r0, struct Moves*r1) +// arm9.bin::02061B60 +void ReadPoke2MovesBits(DataSerializer *r0, Moves* r1) { s32 i; @@ -1582,6 +1592,7 @@ void ReadPoke2MovesBits(DataSerializer *r0, struct Moves*r1) ReadBits(r0, &r1->struggleMoveFlags, 8); } +// arm9.bin::02061AEC bool8 DoesMoveCharge(u16 move) { if (move == MOVE_SOLARBEAM) return TRUE; diff --git a/src/music.c b/src/music.c index ffbeb7c0f..f7bc0e765 100644 --- a/src/music.c +++ b/src/music.c @@ -196,6 +196,7 @@ u16 GetCurrentBGSong(void) return sCurrentBGSong; } +// arm9.bin::0200ADB8 void PlayFanfareSE(u16 songIndex, u16 volume) { u16 playerIndex; diff --git a/src/party_list_menu.c b/src/party_list_menu.c index 530037743..c28e5c56e 100644 --- a/src/party_list_menu.c +++ b/src/party_list_menu.c @@ -25,6 +25,7 @@ #include "string_format.h" #include "text_1.h" #include "text_2.h" +#include "text_3.h" #include "text_util.h" static EWRAM_INIT unkStruct_203B2B8 *sUnknown_203B2B8 = {NULL}; diff --git a/src/pokemon.c b/src/pokemon.c index 02bb9a3b4..8e7899039 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -17,15 +17,15 @@ #include "sprite.h" #include "text_util.h" -static EWRAM_DATA MonsterDataEntry *gMonsterParameters = {0}; -static EWRAM_DATA OpenedFile *gMonsterParametersFile = {0}; +static EWRAM_DATA MonsterDataEntry *gMonsterParameters = {NULL}; // B=02135090 +static EWRAM_DATA OpenedFile *gMonsterParametersFile = {NULL}; static EWRAM_DATA SpriteOAM gShadowSprites[3] = {0}; -static EWRAM_DATA unkStruct_203B45C gRecruitedPokemon = {0}; +static EWRAM_DATA RecruitedMon gRecruitedPokemon = {0}; // B=02135560 static EWRAM_DATA u16 gLevelCurrentPokeId = {0}; UNUSED static EWRAM_DATA u16 unused_data[3] = {0}; static EWRAM_DATA LevelData gLevelCurrentData[0x64] = {0}; -EWRAM_INIT unkStruct_203B45C *gRecruitedPokemonRef = {NULL}; +EWRAM_INIT RecruitedMon *gRecruitedPokemonRef = {NULL}; // B=020EAF94 struct unkStruct_8107654 { @@ -51,38 +51,37 @@ extern char* gFormattedStatusNames[]; extern u32 ReturnIntFromChar(u8 r0); extern void xxx_pokemon2_to_pokemonstruct_808DF44(PokemonStruct1*, PokemonStruct2*); +// arm9.bin::0205C34C void LoadMonsterParameters(void) { gRecruitedPokemonRef = &gRecruitedPokemon; gMonsterParametersFile = OpenFileAndGetFileDataPtr(sMonsterParameterFileName, &gSystemFileArchive); gMonsterParameters = (MonsterDataEntry *)gMonsterParametersFile->data; gLevelCurrentPokeId = 0; + // More in blue } -unkStruct_203B45C *GetRecruitedPokemon(void) +// arm9.bin::0205C340 +RecruitedMon *GetRecruitedPokemon(void) { return &gRecruitedPokemon; } +// arm9.bin::0205C2A4 void InitializeRecruitedPokemon(void) { - s32 index; + s32 index; - for(index = 0; index < NUM_MONSTERS; index++) - { - gRecruitedPokemonRef->pokemon[index].unk0 = 0; - } + for (index = 0; index < NUM_MONSTERS; index++) + gRecruitedPokemonRef->pokemon[index].unk0 = 0; - for(index = 0; index < 4; index++) - { - gRecruitedPokemonRef->pokemon2[index].unk0 = 0; - } + for (index = 0; index < 4; index++) + gRecruitedPokemonRef->pokemon2[index].unk0 = 0; - for(index = 0; index < MAX_TEAM_MEMBERS; index++) - { - gRecruitedPokemonRef->team[index].speciesNum = 0; - gRecruitedPokemonRef->team[index].unk0 = 0; - } + for (index = 0; index < MAX_TEAM_MEMBERS; index++) { + gRecruitedPokemonRef->team[index].speciesNum = 0; + gRecruitedPokemonRef->team[index].unk0 = 0; + } } void sub_808CE74(s16 _species, bool32 _isLeader, u8* name) @@ -648,6 +647,7 @@ void CopyMonsterNameToBuffer(u8 * buffer, s32 index) strncpy(buffer, gMonsterParameters[index_s16].species, 0x14); } +// arm9.bin::0205B274 void CopyYellowMonsterNametoBuffer(u8 *buffer, s16 index) { s32 new_index = index; @@ -838,6 +838,7 @@ s32 GetBaseDefensiveStat(s32 index, u32 r1) return gMonsterParameters[index_s16].baseDefSpDef[r1]; } +// arm9.bin::0205AE2C u8 GetPokemonType(s32 index, u32 typeIndex) { s16 newIndex = index; @@ -915,6 +916,7 @@ OpenedFile *OpenPokemonDialogueSpriteFile(s16 index) return OpenFile(buffer, &gMonsterFileArchive); } +// arm9.bin::0205AC60 OpenedFile *GetDialogueSpriteDataPtr(s32 index) { // Looks like this loads the dialogue sprite for the pokemon diff --git a/src/pokemon_3.c b/src/pokemon_3.c index ad8c46d81..9c5f6142e 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -22,6 +22,16 @@ #include "text_1.h" #include "text_util.h" +struct UnusedOffenseStruct +{ + s32 att[2]; + s32 def[2]; + u8 atkBoost; + u8 spAtkBoost; + u8 defBoost; + u8 spDefBoost; +}; + extern u32 gIQSkillGroups[]; extern SpriteOAM gShadowSprites[3]; // Shadow sprites of some kind @@ -40,7 +50,7 @@ extern u8 gUnknown_810778C[]; extern u8 gUnknown_8107790[]; extern u8 gUnknown_8107798[]; -// 2, 4, 6, 7, 8, 9, 0xA, 0xD, 0xF, 0x11 +// 2, 4, 6, 7, 8, 9, 8, 0xA, 0xD, 0xF, 0x11 extern s32 gUnknown_810AC90[10]; #include "data/pokemon_3.h" @@ -56,28 +66,33 @@ extern void ReadBellyBits(DataSerializer*, FixedPoint *dst); extern void ReadHiddenPowerBits(DataSerializer*, HiddenPower*); s16 GetPokemonEvolveConditions(s16 index, unkEvolve *r1); +// arm9.bin::02059FDC void GenerateHiddenPower(HiddenPower* a1) { - s32 i; + s32 i; - a1->hiddenPowerBasePower = gUnknown_810AC90[RandInt(10)]; - for (i = 0; i < 100; i++) { - a1->hiddenPowerType = RandInt(NUM_TYPES); - if ( a1->hiddenPowerType ) - break; - } - if ( i == 100 ) - a1->hiddenPowerType = TYPE_FIRE; + a1->hiddenPowerBasePower = gUnknown_810AC90[RandInt(10)]; + + for (i = 0; i < 100; i++) { + a1->hiddenPowerType = RandInt(NUM_TYPES); + if (a1->hiddenPowerType) + break; + } + + if (i == 100) + a1->hiddenPowerType = TYPE_FIRE; } -bool8 HasRecruitedMon(s16 species) { +// arm9.bin::02059F70 +bool8 HasRecruitedMon(s16 species) +{ s32 species_s32 = species; s32 i = 0; PokemonStruct1 *pokemon = gRecruitedPokemonRef->pokemon; for (i = 0; i < NUM_MONSTERS; i++) { if (((u8)pokemon->unk0 & 1)) { - if(pokemon->speciesNum == species_s32) + if (pokemon->speciesNum == species_s32) return TRUE; } pokemon++; @@ -85,66 +100,68 @@ bool8 HasRecruitedMon(s16 species) { return FALSE; } -s16 GetBaseSpecies(s16 index) { +// arm9.bin::02059D94 +s16 GetBaseSpecies(s16 index) +{ if (index == MONSTER_CASTFORM_SNOWY) return MONSTER_CASTFORM; if (index == MONSTER_CASTFORM_SUNNY) return MONSTER_CASTFORM; if (index == MONSTER_CASTFORM_RAINY) return MONSTER_CASTFORM; - if(index == MONSTER_UNOWN_B) + if (index == MONSTER_UNOWN_B) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_C) + if (index == MONSTER_UNOWN_C) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_D) + if (index == MONSTER_UNOWN_D) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_E) + if (index == MONSTER_UNOWN_E) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_F) + if (index == MONSTER_UNOWN_F) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_G) + if (index == MONSTER_UNOWN_G) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_H) + if (index == MONSTER_UNOWN_H) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_I) + if (index == MONSTER_UNOWN_I) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_J) + if (index == MONSTER_UNOWN_J) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_K) + if (index == MONSTER_UNOWN_K) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_L) + if (index == MONSTER_UNOWN_L) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_M) + if (index == MONSTER_UNOWN_M) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_N) + if (index == MONSTER_UNOWN_N) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_O) + if (index == MONSTER_UNOWN_O) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_P) + if (index == MONSTER_UNOWN_P) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_Q) + if (index == MONSTER_UNOWN_Q) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_R) + if (index == MONSTER_UNOWN_R) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_S) + if (index == MONSTER_UNOWN_S) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_T) + if (index == MONSTER_UNOWN_T) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_U) + if (index == MONSTER_UNOWN_U) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_V) + if (index == MONSTER_UNOWN_V) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_W) + if (index == MONSTER_UNOWN_W) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_X) + if (index == MONSTER_UNOWN_X) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_Y) + if (index == MONSTER_UNOWN_Y) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_Z) + if (index == MONSTER_UNOWN_Z) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_EMARK) + if (index == MONSTER_UNOWN_EMARK) return MONSTER_UNOWN; - if(index == MONSTER_UNOWN_QMARK) + if (index == MONSTER_UNOWN_QMARK) return MONSTER_UNOWN; if (index == MONSTER_DEOXYS_ATTACK) return MONSTER_DEOXYS_NORMAL; @@ -158,7 +175,9 @@ s16 GetBaseSpecies(s16 index) { return index; } -s16 GetBaseSpeciesNoUnown(s16 index) { +// arm9.bin::02059D04 +s16 GetBaseSpeciesNoUnown(s16 index) +{ s32 a1_ = SpeciesId(index); if (index == MONSTER_CASTFORM_SNOWY) { return MONSTER_CASTFORM; @@ -185,97 +204,93 @@ s16 GetBaseSpeciesNoUnown(s16 index) { return a1_; } +// arm9.bin::02059BB4 s32 GetUnownIndex(s16 index) { - if(index == MONSTER_UNOWN_B) + if (index == MONSTER_UNOWN_B) return 1; - if(index == MONSTER_UNOWN_C) + if (index == MONSTER_UNOWN_C) return 2; - if(index == MONSTER_UNOWN_D) + if (index == MONSTER_UNOWN_D) return 3; - if(index == MONSTER_UNOWN_E) + if (index == MONSTER_UNOWN_E) return 4; - if(index == MONSTER_UNOWN_F) + if (index == MONSTER_UNOWN_F) return 5; - if(index == MONSTER_UNOWN_G) + if (index == MONSTER_UNOWN_G) return 6; - if(index == MONSTER_UNOWN_H) + if (index == MONSTER_UNOWN_H) return 7; - if(index == MONSTER_UNOWN_I) + if (index == MONSTER_UNOWN_I) return 8; - if(index == MONSTER_UNOWN_J) + if (index == MONSTER_UNOWN_J) return 9; - if(index == MONSTER_UNOWN_K) + if (index == MONSTER_UNOWN_K) return 10; - if(index == MONSTER_UNOWN_L) + if (index == MONSTER_UNOWN_L) return 11; - if(index == MONSTER_UNOWN_M) + if (index == MONSTER_UNOWN_M) return 12; - if(index == MONSTER_UNOWN_N) + if (index == MONSTER_UNOWN_N) return 13; - if(index == MONSTER_UNOWN_O) + if (index == MONSTER_UNOWN_O) return 14; - if(index == MONSTER_UNOWN_P) + if (index == MONSTER_UNOWN_P) return 15; - if(index == MONSTER_UNOWN_Q) + if (index == MONSTER_UNOWN_Q) return 16; - if(index == MONSTER_UNOWN_R) + if (index == MONSTER_UNOWN_R) return 17; - if(index == MONSTER_UNOWN_S) + if (index == MONSTER_UNOWN_S) return 18; - if(index == MONSTER_UNOWN_T) + if (index == MONSTER_UNOWN_T) return 19; - if(index == MONSTER_UNOWN_U) + if (index == MONSTER_UNOWN_U) return 20; - if(index == MONSTER_UNOWN_V) + if (index == MONSTER_UNOWN_V) return 21; - if(index == MONSTER_UNOWN_W) + if (index == MONSTER_UNOWN_W) return 22; - if(index == MONSTER_UNOWN_X) + if (index == MONSTER_UNOWN_X) return 23; - if(index == MONSTER_UNOWN_Y) + if (index == MONSTER_UNOWN_Y) return 24; - if(index == MONSTER_UNOWN_Z) + if (index == MONSTER_UNOWN_Z) return 25; - if(index == MONSTER_UNOWN_EMARK) + if (index == MONSTER_UNOWN_EMARK) return 26; - if(index == MONSTER_UNOWN_QMARK) + if (index == MONSTER_UNOWN_QMARK) return 27; return 0; } +// arm9.bin::02059B98 s16 ExtractSpeciesIndex(UnkDungeonGlobal_unk1CD98 *r0) { return r0->unk0 & 0x000001ff; } +// arm9.bin::02059B7C void sub_808E9C4(PokemonStruct1 *r0, s16 r1) { s32 r1_s32 = r1; // cast needed to match r0->unk0 = ((0xFE << 8) & r0->unk0) | r1_s32 ; } +#if (GAME_VERSION == VERSION_RED) void SetSpeciesLevelToExtract(UnkDungeonGlobal_unk1CD98 *r0, s32 level, s32 species) { species = SpeciesId(species); r0->unk0 = species | (level << 9) ; } +#endif +// arm9.bin::02059B6C s32 ExtractLevel(UnkDungeonGlobal_unk1CD98 *r0) { return (r0->unk0 >> 9); } -struct UnusedOffenseStruct -{ - s32 att[2]; - s32 def[2]; - u8 atkBoost; - u8 spAtkBoost; - u8 defBoost; - u8 spDefBoost; -}; - UNUSED static void GetMonOffenseStats(PokemonStruct1 *mon, struct UnusedOffenseStruct *dst) { dst->att[0] = mon->offense.att[0]; @@ -313,6 +328,11 @@ UNUSED static void GetMonOffenseStats(PokemonStruct1 *mon, struct UnusedOffenseS } } + +// TODO: File boundary? + + + const u8 *GetIQSkillName(u8 skill) { return gIQSkillNames[skill]; @@ -346,13 +366,13 @@ void GetAvailTacticsforLvl(u8 *tacticsBuffer, s32 pokeLevel) availTactics = 0; for(tactic = TACTIC_LETS_GO_TOGETHER; tactic < NUM_TACTICS; tactic++) { - if(gReqTacticLvls[tactic] <= pokeLevel) + if (gReqTacticLvls[tactic] <= pokeLevel) { tacticsBuffer[availTactics] = tactic; availTactics++; } } - if(availTactics > TACTIC_UNUSED) + if (availTactics > TACTIC_UNUSED) { return; } @@ -370,7 +390,7 @@ void GetAvailTacticsforLvl_Bool(u8 *tacticsBuffer, s32 pokeLevel) for(tactic = TACTIC_LETS_GO_TOGETHER; tactic < NUM_TACTICS; tactic++) { - if(gReqTacticLvls[tactic] <= pokeLevel) + if (gReqTacticLvls[tactic] <= pokeLevel) { tacticsBuffer[tactic] = TRUE; } @@ -383,7 +403,7 @@ void GetAvailTacticsforLvl_Bool(u8 *tacticsBuffer, s32 pokeLevel) bool8 HasIQForSkill(s32 pokeIQ, u8 IQSkillIndex) { - if(IQSkillIndex == IQ_NONE) + if (IQSkillIndex == IQ_NONE) { return FALSE; } @@ -499,6 +519,13 @@ void sub_808ED00() } } + + +// File boundary here + + + +// arm9.bin::0205CC54 s32 SaveRecruitedPokemon(u8 *a1, s32 a2) { u16 sixMons[6]; @@ -561,6 +588,7 @@ s32 SaveRecruitedPokemon(u8 *a1, s32 a2) return backup.count; } +// arm9.bin::0205CAE4 s32 RestoreRecruitedPokemon(u8 *a1, s32 a2) { DataSerializer backup; @@ -600,6 +628,7 @@ s32 RestoreRecruitedPokemon(u8 *a1, s32 a2) return backup.count; } +// arm9.bin::0205C9D4 void WritePoke1Bits(DataSerializer* a1, PokemonStruct1* pokemon) { WriteBits(a1, &pokemon->level, 7); @@ -618,9 +647,10 @@ void WritePoke1Bits(DataSerializer* a1, PokemonStruct1* pokemon) WriteBits(a1, &pokemon->tacticIndex, 4); WriteHeldItemBits(a1, &pokemon->heldItem); WritePoke1MovesBits(a1, pokemon->moves); - WriteBits(a1, pokemon->name, 10 * 8); + WriteBits(a1, pokemon->name, POKEMON_NAME_LENGTH * 8); } +// arm9.bin::0205C890 void ReadPoke1Bits(DataSerializer* a1, PokemonStruct1* pokemon) { memset(pokemon, 0, sizeof(PokemonStruct1)); @@ -647,124 +677,138 @@ void ReadPoke1Bits(DataSerializer* a1, PokemonStruct1* pokemon) ReadBits(a1, &pokemon->tacticIndex, 4); ReadHeldItemBits(a1, &pokemon->heldItem); ReadPoke1MovesBits(a1, pokemon->moves); - ReadBits(a1, pokemon->name, 10 * 8); + ReadBits(a1, pokemon->name, POKEMON_NAME_LENGTH * 8); } +// arm9.bin::0205C688 s32 SavePoke2s(u8* buffer, s32 size) { - DataSerializer backup; - s32 i; - u8 data_u8_neg1; - u8 data_u8_zero; + DataSerializer backup; + s32 i; + u8 data_u8_neg1; + u8 data_u8_zero; - InitBitWriter(&backup, buffer, size); - data_u8_neg1 = -1; - data_u8_zero = 0; + InitBitWriter(&backup, buffer, size); + data_u8_neg1 = -1; + data_u8_zero = 0; - for (i = 0; i < 4; i++) { - PokemonStruct2* pokemon2 = &gRecruitedPokemonRef->pokemon2[i]; - WriteBits(&backup, &pokemon2->unk0, 2); + for (i = 0; i < 4; i++) { + PokemonStruct2* pokemon2 = &gRecruitedPokemonRef->pokemon2[i]; + WriteBits(&backup, &pokemon2->unk0, 2); - WriteBits(&backup, pokemon2->isTeamLeader ? &data_u8_neg1 : &data_u8_zero, 1); - WriteBits(&backup, &pokemon2->level, 7); + WriteBits(&backup, pokemon2->isTeamLeader ? &data_u8_neg1 : &data_u8_zero, 1); + WriteBits(&backup, &pokemon2->level, 7); - WriteDungeonLocationBits(&backup, &pokemon2->dungeonLocation); - WriteBits(&backup, &pokemon2->IQ, 10); - WriteBits(&backup, &pokemon2->unkA, 16); - WriteBits(&backup, &pokemon2->unkC, 16); - WriteBits(&backup, &pokemon2->speciesNum, 9); - WriteBits(&backup, &pokemon2->unk10, 10); - WriteBits(&backup, &pokemon2->unk12, 10); - WriteBits(&backup, &pokemon2->offense.att[0], 8); - WriteBits(&backup, &pokemon2->offense.att[1], 8); - WriteBits(&backup, &pokemon2->offense.def[0], 8); - WriteBits(&backup, &pokemon2->offense.def[1], 8); - WriteBits(&backup, &pokemon2->currExp, 24); - WritePoke2MovesBits(&backup, &pokemon2->moves); - WriteItemSlotBits(&backup, &pokemon2->itemSlot); - WriteBellyBits(&backup, &pokemon2->belly); - WriteBellyBits(&backup, &pokemon2->maxBelly); - WriteBits(&backup, &pokemon2->IQSkills, 24); - WriteBits(&backup, &pokemon2->tacticIndex, 4); - WriteHiddenPowerBits(&backup, &pokemon2->hiddenPower); - WriteBits(&backup, &pokemon2->name, 10 * 8); - } + WriteDungeonLocationBits(&backup, &pokemon2->dungeonLocation); + WriteBits(&backup, &pokemon2->IQ, 10); + WriteBits(&backup, &pokemon2->unkA, 16); + WriteBits(&backup, &pokemon2->unkC, 16); + WriteBits(&backup, &pokemon2->speciesNum, 9); + WriteBits(&backup, &pokemon2->unk10, 10); + WriteBits(&backup, &pokemon2->unk12, 10); + WriteBits(&backup, &pokemon2->offense.att[0], 8); + WriteBits(&backup, &pokemon2->offense.att[1], 8); + WriteBits(&backup, &pokemon2->offense.def[0], 8); + WriteBits(&backup, &pokemon2->offense.def[1], 8); + WriteBits(&backup, &pokemon2->currExp, 24); + WritePoke2MovesBits(&backup, &pokemon2->moves); + WriteItemSlotBits(&backup, &pokemon2->itemSlot); + WriteBellyBits(&backup, &pokemon2->belly); + WriteBellyBits(&backup, &pokemon2->maxBelly); + WriteBits(&backup, &pokemon2->IQSkills, 24); + WriteBits(&backup, &pokemon2->tacticIndex, 4); + WriteHiddenPowerBits(&backup, &pokemon2->hiddenPower); + WriteBits(&backup, &pokemon2->name, POKEMON_NAME_LENGTH * 8); + } - FinishBitSerializer(&backup); - return backup.count; + FinishBitSerializer(&backup); + return backup.count; } +// arm9.bin::0205C464 s32 RestorePoke2s(u8* a1, s32 size) { - DataSerializer backup; - s32 i; + DataSerializer backup; + s32 i; - InitBitReader(&backup, a1, size); - for (i = 0; i < 4; i++) { - PokemonStruct2* pokemon2 = &gRecruitedPokemonRef->pokemon2[i]; - u8 unk2; + InitBitReader(&backup, a1, size); - memset(pokemon2, 0, sizeof(PokemonStruct2)); + for (i = 0; i < 4; i++) { + PokemonStruct2* pokemon2 = &gRecruitedPokemonRef->pokemon2[i]; + u8 unk2; - ReadBits(&backup, &pokemon2->unk0, 2); + memset(pokemon2, 0, sizeof(PokemonStruct2)); - ReadBits(&backup, &unk2, 1); - if (unk2 & 1) { - pokemon2->isTeamLeader = TRUE; + ReadBits(&backup, &pokemon2->unk0, 2); + + ReadBits(&backup, &unk2, 1); + if (unk2 & 1) { + pokemon2->isTeamLeader = TRUE; + } + else { + pokemon2->isTeamLeader = FALSE; + } + ReadBits(&backup, &pokemon2->level, 7); + + ReadDungeonLocationBits(&backup, &pokemon2->dungeonLocation); + ReadBits(&backup, &pokemon2->IQ, 10); + ReadBits(&backup, &pokemon2->unkA, 16); + ReadBits(&backup, &pokemon2->unkC, 16); + ReadBits(&backup, &pokemon2->speciesNum, 9); + ReadBits(&backup, &pokemon2->unk10, 10); + ReadBits(&backup, &pokemon2->unk12, 10); + ReadBits(&backup, &pokemon2->offense.att[0], 8); + ReadBits(&backup, &pokemon2->offense.att[1], 8); + ReadBits(&backup, &pokemon2->offense.def[0], 8); + ReadBits(&backup, &pokemon2->offense.def[1], 8); + ReadBits(&backup, &pokemon2->currExp, 24); + ReadPoke2MovesBits(&backup, &pokemon2->moves); + ReadItemSlotBits(&backup, &pokemon2->itemSlot); + ReadBellyBits(&backup, &pokemon2->belly); + ReadBellyBits(&backup, &pokemon2->maxBelly); + ReadBits(&backup, &pokemon2->IQSkills, 24); + ReadBits(&backup, &pokemon2->tacticIndex, 4); + ReadHiddenPowerBits(&backup, &pokemon2->hiddenPower); + ReadBits(&backup, &pokemon2->name, POKEMON_NAME_LENGTH * 8); } - else { - pokemon2->isTeamLeader = FALSE; - } - ReadBits(&backup, &pokemon2->level, 7); - ReadDungeonLocationBits(&backup, &pokemon2->dungeonLocation); - ReadBits(&backup, &pokemon2->IQ, 10); - ReadBits(&backup, &pokemon2->unkA, 16); - ReadBits(&backup, &pokemon2->unkC, 16); - ReadBits(&backup, &pokemon2->speciesNum, 9); - ReadBits(&backup, &pokemon2->unk10, 10); - ReadBits(&backup, &pokemon2->unk12, 10); - ReadBits(&backup, &pokemon2->offense.att[0], 8); - ReadBits(&backup, &pokemon2->offense.att[1], 8); - ReadBits(&backup, &pokemon2->offense.def[0], 8); - ReadBits(&backup, &pokemon2->offense.def[1], 8); - ReadBits(&backup, &pokemon2->currExp, 24); - ReadPoke2MovesBits(&backup, &pokemon2->moves); - ReadItemSlotBits(&backup, &pokemon2->itemSlot); - ReadBellyBits(&backup, &pokemon2->belly); - ReadBellyBits(&backup, &pokemon2->maxBelly); - ReadBits(&backup, &pokemon2->IQSkills, 24); - ReadBits(&backup, &pokemon2->tacticIndex, 4); - ReadHiddenPowerBits(&backup, &pokemon2->hiddenPower); - ReadBits(&backup, &pokemon2->name, 80); - } - - FinishBitSerializer(&backup); - return backup.count; + FinishBitSerializer(&backup); + return backup.count; } +// arm9.bin::0205C454 void ReadPoke1LevelBits(DataSerializer* a1, struct unkPokeSubStruct_C* unkC) { - ReadBits(a1, &unkC->level, 7); + ReadBits(a1, &unkC->level, 7); } +// arm9.bin::0205C444 void WritePoke1LevelBits(DataSerializer* a1, struct unkPokeSubStruct_C* unkC) { - WriteBits(a1, &unkC->level, 7); + WriteBits(a1, &unkC->level, 7); } +// arm9.bin::0205C414 void ReadHiddenPowerBits(DataSerializer* a1, HiddenPower* a2) { - ReadBits(a1, &a2->hiddenPowerBasePower, 10); - ReadBits(a1, &a2->hiddenPowerType, 5); + ReadBits(a1, &a2->hiddenPowerBasePower, 10); + ReadBits(a1, &a2->hiddenPowerType, 5); } +// arm9.bin::0205C3E4 void WriteHiddenPowerBits(DataSerializer* a1, HiddenPower* a2) { - WriteBits(a1, &a2->hiddenPowerBasePower, 10); - WriteBits(a1, &a2->hiddenPowerType, 5); + WriteBits(a1, &a2->hiddenPowerBasePower, 10); + WriteBits(a1, &a2->hiddenPowerType, 5); } + + + +// File Boundary here + + + void sub_808F468(struct PokemonStruct1 *pokemon,struct EvolveStatus *evolveStatus,bool8 param_3) { struct FriendAreaCapacity friendAreaCapacity; @@ -966,44 +1010,44 @@ PokemonStruct1 *sub_808F734(PokemonStruct1 *pokemon, s16 _species) PokemonStruct1 *sub_808F798(PokemonStruct1 *pokemon, short _species) { - s32 r6; - s32 index; - PokemonStruct1 pokeStruct; - LevelData levelData; - u8 buffer [64]; - s32 species = _species; - bool32 flag = TRUE; + s32 r6; + s32 index; + PokemonStruct1 pokeStruct; + LevelData levelData; + u8 buffer [64]; + s32 species = _species; + bool32 flag = TRUE; - pokeStruct = *pokemon; - r6 = pokeStruct.speciesNum; - GetPokemonLevelData(&levelData,species,pokeStruct.level); - pokeStruct.currExp = levelData.expRequired; - pokemon->unk0 = 0; - pokeStruct.speciesNum = species; - if (pokeStruct.unkC[0].level == 0) { + pokeStruct = *pokemon; + r6 = pokeStruct.speciesNum; + GetPokemonLevelData(&levelData,species,pokeStruct.level); + pokeStruct.currExp = levelData.expRequired; + pokemon->unk0 = 0; + pokeStruct.speciesNum = species; + if (pokeStruct.unkC[0].level == 0) { pokeStruct.unkC[0].level = pokeStruct.level; - } - else if (pokeStruct.unkC[1].level == 0) { + } + else if (pokeStruct.unkC[1].level == 0) { pokeStruct.unkC[1].level = pokeStruct.level; - } + } - CopyStringtoBuffer(buffer, GetMonSpecies(r6)); + CopyStringtoBuffer(buffer, GetMonSpecies(r6)); - index = 0; - goto _start; - do - { - index++; + index = 0; + goto _start; + do + { + index++; _start: - if(index >= POKEMON_NAME_LENGTH) break; - if(buffer[index] != pokeStruct.name[index]) goto _end; - if(buffer[index] == 0) break; + if (index >= POKEMON_NAME_LENGTH) break; + if (buffer[index] != pokeStruct.name[index]) goto _end; + if (buffer[index] == 0) break; - } while(TRUE); - if(flag) - BoundedCopyStringtoBuffer(pokeStruct.name, GetMonSpecies(species), POKEMON_NAME_LENGTH); + } while(TRUE); + if (flag) + BoundedCopyStringtoBuffer(pokeStruct.name, GetMonSpecies(species), POKEMON_NAME_LENGTH); _end: - return sub_808D1DC(&pokeStruct); + return sub_808D1DC(&pokeStruct); } UNUSED void sub_808F83C(PokemonStruct1 *pokemon, s16 species, u8 *r2) diff --git a/src/sprite.c b/src/sprite.c index 2462d0dc6..d4c95ef09 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -5,23 +5,23 @@ #include "random.h" #include "sprite.h" -EWRAM_DATA static u16 sOAMSpriteCount = {0}; // GBA=2025670 | NDS=20EC504 | Written to but never read +EWRAM_DATA static u16 sOAMSpriteCount = {0}; // R=2025670 | B=20EC504 | Written to but never read EWRAM_DATA static s16 sUnknown_2025672[8] = {0}; EWRAM_DATA static s16 sUnknown_2025682[9] = {0}; EWRAM_DATA static DungeonPos sUnknown_2025694 = {0}; EWRAM_DATA static u32 sUnknown_2025698 = {0}; -UNUSED EWRAM_DATA static u32 sUnused1 = {0}; // GBA=202569C -EWRAM_DATA static SpriteList sSpriteList = {0}; // NDS=20ED4C0 +UNUSED EWRAM_DATA static u32 sUnused1 = {0}; // R=202569C +EWRAM_DATA static SpriteList sSpriteList = {0}; // B=20ED4C0 EWRAM_DATA static UnkSpriteLink sUnknown_2025EA8[128] = {0}; EWRAM_DATA static SpriteOAM sUnknown_20262A8[128] = {0}; -EWRAM_DATA static s32 sSpriteCount = {0}; // GBA=20266A8 -UNUSED EWRAM_DATA static u32 sUnused2 = {0}; // GBA=20266AC +EWRAM_DATA static s32 sSpriteCount = {0}; // R=20266A8 +UNUSED EWRAM_DATA static u32 sUnused2 = {0}; // R=20266AC #define UNK_20266B0_ARR_COUNT 160 EWRAM_DATA static unkStruct_20266B0 sUnknown_20266B0[UNK_20266B0_ARR_COUNT] = {0}; -EWRAM_DATA static void *sCharMemCursor = {0}; // GBA=2026E30 -UNUSED EWRAM_DATA static u32 sUnused3 = {0}; // GBA=2026E34 +EWRAM_DATA static void *sCharMemCursor = { NULL }; // R=2026E30 +UNUSED EWRAM_DATA static u32 sUnused3 = {0}; // R=2026E34 EWRAM_INIT static unkStruct_20266B0 *sUnknown_203B074 = {0}; @@ -728,7 +728,7 @@ void sub_8005770(s32 param_1, const RGB *color, s32 brightness, const RGB *ramp) // Maybe DungeonPos // arm9.bin::02001790 -void nullsub_7(s16 *a0) +void nullsub_7(DungeonPos *a0) { } diff --git a/src/string_format.c b/src/string_format.c index 75d035a32..3527bf375 100644 --- a/src/string_format.c +++ b/src/string_format.c @@ -106,15 +106,15 @@ static void nullsub_35(void); static bool8 AppendString(const u8 *, u8 **, u8 *, u16 r3); // 'd', 'v' and 'V' -EWRAM_DATA s32 gFormatArgs[10] = {0}; +EWRAM_DATA s32 gFormatArgs[10] = {0}; // NDS=02134278 // 'i', apparently only i0 and i1 are actually used though it's yet to be verified -EWRAM_DATA u8 gFormatBuffer_Items[4][FORMAT_BUFFER_LEN] = {0}; +EWRAM_DATA u8 gFormatBuffer_Items[4][FORMAT_BUFFER_LEN] = {0}; // NDS=02134450 // 'm' which probably stands for 'monster', available through m0 to m9 EWRAM_DATA u8 gFormatBuffer_Monsters[10][FORMAT_BUFFER_LEN] = {0}; // 'n' which probably stands for 'name', available through n0 to n9 EWRAM_DATA u8 gFormatBuffer_Names[10][FORMAT_BUFFER_LEN] = {0}; // Current textbox's speaker's name -EWRAM_DATA u8 gSpeakerNameBuffer[FORMAT_BUFFER_LEN] = {0}; +EWRAM_DATA u8 gSpeakerNameBuffer[FORMAT_BUFFER_LEN] = {0}; // NDS=02134400 // 'h' - Friend Area buffer. This buffer seems larger than others. It's possible it actually has the same length, but there were some unused buffers right after it. EWRAM_DATA u8 gFormatBuffer_FriendArea[FRIEND_AREA_BUFFER_LEN] = {0}; @@ -220,6 +220,7 @@ void CreateYesNoDialogueBoxAndPortrait_DefaultNo(const u8 *text, MonPortraitMsg CreateMenuDialogueBoxAndPortrait(text, NULL, -1, gUnknown_80D4880, NULL, 3, 0, monPortraitPtr, flags | 0x300); } +// arm9.bin::0201D700 void CreateMenuDialogueBoxAndPortrait(const u8 *text, void *a1, u32 r9, const MenuItem *menuItems, void *arg_0, u32 a5, u32 unknownUnused, MonPortraitMsg *monPortraitPtr, u16 flags) { bool8 portraitOn = FALSE; @@ -372,10 +373,10 @@ void DrawDialogueBoxString(void) str++; } else { - u32 sp; + u32 chr; - str = xxx_get_next_char_from_string(str, &sp); - gUnknown_202E748.unk0 += xxx_call_draw_char(gUnknown_202E748.unk0, gUnknown_202E748.unk2, sp, gUnknown_202E748.unk10, 0); + str = xxx_get_next_char_from_string(str, &chr); + gUnknown_202E748.unk0 += xxx_call_draw_char(gUnknown_202E748.unk0, gUnknown_202E748.unk2, chr, gUnknown_202E748.unk10, 0); gUnknown_202E748.unk2C = gUnknown_202E78C; } @@ -666,6 +667,7 @@ static void UNUSED nullsub_35(void) { } +// arm9.bin::0201C854 const u8 *FormatString(const u8 *str, u8 *dst, u8 *dstMax, u16 flags) { u8 txtArray[60]; @@ -853,6 +855,7 @@ static bool8 AppendString(const u8 *str, u8 **dstPtr, u8 *dstMax, u16 flags) #define FORMAT_STR_MAX_LEN 500 +// arm9.bin::0201C7AC void PrintFormattedStringOnWindow(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr) { u8 formattedString[FORMAT_STR_MAX_LEN]; @@ -862,6 +865,7 @@ void PrintFormattedStringOnWindow(s32 x, s32 y, const u8 *str, u32 windowId, u32 PrintStringOnWindow(x, y, formattedString, windowId, terminatingChr); } +// arm9.bin::0201C750 void PrintFormattedStringOnWindow2(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 lineSpacing) { u8 formattedString[FORMAT_STR_MAX_LEN]; diff --git a/src/strings.c b/src/strings.c index 967d33521..929a3285b 100644 --- a/src/strings.c +++ b/src/strings.c @@ -9,6 +9,7 @@ #include "constants/move_range.h" #include "structs/str_status_text.h" +// NDS=020C81F0 const char * const gUnformattedTypeStrings[NUM_TYPES] = { [TYPE_NONE] = _("None"), diff --git a/src/text_2.c b/src/text_2.c index cb4d1b051..10aec2c28 100644 --- a/src/text_2.c +++ b/src/text_2.c @@ -24,9 +24,9 @@ static bool8 xxx_update_bg_vram(Window *windows); // TODO: Find these funcs in blue. DTCM funcs // In NDS, this func is copied to 01FF9F34 -u32 xxx_call_draw_char(s32 x, s32 y, u32 a2, u32 color, u32 a4) +u32 xxx_call_draw_char(s32 x, s32 y, u32 chr, u32 color, u32 windowId) { - return xxx_draw_char(gWindows, x, y, a2, color, a4); + return xxx_draw_char(gWindows, x, y, chr, color, windowId); } UNUSED static bool8 sub_8007464(void) @@ -35,7 +35,7 @@ UNUSED static bool8 sub_8007464(void) } // In NDS, this func is copied to 01FF994C -u32 xxx_draw_char(Window *windows, s32 x, s32 y, u32 a3, u32 color, u32 windowId) +u32 xxx_draw_char(Window *windows, s32 x, s32 y, u32 chr, u32 color, u32 windowId) { u32 *r3; const unkShiftData *shiftData; @@ -52,13 +52,13 @@ u32 xxx_draw_char(Window *windows, s32 x, s32 y, u32 a3, u32 color, u32 windowId u32 r2; if (gCurrentCharmap == 1) { - if (a3 == 0x70 || a3 == 0x6A || a3 == 0x71 || a3 == 0x79 || a3 == 0x67) + if (chr == 0x70 || chr == 0x6A || chr == 0x71 || chr == 0x79 || chr == 0x67) y += 2; - else if (a3 == 0x8199) + else if (chr == 0x8199) y -= 2; } - sp0 = GetCharacter(a3); + sp0 = GetCharacter(chr); local_44 = sp0->unk0; ASM_MATCH_TRICK(local_3c); // stack doesn't match without it local_3c = sp0->unk0; @@ -226,6 +226,7 @@ u32 xxx_draw_char(Window *windows, s32 x, s32 y, u32 a3, u32 color, u32 windowId return sp0->unk6 + gCharacterSpacing; } +// Copied to 01ff98f8 in NDS void AddDoubleUnderScoreHighlight(u32 windowId, s32 x, s32 y, s32 width, u32 color) { AddUnderScoreHighlight(windowId, x, y, width, color); @@ -854,7 +855,7 @@ static s32 HexDigitValue(u8 chr) } // In NDS, this func is copied to 01FF8D80 -const u8 *xxx_get_next_char_from_string(const u8 *a1, u32 *a0) +const u8 *xxx_get_next_char_from_string(const u8 *a1, u32 *dstChr) { s32 currChr = *a1; if (currChr == 0x7E) { @@ -868,15 +869,15 @@ const u8 *xxx_get_next_char_from_string(const u8 *a1, u32 *a0) a1++; } } - *a0 = hexDigit; + *dstChr = hexDigit; return a1; } else if ((currChr >= 0x81 && currChr <= 0x84) || currChr == 0x87) { - *a0 = a1[1] | (a1[0] << 8); + *dstChr = a1[1] | (a1[0] << 8); return a1 + 2; } else { - *a0 = currChr; + *dstChr = currChr; return a1 + 1; } } @@ -1237,9 +1238,10 @@ void sub_80089AC(const WindowTemplate *r4, DungeonPos *r5_Str) } } -void CallPrepareTextbox_8008C54(u32 strId) +// Copied to 01FF818C in NDS +void CallPrepareTextbox_8008C54(u32 windowId) { - PrepareTextbox_8008C6C(gWindows, strId); + PrepareTextbox_8008C6C(gWindows, windowId); } UNUSED static void nullsub_169(void) diff --git a/src/text_util.c b/src/text_util.c index 6411d71ac..3a06bd797 100644 --- a/src/text_util.c +++ b/src/text_util.c @@ -12,6 +12,7 @@ u32 ReturnIntFromChar(u8 r0) return r0; } +// arm9.bin::020614D0 u32 ReturnIntFromChar2(u8 r0) { return r0; @@ -68,6 +69,7 @@ void BoundedCopyStringtoBuffer(u8 *buffer, u8 *string, s32 size) } } +// arm9.bin::02061508 const char *GetUnformattedTypeString(u8 type) { return gUnformattedTypeStrings[type]; diff --git a/src/util.c b/src/util.c index 0c9c2dd31..ae4ef1701 100644 --- a/src/util.c +++ b/src/util.c @@ -18,6 +18,7 @@ void ReverseString(u8 *s, s32 len) } } +// arm9.bin::0201275C s32 ConvertToDecimal(s32 *decimal, s32 n, s32 len) { s32 sign;