diff --git a/include/battle_util.h b/include/battle_util.h index b77fa10ad6..157ba8eb6d 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -52,8 +52,8 @@ void CancelMultiTurnMoves(u8 battlerId); bool8 WasUnableToUseMove(u8 battlerId); void PrepareStringBattle(u16 stringId, u8 battlerId); void ResetSentPokesToOpponentValue(void); -void sub_803F9EC(u8 battlerId); -void sub_803FA70(u8 battlerId); +void OpponentSwitchInResetSentPokesToOpponentValue(u8 battlerId); +void UpdateSentPokesToOpponentValue(u8 battlerId); void BattleScriptPush(const u8* bsPtr); void BattleScriptPushCursor(void); void BattleScriptPop(void); diff --git a/src/AgbRfu_LinkManager.c b/src/AgbRfu_LinkManager.c index e4127ee090..f6ebcc7265 100644 --- a/src/AgbRfu_LinkManager.c +++ b/src/AgbRfu_LinkManager.c @@ -918,7 +918,7 @@ static void rfu_LMAN_REQ_callback(u16 reqCommandId, u16 reqResult) { lman.reserveDisconnectSlot_flag = 0; lman.acceptCount = 0; - lman.acceptSlot_flag = 0;; + lman.acceptSlot_flag = 0; lman.parent_child = MODE_NEUTRAL; rfu_LMAN_managerChangeAgbClockMaster(); if (reqCommandId == ID_STOP_MODE_REQ) diff --git a/src/agb_flash.c b/src/agb_flash.c index 1ad9e47ecb..eeccf11164 100644 --- a/src/agb_flash.c +++ b/src/agb_flash.c @@ -41,7 +41,7 @@ u16 ReadFlashId(void) u8 (*readFlash1)(u8 *); SetReadFlash1(readFlash1Buffer); - readFlash1 = (u8 (*)(u8 *))((s32)readFlash1Buffer + 1); + readFlash1 = (u8 (*)(u8 *))((uintptr_t)readFlash1Buffer + 1); // Enter ID mode. FLASH_WRITE(0x5555, 0xAA); @@ -113,12 +113,12 @@ void SetReadFlash1(u16 *dest) u16 *src; u16 i; - PollFlashStatus = (u8 (*)(u8 *))((s32)dest + 1); + PollFlashStatus = (u8 (*)(u8 *))((uintptr_t)dest + 1); src = (u16 *)ReadFlash1; - src = (u16 *)((s32)src ^ 1); + src = (u16 *)((uintptr_t)src ^ 1); - i = ((s32)SetReadFlash1 - (s32)ReadFlash1) >> 1; + i = ((uintptr_t)SetReadFlash1 - (uintptr_t)ReadFlash1) >> 1; while (i != 0) { @@ -154,10 +154,10 @@ void ReadFlash(u16 sectorNum, u32 offset, u8 *dest, u32 size) } funcSrc = (u16 *)ReadFlash_Core; - funcSrc = (u16 *)((s32)funcSrc ^ 1); + funcSrc = (u16 *)((uintptr_t)funcSrc ^ 1); funcDest = readFlash_Core_Buffer; - i = ((s32)ReadFlash - (s32)ReadFlash_Core) >> 1; + i = ((uintptr_t)ReadFlash - (uintptr_t)ReadFlash_Core) >> 1; while (i != 0) { @@ -165,7 +165,7 @@ void ReadFlash(u16 sectorNum, u32 offset, u8 *dest, u32 size) i--; } - readFlash_Core = (void (*)(vu8 *, u8 *, u32))((s32)readFlash_Core_Buffer + 1); + readFlash_Core = (void (*)(vu8 *, u8 *, u32))((uintptr_t)readFlash_Core_Buffer + 1); src = FLASH_BASE + (sectorNum << gFlash->sector.shift) + offset; @@ -202,10 +202,10 @@ u32 VerifyFlashSector(u16 sectorNum, u8 *src) } funcSrc = (u16 *)VerifyFlashSector_Core; - funcSrc = (u16 *)((s32)funcSrc ^ 1); + funcSrc = (u16 *)((uintptr_t)funcSrc ^ 1); funcDest = verifyFlashSector_Core_Buffer; - i = ((s32)VerifyFlashSector - (s32)VerifyFlashSector_Core) >> 1; + i = (u16)(((uintptr_t)VerifyFlashSector - (uintptr_t)VerifyFlashSector_Core) >> 1); while (i != 0) { @@ -213,7 +213,7 @@ u32 VerifyFlashSector(u16 sectorNum, u8 *src) i--; } - verifyFlashSector_Core = (u32 (*)(u8 *, u8 *, u32))((s32)verifyFlashSector_Core_Buffer + 1); + verifyFlashSector_Core = (u32 (*)(u8 *, u8 *, u32))((uintptr_t)verifyFlashSector_Core_Buffer + 1); tgt = FLASH_BASE + (sectorNum << gFlash->sector.shift); size = gFlash->sector.size; @@ -239,10 +239,10 @@ u32 VerifyFlashSectorNBytes(u16 sectorNum, u8 *src, u32 n) REG_WAITCNT = (REG_WAITCNT & ~WAITCNT_SRAM_MASK) | WAITCNT_SRAM_8; funcSrc = (u16 *)VerifyFlashSector_Core; - funcSrc = (u16 *)((s32)funcSrc ^ 1); + funcSrc = (u16 *)((uintptr_t)funcSrc ^ 1); funcDest = verifyFlashSector_Core_Buffer; - i = ((s32)VerifyFlashSector - (s32)VerifyFlashSector_Core) >> 1; + i = ((uintptr_t)VerifyFlashSector - (uintptr_t)VerifyFlashSector_Core) >> 1; while (i != 0) { @@ -250,7 +250,7 @@ u32 VerifyFlashSectorNBytes(u16 sectorNum, u8 *src, u32 n) i--; } - verifyFlashSector_Core = (u32 (*)(u8 *, u8 *, u32))((s32)verifyFlashSector_Core_Buffer + 1); + verifyFlashSector_Core = (u32 (*)(u8 *, u8 *, u32))((uintptr_t)verifyFlashSector_Core_Buffer + 1); tgt = FLASH_BASE + (sectorNum << gFlash->sector.shift); @@ -293,4 +293,4 @@ u32 ProgramFlashSectorAndVerifyNBytes(u16 sectorNum, u8 *src, u32 n) } return result; -} +} \ No newline at end of file diff --git a/src/battle_anim_bug.c b/src/battle_anim_bug.c index ea3df80986..5e8a8b2a76 100644 --- a/src/battle_anim_bug.c +++ b/src/battle_anim_bug.c @@ -372,14 +372,11 @@ static void AnimTranslateStinger(struct Sprite *sprite) { gBattleAnimArgs[2] = -gBattleAnimArgs[2]; } - else + else if (GetBattlerSide(gBattleAnimAttacker)) { - if (GetBattlerSide(gBattleAnimAttacker)) - { - gBattleAnimArgs[2] = -gBattleAnimArgs[2]; - gBattleAnimArgs[1] = -gBattleAnimArgs[1]; - gBattleAnimArgs[3] = -gBattleAnimArgs[3]; - } + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + gBattleAnimArgs[3] = -gBattleAnimArgs[3]; } if (!IsContest() && GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget)) @@ -387,13 +384,8 @@ static void AnimTranslateStinger(struct Sprite *sprite) if (GetBattlerPosition(gBattleAnimTarget) == B_POSITION_PLAYER_LEFT || GetBattlerPosition(gBattleAnimTarget) == B_POSITION_OPPONENT_LEFT) { - s16 temp1, temp2; - - temp1 = gBattleAnimArgs[2]; - gBattleAnimArgs[2] = -temp1; - - temp2 = gBattleAnimArgs[0]; - gBattleAnimArgs[0] = -temp2; + gBattleAnimArgs[2] *= -1; + gBattleAnimArgs[0] *= -1; } } @@ -448,28 +440,24 @@ static void AnimMissileArc_Step(struct Sprite *sprite) else { s16 tempData[8]; - u16 *data = sprite->data; - u16 x1 = sprite->pos1.x; - s16 x2 = sprite->pos2.x; - u16 y1 = sprite->pos1.y; - s16 y2 = sprite->pos2.y; + s16 xpos, ypos; int i; for (i = 0; i < 8; i++) - tempData[i] = data[i]; + tempData[i] = sprite->data[i]; - x2 += x1; - y2 += y1; + xpos = sprite->pos1.x + sprite->pos2.x; + ypos = sprite->pos1.y + sprite->pos2.y; if (!TranslateAnimHorizontalArc(sprite)) { - u16 rotation = ArcTan2Neg(sprite->pos1.x + sprite->pos2.x - x2, - sprite->pos1.y + sprite->pos2.y - y2); + u16 rotation = ArcTan2Neg(sprite->pos1.x + sprite->pos2.x - xpos, //Isn't this zero lol + sprite->pos1.y + sprite->pos2.y - ypos); rotation += 0xC000; TrySetSpriteRotScale(sprite, FALSE, 0x100, 0x100, rotation); for (i = 0; i < 8; i++) - data[i] = tempData[i]; + sprite->data[i] = tempData[i]; } } } diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index 516c58e557..f4769145d4 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -3967,24 +3967,25 @@ static void AnimProtect(struct Sprite* sprite) static void AnimProtect_Step(struct Sprite *sprite) { - int a; - int i; + int i, savedPal; sprite->data[5] += 96; sprite->pos2.x = -(sprite->data[5] >> 8); if (++sprite->data[1] > 1) { + int id; sprite->data[1] = 0; - a = gPlttBufferFaded[sprite->data[2] + 1]; + savedPal = gPlttBufferFaded[sprite->data[2] + 1]; i = 0; do { - gPlttBufferFaded[sprite->data[2] + ++i] = gPlttBufferFaded[sprite->data[2] + i + 1]; + id = sprite->data[2] + ++i; + gPlttBufferFaded[id] = gPlttBufferFaded[id + 1]; } while (i < 6); - gPlttBufferFaded[sprite->data[2] + 7] = a; + gPlttBufferFaded[sprite->data[2] + 7] = savedPal; } - if (sprite->data[7] > 6 && sprite->data[0] >0 && ++sprite->data[6] > 1) + if (sprite->data[7] > 6 && sprite->data[0] > 0 && ++sprite->data[6] > 1) { sprite->data[6] = 0; sprite->data[7] -= 1; diff --git a/src/battle_anim_psychic.c b/src/battle_anim_psychic.c index 7918698fc0..25340f9c6a 100644 --- a/src/battle_anim_psychic.c +++ b/src/battle_anim_psychic.c @@ -1101,7 +1101,7 @@ static void AnimTask_TransparentCloneGrowAndShrink_Step(u8 taskId) break; case 1: task->data[1] -= 4; - task->data[2] = 256 - (gSineTable[task->data[1]] >> 1);; + task->data[2] = 256 - (gSineTable[task->data[1]] >> 1); SetSpriteRotScale(task->data[15], task->data[2], task->data[2], 0); SetBattlerSpriteYOffsetFromOtherYScale(task->data[15], task->data[13]); if (task->data[1] == 0) diff --git a/src/battle_anim_utility_funcs.c b/src/battle_anim_utility_funcs.c index dcef7d4830..bca669cc26 100644 --- a/src/battle_anim_utility_funcs.c +++ b/src/battle_anim_utility_funcs.c @@ -569,7 +569,7 @@ static void sub_81172EC(u8 taskId) if (gTasks[taskId].data[12] == 0) { sub_80A477C(0); - gTasks[taskId].data[15]++;; + gTasks[taskId].data[15]++; } } break; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 4e0e087b60..994d356258 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5471,7 +5471,7 @@ static void Cmd_switchineffects(void) s32 i; gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); - sub_803FA70(gActiveBattler); + UpdateSentPokesToOpponentValue(gActiveBattler); gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); gSpecialStatuses[gActiveBattler].flag40 = 0; diff --git a/src/battle_util.c b/src/battle_util.c index 9cc2252b68..89fe95fbc4 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -259,7 +259,7 @@ void ResetSentPokesToOpponentValue(void) gSentPokesToOpponent[(i & BIT_FLANK) >> 1] = bits; } -void sub_803F9EC(u8 battler) +void OpponentSwitchInResetSentPokesToOpponentValue(u8 battler) { s32 i = 0; u32 bits = 0; @@ -279,11 +279,11 @@ void sub_803F9EC(u8 battler) } } -void sub_803FA70(u8 battler) +void UpdateSentPokesToOpponentValue(u8 battler) { if (GetBattlerSide(battler) == B_SIDE_OPPONENT) { - sub_803F9EC(battler); + OpponentSwitchInResetSentPokesToOpponentValue(battler); } else { @@ -1250,7 +1250,7 @@ bool8 HandleFaintedMonActions(void) gBattleStruct->faintedActionsState = 3; break; case 2: - sub_803F9EC(gBattlerFainted); + OpponentSwitchInResetSentPokesToOpponentValue(gBattlerFainted); if (++gBattleStruct->faintedActionsBattlerId == gBattlersCount) gBattleStruct->faintedActionsState = 3; else diff --git a/src/berry.c b/src/berry.c index 98264f37b8..d70e8c3537 100644 --- a/src/berry.c +++ b/src/berry.c @@ -1331,7 +1331,7 @@ void ResetBerryTreeSparkleFlags(void) s16 bottom; int i; - GetCameraCoords(&cam_left, &cam_top); + GetCameraCoords((u16*)&cam_left, (u16*)&cam_top); left = cam_left; top = cam_top + 3; right = cam_left + 14; diff --git a/src/berry_blender.c b/src/berry_blender.c index a2a96c0892..de3cc62759 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -116,8 +116,8 @@ struct BerryBlenderData u16 field_116; u16 field_118; u16 field_11A; - u16 bg_X; - u16 bg_Y; + s16 bg_X; + s16 bg_Y; u8 field_120[3]; u8 field_123; u16 scores[BLENDER_MAX_PLAYERS][BLENDER_SCORES_NO]; @@ -3166,13 +3166,13 @@ static void sub_80832E8(s16* a0) static void sub_808330C(void) { - sub_80832E8(&sBerryBlenderData->bg_X); - sub_80832E8(&sBerryBlenderData->bg_Y); + sub_80832E8((s16 *)&sBerryBlenderData->bg_X); + sub_80832E8((s16 *)&sBerryBlenderData->bg_Y); } static void sub_8083334(s16* a0, u16 a1) { - s32 var; + u8 var; if (a1 < 10) var = 16; diff --git a/src/digit_obj_util.c b/src/digit_obj_util.c index fe5d49e69d..f887dafb95 100644 --- a/src/digit_obj_util.c +++ b/src/digit_obj_util.c @@ -33,7 +33,7 @@ struct DigitPrinterAlloc }; // this file's functions -static u8 GetFirstOamId(u8 oamCount);; +static u8 GetFirstOamId(u8 oamCount); static void CopyWorkToOam(struct DigitPrinter *objWork); static void DrawNumObjsLeadingZeros(struct DigitPrinter *objWork, s32 num, bool32 sign); static void DrawNumObjsMinusInFront(struct DigitPrinter *objWork, s32 num, bool32 sign); diff --git a/src/easy_chat.c b/src/easy_chat.c index 44a7b90c14..c839c0070d 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -2537,7 +2537,7 @@ u8 sub_811BBBC(void) return sEasyChatScreen->unk_0c; } -void sub_811BBC8(u8 *arg0, u8 *arg1) +static void sub_811BBC8(s8 *arg0, s8 *arg1) { *arg0 = sEasyChatScreen->unk_10; *arg1 = sEasyChatScreen->unk_11; @@ -4529,18 +4529,18 @@ static void sub_811E30C(void) x = var0 * 13; x = x * 8 + 28; y = var1 * 16 + 96; - sub_811E34C(x, y); + sub_811E34C((u8)x, (u8)y); } static void sub_811E34C(u8 x, u8 y) { - if (sUnknown_0203A11C->unk2E4) - { - sUnknown_0203A11C->unk2E4->pos1.x = x; - sUnknown_0203A11C->unk2E4->pos1.y = y; - sUnknown_0203A11C->unk2E4->pos2.x = 0; - sUnknown_0203A11C->unk2E4->data[0] = 0; - } + if (!sUnknown_0203A11C->unk2E4) + return; + + sUnknown_0203A11C->unk2E4->pos1.x = (s16)x; + sUnknown_0203A11C->unk2E4->pos1.y = (s16)y; + sUnknown_0203A11C->unk2E4->pos2.x = 0; + sUnknown_0203A11C->unk2E4->data[0] = 0; } static void sub_811E380(void) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index de55362407..af34829695 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1220,7 +1220,6 @@ static u8 InitObjectEventStateFromTemplate(struct ObjectEventTemplate *template, objectEvent->movementType = template->movementType; objectEvent->localId = template->localId; objectEvent->mapNum = mapNum; - objectEvent++; objectEvent--; objectEvent->mapGroup = mapGroup; objectEvent->initialCoords.x = x; objectEvent->initialCoords.y = y; @@ -1233,13 +1232,11 @@ static u8 InitObjectEventStateFromTemplate(struct ObjectEventTemplate *template, objectEvent->range.as_nybbles.x = template->movementRangeX; objectEvent->range.as_nybbles.y = template->movementRangeY; objectEvent->trainerType = template->trainerType; + objectEvent->mapNum = mapNum; //redundant, but needed to match objectEvent->trainerRange_berryTreeId = template->trainerRange_berryTreeId; objectEvent->previousMovementDirection = gInitialMovementTypeFacingDirections[template->movementType]; SetObjectEventDirection(objectEvent, objectEvent->previousMovementDirection); SetObjectEventDynamicGraphicsId(objectEvent); -#ifndef NONMATCHING - asm("":::"r5", "r6"); -#endif if (gRangedMovementTypes[objectEvent->movementType]) { if (objectEvent->range.as_nybbles.x == 0) @@ -8950,7 +8947,7 @@ void CreateLevitateMovementTask(struct ObjectEvent *objectEvent) u8 taskId = CreateTask(ApplyLevitateMovement, 0xFF); struct Task *task = &gTasks[taskId]; - StoreWordInTwoHalfwords(&task->data[0], (u32)objectEvent); + StoreWordInTwoHalfwords((u16 *)&task->data[0], (u32)objectEvent); objectEvent->warpArrowSpriteId = taskId; task->data[3] = 0xFFFF; } @@ -8961,7 +8958,7 @@ static void ApplyLevitateMovement(u8 taskId) struct Sprite *sprite; struct Task *task = &gTasks[taskId]; - LoadWordFromTwoHalfwords(&task->data[0], (u32 *)&objectEvent); // load the map object pointer. + LoadWordFromTwoHalfwords((u16 *)&task->data[0], (u32 *)&objectEvent); // load the map object pointer. sprite = &gSprites[objectEvent->spriteId]; if(!(task->data[2] & 0x3)) @@ -8978,7 +8975,7 @@ void DestroyExtraMovementTask(u8 taskId) struct ObjectEvent *objectEvent; struct Task *task = &gTasks[taskId]; - LoadWordFromTwoHalfwords(&task->data[0], (u32 *)&objectEvent); // unused objectEvent + LoadWordFromTwoHalfwords((u16 *)&task->data[0], (u32 *)&objectEvent); // unused objectEvent DestroyTask(taskId); } diff --git a/src/field_effect.c b/src/field_effect.c index 07579f55d5..bc1e6f134d 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -2501,7 +2501,7 @@ static void sub_80B8584(struct Task *task) { task->data[11] = REG_WININ; task->data[12] = REG_WINOUT; - StoreWordInTwoHalfwords(&task->data[13], (u32)gMain.vblankCallback); + StoreWordInTwoHalfwords((u16 *)&task->data[13], (u32)gMain.vblankCallback); task->data[1] = 0xf0f1; task->data[2] = 0x5051; task->data[3] = 0x3f; diff --git a/src/item_use.c b/src/item_use.c index 0aae441c8b..fa3f130810 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -721,7 +721,7 @@ static void ItemUseOnFieldCB_WailmerPailBerry(u8 taskId) static bool8 TryToWaterSudowoodo(void) { - u16 x, y; + s16 x, y; u8 z; u8 objId; GetXYCoordsOneStepInFrontOfPlayer(&x, &y); diff --git a/src/list_menu.c b/src/list_menu.c index ddcad0fe9c..ebf02bab65 100644 --- a/src/list_menu.c +++ b/src/list_menu.c @@ -1257,17 +1257,17 @@ void ListMenuSetUpRedOutlineCursorSpriteOamTable(u16 rowWidth, u16 rowHeight, st s32 i, j, id = 0; subsprites[id] = sSubsprite_RedOutline1; - subsprites[id].x = 136; - subsprites[id].y = 136; + subsprites[id].x = -120; + subsprites[id].y = -120; id++; subsprites[id] = sSubsprite_RedOutline2; subsprites[id].x = rowWidth + 128; - subsprites[id].y = 136; + subsprites[id].y = -120; id++; subsprites[id] = sSubsprite_RedOutline7; - subsprites[id].x = 136; + subsprites[id].x = -120; subsprites[id].y = rowHeight + 128; id++; @@ -1297,7 +1297,7 @@ void ListMenuSetUpRedOutlineCursorSpriteOamTable(u16 rowWidth, u16 rowHeight, st for (j = 8; j < rowHeight - 8; j += 8) { subsprites[id] = sSubsprite_RedOutline4; - subsprites[id].x = 136; + subsprites[id].x = -120; subsprites[id].y = j - 120; id++; diff --git a/src/mirage_tower.c b/src/mirage_tower.c index e2f5cefb78..3f3dc1ef85 100644 --- a/src/mirage_tower.c +++ b/src/mirage_tower.c @@ -168,7 +168,7 @@ const struct PulseBlendSettings gMirageTowerPulseBlendSettings = { .numColors = 15, .delay = 5, .numFadeCycles = -1, - .maxBlendCoeff = 11, + .maxBlendCoeff = -5, .fadeType = 1, .restorePaletteOnUnload = FALSE, .unk7_7 = 1, @@ -412,10 +412,9 @@ void DoMirageTowerCeilingCrumble(void) static void WaitCeilingCrumble(u8 taskId) { - u16 *data = gTasks[taskId].data; - data[1]++; + u16 *data = (u16 *)gTasks[taskId].data; // Either wait 1000 frames, or until all 16 crumble sprites and the one screen-shake task are completed. - if (data[1] == 1000 || data[0] == 17) + if (++data[1] == 1000 || data[0] == 17) gTasks[taskId].func = FinishCeilingCrumbleTask; } @@ -691,7 +690,7 @@ static void DoFossilFallAndSink(u8 taskId) if (gSprites[sUnknown_0203CF0C->spriteId].callback != SpriteCallbackDummy) return; DestroySprite(&gSprites[sUnknown_0203CF0C->spriteId]); - FREE_AND_SET_NULL(sUnknown_0203CF0C->unkC);; + FREE_AND_SET_NULL(sUnknown_0203CF0C->unkC); FREE_AND_SET_NULL(sUnknown_0203CF0C->frameImage); FREE_AND_SET_NULL(sUnknown_0203CF0C->frameImageTiles); FREE_AND_SET_NULL(sUnknown_0203CF0C); diff --git a/src/overworld.c b/src/overworld.c index ea0d633bcf..6b8fd232e6 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -3212,7 +3212,7 @@ static void SpriteCB_LinkPlayer(struct Sprite *sprite) SetObjectSubpriorityByZCoord(objEvent->previousElevation, sprite, 1); sprite->oam.priority = ZCoordToPriority(objEvent->previousElevation); - if (!linkPlayerObjEvent->movementMode != MOVEMENT_MODE_FREE) + if (linkPlayerObjEvent->movementMode == MOVEMENT_MODE_FREE) StartSpriteAnim(sprite, GetFaceDirectionAnimNum(objEvent->range.as_byte)); else StartSpriteAnimIfDifferent(sprite, GetMoveDirectionAnimNum(objEvent->range.as_byte)); diff --git a/src/party_menu.c b/src/party_menu.c index d5bc6dfb63..6a38d90989 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -1862,7 +1862,7 @@ u8 GetMonAilment(struct Pokemon *mon) static void SetPartyMonsAllowedInMinigame(void) { - u16 *ptr; + s16 *ptr; if (gPartyMenu.menuType == PARTY_MENU_TYPE_MINIGAME) { @@ -4951,9 +4951,9 @@ static void Task_DisplayLevelUpStatsPg2(u8 taskId) static void DisplayLevelUpStatsPg1(u8 taskId) { - s16 *arrayPtr = sPartyMenuInternal->data; + u16 *arrayPtr = (u16*)sPartyMenuInternal->data; - arrayPtr[12] = CreateLevelUpStatsWindow(); + arrayPtr[12] = (u16)CreateLevelUpStatsWindow(); DrawLevelUpWindowPg1(arrayPtr[12], arrayPtr, &arrayPtr[6], TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY); CopyWindowToVram(arrayPtr[12], 2); ScheduleBgCopyTilemapToVram(2); @@ -4961,7 +4961,7 @@ static void DisplayLevelUpStatsPg1(u8 taskId) static void DisplayLevelUpStatsPg2(u8 taskId) { - s16 *arrayPtr = sPartyMenuInternal->data; + u16 *arrayPtr = (u16 *)sPartyMenuInternal->data; DrawLevelUpWindowPg2(arrayPtr[12], &arrayPtr[6], TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY); CopyWindowToVram(arrayPtr[12], 2); diff --git a/src/player_pc.c b/src/player_pc.c index fc0bd9f4c8..2010d84f85 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -327,7 +327,7 @@ void PlayerPC(void) static void InitPlayerPCMenu(u8 taskId) { - u16 *data; + s16 *data; struct WindowTemplate windowTemplate; data = gTasks[taskId].data; @@ -346,7 +346,7 @@ static void InitPlayerPCMenu(u8 taskId) static void PlayerPCProcessMenuInput(u8 taskId) { - u16 *data; + s16 *data; s8 inputOptionId; data = gTasks[taskId].data; @@ -435,7 +435,7 @@ static void PlayerPC_TurnOff(u8 taskId) static void InitItemStorageMenu(u8 taskId, u8 var) { - u16 *data; + s16 *data; struct WindowTemplate windowTemplate; data = gTasks[taskId].data; @@ -548,7 +548,7 @@ static void ItemStorage_Toss(u8 taskId) static void ItemStorage_WithdrawToss_Helper(u8 taskId, bool8 toss) { - u16 *data = gTasks[taskId].data; + s16 *data = gTasks[taskId].data; data[3] = toss; sub_816B4DC(taskId); @@ -581,9 +581,9 @@ static void ItemStorage_SetItemAndMailCount(u8 taskId) static void sub_816B4DC(u8 taskId) { - u16 *data = gTasks[taskId].data; + u16 *data = (u16 *)gTasks[taskId].data; - ClearStdWindowAndFrameToTransparent(data[4], FALSE); + ClearStdWindowAndFrameToTransparent((u8)data[4], FALSE); ClearWindowTilemap(data[4]); RemoveWindow(data[4]); ScheduleBgCopyTilemapToVram(0); @@ -1380,7 +1380,7 @@ static void ItemStorage_DoItemToss(u8 taskId) data = gTasks[taskId].data; b = (playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove); - if (!ItemId_GetImportance(gSaveBlock1Ptr->pcItems[b].itemId)) + if (ItemId_GetImportance(gSaveBlock1Ptr->pcItems[b].itemId) == 0) { CopyItemName(gSaveBlock1Ptr->pcItems[b].itemId, gStringVar1); ConvertIntToDecimalStringN(gStringVar2, data[2], STR_CONV_MODE_LEFT_ALIGN, 3); diff --git a/src/pokedex.c b/src/pokedex.c index 0541f3f2e6..777cc52cd6 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -5117,9 +5117,9 @@ static void Task_SelectSearchMenuItem(u8 taskId) u16 *scrollOffset; DrawOrEraseSearchParameterBox(FALSE); - menuItem = gTasks[taskId].tMenuItem; - cursorPos = &gTasks[taskId].data[sSearchOptions[menuItem].taskDataCursorPos]; - scrollOffset = &gTasks[taskId].data[sSearchOptions[menuItem].taskDataScrollOffset]; + menuItem = (u16)gTasks[taskId].tMenuItem; + cursorPos = (u16*)&gTasks[taskId].data[sSearchOptions[menuItem].taskDataCursorPos]; + scrollOffset = (u16*)&gTasks[taskId].data[sSearchOptions[menuItem].taskDataScrollOffset]; gTasks[taskId].tCursorPos = *cursorPos; gTasks[taskId].tScrollOffset = *scrollOffset; PrintSearchParameterText(taskId); diff --git a/src/pokemon.c b/src/pokemon.c index 80e93c5685..b26f2f412a 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4628,7 +4628,7 @@ void CopyPlayerPartyMonToBattleData(u8 battlerId, u8 partyIndex) gBattleMons[battlerId].statStages[i] = 6; gBattleMons[battlerId].status2 = 0; - sub_803FA70(battlerId); + UpdateSentPokesToOpponentValue(battlerId); ClearTemporarySpeciesSpriteData(battlerId, FALSE); } diff --git a/src/roulette.c b/src/roulette.c index 58e120cb50..f55736a969 100644 --- a/src/roulette.c +++ b/src/roulette.c @@ -633,7 +633,7 @@ static const struct UnkStruct1 gUnknown_085B6388[] = .var05 = 1, .var06 = 0xFF, .var07_0 = 8, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, { @@ -643,7 +643,7 @@ static const struct UnkStruct1 gUnknown_085B6388[] = .var05 = 1, .var06 = 0xFF, .var07_0 = 8, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, { @@ -653,7 +653,7 @@ static const struct UnkStruct1 gUnknown_085B6388[] = .var05 = 1, .var06 = 0xFF, .var07_0 = 8, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, { @@ -663,7 +663,7 @@ static const struct UnkStruct1 gUnknown_085B6388[] = .var05 = 1, .var06 = 0xFF, .var07_0 = 8, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, { @@ -673,7 +673,7 @@ static const struct UnkStruct1 gUnknown_085B6388[] = .var05 = 1, .var06 = 0xFF, .var07_0 = 8, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, { @@ -683,7 +683,7 @@ static const struct UnkStruct1 gUnknown_085B6388[] = .var05 = 1, .var06 = 0xFF, .var07_0 = 8, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, { @@ -693,7 +693,7 @@ static const struct UnkStruct1 gUnknown_085B6388[] = .var05 = 1, .var06 = 0xFF, .var07_0 = 8, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, { @@ -703,7 +703,7 @@ static const struct UnkStruct1 gUnknown_085B6388[] = .var05 = 1, .var06 = 0xFF, .var07_0 = 8, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, { @@ -713,7 +713,7 @@ static const struct UnkStruct1 gUnknown_085B6388[] = .var05 = 1, .var06 = 0xFF, .var07_0 = 8, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, { @@ -723,7 +723,7 @@ static const struct UnkStruct1 gUnknown_085B6388[] = .var05 = 1, .var06 = 0xFF, .var07_0 = 8, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, { @@ -733,7 +733,7 @@ static const struct UnkStruct1 gUnknown_085B6388[] = .var05 = 1, .var06 = 0xFF, .var07_0 = 8, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, { @@ -743,7 +743,7 @@ static const struct UnkStruct1 gUnknown_085B6388[] = .var05 = 1, .var06 = 0xFF, .var07_0 = 8, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, { @@ -753,7 +753,7 @@ static const struct UnkStruct1 gUnknown_085B6388[] = .var05 = 10, .var06 = 0xFF, .var07_0 = 14, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, }; @@ -767,7 +767,7 @@ static const struct UnkStruct1 gUnknown_085B63F0[] = .var05 = 30, .var06 = 0xFF, .var07_0 = 14, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, { @@ -777,7 +777,7 @@ static const struct UnkStruct1 gUnknown_085B63F0[] = .var05 = 30, .var06 = 0xFF, .var07_0 = 14, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 }, { @@ -787,7 +787,7 @@ static const struct UnkStruct1 gUnknown_085B63F0[] = .var05 = 30, .var06 = 0xFF, .var07_0 = 14, - .var07_5 = 2, + .var07_5 = -2, .var07_7 = 0 } }; diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index a2a2acc8d6..7c824e82dd 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -349,7 +349,7 @@ static void VBlankCB_UpdateClockGraphics(void) gMain.oamBuffer[0] = sClockOamData; gMain.oamBuffer[0].x = 112; - gMain.oamBuffer[0].y = (CLOCK_WIN_TOP + 1) * 8;; + gMain.oamBuffer[0].y = (CLOCK_WIN_TOP + 1) * 8; if (gSaveFailedClockInfo[CLOCK_RUNNING] != FALSE) { diff --git a/src/scrcmd.c b/src/scrcmd.c index 4a7f4ea735..2a6abf17e1 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -788,8 +788,8 @@ bool8 ScrCmd_warphole(struct ScriptContext *ctx) { u8 mapGroup = ScriptReadByte(ctx); u8 mapNum = ScriptReadByte(ctx); - u16 x; - u16 y; + s16 x; + s16 y; PlayerGetDestCoords(&x, &y); if (mapGroup == 0xFF && mapNum == 0xFF) diff --git a/src/secret_base.c b/src/secret_base.c index 83626710fc..3f69e0419e 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -964,7 +964,7 @@ static void HandleRegistryMenuInput(u8 taskId) data = gTasks[taskId].data; input = ListMenu_ProcessInput(data[5]); - ListMenuGetScrollAndRow(data[5], &data[2], &data[1]); + ListMenuGetScrollAndRow(data[5], (u16 *)&data[2], (u16 *)&data[1]); switch (input) { case LIST_NOTHING_CHOSEN: @@ -1045,10 +1045,10 @@ void DeleteRegistry_Yes_Callback(u8 taskId) { s16 *data = gTasks[taskId].data; ClearDialogWindowAndFrame(0, 0); - DestroyListMenuTask(data[5], &data[2], &data[1]); + DestroyListMenuTask((u8)data[5], (u16 *)&data[2], (u16 *)&data[1]); gSaveBlock1Ptr->secretBases[data[4]].registryStatus = 0; BuildRegistryMenuItems(taskId); - sub_812225C(&data[2], &data[1], data[3], data[0]); + sub_812225C((u16 *)&data[2], (u16 *)&data[1], (u16)data[3], (u16)data[0]); FinalizeRegistryMenu(taskId); gTasks[taskId].func = HandleRegistryMenuInput; } @@ -1062,7 +1062,7 @@ static void DeleteRegistry_No(u8 taskId) { s16 *data = gTasks[taskId].data; ClearDialogWindowAndFrame(0, 0); - DestroyListMenuTask(data[5], &data[2], &data[1]); + DestroyListMenuTask((u8)data[5], (u16 *)&data[2], (u16 *)&data[1]); FinalizeRegistryMenu(taskId); gTasks[taskId].func = HandleRegistryMenuInput; } diff --git a/src/slot_machine.c b/src/slot_machine.c index 3fde76ab0a..8669b543b0 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -985,7 +985,7 @@ static void PlaySlotMachine_Internal(u8 slotMachineIndex, MainCallback exitCallb { struct Task *task = &gTasks[CreateTask(SlotMachineDummyTask, 0xFF)]; task->data[0] = slotMachineIndex; - StoreWordInTwoHalfwords(&task->data[1], (intptr_t)exitCallback); + StoreWordInTwoHalfwords((u16 *)&task->data[1], (intptr_t)exitCallback); } diff --git a/src/start_menu.c b/src/start_menu.c index 88ad364c7b..68a3161855 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -463,7 +463,7 @@ static bool32 InitStartMenuStep(void) sInitStartMenuData[0]++; break; case 4: - if (PrintStartMenuActions(&sInitStartMenuData[1], 2)) + if (PrintStartMenuActions((s8 *)&sInitStartMenuData[1], 2)) sInitStartMenuData[0]++; break; case 5: diff --git a/src/trainer_see.c b/src/trainer_see.c index 68a16e208b..93daab421d 100644 --- a/src/trainer_see.c +++ b/src/trainer_see.c @@ -603,7 +603,7 @@ static void sub_80B44C8(u8 taskId) struct ObjectEvent *objEvent; // another objEvent loaded into by loadword? - LoadWordFromTwoHalfwords(&task->data[1], (u32 *)&objEvent); + LoadWordFromTwoHalfwords((u16*)&task->data[1], (u32 *)&objEvent); if (!task->data[7]) { ObjectEventClearHeldMovement(objEvent); @@ -624,7 +624,7 @@ static void sub_80B44C8(u8 taskId) void sub_80B4578(struct ObjectEvent *var) { - StoreWordInTwoHalfwords(&gTasks[CreateTask(sub_80B44C8, 0)].data[1], (u32)var); + StoreWordInTwoHalfwords((u16 *)&gTasks[CreateTask(sub_80B44C8, 0)].data[1], (u32)var); } void EndTrainerApproach(void) diff --git a/tools/gbagfx/gfx.c b/tools/gbagfx/gfx.c index 8d959465f7..4e85953fdc 100644 --- a/tools/gbagfx/gfx.c +++ b/tools/gbagfx/gfx.c @@ -282,7 +282,7 @@ static void HflipTile(unsigned char * tile, int bitDepth) for (i = 0; i < 8; i++) { SWAP_NYBBLES(&tile[4 * i + 0], &tile[4 * i + 3]); - SWAP_NYBBLES(&tile[4 * i + 1], &tile[4 * i + 2]);; + SWAP_NYBBLES(&tile[4 * i + 1], &tile[4 * i + 2]); } break; case 8: