Merge branch 'master' into fix_saveblock_reorder

This commit is contained in:
GriffinR 2021-11-13 23:19:57 -05:00 committed by GitHub
commit 159bb37bbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 723 additions and 640 deletions

View File

@ -3,11 +3,11 @@ gLastSaveCounter
gLastKnownGoodSector
gDamagedSaveSectors
gSaveCounter
gFastSaveSection
gUnknown_03006208
gReadWriteSector
gIncrementalSectorId
gSaveUnusedVar
gSaveFileStatus
gGameContinueCallback
gRamSaveSectionLocations
gRamSaveSectorLocations
gSaveUnusedVar2
gSaveAttemptStatus

View File

@ -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

View File

@ -48,8 +48,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);

View File

@ -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);

View File

@ -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);

View File

@ -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[];

View File

@ -665,9 +665,10 @@ void sub_80A6760(struct Sprite *sprite)
sprite->callback = sub_80A64D0;
}
void sub_80A67A4(struct Sprite *sprite)
// Unused
static void EndUnkPaletteAnim(struct Sprite *sprite)
{
ResetPaletteStructByUid(sprite->data[5]);
PaletteStruct_ResetById(sprite->data[5]);
DestroySpriteAndMatrix(sprite);
}

View File

@ -9,7 +9,6 @@
#include "string_util.h"
#include "text.h"
#include "sound.h"
#include "constants/songs.h"
#include "decompress.h"
#include "task.h"
#include "util.h"
@ -20,10 +19,12 @@
#include "international_string_util.h"
#include "safari_zone.h"
#include "battle_anim.h"
#include "constants/battle_anim.h"
#include "constants/rgb.h"
#include "data.h"
#include "pokemon_summary_screen.h"
#include "strings.h"
#include "constants/battle_anim.h"
#include "constants/rgb.h"
#include "constants/songs.h"
struct TestingBar
{
@ -157,15 +158,6 @@ enum
HEALTHBOX_GFX_FRAME_END_BAR,
};
// strings
extern const u8 gText_Slash[];
extern const u8 gText_HighlightDarkGray[];
extern const u8 gText_DynColor2[];
extern const u8 gText_DynColor2Male[];
extern const u8 gText_DynColor1Female[];
// this file's functions
static const u8 *GetHealthboxElementGfxPtr(u8 elementId);
static u8* AddTextPrinterAndCreateWindowOnHealthbox(const u8 *str, u32 x, u32 y, u32 bgColor, u32 *windowId);
@ -178,27 +170,26 @@ static void SafariTextIntoHealthboxObject(void *dest, u8 *windowTileData, u32 wi
static void HpTextIntoHealthboxObject(void *dest, u8 *windowTileData, u32 windowWidth);
static void FillHealthboxObject(void *dest, u32 arg1, u32 arg2);
static void sub_8073E08(u8 taskId);
static void sub_8073F98(u8 taskId);
static void sub_8073E64(u8 taskId);
static void Task_HidePartyStatusSummary_BattleStart_1(u8 taskId);
static void Task_HidePartyStatusSummary_BattleStart_2(u8 taskId);
static void Task_HidePartyStatusSummary_DuringBattle(u8 taskId);
static void SpriteCB_HealthBoxOther(struct Sprite *sprite);
static void SpriteCB_HealthBar(struct Sprite *sprite);
static void sub_8074158(struct Sprite *sprite);
static void sub_8074090(struct Sprite *sprite);
static void SpriteCB_StatusSummaryBar(struct Sprite *sprite);
static void SpriteCB_StatusSummaryBallsOnBattleStart(struct Sprite *sprite);
static void SpriteCB_StatusSummaryBallsOnSwitchout(struct Sprite *sprite);
static void SpriteCB_StatusSummaryBar_Enter(struct Sprite *sprite);
static void SpriteCB_StatusSummaryBar_Exit(struct Sprite *sprite);
static void SpriteCB_StatusSummaryBalls_Enter(struct Sprite *sprite);
static void SpriteCB_StatusSummaryBalls_Exit(struct Sprite *sprite);
static void SpriteCB_StatusSummaryBalls_OnSwitchout(struct Sprite *sprite);
static u8 GetStatusIconForBattlerId(u8 statusElementId, u8 battlerId);
static s32 CalcNewBarValue(s32 maxValue, s32 currValue, s32 receivedValue, s32 *arg3, u8 arg4, u16 arg5);
static u8 GetScaledExpFraction(s32 currValue, s32 receivedValue, s32 maxValue, u8 scale);
static void MoveBattleBarGraphically(u8 battlerId, u8 whichBar);
static u8 CalcBarFilledPixels(s32 maxValue, s32 oldValue, s32 receivedValue, s32 *currValue, u8 *arg4, u8 scale);
static void sub_8074F88(struct TestingBar *barInfo, s32 *arg1, u16 *arg2);
static void Debug_TestHealthBar_Helper(struct TestingBar *barInfo, s32 *arg1, u16 *arg2);
// const rom data
static const struct OamData sUnknown_0832C138 =
static const struct OamData sOamData_64x32 =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
@ -220,7 +211,7 @@ static const struct SpriteTemplate sHealthboxPlayerSpriteTemplates[2] =
{
.tileTag = TAG_HEALTHBOX_PLAYER1_TILE,
.paletteTag = TAG_HEALTHBOX_PAL,
.oam = &sUnknown_0832C138,
.oam = &sOamData_64x32,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
@ -229,7 +220,7 @@ static const struct SpriteTemplate sHealthboxPlayerSpriteTemplates[2] =
{
.tileTag = TAG_HEALTHBOX_PLAYER2_TILE,
.paletteTag = TAG_HEALTHBOX_PAL,
.oam = &sUnknown_0832C138,
.oam = &sOamData_64x32,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
@ -242,7 +233,7 @@ static const struct SpriteTemplate sHealthboxOpponentSpriteTemplates[2] =
{
.tileTag = TAG_HEALTHBOX_OPPONENT1_TILE,
.paletteTag = TAG_HEALTHBOX_PAL,
.oam = &sUnknown_0832C138,
.oam = &sOamData_64x32,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
@ -251,7 +242,7 @@ static const struct SpriteTemplate sHealthboxOpponentSpriteTemplates[2] =
{
.tileTag = TAG_HEALTHBOX_OPPONENT2_TILE,
.paletteTag = TAG_HEALTHBOX_PAL,
.oam = &sUnknown_0832C138,
.oam = &sOamData_64x32,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
@ -263,7 +254,7 @@ static const struct SpriteTemplate sHealthboxSafariSpriteTemplate =
{
.tileTag = TAG_HEALTHBOX_SAFARI_TILE,
.paletteTag = TAG_HEALTHBOX_PAL,
.oam = &sUnknown_0832C138,
.oam = &sOamData_64x32,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
@ -327,7 +318,7 @@ static const struct SpriteTemplate sHealthbarSpriteTemplates[MAX_BATTLERS_COUNT]
}
};
static const struct Subsprite sUnknown_0832C220[] =
static const struct Subsprite sUnused_Subsprites_0[] =
{
{
.x = DISPLAY_WIDTH,
@ -371,7 +362,7 @@ static const struct Subsprite sUnknown_0832C220[] =
}
};
static const struct Subsprite sUnknown_0832C234[] =
static const struct Subsprite sUnused_Subsprites_2[] =
{
{
.x = DISPLAY_WIDTH,
@ -415,7 +406,7 @@ static const struct Subsprite sUnknown_0832C234[] =
}
};
static const struct Subsprite sUnknown_0832C248[] =
static const struct Subsprite sUnused_Subsprites_1[] =
{
{
.x = DISPLAY_WIDTH,
@ -435,7 +426,7 @@ static const struct Subsprite sUnknown_0832C248[] =
}
};
static const struct Subsprite sUnknown_0832C250[] =
static const struct Subsprite sUnused_Subsprites_3[] =
{
{
.x = DISPLAY_WIDTH,
@ -455,7 +446,7 @@ static const struct Subsprite sUnknown_0832C250[] =
}
};
static const struct Subsprite sUnknown_0832C258[] =
static const struct Subsprite sHealthBar_Subsprites_Player[] =
{
{
.x = DISPLAY_WIDTH,
@ -475,7 +466,7 @@ static const struct Subsprite sUnknown_0832C258[] =
}
};
static const struct Subsprite sUnknown_0832C260[] =
static const struct Subsprite sHealthBar_Subsprites_Opponent[] =
{
{
.x = DISPLAY_WIDTH,
@ -503,25 +494,24 @@ static const struct Subsprite sUnknown_0832C260[] =
}
};
// unused subsprite table
static const struct SubspriteTable sUnknown_0832C26C[] =
static const struct SubspriteTable sUnused_SubspriteTable[] =
{
{ARRAY_COUNT(sUnknown_0832C220), sUnknown_0832C220},
{ARRAY_COUNT(sUnknown_0832C248), sUnknown_0832C248},
{ARRAY_COUNT(sUnknown_0832C234), sUnknown_0832C234},
{ARRAY_COUNT(sUnknown_0832C250), sUnknown_0832C250}
{ARRAY_COUNT(sUnused_Subsprites_0), sUnused_Subsprites_0},
{ARRAY_COUNT(sUnused_Subsprites_1), sUnused_Subsprites_1},
{ARRAY_COUNT(sUnused_Subsprites_2), sUnused_Subsprites_2},
{ARRAY_COUNT(sUnused_Subsprites_3), sUnused_Subsprites_3}
};
static const struct SubspriteTable sUnknown_0832C28C[] =
static const struct SubspriteTable sHealthBar_SubspriteTables[] =
{
{ARRAY_COUNT(sUnknown_0832C258), sUnknown_0832C258},
{ARRAY_COUNT(sUnknown_0832C260), sUnknown_0832C260}
[B_SIDE_PLAYER] = {ARRAY_COUNT(sHealthBar_Subsprites_Player), sHealthBar_Subsprites_Player},
[B_SIDE_OPPONENT] = {ARRAY_COUNT(sHealthBar_Subsprites_Opponent), sHealthBar_Subsprites_Opponent}
};
static const struct Subsprite sStatusSummaryBar_Subsprites_0[] =
static const struct Subsprite sStatusSummaryBar_Subsprites_Enter[] =
{
{
.x = 160,
.x = 32 * 5,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -529,7 +519,7 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_0[] =
.priority = 1
},
{
.x = 192,
.x = 32 * 6,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -537,7 +527,7 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_0[] =
.priority = 1
},
{
.x = 224,
.x = 32 * 7,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -554,10 +544,10 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_0[] =
}
};
static const struct Subsprite sUnknown_0832C2AC[] =
static const struct Subsprite sStatusSummaryBar_Subsprites_Exit[] =
{
{
.x = 160,
.x = 32 * 5,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -565,7 +555,7 @@ static const struct Subsprite sUnknown_0832C2AC[] =
.priority = 1
},
{
.x = 192,
.x = 32 * 6,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -573,7 +563,7 @@ static const struct Subsprite sUnknown_0832C2AC[] =
.priority = 1
},
{
.x = 224,
.x = 32 * 7,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -581,7 +571,7 @@ static const struct Subsprite sUnknown_0832C2AC[] =
.priority = 1
},
{
.x = 0,
.x = 32 * 0,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -589,7 +579,7 @@ static const struct Subsprite sUnknown_0832C2AC[] =
.priority = 1
},
{
.x = 32,
.x = 32 * 1,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -597,7 +587,7 @@ static const struct Subsprite sUnknown_0832C2AC[] =
.priority = 1
},
{
.x = 64,
.x = 32 * 2,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -606,14 +596,14 @@ static const struct Subsprite sUnknown_0832C2AC[] =
}
};
static const struct SubspriteTable sStatusSummaryBar_SubspriteTable[] =
static const struct SubspriteTable sStatusSummaryBar_SubspriteTable_Enter[] =
{
{ARRAY_COUNT(sStatusSummaryBar_Subsprites_0), sStatusSummaryBar_Subsprites_0}
{ARRAY_COUNT(sStatusSummaryBar_Subsprites_Enter), sStatusSummaryBar_Subsprites_Enter}
};
static const struct SubspriteTable sUnknown_0832C2CC[] =
static const struct SubspriteTable sStatusSummaryBar_SubspriteTable_Exit[] =
{
{ARRAY_COUNT(sUnknown_0832C2AC), sUnknown_0832C2AC}
{ARRAY_COUNT(sStatusSummaryBar_Subsprites_Exit), sStatusSummaryBar_Subsprites_Exit}
};
// unused unknown image
@ -676,23 +666,23 @@ static const struct OamData sOamData_StatusSummaryBalls =
static const struct SpriteTemplate sStatusSummaryBarSpriteTemplates[2] =
{
{
{ // Player
.tileTag = TAG_STATUS_SUMMARY_BAR_TILE,
.paletteTag = TAG_STATUS_SUMMARY_BAR_PAL,
.oam = &sUnknown_0832C138,
.oam = &sOamData_64x32,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_StatusSummaryBar
.callback = SpriteCB_StatusSummaryBar_Enter
},
{
{ // Opponent
.tileTag = TAG_STATUS_SUMMARY_BAR_TILE,
.paletteTag = TAG_STATUS_SUMMARY_BAR_PAL,
.oam = &sUnknown_0832C138,
.oam = &sOamData_64x32,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_StatusSummaryBar
.callback = SpriteCB_StatusSummaryBar_Enter
}
};
@ -705,7 +695,7 @@ static const struct SpriteTemplate sStatusSummaryBallsSpriteTemplates[2] =
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_StatusSummaryBallsOnBattleStart
.callback = SpriteCB_StatusSummaryBalls_Enter
},
{
.tileTag = TAG_STATUS_SUMMARY_BALLS_TILE,
@ -714,7 +704,7 @@ static const struct SpriteTemplate sStatusSummaryBallsSpriteTemplates[2] =
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_StatusSummaryBallsOnBattleStart
.callback = SpriteCB_StatusSummaryBalls_Enter
}
};
@ -739,23 +729,28 @@ static const u16 sStatusIconColors[] =
[PAL_STATUS_BRN] = RGB(28, 14, 10),
};
static const struct WindowTemplate sHealthboxWindowTemplate = {0, 0, 0, 8, 2, 0, 0}; // width = 8, height = 2
// code
static const struct WindowTemplate sHealthboxWindowTemplate = {
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 0,
.width = 8,
.height = 2,
.paletteNum = 0,
.baseBlock = 0
};
static s32 DummiedOutFunction(s16 unused1, s16 unused2, s32 unused3)
{
return 9;
}
void sub_8072308(s16 number, u16 *dest, bool8 unk)
static void Debug_DrawNumber(s16 number, u16 *dest, bool8 unk)
{
s8 i, j;
u8 buff[4];
for (i = 0; i < 4; i++)
{
buff[i] = 0;
}
for (i = 3; ; i--)
{
@ -767,9 +762,8 @@ void sub_8072308(s16 number, u16 *dest, bool8 unk)
else
{
for (; i > -1; i--)
{
buff[i] = 0xFF;
}
if (buff[3] == 0xFF)
buff[3] = 0;
break;
@ -819,12 +813,12 @@ void sub_8072308(s16 number, u16 *dest, bool8 unk)
}
}
void sub_80724A8(s16 arg0, s16 arg1, u16 *arg2)
// Unused
static void Debug_DrawNumberPair(s16 number1, s16 number2, u16 *arg2)
{
arg2[4] = 0x1E;
sub_8072308(arg1, arg2, 0);
sub_8072308(arg0, arg2 + 5, 1);
Debug_DrawNumber(number2, arg2, 0);
Debug_DrawNumber(number1, arg2 + 5, 1);
}
// Because the healthbox is too large to fit into one sprite, it is divided into two sprites.
@ -910,7 +904,7 @@ u8 CreateBattlerHealthboxSprites(u8 battlerId)
healthbarSpriteId = CreateSpriteAtEnd(&sHealthbarSpriteTemplates[gBattlerPositions[battlerId]], 140, 60, 0);
healthBarSpritePtr = &gSprites[healthbarSpriteId];
SetSubspriteTables(healthBarSpritePtr, &sUnknown_0832C28C[GetBattlerSide(battlerId)]);
SetSubspriteTables(healthBarSpritePtr, &sHealthBar_SubspriteTables[GetBattlerSide(battlerId)]);
healthBarSpritePtr->subspriteMode = SUBSPRITES_IGNORE_PRIORITY;
healthBarSpritePtr->oam.priority = 1;
@ -1299,7 +1293,7 @@ static void PrintSafariMonInfo(u8 healthboxSpriteId, struct Pokemon *mon)
barFontGfx = &gMonSpritesGfxPtr->barFontGfx[0x520 + (GetBattlerPosition(gSprites[healthboxSpriteId].hMain_Battler) * 384)];
var = 5;
nature = GetNature(mon);
StringCopy(text + 6, gNatureNamePointers[nature]);
StringCopy(&text[6], gNatureNamePointers[nature]);
RenderTextHandleBold(barFontGfx, FONT_BOLD, text);
for (j = 6, i = 0; i < var; i++, j++)
@ -1328,8 +1322,8 @@ static void PrintSafariMonInfo(u8 healthboxSpriteId, struct Pokemon *mon)
}
healthBarSpriteId = gSprites[healthboxSpriteId].hMain_HealthBarSpriteId;
ConvertIntToDecimalStringN(text + 6, gBattleStruct->safariCatchFactor, STR_CONV_MODE_RIGHT_ALIGN, 2);
ConvertIntToDecimalStringN(text + 9, gBattleStruct->safariEscapeFactor, STR_CONV_MODE_RIGHT_ALIGN, 2);
ConvertIntToDecimalStringN(&text[6], gBattleStruct->safariCatchFactor, STR_CONV_MODE_RIGHT_ALIGN, 2);
ConvertIntToDecimalStringN(&text[9], gBattleStruct->safariEscapeFactor, STR_CONV_MODE_RIGHT_ALIGN, 2);
text[5] = CHAR_SPACE;
text[8] = CHAR_SLASH;
RenderTextHandleBold(gMonSpritesGfxPtr->barFontGfx, FONT_BOLD, text);
@ -1424,7 +1418,7 @@ void SwapHpBarsWithHpText(void)
#define tSummaryBarSpriteId data[1]
#define tBallIconSpriteId(n) data[3 + n]
#define tIsBattleStart data[10]
#define tData15 data[15]
#define tBlend data[15]
u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart)
{
@ -1471,7 +1465,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
LoadSpritePalette(&sStatusSummaryBallsSpritePal);
summaryBarSpriteId = CreateSprite(&sStatusSummaryBarSpriteTemplates[isOpponent], bar_X, bar_Y, 10);
SetSubspriteTables(&gSprites[summaryBarSpriteId], sStatusSummaryBar_SubspriteTable);
SetSubspriteTables(&gSprites[summaryBarSpriteId], sStatusSummaryBar_SubspriteTable_Enter);
gSprites[summaryBarSpriteId].x2 = bar_pos2_X;
gSprites[summaryBarSpriteId].data[0] = bar_data0;
@ -1490,7 +1484,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
ballIconSpritesIds[i] = CreateSpriteAtEnd(&sStatusSummaryBallsSpriteTemplates[isOpponent], bar_X, bar_Y - 4, 9);
if (!isBattleStart)
gSprites[ballIconSpritesIds[i]].callback = SpriteCB_StatusSummaryBallsOnSwitchout;
gSprites[ballIconSpritesIds[i]].callback = SpriteCB_StatusSummaryBalls_OnSwitchout;
if (!isOpponent)
{
@ -1522,42 +1516,49 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
{
for (i = 0; i < PARTY_SIZE; i++)
{
if (partyInfo[i].hp == 0xFFFF) // empty slot or an egg
if (partyInfo[i].hp == HP_EMPTY_SLOT)
{
// empty slot or an egg
gSprites[ballIconSpritesIds[i]].oam.tileNum += 1;
gSprites[ballIconSpritesIds[i]].data[7] = 1;
}
else if (partyInfo[i].hp == 0) // fainted mon
else if (partyInfo[i].hp == 0)
{
// fainted mon
gSprites[ballIconSpritesIds[i]].oam.tileNum += 3;
}
else if (partyInfo[i].status != 0) // mon with major status
else if (partyInfo[i].status != 0)
{
// mon with major status
gSprites[ballIconSpritesIds[i]].oam.tileNum += 2;
}
}
}
else
{
for (i = 0, var = 5, j = 0; j < PARTY_SIZE; j++)
for (i = 0, var = PARTY_SIZE - 1, j = 0; j < PARTY_SIZE; j++)
{
if (partyInfo[j].hp == 0xFFFF) // empty slot or an egg
if (partyInfo[j].hp == HP_EMPTY_SLOT)
{
// empty slot or an egg
gSprites[ballIconSpritesIds[var]].oam.tileNum += 1;
gSprites[ballIconSpritesIds[var]].data[7] = 1;
var--;
continue;
}
else if (partyInfo[j].hp == 0) // fainted mon
else if (partyInfo[j].hp == 0)
{
// fainted mon
gSprites[ballIconSpritesIds[i]].oam.tileNum += 3;
}
else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->arenaLostPlayerMons & gBitTable[j])
{
// fainted arena mon
gSprites[ballIconSpritesIds[i]].oam.tileNum += 3;
}
else if (partyInfo[j].status != 0) // mon with major status
else if (partyInfo[j].status != 0)
{
// mon with primary status
gSprites[ballIconSpritesIds[i]].oam.tileNum += 2;
}
i++;
@ -1568,19 +1569,22 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
{
if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS))
{
for (var = 5, i = 0; i < PARTY_SIZE; i++)
for (var = PARTY_SIZE - 1, i = 0; i < PARTY_SIZE; i++)
{
if (partyInfo[i].hp == 0xFFFF) // empty slot or an egg
if (partyInfo[i].hp == HP_EMPTY_SLOT)
{
// empty slot or an egg
gSprites[ballIconSpritesIds[var]].oam.tileNum += 1;
gSprites[ballIconSpritesIds[var]].data[7] = 1;
}
else if (partyInfo[i].hp == 0) // fainted mon
else if (partyInfo[i].hp == 0)
{
// fainted mon
gSprites[ballIconSpritesIds[var]].oam.tileNum += 3;
}
else if (partyInfo[i].status != 0) // mon with major status
else if (partyInfo[i].status != 0)
{
// mon with primary status
gSprites[ballIconSpritesIds[var]].oam.tileNum += 2;
}
var--;
@ -1590,24 +1594,28 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
{
for (var = 0, i = 0, j = 0; j < PARTY_SIZE; j++)
{
if (partyInfo[j].hp == 0xFFFF) // empty slot or an egg
if (partyInfo[j].hp == HP_EMPTY_SLOT)
{
// empty slot or an egg
gSprites[ballIconSpritesIds[i]].oam.tileNum += 1;
gSprites[ballIconSpritesIds[i]].data[7] = 1;
i++;
continue;
}
else if (partyInfo[j].hp == 0) // fainted mon
else if (partyInfo[j].hp == 0)
{
gSprites[ballIconSpritesIds[5 - var]].oam.tileNum += 3;
// fainted mon
gSprites[ballIconSpritesIds[PARTY_SIZE - 1 - var]].oam.tileNum += 3;
}
else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->arenaLostOpponentMons & gBitTable[j]) // hmm...?
else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->arenaLostOpponentMons & gBitTable[j])
{
gSprites[ballIconSpritesIds[5 - var]].oam.tileNum += 3;
// fainted arena mon
gSprites[ballIconSpritesIds[PARTY_SIZE - 1 - var]].oam.tileNum += 3;
}
else if (partyInfo[j].status != 0) // mon with major status
else if (partyInfo[j].status != 0)
{
gSprites[ballIconSpritesIds[5 - var]].oam.tileNum += 2;
// mon with primary status
gSprites[ballIconSpritesIds[PARTY_SIZE - 1 - var]].oam.tileNum += 2;
}
var++;
}
@ -1632,6 +1640,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
return taskId;
}
// Slide the party summary tray back offscreen
void Task_HidePartyStatusSummary(u8 taskId)
{
u8 ballIconSpriteIds[PARTY_SIZE];
@ -1650,7 +1659,7 @@ void Task_HidePartyStatusSummary(u8 taskId)
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0));
gTasks[taskId].tData15 = 16;
gTasks[taskId].tBlend = 16;
for (i = 0; i < PARTY_SIZE; i++)
gSprites[ballIconSpriteIds[i]].oam.objMode = ST_OAM_OBJ_BLEND;
@ -1663,51 +1672,51 @@ void Task_HidePartyStatusSummary(u8 taskId)
{
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
{
gSprites[ballIconSpriteIds[5 - i]].data[1] = 7 * i;
gSprites[ballIconSpriteIds[5 - i]].data[3] = 0;
gSprites[ballIconSpriteIds[5 - i]].data[4] = 0;
gSprites[ballIconSpriteIds[5 - i]].callback = sub_8074158;
gSprites[ballIconSpriteIds[PARTY_SIZE - 1 - i]].data[1] = 7 * i;
gSprites[ballIconSpriteIds[PARTY_SIZE - 1 - i]].data[3] = 0;
gSprites[ballIconSpriteIds[PARTY_SIZE - 1 - i]].data[4] = 0;
gSprites[ballIconSpriteIds[PARTY_SIZE - 1 - i]].callback = SpriteCB_StatusSummaryBalls_Exit;
}
else
{
gSprites[ballIconSpriteIds[i]].data[1] = 7 * i;
gSprites[ballIconSpriteIds[i]].data[3] = 0;
gSprites[ballIconSpriteIds[i]].data[4] = 0;
gSprites[ballIconSpriteIds[i]].callback = sub_8074158;
gSprites[ballIconSpriteIds[i]].callback = SpriteCB_StatusSummaryBalls_Exit;
}
}
gSprites[summaryBarSpriteId].data[0] /= 2;
gSprites[summaryBarSpriteId].data[1] = 0;
gSprites[summaryBarSpriteId].callback = sub_8074090;
SetSubspriteTables(&gSprites[summaryBarSpriteId], sUnknown_0832C2CC);
gTasks[taskId].func = sub_8073E08;
gSprites[summaryBarSpriteId].callback = SpriteCB_StatusSummaryBar_Exit;
SetSubspriteTables(&gSprites[summaryBarSpriteId], sStatusSummaryBar_SubspriteTable_Exit);
gTasks[taskId].func = Task_HidePartyStatusSummary_BattleStart_1;
}
else
{
gTasks[taskId].func = sub_8073F98;
gTasks[taskId].func = Task_HidePartyStatusSummary_DuringBattle;
}
}
static void sub_8073E08(u8 taskId)
static void Task_HidePartyStatusSummary_BattleStart_1(u8 taskId)
{
if ((gTasks[taskId].data[11]++ % 2) == 0)
{
if (--gTasks[taskId].tData15 < 0)
if (--gTasks[taskId].tBlend < 0)
return;
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[15], 16 - gTasks[taskId].data[15]));
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].tBlend, 16 - gTasks[taskId].tBlend));
}
if (gTasks[taskId].tData15 == 0)
gTasks[taskId].func = sub_8073E64;
if (gTasks[taskId].tBlend == 0)
gTasks[taskId].func = Task_HidePartyStatusSummary_BattleStart_2;
}
static void sub_8073E64(u8 taskId)
static void Task_HidePartyStatusSummary_BattleStart_2(u8 taskId)
{
u8 ballIconSpriteIds[PARTY_SIZE];
s32 i;
u8 battlerId = gTasks[taskId].tBattler;
if (--gTasks[taskId].tData15 == -1)
if (--gTasks[taskId].tBlend == -1)
{
u8 summaryBarSpriteId = gTasks[taskId].tSummaryBarSpriteId;
@ -1731,7 +1740,7 @@ static void sub_8073E64(u8 taskId)
for (i = 1; i < PARTY_SIZE; i++)
DestroySprite(&gSprites[ballIconSpriteIds[i]]);
}
else if (gTasks[taskId].tData15 == -3)
else if (gTasks[taskId].tBlend == -3)
{
gBattleSpritesDataPtr->healthBoxesData[battlerId].partyStatusSummaryShown = 0;
SetGpuReg(REG_OFFSET_BLDCNT, 0);
@ -1740,17 +1749,17 @@ static void sub_8073E64(u8 taskId)
}
}
static void sub_8073F98(u8 taskId)
static void Task_HidePartyStatusSummary_DuringBattle(u8 taskId)
{
u8 ballIconSpriteIds[PARTY_SIZE];
s32 i;
u8 battlerId = gTasks[taskId].tBattler;
if (--gTasks[taskId].tData15 >= 0)
if (--gTasks[taskId].tBlend >= 0)
{
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[15], 16 - gTasks[taskId].data[15]));
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].tBlend, 16 - gTasks[taskId].tBlend));
}
else if (gTasks[taskId].tData15 == -1)
else if (gTasks[taskId].tBlend == -1)
{
u8 summaryBarSpriteId = gTasks[taskId].tSummaryBarSpriteId;
@ -1763,7 +1772,7 @@ static void sub_8073F98(u8 taskId)
for (i = 1; i < PARTY_SIZE; i++)
DestroySprite(&gSprites[ballIconSpriteIds[i]]);
}
else if (gTasks[taskId].tData15 == -3)
else if (gTasks[taskId].tBlend == -3)
{
gBattleSpritesDataPtr->healthBoxesData[battlerId].partyStatusSummaryShown = 0;
SetGpuReg(REG_OFFSET_BLDCNT, 0);
@ -1776,15 +1785,15 @@ static void sub_8073F98(u8 taskId)
#undef tSummaryBarSpriteId
#undef tBallIconSpriteId
#undef tIsBattleStart
#undef tData15
#undef tBlend
static void SpriteCB_StatusSummaryBar(struct Sprite *sprite)
static void SpriteCB_StatusSummaryBar_Enter(struct Sprite *sprite)
{
if (sprite->x2 != 0)
sprite->x2 += sprite->data[0];
}
static void sub_8074090(struct Sprite *sprite)
static void SpriteCB_StatusSummaryBar_Exit(struct Sprite *sprite)
{
sprite->data[1] += 32;
if (sprite->data[0] > 0)
@ -1794,7 +1803,7 @@ static void sub_8074090(struct Sprite *sprite)
sprite->data[1] &= 0xF;
}
static void SpriteCB_StatusSummaryBallsOnBattleStart(struct Sprite *sprite)
static void SpriteCB_StatusSummaryBalls_Enter(struct Sprite *sprite)
{
u8 var1;
u16 var2;
@ -1839,7 +1848,7 @@ static void SpriteCB_StatusSummaryBallsOnBattleStart(struct Sprite *sprite)
}
}
static void sub_8074158(struct Sprite *sprite)
static void SpriteCB_StatusSummaryBalls_Exit(struct Sprite *sprite)
{
u8 var1;
u16 var2;
@ -1865,7 +1874,7 @@ static void sub_8074158(struct Sprite *sprite)
}
}
static void SpriteCB_StatusSummaryBallsOnSwitchout(struct Sprite *sprite)
static void SpriteCB_StatusSummaryBalls_OnSwitchout(struct Sprite *sprite)
{
u8 barSpriteId = sprite->data[0];
@ -1882,7 +1891,7 @@ static void UpdateNickInHealthbox(u8 healthboxSpriteId, struct Pokemon *mon)
u16 species;
u8 gender;
StringCopy(gDisplayedStringBattle, gText_HighlightDarkGray);
StringCopy(gDisplayedStringBattle, gText_HealthboxNickname);
GetMonData(mon, MON_DATA_NICKNAME, nickname);
StringGetEnd10(nickname);
ptr = StringAppend(gDisplayedStringBattle, nickname);
@ -1898,15 +1907,15 @@ static void UpdateNickInHealthbox(u8 healthboxSpriteId, struct Pokemon *mon)
switch (gender)
{
default:
StringCopy(ptr, gText_DynColor2);
StringCopy(ptr, gText_HealthboxGender_None);
windowTileData = AddTextPrinterAndCreateWindowOnHealthbox(gDisplayedStringBattle, 0, 3, 2, &windowId);
break;
case MON_MALE:
StringCopy(ptr, gText_DynColor2Male);
StringCopy(ptr, gText_HealthboxGender_Male);
windowTileData = AddTextPrinterAndCreateWindowOnHealthbox(gDisplayedStringBattle, 0, 3, 2, &windowId);
break;
case MON_FEMALE:
StringCopy(ptr, gText_DynColor1Female);
StringCopy(ptr, gText_HealthboxGender_Female);
windowTileData = AddTextPrinterAndCreateWindowOnHealthbox(gDisplayedStringBattle, 0, 3, 2, &windowId);
break;
}
@ -2422,8 +2431,9 @@ static u8 CalcBarFilledPixels(s32 maxValue, s32 oldValue, s32 receivedValue, s32
return filledPixels;
}
// Unused
// These two functions seem as if they were made for testing the health bar.
static s16 sub_8074F28(struct TestingBar *barInfo, s32 *currValue, u16 *arg2, s32 arg3)
static s16 Debug_TestHealthBar(struct TestingBar *barInfo, s32 *currValue, u16 *arg2, s32 arg3)
{
s16 ret, var;
@ -2431,7 +2441,7 @@ static s16 sub_8074F28(struct TestingBar *barInfo, s32 *currValue, u16 *arg2, s3
barInfo->oldValue,
barInfo->receivedValue,
currValue, B_HEALTHBAR_PIXELS / 8, 1);
sub_8074F88(barInfo, currValue, arg2);
Debug_TestHealthBar_Helper(barInfo, currValue, arg2);
if (barInfo->maxValue < B_HEALTHBAR_PIXELS)
var = *currValue >> 8;
@ -2443,7 +2453,7 @@ static s16 sub_8074F28(struct TestingBar *barInfo, s32 *currValue, u16 *arg2, s3
return ret;
}
static void sub_8074F88(struct TestingBar *barInfo, s32 *currValue, u16 *arg2)
static void Debug_TestHealthBar_Helper(struct TestingBar *barInfo, s32 *currValue, u16 *arg2)
{
u8 sp8[6];
u16 sp10[6];

View File

@ -3492,7 +3492,7 @@ static void BattleIntroDrawPartySummaryScreens(void)
if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE
|| GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
{
hpStatus[i].hp = 0xFFFF;
hpStatus[i].hp = HP_EMPTY_SLOT;
hpStatus[i].status = 0;
}
else
@ -3510,7 +3510,7 @@ static void BattleIntroDrawPartySummaryScreens(void)
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE
|| GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
{
hpStatus[i].hp = 0xFFFF;
hpStatus[i].hp = HP_EMPTY_SLOT;
hpStatus[i].status = 0;
}
else
@ -3536,7 +3536,7 @@ static void BattleIntroDrawPartySummaryScreens(void)
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE
|| GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
{
hpStatus[i].hp = 0xFFFF;
hpStatus[i].hp = HP_EMPTY_SLOT;
hpStatus[i].status = 0;
}
else

View File

@ -2785,7 +2785,7 @@ static bool8 LinkPlayAgainHandleSaving(void)
}
break;
case 2:
FullSaveGame();
WriteSaveBlock2();
sBerryBlender->linkPlayAgainState++;
sBerryBlender->framesToWait = 0;
break;
@ -2799,7 +2799,7 @@ static bool8 LinkPlayAgainHandleSaving(void)
case 4:
if (IsLinkTaskFinished())
{
if (CheckSaveFile())
if (WriteSaveBlock1Sector())
{
sBerryBlender->linkPlayAgainState = 5;
}

View File

@ -3244,10 +3244,10 @@ static u32 Cmd_SaveGame(struct BerryCrushGame *game, u8 *args)
DrawDialogueFrame(0, 0);
AddTextPrinterParameterized2(0, FONT_NORMAL, gText_SavingDontTurnOffPower, 0, 0, 2, 1, 3);
CopyWindowToVram(0, COPYWIN_FULL);
CreateTask(Task_LinkSave, 0);
CreateTask(Task_LinkFullSave, 0);
break;
case 3:
if (FuncIsActiveTask(Task_LinkSave))
if (FuncIsActiveTask(Task_LinkFullSave))
return 0;
break;
case 4:

View File

@ -5035,12 +5035,12 @@ static void Msg_SavingDontTurnOff(void)
case 2:
if (!IsDma3ManagerBusyWithBgCopy())
{
CreateTask(Task_LinkSave, 0);
CreateTask(Task_LinkFullSave, 0);
sGfx->state++;
}
break;
case 3:
if (!FuncIsActiveTask(Task_LinkSave))
if (!FuncIsActiveTask(Task_LinkFullSave))
sGfx->state++;
break;
default:

View File

@ -481,7 +481,7 @@ static bool32 TryWriteTrainerHill_Internal(struct EReaderTrainerHillSet * hillSe
}
hillTag->checksum = CalcByteArraySum((u8 *)hillTag->floors, NUM_TRAINER_HILL_FLOORS * sizeof(struct TrHillFloor));
if (TryWriteSpecialSaveSection(SECTOR_ID_TRAINER_HILL, (u8 *)hillTag) != SAVE_STATUS_OK)
if (TryWriteSpecialSaveSector(SECTOR_ID_TRAINER_HILL, (u8 *)hillTag) != SAVE_STATUS_OK)
return FALSE;
return TRUE;
@ -497,7 +497,7 @@ bool32 TryWriteTrainerHill(struct EReaderTrainerHillSet * hillSet)
static bool32 TryReadTrainerHill_Internal(struct EReaderTrainerHillSet * dest, u8 * buffer)
{
if (TryReadSpecialSaveSection(SECTOR_ID_TRAINER_HILL, buffer) != SAVE_STATUS_OK)
if (TryReadSpecialSaveSector(SECTOR_ID_TRAINER_HILL, buffer) != SAVE_STATUS_OK)
return FALSE;
memcpy(dest, buffer, sizeof(struct EReaderTrainerHillSet));

View File

@ -486,12 +486,12 @@ static void Task_Hof_InitTeamSaveData(u8 taskId)
if (!gHasHallOfFameRecords)
{
memset(gDecompressionBuffer, 0, 0x2000);
memset(gDecompressionBuffer, 0, SECTOR_SIZE * NUM_HOF_SECTORS);
}
else
{
if (Save_LoadGameData(SAVE_HALL_OF_FAME) != SAVE_STATUS_OK)
memset(gDecompressionBuffer, 0, 0x2000);
if (LoadGameSave(SAVE_HALL_OF_FAME) != SAVE_STATUS_OK)
memset(gDecompressionBuffer, 0, SECTOR_SIZE * NUM_HOF_SECTORS);
}
for (i = 0; i < HALL_OF_FAME_MAX_TEAMS; i++, lastSavedTeam++)
@ -852,7 +852,7 @@ void CB2_DoHallOfFamePC(void)
gTasks[taskId].tMonSpriteId(i) = SPRITE_NONE;
}
sHofMonPtr = AllocZeroed(0x2000);
sHofMonPtr = AllocZeroed(SECTOR_SIZE * NUM_HOF_SECTORS);
SetMainCallback2(CB2_HallOfFame);
}
break;
@ -862,7 +862,7 @@ void CB2_DoHallOfFamePC(void)
static void Task_HofPC_CopySaveData(u8 taskId)
{
HofPCTopBar_AddWindow(0, 30, 0, 12, 0x226);
if (Save_LoadGameData(SAVE_HALL_OF_FAME) != SAVE_STATUS_OK)
if (LoadGameSave(SAVE_HALL_OF_FAME) != SAVE_STATUS_OK)
{
gTasks[taskId].func = Task_HofPC_PrintDataIsCorrupted;
}
@ -871,7 +871,7 @@ static void Task_HofPC_CopySaveData(u8 taskId)
u16 i;
struct HallofFameTeam* savedTeams;
CpuCopy16(gDecompressionBuffer, sHofMonPtr, 0x2000);
CpuCopy16(gDecompressionBuffer, sHofMonPtr, SECTOR_SIZE * NUM_HOF_SECTORS);
savedTeams = sHofMonPtr;
for (i = 0; i < HALL_OF_FAME_MAX_TEAMS; i++, savedTeams++)
{

View File

@ -1145,7 +1145,7 @@ void CB2_InitCopyrightScreenAfterBootup(void)
SetSaveBlocksPointers(GetSaveBlocksPointersBaseOffset());
ResetMenuAndMonGlobals();
Save_ResetSaveCounters();
Save_LoadGameData(SAVE_NORMAL);
LoadGameSave(SAVE_NORMAL);
if (gSaveFileStatus == SAVE_STATUS_EMPTY || gSaveFileStatus == SAVE_STATUS_CORRUPT)
Sav2_ClearSetDefault();
SetPokemonCryStereo(gSaveBlock2Ptr->optionsSound);

View File

@ -193,13 +193,13 @@ void LoadObjectEvents(void)
gObjectEvents[i] = gSaveBlock1Ptr->objectEvents[i];
}
void SaveSerializedGame(void)
void CopyPartyAndObjectsToSave(void)
{
SavePlayerParty();
SaveObjectEvents();
}
void LoadSerializedGame(void)
void CopyPartyAndObjectsFromSave(void)
{
LoadPlayerParty();
LoadObjectEvents();

View File

@ -16,36 +16,38 @@ enum
// These are structs for some unused palette system.
// The full functionality of this system is unknown.
#define NUM_PALETTE_STRUCTS 16
struct PaletteStructTemplate
{
u16 uid;
u16 id;
u16 *src;
u16 pst_field_8_0:1;
u16 pst_field_8_1:9;
bool16 pst_field_8_0:1;
u16 unused:9;
u16 size:5;
u16 pst_field_9_7:1;
u8 pst_field_A;
u8 time1;
u8 srcCount:5;
u8 pst_field_B_5:3;
u8 pst_field_C;
u8 state:3;
u8 time2;
};
struct PaletteStruct
{
const struct PaletteStructTemplate *base;
u32 ps_field_4_0:1;
u16 ps_field_4_1:1;
const struct PaletteStructTemplate *template;
bool32 active:1;
bool32 flag:1;
u32 baseDestOffset:9;
u16 destOffset:10;
u16 srcIndex:7;
u8 ps_field_8;
u8 ps_field_9;
u32 destOffset:10;
u32 srcIndex:7;
u8 countdown1;
u8 countdown2;
};
static void unused_sub_80A1CDC(struct PaletteStruct *, u32 *);
static void unused_sub_80A1E40(struct PaletteStruct *, u32 *);
static void unused_sub_80A1F00(struct PaletteStruct *);
static u8 GetPaletteNumByUid(u16);
static void PaletteStruct_Copy(struct PaletteStruct *, u32 *);
static void PaletteStruct_Blend(struct PaletteStruct *, u32 *);
static void PaletteStruct_TryEnd(struct PaletteStruct *);
static void PaletteStruct_Reset(u8);
static u8 PaletteStruct_GetPalNum(u16);
static u8 UpdateNormalPaletteFade(void);
static void BeginFastPaletteFadeInternal(u8);
static u8 UpdateFastPaletteFade(void);
@ -58,15 +60,15 @@ static void Task_BlendPalettesGradually(u8 taskId);
// unaligned word reads are issued in BlendPalette otherwise
ALIGNED(4) EWRAM_DATA u16 gPlttBufferUnfaded[PLTT_BUFFER_SIZE] = {0};
ALIGNED(4) EWRAM_DATA u16 gPlttBufferFaded[PLTT_BUFFER_SIZE] = {0};
EWRAM_DATA struct PaletteStruct sPaletteStructs[0x10] = {0};
EWRAM_DATA struct PaletteStruct sPaletteStructs[NUM_PALETTE_STRUCTS] = {0};
EWRAM_DATA struct PaletteFadeControl gPaletteFade = {0};
static EWRAM_DATA u32 sFiller = 0;
static EWRAM_DATA u32 sPlttBufferTransferPending = 0;
EWRAM_DATA u8 gPaletteDecompressionBuffer[PLTT_DECOMP_BUFFER_SIZE] = {0};
static const struct PaletteStructTemplate gDummyPaletteStructTemplate = {
.uid = 0xFFFF,
.pst_field_B_5 = 1
.id = 0xFFFF,
.state = 1
};
static const u8 sRoundedDownGrayscaleMap[] = {
@ -82,20 +84,20 @@ static const u8 sRoundedDownGrayscaleMap[] = {
void LoadCompressedPalette(const u32 *src, u16 offset, u16 size)
{
LZDecompressWram(src, gPaletteDecompressionBuffer);
CpuCopy16(gPaletteDecompressionBuffer, gPlttBufferUnfaded + offset, size);
CpuCopy16(gPaletteDecompressionBuffer, gPlttBufferFaded + offset, size);
CpuCopy16(gPaletteDecompressionBuffer, &gPlttBufferUnfaded[offset], size);
CpuCopy16(gPaletteDecompressionBuffer, &gPlttBufferFaded[offset], size);
}
void LoadPalette(const void *src, u16 offset, u16 size)
{
CpuCopy16(src, gPlttBufferUnfaded + offset, size);
CpuCopy16(src, gPlttBufferFaded + offset, size);
CpuCopy16(src, &gPlttBufferUnfaded[offset], size);
CpuCopy16(src, &gPlttBufferFaded[offset], size);
}
void FillPalette(u16 value, u16 offset, u16 size)
{
CpuFill16(value, gPlttBufferUnfaded + offset, size);
CpuFill16(value, gPlttBufferFaded + offset, size);
CpuFill16(value, &gPlttBufferUnfaded[offset], size);
CpuFill16(value, &gPlttBufferFaded[offset], size);
}
void TransferPlttBuffer(void)
@ -105,7 +107,7 @@ void TransferPlttBuffer(void)
void *src = gPlttBufferFaded;
void *dest = (void *)PLTT;
DmaCopy16(3, src, dest, PLTT_SIZE);
sPlttBufferTransferPending = 0;
sPlttBufferTransferPending = FALSE;
if (gPaletteFade.mode == HARDWARE_FADE && gPaletteFade.active)
UpdateBlendRegisters();
}
@ -135,13 +137,13 @@ void ResetPaletteFade(void)
{
u8 i;
for (i = 0; i < 16; i++)
ResetPaletteStruct(i);
for (i = 0; i < NUM_PALETTE_STRUCTS; i++)
PaletteStruct_Reset(i);
ResetPaletteFadeControl();
}
void ReadPlttIntoBuffers(void)
static void ReadPlttIntoBuffers(void)
{
u16 i;
u16 *pltt = (u16 *)PLTT;
@ -178,7 +180,7 @@ bool8 BeginNormalPaletteFade(u32 selectedPalettes, s8 delay, u8 startY, u8 targe
gPaletteFade.y = startY;
gPaletteFade.targetY = targetY;
gPaletteFade.blendColor = color;
gPaletteFade.active = 1;
gPaletteFade.active = TRUE;
gPaletteFade.mode = NORMAL_FADE;
if (startY < targetY)
@ -189,9 +191,9 @@ bool8 BeginNormalPaletteFade(u32 selectedPalettes, s8 delay, u8 startY, u8 targe
UpdatePaletteFade();
temp = gPaletteFade.bufferTransferDisabled;
gPaletteFade.bufferTransferDisabled = 0;
gPaletteFade.bufferTransferDisabled = FALSE;
CpuCopy32(gPlttBufferFaded, (void *)PLTT, PLTT_SIZE);
sPlttBufferTransferPending = 0;
sPlttBufferTransferPending = FALSE;
if (gPaletteFade.mode == HARDWARE_FADE && gPaletteFade.active)
UpdateBlendRegisters();
gPaletteFade.bufferTransferDisabled = temp;
@ -199,55 +201,55 @@ bool8 BeginNormalPaletteFade(u32 selectedPalettes, s8 delay, u8 startY, u8 targe
}
}
bool8 unref_sub_80A1C1C(u32 a1, u8 a2, u8 a3, u8 a4, u16 a5)
// Unused
static bool8 BeginPlttFade(u32 selectedPalettes, u8 delay, u8 startY, u8 targetY, u16 blendColor)
{
ReadPlttIntoBuffers();
return BeginNormalPaletteFade(a1, a2, a3, a4, a5);
return BeginNormalPaletteFade(selectedPalettes, delay, startY, targetY, blendColor);
}
void unref_sub_80A1C64(u8 a1, u32 *a2)
// Unused
static void PaletteStruct_Run(u8 a1, u32 *unkFlags)
{
u8 i;
for (i = 0; i < 16; i++)
for (i = 0; i < NUM_PALETTE_STRUCTS; i++)
{
struct PaletteStruct *palstruct = &sPaletteStructs[i];
if (palstruct->ps_field_4_0)
if (palstruct->active)
{
if (palstruct->base->pst_field_8_0 == a1)
if (palstruct->template->pst_field_8_0 == a1)
{
u8 val1 = palstruct->srcIndex;
u8 val2 = palstruct->base->srcCount;
if (val1 == val2)
if (palstruct->srcIndex == palstruct->template->srcCount)
{
unused_sub_80A1F00(palstruct);
if (!palstruct->ps_field_4_0)
PaletteStruct_TryEnd(palstruct);
if (!palstruct->active)
continue;
}
if (palstruct->ps_field_8 == 0)
unused_sub_80A1CDC(palstruct, a2);
if (palstruct->countdown1 == 0)
PaletteStruct_Copy(palstruct, unkFlags);
else
palstruct->ps_field_8--;
palstruct->countdown1--;
unused_sub_80A1E40(palstruct, a2);
PaletteStruct_Blend(palstruct, unkFlags);
}
}
}
}
static void unused_sub_80A1CDC(struct PaletteStruct *a1, u32 *a2)
static void PaletteStruct_Copy(struct PaletteStruct *a1, u32 *unkFlags)
{
s32 srcIndex;
s32 srcCount;
u8 i = 0;
u16 srcOffset = a1->srcIndex * a1->base->size;
u16 srcOffset = a1->srcIndex * a1->template->size;
if (!a1->base->pst_field_8_0)
if (!a1->template->pst_field_8_0)
{
while (i < a1->base->size)
while (i < a1->template->size)
{
gPlttBufferUnfaded[a1->destOffset] = a1->base->src[srcOffset];
gPlttBufferFaded[a1->destOffset] = a1->base->src[srcOffset];
gPlttBufferUnfaded[a1->destOffset] = a1->template->src[srcOffset];
gPlttBufferFaded[a1->destOffset] = a1->template->src[srcOffset];
i++;
a1->destOffset++;
srcOffset++;
@ -255,9 +257,9 @@ static void unused_sub_80A1CDC(struct PaletteStruct *a1, u32 *a2)
}
else
{
while (i < a1->base->size)
while (i < a1->template->size)
{
gPlttBufferFaded[a1->destOffset] = a1->base->src[srcOffset];
gPlttBufferFaded[a1->destOffset] = a1->template->src[srcOffset];
i++;
a1->destOffset++;
srcOffset++;
@ -265,33 +267,33 @@ static void unused_sub_80A1CDC(struct PaletteStruct *a1, u32 *a2)
}
a1->destOffset = a1->baseDestOffset;
a1->ps_field_8 = a1->base->pst_field_A;
a1->countdown1 = a1->template->time1;
a1->srcIndex++;
srcIndex = a1->srcIndex;
srcCount = a1->base->srcCount;
srcCount = a1->template->srcCount;
if (srcIndex >= srcCount)
{
if (a1->ps_field_9)
a1->ps_field_9--;
if (a1->countdown2)
a1->countdown2--;
a1->srcIndex = 0;
}
*a2 |= 1 << (a1->baseDestOffset >> 4);
*unkFlags |= 1 << (a1->baseDestOffset >> 4);
}
static void unused_sub_80A1E40(struct PaletteStruct *a1, u32 *a2)
static void PaletteStruct_Blend(struct PaletteStruct *a1, u32 *unkFlags)
{
if (gPaletteFade.active && ((1 << (a1->baseDestOffset >> 4)) & gPaletteFade_selectedPalettes))
{
if (!a1->base->pst_field_8_0)
if (!a1->template->pst_field_8_0)
{
if (gPaletteFade.delayCounter != gPaletteFade_delay)
{
BlendPalette(
a1->baseDestOffset,
a1->base->size,
a1->template->size,
gPaletteFade.y,
gPaletteFade.blendColor);
}
@ -300,64 +302,64 @@ static void unused_sub_80A1E40(struct PaletteStruct *a1, u32 *a2)
{
if (!gPaletteFade.delayCounter)
{
if (a1->ps_field_8 != a1->base->pst_field_A)
if (a1->countdown1 != a1->template->time1)
{
u32 srcOffset = a1->srcIndex * a1->base->size;
u32 srcOffset = a1->srcIndex * a1->template->size;
u8 i;
for (i = 0; i < a1->base->size; i++)
gPlttBufferFaded[a1->baseDestOffset + i] = a1->base->src[srcOffset + i];
for (i = 0; i < a1->template->size; i++)
gPlttBufferFaded[a1->baseDestOffset + i] = a1->template->src[srcOffset + i];
}
}
}
}
}
static void unused_sub_80A1F00(struct PaletteStruct *a1)
static void PaletteStruct_TryEnd(struct PaletteStruct *pal)
{
if (!a1->ps_field_9)
if (pal->countdown2 == 0)
{
s32 val = a1->base->pst_field_B_5;
s32 state = pal->template->state;
if (!val)
if (state == 0)
{
a1->srcIndex = 0;
a1->ps_field_8 = a1->base->pst_field_A;
a1->ps_field_9 = a1->base->pst_field_C;
a1->destOffset = a1->baseDestOffset;
pal->srcIndex = 0;
pal->countdown1 = pal->template->time1;
pal->countdown2 = pal->template->time2;
pal->destOffset = pal->baseDestOffset;
}
else
{
if (val < 0)
if (state < 0)
return;
if (val > 2)
if (state > 2)
return;
ResetPaletteStructByUid(a1->base->uid);
PaletteStruct_ResetById(pal->template->id);
}
}
else
{
a1->ps_field_9--;
pal->countdown2--;
}
}
void ResetPaletteStructByUid(u16 a1)
void PaletteStruct_ResetById(u16 id)
{
u8 paletteNum = GetPaletteNumByUid(a1);
if (paletteNum != 16)
ResetPaletteStruct(paletteNum);
u8 paletteNum = PaletteStruct_GetPalNum(id);
if (paletteNum != NUM_PALETTE_STRUCTS)
PaletteStruct_Reset(paletteNum);
}
void ResetPaletteStruct(u8 paletteNum)
static void PaletteStruct_Reset(u8 paletteNum)
{
sPaletteStructs[paletteNum].base = &gDummyPaletteStructTemplate;
sPaletteStructs[paletteNum].ps_field_4_0 = 0;
sPaletteStructs[paletteNum].template = &gDummyPaletteStructTemplate;
sPaletteStructs[paletteNum].active = FALSE;
sPaletteStructs[paletteNum].baseDestOffset = 0;
sPaletteStructs[paletteNum].destOffset = 0;
sPaletteStructs[paletteNum].srcIndex = 0;
sPaletteStructs[paletteNum].ps_field_4_1 = 0;
sPaletteStructs[paletteNum].ps_field_8 = 0;
sPaletteStructs[paletteNum].ps_field_9 = 0;
sPaletteStructs[paletteNum].flag = 0;
sPaletteStructs[paletteNum].countdown1 = 0;
sPaletteStructs[paletteNum].countdown2 = 0;
}
void ResetPaletteFadeControl(void)
@ -368,41 +370,41 @@ void ResetPaletteFadeControl(void)
gPaletteFade.y = 0;
gPaletteFade.targetY = 0;
gPaletteFade.blendColor = 0;
gPaletteFade.active = 0;
gPaletteFade.active = FALSE;
gPaletteFade.multipurpose2 = 0; // assign same value twice
gPaletteFade.yDec = 0;
gPaletteFade.bufferTransferDisabled = 0;
gPaletteFade.shouldResetBlendRegisters = 0;
gPaletteFade.hardwareFadeFinishing = 0;
gPaletteFade.softwareFadeFinishing = 0;
gPaletteFade.bufferTransferDisabled = FALSE;
gPaletteFade.shouldResetBlendRegisters = FALSE;
gPaletteFade.hardwareFadeFinishing = FALSE;
gPaletteFade.softwareFadeFinishing = FALSE;
gPaletteFade.softwareFadeFinishingCounter = 0;
gPaletteFade.objPaletteToggle = 0;
gPaletteFade.deltaY = 2;
}
void unref_sub_80A2048(u16 uid)
static void PaletteStruct_SetUnusedFlag(u16 id)
{
u8 paletteNum = GetPaletteNumByUid(uid);
if (paletteNum != 16)
sPaletteStructs[paletteNum].ps_field_4_1 = 1;
u8 paletteNum = PaletteStruct_GetPalNum(id);
if (paletteNum != NUM_PALETTE_STRUCTS)
sPaletteStructs[paletteNum].flag = TRUE;
}
void unref_sub_80A2074(u16 uid)
static void PaletteStruct_ClearUnusedFlag(u16 id)
{
u8 paletteNum = GetPaletteNumByUid(uid);
if (paletteNum != 16)
sPaletteStructs[paletteNum].ps_field_4_1 = 0;
u8 paletteNum = PaletteStruct_GetPalNum(id);
if (paletteNum != NUM_PALETTE_STRUCTS)
sPaletteStructs[paletteNum].flag = FALSE;
}
static u8 GetPaletteNumByUid(u16 uid)
static u8 PaletteStruct_GetPalNum(u16 id)
{
u8 i;
for (i = 0; i < 16; i++)
if (sPaletteStructs[i].base->uid == uid)
for (i = 0; i < NUM_PALETTE_STRUCTS; i++)
if (sPaletteStructs[i].template->id == id)
return i;
return 16;
return NUM_PALETTE_STRUCTS;
}
static u8 UpdateNormalPaletteFade(void)
@ -460,7 +462,7 @@ static u8 UpdateNormalPaletteFade(void)
if (gPaletteFade.y == gPaletteFade.targetY)
{
gPaletteFade_selectedPalettes = 0;
gPaletteFade.softwareFadeFinishing = 1;
gPaletteFade.softwareFadeFinishing = TRUE;
}
else
{
@ -557,7 +559,7 @@ static void BeginFastPaletteFadeInternal(u8 submode)
{
gPaletteFade.y = 31;
gPaletteFade_submode = submode & 0x3F;
gPaletteFade.active = 1;
gPaletteFade.active = TRUE;
gPaletteFade.mode = FAST_FADE;
if (submode == FAST_FADE_IN_FROM_BLACK)
@ -719,7 +721,7 @@ static u8 UpdateFastPaletteFade(void)
}
gPaletteFade.mode = NORMAL_FADE;
gPaletteFade.softwareFadeFinishing = 1;
gPaletteFade.softwareFadeFinishing = TRUE;
}
// gPaletteFade.active cannot change since the last time it was checked. So this
@ -734,10 +736,10 @@ void BeginHardwarePaletteFade(u8 blendCnt, u8 delay, u8 y, u8 targetY, u8 should
gPaletteFade_delay = delay;
gPaletteFade.y = y;
gPaletteFade.targetY = targetY;
gPaletteFade.active = 1;
gPaletteFade.active = TRUE;
gPaletteFade.mode = HARDWARE_FADE;
gPaletteFade.shouldResetBlendRegisters = shouldResetBlendRegisters & 1;
gPaletteFade.hardwareFadeFinishing = 0;
gPaletteFade.hardwareFadeFinishing = FALSE;
if (y < targetY)
gPaletteFade.yDec = 0;
@ -784,7 +786,7 @@ static u8 UpdateHardwarePaletteFade(void)
gPaletteFade_blendCnt = 0;
gPaletteFade.y = 0;
}
gPaletteFade.shouldResetBlendRegisters = 0;
gPaletteFade.shouldResetBlendRegisters = FALSE;
}
// gPaletteFade.active cannot change since the last time it was checked. So this
@ -798,11 +800,11 @@ static void UpdateBlendRegisters(void)
SetGpuReg(REG_OFFSET_BLDY, gPaletteFade.y);
if (gPaletteFade.hardwareFadeFinishing)
{
gPaletteFade.hardwareFadeFinishing = 0;
gPaletteFade.hardwareFadeFinishing = FALSE;
gPaletteFade.mode = 0;
gPaletteFade_blendCnt = 0;
gPaletteFade.y = 0;
gPaletteFade.active = 0;
gPaletteFade.active = FALSE;
}
}
@ -812,8 +814,8 @@ static bool8 IsSoftwarePaletteFadeFinishing(void)
{
if (gPaletteFade.softwareFadeFinishingCounter == 4)
{
gPaletteFade.active = 0;
gPaletteFade.softwareFadeFinishing = 0;
gPaletteFade.active = FALSE;
gPaletteFade.softwareFadeFinishing = FALSE;
gPaletteFade.softwareFadeFinishingCounter = 0;
}
else
@ -950,7 +952,7 @@ void TintPalette_CustomTone(u16 *palette, u16 count, u16 rTone, u16 gTone, u16 b
#define tId data[8]
// Blend the selected palettes in a series of steps toward or away from the color.
// Only used by the Groudon/Kyogre fight scene to flash the screen for lightning
// Only used by the Groudon/Kyogre fight scene to flash the screen for lightning.
// One call is used to fade the bg from white, while another fades the duo from black
void BlendPalettesGradually(u32 selectedPalettes, s8 delay, u8 coeff, u8 coeffTarget, u16 color, u8 priority, u8 id)
{
@ -987,8 +989,8 @@ static bool32 IsBlendPalettesGraduallyTaskActive(u8 id)
for (i = 0; i < NUM_TASKS; i++)
if ((gTasks[i].isActive == TRUE)
&& (gTasks[i].func == Task_BlendPalettesGradually)
&& (gTasks[i].tId == id))
&& (gTasks[i].func == Task_BlendPalettesGradually)
&& (gTasks[i].tId == id))
return TRUE;
return FALSE;

View File

@ -1282,12 +1282,12 @@ static bool32 SavePokeJump(void)
case 2:
if (AreLinkQueuesEmpty())
{
CreateTask(Task_LinkSave, 6);
CreateTask(Task_LinkFullSave, 6);
sPokemonJump->mainState++;
}
break;
case 3:
if (!FuncIsActiveTask(Task_LinkSave))
if (!FuncIsActiveTask(Task_LinkFullSave))
{
ClearMessageWindow();
sPokemonJump->mainState++;

View File

@ -1002,11 +1002,11 @@ static void Task_DoRecordMixing(u8 taskId)
case 2:
// Mixing Ruby/Sapphire records.
SetContinueGameWarpStatusToDynamicWarp();
FullSaveGame();
WriteSaveBlock2();
task->tState++;
break;
case 3:
if (CheckSaveFile())
if (WriteSaveBlock1Sector())
{
ClearContinueGameWarpStatus2();
task->tState = 4;
@ -1030,12 +1030,12 @@ static void Task_DoRecordMixing(u8 taskId)
case 6:
if (!Rfu_SetLinkRecovery(FALSE))
{
CreateTask(Task_LinkSave, 5);
CreateTask(Task_LinkFullSave, 5);
task->tState++;
}
break;
case 7: // wait for Task_LinkSave to finish.
if (!FuncIsActiveTask(Task_LinkSave))
case 7: // wait for Task_LinkFullSave to finish.
if (!FuncIsActiveTask(Task_LinkFullSave))
{
if (gWirelessCommType)
{

View File

@ -306,14 +306,14 @@ static bool32 IsRecordedBattleSaveValid(struct RecordedBattleSave *save)
return TRUE;
}
static bool32 RecordedBattleToSave(struct RecordedBattleSave *battleSave, struct RecordedBattleSave *saveSection)
static bool32 RecordedBattleToSave(struct RecordedBattleSave *battleSave, struct RecordedBattleSave *saveSector)
{
memset(saveSection, 0, SECTOR_SIZE);
memcpy(saveSection, battleSave, sizeof(*battleSave));
memset(saveSector, 0, SECTOR_SIZE);
memcpy(saveSector, battleSave, sizeof(*battleSave));
saveSection->checksum = CalcByteArraySum((void*)(saveSection), sizeof(*saveSection) - 4);
saveSector->checksum = CalcByteArraySum((void*)(saveSector), sizeof(*saveSector) - 4);
if (TryWriteSpecialSaveSection(SECTOR_ID_RECORDED_BATTLE, (void*)(saveSection)) != SAVE_STATUS_OK)
if (TryWriteSpecialSaveSector(SECTOR_ID_RECORDED_BATTLE, (void*)(saveSector)) != SAVE_STATUS_OK)
return FALSE;
else
return TRUE;
@ -477,9 +477,9 @@ bool32 MoveRecordedBattleToSaveData(void)
return ret;
}
static bool32 TryCopyRecordedBattleSaveData(struct RecordedBattleSave *dst, struct SaveSection *saveBuffer)
static bool32 TryCopyRecordedBattleSaveData(struct RecordedBattleSave *dst, struct SaveSector *saveBuffer)
{
if (TryReadSpecialSaveSection(SECTOR_ID_RECORDED_BATTLE, (void*)(saveBuffer)) != SAVE_STATUS_OK)
if (TryReadSpecialSaveSector(SECTOR_ID_RECORDED_BATTLE, (void*)(saveBuffer)) != SAVE_STATUS_OK)
return FALSE;
memcpy(dst, saveBuffer, sizeof(struct RecordedBattleSave));
@ -492,7 +492,7 @@ static bool32 TryCopyRecordedBattleSaveData(struct RecordedBattleSave *dst, stru
static bool32 CopyRecordedBattleFromSave(struct RecordedBattleSave *dst)
{
struct SaveSection *savBuffer = AllocZeroed(sizeof(struct SaveSection));
struct SaveSector *savBuffer = AllocZeroed(SECTOR_SIZE);
bool32 ret = TryCopyRecordedBattleSaveData(dst, savBuffer);
Free(savBuffer);

View File

@ -21,7 +21,7 @@ void ReloadSave(void)
SetSaveBlocksPointers(GetSaveBlocksPointersBaseOffset());
ResetMenuAndMonGlobals();
Save_ResetSaveCounters();
Save_LoadGameData(SAVE_NORMAL);
LoadGameSave(SAVE_NORMAL);
if (gSaveFileStatus == SAVE_STATUS_EMPTY || gSaveFileStatus == SAVE_STATUS_CORRUPT)
Sav2_ClearSetDefault();
SetPokemonCryStereo(gSaveBlock2Ptr->optionsSound);

File diff suppressed because it is too large Load Diff

View File

@ -363,9 +363,10 @@ static bool8 VerifySectorWipe(u16 sector)
ReadFlash(sector, 0, (u8 *)ptr, SECTOR_SIZE);
for (i = 0; i < 0x400; i++, ptr++)
// 1/4 because ptr is u32
for (i = 0; i < SECTOR_SIZE / 4; i++, ptr++)
if (*ptr)
return TRUE;
return TRUE; // Sector has nonzero data, failed
return FALSE;
}
@ -375,6 +376,7 @@ static bool8 WipeSector(u16 sector)
u16 i, j;
bool8 failed = TRUE;
// Attempt to wipe sector with an arbitrary attempt limit of 130
for (i = 0; failed && i < 130; i++)
{
for (j = 0; j < SECTOR_SIZE; j++)

View File

@ -1269,11 +1269,11 @@ static void Task_SaveAfterLinkBattle(u8 taskId)
break;
case 1:
SetContinueGameWarpStatusToDynamicWarp();
FullSaveGame();
WriteSaveBlock2();
*state = 2;
break;
case 2:
if (CheckSaveFile())
if (WriteSaveBlock1Sector())
{
ClearContinueGameWarpStatus2();
*state = 3;
@ -1290,11 +1290,11 @@ static void Task_SaveAfterLinkBattle(u8 taskId)
DestroyTask(taskId);
break;
case 5:
CreateTask(Task_LinkSave, 5);
CreateTask(Task_LinkFullSave, 5);
*state = 6;
break;
case 6:
if (!FuncIsActiveTask(Task_LinkSave))
if (!FuncIsActiveTask(Task_LinkFullSave))
{
*state = 3;
}
@ -1374,23 +1374,23 @@ static void RemoveSaveInfoWindow(void)
static void Task_WaitForBattleTowerLinkSave(u8 taskId)
{
if (!FuncIsActiveTask(Task_LinkSave))
if (!FuncIsActiveTask(Task_LinkFullSave))
{
DestroyTask(taskId);
EnableBothScriptContexts();
}
}
#define tPartialSave data[2]
#define tInBattleTower data[2]
void SaveForBattleTowerLink(void)
{
u8 taskId = CreateTask(Task_LinkSave, 5);
gTasks[taskId].tPartialSave = TRUE;
u8 taskId = CreateTask(Task_LinkFullSave, 5);
gTasks[taskId].tInBattleTower = TRUE;
gTasks[CreateTask(Task_WaitForBattleTowerLinkSave, 6)].data[1] = taskId;
}
#undef tPartialSave
#undef tInBattleTower
static void HideStartMenuWindow(void)
{

View File

@ -1242,11 +1242,11 @@ const u8 gText_ContestantsMonWon[] = _("{STR_VAR_1}'s {STR_VAR_2} won!");
const u8 gText_CommunicationStandby[] = _("Communication standby…");
const u8 gText_ColorDarkGray[] = _("{COLOR DARK_GRAY}");
const u8 gText_ColorDynamic6WhiteDynamic5[] = _("{COLOR_HIGHLIGHT_SHADOW DYNAMIC_COLOR6 WHITE DYNAMIC_COLOR5}"); // Unused
const u8 gText_HighlightDarkGray[] = _("{HIGHLIGHT DARK_GRAY}");
const u8 gText_HealthboxNickname[] = _("{HIGHLIGHT DARK_GRAY}");
const u8 gText_EmptySpace2[] = _(" "); // Unused
const u8 gText_DynColor2Male[] = _("{COLOR DYNAMIC_COLOR2}♂");
const u8 gText_DynColor1Female[] = _("{COLOR DYNAMIC_COLOR1}♀");
const u8 gText_DynColor2[] = _("{COLOR DYNAMIC_COLOR2}");
const u8 gText_HealthboxGender_Male[] = _("{COLOR DYNAMIC_COLOR2}♂");
const u8 gText_HealthboxGender_Female[] = _("{COLOR DYNAMIC_COLOR1}♀");
const u8 gText_HealthboxGender_None[] = _("{COLOR DYNAMIC_COLOR2}");
const u8 gText_Upper[] = _("UPPER");
const u8 gText_Lower[] = _("lower");
const u8 gText_Others[] = _("OTHERS");

View File

@ -4654,30 +4654,29 @@ static void CB2_SaveAndEndTrade(void)
MysteryGift_TryIncrementStat(CARD_STAT_NUM_TRADES, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId);
SetContinueGameWarpStatusToDynamicWarp();
sub_8153380();
LinkFullSave_Init();
gMain.state++;
sTradeData->timer = 0;
break;
case 51:
if (++sTradeData->timer == 5)
{
gMain.state++;
}
break;
case 52:
if (sub_81533AC())
if (LinkFullSave_WriteSector())
{
ClearContinueGameWarpStatus2();
gMain.state = 4;
}
else
{
// Save isn't finished, delay again
sTradeData->timer = 0;
gMain.state = 51;
}
break;
case 4:
sub_81533E0();
LinkFullSave_ReplaceLastSector();
gMain.state = 40;
sTradeData->timer = 0;
break;
@ -4709,7 +4708,7 @@ static void CB2_SaveAndEndTrade(void)
case 42:
if (_IsLinkTaskFinished())
{
sub_8153408();
LinkFullSave_SetLastSectorSecurity();
gMain.state = 5;
}
break;
@ -4965,7 +4964,7 @@ static void CB2_SaveAndEndWirelessTrade(void)
StringExpandPlaceholders(gStringVar4, gText_SavingDontTurnOffPower);
DrawTextOnTradeWindow(0, gStringVar4, 0);
IncrementGameStat(GAME_STAT_POKEMON_TRADES);
sub_8153380();
LinkFullSave_Init();
sTradeData->timer = 0;
}
break;
@ -4974,7 +4973,7 @@ static void CB2_SaveAndEndWirelessTrade(void)
gMain.state = 4;
break;
case 4:
if (sub_81533AC())
if (LinkFullSave_WriteSector())
{
gMain.state = 5;
}
@ -4985,7 +4984,7 @@ static void CB2_SaveAndEndWirelessTrade(void)
}
break;
case 5:
sub_81533E0();
LinkFullSave_ReplaceLastSector();
gMain.state = 6;
sTradeData->timer = 0;
break;
@ -5013,7 +5012,7 @@ static void CB2_SaveAndEndWirelessTrade(void)
case 8:
if (_IsLinkTaskFinished())
{
sub_8153408();
LinkFullSave_SetLastSectorSecurity();
gMain.state = 9;
}
break;