From ef2971d8dcc0768265d9b8c0eec40ea55251db8b Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 1 Nov 2021 01:42:02 -0400 Subject: Convert GF ROM header to C --- include/item.h | 1 + include/pokeball.h | 2 ++ include/pokemon_icon.h | 2 ++ 3 files changed, 5 insertions(+) (limited to 'include') diff --git a/include/item.h b/include/item.h index 87ff57bc7..ceca83bd5 100644 --- a/include/item.h +++ b/include/item.h @@ -29,6 +29,7 @@ struct BagPocket u8 capacity; }; +extern const struct Item gItems[]; extern struct BagPocket gBagPockets[]; void ApplyNewEncryptionKeyToBagItems(u32 newKey); diff --git a/include/pokeball.h b/include/pokeball.h index d88e80173..297788db1 100644 --- a/include/pokeball.h +++ b/include/pokeball.h @@ -26,6 +26,8 @@ enum { BALL_AFFINE_ANIM_4 }; +extern const struct CompressedSpriteSheet gBallSpriteSheets[]; +extern const struct CompressedSpritePalette gBallSpritePalettes[]; extern const struct SpriteTemplate gBallSpriteTemplates[]; #define POKEBALL_PLAYER_SENDOUT 0xFF diff --git a/include/pokemon_icon.h b/include/pokemon_icon.h index 4731da90e..9b917c3bf 100644 --- a/include/pokemon_icon.h +++ b/include/pokemon_icon.h @@ -2,6 +2,8 @@ #define GUARD_POKEMON_ICON_H extern const u8 gMonIconPaletteIndices[]; +extern const u8 *const gMonIconTable[]; +extern const struct SpritePalette gMonIconPaletteTable[]; const u8 *GetMonIconTiles(u16 species, bool32); void TryLoadAllMonIconPalettesAtOffset(u16 offset); -- cgit v1.2.3 From 9a0618afc3f7ccf8a5d19ee5815fd388003d4a95 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 3 Nov 2021 15:29:18 -0400 Subject: Add COPYWIN constants --- include/menu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/menu.h b/include/menu.h index eb391e565..cc65a51dc 100644 --- a/include/menu.h +++ b/include/menu.h @@ -123,7 +123,7 @@ void sub_8198314(void); void sub_8198180(const u8 *string, u8 a2, bool8 copyToVram); void ResetBgPositions(void); void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonPress, u8 speed); -void sub_8198C78(void); +void EraseYesNoWindow(void); void PrintTextArray(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs); void Menu_LoadStdPal(void); -- cgit v1.2.3 From 085f8adec62be6a1ecf7b4389148867408b30bed Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 3 Nov 2021 16:06:58 -0400 Subject: Start remaining menu documentation --- include/graphics.h | 8 ++++---- include/menu.h | 19 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/graphics.h b/include/graphics.h index a58b0f0f1..eeb8f65a3 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -3855,10 +3855,10 @@ extern const u32 gItemIcon_ReturnToFieldArrow[]; extern const u32 gItemIconPalette_ReturnToFieldArrow[]; //menu graphics -extern const u16 gFireRedMenuElements1_Pal[16]; -extern const u16 gFireRedMenuElements2_Pal[16]; -extern const u16 gFireRedMenuElements3_Pal[16]; -extern const u8 gFireRedMenuElements_Gfx[]; +extern const u16 gMenuInfoElements1_Pal[16]; +extern const u16 gMenuInfoElements2_Pal[16]; +extern const u16 gMenuInfoElements3_Pal[16]; +extern const u8 gMenuInfoElements_Gfx[]; // item menu graphics extern const u32 gBagScreen_Gfx[]; diff --git a/include/menu.h b/include/menu.h index cc65a51dc..3f9ccd721 100644 --- a/include/menu.h +++ b/include/menu.h @@ -66,7 +66,7 @@ void SetWindowTemplateFields(struct WindowTemplate* template, u8 priority, u8 ti void DrawStdFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 tileStart, u8 palette); void ScheduleBgCopyTilemapToVram(u8 bgNum); void PrintMenuTable(u8 windowId, u8 itemCount, const struct MenuAction *strs); -u8 InitMenuInUpperLeftCornerPlaySoundWhenAPressed(u8 windowId, u8 numItems, u8 initialCursorPos); +u8 InitMenuInUpperLeftCornerNormal(u8 windowId, u8 numItems, u8 initialCursorPos); u8 Menu_GetCursorPos(void); s8 Menu_ProcessInput(void); s8 Menu_ProcessInputNoWrap(void); @@ -85,7 +85,6 @@ void AddTextPrinterParameterized4(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterS void DrawDialogFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 a2, u8 a3); void sub_81995E4(u8 windowId, u8 optionsNo, const struct MenuAction *actions, const u8 *actionIds); void ClearDialogWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram); -u16 sub_8198AA4(u8, u8, u8, u8, u8, u8, u16); void *malloc_and_decompress(const void *src, u32 *sizeOut); u16 copy_decompressed_tile_data_to_vram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode); void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress); @@ -98,8 +97,8 @@ void ListMenuLoadStdPalAt(u8, u8); u8 Menu_MoveCursor(s8 cursorDelta); u8 Menu_MoveCursorNoWrapAround(s8 cursorDelta); void DrawStdWindowFrame(u8 windowId, bool8 CopyToVram); -u8 sub_81979C4(u8 a1); -u8 sub_81983AC(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos); +u8 AddStartMenuWindow(u8 numActions); +u8 InitMenuNormal(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos); void sub_819786C(u8 windowId, bool8 copyToVram); void AddTextPrinterForMessage_2(bool8 allowSkippingDelayWithButtonPress); void RemoveStartMenuWindow(void); @@ -111,20 +110,20 @@ u8 AddMapNamePopUpWindow(void); void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16), u8 letterSpacing, u8 lineSpacing); void SetBgTilemapPalette(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette); void sub_8199D3C(void *ptr, int delta, int width, int height, bool32 is8BPP); -void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyToVram); -void sub_8197AE8(bool8 copyToVram); +void EraseFieldMessageBox(bool8 copyToVram); void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const struct MenuAction *strs); s8 Menu_ProcessInputGridLayout(void); u8 InitMenuInUpperLeftCorner(u8 windowId, u8 itemCount, u8 initialCursorPos, bool8 APressMuted); s8 Menu_ProcessInputNoWrapAround_other(void); void CopyToBufferFromBgTilemap(u8 bgId, u16 *dest, u8 left, u8 top, u8 width, u8 height); -u8 sub_81980F0(u8 bg, u8 xPos, u8 yPos, u8 palette, u16 baseTile); -void sub_8198314(void); -void sub_8198180(const u8 *string, u8 a2, bool8 copyToVram); +u8 HofPCTopBar_AddWindow(u8 bg, u8 xPos, u8 yPos, u8 palette, u16 baseTile); +void HofPCTopBar_RemoveWindow(void); +void HofPCTopBar_Print(const u8 *string, u8 left, bool8 copyToVram); +void HofPCTopBar_PrintPair(const u8 *string, const u8 *string2, bool8 noBg, u8 left, bool8 copyToVram); void ResetBgPositions(void); void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonPress, u8 speed); void EraseYesNoWindow(void); -void PrintTextArray(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs); +void PrintMenuActionTextsAtPos(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs); void Menu_LoadStdPal(void); #endif // GUARD_MENU_H -- cgit v1.2.3 From d6f873ba69af5e4dd9733c2f9f3f75be0d4c6816 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 3 Nov 2021 20:28:43 -0400 Subject: Continue menu documentation --- include/menu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/menu.h b/include/menu.h index 3f9ccd721..7ecb04e53 100644 --- a/include/menu.h +++ b/include/menu.h @@ -109,7 +109,7 @@ u8 GetMapNamePopUpWindowId(void); u8 AddMapNamePopUpWindow(void); void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16), u8 letterSpacing, u8 lineSpacing); void SetBgTilemapPalette(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette); -void sub_8199D3C(void *ptr, int delta, int width, int height, bool32 is8BPP); +void AddValToTilemapBuffer(void *ptr, int delta, int width, int height, bool32 is8BPP); void EraseFieldMessageBox(bool8 copyToVram); void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const struct MenuAction *strs); s8 Menu_ProcessInputGridLayout(void); -- cgit v1.2.3 From 17b657d83a29919253675b06c12a9ea5471385b2 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 3 Nov 2021 23:20:59 -0400 Subject: Finish menu documentation --- include/menu.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/menu.h b/include/menu.h index 7ecb04e53..69000d408 100644 --- a/include/menu.h +++ b/include/menu.h @@ -59,7 +59,7 @@ u32 GetPlayerTextSpeed(void); u8 GetPlayerTextSpeedDelay(void); void Menu_LoadStdPalAt(u16 arg0); void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextPrinterTemplate *, u16)); -void sub_8199DF0(u32 bg, u8 a1, int a2, int a3); +void BgDmaFill(u32 bg, u8 a1, int a2, int a3); void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const u8 *color, s8 speed, const u8 *str); void ClearStdWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram); void SetWindowTemplateFields(struct WindowTemplate* template, u8 priority, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 palNum, u16 baseBlock); @@ -83,15 +83,15 @@ void DoScheduledBgTilemapCopiesToVram(void); void ClearScheduledBgCopiesToVram(void); void AddTextPrinterParameterized4(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, const u8 *color, s8 speed, const u8 *str); void DrawDialogFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 a2, u8 a3); -void sub_81995E4(u8 windowId, u8 optionsNo, const struct MenuAction *actions, const u8 *actionIds); +void PrintMenuActionTextsInUpperLeftCorner(u8 windowId, u8 optionsNo, const struct MenuAction *actions, const u8 *actionIds); void ClearDialogWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram); void *malloc_and_decompress(const void *src, u32 *sizeOut); u16 copy_decompressed_tile_data_to_vram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode); void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress); -void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a8); +void PrintMenuActionTexts(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a8); void PrintMenuActionGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8); u8 InitMenuActionGrid(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCursorPos); -u8 ChangeListMenuCursorPosition(s8 deltaX, s8 deltaY); +u8 ChangeMenuGridCursorPosition(s8 deltaX, s8 deltaY); u8 GetStartMenuWindowId(void); void ListMenuLoadStdPalAt(u8, u8); u8 Menu_MoveCursor(s8 cursorDelta); @@ -99,7 +99,7 @@ u8 Menu_MoveCursorNoWrapAround(s8 cursorDelta); void DrawStdWindowFrame(u8 windowId, bool8 CopyToVram); u8 AddStartMenuWindow(u8 numActions); u8 InitMenuNormal(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos); -void sub_819786C(u8 windowId, bool8 copyToVram); +void LoadMessageBoxAndFrameGfx(u8 windowId, bool8 copyToVram); void AddTextPrinterForMessage_2(bool8 allowSkippingDelayWithButtonPress); void RemoveStartMenuWindow(void); void DisplayYesNoMenuWithDefault(u8 initialCursorPos); @@ -112,7 +112,7 @@ void SetBgTilemapPalette(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palet void AddValToTilemapBuffer(void *ptr, int delta, int width, int height, bool32 is8BPP); void EraseFieldMessageBox(bool8 copyToVram); void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const struct MenuAction *strs); -s8 Menu_ProcessInputGridLayout(void); +s8 Menu_ProcessGridInput(void); u8 InitMenuInUpperLeftCorner(u8 windowId, u8 itemCount, u8 initialCursorPos, bool8 APressMuted); s8 Menu_ProcessInputNoWrapAround_other(void); void CopyToBufferFromBgTilemap(u8 bgId, u16 *dest, u8 left, u8 top, u8 width, u8 height); -- cgit v1.2.3 From 0fe38819616372d8de160fbd2ab8c38c2a109540 Mon Sep 17 00:00:00 2001 From: cbt6 <91667135+cbt6@users.noreply.github.com> Date: Fri, 5 Nov 2021 01:54:34 +0800 Subject: Rename WalkInPlaceFastest to WalkInPlaceFaster --- include/constants/event_object_movement.h | 8 ++++---- include/event_object_movement.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/constants/event_object_movement.h b/include/constants/event_object_movement.h index 9611d008b..2c4273524 100755 --- a/include/constants/event_object_movement.h +++ b/include/constants/event_object_movement.h @@ -121,10 +121,10 @@ #define MOVEMENT_ACTION_WALK_IN_PLACE_FAST_UP 0x22 #define MOVEMENT_ACTION_WALK_IN_PLACE_FAST_LEFT 0x23 #define MOVEMENT_ACTION_WALK_IN_PLACE_FAST_RIGHT 0x24 -#define MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_DOWN 0x25 -#define MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_UP 0x26 -#define MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_LEFT 0x27 -#define MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_RIGHT 0x28 +#define MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_DOWN 0x25 +#define MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_UP 0x26 +#define MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_LEFT 0x27 +#define MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_RIGHT 0x28 #define MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN 0x29 #define MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP 0x2A #define MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT 0x2B diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 9ed524e66..6ad4b55e4 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -121,7 +121,7 @@ void InitObjectEventPalettes(u8 palSlot); void UpdateObjectEventCurrentMovement(struct ObjectEvent *, struct Sprite *, bool8(struct ObjectEvent *, struct Sprite *)); u8 ObjectEventFaceOppositeDirection(struct ObjectEvent *, u8); u8 GetOppositeDirection(u8); -u8 GetWalkInPlaceFastestMovementAction(u32); +u8 GetWalkInPlaceFasterMovementAction(u32); u8 GetWalkInPlaceFastMovementAction(u32); u8 GetWalkInPlaceNormalMovementAction(u32); u8 GetWalkInPlaceSlowMovementAction(u32); -- cgit v1.2.3 From e65677c944b786c8f94adc8c962b7ee180bfe548 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 4 Nov 2021 17:28:41 -0400 Subject: Update modern linker script --- include/crt0.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include') diff --git a/include/crt0.h b/include/crt0.h index 3121eeaed..a4a5c7f79 100644 --- a/include/crt0.h +++ b/include/crt0.h @@ -1,11 +1,6 @@ #ifndef GUARD_CRT0_H #define GUARD_CRT0_H -// Exported type declarations - -// Exported RAM declarations - -// Exported ROM declarations extern u32 IntrMain[]; #endif //GUARD_CRT0_H -- cgit v1.2.3 From 54b254a829d973345b0d282b7a4ffd7458a5c7da Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 7 Nov 2021 12:58:11 -0500 Subject: Add CRY_MODE constants --- include/constants/sound.h | 41 +++++++++++++++++++++++++++++++++++++++++ include/sound.h | 21 +-------------------- 2 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 include/constants/sound.h (limited to 'include') diff --git a/include/constants/sound.h b/include/constants/sound.h new file mode 100644 index 000000000..82cc4ffac --- /dev/null +++ b/include/constants/sound.h @@ -0,0 +1,41 @@ +#ifndef GUARD_CONSTANTS_SOUND_H +#define GUARD_CONSTANTS_SOUND_H + +#define FANFARE_LEVEL_UP 0 +#define FANFARE_OBTAIN_ITEM 1 +#define FANFARE_EVOLVED 2 +#define FANFARE_OBTAIN_TMHM 3 +#define FANFARE_HEAL 4 +#define FANFARE_OBTAIN_BADGE 5 +#define FANFARE_MOVE_DELETED 6 +#define FANFARE_OBTAIN_BERRY 7 +#define FANFARE_AWAKEN_LEGEND 8 +#define FANFARE_SLOTS_JACKPOT 9 +#define FANFARE_SLOTS_WIN 10 +#define FANFARE_TOO_BAD 11 +#define FANFARE_RG_POKE_FLUTE 12 +#define FANFARE_RG_OBTAIN_KEY_ITEM 13 +#define FANFARE_RG_DEX_RATING 14 +#define FANFARE_OBTAIN_B_POINTS 15 +#define FANFARE_OBTAIN_SYMBOL 16 +#define FANFARE_REGISTER_MATCH_CALL 17 + +#define CRY_MODE_NORMAL 0 // Default +#define CRY_MODE_DOUBLES 1 // Shortened cry for double battles +#define CRY_MODE_ENCOUNTER 2 // Used when starting a static encounter, or when a Pokémon is "aggressive" +#define CRY_MODE_HIGH_PITCH 3 // Highest pitch mode, used exclusively by the move Howl +#define CRY_MODE_ECHO_END 4 // For 2nd cry used by the move Hyper Voice. Played in reverse +#define CRY_MODE_FAINT 5 // Used when a Pokémon faints +#define CRY_MODE_ECHO_START 6 // For 1st cry used by the move Hyper Voice +#define CRY_MODE_ROAR_1 7 // For 1st cry used by the move Roar +#define CRY_MODE_ROAR_2 8 // For 2nd cry used by the move Roar +#define CRY_MODE_GROWL_1 9 // For 1st cry used by the move Growl. Played in reverse +#define CRY_MODE_GROWL_2 10 // For 2nd cry used by the move Growl +#define CRY_MODE_WEAK 11 // Used when a Pokémon is unhealthy +#define CRY_MODE_WEAK_DOUBLES 12 // Equivalent to CRY_MODE_DOUBLES for CRY_MODE_WEAK + +// Given to SoundTask_PlayDoubleCry to determine which cry mode to use. Values are arbitrary +#define DOUBLE_CRY_ROAR 2 +#define DOUBLE_CRY_GROWL 255 + +#endif // GUARD_CONSTANTS_SOUND_H diff --git a/include/sound.h b/include/sound.h index 25ffa2d6e..5b34b69ba 100644 --- a/include/sound.h +++ b/include/sound.h @@ -1,26 +1,7 @@ #ifndef GUARD_SOUND_H #define GUARD_SOUND_H -enum { - FANFARE_LEVEL_UP, - FANFARE_OBTAIN_ITEM, - FANFARE_EVOLVED, - FANFARE_OBTAIN_TMHM, - FANFARE_HEAL, - FANFARE_OBTAIN_BADGE, - FANFARE_MOVE_DELETED, - FANFARE_OBTAIN_BERRY, - FANFARE_AWAKEN_LEGEND, - FANFARE_SLOTS_JACKPOT, - FANFARE_SLOTS_WIN, - FANFARE_TOO_BAD, - FANFARE_RG_POKE_FLUTE, - FANFARE_RG_OBTAIN_KEY_ITEM, - FANFARE_RG_DEX_RATING, - FANFARE_OBTAIN_B_POINTS, - FANFARE_OBTAIN_SYMBOL, - FANFARE_REGISTER_MATCH_CALL, -}; +#include "constants/sound.h" void InitMapMusic(void); void MapMusicMain(void); -- cgit v1.2.3 From c4169cfd290dcf7703b79debd66142b277af5613 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 7 Nov 2021 13:54:44 -0500 Subject: Disambiguate cry functions --- include/constants/sound.h | 7 +++++++ include/sound.h | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/constants/sound.h b/include/constants/sound.h index 82cc4ffac..40c3b7d58 100644 --- a/include/constants/sound.h +++ b/include/constants/sound.h @@ -38,4 +38,11 @@ #define DOUBLE_CRY_ROAR 2 #define DOUBLE_CRY_GROWL 255 +#define CRY_PRIORITY_NORMAL 10 +#define CRY_PRIORITY_AMBIENT 1 + +// Cry volume was changed from 125 in R/S to 120 for FRLG/Em, but was (accidentally?) not updated outside of sound.c +#define CRY_VOLUME 120 +#define CRY_VOLUME_RS 125 + #endif // GUARD_CONSTANTS_SOUND_H diff --git a/include/sound.h b/include/sound.h index 5b34b69ba..a5463a456 100644 --- a/include/sound.h +++ b/include/sound.h @@ -25,12 +25,12 @@ bool8 IsBGMPausedOrStopped(void); void FadeInBGM(u8 speed); void FadeOutBGM(u8 speed); bool8 IsBGMStopped(void); -void PlayCry1(u16 species, s8 pan); -void PlayCry2(u16 species, s8 pan, s8 volume, u8 priority); -void PlayCry3(u16 species, s8 pan, u8 mode); -void PlayCry4(u16 species, s8 pan, u8 mode); -void PlayCry5(u16 species, u8 mode); -void PlayCry6(u16 species, s8 pan, u8 mode); +void PlayCry_Normal(u16 species, s8 pan); +void PlayCry_NormalNoDucking(u16 species, s8 pan, s8 volume, u8 priority); +void PlayCry_ByMode(u16 species, s8 pan, u8 mode); +void PlayCry_ReleaseDouble(u16 species, s8 pan, u8 mode); +void PlayCry_Script(u16 species, u8 mode); +void PlayCry_DuckNoRestore(u16 species, s8 pan, u8 mode); void PlayCryInternal(u16 species, s8 pan, s8 volume, u8 priority, u8 mode); bool8 IsCryFinished(void); void StopCryAndClearCrySongs(void); -- cgit v1.2.3 From 684f599a4420c65635aa5e764ae06c2147968dfe Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 6 Nov 2021 11:41:47 -0400 Subject: Label remaining battle_interface symbols --- include/constants/battle.h | 3 +++ include/strings.h | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'include') diff --git a/include/constants/battle.h b/include/constants/battle.h index 2534ade4b..d87a800e2 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -358,4 +358,7 @@ // Flag for BattlePutTextOnWindow. Never set #define B_WIN_COPYTOVRAM (1 << 7) +// Indicator for the party summary bar to display an empty slot. +#define HP_EMPTY_SLOT 0xFFFF + #endif // GUARD_CONSTANTS_BATTLE_H diff --git a/include/strings.h b/include/strings.h index 7317f8aac..845e96a8c 100644 --- a/include/strings.h +++ b/include/strings.h @@ -611,6 +611,10 @@ extern const u8 gText_PlayersBattleResults[]; extern const u8 gText_WinLoseDraw[]; extern const u8 gText_ColorTransparent[]; extern const u8 gText_Slash[]; +extern const u8 gText_HealthboxNickname[]; +extern const u8 gText_HealthboxGender_None[]; +extern const u8 gText_HealthboxGender_Male[]; +extern const u8 gText_HealthboxGender_Female[]; extern const u8 gText_99TimesPlus[]; extern const u8 gText_1MinutePlus[]; -- cgit v1.2.3 From ab1074e629da97a7a68cc1babc0f4840858adb1b Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 1 Nov 2021 12:01:51 -0400 Subject: Label unknown palette functions --- include/palette.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'include') diff --git a/include/palette.h b/include/palette.h index be2a0dd48..81a1e1cae 100644 --- a/include/palette.h +++ b/include/palette.h @@ -58,15 +58,9 @@ void FillPalette(u16, u16, u16); void TransferPlttBuffer(void); u8 UpdatePaletteFade(void); void ResetPaletteFade(void); -void ReadPlttIntoBuffers(void); bool8 BeginNormalPaletteFade(u32, s8, u8, u8, u16); -bool8 unref_sub_8073D3C(u32, u8, u8, u8, u16); -void unref_sub_8073D84(u8, u32 *); -void ResetPaletteStructByUid(u16); -void ResetPaletteStruct(u8); +void PaletteStruct_ResetById(u16); void ResetPaletteFadeControl(void); -void unref_sub_8074168(u16); -void unref_sub_8074194(u16); void InvertPlttBuffer(u32); void TintPlttBuffer(u32, s8, s8, s8); void UnfadePlttBuffer(u32); -- cgit v1.2.3 From adf773f1ed272f31ae34e2613d20ec796b651bf8 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 28 Oct 2021 22:54:41 -0400 Subject: Document remainder of save.c --- include/load_save.h | 4 +- include/save.h | 129 ++++++++++++++++++++++++++-------------------------- 2 files changed, 67 insertions(+), 66 deletions(-) (limited to 'include') diff --git a/include/load_save.h b/include/load_save.h index 2f4a9ace6..14a979b45 100644 --- a/include/load_save.h +++ b/include/load_save.h @@ -24,8 +24,8 @@ void SavePlayerParty(void); void LoadPlayerParty(void); void SaveObjectEvents(void); void LoadObjectEvents(void); -void SaveSerializedGame(void); -void LoadSerializedGame(void); +void CopyPartyAndObjectsToSave(void); +void CopyPartyAndObjectsFromSave(void); void LoadPlayerBag(void); void SavePlayerBag(void); void ApplyNewEncryptionKeyToHword(u16 *hWord, u32 newKey); diff --git a/include/save.h b/include/save.h index 406e2e492..be7961136 100644 --- a/include/save.h +++ b/include/save.h @@ -1,43 +1,43 @@ #ifndef GUARD_SAVE_H #define GUARD_SAVE_H -struct SaveSectionLocation -{ - void *data; - u16 size; -}; - -struct SaveSection -{ - u8 data[0xFF4]; - u16 id; - u16 checksum; - u32 security; - u32 counter; -}; // size is 0x1000 - -// headless save section? -struct UnkSaveSection -{ - u8 data[0xFF4]; - u32 security; -}; // size is 0xFF8 - -struct SaveSectionOffsets -{ - u16 toAdd; - u16 size; -}; - -// Each 4 KiB flash sector contains 3968 bytes of actual data followed by a 128 byte footer +// Each 4 KiB flash sector contains 3968 bytes of actual data followed by a 128 byte footer. +// Only 12 bytes of the footer are used. #define SECTOR_DATA_SIZE 3968 #define SECTOR_FOOTER_SIZE 128 #define SECTOR_SIZE (SECTOR_DATA_SIZE + SECTOR_FOOTER_SIZE) #define NUM_SAVE_SLOTS 2 -#define UNKNOWN_CHECK_VALUE 0x8012025 -#define SPECIAL_SECTION_SENTINEL 0xB39D +// If the sector's security field is not this value then the sector is either invalid or empty. +#define SECTOR_SECURITY_NUM 0x8012025 + +#define SPECIAL_SECTOR_SENTINEL 0xB39D + +#define SECTOR_ID_SAVEBLOCK2 0 +#define SECTOR_ID_SAVEBLOCK1_START 1 +#define SECTOR_ID_SAVEBLOCK1_END 4 +#define SECTOR_ID_PKMN_STORAGE_START 5 +#define SECTOR_ID_PKMN_STORAGE_END 13 +#define NUM_SECTORS_PER_SLOT 14 +// Save Slot 1: 0-13; Save Slot 2: 14-27 +#define SECTOR_ID_HOF_1 28 +#define SECTOR_ID_HOF_2 29 +#define SECTOR_ID_TRAINER_HILL 30 +#define SECTOR_ID_RECORDED_BATTLE 31 +#define SECTORS_COUNT 32 + +#define NUM_HOF_SECTORS 2 + +#define SAVE_STATUS_EMPTY 0 +#define SAVE_STATUS_OK 1 +#define SAVE_STATUS_CORRUPT 2 +#define SAVE_STATUS_NO_FLASH 4 +#define SAVE_STATUS_ERROR 0xFF + +// Special sector id value for certain save functions to +// indicate that no specific sector should be used. +#define FULL_SAVE_SLOT 0xFFFF // SetDamagedSectorBits states enum @@ -51,7 +51,7 @@ enum enum { SAVE_NORMAL, - SAVE_LINK, + SAVE_LINK, // Link / Battle Frontier //EREADER_SAVE, // deprecated in Emerald SAVE_LINK2, // unknown 2nd link save SAVE_HALL_OF_FAME, @@ -59,54 +59,55 @@ enum SAVE_HALL_OF_FAME_ERASE_BEFORE // unused }; -#define SECTOR_ID_SAVEBLOCK2 0 -#define SECTOR_ID_SAVEBLOCK1_START 1 -#define SECTOR_ID_SAVEBLOCK1_END 4 -#define SECTOR_ID_PKMN_STORAGE_START 5 -#define SECTOR_ID_PKMN_STORAGE_END 13 -#define NUM_SECTORS_PER_SLOT 14 -// Save Slot 1: 0-13; Save Slot 2: 14-27 -#define SECTOR_ID_HOF_1 28 -#define SECTOR_ID_HOF_2 29 -#define SECTOR_ID_TRAINER_HILL 30 -#define SECTOR_ID_RECORDED_BATTLE 31 -#define SECTORS_COUNT 32 +// A save sector location holds a pointer to the data for a particular sector +// and the size of that data. Size cannot be greater than SECTOR_DATA_SIZE. +struct SaveSectorLocation +{ + void *data; + u16 size; +}; -#define SAVE_STATUS_EMPTY 0 -#define SAVE_STATUS_OK 1 -#define SAVE_STATUS_CORRUPT 2 -#define SAVE_STATUS_NO_FLASH 4 -#define SAVE_STATUS_ERROR 0xFF +struct SaveSector +{ + u8 data[SECTOR_DATA_SIZE]; + u8 unused[SECTOR_FOOTER_SIZE - 12]; // Unused portion of the footer + u16 id; + u16 checksum; + u32 security; + u32 counter; +}; // size is SECTOR_SIZE (0x1000) + +#define SECTOR_SECURITY_OFFSET offsetof(struct SaveSector, security) +#define SECTOR_COUNTER_OFFSET offsetof(struct SaveSector, counter) extern u16 gLastWrittenSector; extern u32 gLastSaveCounter; extern u16 gLastKnownGoodSector; extern u32 gDamagedSaveSectors; extern u32 gSaveCounter; -extern struct SaveSection *gFastSaveSection; -extern u16 gUnknown_03006208; +extern struct SaveSector *gFastSaveSector; +extern u16 gIncrementalSectorId; extern u16 gSaveFileStatus; extern void (*gGameContinueCallback)(void); -extern struct SaveSectionLocation gRamSaveSectionLocations[]; -extern u16 gUnknown_03006294; +extern struct SaveSectorLocation gRamSaveSectorLocations[]; -extern struct SaveSection gSaveDataBuffer; +extern struct SaveSector gSaveDataBuffer; void ClearSaveData(void); void Save_ResetSaveCounters(void); u8 HandleSavingData(u8 saveType); u8 TrySavingData(u8 saveType); -bool8 sub_8153380(void); -bool8 sub_81533AC(void); -bool8 sub_81533E0(void); -bool8 sub_8153408(void); -bool8 FullSaveGame(void); -bool8 CheckSaveFile(void); -u8 Save_LoadGameData(u8 saveType); +bool8 LinkFullSave_Init(void); +bool8 LinkFullSave_WriteSector(void); +bool8 LinkFullSave_ReplaceLastSector(void); +bool8 LinkFullSave_SetLastSectorSecurity(void); +bool8 WriteSaveBlock2(void); +bool8 WriteSaveBlock1Sector(void); +u8 LoadGameSave(u8 saveType); u16 GetSaveBlocksPointersBaseOffset(void); -u32 TryReadSpecialSaveSection(u8 sector, u8* dst); -u32 TryWriteSpecialSaveSection(u8 sector, u8* src); -void Task_LinkSave(u8 taskId); +u32 TryReadSpecialSaveSector(u8 sector, u8* dst); +u32 TryWriteSpecialSaveSector(u8 sector, u8* src); +void Task_LinkFullSave(u8 taskId); // save_failed_screen.c void DoSaveFailedScreen(u8 saveType); -- cgit v1.2.3 From 342b7da5d36460bb5780ea60da4b6b5be46ddc38 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 10 Nov 2021 11:59:15 -0500 Subject: Fix CRY_MODE_ECHO --- include/constants/sound.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/constants/sound.h b/include/constants/sound.h index 40c3b7d58..dc434bcf8 100644 --- a/include/constants/sound.h +++ b/include/constants/sound.h @@ -24,9 +24,9 @@ #define CRY_MODE_DOUBLES 1 // Shortened cry for double battles #define CRY_MODE_ENCOUNTER 2 // Used when starting a static encounter, or when a Pokémon is "aggressive" #define CRY_MODE_HIGH_PITCH 3 // Highest pitch mode, used exclusively by the move Howl -#define CRY_MODE_ECHO_END 4 // For 2nd cry used by the move Hyper Voice. Played in reverse +#define CRY_MODE_ECHO_START 4 // For 1st half of cry used by the move Hyper Voice. Played in reverse #define CRY_MODE_FAINT 5 // Used when a Pokémon faints -#define CRY_MODE_ECHO_START 6 // For 1st cry used by the move Hyper Voice +#define CRY_MODE_ECHO_END 6 // For 2nd half of cry used by the move Hyper Voice #define CRY_MODE_ROAR_1 7 // For 1st cry used by the move Roar #define CRY_MODE_ROAR_2 8 // For 2nd cry used by the move Roar #define CRY_MODE_GROWL_1 9 // For 1st cry used by the move Growl. Played in reverse -- cgit v1.2.3 From 9d3345a6d69c38bf31014df69c52583c877eed24 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sat, 13 Nov 2021 21:41:16 -0500 Subject: Enforce structs to enforce save block order for modern toolchains. --- include/load_save.h | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/load_save.h b/include/load_save.h index 2f4a9ace6..9e7b1bc92 100644 --- a/include/load_save.h +++ b/include/load_save.h @@ -1,9 +1,33 @@ #ifndef GUARD_LOAD_SAVE_H #define GUARD_LOAD_SAVE_H -extern struct SaveBlock1 gSaveblock1; -extern struct SaveBlock2 gSaveblock2; -extern struct PokemonStorage gPokemonStorage; +#include "pokemon_storage_system.h" + +#define SAVEBLOCK_MOVE_RANGE 128 + +/** + * These structs are to prevent them from being reordered on newer or modern + * toolchains. If this is not done, the ClearSav functions will end up erasing + * the wrong memory leading to various glitches. + */ +struct SaveBlock2DMA { + struct SaveBlock2 block; + u8 dma[SAVEBLOCK_MOVE_RANGE]; +}; + +struct SaveBlock1DMA { + struct SaveBlock1 block; + u8 dma[SAVEBLOCK_MOVE_RANGE]; +}; + +struct PokemonStorageDMA { + struct PokemonStorage block; + u8 dma[SAVEBLOCK_MOVE_RANGE]; +}; + +extern struct SaveBlock1DMA gSaveblock1; +extern struct SaveBlock2DMA gSaveblock2; +extern struct PokemonStorageDMA gPokemonStorage; extern bool32 gFlashMemoryPresent; extern struct SaveBlock1 *gSaveBlock1Ptr; -- cgit v1.2.3