diff options
author | Cleverking2003 <30466983+Cleverking2003@users.noreply.github.com> | 2020-08-13 19:12:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-13 19:12:12 +0300 |
commit | a82d0d55a67b12757b185fd149d6a14dcc7cad02 (patch) | |
tree | 829d21a866de69dc92e1b8e5bb1857a21104027c /include | |
parent | c259e6ed18294c001033fed62d924d379276021a (diff) | |
parent | ddd20f2c76a34b4fc46503c8bf88d53a755453a8 (diff) |
Merge pull request #261 from PikalaxALT/pikalax_work
Name some scrcmds; save block 2 struct resolution
Diffstat (limited to 'include')
-rw-r--r-- | include/coins.h | 13 | ||||
-rw-r--r-- | include/event_data.h | 19 | ||||
-rw-r--r-- | include/igt.h | 16 | ||||
-rw-r--r-- | include/main.h | 4 | ||||
-rw-r--r-- | include/options.h | 10 | ||||
-rw-r--r-- | include/party.h | 21 | ||||
-rw-r--r-- | include/player_data.h | 40 | ||||
-rw-r--r-- | include/pokemon.h | 2 | ||||
-rw-r--r-- | include/proto.h | 3 | ||||
-rw-r--r-- | include/save_block_2.h | 47 | ||||
-rw-r--r-- | include/script.h | 3 | ||||
-rw-r--r-- | include/sound.h | 2 | ||||
-rw-r--r-- | include/structs.h | 44 |
13 files changed, 148 insertions, 76 deletions
diff --git a/include/coins.h b/include/coins.h new file mode 100644 index 00000000..f68d44a0 --- /dev/null +++ b/include/coins.h @@ -0,0 +1,13 @@ +#ifndef POKEDIAMOND_COINS_H +#define POKEDIAMOND_COINS_H + +#define MAX_COINS 50000 + +void InitCoins(u16 * coins); +void SetCoins(u16 * coins, u16 value); +u16 CheckCoins(u16 * coins); +BOOL GiveCoins(u16 * coins, u16 amount); +BOOL CanGiveCoins(u16 * coins, u16 amount); +BOOL TakeCoins(u16 * coins, u16 amount); + +#endif //POKEDIAMOND_COINS_H diff --git a/include/event_data.h b/include/event_data.h new file mode 100644 index 00000000..e1d46348 --- /dev/null +++ b/include/event_data.h @@ -0,0 +1,19 @@ +#ifndef GUARD_SCRIPT_STATE_H +#define GUARD_SCRIPT_STATE_H + +struct ScriptState +{ + u16 vars[288]; + u8 flags[364]; +}; + +u32 SavArray_Flags_sizeof(void); +void SavArray_Flags_init(struct ScriptState * state); +struct ScriptState * SavArray_Flags_get(struct SaveBlock2 * sav2); +BOOL CheckFlagInArray(struct ScriptState * state, u16 flag_id); +void SetFlagInArray(struct ScriptState * state, u16 flag_id); +void ClearFlagInArray(struct ScriptState * state, u16 flag_id); +u8 * GetFlagAddr(struct ScriptState * state, u16 flag_id); +u16 * GetVarAddr(struct ScriptState * state, u16 var_id); + +#endif //GUARD_SCRIPT_STATE_H diff --git a/include/igt.h b/include/igt.h new file mode 100644 index 00000000..bf5e5a63 --- /dev/null +++ b/include/igt.h @@ -0,0 +1,16 @@ +#ifndef POKEDIAMOND_IGT_H +#define POKEDIAMOND_IGT_H + +struct IGT +{ + u16 hours; + u8 minutes; + u8 seconds; +}; + +void InitIGT(struct IGT * igt); +void AddIGTSeconds(struct IGT * igt, u32 seconds); +u16 GetIGTHours(struct IGT * igt); +u8 GetIGTMinutes(struct IGT * igt); + +#endif //POKEDIAMOND_IGT_H diff --git a/include/main.h b/include/main.h index ec3fca46..b61e68b9 100644 --- a/include/main.h +++ b/include/main.h @@ -3,7 +3,7 @@ #include "FS_overlay.h" #include "SPI_pm.h" -#include "structs.h" +#include "save_block_2.h" struct UnkStruct_02006234; @@ -36,7 +36,7 @@ struct Unk2106FA0 struct Unk21DBE18 * unk14; s32 unk18; s32 unk1C; - struct UnkStruct_021C59C8 * unk20; + struct SaveBlock2 * unk20; }; struct Unk21C4818 diff --git a/include/options.h b/include/options.h index 730cbaa5..4ed466df 100644 --- a/include/options.h +++ b/include/options.h @@ -1,15 +1,13 @@ #ifndef POKEDIAMOND_OPTIONS_H #define POKEDIAMOND_OPTIONS_H -#include "main.h" - struct Options { u16 unk0_0:4; u16 unk0_4:2; - u16 unk0_6:10; - u8 padding[2]; // TODO: finish me + u16 unk0_6:1; + u16 unk0_7:1; + u16 unk0_8:2; + u16 unk0_A:5; }; -struct Options * LoadPlayerDataAddress(struct UnkStruct_021C59C8 *); - #endif //POKEDIAMOND_OPTIONS_H diff --git a/include/party.h b/include/party.h index eca62239..2d06705c 100644 --- a/include/party.h +++ b/include/party.h @@ -2,19 +2,20 @@ #define POKEDIAMOND_PARTY_H #include "pokemon.h" +#include "save_block_2.h" BOOL PartyHasMon(struct PlayerParty * party_p, u16 species); int GetPartyCount(struct PlayerParty * party_p); struct Pokemon * GetPartyMonByIndex(struct PlayerParty * party_p, int idx); -u32 FUN_0206B8A4(void); -struct PlayerParty * FUN_0206B8AC(u32 heap_id); -void FUN_0206B8C0(struct PlayerParty * party); -void FUN_0206B8CC(struct PlayerParty * party, int count); -BOOL FUN_0206B900(struct PlayerParty * party, struct Pokemon * pokemon); -BOOL FUN_0206B938(struct PlayerParty * party, int pos); -void FUN_0206B9DC(struct PlayerParty * party, int pos, struct Pokemon * pokemon); -BOOL FUN_0206BA38(struct PlayerParty * party, int pos1, int pos2); -void FUN_0206BAD0(struct PlayerParty * src, struct PlayerParty * dest); -struct PlayerParty * FUN_0206BB1C(void * ptr); +u32 SavArray_Party_sizeof(void); +struct PlayerParty * SavArray_Party_alloc(u32 heap_id); +void SavArray_Party_init(struct PlayerParty * party); +void InitPartyWithMaxSize(struct PlayerParty * party, int count); +BOOL AddMonToParty(struct PlayerParty * party, struct Pokemon * pokemon); +BOOL RemoveMonFromParty(struct PlayerParty * party, int pos); +void ReplacePartySlotWithMon(struct PlayerParty * party, int pos, struct Pokemon * pokemon); +BOOL SwapSlotsInParty(struct PlayerParty * party, int pos1, int pos2); +void CopyPlayerParty(struct PlayerParty * src, struct PlayerParty * dest); +struct PlayerParty * SavArray_PlayerParty_get(struct SaveBlock2 * ptr); #endif //POKEDIAMOND_PARTY_H diff --git a/include/player_data.h b/include/player_data.h new file mode 100644 index 00000000..28133f43 --- /dev/null +++ b/include/player_data.h @@ -0,0 +1,40 @@ +#ifndef POKEDIAMOND_PLAYER_DATA_H +#define POKEDIAMOND_PLAYER_DATA_H + +#include "options.h" +#include "igt.h" + +struct SaveBlock2; + +struct PlayerData +{ + /* 0x00 */ u16 playerName[OT_NAME_LENGTH + 1]; + /* 0x10 */ u32 playerId; + /* 0x14 */ u32 money; + /* 0x18 */ u8 gender; + /* 0x19 */ u8 language; + /* 0x1A */ u8 badges; + /* 0x1B */ u8 avatar; + /* 0x1C */ u8 field_1C; + /* 0x1D */ u8 field_1D_0:1; + u8 field_1D_1:1; + u8 field_1D_pad:6; + /* 0x1E */ u8 padding_1E[2]; +}; + +struct PlayerDataSav +{ + struct Options options; + u8 padding[2]; + struct PlayerData data; + u16 coins; + struct IGT igt; + u8 padding2[2]; +}; + +struct Options * Sav2_PlayerData_GetOptionsAddr(struct SaveBlock2 *); +struct String * PlayerProfile_GetPlayerName_NewString(struct PlayerData *, u32 heap_id); +u32 PlayerProfile_GetTrainerID(struct PlayerData *); +u32 PlayerProfile_GetTrainerGender(struct PlayerData *); + +#endif //POKEDIAMOND_PLAYER_DATA_H diff --git a/include/pokemon.h b/include/pokemon.h index 2387ef78..1ab3c401 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -303,7 +303,7 @@ int LowestFlagNo(u32 mask); BOOL IsPokemonLegendaryOrMythical(u16 species); u16 GetLegendaryMon(u32 idx); BOOL FUN_0206A998(struct Pokemon * pokemon); -BOOL FUN_0206A9AC(struct BoxPokemon * boxmon, struct SaveBlock2 * sb2, u32 heap_id); +BOOL FUN_0206A9AC(struct BoxPokemon * boxmon, struct PlayerData * sb2, u32 heap_id); void FUN_0206AA84(struct Pokemon * pokemon); void FUN_0206AAB4(struct BoxPokemon * boxmon); diff --git a/include/proto.h b/include/proto.h index b45c2b48..fb2f8a78 100644 --- a/include/proto.h +++ b/include/proto.h @@ -16,7 +16,6 @@ void FUN_02005E80(int); void FUN_02005E90(int, int, int, int); void FUN_020056AC(int, int, int, int, int); void FUN_020808AC(struct BoxPokemon *, int, int, int, int); -void * FUN_02022610(void *, int); -void FUN_0200B7B8(u32 *, struct String *, struct String *); +void StringExpandPlaceholders(u32 *, struct String *, struct String *); #endif //POKEDIAMOND_PROTO_H diff --git a/include/save_block_2.h b/include/save_block_2.h index 38e11de4..fe052b1d 100644 --- a/include/save_block_2.h +++ b/include/save_block_2.h @@ -1,18 +1,47 @@ #ifndef POKEDIAMOND_SAVE_BLOCK_2_H #define POKEDIAMOND_SAVE_BLOCK_2_H -struct SaveBlock2 +#include "MATH_crc.h" +#include "player_data.h" + +struct SavArrayHeader { - u16 playerName[OT_NAME_LENGTH + 1]; - u32 playerId; - u8 filler_14[4]; - u8 gender; + u32 id; + u32 size; + u32 offset; + u16 field_C; + u16 field_E; +}; + +struct SaveBlock2_Sub_20464 { + u8 unk_0; u8 padding[3]; - // TODO: finish this struct + int unk_4; + int unk_8; + u8 unk_C; + u8 unk_D; + u8 unk_E; + u8 padding2; }; -struct String * FUN_020239A0(struct SaveBlock2 *, u32 heap_id); -u32 FUN_020239BC(struct SaveBlock2 *); -u32 FUN_020239CC(struct SaveBlock2 *); +struct SaveBlock2 +{ + /* 0x00000 */ int unk_00000; + /* 0x00004 */ int unk_00004; + /* 0x00008 */ int unk_00008; + /* 0x0000C */ int unk_0000C; + /* 0x00010 */ int unk_00010; + /* 0x00014 */ struct MATHCRC16Table unk_00014; + /* 0x00214 */ u8 dynamic_region[0x20000]; + /* 0x20214 */ int unk_20214; + /* 0x20218 */ u8 unk_20218[8]; + /* 0x20220 */ int unk_20220; + /* 0x20224 */ struct SavArrayHeader arrayHeaders[36]; + /* 0x20464 */ struct SaveBlock2_Sub_20464 unk_20464[4]; + /* 0x204A4 */ int unk_204A4; + // TODO: finish this struct +}; // size: 0x204A8 + +void * SavArray_get(struct SaveBlock2 *, int); #endif //POKEDIAMOND_SAVE_BLOCK_2_H diff --git a/include/script.h b/include/script.h index 494a9d9f..7c4dae6d 100644 --- a/include/script.h +++ b/include/script.h @@ -3,6 +3,7 @@ #include "global.h"
#include "msgdata.h"
+#include "save_block_2.h"
struct ScriptContext;
@@ -23,7 +24,7 @@ struct ScriptContext u32 unk74;
struct MsgData * unk78;
u8 *unk7C;
- void * unk80;
+ struct SaveBlock2 * unk80;
};
#define ScriptReadByte(ctx) (*(ctx->scriptPtr++))
diff --git a/include/sound.h b/include/sound.h index a79e6ecf..6e78bfa4 100644 --- a/include/sound.h +++ b/include/sound.h @@ -3,7 +3,7 @@ #include "FS_file.h" #include "sdat.h" -#include "options.h" +#include "save_block_2.h" struct SoundData { diff --git a/include/structs.h b/include/structs.h deleted file mode 100644 index fbcf6e0c..00000000 --- a/include/structs.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef POKEDIAMOND_STRUCTS_H -#define POKEDIAMOND_STRUCTS_H - -#include "pokemon.h" -#include "map.h" - -// MATH -typedef u16 MATHCRC16Table[256]; - -struct UnkStruct_021C59C8_Sub20224 { - int unk_0; - int unk_4; - int unk_8; - u16 unk_C; - u16 unk_E; -}; - -struct UnkStruct_021C59C8_Sub_20464 { - u8 unk_0; - u8 padding[3]; - int unk_4; - int unk_8; - u8 unk_C; - u8 unk_D; - u8 unk_E; - u8 padding2; -}; - -struct UnkStruct_021C59C8 { - /* 0x00000 */ int unk_00000; - /* 0x00004 */ int unk_00004; - /* 0x00008 */ int unk_00008; - /* 0x0000C */ int unk_0000C; - /* 0x00010 */ int unk_00010; - /* 0x00014 */ MATHCRC16Table unk_00014; - /* 0x00214 */ u8 filler_00214[0x2004]; - /* 0x20218 */ u8 unk_20218[8]; - /* 0x20220 */ int unk_20220; - /* 0x20224 */ struct UnkStruct_021C59C8_Sub20224 unk_20224[36]; - /* 0x20464 */ struct UnkStruct_021C59C8_Sub_20464 unk_20464[4]; - /* 0x204A4 */ int unk_204A4; -}; - -#endif //POKEDIAMOND_STRUCTS_H |