diff --git a/asm/shop.s b/asm/shop.s deleted file mode 100644 index a341e90a1..000000000 --- a/asm/shop.s +++ /dev/null @@ -1,2613 +0,0 @@ - .include "constants/gba_constants.inc" - .include "constants/species_constants.inc" - .include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start sub_80B33D0 -sub_80B33D0: @ 80B33D0 - push {r4-r6,lr} - mov r6, r8 - push {r6} - adds r6, r0, 0 - adds r4, r1, 0 - mov r8, r2 - lsls r4, 22 - ldr r5, _080B3418 @ =gBGTilemapBuffers + 0x1800 - lsls r6, 17 - asrs r6, 16 - movs r0, 0x80 - lsls r0, 15 - adds r4, r0 - asrs r4, 16 - adds r0, r5, 0 - adds r1, r6, 0 - adds r2, r4, 0 - mov r3, r8 - bl BuyMenuDrawMapMetatileLayer - ldr r0, _080B341C @ =0xfffff800 - adds r5, r0 - movs r0, 0x8 - add r8, r0 - adds r0, r5, 0 - adds r1, r6, 0 - adds r2, r4, 0 - mov r3, r8 - bl BuyMenuDrawMapMetatileLayer - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_080B3418: .4byte gBGTilemapBuffers + 0x1800 -_080B341C: .4byte 0xfffff800 - thumb_func_end sub_80B33D0 - - thumb_func_start sub_80B3420 -sub_80B3420: @ 80B3420 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl GetXYCoordsOneStepInFrontOfPlayer - mov r1, sp - mov r0, sp - ldrh r0, [r0] - subs r0, 0x3 - strh r0, [r1] - ldrh r0, [r4] - subs r0, 0x3 - strh r0, [r4] - movs r1, 0 - ldr r0, _080B34A8 @ =0x000001ff - mov r10, r0 - ldr r2, _080B34AC @ =gMapHeader - mov r9, r2 -_080B3452: - movs r4, 0 - lsls r1, 16 - mov r8, r1 - asrs r7, r1, 16 -_080B345A: - mov r0, sp - movs r3, 0 - ldrsh r0, [r0, r3] - lsls r4, 16 - asrs r6, r4, 16 - adds r0, r6 - mov r2, sp - movs r3, 0x2 - ldrsh r1, [r2, r3] - adds r1, r7 - bl MapGridGetMetatileIdAt - lsls r0, 16 - lsrs r5, r0, 16 - cmp r7, 0x5 - beq _080B34D0 - cmp r6, 0x6 - beq _080B34D0 - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - adds r0, r6 - mov r2, sp - movs r3, 0x2 - ldrsh r1, [r2, r3] - adds r1, r7 - bl MapGridGetMetatileLayerTypeAt - lsls r0, 24 - lsrs r3, r0, 24 - cmp r5, r10 - bhi _080B34B0 - mov r1, r9 - ldr r0, [r1] - ldr r0, [r0, 0x10] - lsls r1, r5, 4 - ldr r2, [r0, 0xC] - adds r2, r1 - b _080B34C0 - .align 2, 0 -_080B34A8: .4byte 0x000001ff -_080B34AC: .4byte gMapHeader -_080B34B0: - mov r2, r9 - ldr r0, [r2] - ldr r1, [r0, 0x14] - ldr r2, _080B34CC @ =0xfffffe00 - adds r0, r5, r2 - lsls r0, 4 - ldr r2, [r1, 0xC] - adds r2, r0 -_080B34C0: - adds r0, r6, 0 - adds r1, r7, 0 - bl BuyMenuDrawMapMetatile - b _080B3506 - .align 2, 0 -_080B34CC: .4byte 0xfffffe00 -_080B34D0: - cmp r5, r10 - bhi _080B34EC - asrs r0, r4, 16 - mov r3, r9 - ldr r1, [r3] - ldr r1, [r1, 0x10] - lsls r3, r5, 4 - ldr r2, [r1, 0xC] - adds r2, r3 - mov r3, r8 - asrs r1, r3, 16 - bl sub_80B33D0 - b _080B3506 -_080B34EC: - asrs r0, r4, 16 - mov r2, r9 - ldr r1, [r2] - ldr r2, [r1, 0x14] - ldr r3, _080B354C @ =0xfffffe00 - adds r1, r5, r3 - lsls r1, 4 - ldr r2, [r2, 0xC] - adds r2, r1 - mov r3, r8 - asrs r1, r3, 16 - bl sub_80B33D0 -_080B3506: - cmp r7, 0 - bne _080B3520 - asrs r1, r4, 16 - cmp r1, 0 - beq _080B3520 - cmp r1, 0x6 - beq _080B3520 - lsls r1, 17 - asrs r1, 16 - ldr r0, _080B3550 @ =gBGTilemapBuffers + 0x800 - movs r2, 0x40 - bl sub_80B32EC -_080B3520: - movs r1, 0x80 - lsls r1, 9 - adds r0, r4, r1 - lsrs r4, r0, 16 - asrs r0, 16 - cmp r0, 0x6 - ble _080B345A - adds r0, r1, 0 - add r0, r8 - lsrs r1, r0, 16 - asrs r0, 16 - cmp r0, 0x5 - ble _080B3452 - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080B354C: .4byte 0xfffffe00 -_080B3550: .4byte gBGTilemapBuffers + 0x800 - thumb_func_end sub_80B3420 - - thumb_func_start BuyMenuDrawMapGraphics -BuyMenuDrawMapGraphics: @ 80B3554 - push {lr} - bl sub_80F9020 - bl sub_80B356C - bl sub_80B368C - bl sub_80B3420 - pop {r0} - bx r0 - thumb_func_end BuyMenuDrawMapGraphics - - thumb_func_start sub_80B356C -sub_80B356C: @ 80B356C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - movs r0, 0 - mov r8, r0 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl GetXYCoordsOneStepInFrontOfPlayer - bl PlayerGetZCoord - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x4] - movs r5, 0 - ldr r2, _080B3674 @ =gUnknown_020386A4 - movs r1, 0x10 -_080B3598: - lsls r0, r5, 3 - adds r0, r2 - strh r1, [r0] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0xF - bls _080B3598 - movs r5, 0 - ldr r7, _080B3678 @ =gUnknown_020386AA - subs r1, r7, 0x6 - mov r9, r1 -_080B35B0: - movs r4, 0 - adds r2, r5, 0x1 - mov r10, r2 -_080B35B6: - mov r1, sp - ldr r3, _080B367C @ =0x0000fffd - adds r0, r3, 0 - ldrh r1, [r1] - adds r0, r1 - adds r0, r4 - lsls r0, 16 - lsrs r0, 16 - ldr r2, _080B3680 @ =0x0000fffe - adds r1, r2, 0 - mov r3, sp - ldrh r3, [r3, 0x2] - adds r1, r3 - adds r1, r5 - lsls r1, 16 - lsrs r1, 16 - ldr r2, [sp, 0x4] - bl GetFieldObjectIdByXYZ - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x10 - beq _080B3650 - mov r0, r8 - lsls r3, r0, 3 - mov r1, r9 - adds r0, r3, r1 - movs r6, 0 - strh r2, [r0] - mov r0, r9 - adds r0, 0x2 - adds r0, r3, r0 - strh r4, [r0] - ldr r1, _080B3684 @ =gUnknown_020386A8 - adds r0, r3, r1 - strh r5, [r0] - ldr r1, _080B3688 @ =gMapObjects - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - adds r2, r0, r1 - ldrb r0, [r2, 0x18] - lsls r0, 28 - lsrs r0, 28 - cmp r0, 0x1 - bne _080B3616 - adds r0, r3, r7 - strh r6, [r0] -_080B3616: - ldrb r0, [r2, 0x18] - lsls r0, 28 - lsrs r0, 28 - cmp r0, 0x2 - bne _080B3626 - adds r1, r3, r7 - movs r0, 0x1 - strh r0, [r1] -_080B3626: - ldrb r0, [r2, 0x18] - lsls r0, 28 - lsrs r0, 28 - cmp r0, 0x3 - bne _080B3636 - adds r1, r3, r7 - movs r0, 0x2 - strh r0, [r1] -_080B3636: - ldrb r0, [r2, 0x18] - lsls r0, 28 - lsrs r0, 28 - cmp r0, 0x4 - bne _080B3646 - adds r1, r3, r7 - movs r0, 0x3 - strh r0, [r1] -_080B3646: - mov r0, r8 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 -_080B3650: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x6 - bls _080B35B6 - mov r2, r10 - lsls r0, r2, 24 - lsrs r5, r0, 24 - cmp r5, 0x4 - bls _080B35B0 - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080B3674: .4byte gUnknown_020386A4 -_080B3678: .4byte gUnknown_020386AA -_080B367C: .4byte 0x0000fffd -_080B3680: .4byte 0x0000fffe -_080B3684: .4byte gUnknown_020386A8 -_080B3688: .4byte gMapObjects - thumb_func_end sub_80B356C - - thumb_func_start sub_80B368C -sub_80B368C: @ 80B368C - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - movs r5, 0 - ldr r6, _080B3710 @ =gUnknown_020386A4 - adds r0, r6, 0x6 - mov r8, r0 - ldr r7, _080B3714 @ =gMapObjects -_080B369E: - lsls r4, r5, 3 - adds r1, r4, r6 - movs r2, 0 - ldrsh r0, [r1, r2] - cmp r0, 0x10 - beq _080B36F8 - adds r1, r0, 0 - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrb r0, [r0, 0x5] - adds r1, r6, 0x2 - adds r1, r4, r1 - ldrh r2, [r1] - lsls r2, 4 - adds r2, 0x8 - lsls r2, 16 - asrs r2, 16 - adds r1, r6, 0x4 - adds r1, r4, r1 - ldrh r3, [r1] - lsls r3, 20 - movs r1, 0x80 - lsls r1, 14 - adds r3, r1 - asrs r3, 16 - movs r1, 0x2 - str r1, [sp] - ldr r1, _080B3718 @ =SpriteCallbackDummy - bl AddPseudoFieldObject - lsls r0, 24 - lsrs r0, 24 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r0, _080B371C @ =gSprites - adds r2, r0 - mov r1, r8 - adds r0, r4, r1 - ldrb r1, [r0] - adds r0, r2, 0 - bl StartSpriteAnim -_080B36F8: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0xF - bls _080B369E - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080B3710: .4byte gUnknown_020386A4 -_080B3714: .4byte gMapObjects -_080B3718: .4byte SpriteCallbackDummy -_080B371C: .4byte gSprites - thumb_func_end sub_80B368C - - thumb_func_start sub_80B3720 -sub_80B3720: @ 80B3720 - push {r4-r6,lr} - movs r1, 0 - ldr r6, _080B3754 @ =gBGTilemapBuffers + 0x800 - ldr r5, _080B3758 @ =0x000003ff - ldr r4, _080B375C @ =0x02018000 - ldr r0, _080B3760 @ =0x0000c3e0 - adds r3, r0, 0 -_080B372E: - lsls r0, r1, 16 - asrs r2, r0, 16 - lsls r1, r2, 1 - adds r0, r1, r4 - ldrh r0, [r0] - cmp r0, 0 - beq _080B3742 - adds r1, r6 - adds r0, r3 - strh r0, [r1] -_080B3742: - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - asrs r0, 16 - cmp r0, r5 - ble _080B372E - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_080B3754: .4byte gBGTilemapBuffers + 0x800 -_080B3758: .4byte 0x000003ff -_080B375C: .4byte 0x02018000 -_080B3760: .4byte 0x0000c3e0 - thumb_func_end sub_80B3720 - - thumb_func_start sub_80B3764 -sub_80B3764: @ 80B3764 - push {r4,r5,lr} - sub sp, 0x8 - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80B3720 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0 - bl sub_80B39D0 - ldr r0, _080B3798 @ =gUnknown_03000708 - ldrb r0, [r0, 0x9] - str r0, [sp] - movs r0, 0xF - str r0, [sp, 0x4] - movs r0, 0 - movs r1, 0xE - movs r2, 0x2 - movs r3, 0x8 - bl InitMenu - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_080B3798: .4byte gUnknown_03000708 - thumb_func_end sub_80B3764 - - thumb_func_start sub_80B379C -sub_80B379C: @ 80B379C - push {r4-r7,lr} - movs r1, 0 - ldr r0, _080B37E0 @ =gBGTilemapBuffers + 0x800 - mov r12, r0 - ldr r7, _080B37E4 @ =0x02018300 - ldr r0, _080B37E8 @ =0x0000c3e0 - adds r6, r0, 0 -_080B37AA: - movs r2, 0 - adds r0, r1, 0 - adds r0, 0xC - adds r5, r1, 0x1 - lsls r4, r0, 5 - lsls r3, r1, 5 -_080B37B6: - adds r1, r4, r2 - lsls r1, 1 - add r1, r12 - adds r0, r3, r2 - lsls r0, 1 - adds r0, r7 - ldrh r0, [r0] - adds r0, r6, r0 - strh r0, [r1] - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r2, 0xD - bls _080B37B6 - lsls r0, r5, 16 - lsrs r1, r0, 16 - cmp r1, 0x7 - bls _080B37AA - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080B37E0: .4byte gBGTilemapBuffers + 0x800 -_080B37E4: .4byte 0x02018300 -_080B37E8: .4byte 0x0000c3e0 - thumb_func_end sub_80B379C - - thumb_func_start sub_80B37EC -sub_80B37EC: @ 80B37EC - push {lr} - bl sub_80B3A70 - pop {r0} - bx r0 - thumb_func_end sub_80B37EC - - thumb_func_start sub_80B37F8 -sub_80B37F8: @ 80B37F8 - push {r4-r6,lr} - sub sp, 0x8 - adds r6, r0, 0 - lsls r6, 24 - lsrs r6, 24 - ldr r1, _080B3884 @ =gUnknown_03000708 - ldrb r0, [r1, 0xB] - ldrb r2, [r1, 0x9] - adds r0, r2 - ldr r1, [r1, 0x4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - bl ItemId_GetPrice - adds r4, r0, 0 - movs r0, 0x1 - bl GetPriceReduction - lsls r4, 16 - lsrs r4, 16 - lsls r0, 24 - lsrs r0, 24 - asrs r4, r0 - ldr r0, _080B3888 @ =gTasks - lsls r5, r6, 2 - adds r5, r6 - lsls r5, 3 - adds r5, r0 - movs r1, 0xA - ldrsh r0, [r5, r1] - muls r0, r4 - movs r1, 0x6 - movs r2, 0x6 - movs r3, 0xB - bl sub_80B7A94 - ldr r0, _080B388C @ =gStringVar1 - movs r1, 0xFC - strb r1, [r0] - movs r1, 0x14 - strb r1, [r0, 0x1] - movs r1, 0x6 - strb r1, [r0, 0x2] - adds r0, 0x3 - movs r2, 0xA - ldrsh r1, [r5, r2] - movs r2, 0x1 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - ldr r0, _080B3890 @ =gOtherText_xString1 - movs r1, 0x1 - movs r2, 0xB - bl MenuPrint - ldr r0, _080B3894 @ =gBGTilemapBuffers + 0x800 - movs r1, 0x2 - str r1, [sp] - ldr r1, _080B3898 @ =0x0000c3e1 - str r1, [sp, 0x4] - movs r1, 0x1 - movs r2, 0xB - movs r3, 0xC - bl sub_80A3FA0 - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_080B3884: .4byte gUnknown_03000708 -_080B3888: .4byte gTasks -_080B388C: .4byte gStringVar1 -_080B3890: .4byte gOtherText_xString1 -_080B3894: .4byte gBGTilemapBuffers + 0x800 -_080B3898: .4byte 0x0000c3e1 - thumb_func_end sub_80B37F8 - - thumb_func_start sub_80B389C -sub_80B389C: @ 80B389C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - mov r8, r2 - lsls r0, 16 - lsrs r2, r0, 16 - mov r9, r2 - lsls r1, 24 - lsrs r4, r1, 24 - ldr r5, _080B392C @ =gStringVar1 - mov r0, r8 - cmp r0, 0 - beq _080B38C8 - movs r0, 0xFC - strb r0, [r5] - movs r0, 0x1 - strb r0, [r5, 0x1] - movs r0, 0x2 - strb r0, [r5, 0x2] - adds r5, 0x3 -_080B38C8: - adds r0, r2, 0 - adds r1, r5, 0 - bl CopyItemName - ldr r6, _080B392C @ =gStringVar1 - lsls r7, r4, 3 - movs r0, 0x1 - str r0, [sp] - adds r0, r6, 0 - movs r1, 0x70 - adds r2, r7, 0 - movs r3, 0x58 - bl sub_8072A18 - adds r5, r6, 0 - mov r0, r8 - cmp r0, 0 - beq _080B38EE - adds r5, r6, 0x3 -_080B38EE: - mov r0, r9 - bl ItemId_GetPrice - adds r4, r0, 0 - movs r0, 0x1 - bl GetPriceReduction - lsls r4, 16 - lsrs r4, 16 - lsls r0, 24 - lsrs r0, 24 - asrs r4, r0 - adds r0, r5, 0 - adds r1, r4, 0 - movs r2, 0x4 - bl sub_80B79F8 - adds r0, r6, 0 - movs r1, 0xCA - adds r2, r7, 0 - movs r3, 0x1 - bl MenuPrint_PixelCoords - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080B392C: .4byte gStringVar1 - thumb_func_end sub_80B389C - - thumb_func_start sub_80B3930 -sub_80B3930: @ 80B3930 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - adds r4, r2, 0 - lsls r0, 16 - lsrs r3, r0, 16 - lsls r1, 24 - lsrs r1, 24 - mov r9, r1 - ldr r2, _080B39A0 @ =gStringVar1 - cmp r4, 0 - beq _080B395A - movs r0, 0xFC - strb r0, [r2] - movs r0, 0x1 - strb r0, [r2, 0x1] - movs r0, 0x2 - strb r0, [r2, 0x2] - adds r2, 0x3 -_080B395A: - lsls r6, r3, 5 - ldr r0, _080B39A4 @ =gDecorations + 0x1 - mov r8, r0 - adds r1, r6, r0 - adds r0, r2, 0 - bl StringCopy - ldr r5, _080B39A0 @ =gStringVar1 - mov r0, r9 - lsls r7, r0, 3 - movs r0, 0x1 - str r0, [sp] - adds r0, r5, 0 - movs r1, 0x70 - adds r2, r7, 0 - movs r3, 0x58 - bl sub_8072A18 - adds r2, r5, 0 - cmp r4, 0 - beq _080B3986 - adds r2, r5, 0x3 -_080B3986: - mov r0, r8 - subs r0, 0x1 - adds r3, r6, r0 - ldrh r1, [r3, 0x14] - ldr r0, _080B39A8 @ =0x00002710 - cmp r1, r0 - bne _080B39AC - movs r0, 0x19 - mov r1, r9 - adds r2, r4, 0 - bl sub_80B7B34 - b _080B39C2 - .align 2, 0 -_080B39A0: .4byte gStringVar1 -_080B39A4: .4byte gDecorations + 0x1 -_080B39A8: .4byte 0x00002710 -_080B39AC: - ldrh r1, [r3, 0x14] - adds r0, r2, 0 - movs r2, 0x4 - bl sub_80B79F8 - adds r0, r5, 0 - movs r1, 0xCA - adds r2, r7, 0 - movs r3, 0x1 - bl MenuPrint_PixelCoords -_080B39C2: - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80B3930 - - thumb_func_start sub_80B39D0 -sub_80B39D0: @ 80B39D0 - push {r4-r6,lr} - adds r6, r1, 0 - adds r5, r2, 0 - b _080B3A1A -_080B39D8: - ldrb r0, [r1, 0xC] - cmp r0, 0 - bne _080B39FC - ldrb r0, [r1, 0xB] - adds r0, r4 - ldr r1, [r1, 0x4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - lsls r1, r4, 25 - movs r2, 0x80 - lsls r2, 18 - adds r1, r2 - lsrs r1, 24 - adds r2, r5, 0 - bl sub_80B389C - b _080B3A18 -_080B39FC: - ldrb r0, [r1, 0xB] - adds r0, r4 - ldr r1, [r1, 0x4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - lsls r1, r4, 25 - movs r2, 0x80 - lsls r2, 18 - adds r1, r2 - lsrs r1, 24 - adds r2, r5, 0 - bl sub_80B3930 -_080B3A18: - adds r0, r4, 0x1 -_080B3A1A: - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, r6 - bgt _080B3A2E - ldr r1, _080B3A68 @ =gUnknown_03000708 - ldrb r0, [r1, 0xB] - adds r0, r4 - ldrb r2, [r1, 0x8] - cmp r0, r2 - blt _080B39D8 -_080B3A2E: - cmp r4, 0x8 - beq _080B3A60 - ldr r1, _080B3A68 @ =gUnknown_03000708 - ldrb r0, [r1, 0xB] - adds r0, r4 - ldrb r1, [r1, 0x8] - cmp r0, r1 - bne _080B3A60 - lsls r3, r4, 1 - adds r4, r3, 0x2 - lsls r4, 24 - lsrs r4, 24 - adds r3, 0x3 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0xE - adds r1, r4, 0 - movs r2, 0x1C - bl MenuFillWindowRectWithBlankTile - ldr r0, _080B3A6C @ =gOtherText_CancelNoTerminator - movs r1, 0xE - adds r2, r4, 0 - bl MenuPrint -_080B3A60: - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_080B3A68: .4byte gUnknown_03000708 -_080B3A6C: .4byte gOtherText_CancelNoTerminator - thumb_func_end sub_80B39D0 - - thumb_func_start sub_80B3A70 -sub_80B3A70: @ 80B3A70 - push {r4,lr} - sub sp, 0x8 - ldr r2, _080B3A9C @ =gUnknown_03000708 - ldrb r1, [r2, 0xB] - ldrb r0, [r2, 0x9] - adds r0, r1, r0 - ldrb r1, [r2, 0x8] - cmp r0, r1 - beq _080B3ACC - ldrb r4, [r2, 0xC] - cmp r4, 0 - bne _080B3AA0 - ldr r1, [r2, 0x4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - bl ItemId_GetDescription - movs r1, 0x30 - str r1, [sp] - str r4, [sp, 0x4] - b _080B3ABA - .align 2, 0 -_080B3A9C: .4byte gUnknown_03000708 -_080B3AA0: - ldr r1, _080B3AC8 @ =gDecorations - ldr r2, [r2, 0x4] - lsls r0, 1 - adds r0, r2 - ldrh r0, [r0] - lsls r0, 5 - adds r1, 0x18 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x30 - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] -_080B3ABA: - movs r1, 0x4 - movs r2, 0x68 - movs r3, 0x68 - bl sub_8072AB0 - b _080B3AE0 - .align 2, 0 -_080B3AC8: .4byte gDecorations -_080B3ACC: - ldr r0, _080B3AE8 @ =gOtherText_QuitShopping - movs r1, 0x30 - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - movs r1, 0x4 - movs r2, 0x68 - movs r3, 0x68 - bl sub_8072AB0 -_080B3AE0: - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080B3AE8: .4byte gOtherText_QuitShopping - thumb_func_end sub_80B3A70 - - thumb_func_start sub_80B3AEC -sub_80B3AEC: @ 80B3AEC - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, _080B3B5C @ =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080B3B06 - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080B3B7A -_080B3B06: - ldr r4, _080B3B60 @ =gUnknown_03000708 - ldrb r1, [r4, 0x9] - adds r0, r1, 0 - movs r2, 0 - bl sub_80B39D0 - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4, 0xB] - ldrb r1, [r4, 0x9] - adds r0, r1 - ldr r1, [r4, 0x4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - cmp r0, 0x4 - bne _080B3B74 - ldr r0, _080B3B64 @ =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - movs r2, 0xA - ldrsh r0, [r1, r2] - cmp r0, 0x9 - ble _080B3B74 - movs r0, 0xC - movs r1, 0x1 - bl AddBagItem - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B3B74 - ldr r1, _080B3B68 @ =gOtherText_FreePremierBall - ldr r2, _080B3B6C @ =sub_80B4378 - ldr r3, _080B3B70 @ =0x0000c3e1 - adds r0, r5, 0 - bl DisplayItemMessageOnField - b _080B3B7A - .align 2, 0 -_080B3B5C: .4byte gMain -_080B3B60: .4byte gUnknown_03000708 -_080B3B64: .4byte gTasks -_080B3B68: .4byte gOtherText_FreePremierBall -_080B3B6C: .4byte sub_80B4378 -_080B3B70: .4byte 0x0000c3e1 -_080B3B74: - adds r0, r5, 0 - bl sub_80B4378 -_080B3B7A: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80B3AEC - - thumb_func_start sub_80B3B80 -sub_80B3B80: @ 80B3B80 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x26 - bl IncrementGameStat - ldr r5, _080B3BC0 @ =gSaveBlock1 + 0x490 - ldr r0, _080B3BC4 @ =gUnknown_020386A0 - ldr r1, [r0] - adds r0, r5, 0 - bl sub_80B79E0 - movs r0, 0x5F - bl PlaySE - ldr r0, [r5] - movs r1, 0 - movs r2, 0 - bl sub_80B7BEC - ldr r1, _080B3BC8 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, _080B3BCC @ =sub_80B3AEC - str r1, [r0] - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_080B3BC0: .4byte gSaveBlock1 + 0x490 -_080B3BC4: .4byte gUnknown_020386A0 -_080B3BC8: .4byte gTasks -_080B3BCC: .4byte sub_80B3AEC - thumb_func_end sub_80B3B80 - - thumb_func_start sub_80B3BD0 -sub_80B3BD0: @ 80B3BD0 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, _080B3BF0 @ =gUnknown_03000708 - ldrb r1, [r0, 0x9] - adds r0, r1, 0 - movs r2, 0 - bl sub_80B39D0 - adds r0, r4, 0 - bl sub_80B4378 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080B3BF0: .4byte gUnknown_03000708 - thumb_func_end sub_80B3BD0 - - thumb_func_start sub_80B3BF4 -sub_80B3BF4: @ 80B3BF4 - push {r4,r5,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r5, r0, 24 - movs r0, 0x7 - movs r1, 0x8 - movs r2, 0xD - movs r3, 0xD - bl MenuZeroFillWindowRect - ldr r0, _080B3C7C @ =gBGTilemapBuffers + 0x800 - movs r1, 0x4 - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - movs r1, 0x8 - movs r2, 0x9 - movs r3, 0x4 - bl sub_80A3FA0 - bl sub_80B379C - bl sub_80B3420 - ldr r0, _080B3C80 @ =gSaveBlock1 - movs r1, 0x92 - lsls r1, 3 - adds r0, r1 - ldr r0, [r0] - ldr r1, _080B3C84 @ =gUnknown_020386A0 - ldr r1, [r1] - bl IsEnoughMoney - lsls r0, 24 - cmp r0, 0 - beq _080B3D18 - ldr r4, _080B3C88 @ =gUnknown_03000708 - ldrb r0, [r4, 0xC] - cmp r0, 0 - bne _080B3CAC - ldrb r0, [r4, 0xB] - ldrb r1, [r4, 0x9] - adds r0, r1 - ldr r1, [r4, 0x4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - ldr r2, _080B3C8C @ =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r2 - ldrh r1, [r1, 0xA] - bl AddBagItem - lsls r0, 24 - cmp r0, 0 - beq _080B3C9C - ldr r1, _080B3C90 @ =gOtherText_HereYouGo - ldr r2, _080B3C94 @ =sub_80B3B80 - ldr r3, _080B3C98 @ =0x0000c3e1 - adds r0, r5, 0 - bl DisplayItemMessageOnField - adds r0, r5, 0 - bl sub_80B4470 - b _080B3D24 - .align 2, 0 -_080B3C7C: .4byte gBGTilemapBuffers + 0x800 -_080B3C80: .4byte gSaveBlock1 -_080B3C84: .4byte gUnknown_020386A0 -_080B3C88: .4byte gUnknown_03000708 -_080B3C8C: .4byte gTasks -_080B3C90: .4byte gOtherText_HereYouGo -_080B3C94: .4byte sub_80B3B80 -_080B3C98: .4byte 0x0000c3e1 -_080B3C9C: - ldr r1, _080B3CA4 @ =gOtherText_NoRoomFor - ldr r2, _080B3CA8 @ =sub_80B3BD0 - b _080B3CD8 - .align 2, 0 -_080B3CA4: .4byte gOtherText_NoRoomFor -_080B3CA8: .4byte sub_80B3BD0 -_080B3CAC: - ldrb r0, [r4, 0xB] - ldrb r1, [r4, 0x9] - adds r0, r1 - ldr r1, [r4, 0x4] - lsls r0, 1 - adds r0, r1 - ldrb r0, [r0] - bl IsThereStorageSpaceForDecoration - lsls r0, 24 - cmp r0, 0 - beq _080B3CF0 - ldrb r0, [r4, 0xC] - cmp r0, 0x1 - bne _080B3CD4 - ldr r1, _080B3CD0 @ =gOtherText_HereYouGo2 - b _080B3CD6 - .align 2, 0 -_080B3CD0: .4byte gOtherText_HereYouGo2 -_080B3CD4: - ldr r1, _080B3CE4 @ =gOtherText_HereYouGo3 -_080B3CD6: - ldr r2, _080B3CE8 @ =sub_80B3B80 -_080B3CD8: - ldr r3, _080B3CEC @ =0x0000c3e1 - adds r0, r5, 0 - bl DisplayItemMessageOnField - b _080B3D24 - .align 2, 0 -_080B3CE4: .4byte gOtherText_HereYouGo3 -_080B3CE8: .4byte sub_80B3B80 -_080B3CEC: .4byte 0x0000c3e1 -_080B3CF0: - ldr r4, _080B3D08 @ =gStringVar4 - ldr r1, _080B3D0C @ =gOtherText_SpaceForIsFull - adds r0, r4, 0 - bl StringExpandPlaceholders - ldr r2, _080B3D10 @ =sub_80B3BD0 - ldr r3, _080B3D14 @ =0x0000c3e1 - adds r0, r5, 0 - adds r1, r4, 0 - bl DisplayItemMessageOnField - b _080B3D24 - .align 2, 0 -_080B3D08: .4byte gStringVar4 -_080B3D0C: .4byte gOtherText_SpaceForIsFull -_080B3D10: .4byte sub_80B3BD0 -_080B3D14: .4byte 0x0000c3e1 -_080B3D18: - ldr r1, _080B3D2C @ =gOtherText_NotEnoughMoney - ldr r2, _080B3D30 @ =sub_80B3BD0 - ldr r3, _080B3D34 @ =0x0000c3e1 - adds r0, r5, 0 - bl DisplayItemMessageOnField -_080B3D24: - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_080B3D2C: .4byte gOtherText_NotEnoughMoney -_080B3D30: .4byte sub_80B3BD0 -_080B3D34: .4byte 0x0000c3e1 - thumb_func_end sub_80B3BF4 - - thumb_func_start sub_80B3D38 -sub_80B3D38: @ 80B3D38 - push {r4,lr} - sub sp, 0x8 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x7 - movs r1, 0x8 - movs r2, 0x1 - bl DisplayYesNoMenu - ldr r0, _080B3D70 @ =gBGTilemapBuffers + 0x800 - movs r1, 0x4 - str r1, [sp] - ldr r1, _080B3D74 @ =0x0000c3e1 - str r1, [sp, 0x4] - movs r1, 0x8 - movs r2, 0x9 - movs r3, 0x4 - bl sub_80A3FA0 - ldr r1, _080B3D78 @ =gUnknown_083CC708 - adds r0, r4, 0 - bl DoYesNoFuncWithChoice - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080B3D70: .4byte gBGTilemapBuffers + 0x800 -_080B3D74: .4byte 0x0000c3e1 -_080B3D78: .4byte gUnknown_083CC708 - thumb_func_end sub_80B3D38 - - thumb_func_start sub_80B3D7C -sub_80B3D7C: @ 80B3D7C - push {r4,lr} - sub sp, 0x8 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, _080B3DC0 @ =gUnknown_03000708 - ldrb r1, [r0, 0x9] - adds r0, r1, 0 - movs r2, 0 - bl sub_80B39D0 - movs r0, 0x7 - movs r1, 0x8 - movs r2, 0xD - movs r3, 0xD - bl MenuZeroFillWindowRect - ldr r0, _080B3DC4 @ =gBGTilemapBuffers + 0x800 - movs r1, 0x4 - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - movs r1, 0x8 - movs r2, 0x9 - movs r3, 0x4 - bl sub_80A3FA0 - adds r0, r4, 0 - bl sub_80B4378 - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080B3DC0: .4byte gUnknown_03000708 -_080B3DC4: .4byte gBGTilemapBuffers + 0x800 - thumb_func_end sub_80B3D7C - - thumb_func_start sub_80B3DC8 -sub_80B3DC8: @ 80B3DC8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x8 - lsls r0, 24 - lsrs r6, r0, 24 - adds r4, r6, 0 - ldr r7, _080B3EA8 @ =gUnknown_03000708 - ldrb r1, [r7, 0xD] - adds r0, r6, 0 - bl sub_80A52C4 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B3DEE - adds r0, r6, 0 - bl sub_80B37F8 -_080B3DEE: - ldr r0, _080B3EAC @ =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080B3ED8 - ldr r0, _080B3EB0 @ =gUnknown_020386A0 - mov r8, r0 - ldrb r0, [r7, 0xB] - ldrb r1, [r7, 0x9] - adds r0, r1 - ldr r1, [r7, 0x4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - bl ItemId_GetPrice - adds r4, r0, 0 - movs r0, 0x1 - bl GetPriceReduction - lsls r4, 16 - lsrs r4, 16 - lsls r0, 24 - lsrs r0, 24 - asrs r4, r0 - ldr r0, _080B3EB4 @ =gTasks - lsls r5, r6, 2 - adds r5, r6 - lsls r5, 3 - adds r5, r0 - movs r1, 0xA - ldrsh r0, [r5, r1] - muls r0, r4 - mov r2, r8 - str r0, [r2] - movs r0, 0 - movs r1, 0xA - movs r2, 0xD - movs r3, 0xD - bl MenuZeroFillWindowRect - ldr r0, _080B3EB8 @ =gBGTilemapBuffers + 0x800 - movs r1, 0x2 - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - movs r1, 0x1 - movs r2, 0xB - movs r3, 0xC - bl sub_80A3FA0 - bl sub_80B379C - bl sub_80B3420 - ldrb r0, [r7, 0xB] - ldrb r1, [r7, 0x9] - adds r0, r1 - ldr r1, [r7, 0x4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - ldr r1, _080B3EBC @ =gStringVar1 - bl CopyItemName - ldr r0, _080B3EC0 @ =gStringVar2 - movs r2, 0xA - ldrsh r1, [r5, r2] - movs r2, 0 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - ldr r0, _080B3EC4 @ =gStringVar3 - mov r2, r8 - ldr r1, [r2] - movs r2, 0 - movs r3, 0x8 - bl ConvertIntToDecimalStringN - ldr r4, _080B3EC8 @ =gStringVar4 - ldr r1, _080B3ECC @ =gOtherText_ThatWillBe - adds r0, r4, 0 - bl StringExpandPlaceholders - ldr r2, _080B3ED0 @ =sub_80B3D38 - ldr r3, _080B3ED4 @ =0x0000c3e1 - adds r0, r6, 0 - adds r1, r4, 0 - bl DisplayItemMessageOnField - b _080B3EF0 - .align 2, 0 -_080B3EA8: .4byte gUnknown_03000708 -_080B3EAC: .4byte gMain -_080B3EB0: .4byte gUnknown_020386A0 -_080B3EB4: .4byte gTasks -_080B3EB8: .4byte gBGTilemapBuffers + 0x800 -_080B3EBC: .4byte gStringVar1 -_080B3EC0: .4byte gStringVar2 -_080B3EC4: .4byte gStringVar3 -_080B3EC8: .4byte gStringVar4 -_080B3ECC: .4byte gOtherText_ThatWillBe -_080B3ED0: .4byte sub_80B3D38 -_080B3ED4: .4byte 0x0000c3e1 -_080B3ED8: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080B3EF0 - ldrb r1, [r7, 0x9] - adds r0, r1, 0 - movs r2, 0 - bl sub_80B39D0 - adds r0, r4, 0 - bl sub_80B4378 -_080B3EF0: - add sp, 0x8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80B3DC8 - - thumb_func_start sub_80B3EFC -sub_80B3EFC: @ 80B3EFC - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, _080B3F78 @ =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - movs r1, 0x1 - strh r1, [r0, 0xA] - movs r0, 0 - movs r1, 0xA - movs r2, 0xD - movs r3, 0xD - bl MenuDrawTextWindow - adds r0, r5, 0 - bl sub_80B37F8 - ldr r6, _080B3F7C @ =gUnknown_03000708 - ldrb r0, [r6, 0xB] - ldrb r1, [r6, 0x9] - adds r0, r1 - ldr r1, [r6, 0x4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - bl ItemId_GetPrice - adds r4, r0, 0 - movs r0, 0x1 - bl GetPriceReduction - ldr r1, _080B3F80 @ =gSaveBlock1 - movs r2, 0x92 - lsls r2, 3 - adds r1, r2 - lsls r4, 16 - lsrs r4, 16 - lsls r0, 24 - lsrs r0, 24 - asrs r4, r0 - ldr r0, [r1] - adds r1, r4, 0 - bl __udivsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x63 - bls _080B3F62 - movs r0, 0x63 -_080B3F62: - strb r0, [r6, 0xD] - ldr r0, _080B3F78 @ =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldr r0, _080B3F84 @ =sub_80B3DC8 - str r0, [r1] - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_080B3F78: .4byte gTasks -_080B3F7C: .4byte gUnknown_03000708 -_080B3F80: .4byte gSaveBlock1 -_080B3F84: .4byte sub_80B3DC8 - thumb_func_end sub_80B3EFC - - thumb_func_start sub_80B3F88 -sub_80B3F88: @ 80B3F88 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - ldr r0, _080B4020 @ =gMenuWindow - mov r8, r0 - ldr r1, [r0, 0x28] - ldr r3, _080B4024 @ =0x000003de - adds r1, r3 - adds r2, r1, 0 - adds r2, 0x80 - ldr r7, [r0, 0x24] - mov r10, r7 - ldr r0, _080B4028 @ =0x000003ff - mov r9, r0 - movs r6, 0xD -_080B3FAC: - adds r3, r2, 0 - subs r3, 0x40 - str r3, [sp] - movs r7, 0x40 - negs r7, r7 - adds r7, r1 - mov r12, r7 - adds r3, r2, 0 - adds r4, r1, 0 - movs r5, 0xE -_080B3FC0: - ldrh r2, [r4] - mov r1, r9 - ands r1, r2 - mov r7, r8 - ldrh r0, [r7, 0x1A] - adds r0, 0x1 - cmp r1, r0 - ble _080B3FD4 - adds r0, r2, 0 - adds r0, 0x3C -_080B3FD4: - strh r0, [r3] - adds r3, 0x2 - adds r4, 0x2 - subs r5, 0x1 - cmp r5, 0 - bge _080B3FC0 - ldr r2, [sp] - mov r1, r12 - subs r6, 0x1 - cmp r6, 0 - bge _080B3FAC - ldr r1, _080B402C @ =0x00003a20 - add r1, r10 - movs r0, 0xF0 - lsls r0, 3 - adds r2, r1, r0 - ldr r3, _080B4030 @ =0x040000d4 - ldr r5, _080B4034 @ =0x800000f0 - ldr r4, _080B4038 @ =0xfffffc40 - movs r6, 0xD -_080B3FFC: - str r1, [r3] - str r2, [r3, 0x4] - str r5, [r3, 0x8] - ldr r0, [r3, 0x8] - adds r2, r4 - adds r1, r4 - subs r6, 0x1 - cmp r6, 0 - bge _080B3FFC - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080B4020: .4byte gMenuWindow -_080B4024: .4byte 0x000003de -_080B4028: .4byte 0x000003ff -_080B402C: .4byte 0x00003a20 -_080B4030: .4byte 0x040000d4 -_080B4034: .4byte 0x800000f0 -_080B4038: .4byte 0xfffffc40 - thumb_func_end sub_80B3F88 - - thumb_func_start sub_80B403C -sub_80B403C: @ 80B403C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - ldr r0, _080B40D8 @ =gMenuWindow - mov r8, r0 - ldr r2, [r0, 0x28] - adds r1, r2, 0 - adds r1, 0x9E - adds r2, r1, 0 - adds r1, 0x80 - ldr r3, [r0, 0x24] - mov r10, r3 - ldr r7, _080B40DC @ =0x000003ff - mov r9, r7 - movs r6, 0xD -_080B4060: - adds r0, r2, 0 - adds r0, 0x40 - str r0, [sp] - movs r3, 0x40 - adds r3, r1 - mov r12, r3 - adds r3, r2, 0 - adds r4, r1, 0 - movs r5, 0xE -_080B4072: - ldrh r2, [r4] - mov r1, r9 - ands r1, r2 - mov r7, r8 - ldrh r0, [r7, 0x1A] - adds r0, 0x1 - cmp r1, r0 - ble _080B4086 - adds r0, r2, 0 - subs r0, 0x3C -_080B4086: - strh r0, [r3] - adds r3, 0x2 - adds r4, 0x2 - subs r5, 0x1 - cmp r5, 0 - bge _080B4072 - ldr r2, [sp] - mov r1, r12 - subs r6, 0x1 - cmp r6, 0 - bge _080B4060 - movs r1, 0x96 - lsls r1, 4 - add r1, r10 - adds r2, r1, 0 - movs r0, 0xF0 - lsls r0, 3 - adds r1, r0 - ldr r3, _080B40E0 @ =0x040000d4 - ldr r5, _080B40E4 @ =0x800000f0 - movs r4, 0xF0 - lsls r4, 2 - movs r6, 0xD -_080B40B4: - str r1, [r3] - str r2, [r3, 0x4] - str r5, [r3, 0x8] - ldr r0, [r3, 0x8] - adds r2, r4 - adds r1, r4 - subs r6, 0x1 - cmp r6, 0 - bge _080B40B4 - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080B40D8: .4byte gMenuWindow -_080B40DC: .4byte 0x000003ff -_080B40E0: .4byte 0x040000d4 -_080B40E4: .4byte 0x800000f0 - thumb_func_end sub_80B403C - - thumb_func_start sub_80B40E8 -sub_80B40E8: @ 80B40E8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r7, r0, 24 - mov r8, r7 - ldr r0, _080B4134 @ =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _080B4102 - b _080B436C -_080B4102: - ldr r2, _080B4138 @ =gMain - ldrh r0, [r2, 0x30] - movs r1, 0xF0 - ands r1, r0 - cmp r1, 0x40 - bne _080B414C - ldr r4, _080B413C @ =gUnknown_03000708 - ldrb r0, [r4, 0x9] - cmp r0, 0 - bne _080B4140 - ldrb r0, [r4, 0xB] - cmp r0, 0 - bne _080B411E - b _080B436C -_080B411E: - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4, 0xB] - subs r0, 0x1 - strb r0, [r4, 0xB] - bl sub_80B3F88 - movs r0, 0 - movs r1, 0 - b _080B417A - .align 2, 0 -_080B4134: .4byte gPaletteFade -_080B4138: .4byte gMain -_080B413C: .4byte gUnknown_03000708 -_080B4140: - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 - negs r0, r0 - b _080B41A0 -_080B414C: - cmp r1, 0x80 - bne _080B41AC - ldr r4, _080B418C @ =gUnknown_03000708 - ldrb r0, [r4, 0x9] - cmp r0, 0x7 - bne _080B4190 - ldrb r0, [r4, 0xB] - ldrb r1, [r4, 0x9] - adds r0, r1 - ldrb r1, [r4, 0x8] - cmp r0, r1 - bne _080B4166 - b _080B436C -_080B4166: - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4, 0xB] - adds r0, 0x1 - strb r0, [r4, 0xB] - bl sub_80B403C - movs r0, 0x7 - movs r1, 0x7 -_080B417A: - movs r2, 0 - bl sub_80B39D0 - bl sub_80B3A70 - bl sub_80B32A4 - b _080B436C - .align 2, 0 -_080B418C: .4byte gUnknown_03000708 -_080B4190: - ldrb r2, [r4, 0x8] - cmp r0, r2 - bne _080B4198 - b _080B436C -_080B4198: - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 -_080B41A0: - bl MoveMenuCursor - strb r0, [r4, 0x9] - bl sub_80B3A70 - b _080B436C -_080B41AC: - ldrh r1, [r2, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080B41B8 - b _080B4358 -_080B41B8: - movs r0, 0x5 - bl PlaySE - ldr r6, _080B426C @ =gUnknown_03000708 - ldrb r0, [r6, 0xB] - ldrb r1, [r6, 0x9] - adds r0, r1 - ldrb r1, [r6, 0x8] - cmp r0, r1 - bne _080B41CE - b _080B4350 -_080B41CE: - movs r0, 0 - bl PauseVerticalScrollIndicator - movs r0, 0x1 - bl PauseVerticalScrollIndicator - movs r0, 0x1 - movs r1, 0x1 - bl sub_80F979C - ldrb r1, [r6, 0x9] - adds r0, r1, 0 - movs r2, 0x1 - bl sub_80B39D0 - bl HandleDestroyMenuCursors - movs r0, 0 - movs r1, 0xC - movs r2, 0xD - movs r3, 0x13 - bl MenuZeroFillWindowRect - ldrb r0, [r6, 0xC] - cmp r0, 0 - bne _080B428C - ldr r5, _080B4270 @ =gUnknown_020386A0 - ldrb r0, [r6, 0xB] - ldrb r1, [r6, 0x9] - adds r0, r1 - ldr r1, [r6, 0x4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - bl ItemId_GetPrice - adds r4, r0, 0 - movs r0, 0x1 - bl GetPriceReduction - lsls r4, 16 - lsrs r4, 16 - lsls r0, 24 - lsrs r0, 24 - asrs r4, r0 - str r4, [r5] - ldr r0, _080B4274 @ =gSaveBlock1 - movs r2, 0x92 - lsls r2, 3 - adds r0, r2 - ldr r0, [r0] - adds r1, r4, 0 - bl IsEnoughMoney - lsls r0, 24 - cmp r0, 0 - beq _080B42BA - ldrb r0, [r6, 0xB] - ldrb r1, [r6, 0x9] - adds r0, r1 - ldr r1, [r6, 0x4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - ldr r1, _080B4278 @ =gStringVar1 - bl CopyItemName - ldr r4, _080B427C @ =gStringVar4 - ldr r1, _080B4280 @ =gOtherText_HowManyYouWant - adds r0, r4, 0 - bl StringExpandPlaceholders - ldr r2, _080B4284 @ =sub_80B3EFC - ldr r3, _080B4288 @ =0x0000c3e1 - adds r0, r7, 0 - adds r1, r4, 0 - bl DisplayItemMessageOnField - b _080B436C - .align 2, 0 -_080B426C: .4byte gUnknown_03000708 -_080B4270: .4byte gUnknown_020386A0 -_080B4274: .4byte gSaveBlock1 -_080B4278: .4byte gStringVar1 -_080B427C: .4byte gStringVar4 -_080B4280: .4byte gOtherText_HowManyYouWant -_080B4284: .4byte sub_80B3EFC -_080B4288: .4byte 0x0000c3e1 -_080B428C: - ldr r5, _080B42C8 @ =gUnknown_020386A0 - ldr r4, _080B42CC @ =gDecorations - ldrb r0, [r6, 0xB] - ldrb r1, [r6, 0x9] - adds r0, r1 - ldr r1, [r6, 0x4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - lsls r0, 5 - adds r0, r4 - ldrh r1, [r0, 0x14] - str r1, [r5] - ldr r0, _080B42D0 @ =gSaveBlock1 - movs r2, 0x92 - lsls r2, 3 - adds r0, r2 - ldr r0, [r0] - bl IsEnoughMoney - lsls r0, 24 - cmp r0, 0 - bne _080B42E0 -_080B42BA: - ldr r1, _080B42D4 @ =gOtherText_NotEnoughMoney - ldr r2, _080B42D8 @ =sub_80B3BD0 - ldr r3, _080B42DC @ =0x0000c3e1 - adds r0, r7, 0 - bl DisplayItemMessageOnField - b _080B436C - .align 2, 0 -_080B42C8: .4byte gUnknown_020386A0 -_080B42CC: .4byte gDecorations -_080B42D0: .4byte gSaveBlock1 -_080B42D4: .4byte gOtherText_NotEnoughMoney -_080B42D8: .4byte sub_80B3BD0 -_080B42DC: .4byte 0x0000c3e1 -_080B42E0: - ldr r0, _080B4318 @ =gStringVar1 - ldrb r1, [r6, 0xB] - ldrb r2, [r6, 0x9] - adds r1, r2 - ldr r2, [r6, 0x4] - lsls r1, 1 - adds r1, r2 - ldrh r1, [r1] - lsls r1, 5 - adds r2, r4, 0x1 - adds r1, r2 - bl StringCopy - ldr r0, _080B431C @ =gStringVar2 - ldr r1, [r5] - movs r2, 0 - movs r3, 0x8 - bl ConvertIntToDecimalStringN - ldrb r0, [r6, 0xC] - cmp r0, 0x1 - bne _080B4328 - ldr r0, _080B4320 @ =gStringVar4 - ldr r1, _080B4324 @ =gOtherText_ThatWillBe2 - bl StringExpandPlaceholders - b _080B4330 - .align 2, 0 -_080B4318: .4byte gStringVar1 -_080B431C: .4byte gStringVar2 -_080B4320: .4byte gStringVar4 -_080B4324: .4byte gOtherText_ThatWillBe2 -_080B4328: - ldr r0, _080B4340 @ =gStringVar4 - ldr r1, _080B4344 @ =gOtherText_ThatWillBe3 - bl StringExpandPlaceholders -_080B4330: - ldr r1, _080B4340 @ =gStringVar4 - ldr r2, _080B4348 @ =sub_80B3D38 - ldr r3, _080B434C @ =0x0000c3e1 - mov r0, r8 - bl DisplayItemMessageOnField - b _080B436C - .align 2, 0 -_080B4340: .4byte gStringVar4 -_080B4344: .4byte gOtherText_ThatWillBe3 -_080B4348: .4byte sub_80B3D38 -_080B434C: .4byte 0x0000c3e1 -_080B4350: - adds r0, r7, 0 - bl sub_80B43F0 - b _080B436C -_080B4358: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080B436C - movs r0, 0x5 - bl PlaySE - mov r0, r8 - bl sub_80B43F0 -_080B436C: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80B40E8 - - thumb_func_start sub_80B4378 -sub_80B4378: @ 80B4378 - push {r4,lr} - sub sp, 0x8 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0 - movs r1, 0xE - movs r2, 0x1D - movs r3, 0x13 - bl MenuZeroFillWindowRect - movs r0, 0 - movs r1, 0xA - movs r2, 0xD - movs r3, 0xD - bl MenuZeroFillWindowRect - ldr r0, _080B43E4 @ =gBGTilemapBuffers + 0x800 - movs r1, 0x2 - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - movs r1, 0x1 - movs r2, 0xB - movs r3, 0xC - bl sub_80A3FA0 - bl sub_80B3420 - movs r0, 0x6 - movs r1, 0x7 - bl sub_80B3764 - bl sub_80B37EC - movs r0, 0 - bl StartVerticalScrollIndicators - movs r0, 0x1 - bl StartVerticalScrollIndicators - bl sub_80B32A4 - ldr r1, _080B43E8 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, _080B43EC @ =sub_80B40E8 - str r1, [r0] - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080B43E4: .4byte gBGTilemapBuffers + 0x800 -_080B43E8: .4byte gTasks -_080B43EC: .4byte sub_80B40E8 - thumb_func_end sub_80B4378 - - thumb_func_start sub_80B43F0 -sub_80B43F0: @ 80B43F0 - push {r4,lr} - sub sp, 0x4 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r1, _080B4428 @ =gFieldCallback - ldr r0, _080B442C @ =sub_80B3050 - str r0, [r1] - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, _080B4430 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, _080B4434 @ =Task_ExitBuyMenu - str r1, [r0] - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080B4428: .4byte gFieldCallback -_080B442C: .4byte sub_80B3050 -_080B4430: .4byte gTasks -_080B4434: .4byte Task_ExitBuyMenu - thumb_func_end sub_80B43F0 - - thumb_func_start Task_ExitBuyMenu -Task_ExitBuyMenu: @ 80B4438 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, _080B4468 @ =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _080B4462 - movs r0, 0 - movs r1, 0 - bl RemoveMoneyLabelObject - bl BuyMenuFreeMemory - ldr r0, _080B446C @ =c2_exit_to_overworld_2_switch - bl SetMainCallback2 - adds r0, r4, 0 - bl DestroyTask -_080B4462: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080B4468: .4byte gPaletteFade -_080B446C: .4byte c2_exit_to_overworld_2_switch - thumb_func_end Task_ExitBuyMenu - - thumb_func_start sub_80B4470 -sub_80B4470: @ 80B4470 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r5, r0, 24 - movs r2, 0 - ldr r0, _080B44C8 @ =gUnknown_02038724 - mov r12, r0 - ldr r6, _080B44CC @ =gUnknown_03000708 - mov r8, r12 - adds r4, r6, 0 - ldr r1, _080B44D0 @ =gTasks - mov r9, r1 - lsls r0, r5, 2 - adds r0, r5 - lsls r7, r0, 3 -_080B4492: - lsls r0, r2, 2 - mov r1, r8 - adds r3, r0, r1 - ldrb r0, [r4, 0xB] - ldrb r1, [r4, 0x9] - adds r0, r1 - ldr r1, [r4, 0x4] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r3] - ldrh r0, [r0] - cmp r1, r0 - bne _080B44DC - ldrh r0, [r3, 0x2] - cmp r0, 0 - beq _080B44DC - adds r2, r0, 0 - mov r4, r9 - adds r1, r7, r4 - movs r4, 0xA - ldrsh r0, [r1, r4] - adds r0, r2, r0 - cmp r0, 0xFF - ble _080B44D4 - movs r0, 0xFF - strh r0, [r3, 0x2] - b _080B451E - .align 2, 0 -_080B44C8: .4byte gUnknown_02038724 -_080B44CC: .4byte gUnknown_03000708 -_080B44D0: .4byte gTasks -_080B44D4: - ldrh r0, [r1, 0xA] - adds r0, r2, r0 - strh r0, [r3, 0x2] - b _080B451E -_080B44DC: - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r2, 0x2 - bls _080B4492 - ldr r3, _080B452C @ =gUnknown_02038730 - ldrb r0, [r3] - cmp r0, 0x2 - bhi _080B451E - adds r2, r0, 0 - lsls r2, 2 - add r2, r12 - ldrb r0, [r6, 0xB] - ldrb r1, [r6, 0x9] - adds r0, r1 - ldr r1, [r6, 0x4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - strh r0, [r2] - ldrb r1, [r3] - lsls r1, 2 - add r1, r12 - ldr r2, _080B4530 @ =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r2 - ldrh r0, [r0, 0xA] - strh r0, [r1, 0x2] - ldrb r0, [r3] - adds r0, 0x1 - strb r0, [r3] -_080B451E: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080B452C: .4byte gUnknown_02038730 -_080B4530: .4byte gTasks - thumb_func_end sub_80B4470 - - thumb_func_start ClearItemPurchases -ClearItemPurchases: @ 80B4534 - push {lr} - ldr r0, _080B4548 @ =gUnknown_02038730 - movs r1, 0 - strb r1, [r0] - ldr r0, _080B454C @ =gUnknown_02038724 - movs r1, 0x3 - bl ClearItemSlots - pop {r0} - bx r0 - .align 2, 0 -_080B4548: .4byte gUnknown_02038730 -_080B454C: .4byte gUnknown_02038724 - thumb_func_end ClearItemPurchases - - thumb_func_start CreatePokemartMenu -CreatePokemartMenu: @ 80B4550 - push {r4,lr} - adds r4, r0, 0 - movs r0, 0 - bl CreateShopMenu - adds r0, r4, 0 - bl SetShopItemsForSale - bl ClearItemPurchases - ldr r0, _080B4570 @ =EnableBothScriptContexts - bl SetShopMenuCallback - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080B4570: .4byte EnableBothScriptContexts - thumb_func_end CreatePokemartMenu - - thumb_func_start CreateDecorationShop1Menu -CreateDecorationShop1Menu: @ 80B4574 - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x1 - bl CreateShopMenu - adds r0, r4, 0 - bl SetShopItemsForSale - ldr r0, _080B4590 @ =EnableBothScriptContexts - bl SetShopMenuCallback - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080B4590: .4byte EnableBothScriptContexts - thumb_func_end CreateDecorationShop1Menu - - thumb_func_start CreateDecorationShop2Menu -CreateDecorationShop2Menu: @ 80B4594 - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x2 - bl CreateShopMenu - adds r0, r4, 0 - bl SetShopItemsForSale - ldr r0, _080B45B0 @ =EnableBothScriptContexts - bl SetShopMenuCallback - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080B45B0: .4byte EnableBothScriptContexts - thumb_func_end CreateDecorationShop2Menu - - thumb_func_start sub_80B45B4 -sub_80B45B4: @ 80B45B4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - mov r9, r1 - lsls r0, 24 - lsrs r0, 24 - lsls r2, 16 - lsrs r2, 16 - mov r10, r2 - ldr r2, _080B4648 @ =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldrh r0, [r1, 0x10] - subs r0, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - ldrh r0, [r1, 0x12] - subs r0, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - ldrh r4, [r1, 0xA] - movs r2, 0xC - ldrsh r0, [r1, r2] - cmp r0, 0 - bne _080B4678 - movs r2, 0 - lsls r5, 16 - str r5, [sp, 0xC] - lsls r0, r3, 16 - lsls r1, r4, 16 - asrs r0, 16 - str r0, [sp] - asrs r1, 16 - str r1, [sp, 0x4] - lsls r0, r1, 1 - mov r1, r9 - adds r7, r0, r1 -_080B4608: - movs r4, 0 - lsls r2, 16 - mov r8, r2 - asrs r0, r2, 16 - ldr r2, [sp] - adds r6, r2, r0 -_080B4614: - ldr r0, [sp, 0xC] - asrs r1, r0, 16 - lsls r4, 16 - asrs r0, r4, 16 - adds r5, r1, r0 - adds r0, r5, 0 - adds r1, r6, 0 - bl MapGridGetMetatileIdAt - movs r2, 0 - ldrsh r1, [r7, r2] - lsls r0, 16 - asrs r0, 16 - cmp r1, r0 - bne _080B465C - ldr r0, [sp, 0x4] - cmp r0, 0x2 - beq _080B464C - ldrh r0, [r7, 0x2] - mov r2, r10 - orrs r2, r0 - adds r0, r5, 0 - adds r1, r6, 0 - bl MapGridSetMetatileIdAt - b _080B465C - .align 2, 0 -_080B4648: .4byte gTasks -_080B464C: - mov r1, r9 - ldrh r0, [r1] - mov r2, r10 - orrs r2, r0 - adds r0, r5, 0 - adds r1, r6, 0 - bl MapGridSetMetatileIdAt -_080B465C: - movs r2, 0x80 - lsls r2, 9 - adds r0, r4, r2 - lsrs r4, r0, 16 - asrs r0, 16 - cmp r0, 0x2 - ble _080B4614 - adds r0, r2, 0 - add r0, r8 - lsrs r2, r0, 16 - asrs r0, 16 - cmp r0, 0x2 - ble _080B4608 - b _080B4700 -_080B4678: - movs r2, 0 - lsls r5, 16 - str r5, [sp, 0xC] - lsls r0, r3, 16 - lsls r1, r4, 16 - asrs r0, 16 - str r0, [sp, 0x8] - asrs r7, r1, 16 -_080B4688: - movs r4, 0 - lsls r2, 16 - mov r8, r2 - asrs r0, r2, 16 - ldr r1, [sp, 0x8] - adds r6, r1, r0 -_080B4694: - ldr r2, [sp, 0xC] - asrs r1, r2, 16 - lsls r4, 16 - asrs r0, r4, 16 - adds r5, r1, r0 - adds r0, r5, 0 - adds r1, r6, 0 - bl MapGridGetMetatileIdAt - movs r1, 0x2 - subs r1, r7 - lsls r1, 1 - add r1, r9 - movs r2, 0 - ldrsh r1, [r1, r2] - lsls r0, 16 - asrs r0, 16 - cmp r1, r0 - bne _080B46E6 - cmp r7, 0x2 - beq _080B46D6 - movs r0, 0x1 - subs r0, r7 - lsls r0, 1 - add r0, r9 - ldrh r0, [r0] - mov r2, r10 - orrs r2, r0 - adds r0, r5, 0 - adds r1, r6, 0 - bl MapGridSetMetatileIdAt - b _080B46E6 -_080B46D6: - mov r1, r9 - ldrh r0, [r1, 0x4] - mov r2, r10 - orrs r2, r0 - adds r0, r5, 0 - adds r1, r6, 0 - bl MapGridSetMetatileIdAt -_080B46E6: - movs r2, 0x80 - lsls r2, 9 - adds r0, r4, r2 - lsrs r4, r0, 16 - asrs r0, 16 - cmp r0, 0x2 - ble _080B4694 - adds r0, r2, 0 - add r0, r8 - lsrs r2, r0, 16 - asrs r0, 16 - cmp r0, 0x2 - ble _080B4688 -_080B4700: - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80B45B4 - - thumb_func_start sub_80B4710 -sub_80B4710: @ 80B4710 - push {r4,r5,lr} - lsls r0, 24 - lsrs r3, r0, 24 - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 3 - ldr r1, _080B4738 @ =gTasks + 0x8 - adds r4, r0, r1 - movs r0, 0x1 - strh r0, [r4, 0x6] - movs r1, 0 - ldrsh r0, [r4, r1] - cmp r0, 0x6 - bhi _080B47AA - lsls r0, 2 - ldr r1, _080B473C @ =_080B4740 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_080B4738: .4byte gTasks + 0x8 -_080B473C: .4byte _080B4740 - .align 2, 0 -_080B4740: - .4byte _080B475C - .4byte _080B4764 - .4byte _080B476C - .4byte _080B4774 - .4byte _080B477C - .4byte _080B4790 - .4byte _080B47A0 -_080B475C: - ldr r1, _080B4760 @ =gUnknown_083CC714 - b _080B4792 - .align 2, 0 -_080B4760: .4byte gUnknown_083CC714 -_080B4764: - ldr r1, _080B4768 @ =gUnknown_083CC71A - b _080B4792 - .align 2, 0 -_080B4768: .4byte gUnknown_083CC71A -_080B476C: - ldr r1, _080B4770 @ =gUnknown_083CC720 - b _080B477E - .align 2, 0 -_080B4770: .4byte gUnknown_083CC720 -_080B4774: - ldr r1, _080B4778 @ =gUnknown_083CC726 - b _080B4792 - .align 2, 0 -_080B4778: .4byte gUnknown_083CC726 -_080B477C: - ldr r1, _080B478C @ =gUnknown_083CC72C -_080B477E: - movs r2, 0xC0 - lsls r2, 4 - adds r0, r3, 0 - bl sub_80B45B4 - b _080B47AA - .align 2, 0 -_080B478C: .4byte gUnknown_083CC72C -_080B4790: - ldr r1, _080B479C @ =gUnknown_083CC732 -_080B4792: - adds r0, r3, 0 - movs r2, 0 - bl sub_80B45B4 - b _080B47AA - .align 2, 0 -_080B479C: .4byte gUnknown_083CC732 -_080B47A0: - ldr r1, _080B47D4 @ =gUnknown_083CC738 - adds r0, r3, 0 - movs r2, 0 - bl sub_80B45B4 -_080B47AA: - ldrh r0, [r4] - adds r0, 0x1 - movs r1, 0x7 - ands r0, r1 - strh r0, [r4] - adds r5, r0, 0 - cmp r5, 0 - bne _080B47CE - bl DrawWholeMapView - movs r1, 0x2 - ldrsh r0, [r4, r1] - adds r0, 0x1 - movs r1, 0x3 - bl __modsi3 - strh r0, [r4, 0x2] - strh r5, [r4, 0x6] -_080B47CE: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_080B47D4: .4byte gUnknown_083CC738 - thumb_func_end sub_80B4710 - - thumb_func_start sub_80B47D8 -sub_80B47D8: @ 80B47D8 - push {r4-r7,lr} - adds r5, r0, 0 - lsls r5, 16 - lsrs r5, 16 - ldr r6, _080B481C @ =sub_80B4710 - adds r0, r6, 0 - movs r1, 0 - bl CreateTask - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, _080B4820 @ =gTasks + 0x8 - adds r7, r0, r1 - adds r0, r7, 0 - adds r0, 0x8 - adds r1, r7, 0 - adds r1, 0xA - bl PlayerGetDestCoords - movs r0, 0 - strh r0, [r7] - strh r0, [r7, 0x2] - strh r5, [r7, 0x4] - adds r0, r4, 0 - bl _call_via_r6 - adds r0, r4, 0 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_080B481C: .4byte sub_80B4710 -_080B4820: .4byte gTasks + 0x8 - thumb_func_end sub_80B47D8 - - thumb_func_start sub_80B4824 -sub_80B4824: @ 80B4824 - push {lr} - lsls r0, 24 - lsrs r0, 24 - bl sub_80B47D8 - ldr r1, _080B4838 @ =gUnknown_02038731 - strb r0, [r1] - pop {r0} - bx r0 - .align 2, 0 -_080B4838: .4byte gUnknown_02038731 - thumb_func_end sub_80B4824 - - thumb_func_start sub_80B483C -sub_80B483C: @ 80B483C - push {lr} - ldr r0, _080B484C @ =gUnknown_02038731 - ldrb r0, [r0] - bl DestroyTask - pop {r0} - bx r0 - .align 2, 0 -_080B484C: .4byte gUnknown_02038731 - thumb_func_end sub_80B483C - - thumb_func_start sub_80B4850 -sub_80B4850: @ 80B4850 - push {lr} - ldr r2, _080B4874 @ =gTasks - ldr r0, _080B4878 @ =gUnknown_02038731 - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r1, r0, r2 - movs r2, 0xE - ldrsh r0, [r1, r2] - cmp r0, 0 - bne _080B487C - movs r2, 0xA - ldrsh r0, [r1, r2] - cmp r0, 0x2 - bne _080B487C - movs r0, 0 - b _080B487E - .align 2, 0 -_080B4874: .4byte gTasks -_080B4878: .4byte gUnknown_02038731 -_080B487C: - movs r0, 0x1 -_080B487E: - pop {r1} - bx r1 - thumb_func_end sub_80B4850 - - .align 2, 0 @ Don't pad with nop. diff --git a/data/shop.s b/data/shop.s deleted file mode 100644 index 071874d0e..000000000 --- a/data/shop.s +++ /dev/null @@ -1,69 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - - .align 2 -gUnknown_083CC6D0:: @ 83CC6D0 - .4byte MartText_Buy, sub_80B2EFC - .4byte MartText_Sell, sub_80B2F30 - .4byte MartText_Quit2, HandleShopMenuQuit - -gUnknown_083CC6E8:: @ 83CC6E8 - .byte 0, 1, 2 - -gUnknown_083CC6EB:: @ 83CC6EB - .byte 0, 2 - -@ unknown, unreferenced data - .align 1 - .2byte 0x2 - .2byte 0x3 - .2byte 0x4 - .2byte 0xD - .2byte 0x121 - .2byte 0xE - .2byte 0xE - .2byte 0xE - .2byte 0xE - .2byte 0xE - .2byte 0xE - .2byte 0x0 - .2byte 0x0 - - .align 2 -gUnknown_083CC708:: @ 83CC708 - .4byte sub_80B3BF4 - .4byte sub_80B3D7C - - .align 1 -gUnknown_083CC710:: @ 83CC710 - .2byte 0x41EE,0x7FFF - - .align 1 -gUnknown_083CC714:: @ 83CC714 - .2byte 0x284,0x282,0x280 - - .align 1 -gUnknown_083CC71A:: @ 83CC71A - .2byte 0x285,0x283,0x281 - - .align 1 -gUnknown_083CC720:: @ 83CC720 - .2byte 0x28C,0x28A,0x288 - - .align 1 -gUnknown_083CC726:: @ 83CC726 - .2byte 0x28D,0x28B,0x289 - - .align 1 -gUnknown_083CC72C:: @ 83CC72C - .2byte 0x2A0,0x2A2,0x2A4 - - .align 1 -gUnknown_083CC732:: @ 83CC732 - .2byte 0x2A1,0x2A3,0x2A5 - - .align 1 -gUnknown_083CC738:: @ 83CC738 - .2byte 0x2A8,0x2AA,0x2AC diff --git a/include/money.h b/include/money.h index 49015ee19..06ac00e92 100644 --- a/include/money.h +++ b/include/money.h @@ -7,7 +7,7 @@ void sub_80B79E0(u32 *, u32); void sub_80B79F8(u8 *buffer, u32 arg1, u8 arg2); void sub_80B7A94(u32 arg0, u8 arg1, u8 x, u8 y); void sub_80B7AEC(u32, u8 left, u8 top); -void sub_80B7B34(void); +void sub_80B7B34(u8, u8, int); void sub_80B7BEC(u32, u8, u8); void sub_80B7C14(u32, u8, u8); void RemoveMoneyLabelObject(u8, u8); diff --git a/include/shop.h b/include/shop.h index cca6091c9..b785ca764 100644 --- a/include/shop.h +++ b/include/shop.h @@ -1,6 +1,34 @@ #ifndef GUARD_SHOP_H #define GUARD_SHOP_H +enum +{ + MART_TYPE_0, // normal mart + MART_TYPE_1, + MART_TYPE_2, +}; + +// shop view window NPC info enum +enum +{ + MAP_OBJ_ID, + X_COORD, + Y_COORD, + ANIM_NUM +}; + +struct MartInfo +{ + /* 0x0 */ void (* callback) (void); + /* 0x4 */ u16 *itemList; + /* 0x8 */ u8 itemCount; // how many unique items are there for sale? + /* 0x9 */ u8 cursor; // this shows the on-screen true index of the cursor and not the current item selected. + /* 0xA */ u8 numChoices; // how many options does the mart have? can be either 2 or 1 (BUY/SELL vs BUY) + /* 0xB */ u8 choicesAbove; // when your cursor is far down, there are choices that have scrolled up past the top. this is the count of that. + /* 0xC */ u8 martType; // 0-2. 0 is normal mart while 1-2 seem to be decor shops or non-stackable purchases in general. + /* 0xD */ u8 curItemCount; // if you are selling an item, this is the count of the current item stack you have. +}; + void sub_80B2E38(u8); void HandleShopMenuQuit(u8); void sub_80B2FA0(u8); @@ -11,8 +39,10 @@ void BuyMenuDrawMapGraphics(void); void sub_80B3764(int, int); void sub_80B37EC(void); void sub_80B40E8(u8); -void CreatePokemartMenu(void *); -void CreateDecorationShop1Menu(void *); -void CreateDecorationShop2Menu(void *); +void CreatePokemartMenu(u16 *); +void CreateDecorationShop1Menu(u16 *); +void CreateDecorationShop2Menu(u16 *); +void sub_80B356C(void); +void sub_80B368C(void); #endif // GUARD_SHOP_H diff --git a/include/text.h b/include/text.h index 99987d2c3..9a70dec11 100644 --- a/include/text.h +++ b/include/text.h @@ -97,35 +97,35 @@ struct WindowConfig struct Window { - u8 textMode; - u8 fontNum; - u8 language; - u8 foregroundColor; - u8 backgroundColor; - u8 shadowColor; - u8 paletteNum; - u8 tilemapLeft; - u8 tilemapTop; - u8 width; - u8 height; - u8 win_field_B; - u8 win_field_C; - u8 delayCounter; - u8 spacing; - u8 win_field_F; - u8 cursorX; - u8 cursorY; - u8 left; - u16 top; - u16 state; - u16 downArrowCounter; - u16 tileDataStartOffset; - u16 tileDataOffset; - u16 textIndex; - const u8 *text; - u8 *tileData; - u16 *tilemap; - struct WindowConfig *config; + /*0x00*/ u8 textMode; + /*0x01*/ u8 fontNum; + /*0x02*/ u8 language; + /*0x03*/ u8 foregroundColor; + /*0x04*/ u8 backgroundColor; + /*0x05*/ u8 shadowColor; + /*0x06*/ u8 paletteNum; + /*0x07*/ u8 tilemapLeft; + /*0x08*/ u8 tilemapTop; + /*0x09*/ u8 width; + /*0x0A*/ u8 height; + /*0x0B*/ u8 win_field_B; + /*0x0C*/ u8 win_field_C; + /*0x0D*/ u8 delayCounter; + /*0x0E*/ u8 spacing; + /*0x0F*/ u8 win_field_F; + /*0x10*/ u8 cursorX; + /*0x11*/ u8 cursorY; + /*0x12*/ u8 left; + /*0x14*/ u16 top; // padded to 0x14 + /*0x16*/ u16 state; + /*0x18*/ u16 downArrowCounter; + /*0x1A*/ u16 tileDataStartOffset; + /*0x1C*/ u16 tileDataOffset; + /*0x1E*/ u16 textIndex; + /*0x20*/ const u8 *text; + /*0x24*/ u8 *tileData; + /*0x28*/ u16 *tilemap; + /*0x2C*/ struct WindowConfig *config; }; extern vu16 *const gBGControlRegs[]; diff --git a/ld_script.txt b/ld_script.txt index f7024cba7..7ad3c3ddb 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -159,7 +159,6 @@ SECTIONS { src/matsuda_debug_menu.o(.text); asm/contest.o(.text); src/shop.o(.text); - asm/shop.o(.text); src/berry.o(.text); src/script_menu.o(.text); src/naming_screen.o(.text); @@ -399,7 +398,7 @@ SECTIONS { src/item.o(.rodata); data/matsuda_debug_menu.o(.rodata); data/contest.o(.rodata); - data/shop.o(.rodata); + src/shop.o(.rodata); src/berry.o(.rodata); src/script_menu.o(.rodata); src/naming_screen.o(.rodata); diff --git a/src/money.c b/src/money.c index 5d9d0b689..67b7eb03f 100644 --- a/src/money.c +++ b/src/money.c @@ -148,7 +148,7 @@ void sub_80B7AEC(u32 arg0, u8 left, u8 top) } __attribute__((naked)) -void sub_80B7B34(void) +void sub_80B7B34(u8 var1, u8 var2, int var3) { asm(".syntax unified\n\ push {r4-r7,lr}\n\ diff --git a/src/shop.c b/src/shop.c index d53646a88..6a88f1394 100644 --- a/src/shop.c +++ b/src/shop.c @@ -16,68 +16,106 @@ #include "task.h" #include "tv.h" #include "unknown_task.h" +#include "field_map_obj.h" +#include "field_player_avatar.h" +#include "fieldmap.h" +#include "item.h" +#include "decoration.h" +#include "items.h" +#include "songs.h" +#include "rom4.h" +#include "decoration_inventory.h" +#include "field_camera.h" -struct UnknownShopStruct -{ - /* 0x0 */ void (* callback) (void); - /* 0x4 */ u16 *itemList; - /* 0x8 */ u8 itemCount; - /* 0x9 */ u8 unk9; - /* 0xA */ u8 unkA; - /* 0xB */ u8 unkB; - /* 0xC */ bool8 unkC; - // unknown size -}; +#define ewram18000 ((u16 *)(ewram + 0x18000)) +#define ewram18300 ((u16 *)(ewram + 0x18300)) -extern struct UnknownShopStruct gUnknown_03000708; -extern struct MenuAction gUnknown_083CC6D0[]; +extern bool8 sub_80A52C4(u8, u8); -extern u8 gUnknown_083CC6E8[]; -extern u8 gUnknown_083CC6EB[]; +extern u8 ewram[]; extern u8 gBuyMenuFrame_Gfx[]; - extern u16 gBuyMenuFrame_Tilemap[]; extern u16 gMenuMoneyPal[16]; -extern u16 gUnknown_083CC710[2]; -u8 CreateShopMenu(bool8 var) +void sub_80B39D0(int var1, int var2, bool32 hasControlCode); +void sub_80B3A70(void); +void sub_80B4378(u8); +void sub_80B43F0(u8); +void Task_ExitBuyMenu(u8); +void sub_80B4470(u8); +void sub_80B2EFC(u8 taskId); +void sub_80B2F30(u8 taskId); +void HandleShopMenuQuit(u8 taskId); +void sub_80B3BF4(u8 taskId); +void sub_80B3D7C(u8 taskId); + +// iwram +static struct MartInfo gMartInfo; + +// ewram +EWRAM_DATA u32 gMartTotalCost = 0; +EWRAM_DATA s16 gUnknown_020386A4[16][4] = {0}; // game freak barely uses 2d arrays wtf? +EWRAM_DATA struct ItemSlot gUnknown_02038724[3] = {0}; // tv.c uses this, so it cant be static +EWRAM_DATA u8 gUnknown_02038730 = 0; +EWRAM_DATA u8 gUnknown_02038731 = 0; + +// rodata +static const struct MenuAction2 gUnknown_083CC6D0[] = +{ + { MartText_Buy, sub_80B2EFC }, + { MartText_Sell, sub_80B2F30 }, + { MartText_Quit2, HandleShopMenuQuit }, +}; + +static const u8 gUnknown_083CC6E8[] = {0, 1, 2}; // BUY SELL EXIT +static const u8 gUnknown_083CC6EB[] = {0, 2}; // BUY EXIT + +static const u16 gUnusedMartArray[] = {0x2, 0x3, 0x4, 0xD, 0x121, 0xE, 0xE, 0xE, 0xE, 0xE, 0xE, 0x0, 0x0}; + +static const struct YesNoFuncTable gUnknown_083CC708[] = +{ + sub_80B3BF4, + sub_80B3D7C +}; + +u8 CreateShopMenu(u8 martType) { ScriptContext2_Enable(); - gUnknown_03000708.unkC = var; - gUnknown_03000708.unk9 = 0; + gMartInfo.martType = martType; + gMartInfo.cursor = 0; - if(var == FALSE) + if (martType == MART_TYPE_0) { - gUnknown_03000708.unkA = 2; + gMartInfo.numChoices = 2; MenuDrawTextWindow(0, 0, 10, 7); - PrintMenuItemsReordered(1, 1, 3, gUnknown_083CC6D0, (u8 *)gUnknown_083CC6E8); + PrintMenuItemsReordered(1, 1, 3, (struct MenuAction *)gUnknown_083CC6D0, (u8 *)gUnknown_083CC6E8); } else { - gUnknown_03000708.unkA = 1; + gMartInfo.numChoices = 1; MenuDrawTextWindow(0, 0, 10, 5); - PrintMenuItemsReordered(1, 1, 2, gUnknown_083CC6D0, (u8 *)gUnknown_083CC6EB); + PrintMenuItemsReordered(1, 1, 2, (struct MenuAction *)gUnknown_083CC6D0, (u8 *)gUnknown_083CC6EB); } - InitMenu(0, 1, 1, gUnknown_03000708.unkA + 1, 0, 9); + InitMenu(0, 1, 1, gMartInfo.numChoices + 1, 0, 9); // add 1 for cancel return CreateTask(sub_80B2E38, 8); } void SetShopMenuCallback(void *callbackPtr) { - gUnknown_03000708.callback = callbackPtr; + gMartInfo.callback = callbackPtr; } void SetShopItemsForSale(u16 *items) { u16 i = 0; - gUnknown_03000708.itemList = items; - gUnknown_03000708.itemCount = 0; + gMartInfo.itemList = items; + gMartInfo.itemCount = 0; - while (gUnknown_03000708.itemList[i]) + while (gMartInfo.itemList[i]) { - gUnknown_03000708.itemCount++; + gMartInfo.itemCount++; i++; } } @@ -86,37 +124,37 @@ void sub_80B2E38(u8 var) { const u8 local = var; - if(gMain.newAndRepeatedKeys & 0x40) + if (gMain.newAndRepeatedKeys & DPAD_UP) { - if(gUnknown_03000708.unk9) + if (gMartInfo.cursor) // can move cursor up? { - PlaySE(0x5); - gUnknown_03000708.unk9 = MoveMenuCursor(-1); + PlaySE(SE_SELECT); + gMartInfo.cursor = MoveMenuCursor(-1); } } - else if(gMain.newAndRepeatedKeys & 0x80) + else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { - if(gUnknown_03000708.unk9 != gUnknown_03000708.unkA) + if (gMartInfo.cursor != gMartInfo.numChoices) // can move cursor down? { - PlaySE(0x5); - gUnknown_03000708.unk9 = MoveMenuCursor(1); + PlaySE(SE_SELECT); + gMartInfo.cursor = MoveMenuCursor(1); } } - else if (gMain.newKeys & 1) + else if (gMain.newKeys & A_BUTTON) { - PlaySE(0x5); - if(!gUnknown_03000708.unkC) + PlaySE(SE_SELECT); + if (gMartInfo.martType == MART_TYPE_0) { - gUnknown_083CC6D0[gUnknown_083CC6E8[gUnknown_03000708.unk9]].func(local); + gUnknown_083CC6D0[gUnknown_083CC6E8[gMartInfo.cursor]].func(local); } else { - gUnknown_083CC6D0[gUnknown_083CC6EB[gUnknown_03000708.unk9]].func(local); + gUnknown_083CC6D0[gUnknown_083CC6EB[gMartInfo.cursor]].func(local); } } - else if(gMain.newKeys & 2) + else if (gMain.newKeys & B_BUTTON) { - PlaySE(0x5); + PlaySE(SE_SELECT); HandleShopMenuQuit(local); } } @@ -141,17 +179,17 @@ void HandleShopMenuQuit(u8 taskId) { HandleDestroyMenuCursors(); MenuZeroFillWindowRect(0, 0, 11, 8); - sub_80BE3BC(); // in tv.s? + sub_80BE3BC(); ScriptContext2_Disable(); DestroyTask(taskId); - if(gUnknown_03000708.callback) - gUnknown_03000708.callback(); // run the callback if it exists. + if (gMartInfo.callback) + gMartInfo.callback(); // run the callback if it exists. } void sub_80B2FA0(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { SetMainCallback2((void *)((u16)gTasks[taskId].data[8] << 16 | (u16)gTasks[taskId].data[9])); DestroyTask(taskId); @@ -160,15 +198,15 @@ void sub_80B2FA0(u8 taskId) void ReturnToShopMenuAfterExitingSellMenu(u8 taskId) { - CreateShopMenu(gUnknown_03000708.unkC); + CreateShopMenu(gMartInfo.martType); DestroyTask(taskId); } void Task_ExitSellMenu(u8 taskId) { - if(sub_807D770() == 1) + if (sub_807D770() == 1) { - if(gUnknown_03000708.unkC == 2) + if (gMartInfo.martType == MART_TYPE_2) DisplayItemMessageOnField(taskId, gOtherText_CanIHelpYou, ReturnToShopMenuAfterExitingSellMenu, 0); else DisplayItemMessageOnField(taskId, gOtherText_AnythingElse, ReturnToShopMenuAfterExitingSellMenu, 0); @@ -253,8 +291,8 @@ void BuyMenuDrawGraphics(void) SetUpWindowConfig(&gWindowConfig_81E6DFC); InitMenuWindow(&gWindowConfig_81E6DFC); BuyMenuDrawMapGraphics(); - gUnknown_03000708.unk9 = zero; - gUnknown_03000708.unkB = zero2; + gMartInfo.cursor = zero; + gMartInfo.choicesAbove = zero2; MenuZeroFillWindowRect(0, 0, 0x20, 0x20); sub_80B7C14(gSaveBlock1.money, 0, 0); sub_80B3764(0, 7); @@ -272,9 +310,8 @@ void BuyMenuDrawGraphics(void) void sub_80B3240(void) { - u16 tempArr[2]; + u16 tempArr[2] = {0x41EE, 0x7FFF}; - memcpy(tempArr, gUnknown_083CC710, sizeof(tempArr)); LoadPalette(&tempArr[1], 0xD1, 2); LoadPalette(&tempArr[0], 0xD8, 2); } @@ -283,7 +320,7 @@ void sub_80B3270(void) { sub_80F944C(); - if(gUnknown_03000708.itemCount > 7) + if (gMartInfo.itemCount > 7) { CreateVerticalScrollIndicators(0, 172, 12); CreateVerticalScrollIndicators(1, 172, 148); @@ -293,12 +330,12 @@ void sub_80B3270(void) void sub_80B32A4(void) { - if(gUnknown_03000708.unkB == 0) + if (gMartInfo.choicesAbove == 0) sub_80F979C(0, 1); else sub_80F979C(0, 0); - if(gUnknown_03000708.unkB + 7 >= gUnknown_03000708.itemCount) + if (gMartInfo.choicesAbove + 7 >= gMartInfo.itemCount) sub_80F979C(1, 1); else sub_80F979C(1, 0); @@ -318,13 +355,13 @@ void BuyMenuDrawMapMetatileLayer(u16 *array, s16 offset1, s16 offset2, u16 *arra array[offset1 + offset2 + 33] = array2[3]; } -void BuyMenuDrawMapMetatile(int var1, int var2, u16 *var3, s8 var4) +void BuyMenuDrawMapMetatile(int var1, int var2, u16 *var3, s32 var4) { u8 tempVar4 = var4; s16 offset1 = var1 * 2; s16 offset2 = (var2 * 0x40) + 0x40; - switch(tempVar4) + switch (tempVar4) { case 0: // _080B335C BuyMenuDrawMapMetatileLayer(gBGTilemapBuffers[2], offset1, offset2, var3); @@ -340,3 +377,975 @@ void BuyMenuDrawMapMetatile(int var1, int var2, u16 *var3, s8 var4) break; } } + +void sub_80B33D0(s16 var1, int var2, u16 *var3) +{ + s16 offset1 = var1 * 2; + s16 offset2 = (var2 * 0x40) + 0x40; + + BuyMenuDrawMapMetatileLayer(gBGTilemapBuffers[3], offset1, offset2, var3); + BuyMenuDrawMapMetatileLayer(gBGTilemapBuffers[2], offset1, offset2, var3 + 4); +} + +void sub_80B3420(void) +{ + s16 facingX; + s16 facingY; + s16 x; + s16 y; + + GetXYCoordsOneStepInFrontOfPlayer(&facingX, &facingY); + facingX -= 3; + facingY -= 3; + + for (y = 0; y < 6; y++) + { + for (x = 0; x < 7; x++) + { + u16 metatileId = MapGridGetMetatileIdAt(facingX + x, facingY + y); + + if (y != 5 && x != 6) + { + s32 r3 = MapGridGetMetatileLayerTypeAt(facingX + x, facingY + y); + + if (metatileId < 512) + BuyMenuDrawMapMetatile(x, y, (u16 *)gMapHeader.mapData->primaryTileset->metatiles + metatileId * 8, r3); + else + BuyMenuDrawMapMetatile(x, y, (u16 *)gMapHeader.mapData->secondaryTileset->metatiles + (metatileId - 512) * 8, r3); + } + else + { + if (metatileId < 512) + sub_80B33D0(x, y, (u16 *)gMapHeader.mapData->primaryTileset->metatiles + metatileId * 8); + else + sub_80B33D0(x, y, (u16 *)gMapHeader.mapData->secondaryTileset->metatiles + (metatileId - 512) * 8); + } + + if (y == 0 && x != 0 && x != 6) + sub_80B32EC(gBGTilemapBuffers[1], x * 2, 64); + } + } +} + +void BuyMenuDrawMapGraphics(void) +{ + sub_80F9020(); + sub_80B356C(); + sub_80B368C(); + sub_80B3420(); +} + +void sub_80B356C(void) +{ + s16 facingX; + s16 facingY; + u8 playerHeight; + u8 y; + u8 x; + u8 r8 = 0; + + GetXYCoordsOneStepInFrontOfPlayer(&facingX, &facingY); + playerHeight = PlayerGetZCoord(); + for (y = 0; y < 16; y++) + gUnknown_020386A4[y][MAP_OBJ_ID] = 16; + for (y = 0; y < 5; y++) + { + for (x = 0; x < 7; x++) + { + u8 mapObjId = GetFieldObjectIdByXYZ(facingX - 3 + x, facingY - 2 + y, playerHeight); + + if (mapObjId != 16) + { + gUnknown_020386A4[r8][MAP_OBJ_ID] = mapObjId; + gUnknown_020386A4[r8][X_COORD] = x; + gUnknown_020386A4[r8][Y_COORD] = y; + if (gMapObjects[mapObjId].mapobj_unk_18 == 1) + gUnknown_020386A4[r8][ANIM_NUM] = 0; + if (gMapObjects[mapObjId].mapobj_unk_18 == 2) + gUnknown_020386A4[r8][ANIM_NUM] = 1; + if (gMapObjects[mapObjId].mapobj_unk_18 == 3) + gUnknown_020386A4[r8][ANIM_NUM] = 2; + if (gMapObjects[mapObjId].mapobj_unk_18 == 4) + gUnknown_020386A4[r8][ANIM_NUM] = 3; + r8++; + } + } + } +} + +void sub_80B368C(void) +{ + u8 i; + + for (i = 0; i < 16; i++) // max objects? + { + if (gUnknown_020386A4[i][MAP_OBJ_ID] == 16) + continue; + + StartSpriteAnim(&gSprites[AddPseudoFieldObject( + gMapObjects[gUnknown_020386A4[i][MAP_OBJ_ID]].graphicsId, + SpriteCallbackDummy, + (u16)gUnknown_020386A4[i][X_COORD] * 16 + 8, + (u16)gUnknown_020386A4[i][Y_COORD] * 16 + 32, + 2)], + gUnknown_020386A4[i][ANIM_NUM]); + } +} + +void sub_80B3720(void) +{ + s16 i; + + for (i = 0; i < 0x400; i++) + { + if (ewram18000[i] != 0) + gBGTilemapBuffers[1][i] = ewram18000[i] + 0xC3E0; + } +} + +void sub_80B3764(int var1, int var2) +{ + sub_80B3720(); + sub_80B39D0(var1, var2, 0); + InitMenu(0, 0xE, 0x2, 0x8, gMartInfo.cursor, 0xF); +} + +void sub_80B379C(void) +{ + u16 i, j; + + for (i = 0; i < 8; i++) + for (j = 0; j < 14; j++) + gBGTilemapBuffers[1][32 * (i + 12) + j] = ewram18300[32 * i + j] + 0xC3E0; +} + +void sub_80B37EC(void) +{ + sub_80B3A70(); +} + +void sub_80B37F8(u8 taskId) +{ + u16 itemListIndex = gMartInfo.choicesAbove + gMartInfo.cursor; + u16 itemId = gMartInfo.itemList[itemListIndex]; + u32 price = (ItemId_GetPrice(itemId) >> GetPriceReduction(1)); + + sub_80B7A94(gTasks[taskId].data[1] * price, 6, 6, 11); + gStringVar1[0] = EXT_CTRL_CODE_BEGIN; + gStringVar1[1] = 0x14; + gStringVar1[2] = 0x6; + ConvertIntToDecimalStringN(&gStringVar1[3], gTasks[taskId].data[1], 1, 2); + MenuPrint(gOtherText_xString1, 1, 11); + sub_80A3FA0(gBGTilemapBuffers[1], 1, 11, 12, 2, 0xC3E1); +} + +void sub_80B389C(u16 itemId, u8 var2, bool32 hasControlCode) +{ + u8 *stringPtr = gStringVar1; + + if (hasControlCode != FALSE) + { + stringPtr[0] = EXT_CTRL_CODE_BEGIN; + stringPtr[1] = 0x1; + stringPtr[2] = 0x2; + stringPtr += 3; + } + + CopyItemName(itemId, stringPtr); + + sub_8072A18(&gStringVar1[0], 0x70, var2 << 3, 0x58, 0x1); + stringPtr = gStringVar1; + + if (hasControlCode != FALSE) + stringPtr = &gStringVar1[3]; + + sub_80B79F8(stringPtr, (ItemId_GetPrice(itemId) >> GetPriceReduction(1)), 0x4); + MenuPrint_PixelCoords(&gStringVar1[0], 0xCA, var2 << 3, 1); +} + +void sub_80B3930(u16 itemId, u8 var2, bool32 hasControlCode) +{ + u8 *stringPtr = gStringVar1; + + if (hasControlCode != FALSE) + { + stringPtr[0] = EXT_CTRL_CODE_BEGIN; + stringPtr[1] = 0x1; + stringPtr[2] = 0x2; + stringPtr += 3; + } + + StringCopy(stringPtr, gDecorations[itemId].name); + sub_8072A18(&gStringVar1[0], 0x70, var2 << 3, 0x58, 0x1); + stringPtr = gStringVar1; + + if (hasControlCode != FALSE) + stringPtr = &gStringVar1[3]; + + if (gDecorations[itemId].price == 10000) + { + sub_80B7B34(0x19, var2, hasControlCode); // huh??? + } + else + { + sub_80B79F8(stringPtr, gDecorations[itemId].price, 0x4); + MenuPrint_PixelCoords(&gStringVar1[0], 0xCA, var2 << 3, 0x1); + } +} + +void sub_80B39D0(int var1, int var2, bool32 hasControlCode) +{ + u8 i; + + for (i = var1; i <= var2 && gMartInfo.choicesAbove + i < gMartInfo.itemCount; i++) + { + if (gMartInfo.martType == MART_TYPE_0) + sub_80B389C(gMartInfo.itemList[gMartInfo.choicesAbove + i], (i << 1) + 2, hasControlCode); + else + sub_80B3930(gMartInfo.itemList[gMartInfo.choicesAbove + i], (i << 1) + 2, hasControlCode); + } + + if (i != 8 && gMartInfo.choicesAbove + i == gMartInfo.itemCount) + { + MenuFillWindowRectWithBlankTile(0xE, (i << 1) + 2, 0x1C, (i << 1) + 3); + MenuPrint(gOtherText_CancelNoTerminator, 0xE, (i << 1) + 2); + } +} + +void sub_80B3A70(void) +{ + if (gMartInfo.choicesAbove + gMartInfo.cursor != gMartInfo.itemCount) + { + if (gMartInfo.martType == MART_TYPE_0) + { + sub_8072AB0(ItemId_GetDescription(gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor]), + 0x4, 0x68, 0x68, 0x30, 0); + } + else + sub_8072AB0(gDecorations[gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor]].description, + 0x4, 0x68, 0x68, 0x30, 0); + } + else + { + sub_8072AB0(gOtherText_QuitShopping, 0x4, 0x68, 0x68, 0x30, 0); + } +} + +void sub_80B3AEC(u8 taskId) +{ + if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + { + sub_80B39D0(gMartInfo.cursor, gMartInfo.cursor, 0); // huh??? + PlaySE(SE_SELECT); + + if (gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor] == ITEM_POKE_BALL && gTasks[taskId].data[1] >= 10 && AddBagItem(ITEM_PREMIER_BALL, 1) == TRUE) + DisplayItemMessageOnField(taskId, gOtherText_FreePremierBall, sub_80B4378, 0xC3E1); + else + sub_80B4378(taskId); + } +} + +void sub_80B3B80(u8 taskId) +{ + IncrementGameStat(0x26); + sub_80B79E0(&gSaveBlock1.money, gMartTotalCost); + PlaySE(SE_REGI); + sub_80B7BEC(gSaveBlock1.money, 0, 0); + gTasks[taskId].func = sub_80B3AEC; +} + +void sub_80B3BD0(u8 taskId) +{ + sub_80B39D0(gMartInfo.cursor, gMartInfo.cursor, 0); // same thing as above? + sub_80B4378(taskId); +} + +void sub_80B3BF4(u8 taskId) +{ + MenuZeroFillWindowRect(0x7, 0x8, 0xD, 0xD); + sub_80A3FA0(gBGTilemapBuffers[1], 8, 9, 4, 4, 0); + sub_80B379C(); + sub_80B3420(); + + if (IsEnoughMoney(gSaveBlock1.money, gMartTotalCost)) + { + if (gMartInfo.martType == MART_TYPE_0) + { + if (AddBagItem(gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor], gTasks[taskId].data[1])) + { + DisplayItemMessageOnField(taskId, gOtherText_HereYouGo, sub_80B3B80, 0xC3E1); + sub_80B4470(taskId); + } + else + DisplayItemMessageOnField(taskId, gOtherText_NoRoomFor, sub_80B3BD0, 0xC3E1); + } + else // a normal mart is only type 0, so types 1 and 2 are decoration marts. + { + if (IsThereStorageSpaceForDecoration(gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor])) + { + if (gMartInfo.martType == MART_TYPE_1) + DisplayItemMessageOnField(taskId, gOtherText_HereYouGo2, sub_80B3B80, 0xC3E1); + else + DisplayItemMessageOnField(taskId, gOtherText_HereYouGo3, sub_80B3B80, 0xC3E1); + } + else + { + StringExpandPlaceholders(gStringVar4, gOtherText_SpaceForIsFull); + DisplayItemMessageOnField(taskId, gStringVar4, sub_80B3BD0, 0xC3E1); + } + } + } + else + DisplayItemMessageOnField(taskId, gOtherText_NotEnoughMoney, sub_80B3BD0, 0xC3E1); +} + +void sub_80B3D38(u8 taskId) +{ + DisplayYesNoMenu(7, 8, 1); + sub_80A3FA0(gBGTilemapBuffers[1], 8, 9, 4, 4, 0xC3E1); + DoYesNoFuncWithChoice(taskId, gUnknown_083CC708); +} + +void sub_80B3D7C(u8 taskId) +{ + sub_80B39D0(gMartInfo.cursor, gMartInfo.cursor, 0); + MenuZeroFillWindowRect(0x7, 0x8, 0xD, 0xD); + sub_80A3FA0(gBGTilemapBuffers[1], 0x8, 0x9, 0x4, 0x4, 0); + sub_80B4378(taskId); +} + +void sub_80B3DC8(u8 taskId) +{ + if (sub_80A52C4(taskId, gMartInfo.curItemCount) == TRUE) + sub_80B37F8(taskId); + + if (gMain.newKeys & A_BUTTON) + { + gMartTotalCost = (ItemId_GetPrice(gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor]) >> GetPriceReduction(1)) * gTasks[taskId].data[1]; // set total cost of your purchase. + MenuZeroFillWindowRect(0, 0xA, 0xD, 0xD); + sub_80A3FA0(gBGTilemapBuffers[1], 0x1, 0xB, 0xC, 0x2, 0); + sub_80B379C(); + sub_80B3420(); + CopyItemName(gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor], gStringVar1); + ConvertIntToDecimalStringN(gStringVar2, gTasks[taskId].data[1], 0, 0x2); + ConvertIntToDecimalStringN(gStringVar3, gMartTotalCost, 0, 0x8); + StringExpandPlaceholders(gStringVar4, gOtherText_ThatWillBe); + DisplayItemMessageOnField(taskId, gStringVar4, sub_80B3D38, 0xC3E1); + } + else if (gMain.newKeys & B_BUTTON) + { + sub_80B39D0(gMartInfo.cursor, gMartInfo.cursor, 0); + sub_80B4378(taskId); + } +} + +void sub_80B3EFC(u8 taskId) +{ + u16 var; + + gTasks[taskId].data[1] = 1; + MenuDrawTextWindow(0, 0xA, 0xD, 0xD); + sub_80B37F8(taskId); + + var = gSaveBlock1.money / (ItemId_GetPrice(gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor]) >> GetPriceReduction(1)); + if (var > 99) + gMartInfo.curItemCount = 99; + else + gMartInfo.curItemCount = var; + + gTasks[taskId].func = sub_80B3DC8; +} + +#ifdef NONMATCHING +void sub_80B3F88(void) +{ + u16 *r1; + u16 *r2; + register u8 *r10 asm("r10"); + s32 i; + s32 j; + struct Window *r8 = &gMenuWindow; + + r1 = r8->tilemap; + r1 += 0x1EF; + r2 = r1; + r2 += 64; + r10 = r8->tileData; + + for (i = 0; i < 14; i++) + { + for (j = 0; j < 15; j++) + { + if ((r1[j] & 0x3FF) <= r8->tileDataStartOffset + 1) + r2[j] = r8->tileDataStartOffset + 1; + else + r2[j] = r1[j] + 0x3C; + } + + r1 -= 32; + r2 -= 32; + } + + { + u8 *r1 = r10 + 0x3A20; + u8 *r2 = r1 + 0x780; + for (i = 0; i < 14; i++) + { + DmaCopy16(3, r1, r2, 0x1E0); + r2 -= 0x3C0; + r1 -= 0x3C0; + } + } +} +#else +__attribute__((naked)) +void sub_80B3F88(void) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x4\n\ + ldr r0, _080B4020 @ =gMenuWindow\n\ + mov r8, r0\n\ + ldr r1, [r0, 0x28]\n\ + ldr r3, _080B4024 @ =0x000003de\n\ + adds r1, r3\n\ + adds r2, r1, 0\n\ + adds r2, 0x80\n\ + ldr r7, [r0, 0x24]\n\ + mov r10, r7\n\ + ldr r0, _080B4028 @ =0x000003ff\n\ + mov r9, r0\n\ + movs r6, 0xD\n\ +_080B3FAC:\n\ + adds r3, r2, 0\n\ + subs r3, 0x40\n\ + str r3, [sp]\n\ + movs r7, 0x40\n\ + negs r7, r7\n\ + adds r7, r1\n\ + mov r12, r7\n\ + adds r3, r2, 0\n\ + adds r4, r1, 0\n\ + movs r5, 0xE\n\ +_080B3FC0:\n\ + ldrh r2, [r4]\n\ + mov r1, r9\n\ + ands r1, r2\n\ + mov r7, r8\n\ + ldrh r0, [r7, 0x1A]\n\ + adds r0, 0x1\n\ + cmp r1, r0\n\ + ble _080B3FD4\n\ + adds r0, r2, 0\n\ + adds r0, 0x3C\n\ +_080B3FD4:\n\ + strh r0, [r3]\n\ + adds r3, 0x2\n\ + adds r4, 0x2\n\ + subs r5, 0x1\n\ + cmp r5, 0\n\ + bge _080B3FC0\n\ + ldr r2, [sp]\n\ + mov r1, r12\n\ + subs r6, 0x1\n\ + cmp r6, 0\n\ + bge _080B3FAC\n\ + ldr r1, _080B402C @ =0x00003a20\n\ + add r1, r10\n\ + movs r0, 0xF0\n\ + lsls r0, 3\n\ + adds r2, r1, r0\n\ + ldr r3, _080B4030 @ =0x040000d4\n\ + ldr r5, _080B4034 @ =0x800000f0\n\ + ldr r4, _080B4038 @ =0xfffffc40\n\ + movs r6, 0xD\n\ +_080B3FFC:\n\ + str r1, [r3]\n\ + str r2, [r3, 0x4]\n\ + str r5, [r3, 0x8]\n\ + ldr r0, [r3, 0x8]\n\ + adds r2, r4\n\ + adds r1, r4\n\ + subs r6, 0x1\n\ + cmp r6, 0\n\ + bge _080B3FFC\n\ + add sp, 0x4\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_080B4020: .4byte gMenuWindow\n\ +_080B4024: .4byte 0x000003de\n\ +_080B4028: .4byte 0x000003ff\n\ +_080B402C: .4byte 0x00003a20\n\ +_080B4030: .4byte 0x040000d4\n\ +_080B4034: .4byte 0x800000f0\n\ +_080B4038: .4byte 0xfffffc40\n\ + .syntax divided"); +} +#endif + +#ifdef NONMATCHING +void sub_80B403C(void) +{ + u16 *r1; + u16 *r2; + u8 *r10; + s32 i; + s32 j; + struct Window *r8 = &gMenuWindow; + + r1 = r8->tilemap; + r1 += 0x4F; + r2 = r1; + r2 += 64; + r10 = r8->tileData; + + for (i = 0; i < 14; i++) + { + for (j = 0; j < 15; j++) + { + if ((r1[j] & 0x3FF) <= r8->tileDataStartOffset + 1) + r2[j] = r8->tileDataStartOffset + 1; + else + r2[j] = r1[j] + 0x3C; + } + + r1 += 32; + r2 += 32; + } + + { + register u8 *r1 asm("r1") = r10 + 0x960; + register u8 *r2 asm("r2") = r1; + + r1 += 0x780; + for (i = 0; i < 14; i++) + { + DmaCopy16(3, r1, r2, 0x1E0); + r1 += 0x3C0; + r2 += 0x3C0; + } + } +} +#else +__attribute__((naked)) +void sub_80B403C(void) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x4\n\ + ldr r0, _080B40D8 @ =gMenuWindow\n\ + mov r8, r0\n\ + ldr r2, [r0, 0x28]\n\ + adds r1, r2, 0\n\ + adds r1, 0x9E\n\ + adds r2, r1, 0\n\ + adds r1, 0x80\n\ + ldr r3, [r0, 0x24]\n\ + mov r10, r3\n\ + ldr r7, _080B40DC @ =0x000003ff\n\ + mov r9, r7\n\ + movs r6, 0xD\n\ +_080B4060:\n\ + adds r0, r2, 0\n\ + adds r0, 0x40\n\ + str r0, [sp]\n\ + movs r3, 0x40\n\ + adds r3, r1\n\ + mov r12, r3\n\ + adds r3, r2, 0\n\ + adds r4, r1, 0\n\ + movs r5, 0xE\n\ +_080B4072:\n\ + ldrh r2, [r4]\n\ + mov r1, r9\n\ + ands r1, r2\n\ + mov r7, r8\n\ + ldrh r0, [r7, 0x1A]\n\ + adds r0, 0x1\n\ + cmp r1, r0\n\ + ble _080B4086\n\ + adds r0, r2, 0\n\ + subs r0, 0x3C\n\ +_080B4086:\n\ + strh r0, [r3]\n\ + adds r3, 0x2\n\ + adds r4, 0x2\n\ + subs r5, 0x1\n\ + cmp r5, 0\n\ + bge _080B4072\n\ + ldr r2, [sp]\n\ + mov r1, r12\n\ + subs r6, 0x1\n\ + cmp r6, 0\n\ + bge _080B4060\n\ + movs r1, 0x96\n\ + lsls r1, 4\n\ + add r1, r10\n\ + adds r2, r1, 0\n\ + movs r0, 0xF0\n\ + lsls r0, 3\n\ + adds r1, r0\n\ + ldr r3, _080B40E0 @ =0x040000d4\n\ + ldr r5, _080B40E4 @ =0x800000f0\n\ + movs r4, 0xF0\n\ + lsls r4, 2\n\ + movs r6, 0xD\n\ +_080B40B4:\n\ + str r1, [r3]\n\ + str r2, [r3, 0x4]\n\ + str r5, [r3, 0x8]\n\ + ldr r0, [r3, 0x8]\n\ + adds r2, r4\n\ + adds r1, r4\n\ + subs r6, 0x1\n\ + cmp r6, 0\n\ + bge _080B40B4\n\ + add sp, 0x4\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_080B40D8: .4byte gMenuWindow\n\ +_080B40DC: .4byte 0x000003ff\n\ +_080B40E0: .4byte 0x040000d4\n\ +_080B40E4: .4byte 0x800000f0\n\ + .syntax divided"); +} +#endif + +void sub_80B40E8(u8 taskId) // Mart_DoCursorAction +{ + if (!gPaletteFade.active) + { + if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) // only up can be pressed + { + if (gMartInfo.cursor == 0) + { + if (gMartInfo.choicesAbove == 0) // if there are no choices above, dont bother + return; + + PlaySE(SE_SELECT); + gMartInfo.choicesAbove--; // since cursor is at the top and there are choices above the top, scroll the menu up by updating choicesAbove. + sub_80B3F88(); + sub_80B39D0(0, 0, 0); + sub_80B3A70(); + sub_80B32A4(); + } + else // if the cursor is not 0, choicesAbove cannot be updated yet since the cursor is at the top of the menu, so update cursor. + { + PlaySE(SE_SELECT); + gMartInfo.cursor = MoveMenuCursor(-1); // move cursor up + sub_80B3A70(); + } + } + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) // only down can be pressed + { + if (gMartInfo.cursor == 7) // are you at the bottom of the menu? + { + if (gMartInfo.choicesAbove + gMartInfo.cursor == gMartInfo.itemCount) // are you at cancel? + return; + + PlaySE(SE_SELECT); + gMartInfo.choicesAbove++; + sub_80B403C(); + sub_80B39D0(7, 7, 0); + sub_80B3A70(); + sub_80B32A4(); + } + else if (gMartInfo.cursor != gMartInfo.itemCount) + { + PlaySE(SE_SELECT); + gMartInfo.cursor = MoveMenuCursor(1); + sub_80B3A70(); + } + } + else if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + + if (gMartInfo.choicesAbove + gMartInfo.cursor != gMartInfo.itemCount) // did you not hit CANCEL? + { + PauseVerticalScrollIndicator(0); + PauseVerticalScrollIndicator(1); + sub_80F979C(1, 1); + sub_80B39D0(gMartInfo.cursor, gMartInfo.cursor, 1); + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0xC, 0xD, 0x13); + + if (gMartInfo.martType == MART_TYPE_0) + { + gMartTotalCost = (ItemId_GetPrice(gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor]) >> GetPriceReduction(1)); // set 1x price + if (!IsEnoughMoney(gSaveBlock1.money, gMartTotalCost)) + { + DisplayItemMessageOnField(taskId, gOtherText_NotEnoughMoney, sub_80B3BD0, 0xC3E1); // tail merge + } + else // _080B42BA + { + CopyItemName(gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor], gStringVar1); + StringExpandPlaceholders(gStringVar4, gOtherText_HowManyYouWant); + DisplayItemMessageOnField(taskId, gStringVar4, sub_80B3EFC, 0xC3E1); + } + } + else // _080B428C + { + gMartTotalCost = gDecorations[gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor]].price; + + if (!IsEnoughMoney(gSaveBlock1.money, gMartTotalCost)) + { + DisplayItemMessageOnField(taskId, gOtherText_NotEnoughMoney, sub_80B3BD0, 0xC3E1); // tail merge + } + else + { + StringCopy(gStringVar1, gDecorations[gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor]].name); + ConvertIntToDecimalStringN(gStringVar2, gMartTotalCost, 0, 0x8); + + if (gMartInfo.martType == MART_TYPE_1) + { + StringExpandPlaceholders(gStringVar4, gOtherText_ThatWillBe2); + } + else + { + StringExpandPlaceholders(gStringVar4, gOtherText_ThatWillBe3); + } + DisplayItemMessageOnField(taskId, gStringVar4, sub_80B3D38, 0xC3E1); + } + } + } + else + sub_80B43F0(taskId); + } + else if (gMain.newKeys & B_BUTTON) // go back to buy/sell/exit menu + { + PlaySE(SE_SELECT); + sub_80B43F0(taskId); + } + } +} + +void sub_80B4378(u8 taskId) +{ + MenuZeroFillWindowRect(0, 0xE, 0x1D, 0x13); + MenuZeroFillWindowRect(0, 0xA, 0xD, 0xD); + sub_80A3FA0(gBGTilemapBuffers[1], 0x1, 0xB, 0xC, 0x2, 0); + sub_80B3420(); + sub_80B3764(6, 7); + sub_80B37EC(); + StartVerticalScrollIndicators(0); + StartVerticalScrollIndicators(1); + sub_80B32A4(); + gTasks[taskId].func = sub_80B40E8; +} + +void sub_80B43F0(u8 taskId) +{ + gFieldCallback = sub_80B3050; + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gTasks[taskId].func = Task_ExitBuyMenu; +} + +void Task_ExitBuyMenu(u8 taskId) +{ + if (!gPaletteFade.active) + { + RemoveMoneyLabelObject(0, 0); + BuyMenuFreeMemory(); + SetMainCallback2(c2_exit_to_overworld_2_switch); + DestroyTask(taskId); + } +} + +void sub_80B4470(u8 taskId) +{ + u16 i; + + for (i = 0; i < 3; i++) + { + if (gUnknown_02038724[i].itemId == gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor] + && gUnknown_02038724[i].quantity != 0) + { + if (gUnknown_02038724[i].quantity + gTasks[taskId].data[1] > 255) + gUnknown_02038724[i].quantity = 255; + else + gUnknown_02038724[i].quantity += gTasks[taskId].data[1]; + return; + } + } + + if (gUnknown_02038730 < 3) + { + gUnknown_02038724[gUnknown_02038730].itemId = gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor]; + gUnknown_02038724[gUnknown_02038730].quantity = gTasks[taskId].data[1]; + gUnknown_02038730++; + } +} + +void ClearItemPurchases(void) +{ + gUnknown_02038730 = 0; + ClearItemSlots(gUnknown_02038724, 3); +} + +void CreatePokemartMenu(u16 *itemList) +{ + CreateShopMenu(MART_TYPE_0); + SetShopItemsForSale(itemList); + ClearItemPurchases(); + SetShopMenuCallback(EnableBothScriptContexts); +} + +void CreateDecorationShop1Menu(u16 *itemList) +{ + CreateShopMenu(MART_TYPE_1); + SetShopItemsForSale(itemList); + SetShopMenuCallback(EnableBothScriptContexts); +} + +void CreateDecorationShop2Menu(u16 *itemList) +{ + CreateShopMenu(MART_TYPE_2); + SetShopItemsForSale(itemList); + SetShopMenuCallback(EnableBothScriptContexts); +} + +void sub_80B45B4(u8 taskId, const s16 *list, u16 c) +{ + s16 r5 = gTasks[taskId].data[4] - 1; + s16 r3 = gTasks[taskId].data[5] - 1; + s16 r4 = gTasks[taskId].data[1]; + s16 y; + s16 x; + + if (gTasks[taskId].data[2] == 0) + { + for (y = 0; y < 3; y++) + { + for (x = 0; x < 3; x++) + { + s16 metatileId = MapGridGetMetatileIdAt(r5 + x, r3 + y); + + if (list[r4] == metatileId) + { + if (r4 != 2) + MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[r4 + 1]); + else + MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[0]); + } + } + } + } + else + { + for (y = 0; y < 3; y++) + { + for (x = 0; x < 3; x++) + { + s16 metatileId = MapGridGetMetatileIdAt(r5 + x, r3 + y); + + if (list[2 - r4] == metatileId) + { + if (r4 != 2) + MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[1 - r4]); + else + MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[2]); + } + } + } + } +} + +static const u16 gUnknown_083CC714[] = {0x284, 0x282, 0x280}; +static const u16 gUnknown_083CC71A[] = {0x285, 0x283, 0x281}; +static const u16 gUnknown_083CC720[] = {0x28C, 0x28A, 0x288}; +static const u16 gUnknown_083CC726[] = {0x28D, 0x28B, 0x289}; +static const u16 gUnknown_083CC72C[] = {0x2A0, 0x2A2, 0x2A4}; +static const u16 gUnknown_083CC732[] = {0x2A1, 0x2A3, 0x2A5}; +static const u16 gUnknown_083CC738[] = {0x2A8, 0x2AA, 0x2AC}; + +void sub_80B4710(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + data[3] = 1; + + switch (data[0]) + { + case 0: + sub_80B45B4(taskId, gUnknown_083CC714, 0); + break; + case 1: + sub_80B45B4(taskId, gUnknown_083CC71A, 0); + break; + case 2: + sub_80B45B4(taskId, gUnknown_083CC720, 0xC00); + break; + case 3: + sub_80B45B4(taskId, gUnknown_083CC726, 0); + break; + case 4: + sub_80B45B4(taskId, gUnknown_083CC72C, 0xC00); + break; + case 5: + sub_80B45B4(taskId, gUnknown_083CC732, 0); + break; + case 6: + sub_80B45B4(taskId, gUnknown_083CC738, 0); + break; + } + + data[0] = (data[0] + 1) & 7; + if (!data[0]) + { + DrawWholeMapView(); + data[1] = (data[1] + 1) % 3; + data[3] = 0; + } +} + +u8 sub_80B47D8(u16 var) +{ + u8 taskId = CreateTask(sub_80B4710, 0); + s16 *data = gTasks[taskId].data; + + PlayerGetDestCoords(&data[4], &data[5]); + data[0] = 0; + data[1] = 0; + data[2] = var; + sub_80B4710(taskId); + return taskId; +} + +void sub_80B4824(u8 var) +{ + gUnknown_02038731 = sub_80B47D8(var); +} + +void sub_80B483C(void) +{ + DestroyTask(gUnknown_02038731); +} + +bool8 sub_80B4850(void) +{ + if (gTasks[gUnknown_02038731].data[3] == 0 && gTasks[gUnknown_02038731].data[1] == 2) + return FALSE; + else + return TRUE; +} diff --git a/sym_bss.txt b/sym_bss.txt index 3f9757d64..b306da5f6 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -53,12 +53,7 @@ gUnknown_030006DC: @ 30006DC .include "src/field_effect.o" .include "src/item_menu.o" - -@ shop - -gUnknown_03000708: @ 3000708 - .space 0x10 - + .include "src/shop.o" .include "src/record_mixing.o" .include "src/tv.o" diff --git a/sym_ewram.txt b/sym_ewram.txt index 41a73af4d..ac6b8b728 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -510,29 +510,7 @@ gScriptContestCategory: @ 203869C gScriptContestRank: @ 203869E .space 0x2 -@ shop - -gUnknown_020386A0: @ 20386A0 - .space 0x4 - -gUnknown_020386A4: @ 20386A4 - .space 0x4 - -gUnknown_020386A8: @ 20386A8 - .space 0x2 - -gUnknown_020386AA: @ 20386AA - .space 0x7A - -gUnknown_02038724: @ 2038724 - .space 0xC - -gUnknown_02038730: @ 2038730 - .space 0x1 - -gUnknown_02038731: @ 2038731 - .space 0x3 - + .include "src/shop.o" .include "src/money.o" @ record_mixing