From 78151b6d88d22bec6b7d0d450e4ecc1f94491192 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sun, 7 Apr 2019 13:07:23 -0500 Subject: [PATCH] Start decompiling pokemon_jump.c --- asm/pokemon_jump.s | 1247 ------------------------------------- data/pokemon_jump.s | 127 ---- include/constants/songs.h | 2 +- include/pokemon_jump.h | 10 + ld_script.txt | 2 + src/pokemon_jump.c | 838 +++++++++++++++++++++++++ src/union_room.c | 2 +- 7 files changed, 852 insertions(+), 1376 deletions(-) create mode 100755 include/pokemon_jump.h create mode 100755 src/pokemon_jump.c diff --git a/asm/pokemon_jump.s b/asm/pokemon_jump.s index e9aa9089d..3fc91c06b 100755 --- a/asm/pokemon_jump.s +++ b/asm/pokemon_jump.s @@ -5,1253 +5,6 @@ .text - thumb_func_start sub_802A9A8 -sub_802A9A8: @ 802A9A8 - push {r4-r7,lr} - adds r6, r1, 0 - lsls r0, 16 - lsrs r7, r0, 16 - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - beq _0802AA3C - ldr r5, =gUnknown_02022CFC - ldr r0, =0x000083b0 - bl Alloc - str r0, [r5] - cmp r0, 0 - beq _0802AA3C - bl ResetTasks - ldr r0, =sub_802ACA0 - movs r1, 0x1 - bl CreateTask - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, [r5] - movs r1, 0 - strh r1, [r0, 0x8] - str r6, [r0] - strb r4, [r0, 0x4] - bl GetMultiplayerId - ldr r1, [r5] - strb r0, [r1, 0x6] - ldr r0, [r5] - ldrb r2, [r0, 0x6] - lsls r1, r2, 1 - adds r1, r2 - lsls r1, 2 - ldr r2, =0x000082a8 - adds r1, r2 - adds r0, r1 - movs r1, 0x64 - muls r1, r7 - ldr r2, =gPlayerParty - adds r1, r2 - bl sub_802AC2C - ldr r0, [r5] - bl sub_802AA60 - ldr r2, [r5] - adds r0, r4, 0 - movs r1, 0x2 - bl SetWordTaskArg - ldr r0, =sub_802AC6C - bl SetMainCallback2 - b _0802AA42 - .pool -_0802AA3C: - adds r0, r6, 0 - bl SetMainCallback2 -_0802AA42: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_802A9A8 - - thumb_func_start sub_802AA48 -sub_802AA48: @ 802AA48 - push {lr} - bl sub_802D0AC - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - bl Free - pop {r0} - bx r0 - .pool - thumb_func_end sub_802AA48 - - thumb_func_start sub_802AA60 -sub_802AA60: @ 802AA60 - push {r4,lr} - adds r4, r0, 0 - bl GetLinkPlayerCount - movs r2, 0 - strb r0, [r4, 0x5] - adds r1, r4, 0 - adds r1, 0x70 - movs r0, 0x5 - strb r0, [r1] - adds r0, r4, 0 - adds r0, 0x72 - strh r2, [r0] - bl sub_802AB20 - adds r0, r4, 0 - bl sub_802AA94 - ldrb r0, [r4, 0x5] - cmp r0, 0x5 - bne _0802AA8E - bl sub_802E3A8 -_0802AA8E: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_802AA60 - - thumb_func_start sub_802AA94 -sub_802AA94: @ 802AA94 - push {r4-r6,lr} - adds r4, r0, 0 - movs r0, 0x6 - str r0, [r4, 0x14] - str r0, [r4, 0x18] - adds r0, r4, 0 - adds r0, 0x4A - movs r6, 0 - movs r5, 0 - strh r5, [r0] - str r5, [r4, 0x1C] - str r5, [r4, 0x5C] - bl GetMultiplayerId - movs r1, 0 - lsls r0, 24 - cmp r0, 0 - bne _0802AABA - movs r1, 0x1 -_0802AABA: - adds r0, r4, 0 - adds r0, 0x47 - strb r1, [r0] - strh r5, [r4, 0x8] - strh r5, [r4, 0xA] - strh r5, [r4, 0xC] - strh r5, [r4, 0xE] - str r5, [r4, 0x58] - strh r5, [r4, 0x3A] - subs r0, 0x3 - strb r6, [r0] - str r5, [r4, 0x54] - adds r0, 0x2 - strb r6, [r0] - adds r0, 0x3 - strb r6, [r0] - subs r0, 0x1 - movs r1, 0x1 - strb r1, [r0] - str r5, [r4, 0x78] - adds r0, 0x29 - strb r6, [r0] - adds r0, 0x3 - strh r5, [r0] - str r1, [r4, 0x60] - subs r0, 0x27 - strb r6, [r0] - str r5, [r4, 0x68] - str r5, [r4, 0x64] - str r5, [r4, 0x2C] - str r5, [r4, 0x30] - bl sub_802AB98 - bl sub_802C0E8 - movs r2, 0 - adds r5, r4, 0 - adds r5, 0x7C - movs r3, 0 - adds r1, r4, 0 - adds r1, 0x9A -_0802AB0C: - adds r0, r5, r2 - strb r3, [r0] - strh r3, [r1] - adds r1, 0x2 - adds r2, 0x1 - cmp r2, 0x4 - ble _0802AB0C - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_802AA94 - - thumb_func_start sub_802AB20 -sub_802AB20: @ 802AB20 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r7, =gUnknown_02022CFC - movs r6, 0 - movs r5, 0 - ldr r0, =gPkmnJumpSpecies - mov r8, r0 - movs r4, 0x4 -_0802AB32: - ldr r0, [r7] - adds r0, r5 - ldr r1, =0x000082a8 - adds r0, r1 - ldrh r0, [r0] - bl sub_802AC00 - lsls r0, 16 - ldr r1, [r7] - adds r1, r6 - asrs r0, 14 - add r0, r8 - ldrh r0, [r0, 0x2] - ldr r2, =0x000082f0 - adds r1, r2 - strh r0, [r1] - adds r6, 0x28 - adds r5, 0xC - subs r4, 0x1 - cmp r4, 0 - bge _0802AB32 - ldr r0, =gUnknown_02022CFC - ldr r1, [r0] - ldr r0, =0x000083ac - adds r3, r1, r0 - ldrb r2, [r1, 0x6] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r2, =0x000082e4 - adds r0, r2 - adds r1, r0 - str r1, [r3] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802AB20 - - thumb_func_start sub_802AB98 -sub_802AB98: @ 802AB98 - push {r4-r7,lr} - movs r5, 0 - ldr r6, =gUnknown_02022CFC - movs r4, 0 - movs r3, 0 -_0802ABA2: - ldr r2, [r6] - adds r1, r2, r3 - ldr r7, =0x000082f2 - adds r0, r1, r7 - strh r4, [r0] - adds r7, 0x2 - adds r0, r1, r7 - strh r4, [r0] - ldr r0, =0x000082f6 - adds r1, r0 - strh r4, [r1] - ldr r1, =0x000082e4 - adds r0, r2, r1 - adds r0, r3 - str r4, [r0] - subs r7, 0xC - adds r0, r2, r7 - adds r0, r3 - ldr r1, =0x7fffffff - str r1, [r0] - ldr r1, =0x000082f8 - adds r0, r2, r1 - adds r0, r3 - str r4, [r0] - adds r2, 0x8B - adds r2, r5 - movs r0, 0x9 - strb r0, [r2] - adds r3, 0x28 - adds r5, 0x1 - cmp r5, 0x4 - ble _0802ABA2 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802AB98 - - thumb_func_start sub_802AC00 -sub_802AC00: @ 802AC00 - push {lr} - lsls r0, 16 - lsrs r3, r0, 16 - movs r1, 0 - ldr r2, =gPkmnJumpSpecies -_0802AC0A: - ldrh r0, [r2] - cmp r0, r3 - bne _0802AC1C - lsls r0, r1, 16 - asrs r0, 16 - b _0802AC28 - .pool -_0802AC1C: - adds r2, 0x4 - adds r1, 0x1 - cmp r1, 0x63 - bls _0802AC0A - movs r0, 0x1 - negs r0, r0 -_0802AC28: - pop {r1} - bx r1 - thumb_func_end sub_802AC00 - - thumb_func_start sub_802AC2C -sub_802AC2C: @ 802AC2C - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - strh r0, [r5] - adds r0, r4, 0 - movs r1, 0x1 - bl GetMonData - str r0, [r5, 0x4] - adds r0, r4, 0 - movs r1, 0 - bl GetMonData - str r0, [r5, 0x8] - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_802AC2C - - thumb_func_start sub_802AC58 -sub_802AC58: @ 802AC58 - push {lr} - bl TransferPlttBuffer - bl LoadOam - bl ProcessSpriteCopyRequests - pop {r0} - bx r0 - thumb_func_end sub_802AC58 - - thumb_func_start sub_802AC6C -sub_802AC6C: @ 802AC6C - push {lr} - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end sub_802AC6C - - thumb_func_start sub_802AC84 -sub_802AC84: @ 802AC84 - push {lr} - movs r1, 0x1 - bl CreateTask - ldr r2, =gUnknown_02022CFC - ldr r1, [r2] - movs r3, 0 - strb r0, [r1, 0x4] - ldr r0, [r2] - strh r3, [r0, 0x8] - pop {r0} - bx r0 - .pool - thumb_func_end sub_802AC84 - - thumb_func_start sub_802ACA0 -sub_802ACA0: @ 802ACA0 - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_02022CFC - ldr r0, [r1] - ldrh r0, [r0, 0x8] - adds r2, r1, 0 - cmp r0, 0x5 - bls _0802ACB6 - b _0802AE08 -_0802ACB6: - lsls r0, 2 - ldr r1, =_0802ACC8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0802ACC8: - .4byte _0802ACE0 - .4byte _0802AD0C - .4byte _0802AD3C - .4byte _0802AD68 - .4byte _0802ADA4 - .4byte _0802ADD0 -_0802ACE0: - movs r0, 0 - bl SetVBlankCallback - bl ResetSpriteData - bl FreeAllSpritePalettes - ldr r0, =sub_802BD84 - movs r1, 0x5 - bl sub_802BE60 - movs r0, 0x4 - bl FadeOutMapMusic - ldr r0, =gUnknown_02022CFC - ldr r1, [r0] - b _0802ADC0 - .pool -_0802AD0C: - ldr r0, =sub_802BD84 - bl FuncIsActiveTask - lsls r0, 24 - cmp r0, 0 - bne _0802AE08 - ldr r4, =gUnknown_02022CFC - ldr r0, [r4] - adds r0, 0xA4 - bl sub_802D074 - bl sub_800E0E8 - movs r0, 0 - movs r1, 0 - bl CreateWirelessStatusIndicatorSprite - ldr r1, [r4] - b _0802ADC0 - .pool -_0802AD3C: - bl sub_802D0F0 - cmp r0, 0 - bne _0802AE08 - bl IsNotWaitingForBGMStop - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0802AE08 - ldr r0, =0x0000021a - movs r1, 0x8 - bl FadeOutAndPlayNewMapMusic - ldr r0, =gUnknown_02022CFC - ldr r1, [r0] - b _0802ADC0 - .pool -_0802AD68: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _0802AE08 - movs r4, 0x1 - negs r4, r4 - adds r0, r4, 0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - adds r1, r4, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r0, =sub_802AC58 - bl SetVBlankCallback - ldr r0, =gUnknown_02022CFC - ldr r1, [r0] - b _0802ADC0 - .pool -_0802ADA4: - bl UpdatePaletteFade - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0 - bne _0802AE08 - ldr r1, =gUnknown_02022CFC - ldr r0, [r1] - strb r2, [r0, 0x7] - ldr r1, [r1] -_0802ADC0: - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - b _0802AE08 - .pool -_0802ADD0: - ldr r0, [r2] - ldrb r1, [r0, 0x7] - adds r1, 0x1 - strb r1, [r0, 0x7] - ldr r1, [r2] - ldrb r0, [r1, 0x7] - cmp r0, 0x13 - bls _0802AE08 - adds r0, r1, 0 - adds r0, 0x47 - ldrb r0, [r0] - cmp r0, 0 - beq _0802ADF8 - ldr r0, =sub_802AF80 - bl sub_802AC84 - b _0802ADFE - .pool -_0802ADF8: - ldr r0, =sub_802B194 - bl sub_802AC84 -_0802ADFE: - bl sub_802BE80 - adds r0, r4, 0 - bl DestroyTask -_0802AE08: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802ACA0 - - thumb_func_start sub_802AE14 -sub_802AE14: @ 802AE14 - push {lr} - adds r1, r0, 0 - cmp r1, 0 - bne _0802AE34 - ldr r0, =gUnknown_02022CFC - ldr r1, [r0] - ldr r0, =0x00001111 - str r0, [r1, 0x30] - movs r0, 0x1 - str r0, [r1, 0x2C] - b _0802AE46 - .pool -_0802AE34: - ldr r0, =gUnknown_02022CFC - ldr r2, [r0] - subs r1, 0x1 - movs r0, 0x1 - lsls r0, r1 - subs r0, 0x1 - str r0, [r2, 0x30] - movs r0, 0 - str r0, [r2, 0x2C] -_0802AE46: - pop {r0} - bx r0 - .pool - thumb_func_end sub_802AE14 - - thumb_func_start sub_802AE50 -sub_802AE50: @ 802AE50 - push {r4-r6,lr} - ldr r4, =gUnknown_02022CFC - ldr r1, [r4] - adds r1, 0x70 - movs r2, 0 - strb r0, [r1] - ldr r0, [r4] - movs r3, 0 - strh r2, [r0, 0x8] - strh r2, [r0, 0xA] - adds r0, 0x48 - movs r1, 0x1 - strb r1, [r0] - ldr r0, [r4] - adds r0, 0x49 - strb r3, [r0] - movs r3, 0x1 - ldr r0, [r4] - ldrb r0, [r0, 0x5] - cmp r3, r0 - bge _0802AE94 - adds r6, r4, 0 - ldr r5, =0x000082fc - movs r4, 0 - movs r2, 0x28 -_0802AE82: - ldr r1, [r6] - adds r0, r1, r5 - adds r0, r2 - str r4, [r0] - adds r2, 0x28 - adds r3, 0x1 - ldrb r1, [r1, 0x5] - cmp r3, r1 - blt _0802AE82 -_0802AE94: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802AE50 - - thumb_func_start sub_802AEA4 -sub_802AEA4: @ 802AEA4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - movs r4, 0x1 - movs r0, 0 - str r0, [sp, 0x4] - ldr r7, =gUnknown_02022CFC - ldr r0, [r7] - ldrb r0, [r0, 0x5] - cmp r4, r0 - bge _0802AF48 - adds r1, r7, 0 - mov r10, r1 - movs r2, 0x2 - add r2, sp - mov r8, r2 - ldr r3, =0x0000830c - mov r9, r3 - movs r6, 0x28 -_0802AED0: - mov r1, r10 - ldr r0, [r1] - adds r1, r0, r6 - ldr r2, =0x000082f4 - adds r1, r2 - ldrh r5, [r1] - add r0, r9 - adds r1, r4, 0 - mov r2, sp - mov r3, r8 - bl sub_802E264 - cmp r0, 0 - beq _0802AF10 - ldr r2, [r7] - lsls r1, r4, 1 - adds r0, r2, 0 - adds r0, 0x90 - adds r0, r1 - mov r3, r8 - ldrh r1, [r3] - strh r1, [r0] - adds r2, 0x8B - adds r2, r4 - mov r0, sp - ldrb r0, [r0] - strb r0, [r2] - ldr r0, [r7] - adds r0, r6 - ldr r1, =0x000082f6 - adds r0, r1 - strh r5, [r0] -_0802AF10: - mov r2, r10 - ldr r1, [r2] - ldr r3, =0x000082fc - adds r0, r1, r3 - adds r0, r6 - ldr r0, [r0] - cmp r0, 0 - beq _0802AF36 - adds r0, r1, 0 - adds r0, 0x8B - adds r0, r4 - adds r1, 0x70 - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - bne _0802AF36 - ldr r0, [sp, 0x4] - adds r0, 0x1 - str r0, [sp, 0x4] -_0802AF36: - movs r1, 0x28 - add r9, r1 - adds r6, 0x28 - adds r4, 0x1 - ldr r7, =gUnknown_02022CFC - ldr r0, [r7] - ldrb r0, [r0, 0x5] - cmp r4, r0 - blt _0802AED0 -_0802AF48: - ldr r2, =gUnknown_02022CFC - ldr r1, [r2] - ldrb r0, [r1, 0x5] - subs r0, 0x1 - ldr r3, [sp, 0x4] - cmp r3, r0 - bne _0802AF5C - adds r1, 0x49 - movs r0, 0x1 - strb r0, [r1] -_0802AF5C: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802AEA4 - - thumb_func_start sub_802AF80 -sub_802AF80: @ 802AF80 - push {r4,r5,lr} - bl sub_802AEA4 - bl sub_802C43C - ldr r0, =gUnknown_02022CFC - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x48 - ldrb r0, [r0] - cmp r0, 0 - bne _0802AFB2 - adds r0, r1, 0 - adds r0, 0x49 - ldrb r0, [r0] - cmp r0, 0 - beq _0802AFB2 - adds r0, r1, 0 - adds r0, 0x4C - ldrb r0, [r0] - bl sub_802AE50 - movs r0, 0x3 - bl sub_802AE14 -_0802AFB2: - ldr r4, =gUnknown_02022CFC - ldr r2, [r4] - adds r0, r2, 0 - adds r0, 0x48 - ldrb r5, [r0] - cmp r5, 0x1 - bne _0802AFEE - ldr r1, =gUnknown_082FB5F4 - adds r0, 0x28 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 - adds r1, r0, 0 - cmp r1, 0 - bne _0802AFEE - ldr r0, [r4] - adds r0, 0x48 - strb r1, [r0] - ldr r1, [r4] - ldrb r2, [r1, 0x6] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r2, =0x000082fc - adds r1, r2 - adds r1, r0 - str r5, [r1] -_0802AFEE: - bl sub_802C1DC - bl sub_802B008 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802AF80 - - thumb_func_start sub_802B008 -sub_802B008: @ 802B008 - push {r4,lr} - ldr r4, =gUnknown_02022CFC - ldr r1, [r4] - ldr r0, [r1, 0x2C] - cmp r0, 0 - bne _0802B01E - ldr r2, =0x000082e4 - adds r0, r1, r2 - adds r1, 0x70 - bl sub_802E138 -_0802B01E: - ldr r1, [r4] - ldr r2, [r1, 0x30] - ldr r0, =0x00001111 - cmp r2, r0 - beq _0802B030 - ldr r0, [r1, 0x2C] - adds r0, 0x1 - ands r0, r2 - str r0, [r1, 0x2C] -_0802B030: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802B008 - - thumb_func_start sub_802B044 -sub_802B044: @ 802B044 - ldr r2, =gUnknown_02022CFC - ldr r1, [r2] - adds r1, 0x70 - movs r3, 0 - strb r0, [r1] - ldr r0, [r2] - strh r3, [r0, 0x8] - strh r3, [r0, 0xA] - adds r0, 0x48 - movs r1, 0x1 - strb r1, [r0] - ldr r1, [r2] - ldrb r2, [r1, 0x6] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r2, =0x000082fc - adds r1, r2 - adds r1, r0 - str r3, [r1] - bx lr - .pool - thumb_func_end sub_802B044 - - thumb_func_start sub_802B078 -sub_802B078: @ 802B078 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x10 - ldr r4, =gUnknown_02022CFC - ldr r0, [r4] - ldr r2, =0x000082f4 - adds r1, r0, r2 - ldrh r1, [r1] - mov r8, r1 - ldr r3, =0x000082e4 - adds r0, r3 - mov r1, sp - bl sub_802E1BC - cmp r0, 0 - beq _0802B128 - ldr r2, [r4] - ldrb r0, [r2, 0x6] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r3, =0x000082fc - adds r0, r2, r3 - adds r0, r1 - ldr r0, [r0] - cmp r0, 0x1 - bne _0802B0C6 - mov r0, sp - adds r1, r2, 0 - adds r1, 0x70 - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - beq _0802B0C6 - mov r0, sp - ldrb r0, [r0] - bl sub_802B044 -_0802B0C6: - ldr r3, =gUnknown_02022CFC - ldr r2, [r3] - ldr r0, [r2, 0x78] - ldr r1, [sp, 0x8] - cmp r0, r1 - beq _0802B108 - str r1, [r2, 0x78] - movs r4, 0x1 - str r4, [r2, 0x5C] - mov r0, sp - ldrb r1, [r0, 0x1] - adds r0, r2, 0 - adds r0, 0x71 - strb r1, [r0] - ldr r0, [r3] - adds r1, r0, 0 - adds r1, 0x71 - ldrb r1, [r1] - cmp r1, 0 - beq _0802B104 - adds r0, 0x4D - strb r4, [r0] - b _0802B108 - .pool -_0802B104: - adds r0, 0x4D - strb r1, [r0] -_0802B108: - ldr r0, =gUnknown_02022CFC - ldr r1, [r0] - mov r0, sp - ldrh r0, [r0, 0x2] - adds r2, r1, 0 - adds r2, 0x72 - strh r0, [r2] - mov r0, sp - ldrh r2, [r0, 0x4] - adds r0, r1, 0 - adds r0, 0x74 - strh r2, [r0] - ldr r0, =0x000082f6 - adds r1, r0 - mov r2, r8 - strh r2, [r1] -_0802B128: - movs r4, 0x1 - ldr r2, =gUnknown_02022CFC - ldr r0, [r2] - ldrb r0, [r0, 0x5] - cmp r4, r0 - bge _0802B176 - adds r7, r2, 0 - ldr r6, =0x0000830c - movs r5, 0x28 -_0802B13A: - ldr r1, [r7] - ldrb r3, [r1, 0x6] - cmp r4, r3 - beq _0802B168 - adds r0, r1, r5 - ldr r3, =0x000082f4 - adds r0, r3 - ldrh r0, [r0] - mov r8, r0 - adds r0, r1, r6 - adds r1, r4, 0 - str r2, [sp, 0xC] - bl sub_802E2D0 - ldr r2, [sp, 0xC] - cmp r0, 0 - beq _0802B168 - ldr r0, [r7] - adds r0, r5 - ldr r1, =0x000082f6 - adds r0, r1 - mov r3, r8 - strh r3, [r0] -_0802B168: - adds r6, 0x28 - adds r5, 0x28 - adds r4, 0x1 - ldr r0, [r2] - ldrb r0, [r0, 0x5] - cmp r4, r0 - blt _0802B13A -_0802B176: - add sp, 0x10 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802B078 - - thumb_func_start sub_802B194 -sub_802B194: @ 802B194 - push {r4,lr} - bl sub_802B078 - ldr r4, =gUnknown_02022CFC - ldr r2, [r4] - adds r0, r2, 0 - adds r0, 0x48 - ldrb r0, [r0] - cmp r0, 0 - beq _0802B1E0 - ldr r1, =gUnknown_082FB618 - adds r0, r2, 0 - adds r0, 0x70 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 - adds r1, r0, 0 - cmp r1, 0 - bne _0802B1E0 - ldr r0, [r4] - adds r0, 0x48 - strb r1, [r0] - ldr r1, [r4] - ldrb r2, [r1, 0x6] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r2, =0x000082fc - adds r1, r2 - adds r1, r0 - movs r0, 0x1 - str r0, [r1] - movs r0, 0x3 - bl sub_802AE14 -_0802B1E0: - bl sub_802C1DC - bl sub_802B1FC - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802B194 - - thumb_func_start sub_802B1FC -sub_802B1FC: @ 802B1FC - push {r4,lr} - ldr r4, =gUnknown_02022CFC - ldr r2, [r4] - ldr r0, [r2, 0x2C] - cmp r0, 0 - bne _0802B224 - ldrb r1, [r2, 0x6] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - ldr r1, =0x000082e4 - adds r0, r1 - adds r0, r2, r0 - adds r1, r2, 0 - adds r1, 0x70 - ldrb r1, [r1] - adds r2, 0x42 - ldrh r2, [r2] - bl sub_802E234 -_0802B224: - ldr r1, [r4] - ldr r2, [r1, 0x30] - ldr r0, =0x00001111 - cmp r2, r0 - beq _0802B236 - ldr r0, [r1, 0x2C] - adds r0, 0x1 - ands r0, r2 - str r0, [r1, 0x2C] -_0802B236: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802B1FC - - thumb_func_start sub_802B248 -sub_802B248: @ 802B248 - push {r4,lr} - ldr r4, =gUnknown_02022CFC - ldr r0, [r4] - ldrh r0, [r0, 0x8] - cmp r0, 0 - beq _0802B260 - cmp r0, 0x1 - beq _0802B26E - b _0802B294 - .pool -_0802B260: - movs r0, 0x3 - bl sub_802AE14 - ldr r1, [r4] - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] -_0802B26E: - bl sub_802B7E0 - cmp r0, 0 - bne _0802B294 - ldr r0, =gUnknown_02022CFC - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x4A - ldrh r0, [r0] - adds r2, r1, 0 - adds r2, 0x72 - strh r0, [r2] - adds r1, 0x4C - movs r0, 0x1 - strb r0, [r1] - movs r0, 0 - b _0802B296 - .pool -_0802B294: - movs r0, 0x1 -_0802B296: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_802B248 - - thumb_func_start sub_802B29C -sub_802B29C: @ 802B29C - push {r4,lr} - ldr r4, =gUnknown_02022CFC - ldr r0, [r4] - ldrh r0, [r0, 0x8] - cmp r0, 0 - beq _0802B2B4 - cmp r0, 0x1 - beq _0802B2CA - movs r0, 0x1 - b _0802B2CE - .pool -_0802B2B4: - movs r0, 0 - bl sub_802AE14 - ldr r1, [r4] - adds r0, r1, 0 - adds r0, 0x72 - ldrh r0, [r0] - str r0, [r1, 0x24] - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] -_0802B2CA: - bl sub_802B7E0 -_0802B2CE: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_802B29C - - thumb_func_start sub_802B2D4 -sub_802B2D4: @ 802B2D4 - push {r4,lr} - ldr r4, =gUnknown_02022CFC - ldr r1, [r4] - ldrh r0, [r1, 0x8] - cmp r0, 0 - beq _0802B2EC - cmp r0, 0x1 - beq _0802B300 - b _0802B314 - .pool -_0802B2EC: - bl sub_802C0E8 - movs r0, 0x5 - bl sub_802AE14 - ldr r1, [r4] - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - b _0802B314 -_0802B300: - adds r0, r1, 0 - adds r0, 0x49 - ldrb r0, [r0] - cmp r0, 0 - beq _0802B314 - adds r1, 0x4C - movs r0, 0x2 - strb r0, [r1] - movs r0, 0 - b _0802B316 -_0802B314: - movs r0, 0x1 -_0802B316: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_802B2D4 - - thumb_func_start sub_802B31C -sub_802B31C: @ 802B31C - push {r4,lr} - ldr r4, =gUnknown_02022CFC - ldr r0, [r4] - ldrh r0, [r0, 0x8] - cmp r0, 0 - beq _0802B334 - cmp r0, 0x1 - beq _0802B352 - b _0802B35E - .pool -_0802B334: - bl sub_802C0E8 - movs r0, 0 - bl sub_802AE14 - ldr r1, [r4] - adds r0, r1, 0 - adds r0, 0x72 - ldrh r0, [r0] - adds r2, r1, 0 - adds r2, 0x4A - strh r0, [r2] - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] -_0802B352: - bl sub_802C70C - cmp r0, 0 - beq _0802B35E - movs r0, 0 - b _0802B360 -_0802B35E: - movs r0, 0x1 -_0802B360: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_802B31C - - thumb_func_start sub_802B368 -sub_802B368: @ 802B368 - push {lr} - bl sub_802B8CC - cmp r0, 0 - bne _0802B390 - ldr r0, =gUnknown_02022CFC - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x4A - ldrh r0, [r0] - adds r2, r1, 0 - adds r2, 0x72 - strh r0, [r2] - adds r1, 0x4C - movs r0, 0x1 - strb r0, [r1] - b _0802B3AA - .pool -_0802B390: - bl sub_802C538 - cmp r0, 0 - beq _0802B39C - movs r0, 0x1 - b _0802B3AC -_0802B39C: - bl sub_802C0B8 - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - adds r0, 0x4C - movs r1, 0x3 - strb r1, [r0] -_0802B3AA: - movs r0, 0 -_0802B3AC: - pop {r1} - bx r1 - .pool - thumb_func_end sub_802B368 - - thumb_func_start sub_802B3B4 -sub_802B3B4: @ 802B3B4 - push {lr} - bl sub_802B8CC - cmp r0, 0 - beq _0802B3CE - bl sub_802C538 - cmp r0, 0 - beq _0802B3CA - movs r0, 0x1 - b _0802B3D0 -_0802B3CA: - bl sub_802C0B8 -_0802B3CE: - movs r0, 0 -_0802B3D0: - pop {r1} - bx r1 - thumb_func_end sub_802B3B4 - thumb_func_start sub_802B3D4 sub_802B3D4: @ 802B3D4 push {r4,lr} diff --git a/data/pokemon_jump.s b/data/pokemon_jump.s index 8ef0201e4..362965053 100755 --- a/data/pokemon_jump.s +++ b/data/pokemon_jump.s @@ -4,133 +4,6 @@ .section .rodata - .align 2 -gPkmnJumpSpecies:: @ 82FB464 - .2byte SPECIES_BULBASAUR, 0x0002 - .2byte SPECIES_CHARMANDER, 0x0001 - .2byte SPECIES_SQUIRTLE, 0x0000 - .2byte SPECIES_CATERPIE, 0x0001 - .2byte SPECIES_METAPOD, 0x0001 - .2byte SPECIES_WEEDLE, 0x0001 - .2byte SPECIES_KAKUNA, 0x0001 - .2byte SPECIES_RATTATA, 0x0001 - .2byte SPECIES_RATICATE, 0x0001 - .2byte SPECIES_PIKACHU, 0x0000 - .2byte SPECIES_SANDSHREW, 0x0000 - .2byte SPECIES_NIDORAN_F, 0x0000 - .2byte SPECIES_NIDORAN_M, 0x0000 - .2byte SPECIES_CLEFAIRY, 0x0000 - .2byte SPECIES_VULPIX, 0x0000 - .2byte SPECIES_JIGGLYPUFF, 0x0002 - .2byte SPECIES_ODDISH, 0x0002 - .2byte SPECIES_PARAS, 0x0001 - .2byte SPECIES_MEOWTH, 0x0000 - .2byte SPECIES_PSYDUCK, 0x0002 - .2byte SPECIES_MANKEY, 0x0001 - .2byte SPECIES_GROWLITHE, 0x0001 - .2byte SPECIES_POLIWAG, 0x0002 - .2byte SPECIES_BELLSPROUT, 0x0002 - .2byte SPECIES_SHELLDER, 0x0001 - .2byte SPECIES_KRABBY, 0x0001 - .2byte SPECIES_EXEGGCUTE, 0x0002 - .2byte SPECIES_CUBONE, 0x0000 - .2byte SPECIES_DITTO, 0x0002 - .2byte SPECIES_EEVEE, 0x0000 - .2byte SPECIES_OMANYTE, 0x0001 - .2byte SPECIES_KABUTO, 0x0001 - .2byte SPECIES_CHIKORITA, 0x0002 - .2byte SPECIES_CYNDAQUIL, 0x0001 - .2byte SPECIES_TOTODILE, 0x0000 - .2byte SPECIES_SPINARAK, 0x0001 - .2byte SPECIES_PICHU, 0x0000 - .2byte SPECIES_CLEFFA, 0x0000 - .2byte SPECIES_IGGLYBUFF, 0x0002 - .2byte SPECIES_TOGEPI, 0x0002 - .2byte SPECIES_MAREEP, 0x0000 - .2byte SPECIES_BELLOSSOM, 0x0002 - .2byte SPECIES_MARILL, 0x0002 - .2byte SPECIES_SUNKERN, 0x0002 - .2byte SPECIES_WOOPER, 0x0002 - .2byte SPECIES_PINECO, 0x0002 - .2byte SPECIES_SNUBBULL, 0x0000 - .2byte SPECIES_SHUCKLE, 0x0002 - .2byte SPECIES_TEDDIURSA, 0x0000 - .2byte SPECIES_SLUGMA, 0x0002 - .2byte SPECIES_SWINUB, 0x0000 - .2byte SPECIES_HOUNDOUR, 0x0001 - .2byte SPECIES_PHANPY, 0x0000 - .2byte SPECIES_PORYGON2, 0x0000 - .2byte SPECIES_TYROGUE, 0x0001 - .2byte SPECIES_SMOOCHUM, 0x0002 - .2byte SPECIES_ELEKID, 0x0001 - .2byte SPECIES_MAGBY, 0x0001 - .2byte SPECIES_LARVITAR, 0x0001 - .2byte SPECIES_TREECKO, 0x0001 - .2byte SPECIES_TORCHIC, 0x0002 - .2byte SPECIES_MUDKIP, 0x0000 - .2byte SPECIES_MARSHTOMP, 0x0000 - .2byte SPECIES_POOCHYENA, 0x0001 - .2byte SPECIES_ZIGZAGOON, 0x0000 - .2byte SPECIES_LINOONE, 0x0000 - .2byte SPECIES_WURMPLE, 0x0001 - .2byte SPECIES_SILCOON, 0x0002 - .2byte SPECIES_CASCOON, 0x0002 - .2byte SPECIES_LOTAD, 0x0002 - .2byte SPECIES_SEEDOT, 0x0001 - .2byte SPECIES_RALTS, 0x0000 - .2byte SPECIES_KIRLIA, 0x0000 - .2byte SPECIES_SURSKIT, 0x0002 - .2byte SPECIES_SHROOMISH, 0x0002 - .2byte SPECIES_NINCADA, 0x0001 - .2byte SPECIES_WHISMUR, 0x0000 - .2byte SPECIES_AZURILL, 0x0002 - .2byte SPECIES_SKITTY, 0x0000 - .2byte SPECIES_SABLEYE, 0x0000 - .2byte SPECIES_MAWILE, 0x0000 - .2byte SPECIES_ARON, 0x0001 - .2byte SPECIES_MEDITITE, 0x0002 - .2byte SPECIES_ELECTRIKE, 0x0001 - .2byte SPECIES_PLUSLE, 0x0001 - .2byte SPECIES_MINUN, 0x0001 - .2byte SPECIES_VOLBEAT, 0x0000 - .2byte SPECIES_ILLUMISE, 0x0000 - .2byte SPECIES_ROSELIA, 0x0002 - .2byte SPECIES_GULPIN, 0x0002 - .2byte SPECIES_NUMEL, 0x0002 - .2byte SPECIES_TORKOAL, 0x0002 - .2byte SPECIES_SPOINK, 0x0000 - .2byte SPECIES_TRAPINCH, 0x0002 - .2byte SPECIES_CACNEA, 0x0002 - .2byte SPECIES_ANORITH, 0x0001 - .2byte SPECIES_WYNAUT, 0x0000 - .2byte SPECIES_SNORUNT, 0x0000 - .2byte SPECIES_CLAMPERL, 0x0001 - .2byte SPECIES_BAGON, 0x0001 - - .align 2 -gUnknown_082FB5F4:: @ 82FB5F4 - .4byte sub_802B248 - .4byte sub_802B2D4 - .4byte sub_802B368 - .4byte sub_802B3D4 - .4byte sub_802B4CC - .4byte sub_802B5C8 - .4byte sub_802B664 - .4byte sub_802B6B8 - .4byte sub_802B720 - - .align 2 -gUnknown_082FB618:: @ 82FB618 - .4byte sub_802B29C - .4byte sub_802B31C - .4byte sub_802B3B4 - .4byte sub_802B470 - .4byte sub_802B568 - .4byte sub_802B628 - .4byte sub_802B664 - .4byte sub_802B704 - .4byte sub_802B720 - .align 2 gUnknown_082FB63C:: @ 82FB63C .2byte 0x001a, 0x001f, 0x0024, 0x0029, 0x002e, 0x0033, 0x0038, 0x003d diff --git a/include/constants/songs.h b/include/constants/songs.h index 3778d5f08..b44c9f7a8 100644 --- a/include/constants/songs.h +++ b/include/constants/songs.h @@ -463,7 +463,7 @@ #define MUS_RG_SOUSA 535 // Starting Tutorial #define MUS_RG_SEKAIKAN 536 // Starting Tutorial 2 #define MUS_RG_SEIBETU 537 // Starting Tutorial 3 -#define MUS_RG_JUMP 538 // Jumping Minigame +#define MUS_RG_JUMP 538 // Pokemon Jump Minigame #define MUS_RG_UNION 539 // Union Room #define MUS_RG_NETWORK 540 // Network Center #define MUS_RG_OKURIMONO 541 // Mystery Gift diff --git a/include/pokemon_jump.h b/include/pokemon_jump.h new file mode 100755 index 000000000..95db6e404 --- /dev/null +++ b/include/pokemon_jump.h @@ -0,0 +1,10 @@ +#ifndef GUARD_POKEMON_JUMP_H +#define GUARD_POKEMON_JUMP_H + +#include "main.h" + +void sub_802A9A8(u16 monId, MainCallback callback); + +#endif // GUARD_POKEMON_JUMP_H + + diff --git a/ld_script.txt b/ld_script.txt index 8f44e0abf..918c41445 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -69,6 +69,7 @@ SECTIONS { asm/berry_crush.o(.text); src/berry_powder.o(.text); asm/dodrio_berry_picking.o(.text); + src/pokemon_jump.o(.text); asm/pokemon_jump.o(.text); src/rtc.o(.text); src/main_menu.o(.text); @@ -422,6 +423,7 @@ SECTIONS { data/berry_crush.o(.rodata); data/berry_powder.o(.rodata); data/dodrio_berry_picking.o(.rodata); + src/pokemon_jump.o(.rodata); data/pokemon_jump.o(.rodata); src/rtc.o(.rodata); src/main_menu.o(.rodata); diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c new file mode 100755 index 000000000..d49ee293b --- /dev/null +++ b/src/pokemon_jump.c @@ -0,0 +1,838 @@ +#include "global.h" +#include "alloc.h" +#include "link.h" +#include "main.h" +#include "palette.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" +#include "pokemon.h" +#include "pokemon_jump.h" +#include "constants/rgb.h" +#include "constants/songs.h" +#include "constants/species.h" + +struct PokemonJump1_MonInfo +{ + u16 species; + u32 otId; + u32 personality; +}; + +struct PokemonJump1_82E4 +{ + int unk0; + int unk4; + u8 filler8[0x4]; + u16 unkC; + u16 unkE; + u16 unk10; + u16 unk12; + int unk14; + int unk18; + u8 filler1C[0xC]; +}; + +struct PokemonJump1 +{ + MainCallback unk0; + u8 unk4; + u8 unk5; + u8 unk6; + u8 unk7; + u16 unk8; + u16 unkA; + u16 unkC; + u16 unkE; + u8 filler10[0x4]; + int unk14; + int unk18; + int unk1C; + u8 filler20[0x4]; + int unk24; + u8 filler28[0x4]; + int unk2C; + u32 unk30; + u8 filler34[0x6]; + u16 unk3A; + u8 filler3C[0x6]; + u16 unk42; + u8 unk44; + u8 filler45[0x1]; + u8 unk46; + u8 isLeader; + u8 unk48; + u8 unk49; + u16 unk4A; + u8 unk4C; + u8 unk4D; + u8 filler4E[0x6]; + int unk54; + int unk58; + int unk5C; + int unk60; + int unk64; + int unk68; + int unk6C; + u8 unk70; + u8 unk71; + u16 unk72; + u16 unk74; + int unk78; + u8 unk7C[5]; + u8 filler81[0xA]; + u8 unk8B[5]; + u16 unk90[5]; + u16 unk9A[5]; + void **unkA4; + u8 fillerA8[0x8200]; + struct PokemonJump1_MonInfo unk82A8[5]; + struct PokemonJump1_82E4 unk82E4[5]; + struct PokemonJump1_82E4 *unk83AC; +}; + +struct PokemonJumpMons +{ + u16 species; + u16 unk2; +}; + +struct Unk802B078 +{ + u8 unk0; + u8 unk1; + u16 unk2; + u16 unk4; + u16 unk6; + int unk8; +}; + +static void sub_802AA60(struct PokemonJump1 *); +void sub_802AA94(struct PokemonJump1 *); +void sub_802AB20(void); +static void sub_802AB98(void); +s16 sub_802AC00(u16); +static void sub_802AC2C(struct PokemonJump1_MonInfo *monInfo, struct Pokemon *mon); +static void sub_802AC6C(void); +static void sub_802ACA0(u8 taskId); +static void sub_802AF80(u8 taskId); +static void sub_802B008(void); +static void sub_802B194(u8 taskId); +static void sub_802B1FC(void); +bool32 sub_802B248(void); +bool32 sub_802B2D4(void); +bool32 sub_802B368(void); +bool32 sub_802B3D4(void); +bool32 sub_802B4CC(void); +bool32 sub_802B5C8(void); +bool32 sub_802B664(void); +bool32 sub_802B6B8(void); +bool32 sub_802B720(void); +bool32 sub_802B29C(void); +bool32 sub_802B31C(void); +bool32 sub_802B3B4(void); +bool32 sub_802B470(void); +bool32 sub_802B568(void); +bool32 sub_802B628(void); +bool32 sub_802B664(void); +bool32 sub_802B704(void); +bool32 sub_802B720(void); +bool32 sub_802B7E0(void); +bool32 sub_802B8CC(void); +void sub_802BD84(u8 taskId); +void sub_802BE60(TaskFunc func, u8 taskPriority); +void sub_802BE80(void); +void sub_802C0B8(void); +void sub_802C0E8(void); +void sub_802C1DC(void); +void sub_802C43C(void); +bool32 sub_802C538(void); +bool32 sub_802C70C(void); +void sub_802D074(void *); +void sub_802D0AC(void); +int sub_802D0F0(void); +void sub_802E138(struct PokemonJump1_82E4 *, u8 *); +bool32 sub_802E1BC(struct PokemonJump1_82E4 *, struct Unk802B078 *); +void sub_802E234(struct PokemonJump1_82E4 *, u8 , u16); +bool32 sub_802E264(struct PokemonJump1_82E4 *, int, u8 *, u16 *); +bool32 sub_802E2D0(struct PokemonJump1_82E4 *, int); +void sub_802E3A8(void); + +extern struct PokemonJump1 *gUnknown_02022CFC; + +const struct PokemonJumpMons gPkmnJumpSpecies[] = +{ + { .species = SPECIES_BULBASAUR, .unk2 = 2, }, + { .species = SPECIES_CHARMANDER, .unk2 = 1, }, + { .species = SPECIES_SQUIRTLE, .unk2 = 0, }, + { .species = SPECIES_CATERPIE, .unk2 = 1, }, + { .species = SPECIES_METAPOD, .unk2 = 1, }, + { .species = SPECIES_WEEDLE, .unk2 = 1, }, + { .species = SPECIES_KAKUNA, .unk2 = 1, }, + { .species = SPECIES_RATTATA, .unk2 = 1, }, + { .species = SPECIES_RATICATE, .unk2 = 1, }, + { .species = SPECIES_PIKACHU, .unk2 = 0, }, + { .species = SPECIES_SANDSHREW, .unk2 = 0, }, + { .species = SPECIES_NIDORAN_F, .unk2 = 0, }, + { .species = SPECIES_NIDORAN_M, .unk2 = 0, }, + { .species = SPECIES_CLEFAIRY, .unk2 = 0, }, + { .species = SPECIES_VULPIX, .unk2 = 0, }, + { .species = SPECIES_JIGGLYPUFF, .unk2 = 2, }, + { .species = SPECIES_ODDISH, .unk2 = 2, }, + { .species = SPECIES_PARAS, .unk2 = 1, }, + { .species = SPECIES_MEOWTH, .unk2 = 0, }, + { .species = SPECIES_PSYDUCK, .unk2 = 2, }, + { .species = SPECIES_MANKEY, .unk2 = 1, }, + { .species = SPECIES_GROWLITHE, .unk2 = 1, }, + { .species = SPECIES_POLIWAG, .unk2 = 2, }, + { .species = SPECIES_BELLSPROUT, .unk2 = 2, }, + { .species = SPECIES_SHELLDER, .unk2 = 1, }, + { .species = SPECIES_KRABBY, .unk2 = 1, }, + { .species = SPECIES_EXEGGCUTE, .unk2 = 2, }, + { .species = SPECIES_CUBONE, .unk2 = 0, }, + { .species = SPECIES_DITTO, .unk2 = 2, }, + { .species = SPECIES_EEVEE, .unk2 = 0, }, + { .species = SPECIES_OMANYTE, .unk2 = 1, }, + { .species = SPECIES_KABUTO, .unk2 = 1, }, + { .species = SPECIES_CHIKORITA, .unk2 = 2, }, + { .species = SPECIES_CYNDAQUIL, .unk2 = 1, }, + { .species = SPECIES_TOTODILE, .unk2 = 0, }, + { .species = SPECIES_SPINARAK, .unk2 = 1, }, + { .species = SPECIES_PICHU, .unk2 = 0, }, + { .species = SPECIES_CLEFFA, .unk2 = 0, }, + { .species = SPECIES_IGGLYBUFF, .unk2 = 2, }, + { .species = SPECIES_TOGEPI, .unk2 = 2, }, + { .species = SPECIES_MAREEP, .unk2 = 0, }, + { .species = SPECIES_BELLOSSOM, .unk2 = 2, }, + { .species = SPECIES_MARILL, .unk2 = 2, }, + { .species = SPECIES_SUNKERN, .unk2 = 2, }, + { .species = SPECIES_WOOPER, .unk2 = 2, }, + { .species = SPECIES_PINECO, .unk2 = 2, }, + { .species = SPECIES_SNUBBULL, .unk2 = 0, }, + { .species = SPECIES_SHUCKLE, .unk2 = 2, }, + { .species = SPECIES_TEDDIURSA, .unk2 = 0, }, + { .species = SPECIES_SLUGMA, .unk2 = 2, }, + { .species = SPECIES_SWINUB, .unk2 = 0, }, + { .species = SPECIES_HOUNDOUR, .unk2 = 1, }, + { .species = SPECIES_PHANPY, .unk2 = 0, }, + { .species = SPECIES_PORYGON2, .unk2 = 0, }, + { .species = SPECIES_TYROGUE, .unk2 = 1, }, + { .species = SPECIES_SMOOCHUM, .unk2 = 2, }, + { .species = SPECIES_ELEKID, .unk2 = 1, }, + { .species = SPECIES_MAGBY, .unk2 = 1, }, + { .species = SPECIES_LARVITAR, .unk2 = 1, }, + { .species = SPECIES_TREECKO, .unk2 = 1, }, + { .species = SPECIES_TORCHIC, .unk2 = 2, }, + { .species = SPECIES_MUDKIP, .unk2 = 0, }, + { .species = SPECIES_MARSHTOMP, .unk2 = 0, }, + { .species = SPECIES_POOCHYENA, .unk2 = 1, }, + { .species = SPECIES_ZIGZAGOON, .unk2 = 0, }, + { .species = SPECIES_LINOONE, .unk2 = 0, }, + { .species = SPECIES_WURMPLE, .unk2 = 1, }, + { .species = SPECIES_SILCOON, .unk2 = 2, }, + { .species = SPECIES_CASCOON, .unk2 = 2, }, + { .species = SPECIES_LOTAD, .unk2 = 2, }, + { .species = SPECIES_SEEDOT, .unk2 = 1, }, + { .species = SPECIES_RALTS, .unk2 = 0, }, + { .species = SPECIES_KIRLIA, .unk2 = 0, }, + { .species = SPECIES_SURSKIT, .unk2 = 2, }, + { .species = SPECIES_SHROOMISH, .unk2 = 2, }, + { .species = SPECIES_NINCADA, .unk2 = 1, }, + { .species = SPECIES_WHISMUR, .unk2 = 0, }, + { .species = SPECIES_AZURILL, .unk2 = 2, }, + { .species = SPECIES_SKITTY, .unk2 = 0, }, + { .species = SPECIES_SABLEYE, .unk2 = 0, }, + { .species = SPECIES_MAWILE, .unk2 = 0, }, + { .species = SPECIES_ARON, .unk2 = 1, }, + { .species = SPECIES_MEDITITE, .unk2 = 2, }, + { .species = SPECIES_ELECTRIKE, .unk2 = 1, }, + { .species = SPECIES_PLUSLE, .unk2 = 1, }, + { .species = SPECIES_MINUN, .unk2 = 1, }, + { .species = SPECIES_VOLBEAT, .unk2 = 0, }, + { .species = SPECIES_ILLUMISE, .unk2 = 0, }, + { .species = SPECIES_ROSELIA, .unk2 = 2, }, + { .species = SPECIES_GULPIN, .unk2 = 2, }, + { .species = SPECIES_NUMEL, .unk2 = 2, }, + { .species = SPECIES_TORKOAL, .unk2 = 2, }, + { .species = SPECIES_SPOINK, .unk2 = 0, }, + { .species = SPECIES_TRAPINCH, .unk2 = 2, }, + { .species = SPECIES_CACNEA, .unk2 = 2, }, + { .species = SPECIES_ANORITH, .unk2 = 1, }, + { .species = SPECIES_WYNAUT, .unk2 = 0, }, + { .species = SPECIES_SNORUNT, .unk2 = 0, }, + { .species = SPECIES_CLAMPERL, .unk2 = 1, }, + { .species = SPECIES_BAGON, .unk2 = 1, }, +}; + +bool32 (* const gUnknown_082FB5F4[])(void) = +{ + sub_802B248, + sub_802B2D4, + sub_802B368, + sub_802B3D4, + sub_802B4CC, + sub_802B5C8, + sub_802B664, + sub_802B6B8, + sub_802B720, +}; + +bool32 (* const gUnknown_082FB618[])(void) = +{ + sub_802B29C, + sub_802B31C, + sub_802B3B4, + sub_802B470, + sub_802B568, + sub_802B628, + sub_802B664, + sub_802B704, + sub_802B720, +}; + +void sub_802A9A8(u16 partyIndex, MainCallback callback) +{ + u8 taskId; + + if (gReceivedRemoteLinkPlayers) + { + gUnknown_02022CFC = Alloc(sizeof(*gUnknown_02022CFC)); + if (gUnknown_02022CFC) + { + ResetTasks(); + taskId = CreateTask(sub_802ACA0, 1); + gUnknown_02022CFC->unk8 = 0; + gUnknown_02022CFC->unk0 = callback; + gUnknown_02022CFC->unk4 = taskId; + gUnknown_02022CFC->unk6 = GetMultiplayerId(); + sub_802AC2C(&gUnknown_02022CFC->unk82A8[gUnknown_02022CFC->unk6], &gPlayerParty[partyIndex]); + sub_802AA60(gUnknown_02022CFC); + SetWordTaskArg(taskId, 2, (u32)gUnknown_02022CFC); + SetMainCallback2(sub_802AC6C); + return; + } + } + + SetMainCallback2(callback); +} + +void sub_802AA48(void) +{ + sub_802D0AC(); + Free(gUnknown_02022CFC); +} + +static void sub_802AA60(struct PokemonJump1 *arg0) +{ + arg0->unk5 = GetLinkPlayerCount(); + arg0->unk70 = 5; + arg0->unk72 = 0; + sub_802AB20(); + sub_802AA94(arg0); + if (arg0->unk5 == 5) + sub_802E3A8(); +} + +void sub_802AA94(struct PokemonJump1 *arg0) +{ + int i; + + arg0->unk14 = 6; + arg0->unk18 = 6; + arg0->unk4A = 0; + arg0->unk1C = 0; + arg0->unk5C = 0; + arg0->isLeader = GetMultiplayerId() == 0; + arg0->unk8 = 0; + arg0->unkA = 0; + arg0->unkC = 0; + arg0->unkE = 0; + arg0->unk58 = 0; + arg0->unk3A = 0; + arg0->unk44 = 0; + arg0->unk54 = 0; + arg0->unk46 = 0; + arg0->unk49 = 0; + arg0->unk48 = 1; + arg0->unk78 = 0; + arg0->unk71 = 0; + arg0->unk74 = 0; + arg0->unk60 = 1; + arg0->unk4D = 0; + arg0->unk68 = 0; + arg0->unk64 = 0; + arg0->unk2C = 0; + arg0->unk30 = 0; + sub_802AB98(); + sub_802C0E8(); + + for (i = 0; i < 5; i++) + { + arg0->unk7C[i] = 0; + arg0->unk9A[i] = 0; + } +} + +#ifdef NONMATCHING +void sub_802AB20(void) +{ + int i; + s16 index; + + for (i = 0; i < 5; i++) + { + index = sub_802AC00(gUnknown_02022CFC->unk82A8[i].species); + gUnknown_02022CFC->unk82E4[i].unkC = gPkmnJumpSpecies[index].unk2; + } + + gUnknown_02022CFC->unk83AC = &gUnknown_02022CFC->unk82E4[gUnknown_02022CFC->unk6]; +} +#else +NAKED +void sub_802AB20(void) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + ldr r7, =gUnknown_02022CFC\n\ + movs r6, 0\n\ + movs r5, 0\n\ + ldr r0, =gPkmnJumpSpecies\n\ + mov r8, r0\n\ + movs r4, 0x4\n\ +_0802AB32:\n\ + ldr r0, [r7]\n\ + adds r0, r5\n\ + ldr r1, =0x000082a8\n\ + adds r0, r1\n\ + ldrh r0, [r0]\n\ + bl sub_802AC00\n\ + lsls r0, 16\n\ + ldr r1, [r7]\n\ + adds r1, r6\n\ + asrs r0, 14\n\ + add r0, r8\n\ + ldrh r0, [r0, 0x2]\n\ + ldr r2, =0x000082f0\n\ + adds r1, r2\n\ + strh r0, [r1]\n\ + adds r6, 0x28\n\ + adds r5, 0xC\n\ + subs r4, 0x1\n\ + cmp r4, 0\n\ + bge _0802AB32\n\ + ldr r0, =gUnknown_02022CFC\n\ + ldr r1, [r0]\n\ + ldr r0, =0x000083ac\n\ + adds r3, r1, r0\n\ + ldrb r2, [r1, 0x6]\n\ + lsls r0, r2, 2\n\ + adds r0, r2\n\ + lsls r0, 3\n\ + ldr r2, =0x000082e4\n\ + adds r0, r2\n\ + adds r1, r0\n\ + str r1, [r3]\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool"); +} +#endif // NONMATCHING + +static void sub_802AB98(void) +{ + int i; + + for (i = 0; i < 5; i++) + { + gUnknown_02022CFC->unk82E4[i].unkE = 0; + gUnknown_02022CFC->unk82E4[i].unk10 = 0; + gUnknown_02022CFC->unk82E4[i].unk12 = 0; + gUnknown_02022CFC->unk82E4[i].unk0 = 0; + gUnknown_02022CFC->unk82E4[i].unk4 = 0x7FFFFFFF; + gUnknown_02022CFC->unk82E4[i].unk14 = 0; + gUnknown_02022CFC->unk8B[i] = 9; + } +} + +s16 sub_802AC00(u16 species) +{ + u32 i; + for (i = 0; i < ARRAY_COUNT(gPkmnJumpSpecies); i++) + { + if (gPkmnJumpSpecies[i].species == species) + return i; + } + + return -1; +} + +static void sub_802AC2C(struct PokemonJump1_MonInfo *monInfo, struct Pokemon *mon) +{ + monInfo->species = GetMonData(mon, MON_DATA_SPECIES); + monInfo->otId = GetMonData(mon, MON_DATA_OT_ID); + monInfo->personality = GetMonData(mon, MON_DATA_PERSONALITY); +} + +static void sub_802AC58(void) +{ + TransferPlttBuffer(); + LoadOam(); + ProcessSpriteCopyRequests(); +} + +static void sub_802AC6C(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +static void sub_802AC84(TaskFunc func) +{ + gUnknown_02022CFC->unk4 = CreateTask(func, 1); + gUnknown_02022CFC->unk8 = 0; +} + +static void sub_802ACA0(u8 taskId) +{ + switch (gUnknown_02022CFC->unk8) + { + case 0: + SetVBlankCallback(NULL); + ResetSpriteData(); + FreeAllSpritePalettes(); + sub_802BE60(sub_802BD84, 5); + FadeOutMapMusic(4); + gUnknown_02022CFC->unk8++; + break; + case 1: + if (!FuncIsActiveTask(sub_802BD84)) + { + sub_802D074(&gUnknown_02022CFC->unkA4); + sub_800E0E8(); + CreateWirelessStatusIndicatorSprite(0, 0); + gUnknown_02022CFC->unk8++; + } + break; + case 2: + if (!sub_802D0F0() && IsNotWaitingForBGMStop() == TRUE) + { + FadeOutAndPlayNewMapMusic(MUS_RG_JUMP, 8); + gUnknown_02022CFC->unk8++; + } + break; + case 3: + if (IsLinkTaskFinished()) + { + BlendPalettes(0xFFFFFFFF, 16, RGB_BLACK); + BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); + SetVBlankCallback(sub_802AC58); + gUnknown_02022CFC->unk8++; + } + break; + case 4: + UpdatePaletteFade(); + if (!gPaletteFade.active) + { + gUnknown_02022CFC->unk7 = 0; + gUnknown_02022CFC->unk8++; + } + break; + case 5: + gUnknown_02022CFC->unk7++; + if (gUnknown_02022CFC->unk7 >= 20) + { + if (gUnknown_02022CFC->isLeader) + sub_802AC84(sub_802AF80); + else + sub_802AC84(sub_802B194); + + sub_802BE80(); + DestroyTask(taskId); + } + break; + } +} + +void sub_802AE14(int arg0) +{ + if (arg0 == 0) + { + gUnknown_02022CFC->unk30 = 0x1111; + gUnknown_02022CFC->unk2C = 1; + } + else + { + gUnknown_02022CFC->unk30 = (1 << (arg0 - 1)) - 1; + gUnknown_02022CFC->unk2C = 0; + } +} + +static void sub_802AE50(u8 arg0) +{ + int i; + + gUnknown_02022CFC->unk70 = arg0; + gUnknown_02022CFC->unk8 = 0; + gUnknown_02022CFC->unkA = 0; + gUnknown_02022CFC->unk48 = 1; + gUnknown_02022CFC->unk49 = 0; + for (i = 1; i < gUnknown_02022CFC->unk5; i++) + gUnknown_02022CFC->unk82E4[i].unk18 = 0; +} + +static void sub_802AEA4(void) +{ + int i; + int count; + u16 var0; + u8 var1; + u16 var2; + + for (i = 1, count = 0; i < gUnknown_02022CFC->unk5; i++) + { + var0 = gUnknown_02022CFC->unk82E4[i].unk10; + if (sub_802E264(&gUnknown_02022CFC->unk82E4[i], i, &var1, &var2)) + { + gUnknown_02022CFC->unk90[i] = var2; + gUnknown_02022CFC->unk8B[i] = var1; + gUnknown_02022CFC->unk82E4[i].unk12 = var0; + } + + if (gUnknown_02022CFC->unk82E4[i].unk18 && gUnknown_02022CFC->unk8B[i] == gUnknown_02022CFC->unk70) + count++; + } + + if (count == gUnknown_02022CFC->unk5 - 1) + gUnknown_02022CFC->unk49 = 1; +} + +static void sub_802AF80(u8 taskId) +{ + sub_802AEA4(); + sub_802C43C(); + if (!gUnknown_02022CFC->unk48 && gUnknown_02022CFC->unk49) + { + sub_802AE50(gUnknown_02022CFC->unk4C); + sub_802AE14(3); + } + + if (gUnknown_02022CFC->unk48 == 1) + { + if (!gUnknown_082FB5F4[gUnknown_02022CFC->unk70]()) + { + gUnknown_02022CFC->unk48 = 0; + gUnknown_02022CFC->unk82E4[gUnknown_02022CFC->unk6].unk18 = 1; + } + } + + sub_802C1DC(); + sub_802B008(); +} + +static void sub_802B008(void) +{ + if (!gUnknown_02022CFC->unk2C) + sub_802E138(gUnknown_02022CFC->unk82E4, &gUnknown_02022CFC->unk70); + + if (gUnknown_02022CFC->unk30 != 0x1111) + { + gUnknown_02022CFC->unk2C++; + gUnknown_02022CFC->unk2C &= gUnknown_02022CFC->unk30; + } +} + +static void sub_802B044(u8 arg0) +{ + gUnknown_02022CFC->unk70 = arg0; + gUnknown_02022CFC->unk8 = 0; + gUnknown_02022CFC->unkA = 0; + gUnknown_02022CFC->unk48 = 1; + gUnknown_02022CFC->unk82E4[gUnknown_02022CFC->unk6].unk18 = 0; +} + +static void sub_802B078(void) +{ + int i; + u16 var0; + struct Unk802B078 sp0; + + var0 = gUnknown_02022CFC->unk82E4[0].unk10; + if (sub_802E1BC(gUnknown_02022CFC->unk82E4, &sp0)) + { + if (gUnknown_02022CFC->unk82E4[gUnknown_02022CFC->unk6].unk18 == 1 + && sp0.unk0 != gUnknown_02022CFC->unk70) + { + sub_802B044(sp0.unk0); + } + + if (gUnknown_02022CFC->unk78 != sp0.unk8) + { + gUnknown_02022CFC->unk78 = sp0.unk8; + gUnknown_02022CFC->unk5C = 1; + gUnknown_02022CFC->unk71 = sp0.unk1; + if (gUnknown_02022CFC->unk71) + gUnknown_02022CFC->unk4D = 1; + else + gUnknown_02022CFC->unk4D = 0; + } + + gUnknown_02022CFC->unk72 = sp0.unk2; + gUnknown_02022CFC->unk74 = sp0.unk4; + gUnknown_02022CFC->unk82E4[0].unk12 = var0; + } + + for (i = 1; i < gUnknown_02022CFC->unk5; i++) + { + if (i != gUnknown_02022CFC->unk6) + { + var0 = gUnknown_02022CFC->unk82E4[i].unk10; + if (sub_802E2D0(&gUnknown_02022CFC->unk82E4[i], i)) + gUnknown_02022CFC->unk82E4[i].unk12 = var0; + } + } +} + +static void sub_802B194(u8 taskId) +{ + sub_802B078(); + if (gUnknown_02022CFC->unk48) + { + if (!gUnknown_082FB618[gUnknown_02022CFC->unk70]()) + { + gUnknown_02022CFC->unk48 = 0; + gUnknown_02022CFC->unk82E4[gUnknown_02022CFC->unk6].unk18 = 1; + sub_802AE14(3); + } + } + + sub_802C1DC(); + sub_802B1FC(); +} + +static void sub_802B1FC(void) +{ + if (!gUnknown_02022CFC->unk2C) + sub_802E234(&gUnknown_02022CFC->unk82E4[gUnknown_02022CFC->unk6], gUnknown_02022CFC->unk70, gUnknown_02022CFC->unk42); + + if (gUnknown_02022CFC->unk30 != 0x1111) + { + gUnknown_02022CFC->unk2C++; + gUnknown_02022CFC->unk2C &= gUnknown_02022CFC->unk30; + } +} + +bool32 sub_802B248(void) +{ + switch (gUnknown_02022CFC->unk8) + { + case 0: + sub_802AE14(3); + gUnknown_02022CFC->unk8++; + // fall through + case 1: + if (!sub_802B7E0()) + { + gUnknown_02022CFC->unk72 = gUnknown_02022CFC->unk4A; + gUnknown_02022CFC->unk4C = 1; + return FALSE; + } + break; + } + + return TRUE; +} + +bool32 sub_802B29C(void) +{ + switch (gUnknown_02022CFC->unk8) + { + case 0: + sub_802AE14(0); + gUnknown_02022CFC->unk24 = gUnknown_02022CFC->unk72; + gUnknown_02022CFC->unk8++; + // fall through + case 1: + return sub_802B7E0(); + } + + return TRUE; +} + +bool32 sub_802B2D4(void) +{ + switch (gUnknown_02022CFC->unk8) + { + case 0: + sub_802C0E8(); + sub_802AE14(5); + gUnknown_02022CFC->unk8++; + break; + case 1: + if (gUnknown_02022CFC->unk49) + { + gUnknown_02022CFC->unk4C = 2; + return FALSE; + } + break; + } + + return TRUE; +} + +bool32 sub_802B31C(void) +{ + switch (gUnknown_02022CFC->unk8) + { + case 0: + sub_802C0E8(); + sub_802AE14(0); + gUnknown_02022CFC->unk4A = gUnknown_02022CFC->unk72; + gUnknown_02022CFC->unk8++; + // fall through + case 1: + if (sub_802C70C()) + return FALSE; + break; + } + + return TRUE; +} + +bool32 sub_802B368(void) +{ + if (!sub_802B8CC()) + { + gUnknown_02022CFC->unk72 = gUnknown_02022CFC->unk4A; + gUnknown_02022CFC->unk4C = 1; + } + else if (sub_802C538()) + { + return TRUE; + } + else + { + sub_802C0B8(); + gUnknown_02022CFC->unk4C = 3; + } + + return FALSE; +} + +bool32 sub_802B3B4(void) +{ + if (!sub_802B8CC()) + ; + else if (sub_802C538()) + return TRUE; + else + sub_802C0B8(); + + return FALSE; +} diff --git a/src/union_room.c b/src/union_room.c index 687efbf5e..d9bb3ca7c 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -47,6 +47,7 @@ #include "berry_crush.h" #include "mystery_gift.h" #include "union_room_player_avatar.h" +#include "pokemon_jump.h" EWRAM_DATA u8 gUnknown_02022C20[12] = {}; EWRAM_DATA u8 gUnknown_02022C2C = 0; @@ -97,7 +98,6 @@ bool32 sub_8017678(struct UnkStruct_Shared *arg0, struct UnkStruct_Shared *arg1) u32 sub_8018120(struct TradeUnkStruct *arg0, u8 multiplayerId); void sub_801807C(struct TradeUnkStruct *arg0); void sub_801AC54(void); -void sub_802A9A8(u8 monId, MainCallback callback); void sub_802493C(u8 monId, MainCallback callback); void sub_80149D8(void); void MG_DrawTextBorder(u8 windowId);