pokeblock.s is decompiled

This commit is contained in:
DizzyEggg 2017-12-16 15:10:29 +01:00
parent f4ab21ee67
commit 5b409d49ed
10 changed files with 408 additions and 992 deletions

View File

@ -6,928 +6,7 @@
.text
thumb_func_start PutPokeblockOptionsWindow
PutPokeblockOptionsWindow: @ 8136938
push {r4-r7,lr}
lsls r0, 24
lsrs r7, r0, 24
lsls r0, r7, 2
adds r0, r7
lsls r0, 3
ldr r1, =gTasks + 0x8
adds r6, r0, r1
ldr r0, =sPokeblockMenu
ldr r0, [r0]
ldr r1, =0x00000808
adds r0, r1
ldrb r0, [r0]
cmp r0, 0x3
bne _08136968
movs r0, 0x8
b _0813696A
.pool
_08136968:
movs r0, 0x9
_0813696A:
strh r0, [r6, 0x2]
bl sub_8136418
ldrb r0, [r6, 0x2]
movs r1, 0
movs r2, 0x1
movs r3, 0xE
bl SetWindowBorderStyle
ldrb r0, [r6, 0x2]
ldr r5, =sPokeblockMenu
ldr r3, [r5]
ldr r4, =0x00000808
adds r1, r3, r4
ldrb r1, [r1]
ldr r2, =sPokeblockMenuActions
mov r12, r2
ldr r2, =0x00000804
adds r3, r2
ldr r3, [r3]
mov r2, r12
bl sub_81995E4
ldrb r0, [r6, 0x2]
ldr r1, [r5]
adds r1, r4
ldrb r1, [r1]
movs r2, 0
bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed
ldrb r0, [r6, 0x2]
bl PutWindowTilemap
movs r0, 0x1
bl schedule_bg_copy_tilemap_to_vram
ldr r1, =gTasks
lsls r0, r7, 2
adds r0, r7
lsls r0, 3
adds r0, r1
ldr r1, =sub_81369E0
str r1, [r0]
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end PutPokeblockOptionsWindow
thumb_func_start sub_81369E0
sub_81369E0: @ 81369E0
push {r4-r6,lr}
lsls r0, 24
lsrs r5, r0, 24
adds r6, r5, 0
bl sub_81221EC
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
beq _08136A3C
bl ProcessMenuInputNoWrapAround
lsls r0, 24
asrs r4, r0, 24
movs r0, 0x2
negs r0, r0
cmp r4, r0
beq _08136A3C
adds r0, 0x1
cmp r4, r0
bne _08136A18
movs r0, 0x5
bl PlaySE
adds r0, r5, 0
bl PokeblockAction_Cancel
b _08136A3C
_08136A18:
movs r0, 0x5
bl PlaySE
ldr r1, =sPokeblockMenuActions
ldr r0, =sPokeblockMenu
ldr r0, [r0]
ldr r2, =0x00000804
adds r0, r2
ldr r0, [r0]
adds r0, r4
ldrb r0, [r0]
lsls r0, 3
adds r1, 0x4
adds r0, r1
ldr r1, [r0]
adds r0, r6, 0
bl _call_via_r1
_08136A3C:
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_81369E0
thumb_func_start PokeblockAction_UseOnField
PokeblockAction_UseOnField: @ 8136A50
push {lr}
lsls r0, 24
lsrs r0, 24
ldr r1, =sPokeblockMenu
ldr r1, [r1]
movs r2, 0x80
lsls r2, 4
adds r1, r2
ldr r2, =sub_8136A74
str r2, [r1]
bl FadePaletteAndSetTaskToClosePokeblockCase
pop {r0}
bx r0
.pool
thumb_func_end PokeblockAction_UseOnField
thumb_func_start sub_8136A74
sub_8136A74: @ 8136A74
push {lr}
ldr r2, =gSaveBlock1Ptr
ldr r0, =gSpecialVar_ItemId
ldrh r1, [r0]
lsls r1, 3
ldr r0, =0x00000848
adds r1, r0
ldr r0, [r2]
adds r0, r1
ldr r1, =sub_8136AA0
bl ChooseMonToGivePokeblock
pop {r0}
bx r0
.pool
thumb_func_end sub_8136A74
thumb_func_start sub_8136AA0
sub_8136AA0: @ 8136AA0
push {lr}
ldr r0, =sSavedPokeblockData
ldr r1, [r0]
movs r0, 0
bl OpenPokeblockCase
pop {r0}
bx r0
.pool
thumb_func_end sub_8136AA0
thumb_func_start PokeblockAction_Toss
PokeblockAction_Toss: @ 8136AB4
push {r4,r5,lr}
sub sp, 0x10
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
lsls r0, r4, 2
adds r0, r4
lsls r0, 3
ldr r1, =gTasks + 0x8
adds r0, r1
ldrb r0, [r0, 0x2]
movs r1, 0
bl sub_8198070
ldr r0, =gStringVar1
ldr r3, =gPokeblockNames
ldr r1, =gSaveBlock1Ptr
ldr r2, [r1]
ldr r1, =gSpecialVar_ItemId
ldrh r1, [r1]
lsls r1, 3
adds r2, r1
ldr r1, =0x00000848
adds r2, r1
ldrb r1, [r2]
lsls r1, 2
adds r1, r3
ldr r1, [r1]
bl StringCopy
ldr r5, =gStringVar4
ldr r1, =gText_ThrowAwayVar1
adds r0, r5, 0
bl StringExpandPlaceholders
bl GetPlayerTextSpeed
lsls r0, 24
lsrs r0, 24
movs r1, 0x1
str r1, [sp]
str r0, [sp, 0x4]
str r5, [sp, 0x8]
ldr r0, =sub_8136B48
str r0, [sp, 0xC]
adds r0, r4, 0
movs r1, 0xA
movs r2, 0xA
movs r3, 0xD
bl DisplayMessageAndContinueTask
add sp, 0x10
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end PokeblockAction_Toss
thumb_func_start sub_8136B48
sub_8136B48: @ 8136B48
push {lr}
sub sp, 0x10
lsls r0, 24
lsrs r0, 24
ldr r1, =gUnknown_085B27A8
movs r2, 0x2
str r2, [sp]
movs r2, 0x1
str r2, [sp, 0x4]
movs r2, 0xE
str r2, [sp, 0x8]
ldr r2, =sTossYesNoFuncTable
str r2, [sp, 0xC]
movs r2, 0x1
movs r3, 0
bl CreateYesNoMenuWithCallbacks
add sp, 0x10
pop {r0}
bx r0
.pool
thumb_func_end sub_8136B48
thumb_func_start TossPokeblockChoice_Yes
TossPokeblockChoice_Yes: @ 8136B78
push {r4,r5,lr}
sub sp, 0x10
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
ldr r5, =gStringVar4
ldr r1, =gText_Var1ThrownAway
adds r0, r5, 0
bl StringExpandPlaceholders
bl GetPlayerTextSpeed
lsls r0, 24
lsrs r0, 24
movs r1, 0x1
str r1, [sp]
str r0, [sp, 0x4]
str r5, [sp, 0x8]
ldr r0, =sub_8136BC0
str r0, [sp, 0xC]
adds r0, r4, 0
movs r1, 0xA
movs r2, 0xA
movs r3, 0xD
bl DisplayMessageAndContinueTask
add sp, 0x10
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end TossPokeblockChoice_Yes
thumb_func_start sub_8136BC0
sub_8136BC0: @ 8136BC0
push {r4-r7,lr}
lsls r0, 24
lsrs r7, r0, 24
ldr r0, =gMain
ldrh r1, [r0, 0x2E]
movs r0, 0x3
ands r0, r1
cmp r0, 0
beq _08136C36
ldr r0, =gSpecialVar_ItemId
ldrb r0, [r0]
bl sub_8136F68
movs r0, 0x5
bl PlaySE
ldr r5, =sSavedPokeblockData + 6
subs r6, r5, 0x2
lsls r4, r7, 2
adds r4, r7
lsls r4, 3
ldr r0, =gTasks + 0x8
adds r4, r0
ldrb r0, [r4]
adds r1, r5, 0
adds r2, r6, 0
bl sub_81AE6C8
ldrh r0, [r6]
movs r1, 0x5
bl HandlePokeblockMenuCursor
bl SetMenuItemsCountAndMaxShowed
bl sub_81362E0
bl HandlePokeblockListMenuItems
ldr r0, =gMultiuseListMenuTemplate
ldrh r1, [r5]
ldrh r2, [r6]
bl ListMenuInit
lsls r0, 24
lsrs r0, 24
strh r0, [r4]
ldrh r0, [r6]
ldr r1, =0x00001005
bl HandlePokeblockMenuCursor
movs r0, 0
bl schedule_bg_copy_tilemap_to_vram
movs r0, 0x1
bl schedule_bg_copy_tilemap_to_vram
adds r0, r7, 0
bl TossPokeblockChoice_No
_08136C36:
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_8136BC0
thumb_func_start TossPokeblockChoice_No
TossPokeblockChoice_No: @ 8136C54
push {r4,lr}
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
movs r0, 0xA
movs r1, 0
bl sub_8197DF8
movs r0, 0x1
bl schedule_bg_copy_tilemap_to_vram
bl sub_81363BC
ldr r1, =gTasks
lsls r0, r4, 2
adds r0, r4
lsls r0, 3
adds r0, r1
ldr r1, =Task_HandlePokeblockMenuInput
str r1, [r0]
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end TossPokeblockChoice_No
thumb_func_start PokeblockAction_UseInBattle
PokeblockAction_UseInBattle: @ 8136C8C
push {r4-r7,lr}
mov r7, r8
push {r7}
lsls r0, 24
lsrs r0, 24
mov r8, r0
ldr r0, =gEnemyParty
bl GetNature
lsls r0, 24
lsrs r0, 24
ldr r5, =gSaveBlock1Ptr
ldr r7, =gSpecialVar_ItemId
ldrh r2, [r7]
lsls r2, 3
ldr r6, =0x00000848
adds r2, r6
ldr r1, [r5]
adds r1, r2
bl PokeblockGetGain
adds r4, r0, 0
lsls r4, 16
lsrs r4, 16
ldr r0, =gBattleTextBuff1
ldr r3, =gPokeblockNames
ldr r2, [r5]
ldrh r1, [r7]
lsls r1, 3
adds r2, r1
adds r2, r6
ldrb r1, [r2]
lsls r1, 2
adds r1, r3
ldr r1, [r1]
bl StringCopy
ldrb r0, [r7]
bl sub_8136F68
ldr r1, [r5]
ldrh r0, [r7]
lsls r0, 3
adds r1, r0
adds r1, r6
ldrb r0, [r1]
lsls r0, 8
strh r0, [r7]
lsls r4, 16
asrs r4, 16
cmp r4, 0
bne _08136D10
adds r0, 0x1
b _08136D1A
.pool
_08136D10:
cmp r4, 0
ble _08136D18
adds r0, 0x2
b _08136D1A
_08136D18:
adds r0, 0x3
_08136D1A:
strh r0, [r7]
mov r0, r8
bl FadePaletteAndSetTaskToClosePokeblockCase
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end PokeblockAction_UseInBattle
thumb_func_start PokeblockAction_UseOnPokeblockFeeder
PokeblockAction_UseOnPokeblockFeeder: @ 8136D2C
push {r4,r5,lr}
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
ldr r5, =gSpecialVar_ItemId
ldrb r0, [r5]
bl SafariZoneActivatePokeblockFeeder
ldr r0, =gStringVar1
ldr r3, =gPokeblockNames
ldr r1, =gSaveBlock1Ptr
ldr r2, [r1]
ldrh r1, [r5]
lsls r1, 3
adds r2, r1
ldr r1, =0x00000848
adds r2, r1
ldrb r1, [r2]
lsls r1, 2
adds r1, r3
ldr r1, [r1]
bl StringCopy
ldr r1, =gSpecialVar_Result
ldrh r0, [r5]
strh r0, [r1]
lsls r0, 24
lsrs r0, 24
bl sub_8136F68
movs r0, 0
strh r0, [r5]
adds r0, r4, 0
bl FadePaletteAndSetTaskToClosePokeblockCase
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end PokeblockAction_UseOnPokeblockFeeder
thumb_func_start PokeblockAction_GiveToContestLady
PokeblockAction_GiveToContestLady: @ 8136D90
push {r4-r6,lr}
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
ldr r6, =gSpecialVar_0x8004
ldr r0, =gSaveBlock1Ptr
ldr r5, =gSpecialVar_ItemId
ldrh r1, [r5]
lsls r1, 3
ldr r2, =0x00000848
adds r1, r2
ldr r0, [r0]
adds r0, r1
bl sub_818E704
lsls r0, 24
lsrs r0, 24
strh r0, [r6]
ldr r1, =gSpecialVar_Result
ldrh r0, [r5]
strh r0, [r1]
lsls r0, 24
lsrs r0, 24
bl sub_8136F68
movs r0, 0
strh r0, [r5]
adds r0, r4, 0
bl FadePaletteAndSetTaskToClosePokeblockCase
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end PokeblockAction_GiveToContestLady
thumb_func_start PokeblockAction_Cancel
PokeblockAction_Cancel: @ 8136DE8
push {r4,r5,lr}
lsls r0, 24
lsrs r0, 24
lsls r4, r0, 2
adds r4, r0
lsls r4, 3
ldr r5, =gTasks + 0x8
adds r0, r4, r5
ldrb r0, [r0, 0x2]
movs r1, 0
bl sub_8198070
movs r0, 0x1
bl schedule_bg_copy_tilemap_to_vram
bl sub_81363BC
subs r5, 0x8
adds r4, r5
ldr r0, =Task_HandlePokeblockMenuInput
str r0, [r4]
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end PokeblockAction_Cancel
thumb_func_start sub_8136E20
sub_8136E20: @ 8136E20
push {r4,lr}
lsls r0, 24
ldr r3, =gSaveBlock1Ptr
ldr r1, [r3]
lsrs r0, 21
adds r1, r0
ldr r2, =0x00000848
adds r1, r2
movs r2, 0
strb r2, [r1]
ldr r1, [r3]
adds r1, r0
ldr r4, =0x00000849
adds r1, r4
strb r2, [r1]
ldr r1, [r3]
adds r1, r0
adds r4, 0x1
adds r1, r4
strb r2, [r1]
ldr r1, [r3]
adds r1, r0
adds r4, 0x1
adds r1, r4
strb r2, [r1]
ldr r1, [r3]
adds r1, r0
adds r4, 0x1
adds r1, r4
strb r2, [r1]
ldr r1, [r3]
adds r1, r0
adds r4, 0x1
adds r1, r4
strb r2, [r1]
ldr r1, [r3]
adds r1, r0
ldr r0, =0x0000084e
adds r1, r0
strb r2, [r1]
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_8136E20
thumb_func_start ClearPokeblocks
ClearPokeblocks: @ 8136E88
push {r4,lr}
movs r4, 0
_08136E8C:
adds r0, r4, 0
bl sub_8136E20
adds r0, r4, 0x1
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0x27
bls _08136E8C
pop {r4}
pop {r0}
bx r0
thumb_func_end ClearPokeblocks
thumb_func_start GetHighestPokeblocksFlavorLevel
GetHighestPokeblocksFlavorLevel: @ 8136EA4
push {r4-r6,lr}
adds r6, r0, 0
movs r1, 0x1
bl GetPokeblockData
lsls r0, 24
lsrs r5, r0, 24
movs r1, 0x1
_08136EB4:
adds r0, r1, 0x1
lsls r0, 24
lsrs r4, r0, 24
adds r0, r6, 0
adds r1, r4, 0
bl GetPokeblockData
lsls r0, 24
lsrs r0, 24
cmp r5, r0
bcs _08136ECC
adds r5, r0, 0
_08136ECC:
adds r1, r4, 0
cmp r1, 0x4
bls _08136EB4
adds r0, r5, 0
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end GetHighestPokeblocksFlavorLevel
thumb_func_start GetPokeblocksFeel
GetPokeblocksFeel: @ 8136EDC
push {lr}
movs r1, 0x6
bl GetPokeblockData
lsls r0, 24
lsrs r0, 24
cmp r0, 0x63
bls _08136EEE
movs r0, 0x63
_08136EEE:
pop {r1}
bx r1
thumb_func_end GetPokeblocksFeel
thumb_func_start GetFirstFreePokeblockSlot
GetFirstFreePokeblockSlot: @ 8136EF4
push {lr}
movs r1, 0
ldr r0, =gSaveBlock1Ptr
ldr r2, [r0]
ldr r3, =0x00000848
_08136EFE:
lsls r0, r1, 3
adds r0, r2, r0
adds r0, r3
ldrb r0, [r0]
cmp r0, 0
bne _08136F18
lsls r0, r1, 24
asrs r0, 24
b _08136F26
.pool
_08136F18:
adds r0, r1, 0x1
lsls r0, 24
lsrs r1, r0, 24
cmp r1, 0x27
bls _08136EFE
movs r0, 0x1
negs r0, r0
_08136F26:
pop {r1}
bx r1
thumb_func_end GetFirstFreePokeblockSlot
thumb_func_start AddPokeblock
AddPokeblock: @ 8136F2C
push {r4,lr}
adds r4, r0, 0
bl GetFirstFreePokeblockSlot
lsls r0, 24
asrs r1, r0, 24
movs r0, 0x1
negs r0, r0
cmp r1, r0
beq _08136F60
ldr r0, =gSaveBlock1Ptr
ldr r2, [r0]
lsls r0, r1, 3
ldr r1, =0x00000848
adds r2, r1
adds r2, r0
ldr r0, [r4]
ldr r1, [r4, 0x4]
str r0, [r2]
str r1, [r2, 0x4]
movs r0, 0x1
b _08136F62
.pool
_08136F60:
movs r0, 0
_08136F62:
pop {r4}
pop {r1}
bx r1
thumb_func_end AddPokeblock
thumb_func_start sub_8136F68
sub_8136F68: @ 8136F68
push {lr}
lsls r0, 24
lsrs r2, r0, 24
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
lsls r1, r2, 3
adds r0, r1
ldr r1, =0x00000848
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
beq _08136F94
adds r0, r2, 0
bl sub_8136E20
movs r0, 0x1
b _08136F96
.pool
_08136F94:
movs r0, 0
_08136F96:
pop {r1}
bx r1
thumb_func_end sub_8136F68
thumb_func_start GetPokeblockData
GetPokeblockData: @ 8136F9C
push {lr}
lsls r1, 24
lsrs r1, 24
adds r2, r1, 0
cmp r1, 0
bne _08136FAC
ldrb r0, [r0]
b _08136FDE
_08136FAC:
cmp r1, 0x1
bne _08136FB4
ldrb r0, [r0, 0x1]
b _08136FDE
_08136FB4:
cmp r1, 0x2
bne _08136FBC
ldrb r0, [r0, 0x2]
b _08136FDE
_08136FBC:
cmp r1, 0x3
bne _08136FC4
ldrb r0, [r0, 0x3]
b _08136FDE
_08136FC4:
cmp r1, 0x4
bne _08136FCC
ldrb r0, [r0, 0x4]
b _08136FDE
_08136FCC:
cmp r1, 0x5
bne _08136FD4
ldrb r0, [r0, 0x5]
b _08136FDE
_08136FD4:
cmp r2, 0x6
beq _08136FDC
movs r0, 0
b _08136FDE
_08136FDC:
ldrb r0, [r0, 0x6]
_08136FDE:
pop {r1}
bx r1
thumb_func_end GetPokeblockData
thumb_func_start PokeblockGetGain
PokeblockGetGain: @ 8136FE4
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
mov r8, r1
lsls r0, 24
lsrs r0, 24
movs r6, 0
movs r4, 0
ldr r1, =gPokeblockFlavorCompatibilityTable
mov r9, r1
lsls r1, r0, 2
adds r7, r1, r0
_08136FFE:
adds r0, r4, 0x1
lsls r0, 24
lsrs r5, r0, 24
mov r0, r8
adds r1, r5, 0
bl GetPokeblockData
lsls r0, 16
asrs r1, r0, 16
cmp r1, 0
ble _0813702A
adds r0, r7, r4
add r0, r9
ldrb r0, [r0]
lsls r0, 24
asrs r0, 24
muls r1, r0
lsls r0, r6, 16
asrs r0, 16
adds r0, r1
lsls r0, 16
lsrs r6, r0, 16
_0813702A:
adds r4, r5, 0
cmp r4, 0x4
bls _08136FFE
lsls r0, r6, 16
asrs r0, 16
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r1}
bx r1
.pool
thumb_func_end PokeblockGetGain
thumb_func_start PokeblockCopyName
PokeblockCopyName: @ 8137044
push {r4,lr}
adds r4, r1, 0
movs r1, 0
bl GetPokeblockData
lsls r0, 24
ldr r1, =gPokeblockNames
lsrs r0, 22
adds r0, r1
ldr r1, [r0]
adds r0, r4, 0
bl StringCopy
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end PokeblockCopyName
thumb_func_start sub_8137068
sub_8137068: @ 8137068
push {r4-r7,lr}
adds r6, r1, 0
lsls r0, 24
lsrs r5, r0, 24
movs r4, 0
ldr r7, =gPokeblockNames
_08137074:
lsls r1, r4, 3
ldr r0, =sFavoritePokeblocksTable
adds r1, r0
adds r0, r5, 0
bl PokeblockGetGain
lsls r0, 16
cmp r0, 0
ble _081370A0
adds r0, r4, 0x1
lsls r0, 2
adds r0, r7
ldr r1, [r0]
adds r0, r6, 0
bl StringCopy
movs r0, 0x1
b _081370AC
.pool
_081370A0:
adds r0, r4, 0x1
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0x4
bls _08137074
movs r0, 0
_081370AC:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_8137068
thumb_func_start GetPokeblocksFlavor
GetPokeblocksFlavor: @ 81370B4
push {r4-r7,lr}
adds r5, r0, 0
movs r7, 0
movs r6, 0
_081370BC:
adds r1, r7, 0x1
lsls r1, 24
lsrs r1, 24
adds r0, r5, 0
bl GetPokeblockData
adds r4, r0, 0
adds r1, r6, 0x1
lsls r1, 24
lsrs r1, 24
adds r0, r5, 0
bl GetPokeblockData
lsls r4, 16
lsls r0, 16
lsls r1, r6, 16
cmp r4, r0
bge _081370E2
lsrs r7, r1, 16
_081370E2:
movs r2, 0x80
lsls r2, 9
adds r0, r1, r2
lsrs r6, r0, 16
asrs r0, 16
cmp r0, 0x4
ble _081370BC
lsls r0, r7, 24
lsrs r0, 24
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end GetPokeblocksFlavor
thumb_func_start sub_81370FC
sub_81370FC: @ 81370FC
@ -4909,7 +3988,7 @@ sub_81391D0: @ 81391D0
lsls r0, 24
lsrs r0, 24
ldr r1, =gStringVar1
bl sub_8137068
bl CopyMonFavoritePokeblockName
lsls r0, 24
lsrs r0, 24
pop {r1}

