diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/battle.h | 27 | ||||
-rw-r--r-- | include/battle_ai.h | 5 | ||||
-rw-r--r-- | include/battle_anim.h | 7 | ||||
-rw-r--r-- | include/field_map_obj.h | 2 | ||||
-rw-r--r-- | include/gba/defines.h | 9 | ||||
-rw-r--r-- | include/gba/flash_internal.h | 10 | ||||
-rw-r--r-- | include/global.h | 18 | ||||
-rw-r--r-- | include/pokemon.h | 6 | ||||
-rw-r--r-- | include/rom3.h | 8 | ||||
-rw-r--r-- | include/save.h | 2 | ||||
-rw-r--r-- | include/sprite.h | 2 | ||||
-rw-r--r-- | include/string_util.h | 2 |
12 files changed, 70 insertions, 28 deletions
diff --git a/include/battle.h b/include/battle.h index f973849b7..dc9ac93cc 100644 --- a/include/battle.h +++ b/include/battle.h @@ -686,6 +686,32 @@ extern u8 ewram[]; #define ewram17840 (*(struct Struct2017840 *) (ewram + 0x17840)) #define ewram17000 ((u32 *) (ewram + 0x17100)) +// used in many battle files, it seems as though Hisashi Sogabe wrote +// some sort of macro to replace the use of actually calling memset. +// Perhaps it was thought calling memset was much slower? + +// The compiler wont allow us to locally declare ptr in this macro; some +// functions that invoke this macro will not match without this egregeous +// assumption about the variable names, so in order to avoid this assumption, +// we opt to pass the variables themselves, even though it is likely that +// Sogabe assumed the variables were named src and dest. Trust me: I tried to +// avoid assuming variable names, but the ROM just will not match without the +// assumptions. Therefore, these macros are bad practice, but I'm putting them +// here anyway. +#define MEMSET_ALT(data, c, size, var, dest) \ +{ \ + dest = (u8 *)data; \ + for(var = 0; var < (u32)size; var++) \ + dest[var] = c; \ +} \ + +#define MEMCPY_ALT(data, dest, size, var, src) \ +{ \ + src = (u8 *)data; \ + for(var = 0; var < (u32)size; var++) \ + dest[var] = src[var]; \ +} \ + typedef void (*BattleCmdFunc)(void); struct funcStack @@ -725,7 +751,6 @@ void EmitEffectivenessSound(u8 a, u16 sound); //0x2B void Emitcmd44(u8 a, u16 sound); //0x2C void EmitFaintingCry(u8 a); //0x2D void EmitIntroSlide(u8 a, u8 b); //0x2E -void Emitcmd48(u8 a, u8 *b, u8 c); //0x30 void Emitcmd49(u8 a); //0x31 void EmitSpriteInvisibility(u8 a, u8 b); //0x33 void EmitBattleAnimation(u8 a, u8 b, u16 c); //0x34 diff --git a/include/battle_ai.h b/include/battle_ai.h index 2922da0b3..60ca5d000 100644 --- a/include/battle_ai.h +++ b/include/battle_ai.h @@ -1,11 +1,6 @@ #ifndef GUARD_BATTLEAI_H #define GUARD_BATTLEAI_H -#define AIScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24) -#define AIScriptRead16(ptr) ((ptr)[0] | (ptr)[1] << 8) -#define AIScriptRead8(ptr) ((ptr)[0]) -#define AIScriptReadPtr(ptr) (u8*) AIScriptRead32(ptr) - enum { TARGET, diff --git a/include/battle_anim.h b/include/battle_anim.h index 2386c515c..3db5ae967 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -3,10 +3,6 @@ #include "sprite.h" -#define SCRIPT_READ_8(ptr) ((ptr)[0]) -#define SCRIPT_READ_16(ptr) ((ptr)[0] | ((ptr)[1] << 8)) -#define SCRIPT_READ_32(ptr) ((ptr)[0] + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24)) - #define REG_BGnCNT_BITFIELD(n) (*(struct BGCntrlBitfield *)REG_ADDR_BG##n##CNT) #define REG_BG1CNT_BITFIELD REG_BGnCNT_BITFIELD(1) #define REG_BG2CNT_BITFIELD REG_BGnCNT_BITFIELD(2) @@ -55,13 +51,12 @@ struct UnknownStruct3 void DoMoveAnim(const u8 *const moveAnims[], u16 b, u8 c); bool8 IsAnimBankSpriteVisible(u8 a); void sub_8076034(u8, u8); -bool8 IsContest(void); +bool8 NotInBattle(void); void battle_anim_clear_some_data(void); void move_anim_8072740(struct Sprite *sprite); void DestroyAnimVisualTask(u8 task); void DestroyAnimVisualTask(u8 task); bool8 IsAnimBankSpriteVisible(u8); -u8 IsContest(); #endif diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 19482e71f..8e1fdc8bd 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -344,7 +344,7 @@ void FieldObjectTurnByLocalIdAndMap(u8, u8, u8, u8); const struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8); void FieldObjectHandleDynamicGraphicsId(struct MapObject *); void npc_by_local_id_and_map_set_field_1_bit_x20(u8, u8, u8, u8); -void FieldObjectGetLocalIdAndMap(struct MapObject *, u8 *, u8 *, u8 *); +void FieldObjectGetLocalIdAndMap(struct MapObject *, void *, void *, void *); void sub_805BCC0(s16 x, s16 y); void sub_805BCF0(u8, u8, u8, u8); void sub_805BD48(u8, u8, u8); diff --git a/include/gba/defines.h b/include/gba/defines.h index 0f7f06755..7fd429d9e 100644 --- a/include/gba/defines.h +++ b/include/gba/defines.h @@ -29,15 +29,16 @@ #define BG_VRAM VRAM #define BG_VRAM_SIZE 0x10000 -#define BG_CHAR_ADDR(n) (BG_VRAM + (0x4000 * (n))) -#define BG_SCREEN_ADDR(n) (BG_VRAM + (0x800 * (n))) +#define BG_CHAR_ADDR(n) (void *)(BG_VRAM + (0x4000 * (n))) +#define BG_SCREEN_ADDR(n) (void *)(BG_VRAM + (0x800 * (n))) +#define BG_TILE_ADDR(n) (void *)(BG_VRAM + (0x80 * (n))) // text-mode BG -#define OBJ_VRAM0 (VRAM + 0x10000) +#define OBJ_VRAM0 (void *)(VRAM + 0x10000) #define OBJ_VRAM0_SIZE 0x8000 // bitmap-mode BG -#define OBJ_VRAM1 (VRAM + 0x14000) +#define OBJ_VRAM1 (void *)(VRAM + 0x14000) #define OBJ_VRAM1_SIZE 0x4000 #define OAM 0x7000000 diff --git a/include/gba/flash_internal.h b/include/gba/flash_internal.h index cbcfb5466..39e14ef73 100644 --- a/include/gba/flash_internal.h +++ b/include/gba/flash_internal.h @@ -35,7 +35,7 @@ struct FlashType { struct FlashSetupInfo { u16 (*programFlashByte)(u16, u32, u8); - u16 (*programFlashSector)(u16, u8 *); + u16 (*programFlashSector)(u16, void *); u16 (*eraseFlashChip)(void); u16 (*eraseFlashSector)(u16); u16 (*WaitForFlashWrite)(u8, u8 *, u8); @@ -46,7 +46,7 @@ struct FlashSetupInfo extern u16 gFlashNumRemainingBytes; extern u16 (*ProgramFlashByte)(u16, u32, u8); -extern u16 (*ProgramFlashSector)(u16, u8 *); +extern u16 (*ProgramFlashSector)(u16, void *); extern u16 (*EraseFlashChip)(void); extern u16 (*EraseFlashSector)(u16); extern u16 (*WaitForFlashWrite)(u8, u8 *, u8); @@ -67,15 +67,15 @@ void SetReadFlash1(u16 *dest); void StopFlashTimer(void); u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void)); u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src); -void ReadFlash(u16 sectorNum, u32 offset, u8 *dest, u32 size); -u32 ProgramFlashSectorAndVerifyNBytes(u16 sectorNum, u8 *src, u32 n); +void ReadFlash(u16 sectorNum, u32 offset, void *dest, u32 size); +u32 ProgramFlashSectorAndVerifyNBytes(u16 sectorNum, void *dataSrc, u32 n); u16 WaitForFlashWrite_Common(u8 phase, u8 *addr, u8 lastData); u16 EraseFlashChip_MX(void); u16 EraseFlashSector_MX(u16 sectorNum); u16 ProgramFlashByte_MX(u16 sectorNum, u32 offset, u8 data); -u16 ProgramFlashSector_MX(u16 sectorNum, u8 *src); +u16 ProgramFlashSector_MX(u16 sectorNum, void *src); // agb_flash_1m u16 IdentifyFlash(void); diff --git a/include/global.h b/include/global.h index 29804a5a9..647f66bc8 100644 --- a/include/global.h +++ b/include/global.h @@ -55,6 +55,24 @@ enum B_32 = 4 }; +// There are many quirks in the source code which have overarching behavioral differences from +// a number of other files. For example, diploma.c seems to declare rodata before each use while +// other files declare out of order and must be at the beginning. There are also a number of +// macros which differ from one file to the next due to the method of obtaining the result, such +// as these below. Because of this, there is a theory (Two Team Theory) that states that these +// programming projects had more than 1 "programming team" which utilized different macros for +// each of the files that were worked on. +#define T1_READ_8(ptr) ((ptr)[0]) +#define T1_READ_16(ptr) ((ptr)[0] | ((ptr)[1] << 8)) +#define T1_READ_32(ptr) ((ptr)[0] | ((ptr)[1] << 8) | ((ptr)[2] << 16) | ((ptr)[3] << 24)) +#define T1_READ_PTR(ptr) (u8*) T1_READ_32(ptr) + +// T2_READ_8 is a duplicate to remain consistent with each group. +#define T2_READ_8(ptr) ((ptr)[0]) +#define T2_READ_16(ptr) ((ptr)[0] + ((ptr)[1] << 8)) +#define T2_READ_32(ptr) ((ptr)[0] + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24)) +#define T2_READ_PTR(ptr) (void*) T2_READ_32(ptr) + enum { VERSION_SAPPHIRE = 1, diff --git a/include/pokemon.h b/include/pokemon.h index 572862b8f..7fc8e181f 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -541,11 +541,13 @@ union PokemonSubstruct *GetSubstruct(struct BoxPokemon *boxMon, u32 personality, // but they are not used since some code erroneously omits the third arg. // u32 GetMonData(struct Pokemon *mon, s32 field, u8 *data); // u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data); +// void SetMonData(struct Pokemon *mon, s32 field, const void *dataArg); +// void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg); u32 GetMonData(); u32 GetBoxMonData(); +void SetMonData(); +void SetBoxMonData(); -void SetMonData(struct Pokemon *mon, s32 field, const u8 *data); -void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const u8 *data); void CopyMon(void *dest, void *src, size_t size); u8 GiveMonToPlayer(struct Pokemon *mon); u8 SendMonToPC(struct Pokemon *mon); diff --git a/include/rom3.h b/include/rom3.h index 81bb56df1..19c6def25 100644 --- a/include/rom3.h +++ b/include/rom3.h @@ -1,6 +1,12 @@ #ifndef GUARD_ROM3_H #define GUARD_ROM3_H +struct HpAndStatus +{ + u16 hp; + u32 status; +}; + struct DisableStruct; void sub_800B858(void); @@ -55,7 +61,7 @@ void Emitcmd44(u8 a, u16 b); void EmitFaintingCry(u8 a); void EmitIntroSlide(u8 a, u8 b); void EmitTrainerBallThrow(u8 a); -void Emitcmd48(u8 a, u8 *b, u8 c); +void EmitDrawPartyStatusSummary(u8 a, struct HpAndStatus *hpAndStatus, u8 c); //0x30 void Emitcmd49(u8 a); void Emitcmd50(u8 a); void EmitSpriteInvisibility(u8 a, u8 b); diff --git a/include/save.h b/include/save.h index 6c47c6f60..c35ad547a 100644 --- a/include/save.h +++ b/include/save.h @@ -3,7 +3,7 @@ struct SaveSectionLocation { - void *data; + u8 *data; u16 size; }; diff --git a/include/sprite.h b/include/sprite.h index 769e1584d..38687ebd8 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -252,7 +252,7 @@ void SetOamMatrix(u8 matrixNum, u16 a, u16 b, u16 c, u16 d); void CalcCenterToCornerVec(struct Sprite *sprite, u8 shape, u8 size, u8 affineMode); void SpriteCallbackDummy(struct Sprite *sprite); void ProcessSpriteCopyRequests(void); -void RequestSpriteCopy(const u8 *src, u8 *dest, u16 size); +void RequestSpriteCopy(const void *src, u8 *dest, u16 size); void FreeSpriteTiles(struct Sprite *sprite); void FreeSpritePalette(struct Sprite *sprite); void FreeSpriteOamMatrix(struct Sprite *sprite); diff --git a/include/string_util.h b/include/string_util.h index 7a4bfa4c1..55fa988b4 100644 --- a/include/string_util.h +++ b/include/string_util.h @@ -29,7 +29,7 @@ u8 *ConvertIntToHexStringN(u8 *dest, s32 value, enum StringConvertMode mode, u8 u8 *ConvertIntToDecimalString(u8 *dest, s32 value); u8 *StringExpandPlaceholders(u8 *dest, const u8 *src); u8 *StringBraille(u8 *dest, const u8 *src); -u8 *GetExpandedPlaceholder(u32 id); +const u8 *GetExpandedPlaceholder(u32 id); u8 *StringFill(u8 *dest, u8 c, u16 n); u8 *StringCopyPadded(u8 *dest, const u8 *src, u8 c, u16 n); u8 *StringFillWithTerminator(u8 *dest, u16 n); |