ref: 323ef81286c554d928520341fbc13ef21dc1ec79
dir: /engine/pack.asm/
; Pack.Jumptable and BattlePack.Jumptable indexes const_def const PACKSTATE_INITGFX ; 0 const PACKSTATE_INITITEMSPOCKET ; 1 const PACKSTATE_ITEMSPOCKETMENU ; 2 const PACKSTATE_INITBALLSPOCKET ; 3 const PACKSTATE_BALLSPOCKETMENU ; 4 const PACKSTATE_INITKEYITEMSPOCKET ; 5 const PACKSTATE_KEYITEMSPOCKETMENU ; 6 const PACKSTATE_INITTMHMPOCKET ; 7 const PACKSTATE_TMHMPOCKETMENU ; 8 const PACKSTATE_QUITNOSCRIPT ; 9 const PACKSTATE_QUITRUNSCRIPT ; 10 Pack: ; 10000 ld hl, Options set NO_TEXT_SCROLL, [hl] call InitPackBuffers .loop call JoyTextDelay ld a, [wJumptableIndex] bit 7, a jr nz, .done call .RunJumptable call DelayFrame jr .loop .done ld a, [wCurrPocket] ld [wLastPocket], a ld hl, Options res NO_TEXT_SCROLL, [hl] ret ; 10026 .RunJumptable: ; 10026 ld a, [wJumptableIndex] ld hl, .Jumptable call Pack_GetJumptablePointer jp hl ; 10030 .Jumptable: ; 10030 (4:4030) ; entries correspond to PACKSTATE_* constants dw .InitGFX ; 0 dw .InitItemsPocket ; 1 dw .ItemsPocketMenu ; 2 dw .InitBallsPocket ; 3 dw .BallsPocketMenu ; 4 dw .InitKeyItemsPocket ; 5 dw .KeyItemsPocketMenu ; 6 dw .InitTMHMPocket ; 7 dw .TMHMPocketMenu ; 8 dw Pack_QuitNoScript ; 9 dw Pack_QuitRunScript ; 10 .InitGFX: ; 10046 (4:4046) xor a ld [hBGMapMode], a call Pack_InitGFX ld a, [wPackJumptableIndex] ld [wJumptableIndex], a call Pack_InitColors ret .InitItemsPocket: ; 10056 (4:4056) xor a ; ITEM_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName call WaitBGMap_DrawPackGFX call Pack_JumptableNext ret .ItemsPocketMenu: ; 10067 (4:4067) ld hl, ItemsPocketMenuHeader call CopyMenuHeader ld a, [wItemsPocketCursor] ld [wMenuCursorBuffer], a ld a, [wItemsPocketScrollPosition] ld [wMenuScrollPosition], a call ScrollingMenu ld a, [wMenuScrollPosition] ld [wItemsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wItemsPocketCursor], a ld b, PACKSTATE_INITTMHMPOCKET ; left ld c, PACKSTATE_INITBALLSPOCKET ; right call Pack_InterpretJoypad ret c call .ItemBallsKey_LoadSubmenu ret .InitKeyItemsPocket: ; 10094 (4:4094) ld a, KEY_ITEM_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName call WaitBGMap_DrawPackGFX call Pack_JumptableNext ret .KeyItemsPocketMenu: ; 100a6 (4:40a6) ld hl, KeyItemsPocketMenuHeader call CopyMenuHeader ld a, [wKeyItemsPocketCursor] ld [wMenuCursorBuffer], a ld a, [wKeyItemsPocketScrollPosition] ld [wMenuScrollPosition], a call ScrollingMenu ld a, [wMenuScrollPosition] ld [wKeyItemsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wKeyItemsPocketCursor], a ld b, PACKSTATE_INITBALLSPOCKET ; left ld c, PACKSTATE_INITTMHMPOCKET ; right call Pack_InterpretJoypad ret c call .ItemBallsKey_LoadSubmenu ret .InitTMHMPocket: ; 100d3 (4:40d3) ld a, TM_HM_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName xor a ld [hBGMapMode], a call WaitBGMap_DrawPackGFX call Pack_JumptableNext ret .TMHMPocketMenu: ; 100e8 (4:40e8) farcall TMHMPocket ld b, PACKSTATE_INITKEYITEMSPOCKET ; left ld c, PACKSTATE_INITITEMSPOCKET ; right call Pack_InterpretJoypad ret c farcall _CheckTossableItem ld a, [wItemAttributeParamBuffer] and a jr nz, .use_quit ld hl, .MenuHeader2 ld de, .Jumptable2 jr .load_jump .use_quit ld hl, .MenuHeader1 ld de, .Jumptable1 .load_jump push de call LoadMenuHeader call VerticalMenu call ExitMenu pop hl ret c ld a, [wMenuCursorY] dec a call Pack_GetJumptablePointer jp hl ; 10124 (4:4124) .MenuHeader1: ; 0x10124 db MENU_BACKUP_TILES ; flags menu_coords 13, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData_1 db 1 ; default option ; 0x1012c .MenuData_1: ; 0x1012c db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 2 ; items db "USE@" db "QUIT@" ; 0x10137 .Jumptable1: ; 10137 dw .UseItem dw QuitItemSubmenu ; 1013b .MenuHeader2: ; 0x1013b db MENU_BACKUP_TILES ; flags menu_coords 13, 5, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData_2 db 1 ; default option ; 0x10143 .MenuData_2: ; 0x10143 db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 3 ; items db "USE@" db "GIVE@" db "QUIT@" ; 0x10153 .Jumptable2: ; 10153 dw .UseItem dw GiveItem dw QuitItemSubmenu ; 10159 .UseItem: ; 10159 farcall AskTeachTMHM ret c farcall ChooseMonToLearnTMHM jr c, .declined ld hl, Options ld a, [hl] push af res NO_TEXT_SCROLL, [hl] farcall TeachTMHM pop af ld [Options], a .declined xor a ld [hBGMapMode], a call Pack_InitGFX call WaitBGMap_DrawPackGFX call Pack_InitColors ret .InitBallsPocket: ; 10186 (4:4186) ld a, BALL_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName call WaitBGMap_DrawPackGFX call Pack_JumptableNext ret .BallsPocketMenu: ; 10198 (4:4198) ld hl, BallsPocketMenuHeader call CopyMenuHeader ld a, [wBallsPocketCursor] ld [wMenuCursorBuffer], a ld a, [wBallsPocketScrollPosition] ld [wMenuScrollPosition], a call ScrollingMenu ld a, [wMenuScrollPosition] ld [wBallsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wBallsPocketCursor], a ld b, PACKSTATE_INITITEMSPOCKET ; left ld c, PACKSTATE_INITKEYITEMSPOCKET ; right call Pack_InterpretJoypad ret c call .ItemBallsKey_LoadSubmenu ret .ItemBallsKey_LoadSubmenu: ; 101c5 (4:41c5) farcall _CheckTossableItem ld a, [wItemAttributeParamBuffer] and a jr nz, .tossable farcall CheckSelectableItem ld a, [wItemAttributeParamBuffer] and a jr nz, .selectable farcall CheckItemMenu ld a, [wItemAttributeParamBuffer] and a jr nz, .usable jr .unusable .selectable farcall CheckItemMenu ld a, [wItemAttributeParamBuffer] and a jr nz, .selectable_usable jr .selectable_unusable .tossable farcall CheckSelectableItem ld a, [wItemAttributeParamBuffer] and a jr nz, .tossable_selectable jr .tossable_unselectable .usable ld hl, MenuHeader_UsableKeyItem ld de, Jumptable_UseGiveTossRegisterQuit jr .build_menu .selectable_usable ld hl, MenuHeader_UsableItem ld de, Jumptable_UseGiveTossQuit jr .build_menu .tossable_selectable ld hl, MenuHeader_UnusableItem ld de, Jumptable_UseQuit jr .build_menu .tossable_unselectable ld hl, MenuHeader_UnusableKeyItem ld de, Jumptable_UseRegisterQuit jr .build_menu .unusable ld hl, MenuHeader_HoldableKeyItem ld de, Jumptable_GiveTossRegisterQuit jr .build_menu .selectable_unusable ld hl, MenuHeader_HoldableItem ld de, Jumptable_GiveTossQuit .build_menu push de call LoadMenuHeader call VerticalMenu call ExitMenu pop hl ret c ld a, [wMenuCursorY] dec a call Pack_GetJumptablePointer jp hl ; 10249 (4:4249) MenuHeader_UsableKeyItem: ; 0x10249 db MENU_BACKUP_TILES ; flags menu_coords 13, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData db 1 ; default option ; 0x10251 .MenuData: ; 0x10251 db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 5 ; items db "USE@" db "GIVE@" db "TOSS@" db "SEL@" db "QUIT@" ; 0x1026a Jumptable_UseGiveTossRegisterQuit: ; 1026a dw UseItem dw GiveItem dw TossMenu dw RegisterItem dw QuitItemSubmenu ; 10274 MenuHeader_UsableItem: ; 0x10274 db MENU_BACKUP_TILES ; flags menu_coords 13, 3, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData db 1 ; default option ; 0x1027c .MenuData: ; 0x1027c db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 4 ; items db "USE@" db "GIVE@" db "TOSS@" db "QUIT@" ; 0x10291 Jumptable_UseGiveTossQuit: ; 10291 dw UseItem dw GiveItem dw TossMenu dw QuitItemSubmenu ; 10299 MenuHeader_UnusableItem: ; 0x10299 db MENU_BACKUP_TILES ; flags menu_coords 13, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData db 1 ; default option ; 0x102a1 .MenuData: ; 0x102a1 db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 2 ; items db "USE@" db "QUIT@" ; 0x102ac Jumptable_UseQuit: ; 102ac dw UseItem dw QuitItemSubmenu ; 102b0 MenuHeader_UnusableKeyItem: ; 0x102b0 db MENU_BACKUP_TILES ; flags menu_coords 13, 5, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData db 1 ; default option ; 0x102b8 .MenuData: ; 0x102b8 db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 3 ; items db "USE@" db "SEL@" db "QUIT@" ; 0x102c7 Jumptable_UseRegisterQuit: ; 102c7 dw UseItem dw RegisterItem dw QuitItemSubmenu ; 102cd MenuHeader_HoldableKeyItem: ; 0x102cd db MENU_BACKUP_TILES ; flags menu_coords 13, 3, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData db 1 ; default option ; 0x102d5 .MenuData: ; 0x102d5 db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 4 ; items db "GIVE@" db "TOSS@" db "SEL@" db "QUIT@" ; 0x102ea Jumptable_GiveTossRegisterQuit: ; 102ea dw GiveItem dw TossMenu dw RegisterItem dw QuitItemSubmenu ; 102f2 MenuHeader_HoldableItem: ; 0x102f2 db MENU_BACKUP_TILES ; flags menu_coords 13, 5, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData db 1 ; default option ; 0x102fa .MenuData: ; 0x102fa db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 3 ; items db "GIVE@" db "TOSS@" db "QUIT@" ; 0x1030b Jumptable_GiveTossQuit: ; 1030b dw GiveItem dw TossMenu dw QuitItemSubmenu ; 10311 UseItem: ; 10311 farcall CheckItemMenu ld a, [wItemAttributeParamBuffer] ld hl, .dw rst JumpTable ret ; 1031f .dw ; 1031f (4:431f) ; entries correspond to ITEMMENU_* constants dw .Oak ; ITEMMENU_NOUSE dw .Oak dw .Oak dw .Oak dw .Current ; ITEMMENU_CURRENT dw .Party ; ITEMMENU_PARTY dw .Field ; ITEMMENU_CLOSE ; 1035c .Oak: ; 1032d (4:432d) ld hl, Text_ThisIsntTheTime call Pack_PrintTextNoScroll ret .Current: ; 10334 (4:4334) call DoItemEffect ret .Party: ; 10338 (4:4338) ld a, [PartyCount] and a jr z, .NoPokemon call DoItemEffect xor a ld [hBGMapMode], a call Pack_InitGFX call WaitBGMap_DrawPackGFX call Pack_InitColors ret .NoPokemon: ld hl, TextJump_YouDontHaveAPkmn call Pack_PrintTextNoScroll ret .Field: ; 10355 (4:4355) call DoItemEffect ld a, [wItemEffectSucceeded] and a jr z, .Oak ld a, PACKSTATE_QUITRUNSCRIPT ld [wJumptableIndex], a ret ; 10364 (4:4364) TossMenu: ; 10364 ld hl, Text_ThrowAwayHowMany call Pack_PrintTextNoScroll farcall SelectQuantityToToss push af call ExitMenu pop af jr c, .finish call Pack_GetItemName ld hl, Text_ConfirmThrowAway call MenuTextBox call YesNoBox push af call ExitMenu pop af jr c, .finish ld hl, NumItems ld a, [CurItemQuantity] call TossItem call Pack_GetItemName ld hl, Text_ThrewAway call Pack_PrintTextNoScroll .finish ret ; 1039d Unreferenced_ResetPocketCursorPositions: ; 1039d ld a, [wCurrPocket] and a ; ITEM_POCKET jr z, .items dec a ; BALL_POCKET jr z, .balls dec a ; KEY_ITEM_POCKET jr z, .key ret .balls xor a ld [wBallsPocketCursor], a ld [wBallsPocketScrollPosition], a ret .items xor a ld [wItemsPocketCursor], a ld [wItemsPocketScrollPosition], a ret .key xor a ld [wKeyItemsPocketCursor], a ld [wKeyItemsPocketScrollPosition], a ret ; 103c2 RegisterItem: ; 103c2 farcall CheckSelectableItem ld a, [wItemAttributeParamBuffer] and a jr nz, .cant_register ld a, [wCurrPocket] rrca rrca and $c0 ld b, a ld a, [CurItemQuantity] inc a and $3f or b ld [WhichRegisteredItem], a ld a, [CurItem] ld [RegisteredItem], a call Pack_GetItemName ld de, SFX_FULL_HEAL call WaitPlaySFX ld hl, Text_RegisteredItem call Pack_PrintTextNoScroll ret .cant_register ld hl, Text_CantRegister call Pack_PrintTextNoScroll ret ; 103fd GiveItem: ; 103fd ld a, [PartyCount] and a jp z, .NoPokemon ld a, [Options] push af res NO_TEXT_SCROLL, a ld [Options], a ld a, PARTYMENUACTION_GIVE_ITEM ld [PartyMenuActionText], a call ClearBGPalettes farcall LoadPartyMenuGFX farcall InitPartyMenuWithCancel farcall InitPartyMenuGFX .loop farcall WritePartyMenuTilemap farcall PrintPartyMenuText call WaitBGMap call SetPalettes call DelayFrame farcall PartyMenuSelect jr c, .finish ld a, [CurPartySpecies] cp EGG jr nz, .give ld hl, .Egg call PrintText jr .loop .give ld a, [wJumptableIndex] push af ld a, [wPackJumptableIndex] push af call GetCurNick ld hl, StringBuffer1 ld de, wMonOrItemNameBuffer ld bc, MON_NAME_LENGTH call CopyBytes call TryGiveItemToPartymon pop af ld [wPackJumptableIndex], a pop af ld [wJumptableIndex], a .finish pop af ld [Options], a xor a ld [hBGMapMode], a call Pack_InitGFX call WaitBGMap_DrawPackGFX call Pack_InitColors ret .NoPokemon: ; 10486 (4:4486) ld hl, TextJump_YouDontHaveAPkmn call Pack_PrintTextNoScroll ret ; 1048d (4:448d) .Egg: ; 0x1048d ; An EGG can't hold an item. text_jump Text_AnEGGCantHoldAnItem db "@" ; 0x10492 QuitItemSubmenu: ; 10492 ret ; 10493 BattlePack: ; 10493 ld hl, Options set NO_TEXT_SCROLL, [hl] call InitPackBuffers .loop call JoyTextDelay ld a, [wJumptableIndex] bit 7, a jr nz, .end call .RunJumptable call DelayFrame jr .loop .end ld a, [wCurrPocket] ld [wLastPocket], a ld hl, Options res NO_TEXT_SCROLL, [hl] ret ; 104b9 .RunJumptable: ; 104b9 ld a, [wJumptableIndex] ld hl, .Jumptable call Pack_GetJumptablePointer jp hl ; 104c3 .Jumptable: ; 104c3 (4:44c3) ; entries correspond to PACKSTATE_* constants dw .InitGFX ; 0 dw .InitItemsPocket ; 1 dw .ItemsPocketMenu ; 2 dw .InitBallsPocket ; 3 dw .BallsPocketMenu ; 4 dw .InitKeyItemsPocket ; 5 dw .KeyItemsPocketMenu ; 6 dw .InitTMHMPocket ; 7 dw .TMHMPocketMenu ; 8 dw Pack_QuitNoScript ; 9 dw Pack_QuitRunScript ; 10 .InitGFX: ; 104d9 (4:44d9) xor a ld [hBGMapMode], a call Pack_InitGFX ld a, [wPackJumptableIndex] ld [wJumptableIndex], a call Pack_InitColors ret .InitItemsPocket: ; 104e9 (4:44e9) xor a ; ITEM_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName call WaitBGMap_DrawPackGFX call Pack_JumptableNext ret .ItemsPocketMenu: ; 104fa (4:44fa) ld hl, ItemsPocketMenuHeader call CopyMenuHeader ld a, [wItemsPocketCursor] ld [wMenuCursorBuffer], a ld a, [wItemsPocketScrollPosition] ld [wMenuScrollPosition], a call ScrollingMenu ld a, [wMenuScrollPosition] ld [wItemsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wItemsPocketCursor], a ld b, PACKSTATE_INITTMHMPOCKET ; left ld c, PACKSTATE_INITBALLSPOCKET ; right call Pack_InterpretJoypad ret c call ItemSubmenu ret .InitKeyItemsPocket: ; 10527 (4:4527) ld a, KEY_ITEM_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName call WaitBGMap_DrawPackGFX call Pack_JumptableNext ret .KeyItemsPocketMenu: ; 10539 (4:4539) ld hl, KeyItemsPocketMenuHeader call CopyMenuHeader ld a, [wKeyItemsPocketCursor] ld [wMenuCursorBuffer], a ld a, [wKeyItemsPocketScrollPosition] ld [wMenuScrollPosition], a call ScrollingMenu ld a, [wMenuScrollPosition] ld [wKeyItemsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wKeyItemsPocketCursor], a ld b, PACKSTATE_INITBALLSPOCKET ; left ld c, PACKSTATE_INITTMHMPOCKET ; right call Pack_InterpretJoypad ret c call ItemSubmenu ret .InitTMHMPocket: ; 10566 (4:4566) ld a, TM_HM_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName xor a ld [hBGMapMode], a call WaitBGMap_DrawPackGFX ld hl, Text_PackEmptyString call Pack_PrintTextNoScroll call Pack_JumptableNext ret .TMHMPocketMenu: ; 10581 (4:4581) farcall TMHMPocket ld b, PACKSTATE_INITKEYITEMSPOCKET ; left ld c, PACKSTATE_INITITEMSPOCKET ; right call Pack_InterpretJoypad ret c xor a call TMHMSubmenu ret .InitBallsPocket: ; 10594 (4:4594) ld a, BALL_POCKET ld [wCurrPocket], a call ClearPocketList call DrawPocketName call WaitBGMap_DrawPackGFX call Pack_JumptableNext ret .BallsPocketMenu: ; 105a6 (4:45a6) ld hl, BallsPocketMenuHeader call CopyMenuHeader ld a, [wBallsPocketCursor] ld [wMenuCursorBuffer], a ld a, [wBallsPocketScrollPosition] ld [wMenuScrollPosition], a call ScrollingMenu ld a, [wMenuScrollPosition] ld [wBallsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wBallsPocketCursor], a ld b, PACKSTATE_INITITEMSPOCKET ; left ld c, PACKSTATE_INITKEYITEMSPOCKET ; right call Pack_InterpretJoypad ret c call ItemSubmenu ret ItemSubmenu: ; 105d3 (4:45d3) farcall CheckItemContext ld a, [wItemAttributeParamBuffer] TMHMSubmenu: ; 105dc (4:45dc) and a jr z, .NoUse ld hl, .UsableMenuHeader ld de, .UsableJumptable jr .proceed .NoUse: ld hl, .UnusableMenuHeader ld de, .UnusableJumptable .proceed push de call LoadMenuHeader call VerticalMenu call ExitMenu pop hl ret c ld a, [wMenuCursorY] dec a call Pack_GetJumptablePointer jp hl ; 10601 (4:4601) .UsableMenuHeader: ; 0x10601 db MENU_BACKUP_TILES ; flags menu_coords 13, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .UsableMenuData db 1 ; default option ; 0x10609 .UsableMenuData: ; 0x10609 db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 2 ; items db "USE@" db "QUIT@" ; 0x10614 .UsableJumptable: ; 10614 dw .Use dw .Quit ; 10618 .UnusableMenuHeader: ; 0x10618 db MENU_BACKUP_TILES ; flags menu_coords 13, 9, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .UnusableMenuData db 1 ; default option ; 0x10620 .UnusableMenuData: ; 0x10620 db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 1 ; items db "QUIT@" ; 0x10627 .UnusableJumptable: ; 10627 dw .Quit ; 10629 .Use: ; 10629 farcall CheckItemContext ld a, [wItemAttributeParamBuffer] ld hl, .ItemFunctionJumptable rst JumpTable ret .ItemFunctionJumptable: ; 10637 (4:4637) ; entries correspond to ITEMMENU_* constants dw .Oak ; ITEMMENU_NOUSE dw .Oak dw .Oak dw .Oak dw .Unused ; ITEMMENU_CURRENT dw .BattleField ; ITEMMENU_PARTY dw .BattleOnly ; ITEMMENU_CLOSE .Oak: ; 10645 (4:4645) ld hl, Text_ThisIsntTheTime call Pack_PrintTextNoScroll ret .Unused: ; 1064c (4:464c) call DoItemEffect ld a, [wItemEffectSucceeded] and a jr nz, .ReturnToBattle ret .BattleField: ; 10656 (4:4656) call DoItemEffect ld a, [wItemEffectSucceeded] and a jr nz, .quit_run_script xor a ld [hBGMapMode], a call Pack_InitGFX call WaitBGMap_DrawPackGFX call Pack_InitColors ret .ReturnToBattle: ; 1066c (4:466c) call ClearBGPalettes jr .quit_run_script .BattleOnly: ; 10671 (4:4671) call DoItemEffect ld a, [wItemEffectSucceeded] and a jr z, .Oak cp $2 jr z, .didnt_use_item .quit_run_script ; 1067e (4:467e) ld a, PACKSTATE_QUITRUNSCRIPT ld [wJumptableIndex], a ret .didnt_use_item ; 10684 (4:4684) xor a ld [wItemEffectSucceeded], a ret ; 10689 (4:4689) .Quit: ; 10689 ret ; 1068a InitPackBuffers: ; 1068a xor a ld [wJumptableIndex], a ; pocket id -> jumptable index ld a, [wLastPocket] maskbits NUM_POCKETS ld [wCurrPocket], a inc a add a dec a ld [wPackJumptableIndex], a xor a ; FALSE ld [wPackUsedItem], a xor a ld [wSwitchItem], a ret ; 106a5 DepositSellInitPackBuffers: ; 106a5 xor a ld [hBGMapMode], a ld [wJumptableIndex], a ; PACKSTATE_INITGFX ld [wPackJumptableIndex], a ; PACKSTATE_INITGFX ld [wCurrPocket], a ; ITEM_POCKET ld [wPackUsedItem], a ld [wSwitchItem], a call Pack_InitGFX call Pack_InitColors ret ; 106be DepositSellPack: ; 106be .loop call .RunJumptable call DepositSellTutorial_InterpretJoypad jr c, .loop ret ; 106c7 .RunJumptable: ; 106c7 ld a, [wJumptableIndex] ld hl, .Jumptable call Pack_GetJumptablePointer jp hl ; 106d1 .Jumptable: ; 106d1 (4:46d1) ; entries correspond to *_POCKET constants dw .ItemsPocket dw .BallsPocket dw .KeyItemsPocket dw .TMHMPocket .ItemsPocket: ; 106d9 (4:46d9) xor a ; ITEM_POCKET call InitPocket ld hl, PC_Mart_ItemsPocketMenuHeader call CopyMenuHeader ld a, [wItemsPocketCursor] ld [wMenuCursorBuffer], a ld a, [wItemsPocketScrollPosition] ld [wMenuScrollPosition], a call ScrollingMenu ld a, [wMenuScrollPosition] ld [wItemsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wItemsPocketCursor], a ret .KeyItemsPocket: ; 106ff (4:46ff) ld a, KEY_ITEM_POCKET call InitPocket ld hl, PC_Mart_KeyItemsPocketMenuHeader call CopyMenuHeader ld a, [wKeyItemsPocketCursor] ld [wMenuCursorBuffer], a ld a, [wKeyItemsPocketScrollPosition] ld [wMenuScrollPosition], a call ScrollingMenu ld a, [wMenuScrollPosition] ld [wKeyItemsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wKeyItemsPocketCursor], a ret .TMHMPocket: ; 10726 (4:4726) ld a, TM_HM_POCKET call InitPocket call WaitBGMap_DrawPackGFX farcall TMHMPocket ld a, [CurItem] ld [CurItem], a ret .BallsPocket: ; 1073b (4:473b) ld a, BALL_POCKET call InitPocket ld hl, PC_Mart_BallsPocketMenuHeader call CopyMenuHeader ld a, [wBallsPocketCursor] ld [wMenuCursorBuffer], a ld a, [wBallsPocketScrollPosition] ld [wMenuScrollPosition], a call ScrollingMenu ld a, [wMenuScrollPosition] ld [wBallsPocketScrollPosition], a ld a, [wMenuCursorY] ld [wBallsPocketCursor], a ret InitPocket: ; 10762 (4:4762) ld [wCurrPocket], a call ClearPocketList call DrawPocketName call WaitBGMap_DrawPackGFX ret DepositSellTutorial_InterpretJoypad: ; 1076f ld hl, wMenuJoypad ld a, [hl] and A_BUTTON jr nz, .a_button ld a, [hl] and B_BUTTON jr nz, .b_button ld a, [hl] and D_LEFT jr nz, .d_left ld a, [hl] and D_RIGHT jr nz, .d_right scf ret .a_button ld a, TRUE ld [wPackUsedItem], a and a ret .b_button xor a ; FALSE ld [wPackUsedItem], a and a ret .d_left ld a, [wJumptableIndex] dec a maskbits NUM_POCKETS ld [wJumptableIndex], a push de ld de, SFX_SWITCH_POCKETS call PlaySFX pop de scf ret .d_right ld a, [wJumptableIndex] inc a maskbits NUM_POCKETS ld [wJumptableIndex], a push de ld de, SFX_SWITCH_POCKETS call PlaySFX pop de scf ret ; 107bb TutorialPack: ; 107bb call DepositSellInitPackBuffers ld a, [InputType] or a jr z, .loop farcall _DudeAutoInput_RightA .loop call .RunJumptable call DepositSellTutorial_InterpretJoypad jr c, .loop xor a ; FALSE ld [wPackUsedItem], a ret ; 107d7 .RunJumptable: ; 107d7 ld a, [wJumptableIndex] ld hl, .dw call Pack_GetJumptablePointer jp hl ; 107e1 .dw ; 107e1 (4:47e1) ; entries correspond to *_POCKET constants dw .Items dw .Balls dw .KeyItems dw .TMHM .Items: ; 107e9 (4:47e9) xor a ; ITEM_POCKET ld hl, .ItemsMenuHeader jr .DisplayPocket ; 107ef (4:47ef) .ItemsMenuHeader: ; 0x107ef db MENU_BACKUP_TILES ; flags menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .ItemsMenuData db 1 ; default option ; 0x107f7 .ItemsMenuData: ; 0x107f7 db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, wDudeNumItems dba PlaceMenuItemName dba PlaceMenuItemQuantity dba UpdateItemDescription ; 10807 .KeyItems: ; 10807 (4:4807) ld a, KEY_ITEM_POCKET ld hl, .KeyItemsMenuHeader jr .DisplayPocket ; 1080e (4:480e) .KeyItemsMenuHeader: ; 0x1080e db MENU_BACKUP_TILES ; flags menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .KeyItemsMenuData db 1 ; default option ; 0x10816 .KeyItemsMenuData: ; 0x10816 db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns db 1 ; horizontal spacing dbw 0, wDudeNumKeyItems dba PlaceMenuItemName dba PlaceMenuItemQuantity dba UpdateItemDescription ; 10826 .TMHM: ; 10826 (4:4826) ld a, TM_HM_POCKET call InitPocket call WaitBGMap_DrawPackGFX farcall TMHMPocket ld a, [CurItem] ld [CurItem], a ret .Balls: ; 1083b (4:483b) ld a, BALL_POCKET ld hl, .BallsMenuHeader jr .DisplayPocket ; 10842 (4:4842) .BallsMenuHeader: ; 0x10842 db MENU_BACKUP_TILES ; flags menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .BallsMenuData db 1 ; default option ; 0x1084a .BallsMenuData: ; 0x1084a db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, wDudeNumBalls dba PlaceMenuItemName dba PlaceMenuItemQuantity dba UpdateItemDescription ; 1085a .DisplayPocket: ; 1085a (4:485a) push hl call InitPocket pop hl call CopyMenuHeader call ScrollingMenu ret Pack_JumptableNext: ; 10866 (4:4866) ld hl, wJumptableIndex inc [hl] ret Pack_GetJumptablePointer: ; 1086b ld e, a ld d, 0 add hl, de add hl, de ld a, [hli] ld h, [hl] ld l, a ret ; 10874 Pack_QuitNoScript: ; 10874 (4:4874) ld hl, wJumptableIndex set 7, [hl] xor a ; FALSE ld [wPackUsedItem], a ret Pack_QuitRunScript: ; 1087e (4:487e) ld hl, wJumptableIndex set 7, [hl] ld a, TRUE ld [wPackUsedItem], a ret Pack_PrintTextNoScroll: ; 10889 (4:4889) ld a, [Options] push af set NO_TEXT_SCROLL, a ld [Options], a call PrintText pop af ld [Options], a ret WaitBGMap_DrawPackGFX: ; 1089a (4:489a) call WaitBGMap DrawPackGFX: ; 1089d ld a, [wCurrPocket] maskbits NUM_POCKETS ld e, a ld d, $0 ld a, [BattleType] cp BATTLETYPE_TUTORIAL jr z, .male_dude ld a, [wPlayerGender] bit PLAYERGENDER_FEMALE_F, a jr nz, .female .male_dude ld hl, PackGFXPointers add hl, de add hl, de ld a, [hli] ld e, a ld d, [hl] ld hl, vTiles2 tile $50 lb bc, BANK(PackGFX), 15 call Request2bpp ret .female farcall DrawKrisPackGFX ret ; 108cc PackGFXPointers: ; 108cc dw PackGFX + (15 tiles) * 1 ; ITEM_POCKET dw PackGFX + (15 tiles) * 3 ; BALL_POCKET dw PackGFX + (15 tiles) * 0 ; KEY_ITEM_POCKET dw PackGFX + (15 tiles) * 2 ; TM_HM_POCKET ; 108d4 Pack_InterpretJoypad: ; 108d4 (4:48d4) ld hl, wMenuJoypad ld a, [wSwitchItem] and a jr nz, .switching_item ld a, [hl] and A_BUTTON jr nz, .a_button ld a, [hl] and B_BUTTON jr nz, .b_button ld a, [hl] and D_LEFT jr nz, .d_left ld a, [hl] and D_RIGHT jr nz, .d_right ld a, [hl] and SELECT jr nz, .select scf ret .a_button and a ret .b_button ld a, PACKSTATE_QUITNOSCRIPT ld [wJumptableIndex], a scf ret .d_left ld a, b ld [wJumptableIndex], a ld [wPackJumptableIndex], a push de ld de, SFX_SWITCH_POCKETS call PlaySFX pop de scf ret .d_right ld a, c ld [wJumptableIndex], a ld [wPackJumptableIndex], a push de ld de, SFX_SWITCH_POCKETS call PlaySFX pop de scf ret .select farcall SwitchItemsInBag ld hl, Text_MoveItemWhere call Pack_PrintTextNoScroll scf ret .switching_item ld a, [hl] and A_BUTTON | SELECT jr nz, .place_insert ld a, [hl] and B_BUTTON jr nz, .end_switch scf ret .place_insert farcall SwitchItemsInBag ld de, SFX_SWITCH_POKEMON call WaitPlaySFX ld de, SFX_SWITCH_POKEMON call WaitPlaySFX .end_switch xor a ld [wSwitchItem], a scf ret Pack_InitGFX: ; 10955 call ClearBGPalettes call ClearTileMap call ClearSprites call DisableLCD ld hl, PackMenuGFX ld de, vTiles2 ld bc, $60 tiles ld a, BANK(PackMenuGFX) call FarCopyBytes ; Background (blue if male, pink if female) hlcoord 0, 1 ld bc, 11 * SCREEN_WIDTH ld a, $24 call ByteFill ; This is where the items themselves will be listed. hlcoord 5, 1 lb bc, 11, 15 call ClearBox ; ◀▶ POCKET ▼▲ ITEMS hlcoord 0, 0 ld a, $28 ld c, SCREEN_WIDTH .loop ld [hli], a inc a dec c jr nz, .loop call DrawPocketName call PlacePackGFX ; Place the textbox for displaying the item description hlcoord 0, SCREEN_HEIGHT - 4 - 2 lb bc, 4, SCREEN_WIDTH - 2 call TextBox call EnableLCD call DrawPackGFX ret ; 109a5 PlacePackGFX: ; 109a5 hlcoord 0, 3 ld a, $50 ld de, SCREEN_WIDTH - 5 ld b, 3 .row ld c, 5 .column ld [hli], a inc a dec c jr nz, .column add hl, de dec b jr nz, .row ret ; 109bb DrawPocketName: ; 109bb ld a, [wCurrPocket] ; * 15 ld d, a swap a sub d ld d, 0 ld e, a ld hl, .tilemap add hl, de ld d, h ld e, l hlcoord 0, 7 ld c, 3 .row ld b, 5 .col ld a, [de] inc de ld [hli], a dec b jr nz, .col ld a, c ld c, SCREEN_WIDTH - 5 add hl, bc ld c, a dec c jr nz, .row ret ; 109e1 .tilemap ; 109e1 ; ITEM_POCKET db $00, $04, $04, $04, $01 ; top border db $06, $07, $08, $09, $0a ; Items db $02, $05, $05, $05, $03 ; bottom border ; BALL_POCKET db $00, $04, $04, $04, $01 ; top border db $15, $16, $17, $18, $19 ; Balls db $02, $05, $05, $05, $03 ; bottom border ; KEY_ITEM_POCKET db $00, $04, $04, $04, $01 ; top border db $0b, $0c, $0d, $0e, $0f ; Key Items db $02, $05, $05, $05, $03 ; bottom border ; TM_HM_POCKET db $00, $04, $04, $04, $01 ; top border db $10, $11, $12, $13, $14 ; TM/HM db $02, $05, $05, $05, $03 ; bottom border ; 10a1d Pack_GetItemName: ; 10a1d ld a, [CurItem] ld [wNamedObjectIndexBuffer], a call GetItemName call CopyName1 ret ; 10a2a Unreferenced_Pack_ClearTilemap: ; 10a2a hlcoord 0, 0 ld bc, SCREEN_WIDTH * SCREEN_HEIGHT ld a, " " call ByteFill ret ; 10a36 ClearPocketList: ; 10a36 (4:4a36) hlcoord 5, 2 lb bc, 10, SCREEN_WIDTH - 5 call ClearBox ret Pack_InitColors: ; 10a40 call WaitBGMap ld b, SCGB_PACKPALS call GetSGBLayout call SetPalettes call DelayFrame ret ; 10a4f ItemsPocketMenuHeader: ; 0x10a4f db MENU_BACKUP_TILES ; flags menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData db 1 ; default option ; 0x10a57 .MenuData: ; 0x10a57 db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, NumItems dba PlaceMenuItemName dba PlaceMenuItemQuantity dba UpdateItemDescription ; 10a67 PC_Mart_ItemsPocketMenuHeader: ; 0x10a67 db MENU_BACKUP_TILES ; flags menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData db 1 ; default option ; 0x10a6f .MenuData: ; 0x10a6f db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, NumItems dba PlaceMenuItemName dba PlaceMenuItemQuantity dba UpdateItemDescription ; 10a7f KeyItemsPocketMenuHeader: ; 0x10a7f db MENU_BACKUP_TILES ; flags menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData db 1 ; default option ; 0x10a87 .MenuData: ; 0x10a87 db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns db 1 ; horizontal spacing dbw 0, NumKeyItems dba PlaceMenuItemName dba PlaceMenuItemQuantity dba UpdateItemDescription ; 10a97 PC_Mart_KeyItemsPocketMenuHeader: ; 0x10a97 db MENU_BACKUP_TILES ; flags menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData db 1 ; default option ; 0x10a9f .MenuData: ; 0x10a9f db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags db 5, 8 ; rows, columns db 1 ; horizontal spacing dbw 0, NumKeyItems dba PlaceMenuItemName dba PlaceMenuItemQuantity dba UpdateItemDescription ; 10aaf BallsPocketMenuHeader: ; 0x10aaf db MENU_BACKUP_TILES ; flags menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData db 1 ; default option ; 0x10ab7 .MenuData: ; 0x10ab7 db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, NumBalls dba PlaceMenuItemName dba PlaceMenuItemQuantity dba UpdateItemDescription ; 10ac7 PC_Mart_BallsPocketMenuHeader: ; 0x10ac7 db MENU_BACKUP_TILES ; flags menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData db 1 ; default option ; 0x10acf .MenuData: ; 0x10acf db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, NumBalls dba PlaceMenuItemName dba PlaceMenuItemQuantity dba UpdateItemDescription ; 10adf Text_PackNoItems: ; 0x10adf ; No items. text_jump UnknownText_0x1c0b9a db "@" ; 0x10ae4 Text_ThrowAwayHowMany: ; 0x10ae4 ; Throw away how many? text_jump UnknownText_0x1c0ba5 db "@" ; 0x10ae9 Text_ConfirmThrowAway: ; 0x10ae9 ; Throw away @ @ (S)? text_jump UnknownText_0x1c0bbb db "@" ; 0x10aee Text_ThrewAway: ; 0x10aee ; Threw away @ (S). text_jump UnknownText_0x1c0bd8 db "@" ; 0x10af3 Text_ThisIsntTheTime: ; 0x10af3 ; OAK: ! This isn't the time to use that! text_jump UnknownText_0x1c0bee db "@" ; 0x10af8 TextJump_YouDontHaveAPkmn: ; 0x10af8 ; You don't have a #MON! text_jump Text_YouDontHaveAPkmn db "@" ; 0x10afd Text_RegisteredItem: ; 0x10afd ; Registered the @ . text_jump UnknownText_0x1c0c2e db "@" ; 0x10b02 Text_CantRegister: ; 0x10b02 ; You can't register that item. text_jump UnknownText_0x1c0c45 db "@" ; 0x10b07 Text_MoveItemWhere: ; 0x10b07 ; Where should this be moved to? text_jump UnknownText_0x1c0c63 db "@" ; 0x10b0c Text_PackEmptyString: ; 0x10b0c ; text_jump UnknownText_0x1c0c83 db "@" ; 0x10b11 TextJump_YouCantUseItInABattle: ; 0x10b11 ; Doesn't seem to be used anywhere ; "You can't use it in a battle." text_jump Text_YouCantUseItInABattle db "@" ; 0x10b16 PackMenuGFX: INCBIN "gfx/pack/pack_menu.2bpp" PackGFX: INCBIN "gfx/pack/pack.2bpp"