View File

@ -678,7 +678,7 @@ _08166BB6:
bne _08166BDA
ldr r0, =gSpecialVar_ItemId
ldrb r0, [r0]
bl sub_8136F68
bl TryClearPokeblock
ldr r0, =sub_8166BEC
bl sub_816636C
_08166BDA:

View File

@ -7,7 +7,7 @@ void sub_818DA78(void);
void sub_818DEF4(void);
void sub_818E564(void);
void sub_818E570(const struct LilycoveLadyQuiz *quiz);
bool8 sub_818E704(struct Pokeblock *pokeblock);
bool8 GivePokeblockToContestLady(struct Pokeblock *pokeblock);
void sub_818E7E0(u8 *dest1, u8 *dest2);
void sub_818E81C(u8 *dest);
void sub_818E848(u8 *dest);

View File

@ -4,6 +4,9 @@
#include "text.h"
#include "window.h"
#define MENU_NOTHING_CHOSEN -2
#define MENU_B_PRESSED -1
struct MenuAction
{
const u8 *text;
@ -34,5 +37,7 @@ void do_scheduled_bg_tilemap_copies_to_vram(void);
void clear_scheduled_bg_copies_to_vram(void);
void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, const struct TextColor *color, s8 speed, const u8 *str);
void sub_8197B1C(u8 windowId, bool8 copyToVram, u16 a2, u16 a3);
void sub_81995E4(u8 windowId, u8 optionsNo, const struct MenuAction *actions, const u8 *actionIds);
void sub_8197DF8(u8 windowId, bool8 copyToVram);
#endif // GUARD_MENU_H

