mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Continue misc link documentation, rename reset_save_heap
This commit is contained in:
parent
dfdcfc1568
commit
4efa6c882a
@ -5,20 +5,25 @@
|
||||
#include "link.h"
|
||||
#include "AgbRfu_LinkManager.h"
|
||||
|
||||
#define RFUCMD_MASK 0xFF00
|
||||
|
||||
#define RFUCMD_SEND_PACKET 0x2F00
|
||||
#define RFUCMD_BLENDER_SEND_KEYS 0x4400
|
||||
#define RFUCMD_READY_CLOSE_LINK 0x5F00
|
||||
#define RFUCMD_READY_EXIT_STANDBY 0x6600
|
||||
#define RFUCMD_0x7700 0x7700
|
||||
#define RFUCMD_0x7800 0x7800
|
||||
#define RFUCMD_0x8800 0x8800
|
||||
#define RFUCMD_0x8900 0x8900
|
||||
#define RFUCMD_SEND_PLAYER_IDS 0x7700
|
||||
#define RFUCMD_SEND_PLAYER_IDS_NEW 0x7800
|
||||
#define RFUCMD_SEND_BLOCK_INIT 0x8800
|
||||
#define RFUCMD_SEND_BLOCK 0x8900
|
||||
#define RFUCMD_SEND_BLOCK_REQ 0xA100
|
||||
#define RFUCMD_SEND_HELD_KEYS 0xBE00
|
||||
#define RFUCMD_0xED00 0xED00
|
||||
#define RFUCMD_0xEE00 0xEE00
|
||||
#define RFUCMD_DISCONNECT 0xED00
|
||||
#define RFUCMD_DISCONNECT_PARENT 0xEE00
|
||||
|
||||
#define RFU_SERIAL_7F7D 0x7F7D
|
||||
#define RFU_SERIAL_A 0x0002
|
||||
#define RFU_SERIAL_B 0x7F7D
|
||||
#define RFU_SERIAL_C 0x0000
|
||||
#define RFU_SERIAL_END 0xFFFF
|
||||
|
||||
#define RECV_QUEUE_NUM_SLOTS 32
|
||||
#define RECV_QUEUE_SLOT_LENGTH (14 * MAX_RFU_PLAYERS)
|
||||
@ -45,6 +50,24 @@
|
||||
#define RFU_STATUS_CHILD_LEAVE 11
|
||||
#define RFU_STATUS_ACK_JOIN_GROUP 12
|
||||
|
||||
#define CHILD_DATA_LENGTH 14
|
||||
|
||||
// Values for disconnectMode
|
||||
enum {
|
||||
RFU_DISCONNECT_NONE,
|
||||
RFU_DISCONNECT_ERROR,
|
||||
RFU_DISCONNECT_NORMAL,
|
||||
};
|
||||
|
||||
// Values for errorState
|
||||
enum {
|
||||
RFU_ERROR_STATE_NONE,
|
||||
RFU_ERROR_STATE_1,
|
||||
RFU_ERROR_STATE_2,
|
||||
RFU_ERROR_STATE_3,
|
||||
RFU_ERROR_STATE_IGNORE,
|
||||
};
|
||||
|
||||
// RfuTgtData.gname is read as these structs.
|
||||
struct GFtgtGnameSub
|
||||
{
|
||||
@ -125,8 +148,8 @@ struct GFRfuManager
|
||||
/* 0x00f */ u8 unk_0f;
|
||||
/* 0x010 */ u16 unk_10;
|
||||
/* 0x012 */ u16 unk_12;
|
||||
/* 0x014 */ u8 unk_14[RFU_CHILD_MAX][14];
|
||||
/* 0x04c */ u8 unk_4c[14];
|
||||
/* 0x014 */ u8 childRecvBuffer[RFU_CHILD_MAX][CHILD_DATA_LENGTH];
|
||||
/* 0x04c */ u8 childSendBuffer[CHILD_DATA_LENGTH];
|
||||
/* 0x05a */ u8 blockRequestType;
|
||||
/* 0x05b */ u8 unk_5b;
|
||||
/* 0x05c */ bool8 blockReceived[MAX_RFU_PLAYERS];
|
||||
@ -144,9 +167,9 @@ struct GFRfuManager
|
||||
/* 0x0f1 */ u8 status;
|
||||
/* 0x0f2 */ u16 packet[RFU_PACKET_SIZE];
|
||||
/* 0x0fe */ u16 resendExitStandbyTimer;
|
||||
/* 0x100 */ u16 unk_100;
|
||||
/* 0x100 */ u16 allReadyNum;
|
||||
/* 0x102 */ u8 unk_102;
|
||||
/* 0x103 */ u8 filler_103[0x10A - 0x103];
|
||||
/* 0x103 */ u8 filler_103[7];
|
||||
/* 0x10A */ struct GFtgtGname unk_10A;
|
||||
u8 filler_;
|
||||
u8 playerName[PLAYER_NAME_LENGTH + 1];
|
||||
@ -162,36 +185,33 @@ struct GFRfuManager
|
||||
/* 0xc87 */ u8 recvCmds[5][7][2];
|
||||
/* 0xccd */ u8 parentId;
|
||||
/* 0xcce */ u8 multiplayerId;
|
||||
/* 0xccf */ u8 unk_ccf;
|
||||
/* 0xcd0 */ vu8 unk_cd0;
|
||||
/* 0xccf */ u8 connectParentFailures;
|
||||
/* 0xcd0 */ vu8 childSendCount;
|
||||
/* 0xcd1 */ u8 partnerSendStatuses[RFU_CHILD_MAX];
|
||||
/* 0xcd5 */ u8 partnerRecvStatuses[RFU_CHILD_MAX];
|
||||
/* 0xcd9 */ u8 unk_cd9;
|
||||
/* 0xcd9 */ bool8 stopNewConnections;
|
||||
/* 0xcda */ u8 unk_cda;
|
||||
/* 0xcdb */ vbool8 unk_cdb;
|
||||
/* 0xcdc */ vbool8 unk_cdc;
|
||||
/* 0xcdd */ u8 unk_cdd;
|
||||
/* 0xcde */ u8 linkPlayerIdx[RFU_CHILD_MAX];
|
||||
/* 0xce2 */ u8 unk_ce2;
|
||||
/* 0xce2 */ u8 unk_ce3;
|
||||
/* 0xce4 */ u8 unk_ce4;
|
||||
/* 0xce2 */ u8 disconnectSlots;
|
||||
/* 0xce4 */ u8 disconnectMode;
|
||||
/* 0xce5 */ u8 unk_ce5;
|
||||
/* 0xce5 */ u8 unk_ce6;
|
||||
/* 0xce7 */ u8 acceptSlot_flag;
|
||||
/* 0xce8 */ u8 unk_ce8;
|
||||
/* 0xce8 */ bool8 unk_ce8;
|
||||
/* 0xce9 */ u8 unk_ce9;
|
||||
/* 0xcea */ u8 unk_cea[4];
|
||||
/* 0xcee */ u8 unk_cee[4];
|
||||
}; // size = 0xcf4
|
||||
|
||||
// Exported RAM declarations
|
||||
|
||||
extern struct GFtgtGname gHostRFUtgtGnameBuffer;
|
||||
extern u8 gHostRFUtgtUnameBuffer[];
|
||||
extern struct GFRfuManager Rfu;
|
||||
extern u8 gWirelessStatusIndicatorSpriteId;
|
||||
|
||||
// Exported ROM declarations
|
||||
void WipeTrainerNameRecords(void);
|
||||
void InitRFUAPI(void);
|
||||
void LinkRfu_Shutdown(void);
|
||||
@ -219,13 +239,13 @@ bool32 RfuHasErrored(void);
|
||||
bool32 IsRfuRecvQueueEmpty(void);
|
||||
u32 GetRfuRecvQueueLength(void);
|
||||
void RfuVSync(void);
|
||||
void sub_80111B0(bool32 a0);
|
||||
void RfuSetIgnoreError(bool32 enable);
|
||||
u8 RfuGetStatus(void);
|
||||
struct GFtgtGname *GetHostRFUtgtGname(void);
|
||||
void UpdateGameData_GroupLockedIn(u8 a0);
|
||||
void GetLinkmanErrorParams(u32 a0);
|
||||
void RfuSetStatus(u8 a0, u16 a1);
|
||||
u8 sub_801048C(bool32 a0);
|
||||
void UpdateGameData_GroupLockedIn(u8 started);
|
||||
void GetLinkmanErrorParams(u32 msg);
|
||||
void RfuSetStatus(u8 status, u16 msg);
|
||||
u8 Rfu_SetLinkRecovery(bool32 enable);
|
||||
void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *buff1, u8 *buff2);
|
||||
void SetHostRFUtgtGname(u8 activity, u32 child_sprite_genders, bool32 started);
|
||||
void InitializeRfuLinkManager_LinkLeader(u32 a0);
|
||||
@ -235,10 +255,10 @@ bool32 RfuTryDisconnectLeavingChildren(void);
|
||||
bool32 HasTrainerLeftPartnersList(u16 trainerId, const u8 *name);
|
||||
void SendRfuStatusToPartner(u8 status, u16 trainerId, const u8 *name);
|
||||
u32 WaitSendRfuStatusToPartner(u16 trainerId, const u8 *name);
|
||||
void RequestDisconnectSlotByTrainerNameAndId(const u8 *a0, u16 a1);
|
||||
void RequestDisconnectSlotByTrainerNameAndId(const u8 *name, u16 id);
|
||||
bool8 LmanAcceptSlotFlagIsNotZero(void);
|
||||
bool32 WaitRfuState(bool32 a0);
|
||||
void sub_801103C(void);
|
||||
bool32 WaitRfuState(bool32 force);
|
||||
void GetOtherPlayersInfoFlags(void);
|
||||
void InitializeRfuLinkManager_JoinGroup(void);
|
||||
void SendLeaveGroupNotice(void);
|
||||
void RecordMixTrainerNames(void);
|
||||
@ -246,7 +266,7 @@ void LinkRfu_CreateConnectionAsParent(void);
|
||||
void LinkRfu_StopManagerBeforeEnteringChat(void);
|
||||
void UpdateGameData_SetActivity(u8 activity, u32 flags, bool32 started);
|
||||
void CreateTask_RfuReconnectWithParent(const u8 *src, u16 trainerId);
|
||||
void SetGnameBufferWonderFlags(bool32 a0, bool32 a1);
|
||||
void SetGnameBufferWonderFlags(bool32 hasNews, bool32 hasCard);
|
||||
void ClearAndInitHostRFUtgtGname(void);
|
||||
void SetTradeBoardRegisteredMonInfo(u32 type, u32 species, u32 level);
|
||||
void InitializeRfuLinkManager_EnterUnionRoom(void);
|
||||
@ -254,8 +274,8 @@ void sub_8012188(const u8 *name, struct GFtgtGname *structPtr, u8 a2);
|
||||
bool32 IsUnionRoomListenTaskActive(void);
|
||||
void Rfu_SendPacket(void *data);
|
||||
bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name);
|
||||
void sub_8011DE0(u32 arg0);
|
||||
u8 sub_801100C(s32 a0);
|
||||
void Rfu_DisconnectPlayerById(u32 playerIdx);
|
||||
u8 GetLinkPlayerInfoFlags(s32 playerId);
|
||||
void sub_800EF7C(void);
|
||||
bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *buff1, u8 *buff2, u8 idx);
|
||||
bool8 LinkRfu_GetNameIfSerial7F7D(struct GFtgtGname *buff1, u8 *buff2, u8 idx);
|
||||
@ -265,9 +285,9 @@ void DestroyTask_RfuIdle(void);
|
||||
void ClearRecvCommands(void);
|
||||
void LinkRfu_FatalError(void);
|
||||
bool32 sub_8011A9C(void);
|
||||
void sub_80104B0(void);
|
||||
void sub_8011A50(void);
|
||||
void sub_80110B8(u32 a0);
|
||||
void Rfu_StopPartnerSearch(void);
|
||||
void RfuSetNormalDisconnectMode(void);
|
||||
void SetUnionRoomChatPlayerData(u32 numPlayers);
|
||||
bool32 IsRfuSerialNumberValid(u32 serialNo);
|
||||
bool8 IsRfuRecoveringFromLinkLoss(void);
|
||||
void RfuRecvQueue_Reset(struct RfuRecvQueue *queue);
|
||||
|
6
include/reload_save.h
Normal file
6
include/reload_save.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef GUARD_RELOAD_SAVE_H
|
||||
#define GUARD_RELOAD_SAVE_H
|
||||
|
||||
void ReloadSave(void);
|
||||
|
||||
#endif // GUARD_RELOAD_SAVE_H
|
@ -1,12 +0,0 @@
|
||||
#ifndef GUARD_RESET_SAVE_HEAP_H
|
||||
#define GUARD_RESET_SAVE_HEAP_H
|
||||
|
||||
// Exported type declarations
|
||||
|
||||
// Exported RAM declarations
|
||||
|
||||
// Exported ROM declarations
|
||||
|
||||
void sub_81700F8(void);
|
||||
|
||||
#endif //GUARD_RESET_SAVE_HEAP_H
|
@ -36,6 +36,7 @@ struct SaveSectionOffsets
|
||||
|
||||
// Emerald changes this definition to be the sectors per slot.
|
||||
#define NUM_SECTORS_PER_SLOT 16
|
||||
#define NUM_SAVE_SLOTS 2
|
||||
|
||||
#define UNKNOWN_CHECK_VALUE 0x8012025
|
||||
#define SPECIAL_SECTION_SENTINEL 0xB39D
|
||||
@ -104,7 +105,7 @@ bool8 sub_8153408(void);
|
||||
bool8 FullSaveGame(void);
|
||||
bool8 CheckSaveFile(void);
|
||||
u8 Save_LoadGameData(u8 saveType);
|
||||
u16 sub_815355C(void);
|
||||
u16 GetSaveBlocksPointersBaseOffset(void);
|
||||
u32 TryReadSpecialSaveSection(u8 sector, u8* dst);
|
||||
u32 TryWriteSpecialSaveSection(u8 sector, u8* src);
|
||||
void Task_LinkSave(u8 taskId);
|
||||
|
@ -256,7 +256,7 @@ SECTIONS {
|
||||
src/battle_controller_wally.o(.text);
|
||||
src/player_pc.o(.text);
|
||||
src/intro.o(.text);
|
||||
src/reset_save_heap.o(.text);
|
||||
src/reload_save.o(.text);
|
||||
src/field_region_map.o(.text);
|
||||
src/battle_anim_throw.o(.text);
|
||||
src/hall_of_fame.o(.text);
|
||||
|
@ -2069,7 +2069,7 @@ static bool32 CheckRecvCmdMatches(u16 recvCmd, u16 linkCmd, u16 rfuCmd)
|
||||
{
|
||||
if (gReceivedRemoteLinkPlayers && gWirelessCommType)
|
||||
{
|
||||
if ((recvCmd & 0xFF00) == rfuCmd)
|
||||
if ((recvCmd & RFUCMD_MASK) == rfuCmd)
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
@ -3135,7 +3135,7 @@ static void UpdateBlenderCenter(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((gRecvCmds[0][BLENDER_COMM_INPUT_STATE] & 0xFF00) == RFUCMD_BLENDER_SEND_KEYS)
|
||||
if ((gRecvCmds[0][BLENDER_COMM_INPUT_STATE] & RFUCMD_MASK) == RFUCMD_BLENDER_SEND_KEYS)
|
||||
{
|
||||
sBerryBlender->progressBarValue = gRecvCmds[0][BLENDER_COMM_PROGRESS_BAR];
|
||||
sBerryBlender->arrowPos = gRecvCmds[0][BLENDER_COMM_ARROW_POS];
|
||||
|
@ -984,12 +984,12 @@ static u32 QuitBerryCrush(MainCallback exitCallback)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define ERROR_EXIT(exitCallback) \
|
||||
{ \
|
||||
SetMainCallback2(exitCallback); \
|
||||
Rfu.unk_10 = 0; \
|
||||
Rfu.unk_12 = 0; \
|
||||
Rfu.errorState = 1; \
|
||||
#define ERROR_EXIT(exitCallback) \
|
||||
{ \
|
||||
SetMainCallback2(exitCallback); \
|
||||
Rfu.unk_10 = 0; \
|
||||
Rfu.unk_12 = 0; \
|
||||
Rfu.errorState = RFU_ERROR_STATE_1; \
|
||||
}
|
||||
|
||||
void StartBerryCrush(MainCallback exitCallback)
|
||||
@ -2565,7 +2565,7 @@ static void HandlePartnerInput(struct BerryCrushGame *game)
|
||||
linkState = (struct BerryCrushGame_LinkState *)gRecvCmds[i];
|
||||
|
||||
// Skip player if we have not received a packet from them
|
||||
if ((linkState->rfuCmd & 0xFF00) != RFUCMD_SEND_PACKET)
|
||||
if ((linkState->rfuCmd & RFUCMD_MASK) != RFUCMD_SEND_PACKET)
|
||||
continue;
|
||||
if (linkState->sendFlag != SEND_GAME_STATE)
|
||||
continue;
|
||||
@ -2805,7 +2805,7 @@ static void RecvLinkData(struct BerryCrushGame *game)
|
||||
for (i = 0; i < game->playerCount; i++)
|
||||
game->players[i].inputState = INPUT_STATE_NONE;
|
||||
|
||||
if ((gRecvCmds[0][0] & 0xFF00) != RFUCMD_SEND_PACKET)
|
||||
if ((gRecvCmds[0][0] & RFUCMD_MASK) != RFUCMD_SEND_PACKET)
|
||||
{
|
||||
game->playedSound = FALSE;
|
||||
return;
|
||||
|
@ -3106,7 +3106,7 @@ static u32 RecvPacket_ReadyToStart(u32 playerId)
|
||||
{
|
||||
struct ReadyToStartPacket *packet;
|
||||
|
||||
if ((gRecvCmds[0][0] & 0xFF00) != RFUCMD_SEND_PACKET)
|
||||
if ((gRecvCmds[0][0] & RFUCMD_MASK) != RFUCMD_SEND_PACKET)
|
||||
return FALSE;
|
||||
|
||||
packet = (void *)&gRecvCmds[playerId][1];
|
||||
@ -3233,7 +3233,7 @@ static bool32 RecvPacket_GameState(u32 playerId,
|
||||
struct GameStatePacket *packet;
|
||||
struct DodrioGame_Berries *berries = &player->berries;
|
||||
|
||||
if ((gRecvCmds[0][0] & 0xFF00) != RFUCMD_SEND_PACKET)
|
||||
if ((gRecvCmds[0][0] & RFUCMD_MASK) != RFUCMD_SEND_PACKET)
|
||||
return FALSE;
|
||||
|
||||
packet = (void *)&gRecvCmds[0][1];
|
||||
@ -3310,7 +3310,7 @@ static bool32 RecvPacket_PickState(u32 playerId, u8 *pickState)
|
||||
{
|
||||
struct PickStatePacket *packet;
|
||||
|
||||
if ((gRecvCmds[0][0] & 0xFF00) != RFUCMD_SEND_PACKET)
|
||||
if ((gRecvCmds[0][0] & RFUCMD_MASK) != RFUCMD_SEND_PACKET)
|
||||
return FALSE;
|
||||
|
||||
packet = (void *)&gRecvCmds[playerId][1];
|
||||
@ -3341,7 +3341,7 @@ static bool32 RecvPacket_ReadyToEnd(u32 playerId)
|
||||
{
|
||||
struct ReadyToEndPacket *packet;
|
||||
|
||||
if ((gRecvCmds[0][0] & 0xFF00) != RFUCMD_SEND_PACKET)
|
||||
if ((gRecvCmds[0][0] & RFUCMD_MASK) != RFUCMD_SEND_PACKET)
|
||||
return FALSE;
|
||||
|
||||
packet = (void *)&gRecvCmds[playerId][1];
|
||||
|
@ -1142,7 +1142,7 @@ void CB2_InitCopyrightScreenAfterBootup(void)
|
||||
{
|
||||
if (!SetUpCopyrightScreen())
|
||||
{
|
||||
SetSaveBlocksPointers(sub_815355C());
|
||||
SetSaveBlocksPointers(GetSaveBlocksPointersBaseOffset());
|
||||
ResetMenuAndMonGlobals();
|
||||
Save_ResetSaveCounters();
|
||||
Save_LoadGameData(SAVE_NORMAL);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "m4a.h"
|
||||
#include "malloc.h"
|
||||
#include "reset_save_heap.h"
|
||||
#include "reload_save.h"
|
||||
#include "save.h"
|
||||
#include "bg.h"
|
||||
#include "window.h"
|
||||
@ -1705,7 +1705,7 @@ static void CB2_PrintErrorMessage(void)
|
||||
PlaySE(SE_PIN);
|
||||
gWirelessCommType = 0;
|
||||
sLinkErrorBuffer.disconnected = FALSE;
|
||||
sub_81700F8();
|
||||
ReloadSave();
|
||||
}
|
||||
}
|
||||
else if (gWirelessCommType == 2)
|
||||
|
673
src/link_rfu_2.c
673
src/link_rfu_2.c
File diff suppressed because it is too large
Load Diff
@ -719,7 +719,7 @@ bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *buff1, u8 *buff2, u8 idx)
|
||||
bool8 LinkRfu_GetNameIfSerial7F7D(struct GFtgtGname *buff1, u8 *buff2, u8 idx)
|
||||
{
|
||||
bool8 retVal = FALSE;
|
||||
if (gRfuLinkStatus->partner[idx].serialNo == RFU_SERIAL_7F7D)
|
||||
if (gRfuLinkStatus->partner[idx].serialNo == RFU_SERIAL_B)
|
||||
{
|
||||
memcpy(buff1, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
|
||||
memcpy(buff2, gRfuLinkStatus->partner[idx].uname, PLAYER_NAME_LENGTH + 1);
|
||||
|
@ -71,6 +71,7 @@ void ClearSav1(void)
|
||||
CpuFill16(0, &gSaveblock1, sizeof(struct SaveBlock1) + sizeof(gSaveblock1_DMA));
|
||||
}
|
||||
|
||||
// Offset is the sum of the trainer id bytes
|
||||
void SetSaveBlocksPointers(u16 offset)
|
||||
{
|
||||
struct SaveBlock1** sav1_LocalVar = &gSaveBlock1Ptr;
|
||||
|
@ -3945,7 +3945,7 @@ static bool32 RecvPacket_MonInfo(int multiplayerId, struct PokemonJump_MonInfo *
|
||||
{
|
||||
struct MonInfoPacket packet;
|
||||
|
||||
if ((gRecvCmds[multiplayerId][0] & 0xFF00) != RFUCMD_SEND_PACKET)
|
||||
if ((gRecvCmds[multiplayerId][0] & RFUCMD_MASK) != RFUCMD_SEND_PACKET)
|
||||
return FALSE;
|
||||
|
||||
memcpy(&packet, &gRecvCmds[multiplayerId][1], sizeof(packet));
|
||||
@ -4010,7 +4010,7 @@ static bool32 RecvPacket_LeaderState(struct PokemonJump_Player *player, struct P
|
||||
{
|
||||
struct LeaderStatePacket packet;
|
||||
|
||||
if ((gRecvCmds[0][0] & 0xFF00) != RFUCMD_SEND_PACKET)
|
||||
if ((gRecvCmds[0][0] & RFUCMD_MASK) != RFUCMD_SEND_PACKET)
|
||||
return FALSE;
|
||||
|
||||
memcpy(&packet, &gRecvCmds[0][1], sizeof(packet));
|
||||
@ -4057,7 +4057,7 @@ static bool32 RecvPacket_MemberStateToLeader(struct PokemonJump_Player *player,
|
||||
{
|
||||
struct MemberStatePacket packet;
|
||||
|
||||
if ((gRecvCmds[multiplayerId][0] & 0xFF00) != RFUCMD_SEND_PACKET)
|
||||
if ((gRecvCmds[multiplayerId][0] & RFUCMD_MASK) != RFUCMD_SEND_PACKET)
|
||||
return FALSE;
|
||||
|
||||
memcpy(&packet, &gRecvCmds[multiplayerId][1], sizeof(packet));
|
||||
@ -4078,7 +4078,7 @@ static bool32 RecvPacket_MemberStateToMember(struct PokemonJump_Player *player,
|
||||
{
|
||||
struct MemberStatePacket packet;
|
||||
|
||||
if ((gRecvCmds[multiplayerId][0] & 0xFF00) != RFUCMD_SEND_PACKET)
|
||||
if ((gRecvCmds[multiplayerId][0] & RFUCMD_MASK) != RFUCMD_SEND_PACKET)
|
||||
return FALSE;
|
||||
|
||||
memcpy(&packet, &gRecvCmds[multiplayerId][1], sizeof(packet));
|
||||
|
@ -981,7 +981,7 @@ static void Task_DoRecordMixing(u8 taskId)
|
||||
|
||||
// Mixing Emerald records.
|
||||
case 6:
|
||||
if (!sub_801048C(FALSE))
|
||||
if (!Rfu_SetLinkRecovery(FALSE))
|
||||
{
|
||||
CreateTask(Task_LinkSave, 5);
|
||||
task->data[0]++;
|
||||
@ -992,7 +992,7 @@ static void Task_DoRecordMixing(u8 taskId)
|
||||
{
|
||||
if (gWirelessCommType)
|
||||
{
|
||||
sub_801048C(TRUE);
|
||||
Rfu_SetLinkRecovery(TRUE);
|
||||
task->data[0] = 8;
|
||||
}
|
||||
else
|
||||
|
@ -8,17 +8,17 @@
|
||||
#include "overworld.h"
|
||||
#include "malloc.h"
|
||||
|
||||
void sub_81700F8(void)
|
||||
// Reloads the game, continuing from the point of the last save
|
||||
// Used to gracefully exit after a link connection error
|
||||
void ReloadSave(void)
|
||||
{
|
||||
u16 imeBackup;
|
||||
|
||||
imeBackup = REG_IME;
|
||||
u16 imeBackup = REG_IME;
|
||||
REG_IME = 0;
|
||||
RegisterRamReset(RESET_EWRAM);
|
||||
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_FORCED_BLANK);
|
||||
REG_IME = imeBackup;
|
||||
gMain.inBattle = FALSE;
|
||||
SetSaveBlocksPointers(sub_815355C());
|
||||
SetSaveBlocksPointers(GetSaveBlocksPointersBaseOffset());
|
||||
ResetMenuAndMonGlobals();
|
||||
Save_ResetSaveCounters();
|
||||
Save_LoadGameData(SAVE_NORMAL);
|
44
src/save.c
44
src/save.c
@ -126,16 +126,16 @@ static bool32 SetDamagedSectorBits(u8 op, u8 bit)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
static u8 SaveWriteToFlash(u16 a1, const struct SaveSectionLocation *location)
|
||||
static u8 SaveWriteToFlash(u16 sectorId, const struct SaveSectionLocation *location)
|
||||
{
|
||||
u32 status;
|
||||
u16 i;
|
||||
|
||||
gFastSaveSection = &gSaveDataBuffer;
|
||||
|
||||
if (a1 != 0xFFFF) // for link
|
||||
if (sectorId != 0xFFFF) // for link
|
||||
{
|
||||
status = HandleWriteSector(a1, location);
|
||||
status = HandleWriteSector(sectorId, location);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -169,7 +169,7 @@ static u8 HandleWriteSector(u16 sectorId, const struct SaveSectionLocation *loca
|
||||
|
||||
sector = sectorId + gLastWrittenSector;
|
||||
sector %= SECTOR_SAVE_SLOT_LENGTH;
|
||||
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % 2);
|
||||
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % NUM_SAVE_SLOTS);
|
||||
|
||||
data = location[sectorId].data;
|
||||
size = location[sectorId].size;
|
||||
@ -292,7 +292,7 @@ static u8 ClearSaveData_2(u16 sectorId, const struct SaveSectionLocation *locati
|
||||
|
||||
sector = sectorId + gLastWrittenSector;
|
||||
sector %= SECTOR_SAVE_SLOT_LENGTH;
|
||||
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % 2);
|
||||
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % NUM_SAVE_SLOTS);
|
||||
|
||||
data = location[sectorId].data;
|
||||
size = location[sectorId].size;
|
||||
@ -362,7 +362,7 @@ static u8 sav12_xor_get(u16 sectorId, const struct SaveSectionLocation *location
|
||||
|
||||
sector = sectorId + gLastWrittenSector; // no sub 1?
|
||||
sector %= SECTOR_SAVE_SLOT_LENGTH;
|
||||
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % 2);
|
||||
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % NUM_SAVE_SLOTS);
|
||||
|
||||
if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), 0x25))
|
||||
{
|
||||
@ -385,7 +385,7 @@ static u8 sub_8152CAC(u16 sectorId, const struct SaveSectionLocation *location)
|
||||
|
||||
sector = sectorId + gLastWrittenSector - 1;
|
||||
sector %= SECTOR_SAVE_SLOT_LENGTH;
|
||||
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % 2);
|
||||
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % NUM_SAVE_SLOTS);
|
||||
|
||||
if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), ((u8 *)gFastSaveSection)[sizeof(struct UnkSaveSection)]))
|
||||
{
|
||||
@ -408,7 +408,7 @@ static u8 sub_8152D44(u16 sectorId, const struct SaveSectionLocation *location)
|
||||
|
||||
sector = sectorId + gLastWrittenSector - 1; // no sub 1?
|
||||
sector %= SECTOR_SAVE_SLOT_LENGTH;
|
||||
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % 2);
|
||||
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % NUM_SAVE_SLOTS);
|
||||
|
||||
if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), 0x25))
|
||||
{
|
||||
@ -446,12 +446,12 @@ static u8 sub_8152E10(u16 a1, const struct SaveSectionLocation *location)
|
||||
{
|
||||
u16 i;
|
||||
u16 checksum;
|
||||
u16 v3 = SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % 2);
|
||||
u16 slotOffset = SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % NUM_SAVE_SLOTS);
|
||||
u16 id;
|
||||
|
||||
for (i = 0; i < SECTOR_SAVE_SLOT_LENGTH; i++)
|
||||
{
|
||||
DoReadFlashWholeSection(i + v3, gFastSaveSection);
|
||||
DoReadFlashWholeSection(i + slotOffset, gFastSaveSection);
|
||||
id = gFastSaveSection->id;
|
||||
if (id == 0)
|
||||
gLastWrittenSector = i;
|
||||
@ -824,27 +824,29 @@ u8 Save_LoadGameData(u8 saveType)
|
||||
return status;
|
||||
}
|
||||
|
||||
u16 sub_815355C(void)
|
||||
u16 GetSaveBlocksPointersBaseOffset(void)
|
||||
{
|
||||
u16 i, v3;
|
||||
u16 i, slotOffset;
|
||||
struct SaveSection* savSection;
|
||||
|
||||
savSection = gFastSaveSection = &gSaveDataBuffer;
|
||||
if (gFlashMemoryPresent != TRUE)
|
||||
return SAVE_STATUS_EMPTY;
|
||||
return 0;
|
||||
UpdateSaveAddresses();
|
||||
GetSaveValidStatus(gRamSaveSectionLocations);
|
||||
v3 = SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % 2);
|
||||
slotOffset = SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % NUM_SAVE_SLOTS);
|
||||
for (i = 0; i < SECTOR_SAVE_SLOT_LENGTH; i++)
|
||||
{
|
||||
DoReadFlashWholeSection(i + v3, gFastSaveSection);
|
||||
if (gFastSaveSection->id == 0)
|
||||
return savSection->data[10] +
|
||||
savSection->data[11] +
|
||||
savSection->data[12] +
|
||||
savSection->data[13];
|
||||
DoReadFlashWholeSection(i + slotOffset, gFastSaveSection);
|
||||
|
||||
// Base offset for SaveBlock2 is calculated using the trainer id
|
||||
if (gFastSaveSection->id == SECTOR_ID_SAVEBLOCK2)
|
||||
return savSection->data[offsetof(struct SaveBlock2, playerTrainerId[0])] +
|
||||
savSection->data[offsetof(struct SaveBlock2, playerTrainerId[1])] +
|
||||
savSection->data[offsetof(struct SaveBlock2, playerTrainerId[2])] +
|
||||
savSection->data[offsetof(struct SaveBlock2, playerTrainerId[3])];
|
||||
}
|
||||
return SAVE_STATUS_EMPTY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 TryReadSpecialSaveSection(u8 sector, u8* dst)
|
||||
|
@ -459,7 +459,7 @@ static void CB2_CreateTradeMenu(void)
|
||||
sTradeMenuData->timer = 0;
|
||||
if (gWirelessCommType)
|
||||
{
|
||||
sub_801048C(TRUE);
|
||||
Rfu_SetLinkRecovery(TRUE);
|
||||
SetLinkStandbyCallback();
|
||||
}
|
||||
}
|
||||
@ -1709,7 +1709,7 @@ static void CancelTrade_2(void)
|
||||
|
||||
static void LinkTradeWaitForQueue(void)
|
||||
{
|
||||
if (!sub_801048C(FALSE) && GetNumQueuedActions() == 0)
|
||||
if (!Rfu_SetLinkRecovery(FALSE) && GetNumQueuedActions() == 0)
|
||||
{
|
||||
SetLinkStandbyCallback();
|
||||
sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_START_LINK_TRADE;
|
||||
|
@ -680,7 +680,7 @@ static void Task_TryBecomeLinkLeader(u8 taskId)
|
||||
if (gReceivedRemoteLinkPlayers != 0)
|
||||
{
|
||||
if (IsActivityWithVariableGroupSize(gPlayerCurrActivity))
|
||||
sub_801103C();
|
||||
GetOtherPlayersInfoFlags();
|
||||
UpdateGameData_GroupLockedIn(TRUE);
|
||||
CreateTask_RunScriptAndFadeToActivity();
|
||||
Leader_DestroyResources(data);
|
||||
@ -1291,7 +1291,7 @@ static void Task_ListenToWireless(u8 taskId)
|
||||
SetWirelessCommType1();
|
||||
OpenLink();
|
||||
InitializeRfuLinkManager_JoinGroup();
|
||||
sub_80111B0(TRUE);
|
||||
RfuSetIgnoreError(TRUE);
|
||||
data->field_4 = AllocZeroed(4 * sizeof(struct UnkStruct_x1C));
|
||||
data->field_0 = AllocZeroed(16 * sizeof(struct UnkStruct_x20));
|
||||
data->state = 2;
|
||||
@ -2894,7 +2894,7 @@ static void Task_RunUnionRoom(u8 taskId)
|
||||
ReceiveUnionRoomActivityPacket(uroom);
|
||||
if (UnionRoom_HandleContactFromOtherPlayer(uroom) && JOY_NEW(B_BUTTON))
|
||||
{
|
||||
sub_8011DE0(1);
|
||||
Rfu_DisconnectPlayerById(1);
|
||||
StringCopy(gStringVar4, sText_ChatEnded);
|
||||
uroom->state = UR_STATE_CANCEL_REQUEST_PRINT_MSG;
|
||||
}
|
||||
@ -2908,9 +2908,9 @@ static void Task_RunUnionRoom(u8 taskId)
|
||||
case 0: // ACCEPT
|
||||
uroom->playerSendBuffer[0] = ACTIVITY_ACCEPT | IN_UNION_ROOM;
|
||||
if (gPlayerCurrActivity == (ACTIVITY_CHAT | IN_UNION_ROOM))
|
||||
UpdateGameData_SetActivity(gPlayerCurrActivity | IN_UNION_ROOM, sub_801100C(1), FALSE);
|
||||
UpdateGameData_SetActivity(gPlayerCurrActivity | IN_UNION_ROOM, GetLinkPlayerInfoFlags(1), FALSE);
|
||||
else
|
||||
UpdateGameData_SetActivity(gPlayerCurrActivity | IN_UNION_ROOM, sub_801100C(1), TRUE);
|
||||
UpdateGameData_SetActivity(gPlayerCurrActivity | IN_UNION_ROOM, GetLinkPlayerInfoFlags(1), TRUE);
|
||||
|
||||
uroom->field_8->arr[0].field_1B = 0;
|
||||
taskData[3] = 0;
|
||||
@ -3213,7 +3213,7 @@ void SetUsingUnionRoomStartMenu(void)
|
||||
|
||||
static void ReceiveUnionRoomActivityPacket(struct WirelessLink_URoom *data)
|
||||
{
|
||||
if (gRecvCmds[1][1] != 0 && (gRecvCmds[1][0] & 0xFF00) == 0x2F00)
|
||||
if (gRecvCmds[1][1] != 0 && (gRecvCmds[1][0] & RFUCMD_MASK) == RFUCMD_SEND_PACKET)
|
||||
{
|
||||
data->recvActivityRequest[0] = gRecvCmds[1][1];
|
||||
if (gRecvCmds[1][1] == (ACTIVITY_TRADE | IN_UNION_ROOM))
|
||||
@ -3282,7 +3282,7 @@ static void Task_InitUnionRoom(u8 taskId)
|
||||
SetWirelessCommType1();
|
||||
OpenLink();
|
||||
InitializeRfuLinkManager_EnterUnionRoom();
|
||||
sub_80111B0(TRUE);
|
||||
RfuSetIgnoreError(TRUE);
|
||||
data->state = 2;
|
||||
break;
|
||||
case 2:
|
||||
@ -3877,32 +3877,22 @@ static bool32 AreUnionRoomPlayerGnamesDifferent(struct WirelessGnameUnamePair *p
|
||||
s32 i;
|
||||
|
||||
if (pair1->gname.activity != pair2->gname.activity)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (pair1->gname.started != pair2->gname.started)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (i = 0; i < RFU_CHILD_MAX; i++)
|
||||
{
|
||||
if (pair1->gname.child_sprite_gender[i] != pair2->gname.child_sprite_gender[i])
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (pair1->gname.species != pair2->gname.species)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (pair1->gname.type != pair2->gname.type)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -4246,7 +4236,7 @@ static s32 GetChatLeaderActionRequestMessage(u8 *dst, u32 gender, u16 *activityD
|
||||
StringCopy(uroom->activityRequestStrbufs[1], gSpeciesNames[sUnionRoomTrade.playerSpecies]);
|
||||
for (i = 0; i < RFU_CHILD_MAX; i++)
|
||||
{
|
||||
if (gRfuLinkStatus->partner[i].serialNo == 2)
|
||||
if (gRfuLinkStatus->partner[i].serialNo == RFU_SERIAL_A)
|
||||
{
|
||||
ConvertIntToDecimalStringN(uroom->activityRequestStrbufs[2], activityData[2], STR_CONV_MODE_LEFT_ALIGN, 3);
|
||||
StringCopy(uroom->activityRequestStrbufs[3], gSpeciesNames[activityData[1]]);
|
||||
|
@ -1198,7 +1198,7 @@ static void Chat_AskQuitChatting(void)
|
||||
sChat->funcState = 3;
|
||||
break;
|
||||
case 0:
|
||||
sub_80104B0();
|
||||
Rfu_StopPartnerSearch();
|
||||
PrepareSendBuffer_Disband(sChat->sendMessageBuffer);
|
||||
sChat->funcState = 4;
|
||||
sChat->tryQuitAgainTimer = 0;
|
||||
@ -1819,7 +1819,7 @@ static void PrepareSendBuffer_Leave(u8 *buffer)
|
||||
buffer[0] = CHAT_MESSAGE_LEAVE;
|
||||
StringCopy(&buffer[1], gSaveBlock2Ptr->playerName);
|
||||
buffer[1 + (PLAYER_NAME_LENGTH + 1)] = sChat->multiplayerId;
|
||||
sub_8011A50();
|
||||
RfuSetNormalDisconnectMode();
|
||||
}
|
||||
|
||||
static void PrepareSendBuffer_Drop(u8 *buffer)
|
||||
@ -2079,13 +2079,12 @@ static void Task_ReceiveChatMessage(u8 taskId)
|
||||
{
|
||||
if (GetLinkPlayerCount() == 2)
|
||||
{
|
||||
sub_80104B0();
|
||||
Rfu_StopPartnerSearch();
|
||||
sChat->exitType = 1;
|
||||
DestroyTask(taskId);
|
||||
return;
|
||||
}
|
||||
|
||||
sub_8011DE0(tCurrLinkPlayer);
|
||||
Rfu_DisconnectPlayerById(tCurrLinkPlayer);
|
||||
}
|
||||
|
||||
tState = 3;
|
||||
@ -2104,7 +2103,7 @@ static void Task_ReceiveChatMessage(u8 taskId)
|
||||
if (!sub_8011A9C())
|
||||
{
|
||||
if (!sChat->multiplayerId)
|
||||
sub_80110B8(sChat->linkPlayerCount);
|
||||
SetUnionRoomChatPlayerData(sChat->linkPlayerCount);
|
||||
|
||||
tState = 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user