diff --git a/include/comm_player_manager.h b/include/comm_player_manager.h index e65c2c48df..8dab4d72a4 100644 --- a/include/comm_player_manager.h +++ b/include/comm_player_manager.h @@ -60,69 +60,69 @@ typedef struct CommPlayerManager { } CommPlayerManager; CommPlayerManager *CommPlayerMan_Get(void); -BOOL CommPlayerMan_Init(void *param0, FieldSystem *fieldSystem, BOOL param2); +BOOL CommPlayerMan_Init(void *dest, FieldSystem *fieldSystem, BOOL isUnderground); void CommPlayerMan_Reset(void); void CommPlayerMan_Restart(void); -void CommPlayerMan_Delete(BOOL param0); +void CommPlayerMan_Delete(BOOL deletePlayerData); void CommPlayerMan_Reinit(void); void CommPlayerMan_Stop(void); void CommPlayer_InitPersonal(void); -void CommPlayer_CopyPersonal(int param0); -void CommPlayer_SendXZPos(BOOL param0, int param1, int param2); +void CommPlayer_CopyPersonal(int netJd); +void CommPlayer_SendXZPos(BOOL param0, int x, int z); void CommPlayer_SendPos(BOOL param0); void CommPlayer_SendPosServer(BOOL param0); u32 CommPlayer_Size(void); -void CommPlayer_Destroy(u8 param0, BOOL param1, BOOL param2); +void CommPlayer_Destroy(u8 netId, BOOL param1, BOOL param2); BOOL sub_02057FAC(void); void sub_02057FC4(BOOL param0); -void sub_02058018(int param0, int param1, void *param2, void *param3); +void sub_02058018(int netId, int param1, void *param2, void *unused); void sub_0205805C(FieldSystem *fieldSystem, BOOL param1); -BOOL CommPlayer_CheckNPCCollision(int param0, int param1); -void CommPlayer_RecvLocation(int param0, int param1, void *param2, void *param3); -void CommPlayer_RecvDelete(int param0, int param1, void *param2, void *param3); +BOOL CommPlayer_CheckNPCCollision(int x, int z); +void CommPlayer_RecvLocation(int netId, int unused0, void *src, void *unused1); +void CommPlayer_RecvDelete(int unused0, int unused1, void *src, void *unused2); int CommPacketSizeOf_RecvLocation(void); -void CommPlayer_RecvLocationAndInit(int param0, int param1, void *param2, void *param3); -void sub_02058B0C(int param0, int param1, BOOL param2); -void sub_02058B7C(int param0); -void sub_02058B94(int param0); -void CommPlayer_StartBlowAnimation(int param0, int param1, BOOL param2); -void CommPlayer_StopBlowAnimation(int param0); +void CommPlayer_RecvLocationAndInit(int netId, int size, void *src, void *unused); +void sub_02058B0C(int netId, int param1, BOOL param2); +void sub_02058B7C(int netId); +void sub_02058B94(int netId); +void CommPlayer_StartBlowAnimation(int netId, int param1, BOOL unused); +void CommPlayer_StopBlowAnimation(int netId); int CommPacketSizeOf_RecvLocationAndInit(void); BOOL sub_02058C40(void); -BOOL CommPlayer_IsActive(int param0); -int CommPlayer_XPos(int param0); -int CommPlayer_ZPos(int param0); -int sub_02058D48(int param0); -int sub_02058D68(int param0); -int sub_02058D88(int param0); -int sub_02058DC0(int param0); -int CommPlayer_GetXServer(int param0); -int CommPlayer_GetZServer(int param0); -int sub_02058EA0(int param0); -int sub_02058EC0(int param0); -int CommPlayer_AddXServer(int param0); -int CommPlayer_AddZServer(int param0); -int CommPlayer_Dir(int param0); -int CommPlayer_DirServer(int param0); -void CommPlayer_LookTowardsServer(int param0, int param1); -void CommPlayer_LookTowards(int param0, int param1); -int sub_0205900C(int param0, int param1); -void sub_02059058(int param0, BOOL param1); -BOOL sub_02059094(int param0); +BOOL CommPlayer_IsActive(int netId); +int CommPlayer_XPos(int netId); +int CommPlayer_ZPos(int netId); +int sub_02058D48(int netId); +int sub_02058D68(int netId); +int sub_02058D88(int netId); +int sub_02058DC0(int netId); +int CommPlayer_GetXServer(int netId); +int CommPlayer_GetZServer(int netId); +int sub_02058EA0(int netId); +int sub_02058EC0(int netId); +int CommPlayer_AddXServer(int netId); +int CommPlayer_AddZServer(int netId); +int CommPlayer_Dir(int netId); +int CommPlayer_DirServer(int netId); +void CommPlayer_LookTowardsServer(int netIdTarget, int netIdSet); +void CommPlayer_LookTowards(int netIdTarget, int netIdSet); +int sub_0205900C(int xPos, int yPos); +void sub_02059058(int netId, BOOL param1); +BOOL sub_02059094(int netId); BOOL sub_020590C4(void); -void sub_02059180(int param0, int param1, void *param2, void *param3); +void sub_02059180(int netId, int unused0, void *src, void *unused3); void CommPlayer_SetBattleDir(void); BOOL sub_0205928C(void); -int CommPlayer_GetOppositeDir(int param0); -void sub_02059354(int param0, int param1); -void sub_02059378(int param0); -void sub_02059390(int param0, int param1); -void sub_020593B4(int param0); -int CommPlayer_GetMovementTimer(int param0); -int CommPlayer_GetMovementTimerServer(int param0); -void CommPlayer_SetDir(int param0); -void CommPlayer_SetDirClient(int param0, int param1); -int CommPlayer_DirClient(int param0); +int CommPlayer_GetOppositeDir(int dir); +void sub_02059354(int netId, int param1); +void sub_02059378(int netId); +void sub_02059390(int netId, int param1); +void sub_020593B4(int netId); +int CommPlayer_GetMovementTimer(int netId); +int CommPlayer_GetMovementTimerServer(int netId); +void CommPlayer_SetDir(int dir); +void CommPlayer_SetDirClient(int netId, int dir); +int CommPlayer_DirClient(int netId); void sub_02059464(int param0); void sub_0205948C(int param0); void sub_020594EC(void); diff --git a/include/comm_ring.h b/include/comm_ring.h index ea732fe505..dd88b47ffe 100644 --- a/include/comm_ring.h +++ b/include/comm_ring.h @@ -1,5 +1,5 @@ -#ifndef POKEPLATINUM_UNK_02032188_H -#define POKEPLATINUM_UNK_02032188_H +#ifndef POKEPLATINUM_COMM_RING_H +#define POKEPLATINUM_COMM_RING_H typedef struct { u8 *buffer; @@ -9,13 +9,13 @@ typedef struct { s16 size; } CommRing; -void CommRing_Init(CommRing *ring, u8 *param1, int param2); -void CommRring_Write(CommRing *ring, u8 *param1, int param2, int param3); -int CommRing_Read(CommRing *ring, u8 *param1, int param2); +void CommRing_Init(CommRing *ring, u8 *buffer, int size); +void CommRring_Write(CommRing *ring, u8 *buffer, int size, int unused); +int CommRing_Read(CommRing *ring, u8 *buffer, int size); u8 CommRing_ReadByte(CommRing *ring); -int CommRing_Peek(CommRing *ring, u8 *param1, int param2); +int CommRing_Peek(CommRing *ring, u8 *buffer, int size); int CommRing_DataSize(CommRing *ring); int CommRing_RemainingSize(CommRing *ring); void CommRing_UpdateEndPos(CommRing *ring); -#endif // POKEPLATINUM_UNK_02032188_H +#endif // POKEPLATINUM_COMM_RING_H diff --git a/include/communication_information.h b/include/communication_information.h index d82886d307..5c22fa7133 100644 --- a/include/communication_information.h +++ b/include/communication_information.h @@ -13,7 +13,7 @@ void CommInfo_Delete(void); BOOL CommInfo_IsInitialized(void); void CommInfo_SendBattleRegulation(void); int CommPlayerInfo_Size(void); -void CommunicatitonInformaion_FinishReading(int param0, int param1, void *param2, void *param3); +void CommunicatitonInformaion_FinishReading(int unused0, int unused1, void *unused2, void *unused3); BOOL CommInfo_IsDataFinishedReading(void); void CommInfo_RecvPlayerDataArray(int netId, int unused1, void *src, void *unused3); void CommInfo_RecvPlayerData(int netId, int unused1, void *src, void *unused3); diff --git a/include/communication_system.h b/include/communication_system.h index e7f62cec92..885aa1ae57 100644 --- a/include/communication_system.h +++ b/include/communication_system.h @@ -17,18 +17,18 @@ void CommSys_Reset(void); void CommSys_ResetDS(void); void CommSys_ResetBattleClient(void); void sub_0203509C(u16 param0, u16 *param1, u16 param2); -void sub_020351F8(u16 param0, u16 *param1, u16 param2); +void sub_020351F8(u16 param0, u16 *buffer, u16 param2); void sub_020352C0(u16 param0, u16 *param1, u16 param2); void sub_02035664(void); void sub_02035678(void); void sub_0203568C(void); void sub_0203572C(void); void sub_02035938(u8 param0); -BOOL CommSys_SendDataHuge(int param0, const void *param1, int param2); -BOOL CommSys_SendData(int param0, const void *param1, int param2); -BOOL sub_02035A3C(int param0, const void *param1, int param2); -BOOL CommSys_SendDataServer(int param0, const void *param1, int param2); -BOOL sub_02035B48(int param0, const void *param1); +BOOL CommSys_SendDataHuge(int cmd, const void *data, int param2); +BOOL CommSys_SendData(int cmd, const void *data, int param2); +BOOL sub_02035A3C(int cmd, const void *data, int param2); +BOOL CommSys_SendDataServer(int cmd, const void *data, int param2); +BOOL sub_02035B48(int cmd, const void *data); int CommSys_SendRingRemainingSize(void); BOOL CommSys_IsPlayerConnected(u16 param0); int CommSys_ConnectedCount(void); @@ -39,14 +39,14 @@ u16 sub_02035E84(int param0); void CommSys_EnableSendMovementData(void); void CommSys_DisableSendMovementData(void); BOOL CommSys_IsSendingMovementData(void); -BOOL CommSys_WriteToQueueServer(int param0, const void *param1, int param2); -BOOL CommSys_WriteToQueue(int param0, const void *param1, int param2); -void sub_02036008(int param0, int param1, void *param2, void *param3); -void sub_02036030(int param0, int param1, void *param2, void *param3); -void sub_02036058(int param0, int param1, void *param2, void *param3); +BOOL CommSys_WriteToQueueServer(int cmd, const void *data, int param2); +BOOL CommSys_WriteToQueue(int cmd, const void *data, int param2); +void sub_02036008(int unused0, int unused1, void *param2, void *unused3); +void sub_02036030(int unused0, int unused1, void *param2, void *unused3); +void sub_02036058(int unused0, int unused1, void *param2, void *unused3); u16 CommSys_CurNetId(void); -BOOL CommSys_SendDataFixedSize(int param0, const void *param1); -BOOL Link_Message(int param0); +BOOL CommSys_SendDataFixedSize(int cmd, const void *data); +BOOL Link_Message(int cmd); BOOL sub_020360E8(void); BOOL CommSys_CheckError(void); u16 sub_02036128(u16 param0); @@ -63,7 +63,7 @@ BOOL sub_0203629C(void); void CommSys_SetWifiConnected(BOOL param0); BOOL CommSys_WifiConnected(void); void sub_020362DC(int param0, int param1); -int sub_020362F4(int param0); +int sub_020362F4(int networkId); BOOL sub_02036314(void); void sub_0203632C(BOOL param0); void sub_02036378(BOOL param0); diff --git a/include/field_comm_manager.h b/include/field_comm_manager.h index 9027c63558..71d5d4c3a0 100644 --- a/include/field_comm_manager.h +++ b/include/field_comm_manager.h @@ -36,11 +36,11 @@ void FieldCommMan_ReconnectBattleClient(void); void FieldCommMan_EnterBattleRoom(FieldSystem *fieldSystem); void FieldCommMan_EndBattle(void); void sub_020598A0(void); -void sub_02059D0C(int param0, int param1, void *param2, void *param3); +void sub_02059D0C(int unused0, int unused1, void *param2, void *unused3); BOOL sub_02059D2C(void); -void sub_02059EAC(int param0, int param1, void *param2, void *param3); -u8 *sub_02059EBC(int param0, void *param1, int param2); -UnkStruct_02029894 *sub_0205A080(SaveData *param0); +void sub_02059EAC(int param0, int unused1, void *unused2, void *unused3); +u8 *sub_02059EBC(int param0, void *unused1, int unused2); +UnkStruct_02029894 *sub_0205A080(SaveData *saveData); void sub_0205A0A0(void); void sub_0205A0BC(void); diff --git a/include/item.h b/include/item.h index 5f63f6823c..eea402286a 100644 --- a/include/item.h +++ b/include/item.h @@ -173,7 +173,7 @@ u16 Item_FileID(u16 item, enum ItemFileType type); * @param gbaID GBA-era item ID. * @return ID of the item which corresponds to the given GBA-era ID. */ -u16 Item_FromGBAID(u16 param0); +u16 Item_FromGBAID(u16 gbaID); /** * @brief Get the file index of the global NCER file used by all item icons. diff --git a/src/berry_patches.c b/src/berry_patches.c index c625c9d39a..f71b6fa8dd 100644 --- a/src/berry_patches.c +++ b/src/berry_patches.c @@ -53,9 +53,7 @@ BerryGrowthData *BerryGrowthData_Init(enum HeapId heapID) { BerryGrowthData *growthData; BerryData *berryData; - NARC *narc; - - narc = BerryData_NARC_ctor(heapID); + NARC *narc = BerryData_NARC_ctor(heapID); growthData = Heap_AllocFromHeap(heapID, sizeof(BerryGrowthData) * NUM_BERRIES); for (int i = 0; i < NUM_BERRIES; i++) { diff --git a/src/bg_window.c b/src/bg_window.c index f4cf031608..da8052999b 100644 --- a/src/bg_window.c +++ b/src/bg_window.c @@ -1840,13 +1840,12 @@ static void ClearWindowTilemapText(Window *window) return; } - u32 x, y, tilemapRight, tilemapBottom, idx, tilemapWidth; - u16 *tilemap; + u32 x, y, tilemapBottom, idx; + u32 tilemapWidth = sScreenSizeToTilemapWidth[window->bgConfig->bgs[window->bgLayer].screenSize]; + u16 *tilemap = window->bgConfig->bgs[window->bgLayer].tilemapBuffer; + u32 tilemapRight = window->tilemapLeft + window->width; - tilemapWidth = sScreenSizeToTilemapWidth[window->bgConfig->bgs[window->bgLayer].screenSize]; - tilemap = window->bgConfig->bgs[window->bgLayer].tilemapBuffer; - tilemapRight = window->tilemapLeft + window->width; - tilemapBottom = window->tilemapTop + window->height; + tilemapBottom = window->tilemapTop + window->height; // required this way to match for (y = window->tilemapTop; y < tilemapBottom; y++) { for (x = window->tilemapLeft; x < tilemapRight; x++) { @@ -1862,11 +1861,8 @@ static void ClearWindowTilemapAffine(Window *window) return; } - int x, y, tilemapWidth; - u8 *tilemap; - - tilemapWidth = sScreenSizeToTilemapWidth[window->bgConfig->bgs[window->bgLayer].screenSize]; - tilemap = (u8 *)(window->bgConfig->bgs[window->bgLayer].tilemapBuffer) + window->tilemapTop * tilemapWidth + window->tilemapLeft; + int x, y, tilemapWidth = sScreenSizeToTilemapWidth[window->bgConfig->bgs[window->bgLayer].screenSize]; + u8 *tilemap = (u8 *)(window->bgConfig->bgs[window->bgLayer].tilemapBuffer) + window->tilemapTop * tilemapWidth + window->tilemapLeft; for (y = 0; y < window->height; y++) { for (x = 0; x < window->width; x++) { @@ -2118,15 +2114,11 @@ void Window_FillRectWithColor(Window *window, u8 color, u16 x, u16 y, u16 width, void Window_CopyGlyph(Window *window, const u8 *glyphPixels, u16 srcWidth, u16 srcHeight, u16 destX, u16 destY, u16 table) { - u8 *windowPixels; - u16 destWidth, destHeight; + u8 *windowPixels = window->pixels; + u16 destWidth = window->width * 8, destHeight = window->height * 8; int srcRight, srcBottom; u8 glyphSizeParam; - windowPixels = window->pixels; - destWidth = window->width * 8; - destHeight = window->height * 8; - if (destWidth - destX < srcWidth) { srcRight = destWidth - destX; } else { @@ -2208,17 +2200,13 @@ void Window_Scroll(Window *window, u8 direction, u8 distance, u8 fillVal) static void ScrollWindow4bpp(Window *window, u8 direction, u8 distance, u8 fillVal) { - u8 *pixels; + u8 *pixels = window->pixels; int y0, y1, y2; - int fill, size; - u32 width; + int fill = (fillVal << 24) | (fillVal << 16) | (fillVal << 8) | (fillVal << 0); + int size = window->height * window->width * TILE_SIZE_4BPP; + u32 width = window->width; int i, j; - pixels = window->pixels; - fill = (fillVal << 24) | (fillVal << 16) | (fillVal << 8) | (fillVal << 0); - size = window->height * window->width * TILE_SIZE_4BPP; - width = window->width; - switch (direction) { case SCROLL_DIRECTION_UP: for (i = 0; i < size; i += TILE_SIZE_4BPP) { @@ -2269,17 +2257,13 @@ static void ScrollWindow4bpp(Window *window, u8 direction, u8 distance, u8 fillV static void ScrollWindow8bpp(Window *window, u8 direction, u8 distance, u8 fillVal) { - u8 *pixels; + u8 *pixels = window->pixels; int y0, y1, y2; - int fill, size; - u32 width; + int fill = (fillVal << 24) | (fillVal << 16) | (fillVal << 8) | fillVal; + int size = window->height * window->width * TILE_SIZE_8BPP; + u32 width = window->width; int i, j; - pixels = window->pixels; - fill = (fillVal << 24) | (fillVal << 16) | (fillVal << 8) | fillVal; - size = window->height * window->width * TILE_SIZE_8BPP; - width = window->width; - switch (direction) { case SCROLL_DIRECTION_UP: for (i = 0; i < size; i += TILE_SIZE_8BPP) { diff --git a/src/comm_player_manager.c b/src/comm_player_manager.c index 9e4f6379f0..dc1f67b74f 100644 --- a/src/comm_player_manager.c +++ b/src/comm_player_manager.c @@ -33,6 +33,7 @@ #include "field_system.h" #include "game_records.h" #include "heap.h" +#include "location.h" #include "map_header_data.h" #include "map_object.h" #include "map_object_move.h" @@ -48,15 +49,15 @@ #include "unk_0206CCB0.h" static int sub_020581CC(int param0, int param1); -static BOOL CommPlayer_MoveBlow(int param0, int param1); -static BOOL CommPlayer_BlowAnimation(int param0, int param1, int param2, int param3); -static void CommPlayer_SendDataTask(void *param0); -static void sub_02057C2C(void *param0); -static void CommPlayer_Add(u8 param0); -static void CommPlayer_Move(SysTask *param0, void *param1); -static void Task_CommPlayerManagerRun(SysTask *param0, void *param1); -static void sub_02057EF8(void *param0); -static void CommPlayer_MoveClient(int param0); +static BOOL CommPlayer_MoveBlow(int netId, int param1); +static BOOL CommPlayer_BlowAnimation(int netId, int param1, int unused, int animSpeed); +static void CommPlayer_SendDataTask(void *data); +static void sub_02057C2C(void *data); +static void CommPlayer_Add(u8 netId); +static void CommPlayer_Move(SysTask *unused0, void *unused1); +static void Task_CommPlayerManagerRun(SysTask *task, void *data); +static void sub_02057EF8(void *unused); +static void CommPlayer_MoveClient(int netId); static void sub_020591A8(void); static CommPlayerManager *sCommPlayerManager = NULL; @@ -509,7 +510,7 @@ static void Task_CommPlayerManagerRun(SysTask *task, void *data) } } -static void sub_02057EF8(void *param0) +static void sub_02057EF8(void *unused) { for (int netId = 0; netId < MAX_CONNECTED_PLAYERS; netId++) { if (!CommSys_IsPlayerConnected(netId)) { @@ -568,7 +569,7 @@ static void sub_02057FF0(BOOL param0) } } -void sub_02058018(int netId, int param1, void *param2, void *param3) +void sub_02058018(int netId, int param1, void *param2, void *unused) { u8 *buffer = (u8 *)param2; @@ -630,11 +631,8 @@ static int CommPlayer_Direction(u16 unused, u16 keys) BOOL CommPlayer_CheckNPCCollision(int x, int z) { - int npcCnt, i; - const ObjectEvent *objEventList; - - npcCnt = MapHeaderData_GetNumObjectEvents(sCommPlayerManager->fieldSystem); - objEventList = MapHeaderData_GetObjectEvents(sCommPlayerManager->fieldSystem); + int npcCnt = MapHeaderData_GetNumObjectEvents(sCommPlayerManager->fieldSystem), i; + const ObjectEvent *objEventList = MapHeaderData_GetObjectEvents(sCommPlayerManager->fieldSystem); for (i = 0; i < npcCnt; i++) { if ((objEventList[i].x == x) && (objEventList[i].z == z)) { @@ -691,7 +689,7 @@ static int sub_020581E0(int param0) return v0[param0]; } -static void CommPlayer_Move(SysTask *param0, void *param1) +static void CommPlayer_Move(SysTask *unused0, void *unused1) { u16 keys; int dir, x, z, netId, v6; @@ -814,7 +812,7 @@ static void CommPlayer_Move(SysTask *param0, void *param1) } } -void CommPlayer_RecvLocation(int netId, int param1, void *src, void *param3) +void CommPlayer_RecvLocation(int netId, int unused0, void *src, void *unused1) { u8 *buffer = (u8 *)src; CommPlayerLocation *playerLocation; @@ -854,7 +852,7 @@ void CommPlayer_RecvLocation(int netId, int param1, void *src, void *param3) } } -void CommPlayer_RecvDelete(int unused0, int unused2, void *src, void *param3) +void CommPlayer_RecvDelete(int unused0, int unused1, void *src, void *unused2) { u8 *buffer = (u8 *)src; u8 netId = buffer[0]; @@ -888,9 +886,7 @@ void CommPlayer_RecvLocationAndInit(int netId, int size, void *src, void *unused { u8 *buffer = (u8 *)src; CommPlayerLocation *playerLocation; - int netJd; - - netJd = buffer[0] & 0xf; + int netJd = buffer[0] & 0xf; if (sCommPlayerManager == NULL) { return; @@ -936,7 +932,7 @@ static void sub_02058644(int netId) } } -static BOOL CommPlayer_BlowAnimation(int netId, int param1, int param2, int animSpeed) +static BOOL CommPlayer_BlowAnimation(int netId, int param1, int unused, int animSpeed) { MapObject *obj; u8 walkAnimationCode[] = { @@ -983,12 +979,10 @@ static BOOL CommPlayer_BlowAnimation(int netId, int param1, int param2, int anim static void CommPlayer_MoveClient(int netId) { u16 pad = 0; - CommPlayerLocation *playerLocation; + CommPlayerLocation *playerLocation = &sCommPlayerManager->playerLocation[netId]; PlayerAvatar *playerAvatar; int moveSpeed; - playerLocation = &sCommPlayerManager->playerLocation[netId]; - if (sCommPlayerManager->moveTimer[netId] != 0) { sCommPlayerManager->moveTimer[netId]--; return; @@ -1199,7 +1193,7 @@ void sub_02058B94(int netId) sCommPlayerManager->unk_10A[netId] = 0xff; } -void CommPlayer_StartBlowAnimation(int netId, int param1, BOOL param2) +void CommPlayer_StartBlowAnimation(int netId, int param1, BOOL unused) { MapObject *obj; @@ -1514,7 +1508,7 @@ BOOL sub_020590C4(void) return v8; } -void sub_02059180(int netId, int unused1, void *src, void *unused3) +void sub_02059180(int netId, int unused0, void *src, void *unused3) { u8 *buffer = src; @@ -1609,18 +1603,18 @@ BOOL sub_0205928C(void) int CommPlayer_GetOppositeDir(int dir) { - if (dir == 0) { - return 1; - } else if (dir == 1) { - return 0; - } else if (dir == 2) { - return 3; - } else if (dir == 3) { - return 2; + if (dir == FACE_UP) { + return FACE_DOWN; + } else if (dir == FACE_DOWN) { + return FACE_UP; + } else if (dir == FACE_LEFT) { + return FACE_RIGHT; + } else if (dir == FACE_RIGHT) { + return FACE_LEFT; } GF_ASSERT(FALSE); - return 2; + return FACE_LEFT; } void sub_02059354(int netId, int param1) diff --git a/src/communication_information.c b/src/communication_information.c index 009a3786fb..e74ab6a406 100644 --- a/src/communication_information.c +++ b/src/communication_information.c @@ -154,7 +154,7 @@ int CommPlayerInfo_Size(void) return sizeof(CommPlayerInfo); } -void CommunicatitonInformaion_FinishReading(int param0, int param1, void *param2, void *param3) +void CommunicatitonInformaion_FinishReading(int unused0, int unused1, void *unused2, void *unused3) { if (sCommInfo) { sCommInfo->dataFinishedReading = TRUE; diff --git a/src/communication_system.c b/src/communication_system.c index d03ad2dd01..a6d7241337 100644 --- a/src/communication_system.c +++ b/src/communication_system.c @@ -150,7 +150,7 @@ static BOOL CommSys_Init(BOOL shouldAlloc, int maxPacketSize) int maxMachines = CommLocal_MaxMachines(sub_0203895C()) + 1; if (sCommunicationSystem != NULL) { - return 1; + return TRUE; } CommTool_Init(HEAP_ID_COMMUNICATION); @@ -300,13 +300,11 @@ static void CommSys_ClearServerRecvData(int netId) sCommunicationSystem->unk_697[netId] = 1; sCommunicationSystem->unk_664[netId] = 0; - { - int v0 = CommLocal_MaxMachines(sub_0203895C()) + 1; - int v1 = sCommunicationSystem->allocSize / v0; + int v0 = CommLocal_MaxMachines(sub_0203895C()) + 1; + int v1 = sCommunicationSystem->allocSize / v0; - CommRing_Init(&sCommunicationSystem->unk_4B0[netId], &sCommunicationSystem->unk_488[netId * v1], v1); - CommRing_Init(&sCommunicationSystem->sendRingClient[netId], &sCommunicationSystem->recvBufferRingServer[netId * v1], v1); - } + CommRing_Init(&sCommunicationSystem->unk_4B0[netId], &sCommunicationSystem->unk_488[netId * v1], v1); + CommRing_Init(&sCommunicationSystem->sendRingClient[netId], &sCommunicationSystem->recvBufferRingServer[netId * v1], v1); sCommunicationSystem->commRecvServer[netId].unk_0A = 0xee; sCommunicationSystem->commRecvServer[netId].unk_08 = 0xffff; @@ -319,10 +317,8 @@ static void sub_02034734(void) int netId; for (netId = 1; netId < (7 + 1); netId++) { - if ((!CommSys_IsPlayerConnected(netId)) && !sCommunicationSystem->unk_697[netId]) { - if (!CommSys_IsAlone()) { - CommSys_ClearServerRecvData(netId); - } + if (!CommSys_IsPlayerConnected(netId) && !sCommunicationSystem->unk_697[netId] && !CommSys_IsAlone()) { + CommSys_ClearServerRecvData(netId); } } } @@ -334,7 +330,7 @@ static void sub_02034770(int param0) BOOL CommSys_InitServer(BOOL param0, BOOL param1, int param2, BOOL param3) { - BOOL ret = 1; + BOOL ret = TRUE; if (!CommLocal_IsWifiGroup(sub_0203895C())) { ret = CommServerClient_InitServer(param0, param1, param3); @@ -347,7 +343,7 @@ BOOL CommSys_InitServer(BOOL param0, BOOL param1, int param2, BOOL param3) BOOL CommSys_InitClient(BOOL param0, BOOL param1, int param2) { - BOOL v0 = 1; + BOOL v0 = TRUE; if (!CommLocal_IsWifiGroup(sub_0203895C())) { v0 = CommServerClient_InitClient(param0, param1); @@ -367,10 +363,8 @@ static void CommSys_UpdateTransitionType(void) if (Unk_02100A1C != 4) { return; } - } else { - if (Unk_02100A1D != 4) { - return; - } + } else if (Unk_02100A1D != 4) { + return; } if (sCommunicationSystem->transmissionType == TRANSMISSION_TYPE_SWITCH_TO_SERVER_CLIENT) { @@ -437,7 +431,7 @@ BOOL CommSys_TransitionTypeIsParallel(void) void CommSys_Delete(void) { - BOOL v0 = 0; + BOOL v0 = FALSE; if (sCommunicationSystem) { if (CommLocal_IsWifiGroup(sub_0203895C())) { @@ -524,10 +518,8 @@ BOOL CommSys_Update(void) CommSys_RecvData(); } - if ((CommSys_CurNetId() == 0) && (CommSys_IsPlayerConnected(0)) || CommSys_IsAlone()) { - if (!sub_0203272C(sub_0203895C())) { - sub_02034F68(); - } + if ((CommSys_CurNetId() == 0 && CommSys_IsPlayerConnected(0) || CommSys_IsAlone()) && !sub_0203272C(sub_0203895C())) { + sub_02034F68(); } if ((CommSys_CurNetId() == 0) || (CommSys_TransmissionType() == TRANSMISSION_TYPE_PARALLEL) || CommSys_IsAlone()) { @@ -623,12 +615,12 @@ static void sub_02034B50(void) } if (ov4_021D1590(sCommunicationSystem->sendBuffer[0], 38)) { - int v0; + int i; int v1 = CommLocal_MaxMachines(sub_0203895C()) + 1; - for (v0 = 0; v0 < v1; v0++) { - if (CommSys_IsPlayerConnected(v0)) { - sCommunicationSystem->unk_664[v0]++; + for (i = 0; i < v1; i++) { + if (CommSys_IsPlayerConnected(i)) { + sCommunicationSystem->unk_664[i]++; } } @@ -689,41 +681,40 @@ static BOOL sub_02034CF8(int param0) { int v0; int v1; - int v2, v3, v4 = 0; + int i, v3, v4 = 0; v0 = sub_02036128(sub_0203895C()); v1 = CommLocal_MaxMachines(sub_0203895C()) + 1; - for (v2 = 0; v2 < v1; v2++) { - CommRing_UpdateEndPos(&sCommunicationSystem->unk_4B0[v2]); + for (i = 0; i < v1; i++) { + CommRing_UpdateEndPos(&sCommunicationSystem->unk_4B0[i]); - if (CommSys_IsPlayerConnected(v2)) { - sCommunicationSystem->sendBufferServer[param0][v2 * v0] = 0xe; + if (CommSys_IsPlayerConnected(i)) { + sCommunicationSystem->sendBufferServer[param0][i * v0] = 0xe; } else { - sCommunicationSystem->sendBufferServer[param0][v2 * v0] = 0xff; + sCommunicationSystem->sendBufferServer[param0][i * v0] = 0xff; v4++; continue; } - v3 = CommRing_Read(&sCommunicationSystem->unk_4B0[v2], &sCommunicationSystem->sendBufferServer[param0][v2 * v0], v0); + v3 = CommRing_Read(&sCommunicationSystem->unk_4B0[i], &sCommunicationSystem->sendBufferServer[param0][i * v0], v0); - if (sCommunicationSystem->sendBufferServer[param0][v2 * v0] == 0xe) { + if (sCommunicationSystem->sendBufferServer[param0][i * v0] == 0xe) { v4++; } } if (v4 == v1) { - return 0; + return FALSE; } - return 1; + return TRUE; } static void CommSys_UpdateServerClient(void) { - int v0; + int i, v2, v3; int v1 = 0; - int v2, v3; if (!sCommunicationSystem) { return; @@ -739,27 +730,25 @@ static void CommSys_UpdateServerClient(void) if ((Unk_02100A1C == 2) || (Unk_02100A1C == 0)) { Unk_02100A1C++; - if (CommSys_TransmissionType() == 1) { - if (Unk_021C07C4 == 0) { - sub_02034CF8(sCommunicationSystem->unk_6A8); - Unk_021C07C4 = 1; - } + if (CommSys_TransmissionType() == 1 && Unk_021C07C4 == 0) { + sub_02034CF8(sCommunicationSystem->unk_6A8); + Unk_021C07C4 = 1; } - if ((sub_02031934() == 4) && !CommSys_IsAlone()) { - if (!sub_02031E9C(sCommunicationSystem->sendBufferServer[sCommunicationSystem->unk_6A8], 192, 14, sub_020353B0)) { - Unk_02100A1C--; - } + if (sub_02031934() == 4 + && !CommSys_IsAlone() + && !sub_02031E9C(sCommunicationSystem->sendBufferServer[sCommunicationSystem->unk_6A8], 192, 14, sub_020353B0)) { + Unk_02100A1C--; } if ((Unk_02100A1C == 1) || (Unk_02100A1C == 3)) { Unk_021C07C4 = 0; - for (v0 = 0; v0 < v3; v0++) { - if (CommSys_IsPlayerConnected(v0)) { - sCommunicationSystem->unk_664[v0]++; - } else if (CommSys_IsAlone() && (v0 == 0)) { - sCommunicationSystem->unk_664[v0]++; + for (i = 0; i < v3; i++) { + if (CommSys_IsPlayerConnected(i)) { + sCommunicationSystem->unk_664[i]++; + } else if (CommSys_IsAlone() && (i == 0)) { + sCommunicationSystem->unk_664[i]++; } } @@ -775,23 +764,21 @@ static void CommSys_UpdateServerClient(void) static BOOL CommSys_CheckRecvLimit(void) { - int v0; + int i; int v1 = CommLocal_MaxMachines(sub_0203895C()) + 1; - for (v0 = 1; v0 < v1; v0++) { - if (CommSys_IsPlayerConnected(v0)) { - if (sCommunicationSystem->unk_664[v0] > 3) { - return 0; - } + for (i = 1; i < v1; i++) { + if (CommSys_IsPlayerConnected(i) && sCommunicationSystem->unk_664[i] > 3) { + return FALSE; } } - return 1; + return TRUE; } static void sub_02034F68(void) { - int v0; + int i; int v1 = CommLocal_MaxMachines(sub_0203895C()) + 1; if (CommLocal_IsWifiGroup(sub_0203895C())) { @@ -809,12 +796,8 @@ static void sub_02034F68(void) Unk_02100A1C = 2; } } else { - if (Unk_02100A1C == 4) { - if (CommSys_TransmissionType() == 1) { - if (!sub_02034CF8(0)) { - return; - } - } + if (Unk_02100A1C == 4 && CommSys_TransmissionType() == 1 && !sub_02034CF8(0)) { + return; } Unk_02100A1C = 2; @@ -823,9 +806,9 @@ static void sub_02034F68(void) if (ov4_021D14D4(sCommunicationSystem->sendBufferServer[0], 192)) { Unk_02100A1C = 4; - for (v0 = 0; v0 < v1; v0++) { - if (CommSys_IsPlayerConnected(v0)) { - sCommunicationSystem->unk_664[v0]++; + for (i = 0; i < v1; i++) { + if (CommSys_IsPlayerConnected(i)) { + sCommunicationSystem->unk_664[i]++; } } } else { @@ -860,7 +843,7 @@ void sub_0203509C(u16 param0, u16 *param1, u16 param2) static void sub_020350A4(u16 param0, u16 *param1, u16 param2) { u8 *v0 = (u8 *)param1; - int v1; + int i; int v2 = param2; sCommunicationSystem->unk_660--; @@ -890,24 +873,24 @@ static void sub_020350A4(u16 param0, u16 *param1, u16 param2) int v3 = sub_02036128(sub_0203895C()); int v4 = CommLocal_MaxMachines(sub_0203895C()) + 1; - for (v1 = 0; v1 < v4; v1++) { + for (i = 0; i < v4; i++) { if (v0[0] == 0xff) { - sCommunicationSystem->unk_68C = sCommunicationSystem->unk_68C & ~(1 << v1); + sCommunicationSystem->unk_68C = sCommunicationSystem->unk_68C & ~(1 << i); } else { - sCommunicationSystem->unk_68C = sCommunicationSystem->unk_68C | (1 << v1); + sCommunicationSystem->unk_68C = sCommunicationSystem->unk_68C | (1 << i); } if (v0[0] == 0xff) { v0 += v3; } else if (v0[0] == 0xe) { v0 += v3; - } else if ((sCommunicationSystem->unk_697[v1]) && (v0[0] & 0x1)) { + } else if ((sCommunicationSystem->unk_697[i]) && (v0[0] & 0x1)) { v0 += v3; } else { v0++; - CommRring_Write(&sCommunicationSystem->sendRingClient[v1], v0, v3 - 1, 1360 + v1); + CommRring_Write(&sCommunicationSystem->sendRingClient[i], v0, v3 - 1, 1360 + i); v0 += (v3 - 1); - sCommunicationSystem->unk_697[v1] = 0; + sCommunicationSystem->unk_697[i] = 0; } } } else { @@ -1035,10 +1018,6 @@ static void sub_020353B0(BOOL param0) static void sub_020353CC(void) { - u16 v0; - u8 *v1; - int v2; - if (!sCommunicationSystem) { return; } @@ -1047,48 +1026,46 @@ static void sub_020353CC(void) return; } - { - int v3 = sub_02036128(sub_0203895C()); - int v4 = CommLocal_MaxMachines(sub_0203895C()) + 1; + int v3 = sub_02036128(sub_0203895C()); + int v4 = CommLocal_MaxMachines(sub_0203895C()) + 1; - if (CommSys_IsAlone()) { - if ((Unk_02100A1D == 2) || (Unk_02100A1D == 0)) { - Unk_02100A1D++; - sub_02035394(1); + if (CommSys_IsAlone()) { + if (Unk_02100A1D == 2 || Unk_02100A1D == 0) { + Unk_02100A1D++; + sub_02035394(1); - sub_02035200(0, (u16 *)sCommunicationSystem->sendBuffer[sCommunicationSystem->unk_6A7], v3); - sCommunicationSystem->unk_6A7 = 1 - sCommunicationSystem->unk_6A7; - sCommunicationSystem->unk_660++; - return; - } + sub_02035200(0, (u16 *)sCommunicationSystem->sendBuffer[sCommunicationSystem->unk_6A7], v3); + sCommunicationSystem->unk_6A7 = 1 - sCommunicationSystem->unk_6A7; + sCommunicationSystem->unk_660++; + return; } + } - if (sub_02031934() == 4) { - if (!CommSys_IsPlayerConnected(CommSys_CurNetId())) { - if (CommSys_CurNetId() == 1) { - (void)0; - } - - return; + if (sub_02031934() == 4) { + if (!CommSys_IsPlayerConnected(CommSys_CurNetId())) { + if (CommSys_CurNetId() == 1) { + (void)0; } - if ((Unk_02100A1D == 2) || (Unk_02100A1D == 0)) { - if (CommSys_CurNetId() != 0) { - Unk_02100A1D++; + return; + } - if (!sub_02031E9C(sCommunicationSystem->sendBuffer[sCommunicationSystem->unk_6A7], v3, 14, sub_02035394)) { - Unk_02100A1D--; - } else { - sCommunicationSystem->unk_6A7 = 1 - sCommunicationSystem->unk_6A7; - sCommunicationSystem->unk_660++; - } - } else if (sub_020318EC() & 0xfffe) { - Unk_02100A1D++; - sub_02035394(1); - sub_02035200(0, (u16 *)sCommunicationSystem->sendBuffer[sCommunicationSystem->unk_6A7], v3); + if (Unk_02100A1D == 2 || Unk_02100A1D == 0) { + if (CommSys_CurNetId() != 0) { + Unk_02100A1D++; + + if (!sub_02031E9C(sCommunicationSystem->sendBuffer[sCommunicationSystem->unk_6A7], v3, 14, sub_02035394)) { + Unk_02100A1D--; + } else { sCommunicationSystem->unk_6A7 = 1 - sCommunicationSystem->unk_6A7; sCommunicationSystem->unk_660++; } + } else if (sub_020318EC() & 0xfffe) { + Unk_02100A1D++; + sub_02035394(1); + sub_02035200(0, (u16 *)sCommunicationSystem->sendBuffer[sCommunicationSystem->unk_6A7], v3); + sCommunicationSystem->unk_6A7 = 1 - sCommunicationSystem->unk_6A7; + sCommunicationSystem->unk_660++; } } } @@ -1172,7 +1149,6 @@ void sub_0203568C(void) static BOOL sub_020356A0(u8 *param0, int param1) { - int v0; u8 v1[2]; sCommunicationSystem->unk_63C[param1] = 0; @@ -1193,7 +1169,7 @@ static BOOL sub_020356A0(u8 *param0, int param1) sCommunicationSystem->recvSpeed[param1] = (*param0 >> 5) & 0x7; } - return 1; + return TRUE; } void sub_0203572C(void) @@ -1203,14 +1179,12 @@ void sub_0203572C(void) static BOOL sub_02035730(u8 *param0) { - int v0, v1; - if (sCommunicationSystem->unk_656) { - return 0; + return FALSE; } if (CommSys_IsSendingMovementData() == 0) { - return 0; + return FALSE; } if (sCommunicationSystem->unk_6A9) { @@ -1232,12 +1206,11 @@ static BOOL sub_02035730(u8 *param0) } param0[0] |= (sCommunicationSystem->sendSpeed << 5); - return 0; + return FALSE; } static BOOL sub_020357F0(u8 *param0) { - int v0; int v1 = sub_02036128(sub_0203895C()); int v2 = CommLocal_MaxMachines(sub_0203895C()) + 1; @@ -1257,7 +1230,7 @@ static BOOL sub_020357F0(u8 *param0) param0[0] |= 0x2; if (param0[0] == 0x2) { - return 0; + return FALSE; } } else { UnkStruct_0203233C v3; @@ -1276,13 +1249,11 @@ static BOOL sub_020357F0(u8 *param0) } } - return 1; + return TRUE; } static void sub_020358C0(u8 *param0) { - int v0; - param0[0] = 0xb; if (sCommunicationSystem->unk_6AD == 0) { @@ -1291,26 +1262,22 @@ static void sub_020358C0(u8 *param0) param0[1] = 0x1; } - { - u16 v1 = sub_020318EC(); + u16 v1 = sub_020318EC(); - param0[2] = v1 >> 8; - param0[3] = v1 & 0xff; + param0[2] = v1 >> 8; + param0[3] = v1 & 0xff; - { - UnkStruct_0203233C v2; + UnkStruct_0203233C v2; - v2.unk_04 = 192 - 5; - v2.unk_00 = ¶m0[5]; + v2.unk_04 = 192 - 5; + v2.unk_00 = ¶m0[5]; - if (sub_02032574(&sCommunicationSystem->commQueueManSendServer, &v2, 0)) { - sCommunicationSystem->unk_6AD = 0; - param0[4] = (192 - 5) - v2.unk_04; - } else { - sCommunicationSystem->unk_6AD = 1; - param0[4] = 192 - 5; - } - } + if (sub_02032574(&sCommunicationSystem->commQueueManSendServer, &v2, 0)) { + sCommunicationSystem->unk_6AD = 0; + param0[4] = (192 - 5) - v2.unk_04; + } else { + sCommunicationSystem->unk_6AD = 1; + param0[4] = 192 - 5; } } @@ -1322,106 +1289,106 @@ void sub_02035938(u8 param0) static BOOL sub_0203594C(void) { if (sCommunicationSystem->unk_6B4 == 0) { - return 0; + return FALSE; } if ((sCommunicationSystem->unk_6B5 % sCommunicationSystem->unk_6B4) == 0) { - return 1; + return TRUE; } - return 0; + return FALSE; } -BOOL CommSys_SendDataHuge(int cmd, const void *param1, int param2) +BOOL CommSys_SendDataHuge(int cmd, const void *data, int param2) { if (!CommSys_IsPlayerConnected(CommSys_CurNetId()) && !CommSys_IsAlone()) { - return 0; + return FALSE; } - if (CommQueue_Write(&sCommunicationSystem->commQueueManSend, cmd, (u8 *)param1, param2, 1, 0)) { - return 1; + if (CommQueue_Write(&sCommunicationSystem->commQueueManSend, cmd, (u8 *)data, param2, 1, 0)) { + return TRUE; } if (sub_0203895C() == 10) { sub_020363BC(); } - return 0; + return FALSE; } -BOOL CommSys_SendData(int cmd, const void *param1, int param2) +BOOL CommSys_SendData(int cmd, const void *data, int param2) { if (!CommSys_IsPlayerConnected(CommSys_CurNetId()) && !CommSys_IsAlone()) { - return 0; + return FALSE; } - if (CommQueue_Write(&sCommunicationSystem->commQueueManSend, cmd, (u8 *)param1, param2, 1, 1)) { - return 1; + if (CommQueue_Write(&sCommunicationSystem->commQueueManSend, cmd, (u8 *)data, param2, 1, 1)) { + return TRUE; } if (sub_0203895C() == 10) { sub_020363BC(); } - return 0; + return FALSE; } -BOOL sub_02035A3C(int cmd, const void *param1, int param2) +BOOL sub_02035A3C(int cmd, const void *data, int param2) { if (CommSys_CurNetId() != 0) { GF_ASSERT(FALSE); - return 0; + return FALSE; } if (!CommSys_IsPlayerConnected(0) && !CommSys_IsAlone()) { - return 0; + return FALSE; } if (CommSys_TransmissionType() == 1) { - return CommSys_SendDataHuge(cmd, param1, param2); + return CommSys_SendDataHuge(cmd, data, param2); } - if (CommQueue_Write(&sCommunicationSystem->commQueueManSendServer, cmd, (u8 *)param1, param2, 1, 0)) { - return 1; + if (CommQueue_Write(&sCommunicationSystem->commQueueManSendServer, cmd, (u8 *)data, param2, 1, 0)) { + return TRUE; } if (sub_0203895C() == 10) { sub_020363BC(); } - return 0; + return FALSE; } -BOOL CommSys_SendDataServer(int cmd, const void *param1, int param2) +BOOL CommSys_SendDataServer(int cmd, const void *data, int param2) { if (CommSys_CurNetId() != 0) { sub_020363BC(); - return 0; + return FALSE; } if (!CommSys_IsPlayerConnected(0) && !CommSys_IsAlone()) { - return 0; + return FALSE; } if (CommSys_TransmissionType() == 1) { - return CommSys_SendData(cmd, param1, param2); + return CommSys_SendData(cmd, data, param2); } - if (CommQueue_Write(&sCommunicationSystem->commQueueManSendServer, cmd, (u8 *)param1, param2, 1, 1)) { - return 1; + if (CommQueue_Write(&sCommunicationSystem->commQueueManSendServer, cmd, (u8 *)data, param2, 1, 1)) { + return TRUE; } if (sub_0203895C() == 10) { sub_020363BC(); } - return 0; + return FALSE; } -BOOL sub_02035B48(int cmd, const void *param1) +BOOL sub_02035B48(int cmd, const void *data) { - return CommSys_SendDataServer(cmd, param1, 0); + return CommSys_SendDataServer(cmd, data, 0); } int CommSys_SendRingRemainingSize(void) @@ -1523,9 +1490,6 @@ static void CommSys_RecvDataSingle(CommRing *ring, int netId, u8 *buffer, CommRe static void CommSys_RecvData(void) { int v0 = 0; - int v1; - u8 v2; - int v3; if (!sCommunicationSystem) { return; @@ -1544,10 +1508,7 @@ static void CommSys_RecvData(void) static void CommSys_RecvDataServer(void) { - int v0; - int v1; - u8 v2; - int v3; + int i, v3; if (!sCommunicationSystem) { return; @@ -1559,11 +1520,11 @@ static void CommSys_RecvDataServer(void) v3 = CommLocal_MaxMachines(sub_0203895C()) + 1; - for (v0 = 0; v0 < v3; v0++) { - CommRing_UpdateEndPos(&sCommunicationSystem->sendRingClient[v0]); + for (i = 0; i < v3; i++) { + CommRing_UpdateEndPos(&sCommunicationSystem->sendRingClient[i]); - if (CommRing_DataSize(&sCommunicationSystem->sendRingClient[v0]) > 0) { - CommSys_RecvDataSingle(&sCommunicationSystem->sendRingClient[v0], v0, sCommunicationSystem->tempBuffer, &sCommunicationSystem->commRecvServer[v0]); + if (CommRing_DataSize(&sCommunicationSystem->sendRingClient[i]) > 0) { + CommSys_RecvDataSingle(&sCommunicationSystem->sendRingClient[i], i, sCommunicationSystem->tempBuffer, &sCommunicationSystem->commRecvServer[i]); } } } @@ -1571,7 +1532,7 @@ static void CommSys_RecvDataServer(void) BOOL CommSys_IsPlayerConnected(u16 param0) { if (!sCommunicationSystem) { - return 0; + return FALSE; } if (CommLocal_IsWifiGroup(sub_0203895C())) { @@ -1579,34 +1540,34 @@ BOOL CommSys_IsPlayerConnected(u16 param0) u16 v0 = DWC_GetAIDBitmap(); if (v0 & (1 << param0)) { - return 1; + return TRUE; } } - return 0; + return FALSE; } if (!CommSys_IsInitialized()) { - return 0; + return FALSE; } if (sub_02031934() != 4) { - return 0; + return FALSE; } if (CommSys_CurNetId() == param0) { - return 1; + return TRUE; } else if (CommSys_CurNetId() == 0) { u16 v1 = sub_020318EC(); if (v1 & (1 << param0)) { - return 1; + return TRUE; } } else if (sCommunicationSystem->unk_68C & (1 << param0)) { - return 1; + return TRUE; } - return 0; + return FALSE; } int CommSys_ConnectedCount(void) @@ -1677,26 +1638,26 @@ BOOL CommSys_IsSendingMovementData(void) return sCommunicationSystem->sendHeldKeys & 0x8000; } - return 1; + return TRUE; } -BOOL CommSys_WriteToQueueServer(int cmd, const void *param1, int param2) +BOOL CommSys_WriteToQueueServer(int cmd, const void *data, int param2) { if (CommSys_TransmissionType() == 1) { - return CommQueue_Write(&sCommunicationSystem->commQueueManSend, cmd, (u8 *)param1, param2, 1, 0); + return CommQueue_Write(&sCommunicationSystem->commQueueManSend, cmd, (u8 *)data, param2, 1, 0); } else { - return CommQueue_Write(&sCommunicationSystem->commQueueManSendServer, cmd, (u8 *)param1, param2, 1, 0); + return CommQueue_Write(&sCommunicationSystem->commQueueManSendServer, cmd, (u8 *)data, param2, 1, 0); } } -BOOL CommSys_WriteToQueue(int cmd, const void *param1, int param2) +BOOL CommSys_WriteToQueue(int cmd, const void *data, int param2) { - return CommQueue_Write(&sCommunicationSystem->commQueueManSend, cmd, (u8 *)param1, param2, 0, 0); + return CommQueue_Write(&sCommunicationSystem->commQueueManSend, cmd, (u8 *)data, param2, 0, 0); } static void CommSys_Transmission(void) { - BOOL v0 = 0; + BOOL v0 = FALSE; if (!sCommunicationSystem) { return; @@ -1723,10 +1684,9 @@ static void CommSys_Transmission(void) } } -void sub_02036008(int param0, int param1, void *param2, void *param3) +void sub_02036008(int unused0, int unused1, void *param2, void *unused3) { u8 *v0 = param2; - int v1; if (CommSys_CurNetId() != 0) { return; @@ -1736,10 +1696,9 @@ void sub_02036008(int param0, int param1, void *param2, void *param3) sCommunicationSystem->unk_6A4 = v0[0]; } -void sub_02036030(int param0, int param1, void *param2, void *param3) +void sub_02036030(int unused0, int unused1, void *param2, void *unused3) { u8 *v0 = param2; - int v1; if (CommSys_CurNetId() == 0) { return; @@ -1749,10 +1708,9 @@ void sub_02036030(int param0, int param1, void *param2, void *param3) sCommunicationSystem->transmissionState = 3; } -void sub_02036058(int param0, int param1, void *param2, void *param3) +void sub_02036058(int unused0, int unused1, void *param2, void *unused3) { u8 *v0 = param2; - int v1; if (CommSys_CurNetId() != 0) { return; @@ -1804,11 +1762,9 @@ BOOL CommSys_CheckError(void) return FALSE; } - if (sCommunicationSystem) { - if (sCommunicationSystem->unk_6B1) { - CommMan_SetErrorHandling(1, 1); - return TRUE; - } + if (sCommunicationSystem && sCommunicationSystem->unk_6B1) { + CommMan_SetErrorHandling(1, 1); + return TRUE; } return CommServerClient_CheckError(); @@ -1857,10 +1813,8 @@ void sub_0203619C(int param0, int param1, void *param2, void *param3) { u8 v0; - if (!sub_0203406C()) { - if (CommSys_CurNetId() == 0) { - sub_02035B48(2, &v0); - } + if (!sub_0203406C() && CommSys_CurNetId() == 0) { + sub_02035B48(2, &v0); } sub_0203408C(); @@ -1916,10 +1870,8 @@ void sub_020362DC(int param0, int param1) int sub_020362F4(int networkId) { - if (sCommunicationSystem) { - if (sCommunicationSystem->unk_69F[networkId] != 0xff) { - return sCommunicationSystem->unk_69F[networkId]; - } + if (sCommunicationSystem && sCommunicationSystem->unk_69F[networkId] != 0xff) { + return sCommunicationSystem->unk_69F[networkId]; } return networkId; @@ -1928,7 +1880,7 @@ int sub_020362F4(int networkId) BOOL sub_02036314(void) { if (!CommLocal_IsWifiGroup(sub_0203895C())) { - return 0; + return FALSE; } return ov4_021D254C(); @@ -1936,7 +1888,7 @@ BOOL sub_02036314(void) void sub_0203632C(BOOL param0) { - int v0; + int i; if (CommLocal_IsWifiGroup(sub_0203895C())) { if (sCommunicationSystem->unk_65C == param0) { @@ -1948,8 +1900,8 @@ void sub_0203632C(BOOL param0) if (param0) { sCommunicationSystem->unk_660 = 0; - for (v0 = 0; v0 < MAX_CONNECTED_PLAYERS; v0++) { - sCommunicationSystem->unk_664[v0] = 0; + for (i = 0; i < MAX_CONNECTED_PLAYERS; i++) { + sCommunicationSystem->unk_664[i] = 0; } } } @@ -1971,10 +1923,10 @@ void sub_02036378(BOOL param0) BOOL sub_020363A0(void) { if (sCommunicationSystem->unk_6A9) { - return 1; + return TRUE; } - return 0; + return FALSE; } void sub_020363BC(void) diff --git a/src/encounter.c b/src/encounter.c index bdb0be7235..7186d0c988 100644 --- a/src/encounter.c +++ b/src/encounter.c @@ -368,11 +368,8 @@ void Encounter_StartVsWild(FieldSystem *fieldSystem, FieldTask *task, FieldBattl static BOOL FieldTask_WildEncounter(FieldTask *task) { - FieldSystem *fieldSystem; - WildEncounter *encounter; - - fieldSystem = FieldTask_GetFieldSystem(task); - encounter = FieldTask_GetEnv(task); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + WildEncounter *encounter = FieldTask_GetEnv(task); switch (encounter->state) { case 0: @@ -660,10 +657,8 @@ void Encounter_NewVsPalParkTransfer(FieldSystem *fieldSystem, FieldBattleDTO *dt void Encounter_NewVsFirstBattle(FieldTask *task, int trainerID, int heapID, int *resultMaskPtr) { - FieldBattleDTO *dto; FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); - - dto = FieldBattleDTO_New(HEAP_ID_FIELDMAP, BATTLE_TYPE_TRAINER); + FieldBattleDTO *dto = FieldBattleDTO_New(HEAP_ID_FIELDMAP, BATTLE_TYPE_TRAINER); FieldBattleDTO_Init(dto, fieldSystem); dto->battleStatusMask = BATTLE_STATUS_FIRST_BATTLE; @@ -724,12 +719,9 @@ static BOOL FieldTask_CatchingTutorialEncounter(FieldTask *task) void Encounter_NewCatchingTutorial(FieldTask *task) { - Encounter *encounter; - FieldBattleDTO *dto; FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); - - dto = FieldBattleDTO_NewCatchingTutorial(HEAP_ID_FIELDMAP, fieldSystem); - encounter = NewEncounter(dto, EncEffects_CutInEffect(dto), EncEffects_BGM(dto), NULL); + FieldBattleDTO *dto = FieldBattleDTO_NewCatchingTutorial(HEAP_ID_FIELDMAP, fieldSystem); + Encounter *encounter = NewEncounter(dto, EncEffects_CutInEffect(dto), EncEffects_BGM(dto), NULL); FieldTask_InitCall(task, FieldTask_CatchingTutorialEncounter, encounter); } diff --git a/src/field_battle_data_transfer.c b/src/field_battle_data_transfer.c index 9e6175bc7c..95ba924121 100644 --- a/src/field_battle_data_transfer.c +++ b/src/field_battle_data_transfer.c @@ -154,15 +154,11 @@ FieldBattleDTO *FieldBattleDTO_NewCatchingTutorial(enum HeapId heapID, const Fie { TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(fieldSystem->saveData); Options *options = SaveData_Options(fieldSystem->saveData); - MessageLoader *msgLoader; - Strbuf *strbuf; - FieldBattleDTO *dto; + FieldBattleDTO *dto = FieldBattleDTO_New(heapID, BATTLE_TYPE_CATCH_TUTORIAL); + MessageLoader *msgLoader = MessageLoader_Init(MESSAGE_LOADER_NARC_HANDLE, NARC_INDEX_MSGDATA__PL_MSG, message_bank_counterpart_names, heapID); + Strbuf *strbuf = Strbuf_Init(TRAINER_NAME_LEN + 1, heapID); Pokemon *mon; - dto = FieldBattleDTO_New(heapID, BATTLE_TYPE_CATCH_TUTORIAL); - msgLoader = MessageLoader_Init(MESSAGE_LOADER_NARC_HANDLE, NARC_INDEX_MSGDATA__PL_MSG, message_bank_counterpart_names, heapID); - strbuf = Strbuf_Init(TRAINER_NAME_LEN + 1, heapID); - MessageLoader_GetStrbuf(msgLoader, TrainerInfo_Gender(trainerInfo) ^ 1, strbuf); TrainerInfo_SetName(dto->trainerInfo[BATTLER_PLAYER_SLOT_1], Strbuf_GetData(strbuf)); Strbuf_Free(strbuf); diff --git a/src/field_comm_manager.c b/src/field_comm_manager.c index b87db3b44c..17b50517fc 100644 --- a/src/field_comm_manager.c +++ b/src/field_comm_manager.c @@ -35,8 +35,8 @@ #include "unk_02071D40.h" #include "unk_02099500.h" -static void FieldCommMan_RunTask(SysTask *param0, void *param1); -static void FieldCommMan_SetTask(FieldCommTask param0, int param1); +static void FieldCommMan_RunTask(SysTask *task, void *unused); +static void FieldCommMan_SetTask(FieldCommTask task, int time); static void Task_StartBattleServer(void); static void Task_ServerWait(void); static void Task_StartBattleClient(void); @@ -208,7 +208,7 @@ void sub_020598A0(void) FieldCommMan_SetTask(sub_0205A018, 5); } -void FieldCommMan_RunTask(SysTask *task, void *param1) +void FieldCommMan_RunTask(SysTask *task, void *unused) { if (sFieldCommMan == NULL) { SysTask_Done(task); @@ -384,10 +384,8 @@ static void sub_02059B10(void) CommPlayerMan_Restart(); CommPlayer_SendPos(0); - { - u8 v0 = 1; - CommSys_SendDataFixedSize(94, &v0); - } + u8 v0 = 1; + CommSys_SendDataFixedSize(94, &v0); StartScreenTransition(0, 1, 1, 0x0, 6, 1, 4); sub_0200F32C(0); @@ -398,16 +396,16 @@ static void sub_02059B10(void) static void sub_02059B74(void) { - int v0, v1; + int i, j; - for (v0 = 0; v0 < CommSys_ConnectedCount(); v0++) { - if (v0 != CommSys_CurNetId()) { - if (sub_02036564(v0) == 94) { + for (i = 0; i < CommSys_ConnectedCount(); i++) { + if (i != CommSys_CurNetId()) { + if (sub_02036564(i) == 94) { if (sFieldCommMan->fieldSystem->task == NULL) { - for (v1 = 0; v1 < 4; v1++) { - if (sFieldCommMan->trainerCard[v1]) { - Heap_FreeToHeap(sFieldCommMan->trainerCard[v1]); - sFieldCommMan->trainerCard[v1] = NULL; + for (j = 0; j < 4; j++) { + if (sFieldCommMan->trainerCard[j]) { + Heap_FreeToHeap(sFieldCommMan->trainerCard[j]); + sFieldCommMan->trainerCard[j] = NULL; } } @@ -425,10 +423,8 @@ static void sub_02059BF4(void) if (!sub_020590C4()) { sFieldCommMan->unk_43 = 0; - { - u8 v0 = 1; - CommSys_SendDataFixedSize(94, &v0); - } + u8 v0 = 1; + CommSys_SendDataFixedSize(94, &v0); FieldCommMan_SetTask(sub_02059CD8, 0); } @@ -446,10 +442,8 @@ static void sub_02059C2C(BOOL param0, const Party *party) if (param0) { FieldCommMan_SetTask(sub_02059E50, 3); } else { - { - u8 v0 = 3; - CommSys_SendDataFixedSize(94, &v0); - } + u8 v0 = 3; + CommSys_SendDataFixedSize(94, &v0); FieldCommMan_SetTask(sub_02059BF4, 0); } @@ -481,16 +475,14 @@ static void sub_02059CD8(void) if (sFieldCommMan->unk_43) { FieldCommMan_SetTask(sub_02059C8C, 5); - { - u8 v0 = 0; - CommSys_SendDataFixedSize(94, &v0); - } + u8 v0 = 0; + CommSys_SendDataFixedSize(94, &v0); } sub_02059B74(); } -void sub_02059D0C(int param0, int param1, void *param2, void *param3) +void sub_02059D0C(int unused0, int unused1, void *param2, void *unused3) { u8 *v0 = param2; @@ -503,16 +495,16 @@ BOOL sub_02059D2C(void) { if (sFieldCommMan) { if ((sFieldCommMan->task == sub_02059CD8) || (sFieldCommMan->task == sub_02059BF4)) { - return 1; + return TRUE; } } - return 0; + return FALSE; } static void sub_02059D58(void) { - BOOL v0 = 1; + BOOL v0 = TRUE; int v1; u8 v2[6]; @@ -576,7 +568,7 @@ static void sub_02059E0C(void) static void sub_02059E34(void) { - BOOL v0 = 1; + BOOL v0 = TRUE; if (CommTiming_IsSyncState(3)) { FieldCommMan_SetTask(sub_02059E0C, 2); @@ -585,7 +577,7 @@ static void sub_02059E34(void) static void sub_02059E50(void) { - BOOL v0 = 1; + BOOL v0 = TRUE; if (sFieldCommMan->timer != 0) { sFieldCommMan->timer--; @@ -612,12 +604,12 @@ static void sub_02059E94(void) FieldCommMan_SetTask(sub_02059964, 10); } -void sub_02059EAC(int param0, int param1, void *param2, void *param3) +void sub_02059EAC(int param0, int unused1, void *unused2, void *unused3) { sFieldCommMan->unk_10[param0] = 1; } -u8 *sub_02059EBC(int param0, void *param1, int param2) +u8 *sub_02059EBC(int param0, void *unused1, int unused2) { GF_ASSERT(param0 < 4); return (u8 *)sFieldCommMan->trainerCard[param0]; @@ -625,7 +617,7 @@ u8 *sub_02059EBC(int param0, void *param1, int param2) static void FieldCommTask_StartCopyTrainerCard(void) { - int v0, v1 = CommSys_CurNetId(); + int v1 = CommSys_CurNetId(); if (CommTiming_IsSyncState(95)) { CommSys_SendDataHuge(88, sFieldCommMan->trainerCard[v1], sizeof(TrainerCard)); @@ -635,10 +627,10 @@ static void FieldCommTask_StartCopyTrainerCard(void) static void FieldCommTask_CopyTrainerCard(void) { - int v0; + int i; - for (v0 = 0; v0 < CommSys_ConnectedCount(); v0++) { - if (!sFieldCommMan->unk_10[v0]) { + for (i = 0; i < CommSys_ConnectedCount(); i++) { + if (!sFieldCommMan->unk_10[i]) { return; } } @@ -724,13 +716,13 @@ static void sub_0205A058(void) FieldCommMan_SetTask(FieldCommMan_Delete, 0); } -UnkStruct_02029894 *sub_0205A080(SaveData *param0) +UnkStruct_02029894 *sub_0205A080(SaveData *saveData) { if (!sFieldCommMan || !sFieldCommMan->unk_41) { return NULL; } - return ov23_02242E10(param0); + return ov23_02242E10(saveData); } void sub_0205A0A0(void) diff --git a/src/game_overlay.c b/src/game_overlay.c index 5dc07207e2..a2cc2a59e6 100644 --- a/src/game_overlay.c +++ b/src/game_overlay.c @@ -21,10 +21,10 @@ typedef struct { PMiLoadedOverlay unk_80[8]; } UnkStruct_021BF370; -static void FreeOverlayAllocation(PMiLoadedOverlay *param0); -static BOOL CanOverlayBeLoaded(const FSOverlayID param0); +static void FreeOverlayAllocation(PMiLoadedOverlay *loadedOverlays); +static BOOL CanOverlayBeLoaded(const FSOverlayID overlayID); static PMiLoadedOverlay *GetLoadedOverlaysInRegion(int param0); -static BOOL GetOverlayRamBounds(const FSOverlayID param0, u32 *param1, u32 *param2); +static BOOL GetOverlayRamBounds(const FSOverlayID overlayID, u32 *param1, u32 *param2); static BOOL LoadOverlayNormal(MIProcessor param0, FSOverlayID param1); static BOOL LoadOverlayNoInit(MIProcessor param0, FSOverlayID param1); static BOOL LoadOverlayNoInitAsync(MIProcessor param0, FSOverlayID param1); @@ -72,24 +72,22 @@ void LoadOverlayGDB(const FSOverlayID overlayID) } #endif // GDB_DEBUGGING -static void FreeOverlayAllocation(PMiLoadedOverlay *param0) +static void FreeOverlayAllocation(PMiLoadedOverlay *loadedOverlays) { - GF_ASSERT(param0->isActive == 1); - GF_ASSERT(FS_UnloadOverlay(MI_PROCESSOR_ARM9, param0->id) == TRUE); + GF_ASSERT(loadedOverlays->isActive == TRUE); + GF_ASSERT(FS_UnloadOverlay(MI_PROCESSOR_ARM9, loadedOverlays->id) == TRUE); - param0->isActive = 0; + loadedOverlays->isActive = FALSE; } void Overlay_UnloadByID(const FSOverlayID overlayID) { - PMiLoadedOverlay *table; + PMiLoadedOverlay *loadedOverlays = GetLoadedOverlaysInRegion(Overlay_GetLoadDestination(overlayID)); int i; - table = GetLoadedOverlaysInRegion(Overlay_GetLoadDestination(overlayID)); - for (i = 0; i < 8; i++) { - if ((table[i].isActive == 1) && (table[i].id == overlayID)) { - FreeOverlayAllocation(&table[i]); + if (loadedOverlays[i].isActive == TRUE && loadedOverlays[i].id == overlayID) { + FreeOverlayAllocation(&loadedOverlays[i]); #ifdef GDB_DEBUGGING UnloadOverlayGDB(overlayID); #endif @@ -175,20 +173,20 @@ BOOL Overlay_LoadByID(const FSOverlayID overlayID, enum OverlayLoadType loadType return TRUE; } -static BOOL CanOverlayBeLoaded(const FSOverlayID param0) +static BOOL CanOverlayBeLoaded(const FSOverlayID overlayID) { u32 myStart, myEnd, theirStart, theirEnd; - PMiLoadedOverlay *loadedOverlay; + PMiLoadedOverlay *loadedOverlays; int i; - if (!GetOverlayRamBounds(param0, &myStart, &myEnd)) { + if (!GetOverlayRamBounds(overlayID, &myStart, &myEnd)) { return FALSE; } - loadedOverlay = GetLoadedOverlaysInRegion(Overlay_GetLoadDestination(param0)); + loadedOverlays = GetLoadedOverlaysInRegion(Overlay_GetLoadDestination(overlayID)); for (i = 0; i < 8; i++) { - if (loadedOverlay[i].isActive == TRUE && GetOverlayRamBounds(loadedOverlay[i].id, &theirStart, &theirEnd) == TRUE) { + if (loadedOverlays[i].isActive == TRUE && GetOverlayRamBounds(loadedOverlays[i].id, &theirStart, &theirEnd) == TRUE) { if (((myStart >= theirStart) && (myStart < theirEnd)) || ((myEnd > theirStart) && (myEnd <= theirEnd)) || ((myStart <= theirStart) && (myEnd >= theirEnd))) { GF_ASSERT(0); return FALSE; diff --git a/src/heap.c b/src/heap.c index 607ba8351a..9382ed6bcd 100644 --- a/src/heap.c +++ b/src/heap.c @@ -162,31 +162,29 @@ void Heap_Destroy(u32 heapID) { GF_ASSERT(OS_GetProcMode() != OS_PROCMODE_IRQ); - { - u8 index = sHeapInfo.heapIdxs[heapID]; - NNSFndHeapHandle handle = sHeapInfo.heapHandles[index]; + u8 index = sHeapInfo.heapIdxs[heapID]; + NNSFndHeapHandle handle = sHeapInfo.heapHandles[index]; - if (handle != NNS_FND_HEAP_INVALID_HANDLE) { - NNSFndHeapHandle parentHeap; - void *childRaw; + if (handle != NNS_FND_HEAP_INVALID_HANDLE) { + NNSFndHeapHandle parentHeap; + void *childRaw; - NNS_FndDestroyExpHeap(handle); + NNS_FndDestroyExpHeap(handle); - parentHeap = sHeapInfo.parentHeapHandles[sHeapInfo.heapIdxs[heapID]]; - childRaw = sHeapInfo.subHeapRawPtrs[sHeapInfo.heapIdxs[heapID]]; + parentHeap = sHeapInfo.parentHeapHandles[sHeapInfo.heapIdxs[heapID]]; + childRaw = sHeapInfo.subHeapRawPtrs[sHeapInfo.heapIdxs[heapID]]; - if ((parentHeap != NNS_FND_HEAP_INVALID_HANDLE) && (childRaw != NULL)) { - NNS_FndFreeToExpHeap(parentHeap, childRaw); - } else { - GF_ASSERT(0); - } + if ((parentHeap != NNS_FND_HEAP_INVALID_HANDLE) && (childRaw != NULL)) { + NNS_FndFreeToExpHeap(parentHeap, childRaw); + } else { + GF_ASSERT(0); + } - sHeapInfo.heapHandles[sHeapInfo.heapIdxs[heapID]] = (void *)0; - sHeapInfo.parentHeapHandles[sHeapInfo.heapIdxs[heapID]] = (void *)0; - sHeapInfo.subHeapRawPtrs[sHeapInfo.heapIdxs[heapID]] = (void *)0; + sHeapInfo.heapHandles[sHeapInfo.heapIdxs[heapID]] = (void *)0; + sHeapInfo.parentHeapHandles[sHeapInfo.heapIdxs[heapID]] = (void *)0; + sHeapInfo.subHeapRawPtrs[sHeapInfo.heapIdxs[heapID]] = (void *)0; - sHeapInfo.heapIdxs[heapID] = sHeapInfo.unallocatedHeapID; - } + sHeapInfo.heapIdxs[heapID] = sHeapInfo.unallocatedHeapID; } } @@ -355,5 +353,5 @@ void Heap_ReallocFromHeap(void *ptr, u32 newSize) BOOL GF_heap_c_dummy_return_true(u32 heapID) #pragma unused(heapID) { - return 1; + return TRUE; }