mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 11:44:17 +01:00
checkpoint
This commit is contained in:
parent
8ecf3b2159
commit
fa9d1759bd
555
asm/shop.s
555
asm/shop.s
@ -5,561 +5,6 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start BuyMenuAddScrollIndicatorArrows
|
||||
@ void BuyMenuAddScrollIndicatorArrows()
|
||||
BuyMenuAddScrollIndicatorArrows: @ 80E01C8
|
||||
push {r4,r5,lr}
|
||||
sub sp, 0x10
|
||||
ldr r5, =gShopDataPtr
|
||||
ldr r2, [r5]
|
||||
ldr r4, =0x0000200b
|
||||
adds r0, r2, r4
|
||||
ldrb r0, [r0]
|
||||
cmp r0, 0xFF
|
||||
bne _080E0206
|
||||
ldr r0, =gMartInfo
|
||||
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, =gShopDataPtr
|
||||
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, =gShopDataPtr
|
||||
ldr r4, =0x0000200d
|
||||
adds r1, r3, r4
|
||||
ldr r0, [r0]
|
||||
adds r4, r0, r1
|
||||
ldrb r0, [r4]
|
||||
cmp r0, 0xFF
|
||||
bne _080E0310
|
||||
ldr r0, =gMartInfo
|
||||
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, =gShopDataPtr
|
||||
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, =gShopDataPtr
|
||||
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, =gShopDataPtr
|
||||
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 AddTextPrinterParameterized2
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -27,13 +27,15 @@ struct BuyMenuLabel
|
||||
|
||||
struct ShopData
|
||||
{
|
||||
/*0x0000*/ u8 filler0[0x2004];
|
||||
/*0x0000*/ u8 tilemapBuffers[4][0x800];
|
||||
/*0x2000*/ u8 filler2000[0x4];
|
||||
/*0x2004*/ u16 unk2004;
|
||||
/*0x2006*/ u8 filler2006[0x5];
|
||||
/*0x200B*/ u8 unk200B;
|
||||
/*0x2006*/ u8 filler2006[0x2];
|
||||
/*0x2008*/ u16 unk2008;
|
||||
/*0x200A*/ u8 filler200A;
|
||||
/*0x200B*/ u8 scrollIndicatorsTaskId;
|
||||
/*0x200C*/ u8 unk200C;
|
||||
/*0x200D*/ s8 unk200D;
|
||||
/*0x200E*/ s8 unk200E;
|
||||
/*0x200D*/ u8 unk200D[2];
|
||||
/*0x200F*/ u8 filler200F[0xA1];
|
||||
};
|
||||
|
||||
|
@ -264,7 +264,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));
|
||||
@ -532,16 +532,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
331
src/shop.c
331
src/shop.c
@ -1,23 +1,31 @@
|
||||
#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"
|
||||
@ -31,7 +39,12 @@ 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 u8 gUnknown_08589AB3[];
|
||||
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);
|
||||
@ -51,7 +64,14 @@ void BuyMenuDecompressBgGraphics(void);
|
||||
void BuyMenuSetListEntry(struct ListMenuItem*, u16, u8*);
|
||||
void BuyMenuAddItemIcon(u16, u8);
|
||||
void BuyMenuRemoveItemIcon(u16, u8);
|
||||
void BuyMenuPrint(u8, const u8*, u8, u8, u8, 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)
|
||||
@ -227,9 +247,9 @@ void CB2_InitBuyMenu(void)
|
||||
ResetTasks();
|
||||
clear_scheduled_bg_copies_to_vram();
|
||||
gShopDataPtr = AllocZeroed(sizeof(struct ShopData));
|
||||
gShopDataPtr->unk200B = 0xFF;
|
||||
gShopDataPtr->unk200D = -1;
|
||||
gShopDataPtr->unk200E = -1;
|
||||
gShopDataPtr->scrollIndicatorsTaskId = 0xFF;
|
||||
gShopDataPtr->unk200D[0] = -1;
|
||||
gShopDataPtr->unk200D[1] = -1;
|
||||
BuyMenuBuildListMenuTemplate();
|
||||
BuyMenuInitBgs();
|
||||
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
|
||||
@ -355,6 +375,305 @@ void BuyMenuPrintPriceInList(u8 windowId, int item, u8 y)
|
||||
|
||||
StringExpandPlaceholders(gStringVar4, gText_PokedollarVar1);
|
||||
x = GetStringRightAlignXOffset(7, gStringVar4, 0x78);
|
||||
AddTextPrinterParameterized2(windowId, 7, x, y, 0, 0, gUnknown_08589AB3, -1, gStringVar4);
|
||||
AddTextPrinterParameterized2(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)
|
||||
{
|
||||
AddTextPrinterParameterized2(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
|
||||
|
Loading…
Reference in New Issue
Block a user