From 518f9c0638af5890af6bd573b2538bad462f39e5 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 11 Apr 2019 12:05:56 +0200 Subject: [PATCH] Some nonmatchings --- src/ice.c | 508 ++++----------------------- src/pokedex.c | 29 +- src/pokemon_jump.c | 59 +--- src/roulette.c | 610 ++------------------------------ src/water.c | 850 ++++++++++++--------------------------------- 5 files changed, 331 insertions(+), 1725 deletions(-) diff --git a/src/ice.c b/src/ice.c index fa1913b96..8f0c97d82 100644 --- a/src/ice.c +++ b/src/ice.c @@ -47,7 +47,7 @@ void AnimIceBallParticle(struct Sprite *); void AnimTask_Haze2(u8); void AnimTask_OverlayFogTiles(u8); void AnimTask_Hail2(u8); -bool8 GenerateHailParticle(u8, u8, u8, u8); +bool8 GenerateHailParticle(u8 hailStructId, u8 affineAnimNum, u8 taskId, u8 c); const union AnimCmd gUnknown_08595A48[] = { @@ -522,37 +522,33 @@ const struct SpriteTemplate gUnknown_08595DFC = .callback = InitIceBallParticle, }; - // probably unused -#ifdef NONMATCHING static void sub_810B6C4(struct Sprite *sprite) { s16 targetX, targetY, attackerX, attackerY; - s16 i; sprite->oam.tileNum += 7; - targetX = GetBattlerSpriteCoord(gBattleAnimTarget, 2); - targetY = GetBattlerSpriteCoord(gBattleAnimTarget, 3); - attackerX = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); - attackerY = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); + targetX = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); + targetY = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); + attackerX = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2); + attackerY = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET); sprite->data[0] = gBattleAnimArgs[4]; sprite->data[1] = gBattleAnimArgs[0] + attackerX; sprite->data[2] = gBattleAnimArgs[2] + targetX; sprite->data[3] = gBattleAnimArgs[1] + attackerY; sprite->data[4] = gBattleAnimArgs[3] + targetY; sub_80A64EC(sprite); - while ((targetX >= -32 && targetX <= 272) && (targetY >= -32 && targetY <= 192)) - { - targetX += sprite->data[1]; - targetY += sprite->data[2]; - } + + for (;(targetX >= -32 && targetX <= 272) && (targetY >= -32 && targetY <= 192); + targetX += sprite->data[1], targetY += sprite->data[2]) + ; + sprite->data[1] = -sprite->data[1]; sprite->data[2] = -sprite->data[2]; - while ((attackerX >= -32 && attackerX <= 272) && (attackerY >= -32 && attackerY <= 192)) - { - attackerX += sprite->data[1]; - attackerY += sprite->data[2]; - } + for (;(attackerX >= -32 && attackerX <= 272) && (attackerY >= -32 && attackerY <= 192); + attackerX += sprite->data[1], attackerY += sprite->data[2]) + ; + sprite->pos1.x = attackerX; sprite->pos1.y = attackerY; sprite->data[0] = gBattleAnimArgs[4]; @@ -565,195 +561,6 @@ static void sub_810B6C4(struct Sprite *sprite) sprite->data[4] = gBattleAnimArgs[6]; sprite->callback = sub_810B848; } -#else -NAKED -static void sub_810B6C4(struct Sprite *sprite) -{ - asm_unified("push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x4\n\ - adds r5, r0, 0\n\ - ldrh r2, [r5, 0x4]\n\ - lsls r1, r2, 22\n\ - lsrs r1, 22\n\ - adds r1, 0x7\n\ - ldr r3, =0x000003ff\n\ - adds r0, r3, 0\n\ - ands r1, r0\n\ - ldr r0, =0xfffffc00\n\ - ands r0, r2\n\ - orrs r0, r1\n\ - strh r0, [r5, 0x4]\n\ - ldr r4, =gBattleAnimTarget\n\ - ldrb r0, [r4]\n\ - movs r1, 0x2\n\ - bl GetBattlerSpriteCoord\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r9, r0\n\ - ldrb r0, [r4]\n\ - movs r1, 0x3\n\ - bl GetBattlerSpriteCoord\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r8, r0\n\ - ldr r4, =gBattleAnimAttacker\n\ - ldrb r0, [r4]\n\ - movs r1, 0x2\n\ - bl GetBattlerSpriteCoord\n\ - lsls r0, 24\n\ - lsrs r3, r0, 24\n\ - ldrb r0, [r4]\n\ - movs r1, 0x3\n\ - str r3, [sp]\n\ - bl GetBattlerSpriteCoord\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - ldr r1, =gBattleAnimArgs\n\ - ldrh r0, [r1, 0x8]\n\ - strh r0, [r5, 0x2E]\n\ - ldrh r0, [r1]\n\ - ldr r3, [sp]\n\ - adds r0, r3\n\ - strh r0, [r5, 0x30]\n\ - ldrh r0, [r1, 0x4]\n\ - mov r4, r9\n\ - adds r0, r4, r0\n\ - strh r0, [r5, 0x32]\n\ - ldrh r0, [r1, 0x2]\n\ - adds r0, r6\n\ - strh r0, [r5, 0x34]\n\ - ldrh r0, [r1, 0x6]\n\ - mov r7, r8\n\ - adds r0, r7, r0\n\ - strh r0, [r5, 0x36]\n\ - adds r0, r5, 0\n\ - bl sub_80A64EC\n\ - adds r4, 0x20\n\ - movs r0, 0x98\n\ - lsls r0, 1\n\ - mov r12, r0\n\ - ldr r3, [sp]\n\ - cmp r4, r12\n\ - bhi _0810B79E\n\ - adds r0, r7, 0\n\ - adds r0, 0x20\n\ - ldrh r1, [r5, 0x30]\n\ - ldrh r2, [r5, 0x32]\n\ - cmp r0, 0xE0\n\ - bhi _0810B79E\n\ - adds r4, r1, 0\n\ - mov r10, r12\n\ -_0810B76A:\n\ - mov r7, r9\n\ - lsls r1, r7, 16\n\ - asrs r1, 16\n\ - adds r1, r4\n\ - lsls r1, 16\n\ - mov r7, r8\n\ - lsls r0, r7, 16\n\ - asrs r0, 16\n\ - adds r0, r2\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - mov r8, r0\n\ - lsrs r0, r1, 16\n\ - mov r9, r0\n\ - movs r7, 0x80\n\ - lsls r7, 14\n\ - adds r1, r7\n\ - lsrs r1, 16\n\ - cmp r1, r10\n\ - bhi _0810B79E\n\ - mov r1, r8\n\ - lsls r0, r1, 16\n\ - adds r0, r7\n\ - lsrs r0, 16\n\ - cmp r0, 0xE0\n\ - bls _0810B76A\n\ -_0810B79E:\n\ - ldrh r0, [r5, 0x30]\n\ - negs r7, r0\n\ - strh r7, [r5, 0x30]\n\ - ldrh r0, [r5, 0x32]\n\ - negs r4, r0\n\ - strh r4, [r5, 0x32]\n\ - lsls r0, r3, 16\n\ - movs r1, 0x80\n\ - lsls r1, 14\n\ - adds r0, r1\n\ - lsrs r0, 16\n\ - movs r2, 0x98\n\ - lsls r2, 1\n\ - mov r12, r2\n\ - ldr r1, =gBattleAnimArgs\n\ - mov r10, r1\n\ - cmp r0, r12\n\ - bhi _0810B80A\n\ - lsls r1, r6, 16\n\ - movs r2, 0x80\n\ - lsls r2, 14\n\ - adds r0, r1, r2\n\ - b _0810B802\n\ - .pool\n\ -_0810B7E0:\n\ - lsls r1, r3, 16\n\ - asrs r1, 16\n\ - adds r1, r7\n\ - lsls r1, 16\n\ - asrs r0, r2, 16\n\ - adds r0, r4\n\ - lsls r0, 16\n\ - lsrs r6, r0, 16\n\ - lsrs r3, r1, 16\n\ - movs r0, 0x80\n\ - lsls r0, 14\n\ - adds r1, r0\n\ - lsrs r1, 16\n\ - cmp r1, r12\n\ - bhi _0810B80A\n\ - lsls r1, r6, 16\n\ - adds r0, r1, r0\n\ -_0810B802:\n\ - lsrs r0, 16\n\ - adds r2, r1, 0\n\ - cmp r0, 0xE0\n\ - bls _0810B7E0\n\ -_0810B80A:\n\ - strh r3, [r5, 0x20]\n\ - strh r6, [r5, 0x22]\n\ - mov r1, r10\n\ - ldrh r0, [r1, 0x8]\n\ - strh r0, [r5, 0x2E]\n\ - strh r3, [r5, 0x30]\n\ - mov r2, r9\n\ - strh r2, [r5, 0x32]\n\ - strh r6, [r5, 0x34]\n\ - mov r3, r8\n\ - strh r3, [r5, 0x36]\n\ - adds r0, r5, 0\n\ - bl sub_80A64EC\n\ - mov r7, r10\n\ - ldrh r0, [r7, 0xA]\n\ - strh r0, [r5, 0x34]\n\ - ldrh r0, [r7, 0xC]\n\ - strh r0, [r5, 0x36]\n\ - ldr r0, =sub_810B848\n\ - str r0, [r5, 0x1C]\n\ - add sp, 0x4\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n"); -} -#endif void sub_810B848(struct Sprite *sprite) { @@ -797,14 +604,14 @@ void AnimIcePunchSwirlingParticle(struct Sprite *sprite) void AnimIceBeamParticle(struct Sprite *sprite) { InitSpritePosToAnimAttacker(sprite, TRUE); - sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) sprite->data[2] -= gBattleAnimArgs[2]; else sprite->data[2] += gBattleAnimArgs[2]; - sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[3]; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[3]; sprite->data[0] = gBattleAnimArgs[4]; StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); sprite->callback = StartAnimLinearTranslation; @@ -863,8 +670,8 @@ void AnimSwirlingSnowball_Step1(struct Sprite *sprite) if (!gBattleAnimArgs[5]) { - sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); - sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[3]; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[3]; } else { @@ -983,8 +790,8 @@ void AnimMoveParticleBeyondTarget(struct Sprite *sprite) if (!gBattleAnimArgs[7]) { - sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); - sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3); + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); } else { @@ -1274,8 +1081,8 @@ void AnimTask_Haze2(u8 taskId) // arg 5: ??? unknown (seems to vibrate target mon somehow) void AnimThrowMistBall(struct Sprite *sprite) { - sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); - sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET); sprite->callback = TranslateAnimSpriteToTargetMonLocation; } @@ -1380,7 +1187,7 @@ void InitPoisonGasCloudAnim(struct Sprite *sprite) { sprite->data[0] = gBattleAnimArgs[0]; - if (GetBattlerSpriteCoord(gBattleAnimAttacker, 2) < GetBattlerSpriteCoord(gBattleAnimTarget, 2)) + if (GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2) < GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2)) sprite->data[7] = 0x8000; if (!(gBattlerPositions[gBattleAnimTarget] & 1)) @@ -1394,22 +1201,22 @@ void InitPoisonGasCloudAnim(struct Sprite *sprite) sprite->data[6] = 1; } - sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); - sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET); if (gBattleAnimArgs[7]) { sprite->data[1] = sprite->pos1.x + gBattleAnimArgs[1]; - sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2) + gBattleAnimArgs[3]; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) + gBattleAnimArgs[3]; sprite->data[3] = sprite->pos1.y + gBattleAnimArgs[2]; - sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[4]; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[4]; sprite->data[7] |= GetBattlerSpriteBGPriority(gBattleAnimTarget) << 8; } else { sprite->data[1] = sprite->pos1.x + gBattleAnimArgs[1]; - sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 0) + gBattleAnimArgs[3]; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X) + gBattleAnimArgs[3]; sprite->data[3] = sprite->pos1.y + gBattleAnimArgs[2]; - sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 1) + gBattleAnimArgs[4]; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y) + gBattleAnimArgs[4]; sprite->data[7] |= GetBattlerSpriteBGPriority(gBattleAnimTarget) << 8; } @@ -1441,7 +1248,7 @@ void MovePoisonGasCloud(struct Sprite *sprite) if (sprite->data[0] <= 0) { sprite->data[0] = 80; - sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, 0); + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X); sprite->data[1] = sprite->pos1.x; sprite->data[2] = sprite->pos1.x; sprite->pos1.y += sprite->pos2.y; @@ -1575,238 +1382,63 @@ void AnimTask_Hail2(u8 taskId) } } -#ifdef NONMATCHING -bool8 GenerateHailParticle(u8 a, u8 b, u8 taskId, u8 c) +bool8 GenerateHailParticle(u8 hailStructId, u8 affineAnimNum, u8 taskId, u8 c) { - bool8 possibleBool = FALSE; - // s8 unk = gUnknown_08595CB4[a].unk3; - const struct HailStruct *hailData = &gUnknown_08595CB4[a]; - s8 unk = hailData->unk3; - u8 battler; + u8 id; s16 battlerX, battlerY; - u8 spriteId; - // struct Sprite *sprite; s16 spriteX; + bool8 possibleBool = FALSE; + s8 unk = gUnknown_08595CB4[hailStructId].unk3; if (unk != 2) { - battler = GetBattlerAtPosition(hailData->unk2); - if (IsBattlerSpriteVisible(battler)) + id = GetBattlerAtPosition(gUnknown_08595CB4[hailStructId].unk2); + if (IsBattlerSpriteVisible(id)) { possibleBool = TRUE; - battlerX = GetBattlerSpriteCoord(battler, 2); - battlerY = GetBattlerSpriteCoord(battler, 3); + battlerX = GetBattlerSpriteCoord(id, BATTLER_COORD_X_2); + battlerY = GetBattlerSpriteCoord(id, BATTLER_COORD_Y_PIC_OFFSET); switch (unk) { - case 0: - battlerX -= GetBattlerSpriteCoordAttr(battler, BATTLER_COORD_ATTR_WIDTH) / 6; - battlerY -= GetBattlerSpriteCoordAttr(battler, BATTLER_COORD_ATTR_HEIGHT) / 6; - break; - case 1: - battlerX += GetBattlerSpriteCoordAttr(battler, BATTLER_COORD_ATTR_WIDTH) / 6; - battlerY += GetBattlerSpriteCoordAttr(battler, BATTLER_COORD_ATTR_HEIGHT) / 6; - break; + case 0: + battlerX -= GetBattlerSpriteCoordAttr(id, BATTLER_COORD_ATTR_WIDTH) / 6; + battlerY -= GetBattlerSpriteCoordAttr(id, BATTLER_COORD_ATTR_HEIGHT) / 6; + break; + case 1: + battlerX += GetBattlerSpriteCoordAttr(id, BATTLER_COORD_ATTR_WIDTH) / 6; + battlerY += GetBattlerSpriteCoordAttr(id, BATTLER_COORD_ATTR_HEIGHT) / 6; + break; } } + else + { + battlerX = (gUnknown_08595CB4[hailStructId].unk0); + battlerY = (gUnknown_08595CB4[hailStructId].unk1); + } } else { - battlerX = (hailData->unk0); - battlerY = (hailData->unk1); + battlerX = (gUnknown_08595CB4[hailStructId].unk0); + battlerY = (gUnknown_08595CB4[hailStructId].unk1); } spriteX = battlerX - ((battlerY + 8) / 2); - spriteId = CreateSprite(&gUnknown_08595D2C, spriteX, -8, 18); - if (spriteId == MAX_SPRITES) + id = CreateSprite(&gUnknown_08595D2C, spriteX, -8, 18); + if (id == MAX_SPRITES) + { return FALSE; - // sprite = &gSprites[spriteId]; - StartSpriteAffineAnim(&gSprites[spriteId], b); - gSprites[spriteId].data[0] = possibleBool; - gSprites[spriteId].data[3] = battlerX; - gSprites[spriteId].data[4] = battlerY; - gSprites[spriteId].data[5] = b; - gSprites[spriteId].data[6] = taskId; - gSprites[spriteId].data[7] = c; - return TRUE; + } + else + { + StartSpriteAffineAnim(&gSprites[id], affineAnimNum); + gSprites[id].data[0] = possibleBool; + gSprites[id].data[3] = battlerX; + gSprites[id].data[4] = battlerY; + gSprites[id].data[5] = affineAnimNum; + gSprites[id].data[6] = taskId; + gSprites[id].data[7] = c; + return TRUE; + } } -#else -NAKED -bool8 GenerateHailParticle(u8 a, u8 b, u8 taskId, u8 c) -{ - asm_unified("push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x8\n\ - lsls r0, 24\n\ - lsls r1, 24\n\ - lsrs r1, 24\n\ - mov r9, r1\n\ - lsls r2, 24\n\ - lsrs r2, 24\n\ - str r2, [sp]\n\ - lsls r3, 24\n\ - lsrs r3, 24\n\ - mov r10, r3\n\ - movs r1, 0\n\ - str r1, [sp, 0x4]\n\ - ldr r1, =gUnknown_08595CB4\n\ - lsrs r0, 22\n\ - adds r4, r0, r1\n\ - ldrb r0, [r4, 0x3]\n\ - lsls r0, 24\n\ - asrs r0, 28\n\ - mov r8, r0\n\ - cmp r0, 0x2\n\ - beq _0810CAD0\n\ - ldrh r0, [r4, 0x2]\n\ - lsls r0, 20\n\ - lsrs r0, 24\n\ - bl GetBattlerAtPosition\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - adds r0, r5, 0\n\ - bl IsBattlerSpriteVisible\n\ - lsls r0, 24\n\ - cmp r0, 0\n\ - beq _0810CAD0\n\ - movs r0, 0x1\n\ - str r0, [sp, 0x4]\n\ - adds r0, r5, 0\n\ - movs r1, 0x2\n\ - bl GetBattlerSpriteCoord\n\ - lsls r0, 24\n\ - lsrs r7, r0, 24\n\ - adds r0, r5, 0\n\ - movs r1, 0x3\n\ - bl GetBattlerSpriteCoord\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - mov r1, r8\n\ - cmp r1, 0\n\ - beq _0810CA60\n\ - cmp r1, 0x1\n\ - beq _0810CA96\n\ - b _0810CAE2\n\ - .pool\n\ -_0810CA60:\n\ - adds r0, r5, 0\n\ - movs r1, 0x1\n\ - bl GetBattlerSpriteCoordAttr\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - movs r1, 0x6\n\ - bl __divsi3\n\ - lsls r1, r7, 16\n\ - asrs r1, 16\n\ - subs r1, r0\n\ - lsls r1, 16\n\ - lsrs r7, r1, 16\n\ - adds r0, r5, 0\n\ - movs r1, 0\n\ - bl GetBattlerSpriteCoordAttr\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - movs r1, 0x6\n\ - bl __divsi3\n\ - lsls r1, r6, 16\n\ - asrs r1, 16\n\ - subs r1, r0\n\ - b _0810CACA\n\ -_0810CA96:\n\ - adds r0, r5, 0\n\ - movs r1, 0x1\n\ - bl GetBattlerSpriteCoordAttr\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - movs r1, 0x6\n\ - bl __divsi3\n\ - lsls r1, r7, 16\n\ - asrs r1, 16\n\ - adds r1, r0\n\ - lsls r1, 16\n\ - lsrs r7, r1, 16\n\ - adds r0, r5, 0\n\ - movs r1, 0\n\ - bl GetBattlerSpriteCoordAttr\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - movs r1, 0x6\n\ - bl __divsi3\n\ - lsls r1, r6, 16\n\ - asrs r1, 16\n\ - adds r1, r0\n\ -_0810CACA:\n\ - lsls r1, 16\n\ - lsrs r6, r1, 16\n\ - b _0810CAE2\n\ -_0810CAD0:\n\ - ldrh r0, [r4]\n\ - lsls r0, 22\n\ - asrs r0, 6\n\ - lsrs r7, r0, 16\n\ - ldr r0, [r4]\n\ - lsls r0, 12\n\ - asrs r0, 22\n\ - lsls r0, 16\n\ - lsrs r6, r0, 16\n\ -_0810CAE2:\n\ - lsls r0, r6, 16\n\ - asrs r0, 16\n\ - adds r0, 0x8\n\ - lsrs r1, r0, 31\n\ - adds r0, r1\n\ - asrs r0, 1\n\ - lsls r1, r7, 16\n\ - asrs r1, 16\n\ - subs r1, r0\n\ - ldr r0, =gUnknown_08595D2C\n\ - lsls r1, 16\n\ - asrs r1, 16\n\ - movs r2, 0x8\n\ - negs r2, r2\n\ - movs r3, 0x12\n\ - bl CreateSprite\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - cmp r5, 0x40\n\ - beq _0810CB44\n\ - lsls r4, r5, 4\n\ - adds r4, r5\n\ - lsls r4, 2\n\ - ldr r0, =gSprites\n\ - adds r4, r0\n\ - adds r0, r4, 0\n\ - mov r1, r9\n\ - bl StartSpriteAffineAnim\n\ - mov r0, sp\n\ - ldrh r0, [r0, 0x4]\n\ - strh r0, [r4, 0x2E]\n\ - strh r7, [r4, 0x34]\n\ - strh r6, [r4, 0x36]\n\ - mov r1, r9\n\ - strh r1, [r4, 0x38]\n\ - mov r0, sp\n\ - ldrh r0, [r0]\n\ - strh r0, [r4, 0x3A]\n\ - mov r1, r10\n\ - strh r1, [r4, 0x3C]\n\ - movs r0, 0x1\n\ - b _0810CB46\n\ - .pool\n\ -_0810CB44:\n\ - movs r0, 0\n\ -_0810CB46:\n\ - add sp, 0x8\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n"); -} -#endif void AnimHailBegin(struct Sprite *sprite) { @@ -1874,8 +1506,8 @@ void InitIceBallAnim(struct Sprite *sprite) if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) gBattleAnimArgs[2] = -gBattleAnimArgs[2]; - sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2) + gBattleAnimArgs[2]; - sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[3]; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) + gBattleAnimArgs[2]; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[3]; sprite->data[5] = gBattleAnimArgs[5]; InitAnimArcTranslation(sprite); diff --git a/src/pokedex.c b/src/pokedex.c index 0dae8a7b3..3343854cd 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -205,7 +205,7 @@ void blockset_load_palette_to_gpu(u8); void sub_80C01CC(struct Sprite *sprite); void sub_80C020C(u32, u32, u32, u32); void sub_80C0354(u16, u8, u8); -void sub_80C0460(u16, u8, u8); +void sub_80C0460(u16 weight, u8 left, u8 top); void sub_80C09B0(u16); u8 sub_80C0B44(u8, u16, u8, u8); void sub_80C0D30(u8, u16); @@ -3926,9 +3926,6 @@ void sub_80C020C(u32 num, u32 value, u32 c, u32 d) sub_80BE8DC(text3, GetStringCenterAlignXOffset(1, text3, 0xF0), 0x5F); } -#define CHAR_PRIME (0xB4) -#define CHAR_DOUBLE_PRIME (0xB2) - void sub_80C0354(u16 height, u8 left, u8 top) { u8 buffer[16]; @@ -3954,10 +3951,10 @@ void sub_80C0354(u16 height, u8 left, u8 top) buffer[i++] = feet / 10 + CHAR_0; buffer[i++] = (feet % 10) + CHAR_0; } - buffer[i++] = CHAR_PRIME; + buffer[i++] = CHAR_SGL_QUOT_RIGHT; buffer[i++] = (inches / 10) + CHAR_0; buffer[i++] = (inches % 10) + CHAR_0; - buffer[i++] = CHAR_DOUBLE_PRIME; + buffer[i++] = CHAR_DBL_QUOT_RIGHT; buffer[i++] = EOS; sub_80BE8DC(buffer, left, top); } @@ -3968,12 +3965,11 @@ void sub_80C0354(u16 height, u8 left, u8 top) void sub_80C0460(u16 weight, u8 left, u8 top) { u8 buffer[16]; - u32 lbs; - u8 i = 0; bool8 output; + u8 i = 0; + u32 lbs = (weight * 100000) / 4536; - lbs = (weight * 100000) / 4536; - if (lbs % 10 >= 5) + if (lbs % 10u >= 5) lbs += 10; output = FALSE; @@ -3988,9 +3984,9 @@ void sub_80C0460(u16 weight, u8 left, u8 top) i++; } - lbs = (lbs % 100000); + lbs %= 100000; buffer[i] = (lbs / 10000) + CHAR_0; - if (buffer[i] == CHAR_0 && output == FALSE) + if (buffer[i] == CHAR_0 && !output) { buffer[i++] = 0x77; } @@ -4000,9 +3996,9 @@ void sub_80C0460(u16 weight, u8 left, u8 top) i++; } - lbs = (lbs % 10000); + lbs %= 10000; buffer[i] = (lbs / 1000) + CHAR_0; - if (buffer[i] == CHAR_0 && output == FALSE) + if (buffer[i] == CHAR_0 && !output) { buffer[i++] = 0x77; } @@ -4010,9 +4006,10 @@ void sub_80C0460(u16 weight, u8 left, u8 top) { i++; } - lbs = (lbs % 1000); + + lbs %= 1000; buffer[i++] = (lbs / 100) + CHAR_0; - lbs = (lbs % 100); + lbs %= 100; buffer[i++] = CHAR_PERIOD; buffer[i++] = (lbs / 10) + CHAR_0; buffer[i++] = CHAR_SPACE; diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index 7af1d496a..8aec7bed1 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -451,11 +451,9 @@ void sub_802AA94(struct PokemonJump1 *arg0) } } -#ifdef NONMATCHING void sub_802AB20(void) { - int i; - s16 index; + int i, index; for (i = 0; i < MAX_RFU_PLAYERS; i++) { @@ -465,61 +463,6 @@ void sub_802AB20(void) gUnknown_02022CFC->unk83AC = &gUnknown_02022CFC->unk82E4[gUnknown_02022CFC->unk6]; } -#else -NAKED -void sub_802AB20(void) -{ - asm_unified("\n\ - push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - ldr r7, =gUnknown_02022CFC\n\ - movs r6, 0\n\ - movs r5, 0\n\ - ldr r0, =gPkmnJumpSpecies\n\ - mov r8, r0\n\ - movs r4, 0x4\n\ -_0802AB32:\n\ - ldr r0, [r7]\n\ - adds r0, r5\n\ - ldr r1, =0x000082a8\n\ - adds r0, r1\n\ - ldrh r0, [r0]\n\ - bl sub_802AC00\n\ - lsls r0, 16\n\ - ldr r1, [r7]\n\ - adds r1, r6\n\ - asrs r0, 14\n\ - add r0, r8\n\ - ldrh r0, [r0, 0x2]\n\ - ldr r2, =0x000082f0\n\ - adds r1, r2\n\ - strh r0, [r1]\n\ - adds r6, 0x28\n\ - adds r5, 0xC\n\ - subs r4, 0x1\n\ - cmp r4, 0\n\ - bge _0802AB32\n\ - ldr r0, =gUnknown_02022CFC\n\ - ldr r1, [r0]\n\ - ldr r0, =0x000083ac\n\ - adds r3, r1, r0\n\ - ldrb r2, [r1, 0x6]\n\ - lsls r0, r2, 2\n\ - adds r0, r2\n\ - lsls r0, 3\n\ - ldr r2, =0x000082e4\n\ - adds r0, r2\n\ - adds r1, r0\n\ - str r1, [r3]\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool"); -} -#endif // NONMATCHING static void sub_802AB98(void) { diff --git a/src/roulette.c b/src/roulette.c index 39db5630b..25c079cda 100644 --- a/src/roulette.c +++ b/src/roulette.c @@ -902,7 +902,7 @@ static void sub_8140470(void) { sub_815168C(&gUnknown_0203AB88->varB8, i, &gUnknown_085B6388[i]); } - + for (i = 0; i < PARTY_SIZE; i++) { switch (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2)) @@ -953,7 +953,7 @@ static void sub_81405CC(void) case 4: if (free_temp_tile_data_buffers_if_possible()) return; - + sub_8140470(); CopyToBgTilemapBuffer(2, gUnknown_085B5FA0, 0, 0); break; @@ -1379,8 +1379,6 @@ static u8 sub_814118C(u16 r0, u16 r1) } } -// r7/r8 swap -#ifdef NONMATCHING static void sub_8141344(u8 taskId) { u8 randf; @@ -1412,8 +1410,7 @@ static void sub_8141344(u8 taskId) g = S16TOPOSFLOAT(g) / 5.0f; gUnknown_0203AB88->var82 = g * 3; - gUnknown_0203AB88->var84 = g; - gUnknown_0203AB88->var86 = g; + gUnknown_0203AB88->var86 = gUnknown_0203AB88->var84 = g; gUnknown_0203AB88->var88 = S16TOPOSFLOAT(angles[(rand & 1) + r5]); gUnknown_0203AB88->var8C = S16TOPOSFLOAT(gUnknown_085B6348[gUnknown_0203AB88->var04_0].var18); @@ -1424,260 +1421,6 @@ static void sub_8141344(u8 taskId) gUnknown_0203AB88->varA0 = 36.0f; gTasks[taskId].func = sub_814155C; } -#else -static const u16 gUnknown_085B6422[4] = {0, 180, 90, 270}; -NAKED -static void sub_8141344(u8 taskId) -{ - asm_unified(" push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x8\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r10, r0\n\ - movs r4, 0\n\ - ldr r1, =gUnknown_085B6422\n\ - mov r0, sp\n\ - movs r2, 0x8\n\ - bl memcpy\n\ - bl Random\n\ - lsls r0, 16\n\ - lsrs r7, r0, 16\n\ - adds r0, r7, 0\n\ - movs r1, 0x64\n\ - bl __umodsi3\n\ - lsls r0, 16\n\ - lsrs r6, r0, 16\n\ - ldr r3, =gUnknown_0203AB88\n\ - ldr r0, [r3]\n\ - ldr r2, =gTasks\n\ - mov r5, r10\n\ - lsls r1, r5, 2\n\ - add r1, r10\n\ - lsls r1, 3\n\ - adds r1, r2\n\ - ldrh r2, [r1, 0x14]\n\ - adds r0, 0x7C\n\ - strb r2, [r0]\n\ - ldr r0, [r3]\n\ - adds r2, r0, 0\n\ - adds r2, 0x7F\n\ - strb r4, [r2]\n\ - subs r2, 0x1\n\ - strb r4, [r2]\n\ - adds r0, 0x7D\n\ - strb r4, [r0]\n\ - ldrh r0, [r1, 0x18]\n\ - adds r1, r7, 0\n\ - bl sub_814118C\n\ - adds r4, r0, 0\n\ - lsls r4, 24\n\ - lsrs r1, r4, 24\n\ - adds r0, r7, 0\n\ - bl __modsi3\n\ - lsrs r4, 25\n\ - subs r0, r4\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - ldr r0, =gLocalTime\n\ - ldrb r0, [r0, 0x2]\n\ - lsls r0, 24\n\ - asrs r0, 24\n\ - movs r5, 0x1\n\ - cmp r0, 0xC\n\ - bgt _081413C8\n\ - movs r5, 0\n\ -_081413C8:\n\ - cmp r6, 0x4F\n\ - bhi _081413E0\n\ - lsls r0, r5, 25\n\ - b _081413EA\n\ - .pool\n\ -_081413E0:\n\ - lsls r1, r5, 24\n\ - asrs r1, 24\n\ - movs r0, 0x1\n\ - subs r0, r1\n\ - lsls r0, 25\n\ -_081413EA:\n\ - lsrs r5, r0, 24\n\ - ldr r0, _08141530 @ =gUnknown_0203AB88\n\ - ldr r6, [r0]\n\ - ldrb r0, [r6, 0x4]\n\ - lsls r0, 30\n\ - lsrs r0, 25\n\ - ldr r1, _08141534 @ =gUnknown_085B6348\n\ - adds r0, r1\n\ - lsls r4, 24\n\ - asrs r4, 24\n\ - ldrh r0, [r0, 0x1A]\n\ - adds r4, r0\n\ - adds r0, r6, 0\n\ - adds r0, 0x80\n\ - strh r4, [r0]\n\ - lsls r4, 16\n\ - asrs r4, 16\n\ - adds r0, r4, 0\n\ - bl __floatsisf\n\ - cmp r4, 0\n\ - bge _0814141C\n\ - ldr r1, _08141538 @ =0x47800000\n\ - bl __addsf3\n\ -_0814141C:\n\ - ldr r1, _0814153C @ =0x40A00000\n\ - bl __divsf3\n\ - bl __fixunssfsi\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - lsls r0, r4, 1\n\ - adds r0, r4\n\ - movs r2, 0x82\n\ - adds r2, r6\n\ - mov r8, r2\n\ - strh r0, [r2]\n\ - adds r0, r6, 0\n\ - adds r0, 0x84\n\ - strh r4, [r0]\n\ - adds r0, 0x2\n\ - strh r4, [r0]\n\ - movs r0, 0x88\n\ - adds r0, r6\n\ - mov r9, r0\n\ - movs r0, 0x1\n\ - ands r0, r7\n\ - lsls r1, r5, 24\n\ - asrs r1, 24\n\ - adds r0, r1\n\ - lsls r0, 1\n\ - add r0, sp\n\ - movs r1, 0\n\ - ldrsh r4, [r0, r1]\n\ - adds r0, r4, 0\n\ - bl __floatsisf\n\ - cmp r4, 0\n\ - bge _08141468\n\ - ldr r1, _08141538 @ =0x47800000\n\ - bl __addsf3\n\ -_08141468:\n\ - mov r2, r9\n\ - str r0, [r2]\n\ - adds r7, r6, 0\n\ - adds r7, 0x8C\n\ - ldrb r0, [r6, 0x4]\n\ - lsls r0, 30\n\ - lsrs r0, 25\n\ - ldr r5, _08141534 @ =gUnknown_085B6348\n\ - adds r0, r5\n\ - movs r1, 0x18\n\ - ldrsh r4, [r0, r1]\n\ - adds r0, r4, 0\n\ - bl __floatsisf\n\ - adds r5, r0, 0\n\ - cmp r4, 0\n\ - bge _08141492\n\ - ldr r1, _08141538 @ =0x47800000\n\ - bl __addsf3\n\ - adds r5, r0, 0\n\ -_08141492:\n\ - str r5, [r7]\n\ - adds r7, r6, 0\n\ - adds r7, 0x90\n\ - ldr r1, _08141540 @ =0x3F000000\n\ - adds r0, r5, 0\n\ - bl __mulsf3\n\ - adds r1, r5, 0\n\ - bl __subsf3\n\ - adds r5, r0, 0\n\ - mov r2, r8\n\ - movs r0, 0\n\ - ldrsh r4, [r2, r0]\n\ - adds r0, r4, 0\n\ - bl __floatsisf\n\ - adds r2, r0, 0\n\ - cmp r4, 0\n\ - bge _081414C2\n\ - ldr r1, _08141538 @ =0x47800000\n\ - bl __addsf3\n\ - adds r2, r0, 0\n\ -_081414C2:\n\ - adds r0, r5, 0\n\ - adds r1, r2, 0\n\ - bl __divsf3\n\ - str r0, [r7]\n\ - adds r1, r6, 0\n\ - adds r1, 0x94\n\ - ldr r0, _08141544 @ =0x42880000\n\ - str r0, [r1]\n\ - adds r1, 0x8\n\ - ldr r0, _08141548 @ =0x00000000\n\ - str r0, [r1]\n\ - adds r5, r6, 0\n\ - adds r5, 0x98\n\ - mov r1, r8\n\ - movs r2, 0\n\ - ldrsh r4, [r1, r2]\n\ - adds r0, r4, 0\n\ - bl __floatsisf\n\ - adds r2, r0, 0\n\ - cmp r4, 0\n\ - bge _081414F8\n\ - ldr r1, _08141538 @ =0x47800000\n\ - bl __addsf3\n\ - adds r2, r0, 0\n\ -_081414F8:\n\ - ldr r0, _0814154C @ =0x41000000\n\ - adds r1, r2, 0\n\ - bl __divsf3\n\ - bl __negsf2\n\ - str r0, [r5]\n\ - adds r1, r6, 0\n\ - adds r1, 0xA0\n\ - ldr r0, _08141550 @ =0x42100000\n\ - str r0, [r1]\n\ - ldr r1, _08141554 @ =gTasks\n\ - mov r5, r10\n\ - lsls r0, r5, 2\n\ - add r0, r10\n\ - lsls r0, 3\n\ - adds r0, r1\n\ - ldr r1, _08141558 @ =sub_814155C\n\ - str r1, [r0]\n\ - add sp, 0x8\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_08141530:\n\ - .4byte gUnknown_0203AB88\n\ -_08141534:\n\ - .4byte gUnknown_085B6348\n\ -_08141538:\n\ - .4byte 0x47800000\n\ -_0814153C:\n\ - .4byte 0x40A00000\n\ -_08141540:\n\ - .4byte 0x3F000000\n\ -_08141544:\n\ - .4byte 0x42880000\n\ -_08141548:\n\ - .4byte 0x00000000\n\ -_0814154C:\n\ - .4byte 0x41000000\n\ -_08141550:\n\ - .4byte 0x42100000\n\ -_08141554:\n\ - .4byte gTasks\n\ -_08141558:\n\ - .4byte sub_814155C"); -} -#endif // NONMATCHING static void sub_814155C(u8 taskId) { @@ -4345,17 +4088,17 @@ static void sub_81448B8(struct Sprite *sprite) gUnknown_0203AB88->var38 = sprite; } -#ifdef NONMATCHING static void sub_8144A24(struct Sprite *sprite) { u8 z; u16 o; - u8 h = 0; // r10 (sp+0xc) - u8 j = 5; // r9 (r9) - u8 p = 0; // sp+0xc (sp+0x10) - u8 i; - u8 s[10] = {}; // sp+0 (sp+0) - u16 t = Random(); // sp+0x10 (r10) + u8 h = 0; + u8 j = 5; + u8 p = 0; + u8 i = 0; + u8 val; + u8 s[10] = {}; + u16 rand = Random(); gUnknown_0203AB88->var7D = 1; gUnknown_0203AB88->var03_5 = TRUE; @@ -4364,13 +4107,14 @@ static void sub_8144A24(struct Sprite *sprite) gUnknown_0203AB88->var88 = sprite->data[3]; gUnknown_0203AB88->var98 = 0.0f; gUnknown_0203AB88->var8C = gUnknown_085B6348[gUnknown_0203AB88->var04_0].var1C; + o = (gUnknown_0203AB88->var04_0 * 30 + 33) + (0x1 - gUnknown_0203AB88->var03_0) * 15; for (i = 0; i < 4; i++) { if (o < sprite->data[3] && sprite->data[3] <= o + 90) { sprite->data[0] = i / 2; - gUnknown_0203AB88->var03_0 = i & 1; + gUnknown_0203AB88->var03_0 = i % 2; break; } if (i == 3) @@ -4381,354 +4125,52 @@ static void sub_8144A24(struct Sprite *sprite) } o += 90; } + if (gUnknown_0203AB88->var03_0) { if (sprite->data[0]) - { PlayCry1(SPECIES_TAILLOW, -63); - } else - { PlayCry1(SPECIES_TAILLOW, 63); - } } else { PlayCry1(SPECIES_SHROOMISH, -63); } - i = 2; + + val = 2; z = (gUnknown_0203AB88->var7F + 2) % 12; + if (gUnknown_0203AB88->var03_0 == 1 && gUnknown_0203AB88->var04_0 == 1) j += 6; else - j += i; - for (; i < j; i++) + j += val; + + for (i = val; i < j; i++) { if (!(gUnknown_0203AB88->var08 & gUnknown_085B62E4[z].var04)) { s[h++] = i; - if (!p && (gUnknown_085B62E4[z].var04 & gUnknown_085B6154[gUnknown_0203AB88->var1B[gUnknown_0203AB88->var1A_0]].var00)) - { + if (p == 0 && (gUnknown_085B62E4[z].var04 & gUnknown_085B6154[gUnknown_0203AB88->var1B[gUnknown_0203AB88->var1A_0]].var0C)) p = i; - } } z = (z + 1) % 0xC; } + if ((gUnknown_0203AB88->var03_0 + 1) & gUnknown_0203AB88->var02) { - if (p && (t & 0xFF) < 0xc0) - { + if (p && (rand & 0xFF) < 0xc0) sprite->data[7] = p; - } else - { - sprite->data[7] = s[t % h]; - } + sprite->data[7] = s[rand % h]; } else { - sprite->data[7] = s[t % h]; + sprite->data[7] = s[rand % h]; } + sprite->callback = sub_8144168; } -#else -NAKED -static void sub_8144A24(struct Sprite *sprite) -{ - asm_unified("push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x14\n\ - adds r7, r0, 0\n\ - movs r0, 0\n\ - mov r9, r0\n\ - movs r1, 0x5\n\ - mov r8, r1\n\ - str r0, [sp, 0xC]\n\ - mov r0, sp\n\ - movs r1, 0\n\ - movs r2, 0xA\n\ - bl memset\n\ - bl Random\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - str r0, [sp, 0x10]\n\ - ldr r3, _08144B10 @ =gUnknown_0203AB88\n\ - ldr r0, [r3]\n\ - adds r0, 0x7D\n\ - movs r5, 0x1\n\ - strb r5, [r0]\n\ - ldr r2, [r3]\n\ - ldrb r0, [r2, 0x3]\n\ - movs r1, 0x20\n\ - orrs r0, r1\n\ - strb r0, [r2, 0x3]\n\ - ldr r2, [r3]\n\ - ldrb r1, [r2, 0x3]\n\ - movs r0, 0x41\n\ - negs r0, r0\n\ - ands r0, r1\n\ - strb r0, [r2, 0x3]\n\ - ldr r0, [r3]\n\ - adds r0, 0x7E\n\ - movs r1, 0xFF\n\ - strb r1, [r0]\n\ - ldr r6, [r3]\n\ - adds r4, r6, 0\n\ - adds r4, 0x88\n\ - movs r1, 0x34\n\ - ldrsh r0, [r7, r1]\n\ - bl __floatsisf\n\ - str r0, [r4]\n\ - adds r1, r6, 0\n\ - adds r1, 0x98\n\ - ldr r0, _08144B14 @ =0x00000000\n\ - str r0, [r1]\n\ - adds r2, r6, 0\n\ - adds r2, 0x8C\n\ - ldr r1, _08144B18 @ =gUnknown_085B6348\n\ - ldrb r0, [r6, 0x4]\n\ - lsls r0, 30\n\ - lsrs r0, 25\n\ - adds r1, 0x1C\n\ - adds r0, r1\n\ - ldr r0, [r0]\n\ - str r0, [r2]\n\ - ldrb r0, [r6, 0x4]\n\ - lsls r0, 30\n\ - lsrs r0, 30\n\ - lsls r1, r0, 4\n\ - subs r1, r0\n\ - lsls r1, 1\n\ - adds r1, 0x21\n\ - ldrb r0, [r6, 0x3]\n\ - lsls r0, 27\n\ - lsrs r0, 27\n\ - subs r5, r0\n\ - lsls r0, r5, 4\n\ - subs r0, r5\n\ - adds r1, r0\n\ - lsls r1, 16\n\ - lsrs r1, 16\n\ - mov r5, r9\n\ - movs r0, 0x34\n\ - ldrsh r2, [r7, r0]\n\ -_08144ACA:\n\ - cmp r1, r2\n\ - bge _08144AD6\n\ - adds r0, r1, 0\n\ - adds r0, 0x5A\n\ - cmp r2, r0\n\ - ble _08144B38\n\ -_08144AD6:\n\ - cmp r5, 0x3\n\ - beq _08144B1C\n\ - adds r0, r1, 0\n\ - adds r0, 0x5A\n\ - lsls r0, 16\n\ - lsrs r1, r0, 16\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - cmp r5, 0x3\n\ - bls _08144ACA\n\ -_08144AEC:\n\ - ldr r0, _08144B10 @ =gUnknown_0203AB88\n\ - ldr r0, [r0]\n\ - ldrb r1, [r0, 0x3]\n\ - movs r0, 0x1F\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _08144B64\n\ - movs r1, 0x2E\n\ - ldrsh r0, [r7, r1]\n\ - cmp r0, 0\n\ - beq _08144B58\n\ - movs r0, 0x98\n\ - lsls r0, 1\n\ - movs r1, 0x3F\n\ - negs r1, r1\n\ - bl PlayCry1\n\ - b _08144B70\n\ - .align 2, 0\n\ -_08144B10:\n\ - .4byte gUnknown_0203AB88\n\ -_08144B14:\n\ - .4byte 0x00000000\n\ -_08144B18:\n\ - .4byte gUnknown_085B6348\n\ -_08144B1C:\n\ - movs r0, 0x1\n\ - strh r0, [r7, 0x2E]\n\ - ldr r0, =gUnknown_0203AB88\n\ - ldr r2, [r0]\n\ - ldrb r1, [r2, 0x3]\n\ - movs r0, 0x20\n\ - negs r0, r0\n\ - ands r0, r1\n\ - movs r1, 0x1\n\ - orrs r0, r1\n\ - strb r0, [r2, 0x3]\n\ - b _08144AEC\n\ - .pool\n\ -_08144B38:\n\ - lsrs r0, r5, 1\n\ - strh r0, [r7, 0x2E]\n\ - ldr r0, =gUnknown_0203AB88\n\ - ldr r3, [r0]\n\ - movs r1, 0x1\n\ - ands r1, r5\n\ - ldrb r2, [r3, 0x3]\n\ - movs r0, 0x20\n\ - negs r0, r0\n\ - ands r0, r2\n\ - orrs r0, r1\n\ - strb r0, [r3, 0x3]\n\ - b _08144AEC\n\ - .pool\n\ -_08144B58:\n\ - movs r0, 0x98\n\ - lsls r0, 1\n\ - movs r1, 0x3F\n\ - bl PlayCry1\n\ - b _08144B70\n\ -_08144B64:\n\ - movs r0, 0x99\n\ - lsls r0, 1\n\ - movs r1, 0x3F\n\ - negs r1, r1\n\ - bl PlayCry1\n\ -_08144B70:\n\ - movs r0, 0x2\n\ - mov r10, r0\n\ - ldr r4, =gUnknown_0203AB88\n\ - ldr r5, [r4]\n\ - adds r0, r5, 0\n\ - adds r0, 0x7F\n\ - ldrb r0, [r0]\n\ - adds r0, 0x2\n\ - movs r1, 0xC\n\ - bl __modsi3\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - ldrb r1, [r5, 0x3]\n\ - movs r0, 0x1F\n\ - ands r0, r1\n\ - cmp r0, 0x1\n\ - bne _08144BA8\n\ - ldrb r1, [r5, 0x4]\n\ - movs r0, 0x3\n\ - ands r0, r1\n\ - cmp r0, 0x1\n\ - bne _08144BA8\n\ - mov r0, r8\n\ - adds r0, 0x6\n\ - b _08144BAC\n\ - .pool\n\ -_08144BA8:\n\ - mov r0, r8\n\ - add r0, r10\n\ -_08144BAC:\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r8, r0\n\ - mov r5, r10\n\ - cmp r5, r8\n\ - bcs _08144C18\n\ - ldr r1, =gUnknown_085B6154+0xC\n\ - mov r10, r1\n\ -_08144BBC:\n\ - ldr r3, [r4]\n\ - lsls r0, r6, 3\n\ - ldr r1, =gUnknown_085B62E4+0x4\n\ - adds r0, r1\n\ - ldr r1, [r3, 0x8]\n\ - ldr r2, [r0]\n\ - ands r1, r2\n\ - cmp r1, 0\n\ - bne _08144C02\n\ - mov r0, r9\n\ - adds r1, r0, 0x1\n\ - lsls r1, 24\n\ - lsrs r1, 24\n\ - mov r9, r1\n\ - add r0, sp\n\ - strb r5, [r0]\n\ - ldr r0, [sp, 0xC]\n\ - cmp r0, 0\n\ - bne _08144C02\n\ - ldrb r1, [r3, 0x1A]\n\ - lsls r1, 28\n\ - lsrs r1, 28\n\ - adds r0, r3, 0\n\ - adds r0, 0x1B\n\ - adds r0, r1\n\ - ldrb r1, [r0]\n\ - lsls r0, r1, 2\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - add r0, r10\n\ - ldr r0, [r0]\n\ - ands r2, r0\n\ - cmp r2, 0\n\ - beq _08144C02\n\ - str r5, [sp, 0xC]\n\ -_08144C02:\n\ - adds r0, r6, 0x1\n\ - movs r1, 0xC\n\ - bl __modsi3\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - cmp r5, r8\n\ - bcc _08144BBC\n\ -_08144C18:\n\ - ldr r0, [r4]\n\ - ldrb r1, [r0, 0x3]\n\ - lsls r1, 27\n\ - lsrs r1, 27\n\ - adds r1, 0x1\n\ - ldrb r0, [r0, 0x2]\n\ - ands r1, r0\n\ - cmp r1, 0\n\ - beq _08144C48\n\ - ldr r1, [sp, 0xC]\n\ - cmp r1, 0\n\ - beq _08144C48\n\ - movs r0, 0xFF\n\ - ldr r1, [sp, 0x10]\n\ - ands r0, r1\n\ - cmp r0, 0xBF\n\ - bhi _08144C48\n\ - mov r0, sp\n\ - ldrh r0, [r0, 0xC]\n\ - b _08144C54\n\ - .pool\n\ -_08144C48:\n\ - ldr r0, [sp, 0x10]\n\ - mov r1, r9\n\ - bl __modsi3\n\ - add r0, sp\n\ - ldrb r0, [r0]\n\ -_08144C54:\n\ - strh r0, [r7, 0x3C]\n\ - ldr r1, =sub_8144168\n\ - str r1, [r7, 0x1C]\n\ - add sp, 0x14\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool"); -} -#endif // NONMATCHING static const u16 gUnknown_085B7B1A[] = { 0x907, @@ -4955,7 +4397,7 @@ static void sub_81450D8(struct Sprite *sprite) static void sub_8145218(struct Sprite *sprite) { s8 t[2] = {-1, 1}; - + if (sprite->data[1]-- >= 0) { sprite->pos1.x += t[gUnknown_0203AB88->var38->data[0]] * 2; diff --git a/src/water.c b/src/water.c index 9aa08bf01..4480c3f43 100644 --- a/src/water.c +++ b/src/water.c @@ -1405,479 +1405,71 @@ void sub_8107CC4(u8 taskId) } } -#ifdef NONMATCHING void sub_8107D58(u8 taskId) { s16 i; struct ScanlineEffectParams params; struct Task *task = &gTasks[taskId]; - // u16 *scanlineBuffer; switch (task->data[0]) { - case 0: - for (i = 0; i < task->data[4]; i++) - { - /* scanlineBuffer = &gScanlineEffectRegBuffers[0][i]; - *(u16 *)(&gScanlineEffect) = task->data[2]; - *scanlineBuffer = task->data[2] & -1; */ - gScanlineEffectRegBuffers[1][i] = task->data[2]; - gScanlineEffectRegBuffers[0][i] = (u16)((int)(task->data[2] & 0xFFFF)); - } - for (i = task->data[4]; i < task->data[5]; i++) - { - gScanlineEffectRegBuffers[1][i] = task->data[1]; - gScanlineEffectRegBuffers[0][i] = (u16)((int)(task->data[1] & 0xFFFF)); - } - for (i = task->data[5]; i < 160; i++) - { - gScanlineEffectRegBuffers[1][i] = task->data[2]; - gScanlineEffectRegBuffers[0][i] = (u16)((int)(task->data[2] & 0xFFFF)); - } - if (task->data[4] == 0) - { - gScanlineEffectRegBuffers[1][i] = task->data[1]; - gScanlineEffectRegBuffers[0][i] = task->data[1]; - } - else - { - gScanlineEffectRegBuffers[1][i] = task->data[2]; - gScanlineEffectRegBuffers[0][i] = task->data[2]; - } - params.dmaDest = (vu16 *)REG_ADDR_BLDALPHA; - params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT; - params.initState = 1; - params.unused9 = 0; - ScanlineEffect_SetParams(params); - task->data[0]++; - break; - case 1: - if (task->data[3] == 0) - { - if (--task->data[4] <= 0) - { - task->data[4] = 0; - task->data[0]++; - } - } - else if (++task->data[5] > 111) + case 0: + for (i = 0; i < task->data[4]; i++) + gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[2]; + for (i = task->data[4]; i < task->data[5]; i++) + gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[1]; + for (i = task->data[5]; i < 160; i++) + gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[2]; + + if (task->data[4] == 0) + gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[1]; + else + gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[2]; + + params.dmaDest = (vu16 *)REG_ADDR_BLDALPHA; + params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT; + params.initState = 1; + params.unused9 = 0; + ScanlineEffect_SetParams(params); + task->data[0]++; + break; + case 1: + if (task->data[3] == 0) + { + if (--task->data[4] <= 0) { + task->data[4] = 0; task->data[0]++; } - for (i = 0; i < task->data[4]; i++) - { - gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; - } - for (i = task->data[4]; i < task->data[5]; i++) - { - gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[1]; - } - for (i = task->data[5]; i < 160; i++) - { - gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; - } - break; - case 2: - for (i = 0; i < task->data[4]; i++) - { - gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; - } - for (i = task->data[4]; i < task->data[5]; i++) - { - gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[1]; - } - for (i = task->data[5]; i < 160; i++) - { - gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; - } - if (task->data[15] == -1) - { - ScanlineEffect_Stop(); - DestroyTask(taskId); - } - break; + } + else if (++task->data[5] > 111) + { + task->data[0]++; + } + + for (i = 0; i < task->data[4]; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; + for (i = task->data[4]; i < task->data[5]; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[1]; + for (i = task->data[5]; i < 160; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; + break; + case 2: + for (i = 0; i < task->data[4]; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; + for (i = task->data[4]; i < task->data[5]; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[1]; + for (i = task->data[5]; i < 160; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; + + if (task->data[15] == -1) + { + ScanlineEffect_Stop(); + DestroyTask(taskId); + } + break; } } -#else -NAKED -void sub_8107D58(u8 taskId) -{ - asm_unified("push {r4-r7,lr}\n\ - sub sp, 0xC\n\ - lsls r0, 24\n\ - lsrs r7, r0, 24\n\ - lsls r0, r7, 2\n\ - adds r0, r7\n\ - lsls r0, 3\n\ - ldr r1, =gTasks\n\ - adds r4, r0, r1\n\ - movs r1, 0x8\n\ - ldrsh r0, [r4, r1]\n\ - cmp r0, 0x1\n\ - bne _08107D74\n\ - b _08107EAC\n\ -_08107D74:\n\ - cmp r0, 0x1\n\ - bgt _08107D84\n\ - cmp r0, 0\n\ - beq _08107D8C\n\ - b _08108022\n\ - .pool\n\ -_08107D84:\n\ - cmp r0, 0x2\n\ - bne _08107D8A\n\ - b _08107F78\n\ -_08107D8A:\n\ - b _08108022\n\ -_08107D8C:\n\ - movs r3, 0\n\ - movs r2, 0x10\n\ - ldrsh r0, [r4, r2]\n\ - ldr r1, =gScanlineEffectRegBuffers\n\ - mov r12, r1\n\ - cmp r3, r0\n\ - bge _08107DCA\n\ - mov r7, r12\n\ - movs r5, 0xF0\n\ - lsls r5, 3\n\ - add r5, r12\n\ - ldr r6, =0x0000ffff\n\ -_08107DA4:\n\ - lsls r2, r3, 16\n\ - asrs r2, 16\n\ - lsls r1, r2, 1\n\ - adds r3, r1, r7\n\ - adds r1, r5\n\ - ldrh r0, [r4, 0xC]\n\ - strh r0, [r1]\n\ - ldrh r1, [r4, 0xC]\n\ - adds r0, r6, 0\n\ - ands r0, r1\n\ - strh r0, [r3]\n\ - adds r2, 0x1\n\ - lsls r2, 16\n\ - lsrs r3, r2, 16\n\ - asrs r2, 16\n\ - movs r1, 0x10\n\ - ldrsh r0, [r4, r1]\n\ - cmp r2, r0\n\ - blt _08107DA4\n\ -_08107DCA:\n\ - ldrh r3, [r4, 0x10]\n\ - lsls r2, r3, 16\n\ - asrs r1, r2, 16\n\ - movs r3, 0x12\n\ - ldrsh r0, [r4, r3]\n\ - cmp r1, r0\n\ - bge _08107E04\n\ - ldr r5, =gScanlineEffectRegBuffers\n\ - movs r0, 0xF0\n\ - lsls r0, 3\n\ - adds r6, r5, r0\n\ - ldr r7, =0x0000ffff\n\ -_08107DE2:\n\ - asrs r2, 16\n\ - lsls r1, r2, 1\n\ - adds r3, r1, r5\n\ - adds r1, r6\n\ - ldrh r0, [r4, 0xA]\n\ - strh r0, [r1]\n\ - ldrh r1, [r4, 0xA]\n\ - adds r0, r7, 0\n\ - ands r0, r1\n\ - strh r0, [r3]\n\ - adds r2, 0x1\n\ - lsls r2, 16\n\ - asrs r1, r2, 16\n\ - movs r3, 0x12\n\ - ldrsh r0, [r4, r3]\n\ - cmp r1, r0\n\ - blt _08107DE2\n\ -_08107E04:\n\ - ldrh r3, [r4, 0x12]\n\ - lsls r2, r3, 16\n\ - asrs r0, r2, 16\n\ - cmp r0, 0x9F\n\ - bgt _08107E3A\n\ - ldr r5, =gScanlineEffectRegBuffers\n\ - movs r0, 0xF0\n\ - lsls r0, 3\n\ - adds r6, r5, r0\n\ - ldr r7, =0x0000ffff\n\ -_08107E18:\n\ - asrs r2, 16\n\ - lsls r1, r2, 1\n\ - adds r3, r1, r5\n\ - adds r1, r6\n\ - ldrh r0, [r4, 0xC]\n\ - strh r0, [r1]\n\ - ldrh r1, [r4, 0xC]\n\ - adds r0, r7, 0\n\ - ands r0, r1\n\ - strh r0, [r3]\n\ - adds r2, 0x1\n\ - lsls r2, 16\n\ - lsrs r3, r2, 16\n\ - lsls r2, r3, 16\n\ - asrs r0, r2, 16\n\ - cmp r0, 0x9F\n\ - ble _08107E18\n\ -_08107E3A:\n\ - movs r1, 0x10\n\ - ldrsh r0, [r4, r1]\n\ - cmp r0, 0\n\ - bne _08107E64\n\ - lsls r0, r3, 16\n\ - asrs r0, 15\n\ - mov r3, r12\n\ - adds r2, r0, r3\n\ - movs r1, 0xF0\n\ - lsls r1, 3\n\ - add r1, r12\n\ - adds r0, r1\n\ - ldrh r1, [r4, 0xA]\n\ - strh r1, [r0]\n\ - ldrh r0, [r4, 0xA]\n\ - b _08107E7A\n\ - .pool\n\ -_08107E64:\n\ - lsls r0, r3, 16\n\ - asrs r0, 15\n\ - mov r1, r12\n\ - adds r2, r0, r1\n\ - movs r1, 0xF0\n\ - lsls r1, 3\n\ - add r1, r12\n\ - adds r0, r1\n\ - ldrh r1, [r4, 0xC]\n\ - strh r1, [r0]\n\ - ldrh r0, [r4, 0xC]\n\ -_08107E7A:\n\ - strh r0, [r2]\n\ - ldr r0, =0x04000052\n\ - str r0, [sp]\n\ - ldr r0, =0xa2600001\n\ - str r0, [sp, 0x4]\n\ - mov r1, sp\n\ - movs r2, 0\n\ - movs r0, 0x1\n\ - strb r0, [r1, 0x8]\n\ - mov r0, sp\n\ - strb r2, [r0, 0x9]\n\ - ldr r0, [sp]\n\ - ldr r1, [sp, 0x4]\n\ - ldr r2, [sp, 0x8]\n\ - bl ScanlineEffect_SetParams\n\ - ldrh r0, [r4, 0x8]\n\ - adds r0, 0x1\n\ - strh r0, [r4, 0x8]\n\ - b _08108022\n\ - .pool\n\ -_08107EAC:\n\ - movs r2, 0xE\n\ - ldrsh r1, [r4, r2]\n\ - cmp r1, 0\n\ - bne _08107EC4\n\ - ldrh r0, [r4, 0x10]\n\ - subs r0, 0x1\n\ - strh r0, [r4, 0x10]\n\ - lsls r0, 16\n\ - cmp r0, 0\n\ - bgt _08107ED8\n\ - strh r1, [r4, 0x10]\n\ - b _08107ED2\n\ -_08107EC4:\n\ - ldrh r0, [r4, 0x12]\n\ - adds r0, 0x1\n\ - strh r0, [r4, 0x12]\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - cmp r0, 0x6F\n\ - ble _08107ED8\n\ -_08107ED2:\n\ - ldrh r0, [r4, 0x8]\n\ - adds r0, 0x1\n\ - strh r0, [r4, 0x8]\n\ -_08107ED8:\n\ - movs r3, 0\n\ - movs r1, 0x10\n\ - ldrsh r0, [r4, r1]\n\ - cmp r3, r0\n\ - bge _08107F0C\n\ - ldr r6, =gScanlineEffectRegBuffers\n\ - ldr r5, =gScanlineEffect\n\ -_08107EE6:\n\ - lsls r1, r3, 16\n\ - asrs r1, 16\n\ - lsls r3, r1, 1\n\ - ldrb r2, [r5, 0x14]\n\ - lsls r0, r2, 4\n\ - subs r0, r2\n\ - lsls r0, 7\n\ - adds r3, r0\n\ - adds r3, r6\n\ - ldrh r0, [r4, 0xC]\n\ - strh r0, [r3]\n\ - adds r1, 0x1\n\ - lsls r1, 16\n\ - lsrs r3, r1, 16\n\ - asrs r1, 16\n\ - movs r2, 0x10\n\ - ldrsh r0, [r4, r2]\n\ - cmp r1, r0\n\ - blt _08107EE6\n\ -_08107F0C:\n\ - ldrh r3, [r4, 0x10]\n\ - lsls r2, r3, 16\n\ - asrs r1, r2, 16\n\ - movs r3, 0x12\n\ - ldrsh r0, [r4, r3]\n\ - cmp r1, r0\n\ - bge _08107F40\n\ - ldr r6, =gScanlineEffectRegBuffers\n\ - ldr r5, =gScanlineEffect\n\ -_08107F1E:\n\ - asrs r3, r2, 16\n\ - lsls r2, r3, 1\n\ - ldrb r1, [r5, 0x14]\n\ - lsls r0, r1, 4\n\ - subs r0, r1\n\ - lsls r0, 7\n\ - adds r2, r0\n\ - adds r2, r6\n\ - ldrh r0, [r4, 0xA]\n\ - strh r0, [r2]\n\ - adds r3, 0x1\n\ - lsls r2, r3, 16\n\ - asrs r1, r2, 16\n\ - movs r3, 0x12\n\ - ldrsh r0, [r4, r3]\n\ - cmp r1, r0\n\ - blt _08107F1E\n\ -_08107F40:\n\ - ldrh r3, [r4, 0x12]\n\ - lsls r1, r3, 16\n\ - asrs r0, r1, 16\n\ - cmp r0, 0x9F\n\ - bgt _08108022\n\ - ldr r6, =gScanlineEffectRegBuffers\n\ - ldr r5, =gScanlineEffect\n\ -_08107F4E:\n\ - asrs r3, r1, 16\n\ - lsls r2, r3, 1\n\ - ldrb r1, [r5, 0x14]\n\ - lsls r0, r1, 4\n\ - subs r0, r1\n\ - lsls r0, 7\n\ - adds r2, r0\n\ - adds r2, r6\n\ - ldrh r0, [r4, 0xC]\n\ - strh r0, [r2]\n\ - adds r3, 0x1\n\ - lsls r1, r3, 16\n\ - asrs r0, r1, 16\n\ - cmp r0, 0x9F\n\ - ble _08107F4E\n\ - b _08108022\n\ - .pool\n\ -_08107F78:\n\ - movs r3, 0\n\ - movs r1, 0x10\n\ - ldrsh r0, [r4, r1]\n\ - cmp r3, r0\n\ - bge _08107FAC\n\ - ldr r6, =gScanlineEffectRegBuffers\n\ - ldr r5, =gScanlineEffect\n\ -_08107F86:\n\ - lsls r1, r3, 16\n\ - asrs r1, 16\n\ - lsls r3, r1, 1\n\ - ldrb r2, [r5, 0x14]\n\ - lsls r0, r2, 4\n\ - subs r0, r2\n\ - lsls r0, 7\n\ - adds r3, r0\n\ - adds r3, r6\n\ - ldrh r0, [r4, 0xC]\n\ - strh r0, [r3]\n\ - adds r1, 0x1\n\ - lsls r1, 16\n\ - lsrs r3, r1, 16\n\ - asrs r1, 16\n\ - movs r2, 0x10\n\ - ldrsh r0, [r4, r2]\n\ - cmp r1, r0\n\ - blt _08107F86\n\ -_08107FAC:\n\ - ldrh r3, [r4, 0x10]\n\ - lsls r2, r3, 16\n\ - asrs r1, r2, 16\n\ - movs r3, 0x12\n\ - ldrsh r0, [r4, r3]\n\ - cmp r1, r0\n\ - bge _08107FE0\n\ - ldr r6, =gScanlineEffectRegBuffers\n\ - ldr r5, =gScanlineEffect\n\ -_08107FBE:\n\ - asrs r3, r2, 16\n\ - lsls r2, r3, 1\n\ - ldrb r1, [r5, 0x14]\n\ - lsls r0, r1, 4\n\ - subs r0, r1\n\ - lsls r0, 7\n\ - adds r2, r0\n\ - adds r2, r6\n\ - ldrh r0, [r4, 0xA]\n\ - strh r0, [r2]\n\ - adds r3, 0x1\n\ - lsls r2, r3, 16\n\ - asrs r1, r2, 16\n\ - movs r3, 0x12\n\ - ldrsh r0, [r4, r3]\n\ - cmp r1, r0\n\ - blt _08107FBE\n\ -_08107FE0:\n\ - ldrh r3, [r4, 0x12]\n\ - lsls r1, r3, 16\n\ - asrs r0, r1, 16\n\ - cmp r0, 0x9F\n\ - bgt _0810800C\n\ - ldr r6, =gScanlineEffectRegBuffers\n\ - ldr r5, =gScanlineEffect\n\ -_08107FEE:\n\ - asrs r3, r1, 16\n\ - lsls r2, r3, 1\n\ - ldrb r1, [r5, 0x14]\n\ - lsls r0, r1, 4\n\ - subs r0, r1\n\ - lsls r0, 7\n\ - adds r2, r0\n\ - adds r2, r6\n\ - ldrh r0, [r4, 0xC]\n\ - strh r0, [r2]\n\ - adds r3, 0x1\n\ - lsls r1, r3, 16\n\ - asrs r0, r1, 16\n\ - cmp r0, 0x9F\n\ - ble _08107FEE\n\ -_0810800C:\n\ - movs r0, 0x26\n\ - ldrsh r1, [r4, r0]\n\ - movs r0, 0x1\n\ - negs r0, r0\n\ - cmp r1, r0\n\ - bne _08108022\n\ - bl ScanlineEffect_Stop\n\ - adds r0, r7, 0\n\ - bl DestroyTask\n\ -_08108022:\n\ - add sp, 0xC\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n"); -} -#endif void sub_8108034(struct Sprite *sprite) { @@ -1925,82 +1517,82 @@ void sub_8108140(u8 taskId) switch (task->data[0]) { - case 0: - sub_80A805C(task, task->data[15], 0x100, 0x100, 224, 0x200, 32); + case 0: + sub_80A805C(task, task->data[15], 0x100, 0x100, 224, 0x200, 32); + task->data[0]++; + case 1: + if (++task->data[3] > 1) + { + task->data[3] = 0; + if (++task->data[4] & 1) + { + gSprites[task->data[15]].pos2.x = 3; + gSprites[task->data[15]].pos1.y++; + } + else + { + gSprites[task->data[15]].pos2.x = -3; + } + } + if (sub_80A80C8(task) == 0) + { + SetBattlerSpriteYOffsetFromYScale(task->data[15]); + gSprites[task->data[15]].pos2.x = 0; + task->data[3] = 0; + task->data[4] = 0; task->data[0]++; - case 1: - if (++task->data[3] > 1) - { - task->data[3] = 0; - if (++task->data[4] & 1) - { - gSprites[task->data[15]].pos2.x = 3; - gSprites[task->data[15]].pos1.y++; - } - else - { - gSprites[task->data[15]].pos2.x = -3; - } - } - if (sub_80A80C8(task) == 0) - { - SetBattlerSpriteYOffsetFromYScale(task->data[15]); - gSprites[task->data[15]].pos2.x = 0; - task->data[3] = 0; - task->data[4] = 0; - task->data[0]++; - } - break; - case 2: - if (++task->data[3] > 4) - { - sub_80A805C(task, task->data[15], 224, 0x200, 384, 224, 8); - task->data[3] = 0; - task->data[0]++; - } - break; - case 3: - if (sub_80A80C8(task) == 0) - { - task->data[3] = 0; - task->data[4] = 0; - task->data[0]++; - } - break; - case 4: - sub_8108408(task, taskId); + } + break; + case 2: + if (++task->data[3] > 4) + { + sub_80A805C(task, task->data[15], 224, 0x200, 384, 224, 8); + task->data[3] = 0; task->data[0]++; - case 5: - if (++task->data[3] > 1) + } + break; + case 3: + if (sub_80A80C8(task) == 0) + { + task->data[3] = 0; + task->data[4] = 0; + task->data[0]++; + } + break; + case 4: + sub_8108408(task, taskId); + task->data[0]++; + case 5: + if (++task->data[3] > 1) + { + task->data[3] = 0; + if (++task->data[4] & 1) + gSprites[task->data[15]].pos2.y += 2; + else + gSprites[task->data[15]].pos2.y -= 2; + if (task->data[4] == 10) { + sub_80A805C(task, task->data[15], 384, 224, 0x100, 0x100, 8); task->data[3] = 0; - if (++task->data[4] & 1) - gSprites[task->data[15]].pos2.y += 2; - else - gSprites[task->data[15]].pos2.y -= 2; - if (task->data[4] == 10) - { - sub_80A805C(task, task->data[15], 384, 224, 0x100, 0x100, 8); - task->data[3] = 0; - task->data[4] = 0; - task->data[0]++; - } - } - break; - case 6: - gSprites[task->data[15]].pos1.y--; - if (sub_80A80C8(task) == 0) - { - ResetSpriteRotScale(task->data[15]); - gSprites[task->data[15]].pos1.y = task->data[5]; task->data[4] = 0; task->data[0]++; } - break; - case 7: - if (task->data[2] == 0) - DestroyAnimVisualTask(taskId); - break; + } + break; + case 6: + gSprites[task->data[15]].pos1.y--; + if (sub_80A80C8(task) == 0) + { + ResetSpriteRotScale(task->data[15]); + gSprites[task->data[15]].pos1.y = task->data[5]; + task->data[4] = 0; + task->data[0]++; + } + break; + case 7: + if (task->data[2] == 0) + DestroyAnimVisualTask(taskId); + break; } } @@ -2073,21 +1665,21 @@ void sub_810851C(struct Sprite *sprite) { switch (sprite->data[0]) { - case 0: - sprite->data[4] += (sprite->data[1] % 6) * 3; - sprite->data[5] += (sprite->data[1] % 3) * 3; - sprite->data[0]++; - case 1: - sprite->data[2] += sprite->data[4]; - sprite->data[3] += sprite->data[5]; - sprite->pos1.x = sprite->data[2] >> 4; - sprite->pos1.y = sprite->data[3] >> 4; - if (sprite->pos1.x < -8 || sprite->pos1.x > 248 || sprite->pos1.y < -8 || sprite->pos1.y > 120) - { - gTasks[sprite->data[6]].data[sprite->data[7]]--; - DestroySprite(sprite); - } - break; + case 0: + sprite->data[4] += (sprite->data[1] % 6) * 3; + sprite->data[5] += (sprite->data[1] % 3) * 3; + sprite->data[0]++; + case 1: + sprite->data[2] += sprite->data[4]; + sprite->data[3] += sprite->data[5]; + sprite->pos1.x = sprite->data[2] >> 4; + sprite->pos1.y = sprite->data[3] >> 4; + if (sprite->pos1.x < -8 || sprite->pos1.x > 248 || sprite->pos1.y < -8 || sprite->pos1.y > 120) + { + gTasks[sprite->data[6]].data[sprite->data[7]]--; + DestroySprite(sprite); + } + break; } } @@ -2119,39 +1711,39 @@ void sub_810862C(u8 taskId) switch (task->data[0]) { - case 0: - if (++task->data[2] > 2) + case 0: + if (++task->data[2] > 2) + { + task->data[2] = 0; + sub_810871C(task, taskId); + } + if (task->data[10] != 0 && task->data[13] == 0) + { + gBattleAnimArgs[0] = 1; + gBattleAnimArgs[1] = 0; + gBattleAnimArgs[2] = 12; + taskId2 = CreateTask(sub_81152DC, 80); + if (taskId2 != 0xFF) { - task->data[2] = 0; - sub_810871C(task, taskId); + gTasks[taskId2].func(taskId2); + gAnimVisualTaskCount++; } - if (task->data[10] != 0 && task->data[13] == 0) + gBattleAnimArgs[0] = 3; + taskId2 = CreateTask(sub_81152DC, 80); + if (taskId2 != 0xFF) { - gBattleAnimArgs[0] = 1; - gBattleAnimArgs[1] = 0; - gBattleAnimArgs[2] = 12; - taskId2 = CreateTask(sub_81152DC, 80); - if (taskId2 != 0xFF) - { - gTasks[taskId2].func(taskId2); - gAnimVisualTaskCount++; - } - gBattleAnimArgs[0] = 3; - taskId2 = CreateTask(sub_81152DC, 80); - if (taskId2 != 0xFF) - { - gTasks[taskId2].func(taskId2); - gAnimVisualTaskCount++; - } - task->data[13] = 1; + gTasks[taskId2].func(taskId2); + gAnimVisualTaskCount++; } - if (task->data[11] >= task->data[12]) - task->data[0]++; - break; - case 1: - if (task->data[9] == 0) - DestroyAnimVisualTask(taskId); - break; + task->data[13] = 1; + } + if (task->data[11] >= task->data[12]) + task->data[0]++; + break; + case 1: + if (task->data[9] == 0) + DestroyAnimVisualTask(taskId); + break; } } @@ -2232,66 +1824,66 @@ void sub_8108978(u8 taskId) switch (task->data[0]) { - case 0: - sub_8108AC0(task); - if (task->data[10] != 0) - task->data[0]++; - break; - case 1: - sub_8108AC0(task); - if (++task->data[1] > 16) + case 0: + sub_8108AC0(task); + if (task->data[10] != 0) + task->data[0]++; + break; + case 1: + sub_8108AC0(task); + if (++task->data[1] > 16) + { + task->data[1] = 0; + task->data[0]++; + } + break; + case 2: + sub_8108AC0(task); + task->data[5] += task->data[7] * 6; + if (!(task->data[5] >= -16 && task->data[5] <= 256)) + { + if (++task->data[12] > 2) + { + task->data[13] = 1; + task->data[0] = 6; + task->data[1] = 0; + } + else { task->data[1] = 0; task->data[0]++; } - break; - case 2: - sub_8108AC0(task); - task->data[5] += task->data[7] * 6; - if (!(task->data[5] >= -16 && task->data[5] <= 256)) - { - if (++task->data[12] > 2) - { - task->data[13] = 1; - task->data[0] = 6; - task->data[1] = 0; - } - else - { - task->data[1] = 0; - task->data[0]++; - } - } - break; - case 3: - sub_8108AC0(task); - task->data[6] -= task->data[7] * 2; - if (++task->data[1] > 7) - task->data[0]++; - break; - case 4: - sub_8108AC0(task); - task->data[5] -= task->data[7] * 6; - if (!(task->data[5] >= -16 && task->data[5] <= 256)) - { - task->data[12]++; - task->data[1] = 0; - task->data[0]++; - } - break; - case 5: - sub_8108AC0(task); - task->data[6] -= task->data[7] * 2; - if (++task->data[1] > 7) - task->data[0] = 2; - break; - case 6: - if (task->data[8] == 0) - task->data[0]++; - break; - default: - DestroyAnimVisualTask(taskId); - break; + } + break; + case 3: + sub_8108AC0(task); + task->data[6] -= task->data[7] * 2; + if (++task->data[1] > 7) + task->data[0]++; + break; + case 4: + sub_8108AC0(task); + task->data[5] -= task->data[7] * 6; + if (!(task->data[5] >= -16 && task->data[5] <= 256)) + { + task->data[12]++; + task->data[1] = 0; + task->data[0]++; + } + break; + case 5: + sub_8108AC0(task); + task->data[6] -= task->data[7] * 2; + if (++task->data[1] > 7) + task->data[0] = 2; + break; + case 6: + if (task->data[8] == 0) + task->data[0]++; + break; + default: + DestroyAnimVisualTask(taskId); + break; } }