diff --git a/asm/shop.s b/asm/shop.s index 807237389..56658c4ff 100644 --- a/asm/shop.s +++ b/asm/shop.s @@ -5,1404 +5,6 @@ .text - thumb_func_start CreateShopMenu -@ s8 CreateShopMenu(s8 type) -CreateShopMenu: @ 80DFA78 - push {r4,r5,lr} - sub sp, 0x10 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl ScriptContext2_Enable - ldr r5, =gUnknown_02039F60 - strb r4, [r5, 0xF] - cmp r4, 0 - bne _080DFACC - ldr r0, =gUnknown_08589A38 - ldr r1, [r0, 0x4] - ldr r0, [r0] - str r0, [sp] - str r1, [sp, 0x4] - ldr r4, =gUnknown_08589A10 - adds r0, r4, 0 - movs r1, 0x3 - bl GetMaxWidthInMenuTable - lsls r0, 24 - ldr r2, =0x00ffffff - ldr r1, [sp] - ands r1, r2 - orrs r1, r0 - str r1, [sp] - mov r0, sp - bl AddWindow - strb r0, [r5, 0xE] - str r4, [r5, 0x4] - movs r5, 0x3 - b _080DFAF8 - .pool -_080DFACC: - ldr r0, =gUnknown_08589A38 - ldr r1, [r0, 0xC] - ldr r0, [r0, 0x8] - str r0, [sp, 0x8] - str r1, [sp, 0xC] - ldr r4, =gUnknown_08589A28 - adds r0, r4, 0 - movs r1, 0x2 - bl GetMaxWidthInMenuTable - lsls r0, 24 - ldr r2, =0x00ffffff - ldr r1, [sp, 0x8] - ands r1, r2 - orrs r1, r0 - str r1, [sp, 0x8] - add r0, sp, 0x8 - bl AddWindow - strb r0, [r5, 0xE] - str r4, [r5, 0x4] - movs r5, 0x2 -_080DFAF8: - ldr r4, =gUnknown_02039F60 - ldrb r0, [r4, 0xE] - movs r1, 0 - bl SetStandardWindowBorderStyle - ldrb r0, [r4, 0xE] - ldr r2, [r4, 0x4] - adds r1, r5, 0 - bl PrintMenuTable - ldrb r0, [r4, 0xE] - adds r1, r5, 0 - movs r2, 0 - bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed - ldrb r0, [r4, 0xE] - bl PutWindowTilemap - ldrb r0, [r4, 0xE] - movs r1, 0x1 - bl CopyWindowToVram - ldr r0, =Task_ShopMenu - movs r1, 0x8 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - add sp, 0x10 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end CreateShopMenu - - thumb_func_start SetShopMenuCallback -@ void SetShopMenuCallback() -SetShopMenuCallback: @ 80DFB4C - ldr r1, =gUnknown_02039F60 - str r0, [r1] - bx lr - .pool - thumb_func_end SetShopMenuCallback - - thumb_func_start SetShopItemsForSale -@ int SetShopItemsForSale(s16 *itemsForSale) -SetShopItemsForSale: @ 80DFB58 - push {lr} - adds r1, r0, 0 - movs r2, 0 - ldr r3, =gUnknown_02039F60 - str r1, [r3, 0x8] - strh r2, [r3, 0xC] - ldrh r0, [r1] - cmp r0, 0 - beq _080DFB80 -_080DFB6A: - ldrh r0, [r3, 0xC] - adds r0, 0x1 - strh r0, [r3, 0xC] - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - lsls r0, r2, 1 - adds r0, r1 - ldrh r0, [r0] - cmp r0, 0 - bne _080DFB6A -_080DFB80: - pop {r0} - bx r0 - .pool - thumb_func_end SetShopItemsForSale - - thumb_func_start Task_ShopMenu -@ void Task_ShopMenu(u8 taskId) -Task_ShopMenu: @ 80DFB88 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r5, r4, 0 - bl Menu_ProcessInputNoWrapAround - lsls r0, 24 - asrs r2, r0, 24 - movs r0, 0x2 - negs r0, r0 - cmp r2, r0 - beq _080DFBC4 - adds r0, 0x1 - cmp r2, r0 - bne _080DFBB4 - movs r0, 0x5 - bl PlaySE - adds r0, r4, 0 - bl HandleShopMenuQuit - b _080DFBC4 -_080DFBB4: - ldr r0, =gUnknown_02039F60 - ldr r1, [r0, 0x4] - lsls r0, r2, 3 - adds r0, r1 - ldr r1, [r0, 0x4] - adds r0, r5, 0 - bl _call_via_r1 -_080DFBC4: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Task_ShopMenu - - thumb_func_start HandleShopMenuBuy -@ void HandleShopMenuBuy(u8 taskId) -HandleShopMenuBuy: @ 80DFBD0 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r2, =gTasks + 0x8 - adds r4, r1, r2 - ldr r3, =CB2_InitBuyMenu - lsrs r0, r3, 16 - strh r0, [r4, 0x10] - strh r3, [r4, 0x12] - subs r2, 0x8 - adds r1, r2 - ldr r0, =Task_GoToBuyOrSellMenu - str r0, [r1] - movs r0, 0x1 - movs r1, 0 - bl FadeScreen - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end HandleShopMenuBuy - - thumb_func_start HandleShopMenuSell -@ void HandleShopMenuSell(u8 taskId) -HandleShopMenuSell: @ 80DFC0C - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r2, =gTasks + 0x8 - adds r4, r1, r2 - ldr r3, =CB2_GoToSellMenu - lsrs r0, r3, 16 - strh r0, [r4, 0x10] - strh r3, [r4, 0x12] - subs r2, 0x8 - adds r1, r2 - ldr r0, =Task_GoToBuyOrSellMenu - str r0, [r1] - movs r0, 0x1 - movs r1, 0 - bl FadeScreen - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end HandleShopMenuSell - - thumb_func_start CB2_ExitSellMenu -@ int CB2_ExitSellMenu() -CB2_ExitSellMenu: @ 80DFC48 - push {lr} - ldr r0, =gFieldCallback - ldr r1, =MapPostLoadHook_ExitBuyOrSellMenu - str r1, [r0] - ldr r0, =CB2_ReturnToField - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end CB2_ExitSellMenu - - thumb_func_start HandleShopMenuQuit -@ void HandleShopMenuQuit(u8 taskId) -HandleShopMenuQuit: @ 80DFC68 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r5, =gUnknown_02039F60 - ldrb r0, [r5, 0xE] - movs r1, 0x2 - bl sub_8198070 - ldrb r0, [r5, 0xE] - bl RemoveWindow - bl SaveRecordedItemPurchasesForTVShow - bl ScriptContext2_Disable - adds r0, r4, 0 - bl DestroyTask - ldr r5, [r5] - cmp r5, 0 - beq _080DFC98 - bl _call_via_r5 -_080DFC98: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end HandleShopMenuQuit - - thumb_func_start Task_GoToBuyOrSellMenu -@ int Task_GoToBuyOrSellMenu(u8 taskId) -Task_GoToBuyOrSellMenu: @ 80DFCA4 - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _080DFCD2 - adds r0, r2, 0 - bl DestroyTask - ldrh r0, [r4, 0x10] - lsls r0, 16 - ldrh r1, [r4, 0x12] - orrs r0, r1 - bl SetMainCallback2 -_080DFCD2: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end Task_GoToBuyOrSellMenu - - thumb_func_start MapPostLoadHook_ExitBuyOrSellMenu -@ void MapPostLoadHook_ExitBuyOrSellMenu() -MapPostLoadHook_ExitBuyOrSellMenu: @ 80DFCE0 - push {lr} - bl pal_fill_black - ldr r0, =Task_ExitSellMenu - movs r1, 0x8 - bl CreateTask - pop {r0} - bx r0 - .pool - thumb_func_end MapPostLoadHook_ExitBuyOrSellMenu - - thumb_func_start Task_ExitSellMenu -@ void Task_ExitSellMenu(u8 taskId) -Task_ExitSellMenu: @ 80DFCF8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r5, r4, 0 - bl IsWeatherNotFadingIn - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080DFD36 - ldr r0, =gUnknown_02039F60 - ldrb r0, [r0, 0xF] - cmp r0, 0x2 - bne _080DFD2C - ldr r1, =gText_CanIHelpWithAnythingElse - ldr r2, =ReturnToShopMenuAfterExitingSellMenu - adds r0, r4, 0 - bl DisplayItemMessageOnField - b _080DFD36 - .pool -_080DFD2C: - ldr r1, =gText_AnythingElseICanHelp - ldr r2, =ReturnToShopMenuAfterExitingSellMenu - adds r0, r5, 0 - bl DisplayItemMessageOnField -_080DFD36: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Task_ExitSellMenu - - thumb_func_start ReturnToShopMenuAfterExitingSellMenu -@ void ReturnToShopMenuAfterExitingSellMenu(u8 taskId) -ReturnToShopMenuAfterExitingSellMenu: @ 80DFD44 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gUnknown_02039F60 - ldrb r0, [r0, 0xF] - bl CreateShopMenu - adds r0, r4, 0 - bl DestroyTask - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ReturnToShopMenuAfterExitingSellMenu - - thumb_func_start CB2_BuyMenu -@ void CB2_BuyMenu() -CB2_BuyMenu: @ 80DFD64 - push {lr} - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl do_scheduled_bg_tilemap_copies_to_vram - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end CB2_BuyMenu - - thumb_func_start VBlankCB_BuyMenu -@ void VBlankCB_BuyMenu() -VBlankCB_BuyMenu: @ 80DFD80 - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end VBlankCB_BuyMenu - - thumb_func_start CB2_InitBuyMenu -@ void CB2_InitBuyMenu() -CB2_InitBuyMenu: @ 80DFD94 - push {r4,r5,lr} - sub sp, 0xC - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r5, r0, r1 - ldrb r4, [r5] - cmp r4, 0 - beq _080DFE20 - cmp r4, 0x1 - bne _080DFDAC - b _080DFEE4 -_080DFDAC: - bl BuyMenuDrawGraphics - bl BuyMenuAddScrollIndicatorArrows - ldr r0, =Task_BuyMenu - movs r1, 0x8 - bl CreateTask - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gMultiuseListMenuTemplate - movs r1, 0 - movs r2, 0 - bl ListMenuInit - ldr r2, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r2 - lsls r0, 24 - lsrs r0, 24 - movs r5, 0 - strh r0, [r1, 0x16] - movs r4, 0x1 - negs r4, r4 - adds r0, r4, 0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - str r5, [sp] - adds r0, r4, 0 - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r0, =VBlankCB_BuyMenu - bl SetVBlankCallback - ldr r0, =CB2_BuyMenu - bl SetMainCallback2 - b _080DFEF4 - .pool -_080DFE20: - bl SetVBlankHBlankCallbacksToNull - str r4, [sp, 0x8] - movs r1, 0xE0 - lsls r1, 19 - ldr r2, =0x01000100 - add r0, sp, 0x8 - bl CpuFastSet - bl ScanlineEffect_Stop - bl reset_temp_tile_data_buffers - bl FreeAllSpritePalettes - bl ResetPaletteFade - bl ResetSpriteData - bl ResetTasks - bl clear_scheduled_bg_copies_to_vram - ldr r4, =gUnknown_02039F70 - ldr r0, =0x000020b0 - bl AllocZeroed - str r0, [r4] - ldr r1, =0x0000200b - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - ldr r0, [r4] - ldr r1, =0x0000200d - adds r0, r1 - movs r1, 0x1 - negs r1, r1 - strb r1, [r0] - ldr r0, [r4] - ldr r1, =0x0000200e - adds r0, r1 - movs r1, 0x1 - negs r1, r1 - strb r1, [r0] - bl BuyMenuBuildListMenuTemplate - bl BuyMenuInitBgs - movs r4, 0x20 - str r4, [sp] - str r4, [sp, 0x4] - movs r0, 0 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl FillBgTilemapBufferRect_Palette0 - str r4, [sp] - str r4, [sp, 0x4] - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl FillBgTilemapBufferRect_Palette0 - str r4, [sp] - str r4, [sp, 0x4] - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl FillBgTilemapBufferRect_Palette0 - str r4, [sp] - str r4, [sp, 0x4] - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl FillBgTilemapBufferRect_Palette0 - bl BuyMenuInitWindows - bl BuyMenuDecompressBgGraphics - b _080DFEEE - .pool -_080DFEE4: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - bne _080DFEF4 -_080DFEEE: - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] -_080DFEF4: - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end CB2_InitBuyMenu - - thumb_func_start BuyMenuFreeMemory -@ void BuyMenuFreeMemory() -BuyMenuFreeMemory: @ 80DFEFC - push {lr} - ldr r0, =gUnknown_02039F70 - ldr r0, [r0] - bl Free - ldr r0, =gUnknown_02039F74 - ldr r0, [r0] - bl Free - ldr r0, =gUnknown_02039F78 - ldr r0, [r0] - bl Free - bl FreeAllWindowBuffers - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuFreeMemory - - thumb_func_start BuyMenuBuildListMenuTemplate -@ void BuyMenuBuildListMenuTemplate() -BuyMenuBuildListMenuTemplate: @ 80DFF2C - push {r4-r7,lr} - ldr r7, =gUnknown_02039F74 - ldr r4, =gUnknown_02039F60 - ldrh r0, [r4, 0xC] - adds r0, 0x1 - lsls r0, 3 - bl Alloc - str r0, [r7] - ldr r5, =gUnknown_02039F78 - ldrh r0, [r4, 0xC] - adds r0, 0x1 - lsls r0, 4 - bl Alloc - str r0, [r5] - movs r6, 0 - ldrh r0, [r4, 0xC] - cmp r6, r0 - bcs _080DFF78 -_080DFF54: - lsls r1, r6, 3 - ldr r0, [r7] - adds r0, r1 - ldr r2, [r4, 0x8] - lsls r1, r6, 1 - adds r1, r2 - ldrh r1, [r1] - lsls r3, r6, 4 - ldr r2, [r5] - adds r2, r3 - bl BuyMenuSetListEntry - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - ldrh r2, [r4, 0xC] - cmp r6, r2 - bcc _080DFF54 -_080DFF78: - ldr r4, =gUnknown_02039F78 - lsls r5, r6, 4 - ldr r0, [r4] - adds r0, r5 - ldr r1, =gText_Cancel2 - bl StringCopy - ldr r2, =gUnknown_02039F74 - ldr r0, [r2] - lsls r1, r6, 3 - adds r1, r0 - ldr r0, [r4] - adds r0, r5 - str r0, [r1] - movs r0, 0x2 - negs r0, r0 - str r0, [r1, 0x4] - ldr r3, =gMultiuseListMenuTemplate - adds r1, r3, 0 - ldr r0, =gUnknown_08589A48 - ldm r0!, {r4-r6} - stm r1!, {r4-r6} - ldm r0!, {r4-r6} - stm r1!, {r4-r6} - ldr r0, [r2] - str r0, [r3] - ldr r0, =gUnknown_02039F60 - ldrh r0, [r0, 0xC] - adds r1, r0, 0x1 - strh r1, [r3, 0xC] - lsls r0, r1, 16 - lsrs r0, 16 - cmp r0, 0x8 - bls _080DFFDC - movs r0, 0x8 - strh r0, [r3, 0xE] - b _080DFFDE - .pool -_080DFFDC: - strh r1, [r3, 0xE] -_080DFFDE: - ldr r0, =gUnknown_02039F70 - ldr r0, [r0] - ldr r1, =gMultiuseListMenuTemplate - ldrh r1, [r1, 0xE] - ldr r2, =0x00002004 - adds r0, r2 - strh r1, [r0] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuBuildListMenuTemplate - - thumb_func_start BuyMenuSetListEntry -@ void BuyMenuSetListEntry(struct ListMenuEntry *entry, u16 code, u8 *str) -BuyMenuSetListEntry: @ 80E0000 - push {r4-r6,lr} - adds r6, r0, 0 - adds r5, r2, 0 - lsls r1, 16 - lsrs r4, r1, 16 - ldr r0, =gUnknown_02039F60 - ldrb r0, [r0, 0xF] - cmp r0, 0 - bne _080E0020 - adds r0, r4, 0 - adds r1, r5, 0 - bl CopyItemName - b _080E002C - .pool -_080E0020: - lsls r1, r4, 5 - ldr r0, =gDecorations + 1 - adds r1, r0 - adds r0, r5, 0 - bl StringCopy -_080E002C: - str r5, [r6] - str r4, [r6, 0x4] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuSetListEntry - - thumb_func_start BuyMenuPrintItemDescriptionAndShowItemIcon -@ void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 menuEntryCode, bool8 isInitialSelection, struct ListMenu *listMenu) -BuyMenuPrintItemDescriptionAndShowItemIcon: @ 80E003C - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x8 - adds r7, r0, 0 - lsls r1, 24 - lsrs r1, 24 - cmp r1, 0x1 - beq _080E0054 - movs r0, 0x5 - bl PlaySE -_080E0054: - movs r0, 0x2 - negs r0, r0 - cmp r7, r0 - beq _080E0078 - lsls r4, r7, 16 - lsrs r0, r4, 16 - ldr r1, =gUnknown_02039F70 - ldr r1, [r1] - ldr r2, =0x0000200c - adds r1, r2 - ldrb r1, [r1] - bl BuyMenuAddItemIcon - b _080E008A - .pool -_080E0078: - ldr r0, =0x0000ffff - ldr r1, =gUnknown_02039F70 - ldr r1, [r1] - ldr r2, =0x0000200c - adds r1, r2 - ldrb r1, [r1] - bl BuyMenuAddItemIcon - lsls r4, r7, 16 -_080E008A: - lsrs r4, 16 - mov r8, r4 - ldr r6, =gUnknown_02039F70 - ldr r0, [r6] - ldr r5, =0x0000200c - adds r0, r5 - ldrb r0, [r0] - movs r4, 0x1 - adds r1, r4, 0 - eors r1, r0 - mov r0, r8 - bl BuyMenuRemoveItemIcon - ldr r1, [r6] - adds r1, r5 - ldrb r0, [r1] - eors r0, r4 - strb r0, [r1] - movs r0, 0x2 - negs r0, r0 - cmp r7, r0 - beq _080E00E8 - ldr r0, =gUnknown_02039F60 - ldrb r0, [r0, 0xF] - cmp r0, 0 - bne _080E00D8 - mov r0, r8 - bl ItemId_GetDescription - adds r4, r0, 0 - b _080E00EA - .pool -_080E00D8: - ldr r0, =gDecorations - lsls r1, r7, 5 - adds r0, 0x18 - adds r1, r0 - ldr r4, [r1] - b _080E00EA - .pool -_080E00E8: - ldr r4, =gText_QuitShopping -_080E00EA: - movs r0, 0x2 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0 - str r0, [sp] - str r0, [sp, 0x4] - movs r0, 0x2 - adds r1, r4, 0 - movs r2, 0x3 - movs r3, 0x1 - bl BuyMenuPrint - add sp, 0x8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuPrintItemDescriptionAndShowItemIcon - - thumb_func_start BuyMenuPrintPriceInList -@ void BuyMenuPrintPriceInList(u8 windowId, s32 menuEntryCode, u8 y) -BuyMenuPrintPriceInList: @ 80E0114 - push {r4-r7,lr} - sub sp, 0x14 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r2, 24 - lsrs r7, r2, 24 - movs r0, 0x2 - negs r0, r0 - cmp r1, r0 - beq _080E01AC - ldr r0, =gUnknown_02039F60 - ldrb r0, [r0, 0xF] - cmp r0, 0 - bne _080E0164 - ldr r5, =gStringVar1 - lsls r0, r1, 16 - lsrs r0, 16 - 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, 0 - movs r3, 0x5 - bl ConvertIntToDecimalStringN - b _080E0176 - .pool -_080E0164: - ldr r0, =gStringVar1 - ldr r2, =gDecorations - lsls r1, 5 - adds r1, r2 - ldrh r1, [r1, 0x14] - movs r2, 0 - movs r3, 0x5 - bl ConvertIntToDecimalStringN -_080E0176: - ldr r4, =gStringVar4 - ldr r1, =gText_PokedollarVar1 - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0x7 - adds r1, r4, 0 - movs r2, 0x78 - bl GetStringRightAlignXOffset - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0 - str r0, [sp] - str r0, [sp, 0x4] - ldr r0, =gUnknown_08589AB3 - str r0, [sp, 0x8] - movs r0, 0x1 - negs r0, r0 - str r0, [sp, 0xC] - str r4, [sp, 0x10] - adds r0, r6, 0 - movs r1, 0x7 - adds r3, r7, 0 - bl AddTextPrinterParameterized4 -_080E01AC: - add sp, 0x14 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuPrintPriceInList - - thumb_func_start BuyMenuAddScrollIndicatorArrows -@ void BuyMenuAddScrollIndicatorArrows() -BuyMenuAddScrollIndicatorArrows: @ 80E01C8 - push {r4,r5,lr} - sub sp, 0x10 - ldr r5, =gUnknown_02039F70 - ldr r2, [r5] - ldr r4, =0x0000200b - adds r0, r2, r4 - ldrb r0, [r0] - cmp r0, 0xFF - bne _080E0206 - ldr r0, =gUnknown_02039F60 - ldrh r1, [r0, 0xC] - adds r0, r1, 0x1 - cmp r0, 0x8 - ble _080E0206 - subs r0, r1, 0x7 - str r0, [sp] - ldr r0, =0x00000834 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - ldr r1, =0x00002008 - adds r0, r2, r1 - str r0, [sp, 0xC] - movs r0, 0x2 - movs r1, 0xAC - movs r2, 0xC - movs r3, 0x94 - bl AddScrollIndicatorArrowPairParameterized - ldr r1, [r5] - adds r1, r4 - strb r0, [r1] -_080E0206: - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuAddScrollIndicatorArrows - - thumb_func_start BuyMenuRemoveScrollIndicatorArrows -@ void BuyMenuRemoveScrollIndicatorArrows() -BuyMenuRemoveScrollIndicatorArrows: @ 80E0224 - push {r4,lr} - ldr r4, =gUnknown_02039F70 - ldr r0, [r4] - ldr r2, =0x0000200b - adds r1, r0, r2 - ldrb r0, [r1] - cmp r0, 0xFF - beq _080E0242 - bl RemoveScrollIndicatorArrowPair - ldr r0, [r4] - ldr r1, =0x0000200b - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] -_080E0242: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuRemoveScrollIndicatorArrows - - thumb_func_start BuyMenuPrintCursor -@ void BuyMenuPrintCursor(u8 taskId, u8 colorSetId) -BuyMenuPrintCursor: @ 80E0250 - push {r4,lr} - sub sp, 0x8 - adds r4, r1, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r4, 24 - lsrs r4, 24 - bl ListMenuGetYCoordForPrintingArrowCursor - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - ldr r1, =gText_SelectorArrow2 - movs r0, 0 - str r0, [sp] - str r4, [sp, 0x4] - movs r0, 0x1 - movs r2, 0 - bl BuyMenuPrint - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuPrintCursor - - thumb_func_start BuyMenuAddItemIcon -@ void BuyMenuAddItemIcon(u16 id, u8 iconSlot) -BuyMenuAddItemIcon: @ 80E0284 - push {r4,lr} - sub sp, 0x8 - lsls r0, 16 - lsrs r2, r0, 16 - lsls r1, 24 - lsrs r3, r1, 24 - ldr r0, =gUnknown_02039F70 - ldr r4, =0x0000200d - adds r1, r3, r4 - ldr r0, [r0] - adds r4, r0, r1 - ldrb r0, [r4] - cmp r0, 0xFF - bne _080E0310 - ldr r0, =gUnknown_02039F60 - ldrb r0, [r0, 0xF] - cmp r0, 0 - beq _080E02AE - ldr r0, =0x0000ffff - cmp r2, r0 - bne _080E02F0 -_080E02AE: - ldr r0, =0x0000083e - adds r1, r3, r0 - adds r0, r1, 0 - bl AddItemIconSprite - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x40 - beq _080E0310 - strb r2, [r4] - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - movs r1, 0x18 - strh r1, [r0, 0x24] - movs r1, 0x58 - strh r1, [r0, 0x26] - b _080E0310 - .pool -_080E02F0: - lsls r0, r2, 24 - lsrs r0, 24 - ldr r2, =0x0000083e - adds r1, r3, r2 - str r1, [sp] - str r1, [sp, 0x4] - movs r1, 0x14 - movs r2, 0x54 - movs r3, 0x1 - bl AddDecorationIconObject - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x40 - beq _080E0310 - strb r2, [r4] -_080E0310: - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuAddItemIcon - - thumb_func_start BuyMenuRemoveItemIcon -@ void BuyMenuRemoveItemIcon(u16 id, u8 iconSlot) -BuyMenuRemoveItemIcon: @ 80E031C - push {r4,r5,lr} - lsls r1, 24 - lsrs r4, r1, 24 - ldr r0, =gUnknown_02039F70 - ldr r2, =0x0000200d - adds r1, r4, r2 - ldr r0, [r0] - adds r5, r0, r1 - ldrb r0, [r5] - cmp r0, 0xFF - beq _080E0356 - ldr r0, =0x0000083e - adds r4, r0 - adds r0, r4, 0 - bl FreeSpriteTilesByTag - adds r0, r4, 0 - bl FreeSpritePaletteByTag - ldrb r1, [r5] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - bl DestroySprite - movs r0, 0xFF - strb r0, [r5] -_080E0356: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuRemoveItemIcon - - thumb_func_start BuyMenuInitBgs -@ void BuyMenuInitBgs() -BuyMenuInitBgs: @ 80E036C - push {r4,lr} - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_08589A60 - movs r0, 0 - movs r2, 0x4 - bl InitBgsFromTemplates - ldr r4, =gUnknown_02039F70 - ldr r1, [r4] - movs r0, 0x80 - lsls r0, 4 - adds r1, r0 - movs r0, 0x1 - bl SetBgTilemapBuffer - ldr r1, [r4] - movs r0, 0xC0 - lsls r0, 5 - adds r1, r0 - movs r0, 0x2 - bl SetBgTilemapBuffer - ldr r1, [r4] - movs r0, 0x80 - lsls r0, 5 - adds r1, r0 - movs r0, 0x3 - bl SetBgTilemapBuffer - movs r0, 0x10 - movs r1, 0 - bl SetGpuReg - movs r0, 0x12 - movs r1, 0 - bl SetGpuReg - movs r0, 0x14 - movs r1, 0 - bl SetGpuReg - movs r0, 0x16 - movs r1, 0 - bl SetGpuReg - movs r0, 0x18 - movs r1, 0 - bl SetGpuReg - movs r0, 0x1A - movs r1, 0 - bl SetGpuReg - movs r0, 0x1C - movs r1, 0 - bl SetGpuReg - movs r0, 0x1E - movs r1, 0 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuInitBgs - - thumb_func_start BuyMenuDecompressBgGraphics -@ void BuyMenuDecompressBgGraphics() -BuyMenuDecompressBgGraphics: @ 80E0424 - push {lr} - sub sp, 0x4 - ldr r1, =gBuyMenuFrame_Gfx - movs r2, 0xE8 - lsls r2, 2 - ldr r3, =0x000003e3 - movs r0, 0 - str r0, [sp] - movs r0, 0x1 - bl decompress_and_copy_tile_data_to_vram - ldr r0, =gBuyMenuFrame_Tilemap - ldr r1, =gUnknown_02039F70 - ldr r1, [r1] - bl LZDecompressWram - ldr r0, =gMenuMoneyPal - movs r1, 0xC0 - movs r2, 0x20 - bl LoadCompressedPalette - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuDecompressBgGraphics - - thumb_func_start BuyMenuInitWindows -@ void BuyMenuInitWindows() -BuyMenuInitWindows: @ 80E0468 - push {lr} - ldr r0, =gUnknown_08589A70 - bl InitWindows - bl DeactivateAllTextPrinters - movs r0, 0 - movs r1, 0x1 - movs r2, 0xD0 - bl LoadUserWindowBorderGfx - movs r0, 0 - movs r1, 0xA - movs r2, 0xE0 - bl LoadMessageBoxGfx - movs r0, 0 - bl PutWindowTilemap - movs r0, 0x1 - bl PutWindowTilemap - movs r0, 0x2 - bl PutWindowTilemap - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuInitWindows - - thumb_func_start BuyMenuPrint -@ void BuyMenuPrint(u8 windowId, u8 *str, u8 x, u8 y, u8 speed, u8 colorSetId) -BuyMenuPrint: @ 80E04A4 - push {r4-r6,lr} - sub sp, 0x14 - ldr r6, [sp, 0x24] - ldr r5, [sp, 0x28] - lsls r0, 24 - lsrs r0, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r3, 24 - lsls r5, 24 - lsrs r5, 24 - movs r4, 0 - str r4, [sp] - str r4, [sp, 0x4] - lsls r4, r5, 1 - adds r4, r5 - ldr r5, =gUnknown_08589AB0 - adds r4, r5 - str r4, [sp, 0x8] - lsls r6, 24 - asrs r6, 24 - str r6, [sp, 0xC] - str r1, [sp, 0x10] - movs r1, 0x1 - bl AddTextPrinterParameterized4 - add sp, 0x14 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuPrint - - thumb_func_start BuyMenuDisplayMessage -@ void BuyMenuDisplayMessage(u8 taskId, u8 *str, void ( *callback)(u8 taskId)) -BuyMenuDisplayMessage: @ 80E04E8 - push {r4-r6,lr} - sub sp, 0x10 - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - lsls r4, 24 - lsrs r4, 24 - bl GetPlayerTextSpeed - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - str r1, [sp] - str r0, [sp, 0x4] - str r5, [sp, 0x8] - str r6, [sp, 0xC] - adds r0, r4, 0 - movs r1, 0x5 - movs r2, 0xA - movs r3, 0xE - bl DisplayMessageAndContinueTask - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - add sp, 0x10 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end BuyMenuDisplayMessage - - thumb_func_start BuyMenuDrawGraphics -@ void BuyMenuDrawGraphics() -BuyMenuDrawGraphics: @ 80E0524 - push {lr} - bl BuyMenuDrawMapGraphics - bl BuyMenuCopyMenuBgToBg1TilemapBuffer - movs r0, 0x13 - movs r1, 0xB - bl AddMoneyLabelObject - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r1, 0x92 - lsls r1, 3 - adds r0, r1 - bl GetMoney - adds r3, r0, 0 - movs r0, 0 - movs r1, 0x1 - movs r2, 0xD - bl PrintMoneyAmountInMoneyBoxWithBorder - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x3 - bl schedule_bg_copy_tilemap_to_vram - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuDrawGraphics - - thumb_func_start BuyMenuDrawMapGraphics -@ void BuyMenuDrawMapGraphics() -BuyMenuDrawMapGraphics: @ 80E0570 - push {lr} - bl BuyMenuCollectEventObjectData - bl BuyMenuDrawEventObjects - bl BuyMenuDrawMapBg - pop {r0} - bx r0 - thumb_func_end BuyMenuDrawMapGraphics - - thumb_func_start BuyMenuDrawMapBg -@ void BuyMenuDrawMapBg() -BuyMenuDrawMapBg: @ 80E0584 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - ldr r0, =gMapHeader - ldr r0, [r0] - mov r9, r0 - 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, 0x4 - strh r0, [r1] - ldrh r0, [r4] - subs r0, 0x4 - strh r0, [r4] - movs r1, 0 - mov r10, r4 -_080E05B6: - movs r4, 0 - lsls r7, r1, 16 - asrs r0, r7, 16 - mov r8, r0 -_080E05BE: - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - lsls r4, 16 - asrs r5, r4, 16 - adds r0, r5 - mov r2, r10 - movs r3, 0 - ldrsh r1, [r2, r3] - add r1, r8 - bl MapGridGetMetatileIdAt - lsls r0, 16 - lsrs r6, r0, 16 - adds r0, r5, 0 - mov r1, r8 - bl BuyMenuCheckForOverlapWithMenuBg - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080E0608 - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - adds r0, r5 - mov r2, r10 - movs r3, 0 - ldrsh r1, [r2, r3] - add r1, r8 - bl MapGridGetMetatileLayerTypeAt - lsls r0, 24 - lsrs r5, r0, 24 - b _080E060A - .pool -_080E0608: - movs r5, 0x1 -_080E060A: - ldr r0, =0x000001ff - cmp r6, r0 - bhi _080E062C - asrs r0, r4, 16 - mov r2, r9 - ldr r1, [r2, 0x10] - lsls r3, r6, 4 - ldr r2, [r1, 0xC] - adds r2, r3 - asrs r1, r7, 16 - adds r3, r5, 0 - bl BuyMenuDrawMapMetatile - b _080E0644 - .pool -_080E062C: - asrs r0, r4, 16 - mov r3, r9 - ldr r2, [r3, 0x14] - ldr r3, =0xfffffe00 - adds r1, r6, r3 - lsls r1, 4 - ldr r2, [r2, 0xC] - adds r2, r1 - asrs r1, r7, 16 - adds r3, r5, 0 - bl BuyMenuDrawMapMetatile -_080E0644: - movs r1, 0x80 - lsls r1, 9 - adds r0, r4, r1 - lsrs r4, r0, 16 - asrs r0, 16 - cmp r0, 0xE - ble _080E05BE - adds r0, r7, r1 - lsrs r1, r0, 16 - asrs r0, 16 - cmp r0, 0x9 - ble _080E05B6 - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end BuyMenuDrawMapBg - thumb_func_start BuyMenuDrawMapMetatile @ void BuyMenuDrawMapMetatile(u16 x, u16 y, u16 *src, u8 metatileLayerType) BuyMenuDrawMapMetatile: @ 80E0670 @@ -1427,7 +29,7 @@ _080E0690: beq _080E06F8 b _080E0728 _080E0696: - ldr r6, =gUnknown_02039F70 + ldr r6, =gShopDataPtr ldr r0, [r6] movs r2, 0xC0 lsls r2, 5 @@ -1446,7 +48,7 @@ _080E0696: b _080E06E2 .pool _080E06C0: - ldr r6, =gUnknown_02039F70 + ldr r6, =gShopDataPtr ldr r0, [r6] movs r2, 0x80 lsls r2, 5 @@ -1472,7 +74,7 @@ _080E06E2: b _080E0728 .pool _080E06F8: - ldr r6, =gUnknown_02039F70 + ldr r6, =gShopDataPtr ldr r0, [r6] movs r2, 0x80 lsls r2, 5 @@ -1542,7 +144,7 @@ BuyMenuCollectEventObjectData: @ 80E075C adds r1, r4, 0 bl GetXYCoordsOneStepInFrontOfPlayer movs r7, 0 - ldr r5, =gUnknown_02039F70 + ldr r5, =gShopDataPtr ldr r3, =0x00002010 movs r2, 0x10 _080E0780: @@ -1560,7 +162,7 @@ _080E0780: bls _080E0780 movs r7, 0 str r4, [sp, 0x8] - ldr r1, =gUnknown_02039F70 + ldr r1, =gShopDataPtr mov r9, r1 mov r2, sp str r2, [sp, 0x4] @@ -1728,7 +330,7 @@ BuyMenuDrawEventObjects: @ 80E08F0 push {r5-r7} sub sp, 0x4 movs r7, 0 - ldr r0, =gUnknown_02039F70 + ldr r0, =gShopDataPtr mov r8, r0 ldr r1, =gEventObjects mov r10, r1 @@ -1883,7 +485,7 @@ _080E0A3A: @ void BuyMenuCopyMenuBgToBg1TilemapBuffer() BuyMenuCopyMenuBgToBg1TilemapBuffer: @ 80E0A40 push {r4-r6,lr} - ldr r0, =gUnknown_02039F70 + ldr r0, =gShopDataPtr ldr r0, [r0] movs r1, 0x80 lsls r1, 4 @@ -1921,7 +523,7 @@ _080E0A6A: @ bool8 BuyMenuCheckForOverlapWithMenuBg(u16 x, u16 y) BuyMenuCheckForOverlapWithMenuBg: @ 80E0A88 push {lr} - ldr r2, =gUnknown_02039F70 + ldr r2, =gShopDataPtr ldr r2, [r2] lsls r0, 1 lsls r1, 6 @@ -1979,7 +581,7 @@ _080E0AEA: bl ListMenuHandleInputGetItemId adds r5, r0, 0 ldrb r0, [r4, 0xE] - ldr r7, =gUnknown_02039F70 + ldr r7, =gShopDataPtr ldr r2, [r7] ldr r3, =0x00002008 adds r1, r2, r3 @@ -2011,7 +613,7 @@ _080E0B32: ldrb r0, [r4, 0xE] movs r1, 0x2 bl BuyMenuPrintCursor - ldr r0, =gUnknown_02039F60 + ldr r0, =gMartInfo ldrb r0, [r0, 0xF] cmp r0, 0 bne _080E0B80 @@ -2049,7 +651,7 @@ _080E0B92: movs r1, 0x92 lsls r1, 3 adds r0, r1 - ldr r2, =gUnknown_02039F70 + ldr r2, =gShopDataPtr mov r8, r2 ldr r1, [r2] movs r7, 0x80 @@ -2065,7 +667,7 @@ _080E0B92: b _080E0C28 .pool _080E0BD0: - ldr r4, =gUnknown_02039F60 + ldr r4, =gMartInfo ldrb r0, [r4, 0xF] cmp r0, 0 bne _080E0C38 @@ -2199,7 +801,7 @@ Task_BuyHowManyDialogueInit: @ 80E0CA4 lsls r1, 3 adds r0, r1 bl GetMoney - ldr r1, =gUnknown_02039F70 + ldr r1, =gShopDataPtr ldr r4, [r1] movs r2, 0x80 lsls r2, 6 @@ -2248,7 +850,7 @@ Task_BuyHowManyDialogueHandleInput: @ 80E0D88 ldr r1, =gTasks + 0x8 adds r5, r0, r1 adds r0, r5, 0x2 - ldr r7, =gUnknown_02039F70 + ldr r7, =gShopDataPtr ldr r1, [r7] ldr r2, =0x0000200a adds r1, r2 @@ -2389,7 +991,7 @@ BuyMenuTryMakePurchase: @ 80E0EDC adds r4, r0, r1 movs r0, 0x1 bl PutWindowTilemap - ldr r6, =gUnknown_02039F60 + ldr r6, =gMartInfo ldrb r0, [r6, 0xF] cmp r0, 0 bne _080E0F40 @@ -2459,7 +1061,7 @@ BuyMenuSubtractMoney: @ 80E0F88 movs r4, 0x92 lsls r4, 3 adds r0, r4 - ldr r1, =gUnknown_02039F70 + ldr r1, =gShopDataPtr ldr r1, [r1] movs r2, 0x80 lsls r2, 6 @@ -2475,7 +1077,7 @@ BuyMenuSubtractMoney: @ 80E0F88 movs r0, 0 movs r2, 0 bl PrintMoneyAmountInMoneyBox - ldr r0, =gUnknown_02039F60 + ldr r0, =gMartInfo ldrb r0, [r0, 0xF] cmp r0, 0 bne _080E0FF0 @@ -2623,7 +1225,7 @@ BuyMenuPrintItemQuantityAndPrice: @ 80E10EC movs r0, 0x4 movs r1, 0x11 bl FillWindowPixelBuffer - ldr r0, =gUnknown_02039F70 + ldr r0, =gShopDataPtr ldr r0, [r0] movs r1, 0x80 lsls r1, 6 diff --git a/data/shop.s b/data/shop.s index 58f294e6b..45ecbb585 100644 --- a/data/shop.s +++ b/data/shop.s @@ -53,9 +53,10 @@ gUnknown_08589AA8:: @ 8589AA8 gUnknown_08589AB0:: @ 8589AB0 .byte 1, 2, 3 + .byte 0, 2, 3 + .byte 0, 3, 2 -gUnknown_08589AB3:: @ 8589AB3 - .byte 0, 2, 3, 0, 3, 2, 0 + .align 1 gUnknown_08589ABA:: @ 8589ABA .2byte 0x284, 0x282, 0x280 diff --git a/include/battle_pyramid_bag.h b/include/battle_pyramid_bag.h index 5d5d8ccfa..2301b0aa0 100644 --- a/include/battle_pyramid_bag.h +++ b/include/battle_pyramid_bag.h @@ -11,7 +11,7 @@ struct PyramidBagResources u8 windowIds[5]; u8 unk814; u8 unk815; - u8 scrollArrowSpriteId; + u8 scrollIndicatorsTaskId; const u8 *menuActionIds; u8 filler81C[0x820 - 0x81C]; u8 menuActionsCount; diff --git a/include/shop.h b/include/shop.h index 9b14a672e..067b8fee4 100644 --- a/include/shop.h +++ b/include/shop.h @@ -3,6 +3,42 @@ extern EWRAM_DATA struct ItemSlot gUnknown_02039F80[3]; +enum +{ + MART_TYPE_0, // normal mart + MART_TYPE_1, + MART_TYPE_2, +}; + +struct MartInfo +{ + /*0x0*/ void (* callback) (void); + /*0x4*/ const struct MenuAction *menuActions; + /*0x8*/ const u16 *itemList; + /*0xC*/ u16 itemCount; + /*0xE*/ u8 windowId; + /*0xF*/ u8 martType; +}; + +struct BuyMenuLabel +{ + u8 label[16]; +}; + +struct ShopData +{ + /*0x0000*/ u8 tilemapBuffers[4][0x800]; + /*0x2000*/ u8 filler2000[0x4]; + /*0x2004*/ u16 unk2004; + /*0x2006*/ u8 filler2006[0x2]; + /*0x2008*/ u16 unk2008; + /*0x200A*/ u8 filler200A; + /*0x200B*/ u8 scrollIndicatorsTaskId; + /*0x200C*/ u8 unk200C; + /*0x200D*/ u8 unk200D[2]; + /*0x200F*/ u8 filler200F[0xA1]; +}; + void CreatePokemartMenu(const u16 *); void CreateDecorationShop1Menu(const u16 *); void CreateDecorationShop2Menu(const u16 *); diff --git a/include/strings.h b/include/strings.h index 1a254c2ad..4ea33635b 100644 --- a/include/strings.h +++ b/include/strings.h @@ -151,8 +151,6 @@ extern const u8 gMenuText_Confirm[]; extern const u8 gMenuText_Show[]; extern const u8 gMenuText_Give2[]; -extern const u8 gText_Cancel2[]; - extern const u8 gText_WithdrawPokemon[]; extern const u8 gText_WithdrawMonDescription[]; extern const u8 gText_DepositPokemon[]; @@ -853,4 +851,9 @@ extern const u8 gText_CopperCard[]; extern const u8 gText_SilverCard[]; extern const u8 gText_GoldCard[]; +extern const u8 gText_CanIHelpWithAnythingElse[]; +extern const u8 gText_AnythingElseICanHelp[]; +extern const u8 gText_QuitShopping[]; +extern const u8 gText_PokedollarVar1[]; + #endif //GUARD_STRINGS_H diff --git a/include/tv.h b/include/tv.h index 7a938f888..4f1d7730f 100644 --- a/include/tv.h +++ b/include/tv.h @@ -50,5 +50,6 @@ void PutBattleUpdateOnTheAir(u8 opponentLinkPlayerId, u16 move, u16 speciesPlaye void BravoTrainerPokemonProfile_BeforeInterview1(u16 move); void UpdateTVScreensOnMap(int, int); void TV_PrintIntToStringVar(u8 varIdx, int value); +void SaveRecordedItemPurchasesForTVShow(void); #endif //GUARD_TV_H diff --git a/ld_script.txt b/ld_script.txt index 55cb9793f..50ce3bb6d 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -137,6 +137,7 @@ SECTIONS { src/item.o(.text); src/contest.o(.text); asm/contest.o(.text); + src/shop.o(.text); asm/shop.o(.text); src/berry.o(.text); asm/script_menu.o(.text); diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index 74a4d3f83..e8ff7cce7 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -396,7 +396,7 @@ void sub_81C4F98(u8 a0, void (*callback)(void)) gPyramidBagResources->callback2 = NULL; gPyramidBagResources->unk814 = 0xFF; - gPyramidBagResources->scrollArrowSpriteId = 0xFF; + gPyramidBagResources->scrollIndicatorsTaskId = 0xFF; memset(gPyramidBagResources->itemsSpriteIds, 0xFF, sizeof(gPyramidBagResources->itemsSpriteIds)); memset(gPyramidBagResources->windowIds, 0xFF, sizeof(gPyramidBagResources->windowIds)); @@ -664,16 +664,16 @@ static void PrintItemDescription(s32 listMenuId) static void AddScrollArrow(void) { - if (gPyramidBagResources->scrollArrowSpriteId == 0xFF) - gPyramidBagResources->scrollArrowSpriteId = AddScrollIndicatorArrowPairParameterized(2, 172, 12, 148, gPyramidBagResources->listMenuCount - gPyramidBagResources->listMenuMaxShown, 0xB5E, 0xB5E, &gPyramidBagCursorData.scrollPosition); + if (gPyramidBagResources->scrollIndicatorsTaskId == 0xFF) + gPyramidBagResources->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized(2, 172, 12, 148, gPyramidBagResources->listMenuCount - gPyramidBagResources->listMenuMaxShown, 0xB5E, 0xB5E, &gPyramidBagCursorData.scrollPosition); } static void RemoveScrollArrow(void) { - if (gPyramidBagResources->scrollArrowSpriteId != 0xFF) + if (gPyramidBagResources->scrollIndicatorsTaskId != 0xFF) { - RemoveScrollIndicatorArrowPair(gPyramidBagResources->scrollArrowSpriteId); - gPyramidBagResources->scrollArrowSpriteId = 0xFF; + RemoveScrollIndicatorArrowPair(gPyramidBagResources->scrollIndicatorsTaskId); + gPyramidBagResources->scrollIndicatorsTaskId = 0xFF; } } diff --git a/src/money.c b/src/money.c index 7b78dda92..dcc6afa2c 100644 --- a/src/money.c +++ b/src/money.c @@ -6,10 +6,9 @@ #include "menu.h" #include "window.h" #include "sprite.h" +#include "strings.h" #include "decompress.h" -extern const u8 gText_PokedollarVar1[]; - extern const u8 gMenuMoneyGfx[]; extern const u8 gMenuMoneyPal[]; diff --git a/src/shop.c b/src/shop.c new file mode 100755 index 000000000..26151171a --- /dev/null +++ b/src/shop.c @@ -0,0 +1,679 @@ +#include "global.h" +#include "bg.h" +#include "decompress.h" +#include "decoration.h" +#include "field_player_avatar.h" +#include "field_screen.h" +#include "field_weather.h" +#include "fieldmap.h" +#include "gpu_regs.h" +#include "international_string_util.h" +#include "item.h" +#include "item_icon.h" +#include "list_menu.h" +#include "main.h" +#include "malloc.h" +#include "menu.h" +#include "menu_helpers.h" +#include "money.h" +#include "overworld.h" +#include "palette.h" +#include "scanline_effect.h" +#include "script.h" +#include "shop.h" +#include "sound.h" +#include "sprite.h" +#include "string_util.h" +#include "strings.h" +#include "text_window.h" +#include "tv.h" +#include "constants/rgb.h" +#include "constants/songs.h" + +extern struct ShopData *gShopDataPtr; +extern struct ListMenuItem *gUnknown_02039F74; +extern u8 (*gUnknown_02039F78)[16]; +extern struct MartInfo gMartInfo; + +extern const struct WindowTemplate gUnknown_08589A38[2]; +extern const struct MenuAction gUnknown_08589A10[3]; +extern const struct MenuAction gUnknown_08589A28[2]; +extern const struct ListMenuTemplate gUnknown_08589A48; +extern const struct BgTemplate gUnknown_08589A60[4]; +extern const u8 gBuyMenuFrame_Gfx[]; +extern const u8 gBuyMenuFrame_Tilemap[]; +extern const u16 gMenuMoneyPal[]; +extern const struct WindowTemplate gUnknown_08589A70[]; +extern u8 gUnknown_08589AB0[][3]; + +static void Task_ShopMenu(u8 taskId); +void HandleShopMenuQuit(u8 taskId); +void CB2_InitBuyMenu(void); +static void Task_GoToBuyOrSellMenu(u8 taskId); +void CB2_GoToSellMenu(void); +void MapPostLoadHook_ExitBuyOrSellMenu(void); +void Task_ExitSellMenu(u8 taskId); +void ReturnToShopMenuAfterExitingSellMenu(u8 taskId); +void BuyMenuDrawGraphics(void); +void BuyMenuAddScrollIndicatorArrows(void); +void Task_BuyMenu(u8 taskId); +void BuyMenuBuildListMenuTemplate(void); +void BuyMenuInitBgs(void); +void BuyMenuInitWindows(void); +void BuyMenuDecompressBgGraphics(void); +void BuyMenuSetListEntry(struct ListMenuItem*, u16, u8*); +void BuyMenuAddItemIcon(u16, u8); +void BuyMenuRemoveItemIcon(u16, u8); +void BuyMenuPrint(u8 windowId, const u8 *text, u8 x, u8 y, s8 speed, u8 colorSet); +void BuyMenuDrawMapGraphics(void); +void BuyMenuCopyMenuBgToBg1TilemapBuffer(void); +void BuyMenuCollectEventObjectData(void); +void BuyMenuDrawEventObjects(void); +void BuyMenuDrawMapBg(void); +bool8 BuyMenuCheckForOverlapWithMenuBg(u16, u16); +void BuyMenuDrawMapMetatile(s16, s16, u16*, u8); + + +/*static*/ u8 CreateShopMenu(u8 martType) +{ + int numMenuItems; + + ScriptContext2_Enable(); + gMartInfo.martType = martType; + + if (martType == MART_TYPE_0) + { + struct WindowTemplate winTemplate; + winTemplate = gUnknown_08589A38[0]; + winTemplate.width = GetMaxWidthInMenuTable(gUnknown_08589A10, ARRAY_COUNT(gUnknown_08589A10)); + gMartInfo.windowId = AddWindow(&winTemplate); + gMartInfo.menuActions = gUnknown_08589A10; + numMenuItems = ARRAY_COUNT(gUnknown_08589A10); + } + else + { + struct WindowTemplate winTemplate; + winTemplate = gUnknown_08589A38[1]; + winTemplate.width = GetMaxWidthInMenuTable(gUnknown_08589A28, ARRAY_COUNT(gUnknown_08589A28)); + gMartInfo.windowId = AddWindow(&winTemplate); + gMartInfo.menuActions = gUnknown_08589A28; + numMenuItems = ARRAY_COUNT(gUnknown_08589A28); + } + + SetStandardWindowBorderStyle(gMartInfo.windowId, 0); + PrintMenuTable(gMartInfo.windowId, numMenuItems, gMartInfo.menuActions); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gMartInfo.windowId, numMenuItems, 0); + PutWindowTilemap(gMartInfo.windowId); + CopyWindowToVram(gMartInfo.windowId, 1); + + return CreateTask(Task_ShopMenu, 8); +} + +/*static*/ void SetShopMenuCallback(void (* callback)(void)) +{ + gMartInfo.callback = callback; +} + +/*static*/ void SetShopItemsForSale(const u16 *items) +{ + u16 i = 0; + + gMartInfo.itemList = items; + gMartInfo.itemCount = 0; + + while (gMartInfo.itemList[i]) + { + gMartInfo.itemCount++; + i++; + } +} + +static void Task_ShopMenu(u8 taskId) +{ + s8 inputCode = Menu_ProcessInputNoWrapAround(); + switch (inputCode) + { + case -2: + break; + case -1: + PlaySE(SE_SELECT); + HandleShopMenuQuit(taskId); + break; + default: + gMartInfo.menuActions[inputCode].func.void_u8(taskId); + break; + } +} + +void HandleShopMenuBuy(u8 taskId) +{ + s16 *taskData = gTasks[taskId].data; + taskData[8] = (u32)CB2_InitBuyMenu >> 16; + taskData[9] = (u32)CB2_InitBuyMenu; + gTasks[taskId].func = Task_GoToBuyOrSellMenu; + FadeScreen(1, 0); +} + +void HandleShopMenuSell(u8 taskId) +{ + s16 *taskData = gTasks[taskId].data; + taskData[8] = (u32)CB2_GoToSellMenu >> 16; + taskData[9] = (u32)CB2_GoToSellMenu; + gTasks[taskId].func = Task_GoToBuyOrSellMenu; + FadeScreen(1, 0); +} + +void CB2_ExitSellMenu(void) +{ + gFieldCallback = MapPostLoadHook_ExitBuyOrSellMenu; + SetMainCallback2(CB2_ReturnToField); +} + +/*static*/ void HandleShopMenuQuit(u8 taskId) +{ + sub_8198070(gMartInfo.windowId, 2); + RemoveWindow(gMartInfo.windowId); + SaveRecordedItemPurchasesForTVShow(); + ScriptContext2_Disable(); + DestroyTask(taskId); + + if (gMartInfo.callback) + gMartInfo.callback(); +} + +static void Task_GoToBuyOrSellMenu(u8 taskId) +{ + s16 *taskData = gTasks[taskId].data; + if (!gPaletteFade.active) + { + DestroyTask(taskId); + SetMainCallback2((void *)((u16)taskData[8] << 16 | (u16)taskData[9])); + } +} + +void MapPostLoadHook_ExitBuyOrSellMenu(void) +{ + pal_fill_black(); + CreateTask(Task_ExitSellMenu, 8); +} + +void Task_ExitSellMenu(u8 taskId) +{ + if (IsWeatherNotFadingIn() == TRUE) + { + if (gMartInfo.martType == MART_TYPE_2) + DisplayItemMessageOnField(taskId, gText_CanIHelpWithAnythingElse, ReturnToShopMenuAfterExitingSellMenu); + else + DisplayItemMessageOnField(taskId, gText_AnythingElseICanHelp, ReturnToShopMenuAfterExitingSellMenu); + } +} + +void ReturnToShopMenuAfterExitingSellMenu(u8 taskId) +{ + CreateShopMenu(gMartInfo.martType); + DestroyTask(taskId); +} + +void CB2_BuyMenu(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + do_scheduled_bg_tilemap_copies_to_vram(); + UpdatePaletteFade(); +} + +void VBlankCB_BuyMenu(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +void CB2_InitBuyMenu(void) +{ + u8 taskId; + + switch (gMain.state) + { + case 0: + SetVBlankHBlankCallbacksToNull(); + CpuFastFill(0, (void *)OAM, 0x400); + ScanlineEffect_Stop(); + reset_temp_tile_data_buffers(); + FreeAllSpritePalettes(); + ResetPaletteFade(); + ResetSpriteData(); + ResetTasks(); + clear_scheduled_bg_copies_to_vram(); + gShopDataPtr = AllocZeroed(sizeof(struct ShopData)); + gShopDataPtr->scrollIndicatorsTaskId = 0xFF; + gShopDataPtr->unk200D[0] = -1; + gShopDataPtr->unk200D[1] = -1; + BuyMenuBuildListMenuTemplate(); + BuyMenuInitBgs(); + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); + FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 0x20, 0x20); + FillBgTilemapBufferRect_Palette0(2, 0, 0, 0, 0x20, 0x20); + FillBgTilemapBufferRect_Palette0(3, 0, 0, 0, 0x20, 0x20); + BuyMenuInitWindows(); + BuyMenuDecompressBgGraphics(); + gMain.state++; + break; + case 1: + if (!free_temp_tile_data_buffers_if_possible()) + gMain.state++; + break; + default: + BuyMenuDrawGraphics(); + BuyMenuAddScrollIndicatorArrows(); + taskId = CreateTask(Task_BuyMenu, 8); + gTasks[taskId].data[7] = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0); + BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); + SetVBlankCallback(VBlankCB_BuyMenu); + SetMainCallback2(CB2_BuyMenu); + break; + } +} + +void BuyMenuFreeMemory(void) +{ + Free(gShopDataPtr); + Free(gUnknown_02039F74); + Free(gUnknown_02039F78); + FreeAllWindowBuffers(); +} + +void BuyMenuBuildListMenuTemplate(void) +{ + u16 i; + u16 itemCount; + + gUnknown_02039F74 = Alloc((gMartInfo.itemCount + 1) * sizeof(*gUnknown_02039F74)); + gUnknown_02039F78 = Alloc((gMartInfo.itemCount + 1) * sizeof(*gUnknown_02039F78)); + for (i = 0; i < gMartInfo.itemCount; i++) + BuyMenuSetListEntry(&gUnknown_02039F74[i], gMartInfo.itemList[i], gUnknown_02039F78[i]); + + StringCopy(gUnknown_02039F78[i], gText_Cancel2); + gUnknown_02039F74[i].name = gUnknown_02039F78[i]; + gUnknown_02039F74[i].id = -2; + + gMultiuseListMenuTemplate = gUnknown_08589A48; + gMultiuseListMenuTemplate.items = gUnknown_02039F74; + gMultiuseListMenuTemplate.totalItems = gMartInfo.itemCount + 1; + if (gMultiuseListMenuTemplate.totalItems > 8) + gMultiuseListMenuTemplate.maxShowed = 8; + else + gMultiuseListMenuTemplate.maxShowed = gMultiuseListMenuTemplate.totalItems; + + gShopDataPtr->unk2004 = gMultiuseListMenuTemplate.maxShowed; +} + +void BuyMenuSetListEntry(struct ListMenuItem *menuItem, u16 item, u8 *name) +{ + if (gMartInfo.martType == MART_TYPE_0) + CopyItemName(item, name); + else + StringCopy(name, gDecorations[item].name); + + menuItem->name = name; + menuItem->id = item; +} + +void BuyMenuPrintItemDescriptionAndShowItemIcon(int item, bool8 onInit, struct ListMenu *list) +{ + const u8 *description; + if (onInit != TRUE) + PlaySE(SE_SELECT); + + if (item != -2) + BuyMenuAddItemIcon(item, gShopDataPtr->unk200C); + else + BuyMenuAddItemIcon(-1, gShopDataPtr->unk200C); + + BuyMenuRemoveItemIcon(item, gShopDataPtr->unk200C ^ 1); + gShopDataPtr->unk200C ^= 1; + if (item != -2) + { + if (gMartInfo.martType == MART_TYPE_0) + description = ItemId_GetDescription(item); + else + description = gDecorations[item].description; + } + else + { + description = gText_QuitShopping; + } + + FillWindowPixelBuffer(2, 0); + BuyMenuPrint(2, description, 3, 1, 0, 0); +} + +void BuyMenuPrintPriceInList(u8 windowId, int item, u8 y) +{ + u8 x; + + if (item != -2) + { + if (gMartInfo.martType == MART_TYPE_0) + { + ConvertIntToDecimalStringN( + gStringVar1, + ItemId_GetPrice(item) >> GetPriceReduction(1), + STR_CONV_MODE_LEFT_ALIGN, + 5); + } + else + { + ConvertIntToDecimalStringN( + gStringVar1, + gDecorations[item].price, + STR_CONV_MODE_LEFT_ALIGN, + 5); + } + + StringExpandPlaceholders(gStringVar4, gText_PokedollarVar1); + x = GetStringRightAlignXOffset(7, gStringVar4, 0x78); + AddTextPrinterParameterized4(windowId, 7, x, y, 0, 0, gUnknown_08589AB0[1], -1, gStringVar4); + } +} + +void BuyMenuAddScrollIndicatorArrows(void) +{ + if (gShopDataPtr->scrollIndicatorsTaskId == 0xFF && gMartInfo.itemCount + 1 > 8) + { + gShopDataPtr->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized( + SCROLL_ARROW_UP, + 0xAC, + 0xC, + 0x94, + gMartInfo.itemCount - 7, + 0x834, + 0x834, + &gShopDataPtr->unk2008); + } +} + +void BuyMenuRemoveScrollIndicatorArrows(void) +{ + if (gShopDataPtr->scrollIndicatorsTaskId != 0xFF) + { + RemoveScrollIndicatorArrowPair(gShopDataPtr->scrollIndicatorsTaskId); + gShopDataPtr->scrollIndicatorsTaskId = 0xFF; + } +} + +void BuyMenuPrintCursor(u8 scrollIndicatorsTaskId, u8 colorSet) +{ + u8 y = ListMenuGetYCoordForPrintingArrowCursor(scrollIndicatorsTaskId); + BuyMenuPrint(1, gText_SelectorArrow2, 0, y, 0, colorSet); +} + +void BuyMenuAddItemIcon(u16 item, u8 iconSlot) +{ + u8 spriteId; + u8 *spriteIdPtr = &gShopDataPtr->unk200D[iconSlot]; + if (*spriteIdPtr != 0xFF) + return; + + if (gMartInfo.martType == MART_TYPE_0 || item == 0xFFFF) + { + spriteId = AddItemIconSprite(iconSlot + 0x83E, iconSlot + 0x83E, item); + if (spriteId != MAX_SPRITES) + { + *spriteIdPtr = spriteId; + gSprites[spriteId].pos2.x = 24; + gSprites[spriteId].pos2.y = 88; + } + } + else + { + spriteId = AddDecorationIconObject(item, 20, 84, 1, iconSlot + 0x83E, iconSlot + 0x83E); + if (spriteId != MAX_SPRITES) + *spriteIdPtr = spriteId; + } +} + +void BuyMenuRemoveItemIcon(u16 item, u8 iconSlot) +{ + u8 *spriteIdPtr = &gShopDataPtr->unk200D[iconSlot]; + if (*spriteIdPtr == 0xFF) + return; + + FreeSpriteTilesByTag(iconSlot + 0x83E); + FreeSpritePaletteByTag(iconSlot + 0x83E); + DestroySprite(&gSprites[*spriteIdPtr]); + *spriteIdPtr = 0xFF; +} + +void BuyMenuInitBgs(void) +{ + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_08589A60, ARRAY_COUNT(gUnknown_08589A60)); + SetBgTilemapBuffer(1, gShopDataPtr->tilemapBuffers[1]); + SetBgTilemapBuffer(2, gShopDataPtr->tilemapBuffers[3]); + SetBgTilemapBuffer(3, gShopDataPtr->tilemapBuffers[2]); + SetGpuReg(REG_OFFSET_BG0HOFS, 0); + SetGpuReg(REG_OFFSET_BG0VOFS, 0); + SetGpuReg(REG_OFFSET_BG1HOFS, 0); + SetGpuReg(REG_OFFSET_BG1VOFS, 0); + SetGpuReg(REG_OFFSET_BG2HOFS, 0); + SetGpuReg(REG_OFFSET_BG2VOFS, 0); + SetGpuReg(REG_OFFSET_BG3HOFS, 0); + SetGpuReg(REG_OFFSET_BG3VOFS, 0); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); + ShowBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); +} + +void BuyMenuDecompressBgGraphics(void) +{ + decompress_and_copy_tile_data_to_vram(1, gBuyMenuFrame_Gfx, 0x3A0, 0x3E3, 0); + LZDecompressWram(gBuyMenuFrame_Tilemap, gShopDataPtr->tilemapBuffers[0]); + LoadCompressedPalette(gMenuMoneyPal, 0xC0, 0x20); +} + +void BuyMenuInitWindows(void) +{ + InitWindows(gUnknown_08589A70); + DeactivateAllTextPrinters(); + LoadUserWindowBorderGfx(0, 1, 0xD0); + LoadMessageBoxGfx(0, 0xA, 0xE0); + PutWindowTilemap(0); + PutWindowTilemap(1); + PutWindowTilemap(2); +} + +void BuyMenuPrint(u8 windowId, const u8 *text, u8 x, u8 y, s8 speed, u8 colorSet) +{ + AddTextPrinterParameterized4(windowId, 1, x, y, 0, 0, gUnknown_08589AB0[colorSet], speed, text); +} + +void BuyMenuDisplayMessage(u8 taskId, const u8 *text, TaskFunc callback) +{ + DisplayMessageAndContinueTask(taskId, 5, 10, 14, 1, GetPlayerTextSpeed(), text, callback); + schedule_bg_copy_tilemap_to_vram(0); +} + +void BuyMenuDrawGraphics(void) +{ + BuyMenuDrawMapGraphics(); + BuyMenuCopyMenuBgToBg1TilemapBuffer(); + AddMoneyLabelObject(19, 11); + PrintMoneyAmountInMoneyBoxWithBorder(0, 1, 13, GetMoney(&gSaveBlock1Ptr->money)); + schedule_bg_copy_tilemap_to_vram(0); + schedule_bg_copy_tilemap_to_vram(1); + schedule_bg_copy_tilemap_to_vram(2); + schedule_bg_copy_tilemap_to_vram(3); +} + +void BuyMenuDrawMapGraphics(void) +{ + BuyMenuCollectEventObjectData(); + BuyMenuDrawEventObjects(); + BuyMenuDrawMapBg(); +} + +#ifdef NONMATCHING +// functionally equivalent, but couldn't get the loop variables using the +// stack correctly. Might be related to the tileset metatiles type. +void BuyMenuDrawMapBg(void) +{ + s16 i; + s16 j; + s16 x; + s16 y; + const struct MapLayout *mapLayout; + u16 metatile, metatileLayerType; + + mapLayout = gMapHeader.mapLayout; + GetXYCoordsOneStepInFrontOfPlayer(&x, &y); + x -= 4; + y -= 4; + + for (j = 0; j < 10; j++) + { + for (i = 0; i < 15; i++) + { + metatile = MapGridGetMetatileIdAt(x + i, y + j); + if (BuyMenuCheckForOverlapWithMenuBg(i, j) == TRUE) + metatileLayerType = MapGridGetMetatileLayerTypeAt(x + i, y + j); + else + metatileLayerType = 1; + + if (metatile < 0x200) + { + BuyMenuDrawMapMetatile(i, j, (u16*)mapLayout->primaryTileset->metatiles + metatile * 8, metatileLayerType); + } + else + { + BuyMenuDrawMapMetatile(i, j, (u16*)mapLayout->secondaryTileset->metatiles + ((metatile - 0x200) * 8), metatileLayerType); + } + } + } +} +#else +NAKED +void BuyMenuDrawMapBg(void) +{ + asm_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, =gMapHeader\n\ + ldr r0, [r0]\n\ + mov r9, r0\n\ + mov r4, sp\n\ + adds r4, 0x2\n\ + mov r0, sp\n\ + adds r1, r4, 0\n\ + bl GetXYCoordsOneStepInFrontOfPlayer\n\ + mov r1, sp\n\ + mov r0, sp\n\ + ldrh r0, [r0]\n\ + subs r0, 0x4\n\ + strh r0, [r1]\n\ + ldrh r0, [r4]\n\ + subs r0, 0x4\n\ + strh r0, [r4]\n\ + movs r1, 0\n\ + mov r10, r4\n\ +_080E05B6:\n\ + movs r4, 0\n\ + lsls r7, r1, 16\n\ + asrs r0, r7, 16\n\ + mov r8, r0\n\ +_080E05BE:\n\ + mov r0, sp\n\ + movs r1, 0\n\ + ldrsh r0, [r0, r1]\n\ + lsls r4, 16\n\ + asrs r5, r4, 16\n\ + adds r0, r5\n\ + mov r2, r10\n\ + movs r3, 0\n\ + ldrsh r1, [r2, r3]\n\ + add r1, r8\n\ + bl MapGridGetMetatileIdAt\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ + adds r0, r5, 0\n\ + mov r1, r8\n\ + bl BuyMenuCheckForOverlapWithMenuBg\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + bne _080E0608\n\ + mov r0, sp\n\ + movs r1, 0\n\ + ldrsh r0, [r0, r1]\n\ + adds r0, r5\n\ + mov r2, r10\n\ + movs r3, 0\n\ + ldrsh r1, [r2, r3]\n\ + add r1, r8\n\ + bl MapGridGetMetatileLayerTypeAt\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + b _080E060A\n\ + .pool\n\ +_080E0608:\n\ + movs r5, 0x1\n\ +_080E060A:\n\ + ldr r0, =0x000001ff\n\ + cmp r6, r0\n\ + bhi _080E062C\n\ + asrs r0, r4, 16\n\ + mov r2, r9\n\ + ldr r1, [r2, 0x10]\n\ + lsls r3, r6, 4\n\ + ldr r2, [r1, 0xC]\n\ + adds r2, r3\n\ + asrs r1, r7, 16\n\ + adds r3, r5, 0\n\ + bl BuyMenuDrawMapMetatile\n\ + b _080E0644\n\ + .pool\n\ +_080E062C:\n\ + asrs r0, r4, 16\n\ + mov r3, r9\n\ + ldr r2, [r3, 0x14]\n\ + ldr r3, =0xfffffe00\n\ + adds r1, r6, r3\n\ + lsls r1, 4\n\ + ldr r2, [r2, 0xC]\n\ + adds r2, r1\n\ + asrs r1, r7, 16\n\ + adds r3, r5, 0\n\ + bl BuyMenuDrawMapMetatile\n\ +_080E0644:\n\ + movs r1, 0x80\n\ + lsls r1, 9\n\ + adds r0, r4, r1\n\ + lsrs r4, r0, 16\n\ + asrs r0, 16\n\ + cmp r0, 0xE\n\ + ble _080E05BE\n\ + adds r0, r7, r1\n\ + lsrs r1, r0, 16\n\ + asrs r0, 16\n\ + cmp r0, 0x9\n\ + ble _080E05B6\n\ + add sp, 0x4\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool"); +} +#endif // NONMATCHING diff --git a/sym_ewram.txt b/sym_ewram.txt index 08a834057..8ac8871f8 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -380,10 +380,10 @@ gUnknown_02039F5C: @ 2039F5C gUnknown_02039F5D: @ 2039F5D .space 0x3 -gUnknown_02039F60: @ 2039F60 +gMartInfo: @ 2039F60 .space 0x10 -gUnknown_02039F70: @ 2039F70 +gShopDataPtr: @ 2039F70 .space 0x4 gUnknown_02039F74: @ 2039F74