View File

@ -25,5 +25,7 @@ void sub_8122344(void *arg0, u8 arg1);
void LoadListMenuArrowsGfx(void);
void sub_81223FC(u8 *a0, u8 count, u8 a2);
void sub_8122448(u8 *a0, u8 count, u16 x, u16 y);
void DisplayMessageAndContinueTask(u8 taskId, u8 arg1, u16 arg2, u8 arg3, u8 arg4, u8 textSpeed, const u8 *string, void *taskFunc);
void CreateYesNoMenuWithCallbacks(u8 taskId, const struct WindowTemplate *template, u8 arg2, u8 arg3, u8 arg4, u16 tileStart, u8 palette, const struct YesNoFuncTable *yesNo);
#endif //GUARD_MENU_HELPERS_H

View File

@ -52,16 +52,17 @@ void OpenPokeblockCase(u8 caseId, void (*callback)(void));
void OpenPokeblockCaseInBattle(void);
void OpenPokeblockCaseOnFeeder(void);
void ResetPokeblockScrollPositions(void);
u8 CreatePokeblockCaseSprite(s16 x, s16 y, u8 subpriority);
s16 GetPokeblockData(const struct Pokeblock *pokeblock, u8 dataId);
void ClearPokeblocks(void);
s8 GetFirstFreePokeblockSlot(void);
bool32 AddPokeblock(struct Pokeblock *pokeblock);
u8 GetHighestPokeblocksFlavorLevel(const struct Pokeblock *pokeblock);
u8 GetPokeblocksFeel(const struct Pokeblock *pokeblock);
s8 GetFirstFreePokeblockSlot(void);
bool32 AddPokeblock(const struct Pokeblock *pokeblock);
bool32 TryClearPokeblock(u8 pkblId);
s16 GetPokeblockData(const struct Pokeblock *pokeblock, u8 field);
s16 PokeblockGetGain(u8 nature, const struct Pokeblock *pokeblock);
void PokeblockCopyName(const struct Pokeblock *pokeblock, u8 *dest);
bool8 CopyMonFavoritePokeblockName(u8 nature, u8 *dest);
u8 GetPokeblocksFlavor(const struct Pokeblock *pokeblock);
s16 PokeblockGetGain(u8, const struct Pokeblock *pokeblock);
void PokeblockCopyName(const struct Pokeblock *pokeblock, u8 *dst);
#endif // GUARD_POKEBLOCK_H

