diff --git a/asm/battle_1.s b/asm/battle_1.s index d57f91d37..416fd87ec 100644 --- a/asm/battle_1.s +++ b/asm/battle_1.s @@ -1358,8 +1358,8 @@ _080356AA: .pool thumb_func_end trs_config - thumb_func_start c2_berry_program_update_menu -c2_berry_program_update_menu: @ 80356D0 + thumb_func_start sub_80356D0 +sub_80356D0: @ 80356D0 push {lr} movs r0, 0x2 bl DisableInterrupts @@ -1381,10 +1381,10 @@ c2_berry_program_update_menu: @ 80356D0 pop {r0} bx r0 .pool - thumb_func_end c2_berry_program_update_menu + thumb_func_end sub_80356D0 - thumb_func_start sub_803570C -sub_803570C: @ 803570C + thumb_func_start ApplyPlayerChosenFrameToBattleMenu +ApplyPlayerChosenFrameToBattleMenu: @ 803570C push {lr} movs r0, 0x2 movs r1, 0x12 @@ -1422,7 +1422,7 @@ _0803575A: pop {r0} bx r0 .pool - thumb_func_end sub_803570C + thumb_func_end ApplyPlayerChosenFrameToBattleMenu thumb_func_start load_battle_oval_graphics load_battle_oval_graphics: @ 8035770 @@ -1667,8 +1667,8 @@ _08035A8A: .pool thumb_func_end load_battle_oval_graphics - thumb_func_start sub_8035AA4 -sub_8035AA4: @ 8035AA4 + thumb_func_start LoadBattleTextboxAndBackground +LoadBattleTextboxAndBackground: @ 8035AA4 push {lr} ldr r0, =gUnknown_08C00000 movs r1, 0xC0 @@ -1685,12 +1685,12 @@ sub_8035AA4: @ 8035AA4 movs r1, 0 movs r2, 0x40 bl LoadCompressedPalette - bl sub_803570C + bl ApplyPlayerChosenFrameToBattleMenu bl load_battle_oval_graphics pop {r0} bx r0 .pool - thumb_func_end sub_8035AA4 + thumb_func_end LoadBattleTextboxAndBackground thumb_func_start sub_8035AE4 sub_8035AE4: @ 8035AE4 @@ -2457,8 +2457,8 @@ _08036138: .pool thumb_func_end task00_0800F6FC - thumb_func_start sub_8036154 -sub_8036154: @ 8036154 + thumb_func_start LoadBattleEntryBackground +LoadBattleEntryBackground: @ 8036154 push {r4,r5,lr} ldr r0, =gBattleTypeFlags ldr r1, [r0] @@ -2668,10 +2668,10 @@ _080363AC: pop {r0} bx r0 .pool - thumb_func_end sub_8036154 + thumb_func_end LoadBattleEntryBackground - thumb_func_start sub_80363C4 -sub_80363C4: @ 80363C4 + thumb_func_start LoadChosenBattleElement +LoadChosenBattleElement: @ 80363C4 push {r4,lr} lsls r0, 24 lsrs r0, 24 @@ -3051,7 +3051,7 @@ _08036742: b _08036758 .pool _08036750: - bl sub_803570C + bl ApplyPlayerChosenFrameToBattleMenu b _08036758 _08036756: movs r4, 0x1 @@ -3060,6 +3060,6 @@ _08036758: pop {r4} pop {r1} bx r1 - thumb_func_end sub_80363C4 + thumb_func_end LoadChosenBattleElement .align 2, 0 @ Don't pad with nop. diff --git a/asm/battle_2.s b/asm/battle_2.s deleted file mode 100644 index 996579313..000000000 --- a/asm/battle_2.s +++ /dev/null @@ -1,16487 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - thumb_func_start sub_8036760 -sub_8036760: @ 8036760 - push {lr} - bl MoveSaveBlocks_ResetHeap - bl sub_8056F28 - bl dp11_init - bl init_uns_table_pokemon_copy - bl sub_8185F84 - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _080367CC - movs r0, 0x80 - lsls r0, 17 - ands r0, r1 - cmp r0, 0 - beq _08036798 - bl InitBattle - b _080367BA - .pool -_08036798: - movs r0, 0x80 - lsls r0, 15 - ands r1, r0 - cmp r1, 0 - bne _080367B4 - bl battle_wireless_setup_if_required_maybe - ldr r0, =sub_8037ADC - bl SetMainCallback2 - b _080367BA - .pool -_080367B4: - ldr r0, =intro_end - bl SetMainCallback2 -_080367BA: - ldr r1, =gBattleCommunication - movs r0, 0 - strb r0, [r1] - b _080367D0 - .pool -_080367CC: - bl InitBattle -_080367D0: - pop {r0} - bx r0 - thumb_func_end sub_8036760 - - thumb_func_start InitBattle -InitBattle: @ 80367D4 - push {r4,r5,lr} - sub sp, 0x4 - movs r0, 0 - bl SetHBlankCallback - movs r0, 0 - bl SetVBlankCallback - movs r0, 0 - str r0, [sp] - movs r1, 0xC0 - lsls r1, 19 - ldr r2, =0x05006000 - mov r0, sp - bl CpuSet - movs r0, 0x4C - movs r1, 0 - bl SetGpuReg - movs r0, 0x40 - movs r1, 0xF0 - bl SetGpuReg - ldr r1, =0x00005051 - movs r0, 0x44 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0 - bl SetGpuReg - movs r0, 0x4A - movs r1, 0 - bl SetGpuReg - ldr r0, =gUnknown_02022E24 - movs r2, 0xF0 - strh r2, [r0] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 15 - ands r0, r1 - cmp r0, 0 - beq _08036870 - ldr r0, =gPartnerTrainerId - ldrh r1, [r0] - ldr r0, =0x00000c03 - cmp r1, r0 - beq _08036870 - ldr r1, =gUnknown_02022E26 - movs r0, 0x9F - strh r0, [r1] - ldr r0, =gUnknown_02022E28 - strh r2, [r0] - ldr r1, =gUnknown_02022E2A - movs r0, 0x20 - strh r0, [r1] - b _080368BE - .pool -_08036870: - ldr r0, =gUnknown_02022E26 - ldr r2, =0x00005051 - adds r1, r2, 0 - strh r1, [r0] - bl dp12_8087EA4 - ldr r0, =gUnknown_02038C28 - movs r3, 0xF0 - movs r5, 0xF0 - lsls r5, 3 - adds r2, r0, r5 - movs r1, 0x4F -_08036888: - strh r3, [r0] - strh r3, [r2] - adds r2, 0x2 - adds r0, 0x2 - subs r1, 0x1 - cmp r1, 0 - bge _08036888 - movs r1, 0x50 - ldr r4, =gUnknown_0831AC70 - ldr r0, =gUnknown_02038C28 - ldr r3, =0x0000ff10 - movs r5, 0x82 - lsls r5, 4 - adds r2, r0, r5 - adds r0, 0xA0 -_080368A6: - strh r3, [r0] - strh r3, [r2] - adds r2, 0x2 - adds r0, 0x2 - adds r1, 0x1 - cmp r1, 0x9F - ble _080368A6 - ldr r0, [r4] - ldr r1, [r4, 0x4] - ldr r2, [r4, 0x8] - bl sub_80BA038 -_080368BE: - bl ResetPaletteFade - ldr r0, =gUnknown_02022E14 - movs r1, 0 - strh r1, [r0] - ldr r0, =gUnknown_02022E16 - strh r1, [r0] - ldr r0, =gBattle_BG1_X - strh r1, [r0] - ldr r0, =gBattle_BG1_Y - strh r1, [r0] - ldr r0, =gBattle_BG2_X - strh r1, [r0] - ldr r0, =gBattle_BG2_Y - strh r1, [r0] - ldr r0, =gBattle_BG3_X - strh r1, [r0] - ldr r0, =gUnknown_02022E22 - strh r1, [r0] - bl sub_80B0BD0 - ldr r2, =gBattleTerrain - strb r0, [r2] - ldr r4, =gBattleTypeFlags - ldr r0, [r4] - movs r1, 0x80 - lsls r1, 17 - ands r0, r1 - cmp r0, 0 - beq _080368FE - movs r0, 0x8 - strb r0, [r2] -_080368FE: - bl c2_berry_program_update_menu - bl sub_8035AA4 - bl ResetSpriteData - bl ResetTasks - bl sub_8036154 - bl FreeAllSpritePalettes - ldr r1, =gReservedSpritePaletteCount - movs r0, 0x4 - strb r0, [r1] - ldr r0, =VBlankCB_Battle - bl SetVBlankCallback - bl sub_803269C - ldr r2, [r4] - movs r1, 0xA0 - lsls r1, 1 - adds r0, r2, 0 - ands r0, r1 - cmp r0, r1 - beq _0803693E - ldr r1, =0x00400040 - adds r0, r2, 0 - ands r0, r1 - cmp r0, r1 - bne _08036994 -_0803693E: - ldr r0, =sub_8037458 - bl SetMainCallback2 - b _080369AE - .pool -_08036994: - movs r0, 0x40 - ands r2, r0 - cmp r2, 0 - beq _080369A8 - ldr r0, =sub_8037DF4 - bl SetMainCallback2 - b _080369AE - .pool -_080369A8: - ldr r0, =sub_8036FAC - bl SetMainCallback2 -_080369AE: - ldr r5, =gBattleTypeFlags - ldr r0, [r5] - ldr r1, =0x01000002 - ands r0, r1 - cmp r0, 0 - bne _080369E8 - ldr r4, =gEnemyParty - ldr r0, =gTrainerBattleOpponent_A - ldrh r1, [r0] - adds r0, r4, 0 - movs r2, 0x1 - bl CreateNPCTrainerParty - ldr r0, [r5] - movs r1, 0x80 - lsls r1, 8 - ands r0, r1 - cmp r0, 0 - beq _080369E4 - movs r1, 0x96 - lsls r1, 1 - adds r0, r4, r1 - ldr r1, =gTrainerBattleOpponent_B - ldrh r1, [r1] - movs r2, 0 - bl CreateNPCTrainerParty -_080369E4: - bl SetWildMonHeldItem -_080369E8: - ldr r1, =gMain - ldr r2, =0x00000439 - adds r1, r2 - ldrb r0, [r1] - movs r2, 0x2 - orrs r0, r2 - strb r0, [r1] - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldr r5, =0x00000ca9 - adds r1, r5 - ldrb r2, [r1] - movs r0, 0x9 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - ldr r4, =gPlayerParty - movs r0, 0xFA - lsls r0, 1 - adds r5, r4, r0 -_08036A10: - adds r0, r4, 0 - movs r1, 0x3 - bl AdjustFriendship - adds r4, 0x64 - cmp r4, r5 - ble _08036A10 - movs r1, 0 - ldr r0, =gBattleCommunication - strb r1, [r0] - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end InitBattle - - thumb_func_start sub_8036A5C -sub_8036A5C: @ 8036A5C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - movs r6, 0 - mov r9, r6 - movs r0, 0xCE - lsls r0, 1 - mov r10, r0 - mov r8, r6 -_08036A72: - movs r0, 0x64 - mov r4, r9 - muls r4, r0 - ldr r0, =gPlayerParty - adds r4, r0 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - lsls r0, 16 - lsrs r7, r0, 16 - adds r0, r4, 0 - movs r1, 0x37 - bl GetMonData - adds r1, r0, 0 - cmp r5, 0 - beq _08036AEE - cmp r5, r10 - beq _08036ABA - cmp r7, 0 - beq _08036ABA - cmp r1, 0 - bne _08036ABA - movs r0, 0x1 - mov r2, r8 - lsls r0, r2 - orrs r6, r0 - lsls r0, r6, 16 - lsrs r6, r0, 16 -_08036ABA: - cmp r5, 0 - beq _08036AEE - cmp r7, 0 - beq _08036AD6 - cmp r5, r10 - beq _08036ACA - cmp r1, 0 - beq _08036AD6 -_08036ACA: - movs r0, 0x2 - mov r1, r8 - lsls r0, r1 - orrs r6, r0 - lsls r0, r6, 16 - lsrs r6, r0, 16 -_08036AD6: - cmp r5, 0 - beq _08036AEE - cmp r5, r10 - beq _08036AEE - cmp r7, 0 - bne _08036AEE - movs r0, 0x3 - mov r2, r8 - lsls r0, r2 - orrs r6, r0 - lsls r0, r6, 16 - lsrs r6, r0, 16 -_08036AEE: - movs r0, 0x2 - add r8, r0 - movs r1, 0x1 - add r9, r1 - mov r2, r9 - cmp r2, 0x5 - ble _08036A72 - ldr r4, =gBattleStruct - ldr r0, [r4] - movs r1, 0xC1 - lsls r1, 1 - adds r0, r1 - strb r6, [r0] - ldr r0, [r4] - ldr r5, =0x00000183 - adds r0, r5 - lsrs r1, r6, 8 - strb r1, [r0] - ldr r0, =0x000008d2 - bl FlagGet - ldr r1, [r4] - adds r1, r5 - lsls r0, 7 - ldrb r2, [r1] - orrs r0, r2 - strb r0, [r1] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8036A5C - - thumb_func_start sub_8036B44 -sub_8036B44: @ 8036B44 - push {r4-r7,lr} - ldr r0, =gBattleStruct - ldr r5, [r0] - movs r0, 0xC2 - lsls r0, 1 - adds r4, r5, r0 - bl IsEnigmaBerryValid - cmp r0, 0x1 - bne _08036BC0 - movs r2, 0 - ldr r7, =gSaveBlock1Ptr - movs r1, 0xC6 - lsls r1, 1 - adds r5, r1 - adds r6, r7, 0 - ldr r3, =0x000031f8 -_08036B66: - adds r0, r4, r2 - ldr r1, [r6] - adds r1, r3 - adds r1, r2 - ldrb r1, [r1] - strb r1, [r0] - adds r2, 0x1 - cmp r2, 0x5 - ble _08036B66 - adds r1, r4, r2 - movs r0, 0xFF - strb r0, [r1] - movs r2, 0 - adds r3, r5, 0 - ldr r6, =gSaveBlock1Ptr - ldr r5, =0x00003214 -_08036B86: - adds r0, r3, r2 - ldr r1, [r6] - adds r1, r5 - adds r1, r2 - ldrb r1, [r1] - strb r1, [r0] - adds r2, 0x1 - cmp r2, 0x11 - ble _08036B86 - ldr r0, [r7] - ldr r1, =0x00003226 - adds r0, r1 - ldrb r0, [r0] - strb r0, [r4, 0x7] - ldr r0, [r7] - adds r1, 0x1 - adds r0, r1 - ldrb r0, [r0] - b _08036C00 - .pool -_08036BC0: - movs r0, 0xAF - bl ItemIdToBerryType - lsls r0, 24 - lsrs r0, 24 - bl GetBerryInfo - adds r3, r0, 0 - movs r2, 0 - movs r0, 0xC6 - lsls r0, 1 - adds r5, r0 -_08036BD8: - adds r0, r4, r2 - adds r1, r3, r2 - ldrb r1, [r1] - strb r1, [r0] - adds r2, 0x1 - cmp r2, 0x5 - ble _08036BD8 - adds r1, r4, r2 - movs r0, 0xFF - strb r0, [r1] - adds r0, r5, 0 - movs r2, 0 - adds r1, r0, 0 - adds r1, 0x11 -_08036BF4: - strb r2, [r1] - subs r1, 0x1 - cmp r1, r0 - bge _08036BF4 - movs r0, 0 - strb r0, [r4, 0x7] -_08036C00: - strb r0, [r4, 0x1A] - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8036B44 - - thumb_func_start berry_801017C -berry_801017C: @ 8036C08 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08036C20 - b _08036D4C -_08036C20: - bl IsEnigmaBerryValid - cmp r0, 0x1 - bne _08036CDC - movs r5, 0 - ldr r3, =gEnigmaBerries - ldr r0, =gSaveBlock1Ptr - mov r8, r0 - adds r6, r3, 0 - mov r4, r8 - ldr r2, =0x000031f8 - adds r7, r3, 0 - adds r7, 0x38 -_08036C3A: - adds r1, r5, r6 - ldr r0, [r4] - adds r0, r2 - adds r0, r5 - ldrb r0, [r0] - strb r0, [r1] - adds r1, r5, r7 - ldr r0, [r4] - adds r0, r2 - adds r0, r5 - ldrb r0, [r0] - strb r0, [r1] - adds r5, 0x1 - cmp r5, 0x5 - ble _08036C3A - adds r1, r5, r3 - movs r0, 0xFF - strb r0, [r1] - adds r0, r3, 0 - adds r0, 0x38 - adds r0, r5, r0 - movs r1, 0x1 - negs r1, r1 - strb r1, [r0] - movs r5, 0 - adds r7, r3, 0 - adds r7, 0x8 - ldr r4, =gSaveBlock1Ptr - ldr r2, =0x00003214 - adds r6, r3, 0 - adds r6, 0x40 -_08036C78: - adds r1, r5, r7 - ldr r0, [r4] - adds r0, r2 - adds r0, r5 - ldrb r0, [r0] - strb r0, [r1] - adds r1, r5, r6 - ldr r0, [r4] - adds r0, r2 - adds r0, r5 - ldrb r0, [r0] - strb r0, [r1] - adds r5, 0x1 - cmp r5, 0x11 - ble _08036C78 - mov r1, r8 - ldr r0, [r1] - ldr r2, =0x00003226 - adds r0, r2 - ldrb r1, [r0] - strb r1, [r3, 0x7] - ldrb r0, [r0] - adds r1, r3, 0 - adds r1, 0x3F - strb r0, [r1] - mov r4, r8 - ldr r0, [r4] - ldr r1, =0x00003227 - adds r0, r1 - ldrb r1, [r0] - strb r1, [r3, 0x1A] - ldrb r1, [r0] - adds r0, r3, 0 - adds r0, 0x52 - strb r1, [r0] - b _08036EA0 - .pool -_08036CDC: - movs r0, 0xAF - bl ItemIdToBerryType - lsls r0, 24 - lsrs r0, 24 - bl GetBerryInfo - adds r6, r0, 0 - movs r5, 0 - ldr r4, =gEnigmaBerries - adds r7, r4, 0 - adds r7, 0x38 - adds r3, r4, 0 -_08036CF6: - adds r1, r5, r4 - adds r2, r6, r5 - ldrb r0, [r2] - strb r0, [r1] - adds r1, r5, r7 - ldrb r0, [r2] - strb r0, [r1] - adds r5, 0x1 - cmp r5, 0x5 - ble _08036CF6 - adds r1, r5, r3 - movs r0, 0xFF - strb r0, [r1] - adds r0, r3, 0 - adds r0, 0x38 - adds r0, r5, r0 - movs r1, 0x1 - negs r1, r1 - strb r1, [r0] - movs r5, 0 - adds r4, r3, 0 - adds r4, 0x8 - movs r1, 0 - adds r2, r3, 0 - adds r2, 0x40 -_08036D28: - adds r0, r5, r4 - strb r1, [r0] - adds r0, r5, r2 - strb r1, [r0] - adds r5, 0x1 - cmp r5, 0x11 - ble _08036D28 - movs r1, 0 - strb r1, [r3, 0x7] - adds r0, r3, 0 - adds r0, 0x3F - strb r1, [r0] - strb r1, [r3, 0x1A] - adds r0, 0x13 - strb r1, [r0] - b _08036EA0 - .pool -_08036D4C: - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _08036DF0 - movs r0, 0x80 - lsls r0, 1 - ands r1, r0 - movs r2, 0x4 - mov r8, r2 - cmp r1, 0 - beq _08036D66 - movs r4, 0x2 - mov r8, r4 -_08036D66: - movs r5, 0 - cmp r5, r8 - blt _08036D6E - b _08036EA0 -_08036D6E: - ldr r0, =gLinkPlayers - mov r12, r0 - ldr r3, =gEnigmaBerries - adds r6, r3, 0 - movs r1, 0x8 - adds r1, r6 - mov r9, r1 -_08036D7C: - lsls r1, r5, 8 - ldr r0, =gUnknown_020223C8 - adds r7, r1, r0 - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - add r0, r12 - ldrb r3, [r0, 0x18] - movs r4, 0 - adds r5, 0x1 - mov r10, r5 - lsls r1, r3, 3 - subs r0, r1, r3 - adds r5, r1, 0 - lsls r0, 2 - adds r1, r0, r6 -_08036D9C: - adds r0, r7, r4 - ldrb r0, [r0] - strb r0, [r1] - adds r1, 0x1 - adds r4, 0x1 - cmp r4, 0x5 - ble _08036D9C - subs r0, r5, r3 - lsls r0, 2 - adds r1, r4, r0 - adds r1, r6 - movs r2, 0xFF - strb r2, [r1] - movs r4, 0 - mov r2, r9 - adds r1, r0, r2 - adds r2, r7, 0 - adds r2, 0x8 -_08036DC0: - adds r0, r2, r4 - ldrb r0, [r0] - strb r0, [r1] - adds r1, 0x1 - adds r4, 0x1 - cmp r4, 0x11 - ble _08036DC0 - subs r0, r5, r3 - lsls r0, 2 - adds r0, r6 - ldrb r1, [r7, 0x7] - strb r1, [r0, 0x7] - ldrb r1, [r7, 0x1A] - strb r1, [r0, 0x1A] - mov r5, r10 - cmp r5, r8 - blt _08036D7C - b _08036EA0 - .pool -_08036DF0: - movs r5, 0 - ldr r4, =gEnigmaBerries - mov r9, r4 -_08036DF6: - lsls r0, r5, 8 - ldr r1, =gUnknown_020223C8 - adds r7, r0, r1 - movs r4, 0 - adds r2, r5, 0x1 - mov r10, r2 - lsls r0, r5, 3 - mov r8, r0 - adds r1, r5, 0x2 - mov r12, r1 - subs r1, r0, r5 - mov r2, r12 - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - mov r2, r9 - adds r3, r0, r2 - lsls r1, 2 - adds r2, r1, r2 -_08036E1C: - adds r0, r7, r4 - ldrb r1, [r0] - strb r1, [r2] - ldrb r0, [r0] - strb r0, [r3] - adds r3, 0x1 - adds r2, 0x1 - adds r4, 0x1 - cmp r4, 0x5 - ble _08036E1C - mov r0, r8 - subs r3, r0, r5 - lsls r3, 2 - adds r1, r4, r3 - add r1, r9 - ldrb r0, [r1] - movs r2, 0xFF - orrs r0, r2 - strb r0, [r1] - mov r0, r12 - lsls r2, r0, 3 - subs r2, r0 - lsls r2, 2 - adds r1, r4, r2 - add r1, r9 - ldrb r0, [r1] - movs r4, 0xFF - orrs r0, r4 - strb r0, [r1] - movs r4, 0 - ldr r0, =gEnigmaBerries - adds r0, 0x8 - adds r2, r0 - adds r3, r0 - adds r6, r7, 0 - adds r6, 0x8 -_08036E64: - adds r0, r6, r4 - ldrb r1, [r0] - strb r1, [r3] - ldrb r0, [r0] - strb r0, [r2] - adds r2, 0x1 - adds r3, 0x1 - adds r4, 0x1 - cmp r4, 0x11 - ble _08036E64 - mov r0, r8 - subs r2, r0, r5 - lsls r2, 2 - add r2, r9 - ldrb r0, [r7, 0x7] - strb r0, [r2, 0x7] - mov r1, r12 - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r9 - ldrb r1, [r7, 0x7] - strb r1, [r0, 0x7] - ldrb r1, [r7, 0x1A] - strb r1, [r2, 0x1A] - ldrb r1, [r7, 0x1A] - strb r1, [r0, 0x1A] - mov r5, r10 - cmp r5, 0x1 - ble _08036DF6 -_08036EA0: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end berry_801017C - - thumb_func_start sub_8036EB8 -sub_8036EB8: @ 8036EB8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r1, 24 - lsrs r3, r1, 24 - movs r6, 0 - ldr r0, =gUnknown_020223C4 - ldrh r2, [r0] - movs r1, 0x80 - lsls r1, 1 - mov r12, r0 - cmp r2, r1 - bne _08036EFC - cmp r3, 0 - bne _08036EEC - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r2, 0xC - b _08036EF2 - .pool -_08036EEC: - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r2, 0x8 -_08036EF2: - orrs r1, r2 - str r1, [r0] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_08036EFC: - cmp r6, 0 - bne _08036FA0 - movs r2, 0 - cmp r2, r4 - bge _08036F20 - ldr r1, =gUnknown_020223C4 - mov r8, r1 - movs r5, 0x80 - lsls r5, 1 -_08036F0E: - adds r1, r5 - adds r2, 0x1 - cmp r2, r4 - bge _08036F20 - mov r7, r8 - ldrh r0, [r7] - ldrh r7, [r1] - cmp r0, r7 - beq _08036F0E -_08036F20: - cmp r2, r4 - bne _08036F48 - cmp r3, 0 - bne _08036F38 - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r2, 0xC - b _08036F3E - .pool -_08036F38: - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r2, 0x8 -_08036F3E: - orrs r1, r2 - str r1, [r0] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_08036F48: - cmp r6, 0 - bne _08036FA0 - movs r2, 0 - ldr r5, =gBattleTypeFlags - cmp r2, r4 - bge _08036F8A - mov r0, r12 - ldrh r1, [r0] - movs r0, 0xC0 - lsls r0, 2 - cmp r1, r0 - beq _08036F82 -_08036F60: - lsls r0, r2, 8 - add r0, r12 - ldrh r0, [r0] - movs r1, 0xC0 - lsls r1, 2 - cmp r0, r1 - bls _08036F72 - cmp r2, r3 - bne _08036F8A -_08036F72: - adds r2, 0x1 - cmp r2, r4 - bge _08036F8A - lsls r0, r2, 8 - add r0, r12 - ldrh r0, [r0] - cmp r0, r1 - bne _08036F60 -_08036F82: - cmp r2, r3 - beq _08036F60 - cmp r2, r3 - bge _08036F60 -_08036F8A: - cmp r2, r4 - bne _08036F98 - ldr r0, [r5] - movs r1, 0xC - b _08036F9C - .pool -_08036F98: - ldr r0, [r5] - movs r1, 0x8 -_08036F9C: - orrs r0, r1 - str r0, [r5] -_08036FA0: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8036EB8 - - thumb_func_start sub_8036FAC -sub_8036FAC: @ 8036FAC - push {r4-r6,lr} - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl GetMultiplayerId - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, =gBattleScripting - adds r0, 0x25 - strb r6, [r0] - movs r0, 0x1 - adds r5, r6, 0 - eors r5, r0 - ldr r0, =gBattleCommunication - ldrb r0, [r0] - cmp r0, 0x12 - bls _08036FD8 - b _0803744C -_08036FD8: - lsls r0, 2 - ldr r1, =_08036FF0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08036FF0: - .4byte _0803703C - .4byte _08037080 - .4byte _08037144 - .4byte _080371D8 - .4byte _08037200 - .4byte _0803742C - .4byte _08037438 - .4byte _08037230 - .4byte _08037258 - .4byte _0803742C - .4byte _08037438 - .4byte _08037288 - .4byte _080372B0 - .4byte _0803742C - .4byte _08037438 - .4byte _08037318 - .4byte _08037378 - .4byte _080373A0 - .4byte _080373E0 -_0803703C: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _08037068 - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg - bl sub_805EF14 - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1] -_08037068: - ldr r0, =gLinkVSyncDisabled - ldrb r0, [r0] - cmp r0, 0 - bne _08037072 - b _0803744C -_08037072: - bl sub_800E0E8 - b _0803744C - .pool -_08037080: - ldr r2, =gBattleTypeFlags - ldr r1, [r2] - movs r6, 0x2 - adds r0, r1, 0 - ands r0, r6 - cmp r0, 0 - beq _08037124 - ldr r0, =gUnknown_03003124 - ldrb r0, [r0] - cmp r0, 0 - bne _08037098 - b _0803744C -_08037098: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - beq _080370EE - ldr r4, =gBattleStruct - ldr r0, [r4] - movs r5, 0xC0 - lsls r5, 1 - adds r0, r5 - movs r1, 0 - strb r1, [r0] - ldr r0, [r4] - ldr r2, =0x00000181 - adds r1, r0, r2 - movs r0, 0x3 - strb r0, [r1] - bl sub_8036A5C - bl sub_8036B44 - ldr r0, =gTrainerBattleOpponent_A - ldrh r1, [r0] - movs r0, 0xC0 - lsls r0, 4 - cmp r1, r0 - bne _080370D8 - ldr r0, =gLinkPlayers - movs r1, 0 - strh r1, [r0, 0x18] - movs r1, 0x1 - strh r1, [r0, 0x34] -_080370D8: - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, [r4] - adds r1, r5 - movs r2, 0x20 - bl link_0800A448 - ldr r0, =gBattleCommunication - strb r6, [r0] -_080370EE: - ldr r0, =gLinkVSyncDisabled - ldrb r0, [r0] - cmp r0, 0 - bne _080370F8 - b _0803744C -_080370F8: - movs r0, 0 - movs r1, 0 - bl sub_800DFB4 - b _0803744C - .pool -_08037124: - movs r0, 0x80 - lsls r0, 17 - ands r0, r1 - cmp r0, 0 - bne _08037134 - movs r0, 0x4 - orrs r1, r0 - str r1, [r2] -_08037134: - ldr r1, =gBattleCommunication - movs r0, 0xF - strb r0, [r1] - bl berry_801017C - b _0803744C - .pool -_08037144: - bl sub_800A550 - movs r1, 0x3 - ands r1, r0 - cmp r1, 0x3 - beq _08037152 - b _0803744C -_08037152: - bl sub_800A5B4 - movs r0, 0x2 - adds r1, r6, 0 - bl sub_8036EB8 - bl berry_801017C - ldr r0, =task00_0800F6FC - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gTasks - lsls r2, r0, 2 - adds r2, r0 - lsls r2, 3 - adds r2, r1 - movs r1, 0 - movs r0, 0x87 - lsls r0, 1 - strh r0, [r2, 0xA] - movs r0, 0x5A - strh r0, [r2, 0xC] - strh r1, [r2, 0x12] - ldr r0, =gBattleStruct - ldr r3, [r0] - movs r4, 0xC1 - lsls r4, 1 - adds r0, r3, r4 - ldrb r1, [r0] - adds r4, 0x1 - adds r0, r3, r4 - ldrb r0, [r0] - lsls r0, 8 - orrs r1, r0 - strh r1, [r2, 0xE] - ldr r1, =gUnknown_020223C4 - lsls r4, r5, 8 - adds r1, 0x2 - adds r4, r1 - ldrh r0, [r4] - strh r0, [r2, 0x10] - lsls r0, r6, 8 - adds r0, r1 - ldrh r0, [r0] - bl sub_8185F90 - ldrh r0, [r4] - bl sub_8185F90 - bl sub_8068AA4 - ldr r1, =gBattleCommunication - b _08037446 - .pool -_080371D8: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - bne _080371E4 - b _0803744C -_080371E4: - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gPlayerParty - movs r2, 0xC8 - bl link_0800A448 - ldr r1, =gBattleCommunication - b _08037446 - .pool -_08037200: - bl sub_800A550 - movs r1, 0x3 - ands r1, r0 - cmp r1, 0x3 - beq _0803720E - b _0803744C -_0803720E: - bl sub_800A5B4 - ldr r0, =gEnemyParty - lsls r1, r5, 8 - ldr r2, =gUnknown_020223C4 - adds r1, r2 - movs r2, 0xC8 - bl memcpy - ldr r1, =gBattleCommunication - b _08037446 - .pool -_08037230: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - bne _0803723C - b _0803744C -_0803723C: - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gPlayerParty + 200 - movs r2, 0xC8 - bl link_0800A448 - ldr r1, =gBattleCommunication - b _08037446 - .pool -_08037258: - bl sub_800A550 - movs r1, 0x3 - ands r1, r0 - cmp r1, 0x3 - beq _08037266 - b _0803744C -_08037266: - bl sub_800A5B4 - ldr r0, =gEnemyParty + 200 - lsls r1, r5, 8 - ldr r2, =gUnknown_020223C4 - adds r1, r2 - movs r2, 0xC8 - bl memcpy - ldr r1, =gBattleCommunication - b _08037446 - .pool -_08037288: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - bne _08037294 - b _0803744C -_08037294: - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gPlayerParty + 400 - movs r2, 0xC8 - bl link_0800A448 - ldr r1, =gBattleCommunication - b _08037446 - .pool -_080372B0: - bl sub_800A550 - movs r1, 0x3 - ands r1, r0 - cmp r1, 0x3 - beq _080372BE - b _0803744C -_080372BE: - bl sub_800A5B4 - ldr r4, =gEnemyParty + 400 - lsls r1, r5, 8 - ldr r0, =gUnknown_020223C4 - adds r1, r0 - adds r0, r4, 0 - movs r2, 0xC8 - bl memcpy - ldr r1, =0xfffffe70 - adds r0, r4, r1 - bl shedinja_something - ldr r2, =0xfffffed4 - adds r0, r4, r2 - bl shedinja_something - adds r0, r4, 0 - subs r0, 0xC8 - bl shedinja_something - adds r0, r4, 0 - subs r0, 0x64 - bl shedinja_something - adds r0, r4, 0 - bl shedinja_something - adds r0, r4, 0 - adds r0, 0x64 - bl shedinja_something - ldr r1, =gBattleCommunication - b _08037446 - .pool -_08037318: - bl sub_8032768 - bl sub_8184E58 - ldr r2, =gBattleCommunication - movs r0, 0 - strb r0, [r2, 0x1] - strb r0, [r2, 0x2] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08037372 - movs r3, 0 - ldr r1, =gLinkPlayers - ldrb r0, [r1] - adds r5, r2, 0 - cmp r0, 0x3 - bne _08037356 - movs r4, 0xFF - adds r2, r1, 0 -_08037344: - adds r2, 0x1C - adds r3, 0x1 - cmp r3, 0x1 - bgt _08037356 - ldrh r1, [r2] - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0x3 - beq _08037344 -_08037356: - cmp r3, 0x2 - bne _0803736C - movs r0, 0x10 - strb r0, [r5] - b _0803744C - .pool -_0803736C: - movs r0, 0x12 - strb r0, [r5] - b _0803744C -_08037372: - movs r0, 0x12 - strb r0, [r2] - b _0803744C -_08037378: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - beq _0803744C - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0203BD2C - movs r2, 0x4 - bl link_0800A448 - ldr r1, =gBattleCommunication - b _08037446 - .pool -_080373A0: - bl sub_800A550 - movs r1, 0x3 - ands r1, r0 - cmp r1, 0x3 - bne _0803744C - bl sub_800A5B4 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x4 - ands r0, r1 - cmp r0, 0 - bne _080373CA - ldr r0, =gUnknown_0203BD2C - lsls r1, r5, 8 - ldr r2, =gUnknown_020223C4 - adds r1, r2 - movs r2, 0x4 - bl memcpy -_080373CA: - ldr r1, =gBattleCommunication - b _08037446 - .pool -_080373E0: - ldr r0, =gUnknown_02024333 - adds r1, r0, 0x1 - bl battle_load_something - lsls r0, 24 - cmp r0, 0 - beq _0803744C - ldr r2, =gUnknown_03005D00 - ldr r1, =gMain - ldr r0, [r1] - str r0, [r2] - ldr r0, =sub_8039EF0 - str r0, [r1] - ldr r0, =BattleMainCB2 - bl SetMainCallback2 - ldr r2, =gBattleTypeFlags - ldr r1, [r2] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0803744C - movs r0, 0x20 - orrs r1, r0 - str r1, [r2] - b _0803744C - .pool -_0803742C: - ldr r0, =gBattleCommunication - ldrb r1, [r0] - adds r1, 0x1 - strb r1, [r0] - movs r1, 0x1 - strb r1, [r0, 0x1] -_08037438: - ldr r1, =gBattleCommunication - ldrb r0, [r1, 0x1] - subs r0, 0x1 - strb r0, [r1, 0x1] - lsls r0, 24 - cmp r0, 0 - bne _0803744C -_08037446: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_0803744C: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8036FAC - - thumb_func_start sub_8037458 -sub_8037458: @ 8037458 - push {r4-r7,lr} - sub sp, 0x4 - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl GetMultiplayerId - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, =gBattleScripting - adds r0, 0x25 - strb r6, [r0] - movs r0, 0x1 - adds r7, r6, 0 - eors r7, r0 - ldr r0, =gBattleCommunication - ldrb r0, [r0] - cmp r0, 0x10 - bls _08037486 - b _080379D6 -_08037486: - lsls r0, 2 - ldr r1, =_0803749C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0803749C: - .4byte _080374E0 - .4byte _08037518 - .4byte _0803761C - .4byte _08037670 - .4byte _08037694 - .4byte _08037710 - .4byte _08037734 - .4byte _080377B0 - .4byte _080377CC - .4byte _080377FC - .4byte _08037818 - .4byte _08037848 - .4byte _08037864 - .4byte _08037908 - .4byte _0803793A - .4byte _0803795C - .4byte _080379A0 -_080374E0: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0803750C - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg - bl sub_805EF14 - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1] -_0803750C: - ldr r0, =gLinkVSyncDisabled - ldrb r0, [r0] - cmp r0, 0 - beq _08037518 - bl sub_800E0E8 -_08037518: - ldr r2, =gBattleTypeFlags - ldr r1, [r2] - movs r3, 0x2 - adds r0, r1, 0 - ands r0, r3 - cmp r0, 0 - beq _080375FC - ldr r0, =gUnknown_03003124 - ldrb r0, [r0] - cmp r0, 0 - bne _08037530 - b _080379D6 -_08037530: - ldr r6, =gLinkPlayers - movs r0, 0 - strh r0, [r6, 0x18] - strh r3, [r6, 0x34] - adds r1, r6, 0 - adds r1, 0x50 - movs r0, 0x1 - strh r0, [r1] - adds r1, 0x1C - movs r0, 0x3 - strh r0, [r1] - adds r0, r6, 0 - adds r0, 0x40 - ldr r4, =gTrainerBattleOpponent_A - ldrh r1, [r4] - bl GetFrontierTrainerName - adds r0, r6, 0 - adds r0, 0x5C - ldr r5, =gTrainerBattleOpponent_B - ldrh r1, [r5] - bl GetFrontierTrainerName - ldrh r1, [r4] - mov r0, sp - bl sub_8165B88 - mov r0, sp - ldrb r0, [r0] - adds r1, r6, 0 - adds r1, 0x52 - strh r0, [r1] - ldrh r1, [r5] - mov r0, sp - bl sub_8165B88 - mov r0, sp - ldrb r1, [r0] - adds r0, r6, 0 - adds r0, 0x6E - strh r1, [r0] - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - beq _080375C4 - ldr r4, =gBattleStruct - ldr r0, [r4] - movs r5, 0xC0 - lsls r5, 1 - adds r0, r5 - movs r1, 0 - strb r1, [r0] - ldr r0, [r4] - ldr r2, =0x00000181 - adds r1, r0, r2 - movs r0, 0x3 - strb r0, [r1] - bl sub_8036A5C - bl sub_8036B44 - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, [r4] - adds r1, r5 - movs r2, 0x20 - bl link_0800A448 - ldr r1, =gBattleCommunication - movs r0, 0x2 - strb r0, [r1] -_080375C4: - ldr r0, =gLinkVSyncDisabled - ldrb r0, [r0] - cmp r0, 0 - bne _080375CE - b _080379D6 -_080375CE: - movs r0, 0 - movs r1, 0 - bl sub_800DFB4 - b _080379D6 - .pool -_080375FC: - movs r0, 0x80 - lsls r0, 17 - ands r0, r1 - cmp r0, 0 - bne _0803760C - movs r0, 0x4 - orrs r1, r0 - str r1, [r2] -_0803760C: - ldr r1, =gBattleCommunication - movs r0, 0xD - strb r0, [r1] - bl berry_801017C - b _080379D6 - .pool -_0803761C: - bl sub_800A550 - movs r1, 0x3 - ands r1, r0 - cmp r1, 0x3 - beq _0803762A - b _080379D6 -_0803762A: - bl sub_800A5B4 - movs r0, 0x2 - adds r1, r6, 0 - bl sub_8036EB8 - bl berry_801017C - ldr r0, =task00_0800F6FC - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - movs r2, 0 - movs r0, 0x87 - lsls r0, 1 - strh r0, [r1, 0xA] - movs r0, 0x5A - strh r0, [r1, 0xC] - strh r2, [r1, 0x12] - adds r0, 0xEB - strh r0, [r1, 0xE] - strh r0, [r1, 0x10] - b _08037986 - .pool -_08037670: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - bne _0803767C - b _080379D6 -_0803767C: - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gPlayerParty -_08037686: - movs r2, 0xC8 - bl link_0800A448 - b _08037986 - .pool -_08037694: - bl sub_800A550 - movs r1, 0x3 - ands r1, r0 - cmp r1, 0x3 - beq _080376A2 - b _080379D6 -_080376A2: - bl sub_800A5B4 - ldr r0, =gLinkPlayers - lsls r1, r6, 3 - subs r1, r6 - lsls r1, 2 - adds r1, r0 - ldrh r0, [r1, 0x18] - cmp r0, 0 - beq _080376E8 - ldr r4, =gPlayerParty - lsls r1, r7, 8 - ldr r5, =gUnknown_020223C4 - adds r1, r5 - adds r0, r4, 0 - movs r2, 0xC8 - bl memcpy - movs r0, 0x96 - lsls r0, 1 - adds r4, r0 - lsls r1, r6, 8 - adds r1, r5 - adds r0, r4, 0 - movs r2, 0xC8 - bl memcpy - b _08037986 - .pool -_080376E8: - ldr r4, =gPlayerParty - lsls r1, r6, 8 - ldr r5, =gUnknown_020223C4 - adds r1, r5 - adds r0, r4, 0 - movs r2, 0xC8 - bl memcpy - movs r1, 0x96 - lsls r1, 1 - adds r4, r1 - lsls r1, r7, 8 - adds r1, r5 - adds r0, r4, 0 - movs r2, 0xC8 - b _08037982 - .pool -_08037710: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - bne _0803771C - b _080379D6 -_0803771C: - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gPlayerParty + 200 - movs r2, 0x64 - bl link_0800A448 - b _08037986 - .pool -_08037734: - bl sub_800A550 - movs r1, 0x3 - ands r1, r0 - cmp r1, 0x3 - beq _08037742 - b _080379D6 -_08037742: - bl sub_800A5B4 - ldr r0, =gLinkPlayers - lsls r1, r6, 3 - subs r1, r6 - lsls r1, 2 - adds r1, r0 - ldrh r0, [r1, 0x18] - cmp r0, 0 - beq _08037788 - ldr r4, =gPlayerParty + 200 - lsls r1, r7, 8 - ldr r5, =gUnknown_020223C4 - adds r1, r5 - adds r0, r4, 0 - movs r2, 0x64 - bl memcpy - movs r2, 0x96 - lsls r2, 1 - adds r4, r2 - lsls r1, r6, 8 - adds r1, r5 - adds r0, r4, 0 - movs r2, 0x64 - bl memcpy - b _08037986 - .pool -_08037788: - ldr r4, =gPlayerParty + 200 - lsls r1, r6, 8 - ldr r5, =gUnknown_020223C4 - adds r1, r5 - adds r0, r4, 0 - movs r2, 0x64 - bl memcpy - movs r0, 0x96 - lsls r0, 1 - adds r4, r0 - lsls r1, r7, 8 - adds r1, r5 - adds r0, r4, 0 - movs r2, 0x64 - b _08037982 - .pool -_080377B0: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - bne _080377BC - b _080379D6 -_080377BC: - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gEnemyParty - b _08037686 - .pool -_080377CC: - bl sub_800A550 - movs r1, 0x3 - ands r1, r0 - cmp r1, 0x3 - beq _080377DA - b _080379D6 -_080377DA: - bl sub_800A5B4 - bl GetMultiplayerId - lsls r0, 24 - cmp r0, 0 - bne _080377EA - b _08037986 -_080377EA: - ldr r0, =gEnemyParty - ldr r1, =gUnknown_020223C4 - movs r2, 0xC8 - b _08037982 - .pool -_080377FC: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - bne _08037808 - b _080379D6 -_08037808: - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gEnemyParty + 200 - b _08037686 - .pool -_08037818: - bl sub_800A550 - movs r1, 0x3 - ands r1, r0 - cmp r1, 0x3 - beq _08037826 - b _080379D6 -_08037826: - bl sub_800A5B4 - bl GetMultiplayerId - lsls r0, 24 - cmp r0, 0 - bne _08037836 - b _08037986 -_08037836: - ldr r0, =gEnemyParty + 200 - ldr r1, =gUnknown_020223C4 - movs r2, 0xC8 - b _08037982 - .pool -_08037848: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - bne _08037854 - b _080379D6 -_08037854: - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gEnemyParty + 400 - b _08037686 - .pool -_08037864: - bl sub_800A550 - movs r1, 0x3 - ands r1, r0 - cmp r1, 0x3 - beq _08037872 - b _080379D6 -_08037872: - bl sub_800A5B4 - bl GetMultiplayerId - lsls r0, 24 - cmp r0, 0 - beq _0803788A - ldr r0, =gEnemyParty + 400 - ldr r1, =gUnknown_020223C4 - movs r2, 0xC8 - bl memcpy -_0803788A: - ldr r4, =gPlayerParty - adds r0, r4, 0 - bl shedinja_something - adds r0, r4, 0 - adds r0, 0x64 - bl shedinja_something - adds r0, r4, 0 - adds r0, 0xC8 - bl shedinja_something - movs r1, 0x96 - lsls r1, 1 - adds r0, r4, r1 - bl shedinja_something - movs r2, 0xC8 - lsls r2, 1 - adds r0, r4, r2 - bl shedinja_something - movs r1, 0xFA - lsls r1, 1 - adds r0, r4, r1 - bl shedinja_something - ldr r4, =gEnemyParty - adds r0, r4, 0 - bl shedinja_something - adds r0, r4, 0 - adds r0, 0x64 - bl shedinja_something - adds r0, r4, 0 - adds r0, 0xC8 - bl shedinja_something - movs r2, 0x96 - lsls r2, 1 - adds r0, r4, r2 - bl shedinja_something - movs r1, 0xC8 - lsls r1, 1 - adds r0, r4, r1 - bl shedinja_something - movs r2, 0xFA - lsls r2, 1 - adds r0, r4, r2 - bl shedinja_something - b _08037986 - .pool -_08037908: - bl sub_8032768 - bl sub_8184E58 - ldr r2, =gBattleCommunication - movs r0, 0 - strb r0, [r2, 0x1] - strb r0, [r2, 0x2] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08037934 - movs r0, 0xE - strb r0, [r2] - b _080379D6 - .pool -_08037934: - movs r0, 0x10 - strb r0, [r2] - b _080379D6 -_0803793A: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - beq _080379D6 - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0203BD2C - movs r2, 0x4 - bl link_0800A448 - b _08037986 - .pool -_0803795C: - bl sub_800A550 - movs r1, 0x3 - ands r1, r0 - cmp r1, 0x3 - bne _080379D6 - bl sub_800A5B4 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x4 - ands r0, r1 - cmp r0, 0 - bne _08037986 - ldr r0, =gUnknown_0203BD2C - lsls r1, r7, 8 - ldr r2, =gUnknown_020223C4 - adds r1, r2 - movs r2, 0x4 -_08037982: - bl memcpy -_08037986: - ldr r1, =gBattleCommunication - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _080379D6 - .pool -_080379A0: - ldr r0, =gUnknown_02024333 - adds r1, r0, 0x1 - bl battle_load_something - lsls r0, 24 - cmp r0, 0 - beq _080379D6 - bl sub_8166188 - ldr r2, =gUnknown_03005D00 - ldr r1, =gMain - ldr r0, [r1] - str r0, [r2] - ldr r0, =sub_8039EF0 - str r0, [r1] - ldr r0, =BattleMainCB2 - bl SetMainCallback2 - ldr r2, =gBattleTypeFlags - ldr r1, [r2] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080379D6 - movs r0, 0x20 - orrs r1, r0 - str r1, [r2] -_080379D6: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8037458 - - thumb_func_start sub_80379F8 -sub_80379F8: @ 80379F8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] - movs r0, 0 - mov r8, r0 - ldr r6, =gUnknown_02022FF8 - mov r10, r6 -_08037A12: - ldr r1, [sp] - add r1, r8 - movs r0, 0x64 - adds r4, r1, 0 - muls r4, r0 - ldr r0, =gPlayerParty - adds r4, r0 - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - mov r1, r8 - lsls r5, r1, 5 - strh r0, [r6] - adds r0, r4, 0 - movs r1, 0xC - bl GetMonData - strh r0, [r6, 0x2] - movs r0, 0x4 - add r0, r10 - mov r9, r0 - adds r7, r5, r0 - adds r0, r4, 0 - movs r1, 0x2 - adds r2, r7, 0 - bl GetMonData - adds r0, r4, 0 - movs r1, 0x38 - bl GetMonData - strb r0, [r6, 0xF] - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - strh r0, [r6, 0x10] - adds r0, r4, 0 - movs r1, 0x3A - bl GetMonData - strh r0, [r6, 0x12] - adds r0, r4, 0 - movs r1, 0x37 - bl GetMonData - mov r1, r10 - adds r1, 0x14 - adds r5, r1 - str r0, [r5] - adds r0, r4, 0 - movs r1, 0 - bl GetMonData - str r0, [r6, 0x18] - adds r0, r4, 0 - bl GetMonGender - strb r0, [r6, 0x1C] - adds r0, r7, 0 - bl StripExtCtrlCodes - adds r0, r4, 0 - movs r1, 0x3 - bl GetMonData - cmp r0, 0x1 - beq _08037AA4 - adds r0, r7, 0 - movs r1, 0 - bl sub_81DB4DC -_08037AA4: - adds r6, 0x20 - movs r1, 0x1 - add r8, r1 - mov r0, r8 - cmp r0, 0x2 - ble _08037A12 - ldr r0, =gUnknown_02023058 - ldr r0, [r0] - mov r1, r9 - subs r1, 0x4 - movs r2, 0x60 - bl memcpy - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80379F8 - - thumb_func_start sub_8037ADC -sub_8037ADC: @ 8037ADC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - movs r0, 0x4 - mov r9, r0 - movs r4, 0xF - ldr r6, =gBattleTypeFlags - ldr r0, [r6] - movs r1, 0x80 - lsls r1, 1 - ands r0, r1 - cmp r0, 0 - beq _08037B02 - movs r1, 0x2 - mov r9, r1 - movs r4, 0x3 -_08037B02: - bl GetMultiplayerId - lsls r0, 24 - lsrs r7, r0, 24 - ldr r0, =gBattleScripting - adds r0, 0x25 - movs r2, 0 - mov r8, r2 - strb r7, [r0] - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r1, r0, 0 - adds r1, 0xB4 - str r1, [sp] - adds r0, 0xAC - mov r10, r0 - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - ldr r5, =gBattleCommunication - ldrb r0, [r5] - cmp r0, 0x1 - beq _08037BA4 - cmp r0, 0x1 - bgt _08037B50 - cmp r0, 0 - beq _08037B5E - b _08037D0A - .pool -_08037B50: - cmp r0, 0x2 - bne _08037B56 - b _08037C64 -_08037B56: - cmp r0, 0x3 - bne _08037B5C - b _08037C9E -_08037B5C: - b _08037D0A -_08037B5E: - ldr r0, =gUnknown_03003124 - ldrb r0, [r0] - cmp r0, 0 - bne _08037B68 - b _08037D0A -_08037B68: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - bne _08037B74 - b _08037D0A -_08037B74: - ldr r4, =gUnknown_02023058 - movs r0, 0x60 - bl Alloc - str r0, [r4] - movs r0, 0 - bl sub_80379F8 - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, [r4] - movs r2, 0x60 - bl link_0800A448 - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - b _08037D0A - .pool -_08037BA4: - bl sub_800A550 - adds r1, r4, 0 - ands r1, r0 - cmp r1, r4 - beq _08037BB2 - b _08037D0A -_08037BB2: - bl sub_800A5B4 - movs r5, 0 - cmp r8, r9 - bge _08037C2E - lsls r0, r7, 3 - subs r0, r7 - lsls r6, r0, 2 - mov r8, r5 - ldr r4, =gUnknown_020223C4 -_08037BC6: - cmp r5, r7 - beq _08037C1E - mov r2, r9 - cmp r2, 0x4 - bne _08037C14 - ldr r2, =gLinkPlayers - mov r1, r8 - adds r0, r1, r2 - ldrh r1, [r0, 0x18] - movs r3, 0x1 - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - bne _08037BF8 - adds r0, r6, r2 - ldrh r1, [r0, 0x18] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _08037C04 - b _08037C1E - .pool -_08037BF8: - adds r0, r6, r2 - ldrh r1, [r0, 0x18] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _08037C1E -_08037C04: - ldr r0, =gUnknown_02022FF8 - adds r1, r4, 0 - movs r2, 0x60 - bl memcpy - b _08037C1E - .pool -_08037C14: - ldr r0, =gUnknown_02022FF8 - adds r1, r4, 0 - movs r2, 0x60 - bl memcpy -_08037C1E: - movs r2, 0x80 - lsls r2, 1 - adds r4, r2 - movs r0, 0x1C - add r8, r0 - adds r5, 0x1 - cmp r5, r9 - blt _08037BC6 -_08037C2E: - ldr r1, =gBattleCommunication - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r1, =gMain - ldr r0, [r1, 0x8] - ldr r2, [sp] - str r0, [r2] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - mov r2, r10 - str r0, [r2] - ldr r0, =sub_8037ADC - str r0, [r1, 0x8] - bl sub_81B9150 - b _08037D0A - .pool -_08037C64: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - beq _08037D0A - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08037D0A - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - ldr r0, =gLinkVSyncDisabled - ldrb r0, [r0] - cmp r0, 0 - beq _08037C98 - bl sub_800ADF8 - b _08037D0A - .pool -_08037C98: - bl sub_800AC34 - b _08037D0A -_08037C9E: - ldr r0, =gLinkVSyncDisabled - ldrb r0, [r0] - cmp r0, 0 - beq _08037CE4 - bl sub_8010500 - lsls r0, 24 - cmp r0, 0 - beq _08037D0A - mov r1, r10 - ldr r0, [r1] - str r0, [r6] - ldr r1, =gMain - ldr r2, [sp] - ldr r0, [r2] - str r0, [r1, 0x8] - ldr r0, =InitBattle - bl SetMainCallback2 - ldr r4, =gUnknown_02023058 - ldr r0, [r4] - bl Free - mov r0, r8 - str r0, [r4] - b _08037D0A - .pool -_08037CE4: - ldr r0, =gUnknown_03003124 - ldrb r5, [r0] - cmp r5, 0 - bne _08037D0A - mov r1, r10 - ldr r0, [r1] - str r0, [r6] - ldr r1, =gMain - ldr r2, [sp] - ldr r0, [r2] - str r0, [r1, 0x8] - ldr r0, =InitBattle - bl SetMainCallback2 - ldr r4, =gUnknown_02023058 - ldr r0, [r4] - bl Free - str r5, [r4] -_08037D0A: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8037ADC - - thumb_func_start intro_end -intro_end: @ 8037D2C - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r0, =gBattleStruct - ldr r0, [r0] - movs r1, 0xB4 - adds r1, r0 - mov r8, r1 - adds r7, r0, 0 - adds r7, 0xAC - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - ldr r5, =gBattleCommunication - ldrb r0, [r5] - cmp r0, 0 - beq _08037D64 - cmp r0, 0x1 - beq _08037DA4 - b _08037DD6 - .pool -_08037D64: - ldr r4, =gUnknown_02023058 - movs r0, 0x60 - bl Alloc - str r0, [r4] - movs r0, 0x3 - bl sub_80379F8 - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - ldr r1, =gMain - ldr r0, [r1, 0x8] - mov r2, r8 - str r0, [r2] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - str r0, [r7] - ldr r0, =intro_end - str r0, [r1, 0x8] - bl sub_81B9150 - b _08037DD6 - .pool -_08037DA4: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0 - bne _08037DD6 - movs r0, 0x2 - strb r0, [r5] - ldr r1, =gBattleTypeFlags - ldr r0, [r7] - str r0, [r1] - ldr r1, =gMain - mov r2, r8 - ldr r0, [r2] - str r0, [r1, 0x8] - ldr r0, =InitBattle - bl SetMainCallback2 - ldr r4, =gUnknown_02023058 - ldr r0, [r4] - bl Free - str r6, [r4] -_08037DD6: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end intro_end - - thumb_func_start sub_8037DF4 -sub_8037DF4: @ 8037DF4 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - bl GetMultiplayerId - lsls r0, 24 - lsrs r7, r0, 24 - ldr r0, =gBattleScripting - adds r0, 0x25 - strb r7, [r0] - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - ldr r0, =gBattleCommunication - ldrb r0, [r0] - cmp r0, 0xA - bls _08037E20 - b _080383F8 -_08037E20: - lsls r0, 2 - ldr r1, =_08037E38 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08037E38: - .4byte _08037E64 - .4byte _08037EA8 - .4byte _08037F50 - .4byte _08038026 - .4byte _0803804C - .4byte _08038140 - .4byte _08038164 - .4byte _080382CC - .4byte _0803832C - .4byte _0803836C - .4byte _080383BC -_08037E64: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _08037E90 - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg - bl sub_805EF14 - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1] -_08037E90: - ldr r0, =gLinkVSyncDisabled - ldrb r0, [r0] - cmp r0, 0 - bne _08037E9A - b _080383F8 -_08037E9A: - bl sub_800E0E8 - b _080383F8 - .pool -_08037EA8: - ldr r2, =gBattleTypeFlags - ldr r1, [r2] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08037F30 - ldr r0, =gUnknown_03003124 - ldrb r0, [r0] - cmp r0, 0 - bne _08037EBE - b _080383F8 -_08037EBE: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - beq _08037F02 - ldr r4, =gBattleStruct - ldr r0, [r4] - movs r5, 0xC0 - lsls r5, 1 - adds r0, r5 - movs r1, 0 - strb r1, [r0] - ldr r0, [r4] - ldr r2, =0x00000181 - adds r1, r0, r2 - movs r0, 0x3 - strb r0, [r1] - bl sub_8036A5C - bl sub_8036B44 - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, [r4] - adds r1, r5 - movs r2, 0x20 - bl link_0800A448 - ldr r1, =gBattleCommunication - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_08037F02: - ldr r0, =gLinkVSyncDisabled - ldrb r0, [r0] - cmp r0, 0 - bne _08037F0C - b _080383F8 -_08037F0C: - movs r0, 0 - movs r1, 0 - bl sub_800DFB4 - b _080383F8 - .pool -_08037F30: - movs r0, 0x80 - lsls r0, 17 - ands r0, r1 - cmp r0, 0 - bne _08037F40 - movs r0, 0x4 - orrs r1, r0 - str r1, [r2] -_08037F40: - ldr r1, =gBattleCommunication - movs r0, 0x7 - strb r0, [r1] - bl berry_801017C - b _080383F8 - .pool -_08037F50: - bl sub_800A550 - movs r1, 0xF - ands r1, r0 - cmp r1, 0xF - beq _08037F5E - b _080383F8 -_08037F5E: - bl sub_800A5B4 - movs r0, 0x4 - adds r1, r7, 0 - bl sub_8036EB8 - bl berry_801017C - bl sub_8068AA4 - ldr r0, =task00_0800F6FC - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, =gTasks - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r0, r1 - movs r2, 0 - movs r1, 0x87 - lsls r1, 1 - strh r1, [r0, 0xA] - movs r1, 0x5A - strh r1, [r0, 0xC] - strh r2, [r0, 0x12] - strh r2, [r0, 0xE] - strh r2, [r0, 0x10] - ldr r1, =gUnknown_020223C4 - adds r4, r0, 0 - adds r5, r1, 0x2 - movs r7, 0x3F - movs r6, 0x3 -_08037FA4: - ldrh r0, [r5] - str r2, [sp] - bl sub_8185F90 - ldr r0, =gLinkPlayers - ldr r2, [sp] - adds r0, r2, r0 - ldrh r0, [r0, 0x18] - cmp r0, 0x1 - beq _08037FE6 - cmp r0, 0x1 - bgt _08037FD4 - cmp r0, 0 - beq _08037FDE - b _0803800C - .pool -_08037FD4: - cmp r0, 0x2 - beq _08037FEE - cmp r0, 0x3 - beq _08037FFE - b _0803800C -_08037FDE: - ldrh r0, [r5] - adds r1, r7, 0 - ands r1, r0 - b _08037FF6 -_08037FE6: - ldrh r0, [r5] - adds r1, r7, 0 - ands r1, r0 - b _08038006 -_08037FEE: - ldrh r0, [r5] - adds r1, r7, 0 - ands r1, r0 - lsls r1, 6 -_08037FF6: - ldrh r0, [r4, 0xE] - orrs r1, r0 - strh r1, [r4, 0xE] - b _0803800C -_08037FFE: - ldrh r0, [r5] - adds r1, r7, 0 - ands r1, r0 - lsls r1, 6 -_08038006: - ldrh r0, [r4, 0x10] - orrs r1, r0 - strh r1, [r4, 0x10] -_0803800C: - movs r0, 0x80 - lsls r0, 1 - adds r5, r0 - adds r2, 0x1C - subs r6, 0x1 - cmp r6, 0 - bge _08037FA4 - bl ZeroEnemyPartyMons - ldr r1, =gBattleCommunication - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_08038026: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - bne _08038032 - b _080383F8 -_08038032: - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gPlayerParty - movs r2, 0xC8 - bl link_0800A448 - b _080383A6 - .pool -_0803804C: - bl sub_800A550 - movs r1, 0xF - ands r1, r0 - cmp r1, 0xF - beq _0803805A - b _080383F8 -_0803805A: - bl sub_800A5B4 - movs r6, 0 - lsls r0, r7, 3 - subs r0, r7 - lsls r0, 2 - mov r8, r0 - ldr r4, =gUnknown_020223C4 - movs r5, 0 -_0803806C: - cmp r6, r7 - bne _080380A0 - ldr r0, =gLinkPlayers - adds r0, r5, r0 - ldrh r0, [r0, 0x18] - cmp r0, 0x2 - bgt _0803808C - cmp r0, 0x1 - bge _08038098 - cmp r0, 0 - beq _08038090 - b _0803812A - .pool -_0803808C: - cmp r0, 0x3 - bne _0803812A -_08038090: - ldr r0, =gPlayerParty - b _08038110 - .pool -_08038098: - ldr r0, =gPlayerParty + 300 - b _08038110 - .pool -_080380A0: - ldr r2, =gLinkPlayers - adds r0, r5, r2 - ldrh r1, [r0, 0x18] - movs r3, 0x1 - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - bne _080380C4 - mov r1, r8 - adds r0, r1, r2 - ldrh r1, [r0, 0x18] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _080380D2 - b _080380F8 - .pool -_080380C4: - mov r1, r8 - adds r0, r1, r2 - ldrh r1, [r0, 0x18] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _080380F8 -_080380D2: - adds r0, r5, r2 - ldrh r0, [r0, 0x18] - cmp r0, 0x2 - bgt _080380E4 - cmp r0, 0x1 - bge _080380F0 - cmp r0, 0 - beq _080380E8 - b _0803812A -_080380E4: - cmp r0, 0x3 - bne _0803812A -_080380E8: - ldr r0, =gPlayerParty - b _08038110 - .pool -_080380F0: - ldr r0, =gPlayerParty + 300 - b _08038110 - .pool -_080380F8: - adds r0, r5, r2 - ldrh r0, [r0, 0x18] - cmp r0, 0x2 - bgt _0803810A - cmp r0, 0x1 - bge _08038120 - cmp r0, 0 - beq _0803810E - b _0803812A -_0803810A: - cmp r0, 0x3 - bne _0803812A -_0803810E: - ldr r0, =gEnemyParty -_08038110: - adds r1, r4, 0 - movs r2, 0xC8 - bl memcpy - b _0803812A - .pool -_08038120: - ldr r0, =gEnemyParty + 300 - adds r1, r4, 0 - movs r2, 0xC8 - bl memcpy -_0803812A: - movs r2, 0x80 - lsls r2, 1 - adds r4, r2 - adds r5, 0x1C - adds r6, 0x1 - cmp r6, 0x3 - ble _0803806C - b _080383A6 - .pool -_08038140: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - bne _0803814C - b _080383F8 -_0803814C: - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gPlayerParty + 200 - movs r2, 0x64 - bl link_0800A448 - b _080383A6 - .pool -_08038164: - bl sub_800A550 - movs r1, 0xF - ands r1, r0 - cmp r1, 0xF - beq _08038172 - b _080383F8 -_08038172: - bl sub_800A5B4 - movs r6, 0 - lsls r0, r7, 3 - subs r0, r7 - lsls r0, 2 - mov r8, r0 - ldr r4, =gUnknown_020223C4 - movs r5, 0 -_08038184: - cmp r6, r7 - bne _080381B8 - ldr r0, =gLinkPlayers - adds r0, r5, r0 - ldrh r0, [r0, 0x18] - cmp r0, 0x2 - bgt _080381A4 - cmp r0, 0x1 - bge _080381B0 - cmp r0, 0 - beq _080381A8 - b _08038242 - .pool -_080381A4: - cmp r0, 0x3 - bne _08038242 -_080381A8: - ldr r0, =gPlayerParty + 200 - b _08038228 - .pool -_080381B0: - ldr r0, =gPlayerParty + 500 - b _08038228 - .pool -_080381B8: - ldr r2, =gLinkPlayers - adds r0, r5, r2 - ldrh r1, [r0, 0x18] - movs r3, 0x1 - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - bne _080381DC - mov r1, r8 - adds r0, r1, r2 - ldrh r1, [r0, 0x18] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _080381EA - b _08038210 - .pool -_080381DC: - mov r1, r8 - adds r0, r1, r2 - ldrh r1, [r0, 0x18] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _08038210 -_080381EA: - adds r0, r5, r2 - ldrh r0, [r0, 0x18] - cmp r0, 0x2 - bgt _080381FC - cmp r0, 0x1 - bge _08038208 - cmp r0, 0 - beq _08038200 - b _08038242 -_080381FC: - cmp r0, 0x3 - bne _08038242 -_08038200: - ldr r0, =gPlayerParty + 200 - b _08038228 - .pool -_08038208: - ldr r0, =gPlayerParty + 500 - b _08038228 - .pool -_08038210: - adds r0, r5, r2 - ldrh r0, [r0, 0x18] - cmp r0, 0x2 - bgt _08038222 - cmp r0, 0x1 - bge _08038238 - cmp r0, 0 - beq _08038226 - b _08038242 -_08038222: - cmp r0, 0x3 - bne _08038242 -_08038226: - ldr r0, =gEnemyParty + 200 -_08038228: - adds r1, r4, 0 - movs r2, 0x64 - bl memcpy - b _08038242 - .pool -_08038238: - ldr r0, =gEnemyParty + 500 - adds r1, r4, 0 - movs r2, 0x64 - bl memcpy -_08038242: - movs r2, 0x80 - lsls r2, 1 - adds r4, r2 - adds r5, 0x1C - adds r6, 0x1 - cmp r6, 0x3 - ble _08038184 - ldr r4, =gPlayerParty - adds r0, r4, 0 - bl shedinja_something - adds r0, r4, 0 - adds r0, 0x64 - bl shedinja_something - adds r0, r4, 0 - adds r0, 0xC8 - bl shedinja_something - movs r1, 0x96 - lsls r1, 1 - adds r0, r4, r1 - bl shedinja_something - movs r2, 0xC8 - lsls r2, 1 - adds r0, r4, r2 - bl shedinja_something - movs r1, 0xFA - lsls r1, 1 - adds r0, r4, r1 - bl shedinja_something - ldr r4, =gEnemyParty - adds r0, r4, 0 - bl shedinja_something - adds r0, r4, 0 - adds r0, 0x64 - bl shedinja_something - adds r0, r4, 0 - adds r0, 0xC8 - bl shedinja_something - movs r2, 0x96 - lsls r2, 1 - adds r0, r4, r2 - bl shedinja_something - movs r1, 0xC8 - lsls r1, 1 - adds r0, r4, r1 - bl shedinja_something - movs r2, 0xFA - lsls r2, 1 - adds r0, r4, r2 - bl shedinja_something - b _080383A6 - .pool -_080382CC: - bl sub_8032768 - bl sub_8184E58 - ldr r3, =gBattleCommunication - movs r0, 0 - strb r0, [r3, 0x1] - strb r0, [r3, 0x2] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08038326 - movs r6, 0 - ldr r0, =gLinkPlayers - ldrb r1, [r0] - adds r4, r3, 0 - adds r2, r0, 0 - cmp r1, 0x3 - bne _0803830A - movs r3, 0xFF -_080382F8: - adds r2, 0x1C - adds r6, 0x1 - cmp r6, 0x3 - bgt _0803830A - ldrh r1, [r2] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0x3 - beq _080382F8 -_0803830A: - cmp r6, 0x4 - bne _08038320 - movs r0, 0x8 - strb r0, [r4] - b _080383F8 - .pool -_08038320: - movs r0, 0xA - strb r0, [r4] - b _080383F8 -_08038326: - movs r0, 0xA - strb r0, [r3] - b _080383F8 -_0803832C: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - beq _080383F8 - ldr r0, =gBattleStruct - ldr r4, [r0] - movs r0, 0xC0 - lsls r0, 1 - adds r4, r0 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - str r0, [r4] - ldr r0, =gUnknown_0203BD2C - ldr r0, [r0] - str r0, [r4, 0x4] - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - adds r1, r4, 0 - movs r2, 0x8 - bl link_0800A448 - b _080383A6 - .pool -_0803836C: - bl sub_800A550 - movs r1, 0xF - ands r1, r0 - cmp r1, 0xF - bne _080383F8 - bl sub_800A5B4 - movs r2, 0 - b _08038386 -_08038380: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 -_08038386: - cmp r2, 0x3 - bhi _080383A6 - ldr r4, =gUnknown_020223C4 - lsls r3, r2, 8 - adds r0, r3, r4 - ldrh r0, [r0] - movs r1, 0x4 - ands r0, r1 - cmp r0, 0 - beq _08038380 - adds r1, r4, 0x4 - adds r1, r3, r1 - ldr r0, =gUnknown_0203BD2C - movs r2, 0x4 - bl memcpy -_080383A6: - ldr r1, =gBattleCommunication - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _080383F8 - .pool -_080383BC: - ldr r0, =gUnknown_02024333 - adds r1, r0, 0x1 - bl battle_load_something - lsls r0, 24 - cmp r0, 0 - beq _080383F8 - ldr r2, =gUnknown_03005D00 - ldr r1, =gMain - ldr r0, [r1] - str r0, [r2] - ldr r0, =sub_8039EF0 - str r0, [r1] - ldr r0, =BattleMainCB2 - bl SetMainCallback2 - ldr r3, =gBattleTypeFlags - ldr r2, [r3] - movs r0, 0x2 - ands r0, r2 - cmp r0, 0 - beq _080383F8 - ldr r0, =gTrainerBattleOpponent_A - movs r4, 0x80 - lsls r4, 4 - adds r1, r4, 0 - strh r1, [r0] - movs r0, 0x20 - orrs r2, r0 - str r2, [r3] -_080383F8: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8037DF4 - - thumb_func_start BattleMainCB2 -BattleMainCB2: @ 8038420 - push {lr} - sub sp, 0x4 - bl AnimateSprites - bl BuildOamBuffer - bl RunTextPrinters - bl UpdatePaletteFade - bl RunTasks - ldr r0, =gMain - ldrh r1, [r0, 0x2C] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08038482 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 17 - ands r0, r1 - cmp r0, 0 - beq _08038482 - bl rfu_lacks_rfufunc - lsls r0, 24 - cmp r0, 0 - beq _08038482 - ldr r2, =gScriptResult - ldr r1, =gBattleOutcome - movs r0, 0x5 - strb r0, [r1] - movs r0, 0x5 - strh r0, [r2] - bl ResetPaletteFadeControl - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, =sub_80384E4 - bl SetMainCallback2 -_08038482: - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end BattleMainCB2 - - thumb_func_start sub_803849C -sub_803849C: @ 803849C - push {lr} - ldr r1, =gMain - ldr r0, =gUnknown_03005D00 - ldr r0, [r0] - str r0, [r1] - ldr r2, =gUnknown_02039B28 - movs r0, 0x3 - strb r0, [r2, 0x15] - ldr r0, =0x00000439 - adds r1, r0 - ldrb r2, [r1] - movs r0, 0x3 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - bl ZeroEnemyPartyMons - movs r0, 0x5A - bl m4aSongNumStop - bl sub_805F094 - bl dp11_free - bl sub_8057028 - pop {r0} - bx r0 - .pool - thumb_func_end sub_803849C - - thumb_func_start sub_80384E4 -sub_80384E4: @ 80384E4 - push {lr} - bl UpdatePaletteFade - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08038512 - ldr r0, =gMPlay_SE1 - bl m4aMPlayStop - ldr r0, =gMPlay_SE2 - bl m4aMPlayStop - bl sub_803849C - bl FreeAllWindowBuffers - ldr r0, =gMain - ldr r0, [r0, 0x8] - bl SetMainCallback2 -_08038512: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80384E4 - - thumb_func_start sub_8038528 -sub_8038528: @ 8038528 - movs r1, 0 - strh r1, [r0, 0x2E] - ldr r1, =sub_8038538 - str r1, [r0, 0x1C] - bx lr - .pool - thumb_func_end sub_8038528 - - thumb_func_start sub_8038538 -sub_8038538: @ 8038538 - push {r4,r5,lr} - adds r3, r0, 0 - ldr r5, =0x0201c000 - movs r0, 0x2E - ldrsh r1, [r3, r0] - cmp r1, 0x1 - beq _0803856C - cmp r1, 0x1 - bgt _08038554 - cmp r1, 0 - beq _0803855A - b _080385DC - .pool -_08038554: - cmp r1, 0x2 - beq _080385C8 - b _080385DC -_0803855A: - ldrh r0, [r3, 0x2E] - adds r0, 0x1 - strh r0, [r3, 0x2E] - strh r1, [r3, 0x30] - ldr r0, =0x00000281 - strh r0, [r3, 0x32] - strh r1, [r3, 0x34] - movs r0, 0x1 - strh r0, [r3, 0x36] -_0803856C: - ldrh r0, [r3, 0x36] - subs r0, 0x1 - strh r0, [r3, 0x36] - lsls r0, 16 - cmp r0, 0 - bne _080385DC - movs r0, 0x2 - strh r0, [r3, 0x36] - movs r4, 0x30 - ldrsh r2, [r3, r4] - movs r0, 0x34 - ldrsh r1, [r3, r0] - lsls r1, 5 - adds r2, r1 - movs r4, 0x32 - ldrsh r0, [r3, r4] - subs r0, r1 - movs r4, 0x3D - lsls r0, 1 - adds r0, r5 - lsls r2, 1 - adds r2, r5 - movs r1, 0x1C -_0803859A: - strh r4, [r2] - strh r4, [r0] - adds r0, 0x4 - adds r2, 0x4 - subs r1, 0x2 - cmp r1, 0 - bge _0803859A - ldrh r0, [r3, 0x34] - adds r0, 0x1 - strh r0, [r3, 0x34] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x15 - bne _080385DC - ldrh r0, [r3, 0x2E] - adds r0, 0x1 - strh r0, [r3, 0x2E] - movs r0, 0x20 - strh r0, [r3, 0x30] - b _080385DC - .pool -_080385C8: - ldrh r0, [r3, 0x30] - subs r0, 0x1 - strh r0, [r3, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x14 - bne _080385DC - ldr r0, =sub_8036760 - bl SetMainCallback2 -_080385DC: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8038538 - - thumb_func_start CreateNPCTrainerParty -CreateNPCTrainerParty: @ 80385E8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x28 - str r0, [sp, 0x10] - lsls r1, 16 - lsrs r1, 16 - str r1, [sp, 0x14] - lsls r2, 24 - lsrs r2, 24 - movs r0, 0 - mov r9, r0 - movs r0, 0x80 - lsls r0, 3 - cmp r1, r0 - bne _08038610 - movs r0, 0 - b _080389E2 -_08038610: - ldr r4, =gBattleTypeFlags - ldr r0, [r4] - ldr r1, =0x043f0908 - ands r0, r1 - ldr r1, [sp, 0x14] - lsls r1, 2 - str r1, [sp, 0x20] - cmp r0, 0x8 - beq _08038624 - b _080389D2 -_08038624: - cmp r2, 0x1 - bne _0803862C - bl ZeroEnemyPartyMons -_0803862C: - ldr r0, [r4] - movs r1, 0x80 - lsls r1, 8 - ands r0, r1 - cmp r0, 0 - beq _08038668 - ldr r0, =gTrainers - ldr r2, [sp, 0x20] - ldr r3, [sp, 0x14] - adds r1, r2, r3 - lsls r1, 3 - adds r1, r0 - adds r2, r1, 0 - adds r2, 0x20 - ldrb r1, [r2] - movs r4, 0x3 - str r4, [sp, 0x1C] - adds r4, r0, 0 - cmp r1, 0x3 - bhi _0803867C - adds r2, r1, 0 - str r2, [sp, 0x1C] - b _0803867C - .pool -_08038668: - ldr r1, =gTrainers - ldr r2, [sp, 0x20] - ldr r3, [sp, 0x14] - adds r0, r2, r3 - lsls r0, 3 - adds r0, r1 - adds r0, 0x20 - ldrb r0, [r0] - str r0, [sp, 0x1C] - adds r4, r1, 0 -_0803867C: - movs r0, 0 - str r0, [sp, 0x18] - b _080389B4 - .pool -_08038688: - ldr r2, [sp, 0x20] - ldr r3, [sp, 0x14] - adds r0, r2, r3 - lsls r0, 3 - adds r1, r0, r4 - ldrb r0, [r1, 0x18] - cmp r0, 0x1 - bne _0803869E - movs r0, 0x80 - mov r10, r0 - b _080386B0 -_0803869E: - ldrb r1, [r1, 0x2] - movs r0, 0x80 - ands r0, r1 - movs r1, 0x88 - mov r10, r1 - cmp r0, 0 - beq _080386B0 - movs r2, 0x78 - mov r10, r2 -_080386B0: - movs r6, 0 - ldr r2, [sp, 0x20] - ldr r3, [sp, 0x14] - adds r0, r2, r3 - lsls r0, 3 - adds r1, r4, 0x4 - adds r0, r1 - ldrb r0, [r0] - ldr r3, [sp, 0x18] - adds r3, 0x1 - str r3, [sp, 0x24] - cmp r0, 0xFF - beq _080386E6 - adds r3, r1, 0 -_080386CC: - ldr r0, [sp, 0x14] - adds r1, r2, r0 - lsls r1, 3 - adds r0, r6, r1 - adds r0, r3 - ldrb r0, [r0] - add r9, r0 - adds r6, 0x1 - adds r1, r6, r1 - adds r1, r3 - ldrb r0, [r1] - cmp r0, 0xFF - bne _080386CC -_080386E6: - ldr r1, [sp, 0x20] - ldr r2, [sp, 0x14] - adds r0, r1, r2 - lsls r1, r0, 3 - adds r0, r1, r4 - ldrb r0, [r0] - cmp r0, 0x1 - beq _08038794 - cmp r0, 0x1 - bgt _08038700 - cmp r0, 0 - beq _0803870E - b _080389AC -_08038700: - cmp r0, 0x2 - bne _08038706 - b _08038854 -_08038706: - cmp r0, 0x3 - bne _0803870C - b _080388E8 -_0803870C: - b _080389AC -_0803870E: - adds r0, r4, 0 - adds r0, 0x24 - adds r0, r1, r0 - ldr r4, [r0] - movs r6, 0 - ldr r3, [sp, 0x18] - lsls r2, r3, 3 - adds r0, r2, r4 - ldrh r1, [r0, 0x4] - movs r0, 0xB - muls r0, r1 - ldr r1, =gSpeciesNames - adds r0, r1 - ldrb r0, [r0] - adds r5, r2, 0 - cmp r0, 0xFF - beq _08038750 - adds r3, r1, 0 - movs r7, 0xB -_08038734: - adds r0, r2, r4 - ldrh r0, [r0, 0x4] - adds r1, r0, 0 - muls r1, r7 - adds r0, r6, r1 - adds r0, r3 - ldrb r0, [r0] - add r9, r0 - adds r6, 0x1 - adds r1, r6, r1 - adds r1, r3 - ldrb r0, [r1] - cmp r0, 0xFF - bne _08038734 -_08038750: - mov r2, r9 - lsls r0, r2, 8 - add r10, r0 - adds r4, r5, r4 - ldrh r1, [r4] - lsls r0, r1, 5 - subs r0, r1 - movs r1, 0xFF - bl __divsi3 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r3, [sp, 0x18] - movs r1, 0x64 - adds r0, r3, 0 - muls r0, r1 - ldr r2, [sp, 0x10] - adds r0, r2, r0 - ldrh r1, [r4, 0x4] - ldrb r2, [r4, 0x2] - movs r3, 0x1 - str r3, [sp] - mov r3, r10 - str r3, [sp, 0x4] - movs r3, 0x2 - str r3, [sp, 0x8] - movs r3, 0 - str r3, [sp, 0xC] - adds r3, r6, 0 - bl CreateMon - b _080389AC - .pool -_08038794: - adds r0, r4, 0 - adds r0, 0x24 - adds r0, r1, r0 - ldr r7, [r0] - movs r6, 0 - ldr r4, [sp, 0x18] - lsls r2, r4, 4 - adds r0, r2, r7 - ldrh r1, [r0, 0x4] - movs r0, 0xB - muls r0, r1 - ldr r1, =gSpeciesNames - adds r0, r1 - ldrb r0, [r0] - mov r8, r2 - cmp r0, 0xFF - beq _080387D6 - adds r3, r1, 0 - movs r4, 0xB -_080387BA: - adds r0, r2, r7 - ldrh r0, [r0, 0x4] - adds r1, r0, 0 - muls r1, r4 - adds r0, r6, r1 - adds r0, r3 - ldrb r0, [r0] - add r9, r0 - adds r6, 0x1 - adds r1, r6, r1 - adds r1, r3 - ldrb r0, [r1] - cmp r0, 0xFF - bne _080387BA -_080387D6: - mov r2, r9 - lsls r0, r2, 8 - add r10, r0 - mov r3, r8 - adds r4, r3, r7 - ldrh r1, [r4] - lsls r0, r1, 5 - subs r0, r1 - movs r1, 0xFF - bl __divsi3 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, [sp, 0x18] - movs r1, 0x64 - adds r5, r0, 0 - muls r5, r1 - ldr r2, [sp, 0x10] - adds r5, r2, r5 - ldrh r1, [r4, 0x4] - ldrb r2, [r4, 0x2] - movs r0, 0x1 - str r0, [sp] - mov r3, r10 - str r3, [sp, 0x4] - movs r0, 0x2 - str r0, [sp, 0x8] - movs r0, 0 - str r0, [sp, 0xC] - adds r0, r5, 0 - adds r3, r6, 0 - bl CreateMon - movs r6, 0 - mov r0, r8 - adds r0, 0x6 - adds r4, r7, r0 -_08038820: - adds r1, r6, 0 - adds r1, 0xD - adds r0, r5, 0 - adds r2, r4, 0 - bl SetMonData - adds r1, r6, 0 - adds r1, 0x11 - ldrh r0, [r4] - lsls r2, r0, 1 - adds r2, r0 - lsls r2, 2 - ldr r0, =gBattleMoves + 0x4 @ PP offset - adds r2, r0 - adds r0, r5, 0 - bl SetMonData - adds r4, 0x2 - adds r6, 0x1 - cmp r6, 0x3 - ble _08038820 - b _080389AC - .pool -_08038854: - adds r0, r4, 0 - adds r0, 0x24 - adds r0, r1, r0 - ldr r4, [r0] - movs r6, 0 - ldr r0, [sp, 0x18] - lsls r2, r0, 3 - adds r0, r2, r4 - ldrh r1, [r0, 0x4] - movs r0, 0xB - muls r0, r1 - ldr r1, =gSpeciesNames - adds r0, r1 - ldrb r0, [r0] - adds r5, r2, 0 - cmp r0, 0xFF - beq _08038896 - adds r3, r1, 0 - movs r7, 0xB -_0803887A: - adds r0, r2, r4 - ldrh r0, [r0, 0x4] - adds r1, r0, 0 - muls r1, r7 - adds r0, r6, r1 - adds r0, r3 - ldrb r0, [r0] - add r9, r0 - adds r6, 0x1 - adds r1, r6, r1 - adds r1, r3 - ldrb r0, [r1] - cmp r0, 0xFF - bne _0803887A -_08038896: - mov r2, r9 - lsls r0, r2, 8 - add r10, r0 - adds r5, r4 - ldrh r1, [r5] - lsls r0, r1, 5 - subs r0, r1 - movs r1, 0xFF - bl __divsi3 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r3, [sp, 0x18] - movs r0, 0x64 - adds r4, r3, 0 - muls r4, r0 - ldr r1, [sp, 0x10] - adds r4, r1, r4 - ldrh r1, [r5, 0x4] - ldrb r2, [r5, 0x2] - movs r0, 0x1 - str r0, [sp] - mov r3, r10 - str r3, [sp, 0x4] - movs r0, 0x2 - str r0, [sp, 0x8] - movs r0, 0 - str r0, [sp, 0xC] - adds r0, r4, 0 - adds r3, r6, 0 - bl CreateMon - adds r5, 0x6 - adds r0, r4, 0 - movs r1, 0xC - adds r2, r5, 0 - bl SetMonData - b _080389AC - .pool -_080388E8: - adds r0, r4, 0 - adds r0, 0x24 - adds r0, r1, r0 - ldr r7, [r0] - movs r6, 0 - ldr r4, [sp, 0x18] - lsls r2, r4, 4 - adds r0, r2, r7 - ldrh r1, [r0, 0x4] - movs r0, 0xB - muls r0, r1 - ldr r1, =gSpeciesNames - adds r0, r1 - ldrb r0, [r0] - mov r8, r2 - cmp r0, 0xFF - beq _0803892A - adds r3, r1, 0 - movs r4, 0xB -_0803890E: - adds r0, r2, r7 - ldrh r0, [r0, 0x4] - adds r1, r0, 0 - muls r1, r4 - adds r0, r6, r1 - adds r0, r3 - ldrb r0, [r0] - add r9, r0 - adds r6, 0x1 - adds r1, r6, r1 - adds r1, r3 - ldrb r0, [r1] - cmp r0, 0xFF - bne _0803890E -_0803892A: - mov r2, r9 - lsls r0, r2, 8 - add r10, r0 - mov r3, r8 - adds r5, r3, r7 - ldrh r1, [r5] - lsls r0, r1, 5 - subs r0, r1 - movs r1, 0xFF - bl __divsi3 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, [sp, 0x18] - movs r1, 0x64 - adds r4, r0, 0 - muls r4, r1 - ldr r2, [sp, 0x10] - adds r4, r2, r4 - ldrh r1, [r5, 0x4] - ldrb r2, [r5, 0x2] - movs r0, 0x1 - str r0, [sp] - mov r3, r10 - str r3, [sp, 0x4] - movs r0, 0x2 - str r0, [sp, 0x8] - movs r0, 0 - str r0, [sp, 0xC] - adds r0, r4, 0 - adds r3, r6, 0 - bl CreateMon - adds r5, 0x6 - adds r0, r4, 0 - movs r1, 0xC - adds r2, r5, 0 - bl SetMonData - movs r6, 0 - adds r5, r4, 0 - mov r0, r8 - adds r0, 0x8 - adds r4, r7, r0 -_08038982: - adds r1, r6, 0 - adds r1, 0xD - adds r0, r5, 0 - adds r2, r4, 0 - bl SetMonData - adds r1, r6, 0 - adds r1, 0x11 - ldrh r0, [r4] - lsls r2, r0, 1 - adds r2, r0 - lsls r2, 2 - ldr r0, =gBattleMoves + 0x4 @ PP offset - adds r2, r0 - adds r0, r5, 0 - bl SetMonData - adds r4, 0x2 - adds r6, 0x1 - cmp r6, 0x3 - ble _08038982 -_080389AC: - ldr r4, [sp, 0x24] - str r4, [sp, 0x18] - ldr r4, =gTrainers - ldr r0, [sp, 0x18] -_080389B4: - ldr r1, [sp, 0x1C] - cmp r0, r1 - bge _080389BC - b _08038688 -_080389BC: - ldr r2, =gBattleTypeFlags - ldr r1, =gTrainers - ldr r3, [sp, 0x20] - ldr r4, [sp, 0x14] - adds r0, r3, r4 - lsls r0, 3 - adds r0, r1 - ldrb r1, [r0, 0x18] - ldr r0, [r2] - orrs r0, r1 - str r0, [r2] -_080389D2: - ldr r0, =gTrainers - ldr r2, [sp, 0x20] - ldr r3, [sp, 0x14] - adds r1, r2, r3 - lsls r1, 3 - adds r1, r0 - adds r1, 0x20 - ldrb r0, [r1] -_080389E2: - add sp, 0x28 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end CreateNPCTrainerParty - - thumb_func_start sub_8038A04 -sub_8038A04: @ 8038A04 - push {lr} - ldr r0, =0x04000006 - ldrh r0, [r0] - subs r0, 0x6F - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x30 - bhi _08038A1E - movs r1, 0x98 - lsls r1, 8 - movs r0, 0x8 - bl SetGpuReg -_08038A1E: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8038A04 - - thumb_func_start VBlankCB_Battle -VBlankCB_Battle: @ 8038A28 - push {lr} - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ldr r1, =0x013f0102 - ands r0, r1 - cmp r0, 0 - bne _08038A3A - bl Random -_08038A3A: - ldr r0, =gUnknown_02022E14 - ldrh r1, [r0] - movs r0, 0x10 - bl SetGpuReg - ldr r0, =gUnknown_02022E16 - ldrh r1, [r0] - movs r0, 0x12 - bl SetGpuReg - ldr r0, =gBattle_BG1_X - ldrh r1, [r0] - movs r0, 0x14 - bl SetGpuReg - ldr r0, =gBattle_BG1_Y - ldrh r1, [r0] - movs r0, 0x16 - bl SetGpuReg - ldr r0, =gBattle_BG2_X - ldrh r1, [r0] - movs r0, 0x18 - bl SetGpuReg - ldr r0, =gBattle_BG2_Y - ldrh r1, [r0] - movs r0, 0x1A - bl SetGpuReg - ldr r0, =gBattle_BG3_X - ldrh r1, [r0] - movs r0, 0x1C - bl SetGpuReg - ldr r0, =gUnknown_02022E22 - ldrh r1, [r0] - movs r0, 0x1E - bl SetGpuReg - ldr r0, =gUnknown_02022E24 - ldrh r1, [r0] - movs r0, 0x40 - bl SetGpuReg - ldr r0, =gUnknown_02022E26 - ldrh r1, [r0] - movs r0, 0x44 - bl SetGpuReg - ldr r0, =gUnknown_02022E28 - ldrh r1, [r0] - movs r0, 0x42 - bl SetGpuReg - ldr r0, =gUnknown_02022E2A - ldrh r1, [r0] - movs r0, 0x46 - bl SetGpuReg - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - bl sub_80BA0A8 - pop {r0} - bx r0 - .pool - thumb_func_end VBlankCB_Battle - - thumb_func_start nullsub_17 -nullsub_17: @ 8038B00 - bx lr - thumb_func_end nullsub_17 - - thumb_func_start sub_8038B04 -sub_8038B04: @ 8038B04 - push {r4,r5,lr} - adds r5, r0, 0 - movs r1, 0x2E - ldrsh r0, [r5, r1] - cmp r0, 0 - beq _08038B24 - movs r1, 0x32 - ldrsh r0, [r5, r1] - movs r1, 0xFF - lsls r1, 8 - ands r0, r1 - lsrs r0, 8 - ldrh r1, [r5, 0x30] - adds r0, r1 - strh r0, [r5, 0x20] - b _08038B36 -_08038B24: - movs r1, 0x32 - ldrsh r0, [r5, r1] - movs r1, 0xFF - lsls r1, 8 - ands r0, r1 - asrs r0, 8 - ldrh r1, [r5, 0x30] - subs r1, r0 - strh r1, [r5, 0x20] -_08038B36: - movs r1, 0xC0 - lsls r1, 1 - adds r0, r1, 0 - ldrh r1, [r5, 0x32] - adds r0, r1 - strh r0, [r5, 0x32] - adds r0, r5, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _08038B6A - ldr r4, =0x00002710 - adds r0, r4, 0 - bl FreeSpriteTilesByTag - adds r0, r4, 0 - bl FreeSpritePaletteByTag - adds r0, r5, 0 - bl FreeSpriteOamMatrix - adds r0, r5, 0 - bl DestroySprite -_08038B6A: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8038B04 - - thumb_func_start sub_8038B74 -sub_8038B74: @ 8038B74 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x1 - bl StartSpriteAffineAnim - ldr r0, =sub_8038B04 - str r0, [r4, 0x1C] - movs r0, 0x68 - bl PlaySE - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8038B74 - - thumb_func_start sub_8038B94 -sub_8038B94: @ 8038B94 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - movs r1, 0 - str r1, [sp, 0x8] - ldr r0, =gBattleScripting - adds r0, 0x25 - ldrb r2, [r0] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _08038C04 - ldr r1, =gLinkPlayers - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r1 - ldrh r0, [r0, 0x18] - cmp r0, 0x1 - beq _08038BF0 - cmp r0, 0x1 - bgt _08038BE8 - cmp r0, 0 - beq _08038C04 - b _08038C0C - .pool -_08038BE8: - cmp r0, 0x2 - beq _08038C04 - cmp r0, 0x3 - bne _08038C0C -_08038BF0: - ldr r0, =gEnemyParty - str r0, [sp, 0x4] - ldr r1, =gPlayerParty - str r1, [sp, 0x8] - b _08038C0C - .pool -_08038C04: - ldr r2, =gPlayerParty - str r2, [sp, 0x4] - ldr r3, =gEnemyParty - str r3, [sp, 0x8] -_08038C0C: - movs r7, 0 - movs r0, 0 - mov r8, r0 - ldr r1, [sp] - lsls r1, 2 - str r1, [sp, 0xC] - movs r2, 0xCE - lsls r2, 1 - mov r10, r2 - mov r9, r0 -_08038C20: - movs r0, 0x64 - mov r4, r8 - muls r4, r0 - ldr r3, [sp, 0x4] - adds r4, r3, r4 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - lsls r0, 16 - lsrs r6, r0, 16 - adds r0, r4, 0 - movs r1, 0x37 - bl GetMonData - adds r1, r0, 0 - cmp r5, 0 - beq _08038C90 - cmp r5, r10 - beq _08038C64 - cmp r6, 0 - beq _08038C64 - cmp r1, 0 - bne _08038C64 - movs r0, 0x1 - mov r2, r9 - lsls r0, r2 - orrs r7, r0 -_08038C64: - cmp r5, 0 - beq _08038C90 - cmp r6, 0 - beq _08038C7C - cmp r5, r10 - beq _08038C74 - cmp r1, 0 - beq _08038C7C -_08038C74: - movs r0, 0x2 - mov r3, r9 - lsls r0, r3 - orrs r7, r0 -_08038C7C: - cmp r5, 0 - beq _08038C90 - cmp r5, r10 - beq _08038C90 - cmp r6, 0 - bne _08038C90 - movs r0, 0x3 - mov r1, r9 - lsls r0, r1 - orrs r7, r0 -_08038C90: - movs r2, 0x2 - add r9, r2 - movs r3, 0x1 - add r8, r3 - mov r0, r8 - cmp r0, 0x5 - ble _08038C20 - ldr r1, =gTasks - ldr r2, [sp, 0xC] - ldr r3, [sp] - adds r0, r2, r3 - lsls r0, 3 - adds r0, r1 - strh r7, [r0, 0xE] - movs r7, 0 - movs r0, 0 - mov r8, r0 - movs r1, 0xCE - lsls r1, 1 - mov r10, r1 - mov r9, r0 -_08038CBA: - movs r0, 0x64 - mov r4, r8 - muls r4, r0 - ldr r2, [sp, 0x8] - adds r4, r2, r4 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - lsls r0, 16 - lsrs r6, r0, 16 - adds r0, r4, 0 - movs r1, 0x37 - bl GetMonData - adds r1, r0, 0 - cmp r5, 0 - beq _08038D2A - cmp r5, r10 - beq _08038CFE - cmp r6, 0 - beq _08038CFE - cmp r1, 0 - bne _08038CFE - movs r0, 0x1 - mov r3, r9 - lsls r0, r3 - orrs r7, r0 -_08038CFE: - cmp r5, 0 - beq _08038D2A - cmp r6, 0 - beq _08038D16 - cmp r5, r10 - beq _08038D0E - cmp r1, 0 - beq _08038D16 -_08038D0E: - movs r0, 0x2 - mov r1, r9 - lsls r0, r1 - orrs r7, r0 -_08038D16: - cmp r5, 0 - beq _08038D2A - cmp r5, r10 - beq _08038D2A - cmp r6, 0 - bne _08038D2A - movs r0, 0x3 - mov r2, r9 - lsls r0, r2 - orrs r7, r0 -_08038D2A: - movs r3, 0x2 - add r9, r3 - movs r0, 0x1 - add r8, r0 - mov r1, r8 - cmp r1, 0x5 - ble _08038CBA - ldr r1, =gTasks - ldr r2, [sp, 0xC] - ldr r3, [sp] - adds r0, r2, r3 - lsls r0, 3 - adds r0, r1 - strh r7, [r0, 0x10] - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8038B94 - - thumb_func_start sub_8038D64 -sub_8038D64: @ 8038D64 - push {r4,lr} - sub sp, 0x4 - movs r0, 0 - bl SetHBlankCallback - movs r0, 0 - bl SetVBlankCallback - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r2, 0x21 - negs r2, r2 - ands r1, r2 - str r1, [r0] - ldr r0, =0x003f0100 - ands r0, r1 - cmp r0, 0 - beq _08038DAC - ldr r0, =gMain - ldr r0, [r0, 0x8] - bl SetMainCallback2 - bl sub_8057028 - bl dp11_free - bl sub_805F094 - b _08038EB6 - .pool -_08038DAC: - str r0, [sp] - movs r1, 0xC0 - lsls r1, 19 - ldr r2, =0x05006000 - mov r0, sp - bl CpuSet - movs r0, 0x4C - movs r1, 0 - bl SetGpuReg - movs r0, 0x40 - movs r1, 0xF0 - bl SetGpuReg - ldr r4, =0x00005051 - movs r0, 0x44 - adds r1, r4, 0 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0 - bl SetGpuReg - movs r0, 0x4A - movs r1, 0 - bl SetGpuReg - ldr r1, =gUnknown_02022E24 - movs r0, 0xF0 - strh r0, [r1] - ldr r0, =gUnknown_02022E26 - strh r4, [r0] - bl dp12_8087EA4 - ldr r0, =gUnknown_02038C28 - movs r3, 0xF0 - movs r1, 0xF0 - lsls r1, 3 - adds r2, r0, r1 - movs r1, 0x4F -_08038DFE: - strh r3, [r0] - strh r3, [r2] - adds r2, 0x2 - adds r0, 0x2 - subs r1, 0x1 - cmp r1, 0 - bge _08038DFE - movs r1, 0x50 - ldr r0, =gUnknown_02038C28 - ldr r3, =0x0000ff10 - movs r4, 0x82 - lsls r4, 4 - adds r2, r0, r4 - adds r0, 0xA0 -_08038E1A: - strh r3, [r0] - strh r3, [r2] - adds r2, 0x2 - adds r0, 0x2 - adds r1, 0x1 - cmp r1, 0x9F - ble _08038E1A - bl ResetPaletteFade - ldr r0, =gUnknown_02022E14 - movs r4, 0 - strh r4, [r0] - ldr r0, =gUnknown_02022E16 - strh r4, [r0] - ldr r0, =gBattle_BG1_X - strh r4, [r0] - ldr r0, =gBattle_BG1_Y - strh r4, [r0] - ldr r0, =gBattle_BG2_X - strh r4, [r0] - ldr r0, =gBattle_BG2_Y - strh r4, [r0] - ldr r0, =gBattle_BG3_X - strh r4, [r0] - ldr r0, =gUnknown_02022E22 - strh r4, [r0] - bl c2_berry_program_update_menu - ldr r0, =gUnknown_08C004E0 - movs r1, 0 - movs r2, 0x40 - bl LoadCompressedPalette - bl sub_803570C - bl ResetSpriteData - bl ResetTasks - bl sub_8036154 - movs r0, 0x4A - movs r1, 0x37 - bl SetGpuReg - bl FreeAllSpritePalettes - ldr r1, =gReservedSpritePaletteCount - movs r0, 0x4 - strb r0, [r1] - ldr r0, =VBlankCB_Battle - bl SetVBlankCallback - ldr r0, =task00_0800F6FC - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - movs r2, 0x87 - lsls r2, 1 - strh r2, [r1, 0xA] - movs r2, 0x5A - strh r2, [r1, 0xC] - movs r2, 0x1 - strh r2, [r1, 0x12] - bl sub_8038B94 - ldr r0, =sub_8038F14 - bl SetMainCallback2 - ldr r0, =gBattleCommunication - strb r4, [r0] -_08038EB6: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8038D64 - - thumb_func_start sub_8038F14 -sub_8038F14: @ 8038F14 - push {lr} - bl sub_8038F34 - bl AnimateSprites - bl BuildOamBuffer - bl RunTextPrinters - bl UpdatePaletteFade - bl RunTasks - pop {r0} - bx r0 - thumb_func_end sub_8038F14 - - thumb_func_start sub_8038F34 -sub_8038F34: @ 8038F34 - push {r4-r6,lr} - sub sp, 0x8 - ldr r0, =gBattleCommunication - ldrb r1, [r0] - adds r4, r0, 0 - cmp r1, 0x9 - bls _08038F44 - b _080391C6 -_08038F44: - lsls r0, r1, 2 - ldr r1, =_08038F58 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08038F58: - .4byte _08038F80 - .4byte _08038FA0 - .4byte _08038FC2 - .4byte _080390C8 - .4byte _08039100 - .4byte _08039118 - .4byte _0803912C - .4byte _0803914C - .4byte _08039166 - .4byte _08039184 -_08038F80: - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - ldr r1, =gBattleCommunication - movs r0, 0xFF - strb r0, [r1, 0x1] - b _08039174 - .pool -_08038FA0: - ldrb r0, [r4, 0x1] - subs r0, 0x1 - strb r0, [r4, 0x1] - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - beq _08038FB0 - b _080391C6 -_08038FB0: - movs r0, 0x1 - negs r0, r0 - str r1, [sp] - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - b _0803910C -_08038FC2: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08038FD0 - b _080391C6 -_08038FD0: - bl sub_8185FAC - ldr r2, =gMain - ldr r1, =0x00000439 - adds r2, r1 - movs r1, 0x1 - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - movs r3, 0x2 - cmp r0, 0 - beq _08038FFC - movs r3, 0x4 -_08038FFC: - movs r4, 0 - ldr r6, =gSaveBlock2Ptr - cmp r4, r3 - bge _08039022 - ldr r1, =gLinkPlayers - ldrb r0, [r1] - cmp r0, 0x3 - bne _08039022 - movs r5, 0xFF - adds r2, r1, 0 -_08039010: - adds r2, 0x1C - adds r4, 0x1 - cmp r4, r3 - bge _08039022 - ldrh r1, [r2] - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0x3 - beq _08039010 -_08039022: - ldr r0, [r6] - ldr r1, =0x00000ca9 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - bne _080390AC - cmp r4, r3 - bne _080390AC - ldr r0, =0x000008d2 - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _08039074 - bl FreeAllWindowBuffers - ldr r0, =sub_80392A8 - bl SetMainCallback2 - b _080391C6 - .pool -_08039074: - ldr r2, =gMain - ldr r1, =0x00000439 - adds r0, r2, r1 - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - bne _08039090 - ldr r0, [r2, 0x8] - b _080390B0 - .pool -_08039090: - ldr r0, =gUnknown_03003124 - ldrb r0, [r0] - cmp r0, 0 - bne _08039172 - ldr r0, =sub_80B3AF8 - movs r1, 0x5 - bl CreateTask - b _08039172 - .pool -_080390AC: - ldr r0, =gMain - ldr r0, [r0, 0x8] -_080390B0: - bl SetMainCallback2 - bl sub_8057028 - bl dp11_free - bl sub_805F094 - b _080391C6 - .pool -_080390C8: - movs r0, 0 - str r0, [sp, 0x4] - movs r1, 0xC0 - lsls r1, 19 - ldr r2, =0x05006000 - add r0, sp, 0x4 - bl CpuSet - movs r4, 0 -_080390DA: - lsls r0, r4, 24 - lsrs r0, 24 - bl sub_80363C4 - adds r4, 0x1 - cmp r4, 0x1 - ble _080390DA - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - b _08039172 - .pool -_08039100: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _080391C6 -_0803910C: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - b _080391C6 - .pool -_08039118: - ldr r0, =sub_80B3AF8 - bl FuncIsActiveTask - lsls r0, 24 - cmp r0, 0 - bne _080391C6 - b _08039172 - .pool -_0803912C: - bl sub_800A520 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080391C6 - bl sub_800ADF8 - ldr r0, =gUnknown_0824978D - movs r1, 0 - bl sub_814F9EC - b _08039172 - .pool -_0803914C: - movs r0, 0 - bl IsTextPrinterActive - lsls r0, 16 - cmp r0, 0 - bne _080391C6 - bl sub_800A520 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080391C6 - b _08039172 -_08039166: - ldr r0, =gLinkVSyncDisabled - ldrb r0, [r0] - cmp r0, 0 - bne _08039172 - bl sub_800AC34 -_08039172: - ldr r1, =gBattleCommunication -_08039174: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _080391C6 - .pool -_08039184: - ldr r2, =gMain - ldr r1, =0x00000439 - adds r0, r2, r1 - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - adds r3, r2, 0 - cmp r0, 0 - beq _080391A6 - ldr r0, =gLinkVSyncDisabled - ldrb r0, [r0] - cmp r0, 0 - bne _080391A6 - ldr r0, =gUnknown_03003124 - ldrb r0, [r0] - cmp r0, 0x1 - beq _080391C6 -_080391A6: - ldr r0, =0x00000439 - adds r2, r3, r0 - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - ldr r0, [r3, 0x8] - bl SetMainCallback2 - bl sub_8057028 - bl dp11_free - bl sub_805F094 -_080391C6: - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8038F34 - - thumb_func_start sub_80391E0 -sub_80391E0: @ 80391E0 - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r1, 24 - lsrs r1, 24 - movs r0, 0 - cmp r1, 0x6 - bhi _080392A0 - lsls r0, r1, 2 - ldr r1, =_08039200 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08039200: - .4byte _0803921C - .4byte _08039230 - .4byte _08039244 - .4byte _08039258 - .4byte _0803926C - .4byte _08039280 - .4byte _08039294 -_0803921C: - ldr r0, =gUnknown_0831AA08 - lsls r1, r2, 2 - adds r1, r0 - ldrb r0, [r1] - lsls r0, 30 - lsrs r0, 30 - b _080392A0 - .pool -_08039230: - ldr r0, =gUnknown_0831AA08 - lsls r1, r2, 2 - adds r1, r0 - ldrb r0, [r1] - lsls r0, 28 - lsrs r0, 30 - b _080392A0 - .pool -_08039244: - ldr r0, =gUnknown_0831AA08 - lsls r1, r2, 2 - adds r1, r0 - ldrh r0, [r1] - lsls r0, 23 - lsrs r0, 27 - b _080392A0 - .pool -_08039258: - ldr r0, =gUnknown_0831AA08 - lsls r1, r2, 2 - adds r1, r0 - ldrb r0, [r1, 0x1] - lsls r0, 29 - lsrs r0, 30 - b _080392A0 - .pool -_0803926C: - ldr r0, =gUnknown_0831AA08 - lsls r1, r2, 2 - adds r1, r0 - ldrb r0, [r1, 0x1] - lsls r0, 28 - lsrs r0, 31 - b _080392A0 - .pool -_08039280: - ldr r0, =gUnknown_0831AA08 - lsls r1, r2, 2 - adds r1, r0 - ldrb r0, [r1, 0x1] - lsls r0, 26 - lsrs r0, 30 - b _080392A0 - .pool -_08039294: - ldr r0, =gUnknown_0831AA08 - lsls r1, r2, 2 - adds r1, r0 - ldr r0, [r1] - lsls r0, 8 - lsrs r0, 22 -_080392A0: - pop {r1} - bx r1 - .pool - thumb_func_end sub_80391E0 - - thumb_func_start sub_80392A8 -sub_80392A8: @ 80392A8 - push {r4,lr} - sub sp, 0x8 - movs r0, 0 - bl SetHBlankCallback - movs r0, 0 - bl SetVBlankCallback - movs r4, 0 - str r4, [sp, 0x4] - movs r1, 0xC0 - lsls r1, 19 - ldr r2, =0x05006000 - add r0, sp, 0x4 - bl CpuSet - bl ResetPaletteFade - ldr r0, =gUnknown_02022E14 - strh r4, [r0] - ldr r0, =gUnknown_02022E16 - strh r4, [r0] - ldr r0, =gBattle_BG1_X - strh r4, [r0] - ldr r0, =gBattle_BG1_Y - strh r4, [r0] - ldr r0, =gBattle_BG2_X - strh r4, [r0] - ldr r0, =gBattle_BG2_Y - strh r4, [r0] - ldr r0, =gBattle_BG3_X - strh r4, [r0] - ldr r0, =gUnknown_02022E22 - strh r4, [r0] - bl c2_berry_program_update_menu - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - bl sub_803570C -_080392FE: - lsls r0, r4, 24 - lsrs r0, 24 - bl sub_80363C4 - adds r4, 0x1 - cmp r4, 0x1 - ble _080392FE - bl ResetSpriteData - bl ResetTasks - bl FreeAllSpritePalettes - ldr r1, =gReservedSpritePaletteCount - movs r0, 0x4 - strb r0, [r1] - ldr r0, =VBlankCB_Battle - bl SetVBlankCallback - ldr r0, =sub_803937C - bl SetMainCallback2 - movs r0, 0x1 - negs r0, r0 - movs r4, 0 - str r4, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r0, =gBattleCommunication - strb r4, [r0] - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80392A8 - - thumb_func_start sub_803937C -sub_803937C: @ 803937C - push {lr} - bl sub_803939C - bl AnimateSprites - bl BuildOamBuffer - bl RunTextPrinters - bl UpdatePaletteFade - bl RunTasks - pop {r0} - bx r0 - thumb_func_end sub_803937C - - thumb_func_start sub_803939C -sub_803939C: @ 803939C - push {r4,r5,lr} - sub sp, 0x4 - ldr r0, =gBattleCommunication - ldrb r1, [r0] - adds r4, r0, 0 - cmp r1, 0xC - bls _080393AC - b _0803975E -_080393AC: - lsls r0, r1, 2 - ldr r1, =_080393C0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080393C0: - .4byte _080393F4 - .4byte _08039414 - .4byte _08039450 - .4byte _08039470 - .4byte _0803949C - .4byte _080394D8 - .4byte _0803957C - .4byte _08039704 - .4byte _080395CC - .4byte _08039610 - .4byte _08039678 - .4byte _080396A8 - .4byte _08039704 -_080393F4: - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - ldr r1, =gBattleCommunication - ldrb r0, [r1] - adds r0, 0x1 - b _0803975C - .pool -_08039414: - ldr r0, =gMain - ldr r1, =0x00000439 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _08039434 - ldr r0, =gUnknown_03003124 - ldrb r0, [r0] - cmp r0, 0 - bne _08039434 - ldr r0, =sub_80B3AF8 - movs r1, 0x5 - bl CreateTask -_08039434: - ldr r1, =gBattleCommunication - ldrb r0, [r1] - adds r0, 0x1 - b _0803975C - .pool -_08039450: - ldr r0, =sub_80B3AF8 - bl FuncIsActiveTask - lsls r0, 24 - cmp r0, 0 - beq _0803945E - b _0803975E -_0803945E: - ldr r1, =gBattleCommunication - ldrb r0, [r1] - adds r0, 0x1 - b _0803975C - .pool -_08039470: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0803947E - b _0803975E -_0803947E: - ldr r0, =gText_RecordBattleToPass - movs r1, 0 - bl sub_814F9EC - ldr r1, =gBattleCommunication - ldrb r0, [r1] - adds r0, 0x1 - b _0803975C - .pool -_0803949C: - movs r0, 0 - bl IsTextPrinterActive - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0 - beq _080394AC - b _0803975E -_080394AC: - str r0, [sp] - movs r0, 0x18 - movs r1, 0x8 - movs r2, 0x1D - movs r3, 0xD - bl sub_8056A3C - ldr r0, =gText_BattleYesNoChoice - movs r1, 0xC - bl sub_814F9EC - ldr r4, =gBattleCommunication - movs r0, 0x1 - strb r0, [r4, 0x1] - bl BattleCreateCursorAt - b _080396EA - .pool -_080394D8: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _08039500 - ldrb r0, [r4, 0x1] - cmp r0, 0 - bne _080394EC - b _0803975E -_080394EC: - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4, 0x1] - bl BattleDestroyCursorAt - movs r0, 0 - b _0803951E - .pool -_08039500: - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08039526 - ldrb r0, [r4, 0x1] - cmp r0, 0 - beq _08039510 - b _0803975E -_08039510: - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4, 0x1] - bl BattleDestroyCursorAt - movs r0, 0x1 -_0803951E: - strb r0, [r4, 0x1] - bl BattleCreateCursorAt - b _0803975E -_08039526: - movs r5, 0x1 - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0 - beq _08039560 - movs r0, 0x5 - bl PlaySE - ldr r4, =gBattleCommunication - ldrb r0, [r4, 0x1] - cmp r0, 0 - beq _08039540 - b _080396EA -_08039540: - str r5, [sp] - movs r0, 0x18 - movs r1, 0x8 - movs r2, 0x1D - movs r3, 0xD - bl sub_8056A3C - bl sub_8185338 - strb r0, [r4, 0x1] - movs r0, 0xA - strb r0, [r4] - b _0803975E - .pool -_08039560: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _0803956A - b _0803975E -_0803956A: - movs r0, 0x5 - bl PlaySE - ldr r1, =gBattleCommunication - ldrb r0, [r1] - adds r0, 0x1 - b _0803975C - .pool -_0803957C: - bl sub_800A520 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0803958A - b _0803975E -_0803958A: - str r0, [sp] - movs r0, 0x18 - movs r1, 0x8 - movs r2, 0x1D - movs r3, 0xD - bl sub_8056A3C - ldr r0, =gMain - ldr r1, =0x00000439 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _080395B4 - bl sub_800ADF8 - ldr r0, =gUnknown_0824978D - movs r1, 0 - bl sub_814F9EC -_080395B4: - ldr r1, =gBattleCommunication - ldrb r0, [r1] - adds r0, 0x1 - b _0803975C - .pool -_080395CC: - ldrb r0, [r4, 0x1] - subs r0, 0x1 - strb r0, [r4, 0x1] - lsls r0, 24 - cmp r0, 0 - beq _080395DA - b _0803975E -_080395DA: - ldr r0, =gMain - ldr r1, =0x00000439 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _080395F6 - ldr r0, =gLinkVSyncDisabled - ldrb r0, [r0] - cmp r0, 0 - bne _080395F6 - bl sub_800AC34 -_080395F6: - ldr r1, =gBattleCommunication - ldrb r0, [r1] - adds r0, 0x1 - b _0803975C - .pool -_08039610: - ldr r2, =gMain - ldr r1, =0x00000439 - adds r0, r2, r1 - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - adds r3, r2, 0 - cmp r0, 0 - beq _08039634 - ldr r0, =gLinkVSyncDisabled - ldrb r0, [r0] - cmp r0, 0 - bne _08039634 - ldr r0, =gUnknown_03003124 - ldrb r0, [r0] - cmp r0, 0x1 - bne _08039634 - b _0803975E -_08039634: - ldr r0, =0x00000439 - adds r2, r3, r0 - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08039650 - b _0803975E -_08039650: - ldr r0, [r3, 0x8] - bl SetMainCallback2 - bl sub_8057028 - bl dp11_free - bl sub_805F094 - b _0803975E - .pool -_08039678: - ldrb r0, [r4, 0x1] - cmp r0, 0x1 - bne _080396A0 - movs r0, 0x37 - bl PlaySE - ldr r0, =gText_BattleRecordedOnPass -_08039686: - bl BattleStringExpandPlaceholdersToDisplayedString - ldr r0, =gDisplayedStringBattle - movs r1, 0 - bl sub_814F9EC - movs r0, 0x80 - strb r0, [r4, 0x1] - b _080396EA - .pool -_080396A0: - ldr r0, =gUnknown_08242481 - b _08039686 - .pool -_080396A8: - bl sub_800A520 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0803975E - movs r0, 0 - bl IsTextPrinterActive - lsls r0, 16 - cmp r0, 0 - bne _0803975E - ldr r4, =gBattleCommunication - ldrb r0, [r4, 0x1] - subs r0, 0x1 - strb r0, [r4, 0x1] - lsls r0, 24 - cmp r0, 0 - bne _0803975E - ldr r0, =gMain - ldr r1, =0x00000439 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _080396EA - bl sub_800ADF8 - ldr r0, =gUnknown_0824978D - movs r1, 0 - bl sub_814F9EC -_080396EA: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - b _0803975E - .pool -_08039704: - movs r0, 0 - bl IsTextPrinterActive - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0 - bne _0803975E - ldr r0, =gMain - ldr r1, =0x00000439 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - beq _08039744 - bl sub_800A520 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0803975E - movs r0, 0x1 - negs r0, r0 - str r4, [sp] - b _0803974A - .pool -_08039744: - movs r0, 0x1 - negs r0, r0 - str r1, [sp] -_0803974A: - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, =gBattleCommunication - movs r0, 0x20 - strb r0, [r1, 0x1] - movs r0, 0x8 -_0803975C: - strb r0, [r1] -_0803975E: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803939C - - thumb_func_start shedinja_something -shedinja_something: @ 803976C - push {r4,r5,lr} - sub sp, 0x10 - adds r4, r0, 0 - add r5, sp, 0xC - movs r0, 0x1 - strb r0, [r5] - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - ldr r1, =0x0000012f - cmp r0, r1 - bne _080397B4 - adds r0, r4, 0 - movs r1, 0x3 - bl GetMonData - ldrb r1, [r5] - cmp r0, r1 - beq _080397B4 - adds r0, r4, 0 - movs r1, 0x2 - mov r2, sp - bl GetMonData - ldr r1, =gUnknown_0831ACA0 - mov r0, sp - bl StringCompareWithoutExtCtrlCodes - cmp r0, 0 - bne _080397B4 - adds r0, r4, 0 - movs r1, 0x3 - adds r2, r5, 0 - bl SetMonData -_080397B4: - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end shedinja_something - - thumb_func_start sub_80397C4 -sub_80397C4: @ 80397C4 - ldr r2, =gUnknown_0831ABA0 - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - lsls r1, 3 - adds r1, r0 - ldrb r0, [r1, 0x3] - lsls r0, 3 - bx lr - .pool - thumb_func_end sub_80397C4 - - thumb_func_start oac_poke_opponent -oac_poke_opponent: @ 80397DC - push {lr} - sub sp, 0x4 - ldr r1, =sub_803980C - str r1, [r0, 0x1C] - movs r1, 0 - bl StartSpriteAnimIfDifferent - movs r0, 0x80 - lsls r0, 10 - ldr r1, =0x00002108 - str r1, [sp] - movs r1, 0 - movs r2, 0xA - movs r3, 0xA - bl BeginNormalPaletteFade - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end oac_poke_opponent - - thumb_func_start sub_803980C -sub_803980C: @ 803980C - push {lr} - adds r2, r0, 0 - ldr r0, =gUnknown_020243FC - ldrh r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _0803982C - ldrh r0, [r2, 0x24] - adds r0, 0x2 - strh r0, [r2, 0x24] - lsls r0, 16 - cmp r0, 0 - bne _0803982C - ldr r0, =sub_8039838 - str r0, [r2, 0x1C] -_0803982C: - pop {r0} - bx r0 - .pool - thumb_func_end sub_803980C - - thumb_func_start sub_8039838 -sub_8039838: @ 8039838 - push {r4,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08039880 - ldrh r0, [r4, 0x2E] - lsls r0, 24 - lsrs r0, 24 - bl sub_8076918 - ldr r1, =gHealthBoxesIds - movs r2, 0x2E - ldrsh r0, [r4, r2] - adds r0, r1 - ldrb r0, [r0] - bl sub_80729D0 - ldr r0, =sub_8039894 - str r0, [r4, 0x1C] - adds r0, r4, 0 - movs r1, 0 - bl StartSpriteAnimIfDifferent - movs r0, 0x80 - lsls r0, 10 - ldr r1, =0x00002108 - str r1, [sp] - movs r1, 0 - movs r2, 0xA - movs r3, 0 - bl BeginNormalPaletteFade -_08039880: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8039838 - - thumb_func_start sub_8039894 -sub_8039894: @ 8039894 - push {lr} - adds r2, r0, 0 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _080398B0 - ldrh r1, [r2, 0x32] - adds r0, r2, 0 - movs r2, 0 - movs r3, 0x1 - bl BattleAnimateFrontSprite -_080398B0: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8039894 - - thumb_func_start SpriteCallbackDummy_2 -SpriteCallbackDummy_2: @ 80398B8 - bx lr - thumb_func_end SpriteCallbackDummy_2 - - thumb_func_start sub_80398BC -sub_80398BC: @ 80398BC - movs r1, 0x6 - strh r1, [r0, 0x34] - movs r1, 0x1 - strh r1, [r0, 0x36] - ldr r1, =sub_80398D0 - str r1, [r0, 0x1C] - bx lr - .pool - thumb_func_end sub_80398BC - - thumb_func_start sub_80398D0 -sub_80398D0: @ 80398D0 - push {r4,lr} - adds r3, r0, 0 - ldrh r0, [r3, 0x36] - subs r0, 0x1 - strh r0, [r3, 0x36] - lsls r0, 16 - cmp r0, 0 - bne _08039924 - movs r0, 0x8 - strh r0, [r3, 0x36] - movs r0, 0x3E - adds r0, r3 - mov r12, r0 - ldrb r2, [r0] - lsls r0, r2, 29 - lsrs r0, 31 - movs r1, 0x1 - eors r1, r0 - lsls r1, 2 - movs r4, 0x5 - negs r4, r4 - adds r0, r4, 0 - ands r0, r2 - orrs r0, r1 - mov r1, r12 - strb r0, [r1] - ldrh r0, [r3, 0x34] - subs r0, 0x1 - strh r0, [r3, 0x34] - lsls r0, 16 - asrs r2, r0, 16 - cmp r2, 0 - bne _08039924 - ldrb r1, [r1] - adds r0, r4, 0 - ands r0, r1 - mov r1, r12 - strb r0, [r1] - ldr r0, =SpriteCallbackDummy_2 - str r0, [r3, 0x1C] - ldr r0, =gUnknown_02022F88 - str r2, [r0] -_08039924: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80398D0 - - thumb_func_start sub_8039934 -sub_8039934: @ 8039934 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - mov r9, r0 - ldrh r0, [r0, 0x2E] - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, =gUnknown_020244D0 - ldr r0, [r0] - ldr r1, [r0] - lsls r0, r6, 2 - adds r1, r0, r1 - ldrh r0, [r1, 0x2] - cmp r0, 0 - beq _0803995C - adds r4, r0, 0 - b _08039960 - .pool -_0803995C: - mov r0, r9 - ldrh r4, [r0, 0x32] -_08039960: - ldr r1, =gBattlePartyID - lsls r0, r6, 1 - adds r5, r0, r1 - ldrh r0, [r5] - movs r1, 0x64 - mov r8, r1 - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - ldr r7, =gEnemyParty - adds r0, r7 - movs r1, 0 - bl GetMonData - cmp r4, 0xC9 - bne _080399E4 - ldrh r0, [r5] - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - adds r0, r7 - movs r1, 0 - bl GetMonData - adds r2, r0, 0 - movs r0, 0xC0 - lsls r0, 18 - ands r0, r2 - lsrs r0, 18 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r2 - lsrs r1, 12 - orrs r0, r1 - movs r1, 0xC0 - lsls r1, 2 - ands r1, r2 - lsrs r1, 6 - orrs r0, r1 - movs r1, 0x3 - ands r1, r2 - orrs r0, r1 - movs r1, 0x1C - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0 - bne _080399D0 - movs r0, 0xC9 - b _080399DA - .pool -_080399D0: - movs r1, 0xCE - lsls r1, 1 - adds r0, r1 - lsls r0, 16 - lsrs r0, 16 -_080399DA: - ldr r1, =gUnknown_08300D38 - lsls r0, 2 - b _08039A1C - .pool -_080399E4: - ldr r0, =0x00000181 - cmp r4, r0 - bne _08039A08 - ldr r0, =gUnknown_08525F78 - ldr r1, =gBattleMonForms - adds r1, r6, r1 - ldrb r1, [r1] - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0x1] - b _08039A20 - .pool -_08039A08: - movs r0, 0xCE - lsls r0, 1 - cmp r4, r0 - bls _08039A18 - ldr r0, =gUnknown_08300D38 - b _08039A1E - .pool -_08039A18: - ldr r1, =gUnknown_08300D38 - lsls r0, r4, 2 -_08039A1C: - adds r0, r1 -_08039A1E: - ldrb r0, [r0, 0x1] -_08039A20: - lsrs r1, r0, 3 - movs r0, 0x8 - subs r0, r1 - mov r1, r9 - strh r0, [r1, 0x34] - movs r0, 0x1 - strh r0, [r1, 0x36] - ldr r0, =sub_8039A48 - str r0, [r1, 0x1C] - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8039934 - - thumb_func_start sub_8039A48 -sub_8039A48: @ 8039A48 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x36] - subs r0, 0x1 - strh r0, [r4, 0x36] - lsls r0, 16 - cmp r0, 0 - bne _08039AC8 - movs r0, 0x2 - strh r0, [r4, 0x36] - ldrh r0, [r4, 0x26] - adds r0, 0x8 - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x34] - subs r0, 0x1 - strh r0, [r4, 0x34] - lsls r0, 16 - cmp r0, 0 - bge _08039A7C - adds r0, r4, 0 - bl FreeSpriteOamMatrix - adds r0, r4, 0 - bl DestroySprite - b _08039AC8 -_08039A7C: - ldrh r0, [r4, 0x2E] - lsls r0, 24 - lsrs r0, 24 - bl GetBankIdentity - ldr r1, =gBattleSpritesGfx - ldr r1, [r1] - lsls r0, 24 - lsrs r0, 22 - adds r1, 0x4 - adds r1, r0 - ldr r2, =gBattleMonForms - movs r3, 0x2E - ldrsh r0, [r4, r3] - adds r0, r2 - ldrb r0, [r0] - lsls r0, 11 - ldr r1, [r1] - adds r1, r0 - movs r2, 0x34 - ldrsh r0, [r4, r2] - lsls r0, 8 - adds r1, r0 - movs r2, 0 - movs r0, 0xFF -_08039AAE: - strb r2, [r1] - adds r1, 0x1 - subs r0, 0x1 - cmp r0, 0 - bge _08039AAE - ldr r0, =gBattleMonForms - movs r3, 0x2E - ldrsh r1, [r4, r3] - adds r1, r0 - ldrb r1, [r1] - adds r0, r4, 0 - bl StartSpriteAnim -_08039AC8: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8039A48 - - thumb_func_start sub_8039AD8 -sub_8039AD8: @ 8039AD8 - movs r1, 0x8 - strh r1, [r0, 0x34] - adds r1, r0, 0 - adds r1, 0x3E - ldrb r1, [r1] - lsls r1, 29 - lsrs r1, 31 - strh r1, [r0, 0x36] - ldr r1, =sub_8039AF4 - str r1, [r0, 0x1C] - bx lr - .pool - thumb_func_end sub_8039AD8 - - thumb_func_start sub_8039AF4 -sub_8039AF4: @ 8039AF4 - push {lr} - adds r3, r0, 0 - ldrh r0, [r3, 0x34] - subs r0, 0x1 - strh r0, [r3, 0x34] - lsls r0, 16 - cmp r0, 0 - bne _08039B26 - movs r0, 0x3E - adds r0, r3 - mov r12, r0 - ldrb r2, [r0] - lsls r0, r2, 29 - lsrs r0, 31 - movs r1, 0x1 - eors r1, r0 - lsls r1, 2 - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - mov r1, r12 - strb r0, [r1] - movs r0, 0x8 - strh r0, [r3, 0x34] -_08039B26: - pop {r0} - bx r0 - thumb_func_end sub_8039AF4 - - thumb_func_start sub_8039B2C -sub_8039B2C: @ 8039B2C - movs r1, 0x3E - adds r1, r0 - mov r12, r1 - movs r1, 0x1 - ldrh r2, [r0, 0x36] - ands r2, r1 - lsls r2, 2 - mov r1, r12 - ldrb r3, [r1] - movs r1, 0x5 - negs r1, r1 - ands r1, r3 - orrs r1, r2 - mov r2, r12 - strb r1, [r2] - movs r1, 0 - strh r1, [r0, 0x36] - ldr r1, =SpriteCallbackDummy_2 - str r1, [r0, 0x1C] - bx lr - .pool - thumb_func_end sub_8039B2C - - thumb_func_start sub_8039B58 -sub_8039B58: @ 8039B58 - push {r4,lr} - adds r4, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _08039BA0 - ldr r0, =gHitMarker - ldr r0, [r0] - movs r1, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08039B80 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ldr r1, =0x02000002 - ands r0, r1 - cmp r0, 0 - beq _08039B94 -_08039B80: - ldrh r0, [r4, 0x32] - bl HasTwoFramesAnimation - lsls r0, 24 - cmp r0, 0 - beq _08039B94 - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAnim -_08039B94: - ldrh r1, [r4, 0x32] - adds r0, r4, 0 - movs r2, 0x1 - movs r3, 0x1 - bl BattleAnimateFrontSprite -_08039BA0: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8039B58 - - thumb_func_start sub_8039BB4 -sub_8039BB4: @ 8039BB4 - ldr r1, =oac_poke_ally_ - str r1, [r0, 0x1C] - bx lr - .pool - thumb_func_end sub_8039BB4 - - thumb_func_start oac_poke_ally_ -oac_poke_ally_: @ 8039BC0 - push {lr} - adds r2, r0, 0 - ldr r0, =gUnknown_020243FC - ldrh r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _08039BE4 - ldrh r0, [r2, 0x24] - subs r0, 0x2 - strh r0, [r2, 0x24] - lsls r0, 16 - asrs r1, r0, 16 - cmp r1, 0 - bne _08039BE4 - ldr r0, =nullsub_19 - str r0, [r2, 0x1C] - strh r1, [r2, 0x30] -_08039BE4: - pop {r0} - bx r0 - .pool - thumb_func_end oac_poke_ally_ - - thumb_func_start sub_8039BF0 -sub_8039BF0: @ 8039BF0 - ldr r1, =nullsub_19 - str r1, [r0, 0x1C] - bx lr - .pool - thumb_func_end sub_8039BF0 - - thumb_func_start nullsub_19 -nullsub_19: @ 8039BFC - bx lr - thumb_func_end nullsub_19 - - thumb_func_start sub_8039C00 -sub_8039C00: @ 8039C00 - push {lr} - adds r2, r0, 0 - ldr r0, =gUnknown_020243FC - ldrh r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _08039C20 - ldrh r0, [r2, 0x30] - ldrh r1, [r2, 0x24] - adds r0, r1 - strh r0, [r2, 0x24] - ldrh r0, [r2, 0x32] - ldrh r1, [r2, 0x26] - adds r0, r1 - strh r0, [r2, 0x26] -_08039C20: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8039C00 - - thumb_func_start dp11b_obj_instanciate -dp11b_obj_instanciate: @ 8039C28 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r1, 24 - lsrs r1, 24 - mov r8, r1 - lsls r2, 24 - lsrs r2, 24 - mov r9, r2 - lsls r3, 24 - lsrs r3, 24 - mov r10, r3 - cmp r1, 0 - beq _08039C64 - ldr r0, =gUnknown_020244D0 - ldr r0, [r0] - ldr r1, [r0, 0x4] - lsls r2, r4, 1 - adds r0, r2, r4 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x2 - b _08039C76 - .pool -_08039C64: - ldr r0, =gUnknown_020244D0 - ldr r0, [r0] - ldr r1, [r0, 0x4] - lsls r2, r4, 1 - adds r0, r2, r4 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x4 -_08039C76: - ands r0, r1 - adds r6, r2, 0 - cmp r0, 0 - bne _08039D2C - ldr r0, =objc_dp11b_pingpong - bl CreateInvisibleSpriteWithCallback - lsls r0, 24 - lsrs r5, r0, 24 - mov r0, r8 - cmp r0, 0x1 - bne _08039CD0 - ldr r0, =gHealthBoxesIds - adds r0, r4, r0 - ldrb r7, [r0] - ldr r2, =gUnknown_020244D0 - ldr r0, [r2] - ldr r0, [r0, 0x4] - adds r1, r6, r4 - lsls r1, 2 - adds r0, r1, r0 - strb r5, [r0, 0x2] - ldr r0, [r2] - ldr r0, [r0, 0x4] - adds r1, r0 - ldrb r0, [r1] - movs r2, 0x2 - orrs r0, r2 - strb r0, [r1] - ldr r2, =gSprites - lsls r3, r5, 4 - adds r0, r3, r5 - lsls r0, 2 - adds r0, r2 - movs r1, 0x80 - b _08039CFE - .pool -_08039CD0: - ldr r0, =gBankSpriteIds - adds r0, r4, r0 - ldrb r7, [r0] - ldr r2, =gUnknown_020244D0 - ldr r0, [r2] - ldr r0, [r0, 0x4] - adds r1, r6, r4 - lsls r1, 2 - adds r0, r1, r0 - strb r5, [r0, 0x3] - ldr r0, [r2] - ldr r0, [r0, 0x4] - adds r1, r0 - ldrb r0, [r1] - movs r2, 0x4 - orrs r0, r2 - strb r0, [r1] - ldr r2, =gSprites - lsls r3, r5, 4 - adds r0, r3, r5 - lsls r0, 2 - adds r0, r2 - movs r1, 0xC0 -_08039CFE: - strh r1, [r0, 0x2E] - adds r4, r2, 0 - adds r1, r3, r5 - lsls r1, 2 - adds r1, r4 - mov r2, r9 - lsls r0, r2, 24 - asrs r0, 24 - movs r2, 0 - strh r0, [r1, 0x30] - mov r3, r10 - lsls r0, r3, 24 - asrs r0, 24 - strh r0, [r1, 0x32] - strh r7, [r1, 0x34] - mov r0, r8 - strh r0, [r1, 0x36] - lsls r0, r7, 4 - adds r0, r7 - lsls r0, 2 - adds r0, r4 - strh r2, [r0, 0x24] - strh r2, [r0, 0x26] -_08039D2C: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end dp11b_obj_instanciate - - thumb_func_start dp11b_obj_free -dp11b_obj_free: @ 8039D48 - push {r4-r6,lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r1, 24 - lsrs r1, 24 - cmp r1, 0x1 - bne _08039D9C - ldr r6, =gUnknown_020244D0 - ldr r0, [r6] - ldr r1, [r0, 0x4] - lsls r0, r2, 1 - adds r0, r2 - lsls r5, r0, 2 - adds r3, r5, r1 - ldrb r1, [r3] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08039DEA - ldr r2, =gSprites - ldrb r1, [r3, 0x2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x34] - lsls r1, 24 - lsrs r4, r1, 24 - bl DestroySprite - ldr r0, [r6] - ldr r1, [r0, 0x4] - adds r1, r5, r1 - ldrb r2, [r1] - movs r0, 0x3 - negs r0, r0 - b _08039DD6 - .pool -_08039D9C: - ldr r6, =gUnknown_020244D0 - ldr r0, [r6] - ldr r1, [r0, 0x4] - lsls r0, r2, 1 - adds r0, r2 - lsls r5, r0, 2 - adds r3, r5, r1 - ldrb r1, [r3] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _08039DEA - ldr r2, =gSprites - ldrb r1, [r3, 0x3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x34] - lsls r1, 24 - lsrs r4, r1, 24 - bl DestroySprite - ldr r0, [r6] - ldr r1, [r0, 0x4] - adds r1, r5, r1 - ldrb r2, [r1] - movs r0, 0x5 - negs r0, r0 -_08039DD6: - ands r0, r2 - strb r0, [r1] - ldr r0, =gSprites - lsls r1, r4, 4 - adds r1, r4 - lsls r1, 2 - adds r1, r0 - movs r0, 0 - strh r0, [r1, 0x24] - strh r0, [r1, 0x26] -_08039DEA: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end dp11b_obj_free - - thumb_func_start objc_dp11b_pingpong -objc_dp11b_pingpong: @ 8039DF8 - push {r4,r5,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x34] - lsls r0, 24 - lsrs r5, r0, 24 - movs r1, 0x36 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - bne _08039E10 - movs r2, 0x2E - ldrsh r0, [r4, r2] - b _08039E14 -_08039E10: - movs r1, 0x2E - ldrsh r0, [r4, r1] -_08039E14: - movs r2, 0x32 - ldrsh r1, [r4, r2] - bl Sin - ldr r2, =gSprites - lsls r1, r5, 4 - adds r1, r5 - lsls r1, 2 - adds r1, r2 - ldrh r2, [r4, 0x32] - adds r0, r2 - strh r0, [r1, 0x26] - ldrh r0, [r4, 0x30] - ldrh r1, [r4, 0x2E] - adds r0, r1 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x2E] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end objc_dp11b_pingpong - - thumb_func_start sub_8039E44 -sub_8039E44: @ 8039E44 - push {lr} - adds r2, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _08039E5C - ldrh r1, [r2, 0x32] - adds r0, r2, 0 - bl BattleAnimateBackSprite -_08039E5C: - pop {r0} - bx r0 - thumb_func_end sub_8039E44 - - thumb_func_start sub_8039E60 -sub_8039E60: @ 8039E60 - push {r4,lr} - adds r4, r0, 0 - bl sub_8039E9C - adds r0, r4, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08039E7A - ldr r0, =nullsub_19 - str r0, [r4, 0x1C] -_08039E7A: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8039E60 - - thumb_func_start sub_8039E84 -sub_8039E84: @ 8039E84 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x1 - bl StartSpriteAnim - ldr r0, =sub_8039E60 - str r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8039E84 - - thumb_func_start sub_8039E9C -sub_8039E9C: @ 8039E9C - push {lr} - adds r2, r0, 0 - adds r0, 0x2C - ldrb r1, [r0] - movs r0, 0x3F - ands r0, r1 - cmp r0, 0 - bne _08039EBE - ldr r1, =gUnknown_0831ACE0 - adds r0, r2, 0 - adds r0, 0x2B - ldrb r0, [r0] - adds r0, r1 - ldrb r1, [r0] - adds r0, r2, 0 - adds r0, 0x28 - strb r1, [r0] -_08039EBE: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8039E9C - - thumb_func_start nullsub_20 -nullsub_20: @ 8039EC8 - bx lr - thumb_func_end nullsub_20 - - thumb_func_start sub_8039ECC -sub_8039ECC: @ 8039ECC - push {lr} - bl sub_8039F40 - ldr r1, =gBattleCommunication - movs r0, 0 - strb r0, [r1, 0x1] - ldr r1, =gBattleMainFunc - ldr r0, =bc_8012FAC - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_8039ECC - - thumb_func_start sub_8039EF0 -sub_8039EF0: @ 8039EF0 - push {r4,r5,lr} - ldr r0, =gBattleMainFunc - ldr r0, [r0] - bl _call_via_r0 - ldr r1, =gActiveBank - movs r0, 0 - strb r0, [r1] - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r0, 0 - beq _08039F2A - ldr r5, =gBattleBankFunc - adds r4, r1, 0 -_08039F0C: - ldrb r0, [r4] - lsls r0, 2 - adds r0, r5 - ldr r0, [r0] - bl _call_via_r0 - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bcc _08039F0C -_08039F2A: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8039EF0 - - thumb_func_start sub_8039F40 -sub_8039F40: @ 8039F40 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - movs r0, 0 - bl sub_803D580 - bl sub_803D6A0 - movs r2, 0 - movs r3, 0 - ldr r0, =gUnknown_02024260 - mov r10, r0 - ldr r1, =gUnknown_02024258 - mov r9, r1 - ldr r0, =gUnknown_02024250 - mov r8, r0 - ldr r1, =gLastUsedMovesByBanks - mov r12, r1 - ldr r5, =gDisableStructs - movs r4, 0 - ldr r7, =gUnknownMovesUsedByBanks - ldr r6, =gLockedMoves -_08039F70: - ldr r0, =gStatuses3 - adds r0, r4, r0 - str r3, [r0] - movs r1, 0 -_08039F78: - adds r0, r5, r1 - strb r3, [r0] - adds r1, 0x1 - cmp r1, 0x1B - bls _08039F78 - movs r0, 0x2 - strb r0, [r5, 0x16] - ldr r1, =gUnknown_02024284 - adds r0, r2, r1 - strb r3, [r0] - mov r0, r12 - strh r3, [r0] - mov r1, r8 - strh r3, [r1] - mov r0, r9 - strh r3, [r0] - mov r1, r10 - strh r3, [r1] - ldr r0, =gUnknown_02024270 - adds r1, r2, r0 - movs r0, 0xFF - strb r0, [r1] - strh r3, [r6] - strh r3, [r7] - ldr r1, =gBattleResources - ldr r0, [r1] - ldr r0, [r0, 0x4] - adds r0, r4 - str r3, [r0] - ldr r1, =gUnknown_02024230 - adds r0, r4, r1 - str r3, [r0] - movs r0, 0x2 - add r10, r0 - add r9, r0 - add r8, r0 - add r12, r0 - adds r5, 0x1C - adds r4, 0x4 - adds r7, 0x2 - adds r6, 0x2 - adds r2, 0x1 - cmp r2, 0x3 - ble _08039F70 - movs r5, 0 - ldr r3, =gSideTimers - ldr r4, =gSideAffecting - movs r2, 0x1 -_08039FD8: - strh r5, [r4] - movs r1, 0 -_08039FDC: - adds r0, r3, r1 - strb r5, [r0] - adds r1, 0x1 - cmp r1, 0xB - bls _08039FDC - adds r3, 0xC - adds r4, 0x2 - subs r2, 0x1 - cmp r2, 0 - bge _08039FD8 - movs r1, 0 - ldr r2, =gBankAttacker - strb r1, [r2] - ldr r0, =gBankTarget - strb r1, [r0] - ldr r2, =gBattleWeather - strh r1, [r2] - ldr r1, =gWishFutureKnock - movs r2, 0 - movs r3, 0 -_0803A004: - adds r0, r1, r2 - strb r3, [r0] - adds r2, 0x1 - cmp r2, 0x2B - bls _0803A004 - ldr r2, =gHitMarker - movs r0, 0 - str r0, [r2] - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x80 - lsls r0, 17 - ands r0, r1 - cmp r0, 0 - bne _0803A090 - movs r0, 0x2 - ands r1, r0 - cmp r1, 0 - bne _0803A0AE - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldrb r1, [r0, 0x15] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0803A0AE - movs r0, 0x80 - b _0803A0AC - .pool -_0803A090: - ldr r0, =0x02000002 - ands r1, r0 - cmp r1, 0 - bne _0803A0AE - bl sub_8185FB8 - lsls r0, 24 - cmp r0, 0 - beq _0803A0AE - ldr r1, =gHitMarker - ldr r0, [r1] - movs r1, 0x80 - orrs r0, r1 - ldr r2, =gHitMarker -_0803A0AC: - str r0, [r2] -_0803A0AE: - ldr r3, =gBattleScripting - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldrb r0, [r0, 0x15] - lsls r0, 30 - lsrs r0, 31 - movs r1, 0 - strb r0, [r3, 0x1D] - ldr r0, =gMultiHitCounter - strb r1, [r0] - ldr r0, =gBattleOutcome - strb r1, [r0] - ldr r0, =gBattleExecBuffer - str r1, [r0] - ldr r0, =gPaydayMoney - movs r2, 0 - strh r1, [r0] - ldr r1, =gBattleResources - ldr r0, [r1] - ldr r0, [r0, 0x8] - adds r0, 0x20 - strb r2, [r0] - ldr r0, [r1] - ldr r0, [r0, 0xC] - adds r0, 0x20 - strb r2, [r0] - ldr r5, =gPauseCounterBattle - ldr r6, =gBattleMoveDamage - ldr r7, =gUnknown_020243FC - ldr r0, =gLeveledUpInBattle - mov r8, r0 - ldr r1, =gAbsentBankFlags - mov r9, r1 - ldr r2, =gEnemyParty - mov r10, r2 - ldr r1, =gBattleCommunication - movs r2, 0 - adds r0, r1, 0x7 -_0803A0FA: - strb r2, [r0] - subs r0, 0x1 - cmp r0, r1 - bge _0803A0FA - movs r4, 0 - strh r4, [r5] - movs r0, 0 - str r0, [r6] - strh r0, [r7] - strb r4, [r3, 0x18] - strb r4, [r3, 0x19] - mov r0, r8 - strb r4, [r0] - mov r1, r9 - strb r4, [r1] - ldr r5, =gBattleStruct - ldr r0, [r5] - adds r0, 0x6C - strb r4, [r0] - ldr r0, [r5] - adds r0, 0x79 - strb r4, [r0] - ldr r0, [r5] - adds r0, 0x7A - strb r4, [r0] - mov r0, r10 - movs r1, 0xB - bl GetMonData - ldr r6, [r5] - adds r6, 0x7C - ldr r2, =gBaseStats - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r1, [r1, 0x8] - movs r0, 0x64 - muls r0, r1 - ldr r1, =0x000004fb - bl __divsi3 - strb r0, [r6] - ldr r0, [r5] - adds r0, 0x7B - movs r1, 0x3 - strb r1, [r0] - ldr r0, [r5] - strb r4, [r0, 0x12] - ldr r0, [r5] - adds r0, 0x4A - movs r1, 0x1 - strb r1, [r0] - movs r2, 0 - movs r1, 0 - adds r6, r5, 0 -_0803A16A: - ldr r0, [r5] - adds r0, r2, r0 - adds r0, 0x98 - strb r1, [r0] - ldr r0, [r5] - adds r0, r2, r0 - adds r0, 0xB8 - strb r1, [r0] - ldr r0, [r5] - adds r0, r2, r0 - adds r0, 0xC8 - strb r1, [r0] - ldr r0, [r5] - adds r0, r2, r0 - adds r0, 0xD0 - strb r1, [r0] - ldr r0, [r5] - adds r0, r2, r0 - adds r0, 0xE0 - strb r1, [r0] - ldr r0, [r5] - adds r0, r2, r0 - adds r0, 0xE8 - strb r1, [r0] - ldr r0, [r5] - adds r0, r2, r0 - adds r0, 0xF0 - strb r1, [r0] - ldr r0, [r5] - adds r0, r2, r0 - adds r0, 0xF8 - strb r1, [r0] - adds r2, 0x1 - cmp r2, 0x7 - ble _0803A16A - movs r2, 0 - ldr r4, =gBattleStruct - movs r3, 0xA5 - lsls r3, 2 - movs r1, 0x6 -_0803A1BA: - ldr r0, [r4] - adds r0, r2, r0 - adds r0, r3 - strb r1, [r0] - adds r2, 0x1 - cmp r2, 0x3 - ble _0803A1BA - ldr r0, [r6] - adds r0, 0xDF - movs r1, 0 - strb r1, [r0] - ldr r0, [r6] - adds r0, 0x92 - strb r1, [r0] - bl Random - ldr r1, =gUnknown_02024330 - strh r0, [r1] - ldr r1, =gBattleResults - movs r2, 0 - movs r3, 0 -_0803A1E4: - adds r0, r1, r2 - strb r3, [r0] - adds r2, 0x1 - cmp r2, 0x43 - bls _0803A1E4 - ldr r0, =gEnemyParty - bl IsMonShiny - ldr r3, =gBattleResults - movs r1, 0x1 - ands r1, r0 - lsls r1, 6 - ldrb r2, [r3, 0x5] - movs r0, 0x41 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3, 0x5] - ldr r2, =gBattleStruct - ldr r0, [r2] - movs r1, 0xA8 - lsls r1, 2 - adds r0, r1 - movs r1, 0 - strb r1, [r0] - ldr r0, [r2] - ldr r2, =0x000002a1 - adds r0, r2 - strb r1, [r0] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8039F40 - - thumb_func_start SwitchInClearStructs -SwitchInClearStructs: @ 803A284 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x20 - ldr r4, =gDisableStructs - ldr r5, =gActiveBank - ldrb r1, [r5] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - mov r1, sp - adds r0, r4 - ldm r0!, {r2,r3,r6} - stm r1!, {r2,r3,r6} - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - ldr r0, [r0] - str r0, [r1] - ldr r2, =gBattleMoves - ldr r3, =gCurrentMove - ldrh r1, [r3] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0] - mov r12, r4 - mov r9, r5 - ldr r6, =gStatuses3 - mov r10, r6 - cmp r0, 0x7F - beq _0803A35C - movs r5, 0 - mov r6, r9 - movs r4, 0x58 - ldr r2, =gBattleMons - adds r2, 0x18 - movs r1, 0x6 -_0803A2D4: - ldrb r0, [r6] - muls r0, r4 - adds r0, r5, r0 - adds r0, r2 - strb r1, [r0] - adds r5, 0x1 - cmp r5, 0x7 - ble _0803A2D4 - movs r5, 0 - ldr r7, =gNoOfAllBanks - ldrb r7, [r7] - cmp r5, r7 - bge _0803A348 - ldr r0, =gBattleMons + 0x50 - mov r8, r0 - ldr r4, =gDisableStructs - ldr r3, =gStatuses3 -_0803A2F6: - movs r0, 0x58 - muls r0, r5 - mov r1, r8 - adds r2, r0, r1 - ldr r1, [r2] - movs r0, 0x80 - lsls r0, 19 - ands r0, r1 - cmp r0, 0 - beq _0803A31A - ldrb r0, [r4, 0x14] - ldr r6, =gActiveBank - ldrb r6, [r6] - cmp r0, r6 - bne _0803A31A - ldr r0, =0xfbffffff - ands r1, r0 - str r1, [r2] -_0803A31A: - ldr r1, [r3] - movs r0, 0x18 - ands r0, r1 - cmp r0, 0 - beq _0803A33A - ldrb r0, [r4, 0x15] - ldr r7, =gActiveBank - ldrb r7, [r7] - cmp r0, r7 - bne _0803A33A - movs r0, 0x19 - negs r0, r0 - ands r1, r0 - str r1, [r3] - movs r0, 0 - strb r0, [r4, 0x15] -_0803A33A: - adds r4, 0x1C - adds r3, 0x4 - adds r5, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r5, r0 - blt _0803A2F6 -_0803A348: - ldr r1, =gCurrentMove - ldrh r0, [r1] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - ldr r2, =gBattleMoves - adds r1, r2 - ldrb r0, [r1] - cmp r0, 0x7F - bne _0803A414 -_0803A35C: - mov r3, r9 - ldrb r1, [r3] - movs r0, 0x58 - adds r2, r1, 0 - muls r2, r0 - ldr r0, =gBattleMons - adds r0, 0x50 - adds r2, r0 - ldr r0, [r2] - ldr r1, =0x15100007 - ands r0, r1 - str r0, [r2] - ldrb r1, [r3] - lsls r1, 2 - add r1, r10 - ldr r0, [r1] - ldr r2, =0x0003043f - ands r0, r2 - str r0, [r1] - movs r5, 0 - ldr r6, =gNoOfAllBanks - ldrb r6, [r6] - cmp r5, r6 - bge _0803A430 - mov r7, r9 - movs r6, 0 -_0803A390: - ldrb r0, [r7] - bl GetBankSide - adds r4, r0, 0 - lsls r0, r5, 24 - lsrs r0, 24 - bl GetBankSide - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - beq _0803A3D0 - ldr r1, =gStatuses3 - lsls r0, r5, 2 - adds r2, r0, r1 - ldr r1, [r2] - movs r0, 0x18 - ands r0, r1 - cmp r0, 0 - beq _0803A3D0 - ldr r0, =gDisableStructs - adds r0, r6, r0 - ldrb r0, [r0, 0x15] - ldrb r3, [r7] - cmp r0, r3 - bne _0803A3D0 - movs r0, 0x19 - negs r0, r0 - ands r1, r0 - movs r0, 0x10 - orrs r1, r0 - str r1, [r2] -_0803A3D0: - adds r6, 0x1C - adds r5, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r5, r0 - blt _0803A390 - ldr r6, =gDisableStructs - mov r12, r6 - ldr r7, =gActiveBank - mov r9, r7 - b _0803A430 - .pool -_0803A414: - mov r0, r9 - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - ldr r1, =gBattleMons - adds r1, 0x50 - adds r0, r1 - movs r1, 0 - str r1, [r0] - mov r2, r9 - ldrb r0, [r2] - lsls r0, 2 - add r0, r10 - str r1, [r0] -_0803A430: - movs r5, 0 - ldr r3, =gBattleStruct - mov r8, r3 - ldr r6, =gUnknown_020244AC - mov r10, r6 - ldr r7, =gNoOfAllBanks - ldrb r7, [r7] - cmp r5, r7 - bge _0803A490 - ldr r3, =gBattleMons + 0x50 - ldr r7, =gBitTable - ldr r6, =gActiveBank -_0803A448: - movs r0, 0x58 - muls r0, r5 - adds r4, r0, r3 - ldrb r0, [r6] - lsls r0, 2 - adds r0, r7 - ldr r0, [r0] - lsls r2, r0, 16 - ldr r1, [r4] - adds r0, r1, 0 - ands r0, r2 - cmp r0, 0 - beq _0803A466 - bics r1, r2 - str r1, [r4] -_0803A466: - ldr r1, [r4] - movs r0, 0xE0 - lsls r0, 8 - ands r0, r1 - cmp r0, 0 - beq _0803A486 - mov r2, r8 - ldr r0, [r2] - adds r0, r5, r0 - ldrb r0, [r0, 0x14] - ldrb r2, [r6] - cmp r0, r2 - bne _0803A486 - ldr r0, =0xffff1fff - ands r1, r0 - str r1, [r4] -_0803A486: - adds r5, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r5, r0 - blt _0803A448 -_0803A490: - mov r1, r9 - ldrb r0, [r1] - add r0, r10 - movs r1, 0 - strb r1, [r0] - mov r2, r9 - ldrb r0, [r2] - ldr r3, =gUnknown_020244B0 - adds r0, r3 - strb r1, [r0] - ldrb r1, [r2] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - mov r6, r12 - adds r1, r0, r6 - movs r5, 0 - movs r2, 0 -_0803A4B4: - adds r0, r1, r5 - strb r2, [r0] - adds r5, 0x1 - cmp r5, 0x1B - bls _0803A4B4 - ldr r7, =gCurrentMove - ldrh r0, [r7] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - ldr r0, =gBattleMoves - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0x7F - bne _0803A540 - mov r2, r9 - ldrb r1, [r2] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r12 - mov r1, sp - ldrb r1, [r1, 0xA] - strb r1, [r0, 0xA] - ldrb r1, [r2] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r12 - mov r1, sp - ldrb r1, [r1, 0x15] - strb r1, [r0, 0x15] - ldrb r0, [r2] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - add r1, r12 - mov r0, sp - ldrb r2, [r0, 0xF] - lsls r2, 28 - movs r4, 0xF - lsrs r2, 28 - ldrb r3, [r1, 0xF] - movs r0, 0x10 - negs r0, r0 - ands r0, r3 - orrs r0, r2 - strb r0, [r1, 0xF] - mov r3, r9 - ldrb r1, [r3] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r12 - mov r1, sp - ldrb r1, [r1, 0xF] - lsrs r1, 4 - lsls r1, 4 - ldrb r2, [r0, 0xF] - ands r4, r2 - orrs r4, r1 - strb r4, [r0, 0xF] - ldrb r1, [r3] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r12 - mov r1, sp - ldrb r1, [r1, 0x14] - strb r1, [r0, 0x14] -_0803A540: - movs r0, 0 - ldr r6, =gBattleMoveFlags - strb r0, [r6] - mov r7, r9 - ldrb r1, [r7] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r12 - movs r4, 0 - movs r1, 0x2 - strb r1, [r0, 0x16] - ldrb r0, [r7] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - add r1, r12 - mov r0, sp - ldrb r0, [r0, 0x18] - movs r2, 0x2 - ands r2, r0 - ldrb r3, [r1, 0x18] - movs r0, 0x3 - negs r0, r0 - ands r0, r3 - orrs r0, r2 - strb r0, [r1, 0x18] - ldrb r0, [r7] - lsls r0, 1 - ldr r1, =gLastUsedMovesByBanks - adds r0, r1 - movs r2, 0 - strh r4, [r0] - ldrb r0, [r7] - lsls r0, 1 - ldr r3, =gUnknown_02024250 - adds r0, r3 - strh r4, [r0] - ldrb r0, [r7] - lsls r0, 1 - ldr r6, =gUnknown_02024258 - adds r0, r6 - strh r4, [r0] - ldrb r0, [r7] - lsls r0, 1 - ldr r7, =gUnknown_02024260 - adds r0, r7 - strh r4, [r0] - mov r1, r9 - ldrb r0, [r1] - lsls r0, 1 - ldr r3, =gUnknownMovesUsedByBanks - adds r0, r3 - strh r4, [r0] - ldrb r0, [r1] - ldr r6, =gUnknown_02024270 - adds r0, r6 - movs r1, 0xFF - strb r1, [r0] - mov r7, r9 - ldrb r0, [r7] - mov r3, r8 - ldr r1, [r3] - lsls r0, 1 - adds r0, r1 - adds r0, 0x98 - strb r2, [r0] - ldrb r0, [r7] - ldr r1, [r3] - lsls r0, 1 - adds r0, r1 - adds r0, 0x99 - strb r2, [r0] - ldrb r0, [r7] - ldr r1, [r3] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE0 - strb r2, [r0] - ldrb r0, [r7] - ldr r1, [r3] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE1 - strb r2, [r0] - ldrb r0, [r7] - ldr r1, [r3] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE2 - strb r2, [r0] - ldrb r0, [r7] - ldr r1, [r3] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE3 - strb r2, [r0] - ldrb r0, [r7] - ldr r1, [r3] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE4 - strb r2, [r0] - ldrb r0, [r7] - ldr r1, [r3] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE5 - strb r2, [r0] - ldrb r0, [r7] - ldr r1, [r3] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE6 - strb r2, [r0] - ldrb r0, [r7] - ldr r1, [r3] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE7 - strb r2, [r0] - ldr r1, [r3] - adds r1, 0x92 - ldrb r0, [r7] - lsls r0, 2 - ldr r6, =gBitTable - adds r0, r6 - ldr r2, [r0] - ldrb r0, [r1] - bics r0, r2 - strb r0, [r1] - movs r5, 0 - ldr r7, =gNoOfAllBanks - ldrb r7, [r7] - cmp r5, r7 - bge _0803A6B4 - mov r3, r9 - mov r7, r8 - movs r6, 0 -_0803A656: - ldrb r0, [r3] - cmp r5, r0 - beq _0803A68C - lsls r0, r5, 24 - lsrs r0, 24 - str r3, [sp, 0x1C] - bl GetBankSide - adds r4, r0, 0 - ldr r3, [sp, 0x1C] - ldrb r0, [r3] - bl GetBankSide - lsls r4, 24 - lsls r0, 24 - ldr r3, [sp, 0x1C] - cmp r4, r0 - beq _0803A68C - ldr r0, [r7] - lsls r1, r5, 1 - adds r0, r1, r0 - adds r0, 0x98 - strb r6, [r0] - ldr r0, [r7] - adds r1, r0 - adds r1, 0x99 - strb r6, [r1] -_0803A68C: - ldrb r0, [r3] - ldr r1, [r7] - lsls r0, 1 - lsls r2, r5, 3 - adds r0, r2 - adds r0, r1 - adds r0, 0xE0 - strb r6, [r0] - ldrb r0, [r3] - ldr r1, [r7] - lsls r0, 1 - adds r0, r2 - adds r0, r1 - adds r0, 0xE1 - strb r6, [r0] - adds r5, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r5, r0 - blt _0803A656 -_0803A6B4: - mov r1, r9 - ldrb r0, [r1] - mov r2, r8 - ldr r1, [r2] - lsls r0, 1 - adds r0, r1 - adds r0, 0xC8 - movs r2, 0 - strb r2, [r0] - mov r3, r9 - ldrb r0, [r3] - mov r6, r8 - ldr r1, [r6] - lsls r0, 1 - adds r0, r1 - adds r0, 0xC9 - strb r2, [r0] - ldr r0, =gBattleResources - ldr r0, [r0] - ldr r1, [r0, 0x4] - ldrb r0, [r3] - lsls r0, 2 - adds r1, r0 - movs r2, 0 - str r2, [r1] - ldr r0, =gCurrentMove - strh r2, [r0] - ldr r0, [r6] - adds r0, 0xDA - movs r1, 0xFF - strb r1, [r0] - ldrb r0, [r3] - bl ClearBankMoveHistory - mov r7, r9 - ldrb r0, [r7] - bl ClearBankAbilityHistory - add sp, 0x20 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end SwitchInClearStructs - - thumb_func_start UndoEffectsAfterFainting -UndoEffectsAfterFainting: @ 803A75C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - movs r5, 0 - ldr r6, =gBattleMons - ldr r0, =gStatuses3 - mov r8, r0 - ldr r1, =gBattleStruct - mov r12, r1 - ldr r2, =gUnknown_020244AC - mov r9, r2 - ldr r3, =gUnknown_020244B0 - mov r10, r3 - ldr r7, =gProtectStructs - ldr r4, =gActiveBank - movs r3, 0x58 - adds r2, r6, 0 - adds r2, 0x18 - movs r1, 0x6 -_0803A788: - ldrb r0, [r4] - muls r0, r3 - adds r0, r5, r0 - adds r0, r2 - strb r1, [r0] - adds r5, 0x1 - cmp r5, 0x7 - ble _0803A788 - ldr r0, =gActiveBank - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r2, r6, 0 - adds r2, 0x50 - adds r0, r2 - movs r1, 0 - str r1, [r0] - ldr r3, =gActiveBank - ldrb r0, [r3] - lsls r0, 2 - add r0, r8 - str r1, [r0] - movs r5, 0 - ldr r6, =gNoOfAllBanks - ldrb r6, [r6] - cmp r5, r6 - bge _0803A830 - adds r3, r2, 0 - movs r4, 0 - ldr r0, =gBitTable - mov r8, r0 -_0803A7C6: - ldr r1, [r3] - movs r0, 0x80 - lsls r0, 19 - ands r0, r1 - cmp r0, 0 - beq _0803A7E6 - ldr r2, =gDisableStructs - adds r0, r4, r2 - ldrb r0, [r0, 0x14] - ldr r6, =gActiveBank - ldrb r6, [r6] - cmp r0, r6 - bne _0803A7E6 - ldr r0, =0xfbffffff - ands r1, r0 - str r1, [r3] -_0803A7E6: - ldr r1, =gActiveBank - ldrb r0, [r1] - lsls r0, 2 - add r0, r8 - ldr r0, [r0] - lsls r2, r0, 16 - ldr r1, [r3] - adds r0, r1, 0 - ands r0, r2 - cmp r0, 0 - beq _0803A800 - bics r1, r2 - str r1, [r3] -_0803A800: - ldr r1, [r3] - movs r0, 0xE0 - lsls r0, 8 - ands r0, r1 - cmp r0, 0 - beq _0803A822 - mov r2, r12 - ldr r0, [r2] - adds r0, r5, r0 - ldrb r0, [r0, 0x14] - ldr r6, =gActiveBank - ldrb r6, [r6] - cmp r0, r6 - bne _0803A822 - ldr r0, =0xffff1fff - ands r1, r0 - str r1, [r3] -_0803A822: - adds r3, 0x58 - adds r4, 0x1C - adds r5, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r5, r0 - blt _0803A7C6 -_0803A830: - ldr r1, =gActiveBank - ldrb r0, [r1] - add r0, r9 - movs r1, 0 - strb r1, [r0] - ldr r2, =gActiveBank - ldrb r0, [r2] - add r0, r10 - strb r1, [r0] - ldrb r1, [r2] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - ldr r3, =gDisableStructs - adds r1, r0, r3 - movs r5, 0 - movs r2, 0 -_0803A852: - adds r0, r1, r5 - strb r2, [r0] - adds r5, 0x1 - cmp r5, 0x1B - bls _0803A852 - ldr r6, =gActiveBank - ldrb r1, [r6] - lsls r1, 4 - adds r1, r7 - ldrb r2, [r1] - movs r0, 0x2 - negs r0, r0 - mov r9, r0 - ands r0, r2 - strb r0, [r1] - ldrb r1, [r6] - lsls r1, 4 - adds r1, r7 - ldrb r2, [r1] - movs r3, 0x3 - negs r3, r3 - mov r8, r3 - mov r0, r8 - ands r0, r2 - strb r0, [r1] - ldrb r1, [r6] - lsls r1, 4 - adds r1, r7 - ldrb r2, [r1] - movs r6, 0x5 - negs r6, r6 - adds r0, r6, 0 - ands r0, r2 - strb r0, [r1] - ldr r0, =gActiveBank - ldrb r1, [r0] - lsls r1, 4 - adds r1, r7 - ldrb r2, [r1] - subs r3, 0x6 - mov r10, r3 - mov r0, r10 - ands r0, r2 - strb r0, [r1] - ldr r0, =gActiveBank - ldrb r1, [r0] - lsls r1, 4 - adds r1, r7 - ldrb r2, [r1] - movs r0, 0x11 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - ldr r2, =gActiveBank - ldrb r1, [r2] - lsls r1, 4 - adds r1, r7 - ldrb r2, [r1] - movs r5, 0x21 - negs r5, r5 - adds r0, r5, 0 - ands r0, r2 - strb r0, [r1] - ldr r3, =gActiveBank - ldrb r1, [r3] - lsls r1, 4 - adds r1, r7 - ldrb r2, [r1] - movs r4, 0x41 - negs r4, r4 - adds r0, r4, 0 - ands r0, r2 - strb r0, [r1] - ldrb r1, [r3] - lsls r1, 4 - adds r1, r7 - ldrb r2, [r1] - movs r3, 0x7F - adds r0, r3, 0 - ands r0, r2 - strb r0, [r1] - ldr r0, =gActiveBank - ldrb r1, [r0] - lsls r1, 4 - adds r1, r7 - ldrb r2, [r1, 0x1] - mov r0, r9 - ands r0, r2 - strb r0, [r1, 0x1] - ldr r2, =gActiveBank - ldrb r1, [r2] - lsls r1, 4 - adds r1, r7 - ldrb r2, [r1, 0x1] - mov r0, r8 - ands r0, r2 - strb r0, [r1, 0x1] - ldr r0, =gActiveBank - ldrb r1, [r0] - lsls r1, 4 - adds r1, r7 - ldrb r2, [r1, 0x1] - adds r0, r6, 0 - ands r0, r2 - strb r0, [r1, 0x1] - ldr r2, =gActiveBank - ldrb r1, [r2] - lsls r1, 4 - adds r1, r7 - ldrb r2, [r1, 0x1] - movs r0, 0x19 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x1] - ldr r1, =gActiveBank - ldrb r0, [r1] - lsls r0, 4 - adds r0, r7 - ldrb r1, [r0, 0x1] - ands r5, r1 - strb r5, [r0, 0x1] - ldr r2, =gActiveBank - ldrb r0, [r2] - lsls r0, 4 - adds r0, r7 - ldrb r1, [r0, 0x1] - ands r4, r1 - strb r4, [r0, 0x1] - ldrb r0, [r2] - lsls r0, 4 - adds r0, r7 - ldrb r1, [r0, 0x1] - ands r3, r1 - strb r3, [r0, 0x1] - ldrb r0, [r2] - lsls r0, 4 - adds r0, r7 - ldrb r1, [r0, 0x2] - mov r3, r9 - ands r3, r1 - strb r3, [r0, 0x2] - ldrb r0, [r2] - lsls r0, 4 - adds r0, r7 - ldrb r1, [r0, 0x2] - mov r2, r8 - ands r2, r1 - strb r2, [r0, 0x2] - ldr r3, =gActiveBank - ldrb r0, [r3] - lsls r0, 4 - adds r0, r7 - ldrb r1, [r0, 0x2] - ands r6, r1 - strb r6, [r0, 0x2] - ldrb r0, [r3] - lsls r0, 4 - adds r0, r7 - ldrb r1, [r0, 0x2] - mov r6, r10 - ands r6, r1 - strb r6, [r0, 0x2] - ldrb r1, [r3] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - ldr r1, =gDisableStructs - adds r0, r1 - movs r2, 0 - movs r1, 0x2 - strb r1, [r0, 0x16] - ldrb r0, [r3] - lsls r0, 1 - ldr r3, =gLastUsedMovesByBanks - adds r0, r3 - movs r3, 0 - strh r2, [r0] - ldr r6, =gActiveBank - ldrb r0, [r6] - lsls r0, 1 - ldr r1, =gUnknown_02024250 - adds r0, r1 - strh r2, [r0] - ldrb r0, [r6] - lsls r0, 1 - ldr r6, =gUnknown_02024258 - adds r0, r6 - strh r2, [r0] - ldr r1, =gActiveBank - ldrb r0, [r1] - lsls r0, 1 - ldr r6, =gUnknown_02024260 - adds r0, r6 - strh r2, [r0] - ldrb r0, [r1] - lsls r0, 1 - ldr r1, =gUnknownMovesUsedByBanks - adds r0, r1 - strh r2, [r0] - ldr r2, =gActiveBank - ldrb r0, [r2] - ldr r6, =gUnknown_02024270 - adds r0, r6 - movs r1, 0xFF - strb r1, [r0] - ldrb r0, [r2] - mov r2, r12 - ldr r1, [r2] - lsls r0, 1 - adds r0, r1 - adds r0, 0xC8 - strb r3, [r0] - ldr r6, =gActiveBank - ldrb r0, [r6] - ldr r1, [r2] - lsls r0, 1 - adds r0, r1 - adds r0, 0xC9 - strb r3, [r0] - ldrb r0, [r6] - ldr r1, [r2] - lsls r0, 1 - adds r0, r1 - adds r0, 0x98 - strb r3, [r0] - ldrb r0, [r6] - ldr r1, [r2] - lsls r0, 1 - adds r0, r1 - adds r0, 0x99 - strb r3, [r0] - ldrb r0, [r6] - ldr r1, [r2] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE0 - strb r3, [r0] - ldrb r0, [r6] - ldr r1, [r2] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE1 - strb r3, [r0] - ldrb r0, [r6] - ldr r1, [r2] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE2 - strb r3, [r0] - ldrb r0, [r6] - ldr r1, [r2] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE3 - strb r3, [r0] - ldrb r0, [r6] - ldr r1, [r2] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE4 - strb r3, [r0] - ldrb r0, [r6] - ldr r1, [r2] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE5 - strb r3, [r0] - ldrb r0, [r6] - ldr r1, [r2] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE6 - strb r3, [r0] - ldrb r0, [r6] - ldr r1, [r2] - lsls r0, 3 - adds r0, r1 - adds r0, 0xE7 - strb r3, [r0] - ldr r1, [r2] - adds r1, 0x92 - ldrb r0, [r6] - lsls r0, 2 - ldr r2, =gBitTable - adds r0, r2 - ldr r2, [r0] - ldrb r0, [r1] - bics r0, r2 - strb r0, [r1] - movs r5, 0 - ldr r3, =gNoOfAllBanks - ldrb r3, [r3] - cmp r5, r3 - bge _0803AB02 - adds r3, r6, 0 - mov r7, r12 - movs r6, 0 -_0803AAA4: - ldrb r0, [r3] - cmp r5, r0 - beq _0803AADA - lsls r0, r5, 24 - lsrs r0, 24 - str r3, [sp] - bl GetBankSide - adds r4, r0, 0 - ldr r3, [sp] - ldrb r0, [r3] - bl GetBankSide - lsls r4, 24 - lsls r0, 24 - ldr r3, [sp] - cmp r4, r0 - beq _0803AADA - ldr r0, [r7] - lsls r1, r5, 1 - adds r0, r1, r0 - adds r0, 0x98 - strb r6, [r0] - ldr r0, [r7] - adds r1, r0 - adds r1, 0x99 - strb r6, [r1] -_0803AADA: - ldrb r0, [r3] - ldr r1, [r7] - lsls r0, 1 - lsls r2, r5, 3 - adds r0, r2 - adds r0, r1 - adds r0, 0xE0 - strb r6, [r0] - ldrb r0, [r3] - ldr r1, [r7] - lsls r0, 1 - adds r0, r2 - adds r0, r1 - adds r0, 0xE1 - strb r6, [r0] - adds r5, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r5, r0 - blt _0803AAA4 -_0803AB02: - ldr r0, =gBattleResources - ldr r0, [r0] - ldr r1, [r0, 0x4] - ldr r2, =gActiveBank - ldrb r0, [r2] - lsls r0, 2 - adds r1, r0 - movs r0, 0 - str r0, [r1] - ldr r4, =gBattleMons - ldrb r0, [r2] - movs r3, 0x58 - adds r2, r0, 0 - muls r2, r3 - b _0803AB6C - .pool -_0803AB6C: - adds r2, r4 - ldr r5, =gBaseStats - ldrh r1, [r2] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r5 - ldrb r0, [r0, 0x6] - adds r2, 0x21 - strb r0, [r2] - ldr r6, =gActiveBank - ldrb r0, [r6] - adds r1, r0, 0 - muls r1, r3 - adds r1, r4 - ldrh r2, [r1] - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r5 - ldrb r0, [r0, 0x7] - adds r1, 0x22 - strb r0, [r1] - ldrb r0, [r6] - bl ClearBankMoveHistory - ldrb r0, [r6] - bl ClearBankAbilityHistory - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end UndoEffectsAfterFainting - - thumb_func_start bc_8012FAC -bc_8012FAC: @ 803ABC0 - push {r4,r5,lr} - ldr r5, =gBattleCommunication - ldrb r0, [r5] - cmp r0, 0 - beq _0803ABD4 - cmp r0, 0x1 - beq _0803ABF8 - b _0803AC2E - .pool -_0803ABD4: - ldr r4, =gActiveBank - ldrb r0, [r5, 0x1] - strb r0, [r4] - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl EmitGetMonData - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - b _0803AC2E - .pool -_0803ABF8: - ldr r0, =gBattleExecBuffer - ldr r2, [r0] - cmp r2, 0 - bne _0803AC2E - ldrb r0, [r5, 0x1] - adds r0, 0x1 - strb r0, [r5, 0x1] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bne _0803AC2C - ldr r1, =gBattleMainFunc - ldr r0, =bc_load_battlefield - str r0, [r1] - b _0803AC2E - .pool -_0803AC2C: - strb r2, [r5] -_0803AC2E: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end bc_8012FAC - - thumb_func_start bc_load_battlefield -bc_load_battlefield: @ 803AC34 - push {r4,r5,lr} - ldr r0, =gBattleExecBuffer - ldr r5, [r0] - cmp r5, 0 - bne _0803AC64 - movs r0, 0 - bl GetBankByIdentity - ldr r4, =gActiveBank - strb r0, [r4] - ldr r0, =gBattleTerrain - ldrb r1, [r0] - movs r0, 0 - bl dp01_build_cmdbuf_x2E_a - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r1, =gBattleMainFunc - ldr r0, =sub_803AC84 - str r0, [r1] - ldr r0, =gBattleCommunication - strb r5, [r0] - strb r5, [r0, 0x1] -_0803AC64: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end bc_load_battlefield - - thumb_func_start sub_803AC84 -sub_803AC84: @ 803AC84 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r0, =gBattleExecBuffer - ldr r1, [r0] - cmp r1, 0 - beq _0803AC98 - b _0803AF4E -_0803AC98: - ldr r2, =gActiveBank - strb r1, [r2] - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r1, r0 - bcc _0803ACA6 - b _0803AF48 -_0803ACA6: - movs r7, 0x58 - ldr r0, =gBattleMons - mov r8, r0 - mov r9, r2 - movs r1, 0x48 - add r1, r8 - mov r10, r1 -_0803ACB4: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0803ACFC - ldr r4, =gActiveBank - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0803ACFC - ldrb r0, [r4] - muls r0, r7 - mov r2, r8 - adds r3, r0, r2 - movs r2, 0 - movs r1, 0 -_0803ACDA: - adds r0, r3, r2 - strb r1, [r0] - adds r2, 0x1 - cmp r2, 0x57 - bls _0803ACDA - b _0803ADCA - .pool -_0803ACFC: - mov r1, r9 - ldrb r0, [r1] - muls r0, r7 - mov r2, r8 - adds r3, r0, r2 - movs r2, 0 - ldr r6, =gBaseStats - ldr r5, =gBattleBufferB - ldr r4, =gActiveBank -_0803AD0E: - adds r0, r3, r2 - ldrb r1, [r4] - lsls r1, 9 - adds r1, 0x4 - adds r1, r2, r1 - adds r1, r5 - ldrb r1, [r1] - strb r1, [r0] - adds r2, 0x1 - cmp r2, 0x57 - bls _0803AD0E - mov r1, r9 - ldrb r0, [r1] - adds r2, r0, 0 - muls r2, r7 - add r2, r8 - ldrh r1, [r2] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r6 - ldrb r0, [r0, 0x6] - adds r2, 0x21 - strb r0, [r2] - mov r2, r9 - ldrb r0, [r2] - adds r2, r0, 0 - muls r2, r7 - add r2, r8 - ldrh r1, [r2] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r6 - ldrb r0, [r0, 0x7] - adds r2, 0x22 - strb r0, [r2] - mov r1, r9 - ldrb r0, [r1] - adds r1, r0, 0 - muls r1, r7 - add r1, r8 - ldrh r0, [r1] - ldrb r1, [r1, 0x17] - lsrs r1, 7 - bl GetAbilityBySpecies - mov r2, r9 - ldrb r1, [r2] - muls r1, r7 - add r1, r8 - adds r1, 0x20 - strb r0, [r1] - ldrb r0, [r2] - bl GetBankSide - ldr r1, =gBattleStruct - lsls r0, 24 - lsrs r0, 23 - adds r0, 0xA8 - ldr r1, [r1] - adds r1, r0 - mov r2, r9 - ldrb r0, [r2] - muls r0, r7 - add r0, r8 - ldrh r0, [r0, 0x28] - strh r0, [r1] - movs r2, 0 - ldr r4, =gActiveBank - movs r5, 0x58 - ldr r1, =gBattleMons + 0x18 - adds r6, r4, 0 - movs r0, 0x18 - negs r0, r0 - adds r0, r1 - mov r12, r0 - movs r3, 0x6 -_0803ADAA: - ldrb r0, [r4] - muls r0, r5 - adds r0, r2, r0 - adds r0, r1 - strb r3, [r0] - adds r2, 0x1 - cmp r2, 0x7 - ble _0803ADAA - ldrb r0, [r6] - adds r1, r0, 0 - muls r1, r7 - mov r0, r12 - adds r0, 0x50 - adds r1, r0 - movs r0, 0 - str r0, [r1] -_0803ADCA: - ldr r4, =gActiveBank - ldrb r0, [r4] - bl GetBankIdentity - lsls r0, 24 - cmp r0, 0 - bne _0803ADE4 - movs r0, 0 - bl dp01_build_cmdbuf_x07_7_7_7 - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0803ADE4: - ldr r5, =gBattleTypeFlags - ldr r0, [r5] - movs r1, 0x8 - ands r0, r1 - cmp r0, 0 - beq _0803AE60 - ldrb r0, [r4] - bl GetBankIdentity - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0803AE0A - movs r0, 0 - bl dp01_build_cmdbuf_x07_7_7_7 - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0803AE0A: - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0803AEC0 - ldr r0, [r5] - ldr r1, =0x063f0902 - ands r0, r1 - cmp r0, 0 - bne _0803AEC0 - ldrb r0, [r4] - muls r0, r7 - add r0, r8 - ldrh r0, [r0] - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - ldrb r1, [r4] - muls r1, r7 - add r1, r10 - ldr r2, [r1] - movs r1, 0x2 - bl HandleSetPokedexFlag - b _0803AEC0 - .pool -_0803AE60: - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0803AEC0 - ldr r0, [r5] - ldr r1, =0x063f0902 - ands r0, r1 - cmp r0, 0 - bne _0803AE96 - ldrb r0, [r4] - muls r0, r7 - add r0, r8 - ldrh r0, [r0] - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - ldrb r1, [r4] - muls r1, r7 - add r1, r10 - ldr r2, [r1] - movs r1, 0x2 - bl HandleSetPokedexFlag -_0803AE96: - movs r0, 0 - bl dp01_build_cmdbuf_x04_4_4_4 - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r1, =gBattlePartyID - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gEnemyParty - adds r0, r1 - movs r1, 0xB - movs r2, 0 - bl GetMonData - ldr r1, =gBattleResults - strh r0, [r1, 0x20] -_0803AEC0: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0803AEF6 - ldr r4, =gActiveBank - ldrb r0, [r4] - bl GetBankIdentity - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - beq _0803AEEA - ldrb r0, [r4] - bl GetBankIdentity - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bne _0803AEF6 -_0803AEEA: - movs r0, 0 - bl dp01_build_cmdbuf_x07_7_7_7 - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0803AEF6: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 8 - ands r0, r1 - cmp r0, 0 - beq _0803AF20 - ldr r4, =gActiveBank - ldrb r0, [r4] - bl GetBankIdentity - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bne _0803AF20 - movs r0, 0 - bl dp01_build_cmdbuf_x07_7_7_7 - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0803AF20: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 11 - ands r0, r1 - cmp r0, 0 - beq _0803AF32 - bl sub_81A56B4 -_0803AF32: - mov r1, r9 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bcs _0803AF48 - b _0803ACB4 -_0803AF48: - ldr r1, =gBattleMainFunc - ldr r0, =bc_801333C - str r0, [r1] -_0803AF4E: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803AC84 - - thumb_func_start bc_801333C -bc_801333C: @ 803AF80 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x30 - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - beq _0803AF92 - b _0803B10C -_0803AF92: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x8 - ands r0, r1 - cmp r0, 0 - bne _0803AFA0 - b _0803B0AC -_0803AFA0: - movs r7, 0 - add r0, sp, 0x4 - mov r8, r0 - mov r6, r8 - mov r5, sp -_0803AFAA: - movs r0, 0x64 - adds r1, r7, 0 - muls r1, r0 - ldr r0, =gEnemyParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - cmp r0, 0 - beq _0803AFD0 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - bne _0803AFE8 -_0803AFD0: - ldr r0, =0x0000ffff - strh r0, [r5] - movs r0, 0 - b _0803AFFA - .pool -_0803AFE8: - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - strh r0, [r5] - adds r0, r4, 0 - movs r1, 0x37 - bl GetMonData -_0803AFFA: - str r0, [r6] - adds r6, 0x8 - adds r5, 0x8 - adds r7, 0x1 - cmp r7, 0x5 - ble _0803AFAA - movs r0, 0x1 - bl GetBankByIdentity - ldr r4, =gActiveBank - strb r0, [r4] - movs r0, 0 - mov r1, sp - movs r2, 0x80 - bl EmitCmd48 - ldrb r0, [r4] - bl MarkBufferBankForExecution - movs r7, 0 - mov r6, r8 - mov r5, sp -_0803B026: - movs r0, 0x64 - adds r1, r7, 0 - muls r1, r0 - ldr r0, =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - cmp r0, 0 - beq _0803B04C - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - bne _0803B060 -_0803B04C: - ldr r0, =0x0000ffff - strh r0, [r5] - movs r0, 0 - b _0803B072 - .pool -_0803B060: - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - strh r0, [r5] - adds r0, r4, 0 - movs r1, 0x37 - bl GetMonData -_0803B072: - str r0, [r6] - adds r6, 0x8 - adds r5, 0x8 - adds r7, 0x1 - cmp r7, 0x5 - ble _0803B026 - movs r0, 0 - bl GetBankByIdentity - ldr r4, =gActiveBank - strb r0, [r4] - movs r0, 0 - mov r1, sp - movs r2, 0x80 - bl EmitCmd48 - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r1, =gBattleMainFunc - ldr r0, =bc_battle_begin_message - b _0803B10A - .pool -_0803B0AC: - movs r7, 0 - add r6, sp, 0x4 - mov r5, sp -_0803B0B2: - movs r0, 0x64 - adds r1, r7, 0 - muls r1, r0 - ldr r0, =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - cmp r0, 0 - beq _0803B0D8 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - bne _0803B0E8 -_0803B0D8: - ldr r0, =0x0000ffff - strh r0, [r5] - movs r0, 0 - b _0803B0FA - .pool -_0803B0E8: - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - strh r0, [r5] - adds r0, r4, 0 - movs r1, 0x37 - bl GetMonData -_0803B0FA: - str r0, [r6] - adds r6, 0x8 - adds r5, 0x8 - adds r7, 0x1 - cmp r7, 0x5 - ble _0803B0B2 - ldr r1, =gBattleMainFunc - ldr r0, =bc_8013568 -_0803B10A: - str r0, [r1] -_0803B10C: - add sp, 0x30 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end bc_801333C - - thumb_func_start bc_battle_begin_message -bc_battle_begin_message: @ 803B120 - push {lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0803B142 - movs r0, 0x1 - bl GetBankByIdentity - ldr r1, =gActiveBank - strb r0, [r1] - ldrb r1, [r1] - movs r0, 0 - bl PrepareStringBattle - ldr r1, =gBattleMainFunc - ldr r0, =sub_803B180 - str r0, [r1] -_0803B142: - pop {r0} - bx r0 - .pool - thumb_func_end bc_battle_begin_message - - thumb_func_start bc_8013568 -bc_8013568: @ 803B158 - push {lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0803B170 - ldr r1, =gBattleMainFunc - ldr r0, =sub_803B3CC - str r0, [r1] - movs r0, 0 - movs r1, 0 - bl PrepareStringBattle -_0803B170: - pop {r0} - bx r0 - .pool - thumb_func_end bc_8013568 - - thumb_func_start sub_803B180 -sub_803B180: @ 803B180 - push {lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0803B1D0 - ldr r0, =gBattleTypeFlags - ldr r2, [r0] - movs r0, 0x80 - lsls r0, 17 - ands r0, r2 - cmp r0, 0 - beq _0803B1B8 - movs r0, 0x80 - lsls r0, 18 - ands r0, r2 - cmp r0, 0 - beq _0803B1B8 - movs r1, 0x80 - lsls r1, 24 - ands r1, r2 - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 - b _0803B1BA - .pool -_0803B1B8: - movs r0, 0x1 -_0803B1BA: - bl GetBankByIdentity - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - movs r0, 0x1 - bl PrepareStringBattle - ldr r1, =gBattleMainFunc - ldr r0, =sub_803B25C - str r0, [r1] -_0803B1D0: - pop {r0} - bx r0 - .pool - thumb_func_end sub_803B180 - - thumb_func_start sub_803B1DC -sub_803B1DC: @ 803B1DC - push {r4,r5,lr} - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x80 - lsls r0, 17 - ands r0, r1 - cmp r0, 0 - beq _0803B1FC - movs r0, 0x80 - lsls r0, 18 - ands r0, r1 - cmp r0, 0 - beq _0803B1FC - movs r5, 0x2 - cmp r1, 0 - bge _0803B1FE -_0803B1FC: - movs r5, 0x3 -_0803B1FE: - ldr r1, =gActiveBank - movs r0, 0 - strb r0, [r1] - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r0, 0 - beq _0803B23A - adds r4, r1, 0 -_0803B20E: - ldrb r0, [r4] - bl GetBankIdentity - lsls r0, 24 - lsrs r0, 24 - cmp r0, r5 - bne _0803B228 - movs r0, 0 - bl dp01_build_cmdbuf_x2F_2F_2F_2F - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0803B228: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bcc _0803B20E -_0803B23A: - ldr r1, =gBattleMainFunc - ldr r0, =bc_801362C - str r0, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803B1DC - - thumb_func_start sub_803B25C -sub_803B25C: @ 803B25C - push {r4-r6,lr} - ldr r0, =gBattleTypeFlags - ldr r2, [r0] - movs r0, 0x80 - lsls r0, 17 - ands r0, r2 - cmp r0, 0 - beq _0803B298 - movs r0, 0x80 - lsls r0, 18 - ands r0, r2 - cmp r0, 0 - beq _0803B298 - movs r1, 0x80 - lsls r1, 24 - ands r1, r2 - negs r0, r1 - orrs r0, r1 - lsrs r5, r0, 31 - b _0803B29A - .pool -_0803B288: - ldr r1, =gBattleMainFunc - ldr r0, =sub_803B1DC - b _0803B2F0 - .pool -_0803B298: - movs r5, 0x1 -_0803B29A: - ldr r0, =gBattleExecBuffer - ldr r2, [r0] - cmp r2, 0 - bne _0803B2F2 - ldr r0, =gActiveBank - strb r2, [r0] - ldr r1, =gNoOfAllBanks - adds r4, r0, 0 - ldrb r1, [r1] - cmp r2, r1 - bcs _0803B2EC - adds r6, r4, 0 -_0803B2B2: - ldrb r0, [r4] - bl GetBankIdentity - lsls r0, 24 - lsrs r0, 24 - cmp r0, r5 - bne _0803B2D8 - movs r0, 0 - bl dp01_build_cmdbuf_x2F_2F_2F_2F - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ldr r1, =0x00008040 - ands r0, r1 - cmp r0, 0 - bne _0803B288 -_0803B2D8: - ldrb r0, [r6] - adds r0, 0x1 - strb r0, [r6] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldr r4, =gActiveBank - ldrb r1, [r1] - cmp r0, r1 - bcc _0803B2B2 -_0803B2EC: - ldr r1, =gBattleMainFunc - ldr r0, =bc_801362C -_0803B2F0: - str r0, [r1] -_0803B2F2: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803B25C - - thumb_func_start bc_801362C -bc_801362C: @ 803B314 - push {r4-r7,lr} - ldr r0, =gBattleExecBuffer - ldr r1, [r0] - cmp r1, 0 - bne _0803B384 - ldr r2, =gActiveBank - strb r1, [r2] - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r1, r0 - bcs _0803B37E - adds r4, r2, 0 - ldr r6, =gBattleMons - movs r5, 0x58 - adds r7, r6, 0 - adds r7, 0x48 -_0803B334: - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0803B36C - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ldr r1, =0x063f0902 - ands r0, r1 - cmp r0, 0 - bne _0803B36C - ldrb r0, [r4] - muls r0, r5 - adds r0, r6 - ldrh r0, [r0] - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - ldrb r1, [r4] - muls r1, r5 - adds r1, r7 - ldr r2, [r1] - movs r1, 0x2 - bl HandleSetPokedexFlag -_0803B36C: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bcc _0803B334 -_0803B37E: - ldr r1, =gBattleMainFunc - ldr r0, =sub_803B3CC - str r0, [r1] -_0803B384: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end bc_801362C - - thumb_func_start sub_803B3AC -sub_803B3AC: @ 803B3AC - push {lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0803B3BC - ldr r1, =gBattleMainFunc - ldr r0, =sub_803B3CC - str r0, [r1] -_0803B3BC: - pop {r0} - bx r0 - .pool - thumb_func_end sub_803B3AC - - thumb_func_start sub_803B3CC -sub_803B3CC: @ 803B3CC - push {lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0803B418 - ldr r1, =gBattleTypeFlags - ldr r2, [r1] - movs r0, 0x80 - lsls r0, 17 - ands r0, r2 - cmp r0, 0 - beq _0803B3F4 - movs r0, 0x80 - lsls r0, 18 - ands r0, r2 - cmp r0, 0 - beq _0803B3F4 - movs r3, 0x1 - cmp r2, 0 - bge _0803B3F6 -_0803B3F4: - movs r3, 0 -_0803B3F6: - ldr r0, [r1] - movs r1, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0803B412 - adds r0, r3, 0 - bl GetBankByIdentity - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - movs r0, 0x1 - bl PrepareStringBattle -_0803B412: - ldr r1, =gBattleMainFunc - ldr r0, =sub_803B4C8 - str r0, [r1] -_0803B418: - pop {r0} - bx r0 - .pool - thumb_func_end sub_803B3CC - - thumb_func_start sub_803B42C -sub_803B42C: @ 803B42C - push {r4,r5,lr} - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x80 - lsls r0, 17 - ands r0, r1 - cmp r0, 0 - beq _0803B44C - movs r0, 0x80 - lsls r0, 18 - ands r0, r1 - cmp r0, 0 - beq _0803B44C - movs r5, 0x3 - cmp r1, 0 - bge _0803B44E -_0803B44C: - movs r5, 0x2 -_0803B44E: - ldr r1, =gActiveBank - movs r0, 0 - strb r0, [r1] - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r0, 0 - beq _0803B48A - adds r4, r1, 0 -_0803B45E: - ldrb r0, [r4] - bl GetBankIdentity - lsls r0, 24 - lsrs r0, 24 - cmp r0, r5 - bne _0803B478 - movs r0, 0 - bl dp01_build_cmdbuf_x2F_2F_2F_2F - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0803B478: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bcc _0803B45E -_0803B48A: - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r0, 0x4C - movs r1, 0 - strb r1, [r0] - ldr r0, [r2] - adds r0, 0xD9 - strb r1, [r0] - ldr r0, [r2] - movs r2, 0xD1 - lsls r2, 1 - adds r0, r2 - strb r1, [r0] - ldr r1, =gBattleMainFunc - ldr r0, =sub_803B628 - str r0, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803B42C - - thumb_func_start sub_803B4C8 -sub_803B4C8: @ 803B4C8 - push {r4-r6,lr} - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x80 - lsls r0, 17 - ands r0, r1 - cmp r0, 0 - beq _0803B500 - movs r0, 0x80 - lsls r0, 18 - ands r0, r1 - cmp r0, 0 - beq _0803B500 - movs r6, 0x1 - cmp r1, 0 - bge _0803B502 - b _0803B500 - .pool -_0803B4F0: - ldr r1, =gBattleMainFunc - ldr r0, =sub_803B42C - b _0803B572 - .pool -_0803B500: - movs r6, 0 -_0803B502: - ldr r0, =gBattleExecBuffer - ldr r2, [r0] - cmp r2, 0 - bne _0803B574 - ldr r0, =gActiveBank - strb r2, [r0] - ldr r1, =gNoOfAllBanks - adds r4, r0, 0 - ldrb r1, [r1] - cmp r2, r1 - bcs _0803B554 - adds r5, r4, 0 -_0803B51A: - ldrb r0, [r4] - bl GetBankIdentity - lsls r0, 24 - lsrs r0, 24 - cmp r0, r6 - bne _0803B540 - movs r0, 0 - bl dp01_build_cmdbuf_x2F_2F_2F_2F - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - bne _0803B4F0 -_0803B540: - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldr r4, =gActiveBank - ldrb r1, [r1] - cmp r0, r1 - bcc _0803B51A -_0803B554: - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r0, 0x4C - movs r1, 0 - strb r1, [r0] - ldr r0, [r2] - adds r0, 0xD9 - strb r1, [r0] - ldr r0, [r2] - movs r2, 0xD1 - lsls r2, 1 - adds r0, r2 - strb r1, [r0] - ldr r1, =gBattleMainFunc - ldr r0, =sub_803B628 -_0803B572: - str r0, [r1] -_0803B574: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803B4C8 - - thumb_func_start sub_803B598 -sub_803B598: @ 803B598 - push {r4,r5,lr} - ldr r0, =gBattleExecBuffer - ldr r1, [r0] - cmp r1, 0 - bne _0803B606 - ldr r2, =gActiveBank - strb r1, [r2] - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r1, r0 - bcs _0803B5E6 - adds r4, r2, 0 - ldr r5, =gBattlePartyID -_0803B5B2: - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0803B5D4 - ldrb r0, [r4] - lsls r0, 1 - adds r0, r5 - ldrb r1, [r0] - movs r0, 0 - movs r2, 0 - bl EmitSwitchInAnim - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0803B5D4: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bcc _0803B5B2 -_0803B5E6: - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r0, 0x4C - movs r1, 0 - strb r1, [r0] - ldr r0, [r2] - adds r0, 0xD9 - strb r1, [r0] - ldr r0, [r2] - movs r2, 0xD1 - lsls r2, 1 - adds r0, r2 - strb r1, [r0] - ldr r1, =gBattleMainFunc - ldr r0, =sub_803B628 - str r0, [r1] -_0803B606: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803B598 - - thumb_func_start sub_803B628 -sub_803B628: @ 803B628 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - movs r0, 0 - mov r9, r0 - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - beq _0803B642 - b _0803B8B2 -_0803B642: - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x4C - ldrb r0, [r0] - cmp r0, 0 - bne _0803B6C2 - movs r5, 0 - ldr r1, =gNoOfAllBanks - mov r10, r1 - ldrb r3, [r1] - cmp r5, r3 - bge _0803B668 - ldr r2, =gTurnOrder -_0803B65C: - adds r0, r5, r2 - strb r5, [r0] - adds r5, 0x1 - ldrb r0, [r1] - cmp r5, r0 - blt _0803B65C -_0803B668: - movs r5, 0 - b _0803B6B8 - .pool -_0803B67C: - adds r4, r5, 0x1 - mov r8, r4 - ldrb r1, [r1] - cmp r8, r1 - bge _0803B6B6 - ldr r6, =gTurnOrder - ldr r1, =gNoOfAllBanks - mov r10, r1 - lsls r7, r5, 24 -_0803B68E: - adds r0, r5, r6 - ldrb r0, [r0] - adds r1, r4, r6 - ldrb r1, [r1] - movs r2, 0x1 - bl b_first_side - lsls r0, 24 - cmp r0, 0 - beq _0803B6AC - lsls r1, r4, 24 - lsrs r1, 24 - lsrs r0, r7, 24 - bl sub_803CEDC -_0803B6AC: - adds r4, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _0803B68E -_0803B6B6: - mov r5, r8 -_0803B6B8: - mov r1, r10 - ldrb r0, [r1] - subs r0, 0x1 - cmp r5, r0 - blt _0803B67C -_0803B6C2: - ldr r5, =gBattleStruct - ldr r0, [r5] - movs r4, 0xD1 - lsls r4, 1 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0 - bne _0803B6FC - str r0, [sp] - movs r0, 0 - movs r1, 0 - movs r2, 0 - movs r3, 0xFF - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _0803B6FC - ldr r0, [r5] - adds r0, r4 - movs r1, 0x1 - strb r1, [r0] - b _0803B8B2 - .pool -_0803B6FC: - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r0, 0x4C - ldr r1, =gNoOfAllBanks - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - bcs _0803B756 - ldr r5, =gTurnOrder - adds r4, r2, 0 -_0803B710: - ldr r0, [r4] - adds r0, 0x4C - ldrb r0, [r0] - adds r0, r5 - ldrb r1, [r0] - movs r0, 0 - str r0, [sp] - movs r2, 0 - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _0803B736 - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_0803B736: - ldr r1, [r4] - adds r1, 0x4C - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - mov r3, r9 - cmp r3, 0 - beq _0803B748 - b _0803B8B2 -_0803B748: - ldr r0, [r4] - adds r0, 0x4C - ldr r1, =gNoOfAllBanks - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - bcc _0803B710 -_0803B756: - movs r0, 0 - str r0, [sp] - movs r0, 0x9 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _0803B770 - b _0803B8B2 -_0803B770: - str r0, [sp] - movs r0, 0xB - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _0803B786 - b _0803B8B2 -_0803B786: - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r0, 0xD9 - ldr r1, =gNoOfAllBanks - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - bcs _0803B7DA - ldr r5, =gTurnOrder - adds r4, r2, 0 -_0803B79A: - ldr r0, [r4] - adds r0, 0xD9 - ldrb r0, [r0] - adds r0, r5 - ldrb r1, [r0] - movs r0, 0 - movs r2, 0 - bl ItemBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _0803B7BC - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_0803B7BC: - ldr r1, [r4] - adds r1, 0xD9 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - mov r0, r9 - cmp r0, 0 - bne _0803B8B2 - ldr r0, [r4] - adds r0, 0xD9 - ldr r1, =gNoOfAllBanks - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - bcc _0803B79A -_0803B7DA: - movs r5, 0 - ldr r1, =gBattleStruct - mov r8, r1 - movs r7, 0x6 - ldr r6, =gActionForBanks - ldr r2, =gChosenMovesByBanks - movs r4, 0xFF - movs r3, 0 -_0803B7EA: - mov r1, r8 - ldr r0, [r1] - adds r0, r5, r0 - adds r0, 0x5C - strb r7, [r0] - adds r1, r5, r6 - ldrb r0, [r1] - orrs r0, r4 - strb r0, [r1] - strh r3, [r2] - adds r2, 0x2 - adds r5, 0x1 - cmp r5, 0x3 - ble _0803B7EA - movs r0, 0 - bl sub_803D580 - bl sub_803D6A0 - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x91 - ldr r1, =gAbsentBankFlags - ldrb r1, [r1] - strb r1, [r0] - ldr r0, =gText_EmptyString3 - movs r1, 0 - bl sub_814F9EC - ldr r1, =gBattleMainFunc - ldr r0, =sub_803BE74 - str r0, [r1] - bl ResetSentPokesToOpponentValue - ldr r1, =gBattleCommunication - movs r2, 0 - adds r0, r1, 0x7 -_0803B834: - strb r2, [r0] - subs r0, 0x1 - cmp r0, r1 - bge _0803B834 - movs r5, 0 - ldr r3, =gNoOfAllBanks - ldr r2, =gBattleStruct - ldr r6, =gBattleScripting - ldr r7, =gBattleMoveFlags - ldrb r0, [r3] - cmp r5, r0 - bge _0803B866 - ldr r0, =gBattleMons - movs r4, 0x9 - negs r4, r4 - adds r1, r0, 0 - adds r1, 0x50 -_0803B856: - ldr r0, [r1] - ands r0, r4 - str r0, [r1] - adds r1, 0x58 - adds r5, 0x1 - ldrb r0, [r3] - cmp r5, r0 - blt _0803B856 -_0803B866: - ldr r0, [r2] - movs r1, 0 - strb r1, [r0] - ldr r0, [r2] - strb r1, [r0, 0x1] - ldr r0, [r2] - movs r3, 0xD0 - lsls r3, 1 - adds r0, r3 - strb r1, [r0] - ldr r0, [r2] - adds r3, 0x1 - adds r0, r3 - strb r1, [r0] - movs r1, 0 - strb r1, [r6, 0x14] - ldr r0, [r2] - adds r0, 0x4D - strb r1, [r0] - ldr r0, [r2] - strb r1, [r0, 0x3] - strb r1, [r7] - bl Random - ldr r1, =gUnknown_02024330 - strh r0, [r1] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 11 - ands r0, r1 - cmp r0, 0 - beq _0803B8B2 - bl StopCryAndClearCrySongs - ldr r0, =gUnknown_082DB8BE - bl BattleScriptExecute -_0803B8B2: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803B628 - - thumb_func_start bc_8013B1C -bc_8013B1C: @ 803B904 - push {r4-r6,lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0803B994 - ldr r1, =gBattleMainFunc - ldr r0, =BattleTurnPassed - str r0, [r1] - ldr r3, =gNoOfAllBanks - ldr r1, =gBattleCommunication - movs r2, 0 - adds r0, r1, 0x7 -_0803B91C: - strb r2, [r0] - subs r0, 0x1 - cmp r0, r1 - bge _0803B91C - movs r4, 0 - ldrb r3, [r3] - cmp r4, r3 - bge _0803B96E - ldr r5, =gBattleMons - adds r6, r5, 0 - adds r6, 0x4C -_0803B932: - movs r0, 0x58 - adds r2, r4, 0 - muls r2, r0 - adds r1, r5, 0 - adds r1, 0x50 - adds r1, r2, r1 - ldr r3, [r1] - subs r0, 0x61 - ands r3, r0 - str r3, [r1] - adds r2, r6 - ldr r0, [r2] - movs r1, 0x7 - ands r0, r1 - cmp r0, 0 - beq _0803B964 - movs r0, 0x80 - lsls r0, 5 - ands r3, r0 - cmp r3, 0 - beq _0803B964 - lsls r0, r4, 24 - lsrs r0, 24 - bl CancelMultiTurnMoves -_0803B964: - adds r4, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _0803B932 -_0803B96E: - ldr r2, =gBattleStruct - ldr r0, [r2] - movs r1, 0 - strb r1, [r0] - ldr r0, [r2] - strb r1, [r0, 0x1] - ldr r0, [r2] - movs r3, 0xD0 - lsls r3, 1 - adds r0, r3 - strb r1, [r0] - ldr r0, [r2] - adds r3, 0x1 - adds r0, r3 - strb r1, [r0] - ldr r0, [r2] - strb r1, [r0, 0x3] - ldr r0, =gBattleMoveFlags - strb r1, [r0] -_0803B994: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end bc_8013B1C - - thumb_func_start BattleTurnPassed -BattleTurnPassed: @ 803B9BC - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - movs r0, 0x1 - bl sub_803D580 - ldr r0, =gBattleOutcome - ldrb r0, [r0] - cmp r0, 0 - bne _0803B9EA - bl UpdateTurnCounters - lsls r0, 24 - cmp r0, 0 - beq _0803B9DE - b _0803BB78 -_0803B9DE: - bl TurnBasedEffects - lsls r0, 24 - cmp r0, 0 - beq _0803B9EA - b _0803BB78 -_0803B9EA: - bl sub_8041728 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - beq _0803B9F8 - b _0803BB78 -_0803B9F8: - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x4D - strb r1, [r0] - bl sub_8041364 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - beq _0803BA0E - b _0803BB78 -_0803BA0E: - movs r0, 0 - bl sub_803D580 - ldr r2, =gHitMarker - ldr r0, [r2] - ldr r1, =0xfffffdff - ands r0, r1 - ldr r1, =0xfff7ffff - ands r0, r1 - ldr r1, =0xffbfffff - ands r0, r1 - ldr r1, =0xffefffff - ands r0, r1 - str r0, [r2] - ldr r0, =gBattleScripting - strb r4, [r0, 0x18] - strb r4, [r0, 0x19] - strb r4, [r0, 0x14] - ldr r0, =gBattleMoveDamage - str r4, [r0] - ldr r0, =gBattleMoveFlags - strb r4, [r0] - ldr r1, =gBattleCommunication - movs r2, 0 - adds r0, r1, 0x4 -_0803BA40: - strb r2, [r0] - subs r0, 0x1 - cmp r0, r1 - bge _0803BA40 - ldr r0, =gBattleOutcome - ldrb r0, [r0] - cmp r0, 0 - beq _0803BA98 - ldr r1, =gFightStateTracker - movs r0, 0xC - strb r0, [r1] - ldr r1, =gBattleMainFunc - ldr r0, =bc_bs_exec - str r0, [r1] - b _0803BB78 - .pool -_0803BA98: - ldr r1, =gBattleResults - ldrb r0, [r1, 0x13] - ldr r2, =gBattleStruct - mov r8, r2 - cmp r0, 0xFE - bhi _0803BAB2 - adds r0, 0x1 - strb r0, [r1, 0x13] - ldr r1, [r2] - adds r1, 0xDA - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_0803BAB2: - movs r2, 0 - ldr r4, =gNoOfAllBanks - ldr r0, =gAbsentBankFlags - mov r12, r0 - ldr r1, =gText_EmptyString3 - mov r9, r1 - ldrb r0, [r4] - cmp r2, r0 - bge _0803BAE0 - ldr r7, =gActionForBanks - movs r6, 0xFF - movs r5, 0 - ldr r3, =gChosenMovesByBanks -_0803BACC: - adds r1, r2, r7 - ldrb r0, [r1] - orrs r0, r6 - strb r0, [r1] - strh r5, [r3] - adds r3, 0x2 - adds r2, 0x1 - ldrb r1, [r4] - cmp r2, r1 - blt _0803BACC -_0803BAE0: - movs r2, 0 - ldr r3, =gBattleStruct - movs r1, 0x6 -_0803BAE6: - ldr r0, [r3] - adds r0, r2, r0 - adds r0, 0x5C - strb r1, [r0] - adds r2, 0x1 - cmp r2, 0x3 - ble _0803BAE6 - mov r2, r8 - ldr r0, [r2] - adds r0, 0x91 - mov r2, r12 - ldrb r1, [r2] - strb r1, [r0] - mov r0, r9 - movs r1, 0 - bl sub_814F9EC - ldr r1, =gBattleMainFunc - ldr r0, =sub_803BE74 - str r0, [r1] - bl Random - ldr r1, =gUnknown_02024330 - strh r0, [r1] - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x80 - lsls r0, 10 - ands r0, r1 - cmp r0, 0 - beq _0803BB5C - ldr r0, =gUnknown_082DB881 - bl BattleScriptExecute - b _0803BB78 - .pool -_0803BB5C: - movs r0, 0x80 - lsls r0, 11 - ands r1, r0 - cmp r1, 0 - beq _0803BB78 - mov r1, r8 - ldr r0, [r1] - adds r0, 0xDA - ldrb r0, [r0] - cmp r0, 0 - bne _0803BB78 - ldr r0, =gUnknown_082DB8BE - bl BattleScriptExecute -_0803BB78: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end BattleTurnPassed - - thumb_func_start IsRunningFromBattleImpossible -IsRunningFromBattleImpossible: @ 803BB88 - push {r4-r7,lr} - sub sp, 0x4 - ldr r1, =gBattleMons - ldr r0, =gActiveBank - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r1, r0, r1 - ldrh r0, [r1, 0x2E] - cmp r0, 0xAF - bne _0803BBB8 - ldr r1, =gEnigmaBerries - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r2, [r0, 0x7] - b _0803BBC2 - .pool -_0803BBB8: - ldrh r0, [r1, 0x2E] - bl ItemId_GetHoldEffect - lsls r0, 24 - lsrs r2, r0, 24 -_0803BBC2: - ldr r1, =gStringBank - ldr r3, =gActiveBank - ldrb r0, [r3] - strb r0, [r1] - cmp r2, 0x25 - bne _0803BBD0 - b _0803BD4C -_0803BBD0: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0803BBDE - b _0803BD4C -_0803BBDE: - ldr r1, =gBattleMons - ldrb r2, [r3] - movs r0, 0x58 - muls r0, r2 - adds r0, r1 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x32 - bne _0803BBF2 - b _0803BD4C -_0803BBF2: - adds r0, r2, 0 - bl GetBankSide - lsls r0, 24 - lsrs r6, r0, 24 - movs r5, 0 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r5, r0 - bge _0803BC86 - movs r7, 0 -_0803BC08: - lsrs r4, r7, 24 - adds r0, r4, 0 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r6, r0 - beq _0803BC2C - ldr r1, =gBattleMons - movs r0, 0x58 - muls r0, r5 - adds r0, r1 - adds r2, r0, 0 - adds r2, 0x20 - ldrb r0, [r2] - cmp r0, 0x17 - bne _0803BC2C - b _0803BD54 -_0803BC2C: - adds r0, r4, 0 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r6, r0 - beq _0803BC76 - ldr r3, =gBattleMons - ldr r0, =gActiveBank - ldrb r0, [r0] - movs r2, 0x58 - muls r0, r2 - adds r1, r0, r3 - adds r0, r1, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x1A - beq _0803BC76 - adds r0, r1, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0x2 - beq _0803BC76 - adds r0, r1, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0x2 - beq _0803BC76 - adds r0, r5, 0 - muls r0, r2 - adds r0, r3 - adds r2, r0, 0 - adds r2, 0x20 - ldrb r0, [r2] - cmp r0, 0x47 - bne _0803BC76 - b _0803BD70 -_0803BC76: - movs r0, 0x80 - lsls r0, 17 - adds r7, r0 - adds r5, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r5, r0 - blt _0803BC08 -_0803BC86: - ldr r4, =gActiveBank - ldrb r1, [r4] - movs r0, 0 - str r0, [sp] - movs r0, 0xF - movs r2, 0x2A - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - beq _0803BCF8 - ldr r6, =gBattleMons - ldrb r0, [r4] - movs r3, 0x58 - muls r0, r3 - adds r1, r0, r6 - adds r0, r1, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0x8 - beq _0803BCBE - adds r0, r1, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0x8 - bne _0803BCF8 -_0803BCBE: - ldr r0, =gBattleScripting - subs r1, r5, 0x1 - strb r1, [r0, 0x17] - ldr r2, =gLastUsedAbility - adds r0, r1, 0 - muls r0, r3 - adds r0, r6 - adds r0, 0x20 - ldrb r0, [r0] - strb r0, [r2] - ldr r1, =gBattleCommunication - movs r0, 0x2 - b _0803BD90 - .pool -_0803BCF8: - ldr r1, =gBattleMons - ldr r0, =gActiveBank - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - ldr r1, =0x0400e000 - ands r0, r1 - cmp r0, 0 - bne _0803BD22 - ldr r1, =gStatuses3 - lsls r0, r2, 2 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 3 - ands r0, r1 - cmp r0, 0 - beq _0803BD40 -_0803BD22: - ldr r1, =gBattleCommunication - movs r0, 0 - strb r0, [r1, 0x5] - movs r0, 0x1 - b _0803BD92 - .pool -_0803BD40: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x10 - ands r0, r1 - cmp r0, 0 - bne _0803BD8C -_0803BD4C: - movs r0, 0 - b _0803BD92 - .pool -_0803BD54: - ldr r0, =gBattleScripting - strb r5, [r0, 0x17] - ldr r1, =gLastUsedAbility - ldrb r0, [r2] - strb r0, [r1] - ldr r1, =gBattleCommunication - movs r0, 0x2 - b _0803BD90 - .pool -_0803BD70: - ldr r0, =gBattleScripting - strb r5, [r0, 0x17] - ldr r1, =gLastUsedAbility - ldrb r0, [r2] - strb r0, [r1] - ldr r1, =gBattleCommunication - movs r0, 0x2 - b _0803BD90 - .pool -_0803BD8C: - ldr r1, =gBattleCommunication - movs r0, 0x1 -_0803BD90: - strb r0, [r1, 0x5] -_0803BD92: - add sp, 0x4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end IsRunningFromBattleImpossible - - thumb_func_start sub_803BDA0 -sub_803BDA0: @ 803BDA0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r5, r0, 24 - movs r3, 0 - ldr r0, =gBattlePartyID - mov r8, r0 - ldr r1, =gUnknown_0203CF00 - mov r12, r1 - ldr r7, =gBattleStruct - lsls r0, r5, 1 - adds r4, r0, r5 - adds r6, r0, 0 -_0803BDBC: - mov r0, r12 - adds r2, r3, r0 - ldr r1, [r7] - adds r0, r4, r3 - adds r0, r1 - adds r0, 0x60 - ldrb r0, [r0] - strb r0, [r2] - adds r3, 0x1 - cmp r3, 0x2 - ble _0803BDBC - mov r1, r8 - adds r0, r6, r1 - ldrb r0, [r0] - bl pokemon_order_func - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r7, =gBattleStruct - ldr r0, [r7] - adds r0, r5, r0 - adds r0, 0x5C - ldrb r0, [r0] - bl pokemon_order_func - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl sub_81B8FB0 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0803BE4C - movs r3, 0 - adds r4, r7, 0 - adds r6, r5 - movs r0, 0x2 - adds r1, r5, 0 - eors r1, r0 - ldr r7, =gUnknown_0203CF00 - lsls r0, r1, 1 - adds r5, r0, r1 -_0803BE1A: - ldr r0, [r4] - adds r1, r6, r3 - adds r1, r0 - adds r1, 0x60 - adds r2, r3, r7 - ldrb r0, [r2] - strb r0, [r1] - ldr r1, [r4] - adds r0, r5, r3 - adds r0, r1 - adds r0, 0x60 - ldrb r1, [r2] - strb r1, [r0] - adds r3, 0x1 - cmp r3, 0x2 - ble _0803BE1A - b _0803BE66 - .pool -_0803BE4C: - movs r3, 0 - adds r2, r6, r5 - ldr r4, =gUnknown_0203CF00 -_0803BE52: - ldr r0, [r7] - adds r1, r2, r3 - adds r1, r0 - adds r1, 0x60 - adds r0, r3, r4 - ldrb r0, [r0] - strb r0, [r1] - adds r3, 0x1 - cmp r3, 0x2 - ble _0803BE52 -_0803BE66: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803BDA0 - - thumb_func_start sub_803BE74 -sub_803BE74: @ 803BE74 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x1C - ldr r0, =gBattleCommunication - movs r1, 0 - strb r1, [r0, 0x4] - ldr r0, =gActiveBank - strb r1, [r0] - ldr r0, =gNoOfAllBanks - bl _0803CD12 - .pool -_0803BE9C: - ldr r4, =gActiveBank - ldrb r0, [r4] - bl GetBankIdentity - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gBattleCommunication - ldrb r0, [r4] - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x8 - bls _0803BEB8 - bl _0803CD04 -_0803BEB8: - lsls r0, 2 - ldr r1, =_0803BED0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0803BED0: - .4byte _0803BEF4 - .4byte _0803BF0C - .4byte _0803C02C - .4byte _0803C7D8 - .4byte _0803CAD0 - .4byte _0803CB84 - .4byte _0803CBC8 - .4byte _0803CBF4 - .4byte _0803CC38 -_0803BEF4: - bl sub_8185FD0 - ldr r1, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r0, [r0] - adds r0, r1 - bl _0803CC20 - .pool -_0803BF0C: - ldr r0, =gActiveBank - ldrb r1, [r0] - ldr r4, =gBattleStruct - ldr r0, [r4] - adds r1, r0 - adds r1, 0x5C - movs r0, 0x6 - strb r0, [r1] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - bne _0803BF68 - movs r1, 0x2 - movs r0, 0x2 - ands r0, r5 - cmp r0, 0 - beq _0803BF68 - eors r5, r1 - adds r0, r5, 0 - bl GetBankByIdentity - ldr r1, [r4] - adds r1, 0x91 - ldrb r1, [r1] - ldr r2, =gBitTable - lsls r0, 24 - lsrs r0, 22 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _0803BF68 - ldr r4, =gBattleCommunication - adds r0, r5, 0 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0x5 - beq _0803BF68 - bl _0803CD04 -_0803BF68: - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x91 - ldrb r3, [r0] - ldr r1, =gBitTable - ldr r4, =gActiveBank - ldrb r2, [r4] - lsls r0, r2, 2 - adds r0, r1 - ldr r0, [r0] - ands r3, r0 - cmp r3, 0 - beq _0803BFD0 - ldr r0, =gActionForBanks - adds r0, r2, r0 - movs r1, 0xD - strb r1, [r0] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - bne _0803BFBC - ldr r0, =gBattleCommunication - ldrb r1, [r4] - adds r1, r0 - movs r0, 0x5 - strb r0, [r1] - bl _0803CD04 - .pool -_0803BFBC: - ldr r0, =gBattleCommunication - ldrb r1, [r4] - adds r1, r0 - movs r0, 0x4 - strb r0, [r1] - bl _0803CD04 - .pool -_0803BFD0: - ldr r1, =gBattleMons - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r1, [r0] - movs r0, 0x80 - lsls r0, 5 - ands r0, r1 - cmp r0, 0 - bne _0803BFF0 - movs r0, 0x80 - lsls r0, 15 - ands r1, r0 - cmp r1, 0 - beq _0803C00C -_0803BFF0: - ldr r0, =gActionForBanks - adds r0, r2, r0 - strb r3, [r0] - ldr r1, =gBattleCommunication - ldrb r0, [r4] - bl _0803CC72 - .pool -_0803C00C: - ldr r0, =gActionForBanks - ldrb r1, [r0] - ldr r0, =gBattleBufferB - ldrb r2, [r0, 0x1] - ldrb r0, [r0, 0x2] - lsls r0, 8 - orrs r2, r0 - movs r0, 0 - bl dp01_build_cmdbuf_x12_a_bb - bl _0803CB68 - .pool -_0803C02C: - ldr r3, =gBattleExecBuffer - ldr r1, =gBitTable - ldr r6, =gActiveBank - ldrb r5, [r6] - lsls r0, r5, 2 - adds r0, r1 - ldr r2, [r0] - lsls r1, r2, 4 - movs r0, 0xF0 - lsls r0, 24 - orrs r1, r0 - orrs r1, r2 - lsls r0, r2, 8 - orrs r1, r0 - lsls r2, 12 - orrs r1, r2 - ldr r0, [r3] - ands r0, r1 - cmp r0, 0 - beq _0803C058 - bl _0803CD04 -_0803C058: - ldr r4, =gBattleBufferB - lsls r0, r5, 9 - adds r4, 0x1 - adds r0, r4 - ldrb r1, [r0] - adds r0, r5, 0 - bl RecordedBattle_SetBankAction - ldr r1, =gActionForBanks - ldrb r0, [r6] - adds r1, r0, r1 - lsls r0, 9 - adds r0, r4 - ldrb r0, [r0] - strb r0, [r1] - ldrb r0, [r6] - lsls r0, 9 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0xC - bls _0803C084 - b _0803C6C4 -_0803C084: - lsls r0, 2 - ldr r1, =_0803C0A8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0803C0A8: - .4byte _0803C0DC - .4byte _0803C230 - .4byte _0803C268 - .4byte _0803C6C4 - .4byte _0803C6C4 - .4byte _0803C440 - .4byte _0803C48C - .4byte _0803C6C4 - .4byte _0803C6C4 - .4byte _0803C6C4 - .4byte _0803C6C4 - .4byte _0803C6C4 - .4byte _0803C4B4 -_0803C0DC: - bl AreAllMovesUnusable - lsls r0, 24 - cmp r0, 0 - beq _0803C134 - ldr r0, =gBattleCommunication - ldr r3, =gActiveBank - ldrb r1, [r3] - adds r1, r0 - movs r4, 0 - movs r0, 0x6 - strb r0, [r1] - ldrb r1, [r3] - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r1, r0 - adds r1, 0x54 - strb r4, [r1] - ldrb r1, [r3] - ldr r0, [r2] - adds r1, r0 - adds r1, 0x84 - movs r0, 0x4 - strb r0, [r1] - ldrb r1, [r3] - ldr r2, [r2] - adds r2, r1, r2 - ldr r0, =gBattleBufferB - lsls r1, 9 - adds r0, 0x3 - adds r1, r0 - ldrb r0, [r1] - strb r0, [r2, 0xC] - bl _0803CD70 - .pool -_0803C134: - ldr r3, =gDisableStructs - ldr r5, =gActiveBank - ldrb r4, [r5] - lsls r0, r4, 3 - subs r0, r4 - lsls r0, 2 - adds r0, r3 - ldrh r2, [r0, 0x6] - cmp r2, 0 - beq _0803C188 - ldr r1, =gChosenMovesByBanks - lsls r0, r4, 1 - adds r0, r1 - strh r2, [r0] - ldrb r2, [r5] - ldr r0, =gBattleStruct - ldr r1, [r0] - adds r1, r2, r1 - adds r1, 0x80 - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r3 - ldrb r0, [r0, 0xC] - strb r0, [r1] - ldr r1, =gBattleCommunication - ldrb r0, [r5] - adds r0, r1 - movs r1, 0x4 - strb r1, [r0] - bl _0803CD70 - .pool -_0803C188: - add r2, sp, 0x4 - ldr r3, =gBattleMons - movs r1, 0x58 - adds r0, r4, 0 - muls r0, r1 - adds r0, r3 - ldrh r0, [r0] - strh r0, [r2, 0x10] - ldrb r0, [r5] - muls r0, r1 - adds r0, r3 - adds r0, 0x21 - ldrb r0, [r0] - strb r0, [r2, 0x12] - ldrb r0, [r5] - muls r0, r1 - adds r0, r3 - adds r0, 0x22 - ldrb r0, [r0] - strb r0, [r2, 0x13] - movs r4, 0 - mov r1, sp - adds r1, 0xC - str r1, [sp, 0x18] - add r2, sp, 0x10 - mov r10, r2 - mov r8, r3 - adds r7, r5, 0 - movs r6, 0x58 - movs r0, 0xC - add r0, r8 - mov r9, r0 - add r5, sp, 0x4 -_0803C1CA: - lsls r2, r4, 1 - ldrb r0, [r7] - muls r0, r6 - adds r0, r2, r0 - add r0, r9 - ldrh r0, [r0] - strh r0, [r5] - ldr r1, [sp, 0x18] - adds r3, r1, r4 - ldrb r0, [r7] - muls r0, r6 - adds r0, r4, r0 - mov r1, r8 - adds r1, 0x24 - adds r0, r1 - ldrb r0, [r0] - strb r0, [r3] - ldrb r0, [r7] - adds r1, r0, 0 - muls r1, r6 - adds r2, r1 - add r2, r9 - ldrh r0, [r2] - add r1, r8 - adds r1, 0x3B - ldrb r1, [r1] - lsls r2, r4, 24 - lsrs r2, 24 - bl CalculatePPWithBonus - mov r2, r10 - adds r1, r2, r4 - strb r0, [r1] - adds r5, 0x2 - adds r4, 0x1 - cmp r4, 0x3 - ble _0803C1CA - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x1 - ands r1, r0 - movs r0, 0 - movs r2, 0 - add r3, sp, 0x4 - bl sub_8033E30 - b _0803C42E - .pool -_0803C230: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ldr r1, =0x021f0902 - ands r0, r1 - cmp r0, 0 - bne _0803C23E - b _0803C48C -_0803C23E: - ldr r4, =gActiveBank - ldrb r0, [r4] - movs r1, 0x1 - bl sub_8185008 - ldr r1, =gUnknown_02024220 - ldrb r0, [r4] - lsls r0, 2 - adds r0, r1 - ldr r1, =gUnknown_082DB879 - b _0803C784 - .pool -_0803C268: - ldr r5, =gActiveBank - ldrb r0, [r5] - ldr r3, =gBattleStruct - ldr r1, [r3] - adds r1, r0, r1 - adds r1, 0x58 - ldr r2, =gBattlePartyID - lsls r0, 1 - adds r0, r2 - ldrh r0, [r0] - strb r0, [r1] - ldr r7, =gBattleMons - ldrb r2, [r5] - movs r6, 0x58 - adds r0, r2, 0 - muls r0, r6 - adds r1, r7, 0 - adds r1, 0x50 - adds r0, r1 - ldr r1, [r0] - ldr r0, =0x0400e000 - ands r1, r0 - cmp r1, 0 - bne _0803C2B8 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 11 - ands r0, r1 - cmp r0, 0 - bne _0803C2B8 - ldr r0, =gStatuses3 - lsls r1, r2, 2 - adds r1, r0 - ldr r1, [r1] - movs r0, 0x80 - lsls r0, 3 - ands r1, r0 - cmp r1, 0 - beq _0803C2EC -_0803C2B8: - ldr r0, =gActiveBank - ldrb r0, [r0] - lsls r1, r0, 1 - adds r1, r0 - adds r1, 0x60 - ldr r0, [r3] - adds r0, r1 - str r0, [sp] - movs r0, 0 - movs r1, 0x2 - movs r2, 0x6 - b _0803C400 - .pool -_0803C2EC: - str r1, [sp] - movs r0, 0xC - adds r1, r2, 0 - movs r2, 0x17 - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - bne _0803C374 - ldrb r1, [r5] - str r4, [sp] - movs r0, 0xC - movs r2, 0x47 - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - beq _0803C33C - ldrb r0, [r5] - muls r0, r6 - adds r1, r0, r7 - adds r0, r1, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0x2 - beq _0803C33C - adds r0, r1, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0x2 - beq _0803C33C - adds r0, r1, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x1A - bne _0803C374 -_0803C33C: - ldr r5, =gActiveBank - ldrb r1, [r5] - movs r0, 0 - str r0, [sp] - movs r0, 0xF - movs r2, 0x2A - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - beq _0803C3B0 - ldr r2, =gBattleMons - ldrb r1, [r5] - movs r0, 0x58 - muls r0, r1 - adds r1, r0, r2 - adds r0, r1, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0x8 - beq _0803C374 - adds r0, r1, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0x8 - bne _0803C3B0 -_0803C374: - subs r1, r4, 0x1 - lsls r1, 4 - movs r0, 0x4 - orrs r1, r0 - lsls r1, 24 - lsrs r1, 24 - ldr r0, =gLastUsedAbility - ldrb r3, [r0] - ldr r4, =gBattleStruct - ldr r0, =gActiveBank - ldrb r0, [r0] - lsls r2, r0, 1 - adds r2, r0 - adds r2, 0x60 - ldr r0, [r4] - adds r0, r2 - str r0, [sp] - movs r0, 0 - movs r2, 0x6 - bl EmitChoosePokemon - b _0803C42E - .pool -_0803C3B0: - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r4, r0, 0 - cmp r1, 0x2 - bne _0803C3D8 - ldr r0, =gActionForBanks - ldrb r0, [r0] - cmp r0, 0x2 - bne _0803C3D8 - ldr r0, =gBattleStruct - ldr r3, [r0] - adds r0, r3, 0 - adds r0, 0x5C - b _0803C3EE - .pool -_0803C3D8: - ldrb r0, [r4] - cmp r0, 0x3 - bne _0803C410 - ldr r0, =gActionForBanks - ldrb r0, [r0, 0x1] - cmp r0, 0x2 - bne _0803C410 - ldr r0, =gBattleStruct - ldr r3, [r0] - adds r0, r3, 0 - adds r0, 0x5D -_0803C3EE: - ldrb r2, [r0] - ldrb r1, [r4] - lsls r0, r1, 1 - adds r0, r1 - adds r0, 0x60 - adds r3, r0 - str r3, [sp] - movs r0, 0 - movs r1, 0 -_0803C400: - movs r3, 0 - bl EmitChoosePokemon - b _0803C42E - .pool -_0803C410: - ldr r2, =gBattleStruct - ldr r0, =gActiveBank - ldrb r0, [r0] - lsls r1, r0, 1 - adds r1, r0 - adds r1, 0x60 - ldr r0, [r2] - adds r0, r1 - str r0, [sp] - movs r0, 0 - movs r1, 0 - movs r2, 0x6 - movs r3, 0 - bl EmitChoosePokemon -_0803C42E: - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution - b _0803C6C4 - .pool -_0803C440: - bl IsPlayerPartyAndPokemonStorageFull - lsls r0, 24 - cmp r0, 0 - bne _0803C44C - b _0803C6C4 -_0803C44C: - ldr r1, =gUnknown_02024220 - ldr r3, =gActiveBank - ldrb r0, [r3] - lsls r0, 2 - adds r0, r1 - ldr r1, =gUnknown_082DAB11 - str r1, [r0] - ldr r0, =gBattleCommunication - ldrb r1, [r3] - adds r1, r0 - movs r4, 0 - movs r0, 0x6 - strb r0, [r1] - ldrb r1, [r3] - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r1, r0 - adds r1, 0x54 - strb r4, [r1] - ldrb r1, [r3] - b _0803C7A0 - .pool -_0803C48C: - ldr r2, =gBattleStruct - ldr r4, =gActiveBank - ldrb r1, [r4] - lsls r0, r1, 1 - adds r0, r1 - adds r0, 0x60 - ldr r1, [r2] - adds r1, r0 - movs r0, 0 - bl sub_8033E6C - ldrb r0, [r4] - bl MarkBufferBankForExecution - b _0803C6C4 - .pool -_0803C4B4: - ldr r4, =gBattleCommunication - ldr r5, =gActiveBank - ldrb r0, [r5] - adds r0, r4 - movs r1, 0x7 - strb r1, [r0] - ldrb r0, [r5] - bl GetBankIdentity - movs r6, 0x2 - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - movs r1, 0x1 - strb r1, [r0] - ldrb r0, [r5] - bl sub_8185008 - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - ldr r1, =gBattleMons - lsls r0, 24 - lsrs r0, 24 - movs r7, 0x58 - muls r0, r7 - adds r4, r1, 0 - adds r4, 0x50 - adds r0, r4 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 5 - ands r0, r1 - cmp r0, 0 - bne _0803C532 - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - muls r0, r7 - adds r0, r4 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 15 - ands r0, r1 - cmp r0, 0 - beq _0803C550 -_0803C532: - movs r0, 0 - bl dp01_build_cmdbuf_x32_32_32_32 - ldrb r0, [r5] - bl MarkBufferBankForExecution - bl _0803CD70 - .pool -_0803C550: - ldr r4, =gActionForBanks - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0x2 - bne _0803C590 - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x2 - bl sub_8185008 - b _0803C6AE - .pool -_0803C590: - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0x3 - bne _0803C5B6 - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - b _0803C668 -_0803C5B6: - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0 - bne _0803C628 - ldr r4, =gProtectStructs - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 20 - adds r0, r4 - ldrb r0, [r0] - lsls r0, 29 - cmp r0, 0 - blt _0803C616 - ldr r4, =gDisableStructs - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r4 - ldrh r0, [r1, 0x6] - cmp r0, 0 - beq _0803C628 -_0803C616: - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - b _0803C668 - .pool -_0803C628: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 10 - ands r0, r1 - cmp r0, 0 - beq _0803C690 - ldr r4, =gActionForBanks - ldr r6, =gActiveBank - ldrb r0, [r6] - bl GetBankIdentity - movs r5, 0x2 - eors r0, r5 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0 - bne _0803C690 - ldr r1, =gRngValue - ldr r0, =gUnknown_0203BD30 - ldr r0, [r0] - str r0, [r1] - ldrb r0, [r6] - bl GetBankIdentity - eors r0, r5 -_0803C668: - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - bl sub_8185008 - b _0803C6AE - .pool -_0803C690: - ldr r0, =gActiveBank - ldrb r0, [r0] - bl GetBankIdentity - movs r1, 0x2 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x3 - bl sub_8185008 -_0803C6AE: - movs r0, 0 - bl dp01_build_cmdbuf_x32_32_32_32 - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution - b _0803CD70 - .pool -_0803C6C4: - ldr r1, =gBattleTypeFlags - ldr r2, [r1] - movs r5, 0x8 - adds r0, r2, 0 - ands r0, r5 - adds r3, r1, 0 - cmp r0, 0 - beq _0803C720 - ldr r0, =0x043f0100 - ands r2, r0 - cmp r2, 0 - beq _0803C720 - ldr r0, =gBattleBufferB - ldr r4, =gActiveBank - ldrb r2, [r4] - lsls r1, r2, 9 - adds r0, 0x1 - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0x3 - bne _0803C720 - ldr r1, =gUnknown_02024220 - lsls r0, r2, 2 - adds r0, r1 - ldr r1, =gUnknown_082DB9BA - str r1, [r0] - ldr r1, =gBattleCommunication - ldrb r0, [r4] - adds r0, r1 - movs r3, 0 - strb r5, [r0] - b _0803C792 - .pool -_0803C720: - ldr r0, [r3] - ldr r1, =0x0200000a - ands r0, r1 - cmp r0, 0x8 - bne _0803C760 - ldr r0, =gBattleBufferB - ldr r4, =gActiveBank - ldrb r1, [r4] - lsls r1, 9 - adds r0, 0x1 - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0x3 - bne _0803C760 - ldr r0, =gUnknown_082DAAFE - bl BattleScriptExecute - ldr r1, =gBattleCommunication - ldrb r0, [r4] - adds r0, r1 - b _0803CC20 - .pool -_0803C760: - bl IsRunningFromBattleImpossible - lsls r0, 24 - cmp r0, 0 - beq _0803C7C4 - ldr r0, =gBattleBufferB - ldr r4, =gActiveBank - ldrb r2, [r4] - lsls r1, r2, 9 - adds r0, 0x1 - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0x3 - bne _0803C7C4 - ldr r1, =gUnknown_02024220 - lsls r0, r2, 2 - adds r0, r1 - ldr r1, =gUnknown_082DAB0B -_0803C784: - str r1, [r0] - ldr r0, =gBattleCommunication - ldrb r1, [r4] - adds r1, r0 - movs r3, 0 - movs r0, 0x6 - strb r0, [r1] -_0803C792: - ldrb r1, [r4] - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r1, r0 - adds r1, 0x54 - strb r3, [r1] - ldrb r1, [r4] -_0803C7A0: - ldr r0, [r2] - adds r1, r0 - adds r1, 0x84 - movs r0, 0x1 - strb r0, [r1] - b _0803CD70 - .pool -_0803C7C4: - ldr r2, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, r2 - b _0803CB74 - .pool -_0803C7D8: - ldr r4, =gBattleExecBuffer - ldr r1, =gBitTable - ldr r3, =gActiveBank - ldrb r5, [r3] - lsls r0, r5, 2 - adds r0, r1 - ldr r2, [r0] - lsls r0, r2, 4 - movs r1, 0xF0 - lsls r1, 24 - orrs r0, r1 - orrs r0, r2 - lsls r1, r2, 8 - orrs r0, r1 - lsls r2, 12 - orrs r0, r2 - ldr r1, [r4] - ands r1, r0 - adds r4, r3, 0 - cmp r1, 0 - beq _0803C804 - b _0803CD04 -_0803C804: - ldr r1, =gActionForBanks - adds r0, r5, r1 - ldrb r0, [r0] - adds r2, r1, 0 - cmp r0, 0x9 - bls _0803C812 - b _0803CD04 -_0803C812: - lsls r0, 2 - ldr r1, =_0803C830 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0803C830: - .4byte _0803C858 - .4byte _0803C99C - .4byte _0803C9D4 - .4byte _0803CA0A - .4byte _0803CA2C - .4byte _0803CA40 - .4byte _0803CA54 - .4byte _0803CA84 - .4byte _0803CA98 - .4byte _0803CABC -_0803C858: - ldr r1, =gBattleBufferB - ldrb r3, [r4] - lsls r0, r3, 9 - adds r1, 0x1 - adds r0, r1 - ldrb r1, [r0] - cmp r1, 0x3 - blt _0803C88A - cmp r1, 0x9 - ble _0803C878 - cmp r1, 0xF - beq _0803C87E - b _0803C88A - .pool -_0803C878: - adds r0, r3, r2 - strb r1, [r0] - b _0803CD70 -_0803C87E: - adds r1, r3, r2 - movs r0, 0x2 - strb r0, [r1] - bl sub_803CDF8 - b _0803CD70 -_0803C88A: - movs r0, 0x2 - bl sub_818603C - ldr r4, =gBattleBufferB - ldr r6, =gActiveBank - ldrb r3, [r6] - lsls r1, r3, 9 - adds r5, r4, 0x2 - adds r0, r1, r5 - ldrb r2, [r0] - adds r7, r4, 0x3 - adds r1, r7 - ldrb r0, [r1] - lsls r0, 8 - orrs r2, r0 - ldr r0, =0x0000ffff - cmp r2, r0 - bne _0803C8D0 - ldr r0, =gBattleCommunication - adds r0, r3, r0 - movs r1, 0x1 - strb r1, [r0] - ldrb r0, [r6] - bl sub_8185008 - b _0803CD04 - .pool -_0803C8D0: - bl sub_803FB4C - lsls r0, 24 - cmp r0, 0 - beq _0803C91C - ldrb r0, [r6] - movs r1, 0x1 - bl sub_8185008 - ldr r0, =gBattleCommunication - ldrb r1, [r6] - adds r1, r0 - movs r3, 0 - movs r0, 0x6 - strb r0, [r1] - ldrb r1, [r6] - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r1, r0 - adds r1, 0x54 - strb r3, [r1] - ldrb r0, [r6] - lsls r0, 9 - adds r1, r4, 0x1 - adds r0, r1 - strb r3, [r0] - ldrb r1, [r6] - ldr r0, [r2] - adds r1, r0 - adds r1, 0x84 - movs r0, 0x2 - strb r0, [r1] - b _0803CD70 - .pool -_0803C91C: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 10 - ands r0, r1 - cmp r0, 0 - bne _0803C942 - ldrb r0, [r6] - lsls r1, r0, 9 - adds r1, r5 - ldrb r1, [r1] - bl RecordedBattle_SetBankAction - ldrb r0, [r6] - lsls r1, r0, 9 - adds r1, r7 - ldrb r1, [r1] - bl RecordedBattle_SetBankAction -_0803C942: - ldrb r0, [r6] - ldr r4, =gBattleStruct - ldr r1, [r4] - adds r1, r0, r1 - adds r1, 0x80 - lsls r0, 9 - adds r0, r5 - ldrb r0, [r0] - strb r0, [r1] - ldr r0, =gChosenMovesByBanks - ldrb r2, [r6] - lsls r5, r2, 1 - adds r5, r0 - ldr r3, =gBattleMons - ldr r4, [r4] - adds r0, r2, r4 - adds r0, 0x80 - ldrb r0, [r0] - lsls r0, 1 - movs r1, 0x58 - muls r1, r2 - adds r0, r1 - adds r3, 0xC - adds r0, r3 - ldrh r0, [r0] - strh r0, [r5] - ldrb r0, [r6] - adds r4, r0, r4 - lsls r0, 9 - adds r0, r7 - ldrb r0, [r0] - strb r0, [r4, 0xC] - ldr r0, =gBattleCommunication - ldrb r1, [r6] - b _0803CB72 - .pool -_0803C99C: - ldr r2, =gBattleBufferB - ldr r5, =gActiveBank - ldrb r4, [r5] - lsls r1, r4, 9 - adds r0, r2, 0x1 - adds r0, r1, r0 - ldrb r3, [r0] - adds r2, 0x2 - adds r1, r2 - ldrb r0, [r1] - lsls r0, 8 - orrs r3, r0 - cmp r3, 0 - bne _0803C9BA - b _0803CC1C -_0803C9BA: - ldr r0, =gLastUsedItem - strh r3, [r0] - ldr r0, =gBattleCommunication - ldrb r1, [r5] - b _0803CB72 - .pool -_0803C9D4: - ldr r0, =gBattleBufferB - ldr r4, =gActiveBank - ldrb r2, [r4] - lsls r1, r2, 9 - adds r0, 0x1 - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0x6 - bne _0803CA04 - ldr r0, =gBattleCommunication - adds r0, r2, r0 - movs r1, 0x1 - strb r1, [r0] - ldrb r0, [r4] - bl sub_8185008 - b _0803CD04 - .pool -_0803CA04: - bl sub_803CDF8 - b _0803CB6E -_0803CA0A: - ldr r2, =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 8 - orrs r0, r1 - str r0, [r2] - ldr r2, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, r2 - b _0803CB74 - .pool -_0803CA2C: - ldr r2, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, r2 - b _0803CB74 - .pool -_0803CA40: - ldr r2, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, r2 - b _0803CB74 - .pool -_0803CA54: - ldr r3, =gBattleBufferB - ldr r0, =gActiveBank - ldrb r4, [r0] - lsls r1, r4, 9 - adds r0, r3, 0x1 - adds r0, r1, r0 - ldrb r2, [r0] - adds r3, 0x2 - adds r1, r3 - ldrb r0, [r1] - lsls r0, 8 - orrs r2, r0 - cmp r2, 0 - bne _0803CA72 - b _0803CC1C -_0803CA72: - ldr r1, =gBattleCommunication - adds r1, r4, r1 - b _0803CB74 - .pool -_0803CA84: - ldr r2, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, r2 - b _0803CB74 - .pool -_0803CA98: - ldr r2, =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 8 - orrs r0, r1 - str r0, [r2] - ldr r2, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, r2 - b _0803CB74 - .pool -_0803CABC: - ldr r2, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, r2 - b _0803CB74 - .pool -_0803CAD0: - ldr r3, =gBattleExecBuffer - ldr r6, =gBitTable - ldr r0, =gActiveBank - ldrb r0, [r0] - lsls r0, 2 - adds r0, r6 - ldr r2, [r0] - lsls r1, r2, 4 - movs r0, 0xF0 - lsls r0, 24 - orrs r1, r0 - orrs r1, r2 - lsls r0, r2, 8 - orrs r1, r0 - lsls r2, 12 - orrs r1, r2 - ldr r0, [r3] - ands r0, r1 - cmp r0, 0 - beq _0803CAFA - b _0803CD04 -_0803CAFA: - bl sub_803CDB8 - lsls r0, 24 - lsrs r0, 24 - negs r1, r0 - orrs r1, r0 - lsrs r4, r1, 31 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x41 - ands r0, r1 - cmp r0, 0x1 - bne _0803CB3C - movs r1, 0x2 - movs r0, 0x2 - ands r0, r5 - cmp r0, 0 - bne _0803CB3C - adds r0, r5, 0 - eors r0, r1 - bl GetBankByIdentity - ldr r1, =gBattleStruct - ldr r1, [r1] - adds r1, 0x91 - ldrb r1, [r1] - lsls r0, 24 - lsrs r0, 22 - adds r0, r6 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _0803CB5C -_0803CB3C: - movs r0, 0 - movs r1, 0 - adds r2, r4, 0 - bl EmitLinkStandbyMsg - b _0803CB66 - .pool -_0803CB5C: - movs r0, 0 - movs r1, 0x1 - adds r2, r4, 0 - bl EmitLinkStandbyMsg -_0803CB66: - ldr r4, =gActiveBank -_0803CB68: - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0803CB6E: - ldr r0, =gBattleCommunication - ldrb r1, [r4] -_0803CB72: - adds r1, r0 -_0803CB74: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _0803CD04 - .pool -_0803CB84: - ldr r3, =gBattleExecBuffer - ldr r1, =gBitTable - ldr r0, =gActiveBank - ldrb r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r2, [r0] - lsls r1, r2, 4 - movs r0, 0xF0 - lsls r0, 24 - orrs r1, r0 - orrs r1, r2 - lsls r0, r2, 8 - orrs r1, r0 - lsls r2, 12 - orrs r1, r2 - ldr r0, [r3] - ands r0, r1 - cmp r0, 0 - beq _0803CBAE - b _0803CD04 -_0803CBAE: - ldr r1, =gBattleCommunication - ldrb r0, [r1, 0x4] - adds r0, 0x1 - strb r0, [r1, 0x4] - b _0803CD04 - .pool -_0803CBC8: - ldr r5, =gActiveBank - ldrb r2, [r5] - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r1, r2, r0 - adds r0, r1, 0 - adds r0, 0x54 - ldrb r0, [r0] - cmp r0, 0 - beq _0803CCB4 - ldr r0, =gBattleCommunication - adds r0, r2, r0 - adds r1, 0x84 - ldrb r1, [r1] - strb r1, [r0] - b _0803CD04 - .pool -_0803CBF4: - ldr r3, =gBattleExecBuffer - ldr r1, =gBitTable - ldr r0, =gActiveBank - ldrb r4, [r0] - lsls r0, r4, 2 - adds r0, r1 - ldr r2, [r0] - lsls r1, r2, 4 - movs r0, 0xF0 - lsls r0, 24 - orrs r1, r0 - orrs r1, r2 - lsls r0, r2, 8 - orrs r1, r0 - lsls r2, 12 - orrs r1, r2 - ldr r0, [r3] - ands r0, r1 - cmp r0, 0 - bne _0803CD04 -_0803CC1C: - ldr r0, =gBattleCommunication - adds r0, r4, r0 -_0803CC20: - movs r1, 0x1 - strb r1, [r0] - b _0803CD04 - .pool -_0803CC38: - ldr r5, =gActiveBank - ldrb r2, [r5] - ldr r4, =gBattleStruct - ldr r0, [r4] - adds r0, r2, r0 - adds r0, 0x54 - ldrb r0, [r0] - cmp r0, 0 - beq _0803CCB4 - ldr r0, =gBattleBufferB - lsls r1, r2, 9 - adds r0, 0x1 - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0xD - bne _0803CC94 - ldr r2, =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 8 - orrs r0, r1 - str r0, [r2] - ldr r1, =gActionForBanks - ldrb r0, [r5] - adds r0, r1 - movs r1, 0x3 - strb r1, [r0] - ldr r1, =gBattleCommunication - ldrb r0, [r5] -_0803CC72: - adds r0, r1 - movs r1, 0x4 - strb r1, [r0] - b _0803CD04 - .pool -_0803CC94: - adds r0, r2, 0 - movs r1, 0x1 - bl sub_8185008 - ldr r2, =gBattleCommunication - ldrb r0, [r5] - adds r2, r0, r2 - ldr r1, [r4] - adds r0, r1 - adds r0, 0x84 - ldrb r0, [r0] - strb r0, [r2] - b _0803CD04 - .pool -_0803CCB4: - ldr r0, =gBankAttacker - strb r2, [r0] - ldr r7, =gBattlescriptCurrInstr - ldr r6, =gUnknown_02024220 - ldrb r0, [r5] - lsls r0, 2 - adds r0, r6 - ldr r4, [r0] - str r4, [r7] - ldr r3, =gBattleExecBuffer - ldr r1, =gBitTable - ldrb r0, [r5] - lsls r0, 2 - adds r0, r1 - ldr r2, [r0] - lsls r1, r2, 4 - movs r0, 0xF0 - lsls r0, 24 - orrs r1, r0 - orrs r1, r2 - lsls r0, r2, 8 - orrs r1, r0 - lsls r2, 12 - orrs r1, r2 - ldr r0, [r3] - ands r0, r1 - cmp r0, 0 - bne _0803CCFA - ldr r0, =gBattleScriptingCommandsTable - ldrb r1, [r4] - lsls r1, 2 - adds r1, r0 - ldr r0, [r1] - bl _call_via_r0 -_0803CCFA: - ldrb r0, [r5] - lsls r0, 2 - adds r0, r6 - ldr r1, [r7] - str r1, [r0] -_0803CD04: - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, 0x1 - strb r1, [r0] - ldr r0, =gNoOfAllBanks - lsls r1, 24 - lsrs r1, 24 -_0803CD12: - adds r5, r0, 0 - ldrb r0, [r5] - cmp r1, r0 - bcs _0803CD1E - bl _0803BE9C -_0803CD1E: - ldr r0, =gBattleCommunication - ldrb r0, [r0, 0x4] - ldrb r1, [r5] - cmp r0, r1 - bne _0803CD70 - movs r0, 0x1 - bl sub_818603C - ldr r1, =gBattleMainFunc - ldr r0, =sub_803D2E8 - str r0, [r1] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 15 - ands r0, r1 - cmp r0, 0 - beq _0803CD70 - movs r4, 0 - ldrb r5, [r5] - cmp r4, r5 - bge _0803CD70 -_0803CD4A: - ldr r0, =gActionForBanks - adds r0, r4, r0 - ldrb r0, [r0] - cmp r0, 0x2 - bne _0803CD66 - lsls r0, r4, 24 - lsrs r0, 24 - ldr r1, =gBattleStruct - ldr r1, [r1] - adds r1, r4, r1 - adds r1, 0x5C - ldrb r1, [r1] - bl sub_80571DC -_0803CD66: - adds r4, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _0803CD4A -_0803CD70: - add sp, 0x1C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803BE74 - - thumb_func_start sub_803CDB8 -sub_803CDB8: @ 803CDB8 - push {r4,r5,lr} - movs r3, 0 - movs r1, 0 - ldr r0, =gNoOfAllBanks - ldrb r2, [r0] - adds r5, r0, 0 - cmp r3, r2 - bge _0803CDDA - ldr r4, =gBattleCommunication -_0803CDCA: - adds r0, r1, r4 - ldrb r0, [r0] - cmp r0, 0x5 - bne _0803CDD4 - adds r3, 0x1 -_0803CDD4: - adds r1, 0x1 - cmp r1, r2 - blt _0803CDCA -_0803CDDA: - adds r0, r3, 0x1 - ldrb r5, [r5] - cmp r0, r5 - beq _0803CDF0 - movs r0, 0 - b _0803CDF2 - .pool -_0803CDF0: - movs r0, 0x1 -_0803CDF2: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_803CDB8 - - thumb_func_start sub_803CDF8 -sub_803CDF8: @ 803CDF8 - push {r4-r7,lr} - ldr r7, =gActiveBank - ldrb r0, [r7] - ldr r6, =gBattleStruct - ldr r1, [r6] - adds r1, r0, r1 - adds r1, 0x5C - ldr r4, =gBattleBufferB - lsls r0, 9 - adds r2, r4, 0x1 - adds r0, r2 - ldrb r0, [r0] - strb r0, [r1] - ldrb r0, [r7] - lsls r1, r0, 9 - adds r1, r2 - ldrb r1, [r1] - bl RecordedBattle_SetBankAction - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x42 - ands r0, r1 - cmp r0, 0x42 - bne _0803CEC6 - ldrb r0, [r7] - ldr r2, [r6] - lsls r1, r0, 1 - adds r1, r0 - adds r1, r2 - adds r1, 0x60 - ldrb r2, [r1] - movs r0, 0xF - ands r0, r2 - strb r0, [r1] - ldrb r0, [r7] - ldr r2, [r6] - lsls r1, r0, 1 - adds r1, r0 - adds r1, r2 - adds r1, 0x60 - lsls r0, 9 - adds r5, r4, 0x2 - adds r0, r5 - ldrb r2, [r0] - movs r3, 0xF0 - adds r0, r3, 0 - ands r0, r2 - ldrb r2, [r1] - orrs r0, r2 - strb r0, [r1] - ldrb r1, [r7] - ldr r2, [r6] - lsls r0, r1, 1 - adds r0, r1 - adds r0, r2 - adds r0, 0x61 - lsls r1, 9 - adds r4, 0x3 - mov r12, r4 - add r1, r12 - ldrb r1, [r1] - strb r1, [r0] - ldrb r0, [r7] - movs r4, 0x2 - eors r0, r4 - ldr r2, [r6] - lsls r1, r0, 1 - adds r1, r0 - adds r1, r2 - adds r1, 0x60 - ldrb r2, [r1] - adds r0, r3, 0 - ands r0, r2 - strb r0, [r1] - ldrb r0, [r7] - eors r0, r4 - ldr r2, [r6] - lsls r1, r0, 1 - adds r1, r0 - adds r1, r2 - adds r1, 0x60 - ldrb r0, [r7] - lsls r0, 9 - adds r0, r5 - ldrb r0, [r0] - ands r3, r0 - lsrs r3, 4 - ldrb r0, [r1] - orrs r3, r0 - strb r3, [r1] - ldrb r0, [r7] - eors r4, r0 - ldr r0, [r6] - lsls r1, r4, 1 - adds r1, r4 - adds r1, r0 - adds r1, 0x62 - ldrb r0, [r7] - lsls r0, 9 - add r0, r12 - ldrb r0, [r0] - strb r0, [r1] -_0803CEC6: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803CDF8 - - thumb_func_start sub_803CEDC -sub_803CEDC: @ 803CEDC - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - ldr r2, =gUnknown_0202407A - adds r4, r0, r2 - ldrb r5, [r4] - adds r2, r1, r2 - ldrb r3, [r2] - strb r3, [r4] - strb r5, [r2] - ldr r2, =gTurnOrder - adds r0, r2 - ldrb r5, [r0] - adds r1, r2 - ldrb r2, [r1] - strb r2, [r0] - strb r5, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803CEDC - - thumb_func_start b_first_side -b_first_side: @ 803CF10 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xC - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - lsls r1, 24 - lsrs r1, 24 - mov r10, r1 - lsls r2, 24 - lsrs r2, 24 - str r2, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - str r0, [sp] - movs r0, 0x13 - movs r1, 0 - movs r2, 0xD - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - bne _0803CFD8 - ldr r1, [sp, 0x8] - str r1, [sp] - movs r0, 0x13 - movs r1, 0 - movs r2, 0x4D - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - bne _0803CFD8 - ldr r1, =gBattleMons - movs r0, 0x58 - mov r2, r9 - muls r2, r0 - adds r0, r2, 0 - adds r0, r1 - adds r0, 0x20 - ldrb r3, [r0] - cmp r3, 0x21 - bne _0803CF7C - ldr r0, =gBattleWeather - ldrh r1, [r0] - movs r0, 0x7 - ands r0, r1 - cmp r0, 0 - bne _0803CF8C -_0803CF7C: - cmp r3, 0x22 - bne _0803CF98 - ldr r0, =gBattleWeather - ldrh r1, [r0] - movs r0, 0x60 - ands r0, r1 - cmp r0, 0 - beq _0803CF98 -_0803CF8C: - movs r3, 0x2 - b _0803CF9A - .pool -_0803CF98: - movs r3, 0x1 -_0803CF9A: - movs r0, 0x58 - mov r1, r10 - muls r1, r0 - adds r0, r1, 0 - ldr r2, =gBattleMons - adds r0, r2 - adds r0, 0x20 - ldrb r2, [r0] - cmp r2, 0x21 - bne _0803CFBA - ldr r0, =gBattleWeather - ldrh r1, [r0] - movs r0, 0x7 - ands r0, r1 - cmp r0, 0 - bne _0803CFCA -_0803CFBA: - cmp r2, 0x22 - bne _0803CFDA - ldr r0, =gBattleWeather - ldrh r1, [r0] - movs r0, 0x60 - ands r0, r1 - cmp r0, 0 - beq _0803CFDA -_0803CFCA: - movs r7, 0x2 - b _0803CFDC - .pool -_0803CFD8: - movs r3, 0x1 -_0803CFDA: - movs r7, 0x1 -_0803CFDC: - ldr r1, =gBattleMons - movs r0, 0x58 - mov r2, r9 - muls r2, r0 - adds r0, r2, 0 - adds r4, r0, r1 - ldrh r0, [r4, 0x6] - muls r3, r0 - ldr r2, =gStatStageRatios - movs r1, 0x1B - ldrsb r1, [r4, r1] - lsls r1, 1 - adds r0, r1, r2 - ldrb r0, [r0] - muls r0, r3 - adds r2, 0x1 - adds r1, r2 - ldrb r1, [r1] - bl __divsi3 - mov r8, r0 - ldrh r0, [r4, 0x2E] - cmp r0, 0xAF - bne _0803D02C - ldr r1, =gEnigmaBerries - mov r3, r9 - lsls r0, r3, 3 - subs r0, r3 - lsls r0, 2 - adds r0, r1 - ldrb r6, [r0, 0x7] - ldrb r5, [r0, 0x1A] - b _0803D040 - .pool -_0803D02C: - ldrh r0, [r4, 0x2E] - bl ItemId_GetHoldEffect - lsls r0, 24 - lsrs r6, r0, 24 - ldrh r0, [r4, 0x2E] - bl ItemId_GetHoldEffectParam - lsls r0, 24 - lsrs r5, r0, 24 -_0803D040: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ldr r1, =0x023f0102 - ands r0, r1 - cmp r0, 0 - bne _0803D074 - ldr r0, =0x00000869 - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _0803D074 - mov r0, r9 - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0803D074 - movs r0, 0x6E - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - movs r1, 0x64 - bl __udivsi3 - mov r8, r0 -_0803D074: - cmp r6, 0x18 - bne _0803D07E - mov r2, r8 - lsrs r2, 1 - mov r8, r2 -_0803D07E: - ldr r1, =gBattleMons - movs r0, 0x58 - mov r3, r9 - muls r3, r0 - adds r0, r3, 0 - adds r1, 0x4C - adds r0, r1 - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0803D09C - mov r0, r8 - lsrs r0, 2 - mov r8, r0 -_0803D09C: - cmp r6, 0x1A - bne _0803D0B8 - ldr r0, =gUnknown_02024330 - ldrh r4, [r0] - lsls r0, r5, 16 - subs r0, r5 - movs r1, 0x64 - bl __divsi3 - cmp r4, r0 - bge _0803D0B8 - movs r1, 0x1 - negs r1, r1 - mov r8, r1 -_0803D0B8: - ldr r1, =gBattleMons - movs r0, 0x58 - mov r2, r10 - muls r2, r0 - adds r0, r2, 0 - adds r4, r0, r1 - ldrh r0, [r4, 0x6] - adds r3, r0, 0 - muls r3, r7 - ldr r2, =gStatStageRatios - movs r1, 0x1B - ldrsb r1, [r4, r1] - lsls r1, 1 - adds r0, r1, r2 - ldrb r0, [r0] - muls r0, r3 - adds r2, 0x1 - adds r1, r2 - ldrb r1, [r1] - bl __divsi3 - adds r7, r0, 0 - ldrh r0, [r4, 0x2E] - cmp r0, 0xAF - bne _0803D118 - ldr r1, =gEnigmaBerries - mov r3, r10 - lsls r0, r3, 3 - subs r0, r3 - lsls r0, 2 - adds r0, r1 - ldrb r6, [r0, 0x7] - ldrb r5, [r0, 0x1A] - b _0803D12C - .pool -_0803D118: - ldrh r0, [r4, 0x2E] - bl ItemId_GetHoldEffect - lsls r0, 24 - lsrs r6, r0, 24 - ldrh r0, [r4, 0x2E] - bl ItemId_GetHoldEffectParam - lsls r0, 24 - lsrs r5, r0, 24 -_0803D12C: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ldr r1, =0x023f0102 - ands r0, r1 - cmp r0, 0 - bne _0803D15C - ldr r0, =0x00000869 - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _0803D15C - mov r0, r10 - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0803D15C - movs r0, 0x6E - muls r0, r7 - movs r1, 0x64 - bl __udivsi3 - adds r7, r0, 0 -_0803D15C: - cmp r6, 0x18 - bne _0803D162 - lsrs r7, 1 -_0803D162: - ldr r2, =gBattleMons - movs r0, 0x58 - mov r1, r10 - muls r1, r0 - adds r0, r1, 0 - adds r1, r2, 0 - adds r1, 0x4C - adds r0, r1 - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0803D17E - lsrs r7, 2 -_0803D17E: - cmp r6, 0x1A - bne _0803D198 - ldr r0, =gUnknown_02024330 - ldrh r4, [r0] - lsls r0, r5, 16 - subs r0, r5 - movs r1, 0x64 - bl __divsi3 - cmp r4, r0 - bge _0803D198 - movs r7, 0x1 - negs r7, r7 -_0803D198: - ldr r2, [sp, 0x4] - cmp r2, 0 - beq _0803D1B8 - movs r3, 0 - b _0803D254 - .pool -_0803D1B8: - ldr r0, =gActionForBanks - mov r3, r9 - adds r1, r3, r0 - ldrb r1, [r1] - adds r2, r0, 0 - cmp r1, 0 - bne _0803D208 - ldr r0, =gProtectStructs - lsls r1, r3, 4 - adds r1, r0 - ldrb r0, [r1] - lsls r0, 29 - cmp r0, 0 - bge _0803D1E0 - movs r3, 0xA5 - b _0803D20A - .pool -_0803D1E0: - ldr r0, =gBattleStruct - ldr r0, [r0] - add r0, r9 - adds r0, 0x80 - ldrb r0, [r0] - lsls r0, 1 - movs r1, 0x58 - mov r3, r9 - muls r3, r1 - adds r1, r3, 0 - adds r0, r1 - ldr r1, =gBattleMons - adds r1, 0xC - adds r0, r1 - ldrh r3, [r0] - b _0803D20A - .pool -_0803D208: - movs r3, 0 -_0803D20A: - mov r1, r10 - adds r0, r1, r2 - ldrb r0, [r0] - cmp r0, 0 - bne _0803D254 - ldr r0, =gProtectStructs - lsls r1, 4 - adds r1, r0 - ldrb r0, [r1] - lsls r0, 29 - cmp r0, 0 - bge _0803D22C - movs r2, 0xA5 - b _0803D256 - .pool -_0803D22C: - ldr r0, =gBattleStruct - ldr r0, [r0] - add r0, r10 - adds r0, 0x80 - ldrb r0, [r0] - lsls r0, 1 - movs r1, 0x58 - mov r2, r10 - muls r2, r1 - adds r1, r2, 0 - adds r0, r1 - ldr r1, =gBattleMons - adds r1, 0xC - adds r0, r1 - ldrh r2, [r0] - b _0803D256 - .pool -_0803D254: - movs r2, 0 -_0803D256: - ldr r4, =gBattleMoves - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 2 - adds r0, r4 - movs r1, 0x7 - ldrsb r1, [r0, r1] - lsls r3, r2, 1 - cmp r1, 0 - bne _0803D27A - adds r0, r3, r2 - lsls r0, 2 - adds r0, r4 - ldrb r0, [r0, 0x7] - lsls r0, 24 - asrs r0, 24 - cmp r0, 0 - beq _0803D2B8 -_0803D27A: - adds r0, r3, r2 - lsls r0, 2 - adds r0, r4 - ldrb r0, [r0, 0x7] - lsls r0, 24 - asrs r0, 24 - cmp r1, r0 - bne _0803D2AE - cmp r8, r7 - bne _0803D2A4 - bl Random - movs r1, 0x1 - ands r1, r0 - cmp r1, 0 - beq _0803D2A4 - movs r3, 0x2 - b _0803D2D4 - .pool -_0803D2A4: - cmp r8, r7 - bcs _0803D2D6 - movs r0, 0x1 - str r0, [sp, 0x8] - b _0803D2D6 -_0803D2AE: - cmp r1, r0 - bge _0803D2D6 - movs r1, 0x1 - str r1, [sp, 0x8] - b _0803D2D6 -_0803D2B8: - cmp r8, r7 - bne _0803D2CE - bl Random - movs r1, 0x1 - ands r1, r0 - cmp r1, 0 - beq _0803D2CE - movs r2, 0x2 - str r2, [sp, 0x8] - b _0803D2D6 -_0803D2CE: - cmp r8, r7 - bcs _0803D2D6 - movs r3, 0x1 -_0803D2D4: - str r3, [sp, 0x8] -_0803D2D6: - ldr r0, [sp, 0x8] - add sp, 0xC - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end b_first_side - - thumb_func_start sub_803D2E8 -sub_803D2E8: @ 803D2E8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - movs r3, 0 - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0803D354 - ldr r0, =gActiveBank - strb r3, [r0] - ldr r4, =gNoOfAllBanks - mov r8, r0 - ldrb r0, [r4] - cmp r3, r0 - bcc _0803D310 - b _0803D54A -_0803D310: - ldr r7, =gUnknown_0202407A - ldr r6, =gActionForBanks - mov r2, r8 - ldr r5, =gTurnOrder -_0803D318: - adds r1, r3, r7 - ldrb r0, [r2] - adds r0, r6 - ldrb r0, [r0] - strb r0, [r1] - adds r1, r3, r5 - ldrb r0, [r2] - strb r0, [r1] - adds r3, 0x1 - ldrb r0, [r2] - adds r0, 0x1 - strb r0, [r2] - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r4] - cmp r0, r1 - bcc _0803D318 - b _0803D54A - .pool -_0803D354: - movs r2, 0x2 - ands r1, r2 - cmp r1, 0 - beq _0803D3A4 - ldr r0, =gActiveBank - strb r3, [r0] - ldr r1, =gNoOfAllBanks - mov r8, r0 - adds r2, r1, 0 - ldrb r2, [r2] - cmp r3, r2 - bcs _0803D3C0 - ldr r0, =gActionForBanks - ldrb r1, [r0] - adds r4, r0, 0 - cmp r1, 0x3 - beq _0803D3BE -_0803D376: - mov r7, r8 - ldrb r0, [r7] - adds r0, 0x1 - strb r0, [r7] - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gNoOfAllBanks - ldrb r1, [r1] - cmp r0, r1 - bcs _0803D3C0 - ldrb r0, [r7] - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0x3 - bne _0803D376 - b _0803D3BE - .pool -_0803D3A4: - ldr r1, =gActionForBanks - ldrb r0, [r1] - ldr r4, =gActiveBank - mov r8, r4 - cmp r0, 0x3 - bne _0803D3B4 - strb r3, [r4] - movs r3, 0x5 -_0803D3B4: - ldrb r0, [r1, 0x2] - cmp r0, 0x3 - bne _0803D3C0 - mov r7, r8 - strb r2, [r7] -_0803D3BE: - movs r3, 0x5 -_0803D3C0: - cmp r3, 0x5 - bne _0803D448 - ldr r6, =gUnknown_0202407A - ldr r1, =gActionForBanks - mov r2, r8 - ldrb r0, [r2] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r6] - ldr r2, =gTurnOrder - mov r3, r8 - ldrb r0, [r3] - strb r0, [r2] - movs r3, 0x1 - movs r5, 0 - adds r4, r1, 0 - ldr r7, =gBattleMainFunc - mov r10, r7 - ldr r0, =bc_80154A0 - mov r12, r0 - ldr r1, =gBattleStruct - mov r9, r1 - ldr r7, =gNoOfAllBanks - ldrb r7, [r7] - cmp r5, r7 - bge _0803D41A - adds r7, r6, 0 - adds r6, r4, 0 - adds r4, r2, 0 - ldr r2, =gNoOfAllBanks -_0803D3FC: - mov r0, r8 - ldrb r0, [r0] - cmp r5, r0 - beq _0803D412 - adds r1, r3, r7 - adds r0, r5, r6 - ldrb r0, [r0] - strb r0, [r1] - adds r0, r3, r4 - strb r5, [r0] - adds r3, 0x1 -_0803D412: - adds r5, 0x1 - ldrb r1, [r2] - cmp r5, r1 - blt _0803D3FC -_0803D41A: - mov r2, r12 - mov r3, r10 - str r2, [r3] - mov r4, r9 - ldr r0, [r4] - b _0803D554 - .pool -_0803D448: - movs r0, 0 - mov r7, r8 - strb r0, [r7] - ldr r1, =gNoOfAllBanks - ldrb r0, [r1] - cmp r0, 0 - beq _0803D48E - ldr r6, =gActionForBanks - mov r2, r8 - ldr r5, =gUnknown_0202407A - ldr r4, =gTurnOrder -_0803D45E: - ldrb r0, [r2] - adds r0, r6 - ldrb r1, [r0] - subs r0, r1, 0x1 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bhi _0803D47C - adds r0, r3, r5 - strb r1, [r0] - adds r1, r3, r4 - mov r7, r8 - ldrb r0, [r7] - strb r0, [r1] - adds r3, 0x1 -_0803D47C: - ldrb r0, [r2] - adds r0, 0x1 - strb r0, [r2] - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gNoOfAllBanks - ldrb r1, [r1] - cmp r0, r1 - bcc _0803D45E -_0803D48E: - movs r0, 0 - mov r2, r8 - strb r0, [r2] - ldr r4, =gNoOfAllBanks - ldrb r0, [r4] - cmp r0, 0 - beq _0803D4D2 - ldr r6, =gActionForBanks - ldr r5, =gUnknown_0202407A - ldr r4, =gTurnOrder -_0803D4A2: - ldrb r0, [r2] - adds r0, r6 - ldrb r1, [r0] - subs r0, r1, 0x1 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bls _0803D4C0 - adds r0, r3, r5 - strb r1, [r0] - adds r1, r3, r4 - mov r7, r8 - ldrb r0, [r7] - strb r0, [r1] - adds r3, 0x1 -_0803D4C0: - ldrb r0, [r2] - adds r0, 0x1 - strb r0, [r2] - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gNoOfAllBanks - ldrb r1, [r1] - cmp r0, r1 - bcc _0803D4A2 -_0803D4D2: - movs r5, 0 - b _0803D540 - .pool -_0803D4E8: - adds r4, r5, 0x1 - adds r7, r4, 0 - ldrb r1, [r1] - cmp r7, r1 - bge _0803D53E - ldr r6, =gUnknown_0202407A - lsls r2, r5, 24 - mov r8, r2 -_0803D4F8: - ldr r0, =gTurnOrder - adds r1, r5, r0 - ldrb r3, [r1] - adds r0, r4, r0 - ldrb r1, [r0] - adds r0, r5, r6 - ldrb r2, [r0] - cmp r2, 0x1 - beq _0803D534 - adds r0, r4, r6 - ldrb r0, [r0] - cmp r0, 0x1 - beq _0803D534 - cmp r2, 0x2 - beq _0803D534 - cmp r0, 0x2 - beq _0803D534 - adds r0, r3, 0 - movs r2, 0 - bl b_first_side - lsls r0, 24 - cmp r0, 0 - beq _0803D534 - lsls r1, r4, 24 - lsrs r1, 24 - mov r3, r8 - lsrs r0, r3, 24 - bl sub_803CEDC -_0803D534: - adds r4, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _0803D4F8 -_0803D53E: - adds r5, r7, 0 -_0803D540: - ldr r1, =gNoOfAllBanks - ldrb r0, [r1] - subs r0, 0x1 - cmp r5, r0 - blt _0803D4E8 -_0803D54A: - ldr r1, =gBattleMainFunc - ldr r0, =bc_80154A0 - str r0, [r1] - ldr r0, =gBattleStruct - ldr r0, [r0] -_0803D554: - adds r0, 0x48 - movs r1, 0 - strb r1, [r0] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803D2E8 - - thumb_func_start sub_803D580 -sub_803D580: @ 803D580 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldr r1, =gActiveBank - movs r0, 0 - strb r0, [r1] - ldr r0, =gNoOfAllBanks - ldrb r2, [r0] - adds r5, r1, 0 - cmp r2, 0 - beq _0803D678 - ldr r7, =gProtectStructs - adds r6, r5, 0 - ldr r0, =gBattleMons + 0x50 - mov r12, r0 - ldr r1, =gDisableStructs - mov r8, r1 - mov r10, r8 -_0803D5AE: - mov r2, r9 - cmp r2, 0 - beq _0803D5EC - ldrb r1, [r6] - lsls r1, 4 - adds r1, r7 - ldrb r2, [r1] - movs r0, 0x2 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - ldrb r1, [r6] - lsls r1, 4 - adds r1, r7 - ldrb r2, [r1] - movs r0, 0x3 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - b _0803D648 - .pool -_0803D5EC: - ldrb r0, [r6] - lsls r0, 4 - adds r2, r0, r7 - movs r1, 0 - mov r4, r10 - movs r3, 0 -_0803D5F8: - adds r0, r2, r1 - strb r3, [r0] - adds r1, 0x1 - cmp r1, 0xF - bls _0803D5F8 - ldrb r1, [r5] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r1, r0, r4 - ldrb r0, [r1, 0x16] - cmp r0, 0 - beq _0803D616 - subs r0, 0x1 - strb r0, [r1, 0x16] -_0803D616: - ldrb r1, [r5] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r1, r0, r4 - ldrb r0, [r1, 0x19] - cmp r0, 0 - beq _0803D648 - subs r0, 0x1 - strb r0, [r1, 0x19] - ldrb r2, [r5] - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r4 - ldrb r0, [r0, 0x19] - cmp r0, 0 - bne _0803D648 - movs r0, 0x58 - muls r2, r0 - add r2, r12 - ldr r0, [r2] - ldr r1, =0xffbfffff - ands r0, r1 - str r0, [r2] -_0803D648: - ldrb r2, [r5] - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - add r0, r8 - ldrb r0, [r0, 0xA] - cmp r0, 0 - bne _0803D666 - movs r0, 0x58 - muls r2, r0 - add r2, r12 - ldr r0, [r2] - ldr r1, =0xfeffffff - ands r0, r1 - str r0, [r2] -_0803D666: - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gNoOfAllBanks - ldrb r1, [r1] - cmp r0, r1 - bcc _0803D5AE -_0803D678: - movs r0, 0 - ldr r2, =gSideTimers - strb r0, [r2, 0x8] - strb r0, [r2, 0x14] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803D580 - - thumb_func_start sub_803D6A0 -sub_803D6A0: @ 803D6A0 - push {r4-r6,lr} - ldr r2, =gActiveBank - movs r0, 0 - strb r0, [r2] - ldr r0, =gNoOfAllBanks - ldrb r1, [r0] - adds r6, r0, 0 - cmp r1, 0 - beq _0803D6DE - adds r3, r2, 0 - movs r4, 0 - ldr r5, =gSpecialStatuses -_0803D6B8: - ldrb r1, [r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r2, r0, r5 - movs r1, 0 -_0803D6C4: - adds r0, r2, r1 - strb r4, [r0] - adds r1, 0x1 - cmp r1, 0x13 - bls _0803D6C4 - ldrb r0, [r3] - adds r0, 0x1 - strb r0, [r3] - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r6] - cmp r0, r1 - bcc _0803D6B8 -_0803D6DE: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803D6A0 - - thumb_func_start bc_80154A0 -bc_80154A0: @ 803D6F0 - push {r4-r7,lr} - ldr r0, =gHitMarker - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 8 - ands r0, r1 - cmp r0, 0 - bne _0803D7AE - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r0, 0x48 - ldr r1, =gNoOfAllBanks - ldrb r0, [r0] - mov r12, r2 - adds r6, r1, 0 - ldrb r1, [r6] - cmp r0, r1 - bcs _0803D7AE - ldr r5, =gActiveBank - ldr r4, =gBankAttacker - movs r7, 0x84 - lsls r7, 1 -_0803D71C: - ldr r1, [r2] - adds r1, 0x48 - ldrb r0, [r1] - strb r0, [r4] - strb r0, [r5] - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r1, =gChosenMovesByBanks - ldrb r3, [r5] - lsls r0, r3, 1 - adds r0, r1 - ldrh r0, [r0] - cmp r0, r7 - bne _0803D7A0 - ldr r1, =gBattleMons - movs r0, 0x58 - muls r0, r3 - adds r1, 0x4C - adds r0, r1 - ldr r0, [r0] - movs r1, 0x7 - ands r0, r1 - cmp r0, 0 - bne _0803D7A0 - ldr r2, =gDisableStructs - ldrb r1, [r4] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x18] - lsls r0, 31 - cmp r0, 0 - bne _0803D7A0 - ldr r0, =gProtectStructs - lsls r1, r3, 4 - adds r1, r0 - ldrb r0, [r1] - lsls r0, 29 - cmp r0, 0 - blt _0803D7A0 - ldr r0, =gUnknown_082DB1FF - bl BattleScriptExecute - b _0803D7E8 - .pool -_0803D7A0: - mov r2, r12 - ldr r0, [r2] - adds r0, 0x48 - ldrb r0, [r0] - ldrb r1, [r6] - cmp r0, r1 - bcc _0803D71C -_0803D7AE: - bl b_clear_atk_up_if_hit_flag_unless_enraged - ldr r1, =gCurrentMoveTurn - movs r0, 0 - strb r0, [r1] - ldr r1, =gFightStateTracker - ldr r0, =gUnknown_0202407A - movs r3, 0 - ldrb r0, [r0] - strb r0, [r1] - ldr r0, =gDynamicBasePower - movs r2, 0 - strh r3, [r0] - ldr r0, =gBattleStruct - ldr r0, [r0] - strb r2, [r0, 0x13] - ldr r1, =gBattleMainFunc - ldr r0, =bc_bs_exec - str r0, [r1] - ldr r0, =gBattleCommunication - strb r2, [r0, 0x3] - strb r2, [r0, 0x4] - ldr r0, =gBattleScripting - strb r2, [r0, 0x16] - ldr r0, =gBattleResources - ldr r0, [r0] - ldr r0, [r0, 0x8] - adds r0, 0x20 - strb r2, [r0] -_0803D7E8: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end bc_80154A0 - - thumb_func_start bc_bs_exec -bc_bs_exec: @ 803D818 - push {r4-r6,lr} - ldr r6, =gBattleOutcome - ldrb r0, [r6] - ldr r2, =gFightStateTracker - cmp r0, 0 - beq _0803D828 - movs r0, 0xC - strb r0, [r2] -_0803D828: - ldr r5, =gBattleStruct - ldr r0, [r5] - adds r0, 0x4B - ldr r4, =gCurrentMoveTurn - ldrb r1, [r4] - strb r1, [r0] - ldr r1, =gUnknown_0831BC0C - ldrb r0, [r2] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 - ldr r0, =gNoOfAllBanks - ldrb r1, [r4] - ldrb r0, [r0] - cmp r1, r0 - bcc _0803D894 - ldr r2, =gHitMarker - ldr r0, [r2] - ldr r1, =0xffefffff - ands r0, r1 - str r0, [r2] - ldr r3, =gBattleMainFunc - ldr r2, =gUnknown_0831BC44 - ldrb r1, [r6] - movs r0, 0x7F - ands r0, r1 - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - str r0, [r3] - b _0803D8AC - .pool -_0803D894: - ldr r0, [r5] - adds r0, 0x4B - ldrb r0, [r0] - cmp r0, r1 - beq _0803D8AC - ldr r2, =gHitMarker - ldr r0, [r2] - ldr r1, =0xfffffdff - ands r0, r1 - ldr r1, =0xfff7ffff - ands r0, r1 - str r0, [r2] -_0803D8AC: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end bc_bs_exec - - thumb_func_start sub_803D8C0 -sub_803D8C0: @ 803D8C0 - push {r4,lr} - ldr r1, =gFightStateTracker - movs r0, 0 - strb r0, [r1] - ldr r1, =gBattleTypeFlags - ldr r2, [r1] - ldr r0, =0x02000002 - ands r0, r2 - cmp r0, 0 - beq _0803D920 - ldr r1, =gScriptResult - ldr r4, =gBattleOutcome - ldrb r0, [r4] - strh r0, [r1] - ldr r1, =gBattleTextBuff1 - ldrb r0, [r4] - strb r0, [r1] - movs r0, 0 - bl GetBankByIdentity - ldr r1, =gBankAttacker - strb r0, [r1] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAA35 - str r0, [r1] - ldrb r1, [r4] - movs r0, 0x7F - ands r0, r1 - strb r0, [r4] - b _0803DAA4 - .pool -_0803D920: - movs r0, 0x8 - ands r0, r2 - cmp r0, 0 - beq _0803D95C - ldr r0, =0x043f0900 - ands r2, r0 - cmp r2, 0 - beq _0803D95C - bl BattleMusicStop - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAA87 - str r0, [r1] - ldr r0, =gTrainerBattleOpponent_A - ldrh r1, [r0] - ldr r0, =0x000003fe - cmp r1, r0 - bne _0803D946 - b _0803DA8A -_0803D946: - b _0803DA94 - .pool -_0803D95C: - ldr r0, [r1] - movs r1, 0xA - ands r0, r1 - cmp r0, 0x8 - beq _0803D968 - b _0803DA9E -_0803D968: - bl BattleMusicStop - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DA92D - str r0, [r1] - ldr r2, =gTrainers - ldr r0, =gTrainerBattleOpponent_A - ldrh r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldrb r0, [r0, 0x1] - subs r0, 0x3 - cmp r0, 0x32 - bls _0803D98A - b _0803DA94 -_0803D98A: - lsls r0, 2 - ldr r1, =_0803D9A8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0803D9A8: - .4byte _0803DA80 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA80 - .4byte _0803DA94 - .4byte _0803DA80 - .4byte _0803DA94 - .4byte _0803DA80 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA74 - .4byte _0803DA8A - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA74 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA80 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA94 - .4byte _0803DA80 -_0803DA74: - ldr r0, =0x00000163 - bl PlayBGM - b _0803DAA4 - .pool -_0803DA80: - movs r0, 0xD4 - lsls r0, 1 - bl PlayBGM - b _0803DAA4 -_0803DA8A: - movs r0, 0xB1 - lsls r0, 1 - bl PlayBGM - b _0803DAA4 -_0803DA94: - movs r0, 0xCE - lsls r0, 1 - bl PlayBGM - b _0803DAA4 -_0803DA9E: - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DA96A - str r0, [r1] -_0803DAA4: - ldr r1, =gBattleMainFunc - ldr r0, =sub_803DCD8 - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803D8C0 - - thumb_func_start sub_803DAC0 -sub_803DAC0: @ 803DAC0 - push {r4,lr} - ldr r1, =gFightStateTracker - movs r0, 0 - strb r0, [r1] - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - ldr r0, =0x02000002 - ands r0, r1 - cmp r0, 0 - beq _0803DB7C - ldr r0, =0x003f0100 - ands r1, r0 - cmp r1, 0 - beq _0803DB44 - ldr r3, =gBattleOutcome - ldrb r2, [r3] - movs r0, 0x80 - ands r0, r2 - cmp r0, 0 - beq _0803DB2C - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DB9C8 - str r0, [r1] - movs r0, 0x7F - ands r0, r2 - strb r0, [r3] - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldr r0, =0x00000ca9 - adds r1, r0 - ldrb r0, [r1] - movs r2, 0x8 - orrs r0, r2 - strb r0, [r1] - b _0803DB82 - .pool -_0803DB2C: - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAA0B - str r0, [r1] - movs r0, 0x7F - ands r0, r2 - strb r0, [r3] - b _0803DB82 - .pool -_0803DB44: - ldr r1, =gBattleTextBuff1 - ldr r4, =gBattleOutcome - ldrb r0, [r4] - strb r0, [r1] - movs r0, 0 - bl GetBankByIdentity - ldr r1, =gBankAttacker - strb r0, [r1] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAA35 - str r0, [r1] - ldrb r1, [r4] - movs r0, 0x7F - ands r0, r1 - strb r0, [r4] - b _0803DB82 - .pool -_0803DB7C: - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DA96D - str r0, [r1] -_0803DB82: - ldr r1, =gBattleMainFunc - ldr r0, =sub_803DCD8 - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803DAC0 - - thumb_func_start sub_803DBA0 -sub_803DBA0: @ 803DBA0 - push {lr} - ldr r1, =gFightStateTracker - movs r0, 0 - strb r0, [r1] - ldr r1, =gBattleTypeFlags - ldr r2, [r1] - ldr r0, =0x003f0100 - ands r0, r2 - cmp r0, 0 - beq _0803DBFC - movs r0, 0x8 - ands r2, r0 - cmp r2, 0 - beq _0803DBFC - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DB9C1 - str r0, [r1] - ldr r1, =gBattleOutcome - movs r0, 0x9 - strb r0, [r1] - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldr r0, =0x00000ca9 - adds r1, r0 - ldrb r0, [r1] - movs r2, 0x8 - orrs r0, r2 - strb r0, [r1] - b _0803DC6A - .pool -_0803DBFC: - ldr r0, [r1] - movs r1, 0x80 - lsls r1, 19 - ands r0, r1 - cmp r0, 0 - beq _0803DC24 - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DB9C1 - str r0, [r1] - ldr r1, =gBattleOutcome - movs r0, 0x9 - strb r0, [r1] - b _0803DC6A - .pool -_0803DC24: - ldr r1, =gProtectStructs - ldr r0, =gBankAttacker - ldrb r0, [r0] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0x1] - lsls r0, 27 - lsrs r0, 30 - cmp r0, 0x1 - beq _0803DC54 - cmp r0, 0x2 - beq _0803DC64 - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAAF0 - b _0803DC68 - .pool -_0803DC54: - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAADB - b _0803DC68 - .pool -_0803DC64: - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAAE9 -_0803DC68: - str r0, [r1] -_0803DC6A: - ldr r1, =gBattleMainFunc - ldr r0, =sub_803DCD8 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_803DBA0 - - thumb_func_start bc_80158BC -bc_80158BC: @ 803DC84 - ldr r1, =gFightStateTracker - movs r0, 0 - strb r0, [r1] - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x7 - strb r0, [r1, 0x1] - ldr r2, =gBankAttacker - ldrb r0, [r2] - strb r0, [r1, 0x2] - ldr r3, =gBattlePartyID - ldrb r0, [r2] - lsls r0, 1 - adds r0, r3 - ldrh r0, [r0] - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAAF7 - str r0, [r1] - ldr r1, =gBattleMainFunc - ldr r0, =sub_803DCD8 - str r0, [r1] - bx lr - .pool - thumb_func_end bc_80158BC - - thumb_func_start sub_803DCD8 -sub_803DCD8: @ 803DCD8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r0, =gFightStateTracker - ldrb r0, [r0] - subs r0, 0xB - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bls _0803DCEE - b _0803DE10 -_0803DCEE: - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - ldr r0, =0x023f0b92 - ands r1, r0 - cmp r1, 0 - bne _0803DDB6 - ldr r2, =gActiveBank - strb r1, [r2] - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r1, r0 - bcs _0803DDB2 - adds r5, r2, 0 - ldr r0, =gBattlePartyID - mov r8, r0 - movs r7, 0x64 - ldr r6, =gPlayerParty -_0803DD10: - ldrb r0, [r5] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0803DDA0 - ldr r4, =gBattleResults - ldrh r0, [r4, 0x6] - cmp r0, 0 - bne _0803DD74 - ldrb r0, [r5] - lsls r0, 1 - add r0, r8 - ldrh r0, [r0] - muls r0, r7 - adds r0, r6 - movs r1, 0xB - movs r2, 0 - bl GetMonData - strh r0, [r4, 0x6] - ldrb r0, [r5] - lsls r0, 1 - add r0, r8 - ldrh r0, [r0] - muls r0, r7 - adds r0, r6 - movs r1, 0x2 - adds r2, r4, 0 - adds r2, 0x8 - bl GetMonData - b _0803DDA0 - .pool -_0803DD74: - ldrb r0, [r5] - lsls r0, 1 - add r0, r8 - ldrh r0, [r0] - muls r0, r7 - adds r0, r6 - movs r1, 0xB - movs r2, 0 - bl GetMonData - strh r0, [r4, 0x26] - ldrb r0, [r5] - lsls r0, 1 - add r0, r8 - ldrh r0, [r0] - muls r0, r7 - adds r0, r6 - movs r1, 0x2 - adds r2, r4, 0 - adds r2, 0x14 - bl GetMonData -_0803DDA0: - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bcc _0803DD10 -_0803DDB2: - bl sub_80EC728 -_0803DDB6: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ldr r1, =0x023f0b9a - ands r0, r1 - cmp r0, 0 - bne _0803DDD2 - ldr r0, =gBattleResults - ldrb r1, [r0, 0x5] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0803DDD2 - bl sub_80EE184 -_0803DDD2: - bl sub_8186444 - movs r0, 0x3 - bl BeginFastPaletteFade - movs r0, 0x5 - bl FadeOutMapMusic - ldr r1, =gBattleMainFunc - ldr r0, =sub_803DE40 - str r0, [r1] - ldr r1, =gUnknown_030061E8 - ldr r0, =BattleMainCB2 - str r0, [r1] - b _0803DE2A - .pool -_0803DE10: - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0803DE2A - ldr r1, =gBattleScriptingCommandsTable - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 -_0803DE2A: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803DCD8 - - thumb_func_start sub_803DE40 -sub_803DE40: @ 803DE40 - push {lr} - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0803DE86 - bl ResetSpriteData - ldr r0, =gLeveledUpInBattle - ldrb r0, [r0] - cmp r0, 0 - beq _0803DE62 - ldr r0, =gBattleOutcome - ldrb r0, [r0] - cmp r0, 0x1 - beq _0803DE80 -_0803DE62: - ldr r1, =gBattleMainFunc - ldr r0, =c4_overworld - str r0, [r1] - b _0803DEA2 - .pool -_0803DE80: - ldr r1, =gBattleMainFunc - ldr r0, =bc_evolution_cutscene - str r0, [r1] -_0803DE86: - bl FreeAllWindowBuffers - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - bne _0803DEA2 - bl sub_805F094 - bl sub_8057028 - bl dp11_free -_0803DEA2: - pop {r0} - bx r0 - .pool - thumb_func_end sub_803DE40 - - thumb_func_start bc_evolution_cutscene -bc_evolution_cutscene: @ 803DEB4 - push {r4-r6,lr} - ldr r0, =gLeveledUpInBattle - ldrb r1, [r0] - adds r3, r0, 0 - cmp r1, 0 - beq _0803DF2E -_0803DEC0: - movs r6, 0 -_0803DEC2: - ldrb r2, [r3] - ldr r0, =gBitTable - lsls r1, r6, 2 - adds r1, r0 - ldr r1, [r1] - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - beq _0803DF20 - bics r2, r1 - strb r2, [r3] - movs r0, 0x64 - adds r1, r6, 0 - muls r1, r0 - ldr r0, =gPlayerParty - adds r5, r1, r0 - adds r0, r5, 0 - movs r1, 0 - bl GetEvolutionTargetSpecies - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0 - beq _0803DF20 - bl FreeAllWindowBuffers - ldr r0, =gBattleMainFunc - ldr r1, =sub_803DF48 - str r1, [r0] - lsls r3, r6, 24 - lsrs r3, 24 - adds r0, r5, 0 - adds r1, r4, 0 - movs r2, 0x1 - bl evolution_cutscene - b _0803DF34 - .pool -_0803DF20: - adds r6, 0x1 - ldr r3, =gLeveledUpInBattle - cmp r6, 0x5 - ble _0803DEC2 - ldrb r0, [r3] - cmp r0, 0 - bne _0803DEC0 -_0803DF2E: - ldr r1, =gBattleMainFunc - ldr r0, =c4_overworld - str r0, [r1] -_0803DF34: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end bc_evolution_cutscene - - thumb_func_start sub_803DF48 -sub_803DF48: @ 803DF48 - push {lr} - ldr r0, =gMain - ldr r1, [r0, 0x4] - ldr r0, =BattleMainCB2 - cmp r1, r0 - bne _0803DF5A - ldr r1, =gBattleMainFunc - ldr r0, =bc_evolution_cutscene - str r0, [r1] -_0803DF5A: - pop {r0} - bx r0 - .pool - thumb_func_end sub_803DF48 - - thumb_func_start c4_overworld -c4_overworld: @ 803DF70 - push {r4-r6,lr} - ldr r6, =gBattleTypeFlags - ldr r0, [r6] - movs r5, 0x2 - ands r0, r5 - cmp r0, 0 - bne _0803DF8C - ldr r4, =gPlayerParty - adds r0, r4, 0 - bl RandomlyGivePartyPokerus - adds r0, r4, 0 - bl PartySpreadPokerus -_0803DF8C: - ldr r4, [r6] - adds r0, r4, 0 - ands r0, r5 - cmp r0, 0 - beq _0803DF9E - ldr r0, =gUnknown_03003124 - ldrb r0, [r0] - cmp r0, 0 - bne _0803DFEC -_0803DF9E: - ldr r1, =gScriptResult - ldr r5, =gBattleOutcome - ldrb r0, [r5] - strh r0, [r1] - ldr r3, =gMain - ldr r0, =0x00000439 - adds r2, r3, r0 - ldrb r1, [r2] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - ldr r0, =gUnknown_03005D00 - ldr r0, [r0] - str r0, [r3] - movs r0, 0x80 - lsls r0, 3 - ands r4, r0 - cmp r4, 0 - beq _0803DFDE - ldr r0, =gEnemyParty - bl UpdateRoamerHPStatus - ldrb r1, [r5] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _0803DFDA - cmp r1, 0x7 - bne _0803DFDE -_0803DFDA: - bl SetRoamerInactive -_0803DFDE: - movs r0, 0x5A - bl m4aSongNumStop - ldr r0, =gMain - ldr r0, [r0, 0x8] - bl SetMainCallback2 -_0803DFEC: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end c4_overworld - - thumb_func_start bc_move_exec_returning -bc_move_exec_returning: @ 803E018 - push {lr} - ldr r0, =gFightStateTracker - ldrb r0, [r0] - subs r0, 0xB - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bhi _0803E060 - ldr r3, =gBattleResources - ldr r0, [r3] - ldr r0, [r0, 0xC] - adds r1, r0, 0 - adds r1, 0x20 - ldrb r0, [r1] - cmp r0, 0 - beq _0803E03C - subs r0, 0x1 - strb r0, [r1] -_0803E03C: - ldr r2, =gBattleMainFunc - ldr r0, [r3] - ldr r1, [r0, 0xC] - adds r0, r1, 0 - adds r0, 0x20 - ldrb r0, [r0] - lsls r0, 2 - adds r1, r0 - ldr r0, [r1] - str r0, [r2] - b _0803E07A - .pool -_0803E060: - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0803E07A - ldr r1, =gBattleScriptingCommandsTable - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 -_0803E07A: - pop {r0} - bx r0 - .pool - thumb_func_end bc_move_exec_returning - - thumb_func_start sub_803E08C -sub_803E08C: @ 803E08C - push {lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0803E0A8 - ldr r1, =gBattleScriptingCommandsTable - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 -_0803E0A8: - pop {r0} - bx r0 - .pool - thumb_func_end sub_803E08C - - thumb_func_start sub_803E0B8 -sub_803E0B8: @ 803E0B8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - movs r0, 0x4 - str r0, [sp] - ldr r6, =gBankAttacker - ldr r1, =gTurnOrder - ldr r0, =gCurrentMoveTurn - ldrb r0, [r0] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r6] - ldr r1, =gBattleStruct - ldr r3, [r1] - adds r0, r3, 0 - adds r0, 0x91 - ldrb r2, [r0] - ldr r1, =gBitTable - ldrb r0, [r6] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - ands r2, r0 - cmp r2, 0 - beq _0803E110 - ldr r1, =gFightStateTracker - movs r0, 0xC - b _0803E83C - .pool -_0803E110: - ldr r1, =gCritMultiplier - movs r0, 0x1 - strb r0, [r1] - ldr r1, =gBattleScripting - movs r0, 0x1 - strb r0, [r1, 0xE] - ldr r5, =0x000001a3 - adds r0, r3, r5 - strb r2, [r0] - ldr r0, =gBattleMoveFlags - strb r2, [r0] - ldr r0, =gMultiHitCounter - strb r2, [r0] - ldr r0, =gBattleCommunication - strb r2, [r0, 0x6] - ldr r2, =gCurrMovePos - ldr r0, =gUnknown_020241E9 - mov r9, r0 - ldrb r0, [r6] - ldr r3, =gBattleStruct - ldr r1, [r3] - adds r0, r1 - adds r0, 0x80 - ldrb r0, [r0] - mov r5, r9 - strb r0, [r5] - strb r0, [r2] - ldr r1, =gProtectStructs - ldrb r4, [r6] - lsls r0, r4, 4 - adds r3, r0, r1 - ldrb r1, [r3] - lsls r0, r1, 29 - mov r8, r2 - cmp r0, 0 - bge _0803E1BC - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r3] - ldr r2, =gCurrentMove - ldr r1, =gLastUsedMove - movs r0, 0xA5 - strh r0, [r1] - strh r0, [r2] - ldr r2, =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 4 - orrs r0, r1 - str r0, [r2] - movs r0, 0xA5 - movs r1, 0 - bl GetMoveTarget - ldrb r1, [r6] - ldr r3, =gBattleStruct - ldr r2, [r3] - b _0803E316 - .pool -_0803E1BC: - ldr r5, =gBattleMons - mov r10, r5 - movs r0, 0x58 - adds r5, r4, 0 - muls r5, r0 - mov r0, r10 - adds r0, 0x50 - adds r0, r5, r0 - ldr r1, [r0] - movs r0, 0x80 - lsls r0, 5 - ands r0, r1 - cmp r0, 0 - bne _0803E1E2 - movs r7, 0x80 - lsls r7, 15 - ands r7, r1 - cmp r7, 0 - beq _0803E204 -_0803E1E2: - ldr r3, =gCurrentMove - ldr r2, =gLastUsedMove - ldr r1, =gLockedMoves - lsls r0, r4, 1 - adds r0, r1 - ldrh r0, [r0] - strh r0, [r2] - strh r0, [r3] - b _0803E33C - .pool -_0803E204: - ldr r1, =gDisableStructs - mov r12, r1 - lsls r0, r4, 3 - subs r0, r4 - lsls r0, 2 - add r0, r12 - ldrh r3, [r0, 0x6] - adds r1, r3, 0 - cmp r1, 0 - beq _0803E2DC - ldrb r2, [r0, 0xC] - lsls r0, r2, 1 - adds r0, r5 - mov r4, r10 - adds r4, 0xC - adds r0, r4 - ldrh r0, [r0] - cmp r1, r0 - bne _0803E268 - ldr r2, =gCurrentMove - ldr r0, =gLastUsedMove - strh r3, [r0] - strh r3, [r2] - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r12 - ldrb r0, [r0, 0xC] - mov r3, r9 - strb r0, [r3] - mov r5, r8 - strb r0, [r5] - ldrh r0, [r2] - movs r1, 0 - bl GetMoveTarget - ldrb r1, [r6] - ldr r3, =gBattleStruct - ldr r2, [r3] - b _0803E316 - .pool -_0803E268: - cmp r1, 0 - beq _0803E2DC - cmp r1, r0 - beq _0803E2DC - mov r5, r9 - strb r2, [r5] - mov r0, r8 - strb r2, [r0] - ldr r3, =gCurrentMove - ldr r2, =gLastUsedMove - ldrb r0, [r0] - lsls r0, 1 - ldrb r1, [r6] - movs r5, 0x58 - muls r1, r5 - adds r0, r1 - adds r0, r4 - ldrh r0, [r0] - strh r0, [r2] - strh r0, [r3] - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r12 - movs r2, 0 - strh r7, [r0, 0x6] - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r12 - strb r2, [r0, 0xC] - ldrb r0, [r6] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - add r1, r12 - ldrb r2, [r1, 0xE] - movs r0, 0x10 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0xE] - ldrh r0, [r3] - movs r1, 0 - bl GetMoveTarget - ldrb r1, [r6] - ldr r3, =gBattleStruct - ldr r2, [r3] - b _0803E316 - .pool -_0803E2DC: - ldr r3, =gBattleMons - mov r5, r8 - ldrb r0, [r5] - lsls r0, 1 - ldr r4, =gBankAttacker - ldrb r2, [r4] - movs r1, 0x58 - muls r1, r2 - adds r0, r1 - adds r3, 0xC - adds r0, r3 - ldr r1, =gChosenMovesByBanks - lsls r2, 1 - adds r2, r1 - ldrh r3, [r0] - ldrh r2, [r2] - cmp r3, r2 - beq _0803E334 - ldr r1, =gCurrentMove - ldr r0, =gLastUsedMove - strh r3, [r0] - strh r3, [r1] - ldrh r0, [r1] - movs r1, 0 - bl GetMoveTarget - ldrb r1, [r4] - ldr r2, =gBattleStruct - ldr r2, [r2] -_0803E316: - adds r1, r2 - strb r0, [r1, 0xC] - b _0803E33C - .pool -_0803E334: - ldr r1, =gCurrentMove - ldr r0, =gLastUsedMove - strh r3, [r0] - strh r3, [r1] -_0803E33C: - ldr r2, =gBattleMons - ldr r1, =gBankAttacker - ldrb r3, [r1] - movs r0, 0x58 - muls r0, r3 - adds r0, r2 - ldrh r0, [r0, 0x28] - mov r8, r1 - cmp r0, 0 - beq _0803E384 - adds r0, r3, 0 - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0803E37C - ldr r0, =gBattleResults - ldr r1, =gCurrentMove - ldrh r1, [r1] - strh r1, [r0, 0x22] - b _0803E384 - .pool -_0803E37C: - ldr r0, =gBattleResults - ldr r1, =gCurrentMove - ldrh r1, [r1] - strh r1, [r0, 0x24] -_0803E384: - mov r1, r8 - ldrb r0, [r1] - bl GetBankSide - movs r1, 0x1 - eors r0, r1 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gSideTimers - lsls r0, r6, 1 - adds r0, r6 - lsls r0, 2 - adds r5, r0, r1 - ldrb r0, [r5, 0x8] - cmp r0, 0 - beq _0803E400 - ldr r2, =gBattleMoves - ldr r0, =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x6] - cmp r0, 0 - bne _0803E400 - mov r3, r8 - ldrb r0, [r3] - bl GetBankSide - adds r4, r0, 0 - ldrb r0, [r5, 0x9] - bl GetBankSide - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - beq _0803E400 - ldr r1, =gBattleMons - ldrb r2, [r5, 0x9] - movs r0, 0x58 - muls r0, r2 - adds r0, r1 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _0803E400 - ldr r0, =gBankTarget - strb r2, [r0] - b _0803E76A - .pool -_0803E400: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x1 - ands r0, r1 - ldr r5, =gBankAttacker - mov r8, r5 - cmp r0, 0 - bne _0803E412 - b _0803E6E0 -_0803E412: - ldr r1, =gSideTimers - lsls r0, r6, 1 - adds r0, r6 - lsls r0, 2 - adds r0, r1 - ldrb r5, [r0, 0x8] - cmp r5, 0 - beq _0803E424 - b _0803E630 -_0803E424: - ldr r2, =gBattleMoves - ldr r0, =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r4, r0, r2 - ldrb r0, [r4, 0x1] - cmp r0, 0 - bne _0803E440 - ldrb r0, [r4, 0x6] - cmp r0, 0x10 - bne _0803E440 - b _0803E630 -_0803E440: - ldr r3, =gBattleMons - ldr r2, =gBankAttacker - ldrb r6, [r2] - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, r6, r0 - ldrb r1, [r0, 0xC] - movs r0, 0x58 - muls r0, r1 - adds r0, r3 - adds r0, 0x20 - ldrb r0, [r0] - mov r8, r2 - cmp r0, 0x1F - bne _0803E460 - b _0803E630 -_0803E460: - ldrb r0, [r4, 0x2] - cmp r0, 0xD - beq _0803E468 - b _0803E630 -_0803E468: - adds r0, r6, 0 - bl GetBankSide - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gActiveBank - strb r5, [r1] - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r5, r0 - bcs _0803E4E0 - adds r4, r1, 0 -_0803E480: - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r6, r0 - beq _0803E4CE - ldr r0, =gBankAttacker - ldrb r1, [r0] - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r1, r0 - ldrb r0, [r1, 0xC] - ldrb r1, [r4] - cmp r0, r1 - beq _0803E4CE - ldr r1, =gBattleMons - ldrb r2, [r4] - movs r0, 0x58 - muls r0, r2 - adds r0, r1 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x1F - bne _0803E4CE - adds r0, r2, 0 - bl BankGetTurnOrder - lsls r0, 24 - lsrs r0, 24 - ldr r3, [sp] - cmp r0, r3 - bcs _0803E4CE - ldrb r0, [r4] - bl BankGetTurnOrder - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] -_0803E4CE: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bcc _0803E480 -_0803E4E0: - ldr r5, [sp] - cmp r5, 0x4 - beq _0803E4E8 - b _0803E5E2 -_0803E4E8: - ldr r2, =gBattleMoves - ldr r0, =gLastUsedMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x6] - ands r5, r0 - cmp r5, 0 - beq _0803E568 - ldr r0, =gBankAttacker - ldrb r0, [r0] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0803E548 - bl Random - movs r1, 0x1 - ands r1, r0 - cmp r1, 0 - beq _0803E544 - movs r0, 0x1 - b _0803E55A - .pool -_0803E544: - movs r0, 0x3 - b _0803E55A -_0803E548: - bl Random - movs r1, 0x1 - ands r1, r0 - cmp r1, 0 - beq _0803E558 - movs r0, 0 - b _0803E55A -_0803E558: - movs r0, 0x2 -_0803E55A: - bl GetBankByIdentity - ldr r1, =gBankTarget - strb r0, [r1] - b _0803E578 - .pool -_0803E568: - ldr r2, =gBankTarget - ldr r0, =gBankAttacker - ldrb r0, [r0] - ldr r1, =gBattleStruct - ldr r1, [r1] - adds r0, r1 - ldrb r0, [r0, 0xC] - strb r0, [r2] -_0803E578: - ldr r7, =gAbsentBankFlags - ldrb r0, [r7] - ldr r1, =gBitTable - mov r8, r1 - ldr r5, =gBankTarget - ldrb r1, [r5] - lsls r1, 2 - add r1, r8 - ldr r1, [r1] - ands r0, r1 - cmp r0, 0 - bne _0803E592 - b _0803E76A -_0803E592: - ldr r6, =gBankAttacker - ldrb r0, [r6] - bl GetBankSide - adds r4, r0, 0 - ldrb r0, [r5] - bl GetBankSide - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - beq _0803E5C4 - ldrb r0, [r5] - b _0803E758 - .pool -_0803E5C4: - ldrb r0, [r6] - bl GetBankIdentity - movs r1, 0x1 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - strb r0, [r5] - ldrb r1, [r7] - ldrb r2, [r5] - lsls r0, r2, 2 - add r0, r8 - b _0803E74E -_0803E5E2: - ldr r4, =gActiveBank - ldr r0, =gTurnOrder - ldr r3, [sp] - adds r0, r3, r0 - ldrb r0, [r0] - strb r0, [r4] - ldrb r0, [r4] - ldr r2, =gBattleMons - movs r1, 0x58 - muls r1, r0 - adds r1, r2 - adds r1, 0x20 - ldrb r1, [r1] - bl RecordAbilityBattle - ldr r2, =gSpecialStatuses - ldrb r1, [r4] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - movs r2, 0x2 - orrs r1, r2 - strb r1, [r0] - ldr r1, =gBankTarget - ldrb r0, [r4] - strb r0, [r1] - b _0803E76A - .pool -_0803E630: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r4, 0x1 - ands r0, r4 - cmp r0, 0 - beq _0803E6E0 - ldr r2, =gBattleMoves - ldr r0, =gLastUsedMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0, 0x6] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0803E6E0 - mov r5, r8 - ldrb r0, [r5] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0803E684 - bl Random - adds r1, r4, 0 - ands r1, r0 - cmp r1, 0 - beq _0803E680 - movs r0, 0x1 - b _0803E696 - .pool -_0803E680: - movs r0, 0x3 - b _0803E696 -_0803E684: - bl Random - adds r1, r4, 0 - ands r1, r0 - cmp r1, 0 - beq _0803E694 - movs r0, 0 - b _0803E696 -_0803E694: - movs r0, 0x2 -_0803E696: - bl GetBankByIdentity - ldr r1, =gBankTarget - strb r0, [r1] - ldr r0, =gAbsentBankFlags - ldrb r1, [r0] - ldr r2, =gBitTable - ldr r5, =gBankTarget - ldrb r0, [r5] - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _0803E76A - ldr r0, =gBankAttacker - ldrb r0, [r0] - bl GetBankSide - adds r4, r0, 0 - ldrb r0, [r5] - bl GetBankSide - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - beq _0803E76A - ldrb r0, [r5] - b _0803E758 - .pool -_0803E6E0: - ldr r5, =gBankTarget - mov r2, r8 - ldrb r0, [r2] - ldr r1, =gBattleStruct - ldr r1, [r1] - adds r0, r1 - ldrb r0, [r0, 0xC] - strb r0, [r5] - ldr r6, =gAbsentBankFlags - ldrb r1, [r6] - ldr r7, =gBitTable - ldrb r0, [r5] - lsls r0, 2 - adds r0, r7 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _0803E76A - ldrb r0, [r2] - bl GetBankSide - adds r4, r0, 0 - ldrb r0, [r5] - bl GetBankSide - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - beq _0803E730 - ldrb r0, [r5] - b _0803E758 - .pool -_0803E730: - mov r1, r8 - ldrb r0, [r1] - bl GetBankIdentity - movs r1, 0x1 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - strb r0, [r5] - ldrb r1, [r6] - ldrb r2, [r5] - lsls r0, r2, 2 - adds r0, r7 -_0803E74E: - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _0803E76A - adds r0, r2, 0 -_0803E758: - bl GetBankIdentity - movs r1, 0x2 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - strb r0, [r5] -_0803E76A: - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r2, 0x80 - lsls r2, 10 - ands r1, r2 - adds r5, r0, 0 - cmp r1, 0 - beq _0803E808 - ldr r0, =gProtectStructs - ldr r4, =gBankAttacker - ldrb r2, [r4] - lsls r1, r2, 4 - adds r1, r0 - ldrb r0, [r1, 0x2] - lsls r0, 27 - cmp r0, 0 - bge _0803E808 - ldr r1, =gBattleMons - movs r0, 0x58 - muls r0, r2 - adds r0, r1 - ldrh r0, [r0, 0x28] - cmp r0, 0 - bne _0803E7B4 - ldr r1, =gFightStateTracker - movs r0, 0xC - b _0803E83C - .pool -_0803E7B4: - ldr r3, =gUnknown_02024230 - lsls r0, r2, 2 - adds r0, r3 - ldr r0, [r0] - cmp r0, 0 - beq _0803E7EC - ldr r1, =gBattleCommunication - movs r2, 0 - movs r0, 0x4 - strb r0, [r1, 0x5] - ldr r1, =gBattlescriptCurrInstr - ldrb r0, [r4] - lsls r0, 2 - adds r0, r3 - ldr r0, [r0] - str r0, [r1] - ldrb r0, [r4] - lsls r0, 2 - adds r0, r3 - str r2, [r0] - b _0803E824 - .pool -_0803E7EC: - ldr r1, =gBattleCommunication - movs r0, 0x4 - strb r0, [r1, 0x5] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =BattleScript_MoveUsedLoafingAround - str r0, [r1] - b _0803E824 - .pool -_0803E808: - ldr r4, =gBattlescriptCurrInstr - ldr r3, =gBattleScriptsForMoveEffects - ldr r2, =gBattleMoves - ldr r0, =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r3 - ldr r0, [r0] - str r0, [r4] -_0803E824: - ldr r0, [r5] - movs r1, 0x80 - lsls r1, 11 - ands r0, r1 - cmp r0, 0 - beq _0803E838 - ldr r0, =gBankAttacker - ldrb r0, [r0] - bl sub_81A56E8 -_0803E838: - ldr r1, =gFightStateTracker - movs r0, 0xA -_0803E83C: - strb r0, [r1] - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803E0B8 - - thumb_func_start bs2_8016374 -bs2_8016374: @ 803E868 - push {r4,lr} - ldr r3, =gBankAttacker - ldr r1, =gTurnOrder - ldr r0, =gCurrentMoveTurn - ldrb r0, [r0] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r3] - ldr r0, =gUnknown_02022E14 - movs r2, 0 - strh r2, [r0] - ldr r0, =gUnknown_02022E16 - strh r2, [r0] - ldr r1, =gUnknown_020244AC - ldrb r0, [r3] - adds r0, r1 - strb r2, [r0] - ldr r1, =gUnknown_020244B0 - ldrb r0, [r3] - adds r0, r1 - strb r2, [r0] - ldr r2, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r2] - movs r0, 0x7 - strb r0, [r2, 0x1] - ldrb r4, [r3] - strb r4, [r2, 0x2] - ldrb r0, [r3] - ldr r1, =gBattleStruct - ldr r1, [r1] - adds r0, r1 - adds r0, 0x58 - ldrb r0, [r0] - strb r0, [r2, 0x3] - movs r0, 0xFF - strb r0, [r2, 0x4] - ldr r0, =gBattleScripting - strb r4, [r0, 0x17] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAB15 - str r0, [r1] - ldr r1, =gFightStateTracker - movs r0, 0xA - strb r0, [r1] - ldr r1, =gBattleResults - ldrb r0, [r1, 0x2] - cmp r0, 0xFE - bhi _0803E8CE - adds r0, 0x1 - strb r0, [r1, 0x2] -_0803E8CE: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end bs2_8016374 - - thumb_func_start sub_803E90C -sub_803E90C: @ 803E90C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r4, =gBankAttacker - ldr r2, =gBankTarget - ldr r1, =gTurnOrder - ldr r0, =gCurrentMoveTurn - ldrb r0, [r0] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r2] - strb r0, [r4] - ldr r0, =gUnknown_02022E14 - movs r1, 0 - strh r1, [r0] - ldr r0, =gUnknown_02022E16 - strh r1, [r0] - ldrb r0, [r4] - bl sub_8045868 - ldr r5, =gLastUsedItem - ldr r2, =gBattleBufferB - ldrb r1, [r4] - lsls r1, 9 - adds r0, r2, 0x1 - adds r0, r1, r0 - ldrb r3, [r0] - adds r2, 0x2 - adds r1, r2 - ldrb r0, [r1] - lsls r0, 8 - orrs r3, r0 - strh r3, [r5] - cmp r3, 0xC - bhi _0803E998 - ldr r2, =gBattlescriptCurrInstr - ldr r1, =gUnknown_082DBD08 - ldrh r0, [r5] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - str r0, [r2] - ldr r0, =gFightStateTracker - mov r10, r0 - b _0803EBF6 - .pool -_0803E998: - adds r0, r3, 0 - subs r0, 0x50 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bhi _0803E9C0 - ldr r0, =gBattlescriptCurrInstr - ldr r1, =gUnknown_082DBD54 - ldr r1, [r1] - str r1, [r0] - ldr r1, =gFightStateTracker - mov r10, r1 - b _0803EBF6 - .pool -_0803E9C0: - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0803E9E8 - ldr r0, =gBattlescriptCurrInstr - ldr r1, =gUnknown_082DBD3C - ldr r1, [r1] - str r1, [r0] - ldr r2, =gFightStateTracker - mov r10, r2 - b _0803EBF6 - .pool -_0803E9E8: - ldr r3, =gBattleScripting - ldrb r0, [r4] - strb r0, [r3, 0x17] - lsls r0, 24 - lsrs r0, 25 - ldr r2, =gBattleStruct - ldr r1, [r2] - adds r0, r1 - adds r0, 0xC4 - ldrb r0, [r0] - subs r0, 0x1 - mov r8, r4 - ldr r1, =gBattlescriptCurrInstr - mov r9, r1 - ldr r6, =gUnknown_082DBD3C - mov r12, r3 - adds r7, r2, 0 - ldr r2, =gFightStateTracker - mov r10, r2 - cmp r0, 0x4 - bls _0803EA14 - b _0803EBDE -_0803EA14: - lsls r0, 2 - ldr r1, =_0803EA38 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0803EA38: - .4byte _0803EBDE - .4byte _0803EBDE - .4byte _0803EA4C - .4byte _0803EAE0 - .4byte _0803EBB0 -_0803EA4C: - ldr r5, =gBattleCommunication - movs r0, 0 - strb r0, [r5, 0x5] - ldr r2, =gBankAttacker - ldrb r0, [r2] - lsrs r0, 1 - ldr r1, [r7] - adds r0, r1 - adds r0, 0xC6 - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - mov r8, r2 - cmp r0, 0 - beq _0803EA98 - movs r0, 0x3E - ands r0, r1 - ldr r1, =gBattlescriptCurrInstr - mov r9, r1 - ldr r6, =gUnknown_082DBD3C - ldr r2, =gFightStateTracker - mov r10, r2 - cmp r0, 0 - bne _0803EA7E - b _0803EBDE -_0803EA7E: - movs r0, 0x5 - strb r0, [r5, 0x5] - b _0803EBDE - .pool -_0803EA98: - ldr r0, =gBattlescriptCurrInstr - mov r9, r0 - ldr r6, =gUnknown_082DBD3C - ldr r1, =gFightStateTracker - mov r10, r1 - mov r4, r8 - adds r3, r7, 0 - adds r2, r5, 0 -_0803EAA8: - ldrb r1, [r4] - lsrs r1, 1 - ldr r0, [r3] - adds r1, r0 - adds r1, 0xC6 - ldrb r0, [r1] - lsrs r0, 1 - strb r0, [r1] - ldrb r0, [r2, 0x5] - adds r0, 0x1 - strb r0, [r2, 0x5] - ldrb r0, [r4] - lsrs r0, 1 - ldr r1, [r3] - adds r0, r1 - adds r0, 0xC6 - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0803EAA8 - b _0803EBDE - .pool -_0803EAE0: - ldr r3, =gBattleCommunication - movs r0, 0x4 - strb r0, [r3, 0x5] - ldr r2, =gBankAttacker - ldrb r0, [r2] - lsrs r0, 1 - ldr r1, [r7] - adds r0, r1 - adds r6, r0, 0 - adds r6, 0xC6 - ldrb r1, [r6] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - mov r8, r2 - cmp r5, 0 - beq _0803EB28 - movs r0, 0x5 - strb r0, [r3, 0x5] - ldr r2, =gBattlescriptCurrInstr - mov r9, r2 - ldr r6, =gUnknown_082DBD3C - ldr r0, =gFightStateTracker - mov r10, r0 - b _0803EBDE - .pool -_0803EB28: - ldr r3, =gBattleTextBuff1 - movs r4, 0xFD - strb r4, [r3] - movs r0, 0x5 - strb r0, [r3, 0x1] - movs r2, 0x1 - strb r2, [r3, 0x2] - movs r0, 0xFF - strb r0, [r3, 0x3] - ldr r1, =gBattleTextBuff2 - strb r4, [r1] - strb r5, [r1, 0x1] - movs r0, 0xD2 - strb r0, [r1, 0x2] - strb r5, [r1, 0x3] - subs r0, 0xD3 - strb r0, [r1, 0x4] - ldrb r0, [r6] - ands r2, r0 - ldr r1, =gBattlescriptCurrInstr - mov r9, r1 - ldr r6, =gUnknown_082DBD3C - ldr r0, =gFightStateTracker - mov r10, r0 - cmp r2, 0 - bne _0803EB8C - mov r5, r8 - adds r4, r7, 0 - adds r2, r3, 0 -_0803EB62: - ldrb r1, [r5] - lsrs r1, 1 - ldr r0, [r4] - adds r1, r0 - adds r1, 0xC6 - ldrb r0, [r1] - lsrs r0, 1 - strb r0, [r1] - ldrb r0, [r2, 0x2] - adds r0, 0x1 - strb r0, [r2, 0x2] - ldrb r0, [r5] - lsrs r0, 1 - ldr r1, [r4] - adds r0, r1 - adds r0, 0xC6 - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0803EB62 -_0803EB8C: - ldrb r0, [r3, 0x2] - adds r0, 0xE - movs r1, 0 - mov r2, r12 - strb r0, [r2, 0x10] - strb r1, [r2, 0x11] - b _0803EBDE - .pool -_0803EBB0: - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x1 - ands r1, r0 - cmp r1, 0 - beq _0803EBCC - ldr r1, =gBattleCommunication - movs r0, 0x2 - strb r0, [r1, 0x5] - b _0803EBD0 - .pool -_0803EBCC: - ldr r0, =gBattleCommunication - strb r1, [r0, 0x5] -_0803EBD0: - ldr r0, =gBankAttacker - mov r8, r0 - ldr r1, =gBattlescriptCurrInstr - mov r9, r1 - ldr r6, =gUnknown_082DBD3C - ldr r2, =gFightStateTracker - mov r10, r2 -_0803EBDE: - mov r1, r8 - ldrb r0, [r1] - lsrs r0, 1 - ldr r1, [r7] - adds r0, r1 - adds r0, 0xC4 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r6 - ldr r0, [r0] - mov r2, r9 - str r0, [r2] -_0803EBF6: - movs r0, 0xA - mov r1, r10 - strb r0, [r1] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803E90C - - thumb_func_start CanRunFromBattle -CanRunFromBattle: @ 803EC20 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r5, r0, 24 - movs r7, 0 - ldr r1, =gBattleMons - movs r0, 0x58 - muls r0, r5 - adds r1, r0, r1 - ldrh r0, [r1, 0x2E] - cmp r0, 0xAF - bne _0803EC54 - ldr r1, =gEnigmaBerries - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x7] - b _0803EC5E - .pool -_0803EC54: - ldrh r0, [r1, 0x2E] - bl ItemId_GetHoldEffect - lsls r0, 24 - lsrs r1, r0, 24 -_0803EC5E: - ldr r0, =gStringBank - strb r5, [r0] - cmp r1, 0x25 - bne _0803EC9C - ldr r2, =gLastUsedItem - ldr r1, =gBattleMons - movs r0, 0x58 - muls r0, r5 - adds r0, r1 - ldrh r0, [r0, 0x2E] - strh r0, [r2] - ldr r0, =gProtectStructs - lsls r2, r5, 4 - adds r2, r0 - ldrb r1, [r2, 0x1] - movs r0, 0x19 - negs r0, r0 - ands r0, r1 - movs r1, 0x8 - orrs r0, r1 - strb r0, [r2, 0x1] - b _0803ED70 - .pool -_0803EC9C: - ldr r0, =gBattleMons - mov r10, r0 - movs r2, 0x58 - mov r9, r2 - mov r0, r9 - muls r0, r5 - add r0, r10 - mov r8, r0 - adds r0, 0x20 - ldrb r6, [r0] - cmp r6, 0x32 - bne _0803ED5C - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - beq _0803ED38 - ldr r4, =gBattleStruct - ldr r1, [r4] - adds r1, 0x6C - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - bl sub_81A9E28 - lsls r0, 24 - lsrs r1, r0, 24 - mov r2, r8 - ldrh r0, [r2, 0x6] - muls r0, r1 - movs r2, 0x1 - adds r1, r5, 0 - eors r1, r2 - mov r2, r9 - muls r2, r1 - adds r1, r2, 0 - add r1, r10 - ldrh r1, [r1, 0x6] - bl __divsi3 - ldr r1, [r4] - adds r1, 0x6C - ldrb r2, [r1] - lsls r1, r2, 4 - subs r1, r2 - lsls r1, 1 - adds r0, r1 - lsls r0, 24 - lsrs r4, r0, 24 - bl Random - movs r1, 0xFF - ands r1, r0 - cmp r4, r1 - bhi _0803ED0C - b _0803EE12 -_0803ED0C: - ldr r0, =gLastUsedAbility - strb r6, [r0] - ldr r0, =gProtectStructs - lsls r2, r5, 4 - adds r2, r0 - ldrb r1, [r2, 0x1] - movs r0, 0x19 - negs r0, r0 - ands r0, r1 - movs r1, 0x10 - orrs r0, r1 - strb r0, [r2, 0x1] - b _0803ED70 - .pool -_0803ED38: - ldr r0, =gLastUsedAbility - strb r6, [r0] - ldr r0, =gProtectStructs - lsls r2, r5, 4 - adds r2, r0 - ldrb r1, [r2, 0x1] - movs r0, 0x19 - negs r0, r0 - ands r0, r1 - movs r1, 0x10 - orrs r0, r1 - strb r0, [r2, 0x1] - b _0803ED70 - .pool -_0803ED5C: - ldr r1, =gBattleTypeFlags - ldr r2, [r1] - ldr r0, =0x043f0100 - ands r0, r2 - cmp r0, 0 - beq _0803ED80 - movs r0, 0x8 - ands r2, r0 - cmp r2, 0 - beq _0803ED80 -_0803ED70: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - b _0803EE12 - .pool -_0803ED80: - ldr r0, [r1] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - bne _0803EE06 - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - beq _0803EDBC - bl sub_81A9E28 - lsls r0, 24 - lsrs r1, r0, 24 - ldr r4, =gBattleMons - movs r3, 0x58 - adds r0, r5, 0 - muls r0, r3 - adds r0, r4 - ldrh r0, [r0, 0x6] - muls r0, r1 - movs r2, 0x1 - adds r1, r5, 0 - eors r1, r2 - muls r1, r3 - adds r1, r4 - b _0803EDDA - .pool -_0803EDBC: - ldr r3, =gBattleMons - movs r2, 0x58 - adds r0, r5, 0 - muls r0, r2 - adds r4, r0, r3 - movs r1, 0x1 - adds r0, r5, 0 - eors r0, r1 - muls r0, r2 - adds r1, r0, r3 - ldrh r0, [r4, 0x6] - ldrh r2, [r1, 0x6] - cmp r0, r2 - bcs _0803EE00 - lsls r0, 7 -_0803EDDA: - ldrh r1, [r1, 0x6] - bl __divsi3 - ldr r1, =gBattleStruct - ldr r1, [r1] - adds r1, 0x6C - ldrb r2, [r1] - lsls r1, r2, 4 - subs r1, r2 - lsls r1, 1 - adds r0, r1 - lsls r0, 24 - lsrs r4, r0, 24 - bl Random - movs r1, 0xFF - ands r1, r0 - cmp r4, r1 - bls _0803EE06 -_0803EE00: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 -_0803EE06: - ldr r0, =gBattleStruct - ldr r1, [r0] - adds r1, 0x6C - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_0803EE12: - cmp r7, 0 - beq _0803EE24 - ldr r1, =gCurrentMoveTurn - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - strb r0, [r1] - ldr r1, =gBattleOutcome - movs r0, 0x4 - strb r0, [r1] -_0803EE24: - adds r0, r7, 0 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end CanRunFromBattle - - thumb_func_start sub_803EE48 -sub_803EE48: @ 803EE48 - push {r4-r6,lr} - ldr r4, =gBankAttacker - ldr r1, =gTurnOrder - ldr r5, =gCurrentMoveTurn - ldrb r0, [r5] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r4] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ldr r1, =0x02000002 - ands r0, r1 - cmp r0, 0 - beq _0803EF0C - ldr r0, =gNoOfAllBanks - ldrb r1, [r0] - strb r1, [r5] - ldr r2, =gActiveBank - movs r0, 0 - strb r0, [r2] - lsls r1, 24 - cmp r1, 0 - beq _0803EEE0 - adds r4, r2, 0 - ldr r6, =gActionForBanks - ldr r5, =gBattleOutcome -_0803EE7C: - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0803EEBC - ldrb r0, [r4] - adds r0, r6 - ldrb r0, [r0] - cmp r0, 0x3 - bne _0803EECE - ldrb r0, [r5] - movs r1, 0x2 - b _0803EECA - .pool -_0803EEBC: - ldrb r0, [r4] - adds r0, r6 - ldrb r0, [r0] - cmp r0, 0x3 - bne _0803EECE - ldrb r0, [r5] - movs r1, 0x1 -_0803EECA: - orrs r0, r1 - strb r0, [r5] -_0803EECE: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bcc _0803EE7C -_0803EEE0: - ldr r2, =gBattleOutcome - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldr r0, =0x00000ca9 - adds r1, r0 - ldrb r0, [r1] - movs r2, 0x8 - orrs r0, r2 - b _0803EF96 - .pool -_0803EF0C: - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0803EF4C - ldrb r0, [r4] - bl CanRunFromBattle - lsls r0, 24 - cmp r0, 0 - bne _0803EF98 - ldrb r0, [r4] - bl sub_8045868 - ldr r1, =gBattleCommunication - movs r0, 0x3 - strb r0, [r1, 0x5] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAB02 - str r0, [r1] - ldr r1, =gFightStateTracker - movs r0, 0xA - b _0803EF96 - .pool -_0803EF4C: - ldr r1, =gBattleMons - ldrb r2, [r4] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - ldr r1, =0x0400e000 - ands r0, r1 - cmp r0, 0 - beq _0803EF8C - ldr r1, =gBattleCommunication - movs r0, 0x4 - strb r0, [r1, 0x5] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAB02 - str r0, [r1] - ldr r1, =gFightStateTracker - movs r0, 0xA - b _0803EF96 - .pool -_0803EF8C: - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - strb r0, [r5] - ldr r1, =gBattleOutcome - movs r0, 0x6 -_0803EF96: - strb r0, [r1] -_0803EF98: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803EE48 - - thumb_func_start sub_803EFA8 -sub_803EFA8: @ 803EFA8 - ldr r2, =gBankAttacker - ldr r1, =gTurnOrder - ldr r0, =gCurrentMoveTurn - ldrb r0, [r0] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r2] - ldr r0, =gUnknown_02022E14 - movs r1, 0 - strh r1, [r0] - ldr r0, =gUnknown_02022E16 - strh r1, [r0] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DBD58 - ldr r0, [r0] - str r0, [r1] - ldr r1, =gFightStateTracker - movs r0, 0xA - strb r0, [r1] - bx lr - .pool - thumb_func_end sub_803EFA8 - - thumb_func_start bs5_8016AC0 -bs5_8016AC0: @ 803EFF0 - ldr r2, =gBankAttacker - ldr r1, =gTurnOrder - ldr r0, =gCurrentMoveTurn - ldrb r0, [r0] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r2] - ldr r0, =gUnknown_02022E14 - movs r1, 0 - strh r1, [r0] - ldr r0, =gUnknown_02022E16 - strh r1, [r0] - ldr r1, =gNumSafariBalls - ldrb r0, [r1] - subs r0, 0x1 - strb r0, [r1] - ldr r1, =gLastUsedItem - movs r0, 0x5 - strh r0, [r1] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DBD08 - ldr r0, [r0, 0x14] - str r0, [r1] - ldr r1, =gFightStateTracker - movs r0, 0xA - strb r0, [r1] - bx lr - .pool - thumb_func_end bs5_8016AC0 - - thumb_func_start sub_803F050 -sub_803F050: @ 803F050 - push {r4-r6,lr} - ldr r3, =gBankAttacker - ldr r1, =gTurnOrder - ldr r0, =gCurrentMoveTurn - ldrb r0, [r0] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r3] - ldr r0, =gUnknown_02022E14 - movs r1, 0 - strh r1, [r0] - ldr r0, =gUnknown_02022E16 - strh r1, [r0] - ldr r6, =gBattleCommunication - ldr r2, =gBattleBufferB - ldrb r0, [r3] - lsls r0, 9 - adds r1, r2, 0x1 - adds r0, r1 - ldrb r0, [r0] - subs r0, 0x1 - strb r0, [r6, 0x5] - ldr r1, =gLastUsedItem - ldrb r0, [r3] - lsls r0, 9 - adds r2, 0x2 - adds r0, r2 - ldrb r0, [r0] - strh r0, [r1] - ldr r1, =gBattleResults - ldrb r0, [r1, 0x1F] - cmp r0, 0xFE - bhi _0803F096 - adds r0, 0x1 - strb r0, [r1, 0x1F] -_0803F096: - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r1, r0, 0 - adds r1, 0x7A - ldrb r0, [r1] - cmp r0, 0x2 - bhi _0803F0A8 - adds r0, 0x1 - strb r0, [r1] -_0803F0A8: - ldr r0, [r2] - adds r3, r0, 0 - adds r3, 0x7B - ldrb r5, [r3] - adds r4, r5, 0 - cmp r4, 0x1 - bls _0803F100 - ldr r2, =gUnknown_0831BCE0 - adds r0, 0x7A - ldrb r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - ldrb r6, [r6, 0x5] - adds r0, r6 - adds r0, r2 - ldrb r0, [r0] - cmp r4, r0 - bcs _0803F0FC - movs r0, 0x1 - b _0803F0FE - .pool -_0803F0FC: - subs r0, r5, r0 -_0803F0FE: - strb r0, [r3] -_0803F100: - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DBD58 - ldr r0, [r0, 0x8] - str r0, [r1] - ldr r1, =gFightStateTracker - movs r0, 0xA - strb r0, [r1] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803F050 - - thumb_func_start sub_803F120 -sub_803F120: @ 803F120 - push {r4,lr} - ldr r2, =gBankAttacker - ldr r1, =gTurnOrder - ldr r0, =gCurrentMoveTurn - ldrb r0, [r0] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r2] - ldr r0, =gUnknown_02022E14 - movs r4, 0 - strh r4, [r0] - ldr r0, =gUnknown_02022E16 - strh r4, [r0] - ldr r3, =gBattleStruct - ldr r0, [r3] - adds r2, r0, 0 - adds r2, 0x7C - ldr r1, =gUnknown_0831BCEF - adds r0, 0x79 - ldrb r0, [r0] - adds r0, r1 - ldrb r0, [r0] - ldrb r1, [r2] - adds r0, r1 - strb r0, [r2] - ldr r0, [r3] - adds r1, r0, 0 - adds r1, 0x7C - ldrb r0, [r1] - cmp r0, 0x14 - bls _0803F162 - movs r0, 0x14 - strb r0, [r1] -_0803F162: - ldr r0, [r3] - adds r2, r0, 0 - adds r2, 0x7B - ldr r1, =gUnknown_0831BCF3 - adds r0, 0x79 - ldrb r0, [r0] - adds r0, r1 - ldrb r0, [r0] - ldrb r1, [r2] - adds r0, r1 - strb r0, [r2] - ldr r0, [r3] - adds r1, r0, 0 - adds r1, 0x7B - ldrb r0, [r1] - cmp r0, 0x14 - bls _0803F188 - movs r0, 0x14 - strb r0, [r1] -_0803F188: - ldr r0, [r3] - adds r1, r0, 0 - adds r1, 0x79 - ldrb r0, [r1] - cmp r0, 0x2 - bhi _0803F1C4 - adds r0, 0x1 - strb r0, [r1] - ldr r0, =gBattleCommunication - strb r4, [r0, 0x5] - b _0803F1CA - .pool -_0803F1C4: - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] -_0803F1CA: - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DBD58 - ldr r0, [r0, 0x4] - str r0, [r1] - ldr r1, =gFightStateTracker - movs r0, 0xA - strb r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803F120 - - thumb_func_start bs8_exit_by_flight -bs8_exit_by_flight: @ 803F1F0 - push {r4,lr} - ldr r2, =gBankAttacker - ldr r1, =gTurnOrder - ldr r4, =gCurrentMoveTurn - ldrb r0, [r4] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r2] - movs r0, 0x11 - bl PlaySE - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - strb r0, [r4] - ldr r1, =gBattleOutcome - movs r0, 0x4 - strb r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end bs8_exit_by_flight - - thumb_func_start bs9_8016C9C -bs9_8016C9C: @ 803F22C - ldr r3, =gBankAttacker - ldr r1, =gTurnOrder - ldr r0, =gCurrentMoveTurn - ldrb r0, [r0] - adds r0, r1 - ldrb r2, [r0] - strb r2, [r3] - ldr r0, =gUnknown_02022E14 - movs r1, 0 - strh r1, [r0] - ldr r0, =gUnknown_02022E16 - strh r1, [r0] - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x7 - strb r0, [r1, 0x1] - strb r2, [r1, 0x2] - ldr r2, =gBattlePartyID - ldrb r0, [r3] - lsls r0, 1 - adds r0, r2 - ldrh r0, [r0] - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DBD58 - ldr r0, [r0, 0xC] - str r0, [r1] - ldr r1, =gFightStateTracker - movs r0, 0xA - strb r0, [r1] - ldr r1, =gUnknown_0202407A - movs r0, 0xC - strb r0, [r1, 0x1] - bx lr - .pool - thumb_func_end bs9_8016C9C - - thumb_func_start bsB_exit_by_move -bsB_exit_by_move: @ 803F2A4 - push {lr} - bl sub_8041728 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _0803F2C0 - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x4D - strb r1, [r0] - ldr r1, =gFightStateTracker - movs r0, 0xC - strb r0, [r1] -_0803F2C0: - pop {r0} - bx r0 - .pool - thumb_func_end bsB_exit_by_move - - thumb_func_start bsD_proceed -bsD_proceed: @ 803F2CC - ldr r1, =gCurrentMoveTurn - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r3, =gFightStateTracker - ldr r2, =gUnknown_0202407A - ldrb r0, [r1] - adds r0, r2 - ldrb r0, [r0] - strb r0, [r3] - ldr r2, =gHitMarker - ldr r0, [r2] - ldr r1, =0xf1e892af - ands r0, r1 - str r0, [r2] - bx lr - .pool - thumb_func_end bsD_proceed - - thumb_func_start bsC_8016D70 -bsC_8016D70: @ 803F300 - push {r4-r6,lr} - ldr r1, =gTurnOrder - ldr r2, =gCurrentMoveTurn - ldrb r0, [r2] - adds r0, r1 - ldrb r0, [r0] - ldr r6, =gBattleStruct - ldr r1, [r6] - adds r0, r1 - adds r0, 0x5C - movs r1, 0x6 - strb r1, [r0] - ldrb r0, [r2] - adds r0, 0x1 - strb r0, [r2] - ldr r3, =gFightStateTracker - ldr r1, =gUnknown_0202407A - ldrb r0, [r2] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r3] - bl sub_803D6A0 - ldr r2, =gHitMarker - ldr r0, [r2] - ldr r1, =0xf1e892af - ands r0, r1 - str r0, [r2] - ldr r0, =gCurrentMove - movs r1, 0 - strh r1, [r0] - ldr r0, =gBattleMoveDamage - movs r4, 0 - str r4, [r0] - ldr r0, =gBattleMoveFlags - strb r1, [r0] - ldr r5, =gBattleScripting - strb r1, [r5, 0x18] - strb r1, [r5, 0x19] - ldr r2, =gUnknown_02024250 - ldr r3, =gBankAttacker - ldrb r0, [r3] - lsls r0, 1 - adds r0, r2 - strh r4, [r0] - ldr r2, =gUnknown_02024258 - ldrb r0, [r3] - lsls r0, 1 - adds r0, r2 - strh r4, [r0] - ldr r0, [r6] - strb r1, [r0, 0x13] - ldr r0, =gDynamicBasePower - strh r4, [r0] - strb r1, [r5, 0x14] - ldr r0, =gBattleCommunication - strb r1, [r0, 0x3] - strb r1, [r0, 0x4] - strb r1, [r5, 0x16] - ldr r0, =gBattleResources - ldr r0, [r0] - ldr r0, [r0, 0x8] - adds r0, 0x20 - strb r1, [r0] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end bsC_8016D70 - - thumb_func_start GetBattleBank -GetBattleBank: @ 803F3CC - push {lr} - lsls r0, 24 - lsrs r1, r0, 24 - movs r0, 0 - cmp r1, 0xE - bhi _0803F47A - lsls r0, r1, 2 - ldr r1, =_0803F3E8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0803F3E8: - .4byte _0803F424 - .4byte _0803F430 - .4byte _0803F43C - .4byte _0803F458 - .4byte _0803F464 - .4byte _0803F458 - .4byte _0803F464 - .4byte _0803F448 - .4byte _0803F464 - .4byte _0803F464 - .4byte _0803F44C - .4byte _0803F464 - .4byte _0803F468 - .4byte _0803F46C - .4byte _0803F470 -_0803F424: - ldr r0, =gBankTarget - ldrb r0, [r0] - b _0803F47A - .pool -_0803F430: - ldr r0, =gBankAttacker - ldrb r0, [r0] - b _0803F47A - .pool -_0803F43C: - ldr r0, =gEffectBank - ldrb r0, [r0] - b _0803F47A - .pool -_0803F448: - movs r0, 0 - b _0803F47A -_0803F44C: - ldr r0, =gBattleScripting - ldrb r0, [r0, 0x17] - b _0803F47A - .pool -_0803F458: - ldr r0, =gBank1 - ldrb r0, [r0] - b _0803F47A - .pool -_0803F464: - movs r0, 0 - b _0803F472 -_0803F468: - movs r0, 0x1 - b _0803F472 -_0803F46C: - movs r0, 0x2 - b _0803F472 -_0803F470: - movs r0, 0x3 -_0803F472: - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 -_0803F47A: - pop {r1} - bx r1 - thumb_func_end GetBattleBank - - thumb_func_start PressurePPLose -PressurePPLose: @ 803F480 - push {r4-r7,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r5, r1, 24 - lsls r2, 16 - lsrs r2, 16 - ldr r1, =gBattleMons - movs r4, 0x58 - muls r0, r4 - adds r0, r1 - adds r0, 0x20 - ldrb r0, [r0] - mov r12, r1 - cmp r0, 0x2E - bne _0803F532 - movs r3, 0 - adds r0, r5, 0 - muls r0, r4 - adds r1, 0xC - adds r1, r0, r1 - b _0803F4BC - .pool -_0803F4B4: - adds r1, 0x2 - adds r3, 0x1 - cmp r3, 0x3 - bgt _0803F4C2 -_0803F4BC: - ldrh r0, [r1] - cmp r0, r2 - bne _0803F4B4 -_0803F4C2: - cmp r3, 0x4 - beq _0803F532 - movs r7, 0x58 - adds r2, r5, 0 - muls r2, r7 - adds r0, r3, r2 - mov r6, r12 - adds r6, 0x24 - adds r1, r0, r6 - ldrb r0, [r1] - cmp r0, 0 - beq _0803F4DE - subs r0, 0x1 - strb r0, [r1] -_0803F4DE: - mov r0, r12 - adds r0, 0x50 - adds r0, r2, r0 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 14 - ands r0, r1 - cmp r0, 0 - bne _0803F532 - ldr r1, =gDisableStructs - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x18] - lsrs r1, 4 - ldr r2, =gBitTable - lsls r0, r3, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _0803F532 - ldr r4, =gActiveBank - strb r5, [r4] - adds r1, r3, 0 - adds r1, 0x9 - lsls r1, 24 - lsrs r1, 24 - ldrb r0, [r4] - muls r0, r7 - adds r0, r6 - adds r0, r3 - str r0, [sp] - movs r0, 0 - movs r2, 0 - movs r3, 0x1 - bl EmitSetMonData - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0803F532: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end PressurePPLose - - thumb_func_start PressurePPLoseOnUsingImprision -PressurePPLoseOnUsingImprision: @ 803F548 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r5, r0, 24 - movs r0, 0x4 - mov r8, r0 - adds r0, r5, 0 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - movs r4, 0 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - bge _0803F5F0 - ldr r1, =gBattleMons - movs r0, 0x58 - adds r7, r5, 0 - muls r7, r0 - adds r1, 0xC - mov r10, r1 -_0803F57E: - lsls r0, r4, 24 - lsrs r0, 24 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - adds r6, r4, 0x1 - cmp r9, r0 - beq _0803F5E6 - ldr r0, =gBattleMons - movs r3, 0x58 - adds r1, r4, 0 - muls r1, r3 - adds r1, r0 - adds r1, 0x20 - ldrb r1, [r1] - adds r4, r0, 0 - cmp r1, 0x2E - bne _0803F5E6 - movs r2, 0 - adds r0, r5, 0 - muls r0, r3 - adds r1, r4, 0 - adds r1, 0xC - adds r0, r1 - ldrh r0, [r0] - movs r1, 0x8F - lsls r1, 1 - cmp r0, r1 - beq _0803F5CE - adds r3, r1, 0 - mov r0, r10 - adds r1, r7, r0 -_0803F5C0: - adds r1, 0x2 - adds r2, 0x1 - cmp r2, 0x3 - bgt _0803F5CE - ldrh r0, [r1] - cmp r0, r3 - bne _0803F5C0 -_0803F5CE: - cmp r2, 0x4 - beq _0803F5E6 - mov r8, r2 - adds r1, r2, r7 - adds r0, r4, 0 - adds r0, 0x24 - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0 - beq _0803F5E6 - subs r0, 0x1 - strb r0, [r1] -_0803F5E6: - adds r4, r6, 0 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _0803F57E -_0803F5F0: - mov r1, r8 - cmp r1, 0x4 - beq _0803F658 - ldr r6, =gBattleMons - movs r3, 0x58 - adds r0, r5, 0 - muls r0, r3 - adds r1, r6, 0 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 14 - ands r0, r1 - cmp r0, 0 - bne _0803F658 - ldr r1, =gDisableStructs - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x18] - lsrs r1, 4 - ldr r2, =gBitTable - mov r4, r8 - lsls r0, r4, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _0803F658 - ldr r4, =gActiveBank - strb r5, [r4] - mov r1, r8 - adds r1, 0x9 - lsls r1, 24 - lsrs r1, 24 - ldrb r0, [r4] - muls r0, r3 - adds r2, r6, 0 - adds r2, 0x24 - adds r0, r2 - add r0, r8 - str r0, [sp] - movs r0, 0 - movs r2, 0 - movs r3, 0x1 - bl EmitSetMonData - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0803F658: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end PressurePPLoseOnUsingImprision - - thumb_func_start PressurePPLoseOnUsingPerishSong -PressurePPLoseOnUsingPerishSong: @ 803F67C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r3, r0, 24 - movs r6, 0x4 - movs r1, 0 - ldr r0, =gNoOfAllBanks - mov r8, r0 - ldrb r0, [r0] - cmp r1, r0 - bge _0803F6FE - ldr r7, =gBattleMons - movs r2, 0x58 - mov r12, r2 - mov r5, r12 - muls r5, r3 - adds r0, r7, 0 - adds r0, 0xC - adds r2, r5, r0 - mov r10, r2 - mov r9, r5 -_0803F6AE: - mov r0, r12 - muls r0, r1 - adds r0, r7 - adds r0, 0x20 - ldrb r0, [r0] - adds r4, r1, 0x1 - cmp r0, 0x2E - bne _0803F6F4 - cmp r1, r3 - beq _0803F6F4 - movs r2, 0 - mov r1, r10 - ldrh r0, [r1] - cmp r0, 0xC3 - beq _0803F6DE - ldr r1, =gBattleMons + 0xC - add r1, r9 -_0803F6D0: - adds r1, 0x2 - adds r2, 0x1 - cmp r2, 0x3 - bgt _0803F6DE - ldrh r0, [r1] - cmp r0, 0xC3 - bne _0803F6D0 -_0803F6DE: - cmp r2, 0x4 - beq _0803F6F4 - adds r6, r2, 0 - adds r0, r6, r5 - ldr r2, =gBattleMons + 0x24 - adds r1, r0, r2 - ldrb r0, [r1] - cmp r0, 0 - beq _0803F6F4 - subs r0, 0x1 - strb r0, [r1] -_0803F6F4: - adds r1, r4, 0 - mov r0, r8 - ldrb r0, [r0] - cmp r1, r0 - blt _0803F6AE -_0803F6FE: - cmp r6, 0x4 - beq _0803F762 - ldr r7, =gBattleMons - movs r5, 0x58 - adds r0, r3, 0 - muls r0, r5 - adds r1, r7, 0 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 14 - ands r0, r1 - cmp r0, 0 - bne _0803F762 - ldr r1, =gDisableStructs - lsls r0, r3, 3 - subs r0, r3 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x18] - lsrs r1, 4 - ldr r2, =gBitTable - lsls r0, r6, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _0803F762 - ldr r4, =gActiveBank - strb r3, [r4] - adds r1, r6, 0 - adds r1, 0x9 - lsls r1, 24 - lsrs r1, 24 - ldrb r0, [r4] - muls r0, r5 - adds r2, r7, 0 - adds r2, 0x24 - adds r0, r2 - adds r0, r6 - str r0, [sp] - movs r0, 0 - movs r2, 0 - movs r3, 0x1 - bl EmitSetMonData - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0803F762: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end PressurePPLoseOnUsingPerishSong - - thumb_func_start sub_803F790 -sub_803F790: @ 803F790 - push {r4,r5,lr} - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0803F7D0 - movs r2, 0 - ldr r4, =gNoOfAllBanks - ldrb r0, [r4] - cmp r2, r0 - bge _0803F7EE - ldr r3, =gBattleExecBuffer - ldr r5, =gBitTable -_0803F7AC: - ldm r5!, {r1} - lsls r1, 28 - ldr r0, [r3] - orrs r0, r1 - str r0, [r3] - adds r2, 0x1 - ldrb r0, [r4] - cmp r2, r0 - blt _0803F7AC - b _0803F7EE - .pool -_0803F7D0: - movs r2, 0 - ldr r4, =gNoOfAllBanks - ldrb r0, [r4] - cmp r2, r0 - bge _0803F7EE - ldr r3, =gBattleExecBuffer - ldr r5, =gBitTable -_0803F7DE: - ldr r0, [r3] - ldm r5!, {r1} - orrs r0, r1 - str r0, [r3] - adds r2, 0x1 - ldrb r0, [r4] - cmp r2, r0 - blt _0803F7DE -_0803F7EE: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803F790 - - thumb_func_start MarkBufferBankForExecution -MarkBufferBankForExecution: @ 803F800 - push {lr} - lsls r0, 24 - lsrs r3, r0, 24 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0803F834 - ldr r2, =gBattleExecBuffer - ldr r1, =gBitTable - lsls r0, r3, 2 - adds r0, r1 - ldr r1, [r0] - lsls r1, 28 - ldr r0, [r2] - orrs r0, r1 - str r0, [r2] - b _0803F844 - .pool -_0803F834: - ldr r2, =gBattleExecBuffer - ldr r1, =gBitTable - lsls r0, r3, 2 - adds r0, r1 - ldr r1, [r2] - ldr r0, [r0] - orrs r1, r0 - str r1, [r2] -_0803F844: - pop {r0} - bx r0 - .pool - thumb_func_end MarkBufferBankForExecution - - thumb_func_start sub_803F850 -sub_803F850: @ 803F850 - push {r4-r7,lr} - lsls r0, 24 - lsrs r7, r0, 24 - movs r4, 0 - ldr r5, =gBattleExecBuffer - ldr r1, =gBitTable - lsls r0, r7, 2 - adds r6, r0, r1 - b _0803F87A - .pool -_0803F86C: - lsls r0, r4, 2 - ldr r1, [r6] - lsls r1, r0 - ldr r0, [r5] - orrs r0, r1 - str r0, [r5] - adds r4, 0x1 -_0803F87A: - bl sub_8009FCC - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - blt _0803F86C - ldr r2, =gBattleExecBuffer - movs r1, 0x80 - lsls r1, 21 - lsls r1, r7 - ldr r0, [r2] - bics r0, r1 - str r0, [r2] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803F850 - - thumb_func_start CancelMultiTurnMoves -CancelMultiTurnMoves: @ 803F8A0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleMons - movs r2, 0x58 - adds r3, r0, 0 - muls r3, r2 - adds r1, 0x50 - adds r3, r1 - ldr r1, [r3] - ldr r2, =0xffffefff - ands r1, r2 - ldr r2, =0xfffff3ff - ands r1, r2 - movs r2, 0x71 - negs r2, r2 - ands r1, r2 - ldr r2, =0xfffffcff - ands r1, r2 - str r1, [r3] - ldr r1, =gStatuses3 - lsls r2, r0, 2 - adds r2, r1 - ldr r1, [r2] - ldr r3, =0xfffbff3f - ands r1, r3 - str r1, [r2] - ldr r2, =gDisableStructs - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r2, [r1, 0x11] - movs r0, 0x10 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x11] - movs r0, 0 - strb r0, [r1, 0x10] - bx lr - .pool - thumb_func_end CancelMultiTurnMoves - - thumb_func_start HasMoveFailed -HasMoveFailed: @ 803F90C - push {lr} - lsls r0, 24 - ldr r1, =gProtectStructs - lsrs r0, 20 - adds r1, r0, r1 - ldrb r0, [r1] - lsrs r0, 7 - cmp r0, 0 - bne _0803F952 - ldrb r2, [r1, 0x1] - lsls r0, r2, 30 - cmp r0, 0 - blt _0803F952 - lsls r0, r2, 26 - cmp r0, 0 - blt _0803F952 - lsls r0, r2, 25 - cmp r0, 0 - blt _0803F952 - lsrs r0, r2, 7 - cmp r0, 0 - bne _0803F952 - ldrb r1, [r1, 0x2] - lsls r0, r1, 31 - cmp r0, 0 - bne _0803F952 - lsls r0, r1, 30 - cmp r0, 0 - blt _0803F952 - lsls r0, r1, 29 - cmp r0, 0 - blt _0803F952 - lsls r0, r2, 31 - cmp r0, 0 - beq _0803F95C -_0803F952: - movs r0, 0x1 - b _0803F95E - .pool -_0803F95C: - movs r0, 0 -_0803F95E: - pop {r1} - bx r1 - thumb_func_end HasMoveFailed - - thumb_func_start PrepareStringBattle -PrepareStringBattle: @ 803F964 - push {r4,lr} - adds r2, r0, 0 - lsls r2, 16 - lsrs r2, 16 - ldr r4, =gActiveBank - strb r1, [r4] - movs r0, 0 - adds r1, r2, 0 - bl dp01_build_cmdbuf_x10_TODO - ldrb r0, [r4] - bl MarkBufferBankForExecution - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end PrepareStringBattle - - thumb_func_start ResetSentPokesToOpponentValue -ResetSentPokesToOpponentValue: @ 803F988 - push {r4-r6,lr} - movs r3, 0 - ldr r0, =gSentPokesToOpponent - strb r3, [r0] - strb r3, [r0, 0x1] - movs r1, 0 - ldr r0, =gNoOfAllBanks - ldrb r2, [r0] - adds r6, r0, 0 - cmp r1, r2 - bge _0803F9B6 - ldr r5, =gBitTable - adds r4, r2, 0 - ldr r2, =gBattlePartyID -_0803F9A4: - ldrh r0, [r2] - lsls r0, 2 - adds r0, r5 - ldr r0, [r0] - orrs r3, r0 - adds r2, 0x4 - adds r1, 0x2 - cmp r1, r4 - blt _0803F9A4 -_0803F9B6: - movs r1, 0x1 - adds r2, r6, 0 - ldrb r0, [r2] - cmp r1, r0 - bge _0803F9D6 - ldr r5, =gSentPokesToOpponent - movs r4, 0x2 -_0803F9C4: - adds r0, r1, 0 - ands r0, r4 - asrs r0, 1 - adds r0, r5 - strb r3, [r0] - adds r1, 0x2 - ldrb r0, [r2] - cmp r1, r0 - blt _0803F9C4 -_0803F9D6: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end ResetSentPokesToOpponentValue - - thumb_func_start sub_803F9EC -sub_803F9EC: @ 803F9EC - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 - adds r0, r5, 0 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0803FA50 - movs r0, 0x2 - ands r0, r5 - lsls r0, 24 - lsrs r0, 25 - mov r12, r0 - ldr r1, =gSentPokesToOpponent - adds r0, r1 - strb r4, [r0] - adds r5, r4, 0 - ldr r0, =gNoOfAllBanks - ldrb r2, [r0] - mov r8, r1 - cmp r4, r2 - bge _0803FA4A - ldr r0, =gAbsentBankFlags - ldrb r7, [r0] - ldr r1, =gBitTable - adds r6, r2, 0 - ldr r3, =gBattlePartyID - adds r2, r1, 0 -_0803FA2E: - ldr r0, [r2] - ands r0, r7 - cmp r0, 0 - bne _0803FA40 - ldrh r0, [r3] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - orrs r4, r0 -_0803FA40: - adds r3, 0x4 - adds r2, 0x8 - adds r5, 0x2 - cmp r5, r6 - blt _0803FA2E -_0803FA4A: - mov r0, r12 - add r0, r8 - strb r4, [r0] -_0803FA50: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803F9EC - - thumb_func_start sub_803FA70 -sub_803FA70: @ 803FA70 - push {r4-r7,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0803FA8C - adds r0, r4, 0 - bl sub_803F9EC - b _0803FAC2 -_0803FA8C: - movs r3, 0x1 - ldr r5, =gNoOfAllBanks - ldrb r0, [r5] - cmp r3, r0 - bge _0803FAC2 - ldr r0, =gSentPokesToOpponent - mov r12, r0 - movs r7, 0x2 - ldr r6, =gBitTable - ldr r1, =gBattlePartyID - lsls r0, r4, 1 - adds r4, r0, r1 -_0803FAA4: - adds r2, r3, 0 - ands r2, r7 - asrs r2, 1 - add r2, r12 - ldrh r0, [r4] - lsls r0, 2 - adds r0, r6 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - adds r3, 0x1 - ldrb r0, [r5] - cmp r3, r0 - blt _0803FAA4 -_0803FAC2: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803FA70 - - .align 2, 0 @ Don't pad with nop. - \ No newline at end of file diff --git a/asm/battle_5.s b/asm/battle_5.s index bb5b406e5..4d02a5942 100644 --- a/asm/battle_5.s +++ b/asm/battle_5.s @@ -6,8 +6,8 @@ .text - thumb_func_start sub_8056F28 -sub_8056F28: @ 8056F28 + thumb_func_start AllocateBattleResrouces +AllocateBattleResrouces: @ 8056F28 push {r4-r6,lr} ldr r5, =gBattleResources ldr r6, =gBattleTypeFlags @@ -102,10 +102,10 @@ _08056FFA: pop {r0} bx r0 .pool - thumb_func_end sub_8056F28 + thumb_func_end AllocateBattleResrouces - thumb_func_start sub_8057028 -sub_8057028: @ 8057028 + thumb_func_start FreeBattleResources +FreeBattleResources: @ 8057028 push {r4-r6,lr} ldr r0, =gBattleTypeFlags ldr r0, [r0] @@ -181,7 +181,7 @@ _080570D0: pop {r0} bx r0 .pool - thumb_func_end sub_8057028 + thumb_func_end FreeBattleResources thumb_func_start AdjustFriendshipOnBattleFaint AdjustFriendshipOnBattleFaint: @ 80570F4 diff --git a/asm/battle_7.s b/asm/battle_7.s index bfb5f82dc..7aea39cff 100644 --- a/asm/battle_7.s +++ b/asm/battle_7.s @@ -5,10 +5,10 @@ .text - thumb_func_start dp11_init -dp11_init: @ 805D118 + thumb_func_start AllocateBattleSpritesData +AllocateBattleSpritesData: @ 805D118 push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr movs r0, 0x10 bl AllocZeroed str r0, [r4] @@ -32,12 +32,12 @@ dp11_init: @ 805D118 pop {r0} bx r0 .pool - thumb_func_end dp11_init + thumb_func_end AllocateBattleSpritesData - thumb_func_start dp11_free -dp11_free: @ 805D158 + thumb_func_start FreeBattleSpritesData +FreeBattleSpritesData: @ 805D158 push {r4,r5,lr} - ldr r5, =gUnknown_020244D0 + ldr r5, =gBattleSpritesDataPtr ldr r0, [r5] cmp r0, 0 beq _0805D192 @@ -65,7 +65,7 @@ _0805D192: pop {r0} bx r0 .pool - thumb_func_end dp11_free + thumb_func_end FreeBattleSpritesData thumb_func_start sub_805D19C sub_805D19C: @ 805D19C @@ -839,7 +839,7 @@ move_anim_start_t2_for_situation: @ 805D808 push {r4-r6,lr} adds r4, r1, 0 lsls r0, 24 - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r1, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -1001,7 +1001,7 @@ move_anim_start_t3: @ 805D908 b _0805DA1E .pool _0805D950: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr mov r9, r0 ldr r0, [r0] ldr r0, [r0] @@ -1063,7 +1063,7 @@ _0805D9CC: mov r1, sp ldrb r1, [r1] strb r1, [r0] - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r0, [r0, 0x8] strh r7, [r0] @@ -1119,7 +1119,7 @@ task0A_0803415C: @ 805DA48 ldrb r0, [r0] cmp r0, 0 bne _0805DA8A - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r1, =gTasks lsls r0, r4, 2 @@ -1199,7 +1199,7 @@ move_anim_start_t4: @ 805DAC4 lsls r1, 3 adds r1, r2 strh r4, [r1, 0x8] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] movs r2, 0x8 ldrsh r1, [r1, r2] @@ -1230,7 +1230,7 @@ task0A_08034248: @ 805DB34 ldrb r0, [r0] cmp r0, 0 bne _0805DB76 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r1, =gTasks lsls r0, r4, 2 @@ -1274,7 +1274,7 @@ mplay_80342A4: @ 805DB90 lsls r0, 24 cmp r0, 0 beq _0805DBD8 - ldr r2, =gUnknown_020244D0 + ldr r2, =gBattleSpritesDataPtr ldr r0, [r2] ldr r1, [r0, 0x4] lsls r0, r4, 1 @@ -1307,7 +1307,7 @@ _0805DBDC: b _0805DC02 .pool _0805DBF0: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x4] lsls r0, r4, 1 @@ -1338,7 +1338,7 @@ sub_805DC0C: @ 805DC0C movs r1, 0 bl GetMonData str r0, [sp] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] mov r2, r8 @@ -1371,7 +1371,7 @@ _0805DC58: lsls r2, r5, 3 ldr r1, =gMonFrontPicTable adds r2, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] lsrs r0, 22 adds r1, 0x4 @@ -1386,7 +1386,7 @@ _0805DC58: movs r0, 0x80 lsls r0, 1 adds r7, r2, r0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] lsls r1, r3, 2 @@ -1444,7 +1444,7 @@ _0805DCC6: movs r2, 0x20 bl LoadPalette _0805DD1A: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] ldr r1, [sp, 0x4] @@ -1491,7 +1491,7 @@ sub_805DD7C: @ 805DD7C movs r1, 0 bl GetMonData str r0, [sp] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] mov r2, r8 @@ -1532,7 +1532,7 @@ _0805DDC8: mov r10, r1 cmp r0, 0x1 beq _0805DE00 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] add r0, r10 @@ -1543,7 +1543,7 @@ _0805DE00: lsls r0, r5, 3 ldr r1, =gMonBackPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] lsls r2, r7, 2 adds r1, 0x4 @@ -1558,7 +1558,7 @@ _0805DE2C: lsls r0, r5, 3 ldr r1, =gMonBackPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] lsls r2, r7, 2 adds r1, 0x4 @@ -1573,7 +1573,7 @@ _0805DE46: movs r0, 0x80 lsls r0, 1 adds r7, r1, r0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] add r0, r10 @@ -1629,7 +1629,7 @@ _0805DE7E: movs r2, 0x20 bl LoadPalette _0805DED2: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] add r0, r10 @@ -1684,7 +1684,7 @@ sub_805DF38: @ 805DF38 lsls r4, 3 ldr r2, =gTrainerFrontPicTable adds r2, r4, r2 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] lsrs r0, 22 adds r1, 0x4 @@ -1718,7 +1718,7 @@ sub_805DF84: @ 805DF84 lsls r5, 3 ldr r2, =gTrainerBackPicTable adds r2, r5, r2 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] lsrs r0, 22 adds r1, 0x4 @@ -1959,7 +1959,7 @@ _0805E1AE: load_gfxc_health_bar: @ 805E1B8 push {lr} ldr r0, =gUnknown_08C093F0 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] movs r2, 0xBA lsls r2, 1 @@ -1971,8 +1971,8 @@ load_gfxc_health_bar: @ 805E1B8 .pool thumb_func_end load_gfxc_health_bar - thumb_func_start battle_load_something -battle_load_something: @ 805E1D8 + thumb_func_start BattleInitAllSprites +BattleInitAllSprites: @ 805E1D8 push {r4-r6,lr} adds r5, r0, 0 adds r4, r1, 0 @@ -2136,12 +2136,12 @@ _0805E346: pop {r4-r6} pop {r1} bx r1 - thumb_func_end battle_load_something + thumb_func_end BattleInitAllSprites thumb_func_start sub_805E350 sub_805E350: @ 805E350 push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r0, [r0, 0x4] movs r1, 0 @@ -2162,7 +2162,7 @@ sub_805E350: @ 805E350 sub_805E378: @ 805E378 push {lr} bl sub_805E350 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] movs r1, 0 @@ -2191,7 +2191,7 @@ sub_805E394: @ 805E394 movs r0, 0x2 negs r0, r0 mov r8, r0 - ldr r7, =gUnknown_020244D0 + ldr r7, =gBattleSpritesDataPtr ldr r6, =gBankSpriteIds _0805E3B8: ldr r0, [r7] @@ -2233,7 +2233,7 @@ _0805E3EA: sub_805E408: @ 805E408 lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_020244D0 + ldr r1, =gBattleSpritesDataPtr ldr r1, [r1] ldr r1, [r1] lsls r3, r0, 2 @@ -2285,7 +2285,7 @@ sub_805E448: @ 805E448 ldr r1, =gSprites mov r8, r1 add r0, r8 - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r1, [r4] ldr r1, [r1, 0x8] ldrb r1, [r1] @@ -2364,7 +2364,7 @@ _0805E51C: lsls r0, r1, 3 ldr r1, =gMonBackPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] ldr r1, [r1, 0x4] ldr r3, [r2, 0x10] @@ -2434,7 +2434,7 @@ _0805E59C: lsls r0, r1, 3 ldr r1, =gMonBackPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] mov r3, r10 lsls r2, r3, 2 @@ -2472,7 +2472,7 @@ _0805E618: lsls r0, r1, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] mov r3, r10 lsls r2, r3, 2 @@ -2486,7 +2486,7 @@ _0805E618: mov r2, r8 bl HandleLoadSpecialPokePic_DontHandleDeoxys _0805E662: - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r0, [r0] mov r2, r10 lsls r1, r2, 2 @@ -2582,7 +2582,7 @@ _0805E70A: lsls r0, 24 cmp r0, 0 bne _0805E74A - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r7, 2 @@ -2666,7 +2666,7 @@ _0805E814: beq _0805E83C ldr r0, =gUnknown_08C2CEE0 _0805E822: - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] lsls r4, 2 adds r1, 0x4 @@ -2677,7 +2677,7 @@ _0805E822: .pool _0805E83C: ldr r0, =gUnknown_08C2D120 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] lsls r4, 2 adds r1, 0x4 @@ -2688,7 +2688,7 @@ _0805E84E: movs r3, 0x1 lsls r6, r5, 4 ldr r7, =gUnknown_08C2CEBC - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r0, [r0] adds r0, 0x4 adds r4, r0, r4 @@ -2804,7 +2804,7 @@ sub_805E94C: @ 805E94C lsrs r1, 16 cmp r1, 0xA4 bne _0805E96C - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] lsls r1, r2, 2 @@ -2822,7 +2822,7 @@ _0805E96C: thumb_func_start sub_805E974 sub_805E974: @ 805E974 lsls r0, 24 - ldr r1, =gUnknown_020244D0 + ldr r1, =gBattleSpritesDataPtr ldr r1, [r1] ldr r1, [r1] lsrs r0, 22 @@ -2862,7 +2862,7 @@ sub_805E990: @ 805E990 lsrs r0, 24 cmp r0, 0x1 bne _0805EA08 - ldr r7, =gUnknown_020244D0 + ldr r7, =gBattleSpritesDataPtr ldr r0, [r7] ldr r2, [r0] lsls r4, r6, 2 @@ -2895,7 +2895,7 @@ _0805E9F6: b _0805EA5A .pool _0805EA08: - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r0, [r0] lsls r1, r6, 2 @@ -2944,7 +2944,7 @@ BattleMusicStop: @ 805EA60 bl GetBankByIdentity lsls r0, 24 lsrs r4, r0, 24 - ldr r5, =gUnknown_020244D0 + ldr r5, =gBattleSpritesDataPtr ldr r0, [r5] ldr r0, [r0] lsls r1, r4, 2 @@ -3134,7 +3134,7 @@ _0805EBC8: mov r7, r8 cmp r7, 0 bne _0805EC3C - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r2, [r0, 0x4] adds r2, r6, r2 @@ -3164,7 +3164,7 @@ _0805EC3C: adds r2, r0 lsls r2, 2 adds r2, r4 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x4] adds r0, r6, r0 @@ -3229,7 +3229,7 @@ sub_805EC84: @ 805EC84 adds r1, r4, 0 movs r3, 0xC8 bl CreateSprite - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r1, [r6] ldr r2, [r1, 0x4] lsls r1, r5, 1 @@ -3351,12 +3351,12 @@ _0805EDC0: _0805EDD2: movs r0, 0x1 mov r8, r0 - ldr r2, =gUnknown_020244D0 + ldr r2, =gBattleSpritesDataPtr lsls r4, 2 b _0805EE06 .pool _0805EDE4: - ldr r2, =gUnknown_020244D0 + ldr r2, =gBattleSpritesDataPtr ldr r0, [r2] ldr r0, [r0] lsls r1, r4, 2 @@ -3431,7 +3431,7 @@ sub_805EE54: @ 805EE54 lsls r0, 24 cmp r0, 0 beq _0805EED0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r3, [r0] ldr r1, [r3] lsls r0, r4, 2 @@ -3489,7 +3489,7 @@ sub_805EEE0: @ 805EEE0 lsls r0, 24 lsrs r0, 24 ldr r2, =gSprites - ldr r1, =gUnknown_020244D0 + ldr r1, =gBattleSpritesDataPtr ldr r1, [r1] ldr r3, [r1, 0x4] lsls r1, r0, 1 @@ -3578,7 +3578,7 @@ sub_805EF84: @ 805EF84 lsls r0, 24 lsrs r4, r0, 24 lsls r1, 24 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r2, [r0] lsls r0, r4, 2 @@ -3600,15 +3600,15 @@ _0805EFAC: .pool thumb_func_end sub_805EF84 - thumb_func_start init_uns_table_pokemon_copy -init_uns_table_pokemon_copy: @ 805EFBC + thumb_func_start AllocateMonSpritesGfx +AllocateMonSpritesGfx: @ 805EFBC push {r4-r7,lr} mov r7, r10 mov r6, r9 mov r5, r8 push {r5-r7} movs r6, 0 - ldr r4, =gBattleSpritesGfx + ldr r4, =gMonSpritesGfxPtr str r6, [r4] movs r0, 0xC0 lsls r0, 1 @@ -3620,7 +3620,7 @@ init_uns_table_pokemon_copy: @ 805EFBC ldr r1, [r4] str r0, [r1] _0805EFE2: - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r1, [r0] lsls r4, r6, 2 adds r2, r1, 0x4 @@ -3649,7 +3649,7 @@ _0805EFE2: mov r12, r8 adds r7, r4, 0 _0805F01A: - ldr r2, =gBattleSpritesGfx + ldr r2, =gMonSpritesGfxPtr ldr r1, [r2] lsls r4, r5, 3 add r4, r12 @@ -3672,7 +3672,7 @@ _0805F01A: lsrs r5, r0, 24 cmp r5, 0x3 bls _0805F01A - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r2, [r1] mov r5, r9 adds r0, r5, r6 @@ -3692,7 +3692,7 @@ _0805F01A: movs r0, 0x80 lsls r0, 5 bl AllocZeroed - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] movs r2, 0xBA lsls r2, 1 @@ -3706,12 +3706,12 @@ _0805F01A: pop {r0} bx r0 .pool - thumb_func_end init_uns_table_pokemon_copy + thumb_func_end AllocateMonSpritesGfx - thumb_func_start sub_805F094 -sub_805F094: @ 805F094 + thumb_func_start FreeMonSpritesGfx +FreeMonSpritesGfx: @ 805F094 push {r4-r6,lr} - ldr r6, =gBattleSpritesGfx + ldr r6, =gMonSpritesGfxPtr ldr r0, [r6] cmp r0, 0 beq _0805F106 @@ -3769,7 +3769,7 @@ _0805F106: pop {r0} bx r0 .pool - thumb_func_end sub_805F094 + thumb_func_end FreeMonSpritesGfx thumb_func_start sub_805F110 sub_805F110: @ 805F110 diff --git a/asm/battle_anim.s b/asm/battle_anim.s index 9c0190214..645700d53 100644 --- a/asm/battle_anim.s +++ b/asm/battle_anim.s @@ -264,14 +264,14 @@ _080A3BAA: movs r2, 0x80 bl m4aMPlayVolumeControl _080A3BC2: - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r1, [r0] - ldr r0, =gUnknown_02022E28 + ldr r0, =gBattle_WIN1H strh r1, [r0] - ldr r0, =gUnknown_02022E2A + ldr r0, =gBattle_WIN1V strh r1, [r0] add sp, 0x4 pop {r3-r5} @@ -449,10 +449,10 @@ ma00_load_graphics: @ 80A3D24 lsls r0, 8 orrs r4, r0 lsls r5, r4, 3 - ldr r0, =gUnknown_085112C4 + ldr r0, =gUnknown_085112B4 + 0x10 adds r0, r5, r0 bl LoadCompressedObjectPicUsingHeap - ldr r0, =gUnknown_08511BCC + ldr r0, =gUnknown_08511A34 + 0x198 adds r5, r0 adds r0, r5, 0 bl LoadCompressedObjectPaletteUsingHeap @@ -1150,7 +1150,7 @@ _080A4330: lsls r0, 24 cmp r0, 0 bne _080A4374 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r5, 2 @@ -2864,7 +2864,7 @@ BattleAnimGetPanControl: @ 80A5178 lsls r0, 24 cmp r0, 0 bne _080A51C0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gAnimationBankAttacker ldrb r2, [r0] @@ -2986,7 +2986,7 @@ sub_80A5278: @ 80A5278 lsls r0, 24 cmp r0, 0 bne _080A52C0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gAnimationBankAttacker ldrb r2, [r0] diff --git a/asm/battle_anim_80A9C70.s b/asm/battle_anim_80A9C70.s index 16366988e..ca6572e1a 100644 --- a/asm/battle_anim_80A9C70.s +++ b/asm/battle_anim_80A9C70.s @@ -629,7 +629,7 @@ sub_80AA18C: @ 80AA18C lsls r0, 24 lsrs r4, r0, 24 movs r3, 0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] ldrh r0, [r0] @@ -899,7 +899,7 @@ task0A_80788BC: @ 80AA3B4 ldrb r0, [r0] cmp r0, 0 bne _080AA3F6 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r1, =gTasks lsls r0, r4, 2 diff --git a/asm/battle_anim_80FE840.s b/asm/battle_anim_80FE840.s index 860f1a6cb..58eb2ebf0 100644 --- a/asm/battle_anim_80FE840.s +++ b/asm/battle_anim_80FE840.s @@ -14561,7 +14561,7 @@ _08105CCC: lsls r0, 6 bl AllocZeroed adds r1, r0, 0 - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r0, [r0] movs r2, 0xBE lsls r2, 1 @@ -14571,7 +14571,7 @@ _08105CCC: bl LZDecompressWram movs r4, 0 _08105D00: - ldr r5, =gBattleSpritesGfx + ldr r5, =gMonSpritesGfxPtr ldr r0, [r5] movs r1, 0xBE lsls r1, 1 @@ -14785,9 +14785,9 @@ sub_8105EB0: @ 8105EB0 movs r6, 0x98 _08105EC4: movs r5, 0 - ldr r1, =gUnknown_02022E24 + ldr r1, =gBattle_WIN0H strh r6, [r1] - ldr r4, =gUnknown_02022E26 + ldr r4, =gBattle_WIN0V movs r0, 0xA0 strh r0, [r4] ldrh r1, [r1] @@ -14845,7 +14845,7 @@ sub_8105F30: @ 8105F30 lsls r0, r2, 16 cmp r1, r0 blt _08105F70 - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H movs r1, 0 strh r1, [r0] ldr r0, =sub_8105F84 @@ -14853,7 +14853,7 @@ sub_8105F30: @ 8105F30 b _08105F78 .pool _08105F70: - ldr r1, =gUnknown_02022E24 + ldr r1, =gBattle_WIN0H lsls r0, r4, 8 orrs r2, r0 strh r2, [r1] @@ -14905,9 +14905,9 @@ sub_8105F84: @ 8105F84 _08105FD8: cmp r0, 0x4 ble _0810600C - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H strh r4, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r4, [r0] ldr r4, =0x00003f3f movs r0, 0x48 @@ -30154,7 +30154,7 @@ _0810DB50: strh r0, [r2] adds r7, r2, 0 _0810DB60: - ldr r3, =gUnknown_02022E22 + ldr r3, =gBattle_BG3_Y ldrh r2, [r4, 0x1C] lsls r0, r2, 16 asrs r0, 24 @@ -37347,7 +37347,7 @@ sub_811152C: @ 811152C movs r0, 0xC8 strh r0, [r5, 0xA] _0811154E: - ldr r4, =gUnknown_02022E22 + ldr r4, =gBattle_BG3_Y movs r1, 0xA ldrsh r0, [r5, r1] movs r1, 0xA @@ -37396,7 +37396,7 @@ sub_8111590: @ 8111590 ldrh r0, [r4, 0x8] adds r0, 0x1 strh r0, [r4, 0x8] - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y ldrh r0, [r0] strh r0, [r4, 0xC] _081115BC: @@ -37405,7 +37405,7 @@ _081115BC: movs r1, 0xFF ands r0, r1 strh r0, [r4, 0xA] - ldr r6, =gUnknown_02022E22 + ldr r6, =gBattle_BG3_Y movs r2, 0xA ldrsh r1, [r4, r2] movs r0, 0x4 @@ -38602,7 +38602,7 @@ _08111F0C: adds r2, r0 lsls r2, 2 adds r2, r4 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gAnimationBankTarget ldrb r0, [r0] @@ -39577,10 +39577,10 @@ sub_8112758: @ 8112758 push {r4-r7,lr} lsls r0, 24 lsrs r7, r0, 24 - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r1, [r0] ldr r1, =0x00003f3f movs r0, 0x48 @@ -39611,13 +39611,13 @@ _081127A0: _081127B8: movs r6, 0xC8 _081127BA: - ldr r1, =gUnknown_02022E24 + ldr r1, =gBattle_WIN0H lsls r3, r6, 16 asrs r2, r3, 16 lsls r0, r2, 8 orrs r0, r2 strh r0, [r1] - ldr r1, =gUnknown_02022E26 + ldr r1, =gBattle_WIN0V movs r5, 0x28 ldr r0, =0x00002828 strh r0, [r1] @@ -39798,12 +39798,12 @@ _08112938: ldr r0, _08112988 @=sub_8112994 str r0, [r4] _08112966: - ldr r1, _0811298C @=gUnknown_02022E24 + ldr r1, _0811298C @=gBattle_WIN0H mov r2, r9 lsls r0, r2, 8 orrs r7, r0 strh r7, [r1] - ldr r1, _08112990 @=gUnknown_02022E26 + ldr r1, _08112990 @=gBattle_WIN0V lsls r0, r6, 8 orrs r5, r0 strh r5, [r1] @@ -39819,9 +39819,9 @@ _08112966: _08112988: .4byte sub_8112994 _0811298C: - .4byte gUnknown_02022E24 + .4byte gBattle_WIN0H _08112990: - .4byte gUnknown_02022E26 + .4byte gBattle_WIN0V thumb_func_end sub_811280C thumb_func_start sub_8112994 @@ -39837,9 +39837,9 @@ sub_8112994: @ 8112994 lsrs r1, r0, 24 cmp r1, 0 bne _081129DA - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H strh r1, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r1, [r0] ldr r4, =0x00003f3f movs r0, 0x48 @@ -40042,10 +40042,10 @@ sub_8112B44: @ 8112B44 movs r0, 0x52 movs r1, 0 bl SetGpuReg - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r1, [r0] adds r0, r4, 0 bl move_anim_8072740 @@ -42202,13 +42202,13 @@ _08113CDC: ldr r1, =0x00003f3f movs r0, 0x48 bl SetGpuReg - ldr r2, =gUnknown_02022E24 + ldr r2, =gBattle_WIN0H ldrh r0, [r5, 0x24] lsls r0, 8 ldrh r1, [r5, 0x26] orrs r0, r1 strh r0, [r2] - ldr r1, =gUnknown_02022E26 + ldr r1, =gBattle_WIN0V movs r0, 0xA0 strh r0, [r1] ldr r0, =sub_8113D60 @@ -42331,7 +42331,7 @@ _08113E1C: blt _08113E3E strh r2, [r4, 0x24] _08113E3E: - ldr r3, =gUnknown_02022E24 + ldr r3, =gBattle_WIN0H ldrh r2, [r4, 0x24] lsls r0, r2, 8 ldrh r1, [r4, 0x26] @@ -42398,10 +42398,10 @@ _08113EBC: lsrs r0, 24 cmp r0, 0x1 bne _08113EF8 - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r1, [r0] ldr r4, =0x00003f3f movs r0, 0x48 @@ -42588,13 +42588,13 @@ _08114078: ldr r1, =0x00003f3f movs r0, 0x48 bl SetGpuReg - ldr r2, =gUnknown_02022E24 + ldr r2, =gBattle_WIN0H ldrh r0, [r5, 0x24] lsls r0, 8 ldrh r1, [r5, 0x26] orrs r0, r1 strh r0, [r2] - ldr r1, =gUnknown_02022E26 + ldr r1, =gBattle_WIN0V movs r0, 0xA0 strh r0, [r1] movs r0, 0 @@ -42686,7 +42686,7 @@ _08114150: movs r0, 0x1 strh r0, [r4, 0xA] _08114154: - ldr r2, =gUnknown_02022E24 + ldr r2, =gBattle_WIN0H ldrh r0, [r4, 0x24] lsls r0, 8 ldrh r1, [r4, 0x26] @@ -42782,10 +42782,10 @@ _08114204: b _08114232 .pool _08114210: - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r1, [r0] ldr r4, =0x00003f3f movs r0, 0x48 @@ -43157,9 +43157,9 @@ sub_81144F8: @ 81144F8 lsls r0, 24 lsrs r7, r0, 24 movs r6, 0 - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H strh r6, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r6, [r0] ldr r1, =0x00003f3f movs r0, 0x48 @@ -43485,9 +43485,9 @@ _081147B8: _08114824: cmp r0, 0x3 bne _08114886 - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H strh r5, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r5, [r0] ldr r4, =0x00003f3f movs r0, 0x48 @@ -45266,7 +45266,7 @@ _0811565A: ldr r2, =gBattle_BG3_X ldrh r0, [r4, 0xA] strh r0, [r2] - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y strh r1, [r0] ldrh r0, [r6, 0x4] strh r0, [r4, 0xE] @@ -45298,7 +45298,7 @@ sub_81156D0: @ 81156D0 ldr r0, =gBattle_BG3_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y strh r1, [r0] adds r0, r3, 0 bl DestroyTask @@ -45308,7 +45308,7 @@ _08115710: ldr r1, =gBattle_BG3_X ldrh r0, [r2, 0xA] strh r0, [r1] - ldr r1, =gUnknown_02022E22 + ldr r1, =gBattle_BG3_Y ldrh r0, [r2, 0xC] strh r0, [r1] _0811571C: @@ -46557,7 +46557,7 @@ _081160E2: b _081160F6 .pool _081160EC: - ldr r1, =gUnknown_02022E22 + ldr r1, =gBattle_BG3_Y b _081160F6 .pool _081160F4: @@ -46796,7 +46796,7 @@ sub_81162A4: @ 81162A4 ldr r4, =gBattle_BG3_X ldrh r1, [r3] strh r1, [r4] - ldr r4, =gUnknown_02022E22 + ldr r4, =gBattle_BG3_Y ldrh r1, [r3, 0x2] strh r1, [r4] ldr r1, =sub_81162F8 @@ -46839,7 +46839,7 @@ _08116330: ldrh r0, [r3, 0x8] _08116332: strh r0, [r6] - ldr r2, =gUnknown_02022E22 + ldr r2, =gBattle_BG3_Y ldrh r3, [r2] lsls r1, r5, 2 adds r0, r1, r5 @@ -47805,9 +47805,9 @@ sub_8116B14: @ 8116B14 lsrs r0, 24 mov r9, r0 movs r7, 0 - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H strh r7, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r7, [r0] ldr r1, =0x00003f3f movs r0, 0x48 @@ -48072,10 +48072,10 @@ sub_8116D64: @ 8116D64 bne _08116E86 movs r0, 0 bl sub_80A477C - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H mov r1, r8 strh r1, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r1, [r0] ldr r4, =0x00003f3f movs r0, 0x48 @@ -48256,10 +48256,10 @@ _08116F56: movs r0, 0 strh r0, [r1, 0xA] _08116F5C: - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r1, [r0] ldr r1, =0x00003f3f movs r0, 0x48 @@ -48746,10 +48746,10 @@ _081173AE: strh r0, [r5, 0x26] b _08117478 _081173B6: - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r1, [r0] ldr r4, =0x00003f3f movs r0, 0x48 @@ -49158,7 +49158,7 @@ sub_81176D8: @ 81176D8 ldrh r4, [r6] adds r0, r4 strh r0, [r6] - ldr r4, =gUnknown_02022E22 + ldr r4, =gBattle_BG3_Y lsls r0, r2, 16 asrs r0, 24 ldrh r7, [r4] @@ -49363,10 +49363,10 @@ _081178B6: movs r2, 0 mov r8, r2 _081178BA: - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r1, [r0] ldr r1, =0x00003f3f movs r0, 0x48 @@ -49676,9 +49676,9 @@ _08117B34: bne _08117C0C movs r0, 0 bl sub_80A477C - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H strh r4, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r4, [r0] ldr r4, =0x00003f3f movs r0, 0x48 @@ -49777,7 +49777,7 @@ sub_8117C44: @ 8117C44 movs r0, 0x80 lsls r0, 6 bl AllocZeroed - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] movs r2, 0xBE lsls r2, 1 @@ -49797,7 +49797,7 @@ sub_8117C70: @ 8117C70 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - ldr r6, =gBattleSpritesGfx + ldr r6, =gMonSpritesGfxPtr ldr r0, [r6] movs r5, 0xBE lsls r5, 1 @@ -49866,7 +49866,7 @@ _08117CF6: adds r4, r0, 0 adds r4, 0x10 _08117CFC: - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r1, [r0] ldr r0, =gBattleAnimArgs movs r2, 0x2 @@ -49944,7 +49944,7 @@ _08117D98: lsls r0, r4, 5 ldr r1, =gPlttBufferUnfaded adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r2, [r1] ldr r1, =gBattleAnimArgs movs r3, 0x2 @@ -50163,7 +50163,7 @@ _08117F78: adds r3, r4 lsls r3, 3 adds r3, r0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r4, [r0] ldr r2, =gAnimationBankAttacker ldrb r0, [r2] @@ -50207,7 +50207,7 @@ sub_8117FD0: @ 8117FD0 lsls r0, 5 cmp r1, r0 bne _08118014 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gAnimationBankAttacker ldrb r3, [r0] @@ -50646,7 +50646,7 @@ _0811838C: bl SetGpuReg b _0811852A _0811839C: - ldr r1, =gUnknown_02022E26 + ldr r1, =gBattle_WIN0V ldrh r0, [r1] subs r0, 0xFF strh r0, [r1] @@ -50715,7 +50715,7 @@ _08118420: _0811842C: strh r0, [r2] _0811842E: - ldr r2, =gUnknown_02022E26 + ldr r2, =gBattle_WIN0V ldrh r1, [r2] movs r0, 0xFF lsls r0, 8 @@ -50988,7 +50988,7 @@ _08118662: b _0811881A .pool _08118678: - ldr r1, =gUnknown_02022E26 + ldr r1, =gBattle_WIN0V ldrh r0, [r1] subs r0, 0xFF strh r0, [r1] @@ -51065,7 +51065,7 @@ _08118708: movs r0, 0x4 strh r0, [r1, 0x12] _08118728: - ldr r2, =gUnknown_02022E26 + ldr r2, =gBattle_WIN0V ldrh r1, [r2] movs r0, 0xFF lsls r0, 8 @@ -51288,7 +51288,7 @@ _08118908: b _08118A96 .pool _0811891C: - ldr r1, =gUnknown_02022E26 + ldr r1, =gBattle_WIN0V ldrh r0, [r1] subs r0, 0xFF strh r0, [r1] @@ -51354,7 +51354,7 @@ _08118986: movs r0, 0x6 strh r0, [r2, 0x12] _081189A6: - ldr r2, =gUnknown_02022E26 + ldr r2, =gBattle_WIN0V ldrh r1, [r2] movs r0, 0xFF lsls r0, 8 @@ -51652,7 +51652,7 @@ _08118BA8: b _08118D5A .pool _08118C38: - ldr r1, =gUnknown_02022E26 + ldr r1, =gBattle_WIN0V ldrh r0, [r1] subs r0, 0xFF strh r0, [r1] @@ -51683,7 +51683,7 @@ _08118C50: b _08118D5A .pool _08118C7C: - ldr r2, =gUnknown_02022E26 + ldr r2, =gBattle_WIN0V ldrh r1, [r2] movs r0, 0xFF lsls r0, 8 @@ -51874,7 +51874,7 @@ _08118DD4: ldr r1, =0x00003f3f movs r0, 0x4A bl SetGpuReg - ldr r1, =gUnknown_02022E16 + ldr r1, =gBattle_BG0_Y ldr r2, =0x0000ffd0 adds r0, r2, 0 strh r0, [r1] @@ -51888,7 +51888,7 @@ _08118DD4: b _08118FB2 .pool _08118E4C: - ldr r2, =gUnknown_02022E26 + ldr r2, =gBattle_WIN0V ldrh r3, [r2] movs r1, 0x80 lsls r1, 1 @@ -51932,7 +51932,7 @@ _08118E7E: b _08118FB2 .pool _08118EA8: - ldr r3, =gUnknown_02022E26 + ldr r3, =gBattle_WIN0V ldrh r2, [r3] movs r0, 0xFF lsls r0, 8 @@ -51973,7 +51973,7 @@ _08118ED8: b _08118FB2 .pool _08118F00: - ldr r1, =gUnknown_02022E16 + ldr r1, =gBattle_BG0_Y ldrh r0, [r1] adds r3, r0, 0x2 strh r3, [r1] @@ -51981,7 +51981,7 @@ _08118F00: ldrh r0, [r1] adds r0, 0x2 strh r0, [r1] - ldr r5, =gUnknown_02022E26 + ldr r5, =gBattle_WIN0V ldrh r2, [r5] movs r0, 0xFF lsls r0, 8 @@ -52081,7 +52081,7 @@ sub_8118FBC: @ 8118FBC bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r2, [r1] lsls r4, 2 adds r2, 0x4 @@ -52189,7 +52189,7 @@ sub_8119094: @ 8119094 lsls r0, 24 mov r9, r0 ldr r4, =0x040000d4 - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r0, [r0] lsrs r2, 22 adds r0, 0x4 diff --git a/asm/battle_anim_815A0D4.s b/asm/battle_anim_815A0D4.s index f219c6988..81e4f9163 100755 --- a/asm/battle_anim_815A0D4.s +++ b/asm/battle_anim_815A0D4.s @@ -1077,10 +1077,10 @@ sub_815A934: @ 815A934 lsls r1, 8 movs r0, 0 bl SetGpuRegBits - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H movs r1, 0 strh r1, [r0] - ldr r4, =gUnknown_02022E26 + ldr r4, =gBattle_WIN0V strh r1, [r4] movs r0, 0x40 movs r1, 0 @@ -1416,18 +1416,18 @@ sub_815ABEC: @ 815ABEC ldr r1, =0x00001f3f movs r0, 0x48 bl SetGpuReg - ldr r1, =gUnknown_02022E28 + ldr r1, =gBattle_WIN1H ldr r2, =0x000098f0 adds r0, r2, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E2A + ldr r1, =gBattle_WIN1V movs r0, 0xA0 strh r0, [r1] - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H ldrh r1, [r0] movs r0, 0x42 bl SetGpuReg - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V ldrh r1, [r0] movs r0, 0x46 bl SetGpuReg @@ -1437,10 +1437,10 @@ _0815AC40: ldr r1, =0x00001f3f movs r0, 0x48 bl SetGpuReg - ldr r1, =gUnknown_02022E28 + ldr r1, =gBattle_WIN1H movs r0, 0xF0 strh r0, [r1] - ldr r4, =gUnknown_02022E2A + ldr r4, =gBattle_WIN1V ldr r1, =0x000078a0 adds r0, r1, 0 strh r0, [r4] @@ -1471,10 +1471,10 @@ sub_815AC8C: @ 815AC8C ldr r1, =0x00003f3f movs r0, 0x48 bl SetGpuReg - ldr r0, =gUnknown_02022E28 + ldr r0, =gBattle_WIN1H movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E2A + ldr r0, =gBattle_WIN1V strh r1, [r0] bl IsContest lsls r0, 24 @@ -3024,7 +3024,7 @@ _0815B8E0: lsls r0, 24 lsrs r1, r0, 24 _0815B8EA: - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r2, [r0] lsls r0, r1, 2 adds r2, 0x4 @@ -3250,7 +3250,7 @@ _0815BAB6: cmp r0, 0 bne _0815BAF6 ldrb r0, [r4] - ldr r1, =gUnknown_020244D0 + ldr r1, =gBattleSpritesDataPtr ldr r1, [r1] ldr r2, [r1] lsls r1, r0, 2 @@ -5397,10 +5397,10 @@ sub_815CC94: @ 815CC94 lsls r1, 8 movs r0, 0 bl SetGpuRegBits - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H movs r1, 0 strh r1, [r0] - ldr r4, =gUnknown_02022E26 + ldr r4, =gBattle_WIN0V strh r1, [r4] movs r0, 0x40 movs r1, 0 @@ -5723,7 +5723,7 @@ _0815CF18: movs r1, 0x1 bl GetMonData mov r8, r0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r2, [r4] ldr r1, [r0] @@ -5791,7 +5791,7 @@ _0815CFC4: movs r1, 0x1 bl GetMonData mov r8, r0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r2, [r4] ldr r1, [r0] @@ -10637,7 +10637,7 @@ _0815F67C: adds r0, r2 movs r1, 0x2 strh r1, [r0, 0x8] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gAnimationBankTarget ldrb r0, [r0] @@ -10762,7 +10762,7 @@ sub_815F7C4: @ 815F7C4 ble _0815F80E movs r0, 0 strh r0, [r4, 0x30] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gAnimationBankTarget ldrb r0, [r0] @@ -11072,7 +11072,7 @@ _0815FA28: movs r1, 0x1 bl GetMonData mov r9, r0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r2, [r4] ldr r1, [r0] @@ -11136,7 +11136,7 @@ _0815FAC8: movs r1, 0x1 bl GetMonData mov r9, r0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r2, [r4] ldr r1, [r0] @@ -11202,7 +11202,7 @@ _0815FB50: bl sub_80A8394 lsls r0, 24 lsrs r5, r0, 24 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldrb r0, [r4] ldr r1, [r1] diff --git a/asm/battle_anim_8170478.s b/asm/battle_anim_8170478.s index 85f94c20e..dd992a8cd 100644 --- a/asm/battle_anim_8170478.s +++ b/asm/battle_anim_8170478.s @@ -18,10 +18,10 @@ sub_8170478: @ 8170478 str r0, [sp, 0x10] ldr r0, =gAnimationBankAttacker ldrb r4, [r0] - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r1, [r0] ldr r1, =0x00003f3f movs r0, 0x48 @@ -317,9 +317,9 @@ _08170708: bne _08170814 movs r0, 0 bl sub_80A477C - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H strh r4, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r4, [r0] ldr r4, =0x00003f3f movs r0, 0x48 @@ -1035,7 +1035,7 @@ sub_8170D4C: @ 8170D4C push {lr} lsls r0, 24 lsrs r2, r0, 24 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] ldrb r0, [r0, 0x8] @@ -1183,7 +1183,7 @@ sub_8170E04: @ 8170E04 adds r4, r0 ldr r0, =sub_8171104 str r0, [r4] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r3, [r0, 0x8] ldr r1, =gBankSpriteIds @@ -1491,7 +1491,7 @@ sub_8171134: @ 8171134 lsls r0, 24 cmp r0, 0 beq _081711D2 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] ldrb r0, [r0, 0x8] @@ -1894,7 +1894,7 @@ _08171486: adds r0, r1 strh r0, [r4, 0x22] strh r5, [r4, 0x26] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] ldrb r0, [r0, 0x8] @@ -1940,7 +1940,7 @@ sub_81714D4: @ 81714D4 adds r0, r4, 0 movs r1, 0x1 bl StartSpriteAffineAnim - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] strh r5, [r0, 0xC] @@ -1982,7 +1982,7 @@ _08171540: .4byte _08171708 .4byte _08171768 _0817155C: - ldr r1, =gUnknown_020244D0 + ldr r1, =gBattleSpritesDataPtr ldr r5, [r1] ldr r2, [r5, 0x8] ldrh r3, [r2, 0xC] @@ -2060,7 +2060,7 @@ _081715EA: bl ChangeSpriteAffineAnim b _081717AE _081715F4: - ldr r1, =gUnknown_020244D0 + ldr r1, =gBattleSpritesDataPtr ldr r5, [r1] ldr r2, [r5, 0x8] ldrh r3, [r2, 0xC] @@ -2152,7 +2152,7 @@ _0817169C: movs r1, 0x1 bl ChangeSpriteAffineAnim _081716A4: - ldr r1, =gUnknown_020244D0 + ldr r1, =gBattleSpritesDataPtr ldr r5, [r1] ldr r2, [r5, 0x8] ldrh r3, [r2, 0xC] @@ -2211,7 +2211,7 @@ _08171708: strh r0, [r4, 0x34] lsls r0, 16 asrs r1, r0, 24 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] ldrb r0, [r0, 0x8] @@ -2859,7 +2859,7 @@ _08171C24: adds r2, r0 lsls r2, 2 adds r2, r4 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] ldrb r1, [r0, 0x9] @@ -3083,7 +3083,7 @@ sub_8171E20: @ 8171E20 ands r0, r1 cmp r0, 0 beq _08171E3E - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x8] ldrb r0, [r1, 0xA] @@ -4419,7 +4419,7 @@ sub_8172944: @ 8172944 b _081729E2 .pool _08172970: - ldr r2, =gUnknown_020244D0 + ldr r2, =gBattleSpritesDataPtr ldr r0, [r2] ldr r1, [r0, 0x8] ldrb r0, [r1, 0xA] @@ -5046,7 +5046,7 @@ sub_8172E9C: @ 8172E9C lsls r0, 24 lsrs r0, 24 ldr r3, =gBattleAnimArgs - ldr r1, =gUnknown_020244D0 + ldr r1, =gBattleSpritesDataPtr ldr r2, [r1] ldr r1, =gAnimationBankAttacker ldrb r1, [r1] @@ -5088,7 +5088,7 @@ sub_8172EF0: @ 8172EF0 lsrs r6, r0, 24 movs r0, 0 mov r8, r0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x4] lsls r0, r6, 1 @@ -5169,7 +5169,7 @@ _08172F6E: b _08172FDE .pool _08172FC8: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x4] lsls r0, r6, 1 @@ -5212,7 +5212,7 @@ sub_8172FEC: @ 8172FEC b _08173190 .pool _08173018: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] ldrb r0, [r0, 0xA] @@ -5414,7 +5414,7 @@ sub_81731B0: @ 81731B0 cmp r0, 0x1 bne _081731EA ldrb r1, [r1, 0x8] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r2, [r0, 0x4] lsls r0, r1, 1 @@ -5762,7 +5762,7 @@ sub_81734B4: @ 81734B4 push {lr} lsls r0, 24 lsrs r2, r0, 24 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] ldrh r1, [r0] @@ -5813,7 +5813,7 @@ sub_817351C: @ 817351C lsls r0, 24 lsrs r0, 24 ldr r3, =gAnimationBankAttacker - ldr r1, =gUnknown_020244D0 + ldr r1, =gBattleSpritesDataPtr ldr r2, [r1] ldr r1, [r2, 0x8] ldrh r1, [r1] diff --git a/asm/battle_controller_linkopponent.s b/asm/battle_controller_linkopponent.s index 8ea32eca0..5005a562e 100644 --- a/asm/battle_controller_linkopponent.s +++ b/asm/battle_controller_linkopponent.s @@ -158,7 +158,7 @@ _080644C2: thumb_func_start sub_80644D8 sub_80644D8: @ 80644D8 push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r1, [r4] ldr r3, =gActiveBank ldrb r0, [r3] @@ -281,7 +281,7 @@ _080645CA: cmp r0, 0 bne _0806469C _080645DE: - ldr r1, =gUnknown_020244D0 + ldr r1, =gBattleSpritesDataPtr mov r12, r1 ldr r0, [r1] ldr r7, =gActiveBank @@ -364,7 +364,7 @@ _08064600: b _080646F2 .pool _0806469C: - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldrb r1, [r7] ldr r2, [r0, 0x4] @@ -405,7 +405,7 @@ _0806469C: adds r0, r4, 0 bl FreeSpritePaletteByTag _080646F2: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r3, =gActiveBank ldrb r1, [r3] @@ -440,7 +440,7 @@ sub_8064734: @ 8064734 push {r5-r7} movs r0, 0 mov r10, r0 - ldr r5, =gUnknown_020244D0 + ldr r5, =gBattleSpritesDataPtr ldr r0, [r5] ldr r4, =gActiveBank ldrb r2, [r4] @@ -497,7 +497,7 @@ _08064776: adds r0, r3, 0 bl sub_8172EF0 _080647B4: - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldr r2, =gActiveBank ldrb r5, [r2] @@ -591,7 +591,7 @@ _0806484A: ldrb r0, [r0] bl sub_80729D0 _0806487A: - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r3, =gActiveBank ldrb r1, [r3] @@ -673,7 +673,7 @@ _08064930: lsls r2, 1 bl m4aMPlayVolumeControl _0806493C: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -735,7 +735,7 @@ _08064998: lsrs r0, 24 cmp r0, 0x3 bne _080649E2 - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldrb r2, [r5] ldr r0, [r0, 0x4] @@ -828,7 +828,7 @@ _08064A3A: lsrs r1, 16 adds r0, r5, 0 bl sub_805EE54 - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldr r2, [r0, 0x8] ldrb r1, [r2, 0x9] @@ -900,7 +900,7 @@ sub_8064B04: @ 8064B04 ldrsh r0, [r0, r1] cmp r0, 0 bne _08064BB6 - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldr r1, [r0, 0x4] lsls r4, r3, 1 @@ -1028,7 +1028,7 @@ _08064C42: thumb_func_start sub_8064C58 sub_8064C58: @ 8064C58 push {r4-r6,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r6, =gActiveBank ldrb r2, [r6] @@ -1166,7 +1166,7 @@ sub_8064D60: @ 8064D60 ldr r0, =SpriteCallbackDummy cmp r1, r0 bne _08064DAC - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r3, 2 @@ -1198,7 +1198,7 @@ _08064DAC: thumb_func_start sub_8064DD0 sub_8064DD0: @ 8064DD0 push {r4,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r4, =gActiveBank ldrb r1, [r4] @@ -1250,7 +1250,7 @@ _08064E2A: thumb_func_start sub_8064E50 sub_8064E50: @ 8064E50 push {r4-r7,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r5, =gActiveBank ldrb r2, [r5] @@ -1346,7 +1346,7 @@ _08064F0C: thumb_func_start sub_8064F40 sub_8064F40: @ 8064F40 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -1430,7 +1430,7 @@ _08064FDC: thumb_func_start sub_8065008 sub_8065008: @ 8065008 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -1454,7 +1454,7 @@ _0806502A: thumb_func_start sub_8065038 sub_8065038: @ 8065038 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -3907,7 +3907,7 @@ sub_8066624: @ 8066624 ldrb r3, [r0] cmp r3, 0 bne _0806666C - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x4] lsls r0, r2, 1 @@ -3959,7 +3959,7 @@ _080666A8: thumb_func_start sub_80666BC sub_80666BC: @ 80666BC push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -4589,7 +4589,7 @@ sub_8066B94: @ 8066B94 thumb_func_start sub_8066C40 sub_8066C40: @ 8066C40 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -4816,7 +4816,7 @@ _08066D32: b _08066E58 .pool _08066E30: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r1, [r5] ldr r2, [r0, 0x4] @@ -4869,7 +4869,7 @@ sub_8066E70: @ 8066E70 adds r1, r2 ldrb r1, [r1] mov r8, r1 - ldr r7, =gUnknown_020244D0 + ldr r7, =gBattleSpritesDataPtr ldr r5, [r7] ldr r1, [r5, 0x4] lsls r0, r3, 1 @@ -4977,7 +4977,7 @@ _08066F32: ands r0, r2 strb r0, [r1] _08066F80: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -5031,10 +5031,10 @@ _08066FE4: thumb_func_start sub_8066FF4 sub_8066FF4: @ 8066FF4 push {r4,r5,lr} - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r5, =gActiveBank ldrb r4, [r5] @@ -5244,7 +5244,7 @@ sub_806719C: @ 806719C movs r2, 0x9 bl healthbar_draw_field_maybe ldrb r2, [r4] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x4] lsls r1, r2, 1 @@ -5718,7 +5718,7 @@ sub_8067508: @ 8067508 adds r1, r4 ldrb r0, [r6] strh r0, [r1, 0x8] - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldrb r2, [r6] ldr r1, [r0, 0x4] @@ -5893,7 +5893,7 @@ sub_8067718: @ 8067718 b _08067812 .pool _08067748: - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r3, =gActiveBank ldrb r1, [r3] @@ -5960,7 +5960,7 @@ _080677B4: adds r1, r2 movs r3, 0 strb r0, [r1] - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldrb r1, [r5] ldr r2, [r0, 0x4] @@ -6000,7 +6000,7 @@ _08067812: thumb_func_start sub_806782C sub_806782C: @ 806782C push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r3, =gActiveBank ldrb r1, [r3] @@ -6036,7 +6036,7 @@ _08067864: thumb_func_start sub_8067874 sub_8067874: @ 8067874 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gActiveBank ldrb r3, [r0] diff --git a/asm/battle_controller_linkpartner.s b/asm/battle_controller_linkpartner.s index 504ba6b5c..c2f6a4571 100644 --- a/asm/battle_controller_linkpartner.s +++ b/asm/battle_controller_linkpartner.s @@ -131,7 +131,7 @@ _0814AFA4: thumb_func_start sub_814AFBC sub_814AFBC: @ 814AFBC push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r1, [r4] ldr r3, =gActiveBank ldrb r0, [r3] @@ -239,7 +239,7 @@ _0814B094: _0814B0A0: cmp r6, 0 beq _0814B0C6 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r3, =gActiveBank ldrb r1, [r3] @@ -270,7 +270,7 @@ sub_814B0E8: @ 814B0E8 mov r6, r9 mov r5, r8 push {r5-r7} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr mov r12, r0 ldr r0, [r0] ldr r7, =gActiveBank @@ -426,7 +426,7 @@ _0814B1F0: adds r0, r5 ldrb r0, [r0] bl sub_80729D0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r2, [r0, 0x8] ldrb r1, [r2, 0x9] @@ -599,7 +599,7 @@ _0814B3BC: thumb_func_start sub_814B3DC sub_814B3DC: @ 814B3DC push {r4-r6,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r6, =gActiveBank ldrb r2, [r6] @@ -737,7 +737,7 @@ sub_814B4E0: @ 814B4E0 bne _0814B532 adds r0, r3, 0 bl sub_805E408 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r2, [r4] ldr r1, [r0] @@ -769,7 +769,7 @@ _0814B532: thumb_func_start sub_814B554 sub_814B554: @ 814B554 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gActiveBank ldrb r3, [r0] @@ -808,7 +808,7 @@ sub_814B5A8: @ 814B5A8 push {r4-r7,lr} mov r7, r8 push {r7} - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldr r7, =gActiveBank ldrb r1, [r7] @@ -903,7 +903,7 @@ _0814B664: thumb_func_start sub_814B69C sub_814B69C: @ 814B69C push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldr r4, =gActiveBank ldrb r2, [r4] @@ -1021,7 +1021,7 @@ _0814B7A6: thumb_func_start sub_814B7B8 sub_814B7B8: @ 814B7B8 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -1045,7 +1045,7 @@ _0814B7DA: thumb_func_start sub_814B7E8 sub_814B7E8: @ 814B7E8 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -3476,7 +3476,7 @@ sub_814CE14: @ 814CE14 ldrb r3, [r0] cmp r3, 0 bne _0814CE5C - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x4] lsls r0, r2, 1 @@ -3526,7 +3526,7 @@ _0814CE92: thumb_func_start sub_814CEA4 sub_814CEA4: @ 814CEA4 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -3870,7 +3870,7 @@ sub_814D0F0: @ 814D0F0 thumb_func_start sub_814D19C sub_814D19C: @ 814D19C push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -4125,7 +4125,7 @@ _0814D2CE: b _0814D3F4 .pool _0814D3CC: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r1, [r5] ldr r2, [r0, 0x4] @@ -4178,7 +4178,7 @@ bx_move_anim_4: @ 814D40C adds r1, r2 ldrb r1, [r1] mov r8, r1 - ldr r7, =gUnknown_020244D0 + ldr r7, =gBattleSpritesDataPtr ldr r5, [r7] ldr r1, [r5, 0x4] lsls r0, r3, 1 @@ -4286,7 +4286,7 @@ _0814D4CE: ands r0, r2 strb r0, [r1] _0814D51C: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -4340,10 +4340,10 @@ _0814D580: thumb_func_start sub_814D590 sub_814D590: @ 814D590 push {r4,r5,lr} - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r5, =gActiveBank ldrb r4, [r5] @@ -4553,7 +4553,7 @@ sub_814D738: @ 814D738 movs r2, 0x9 bl healthbar_draw_field_maybe ldrb r2, [r4] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x4] lsls r1, r2, 1 @@ -5147,7 +5147,7 @@ _0814DC06: adds r1, r4 ldrb r0, [r5] strh r0, [r1, 0x8] - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldrb r2, [r5] ldr r1, [r0, 0x4] @@ -5326,7 +5326,7 @@ sub_814DDD8: @ 814DDD8 b _0814DE7C .pool _0814DE08: - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldr r5, =gActiveBank ldrb r1, [r5] @@ -5394,7 +5394,7 @@ _0814DE7C: thumb_func_start sub_814DE9C sub_814DE9C: @ 814DE9C push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r3, =gActiveBank ldrb r1, [r3] @@ -5430,7 +5430,7 @@ _0814DED4: thumb_func_start sub_814DEE4 sub_814DEE4: @ 814DEE4 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gActiveBank ldrb r3, [r0] diff --git a/asm/battle_controller_opponent.s b/asm/battle_controller_opponent.s index 0910fc8e2..48b7c7bf4 100644 --- a/asm/battle_controller_opponent.s +++ b/asm/battle_controller_opponent.s @@ -158,7 +158,7 @@ _0805F292: thumb_func_start sub_805F2A8 sub_805F2A8: @ 805F2A8 push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r1, [r4] ldr r3, =gActiveBank ldrb r0, [r3] @@ -277,7 +277,7 @@ _0805F3A0: movs r6, 0x1 _0805F3A2: ldr r3, =gUnknown_020244D8 - ldr r1, =gUnknown_020244D0 + ldr r1, =gBattleSpritesDataPtr mov r8, r1 ldr r2, [r1] ldr r7, =gActiveBank @@ -449,7 +449,7 @@ _0805F4E4: ands r0, r2 strb r0, [r1, 0x1] _0805F51A: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r3, =gActiveBank ldrb r1, [r3] @@ -488,7 +488,7 @@ sub_805F560: @ 805F560 movs r0, 0 str r0, [sp] mov r10, r0 - ldr r5, =gUnknown_020244D0 + ldr r5, =gBattleSpritesDataPtr ldr r0, [r5] ldr r4, =gActiveBank ldrb r2, [r4] @@ -549,7 +549,7 @@ _0805F5A6: adds r0, r3, 0 bl sub_8172EF0 _0805F5EE: - ldr r2, =gUnknown_020244D0 + ldr r2, =gBattleSpritesDataPtr ldr r0, [r2] ldr r1, =gActiveBank mov r8, r1 @@ -643,7 +643,7 @@ _0805F684: ldrb r0, [r0] bl sub_80729D0 _0805F6B4: - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r2, [r3] ldr r0, =gActiveBank ldrb r1, [r0] @@ -723,7 +723,7 @@ _0805F768: lsls r2, 1 bl m4aMPlayVolumeControl _0805F774: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -906,7 +906,7 @@ _0805F8D2: lsrs r1, 16 adds r0, r5, 0 bl sub_805EE54 - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldr r2, [r0, 0x8] ldrb r1, [r2, 0x9] @@ -972,7 +972,7 @@ sub_805F994: @ 805F994 ldrsh r0, [r0, r1] cmp r0, 0 bne _0805F9E0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x4] lsls r2, r3, 1 @@ -1010,7 +1010,7 @@ _0805F9E0: ldr r0, =SpriteCallbackDummy cmp r1, r0 bne _0805FA48 - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r1, [r0, 0x4] lsls r0, r3, 1 @@ -1122,7 +1122,7 @@ _0805FAF2: thumb_func_start sub_805FB08 sub_805FB08: @ 805FB08 push {r4-r6,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r6, =gActiveBank ldrb r2, [r6] @@ -1260,7 +1260,7 @@ sub_805FC10: @ 805FC10 ldr r0, =SpriteCallbackDummy cmp r1, r0 bne _0805FC5C - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r3, 2 @@ -1292,7 +1292,7 @@ _0805FC5C: thumb_func_start bx_803AEDC bx_803AEDC: @ 805FC80 push {r4,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r4, =gActiveBank ldrb r1, [r4] @@ -1344,7 +1344,7 @@ _0805FCDA: thumb_func_start sub_805FD00 sub_805FD00: @ 805FD00 push {r4-r7,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r5, =gActiveBank ldrb r2, [r5] @@ -1440,7 +1440,7 @@ _0805FDBC: thumb_func_start sub_805FDF0 sub_805FDF0: @ 805FDF0 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -1524,7 +1524,7 @@ _0805FE8C: thumb_func_start sub_805FEB8 sub_805FEB8: @ 805FEB8 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -1548,7 +1548,7 @@ _0805FEDA: thumb_func_start bx_803B0F4 bx_803B0F4: @ 805FEE8 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -4069,7 +4069,7 @@ sub_806156C: @ 806156C ldrb r3, [r0] cmp r3, 0 bne _080615B4 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x4] lsls r0, r2, 1 @@ -4121,7 +4121,7 @@ _080615F0: thumb_func_start sub_8061604 sub_8061604: @ 8061604 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -4741,7 +4741,7 @@ sub_8061AF0: @ 8061AF0 thumb_func_start sub_8061B9C sub_8061B9C: @ 8061B9C push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -4962,7 +4962,7 @@ _08061C8A: b _08061D9E .pool _08061D80: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r1, [r6] ldr r2, [r0, 0x4] @@ -5009,7 +5009,7 @@ bx_move_anim_7: @ 8061DB0 adds r1, r2 ldrb r1, [r1] mov r8, r1 - ldr r7, =gUnknown_020244D0 + ldr r7, =gBattleSpritesDataPtr ldr r5, [r7] ldr r1, [r5, 0x4] lsls r0, r3, 1 @@ -5117,7 +5117,7 @@ _08061E72: ands r0, r2 strb r0, [r1] _08061EC0: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -5171,10 +5171,10 @@ _08061F24: thumb_func_start sub_8061F34 sub_8061F34: @ 8061F34 push {r4,r5,lr} - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r5, =gActiveBank ldrb r4, [r5] @@ -5694,7 +5694,7 @@ sub_8062390: @ 8062390 movs r2, 0x9 bl healthbar_draw_field_maybe ldrb r2, [r4] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x4] lsls r1, r2, 1 @@ -6168,7 +6168,7 @@ sub_80626FC: @ 80626FC adds r1, r4 ldrb r0, [r6] strh r0, [r1, 0x8] - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldrb r2, [r6] ldr r1, [r0, 0x4] @@ -6348,7 +6348,7 @@ dp01t_30_7_0803D67C: @ 8062918 b _08062A12 .pool _08062948: - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r3, =gActiveBank ldrb r1, [r3] @@ -6415,7 +6415,7 @@ _080629B4: adds r1, r2 movs r3, 0 strb r0, [r1] - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldrb r1, [r5] ldr r2, [r0, 0x4] @@ -6455,7 +6455,7 @@ _08062A12: thumb_func_start bx_0803D790_t7 bx_0803D790_t7: @ 8062A2C push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r3, =gActiveBank ldrb r1, [r3] @@ -6491,7 +6491,7 @@ _08062A64: thumb_func_start sub_8062A74 sub_8062A74: @ 8062A74 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gActiveBank ldrb r3, [r0] @@ -6655,7 +6655,7 @@ sub_8062BB0: @ 8062BB0 negs r0, r0 ands r0, r1 strb r0, [r3] - ldr r0, =gUnknown_03005D00 + ldr r0, =gPreBattleCallback1 ldr r0, [r0] str r0, [r2] ldr r0, [r2, 0x8] diff --git a/asm/battle_controller_player.s b/asm/battle_controller_player.s index d3b29ffe8..4dbdf3968 100644 --- a/asm/battle_controller_player.s +++ b/asm/battle_controller_player.s @@ -191,7 +191,7 @@ _080575F0: beq _08057658 movs r0, 0x5 bl PlaySE - ldr r1, =gUnknown_020244AC + ldr r1, =gActionSelectionCursor ldr r0, =gActiveBank ldrb r0, [r0] adds r0, r1 @@ -233,7 +233,7 @@ _08057658: ands r0, r2 cmp r0, 0 beq _08057698 - ldr r5, =gUnknown_020244AC + ldr r5, =gActionSelectionCursor ldr r4, =gActiveBank ldrb r0, [r4] adds r0, r5 @@ -261,7 +261,7 @@ _08057698: ands r0, r2 cmp r0, 0 beq _080576D8 - ldr r5, =gUnknown_020244AC + ldr r5, =gActionSelectionCursor ldr r4, =gActiveBank ldrb r0, [r4] adds r0, r5 @@ -290,7 +290,7 @@ _080576D8: ands r0, r2 cmp r0, 0 beq _08057700 - ldr r5, =gUnknown_020244AC + ldr r5, =gActionSelectionCursor ldr r4, =gActiveBank ldrb r0, [r4] adds r0, r5 @@ -306,7 +306,7 @@ _08057700: ands r0, r2 cmp r0, 0 beq _0805774C - ldr r5, =gUnknown_020244AC + ldr r5, =gActionSelectionCursor ldr r4, =gActiveBank ldrb r0, [r4] adds r0, r5 @@ -508,7 +508,7 @@ _080578A0: adds r0, r2 ldr r1, =sub_8039B2C str r1, [r0] - ldr r1, =gUnknown_020244B0 + ldr r1, =gMoveSelectionCursor ldr r0, =gActiveBank ldrb r0, [r0] adds r0, r1 @@ -664,7 +664,7 @@ _08057A32: muls r0, r1 ldr r1, =gPlayerParty adds r0, r1 - ldr r1, =gUnknown_020244B0 + ldr r1, =gMoveSelectionCursor adds r2, r1 ldrb r1, [r2] adds r1, 0xD @@ -792,7 +792,7 @@ _08057B56: muls r0, r1 ldr r1, =gPlayerParty adds r0, r1 - ldr r1, =gUnknown_020244B0 + ldr r1, =gMoveSelectionCursor adds r2, r1 ldrb r1, [r2] adds r1, 0xD @@ -890,7 +890,7 @@ _08057C48: _08057C58: movs r0, 0x5 bl PlaySE - ldr r1, =gUnknown_020244B0 + ldr r1, =gMoveSelectionCursor ldr r0, =gActiveBank ldrb r0, [r0] adds r0, r1 @@ -977,7 +977,7 @@ _08057D18: movs r0, 0x1 add r8, r0 _08057D24: - ldr r0, =gUnknown_020244B0 + ldr r0, =gMoveSelectionCursor adds r0, r3, r0 adds r1, r6, 0 adds r1, 0x8 @@ -1008,7 +1008,7 @@ _08057D5A: cmp r0, 0 bne _08057D80 _08057D62: - ldr r1, =gUnknown_020244B0 + ldr r1, =gMoveSelectionCursor ldrb r0, [r7] adds r0, r1 ldrb r2, [r0] @@ -1095,7 +1095,7 @@ _08057E30: ands r0, r2 cmp r0, 0 beq _08057E60 - ldr r4, =gUnknown_020244B0 + ldr r4, =gMoveSelectionCursor ldrb r0, [r7] adds r2, r0, r4 ldrb r1, [r2] @@ -1119,7 +1119,7 @@ _08057E60: ands r0, r2 cmp r0, 0 beq _08057EA4 - ldr r4, =gUnknown_020244B0 + ldr r4, =gMoveSelectionCursor ldrb r0, [r7] adds r3, r0, r4 ldrb r2, [r3] @@ -1151,7 +1151,7 @@ _08057EA4: ands r0, r2 cmp r0, 0 beq _08057ED4 - ldr r4, =gUnknown_020244B0 + ldr r4, =gMoveSelectionCursor ldrb r0, [r7] adds r2, r0, r4 ldrb r1, [r2] @@ -1173,7 +1173,7 @@ _08057ED4: ands r0, r2 cmp r0, 0 beq _08057F30 - ldr r4, =gUnknown_020244B0 + ldr r4, =gMoveSelectionCursor ldrb r0, [r7] adds r3, r0, r4 ldrb r2, [r3] @@ -1221,7 +1221,7 @@ _08057F30: ands r5, r6 cmp r5, 0 bne _08057F9E - ldr r4, =gUnknown_020244B0 + ldr r4, =gMoveSelectionCursor ldrb r0, [r7] adds r0, r4 ldrb r0, [r0] @@ -1287,10 +1287,10 @@ _08057FD6: beq _08057FF8 movs r0, 0x5 bl PlaySE - ldr r1, =gUnknown_02022E14 + ldr r1, =gBattle_BG0_X movs r0, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E16 + ldr r1, =gBattle_BG0_Y movs r2, 0xA0 lsls r2, 1 adds r0, r2, 0 @@ -1302,7 +1302,7 @@ _08057FF8: ands r0, r1 cmp r0, 0 beq _08058038 - ldr r5, =gUnknown_020244B0 + ldr r5, =gMoveSelectionCursor ldr r4, =gActiveBank ldrb r0, [r4] adds r2, r0, r5 @@ -1333,7 +1333,7 @@ _08058038: ands r0, r1 cmp r0, 0 beq _08058086 - ldr r5, =gUnknown_020244B0 + ldr r5, =gMoveSelectionCursor ldr r4, =gActiveBank ldrb r0, [r4] adds r3, r0, r5 @@ -1370,7 +1370,7 @@ _08058086: ands r0, r1 cmp r0, 0 beq _080580C8 - ldr r5, =gUnknown_020244B0 + ldr r5, =gMoveSelectionCursor ldr r4, =gActiveBank ldrb r0, [r4] adds r2, r0, r5 @@ -1401,7 +1401,7 @@ _080580C8: ands r0, r1 cmp r0, 0 beq _08058116 - ldr r5, =gUnknown_020244B0 + ldr r5, =gMoveSelectionCursor ldr r4, =gActiveBank ldrb r0, [r4] adds r3, r0, r5 @@ -1457,7 +1457,7 @@ sub_8058138: @ 8058138 _08058152: movs r0, 0x5 bl PlaySE - ldr r0, =gUnknown_020244B0 + ldr r0, =gMoveSelectionCursor mov r10, r0 ldr r1, =gActiveBank mov r8, r1 @@ -1594,7 +1594,7 @@ _0805824E: adds r6, 0x1 cmp r6, 0x3 ble _0805824E - ldr r1, =gUnknown_020244B0 + ldr r1, =gMoveSelectionCursor ldrb r0, [r7] adds r0, r1 ldrb r0, [r0] @@ -1758,7 +1758,7 @@ _08058392: adds r6, 0x1 cmp r6, 0x3 ble _08058392 - ldr r4, =gUnknown_020244B0 + ldr r4, =gMoveSelectionCursor ldr r3, =gActiveBank ldrb r0, [r3] adds r0, r4 @@ -1892,7 +1892,7 @@ _080584A8: adds r0, r1 ldr r1, =sub_8057BFC str r1, [r0] - ldr r3, =gUnknown_020244B0 + ldr r3, =gMoveSelectionCursor ldrb r0, [r2] adds r0, r3 ldr r1, =gUnknown_03005D74 @@ -1915,7 +1915,7 @@ _08058500: ldr r0, =gUnknown_03005D74 ldrb r0, [r0] bl battle_menu_cursor_related - ldr r1, =gUnknown_020244B0 + ldr r1, =gMoveSelectionCursor ldr r4, =gActiveBank ldrb r0, [r4] adds r0, r1 @@ -1947,7 +1947,7 @@ _08058554: bne _0805856A b _080586E8 _0805856A: - ldr r0, =gUnknown_020244B0 + ldr r0, =gMoveSelectionCursor ldr r1, =gActiveBank ldrb r1, [r1] adds r1, r0 @@ -1990,7 +1990,7 @@ _080585BA: bcc _080585C8 b _080586E8 _080585C8: - ldr r0, =gUnknown_020244B0 + ldr r0, =gMoveSelectionCursor ldr r1, =gActiveBank ldrb r1, [r1] adds r1, r0 @@ -2010,7 +2010,7 @@ _080585E8: ands r0, r2 cmp r0, 0 beq _080586E8 - ldr r0, =gUnknown_020244B0 + ldr r0, =gMoveSelectionCursor ldr r1, =gActiveBank ldrb r1, [r1] adds r1, r0 @@ -2034,7 +2034,7 @@ _0805862C: strb r0, [r4] movs r0, 0x5 bl PlaySE - ldr r1, =gUnknown_020244B0 + ldr r1, =gMoveSelectionCursor ldr r0, =gActiveBank ldrb r0, [r0] adds r0, r1 @@ -2064,7 +2064,7 @@ _0805865C: ldrb r1, [r1] cmp r0, r1 bcs _080586E8 - ldr r0, =gUnknown_020244B0 + ldr r0, =gMoveSelectionCursor ldr r1, =gActiveBank ldrb r1, [r1] adds r1, r0 @@ -2087,7 +2087,7 @@ _080586AA: strb r0, [r4] movs r0, 0x5 bl PlaySE - ldr r1, =gUnknown_020244B0 + ldr r1, =gMoveSelectionCursor ldr r0, =gActiveBank ldrb r0, [r0] adds r0, r1 @@ -2123,7 +2123,7 @@ sub_80586F8: @ 80586F8 ldrb r0, [r0] cmp r0, 0 bne _0805875C - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _08058798 @@ -2137,7 +2137,7 @@ sub_80586F8: @ 80586F8 negs r0, r0 ands r0, r1 strb r0, [r2] - ldr r0, =gUnknown_03005D00 + ldr r0, =gPreBattleCallback1 ldr r0, [r0] str r0, [r3] ldr r0, =sub_8038D64 @@ -2166,7 +2166,7 @@ _0805875C: negs r0, r0 ands r0, r1 strb r0, [r2] - ldr r0, =gUnknown_03005D00 + ldr r0, =gPreBattleCallback1 ldr r0, [r0] str r0, [r3] ldr r0, =sub_8038D64 @@ -2233,7 +2233,7 @@ _08058810: negs r0, r0 ands r0, r1 strb r0, [r3] - ldr r0, =gUnknown_03005D00 + ldr r0, =gPreBattleCallback1 ldr r0, [r0] str r0, [r2] ldr r0, [r2, 0x8] @@ -2344,7 +2344,7 @@ _08058908: thumb_func_start sub_8058924 sub_8058924: @ 8058924 push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r1, [r4] ldr r3, =gActiveBank ldrb r0, [r3] @@ -2452,7 +2452,7 @@ _08058A0A: cmp r7, 0 beq _08058B08 _08058A0E: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr mov r9, r0 ldr r0, [r0] mov r6, r10 @@ -2593,7 +2593,7 @@ sub_8058B40: @ 8058B40 movs r0, 0 mov r9, r0 mov r8, r0 - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r7, =gActiveBank ldrb r2, [r7] @@ -2729,7 +2729,7 @@ _08058C38: ldrb r0, [r0] bl sub_80729D0 _08058C68: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -2743,7 +2743,7 @@ _08058C68: orrs r1, r2 strb r1, [r0, 0x1] _08058C82: - ldr r5, =gUnknown_020244D0 + ldr r5, =gBattleSpritesDataPtr ldr r0, [r5] ldr r4, =gActiveBank ldrb r2, [r4] @@ -2801,7 +2801,7 @@ _08058D08: lsls r2, 1 bl m4aMPlayVolumeControl _08058D14: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -2950,7 +2950,7 @@ _08058E48: ldr r1, =gSprites adds r0, r1 bl DestroySprite - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldr r2, [r0, 0x8] ldrb r1, [r2, 0x9] @@ -3015,7 +3015,7 @@ sub_8058EDC: @ 8058EDC ldr r0, =SpriteCallbackDummy cmp r4, r0 bne _08058F94 - ldr r5, =gUnknown_020244D0 + ldr r5, =gBattleSpritesDataPtr ldr r0, [r5] ldr r1, [r0, 0x4] lsls r0, r3, 1 @@ -3098,7 +3098,7 @@ _08058F94: thumb_func_start sub_8058FC0 sub_8058FC0: @ 8058FC0 push {r4,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r4, =gActiveBank ldrb r1, [r4] @@ -3142,7 +3142,7 @@ _0805900E: thumb_func_start sub_805902C sub_805902C: @ 805902C push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -3774,7 +3774,7 @@ sub_80595A4: @ 80595A4 lsls r0, 3 adds r2, r0, r1 ldrb r5, [r2, 0xC] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x4] lsls r0, r5, 1 @@ -3942,7 +3942,7 @@ _08059724: thumb_func_start sub_8059744 sub_8059744: @ 8059744 push {r4-r6,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r6, =gActiveBank ldrb r2, [r6] @@ -4145,7 +4145,7 @@ bx_wait_t1: @ 805991C ldrb r0, [r0] cmp r0, 0 beq _08059942 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -4407,7 +4407,7 @@ sub_8059B3C: @ 8059B3C adds r0, r5, 0x4 adds r4, r0 ldr r6, =gDisplayedStringBattle - ldr r5, =gUnknown_020244B0 + ldr r5, =gMoveSelectionCursor adds r1, r5 adds r0, r4, 0 adds r0, 0x8 @@ -4462,7 +4462,7 @@ sub_8059BB0: @ 8059BB0 strb r1, [r0] adds r0, 0x1 ldr r3, =gBattleMoves - ldr r2, =gUnknown_020244B0 + ldr r2, =gMoveSelectionCursor ldrb r1, [r5] adds r1, r2 ldrb r1, [r1] @@ -4657,7 +4657,7 @@ sub_8059D50: @ 8059D50 thumb_func_start sub_8059D60 sub_8059D60: @ 8059D60 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -4681,7 +4681,7 @@ _08059D82: thumb_func_start bx_8030B2C bx_8030B2C: @ 8059D90 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -4711,10 +4711,10 @@ b_link_standby_message: @ 8059DC0 ands r0, r1 cmp r0, 0 beq _08059DE0 - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r0, =gText_LinkStandby movs r1, 0 @@ -6924,11 +6924,11 @@ sub_805B1CC: @ 805B1CC ldr r2, =gPlayerParty adds r0, r2 bl sub_805DD7C - ldr r1, =gUnknown_020244AC + ldr r1, =gActionSelectionCursor ldrb r0, [r5] adds r0, r1 strb r4, [r0] - ldr r1, =gUnknown_020244B0 + ldr r1, =gMoveSelectionCursor ldrb r0, [r5] adds r0, r1 strb r4, [r0] @@ -7124,7 +7124,7 @@ sub_805B3D4: @ 805B3D4 ldrb r3, [r0] cmp r3, 0 bne _0805B41C - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x4] lsls r0, r2, 1 @@ -7174,7 +7174,7 @@ _0805B452: thumb_func_start sub_805B464 sub_805B464: @ 805B464 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -7890,7 +7890,7 @@ sub_805B9F8: @ 805B9F8 thumb_func_start sub_805BAB8 sub_805BAB8: @ 805BAB8 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -8013,7 +8013,7 @@ sub_805BBA4: @ 805BBA4 thumb_func_start sub_805BBC4 sub_805BBC4: @ 805BBC4 push {r4,r5,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x8] movs r0, 0x4 @@ -8054,7 +8054,7 @@ sub_805BC18: @ 805BC18 adds r1, 0x1 adds r0, r1 ldrb r1, [r0] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] strb r1, [r0, 0x8] @@ -8229,7 +8229,7 @@ _0805BCBE: b _0805BDE4 .pool _0805BDBC: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r1, [r5] ldr r2, [r0, 0x4] @@ -8282,7 +8282,7 @@ bx_move_anim_1: @ 805BDFC adds r1, r2 ldrb r1, [r1] mov r8, r1 - ldr r7, =gUnknown_020244D0 + ldr r7, =gBattleSpritesDataPtr ldr r5, [r7] ldr r1, [r5, 0x4] lsls r0, r3, 1 @@ -8390,7 +8390,7 @@ _0805BEBE: ands r0, r2 strb r0, [r1] _0805BF0C: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -8444,10 +8444,10 @@ _0805BF70: thumb_func_start sub_805BF80 sub_805BF80: @ 805BF80 push {r4,r5,lr} - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r5, =gActiveBank ldrb r4, [r5] @@ -8503,9 +8503,9 @@ sub_805C004: @ 805C004 lsrs r1, r0, 24 cmp r1, 0 bne _0805C02A - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X strh r1, [r0] - ldr r1, =gUnknown_02022E16 + ldr r1, =gBattle_BG0_Y movs r0, 0xA0 strh r0, [r1] ldr r1, =gBattleBankFunc @@ -8543,7 +8543,7 @@ _0805C062: adds r4, 0x1 cmp r4, 0x3 ble _0805C062 - ldr r1, =gUnknown_020244AC + ldr r1, =gActionSelectionCursor ldr r0, =gActiveBank ldrb r0, [r0] adds r0, r1 @@ -8611,9 +8611,9 @@ sub_805C114: @ 805C114 lsrs r1, r0, 24 cmp r1, 0 bne _0805C13E - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X strh r1, [r0] - ldr r1, =gUnknown_02022E16 + ldr r1, =gBattle_BG0_Y movs r2, 0xA0 lsls r2, 1 adds r0, r2, 0 @@ -8648,7 +8648,7 @@ sub_805C158: @ 805C158 lsls r0, 24 cmp r0, 0 bne _0805C194 - ldr r1, =gUnknown_0203BD30 + ldr r1, =gBattlePalaceMoveSelectionRngValue ldr r0, =gRngValue ldr r0, [r0] str r0, [r1] @@ -8715,7 +8715,7 @@ sub_805C210: @ 805C210 ldr r1, =gUnknown_03005D74 movs r0, 0xFF strb r0, [r1] - ldr r1, =gUnknown_020244B0 + ldr r1, =gMoveSelectionCursor ldr r0, =gActiveBank ldrb r0, [r0] adds r0, r1 @@ -9132,7 +9132,7 @@ sub_805C5C4: @ 805C5C4 movs r2, 0x9 bl healthbar_draw_field_maybe ldrb r2, [r4] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x4] lsls r1, r2, 1 @@ -9794,7 +9794,7 @@ dp01t_2F_1_pokemon_enter: @ 805CA80 adds r1, r4 ldrb r0, [r7] strh r0, [r1, 0x8] - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldrb r2, [r7] ldr r1, [r0, 0x4] @@ -10015,7 +10015,7 @@ sub_805CD74: @ 805CD74 b _0805CE18 .pool _0805CDA4: - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldr r5, =gActiveBank ldrb r1, [r5] @@ -10083,7 +10083,7 @@ _0805CE18: thumb_func_start sub_805CE38 sub_805CE38: @ 805CE38 push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r3, =gActiveBank ldrb r1, [r3] @@ -10119,7 +10119,7 @@ _0805CE70: thumb_func_start sub_805CE80 sub_805CE80: @ 805CE80 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gActiveBank ldrb r3, [r0] @@ -10333,21 +10333,21 @@ _0805D054: beq _0805D07C b _0805D084 _0805D05A: - ldr r0, =gUnknown_020244AC + ldr r0, =gActionSelectionCursor adds r0, r3, r0 strb r2, [r0] - ldr r1, =gUnknown_020244B0 + ldr r1, =gMoveSelectionCursor ldrb r0, [r4] adds r0, r1 strb r2, [r0] b _0805D084 .pool _0805D074: - ldr r0, =gUnknown_020244AC + ldr r0, =gActionSelectionCursor b _0805D07E .pool _0805D07C: - ldr r0, =gUnknown_020244B0 + ldr r0, =gMoveSelectionCursor _0805D07E: adds r0, r3, r0 movs r1, 0 diff --git a/asm/battle_controller_player_partner.s b/asm/battle_controller_player_partner.s index 32e3ac5d1..0ddd2a924 100644 --- a/asm/battle_controller_player_partner.s +++ b/asm/battle_controller_player_partner.s @@ -132,7 +132,7 @@ _081BAEE8: thumb_func_start sub_81BAF00 sub_81BAF00: @ 81BAF00 push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r1, [r4] ldr r3, =gActiveBank ldrb r0, [r3] @@ -240,7 +240,7 @@ _081BAFD8: _081BAFE4: cmp r6, 0 beq _081BB00A - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r3, =gActiveBank ldrb r1, [r3] @@ -271,7 +271,7 @@ sub_81BB02C: @ 81BB02C mov r6, r9 mov r5, r8 push {r5-r7} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr mov r12, r0 ldr r0, [r0] ldr r7, =gActiveBank @@ -427,7 +427,7 @@ _081BB134: adds r0, r5 ldrb r0, [r0] bl sub_80729D0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r2, [r0, 0x8] ldrb r1, [r2, 0x9] @@ -1006,7 +1006,7 @@ sub_81BB688: @ 81BB688 lsls r0, 3 adds r2, r0, r1 ldrb r5, [r2, 0xC] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x4] lsls r0, r5, 1 @@ -1174,7 +1174,7 @@ _081BB808: thumb_func_start sub_81BB828 sub_81BB828: @ 81BB828 push {r4-r6,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r6, =gActiveBank ldrb r2, [r6] @@ -1312,7 +1312,7 @@ sub_81BB92C: @ 81BB92C bne _081BB97E adds r0, r3, 0 bl sub_805E408 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r2, [r4] ldr r1, [r0] @@ -1344,7 +1344,7 @@ _081BB97E: thumb_func_start dp01t_35_3_free_vram dp01t_35_3_free_vram: @ 81BB9A0 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gActiveBank ldrb r3, [r0] @@ -1383,7 +1383,7 @@ sub_81BB9F4: @ 81BB9F4 push {r4-r7,lr} mov r7, r8 push {r7} - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldr r7, =gActiveBank ldrb r1, [r7] @@ -1478,7 +1478,7 @@ _081BBAB0: thumb_func_start sub_81BBAE8 sub_81BBAE8: @ 81BBAE8 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldr r4, =gActiveBank ldrb r2, [r4] @@ -1596,7 +1596,7 @@ _081BBBF2: thumb_func_start sub_81BBC04 sub_81BBC04: @ 81BBC04 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -1620,7 +1620,7 @@ _081BBC26: thumb_func_start bx_80E8A6C bx_80E8A6C: @ 81BBC34 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -4051,7 +4051,7 @@ sub_81BD260: @ 81BD260 ldrb r3, [r0] cmp r3, 0 bne _081BD2A8 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x4] lsls r0, r2, 1 @@ -4101,7 +4101,7 @@ _081BD2DE: thumb_func_start sub_81BD2F0 sub_81BD2F0: @ 81BD2F0 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -4494,7 +4494,7 @@ sub_81BD5C8: @ 81BD5C8 thumb_func_start sub_81BD674 sub_81BD674: @ 81BD674 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -4743,7 +4743,7 @@ _081BD7A2: b _081BD8B6 .pool _081BD898: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r1, [r6] ldr r2, [r0, 0x4] @@ -4790,7 +4790,7 @@ bx_move_anim_3: @ 81BD8C8 adds r1, r2 ldrb r1, [r1] mov r8, r1 - ldr r7, =gUnknown_020244D0 + ldr r7, =gBattleSpritesDataPtr ldr r5, [r7] ldr r1, [r5, 0x4] lsls r0, r3, 1 @@ -4898,7 +4898,7 @@ _081BD98A: ands r0, r2 strb r0, [r1] _081BD9D8: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -4952,10 +4952,10 @@ _081BDA3C: thumb_func_start sub_81BDA4C sub_81BDA4C: @ 81BDA4C push {r4,lr} - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r4, =gActiveBank ldrb r0, [r4] @@ -5340,7 +5340,7 @@ sub_81BDD9C: @ 81BDD9C movs r2, 0x9 bl healthbar_draw_field_maybe ldrb r2, [r4] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x4] lsls r1, r2, 1 @@ -5880,7 +5880,7 @@ _081BE21A: adds r1, r4 ldrb r0, [r5] strh r0, [r1, 0x8] - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldrb r2, [r5] ldr r1, [r0, 0x4] @@ -6059,7 +6059,7 @@ dp01t_30_3_80EB11C: @ 81BE3D4 b _081BE478 .pool _081BE404: - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldr r5, =gActiveBank ldrb r1, [r5] @@ -6127,7 +6127,7 @@ _081BE478: thumb_func_start sub_81BE498 sub_81BE498: @ 81BE498 push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r3, =gActiveBank ldrb r1, [r3] @@ -6163,7 +6163,7 @@ _081BE4D0: thumb_func_start sub_81BE4E0 sub_81BE4E0: @ 81BE4E0 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gActiveBank ldrb r3, [r0] diff --git a/asm/battle_controller_recorded_opponent.s b/asm/battle_controller_recorded_opponent.s index cde1bc128..152dfca9c 100644 --- a/asm/battle_controller_recorded_opponent.s +++ b/asm/battle_controller_recorded_opponent.s @@ -157,7 +157,7 @@ _0818661A: thumb_func_start sub_8186630 sub_8186630: @ 8186630 push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r1, [r4] ldr r3, =gActiveBank ldrb r0, [r3] @@ -311,7 +311,7 @@ _0818676A: lsrs r3, r0, 24 cmp r3, 0x1 bne _08186816 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr mov r12, r0 ldr r0, [r0] ldrb r2, [r6] @@ -388,7 +388,7 @@ _0818676A: adds r0, r4, 0 bl FreeSpritePaletteByTag _08186816: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] mov r2, r8 ldrb r1, [r2] @@ -425,7 +425,7 @@ sub_818686C: @ 818686C movs r0, 0 mov r9, r0 mov r8, r0 - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r7, =gActiveBank ldrb r2, [r7] @@ -561,7 +561,7 @@ _08186964: ldrb r0, [r0] bl sub_80729D0 _08186994: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -575,7 +575,7 @@ _08186994: orrs r1, r2 strb r1, [r0, 0x1] _081869AE: - ldr r5, =gUnknown_020244D0 + ldr r5, =gBattleSpritesDataPtr ldr r0, [r5] ldr r4, =gActiveBank ldrb r2, [r4] @@ -639,7 +639,7 @@ _08186A40: lsls r2, 1 bl m4aMPlayVolumeControl _08186A4C: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -810,7 +810,7 @@ _08186B8A: lsrs r1, 16 adds r0, r5, 0 bl sub_805EE54 - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldr r2, [r0, 0x8] ldrb r1, [r2, 0x9] @@ -881,7 +881,7 @@ sub_8186C48: @ 8186C48 ldrsh r0, [r0, r1] cmp r0, 0 bne _08186CFA - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldr r1, [r0, 0x4] lsls r4, r3, 1 @@ -1009,7 +1009,7 @@ _08186D86: thumb_func_start sub_8186D9C sub_8186D9C: @ 8186D9C push {r4-r6,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r6, =gActiveBank ldrb r2, [r6] @@ -1147,7 +1147,7 @@ sub_8186EA4: @ 8186EA4 ldr r0, =SpriteCallbackDummy cmp r1, r0 bne _08186EF0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r3, 2 @@ -1179,7 +1179,7 @@ _08186EF0: thumb_func_start sub_8186F14 sub_8186F14: @ 8186F14 push {r4,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r4, =gActiveBank ldrb r1, [r4] @@ -1231,7 +1231,7 @@ _08186F6E: thumb_func_start sub_8186F94 sub_8186F94: @ 8186F94 push {r4-r7,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r5, =gActiveBank ldrb r2, [r5] @@ -1327,7 +1327,7 @@ _08187050: thumb_func_start sub_8187084 sub_8187084: @ 8187084 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -1411,7 +1411,7 @@ _08187120: thumb_func_start sub_818714C sub_818714C: @ 818714C push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -1435,7 +1435,7 @@ _0818716E: thumb_func_start sub_818717C sub_818717C: @ 818717C push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -3888,7 +3888,7 @@ sub_8188768: @ 8188768 ldrb r3, [r0] cmp r3, 0 bne _081887B0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x4] lsls r0, r2, 1 @@ -3940,7 +3940,7 @@ _081887EC: thumb_func_start sub_8188800 sub_8188800: @ 8188800 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -4278,7 +4278,7 @@ sub_8188A4C: @ 8188A4C thumb_func_start sub_8188AF8 sub_8188AF8: @ 8188AF8 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -4499,7 +4499,7 @@ _08188BE6: b _08188CFA .pool _08188CDC: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r1, [r6] ldr r2, [r0, 0x4] @@ -4546,7 +4546,7 @@ sub_8188D0C: @ 8188D0C adds r1, r2 ldrb r1, [r1] mov r8, r1 - ldr r7, =gUnknown_020244D0 + ldr r7, =gBattleSpritesDataPtr ldr r5, [r7] ldr r1, [r5, 0x4] lsls r0, r3, 1 @@ -4654,7 +4654,7 @@ _08188DCE: ands r0, r2 strb r0, [r1] _08188E1C: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -4708,10 +4708,10 @@ _08188E80: thumb_func_start sub_8188E90 sub_8188E90: @ 8188E90 push {r4,lr} - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r4, =gActiveBank ldrb r0, [r4] @@ -4983,7 +4983,7 @@ sub_81890CC: @ 81890CC movs r2, 0x9 bl healthbar_draw_field_maybe ldrb r2, [r4] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x4] lsls r1, r2, 1 @@ -5457,7 +5457,7 @@ sub_8189438: @ 8189438 adds r1, r4 ldrb r0, [r6] strh r0, [r1, 0x8] - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldrb r2, [r6] ldr r1, [r0, 0x4] @@ -5632,7 +5632,7 @@ sub_8189648: @ 8189648 b _08189742 .pool _08189678: - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r3, =gActiveBank ldrb r1, [r3] @@ -5699,7 +5699,7 @@ _081896E4: adds r1, r2 movs r3, 0 strb r0, [r1] - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldrb r1, [r5] ldr r2, [r0, 0x4] @@ -5739,7 +5739,7 @@ _08189742: thumb_func_start sub_818975C sub_818975C: @ 818975C push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r3, =gActiveBank ldrb r1, [r3] @@ -5775,7 +5775,7 @@ _08189794: thumb_func_start sub_81897A4 sub_81897A4: @ 81897A4 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gActiveBank ldrb r3, [r0] diff --git a/asm/battle_controller_recorded_player.s b/asm/battle_controller_recorded_player.s index f24cf8c4a..a2ea742b7 100644 --- a/asm/battle_controller_recorded_player.s +++ b/asm/battle_controller_recorded_player.s @@ -132,7 +132,7 @@ _08189A40: thumb_func_start sub_8189A58 sub_8189A58: @ 8189A58 push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r1, [r4] ldr r3, =gActiveBank ldrb r0, [r3] @@ -244,7 +244,7 @@ _08189B42: bne _08189B48 b _08189D18 _08189B48: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr mov r9, r0 ldr r0, [r0] ldr r5, =gActiveBank @@ -435,7 +435,7 @@ _08189CE6: _08189CF2: cmp r6, 0 beq _08189D18 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r3, =gActiveBank ldrb r1, [r3] @@ -478,7 +478,7 @@ sub_8189D40: @ 8189D40 lsls r0, 24 cmp r0, 0 bne _08189DBE - ldr r5, =gUnknown_020244D0 + ldr r5, =gBattleSpritesDataPtr ldr r0, [r5] ldrb r2, [r4] ldr r1, [r0, 0x4] @@ -527,7 +527,7 @@ _08189D8C: adds r0, r3, 0 bl sub_8172EF0 _08189DBE: - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldr r2, =gActiveBank ldrb r5, [r2] @@ -621,7 +621,7 @@ _08189E54: ldrb r0, [r0] bl sub_80729D0 _08189E84: - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r3, =gActiveBank ldrb r1, [r3] @@ -702,7 +702,7 @@ _08189F38: lsls r2, 1 bl m4aMPlayVolumeControl _08189F44: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -779,7 +779,7 @@ _08189FC8: ldr r1, =gSprites adds r0, r1 bl DestroySprite - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldr r2, [r0, 0x8] ldrb r1, [r2, 0x9] @@ -975,7 +975,7 @@ _0818A190: thumb_func_start sub_818A1B0 sub_818A1B0: @ 818A1B0 push {r4-r6,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r6, =gActiveBank ldrb r2, [r6] @@ -1113,7 +1113,7 @@ sub_818A2B4: @ 818A2B4 bne _0818A306 adds r0, r3, 0 bl sub_805E408 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r2, [r4] ldr r1, [r0] @@ -1145,7 +1145,7 @@ _0818A306: thumb_func_start sub_818A328 sub_818A328: @ 818A328 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gActiveBank ldrb r3, [r0] @@ -1184,7 +1184,7 @@ sub_818A37C: @ 818A37C push {r4-r7,lr} mov r7, r8 push {r7} - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldr r7, =gActiveBank ldrb r1, [r7] @@ -1279,7 +1279,7 @@ _0818A438: thumb_func_start sub_818A470 sub_818A470: @ 818A470 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldr r4, =gActiveBank ldrb r2, [r4] @@ -1397,7 +1397,7 @@ _0818A57A: thumb_func_start sub_818A58C sub_818A58C: @ 818A58C push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -1421,7 +1421,7 @@ _0818A5AE: thumb_func_start sub_818A5BC sub_818A5BC: @ 818A5BC push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -3852,7 +3852,7 @@ sub_818BBE8: @ 818BBE8 ldrb r3, [r0] cmp r3, 0 bne _0818BC30 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x4] lsls r0, r2, 1 @@ -3902,7 +3902,7 @@ _0818BC66: thumb_func_start sub_818BC78 sub_818BC78: @ 818BC78 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -4350,7 +4350,7 @@ sub_818BFB8: @ 818BFB8 thumb_func_start sub_818C064 sub_818C064: @ 818C064 push {r4-r6,lr} - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, =gActiveBank ldrb r2, [r5] @@ -4599,7 +4599,7 @@ _0818C192: b _0818C2A6 .pool _0818C288: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r1, [r6] ldr r2, [r0, 0x4] @@ -4646,7 +4646,7 @@ bx_move_anim_2: @ 818C2B8 adds r1, r2 ldrb r1, [r1] mov r8, r1 - ldr r7, =gUnknown_020244D0 + ldr r7, =gBattleSpritesDataPtr ldr r5, [r7] ldr r1, [r5, 0x4] lsls r0, r3, 1 @@ -4754,7 +4754,7 @@ _0818C37A: ands r0, r2 strb r0, [r1] _0818C3C8: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -4808,10 +4808,10 @@ _0818C42C: thumb_func_start sub_818C43C sub_818C43C: @ 818C43C push {r4,lr} - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r4, =gActiveBank ldrb r0, [r4] @@ -5134,7 +5134,7 @@ sub_818C6F4: @ 818C6F4 movs r2, 0x9 bl healthbar_draw_field_maybe ldrb r2, [r4] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x4] lsls r1, r2, 1 @@ -5676,7 +5676,7 @@ _0818CB5A: adds r1, r4 ldrb r0, [r5] strh r0, [r1, 0x8] - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldrb r2, [r5] ldr r1, [r0, 0x4] @@ -5855,7 +5855,7 @@ sub_818CD30: @ 818CD30 b _0818CDD4 .pool _0818CD60: - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r0, [r6] ldr r5, =gActiveBank ldrb r1, [r5] @@ -5923,7 +5923,7 @@ _0818CDD4: thumb_func_start bx_increment_dp11b_field_5_till_x60_then_resume bx_increment_dp11b_field_5_till_x60_then_resume: @ 818CDF4 push {r4,lr} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r3, =gActiveBank ldrb r1, [r3] @@ -5959,7 +5959,7 @@ _0818CE2C: thumb_func_start sub_818CE3C sub_818CE3C: @ 818CE3C push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] ldr r0, =gActiveBank ldrb r3, [r0] diff --git a/asm/battle_controller_safari.s b/asm/battle_controller_safari.s index a8187d642..a5acca8c1 100644 --- a/asm/battle_controller_safari.s +++ b/asm/battle_controller_safari.s @@ -71,7 +71,7 @@ bx_battle_menu_t6_2: @ 81593D8 beq _08159446 movs r0, 0x5 bl PlaySE - ldr r1, =gUnknown_020244AC + ldr r1, =gActionSelectionCursor ldr r0, =gActiveBank ldrb r0, [r0] adds r0, r1 @@ -118,7 +118,7 @@ _08159446: ands r0, r1 cmp r0, 0 beq _08159484 - ldr r5, =gUnknown_020244AC + ldr r5, =gActionSelectionCursor ldr r4, =gActiveBank ldrb r0, [r4] adds r0, r5 @@ -144,7 +144,7 @@ _08159484: ands r0, r1 cmp r0, 0 beq _081594C0 - ldr r5, =gUnknown_020244AC + ldr r5, =gActionSelectionCursor ldr r4, =gActiveBank ldrb r0, [r4] adds r0, r5 @@ -170,7 +170,7 @@ _081594C0: ands r0, r1 cmp r0, 0 beq _0815950C - ldr r5, =gUnknown_020244AC + ldr r5, =gActionSelectionCursor ldr r4, =gActiveBank ldrb r0, [r4] adds r0, r5 @@ -204,7 +204,7 @@ _0815950C: ands r0, r1 cmp r0, 0 beq _0815954E - ldr r5, =gUnknown_020244AC + ldr r5, =gActionSelectionCursor ldr r4, =gActiveBank ldrb r0, [r4] adds r0, r5 @@ -318,7 +318,7 @@ sub_81595E4: @ 81595E4 negs r0, r0 ands r0, r1 strb r0, [r3] - ldr r0, =gUnknown_03005D00 + ldr r0, =gPreBattleCallback1 ldr r0, [r0] str r0, [r2] ldr r0, [r2, 0x8] @@ -336,7 +336,7 @@ bx_wait_t6: @ 8159624 ldrb r0, [r0] cmp r0, 0 beq _0815964A - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -410,7 +410,7 @@ _081596BE: thumb_func_start sub_81596D4 sub_81596D4: @ 81596D4 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -484,7 +484,7 @@ _0815976A: thumb_func_start bx_80364D0 bx_80364D0: @ 815977C push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -689,7 +689,7 @@ sub_8159904: @ 8159904 thumb_func_start sub_8159910 sub_8159910: @ 8159910 push {r4,r5,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x8] movs r0, 0x4 @@ -730,7 +730,7 @@ sub_8159964: @ 8159964 adds r1, 0x1 adds r0, r1 ldrb r1, [r0] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] strb r1, [r0, 0x8] @@ -778,10 +778,10 @@ sub_81599D0: @ 81599D0 thumb_func_start dp01t_10_6_message dp01t_10_6_message: @ 81599DC push {r4,lr} - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r4, =gActiveBank ldrb r0, [r4] @@ -832,9 +832,9 @@ sub_8159A54: @ 8159A54 lsrs r1, r0, 24 cmp r1, 0 bne _08159A7A - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X strh r1, [r0] - ldr r1, =gUnknown_02022E16 + ldr r1, =gBattle_BG0_Y movs r0, 0xA0 strh r0, [r1] ldr r1, =gBattleBankFunc @@ -871,7 +871,7 @@ _08159AAE: adds r4, 0x1 cmp r4, 0x3 ble _08159AAE - ldr r1, =gUnknown_020244AC + ldr r1, =gActionSelectionCursor ldr r0, =gActiveBank ldrb r0, [r0] adds r0, r1 diff --git a/asm/battle_controller_wally.s b/asm/battle_controller_wally.s index 9f3b4ce56..64c8b4442 100644 --- a/asm/battle_controller_wally.s +++ b/asm/battle_controller_wally.s @@ -324,7 +324,7 @@ sub_816864C: @ 816864C push {r4-r7,lr} mov r7, r8 push {r7} - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r5, =gActiveBank ldrb r2, [r5] @@ -500,7 +500,7 @@ _0816877A: adds r0, r5 ldrb r0, [r0] bl sub_80729D0 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r2, [r0, 0x8] ldrb r1, [r2, 0x9] @@ -549,7 +549,7 @@ sub_8168818: @ 8168818 _08168842: cmp r4, 0 beq _08168904 - ldr r7, =gUnknown_020244D0 + ldr r7, =gBattleSpritesDataPtr ldr r0, [r7] ldr r4, [r0, 0x4] lsls r0, r3, 1 @@ -761,7 +761,7 @@ _08168A1A: thumb_func_start sub_8168A20 sub_8168A20: @ 8168A20 push {r4-r6,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r6, =gActiveBank ldrb r2, [r6] @@ -833,7 +833,7 @@ _08168AB4: thumb_func_start sub_8168AC8 sub_8168AC8: @ 8168AC8 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -907,7 +907,7 @@ _08168B5E: thumb_func_start sub_8168B70 sub_8168B70: @ 8168B70 push {lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r2, [r0] ldr r0, =gActiveBank ldrb r1, [r0] @@ -3221,7 +3221,7 @@ sub_816A078: @ 816A078 thumb_func_start sub_816A084 sub_816A084: @ 816A084 push {r4,r5,lr} - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x8] movs r0, 0x4 @@ -3262,7 +3262,7 @@ sub_816A0D8: @ 816A0D8 adds r1, 0x1 adds r0, r1 ldrb r1, [r0] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] strb r1, [r0, 0x8] @@ -3407,7 +3407,7 @@ sub_816A144: @ 816A144 b _0816A25A .pool _0816A23C: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldrb r1, [r6] ldr r2, [r0, 0x4] @@ -3449,7 +3449,7 @@ bx_move_anim_5: @ 816A26C ldrb r0, [r1] lsls r0, 8 orrs r4, r0 - ldr r7, =gUnknown_020244D0 + ldr r7, =gBattleSpritesDataPtr ldr r5, [r7] ldr r1, [r5, 0x4] lsls r0, r3, 1 @@ -3592,10 +3592,10 @@ _0816A3AC: thumb_func_start sub_816A3B8 sub_816A3B8: @ 816A3B8 push {r4,lr} - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r4, =gActiveBank ldrb r0, [r4] @@ -3646,9 +3646,9 @@ sub_816A430: @ 816A430 lsrs r1, r0, 24 cmp r1, 0 bne _0816A456 - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X strh r1, [r0] - ldr r1, =gUnknown_02022E16 + ldr r1, =gBattle_BG0_Y movs r0, 0xA0 strh r0, [r1] ldr r1, =gBattleBankFunc @@ -3685,7 +3685,7 @@ _0816A48A: adds r4, 0x1 cmp r4, 0x3 ble _0816A48A - ldr r1, =gUnknown_020244AC + ldr r1, =gActionSelectionCursor ldr r0, =gActiveBank ldrb r0, [r0] adds r0, r1 @@ -3749,9 +3749,9 @@ _0816A522: lsrs r1, r0, 24 cmp r1, 0 bne _0816A574 - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X strh r1, [r0] - ldr r1, =gUnknown_02022E16 + ldr r1, =gBattle_BG0_Y movs r2, 0xA0 lsls r2, 1 adds r0, r2, 0 @@ -4342,7 +4342,7 @@ sub_816A90C: @ 816A90C adds r1, r4 ldrb r0, [r7] strh r0, [r1, 0x8] - ldr r3, =gUnknown_020244D0 + ldr r3, =gBattleSpritesDataPtr ldr r0, [r3] ldrb r2, [r7] ldr r1, [r0, 0x4] @@ -4393,7 +4393,7 @@ sub_816AA80: @ 816AA80 adds r6, r0, 0 lsls r6, 24 lsrs r6, 24 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r6, 2 @@ -4622,7 +4622,7 @@ sub_816AC78: @ 816AC78 b _0816ACE6 .pool _0816ACA8: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r5, =gActiveBank ldrb r1, [r5] diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index e870c8798..4c44855f9 100755 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -3161,9 +3161,9 @@ _0819044E: ldr r0, =gUnknown_0860CEB4 bl InitWindows bl DeactivateAllTextPrinters - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X strh r4, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r4, [r0] ldr r0, =gBattle_BG1_X strh r4, [r0] @@ -3171,7 +3171,7 @@ _0819044E: strh r4, [r0] ldr r0, =gBattle_BG3_X strh r4, [r0] - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y strh r4, [r0] mov r2, r9 cmp r2, 0x2 @@ -4366,10 +4366,10 @@ _08190E98: ldrsh r2, [r0, r5] cmp r2, 0 beq _08190ED4 - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r0, =gBattle_BG1_X strh r1, [r0] @@ -4379,9 +4379,9 @@ _08190E98: b _08190EE6 .pool _08190ED4: - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X strh r2, [r0] - ldr r1, =gUnknown_02022E16 + ldr r1, =gBattle_BG0_Y movs r0, 0xA0 strh r0, [r1] ldr r0, =gBattle_BG1_X @@ -4765,10 +4765,10 @@ _08191234: ldrsh r2, [r0, r5] cmp r2, 0 beq _08191278 - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r0, =gBattle_BG1_X strh r1, [r0] @@ -4779,9 +4779,9 @@ _08191234: b _0819128C .pool _08191278: - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X strh r2, [r0] - ldr r1, =gUnknown_02022E16 + ldr r1, =gBattle_BG0_Y ldr r3, =0x0000ff60 adds r0, r3, 0 strh r0, [r1] @@ -5157,10 +5157,10 @@ _081915CC: ldrsh r2, [r0, r5] cmp r2, 0 beq _0819160C - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r2, =gBattle_BG1_X movs r6, 0x80 @@ -5172,12 +5172,12 @@ _081915CC: b _08191622 .pool _0819160C: - ldr r1, =gUnknown_02022E14 + ldr r1, =gBattle_BG0_X movs r3, 0x80 lsls r3, 1 adds r0, r3, 0 strh r0, [r1] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r2, [r0] ldr r0, =gBattle_BG1_X strh r2, [r0] @@ -5457,10 +5457,10 @@ _0819187C: ldrsh r2, [r0, r5] cmp r2, 0 beq _081918BC - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r2, =gBattle_BG1_X movs r6, 0x80 @@ -5472,12 +5472,12 @@ _0819187C: b _081918D2 .pool _081918BC: - ldr r1, =gUnknown_02022E14 + ldr r1, =gBattle_BG0_X movs r3, 0x80 lsls r3, 1 adds r0, r3, 0 strh r0, [r1] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r2, [r0] ldr r0, =gBattle_BG1_X strh r2, [r0] @@ -5744,10 +5744,10 @@ _08191B08: ldrsh r2, [r0, r5] cmp r2, 0 beq _08191B48 - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r2, =gBattle_BG1_X movs r6, 0xFF @@ -5759,12 +5759,12 @@ _08191B08: b _08191B5E .pool _08191B48: - ldr r1, =gUnknown_02022E14 + ldr r1, =gBattle_BG0_X movs r3, 0xFF lsls r3, 8 adds r0, r3, 0 strh r0, [r1] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r2, [r0] ldr r0, =gBattle_BG1_X strh r2, [r0] @@ -6011,10 +6011,10 @@ _08191D68: ldrsh r2, [r0, r5] cmp r2, 0 beq _08191DA8 - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r2, =gBattle_BG1_X movs r6, 0xFF @@ -6026,12 +6026,12 @@ _08191D68: b _08191DBE .pool _08191DA8: - ldr r1, =gUnknown_02022E14 + ldr r1, =gBattle_BG0_X movs r3, 0xFF lsls r3, 8 adds r0, r3, 0 strh r0, [r1] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r2, [r0] ldr r0, =gBattle_BG1_X strh r2, [r0] @@ -6306,7 +6306,7 @@ _08191FF8: asrs r0, 16 cmp r0, 0x29 beq _08192100 - ldr r1, =gUnknown_02022E16 + ldr r1, =gBattle_BG0_Y ldrh r0, [r1] subs r0, 0x4 strh r0, [r1] @@ -6331,7 +6331,7 @@ _08192038: asrs r0, 16 cmp r0, 0x29 beq _08192100 - ldr r1, =gUnknown_02022E16 + ldr r1, =gBattle_BG0_Y ldrh r0, [r1] adds r0, 0x4 strh r0, [r1] @@ -6356,7 +6356,7 @@ _08192078: asrs r0, 16 cmp r0, 0x41 beq _08192100 - ldr r1, =gUnknown_02022E14 + ldr r1, =gBattle_BG0_X ldrh r0, [r1] subs r0, 0x4 strh r0, [r1] @@ -6385,7 +6385,7 @@ _081920BC: asrs r0, 16 cmp r0, 0x41 beq _08192100 - ldr r1, =gUnknown_02022E14 + ldr r1, =gBattle_BG0_X ldrh r0, [r1] adds r0, 0x4 strh r0, [r1] @@ -10400,9 +10400,9 @@ _0819427C: ldr r0, =gUnknown_0860CE94 bl InitWindows bl DeactivateAllTextPrinters - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X strh r4, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r4, [r0] ldr r0, =gBattle_BG1_X strh r4, [r0] @@ -11358,11 +11358,11 @@ sub_8194B70: @ 8194B70 movs r1, 0x80 movs r2, 0x2 bl ChangeBgY - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X ldrh r1, [r0] movs r0, 0x10 bl SetGpuReg - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y ldrh r1, [r0] movs r0, 0x12 bl SetGpuReg @@ -11486,11 +11486,11 @@ _08194CD4: thumb_func_start sub_8194CE4 sub_8194CE4: @ 8194CE4 push {lr} - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X ldrh r1, [r0] movs r0, 0x10 bl SetGpuReg - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y ldrh r1, [r0] movs r0, 0x12 bl SetGpuReg diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index 36898e456..de5617167 100755 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -18768,7 +18768,7 @@ _081A43EE: sub_81A4410: @ 81A4410 push {r4,lr} ldr r4, =gScriptResult - bl sub_8185338 + bl MoveRecordedBattleToSaveData strh r0, [r4] ldr r0, =gSaveBlock2Ptr ldr r1, [r0] @@ -20533,10 +20533,10 @@ _081A52A4: lsls r1, 1 movs r2, 0x20 bl LoadCompressedPalette - ldr r1, =gUnknown_02022E24 + ldr r1, =gBattle_WIN0H movs r0, 0xFF strh r0, [r1] - ldr r1, =gUnknown_02022E26 + ldr r1, =gBattle_WIN0V movs r0, 0x70 strh r0, [r1] b _081A553E diff --git a/asm/battle_interface.s b/asm/battle_interface.s index 31ad9a330..d9bb3d8cc 100755 --- a/asm/battle_interface.s +++ b/asm/battle_interface.s @@ -780,7 +780,7 @@ sub_807294C: @ 807294C ldr r7, [sp, 0x14] lsls r0, 24 lsrs r0, 24 - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr ldr r4, [r6] ldr r5, [r4, 0xC] lsls r4, r0, 2 @@ -1317,7 +1317,7 @@ _08072D86: movs r2, 0x1 movs r3, 0x3 bl ConvertIntToDecimalStringN - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r0, [r0] movs r1, 0xBA lsls r1, 1 @@ -1333,7 +1333,7 @@ _08072D86: lsls r0, 2 adds r5, r0, r1 _08072DB8: - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r0, [r0] movs r1, 0xBA lsls r1, 1 @@ -1398,7 +1398,7 @@ sub_8072E0C: @ 8072E0C lsls r0, 24 cmp r0, 0 bne _08072F28 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r1, [r0] movs r2, 0x3A ldrsh r0, [r7, r2] @@ -1500,7 +1500,7 @@ _08072F28: lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x2C] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] ldr r2, [sp, 0x2C] @@ -1536,7 +1536,7 @@ _08072F52: ldr r1, =gText_Slash bl StringCopy _08072F82: - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r0, [r0] movs r1, 0xBA lsls r1, 1 @@ -1556,7 +1556,7 @@ _08072F82: _08072FA6: cmp r4, 0x2 bhi _08072FF0 - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r0, [r0] movs r2, 0xBA lsls r2, 1 @@ -1579,7 +1579,7 @@ _08072FA6: b _0807301A .pool _08072FF0: - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r0, [r0] movs r1, 0xBA lsls r1, 1 @@ -1609,7 +1609,7 @@ _08073024: mov r3, r8 cmp r3, 0 bne _08073084 - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r0, [r0] movs r1, 0xBA lsls r1, 1 @@ -1702,7 +1702,7 @@ sub_80730D4: @ 80730D4 lsls r0, 24 lsrs r0, 24 bl GetBankIdentity - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r2, [r1] movs r3, 0xBA lsls r3, 1 @@ -1877,7 +1877,7 @@ _08073236: strb r0, [r1, 0x5] movs r0, 0xBA strb r0, [r1, 0x8] - ldr r5, =gBattleSpritesGfx + ldr r5, =gMonSpritesGfxPtr ldr r0, [r5] movs r2, 0xBA lsls r2, 1 @@ -2004,7 +2004,7 @@ _0807336A: bne _08073382 b _080735A8 _08073382: - ldr r5, =gUnknown_020244D0 + ldr r5, =gBattleSpritesDataPtr ldr r0, [r5] ldr r3, [r0] mov r0, r9 @@ -2988,7 +2988,7 @@ _08073BC6: ldr r2, [sp, 0x10] cmp r2, 0 beq _08073C0A - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r3, [r0, 0x8] ldrb r2, [r3, 0x9] @@ -3311,7 +3311,7 @@ sub_8073E64: @ 8073E64 bne _08073F54 ldrb r5, [r4, 0xA] movs r4, 0 - ldr r6, =gUnknown_020244D0 + ldr r6, =gBattleSpritesDataPtr adds r0, r7, 0 adds r0, 0xE adds r2, r3, r0 @@ -3406,7 +3406,7 @@ _08073F54: negs r0, r0 cmp r1, r0 bne _08073F8A - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x4] lsls r1, r2, 1 @@ -3516,7 +3516,7 @@ _08074034: negs r0, r0 cmp r2, r0 bne _0807406A - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x4] lsls r1, r5, 1 @@ -4140,7 +4140,7 @@ _08074542: adds r4, 0x1 cmp r4, 0x2 ble _08074542 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] adds r0, r7, r0 @@ -4222,7 +4222,7 @@ _080745B8: cmp r0, 0x1 bne _08074672 _08074626: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r7, 2 @@ -4760,7 +4760,7 @@ sub_8074AA0: @ 8074AA0 mov r9, r2 cmp r2, 0 bne _08074AEC - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0xC] mov r1, r8 @@ -4782,7 +4782,7 @@ sub_8074AA0: @ 8074AA0 b _08074B48 .pool _08074AEC: - ldr r2, =gUnknown_020244D0 + ldr r2, =gBattleSpritesDataPtr mov r10, r2 ldr r0, [r2] ldr r2, [r0, 0xC] @@ -4833,7 +4833,7 @@ _08074B48: beq _08074B64 cmp r2, 0 bne _08074B6C - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] adds r0, r7, r0 @@ -4851,7 +4851,7 @@ _08074B6C: negs r0, r0 cmp r4, r0 bne _08074B86 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0xC] mov r2, r8 @@ -4890,7 +4890,7 @@ sub_8074B9C: @ 8074B9C beq _08074CA0 b _08074D9E _08074BB8: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0xC] lsls r5, r6, 2 @@ -4924,7 +4924,7 @@ _08074BF4: ldr r0, =gSprites mov r8, r0 _08074BFA: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0xC] adds r0, r7, r6 @@ -4995,7 +4995,7 @@ _08074C8A: b _08074D9E .pool _08074CA0: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0xC] lsls r5, r6, 2 @@ -5055,7 +5055,7 @@ _08074D02: ldrb r1, [r1] lsls r1, 5 adds r0, r1 - ldr r1, =gUnknown_020244D0 + ldr r1, =gBattleSpritesDataPtr ldr r1, [r1] ldr r1, [r1, 0xC] adds r1, r4, r1 @@ -5086,7 +5086,7 @@ _08074D5C: ldrb r1, [r1] lsls r1, 5 adds r0, r1 - ldr r1, =gUnknown_020244D0 + ldr r1, =gBattleSpritesDataPtr ldr r1, [r1] ldr r1, [r1, 0xC] adds r1, r4, r1 diff --git a/asm/battle_link_817C95C.s b/asm/battle_link_817C95C.s index 94ae7ad7f..39ae59d8b 100644 --- a/asm/battle_link_817C95C.s +++ b/asm/battle_link_817C95C.s @@ -4322,7 +4322,7 @@ _0817EF36: b _0817F1FA _0817EF44: ldr r3, =gBattleMoves - ldr r2, =gUnknown_020244B0 + ldr r2, =gMoveSelectionCursor adds r0, r4, r2 ldrb r0, [r0] lsls r0, 1 @@ -4514,7 +4514,7 @@ _0817F0B4: ble _0817EFC2 movs r5, 0 ldr r3, =gBankAttacker - ldr r6, =gUnknown_020244B0 + ldr r6, =gMoveSelectionCursor ldr r4, =gBattlePartyID mov r8, r4 movs r7, 0x64 @@ -4624,7 +4624,7 @@ _0817F1D4: b _0817F0CC _0817F1DC: ldr r2, =gBattleMoveDamage - ldr r1, =gUnknown_020244B0 + ldr r1, =gMoveSelectionCursor ldr r0, =gBankAttacker ldrb r0, [r0] adds r0, r1 diff --git a/asm/battle_message.s b/asm/battle_message.s index 96869a350..b114a36f8 100644 --- a/asm/battle_message.s +++ b/asm/battle_message.s @@ -738,7 +738,7 @@ _0814E730: ldr r5, [sp] ldr r4, [sp, 0x4] movs r3, 0 - ldr r2, =gUnknown_0831BCA8 + ldr r2, =gStatusConditionStringsTable _0814E738: ldr r1, [r2] ldr r0, [r1] @@ -2998,7 +2998,7 @@ sub_814FBAC: @ 814FBAC ldr r0, =gBattleBufferA + 4 adds r1, r0 ldr r4, =gUnknown_08D85620 - ldr r0, =gUnknown_020244B0 + ldr r0, =gMoveSelectionCursor adds r2, r0 ldrb r2, [r2] adds r0, r1, 0 diff --git a/asm/battle_setup.s b/asm/battle_setup.s index c2c762e96..fcc0de95b 100644 --- a/asm/battle_setup.s +++ b/asm/battle_setup.s @@ -41,7 +41,7 @@ _080B062E: cmp r0, 0x1 bne _080B0652 bl overworld_free_bg_tilemaps - ldr r0, =sub_8036760 + ldr r0, =CB2_InitBattle bl SetMainCallback2 bl prev_quest_postbuffer_cursor_backup_reset bl overworld_poison_timer_set @@ -638,8 +638,8 @@ _080B0BC6: .pool thumb_func_end sub_80B0B6C - thumb_func_start sub_80B0BD0 -sub_80B0BD0: @ 80B0BD0 + thumb_func_start BattleSetup_GetTerrainId +BattleSetup_GetTerrainId: @ 80B0BD0 push {r4,r5,lr} sub sp, 0x4 mov r4, sp @@ -798,7 +798,7 @@ _080B0D1A: pop {r4,r5} pop {r1} bx r1 - thumb_func_end sub_80B0BD0 + thumb_func_end BattleSetup_GetTerrainId thumb_func_start sub_80B0D24 sub_80B0D24: @ 80B0D24 @@ -1387,7 +1387,7 @@ sub_80B11A8: @ 80B11A8 ldr r0, =sub_80B1204 str r0, [r1, 0x8] bl FreeAllWindowBuffers - ldr r0, =sub_8036760 + ldr r0, =CB2_InitBattle bl SetMainCallback2 bl prev_quest_postbuffer_cursor_backup_reset bl overworld_poison_timer_set diff --git a/asm/battle_tower.s b/asm/battle_tower.s index 0782b8609..eb91121ae 100755 --- a/asm/battle_tower.s +++ b/asm/battle_tower.s @@ -3194,7 +3194,7 @@ sub_8163A8C: @ 8163A8C ldr r0, =gMain ldr r1, =sub_81639AC str r1, [r0, 0x8] - ldr r0, =sub_8036760 + ldr r0, =CB2_InitBattle bl SetMainCallback2 adds r0, r4, 0 bl DestroyTask @@ -5125,21 +5125,21 @@ _08164C18: lsrs r0, 24 mov r1, sp movs r2, 0x4 - bl link_0800A448 + bl SendBlock ldr r1, =gScriptResult movs r0, 0x1 b _08164DB4 .pool _08164C3C: - bl sub_800A550 + bl GetBlockReceivedStatus movs r1, 0x3 ands r1, r0 cmp r1, 0x3 beq _08164C4A b _08164DB6 _08164C4A: - bl sub_800A5B4 - ldr r1, =gUnknown_020223C4 + bl ResetBlockReceivedFlags + ldr r1, =gBlockRecvBuffer movs r0, 0x80 lsls r0, 1 adds r2, r1, r0 @@ -5221,23 +5221,23 @@ _08164CE0: ldr r3, =0x00000cb4 adds r1, r3 movs r2, 0x28 - bl link_0800A448 + bl SendBlock ldr r1, =gScriptResult movs r0, 0x3 b _08164DB4 .pool _08164D14: - bl sub_800A550 + bl GetBlockReceivedStatus movs r1, 0x3 ands r1, r0 cmp r1, 0x3 bne _08164DB6 - bl sub_800A5B4 + bl ResetBlockReceivedFlags ldr r4, =gSaveBlock2Ptr ldr r0, [r4] ldr r5, =0x00000cb4 adds r0, r5 - ldr r1, =gUnknown_020223C4 + ldr r1, =gBlockRecvBuffer movs r2, 0x28 bl memcpy ldr r2, =gTrainerBattleOpponent_A @@ -5260,7 +5260,7 @@ _08164D14: ldrh r0, [r4] movs r1, 0x1 bl sub_8162614 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _08164DB0 @@ -5279,7 +5279,7 @@ _08164D98: b _08164DB4 .pool _08164DA8: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _08164DB6 diff --git a/asm/battle_transition.s b/asm/battle_transition.s index 6406a3f24..a6e44f087 100644 --- a/asm/battle_transition.s +++ b/asm/battle_transition.s @@ -9513,11 +9513,11 @@ sub_814ABE4: @ 814ABE4 strh r0, [r6, 0xC] cmp r0, 0 bne _0814AC24 - ldr r5, =gUnknown_02022E14 + ldr r5, =gBattle_BG0_X ldrh r1, [r5] movs r0, 0x12 bl SetGpuReg - ldr r4, =gUnknown_02022E16 + ldr r4, =gBattle_BG0_Y ldrh r1, [r4] movs r0, 0x10 bl SetGpuReg @@ -9562,9 +9562,9 @@ sub_814AC38: @ 814AC38 movs r1, 0xF0 movs r2, 0x20 bl LoadPalette - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X strh r5, [r0] - ldr r4, =gUnknown_02022E16 + ldr r4, =gBattle_BG0_Y strh r5, [r4] movs r0, 0x12 movs r1, 0 @@ -9781,10 +9781,10 @@ sub_814AE40: @ 814AE40 push {r4,r5,lr} sub sp, 0x8 adds r5, r0, 0 - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r4, =gUnknown_02022E16 + ldr r4, =gBattle_BG0_Y strh r1, [r4] movs r0, 0x12 movs r1, 0 diff --git a/asm/berry_blender.s b/asm/berry_blender.s index 0599fa153..277a49d2f 100644 --- a/asm/berry_blender.s +++ b/asm/berry_blender.s @@ -512,7 +512,7 @@ _0807FBBE: adds r4, 0x1 cmp r4, 0x3 ble _0807FBBE - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _0807FC14 @@ -1116,7 +1116,7 @@ _08080126: adds r5, 0x1 cmp r5, 0x3 ble _08080126 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0808016A @@ -1213,7 +1213,7 @@ _08080248: bne _08080254 b _08080546 _08080254: - bl sub_800A5B4 + bl ResetBlockReceivedFlags bl GetMultiplayerId lsls r0, 24 cmp r0, 0 @@ -1239,7 +1239,7 @@ _08080282: movs r0, 0x4 movs r1, 0x1 bl sub_8197DF8 - bl sub_800A550 + bl GetBlockReceivedStatus adds r4, r0, 0 bl sub_800A9D8 lsls r4, 24 @@ -1260,7 +1260,7 @@ _080802AC: adds r0, r4, r0 adds r0, r6 lsls r1, r5, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0x10 bl memcpy @@ -1280,7 +1280,7 @@ _080802D4: lsrs r0, 24 cmp r5, r0 blt _080802AC - bl sub_800A5B4 + bl ResetBlockReceivedFlags b _080804F8 .pool _080802EC: @@ -1876,7 +1876,7 @@ sub_80807BC: @ 80807BC sub sp, 0x1C movs r0, 0 mov r10, r0 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080807DE @@ -3330,7 +3330,7 @@ sub_80814B0: @ 80814B0 lsrs r1, 16 lsls r2, 16 lsrs r2, 16 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080814E4 @@ -3633,7 +3633,7 @@ sub_8081744: @ 8081744 push {r4-r6,lr} movs r4, 0 movs r6, 0 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _0808175A @@ -4702,7 +4702,7 @@ _08081F7C: sub_8081F94: @ 8081F94 push {lr} adds r1, r0, 0 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _08081FB8 @@ -4810,7 +4810,7 @@ _08082078: adds r1, 0x4C movs r0, 0 strh r0, [r1] - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080820B0 @@ -4848,7 +4848,7 @@ _080820E0: bne _080820EC b _0808249E _080820EC: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _0808218C @@ -4911,7 +4911,7 @@ _08082132: adds r1, r4 movs r0, 0 movs r2, 0x20 - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 bne _08082172 @@ -4941,7 +4941,7 @@ _0808218C: strh r2, [r0] movs r0, 0 movs r2, 0x28 - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 bne _080821BE @@ -4951,20 +4951,20 @@ _080821BE: b _0808245C .pool _080821C8: - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 cmp r0, 0 bne _080821D4 b _0808249E _080821D4: - bl sub_800A5B4 + bl ResetBlockReceivedFlags ldr r5, =gUnknown_020322A4 ldr r1, [r5] adds r1, 0x63 ldrb r0, [r1] adds r0, 0x1 strb r0, [r1] - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _08082254 @@ -4972,7 +4972,7 @@ _080821D4: ldrb r0, [r0] cmp r0, 0 beq _08082254 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer ldr r3, [r5] ldrh r0, [r2, 0x4] adds r1, r3, 0 @@ -5016,7 +5016,7 @@ _08082220: b _0808249E .pool _08082254: - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer ldr r0, =gUnknown_020322A4 ldr r3, [r0] ldrh r0, [r2, 0x4] @@ -5748,7 +5748,7 @@ _080828BC: strb r0, [r1] b _080828DC _080828C6: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r4, [r0] cmp r4, 0 bne _080828DC @@ -5966,7 +5966,7 @@ _08082A92: thumb_func_start sub_8082AD4 sub_8082AD4: @ 8082AD4 push {r4-r7,lr} - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _08082AE0 @@ -6242,7 +6242,7 @@ sub_8082D18: @ 8082D18 sub_8082D28: @ 8082D28 push {r4,lr} movs r1, 0 - ldr r4, =gUnknown_03003124 + ldr r4, =gReceivedRemoteLinkPlayers ldrb r0, [r4] cmp r0, 0 beq _08082D3C @@ -7909,7 +7909,7 @@ _08083A80: cmp r5, r0 bcc _08083A80 _08083A9E: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _08083AB4 @@ -8514,7 +8514,7 @@ sub_8083F94: @ 8083F94 strb r0, [r7, 0xC] movs r0, 0xFF strb r0, [r7] - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080840C4 diff --git a/asm/braille_puzzles.s b/asm/braille_puzzles.s deleted file mode 100644 index 095b1b793..000000000 --- a/asm/braille_puzzles.s +++ /dev/null @@ -1,627 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_81795E8 -sub_81795E8: @ 81795E8 - push {lr} - ldr r0, =0x000008af - bl FlagGet - lsls r0, 24 - cmp r0, 0 - bne _08179634 - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldrh r1, [r2, 0x4] - ldr r0, =0x00004718 - cmp r1, r0 - bne _08179634 - ldr r1, [r2] - ldr r0, =0x0003000a - cmp r1, r0 - beq _08179616 - ldr r0, =0x00030009 - cmp r1, r0 - beq _08179616 - ldr r0, =0x0003000b - cmp r1, r0 - bne _08179634 -_08179616: - movs r0, 0x1 - b _08179636 - .pool -_08179634: - movs r0, 0 -_08179636: - pop {r1} - bx r1 - thumb_func_end sub_81795E8 - - thumb_func_start sub_817963C -sub_817963C: @ 817963C - push {lr} - ldr r2, =0x0000022a - movs r0, 0x10 - movs r1, 0x8 - bl MapGridSetMetatileIdAt - ldr r2, =0x0000022b - movs r0, 0x11 - movs r1, 0x8 - bl MapGridSetMetatileIdAt - movs r2, 0x8B - lsls r2, 2 - movs r0, 0x12 - movs r1, 0x8 - bl MapGridSetMetatileIdAt - ldr r2, =0x00000e32 - movs r0, 0x10 - movs r1, 0x9 - bl MapGridSetMetatileIdAt - ldr r2, =0x00000233 - movs r0, 0x11 - movs r1, 0x9 - bl MapGridSetMetatileIdAt - ldr r2, =0x00000e34 - movs r0, 0x12 - movs r1, 0x9 - bl MapGridSetMetatileIdAt - bl DrawWholeMapView - movs r0, 0x14 - bl PlaySE - ldr r0, =0x000008af - bl FlagSet - bl ScriptContext2_Disable - pop {r0} - bx r0 - .pool - thumb_func_end sub_817963C - - thumb_func_start sub_81796AC -sub_81796AC: @ 81796AC - push {r4,lr} - ldr r4, =gPlayerParty - adds r0, r4, 0 - movs r1, 0x41 - movs r2, 0 - bl GetMonData - movs r1, 0x9D - lsls r1, 1 - cmp r0, r1 - bne _081796F4 - bl CalculatePlayerPartyCount - ldr r0, =gPlayerPartyCount - ldrb r1, [r0] - movs r0, 0x64 - muls r0, r1 - adds r1, r4, 0 - subs r1, 0x64 - adds r0, r1 - movs r1, 0x41 - movs r2, 0 - bl GetMonData - ldr r1, =0x0000017d - cmp r0, r1 - bne _081796F4 - movs r0, 0x1 - b _081796F6 - .pool -_081796F4: - movs r0, 0 -_081796F6: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81796AC - - thumb_func_start nullsub_84 -nullsub_84: @ 81796FC - bx lr - thumb_func_end nullsub_84 - - thumb_func_start sub_8179700 -sub_8179700: @ 8179700 - push {lr} - ldr r0, =sub_8179778 - movs r1, 0x9 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - movs r0, 0 - strh r0, [r1, 0xA] - strh r0, [r1, 0xC] - movs r0, 0x2 - strh r0, [r1, 0x10] - movs r0, 0x5 - strh r0, [r1, 0x12] - movs r0, 0x32 - strh r0, [r1, 0x14] - movs r0, 0 - bl SetCameraPanningCallback - pop {r0} - bx r0 - .pool - thumb_func_end sub_8179700 - - thumb_func_start sub_817973C -sub_817973C: @ 817973C - push {lr} - ldr r0, =sub_8179778 - movs r1, 0x9 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - movs r0, 0 - strh r0, [r1, 0xA] - strh r0, [r1, 0xC] - movs r0, 0x3 - strh r0, [r1, 0x10] - movs r0, 0x5 - strh r0, [r1, 0x12] - movs r0, 0x2 - strh r0, [r1, 0x14] - movs r0, 0 - bl SetCameraPanningCallback - pop {r0} - bx r0 - .pool - thumb_func_end sub_817973C - - thumb_func_start sub_8179778 -sub_8179778: @ 8179778 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - movs r1, 0xA - ldrsh r0, [r4, r1] - movs r2, 0x12 - ldrsh r1, [r4, r2] - bl __modsi3 - cmp r0, 0 - bne _081797D0 - strh r0, [r4, 0xA] - ldrh r0, [r4, 0xC] - adds r0, 0x1 - strh r0, [r4, 0xC] - ldrh r0, [r4, 0x10] - negs r0, r0 - strh r0, [r4, 0x10] - movs r0, 0x10 - ldrsh r1, [r4, r0] - movs r0, 0 - bl SetCameraPanning - movs r2, 0xC - ldrsh r1, [r4, r2] - movs r2, 0x14 - ldrsh r0, [r4, r2] - cmp r1, r0 - bne _081797D0 - adds r0, r5, 0 - bl DestroyTask - bl EnableBothScriptContexts - bl InstallCameraPanAheadCallback -_081797D0: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8179778 - - thumb_func_start sub_81797DC -sub_81797DC: @ 81797DC - push {lr} - movs r0, 0x8B - lsls r0, 4 - bl FlagGet - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0 - bne _0817982C - ldr r0, =gSaveBlock1Ptr - ldr r3, [r0] - ldrh r1, [r3, 0x4] - movs r0, 0xC3 - lsls r0, 3 - cmp r1, r0 - bne _0817982C - ldr r1, [r3] - ldr r0, =0x00170006 - cmp r1, r0 - beq _08179810 - ldr r0, =0x00170005 - cmp r1, r0 - beq _08179810 - ldr r0, =0x00170007 - cmp r1, r0 - bne _0817982C -_08179810: - ldr r0, =gUnknown_0203BD14 - strb r2, [r0] - movs r0, 0x1 - b _0817982E - .pool -_0817982C: - movs r0, 0 -_0817982E: - pop {r1} - bx r1 - thumb_func_end sub_81797DC - - thumb_func_start sub_8179834 -sub_8179834: @ 8179834 - push {lr} - bl brm_get_pokemon_selection - ldr r1, =gFieldEffectSpawnParams - lsls r0, 24 - lsrs r0, 24 - str r0, [r1] - movs r0, 0x3C - bl FieldEffectStart - pop {r0} - bx r0 - .pool - thumb_func_end sub_8179834 - - thumb_func_start sub_8179850 -sub_8179850: @ 8179850 - push {lr} - movs r0, 0x3C - bl FieldEffectActiveListRemove - bl sub_8179860 - pop {r0} - bx r0 - thumb_func_end sub_8179850 - - thumb_func_start sub_8179860 -sub_8179860: @ 8179860 - push {lr} - ldr r2, =0x0000022a - movs r0, 0xE - movs r1, 0x1A - bl MapGridSetMetatileIdAt - ldr r2, =0x0000022b - movs r0, 0xF - movs r1, 0x1A - bl MapGridSetMetatileIdAt - movs r2, 0x8B - lsls r2, 2 - movs r0, 0x10 - movs r1, 0x1A - bl MapGridSetMetatileIdAt - ldr r2, =0x00000e32 - movs r0, 0xE - movs r1, 0x1B - bl MapGridSetMetatileIdAt - ldr r2, =0x00000233 - movs r0, 0xF - movs r1, 0x1B - bl MapGridSetMetatileIdAt - ldr r2, =0x00000e34 - movs r0, 0x10 - movs r1, 0x1B - bl MapGridSetMetatileIdAt - bl DrawWholeMapView - movs r0, 0x14 - bl PlaySE - movs r0, 0x8B - lsls r0, 4 - bl FlagSet - bl ScriptContext2_Disable - pop {r0} - bx r0 - .pool - thumb_func_end sub_8179860 - - thumb_func_start sub_81798D0 -sub_81798D0: @ 81798D0 - push {lr} - ldr r0, =0x000008b2 - bl FlagGet - lsls r0, 24 - cmp r0, 0 - bne _08179910 - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldrh r1, [r2, 0x4] - ldr r0, =0x00004418 - cmp r1, r0 - bne _08179910 - ldr r1, [r2] - ldr r0, =0x00190008 - cmp r1, r0 - bne _08179910 - ldr r1, =gUnknown_0203BD14 - movs r0, 0x1 - strb r0, [r1] - movs r0, 0x1 - b _08179912 - .pool -_08179910: - movs r0, 0 -_08179912: - pop {r1} - bx r1 - thumb_func_end sub_81798D0 - - thumb_func_start sub_8179918 -sub_8179918: @ 8179918 - push {lr} - bl brm_get_pokemon_selection - ldr r1, =gFieldEffectSpawnParams - lsls r0, 24 - lsrs r0, 24 - str r0, [r1] - movs r0, 0x3C - bl FieldEffectStart - pop {r0} - bx r0 - .pool - thumb_func_end sub_8179918 - - thumb_func_start sub_8179934 -sub_8179934: @ 8179934 - push {lr} - movs r0, 0x3C - bl FieldEffectActiveListRemove - bl sub_8179944 - pop {r0} - bx r0 - thumb_func_end sub_8179934 - - thumb_func_start sub_8179944 -sub_8179944: @ 8179944 - push {lr} - ldr r2, =0x0000022a - movs r0, 0xE - movs r1, 0x1A - bl MapGridSetMetatileIdAt - ldr r2, =0x0000022b - movs r0, 0xF - movs r1, 0x1A - bl MapGridSetMetatileIdAt - movs r2, 0x8B - lsls r2, 2 - movs r0, 0x10 - movs r1, 0x1A - bl MapGridSetMetatileIdAt - ldr r2, =0x00000e32 - movs r0, 0xE - movs r1, 0x1B - bl MapGridSetMetatileIdAt - ldr r2, =0x00000233 - movs r0, 0xF - movs r1, 0x1B - bl MapGridSetMetatileIdAt - ldr r2, =0x00000e34 - movs r0, 0x10 - movs r1, 0x1B - bl MapGridSetMetatileIdAt - bl DrawWholeMapView - movs r0, 0x14 - bl PlaySE - ldr r0, =0x000008b2 - bl FlagSet - bl ScriptContext2_Disable - pop {r0} - bx r0 - .pool - thumb_func_end sub_8179944 - - thumb_func_start nullsub_64 -nullsub_64: @ 81799B4 - bx lr - thumb_func_end nullsub_64 - - thumb_func_start sub_81799B8 -sub_81799B8: @ 81799B8 - push {lr} - bl oei_task_add - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_0203BD14 - ldrb r0, [r0] - cmp r0, 0x1 - bne _081799E4 - ldr r1, =gTasks - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r0, r1 - ldr r2, =sub_8179934 - b _081799F0 - .pool -_081799E4: - ldr r1, =gTasks - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r0, r1 - ldr r2, =sub_8179850 -_081799F0: - lsrs r1, r2, 16 - strh r1, [r0, 0x18] - strh r2, [r0, 0x1A] - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_81799B8 - - thumb_func_start sub_8179A04 -sub_8179A04: @ 8179A04 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - ldr r4, =gSaveBlock1Ptr - ldr r0, [r4] - ldrh r1, [r0, 0x4] - ldr r0, =0x00004318 - cmp r1, r0 - beq _08179A1A - b _08179B5A -_08179A1A: - ldr r0, =0x000008b1 - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _08179A28 - b _08179B5A -_08179A28: - movs r0, 0x2 - bl FlagGet - lsls r0, 24 - cmp r0, 0 - bne _08179A36 - b _08179B5A -_08179A36: - movs r0, 0x3 - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08179A58 - b _08179B5A - .pool -_08179A54: - movs r0, 0x1 - b _08179B5C -_08179A58: - movs r5, 0 - mov r8, r4 - ldr r4, =gUnknown_085EFE74 - adds r0, r4, 0x1 - mov r12, r0 - ldr r6, =0x0000403b - ldr r1, =0x0000403c - mov r9, r1 -_08179A68: - lsls r0, r5, 1 - adds r1, r0, r4 - add r0, r12 - ldrb r3, [r0] - mov r7, r8 - ldr r2, [r7] - movs r7, 0 - ldrsh r0, [r2, r7] - ldrb r1, [r1] - cmp r0, r1 - bne _08179B44 - movs r1, 0x2 - ldrsh r0, [r2, r1] - cmp r0, r3 - bne _08179B44 - cmp r5, 0xF - bhi _08179AB0 - adds r0, r6, 0 - bl VarGet - lsls r0, 16 - movs r1, 0x80 - lsls r1, 9 - lsls r1, r5 - orrs r1, r0 - lsrs r1, 16 - adds r0, r6, 0 - bl VarSet - b _08179AF0 - .pool -_08179AB0: - cmp r5, 0x1F - bhi _08179AD2 - mov r0, r9 - bl VarGet - lsls r0, 16 - adds r2, r5, 0 - subs r2, 0x10 - movs r1, 0x80 - lsls r1, 9 - lsls r1, r2 - orrs r1, r0 - lsrs r1, 16 - mov r0, r9 - bl VarSet - b _08179AF0 -_08179AD2: - ldr r4, =0x0000403d - adds r0, r4, 0 - bl VarGet - lsls r0, 16 - adds r2, r5, 0 - subs r2, 0x20 - movs r1, 0x80 - lsls r1, 9 - lsls r1, r2 - orrs r1, r0 - lsrs r1, 16 - adds r0, r4, 0 - bl VarSet -_08179AF0: - ldr r0, =0x0000403b - bl VarGet - lsls r0, 16 - lsrs r4, r0, 16 - ldr r0, =0x0000ffff - cmp r4, r0 - bne _08179B5A - ldr r0, =0x0000403c - bl VarGet - lsls r0, 16 - lsrs r0, 16 - cmp r0, r4 - bne _08179B5A - ldr r0, =0x0000403d - bl VarGet - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0xF - bne _08179B5A - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, [r0] - ldr r0, =0x00150008 - cmp r1, r0 - beq _08179A54 - b _08179B5A - .pool -_08179B44: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x23 - bls _08179A68 - movs r0, 0x3 - bl FlagSet - movs r0, 0x2 - bl FlagReset -_08179B5A: - movs r0, 0 -_08179B5C: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_8179A04 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/cable_club.s b/asm/cable_club.s index 80d9a0916..d5d3af151 100644 --- a/asm/cable_club.s +++ b/asm/cable_club.s @@ -1030,7 +1030,7 @@ sub_80B2C30: @ 80B2C30 bl sub_80B24F8 cmp r0, 0x1 beq _080B2C9C - bl sub_800A550 + bl GetBlockReceivedStatus adds r4, r0, 0 bl sub_800A9A8 lsls r4, 24 @@ -1047,7 +1047,7 @@ _080B2C5C: ldr r1, =gUnknown_02039B58 adds r0, r1 lsls r1, r4, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 lsls r2, r4, 3 subs r2, r4 @@ -1066,7 +1066,7 @@ _080B2C7E: bcc _080B2C5C movs r0, 0 bl sub_800B330 - bl sub_800A5B4 + bl ResetBlockReceivedFlags ldr r0, =gScriptResult adds r1, r5, 0 bl task_map_chg_seq_0807EC34 @@ -1082,7 +1082,7 @@ sub_80B2CB0: @ 80B2CB0 push {r4,r5,lr} lsls r0, 24 lsrs r5, r0, 24 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _080B2CDE @@ -1434,7 +1434,7 @@ _080B2FA8: bl DestroyTask b _080B2FC6 _080B2FB4: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _080B2FC6 @@ -1706,7 +1706,7 @@ sub_80B3220: @ 80B3220 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0x1 bne _080B3248 @@ -1836,7 +1836,7 @@ _080B3338: bl sub_800AC34 b _080B3346 _080B333E: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] _080B3342: cmp r0, 0 @@ -1872,7 +1872,7 @@ _080B3378: lsls r2, 4 adds r0, r2, 0 strh r0, [r1] - ldr r0, =sub_8036760 + ldr r0, =CB2_InitBattle bl SetMainCallback2 ldr r1, =gMain ldr r0, =sub_80B360C @@ -1948,13 +1948,13 @@ _080B3444: ldr r1, =gUnknown_020229CC movs r0, 0 movs r2, 0x1C - bl link_0800A448 + bl SendBlock movs r0, 0x3 strh r0, [r6] b _080B3532 .pool _080B3458: - bl sub_800A550 + bl GetBlockReceivedStatus adds r4, r0, 0 bl sub_800A9D8 lsls r4, 24 @@ -1967,7 +1967,7 @@ _080B3458: .pool _080B3474: lsls r1, r4, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r0, r5, 0 adds r1, r2 ldm r1!, {r2,r3,r7} @@ -2045,7 +2045,7 @@ _080B3504: lsls r3, 4 adds r0, r3, 0 strh r0, [r1] - ldr r0, =sub_8036760 + ldr r0, =CB2_InitBattle bl SetMainCallback2 ldr r1, =gMain ldr r0, =sub_80B360C @@ -2128,7 +2128,7 @@ _080B35C8: b _080B35FE .pool _080B35E0: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _080B35FE @@ -2425,7 +2425,7 @@ _080B3864: b _080B3884 .pool _080B3870: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _080B3884 @@ -2657,7 +2657,7 @@ task00_08081A90: @ 80B3A30 adds r0, r4, 0 bl DestroyTask _080B3A62: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080B3AA6 @@ -2691,7 +2691,7 @@ sub_80B3AAC: @ 80B3AAC push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _080B3AC4 @@ -2804,7 +2804,7 @@ _080B3B96: strh r0, [r5] b _080B3BB8 _080B3B9E: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0x1 bne _080B3BB8 diff --git a/asm/contest.s b/asm/contest.s index 023c6ebef..561c79857 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -45,10 +45,10 @@ sub_80D7678: @ 80D7678 lsls r1, 7 movs r0, 0 bl SetGpuRegBits - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r0, =gBattle_BG1_X strh r1, [r0] @@ -60,15 +60,15 @@ sub_80D7678: @ 80D7678 strh r1, [r0] ldr r0, =gBattle_BG3_X strh r1, [r0] - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y strh r1, [r0] - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H strh r1, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r1, [r0] - ldr r0, =gUnknown_02022E28 + ldr r0, =gBattle_WIN1H strh r1, [r0] - ldr r0, =gUnknown_02022E2A + ldr r0, =gBattle_WIN1V strh r1, [r0] pop {r4} pop {r0} @@ -546,8 +546,8 @@ _080D7B4E: ldr r0, =gUnknown_02039F38 strb r5, [r0] bl sub_80D7988 - bl init_uns_table_pokemon_copy - ldr r4, =gBattleSpritesGfx + bl AllocateMonSpritesGfx + ldr r4, =gMonSpritesGfxPtr ldr r0, [r4] ldr r0, [r0] bl Free @@ -1316,11 +1316,11 @@ _080D8266: thumb_func_start vblank_cb_battle vblank_cb_battle: @ 80D827C push {lr} - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X ldrh r1, [r0] movs r0, 0x10 bl SetGpuReg - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y ldrh r1, [r0] movs r0, 0x12 bl SetGpuReg @@ -1344,23 +1344,23 @@ vblank_cb_battle: @ 80D827C ldrh r1, [r0] movs r0, 0x1C bl SetGpuReg - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y ldrh r1, [r0] movs r0, 0x1E bl SetGpuReg - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H ldrh r1, [r0] movs r0, 0x40 bl SetGpuReg - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V ldrh r1, [r0] movs r0, 0x44 bl SetGpuReg - ldr r0, =gUnknown_02022E28 + ldr r0, =gBattle_WIN1H ldrh r1, [r0] movs r0, 0x42 bl SetGpuReg - ldr r0, =gUnknown_02022E2A + ldr r0, =gBattle_WIN1V ldrh r1, [r0] movs r0, 0x46 bl SetGpuReg @@ -1387,7 +1387,7 @@ sub_80D833C: @ 80D833C ldrsh r1, [r4, r0] cmp r1, 0 bne _080D840C - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r0, =gBattle_BG2_Y strh r1, [r0] @@ -1517,7 +1517,7 @@ sub_80D8490: @ 80D8490 lsls r0, 24 lsrs r0, 24 mov r9, r0 - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y movs r1, 0xA0 strh r1, [r0] ldr r0, =gBattle_BG2_Y @@ -1770,7 +1770,7 @@ _080D86E4: adds r0, r4, 0 movs r1, 0 bl sub_80DEC30 - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y movs r1, 0 strh r1, [r0] ldr r0, =gBattle_BG2_Y @@ -2041,7 +2041,7 @@ sub_80D895C: @ 80D895C lsls r0, 24 lsrs r7, r0, 24 bl sub_80DB89C - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y movs r1, 0 strh r1, [r0] ldr r0, =gBattle_BG2_Y @@ -5322,7 +5322,7 @@ sub_80DA5E8: @ 80DA5E8 push {r4,r5,lr} lsls r0, 24 lsrs r5, r0, 24 - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y movs r1, 0 strh r1, [r0] ldr r0, =gBattle_BG2_Y @@ -5587,7 +5587,7 @@ sub_80DA830: @ 80DA830 str r1, [r0] bl FreeAllWindowBuffers bl sub_80D7A5C - bl sub_805F094 + bl FreeMonSpritesGfx ldr r0, =c2_exit_to_overworld_2_switch bl SetMainCallback2 _080DA860: @@ -6741,7 +6741,7 @@ sub_80DB174: @ 80DB174 lsls r0, r5, 3 ldr r1, =gMonBackPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] ldr r1, [r1, 0x4] adds r2, r5, 0 @@ -6753,7 +6753,7 @@ _080DB1B8: lsls r0, r5, 3 ldr r1, =gMonBackPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] ldr r1, [r1, 0x4] adds r2, r5, 0 @@ -8516,7 +8516,7 @@ _080DBF62: thumb_func_start sub_80DBF68 sub_80DBF68: @ 80DBF68 push {lr} - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y movs r1, 0 strh r1, [r0] ldr r0, =gBattle_BG2_Y diff --git a/asm/contest_link_80F57C4.s b/asm/contest_link_80F57C4.s index 8e2e2c61c..03e1aaf2b 100644 --- a/asm/contest_link_80F57C4.s +++ b/asm/contest_link_80F57C4.s @@ -92,10 +92,10 @@ _080F57E0: lsls r1, 8 movs r0, 0 bl SetGpuRegBits - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r0, =gBattle_BG1_X strh r1, [r0] @@ -107,15 +107,15 @@ _080F57E0: strh r1, [r0] ldr r0, =gBattle_BG3_X strh r1, [r0] - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y strh r1, [r0] - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H strh r1, [r0] - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V strh r1, [r0] - ldr r0, =gUnknown_02022E28 + ldr r0, =gBattle_WIN1H strh r1, [r0] - ldr r0, =gUnknown_02022E2A + ldr r0, =gBattle_WIN1V strh r1, [r0] pop {r4} pop {r0} @@ -387,10 +387,10 @@ sub_80F5B00: @ 80F5B00 strb r0, [r1, 0x2] ldr r0, =sub_80F5C00 bl SetMainCallback2 - ldr r1, =gUnknown_02022E28 + ldr r1, =gBattle_WIN1H movs r0, 0xF0 strh r0, [r1] - ldr r1, =gUnknown_02022E2A + ldr r1, =gBattle_WIN1V ldr r2, =0x000080a0 adds r0, r2, 0 strh r0, [r1] @@ -441,11 +441,11 @@ sub_80F5C00: @ 80F5C00 thumb_func_start sub_80F5C24 sub_80F5C24: @ 80F5C24 push {lr} - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X ldrh r1, [r0] movs r0, 0x10 bl SetGpuReg - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y ldrh r1, [r0] movs r0, 0x12 bl SetGpuReg @@ -469,23 +469,23 @@ sub_80F5C24: @ 80F5C24 ldrh r1, [r0] movs r0, 0x1C bl SetGpuReg - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y ldrh r1, [r0] movs r0, 0x1E bl SetGpuReg - ldr r0, =gUnknown_02022E24 + ldr r0, =gBattle_WIN0H ldrh r1, [r0] movs r0, 0x40 bl SetGpuReg - ldr r0, =gUnknown_02022E26 + ldr r0, =gBattle_WIN0V ldrh r1, [r0] movs r0, 0x44 bl SetGpuReg - ldr r0, =gUnknown_02022E28 + ldr r0, =gBattle_WIN1H ldrh r1, [r0] movs r0, 0x42 bl SetGpuReg - ldr r0, =gUnknown_02022E2A + ldr r0, =gBattle_WIN1V ldrh r1, [r0] movs r0, 0x46 bl SetGpuReg @@ -702,7 +702,7 @@ sub_80F5ED8: @ 80F5ED8 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080F5EFC @@ -1347,10 +1347,10 @@ _080F643C: .4byte _080F6638 .4byte _080F667C _080F6454: - ldr r1, =gUnknown_02022E24 + ldr r1, =gBattle_WIN0H movs r0, 0xF0 strh r0, [r1] - ldr r1, =gUnknown_02022E26 + ldr r1, =gBattle_WIN0V ldr r3, =0x00005050 adds r0, r3, 0 strh r0, [r1] @@ -1364,7 +1364,7 @@ _080F6454: mov r9, r4 ldr r4, =gMonFrontPicTable mov r12, r4 - ldr r4, =gBattleSpritesGfx + ldr r4, =gMonSpritesGfxPtr mov r8, r4 cmp r0, 0 beq _080F648C @@ -1494,7 +1494,7 @@ _080F65A4: strh r0, [r4, 0xC] _080F65BA: ldrb r2, [r4, 0xC] - ldr r3, =gUnknown_02022E26 + ldr r3, =gBattle_WIN0V movs r0, 0x50 subs r0, r2 lsls r0, 8 @@ -1556,7 +1556,7 @@ _080F6638: ldrb r0, [r0, 0x6] cmp r0, 0x2 bne _080F669C - ldr r3, =gUnknown_02022E26 + ldr r3, =gBattle_WIN0V ldrh r0, [r3] lsrs r2, r0, 8 adds r0, r2, 0x2 @@ -1706,7 +1706,7 @@ sub_80F677C: @ 80F677C push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _080F67AC @@ -1842,7 +1842,7 @@ sub_80F68B4: @ 80F68B4 ldrh r3, [r2] adds r0, r3, 0x2 strh r0, [r2] - ldr r4, =gUnknown_02022E22 + ldr r4, =gBattle_BG3_Y ldrh r5, [r4] adds r1, r5, 0x1 strh r1, [r4] @@ -2870,10 +2870,10 @@ _080F70BE: adds r5, 0x1 cmp r5, 0x2 ble _080F70BE - ldr r1, =gUnknown_02022E24 + ldr r1, =gBattle_WIN0H movs r0, 0xF0 strh r0, [r1] - ldr r2, =gUnknown_02022E26 + ldr r2, =gBattle_WIN0V ldrh r1, [r4, 0x22] adds r0, r1, 0 subs r0, 0x10 @@ -2910,8 +2910,8 @@ sub_80F7144: @ 80F7144 orrs r0, r1 mov r1, r12 strb r0, [r1] - ldr r7, =gUnknown_02022E24 - ldr r6, =gUnknown_02022E26 + ldr r7, =gBattle_WIN0H + ldr r6, =gBattle_WIN0V adds r5, r3, 0 movs r4, 0x4 adds r2, 0x2E @@ -4522,7 +4522,7 @@ sub_80F7DF4: @ 80F7DF4 bl AllocZeroed ldr r1, [r4] str r0, [r1, 0x1C] - bl init_uns_table_pokemon_copy + bl AllocateMonSpritesGfx pop {r4,r5} pop {r0} bx r0 @@ -4569,7 +4569,7 @@ sub_80F7E64: @ 80F7E64 str r4, [r0, 0x1C] bl Free str r4, [r5] - bl sub_805F094 + bl FreeMonSpritesGfx pop {r4,r5} pop {r0} bx r0 @@ -5633,7 +5633,7 @@ sub_80F87B4: @ 80F87B4 push {lr} lsls r0, 24 lsrs r1, r0, 24 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _080F87D0 diff --git a/asm/contest_link_80FC4F4.s b/asm/contest_link_80FC4F4.s index 0d6116766..ad22946c5 100644 --- a/asm/contest_link_80FC4F4.s +++ b/asm/contest_link_80FC4F4.s @@ -21,7 +21,7 @@ sub_80FC4F4: @ 80FC4F4 lsrs r0, 24 adds r1, r5, 0 adds r2, r4, 0 - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 bne _080FC528 @@ -45,7 +45,7 @@ sub_80FC530: @ 80FC530 lsls r4, 17 lsls r4, r5 lsrs r4, 24 - bl sub_800A550 + bl GetBlockReceivedStatus ands r4, r0 cmp r4, 0 beq _080FC552 @@ -64,7 +64,7 @@ _080FC554: thumb_func_start sub_80FC55C sub_80FC55C: @ 80FC55C push {r4,lr} - bl sub_800A550 + bl GetBlockReceivedStatus adds r4, r0, 0 bl sub_800A9D8 lsls r4, 24 @@ -74,7 +74,7 @@ sub_80FC55C: @ 80FC55C movs r0, 0 b _080FC57A _080FC574: - bl sub_800A5B4 + bl ResetBlockReceivedFlags movs r0, 0x1 _080FC57A: pop {r4} @@ -90,7 +90,7 @@ sub_80FC580: @ 80FC580 movs r1, 0 ldr r5, =gTasks ldr r6, =sub_80FC5C0 - ldr r4, =gUnknown_020223C4 + ldr r4, =gBlockRecvBuffer movs r3, 0xFF _080FC590: lsls r0, r1, 8 @@ -134,7 +134,7 @@ sub_80FC5DC: @ 80FC5DC push {r4-r7,lr} lsls r0, 24 lsrs r7, r0, 24 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080FC650 @@ -324,7 +324,7 @@ _080FC770: ldr r0, =gUnknown_02039E00 adds r4, r0 lsls r1, r5, 8 - ldr r0, =gUnknown_020223C4 + ldr r0, =gBlockRecvBuffer adds r1, r0 adds r0, r4, 0 movs r2, 0x40 @@ -430,7 +430,7 @@ _080FC858: cmp r0, 0 beq _080FC880 ldr r0, =gRngValue - ldr r4, =gUnknown_020223C4 + ldr r4, =gBlockRecvBuffer adds r1, r4, 0 movs r2, 0x4 bl memcpy @@ -517,7 +517,7 @@ _080FC90C: ldrb r0, [r1] cmp r3, r0 bge _080FC93A - ldr r4, =gUnknown_020223C4 + ldr r4, =gBlockRecvBuffer adds r0, r7, 0x2 adds r2, r5, r0 movs r5, 0x80 @@ -690,7 +690,7 @@ _080FCA68: bge _080FCAA4 ldr r1, =gUnknown_02039F34 mov r8, r1 - ldr r4, =gUnknown_020223C4 + ldr r4, =gBlockRecvBuffer movs r3, 0 movs r7, 0x80 lsls r7, 1 @@ -784,7 +784,7 @@ _080FCB50: ldr r1, =gUnknown_02039F2B ldrb r1, [r1] lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0x8 b _080FCC50 @@ -827,7 +827,7 @@ _080FCBA4: ldr r1, =gUnknown_02039F2B ldrb r1, [r1] lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0x8 b _080FCC50 @@ -850,7 +850,7 @@ _080FCBE0: ldr r1, =gUnknown_02039F2B ldrb r1, [r1] lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0x8 b _080FCC50 @@ -885,7 +885,7 @@ _080FCC38: ldr r1, =gUnknown_02039F2B ldrb r1, [r1] lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0x4 _080FCC50: @@ -974,7 +974,7 @@ _080FCD10: ldr r1, =gUnknown_02039F2B ldrb r1, [r1] lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0x70 b _080FCE10 @@ -1021,7 +1021,7 @@ _080FCD6C: ldr r1, =gUnknown_02039F2B ldrb r1, [r1] lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0x14 b _080FCE10 @@ -1078,7 +1078,7 @@ _080FCE04: ldr r1, =gUnknown_02039F2B ldrb r1, [r1] lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0x4 _080FCE10: @@ -1169,7 +1169,7 @@ _080FCEC0: beq _080FCF2E mov r1, r8 mov r8, r9 - ldr r4, =gUnknown_020223C4 + ldr r4, =gBlockRecvBuffer adds r0, r7, 0 adds r0, 0xA adds r2, r5, r0 @@ -1278,7 +1278,7 @@ _080FCF9C: ldr r1, =gUnknown_02039F2B ldrb r1, [r1] lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0x8 bl memcpy @@ -1344,7 +1344,7 @@ _080FD02C: ldr r1, =gUnknown_02039F2B ldrb r1, [r1] lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0x4 bl memcpy diff --git a/asm/contest_link_81D9DE4.s b/asm/contest_link_81D9DE4.s index cec1c6e5d..3fd8f56f1 100755 --- a/asm/contest_link_81D9DE4.s +++ b/asm/contest_link_81D9DE4.s @@ -469,7 +469,7 @@ _081DA1EC: ldr r0, =gUnknown_02039E00 adds r4, r0 lsls r1, r5, 8 - ldr r0, =gUnknown_020223C4 + ldr r0, =gBlockRecvBuffer adds r1, r0 adds r0, r4, 0 movs r2, 0x40 @@ -554,7 +554,7 @@ _081DA2AC: cmp r0, 0 beq _081DA2D4 ldr r0, =gRngValue - ldr r4, =gUnknown_020223C4 + ldr r4, =gBlockRecvBuffer adds r1, r4, 0 movs r2, 0x4 bl memcpy @@ -641,7 +641,7 @@ _081DA35A: mov r0, r8 adds r0, 0xA adds r3, r5, r0 - ldr r4, =gUnknown_020223C4 + ldr r4, =gBlockRecvBuffer mov r2, sp movs r5, 0x80 lsls r5, 1 @@ -744,7 +744,7 @@ _081DA42A: mov r0, r8 adds r0, 0x2 adds r3, r5, r0 - ldr r4, =gUnknown_020223C4 + ldr r4, =gBlockRecvBuffer mov r2, sp movs r5, 0x80 lsls r5, 1 @@ -849,7 +849,7 @@ _081DA50C: lsls r0, r3, 6 ldr r5, =gUnknown_02039E00 adds r0, r5 - ldr r1, =gUnknown_020223C4 + ldr r1, =gBlockRecvBuffer movs r2, 0x4 subs r2, r3 lsls r2, 6 diff --git a/asm/contest_painting.s b/asm/contest_painting.s index 62359497c..2caf15194 100644 --- a/asm/contest_painting.s +++ b/asm/contest_painting.s @@ -72,7 +72,7 @@ sub_812FE0C: @ 812FE0C movs r0, 0x1 bl GetBgTilemapBuffer bl Free - bl sub_805F094 + bl FreeMonSpritesGfx pop {r4,r5} pop {r0} bx r0 @@ -110,7 +110,7 @@ _0812FE94: bl remove_some_task movs r0, 0 bl SetVBlankCallback - bl init_uns_table_pokemon_copy + bl AllocateMonSpritesGfx ldr r1, =gUnknown_030061C0 ldr r0, =gUnknown_02039F3C str r0, [r1] @@ -581,7 +581,7 @@ sub_81302E8: @ 81302E8 lsls r0, r5, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r4, =gBattleSpritesGfx + ldr r4, =gMonSpritesGfxPtr ldr r1, [r4] ldr r1, [r1, 0x8] ldr r2, [r6] @@ -600,7 +600,7 @@ _08130348: lsls r0, r5, 3 ldr r1, =gMonBackPicTable adds r0, r1 - ldr r4, =gBattleSpritesGfx + ldr r4, =gMonSpritesGfxPtr ldr r1, [r4] ldr r1, [r1, 0x4] ldr r2, [r6] diff --git a/asm/credits.s b/asm/credits.s index 0a568a3ae..0b2da16b8 100644 --- a/asm/credits.s +++ b/asm/credits.s @@ -491,14 +491,14 @@ _08175906: ldr r1, =gReservedSpritePaletteCount movs r0, 0x8 strb r0, [r1] - ldr r0, =gUnknown_085B0E04 + ldr r0, =gBirchHelpGfx movs r1, 0xC0 lsls r1, 19 bl LZ77UnCompVram - ldr r0, =gUnknown_085B0C0C + ldr r0, =gBirchGrassTilemap ldr r1, =0x06003800 bl LZ77UnCompVram - ldr r0, =gUnknown_085B0A02 + ldr r0, =gBirchBagGrassPal + 0x2 movs r1, 0x1 movs r2, 0x3E bl LoadPalette diff --git a/asm/diploma.s b/asm/diploma.s deleted file mode 100644 index 4f21fe39d..000000000 --- a/asm/diploma.s +++ /dev/null @@ -1,387 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8177874 -sub_8177874: @ 8177874 - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end sub_8177874 - - thumb_func_start sub_8177888 -sub_8177888: @ 8177888 - push {r4,r5,lr} - sub sp, 0xC - movs r0, 0 - bl SetVBlankCallback - movs r0, 0 - movs r1, 0 - bl SetGpuReg - movs r0, 0xE - movs r1, 0 - bl SetGpuReg - movs r0, 0xC - movs r1, 0 - bl SetGpuReg - movs r0, 0xA - movs r1, 0 - bl SetGpuReg - movs r0, 0x8 - movs r1, 0 - bl SetGpuReg - movs r0, 0x1C - movs r1, 0 - bl SetGpuReg - movs r0, 0x1E - movs r1, 0 - bl SetGpuReg - movs r0, 0x18 - movs r1, 0 - bl SetGpuReg - movs r0, 0x1A - movs r1, 0 - bl SetGpuReg - movs r0, 0x14 - movs r1, 0 - bl SetGpuReg - movs r0, 0x16 - movs r1, 0 - bl SetGpuReg - movs r0, 0x10 - movs r1, 0 - bl SetGpuReg - movs r0, 0x12 - movs r1, 0 - bl SetGpuReg - add r1, sp, 0x4 - movs r0, 0 - strh r0, [r1] - ldr r1, =0x040000d4 - add r0, sp, 0x4 - str r0, [r1] - movs r0, 0xC0 - lsls r0, 19 - str r0, [r1, 0x4] - ldr r0, =0x8100c000 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - movs r5, 0 - str r5, [sp, 0x8] - add r0, sp, 0x8 - str r0, [r1] - movs r0, 0xE0 - lsls r0, 19 - str r0, [r1, 0x4] - ldr r0, =0x85000100 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - add r0, sp, 0x4 - strh r5, [r0] - str r0, [r1] - movs r0, 0xA0 - lsls r0, 19 - str r0, [r1, 0x4] - ldr r0, =0x81000200 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - bl remove_some_task - bl ResetTasks - bl ResetSpriteData - bl ResetPaletteFade - bl FreeAllSpritePalettes - ldr r0, =gUnknown_085E7088 - movs r1, 0 - movs r2, 0x40 - bl LoadPalette - ldr r4, =gUnknown_0203BCF0 - movs r0, 0x80 - lsls r0, 5 - bl Alloc - str r0, [r4] - bl sub_8177B44 - bl sub_8177B9C - bl reset_temp_tile_data_buffers - ldr r1, =gUnknown_085E7804 - str r5, [sp] - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram -_0817797C: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - bne _0817797C - ldr r0, =gUnknown_085E70C8 - ldr r1, =gUnknown_0203BCF0 - ldr r1, [r1] - bl LZDecompressWram - movs r0, 0x1 - bl CopyBgTilemapBufferToVram - bl pokedex_diploma_something - movs r4, 0x1 - negs r4, r4 - adds r0, r4, 0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - str r5, [sp] - adds r0, r4, 0 - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - movs r0, 0x1 - bl EnableInterrupts - ldr r0, =sub_8177874 - bl SetVBlankCallback - ldr r0, =sub_8177A08 - bl SetMainCallback2 - ldr r0, =sub_8177A20 - movs r1, 0 - bl CreateTask - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8177888 - - thumb_func_start sub_8177A08 -sub_8177A08: @ 8177A08 - push {lr} - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end sub_8177A08 - - thumb_func_start sub_8177A20 -sub_8177A20: @ 8177A20 - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08177A40 - ldr r0, =gTasks - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_8177A50 - str r0, [r1] -_08177A40: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8177A20 - - thumb_func_start sub_8177A50 -sub_8177A50: @ 8177A50 - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _08177A82 - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_8177A98 - str r1, [r0] -_08177A82: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8177A50 - - thumb_func_start sub_8177A98 -sub_8177A98: @ 8177A98 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08177AC2 - ldr r0, =gUnknown_0203BCF0 - ldr r0, [r0] - bl Free - bl FreeAllWindowBuffers - adds r0, r4, 0 - bl DestroyTask - ldr r0, =sub_80861E8 - bl SetMainCallback2 -_08177AC2: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8177A98 - - thumb_func_start pokedex_diploma_something -pokedex_diploma_something: @ 8177AD4 - push {r4,lr} - bl sub_80C0944 - lsls r0, 16 - cmp r0, 0 - beq _08177AFC - movs r1, 0x80 - lsls r1, 1 - movs r0, 0x14 - bl SetGpuReg - ldr r0, =gStringVar1 - ldr r1, =gText_DexNational - bl StringCopy - b _08177B0C - .pool -_08177AFC: - movs r0, 0x14 - movs r1, 0 - bl SetGpuReg - ldr r0, =gStringVar1 - ldr r1, =gText_DexHoenn - bl StringCopy -_08177B0C: - ldr r4, =gStringVar4 - ldr r1, =gText_PokedexDiploma - adds r0, r4, 0 - bl StringExpandPlaceholders - adds r0, r4, 0 - movs r1, 0 - movs r2, 0x1 - bl sub_8177BCC - movs r0, 0 - bl PutWindowTilemap - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end pokedex_diploma_something - - thumb_func_start sub_8177B44 -sub_8177B44: @ 8177B44 - push {lr} - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_085E81FC - movs r0, 0 - movs r2, 0x2 - bl InitBgsFromTemplates - ldr r0, =gUnknown_0203BCF0 - ldr r1, [r0] - movs r0, 0x1 - bl SetBgTilemapBuffer - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - pop {r0} - bx r0 - .pool - thumb_func_end sub_8177B44 - - thumb_func_start sub_8177B9C -sub_8177B9C: @ 8177B9C - push {lr} - ldr r0, =gUnknown_085E8204 - bl InitWindows - bl DeactivateAllTextPrinters - ldr r0, =gUnknown_0860F074 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - movs r0, 0 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0 - bl PutWindowTilemap - pop {r0} - bx r0 - .pool - thumb_func_end sub_8177B9C - - thumb_func_start sub_8177BCC -sub_8177BCC: @ 8177BCC - push {r4-r6,lr} - sub sp, 0x18 - adds r6, r0, 0 - adds r4, r1, 0 - adds r5, r2, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - ldr r1, =gUnknown_085E8214 - add r0, sp, 0x14 - movs r2, 0x3 - bl memcpy - movs r0, 0 - str r0, [sp] - str r0, [sp, 0x4] - add r0, sp, 0x14 - str r0, [sp, 0x8] - movs r0, 0x1 - negs r0, r0 - str r0, [sp, 0xC] - str r6, [sp, 0x10] - movs r0, 0 - movs r1, 0x1 - adds r2, r4, 0 - adds r3, r5, 0 - bl AddTextPrinterParametrized2 - add sp, 0x18 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8177BCC - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/evolution_scene.s b/asm/evolution_scene.s index 5d0268173..e5e9aaab9 100644 --- a/asm/evolution_scene.s +++ b/asm/evolution_scene.s @@ -68,7 +68,7 @@ _0813DA00: adds r1, r4, 0 adds r2, r5, 0 adds r3, r6, 0 - bl evolution_cutscene + bl EvolutionScene _0813DA30: add sp, 0x4 pop {r4-r7} @@ -77,8 +77,8 @@ _0813DA30: .pool thumb_func_end sub_813D9C0 - thumb_func_start sub_813DA40 -sub_813DA40: @ 813DA40 + thumb_func_start BeginEvolutionScene +BeginEvolutionScene: @ 813DA40 push {r4-r6,lr} adds r4, r1, 0 adds r5, r2, 0 @@ -110,10 +110,10 @@ sub_813DA40: @ 813DA40 pop {r0} bx r0 .pool - thumb_func_end sub_813DA40 + thumb_func_end BeginEvolutionScene - thumb_func_start evolution_cutscene -evolution_cutscene: @ 813DA8C + thumb_func_start EvolutionScene +EvolutionScene: @ 813DA8C push {r4-r7,lr} mov r7, r10 mov r6, r9 @@ -165,10 +165,10 @@ evolution_cutscene: @ 813DA8C movs r1, 0 bl SetGpuReg bl ResetPaletteFade - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r2, 0 strh r2, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r2, [r0] ldr r0, =gBattle_BG1_X strh r2, [r0] @@ -183,14 +183,14 @@ evolution_cutscene: @ 813DA8C lsls r2, 1 adds r0, r2, 0 strh r0, [r1] - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y movs r1, 0 strh r1, [r0] ldr r1, =gBattleTerrain movs r0, 0x9 strb r0, [r1] - bl c2_berry_program_update_menu - bl sub_8035AA4 + bl sub_80356D0 + bl LoadBattleTextboxAndBackground bl ResetSpriteData bl remove_some_task bl ResetTasks @@ -202,7 +202,7 @@ evolution_cutscene: @ 813DA8C bl AllocZeroed ldr r1, =gUnknown_0203AB80 str r0, [r1] - bl init_uns_table_pokemon_copy + bl AllocateMonSpritesGfx adds r0, r4, 0 movs r1, 0x2 mov r2, sp @@ -235,7 +235,7 @@ evolution_cutscene: @ 813DA8C lsls r0, r5, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r2, =gBattleSpritesGfx + ldr r2, =gMonSpritesGfxPtr ldr r1, [r2] ldr r1, [r1, 0x8] adds r2, r5, 0 @@ -291,7 +291,7 @@ evolution_cutscene: @ 813DA8C lsls r0, r1, 3 ldr r2, =gMonFrontPicTable adds r0, r2 - ldr r2, =gBattleSpritesGfx + ldr r2, =gMonSpritesGfxPtr ldr r1, [r2] ldr r1, [r1, 0x10] mov r2, r10 @@ -393,7 +393,7 @@ evolution_cutscene: @ 813DA8C pop {r0} bx r0 .pool - thumb_func_end evolution_cutscene + thumb_func_end EvolutionScene thumb_func_start sub_813DD7C sub_813DD7C: @ 813DD7C @@ -460,9 +460,9 @@ sub_813DD7C: @ 813DD7C movs r1, 0 bl SetGpuReg bl ResetPaletteFade - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X strh r4, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r4, [r0] ldr r0, =gBattle_BG1_X strh r4, [r0] @@ -477,13 +477,13 @@ sub_813DD7C: @ 813DD7C lsls r2, 1 adds r0, r2, 0 strh r0, [r1] - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y strh r4, [r0] ldr r1, =gBattleTerrain movs r0, 0x9 strb r0, [r1] - bl c2_berry_program_update_menu - bl sub_8035AA4 + bl sub_80356D0 + bl LoadBattleTextboxAndBackground bl ResetSpriteData bl FreeAllSpritePalettes ldr r1, =gReservedSpritePaletteCount @@ -492,7 +492,7 @@ sub_813DD7C: @ 813DD7C lsls r0, r5, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] ldr r1, [r1, 0x10] adds r2, r5, 0 @@ -629,10 +629,10 @@ _0813DFE0: ldr r1, =gReservedSpritePaletteCount movs r0, 0x4 strb r0, [r1] - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r0, =gBattle_BG1_X strh r1, [r0] @@ -647,7 +647,7 @@ _0813DFE0: lsls r3, 1 adds r0, r3, 0 strh r0, [r2] - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y strh r1, [r0] b _0813E180 .pool @@ -697,7 +697,7 @@ _0813E0A8: lsls r0, r6, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] ldr r1, [r1, 0x10] adds r2, r6, 0 @@ -867,7 +867,7 @@ sub_813E1D4: @ 813E1D4 lsls r0, r5, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] ldr r1, [r1, 0x8] adds r2, r5, 0 @@ -941,9 +941,9 @@ sub_813E1D4: @ 813E1D4 mov r1, sp ldrh r1, [r1, 0x14] strh r1, [r0, 0x1C] - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X strh r4, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r4, [r0] ldr r0, =gBattle_BG1_X strh r4, [r0] @@ -958,7 +958,7 @@ sub_813E1D4: @ 813E1D4 lsls r2, 1 adds r0, r2, 0 strh r0, [r1] - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y strh r4, [r0] ldr r2, =gTextFlags ldrb r0, [r2] @@ -1775,7 +1775,7 @@ _0813EAF6: _0813EB06: adds r0, r7, 0 bl DestroyTask - bl sub_805F094 + bl FreeMonSpritesGfx ldr r4, =gUnknown_0203AB80 ldr r0, [r4] bl Free @@ -3630,11 +3630,11 @@ nullsub_83: @ 813FCD8 thumb_func_start sub_813FCDC sub_813FCDC: @ 813FCDC push {lr} - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X ldrh r1, [r0] movs r0, 0x10 bl SetGpuReg - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y ldrh r1, [r0] movs r0, 0x12 bl SetGpuReg @@ -3658,7 +3658,7 @@ sub_813FCDC: @ 813FCDC ldrh r1, [r0] movs r0, 0x1C bl SetGpuReg - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y ldrh r1, [r0] movs r0, 0x1E bl SetGpuReg @@ -3674,11 +3674,11 @@ sub_813FCDC: @ 813FCDC thumb_func_start sub_813FD64 sub_813FD64: @ 813FD64 push {lr} - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X ldrh r1, [r0] movs r0, 0x10 bl SetGpuReg - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y ldrh r1, [r0] movs r0, 0x12 bl SetGpuReg @@ -3702,7 +3702,7 @@ sub_813FD64: @ 813FD64 ldrh r1, [r0] movs r0, 0x1C bl SetGpuReg - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y ldrh r1, [r0] movs r0, 0x1E bl SetGpuReg @@ -3871,7 +3871,7 @@ sub_813FEE8: @ 813FEE8 .pool _0813FF28: ldr r7, =gBattle_BG3_X - ldr r6, =gUnknown_02022E22 + ldr r6, =gBattle_BG3_Y _0813FF2C: lsls r4, r5, 2 adds r4, r5 diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index 1f2d638c3..fa923d94b 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -1411,7 +1411,7 @@ _0809CA64: b _0809CB28 .pool _0809CA7C: - bl sub_8179A04 + bl ShouldDoBrailleRegicePuzzle lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 diff --git a/asm/field_screen.s b/asm/field_screen.s index 0de68b86b..83fea2f44 100644 --- a/asm/field_screen.s +++ b/asm/field_screen.s @@ -9010,7 +9010,7 @@ _080AF9C8: strh r0, [r4] b _080AF9E8 _080AF9D0: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _080AF9E8 diff --git a/asm/librfu.s b/asm/librfu.s index d8ca7538c..129e0f34a 100644 --- a/asm/librfu.s +++ b/asm/librfu.s @@ -2762,7 +2762,7 @@ sub_82E424C: @ 82E424C b _082E4266 .align 2, 0 _082E4254: .4byte gUnknown_089A324C -_082E4258: .4byte gUnknown_030000F0 +_082E4258: .4byte gDma3Requests + 0xE0 thumb_func_end sub_82E424C thumb_func_start sub_82E425C @@ -2810,7 +2810,7 @@ _082E4274: movs r0, 0 b _082E42BE .align 2, 0 -_082E42B0: .4byte gUnknown_030000FA +_082E42B0: .4byte gDma3Requests + 0xEA _082E42B4: .4byte gUnknown_03007890 _082E42B8: .4byte gUnknown_03007894 _082E42BC: diff --git a/asm/link.s b/asm/link.s index d1c8d0542..fb20b1fb2 100644 --- a/asm/link.s +++ b/asm/link.s @@ -402,7 +402,7 @@ sub_8009734: @ 8009734 strb r4, [r0] ldr r0, =gUnknown_030030F8 strb r4, [r0] - bl sub_800A5B4 + bl ResetBlockReceivedFlags bl sub_800A2E0 ldr r0, =gUnknown_03000D54 str r4, [r0] @@ -420,7 +420,7 @@ sub_8009734: @ 8009734 _080097A8: bl sub_800E700 _080097AC: - ldr r1, =gUnknown_03003124 + ldr r1, =gReceivedRemoteLinkPlayers movs r0, 0 strb r0, [r1] movs r1, 0 @@ -448,7 +448,7 @@ _080097BE: thumb_func_start sub_80097E8 sub_80097E8: @ 80097E8 push {r4,lr} - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers movs r4, 0 strb r4, [r0] ldr r0, =gLinkVSyncDisabled @@ -514,7 +514,7 @@ _08009868: lsrs r5, r0, 24 cmp r5, 0x3 bls _08009840 - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r7, r0, 24 cmp r7, 0xF @@ -532,7 +532,7 @@ _08009888: cmp r0, 0 beq _080098C4 lsls r0, r5, 8 - ldr r1, =gUnknown_020223C4 + ldr r1, =gBlockRecvBuffer adds r0, r1 lsls r4, r5, 1 adds r1, r4, r5 @@ -752,7 +752,7 @@ _08009A78: blt _08009A70 cmp r5, 0 bne _08009A94 - ldr r1, =gUnknown_03003124 + ldr r1, =gReceivedRemoteLinkPlayers ldrb r0, [r1] cmp r0, 0 bne _08009A94 @@ -952,7 +952,7 @@ _08009C14: .pool _08009C40: movs r2, 0 - ldr r1, =gUnknown_020223C4 + ldr r1, =gBlockRecvBuffer mov r9, r1 adds r7, r3, 0 ldr r3, =gUnknown_03003090 @@ -996,7 +996,7 @@ _08009C70: cmp r0, 0x1 bne _08009D16 lsls r1, r6, 8 - ldr r0, =gUnknown_020223C4 + ldr r0, =gBlockRecvBuffer adds r1, r0 mov r8, r1 lsls r0, r6, 3 @@ -1080,7 +1080,7 @@ _08009D3E: adds r2, r3 ldrh r2, [r2] movs r0, 0 - bl link_0800A448 + bl SendBlock b _08009D6E .pool _08009D64: @@ -1321,7 +1321,7 @@ _08009F6A: thumb_func_start sub_8009F70 sub_8009F70: @ 8009F70 push {lr} - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0x1 bne _08009F80 @@ -1526,7 +1526,7 @@ sub_800A0C8: @ 800A0C8 adds r5, r0, 0 adds r6, r1, 0 movs r7, 0 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r4, [r0] cmp r4, 0x1 beq _0800A0DA @@ -2008,8 +2008,8 @@ bitmask_all_link_players_but_self: @ 800A490 bx r1 thumb_func_end bitmask_all_link_players_but_self - thumb_func_start link_0800A448 -link_0800A448: @ 800A4AC + thumb_func_start SendBlock +SendBlock: @ 800A4AC push {lr} adds r3, r1, 0 lsls r2, 16 @@ -2030,7 +2030,7 @@ _0800A4CE: lsrs r0, 24 pop {r1} bx r1 - thumb_func_end link_0800A448 + thumb_func_end SendBlock thumb_func_start sub_800A4D8 sub_800A4D8: @ 800A4D8 @@ -2095,8 +2095,8 @@ _0800A546: .pool thumb_func_end sub_800A520 - thumb_func_start sub_800A550 -sub_800A550: @ 800A550 + thumb_func_start GetBlockReceivedStatus +GetBlockReceivedStatus: @ 800A550 push {lr} ldr r0, =gLinkVSyncDisabled ldrb r0, [r0] @@ -2122,7 +2122,7 @@ _0800A580: lsrs r0, 24 pop {r1} bx r1 - thumb_func_end sub_800A550 + thumb_func_end GetBlockReceivedStatus thumb_func_start sub_800A588 sub_800A588: @ 800A588 @@ -2148,8 +2148,8 @@ _0800A5AC: .pool thumb_func_end sub_800A588 - thumb_func_start sub_800A5B4 -sub_800A5B4: @ 800A5B4 + thumb_func_start ResetBlockReceivedFlags +ResetBlockReceivedFlags: @ 800A5B4 push {r4,lr} ldr r0, =gLinkVSyncDisabled ldrb r0, [r0] @@ -2179,7 +2179,7 @@ _0800A5E2: pop {r0} bx r0 .pool - thumb_func_end sub_800A5B4 + thumb_func_end ResetBlockReceivedFlags thumb_func_start sub_800A5EC sub_800A5EC: @ 800A5EC @@ -2573,7 +2573,7 @@ task00_link_test: @ 800A850 movs r2, 0x2 movs r3, 0x2 bl sub_800A6E8 - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r0, 24 movs r1, 0xF @@ -3813,7 +3813,7 @@ sub_800B3A4: @ 800B3A4 lsls r0, 24 lsrs r0, 24 lsls r2, r0, 8 - ldr r1, =gUnknown_020223C4 + ldr r1, =gBlockRecvBuffer adds r4, r2, r1 lsls r2, r0, 3 subs r2, r0 @@ -3907,7 +3907,7 @@ _0800B482: thumb_func_start sub_800B488 sub_800B488: @ 800B488 push {lr} - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0800B498 @@ -3923,7 +3923,7 @@ _0800B498: thumb_func_start sub_800B4A4 sub_800B4A4: @ 800B4A4 push {lr} - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r1, [r0] cmp r1, 0 bne _0800B4B2 @@ -3938,7 +3938,7 @@ _0800B4B2: thumb_func_start sub_800B4C0 sub_800B4C0: @ 800B4C0 push {lr} - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r1, [r0] cmp r1, 0 bne _0800B4CE @@ -11500,7 +11500,7 @@ _0800F18C: cmp r4, 0 bne _0800F1A8 bl sub_800EDD4 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers strb r4, [r0] b _0800F1D2 .pool @@ -11976,7 +11976,7 @@ _0800F514: bl sub_8011A64 _0800F58C: bl rfu_clearAllSlot - ldr r1, =gUnknown_03003124 + ldr r1, =gReceivedRemoteLinkPlayers movs r0, 0 strb r0, [r1] ldr r0, =gUnknown_03005000 @@ -12224,7 +12224,7 @@ _0800F786: thumb_func_start rfu_func_080F97B8 rfu_func_080F97B8: @ 800F794 push {lr} - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _0800F7C6 @@ -12430,7 +12430,7 @@ _0800F90E: ldrb r0, [r4, 0xC] cmp r0, 0 bne _0800F920 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _0800F920 @@ -12536,7 +12536,7 @@ _0800F9EA: orrs r0, r3 str r0, [r1] movs r4, 0 - ldr r0, =gUnknown_020223C4 + ldr r0, =gBlockRecvBuffer mov r9, r0 mov r12, r2 mov r1, r8 @@ -12599,7 +12599,7 @@ _0800FA5C: beq _0800FA7E b _0800FC08 _0800FA7E: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0800FA88 @@ -12610,7 +12610,7 @@ _0800FA88: beq _0800FA90 b _0800FC08 _0800FA90: - ldr r0, =gUnknown_020223C4 + ldr r0, =gBlockRecvBuffer bl sub_8010A70 b _0800FC08 .pool @@ -12662,7 +12662,7 @@ _0800FB10: ldrb r2, [r7, 0xC] cmp r2, 0 bne _0800FB78 - ldr r3, =gUnknown_03003124 + ldr r3, =gReceivedRemoteLinkPlayers ldrb r0, [r3] mov r6, r8 adds r6, 0x1 @@ -13410,7 +13410,7 @@ sub_801011C: @ 801011C push {lr} bl rfu_clearAllSlot bl sub_800C048 - ldr r1, =gUnknown_03003124 + ldr r1, =gReceivedRemoteLinkPlayers movs r0, 0 strb r0, [r1] ldr r2, =gUnknown_03005000 @@ -14374,14 +14374,14 @@ _080108B6: bne _080108C2 b _080109D2 _080108C2: - bl sub_800A5B4 + bl ResetBlockReceivedFlags bl sub_800B348 b _08010948 _080108CC: ldrb r0, [r5, 0xC] cmp r0, 0x1 bne _0801090C - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080108E8 @@ -14471,7 +14471,7 @@ _0801096E: _08010984: adds r0, r6, 0 bl DestroyTask - ldr r1, =gUnknown_03003124 + ldr r1, =gReceivedRemoteLinkPlayers movs r0, 0x1 strb r0, [r1] ldr r0, =0x00000ce8 @@ -14702,7 +14702,7 @@ _08010B6A: b _08010C52 .pool _08010B78: - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r0, 24 asrs r0, r4 @@ -14715,7 +14715,7 @@ _08010B8C: adds r0, r4, 0 bl sub_800A5EC lsls r2, r4, 8 - ldr r0, =gUnknown_020223C4 + ldr r0, =gBlockRecvBuffer adds r2, r0 ldr r1, =gLinkPlayers lsls r0, r4, 3 @@ -14799,7 +14799,7 @@ _08010C20: ldr r1, =gUnknown_020228C4 movs r0, 0 movs r2, 0xA0 - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 beq _08010CF0 @@ -14833,7 +14833,7 @@ _08010C94: lsls r0, 24 cmp r0, 0 beq _08010CF0 - bl sub_800A550 + bl GetBlockReceivedStatus movs r1, 0x1 ands r1, r0 cmp r1, 0 @@ -14841,7 +14841,7 @@ _08010C94: mov r0, sp movs r4, 0 strh r4, [r0] - ldr r1, =gUnknown_020223C4 + ldr r1, =gBlockRecvBuffer ldr r2, =0x0100007e bl CpuSet movs r0, 0 @@ -14924,7 +14924,7 @@ _08010D56: ldr r1, =gUnknown_020228C4 movs r0, 0 movs r2, 0x3C - bl link_0800A448 + bl SendBlock b _08010D7A .pool _08010D70: @@ -14938,17 +14938,17 @@ _08010D7A: strh r0, [r4, 0x8] b _08010DA6 _08010D82: - bl sub_800A550 + bl GetBlockReceivedStatus movs r4, 0x1 adds r1, r4, 0 ands r1, r0 cmp r1, 0 beq _08010DA6 - ldr r0, =gUnknown_020223C4 + ldr r0, =gBlockRecvBuffer bl sub_8010A14 movs r0, 0 bl sub_800A5EC - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers strb r4, [r0] adds r0, r5, 0 bl DestroyTask @@ -15701,7 +15701,7 @@ _0801136C: bics r3, r2 adds r2, r3, 0 strb r2, [r1] - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0x1 bne _080113B0 @@ -15912,7 +15912,7 @@ _08011544: movs r1, 0x5 movs r2, 0x5 bl nullsub_5 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0x1 bne _080115DE @@ -16397,7 +16397,7 @@ _08011958: ldrb r0, [r2, 0xC] cmp r0, 0x1 bne _08011996 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0x1 bne _080119B4 @@ -16423,7 +16423,7 @@ _08011996: ldrb r0, [r0] cmp r0, 0x2 beq _080119B4 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0x1 bne _080119B4 @@ -17502,7 +17502,7 @@ sub_801229C: @ 801229C push {r4-r7,lr} mov r7, r8 push {r7} - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r0, 24 movs r1, 0x1C @@ -18913,7 +18913,7 @@ _08012F14: strb r0, [r6, 0xC] b _08012F50 _08012F22: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _08012F50 @@ -19861,7 +19861,7 @@ _080137A6: b _08013A86 .pool _080137C4: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _0801387A @@ -20806,11 +20806,11 @@ _08013FDE: adds r1, r0 movs r0, 0 movs r2, 0x64 - bl link_0800A448 + bl SendBlock b _080140BC .pool _08013FFC: - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r0, 24 cmp r0, 0x3 @@ -20822,13 +20822,13 @@ _08013FFC: eors r1, r2 lsls r1, 24 lsrs r1, 16 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0x64 bl memcpy movs r0, 0x32 bl IncrementGameStat - bl sub_800A5B4 + bl ResetBlockReceivedFlags b _0801405A .pool _08014038: @@ -20843,7 +20843,7 @@ _08014038: movs r0, 0 adds r1, r4, 0 movs r2, 0xDC - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 beq _080140BC @@ -20854,7 +20854,7 @@ _0801405A: b _080140BC .pool _08014070: - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r0, 24 cmp r0, 0x3 @@ -20866,12 +20866,12 @@ _08014070: eors r1, r0 lsls r1, 24 lsrs r1, 16 - ldr r0, =gUnknown_020223C4 + ldr r0, =gBlockRecvBuffer adds r1, r0 adds r0, r4, 0 movs r2, 0xD8 bl memcpy - bl sub_800A5B4 + bl ResetBlockReceivedFlags ldr r1, =gUnknown_02032298 strb r7, [r1] movs r0, 0x6 @@ -20925,7 +20925,7 @@ _08014114: strh r0, [r4, 0x8] b _0801419E _0801411C: - bl sub_800A550 + bl GetBlockReceivedStatus adds r4, r0, 0 bl sub_800A9D8 lsls r4, 24 @@ -20938,7 +20938,7 @@ _0801411C: .pool _08014138: lsls r1, r4, 8 - ldr r0, =gUnknown_020223C4 + ldr r0, =gBlockRecvBuffer adds r3, r1, r0 movs r0, 0x64 muls r0, r4 @@ -20965,7 +20965,7 @@ _08014152: eors r0, r1 lsls r0, 24 lsrs r0, 16 - ldr r1, =gUnknown_020223C4 + ldr r1, =gBlockRecvBuffer adds r3, r0, r1 adds r0, r3, 0 adds r0, 0x60 @@ -20976,7 +20976,7 @@ _08014152: _08014190: bl sub_801B940 _08014194: - bl sub_800A5B4 + bl ResetBlockReceivedFlags adds r0, r6, 0 bl DestroyTask _0801419E: @@ -21665,7 +21665,7 @@ _08014854: movs r0, 0x4 strh r0, [r7] bl sub_800E3A8 - bl sub_800A5B4 + bl ResetBlockReceivedFlags b _080149B2 .pool _080148B8: @@ -21723,7 +21723,7 @@ _08014934: movs r0, 0 adds r1, r2, 0 movs r2, 0xE - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 beq _080149B2 @@ -21731,13 +21731,13 @@ _08014934: strh r0, [r7] b _080149B2 _0801494A: - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r0, 24 cmp r0, 0x3 bne _080149B2 - bl sub_800A5B4 - ldr r0, =gUnknown_020223C4 + bl ResetBlockReceivedFlags + ldr r0, =gBlockRecvBuffer movs r2, 0x80 lsls r2, 1 adds r1, r0, r2 @@ -21766,7 +21766,7 @@ _08014992: strh r0, [r7] b _080149B2 _0801499C: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _080149B2 @@ -22316,7 +22316,7 @@ _08014E8C: strb r0, [r5, 0xC] b _08014EF2 _08014E92: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _08014EF2 @@ -22636,7 +22636,7 @@ _08015180: b _080152A0 .pool _080151A4: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080151C2 @@ -23002,7 +23002,7 @@ _080154E0: b _08015604 .pool _08015504: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _08015522 @@ -23714,7 +23714,7 @@ _08015BB8: movs r0, 0x40 strb r0, [r1] _08015BBE: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _08015BCA @@ -23750,7 +23750,7 @@ _08015C24: movs r0, 0x5 bl _08016876 _08015C2A: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _08015C36 @@ -23785,7 +23785,7 @@ _08015C54: bne _08015C78 bl _08016878 _08015C78: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _08015C94 @@ -23918,7 +23918,7 @@ _08015DA6: bl _08016876 .pool _08015DD0: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _08015DF4 @@ -24212,7 +24212,7 @@ _08016084: movs r0, 0x1E bl sub_8015664 _08016092: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0801609E @@ -24241,7 +24241,7 @@ _080160C6: movs r0, 0x2 bl _08016876 _080160DA: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _080160E4 @@ -24452,7 +24452,7 @@ _080162D4: movs r0, 0x24 b _08016876 _080162DC: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r4, [r0] cmp r4, 0 beq _080162E6 @@ -30478,7 +30478,7 @@ _08019406: strb r0, [r5, 0x8] b _08019922 _0801940C: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _0801942C @@ -30646,7 +30646,7 @@ _0801956A: strb r0, [r5, 0x8] b _08019922 _08019574: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _0801957E @@ -30981,7 +30981,7 @@ _080197EE: strb r0, [r5, 0x8] b _08019922 _080197F8: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _08019810 @@ -31050,7 +31050,7 @@ _08019884: b _08019922 .pool _080198A0: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _08019922 @@ -33417,7 +33417,7 @@ _0801AB1E: lsls r2, 4 adds r1, r2, 0 strh r1, [r0] - ldr r0, =sub_8036760 + ldr r0, =CB2_InitBattle bl SetMainCallback2 pop {r4-r7} pop {r0} @@ -33741,7 +33741,7 @@ _0801AE7A: ldr r1, =gUnknown_020228C4 movs r0, 0 movs r2, 0x20 - bl link_0800A448 + bl SendBlock ldr r1, =gMain movs r2, 0x87 lsls r2, 3 @@ -33749,14 +33749,14 @@ _0801AE7A: b _0801AF8A .pool _0801AE98: - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r0, 24 cmp r0, 0x3 beq _0801AEA6 b _0801AFAE _0801AEA6: - ldr r1, =gUnknown_020223C4 + ldr r1, =gBlockRecvBuffer ldrh r0, [r1] cmp r0, 0x51 bne _0801AEE0 @@ -33782,7 +33782,7 @@ _0801AEA6: .pool _0801AEE0: bl sub_800AC34 - ldr r4, =gUnknown_020223C4 + ldr r4, =gBlockRecvBuffer bl GetMultiplayerId lsls r0, 24 lsrs r0, 16 @@ -33805,7 +33805,7 @@ _0801AF0C: movs r1, 0x8 _0801AF16: strb r1, [r0] - bl sub_800A5B4 + bl ResetBlockReceivedFlags b _0801AFAE .pool _0801AF24: @@ -33842,7 +33842,7 @@ _0801AF58: b _0801AFAE .pool _0801AF7C: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0801AFAE @@ -39072,7 +39072,7 @@ sub_801D938: @ 801D938 adds r3, r0, 0 adds r0, r1, 0 lsls r3, 8 - ldr r1, =gUnknown_020223C4 + ldr r1, =gBlockRecvBuffer adds r3, r1 adds r1, r3, 0 bl memcpy @@ -39085,7 +39085,7 @@ sub_801D938: @ 801D938 sub_801D954: @ 801D954 push {r4,lr} adds r4, r0, 0 - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r0, 24 asrs r0, r4 @@ -39273,7 +39273,7 @@ _0801DA7C: movs r0, 0 mov r1, sp movs r2, 0x8 - bl link_0800A448 + bl SendBlock b _0801DB3E .pool _0801DAC8: @@ -39300,7 +39300,7 @@ _0801DAC8: lsls r2, r0, 16 lsrs r2, 16 movs r0, 0 - bl link_0800A448 + bl SendBlock ldrh r0, [r4, 0x10] adds r0, 0x1 strh r0, [r4, 0x10] @@ -39310,7 +39310,7 @@ _0801DB08: adds r1, r3 movs r0, 0 movs r2, 0xFC - bl link_0800A448 + bl SendBlock ldrh r0, [r4, 0x10] adds r0, 0x1 strh r0, [r4, 0x10] @@ -39942,7 +39942,7 @@ _0801DFE0: adds r1, r0 movs r0, 0 movs r2, 0x28 - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 beq _0801E028 @@ -40416,7 +40416,7 @@ _0801E3D4: adds r1, r0 movs r0, 0 movs r2, 0x28 - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 beq _0801E414 @@ -40432,14 +40432,14 @@ _0801E410: _0801E412: strh r0, [r1, 0x6] _0801E414: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0801E458 b _0801E42C .pool _0801E424: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0801E438 @@ -40556,7 +40556,7 @@ _0801E50C: adds r1, r0 movs r0, 0 movs r2, 0x28 - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 beq _0801E5BC @@ -40564,7 +40564,7 @@ _0801E50C: b _0801E59A .pool _0801E540: - bl sub_800A550 + bl GetBlockReceivedStatus movs r1, 0x1 ands r1, r0 cmp r1, 0 @@ -40599,7 +40599,7 @@ _0801E584: adds r0, 0x1 strh r0, [r1, 0xA] _0801E590: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0801E5BC @@ -40683,7 +40683,7 @@ _0801E62E: adds r0, 0x1 strh r0, [r1, 0xA] _0801E638: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0801E662 @@ -40798,7 +40798,7 @@ _0801E724: adds r0, 0x1 strh r0, [r1, 0xA] _0801E730: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0801E75C @@ -40849,7 +40849,7 @@ _0801E784: .4byte _0801E802 .4byte _0801E820 _0801E798: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0801E7AC @@ -40883,7 +40883,7 @@ _0801E7C0: adds r1, r0 movs r0, 0 movs r2, 0x28 - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 beq _0801E830 @@ -42276,7 +42276,7 @@ _0801F2E0: .4byte _0801F494 .4byte _0801F438 _0801F300: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0801F30A @@ -42304,7 +42304,7 @@ _0801F30E: b _0801F4C4 .pool _0801F33C: - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r0, 24 strh r0, [r4, 0x6] @@ -42365,7 +42365,7 @@ _0801F3A2: movs r1, 0x2 ldrsh r0, [r4, r1] lsls r0, 8 - ldr r1, =gUnknown_020223C4 + ldr r1, =gBlockRecvBuffer adds r0, r1 ldrb r0, [r0] subs r0, 0x1 @@ -42406,7 +42406,7 @@ _0801F3F6: movs r2, 0x2 ldrsh r1, [r4, r2] lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 bl sub_801EFF8 cmp r0, 0 @@ -45486,7 +45486,7 @@ sub_8020C70: @ 8020C70 adds r4, r0, 0 movs r0, 0 mov r8, r0 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _08020C8E @@ -49731,7 +49731,7 @@ _08022F7A: movs r0, 0 adds r1, r4, 0 movs r2, 0x2 - bl link_0800A448 + bl SendBlock b _08023060 _08022FAA: bl sub_800A520 @@ -49742,7 +49742,7 @@ _08022FAA: strh r0, [r5, 0x10] b _08023060 _08022FBA: - bl sub_800A550 + bl GetBlockReceivedStatus ldr r2, =gUnknown_082F4448 ldrb r4, [r5, 0x9] subs r1, r4, 0x2 @@ -49755,7 +49755,7 @@ _08022FBA: movs r3, 0 cmp r3, r4 bcs _0802301E - ldr r7, =gUnknown_020223C4 + ldr r7, =gBlockRecvBuffer movs r6, 0 ldr r4, =gUnknown_0858AB24 _08022FDC: @@ -49796,7 +49796,7 @@ _08022FF6: _0802301E: movs r0, 0 strh r0, [r5, 0x10] - bl sub_800A5B4 + bl ResetBlockReceivedFlags movs r1, 0x18 ldrsh r0, [r5, r1] lsls r0, 8 @@ -51445,7 +51445,7 @@ _08023D12: movs r0, 0 adds r1, r4, 0 movs r2, 0x2 - bl link_0800A448 + bl SendBlock b _0802402E _08023D2A: bl sub_800A520 @@ -51456,7 +51456,7 @@ _08023D2A: _08023D36: b _08024004 _08023D38: - bl sub_800A550 + bl GetBlockReceivedStatus ldr r2, =gUnknown_082F4448 ldrb r3, [r7, 0x9] subs r1, r3, 0x2 @@ -51474,7 +51474,7 @@ _08023D50: adds r4, 0x42 cmp r8, r3 bcs _08023D7E - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer _08023D5E: mov r3, r8 lsls r1, r3, 5 @@ -51496,7 +51496,7 @@ _08023D7E: movs r0, 0 strh r0, [r7, 0x10] strh r0, [r4] - bl sub_800A5B4 + bl ResetBlockReceivedFlags ldrb r0, [r7, 0x8] cmp r0, 0 bne _08023D9C @@ -51788,7 +51788,7 @@ _08023FC4: movs r0, 0 ldr r1, [sp, 0xC] movs r2, 0x30 - bl link_0800A448 + bl SendBlock b _0802402E _08023FD0: bl sub_800A520 @@ -51797,7 +51797,7 @@ _08023FD0: beq _08024034 b _08024004 _08023FDC: - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -51808,11 +51808,11 @@ _08023FDC: movs r1, 0 movs r2, 0x30 bl memset - ldr r1, =gUnknown_020223C4 + ldr r1, =gBlockRecvBuffer adds r0, r4, 0 movs r2, 0x30 bl memcpy - bl sub_800A5B4 + bl ResetBlockReceivedFlags _08024004: movs r0, 0 strh r0, [r7, 0x10] @@ -52207,7 +52207,7 @@ _08024306: strh r5, [r0] movs r0, 0 movs r2, 0x2 - bl link_0800A448 + bl SendBlock b _080243AC _08024328: bl sub_800A520 @@ -52217,7 +52217,7 @@ _08024328: strh r5, [r4, 0x10] b _080243AC _08024336: - bl sub_800A550 + bl GetBlockReceivedStatus ldr r2, =gUnknown_082F4448 ldrb r3, [r4, 0x9] subs r1, r3, 0x2 @@ -52234,7 +52234,7 @@ _08024336: cmp r5, r3 bcs _08024374 adds r1, r6, 0 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer _0802435C: lsls r0, r5, 8 adds r0, r2 @@ -52264,7 +52264,7 @@ _08024390: movs r2, 0 bl sub_8022BEC _0802439A: - bl sub_800A5B4 + bl ResetBlockReceivedFlags movs r1, 0 movs r0, 0 strh r0, [r7] @@ -52485,7 +52485,7 @@ _08024528: bl sub_800AC34 b _08024558 _08024538: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0802455E @@ -53023,7 +53023,7 @@ sub_802493C: @ 802493C ldr r1, =gUnknown_03000DB0 movs r0, 0 str r0, [r1] - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _08024A10 @@ -53382,7 +53382,7 @@ _08024C5A: lsls r0, 24 cmp r0, 0 beq _08024D40 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _08024D20 @@ -53989,7 +53989,7 @@ _0802516C: thumb_func_start sub_8025170 sub_8025170: @ 8025170 push {r4,lr} - bl sub_800A550 + bl GetBlockReceivedStatus adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 @@ -54001,7 +54001,7 @@ sub_8025170: @ 8025170 movs r0, 0 b _08025192 _0802518C: - bl sub_800A5B4 + bl ResetBlockReceivedFlags movs r0, 0x1 _08025192: pop {r4} @@ -54031,7 +54031,7 @@ _080251BA: adds r1, 0x4A movs r0, 0 movs r2, 0x3C - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 beq _08025226 @@ -54115,7 +54115,7 @@ _08025252: adds r1, r2, r1 movs r0, 0 movs r2, 0x3C - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 beq _08025316 @@ -54139,7 +54139,7 @@ _08025282: _0802528E: ldr r0, [r5] adds r0, 0x4A - ldr r1, =gUnknown_020223C4 + ldr r1, =gBlockRecvBuffer movs r2, 0x3C bl memcpy ldr r1, [r5] @@ -54265,7 +54265,7 @@ _0802539C: strb r0, [r1] movs r0, 0 movs r2, 0x1 - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 beq _08025466 @@ -54302,7 +54302,7 @@ _080253DC: adds r3, r1, 0 movs r5, 0x86 lsls r5, 1 - ldr r4, =gUnknown_020223C4 + ldr r4, =gBlockRecvBuffer _080253FA: ldr r1, [r3] adds r1, r2, r1 @@ -54452,7 +54452,7 @@ _0802553C: strb r0, [r1] movs r0, 0 movs r2, 0x1 - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 beq _0802563C @@ -54486,7 +54486,7 @@ _08025578: adds r3, r1, 0 movs r5, 0x86 lsls r5, 1 - ldr r4, =gUnknown_020223C4 + ldr r4, =gBlockRecvBuffer _08025596: ldr r1, [r3] adds r1, r2, r1 @@ -54617,7 +54617,7 @@ _08025688: strb r0, [r1, 0x10] b _080256A0 _08025692: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _080256A0 @@ -54829,7 +54829,7 @@ _0802585C: bl sub_802903C ldr r0, [r4] bl sub_8024A30 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _08025882 @@ -54946,7 +54946,7 @@ _0802593E: adds r1, r0 movs r0, 0 movs r2, 0x1 - bl link_0800A448 + bl SendBlock lsls r0, 24 cmp r0, 0 beq _080259E8 @@ -54976,7 +54976,7 @@ _0802597E: cmp r2, r0 bcs _080259C4 adds r3, r1, 0 - ldr r5, =gUnknown_020223C4 + ldr r5, =gBlockRecvBuffer ldr r4, =0x0000318c _0802599A: ldr r0, [r3] @@ -58643,7 +58643,7 @@ sub_8027660: @ 8027660 push {lr} lsls r0, 24 lsrs r2, r0, 24 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0802768C @@ -64818,7 +64818,7 @@ sub_802A9A8: @ 802A9A8 adds r6, r1, 0 lsls r0, 16 lsrs r7, r0, 16 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _0802AA3C @@ -67232,7 +67232,7 @@ _0802BD02: b _0802BD24 .pool _0802BD14: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0802BD24 @@ -71211,7 +71211,7 @@ sub_802DBF8: @ 802DBF8 movs r6, 0 cmp r6, r10 bge _0802DC62 - ldr r0, =gUnknown_08300D38 + ldr r0, =gMonFrontPicCoords mov r9, r0 ldr r1, =gUnknown_02022D00 mov r8, r1 @@ -73081,7 +73081,7 @@ sub_802EAB0: @ 802EAB0 lsls r1, 3 ldr r0, =gTasks + 0x8 adds r4, r1, r0 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _0802EB14 diff --git a/asm/menu_helpers.s b/asm/menu_helpers.s index acc3065ea..423f653d9 100644 --- a/asm/menu_helpers.s +++ b/asm/menu_helpers.s @@ -533,7 +533,7 @@ sub_81221AC: @ 81221AC bl is_c1_link_related_active cmp r0, 0x1 beq _081221BE - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0x1 bne _081221C8 diff --git a/asm/mystery_event_menu.s b/asm/mystery_event_menu.s index 49de57848..df8e443a1 100644 --- a/asm/mystery_event_menu.s +++ b/asm/mystery_event_menu.s @@ -337,7 +337,7 @@ _08178C54: lsls r0, 24 cmp r0, 0 beq _08178D00 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _08178C68 @@ -435,13 +435,13 @@ _08178D28: _08178D36: b _08178E34 _08178D38: - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 cmp r0, 0 bne _08178D44 b _08178E58 _08178D44: - bl sub_800A5B4 + bl ResetBlockReceivedFlags ldr r1, =gMain movs r2, 0x87 lsls r2, 3 @@ -462,7 +462,7 @@ _08178D60: b _08178E3C .pool _08178D74: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r6, [r0] cmp r6, 0 bne _08178E58 diff --git a/asm/party_menu.s b/asm/party_menu.s index 4eb080b13..a881d4589 100755 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -13868,7 +13868,7 @@ sub_81B7810: @ 81B7810 adds r0, r7, 0 adds r1, r4, 0 movs r2, 0x1 - bl sub_813DA40 + bl BeginEvolutionScene adds r0, r5, 0 bl DestroyTask b _081B786E diff --git a/asm/pokeball.s b/asm/pokeball.s index 557813c19..4e637fb9d 100755 --- a/asm/pokeball.s +++ b/asm/pokeball.s @@ -17,7 +17,7 @@ sub_80753E8: @ 80753E8 ldr r1, =gDoingBattleAnim movs r0, 0x1 strb r0, [r1] - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r6, =gActiveBank ldrb r1, [r6] @@ -992,7 +992,7 @@ _08075C22: movs r2, 0xC bl PlayCry4 _08075C2E: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x4] mov r2, r8 @@ -1082,7 +1082,7 @@ _08075CD8: movs r2, 0xB bl PlayCry4 _08075CE4: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x4] mov r2, r8 @@ -1215,7 +1215,7 @@ _08075E00: lsls r0, 24 cmp r0, 0 beq _08075E56 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] ldrb r1, [r0, 0x9] @@ -1247,7 +1247,7 @@ _08075E56: lsls r0, 24 cmp r0, 0 beq _08075E70 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] ldrb r1, [r0, 0x9] @@ -1278,7 +1278,7 @@ _08075E9C: _08075EA0: movs r4, 0x2 _08075EA2: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x4] mov r2, r8 @@ -1508,7 +1508,7 @@ _0807605C: strh r1, [r0, 0x26] ldr r0, =gDoingBattleAnim strb r2, [r0] - ldr r4, =gUnknown_020244D0 + ldr r4, =gBattleSpritesDataPtr ldr r0, [r4] ldr r0, [r0, 0x4] lsls r1, r6, 1 @@ -1619,7 +1619,7 @@ _08076130: ands r0, r1 cmp r0, 0 beq _08076196 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x4] lsls r1, r7, 1 @@ -1819,7 +1819,7 @@ _080762F8: lsls r0, 24 cmp r0, 0 beq _08076358 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] ldrb r1, [r0, 0x9] @@ -1892,7 +1892,7 @@ sub_8076398: @ 8076398 lsls r0, 24 cmp r0, 0 beq _080763E8 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0, 0x8] ldrb r1, [r0, 0x9] diff --git a/asm/pokeblock_feed.s b/asm/pokeblock_feed.s index d82c5df07..1f8e45f0a 100644 --- a/asm/pokeblock_feed.s +++ b/asm/pokeblock_feed.s @@ -95,7 +95,7 @@ _08179C48: bl FreeAllSpritePalettes b _08179D32 _08179C4E: - bl init_uns_table_pokemon_copy + bl AllocateMonSpritesGfx ldr r1, =gMain movs r2, 0x87 lsls r2, 3 @@ -322,7 +322,7 @@ _08179E48: lsls r0, r5, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] ldr r1, [r1, 0x8] adds r2, r5, 0 @@ -797,7 +797,7 @@ sub_817A2C0: @ 817A2C0 ldr r0, =gUnknown_0203BD18 ldr r0, [r0] bl Free - bl sub_805F094 + bl FreeMonSpritesGfx _0817A304: pop {r4} pop {r0} diff --git a/asm/pokemon_item_effect.s b/asm/pokemon_item_effect.s index 5dc6452e9..49b205967 100644 --- a/asm/pokemon_item_effect.s +++ b/asm/pokemon_item_effect.s @@ -221,7 +221,7 @@ _0806BEE0: mov r0, r8 movs r2, 0 ldr r3, [sp, 0x10] - bl sub_813DA40 + bl BeginEvolutionScene movs r0, 0 bl _0806CD5C _0806BEF0: diff --git a/asm/pokemon_summary_screen.s b/asm/pokemon_summary_screen.s index 2ad67ba5a..bcc52c172 100755 --- a/asm/pokemon_summary_screen.s +++ b/asm/pokemon_summary_screen.s @@ -127,7 +127,7 @@ _081BF9EE: strb r1, [r0] movs r0, 0xFF bl sub_81C488C - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r0, [r0] cmp r0, 0 bne _081BFA12 @@ -1284,7 +1284,7 @@ sub_81C0484: @ 81C0484 movs r2, 0x80 lsls r2, 1 bl m4aMPlayVolumeControl - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r0, [r0] cmp r0, 0 bne _081C04E2 @@ -8807,7 +8807,7 @@ _081C4620: lsls r0, r2, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] ldr r1, [r1, 0x8] b _081C46D6 @@ -8817,12 +8817,12 @@ _081C4668: lsls r0, r2, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] b _081C46B0 .pool _081C4680: - ldr r0, =gBattleSpritesGfx + ldr r0, =gMonSpritesGfxPtr ldr r3, [r0] adds r4, r0, 0 cmp r3, 0 diff --git a/asm/pokenav.s b/asm/pokenav.s index fa0aaa9d0..0c7a80742 100755 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -28252,7 +28252,7 @@ _081D4FB6: lsls r0, 24 cmp r0, 0 beq _081D500C - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _081D4FE6 @@ -28280,7 +28280,7 @@ _081D4FEC: strb r0, [r4] b _081D500C _081D4FF8: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _081D500C @@ -28673,13 +28673,13 @@ _081D5374: bl sub_80097E8 b _081D53C0 _081D537A: - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 cmp r0, 0 bne _081D5386 b _081D548A _081D5386: - bl sub_800A5B4 + bl ResetBlockReceivedFlags movs r0, 0xF strb r0, [r4, 0x8] b _081D548A @@ -28694,7 +28694,7 @@ _081D5390: b _081D548A .pool _081D53A8: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _081D548A diff --git a/asm/record_mixing.s b/asm/record_mixing.s index a62022cc7..aacc5baa0 100644 --- a/asm/record_mixing.s +++ b/asm/record_mixing.s @@ -849,7 +849,7 @@ _080E745A: strh r0, [r5, 0x20] b _080E7566 _080E7464: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _080E746E @@ -1066,7 +1066,7 @@ sub_80E7630: @ 80E7630 ldr r1, =gTasks adds r0, r1 mov r10, r0 - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x4] @@ -1302,7 +1302,7 @@ sub_80E7810: @ 80E7810 sub_80E7820: @ 80E7820 lsls r0, 24 lsrs r0, 16 - ldr r1, =gUnknown_020223C4 + ldr r1, =gBlockRecvBuffer adds r0, r1 bx lr .pool @@ -2368,7 +2368,7 @@ _080E807C: bl sub_800AC34 b _080E80F2 _080E8090: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _080E810A diff --git a/asm/recorded_battle.s b/asm/recorded_battle.s index c84b518c3..e742cbe7d 100644 --- a/asm/recorded_battle.s +++ b/asm/recorded_battle.s @@ -95,7 +95,7 @@ sub_8184E58: @ 8184E58 ldrb r0, [r0] cmp r0, 0x1 bne _08184EA0 - ldr r1, =gUnknown_0203BD2C + ldr r1, =gRecordedBattleRngSeed ldr r0, =gRngValue ldr r0, [r0] str r0, [r1] @@ -112,7 +112,7 @@ _08184EA0: cmp r0, 0x2 bne _08184EAC ldr r0, =gRngValue - ldr r1, =gUnknown_0203BD2C + ldr r1, =gRecordedBattleRngSeed ldr r1, [r1] str r1, [r0] _08184EAC: @@ -271,8 +271,8 @@ _08184FF0: .pool thumb_func_end RecordedBattle_SetBankAction - thumb_func_start sub_8185008 -sub_8185008: @ 8185008 + thumb_func_start RecordedBattle_ClearBankAction +RecordedBattle_ClearBankAction: @ 8185008 push {r4-r7,lr} lsls r0, 24 lsrs r5, r0, 24 @@ -310,7 +310,7 @@ _08185046: pop {r0} bx r0 .pool - thumb_func_end sub_8185008 + thumb_func_end RecordedBattle_ClearBankAction thumb_func_start sub_8185054 sub_8185054: @ 8185054 @@ -348,7 +348,7 @@ _0818507A: movs r2, 0 movs r3, 0x10 bl BeginNormalPaletteFade - ldr r0, =sub_80384E4 + ldr r0, =CB2_QuitRecordedBattle bl SetMainCallback2 movs r0, 0xFF b _081850C6 @@ -681,8 +681,8 @@ _08185332: bx r1 thumb_func_end sub_81852F0 - thumb_func_start sub_8185338 -sub_8185338: @ 8185338 + thumb_func_start MoveRecordedBattleToSaveData +MoveRecordedBattleToSaveData: @ 8185338 push {r4-r7,lr} mov r7, r10 mov r6, r9 @@ -779,7 +779,7 @@ _081853BA: movs r4, 0x9D lsls r4, 3 adds r1, r7, r4 - ldr r5, =gUnknown_0203BD2C + ldr r5, =gRecordedBattleRngSeed ldr r0, [r5] str r0, [r1] ldr r0, =gUnknown_0203C7B8 @@ -1469,7 +1469,7 @@ _08185A14: pop {r1} bx r1 .pool - thumb_func_end sub_8185338 + thumb_func_end MoveRecordedBattleToSaveData thumb_func_start sub_8185A54 sub_8185A54: @ 8185A54 @@ -1576,7 +1576,7 @@ sub_8185B1C: @ 8185B1C ldr r0, =gMain ldr r1, =sub_8185AB0 str r1, [r0, 0x8] - ldr r0, =sub_8036760 + ldr r0, =CB2_InitBattle bl SetMainCallback2 adds r0, r4, 0 bl DestroyTask @@ -1701,7 +1701,7 @@ _08185C2A: adds r6, 0x1 cmp r6, 0x3 ble _08185BBE - ldr r1, =gUnknown_0203BD2C + ldr r1, =gRecordedBattleRngSeed movs r3, 0x9D lsls r3, 3 adds r0, r7, r3 @@ -2655,8 +2655,8 @@ sub_8186444: @ 8186444 .pool thumb_func_end sub_8186444 - thumb_func_start rfu_lacks_rfufunc -rfu_lacks_rfufunc: @ 8186450 + thumb_func_start sub_8186450 +sub_8186450: @ 8186450 push {lr} movs r1, 0 ldr r0, =gUnknown_0203CCD0 @@ -2669,7 +2669,7 @@ _0818645E: pop {r1} bx r1 .pool - thumb_func_end rfu_lacks_rfufunc + thumb_func_end sub_8186450 thumb_func_start sub_8186468 sub_8186468: @ 8186468 diff --git a/asm/reshow_battle_screen.s b/asm/reshow_battle_screen.s index 96d9c3658..64ebcdd00 100644 --- a/asm/reshow_battle_screen.s +++ b/asm/reshow_battle_screen.s @@ -98,10 +98,10 @@ _080A93B0: movs r0, 0x3 bl ShowBg bl ResetPaletteFade - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y strh r1, [r0] ldr r0, =gBattle_BG1_X strh r1, [r0] @@ -113,7 +113,7 @@ _080A93B0: strh r1, [r0] ldr r0, =gBattle_BG3_X strh r1, [r0] - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y strh r1, [r0] b _080A95D2 .pool @@ -128,7 +128,7 @@ _080A942C: b _080A95D2 .pool _080A9444: - bl sub_8035AA4 + bl LoadBattleTextboxAndBackground b _080A95D2 _080A944A: bl ResetSpriteData @@ -264,7 +264,7 @@ _080A94F8: adds r0, r4, 0 bl sub_805EE54 _080A955C: - ldr r1, =gUnknown_020244AC + ldr r1, =gActionSelectionCursor ldr r0, =gBankInMenu ldrb r0, [r0] adds r0, r1 @@ -275,7 +275,7 @@ _080A955C: ldrb r0, [r0] cmp r0, 0 beq _080A95D2 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080A95D2 @@ -348,7 +348,7 @@ sub_80A9614: @ 80A9614 lsls r0, 24 cmp r0, 0 beq _080A9676 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r4, 2 @@ -404,7 +404,7 @@ _080A96AA: bl sub_805DF84 b _080A96F4 _080A96B2: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r4, 2 @@ -459,7 +459,7 @@ sub_80A9708: @ 80A9708 bcc _080A9722 b _080A9AA0 _080A9722: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] lsls r2, r7, 2 @@ -591,7 +591,7 @@ _080A9786: adds r1, r7, r1 ldrb r1, [r1] bl StartSpriteAnim - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] ldr r2, [sp] @@ -808,7 +808,7 @@ _080A998C: adds r1, r7, r1 ldrb r1, [r1] bl StartSpriteAnim - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] ldr r1, [sp] @@ -839,7 +839,7 @@ _080A9A70: adds r2, r0 lsls r2, 2 adds r2, r1 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] ldr r1, [sp] diff --git a/asm/rom3.s b/asm/rom3.s index 9bd95c252..bde493568 100644 --- a/asm/rom3.s +++ b/asm/rom3.s @@ -5,8 +5,8 @@ .text - thumb_func_start battle_wireless_setup_if_required_maybe -battle_wireless_setup_if_required_maybe: @ 8032654 + thumb_func_start HandleLinkBattleSetup +HandleLinkBattleSetup: @ 8032654 push {lr} ldr r0, =gBattleTypeFlags ldr r0, [r0] @@ -20,7 +20,7 @@ battle_wireless_setup_if_required_maybe: @ 8032654 beq _0803266E bl sub_800B488 _0803266E: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0803267A @@ -34,10 +34,10 @@ _08032686: pop {r0} bx r0 .pool - thumb_func_end battle_wireless_setup_if_required_maybe + thumb_func_end HandleLinkBattleSetup - thumb_func_start sub_803269C -sub_803269C: @ 803269C + thumb_func_start SetUpBattleVarsAndBirchZigzagoon +SetUpBattleVarsAndBirchZigzagoon: @ 803269C push {r4-r7,lr} sub sp, 0x14 ldr r0, =gBattleMainFunc @@ -47,9 +47,9 @@ sub_803269C: @ 803269C str r0, [sp, 0x10] movs r1, 0 ldr r7, =gBattleBankFunc - ldr r6, =gUnknown_020244AC + ldr r6, =gActionSelectionCursor movs r2, 0 - ldr r5, =gUnknown_020244B0 + ldr r5, =gMoveSelectionCursor ldr r4, =nullsub_21 ldr r3, =gBanksBySide _080326B8: @@ -71,7 +71,7 @@ _080326B8: adds r1, r0, 0 cmp r1, 0x3 ble _080326B8 - bl battle_wireless_setup_if_required_maybe + bl HandleLinkBattleSetup ldr r0, =gBattleExecBuffer movs r5, 0 str r5, [r0] @@ -112,7 +112,7 @@ _08032728: pop {r0} bx r0 .pool - thumb_func_end sub_803269C + thumb_func_end SetUpBattleVarsAndBirchZigzagoon thumb_func_start sub_8032768 sub_8032768: @ 8032768 @@ -222,7 +222,7 @@ b_setup_bx: @ 8032824 cmp r5, 0 beq _080328E4 ldr r1, =gBattleMainFunc - ldr r0, =sub_8039ECC + ldr r0, =BeginBattleIntro str r0, [r1] movs r4, 0x80 lsls r4, 17 @@ -286,7 +286,7 @@ _080328E4: b _080329E0 _080328F0: ldr r0, =gBattleMainFunc - ldr r2, =sub_8039ECC + ldr r2, =BeginBattleIntro str r2, [r0] movs r1, 0x80 ands r1, r3 @@ -380,7 +380,7 @@ _080329CC: b _08032CB2 .pool _080329E0: - ldr r1, =sub_8039ECC + ldr r1, =BeginBattleIntro ldr r2, =gBattleMainFunc str r1, [r2] ldr r2, =gBattleBankFunc @@ -419,7 +419,7 @@ _08032A20: ands r0, r1 cmp r0, r1 bne _08032AA0 - ldr r0, =sub_8039ECC + ldr r0, =BeginBattleIntro ldr r1, =gBattleMainFunc str r0, [r1] ldr r0, =SetBankFuncToRecordedPlayerBufferRunCommand @@ -751,7 +751,7 @@ b_setup_bx_link: @ 8032CC0 cmp r4, 0 beq _08032D1C ldr r1, =gBattleMainFunc - ldr r0, =sub_8039ECC + ldr r0, =BeginBattleIntro str r0, [r1] ldr r2, =gBattleBankFunc ldr r0, =SetBankFuncToPlayerBufferRunCommand @@ -789,7 +789,7 @@ _08032D48: cmp r3, 0 beq _08032D98 ldr r1, =gBattleMainFunc - ldr r0, =sub_8039ECC + ldr r0, =BeginBattleIntro str r0, [r1] ldr r2, =gBattleBankFunc ldr r4, =SetBankFuncToPlayerBufferRunCommand @@ -840,7 +840,7 @@ _08032DD0: cmp r3, 0 beq _08032E1C ldr r1, =gBattleMainFunc - ldr r0, =sub_8039ECC + ldr r0, =BeginBattleIntro str r0, [r1] ldr r2, =gBattleBankFunc ldr r0, =SetBankFuncToPlayerBufferRunCommand @@ -904,7 +904,7 @@ _08032E8C: cmp r0, 0 beq _08032EA4 ldr r1, =gBattleMainFunc - ldr r0, =sub_8039ECC + ldr r0, =BeginBattleIntro str r0, [r1] _08032EA4: movs r0, 0 @@ -1790,7 +1790,7 @@ _080335A0: ldr r1, [r5] adds r1, r2 adds r2, r6, 0 - bl link_0800A448 + bl SendBlock ldrh r0, [r4, 0x1E] adds r0, 0x1 strh r0, [r4, 0x1E] @@ -1857,7 +1857,7 @@ sub_8033648: @ 8033648 mov r6, r9 mov r5, r8 push {r5-r7} - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _08033738 @@ -1869,12 +1869,12 @@ sub_8033648: @ 8033648 beq _08033738 bl sub_8011BD0 movs r4, 0 - ldr r0, =gUnknown_020223C4 + ldr r0, =gBlockRecvBuffer mov r10, r0 b _0803372C .pool _08033680: - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r0, 24 ldr r2, =gBitTable @@ -1891,7 +1891,7 @@ _08033680: lsls r0, r4, 8 mov r4, r10 adds r3, r0, r4 - ldr r1, =gUnknown_020223C8 + ldr r1, =gBlockRecvBuffer + 4 adds r0, r1 ldrh r6, [r0] ldr r7, =gTasks @@ -2247,8 +2247,8 @@ _0803396C: .pool thumb_func_end sub_8033940 - thumb_func_start dp01_build_cmdbuf_x04_4_4_4 -dp01_build_cmdbuf_x04_4_4_4: @ 8033980 + thumb_func_start EmitLoadMonSprite +EmitLoadMonSprite: @ 8033980 push {lr} lsls r0, 24 lsrs r0, 24 @@ -2262,7 +2262,7 @@ dp01_build_cmdbuf_x04_4_4_4: @ 8033980 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x04_4_4_4 + thumb_func_end EmitLoadMonSprite thumb_func_start EmitSwitchInAnim EmitSwitchInAnim: @ 80339A0 @@ -2301,8 +2301,8 @@ EmitReturnPokeToBall: @ 80339C4 .pool thumb_func_end EmitReturnPokeToBall - thumb_func_start dp01_build_cmdbuf_x07_7_7_7 -dp01_build_cmdbuf_x07_7_7_7: @ 80339E4 + thumb_func_start EmitDrawTrainerPic +EmitDrawTrainerPic: @ 80339E4 push {lr} lsls r0, 24 lsrs r0, 24 @@ -2317,7 +2317,7 @@ dp01_build_cmdbuf_x07_7_7_7: @ 80339E4 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x07_7_7_7 + thumb_func_end EmitDrawTrainerPic thumb_func_start EmitTrainerSlide EmitTrainerSlide: @ 8033A04 @@ -2570,8 +2570,8 @@ _08033BB6: .pool thumb_func_end EmitMoveAnimation - thumb_func_start dp01_build_cmdbuf_x10_TODO -dp01_build_cmdbuf_x10_TODO: @ 8033BE4 + thumb_func_start EmitPrintString +EmitPrintString: @ 8033BE4 push {r4-r7,lr} mov r7, r10 mov r6, r9 @@ -2685,7 +2685,7 @@ _08033C88: pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x10_TODO + thumb_func_end EmitPrintString thumb_func_start EmitPrintStringPlayerOnly EmitPrintStringPlayerOnly: @ 8033CFC @@ -2786,8 +2786,8 @@ _08033D7C: .pool thumb_func_end EmitPrintStringPlayerOnly - thumb_func_start dp01_build_cmdbuf_x12_a_bb -dp01_build_cmdbuf_x12_a_bb: @ 8033DE4 + thumb_func_start EmitChooseAction +EmitChooseAction: @ 8033DE4 push {r4,lr} adds r4, r1, 0 lsls r0, 24 @@ -2807,7 +2807,7 @@ dp01_build_cmdbuf_x12_a_bb: @ 8033DE4 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x12_a_bb + thumb_func_end EmitChooseAction thumb_func_start EmitCmd13 EmitCmd13: @ 8033E10 @@ -2827,8 +2827,8 @@ EmitCmd13: @ 8033E10 .pool thumb_func_end EmitCmd13 - thumb_func_start sub_8033E30 -sub_8033E30: @ 8033E30 + thumb_func_start EmitChooseMove +EmitChooseMove: @ 8033E30 push {r4-r6,lr} adds r5, r3, 0 lsls r0, 24 @@ -2858,10 +2858,10 @@ _08033E4C: pop {r0} bx r0 .pool - thumb_func_end sub_8033E30 + thumb_func_end EmitChooseMove - thumb_func_start sub_8033E6C -sub_8033E6C: @ 8033E6C + thumb_func_start EmitOpenBag +EmitOpenBag: @ 8033E6C push {r4,r5,lr} adds r4, r1, 0 lsls r0, 24 @@ -2886,7 +2886,7 @@ _08033E7E: pop {r0} bx r0 .pool - thumb_func_end sub_8033E6C + thumb_func_end EmitOpenBag thumb_func_start EmitChoosePokemon EmitChoosePokemon: @ 8033EA0 @@ -3532,8 +3532,8 @@ EmitFaintingCry: @ 803432C .pool thumb_func_end EmitFaintingCry - thumb_func_start dp01_build_cmdbuf_x2E_a -dp01_build_cmdbuf_x2E_a: @ 803434C + thumb_func_start EmitIntroSlide +EmitIntroSlide: @ 803434C push {lr} adds r3, r1, 0 lsls r0, 24 @@ -3547,10 +3547,10 @@ dp01_build_cmdbuf_x2E_a: @ 803434C pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x2E_a + thumb_func_end EmitIntroSlide - thumb_func_start dp01_build_cmdbuf_x2F_2F_2F_2F -dp01_build_cmdbuf_x2F_2F_2F_2F: @ 803436C + thumb_func_start EmitIntroTrainerBallThrow +EmitIntroTrainerBallThrow: @ 803436C push {lr} lsls r0, 24 lsrs r0, 24 @@ -3565,10 +3565,10 @@ dp01_build_cmdbuf_x2F_2F_2F_2F: @ 803436C pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x2F_2F_2F_2F + thumb_func_end EmitIntroTrainerBallThrow - thumb_func_start EmitCmd48 -EmitCmd48: @ 803438C + thumb_func_start EmitDrawPartyStatusSummary +EmitDrawPartyStatusSummary: @ 803438C push {r4,r5,lr} adds r4, r1, 0 lsls r0, 24 @@ -3604,7 +3604,7 @@ _080343B4: pop {r0} bx r0 .pool - thumb_func_end EmitCmd48 + thumb_func_end EmitDrawPartyStatusSummary thumb_func_start EmitCmd49 EmitCmd49: @ 80343D4 @@ -3624,8 +3624,8 @@ EmitCmd49: @ 80343D4 .pool thumb_func_end EmitCmd49 - thumb_func_start dp01_build_cmdbuf_x32_32_32_32 -dp01_build_cmdbuf_x32_32_32_32: @ 80343F4 + thumb_func_start Emit_x32 +Emit_x32: @ 80343F4 push {lr} lsls r0, 24 lsrs r0, 24 @@ -3640,7 +3640,7 @@ dp01_build_cmdbuf_x32_32_32_32: @ 80343F4 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x32_32_32_32 + thumb_func_end Emit_x32 thumb_func_start EmitSpriteInvisibility EmitSpriteInvisibility: @ 8034414 diff --git a/asm/rom4.s b/asm/rom4.s index 5250659e7..0a624620d 100644 --- a/asm/rom4.s +++ b/asm/rom4.s @@ -1375,7 +1375,7 @@ _080850C8: bl warp_shift bl set_current_map_header_from_sav1_save_old_name bl CopyFieldObjectTemplatesToSav1 - bl sav2_set_x9_depending_on_sav1_map + bl TrySetMapSaveWarpStatus bl ClearTempFieldEventData bl wild_pokemon_reroll bl prev_quest_postbuffer_cursor_backup_reset @@ -1463,7 +1463,7 @@ _080851A2: lsls r0, 24 lsrs r6, r0, 24 bl sub_80EB218 - bl sav2_set_x9_depending_on_sav1_map + bl TrySetMapSaveWarpStatus bl ClearTempFieldEventData bl wild_pokemon_reroll bl prev_quest_postbuffer_cursor_backup_reset @@ -3640,7 +3640,7 @@ VBlankCB_Field: @ 8086390 bl sub_80BA0A8 bl FieldUpdateBgTilemapScroll bl TransferPlttBuffer - bl sub_80A09D0 + bl TransferTilesetAnimsBuffer pop {r0} bx r0 thumb_func_end VBlankCB_Field diff --git a/asm/rom6.s b/asm/rom6.s index cd1421b4f..0a8960811 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -258,7 +258,7 @@ sub_813561C: @ 813561C thumb_func_start sub_8135654 sub_8135654: @ 8135654 push {r4,lr} - bl sub_81797DC + bl ShouldDoBrailleStrengthEffect lsls r0, 24 cmp r0, 0 beq _0813568C @@ -404,7 +404,7 @@ sub_8135780: @ 8135780 lsrs r0, r2, 16 strh r0, [r1, 0x18] strh r2, [r1, 0x1A] - bl sub_81795E8 + bl ShouldDoBrailleDigEffect lsls r0, 24 cmp r0, 0 bne _081357AC @@ -422,12 +422,12 @@ sub_81357BC: @ 81357BC push {r4,lr} movs r0, 0x26 bl FieldEffectActiveListRemove - bl sub_81795E8 + bl ShouldDoBrailleDigEffect lsls r0, 24 lsrs r4, r0, 24 cmp r4, 0 beq _081357D6 - bl sub_817963C + bl DoBrailleDigEffect b _081357EE _081357D6: ldr r0, =task08_080A1C44 @@ -3329,7 +3329,7 @@ _081370E2: thumb_func_start sub_81370FC sub_81370FC: @ 81370FC push {r4,lr} - bl sub_81798D0 + bl ShouldDoBrailleFlyEffect lsls r0, 24 cmp r0, 0 beq _08137134 @@ -4705,7 +4705,7 @@ _08137CAC: thumb_func_start sub_8137CB4 sub_8137CB4: @ 8137CB4 push {lr} - ldr r0, =sub_8177888 + ldr r0, =CB2_ShowDiploma bl SetMainCallback2 bl ScriptContext2_Enable pop {r0} @@ -11564,7 +11564,7 @@ sub_813B534: @ 813B534 str r0, [r2] movs r0, 0 str r0, [r1] - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0813B552 @@ -11651,11 +11651,11 @@ _0813B5FE: lsrs r0, 24 ldr r1, =gSpecialVar_0x8004 movs r2, 0x2 - bl link_0800A448 + bl SendBlock b _0813B708 .pool _0813B614: - bl sub_800A550 + bl GetBlockReceivedStatus movs r1, 0x2 ands r1, r0 cmp r1, 0 @@ -11669,7 +11669,7 @@ _0813B622: b _0813B790 _0813B62E: ldr r5, =gSpecialVar_0x8005 - ldr r0, =gUnknown_020223C4 + ldr r0, =gBlockRecvBuffer movs r1, 0x80 lsls r1, 1 adds r0, r1 @@ -11738,11 +11738,11 @@ _0813B6C2: lsrs r0, 24 ldr r1, =gScriptResult movs r2, 0x2 - bl link_0800A448 + bl SendBlock b _0813B708 .pool _0813B6E4: - bl sub_800A550 + bl GetBlockReceivedStatus movs r1, 0x1 ands r1, r0 cmp r1, 0 @@ -11752,7 +11752,7 @@ _0813B6E4: cmp r0, 0 beq _0813B790 ldr r1, =gScriptResult - ldr r0, =gUnknown_020223C4 + ldr r0, =gBlockRecvBuffer ldrh r0, [r0] strh r0, [r1] movs r0, 0 diff --git a/asm/rom_80A5C6C.s b/asm/rom_80A5C6C.s index 0f6f5a623..cf09bf148 100644 --- a/asm/rom_80A5C6C.s +++ b/asm/rom_80A5C6C.s @@ -94,7 +94,7 @@ _080A5D28: lsls r0, 24 cmp r0, 0 beq _080A5D60 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r5, 2 @@ -112,7 +112,7 @@ _080A5D28: b _080A5D7E .pool _080A5D60: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r5, 2 @@ -195,7 +195,7 @@ _080A5E00: ldr r2, [r2, 0x8] b _080A5E42 _080A5E04: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] lsls r1, r4, 2 @@ -285,7 +285,7 @@ _080A5EC0: _080A5EC8: cmp r5, 0xC9 bne _080A5F58 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] lsls r1, r4, 2 @@ -344,7 +344,7 @@ _080A5F44: lsls r0, 16 lsrs r0, 16 _080A5F4E: - ldr r1, =gUnknown_08300D38 + ldr r1, =gMonFrontPicCoords lsls r0, 2 b _080A5F90 .pool @@ -352,7 +352,7 @@ _080A5F58: ldr r0, =0x00000181 cmp r5, r0 bne _080A5F7C - ldr r0, =gUnknown_08525F78 + ldr r0, =gCastformFrontSpriteCoords ldr r1, =gBattleMonForms adds r1, r4, r1 ldrb r1, [r1] @@ -366,11 +366,11 @@ _080A5F7C: lsls r0, 1 cmp r5, r0 bls _080A5F8C - ldr r0, =gUnknown_08300D38 + ldr r0, =gMonFrontPicCoords b _080A5F92 .pool _080A5F8C: - ldr r1, =gUnknown_08300D38 + ldr r1, =gMonFrontPicCoords _080A5F8E: lsls r0, r5, 2 _080A5F90: @@ -546,7 +546,7 @@ _080A60E4: ldrh r1, [r2] b _080A610E _080A60E8: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r4, 2 @@ -654,7 +654,7 @@ sub_80A6190: @ 80A6190 lsls r0, 24 cmp r0, 0 beq _080A61E4 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r5, 2 @@ -672,7 +672,7 @@ sub_80A6190: @ 80A6190 b _080A6202 .pool _080A61E4: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r5, 2 @@ -2976,7 +2976,7 @@ _080A72B4: lsls r0, 30 cmp r0, 0 bne _080A7312 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0, 0x4] lsls r0, r7, 1 @@ -4571,7 +4571,7 @@ _080A7F78: lsls r0, 24 cmp r0, 0 bne _080A7FD8 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r5, 2 @@ -4606,7 +4606,7 @@ _080A7FD0: b _080A8026 .pool _080A7FD8: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] lsls r0, r5, 2 @@ -4641,7 +4641,7 @@ _080A8018: b _080A8042 .pool _080A8024: - ldr r0, =gUnknown_08300D38 + ldr r0, =gMonFrontPicCoords _080A8026: lsls r1, r2, 2 adds r1, r0 @@ -5155,7 +5155,7 @@ sub_80A8394: @ 80A8394 bl AllocSpritePalette lsls r0, 24 lsrs r5, r0, 24 - ldr r4, =gBattleSpritesGfx + ldr r4, =gMonSpritesGfxPtr ldr r0, [r4] cmp r0, 0 beq _080A8412 @@ -5200,7 +5200,7 @@ _080A8412: lsrs r0, 24 cmp r0, 0x1 beq _080A845E - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] ldr r2, [sp, 0x40] @@ -5213,7 +5213,7 @@ _080A845E: lsls r0, r6, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] movs r3, 0xBE lsls r3, 1 @@ -5226,7 +5226,7 @@ _080A8488: lsls r0, r6, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] movs r2, 0xBE lsls r2, 1 @@ -5263,7 +5263,7 @@ _080A84B0: lsrs r0, 24 cmp r0, 0x1 beq _080A84F6 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r1, [r0] ldr r3, [sp, 0x40] @@ -5276,7 +5276,7 @@ _080A84F6: lsls r0, r6, 3 ldr r1, =gMonBackPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] movs r2, 0xBE lsls r2, 1 @@ -5294,7 +5294,7 @@ _080A8524: lsls r0, r6, 3 ldr r1, =gMonBackPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] movs r3, 0xBE lsls r3, 1 @@ -5305,7 +5305,7 @@ _080A8524: mov r3, r8 bl LoadSpecialPokePic_2 _080A8540: - ldr r5, =gBattleSpritesGfx + ldr r5, =gMonSpritesGfxPtr ldr r0, [r5] movs r4, 0xBE lsls r4, 1 @@ -5338,7 +5338,7 @@ _080A8540: mov r2, r10 lsls r1, r2, 16 asrs r1, 16 - ldr r3, =gUnknown_08300D38 + ldr r3, =gMonFrontPicCoords b _080A85B2 .pool _080A85A0: @@ -5490,7 +5490,7 @@ _080A86C4: lsls r0, 24 cmp r0, 0 bne _080A8790 - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] mov r1, r8 @@ -5580,7 +5580,7 @@ _080A8784: b _080A8864 .pool _080A8790: - ldr r0, =gUnknown_020244D0 + ldr r0, =gBattleSpritesDataPtr ldr r0, [r0] ldr r0, [r0] mov r1, r8 @@ -5662,7 +5662,7 @@ _080A8834: add r0, r8 ldrb r0, [r0] lsls r0, 2 - ldr r1, =gUnknown_08525F78 + ldr r1, =gCastformFrontSpriteCoords adds r4, r0, r1 b _080A8866 .pool @@ -5671,13 +5671,13 @@ _080A8850: lsls r0, 1 cmp r7, r0 bls _080A8860 - ldr r4, =gUnknown_08300D38 + ldr r4, =gMonFrontPicCoords b _080A8866 .pool _080A8860: lsls r1, r7, 2 _080A8862: - ldr r0, =gUnknown_08300D38 + ldr r0, =gMonFrontPicCoords _080A8864: adds r4, r1, r0 _080A8866: diff --git a/asm/save_failed_screen.s b/asm/save_failed_screen.s deleted file mode 100644 index 182ff8954..000000000 --- a/asm/save_failed_screen.s +++ /dev/null @@ -1,707 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8178F44 -sub_8178F44: @ 8178F44 - push {r4,r5,lr} - sub sp, 0x18 - adds r5, r0, 0 - adds r4, r1, 0 - adds r3, r2, 0 - lsls r3, 24 - add r0, sp, 0x14 - movs r2, 0 - strb r2, [r0] - adds r1, r0, 0 - movs r0, 0xF - strb r0, [r1, 0x1] - movs r0, 0x3 - strb r0, [r1, 0x2] - ldr r0, =gUnknown_0203BD0E - ldrb r0, [r0] - lsls r4, 27 - lsrs r4, 24 - lsrs r3, 21 - adds r3, 0x1 - lsls r3, 24 - lsrs r3, 24 - str r2, [sp] - str r2, [sp, 0x4] - str r1, [sp, 0x8] - str r2, [sp, 0xC] - str r5, [sp, 0x10] - movs r1, 0x1 - adds r2, r4, 0 - bl AddTextPrinterParametrized2 - add sp, 0x18 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8178F44 - - thumb_func_start DoSaveFailedScreen -DoSaveFailedScreen: @ 8178F90 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =sub_8178FDC - bl SetMainCallback2 - ldr r0, =gUnknown_0203BCFC - strh r4, [r0] - ldr r1, =gUnknown_0203BCFE - movs r2, 0 - movs r0, 0 - strh r0, [r1] - strh r0, [r1, 0x2] - ldr r0, =gUnknown_0203BD0E - strb r2, [r0] - strb r2, [r0, 0x1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end DoSaveFailedScreen - - thumb_func_start sub_8178FC8 -sub_8178FC8: @ 8178FC8 - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end sub_8178FC8 - - thumb_func_start sub_8178FDC -sub_8178FDC: @ 8178FDC - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0xC - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r7, r0, r1 - ldrb r0, [r7] - cmp r0, 0 - beq _08178FF8 - cmp r0, 0x1 - bne _08178FF8 - b _0817925C -_08178FF8: - movs r0, 0 - bl SetVBlankCallback - movs r0, 0 - movs r1, 0 - bl SetGpuReg - movs r0, 0xE - movs r1, 0 - bl SetGpuReg - movs r0, 0xC - movs r1, 0 - bl SetGpuReg - movs r0, 0xA - movs r1, 0 - bl SetGpuReg - movs r0, 0x8 - movs r1, 0 - bl SetGpuReg - movs r0, 0x1C - movs r1, 0 - bl SetGpuReg - movs r0, 0x1E - movs r1, 0 - bl SetGpuReg - movs r0, 0x18 - movs r1, 0 - bl SetGpuReg - movs r0, 0x1A - movs r1, 0 - bl SetGpuReg - movs r0, 0x14 - movs r1, 0 - bl SetGpuReg - movs r0, 0x16 - movs r1, 0 - bl SetGpuReg - movs r0, 0x10 - movs r1, 0 - bl SetGpuReg - movs r0, 0x12 - movs r1, 0 - bl SetGpuReg - add r1, sp, 0x4 - movs r0, 0 - strh r0, [r1] - ldr r2, =0x040000d4 - str r1, [r2] - movs r1, 0xC0 - lsls r1, 19 - str r1, [r2, 0x4] - ldr r0, =0x8100c000 - str r0, [r2, 0x8] - ldr r0, [r2, 0x8] - movs r3, 0 - mov r8, r3 - str r3, [sp, 0x8] - add r4, sp, 0x8 - str r4, [r2] - movs r0, 0xE0 - lsls r0, 19 - str r0, [r2, 0x4] - ldr r0, =0x85000100 - str r0, [r2, 0x8] - ldr r0, [r2, 0x8] - add r0, sp, 0x4 - mov r3, r8 - strh r3, [r0] - str r0, [r2] - movs r0, 0xA0 - lsls r0, 19 - str r0, [r2, 0x4] - ldr r0, =0x81000200 - str r0, [r2, 0x8] - ldr r0, [r2, 0x8] - ldr r0, =gUnknown_085B0E04 - bl LZ77UnCompVram - ldr r0, =gUnknown_085B0A80 - ldr r1, =0x06007000 - bl LZ77UnCompVram - ldr r0, =gUnknown_085B0C0C - ldr r1, =0x06007800 - bl LZ77UnCompVram - ldr r0, =gUnknown_085EFDE4 - ldr r1, =0x06010020 - bl LZ77UnCompVram - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_085EFD88 - movs r0, 0 - movs r2, 0x3 - bl InitBgsFromTemplates - ldr r5, =0x0201e000 - movs r0, 0 - adds r1, r5, 0 - bl SetBgTilemapBuffer - mov r0, r8 - str r0, [sp, 0x8] - ldr r2, =0x05000200 - adds r0, r4, 0 - adds r1, r5, 0 - bl CpuSet - ldr r1, =gUnknown_0850E87C - movs r2, 0x90 - lsls r2, 1 - movs r6, 0x85 - lsls r6, 2 - movs r0, 0 - adds r3, r6, 0 - bl LoadBgTiles - ldr r0, =gUnknown_085EFD94 - bl InitWindows - ldr r0, =gUnknown_085EFD9C - bl AddWindowWithoutTileMap - ldr r4, =gUnknown_0203BD0E - strb r0, [r4] - ldrb r0, [r4] - movs r1, 0x80 - lsls r1, 4 - adds r2, r5, r1 - movs r1, 0x7 - bl SetWindowAttribute - ldr r0, =gUnknown_085EFDA4 - bl AddWindowWithoutTileMap - strb r0, [r4, 0x1] - ldrb r0, [r4, 0x1] - movs r3, 0xE8 - lsls r3, 5 - adds r5, r3 - movs r1, 0x7 - adds r2, r5, 0 - bl SetWindowAttribute - bl DeactivateAllTextPrinters - bl ResetSpriteData - bl ResetTasks - bl ResetPaletteFade - ldr r0, =gUnknown_085B0A00 - movs r1, 0 - movs r2, 0x40 - bl LoadPalette - ldr r0, =gUnknown_085EFDC4 - movs r1, 0x80 - lsls r1, 1 - movs r2, 0x20 - bl LoadPalette - ldr r0, =gUnknown_0850FEFC - movs r1, 0xE0 - movs r2, 0x20 - bl LoadPalette - ldr r0, =gUnknown_0860F074 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - ldrb r0, [r4] - movs r1, 0 - adds r2, r6, 0 - movs r3, 0xE - bl SetWindowBorderStyle - ldrb r0, [r4, 0x1] - movs r1, 0 - adds r2, r6, 0 - movs r3, 0xE - bl SetWindowBorderStyle - ldrb r0, [r4, 0x1] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldrb r0, [r4] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldrb r0, [r4, 0x1] - movs r1, 0x2 - bl CopyWindowToVram - ldrb r0, [r4] - movs r1, 0x1 - bl CopyWindowToVram - ldr r0, =gText_SaveFailedCheckingBackup - movs r1, 0x1 - movs r2, 0 - bl sub_8178F44 - movs r0, 0x1 - negs r0, r0 - mov r1, r8 - str r1, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - movs r0, 0x1 - bl EnableInterrupts - ldr r0, =sub_8178FC8 - bl SetVBlankCallback - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg - ldrb r0, [r7] - adds r0, 0x1 - strb r0, [r7] - b _08179272 - .pool -_0817925C: - bl UpdatePaletteFade - lsls r0, 24 - cmp r0, 0 - bne _08179272 - ldr r0, =sub_8179288 - bl SetMainCallback2 - ldr r0, =sub_8179454 - bl SetVBlankCallback -_08179272: - add sp, 0xC - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8178FDC - - thumb_func_start sub_8179288 -sub_8179288: @ 8179288 - push {r4-r6,lr} - movs r5, 0 - ldr r0, =gUnknown_0203BCFE - movs r1, 0x1 - strh r1, [r0] - ldr r1, =gDamagedSaveSectors - ldr r0, [r1] - cmp r0, 0 - beq _081792EC - adds r6, r1, 0 -_0817929C: - ldr r0, [r6] - bl sub_81795AC - lsls r0, 24 - cmp r0, 0 - bne _08179348 - ldr r4, =gUnknown_0203BD0E - ldrb r0, [r4] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r0, =gText_CheckCompleted - movs r1, 0x1 - movs r2, 0 - bl sub_8178F44 - ldr r0, =gUnknown_0203BCFC - ldrb r0, [r0] - bl HandleSavingData - ldr r0, [r6] - cmp r0, 0 - beq _081792DC - ldrb r0, [r4] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r0, =gText_SaveFailedCheckingBackup - movs r1, 0x1 - movs r2, 0 - bl sub_8178F44 -_081792DC: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, [r6] - cmp r0, 0 - beq _081792EC - cmp r5, 0x2 - bls _0817929C -_081792EC: - cmp r5, 0x3 - bne _0817931C - ldr r0, =gUnknown_0203BD0E - ldrb r0, [r0] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r0, =gText_BackupMemoryDamaged - b _08179330 - .pool -_0817931C: - ldr r0, =gUnknown_0203BD0E - ldrb r0, [r0] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r0, =gGameContinueCallback - ldr r0, [r0] - cmp r0, 0 - bne _08179370 - ldr r0, =gText_SaveCompleteGameCannotContinue -_08179330: - movs r1, 0x1 - movs r2, 0 - bl sub_8178F44 - b _0817937A - .pool -_08179348: - ldr r0, =gUnknown_0203BD0E - ldrb r0, [r0] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r0, =gText_BackupMemoryDamaged - movs r1, 0x1 - movs r2, 0 - bl sub_8178F44 - ldr r0, =sub_8179390 - bl SetMainCallback2 - b _08179380 - .pool -_08179370: - ldr r0, =gText_SaveCompletePressA - movs r1, 0x1 - movs r2, 0 - bl sub_8178F44 -_0817937A: - ldr r0, =sub_81793E0 - bl SetMainCallback2 -_08179380: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8179288 - - thumb_func_start sub_8179390 -sub_8179390: @ 8179390 - push {lr} - ldr r1, =gUnknown_0203BCFE - movs r0, 0 - strh r0, [r1] - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081793C4 - ldr r0, =gUnknown_0203BD0E - ldrb r0, [r0] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r0, =gText_GamePlayCannotBeContinued - movs r1, 0x1 - movs r2, 0 - bl sub_8178F44 - ldr r0, =sub_8178FC8 - bl SetVBlankCallback - ldr r0, =sub_81793E0 - bl SetMainCallback2 -_081793C4: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8179390 - - thumb_func_start sub_81793E0 -sub_81793E0: @ 81793E0 - push {lr} - sub sp, 0x4 - ldr r0, =gUnknown_0203BCFE - movs r2, 0 - strh r2, [r0] - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08179410 - movs r0, 0x1 - negs r0, r0 - str r2, [sp] - movs r1, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, =sub_8178FC8 - bl SetVBlankCallback - ldr r0, =sub_8179428 - bl SetMainCallback2 -_08179410: - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_81793E0 - - thumb_func_start sub_8179428 -sub_8179428: @ 8179428 - push {r4,r5,lr} - bl UpdatePaletteFade - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - bne _0817944E - ldr r5, =gGameContinueCallback - ldr r0, [r5] - cmp r0, 0 - bne _08179448 - bl DoSoftReset - b _0817944E - .pool -_08179448: - bl SetMainCallback2 - str r4, [r5] -_0817944E: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8179428 - - thumb_func_start sub_8179454 -sub_8179454: @ 8179454 - push {r4,r5,lr} - ldr r5, =gMain - ldr r0, [r5, 0x24] - lsrs r4, r0, 3 - movs r0, 0x7 - ands r4, r0 - ldr r0, =gUnknown_085EFD80 - ldr r1, [r0, 0x4] - ldr r0, [r0] - str r0, [r5, 0x38] - str r1, [r5, 0x3C] - ldrh r1, [r5, 0x3A] - ldr r0, =0xfffffe00 - ands r0, r1 - movs r1, 0x70 - orrs r0, r1 - strh r0, [r5, 0x3A] - adds r1, r5, 0 - adds r1, 0x38 - movs r0, 0x48 - strb r0, [r1] - ldr r0, =gUnknown_0203BCFE - ldrh r0, [r0] - cmp r0, 0 - beq _081794DC - ldr r3, =gUnknown_085EFDAC - lsls r2, r4, 1 - adds r2, r4 - adds r0, r2, r3 - ldrb r4, [r0] - ldrh r1, [r5, 0x3C] - ldr r0, =0xfffffc00 - ands r0, r1 - orrs r0, r4 - strh r0, [r5, 0x3C] - adds r0, r3, 0x2 - adds r0, r2, r0 - ldrb r1, [r0] - lsls r1, 4 - adds r3, 0x1 - adds r2, r3 - ldrb r0, [r2] - lsls r0, 3 - orrs r1, r0 - adds r3, r5, 0 - adds r3, 0x3B - movs r0, 0x1F - ands r1, r0 - lsls r1, 1 - ldrb r2, [r3] - movs r0, 0x3F - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - b _081794E8 - .pool -_081794DC: - ldrh r0, [r5, 0x3C] - ldr r1, =0xfffffc00 - ands r1, r0 - movs r0, 0x1 - orrs r1, r0 - strh r1, [r5, 0x3C] -_081794E8: - ldr r0, =gUnknown_030022F8 - movs r1, 0xE0 - lsls r1, 19 - movs r2, 0x1 - bl CpuFastSet - ldr r1, =gUnknown_0203BCFE - ldrh r0, [r1, 0x2] - cmp r0, 0 - beq _08179500 - subs r0, 0x1 - strh r0, [r1, 0x2] -_08179500: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8179454 - - thumb_func_start sub_8179514 -sub_8179514: @ 8179514 - push {r4,lr} - lsls r0, 16 - lsrs r0, 16 - ldr r4, =gSaveDataBuffer - movs r3, 0x80 - lsls r3, 5 - movs r1, 0 - adds r2, r4, 0 - bl ReadFlash - movs r1, 0 - ldr r2, =0x000003ff -_0817952C: - ldr r0, [r4] - cmp r0, 0 - beq _08179540 - movs r0, 0x1 - b _0817954E - .pool -_08179540: - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - adds r4, 0x4 - cmp r1, r2 - bls _0817952C - movs r0, 0 -_0817954E: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8179514 - - thumb_func_start sub_8179554 -sub_8179554: @ 8179554 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 16 - lsrs r6, r0, 16 - movs r0, 0 - ldr r1, =0x00000fff - mov r8, r1 - ldr r7, =ProgramFlashByte -_08179566: - movs r4, 0 - adds r5, r0, 0x1 -_0817956A: - ldr r3, [r7] - adds r0, r6, 0 - adds r1, r4, 0 - movs r2, 0 - bl _call_via_r3 - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, r8 - bls _0817956A - adds r0, r6, 0 - bl sub_8179514 - lsls r0, 24 - lsrs r1, r0, 24 - lsls r0, r5, 16 - lsrs r0, 16 - cmp r1, 0 - beq _08179596 - cmp r0, 0x81 - bls _08179566 -_08179596: - adds r0, r1, 0 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8179554 - - thumb_func_start sub_81795AC -sub_81795AC: @ 81795AC - push {r4-r6,lr} - adds r5, r0, 0 - movs r6, 0 -_081795B2: - movs r4, 0x1 - lsls r4, r6 - adds r0, r5, 0 - ands r0, r4 - cmp r0, 0 - beq _081795CC - adds r0, r6, 0 - bl sub_8179554 - lsls r0, 24 - cmp r0, 0 - bne _081795CC - bics r5, r4 -_081795CC: - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - cmp r6, 0x1F - bls _081795B2 - cmp r5, 0 - beq _081795DE - movs r0, 0x1 - b _081795E0 -_081795DE: - movs r0, 0 -_081795E0: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_81795AC - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/save_location.s b/asm/save_location.s deleted file mode 100755 index 1a5b3c6da..000000000 --- a/asm/save_location.s +++ /dev/null @@ -1,205 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sav1_are_mapnumbers_in_given_list -sav1_are_mapnumbers_in_given_list: @ 81AFC84 - push {r4,lr} - adds r2, r0, 0 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r1, 0x4 - ldrsb r1, [r0, r1] - lsls r1, 8 - ldrb r0, [r0, 0x5] - lsls r0, 24 - asrs r0, 24 - adds r0, r1 - lsls r0, 16 - lsrs r3, r0, 16 - ldrh r0, [r2] - ldr r1, =0x0000ffff - cmp r0, r1 - beq _081AFCC4 - adds r4, r1, 0 - adds r1, r2, 0 -_081AFCAA: - ldrh r0, [r1] - cmp r0, r3 - bne _081AFCBC - movs r0, 0x1 - b _081AFCC6 - .pool -_081AFCBC: - adds r1, 0x2 - ldrh r0, [r1] - cmp r0, r4 - bne _081AFCAA -_081AFCC4: - movs r0, 0 -_081AFCC6: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sav1_are_mapnumbers_in_given_list - - thumb_func_start sav1_is_in_pokecenter -sav1_is_in_pokecenter: @ 81AFCCC - push {lr} - ldr r0, =gUnknown_086143BC - bl sav1_are_mapnumbers_in_given_list - pop {r1} - bx r1 - .pool - thumb_func_end sav1_is_in_pokecenter - - thumb_func_start sub_81AFCDC -sub_81AFCDC: @ 81AFCDC - push {lr} - ldr r0, =gUnknown_0861440A - bl sav1_are_mapnumbers_in_given_list - pop {r1} - bx r1 - .pool - thumb_func_end sub_81AFCDC - - thumb_func_start sub_81AFCEC -sub_81AFCEC: @ 81AFCEC - push {lr} - ldr r0, =gUnknown_0861440E - bl sav1_are_mapnumbers_in_given_list - pop {r1} - bx r1 - .pool - thumb_func_end sub_81AFCEC - - thumb_func_start sav2_set_x9_bit3_when_sav1_in_pokecenter -sav2_set_x9_bit3_when_sav1_in_pokecenter: @ 81AFCFC - push {lr} - bl sav1_is_in_pokecenter - cmp r0, 0 - bne _081AFD18 - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldrb r1, [r2, 0x9] - movs r0, 0xFD - ands r0, r1 - b _081AFD22 - .pool -_081AFD18: - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldrb r1, [r2, 0x9] - movs r0, 0x2 - orrs r0, r1 -_081AFD22: - strb r0, [r2, 0x9] - pop {r0} - bx r0 - .pool - thumb_func_end sav2_set_x9_bit3_when_sav1_in_pokecenter - - thumb_func_start sub_81AFD2C -sub_81AFD2C: @ 81AFD2C - push {lr} - bl sub_81AFCDC - cmp r0, 0 - bne _081AFD48 - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldrb r1, [r2, 0x9] - movs r0, 0xFB - ands r0, r1 - b _081AFD52 - .pool -_081AFD48: - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldrb r1, [r2, 0x9] - movs r0, 0x4 - orrs r0, r1 -_081AFD52: - strb r0, [r2, 0x9] - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AFD2C - - thumb_func_start sub_81AFD5C -sub_81AFD5C: @ 81AFD5C - push {lr} - bl sub_81AFCEC - cmp r0, 0 - bne _081AFD78 - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldrb r1, [r2, 0x9] - movs r0, 0xF7 - ands r0, r1 - b _081AFD82 - .pool -_081AFD78: - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldrb r1, [r2, 0x9] - movs r0, 0x8 - orrs r0, r1 -_081AFD82: - strb r0, [r2, 0x9] - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AFD5C - - thumb_func_start sav2_set_x9_depending_on_sav1_map -sav2_set_x9_depending_on_sav1_map: @ 81AFD8C - push {lr} - bl sav2_set_x9_bit3_when_sav1_in_pokecenter - bl sub_81AFD2C - bl sub_81AFD5C - pop {r0} - bx r0 - thumb_func_end sav2_set_x9_depending_on_sav1_map - - thumb_func_start sub_81AFDA0 -sub_81AFDA0: @ 81AFDA0 - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - adds r2, 0xA8 - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 8 - orrs r0, r1 - movs r1, 0x1 - orrs r0, r1 - movs r1, 0x2 - orrs r0, r1 - movs r1, 0x4 - orrs r0, r1 - movs r1, 0x10 - orrs r0, r1 - movs r1, 0x20 - orrs r0, r1 - movs r1, 0x8 - orrs r0, r1 - str r0, [r2] - bx lr - .pool - thumb_func_end sub_81AFDA0 - - thumb_func_start sub_81AFDD0 -sub_81AFDD0: @ 81AFDD0 - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldrb r1, [r2, 0x9] - movs r0, 0x80 - orrs r0, r1 - strb r0, [r2, 0x9] - bx lr - .pool - thumb_func_end sub_81AFDD0 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/script_pokemon_util_80F87D8.s b/asm/script_pokemon_util_80F87D8.s index e26194298..231879f02 100644 --- a/asm/script_pokemon_util_80F87D8.s +++ b/asm/script_pokemon_util_80F87D8.s @@ -670,7 +670,7 @@ sub_80F8D28: @ 80F8D28 beq _080F8D44 b _080F8E9C _080F8D44: - bl init_uns_table_pokemon_copy + bl AllocateMonSpritesGfx movs r0, 0xA mov r9, r0 movs r1, 0x3 @@ -710,7 +710,7 @@ _080F8D44: lsls r0, r6, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] ldr r1, [r1, 0x8] adds r2, r6, 0 @@ -722,7 +722,7 @@ _080F8DC4: lsls r0, r6, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] ldr r1, [r1, 0x8] adds r2, r6, 0 @@ -842,7 +842,7 @@ sub_80F8EB8: @ 80F8EB8 ldrh r0, [r1, 0x8] adds r0, 0x1 strh r0, [r1, 0x8] - bl sub_805F094 + bl FreeMonSpritesGfx _080F8EDC: pop {r0} bx r0 @@ -1093,7 +1093,7 @@ sub_80F90DC: @ 80F90DC ands r0, r1 cmp r0, 0 beq _080F90FE - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080F90FE @@ -1116,7 +1116,7 @@ sub_80F910C: @ 80F910C ands r0, r1 cmp r0, 0 beq _080F9126 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080F9126 diff --git a/asm/starter_choose.s b/asm/starter_choose.s index 7e998c45f..da42959ea 100644 --- a/asm/starter_choose.s +++ b/asm/starter_choose.s @@ -122,12 +122,12 @@ set_256color_bg_bg0: @ 8133F0C ldr r0, =0x81000200 str r0, [r2, 0x8] ldr r0, [r2, 0x8] - ldr r0, =gUnknown_085B0E04 + ldr r0, =gBirchHelpGfx bl LZ77UnCompVram - ldr r0, =gUnknown_085B0A80 + ldr r0, =gBirchBagTilemap ldr r1, =0x06003000 bl LZ77UnCompVram - ldr r0, =gUnknown_085B0C0C + ldr r0, =gBirchGrassTilemap ldr r1, =0x06003800 bl LZ77UnCompVram movs r0, 0 @@ -155,7 +155,7 @@ set_256color_bg_bg0: @ 8133F0C movs r1, 0xE0 movs r2, 0x20 bl LoadPalette - ldr r0, =gUnknown_085B0A00 + ldr r0, =gBirchBagGrassPal movs r1, 0 movs r2, 0x40 bl LoadPalette diff --git a/asm/tileset.s b/asm/tileset.s deleted file mode 100644 index 0605c7621..000000000 --- a/asm/tileset.s +++ /dev/null @@ -1,1793 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_80A0954 -@ void sub_80A0954() -sub_80A0954: @ 80A0954 - push {lr} - sub sp, 0x4 - ldr r1, =gUnknown_03000F34 - movs r0, 0 - strb r0, [r1] - movs r0, 0 - str r0, [sp] - ldr r1, =gUnknown_02037624 - ldr r2, =0x0500003c - mov r0, sp - bl CpuSet - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A0954 - - thumb_func_start sub_80A0980 -sub_80A0980: @ 80A0980 - push {r4-r6,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r2, 16 - lsrs r6, r2, 16 - ldr r3, =gUnknown_03000F34 - ldrb r0, [r3] - cmp r0, 0x13 - bhi _080A09C0 - ldr r2, =gUnknown_02037624 - adds r1, r0, 0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - str r4, [r0] - ldrb r1, [r3] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r1, r2, 0x4 - adds r0, r1 - str r5, [r0] - ldrb r1, [r3] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r6, [r0, 0x8] - ldrb r0, [r3] - adds r0, 0x1 - strb r0, [r3] -_080A09C0: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A0980 - - thumb_func_start sub_80A09D0 -sub_80A09D0: @ 80A09D0 - push {r4-r6,lr} - movs r3, 0 - ldr r4, =gUnknown_03000F34 - adds r6, r4, 0 - ldrb r0, [r4] - cmp r3, r0 - bge _080A0A02 - ldr r2, =0x040000d4 - ldr r1, =gUnknown_02037624 - movs r5, 0x80 - lsls r5, 24 -_080A09E6: - ldr r0, [r1] - str r0, [r2] - ldr r0, [r1, 0x4] - str r0, [r2, 0x4] - ldrh r0, [r1, 0x8] - lsrs r0, 1 - orrs r0, r5 - str r0, [r2, 0x8] - ldr r0, [r2, 0x8] - adds r1, 0xC - adds r3, 0x1 - ldrb r0, [r4] - cmp r3, r0 - blt _080A09E6 -_080A0A02: - movs r0, 0 - strb r0, [r6] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A09D0 - - thumb_func_start cur_mapheader_run_tileset_funcs_after_some_cpuset -cur_mapheader_run_tileset_funcs_after_some_cpuset: @ 80A0A18 - push {lr} - bl sub_80A0954 - bl cur_mapheader_run_tileset1_func - bl cur_mapheader_run_tileset2_func - pop {r0} - bx r0 - thumb_func_end cur_mapheader_run_tileset_funcs_after_some_cpuset - - thumb_func_start sub_80A0A2C -sub_80A0A2C: @ 80A0A2C - push {lr} - bl cur_mapheader_run_tileset2_func - pop {r0} - bx r0 - thumb_func_end sub_80A0A2C - - thumb_func_start sub_80A0A38 -sub_80A0A38: @ 80A0A38 - push {r4,lr} - bl sub_80A0954 - ldr r2, =gUnknown_03000F36 - ldrh r0, [r2] - adds r0, 0x1 - strh r0, [r2] - ldr r1, =gUnknown_03000F38 - lsls r0, 16 - lsrs r0, 16 - ldrh r1, [r1] - cmp r0, r1 - bcc _080A0A56 - movs r0, 0 - strh r0, [r2] -_080A0A56: - ldr r4, =gUnknown_03000F3A - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - ldr r1, =gUnknown_03000F3C - lsls r0, 16 - lsrs r0, 16 - ldrh r1, [r1] - cmp r0, r1 - bcc _080A0A6E - movs r0, 0 - strh r0, [r4] -_080A0A6E: - ldr r0, =gUnknown_03000F40 - ldr r1, [r0] - cmp r1, 0 - beq _080A0A7C - ldrh r0, [r2] - bl _call_via_r1 -_080A0A7C: - ldr r0, =gUnknown_03000F44 - ldr r1, [r0] - cmp r1, 0 - beq _080A0A8A - ldrh r0, [r4] - bl _call_via_r1 -_080A0A8A: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A0A38 - - thumb_func_start cur_mapheader_run_tileset1_func -cur_mapheader_run_tileset1_func: @ 80A0AA8 - push {lr} - ldr r0, =gUnknown_03000F36 - movs r1, 0 - strh r1, [r0] - ldr r0, =gUnknown_03000F38 - strh r1, [r0] - ldr r1, =gUnknown_03000F40 - movs r0, 0 - str r0, [r1] - ldr r0, =gMapHeader - ldr r0, [r0] - ldr r0, [r0, 0x10] - cmp r0, 0 - beq _080A0ACE - ldr r0, [r0, 0x14] - cmp r0, 0 - beq _080A0ACE - bl _call_via_r0 -_080A0ACE: - pop {r0} - bx r0 - .pool - thumb_func_end cur_mapheader_run_tileset1_func - - thumb_func_start cur_mapheader_run_tileset2_func -cur_mapheader_run_tileset2_func: @ 80A0AE4 - push {lr} - ldr r0, =gUnknown_03000F3A - movs r1, 0 - strh r1, [r0] - ldr r0, =gUnknown_03000F3C - strh r1, [r0] - ldr r1, =gUnknown_03000F44 - movs r0, 0 - str r0, [r1] - ldr r0, =gMapHeader - ldr r0, [r0] - ldr r0, [r0, 0x14] - cmp r0, 0 - beq _080A0B0A - ldr r0, [r0, 0x14] - cmp r0, 0 - beq _080A0B0A - bl _call_via_r0 -_080A0B0A: - pop {r0} - bx r0 - .pool - thumb_func_end cur_mapheader_run_tileset2_func - - thumb_func_start TilesetCb_General -TilesetCb_General: @ 80A0B20 - ldr r1, =gUnknown_03000F36 - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F38 - movs r2, 0x80 - lsls r2, 1 - adds r0, r2, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F40 - ldr r0, =sub_80A0B70 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_General - - thumb_func_start TilesetCb_InsideBuilding -TilesetCb_InsideBuilding: @ 80A0B48 - ldr r1, =gUnknown_03000F36 - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F38 - movs r2, 0x80 - lsls r2, 1 - adds r0, r2, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F40 - ldr r0, =sub_80A0BB4 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_InsideBuilding - - thumb_func_start sub_80A0B70 -sub_80A0B70: @ 80A0B70 - push {r4,r5,lr} - lsls r5, r0, 16 - movs r0, 0xF0 - lsls r0, 12 - ands r0, r5 - lsrs r4, r0, 16 - cmp r4, 0 - bne _080A0B86 - lsrs r0, r5, 20 - bl sub_80A0BCC -_080A0B86: - cmp r4, 0x1 - bne _080A0B90 - lsrs r0, r5, 20 - bl sub_80A0BF4 -_080A0B90: - cmp r4, 0x2 - bne _080A0B9A - lsrs r0, r5, 20 - bl sub_80A0C1C -_080A0B9A: - cmp r4, 0x3 - bne _080A0BA4 - lsrs r0, r5, 20 - bl sub_80A0C44 -_080A0BA4: - cmp r4, 0x4 - bne _080A0BAE - lsrs r0, r5, 20 - bl sub_80A12AC -_080A0BAE: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80A0B70 - - thumb_func_start sub_80A0BB4 -sub_80A0BB4: @ 80A0BB4 - push {lr} - lsls r1, r0, 16 - movs r0, 0xE0 - lsls r0, 11 - ands r0, r1 - cmp r0, 0 - bne _080A0BC8 - lsrs r0, r1, 19 - bl sub_80A1688 -_080A0BC8: - pop {r0} - bx r0 - thumb_func_end sub_80A0BB4 - - thumb_func_start sub_80A0BCC -sub_80A0BCC: @ 80A0BCC - push {lr} - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - ldr r0, =gUnknown_08510764 - lsrs r1, 14 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06003f80 - movs r2, 0x80 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A0BCC - - thumb_func_start sub_80A0BF4 -sub_80A0BF4: @ 80A0BF4 - push {lr} - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x7 - ands r0, r1 - ldr r1, =gUnknown_08512574 - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - ldr r1, =0x06003600 - movs r2, 0xF0 - lsls r2, 2 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A0BF4 - - thumb_func_start sub_80A0C1C -sub_80A0C1C: @ 80A0C1C - push {lr} - lsls r0, 16 - movs r1, 0xE0 - lsls r1, 11 - ands r1, r0 - ldr r0, =gUnknown_08512E54 - lsrs r1, 14 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06003a00 - movs r2, 0xA0 - lsls r2, 1 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A0C1C - - thumb_func_start sub_80A0C44 -sub_80A0C44: @ 80A0C44 - push {lr} - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - ldr r0, =gUnknown_08513174 - lsrs r1, 14 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06003e00 - movs r2, 0xC0 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A0C44 - - thumb_func_start TilesetCb_Petalburg -TilesetCb_Petalburg: @ 80A0C6C - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - movs r0, 0 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_Petalburg - - thumb_func_start TilesetCb_Rustboro -TilesetCb_Rustboro: @ 80A0C94 - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A103C - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_Rustboro - - thumb_func_start TilesetCb_Dewford -TilesetCb_Dewford: @ 80A0CC0 - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A10B8 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_Dewford - - thumb_func_start TilesetCb_Slateport -TilesetCb_Slateport: @ 80A0CEC - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A10D0 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_Slateport - - thumb_func_start TilesetCb_Mauville -TilesetCb_Mauville: @ 80A0D18 - ldr r1, =gUnknown_03000F3A - ldr r0, =gUnknown_03000F36 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A10E8 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_Mauville - - thumb_func_start TilesetCb_Lavaridge -TilesetCb_Lavaridge: @ 80A0D48 - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A115C - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_Lavaridge - - thumb_func_start TilesetCb_Fallarbor -TilesetCb_Fallarbor: @ 80A0D74 - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - movs r0, 0 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_Fallarbor - - thumb_func_start TilesetCb_Fortree -TilesetCb_Fortree: @ 80A0D9C - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - movs r0, 0 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_Fortree - - thumb_func_start TilesetCb_Lilycove -TilesetCb_Lilycove: @ 80A0DC4 - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - movs r0, 0 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_Lilycove - - thumb_func_start TilesetCb_Mossdeep -TilesetCb_Mossdeep: @ 80A0DEC - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - movs r0, 0 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_Mossdeep - - thumb_func_start TilesetCb_EverGrande -TilesetCb_EverGrande: @ 80A0E14 - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A1188 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_EverGrande - - thumb_func_start TilesetCb_Pacifidlog -TilesetCb_Pacifidlog: @ 80A0E40 - ldr r1, =gUnknown_03000F3A - ldr r0, =gUnknown_03000F36 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A11FC - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_Pacifidlog - - thumb_func_start TilesetCb_Sootopolis -TilesetCb_Sootopolis: @ 80A0E70 - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A122C - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_Sootopolis - - thumb_func_start TilesetCb_BattleFrontierOutsideWest -TilesetCb_BattleFrontierOutsideWest: @ 80A0E9C - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A127C - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_BattleFrontierOutsideWest - - thumb_func_start TilesetCb_BattleFrontierOutsideEast -TilesetCb_BattleFrontierOutsideEast: @ 80A0EC8 - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A1294 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_BattleFrontierOutsideEast - - thumb_func_start TilesetCb_Underwater -TilesetCb_Underwater: @ 80A0EF4 - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - movs r0, 0x80 - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A1244 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_Underwater - - thumb_func_start TilesetCb_SootopolisGym -TilesetCb_SootopolisGym: @ 80A0F18 - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - movs r0, 0xF0 - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A15D8 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_SootopolisGym - - thumb_func_start TilesetCb_Cave -TilesetCb_Cave: @ 80A0F3C - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A1260 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_Cave - - thumb_func_start TilesetCb_EliteFour -TilesetCb_EliteFour: @ 80A0F68 - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - movs r0, 0x80 - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A15F0 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_EliteFour - - thumb_func_start TilesetCb_MauvilleGym -TilesetCb_MauvilleGym: @ 80A0F8C - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A15C0 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_MauvilleGym - - thumb_func_start TilesetCb_BikeShop -TilesetCb_BikeShop: @ 80A0FB8 - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A161C - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_BikeShop - - thumb_func_start TilesetCb_BattlePyramid -TilesetCb_BattlePyramid: @ 80A0FE4 - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A1634 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_BattlePyramid - - thumb_func_start TilesetCb_BattleDome -TilesetCb_BattleDome: @ 80A1010 - ldr r1, =gUnknown_03000F3A - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000F3C - ldr r0, =gUnknown_03000F38 - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gUnknown_03000F44 - ldr r0, =sub_80A1658 - str r0, [r1] - bx lr - .pool - thumb_func_end TilesetCb_BattleDome - - thumb_func_start sub_80A103C -sub_80A103C: @ 80A103C - push {r4-r6,lr} - lsls r5, r0, 16 - movs r0, 0xE0 - lsls r0, 11 - ands r0, r5 - lsrs r6, r0, 16 - cmp r6, 0 - bne _080A105C - lsrs r4, r5, 19 - adds r0, r4, 0 - movs r1, 0 - bl sub_80A1434 - adds r0, r4, 0 - bl sub_80A1470 -_080A105C: - cmp r6, 0x1 - bne _080A1068 - lsrs r0, r5, 19 - movs r1, 0x1 - bl sub_80A1434 -_080A1068: - cmp r6, 0x2 - bne _080A1074 - lsrs r0, r5, 19 - movs r1, 0x2 - bl sub_80A1434 -_080A1074: - cmp r6, 0x3 - bne _080A1080 - lsrs r0, r5, 19 - movs r1, 0x3 - bl sub_80A1434 -_080A1080: - cmp r6, 0x4 - bne _080A108C - lsrs r0, r5, 19 - movs r1, 0x4 - bl sub_80A1434 -_080A108C: - cmp r6, 0x5 - bne _080A1098 - lsrs r0, r5, 19 - movs r1, 0x5 - bl sub_80A1434 -_080A1098: - cmp r6, 0x6 - bne _080A10A4 - lsrs r0, r5, 19 - movs r1, 0x6 - bl sub_80A1434 -_080A10A4: - cmp r6, 0x7 - bne _080A10B0 - lsrs r0, r5, 19 - movs r1, 0x7 - bl sub_80A1434 -_080A10B0: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_80A103C - - thumb_func_start sub_80A10B8 -sub_80A10B8: @ 80A10B8 - push {lr} - lsls r1, r0, 16 - movs r0, 0xE0 - lsls r0, 11 - ands r0, r1 - cmp r0, 0 - bne _080A10CC - lsrs r0, r1, 19 - bl sub_80A1520 -_080A10CC: - pop {r0} - bx r0 - thumb_func_end sub_80A10B8 - - thumb_func_start sub_80A10D0 -sub_80A10D0: @ 80A10D0 - push {lr} - lsls r1, r0, 16 - movs r0, 0xF0 - lsls r0, 12 - ands r0, r1 - cmp r0, 0 - bne _080A10E4 - lsrs r0, r1, 20 - bl sub_80A1598 -_080A10E4: - pop {r0} - bx r0 - thumb_func_end sub_80A10D0 - - thumb_func_start sub_80A10E8 -sub_80A10E8: @ 80A10E8 - push {r4,r5,lr} - lsls r4, r0, 16 - movs r0, 0xE0 - lsls r0, 11 - ands r0, r4 - lsrs r5, r0, 16 - cmp r5, 0 - bne _080A1100 - lsrs r0, r4, 19 - movs r1, 0 - bl sub_80A1394 -_080A1100: - cmp r5, 0x1 - bne _080A110C - lsrs r0, r4, 19 - movs r1, 0x1 - bl sub_80A1394 -_080A110C: - cmp r5, 0x2 - bne _080A1118 - lsrs r0, r4, 19 - movs r1, 0x2 - bl sub_80A1394 -_080A1118: - cmp r5, 0x3 - bne _080A1124 - lsrs r0, r4, 19 - movs r1, 0x3 - bl sub_80A1394 -_080A1124: - cmp r5, 0x4 - bne _080A1130 - lsrs r0, r4, 19 - movs r1, 0x4 - bl sub_80A1394 -_080A1130: - cmp r5, 0x5 - bne _080A113C - lsrs r0, r4, 19 - movs r1, 0x5 - bl sub_80A1394 -_080A113C: - cmp r5, 0x6 - bne _080A1148 - lsrs r0, r4, 19 - movs r1, 0x6 - bl sub_80A1394 -_080A1148: - cmp r5, 0x7 - bne _080A1154 - lsrs r0, r4, 19 - movs r1, 0x7 - bl sub_80A1394 -_080A1154: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80A10E8 - - thumb_func_start sub_80A115C -sub_80A115C: @ 80A115C - push {r4,r5,lr} - lsls r4, r0, 16 - movs r0, 0xF0 - lsls r0, 12 - ands r0, r4 - lsrs r5, r0, 16 - cmp r5, 0 - bne _080A1176 - lsrs r0, r4, 20 - lsls r0, 24 - lsrs r0, 24 - bl sub_80A12D4 -_080A1176: - cmp r5, 0x1 - bne _080A1180 - lsrs r0, r4, 20 - bl sub_80A1498 -_080A1180: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80A115C - - thumb_func_start sub_80A1188 -sub_80A1188: @ 80A1188 - push {r4,r5,lr} - lsls r4, r0, 16 - movs r0, 0xE0 - lsls r0, 11 - ands r0, r4 - lsrs r5, r0, 16 - cmp r5, 0 - bne _080A11A0 - lsrs r0, r4, 19 - movs r1, 0 - bl sub_80A14C0 -_080A11A0: - cmp r5, 0x1 - bne _080A11AC - lsrs r0, r4, 19 - movs r1, 0x1 - bl sub_80A14C0 -_080A11AC: - cmp r5, 0x2 - bne _080A11B8 - lsrs r0, r4, 19 - movs r1, 0x2 - bl sub_80A14C0 -_080A11B8: - cmp r5, 0x3 - bne _080A11C4 - lsrs r0, r4, 19 - movs r1, 0x3 - bl sub_80A14C0 -_080A11C4: - cmp r5, 0x4 - bne _080A11D0 - lsrs r0, r4, 19 - movs r1, 0x4 - bl sub_80A14C0 -_080A11D0: - cmp r5, 0x5 - bne _080A11DC - lsrs r0, r4, 19 - movs r1, 0x5 - bl sub_80A14C0 -_080A11DC: - cmp r5, 0x6 - bne _080A11E8 - lsrs r0, r4, 19 - movs r1, 0x6 - bl sub_80A14C0 -_080A11E8: - cmp r5, 0x7 - bne _080A11F4 - lsrs r0, r4, 19 - movs r1, 0x7 - bl sub_80A14C0 -_080A11F4: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80A1188 - - thumb_func_start sub_80A11FC -sub_80A11FC: @ 80A11FC - push {r4,r5,lr} - lsls r4, r0, 16 - movs r0, 0xF0 - lsls r0, 12 - ands r0, r4 - lsrs r5, r0, 16 - cmp r5, 0 - bne _080A1216 - lsrs r0, r4, 20 - lsls r0, 24 - lsrs r0, 24 - bl sub_80A131C -_080A1216: - cmp r5, 0x1 - bne _080A1224 - lsrs r0, r4, 20 - lsls r0, 24 - lsrs r0, 24 - bl sub_80A136C -_080A1224: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80A11FC - - thumb_func_start sub_80A122C -sub_80A122C: @ 80A122C - push {lr} - lsls r1, r0, 16 - movs r0, 0xF0 - lsls r0, 12 - ands r0, r1 - cmp r0, 0 - bne _080A1240 - lsrs r0, r1, 20 - bl sub_80A1798 -_080A1240: - pop {r0} - bx r0 - thumb_func_end sub_80A122C - - thumb_func_start sub_80A1244 -sub_80A1244: @ 80A1244 - push {lr} - lsls r1, r0, 16 - movs r0, 0xF0 - lsls r0, 12 - ands r0, r1 - cmp r0, 0 - bne _080A125C - lsrs r0, r1, 20 - lsls r0, 24 - lsrs r0, 24 - bl sub_80A1344 -_080A125C: - pop {r0} - bx r0 - thumb_func_end sub_80A1244 - - thumb_func_start sub_80A1260 -sub_80A1260: @ 80A1260 - push {lr} - lsls r1, r0, 16 - movs r0, 0xF0 - lsls r0, 12 - ands r0, r1 - lsrs r0, 16 - cmp r0, 0x1 - bne _080A1276 - lsrs r0, r1, 20 - bl sub_80A14F8 -_080A1276: - pop {r0} - bx r0 - thumb_func_end sub_80A1260 - - thumb_func_start sub_80A127C -sub_80A127C: @ 80A127C - push {lr} - lsls r1, r0, 16 - movs r0, 0xE0 - lsls r0, 11 - ands r0, r1 - cmp r0, 0 - bne _080A1290 - lsrs r0, r1, 19 - bl sub_80A1548 -_080A1290: - pop {r0} - bx r0 - thumb_func_end sub_80A127C - - thumb_func_start sub_80A1294 -sub_80A1294: @ 80A1294 - push {lr} - lsls r1, r0, 16 - movs r0, 0xE0 - lsls r0, 11 - ands r0, r1 - cmp r0, 0 - bne _080A12A8 - lsrs r0, r1, 19 - bl sub_80A1570 -_080A12A8: - pop {r0} - bx r0 - thumb_func_end sub_80A1294 - - thumb_func_start sub_80A12AC -sub_80A12AC: @ 80A12AC - push {lr} - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - ldr r0, =gUnknown_08513684 - lsrs r1, 14 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06003c00 - movs r2, 0xA0 - lsls r2, 1 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A12AC - - thumb_func_start sub_80A12D4 -sub_80A12D4: @ 80A12D4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0x3 - ands r0, r4 - ldr r5, =gUnknown_08513894 - lsls r0, 2 - adds r0, r5 - ldr r0, [r0] - ldr r1, =0x06006400 - movs r2, 0x80 - bl sub_80A0980 - adds r1, r4, 0x2 - adds r0, r1, 0 - asrs r0, 2 - lsls r0, 2 - subs r0, r1, r0 - lsls r0, 24 - lsrs r0, 22 - adds r0, r5 - ldr r0, [r0] - ldr r1, =0x06006480 - movs r2, 0x80 - bl sub_80A0980 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A12D4 - - thumb_func_start sub_80A131C -sub_80A131C: @ 80A131C - push {lr} - lsls r0, 24 - movs r1, 0xC0 - lsls r1, 18 - ands r1, r0 - ldr r0, =gUnknown_085143E4 - lsrs r1, 22 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06007a00 - movs r2, 0xF0 - lsls r2, 2 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A131C - - thumb_func_start sub_80A1344 -sub_80A1344: @ 80A1344 - push {lr} - lsls r0, 24 - movs r1, 0xC0 - lsls r1, 18 - ands r1, r0 - ldr r0, =gUnknown_085145F4 - lsrs r1, 22 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06007e00 - movs r2, 0x80 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A1344 - - thumb_func_start sub_80A136C -sub_80A136C: @ 80A136C - push {lr} - lsls r0, 24 - movs r1, 0xE0 - lsls r1, 19 - ands r1, r0 - ldr r0, =gUnknown_08514E04 - lsrs r1, 22 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06007e00 - movs r2, 0x80 - lsls r2, 1 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A136C - - thumb_func_start sub_80A1394 -sub_80A1394: @ 80A1394 - push {r4-r6,lr} - lsls r0, 16 - lsrs r5, r0, 16 - lsls r1, 24 - lsrs r6, r1, 24 - subs r0, r5, r6 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0xB - bhi _080A13F0 - adds r0, r5, 0 - movs r1, 0xC - bl __umodsi3 - adds r4, r0, 0 - lsls r4, 16 - ldr r0, =gUnknown_08515384 - lsrs r4, 14 - adds r0, r4, r0 - ldr r0, [r0] - ldr r1, =gUnknown_08515344 - lsls r5, r6, 2 - adds r1, r5, r1 - ldr r1, [r1] - movs r2, 0x80 - bl sub_80A0980 - ldr r0, =gUnknown_085153B4 - adds r4, r0 - ldr r0, [r4] - ldr r1, =gUnknown_08515364 - adds r5, r1 - ldr r1, [r5] - movs r2, 0x80 - bl sub_80A0980 - b _080A141C - .pool -_080A13F0: - movs r0, 0x3 - ands r5, r0 - ldr r0, =gUnknown_085153E4 - lsls r5, 2 - adds r0, r5, r0 - ldr r0, [r0] - ldr r1, =gUnknown_08515344 - lsls r4, r6, 2 - adds r1, r4, r1 - ldr r1, [r1] - movs r2, 0x80 - bl sub_80A0980 - ldr r0, =gUnknown_085153F4 - adds r5, r0 - ldr r0, [r5] - ldr r1, =gUnknown_08515364 - adds r4, r1 - ldr r1, [r4] - movs r2, 0x80 - bl sub_80A0980 -_080A141C: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A1394 - - thumb_func_start sub_80A1434 -sub_80A1434: @ 80A1434 - push {lr} - lsls r0, 16 - lsrs r0, 16 - lsls r1, 24 - lsrs r3, r1, 24 - subs r0, r3 - lsls r0, 16 - movs r1, 0xE0 - lsls r1, 11 - ands r1, r0 - ldr r0, =gUnknown_08515824 - lsrs r1, 14 - adds r1, r0 - ldr r2, [r1] - cmp r2, 0 - beq _080A1464 - ldr r0, =gUnknown_08515804 - lsls r1, r3, 2 - adds r1, r0 - ldr r1, [r1] - adds r0, r2, 0 - movs r2, 0x80 - bl sub_80A0980 -_080A1464: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A1434 - - thumb_func_start sub_80A1470 -sub_80A1470: @ 80A1470 - push {lr} - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - ands r0, r1 - ldr r1, =gUnknown_08515964 - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - ldr r1, =0x06007800 - movs r2, 0x80 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A1470 - - thumb_func_start sub_80A1498 -sub_80A1498: @ 80A1498 - push {lr} - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - ldr r0, =gUnknown_08515D8C - lsrs r1, 14 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06005400 - movs r2, 0x80 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A1498 - - thumb_func_start sub_80A14C0 -sub_80A14C0: @ 80A14C0 - push {lr} - lsls r0, 16 - lsrs r0, 16 - lsls r1, 24 - lsrs r1, 24 - subs r0, r1 - lsls r0, 16 - movs r2, 0xE0 - lsls r2, 11 - ands r2, r0 - ldr r0, =gUnknown_085161DC - lsrs r2, 14 - adds r2, r0 - ldr r0, [r2] - ldr r2, =gUnknown_085161BC - lsls r1, 2 - adds r1, r2 - ldr r1, [r1] - movs r2, 0x80 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A14C0 - - thumb_func_start sub_80A14F8 -sub_80A14F8: @ 80A14F8 - push {lr} - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - ldr r0, =gUnknown_08515D8C - lsrs r1, 14 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06007400 - movs r2, 0x80 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A14F8 - - thumb_func_start sub_80A1520 -sub_80A1520: @ 80A1520 - push {lr} - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - ldr r0, =gUnknown_085164FC - lsrs r1, 14 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06005540 - movs r2, 0xC0 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A1520 - - thumb_func_start sub_80A1548 -sub_80A1548: @ 80A1548 - push {lr} - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - ldr r0, =gUnknown_0851680C - lsrs r1, 14 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06005b40 - movs r2, 0xC0 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A1548 - - thumb_func_start sub_80A1570 -sub_80A1570: @ 80A1570 - push {lr} - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - ldr r0, =gUnknown_08516B1C - lsrs r1, 14 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06005b40 - movs r2, 0xC0 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A1570 - - thumb_func_start sub_80A1598 -sub_80A1598: @ 80A1598 - push {lr} - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - ldr r0, =gUnknown_08516D2C - lsrs r1, 14 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06005c00 - movs r2, 0x80 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A1598 - - thumb_func_start sub_80A15C0 -sub_80A15C0: @ 80A15C0 - push {lr} - lsls r2, r0, 16 - lsrs r0, r2, 16 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080A15D4 - lsrs r0, r2, 17 - bl sub_80A1748 -_080A15D4: - pop {r0} - bx r0 - thumb_func_end sub_80A15C0 - - thumb_func_start sub_80A15D8 -sub_80A15D8: @ 80A15D8 - push {lr} - lsls r1, r0, 16 - movs r0, 0xE0 - lsls r0, 11 - ands r0, r1 - cmp r0, 0 - bne _080A15EC - lsrs r0, r1, 19 - bl sub_80A16B0 -_080A15EC: - pop {r0} - bx r0 - thumb_func_end sub_80A15D8 - - thumb_func_start sub_80A15F0 -sub_80A15F0: @ 80A15F0 - push {r4,r5,lr} - lsls r4, r0, 16 - lsrs r0, r4, 16 - adds r5, r0, 0 - movs r0, 0x3F - ands r0, r5 - cmp r0, 0x1 - bne _080A1606 - lsrs r0, r4, 22 - bl sub_80A1720 -_080A1606: - movs r0, 0x7 - ands r0, r5 - cmp r0, 0x1 - bne _080A1614 - lsrs r0, r4, 19 - bl sub_80A16F8 -_080A1614: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80A15F0 - - thumb_func_start sub_80A161C -sub_80A161C: @ 80A161C - push {lr} - lsls r1, r0, 16 - movs r0, 0xC0 - lsls r0, 10 - ands r0, r1 - cmp r0, 0 - bne _080A1630 - lsrs r0, r1, 18 - bl sub_80A1770 -_080A1630: - pop {r0} - bx r0 - thumb_func_end sub_80A161C - - thumb_func_start sub_80A1634 -sub_80A1634: @ 80A1634 - push {r4,lr} - lsls r4, r0, 16 - movs r0, 0xE0 - lsls r0, 11 - ands r0, r4 - cmp r0, 0 - bne _080A1650 - lsrs r4, 19 - adds r0, r4, 0 - bl sub_80A17C0 - adds r0, r4, 0 - bl sub_80A17EC -_080A1650: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80A1634 - - thumb_func_start sub_80A1658 -sub_80A1658: @ 80A1658 - push {lr} - lsls r1, r0, 16 - movs r0, 0xC0 - lsls r0, 10 - ands r0, r1 - cmp r0, 0 - bne _080A166C - lsrs r0, r1, 18 - bl sub_80A1818 -_080A166C: - pop {r0} - bx r0 - thumb_func_end sub_80A1658 - - thumb_func_start sub_80A1670 -sub_80A1670: @ 80A1670 - push {lr} - lsls r1, r0, 16 - movs r0, 0xC0 - lsls r0, 10 - ands r0, r1 - cmp r0, 0 - bne _080A1684 - lsrs r0, r1, 18 - bl sub_80A1884 -_080A1684: - pop {r0} - bx r0 - thumb_func_end sub_80A1670 - - thumb_func_start sub_80A1688 -sub_80A1688: @ 80A1688 - push {lr} - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - ands r0, r1 - ldr r1, =gUnknown_08516E3C - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - ldr r1, =0x06003e00 - movs r2, 0x80 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A1688 - - thumb_func_start sub_80A16B0 -sub_80A16B0: @ 80A16B0 - push {r4,lr} - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - bl __umodsi3 - adds r4, r0, 0 - lsls r4, 16 - ldr r0, =gUnknown_08517A44 - lsrs r4, 14 - adds r0, r4, r0 - ldr r0, [r0] - ldr r1, =0x06007e00 - movs r2, 0xC0 - lsls r2, 1 - bl sub_80A0980 - ldr r0, =gUnknown_08517A50 - adds r4, r0 - ldr r0, [r4] - ldr r1, =0x06007a00 - movs r2, 0xA0 - lsls r2, 2 - bl sub_80A0980 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A16B0 - - thumb_func_start sub_80A16F8 -sub_80A16F8: @ 80A16F8 - push {lr} - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - ldr r0, =gUnknown_08517BFC - lsrs r1, 14 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06007f00 - movs r2, 0x20 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A16F8 - - thumb_func_start sub_80A1720 -sub_80A1720: @ 80A1720 - push {lr} - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - ands r0, r1 - ldr r1, =gUnknown_08517C0C - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - ldr r1, =0x06007c00 - movs r2, 0x80 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A1720 - - thumb_func_start sub_80A1748 -sub_80A1748: @ 80A1748 - push {lr} - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - ands r0, r1 - ldr r1, =gUnknown_08518034 - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - ldr r1, =0x06005200 - movs r2, 0x80 - lsls r2, 2 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A1748 - - thumb_func_start sub_80A1770 -sub_80A1770: @ 80A1770 - push {lr} - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - ands r0, r1 - ldr r1, =gUnknown_0851829C - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - ldr r1, =0x06007e00 - movs r2, 0x90 - lsls r2, 1 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A1770 - - thumb_func_start sub_80A1798 -sub_80A1798: @ 80A1798 - push {lr} - lsls r0, 16 - movs r1, 0xE0 - lsls r1, 11 - ands r1, r0 - ldr r0, =gUnknown_085202C4 - lsrs r1, 14 - adds r1, r0 - ldr r0, [r1] - ldr r1, =0x06005e00 - movs r2, 0xC0 - lsls r2, 4 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A1798 - - thumb_func_start sub_80A17C0 -sub_80A17C0: @ 80A17C0 - push {lr} - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - bl __umodsi3 - lsls r0, 16 - ldr r1, =gUnknown_08524864 - lsrs r0, 14 - adds r0, r1 - ldr r0, [r0] - ldr r1, =0x060052e0 - movs r2, 0x80 - lsls r2, 1 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A17C0 - - thumb_func_start sub_80A17EC -sub_80A17EC: @ 80A17EC - push {lr} - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - bl __umodsi3 - lsls r0, 16 - ldr r1, =gUnknown_08524870 - lsrs r0, 14 - adds r0, r1 - ldr r0, [r0] - ldr r1, =0x060050e0 - movs r2, 0x80 - lsls r2, 1 - bl sub_80A0980 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A17EC - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/trade.s b/asm/trade.s index 8712567c7..d4c54cef6 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -18,7 +18,7 @@ sub_8077170: @ 8077170 lsrs r2, 16 movs r0, 0 adds r1, r4, 0 - bl link_0800A448 + bl SendBlock lsls r0, 24 lsrs r0, 24 b _080771A2 @@ -83,7 +83,7 @@ _080771F8: thumb_func_start sub_8077200 sub_8077200: @ 8077200 push {lr} - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r0, 24 pop {r1} @@ -103,7 +103,7 @@ sub_8077210: @ 8077210 b _08077230 .pool _0807722C: - bl sub_800A5B4 + bl ResetBlockReceivedFlags _08077230: pop {r0} bx r0 @@ -397,7 +397,7 @@ _080774B2: bl sub_807A19C movs r0, 0 bl ShowBg - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r2, [r0] cmp r2, 0 bne _0807754C @@ -504,7 +504,7 @@ _080775D8: b _08077B22 .pool _080775E8: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0x1 beq _080775F2 @@ -1832,7 +1832,7 @@ sub_80781C8: @ 80781C8 b _08078244 .pool _08078220: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r4, [r0] cmp r4, 0 bne _08078244 @@ -2198,7 +2198,7 @@ _08078552: adds r1, r5, 0 eors r1, r2 lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0xC8 bl sub_8078438 @@ -2237,7 +2237,7 @@ _080785B6: adds r1, r5, 0 eors r1, r2 lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0xC8 bl sub_8078438 @@ -2276,7 +2276,7 @@ _0807861A: adds r1, r5, 0 eors r1, r2 lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0xC8 bl sub_8078438 @@ -2318,7 +2318,7 @@ _0807868A: adds r1, r5, 0 eors r1, r2 lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0xD8 bl sub_8078438 @@ -2360,7 +2360,7 @@ _080786F0: adds r1, r5, 0 eors r1, r2 lsls r1, 8 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer adds r1, r2 movs r2, 0xB bl sub_8078438 @@ -2467,7 +2467,7 @@ sub_80787E0: @ 80787E0 ands r0, r2 cmp r0, 0 beq _08078864 - ldr r0, =gUnknown_020223C4 + ldr r0, =gBlockRecvBuffer ldrh r1, [r0] ldr r0, =0x0000bbbb cmp r1, r0 @@ -2521,7 +2521,7 @@ _08078864: ands r0, r2 cmp r0, 0 beq _080788F6 - ldr r3, =gUnknown_020223C4 + ldr r3, =gBlockRecvBuffer movs r1, 0x80 lsls r1, 1 adds r0, r3, r1 @@ -2597,7 +2597,7 @@ sub_8078900: @ 8078900 ands r0, r5 cmp r0, 0 beq _080789E2 - ldr r2, =gUnknown_020223C4 + ldr r2, =gBlockRecvBuffer ldrh r1, [r2] ldr r0, =0x0000ddee cmp r1, r0 @@ -4052,7 +4052,7 @@ sub_80794CC: @ 80794CC b _0807953A .pool _08079518: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0807953A @@ -6279,7 +6279,7 @@ _0807A718: thumb_func_start sub_807A728 sub_807A728: @ 807A728 push {r4-r7,lr} - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _0807A7B4 @@ -7054,7 +7054,7 @@ _0807ACC4: thumb_func_start sub_807ACDC sub_807ACDC: @ 807ACDC push {lr} - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0807ACF0 @@ -7128,7 +7128,7 @@ _0807AD58: lsls r0, r5, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] ldr r1, [r1, 0x8] adds r2, r5, 0 @@ -7141,7 +7141,7 @@ _0807AD94: lsls r0, r5, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r2, [r1] lsls r4, r6, 1 adds r1, r4, 0x1 @@ -7254,7 +7254,7 @@ _0807AE78: .4byte _0807B0D4 .4byte _0807B0F0 _0807AEAC: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _0807AEC0 @@ -7270,7 +7270,7 @@ _0807AEC0: adds r0, r5, 0 bl AllocZeroed str r0, [r4] - bl init_uns_table_pokemon_copy + bl AllocateMonSpritesGfx bl ResetTasks bl ResetSpriteData bl FreeAllSpritePalettes @@ -7321,7 +7321,7 @@ _0807AEC0: b _0807B116 .pool _0807AF58: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r5, [r0] cmp r5, 0 bne _0807AF90 @@ -7401,7 +7401,7 @@ _0807B000: b _0807B116 _0807B006: bl sub_807AC64 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0x1 beq _0807B014 @@ -7729,7 +7729,7 @@ _0807B2D0: adds r0, r5, 0 bl AllocZeroed str r0, [r4] - bl init_uns_table_pokemon_copy + bl AllocateMonSpritesGfx bl ResetTasks bl ResetSpriteData bl FreeAllSpritePalettes @@ -7989,7 +7989,7 @@ _0807B566: _0807B57C: mov r0, r9 bl sub_807B464 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _0807B58E @@ -8029,7 +8029,7 @@ _0807B5D0: ldr r1, [r4] adds r1, 0x74 movs r2, 0x14 - bl link_0800A448 + bl SendBlock ldr r1, [r4] adds r1, 0x93 ldrb r0, [r1] @@ -8939,7 +8939,7 @@ _0807C04C: adds r1, r0 lsls r1, 2 adds r1, r3 - ldr r2, =gUnknown_08300D38 + ldr r2, =gMonFrontPicCoords adds r0, r4, 0 adds r0, 0xF0 ldrh r0, [r0] @@ -10369,7 +10369,7 @@ _0807CCEE: lsls r0, r2, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] ldr r1, [r1, 0x10] ldr r3, [r3, 0x6C] @@ -10395,7 +10395,7 @@ _0807CD1C: adds r1, r0 lsls r1, 2 adds r1, r4 - ldr r3, =gUnknown_08300D38 + ldr r3, =gMonFrontPicCoords adds r2, 0xF2 ldrh r0, [r2] lsls r0, 2 @@ -10663,7 +10663,7 @@ _0807CF5C: movs r0, 0 bl GetBgTilemapBuffer bl Free - bl sub_805F094 + bl FreeMonSpritesGfx ldr r0, [r7] bl Free str r4, [r7] @@ -11001,7 +11001,7 @@ _0807D428: adds r1, r0 lsls r1, 2 adds r1, r3 - ldr r2, =gUnknown_08300D38 + ldr r2, =gMonFrontPicCoords adds r0, r4, 0 adds r0, 0xF0 ldrh r0, [r0] @@ -12474,7 +12474,7 @@ _0807E13A: lsls r0, r2, 3 ldr r1, =gMonFrontPicTable adds r0, r1 - ldr r1, =gBattleSpritesGfx + ldr r1, =gMonSpritesGfxPtr ldr r1, [r1] ldr r1, [r1, 0x10] ldr r3, [r3, 0x6C] @@ -12500,7 +12500,7 @@ _0807E168: adds r1, r0 lsls r1, 2 adds r1, r4 - ldr r3, =gUnknown_08300D38 + ldr r3, =gMonFrontPicCoords adds r2, 0xF2 ldrh r0, [r2] lsls r0, 2 @@ -12768,7 +12768,7 @@ _0807E3A8: movs r0, 0 bl GetBgTilemapBuffer bl Free - bl sub_805F094 + bl FreeMonSpritesGfx ldr r0, [r7] bl Free str r4, [r7] @@ -12877,7 +12877,7 @@ _0807E4C2: sub_807E4DC: @ 807E4DC push {r4-r6,lr} bl sub_807ACDC - bl sub_800A550 + bl GetBlockReceivedStatus lsls r0, 24 lsrs r5, r0, 24 movs r6, 0x1 @@ -12885,7 +12885,7 @@ sub_807E4DC: @ 807E4DC ands r0, r6 cmp r0, 0 beq _0807E51A - ldr r4, =gUnknown_020223C4 + ldr r4, =gBlockRecvBuffer ldrh r1, [r4] ldr r0, =0x0000dcba cmp r1, r0 @@ -12909,7 +12909,7 @@ _0807E51A: ands r0, r5 cmp r0, 0 beq _0807E542 - ldr r0, =gUnknown_020223C4 + ldr r0, =gBlockRecvBuffer movs r1, 0x80 lsls r1, 1 adds r0, r1 @@ -13600,7 +13600,7 @@ _0807EAEC: ldr r1, [r4] adds r1, 0x74 movs r2, 0x14 - bl link_0800A448 + bl SendBlock ldr r0, [r4] adds r0, 0x72 movs r1, 0x2 @@ -14090,7 +14090,7 @@ _0807EFF0: b _0807F03A .pool _0807F028: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r1, [r0] cmp r1, 0 bne _0807F03A @@ -14136,7 +14136,7 @@ c2_080543C4: @ 807F068 movs r0, 0 bl GetBgTilemapBuffer bl Free - bl sub_805F094 + bl FreeMonSpritesGfx ldr r4, =gUnknown_020322A0 ldr r0, [r4] bl Free diff --git a/asm/trainer_card.s b/asm/trainer_card.s index 7552d7ace..bee1f4f7f 100644 --- a/asm/trainer_card.s +++ b/asm/trainer_card.s @@ -191,7 +191,7 @@ _080C2836: ldrb r0, [r0] cmp r0, 0x1 bne _080C2852 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0x1 bne _080C2852 @@ -261,7 +261,7 @@ _080C28D8: b _080C2ACA .pool _080C28E4: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r5, [r0] cmp r5, 0 bne _080C290A @@ -301,7 +301,7 @@ _080C293C: bne _080C2946 b _080C2ACA _080C2946: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080C2960 @@ -346,7 +346,7 @@ _080C299C: ands r0, r1 cmp r0, 0 beq _080C29F4 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080C29DC @@ -358,7 +358,7 @@ _080C299C: cmp r0, 0x1 beq _080C2A14 _080C29C0: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080C29DC @@ -382,7 +382,7 @@ _080C29F4: ands r0, r1 cmp r0, 0 beq _080C2ACA - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080C2A20 @@ -430,7 +430,7 @@ _080C2A2C: b _080C2ACA .pool _080C2A68: - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 bne _080C2ACA @@ -1403,7 +1403,7 @@ sub_80C3278: @ 80C3278 movs r0, 0x40 movs r1, 0xF0 bl SetGpuReg - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080C32E0 @@ -4267,7 +4267,7 @@ _080C4BF6: ldrb r0, [r1, 0x4] adds r0, 0x1 strb r0, [r1, 0x4] - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0 beq _080C4B20 @@ -4745,7 +4745,7 @@ sub_80C4FF0: @ 80C4FF0 bl InUnionRoom cmp r0, 0x1 bne _080C5060 - ldr r0, =gUnknown_03003124 + ldr r0, =gReceivedRemoteLinkPlayers ldrb r0, [r0] cmp r0, 0x1 bne _080C5060 diff --git a/asm/unk_text_util_2.s b/asm/unk_text_util_2.s deleted file mode 100755 index 7f1a5ef70..000000000 --- a/asm/unk_text_util_2.s +++ /dev/null @@ -1,583 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start Font6Func -@ int Font6Func(struct TextPrinter *x) -Font6Func: @ 81BA250 - push {r4-r6,lr} - adds r6, r0, 0 - adds r4, r6, 0 - adds r4, 0x14 - ldrb r0, [r6, 0x1C] - cmp r0, 0x6 - bls _081BA260 - b _081BA660 -_081BA260: - lsls r0, 2 - ldr r1, =_081BA270 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081BA270: - .4byte _081BA28C - .4byte _081BA554 - .4byte _081BA566 - .4byte _081BA590 - .4byte _081BA5C8 - .4byte _081BA63C - .4byte _081BA64E -_081BA28C: - ldr r2, =gMain - ldrh r1, [r2, 0x2C] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _081BA2A6 - ldrb r1, [r4] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _081BA2A6 - movs r0, 0 - strb r0, [r6, 0x1E] -_081BA2A6: - ldrb r1, [r6, 0x1E] - cmp r1, 0 - beq _081BA2E8 - ldrb r0, [r6, 0x1D] - cmp r0, 0 - beq _081BA2E8 - subs r0, r1, 0x1 - strb r0, [r6, 0x1E] - ldr r0, =gTextFlags - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _081BA2C4 - b _081BA50E -_081BA2C4: - ldrh r1, [r2, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - bne _081BA2D0 - b _081BA50E -_081BA2D0: - ldrb r0, [r4] - movs r1, 0x10 - orrs r0, r1 - strb r0, [r4] - movs r0, 0 - strb r0, [r6, 0x1E] - b _081BA50E - .pool -_081BA2E8: - ldr r2, =gTextFlags - ldrb r1, [r2] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _081BA2FC - movs r0, 0x3 - b _081BA2FE - .pool -_081BA2FC: - ldrb r0, [r6, 0x1D] -_081BA2FE: - strb r0, [r6, 0x1E] - ldr r0, [r6] - ldrb r3, [r0] - adds r0, 0x1 - str r0, [r6] - adds r0, r3, 0 - subs r0, 0xF8 - cmp r0, 0x7 - bls _081BA312 - b _081BA52E -_081BA312: - lsls r0, 2 - ldr r1, =_081BA320 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081BA320: - .4byte _081BA524 - .4byte _081BA512 - .4byte _081BA504 - .4byte _081BA500 - .4byte _081BA36E - .4byte _081BA368 - .4byte _081BA340 - .4byte _081BA660 -_081BA340: - ldrb r0, [r6, 0x6] - strb r0, [r6, 0x8] - ldrb r1, [r6, 0x5] - ldr r0, =gFonts - ldr r2, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r6, 0xB] - ldrb r0, [r0, 0x5] - adds r1, r0 - ldrb r0, [r6, 0x9] - adds r0, r1 - strb r0, [r6, 0x9] -_081BA35E: - movs r0, 0x2 - b _081BA662 - .pool -_081BA368: - ldr r0, [r6] - adds r0, 0x1 - b _081BA4C4 -_081BA36E: - ldr r0, [r6] - ldrb r3, [r0] - adds r0, 0x1 - str r0, [r6] - subs r0, r3, 0x1 - cmp r0, 0xF - bls _081BA37E - b _081BA52E -_081BA37E: - lsls r0, 2 - ldr r1, =_081BA38C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081BA38C: - .4byte _081BA3CC - .4byte _081BA3EE - .4byte _081BA412 - .4byte _081BA42C - .4byte _081BA478 - .4byte _081BA47E - .4byte _081BA35E - .4byte _081BA498 - .4byte _081BA4A8 - .4byte _081BA4BC - .4byte _081BA4C0 - .4byte _081BA4C8 - .4byte _081BA4D2 - .4byte _081BA4DE - .4byte _081BA4EE - .4byte _081BA4C0 -_081BA3CC: - ldr r2, [r6] - ldrb r1, [r2] - lsls r1, 4 - ldrb r3, [r6, 0xC] - movs r0, 0xF - ands r0, r3 - orrs r0, r1 - strb r0, [r6, 0xC] - adds r2, 0x1 - str r2, [r6] - lsls r0, 24 - lsrs r0, 28 - ldrb r2, [r6, 0xD] - lsls r1, r2, 28 - lsrs r1, 28 - lsrs r2, 4 - b _081BA472 -_081BA3EE: - ldr r1, [r6] - ldrb r2, [r1] - movs r0, 0xF - ands r0, r2 - ldrb r3, [r6, 0xD] - movs r2, 0x10 - negs r2, r2 - ands r2, r3 - orrs r2, r0 - strb r2, [r6, 0xD] - adds r1, 0x1 - str r1, [r6] - ldrb r0, [r6, 0xC] - lsrs r0, 4 - lsls r1, r2, 28 - lsrs r1, 28 - lsrs r2, 4 - b _081BA472 -_081BA412: - ldr r1, [r6] - ldrb r0, [r1] - lsls r0, 4 - ldrb r3, [r6, 0xD] - movs r2, 0xF - ands r2, r3 - orrs r2, r0 - strb r2, [r6, 0xD] - adds r1, 0x1 - str r1, [r6] - ldrb r0, [r6, 0xC] - lsrs r0, 4 - b _081BA46A -_081BA42C: - ldr r3, [r6] - ldrb r1, [r3] - lsls r1, 4 - ldrb r4, [r6, 0xC] - movs r2, 0xF - adds r0, r2, 0 - ands r0, r4 - orrs r0, r1 - strb r0, [r6, 0xC] - adds r5, r3, 0x1 - str r5, [r6] - ldrb r3, [r3, 0x1] - adds r1, r2, 0 - ands r1, r3 - ldrb r4, [r6, 0xD] - movs r3, 0x10 - negs r3, r3 - ands r3, r4 - orrs r3, r1 - strb r3, [r6, 0xD] - adds r4, r5, 0x1 - str r4, [r6] - ldrb r1, [r5, 0x1] - lsls r1, 4 - ands r2, r3 - orrs r2, r1 - strb r2, [r6, 0xD] - adds r4, 0x1 - str r4, [r6] - lsls r0, 24 - lsrs r0, 28 -_081BA46A: - lsls r1, r2, 28 - lsrs r1, 28 - lsls r2, 24 - lsrs r2, 28 -_081BA472: - bl GenerateFontHalfRowLookupTable - b _081BA35E -_081BA478: - ldr r0, [r6] - adds r0, 0x1 - b _081BA4C4 -_081BA47E: - ldr r0, [r6] - ldrb r0, [r0] - movs r1, 0xF - ands r1, r0 - ldrb r2, [r4] - movs r0, 0x10 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r4] - ldr r0, [r6] - adds r0, 0x1 - b _081BA4C4 -_081BA498: - ldr r0, [r6] - ldrb r1, [r0] - strb r1, [r6, 0x1E] - adds r0, 0x1 - str r0, [r6] - movs r0, 0x6 - strb r0, [r6, 0x1C] - b _081BA35E -_081BA4A8: - movs r0, 0x1 - strb r0, [r6, 0x1C] - ldrb r1, [r2] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _081BA50E - movs r0, 0 - strb r0, [r4, 0x2] - b _081BA50E -_081BA4BC: - movs r0, 0x5 - b _081BA64A -_081BA4C0: - ldr r0, [r6] - adds r0, 0x2 -_081BA4C4: - str r0, [r6] - b _081BA35E -_081BA4C8: - ldr r1, [r6] - adds r0, r1, 0x1 - str r0, [r6] - ldrb r3, [r1, 0x1] - b _081BA52E -_081BA4D2: - ldr r1, [r6] - ldrb r0, [r1] - ldrb r2, [r6, 0x6] - adds r0, r2 - strb r0, [r6, 0x8] - b _081BA4E8 -_081BA4DE: - ldr r1, [r6] - ldrb r0, [r1] - ldrb r2, [r6, 0x7] - adds r0, r2 - strb r0, [r6, 0x9] -_081BA4E8: - adds r1, 0x1 - str r1, [r6] - b _081BA35E -_081BA4EE: - ldrb r0, [r6, 0x4] - ldrb r2, [r6, 0xD] - lsls r2, 28 - lsrs r1, r2, 4 - orrs r1, r2 - lsrs r1, 24 - bl FillWindowPixelBuffer - b _081BA35E -_081BA500: - movs r0, 0x2 - b _081BA506 -_081BA504: - movs r0, 0x3 -_081BA506: - strb r0, [r6, 0x1C] - adds r0, r6, 0 - bl TextPrinterInitDownArrowCounters -_081BA50E: - movs r0, 0x3 - b _081BA662 -_081BA512: - ldr r0, [r6] - ldrb r3, [r0] - movs r2, 0x80 - lsls r2, 1 - adds r1, r2, 0 - orrs r3, r1 - adds r0, 0x1 - str r0, [r6] - b _081BA52E -_081BA524: - ldr r0, [r6] - adds r0, 0x1 - str r0, [r6] - movs r0, 0 - b _081BA662 -_081BA52E: - adds r0, r3, 0 - bl DecompressGlyphFont6 - adds r0, r6, 0 - bl CopyGlyphToWindow - ldr r0, =gUnknown_03002F90 - adds r0, 0x80 - ldrb r1, [r6, 0xA] - ldrb r0, [r0] - adds r1, r0 - ldrb r0, [r6, 0x8] - adds r0, r1 - strb r0, [r6, 0x8] - movs r0, 0 - b _081BA662 - .pool -_081BA554: - adds r0, r6, 0 - bl TextPrinterWait - lsls r0, 16 - cmp r0, 0 - beq _081BA50E - movs r0, 0 - strb r0, [r6, 0x1C] - b _081BA50E -_081BA566: - adds r0, r6, 0 - bl TextPrinterWaitWithDownArrow - lsls r0, 16 - cmp r0, 0 - beq _081BA50E - ldrb r0, [r6, 0x4] - ldrb r2, [r6, 0xD] - lsls r2, 28 - lsrs r1, r2, 4 - orrs r1, r2 - lsrs r1, 24 - bl FillWindowPixelBuffer - ldrb r0, [r6, 0x6] - movs r1, 0 - strb r0, [r6, 0x8] - ldrb r0, [r6, 0x7] - strb r0, [r6, 0x9] - strb r1, [r6, 0x1C] - b _081BA50E -_081BA590: - adds r0, r6, 0 - bl TextPrinterWaitWithDownArrow - lsls r0, 16 - cmp r0, 0 - beq _081BA50E - adds r0, r6, 0 - bl TextPrinterClearDownArrow - ldrb r1, [r6, 0x5] - ldr r0, =gFonts - ldr r2, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r6, 0xB] - ldrb r0, [r0, 0x5] - adds r1, r0 - strb r1, [r6, 0x1F] - ldrb r0, [r6, 0x6] - strb r0, [r6, 0x8] - movs r0, 0x4 - strb r0, [r6, 0x1C] - b _081BA50E - .pool -_081BA5C8: - ldrb r2, [r6, 0x1F] - cmp r2, 0 - beq _081BA638 - ldr r4, =gUnknown_08616124 - ldr r5, =gSaveBlock2Ptr - ldr r0, [r5] - ldrb r0, [r0, 0x14] - lsls r1, r0, 29 - lsrs r0, r1, 29 - adds r0, r4 - ldrb r0, [r0] - cmp r2, r0 - bcs _081BA604 - ldrb r0, [r6, 0x4] - ldrb r1, [r6, 0xD] - lsls r1, 28 - lsrs r3, r1, 4 - orrs r3, r1 - lsrs r3, 24 - movs r1, 0 - bl ScrollWindow - movs r0, 0 - strb r0, [r6, 0x1F] - b _081BA62E - .pool -_081BA604: - ldrb r0, [r6, 0x4] - lsrs r1, 29 - adds r1, r4 - ldrb r2, [r1] - ldrb r1, [r6, 0xD] - lsls r1, 28 - lsrs r3, r1, 4 - orrs r3, r1 - lsrs r3, 24 - movs r1, 0 - bl ScrollWindow - ldr r0, [r5] - ldrb r0, [r0, 0x14] - lsls r0, 29 - lsrs r0, 29 - adds r0, r4 - ldrb r1, [r6, 0x1F] - ldrb r0, [r0] - subs r1, r0 - strb r1, [r6, 0x1F] -_081BA62E: - ldrb r0, [r6, 0x4] - movs r1, 0x2 - bl CopyWindowToVram - b _081BA50E -_081BA638: - strb r2, [r6, 0x1C] - b _081BA50E -_081BA63C: - bl IsSEPlaying - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _081BA64A - b _081BA50E -_081BA64A: - strb r0, [r6, 0x1C] - b _081BA50E -_081BA64E: - ldrb r0, [r6, 0x1E] - adds r1, r0, 0 - cmp r1, 0 - beq _081BA65C - subs r0, 0x1 - strb r0, [r6, 0x1E] - b _081BA50E -_081BA65C: - strb r1, [r6, 0x1C] - b _081BA50E -_081BA660: - movs r0, 0x1 -_081BA662: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end Font6Func - - thumb_func_start DecompressGlyphFont6 -DecompressGlyphFont6: @ 81BA668 - push {r4,r5,lr} - lsls r0, 16 - lsrs r2, r0, 19 - lsls r2, 9 - movs r1, 0xE0 - lsls r1, 11 - ands r1, r0 - lsrs r1, 11 - ldr r0, =gFont6BrailleGlyphs - adds r1, r0 - adds r5, r2, r1 - ldr r4, =gUnknown_03002F90 - adds r0, r5, 0 - adds r1, r4, 0 - bl DecompressGlyphTile - adds r0, r5, 0 - adds r0, 0x10 - adds r1, r4, 0 - adds r1, 0x20 - bl DecompressGlyphTile - movs r1, 0x80 - lsls r1, 1 - adds r0, r5, r1 - adds r1, r4, 0 - adds r1, 0x40 - bl DecompressGlyphTile - movs r1, 0x88 - lsls r1, 1 - adds r0, r5, r1 - adds r1, r4, 0 - adds r1, 0x60 - bl DecompressGlyphTile - adds r0, r4, 0 - adds r0, 0x80 - movs r1, 0x10 - strb r1, [r0] - adds r0, 0x1 - strb r1, [r0] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end DecompressGlyphFont6 - - thumb_func_start GetGlyphWidthFont6 -GetGlyphWidthFont6: @ 81BA6CC - movs r0, 0x10 - bx lr - thumb_func_end GetGlyphWidthFont6 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/unknown_task.s b/asm/unknown_task.s index 99a614e37..f6b96287e 100644 --- a/asm/unknown_task.s +++ b/asm/unknown_task.s @@ -267,11 +267,11 @@ _080BA1D8: .4byte _080BA250 .4byte _080BA24C _080BA214: - ldr r0, =gUnknown_02022E14 + ldr r0, =gBattle_BG0_X b _080BA24E .pool _080BA21C: - ldr r0, =gUnknown_02022E16 + ldr r0, =gBattle_BG0_Y b _080BA24E .pool _080BA224: @@ -295,7 +295,7 @@ _080BA244: b _080BA24E .pool _080BA24C: - ldr r0, =gUnknown_02022E22 + ldr r0, =gBattle_BG3_Y _080BA24E: ldrh r6, [r0] _080BA250: diff --git a/asmdiff.sh b/asmdiff.sh new file mode 100644 index 000000000..1d2141c32 --- /dev/null +++ b/asmdiff.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb" +OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))" +$OBJDUMP $OPTIONS baserom.gba > baserom.dump +$OBJDUMP $OPTIONS pokeemerald.gba > pokeemerald.dump +diff baserom.dump pokeemerald.dump diff --git a/data/battle_anims.s b/data/battle_anims.s index 471394fe8..13e1bdc2f 100644 --- a/data/battle_anims.s +++ b/data/battle_anims.s @@ -988,7 +988,7 @@ gUnknown_08525F58:: @ 8525F58 .byte 0x5a, 0x58, 0x00, 0x00, 0x98, 0x20, 0x00, 0x00 .align 2 -gUnknown_08525F78:: @ 8525F78 +gCastformFrontSpriteCoords:: @ 8525F78 .byte 0x44, 0x11, 0x00, 0x00, 0x66, 0x09, 0x00, 0x00 .byte 0x46, 0x09, 0x00, 0x00, 0x86, 0x08, 0x00, 0x00 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 206519f40..b2dfec5d8 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -45,40 +45,40 @@ gUnknown_082DA7C4:: @ 82DA7C4 gUnknown_082DA7CD:: @ 82DA7CD .incbin "baserom.gba", 0x2da7cd, 0x160 -gUnknown_082DA92D:: @ 82DA92D +BattleScript_LocalTrainerBattleWon:: @ 82DA92D .incbin "baserom.gba", 0x2da92d, 0x3d -gUnknown_082DA96A:: @ 82DA96A +BattleScript_PayDayMoneyAndPickUpItems:: @ 82DA96A .incbin "baserom.gba", 0x2da96a, 0x3 -gUnknown_082DA96D:: @ 82DA96D +BattleScript_LocalBattleLost:: @ 82DA96D .incbin "baserom.gba", 0x2da96d, 0x9e gUnknown_082DAA0B:: @ 82DAA0B .incbin "baserom.gba", 0x2daa0b, 0x2a -gUnknown_082DAA35:: @ 82DAA35 +BattleScript_LinkBattleWonOrLost:: @ 82DAA35 .incbin "baserom.gba", 0x2daa35, 0x52 -gUnknown_082DAA87:: @ 82DAA87 +BattleScript_FrontierTrainerBattleWon:: @ 82DAA87 .incbin "baserom.gba", 0x2daa87, 0x54 -gUnknown_082DAADB:: @ 82DAADB +BattleScript_SmokeBallEscape:: @ 82DAADB .incbin "baserom.gba", 0x2daadb, 0xe -gUnknown_082DAAE9:: @ 82DAAE9 +BattleScript_RanAwayUsingMonAbility:: @ 82DAAE9 .incbin "baserom.gba", 0x2daae9, 0x7 -gUnknown_082DAAF0:: @ 82DAAF0 +BattleScript_GotAwaySafely:: @ 82DAAF0 .incbin "baserom.gba", 0x2daaf0, 0x7 -gUnknown_082DAAF7:: @ 82DAAF7 +BattleScript_WildMonFled:: @ 82DAAF7 .incbin "baserom.gba", 0x2daaf7, 0x7 gUnknown_082DAAFE:: @ 82DAAFE .incbin "baserom.gba", 0x2daafe, 0x4 -gUnknown_082DAB02:: @ 82DAB02 +BattleScript_PrintFailedToRunString:: @ 82DAB02 .incbin "baserom.gba", 0x2dab02, 0x9 gUnknown_082DAB0B:: @ 82DAB0B @@ -87,7 +87,7 @@ gUnknown_082DAB0B:: @ 82DAB0B gUnknown_082DAB11:: @ 82DAB11 .incbin "baserom.gba", 0x2dab11, 0x4 -gUnknown_082DAB15:: @ 82DAB15 +BattleScript_ActionSwitch:: @ 82DAB15 .incbin "baserom.gba", 0x2dab15, 0xa4 BattleScript_Pausex20:: @ 82DABB9 @@ -255,7 +255,7 @@ BattleScript_OneHitKOMsg:: @ 82DB1CE BattleScript_SAtkDown2:: @ 82DB1D5 .incbin "baserom.gba", 0x2db1d5, 0x2a -gUnknown_082DB1FF:: @ 82DB1FF +BattleScript_FocusPunchSetUp:: @ 82DB1FF .incbin "baserom.gba", 0x2db1ff, 0x14 BattleScript_MoveUsedIsAsleep:: @ 82DB213 @@ -561,7 +561,7 @@ BattleScript_BerryStatRaiseEnd2:: @ 82DB84E BattleScript_BerryFocusEnergyEnd2:: @ 82DB869 .incbin "baserom.gba", 0x2db869, 0x10 -gUnknown_082DB879:: @ 82DB879 +BattleScript_ActionSelectionItemsCantBeUsed:: @ 82DB879 .incbin "baserom.gba", 0x2db879, 0x4 gUnknown_082DB87D:: @ 82DB87D diff --git a/data/battle_scripts_2.s b/data/battle_scripts_2.s index adabccb88..4a4dc4665 100644 --- a/data/battle_scripts_2.s +++ b/data/battle_scripts_2.s @@ -4,7 +4,7 @@ .section script_data, "aw", %progbits .align 2 -gUnknown_082DBD08:: @ 82DBD08 +gBattlescriptsForBallThrow:: @ 82DBD08 .4byte gUnknown_082DBD68 .4byte gUnknown_082DBD68 .4byte gUnknown_082DBD68 @@ -29,11 +29,11 @@ gUnknown_082DBD3C:: @ 82DBD3C .4byte gUnknown_082DBE91 .align 2 -gUnknown_082DBD54:: @ 82DBD54 - .4byte gUnknown_082DBEB3 +gBattlescriptsForRunningByItem:: @ 82DBD54 + .4byte BattleScript_RunByUsingItem .align 2 -gUnknown_082DBD58:: @ 82DBD58 +gBattlescriptsForSafariActions:: @ 82DBD58 .4byte gUnknown_082DBEBD .4byte gUnknown_082DBEC4 .4byte gUnknown_082DBECD @@ -72,7 +72,7 @@ gUnknown_082DBE6F:: @ 82DBE6F gUnknown_082DBE91:: @ 82DBE91 .incbin "baserom.gba", 0x2dbe91, 0x22 -gUnknown_082DBEB3:: @ 82DBEB3 +BattleScript_RunByUsingItem:: @ 82DBEB3 .incbin "baserom.gba", 0x2dbeb3, 0xA gUnknown_082DBEBD:: @ 82DBEBD diff --git a/data/data2b.s b/data/data2b.s index 471993027..2565f4c04 100644 --- a/data/data2b.s +++ b/data/data2b.s @@ -3039,7 +3039,7 @@ gUnknown_08300654:: @ 8300654 .4byte gUnknown_08300654 .align 2 -gUnknown_08300D38:: @ 8300D38 +gMonFrontPicCoords:: @ 8300D38 .byte 0x88, 0x00, 0x00, 0x00 .byte 0x45, 0x0e, 0x00, 0x00 .byte 0x56, 0x0a, 0x00, 0x00 @@ -4828,10 +4828,9 @@ gUnknown_0831AC70:: @ 831AC70 gUnknown_0831AC88:: @ 831AC88 spr_template 0x0000, 0x0000, gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_8038528 - .align 2 -gUnknown_0831ACA0:: @ 831ACA0 - .string "ヌケニン$" @ "Nukenin" (Shedinja) - +gText_ShedinjaJapaneseName:: @ 831ACA0 + .string "ヌケニン$" @ Nukenin + .align 2 gUnknown_0831ACA8:: @ 831ACA8 .2byte 0x0100 @@ -4881,93 +4880,3 @@ gUnknown_0831ACE0:: @ 831ACE0 @ 831BAD4 .include "data/text/ability_description_pointers.inc" - - .align 2 -gUnknown_0831BC0C:: @ 831BC0C - .4byte sub_803E0B8 - .4byte sub_803E90C - .4byte bs2_8016374 - .4byte sub_803EE48 - .4byte sub_803EFA8 - .4byte bs5_8016AC0 - .4byte sub_803F050 - .4byte sub_803F120 - .4byte bs8_exit_by_flight - .4byte bs9_8016C9C - .4byte sub_80458B4 - .4byte bsB_exit_by_move - .4byte bsC_8016D70 - .4byte bsD_proceed - - .align 2 -gUnknown_0831BC44:: @ 831BC44 - .4byte bc_8013B1C - .4byte sub_803D8C0 - .4byte sub_803DAC0 - .4byte sub_803DAC0 - .4byte sub_803DBA0 - .4byte sub_803DCD8 - .4byte bc_80158BC - .4byte sub_803DCD8 - .4byte sub_803DCD8 - .4byte sub_803DCD8 - .4byte sub_803DCD8 - -gStatusConditionString_PoisonJpn:: @ 81FA69C - .string "どく$$$$$$" - -gStatusConditionString_SleepJpn:: @ 81FA6A4 - .string "ねむり$$$$$" - -gStatusConditionString_ParalysisJpn:: @ 81FA6AC - .string "まひ$$$$$$" - -gStatusConditionString_BurnJpn:: @ 81FA6B4 - .string "やけど$$$$$" - -gStatusConditionString_IceJpn:: @ 81FA6BC - .string "こおり$$$$$" - -gStatusConditionString_ConfusionJpn:: @ 81FA6C4 - .string "こんらん$$$$" - -gStatusConditionString_LoveJpn:: @ 81FA6CC - .string "メロメロ$$$$" - - .align 2 -gUnknown_0831BCA8:: @ 831BCA8 - .4byte gStatusConditionString_PoisonJpn, gText_Poison - .4byte gStatusConditionString_SleepJpn, gText_Sleep - .4byte gStatusConditionString_ParalysisJpn, gText_Paralysis - .4byte gStatusConditionString_BurnJpn, gText_Burn - .4byte gStatusConditionString_IceJpn, gText_Ice - .4byte gStatusConditionString_ConfusionJpn, gText_Confusion - .4byte gStatusConditionString_LoveJpn, gText_Love - -gUnknown_0831BCE0:: @ 831BCE0 - .byte 0, 0, 0 - .byte 3, 5, 0 - .byte 2, 3, 0 - .byte 1, 2, 0 - .byte 1, 1, 0 - -gUnknown_0831BCEF:: @ 831BCEF - .byte 4, 3, 2, 1 - -gUnknown_0831BCF3:: @ 831BCF3 - .byte 4, 4, 4, 4 - - .align 2 -gSoundMovesTable:: @ 831BCF8 - .2byte 0x2D - .2byte 0x2E - .2byte 0x2F - .2byte 0x30 - .2byte 0x67 - .2byte 0xAD - .2byte 0xFD - .2byte 0x13F - .2byte 0x140 - .2byte 0x130 - .2byte 0xFFFF - diff --git a/data/data4.s b/data/data4.s index 202b1ffe7..d99336e87 100644 --- a/data/data4.s +++ b/data/data4.s @@ -14,19 +14,16 @@ gUnknown_085B09F4:: @ 85B09F4 gUnknown_085B09F8:: @ 85B09F8 .incbin "baserom.gba", 0x5b09f8, 0x8 -gUnknown_085B0A00:: @ 85B0A00 - .incbin "baserom.gba", 0x5b0a00, 0x2 +gBirchBagGrassPal:: @ 85B0A00 + .incbin "baserom.gba", 0x5b0a00, 0x80 -gUnknown_085B0A02:: @ 85B0A02 - .incbin "baserom.gba", 0x5b0a02, 0x7e - -gUnknown_085B0A80:: @ 85B0A80 +gBirchBagTilemap:: @ 85B0A80 .incbin "baserom.gba", 0x5b0a80, 0x18c -gUnknown_085B0C0C:: @ 85B0C0C +gBirchGrassTilemap:: @ 85B0C0C .incbin "baserom.gba", 0x5b0c0c, 0x1f8 -gUnknown_085B0E04:: @ 85B0E04 +gBirchHelpGfx:: @ 85B0E04 .incbin "baserom.gba", 0x5b0e04, 0xfc8 gUnknown_085B1DCC:: @ 85B1DCC diff --git a/data/diploma.s b/data/diploma.s deleted file mode 100644 index 43a3d9c70..000000000 --- a/data/diploma.s +++ /dev/null @@ -1,22 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - -gUnknown_085E7088:: @ 85E7088 - .incbin "baserom.gba", 0x5e7088, 0x40 - -gUnknown_085E70C8:: @ 85E70C8 - .incbin "baserom.gba", 0x5e70c8, 0x73c - -gUnknown_085E7804:: @ 85E7804 - .incbin "baserom.gba", 0x5e7804, 0x9f8 - -gUnknown_085E81FC:: @ 85E81FC - .incbin "baserom.gba", 0x5e81fc, 0x8 - -gUnknown_085E8204:: @ 85E8204 - .incbin "baserom.gba", 0x5e8204, 0x10 - -gUnknown_085E8214:: @ 85E8214 - .incbin "baserom.gba", 0x5e8214, 0x4 diff --git a/data/event_scripts.s b/data/event_scripts.s index e4293570d..4dd5761e5 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -84,14 +84,14 @@ gUnknown_0823B68C:: @ 823B68C gUnknown_0823C050:: @ 823C050 .incbin "baserom.gba", 0x23c050, 0x6431 -gUnknown_08242481:: @ 8242481 +gText_BattleRecordCouldntBeSaved:: @ 8242481 .incbin "baserom.gba", 0x242481, 0x87b gUnknown_08242CFC:: @ 8242CFC .incbin "baserom.gba", 0x242cfc, 0x6a91 -gUnknown_0824978D:: @ 824978D - .incbin "baserom.gba", 0x24978d, 0xe +gText_LinkStandby3:: @ 824978D + .string "Link standby…$" gUnknown_0824979B:: @ 824979B .incbin "baserom.gba", 0x24979b, 0x944d diff --git a/data/field_effect_scripts.s b/data/field_effect_scripts.s index 89ed27301..ceb327084 100644 --- a/data/field_effect_scripts.s +++ b/data/field_effect_scripts.s @@ -316,7 +316,7 @@ gFieldEffectScript_FieldMoveShowMonInit:: @ 82DBCCC field_eff_end gFieldEffectScript_Unknown60:: @ 82DBCD2 - field_eff_callnative sub_81799B8 + field_eff_callnative FldEff_UsePuzzleEffect field_eff_end gFieldEffectScript_Unknown61:: @ 82DBCD8 diff --git a/data/graphics.s b/data/graphics.s index 2c29d6ca5..e1b76565a 100644 --- a/data/graphics.s +++ b/data/graphics.s @@ -467,7 +467,19 @@ gUnknown_08D85600:: @ 8D85600 .incbin "baserom.gba", 0xd85600, 0x20 gUnknown_08D85620:: @ 8D85620 - .incbin "baserom.gba", 0xd85620, 0xa8 + .incbin "baserom.gba", 0xd85620, 0x20 + +gUnknown_08D85640:: @ 8D85640 + .incbin "baserom.gba", 0xd85640, 0x20 + +gUnknown_08D85660:: @ 8D85660 + .incbin "baserom.gba", 0xd85660, 0x20 + +gUnknown_08D85680:: @ 8D85680 + .incbin "baserom.gba", 0xd85680, 0x20 + +gUnknown_08D856A0:: @ 8D856A0 + .incbin "baserom.gba", 0xd856a0, 0x28 gUnknown_08D856C8:: @ 8D856C8 .incbin "baserom.gba", 0xd856c8, 0xe0 diff --git a/data/palette.s b/data/palette.s deleted file mode 100644 index 2dbfed8d2..000000000 --- a/data/palette.s +++ /dev/null @@ -1,18 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2, 0 - -gUnknown_0852487C:: @ 852487C - .incbin "baserom.gba", 0x52487c, 0x10 - -gDummyPaletteStructTemplate:: @ 852488C - .2byte 0xFFFF - .space 9 - .byte 0x20 - .space 4 - - .align 2 -gUnknown_0852489C:: @ 852489C - .incbin "baserom.gba", 0x52489c, 0x20 diff --git a/data/save_failed_screen.s b/data/save_failed_screen.s deleted file mode 100644 index 446eee2d2..000000000 --- a/data/save_failed_screen.s +++ /dev/null @@ -1,28 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - -gUnknown_085EFD80:: @ 85EFD80 - .incbin "baserom.gba", 0x5efd80, 0x8 - -gUnknown_085EFD88:: @ 85EFD88 - .incbin "baserom.gba", 0x5efd88, 0xc - -gUnknown_085EFD94:: @ 85EFD94 - .incbin "baserom.gba", 0x5efd94, 0x8 - -gUnknown_085EFD9C:: @ 85EFD9C - .incbin "baserom.gba", 0x5efd9c, 0x8 - -gUnknown_085EFDA4:: @ 85EFDA4 - .incbin "baserom.gba", 0x5efda4, 0x8 - -gUnknown_085EFDAC:: @ 85EFDAC - .incbin "baserom.gba", 0x5efdac, 0x18 - -gUnknown_085EFDC4:: @ 85EFDC4 - .incbin "baserom.gba", 0x5efdc4, 0x20 - -gUnknown_085EFDE4:: @ 85EFDE4 - .incbin "baserom.gba", 0x5efde4, 0x90 diff --git a/data/save_location.s b/data/save_location.s deleted file mode 100644 index eabed7d86..000000000 --- a/data/save_location.s +++ /dev/null @@ -1,13 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - -gUnknown_086143BC:: @ 86143BC - .incbin "baserom.gba", 0x6143bc, 0x4e - -gUnknown_0861440A:: @ 861440A - .incbin "baserom.gba", 0x61440a, 0x4 - -gUnknown_0861440E:: @ 861440E - .incbin "baserom.gba", 0x61440e, 0x2 diff --git a/data/start_menu.s b/data/start_menu.s index eaba0b8e1..07e428d0d 100644 --- a/data/start_menu.s +++ b/data/start_menu.s @@ -26,4 +26,4 @@ gUnknown_085105AC:: @ 85105AC .incbin "baserom.gba", 0x5105ac, 0x10 gUnknown_085105BC:: @ 85105BC - .incbin "baserom.gba", 0x5105bc, 0x1a8 + .incbin "baserom.gba", 0x5105bc, 0x8 diff --git a/data/tileset.s b/data/tileset.s deleted file mode 100644 index 1221d8967..000000000 --- a/data/tileset.s +++ /dev/null @@ -1,116 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2, 0 - -gUnknown_08510764:: @ 8510764 - .incbin "baserom.gba", 0x510764, 0xb60 - -gUnknown_085112C4:: @ 85112C4 - .incbin "baserom.gba", 0x5112c4, 0x908 - -gUnknown_08511BCC:: @ 8511BCC - .incbin "baserom.gba", 0x511bcc, 0x9a8 - -gUnknown_08512574:: @ 8512574 - .incbin "baserom.gba", 0x512574, 0x8e0 - -gUnknown_08512E54:: @ 8512E54 - .incbin "baserom.gba", 0x512e54, 0x320 - -gUnknown_08513174:: @ 8513174 - .incbin "baserom.gba", 0x513174, 0x510 - -gUnknown_08513684:: @ 8513684 - .incbin "baserom.gba", 0x513684, 0x210 - -gUnknown_08513894:: @ 8513894 - .incbin "baserom.gba", 0x513894, 0xb50 - -gUnknown_085143E4:: @ 85143E4 - .incbin "baserom.gba", 0x5143e4, 0x210 - -gUnknown_085145F4:: @ 85145F4 - .incbin "baserom.gba", 0x5145f4, 0x810 - -gUnknown_08514E04:: @ 8514E04 - .incbin "baserom.gba", 0x514e04, 0x540 - -gUnknown_08515344:: @ 8515344 - .incbin "baserom.gba", 0x515344, 0x20 - -gUnknown_08515364:: @ 8515364 - .incbin "baserom.gba", 0x515364, 0x20 - -gUnknown_08515384:: @ 8515384 - .incbin "baserom.gba", 0x515384, 0x30 - -gUnknown_085153B4:: @ 85153B4 - .incbin "baserom.gba", 0x5153b4, 0x30 - -gUnknown_085153E4:: @ 85153E4 - .incbin "baserom.gba", 0x5153e4, 0x10 - -gUnknown_085153F4:: @ 85153F4 - .incbin "baserom.gba", 0x5153f4, 0x410 - -gUnknown_08515804:: @ 8515804 - .incbin "baserom.gba", 0x515804, 0x20 - -gUnknown_08515824:: @ 8515824 - .incbin "baserom.gba", 0x515824, 0x140 - -gUnknown_08515964:: @ 8515964 - .incbin "baserom.gba", 0x515964, 0x428 - -gUnknown_08515D8C:: @ 8515D8C - .incbin "baserom.gba", 0x515d8c, 0x430 - -gUnknown_085161BC:: @ 85161BC - .incbin "baserom.gba", 0x5161bc, 0x20 - -gUnknown_085161DC:: @ 85161DC - .incbin "baserom.gba", 0x5161dc, 0x320 - -gUnknown_085164FC:: @ 85164FC - .incbin "baserom.gba", 0x5164fc, 0x310 - -gUnknown_0851680C:: @ 851680C - .incbin "baserom.gba", 0x51680c, 0x310 - -gUnknown_08516B1C:: @ 8516B1C - .incbin "baserom.gba", 0x516b1c, 0x210 - -gUnknown_08516D2C:: @ 8516D2C - .incbin "baserom.gba", 0x516d2c, 0x110 - -gUnknown_08516E3C:: @ 8516E3C - .incbin "baserom.gba", 0x516e3c, 0xc08 - -gUnknown_08517A44:: @ 8517A44 - .incbin "baserom.gba", 0x517a44, 0xc - -gUnknown_08517A50:: @ 8517A50 - .incbin "baserom.gba", 0x517a50, 0x1ac - -gUnknown_08517BFC:: @ 8517BFC - .incbin "baserom.gba", 0x517bfc, 0x10 - -gUnknown_08517C0C:: @ 8517C0C - .incbin "baserom.gba", 0x517c0c, 0x428 - -gUnknown_08518034:: @ 8518034 - .incbin "baserom.gba", 0x518034, 0x268 - -gUnknown_0851829C:: @ 851829C - .incbin "baserom.gba", 0x51829c, 0x8028 - -gUnknown_085202C4:: @ 85202C4 - .incbin "baserom.gba", 0x5202c4, 0x45a0 - -gUnknown_08524864:: @ 8524864 - .incbin "baserom.gba", 0x524864, 0xc - -gUnknown_08524870:: @ 8524870 - .incbin "baserom.gba", 0x524870, 0xc diff --git a/data/tilesets/primary/building/anim/0.png b/data/tilesets/primary/building/anim/0.png new file mode 100644 index 000000000..004eccc67 Binary files /dev/null and b/data/tilesets/primary/building/anim/0.png differ diff --git a/data/tilesets/primary/building/anim/1.png b/data/tilesets/primary/building/anim/1.png new file mode 100644 index 000000000..e28281dea Binary files /dev/null and b/data/tilesets/primary/building/anim/1.png differ diff --git a/data/tilesets/primary/general/anim/0/0.png b/data/tilesets/primary/general/anim/0/0.png new file mode 100644 index 000000000..d535d920e Binary files /dev/null and b/data/tilesets/primary/general/anim/0/0.png differ diff --git a/data/tilesets/primary/general/anim/0/1.png b/data/tilesets/primary/general/anim/0/1.png new file mode 100644 index 000000000..74f93ecce Binary files /dev/null and b/data/tilesets/primary/general/anim/0/1.png differ diff --git a/data/tilesets/primary/general/anim/0/2.png b/data/tilesets/primary/general/anim/0/2.png new file mode 100644 index 000000000..fb0bfe89f Binary files /dev/null and b/data/tilesets/primary/general/anim/0/2.png differ diff --git a/data/tilesets/primary/general/anim/1/0.png b/data/tilesets/primary/general/anim/1/0.png new file mode 100644 index 000000000..a7bb2e631 Binary files /dev/null and b/data/tilesets/primary/general/anim/1/0.png differ diff --git a/data/tilesets/primary/general/anim/1/1.png b/data/tilesets/primary/general/anim/1/1.png new file mode 100644 index 000000000..c215f1683 Binary files /dev/null and b/data/tilesets/primary/general/anim/1/1.png differ diff --git a/data/tilesets/primary/general/anim/1/2.png b/data/tilesets/primary/general/anim/1/2.png new file mode 100644 index 000000000..f8e0ee273 Binary files /dev/null and b/data/tilesets/primary/general/anim/1/2.png differ diff --git a/data/tilesets/primary/general/anim/1/3.png b/data/tilesets/primary/general/anim/1/3.png new file mode 100644 index 000000000..6c6ce3611 Binary files /dev/null and b/data/tilesets/primary/general/anim/1/3.png differ diff --git a/data/tilesets/primary/general/anim/1/4.png b/data/tilesets/primary/general/anim/1/4.png new file mode 100644 index 000000000..cc1f9576c Binary files /dev/null and b/data/tilesets/primary/general/anim/1/4.png differ diff --git a/data/tilesets/primary/general/anim/1/5.png b/data/tilesets/primary/general/anim/1/5.png new file mode 100644 index 000000000..3c0c57a86 Binary files /dev/null and b/data/tilesets/primary/general/anim/1/5.png differ diff --git a/data/tilesets/primary/general/anim/1/6.png b/data/tilesets/primary/general/anim/1/6.png new file mode 100644 index 000000000..be5ecacaa Binary files /dev/null and b/data/tilesets/primary/general/anim/1/6.png differ diff --git a/data/tilesets/primary/general/anim/1/7.png b/data/tilesets/primary/general/anim/1/7.png new file mode 100644 index 000000000..85bc7561a Binary files /dev/null and b/data/tilesets/primary/general/anim/1/7.png differ diff --git a/data/tilesets/primary/general/anim/2/0.png b/data/tilesets/primary/general/anim/2/0.png new file mode 100644 index 000000000..6f9f0c309 Binary files /dev/null and b/data/tilesets/primary/general/anim/2/0.png differ diff --git a/data/tilesets/primary/general/anim/2/1.png b/data/tilesets/primary/general/anim/2/1.png new file mode 100644 index 000000000..bef1f3023 Binary files /dev/null and b/data/tilesets/primary/general/anim/2/1.png differ diff --git a/data/tilesets/primary/general/anim/2/2.png b/data/tilesets/primary/general/anim/2/2.png new file mode 100644 index 000000000..b5d7a9ee9 Binary files /dev/null and b/data/tilesets/primary/general/anim/2/2.png differ diff --git a/data/tilesets/primary/general/anim/2/3.png b/data/tilesets/primary/general/anim/2/3.png new file mode 100644 index 000000000..42a953a83 Binary files /dev/null and b/data/tilesets/primary/general/anim/2/3.png differ diff --git a/data/tilesets/primary/general/anim/2/4.png b/data/tilesets/primary/general/anim/2/4.png new file mode 100644 index 000000000..112b20077 Binary files /dev/null and b/data/tilesets/primary/general/anim/2/4.png differ diff --git a/data/tilesets/primary/general/anim/2/5.png b/data/tilesets/primary/general/anim/2/5.png new file mode 100644 index 000000000..7f58c0b94 Binary files /dev/null and b/data/tilesets/primary/general/anim/2/5.png differ diff --git a/data/tilesets/primary/general/anim/2/6.png b/data/tilesets/primary/general/anim/2/6.png new file mode 100644 index 000000000..784a543b4 Binary files /dev/null and b/data/tilesets/primary/general/anim/2/6.png differ diff --git a/data/tilesets/primary/general/anim/3/0.png b/data/tilesets/primary/general/anim/3/0.png new file mode 100644 index 000000000..2f8bb49b6 Binary files /dev/null and b/data/tilesets/primary/general/anim/3/0.png differ diff --git a/data/tilesets/primary/general/anim/3/1.png b/data/tilesets/primary/general/anim/3/1.png new file mode 100644 index 000000000..5a2744a66 Binary files /dev/null and b/data/tilesets/primary/general/anim/3/1.png differ diff --git a/data/tilesets/primary/general/anim/3/2.png b/data/tilesets/primary/general/anim/3/2.png new file mode 100644 index 000000000..0ddf1cda7 Binary files /dev/null and b/data/tilesets/primary/general/anim/3/2.png differ diff --git a/data/tilesets/primary/general/anim/3/3.png b/data/tilesets/primary/general/anim/3/3.png new file mode 100644 index 000000000..f3fee8470 Binary files /dev/null and b/data/tilesets/primary/general/anim/3/3.png differ diff --git a/data/tilesets/primary/general/anim/4/0.png b/data/tilesets/primary/general/anim/4/0.png new file mode 100644 index 000000000..90dc0bc02 Binary files /dev/null and b/data/tilesets/primary/general/anim/4/0.png differ diff --git a/data/tilesets/primary/general/anim/4/1.png b/data/tilesets/primary/general/anim/4/1.png new file mode 100644 index 000000000..4459a94e5 Binary files /dev/null and b/data/tilesets/primary/general/anim/4/1.png differ diff --git a/data/tilesets/primary/general/anim/4/2.png b/data/tilesets/primary/general/anim/4/2.png new file mode 100644 index 000000000..389875c31 Binary files /dev/null and b/data/tilesets/primary/general/anim/4/2.png differ diff --git a/data/tilesets/primary/general/anim/4/3.png b/data/tilesets/primary/general/anim/4/3.png new file mode 100644 index 000000000..ac8936cce Binary files /dev/null and b/data/tilesets/primary/general/anim/4/3.png differ diff --git a/data/tilesets/primary/general/tiles.png b/data/tilesets/primary/general/tiles.png index 3d1e90510..121e835a2 100644 Binary files a/data/tilesets/primary/general/tiles.png and b/data/tilesets/primary/general/tiles.png differ diff --git a/data/tilesets/primary/inside_building/tiles.png b/data/tilesets/primary/inside_building/tiles.png index 7d267dfb7..506bb7400 100644 Binary files a/data/tilesets/primary/inside_building/tiles.png and b/data/tilesets/primary/inside_building/tiles.png differ diff --git a/data/tilesets/primary/secret_base/tiles.png b/data/tilesets/primary/secret_base/tiles.png index 9adc0e13f..9dee014ea 100644 Binary files a/data/tilesets/primary/secret_base/tiles.png and b/data/tilesets/primary/secret_base/tiles.png differ diff --git a/data/tilesets/primary/secret_base/unknown_tiles.png b/data/tilesets/primary/secret_base/unknown_tiles.png index dd5c4e16a..3ca4d9e87 100644 Binary files a/data/tilesets/primary/secret_base/unknown_tiles.png and b/data/tilesets/primary/secret_base/unknown_tiles.png differ diff --git a/data/tilesets/secondary/battle_arena/tiles.png b/data/tilesets/secondary/battle_arena/tiles.png index 43297aa7b..7414666df 100644 Binary files a/data/tilesets/secondary/battle_arena/tiles.png and b/data/tilesets/secondary/battle_arena/tiles.png differ diff --git a/data/tilesets/secondary/battle_dome/tiles.png b/data/tilesets/secondary/battle_dome/tiles.png index e0fce3196..be3708bfd 100644 Binary files a/data/tilesets/secondary/battle_dome/tiles.png and b/data/tilesets/secondary/battle_dome/tiles.png differ diff --git a/data/tilesets/secondary/battle_factory/tiles.png b/data/tilesets/secondary/battle_factory/tiles.png index 7857f0813..4d9463b20 100644 Binary files a/data/tilesets/secondary/battle_factory/tiles.png and b/data/tilesets/secondary/battle_factory/tiles.png differ diff --git a/data/tilesets/secondary/battle_frontier/tiles.png b/data/tilesets/secondary/battle_frontier/tiles.png index 70ec420e9..1b14ce555 100644 Binary files a/data/tilesets/secondary/battle_frontier/tiles.png and b/data/tilesets/secondary/battle_frontier/tiles.png differ diff --git a/data/tilesets/secondary/battle_frontier_outside_east/anim/0.png b/data/tilesets/secondary/battle_frontier_outside_east/anim/0.png new file mode 100644 index 000000000..8a9905198 Binary files /dev/null and b/data/tilesets/secondary/battle_frontier_outside_east/anim/0.png differ diff --git a/data/tilesets/secondary/battle_frontier_outside_east/anim/1.png b/data/tilesets/secondary/battle_frontier_outside_east/anim/1.png new file mode 100644 index 000000000..836986b12 Binary files /dev/null and b/data/tilesets/secondary/battle_frontier_outside_east/anim/1.png differ diff --git a/data/tilesets/secondary/battle_frontier_outside_east/anim/2.png b/data/tilesets/secondary/battle_frontier_outside_east/anim/2.png new file mode 100644 index 000000000..660d3080f Binary files /dev/null and b/data/tilesets/secondary/battle_frontier_outside_east/anim/2.png differ diff --git a/data/tilesets/secondary/battle_frontier_outside_east/anim/3.png b/data/tilesets/secondary/battle_frontier_outside_east/anim/3.png new file mode 100644 index 000000000..7fe571b4a Binary files /dev/null and b/data/tilesets/secondary/battle_frontier_outside_east/anim/3.png differ diff --git a/data/tilesets/secondary/battle_frontier_outside_east/tiles.png b/data/tilesets/secondary/battle_frontier_outside_east/tiles.png index 20cb7d67e..da34656d1 100644 Binary files a/data/tilesets/secondary/battle_frontier_outside_east/tiles.png and b/data/tilesets/secondary/battle_frontier_outside_east/tiles.png differ diff --git a/data/tilesets/secondary/battle_frontier_outside_west/anim/0.png b/data/tilesets/secondary/battle_frontier_outside_west/anim/0.png new file mode 100644 index 000000000..8a9905198 Binary files /dev/null and b/data/tilesets/secondary/battle_frontier_outside_west/anim/0.png differ diff --git a/data/tilesets/secondary/battle_frontier_outside_west/anim/1.png b/data/tilesets/secondary/battle_frontier_outside_west/anim/1.png new file mode 100644 index 000000000..836986b12 Binary files /dev/null and b/data/tilesets/secondary/battle_frontier_outside_west/anim/1.png differ diff --git a/data/tilesets/secondary/battle_frontier_outside_west/anim/2.png b/data/tilesets/secondary/battle_frontier_outside_west/anim/2.png new file mode 100644 index 000000000..660d3080f Binary files /dev/null and b/data/tilesets/secondary/battle_frontier_outside_west/anim/2.png differ diff --git a/data/tilesets/secondary/battle_frontier_outside_west/anim/3.png b/data/tilesets/secondary/battle_frontier_outside_west/anim/3.png new file mode 100644 index 000000000..7fe571b4a Binary files /dev/null and b/data/tilesets/secondary/battle_frontier_outside_west/anim/3.png differ diff --git a/data/tilesets/secondary/battle_frontier_outside_west/tiles.png b/data/tilesets/secondary/battle_frontier_outside_west/tiles.png index 3d5ea94f9..03704bfd0 100644 Binary files a/data/tilesets/secondary/battle_frontier_outside_west/tiles.png and b/data/tilesets/secondary/battle_frontier_outside_west/tiles.png differ diff --git a/data/tilesets/secondary/battle_frontier_ranking_hall/tiles.png b/data/tilesets/secondary/battle_frontier_ranking_hall/tiles.png index cf54e1d77..1c1f700c0 100644 Binary files a/data/tilesets/secondary/battle_frontier_ranking_hall/tiles.png and b/data/tilesets/secondary/battle_frontier_ranking_hall/tiles.png differ diff --git a/data/tilesets/secondary/battle_palace/tiles.png b/data/tilesets/secondary/battle_palace/tiles.png index a848a9eef..4e11e3596 100644 Binary files a/data/tilesets/secondary/battle_palace/tiles.png and b/data/tilesets/secondary/battle_palace/tiles.png differ diff --git a/data/tilesets/secondary/battle_pike/tiles.png b/data/tilesets/secondary/battle_pike/tiles.png index cba2f5794..fc11f1d1a 100644 Binary files a/data/tilesets/secondary/battle_pike/tiles.png and b/data/tilesets/secondary/battle_pike/tiles.png differ diff --git a/data/tilesets/secondary/battle_pyramid/anim/0/0.png b/data/tilesets/secondary/battle_pyramid/anim/0/0.png new file mode 100644 index 000000000..c0fb59c0e Binary files /dev/null and b/data/tilesets/secondary/battle_pyramid/anim/0/0.png differ diff --git a/data/tilesets/secondary/battle_pyramid/anim/0/1.png b/data/tilesets/secondary/battle_pyramid/anim/0/1.png new file mode 100644 index 000000000..29c019209 Binary files /dev/null and b/data/tilesets/secondary/battle_pyramid/anim/0/1.png differ diff --git a/data/tilesets/secondary/battle_pyramid/anim/0/2.png b/data/tilesets/secondary/battle_pyramid/anim/0/2.png new file mode 100644 index 000000000..7c463d9c3 Binary files /dev/null and b/data/tilesets/secondary/battle_pyramid/anim/0/2.png differ diff --git a/data/tilesets/secondary/battle_pyramid/anim/1/0.png b/data/tilesets/secondary/battle_pyramid/anim/1/0.png new file mode 100644 index 000000000..2a0921dea Binary files /dev/null and b/data/tilesets/secondary/battle_pyramid/anim/1/0.png differ diff --git a/data/tilesets/secondary/battle_pyramid/anim/1/1.png b/data/tilesets/secondary/battle_pyramid/anim/1/1.png new file mode 100644 index 000000000..3474d081f Binary files /dev/null and b/data/tilesets/secondary/battle_pyramid/anim/1/1.png differ diff --git a/data/tilesets/secondary/battle_pyramid/anim/1/2.png b/data/tilesets/secondary/battle_pyramid/anim/1/2.png new file mode 100644 index 000000000..b9f1c4423 Binary files /dev/null and b/data/tilesets/secondary/battle_pyramid/anim/1/2.png differ diff --git a/data/tilesets/secondary/battle_pyramid/anim/1/3.png b/data/tilesets/secondary/battle_pyramid/anim/1/3.png new file mode 100644 index 000000000..8ad81b1e1 Binary files /dev/null and b/data/tilesets/secondary/battle_pyramid/anim/1/3.png differ diff --git a/data/tilesets/secondary/battle_pyramid/anim/1/4.png b/data/tilesets/secondary/battle_pyramid/anim/1/4.png new file mode 100644 index 000000000..bea921d90 Binary files /dev/null and b/data/tilesets/secondary/battle_pyramid/anim/1/4.png differ diff --git a/data/tilesets/secondary/battle_pyramid/anim/1/5.png b/data/tilesets/secondary/battle_pyramid/anim/1/5.png new file mode 100644 index 000000000..bea921d90 Binary files /dev/null and b/data/tilesets/secondary/battle_pyramid/anim/1/5.png differ diff --git a/data/tilesets/secondary/battle_pyramid/anim/1/6.png b/data/tilesets/secondary/battle_pyramid/anim/1/6.png new file mode 100644 index 000000000..16652df19 Binary files /dev/null and b/data/tilesets/secondary/battle_pyramid/anim/1/6.png differ diff --git a/data/tilesets/secondary/battle_pyramid/anim/1/7.png b/data/tilesets/secondary/battle_pyramid/anim/1/7.png new file mode 100644 index 000000000..8ea7a49e6 Binary files /dev/null and b/data/tilesets/secondary/battle_pyramid/anim/1/7.png differ diff --git a/data/tilesets/secondary/battle_pyramid/anim/1/8.png b/data/tilesets/secondary/battle_pyramid/anim/1/8.png new file mode 100644 index 000000000..2895d3319 Binary files /dev/null and b/data/tilesets/secondary/battle_pyramid/anim/1/8.png differ diff --git a/data/tilesets/secondary/battle_pyramid/anim/1/9.png b/data/tilesets/secondary/battle_pyramid/anim/1/9.png new file mode 100644 index 000000000..63c22acf2 Binary files /dev/null and b/data/tilesets/secondary/battle_pyramid/anim/1/9.png differ diff --git a/data/tilesets/secondary/battle_pyramid/tiles.png b/data/tilesets/secondary/battle_pyramid/tiles.png index cd45ea045..d9609f3dd 100644 Binary files a/data/tilesets/secondary/battle_pyramid/tiles.png and b/data/tilesets/secondary/battle_pyramid/tiles.png differ diff --git a/data/tilesets/secondary/battle_tent/tiles.png b/data/tilesets/secondary/battle_tent/tiles.png index 919e3878f..35e5c4b65 100644 Binary files a/data/tilesets/secondary/battle_tent/tiles.png and b/data/tilesets/secondary/battle_tent/tiles.png differ diff --git a/data/tilesets/secondary/bike_shop/anim/0.png b/data/tilesets/secondary/bike_shop/anim/0.png new file mode 100644 index 000000000..069509b27 Binary files /dev/null and b/data/tilesets/secondary/bike_shop/anim/0.png differ diff --git a/data/tilesets/secondary/bike_shop/anim/1.png b/data/tilesets/secondary/bike_shop/anim/1.png new file mode 100644 index 000000000..4123bb0bf Binary files /dev/null and b/data/tilesets/secondary/bike_shop/anim/1.png differ diff --git a/data/tilesets/secondary/bike_shop/anim/2.png b/data/tilesets/secondary/bike_shop/anim/2.png new file mode 100644 index 000000000..7c463d9c3 Binary files /dev/null and b/data/tilesets/secondary/bike_shop/anim/2.png differ diff --git a/data/tilesets/secondary/bike_shop/tiles.png b/data/tilesets/secondary/bike_shop/tiles.png index ec109c3be..e068538f5 100644 Binary files a/data/tilesets/secondary/bike_shop/tiles.png and b/data/tilesets/secondary/bike_shop/tiles.png differ diff --git a/data/tilesets/secondary/brendans_mays_house/tiles.png b/data/tilesets/secondary/brendans_mays_house/tiles.png index 10163e9f1..6d6a5f047 100644 Binary files a/data/tilesets/secondary/brendans_mays_house/tiles.png and b/data/tilesets/secondary/brendans_mays_house/tiles.png differ diff --git a/data/tilesets/secondary/cable_club/tiles.png b/data/tilesets/secondary/cable_club/tiles.png index 2b153c1f4..c5ad4cfac 100644 Binary files a/data/tilesets/secondary/cable_club/tiles.png and b/data/tilesets/secondary/cable_club/tiles.png differ diff --git a/data/tilesets/secondary/cable_club/unknown_tiles.png b/data/tilesets/secondary/cable_club/unknown_tiles.png index da68cdff2..84e79f720 100644 Binary files a/data/tilesets/secondary/cable_club/unknown_tiles.png and b/data/tilesets/secondary/cable_club/unknown_tiles.png differ diff --git a/data/tilesets/secondary/cave/anim/0.png b/data/tilesets/secondary/cave/anim/0.png new file mode 100644 index 000000000..67f294ffe Binary files /dev/null and b/data/tilesets/secondary/cave/anim/0.png differ diff --git a/data/tilesets/secondary/cave/anim/1.png b/data/tilesets/secondary/cave/anim/1.png new file mode 100644 index 000000000..9c92be807 Binary files /dev/null and b/data/tilesets/secondary/cave/anim/1.png differ diff --git a/data/tilesets/secondary/cave/anim/2.png b/data/tilesets/secondary/cave/anim/2.png new file mode 100644 index 000000000..78ea00e04 Binary files /dev/null and b/data/tilesets/secondary/cave/anim/2.png differ diff --git a/data/tilesets/secondary/cave/anim/3.png b/data/tilesets/secondary/cave/anim/3.png new file mode 100644 index 000000000..7edd52eaa Binary files /dev/null and b/data/tilesets/secondary/cave/anim/3.png differ diff --git a/data/tilesets/secondary/cave/anim/unused/0.png b/data/tilesets/secondary/cave/anim/unused/0.png new file mode 100644 index 000000000..44564e67a Binary files /dev/null and b/data/tilesets/secondary/cave/anim/unused/0.png differ diff --git a/data/tilesets/secondary/cave/anim/unused/1.png b/data/tilesets/secondary/cave/anim/unused/1.png new file mode 100644 index 000000000..47e7e17ee Binary files /dev/null and b/data/tilesets/secondary/cave/anim/unused/1.png differ diff --git a/data/tilesets/secondary/cave/anim/unused/2.png b/data/tilesets/secondary/cave/anim/unused/2.png new file mode 100644 index 000000000..d1447cde2 Binary files /dev/null and b/data/tilesets/secondary/cave/anim/unused/2.png differ diff --git a/data/tilesets/secondary/cave/anim/unused/3.png b/data/tilesets/secondary/cave/anim/unused/3.png new file mode 100644 index 000000000..8ad81b1e1 Binary files /dev/null and b/data/tilesets/secondary/cave/anim/unused/3.png differ diff --git a/data/tilesets/secondary/cave/tiles.png b/data/tilesets/secondary/cave/tiles.png index f905c6b21..e8c98dd71 100644 Binary files a/data/tilesets/secondary/cave/tiles.png and b/data/tilesets/secondary/cave/tiles.png differ diff --git a/data/tilesets/secondary/contest/tiles.png b/data/tilesets/secondary/contest/tiles.png index 09ddee472..710654f5f 100644 Binary files a/data/tilesets/secondary/contest/tiles.png and b/data/tilesets/secondary/contest/tiles.png differ diff --git a/data/tilesets/secondary/dewford/anim/0.png b/data/tilesets/secondary/dewford/anim/0.png new file mode 100644 index 000000000..adf42975f Binary files /dev/null and b/data/tilesets/secondary/dewford/anim/0.png differ diff --git a/data/tilesets/secondary/dewford/anim/1.png b/data/tilesets/secondary/dewford/anim/1.png new file mode 100644 index 000000000..6e7c23a18 Binary files /dev/null and b/data/tilesets/secondary/dewford/anim/1.png differ diff --git a/data/tilesets/secondary/dewford/anim/2.png b/data/tilesets/secondary/dewford/anim/2.png new file mode 100644 index 000000000..86075ffb0 Binary files /dev/null and b/data/tilesets/secondary/dewford/anim/2.png differ diff --git a/data/tilesets/secondary/dewford/anim/3.png b/data/tilesets/secondary/dewford/anim/3.png new file mode 100644 index 000000000..6e3c57621 Binary files /dev/null and b/data/tilesets/secondary/dewford/anim/3.png differ diff --git a/data/tilesets/secondary/dewford/tiles.png b/data/tilesets/secondary/dewford/tiles.png index f79972197..1cf4c165c 100644 Binary files a/data/tilesets/secondary/dewford/tiles.png and b/data/tilesets/secondary/dewford/tiles.png differ diff --git a/data/tilesets/secondary/dewford_gym/tiles.png b/data/tilesets/secondary/dewford_gym/tiles.png index 1dad6f205..7d923b505 100644 Binary files a/data/tilesets/secondary/dewford_gym/tiles.png and b/data/tilesets/secondary/dewford_gym/tiles.png differ diff --git a/data/tilesets/secondary/elite_four/anim/0/0.png b/data/tilesets/secondary/elite_four/anim/0/0.png new file mode 100644 index 000000000..806d26e57 Binary files /dev/null and b/data/tilesets/secondary/elite_four/anim/0/0.png differ diff --git a/data/tilesets/secondary/elite_four/anim/0/1.png b/data/tilesets/secondary/elite_four/anim/0/1.png new file mode 100644 index 000000000..2a8e6a31c Binary files /dev/null and b/data/tilesets/secondary/elite_four/anim/0/1.png differ diff --git a/data/tilesets/secondary/elite_four/anim/0/2.png b/data/tilesets/secondary/elite_four/anim/0/2.png new file mode 100644 index 000000000..c4e6161a6 Binary files /dev/null and b/data/tilesets/secondary/elite_four/anim/0/2.png differ diff --git a/data/tilesets/secondary/elite_four/anim/0/3.png b/data/tilesets/secondary/elite_four/anim/0/3.png new file mode 100644 index 000000000..2a8e6a31c Binary files /dev/null and b/data/tilesets/secondary/elite_four/anim/0/3.png differ diff --git a/data/tilesets/secondary/elite_four/anim/1/0.png b/data/tilesets/secondary/elite_four/anim/1/0.png new file mode 100644 index 000000000..7822d1896 Binary files /dev/null and b/data/tilesets/secondary/elite_four/anim/1/0.png differ diff --git a/data/tilesets/secondary/elite_four/anim/1/1.png b/data/tilesets/secondary/elite_four/anim/1/1.png new file mode 100644 index 000000000..66d60e90b Binary files /dev/null and b/data/tilesets/secondary/elite_four/anim/1/1.png differ diff --git a/data/tilesets/secondary/elite_four/anim/1/2.png b/data/tilesets/secondary/elite_four/anim/1/2.png new file mode 100644 index 000000000..09fb59fbf Binary files /dev/null and b/data/tilesets/secondary/elite_four/anim/1/2.png differ diff --git a/data/tilesets/secondary/elite_four/anim/1/3.png b/data/tilesets/secondary/elite_four/anim/1/3.png new file mode 100644 index 000000000..0c7c05034 Binary files /dev/null and b/data/tilesets/secondary/elite_four/anim/1/3.png differ diff --git a/data/tilesets/secondary/elite_four/anim/1/4.png b/data/tilesets/secondary/elite_four/anim/1/4.png new file mode 100644 index 000000000..317db1714 Binary files /dev/null and b/data/tilesets/secondary/elite_four/anim/1/4.png differ diff --git a/data/tilesets/secondary/elite_four/anim/1/5.png b/data/tilesets/secondary/elite_four/anim/1/5.png new file mode 100644 index 000000000..d0cbfeb57 Binary files /dev/null and b/data/tilesets/secondary/elite_four/anim/1/5.png differ diff --git a/data/tilesets/secondary/elite_four/anim/1/6.png b/data/tilesets/secondary/elite_four/anim/1/6.png new file mode 100644 index 000000000..4b35ededd Binary files /dev/null and b/data/tilesets/secondary/elite_four/anim/1/6.png differ diff --git a/data/tilesets/secondary/elite_four/anim/1/7.png b/data/tilesets/secondary/elite_four/anim/1/7.png new file mode 100644 index 000000000..dfe698edb Binary files /dev/null and b/data/tilesets/secondary/elite_four/anim/1/7.png differ diff --git a/data/tilesets/secondary/elite_four/tiles.png b/data/tilesets/secondary/elite_four/tiles.png index 834be3701..d16b2db03 100644 Binary files a/data/tilesets/secondary/elite_four/tiles.png and b/data/tilesets/secondary/elite_four/tiles.png differ diff --git a/data/tilesets/secondary/ever_grande/anim/0.png b/data/tilesets/secondary/ever_grande/anim/0.png new file mode 100644 index 000000000..7536d08ad Binary files /dev/null and b/data/tilesets/secondary/ever_grande/anim/0.png differ diff --git a/data/tilesets/secondary/ever_grande/anim/1.png b/data/tilesets/secondary/ever_grande/anim/1.png new file mode 100644 index 000000000..7536d08ad Binary files /dev/null and b/data/tilesets/secondary/ever_grande/anim/1.png differ diff --git a/data/tilesets/secondary/ever_grande/anim/2.png b/data/tilesets/secondary/ever_grande/anim/2.png new file mode 100644 index 000000000..f0835aa3b Binary files /dev/null and b/data/tilesets/secondary/ever_grande/anim/2.png differ diff --git a/data/tilesets/secondary/ever_grande/anim/3.png b/data/tilesets/secondary/ever_grande/anim/3.png new file mode 100644 index 000000000..c07cbbd17 Binary files /dev/null and b/data/tilesets/secondary/ever_grande/anim/3.png differ diff --git a/data/tilesets/secondary/ever_grande/anim/4.png b/data/tilesets/secondary/ever_grande/anim/4.png new file mode 100644 index 000000000..7536d08ad Binary files /dev/null and b/data/tilesets/secondary/ever_grande/anim/4.png differ diff --git a/data/tilesets/secondary/ever_grande/anim/5.png b/data/tilesets/secondary/ever_grande/anim/5.png new file mode 100644 index 000000000..7536d08ad Binary files /dev/null and b/data/tilesets/secondary/ever_grande/anim/5.png differ diff --git a/data/tilesets/secondary/ever_grande/anim/6.png b/data/tilesets/secondary/ever_grande/anim/6.png new file mode 100644 index 000000000..9b5030306 Binary files /dev/null and b/data/tilesets/secondary/ever_grande/anim/6.png differ diff --git a/data/tilesets/secondary/ever_grande/anim/7.png b/data/tilesets/secondary/ever_grande/anim/7.png new file mode 100644 index 000000000..9b5030306 Binary files /dev/null and b/data/tilesets/secondary/ever_grande/anim/7.png differ diff --git a/data/tilesets/secondary/ever_grande/tiles.png b/data/tilesets/secondary/ever_grande/tiles.png index 0f3689c24..943a3f8f4 100644 Binary files a/data/tilesets/secondary/ever_grande/tiles.png and b/data/tilesets/secondary/ever_grande/tiles.png differ diff --git a/data/tilesets/secondary/facility/tiles.png b/data/tilesets/secondary/facility/tiles.png index 5585dee3b..f99c24150 100644 Binary files a/data/tilesets/secondary/facility/tiles.png and b/data/tilesets/secondary/facility/tiles.png differ diff --git a/data/tilesets/secondary/fallarbor/tiles.png b/data/tilesets/secondary/fallarbor/tiles.png index 4c5d72277..21ab321ef 100644 Binary files a/data/tilesets/secondary/fallarbor/tiles.png and b/data/tilesets/secondary/fallarbor/tiles.png differ diff --git a/data/tilesets/secondary/fortree/tiles.png b/data/tilesets/secondary/fortree/tiles.png index 0875d1d47..78cb1c1ae 100644 Binary files a/data/tilesets/secondary/fortree/tiles.png and b/data/tilesets/secondary/fortree/tiles.png differ diff --git a/data/tilesets/secondary/fortree_gym/tiles.png b/data/tilesets/secondary/fortree_gym/tiles.png index bb16dd0ca..932b5c06a 100644 Binary files a/data/tilesets/secondary/fortree_gym/tiles.png and b/data/tilesets/secondary/fortree_gym/tiles.png differ diff --git a/data/tilesets/secondary/generic_building/tiles.png b/data/tilesets/secondary/generic_building/tiles.png index d94085b06..6f681f837 100644 Binary files a/data/tilesets/secondary/generic_building/tiles.png and b/data/tilesets/secondary/generic_building/tiles.png differ diff --git a/data/tilesets/secondary/inside_of_truck/tiles.png b/data/tilesets/secondary/inside_of_truck/tiles.png index 44f923a5a..65a82e888 100644 Binary files a/data/tilesets/secondary/inside_of_truck/tiles.png and b/data/tilesets/secondary/inside_of_truck/tiles.png differ diff --git a/data/tilesets/secondary/inside_ship/tiles.png b/data/tilesets/secondary/inside_ship/tiles.png index d4b0471b2..77142a755 100644 Binary files a/data/tilesets/secondary/inside_ship/tiles.png and b/data/tilesets/secondary/inside_ship/tiles.png differ diff --git a/data/tilesets/secondary/island_harbor/tiles.png b/data/tilesets/secondary/island_harbor/tiles.png index e70a72977..82e419e72 100644 Binary files a/data/tilesets/secondary/island_harbor/tiles.png and b/data/tilesets/secondary/island_harbor/tiles.png differ diff --git a/data/tilesets/secondary/lab/tiles.png b/data/tilesets/secondary/lab/tiles.png index c2a86a73d..6a213d960 100644 Binary files a/data/tilesets/secondary/lab/tiles.png and b/data/tilesets/secondary/lab/tiles.png differ diff --git a/data/tilesets/secondary/lavaridge/anim/0.png b/data/tilesets/secondary/lavaridge/anim/0.png new file mode 100644 index 000000000..303855f71 Binary files /dev/null and b/data/tilesets/secondary/lavaridge/anim/0.png differ diff --git a/data/tilesets/secondary/lavaridge/anim/1.png b/data/tilesets/secondary/lavaridge/anim/1.png new file mode 100644 index 000000000..7cdee79e2 Binary files /dev/null and b/data/tilesets/secondary/lavaridge/anim/1.png differ diff --git a/data/tilesets/secondary/lavaridge/anim/2.png b/data/tilesets/secondary/lavaridge/anim/2.png new file mode 100644 index 000000000..b5810b806 Binary files /dev/null and b/data/tilesets/secondary/lavaridge/anim/2.png differ diff --git a/data/tilesets/secondary/lavaridge/anim/3.png b/data/tilesets/secondary/lavaridge/anim/3.png new file mode 100644 index 000000000..caf7b5698 Binary files /dev/null and b/data/tilesets/secondary/lavaridge/anim/3.png differ diff --git a/data/tilesets/secondary/lavaridge/tiles.png b/data/tilesets/secondary/lavaridge/tiles.png index 4886aa28e..896c43194 100644 Binary files a/data/tilesets/secondary/lavaridge/tiles.png and b/data/tilesets/secondary/lavaridge/tiles.png differ diff --git a/data/tilesets/secondary/lavaridge_gym/tiles.png b/data/tilesets/secondary/lavaridge_gym/tiles.png index 0865ea207..8734cc3bf 100644 Binary files a/data/tilesets/secondary/lavaridge_gym/tiles.png and b/data/tilesets/secondary/lavaridge_gym/tiles.png differ diff --git a/data/tilesets/secondary/lilycove/tiles.png b/data/tilesets/secondary/lilycove/tiles.png index 88c5c7a28..b77f3d379 100644 Binary files a/data/tilesets/secondary/lilycove/tiles.png and b/data/tilesets/secondary/lilycove/tiles.png differ diff --git a/data/tilesets/secondary/lilycove_museum/tiles.png b/data/tilesets/secondary/lilycove_museum/tiles.png index 495187301..5bcc0ecfe 100644 Binary files a/data/tilesets/secondary/lilycove_museum/tiles.png and b/data/tilesets/secondary/lilycove_museum/tiles.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/a/0.png b/data/tilesets/secondary/mauville/anim/0/a/0.png new file mode 100644 index 000000000..88b028b52 Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/a/0.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/a/1.png b/data/tilesets/secondary/mauville/anim/0/a/1.png new file mode 100644 index 000000000..ce4010db2 Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/a/1.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/a/2.png b/data/tilesets/secondary/mauville/anim/0/a/2.png new file mode 100644 index 000000000..5ea20f6db Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/a/2.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/a/3.png b/data/tilesets/secondary/mauville/anim/0/a/3.png new file mode 100644 index 000000000..fdf4d30bf Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/a/3.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/a/4.png b/data/tilesets/secondary/mauville/anim/0/a/4.png new file mode 100644 index 000000000..c8097808c Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/a/4.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/a/5.png b/data/tilesets/secondary/mauville/anim/0/a/5.png new file mode 100644 index 000000000..88b028b52 Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/a/5.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/a/6.png b/data/tilesets/secondary/mauville/anim/0/a/6.png new file mode 100644 index 000000000..ce4010db2 Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/a/6.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/a/7.png b/data/tilesets/secondary/mauville/anim/0/a/7.png new file mode 100644 index 000000000..5ea20f6db Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/a/7.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/a/8.png b/data/tilesets/secondary/mauville/anim/0/a/8.png new file mode 100644 index 000000000..fdf4d30bf Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/a/8.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/a/9.png b/data/tilesets/secondary/mauville/anim/0/a/9.png new file mode 100644 index 000000000..c8097808c Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/a/9.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/b/0.png b/data/tilesets/secondary/mauville/anim/0/b/0.png new file mode 100644 index 000000000..88b028b52 Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/b/0.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/b/1.png b/data/tilesets/secondary/mauville/anim/0/b/1.png new file mode 100644 index 000000000..ce4010db2 Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/b/1.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/b/2.png b/data/tilesets/secondary/mauville/anim/0/b/2.png new file mode 100644 index 000000000..5ea20f6db Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/b/2.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/b/3.png b/data/tilesets/secondary/mauville/anim/0/b/3.png new file mode 100644 index 000000000..fdf4d30bf Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/b/3.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/b/4.png b/data/tilesets/secondary/mauville/anim/0/b/4.png new file mode 100644 index 000000000..91f368cf8 Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/b/4.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/b/5.png b/data/tilesets/secondary/mauville/anim/0/b/5.png new file mode 100644 index 000000000..91f368cf8 Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/b/5.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/b/6.png b/data/tilesets/secondary/mauville/anim/0/b/6.png new file mode 100644 index 000000000..91f368cf8 Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/b/6.png differ diff --git a/data/tilesets/secondary/mauville/anim/0/b/7.png b/data/tilesets/secondary/mauville/anim/0/b/7.png new file mode 100644 index 000000000..91f368cf8 Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/0/b/7.png differ diff --git a/data/tilesets/secondary/mauville/anim/1/a/0.png b/data/tilesets/secondary/mauville/anim/1/a/0.png new file mode 100644 index 000000000..88b028b52 Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/1/a/0.png differ diff --git a/data/tilesets/secondary/mauville/anim/1/a/1.png b/data/tilesets/secondary/mauville/anim/1/a/1.png new file mode 100644 index 000000000..c8097808c Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/1/a/1.png differ diff --git a/data/tilesets/secondary/mauville/anim/1/a/2.png b/data/tilesets/secondary/mauville/anim/1/a/2.png new file mode 100644 index 000000000..5ea20f6db Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/1/a/2.png differ diff --git a/data/tilesets/secondary/mauville/anim/1/a/3.png b/data/tilesets/secondary/mauville/anim/1/a/3.png new file mode 100644 index 000000000..fdf4d30bf Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/1/a/3.png differ diff --git a/data/tilesets/secondary/mauville/anim/1/b/0.png b/data/tilesets/secondary/mauville/anim/1/b/0.png new file mode 100644 index 000000000..88b028b52 Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/1/b/0.png differ diff --git a/data/tilesets/secondary/mauville/anim/1/b/1.png b/data/tilesets/secondary/mauville/anim/1/b/1.png new file mode 100644 index 000000000..c8097808c Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/1/b/1.png differ diff --git a/data/tilesets/secondary/mauville/anim/1/b/2.png b/data/tilesets/secondary/mauville/anim/1/b/2.png new file mode 100644 index 000000000..5ea20f6db Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/1/b/2.png differ diff --git a/data/tilesets/secondary/mauville/anim/1/b/3.png b/data/tilesets/secondary/mauville/anim/1/b/3.png new file mode 100644 index 000000000..fdf4d30bf Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/1/b/3.png differ diff --git a/data/tilesets/secondary/mauville/anim/1/b/4.png b/data/tilesets/secondary/mauville/anim/1/b/4.png new file mode 100644 index 000000000..44564e67a Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/1/b/4.png differ diff --git a/data/tilesets/secondary/mauville/anim/1/b/5.png b/data/tilesets/secondary/mauville/anim/1/b/5.png new file mode 100644 index 000000000..47e7e17ee Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/1/b/5.png differ diff --git a/data/tilesets/secondary/mauville/anim/1/b/6.png b/data/tilesets/secondary/mauville/anim/1/b/6.png new file mode 100644 index 000000000..d1447cde2 Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/1/b/6.png differ diff --git a/data/tilesets/secondary/mauville/anim/1/b/7.png b/data/tilesets/secondary/mauville/anim/1/b/7.png new file mode 100644 index 000000000..8ad81b1e1 Binary files /dev/null and b/data/tilesets/secondary/mauville/anim/1/b/7.png differ diff --git a/data/tilesets/secondary/mauville/tiles.png b/data/tilesets/secondary/mauville/tiles.png index a015fe5b4..e4ce0d4f8 100644 Binary files a/data/tilesets/secondary/mauville/tiles.png and b/data/tilesets/secondary/mauville/tiles.png differ diff --git a/data/tilesets/secondary/mauville_game_corner/tiles.png b/data/tilesets/secondary/mauville_game_corner/tiles.png index c8f0dd1ee..3f7f565c9 100644 Binary files a/data/tilesets/secondary/mauville_game_corner/tiles.png and b/data/tilesets/secondary/mauville_game_corner/tiles.png differ diff --git a/data/tilesets/secondary/mauville_gym/anim/0.png b/data/tilesets/secondary/mauville_gym/anim/0.png new file mode 100644 index 000000000..090fe6a1a Binary files /dev/null and b/data/tilesets/secondary/mauville_gym/anim/0.png differ diff --git a/data/tilesets/secondary/mauville_gym/anim/1.png b/data/tilesets/secondary/mauville_gym/anim/1.png new file mode 100644 index 000000000..48f325890 Binary files /dev/null and b/data/tilesets/secondary/mauville_gym/anim/1.png differ diff --git a/data/tilesets/secondary/mauville_gym/anim/2.png b/data/tilesets/secondary/mauville_gym/anim/2.png new file mode 100644 index 000000000..16652df19 Binary files /dev/null and b/data/tilesets/secondary/mauville_gym/anim/2.png differ diff --git a/data/tilesets/secondary/mauville_gym/anim/3.png b/data/tilesets/secondary/mauville_gym/anim/3.png new file mode 100644 index 000000000..8ea7a49e6 Binary files /dev/null and b/data/tilesets/secondary/mauville_gym/anim/3.png differ diff --git a/data/tilesets/secondary/mauville_gym/tiles.png b/data/tilesets/secondary/mauville_gym/tiles.png index d710d2e40..5606bb101 100644 Binary files a/data/tilesets/secondary/mauville_gym/tiles.png and b/data/tilesets/secondary/mauville_gym/tiles.png differ diff --git a/data/tilesets/secondary/meteor_falls/tiles.png b/data/tilesets/secondary/meteor_falls/tiles.png index 5b0342f9b..9c7532805 100644 Binary files a/data/tilesets/secondary/meteor_falls/tiles.png and b/data/tilesets/secondary/meteor_falls/tiles.png differ diff --git a/data/tilesets/secondary/mirage_tower/tiles.png b/data/tilesets/secondary/mirage_tower/tiles.png index 8eab57f93..fd2904ca1 100644 Binary files a/data/tilesets/secondary/mirage_tower/tiles.png and b/data/tilesets/secondary/mirage_tower/tiles.png differ diff --git a/data/tilesets/secondary/mossdeep/tiles.png b/data/tilesets/secondary/mossdeep/tiles.png index 1933b8983..818406b23 100644 Binary files a/data/tilesets/secondary/mossdeep/tiles.png and b/data/tilesets/secondary/mossdeep/tiles.png differ diff --git a/data/tilesets/secondary/mossdeep_game_corner/tiles.png b/data/tilesets/secondary/mossdeep_game_corner/tiles.png index 379c4f42f..f09edf436 100644 Binary files a/data/tilesets/secondary/mossdeep_game_corner/tiles.png and b/data/tilesets/secondary/mossdeep_game_corner/tiles.png differ diff --git a/data/tilesets/secondary/mossdeep_gym/tiles.png b/data/tilesets/secondary/mossdeep_gym/tiles.png index 919d0334e..36a0873a4 100644 Binary files a/data/tilesets/secondary/mossdeep_gym/tiles.png and b/data/tilesets/secondary/mossdeep_gym/tiles.png differ diff --git a/data/tilesets/secondary/mystery_events_house/tiles.png b/data/tilesets/secondary/mystery_events_house/tiles.png index 1f5f8639b..5afa07fcf 100644 Binary files a/data/tilesets/secondary/mystery_events_house/tiles.png and b/data/tilesets/secondary/mystery_events_house/tiles.png differ diff --git a/data/tilesets/secondary/navel_rock/tiles.png b/data/tilesets/secondary/navel_rock/tiles.png index 06d8065f1..ffbc04584 100644 Binary files a/data/tilesets/secondary/navel_rock/tiles.png and b/data/tilesets/secondary/navel_rock/tiles.png differ diff --git a/data/tilesets/secondary/oceanic_museum/tiles.png b/data/tilesets/secondary/oceanic_museum/tiles.png index 25a20d586..a074d4a05 100644 Binary files a/data/tilesets/secondary/oceanic_museum/tiles.png and b/data/tilesets/secondary/oceanic_museum/tiles.png differ diff --git a/data/tilesets/secondary/pacifidlog/anim/0/0.png b/data/tilesets/secondary/pacifidlog/anim/0/0.png new file mode 100644 index 000000000..e7bcfd743 Binary files /dev/null and b/data/tilesets/secondary/pacifidlog/anim/0/0.png differ diff --git a/data/tilesets/secondary/pacifidlog/anim/0/1.png b/data/tilesets/secondary/pacifidlog/anim/0/1.png new file mode 100644 index 000000000..dde024f6e Binary files /dev/null and b/data/tilesets/secondary/pacifidlog/anim/0/1.png differ diff --git a/data/tilesets/secondary/pacifidlog/anim/0/2.png b/data/tilesets/secondary/pacifidlog/anim/0/2.png new file mode 100644 index 000000000..1a4cea24d Binary files /dev/null and b/data/tilesets/secondary/pacifidlog/anim/0/2.png differ diff --git a/data/tilesets/secondary/pacifidlog/anim/1/0.png b/data/tilesets/secondary/pacifidlog/anim/1/0.png new file mode 100644 index 000000000..beb8ee82d Binary files /dev/null and b/data/tilesets/secondary/pacifidlog/anim/1/0.png differ diff --git a/data/tilesets/secondary/pacifidlog/anim/1/1.png b/data/tilesets/secondary/pacifidlog/anim/1/1.png new file mode 100644 index 000000000..594655120 Binary files /dev/null and b/data/tilesets/secondary/pacifidlog/anim/1/1.png differ diff --git a/data/tilesets/secondary/pacifidlog/anim/1/2.png b/data/tilesets/secondary/pacifidlog/anim/1/2.png new file mode 100644 index 000000000..747306d5c Binary files /dev/null and b/data/tilesets/secondary/pacifidlog/anim/1/2.png differ diff --git a/data/tilesets/secondary/pacifidlog/anim/1/3.png b/data/tilesets/secondary/pacifidlog/anim/1/3.png new file mode 100644 index 000000000..20e0a7cdd Binary files /dev/null and b/data/tilesets/secondary/pacifidlog/anim/1/3.png differ diff --git a/data/tilesets/secondary/pacifidlog/anim/1/4.png b/data/tilesets/secondary/pacifidlog/anim/1/4.png new file mode 100644 index 000000000..7b74ee349 Binary files /dev/null and b/data/tilesets/secondary/pacifidlog/anim/1/4.png differ diff --git a/data/tilesets/secondary/pacifidlog/anim/1/5.png b/data/tilesets/secondary/pacifidlog/anim/1/5.png new file mode 100644 index 000000000..b135bdfbe Binary files /dev/null and b/data/tilesets/secondary/pacifidlog/anim/1/5.png differ diff --git a/data/tilesets/secondary/pacifidlog/anim/1/6.png b/data/tilesets/secondary/pacifidlog/anim/1/6.png new file mode 100644 index 000000000..4eae151e6 Binary files /dev/null and b/data/tilesets/secondary/pacifidlog/anim/1/6.png differ diff --git a/data/tilesets/secondary/pacifidlog/anim/1/7.png b/data/tilesets/secondary/pacifidlog/anim/1/7.png new file mode 100644 index 000000000..f1863fdd5 Binary files /dev/null and b/data/tilesets/secondary/pacifidlog/anim/1/7.png differ diff --git a/data/tilesets/secondary/pacifidlog/tiles.png b/data/tilesets/secondary/pacifidlog/tiles.png index 496232735..94fe6d96b 100644 Binary files a/data/tilesets/secondary/pacifidlog/tiles.png and b/data/tilesets/secondary/pacifidlog/tiles.png differ diff --git a/data/tilesets/secondary/petalburg/tiles.png b/data/tilesets/secondary/petalburg/tiles.png index 97e8bf187..dd0e23ca4 100644 Binary files a/data/tilesets/secondary/petalburg/tiles.png and b/data/tilesets/secondary/petalburg/tiles.png differ diff --git a/data/tilesets/secondary/petalburg_gym/tiles.png b/data/tilesets/secondary/petalburg_gym/tiles.png index 8c996f701..cb7c40e5a 100644 Binary files a/data/tilesets/secondary/petalburg_gym/tiles.png and b/data/tilesets/secondary/petalburg_gym/tiles.png differ diff --git a/data/tilesets/secondary/pokemon_center/tiles.png b/data/tilesets/secondary/pokemon_center/tiles.png index 826da07bf..673746c5a 100644 Binary files a/data/tilesets/secondary/pokemon_center/tiles.png and b/data/tilesets/secondary/pokemon_center/tiles.png differ diff --git a/data/tilesets/secondary/pokemon_day_care/tiles.png b/data/tilesets/secondary/pokemon_day_care/tiles.png index eab49af32..76cd9ab96 100644 Binary files a/data/tilesets/secondary/pokemon_day_care/tiles.png and b/data/tilesets/secondary/pokemon_day_care/tiles.png differ diff --git a/data/tilesets/secondary/pokemon_fan_club/tiles.png b/data/tilesets/secondary/pokemon_fan_club/tiles.png index 2714292f0..62dd0f03f 100644 Binary files a/data/tilesets/secondary/pokemon_fan_club/tiles.png and b/data/tilesets/secondary/pokemon_fan_club/tiles.png differ diff --git a/data/tilesets/secondary/pokemon_school/tiles.png b/data/tilesets/secondary/pokemon_school/tiles.png index 3c8c4dffe..20e3f32c8 100644 Binary files a/data/tilesets/secondary/pokemon_school/tiles.png and b/data/tilesets/secondary/pokemon_school/tiles.png differ diff --git a/data/tilesets/secondary/pretty_petal_flower_shop/tiles.png b/data/tilesets/secondary/pretty_petal_flower_shop/tiles.png index 7a9e44935..f10306e7a 100644 Binary files a/data/tilesets/secondary/pretty_petal_flower_shop/tiles.png and b/data/tilesets/secondary/pretty_petal_flower_shop/tiles.png differ diff --git a/data/tilesets/secondary/rustboro/anim/0/0.png b/data/tilesets/secondary/rustboro/anim/0/0.png new file mode 100644 index 000000000..358745e4b Binary files /dev/null and b/data/tilesets/secondary/rustboro/anim/0/0.png differ diff --git a/data/tilesets/secondary/rustboro/anim/0/1.png b/data/tilesets/secondary/rustboro/anim/0/1.png new file mode 100644 index 000000000..f5a095b15 Binary files /dev/null and b/data/tilesets/secondary/rustboro/anim/0/1.png differ diff --git a/data/tilesets/secondary/rustboro/anim/0/2.png b/data/tilesets/secondary/rustboro/anim/0/2.png new file mode 100644 index 000000000..91f368cf8 Binary files /dev/null and b/data/tilesets/secondary/rustboro/anim/0/2.png differ diff --git a/data/tilesets/secondary/rustboro/anim/0/3.png b/data/tilesets/secondary/rustboro/anim/0/3.png new file mode 100644 index 000000000..91f368cf8 Binary files /dev/null and b/data/tilesets/secondary/rustboro/anim/0/3.png differ diff --git a/data/tilesets/secondary/rustboro/anim/0/4.png b/data/tilesets/secondary/rustboro/anim/0/4.png new file mode 100644 index 000000000..91f368cf8 Binary files /dev/null and b/data/tilesets/secondary/rustboro/anim/0/4.png differ diff --git a/data/tilesets/secondary/rustboro/anim/0/5.png b/data/tilesets/secondary/rustboro/anim/0/5.png new file mode 100644 index 000000000..91f368cf8 Binary files /dev/null and b/data/tilesets/secondary/rustboro/anim/0/5.png differ diff --git a/data/tilesets/secondary/rustboro/anim/0/6.png b/data/tilesets/secondary/rustboro/anim/0/6.png new file mode 100644 index 000000000..91f368cf8 Binary files /dev/null and b/data/tilesets/secondary/rustboro/anim/0/6.png differ diff --git a/data/tilesets/secondary/rustboro/anim/0/7.png b/data/tilesets/secondary/rustboro/anim/0/7.png new file mode 100644 index 000000000..91f368cf8 Binary files /dev/null and b/data/tilesets/secondary/rustboro/anim/0/7.png differ diff --git a/data/tilesets/secondary/rustboro/anim/1/0.png b/data/tilesets/secondary/rustboro/anim/1/0.png new file mode 100644 index 000000000..75bd2f8a4 Binary files /dev/null and b/data/tilesets/secondary/rustboro/anim/1/0.png differ diff --git a/data/tilesets/secondary/rustboro/anim/1/1.png b/data/tilesets/secondary/rustboro/anim/1/1.png new file mode 100644 index 000000000..9f8b3a02f Binary files /dev/null and b/data/tilesets/secondary/rustboro/anim/1/1.png differ diff --git a/data/tilesets/secondary/rustboro/anim/1/2.png b/data/tilesets/secondary/rustboro/anim/1/2.png new file mode 100644 index 000000000..86075ffb0 Binary files /dev/null and b/data/tilesets/secondary/rustboro/anim/1/2.png differ diff --git a/data/tilesets/secondary/rustboro/anim/1/3.png b/data/tilesets/secondary/rustboro/anim/1/3.png new file mode 100644 index 000000000..6e3c57621 Binary files /dev/null and b/data/tilesets/secondary/rustboro/anim/1/3.png differ diff --git a/data/tilesets/secondary/rustboro/tiles.png b/data/tilesets/secondary/rustboro/tiles.png index 8cea2a4d9..fbfc72d46 100644 Binary files a/data/tilesets/secondary/rustboro/tiles.png and b/data/tilesets/secondary/rustboro/tiles.png differ diff --git a/data/tilesets/secondary/rustboro_gym/tiles.png b/data/tilesets/secondary/rustboro_gym/tiles.png index bfdc07c07..d4ebc14a1 100644 Binary files a/data/tilesets/secondary/rustboro_gym/tiles.png and b/data/tilesets/secondary/rustboro_gym/tiles.png differ diff --git a/data/tilesets/secondary/rusturf_tunnel/tiles.png b/data/tilesets/secondary/rusturf_tunnel/tiles.png index dc947bcc5..913935f77 100644 Binary files a/data/tilesets/secondary/rusturf_tunnel/tiles.png and b/data/tilesets/secondary/rusturf_tunnel/tiles.png differ diff --git a/data/tilesets/secondary/seashore_house/tiles.png b/data/tilesets/secondary/seashore_house/tiles.png index 695f83037..ea48f5006 100644 Binary files a/data/tilesets/secondary/seashore_house/tiles.png and b/data/tilesets/secondary/seashore_house/tiles.png differ diff --git a/data/tilesets/secondary/secret_base/blue_cave/tiles.png b/data/tilesets/secondary/secret_base/blue_cave/tiles.png index 207e8d845..9d820463b 100644 Binary files a/data/tilesets/secondary/secret_base/blue_cave/tiles.png and b/data/tilesets/secondary/secret_base/blue_cave/tiles.png differ diff --git a/data/tilesets/secondary/secret_base/blue_cave/unused_tiles.png b/data/tilesets/secondary/secret_base/blue_cave/unused_tiles.png new file mode 100644 index 000000000..1e42fed54 Binary files /dev/null and b/data/tilesets/secondary/secret_base/blue_cave/unused_tiles.png differ diff --git a/data/tilesets/secondary/secret_base/brown_cave/tiles.png b/data/tilesets/secondary/secret_base/brown_cave/tiles.png index 7888f8cc2..a1c8bfe72 100644 Binary files a/data/tilesets/secondary/secret_base/brown_cave/tiles.png and b/data/tilesets/secondary/secret_base/brown_cave/tiles.png differ diff --git a/data/tilesets/secondary/secret_base/brown_cave/unused_tiles.png b/data/tilesets/secondary/secret_base/brown_cave/unused_tiles.png new file mode 100644 index 000000000..dfd187d51 Binary files /dev/null and b/data/tilesets/secondary/secret_base/brown_cave/unused_tiles.png differ diff --git a/data/tilesets/secondary/secret_base/red_cave/tiles.png b/data/tilesets/secondary/secret_base/red_cave/tiles.png index 5c21865e2..2652f6bbf 100644 Binary files a/data/tilesets/secondary/secret_base/red_cave/tiles.png and b/data/tilesets/secondary/secret_base/red_cave/tiles.png differ diff --git a/data/tilesets/secondary/secret_base/red_cave/unused_tiles.png b/data/tilesets/secondary/secret_base/red_cave/unused_tiles.png new file mode 100644 index 000000000..5cfebd309 Binary files /dev/null and b/data/tilesets/secondary/secret_base/red_cave/unused_tiles.png differ diff --git a/data/tilesets/secondary/secret_base/shrub/tiles.png b/data/tilesets/secondary/secret_base/shrub/tiles.png index 2e0a6d028..692141b04 100644 Binary files a/data/tilesets/secondary/secret_base/shrub/tiles.png and b/data/tilesets/secondary/secret_base/shrub/tiles.png differ diff --git a/data/tilesets/secondary/secret_base/shrub/unused_tiles.png b/data/tilesets/secondary/secret_base/shrub/unused_tiles.png new file mode 100644 index 000000000..461d620ae Binary files /dev/null and b/data/tilesets/secondary/secret_base/shrub/unused_tiles.png differ diff --git a/data/tilesets/secondary/secret_base/tree/tiles.png b/data/tilesets/secondary/secret_base/tree/tiles.png index 83ddd6144..94887cc1f 100644 Binary files a/data/tilesets/secondary/secret_base/tree/tiles.png and b/data/tilesets/secondary/secret_base/tree/tiles.png differ diff --git a/data/tilesets/secondary/secret_base/tree/unused_tiles.png b/data/tilesets/secondary/secret_base/tree/unused_tiles.png new file mode 100644 index 000000000..567cf7800 Binary files /dev/null and b/data/tilesets/secondary/secret_base/tree/unused_tiles.png differ diff --git a/data/tilesets/secondary/secret_base/yellow_cave/tiles.png b/data/tilesets/secondary/secret_base/yellow_cave/tiles.png index e8386a804..b171b5ec6 100644 Binary files a/data/tilesets/secondary/secret_base/yellow_cave/tiles.png and b/data/tilesets/secondary/secret_base/yellow_cave/tiles.png differ diff --git a/data/tilesets/secondary/secret_base/yellow_cave/unused_tiles.png b/data/tilesets/secondary/secret_base/yellow_cave/unused_tiles.png new file mode 100644 index 000000000..f825201cc Binary files /dev/null and b/data/tilesets/secondary/secret_base/yellow_cave/unused_tiles.png differ diff --git a/data/tilesets/secondary/shop/tiles.png b/data/tilesets/secondary/shop/tiles.png index 31e3c5319..f253a2e53 100644 Binary files a/data/tilesets/secondary/shop/tiles.png and b/data/tilesets/secondary/shop/tiles.png differ diff --git a/data/tilesets/secondary/slateport/anim/0.png b/data/tilesets/secondary/slateport/anim/0.png new file mode 100644 index 000000000..ef62c4143 Binary files /dev/null and b/data/tilesets/secondary/slateport/anim/0.png differ diff --git a/data/tilesets/secondary/slateport/anim/1.png b/data/tilesets/secondary/slateport/anim/1.png new file mode 100644 index 000000000..9b926bdfc Binary files /dev/null and b/data/tilesets/secondary/slateport/anim/1.png differ diff --git a/data/tilesets/secondary/slateport/anim/2.png b/data/tilesets/secondary/slateport/anim/2.png new file mode 100644 index 000000000..c5974f105 Binary files /dev/null and b/data/tilesets/secondary/slateport/anim/2.png differ diff --git a/data/tilesets/secondary/slateport/anim/3.png b/data/tilesets/secondary/slateport/anim/3.png new file mode 100644 index 000000000..9b926bdfc Binary files /dev/null and b/data/tilesets/secondary/slateport/anim/3.png differ diff --git a/data/tilesets/secondary/slateport/tiles.png b/data/tilesets/secondary/slateport/tiles.png index f89ca2b0c..d8661b99a 100644 Binary files a/data/tilesets/secondary/slateport/tiles.png and b/data/tilesets/secondary/slateport/tiles.png differ diff --git a/data/tilesets/secondary/sootopolis/anim/0.png b/data/tilesets/secondary/sootopolis/anim/0.png new file mode 100644 index 000000000..63f97ad47 Binary files /dev/null and b/data/tilesets/secondary/sootopolis/anim/0.png differ diff --git a/data/tilesets/secondary/sootopolis/anim/1.png b/data/tilesets/secondary/sootopolis/anim/1.png new file mode 100644 index 000000000..aa14ec04a Binary files /dev/null and b/data/tilesets/secondary/sootopolis/anim/1.png differ diff --git a/data/tilesets/secondary/sootopolis/anim/2.png b/data/tilesets/secondary/sootopolis/anim/2.png new file mode 100644 index 000000000..09fb59fbf Binary files /dev/null and b/data/tilesets/secondary/sootopolis/anim/2.png differ diff --git a/data/tilesets/secondary/sootopolis/anim/3.png b/data/tilesets/secondary/sootopolis/anim/3.png new file mode 100644 index 000000000..0c7c05034 Binary files /dev/null and b/data/tilesets/secondary/sootopolis/anim/3.png differ diff --git a/data/tilesets/secondary/sootopolis/anim/4.png b/data/tilesets/secondary/sootopolis/anim/4.png new file mode 100644 index 000000000..317db1714 Binary files /dev/null and b/data/tilesets/secondary/sootopolis/anim/4.png differ diff --git a/data/tilesets/secondary/sootopolis/anim/5.png b/data/tilesets/secondary/sootopolis/anim/5.png new file mode 100644 index 000000000..d0cbfeb57 Binary files /dev/null and b/data/tilesets/secondary/sootopolis/anim/5.png differ diff --git a/data/tilesets/secondary/sootopolis/anim/6.png b/data/tilesets/secondary/sootopolis/anim/6.png new file mode 100644 index 000000000..4b35ededd Binary files /dev/null and b/data/tilesets/secondary/sootopolis/anim/6.png differ diff --git a/data/tilesets/secondary/sootopolis/anim/7.png b/data/tilesets/secondary/sootopolis/anim/7.png new file mode 100644 index 000000000..dfe698edb Binary files /dev/null and b/data/tilesets/secondary/sootopolis/anim/7.png differ diff --git a/data/tilesets/secondary/sootopolis/tiles.png b/data/tilesets/secondary/sootopolis/tiles.png index 5e9866821..92df774ae 100644 Binary files a/data/tilesets/secondary/sootopolis/tiles.png and b/data/tilesets/secondary/sootopolis/tiles.png differ diff --git a/data/tilesets/secondary/sootopolis_gym/anim/0/0.png b/data/tilesets/secondary/sootopolis_gym/anim/0/0.png new file mode 100644 index 000000000..f0ec1ac00 Binary files /dev/null and b/data/tilesets/secondary/sootopolis_gym/anim/0/0.png differ diff --git a/data/tilesets/secondary/sootopolis_gym/anim/0/1.png b/data/tilesets/secondary/sootopolis_gym/anim/0/1.png new file mode 100644 index 000000000..4fefe4598 Binary files /dev/null and b/data/tilesets/secondary/sootopolis_gym/anim/0/1.png differ diff --git a/data/tilesets/secondary/sootopolis_gym/anim/0/2.png b/data/tilesets/secondary/sootopolis_gym/anim/0/2.png new file mode 100644 index 000000000..f603b3046 Binary files /dev/null and b/data/tilesets/secondary/sootopolis_gym/anim/0/2.png differ diff --git a/data/tilesets/secondary/sootopolis_gym/anim/0/3.png b/data/tilesets/secondary/sootopolis_gym/anim/0/3.png new file mode 100644 index 000000000..2a8e6a31c Binary files /dev/null and b/data/tilesets/secondary/sootopolis_gym/anim/0/3.png differ diff --git a/data/tilesets/secondary/sootopolis_gym/anim/1/0.png b/data/tilesets/secondary/sootopolis_gym/anim/1/0.png new file mode 100644 index 000000000..e0f807ef4 Binary files /dev/null and b/data/tilesets/secondary/sootopolis_gym/anim/1/0.png differ diff --git a/data/tilesets/secondary/sootopolis_gym/anim/1/1.png b/data/tilesets/secondary/sootopolis_gym/anim/1/1.png new file mode 100644 index 000000000..08413b63c Binary files /dev/null and b/data/tilesets/secondary/sootopolis_gym/anim/1/1.png differ diff --git a/data/tilesets/secondary/sootopolis_gym/anim/1/2.png b/data/tilesets/secondary/sootopolis_gym/anim/1/2.png new file mode 100644 index 000000000..6681b5e96 Binary files /dev/null and b/data/tilesets/secondary/sootopolis_gym/anim/1/2.png differ diff --git a/data/tilesets/secondary/sootopolis_gym/tiles.png b/data/tilesets/secondary/sootopolis_gym/tiles.png index b2533b243..4f6b25769 100644 Binary files a/data/tilesets/secondary/sootopolis_gym/tiles.png and b/data/tilesets/secondary/sootopolis_gym/tiles.png differ diff --git a/data/tilesets/secondary/trainer_hill/tiles.png b/data/tilesets/secondary/trainer_hill/tiles.png index f5330af84..78d292513 100644 Binary files a/data/tilesets/secondary/trainer_hill/tiles.png and b/data/tilesets/secondary/trainer_hill/tiles.png differ diff --git a/data/tilesets/secondary/trick_house_puzzle/tiles.png b/data/tilesets/secondary/trick_house_puzzle/tiles.png index eb81554cc..5ef1bf9ca 100644 Binary files a/data/tilesets/secondary/trick_house_puzzle/tiles.png and b/data/tilesets/secondary/trick_house_puzzle/tiles.png differ diff --git a/data/tilesets/secondary/underwater/anim/0.png b/data/tilesets/secondary/underwater/anim/0.png new file mode 100644 index 000000000..7609cc82a Binary files /dev/null and b/data/tilesets/secondary/underwater/anim/0.png differ diff --git a/data/tilesets/secondary/underwater/anim/1.png b/data/tilesets/secondary/underwater/anim/1.png new file mode 100644 index 000000000..64cddd371 Binary files /dev/null and b/data/tilesets/secondary/underwater/anim/1.png differ diff --git a/data/tilesets/secondary/underwater/anim/2.png b/data/tilesets/secondary/underwater/anim/2.png new file mode 100644 index 000000000..ff6ff8437 Binary files /dev/null and b/data/tilesets/secondary/underwater/anim/2.png differ diff --git a/data/tilesets/secondary/underwater/anim/3.png b/data/tilesets/secondary/underwater/anim/3.png new file mode 100644 index 000000000..2863c2261 Binary files /dev/null and b/data/tilesets/secondary/underwater/anim/3.png differ diff --git a/data/tilesets/secondary/underwater/tiles.png b/data/tilesets/secondary/underwater/tiles.png index e0569d970..5af21f353 100644 Binary files a/data/tilesets/secondary/underwater/tiles.png and b/data/tilesets/secondary/underwater/tiles.png differ diff --git a/data/tilesets/secondary/union_room/tiles.png b/data/tilesets/secondary/union_room/tiles.png index 50d44bf93..b38ffe9e5 100644 Binary files a/data/tilesets/secondary/union_room/tiles.png and b/data/tilesets/secondary/union_room/tiles.png differ diff --git a/data/tilesets/secondary/unused_1/0.png b/data/tilesets/secondary/unused_1/0.png new file mode 100644 index 000000000..bea921d90 Binary files /dev/null and b/data/tilesets/secondary/unused_1/0.png differ diff --git a/data/tilesets/secondary/unused_1/1.png b/data/tilesets/secondary/unused_1/1.png new file mode 100644 index 000000000..bea921d90 Binary files /dev/null and b/data/tilesets/secondary/unused_1/1.png differ diff --git a/data/tilesets/secondary/unused_1/2.png b/data/tilesets/secondary/unused_1/2.png new file mode 100644 index 000000000..16652df19 Binary files /dev/null and b/data/tilesets/secondary/unused_1/2.png differ diff --git a/data/tilesets/secondary/unused_1/3.png b/data/tilesets/secondary/unused_1/3.png new file mode 100644 index 000000000..8ea7a49e6 Binary files /dev/null and b/data/tilesets/secondary/unused_1/3.png differ diff --git a/data/tilesets/secondary/unused_1/tiles.png b/data/tilesets/secondary/unused_1/tiles.png index 0a35187c8..3ae8bce42 100644 Binary files a/data/tilesets/secondary/unused_1/tiles.png and b/data/tilesets/secondary/unused_1/tiles.png differ diff --git a/data/tilesets/secondary/unused_2/0.png b/data/tilesets/secondary/unused_2/0.png new file mode 100644 index 000000000..2895d3319 Binary files /dev/null and b/data/tilesets/secondary/unused_2/0.png differ diff --git a/data/tilesets/secondary/unused_2/1.png b/data/tilesets/secondary/unused_2/1.png new file mode 100644 index 000000000..63c22acf2 Binary files /dev/null and b/data/tilesets/secondary/unused_2/1.png differ diff --git a/data/tilesets/secondary/unused_2/2.png b/data/tilesets/secondary/unused_2/2.png new file mode 100644 index 000000000..d1447cde2 Binary files /dev/null and b/data/tilesets/secondary/unused_2/2.png differ diff --git a/data/tilesets/secondary/unused_2/3.png b/data/tilesets/secondary/unused_2/3.png new file mode 100644 index 000000000..8ad81b1e1 Binary files /dev/null and b/data/tilesets/secondary/unused_2/3.png differ diff --git a/data/tilesets/secondary/unused_2/tiles.png b/data/tilesets/secondary/unused_2/tiles.png index b9c594303..2ab3b63d6 100644 Binary files a/data/tilesets/secondary/unused_2/tiles.png and b/data/tilesets/secondary/unused_2/tiles.png differ diff --git a/data/unk_text_util_2.s b/data/unk_text_util_2.s deleted file mode 100644 index 69f227ea2..000000000 --- a/data/unk_text_util_2.s +++ /dev/null @@ -1,11 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - -gUnknown_08616124:: @ 8616124 - .incbin "baserom.gba", 0x616124, 0x4 - - .align 2 -gFont6BrailleGlyphs:: @ 8616128 - .incbin "data/graphics/fonts/font6.fwjpnfont" diff --git a/graphics/misc/clock_small.pal b/graphics/misc/clock_small.pal new file mode 100755 index 000000000..3398fcbe3 --- /dev/null +++ b/graphics/misc/clock_small.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +98 139 90 +0 0 0 +57 57 57 +123 123 123 +189 189 189 +255 255 255 +255 65 41 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 diff --git a/graphics/misc/clock_small.png b/graphics/misc/clock_small.png new file mode 100755 index 000000000..6b9f6c1f7 Binary files /dev/null and b/graphics/misc/clock_small.png differ diff --git a/graphics/misc/diploma.png b/graphics/misc/diploma.png new file mode 100755 index 000000000..d9607dce6 Binary files /dev/null and b/graphics/misc/diploma.png differ diff --git a/graphics/misc/diploma_hoenn.pal b/graphics/misc/diploma_hoenn.pal new file mode 100755 index 000000000..2890eb24a --- /dev/null +++ b/graphics/misc/diploma_hoenn.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +24 41 82 +255 255 222 +246 238 230 +205 230 139 +172 222 49 +238 238 222 +222 230 230 +255 222 197 +222 222 189 +246 246 180 +238 230 180 +213 213 156 +230 230 139 +255 255 123 +238 238 106 +255 205 172 diff --git a/graphics/misc/diploma_map.bin b/graphics/misc/diploma_map.bin new file mode 100755 index 000000000..e9a47fa44 Binary files /dev/null and b/graphics/misc/diploma_map.bin differ diff --git a/graphics/misc/diploma_national.pal b/graphics/misc/diploma_national.pal new file mode 100755 index 000000000..03c37bf22 --- /dev/null +++ b/graphics/misc/diploma_national.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +24 41 82 +255 255 222 +255 255 189 +230 238 90 +213 222 0 +238 238 222 +222 230 230 +255 222 197 +222 222 189 +246 246 180 +238 230 180 +213 213 156 +230 230 139 +255 255 123 +238 238 106 +255 205 172 diff --git a/include/battle.h b/include/battle.h index 67d3d873d..d41702396 100644 --- a/include/battle.h +++ b/include/battle.h @@ -1,6 +1,11 @@ #ifndef GUARD_BATTLE_H #define GUARD_BATTLE_H +// should they be included here or included individually by every file? +#include "battle_util.h" +#include "battle_script_commands.h" +#include "battle_2.h" + /* Banks are a name given to what could be called a 'battlerId' or 'monControllerId'. Each bank has a value consisting of two bits. @@ -54,11 +59,16 @@ #define BATTLE_TYPE_GROUDON 0x10000000 #define BATTLE_TYPE_KYORGE 0x20000000 #define BATTLE_TYPE_RAYQUAZA 0x40000000 +#define BATTLE_TYPE_x80000000 0x80000000 +#define TRAINER_OPPONENT_3FE 0x3FE +#define TRAINER_OPPONENT_C00 0xC00 +#define TRAINER_OPPONENT_800 0x800 #define STEVEN_PARTNER_ID 0xC03 #define SECRET_BASE_OPPONENT 0x400 -#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID) +#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID) +#define BATTLE_TYPE_FRONTIER_NO_PYRAMID (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000) #define BATTLE_WON 0x1 #define BATTLE_LOST 0x2 @@ -67,8 +77,11 @@ #define BATTLE_PLAYER_TELEPORTED 0x5 #define BATTLE_POKE_FLED 0x6 #define BATTLE_CAUGHT 0x7 +#define BATTLE_FORFEITED 0x9 #define BATTLE_OPPONENT_TELEPORTED 0xA +#define BATTLE_OUTCOME_BIT_x80 0x80 + #define STATUS_SLEEP 0x7 #define STATUS_POISON 0x8 #define STATUS_BURN 0x10 @@ -111,8 +124,8 @@ #define STATUS3_MINIMIZED 0x100 #define STATUS3_ROOTED 0x400 #define STATUS3_CHARGED_UP 0x200 -#define STATUS3_YAWN 0x1800 //two bits -#define STATUS3_IMPRISONED_OTHERS 0x2000 +#define STATUS3_YAWN 0x1800 // two bits +#define STATUS3_IMPRISONED_OTHERS 0x2000 #define STATUS3_GRUDGE 0x4000 #define STATUS3_CANT_SCORE_A_CRIT 0x8000 #define STATUS3_MUDSPORT 0x10000 @@ -123,6 +136,7 @@ #define STATUS3_SEMI_INVULNERABLE ((STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER)) +#define HITMARKER_x10 0x00000010 #define HITMARKER_x20 0x00000020 #define HITMARKER_DESTINYBOND 0x00000040 #define HITMARKER_NO_ANIMATIONS 0x00000080 @@ -133,6 +147,7 @@ #define HITMARKER_PURSUIT_TRAP 0x00001000 #define HITMARKER_IGNORE_SAFEGUARD 0x00002000 #define HITMARKER_SYNCHRONISE_EFFECT 0x00004000 +#define HITMARKER_RUN 0x00008000 #define HITMARKER_IGNORE_ON_AIR 0x00010000 #define HITMARKER_IGNORE_UNDERGROUND 0x00020000 #define HITMARKER_IGNORE_UNDERWATER 0x00040000 @@ -143,6 +158,7 @@ #define HITMARKER_x800000 0x00800000 #define HITMARKER_GRUDGE 0x01000000 #define HITMARKER_OBEYS 0x02000000 +#define HITMARKER_x4000000 0x04000000 #define HITMARKER_x8000000 0x08000000 #define HITMARKER_FAINTED(bank) ((gBitTable[bank] << 0x1C)) #define HITMARKER_UNK(bank) ((0x10000000 << bank)) @@ -156,28 +172,21 @@ #define SIDE_STATUS_MIST (1 << 8) #define SIDE_STATUS_SPIKES_DAMAGED (1 << 9) -#define ABILITYEFFECT_ON_SWITCHIN 0x0 -#define ABILITYEFFECT_ENDTURN 0x1 -#define ABILITYEFFECT_MOVES_BLOCK 0x2 -#define ABILITYEFFECT_ABSORBING 0x3 -#define ABILITYEFFECT_CONTACT 0x4 -#define ABILITYEFFECT_IMMUNITY 0x5 -#define ABILITYEFFECT_FORECAST 0x6 -#define ABILITYEFFECT_SYNCHRONIZE 0x7 -#define ABILITYEFFECT_ATK_SYNCHRONIZE 0x8 -#define ABILITYEFFECT_INTIMIDATE1 0x9 -#define ABILITYEFFECT_INTIMIDATE2 0xA -#define ABILITYEFFECT_TRACE 0xB -#define ABILITYEFFECT_CHECK_OTHER_SIDE 0xC -#define ABILITYEFFECT_CHECK_BANK_SIDE 0xD -#define ABILITYEFFECT_FIELD_SPORT 0xE -#define ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK 0xF -#define ABILITYEFFECT_COUNT_OTHER_SIDE 0x10 -#define ABILITYEFFECT_COUNT_BANK_SIDE 0x11 -#define ABILITYEFFECT_COUNT_ON_FIELD 0x12 -#define ABILITYEFFECT_CHECK_ON_FIELD 0x13 - -#define WEATHER_HAS_EFFECT ((!AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, ABILITY_CLOUD_NINE, 0, 0) && !AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, ABILITY_AIR_LOCK, 0, 0))) +#define ACTION_USE_MOVE 0 +#define ACTION_USE_ITEM 1 +#define ACTION_SWITCH 2 +#define ACTION_RUN 3 +#define ACTION_WATCHES_CAREFULLY 4 +#define ACTION_SAFARI_ZONE_BALL 5 +#define ACTION_POKEBLOCK_CASE 6 +#define ACTION_GO_NEAR 7 +#define ACTION_SAFARI_ZONE_RUN 8 +#define ACTION_9 9 +#define ACTION_RUN_BATTLESCRIPT 10 // when executing an action +#define ACTION_CANCEL_PARTNER 12 // when choosing an action +#define ACTION_FINISHED 12 // when executing an action +#define ACTION_NOTHING_FAINTED 13 // when choosing an action +#define ACTION_INIT_VALUE 0xFF #define MOVESTATUS_MISSED (1 << 0) #define MOVESTATUS_SUPEREFFECTIVE (1 << 1) @@ -215,14 +224,19 @@ #define BATTLE_TERRAIN_POND 5 #define BATTLE_TERRAIN_ROCK 6 #define BATTLE_TERRAIN_CAVE 7 +#define BATTLE_TERRAIN_INSIDE 8 // array entries for battle communication -#define MULTIUSE_STATE 0x0 -#define CURSOR_POSITION 0x1 -#define TASK_ID 0x1 // task Id and cursor position share the same field -#define MOVE_EFFECT_BYTE 0x3 -#define MULTISTRING_CHOOSER 0x5 -#define MSG_DISPLAY 0x7 +#define MULTIUSE_STATE 0x0 +#define CURSOR_POSITION 0x1 +#define TASK_ID 0x1 // task Id and cursor position share the same field +#define SPRITES_INIT_STATE1 0x1 // shares the Id as well +#define SPRITES_INIT_STATE2 0x2 +#define MOVE_EFFECT_BYTE 0x3 +#define ACTIONS_CONFIRMED_COUNT 0x4 +#define MULTISTRING_CHOOSER 0x5 +#define MSG_DISPLAY 0x7 +#define BATTLE_COMMUNICATION_ENTRIES_COUNT 0x8 #define MOVE_TARGET_SELECTED 0x0 #define MOVE_TARGET_DEPENDS 0x1 @@ -238,53 +252,34 @@ #define TYPE_MUL_NORMAL 10 #define TYPE_MUL_SUPER_EFFECTIVE 20 -#define BS_GET_TARGET 0 -#define BS_GET_ATTACKER 1 -#define BS_GET_EFFECT_BANK 2 -#define BS_ATTACKER_WITH_PARTNER 4 // for atk98_status_icon_update -#define BS_GET_ATTACKER_SIDE 8 // for atk1E_jumpifability -#define BS_GET_NOT_ATTACKER_SIDE 9 // for atk1E_jumpifability -#define BS_GET_SCRIPTING_BANK 10 -#define BS_GET_OPPONENT1 12 -#define BS_GET_PLAYER2 13 -#define BS_GET_OPPONENT2 14 - -// for battle script commands -#define CMP_EQUAL 0x0 -#define CMP_NOT_EQUAL 0x1 -#define CMP_GREATER_THAN 0x2 -#define CMP_LESS_THAN 0x3 -#define CMP_COMMON_BITS 0x4 -#define CMP_NO_COMMON_BITS 0x5 - struct TrainerMonNoItemDefaultMoves { - u16 species; + u16 iv; u8 lvl; - u16 evsValue; + u16 species; }; struct TrainerMonItemDefaultMoves { - u16 species; + u16 iv; u8 lvl; - u16 evsValue; + u16 species; u16 heldItem; }; struct TrainerMonNoItemCustomMoves { - u16 species; + u16 iv; u8 lvl; - u16 evsValue; + u16 species; u16 moves[4]; }; struct TrainerMonItemCustomMoves { - u16 species; + u16 iv; u8 lvl; - u16 evsValue; + u16 species; u16 heldItem; u16 moves[4]; }; @@ -342,8 +337,8 @@ struct DisableStruct /*0x0F*/ u8 perishSong1 : 4; /*0x0F*/ u8 perishSong2 : 4; /*0x10*/ u8 furyCutterCounter; - /*0x11*/ u8 rolloutTimer1 : 4; - /*0x11*/ u8 rolloutTimer2 : 4; + /*0x11*/ u8 rolloutCounter1 : 4; + /*0x11*/ u8 rolloutCounter2 : 4; /*0x12*/ u8 chargeTimer1 : 4; /*0x12*/ u8 chargeTimer2 : 4; /*0x13*/ u8 tauntTimer1:4; @@ -375,7 +370,7 @@ struct ProtectStruct u32 prlzImmobility:1; /* field_1 */ u32 confusionSelfDmg:1; - u32 notEffective:1; + u32 targetNotAffected:1; u32 chargingTurn:1; u32 fleeFlag:2; // for RunAway and Smoke Ball u32 usedImprisionedMove:1; @@ -532,26 +527,24 @@ struct BattleResults u8 playerSwitchesCounter; // 0x2 u8 unk3; // 0x3 u8 unk4; // 0x4 - u8 unk5_0:1; // 0x5 - u8 unk5_1:1; // 0x5 - u8 caughtMonBall:4; // 0x5 - u8 unk5_6:1; // 0x5 - u8 unk5_7:1; // 0x5 - u16 poke1Species; // 0x6 - u8 pokeString1[10]; // 0x8 - u8 unk12; + u8 unk5_0:1; // 0x5 , 0x1 + u8 unk5_1:1; // 0x5 , 0x2 + u8 caughtMonBall:4; // 0x5 , 0x4/0x8/0x10/0x20 + u8 unk5_6:1; // 0x5 , 0x40 + u8 unk5_7:1; // 0x5 , 0x80 + u16 playerMon1Species; // 0x6 + u8 playerMon1Name[11]; // 0x8 u8 battleTurnCounter; // 0x13 - u8 pokeString2[10]; // 0x14 - u8 field_1E; // 0x1E + u8 playerMon2Name[11]; // 0x14 u8 field_1F; // 0x1F u16 lastOpponentSpecies; // 0x20 - u16 lastUsedMove; // 0x22 - u16 opponentMove; // 0x24 - u16 opponentSpecies; // 0x26 + u16 lastUsedMovePlayer; // 0x22 + u16 lastUsedMoveOpponent; // 0x24 + u16 playerMon2Species; // 0x26 u16 caughtMonSpecies; // 0x28 u8 caughtMonNick[10]; // 0x2A u8 filler34[2]; - u8 catchAttempts[10]; // 0x36 + u8 catchAttempts[12]; // 0x36 }; extern struct BattleResults gBattleResults; @@ -578,22 +571,22 @@ struct BattleStruct u8 field_45; u8 field_46; u8 field_47; - u8 field_48; + u8 focusPunchBank; u8 field_49; u8 moneyMultiplier; u8 field_4B; - u8 field_4C; + u8 switchInAbilitiesCounter; u8 field_4D; u8 field_4E; u8 field_4F; u16 expValue; u8 field_52; u8 sentInPokes; - u8 field_54[4]; + bool8 selectionScriptFinished[BATTLE_BANKS_COUNT]; u8 field_58[4]; u8 field_5C[4]; u8 field_60[4][3]; - u8 field_6C; + u8 runTries; u8 caughtMonNick[11]; u8 field_78; u8 field_79; @@ -603,11 +596,8 @@ struct BattleStruct u8 field_7D; u8 field_7E; u8 formToChangeInto; - u8 chosenMovesIds[4]; - u8 field_84; - u8 field_85; - u8 field_86; - u8 field_87; + u8 chosenMovePositions[BATTLE_BANKS_COUNT]; + u8 stateIdAfterSelScript[BATTLE_BANKS_COUNT]; u8 field_88; u8 field_89; u8 field_8A; @@ -633,31 +623,35 @@ struct BattleStruct u8 field_A5; u8 field_A6; u8 field_A7; - u16 hpOnSwitchout[4]; + u16 hpOnSwitchout[2]; + u32 savedBattleTypeFlags; u8 field_B0; u8 hpScale; u8 synchronizeMoveEffect; u8 field_B3; - u8 field_B4; - u8 field_B5; - u8 field_B6; - u8 field_B7; + void (*savedCallback)(void); u16 usedHeldItems[BATTLE_BANKS_COUNT]; - u8 field_C0[8]; + u8 field_C0[4]; + u8 field_C4[2]; + u8 field_C6[2]; u16 choicedMove[BATTLE_BANKS_COUNT]; u16 changedItems[BATTLE_BANKS_COUNT]; u8 intimidateBank; - u8 fillerD9[0xDA-0xD9]; + u8 switchInItemsCounter; u8 field_DA; u8 turnSideTracker; u8 fillerDC[0xDF-0xDC]; u8 field_DF; u8 mirrorMoveArrays[32]; u16 castformPalette[4][16]; - u8 field_180[32]; + u8 field_180; + u8 field_181; + u8 field_182; + u8 field_183; + struct BattleEnigmaBerry battleEnigmaBerry; u8 field_1A0; u8 field_1A1; - u8 filler1A2; + bool8 overworldWeatherDone; u8 atkCancellerTracker; u8 field_1A4[240]; u8 field_294[4]; @@ -783,38 +777,10 @@ extern struct BattleStruct* gBattleStruct; #define B_ANIM_x1C 0x1C #define B_ANIM_x1D 0x1D -#define ATK48_STAT_NEGATIVE 0x1 -#define ATK48_STAT_BY_TWO 0x2 -#define ATK48_BIT_x4 0x4 -#define ATK48_LOWER_FAIL_CHECK 0x8 - -#define ATK4F_DONT_CHECK_STATUSES 0x80 - -#define VARIOUS_CANCEL_MULTI_TURN_MOVES 0 -#define VARIOUS_SET_MAGIC_COAT_TARGET 1 -#define VARIOUS_GET_MOVE_TARGET 3 -#define VARIOUS_RESET_INTIMIDATE_TRACE_BITS 5 -#define VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP 6 -#define VARIOUS_WAIT_CRY 18 -#define VARIOUS_RETURN_OPPONENT_MON1 19 -#define VARIOUS_RETURN_OPPONENT_MON2 20 -#define VARIOUS_SET_TELEPORT_OUTCOME 25 -#define VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC 26 - -#define ATK80_DMG_CHANGE_SIGN 0 -#define ATK80_DMG_HALF_BY_TWO_NOT_MORE_THAN_HALF_MAX_HP 1 -#define ATK80_DMG_DOUBLED 2 - #define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8 #define GET_STAT_BUFF_VALUE(n)(((n >> 4) & 7)) // 0x10, 0x20, 0x40 #define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit -#define STAT_CHANGE_BS_PTR 0x1 -#define STAT_CHANGE_NOT_PROTECT_AFFECTED 0x20 - -#define STAT_CHANGE_WORKED 0 -#define STAT_CHANGE_DIDNT_WORK 1 - #define SET_STAT_BUFF_ID(n)((n & 0xF)) #define SET_STAT_BUFF_VALUE(n)(((s8)(((s8)(n) << 4)) & 0xF0)) @@ -838,106 +804,103 @@ struct BattleScripting u8 statChanger; u8 field_1B; u8 atk23_state; - u8 field_1D; + u8 battleStyle; u8 atk6C_state; u8 learnMoveState; u8 field_20; + u8 field_21; + u8 field_22; + u8 field_23; + u8 field_24; + u8 multiplayerId; }; extern struct BattleScripting gBattleScripting; // functions -// battle_2 -void CancelMultiTurnMoves(u8 bank); -void PressurePPLose(u8 bankAtk, u8 bankDef, u16 move); -void PrepareStringBattle(u16 stringId, u8 bank); -u8 GetBattleBank(u8 caseId); -void UndoEffectsAfterFainting(void); -bool8 HasMoveFailed(u8 bank); -void SwitchInClearStructs(void); -void sub_803BDA0(u8 bank); -void sub_803FA70(u8 bank); -void BattleMainCB2(void); -void VBlankCB_Battle(void); -void ResetSentPokesToOpponentValue(void); -bool8 CanRunFromBattle(u8 bank); -bool8 IsRunningFromBattleImpossible(void); -void PressurePPLoseOnUsingPerishSong(u8 bankAtk); -void PressurePPLoseOnUsingImprision(u8 bankAtk); - -// battle_3 -#define MOVE_LIMITATION_ZEROMOVE (1 << 0) -#define MOVE_LIMITATION_PP (1 << 1) -#define MOVE_LIMITATION_DISABLED (1 << 2) -#define MOVE_LIMITATION_TORMENTED (1 << 3) -#define MOVE_LIMITATION_TAUNT (1 << 4) -#define MOVE_LIMITATION_IMPRISION (1 << 5) - -void BattleScriptPush(const u8* bsPtr); -void BattleScriptPushCursor(void); -void BattleScriptPop(void); -u8 sub_803FB4C(void); // msg, can't select a move -u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check); -bool8 AreAllMovesUnusable(void); -u8 GetImprisonedMovesCount(u8 bank, u16 move); -u8 UpdateTurnCounters(void); -u8 TurnBasedEffects(void); -bool8 sub_8041364(void); -bool8 sub_8041728(void); -void b_clear_atk_up_if_hit_flag_unless_enraged(void); -u8 AtkCanceller_UnableToUseMove(void); -bool8 sub_80423F4(u8 bank, u8 r1, u8 r2); -u8 CastformDataTypeChange(u8 bank); -u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg); -void BattleScriptExecute(const u8* BS_ptr); -void BattleScriptPushCursorAndCallback(const u8* BS_ptr); -u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn); -void sub_8045868(u8 bank); -void sub_80458B4(void); -u8 GetMoveTarget(u16 move, u8 useMoveTarget); -u8 IsPokeDisobedient(void); - -// battle_script_commands -void AI_CalcDmg(u8 bankAtk, u8 bankDef); -u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef); -u8 AI_TypeCalc(u16 move, u16 species, u8 ability); -u8 BankGetTurnOrder(u8 bank); -void SetMoveEffect(bool8 primary, u8 certain); -void BattleDestroyCursorAt(u8 cursorPosition); -void BattleCreateCursorAt(u8 cursorPosition); -void BufferMoveToLearnIntoBattleTextBuff2(void); -void sub_8056A3C(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 flags); -bool8 UproarWakeUpCheck(u8 bank); - -extern void (* const gBattleScriptingCommandsTable[])(void); -extern const u8 gUnknown_0831C494[]; +// battle_1 +void LoadBattleTextboxAndBackground(void); +void LoadBattleEntryBackground(void); +void ApplyPlayerChosenFrameToBattleMenu(void); +bool8 LoadChosenBattleElement(u8 caseId); +void task00_0800F6FC(u8 taskId); // battle_5 +void AllocateBattleResrouces(void); +void FreeBattleResources(void); void AdjustFriendshipOnBattleFaint(u8 bank); void sub_80571DC(u8 bank, u8 arg1); u32 sub_805725C(u8 bank); // battle 7 +void AllocateBattleSpritesData(void); +void FreeBattleSpritesData(void); +void AllocateMonSpritesGfx(void); +void FreeMonSpritesGfx(void); void BattleMusicStop(void); void sub_805E990(struct Pokemon* mon, u8 bank); +void sub_805EF14(void); +bool8 BattleInitAllSprites(u8 *state1, u8 *state2); // rom_80A5C6C u8 GetBankSide(u8 bank); u8 GetBankIdentity(u8 bank); u8 GetBankByIdentity(u8 bank); +struct BattleSpriteInfo +{ + u16 invisible : 1; // 0x1 + u16 flag_x2 : 1; // 0x2 + u16 behindSubstitute : 1; // 0x4 + u16 flag_x8 : 1; // 0x8 + u16 hpNumbersNoBars : 1; // 0x10 + u16 transformSpecies; +}; + +struct BattleAnimationInfo +{ + u16 field; // to fill up later +}; + +struct BattleHealthboxInfo +{ + u8 flag_x1 : 1; + u8 flag_x2 : 1; + u8 flag_x4 : 1; + u8 field_1; + u8 field_2; + u8 field_3; + u8 field_4; + u8 field_5; + u8 field_6; + u8 field_7; + u8 field_8; + u8 field_9; + u8 field_A; + u8 field_B; +}; + +struct BattleSpriteData +{ + struct BattleSpriteInfo *bankData; + struct BattleHealthboxInfo *healthBoxesData; + struct BattleAnimationInfo *animationData; +}; + +extern struct BattleSpriteData *gBattleSpritesDataPtr; + // Move this somewhere else #include "sprite.h" -struct BattleSpritesGfx +struct MonSpritesGfx { void* firstDecompressed; // ptr to the decompressed sprite of the first pokemon void* sprites[4]; struct SpriteTemplate templates[4]; }; -extern struct BattleSpritesGfx* gBattleSpritesGfx; +extern struct MonSpritesGfx* gMonSpritesGfxPtr; #endif // GUARD_BATTLE_H diff --git a/include/battle_2.h b/include/battle_2.h new file mode 100644 index 000000000..edd6b6ef3 --- /dev/null +++ b/include/battle_2.h @@ -0,0 +1,30 @@ +#ifndef GUARD_BATTLE_2_H +#define GUARD_BATTLE_2_H + +void CB2_InitBattle(void); +void CB2_QuitRecordedBattle(void); +void FaintClearSetData(void); +void SwitchInClearSetData(void); +void sub_803BDA0(u8 bank); +void BattleMainCB2(void); +void VBlankCB_Battle(void); +bool8 TryRunFromBattle(u8 bank); +u8 IsRunningFromBattleImpossible(void); +u8 GetWhoStrikesFirst(u8 bank1, u8 bank2, bool8 ignoreChosenMoves); +void SwapTurnOrder(u8 id1, u8 id2); +void BattleTurnPassed(void); +void RunBattleScriptCommands_PopCallbacksStack(void); +void RunBattleScriptCommands(void); +void sub_8039E9C(struct Sprite *sprite); + +extern const u8 gStatusConditionString_PoisonJpn[8]; +extern const u8 gStatusConditionString_SleepJpn[8]; +extern const u8 gStatusConditionString_ParalysisJpn[8]; +extern const u8 gStatusConditionString_BurnJpn[8]; +extern const u8 gStatusConditionString_IceJpn[8]; +extern const u8 gStatusConditionString_ConfusionJpn[8]; +extern const u8 gStatusConditionString_LoveJpn[8]; + +extern const u8 * const gStatusConditionStringsTable[][2]; + +#endif // GUARD_BATTLE_2_H diff --git a/include/battle_controllers.h b/include/battle_controllers.h index b2846d7cf..2281fdaff 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -1,6 +1,28 @@ #ifndef GUARD_BATTLE_CONTROLLERS_H #define GUARD_BATTLE_CONTROLLERS_H +#define REQUEST_ALL_BATTLE 0x0 +#define REQUEST_SPECIES_BATTLE 0x1 +#define REQUEST_HELDITEM_BATTLE 0x2 +#define REQUEST_MOVES_PP_BATTLE 0x3 +#define REQUEST_PPMOVE1_BATTLE 0x9 +#define REQUEST_PPMOVE2_BATTLE 0xA +#define REQUEST_PPMOVE3_BATTLE 0xB +#define REQUEST_PPMOVE4_BATTLE 0xC +#define REQUEST_STATUS_BATTLE 0x28 +#define REQUEST_HP_BATTLE 0x2A + +#define RESET_ACTION_MOVE_SELECTION 0 +#define RESET_ACTION_SELECTION 1 +#define RESET_MOVE_SELECTION 2 + +#define BALL_NO_SHAKES 0 +#define BALL_1_SHAKE 1 +#define BALL_2_SHAKES 2 +#define BALL_3_SHAKES_FAIL 3 +#define BALL_3_SHAKES_SUCCESS 4 +#define BALL_TRAINER_BLOCK 5 + struct HpAndStatus { u16 hp; @@ -14,16 +36,15 @@ struct MovePpInfo u8 ppBonuses; }; -#define REQUEST_ALL_BATTLE 0x0 -#define REQUEST_SPECIES_BATTLE 0x1 -#define REQUEST_HELDITEM_BATTLE 0x2 -#define REQUEST_MOVES_PP_BATTLE 0x3 -#define REQUEST_PPMOVE1_BATTLE 0x9 -#define REQUEST_PPMOVE2_BATTLE 0xA -#define REQUEST_PPMOVE3_BATTLE 0xB -#define REQUEST_PPMOVE4_BATTLE 0xC -#define REQUEST_STATUS_BATTLE 0x28 -#define REQUEST_HP_BATTLE 0x2A +struct ChooseMoveStruct +{ + u16 moves[4]; + u8 ppNumbers[4]; + u8 ppWithBonusNumbers[4]; + u16 species; + u8 monType1; + u8 monType2; +}; // rom3.s, emitters void EmitSetMonData(u8 bufferId, u8 request, u8 c, u8 bytes, void *data); @@ -40,34 +61,28 @@ void EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible); void EmitReturnPokeToBall(u8 bufferId, u8 arg1); void EmitGetMonData(u8 bufferId, u8 arg1, u8 arg2); void EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit); -void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, const u8* arg4); -void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, u8 arg2); +void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8* arg4); +void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 arg2); void EmitTrainerSlide(u8 bufferId); void EmitTrainerSlideBack(u8 bufferId); void EmitFaintingCry(u8 bufferId); void Emit_x37(u8 bufferId, u8 arg1); void EmitHitAnimation(u8 bufferId); -void EmitCmd48(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 arg2); +void EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 arg2); void EmitCmd49(u8 bufferId); void EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status); void EmitCmd13(u8 bufferId); void EmitStatusIconUpdate(u8 bufferId, u32 status1, u32 status2); - -#define RESET_ACTION_MOVE_SELECTION 0 -#define RESET_ACTION_SELECTION 1 -#define RESET_MOVE_SELECTION 2 - +void EmitIntroSlide(u8 bufferId, u8 terrainId); +void EmitDrawTrainerPic(u8 bufferId); +void EmitLoadMonSprite(u8 bufferId); +void EmitIntroTrainerBallThrow(u8 bufferId); +void EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2); +void EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct* movePpData); +void EmitOpenBag(u8 bufferId, u8* arg1); +void Emit_x32(u8 bufferId); +void EmitPrintString(u8 bufferId, u16 stringId); void EmitResetActionMoveSelection(u8 bufferId, u8 caseId); - -#define BALL_NO_SHAKES 0 -#define BALL_1_SHAKE 1 -#define BALL_2_SHAKES 2 -#define BALL_3_SHAKES_FAIL 3 -#define BALL_3_SHAKES_SUCCESS 4 -#define BALL_TRAINER_BLOCK 5 - void EmitBallThrow(u8 bufferId, u8 caseId); -void MarkBufferBankForExecution(u8 bank); - #endif // GUARD_BATTLE_CONTROLLERS_H diff --git a/include/battle_script_commands.h b/include/battle_script_commands.h new file mode 100644 index 000000000..ae0d20f28 --- /dev/null +++ b/include/battle_script_commands.h @@ -0,0 +1,58 @@ +#ifndef GUARD_BATTLE_SCRIPT_COMMANDS_H +#define GUARD_BATTLE_SCRIPT_COMMANDS_H + +#define CMP_EQUAL 0x0 +#define CMP_NOT_EQUAL 0x1 +#define CMP_GREATER_THAN 0x2 +#define CMP_LESS_THAN 0x3 +#define CMP_COMMON_BITS 0x4 +#define CMP_NO_COMMON_BITS 0x5 + +#define BS_ATTACKER_WITH_PARTNER 4 // for atk98_status_icon_update +#define BS_GET_ATTACKER_SIDE 8 // for atk1E_jumpifability +#define BS_GET_NOT_ATTACKER_SIDE 9 // for atk1E_jumpifability + +#define ATK48_STAT_NEGATIVE 0x1 +#define ATK48_STAT_BY_TWO 0x2 +#define ATK48_BIT_x4 0x4 +#define ATK48_LOWER_FAIL_CHECK 0x8 + +#define ATK4F_DONT_CHECK_STATUSES 0x80 + +#define VARIOUS_CANCEL_MULTI_TURN_MOVES 0 +#define VARIOUS_SET_MAGIC_COAT_TARGET 1 +#define VARIOUS_CAN_RUN_FROM_BATTLE 2 +#define VARIOUS_GET_MOVE_TARGET 3 +#define VARIOUS_RESET_INTIMIDATE_TRACE_BITS 5 +#define VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP 6 +#define VARIOUS_WAIT_CRY 18 +#define VARIOUS_RETURN_OPPONENT_MON1 19 +#define VARIOUS_RETURN_OPPONENT_MON2 20 +#define VARIOUS_SET_TELEPORT_OUTCOME 25 +#define VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC 26 + +#define ATK80_DMG_CHANGE_SIGN 0 +#define ATK80_DMG_HALF_BY_TWO_NOT_MORE_THAN_HALF_MAX_HP 1 +#define ATK80_DMG_DOUBLED 2 + +#define STAT_CHANGE_BS_PTR 0x1 +#define STAT_CHANGE_NOT_PROTECT_AFFECTED 0x20 + +#define STAT_CHANGE_WORKED 0 +#define STAT_CHANGE_DIDNT_WORK 1 + +void AI_CalcDmg(u8 bankAtk, u8 bankDef); +u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef); +u8 AI_TypeCalc(u16 move, u16 species, u8 ability); +u8 BankGetTurnOrder(u8 bank); +void SetMoveEffect(bool8 primary, u8 certain); +void BattleDestroyCursorAt(u8 cursorPosition); +void BattleCreateCursorAt(u8 cursorPosition); +void BufferMoveToLearnIntoBattleTextBuff2(void); +void sub_8056A3C(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 flags); +bool8 UproarWakeUpCheck(u8 bank); + +extern void (* const gBattleScriptingCommandsTable[])(void); +extern const u8 gUnknown_0831C494[]; + +#endif // GUARD_BATTLE_SCRIPT_COMMANDS_H diff --git a/include/battle_setup.h b/include/battle_setup.h new file mode 100644 index 000000000..80fb55da2 --- /dev/null +++ b/include/battle_setup.h @@ -0,0 +1,6 @@ +#ifndef GUARD_BATTLE_SETUP_H +#define GUARD_BATTLE_SETUP_H + +u8 BattleSetup_GetTerrainId(void); + +#endif // GUARD_BATTLE_SETUP_H diff --git a/include/battle_transition.h b/include/battle_transition.h new file mode 100644 index 000000000..1603f5c93 --- /dev/null +++ b/include/battle_transition.h @@ -0,0 +1,6 @@ +#ifndef GUARD_BATTLE_TRANSITION_H +#define GUARD_BATTLE_TRANSITION_H + +void sub_8149DFC(u8 a1); + +#endif // GUARD_BATTLE_TRANSITION_H diff --git a/include/battle_util.h b/include/battle_util.h new file mode 100644 index 000000000..c1ff7d8ab --- /dev/null +++ b/include/battle_util.h @@ -0,0 +1,83 @@ +#ifndef GUARD_BATTLE_UTIL_H +#define GUARD_BATTLE_UTIL_H + +#define MOVE_LIMITATION_ZEROMOVE (1 << 0) +#define MOVE_LIMITATION_PP (1 << 1) +#define MOVE_LIMITATION_DISABLED (1 << 2) +#define MOVE_LIMITATION_TORMENTED (1 << 3) +#define MOVE_LIMITATION_TAUNT (1 << 4) +#define MOVE_LIMITATION_IMPRISION (1 << 5) + +#define ABILITYEFFECT_ON_SWITCHIN 0x0 +#define ABILITYEFFECT_ENDTURN 0x1 +#define ABILITYEFFECT_MOVES_BLOCK 0x2 +#define ABILITYEFFECT_ABSORBING 0x3 +#define ABILITYEFFECT_CONTACT 0x4 +#define ABILITYEFFECT_IMMUNITY 0x5 +#define ABILITYEFFECT_FORECAST 0x6 +#define ABILITYEFFECT_SYNCHRONIZE 0x7 +#define ABILITYEFFECT_ATK_SYNCHRONIZE 0x8 +#define ABILITYEFFECT_INTIMIDATE1 0x9 +#define ABILITYEFFECT_INTIMIDATE2 0xA +#define ABILITYEFFECT_TRACE 0xB +#define ABILITYEFFECT_CHECK_OTHER_SIDE 0xC +#define ABILITYEFFECT_CHECK_BANK_SIDE 0xD +#define ABILITYEFFECT_FIELD_SPORT 0xE +#define ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK 0xF +#define ABILITYEFFECT_COUNT_OTHER_SIDE 0x10 +#define ABILITYEFFECT_COUNT_BANK_SIDE 0x11 +#define ABILITYEFFECT_COUNT_ON_FIELD 0x12 +#define ABILITYEFFECT_CHECK_ON_FIELD 0x13 +#define ABILITYEFFECT_SWITCH_IN_WEATHER 0xFF + +#define ITEMEFFECT_ON_SWITCH_IN 0x0 + +#define WEATHER_HAS_EFFECT ((!AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, ABILITY_CLOUD_NINE, 0, 0) && !AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, ABILITY_AIR_LOCK, 0, 0))) + +#define BS_GET_TARGET 0 +#define BS_GET_ATTACKER 1 +#define BS_GET_EFFECT_BANK 2 +#define BS_GET_SCRIPTING_BANK 10 +#define BS_GET_PLAYER1 11 +#define BS_GET_OPPONENT1 12 +#define BS_GET_PLAYER2 13 +#define BS_GET_OPPONENT2 14 + +u8 GetBattleBank(u8 caseId); +void PressurePPLose(u8 bankDef, u8 bankAtk, u16 move); +void PressurePPLoseOnUsingPerishSong(u8 bankAtk); +void PressurePPLoseOnUsingImprision(u8 bankAtk); +void MarkAllBufferBanksForExecution(void); // unused +void MarkBufferBankForExecution(u8 bank); +void sub_803F850(u8 arg0); +void CancelMultiTurnMoves(u8 bank); +bool8 WasUnableToUseMove(u8 bank); +void PrepareStringBattle(u16 stringId, u8 bank); +void ResetSentPokesToOpponentValue(void); +void sub_803F9EC(u8 bank); +void sub_803FA70(u8 bank); +void BattleScriptPush(const u8* bsPtr); +void BattleScriptPushCursor(void); +void BattleScriptPop(void); +u8 TrySetCantSelectMoveBattleScript(void); +u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check); +bool8 AreAllMovesUnusable(void); +u8 GetImprisonedMovesCount(u8 bank, u16 move); +u8 UpdateTurnCounters(void); +u8 TurnBasedEffects(void); +bool8 sub_8041364(void); +bool8 sub_8041728(void); +void TryClearRageStatuses(void); +u8 AtkCanceller_UnableToUseMove(void); +bool8 sub_80423F4(u8 bank, u8 r1, u8 r2); +u8 CastformDataTypeChange(u8 bank); +u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg); +void BattleScriptExecute(const u8* BS_ptr); +void BattleScriptPushCursorAndCallback(const u8* BS_ptr); +u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn); +void ClearFuryCutterDestinyBondGrudge(u8 bank); +void HandleAction_RunBattleScript(void); +u8 GetMoveTarget(u16 move, u8 useMoveTarget); +u8 IsPokeDisobedient(void); + +#endif // GUARD_BATTLE_UTIL_H diff --git a/include/blend_palette.h b/include/blend_palette.h new file mode 100644 index 000000000..1db3f4eb0 --- /dev/null +++ b/include/blend_palette.h @@ -0,0 +1,12 @@ +#ifndef GUARD_BLEND_PALETTE_H +#define GUARD_BLEND_PALETTE_H + +// Exported type declarations + +// Exported RAM declarations + +// Exported ROM declarations + +void BlendPalette(u16, u16, u8, u16); + +#endif //GUARD_BLEND_PALETTE_H diff --git a/include/dma3.h b/include/dma3.h index db75ea9e3..265b47824 100644 --- a/include/dma3.h +++ b/include/dma3.h @@ -1,20 +1,6 @@ #ifndef GUARD_DMA3_H #define GUARD_DMA3_H -extern u8 gDma3ManagerLocked; -extern u8 gDma3RequestCursor; - -struct DmaRequestsStruct -{ - /* 0x00 */ const u8 *src; - /* 0x04 */ u8 *dest; - /* 0x08 */ u16 size; - /* 0x0A */ u16 mode; - /* 0x0C */ u32 value; -}; - -extern struct DmaRequestsStruct gDma3Requests[128]; - void ClearDma3Requests(void); void ProcessDma3Requests(void); int RequestDma3Copy(const void *src, void *dest, u16 size, u8 mode); diff --git a/include/evolution_scene.h b/include/evolution_scene.h new file mode 100644 index 000000000..48bd6ebe1 --- /dev/null +++ b/include/evolution_scene.h @@ -0,0 +1,10 @@ +#ifndef GUARD_EVOLUTION_SCENE_H +#define GUARD_EVOLUTION_SCENE_H + +void EvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, bool8 canStopEvo, u8 partyID); +void BeginEvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, bool8 canStopEvo, u8 partyID); +void TradeEvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, u8 preEvoSpriteID, u8 partyID); + +extern void (*gCB2_AfterEvolution)(void); + +#endif // GUARD_EVOLUTION_SCENE_H diff --git a/include/flags.h b/include/flags.h index 19ec01b56..020fc59cb 100644 --- a/include/flags.h +++ b/include/flags.h @@ -84,6 +84,8 @@ #define SYS_CTRL_OBJ_DELETE CODE_FLAGS + 0x61 #define SYS_RESET_RTC_ENABLE CODE_FLAGS + 0x62 +#define SYS_FRONTIER_PASS CODE_FLAGS + 0x72 + #define SYS_STORAGE_UNKNOWN_FLAG CODE_FLAGS + 0x77 #define SYS_MYSTERY_GIFT_ENABLE CODE_FLAGS + 0x7B diff --git a/include/gba/flash_internal.h b/include/gba/flash_internal.h index 6156b6c14..ba84546aa 100644 --- a/include/gba/flash_internal.h +++ b/include/gba/flash_internal.h @@ -65,6 +65,7 @@ u16 ReadFlashId(void); void StartFlashTimer(u8 phase); void SetReadFlash1(u16 *dest); void StopFlashTimer(void); +void ReadFlash(u16 sectorNum, u32 offset, u8 *dest, u32 size); u16 WaitForFlashWrite_Common(u8 phase, u8 *addr, u8 lastData); diff --git a/include/global.berry.h b/include/global.berry.h index a77da20ba..5c8a43a02 100644 --- a/include/global.berry.h +++ b/include/global.berry.h @@ -1,9 +1,12 @@ #ifndef GUARD_GLOBAL_BERRY_H #define GUARD_GLOBAL_BERRY_H +#define BERRY_NAME_COUNT 7 +#define BERRY_ITEM_EFFECT_COUNT 18 + struct Berry { - const u8 name[7]; + const u8 name[BERRY_NAME_COUNT]; u8 firmness; u16 size; u8 maxYield; @@ -23,7 +26,7 @@ struct Berry struct Berry2 { - u8 name[7]; + u8 name[BERRY_NAME_COUNT]; u8 firmness; u16 size; u8 maxYield; @@ -42,7 +45,7 @@ struct Berry2 struct EnigmaBerry { struct Berry2 berry; - u8 itemEffect[18]; + u8 itemEffect[BERRY_ITEM_EFFECT_COUNT]; u8 holdEffect; u8 holdEffectParam; u32 checksum; @@ -50,9 +53,9 @@ struct EnigmaBerry struct BattleEnigmaBerry { - /*0x00*/ u8 name[7]; + /*0x00*/ u8 name[BERRY_NAME_COUNT]; /*0x07*/ u8 holdEffect; - /*0x08*/ u8 itemEffect[18]; + /*0x08*/ u8 itemEffect[BERRY_ITEM_EFFECT_COUNT]; /*0x1A*/ u8 holdEffectParam; }; diff --git a/include/global.h b/include/global.h index 4014c6dde..e0c09d29a 100644 --- a/include/global.h +++ b/include/global.h @@ -198,8 +198,13 @@ struct SaveBlock2 // All below could be a one giant struct /*0x64C*/ u8 field_64C[1629]; - /*0xCA9*/ u8 frontierChosenLvl : 2; - /*0xCA9*/ u8 field_CA9_a : 6; + /*0xCA9*/ u8 frontierChosenLvl : 2; // 0x1, 0x2 -> 0x3 + /*0xCA9*/ u8 field_CA9_a : 1; // 0x4 + /*0xCA9*/ u8 field_CA9_b : 1; // 0x8 + /*0xCA9*/ u8 field_CA9_c : 1; // 0x10 + /*0xCA9*/ u8 field_CA9_d : 1; // 0x20 + /*0xCA9*/ u8 field_CA9_e : 1; // 0x40 + /*0xCA9*/ u8 field_CA9_f : 1; // 0x80 /*0xCAA*/ u8 field_CAA[368]; /*0xE1A*/ u16 battlePyramidFloor; // possibly? /*0xE1C*/ u8 field_E1C[16]; diff --git a/include/link.h b/include/link.h index 5db3ff3d2..012c90480 100644 --- a/include/link.h +++ b/include/link.h @@ -143,7 +143,6 @@ extern u16 word_3002910[]; extern bool8 gReceivedRemoteLinkPlayers; void Task_DestroySelf(u8); -void sub_8007270(u8); void OpenLink(void); void CloseLink(void); u16 LinkMain2(u16 *); @@ -162,24 +161,12 @@ void sub_8007E4C(void); u8 GetMultiplayerId(void); u8 bitmask_all_link_players_but_self(void); bool8 SendBlock(u8, void *, u16); -bool8 sub_8007E9C(u8); -bool8 sub_8007ECC(void); u8 GetBlockReceivedStatus(void); void ResetBlockReceivedFlags(void); void ResetBlockReceivedFlag(u8); -void sub_8007F4C(void); void SetLinkDebugValues(u32, u32); -u8 sub_8008198(void); -void sub_80081C8(u8); -u8 sub_800820C(void); -u8 sub_8008218(void); -void sub_800826C(void); -void sub_80082EC(void); u8 GetLinkPlayerCount_2(void); bool8 IsLinkMaster(void); -void sub_800832C(void); -void sub_8008480(void); -void sub_80084A4(void); void CB2_LinkError(void); u8 GetSioMultiSI(void); bool8 IsLinkConnectionEstablished(void); @@ -191,4 +178,11 @@ void LinkVSync(void); void Timer3Intr(void); void SerialCB(void); +void sub_800E0E8(void); +bool8 sub_800A520(void); +bool8 sub_8010500(void); +void sub_800DFB4(u8, u8); +void sub_800ADF8(void); +u8 sub_8009FCC(void); + #endif // GUARD_LINK_H diff --git a/include/load_save.h b/include/load_save.h index 20848e1a7..1f406bbad 100644 --- a/include/load_save.h +++ b/include/load_save.h @@ -19,5 +19,6 @@ void LoadSerializedGame(void); void LoadPlayerBag(void); void SavePlayerBag(void); void SetSaveBlocksPointers(u16); +void MoveSaveBlocks_ResetHeap(void); #endif // GUARD_LOAD_SAVE_H diff --git a/include/main.h b/include/main.h index e5460b3bf..e283d1754 100644 --- a/include/main.h +++ b/include/main.h @@ -39,6 +39,7 @@ struct Main /*0x439*/ u8 oamLoadDisabled:1; /*0x439*/ u8 inBattle:1; + /*0x439*/ u8 field_439_x4:1; }; extern u8 gUnknown_3001764; diff --git a/include/pokemon.h b/include/pokemon.h index 20e904f39..263a37426 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -439,7 +439,7 @@ struct BattleMove u8 pp; u8 secondaryEffectChance; u8 target; - u8 priority; + s8 priority; u8 flags; }; @@ -632,9 +632,21 @@ void HandleSetPokedexFlag(u16 nationalNum, u8 caseId, u32 personality); s32 sub_806D864(u16 a1); bool16 sub_806D82C(u8 id); u16 MonTryLearningNewMove(struct Pokemon* mon, bool8); +void sub_8068AA4(void); // sets stats for deoxys +bool8 HasTwoFramesAnimation(u16 species); +u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem); +void RandomlyGivePartyPokerus(struct Pokemon *party); +u8 CheckPartyPokerus(struct Pokemon *party, u8 selection); +u8 CheckPartyHasHadPokerus(struct Pokemon *party, u8 selection); +void UpdatePartyPokerusTime(u16 days); +void PartySpreadPokerus(struct Pokemon *party); +s8 GetMonFlavourRelation(struct Pokemon *mon, u8 a2); +s8 GetFlavourRelationByPersonality(u32 personality, u8 a2); #include "sprite.h" void DoMonFrontSpriteAnimation(struct Sprite* sprite, u16 species, bool8 noCry, u8 arg3); +void BattleAnimateFrontSprite(struct Sprite* sprite, u16 species, bool8 noCry, u8 arg3); +void BattleAnimateBackSprite(struct Sprite* sprite, u16 species); #endif // GUARD_POKEMON_H diff --git a/include/recorded_battle.h b/include/recorded_battle.h index d19a2b713..65ad998e6 100644 --- a/include/recorded_battle.h +++ b/include/recorded_battle.h @@ -1,6 +1,19 @@ #ifndef GUARD_RECORDED_BATTLE_H #define GUARD_RECORDED_BATTLE_H +extern u32 gRecordedBattleRngSeed; + +void sub_8185F84(void); +void sub_8184E58(void); void RecordedBattle_SetBankAction(u8 bank, u8 action); +void RecordedBattle_ClearBankAction(u8 bank, u8 bytesToClear); +void sub_8185F90(u16 arg0); +bool8 sub_8186450(void); +u8 sub_8185FAC(void); +u8 sub_8185FB8(void); +u8 MoveRecordedBattleToSaveData(void); +void sub_818603C(u8); +void sub_8185FD0(void); +void sub_8186444(void); #endif // GUARD_RECORDED_BATTLE_H diff --git a/include/save.h b/include/save.h index e98233c67..6c1238cd2 100644 --- a/include/save.h +++ b/include/save.h @@ -76,7 +76,7 @@ u8 GetSaveValidStatus(const struct SaveSectionLocation *location); //u8 sub_8125B88(u8 a1, u8 *data, u16 size); u8 DoReadFlashWholeSection(u8, struct SaveSection *); u16 CalculateChecksum(void *, u16); -//u8 HandleSavingData(u8 saveType); +u8 HandleSavingData(u8 saveType); //u8 TrySavingData(u8 saveType); //u8 sub_8125D80(void); //bool8 sub_8125DA8(void); diff --git a/include/songs.h b/include/songs.h index d828e4068..5a1fff00c 100644 --- a/include/songs.h +++ b/include/songs.h @@ -252,23 +252,23 @@ enum SE_W114, SE_W063B, BGM_STOP = 349, - BGM_TETSUJI, - BGM_FIELD13, - BGM_KACHI22, - BGM_KACHI2, - BGM_KACHI3, - BGM_KACHI5, - BGM_PCC, - BGM_NIBI, - BGM_SUIKUN, - BGM_DOORO1, - BGM_DOORO_X1, - BGM_DOORO_X3, - BGM_MACHI_S2, - BGM_MACHI_S4, - BGM_GIM, - BGM_NAMINORI, - BGM_DAN01, + /*0x15E*/ BGM_TETSUJI, + /*0x15F*/ BGM_FIELD13, + /*0x160*/ BGM_KACHI22, + /*0x161*/ BGM_KACHI2, + /*0x162*/ BGM_KACHI3, + /*0x163*/ BGM_KACHI5, + /*0x164*/ BGM_PCC, + /*0x165*/ BGM_NIBI, + /*0x166*/ BGM_SUIKUN, + /*0x167*/ BGM_DOORO1, + /*0x168*/ BGM_DOORO_X1, + /*0x169*/ BGM_DOORO_X3, + /*0x16A*/ BGM_MACHI_S2, + /*0x16B*/ BGM_MACHI_S4, + /*0x16C*/ BGM_GIM, + /*0x16D*/ BGM_NAMINORI, + /*0x16E*/ BGM_DAN01, /*0x16F*/ BGM_FANFA1, /*0x170*/ BGM_ME_ASA, /*0x171*/ BGM_ME_BACHI, @@ -306,31 +306,31 @@ enum /*0x191*/ BGM_NEXTROAD, /*0x192*/ BGM_GRANROAD, /*0x193*/ BGM_CYCLING, - BGM_FRIENDLY, - BGM_MISHIRO, - BGM_TOZAN, - BGM_GIRLEYE, - BGM_MINAMO, - BGM_ASHROAD, - BGM_EVENT0, - BGM_DEEPDEEP, - BGM_KACHI1, - BGM_TITLE3, - BGM_DEMO1, - BGM_GIRL_SUP, - BGM_HAGESHII, - BGM_KAKKOII, - BGM_KAZANBAI, - BGM_AQA_0, - BGM_TSURETEK, - BGM_BOY_SUP, - BGM_RAINBOW, - BGM_AYASII, - BGM_KACHI4, - BGM_ROPEWAY, - BGM_CASINO, - BGM_HIGHTOWN, - BGM_SAFARI, + /*0x194*/ BGM_FRIENDLY, + /*0x195*/ BGM_MISHIRO, + /*0x196*/ BGM_TOZAN, + /*0x197*/ BGM_GIRLEYE, + /*0x198*/ BGM_MINAMO, + /*0x199*/ BGM_ASHROAD, + /*0x19A*/ BGM_EVENT0, + /*0x19B*/ BGM_DEEPDEEP, + /*0x19C*/ BGM_KACHI1, + /*0x19D*/ BGM_TITLE3, + /*0x19E*/ BGM_DEMO1, + /*0x19F*/ BGM_GIRL_SUP, + /*0x1A0*/ BGM_HAGESHII, + /*0x1A1*/ BGM_KAKKOII, + /*0x1A2*/ BGM_KAZANBAI, + /*0x1A3*/ BGM_AQA_0, + /*0x1A4*/ BGM_TSURETEK, + /*0x1A5*/ BGM_BOY_SUP, + /*0x1A6*/ BGM_RAINBOW, + /*0x1A7*/ BGM_AYASII, + /*0x1A8*/ BGM_KACHI4, + /*0x1A9*/ BGM_ROPEWAY, + /*0x1AA*/ BGM_CASINO, + /*0x1AB*/ BGM_HIGHTOWN, + /*0x1AC*/ BGM_SAFARI, BGM_C_ROAD, BGM_AJITO, BGM_M_BOAT, diff --git a/include/sprite.h b/include/sprite.h index 838b0d7c0..a9377165e 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -212,14 +212,14 @@ struct Sprite u16 flags_5:1; //0x20 u16 flags_6:1; //0x40 u16 flags_7:1; //0x80 - /*0x3F*/ u16 hFlip:1; - u16 vFlip:1; - u16 animBeginning:1; - u16 affineAnimBeginning:1; - u16 animEnded:1; - u16 affineAnimEnded:1; - u16 usingSheet:1; - u16 flags_f:1; + /*0x3F*/ u16 hFlip:1; //1 + u16 vFlip:1; //2 + u16 animBeginning:1; //4 + u16 affineAnimBeginning:1; //8 + u16 animEnded:1; //0x10 + u16 affineAnimEnded:1; //0x20 + u16 usingSheet:1; //0x40 + u16 flags_f:1; //0x80 /*0x40*/ u16 sheetTileStart; diff --git a/include/text.h b/include/text.h index 88f2cc0e2..217de0687 100644 --- a/include/text.h +++ b/include/text.h @@ -85,6 +85,22 @@ #define NUM_TEXT_PRINTERS 32 +struct TextPrinterSubStruct +{ + u8 font_type:4; // 0x14 + u8 font_type_upper:1; + u8 font_type_5:3; + u8 field_1:5; + u8 field_1_upmid:2; + u8 field_1_top:1; + u8 frames_visible_counter; + u8 field_3; + u8 field_4; // 0x18 + u8 field_5; + u8 field_6; + u8 active; +}; + struct TextSubPrinter // TODO: Better name { u8* current_text_offset; @@ -109,20 +125,7 @@ struct TextPrinter void (*callback)(struct TextSubPrinter *, u16); // 0x10 union { - struct TextPrinterSubStruct - { - u8 font_type:4; // 0x14 - u8 font_type_upper:4; - u8 field_1:5; - u8 field_1_upmid:2; - u8 field_1_top:1; - u8 frames_visible_counter; - u8 field_3; - u8 field_4; // 0x18 - u8 field_5; - u8 field_6; - u8 active; - } sub; + struct TextPrinterSubStruct sub; u8 sub_fields[8]; } sub_union; @@ -148,6 +151,8 @@ struct FontInfo u8 shadowColor:4; }; +extern const struct FontInfo *gFonts; + struct GlyphWidthFunc { u32 font_id; @@ -161,6 +166,14 @@ struct KeypadIcon u8 height; }; +typedef struct { + u8 flag_0:1; + u8 flag_1:1; + u8 flag_2:1; +} TextFlags; + +extern TextFlags gTextFlags; + struct __attribute__((packed)) TextColor { u8 fgColor; @@ -173,6 +186,13 @@ extern u8 gStringVar2[]; extern u8 gStringVar3[]; extern u8 gStringVar4[]; +u8 gUnknown_03002F84; +u8 gUnknown_03002F90[0x20]; +u8 gUnknown_03002FB0[0x20]; +u8 gUnknown_03002FD0[0x20]; +u8 gUnknown_03002FF0[0x20]; +u8 gGlyphDimensions[0x2]; + void SetFontsPointer(const struct FontInfo *fonts); void DeactivateAllTextPrinters(void); u16 PrintTextOnWindow(u8 windowId, u8 fontId, u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextSubPrinter *, u16)); @@ -201,8 +221,8 @@ void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter); void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter); void TextPrinterClearDownArrow(struct TextPrinter *textPrinter); bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter); -bool8 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter); -bool8 TextPrinterWait(struct TextPrinter *textPrinter); +bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter); +bool16 TextPrinterWait(struct TextPrinter *textPrinter); void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *counter, u8 *yCoordIndex); u16 RenderText(struct TextPrinter *textPrinter); u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing); diff --git a/include/unknown_task.h b/include/unknown_task.h index f59ca9ac3..9c6968c30 100644 --- a/include/unknown_task.h +++ b/include/unknown_task.h @@ -2,10 +2,21 @@ #define GUARD_unknown_task_H // Exported type declarations +struct UnknownTaskStruct +{ + volatile void *dest; + u32 control; + u8 unk8; + u8 unk9; +}; + +extern struct UnknownTaskStruct gUnknown_0831AC70; // Exported RAM declarations // Exported ROM declarations void remove_some_task(void); +void sub_80BA038(struct UnknownTaskStruct arg0); +void sub_80BA0A8(void); -#endif //GUARD_unknown_task_H +#endif // GUARD_unknown_task_H diff --git a/include/window.h b/include/window.h index 4e814ebc6..b630cd316 100644 --- a/include/window.h +++ b/include/window.h @@ -43,7 +43,7 @@ struct Window bool16 InitWindows(const struct WindowTemplate *templates); u16 AddWindow(const struct WindowTemplate *template); -int AddWindowWithoutTileMap(struct WindowTemplate *template); +int AddWindowWithoutTileMap(const struct WindowTemplate *template); void RemoveWindow(u8 windowId); void FreeAllWindowBuffers(void); void CopyWindowToVram(u8 windowId, u8 mode); diff --git a/ld_script.txt b/ld_script.txt index 2a8ec94db..c3a0441ff 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -57,8 +57,8 @@ SECTIONS { asm/rom3.o(.text); src/decompress.o(.text); asm/battle_1.o(.text); - asm/battle_2.o(.text); - src/battle_3.o(.text); + src/battle_2.o(.text); + src/battle_util.o(.text); src/battle_script_commands.o(.text); asm/battle_5.o(.text); asm/battle_controller_player.o(.text); @@ -110,7 +110,7 @@ SECTIONS { asm/reset_rtc_screen.o(.text); src/start_menu.o(.text); asm/start_menu.o(.text); - asm/tileset.o(.text); + src/tileset_anims.o(.text); src/palette.o(.text); src/sound.o(.text); asm/battle_anim.o(.text); @@ -217,11 +217,11 @@ SECTIONS { asm/hall_of_fame.o(.text); asm/credits.o(.text); src/lottery_corner.o(.text); - asm/diploma.o(.text); + src/diploma.o(.text); asm/berry_tag_screen.o(.text); asm/mystery_event_menu.o(.text); - asm/save_failed_screen.o(.text); - asm/braille_puzzles.o(.text); + src/save_failed_screen.o(.text); + src/braille_puzzles.o(.text); asm/pokeblock_feed.o(.text); asm/clear_save_data_screen.o(.text); asm/intro_credits_graphics.o(.text); @@ -243,11 +243,11 @@ SECTIONS { asm/list_menu.o(.text); asm/menu_indicators.o(.text); asm/unk_text_util.o(.text); - asm/save_location.o(.text); + src/save_location.o(.text); asm/item_icon.o(.text); asm/party_menu.o(.text); asm/battle_tent.o(.text); - asm/unk_text_util_2.o(.text); + src/unk_text_util_2.o(.text); src/multiboot.o(.text); asm/unk_81BAD84.o(.text); asm/battle_controller_player_partner.o(.text); @@ -326,6 +326,8 @@ SECTIONS { data/main_menu.o(.rodata); data/battle_1.o(.rodata); data/data2b.o(.rodata); + src/battle_2.o(.rodata); + src/battle_util.o(.rodata); src/battle_script_commands.o(.rodata); data/battle_controller_player.o(.rodata); data/smokescreen.o(.rodata); @@ -357,8 +359,8 @@ SECTIONS { data/field_tasks.o(.rodata); data/reset_rtc_screen.o(.rodata); data/start_menu.o(.rodata); - data/tileset.o(.rodata); - data/palette.o(.rodata); + src/tileset_anims.o(.rodata); + src/palette.o(.rodata); data/fanfares.o(.rodata); data/battle_anims.o(.rodata); data/title_screen.o(.rodata); @@ -428,11 +430,11 @@ SECTIONS { data/hall_of_fame.o(.rodata); data/credits.o(.rodata); src/lottery_corner.o(.rodata); - data/diploma.o(.rodata); + src/diploma.o(.rodata); data/strings.o(.rodata); data/berry_tag_screen.o(.rodata); data/mystery_event_menu.o(.rodata); - data/save_failed_screen.o(.rodata); + src/save_failed_screen.o(.rodata); data/braille_puzzles.o(.rodata); data/pokeblock_feed.o(.rodata); data/clear_save_data_screen.o(.rodata); @@ -449,11 +451,11 @@ SECTIONS { data/battle_frontier_2.o(.rodata); data/item_menu.o(.rodata); data/menu_indicators.o(.rodata); - data/save_location.o(.rodata); + src/save_location.o(.rodata); data/item_icon.o(.rodata); data/party_menu.o(.rodata); data/battle_tent.o(.rodata); - data/unk_text_util_2.o(.rodata); + src/unk_text_util_2.o(.rodata); data/unk_81BAD84.o(.rodata); data/battle_controller_player_partner.o(.rodata); data/fossil_special_fldeff_groundshake.o(.rodata); diff --git a/src/battle_1.c b/src/battle_1.c new file mode 100644 index 000000000..5e4ef5583 --- /dev/null +++ b/src/battle_1.c @@ -0,0 +1,17 @@ + +// Includes +#include "global.h" + +// Static type declarations + +// Static RAM declarations + +IWRAM_DATA u32 gUnknown_03000DD4; +IWRAM_DATA u32 gUnknown_03000DD8; +IWRAM_DATA u32 gUnknown_03000DDC; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/battle_2.c b/src/battle_2.c new file mode 100644 index 000000000..0462615b8 --- /dev/null +++ b/src/battle_2.c @@ -0,0 +1,5653 @@ +#include "global.h" +#include "battle.h" +#include "recorded_battle.h" +#include "main.h" +#include "load_save.h" +#include "gpu_regs.h" +#include "unknown_task.h" +#include "battle_setup.h" +#include "pokemon.h" +#include "palette.h" +#include "task.h" +#include "event_data.h" +#include "species.h" +#include "berry.h" +#include "text.h" +#include "item.h" +#include "items.h" +#include "hold_effects.h" +#include "link.h" +#include "bg.h" +#include "dma3.h" +#include "string_util.h" +#include "malloc.h" +#include "event_data.h" +#include "m4a.h" +#include "window.h" +#include "rng.h" +#include "songs.h" +#include "sound.h" +#include "battle_message.h" +#include "sprite.h" +#include "util.h" +#include "trig.h" +#include "battle_ai_script_commands.h" +#include "battle_move_effects.h" +#include "battle_controllers.h" +#include "pokedex.h" +#include "abilities.h" +#include "moves.h" +#include "trainer_classes.h" +#include "evolution_scene.h" +#include "roamer.h" +#include "safari_zone.h" + +struct UnknownStruct6 +{ + u16 unk0[0xA0]; + u8 fillerA0[0x640]; + u16 unk780[0xA0]; +}; + +struct UnknownPokemonStruct2 +{ + /*0x00*/ u16 species; + /*0x02*/ u16 heldItem; + /*0x04*/ u8 nickname[POKEMON_NAME_LENGTH + 1]; + /*0x0F*/ u8 level; + /*0x10*/ u16 hp; + /*0x12*/ u16 maxhp; + /*0x14*/ u32 status; + /*0x18*/ u32 personality; + /*0x1C*/ u8 gender; + /*0x1D*/ u8 language; +}; + +extern u32 gBattleTypeFlags; +extern u8 gBattleCommunication[]; +extern u8 gBattleTerrain; +extern u16 gBattle_BG0_X; +extern u16 gBattle_BG0_Y; +extern u16 gBattle_BG1_X; +extern u16 gBattle_BG1_Y; +extern u16 gBattle_BG2_X; +extern u16 gBattle_BG2_Y; +extern u16 gBattle_BG3_X; +extern u16 gBattle_BG3_Y; +extern u16 gPartnerTrainerId; +extern u16 gBattle_WIN0H; +extern u16 gBattle_WIN0V; +extern u16 gBattle_WIN1H; +extern u16 gBattle_WIN1V; +extern u16 gTrainerBattleOpponent_A; +extern u16 gTrainerBattleOpponent_B; +extern struct BattleEnigmaBerry gEnigmaBerries[BATTLE_BANKS_COUNT]; +extern void (*gPreBattleCallback1)(void); +extern void (*gBattleMainFunc)(void); +extern void (*gUnknown_030061E8)(void); +extern struct UnknownPokemonStruct2 gUnknown_02022FF8[3]; // what is it used for? +extern struct UnknownPokemonStruct2* gUnknown_02023058; // what is it used for? +extern u8 gBattleOutcome; +extern u8 gUnknown_02039B28[]; // possibly a struct? +extern struct UnknownStruct6 gUnknown_02038C28; // todo: identify & document +extern struct MusicPlayerInfo gMPlay_SE1; +extern struct MusicPlayerInfo gMPlay_SE2; +extern u8 gDecompressionBuffer[]; +extern u16 gUnknown_020243FC; +extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; +extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); +extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; +extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; +extern u8 gStringBank; +extern u32 gUnknown_02022F88; +extern u32 gHitMarker; +extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; +extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; +extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; +extern u16 gPaydayMoney; +extern u16 gBattleWeather; +extern u16 gPauseCounterBattle; +extern u16 gRandomTurnNumber; +extern u8 gActiveBank; +extern u8 gNoOfAllBanks; +extern u8 gBankAttacker; +extern u8 gBankTarget; +extern u8 gLeveledUpInBattle; +extern u8 gAbsentBankFlags; +extern u32 gBattleExecBuffer; +extern u8 gMultiHitCounter; +extern u8 gBattleMoveFlags; +extern s32 gBattleMoveDamage; +extern const u8* gUnknown_02024230[BATTLE_BANKS_COUNT]; +extern u16 gUnknownMovesUsedByBanks[BATTLE_BANKS_COUNT]; +extern u16 gLastUsedMovesByBanks[BATTLE_BANKS_COUNT]; +extern u16 gUnknown_02024250[BATTLE_BANKS_COUNT]; +extern u16 gUnknown_02024258[BATTLE_BANKS_COUNT]; +extern u16 gUnknown_02024260[BATTLE_BANKS_COUNT]; +extern u16 gLockedMoves[BATTLE_BANKS_COUNT]; +extern u8 gUnknown_02024270[BATTLE_BANKS_COUNT]; +extern u8 gUnknown_02024284[BATTLE_BANKS_COUNT]; +extern u32 gStatuses3[BATTLE_BANKS_COUNT]; +extern u16 gSideAffecting[2]; +extern u16 gCurrentMove; +extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; +extern u8 gMoveSelectionCursor[BATTLE_BANKS_COUNT]; +extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; +extern u8 gBanksByTurnOrder[BATTLE_BANKS_COUNT]; +extern u8 gActionForBanks[BATTLE_BANKS_COUNT]; +extern u16 gChosenMovesByBanks[BATTLE_BANKS_COUNT]; +extern u8 gCurrentActionFuncId; +extern u8 gLastUsedAbility; +extern u16 gLastUsedItem; +extern u8 gUnknown_0203CF00[]; +extern const u8* gBattlescriptPtrsForSelection[BATTLE_BANKS_COUNT]; +extern const u8* gBattlescriptCurrInstr; +extern u32 gBattlePalaceMoveSelectionRngValue; +extern u8 gActionsByTurnOrder[BATTLE_BANKS_COUNT]; +extern u8 gCurrentTurnActionNumber; +extern u16 gDynamicBasePower; +extern u8 gCritMultiplier; +extern u8 gCurrMovePos; +extern u8 gUnknown_020241E9; +extern u16 gLastUsedMove; + +extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1]; +extern const struct BattleMove gBattleMoves[]; +extern const u16 gUnknown_08C004E0[]; // battle textbox palette +extern const struct BgTemplate gUnknown_0831AA08[]; +extern const struct WindowTemplate * const gUnknown_0831ABA0[]; +extern const u8 gUnknown_0831ACE0[]; +extern const u8 gStatStageRatios[][2]; +extern const u8 * const gBattleScriptsForMoveEffects[]; +extern const u8 * const gBattlescriptsForBallThrow[]; +extern const u8 * const gBattlescriptsForRunningByItem[]; +extern const u8 * const gUnknown_082DBD3C[]; +extern const u8 * const gBattlescriptsForSafariActions[]; + +// strings +extern const u8 gText_LinkStandby3[]; +extern const u8 gText_RecordBattleToPass[]; +extern const u8 gText_BattleYesNoChoice[]; +extern const u8 gText_BattleRecordCouldntBeSaved[]; +extern const u8 gText_BattleRecordedOnPass[]; +extern const u8 gText_ShedinjaJapaneseName[]; +extern const u8 gText_EmptyString3[]; +extern const u8 gText_Poison[]; +extern const u8 gText_Sleep[]; +extern const u8 gText_Paralysis[]; +extern const u8 gText_Burn[]; +extern const u8 gText_Ice[]; +extern const u8 gText_Confusion[]; +extern const u8 gText_Love[]; + +// battlescripts +extern const u8 gUnknown_082DB8BE[]; +extern const u8 gUnknown_082DB881[]; +extern const u8 BattleScript_ActionSelectionItemsCantBeUsed[]; +extern const u8 gUnknown_082DAB11[]; +extern const u8 gUnknown_082DB9BA[]; +extern const u8 gUnknown_082DAAFE[]; +extern const u8 gUnknown_082DAB0B[]; +extern const u8 BattleScript_FocusPunchSetUp[]; +extern const u8 BattleScript_LinkBattleWonOrLost[]; +extern const u8 BattleScript_FrontierTrainerBattleWon[]; +extern const u8 BattleScript_LocalTrainerBattleWon[]; +extern const u8 BattleScript_PayDayMoneyAndPickUpItems[]; +extern const u8 BattleScript_LocalBattleLost[]; +extern const u8 gUnknown_082DB9C8[]; +extern const u8 gUnknown_082DAA0B[]; +extern const u8 gUnknown_082DB9C1[]; +extern const u8 BattleScript_RanAwayUsingMonAbility[]; +extern const u8 BattleScript_SmokeBallEscape[]; +extern const u8 BattleScript_GotAwaySafely[]; +extern const u8 BattleScript_WildMonFled[]; +extern const u8 BattleScript_MoveUsedLoafingAround[]; +extern const u8 BattleScript_ActionSwitch[]; +extern const u8 BattleScript_PrintFailedToRunString[]; + +// functions +extern void HandleLinkBattleSetup(void); // rom_3 +extern void SetUpBattleVarsAndBirchZigzagoon(void); // rom_3 +extern void sub_8032768(void); // rom_3 +extern void dp12_8087EA4(void); +extern void sub_80356D0(void); +extern void GetFrontierTrainerName(u8* dst, u16 trainerId); // battle tower +extern void sub_8166188(void); // battle tower, sets link battle mons level but why? +extern void sub_8165B88(u8* dst, u16 trainerId); // battle tower, gets language +extern void sub_81DB4DC(u8* dst, u8 arg2); // +extern void sub_81B9150(void); +extern void sub_800AC34(void); +extern void sub_80B3AF8(u8 taskId); // cable club +extern void sub_8076918(u8 bank); +extern void sub_80729D0(u8 healthoxSpriteId); +extern void sub_81A56B4(void); // battle frontier 2 +extern u8 sub_81A9E28(void); // battle frontier 2 +extern void sub_81A56E8(u8 bank); // battle frontier 2 +extern void sub_81B8FB0(u8, u8); // party menu +extern u8 pokemon_order_func(u8); // party menu +extern void sub_80EC728(void); // tv +extern void sub_80EE184(void); // tv +extern bool8 InBattlePyramid(void); + +// this file's functions +static void CB2_InitBattleInternal(void); +static void CB2_PreInitMultiBattle(void); +static void CB2_PreInitIngamePlayerPartnerBattle(void); +static void CB2_HandleStartMultiPartnerBattle(void); +static void CB2_HandleStartMultiBattle(void); +static void CB2_HandleStartBattle(void); +static void TryCorrectShedinjaLanguage(struct Pokemon *mon); +static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 firstTrainer); +static void BattleMainCB1(void); +static void sub_8038538(struct Sprite *sprite); +static void sub_8038F14(void); +static void sub_8038F34(void); +static void sub_80392A8(void); +static void sub_803937C(void); +static void sub_803939C(void); +void oac_poke_opponent(struct Sprite *sprite); +static void sub_803980C(struct Sprite *sprite); +static void sub_8039838(struct Sprite *sprite); +static void sub_8039894(struct Sprite *sprite); +static void sub_80398D0(struct Sprite *sprite); +static void sub_8039A48(struct Sprite *sprite); +static void sub_8039AF4(struct Sprite *sprite); +static void SpriteCallbackDummy_3(struct Sprite *sprite); +static void oac_poke_ally_(struct Sprite *sprite); +static void SpecialStatusesClear(void); +static void TurnValuesCleanUp(bool8 var0); +static void SpriteCB_HealthBoxBounce(struct Sprite *sprite); +static void BattleStartClearSetData(void); +static void BattleIntroGetMonsData(void); +static void BattleIntroPrepareBackgroundSlide(void); +static void BattleIntroDrawTrainersOrMonsSprites(void); +static void BattleIntroDrawPartySummaryScreens(void); +static void BattleIntroPrintTrainerWantsToBattle(void); +static void BattleIntroPrintWildMonAttacked(void); +static void BattleIntroPrintOpponentSendsOut(void); +static void BattleIntroPrintPlayerSendsOut(void); +static void BattleIntroOpponent1SendsOutMonAnimation(void); +static void BattleIntroOpponent2SendsOutMonAnimation(void); +static void BattleIntroRecordMonsToDex(void); +static void BattleIntroPlayer1SendsOutMonAnimation(void); +static void TryDoEventsBeforeFirstTurn(void); +static void HandleTurnActionSelectionState(void); +static void RunTurnActionsFunctions(void); +static void SetActionsAndBanksTurnOrder(void); +static void sub_803CDF8(void); +static bool8 sub_803CDB8(void); +static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void); +static void FreeResetData_ReturnToOvOrDoEvolutions(void); +static void ReturnFromBattleToOverworld(void); +static void TryEvolvePokemon(void); +static void WaitForEvoSceneToFinish(void); +static void HandleEndTurn_ContinueBattle(void); +static void HandleEndTurn_BattleWon(void); +static void HandleEndTurn_BattleLost(void); +static void HandleEndTurn_RanFromBattle(void); +static void HandleEndTurn_MonFled(void); +static void HandleEndTurn_FinishBattle(void); +static void HandleAction_UseMove(void); +static void HandleAction_Switch(void); +static void HandleAction_UseItem(void); +static void HandleAction_Run(void); +static void HandleAction_WatchesCarefully(void); +static void HandleAction_SafariZoneBallThrow(void); +static void HandleAction_ThrowPokeblock(void); +static void HandleAction_GoNear(void); +static void HandleAction_SafriZoneRun(void); +static void HandleAction_Action9(void); +static void HandleAction_Action11(void); +static void HandleAction_NothingIsFainted(void); +static void HandleAction_ActionFinished(void); + +// rom const data +static void (* const sTurnActionsFuncsTable[])(void) = +{ + HandleAction_UseMove, // ACTION_USE_MOVE + HandleAction_UseItem, // ACTION_USE_ITEM + HandleAction_Switch, // ACTION_SWITCH + HandleAction_Run, // ACTION_RUN + HandleAction_WatchesCarefully, // ACTION_WATCHES_CAREFULLY + HandleAction_SafariZoneBallThrow, // ACTION_SAFARI_ZONE_BALL + HandleAction_ThrowPokeblock, // ACTION_POKEBLOCK_CASE + HandleAction_GoNear, // ACTION_GO_NEAR + HandleAction_SafriZoneRun, // ACTION_SAFARI_ZONE_RUN + HandleAction_Action9, // ACTION_9 + HandleAction_RunBattleScript, // ACTION_RUN_BATTLESCRIPT + HandleAction_Action11, // not sure about this one + HandleAction_ActionFinished, // ACTION_FINISHED + HandleAction_NothingIsFainted, // ACTION_NOTHING_FAINTED +}; + +static void (* const sEndTurnFuncsTable[])(void) = +{ + HandleEndTurn_ContinueBattle, // battle outcome 0 + HandleEndTurn_BattleWon, // BATTLE_WON + HandleEndTurn_BattleLost, // BATTLE_LOST + HandleEndTurn_BattleLost, // BATTLE_DREW + HandleEndTurn_RanFromBattle, // BATTLE_RAN + HandleEndTurn_FinishBattle, // BATTLE_PLAYER_TELEPORTED + HandleEndTurn_MonFled, // BATTLE_POKE_FLED + HandleEndTurn_FinishBattle, // BATTLE_CAUGHT + HandleEndTurn_FinishBattle, // battle outcome 8 + HandleEndTurn_FinishBattle, // BATTLE_FORFEITED + HandleEndTurn_FinishBattle, // BATTLE_OPPONENT_TELEPORTED +}; + +const u8 gStatusConditionString_PoisonJpn[8] = _("どく$$$$$"); +const u8 gStatusConditionString_SleepJpn[8] = _("ねむり$$$$"); +const u8 gStatusConditionString_ParalysisJpn[8] = _("まひ$$$$$"); +const u8 gStatusConditionString_BurnJpn[8] = _("やけど$$$$"); +const u8 gStatusConditionString_IceJpn[8] = _("こおり$$$$"); +const u8 gStatusConditionString_ConfusionJpn[8] = _("こんらん$$$"); +const u8 gStatusConditionString_LoveJpn[8] = _("メロメロ$$$"); + +const u8 * const gStatusConditionStringsTable[][2] = +{ + {gStatusConditionString_PoisonJpn, gText_Poison}, + {gStatusConditionString_SleepJpn, gText_Sleep}, + {gStatusConditionString_ParalysisJpn, gText_Paralysis}, + {gStatusConditionString_BurnJpn, gText_Burn}, + {gStatusConditionString_IceJpn, gText_Ice}, + {gStatusConditionString_ConfusionJpn, gText_Confusion}, + {gStatusConditionString_LoveJpn, gText_Love} +}; + +static const u8 sUnknown_0831BCE0[][3] = {{0, 0, 0}, {3, 5, 0}, {2, 3, 0}, {1, 2, 0}, {1, 1, 0}}; +static const u8 sUnknown_0831BCEF[] = {4, 3, 2, 1}; +static const u8 sUnknown_0831BCF3[] = {4, 4, 4, 4}; + +void CB2_InitBattle(void) +{ + MoveSaveBlocks_ResetHeap(); + AllocateBattleResrouces(); + AllocateBattleSpritesData(); + AllocateMonSpritesGfx(); + sub_8185F84(); + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) + { + CB2_InitBattleInternal(); + } + else if (!(gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)) + { + HandleLinkBattleSetup(); + SetMainCallback2(CB2_PreInitMultiBattle); + } + else + { + SetMainCallback2(CB2_PreInitIngamePlayerPartnerBattle); + } + gBattleCommunication[MULTIUSE_STATE] = 0; + } + else + { + CB2_InitBattleInternal(); + } +} + +static void CB2_InitBattleInternal(void) +{ + s32 i; + + SetHBlankCallback(NULL); + SetVBlankCallback(NULL); + + CpuFill32(0, (void*)(VRAM), VRAM_SIZE); + + SetGpuReg(REG_OFFSET_MOSAIC, 0); + SetGpuReg(REG_OFFSET_WIN0H, 240); + SetGpuReg(REG_OFFSET_WIN0V, 0x5051); + SetGpuReg(REG_OFFSET_WININ, 0); + SetGpuReg(REG_OFFSET_WINOUT, 0); + + gBattle_WIN0H = 240; + + if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId != STEVEN_PARTNER_ID) + { + gBattle_WIN0V = 159; + gBattle_WIN1H = 240; + gBattle_WIN1V = 32; + } + else + { + gBattle_WIN0V = 0x5051; + dp12_8087EA4(); + + for (i = 0; i < 80; i++) + { + gUnknown_02038C28.unk0[i] = 0xF0; + gUnknown_02038C28.unk780[i] = 0xF0; + } + for (i = 80; i < 160; i++) + { + #ifndef NONMATCHING + asm(""::"r"(i)); // needed to match + #endif // NONMATCHING + + gUnknown_02038C28.unk0[i] = 0xFF10; + gUnknown_02038C28.unk780[i] = 0xFF10; + } + + sub_80BA038(gUnknown_0831AC70); + } + + ResetPaletteFade(); + gBattle_BG0_X = 0; + gBattle_BG0_Y = 0; + gBattle_BG1_X = 0; + gBattle_BG1_Y = 0; + gBattle_BG2_X = 0; + gBattle_BG2_Y = 0; + gBattle_BG3_X = 0; + gBattle_BG3_Y = 0; + + gBattleTerrain = BattleSetup_GetTerrainId(); + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) + gBattleTerrain = BATTLE_TERRAIN_INSIDE; + + sub_80356D0(); + LoadBattleTextboxAndBackground(); + ResetSpriteData(); + ResetTasks(); + LoadBattleEntryBackground(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 4; + SetVBlankCallback(VBlankCB_Battle); + SetUpBattleVarsAndBirchZigzagoon(); + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) + SetMainCallback2(CB2_HandleStartMultiPartnerBattle); + else if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) + SetMainCallback2(CB2_HandleStartMultiPartnerBattle); + else if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + SetMainCallback2(CB2_HandleStartMultiBattle); + else + SetMainCallback2(CB2_HandleStartBattle); + + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED))) + { + CreateNPCTrainerParty(&gEnemyParty[0], gTrainerBattleOpponent_A, TRUE); + if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) + CreateNPCTrainerParty(&gEnemyParty[3], gTrainerBattleOpponent_B, FALSE); + SetWildMonHeldItem(); + } + + gMain.inBattle = TRUE; + gSaveBlock2Ptr->field_CA9_b = 0; + + for (i = 0; i < 6; i++) + AdjustFriendship(&gPlayerParty[i], 3); + + gBattleCommunication[MULTIUSE_STATE] = 0; +} + +static void sub_8036A5C(void) +{ + u16 r6 = 0; + u16 species = 0; + u16 hp = 0; + u32 status = 0; + s32 i; + + for (i = 0; i < 6; i++) + { + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + hp = GetMonData(&gPlayerParty[i], MON_DATA_HP); + status = GetMonData(&gPlayerParty[i], MON_DATA_STATUS); + + if (species == SPECIES_NONE) + continue; + if (species != SPECIES_EGG && hp != 0 && status == 0) + r6 |= 1 << i * 2; + + if (species == SPECIES_NONE) + continue; + if (hp != 0 && (species == SPECIES_EGG || status != 0)) + r6 |= 2 << i * 2; + + if (species == SPECIES_NONE) + continue; + if (species != SPECIES_EGG && hp == 0) + r6 |= 3 << i * 2; + } + + gBattleStruct->field_182 = r6; + *(&gBattleStruct->field_183) = r6 >> 8; + gBattleStruct->field_183 |= FlagGet(SYS_FRONTIER_PASS) << 7; +} + +static void SetPlayerBerryDataInBattleStruct(void) +{ + s32 i; + struct BattleStruct *battleStruct = gBattleStruct; + struct BattleEnigmaBerry *battleBerry = &battleStruct->battleEnigmaBerry; + + if (IsEnigmaBerryValid() == TRUE) + { + for (i = 0; i < BERRY_NAME_COUNT - 1; i++) + battleBerry->name[i] = gSaveBlock1Ptr->enigmaBerry.berry.name[i]; + battleBerry->name[i] = EOS; + + for (i = 0; i < BERRY_ITEM_EFFECT_COUNT; i++) + battleBerry->itemEffect[i] = gSaveBlock1Ptr->enigmaBerry.itemEffect[i]; + + battleBerry->holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect; + battleBerry->holdEffectParam = gSaveBlock1Ptr->enigmaBerry.holdEffectParam; + } + else + { + const struct Berry* berryData = GetBerryInfo(ItemIdToBerryType(ITEM_ENIGMA_BERRY)); + + for (i = 0; i < BERRY_NAME_COUNT - 1; i++) + battleBerry->name[i] = berryData->name[i]; + battleBerry->name[i] = EOS; + + for (i = 0; i < BERRY_ITEM_EFFECT_COUNT; i++) + battleBerry->itemEffect[i] = 0; + + battleBerry->holdEffect = HOLD_EFFECT_NONE; + battleBerry->holdEffectParam = 0; + } +} + +static void SetAllPlayersBerryData(void) +{ + s32 i; + s32 j; + + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) + { + if (IsEnigmaBerryValid() == TRUE) + { + for (i = 0; i < BERRY_NAME_COUNT - 1; i++) + { + gEnigmaBerries[0].name[i] = gSaveBlock1Ptr->enigmaBerry.berry.name[i]; + gEnigmaBerries[2].name[i] = gSaveBlock1Ptr->enigmaBerry.berry.name[i]; + } + gEnigmaBerries[0].name[i] = EOS; + gEnigmaBerries[2].name[i] = EOS; + + for (i = 0; i < BERRY_ITEM_EFFECT_COUNT; i++) + { + gEnigmaBerries[0].itemEffect[i] = gSaveBlock1Ptr->enigmaBerry.itemEffect[i]; + gEnigmaBerries[2].itemEffect[i] = gSaveBlock1Ptr->enigmaBerry.itemEffect[i]; + } + + gEnigmaBerries[0].holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect; + gEnigmaBerries[2].holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect; + gEnigmaBerries[0].holdEffectParam = gSaveBlock1Ptr->enigmaBerry.holdEffectParam; + gEnigmaBerries[2].holdEffectParam = gSaveBlock1Ptr->enigmaBerry.holdEffectParam; + } + else + { + const struct Berry* berryData = GetBerryInfo(ItemIdToBerryType(ITEM_ENIGMA_BERRY)); + + for (i = 0; i < BERRY_NAME_COUNT - 1; i++) + { + gEnigmaBerries[0].name[i] = berryData->name[i]; + gEnigmaBerries[2].name[i] = berryData->name[i]; + } + gEnigmaBerries[0].name[i] = EOS; + gEnigmaBerries[2].name[i] = EOS; + + for (i = 0; i < BERRY_ITEM_EFFECT_COUNT; i++) + { + gEnigmaBerries[0].itemEffect[i] = 0; + gEnigmaBerries[2].itemEffect[i] = 0; + } + + gEnigmaBerries[0].holdEffect = 0; + gEnigmaBerries[2].holdEffect = 0; + gEnigmaBerries[0].holdEffectParam = 0; + gEnigmaBerries[2].holdEffectParam = 0; + } + } + else + { + s32 numPlayers; + struct BattleEnigmaBerry *src; + u8 r4; + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + if (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) + numPlayers = 2; + else + numPlayers = 4; + + for (i = 0; i < numPlayers; i++) + { + src = (struct BattleEnigmaBerry *)(gBlockRecvBuffer[i] + 2); + r4 = gLinkPlayers[i].lp_field_18; + + for (j = 0; j < BERRY_NAME_COUNT - 1; j++) + gEnigmaBerries[r4].name[j] = src->name[j]; + gEnigmaBerries[r4].name[j] = EOS; + + for (j = 0; j < BERRY_ITEM_EFFECT_COUNT; j++) + gEnigmaBerries[r4].itemEffect[j] = src->itemEffect[j]; + + gEnigmaBerries[r4].holdEffect = src->holdEffect; + gEnigmaBerries[r4].holdEffectParam = src->holdEffectParam; + } + } + else + { + for (i = 0; i < 2; i++) + { + src = (struct BattleEnigmaBerry *)(gBlockRecvBuffer[i] + 2); + + for (j = 0; j < BERRY_NAME_COUNT - 1; j++) + { + gEnigmaBerries[i].name[j] = src->name[j]; + gEnigmaBerries[i + 2].name[j] = src->name[j]; + } + gEnigmaBerries[i].name[j] = EOS; + gEnigmaBerries[i + 2].name[j] = EOS; + + for (j = 0; j < BERRY_ITEM_EFFECT_COUNT; j++) + { + gEnigmaBerries[i].itemEffect[j] = src->itemEffect[j]; + gEnigmaBerries[i + 2].itemEffect[j] = src->itemEffect[j]; + } + + gEnigmaBerries[i].holdEffect = src->holdEffect; + gEnigmaBerries[i + 2].holdEffect = src->holdEffect; + gEnigmaBerries[i].holdEffectParam = src->holdEffectParam; + gEnigmaBerries[i + 2].holdEffectParam = src->holdEffectParam; + } + } + } +} + +static void sub_8036EB8(u8 arg0, u8 arg1) +{ + u8 var = 0; + + if (gBlockRecvBuffer[0][0] == 256) + { + if (arg1 == 0) + gBattleTypeFlags |= BATTLE_TYPE_WILD | BATTLE_TYPE_TRAINER; + else + gBattleTypeFlags |= BATTLE_TYPE_TRAINER; + var++; + } + + if (var == 0) + { + s32 i; + + for (i = 0; i < arg0; i++) + { + if (gBlockRecvBuffer[0][0] != gBlockRecvBuffer[i][0]) + break; + } + + if (i == arg0) + { + if (arg1 == 0) + gBattleTypeFlags |= BATTLE_TYPE_WILD | BATTLE_TYPE_TRAINER; + else + gBattleTypeFlags |= BATTLE_TYPE_TRAINER; + var++; + } + + if (var == 0) + { + for (i = 0; i < arg0; i++) + { + if (gBlockRecvBuffer[i][0] == 0x300) + { + if (i != arg1 && i < arg1) + break; + } + if (gBlockRecvBuffer[i][0] > 0x300 && i != arg1) + break; + } + + if (i == arg0) + gBattleTypeFlags |= BATTLE_TYPE_WILD | BATTLE_TYPE_TRAINER; + else + gBattleTypeFlags |= BATTLE_TYPE_TRAINER; + } + } +} + +static void CB2_HandleStartBattle(void) +{ + u8 playerMultiplayerId; + u8 enemyMultiplayerId; + + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + + playerMultiplayerId = GetMultiplayerId(); + gBattleScripting.multiplayerId = playerMultiplayerId; + enemyMultiplayerId = playerMultiplayerId ^ BIT_SIDE; + + switch (gBattleCommunication[MULTIUSE_STATE]) + { + case 0: + if (!IsDma3ManagerBusyWithBgCopy()) + { + ShowBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + sub_805EF14(); + gBattleCommunication[MULTIUSE_STATE] = 1; + } + if (gLinkVSyncDisabled) + sub_800E0E8(); + break; + case 1: + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + if (gReceivedRemoteLinkPlayers != 0) + { + if (sub_800A520()) + { + *(&gBattleStruct->field_180) = 0; + *(&gBattleStruct->field_181) = 3; + sub_8036A5C(); + SetPlayerBerryDataInBattleStruct(); + + if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_C00) + { + gLinkPlayers[0].lp_field_18 = 0; + gLinkPlayers[1].lp_field_18 = 1; + } + + SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->field_180, 32); + gBattleCommunication[MULTIUSE_STATE] = 2; + } + if (gLinkVSyncDisabled) + sub_800DFB4(0, 0); + } + } + else + { + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) + gBattleTypeFlags |= BATTLE_TYPE_WILD; + gBattleCommunication[MULTIUSE_STATE] = 15; + SetAllPlayersBerryData(); + } + break; + case 2: + if ((GetBlockReceivedStatus() & 3) == 3) + { + u8 taskId; + + ResetBlockReceivedFlags(); + sub_8036EB8(2, playerMultiplayerId); + SetAllPlayersBerryData(); + taskId = CreateTask(task00_0800F6FC, 0); + gTasks[taskId].data[1] = 0x10E; + gTasks[taskId].data[2] = 0x5A; + gTasks[taskId].data[5] = 0; + gTasks[taskId].data[3] = gBattleStruct->field_182 | (gBattleStruct->field_183 << 8); + gTasks[taskId].data[4] = gBlockRecvBuffer[enemyMultiplayerId][1]; + sub_8185F90(gBlockRecvBuffer[playerMultiplayerId][1]); + sub_8185F90(gBlockRecvBuffer[enemyMultiplayerId][1]); + sub_8068AA4(); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 3: + if (sub_800A520()) + { + SendBlock(bitmask_all_link_players_but_self(), gPlayerParty, sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 4: + if ((GetBlockReceivedStatus() & 3) == 3) + { + ResetBlockReceivedFlags(); + memcpy(gEnemyParty, gBlockRecvBuffer[enemyMultiplayerId], sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 7: + if (sub_800A520()) + { + SendBlock(bitmask_all_link_players_but_self(), gPlayerParty + 2, sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 8: + if ((GetBlockReceivedStatus() & 3) == 3) + { + ResetBlockReceivedFlags(); + memcpy(gEnemyParty + 2, gBlockRecvBuffer[enemyMultiplayerId], sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 11: + if (sub_800A520()) + { + SendBlock(bitmask_all_link_players_but_self(), gPlayerParty + 4, sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 12: + if ((GetBlockReceivedStatus() & 3) == 3) + { + ResetBlockReceivedFlags(); + memcpy(gEnemyParty + 4, gBlockRecvBuffer[enemyMultiplayerId], sizeof(struct Pokemon) * 2); + TryCorrectShedinjaLanguage(&gEnemyParty[0]); + TryCorrectShedinjaLanguage(&gEnemyParty[1]); + TryCorrectShedinjaLanguage(&gEnemyParty[2]); + TryCorrectShedinjaLanguage(&gEnemyParty[3]); + TryCorrectShedinjaLanguage(&gEnemyParty[4]); + TryCorrectShedinjaLanguage(&gEnemyParty[5]); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 15: + sub_8032768(); + sub_8184E58(); + gBattleCommunication[SPRITES_INIT_STATE1] = 0; + gBattleCommunication[SPRITES_INIT_STATE2] = 0; + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + s32 i; + + for (i = 0; i < 2 && (gLinkPlayers[i].version & 0xFF) == 3; i++); + + if (i == 2) + gBattleCommunication[MULTIUSE_STATE] = 16; + else + gBattleCommunication[MULTIUSE_STATE] = 18; + } + else + { + gBattleCommunication[MULTIUSE_STATE] = 18; + } + break; + case 16: + if (sub_800A520()) + { + SendBlock(bitmask_all_link_players_but_self(), &gRecordedBattleRngSeed, sizeof(gRecordedBattleRngSeed)); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 17: + if ((GetBlockReceivedStatus() & 3) == 3) + { + ResetBlockReceivedFlags(); + if (!(gBattleTypeFlags & BATTLE_TYPE_WILD)) + memcpy(&gRecordedBattleRngSeed, gBlockRecvBuffer[enemyMultiplayerId], sizeof(gRecordedBattleRngSeed)); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 18: + if (BattleInitAllSprites(&gBattleCommunication[SPRITES_INIT_STATE1], &gBattleCommunication[SPRITES_INIT_STATE2])) + { + gPreBattleCallback1 = gMain.callback1; + gMain.callback1 = BattleMainCB1; + SetMainCallback2(BattleMainCB2); + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + gBattleTypeFlags |= BATTLE_TYPE_20; + } + } + break; + case 5: + case 9: + case 13: + gBattleCommunication[MULTIUSE_STATE]++; + gBattleCommunication[1] = 1; + case 6: + case 10: + case 14: + if (--gBattleCommunication[1] == 0) + gBattleCommunication[MULTIUSE_STATE]++; + break; + } +} + +static void CB2_HandleStartMultiPartnerBattle(void) +{ + u8 playerMultiplayerId; + u8 enemyMultiplayerId; + + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + + playerMultiplayerId = GetMultiplayerId(); + gBattleScripting.multiplayerId = playerMultiplayerId; + enemyMultiplayerId = playerMultiplayerId ^ BIT_SIDE; + + switch (gBattleCommunication[MULTIUSE_STATE]) + { + case 0: + if (!IsDma3ManagerBusyWithBgCopy()) + { + ShowBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + sub_805EF14(); + gBattleCommunication[MULTIUSE_STATE] = 1; + } + if (gLinkVSyncDisabled) + sub_800E0E8(); + // fall through + case 1: + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + if (gReceivedRemoteLinkPlayers != 0) + { + u8 language; + + gLinkPlayers[0].lp_field_18 = 0; + gLinkPlayers[1].lp_field_18 = 2; + gLinkPlayers[2].lp_field_18 = 1; + gLinkPlayers[3].lp_field_18 = 3; + GetFrontierTrainerName(gLinkPlayers[2].name, gTrainerBattleOpponent_A); + GetFrontierTrainerName(gLinkPlayers[3].name, gTrainerBattleOpponent_B); + sub_8165B88(&language, gTrainerBattleOpponent_A); + gLinkPlayers[2].language = language; + sub_8165B88(&language, gTrainerBattleOpponent_B); + gLinkPlayers[3].language = language; + + if (sub_800A520()) + { + *(&gBattleStruct->field_180) = 0; + *(&gBattleStruct->field_181) = 3; + sub_8036A5C(); + SetPlayerBerryDataInBattleStruct(); + SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->field_180, 32); + gBattleCommunication[MULTIUSE_STATE] = 2; + } + + if (gLinkVSyncDisabled) + sub_800DFB4(0, 0); + } + } + else + { + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) + gBattleTypeFlags |= BATTLE_TYPE_WILD; + gBattleCommunication[MULTIUSE_STATE] = 13; + SetAllPlayersBerryData(); + } + break; + case 2: + if ((GetBlockReceivedStatus() & 3) == 3) + { + u8 taskId; + + ResetBlockReceivedFlags(); + sub_8036EB8(2, playerMultiplayerId); + SetAllPlayersBerryData(); + taskId = CreateTask(task00_0800F6FC, 0); + gTasks[taskId].data[1] = 0x10E; + gTasks[taskId].data[2] = 0x5A; + gTasks[taskId].data[5] = 0; + gTasks[taskId].data[3] = 0x145; + gTasks[taskId].data[4] = 0x145; + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 3: + if (sub_800A520()) + { + SendBlock(bitmask_all_link_players_but_self(), gPlayerParty, sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 4: + if ((GetBlockReceivedStatus() & 3) == 3) + { + ResetBlockReceivedFlags(); + if (gLinkPlayers[playerMultiplayerId].lp_field_18 != 0) + { + memcpy(gPlayerParty, gBlockRecvBuffer[enemyMultiplayerId], sizeof(struct Pokemon) * 2); + memcpy(gPlayerParty + 3, gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon) * 2); + } + else + { + memcpy(gPlayerParty, gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon) * 2); + memcpy(gPlayerParty + 3, gBlockRecvBuffer[enemyMultiplayerId], sizeof(struct Pokemon) * 2); + } + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 5: + if (sub_800A520()) + { + SendBlock(bitmask_all_link_players_but_self(), gPlayerParty + 2, sizeof(struct Pokemon)); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 6: + if ((GetBlockReceivedStatus() & 3) == 3) + { + ResetBlockReceivedFlags(); + if (gLinkPlayers[playerMultiplayerId].lp_field_18 != 0) + { + memcpy(gPlayerParty + 2, gBlockRecvBuffer[enemyMultiplayerId], sizeof(struct Pokemon)); + memcpy(gPlayerParty + 5, gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon)); + } + else + { + memcpy(gPlayerParty + 2, gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon)); + memcpy(gPlayerParty + 5, gBlockRecvBuffer[enemyMultiplayerId], sizeof(struct Pokemon)); + } + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 7: + if (sub_800A520()) + { + SendBlock(bitmask_all_link_players_but_self(), gEnemyParty, sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 8: + if ((GetBlockReceivedStatus() & 3) == 3) + { + ResetBlockReceivedFlags(); + if (GetMultiplayerId() != 0) + { + memcpy(gEnemyParty, gBlockRecvBuffer[0], sizeof(struct Pokemon) * 2); + } + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 9: + if (sub_800A520()) + { + SendBlock(bitmask_all_link_players_but_self(), gEnemyParty + 2, sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 10: + if ((GetBlockReceivedStatus() & 3) == 3) + { + ResetBlockReceivedFlags(); + if (GetMultiplayerId() != 0) + { + memcpy(gEnemyParty + 2, gBlockRecvBuffer[0], sizeof(struct Pokemon) * 2); + } + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 11: + if (sub_800A520()) + { + SendBlock(bitmask_all_link_players_but_self(), gEnemyParty + 4, sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 12: + if ((GetBlockReceivedStatus() & 3) == 3) + { + ResetBlockReceivedFlags(); + if (GetMultiplayerId() != 0) + memcpy(gEnemyParty + 4, gBlockRecvBuffer[0], sizeof(struct Pokemon) * 2); + TryCorrectShedinjaLanguage(&gPlayerParty[0]); + TryCorrectShedinjaLanguage(&gPlayerParty[1]); + TryCorrectShedinjaLanguage(&gPlayerParty[2]); + TryCorrectShedinjaLanguage(&gPlayerParty[3]); + TryCorrectShedinjaLanguage(&gPlayerParty[4]); + TryCorrectShedinjaLanguage(&gPlayerParty[5]); + TryCorrectShedinjaLanguage(&gEnemyParty[0]); + TryCorrectShedinjaLanguage(&gEnemyParty[1]); + TryCorrectShedinjaLanguage(&gEnemyParty[2]); + TryCorrectShedinjaLanguage(&gEnemyParty[3]); + TryCorrectShedinjaLanguage(&gEnemyParty[4]); + TryCorrectShedinjaLanguage(&gEnemyParty[5]); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 13: + sub_8032768(); + sub_8184E58(); + gBattleCommunication[SPRITES_INIT_STATE1] = 0; + gBattleCommunication[SPRITES_INIT_STATE2] = 0; + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + gBattleCommunication[MULTIUSE_STATE] = 14; + } + else + { + gBattleCommunication[MULTIUSE_STATE] = 16; + } + break; + case 14: + if (sub_800A520()) + { + SendBlock(bitmask_all_link_players_but_self(), &gRecordedBattleRngSeed, sizeof(gRecordedBattleRngSeed)); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 15: + if ((GetBlockReceivedStatus() & 3) == 3) + { + ResetBlockReceivedFlags(); + if (!(gBattleTypeFlags & BATTLE_TYPE_WILD)) + memcpy(&gRecordedBattleRngSeed, gBlockRecvBuffer[enemyMultiplayerId], sizeof(gRecordedBattleRngSeed)); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 16: + if (BattleInitAllSprites(&gBattleCommunication[SPRITES_INIT_STATE1], &gBattleCommunication[SPRITES_INIT_STATE2])) + { + sub_8166188(); + gPreBattleCallback1 = gMain.callback1; + gMain.callback1 = BattleMainCB1; + SetMainCallback2(BattleMainCB2); + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + gBattleTypeFlags |= BATTLE_TYPE_20; + } + } + break; + } +} + +static void sub_80379F8(u8 arrayIdPlus) +{ + s32 i; + + for (i = 0; i < 3; i++) + { + gUnknown_02022FF8[i].species = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_SPECIES); + gUnknown_02022FF8[i].heldItem = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_HELD_ITEM); + GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_NICKNAME, gUnknown_02022FF8[i].nickname); + gUnknown_02022FF8[i].level = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_LEVEL); + gUnknown_02022FF8[i].hp = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_HP); + gUnknown_02022FF8[i].maxhp = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_MAX_HP); + gUnknown_02022FF8[i].status = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_STATUS); + gUnknown_02022FF8[i].personality = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_PERSONALITY); + gUnknown_02022FF8[i].gender = GetMonGender(&gPlayerParty[arrayIdPlus + i]); + StripExtCtrlCodes(gUnknown_02022FF8[i].nickname); + if (GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_LANGUAGE) != LANGUAGE_JAPANESE) + sub_81DB4DC(gUnknown_02022FF8[i].nickname, 0); + } + memcpy(gUnknown_02023058, gUnknown_02022FF8, sizeof(gUnknown_02022FF8)); +} + +static void CB2_PreInitMultiBattle(void) +{ + s32 i; + u8 playerMultiplierId; + s32 numPlayers = 4; + u8 r4 = 0xF; + u32* savedBattleTypeFlags; + void (**savedCallback)(void); + + if (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) + { + numPlayers = 2; + r4 = 3; + } + + playerMultiplierId = GetMultiplayerId(); + gBattleScripting.multiplayerId = playerMultiplierId; + savedCallback = &gBattleStruct->savedCallback; + savedBattleTypeFlags = &gBattleStruct->savedBattleTypeFlags; + + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + + switch (gBattleCommunication[MULTIUSE_STATE]) + { + case 0: + if (gReceivedRemoteLinkPlayers != 0 && sub_800A520()) + { + gUnknown_02023058 = Alloc(sizeof(struct UnknownPokemonStruct2) * 3); + sub_80379F8(0); + SendBlock(bitmask_all_link_players_but_self(), gUnknown_02023058, sizeof(struct UnknownPokemonStruct2) * 3); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 1: + if ((GetBlockReceivedStatus() & r4) == r4) + { + ResetBlockReceivedFlags(); + for (i = 0; i < numPlayers; i++) + { + if (i == playerMultiplierId) + continue; + + if (numPlayers == 4) + { + if ((!(gLinkPlayers[i].lp_field_18 & 1) && !(gLinkPlayers[playerMultiplierId].lp_field_18 & 1)) + || (gLinkPlayers[i].lp_field_18 & 1 && gLinkPlayers[playerMultiplierId].lp_field_18 & 1)) + { + memcpy(gUnknown_02022FF8, gBlockRecvBuffer[i], sizeof(struct UnknownPokemonStruct2) * 3); + } + } + else + { + memcpy(gUnknown_02022FF8, gBlockRecvBuffer[i], sizeof(struct UnknownPokemonStruct2) * 3); + } + } + gBattleCommunication[MULTIUSE_STATE]++; + *savedCallback = gMain.savedCallback; + *savedBattleTypeFlags = gBattleTypeFlags; + gMain.savedCallback = CB2_PreInitMultiBattle; + sub_81B9150(); + } + break; + case 2: + if (sub_800A520() && !gPaletteFade.active) + { + gBattleCommunication[MULTIUSE_STATE]++; + if (gLinkVSyncDisabled) + sub_800ADF8(); + else + sub_800AC34(); + } + break; + case 3: + if (gLinkVSyncDisabled) + { + if (sub_8010500()) + { + gBattleTypeFlags = *savedBattleTypeFlags; + gMain.savedCallback = *savedCallback; + SetMainCallback2(CB2_InitBattleInternal); + Free(gUnknown_02023058); + gUnknown_02023058 = NULL; + } + } + else if (gReceivedRemoteLinkPlayers == 0) + { + gBattleTypeFlags = *savedBattleTypeFlags; + gMain.savedCallback = *savedCallback; + SetMainCallback2(CB2_InitBattleInternal); + Free(gUnknown_02023058); + gUnknown_02023058 = NULL; + } + break; + } +} + +static void CB2_PreInitIngamePlayerPartnerBattle(void) +{ + u32* savedBattleTypeFlags; + void (**savedCallback)(void); + + savedCallback = &gBattleStruct->savedCallback; + savedBattleTypeFlags = &gBattleStruct->savedBattleTypeFlags; + + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + + switch (gBattleCommunication[MULTIUSE_STATE]) + { + case 0: + gUnknown_02023058 = Alloc(sizeof(struct UnknownPokemonStruct2) * 3); + sub_80379F8(3); + gBattleCommunication[MULTIUSE_STATE]++; + *savedCallback = gMain.savedCallback; + *savedBattleTypeFlags = gBattleTypeFlags; + gMain.savedCallback = CB2_PreInitIngamePlayerPartnerBattle; + sub_81B9150(); + break; + case 1: + if (!gPaletteFade.active) + { + gBattleCommunication[MULTIUSE_STATE] = 2; + gBattleTypeFlags = *savedBattleTypeFlags; + gMain.savedCallback = *savedCallback; + SetMainCallback2(CB2_InitBattleInternal); + Free(gUnknown_02023058); + gUnknown_02023058 = NULL; + } + break; + } +} + +static void CB2_HandleStartMultiBattle(void) +{ + u8 playerMultiplayerId; + s32 id; + u8 var; + + playerMultiplayerId = GetMultiplayerId(); + gBattleScripting.multiplayerId = playerMultiplayerId; + + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + + switch (gBattleCommunication[MULTIUSE_STATE]) + { + case 0: + if (!IsDma3ManagerBusyWithBgCopy()) + { + ShowBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + sub_805EF14(); + gBattleCommunication[MULTIUSE_STATE] = 1; + } + if (gLinkVSyncDisabled) + sub_800E0E8(); + break; + case 1: + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + if (gReceivedRemoteLinkPlayers != 0) + { + if (sub_800A520()) + { + *(&gBattleStruct->field_180) = 0; + *(&gBattleStruct->field_181) = 3; + sub_8036A5C(); + SetPlayerBerryDataInBattleStruct(); + + SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->field_180, 32); + gBattleCommunication[MULTIUSE_STATE]++; + } + if (gLinkVSyncDisabled) + sub_800DFB4(0, 0); + } + } + else + { + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) + gBattleTypeFlags |= BATTLE_TYPE_WILD; + gBattleCommunication[MULTIUSE_STATE] = 7; + SetAllPlayersBerryData(); + } + break; + case 2: + if ((GetBlockReceivedStatus() & 0xF) == 0xF) + { + ResetBlockReceivedFlags(); + sub_8036EB8(4, playerMultiplayerId); + SetAllPlayersBerryData(); + sub_8068AA4(); + var = CreateTask(task00_0800F6FC, 0); + gTasks[var].data[1] = 0x10E; + gTasks[var].data[2] = 0x5A; + gTasks[var].data[5] = 0; + gTasks[var].data[3] = 0; + gTasks[var].data[4] = 0; + + for (id = 0; id < MAX_LINK_PLAYERS; id++) + { + sub_8185F90(gBlockRecvBuffer[id][1]); + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + gTasks[var].data[3] |= gBlockRecvBuffer[id][1] & 0x3F; + break; + case 1: + gTasks[var].data[4] |= gBlockRecvBuffer[id][1] & 0x3F; + break; + case 2: + gTasks[var].data[3] |= (gBlockRecvBuffer[id][1] & 0x3F) << 6; + break; + case 3: + gTasks[var].data[4] |= (gBlockRecvBuffer[id][1] & 0x3F) << 6; + break; + } + } + ZeroEnemyPartyMons(); + gBattleCommunication[MULTIUSE_STATE]++; + } + else + break; + // fall through + case 3: + if (sub_800A520()) + { + SendBlock(bitmask_all_link_players_but_self(), gPlayerParty, sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 4: + if ((GetBlockReceivedStatus() & 0xF) == 0xF) + { + ResetBlockReceivedFlags(); + for (id = 0; id < MAX_LINK_PLAYERS; id++) + { + if (id == playerMultiplayerId) + { + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + case 3: + memcpy(gPlayerParty, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + break; + case 1: + case 2: + memcpy(gPlayerParty + 3, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + break; + } + } + else + { + if ((!(gLinkPlayers[id].lp_field_18 & 1) && !(gLinkPlayers[playerMultiplayerId].lp_field_18 & 1)) + || ((gLinkPlayers[id].lp_field_18 & 1) && (gLinkPlayers[playerMultiplayerId].lp_field_18 & 1))) + { + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + case 3: + memcpy(gPlayerParty, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + break; + case 1: + case 2: + memcpy(gPlayerParty + 3, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + break; + } + } + else + { + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + case 3: + memcpy(gEnemyParty, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + break; + case 1: + case 2: + memcpy(gEnemyParty + 3, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + break; + } + } + } + } + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 5: + if (sub_800A520()) + { + SendBlock(bitmask_all_link_players_but_self(), gPlayerParty + 2, sizeof(struct Pokemon)); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 6: + if ((GetBlockReceivedStatus() & 0xF) == 0xF) + { + ResetBlockReceivedFlags(); + for (id = 0; id < MAX_LINK_PLAYERS; id++) + { + if (id == playerMultiplayerId) + { + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + case 3: + memcpy(gPlayerParty + 2, gBlockRecvBuffer[id], sizeof(struct Pokemon)); + break; + case 1: + case 2: + memcpy(gPlayerParty + 5, gBlockRecvBuffer[id], sizeof(struct Pokemon)); + break; + } + } + else + { + if ((!(gLinkPlayers[id].lp_field_18 & 1) && !(gLinkPlayers[playerMultiplayerId].lp_field_18 & 1)) + || ((gLinkPlayers[id].lp_field_18 & 1) && (gLinkPlayers[playerMultiplayerId].lp_field_18 & 1))) + { + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + case 3: + memcpy(gPlayerParty + 2, gBlockRecvBuffer[id], sizeof(struct Pokemon)); + break; + case 1: + case 2: + memcpy(gPlayerParty + 5, gBlockRecvBuffer[id], sizeof(struct Pokemon)); + break; + } + } + else + { + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + case 3: + memcpy(gEnemyParty + 2, gBlockRecvBuffer[id], sizeof(struct Pokemon)); + break; + case 1: + case 2: + memcpy(gEnemyParty + 5, gBlockRecvBuffer[id], sizeof(struct Pokemon)); + break; + } + } + } + } + TryCorrectShedinjaLanguage(&gPlayerParty[0]); + TryCorrectShedinjaLanguage(&gPlayerParty[1]); + TryCorrectShedinjaLanguage(&gPlayerParty[2]); + TryCorrectShedinjaLanguage(&gPlayerParty[3]); + TryCorrectShedinjaLanguage(&gPlayerParty[4]); + TryCorrectShedinjaLanguage(&gPlayerParty[5]); + + TryCorrectShedinjaLanguage(&gEnemyParty[0]); + TryCorrectShedinjaLanguage(&gEnemyParty[1]); + TryCorrectShedinjaLanguage(&gEnemyParty[2]); + TryCorrectShedinjaLanguage(&gEnemyParty[3]); + TryCorrectShedinjaLanguage(&gEnemyParty[4]); + TryCorrectShedinjaLanguage(&gEnemyParty[5]); + + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 7: + sub_8032768(); + sub_8184E58(); + gBattleCommunication[SPRITES_INIT_STATE1] = 0; + gBattleCommunication[SPRITES_INIT_STATE2] = 0; + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + for (id = 0; id < 4 && (gLinkPlayers[id].version & 0xFF) == 3; id++); + + if (id == 4) + gBattleCommunication[MULTIUSE_STATE] = 8; + else + gBattleCommunication[MULTIUSE_STATE] = 10; + } + else + { + gBattleCommunication[MULTIUSE_STATE] = 10; + } + break; + case 8: + if (sub_800A520()) + { + u32* ptr = (u32*)(&gBattleStruct->field_180); + ptr[0] = gBattleTypeFlags; + ptr[1] = gRecordedBattleRngSeed; // UB: overwrites berry data + SendBlock(bitmask_all_link_players_but_self(), ptr, 8); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 9: + if ((GetBlockReceivedStatus() & 0xF) == 0xF) + { + ResetBlockReceivedFlags(); + for (var = 0; var < 4; var++) + { + u32 blockValue = gBlockRecvBuffer[var][0]; + if (blockValue & 4) + { + memcpy(&gRecordedBattleRngSeed, &gBlockRecvBuffer[var][2], sizeof(gRecordedBattleRngSeed)); + break; + } + } + + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 10: + if (BattleInitAllSprites(&gBattleCommunication[SPRITES_INIT_STATE1], &gBattleCommunication[SPRITES_INIT_STATE2])) + { + gPreBattleCallback1 = gMain.callback1; + gMain.callback1 = BattleMainCB1; + SetMainCallback2(BattleMainCB2); + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + gTrainerBattleOpponent_A = TRAINER_OPPONENT_800; + gBattleTypeFlags |= BATTLE_TYPE_20; + } + } + break; + } +} + +void BattleMainCB2(void) +{ + AnimateSprites(); + BuildOamBuffer(); + RunTextPrinters(); + UpdatePaletteFade(); + RunTasks(); + + if (gMain.heldKeys & B_BUTTON && gBattleTypeFlags & BATTLE_TYPE_RECORDED && sub_8186450()) + { + gScriptResult = gBattleOutcome = BATTLE_PLAYER_TELEPORTED; + ResetPaletteFadeControl(); + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + SetMainCallback2(CB2_QuitRecordedBattle); + } +} + +static void FreeRestoreBattleData(void) +{ + gMain.callback1 = gPreBattleCallback1; + gUnknown_02039B28[0x15] = 3; + gMain.inBattle = 0; + ZeroEnemyPartyMons(); + m4aSongNumStop(0x5A); + FreeMonSpritesGfx(); + FreeBattleSpritesData(); + FreeBattleResources(); +} + +void CB2_QuitRecordedBattle(void) +{ + UpdatePaletteFade(); + if (!gPaletteFade.active) + { + m4aMPlayStop(&gMPlay_SE1); + m4aMPlayStop(&gMPlay_SE2); + FreeRestoreBattleData(); + FreeAllWindowBuffers(); + SetMainCallback2(gMain.savedCallback); + } +} + +void sub_8038528(struct Sprite* sprite) +{ + sprite->data0 = 0; + sprite->callback = sub_8038538; +} + +static void sub_8038538(struct Sprite *sprite) +{ + u16 *arr = (u16*)(gDecompressionBuffer); + + switch (sprite->data0) + { + case 0: + sprite->data0++; + sprite->data1 = 0; + sprite->data2 = 0x281; + sprite->data3 = 0; + sprite->data4 = 1; + // fall through + case 1: + sprite->data4--; + if (sprite->data4 == 0) + { + s32 i; + s32 r2; + s32 r0; + + sprite->data4 = 2; + r2 = sprite->data1 + sprite->data3 * 32; + r0 = sprite->data2 - sprite->data3 * 32; + for (i = 0; i < 29; i += 2) + { + arr[r2 + i] = 0x3D; + arr[r0 + i] = 0x3D; + } + sprite->data3++; + if (sprite->data3 == 21) + { + sprite->data0++; + sprite->data1 = 32; + } + } + break; + case 2: + sprite->data1--; + if (sprite->data1 == 20) + SetMainCallback2(CB2_InitBattle); + break; + } +} + +static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 firstTrainer) +{ + u32 nameHash = 0; + u32 personalityValue; + u8 fixedIV; + s32 i, j; + u8 monsCount; + + if (trainerNum == SECRET_BASE_OPPONENT) + return 0; + + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && !(gBattleTypeFlags & (BATTLE_TYPE_FRONTIER + | BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_x4000000))) + { + if (firstTrainer == TRUE) + ZeroEnemyPartyMons(); + + if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) + { + if (gTrainers[trainerNum].partySize > 3) + monsCount = 3; + else + monsCount = gTrainers[trainerNum].partySize; + } + else + { + monsCount = gTrainers[trainerNum].partySize; + } + + for (i = 0; i < monsCount; i++) + { + + if (gTrainers[trainerNum].doubleBattle == TRUE) + personalityValue = 0x80; + else if (gTrainers[trainerNum].encounterMusic_gender & 0x80) + personalityValue = 0x78; + else + personalityValue = 0x88; + + for (j = 0; gTrainers[trainerNum].trainerName[j] != 0xFF; j++) + nameHash += gTrainers[trainerNum].trainerName[j]; + + switch (gTrainers[trainerNum].partyFlags) + { + case 0: + { + const struct TrainerMonNoItemDefaultMoves *partyData = gTrainers[trainerNum].party.NoItemDefaultMoves; + + for (j = 0; gSpeciesNames[partyData[i].species][j] != 0xFF; j++) + nameHash += gSpeciesNames[partyData[i].species][j]; + + personalityValue += nameHash << 8; + fixedIV = partyData[i].iv * 31 / 255; + CreateMon(&party[i], partyData[i].species, partyData[i].lvl, fixedIV, TRUE, personalityValue, OT_ID_RANDOM_NO_SHINY, 0); + break; + } + case PARTY_FLAG_CUSTOM_MOVES: + { + const struct TrainerMonNoItemCustomMoves *partyData = gTrainers[trainerNum].party.NoItemCustomMoves; + + for (j = 0; gSpeciesNames[partyData[i].species][j] != 0xFF; j++) + nameHash += gSpeciesNames[partyData[i].species][j]; + + personalityValue += nameHash << 8; + fixedIV = partyData[i].iv * 31 / 255; + CreateMon(&party[i], partyData[i].species, partyData[i].lvl, fixedIV, TRUE, personalityValue, 2, 0); + + for (j = 0; j < 4; j++) + { + SetMonData(&party[i], MON_DATA_MOVE1 + j, &partyData[i].moves[j]); + SetMonData(&party[i], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp); + } + break; + } + case PARTY_FLAG_HAS_ITEM: + { + const struct TrainerMonItemDefaultMoves *partyData = gTrainers[trainerNum].party.ItemDefaultMoves; + + for (j = 0; gSpeciesNames[partyData[i].species][j] != 0xFF; j++) + nameHash += gSpeciesNames[partyData[i].species][j]; + + personalityValue += nameHash << 8; + fixedIV = partyData[i].iv * 31 / 255; + CreateMon(&party[i], partyData[i].species, partyData[i].lvl, fixedIV, TRUE, personalityValue, 2, 0); + + SetMonData(&party[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem); + break; + } + case PARTY_FLAG_CUSTOM_MOVES | PARTY_FLAG_HAS_ITEM: + { + const struct TrainerMonItemCustomMoves *partyData = gTrainers[trainerNum].party.ItemCustomMoves; + + for (j = 0; gSpeciesNames[partyData[i].species][j] != 0xFF; j++) + nameHash += gSpeciesNames[partyData[i].species][j]; + + personalityValue += nameHash << 8; + fixedIV = partyData[i].iv * 31 / 255; + CreateMon(&party[i], partyData[i].species, partyData[i].lvl, fixedIV, TRUE, personalityValue, 2, 0); + + SetMonData(&party[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem); + + for (j = 0; j < 4; j++) + { + SetMonData(&party[i], MON_DATA_MOVE1 + j, &partyData[i].moves[j]); + SetMonData(&party[i], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp); + } + break; + } + } + } + + gBattleTypeFlags |= gTrainers[trainerNum].doubleBattle; + } + + return gTrainers[trainerNum].partySize; +} + +void sub_8038A04(void) // unused +{ + if (REG_VCOUNT < 0xA0 && REG_VCOUNT >= 0x6F) + SetGpuReg(REG_OFFSET_BG0CNT, 0x9800); +} + +void VBlankCB_Battle(void) +{ + // change gRngSeed every vblank unless the battle could be recorded + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_RECORDED))) + Random(); + + SetGpuReg(REG_OFFSET_BG0HOFS, gBattle_BG0_X); + SetGpuReg(REG_OFFSET_BG0VOFS, gBattle_BG0_Y); + SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X); + SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y); + SetGpuReg(REG_OFFSET_BG2HOFS, gBattle_BG2_X); + SetGpuReg(REG_OFFSET_BG2VOFS, gBattle_BG2_Y); + SetGpuReg(REG_OFFSET_BG3HOFS, gBattle_BG3_X); + SetGpuReg(REG_OFFSET_BG3VOFS, gBattle_BG3_Y); + SetGpuReg(REG_OFFSET_WIN0H, gBattle_WIN0H); + SetGpuReg(REG_OFFSET_WIN0V, gBattle_WIN0V); + SetGpuReg(REG_OFFSET_WIN1H, gBattle_WIN1H); + SetGpuReg(REG_OFFSET_WIN1V, gBattle_WIN1V); + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); + sub_80BA0A8(); +} + +void nullsub_17(void) +{ + +} + +static void sub_8038B04(struct Sprite *sprite) +{ + if (sprite->data0 != 0) + sprite->pos1.x = sprite->data1 + ((sprite->data2 & 0xFF00) >> 8); + else + sprite->pos1.x = sprite->data1 - ((sprite->data2 & 0xFF00) >> 8); + + sprite->data2 += 0x180; + + if (sprite->affineAnimEnded) + { + FreeSpriteTilesByTag(0x2710); + FreeSpritePaletteByTag(0x2710); + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + } +} + +void sub_8038B74(struct Sprite *sprite) +{ + StartSpriteAffineAnim(sprite, 1); + sprite->callback = sub_8038B04; + PlaySE(SE_BT_START); +} + +static void sub_8038B94(u8 taskId) +{ + struct Pokemon *sp4 = NULL; + struct Pokemon *sp8 = NULL; + u8 r2 = gBattleScripting.multiplayerId; + u32 r7; + s32 i; + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + switch (gLinkPlayers[r2].lp_field_18) + { + case 0: + case 2: + sp4 = gPlayerParty; + sp8 = gEnemyParty; + break; + case 1: + case 3: + sp4 = gEnemyParty; + sp8 = gPlayerParty; + break; + } + } + else + { + sp4 = gPlayerParty; + sp8 = gEnemyParty; + } + + r7 = 0; + for (i = 0; i < 6; i++) + { + u16 species = GetMonData(&sp4[i], MON_DATA_SPECIES2); + u16 hp = GetMonData(&sp4[i], MON_DATA_HP); + u32 status = GetMonData(&sp4[i], MON_DATA_STATUS); + + if (species == SPECIES_NONE) + continue; + if (species != SPECIES_EGG && hp != 0 && status == 0) + r7 |= 1 << i * 2; + + if (species == 0) + continue; + if (hp != 0 && (species == SPECIES_EGG || status != 0)) + r7 |= 2 << i * 2; + + if (species == 0) + continue; + if (species != SPECIES_EGG && hp == 0) + r7 |= 3 << i * 2; + } + gTasks[taskId].data[3] = r7; + + r7 = 0; + for (i = 0; i < 6; i++) + { + u16 species = GetMonData(&sp8[i], MON_DATA_SPECIES2); + u16 hp = GetMonData(&sp8[i], MON_DATA_HP); + u32 status = GetMonData(&sp8[i], MON_DATA_STATUS); + + if (species == SPECIES_NONE) + continue; + if (species != SPECIES_EGG && hp != 0 && status == 0) + r7 |= 1 << i * 2; + + if (species == SPECIES_NONE) + continue; + if (hp != 0 && (species == SPECIES_EGG || status != 0)) + r7 |= 2 << i * 2; + + if (species == SPECIES_NONE) + continue; + if (species != SPECIES_EGG && hp == 0) + r7 |= 3 << i * 2; + } + gTasks[taskId].data[4] = r7; +} + +void sub_8038D64(void) +{ + s32 i; + u8 taskId; + + SetHBlankCallback(NULL); + SetVBlankCallback(NULL); + gBattleTypeFlags &= ~(BATTLE_TYPE_20); + + if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) + { + SetMainCallback2(gMain.savedCallback); + FreeBattleResources(); + FreeBattleSpritesData(); + FreeMonSpritesGfx(); + } + else + { + CpuFill32(0, (void*)(VRAM), VRAM_SIZE); + SetGpuReg(REG_OFFSET_MOSAIC, 0); + SetGpuReg(REG_OFFSET_WIN0H, 0xF0); + SetGpuReg(REG_OFFSET_WIN0V, 0x5051); + SetGpuReg(REG_OFFSET_WININ, 0); + SetGpuReg(REG_OFFSET_WINOUT, 0); + gBattle_WIN0H = 0xF0; + gBattle_WIN0V = 0x5051; + dp12_8087EA4(); + + for (i = 0; i < 80; i++) + { + gUnknown_02038C28.unk0[i] = 0xF0; + gUnknown_02038C28.unk780[i] = 0xF0; + } + for (i = 80; i < 160; i++) + { + asm(""::"r"(i)); // Needed to stop the compiler from optimizing out the loop counter + gUnknown_02038C28.unk0[i] = 0xFF10; + gUnknown_02038C28.unk780[i] = 0xFF10; + } + + ResetPaletteFade(); + + gBattle_BG0_X = 0; + gBattle_BG0_Y = 0; + gBattle_BG1_X = 0; + gBattle_BG1_Y = 0; + gBattle_BG2_X = 0; + gBattle_BG2_Y = 0; + gBattle_BG3_X = 0; + gBattle_BG3_Y = 0; + + sub_80356D0(); + LoadCompressedPalette(gUnknown_08C004E0, 0, 64); + ApplyPlayerChosenFrameToBattleMenu(); + ResetSpriteData(); + ResetTasks(); + LoadBattleEntryBackground(); + SetGpuReg(REG_OFFSET_WINOUT, 0x37); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 4; + SetVBlankCallback(VBlankCB_Battle); + + taskId = CreateTask(task00_0800F6FC, 0); + gTasks[taskId].data[1] = 0x10E; + gTasks[taskId].data[2] = 0x5A; + gTasks[taskId].data[5] = 1; + sub_8038B94(taskId); + SetMainCallback2(sub_8038F14); + gBattleCommunication[MULTIUSE_STATE] = 0; + } +} + +static void sub_8038F14(void) +{ + sub_8038F34(); + AnimateSprites(); + BuildOamBuffer(); + RunTextPrinters(); + UpdatePaletteFade(); + RunTasks(); +} + +static void sub_8038F34(void) +{ + s32 i; + + switch (gBattleCommunication[MULTIUSE_STATE]) + { + case 0: + ShowBg(0); + ShowBg(1); + ShowBg(2); + gBattleCommunication[1] = 0xFF; + gBattleCommunication[MULTIUSE_STATE]++; + break; + case 1: + if (--gBattleCommunication[1] == 0) + { + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 2: + if (!gPaletteFade.active) + { + u8 monsCount; + + gMain.field_439_x4 = sub_8185FAC(); + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + monsCount = 4; + else + monsCount = 2; + + for (i = 0; i < monsCount && (gLinkPlayers[i].version & 0xFF) == 3; i++); + + if (!gSaveBlock2Ptr->field_CA9_b && i == monsCount) + { + if (FlagGet(SYS_FRONTIER_PASS)) + { + FreeAllWindowBuffers(); + SetMainCallback2(sub_80392A8); + } + else if (!gMain.field_439_x4) + { + SetMainCallback2(gMain.savedCallback); + FreeBattleResources(); + FreeBattleSpritesData(); + FreeMonSpritesGfx(); + } + else if (gReceivedRemoteLinkPlayers == 0) + { + CreateTask(sub_80B3AF8, 5); + gBattleCommunication[MULTIUSE_STATE]++; + } + else + { + gBattleCommunication[MULTIUSE_STATE]++; + } + } + else + { + SetMainCallback2(gMain.savedCallback); + FreeBattleResources(); + FreeBattleSpritesData(); + FreeMonSpritesGfx(); + } + } + break; + case 3: + CpuFill32(0, (void*)(VRAM), VRAM_SIZE); + + for (i = 0; i < 2; i++) + LoadChosenBattleElement(i); + + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + gBattleCommunication[MULTIUSE_STATE]++; + break; + case 4: + if (!gPaletteFade.active) + gBattleCommunication[MULTIUSE_STATE]++; + break; + case 5: + if (!FuncIsActiveTask(sub_80B3AF8)) + gBattleCommunication[MULTIUSE_STATE]++; + break; + case 6: + if (sub_800A520() == TRUE) + { + sub_800ADF8(); + sub_814F9EC(gText_LinkStandby3, 0); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 7: + if (!IsTextPrinterActive(0)) + { + if (sub_800A520() == TRUE) + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 8: + if (!gLinkVSyncDisabled) + sub_800AC34(); + gBattleCommunication[MULTIUSE_STATE]++; + break; + case 9: + if (!gMain.field_439_x4 || gLinkVSyncDisabled || gReceivedRemoteLinkPlayers != 1) + { + gMain.field_439_x4 = 0; + SetMainCallback2(gMain.savedCallback); + FreeBattleResources(); + FreeBattleSpritesData(); + FreeMonSpritesGfx(); + } + break; + } +} + +u32 sub_80391E0(u8 arrayId, u8 caseId) +{ + u32 ret = 0; + + switch (caseId) + { + case 0: + ret = gUnknown_0831AA08[arrayId].bg; + break; + case 1: + ret = gUnknown_0831AA08[arrayId].charBaseIndex; + break; + case 2: + ret = gUnknown_0831AA08[arrayId].mapBaseIndex; + break; + case 3: + ret = gUnknown_0831AA08[arrayId].screenSize; + break; + case 4: + ret = gUnknown_0831AA08[arrayId].paletteMode; + break; + case 5: + ret = gUnknown_0831AA08[arrayId].priority; + break; + case 6: + ret = gUnknown_0831AA08[arrayId].baseTile; + break; + } + + return ret; +} + +static void sub_80392A8(void) +{ + s32 i; + + SetHBlankCallback(NULL); + SetVBlankCallback(NULL); + CpuFill32(0, (void*)(VRAM), VRAM_SIZE); + ResetPaletteFade(); + gBattle_BG0_X = 0; + gBattle_BG0_Y = 0; + gBattle_BG1_X = 0; + gBattle_BG1_Y = 0; + gBattle_BG2_X = 0; + gBattle_BG2_Y = 0; + gBattle_BG3_X = 0; + gBattle_BG3_Y = 0; + sub_80356D0(); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); + ApplyPlayerChosenFrameToBattleMenu(); + + for (i = 0; i < 2; i++) + LoadChosenBattleElement(i); + + ResetSpriteData(); + ResetTasks(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 4; + SetVBlankCallback(VBlankCB_Battle); + SetMainCallback2(sub_803937C); + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + gBattleCommunication[MULTIUSE_STATE] = 0; +} + +static void sub_803937C(void) +{ + sub_803939C(); + AnimateSprites(); + BuildOamBuffer(); + RunTextPrinters(); + UpdatePaletteFade(); + RunTasks(); +} + +static void sub_803939C(void) +{ + switch (gBattleCommunication[MULTIUSE_STATE]) + { + case 0: + ShowBg(0); + ShowBg(1); + ShowBg(2); + gBattleCommunication[MULTIUSE_STATE]++; + break; + case 1: + if (gMain.field_439_x4 && gReceivedRemoteLinkPlayers == 0) + CreateTask(sub_80B3AF8, 5); + gBattleCommunication[MULTIUSE_STATE]++; + break; + case 2: + if (!FuncIsActiveTask(sub_80B3AF8)) + gBattleCommunication[MULTIUSE_STATE]++; + break; + case 3: + if (!gPaletteFade.active) + { + sub_814F9EC(gText_RecordBattleToPass, 0); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 4: + if (!IsTextPrinterActive(0)) + { + sub_8056A3C(0x18, 8, 0x1D, 0xD, 0); + sub_814F9EC(gText_BattleYesNoChoice, 0xC); + gBattleCommunication[CURSOR_POSITION] = 1; + BattleCreateCursorAt(1); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 5: + if (gMain.newKeys & DPAD_UP) + { + if (gBattleCommunication[CURSOR_POSITION] != 0) + { + PlaySE(SE_SELECT); + BattleDestroyCursorAt(gBattleCommunication[CURSOR_POSITION]); + gBattleCommunication[CURSOR_POSITION] = 0; + BattleCreateCursorAt(0); + } + } + else if (gMain.newKeys & DPAD_DOWN) + { + if (gBattleCommunication[CURSOR_POSITION] == 0) + { + PlaySE(SE_SELECT); + BattleDestroyCursorAt(gBattleCommunication[CURSOR_POSITION]); + gBattleCommunication[CURSOR_POSITION] = 1; + BattleCreateCursorAt(1); + } + } + else if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + if (gBattleCommunication[CURSOR_POSITION] == 0) + { + sub_8056A3C(0x18, 8, 0x1D, 0xD, 1); + gBattleCommunication[1] = MoveRecordedBattleToSaveData(); + gBattleCommunication[MULTIUSE_STATE] = 10; + } + else + { + gBattleCommunication[MULTIUSE_STATE]++; + } + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 6: + if (sub_800A520() == TRUE) + { + sub_8056A3C(0x18, 8, 0x1D, 0xD, 1); + if (gMain.field_439_x4) + { + sub_800ADF8(); + sub_814F9EC(gText_LinkStandby3, 0); + } + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 8: + if (--gBattleCommunication[1] == 0) + { + if (gMain.field_439_x4 && !gLinkVSyncDisabled) + sub_800AC34(); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 9: + if (!gMain.field_439_x4 || gLinkVSyncDisabled || gReceivedRemoteLinkPlayers != 1) + { + gMain.field_439_x4 = 0; + if (!gPaletteFade.active) + { + SetMainCallback2(gMain.savedCallback); + FreeBattleResources(); + FreeBattleSpritesData(); + FreeMonSpritesGfx(); + } + } + break; + case 10: + if (gBattleCommunication[1] == 1) + { + PlaySE(SE_SAVE); + BattleStringExpandPlaceholdersToDisplayedString(gText_BattleRecordedOnPass); + sub_814F9EC(gDisplayedStringBattle, 0); + gBattleCommunication[1] = 0x80; + gBattleCommunication[MULTIUSE_STATE]++; + } + else + { + BattleStringExpandPlaceholdersToDisplayedString(gText_BattleRecordCouldntBeSaved); + sub_814F9EC(gDisplayedStringBattle, 0); + gBattleCommunication[1] = 0x80; + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 11: + if (sub_800A520() == TRUE && !IsTextPrinterActive(0) && --gBattleCommunication[1] == 0) + { + if (gMain.field_439_x4) + { + sub_800ADF8(); + sub_814F9EC(gText_LinkStandby3, 0); + } + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 12: + case 7: + if (!IsTextPrinterActive(0)) + { + if (gMain.field_439_x4) + { + if (sub_800A520() == TRUE) + { + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gBattleCommunication[1] = 0x20; + gBattleCommunication[MULTIUSE_STATE] = 8; + } + + } + else + { + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gBattleCommunication[1] = 0x20; + gBattleCommunication[MULTIUSE_STATE] = 8; + } + } + break; + } +} + +static void TryCorrectShedinjaLanguage(struct Pokemon *mon) +{ + u8 nickname[POKEMON_NAME_LENGTH + 1]; + u8 language = LANGUAGE_JAPANESE; + + if (GetMonData(mon, MON_DATA_SPECIES) == SPECIES_SHEDINJA + && GetMonData(mon, MON_DATA_LANGUAGE) != language) + { + GetMonData(mon, MON_DATA_NICKNAME, nickname); + if (StringCompareWithoutExtCtrlCodes(nickname, gText_ShedinjaJapaneseName) == 0) + SetMonData(mon, MON_DATA_LANGUAGE, &language); + } +} + +u32 sub_80397C4(u32 setId, u32 tableId) +{ + return gUnknown_0831ABA0[setId][tableId].width * 8; +} + +#define tBank data0 +#define tSpeciesId data2 + +void oac_poke_opponent(struct Sprite *sprite) +{ + sprite->callback = sub_803980C; + StartSpriteAnimIfDifferent(sprite, 0); + BeginNormalPaletteFade(0x20000, 0, 10, 10, 0x2108); +} + +static void sub_803980C(struct Sprite *sprite) +{ + if ((gUnknown_020243FC & 1) == 0) + { + sprite->pos2.x += 2; + if (sprite->pos2.x == 0) + { + sprite->callback = sub_8039838; + } + } +} + +static void sub_8039838(struct Sprite *sprite) +{ + if (sprite->animEnded) + { + sub_8076918(sprite->tBank); + sub_80729D0(gHealthBoxesIds[sprite->tBank]); + sprite->callback = sub_8039894; + StartSpriteAnimIfDifferent(sprite, 0); + BeginNormalPaletteFade(0x20000, 0, 10, 0, 0x2108); + } +} + +static void sub_8039894(struct Sprite *sprite) +{ + if (!gPaletteFade.active) + { + BattleAnimateFrontSprite(sprite, sprite->tSpeciesId, FALSE, 1); + } +} + +void SpriteCallbackDummy_2(struct Sprite *sprite) +{ + +} + +static void sub_80398BC(struct Sprite *sprite) // unused? +{ + sprite->data3 = 6; + sprite->data4 = 1; + sprite->callback = sub_80398D0; +} + +static void sub_80398D0(struct Sprite *sprite) +{ + sprite->data4--; + if (sprite->data4 == 0) + { + sprite->data4 = 8; + sprite->invisible ^= 1; + sprite->data3--; + if (sprite->data3 == 0) + { + sprite->invisible = FALSE; + sprite->callback = SpriteCallbackDummy_2; + gUnknown_02022F88 = 0; + } + } +} + +// to get rid of once the struct is declared in a header +struct MonCoords +{ + // This would use a bitfield, but sub_8079F44 + // uses it as a u8 and casting won't match. + u8 coords; // u8 x:4, y:4; + u8 y_offset; +}; + +extern const struct MonCoords gMonFrontPicCoords[]; +extern const struct MonCoords gCastformFrontSpriteCoords[]; + +void sub_8039934(struct Sprite *sprite) +{ + u8 bank = sprite->tBank; + u16 species; + u8 yOffset; + + if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != 0) + species = gBattleSpritesDataPtr->bankData[bank].transformSpecies; + else + species = sprite->tSpeciesId; + + GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_PERSONALITY); // Unused return value + + if (species == SPECIES_UNOWN) + { + u32 personalityValue = GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_PERSONALITY); + u16 unownForm = ((((personalityValue & 0x3000000) >> 18) | ((personalityValue & 0x30000) >> 12) | ((personalityValue & 0x300) >> 6) | (personalityValue & 3)) % 0x1C); + u16 unownSpecies; + + if (unownForm == 0) + unownSpecies = SPECIES_UNOWN; // Use the A Unown form + else + unownSpecies = NUM_SPECIES + unownForm; // Use one of the other Unown letters + + yOffset = gMonFrontPicCoords[unownSpecies].y_offset; + } + else if (species == SPECIES_CASTFORM) + { + yOffset = gCastformFrontSpriteCoords[gBattleMonForms[bank]].y_offset; + } + else if (species > NUM_SPECIES) + { + yOffset = gMonFrontPicCoords[SPECIES_NONE].y_offset; + } + else + { + yOffset = gMonFrontPicCoords[species].y_offset; + } + + sprite->data3 = 8 - yOffset / 8; + sprite->data4 = 1; + sprite->callback = sub_8039A48; +} + +static void sub_8039A48(struct Sprite *sprite) +{ + s32 i; + + sprite->data4--; + if (sprite->data4 == 0) + { + sprite->data4 = 2; + sprite->pos2.y += 8; + sprite->data3--; + if (sprite->data3 < 0) + { + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + } + else + { + u8 *dst = (u8 *)gMonSpritesGfxPtr->sprites[GetBankIdentity(sprite->tBank)] + (gBattleMonForms[sprite->tBank] << 11) + (sprite->data3 << 8); + + for (i = 0; i < 0x100; i++) + *(dst++) = 0; + + StartSpriteAnim(sprite, gBattleMonForms[sprite->tBank]); + } + } +} + +void sub_8039AD8(struct Sprite *sprite) +{ + sprite->data3 = 8; + sprite->data4 = sprite->invisible; + sprite->callback = sub_8039AF4; +} + +static void sub_8039AF4(struct Sprite *sprite) +{ + sprite->data3--; + if (sprite->data3 == 0) + { + sprite->invisible ^= 1; + sprite->data3 = 8; + } +} + +void sub_8039B2C(struct Sprite *sprite) +{ + sprite->invisible = sprite->data4; + sprite->data4 = FALSE; + sprite->callback = SpriteCallbackDummy_2; +} + +void sub_8039B58(struct Sprite *sprite) +{ + if (sprite->affineAnimEnded) + { + if (!(gHitMarker & HITMARKER_NO_ANIMATIONS) || gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + { + if (HasTwoFramesAnimation(sprite->tSpeciesId)) + StartSpriteAnim(sprite, 1); + } + BattleAnimateFrontSprite(sprite, sprite->tSpeciesId, TRUE, 1); + } +} + +void sub_8039BB4(struct Sprite *sprite) +{ + sprite->callback = oac_poke_ally_; +} + +static void oac_poke_ally_(struct Sprite *sprite) +{ + if ((gUnknown_020243FC & 1) == 0) + { + sprite->pos2.x -= 2; + if (sprite->pos2.x == 0) + { + sprite->callback = SpriteCallbackDummy_3; + sprite->data1 = 0; + } + } +} + +void sub_80105DC(struct Sprite *sprite) +{ + sprite->callback = SpriteCallbackDummy_3; +} + +static void SpriteCallbackDummy_3(struct Sprite *sprite) +{ +} + +void sub_8039C00(struct Sprite *sprite) +{ + if (!(gUnknown_020243FC & 1)) + { + sprite->pos2.x += sprite->data1; + sprite->pos2.y += sprite->data2; + } +} + +void dp11b_obj_instanciate(u8 bank, u8 b, s8 c, s8 d) +{ + u8 bounceHealthBoxSpriteId; + u8 spriteId2; + + if (b) + { + if (gBattleSpritesDataPtr->healthBoxesData[bank].flag_x2) + return; + } + else + { + if (gBattleSpritesDataPtr->healthBoxesData[bank].flag_x4) + return; + } + + bounceHealthBoxSpriteId = CreateInvisibleSpriteWithCallback(SpriteCB_HealthBoxBounce); + if (b == TRUE) + { + spriteId2 = gHealthBoxesIds[bank]; + gBattleSpritesDataPtr->healthBoxesData[bank].field_2 = bounceHealthBoxSpriteId; + gBattleSpritesDataPtr->healthBoxesData[bank].flag_x2 = 1; + gSprites[bounceHealthBoxSpriteId].data0 = 0x80; + } + else + { + spriteId2 = gBankSpriteIds[bank]; + gBattleSpritesDataPtr->healthBoxesData[bank].field_3 = bounceHealthBoxSpriteId; + gBattleSpritesDataPtr->healthBoxesData[bank].flag_x4 = 1; + gSprites[bounceHealthBoxSpriteId].data0 = 0xC0; + } + gSprites[bounceHealthBoxSpriteId].data1 = c; + gSprites[bounceHealthBoxSpriteId].data2 = d; + gSprites[bounceHealthBoxSpriteId].data3 = spriteId2; + gSprites[bounceHealthBoxSpriteId].data4 = b; + gSprites[spriteId2].pos2.x = 0; + gSprites[spriteId2].pos2.y = 0; +} + +void dp11b_obj_free(u8 bank, bool8 b) +{ + u8 r4; + + if (b == TRUE) + { + if (!gBattleSpritesDataPtr->healthBoxesData[bank].flag_x2) + return; + + r4 = gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].field_2].data3; + DestroySprite(&gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].field_2]); + gBattleSpritesDataPtr->healthBoxesData[bank].flag_x2 = 0; + } + else + { + if (!gBattleSpritesDataPtr->healthBoxesData[bank].flag_x4) + return; + + r4 = gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].field_3].data3; + DestroySprite(&gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].field_3]); + gBattleSpritesDataPtr->healthBoxesData[bank].flag_x4 = 0; + } + gSprites[r4].pos2.x = 0; + gSprites[r4].pos2.y = 0; +} + +static void SpriteCB_HealthBoxBounce(struct Sprite *sprite) +{ + u8 spriteId = sprite->data3; + s32 var; + + if (sprite->data4 == 1) + var = sprite->data0; + else + var = sprite->data0; + + gSprites[spriteId].pos2.y = Sin(var, sprite->data2) + sprite->data2; + sprite->data0 = (sprite->data0 + sprite->data1) & 0xFF; +} + +void sub_8039E44(struct Sprite *sprite) +{ + if (sprite->affineAnimEnded) + BattleAnimateBackSprite(sprite, sprite->tSpeciesId); +} + +void sub_8039E60(struct Sprite *sprite) +{ + sub_8039E9C(sprite); + if (sprite->animEnded) + sprite->callback = SpriteCallbackDummy_3; +} + +void sub_8039E84(struct Sprite *sprite) +{ + StartSpriteAnim(sprite, 1); + sprite->callback = sub_8039E60; +} + +void sub_8039E9C(struct Sprite *sprite) +{ + if (sprite->animDelayCounter == 0) + sprite->centerToCornerVecX = gUnknown_0831ACE0[sprite->animCmdIndex]; +} + +void nullsub_20(void) +{ + +} + +void BeginBattleIntro(void) +{ + BattleStartClearSetData(); + gBattleCommunication[1] = 0; + gBattleMainFunc = BattleIntroGetMonsData; +} + +static void BattleMainCB1(void) +{ + gBattleMainFunc(); + + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + gBattleBankFunc[gActiveBank](); +} + +static void BattleStartClearSetData(void) +{ + s32 i; + u32 j; + u8 *dataPtr; + + TurnValuesCleanUp(FALSE); + SpecialStatusesClear(); + + for (i = 0; i < BATTLE_BANKS_COUNT; i++) + { + gStatuses3[i] = 0; + + dataPtr = (u8 *)&gDisableStructs[i]; + for (j = 0; j < sizeof(struct DisableStruct); j++) + dataPtr[j] = 0; + + gDisableStructs[i].isFirstTurn= 2; + gUnknown_02024284[i] = 0; + gLastUsedMovesByBanks[i] = 0; + gUnknown_02024250[i] = 0; + gUnknown_02024258[i] = 0; + gUnknown_02024260[i] = 0; + gUnknown_02024270[i] = 0xFF; + gLockedMoves[i] = 0; + gUnknownMovesUsedByBanks[i] = 0; + gBattleResources->flags->flags[i] = 0; + gUnknown_02024230[i] = 0; + } + + for (i = 0; i < 2; i++) + { + gSideAffecting[i] = 0; + + dataPtr = (u8 *)&gSideTimers[i]; + for (j = 0; j < sizeof(struct SideTimer); j++) + dataPtr[j] = 0; + } + + gBankAttacker = 0; + gBankTarget = 0; + gBattleWeather = 0; + + dataPtr = (u8 *)&gWishFutureKnock; + for (i = 0; i < sizeof(struct WishFutureKnock); i++) + dataPtr[i] = 0; + + gHitMarker = 0; + + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) + { + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && gSaveBlock2Ptr->optionsBattleSceneOff == TRUE) + gHitMarker |= HITMARKER_NO_ANIMATIONS; + } + else if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) && sub_8185FB8()) + gHitMarker |= HITMARKER_NO_ANIMATIONS; + + gBattleScripting.battleStyle = gSaveBlock2Ptr->optionsBattleStyle; + + gMultiHitCounter = 0; + gBattleOutcome = 0; + gBattleExecBuffer = 0; + gPaydayMoney = 0; + gBattleResources->battleScriptsStack->size = 0; + gBattleResources->battleCallbackStack->size = 0; + + for (i = 0; i < BATTLE_COMMUNICATION_ENTRIES_COUNT; i++) + gBattleCommunication[i] = 0; + + gPauseCounterBattle = 0; + gBattleMoveDamage = 0; + gUnknown_020243FC = 0; + gBattleScripting.animTurn = 0; + gBattleScripting.animTargetsHit = 0; + gLeveledUpInBattle = 0; + gAbsentBankFlags = 0; + gBattleStruct->runTries = 0; + gBattleStruct->field_79 = 0; + gBattleStruct->field_7A = 0; + *(&gBattleStruct->field_7C) = gBaseStats[GetMonData(&gEnemyParty[0], MON_DATA_SPECIES)].catchRate * 100 / 1275; + gBattleStruct->field_7B = 3; + gBattleStruct->wildVictorySong = 0; + gBattleStruct->moneyMultiplier = 1; + + for (i = 0; i < 8; i++) + { + *((u8 *)gBattleStruct->mirrorMoves + i) = 0; + *((u8 *)gBattleStruct->usedHeldItems + i) = 0; + *((u8 *)gBattleStruct->choicedMove + i) = 0; + *((u8 *)gBattleStruct->changedItems + i) = 0; + *(i + 0 * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(i + 1 * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(i + 2 * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(i + 3 * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + } + + for (i = 0; i < 4; i++) + { + *(gBattleStruct->field_294 + i) = 6; + } + + gBattleStruct->field_DF = 0; + gBattleStruct->field_92 = 0; + + gRandomTurnNumber = Random(); + + dataPtr = (u8 *)(&gBattleResults); + for (i = 0; i < sizeof(struct BattleResults); i++) + dataPtr[i] = 0; + + gBattleResults.unk5_6 = IsMonShiny(&gEnemyParty[0]); + + gBattleStruct->field_2A0 = 0; + gBattleStruct->field_2A1 = 0; +} + +void SwitchInClearSetData(void) +{ + struct DisableStruct disableStructCopy = gDisableStructs[gActiveBank]; + s32 i; + u8 *ptr; + + if (gBattleMoves[gCurrentMove].effect != EFFECT_BATON_PASS) + { + for (i = 0; i < BATTLE_STATS_NO; i++) + gBattleMons[gActiveBank].statStages[i] = 6; + for (i = 0; i < gNoOfAllBanks; i++) + { + if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].bankPreventingEscape == gActiveBank) + gBattleMons[i].status2 &= ~STATUS2_ESCAPE_PREVENTION; + if ((gStatuses3[i] & STATUS3_ALWAYS_HITS) && gDisableStructs[i].bankWithSureHit == gActiveBank) + { + gStatuses3[i] &= ~STATUS3_ALWAYS_HITS; + gDisableStructs[i].bankWithSureHit = 0; + } + } + } + if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS) + { + gBattleMons[gActiveBank].status2 &= (STATUS2_CONFUSION | STATUS2_FOCUS_ENERGY | STATUS2_SUBSTITUTE | STATUS2_ESCAPE_PREVENTION | STATUS2_CURSED); + gStatuses3[gActiveBank] &= (STATUS3_LEECHSEED_BANK | STATUS3_LEECHSEED | STATUS3_ALWAYS_HITS | STATUS3_PERISH_SONG | STATUS3_ROOTED | STATUS3_MUDSPORT | STATUS3_WATERSPORT); + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (GetBankSide(gActiveBank) != GetBankSide(i) + && (gStatuses3[i] & STATUS3_ALWAYS_HITS) != 0 + && (gDisableStructs[i].bankWithSureHit == gActiveBank)) + { + gStatuses3[i] &= ~STATUS3_ALWAYS_HITS; + gStatuses3[i] |= 0x10; + } + } + } + else + { + gBattleMons[gActiveBank].status2 = 0; + gStatuses3[gActiveBank] = 0; + } + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(gActiveBank)) + gBattleMons[i].status2 &= ~(STATUS2_INFATUATED_WITH(gActiveBank)); + if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == gActiveBank) + gBattleMons[i].status2 &= ~(STATUS2_WRAPPED); + } + + gActionSelectionCursor[gActiveBank] = 0; + gMoveSelectionCursor[gActiveBank] = 0; + + ptr = (u8 *)&gDisableStructs[gActiveBank]; + for (i = 0; i < sizeof(struct DisableStruct); i++) + ptr[i] = 0; + + if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS) + { + gDisableStructs[gActiveBank].substituteHP = disableStructCopy.substituteHP; + gDisableStructs[gActiveBank].bankWithSureHit = disableStructCopy.bankWithSureHit; + gDisableStructs[gActiveBank].perishSong1 = disableStructCopy.perishSong1; + gDisableStructs[gActiveBank].perishSong2 = disableStructCopy.perishSong2; + gDisableStructs[gActiveBank].bankPreventingEscape = disableStructCopy.bankPreventingEscape; + } + + gBattleMoveFlags = 0; + gDisableStructs[gActiveBank].isFirstTurn= 2; + gDisableStructs[gActiveBank].truantUnknownBit = disableStructCopy.truantUnknownBit; + gLastUsedMovesByBanks[gActiveBank] = 0; + gUnknown_02024250[gActiveBank] = 0; + gUnknown_02024258[gActiveBank] = 0; + gUnknown_02024260[gActiveBank] = 0; + gUnknownMovesUsedByBanks[gActiveBank] = 0; + gUnknown_02024270[gActiveBank] = 0xFF; + + *(gBattleStruct->mirrorMoves + gActiveBank * 2 + 0) = 0; + *(gBattleStruct->mirrorMoves + gActiveBank * 2 + 1) = 0; + *(0 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(0 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(1 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(1 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(2 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(2 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(3 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(3 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + + gBattleStruct->field_92 &= ~(gBitTable[gActiveBank]); + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (i != gActiveBank && GetBankSide(i) != GetBankSide(gActiveBank)) + { + *(gBattleStruct->mirrorMoves + i * 2 + 0) = 0; + *(gBattleStruct->mirrorMoves + i * 2 + 1) = 0; + } + *(i * 8 + gActiveBank * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(i * 8 + gActiveBank * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + } + + *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBank]) + 0) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBank]) + 1) = 0; + + gBattleResources->flags->flags[gActiveBank] = 0; + gCurrentMove = 0; + gBattleStruct->field_DA = 0xFF; + + ClearBankMoveHistory(gActiveBank); + ClearBankAbilityHistory(gActiveBank); +} + +void FaintClearSetData(void) +{ + s32 i; + u8 *ptr; + + for (i = 0; i < BATTLE_STATS_NO; i++) + gBattleMons[gActiveBank].statStages[i] = 6; + + gBattleMons[gActiveBank].status2 = 0; + gStatuses3[gActiveBank] = 0; + + for (i = 0; i < gNoOfAllBanks; i++) + { + if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].bankPreventingEscape == gActiveBank) + gBattleMons[i].status2 &= ~STATUS2_ESCAPE_PREVENTION; + if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(gActiveBank)) + gBattleMons[i].status2 &= ~(STATUS2_INFATUATED_WITH(gActiveBank)); + if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == gActiveBank) + gBattleMons[i].status2 &= ~(STATUS2_WRAPPED); + } + + gActionSelectionCursor[gActiveBank] = 0; + gMoveSelectionCursor[gActiveBank] = 0; + + ptr = (u8 *)&gDisableStructs[gActiveBank]; + for (i = 0; i < sizeof(struct DisableStruct); i++) + ptr[i] = 0; + + gProtectStructs[gActiveBank].protected = 0; + gProtectStructs[gActiveBank].endured = 0; + gProtectStructs[gActiveBank].onlyStruggle = 0; + gProtectStructs[gActiveBank].helpingHand = 0; + gProtectStructs[gActiveBank].bounceMove = 0; + gProtectStructs[gActiveBank].stealMove = 0; + gProtectStructs[gActiveBank].flag0Unknown = 0; + gProtectStructs[gActiveBank].prlzImmobility = 0; + gProtectStructs[gActiveBank].confusionSelfDmg = 0; + gProtectStructs[gActiveBank].targetNotAffected = 0; + gProtectStructs[gActiveBank].chargingTurn = 0; + gProtectStructs[gActiveBank].fleeFlag = 0; + gProtectStructs[gActiveBank].usedImprisionedMove = 0; + gProtectStructs[gActiveBank].loveImmobility = 0; + gProtectStructs[gActiveBank].usedDisabledMove = 0; + gProtectStructs[gActiveBank].usedTauntedMove = 0; + gProtectStructs[gActiveBank].flag2Unknown = 0; + gProtectStructs[gActiveBank].flinchImmobility = 0; + gProtectStructs[gActiveBank].notFirstStrike = 0; + + gDisableStructs[gActiveBank].isFirstTurn = 2; + + gLastUsedMovesByBanks[gActiveBank] = 0; + gUnknown_02024250[gActiveBank] = 0; + gUnknown_02024258[gActiveBank] = 0; + gUnknown_02024260[gActiveBank] = 0; + gUnknownMovesUsedByBanks[gActiveBank] = 0; + gUnknown_02024270[gActiveBank] = 0xFF; + + *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBank]) + 0) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBank]) + 1) = 0; + + *(gBattleStruct->mirrorMoves + gActiveBank * 2 + 0) = 0; + *(gBattleStruct->mirrorMoves + gActiveBank * 2 + 1) = 0; + *(0 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(0 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(1 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(1 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(2 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(2 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(3 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(3 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + + gBattleStruct->field_92 &= ~(gBitTable[gActiveBank]); + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (i != gActiveBank && GetBankSide(i) != GetBankSide(gActiveBank)) + { + *(gBattleStruct->mirrorMoves + i * 2 + 0) = 0; + *(gBattleStruct->mirrorMoves + i * 2 + 1) = 0; + } + *(i * 8 + gActiveBank * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(i * 8 + gActiveBank * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + } + + gBattleResources->flags->flags[gActiveBank] = 0; + + gBattleMons[gActiveBank].type1 = gBaseStats[gBattleMons[gActiveBank].species].type1; + gBattleMons[gActiveBank].type2 = gBaseStats[gBattleMons[gActiveBank].species].type2; + + ClearBankMoveHistory(gActiveBank); + ClearBankAbilityHistory(gActiveBank); +} + +static void BattleIntroGetMonsData(void) +{ + switch (gBattleCommunication[MULTIUSE_STATE]) + { + case 0: + gActiveBank = gBattleCommunication[1]; + EmitGetMonData(0, 0, 0); + MarkBufferBankForExecution(gActiveBank); + gBattleCommunication[MULTIUSE_STATE]++; + break; + case 1: + if (gBattleExecBuffer == 0) + { + gBattleCommunication[1]++; + if (gBattleCommunication[1] == gNoOfAllBanks) + gBattleMainFunc = BattleIntroPrepareBackgroundSlide; + else + gBattleCommunication[MULTIUSE_STATE] = 0; + } + break; + } +} + +static void BattleIntroPrepareBackgroundSlide(void) +{ + if (gBattleExecBuffer == 0) + { + gActiveBank = GetBankByIdentity(0); + EmitIntroSlide(0, gBattleTerrain); + MarkBufferBankForExecution(gActiveBank); + gBattleMainFunc = BattleIntroDrawTrainersOrMonsSprites; + gBattleCommunication[0] = 0; + gBattleCommunication[1] = 0; + } +} + +static void BattleIntroDrawTrainersOrMonsSprites(void) +{ + u8 *ptr; + s32 i; + + if (gBattleExecBuffer) + return; + + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) + && GetBankSide(gActiveBank) == SIDE_PLAYER) + { + ptr = (u8 *)&gBattleMons[gActiveBank]; + for (i = 0; i < sizeof(struct BattlePokemon); i++) + ptr[i] = 0; + } + else + { + u16* hpOnSwitchout; + + ptr = (u8 *)&gBattleMons[gActiveBank]; + for (i = 0; i < sizeof(struct BattlePokemon); i++) + ptr[i] = gBattleBufferB[gActiveBank][4 + i]; + + gBattleMons[gActiveBank].type1 = gBaseStats[gBattleMons[gActiveBank].species].type1; + gBattleMons[gActiveBank].type2 = gBaseStats[gBattleMons[gActiveBank].species].type2; + gBattleMons[gActiveBank].ability = GetAbilityBySpecies(gBattleMons[gActiveBank].species, gBattleMons[gActiveBank].altAbility); + hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBankSide(gActiveBank)]; + *hpOnSwitchout = gBattleMons[gActiveBank].hp; + for (i = 0; i < BATTLE_STATS_NO; i++) + gBattleMons[gActiveBank].statStages[i] = 6; + gBattleMons[gActiveBank].status2 = 0; + } + + if (GetBankIdentity(gActiveBank) == IDENTITY_PLAYER_MON1) + { + EmitDrawTrainerPic(0); + MarkBufferBankForExecution(gActiveBank); + } + + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) + { + if (GetBankIdentity(gActiveBank) == IDENTITY_OPPONENT_MON1) + { + EmitDrawTrainerPic(0); + MarkBufferBankForExecution(gActiveBank); + } + if (GetBankSide(gActiveBank) == SIDE_OPPONENT + && !(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_FRONTIER + | BATTLE_TYPE_LINK + | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_x4000000))) + { + HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBank].species), FLAG_SET_SEEN, gBattleMons[gActiveBank].personality); + } + } + else + { + if (GetBankSide(gActiveBank) == SIDE_OPPONENT) + { + if (!(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_FRONTIER + | BATTLE_TYPE_LINK + | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_x4000000))) + { + HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBank].species), FLAG_SET_SEEN, gBattleMons[gActiveBank].personality); + } + EmitLoadMonSprite(0); + MarkBufferBankForExecution(gActiveBank); + gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES, NULL); + } + } + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + if (GetBankIdentity(gActiveBank) == IDENTITY_PLAYER_MON2 + || GetBankIdentity(gActiveBank) == IDENTITY_OPPONENT_MON2) + { + EmitDrawTrainerPic(0); + MarkBufferBankForExecution(gActiveBank); + } + } + + if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS && GetBankIdentity(gActiveBank) == IDENTITY_OPPONENT_MON2) + { + EmitDrawTrainerPic(0); + MarkBufferBankForExecution(gActiveBank); + } + + if (gBattleTypeFlags & BATTLE_TYPE_ARENA) + sub_81A56B4(); + } + gBattleMainFunc = BattleIntroDrawPartySummaryScreens; +} + +static void BattleIntroDrawPartySummaryScreens(void) +{ + s32 i; + struct HpAndStatus hpStatus[6]; + + if (gBattleExecBuffer) + return; + + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) + { + for (i = 0; i < 6; i++) + { + if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE + || GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) + { + hpStatus[i].hp = 0xFFFF; + hpStatus[i].status = 0; + } + else + { + hpStatus[i].hp = GetMonData(&gEnemyParty[i], MON_DATA_HP); + hpStatus[i].status = GetMonData(&gEnemyParty[i], MON_DATA_STATUS); + } + } + gActiveBank = GetBankByIdentity(IDENTITY_OPPONENT_MON1); + EmitDrawPartyStatusSummary(0, hpStatus, 0x80); + MarkBufferBankForExecution(gActiveBank); + + for (i = 0; i < 6; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE + || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) + { + hpStatus[i].hp = 0xFFFF; + hpStatus[i].status = 0; + } + else + { + hpStatus[i].hp = GetMonData(&gPlayerParty[i], MON_DATA_HP); + hpStatus[i].status = GetMonData(&gPlayerParty[i], MON_DATA_STATUS); + } + } + gActiveBank = GetBankByIdentity(IDENTITY_PLAYER_MON1); + EmitDrawPartyStatusSummary(0, hpStatus, 0x80); + MarkBufferBankForExecution(gActiveBank); + + gBattleMainFunc = BattleIntroPrintTrainerWantsToBattle; + } + else + { + // The struct gets set here, but nothing is ever done with it since + // wild battles don't show the party summary. + // Still, there's no point in having dead code. + + for (i = 0; i < 6; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE + || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) + { + hpStatus[i].hp = 0xFFFF; + hpStatus[i].status = 0; + } + else + { + hpStatus[i].hp = GetMonData(&gPlayerParty[i], MON_DATA_HP); + hpStatus[i].status = GetMonData(&gPlayerParty[i], MON_DATA_STATUS); + } + } + + gBattleMainFunc = BattleIntroPrintWildMonAttacked; + } + +} + +static void BattleIntroPrintTrainerWantsToBattle(void) +{ + if (gBattleExecBuffer == 0) + { + gActiveBank = GetBankByIdentity(IDENTITY_OPPONENT_MON1); + PrepareStringBattle(0, gActiveBank); + gBattleMainFunc = BattleIntroPrintOpponentSendsOut; + } +} + +static void BattleIntroPrintWildMonAttacked(void) +{ + if (gBattleExecBuffer == 0) + { + gBattleMainFunc = BattleIntroPrintPlayerSendsOut; + PrepareStringBattle(0, 0); + } +} + +static void BattleIntroPrintOpponentSendsOut(void) +{ + u32 identity; + + if (gBattleExecBuffer) + return; + + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) + identity = IDENTITY_OPPONENT_MON1; + else if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + { + if (gBattleTypeFlags & BATTLE_TYPE_x80000000) + identity = IDENTITY_OPPONENT_MON1; + else + identity = IDENTITY_PLAYER_MON1; + } + else + identity = IDENTITY_OPPONENT_MON1; + + PrepareStringBattle(1, GetBankByIdentity(identity)); + gBattleMainFunc = BattleIntroOpponent1SendsOutMonAnimation; +} + +static void BattleIntroOpponent2SendsOutMonAnimation(void) +{ + u32 identity; + + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) + identity = IDENTITY_OPPONENT_MON2; + else if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + { + if (gBattleTypeFlags & BATTLE_TYPE_x80000000) + identity = IDENTITY_OPPONENT_MON2; + else + identity = IDENTITY_PLAYER_MON2; + } + else + identity = IDENTITY_OPPONENT_MON2; + + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (GetBankIdentity(gActiveBank) == identity) + { + EmitIntroTrainerBallThrow(0); + MarkBufferBankForExecution(gActiveBank); + } + } + + gBattleMainFunc = BattleIntroRecordMonsToDex; +} + +#ifdef NONMATCHING +static void BattleIntroOpponent1SendsOutMonAnimation(void) +{ + u32 identity; + + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) + identity = IDENTITY_OPPONENT_MON1; + else if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + { + if (gBattleTypeFlags & BATTLE_TYPE_x80000000) + identity = IDENTITY_OPPONENT_MON1; + else + identity = IDENTITY_PLAYER_MON1; + } + else + identity = IDENTITY_OPPONENT_MON1; + + if (gBattleExecBuffer) + return; + + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (GetBankIdentity(gActiveBank) == identity) + { + EmitIntroTrainerBallThrow(0); + MarkBufferBankForExecution(gActiveBank); + if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS)) + { + gBattleMainFunc = BattleIntroOpponent2SendsOutMonAnimation; + return; + } + } + } + + gBattleMainFunc = BattleIntroRecordMonsToDex; +} + +#else +__attribute__((naked)) +static void BattleIntroOpponent1SendsOutMonAnimation(void) +{ + asm(".syntax unified\n\ + push {r4-r6,lr}\n\ + ldr r0, =gBattleTypeFlags\n\ + ldr r2, [r0]\n\ + movs r0, 0x80\n\ + lsls r0, 17\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + beq _0803B298\n\ + movs r0, 0x80\n\ + lsls r0, 18\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + beq _0803B298\n\ + movs r1, 0x80\n\ + lsls r1, 24\n\ + ands r1, r2\n\ + negs r0, r1\n\ + orrs r0, r1\n\ + lsrs r5, r0, 31\n\ + b _0803B29A\n\ + .pool\n\ +_0803B288:\n\ + ldr r1, =gBattleMainFunc\n\ + ldr r0, =BattleIntroOpponent2SendsOutMonAnimation\n\ + b _0803B2F0\n\ + .pool\n\ +_0803B298:\n\ + movs r5, 0x1\n\ +_0803B29A:\n\ + ldr r0, =gBattleExecBuffer\n\ + ldr r2, [r0]\n\ + cmp r2, 0\n\ + bne _0803B2F2\n\ + ldr r0, =gActiveBank\n\ + strb r2, [r0]\n\ + ldr r1, =gNoOfAllBanks\n\ + adds r4, r0, 0\n\ + ldrb r1, [r1]\n\ + cmp r2, r1\n\ + bcs _0803B2EC\n\ + adds r6, r4, 0\n\ +_0803B2B2:\n\ + ldrb r0, [r4]\n\ + bl GetBankIdentity\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, r5\n\ + bne _0803B2D8\n\ + movs r0, 0\n\ + bl EmitIntroTrainerBallThrow\n\ + ldrb r0, [r4]\n\ + bl MarkBufferBankForExecution\n\ + ldr r0, =gBattleTypeFlags\n\ + ldr r0, [r0]\n\ + ldr r1, =0x00008040\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0803B288\n\ +_0803B2D8:\n\ + ldrb r0, [r6]\n\ + adds r0, 0x1\n\ + strb r0, [r6]\n\ + ldr r1, =gNoOfAllBanks\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + ldr r4, =gActiveBank\n\ + ldrb r1, [r1]\n\ + cmp r0, r1\n\ + bcc _0803B2B2\n\ +_0803B2EC:\n\ + ldr r1, =gBattleMainFunc\n\ + ldr r0, =BattleIntroRecordMonsToDex\n\ +_0803B2F0:\n\ + str r0, [r1]\n\ +_0803B2F2:\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided"); +} + +#endif // NONMATCHING + +static void BattleIntroRecordMonsToDex(void) +{ + if (gBattleExecBuffer == 0) + { + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (GetBankSide(gActiveBank) == SIDE_OPPONENT + && !(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_FRONTIER + | BATTLE_TYPE_LINK + | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_x4000000))) + { + HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBank].species), FLAG_SET_SEEN, gBattleMons[gActiveBank].personality); + } + } + gBattleMainFunc = BattleIntroPrintPlayerSendsOut; + } +} + +void sub_803B3AC(void) // unused +{ + if (gBattleExecBuffer == 0) + gBattleMainFunc = BattleIntroPrintPlayerSendsOut; +} + +static void BattleIntroPrintPlayerSendsOut(void) +{ + if (gBattleExecBuffer == 0) + { + u8 identity; + + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) + identity = IDENTITY_PLAYER_MON1; + else if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + { + if (gBattleTypeFlags & BATTLE_TYPE_x80000000) + identity = IDENTITY_PLAYER_MON1; + else + identity = IDENTITY_OPPONENT_MON1; + } + else + identity = IDENTITY_PLAYER_MON1; + + if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) + PrepareStringBattle(1, GetBankByIdentity(identity)); + + gBattleMainFunc = BattleIntroPlayer1SendsOutMonAnimation; + } +} + +static void BattleIntroPlayer2SendsOutMonAnimation(void) +{ + u32 identity; + + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) + identity = IDENTITY_PLAYER_MON2; + else if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + { + if (gBattleTypeFlags & BATTLE_TYPE_x80000000) + identity = IDENTITY_PLAYER_MON2; + else + identity = IDENTITY_OPPONENT_MON2; + } + else + identity = IDENTITY_PLAYER_MON2; + + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (GetBankIdentity(gActiveBank) == identity) + { + EmitIntroTrainerBallThrow(0); + MarkBufferBankForExecution(gActiveBank); + } + } + + gBattleStruct->switchInAbilitiesCounter = 0; + gBattleStruct->switchInItemsCounter = 0; + gBattleStruct->overworldWeatherDone = FALSE; + + gBattleMainFunc = TryDoEventsBeforeFirstTurn; +} + +static void BattleIntroPlayer1SendsOutMonAnimation(void) +{ + u32 identity; + + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) + identity = IDENTITY_PLAYER_MON1; + else if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + { + if (gBattleTypeFlags & BATTLE_TYPE_x80000000) + identity = IDENTITY_PLAYER_MON1; + else + identity = IDENTITY_OPPONENT_MON1; + } + else + identity = IDENTITY_PLAYER_MON1; + + if (gBattleExecBuffer) + return; + + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (GetBankIdentity(gActiveBank) == identity) + { + EmitIntroTrainerBallThrow(0); + MarkBufferBankForExecution(gActiveBank); + if (gBattleTypeFlags & (BATTLE_TYPE_MULTI)) + { + gBattleMainFunc = BattleIntroPlayer2SendsOutMonAnimation; + return; + } + } + } + + gBattleStruct->switchInAbilitiesCounter = 0; + gBattleStruct->switchInItemsCounter = 0; + gBattleStruct->overworldWeatherDone = FALSE; + + gBattleMainFunc = TryDoEventsBeforeFirstTurn; +} + +void sub_803B598(void) // unused +{ + if (gBattleExecBuffer == 0) + { + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (GetBankSide(gActiveBank) == SIDE_PLAYER) + { + EmitSwitchInAnim(0, gBattlePartyID[gActiveBank], FALSE); + MarkBufferBankForExecution(gActiveBank); + } + } + + gBattleStruct->switchInAbilitiesCounter = 0; + gBattleStruct->switchInItemsCounter = 0; + gBattleStruct->overworldWeatherDone = FALSE; + + gBattleMainFunc = TryDoEventsBeforeFirstTurn; + } +} + +static void TryDoEventsBeforeFirstTurn(void) +{ + s32 i; + s32 j; + u8 effect = 0; + + if (gBattleExecBuffer) + return; + + if (gBattleStruct->switchInAbilitiesCounter == 0) + { + for (i = 0; i < gNoOfAllBanks; i++) + gBanksByTurnOrder[i] = i; + for (i = 0; i < gNoOfAllBanks - 1; i++) + { + for (j = i + 1; j < gNoOfAllBanks; j++) + { + if (GetWhoStrikesFirst(gBanksByTurnOrder[i], gBanksByTurnOrder[j], TRUE) != 0) + SwapTurnOrder(i, j); + } + } + } + if (!gBattleStruct->overworldWeatherDone + && AbilityBattleEffects(0, 0, 0, ABILITYEFFECT_SWITCH_IN_WEATHER, 0) != 0) + { + gBattleStruct->overworldWeatherDone = TRUE; + return; + } + // check all switch in abilities happening from the fastest mon to slowest + while (gBattleStruct->switchInAbilitiesCounter < gNoOfAllBanks) + { + if (AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gBanksByTurnOrder[gBattleStruct->switchInAbilitiesCounter], 0, 0, 0) != 0) + effect++; + + gBattleStruct->switchInAbilitiesCounter++; + + if (effect) + return; + } + if (AbilityBattleEffects(ABILITYEFFECT_INTIMIDATE1, 0, 0, 0, 0) != 0) + return; + if (AbilityBattleEffects(ABILITYEFFECT_TRACE, 0, 0, 0, 0) != 0) + return; + // check all switch in items having effect from the fastest mon to slowest + while (gBattleStruct->switchInItemsCounter < gNoOfAllBanks) + { + if (ItemBattleEffects(ITEMEFFECT_ON_SWITCH_IN, gBanksByTurnOrder[gBattleStruct->switchInItemsCounter], 0) != 0) + effect++; + + gBattleStruct->switchInItemsCounter++; + + if (effect) + return; + } + for (i = 0; i < BATTLE_BANKS_COUNT; i++) + { + *(gBattleStruct->field_5C + i) = 6; + gActionForBanks[i] = ACTION_INIT_VALUE; + gChosenMovesByBanks[i] = MOVE_NONE; + } + TurnValuesCleanUp(FALSE); + SpecialStatusesClear(); + *(&gBattleStruct->field_91) = gAbsentBankFlags; + sub_814F9EC(gText_EmptyString3, 0); + gBattleMainFunc = HandleTurnActionSelectionState; + ResetSentPokesToOpponentValue(); + + for (i = 0; i < BATTLE_COMMUNICATION_ENTRIES_COUNT; i++) + gBattleCommunication[i] = 0; + + for (i = 0; i < gNoOfAllBanks; i++) + gBattleMons[i].status2 &= ~(STATUS2_FLINCHED); + + *(&gBattleStruct->turnEffectsTracker) = 0; + *(&gBattleStruct->turnEffectsBank) = 0; + *(&gBattleStruct->field_1A0) = 0; + *(&gBattleStruct->field_1A1) = 0; + gBattleScripting.atk49_state = 0; + gBattleStruct->field_4D = 0; + gBattleStruct->turncountersTracker = 0; + gBattleMoveFlags = 0; + + gRandomTurnNumber = Random(); + + if (gBattleTypeFlags & BATTLE_TYPE_ARENA) + { + StopCryAndClearCrySongs(); + BattleScriptExecute(gUnknown_082DB8BE); + } +} + +static void HandleEndTurn_ContinueBattle(void) +{ + s32 i; + + if (gBattleExecBuffer == 0) + { + gBattleMainFunc = BattleTurnPassed; + for (i = 0; i < BATTLE_COMMUNICATION_ENTRIES_COUNT; i++) + gBattleCommunication[i] = 0; + for (i = 0; i < gNoOfAllBanks; i++) + { + gBattleMons[i].status2 &= ~(STATUS2_FLINCHED); + if ((gBattleMons[i].status1 & STATUS_SLEEP) && (gBattleMons[i].status2 & STATUS2_MULTIPLETURNS)) + CancelMultiTurnMoves(i); + } + gBattleStruct->turnEffectsTracker = 0; + gBattleStruct->turnEffectsBank = 0; + gBattleStruct->field_1A0 = 0; + gBattleStruct->field_1A1 = 0; + gBattleStruct->turncountersTracker = 0; + gBattleMoveFlags = 0; + } +} + +void BattleTurnPassed(void) +{ + s32 i; + + TurnValuesCleanUp(TRUE); + if (gBattleOutcome == 0) + { + if (UpdateTurnCounters() != 0) + return; + if (TurnBasedEffects() != 0) + return; + } + if (sub_8041728() != 0) + return; + gBattleStruct->field_4D = 0; + if (sub_8041364() != 0) + return; + + TurnValuesCleanUp(FALSE); + gHitMarker &= ~(HITMARKER_NO_ATTACKSTRING); + gHitMarker &= ~(HITMARKER_UNABLE_TO_USE_MOVE); + gHitMarker &= ~(HITMARKER_x400000); + gHitMarker &= ~(HITMARKER_x100000); + gBattleScripting.animTurn = 0; + gBattleScripting.animTargetsHit = 0; + gBattleScripting.atk49_state = 0; + gBattleMoveDamage = 0; + gBattleMoveFlags = 0; + + for (i = 0; i < 5; i++) + gBattleCommunication[i] = 0; + + if (gBattleOutcome != 0) + { + gCurrentActionFuncId = 12; + gBattleMainFunc = RunTurnActionsFunctions; + return; + } + + if (gBattleResults.battleTurnCounter < 0xFF) + { + gBattleResults.battleTurnCounter++; + gBattleStruct->field_DA++; + } + + for (i = 0; i < gNoOfAllBanks; i++) + { + gActionForBanks[i] = ACTION_INIT_VALUE; + gChosenMovesByBanks[i] = MOVE_NONE; + } + + for (i = 0; i < 4; i++) + *(gBattleStruct->field_5C + i) = 6; + + *(&gBattleStruct->field_91) = gAbsentBankFlags; + sub_814F9EC(gText_EmptyString3, 0); + gBattleMainFunc = HandleTurnActionSelectionState; + gRandomTurnNumber = Random(); + + if (gBattleTypeFlags & BATTLE_TYPE_PALACE) + BattleScriptExecute(gUnknown_082DB881); + else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->field_DA == 0) + BattleScriptExecute(gUnknown_082DB8BE); +} + +u8 IsRunningFromBattleImpossible(void) +{ + u8 holdEffect; + u8 side; + s32 i; + + if (gBattleMons[gActiveBank].item == ITEM_ENIGMA_BERRY) + holdEffect = gEnigmaBerries[gActiveBank].holdEffect; + else + holdEffect = ItemId_GetHoldEffect(gBattleMons[gActiveBank].item); + + gStringBank = gActiveBank; + + if (holdEffect == HOLD_EFFECT_CAN_ALWAYS_RUN) + return 0; + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + return 0; + if (gBattleMons[gActiveBank].ability == ABILITY_RUN_AWAY) + return 0; + + side = GetBankSide(gActiveBank); + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (side != GetBankSide(i) + && gBattleMons[i].ability == ABILITY_SHADOW_TAG) + { + gBattleScripting.bank = i; + gLastUsedAbility = gBattleMons[i].ability; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + return 2; + } + if (side != GetBankSide(i) + && gBattleMons[gActiveBank].ability != ABILITY_LEVITATE + && gBattleMons[gActiveBank].type1 != TYPE_FLYING + && gBattleMons[gActiveBank].type2 != TYPE_FLYING + && gBattleMons[i].ability == ABILITY_ARENA_TRAP) + { + gBattleScripting.bank = i; + gLastUsedAbility = gBattleMons[i].ability; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + return 2; + } + } + i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK, gActiveBank, ABILITY_MAGNET_PULL, 0, 0); + if (i != 0 && (gBattleMons[gActiveBank].type1 == TYPE_STEEL || gBattleMons[gActiveBank].type2 == TYPE_STEEL)) + { + gBattleScripting.bank = i - 1; + gLastUsedAbility = gBattleMons[i - 1].ability; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + return 2; + } + if ((gBattleMons[gActiveBank].status2 & (STATUS2_ESCAPE_PREVENTION | STATUS2_WRAPPED)) + || (gStatuses3[gActiveBank] & STATUS3_ROOTED)) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + return 1; + } + if (gBattleTypeFlags & BATTLE_TYPE_FIRST_BATTLE) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + return 1; + } + return 0; +} + +void sub_803BDA0(u8 bank) +{ + s32 i; + u8 r4; + u8 r1; + + // gBattleStruct->field_60[bank][i] + + for (i = 0; i < 3; i++) + gUnknown_0203CF00[i] = *(bank * 3 + i + (u8*)(gBattleStruct->field_60)); + + r4 = pokemon_order_func(gBattlePartyID[bank]); + r1 = pokemon_order_func(*(gBattleStruct->field_5C + bank)); + sub_81B8FB0(r4, r1); + + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + for (i = 0; i < 3; i++) + { + *(bank * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; + *((bank ^ BIT_MON) * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; + } + } + else + { + for (i = 0; i < 3; i++) + { + *(bank * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; + } + } +} + +enum +{ + STATE_TURN_START_RECORD, + STATE_BEFORE_ACTION_CHOSEN, + STATE_WAIT_ACTION_CHOSEN, + STATE_WAIT_ACTION_CASE_CHOSEN, + STATE_WAIT_ACTION_CONFIRMED_STANDBY, + STATE_WAIT_ACTION_CONFIRMED, + STATE_SELECTION_SCRIPT, + STATE_WAIT_SET_BEFORE_ACTION, + STATE_SELECTION_SCRIPT_MAY_RUN +}; + +static void HandleTurnActionSelectionState(void) +{ + s32 i; + + gBattleCommunication[ACTIONS_CONFIRMED_COUNT] = 0; + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + u8 identity = GetBankIdentity(gActiveBank); + switch (gBattleCommunication[gActiveBank]) + { + case STATE_TURN_START_RECORD: // recorded battle related on start of every turn + sub_8185FD0(); + gBattleCommunication[gActiveBank] = STATE_BEFORE_ACTION_CHOSEN; + break; + case STATE_BEFORE_ACTION_CHOSEN: // choose an action + *(gBattleStruct->field_5C + gActiveBank) = 6; + if (gBattleTypeFlags & BATTLE_TYPE_MULTI + || !(identity & BIT_MON) + || gBattleStruct->field_91 & gBitTable[GetBankByIdentity(identity ^ BIT_MON)] + || gBattleCommunication[GetBankByIdentity(identity ^ BIT_MON)] == 5) + { + if (gBattleStruct->field_91 & gBitTable[gActiveBank]) + { + gActionForBanks[gActiveBank] = ACTION_NOTHING_FAINTED; + if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) + gBattleCommunication[gActiveBank] = STATE_WAIT_ACTION_CONFIRMED; + else + gBattleCommunication[gActiveBank] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; + } + else + { + if (gBattleMons[gActiveBank].status2 & STATUS2_MULTIPLETURNS + || gBattleMons[gActiveBank].status2 & STATUS2_RECHARGE) + { + gActionForBanks[gActiveBank] = ACTION_USE_MOVE; + gBattleCommunication[gActiveBank] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; + } + else + { + EmitChooseAction(0, gActionForBanks[0], gBattleBufferB[0][1] | (gBattleBufferB[0][2] << 8)); + MarkBufferBankForExecution(gActiveBank); + gBattleCommunication[gActiveBank]++; + } + } + } + break; + case STATE_WAIT_ACTION_CHOSEN: // try to perform an action + if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + { + RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][1]); + gActionForBanks[gActiveBank] = gBattleBufferB[gActiveBank][1]; + + switch (gBattleBufferB[gActiveBank][1]) + { + case ACTION_USE_MOVE: + if (AreAllMovesUnusable()) + { + gBattleCommunication[gActiveBank] = STATE_SELECTION_SCRIPT; + *(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE; + *(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_WAIT_ACTION_CONFIRMED_STANDBY; + *(gBattleStruct->moveTarget + gActiveBank) = gBattleBufferB[gActiveBank][3]; + return; + } + else if (gDisableStructs[gActiveBank].encoredMove != 0) + { + gChosenMovesByBanks[gActiveBank] = gDisableStructs[gActiveBank].encoredMove; + *(gBattleStruct->chosenMovePositions + gActiveBank) = gDisableStructs[gActiveBank].encoredMovePos; + gBattleCommunication[gActiveBank] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; + return; + } + else + { + struct ChooseMoveStruct moveInfo; + + moveInfo.species = gBattleMons[gActiveBank].species; + moveInfo.monType1 = gBattleMons[gActiveBank].type1; + moveInfo.monType2 = gBattleMons[gActiveBank].type2; + + for (i = 0; i < 4; i++) + { + moveInfo.moves[i] = gBattleMons[gActiveBank].moves[i]; + moveInfo.ppNumbers[i] = gBattleMons[gActiveBank].pp[i]; + moveInfo.ppWithBonusNumbers[i] = CalculatePPWithBonus( + gBattleMons[gActiveBank].moves[i], + gBattleMons[gActiveBank].ppBonuses, + i); + } + + EmitChooseMove(0, (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) != 0, FALSE, &moveInfo); + MarkBufferBankForExecution(gActiveBank); + } + break; + case ACTION_USE_ITEM: + if (gBattleTypeFlags & (BATTLE_TYPE_LINK + | BATTLE_TYPE_FRONTIER_NO_PYRAMID + | BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_x2000000)) + { + RecordedBattle_ClearBankAction(gActiveBank, 1); + gBattlescriptPtrsForSelection[gActiveBank] = BattleScript_ActionSelectionItemsCantBeUsed; + gBattleCommunication[gActiveBank] = STATE_SELECTION_SCRIPT; + *(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE; + *(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_BEFORE_ACTION_CHOSEN; + return; + } + else + { + EmitOpenBag(0, gBattleStruct->field_60[gActiveBank]); + MarkBufferBankForExecution(gActiveBank); + } + break; + case ACTION_SWITCH: + *(gBattleStruct->field_58 + gActiveBank) = gBattlePartyID[gActiveBank]; + if (gBattleMons[gActiveBank].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION) + || gBattleTypeFlags & BATTLE_TYPE_ARENA + || gStatuses3[gActiveBank] & STATUS3_ROOTED) + { + EmitChoosePokemon(0, 2, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBank]); + } + else if ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBank, ABILITY_SHADOW_TAG, 0, 0)) + || ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBank, ABILITY_ARENA_TRAP, 0, 0)) + && gBattleMons[gActiveBank].type1 != TYPE_FLYING + && gBattleMons[gActiveBank].type2 != TYPE_FLYING + && gBattleMons[gActiveBank].ability != ABILITY_LEVITATE) + || ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK, gActiveBank, ABILITY_MAGNET_PULL, 0, 0)) + && (gBattleMons[gActiveBank].type1 == TYPE_STEEL + || gBattleMons[gActiveBank].type2 == TYPE_STEEL))) + { + EmitChoosePokemon(0, ((i - 1) << 4) | 4, 6, gLastUsedAbility, gBattleStruct->field_60[gActiveBank]); + } + else + { + if (gActiveBank == 2 && gActionForBanks[0] == ACTION_SWITCH) + EmitChoosePokemon(0, 0, *(gBattleStruct->field_5C + 0), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]); + else if (gActiveBank == 3 && gActionForBanks[1] == ACTION_SWITCH) + EmitChoosePokemon(0, 0, *(gBattleStruct->field_5C + 1), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]); + else + EmitChoosePokemon(0, 0, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBank]); + } + MarkBufferBankForExecution(gActiveBank); + break; + case ACTION_SAFARI_ZONE_BALL: + if (IsPlayerPartyAndPokemonStorageFull()) + { + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DAB11; + gBattleCommunication[gActiveBank] = STATE_SELECTION_SCRIPT; + *(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE; + *(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_BEFORE_ACTION_CHOSEN; + return; + } + break; + case ACTION_POKEBLOCK_CASE: + EmitOpenBag(0, gBattleStruct->field_60[gActiveBank]); + MarkBufferBankForExecution(gActiveBank); + break; + case ACTION_CANCEL_PARTNER: + gBattleCommunication[gActiveBank] = 7; + gBattleCommunication[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] = 1; + RecordedBattle_ClearBankAction(gActiveBank, 1); + if (gBattleMons[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)].status2 & STATUS2_MULTIPLETURNS + || gBattleMons[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)].status2 & STATUS2_RECHARGE) + { + Emit_x32(0); + MarkBufferBankForExecution(gActiveBank); + return; + } + else if (gActionForBanks[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] == ACTION_SWITCH) + { + RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 2); + } + else if (gActionForBanks[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] == ACTION_RUN) + { + RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 1); + } + else if (gActionForBanks[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] == ACTION_USE_MOVE + && (gProtectStructs[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)].onlyStruggle + || gDisableStructs[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)].encoredMove)) + { + RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 1); + } + else if (gBattleTypeFlags & BATTLE_TYPE_PALACE + && gActionForBanks[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] == ACTION_USE_MOVE) + { + gRngValue = gBattlePalaceMoveSelectionRngValue; + RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 1); + } + else + { + RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 3); + } + Emit_x32(0); + MarkBufferBankForExecution(gActiveBank); + return; + } + + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER + && gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_x4000000) + && gBattleBufferB[gActiveBank][1] == ACTION_RUN) + { + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB9BA; + gBattleCommunication[gActiveBank] = 8; + *(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE; + *(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_BEFORE_ACTION_CHOSEN; + return; + } + else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER + && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + && gBattleBufferB[gActiveBank][1] == ACTION_RUN) + { + BattleScriptExecute(gUnknown_082DAAFE); + gBattleCommunication[gActiveBank] = 1; + } + else if (IsRunningFromBattleImpossible() != 0 + && gBattleBufferB[gActiveBank][1] == ACTION_RUN) + { + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DAB0B; + gBattleCommunication[gActiveBank] = STATE_SELECTION_SCRIPT; + *(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE; + *(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_BEFORE_ACTION_CHOSEN; + return; + } + else + { + gBattleCommunication[gActiveBank]++; + } + } + break; + case STATE_WAIT_ACTION_CASE_CHOSEN: + if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + { + switch (gActionForBanks[gActiveBank]) + { + case ACTION_USE_MOVE: + switch (gBattleBufferB[gActiveBank][1]) + { + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + gActionForBanks[gActiveBank] = gBattleBufferB[gActiveBank][1]; + return; + case 15: + gActionForBanks[gActiveBank] = ACTION_SWITCH; + sub_803CDF8(); + return; + default: + sub_818603C(2); + if ((gBattleBufferB[gActiveBank][2] | (gBattleBufferB[gActiveBank][3] << 8)) == 0xFFFF) + { + gBattleCommunication[gActiveBank] = 1; + RecordedBattle_ClearBankAction(gActiveBank, 1); + } + else if (TrySetCantSelectMoveBattleScript()) + { + RecordedBattle_ClearBankAction(gActiveBank, 1); + gBattleCommunication[gActiveBank] = STATE_SELECTION_SCRIPT; + *(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE; + gBattleBufferB[gActiveBank][1] = 0; + *(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_WAIT_ACTION_CHOSEN; + return; + } + else + { + if (!(gBattleTypeFlags & BATTLE_TYPE_PALACE)) + { + RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][2]); + RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][3]); + } + *(gBattleStruct->chosenMovePositions + gActiveBank) = gBattleBufferB[gActiveBank][2]; + gChosenMovesByBanks[gActiveBank] = gBattleMons[gActiveBank].moves[*(gBattleStruct->chosenMovePositions + gActiveBank)]; + *(gBattleStruct->moveTarget + gActiveBank) = gBattleBufferB[gActiveBank][3]; + gBattleCommunication[gActiveBank]++; + } + break; + } + break; + case ACTION_USE_ITEM: + if ((gBattleBufferB[gActiveBank][1] | (gBattleBufferB[gActiveBank][2] << 8)) == 0) + { + gBattleCommunication[gActiveBank] = 1; + } + else + { + gLastUsedItem = (gBattleBufferB[gActiveBank][1] | (gBattleBufferB[gActiveBank][2] << 8)); + gBattleCommunication[gActiveBank]++; + } + break; + case ACTION_SWITCH: + if (gBattleBufferB[gActiveBank][1] == 6) + { + gBattleCommunication[gActiveBank] = 1; + RecordedBattle_ClearBankAction(gActiveBank, 1); + } + else + { + sub_803CDF8(); + gBattleCommunication[gActiveBank]++; + } + break; + case ACTION_RUN: + gHitMarker |= HITMARKER_RUN; + gBattleCommunication[gActiveBank]++; + break; + case ACTION_WATCHES_CAREFULLY: + gBattleCommunication[gActiveBank]++; + break; + case ACTION_SAFARI_ZONE_BALL: + gBattleCommunication[gActiveBank]++; + break; + case ACTION_POKEBLOCK_CASE: + if ((gBattleBufferB[gActiveBank][1] | (gBattleBufferB[gActiveBank][2] << 8)) != 0) + { + gBattleCommunication[gActiveBank]++; + } + else + { + gBattleCommunication[gActiveBank] = STATE_BEFORE_ACTION_CHOSEN; + } + break; + case ACTION_GO_NEAR: + gBattleCommunication[gActiveBank]++; + break; + case ACTION_SAFARI_ZONE_RUN: + gHitMarker |= HITMARKER_RUN; + gBattleCommunication[gActiveBank]++; + break; + case ACTION_9: + gBattleCommunication[gActiveBank]++; + break; + } + } + break; + case STATE_WAIT_ACTION_CONFIRMED_STANDBY: + if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + { + i = (sub_803CDB8() != 0); + + if (((gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_DOUBLE)) != BATTLE_TYPE_DOUBLE) + || (identity & BIT_MON) + || (*(&gBattleStruct->field_91) & gBitTable[GetBankByIdentity(identity ^ BIT_MON)])) + { + EmitLinkStandbyMsg(0, 0, i); + } + else + { + EmitLinkStandbyMsg(0, 1, i); + } + MarkBufferBankForExecution(gActiveBank); + gBattleCommunication[gActiveBank]++; + } + break; + case STATE_WAIT_ACTION_CONFIRMED: + if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + { + gBattleCommunication[ACTIONS_CONFIRMED_COUNT]++; + } + break; + case STATE_SELECTION_SCRIPT: + if (*(gBattleStruct->selectionScriptFinished + gActiveBank)) + { + gBattleCommunication[gActiveBank] = *(gBattleStruct->stateIdAfterSelScript + gActiveBank); + } + else + { + gBankAttacker = gActiveBank; + gBattlescriptCurrInstr = gBattlescriptPtrsForSelection[gActiveBank]; + if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + { + gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]](); + } + gBattlescriptPtrsForSelection[gActiveBank] = gBattlescriptCurrInstr; + } + break; + case STATE_WAIT_SET_BEFORE_ACTION: + if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + { + gBattleCommunication[gActiveBank] = 1; + } + break; + case STATE_SELECTION_SCRIPT_MAY_RUN: + if (*(gBattleStruct->selectionScriptFinished + gActiveBank)) + { + if (gBattleBufferB[gActiveBank][1] == 13) + { + gHitMarker |= HITMARKER_RUN; + gActionForBanks[gActiveBank] = ACTION_RUN; + gBattleCommunication[gActiveBank] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; + } + else + { + RecordedBattle_ClearBankAction(gActiveBank, 1); + gBattleCommunication[gActiveBank] = *(gBattleStruct->stateIdAfterSelScript + gActiveBank); + } + } + else + { + gBankAttacker = gActiveBank; + gBattlescriptCurrInstr = gBattlescriptPtrsForSelection[gActiveBank]; + if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + { + gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]](); + } + gBattlescriptPtrsForSelection[gActiveBank] = gBattlescriptCurrInstr; + } + break; + } + } + + // check if everyone chose actions + if (gBattleCommunication[ACTIONS_CONFIRMED_COUNT] == gNoOfAllBanks) + { + sub_818603C(1); + gBattleMainFunc = SetActionsAndBanksTurnOrder; + + if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) + { + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gActionForBanks[i] == ACTION_SWITCH) + sub_80571DC(i, *(gBattleStruct->field_5C + i)); + } + } + } +} + +static bool8 sub_803CDB8(void) +{ + s32 i, var; + + for (var = 0, i = 0; i < gNoOfAllBanks; i++) + { + if (gBattleCommunication[i] == 5) + var++; + } + + if (var + 1 == gNoOfAllBanks) + return TRUE; + else + return FALSE; +} + +static void sub_803CDF8(void) +{ + *(gBattleStruct->field_5C + gActiveBank) = gBattleBufferB[gActiveBank][1]; + RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][1]); + + if (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 0) &= 0xF; + *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBank][2] & 0xF0); + *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 1) = gBattleBufferB[gActiveBank][3]; + + *((gActiveBank ^ BIT_MON) * 3 + (u8*)(gBattleStruct->field_60) + 0) &= (0xF0); + *((gActiveBank ^ BIT_MON) * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBank][2] & 0xF0) >> 4; + *((gActiveBank ^ BIT_MON) * 3 + (u8*)(gBattleStruct->field_60) + 2) = gBattleBufferB[gActiveBank][3]; + } +} + +void SwapTurnOrder(u8 id1, u8 id2) +{ + u32 temp = gActionsByTurnOrder[id1]; + gActionsByTurnOrder[id1] = gActionsByTurnOrder[id2]; + gActionsByTurnOrder[id2] = temp; + + temp = gBanksByTurnOrder[id1]; + gBanksByTurnOrder[id1] = gBanksByTurnOrder[id2]; + gBanksByTurnOrder[id2] = temp; +} + +u8 GetWhoStrikesFirst(u8 bank1, u8 bank2, bool8 ignoreChosenMoves) +{ + u8 strikesFirst = 0; + u8 speedMultiplierBank1 = 0, speedMultiplierBank2 = 0; + u32 speedBank1 = 0, speedBank2 = 0; + u8 holdEffect = 0; + u8 holdEffectParam = 0; + u16 moveBank1 = 0, moveBank2 = 0; + + if (WEATHER_HAS_EFFECT) + { + if ((gBattleMons[bank1].ability == ABILITY_SWIFT_SWIM && gBattleWeather & WEATHER_RAIN_ANY) + || (gBattleMons[bank1].ability == ABILITY_CHLOROPHYLL && gBattleWeather & WEATHER_SUN_ANY)) + speedMultiplierBank1 = 2; + else + speedMultiplierBank1 = 1; + + if ((gBattleMons[bank2].ability == ABILITY_SWIFT_SWIM && gBattleWeather & WEATHER_RAIN_ANY) + || (gBattleMons[bank2].ability == ABILITY_CHLOROPHYLL && gBattleWeather & WEATHER_SUN_ANY)) + speedMultiplierBank2 = 2; + else + speedMultiplierBank2 = 1; + } + else + { + speedMultiplierBank1 = 1; + speedMultiplierBank2 = 1; + } + + speedBank1 = (gBattleMons[bank1].speed * speedMultiplierBank1) + * (gStatStageRatios[gBattleMons[bank1].statStages[STAT_STAGE_SPEED]][0]) + / (gStatStageRatios[gBattleMons[bank1].statStages[STAT_STAGE_SPEED]][1]); + + if (gBattleMons[bank1].item == ITEM_ENIGMA_BERRY) + { + holdEffect = gEnigmaBerries[bank1].holdEffect; + holdEffectParam = gEnigmaBerries[bank1].holdEffectParam; + } + else + { + holdEffect = ItemId_GetHoldEffect(gBattleMons[bank1].item); + holdEffectParam = ItemId_GetHoldEffectParam(gBattleMons[bank1].item); + } + + // badge boost + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_FRONTIER)) + && FlagGet(BADGE03_GET) + && GetBankSide(bank1) == SIDE_PLAYER) + { + speedBank1 = (speedBank1 * 110) / 100; + } + + if (holdEffect == HOLD_EFFECT_MACHO_BRACE) + speedBank1 /= 2; + + if (gBattleMons[bank1].status1 & STATUS_PARALYSIS) + speedBank1 /= 4; + + if (holdEffect == HOLD_EFFECT_QUICK_CLAW && gRandomTurnNumber < (0xFFFF * holdEffectParam) / 100) + speedBank1 = UINT_MAX; + + // check second bank's speed + + speedBank2 = (gBattleMons[bank2].speed * speedMultiplierBank2) + * (gStatStageRatios[gBattleMons[bank2].statStages[STAT_STAGE_SPEED]][0]) + / (gStatStageRatios[gBattleMons[bank2].statStages[STAT_STAGE_SPEED]][1]); + + if (gBattleMons[bank2].item == ITEM_ENIGMA_BERRY) + { + holdEffect = gEnigmaBerries[bank2].holdEffect; + holdEffectParam = gEnigmaBerries[bank2].holdEffectParam; + } + else + { + holdEffect = ItemId_GetHoldEffect(gBattleMons[bank2].item); + holdEffectParam = ItemId_GetHoldEffectParam(gBattleMons[bank2].item); + } + + // badge boost + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_FRONTIER)) + && FlagGet(BADGE03_GET) + && GetBankSide(bank2) == SIDE_PLAYER) + { + speedBank2 = (speedBank2 * 110) / 100; + } + + if (holdEffect == HOLD_EFFECT_MACHO_BRACE) + speedBank2 /= 2; + + if (gBattleMons[bank2].status1 & STATUS_PARALYSIS) + speedBank2 /= 4; + + if (holdEffect == HOLD_EFFECT_QUICK_CLAW && gRandomTurnNumber < (0xFFFF * holdEffectParam) / 100) + speedBank2 = UINT_MAX; + + if (ignoreChosenMoves) + { + moveBank1 = MOVE_NONE; + moveBank2 = MOVE_NONE; + } + else + { + if (gActionForBanks[bank1] == ACTION_USE_MOVE) + { + if (gProtectStructs[bank1].onlyStruggle) + moveBank1 = MOVE_STRUGGLE; + else + moveBank1 = gBattleMons[bank1].moves[*(gBattleStruct->chosenMovePositions + bank1)]; + } + else + moveBank1 = MOVE_NONE; + + if (gActionForBanks[bank2] == ACTION_USE_MOVE) + { + if (gProtectStructs[bank2].onlyStruggle) + moveBank2 = MOVE_STRUGGLE; + else + moveBank2 = gBattleMons[bank2].moves[*(gBattleStruct->chosenMovePositions + bank2)]; + } + else + moveBank2 = MOVE_NONE; + } + + // both move priorities are different than 0 + if (gBattleMoves[moveBank1].priority != 0 || gBattleMoves[moveBank2].priority != 0) + { + // both priorities are the same + if (gBattleMoves[moveBank1].priority == gBattleMoves[moveBank2].priority) + { + if (speedBank1 == speedBank2 && Random() & 1) + strikesFirst = 2; // same speeds, same priorities + else if (speedBank1 < speedBank2) + strikesFirst = 1; // bank2 has more speed + + // else bank1 has more speed + } + else if (gBattleMoves[moveBank1].priority < gBattleMoves[moveBank2].priority) + strikesFirst = 1; // bank2's move has greater priority + + // else bank1's move has greater priority + } + // both priorities are equal to 0 + else + { + if (speedBank1 == speedBank2 && Random() & 1) + strikesFirst = 2; // same speeds, same priorities + else if (speedBank1 < speedBank2) + strikesFirst = 1; // bank2 has more speed + + // else bank1 has more speed + } + + return strikesFirst; +} + +static void SetActionsAndBanksTurnOrder(void) +{ + s32 var = 0; + s32 i, j; + + if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) + { + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + gActionsByTurnOrder[var] = gActionForBanks[gActiveBank]; + gBanksByTurnOrder[var] = gActiveBank; + var++; + } + } + else + { + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (gActionForBanks[gActiveBank] == ACTION_RUN) + { + var = 5; + break; + } + } + } + else + { + if (gActionForBanks[0] == ACTION_RUN) + { + gActiveBank = 0; + var = 5; + } + if (gActionForBanks[2] == ACTION_RUN) + { + gActiveBank = 2; + var = 5; + } + } + + if (var == 5) + { + gActionsByTurnOrder[0] = gActionForBanks[gActiveBank]; + gBanksByTurnOrder[0] = gActiveBank; + var = 1; + for (i = 0; i < gNoOfAllBanks; i++) + { + if (i != gActiveBank) + { + gActionsByTurnOrder[var] = gActionForBanks[i]; + gBanksByTurnOrder[var] = i; + var++; + } + } + gBattleMainFunc = CheckFocusPunch_ClearVarsBeforeTurnStarts; + gBattleStruct->focusPunchBank = 0; + return; + } + else + { + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (gActionForBanks[gActiveBank] == ACTION_USE_ITEM || gActionForBanks[gActiveBank] == ACTION_SWITCH) + { + gActionsByTurnOrder[var] = gActionForBanks[gActiveBank]; + gBanksByTurnOrder[var] = gActiveBank; + var++; + } + } + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (gActionForBanks[gActiveBank] != ACTION_USE_ITEM && gActionForBanks[gActiveBank] != ACTION_SWITCH) + { + gActionsByTurnOrder[var] = gActionForBanks[gActiveBank]; + gBanksByTurnOrder[var] = gActiveBank; + var++; + } + } + for (i = 0; i < gNoOfAllBanks - 1; i++) + { + for (j = i + 1; j < gNoOfAllBanks; j++) + { + u8 bank1 = gBanksByTurnOrder[i]; + u8 bank2 = gBanksByTurnOrder[j]; + if (gActionsByTurnOrder[i] != ACTION_USE_ITEM + && gActionsByTurnOrder[j] != ACTION_USE_ITEM + && gActionsByTurnOrder[i] != ACTION_SWITCH + && gActionsByTurnOrder[j] != ACTION_SWITCH) + { + if (GetWhoStrikesFirst(bank1, bank2, FALSE)) + SwapTurnOrder(i, j); + } + } + } + } + } + gBattleMainFunc = CheckFocusPunch_ClearVarsBeforeTurnStarts; + gBattleStruct->focusPunchBank = 0; +} + +static void TurnValuesCleanUp(bool8 var0) +{ + s32 i; + u8 *dataPtr; + + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (var0) + { + gProtectStructs[gActiveBank].protected = 0; + gProtectStructs[gActiveBank].endured = 0; + } + else + { + dataPtr = (u8*)(&gProtectStructs[gActiveBank]); + for (i = 0; i < sizeof(struct ProtectStruct); i++) + dataPtr[i] = 0; + + if (gDisableStructs[gActiveBank].isFirstTurn) + gDisableStructs[gActiveBank].isFirstTurn--; + + if (gDisableStructs[gActiveBank].rechargeCounter) + { + gDisableStructs[gActiveBank].rechargeCounter--; + if (gDisableStructs[gActiveBank].rechargeCounter == 0) + gBattleMons[gActiveBank].status2 &= ~(STATUS2_RECHARGE); + } + } + + if (gDisableStructs[gActiveBank].substituteHP == 0) + gBattleMons[gActiveBank].status2 &= ~(STATUS2_SUBSTITUTE); + } + + gSideTimers[0].followmeTimer = 0; + gSideTimers[1].followmeTimer = 0; +} + +static void SpecialStatusesClear(void) +{ + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + s32 i; + u8 *dataPtr = (u8*)(&gSpecialStatuses[gActiveBank]); + + for (i = 0; i < sizeof(struct SpecialStatus); i++) + dataPtr[i] = 0; + } +} + +static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void) +{ + if (!(gHitMarker & HITMARKER_RUN)) + { + while (gBattleStruct->focusPunchBank < gNoOfAllBanks) + { + gActiveBank = gBankAttacker = gBattleStruct->focusPunchBank; + gBattleStruct->focusPunchBank++; + if (gChosenMovesByBanks[gActiveBank] == MOVE_FOCUS_PUNCH + && !(gBattleMons[gActiveBank].status1 & STATUS_SLEEP) + && !(gDisableStructs[gBankAttacker].truantCounter) + && !(gProtectStructs[gActiveBank].onlyStruggle)) + { + BattleScriptExecute(BattleScript_FocusPunchSetUp); + return; + } + } + } + + TryClearRageStatuses(); + gCurrentTurnActionNumber = 0; +{ + // something stupid needed to match + u8 zero; + gCurrentActionFuncId = gActionsByTurnOrder[(zero = 0)]; +} + gDynamicBasePower = 0; + gBattleStruct->dynamicMoveType = 0; + gBattleMainFunc = RunTurnActionsFunctions; + gBattleCommunication[3] = 0; + gBattleCommunication[4] = 0; + gBattleScripting.field_16 = 0; + gBattleResources->battleScriptsStack->size = 0; +} + +static void RunTurnActionsFunctions(void) +{ + if (gBattleOutcome != 0) + gCurrentActionFuncId = 12; + + *(&gBattleStruct->field_4B) = gCurrentTurnActionNumber; + sTurnActionsFuncsTable[gCurrentActionFuncId](); + + if (gCurrentTurnActionNumber >= gNoOfAllBanks) // everyone did their actions, turn finished + { + gHitMarker &= ~(HITMARKER_x100000); + gBattleMainFunc = sEndTurnFuncsTable[gBattleOutcome & 0x7F]; + } + else + { + if (gBattleStruct->field_4B != gCurrentTurnActionNumber) // action turn has been done, clear hitmarker bits for another bank + { + gHitMarker &= ~(HITMARKER_NO_ATTACKSTRING); + gHitMarker &= ~(HITMARKER_UNABLE_TO_USE_MOVE); + } + } +} + +static void HandleEndTurn_BattleWon(void) +{ + gCurrentActionFuncId = 0; + + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + { + gScriptResult = gBattleOutcome; + gBattleTextBuff1[0] = gBattleOutcome; + gBankAttacker = GetBankByIdentity(IDENTITY_PLAYER_MON1); + gBattlescriptCurrInstr = BattleScript_LinkBattleWonOrLost; + gBattleOutcome &= ~(BATTLE_OUTCOME_BIT_x80); + } + else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER + && gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_x4000000 | BATTLE_TYPE_EREADER_TRAINER)) + { + BattleMusicStop(); + gBattlescriptCurrInstr = BattleScript_FrontierTrainerBattleWon; + + if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_3FE) + PlayBGM(BGM_KACHI3); + else + PlayBGM(BGM_KACHI1); + } + else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && !(gBattleTypeFlags & BATTLE_TYPE_LINK)) + { + BattleMusicStop(); + gBattlescriptCurrInstr = BattleScript_LocalTrainerBattleWon; + + switch (gTrainers[gTrainerBattleOpponent_A].trainerClass) + { + case CLASS_ELITE_FOUR: + case CLASS_CHAMPION: + PlayBGM(BGM_KACHI5); + break; + case CLASS_TEAM_AQUA: + case CLASS_TEAM_MAGMA: + case CLASS_AQUA_ADMIN: + case CLASS_AQUA_LEADER: + case CLASS_MAGMA_ADMIN: + case CLASS_MAGMA_LEADER: + PlayBGM(BGM_KACHI4); + break; + case CLASS_LEADER: + PlayBGM(BGM_KACHI3); + break; + default: + PlayBGM(BGM_KACHI1); + break; + } + } + else + { + gBattlescriptCurrInstr = BattleScript_PayDayMoneyAndPickUpItems; + } + + gBattleMainFunc = HandleEndTurn_FinishBattle; +} + +static void HandleEndTurn_BattleLost(void) +{ + gCurrentActionFuncId = 0; + + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + { + if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) + { + if (gBattleOutcome & BATTLE_OUTCOME_BIT_x80) + { + gBattlescriptCurrInstr = gUnknown_082DB9C8; + gBattleOutcome &= ~(BATTLE_OUTCOME_BIT_x80); + gSaveBlock2Ptr->field_CA9_b = 1; + } + else + { + gBattlescriptCurrInstr = gUnknown_082DAA0B; + gBattleOutcome &= ~(BATTLE_OUTCOME_BIT_x80); + } + } + else + { + gBattleTextBuff1[0] = gBattleOutcome; + gBankAttacker = GetBankByIdentity(IDENTITY_PLAYER_MON1); + gBattlescriptCurrInstr = BattleScript_LinkBattleWonOrLost; + gBattleOutcome &= ~(BATTLE_OUTCOME_BIT_x80); + } + } + else + { + gBattlescriptCurrInstr = BattleScript_LocalBattleLost; + } + + gBattleMainFunc = HandleEndTurn_FinishBattle; +} + +static void HandleEndTurn_RanFromBattle(void) +{ + gCurrentActionFuncId = 0; + + if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER && gBattleTypeFlags & BATTLE_TYPE_TRAINER) + { + gBattlescriptCurrInstr = gUnknown_082DB9C1; + gBattleOutcome = BATTLE_FORFEITED; + gSaveBlock2Ptr->field_CA9_b = 1; + } + else if (gBattleTypeFlags & BATTLE_TYPE_x4000000) + { + gBattlescriptCurrInstr = gUnknown_082DB9C1; + gBattleOutcome = BATTLE_FORFEITED; + } + else + { + switch (gProtectStructs[gBankAttacker].fleeFlag) + { + default: + gBattlescriptCurrInstr = BattleScript_GotAwaySafely; + break; + case 1: + gBattlescriptCurrInstr = BattleScript_SmokeBallEscape; + break; + case 2: + gBattlescriptCurrInstr = BattleScript_RanAwayUsingMonAbility; + break; + } + } + + gBattleMainFunc = HandleEndTurn_FinishBattle; +} + +static void HandleEndTurn_MonFled(void) +{ + gCurrentActionFuncId = 0; + + PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBankAttacker, gBattlePartyID[gBankAttacker]); + gBattlescriptCurrInstr = BattleScript_WildMonFled; + + gBattleMainFunc = HandleEndTurn_FinishBattle; +} + +static void HandleEndTurn_FinishBattle(void) +{ + if (gCurrentActionFuncId == 0xB || gCurrentActionFuncId == 0xC) + { + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK + | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_FIRST_BATTLE + | BATTLE_TYPE_SAFARI + | BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_WALLY_TUTORIAL + | BATTLE_TYPE_FRONTIER))) + { + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (GetBankSide(gActiveBank) == SIDE_PLAYER) + { + if (gBattleResults.playerMon1Species == SPECIES_NONE) + { + gBattleResults.playerMon1Species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES, NULL); + GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_NICKNAME, gBattleResults.playerMon1Name); + } + else + { + gBattleResults.playerMon2Species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES, NULL); + GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_NICKNAME, gBattleResults.playerMon2Name); + } + } + } + sub_80EC728(); + } + + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK + | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_TRAINER + | BATTLE_TYPE_FIRST_BATTLE + | BATTLE_TYPE_SAFARI + | BATTLE_TYPE_FRONTIER + | BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_WALLY_TUTORIAL)) + && gBattleResults.unk5_6) + { + sub_80EE184(); + } + + sub_8186444(); + BeginFastPaletteFade(3); + FadeOutMapMusic(5); + gBattleMainFunc = FreeResetData_ReturnToOvOrDoEvolutions; + gUnknown_030061E8 = BattleMainCB2; + } + else + { + if (gBattleExecBuffer == 0) + gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]](); + } +} + +static void FreeResetData_ReturnToOvOrDoEvolutions(void) +{ + if (!gPaletteFade.active) + { + ResetSpriteData(); + if (gLeveledUpInBattle == 0 || gBattleOutcome != BATTLE_WON) + { + gBattleMainFunc = ReturnFromBattleToOverworld; + return; + } + else + { + gBattleMainFunc = TryEvolvePokemon; + } + } + + FreeAllWindowBuffers(); + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) + { + FreeMonSpritesGfx(); + FreeBattleResources(); + FreeBattleSpritesData(); + } +} + +static void TryEvolvePokemon(void) +{ + s32 i; + + while (gLeveledUpInBattle != 0) + { + for (i = 0; i < 6; i++) + { + if (gLeveledUpInBattle & gBitTable[i]) + { + u16 species; + u8 levelUpBits = gLeveledUpInBattle; + + levelUpBits &= ~(gBitTable[i]); + gLeveledUpInBattle = levelUpBits; + + species = GetEvolutionTargetSpecies(&gPlayerParty[i], 0, levelUpBits); + if (species != SPECIES_NONE) + { + FreeAllWindowBuffers(); + gBattleMainFunc = WaitForEvoSceneToFinish; + EvolutionScene(&gPlayerParty[i], species, TRUE, i); + return; + } + } + } + } + + gBattleMainFunc = ReturnFromBattleToOverworld; +} + +static void WaitForEvoSceneToFinish(void) +{ + if (gMain.callback2 == BattleMainCB2) + gBattleMainFunc = TryEvolvePokemon; +} + +static void ReturnFromBattleToOverworld(void) +{ + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) + { + RandomlyGivePartyPokerus(gPlayerParty); + PartySpreadPokerus(gPlayerParty); + } + + if (gBattleTypeFlags & BATTLE_TYPE_LINK && gReceivedRemoteLinkPlayers != 0) + return; + + gScriptResult = gBattleOutcome; + gMain.inBattle = 0; + gMain.callback1 = gPreBattleCallback1; + + if (gBattleTypeFlags & BATTLE_TYPE_ROAMER) + { + UpdateRoamerHPStatus(&gEnemyParty[0]); + if ((gBattleOutcome & BATTLE_WON) || gBattleOutcome == BATTLE_CAUGHT) + SetRoamerInactive(); + } + + m4aSongNumStop(0x5A); + SetMainCallback2(gMain.savedCallback); +} + +void RunBattleScriptCommands_PopCallbacksStack(void) +{ + if (gCurrentActionFuncId == 0xB || gCurrentActionFuncId == 0xC) + { + if (BATTLE_CALLBACKS_STACK->size != 0) + BATTLE_CALLBACKS_STACK->size--; + gBattleMainFunc = BATTLE_CALLBACKS_STACK->function[BATTLE_CALLBACKS_STACK->size]; + } + else + { + if (gBattleExecBuffer == 0) + gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]](); + } +} + +void RunBattleScriptCommands(void) +{ + if (gBattleExecBuffer == 0) + gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]](); +} + +static void HandleAction_UseMove(void) +{ + u8 side; + u8 var = 4; + + gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + + if (*(&gBattleStruct->field_91) & gBitTable[gBankAttacker]) + { + gCurrentActionFuncId = ACTION_FINISHED; + return; + } + + gCritMultiplier = 1; + gBattleScripting.dmgMultiplier = 1; + gBattleStruct->atkCancellerTracker = 0; + gBattleMoveFlags = 0; + gMultiHitCounter = 0; + gBattleCommunication[6] = 0; + gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovePositions + gBankAttacker); + + // choose move + if (gProtectStructs[gBankAttacker].onlyStruggle) + { + gProtectStructs[gBankAttacker].onlyStruggle = 0; + gCurrentMove = gLastUsedMove = MOVE_STRUGGLE; + gHitMarker |= HITMARKER_NO_PPDEDUCT; + *(gBattleStruct->moveTarget + gBankAttacker) = GetMoveTarget(MOVE_STRUGGLE, 0); + } + else if (gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS || gBattleMons[gBankAttacker].status2 & STATUS2_RECHARGE) + { + gCurrentMove = gLastUsedMove = gLockedMoves[gBankAttacker]; + } + // encore forces you to use the same move + else if (gDisableStructs[gBankAttacker].encoredMove != MOVE_NONE + && gDisableStructs[gBankAttacker].encoredMove == gBattleMons[gBankAttacker].moves[gDisableStructs[gBankAttacker].encoredMovePos]) + { + gCurrentMove = gLastUsedMove = gDisableStructs[gBankAttacker].encoredMove; + gCurrMovePos = gUnknown_020241E9 = gDisableStructs[gBankAttacker].encoredMovePos; + *(gBattleStruct->moveTarget + gBankAttacker) = GetMoveTarget(gCurrentMove, 0); + } + // check if the encored move wasn't overwritten + else if (gDisableStructs[gBankAttacker].encoredMove != MOVE_NONE + && gDisableStructs[gBankAttacker].encoredMove != gBattleMons[gBankAttacker].moves[gDisableStructs[gBankAttacker].encoredMovePos]) + { + gCurrMovePos = gUnknown_020241E9 = gDisableStructs[gBankAttacker].encoredMovePos; + gCurrentMove = gLastUsedMove = gBattleMons[gBankAttacker].moves[gCurrMovePos]; + gDisableStructs[gBankAttacker].encoredMove = MOVE_NONE; + gDisableStructs[gBankAttacker].encoredMovePos = 0; + gDisableStructs[gBankAttacker].encoreTimer1 = 0; + *(gBattleStruct->moveTarget + gBankAttacker) = GetMoveTarget(gCurrentMove, 0); + } + else if (gBattleMons[gBankAttacker].moves[gCurrMovePos] != gChosenMovesByBanks[gBankAttacker]) + { + gCurrentMove = gLastUsedMove = gBattleMons[gBankAttacker].moves[gCurrMovePos]; + *(gBattleStruct->moveTarget + gBankAttacker) = GetMoveTarget(gCurrentMove, 0); + } + else + { + gCurrentMove = gLastUsedMove = gBattleMons[gBankAttacker].moves[gCurrMovePos]; + } + + if (gBattleMons[gBankAttacker].hp != 0) + { + if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + gBattleResults.lastUsedMovePlayer = gCurrentMove; + else + gBattleResults.lastUsedMoveOpponent = gCurrentMove; + } + + // choose target + side = GetBankSide(gBankAttacker) ^ BIT_SIDE; + if (gSideTimers[side].followmeTimer != 0 + && gBattleMoves[gCurrentMove].target == MOVE_TARGET_SELECTED + && GetBankSide(gBankAttacker) != GetBankSide(gSideTimers[side].followmeTarget) + && gBattleMons[gSideTimers[side].followmeTarget].hp != 0) + { + gBankTarget = gSideTimers[side].followmeTarget; + } + else if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + && gSideTimers[side].followmeTimer == 0 + && (gBattleMoves[gCurrentMove].power != 0 + || gBattleMoves[gCurrentMove].target != MOVE_TARGET_x10) + && gBattleMons[*(gBattleStruct->moveTarget + gBankAttacker)].ability != ABILITY_LIGHTNING_ROD + && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) + { + side = GetBankSide(gBankAttacker); + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (side != GetBankSide(gActiveBank) + && *(gBattleStruct->moveTarget + gBankAttacker) != gActiveBank + && gBattleMons[gActiveBank].ability == ABILITY_LIGHTNING_ROD + && BankGetTurnOrder(gActiveBank) < var) + { + var = BankGetTurnOrder(gActiveBank); + } + } + if (var == 4) + { + if (gBattleMoves[gLastUsedMove].target & MOVE_TARGET_RANDOM) + { + if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + { + if (Random() & 1) + gBankTarget = GetBankByIdentity(IDENTITY_OPPONENT_MON1); + else + gBankTarget = GetBankByIdentity(IDENTITY_OPPONENT_MON2); + } + else + { + if (Random() & 1) + gBankTarget = GetBankByIdentity(IDENTITY_PLAYER_MON1); + else + gBankTarget = GetBankByIdentity(IDENTITY_PLAYER_MON2); + } + } + else + { + gBankTarget = *(gBattleStruct->moveTarget + gBankAttacker); + } + + if (gAbsentBankFlags & gBitTable[gBankTarget]) + { + if (GetBankSide(gBankAttacker) != GetBankSide(gBankTarget)) + { + gBankTarget = GetBankByIdentity(GetBankIdentity(gBankTarget) ^ BIT_MON); + } + else + { + gBankTarget = GetBankByIdentity(GetBankIdentity(gBankAttacker) ^ BIT_SIDE); + if (gAbsentBankFlags & gBitTable[gBankTarget]) + gBankTarget = GetBankByIdentity(GetBankIdentity(gBankTarget) ^ BIT_MON); + } + } + } + else + { + gActiveBank = gBanksByTurnOrder[var]; + RecordAbilityBattle(gActiveBank, gBattleMons[gActiveBank].ability); + gSpecialStatuses[gActiveBank].lightningRodRedirected = 1; + gBankTarget = gActiveBank; + } + } + else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE + && gBattleMoves[gLastUsedMove].target & MOVE_TARGET_RANDOM) + { + if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + { + if (Random() & 1) + gBankTarget = GetBankByIdentity(IDENTITY_OPPONENT_MON1); + else + gBankTarget = GetBankByIdentity(IDENTITY_OPPONENT_MON2); + } + else + { + if (Random() & 1) + gBankTarget = GetBankByIdentity(IDENTITY_PLAYER_MON1); + else + gBankTarget = GetBankByIdentity(IDENTITY_PLAYER_MON2); + } + + if (gAbsentBankFlags & gBitTable[gBankTarget] + && GetBankSide(gBankAttacker) != GetBankSide(gBankTarget)) + { + gBankTarget = GetBankByIdentity(GetBankIdentity(gBankTarget) ^ BIT_MON); + } + } + else + { + gBankTarget = *(gBattleStruct->moveTarget + gBankAttacker); + if (gAbsentBankFlags & gBitTable[gBankTarget]) + { + if (GetBankSide(gBankAttacker) != GetBankSide(gBankTarget)) + { + gBankTarget = GetBankByIdentity(GetBankIdentity(gBankTarget) ^ BIT_MON); + } + else + { + gBankTarget = GetBankByIdentity(GetBankIdentity(gBankAttacker) ^ BIT_SIDE); + if (gAbsentBankFlags & gBitTable[gBankTarget]) + gBankTarget = GetBankByIdentity(GetBankIdentity(gBankTarget) ^ BIT_MON); + } + } + } + + // choose battlescript + if (gBattleTypeFlags & BATTLE_TYPE_PALACE + && gProtectStructs[gBankAttacker].flag_x10) + { + if (gBattleMons[gBankAttacker].hp == 0) + { + gCurrentActionFuncId = 12; + return; + } + else if (gUnknown_02024230[gBankAttacker] != NULL) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 4; + gBattlescriptCurrInstr = gUnknown_02024230[gBankAttacker]; + gUnknown_02024230[gBankAttacker] = NULL; + } + else + { + gBattleCommunication[MULTISTRING_CHOOSER] = 4; + gBattlescriptCurrInstr = BattleScript_MoveUsedLoafingAround; + } + } + else + { + gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; + } + + if (gBattleTypeFlags & BATTLE_TYPE_ARENA) + sub_81A56E8(gBankAttacker); + + gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; +} + +static void HandleAction_Switch(void) +{ + gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattle_BG0_X = 0; + gBattle_BG0_Y = 0; + gActionSelectionCursor[gBankAttacker] = 0; + gMoveSelectionCursor[gBankAttacker] = 0; + + PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBankAttacker, *(gBattleStruct->field_58 + gBankAttacker)) + + gBattleScripting.bank = gBankAttacker; + gBattlescriptCurrInstr = BattleScript_ActionSwitch; + gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; + + if (gBattleResults.playerSwitchesCounter < 255) + gBattleResults.playerSwitchesCounter++; +} + +static void HandleAction_UseItem(void) +{ + gBankAttacker = gBankTarget = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattle_BG0_X = 0; + gBattle_BG0_Y = 0; + ClearFuryCutterDestinyBondGrudge(gBankAttacker); + gLastUsedItem = gBattleBufferB[gBankAttacker][1] | (gBattleBufferB[gBankAttacker][2] << 8); + + if (gLastUsedItem <= ITEM_PREMIER_BALL) // is ball + { + gBattlescriptCurrInstr = gBattlescriptsForBallThrow[gLastUsedItem]; + } + else if (gLastUsedItem == ITEM_POKE_DOLL || gLastUsedItem == ITEM_FLUFFY_TAIL) + { + gBattlescriptCurrInstr = gBattlescriptsForRunningByItem[0]; + } + else if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + { + gBattlescriptCurrInstr = gUnknown_082DBD3C[0]; + } + else + { + gBattleScripting.bank = gBankAttacker; + + switch (*(gBattleStruct->field_C4 + (gBankAttacker >> 1))) + { + case 1: + case 2: + break; + case 3: + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + if (*(gBattleStruct->field_C6 + gBankAttacker / 2) & 1) + { + if (*(gBattleStruct->field_C6 + gBankAttacker / 2) & 0x3E) + gBattleCommunication[MULTISTRING_CHOOSER] = 5; + } + else + { + while (!(*(gBattleStruct->field_C6 + gBankAttacker / 2) & 1)) + { + *(gBattleStruct->field_C6 + gBankAttacker / 2) >>= 1; + gBattleCommunication[MULTISTRING_CHOOSER]++; + } + } + break; + case 4: + gBattleCommunication[MULTISTRING_CHOOSER] = 4; + if (*(gBattleStruct->field_C6 + (gBankAttacker >> 1)) & 0x80) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 5; + } + else + { + PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_ATK) + PREPARE_STRING_BUFFER(gBattleTextBuff2, 0xD2) + + while (!((*(gBattleStruct->field_C6 + (gBankAttacker >> 1))) & 1)) + { + *(gBattleStruct->field_C6 + gBankAttacker / 2) >>= 1; + gBattleTextBuff1[2]++; + } + + gBattleScripting.animArg1 = gBattleTextBuff1[2] + 14; + gBattleScripting.animArg2 = 0; + } + break; + case 5: + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + else + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + break; + } + + gBattlescriptCurrInstr = gUnknown_082DBD3C[*(gBattleStruct->field_C4 + gBankAttacker / 2)]; + } + gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; +} + +bool8 TryRunFromBattle(u8 bank) +{ + bool8 effect = FALSE; + u8 holdEffect; + u8 pyramidMultiplier; + u8 speedVar; + + if (gBattleMons[bank].item == ITEM_ENIGMA_BERRY) + holdEffect = gEnigmaBerries[bank].holdEffect; + else + holdEffect = ItemId_GetHoldEffect(gBattleMons[bank].item); + + gStringBank = bank; + + if (holdEffect == HOLD_EFFECT_CAN_ALWAYS_RUN) + { + gLastUsedItem = gBattleMons[bank].item ; + gProtectStructs[bank].fleeFlag = 1; + effect++; + } + else if (gBattleMons[bank].ability == ABILITY_RUN_AWAY) + { + if (InBattlePyramid()) + { + gBattleStruct->runTries++; + pyramidMultiplier = sub_81A9E28(); + speedVar = (gBattleMons[bank].speed * pyramidMultiplier) / (gBattleMons[bank ^ BIT_SIDE].speed) + (gBattleStruct->runTries * 30); + if (speedVar > (Random() & 0xFF)) + { + gLastUsedAbility = ABILITY_RUN_AWAY; + gProtectStructs[bank].fleeFlag = 2; + effect++; + } + } + else + { + gLastUsedAbility = ABILITY_RUN_AWAY; + gProtectStructs[bank].fleeFlag = 2; + effect++; + } + } + else if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_x4000000) && gBattleTypeFlags & BATTLE_TYPE_TRAINER) + { + effect++; + } + else + { + if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) + { + if (InBattlePyramid()) + { + pyramidMultiplier = sub_81A9E28(); + speedVar = (gBattleMons[bank].speed * pyramidMultiplier) / (gBattleMons[bank ^ BIT_SIDE].speed) + (gBattleStruct->runTries * 30); + if (speedVar > (Random() & 0xFF)) + effect++; + } + else if (gBattleMons[bank].speed < gBattleMons[bank ^ BIT_SIDE].speed) + { + speedVar = (gBattleMons[bank].speed * 128) / (gBattleMons[bank ^ BIT_SIDE].speed) + (gBattleStruct->runTries * 30); + if (speedVar > (Random() & 0xFF)) + effect++; + } + else // same speed or faster + { + effect++; + } + } + + gBattleStruct->runTries++; + } + + if (effect) + { + gCurrentTurnActionNumber = gNoOfAllBanks; + gBattleOutcome = BATTLE_RAN; + } + + return effect; +} + +static void HandleAction_Run(void) +{ + gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + { + gCurrentTurnActionNumber = gNoOfAllBanks; + + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (GetBankSide(gActiveBank) == SIDE_PLAYER) + { + if (gActionForBanks[gActiveBank] == ACTION_RUN) + gBattleOutcome |= BATTLE_LOST; + } + else + { + if (gActionForBanks[gActiveBank] == ACTION_RUN) + gBattleOutcome |= BATTLE_WON; + } + } + + gBattleOutcome |= BATTLE_OUTCOME_BIT_x80; + gSaveBlock2Ptr->field_CA9_b = 1; + } + else + { + if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + { + if (!TryRunFromBattle(gBankAttacker)) // failed to run away + { + ClearFuryCutterDestinyBondGrudge(gBankAttacker); + gBattleCommunication[MULTISTRING_CHOOSER] = 3; + gBattlescriptCurrInstr = BattleScript_PrintFailedToRunString; + gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; + } + } + else + { + if (gBattleMons[gBankAttacker].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 4; + gBattlescriptCurrInstr = BattleScript_PrintFailedToRunString; + gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; + } + else + { + gCurrentTurnActionNumber = gNoOfAllBanks; + gBattleOutcome = BATTLE_POKE_FLED; + } + } + } +} + +static void HandleAction_WatchesCarefully(void) +{ + gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattle_BG0_X = 0; + gBattle_BG0_Y = 0; + gBattlescriptCurrInstr = gBattlescriptsForSafariActions[0]; + gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; +} + +static void HandleAction_SafariZoneBallThrow(void) +{ + gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattle_BG0_X = 0; + gBattle_BG0_Y = 0; + gNumSafariBalls--; + gLastUsedItem = ITEM_SAFARI_BALL; + gBattlescriptCurrInstr = gBattlescriptsForBallThrow[ITEM_SAFARI_BALL]; + gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; +} + +static void HandleAction_ThrowPokeblock(void) +{ + gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattle_BG0_X = 0; + gBattle_BG0_Y = 0; + gBattleCommunication[MULTISTRING_CHOOSER] = gBattleBufferB[gBankAttacker][1] - 1; + gLastUsedItem = gBattleBufferB[gBankAttacker][2]; + + if (gBattleResults.field_1F < 0xFF) + gBattleResults.field_1F++; + if (gBattleStruct->field_7A < 3) + gBattleStruct->field_7A++; + if (gBattleStruct->field_7B > 1) + { + if (gBattleStruct->field_7B < sUnknown_0831BCE0[gBattleStruct->field_7A][gBattleCommunication[MULTISTRING_CHOOSER]]) + gBattleStruct->field_7B = 1; + else + gBattleStruct->field_7B -= sUnknown_0831BCE0[gBattleStruct->field_7A][gBattleCommunication[MULTISTRING_CHOOSER]]; + } + + gBattlescriptCurrInstr = gBattlescriptsForSafariActions[2]; + gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; +} + +static void HandleAction_GoNear(void) +{ + gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattle_BG0_X = 0; + gBattle_BG0_Y = 0; + + gBattleStruct->field_7C += sUnknown_0831BCEF[gBattleStruct->field_79]; + if (gBattleStruct->field_7C > 20) + gBattleStruct->field_7C = 20; + + gBattleStruct->field_7B +=sUnknown_0831BCF3[gBattleStruct->field_79]; + if (gBattleStruct->field_7B > 20) + gBattleStruct->field_7B = 20; + + if (gBattleStruct->field_79 < 3) + { + gBattleStruct->field_79++; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + else + { + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + } + gBattlescriptCurrInstr = gBattlescriptsForSafariActions[1]; + gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; +} + +static void HandleAction_SafriZoneRun(void) +{ + gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + PlaySE(SE_NIGERU); + gCurrentTurnActionNumber = gNoOfAllBanks; + gBattleOutcome = BATTLE_RAN; +} + +static void HandleAction_Action9(void) +{ + gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattle_BG0_X = 0; + gBattle_BG0_Y = 0; + + PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBankAttacker, gBattlePartyID[gBankAttacker]) + + gBattlescriptCurrInstr = gBattlescriptsForSafariActions[3]; + gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; + gActionsByTurnOrder[1] = ACTION_FINISHED; +} + +static void HandleAction_Action11(void) +{ + if (!sub_8041728()) + { + gBattleStruct->field_4D = 0; + gCurrentActionFuncId = ACTION_FINISHED; + } +} + +static void HandleAction_NothingIsFainted(void) +{ + gCurrentTurnActionNumber++; + gCurrentActionFuncId = gActionsByTurnOrder[gCurrentTurnActionNumber]; + gHitMarker &= ~(HITMARKER_DESTINYBOND | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_ATTACKSTRING_PRINTED + | HITMARKER_NO_PPDEDUCT | HITMARKER_IGNORE_SAFEGUARD | HITMARKER_IGNORE_ON_AIR + | HITMARKER_IGNORE_UNDERGROUND | HITMARKER_IGNORE_UNDERWATER | HITMARKER_x100000 + | HITMARKER_OBEYS | HITMARKER_x10 | HITMARKER_SYNCHRONISE_EFFECT + | HITMARKER_x8000000 | HITMARKER_x4000000); +} + +static void HandleAction_ActionFinished(void) +{ + *(gBattleStruct->field_5C + gBanksByTurnOrder[gCurrentTurnActionNumber]) = 6; + gCurrentTurnActionNumber++; + gCurrentActionFuncId = gActionsByTurnOrder[gCurrentTurnActionNumber]; + SpecialStatusesClear(); + gHitMarker &= ~(HITMARKER_DESTINYBOND | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_ATTACKSTRING_PRINTED + | HITMARKER_NO_PPDEDUCT | HITMARKER_IGNORE_SAFEGUARD | HITMARKER_IGNORE_ON_AIR + | HITMARKER_IGNORE_UNDERGROUND | HITMARKER_IGNORE_UNDERWATER | HITMARKER_x100000 + | HITMARKER_OBEYS | HITMARKER_x10 | HITMARKER_SYNCHRONISE_EFFECT + | HITMARKER_x8000000 | HITMARKER_x4000000); + + gCurrentMove = 0; + gBattleMoveDamage = 0; + gBattleMoveFlags = 0; + gBattleScripting.animTurn = 0; + gBattleScripting.animTargetsHit = 0; + gUnknown_02024250[gBankAttacker] = 0; + gUnknown_02024258[gBankAttacker] = 0; + gBattleStruct->dynamicMoveType = 0; + gDynamicBasePower = 0; + gBattleScripting.atk49_state = 0; + gBattleCommunication[3] = 0; + gBattleCommunication[4] = 0; + gBattleScripting.field_16 = 0; + gBattleResources->battleScriptsStack->size = 0; +} diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index dae43f13c..92126e40c 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -73,7 +73,7 @@ extern const struct BaseStats gBaseStats[]; extern const u32 gBitTable[]; extern u8 * const gBattleAI_ScriptsTable[]; -extern u8 b_first_side(u8, u8, u8); +extern u8 GetWhoStrikesFirst(u8, u8, u8); extern void AI_CalcDmg(u8, u8); extern u8 CheckMoveLimitations(); @@ -1756,7 +1756,7 @@ static void BattleAICmd_if_arg_not_equal(void) static void BattleAICmd_if_would_go_first(void) { - if (b_first_side(sBank_AI, gBankTarget, 1) == gAIScriptPtr[1]) + if (GetWhoStrikesFirst(sBank_AI, gBankTarget, 1) == gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -1764,7 +1764,7 @@ static void BattleAICmd_if_would_go_first(void) static void BattleAICmd_if_would_not_go_first(void) { - if (b_first_side(sBank_AI, gBankTarget, 1) != gAIScriptPtr[1]) + if (GetWhoStrikesFirst(sBank_AI, gBankTarget, 1) != gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); else gAIScriptPtr += 6; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e0cb3e941..e53292442 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -47,8 +47,8 @@ extern u8 gActiveBank; extern u32 gBattleExecBuffer; extern u8 gNoOfAllBanks; extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gTurnOrder[BATTLE_BANKS_COUNT]; -extern u8 gUnknown_0202407A[BATTLE_BANKS_COUNT]; +extern u8 gBanksByTurnOrder[BATTLE_BANKS_COUNT]; +extern u8 gActionsByTurnOrder[BATTLE_BANKS_COUNT]; extern u16 gCurrentMove; extern u8 gLastUsedAbility; extern u16 gBattleWeather; @@ -67,7 +67,7 @@ extern u8 gBankAttacker; extern u8 gBankTarget; extern const u8* gBattlescriptCurrInstr; extern u8 gCurrMovePos; -extern u8 gFightStateTracker; +extern u8 gCurrentActionFuncId; extern u32 gHitMarker; extern u8 gBattleMoveFlags; extern u8 gBattleCommunication[]; @@ -92,7 +92,7 @@ extern u16 gMoveToLearn; extern u16 gRandomMove; extern u8 gBankInMenu; extern u8 gActionForBanks[BATTLE_BANKS_COUNT]; -extern u8 gCurrentMoveTurn; +extern u8 gCurrentTurnActionNumber; extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; extern u16 gLockedMoves[BATTLE_BANKS_COUNT]; extern u16 gPartnerTrainerId; @@ -145,8 +145,7 @@ extern u16 GetBattlePyramidPickupItemId(void); extern u8 sav1_map_get_light_level(void); extern u8 sub_813B21C(void); extern u16 get_unknown_box_id(void); -extern void c2_berry_program_update_menu(void); -extern void sub_8035AA4(void); +extern void sub_80356D0(void); // BattleScripts extern const u8 BattleScript_MoveEnd[]; @@ -332,7 +331,7 @@ static void atk40_jump_if_move_affected_by_protect(void); static void atk41_call(void); static void atk42_jumpiftype2(void); static void atk43_jumpifabilitypresent(void); -static void atk44(void); +static void atk44_end_selection_script(void); static void atk45_playanimation(void); static void atk46_playanimation2(void); static void atk47_setgraphicalstatchangevalues(void); @@ -361,7 +360,7 @@ static void atk5D_getmoneyreward(void); static void atk5E_8025A70(void); static void atk5F_8025B24(void); static void atk60_increment_gamestat(void); -static void atk61_8025BA4(void); +static void atk61_draw_party_status_summary(void); static void atk62_08025C6C(void); static void atk63_jumptorandomattack(void); static void atk64_statusanimation(void); @@ -378,7 +377,7 @@ static void atk6E_set_atk_to_player0(void); static void atk6F_set_visible(void); static void atk70_record_last_used_ability(void); static void atk71_buffer_move_to_learn(void); -static void atk72_jump_if_can_run_frombattle(void); +static void atk72_jump_if_run_attempt_success(void); static void atk73_hp_thresholds(void); static void atk74_hp_thresholds2(void); static void atk75_item_effect_on_opponent(void); @@ -510,8 +509,8 @@ static void atkF2_display_dex_info(void); static void atkF3_nickname_caught_poke(void); static void atkF4_subattackerhpbydmg(void); static void atkF5_removeattackerstatus1(void); -static void atkF6_802BF48(void); -static void atkF7_802BF54(void); +static void atkF6_action_finished(void); +static void atkF7_turn_finished(void); static void atkF8_trainer_slide_back(void); void (* const gBattleScriptingCommandsTable[])(void) = @@ -584,7 +583,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atk41_call, atk42_jumpiftype2, atk43_jumpifabilitypresent, - atk44, + atk44_end_selection_script, atk45_playanimation, atk46_playanimation2, atk47_setgraphicalstatchangevalues, @@ -613,7 +612,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atk5E_8025A70, atk5F_8025B24, atk60_increment_gamestat, - atk61_8025BA4, + atk61_draw_party_status_summary, atk62_08025C6C, atk63_jumptorandomattack, atk64_statusanimation, @@ -630,7 +629,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atk6F_set_visible, atk70_record_last_used_ability, atk71_buffer_move_to_learn, - atk72_jump_if_can_run_frombattle, + atk72_jump_if_run_attempt_success, atk73_hp_thresholds, atk74_hp_thresholds2, atk75_item_effect_on_opponent, @@ -762,8 +761,8 @@ void (* const gBattleScriptingCommandsTable[])(void) = atkF3_nickname_caught_poke, atkF4_subattackerhpbydmg, atkF5_removeattackerstatus1, - atkF6_802BF48, - atkF7_802BF54, + atkF6_action_finished, + atkF7_turn_finished, atkF8_trainer_slide_back }; @@ -1098,9 +1097,9 @@ static void atk00_attackcanceler(void) { s32 i; - if (gBattleOutcome) + if (gBattleOutcome != 0) { - gFightStateTracker = 0xC; + gCurrentActionFuncId = ACTION_FINISHED; return; } if (gBattleMons[gBankAttacker].hp == 0 && !(gHitMarker & HITMARKER_NO_ATTACKSTRING)) @@ -1152,11 +1151,11 @@ static void atk00_attackcanceler(void) for (i = 0; i < gNoOfAllBanks; i++) { - if ((gProtectStructs[gTurnOrder[i]].stealMove) && gBattleMoves[gCurrentMove].flags & FLAG_SNATCH_AFFECTED) + if ((gProtectStructs[gBanksByTurnOrder[i]].stealMove) && gBattleMoves[gCurrentMove].flags & FLAG_SNATCH_AFFECTED) { - PressurePPLose(gBankAttacker, gTurnOrder[i], MOVE_SNATCH); - gProtectStructs[gTurnOrder[i]].stealMove = 0; - gBattleScripting.bank = gTurnOrder[i]; + PressurePPLose(gBankAttacker, gBanksByTurnOrder[i], MOVE_SNATCH); + gProtectStructs[gBanksByTurnOrder[i]].stealMove = 0; + gBattleScripting.bank = gBanksByTurnOrder[i]; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SnatchedMove; return; @@ -1601,7 +1600,7 @@ static void atk06_typecalc(void) RecordAbilityBattle(gBankTarget, gLastUsedAbility); } if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED) - gProtectStructs[gBankAttacker].notEffective = 1; + gProtectStructs[gBankAttacker].targetNotAffected = 1; gBattlescriptCurrInstr++; } @@ -1640,14 +1639,14 @@ static void CheckWonderGuardAndLevitate(void) if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type1 && gTypeEffectiveness[i + 2] == 0) { gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED; - gProtectStructs[gBankAttacker].notEffective = 1; + gProtectStructs[gBankAttacker].targetNotAffected = 1; } if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2 && gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2 && gTypeEffectiveness[i + 2] == TYPE_MUL_NO_EFFECT) { gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED; - gProtectStructs[gBankAttacker].notEffective = 1; + gProtectStructs[gBankAttacker].targetNotAffected = 1; } // check super effective @@ -2379,7 +2378,7 @@ u8 BankGetTurnOrder(u8 bank) s32 i; for (i = 0; i < gNoOfAllBanks; i++) { - if (gTurnOrder[i] == bank) + if (gBanksByTurnOrder[i] == bank) break; } return i; @@ -2737,7 +2736,7 @@ void SetMoveEffect(bool8 primary, u8 certain) } else { - if (BankGetTurnOrder(gEffectBank) > gCurrentMoveTurn) + if (BankGetTurnOrder(gEffectBank) > gCurrentTurnActionNumber) gBattleMons[gEffectBank].status2 |= sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]; gBattlescriptCurrInstr++; } @@ -3209,7 +3208,7 @@ static void atk19_faint_pokemon(void) && gBattleMons[gBankAttacker].hp != 0 && gCurrentMove != MOVE_STRUGGLE) { - u8 moveIndex = *(gBattleStruct->chosenMovesIds + gBankAttacker); + u8 moveIndex = *(gBattleStruct->chosenMovePositions + gBankAttacker); gBattleMons[gBankAttacker].pp[moveIndex] = 0; BattleScriptPush(gBattlescriptCurrInstr); @@ -3252,7 +3251,7 @@ static void atk1B_faint_effects_clear(void) MarkBufferBankForExecution(gActiveBank); } - UndoEffectsAfterFainting(); // Effects like attractions, trapping, etc. + FaintClearSetData(); // Effects like attractions, trapping, etc. gBattlescriptCurrInstr += 2; } } @@ -4422,13 +4421,13 @@ static void atk3D_end(void) gBattleMoveFlags = 0; gActiveBank = 0; - gFightStateTracker = 0xB; + gCurrentActionFuncId = 0xB; } static void atk3E_end2(void) { gActiveBank = 0; - gFightStateTracker = 0xB; + gCurrentActionFuncId = 0xB; } static void atk3F_end3(void) // pops the main function stack @@ -4463,9 +4462,9 @@ static void atk43_jumpifabilitypresent(void) gBattlescriptCurrInstr += 6; } -static void atk44(void) +static void atk44_end_selection_script(void) { - *(gBankAttacker + gBattleStruct->field_54) = 1; + *(gBankAttacker + gBattleStruct->selectionScriptFinished) = TRUE; } static void atk45_playanimation(void) @@ -5067,7 +5066,7 @@ static void atk49_moveend(void) case 9: // make attacker sprite visible if (gBattleMoveFlags & MOVESTATUS_NOEFFECT || !(gStatuses3[gBankAttacker] & (STATUS3_SEMI_INVULNERABLE)) - || HasMoveFailed(gBankAttacker)) + || WasUnableToUseMove(gBankAttacker)) { gActiveBank = gBankAttacker; EmitSpriteInvisibility(0, FALSE); @@ -5298,7 +5297,7 @@ static void atk4A_typecalc2(void) RecordAbilityBattle(gBankTarget, gLastUsedAbility); } if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED) - gProtectStructs[gBankAttacker].notEffective = 1; + gProtectStructs[gBankAttacker].targetNotAffected = 1; gBattlescriptCurrInstr++; } @@ -5367,7 +5366,7 @@ static void atk4D_switch_data_update(void) gBattleMons[gActiveBank].status2 = oldData.status2; } - SwitchInClearStructs(); + SwitchInClearSetData(); if (gBattleTypeFlags & BATTLE_TYPE_PALACE && gBattleMons[gActiveBank].maxHP / 2 >= gBattleMons[gActiveBank].hp && gBattleMons[gActiveBank].hp != 0 && !(gBattleMons[gActiveBank].status1 & STATUS_SLEEP)) @@ -5904,15 +5903,15 @@ static void atk51_switch_handle_order(void) gBattleCommunication[0] = gBattleBufferB[gActiveBank][1]; *(gBattleStruct->field_5C + gActiveBank) = gBattleBufferB[gActiveBank][1]; - if ((gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_LINK)) == (BATTLE_TYPE_MULTI | BATTLE_TYPE_LINK)) + if (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI) { *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 0) &= 0xF; *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBank][2] & 0xF0); *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 1) = gBattleBufferB[gActiveBank][3]; - *((gActiveBank ^ 2) * 3 + (u8*)(gBattleStruct->field_60) + 0) &= (0xF0); - *((gActiveBank ^ 2) * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBank][2] & 0xF0) >> 4; - *((gActiveBank ^ 2) * 3 + (u8*)(gBattleStruct->field_60) + 2) = gBattleBufferB[gActiveBank][3]; + *((gActiveBank ^ BIT_MON) * 3 + (u8*)(gBattleStruct->field_60) + 0) &= (0xF0); + *((gActiveBank ^ BIT_MON) * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBank][2] & 0xF0) >> 4; + *((gActiveBank ^ BIT_MON) * 3 + (u8*)(gBattleStruct->field_60) + 2) = gBattleBufferB[gActiveBank][3]; } else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) { @@ -5984,8 +5983,8 @@ static void atk52_switch_in_effects(void) for (i = 0; i < gNoOfAllBanks; i++) { - if (gTurnOrder[i] == gActiveBank) - gUnknown_0202407A[i] = 0xC; + if (gBanksByTurnOrder[i] == gActiveBank) + gActionsByTurnOrder[i] = ACTION_CANCEL_PARTNER; } for (i = 0; i < gNoOfAllBanks; i++) @@ -6412,7 +6411,7 @@ static void atk60_increment_gamestat(void) gBattlescriptCurrInstr += 2; } -static void atk61_8025BA4(void) +static void atk61_draw_party_status_summary(void) { s32 i; struct Pokemon* party; @@ -6443,7 +6442,7 @@ static void atk61_8025BA4(void) } } - EmitCmd48(0, hpStatuses, 1); + EmitDrawPartyStatusSummary(0, hpStatuses, 1); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr += 2; @@ -6570,7 +6569,7 @@ static void atk68_80246A0(void) s32 i; for (i = 0; i < gNoOfAllBanks; i++) - gUnknown_0202407A[i] = 0xC; + gActionsByTurnOrder[i] = ACTION_CANCEL_PARTNER; gBattlescriptCurrInstr++; } @@ -6957,9 +6956,9 @@ static void atk71_buffer_move_to_learn(void) gBattlescriptCurrInstr++; } -static void atk72_jump_if_can_run_frombattle(void) +static void atk72_jump_if_run_attempt_success(void) { - if (CanRunFromBattle(gBank1)) + if (TryRunFromBattle(gBank1)) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); else gBattlescriptCurrInstr += 5; @@ -7046,7 +7045,7 @@ static void atk76_various(void) else gBankTarget = gActiveBank; break; - case 2: + case VARIOUS_CAN_RUN_FROM_BATTLE: gBattleCommunication[0] = IsRunningFromBattleImpossible(); break; case VARIOUS_GET_MOVE_TARGET: @@ -7197,7 +7196,7 @@ static void atk76_various(void) gBattleOutcome = BATTLE_OPPONENT_TELEPORTED; break; case VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC: - EmitPlaySound(0, 0x19C, 1); + EmitPlaySound(0, BGM_KACHI1, 1); MarkBufferBankForExecution(gActiveBank); break; } @@ -7213,7 +7212,7 @@ static void atk77_set_protect_like(void) // protect and endure if (lastMove != MOVE_PROTECT && lastMove != MOVE_DETECT && lastMove != MOVE_ENDURE) gDisableStructs[gBankAttacker].protectUses = 0; - if (gCurrentMoveTurn == (gNoOfAllBanks - 1)) + if (gCurrentTurnActionNumber == (gNoOfAllBanks - 1)) notLastTurn = FALSE; if (sProtectSuccessRates[gDisableStructs[gBankAttacker].protectUses] >= Random() && notLastTurn) @@ -9519,19 +9518,19 @@ static void atkB3_rolloutdamagecalculation(void) if (!(gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS)) // first hit { - gDisableStructs[gBankAttacker].rolloutTimer1 = 5; - gDisableStructs[gBankAttacker].rolloutTimer2 = 5; + gDisableStructs[gBankAttacker].rolloutCounter1 = 5; + gDisableStructs[gBankAttacker].rolloutCounter2 = 5; gBattleMons[gBankAttacker].status2 |= STATUS2_MULTIPLETURNS; gLockedMoves[gBankAttacker] = gCurrentMove; } - if (--gDisableStructs[gBankAttacker].rolloutTimer1 == 0) // last hit + if (--gDisableStructs[gBankAttacker].rolloutCounter1 == 0) // last hit { gBattleMons[gBankAttacker].status2 &= ~(STATUS2_MULTIPLETURNS); } gDynamicBasePower = gBattleMoves[gCurrentMove].power; - for (i = 1; i < (5 - gDisableStructs[gBankAttacker].rolloutTimer1); i++) + for (i = 1; i < (5 - gDisableStructs[gBankAttacker].rolloutCounter1); i++) gDynamicBasePower *= 2; if (gBattleMons[gBankAttacker].status2 & STATUS2_DEFENSE_CURL) @@ -9711,12 +9710,12 @@ static void atkBA_jumpifnopursuitswitchdmg(void) for (i = 0; i < gNoOfAllBanks; i++) { - if (gTurnOrder[i] == gBankTarget) - gUnknown_0202407A[i] = 11; + if (gBanksByTurnOrder[i] == gBankTarget) + gActionsByTurnOrder[i] = 11; } gCurrentMove = MOVE_PURSUIT; - gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovesIds + gBankTarget); + gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovePositions + gBankTarget); gBattlescriptCurrInstr += 5; gBattleScripting.animTurn = 1; gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); @@ -10632,7 +10631,7 @@ static void atkDF_setmagiccoat(void) { gBankTarget = gBankAttacker; gSpecialStatuses[gBankAttacker].flag20 = 1; - if (gCurrentMoveTurn == gNoOfAllBanks - 1) // moves last turn + if (gCurrentTurnActionNumber == gNoOfAllBanks - 1) // moves last turn { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } @@ -10646,7 +10645,7 @@ static void atkDF_setmagiccoat(void) static void atkE0_setstealstatchange(void) // snatch { gSpecialStatuses[gBankAttacker].flag20 = 1; - if (gCurrentMoveTurn == gNoOfAllBanks - 1) // moves last turn + if (gCurrentTurnActionNumber == gNoOfAllBanks - 1) // moves last turn { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } @@ -10943,7 +10942,7 @@ static void atkEC_pursuit_sth(void) && gActionForBanks[gActiveBank] == 0 && gChosenMovesByBanks[gActiveBank] == MOVE_PURSUIT) { - gUnknown_0202407A[gActiveBank] = 11; + gActionsByTurnOrder[gActiveBank] = 11; gCurrentMove = MOVE_PURSUIT; gBattlescriptCurrInstr += 5; gBattleScripting.animTurn = 1; @@ -11217,8 +11216,8 @@ static void atkF2_display_dex_info(void) } break; case 3: - c2_berry_program_update_menu(); - sub_8035AA4(); + sub_80356D0(); + LoadBattleTextboxAndBackground(); gBattle_BG3_X = 0x100; gBattleCommunication[0]++; break; @@ -11394,15 +11393,15 @@ static void atkF5_removeattackerstatus1(void) gBattlescriptCurrInstr++; } -static void atkF6_802BF48(void) +static void atkF6_action_finished(void) { - gFightStateTracker = 0xC; + gCurrentActionFuncId = ACTION_FINISHED; } -static void atkF7_802BF54(void) +static void atkF7_turn_finished(void) { - gFightStateTracker = 0xC; - gCurrentMoveTurn = gNoOfAllBanks; + gCurrentActionFuncId = ACTION_FINISHED; + gCurrentTurnActionNumber = gNoOfAllBanks; } static void atkF8_trainer_slide_back(void) diff --git a/src/battle_3.c b/src/battle_util.c similarity index 95% rename from src/battle_3.c rename to src/battle_util.c index e42d9317d..c6762dd99 100644 --- a/src/battle_3.c +++ b/src/battle_util.c @@ -17,9 +17,10 @@ #include "battle_controllers.h" #include "event_data.h" #include "calculate_base_damage.h" +#include "link.h" extern const u8* gBattlescriptCurrInstr; -extern const u8* gUnknown_02024220[BATTLE_BANKS_COUNT]; +extern const u8* gBattlescriptPtrsForSelection[BATTLE_BANKS_COUNT]; extern const u8* gUnknown_02024230[BATTLE_BANKS_COUNT]; extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; extern u8 gActiveBank; @@ -32,8 +33,8 @@ extern u8 gBankAttacker; extern u8 gBankTarget; extern u8 gAbsentBankFlags; extern u16 gBattleWeather; -extern u8 gTurnOrder[BATTLE_BANKS_COUNT]; -extern u16 gSideAffecting[]; +extern u8 gBanksByTurnOrder[BATTLE_BANKS_COUNT]; +extern u16 gSideAffecting[2]; extern u8 gBattleCommunication[]; extern void (*gBattleMainFunc)(void); extern s32 gBattleMoveDamage; @@ -45,16 +46,17 @@ extern u32 gHitMarker; extern u8 gEffectBank; extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; extern u8 gBank1; -extern u16 gChosenMovesByBanks[]; +extern u16 gChosenMovesByBanks[BATTLE_BANKS_COUNT]; extern u8 gBattleMoveFlags; extern s32 gTakenDmg[BATTLE_BANKS_COUNT]; extern u8 gTakenDmgBanks[BATTLE_BANKS_COUNT]; extern u8 gLastUsedAbility; -extern u8 gFightStateTracker; +extern u8 gCurrentActionFuncId; extern u32 gBattleExecBuffer; extern u16 gRandomMove; extern u8 gCurrMovePos; extern u8 gUnknown_020241E9; +extern u8 gSentPokesToOpponent[2]; extern const struct BattleMove gBattleMoves[]; @@ -169,24 +171,278 @@ extern const u8 gUnknown_082DB6A5[]; //disobedient, uses a random move extern const u8 gUnknown_082DB6D9[]; //disobedient, went to sleep extern const u8 gUnknown_082DB6F0[]; //disobedient, hits itself -extern const u8 gStatusConditionString_PoisonJpn[]; -extern const u8 gStatusConditionString_SleepJpn[]; -extern const u8 gStatusConditionString_ParalysisJpn[]; -extern const u8 gStatusConditionString_BurnJpn[]; -extern const u8 gStatusConditionString_IceJpn[]; -extern const u8 gStatusConditionString_ConfusionJpn[]; -extern const u8 gStatusConditionString_LoveJpn[]; -extern const u16 gSoundMovesTable[]; - -extern u8 b_first_side(u8, u8, u8); -extern void sub_803CEDC(u8, u8); -extern void BattleTurnPassed(void); -extern void sub_803F9EC(); -extern bool8 sub_80423F4(u8 bank, u8, u8); extern u8 weather_get_current(void); -extern void sub_803E08C(void); -extern void bc_move_exec_returning(void); -extern s8 GetFlavourRelationByPersonality(u32 personality, u8 flavor); + +// rom const data +static const u16 sSoundMovesTable[] = +{ + MOVE_GROWL, MOVE_ROAR, MOVE_SING, MOVE_SUPERSONIC, MOVE_SCREECH, MOVE_SNORE, + MOVE_UPROAR, MOVE_METAL_SOUND, MOVE_GRASS_WHISTLE, MOVE_HYPER_VOICE, 0xFFFF +}; + +u8 GetBattleBank(u8 caseId) +{ + u8 ret = 0; + switch (caseId) + { + case BS_GET_TARGET: + ret = gBankTarget; + break; + case BS_GET_ATTACKER: + ret = gBankAttacker; + break; + case BS_GET_EFFECT_BANK: + ret = gEffectBank; + break; + case 7: + ret = 0; + break; + case BS_GET_SCRIPTING_BANK: + ret = gBattleScripting.bank; + break; + case 3: + ret = gBank1; + break; + case 5: + ret = gBank1; + break; + case 4: + case 6: + case 8: + case 9: + case BS_GET_PLAYER1: + ret = GetBankByIdentity(IDENTITY_PLAYER_MON1); + break; + case BS_GET_OPPONENT1: + ret = GetBankByIdentity(IDENTITY_OPPONENT_MON1); + break; + case BS_GET_PLAYER2: + ret = GetBankByIdentity(IDENTITY_PLAYER_MON2); + break; + case BS_GET_OPPONENT2: + ret = GetBankByIdentity(IDENTITY_OPPONENT_MON2); + break; + } + return ret; +} + +void PressurePPLose(u8 bankDef, u8 bankAtk, u16 move) +{ + s32 i; + + if (gBattleMons[bankDef].ability != ABILITY_PRESSURE) + return; + + for (i = 0; i < 4; i++) + { + if (gBattleMons[bankAtk].moves[i] == move) + break; + } + + if (i == 4) // mons don't share any moves + return; + + if (gBattleMons[bankAtk].pp[i] != 0) + gBattleMons[bankAtk].pp[i]--; + + if (!(gBattleMons[bankAtk].status2 & STATUS2_TRANSFORMED) + && !(gDisableStructs[bankAtk].unk18_b & gBitTable[i])) + { + gActiveBank = bankAtk; + EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + i, 0, 1, &gBattleMons[gActiveBank].pp[i]); + MarkBufferBankForExecution(gActiveBank); + } +} + +void PressurePPLoseOnUsingImprision(u8 bankAtk) +{ + s32 i, j; + s32 imprisionPos = 4; + u8 atkSide = GetBankSide(bankAtk); + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (atkSide != GetBankSide(i) && gBattleMons[i].ability == ABILITY_PRESSURE) + { + for (j = 0; j < 4; j++) + { + if (gBattleMons[bankAtk].moves[j] == MOVE_IMPRISON) + break; + } + if (j != 4) + { + imprisionPos = j; + if (gBattleMons[bankAtk].pp[j] != 0) + gBattleMons[bankAtk].pp[j]--; + } + } + } + + if (imprisionPos != 4 + && !(gBattleMons[bankAtk].status2 & STATUS2_TRANSFORMED) + && !(gDisableStructs[bankAtk].unk18_b & gBitTable[imprisionPos])) + { + gActiveBank = bankAtk; + EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + imprisionPos, 0, 1, &gBattleMons[gActiveBank].pp[imprisionPos]); + MarkBufferBankForExecution(gActiveBank); + } +} + +void PressurePPLoseOnUsingPerishSong(u8 bankAtk) +{ + s32 i, j; + s32 perishSongPos = 4; + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gBattleMons[i].ability == ABILITY_PRESSURE && i != bankAtk) + { + for (j = 0; j < 4; j++) + { + if (gBattleMons[bankAtk].moves[j] == MOVE_PERISH_SONG) + break; + } + if (j != 4) + { + perishSongPos = j; + if (gBattleMons[bankAtk].pp[j] != 0) + gBattleMons[bankAtk].pp[j]--; + } + } + } + + if (perishSongPos != 4 + && !(gBattleMons[bankAtk].status2 & STATUS2_TRANSFORMED) + && !(gDisableStructs[bankAtk].unk18_b & gBitTable[perishSongPos])) + { + gActiveBank = bankAtk; + EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + perishSongPos, 0, 1, &gBattleMons[gActiveBank].pp[perishSongPos]); + MarkBufferBankForExecution(gActiveBank); + } +} + +void MarkAllBufferBanksForExecution(void) // unused +{ + s32 i; + + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + for (i = 0; i < gNoOfAllBanks; i++) + gBattleExecBuffer |= gBitTable[i] << 0x1C; + } + else + { + for (i = 0; i < gNoOfAllBanks; i++) + gBattleExecBuffer |= gBitTable[i]; + } +} + +void MarkBufferBankForExecution(u8 bank) +{ + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + gBattleExecBuffer |= gBitTable[bank] << 0x1C; + } + else + { + gBattleExecBuffer |= gBitTable[bank]; + } +} + +void sub_803F850(u8 arg0) +{ + s32 i; + + for (i = 0; i < sub_8009FCC(); i++) + gBattleExecBuffer |= gBitTable[arg0] << (i << 2); + + gBattleExecBuffer &= ~(0x10000000 << arg0); +} + +void CancelMultiTurnMoves(u8 bank) +{ + gBattleMons[bank].status2 &= ~(STATUS2_MULTIPLETURNS); + gBattleMons[bank].status2 &= ~(STATUS2_LOCK_CONFUSE); + gBattleMons[bank].status2 &= ~(STATUS2_UPROAR); + gBattleMons[bank].status2 &= ~(STATUS2_BIDE); + + gStatuses3[bank] &= ~(STATUS3_SEMI_INVULNERABLE); + + gDisableStructs[bank].rolloutCounter1 = 0; + gDisableStructs[bank].furyCutterCounter = 0; +} + +bool8 WasUnableToUseMove(u8 bank) +{ + if (gProtectStructs[bank].prlzImmobility + || gProtectStructs[bank].targetNotAffected + || gProtectStructs[bank].usedImprisionedMove + || gProtectStructs[bank].loveImmobility + || gProtectStructs[bank].usedDisabledMove + || gProtectStructs[bank].usedTauntedMove + || gProtectStructs[bank].flag2Unknown + || gProtectStructs[bank].flinchImmobility + || gProtectStructs[bank].confusionSelfDmg) + return TRUE; + else + return FALSE; +} + +void PrepareStringBattle(u16 stringId, u8 bank) +{ + gActiveBank = bank; + EmitPrintString(0, stringId); + MarkBufferBankForExecution(gActiveBank); +} + +void ResetSentPokesToOpponentValue(void) +{ + s32 i; + u32 bits = 0; + + gSentPokesToOpponent[0] = 0; + gSentPokesToOpponent[1] = 0; + + for (i = 0; i < gNoOfAllBanks; i += 2) + bits |= gBitTable[gBattlePartyID[i]]; + + for (i = 1; i < gNoOfAllBanks; i += 2) + gSentPokesToOpponent[(i & BIT_MON) >> 1] = bits; +} + +void sub_803F9EC(u8 bank) +{ + s32 i = 0; + u32 bits = 0; + + if (GetBankSide(bank) == SIDE_OPPONENT) + { + u8 id = ((bank & BIT_MON) >> 1); + gSentPokesToOpponent[id] = 0; + + for (i = 0; i < gNoOfAllBanks; i += 2) + { + if (!(gAbsentBankFlags & gBitTable[i])) + bits |= gBitTable[gBattlePartyID[i]]; + } + + gSentPokesToOpponent[id] = bits; + } +} + +void sub_803FA70(u8 bank) +{ + if (GetBankSide(bank) == SIDE_OPPONENT) + { + sub_803F9EC(bank); + } + else + { + s32 i; + for (i = 1; i < gNoOfAllBanks; i++) + gSentPokesToOpponent[(i & BIT_MON) >> 1] |= gBitTable[gBattlePartyID[bank]]; + } +} void BattleScriptPush(const u8* bsPtr) { @@ -203,7 +459,7 @@ void BattleScriptPop(void) gBattlescriptCurrInstr = BATTLESCRIPTS_STACK->ptr[--BATTLESCRIPTS_STACK->size]; } -u8 sub_803FB4C(void) // msg, can't select a move +u8 TrySetCantSelectMoveBattleScript(void) { u8 limitations = 0; u16 move = gBattleMons[gActiveBank].moves[gBattleBufferB[gActiveBank][2]]; @@ -221,7 +477,7 @@ u8 sub_803FB4C(void) // msg, can't select a move } else { - gUnknown_02024220[gActiveBank] = gUnknown_082DAE1F; + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DAE1F; limitations = 1; } } @@ -236,7 +492,7 @@ u8 sub_803FB4C(void) // msg, can't select a move } else { - gUnknown_02024220[gActiveBank] = gUnknown_082DB089; + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB089; limitations++; } } @@ -251,7 +507,7 @@ u8 sub_803FB4C(void) // msg, can't select a move } else { - gUnknown_02024220[gActiveBank] = gUnknown_082DB0A0; + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB0A0; limitations++; } } @@ -266,7 +522,7 @@ u8 sub_803FB4C(void) // msg, can't select a move } else { - gUnknown_02024220[gActiveBank] = gUnknown_082DB181; + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB181; limitations++; } } @@ -288,7 +544,7 @@ u8 sub_803FB4C(void) // msg, can't select a move } else { - gUnknown_02024220[gActiveBank] = gUnknown_082DB812; + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB812; limitations++; } } @@ -301,7 +557,7 @@ u8 sub_803FB4C(void) // msg, can't select a move } else { - gUnknown_02024220[gActiveBank] = gUnknown_082DB076; + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB076; limitations++; } } @@ -352,7 +608,7 @@ bool8 AreAllMovesUnusable(void) if (unusable == 0xF) // all moves are unusable { gProtectStructs[gActiveBank].onlyStruggle = 1; - gUnknown_02024220[gActiveBank] = BattleScript_NoMovesLeft; + gBattlescriptPtrsForSelection[gActiveBank] = BattleScript_NoMovesLeft; } else { @@ -407,15 +663,15 @@ u8 UpdateTurnCounters(void) case 0: for (i = 0; i < gNoOfAllBanks; i++) { - gTurnOrder[i] = i; + gBanksByTurnOrder[i] = i; } for (i = 0; i < gNoOfAllBanks - 1; i++) { s32 j; for (j = i + 1; j < gNoOfAllBanks; j++) { - if (b_first_side(gTurnOrder[i], gTurnOrder[j], 0)) - sub_803CEDC(i, j); + if (GetWhoStrikesFirst(gBanksByTurnOrder[i], gBanksByTurnOrder[j], 0)) + SwapTurnOrder(i, j); } } @@ -540,7 +796,7 @@ u8 UpdateTurnCounters(void) case 5: while (gBattleStruct->turnSideTracker < gNoOfAllBanks) { - gActiveBank = gTurnOrder[gBattleStruct->turnSideTracker]; + gActiveBank = gBanksByTurnOrder[gBattleStruct->turnSideTracker]; if (gWishFutureKnock.wishCounter[gActiveBank] != 0 && --gWishFutureKnock.wishCounter[gActiveBank] == 0 && gBattleMons[gActiveBank].hp != 0) @@ -652,7 +908,7 @@ u8 TurnBasedEffects(void) gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_x20); while (gBattleStruct->turnEffectsBank < gNoOfAllBanks && gBattleStruct->turnEffectsTracker <= TURNBASED_MAX_CASE) { - gActiveBank = gBankAttacker = gTurnOrder[gBattleStruct->turnEffectsBank]; + gActiveBank = gBankAttacker = gBanksByTurnOrder[gBattleStruct->turnEffectsBank]; if (gAbsentBankFlags & gBitTable[gActiveBank]) { gBattleStruct->turnEffectsBank++; @@ -833,7 +1089,7 @@ u8 TurnBasedEffects(void) { gBankAttacker = gActiveBank; gBattleMons[gActiveBank].status2 -= 0x10; // uproar timer goes down - if (HasMoveFailed(gActiveBank)) + if (WasUnableToUseMove(gActiveBank)) { CancelMultiTurnMoves(gActiveBank); gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -859,7 +1115,7 @@ u8 TurnBasedEffects(void) if (gBattleMons[gActiveBank].status2 & STATUS2_LOCK_CONFUSE) { gBattleMons[gActiveBank].status2 -= 0x400; - if (HasMoveFailed(gActiveBank)) + if (WasUnableToUseMove(gActiveBank)) CancelMultiTurnMoves(gActiveBank); else if (!(gBattleMons[gActiveBank].status2 & STATUS2_LOCK_CONFUSE) && (gBattleMons[gActiveBank].status2 & STATUS2_MULTIPLETURNS)) @@ -1021,7 +1277,7 @@ bool8 sub_8041364(void) case 1: while (gBattleStruct->field_1A1 < gNoOfAllBanks) { - gActiveBank = gBankAttacker = gTurnOrder[gBattleStruct->field_1A1]; + gActiveBank = gBankAttacker = gBanksByTurnOrder[gBattleStruct->field_1A1]; if (gAbsentBankFlags & gBitTable[gActiveBank]) { gBattleStruct->field_1A1++; @@ -1130,7 +1386,7 @@ bool8 sub_8041728(void) case 4: do { - gBank1 = gBankTarget = gBattleStruct->field_4E; //or should banks be switched? + gBank1 = gBankTarget = gBattleStruct->field_4E; if (gBattleMons[gBattleStruct->field_4E].hp == 0 && !(gAbsentBankFlags & gBitTable[gBattleStruct->field_4E])) { @@ -1159,7 +1415,7 @@ bool8 sub_8041728(void) return FALSE; } -void b_clear_atk_up_if_hit_flag_unless_enraged(void) +void TryClearRageStatuses(void) { int i; for (i = 0; i < gNoOfAllBanks; i++) @@ -1667,7 +1923,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBankAttacker = bank; switch (gLastUsedAbility) { - case 0xFF: //weather from overworld + case ABILITYEFFECT_SWITCH_IN_WEATHER: //_08042A86 switch (weather_get_current()) { @@ -1850,12 +2106,12 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) //_08042EF8 if (gLastUsedAbility == ABILITY_SOUNDPROOF) { - for (i = 0; gSoundMovesTable[i] != 0xFFFF; i++) + for (i = 0; sSoundMovesTable[i] != 0xFFFF; i++) { - if (gSoundMovesTable[i] == move) + if (sSoundMovesTable[i] == move) break; } - if (gSoundMovesTable[i] != 0xFFFF) + if (sSoundMovesTable[i] != 0xFFFF) { if (gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS) gHitMarker |= HITMARKER_NO_PPDEDUCT; @@ -3156,7 +3412,7 @@ _08042EF8:\n\ bl _0804441E\n\ _08042F02:\n\ movs r4, 0\n\ - ldr r0, =gSoundMovesTable\n\ + ldr r0, =sSoundMovesTable\n\ ldrh r2, [r0]\n\ ldr r3, =0x0000ffff\n\ adds r1, r0, 0\n\ @@ -5444,8 +5700,8 @@ void BattleScriptExecute(const u8* BS_ptr) { gBattlescriptCurrInstr = BS_ptr; BATTLE_CALLBACKS_STACK->function[BATTLE_CALLBACKS_STACK->size++] = gBattleMainFunc; - gBattleMainFunc = bc_move_exec_returning; - gFightStateTracker = 0; + gBattleMainFunc = RunBattleScriptCommands_PopCallbacksStack; + gCurrentActionFuncId = 0; } void BattleScriptPushCursorAndCallback(const u8* BS_ptr) @@ -5453,7 +5709,7 @@ void BattleScriptPushCursorAndCallback(const u8* BS_ptr) BattleScriptPushCursor(); gBattlescriptCurrInstr = BS_ptr; BATTLE_CALLBACKS_STACK->function[BATTLE_CALLBACKS_STACK->size++] = gBattleMainFunc; - gBattleMainFunc = sub_803E08C; + gBattleMainFunc = RunBattleScriptCommands; } enum @@ -5523,7 +5779,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) switch (caseID) { - case 0: + case ITEMEFFECT_ON_SWITCH_IN: switch (bankHoldEffect) { case HOLD_EFFECT_DOUBLE_PRIZE: @@ -6188,14 +6444,14 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) return effect; } -void sub_8045868(u8 bank) +void ClearFuryCutterDestinyBondGrudge(u8 bank) { gDisableStructs[bank].furyCutterCounter = 0; gBattleMons[bank].status2 &= ~(STATUS2_DESTINY_BOND); gStatuses3[bank] &= ~(STATUS3_GRUDGE); } -void sub_80458B4(void) +void HandleAction_RunBattleScript(void) // identical to RunBattleScriptCommands { if (gBattleExecBuffer == 0) gBattleScriptingCommandsTable[*gBattlescriptCurrInstr](); diff --git a/src/berry_blender.c b/src/berry_blender.c new file mode 100644 index 000000000..db50fe4c4 --- /dev/null +++ b/src/berry_blender.c @@ -0,0 +1,18 @@ + +// Includes +#include "global.h" + +// Static type declarations + +// Static RAM declarations +IWRAM_DATA void *berry_blender_c_unused_03000de4; +IWRAM_DATA s16 gUnknown_03000DE8[8]; +IWRAM_DATA s16 gUnknown_03000DF8[6]; +IWRAM_DATA s16 gUnknown_03000E04; +IWRAM_DATA s16 gUnknown_03000E06; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c new file mode 100755 index 000000000..83d32b56c --- /dev/null +++ b/src/braille_puzzles.c @@ -0,0 +1,583 @@ +#include "global.h" +#include "event_data.h" +#include "songs.h" +#include "sound.h" +#include "script.h" +#include "species.h" +#include "task.h" +#include "field_effect.h" +#include "flags.h" + +extern void MapGridSetMetatileIdAt(s32 x, s32 y, u16 metatileId); // fieldmap +extern void DrawWholeMapView(); // field_camera +extern void SetCameraPanningCallback(void ( *callback)()); // field_camera +extern void InstallCameraPanAheadCallback(void); +extern void SetCameraPanning(s16 x, s16 y); +extern u8 brm_get_pokemon_selection(void); +extern void FieldEffectActiveListRemove(u8 id); // field_effect +extern u8 oei_task_add(void); + +// why do this, GF? +enum +{ + STRENGTH_PUZZLE, + FLY_PUZZLE +}; + +extern u8 gBraillePuzzleCallbackFlag; +extern u8 gUnknown_085EFE74[][2]; + +void SealedChamberShakingEffect(u8); +void sub_8179860(void); +void sub_8179944(void); + +bool8 ShouldDoBrailleDigEffect(void) +{ + if (!FlagGet(SYS_BRAILLE_DIG) + && (gSaveBlock1Ptr->location.mapGroup == 0x18 + && gSaveBlock1Ptr->location.mapNum == 0x47)) + { + if (gSaveBlock1Ptr->pos.x == 10 && gSaveBlock1Ptr->pos.y == 3) + return TRUE; + if (gSaveBlock1Ptr->pos.x == 9 && gSaveBlock1Ptr->pos.y == 3) + return TRUE; + if (gSaveBlock1Ptr->pos.x == 11 && gSaveBlock1Ptr->pos.y == 3) + return TRUE; + } + + return FALSE; +} + +void DoBrailleDigEffect(void) +{ + MapGridSetMetatileIdAt(16, 8, 554); + MapGridSetMetatileIdAt(17, 8, 555); + MapGridSetMetatileIdAt(18, 8, 556); + MapGridSetMetatileIdAt(16, 9, 3634); + MapGridSetMetatileIdAt(17, 9, 563); + MapGridSetMetatileIdAt(18, 9, 3636); + DrawWholeMapView(); + PlaySE(SE_BAN); + FlagSet(SYS_BRAILLE_DIG); + ScriptContext2_Disable(); +} + +bool8 CheckRelicanthWailord(void) +{ + // Emerald change: why did they flip it? + // First comes Wailord + if (GetMonData(&gPlayerParty[0], MON_DATA_SPECIES2, 0) == SPECIES_WAILORD) + { + CalculatePlayerPartyCount(); + // Last comes Relicanth + if (GetMonData(&gPlayerParty[gPlayerPartyCount - 1], MON_DATA_SPECIES2, 0) == SPECIES_RELICANTH) + return TRUE; + } + return FALSE; +} + +// THEORY: this was caused by block commenting out all of the older R/S braille functions but leaving the call to it itself, which creates the nullsub. +// the code is shown below to show what this might look like. +void ShouldDoBrailleStrengthEffectOld(void) +{ + /* + if (!FlagGet(SYS_BRAILLE_STRENGTH) && (gSaveBlock1.location.mapGroup == MAP_GROUP_DESERT_RUINS && gSaveBlock1.location.mapNum == MAP_ID_DESERT_RUINS)) + { + if (gSaveBlock1.pos.x == 10 && gSaveBlock1.pos.y == 23) + return TRUE; + else if (gSaveBlock1.pos.x == 9 && gSaveBlock1.pos.y == 23) + return TRUE; + else if (gSaveBlock1.pos.x == 11 && gSaveBlock1.pos.y == 23) + return TRUE; + } + + return FALSE; +} + +void DoBrailleStrengthEffect(void) +{ + FieldEffectActiveListRemove(FLDEFF_USE_STRENGTH); + MapGridSetMetatileIdAt(14, 26, 554); + MapGridSetMetatileIdAt(15, 26, 555); + MapGridSetMetatileIdAt(16, 26, 556); + MapGridSetMetatileIdAt(14, 27, 3634); + MapGridSetMetatileIdAt(15, 27, 563); + MapGridSetMetatileIdAt(16, 27, 3636); + DrawWholeMapView(); + PlaySE(SE_BAN); + FlagSet(SYS_BRAILLE_STRENGTH); + ScriptContext2_Disable(); +} + +bool8 ShouldDoBrailleFlyEffect(void) +{ + if (!FlagGet(SYS_BRAILLE_FLY) && (gSaveBlock1.location.mapGroup == MAP_GROUP_ANCIENT_TOMB && gSaveBlock1.location.mapNum == MAP_ID_ANCIENT_TOMB)) + { + if (gSaveBlock1.pos.x == 8 && gSaveBlock1.pos.y == 25) + return TRUE; + } + + return FALSE; +} + +void DoBrailleFlyEffect(void) +{ + gFieldEffectArguments[0] = gLastFieldPokeMenuOpened; + FieldEffectStart(FLDEFF_USE_FLY_ANCIENT_TOMB); +} + +bool8 FldEff_UseFlyAncientTomb(void) +{ + u8 taskId = oei_task_add(); + + gTasks[taskId].data[8] = (u32)UseFlyAncientTomb_Callback >> 16; + gTasks[taskId].data[9] = (u32)UseFlyAncientTomb_Callback; + return FALSE; +} + +void UseFlyAncientTomb_Callback(void) +{ + FieldEffectActiveListRemove(FLDEFF_USE_FLY_ANCIENT_TOMB); + UseFlyAncientTomb_Finish(); +} + +void UseFlyAncientTomb_Finish(void) +{ + MapGridSetMetatileIdAt(14, 26, 554); + MapGridSetMetatileIdAt(15, 26, 555); + MapGridSetMetatileIdAt(16, 26, 556); + MapGridSetMetatileIdAt(14, 27, 3634); + MapGridSetMetatileIdAt(15, 27, 563); + MapGridSetMetatileIdAt(16, 27, 3636); + DrawWholeMapView(); + PlaySE(SE_BAN); + FlagSet(SYS_BRAILLE_FLY); + ScriptContext2_Disable(); +} + */ +} + +void DoSealedChamberShakingEffect1(void) +{ + u8 taskId = CreateTask(SealedChamberShakingEffect, 9); + + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[4] = 2; + gTasks[taskId].data[5] = 5; + gTasks[taskId].data[6] = 50; + SetCameraPanningCallback(0); +} + +void DoSealedChamberShakingEffect2(void) +{ + u8 taskId = CreateTask(SealedChamberShakingEffect, 9); + + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[4] = 3; + gTasks[taskId].data[5] = 5; + gTasks[taskId].data[6] = 2; + SetCameraPanningCallback(0); +} + +void SealedChamberShakingEffect(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + task->data[1]++; + + if (!(task->data[1] % task->data[5])) + { + task->data[1] = 0; + task->data[2]++; + task->data[4] = -task->data[4]; + SetCameraPanning(0, task->data[4]); + if (task->data[2] == task->data[6]) + { + DestroyTask(taskId); + EnableBothScriptContexts(); + InstallCameraPanAheadCallback(); + } + } +} + +// moved later in the function because it was rewritten. +bool8 ShouldDoBrailleStrengthEffect(void) +{ + if (!FlagGet(SYS_BRAILLE_STRENGTH) && (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x06)) + { + if (gSaveBlock1Ptr->pos.x == 6 && gSaveBlock1Ptr->pos.y == 23) + { gBraillePuzzleCallbackFlag = STRENGTH_PUZZLE; return TRUE; } + else if (gSaveBlock1Ptr->pos.x == 5 && gSaveBlock1Ptr->pos.y == 23) + { gBraillePuzzleCallbackFlag = STRENGTH_PUZZLE; return TRUE; } + else if (gSaveBlock1Ptr->pos.x == 7 && gSaveBlock1Ptr->pos.y == 23) + { gBraillePuzzleCallbackFlag = STRENGTH_PUZZLE; return TRUE; } + } + + return FALSE; +} + +void sub_8179834(void) +{ + gFieldEffectSpawnParams[0] = brm_get_pokemon_selection(); + FieldEffectStart(FLDEFF_USE_FLY_ANCIENT_TOMB); +} + +void UseStrengthDesertRuins_Callback(void) +{ + FieldEffectActiveListRemove(FLDEFF_USE_FLY_ANCIENT_TOMB); + sub_8179860(); +} + +void sub_8179860(void) +{ + MapGridSetMetatileIdAt(14, 26, 554); + MapGridSetMetatileIdAt(15, 26, 555); + MapGridSetMetatileIdAt(16, 26, 556); + MapGridSetMetatileIdAt(14, 27, 3634); + MapGridSetMetatileIdAt(15, 27, 563); + MapGridSetMetatileIdAt(16, 27, 3636); + DrawWholeMapView(); + PlaySE(SE_BAN); + FlagSet(SYS_BRAILLE_STRENGTH); + ScriptContext2_Disable(); +} + +bool8 ShouldDoBrailleFlyEffect(void) +{ + if (!FlagGet(SYS_BRAILLE_FLY) && (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x44)) + { + if (gSaveBlock1Ptr->pos.x == 8 && gSaveBlock1Ptr->pos.y == 25) + { gBraillePuzzleCallbackFlag = FLY_PUZZLE; return TRUE; } + } + return FALSE; +} + +void sub_8179918(void) +{ + gFieldEffectSpawnParams[0] = brm_get_pokemon_selection(); + FieldEffectStart(FLDEFF_USE_FLY_ANCIENT_TOMB); +} + +void UseFlyAncientTomb_Callback(void) +{ + FieldEffectActiveListRemove(FLDEFF_USE_FLY_ANCIENT_TOMB); + sub_8179944(); +} + +void sub_8179944(void) +{ + MapGridSetMetatileIdAt(14, 26, 554); + MapGridSetMetatileIdAt(15, 26, 555); + MapGridSetMetatileIdAt(16, 26, 556); + MapGridSetMetatileIdAt(14, 27, 3634); + MapGridSetMetatileIdAt(15, 27, 563); + MapGridSetMetatileIdAt(16, 27, 3636); + DrawWholeMapView(); + PlaySE(SE_BAN); + FlagSet(SYS_BRAILLE_FLY); + ScriptContext2_Disable(); +} + +// theory: another commented out DoBrailleWait and Task_BrailleWait. +void DoBrailleWait(void) +{ + /* + if (!FlagGet(SYS_BRAILLE_WAIT)) + CreateTask(Task_BrailleWait, 0x50); +} + +void Task_BrailleWait(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + switch (data[0]) + { + case 0: + data[1] = 7200; + data[0] = 1; + break; + case 1: + if (BrailleWait_CheckButtonPress() != FALSE) + { + MenuZeroFillScreen(); + PlaySE(SE_SELECT); + data[0] = 2; + } + else + { + data[1] = data[1] - 1; + if (data[1] == 0) + { + MenuZeroFillScreen(); + data[0] = 3; + data[1] = 30; + } + } + break; + case 2: + if (BrailleWait_CheckButtonPress() == FALSE) + { + data[1] = data[1] - 1; + if (data[1] == 0) + data[0] = 4; + break; + } + sub_8064E2C(); + DestroyTask(taskId); + ScriptContext2_Disable(); + break; + case 3: + data[1] = data[1] - 1; + if (data[1] == 0) + data[0] = 4; + break; + case 4: + sub_8064E2C(); + ScriptContext1_SetupScript(S_OpenRegiceChamber); + DestroyTask(taskId); + break; + } +} + +bool32 BrailleWait_CheckButtonPress(void) +{ + u16 keyMask = A_BUTTON | B_BUTTON | START_BUTTON | SELECT_BUTTON | DPAD_ANY; + + if (gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR) + keyMask |= L_BUTTON | R_BUTTON; + if (gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A) + keyMask |= L_BUTTON; + + if (gMain.newKeys & keyMask) + return TRUE; + else + return FALSE; + */ +} + +// this used to be FldEff_UseFlyAncientTomb . why did GF merge the 2 functions? +bool8 FldEff_UsePuzzleEffect(void) +{ + u8 taskId = oei_task_add(); + + if (gBraillePuzzleCallbackFlag == FLY_PUZZLE) + { + gTasks[taskId].data[8] = (u32)UseFlyAncientTomb_Callback >> 16; + gTasks[taskId].data[9] = (u32)UseFlyAncientTomb_Callback; + } + else + { + gTasks[taskId].data[8] = (u32)UseStrengthDesertRuins_Callback >> 16; + gTasks[taskId].data[9] = (u32)UseStrengthDesertRuins_Callback; + } + return FALSE; +} + +// can't get this one to match due to the weird macro-like varsets with strange bitshifting. +// to note: 0x10000 is loaded in, and its obviously supposed to be 1, but i cant get 0x80 << 9 to be loaded in without using it directly. +// maybe there's some way of writing it that works? +#ifdef NONMATCHING +// ShouldDoBrailleRegicePuzzle +bool8 ShouldDoBrailleRegicePuzzle(void) +{ + u8 i; + + if (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x43) + { + // _08179A1A + if (FlagGet(SYS_BRAILLE_WAIT) != FALSE) + return FALSE; + if (FlagGet(2) == FALSE) + return FALSE; + if (FlagGet(3) == TRUE) + return FALSE; + + for (i = 0; i < 36; i++) + { + if (gSaveBlock1Ptr->pos.x == gUnknown_085EFE74[i][0] && gSaveBlock1Ptr->pos.y == gUnknown_085EFE74[i][1]) + { + if (i < 16) + VarSet(0x403B, (0x10000 << i | VarGet(0x403B) << 16) >> 16); // correct + else if (i < 32) + VarSet(0x403C, (0x10000 << (i - 16) | VarGet(0x403C) << 16) >> 16); // hmm? + else + VarSet(0x403D, (0x10000 << (i - 32) | VarGet(0x403D) << 16) >> 16); // hmm? + + if (VarGet(0x403B) != 0xFFFF || VarGet(0x403C) != 0xFF || VarGet(0x403D) != 0xF) + return FALSE; + + if (gSaveBlock1Ptr->pos.x == 8 && gSaveBlock1Ptr->pos.y == 21) + return TRUE; + else + return FALSE; + } + } + } + // TODO: Find what flags 2 and 3 are. + FlagSet(3); + FlagReset(2); + return FALSE; +} +#else +__attribute__((naked)) +bool8 ShouldDoBrailleRegicePuzzle(void) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r9\n\ + mov r6, r8\n\ + push {r6,r7}\n\ + ldr r4, =gSaveBlock1Ptr\n\ + ldr r0, [r4]\n\ + ldrh r1, [r0, 0x4]\n\ + ldr r0, =0x00004318\n\ + cmp r1, r0\n\ + beq _08179A1A\n\ + b _08179B5A\n\ +_08179A1A:\n\ + ldr r0, =0x000008b1\n\ + bl FlagGet\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _08179A28\n\ + b _08179B5A\n\ +_08179A28:\n\ + movs r0, 0x2\n\ + bl FlagGet\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _08179A36\n\ + b _08179B5A\n\ +_08179A36:\n\ + movs r0, 0x3\n\ + bl FlagGet\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + bne _08179A58\n\ + b _08179B5A\n\ + .pool\n\ +_08179A54:\n\ + movs r0, 0x1\n\ + b _08179B5C\n\ +_08179A58:\n\ + movs r5, 0\n\ + mov r8, r4\n\ + ldr r4, =gUnknown_085EFE74\n\ + adds r0, r4, 0x1\n\ + mov r12, r0\n\ + ldr r6, =0x0000403b\n\ + ldr r1, =0x0000403c\n\ + mov r9, r1\n\ +_08179A68:\n\ + lsls r0, r5, 1\n\ + adds r1, r0, r4\n\ + add r0, r12\n\ + ldrb r3, [r0]\n\ + mov r7, r8\n\ + ldr r2, [r7]\n\ + movs r7, 0\n\ + ldrsh r0, [r2, r7]\n\ + ldrb r1, [r1]\n\ + cmp r0, r1\n\ + bne _08179B44\n\ + movs r1, 0x2\n\ + ldrsh r0, [r2, r1]\n\ + cmp r0, r3\n\ + bne _08179B44\n\ + cmp r5, 0xF\n\ + bhi _08179AB0\n\ + adds r0, r6, 0\n\ + bl VarGet\n\ + lsls r0, 16\n\ + movs r1, 0x80\n\ + lsls r1, 9\n\ + lsls r1, r5\n\ + orrs r1, r0\n\ + lsrs r1, 16\n\ + adds r0, r6, 0\n\ + bl VarSet\n\ + b _08179AF0\n\ + .pool\n\ +_08179AB0:\n\ + cmp r5, 0x1F\n\ + bhi _08179AD2\n\ + mov r0, r9\n\ + bl VarGet\n\ + lsls r0, 16\n\ + adds r2, r5, 0\n\ + subs r2, 0x10\n\ + movs r1, 0x80\n\ + lsls r1, 9\n\ + lsls r1, r2\n\ + orrs r1, r0\n\ + lsrs r1, 16\n\ + mov r0, r9\n\ + bl VarSet\n\ + b _08179AF0\n\ +_08179AD2:\n\ + ldr r4, =0x0000403d\n\ + adds r0, r4, 0\n\ + bl VarGet\n\ + lsls r0, 16\n\ + adds r2, r5, 0\n\ + subs r2, 0x20\n\ + movs r1, 0x80\n\ + lsls r1, 9\n\ + lsls r1, r2\n\ + orrs r1, r0\n\ + lsrs r1, 16\n\ + adds r0, r4, 0\n\ + bl VarSet\n\ +_08179AF0:\n\ + ldr r0, =0x0000403b\n\ + bl VarGet\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + ldr r0, =0x0000ffff\n\ + cmp r4, r0\n\ + bne _08179B5A\n\ + ldr r0, =0x0000403c\n\ + bl VarGet\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + cmp r0, r4\n\ + bne _08179B5A\n\ + ldr r0, =0x0000403d\n\ + bl VarGet\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + cmp r0, 0xF\n\ + bne _08179B5A\n\ + ldr r0, =gSaveBlock1Ptr\n\ + ldr r0, [r0]\n\ + ldr r1, [r0]\n\ + ldr r0, =0x00150008\n\ + cmp r1, r0\n\ + beq _08179A54\n\ + b _08179B5A\n\ + .pool\n\ +_08179B44:\n\ + adds r0, r5, 0x1\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + cmp r5, 0x23\n\ + bls _08179A68\n\ + movs r0, 0x3\n\ + bl FlagSet\n\ + movs r0, 0x2\n\ + bl FlagReset\n\ +_08179B5A:\n\ + movs r0, 0\n\ +_08179B5C:\n\ + pop {r3,r4}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + .syntax divided"); +} +#endif diff --git a/src/diploma.c b/src/diploma.c new file mode 100755 index 000000000..f2cbcabb7 --- /dev/null +++ b/src/diploma.c @@ -0,0 +1,218 @@ +#include "global.h" +#include "palette.h" +#include "main.h" +#include "gpu_regs.h" +#include "unknown_task.h" +#include "task.h" +#include "malloc.h" +#include "decompress.h" +#include "bg.h" +#include "window.h" +#include "string_util.h" +#include "text.h" + +extern void reset_temp_tile_data_buffers(void); +extern int decompress_and_copy_tile_data_to_vram(u8 bg_id, void *src, int size, u16 offset, u8 mode); +extern bool8 free_temp_tile_data_buffers_if_possible(void); +extern void sub_80861E8(void); // rom4 +extern bool16 sub_80C0944(void); +extern void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor *color, s8 speed, u8 *str); + +extern u16 gUnknown_0860F074[]; + +extern u8 gText_DexNational[]; +extern u8 gText_DexHoenn[]; +extern u8 gText_PokedexDiploma[]; + +static void MainCB2(void); +static void Task_DiplomaFadeIn(u8); +static void Task_DiplomaWaitForKeyPress(u8); +static void Task_DiplomaFadeOut(u8); +static void DisplayDiplomaText(void); +static void InitDiplomaBg(void); +static void InitDiplomaWindow(void); +static void PrintDiplomaText(u8 *, u8, u8); + +EWRAM_DATA void **gDiplomaTilemapPtr = {NULL}; + +static void VBlankCB(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +static const u16 gDiplomaPalettes[][16] = +{ + INCBIN_U16("graphics/misc/diploma_national.gbapal"), + INCBIN_U16("graphics/misc/diploma_hoenn.gbapal"), +}; + +static const u8 gDiplomaTilemap[] = INCBIN_U8("graphics/misc/diploma_map.bin.lz"); +static const u8 gDiplomaTiles[] = INCBIN_U8("graphics/misc/diploma.4bpp.lz"); + +void CB2_ShowDiploma(void) +{ + SetVBlankCallback(NULL); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0); + SetGpuReg(REG_OFFSET_BG3CNT, DISPCNT_MODE_0); + SetGpuReg(REG_OFFSET_BG2CNT, DISPCNT_MODE_0); + SetGpuReg(REG_OFFSET_BG1CNT, DISPCNT_MODE_0); + SetGpuReg(REG_OFFSET_BG0CNT, DISPCNT_MODE_0); + SetGpuReg(REG_OFFSET_BG3HOFS, DISPCNT_MODE_0); + SetGpuReg(REG_OFFSET_BG3VOFS, DISPCNT_MODE_0); + SetGpuReg(REG_OFFSET_BG2HOFS, DISPCNT_MODE_0); + SetGpuReg(REG_OFFSET_BG2VOFS, DISPCNT_MODE_0); + SetGpuReg(REG_OFFSET_BG1HOFS, DISPCNT_MODE_0); + SetGpuReg(REG_OFFSET_BG1VOFS, DISPCNT_MODE_0); + SetGpuReg(REG_OFFSET_BG0HOFS, DISPCNT_MODE_0); + SetGpuReg(REG_OFFSET_BG0VOFS, DISPCNT_MODE_0); + // why doesn't this one use the dma manager either? + DmaFill16(3, 0, VRAM, VRAM_SIZE); + DmaFill32(3, 0, OAM, OAM_SIZE); + DmaFill16(3, 0, PLTT, PLTT_SIZE); + remove_some_task(); + ResetTasks(); + ResetSpriteData(); + ResetPaletteFade(); + FreeAllSpritePalettes(); + LoadPalette(gDiplomaPalettes, 0, 64); + gDiplomaTilemapPtr = malloc(0x1000); + InitDiplomaBg(); + InitDiplomaWindow(); + reset_temp_tile_data_buffers(); + decompress_and_copy_tile_data_to_vram(1, &gDiplomaTiles, 0, 0, 0); + while (free_temp_tile_data_buffers_if_possible()) + ; + LZDecompressWram(&gDiplomaTilemap, gDiplomaTilemapPtr); + CopyBgTilemapBufferToVram(1); + DisplayDiplomaText(); + BlendPalettes(-1, 16, 0); + BeginNormalPaletteFade(-1, 0, 16, 0, 0); + EnableInterrupts(1); + SetVBlankCallback(VBlankCB); + SetMainCallback2(MainCB2); + CreateTask(Task_DiplomaFadeIn, 0); +} + +static void MainCB2(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +static void Task_DiplomaFadeIn(u8 taskId) +{ + if (!gPaletteFade.active) + gTasks[taskId].func = Task_DiplomaWaitForKeyPress; +} + +static void Task_DiplomaWaitForKeyPress(u8 taskId) +{ + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + BeginNormalPaletteFade(-1, 0, 0, 16, 0); + gTasks[taskId].func = Task_DiplomaFadeOut; + } +} + +static void Task_DiplomaFadeOut(u8 taskId) +{ + if (!gPaletteFade.active) + { + Free(gDiplomaTilemapPtr); + FreeAllWindowBuffers(); + DestroyTask(taskId); + SetMainCallback2(sub_80861E8); + } +} + +static void DisplayDiplomaText(void) +{ + if (sub_80C0944()) + { + SetGpuReg(REG_OFFSET_BG1HOFS, DISPCNT_BG0_ON); + StringCopy(gStringVar1, gText_DexNational); + } + else + { + SetGpuReg(REG_OFFSET_BG1HOFS, DISPCNT_MODE_0); + StringCopy(gStringVar1, gText_DexHoenn); + } + StringExpandPlaceholders(gStringVar4, gText_PokedexDiploma); + PrintDiplomaText(gStringVar4, 0, 1); + PutWindowTilemap(0); + CopyWindowToVram(0, 3); +} + +static const struct BgTemplate gDiplomaBgTemplates[2] = +{ + { + .bg = 0, + .charBaseIndex = 1, + .mapBaseIndex = 31, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0, + }, + { + .bg = 1, + .charBaseIndex = 0, + .mapBaseIndex = 6, + .screenSize = 1, + .paletteMode = 0, + .priority = 1, + .baseTile = 0, + }, +}; + +static void InitDiplomaBg(void) +{ + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gDiplomaBgTemplates, 2); + SetBgTilemapBuffer(1, gDiplomaTilemapPtr); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); + ShowBg(0); + ShowBg(1); + SetGpuReg(REG_OFFSET_BLDCNT, DISPCNT_MODE_0); + SetGpuReg(REG_OFFSET_BLDALPHA, DISPCNT_MODE_0); + SetGpuReg(REG_OFFSET_BLDY, DISPCNT_MODE_0); +} + +static const struct WindowTemplate gDiplomaWinTemplates[2] = +{ + { + .priority = 0, + .tilemapLeft = 5, + .tilemapTop = 2, + .width = 20, + .height = 16, + .paletteNum = 15, + .baseBlock = 1, + }, + DUMMY_WIN_TEMPLATE, +}; + +static void InitDiplomaWindow(void) +{ + InitWindows(gDiplomaWinTemplates); + DeactivateAllTextPrinters(); + LoadPalette(gUnknown_0860F074, 0xF0, 0x20); + FillWindowPixelBuffer(0, 0); + PutWindowTilemap(0); +} + +static void PrintDiplomaText(u8 *text, u8 var1, u8 var2) +{ + struct TextColor color = + { + .fgColor = 0, + .bgColor = 2, + .shadowColor = 3, + }; + + AddTextPrinterParametrized2(0, 1, var1, var2, 0, 0, &color, -1, text); +} diff --git a/src/dma3_manager.c b/src/dma3_manager.c index 7cce06c15..bb015c5cf 100644 --- a/src/dma3_manager.c +++ b/src/dma3_manager.c @@ -1,12 +1,23 @@ #include "global.h" #include "dma3.h" +IWRAM_DATA struct { + /* 0x00 */ const u8 *src; + /* 0x04 */ u8 *dest; + /* 0x08 */ u16 size; + /* 0x0A */ u16 mode; + /* 0x0C */ u32 value; +} gDma3Requests[128]; + +static bool8 gDma3ManagerLocked; +static u8 gDma3RequestCursor; + void ClearDma3Requests(void) { int i; gDma3ManagerLocked = TRUE; - gDma3RequestCursor = FALSE; + gDma3RequestCursor = 0; for(i = 0; i < (u8)ARRAY_COUNT(gDma3Requests); i++) { @@ -22,7 +33,6 @@ void ClearDma3Requests(void) void ProcessDma3Requests(void) { // NOTE: the fillerA member of the DMA struct is actually u32 value; - // NOTE: gUnknown_0300001C is just a pointer inside the gDma3Requests structure, not a true symbol; feel free to remove u16 total_size; if (gDma3ManagerLocked) @@ -331,7 +341,7 @@ _08000DB2:\n\ mov r5, r12\n\ ldrb r0, [r5]\n\ lsls r0, 4\n\ - ldr r3, =gUnknown_0300001C\n\ + ldr r3, =gDma3Requests + 0x0C\n\ adds r0, r3\n\ ldr r0, [r0]\n\ strh r0, [r1]\n\ @@ -347,7 +357,7 @@ _08000DB2:\n\ bhi _08000DB2\n\ ldrb r0, [r5]\n\ lsls r0, 4\n\ - ldr r5, =gUnknown_0300001C\n\ + ldr r5, =gDma3Requests + 0x0C\n\ adds r0, r5\n\ ldr r0, [r0]\n\ strh r0, [r1]\n\ diff --git a/src/egg_hatch.c b/src/egg_hatch.c index 6d14e92f0..4e4c10090 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -64,8 +64,8 @@ extern void sub_806A068(u16, u8); extern void fade_screen(u8, u8); extern void overworld_free_bg_tilemaps(void); extern void sub_80AF168(void); -extern void init_uns_table_pokemon_copy(void); -extern void sub_805F094(void); +extern void AllocateMonSpritesGfx(void); +extern void FreeMonSpritesGfx(void); extern void remove_some_task(void); extern void reset_temp_tile_data_buffers(void); extern void c2_exit_to_overworld_2_switch(void); @@ -439,7 +439,7 @@ static u8 EggHatchCreateMonSprite(u8 a0, u8 switchID, u8 pokeID, u16* speciesLoc u16 species = GetMonData(mon, MON_DATA_SPECIES); u32 pid = GetMonData(mon, MON_DATA_PERSONALITY); HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], - gBattleSpritesGfx->sprites[(a0 * 2) + 1], + gMonSpritesGfxPtr->sprites[(a0 * 2) + 1], species, pid); LoadCompressedObjectPalette(sub_806E794(mon)); *speciesLoc = species; @@ -488,7 +488,7 @@ static void CB2_EggHatch_0(void) SetGpuReg(REG_OFFSET_DISPCNT, 0); sEggHatchData = Alloc(sizeof(struct EggHatchData)); - init_uns_table_pokemon_copy(); + AllocateMonSpritesGfx(); sEggHatchData->eggPartyID = gSpecialVar_0x8004; sEggHatchData->eggShardVelocityID = 0; @@ -570,7 +570,7 @@ static void CB2_EggHatch_0(void) static void EggHatchSetMonNickname(void) { SetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, gStringVar3); - sub_805F094(); + FreeMonSpritesGfx(); Free(sEggHatchData); SetMainCallback2(c2_exit_to_overworld_2_switch); } @@ -691,7 +691,7 @@ static void CB2_EggHatch_1(void) case 12: if (!gPaletteFade.active) { - sub_805F094(); + FreeMonSpritesGfx(); RemoveWindow(sEggHatchData->windowId); UnsetBgTilemapBuffer(0); UnsetBgTilemapBuffer(1); diff --git a/src/field_camera.c b/src/field_camera.c new file mode 100644 index 000000000..17ced6aa5 --- /dev/null +++ b/src/field_camera.c @@ -0,0 +1,28 @@ + +// Includes +#include "global.h" + +// Static type declarations + +struct FieldCameraUnknownStruct +{ + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + bool8 unk4; +}; + +// Static RAM declarations + +IWRAM_DATA struct FieldCameraUnknownStruct gUnknown_03000E20; +IWRAM_DATA s16 gUnknown_03000E28; +IWRAM_DATA s16 gUnknown_03000E2A; +IWRAM_DATA u8 gUnknown_03000E2C; +IWRAM_DATA void (*gUnknown_03000E30)(void); + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/field_effect.c b/src/field_effect.c new file mode 100644 index 000000000..628dc776a --- /dev/null +++ b/src/field_effect.c @@ -0,0 +1,15 @@ + +// Includes +#include "global.h" + +// Static type declarations + +// Static RAM declarations + +IWRAM_DATA u8 gUnknown_03000F58[32]; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/field_screen.c b/src/field_screen.c new file mode 100644 index 000000000..2d33d237f --- /dev/null +++ b/src/field_screen.c @@ -0,0 +1,15 @@ + +// Includes +#include "global.h" + +// Static type declarations + +// Static RAM declarations +IWRAM_DATA u8 *gUnknown_03000F50; +IWRAM_DATA u32 filler_03000f54; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c new file mode 100644 index 000000000..9929dd6f9 --- /dev/null +++ b/src/fldeff_cut.c @@ -0,0 +1,19 @@ + +// Includes +#include "global.h" + +// Static type declarations + +// Static RAM declarations + +IWRAM_DATA u8 gUnknown_03001100; +IWRAM_DATA u8 gUnknown_03001101; +IWRAM_DATA u8 gUnknown_03001102; +IWRAM_DATA u32 fldeff_cut_unused_03001104; +IWRAM_DATA u8 gUnknown_03001108[25]; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/link.c b/src/link.c new file mode 100644 index 000000000..ae2cd1992 --- /dev/null +++ b/src/link.c @@ -0,0 +1,56 @@ + +// Includes +#include "global.h" + +// Static type declarations + +struct BlockTransfer +{ + u16 pos; + u16 size; + void *src; + bool8 active; + u8 multiplayerId; +}; + +struct LinkTestBGInfo +{ + u32 screenBaseBlock; + u32 paletteNum; + u32 dummy_8; + u32 dummy_C; +}; + +// Static RAM declarations + +IWRAM_DATA struct BlockTransfer gUnknown_03000D10; +IWRAM_DATA u32 link_c_unused_03000d1c; +IWRAM_DATA struct BlockTransfer gUnknown_03000D20[4]; +IWRAM_DATA u32 gUnknown_03000D50; +IWRAM_DATA u32 gUnknown_03000D54; +IWRAM_DATA u8 gUnknown_03000D58; +IWRAM_DATA u32 gUnknown_03000D5C; +IWRAM_DATA u32 gUnknown_03000D60; +IWRAM_DATA u8 gUnknown_03000D64[4]; // not really, but won't match otherwise +IWRAM_DATA u8 gUnknown_03000D68[4]; +IWRAM_DATA u8 gUnknown_03000D6C; +IWRAM_DATA bool8 gUnknown_03000D6D; +IWRAM_DATA u16 gUnknown_03000D6E; +IWRAM_DATA u16 gUnknown_03000D70; +IWRAM_DATA u8 gUnknown_03000D72; +IWRAM_DATA u8 gUnknown_03000D73; +IWRAM_DATA u8 gUnknown_03000D74[4]; // not really, but won't match otherwise +IWRAM_DATA u8 gUnknown_03000D78[8]; // not really, but won't match otherwise +IWRAM_DATA u8 gUnknown_03000D80[16]; +IWRAM_DATA u16 gUnknown_03000D90[8]; +IWRAM_DATA u32 gUnknown_03000DA0; +IWRAM_DATA u32 gUnknown_03000DA4; +IWRAM_DATA void *gUnknown_03000DA8; +IWRAM_DATA void *gUnknown_03000DAC; +IWRAM_DATA bool32 gUnknown_03000DB0; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/main.c b/src/main.c index 5707e18af..665a4dd84 100644 --- a/src/main.c +++ b/src/main.c @@ -77,7 +77,7 @@ const IntrFunc gIntrTableTemplate[] = #define INTR_COUNT ((int)(sizeof(gIntrTableTemplate)/sizeof(IntrFunc))) -extern u16 gUnknown_03000000; +static u16 gUnknown_03000000; extern u16 gKeyRepeatStartDelay; extern u8 gUnknown_030022B4; diff --git a/src/main_menu.c b/src/main_menu.c new file mode 100644 index 000000000..8608159c2 --- /dev/null +++ b/src/main_menu.c @@ -0,0 +1,15 @@ + +// Includes +#include "global.h" + +// Static type declarations + +// Static RAM declarations + +IWRAM_DATA u8 gUnknown_03000DD0; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/malloc.c b/src/malloc.c index ccb2f7d20..1d64351c3 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -2,6 +2,7 @@ static void *sHeapStart; static u32 sHeapSize; +static u32 malloc_c_unused_0300000c; // needed to align dma3_manager.o(.bss) #define MALLOC_SYSTEM_ID 0xA3A3 diff --git a/src/palette.c b/src/palette.c index aa9a84e4c..d60efdbc5 100644 --- a/src/palette.c +++ b/src/palette.c @@ -1,5 +1,8 @@ #include "global.h" +#include "blend_palette.h" #include "palette.h" +#include "decompress.h" +#include "gpu_regs.h" #include "task.h" enum @@ -28,7 +31,7 @@ struct PaletteStructTemplate struct PaletteStruct { - struct PaletteStructTemplate *base; + const struct PaletteStructTemplate *base; u32 ps_field_4_0:1; u16 ps_field_4_1:1; u32 baseDestOffset:9; @@ -38,31 +41,6 @@ struct PaletteStruct u8 ps_field_9; }; -extern void LZDecompressWram(const void *src, void *dest); -extern void SetGpuReg(u8 regOffset, u16 value); -extern void sub_8149DFC(u8 a1); -extern void sub_80A1670(u16 a1); -extern void sub_80A2D54(u8 a1); -extern void SetWordTaskArg(u8 taskId, u8 dataElem, u32 value); -extern void _call_via_r1(u32 a1, void *a2); - -extern void BlendPalette(u16, u16, u8, u16); - -EWRAM_DATA u16 gPlttBufferUnfaded[0x200] = {0}; -EWRAM_DATA u16 gPlttBufferFaded[0x200] = {0}; -EWRAM_DATA struct PaletteStruct sPaletteStructs[0x10] = {0}; -EWRAM_DATA struct PaletteFadeControl gPaletteFade = {0}; -EWRAM_DATA u32 gFiller_2037FE0 = 0; -EWRAM_DATA u32 sPlttBufferTransferPending = 0; -EWRAM_DATA u8 gPaletteDecompressionBuffer[0x400] = {0}; - -extern struct PaletteStructTemplate gDummyPaletteStructTemplate; -extern void *gUnknown_0852487C; -extern u8 gUnknown_0852489C[]; - -extern u16 gUnknown_03000F3C; -extern void *gUnknown_03000F44; - static void unused_sub_80A1CDC(struct PaletteStruct *, u32 *); static void unused_sub_80A1E40(struct PaletteStruct *, u32 *); static void unused_sub_80A1F00(struct PaletteStruct *); @@ -73,32 +51,29 @@ static u8 UpdateFastPaletteFade(void); static u8 UpdateHardwarePaletteFade(void); static void UpdateBlendRegisters(void); static bool8 IsSoftwarePaletteFadeFinishing(void); +static void sub_80A2D54(u8 taskId); -void sub_80A1818(u16 a1) -{ - void **v1 = &gUnknown_0852487C; - CpuSet(v1[a1 & 0x3], gPlttBufferUnfaded + 0x80, 0x10); - BlendPalette(0x80, 0x10, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF); - if ((u8)FindTaskIdByFunc(sub_8149DFC) != 0xFF ) - { - gUnknown_03000F44 = sub_80A1670; - gUnknown_03000F3C = 0x20; - } - return; -} +EWRAM_DATA u16 gPlttBufferUnfaded[0x200] = {0}; +EWRAM_DATA u16 gPlttBufferFaded[0x200] = {0}; +EWRAM_DATA struct PaletteStruct sPaletteStructs[0x10] = {0}; +EWRAM_DATA struct PaletteFadeControl gPaletteFade = {0}; +static EWRAM_DATA u32 gFiller_2037FE0 = 0; +static EWRAM_DATA u32 sPlttBufferTransferPending = 0; +EWRAM_DATA u8 gPaletteDecompressionBuffer[0x400] = {0}; -void sub_80A1884(u16 a1) -{ - void **v1 = &gUnknown_0852487C; - CpuSet(v1[a1 & 0x3], gPlttBufferUnfaded + 0x80, 0x10); - if ((u8)FindTaskIdByFunc(sub_8149DFC) == 0xFF ) - { - BlendPalette(0x80, 0x10, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF); - if (!--gUnknown_03000F3C) - gUnknown_03000F44 = 0; - } - return; -} +static const struct PaletteStructTemplate gDummyPaletteStructTemplate = { + .uid = 0xFFFF, + .pst_field_B_5 = 1 +}; +static const u8 gUnknown_0852489C[] = { + 0, 0, 0, 0, 0, + 5, 5, 5, 5, 5, + 11, 11, 11, 11, 11, + 16, 16, 16, 16, 16, + 21, 21, 21, 21, 21, + 27, 27, 27, 27, 27, + 31, 31 +}; void LoadCompressedPalette(const void *src, u16 offset, u16 size) { diff --git a/src/pokemon_2.c b/src/pokemon_2.c index c3d3bf8cf..ee54f0e4d 100644 --- a/src/pokemon_2.c +++ b/src/pokemon_2.c @@ -152,8 +152,8 @@ u8 GetGenderFromSpeciesAndPersonality(u16 species, u32 personality) void sub_806A068(u16 species, u8 bankIdentity) { - if (gBattleSpritesGfx != NULL) - gUnknown_0202499C = gBattleSpritesGfx->templates[bankIdentity]; + if (gMonSpritesGfxPtr != NULL) + gUnknown_0202499C = gMonSpritesGfxPtr->templates[bankIdentity]; else if (gUnknown_020249B4[0]) gUnknown_0202499C = gUnknown_020249B4[0]->templates[bankIdentity]; else if (gUnknown_020249B4[1]) @@ -180,8 +180,8 @@ void sub_806A12C(u16 trainerSpriteId, u8 bankIdentity) } else { - if (gBattleSpritesGfx != NULL) - gUnknown_0202499C = gBattleSpritesGfx->templates[bankIdentity]; + if (gMonSpritesGfxPtr != NULL) + gUnknown_0202499C = gMonSpritesGfxPtr->templates[bankIdentity]; else gUnknown_0202499C = gUnknown_08329D98[bankIdentity]; gUnknown_0202499C.anims = gUnknown_0830536C[trainerSpriteId]; @@ -190,8 +190,8 @@ void sub_806A12C(u16 trainerSpriteId, u8 bankIdentity) void sub_806A1C0(u16 arg0, u8 bankIdentity) { - if (gBattleSpritesGfx != NULL) - gUnknown_0202499C = gBattleSpritesGfx->templates[bankIdentity]; + if (gMonSpritesGfxPtr != NULL) + gUnknown_0202499C = gMonSpritesGfxPtr->templates[bankIdentity]; else gUnknown_0202499C = gUnknown_08329D98[bankIdentity]; gUnknown_0202499C.paletteTag = arg0; diff --git a/src/pokemon_3.c b/src/pokemon_3.c index d44c0cb2f..5ff99aee2 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -486,8 +486,8 @@ u16 SpeciesToCryId(u16 species) void sub_806D544(u16 species, u32 personality, u8 *dest) { if (species == SPECIES_SPINDA - && dest != gBattleSpritesGfx->sprites[0] - && dest != gBattleSpritesGfx->sprites[2]) + && dest != gMonSpritesGfxPtr->sprites[0] + && dest != gMonSpritesGfxPtr->sprites[2]) { int i; for (i = 0; i < 4; i++) @@ -1519,8 +1519,6 @@ void BattleAnimateFrontSprite(struct Sprite* sprite, u16 species, bool8 noCry, u DoMonFrontSpriteAnimation(sprite, species, noCry, arg3); } -bool8 HasTwoFramesAnimation(u16 species); - extern void SpriteCallbackDummy_2(struct Sprite*); extern void sub_817F60C(struct Sprite*); diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c new file mode 100644 index 000000000..3e409244c --- /dev/null +++ b/src/pokemon_storage_system.c @@ -0,0 +1,15 @@ + +// Includes +#include "global.h" + +// Static type declarations + +// Static RAM declarations + +IWRAM_DATA u8 gUnknown_03000F78[0x188]; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/record_mixing.c b/src/record_mixing.c new file mode 100644 index 000000000..151835e5e --- /dev/null +++ b/src/record_mixing.c @@ -0,0 +1,28 @@ + +// Includes +#include "global.h" + +// Static type declarations + +// Static RAM declarations + +IWRAM_DATA bool8 gUnknown_03001130; +IWRAM_DATA struct SecretBaseRecord *gUnknown_03001134; +IWRAM_DATA TVShow *gUnknown_03001138; +IWRAM_DATA struct UnknownSaveStruct2ABC *gUnknown_0300113C; +IWRAM_DATA OldMan *gUnknown_03001140; +IWRAM_DATA struct EasyChatPair *gUnknown_03001144; +IWRAM_DATA struct DaycareData *gUnknown_03001148; +IWRAM_DATA void *gUnknown_0300114C; // gSaveBlock2Ptr->field_64C +IWRAM_DATA LilycoveLady *gUnknown_03001150; +IWRAM_DATA void *gUnknown_03001154; // gSaveBlock2Ptr->field_0DC; +IWRAM_DATA void *gUnknown_03001158; // gSaveBlock2Ptr->field_64C +IWRAM_DATA u32 gUnknown_0300115C; +IWRAM_DATA u8 gUnknown_03001160[8]; +IWRAM_DATA u32 gUnknown_03001168[3]; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/rom4.c b/src/rom4.c new file mode 100644 index 000000000..c538595f2 --- /dev/null +++ b/src/rom4.c @@ -0,0 +1,19 @@ + +// Includes +#include "global.h" + +// Static type declarations + +// Static RAM declarations +IWRAM_DATA void *gUnknown_03000E0C; +IWRAM_DATA u8 gUnknown_03000E10[4]; +IWRAM_DATA u8 (*gUnknown_03000E14)(u32); +IWRAM_DATA u8 gUnknown_03000E18; +IWRAM_DATA u8 gUnknown_03000E19; +IWRAM_DATA void *rom4_c_unused_03000e1c; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/save.c b/src/save.c index aee20d451..2c1b26ca9 100644 --- a/src/save.c +++ b/src/save.c @@ -15,7 +15,6 @@ extern const struct SaveSectionOffsets gSaveSectionOffsets[0xE]; extern void DoSaveFailedScreen(u8); // save_failed_screen extern void LoadSerializedGame(void); // load_save extern bool32 ProgramFlashSectorAndVerify(u8 sector, u8 *data); -extern void ReadFlash(u8 sector, u32 arg1, void* data, u32 size); // iwram common u16 gLastWrittenSector; @@ -806,7 +805,7 @@ u32 sub_81535DC(u8 sector, u8* dst) if (sector != 30 && sector != 31) return 0xFF; - ReadFlash(sector, 0, &gSaveDataBuffer, sizeof(struct SaveSection)); + ReadFlash(sector, 0, (u8 *)&gSaveDataBuffer, sizeof(struct SaveSection)); if (*(u32*)(&gSaveDataBuffer.data[0]) != 0xB39D) return 0xFF; // copies whole save section except u32 counter diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c new file mode 100755 index 000000000..3f49b89e6 --- /dev/null +++ b/src/save_failed_screen.c @@ -0,0 +1,426 @@ +#include "global.h" +#include "text.h" +#include "main.h" +#include "palette.h" +#include "gpu_regs.h" +#include "bg.h" +#include "task.h" +#include "window.h" +#include "menu.h" +#include "save.h" +#include "gba/flash_internal.h" + +#define MSG_WIN_TOP 12 +#define CLOCK_WIN_TOP (MSG_WIN_TOP - 4) + +extern void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor *color, s8 speed, u8 *str); + +extern void (*gGameContinueCallback)(void); + +extern u32 gDamagedSaveSectors; + +extern const u8 gBirchHelpGfx[]; +extern const u8 gBirchBagTilemap[]; +extern const u8 gBirchGrassTilemap[]; +extern const u16 gBirchBagGrassPal[]; +extern const u16 gUnknown_0850FEFC[]; +extern const u16 gUnknown_0860F074[]; +extern const u32 gUnknown_0850E87C[]; +extern struct SaveSection gSaveDataBuffer; + +extern u8 gText_SaveFailedCheckingBackup[]; +extern u8 gText_BackupMemoryDamaged[]; +extern u8 gText_CheckCompleted[]; +extern u8 gText_SaveCompleteGameCannotContinue[]; +extern u8 gText_SaveCompletePressA[]; +extern u8 gText_GamePlayCannotBeContinued[]; + +extern u8 gDecompressionBuffer[]; + +// gSaveFailedClockInfo enum +enum +{ + CLOCK_RUNNING, + DEBUG_TIMER +}; + +// gSaveFailedWindowIds enum +enum +{ + TEXT_WIN_ID, + CLOCK_WIN_ID +}; + +EWRAM_DATA u16 gSaveFailedType = {0}; +EWRAM_DATA u16 gSaveFailedClockInfo[2] = {0}; +EWRAM_DATA u8 gSaveFailedUnused1[12] = {0}; +EWRAM_DATA u8 gSaveFailedWindowIds[2] = {0}; +EWRAM_DATA u8 gSaveFailedUnused2[4] = {0}; + +static const struct OamData sClockOamData = +{ + 160, // Y + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0 +}; + +static const struct BgTemplate gUnknown_085EFD88[3] = +{ + { + .bg = 0, + .charBaseIndex = 2, + .mapBaseIndex = 31, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0, + }, + { + .bg = 2, + .charBaseIndex = 0, + .mapBaseIndex = 14, + .screenSize = 0, + .paletteMode = 0, + .priority = 2, + .baseTile = 0, + }, + { + .bg = 3, + .charBaseIndex = 0, + .mapBaseIndex = 15, + .screenSize = 0, + .paletteMode = 0, + .priority = 3, + .baseTile = 0, + }, +}; + +static const struct WindowTemplate gUnknown_085EFD94[] = +{ + { + .priority = 255, + .tilemapLeft = 0, + .tilemapTop = 0, + .width = 0, + .height = 0, + .paletteNum = 0, + .baseBlock = 0, + } +}; + +static const struct WindowTemplate gUnknown_085EFD9C[] = +{ + { + .priority = 0, + .tilemapLeft = 1, + .tilemapTop = 13, + .width = 28, + .height = 6, + .paletteNum = 15, + .baseBlock = 1, + } +}; + +static const struct WindowTemplate gUnknown_085EFDA4[] = +{ + { + .priority = 0, + .tilemapLeft = 14, + .tilemapTop = 9, + .width = 2, + .height = 2, + .paletteNum = 15, + .baseBlock = 169, + } +}; + +static const u8 sClockFrames[8][3] = +{ + { 1, 0, 0 }, + { 5, 0, 0 }, + { 9, 0, 0 }, + { 5, 0, 1 }, + { 1, 0, 1 }, + { 5, 1, 1 }, + { 9, 1, 0 }, + { 5, 1, 0 }, +}; + +static const u8 gSaveFailedClockPal[] = INCBIN_U8("graphics/misc/clock_small.gbapal"); +static const u8 gSaveFailedClockGfx[] = INCBIN_U8("graphics/misc/clock_small.4bpp.lz"); + +static void CB2_SaveFailedScreen(void); +static void CB2_WipeSave(void); +static void CB2_GameplayCannotBeContinued(void); +static void CB2_FadeAndReturnToTitleScreen(void); +static void CB2_ReturnToTitleScreen(void); +static void VBlankCB_UpdateClockGraphics(void); +static bool8 VerifySectorWipe(u16 sector); +static bool8 WipeSectors(u32); + +// although this is a general text printer, it's only used in this file. +static void SaveFailedScreenTextPrint(u8 *text, u8 var1, u8 var2) +{ + struct TextColor color; + + color.fgColor = 0; + color.bgColor = 15; + color.shadowColor = 3; + AddTextPrinterParametrized2(gSaveFailedWindowIds[TEXT_WIN_ID], 1, var1 * 8, var2 * 8 + 1, 0, 0, &color, 0, text); +} + +void DoSaveFailedScreen(u8 saveType) +{ + SetMainCallback2(CB2_SaveFailedScreen); + gSaveFailedType = saveType; + gSaveFailedClockInfo[CLOCK_RUNNING] = FALSE; + gSaveFailedClockInfo[DEBUG_TIMER] = 0; + gSaveFailedWindowIds[TEXT_WIN_ID] = 0; + gSaveFailedWindowIds[CLOCK_WIN_ID] = 0; +} + +static void VBlankCB(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +static void CB2_SaveFailedScreen(void) +{ + switch (gMain.state) + { + case 0: + default: + SetVBlankCallback(NULL); + SetGpuReg(REG_OFFSET_DISPCNT, 0); + SetGpuReg(REG_OFFSET_BG3CNT, 0); + SetGpuReg(REG_OFFSET_BG2CNT, 0); + SetGpuReg(REG_OFFSET_BG1CNT, 0); + SetGpuReg(REG_OFFSET_BG0CNT, 0); + SetGpuReg(REG_OFFSET_BG3HOFS, 0); + SetGpuReg(REG_OFFSET_BG3VOFS, 0); + SetGpuReg(REG_OFFSET_BG2HOFS, 0); + SetGpuReg(REG_OFFSET_BG2VOFS, 0); + SetGpuReg(REG_OFFSET_BG1HOFS, 0); + SetGpuReg(REG_OFFSET_BG1VOFS, 0); + SetGpuReg(REG_OFFSET_BG0HOFS, 0); + SetGpuReg(REG_OFFSET_BG0VOFS, 0); + // how come this doesnt use the Dma manager? + DmaFill16(3, 0, VRAM, VRAM_SIZE); + DmaFill32(3, 0, OAM, OAM_SIZE); + DmaFill16(3, 0, PLTT, PLTT_SIZE); + LZ77UnCompVram(gBirchHelpGfx, (void *)VRAM); + LZ77UnCompVram(gBirchBagTilemap, (void *)(VRAM + 0x7000)); + LZ77UnCompVram(gBirchGrassTilemap, (void *)(VRAM + 0x7800)); + LZ77UnCompVram(gSaveFailedClockGfx, (void *)(VRAM + 0x10020)); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_085EFD88, 3); + SetBgTilemapBuffer(0, (void *)&gDecompressionBuffer[0x2000]); + CpuFill32(0, &gDecompressionBuffer[0x2000], 0x800); + LoadBgTiles(0, gUnknown_0850E87C, 0x120, 0x214); + InitWindows(gUnknown_085EFD94); + // AddWindowWithoutTileMap returns a u16/integer, but the info is clobbered into a u8 here resulting in lost info. Bug? + gSaveFailedWindowIds[TEXT_WIN_ID] = AddWindowWithoutTileMap(gUnknown_085EFD9C); + SetWindowAttribute(gSaveFailedWindowIds[TEXT_WIN_ID], 7, (u32)&gDecompressionBuffer[0x2800]); + gSaveFailedWindowIds[CLOCK_WIN_ID] = AddWindowWithoutTileMap(gUnknown_085EFDA4); + SetWindowAttribute(gSaveFailedWindowIds[CLOCK_WIN_ID], 7, (u32)&gDecompressionBuffer[0x3D00]); + DeactivateAllTextPrinters(); + ResetSpriteData(); + ResetTasks(); + ResetPaletteFade(); + LoadPalette(gBirchBagGrassPal, 0, 0x40); + LoadPalette(gSaveFailedClockPal, 0x100, 0x20); + LoadPalette(gUnknown_0850FEFC, 0xE0, 0x20); + LoadPalette(gUnknown_0860F074, 0xF0, 0x20); + SetWindowBorderStyle(gSaveFailedWindowIds[TEXT_WIN_ID], FALSE, 0x214, 0xE); + SetWindowBorderStyle(gSaveFailedWindowIds[CLOCK_WIN_ID], FALSE, 0x214, 0xE); + FillWindowPixelBuffer(gSaveFailedWindowIds[CLOCK_WIN_ID], 0x11); // backwards? + FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], 0x11); + CopyWindowToVram(gSaveFailedWindowIds[CLOCK_WIN_ID], 2); // again? + CopyWindowToVram(gSaveFailedWindowIds[TEXT_WIN_ID], 1); + SaveFailedScreenTextPrint(gText_SaveFailedCheckingBackup, 1, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + EnableInterrupts(1); + SetVBlankCallback(VBlankCB); + SetGpuReg(0, 0x1040); + ShowBg(0); + ShowBg(2); + ShowBg(3); + gMain.state++; + break; + case 1: + if (!UpdatePaletteFade()) + { + SetMainCallback2(CB2_WipeSave); + SetVBlankCallback(VBlankCB_UpdateClockGraphics); + } + break; + } +} + +static void CB2_WipeSave(void) +{ + u8 wipeTries = 0; + + gSaveFailedClockInfo[CLOCK_RUNNING] = TRUE; + + while (gDamagedSaveSectors != 0 && wipeTries < 3) + { + if (WipeSectors(gDamagedSaveSectors) != FALSE) + { + FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], 0x11); + SaveFailedScreenTextPrint(gText_BackupMemoryDamaged, 1, 0); + SetMainCallback2(CB2_GameplayCannotBeContinued); + return; + } + + FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], 0x11); + SaveFailedScreenTextPrint(gText_CheckCompleted, 1, 0); + HandleSavingData(gSaveFailedType); + + if (gDamagedSaveSectors != 0) + { + FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], 0x11); + SaveFailedScreenTextPrint(gText_SaveFailedCheckingBackup, 1, 0); + } + + wipeTries++; + } + + if (wipeTries == 3) + { + FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], 0x11); + SaveFailedScreenTextPrint(gText_BackupMemoryDamaged, 1, 0); + } + else + { + FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], 0x11); + + if (gGameContinueCallback == NULL) + SaveFailedScreenTextPrint(gText_SaveCompleteGameCannotContinue, 1, 0); + else + SaveFailedScreenTextPrint(gText_SaveCompletePressA, 1, 0); + } + + SetMainCallback2(CB2_FadeAndReturnToTitleScreen); +} + +static void CB2_GameplayCannotBeContinued(void) +{ + gSaveFailedClockInfo[CLOCK_RUNNING] = FALSE; + + if (gMain.newKeys & A_BUTTON) + { + FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], 0x11); + SaveFailedScreenTextPrint(gText_GamePlayCannotBeContinued, 1, 0); + SetVBlankCallback(VBlankCB); + SetMainCallback2(CB2_FadeAndReturnToTitleScreen); + } +} + +static void CB2_FadeAndReturnToTitleScreen(void) +{ + gSaveFailedClockInfo[CLOCK_RUNNING] = FALSE; + + if (gMain.newKeys & A_BUTTON) + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + SetVBlankCallback(VBlankCB); + SetMainCallback2(CB2_ReturnToTitleScreen); + } +} + +static void CB2_ReturnToTitleScreen(void) +{ + if (!UpdatePaletteFade()) + { + if (gGameContinueCallback == NULL) // no callback exists, so do a soft reset. + { + DoSoftReset(); + } + else + { + SetMainCallback2((MainCallback)gGameContinueCallback); + gGameContinueCallback = NULL; + } + } +} + +static void VBlankCB_UpdateClockGraphics(void) +{ + unsigned int n = (gMain.vblankCounter2 >> 3) & 7; + + gMain.oamBuffer[0] = sClockOamData; + gMain.oamBuffer[0].x = 112; + gMain.oamBuffer[0].y = (CLOCK_WIN_TOP + 1) * 8;; + + if (gSaveFailedClockInfo[CLOCK_RUNNING] != FALSE) + { + gMain.oamBuffer[0].tileNum = sClockFrames[n][0]; + gMain.oamBuffer[0].matrixNum = (sClockFrames[n][2] << 4) | (sClockFrames[n][1] << 3); + } + else + { + gMain.oamBuffer[0].tileNum = 1; + } + + CpuFastCopy(gMain.oamBuffer, (void *)OAM, 4); + + if (gSaveFailedClockInfo[DEBUG_TIMER]) + gSaveFailedClockInfo[DEBUG_TIMER]--; +} + +static bool8 VerifySectorWipe(u16 sector) +{ + u32 *ptr = (u32 *)&gSaveDataBuffer; + u16 i; + + ReadFlash(sector, 0, (u8 *)ptr, 4096); + + for (i = 0; i < 0x400; i++, ptr++) + if (*ptr) + return TRUE; + + return FALSE; +} + +static bool8 WipeSector(u16 sector) +{ + u16 i, j; + bool8 failed = TRUE; + + for (i = 0; failed && i < 130; i++) + { + for (j = 0; j < 0x1000; j++) + ProgramFlashByte(sector, j, 0); + + failed = VerifySectorWipe(sector); + } + + return failed; +} + +static bool8 WipeSectors(u32 sectorBits) +{ + u16 i; + + for (i = 0; i < 0x20; i++) + if ((sectorBits & (1 << i)) && !WipeSector(i)) + sectorBits &= ~(1 << i); + + if (sectorBits == 0) + return FALSE; + else + return TRUE; +} diff --git a/src/save_location.c b/src/save_location.c new file mode 100755 index 000000000..87067e14d --- /dev/null +++ b/src/save_location.c @@ -0,0 +1,145 @@ +#include "global.h" +#include "map_constants.h" + +// used to make the list defines a little less ugly. +#define MAP(name) ((MAP_GROUP_##name << 8) + (MAP_ID_##name)) + +// specialSaveWarp flags +#define POKECENTER_SAVEWARP (1 << 1) +#define LOBBY_SAVEWARP (1 << 2) +#define UNK_SPECIAL_SAVE_WARP_FLAG_3 (1 << 3) + +static bool32 IsCurMapInLocationList(const u16 *list) +{ + u16 locSum = (gSaveBlock1Ptr->location.mapGroup << 8) + (gSaveBlock1Ptr->location.mapNum); + + // im sure it was written a different way, but for the love of christ I cant figure out how to write it different where it still matches. + if (*list != 0xFFFF) + { + u16 termValue = 0xFFFF; + const u16 *localList; + for (localList = list; *localList != termValue; localList++) + if (*localList == locSum) + return TRUE; + } + return FALSE; +} + +// TODO: Not require a packed u16 array for these lists +static const u16 gSaveLocationPokeCenterList[] = +{ + MAP(OLDALE_TOWN_POKEMON_CENTER_1F), + MAP(OLDALE_TOWN_POKEMON_CENTER_2F), + MAP(DEWFORD_TOWN_POKEMON_CENTER_1F), + MAP(DEWFORD_TOWN_POKEMON_CENTER_2F), + MAP(LAVARIDGE_TOWN_POKEMON_CENTER_1F), + MAP(LAVARIDGE_TOWN_POKEMON_CENTER_2F), + MAP(FALLARBOR_TOWN_POKEMON_CENTER_1F), + MAP(FALLARBOR_TOWN_POKEMON_CENTER_2F), + MAP(VERDANTURF_TOWN_POKEMON_CENTER_1F), + MAP(VERDANTURF_TOWN_POKEMON_CENTER_2F), + MAP(PACIFIDLOG_TOWN_POKEMON_CENTER_1F), + MAP(PACIFIDLOG_TOWN_POKEMON_CENTER_2F), + MAP(PETALBURG_CITY_POKEMON_CENTER_1F), + MAP(PETALBURG_CITY_POKEMON_CENTER_2F), + MAP(SLATEPORT_CITY_POKEMON_CENTER_1F), + MAP(SLATEPORT_CITY_POKEMON_CENTER_2F), + MAP(MAUVILLE_CITY_POKEMON_CENTER_1F), + MAP(MAUVILLE_CITY_POKEMON_CENTER_2F), + MAP(RUSTBORO_CITY_POKEMON_CENTER_1F), + MAP(RUSTBORO_CITY_POKEMON_CENTER_2F), + MAP(FORTREE_CITY_POKEMON_CENTER_1F), + MAP(FORTREE_CITY_POKEMON_CENTER_2F), + MAP(LILYCOVE_CITY_POKEMON_CENTER_1F), + MAP(LILYCOVE_CITY_POKEMON_CENTER_2F), + MAP(MOSSDEEP_CITY_POKEMON_CENTER_1F), + MAP(MOSSDEEP_CITY_POKEMON_CENTER_2F), + MAP(SOOTOPOLIS_CITY_POKEMON_CENTER_1F), + MAP(SOOTOPOLIS_CITY_POKEMON_CENTER_2F), + MAP(EVER_GRANDE_CITY_POKEMON_CENTER_1F), + MAP(EVER_GRANDE_CITY_POKEMON_CENTER_2F), + MAP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), + MAP(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), + MAP(BATTLE_FRONTIER_POKEMON_CENTER_1F), + MAP(BATTLE_FRONTIER_POKEMON_CENTER_2F), + MAP(SINGLE_BATTLE_COLOSSEUM), + MAP(TRADE_CENTER), + MAP(RECORD_CORNER), + MAP(DOUBLE_BATTLE_COLOSSEUM), + 0xFFFF, +}; + +static bool32 IsCurMapPokeCenter(void) +{ + return IsCurMapInLocationList(gSaveLocationPokeCenterList); +} + +static const u16 gSaveLocationReloadLocList[] = // there's only 1 location, and it's presumed its for the save reload feature for battle tower +{ + MAP(BATTLE_TOWER_LOBBY), + 0xFFFF, +}; + +static bool32 IsCurMapReloadLocation(void) +{ + return IsCurMapInLocationList(gSaveLocationReloadLocList); +} + +// nulled out list. unknown what this would have been +static const u16 gUnknown_0861440E[] = +{ + 0xFFFF, +}; + +bool32 sub_81AFCEC(void) +{ + return IsCurMapInLocationList(gUnknown_0861440E); +} + +static void TrySetPokeCenterWarpStatus(void) +{ + if (IsCurMapPokeCenter() == FALSE) + gSaveBlock2Ptr->specialSaveWarp &= ~(POKECENTER_SAVEWARP); + else + gSaveBlock2Ptr->specialSaveWarp |= POKECENTER_SAVEWARP; +} + +static void TrySetReloadWarpStatus(void) +{ + if (!IsCurMapReloadLocation()) + gSaveBlock2Ptr->specialSaveWarp &= ~(LOBBY_SAVEWARP); + else + gSaveBlock2Ptr->specialSaveWarp |= LOBBY_SAVEWARP; +} + +// this function definitely sets a warp status, but because the list is empty, it's unknown what this does yet. +static void sub_81AFD5C(void) +{ + if (!sub_81AFCEC()) + gSaveBlock2Ptr->specialSaveWarp &= ~(UNK_SPECIAL_SAVE_WARP_FLAG_3); + else + gSaveBlock2Ptr->specialSaveWarp |= UNK_SPECIAL_SAVE_WARP_FLAG_3; +} + +void TrySetMapSaveWarpStatus(void) +{ + TrySetPokeCenterWarpStatus(); + TrySetReloadWarpStatus(); + sub_81AFD5C(); +} + +void sub_81AFDA0(void) +{ + gSaveBlock2Ptr->field_A8 |= 0x8000; + gSaveBlock2Ptr->field_A8 |= 0x1; + gSaveBlock2Ptr->field_A8 |= 0x2; + gSaveBlock2Ptr->field_A8 |= 0x4; + gSaveBlock2Ptr->field_A8 |= 0x10; + gSaveBlock2Ptr->field_A8 |= 0x20; + gSaveBlock2Ptr->field_A8 |= 0x8; +} + +void sub_81AFDD0(void) +{ + gSaveBlock2Ptr->specialSaveWarp |= 0x80; +} diff --git a/src/scrcmd.c b/src/scrcmd.c new file mode 100644 index 000000000..b56a53caf --- /dev/null +++ b/src/scrcmd.c @@ -0,0 +1,15 @@ + +// Includes +#include "global.h" + +// Static type declarations + +// Static RAM declarations + +IWRAM_DATA u8 gUnknown_03000F30; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/script_menu.c b/src/script_menu.c new file mode 100644 index 000000000..04f1e82b7 --- /dev/null +++ b/src/script_menu.c @@ -0,0 +1,16 @@ + +// Includes +#include "global.h" + +// Static type declarations + +// Static RAM declarations + +IWRAM_DATA u8 gUnknown_03001124[6]; +IWRAM_DATA u32 filler_0300112c; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/text.c b/src/text.c index 0081a8244..7cc46cd92 100644 --- a/src/text.c +++ b/src/text.c @@ -1,9 +1,9 @@ #include "global.h" -#include "text.h" #include "main.h" #include "palette.h" #include "string_util.h" #include "window.h" +#include "text.h" extern void FillBitmapRect4Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue); extern void FillWindowPixelRect(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height); @@ -32,11 +32,7 @@ u8 gUnknown_03002FB0[0x20]; u8 gUnknown_03002FD0[0x20]; u8 gUnknown_03002FF0[0x20]; u8 gGlyphDimensions[0x2]; -struct { - u8 flag_0:1; - u8 flag_1:1; - u8 flag_2:1; -} gTextFlags; +TextFlags gTextFlags; const u8 gFontHalfRowOffsets[] = { 0x00, 0x01, 0x02, 0x00, 0x03, 0x04, 0x05, 0x03, 0x06, 0x07, 0x08, 0x06, 0x00, 0x01, 0x02, 0x00, @@ -1972,7 +1968,7 @@ bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter) } } -bool8 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter) +bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter) { bool8 result = FALSE; if (gTextFlags.flag_2 != 0) @@ -1991,9 +1987,9 @@ bool8 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter) return result; } -bool8 TextPrinterWait(struct TextPrinter *textPrinter) +bool16 TextPrinterWait(struct TextPrinter *textPrinter) { - bool8 result = FALSE; + bool16 result = FALSE; if (gTextFlags.flag_2 != 0) { result = TextPrinterWaitAutoMode(textPrinter); diff --git a/src/tileset_anims.c b/src/tileset_anims.c new file mode 100644 index 000000000..4ad787e1c --- /dev/null +++ b/src/tileset_anims.c @@ -0,0 +1,1411 @@ + +// Includes +#include "global.h" +#include "palette.h" +#include "blend_palette.h" +#include "battle_transition.h" +#include "task.h" + +// Static type declarations + +// Static RAM declarations + +static EWRAM_DATA struct { + const u16 *src; + u16 *dest; + u16 size; +} sTilesetDMA3TransferBuffer[20] = {0}; + +static u8 sTilesetDMA3TransferBufferSize; +static u16 sPrimaryTilesetCBCounter; +static u16 sPrimaryTilesetCBBufferSize; +static u16 sSecondaryTilesetCBCounter; +static u16 sSecondaryTilesetCBBufferSize; +static void (*sPrimaryTilesetCB)(u16); +static void (*sSecondaryTilesetCB)(u16); + +// Static ROM declarations + +static void cur_mapheader_run_tileset1_func(void); +static void cur_mapheader_run_tileset2_func(void); + +// .rodata + + +const u16 gUnknown_085105C4[] = INCBIN_U16("data/tilesets/primary/general/anim/0/1.4bpp"); + +const u16 gUnknown_08510644[] = INCBIN_U16("data/tilesets/primary/general/anim/0/0.4bpp"); + +const u16 gUnknown_085106C4[] = INCBIN_U16("data/tilesets/primary/general/anim/0/2.4bpp"); + +const u16 tileset_anims_space_0[16] = {}; + +const u16 *const gTilesetAnims_General0[] = { + gUnknown_08510644, + gUnknown_085105C4, + gUnknown_08510644, + gUnknown_085106C4 +}; + +const u16 gUnknown_08510774[] = INCBIN_U16("data/tilesets/primary/general/anim/1/0.4bpp"); + +const u16 gUnknown_08510B34[] = INCBIN_U16("data/tilesets/primary/general/anim/1/1.4bpp"); + +const u16 gUnknown_08510EF4[] = INCBIN_U16("data/tilesets/primary/general/anim/1/2.4bpp"); + +const u16 gUnknown_085112B4[] = INCBIN_U16("data/tilesets/primary/general/anim/1/3.4bpp"); + +const u16 gUnknown_08511674[] = INCBIN_U16("data/tilesets/primary/general/anim/1/4.4bpp"); + +const u16 gUnknown_08511A34[] = INCBIN_U16("data/tilesets/primary/general/anim/1/5.4bpp"); + +const u16 gUnknown_08511DF4[] = INCBIN_U16("data/tilesets/primary/general/anim/1/6.4bpp"); + +const u16 gUnknown_085121B4[] = INCBIN_U16("data/tilesets/primary/general/anim/1/7.4bpp"); + +const u16 *const gTilesetAnims_General1[] = { + gUnknown_08510774, + gUnknown_08510B34, + gUnknown_08510EF4, + gUnknown_085112B4, + gUnknown_08511674, + gUnknown_08511A34, + gUnknown_08511DF4, + gUnknown_085121B4 +}; + +const u16 gUnknown_08512594[] = INCBIN_U16("data/tilesets/primary/general/anim/2/0.4bpp"); + +const u16 gUnknown_085126D4[] = INCBIN_U16("data/tilesets/primary/general/anim/2/1.4bpp"); + +const u16 gUnknown_08512814[] = INCBIN_U16("data/tilesets/primary/general/anim/2/2.4bpp"); + +const u16 gUnknown_08512954[] = INCBIN_U16("data/tilesets/primary/general/anim/2/3.4bpp"); + +const u16 gUnknown_08512A94[] = INCBIN_U16("data/tilesets/primary/general/anim/2/4.4bpp"); + +const u16 gUnknown_08512BD4[] = INCBIN_U16("data/tilesets/primary/general/anim/2/5.4bpp"); + +const u16 gUnknown_08512D14[] = INCBIN_U16("data/tilesets/primary/general/anim/2/6.4bpp"); + +const u16 *const gTilesetAnims_General2[] = { + gUnknown_08512594, + gUnknown_085126D4, + gUnknown_08512814, + gUnknown_08512954, + gUnknown_08512A94, + gUnknown_08512BD4, + gUnknown_08512D14, + gUnknown_08512594 +}; + +const u16 gUnknown_08512E74[] = INCBIN_U16("data/tilesets/primary/general/anim/3/0.4bpp"); + +const u16 gUnknown_08512F34[] = INCBIN_U16("data/tilesets/primary/general/anim/3/1.4bpp"); + +const u16 gUnknown_08512FF4[] = INCBIN_U16("data/tilesets/primary/general/anim/3/2.4bpp"); + +const u16 gUnknown_085130B4[] = INCBIN_U16("data/tilesets/primary/general/anim/3/3.4bpp"); + +const u16 *const gTilesetAnims_General3[] = { + gUnknown_08512E74, + gUnknown_08512F34, + gUnknown_08512FF4, + gUnknown_085130B4 +}; + +const u16 gUnknown_08513184[] = INCBIN_U16("data/tilesets/primary/general/anim/4/0.4bpp"); + +const u16 gUnknown_085132C4[] = INCBIN_U16("data/tilesets/primary/general/anim/4/1.4bpp"); + +const u16 gUnknown_08513404[] = INCBIN_U16("data/tilesets/primary/general/anim/4/2.4bpp"); + +const u16 gUnknown_08513544[] = INCBIN_U16("data/tilesets/primary/general/anim/4/3.4bpp"); + +const u16 *const gTilesetAnims_General4[] = { + gUnknown_08513184, + gUnknown_085132C4, + gUnknown_08513404, + gUnknown_08513544 +}; + +const u16 gUnknown_08513694[] = INCBIN_U16("data/tilesets/secondary/lavaridge/anim/0.4bpp"); + +const u16 gUnknown_08513714[] = INCBIN_U16("data/tilesets/secondary/lavaridge/anim/1.4bpp"); + +const u16 gUnknown_08513794[] = INCBIN_U16("data/tilesets/secondary/lavaridge/anim/2.4bpp"); + +const u16 gUnknown_08513814[] = INCBIN_U16("data/tilesets/secondary/lavaridge/anim/3.4bpp"); + +const u16 *const gTilesetAnims_Lavaridge0[] = { + gUnknown_08513694, + gUnknown_08513714, + gUnknown_08513794, + gUnknown_08513814 +}; + +const u16 gUnknown_085138A4[] = INCBIN_U16("data/tilesets/secondary/pacifidlog/anim/0/0.4bpp"); + +const u16 gUnknown_08513C64[] = INCBIN_U16("data/tilesets/secondary/pacifidlog/anim/0/1.4bpp"); + +const u16 gUnknown_08514024[] = INCBIN_U16("data/tilesets/secondary/pacifidlog/anim/0/2.4bpp"); + +const u16 *const gTilesetAnims_Pacifidlog0[] = { + gUnknown_085138A4, + gUnknown_08513C64, + gUnknown_08514024, + gUnknown_08513C64 +}; + +const u16 gUnknown_085143F4[] = INCBIN_U16("data/tilesets/secondary/underwater/anim/0.4bpp"); + +const u16 gUnknown_08514474[] = INCBIN_U16("data/tilesets/secondary/underwater/anim/1.4bpp"); + +const u16 gUnknown_085144F4[] = INCBIN_U16("data/tilesets/secondary/underwater/anim/2.4bpp"); + +const u16 gUnknown_08514574[] = INCBIN_U16("data/tilesets/secondary/underwater/anim/3.4bpp"); + +const u16 *const gTilesetAnims_Underwater0[] = { + gUnknown_085143F4, + gUnknown_08514474, + gUnknown_085144F4, + gUnknown_08514574 +}; + +const u16 gUnknown_08514604[] = INCBIN_U16("data/tilesets/secondary/pacifidlog/anim/1/0.4bpp"); + +const u16 gUnknown_08514704[] = INCBIN_U16("data/tilesets/secondary/pacifidlog/anim/1/1.4bpp"); + +const u16 gUnknown_08514804[] = INCBIN_U16("data/tilesets/secondary/pacifidlog/anim/1/2.4bpp"); + +const u16 gUnknown_08514904[] = INCBIN_U16("data/tilesets/secondary/pacifidlog/anim/1/3.4bpp"); + +const u16 gUnknown_08514A04[] = INCBIN_U16("data/tilesets/secondary/pacifidlog/anim/1/4.4bpp"); + +const u16 gUnknown_08514B04[] = INCBIN_U16("data/tilesets/secondary/pacifidlog/anim/1/5.4bpp"); + +const u16 gUnknown_08514C04[] = INCBIN_U16("data/tilesets/secondary/pacifidlog/anim/1/6.4bpp"); + +const u16 gUnknown_08514D04[] = INCBIN_U16("data/tilesets/secondary/pacifidlog/anim/1/7.4bpp"); + +const u16 *const gTilesetAnims_Pacifidlog1[] = { + gUnknown_08514604, + gUnknown_08514704, + gUnknown_08514804, + gUnknown_08514904, + gUnknown_08514A04, + gUnknown_08514B04, + gUnknown_08514C04, + gUnknown_08514D04 +}; + +const u16 gUnknown_08514E24[] = INCBIN_U16("data/tilesets/secondary/mauville/anim/0/a/0.4bpp"); + +const u16 gUnknown_08514EA4[] = INCBIN_U16("data/tilesets/secondary/mauville/anim/0/a/1.4bpp"); + +const u16 gUnknown_08514F24[] = INCBIN_U16("data/tilesets/secondary/mauville/anim/0/a/2.4bpp"); + +const u16 gUnknown_08514FA4[] = INCBIN_U16("data/tilesets/secondary/mauville/anim/0/a/3.4bpp"); + +const u16 gUnknown_08515024[] = INCBIN_U16("data/tilesets/secondary/mauville/anim/1/a/1.4bpp"); + +const u16 gUnknown_085150A4[] = INCBIN_U16("data/tilesets/secondary/mauville/anim/0/b/0.4bpp"); + +const u16 gUnknown_08515124[] = INCBIN_U16("data/tilesets/secondary/mauville/anim/0/b/1.4bpp"); + +const u16 gUnknown_085151A4[] = INCBIN_U16("data/tilesets/secondary/mauville/anim/0/b/2.4bpp"); + +const u16 gUnknown_08515224[] = INCBIN_U16("data/tilesets/secondary/mauville/anim/0/b/3.4bpp"); + +const u16 gUnknown_085152A4[] = INCBIN_U16("data/tilesets/secondary/mauville/anim/1/b/1.4bpp"); + +const u16 tileset_anims_space_1[16] = {}; + +u16 *const gTilesetAnims_MauvilleVDests0[] = { + (u16 *)(BG_VRAM + 0x4c00), + (u16 *)(BG_VRAM + 0x4c80), + (u16 *)(BG_VRAM + 0x4d00), + (u16 *)(BG_VRAM + 0x4d80), + (u16 *)(BG_VRAM + 0x4e00), + (u16 *)(BG_VRAM + 0x4e80), + (u16 *)(BG_VRAM + 0x4f00), + (u16 *)(BG_VRAM + 0x4f80) +}; + +u16 *const gTilesetAnims_MauvilleVDests1[] = { + (u16 *)(BG_VRAM + 0x5000), + (u16 *)(BG_VRAM + 0x5080), + (u16 *)(BG_VRAM + 0x5100), + (u16 *)(BG_VRAM + 0x5180), + (u16 *)(BG_VRAM + 0x5200), + (u16 *)(BG_VRAM + 0x5280), + (u16 *)(BG_VRAM + 0x5300), + (u16 *)(BG_VRAM + 0x5380) +}; + +const u16 *const gTilesetAnims_Mauville0a[] = { + gUnknown_08514E24, + gUnknown_08514E24, + gUnknown_08514EA4, + gUnknown_08514F24, + gUnknown_08514FA4, + gUnknown_08514FA4, + gUnknown_08514FA4, + gUnknown_08514FA4, + gUnknown_08514FA4, + gUnknown_08514FA4, + gUnknown_08514F24, + gUnknown_08514EA4 +}; + +const u16 *const gTilesetAnims_Mauville0b[] = { + gUnknown_085150A4, + gUnknown_085150A4, + gUnknown_08515124, + gUnknown_085151A4, + gUnknown_08515224, + gUnknown_08515224, + gUnknown_08515224, + gUnknown_08515224, + gUnknown_08515224, + gUnknown_08515224, + gUnknown_085151A4, + gUnknown_08515124 +}; + +const u16 *const gTilesetAnims_Mauville1a[] = { + gUnknown_08514E24, + gUnknown_08514E24, + gUnknown_08515024, + gUnknown_08515024 +}; + +const u16 *const gTilesetAnims_Mauville1b[] = { + gUnknown_085150A4, + gUnknown_085150A4, + gUnknown_085152A4, + gUnknown_085152A4 +}; + +const u16 gUnknown_08515404[] = INCBIN_U16("data/tilesets/secondary/rustboro/anim/0/0.4bpp"); + +const u16 gUnknown_08515484[] = INCBIN_U16("data/tilesets/secondary/rustboro/anim/0/1.4bpp"); + +const u16 gUnknown_08515504[] = INCBIN_U16("data/tilesets/secondary/rustboro/anim/0/2.4bpp"); + +const u16 gUnknown_08515584[] = INCBIN_U16("data/tilesets/secondary/rustboro/anim/0/3.4bpp"); + +const u16 gUnknown_08515604[] = INCBIN_U16("data/tilesets/secondary/rustboro/anim/0/4.4bpp"); + +const u16 gUnknown_08515684[] = INCBIN_U16("data/tilesets/secondary/rustboro/anim/0/5.4bpp"); + +const u16 gUnknown_08515704[] = INCBIN_U16("data/tilesets/secondary/rustboro/anim/0/6.4bpp"); + +const u16 gUnknown_08515784[] = INCBIN_U16("data/tilesets/secondary/rustboro/anim/0/7.4bpp"); + +u16 *const gTilesetAnims_RustboroVDests0[] = { + (u16 *)(BG_VRAM + 0x5000), + (u16 *)(BG_VRAM + 0x5080), + (u16 *)(BG_VRAM + 0x5100), + (u16 *)(BG_VRAM + 0x5180), + (u16 *)(BG_VRAM + 0x5200), + (u16 *)(BG_VRAM + 0x5280), + (u16 *)(BG_VRAM + 0x5300), + (u16 *)(BG_VRAM + 0x5380) +}; + +const u16 *const gTilesetAnims_Rustboro0[] = { + gUnknown_08515404, + gUnknown_08515484, + gUnknown_08515504, + gUnknown_08515584, + gUnknown_08515604, + gUnknown_08515684, + gUnknown_08515704, + gUnknown_08515784 +}; + +const u16 gUnknown_08515844[] = INCBIN_U16("data/tilesets/secondary/rustboro/anim/1/0.4bpp"); + +const u16 gUnknown_085158C4[] = INCBIN_U16("data/tilesets/secondary/rustboro/anim/1/1.4bpp"); + +const u16 tileset_anims_space_2[16] = {}; + +const u16 *const gTilesetAnims_Rustboro1[] = { + gUnknown_08515844, + gUnknown_085158C4 +}; + +const u16 gUnknown_0851596C[] = INCBIN_U16("data/tilesets/secondary/cave/anim/0.4bpp"); + +const u16 gUnknown_085159EC[] = INCBIN_U16("data/tilesets/secondary/cave/anim/1.4bpp"); + +const u16 gUnknown_08515A6C[] = INCBIN_U16("data/tilesets/secondary/cave/anim/2.4bpp"); + +const u16 gUnknown_08515AEC[] = INCBIN_U16("data/tilesets/secondary/cave/anim/3.4bpp"); + +const u16 gUnknown_08515B6C[] = INCBIN_U16("data/tilesets/secondary/cave/anim/unused/0.4bpp"); + +const u16 gUnknown_08515BEC[] = INCBIN_U16("data/tilesets/secondary/cave/anim/unused/1.4bpp"); + +const u16 gUnknown_08515C6C[] = INCBIN_U16("data/tilesets/secondary/cave/anim/unused/2.4bpp"); + +const u16 gUnknown_08515CEC[] = INCBIN_U16("data/tilesets/secondary/cave/anim/unused/3.4bpp"); + +const u16 tileset_anims_space_3[16] = {}; + +const u16 *const gTilesetAnims_Lavaridge1_Cave0[] = { + gUnknown_0851596C, + gUnknown_085159EC, + gUnknown_08515A6C, + gUnknown_08515AEC +}; + +const u16 gUnknown_08515D9C[] = INCBIN_U16("data/tilesets/secondary/ever_grande/anim/0.4bpp"); + +const u16 gUnknown_08515E1C[] = INCBIN_U16("data/tilesets/secondary/ever_grande/anim/1.4bpp"); + +const u16 gUnknown_08515E9C[] = INCBIN_U16("data/tilesets/secondary/ever_grande/anim/2.4bpp"); + +const u16 gUnknown_08515F1C[] = INCBIN_U16("data/tilesets/secondary/ever_grande/anim/3.4bpp"); + +const u16 gUnknown_08515F9C[] = INCBIN_U16("data/tilesets/secondary/ever_grande/anim/4.4bpp"); + +const u16 gUnknown_0851601C[] = INCBIN_U16("data/tilesets/secondary/ever_grande/anim/5.4bpp"); + +const u16 gUnknown_0851609C[] = INCBIN_U16("data/tilesets/secondary/ever_grande/anim/6.4bpp"); + +const u16 gUnknown_0851611C[] = INCBIN_U16("data/tilesets/secondary/ever_grande/anim/7.4bpp"); + +const u16 tileset_anims_space_4[16] = {}; + +u16 *const gTilesetAnims_EverGrandeVDests0[] = { + (u16 *)(BG_VRAM + 0x5c00), + (u16 *)(BG_VRAM + 0x5c80), + (u16 *)(BG_VRAM + 0x5d00), + (u16 *)(BG_VRAM + 0x5d80), + (u16 *)(BG_VRAM + 0x5e00), + (u16 *)(BG_VRAM + 0x5e80), + (u16 *)(BG_VRAM + 0x5f00), + (u16 *)(BG_VRAM + 0x5f80) +}; + +const u16 *const gTilesetAnims_EverGrande0[] = { + gUnknown_08515D9C, + gUnknown_08515E1C, + gUnknown_08515E9C, + gUnknown_08515F1C, + gUnknown_08515F9C, + gUnknown_0851601C, + gUnknown_0851609C, + gUnknown_0851611C +}; + +const u16 gUnknown_085161FC[] = INCBIN_U16("data/tilesets/secondary/dewford/anim/0.4bpp"); + +const u16 gUnknown_085162BC[] = INCBIN_U16("data/tilesets/secondary/dewford/anim/1.4bpp"); + +const u16 gUnknown_0851637C[] = INCBIN_U16("data/tilesets/secondary/dewford/anim/2.4bpp"); + +const u16 gUnknown_0851643C[] = INCBIN_U16("data/tilesets/secondary/dewford/anim/3.4bpp"); + +const u16 *const gTilesetAnims_Dewford0[] = { + gUnknown_085161FC, + gUnknown_085162BC, + gUnknown_0851637C, + gUnknown_0851643C +}; + +const u16 gUnknown_0851650C[] = INCBIN_U16("data/tilesets/secondary/battle_frontier_outside_west/anim/0.4bpp"); + +const u16 gUnknown_085165CC[] = INCBIN_U16("data/tilesets/secondary/battle_frontier_outside_west/anim/1.4bpp"); + +const u16 gUnknown_0851668C[] = INCBIN_U16("data/tilesets/secondary/battle_frontier_outside_west/anim/2.4bpp"); + +const u16 gUnknown_0851674C[] = INCBIN_U16("data/tilesets/secondary/battle_frontier_outside_west/anim/3.4bpp"); + +const u16 *const gTilesetAnims_BattleFrontierOutsideWest0[] = { + gUnknown_0851650C, + gUnknown_085165CC, + gUnknown_0851668C, + gUnknown_0851674C +}; + +const u16 gUnknown_0851681C[] = INCBIN_U16("data/tilesets/secondary/battle_frontier_outside_east/anim/0.4bpp"); + +const u16 gUnknown_085168DC[] = INCBIN_U16("data/tilesets/secondary/battle_frontier_outside_east/anim/1.4bpp"); + +const u16 gUnknown_0851699C[] = INCBIN_U16("data/tilesets/secondary/battle_frontier_outside_east/anim/2.4bpp"); + +const u16 gUnknown_08516A5C[] = INCBIN_U16("data/tilesets/secondary/battle_frontier_outside_east/anim/3.4bpp"); + +const u16 *const gTilesetAnims_BattleFrontierOutsideEast0[] = { + gUnknown_0851681C, + gUnknown_085168DC, + gUnknown_0851699C, + gUnknown_08516A5C +}; + +const u16 gUnknown_08516B2C[] = INCBIN_U16("data/tilesets/secondary/slateport/anim/0.4bpp"); + +const u16 gUnknown_08516BAC[] = INCBIN_U16("data/tilesets/secondary/slateport/anim/1.4bpp"); + +const u16 gUnknown_08516C2C[] = INCBIN_U16("data/tilesets/secondary/slateport/anim/2.4bpp"); + +const u16 gUnknown_08516CAC[] = INCBIN_U16("data/tilesets/secondary/slateport/anim/3.4bpp"); + +const u16 *const gTilesetAnims_Slateport0[] = { + gUnknown_08516B2C, + gUnknown_08516BAC, + gUnknown_08516C2C, + gUnknown_08516CAC +}; + +const u16 gUnknown_08516D3C[] = INCBIN_U16("data/tilesets/primary/building/anim/0.4bpp"); + +const u16 gUnknown_08516DBC[] = INCBIN_U16("data/tilesets/primary/building/anim/1.4bpp"); + +const u16 *const gTilesetAnims_InsideBuilding0[] = { + gUnknown_08516D3C, + gUnknown_08516DBC +}; + +const u16 gUnknown_08516E44[] = INCBIN_U16("data/tilesets/secondary/sootopolis_gym/anim/0/0.4bpp"); + +const u16 gUnknown_08516FC4[] = INCBIN_U16("data/tilesets/secondary/sootopolis_gym/anim/0/1.4bpp"); + +const u16 gUnknown_08517144[] = INCBIN_U16("data/tilesets/secondary/sootopolis_gym/anim/0/2.4bpp"); + +const u16 gUnknown_085172C4[] = INCBIN_U16("data/tilesets/secondary/sootopolis_gym/anim/1/0.4bpp"); + +const u16 gUnknown_08517544[] = INCBIN_U16("data/tilesets/secondary/sootopolis_gym/anim/1/1.4bpp"); + +const u16 gUnknown_085177C4[] = INCBIN_U16("data/tilesets/secondary/sootopolis_gym/anim/1/2.4bpp"); + +const u16 *const gTilesetAnims_SootopolisGym0[] = { + gUnknown_08516E44, + gUnknown_08516FC4, + gUnknown_08517144 +}; + +const u16 *const gTilesetAnims_SootopolisGym1[] = { + gUnknown_085172C4, + gUnknown_08517544, + gUnknown_085177C4 +}; + +const u16 gUnknown_08517A5C[] = INCBIN_U16("data/tilesets/secondary/elite_four/anim/1/0.4bpp"); + +const u16 gUnknown_08517ADC[] = INCBIN_U16("data/tilesets/secondary/elite_four/anim/1/1.4bpp"); + +const u16 gUnknown_08517B5C[] = INCBIN_U16("data/tilesets/secondary/elite_four/anim/0/0.4bpp"); + +const u16 gUnknown_08517B7C[] = INCBIN_U16("data/tilesets/secondary/elite_four/anim/0/1.4bpp"); + +const u16 gUnknown_08517B9C[] = INCBIN_U16("data/tilesets/secondary/elite_four/anim/0/2.4bpp"); + +const u16 gUnknown_08517BBC[] = INCBIN_U16("data/tilesets/secondary/elite_four/anim/0/3.4bpp"); + +const u16 tileset_anims_space_5[16] = {}; + +const u16 *const gTilesetAnims_EliteFour1[] = { + gUnknown_08517B5C, + gUnknown_08517B7C, + gUnknown_08517B9C, + gUnknown_08517BBC +}; + +const u16 *const gTilesetAnims_EliteFour0[] = { + gUnknown_08517A5C, + gUnknown_08517ADC +}; + +const u16 gUnknown_08517C14[] = INCBIN_U16("data/tilesets/secondary/mauville_gym/anim/0.4bpp"); + +const u16 gUnknown_08517E14[] = INCBIN_U16("data/tilesets/secondary/mauville_gym/anim/1.4bpp"); + +const u16 tileset_anims_space_6[16] = {}; + +const u16 *const gTilesetAnims_MauvilleGym0[] = { + gUnknown_08517C14, + gUnknown_08517E14 +}; + +const u16 gUnknown_0851803C[] = INCBIN_U16("data/tilesets/secondary/bike_shop/anim/0.4bpp"); + +const u16 gUnknown_0851815C[] = INCBIN_U16("data/tilesets/secondary/bike_shop/anim/1.4bpp"); + +const u16 tileset_anims_space_7[16] = {}; + +const u16 *const gTilesetAnims_BikeShop0[] = { + gUnknown_0851803C, + gUnknown_0851815C +}; + +const u16 gUnknown_085182A4[] = INCBIN_U16("data/tilesets/secondary/sootopolis/anim/0.4bpp"); + +const u16 gUnknown_08518EA4[] = INCBIN_U16("data/tilesets/secondary/sootopolis/anim/1.4bpp"); + +const u16 gUnknown_08519AA4[] = INCBIN_U16("data/tilesets/secondary/sootopolis/anim/2.4bpp"); + +const u16 gUnknown_0851A6A4[] = INCBIN_U16("data/tilesets/secondary/sootopolis/anim/3.4bpp"); + +const u16 gUnknown_0851B2A4[] = INCBIN_U16("data/tilesets/secondary/sootopolis/anim/4.4bpp"); + +const u16 gUnknown_0851BEA4[] = INCBIN_U16("data/tilesets/secondary/sootopolis/anim/5.4bpp"); + +const u16 gUnknown_0851CAA4[] = INCBIN_U16("data/tilesets/secondary/sootopolis/anim/6.4bpp"); + +const u16 gUnknown_0851D6A4[] = INCBIN_U16("data/tilesets/secondary/sootopolis/anim/7.4bpp"); + +const u16 tileset_anims_space_8[16] = {}; + +const u16 gUnknown_0851E2C4[] = INCBIN_U16("data/tilesets/secondary/unused_1/0.4bpp"); + +const u16 gUnknown_0851EAC4[] = INCBIN_U16("data/tilesets/secondary/unused_1/1.4bpp"); + +const u16 gUnknown_0851F2C4[] = INCBIN_U16("data/tilesets/secondary/unused_1/2.4bpp"); + +const u16 gUnknown_0851FAC4[] = INCBIN_U16("data/tilesets/secondary/unused_1/3.4bpp"); + +const u16 *const gTilesetAnims_Sootopolis0[] = { + gUnknown_085182A4, + gUnknown_08518EA4, + gUnknown_08519AA4, + gUnknown_0851A6A4, + gUnknown_0851B2A4, + gUnknown_0851BEA4, + gUnknown_0851CAA4, + gUnknown_0851D6A4 +}; + +const u16 gUnknown_085202E4[] = INCBIN_U16("data/tilesets/secondary/battle_pyramid/anim/0/0.4bpp"); + +const u16 gUnknown_085203E4[] = INCBIN_U16("data/tilesets/secondary/battle_pyramid/anim/0/1.4bpp"); + +const u16 gUnknown_085204E4[] = INCBIN_U16("data/tilesets/secondary/battle_pyramid/anim/0/2.4bpp"); + +const u16 tileset_anims_space_9[16] = {}; + +const u16 gUnknown_08520604[] = INCBIN_U16("data/tilesets/secondary/battle_pyramid/anim/1/0.4bpp"); + +const u16 gUnknown_08520704[] = INCBIN_U16("data/tilesets/secondary/battle_pyramid/anim/1/1.4bpp"); + +const u16 gUnknown_08520804[] = INCBIN_U16("data/tilesets/secondary/battle_pyramid/anim/1/2.4bpp"); + +const u16 tileset_anims_space_10[7808] = {}; + +const u16 gUnknown_08524604[] = INCBIN_U16("data/tilesets/secondary/unused_2/0.4bpp"); + +const u16 tileset_anims_space_11[224] = {}; + +const u16 gUnknown_08524804[] = INCBIN_U16("data/tilesets/secondary/unused_2/1.4bpp"); + +const u16 *const gTilesetAnims_BattlePyramid0[] = { + gUnknown_085202E4, + gUnknown_085203E4, + gUnknown_085204E4 +}; + +const u16 *const gTilesetAnims_BattlePyramid1[] = { + gUnknown_08520604, + gUnknown_08520704, + gUnknown_08520804 +}; + +extern const u16 gUnknown_08D85640[]; +extern const u16 gUnknown_08D85660[]; +extern const u16 gUnknown_08D85680[]; +extern const u16 gUnknown_08D856A0[]; + +static const u16 *const gTilesetAnims_BattleDomePals0[] = { + gUnknown_08D85640, + gUnknown_08D85660, + gUnknown_08D85680, + gUnknown_08D856A0, +}; + +// .text + +static void ResetTilesetAnimBuffer(void) +{ + sTilesetDMA3TransferBufferSize = 0; + CpuFill32(0, sTilesetDMA3TransferBuffer, sizeof sTilesetDMA3TransferBuffer); +} + +static void AppendTilesetAnimToBuffer(const u16 *src, u16 *dest, u16 size) +{ + if (sTilesetDMA3TransferBufferSize < 20) + { + sTilesetDMA3TransferBuffer[sTilesetDMA3TransferBufferSize].src = src; + sTilesetDMA3TransferBuffer[sTilesetDMA3TransferBufferSize].dest = dest; + sTilesetDMA3TransferBuffer[sTilesetDMA3TransferBufferSize].size = size; + sTilesetDMA3TransferBufferSize ++; + } +} + +void TransferTilesetAnimsBuffer(void) +{ + int i; + + for (i = 0; i < sTilesetDMA3TransferBufferSize; i ++) + { + DmaCopy16(3, sTilesetDMA3TransferBuffer[i].src, sTilesetDMA3TransferBuffer[i].dest, sTilesetDMA3TransferBuffer[i].size); + } + sTilesetDMA3TransferBufferSize = 0; +} + +void cur_mapheader_run_tileset_funcs_after_some_cpuset(void) +{ + ResetTilesetAnimBuffer(); + cur_mapheader_run_tileset1_func(); + cur_mapheader_run_tileset2_func(); +} + +void sub_80A0A2C(void) +{ + cur_mapheader_run_tileset2_func(); +} + +void sub_80A0A38(void) +{ + ResetTilesetAnimBuffer(); + if (++sPrimaryTilesetCBCounter >= sPrimaryTilesetCBBufferSize) + sPrimaryTilesetCBCounter = 0; + if (++sSecondaryTilesetCBCounter >= sSecondaryTilesetCBBufferSize) + sSecondaryTilesetCBCounter = 0; + if (sPrimaryTilesetCB) + sPrimaryTilesetCB(sPrimaryTilesetCBCounter); + if (sSecondaryTilesetCB) + sSecondaryTilesetCB(sSecondaryTilesetCBCounter); +} + +static void cur_mapheader_run_tileset1_func(void) +{ + sPrimaryTilesetCBCounter = 0; + sPrimaryTilesetCBBufferSize = 0; + sPrimaryTilesetCB = NULL; + if (gMapHeader.mapData->primaryTileset && gMapHeader.mapData->primaryTileset->callback) + gMapHeader.mapData->primaryTileset->callback(); +} + +static void cur_mapheader_run_tileset2_func(void) +{ + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = 0; + sSecondaryTilesetCB = NULL; + if (gMapHeader.mapData->secondaryTileset && gMapHeader.mapData->secondaryTileset->callback) + gMapHeader.mapData->secondaryTileset->callback(); +} + +void TilesetCb_General(void) +{ + static void sub_80A0B70(u16); + + sPrimaryTilesetCBCounter = 0; + sPrimaryTilesetCBBufferSize = 0x100; + sPrimaryTilesetCB = sub_80A0B70; +} + +void TilesetCb_InsideBuilding(void) +{ + static void sub_80A0BB4(u16); + + sPrimaryTilesetCBCounter = 0; + sPrimaryTilesetCBBufferSize = 0x100; + sPrimaryTilesetCB = sub_80A0BB4; +} + +static void sub_80A0B70(u16 timer) +{ + static void sub_80A0BCC(u16); + static void sub_80A0BF4(u16); + static void sub_80A0C1C(u16); + static void sub_80A0C44(u16); + static void sub_80A12AC(u16); + + if ((timer & 0x0F) == 0) + sub_80A0BCC(timer >> 4); + if ((timer & 0x0F) == 1) + sub_80A0BF4(timer >> 4); + if ((timer & 0x0F) == 2) + sub_80A0C1C(timer >> 4); + if ((timer & 0x0F) == 3) + sub_80A0C44(timer >> 4); + if ((timer & 0x0F) == 4) + sub_80A12AC(timer >> 4); +} + +static void sub_80A0BB4(u16 timer) +{ + static void sub_80A1688(u16); + + if ((timer & 0x7) == 0) + sub_80A1688(timer >> 3); +} + +static void sub_80A0BCC(u16 timer) +{ + u16 idx; + + idx = timer % 4; + AppendTilesetAnimToBuffer(gTilesetAnims_General0[idx], (u16 *)(BG_VRAM + 0x3F80), 0x80); +} + +static void sub_80A0BF4(u16 timer) +{ + u8 idx; + + idx = timer % 8; + AppendTilesetAnimToBuffer(gTilesetAnims_General1[idx], (u16 *)(BG_VRAM + 0x3600), 0x3C0); +} + +static void sub_80A0C1C(u16 timer) +{ + u16 idx; + + idx = timer % 8; + AppendTilesetAnimToBuffer(gTilesetAnims_General2[idx], (u16 *)(BG_VRAM + 0x3a00), 0x140); +} + +static void sub_80A0C44(u16 timer) +{ + u16 idx; + + idx = timer % 4; + AppendTilesetAnimToBuffer(gTilesetAnims_General3[idx], (u16 *)(BG_VRAM + 0x3e00), 0xc0); +} + +void TilesetCb_Petalburg(void) +{ + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = NULL; +} + +void TilesetCb_Rustboro(void) +{ + static void sub_80A103C(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A103C; +} + +void TilesetCb_Dewford(void) +{ + static void sub_80A10B8(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A10B8; +} + +void TilesetCb_Slateport(void) +{ + static void sub_80A10D0(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A10D0; +} + +void TilesetCb_Mauville(void) +{ + static void sub_80A10E8(u16); + + sSecondaryTilesetCBCounter = sPrimaryTilesetCBCounter; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A10E8; +} + +void TilesetCb_Lavaridge(void) +{ + static void sub_80A115C(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A115C; +} + +void TilesetCb_Fallarbor(void) +{ + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = NULL; +} + +void TilesetCb_Fortree(void) +{ + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = NULL; +} + +void TilesetCb_Lilycove(void) +{ + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = NULL; +} + +void TilesetCb_Mossdeep(void) +{ + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = NULL; +} + +void TilesetCb_EverGrande(void) +{ + static void sub_80A1188(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A1188; +} + +void TilesetCb_Pacifidlog(void) +{ + static void sub_80A11FC(u16); + + sSecondaryTilesetCBCounter = sPrimaryTilesetCBCounter; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A11FC; +} + +void TilesetCb_Sootopolis(void) +{ + static void sub_80A122C(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A122C; +} + +void TilesetCb_BattleFrontierOutsideWest(void) +{ + static void sub_80A127C(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A127C; +} + +void TilesetCb_BattleFrontierOutsideEast(void) +{ + static void sub_80A1294(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A1294; +} + +void TilesetCb_Underwater(void) +{ + static void sub_80A1244(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = 128; + sSecondaryTilesetCB = sub_80A1244; +} + +void TilesetCb_SootopolisGym(void) +{ + static void sub_80A15D8(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = 240; + sSecondaryTilesetCB = sub_80A15D8; +} + +void TilesetCb_Cave(void) +{ + static void sub_80A1260(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A1260; +} + +void TilesetCb_EliteFour(void) +{ + static void sub_80A15F0(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = 128; + sSecondaryTilesetCB = sub_80A15F0; +} + +void TilesetCb_MauvilleGym(void) +{ + static void sub_80A15C0(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A15C0; +} + +void TilesetCb_BikeShop(void) +{ + static void sub_80A161C(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A161C; +} + +void TilesetCb_BattlePyramid(void) +{ + static void sub_80A1634(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A1634; +} + +void TilesetCb_BattleDome(void) +{ + static void sub_80A1658(u16); + + sSecondaryTilesetCBCounter = 0; + sSecondaryTilesetCBBufferSize = sPrimaryTilesetCBBufferSize; + sSecondaryTilesetCB = sub_80A1658; +} + +static void sub_80A103C(u16 timer) +{ + static void sub_80A1434(u16, u8); + static void sub_80A1470(u16); + + if ((timer & 0x07) == 0) + { + sub_80A1434(timer >> 3, 0); + sub_80A1470(timer >> 3); + } + if ((timer & 0x07) == 1) + sub_80A1434(timer >> 3, 1); + if ((timer & 0x07) == 2) + sub_80A1434(timer >> 3, 2); + if ((timer & 0x07) == 3) + sub_80A1434(timer >> 3, 3); + if ((timer & 0x07) == 4) + sub_80A1434(timer >> 3, 4); + if ((timer & 0x07) == 5) + sub_80A1434(timer >> 3, 5); + if ((timer & 0x07) == 6) + sub_80A1434(timer >> 3, 6); + if ((timer & 0x07) == 7) + sub_80A1434(timer >> 3, 7); +} + +static void sub_80A10B8(u16 timer) +{ + static void sub_80A1520(u16); + + if ((timer & 7) == 0) + sub_80A1520(timer >> 3); +} + +static void sub_80A10D0(u16 timer) +{ + static void sub_80A1598(u16); + + if ((timer & 15) == 0) + sub_80A1598(timer >> 4); +} + +static void sub_80A10E8(u16 timer) +{ + static void sub_80A1394(u16, u8); + + if ((timer & 0x07) == 0) + sub_80A1394(timer >> 3, 0); + if ((timer & 0x07) == 1) + sub_80A1394(timer >> 3, 1); + if ((timer & 0x07) == 2) + sub_80A1394(timer >> 3, 2); + if ((timer & 0x07) == 3) + sub_80A1394(timer >> 3, 3); + if ((timer & 0x07) == 4) + sub_80A1394(timer >> 3, 4); + if ((timer & 0x07) == 5) + sub_80A1394(timer >> 3, 5); + if ((timer & 0x07) == 6) + sub_80A1394(timer >> 3, 6); + if ((timer & 0x07) == 7) + sub_80A1394(timer >> 3, 7); +} + +static void sub_80A115C(u16 timer) +{ + static void sub_80A12D4(u8); + static void sub_80A1498(u16); + + if ((timer & 0x0F) == 0) + sub_80A12D4(timer >> 4); + if ((timer & 0x0F) == 1) + sub_80A1498(timer >> 4); +} + +static void sub_80A1188(u16 timer) +{ + static void sub_80A14C0(u16, u8); + + if ((timer & 0x07) == 0) + sub_80A14C0(timer >> 3, 0); + if ((timer & 0x07) == 1) + sub_80A14C0(timer >> 3, 1); + if ((timer & 0x07) == 2) + sub_80A14C0(timer >> 3, 2); + if ((timer & 0x07) == 3) + sub_80A14C0(timer >> 3, 3); + if ((timer & 0x07) == 4) + sub_80A14C0(timer >> 3, 4); + if ((timer & 0x07) == 5) + sub_80A14C0(timer >> 3, 5); + if ((timer & 0x07) == 6) + sub_80A14C0(timer >> 3, 6); + if ((timer & 0x07) == 7) + sub_80A14C0(timer >> 3, 7); +} + +static void sub_80A11FC(u16 timer) +{ + static void sub_80A131C(u8); + static void sub_80A136C(u8); + + if ((timer & 0x0F) == 0) + sub_80A131C(timer >> 4); + if ((timer & 0x0F) == 1) + sub_80A136C(timer >> 4); +} + +static void sub_80A122C(u16 timer) +{ + static void sub_80A1798(u16); + + if ((timer & 0x0F) == 0) + sub_80A1798(timer >> 4); +} + +static void sub_80A1244(u16 timer) +{ + static void sub_80A1344(u8); + + if ((timer & 0x0F) == 0) + sub_80A1344(timer >> 4); +} + +static void sub_80A1260(u16 timer) +{ + static void sub_80A14F8(u16); + + if ((timer & 0x0F) == 1) + sub_80A14F8(timer >> 4); +} + +static void sub_80A127C(u16 timer) +{ + static void sub_80A1548(u16); + + if ((timer & 0x07) == 0) + sub_80A1548(timer >> 3); +} + +static void sub_80A1294(u16 timer) +{ + static void sub_80A1570(u16); + + if ((timer & 0x07) == 0) + sub_80A1570(timer >> 3); +} + +static void sub_80A12AC(u16 timer) +{ + u16 idx; + + idx = timer % 4; + AppendTilesetAnimToBuffer(gTilesetAnims_General4[idx], (u16 *)(BG_VRAM + 0x3c00), 0x140); +} + +static void sub_80A12D4(u8 timer) +{ + u8 idx; + + idx = timer % 4; + AppendTilesetAnimToBuffer(gTilesetAnims_Lavaridge0[idx], (u16 *)(BG_VRAM + 0x6400), 0x80); + + idx = (timer + 2) % 4; + AppendTilesetAnimToBuffer(gTilesetAnims_Lavaridge0[idx], (u16 *)(BG_VRAM + 0x6480), 0x80); +} + +static void sub_80A131C(u8 timer) +{ + u8 idx; + + idx = timer % 4; + AppendTilesetAnimToBuffer(gTilesetAnims_Pacifidlog0[idx], (u16 *)(BG_VRAM + 0x7a00), 0x3C0); +} + +static void sub_80A1344(u8 timer) +{ + u8 idx; + + idx = timer % 4; + AppendTilesetAnimToBuffer(gTilesetAnims_Underwater0[idx], (u16 *)(BG_VRAM + 0x7e00), 0x80); +} + +static void sub_80A136C(u8 timer) +{ + u8 idx; + + idx = timer % 8; + AppendTilesetAnimToBuffer(gTilesetAnims_Pacifidlog1[idx], (u16 *)(BG_VRAM + 0x7e00), 0x100); +} + +static void sub_80A1394(u16 timer_div, u8 timer_mod) +{ + timer_div -= timer_mod; + if (timer_div < 12) // almost certainly a typo + { + timer_div %= 12; + AppendTilesetAnimToBuffer(gTilesetAnims_Mauville0a[timer_div], gTilesetAnims_MauvilleVDests0[timer_mod], 0x80); + AppendTilesetAnimToBuffer(gTilesetAnims_Mauville0b[timer_div], gTilesetAnims_MauvilleVDests1[timer_mod], 0x80); + } + else + { + timer_div %= 4; + AppendTilesetAnimToBuffer(gTilesetAnims_Mauville1a[timer_div], gTilesetAnims_MauvilleVDests0[timer_mod], 0x80); + AppendTilesetAnimToBuffer(gTilesetAnims_Mauville1b[timer_div], gTilesetAnims_MauvilleVDests1[timer_mod], 0x80); + } +} + +static void sub_80A1434(u16 timer_div, u8 timer_mod) +{ + timer_div -= timer_mod; + timer_div %= 8; + if (gTilesetAnims_Rustboro0[timer_div]) + AppendTilesetAnimToBuffer(gTilesetAnims_Rustboro0[timer_div], gTilesetAnims_RustboroVDests0[timer_mod], 0x80); +} + +static void sub_80A1470(u16 timer) +{ + u16 idx; + + idx = timer % 2; + AppendTilesetAnimToBuffer(gTilesetAnims_Rustboro1[idx], (u16 *)(BG_VRAM + 0x7800), 0x80); +} + +static void sub_80A1498(u16 timer) +{ + u16 idx; + + idx = timer % 4; + AppendTilesetAnimToBuffer(gTilesetAnims_Lavaridge1_Cave0[idx], (u16 *)(BG_VRAM + 0x5400), 0x80); +} + +static void sub_80A14C0(u16 timer_div, u8 timer_mod) +{ + timer_div -= timer_mod; + timer_div %= 8; + + AppendTilesetAnimToBuffer(gTilesetAnims_EverGrande0[timer_div], gTilesetAnims_EverGrandeVDests0[timer_mod], 0x80); +} + +static void sub_80A14F8(u16 timer) +{ + u16 idx; + + idx = timer % 4; + AppendTilesetAnimToBuffer(gTilesetAnims_Lavaridge1_Cave0[idx], (u16 *)(BG_VRAM + 0x7400), 0x80); +} + +static void sub_80A1520(u16 timer) +{ + u16 idx; + + idx = timer % 4; + AppendTilesetAnimToBuffer(gTilesetAnims_Dewford0[idx], (u16 *)(BG_VRAM + 0x5540), 0xC0); +} + +static void sub_80A1548(u16 timer) +{ + u16 idx; + + idx = timer % 4; + AppendTilesetAnimToBuffer(gTilesetAnims_BattleFrontierOutsideWest0[idx], (u16 *)(BG_VRAM + 0x5b40), 0xC0); +} + +static void sub_80A1570(u16 timer) +{ + u16 idx; + + idx = timer % 4; + AppendTilesetAnimToBuffer(gTilesetAnims_BattleFrontierOutsideEast0[idx], (u16 *)(BG_VRAM + 0x5b40), 0xC0); +} + +static void sub_80A1598(u16 timer) +{ + u16 idx; + + idx = timer % 4; + AppendTilesetAnimToBuffer(gTilesetAnims_Slateport0[idx], (u16 *)(BG_VRAM + 0x5c00), 0x80); +} + +static void sub_80A15C0(u16 timer) +{ + static void sub_80A1748(u16); + + if ((timer & 1) == 0) + sub_80A1748(timer >> 1); +} + +static void sub_80A15D8(u16 timer) +{ + static void sub_80A16B0(u16); + + if ((timer & 7) == 0) + sub_80A16B0(timer >> 3); +} + +static void sub_80A15F0(u16 timer) +{ + static void sub_80A1720(u16); + static void sub_80A16F8(u16); + + if ((timer & 0x3f) == 1) + sub_80A1720(timer >> 6); + if ((timer & 0x07) == 1) + sub_80A16F8(timer >> 3); +} +static void sub_80A161C(u16 timer) +{ + static void sub_80A1770(u16); + + if ((timer & 3) == 0) + sub_80A1770(timer >> 2); +} + +static void sub_80A1634(u16 timer) +{ + static void sub_80A17C0(u16); + static void sub_80A17EC(u16); + + if ((timer & 7) == 0) + { + sub_80A17C0(timer >> 3); + sub_80A17EC(timer >> 3); + } +} + +static void sub_80A1658(u16 timer) +{ + static void sub_80A1818(u16); + + if ((timer & 3) == 0) + sub_80A1818(timer >> 2); +} + +static void sub_80A1670(u16 timer) +{ + static void sub_80A1884(u16); + + if ((timer & 3) == 0) + sub_80A1884(timer >> 2); +} + +static void sub_80A1688(u16 timer) +{ + u16 idx; + + idx = timer % 2; + AppendTilesetAnimToBuffer(gTilesetAnims_InsideBuilding0[idx], (u16 *)(BG_VRAM + 0x3e00), 0x80); +} + +static void sub_80A16B0(u16 timer) +{ + u16 idx; + + idx = timer % 3; + AppendTilesetAnimToBuffer(gTilesetAnims_SootopolisGym0[idx], (u16 *)(BG_VRAM + 0x7e00), 0x180); + AppendTilesetAnimToBuffer(gTilesetAnims_SootopolisGym1[idx], (u16 *)(BG_VRAM + 0x7a00), 0x280); +} + +static void sub_80A16F8(u16 timer) +{ + u16 idx; + + idx = timer % 4; + AppendTilesetAnimToBuffer(gTilesetAnims_EliteFour1[idx], (u16 *)(BG_VRAM + 0x7f00), 0x20); +} + +static void sub_80A1720(u16 timer) +{ + u16 idx; + + idx = timer % 2; + AppendTilesetAnimToBuffer(gTilesetAnims_EliteFour0[idx], (u16 *)(BG_VRAM + 0x7c00), 0x80); +} + +static void sub_80A1748(u16 timer) +{ + u16 idx; + + idx = timer % 2; + AppendTilesetAnimToBuffer(gTilesetAnims_MauvilleGym0[idx], (u16 *)(BG_VRAM + 0x5200), 0x200); +} + +static void sub_80A1770(u16 timer) +{ + u16 idx; + + idx = timer % 2; + AppendTilesetAnimToBuffer(gTilesetAnims_BikeShop0[idx], (u16 *)(BG_VRAM + 0x7e00), 0x120); +} + +static void sub_80A1798(u16 timer) +{ + u16 idx; + + idx = timer % 8; + AppendTilesetAnimToBuffer(gTilesetAnims_Sootopolis0[idx], (u16 *)(BG_VRAM + 0x5e00), 0xc00); +} + +static void sub_80A17C0(u16 timer) +{ + u16 idx; + + idx = timer % 3; + AppendTilesetAnimToBuffer(gTilesetAnims_BattlePyramid0[idx], (u16 *)(BG_VRAM + 0x52e0), 0x100); +} + +static void sub_80A17EC(u16 timer) +{ + u16 idx; + + idx = timer % 3; + AppendTilesetAnimToBuffer(gTilesetAnims_BattlePyramid1[idx], (u16 *)(BG_VRAM + 0x50e0), 0x100); +} + +static void sub_80A1818(u16 a1) +{ + CpuCopy16(gTilesetAnims_BattleDomePals0[a1 & 0x3], gPlttBufferUnfaded + 0x80, 32); + BlendPalette(0x80, 0x10, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF); + if ((u8)FindTaskIdByFunc(sub_8149DFC) != 0xFF ) + { + sSecondaryTilesetCB = sub_80A1670; + sSecondaryTilesetCBBufferSize = 0x20; + } +} + +static void sub_80A1884(u16 a1) +{ + CpuCopy16(gTilesetAnims_BattleDomePals0[a1 & 0x3], gPlttBufferUnfaded + 0x80, 32); + if ((u8)FindTaskIdByFunc(sub_8149DFC) == 0xFF ) + { + BlendPalette(0x80, 0x10, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF); + if (!--sSecondaryTilesetCBBufferSize) + sSecondaryTilesetCB = NULL; + } +} diff --git a/src/unk_text_util_2.c b/src/unk_text_util_2.c new file mode 100644 index 000000000..d88af611f --- /dev/null +++ b/src/unk_text_util_2.c @@ -0,0 +1,219 @@ +#include "global.h" +#include "main.h" +#include "window.h" +#include "text.h" +#include "sound.h" + +static const u8 gUnknown_08616124[] = {1, 2, 4}; +static const u16 gFont6BrailleGlyphs[] = INCBIN_U16("data/graphics/fonts/font6.fwjpnfont"); + +static void DecompressGlyphFont6(u16); + +u16 Font6Func(struct TextPrinter *textPrinter) +{ + u16 char_; + struct TextPrinterSubStruct *sub; + + sub = &textPrinter->sub_union.sub; + switch (textPrinter->state) + { + case 0: + if (gMain.heldKeys & (A_BUTTON | B_BUTTON) && sub->font_type_upper) + { + textPrinter->delayCounter = 0; + } + if (textPrinter->delayCounter && textPrinter->text_speed) + { + textPrinter->delayCounter --; + if (gTextFlags.flag_0 && gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + sub->font_type_upper = TRUE; + textPrinter->delayCounter = 0; + } + return 3; + } + if (gTextFlags.flag_2) + { + textPrinter->delayCounter = 3; + } + else + { + textPrinter->delayCounter = textPrinter->text_speed; + } + char_ = *textPrinter->subPrinter.current_text_offset ++; + switch (char_) + { + case EOS: + return 1; + case CHAR_NEWLINE: + textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; + textPrinter->subPrinter.currentY += gFonts[textPrinter->subPrinter.fontId].maxLetterHeight + textPrinter->subPrinter.lineSpacing; + return 2; + case PLACEHOLDER_BEGIN: + textPrinter->subPrinter.current_text_offset ++; + return 2; + case EXT_CTRL_CODE_BEGIN: + char_ = *textPrinter->subPrinter.current_text_offset ++; + switch (char_) + { + case 1: + textPrinter->subPrinter.fontColor_h = *textPrinter->subPrinter.current_text_offset ++; + GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + return 2; + case 2: + textPrinter->subPrinter.bgColor = *textPrinter->subPrinter.current_text_offset ++; + GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + return 2; + case 3: + textPrinter->subPrinter.shadowColor = *textPrinter->subPrinter.current_text_offset ++; + GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + return 2; + case 4: + textPrinter->subPrinter.fontColor_h = *textPrinter->subPrinter.current_text_offset; + textPrinter->subPrinter.bgColor = *++ textPrinter->subPrinter.current_text_offset; + textPrinter->subPrinter.shadowColor = *++ textPrinter->subPrinter.current_text_offset; + textPrinter->subPrinter.current_text_offset ++; + + GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + return 2; + case 5: + textPrinter->subPrinter.current_text_offset ++; + return 2; + case 6: + sub->font_type = *textPrinter->subPrinter.current_text_offset; + textPrinter->subPrinter.current_text_offset ++; + return 2; + case 7: + return 2; + case 8: + textPrinter->delayCounter = *textPrinter->subPrinter.current_text_offset ++; + textPrinter->state = 6; + return 2; + case 9: + textPrinter->state = 1; + if (gTextFlags.flag_2) + { + sub->frames_visible_counter = 0; + } + return 3; + case 10: + textPrinter->state = 5; + return 3; + case 11: + case 16: + textPrinter->subPrinter.current_text_offset += 2; + return 2; + case 12: + char_ = *++textPrinter->subPrinter.current_text_offset; + break; + case 13: + textPrinter->subPrinter.currentX = textPrinter->subPrinter.x + *textPrinter->subPrinter.current_text_offset ++; + return 2; + case 14: + textPrinter->subPrinter.currentY = textPrinter->subPrinter.y + *textPrinter->subPrinter.current_text_offset ++; + return 2; + case 15: + FillWindowPixelBuffer(textPrinter->subPrinter.windowId, textPrinter->subPrinter.bgColor | (textPrinter->subPrinter.bgColor << 4)); + return 2; + } + break; + case CHAR_PROMPT_CLEAR: + textPrinter->state = 2; + TextPrinterInitDownArrowCounters(textPrinter); + return 3; + case CHAR_PROMPT_SCROLL: + textPrinter->state = 3; + TextPrinterInitDownArrowCounters(textPrinter); + return 3; + case 0xF9: + char_ = *textPrinter->subPrinter.current_text_offset ++ | 0x100; + break; + case 0xF8: + textPrinter->subPrinter.current_text_offset ++; + return 0; + } + DecompressGlyphFont6(char_); + CopyGlyphToWindow(textPrinter); + textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80] + textPrinter->subPrinter.letterSpacing; + return 0; + case 1: + if (TextPrinterWait(textPrinter)) + { + textPrinter->state = 0; + } + return 3; + case 2: + if (TextPrinterWaitWithDownArrow(textPrinter)) + { + FillWindowPixelBuffer(textPrinter->subPrinter.windowId, textPrinter->subPrinter.bgColor | (textPrinter->subPrinter.bgColor << 4)); + textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; + textPrinter->subPrinter.currentY = textPrinter->subPrinter.y; + textPrinter->state = 0; + } + return 3; + case 3: + if (TextPrinterWaitWithDownArrow(textPrinter)) + { + TextPrinterClearDownArrow(textPrinter); + textPrinter->scrollDistance = gFonts[textPrinter->subPrinter.fontId].maxLetterHeight + textPrinter->subPrinter.lineSpacing; + textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; + textPrinter->state = 4; + } + return 3; + case 4: + if (textPrinter->scrollDistance) + { + if (textPrinter->scrollDistance < gUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed]) + { + ScrollWindow(textPrinter->subPrinter.windowId, 0, textPrinter->scrollDistance, textPrinter->subPrinter.bgColor | (textPrinter->subPrinter.bgColor << 4)); + textPrinter->scrollDistance = 0; + } + else + { + ScrollWindow(textPrinter->subPrinter.windowId, 0, gUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed], textPrinter->subPrinter.bgColor | (textPrinter->subPrinter.bgColor << 4)); + textPrinter->scrollDistance -= gUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed]; + } + CopyWindowToVram(textPrinter->subPrinter.windowId, 2); + } + else + { + textPrinter->state = 0; + } + return 3; + case 5: + if (!IsSEPlaying()) + { + textPrinter->state = 0; + } + return 3; + case 6: + if (textPrinter->delayCounter) + { + textPrinter->delayCounter --; + } + else + { + textPrinter->state = 0; + } + return 3; + } + return 1; +} + +static void DecompressGlyphFont6(u16 glyph) +{ + const u16 *glyphs; + + glyphs = gFont6BrailleGlyphs + 0x100 * (glyph / 8) + 0x10 * (glyph % 8); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90 + 0x20)); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90 + 0x40)); + DecompressGlyphTile(glyphs + 0x88, (u16 *)(gUnknown_03002F90 + 0x60)); + gUnknown_03002F90[0x80] = 0x10; + gUnknown_03002F90[0x81] = 0x10; +} + +u8 GetGlyphWidthFont6(void) +{ + return 0x10; +} diff --git a/src/window.c b/src/window.c index 704060b9d..f4cb48ec0 100644 --- a/src/window.c +++ b/src/window.c @@ -190,7 +190,7 @@ u16 AddWindow(const struct WindowTemplate *template) return win; } -int AddWindowWithoutTileMap(struct WindowTemplate *template) +int AddWindowWithoutTileMap(const struct WindowTemplate *template) { u16 win; u8 bgLayer; diff --git a/sym_bss.txt b/sym_bss.txt index aacfa59a0..f32300b15 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -1,262 +1,30 @@ -gUnknown_03000000: @ 3000000 - .space 0x4 - + .include "src/main.o" .include "src/malloc.o" - - .align 4 -gDma3Requests: @ 3000010 - .space 0xC - -gUnknown_0300001C: @ 300001C - .space 0xD4 - -gUnknown_030000F0: @ 30000F0 - .space 0xA - -gUnknown_030000FA: @ 30000FA - .space 0x716 - -gDma3ManagerLocked: @ 3000810 - .space 0x1 - -gDma3RequestCursor: @ 3000811 - .space 0x7 - + .include "src/dma3_manager.o" .include "src/gpu_regs.o" .include "src/bg.o" .include "src/text.o" .include "src/sprite.o" - -gUnknown_03000D10: @ 3000D10 - .space 0x10 - -gUnknown_03000D20: @ 3000D20 - .space 0x30 - -gUnknown_03000D50: @ 3000D50 - .space 0x4 - -gUnknown_03000D54: @ 3000D54 - .space 0x4 - -gUnknown_03000D58: @ 3000D58 - .space 0x4 - -gUnknown_03000D5C: @ 3000D5C - .space 0x4 - -gUnknown_03000D60: @ 3000D60 - .space 0x4 - -gUnknown_03000D64: @ 3000D64 - .space 0x4 - -gUnknown_03000D68: @ 3000D68 - .space 0x4 - -gUnknown_03000D6C: @ 3000D6C - .space 0x1 - -gUnknown_03000D6D: @ 3000D6D - .space 0x1 - -gUnknown_03000D6E: @ 3000D6E - .space 0x2 - -gUnknown_03000D70: @ 3000D70 - .space 0x2 - -gUnknown_03000D72: @ 3000D72 - .space 0x1 - -gUnknown_03000D73: @ 3000D73 - .space 0x1 - -gUnknown_03000D74: @ 3000D74 - .space 0x4 - -gUnknown_03000D78: @ 3000D78 - .space 0x8 - -gUnknown_03000D80: @ 3000D80 - .space 0x10 - -gUnknown_03000D90: @ 3000D90 - .space 0x10 - -gUnknown_03000DA0: @ 3000DA0 - .space 0x4 - -gUnknown_03000DA4: @ 3000DA4 - .space 0x4 - -gUnknown_03000DA8: @ 3000DA8 - .space 0x4 - -gUnknown_03000DAC: @ 3000DAC - .space 0x4 - -gUnknown_03000DB0: @ 3000DB0 - .space 0x8 - + .include "src/link.o" .include "src/rtc.o" - -gUnknown_03000DD0: @ 3000DD0 - .space 0x4 - -gUnknown_03000DD4: @ 3000DD4 - .space 0x4 - -gUnknown_03000DD8: @ 3000DD8 - .space 0x4 - -gUnknown_03000DDC: @ 3000DDC - .space 0x4 - + .include "src/main_menu.o" + .include "src/battle_1.o" .include "src/egg_hatch.o" - -.space 0x4 @ why the gap? - -gUnknown_03000DE8: @ 3000DE8 - .space 0x10 - -gUnknown_03000DF8: @ 3000DF8 - .space 0xC - -gUnknown_03000E04: @ 3000E04 - .space 0x2 - -gUnknown_03000E06: @ 3000E06 - .space 0x2 - + .include "src/berry_blender.o" .include "src/play_time.o" - -.align 2 - -gUnknown_03000E0C: @ 3000E0C - .space 0x4 - -gUnknown_03000E10: @ 3000E10 - .space 0x4 - -gUnknown_03000E14: @ 3000E14 - .space 0x4 - -gUnknown_03000E18: @ 3000E18 - .space 0x1 - -gUnknown_03000E19: @ 3000E19 - .space 0x7 - -gUnknown_03000E20: @ 3000E20 - .space 0x8 - -gUnknown_03000E28: @ 3000E28 - .space 0x2 - -gUnknown_03000E2A: @ 3000E2A - .space 0x2 - -gUnknown_03000E2C: @ 3000E2C - .space 0x4 - -gUnknown_03000E30: @ 3000E30 - .space 0x8 - -.include "src/script.o" - -.align 2 -gUnknown_03000F30: @ 3000F30 - .space 0x4 - -gUnknown_03000F34: @ 3000F34 - .space 0x2 - -gUnknown_03000F36: @ 3000F36 - .space 0x2 - -gUnknown_03000F38: @ 3000F38 - .space 0x2 - -gUnknown_03000F3A: @ 3000F3A - .space 0x2 - -gUnknown_03000F3C: @ 3000F3C - .space 0x4 - -gUnknown_03000F40: @ 3000F40 - .space 0x4 - -gUnknown_03000F44: @ 3000F44 - .space 0x4 - + .include "src/rom4.o" + .include "src/field_camera.o" + .include "src/script.o" + .include "src/scrcmd.o" + .include "src/tileset_anims.o" + .include "src/palette.o" .include "src/sound.o" - -gUnknown_03000F50: @ 3000F50 - .space 0x8 - -gUnknown_03000F58: @ 3000F58 - .space 0x20 - -gUnknown_03000F78: @ 3000F78 - .space 0x188 - -gUnknown_03001100: @ 3001100 - .space 0x1 - -gUnknown_03001101: @ 3001101 - .space 0x1 - -gUnknown_03001102: @ 3001102 - .space 0x6 - -gUnknown_03001108: @ 3001108 - .space 0x1C - -gUnknown_03001124: @ 3001124 - .space 0xC - -gUnknown_03001130: @ 3001130 - .space 0x4 - -gUnknown_03001134: @ 3001134 - .space 0x4 - -gUnknown_03001138: @ 3001138 - .space 0x4 - -gUnknown_0300113C: @ 300113C - .space 0x4 - -gUnknown_03001140: @ 3001140 - .space 0x4 - -gUnknown_03001144: @ 3001144 - .space 0x4 - -gUnknown_03001148: @ 3001148 - .space 0x4 - -gUnknown_0300114C: @ 300114C - .space 0x4 - -gUnknown_03001150: @ 3001150 - .space 0x4 - -gUnknown_03001154: @ 3001154 - .space 0x4 - -gUnknown_03001158: @ 3001158 - .space 0x4 - -gUnknown_0300115C: @ 300115C - .space 0x4 - -gUnknown_03001160: @ 3001160 - .space 0x8 - -gUnknown_03001168: @ 3001168 - .space 0xC + .include "src/field_screen.o" + .include "src/field_effect.o" + .include "src/pokemon_storage_system.o" + .include "src/fldeff_cut.o" + .include "src/script_menu.o" + .include "src/record_mixing.o" gUnknown_03001174: @ 3001174 .space 0x1 diff --git a/sym_common.txt b/sym_common.txt index 834f23918..7ba414cab 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -117,7 +117,7 @@ gUnknown_03003110: @ 3003110 gUnknown_03003120: @ 3003120 .space 0x4 -gUnknown_03003124: @ 3003124 +gReceivedRemoteLinkPlayers: @ 3003124 .space 0xC gUnknown_03003130: @ 3003130 @@ -203,7 +203,7 @@ gUnknown_03005CDE: @ 3005CDE .include "rtc.o" -gUnknown_03005D00: @ 3005D00 +gPreBattleCallback1: @ 3005D00 .space 0x4 gBattleMainFunc: @ 3005D04 diff --git a/sym_ewram.txt b/sym_ewram.txt index e49b94160..166ea64d0 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -31,11 +31,8 @@ gUnknown_020223BD: @ 20223BD gUnknown_020223C0: @ 20223C0 .space 0x4 -gUnknown_020223C4: @ 20223C4 - .space 0x4 - -gUnknown_020223C8: @ 20223C8 - .space 0x4FC +gBlockRecvBuffer: @ 20223C4 + .space 0x500 gUnknown_020228C4: @ 20228C4 gBlockSendBuffer .space 0x100 @@ -205,10 +202,10 @@ gUnknown_02022D10: @ 2022D10 gUnknown_02022E10: @ 2022E10 .space 0x4 -gUnknown_02022E14: @ 2022E14 +gBattle_BG0_X: @ 2022E14 .space 0x2 -gUnknown_02022E16: @ 2022E16 +gBattle_BG0_Y: @ 2022E16 .space 0x2 gBattle_BG1_X: @ 2022E18 @@ -226,19 +223,19 @@ gBattle_BG2_Y: @ 2022E1E gBattle_BG3_X: @ 2022E20 .space 0x2 -gUnknown_02022E22: @ 2022E22 +gBattle_BG3_Y: @ 2022E22 .space 0x2 -gUnknown_02022E24: @ 2022E24 +gBattle_WIN0H: @ 2022E24 .space 0x2 -gUnknown_02022E26: @ 2022E26 +gBattle_WIN0V: @ 2022E26 .space 0x2 -gUnknown_02022E28: @ 2022E28 +gBattle_WIN1H: @ 2022E28 .space 0x2 -gUnknown_02022E2A: @ 2022E2A +gBattle_WIN1V: @ 2022E2A .space 0x2 gDisplayedStringBattle: @ 2022E2C @@ -307,16 +304,16 @@ gBattlePartyID: @ 202406E gBanksBySide: @ 2024076 .space 0x4 -gUnknown_0202407A: @ 202407A +gActionsByTurnOrder: @ 202407A .space 0x4 -gTurnOrder: @ 202407E +gBanksByTurnOrder: @ 202407E .space 0x4 -gCurrentMoveTurn: @ 2024082 +gCurrentTurnActionNumber: @ 2024082 .space 0x1 -gFightStateTracker: @ 2024083 +gCurrentActionFuncId: @ 2024083 .space 0x1 gBattleMons: @ 2024084 @@ -385,7 +382,7 @@ gBattlescriptCurrInstr: @ 2024214 gActionForBanks: @ 202421C .space 0x4 -gUnknown_02024220: @ 2024220 +gBattlescriptPtrsForSelection: @ 2024220 .space 0x10 gUnknown_02024230: @ 2024230 @@ -448,7 +445,7 @@ gPauseCounterBattle: @ 202432C gPaydayMoney: @ 202432E .space 0x2 -gUnknown_02024330: @ 2024330 +gRandomTurnNumber: @ 2024330 .space 0x2 gBattleCommunication: @ 2024332 @@ -502,10 +499,10 @@ gUnknown_020244A4: @ 20244A4 gBattleResources: @ 20244A8 .space 0x4 -gUnknown_020244AC: @ 20244AC +gActionSelectionCursor: @ 20244AC .space 0x4 -gUnknown_020244B0: @ 20244B0 +gMoveSelectionCursor: @ 20244B0 .space 0x4 gUnknown_020244B4: @ 20244B4 @@ -523,10 +520,10 @@ gUnknown_020244BC: @ 20244BC gUnknown_020244CC: @ 20244CC .space 0x4 -gUnknown_020244D0: @ 20244D0 +gBattleSpritesDataPtr: @ 20244D0 .space 0x4 -gBattleSpritesGfx: @ 20244D4 +gMonSpritesGfxPtr: @ 20244D4 .space 0x4 gUnknown_020244D8: @ 20244D8 @@ -747,9 +744,7 @@ gUnknown_02037621: @ 2037621 gUnknown_02037622: @ 2037622 .space 0x2 -gUnknown_02037624: @ 2037624 - .space 0xF0 - + .include "src/tileset_anims.o" .include "src/palette.o" .include "src/sound.o" @@ -1634,9 +1629,7 @@ gUnknown_0203BCE8: @ 203BCE8 .space 0x4 .include "src/lottery_corner.o" - -gUnknown_0203BCF0: @ 203BCF0 - .space 0x4 + .include "src/diploma.o" gUnknown_0203BCF4: @ 203BCF4 .space 0x4 @@ -1644,16 +1637,9 @@ gUnknown_0203BCF4: @ 203BCF4 gUnknown_0203BCF8: @ 203BCF8 .space 0x4 -gUnknown_0203BCFC: @ 203BCFC - .space 0x2 + .include "src/save_failed_screen.o" -gUnknown_0203BCFE: @ 203BCFE - .space 0x10 - -gUnknown_0203BD0E: @ 203BD0E - .space 0x6 - -gUnknown_0203BD14: @ 203BD14 +gBraillePuzzleCallbackFlag: @ 203BD14 .space 0x4 gUnknown_0203BD18: @ 203BD18 @@ -1671,10 +1657,10 @@ gUnknown_0203BD26: @ 203BD26 gUnknown_0203BD28: @ 203BD28 .space 0x4 -gUnknown_0203BD2C: @ 203BD2C +gRecordedBattleRngSeed: @ 203BD2C .space 0x4 -gUnknown_0203BD30: @ 203BD30 +gBattlePalaceMoveSelectionRngValue: @ 203BD30 .space 0x4 gUnknown_0203BD34: @ 203BD34