From 11fb13d63585cf92ab9490f75c115eed0da025ad Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 3 Jul 2019 10:35:46 +0200 Subject: [PATCH] Some pokemon jump work --- asm/pokemon_jump.s | 1440 +--------------------------------------- include/pokemon_jump.h | 2 +- include/strings.h | 8 + src/pokemon_jump.c | 687 +++++++++++++++++-- 4 files changed, 645 insertions(+), 1492 deletions(-) diff --git a/asm/pokemon_jump.s b/asm/pokemon_jump.s index 4327bb920e..73582cb060 100755 --- a/asm/pokemon_jump.s +++ b/asm/pokemon_jump.s @@ -5,1446 +5,8 @@ .text - thumb_func_start sub_802CE9C -sub_802CE9C: @ 802CE9C - push {r4-r7,lr} - adds r7, r0, 0 - movs r5, 0 - movs r4, 0 - ldr r6, =gUnknown_082FBE58 -_0802CEA6: - ldr r1, =gUnknown_082FBEB8 - lsls r0, r4, 2 - adds r0, r1 - ldr r0, [r0] - ldr r2, =gUnknown_082FBEA8 - lsls r1, r5, 1 - adds r1, r2 - movs r2, 0 - ldrsh r1, [r1, r2] - movs r3, 0 - ldrsh r2, [r6, r3] - movs r3, 0x2 - bl CreateSprite - lsls r0, 24 - lsrs r1, r0, 24 - lsls r0, r5, 2 - ldr r3, =0x000081d0 - adds r2, r7, r3 - adds r2, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - str r0, [r2] - adds r5, 0x1 - adds r6, 0x14 - adds r4, 0x1 - cmp r4, 0x3 - ble _0802CEA6 - movs r4, 0x3 - movs r6, 0x3C -_0802CEE8: - ldr r1, =gUnknown_082FBEB8 - lsls r0, r4, 2 - adds r0, r1 - ldr r0, [r0] - ldr r2, =gUnknown_082FBEA8 - lsls r1, r5, 1 - adds r1, r2 - movs r2, 0 - ldrsh r1, [r1, r2] - ldr r2, =gUnknown_082FBE58 - adds r2, r6, r2 - movs r3, 0 - ldrsh r2, [r2, r3] - movs r3, 0x2 - bl CreateSprite - lsls r0, 24 - lsrs r1, r0, 24 - lsls r0, r5, 2 - ldr r3, =0x000081d0 - adds r2, r7, r3 - adds r2, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - str r0, [r2] - adds r0, 0x3F - ldrb r1, [r0] - movs r2, 0x1 - orrs r1, r2 - strb r1, [r0] - adds r5, 0x1 - subs r6, 0x14 - subs r4, 0x1 - cmp r4, 0 - bge _0802CEE8 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802CE9C + - thumb_func_start sub_802CF50 -sub_802CF50: @ 802CF50 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xC - str r0, [sp, 0x8] - cmp r1, 0x5 - ble _0802CF70 - movs r0, 0xA - subs r1, r0, r1 - movs r0, 0x3 - str r0, [sp] - ldr r2, [sp, 0x8] - ldrb r0, [r2, 0xF] - b _0802CF78 -_0802CF70: - movs r3, 0x2 - str r3, [sp] - ldr r7, [sp, 0x8] - ldrb r0, [r7, 0xE] -_0802CF78: - movs r6, 0 - lsls r2, r1, 1 - str r2, [sp, 0x4] - lsls r0, 4 - mov r9, r0 - lsls r1, 24 - mov r8, r1 - ldr r0, =gUnknown_082FBE58 - adds r4, r2, r0 - ldr r3, [sp] - lsls r3, 2 - mov r10, r3 - movs r5, 0x3 -_0802CF92: - lsls r0, r6, 2 - ldr r7, [sp, 0x8] - ldr r1, =0x000081d0 - adds r2, r7, r1 - adds r2, r0 - ldr r1, [r2] - ldrh r0, [r4] - strh r0, [r1, 0x22] - ldr r3, [r2] - ldrb r0, [r3, 0x5] - movs r7, 0xD - negs r7, r7 - adds r1, r7, 0 - ands r0, r1 - mov r1, r10 - orrs r0, r1 - strb r0, [r3, 0x5] - ldr r3, [r2] - ldrb r1, [r3, 0x5] - movs r0, 0xF - ands r0, r1 - mov r7, r9 - orrs r0, r7 - strb r0, [r3, 0x5] - ldr r0, [r2] - mov r2, r8 - lsrs r1, r2, 24 - bl StartSpriteAnim - adds r6, 0x1 - adds r4, 0x14 - subs r5, 0x1 - cmp r5, 0 - bge _0802CF92 - movs r5, 0x3 - ldr r0, =gUnknown_082FBE58 - ldr r3, [sp, 0x4] - adds r0, r3, r0 - adds r4, r0, 0 - adds r4, 0x3C - ldr r7, [sp] - lsls r7, 2 - mov r10, r7 -_0802CFE8: - lsls r0, r6, 2 - ldr r1, [sp, 0x8] - ldr r3, =0x000081d0 - adds r2, r1, r3 - adds r2, r0 - ldr r1, [r2] - ldrh r0, [r4] - strh r0, [r1, 0x22] - ldr r3, [r2] - ldrb r0, [r3, 0x5] - movs r7, 0xD - negs r7, r7 - adds r1, r7, 0 - ands r0, r1 - mov r1, r10 - orrs r0, r1 - strb r0, [r3, 0x5] - ldr r3, [r2] - ldrb r1, [r3, 0x5] - movs r0, 0xF - ands r0, r1 - mov r7, r9 - orrs r0, r7 - strb r0, [r3, 0x5] - ldr r0, [r2] - mov r2, r8 - lsrs r1, r2, 24 - bl StartSpriteAnim - adds r6, 0x1 - subs r4, 0x14 - subs r5, 0x1 - cmp r5, 0 - bge _0802CFE8 - add sp, 0xC - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802CF50 - - thumb_func_start sub_802D044 -sub_802D044: @ 802D044 - push {r4,lr} - sub sp, 0x4 - adds r4, r0, 0 - movs r0, 0 - str r0, [sp] - movs r0, 0x9 - movs r1, 0x7 - movs r2, 0x78 - movs r3, 0x50 - bl sub_802EB24 - adds r0, r4, 0 - bl sub_802CD3C - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_802D044 - - thumb_func_start sub_802D068 -sub_802D068: @ 802D068 - push {lr} - bl sub_802EB84 - pop {r1} - bx r1 - thumb_func_end sub_802D068 - - thumb_func_start sub_802D074 -sub_802D074: @ 802D074 - push {r4,lr} - ldr r4, =gUnknown_02022D00 - str r0, [r4] - bl sub_802D0BC - ldr r0, =sub_802D12C - movs r1, 0x3 - bl CreateTask - ldr r1, [r4] - strb r0, [r1, 0x6] - ldr r2, [r4] - ldrb r0, [r2, 0x6] - movs r1, 0x2 - bl SetWordTaskArg - ldr r0, =sub_802D150 - bl sub_802D108 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802D074 - - thumb_func_start sub_802D0AC -sub_802D0AC: @ 802D0AC - push {lr} - bl FreeAllWindowBuffers - bl sub_8034CC8 - pop {r0} - bx r0 - thumb_func_end sub_802D0AC - - thumb_func_start sub_802D0BC -sub_802D0BC: @ 802D0BC - movs r1, 0 - strh r1, [r0, 0x4] - str r1, [r0] - movs r1, 0xFF - strh r1, [r0, 0x12] - bx lr - thumb_func_end sub_802D0BC - - thumb_func_start sub_802D0C8 -sub_802D0C8: @ 802D0C8 - push {r4-r6,lr} - adds r6, r0, 0 - movs r5, 0 - ldr r4, =gUnknown_082FE18C -_0802D0D0: - ldr r0, [r4] - cmp r0, r6 - bne _0802D0DC - ldr r0, [r4, 0x4] - bl sub_802D108 -_0802D0DC: - adds r4, 0x8 - adds r5, 0x1 - cmp r5, 0x9 - bls _0802D0D0 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802D0C8 - - thumb_func_start sub_802D0F0 -sub_802D0F0: @ 802D0F0 - ldr r0, =gUnknown_02022D00 - ldr r0, [r0] - ldr r1, [r0] - movs r0, 0x1 - eors r1, r0 - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 - bx lr - .pool - thumb_func_end sub_802D0F0 - - thumb_func_start sub_802D108 -sub_802D108: @ 802D108 - push {r4,lr} - adds r2, r0, 0 - ldr r4, =gUnknown_02022D00 - ldr r0, [r4] - ldrb r0, [r0, 0x6] - movs r1, 0 - bl SetWordTaskArg - ldr r1, [r4] - movs r0, 0 - strh r0, [r1, 0x4] - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802D108 - - thumb_func_start sub_802D12C -sub_802D12C: @ 802D12C - push {lr} - lsls r0, 24 - lsrs r1, r0, 24 - ldr r0, =gUnknown_02022D00 - ldr r0, [r0] - ldr r0, [r0] - cmp r0, 0 - bne _0802D148 - adds r0, r1, 0 - movs r1, 0 - bl GetWordTaskArg - bl _call_via_r0 -_0802D148: - pop {r0} - bx r0 - .pool - thumb_func_end sub_802D12C - - thumb_func_start sub_802D150 -sub_802D150: @ 802D150 - push {r4-r6,lr} - sub sp, 0x8 - ldr r6, =gUnknown_02022D00 - ldr r1, [r6] - ldrh r5, [r1, 0x4] - cmp r5, 0x1 - bne _0802D160 - b _0802D298 -_0802D160: - cmp r5, 0x1 - bgt _0802D170 - cmp r5, 0 - beq _0802D178 - b _0802D2DA - .pool -_0802D170: - cmp r5, 0x2 - bne _0802D176 - b _0802D2D6 -_0802D176: - b _0802D2DA -_0802D178: - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_082FE164 - movs r0, 0 - movs r2, 0x4 - bl InitBgsFromTemplates - ldr r0, =gUnknown_082FE174 - bl InitWindows - bl reset_temp_tile_data_buffers - ldr r0, [r6] - bl sub_802C974 - bl sub_802DD08 - ldr r0, =gPkmnJumpBgPal - movs r1, 0 - movs r2, 0x20 - bl LoadPalette - ldr r1, =gPkmnJumpBgGfx - str r5, [sp] - movs r0, 0x3 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r1, =gPkmnJumpBgTilemap - movs r4, 0x1 - str r4, [sp] - movs r0, 0x3 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r0, =gPkmnJumpVenusaurPal - movs r1, 0x30 - movs r2, 0x20 - bl LoadPalette - ldr r1, =gPkmnJumpVenusaurGfx - str r5, [sp] - movs r0, 0x2 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r1, =gPkmnJumpVenusaurTilemap - str r4, [sp] - movs r0, 0x2 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r0, =gPkmnJumpResultsPal - movs r1, 0x10 - movs r2, 0x20 - bl LoadPalette - ldr r1, =gPkmnJumpResultsGfx - str r5, [sp] - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r1, =gPkmnJumpResultsTilemap - str r4, [sp] - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r0, =gPkmnJumpPal3 - movs r1, 0x20 - movs r2, 0x20 - bl LoadPalette - ldr r1, [r6] - movs r0, 0xD3 - lsls r0, 1 - adds r1, r0 - movs r0, 0 - bl SetBgTilemapBuffer - movs r0, 0x20 - str r0, [sp] - str r0, [sp, 0x4] - movs r0, 0 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl FillBgTilemapBufferRect_Palette0 - bl sub_802DB8C - movs r0, 0 - bl sub_802DD64 - movs r0, 0 - movs r1, 0x1 - movs r2, 0xE0 - bl sub_8098C6C - movs r0, 0 - bl CopyBgTilemapBufferToVram - movs r0, 0x2 - bl CopyBgTilemapBufferToVram - movs r0, 0x1 - bl CopyBgTilemapBufferToVram - bl ResetBgPositions - b _0802D2CC - .pool -_0802D298: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - bne _0802D2DA - bl sub_802DBF8 - ldr r0, [r6] - bl sub_802CE9C - ldr r0, [r6] - movs r1, 0x6 - bl sub_802CF50 - movs r0, 0x3 - bl ShowBg - movs r0, 0 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x1 - bl HideBg -_0802D2CC: - ldr r1, [r6] - ldrh r0, [r1, 0x4] - adds r0, 0x1 - strh r0, [r1, 0x4] - b _0802D2DA -_0802D2D6: - movs r0, 0x1 - str r0, [r1] -_0802D2DA: - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_802D150 - - thumb_func_start sub_802D2E4 -sub_802D2E4: @ 802D2E4 - push {r4,lr} - ldr r4, =gUnknown_02022D00 - ldr r0, [r4] - ldrh r0, [r0, 0x4] - cmp r0, 0x1 - beq _0802D310 - cmp r0, 0x1 - bgt _0802D300 - cmp r0, 0 - beq _0802D30A - b _0802D34A - .pool -_0802D300: - cmp r0, 0x2 - beq _0802D322 - cmp r0, 0x3 - beq _0802D33A - b _0802D34A -_0802D30A: - bl sub_802DE1C - b _0802D330 -_0802D310: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D34A - movs r0, 0 - bl sub_802DF70 - b _0802D330 -_0802D322: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D34A - bl sub_802DFD4 -_0802D330: - ldr r1, [r4] - ldrh r0, [r1, 0x4] - adds r0, 0x1 - strh r0, [r1, 0x4] - b _0802D34A -_0802D33A: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D34A - ldr r1, [r4] - movs r0, 0x1 - str r0, [r1] -_0802D34A: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_802D2E4 - - thumb_func_start sub_802D350 -sub_802D350: @ 802D350 - push {r4,lr} - ldr r4, =gUnknown_02022D00 - ldr r0, [r4] - ldrh r0, [r0, 0x4] - cmp r0, 0x1 - beq _0802D37C - cmp r0, 0x1 - bgt _0802D36C - cmp r0, 0 - beq _0802D376 - b _0802D3B6 - .pool -_0802D36C: - cmp r0, 0x2 - beq _0802D38E - cmp r0, 0x3 - beq _0802D3A6 - b _0802D3B6 -_0802D376: - bl sub_802DE1C - b _0802D39C -_0802D37C: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D3B6 - movs r0, 0x1 - bl sub_802DF70 - b _0802D39C -_0802D38E: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D3B6 - bl sub_802DFD4 -_0802D39C: - ldr r1, [r4] - ldrh r0, [r1, 0x4] - adds r0, 0x1 - strh r0, [r1, 0x4] - b _0802D3B6 -_0802D3A6: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D3B6 - ldr r1, [r4] - movs r0, 0x1 - str r0, [r1] -_0802D3B6: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_802D350 - - thumb_func_start sub_802D3BC -sub_802D3BC: @ 802D3BC - push {r4,r5,lr} - bl sub_802C8AC - lsls r0, 16 - lsrs r5, r0, 16 - ldr r0, =gUnknown_02022D00 - ldr r0, [r0] - ldrh r0, [r0, 0x4] - cmp r0, 0 - beq _0802D3DC - cmp r0, 0x1 - beq _0802D410 - b _0802D43E - .pool -_0802D3DC: - movs r4, 0 - cmp r4, r5 - bge _0802D3F8 -_0802D3E2: - ldr r0, =gUnknown_02022D00 - ldr r0, [r0] - lsls r1, r4, 1 - adds r0, 0x1C - adds r0, r1 - ldrb r0, [r0] - bl ClearWindowTilemap - adds r4, 0x1 - cmp r4, r5 - blt _0802D3E2 -_0802D3F8: - movs r0, 0 - bl CopyBgTilemapBufferToVram - ldr r0, =gUnknown_02022D00 - ldr r1, [r0] - ldrh r0, [r1, 0x4] - adds r0, 0x1 - strh r0, [r1, 0x4] - b _0802D43E - .pool -_0802D410: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D43E - movs r4, 0 - cmp r4, r5 - bge _0802D436 -_0802D420: - ldr r0, =gUnknown_02022D00 - ldr r0, [r0] - lsls r1, r4, 1 - adds r0, 0x1C - adds r0, r1 - ldrb r0, [r0] - bl RemoveWindow - adds r4, 0x1 - cmp r4, r5 - blt _0802D420 -_0802D436: - ldr r0, =gUnknown_02022D00 - ldr r1, [r0] - movs r0, 0x1 - str r0, [r1] -_0802D43E: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802D3BC - - thumb_func_start sub_802D448 -sub_802D448: @ 802D448 - push {r4,r5,lr} - sub sp, 0xC - ldr r5, =gUnknown_02022D00 - ldr r0, [r5] - ldrh r4, [r0, 0x4] - cmp r4, 0x1 - beq _0802D4A4 - cmp r4, 0x1 - bgt _0802D464 - cmp r4, 0 - beq _0802D46A - b _0802D4EC - .pool -_0802D464: - cmp r4, 0x2 - beq _0802D4DC - b _0802D4EC -_0802D46A: - movs r0, 0x1 - movs r1, 0x8 - movs r2, 0x14 - movs r3, 0x2 - bl sub_802DA9C - ldr r1, [r5] - strh r0, [r1, 0x12] - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gText_WantToPlayAgain2 - movs r1, 0x1 - str r1, [sp] - movs r1, 0xFF - str r1, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0x1 - movs r3, 0 - bl AddTextPrinterParameterized - ldr r0, [r5] - ldrb r0, [r0, 0x12] - movs r1, 0x2 - bl CopyWindowToVram - b _0802D4D2 - .pool -_0802D4A4: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D4EC - ldr r0, [r5] - ldrb r0, [r0, 0x12] - bl PutWindowTilemap - ldr r0, [r5] - ldrb r0, [r0, 0x12] - movs r1, 0x1 - movs r2, 0xE - bl DrawTextBorderOuter - movs r0, 0x17 - movs r1, 0x7 - movs r2, 0 - bl sub_802DB18 - movs r0, 0 - bl CopyBgTilemapBufferToVram -_0802D4D2: - ldr r1, [r5] - ldrh r0, [r1, 0x4] - adds r0, 0x1 - strh r0, [r1, 0x4] - b _0802D4EC -_0802D4DC: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D4EC - ldr r1, [r5] - movs r0, 0x1 - str r0, [r1] -_0802D4EC: - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_802D448 - - thumb_func_start sub_802D4F4 -sub_802D4F4: @ 802D4F4 - push {r4,r5,lr} - sub sp, 0xC - ldr r5, =gUnknown_02022D00 - ldr r0, [r5] - ldrh r4, [r0, 0x4] - cmp r4, 0x1 - beq _0802D550 - cmp r4, 0x1 - bgt _0802D510 - cmp r4, 0 - beq _0802D516 - b _0802D58E - .pool -_0802D510: - cmp r4, 0x2 - beq _0802D57E - b _0802D58E -_0802D516: - movs r0, 0x2 - movs r1, 0x7 - movs r2, 0x1A - movs r3, 0x4 - bl sub_802DA9C - ldr r1, [r5] - strh r0, [r1, 0x12] - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gText_SavingDontTurnOffPower - movs r1, 0x1 - str r1, [sp] - movs r1, 0xFF - str r1, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0x1 - movs r3, 0 - bl AddTextPrinterParameterized - ldr r0, [r5] - ldrb r0, [r0, 0x12] - movs r1, 0x2 - bl CopyWindowToVram - b _0802D574 - .pool -_0802D550: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D58E - ldr r0, [r5] - ldrb r0, [r0, 0x12] - bl PutWindowTilemap - ldr r0, [r5] - ldrb r0, [r0, 0x12] - movs r1, 0x1 - movs r2, 0xE - bl DrawTextBorderOuter - movs r0, 0 - bl CopyBgTilemapBufferToVram -_0802D574: - ldr r1, [r5] - ldrh r0, [r1, 0x4] - adds r0, 0x1 - strh r0, [r1, 0x4] - b _0802D58E -_0802D57E: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D58E - ldr r1, [r5] - movs r0, 0x1 - str r0, [r1] -_0802D58E: - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_802D4F4 - - thumb_func_start sub_802D598 -sub_802D598: @ 802D598 - push {r4,r5,lr} - ldr r5, =gUnknown_02022D00 - ldr r0, [r5] - ldrh r4, [r0, 0x4] - cmp r4, 0 - beq _0802D5B0 - cmp r4, 0x1 - beq _0802D5C8 - b _0802D5DE - .pool -_0802D5B0: - bl sub_802DA14 - bl sub_8198C78 - movs r0, 0 - bl CopyBgTilemapBufferToVram - ldr r1, [r5] - ldrh r0, [r1, 0x4] - adds r0, 0x1 - strh r0, [r1, 0x4] - b _0802D5DE -_0802D5C8: - bl sub_802DA44 - cmp r0, 0 - bne _0802D5DE - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D5DE - ldr r0, [r5] - str r4, [r0] -_0802D5DE: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_802D598 - - thumb_func_start sub_802D5E4 -sub_802D5E4: @ 802D5E4 - push {r4,r5,lr} - sub sp, 0xC - ldr r5, =gUnknown_02022D00 - ldr r0, [r5] - ldrh r4, [r0, 0x4] - cmp r4, 0x1 - beq _0802D640 - cmp r4, 0x1 - bgt _0802D600 - cmp r4, 0 - beq _0802D606 - b _0802D67E - .pool -_0802D600: - cmp r4, 0x2 - beq _0802D66E - b _0802D67E -_0802D606: - movs r0, 0x2 - movs r1, 0x8 - movs r2, 0x16 - movs r3, 0x4 - bl sub_802DA9C - ldr r1, [r5] - strh r0, [r1, 0x12] - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gText_SomeoneDroppedOut2 - movs r1, 0x1 - str r1, [sp] - movs r1, 0xFF - str r1, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0x1 - movs r3, 0 - bl AddTextPrinterParameterized - ldr r0, [r5] - ldrb r0, [r0, 0x12] - movs r1, 0x2 - bl CopyWindowToVram - b _0802D664 - .pool -_0802D640: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D67E - ldr r0, [r5] - ldrb r0, [r0, 0x12] - bl PutWindowTilemap - ldr r0, [r5] - ldrb r0, [r0, 0x12] - movs r1, 0x1 - movs r2, 0xE - bl DrawTextBorderOuter - movs r0, 0 - bl CopyBgTilemapBufferToVram -_0802D664: - ldr r1, [r5] - ldrh r0, [r1, 0x4] - adds r0, 0x1 - strh r0, [r1, 0x4] - b _0802D67E -_0802D66E: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D67E - ldr r1, [r5] - movs r0, 0x1 - str r0, [r1] -_0802D67E: - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_802D5E4 - - thumb_func_start sub_802D688 -sub_802D688: @ 802D688 - push {r4,r5,lr} - sub sp, 0xC - ldr r5, =gUnknown_02022D00 - ldr r0, [r5] - ldrh r4, [r0, 0x4] - cmp r4, 0x1 - beq _0802D6E4 - cmp r4, 0x1 - bgt _0802D6A4 - cmp r4, 0 - beq _0802D6AA - b _0802D722 - .pool -_0802D6A4: - cmp r4, 0x2 - beq _0802D712 - b _0802D722 -_0802D6AA: - movs r0, 0x7 - movs r1, 0xA - movs r2, 0x10 - movs r3, 0x2 - bl sub_802DA9C - ldr r1, [r5] - strh r0, [r1, 0x12] - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gText_CommunicationStandby4 - movs r1, 0x1 - str r1, [sp] - movs r1, 0xFF - str r1, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0x1 - movs r3, 0 - bl AddTextPrinterParameterized - ldr r0, [r5] - ldrb r0, [r0, 0x12] - movs r1, 0x2 - bl CopyWindowToVram - b _0802D708 - .pool -_0802D6E4: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D722 - ldr r0, [r5] - ldrb r0, [r0, 0x12] - bl PutWindowTilemap - ldr r0, [r5] - ldrb r0, [r0, 0x12] - movs r1, 0x1 - movs r2, 0xE - bl DrawTextBorderOuter - movs r0, 0 - bl CopyBgTilemapBufferToVram -_0802D708: - ldr r1, [r5] - ldrh r0, [r1, 0x4] - adds r0, 0x1 - strh r0, [r1, 0x4] - b _0802D722 -_0802D712: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802D722 - ldr r1, [r5] - movs r0, 0x1 - str r0, [r1] -_0802D722: - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_802D688 - - thumb_func_start sub_802D72C -sub_802D72C: @ 802D72C - push {r4,r5,lr} - ldr r5, =gUnknown_02022D00 - ldr r0, [r5] - ldrh r4, [r0, 0x4] - cmp r4, 0 - beq _0802D744 - cmp r4, 0x1 - beq _0802D752 - b _0802D75E - .pool -_0802D744: - bl sub_802D044 - ldr r1, [r5] - ldrh r0, [r1, 0x4] - adds r0, 0x1 - strh r0, [r1, 0x4] - b _0802D75E -_0802D752: - bl sub_802D068 - cmp r0, 0 - bne _0802D75E - ldr r0, [r5] - str r4, [r0] -_0802D75E: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_802D72C - - thumb_func_start sub_802D764 -sub_802D764: @ 802D764 - push {lr} - ldr r1, =gUnknown_02022D00 - ldr r0, [r1] - movs r2, 0 - strb r2, [r0, 0xA] - ldr r0, [r1] - strb r2, [r0, 0xB] - ldr r2, [r1] - movs r0, 0x6 - strb r0, [r2, 0xC] - ldr r0, [r1] - ldrb r0, [r0, 0xC] - bl sub_802DC9C - pop {r0} - bx r0 - .pool - thumb_func_end sub_802D764 - - thumb_func_start sub_802D788 -sub_802D788: @ 802D788 - push {r4,lr} - ldr r0, =gUnknown_02022D00 - ldr r2, [r0] - ldrb r3, [r2, 0xA] - adds r4, r0, 0 - cmp r3, 0 - beq _0802D7A0 - cmp r3, 0x1 - beq _0802D7DA - b _0802D7DE - .pool -_0802D7A0: - ldrb r0, [r2, 0xB] - adds r0, 0x1 - strb r0, [r2, 0xB] - ldr r1, [r4] - ldrb r0, [r1, 0xB] - cmp r0, 0xA - bls _0802D7CA - strb r3, [r1, 0xB] - ldr r0, [r4] - ldrb r1, [r0, 0xC] - adds r1, 0x1 - strb r1, [r0, 0xC] - ldr r1, [r4] - ldrb r0, [r1, 0xC] - cmp r0, 0x9 - bls _0802D7CA - strb r3, [r1, 0xC] - ldr r1, [r4] - ldrb r0, [r1, 0xA] - adds r0, 0x1 - strb r0, [r1, 0xA] -_0802D7CA: - ldr r0, [r4] - ldrb r0, [r0, 0xC] - bl sub_802DC9C - ldr r0, [r4] - ldrb r0, [r0, 0xC] - cmp r0, 0x7 - bne _0802D7DE -_0802D7DA: - movs r0, 0 - b _0802D7E0 -_0802D7DE: - movs r0, 0x1 -_0802D7E0: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_802D788 - - thumb_func_start sub_802D7E8 -sub_802D7E8: @ 802D7E8 - push {r4,r5,lr} - sub sp, 0xC - adds r4, r1, 0 - lsls r0, 16 - lsrs r0, 16 - lsls r4, 16 - lsrs r4, 16 - ldr r5, =gUnknown_02022D00 - ldr r1, [r5] - adds r1, 0x26 - adds r2, r4, 0 - bl CopyItemNameHandlePlural - ldr r0, [r5] - adds r0, 0x66 - adds r1, r4, 0 - movs r2, 0 - movs r3, 0x1 - bl ConvertIntToDecimalStringN - bl DynamicPlaceholderTextUtil_Reset - ldr r1, [r5] - adds r1, 0x26 - movs r0, 0 - bl DynamicPlaceholderTextUtil_SetPlaceholderPtr - ldr r1, [r5] - adds r1, 0x66 - movs r0, 0x1 - bl DynamicPlaceholderTextUtil_SetPlaceholderPtr - ldr r0, [r5] - adds r0, 0xA6 - ldr r1, =gText_AwesomeWonF701F700 - bl DynamicPlaceholderTextUtil_ExpandPlaceholders - movs r0, 0x4 - movs r1, 0x8 - movs r2, 0x16 - movs r3, 0x4 - bl sub_802DA9C - ldr r2, [r5] - movs r4, 0 - movs r3, 0 - strh r0, [r2, 0x12] - lsls r0, 24 - lsrs r0, 24 - adds r2, 0xA6 - movs r1, 0x1 - str r1, [sp] - movs r1, 0xFF - str r1, [sp, 0x4] - str r3, [sp, 0x8] - movs r1, 0x1 - bl AddTextPrinterParameterized - ldr r0, [r5] - ldrb r0, [r0, 0x12] - movs r1, 0x2 - bl CopyWindowToVram - ldr r1, [r5] - ldr r0, =0x0000016f - strh r0, [r1, 0x14] - strb r4, [r1, 0xD] - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802D7E8 - - thumb_func_start sub_802D884 -sub_802D884: @ 802D884 - push {r4-r6,lr} - sub sp, 0xC - lsls r0, 16 - lsrs r0, 16 - ldr r4, =gUnknown_02022D00 - ldr r1, [r4] - adds r1, 0x26 - bl CopyItemName - bl DynamicPlaceholderTextUtil_Reset - ldr r1, [r4] - adds r1, 0x26 - movs r0, 0 - bl DynamicPlaceholderTextUtil_SetPlaceholderPtr - ldr r0, [r4] - adds r0, 0xA6 - ldr r1, =gText_FilledStorageSpace2 - bl DynamicPlaceholderTextUtil_ExpandPlaceholders - movs r0, 0x4 - movs r1, 0x8 - movs r2, 0x16 - movs r3, 0x4 - bl sub_802DA9C - ldr r2, [r4] - movs r6, 0 - movs r5, 0 - strh r0, [r2, 0x12] - lsls r0, 24 - lsrs r0, 24 - adds r2, 0xA6 - movs r1, 0x1 - str r1, [sp] - movs r1, 0xFF - str r1, [sp, 0x4] - str r5, [sp, 0x8] - movs r1, 0x1 - movs r3, 0 - bl AddTextPrinterParameterized - ldr r0, [r4] - ldrb r0, [r0, 0x12] - movs r1, 0x2 - bl CopyWindowToVram - ldr r0, [r4] - strh r5, [r0, 0x14] - strb r6, [r0, 0xD] - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802D884 - - thumb_func_start sub_802D8FC -sub_802D8FC: @ 802D8FC - push {r4-r6,lr} - sub sp, 0xC - lsls r0, 16 - lsrs r0, 16 - ldr r4, =gUnknown_02022D00 - ldr r1, [r4] - adds r1, 0x26 - bl CopyItemName - bl DynamicPlaceholderTextUtil_Reset - ldr r1, [r4] - adds r1, 0x26 - movs r0, 0 - bl DynamicPlaceholderTextUtil_SetPlaceholderPtr - ldr r0, [r4] - adds r0, 0xA6 - ldr r1, =gText_CantHoldMore - bl DynamicPlaceholderTextUtil_ExpandPlaceholders - movs r0, 0x4 - movs r1, 0x9 - movs r2, 0x16 - movs r3, 0x2 - bl sub_802DA9C - ldr r2, [r4] - movs r6, 0 - movs r5, 0 - strh r0, [r2, 0x12] - lsls r0, 24 - lsrs r0, 24 - adds r2, 0xA6 - movs r1, 0x1 - str r1, [sp] - movs r1, 0xFF - str r1, [sp, 0x4] - str r5, [sp, 0x8] - movs r1, 0x1 - movs r3, 0 - bl AddTextPrinterParameterized - ldr r0, [r4] - ldrb r0, [r0, 0x12] - movs r1, 0x2 - bl CopyWindowToVram - ldr r0, [r4] - strh r5, [r0, 0x14] - strb r6, [r0, 0xD] - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802D8FC - - thumb_func_start sub_802D974 -sub_802D974: @ 802D974 - push {r4,lr} - ldr r4, =gUnknown_02022D00 - ldr r0, [r4] - ldrb r0, [r0, 0xD] - cmp r0, 0x1 - beq _0802D9C8 - cmp r0, 0x1 - bgt _0802D990 - cmp r0, 0 - beq _0802D99A - b _0802DA0C - .pool -_0802D990: - cmp r0, 0x2 - beq _0802D9EE - cmp r0, 0x3 - beq _0802DA02 - b _0802DA0C -_0802D99A: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802DA0C - ldr r0, [r4] - ldrb r0, [r0, 0x12] - bl PutWindowTilemap - ldr r0, [r4] - ldrb r0, [r0, 0x12] - movs r1, 0x1 - movs r2, 0xE - bl DrawTextBorderOuter - movs r0, 0 - bl CopyBgTilemapBufferToVram - ldr r1, [r4] - ldrb r0, [r1, 0xD] - adds r0, 0x1 - strb r0, [r1, 0xD] - b _0802DA0C -_0802D9C8: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0802DA0C - ldr r1, [r4] - ldrh r0, [r1, 0x14] - cmp r0, 0 - bne _0802D9E0 - ldrb r0, [r1, 0xD] - adds r0, 0x2 - b _0802DA00 -_0802D9E0: - ldrh r0, [r1, 0x14] - bl PlayFanfare - ldr r1, [r4] - ldrb r0, [r1, 0xD] - adds r0, 0x1 - strb r0, [r1, 0xD] -_0802D9EE: - bl IsFanfareTaskInactive - lsls r0, 24 - cmp r0, 0 - beq _0802DA0C - ldr r0, =gUnknown_02022D00 - ldr r1, [r0] - ldrb r0, [r1, 0xD] - adds r0, 0x1 -_0802DA00: - strb r0, [r1, 0xD] -_0802DA02: - movs r0, 0 - b _0802DA0E - .pool -_0802DA0C: - movs r0, 0x1 -_0802DA0E: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_802D974 - - thumb_func_start sub_802DA14 -sub_802DA14: @ 802DA14 - push {r4,lr} - ldr r4, =gUnknown_02022D00 - ldr r0, [r4] - ldrh r0, [r0, 0x12] - cmp r0, 0xFF - beq _0802DA38 - lsls r0, 24 - lsrs r0, 24 - bl rbox_fill_rectangle - ldr r0, [r4] - ldrb r0, [r0, 0x12] - movs r1, 0x1 - bl CopyWindowToVram - ldr r1, [r4] - movs r0, 0 - strb r0, [r1, 0xD] -_0802DA38: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802DA14 thumb_func_start sub_802DA44 sub_802DA44: @ 802DA44 diff --git a/include/pokemon_jump.h b/include/pokemon_jump.h index 9dbf194d06..d137c37b2d 100644 --- a/include/pokemon_jump.h +++ b/include/pokemon_jump.h @@ -3,7 +3,7 @@ #include "main.h" -void sub_802EB24(u8, u8, u8, u8, u8); +void sub_802EB24(s16 arg0, s16 arg1, s16 arg2, s16 arg3, u8 arg4); bool32 sub_802EB84(void); void sub_802A9A8(u16 monId, MainCallback callback); bool32 sub_802C908(u16 species); diff --git a/include/strings.h b/include/strings.h index f30e823211..e373a5660b 100644 --- a/include/strings.h +++ b/include/strings.h @@ -2708,6 +2708,14 @@ extern const u8 gText_Symbols[]; extern const u8 gText_Register2[]; extern const u8 gText_Exit2[]; +// Pokemon jump +extern const u8 gText_WantToPlayAgain2[]; +extern const u8 gText_SomeoneDroppedOut2[]; +extern const u8 gText_CommunicationStandby4[]; +extern const u8 gText_AwesomeWonF701F700[]; +extern const u8 gText_FilledStorageSpace2[]; +extern const u8 gText_CantHoldMore[]; + // Pokenav Match Call extern const u8 gText_CallCantBeMadeHere[]; extern const u8 gText_NumberRegistered[]; diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index 4a457adc47..6998628834 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -1,7 +1,9 @@ #include "global.h" #include "alloc.h" +#include "bg.h" #include "data.h" #include "decompress.h" +#include "dynamic_placeholder_text_util.h" #include "event_data.h" #include "item.h" #include "link.h" @@ -10,11 +12,14 @@ #include "menu.h" #include "palette.h" #include "random.h" +#include "rom_8034C54.h" #include "save.h" #include "sound.h" #include "sprite.h" #include "string_util.h" +#include "strings.h" #include "task.h" +#include "text_window.h" #include "trig.h" #include "pokemon.h" #include "pokemon_jump.h" @@ -43,6 +48,33 @@ struct PokemonJump1_82E4 u8 unk1C[11]; }; +struct PokemonJump2 +{ + int unk0; + u16 unk4; + u8 unk6; + u8 filler7[0xa - 0x7]; + u8 unkA; + u8 unkB; + u8 unkC; + u8 unkD; + u8 unkE; + u8 unkF; + u16 filler10; + u16 unk12; + u16 unk14; + u8 filler16[0x1c - 0x16]; + u16 unk1C[5]; + u8 txtBuff[2][0x40]; + u8 strBuff[0x100]; + u16 tilemapBuffer[(0x81a8 - 0x1a6) / 2]; // 0x1A6 + struct Sprite *unk81A8[MAX_RFU_PLAYERS]; + struct Sprite *unk81BC[MAX_RFU_PLAYERS]; + struct Sprite *unk81D0[8]; + u8 filler81F0[0xC]; + u8 unk81FC[MAX_RFU_PLAYERS]; +}; + struct PokemonJump1 { MainCallback returnCallback; @@ -102,8 +134,7 @@ struct PokemonJump1 u8 unk8B[MAX_RFU_PLAYERS]; u16 unk90[MAX_RFU_PLAYERS]; u16 unk9A[MAX_RFU_PLAYERS]; - void **unkA4; - u8 fillerA8[0x8200]; + struct PokemonJump2 unkA4; struct PokemonJump1_MonInfo unk82A8[MAX_RFU_PLAYERS]; struct PokemonJump1_82E4 unk82E4[MAX_RFU_PLAYERS]; struct PokemonJump1_82E4 *unk83AC; @@ -125,20 +156,6 @@ struct Unk802B078 int unk8; }; - -struct PokemonJump2 -{ - u8 filler0[0xE]; - u8 unkE; - u8 unkF; - u8 filler10[0x8198]; - struct Sprite *unk81A8[MAX_RFU_PLAYERS]; - struct Sprite *unk81BC[MAX_RFU_PLAYERS]; - struct Sprite *unk81D0[8]; - u8 filler81F0[0xC]; - u8 unk81FC[MAX_RFU_PLAYERS]; -}; - static void sub_802AA60(struct PokemonJump1 *); void sub_802AA94(struct PokemonJump1 *); void sub_802AB20(void); @@ -216,15 +233,16 @@ static void sub_802CC40(struct Sprite *sprite); static void sub_802CD08(struct Sprite *sprite); static void sub_802CDD4(struct Sprite *sprite); void sub_802DC9C(u32); -void sub_802D074(void *); +void sub_802D074(struct PokemonJump2 *); +void sub_802D0BC(struct PokemonJump2 *); void sub_802D0AC(void); void sub_802D0C8(int); -int sub_802D0F0(void); +bool32 sub_802D0F0(void); void sub_802D764(void); bool32 sub_802D788(void); -void sub_802D7E8(u16, u16); -void sub_802D884(u16); -void sub_802D8FC(u16); +void sub_802D7E8(u16 itemId, u16 quantity); +void sub_802D884(u16 itemId); +void sub_802D8FC(u16 itemId); bool32 sub_802D974(void); void sub_802DA14(void); void sub_802DC80(int, s8); @@ -249,6 +267,7 @@ bool32 sub_802E264(struct PokemonJump1_82E4 *, int, u8 *, u16 *); bool32 sub_802E2D0(struct PokemonJump1_82E4 *, int); int sub_802E354(int, u16, u16); void sub_802E3A8(void); +void sub_802D12C(u8 taskId); extern struct PokemonJump1 *gUnknown_02022CFC; extern struct PokemonJump2 *gUnknown_02022D00; @@ -388,15 +407,33 @@ extern const u16 gUnknown_082FB64C[4]; extern const u16 gUnknown_082FB654[]; extern const s8 gUnknown_082FB65C[][48]; extern const int gUnknown_082FB6EC[]; -extern const int gUnknown_082FB714[]; +extern const u32 gUnknown_082FB714[][2]; extern const u16 gUnknown_082FB704[8]; extern const struct CompressedSpriteSheet gUnknown_082FBE08[5]; extern const struct SpritePalette gUnknown_082FBE30[2]; extern const struct SpriteTemplate gUnknown_082FBE40; extern const struct SpriteTemplate gUnknown_082FC00C; -extern const s16 gUnknown_082FBE58[]; +extern const s16 gUnknown_082FBE58[][10]; extern const s16 gUnknown_082FBEA8[8]; -extern const struct SpriteTemplate gUnknown_082FBEB8[4]; +extern const struct SpriteTemplate *gUnknown_082FBEB8[4]; +extern const struct BgTemplate gUnknown_082FE164[4]; +extern const struct WindowTemplate gUnknown_082FE174[]; +extern const u16 gPkmnJumpBgPal[]; +extern const u16 gPkmnJumpVenusaurPal[]; +extern const u16 gPkmnJumpResultsPal[]; +extern const u16 gPkmnJumpPal3[]; +extern const u32 gPkmnJumpVenusaurGfx[]; +extern const u32 gPkmnJumpBgTilemap[]; +extern const u32 gPkmnJumpBgGfx[]; +extern const u32 gPkmnJumpVenusaurTilemap[]; +extern const u32 gPkmnJumpResultsGfx[]; +extern const u32 gPkmnJumpResultsTilemap[]; + +struct +{ + int id; + void (*func)(void); +} extern const gUnknown_082FE18C[10]; void sub_802A9A8(u16 partyIndex, MainCallback callback) { @@ -1145,8 +1182,6 @@ static bool32 sub_802B720(void) static bool32 sub_802B7E0(void) { - int var0; - switch (gUnknown_02022CFC->unkA) { case 0: @@ -1155,8 +1190,7 @@ static bool32 sub_802B7E0(void) gUnknown_02022CFC->unkA++; break; case 1: - var0 = sub_802D0F0(); - if (!var0) + if (!sub_802D0F0()) { sub_802DDF4(gUnknown_02022CFC->unk6); gUnknown_02022CFC->unk3C = 0; @@ -1813,7 +1847,7 @@ static void sub_802C398(int multiplayerId) sub_802DC80(multiplayerId, var1); if (!var1 && multiplayerId == gUnknown_02022CFC->unk6) sub_802C1BC(); - + player->unk0 = var1; } @@ -2028,7 +2062,7 @@ static void sub_802C7A0(u16 arg0) static bool32 sub_802C7BC(void) { - if (gUnknown_02022CFC->unk78 >= gUnknown_082FB714[0]) + if (gUnknown_02022CFC->unk78 >= gUnknown_082FB714[0][0]) return TRUE; else return FALSE; @@ -2053,6 +2087,22 @@ static u16 sub_802C818(void) return gUnknown_082FB704[index]; } +#ifdef NONMATCHING +// Impossible to match. +static u16 sub_802C838(void) +{ + u32 val, i; + + val = 0; + for (i = 0; i < 5; val = gUnknown_082FB714[i][1], i++) + { + if (gUnknown_02022CFC->unk78 < gUnknown_082FB714[i][0]) + break; + } + + return val; +} +#else NAKED static u16 sub_802C838(void) { @@ -2091,12 +2141,13 @@ _0802C874:\n\ pop {r1}\n\ bx r1"); } +#endif static u16 sub_802C880(u16 item, u16 quantity) { while (quantity && !CheckBagHasSpace(item, quantity)) quantity--; - + return quantity; } @@ -2151,7 +2202,7 @@ void sub_802C974(struct PokemonJump2 *arg0) for (i = 0; i < ARRAY_COUNT(gUnknown_082FBE08); i++) LoadCompressedSpriteSheet(&gUnknown_082FBE08[i]); - + for (i = 0; i < ARRAY_COUNT(gUnknown_082FBE30); i++) LoadSpritePalette(&gUnknown_082FBE30[i]); @@ -2382,25 +2433,557 @@ void sub_802CE48(struct PokemonJump2 *arg0, s16 x, s16 y, u8 multiplayerId) } } -// void sub_802CE9C(struct PokemonJump2 *arg0) -// { -// int i; -// int count; -// u8 spriteId; +void sub_802CE9C(struct PokemonJump2 *arg0) +{ + int i; + int count; + u8 spriteId; -// count = 0; -// for (i = 0; i < 4; i++) -// { -// spriteId = CreateSprite(&gUnknown_082FBEB8[i], gUnknown_082FBEA8[count], gUnknown_082FBE58[i * 10], 2); -// arg0->unk81D0[count] = &gSprites[spriteId]; -// count++; -// } + count = 0; + for (i = 0; i < 4; i++) + { + spriteId = CreateSprite(gUnknown_082FBEB8[i], gUnknown_082FBEA8[count], gUnknown_082FBE58[i][0], 2); + arg0->unk81D0[count] = &gSprites[spriteId]; + count++; + } -// for (i = 0; i < 4; i++) -// { -// spriteId = CreateSprite(&gUnknown_082FBEB8[i], gUnknown_082FBEA8[count], gUnknown_082FBE58[i * 10], 2); -// arg0->unk81D0[count] = &gSprites[spriteId]; -// arg0->unk81D0[count]->hFlip = 1; -// count++; -// } -// } + for (i = 3; i >= 0; i--) + { + spriteId = CreateSprite(gUnknown_082FBEB8[i], gUnknown_082FBEA8[count], gUnknown_082FBE58[i][0], 2); + arg0->unk81D0[count] = &gSprites[spriteId]; + arg0->unk81D0[count]->hFlip = 1; + count++; + } +} + +void sub_802CF50(struct PokemonJump2 *arg0, int arg1) +{ + int i, count, palNum; + int priority; + + if (arg1 > 5) + { + arg1 = 10 - arg1; + priority = 3; + palNum = arg0->unkF; + } + else + { + priority = 2; + palNum = arg0->unkE; + } + + count = 0; + for (i = 0; i < 4; i++) + { + arg0->unk81D0[count]->pos1.y = gUnknown_082FBE58[i][arg1]; + arg0->unk81D0[count]->oam.priority = priority; + arg0->unk81D0[count]->oam.paletteNum = palNum; + StartSpriteAnim(arg0->unk81D0[count], arg1); + count++; + } + + for (i = 3; i >= 0; i--) + { + arg0->unk81D0[count]->pos1.y = gUnknown_082FBE58[i][arg1]; + arg0->unk81D0[count]->oam.priority = priority; + arg0->unk81D0[count]->oam.paletteNum = palNum; + StartSpriteAnim(arg0->unk81D0[count], arg1); + count++; + } +} + +void sub_802D044(struct PokemonJump2 *arg0) +{ + sub_802EB24(9, 7, 120, 80, 0); + sub_802CD3C(arg0); +} + +bool32 sub_802D068(void) +{ + return sub_802EB84(); +} + +void sub_802D150(void); +void sub_802DD08(void); +void sub_802DB8C(void); +void sub_802DBF8(void); +void sub_802DE1C(void); +void sub_802DFD4(void); +void sub_802D108(void (*func)(void)); +void sub_802DF70(int arg0); +u32 sub_802DA9C(u8 arg0, u8 arg1, u8 arg2, u8 arg3); +void sub_802DB18(u8 arg0, u8 arg1, u8 arg2); + +void sub_802D074(struct PokemonJump2 *arg0) +{ + u8 taskId; + + gUnknown_02022D00 = arg0; + sub_802D0BC(gUnknown_02022D00); + taskId = CreateTask(sub_802D12C, 3); + gUnknown_02022D00->unk6 = taskId; + SetWordTaskArg(gUnknown_02022D00->unk6, 2, (u32) gUnknown_02022D00); + sub_802D108(sub_802D150); +} + +void sub_802D0AC(void) +{ + FreeAllWindowBuffers(); + sub_8034CC8(); +} + +void sub_802D0BC(struct PokemonJump2 *arg0) +{ + arg0->unk4 = 0; + arg0->unk0 = 0; + arg0->unk12 = 0xFF; +} + +void sub_802D0C8(int arg0) +{ + int i; + + for (i = 0; i < ARRAY_COUNT(gUnknown_082FE18C); i++) + { + if (gUnknown_082FE18C[i].id == arg0) + sub_802D108(gUnknown_082FE18C[i].func); + } +} + +bool32 sub_802D0F0(void) +{ + return (gUnknown_02022D00->unk0 != 1); +} + +void sub_802D108(void (*func)(void)) +{ + SetWordTaskArg(gUnknown_02022D00->unk6, 0, (u32) func); + gUnknown_02022D00->unk4 = 0; + gUnknown_02022D00->unk0 = 0; +} + +void sub_802D12C(u8 taskId) +{ + if (!gUnknown_02022D00->unk0) + { + void (*func)(void) = (void *)(GetWordTaskArg(taskId, 0)); + + func(); + } +} + +void sub_802D150(void) +{ + switch (gUnknown_02022D00->unk4) + { + case 0: + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_082FE164, ARRAY_COUNT(gUnknown_082FE164)); + InitWindows(gUnknown_082FE174); + reset_temp_tile_data_buffers(); + sub_802C974(gUnknown_02022D00); + sub_802DD08(); + LoadPalette(gPkmnJumpBgPal, 0, 0x20); + decompress_and_copy_tile_data_to_vram(3, gPkmnJumpBgGfx, 0, 0, 0); + decompress_and_copy_tile_data_to_vram(3, gPkmnJumpBgTilemap, 0, 0, 1); + LoadPalette(gPkmnJumpVenusaurPal, 0x30, 0x20); + decompress_and_copy_tile_data_to_vram(2, gPkmnJumpVenusaurGfx, 0, 0, 0); + decompress_and_copy_tile_data_to_vram(2, gPkmnJumpVenusaurTilemap, 0, 0, 1); + LoadPalette(gPkmnJumpResultsPal, 0x10, 0x20); + decompress_and_copy_tile_data_to_vram(1, gPkmnJumpResultsGfx, 0, 0, 0); + decompress_and_copy_tile_data_to_vram(1, gPkmnJumpResultsTilemap, 0, 0, 1); + LoadPalette(gPkmnJumpPal3, 0x20, 0x20); + SetBgTilemapBuffer(0, gUnknown_02022D00->tilemapBuffer); + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); + sub_802DB8C(); + sub_802DD64(0); + sub_8098C6C(0, 1, 0xE0); + CopyBgTilemapBufferToVram(0); + CopyBgTilemapBufferToVram(2); + CopyBgTilemapBufferToVram(1); + ResetBgPositions(); + gUnknown_02022D00->unk4++; + break; + case 1: + if (!free_temp_tile_data_buffers_if_possible()) + { + sub_802DBF8(); + sub_802CE9C(gUnknown_02022D00); + sub_802CF50(gUnknown_02022D00, 6); + ShowBg(3); + ShowBg(0); + ShowBg(2); + HideBg(1); + gUnknown_02022D00->unk4++; + } + break; + case 2: + gUnknown_02022D00->unk0 = 1; + break; + } +} + +void sub_802D2E4(void) +{ + switch (gUnknown_02022D00->unk4) + { + case 0: + sub_802DE1C(); + gUnknown_02022D00->unk4++; + break; + case 1: + if (!IsDma3ManagerBusyWithBgCopy()) + { + sub_802DF70(0); + gUnknown_02022D00->unk4++; + } + break; + case 2: + if (!IsDma3ManagerBusyWithBgCopy()) + { + sub_802DFD4(); + gUnknown_02022D00->unk4++; + } + break; + case 3: + if (!IsDma3ManagerBusyWithBgCopy()) + gUnknown_02022D00->unk0 = 1; + break; + } +} + +void sub_802D350(void) +{ + switch (gUnknown_02022D00->unk4) + { + case 0: + sub_802DE1C(); + gUnknown_02022D00->unk4++; + break; + case 1: + if (!IsDma3ManagerBusyWithBgCopy()) + { + sub_802DF70(1); + gUnknown_02022D00->unk4++; + } + break; + case 2: + if (!IsDma3ManagerBusyWithBgCopy()) + { + sub_802DFD4(); + gUnknown_02022D00->unk4++; + } + break; + case 3: + if (!IsDma3ManagerBusyWithBgCopy()) + gUnknown_02022D00->unk0 = 1; + break; + } +} + +void sub_802D3BC(void) +{ + int i, numPlayers; + + numPlayers = sub_802C8AC(); + switch (gUnknown_02022D00->unk4) + { + case 0: + for (i = 0; i < numPlayers; i++) + ClearWindowTilemap(gUnknown_02022D00->unk1C[i]); + + CopyBgTilemapBufferToVram(0); + gUnknown_02022D00->unk4++; + break; + case 1: + if (!IsDma3ManagerBusyWithBgCopy()) + { + for (i = 0; i < numPlayers; i++) + RemoveWindow(gUnknown_02022D00->unk1C[i]); + + gUnknown_02022D00->unk0 = 1; + } + break; + } +} + +void sub_802D448(void) +{ + switch (gUnknown_02022D00->unk4) + { + case 0: + gUnknown_02022D00->unk12 = sub_802DA9C(1, 8, 20, 2); + AddTextPrinterParameterized(gUnknown_02022D00->unk12, 1, gText_WantToPlayAgain2, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(gUnknown_02022D00->unk12, 2); + gUnknown_02022D00->unk4++; + break; + case 1: + if (!IsDma3ManagerBusyWithBgCopy()) + { + PutWindowTilemap(gUnknown_02022D00->unk12); + DrawTextBorderOuter(gUnknown_02022D00->unk12, 1, 14); + sub_802DB18(23, 7, 0); + CopyBgTilemapBufferToVram(0); + gUnknown_02022D00->unk4++; + } + break; + case 2: + if (!IsDma3ManagerBusyWithBgCopy()) + gUnknown_02022D00->unk0 = 1; + break; + } +} + +void sub_802D4F4(void) +{ + switch (gUnknown_02022D00->unk4) + { + case 0: + gUnknown_02022D00->unk12 = sub_802DA9C(2, 7, 26, 4); + AddTextPrinterParameterized(gUnknown_02022D00->unk12, 1, gText_SavingDontTurnOffPower, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(gUnknown_02022D00->unk12, 2); + gUnknown_02022D00->unk4++; + break; + case 1: + if (!IsDma3ManagerBusyWithBgCopy()) + { + PutWindowTilemap(gUnknown_02022D00->unk12); + DrawTextBorderOuter(gUnknown_02022D00->unk12, 1, 14); + CopyBgTilemapBufferToVram(0); + gUnknown_02022D00->unk4++; + } + break; + case 2: + if (!IsDma3ManagerBusyWithBgCopy()) + gUnknown_02022D00->unk0 = 1; + break; + } +} + +void sub_802D598(void) +{ + switch (gUnknown_02022D00->unk4) + { + case 0: + sub_802DA14(); + sub_8198C78(); + CopyBgTilemapBufferToVram(0); + gUnknown_02022D00->unk4++; + break; + case 1: + if (!sub_802DA44() && !IsDma3ManagerBusyWithBgCopy()) + gUnknown_02022D00->unk0 = 1; + break; + } +} + +void sub_802D5E4(void) +{ + switch (gUnknown_02022D00->unk4) + { + case 0: + gUnknown_02022D00->unk12 = sub_802DA9C(2, 8, 22, 4); + AddTextPrinterParameterized(gUnknown_02022D00->unk12, 1, gText_SomeoneDroppedOut2, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(gUnknown_02022D00->unk12, 2); + gUnknown_02022D00->unk4++; + break; + case 1: + if (!IsDma3ManagerBusyWithBgCopy()) + { + PutWindowTilemap(gUnknown_02022D00->unk12); + DrawTextBorderOuter(gUnknown_02022D00->unk12, 1, 14); + CopyBgTilemapBufferToVram(0); + gUnknown_02022D00->unk4++; + } + break; + case 2: + if (!IsDma3ManagerBusyWithBgCopy()) + gUnknown_02022D00->unk0 = 1; + break; + } +} + +void sub_802D688(void) +{ + switch (gUnknown_02022D00->unk4) + { + case 0: + gUnknown_02022D00->unk12 = sub_802DA9C(7, 10, 16, 2); + AddTextPrinterParameterized(gUnknown_02022D00->unk12, 1, gText_CommunicationStandby4, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(gUnknown_02022D00->unk12, 2); + gUnknown_02022D00->unk4++; + break; + case 1: + if (!IsDma3ManagerBusyWithBgCopy()) + { + PutWindowTilemap(gUnknown_02022D00->unk12); + DrawTextBorderOuter(gUnknown_02022D00->unk12, 1, 14); + CopyBgTilemapBufferToVram(0); + gUnknown_02022D00->unk4++; + } + break; + case 2: + if (!IsDma3ManagerBusyWithBgCopy()) + gUnknown_02022D00->unk0 = 1; + break; + } +} + +void sub_802D72C(void) +{ + switch (gUnknown_02022D00->unk4) + { + case 0: + sub_802D044(gUnknown_02022D00); + gUnknown_02022D00->unk4++; + break; + case 1: + if (!sub_802D068()) + gUnknown_02022D00->unk0 = 1; + break; + } +} + +void sub_802D764(void) +{ + gUnknown_02022D00->unkA = 0; + gUnknown_02022D00->unkB = 0; + gUnknown_02022D00->unkC = 6; + sub_802DC9C(gUnknown_02022D00->unkC); +} + +bool32 sub_802D788(void) +{ + switch (gUnknown_02022D00->unkA) + { + case 0: + gUnknown_02022D00->unkB++; + if (gUnknown_02022D00->unkB > 10) + { + gUnknown_02022D00->unkB = 0; + gUnknown_02022D00->unkC++; + if (gUnknown_02022D00->unkC >= 10) + { + gUnknown_02022D00->unkC = 0; + gUnknown_02022D00->unkA++; + } + } + sub_802DC9C(gUnknown_02022D00->unkC); + if (gUnknown_02022D00->unkC != 7) + break; + case 1: + return FALSE; + } + + return TRUE; +} + +void sub_802D7E8(u16 itemId, u16 quantity) +{ + CopyItemNameHandlePlural(itemId, gUnknown_02022D00->txtBuff[0], quantity); + ConvertIntToDecimalStringN(gUnknown_02022D00->txtBuff[1], quantity, STR_CONV_MODE_LEFT_ALIGN, 1); + DynamicPlaceholderTextUtil_Reset(); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gUnknown_02022D00->txtBuff[0]); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gUnknown_02022D00->txtBuff[1]); + DynamicPlaceholderTextUtil_ExpandPlaceholders(gUnknown_02022D00->strBuff, gText_AwesomeWonF701F700); + gUnknown_02022D00->unk12 = sub_802DA9C(4, 8, 22, 4); + AddTextPrinterParameterized(gUnknown_02022D00->unk12, 1, gUnknown_02022D00->strBuff, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(gUnknown_02022D00->unk12, 2); + gUnknown_02022D00->unk14 = MUS_FANFA1; + gUnknown_02022D00->unkD = 0; +} + +void sub_802D884(u16 itemId) +{ + CopyItemName(itemId, gUnknown_02022D00->txtBuff[0]); + DynamicPlaceholderTextUtil_Reset(); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gUnknown_02022D00->txtBuff[0]); + DynamicPlaceholderTextUtil_ExpandPlaceholders(gUnknown_02022D00->strBuff, gText_FilledStorageSpace2); + gUnknown_02022D00->unk12 = sub_802DA9C(4, 8, 22, 4); + AddTextPrinterParameterized(gUnknown_02022D00->unk12, 1, gUnknown_02022D00->strBuff, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(gUnknown_02022D00->unk12, 2); + gUnknown_02022D00->unk14 = 0; + gUnknown_02022D00->unkD = 0; +} + +void sub_802D8FC(u16 itemId) +{ + CopyItemName(itemId, gUnknown_02022D00->txtBuff[0]); + DynamicPlaceholderTextUtil_Reset(); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gUnknown_02022D00->txtBuff[0]); + DynamicPlaceholderTextUtil_ExpandPlaceholders(gUnknown_02022D00->strBuff, gText_CantHoldMore); + gUnknown_02022D00->unk12 = sub_802DA9C(4, 9, 22, 2); + AddTextPrinterParameterized(gUnknown_02022D00->unk12, 1, gUnknown_02022D00->strBuff, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(gUnknown_02022D00->unk12, 2); + gUnknown_02022D00->unk14 = 0; + gUnknown_02022D00->unkD = 0; +} + +bool32 sub_802D974(void) +{ + switch (gUnknown_02022D00->unkD) + { + case 0: + if (!IsDma3ManagerBusyWithBgCopy()) + { + PutWindowTilemap(gUnknown_02022D00->unk12); + DrawTextBorderOuter(gUnknown_02022D00->unk12, 1, 14); + CopyBgTilemapBufferToVram(0); + gUnknown_02022D00->unkD++; + } + break; + case 1: + if (IsDma3ManagerBusyWithBgCopy()) + break; + if (gUnknown_02022D00->unk14 == 0) + { + gUnknown_02022D00->unkD += 2; + return FALSE; + } + PlayFanfare(gUnknown_02022D00->unk14); + gUnknown_02022D00->unkD++; + case 2: + if (!IsFanfareTaskInactive()) + break; + gUnknown_02022D00->unkD++; + case 3: + return FALSE; + } + + return TRUE; +} + +void sub_802DA14(void) +{ + if (gUnknown_02022D00->unk12 != 0xFF) + { + rbox_fill_rectangle(gUnknown_02022D00->unk12); + CopyWindowToVram(gUnknown_02022D00->unk12, 1); + gUnknown_02022D00->unkD = 0; + } +} + +// Can't match this +/* +bool32 sub_802DA44(void) +{ + if (gUnknown_02022D00->unk12 == 0xFF) + return FALSE; + + if (gUnknown_02022D00->unkD == 0) + { + if (!IsDma3ManagerBusyWithBgCopy()) + { + RemoveWindow(gUnknown_02022D00->unk12); + gUnknown_02022D00->unk12 = 0xFF; + gUnknown_02022D00->unkD++; + return FALSE; + } + } + else if (gUnknown_02022D00->unkD == 1) + return FALSE; + + return TRUE; +} +*/