View File

@ -54,6 +54,9 @@ extern const u8 gText_NoDecorationsInUse[];
extern const u8 gText_Exit[];
extern const u8 gText_Cancel[];
extern const u8 gText_ThrowAwayVar1[];
extern const u8 gText_Var1ThrownAway[];
extern const u8 gText_Color161Shadow161[];
extern const u8 gText_GoBackPrevMenu[];
extern const u8 gText_CantPlaceInRoom[];

View File

@ -177,7 +177,6 @@ extern const u16 gBattleInterface_BallDisplayPal[];
extern const u8 gHealthboxElementsGfxTable[][32];
// functions
extern void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor *color, s8 speed, const u8 *str); // menu.h
extern void LoadBattleBarGfx(u8 arg0);
// this file's functions

View File

@ -943,7 +943,7 @@ static void sub_818E6B0(u8 sheen)
}
}
bool8 sub_818E704(struct Pokeblock *pokeblock)
bool8 GivePokeblockToContestLady(struct Pokeblock *pokeblock)
{
u8 sheen;
bool8 response;

View File

@ -6,6 +6,7 @@
#include "menu.h"
#include "task.h"
#include "menu_helpers.h"
#include "new_menu_helpers.h"
#include "pokemon.h"
#include "graphics.h"
#include "malloc.h"
@ -19,21 +20,25 @@
#include "decompress.h"
#include "international_string_util.h"
#include "item.h"
#include "items.h"
#include "constants/items.h"
#include "string_util.h"
#include "songs.h"
#include "sound.h"
#include "berry.h"
#include "menu_indicators.h"
#include "event_data.h"
#include "battle_message.h"
#include "safari_zone.h"
#include "lilycove_lady.h"
#define POKEBLOCK_MAX_FEEL 99
#define FIELD_E75_COUNT 7
struct PokeblockMenuStruct
{
u8 tilemap[0x800];
void (*debugCallback)(void);
const u8 *pokeblockOptions;
void (*callbackOnUse)(void);
const u8 *pokeblockOptionsIds;
u8 optionsNo;
u8 caseId;
u8 itemsNo;
@ -84,39 +89,44 @@ extern void copy_textbox_border_tile_patterns_to_vram(u8, u16, u8);
extern void sub_80AF168(void);
// this file's functions
void CB2_InitPokeblockMenu(void);
bool8 InitPokeblockMenu(void);
static void CB2_InitPokeblockMenu(void);
static bool8 InitPokeblockMenu(void);
static bool8 LoadPokeblockMenuGfx(void);
static void HandleInitBackgrounds(void);
static void HandleInitWindows(void);
void SetMenuItemsCountAndMaxShowed(void);
void sub_81362E0(void);
void sub_8136344(void);
void HandlePokeblockListMenuItems(void);
void sub_81363BC(void);
static void SetMenuItemsCountAndMaxShowed(void);
static void sub_81362E0(void);
static void sub_8136344(void);
static void HandlePokeblockListMenuItems(void);
static void sub_81363BC(void);
static void MovePokeblockMenuCursor(u32 pkblId, bool8 arg1, struct ListMenu *arg2);
static void PutPokeblockInfoText(void);
void HandlePokeblockMenuCursor(u16 cursorPos, u16 arg1);
static void HandlePokeblockMenuCursor(u16 cursorPos, u16 arg1);
static void PutPokeblockListMenuString(u8 *dst, u16 pkblId);
void Task_HandlePokeblockMenuInput(u8 taskId);
void PokeblockAction_UseOnField(u8 taskId);
void PokeblockAction_Toss(u8 taskId);
void PokeblockAction_Cancel(u8 taskId);
void PokeblockAction_UseInBattle(u8 taskId);
void PokeblockAction_UseOnPokeblockFeeder(u8 taskId);
void PokeblockAction_GiveToContestLady(u8 taskId);
void TossPokeblockChoice_Yes(u8 taskId);
void TossPokeblockChoice_No(u8 taskId);
void Task_FreeDataAndExitPokeblockCase(u8 taskId);
void PutPokeblockOptionsWindow(u8 taskId);
static void Task_HandlePokeblockMenuInput(u8 taskId);
static void PokeblockAction_UseOnField(u8 taskId);
static void PokeblockAction_Toss(u8 taskId);
static void PokeblockAction_Cancel(u8 taskId);
static void PokeblockAction_UseInBattle(u8 taskId);
static void PokeblockAction_UseOnPokeblockFeeder(u8 taskId);
static void PokeblockAction_GiveToContestLady(u8 taskId);
static void TossPokeblockChoice_Yes(u8 taskId);
static void TossPokeblockChoice_No(u8 taskId);
static void Task_FreeDataAndExitPokeblockCase(u8 taskId);
static void Task_HandlePokeblockOptionsInput(u8 taskId);
static void PutPokeblockOptionsWindow(u8 taskId);
static void Task_HandlePokeblocksSwapInput(u8 taskId);
static void sub_8136470(struct Sprite *sprite);
static void sub_8135FCC(s32 pkblId);
void HandlePokeblocksSwap(u8 taskId, bool8 noSwap);
static void HandlePokeblocksSwap(u8 taskId, bool8 noSwap);
static void UsePokeblockOnField(void);
static void ReturnToPokeblockCaseOnField(void);
static void CreateTossPokeblockYesNoMenu(u8 taskId);
static void HandleErasePokeblock(u8 taskId);
// ram variables
EWRAM_DATA struct PokeblockSavedData sSavedPokeblockData = {0};
EWRAM_DATA struct PokeblockMenuStruct *sPokeblockMenu = NULL;
EWRAM_DATA static struct PokeblockSavedData sSavedPokeblockData = {0};
EWRAM_DATA static struct PokeblockMenuStruct *sPokeblockMenu = NULL;
// const rom data
const s8 gPokeblockFlavorCompatibilityTable[] =
@ -199,7 +209,7 @@ const u8 *const gPokeblockNames[] =
gText_GoldPokeblock
};
const struct MenuAction sPokeblockMenuActions[] =
static const struct MenuAction sPokeblockMenuActions[] =
{
{gMenuText_Use, PokeblockAction_UseOnField},
{gMenuText_Toss, PokeblockAction_Toss},
@ -209,12 +219,12 @@ const struct MenuAction sPokeblockMenuActions[] =
{gMenuText_Give2, PokeblockAction_GiveToContestLady},
};
const u8 sActionsOnField[] = {PKBL_USE_ON_FIELD, PKBL_TOSS, PKBL_CANCEL};
const u8 sActionsInBattle[] = {PKBL_USE_IN_BATTLE, PKBL_CANCEL};
const u8 sActionsOnPokeblockFeeder[] = {PKBL_USE_ON_FEEDER, PKBL_CANCEL};
const u8 sActionsWhenGivingToLady[] = {PKBL_GIVE_TO_LADY, PKBL_CANCEL};
static const u8 sActionsOnField[] = {PKBL_USE_ON_FIELD, PKBL_TOSS, PKBL_CANCEL};
static const u8 sActionsInBattle[] = {PKBL_USE_IN_BATTLE, PKBL_CANCEL};
static const u8 sActionsOnPokeblockFeeder[] = {PKBL_USE_ON_FEEDER, PKBL_CANCEL};
static const u8 sActionsWhenGivingToLady[] = {PKBL_GIVE_TO_LADY, PKBL_CANCEL};
const struct YesNoFuncTable sTossYesNoFuncTable = {TossPokeblockChoice_Yes, TossPokeblockChoice_No};
static const struct YesNoFuncTable sTossYesNoFuncTable = {TossPokeblockChoice_Yes, TossPokeblockChoice_No};
static const u8 sContestStatsMonData[] = {MON_DATA_COOL, MON_DATA_BEAUTY, MON_DATA_CUTE, MON_DATA_SMART, MON_DATA_TOUGH};
@ -246,7 +256,7 @@ static const union AnimCmd *const sSpriteAnimTable_PokeblockCase[] =
sSpriteAnim_PokeblockCase
};
static const union AffineAnimCmd gSpriteAffineAnim_85B26C8[] =
static const union AffineAnimCmd sSpriteAffineAnim_85B26C8[] =
{
AFFINEANIMCMD_FRAME(0, 0, -2, 2),
AFFINEANIMCMD_FRAME(0, 0, 2, 4),
@ -255,9 +265,9 @@ static const union AffineAnimCmd gSpriteAffineAnim_85B26C8[] =
AFFINEANIMCMD_END
};
const union AffineAnimCmd *const sSpriteAffineAnimTable_85B26F0[] =
static const union AffineAnimCmd *const sSpriteAffineAnimTable_85B26F0[] =
{
gSpriteAffineAnim_85B26C8
sSpriteAffineAnim_85B26C8
};
const struct CompressedSpriteSheet gPokeblockCase_SpriteSheet =
@ -281,9 +291,9 @@ static const struct SpriteTemplate sSpriteTemplate_PokeblockCase =
SpriteCallbackDummy
};
const struct TextColor sTextColorInPokeblockMenu = {0, 2, 3};
static const struct TextColor sTextColorInPokeblockMenu = {0, 2, 3};
const struct Pokeblock sFavoritePokeblocksTable[] =
static const struct Pokeblock sFavoritePokeblocksTable[] =
{
{ PBLOCK_CLR_RED, 20, 0, 0, 0, 0, 20},
{ PBLOCK_CLR_BLUE, 0, 20, 0, 0, 0, 20},
@ -308,7 +318,7 @@ static const struct WindowTemplate sWindowTemplatesForPokeblockMenu[] =
DUMMY_WIN_TEMPLATE
};
const struct WindowTemplate gUnknown_085B27A8[] = {1, 0x15, 9, 5, 4, 0xF, 0x20A};
static const struct WindowTemplate sTossPkblockWindowTemplate = {1, 0x15, 9, 5, 4, 0xF, 0x20A};
static const struct ListMenuTemplate sPokeblockListMenuTemplate =
{
@ -337,7 +347,7 @@ void OpenPokeblockCase(u8 caseId, void (*callback)(void))
{
sPokeblockMenu = Alloc(sizeof(*sPokeblockMenu));
sPokeblockMenu->caseId = caseId;
sPokeblockMenu->debugCallback = NULL;
sPokeblockMenu->callbackOnUse = NULL;
sPokeblockMenu->unkTaskId = 0xFF;
sPokeblockMenu->isSwapping = FALSE;
sSavedPokeblockData.callback = callback;
@ -345,19 +355,19 @@ void OpenPokeblockCase(u8 caseId, void (*callback)(void))
switch (sPokeblockMenu->caseId)
{
case PBLOCK_CASE_BATTLE:
sPokeblockMenu->pokeblockOptions = sActionsInBattle;
sPokeblockMenu->pokeblockOptionsIds = sActionsInBattle;
sPokeblockMenu->optionsNo = ARRAY_COUNT(sActionsInBattle);
break;
case PBLOCK_CASE_FEEDER:
sPokeblockMenu->pokeblockOptions = sActionsOnPokeblockFeeder;
sPokeblockMenu->pokeblockOptionsIds = sActionsOnPokeblockFeeder;
sPokeblockMenu->optionsNo = ARRAY_COUNT(sActionsOnPokeblockFeeder);
break;
case PBLOCK_CASE_GIVE:
sPokeblockMenu->pokeblockOptions = sActionsWhenGivingToLady;
sPokeblockMenu->pokeblockOptionsIds = sActionsWhenGivingToLady;
sPokeblockMenu->optionsNo = ARRAY_COUNT(sActionsWhenGivingToLady);
break;
default:
sPokeblockMenu->pokeblockOptions = sActionsOnField;
sPokeblockMenu->pokeblockOptionsIds = sActionsOnField;
sPokeblockMenu->optionsNo = ARRAY_COUNT(sActionsOnField);
break;
}
@ -391,7 +401,7 @@ static void VBlankCB_PokeblockMenu(void)
TransferPlttBuffer();
}
void CB2_InitPokeblockMenu(void)
static void CB2_InitPokeblockMenu(void)
{
while (1)
{
@ -404,7 +414,7 @@ void CB2_InitPokeblockMenu(void)
}
}
bool8 InitPokeblockMenu(void)
static bool8 InitPokeblockMenu(void)
{
u8 taskId;
@ -578,7 +588,7 @@ static void HandleInitWindows(void)
schedule_bg_copy_tilemap_to_vram(1);
}
void PrintOnPokeblockWindow(u8 windowId, const u8 *string, s32 x)
static void PrintOnPokeblockWindow(u8 windowId, const u8 *string, s32 x)
{
AddTextPrinterParametrized2(windowId, 1, x, 1, 0, 0, &sTextColorInPokeblockMenu, 0, string);
}
@ -602,7 +612,7 @@ static void PutPokeblockInfoText(void)
}
}
void HandlePokeblockListMenuItems(void)
static void HandlePokeblockListMenuItems(void)
{
u16 i;
@ -695,13 +705,13 @@ static void sub_8135FCC(s32 pkblId)
schedule_bg_copy_tilemap_to_vram(2);
}
void HandlePokeblockMenuCursor(u16 cursorPos, u16 arg1)
static void HandlePokeblockMenuCursor(u16 cursorPos, u16 arg1)
{
FillBgTilemapBufferRect_Palette0(2, arg1, 0xF, (cursorPos * 2) + 1, 0xE, 2);
schedule_bg_copy_tilemap_to_vram(2);
}
void CompactPokeblockSlots(void)
static void CompactPokeblockSlots(void)
{
u16 i, j;
@ -719,7 +729,7 @@ void CompactPokeblockSlots(void)
}
}
void SwapSortPokeblocksInternalData(u32 id1, u32 id2)
static void SwapSortPokeblocksInternalData(u32 id1, u32 id2)
{
s16 i, count;
struct Pokeblock *pokeblocks = gSaveBlock1Ptr->pokeblocks;
@ -753,7 +763,7 @@ void ResetPokeblockScrollPositions(void)
sSavedPokeblockData.lastItemPage = 0;
}
void SetMenuItemsCountAndMaxShowed(void)
static void SetMenuItemsCountAndMaxShowed(void)
{
u16 i;
@ -773,7 +783,7 @@ void SetMenuItemsCountAndMaxShowed(void)
sPokeblockMenu->maxShowed = sPokeblockMenu->itemsNo;
}
void sub_81362E0(void)
static void sub_81362E0(void)
{
if (sSavedPokeblockData.lastItemPage != 0)
{
@ -790,7 +800,7 @@ void sub_81362E0(void)
}
}
void sub_8136344(void)
static void sub_8136344(void)
{
if (sSavedPokeblockData.lastItemPos > 4)
{
@ -802,7 +812,7 @@ void sub_8136344(void)
}
}
void sub_81363BC(void)
static void sub_81363BC(void)
{
if (sPokeblockMenu->unkTaskId == 0xFF)
{
@ -811,7 +821,7 @@ void sub_81363BC(void)
}
}
void sub_8136418(void)
static void sub_8136418(void)
{
if (sPokeblockMenu->unkTaskId != 0xFF)
{
@ -852,13 +862,13 @@ static void sub_8136470(struct Sprite *sprite)
}
}
void FadePaletteAndSetTaskToClosePokeblockCase(u8 taskId)
static void FadePaletteAndSetTaskToClosePokeblockCase(u8 taskId)
{
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
gTasks[taskId].func = Task_FreeDataAndExitPokeblockCase;
}
void Task_FreeDataAndExitPokeblockCase(u8 taskId)
static void Task_FreeDataAndExitPokeblockCase(u8 taskId)
{
s16 *data = gTasks[taskId].data;
@ -872,8 +882,8 @@ void Task_FreeDataAndExitPokeblockCase(u8 taskId)
ResetSpriteData();
FreeAllSpritePalettes();
if (sPokeblockMenu->debugCallback != NULL)
SetMainCallback2(sPokeblockMenu->debugCallback);
if (sPokeblockMenu->callbackOnUse != NULL)
SetMainCallback2(sPokeblockMenu->callbackOnUse);
else
SetMainCallback2(sSavedPokeblockData.callback);
@ -883,7 +893,7 @@ void Task_FreeDataAndExitPokeblockCase(u8 taskId)
}
}
void Task_HandlePokeblockMenuInput(u8 taskId)
static void Task_HandlePokeblockMenuInput(u8 taskId)
{
s16 *data = gTasks[taskId].data;
@ -987,7 +997,7 @@ static void Task_HandlePokeblocksSwapInput(u8 taskId)
}
}
void HandlePokeblocksSwap(u8 taskId, bool8 noSwap)
static void HandlePokeblocksSwap(u8 taskId, bool8 noSwap)
{
u8 i;
s16 *data = gTasks[taskId].data;
@ -1015,3 +1025,320 @@ void HandlePokeblocksSwap(u8 taskId, bool8 noSwap)
HandlePokeblockMenuCursor(sSavedPokeblockData.lastItemPos, 0x1005);
gTasks[taskId].func = Task_HandlePokeblockMenuInput;
}
static void PutPokeblockOptionsWindow(u8 taskId)
{
s16 *data = gTasks[taskId].data;
if (sPokeblockMenu->optionsNo == 3)
data[1] = 8;
else
data[1] = 9;
sub_8136418();
SetWindowBorderStyle(data[1], 0, 1, 0xE);
sub_81995E4(data[1], sPokeblockMenu->optionsNo, sPokeblockMenuActions, sPokeblockMenu->pokeblockOptionsIds);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[1], sPokeblockMenu->optionsNo, 0);
PutWindowTilemap(data[1]);
schedule_bg_copy_tilemap_to_vram(1);
gTasks[taskId].func = Task_HandlePokeblockOptionsInput;
}
static void Task_HandlePokeblockOptionsInput(u8 taskId)
{
s8 itemId;
if (sub_81221EC() == TRUE)
return;
itemId = ProcessMenuInputNoWrapAround();
if (itemId == MENU_NOTHING_CHOSEN)
{
return;
}
else if (itemId == MENU_B_PRESSED)
{
PlaySE(SE_SELECT);
PokeblockAction_Cancel(taskId);
}
else
{
PlaySE(SE_SELECT);
sPokeblockMenuActions[sPokeblockMenu->pokeblockOptionsIds[itemId]].func.void_u8(taskId);
}
}
static void PokeblockAction_UseOnField(u8 taskId)
{
sPokeblockMenu->callbackOnUse = UsePokeblockOnField;
FadePaletteAndSetTaskToClosePokeblockCase(taskId);
}
static void UsePokeblockOnField(void)
{
ChooseMonToGivePokeblock(&gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId], ReturnToPokeblockCaseOnField);
}
static void ReturnToPokeblockCaseOnField(void)
{
OpenPokeblockCase(PBLOCK_CASE_FIELD, sSavedPokeblockData.callback);
}
static void PokeblockAction_Toss(u8 taskId)
{
s16 *data = gTasks[taskId].data;
sub_8198070(data[1], FALSE);
StringCopy(gStringVar1, gPokeblockNames[gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId].color]);
StringExpandPlaceholders(gStringVar4, gText_ThrowAwayVar1);
DisplayMessageAndContinueTask(taskId, 10, 10, 13, 1, GetPlayerTextSpeed(), gStringVar4, CreateTossPokeblockYesNoMenu);
}
static void CreateTossPokeblockYesNoMenu(u8 taskId)
{
CreateYesNoMenuWithCallbacks(taskId, &sTossPkblockWindowTemplate, 1, 0, 2, 1, 0xE, &sTossYesNoFuncTable);
}
static void TossPokeblockChoice_Yes(u8 taskId)
{
StringExpandPlaceholders(gStringVar4, gText_Var1ThrownAway);
DisplayMessageAndContinueTask(taskId, 10, 10, 13, 1, GetPlayerTextSpeed(), gStringVar4, HandleErasePokeblock);
}
static void HandleErasePokeblock(u8 taskId)
{
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
{
s16 *data;
u16 *lastPage, *lastPos;
TryClearPokeblock(gSpecialVar_ItemId);
PlaySE(SE_SELECT);
lastPage = &sSavedPokeblockData.lastItemPage;
lastPos = &sSavedPokeblockData.lastItemPos;
data = gTasks[taskId].data;
sub_81AE6C8(data[0], lastPage, lastPos);
HandlePokeblockMenuCursor(*lastPos, 5);
SetMenuItemsCountAndMaxShowed();
sub_81362E0();
HandlePokeblockListMenuItems();
data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *lastPage, *lastPos);
HandlePokeblockMenuCursor(*lastPos, 0x1005);
schedule_bg_copy_tilemap_to_vram(0);
schedule_bg_copy_tilemap_to_vram(1);
TossPokeblockChoice_No(taskId);
}
}
static void TossPokeblockChoice_No(u8 taskId)
{
sub_8197DF8(10, FALSE);
schedule_bg_copy_tilemap_to_vram(1);
sub_81363BC();
gTasks[taskId].func = Task_HandlePokeblockMenuInput;
}
static void PokeblockAction_UseInBattle(u8 taskId)
{
u8 nature = GetNature(&gEnemyParty[0]);
s16 gain = PokeblockGetGain(nature, &gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId]);
StringCopy(gBattleTextBuff1, gPokeblockNames[gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId].color]);
TryClearPokeblock(gSpecialVar_ItemId);
gSpecialVar_ItemId = gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId].color << 8;
if (gain == 0)
gSpecialVar_ItemId += 1;
else if (gain > 0)
gSpecialVar_ItemId += 2;
else
gSpecialVar_ItemId += 3;
FadePaletteAndSetTaskToClosePokeblockCase(taskId);
}
static void PokeblockAction_UseOnPokeblockFeeder(u8 taskId)
{
SafariZoneActivatePokeblockFeeder(gSpecialVar_ItemId);
StringCopy(gStringVar1, gPokeblockNames[gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId].color]);
gSpecialVar_Result = gSpecialVar_ItemId;
TryClearPokeblock(gSpecialVar_ItemId);
gSpecialVar_ItemId = 0;
FadePaletteAndSetTaskToClosePokeblockCase(taskId);
}
static void PokeblockAction_GiveToContestLady(u8 taskId)
{
gSpecialVar_0x8004 = GivePokeblockToContestLady(&gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId]);
gSpecialVar_Result = gSpecialVar_ItemId;
TryClearPokeblock(gSpecialVar_ItemId);
gSpecialVar_ItemId = 0;
FadePaletteAndSetTaskToClosePokeblockCase(taskId);
}
static void PokeblockAction_Cancel(u8 taskId)
{
s16 *data = gTasks[taskId].data;
sub_8198070(data[1], FALSE);
schedule_bg_copy_tilemap_to_vram(1);
sub_81363BC();
gTasks[taskId].func = Task_HandlePokeblockMenuInput;
}
static void ClearPokeblock(u8 pkblId)
{
gSaveBlock1Ptr->pokeblocks[pkblId].color = 0;
gSaveBlock1Ptr->pokeblocks[pkblId].spicy = 0;
gSaveBlock1Ptr->pokeblocks[pkblId].dry = 0;
gSaveBlock1Ptr->pokeblocks[pkblId].sweet = 0;
gSaveBlock1Ptr->pokeblocks[pkblId].bitter = 0;
gSaveBlock1Ptr->pokeblocks[pkblId].sour = 0;
gSaveBlock1Ptr->pokeblocks[pkblId].feel = 0;
}
void ClearPokeblocks(void)
{
u8 i;
for (i = 0; i < POKEBLOCKS_COUNT; i++)
ClearPokeblock(i);
}
u8 GetHighestPokeblocksFlavorLevel(const struct Pokeblock *pokeblock)
{
u8 i;
u8 maxFlavor = GetPokeblockData(pokeblock, PBLOCK_SPICY);
for (i = PBLOCK_SPICY; i < FLAVOR_COUNT; i++)
{
u8 currFlavor = GetPokeblockData(pokeblock, PBLOCK_SPICY + i);
if (maxFlavor < currFlavor)
maxFlavor = currFlavor;
}
return maxFlavor;
}
u8 GetPokeblocksFeel(const struct Pokeblock *pokeblock)
{
u8 feel = GetPokeblockData(pokeblock, PBLOCK_FEEL);
if (feel > POKEBLOCK_MAX_FEEL)
feel = POKEBLOCK_MAX_FEEL;
return feel;
}
s8 GetFirstFreePokeblockSlot(void)
{
u8 i;
for (i = 0; i < POKEBLOCKS_COUNT; i++)
{
if (gSaveBlock1Ptr->pokeblocks[i].color == 0)
return i;
}
return -1;
}
bool32 AddPokeblock(const struct Pokeblock *pokeblock)
{
s8 slot = GetFirstFreePokeblockSlot();
if (slot == -1)
{
return FALSE;
}
else
{
gSaveBlock1Ptr->pokeblocks[slot] = *pokeblock;
return TRUE;
}
}
bool32 TryClearPokeblock(u8 pkblId)
{
if (gSaveBlock1Ptr->pokeblocks[pkblId].color == 0)
{
return FALSE;
}
else
{
ClearPokeblock(pkblId);
return TRUE;
}
}
s16 GetPokeblockData(const struct Pokeblock *pokeblock, u8 field)
{
if (field == PBLOCK_COLOR)
return pokeblock->color;
if (field == PBLOCK_SPICY)
return pokeblock->spicy;
if (field == PBLOCK_DRY)
return pokeblock->dry;
if (field == PBLOCK_SWEET)
return pokeblock->sweet;
if (field == PBLOCK_BITTER)
return pokeblock->bitter;
if (field == PBLOCK_SOUR)
return pokeblock->sour;
if (field == PBLOCK_FEEL)
return pokeblock->feel;
return 0;
}
s16 PokeblockGetGain(u8 nature, const struct Pokeblock *pokeblock)
{
u8 flavor;
s16 curGain, totalGain = 0;
for (flavor = 0; flavor < FLAVOR_COUNT; flavor++)
{
curGain = GetPokeblockData(pokeblock, flavor + PBLOCK_SPICY);
if (curGain > 0)
totalGain += curGain * gPokeblockFlavorCompatibilityTable[5 * nature + flavor];
}
return totalGain;
}
void PokeblockCopyName(const struct Pokeblock *pokeblock, u8 *dest)
{
u8 color = GetPokeblockData(pokeblock, PBLOCK_COLOR);
StringCopy(dest, gPokeblockNames[color]);
}
bool8 CopyMonFavoritePokeblockName(u8 nature, u8 *dest)
{
u8 i;
for (i = 0; i < FLAVOR_COUNT; i++)
{
if (PokeblockGetGain(nature, &sFavoritePokeblocksTable[i]) > 0)
{
StringCopy(dest, gPokeblockNames[i + 1]);
return TRUE;
}
}
return FALSE;
}
u8 GetPokeblocksFlavor(const struct Pokeblock *pokeblock)
{
s16 bestFlavor = 0;
s16 i;
for (i = 0; i < FLAVOR_COUNT; i++)
{
if (GetPokeblockData(pokeblock, bestFlavor + 1) < GetPokeblockData(pokeblock, i + 1))
bestFlavor = i;
}
return bestFlavor;
}