pokecrystal-board/engine/pokemon/bills_pc.asm

2619 lines
42 KiB
NASM
Raw Normal View History

2015-11-11 20:38:57 -08:00
_DepositPKMN: ; e2391 (38:6391)
2018-01-23 14:39:09 -08:00
ld hl, wOptions
2015-11-11 20:38:57 -08:00
ld a, [hl]
push af
2018-04-05 08:44:02 -07:00
set NO_TEXT_SCROLL, [hl]
2018-01-23 14:39:09 -08:00
ld a, [wVramState]
2015-11-11 20:38:57 -08:00
push af
xor a
2018-01-23 14:39:09 -08:00
ld [wVramState], a
2015-11-11 20:38:57 -08:00
ld a, [hInMenu]
push af
ld a, $1
ld [hInMenu], a
xor a
ld [hMapAnims], a
2015-12-16 09:32:08 -08:00
call BillsPC_InitRAM
2015-11-11 20:38:57 -08:00
xor a
2015-12-16 09:32:08 -08:00
ld [wBillsPC_LoadedBox], a
2015-11-11 20:38:57 -08:00
call DelayFrame
2015-12-16 09:32:08 -08:00
.loop
2015-11-11 20:38:57 -08:00
call JoyTextDelay
ld a, [wJumptableIndex]
bit 7, a
2015-12-16 09:32:08 -08:00
jr nz, .done
call .RunJumptable
2015-11-11 20:38:57 -08:00
call DelayFrame
2015-12-16 09:32:08 -08:00
jr .loop
.done
2015-11-11 20:38:57 -08:00
call ClearSprites
pop af
ld [hInMenu], a
pop af
2018-01-23 14:39:09 -08:00
ld [wVramState], a
2015-11-11 20:38:57 -08:00
pop af
2018-01-23 14:39:09 -08:00
ld [wOptions], a
2015-11-11 20:38:57 -08:00
ret
2015-12-16 09:32:08 -08:00
.RunJumptable: ; e23d5 (38:63d5)
2015-11-11 20:38:57 -08:00
ld a, [wJumptableIndex]
2015-12-16 09:32:08 -08:00
ld hl, .Jumptable
call BillsPC_Jumptable
jp hl
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
.Jumptable: ; e23df (38:63df)
2015-12-26 18:59:03 -08:00
dw .Init
dw .HandleJoypad
dw .WhatsUp
dw .Submenu
dw BillsPC_EndJumptableLoop
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
.Init: ; e23e9 (38:63e9)
2015-11-11 20:38:57 -08:00
xor a
ld [hBGMapMode], a
call ClearSprites
2015-12-16 09:32:08 -08:00
call CopyBoxmonSpecies
call BillsPC_BoxName
2015-11-11 20:38:57 -08:00
ld de, PCString_ChooseaPKMN
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
ld a, $5
2015-12-16 09:32:08 -08:00
ld [wBillsPC_NumMonsOnScreen], a
call BillsPC_RefreshTextboxes
2015-11-11 20:38:57 -08:00
call PCMonInfo
ld a, $ff
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-06-06 15:23:00 -07:00
ld a, SCGB_BILLS_PC
2015-12-16 09:32:08 -08:00
call BillsPC_ApplyPalettes
2015-11-11 20:38:57 -08:00
call WaitBGMap
2015-12-16 09:32:08 -08:00
call BillsPC_UpdateSelectionCursor
call BillsPC_IncrementJumptableIndex
2015-11-11 20:38:57 -08:00
ret
2015-12-16 09:32:08 -08:00
.HandleJoypad: ; e241a (38:641a)
2015-11-11 20:38:57 -08:00
ld hl, hJoyPressed ; $ffa7
ld a, [hl]
and B_BUTTON
2015-12-16 09:32:08 -08:00
jr nz, .b_button
2015-11-11 20:38:57 -08:00
ld a, [hl]
and A_BUTTON
2015-12-16 09:32:08 -08:00
jr nz, .a_button
call Withdraw_UpDown
2015-11-11 20:38:57 -08:00
and a
ret z
2015-12-16 09:32:08 -08:00
call BillsPC_UpdateSelectionCursor
2015-11-11 20:38:57 -08:00
xor a
ld [hBGMapMode], a
2015-12-16 09:32:08 -08:00
call BillsPC_RefreshTextboxes
2015-11-11 20:38:57 -08:00
call PCMonInfo
ld a, $1
ld [hBGMapMode], a
call DelayFrame
call DelayFrame
ret
2015-12-16 09:32:08 -08:00
.a_button
call BillsPC_GetSelectedPokemonSpecies
2015-11-11 20:38:57 -08:00
and a
ret z
2015-12-16 09:32:08 -08:00
cp -1
jr z, .b_button
2015-11-11 20:38:57 -08:00
ld a, $2
ld [wJumptableIndex], a
ret
; e2452 (38:6452)
2015-12-16 09:32:08 -08:00
.go_back
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
dec [hl]
ret
2015-12-16 09:32:08 -08:00
.b_button
2015-11-11 20:38:57 -08:00
ld a, $4
ld [wJumptableIndex], a
ret
2015-12-16 09:32:08 -08:00
.WhatsUp: ; e245d (38:645d)
2015-11-11 20:38:57 -08:00
xor a
ld [hBGMapMode], a
call ClearSprites
2015-12-16 09:32:08 -08:00
call BillsPC_GetSelectedPokemonSpecies
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-06-06 15:23:00 -07:00
ld a, SCGB_BILLS_PC
2015-12-16 09:32:08 -08:00
call BillsPC_ApplyPalettes
2015-11-11 20:38:57 -08:00
ld de, PCString_WhatsUp
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
ld a, $1
2015-12-15 15:59:49 -08:00
ld [wMenuCursorY], a
2015-12-16 09:32:08 -08:00
call BillsPC_IncrementJumptableIndex
2015-11-11 20:38:57 -08:00
ret
2015-12-16 09:32:08 -08:00
.Submenu: ; e247d (38:647d)
ld hl, BillsPCDepositMenuHeader
call CopyMenuHeader
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-12-16 09:32:08 -08:00
call StoreTo_wMenuCursorBuffer
2015-12-15 15:59:49 -08:00
call VerticalMenu
2015-11-11 20:38:57 -08:00
jp c, BillsPCDepositFuncCancel
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-11-11 20:38:57 -08:00
dec a
2018-01-11 09:00:01 -08:00
and %11
2015-11-11 20:38:57 -08:00
ld e, a
ld d, 0
ld hl, BillsPCDepositJumptable
add hl, de
add hl, de
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-11-11 20:38:57 -08:00
BillsPCDepositJumptable: ; e24a1 (38:64a1)
2015-12-26 18:59:03 -08:00
dw BillsPCDepositFuncDeposit ; Deposit Pokemon
dw BillsPCDepositFuncStats ; Pokemon Stats
dw BillsPCDepositFuncRelease ; Release Pokemon
dw BillsPCDepositFuncCancel ; Cancel
2015-11-11 20:38:57 -08:00
BillsPCDepositFuncDeposit: ; e24a9 (38:64a9)
2015-12-16 09:32:08 -08:00
call BillsPC_CheckMail_PreventBlackout
2015-11-11 20:38:57 -08:00
jp c, BillsPCDepositFuncCancel
2015-12-16 09:32:08 -08:00
call DepositPokemon
jr c, .box_full
2015-11-11 20:38:57 -08:00
ld a, $0
ld [wJumptableIndex], a
xor a
2015-12-16 09:32:08 -08:00
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
2015-11-11 20:38:57 -08:00
ret
2015-12-16 09:32:08 -08:00
.box_full
2015-11-11 20:38:57 -08:00
ld de, PCString_WhatsUp
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
ret
BillsPCDepositFuncStats: ; e24c8 (38:64c8)
call LoadStandardMenuHeader
2015-12-16 09:32:08 -08:00
call BillsPC_StatsScreen
2015-11-11 20:38:57 -08:00
call ExitMenu
call PCMonInfo
2015-12-16 09:32:08 -08:00
call BillsPC_GetSelectedPokemonSpecies
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-06-06 15:23:00 -07:00
ld a, SCGB_BILLS_PC
2015-12-16 09:32:08 -08:00
call BillsPC_ApplyPalettes
2015-11-11 20:38:57 -08:00
ret
BillsPCDepositFuncRelease: ; e24e0 (38:64e0)
2015-12-16 09:32:08 -08:00
call BillsPC_CheckMail_PreventBlackout
2015-11-11 20:38:57 -08:00
jr c, BillsPCDepositFuncCancel
2015-12-16 09:32:08 -08:00
call BillsPC_IsMonAnEgg
2015-11-11 20:38:57 -08:00
jr c, BillsPCDepositFuncCancel
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-11-11 20:38:57 -08:00
push af
ld de, PCString_ReleasePKMN
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
call LoadStandardMenuHeader
2015-11-11 20:38:57 -08:00
lb bc, 14, 11
call PlaceYesNoBox
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-11-11 20:38:57 -08:00
dec a
call ExitMenu
and a
2015-12-16 09:32:08 -08:00
jr nz, .failed_release
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
2018-01-23 14:39:09 -08:00
ld [wCurPartyMon], a
xor a ; REMOVE_PARTY
2015-11-11 20:38:57 -08:00
ld [wPokemonWithdrawDepositParameter], a
2017-12-24 09:47:30 -08:00
farcall RemoveMonFromPartyOrBox
2015-12-16 09:32:08 -08:00
call ReleasePKMN_ByePKMN
2015-11-11 20:38:57 -08:00
ld a, $0
ld [wJumptableIndex], a
xor a
2015-12-16 09:32:08 -08:00
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
2015-11-11 20:38:57 -08:00
pop af
ret
2015-12-16 09:32:08 -08:00
.failed_release
2015-11-11 20:38:57 -08:00
ld de, PCString_WhatsUp
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
pop af
2015-12-15 15:59:49 -08:00
ld [wMenuCursorY], a
2015-11-11 20:38:57 -08:00
ret
BillsPCDepositFuncCancel: ; e2537 (38:6537)
ld a, $0
ld [wJumptableIndex], a
ret
; e253d (38:653d)
BillsPCDepositMenuHeader: ; 0xe253d (38:653d)
db MENU_BACKUP_TILES ; flags
menu_coords 9, 4, SCREEN_WIDTH - 1, 13
dw .MenuData
2015-11-11 20:38:57 -08:00
db 1 ; default option
; 0xe2545
.MenuData: ; 0xe2545 (38:6545)
db STATICMENU_CURSOR ; flags
2015-11-11 20:38:57 -08:00
db 4 ; items
db "DEPOSIT@"
db "STATS@"
db "RELEASE@"
db "CANCEL@"
; 0xe2564 (38:6564)
2018-01-02 07:04:21 -08:00
Unreferenced_BillsPCClearThreeBoxes: ; e2564
2015-11-11 20:38:57 -08:00
hlcoord 0, 0
2015-12-16 09:32:08 -08:00
ld b, 4
ld c, 8
2015-11-11 20:38:57 -08:00
call ClearBox
hlcoord 0, 4
2015-12-16 09:32:08 -08:00
ld b, 10
ld c, 9
2015-11-11 20:38:57 -08:00
call ClearBox
hlcoord 0, 14
2015-12-16 09:32:08 -08:00
ld b, 2
ld c, 8
2015-11-11 20:38:57 -08:00
call ClearBox
ret
; e2583
_WithdrawPKMN: ; e2583 (38:6583)
2018-01-23 14:39:09 -08:00
ld hl, wOptions
2015-11-11 20:38:57 -08:00
ld a, [hl]
push af
2018-04-05 08:44:02 -07:00
set NO_TEXT_SCROLL, [hl]
2018-01-23 14:39:09 -08:00
ld a, [wVramState]
2015-11-11 20:38:57 -08:00
push af
xor a
2018-01-23 14:39:09 -08:00
ld [wVramState], a
2015-11-11 20:38:57 -08:00
ld a, [hInMenu]
push af
ld a, $1
ld [hInMenu], a
xor a
ld [hMapAnims], a
2015-12-16 09:32:08 -08:00
call BillsPC_InitRAM
ld a, NUM_BOXES + 1
ld [wBillsPC_LoadedBox], a
2015-11-11 20:38:57 -08:00
call DelayFrame
2015-12-16 09:32:08 -08:00
.loop
2015-11-11 20:38:57 -08:00
call JoyTextDelay
ld a, [wJumptableIndex]
bit 7, a
2015-12-16 09:32:08 -08:00
jr nz, .done
call .RunJumptable
2015-11-11 20:38:57 -08:00
call DelayFrame
2015-12-16 09:32:08 -08:00
jr .loop
.done
2015-11-11 20:38:57 -08:00
call ClearSprites
pop af
ld [hInMenu], a
pop af
2018-01-23 14:39:09 -08:00
ld [wVramState], a
2015-11-11 20:38:57 -08:00
pop af
2018-01-23 14:39:09 -08:00
ld [wOptions], a
2015-11-11 20:38:57 -08:00
ret
2015-12-16 09:32:08 -08:00
.RunJumptable: ; e25c8 (38:65c8)
2015-11-11 20:38:57 -08:00
ld a, [wJumptableIndex]
2015-12-16 09:32:08 -08:00
ld hl, .Jumptable
call BillsPC_Jumptable
jp hl
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
.Jumptable: ; e25d2 (38:65d2)
2015-12-26 18:59:03 -08:00
dw .Init
dw .Joypad
dw .PrepSubmenu
dw BillsPC_Withdraw
dw BillsPC_EndJumptableLoop
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
.Init: ; e25dc (38:65dc)
ld a, NUM_BOXES + 1
ld [wBillsPC_LoadedBox], a
2015-11-11 20:38:57 -08:00
xor a
ld [hBGMapMode], a
call ClearSprites
2015-12-16 09:32:08 -08:00
call CopyBoxmonSpecies
call BillsPC_BoxName
2015-11-11 20:38:57 -08:00
ld de, PCString_ChooseaPKMN
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
ld a, $5
2015-12-16 09:32:08 -08:00
ld [wBillsPC_NumMonsOnScreen], a
call BillsPC_RefreshTextboxes
2015-11-11 20:38:57 -08:00
call PCMonInfo
ld a, $ff
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-06-06 15:23:00 -07:00
ld a, SCGB_BILLS_PC
2015-12-16 09:32:08 -08:00
call BillsPC_ApplyPalettes
2015-11-11 20:38:57 -08:00
call WaitBGMap
2015-12-16 09:32:08 -08:00
call BillsPC_UpdateSelectionCursor
call BillsPC_IncrementJumptableIndex
2015-11-11 20:38:57 -08:00
ret
2015-12-16 09:32:08 -08:00
.Joypad: ; e2612 (38:6612)
2015-11-11 20:38:57 -08:00
ld hl, hJoyPressed ; $ffa7
ld a, [hl]
and B_BUTTON
2015-12-16 09:32:08 -08:00
jr nz, .b_button
2015-11-11 20:38:57 -08:00
ld a, [hl]
and A_BUTTON
2015-12-16 09:32:08 -08:00
jr nz, .a_button
call Withdraw_UpDown
2015-11-11 20:38:57 -08:00
and a
ret z
2015-12-16 09:32:08 -08:00
call BillsPC_UpdateSelectionCursor
2015-11-11 20:38:57 -08:00
xor a
ld [hBGMapMode], a
2015-12-16 09:32:08 -08:00
call BillsPC_RefreshTextboxes
2015-11-11 20:38:57 -08:00
call PCMonInfo
ld a, $1
ld [hBGMapMode], a
call DelayFrame
call DelayFrame
ret
2015-12-16 09:32:08 -08:00
.a_button
call BillsPC_GetSelectedPokemonSpecies
2015-11-11 20:38:57 -08:00
and a
ret z
2015-12-16 09:32:08 -08:00
cp -1
jr z, .b_button
2015-11-11 20:38:57 -08:00
ld a, $2
ld [wJumptableIndex], a
2015-12-16 09:32:08 -08:00
ret ; e264a (38:664a)
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
.unused
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
dec [hl]
ret
2015-12-16 09:32:08 -08:00
.b_button
2015-11-11 20:38:57 -08:00
ld a, $4
ld [wJumptableIndex], a
ret
; e2655
2015-12-16 09:32:08 -08:00
.PrepSubmenu: ; e2655 (38:6655)
2015-11-11 20:38:57 -08:00
xor a
ld [hBGMapMode], a
call ClearSprites
2015-12-16 09:32:08 -08:00
call BillsPC_GetSelectedPokemonSpecies
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-06-06 15:23:00 -07:00
ld a, SCGB_BILLS_PC
2015-12-16 09:32:08 -08:00
call BillsPC_ApplyPalettes
2015-11-11 20:38:57 -08:00
ld de, PCString_WhatsUp
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
ld a, $1
2015-12-15 15:59:49 -08:00
ld [wMenuCursorY], a
2015-12-16 09:32:08 -08:00
call BillsPC_IncrementJumptableIndex
2015-11-11 20:38:57 -08:00
ret
BillsPC_Withdraw: ; e2675 (38:6675)
ld hl, .MenuHeader
call CopyMenuHeader
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-12-16 09:32:08 -08:00
call StoreTo_wMenuCursorBuffer
2015-12-15 15:59:49 -08:00
call VerticalMenu
2015-11-11 20:38:57 -08:00
jp c, .cancel
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-11-11 20:38:57 -08:00
dec a
2018-01-11 09:00:01 -08:00
and %11
2015-11-11 20:38:57 -08:00
ld e, a
ld d, 0
2015-12-26 18:59:03 -08:00
ld hl, .dw
2015-11-11 20:38:57 -08:00
add hl, de
add hl, de
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-11-11 20:38:57 -08:00
.dw ; e2699 (38:6699) #mark
2015-11-11 20:38:57 -08:00
dw .withdraw ; Withdraw
dw .stats ; Stats
dw .release ; Release
dw .cancel ; Cancel
.withdraw ; e26a1 (38:66a1)
2015-12-16 09:32:08 -08:00
call BillsPC_CheckMail_PreventBlackout
2015-11-11 20:38:57 -08:00
jp c, .cancel
call TryWithdrawPokemon
jr c, .FailedWithdraw
ld a, $0
ld [wJumptableIndex], a
xor a
2015-12-16 09:32:08 -08:00
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
2015-11-11 20:38:57 -08:00
ret
.FailedWithdraw:
2015-11-11 20:38:57 -08:00
ld de, PCString_WhatsUp
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
ret
.stats ; e26c0 (38:66c0)
call LoadStandardMenuHeader
2015-12-16 09:32:08 -08:00
call BillsPC_StatsScreen
2015-11-11 20:38:57 -08:00
call ExitMenu
call PCMonInfo
2015-12-16 09:32:08 -08:00
call BillsPC_GetSelectedPokemonSpecies
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-06-06 15:23:00 -07:00
ld a, SCGB_BILLS_PC
2015-12-16 09:32:08 -08:00
call BillsPC_ApplyPalettes
2015-11-11 20:38:57 -08:00
ret
.release ; e26d8 (38:66d8)
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-11-11 20:38:57 -08:00
push af
2015-12-16 09:32:08 -08:00
call BillsPC_IsMonAnEgg
2015-11-11 20:38:57 -08:00
jr c, .FailedRelease
ld de, PCString_ReleasePKMN
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
call LoadStandardMenuHeader
2015-11-11 20:38:57 -08:00
lb bc, 14, 11
call PlaceYesNoBox
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-11-11 20:38:57 -08:00
dec a
call ExitMenu
and a
jr nz, .FailedRelease
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
2018-01-23 14:39:09 -08:00
ld [wCurPartyMon], a
ld a, REMOVE_BOX
2015-11-11 20:38:57 -08:00
ld [wPokemonWithdrawDepositParameter], a
2017-12-24 09:47:30 -08:00
farcall RemoveMonFromPartyOrBox
2015-12-16 09:32:08 -08:00
call ReleasePKMN_ByePKMN
2015-11-11 20:38:57 -08:00
ld a, $0
ld [wJumptableIndex], a
xor a
2015-12-16 09:32:08 -08:00
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
2015-11-11 20:38:57 -08:00
pop af
ret
.FailedRelease:
2015-11-11 20:38:57 -08:00
ld de, PCString_WhatsUp
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
pop af
2015-12-15 15:59:49 -08:00
ld [wMenuCursorY], a
2015-11-11 20:38:57 -08:00
ret
.cancel ; e272b (38:672b)
2015-11-11 20:38:57 -08:00
ld a, $0
ld [wJumptableIndex], a
ret
; e2731 (38:6731)
.MenuHeader: ; 0xe2731
db MENU_BACKUP_TILES ; flags
menu_coords 9, 4, SCREEN_WIDTH - 1, 13
2015-11-11 20:38:57 -08:00
dw .MenuData
db 1 ; default option
; 0xe2739
.MenuData: ; 0xe2739
db STATICMENU_CURSOR ; flags
2015-11-11 20:38:57 -08:00
db 4 ; items
db "WITHDRAW@"
db "STATS@"
db "RELEASE@"
db "CANCEL@"
; 0xe2759
_MovePKMNWithoutMail: ; e2759
2018-01-23 14:39:09 -08:00
ld hl, wOptions
2015-11-11 20:38:57 -08:00
ld a, [hl]
push af
2018-04-05 08:44:02 -07:00
set NO_TEXT_SCROLL, [hl]
2018-01-23 14:39:09 -08:00
ld a, [wVramState]
2015-11-11 20:38:57 -08:00
push af
xor a
2018-01-23 14:39:09 -08:00
ld [wVramState], a
2015-11-11 20:38:57 -08:00
ld a, [hInMenu]
push af
ld a, $1
ld [hInMenu], a
xor a
ld [hMapAnims], a
2015-12-16 09:32:08 -08:00
call BillsPC_InitRAM
2015-11-11 20:38:57 -08:00
ld a, [wCurBox]
and $f
inc a
2015-12-16 09:32:08 -08:00
ld [wBillsPC_LoadedBox], a
2015-11-11 20:38:57 -08:00
call DelayFrame
.asm_e2781
call JoyTextDelay
ld a, [wJumptableIndex]
bit 7, a
jr nz, .asm_e2793
2015-12-16 09:32:08 -08:00
call .RunJumptable
2015-11-11 20:38:57 -08:00
call DelayFrame
jr .asm_e2781
.asm_e2793
call ClearSprites
pop af
ld [hInMenu], a
pop af
2018-01-23 14:39:09 -08:00
ld [wVramState], a
2015-11-11 20:38:57 -08:00
pop af
2018-01-23 14:39:09 -08:00
ld [wOptions], a
2015-11-11 20:38:57 -08:00
ret
; e27a2
2015-12-16 09:32:08 -08:00
.RunJumptable: ; e27a2
2015-11-11 20:38:57 -08:00
ld a, [wJumptableIndex]
2015-12-16 09:32:08 -08:00
ld hl, .Jumptable
call BillsPC_Jumptable
jp hl
2015-11-11 20:38:57 -08:00
; e27ac
2015-12-16 09:32:08 -08:00
.Jumptable: ; e27ac
2015-12-26 18:59:03 -08:00
dw .Init
dw .Joypad
dw .PrepSubmenu
dw .MoveMonWOMailSubmenu
dw .PrepInsertCursor
dw .Joypad2
dw BillsPC_EndJumptableLoop
2015-11-11 20:38:57 -08:00
; e27ba
2015-12-16 09:32:08 -08:00
.Init: ; e27ba
2015-11-11 20:38:57 -08:00
xor a
ld [hBGMapMode], a
call ClearSprites
2015-12-16 09:32:08 -08:00
call CopyBoxmonSpecies
2015-11-11 20:38:57 -08:00
ld de, PCString_ChooseaPKMN
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
ld a, 5
ld [wBillsPC_NumMonsOnScreen], a
call BillsPC_RefreshTextboxes
call BillsPC_MoveMonWOMail_BoxNameAndArrows
2015-11-11 20:38:57 -08:00
call PCMonInfo
ld a, $ff
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-06-06 15:23:00 -07:00
ld a, SCGB_BILLS_PC
2015-12-16 09:32:08 -08:00
call BillsPC_ApplyPalettes
2015-11-11 20:38:57 -08:00
call WaitBGMap
2015-12-16 09:32:08 -08:00
call BillsPC_UpdateSelectionCursor
call BillsPC_IncrementJumptableIndex
2015-11-11 20:38:57 -08:00
ret
; e27eb
2015-12-16 09:32:08 -08:00
.Joypad: ; e27eb
2015-11-11 20:38:57 -08:00
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
2015-12-16 09:32:08 -08:00
jr nz, .b_button
2015-11-11 20:38:57 -08:00
ld a, [hl]
and A_BUTTON
2015-12-16 09:32:08 -08:00
jr nz, .a_button
call MoveMonWithoutMail_DPad
2015-12-16 09:32:08 -08:00
jr c, .d_pad
2015-11-11 20:38:57 -08:00
and a
ret z
2015-12-16 09:32:08 -08:00
call BillsPC_UpdateSelectionCursor
2015-11-11 20:38:57 -08:00
xor a
ld [hBGMapMode], a
2015-12-16 09:32:08 -08:00
call BillsPC_RefreshTextboxes
2015-11-11 20:38:57 -08:00
call PCMonInfo
ld a, $1
ld [hBGMapMode], a
call DelayFrame
call DelayFrame
ret
2015-12-16 09:32:08 -08:00
.d_pad
2015-11-11 20:38:57 -08:00
xor a
2015-12-16 09:32:08 -08:00
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
2015-11-11 20:38:57 -08:00
ld a, $0
ld [wJumptableIndex], a
ret
2015-12-16 09:32:08 -08:00
.a_button
call BillsPC_GetSelectedPokemonSpecies
2015-11-11 20:38:57 -08:00
and a
ret z
2015-12-16 09:32:08 -08:00
cp -1
jr z, .b_button
2015-11-11 20:38:57 -08:00
ld a, $2
ld [wJumptableIndex], a
ret
2015-12-16 09:32:08 -08:00
.unused
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
dec [hl]
ret
2015-12-16 09:32:08 -08:00
.b_button
2015-11-11 20:38:57 -08:00
ld a, $6
ld [wJumptableIndex], a
ret
; e283d
2015-12-16 09:32:08 -08:00
.PrepSubmenu: ; e283d
2015-11-11 20:38:57 -08:00
xor a
ld [hBGMapMode], a
call ClearSprites
2015-12-16 09:32:08 -08:00
call BillsPC_GetSelectedPokemonSpecies
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-06-06 15:23:00 -07:00
ld a, SCGB_BILLS_PC
2015-12-16 09:32:08 -08:00
call BillsPC_ApplyPalettes
2015-11-11 20:38:57 -08:00
ld de, PCString_WhatsUp
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
ld a, $1
2015-12-15 15:59:49 -08:00
ld [wMenuCursorY], a
2015-12-16 09:32:08 -08:00
call BillsPC_IncrementJumptableIndex
2015-11-11 20:38:57 -08:00
ret
; e285d
2015-12-16 09:32:08 -08:00
.MoveMonWOMailSubmenu: ; e285d
ld hl, .MenuHeader
call CopyMenuHeader
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-12-16 09:32:08 -08:00
call StoreTo_wMenuCursorBuffer
2015-12-15 15:59:49 -08:00
call VerticalMenu
2015-12-16 09:32:08 -08:00
jp c, .Cancel
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-11-11 20:38:57 -08:00
dec a
2018-01-11 09:00:01 -08:00
and %11
2015-11-11 20:38:57 -08:00
ld e, a
ld d, 0
2015-12-16 09:32:08 -08:00
ld hl, .Jumptable2
2015-11-11 20:38:57 -08:00
add hl, de
add hl, de
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-11-11 20:38:57 -08:00
; e2881
2015-12-16 09:32:08 -08:00
.Jumptable2: ; e2881
dw .Move
dw .Stats
dw .Cancel
2015-11-11 20:38:57 -08:00
; e2887
2015-12-16 09:32:08 -08:00
.Move: ; e2887
call BillsPC_CheckMail_PreventBlackout
jp c, .Cancel
ld a, [wBillsPC_ScrollPosition]
ld [wBillsPC_BackupScrollPosition], a
ld a, [wBillsPC_CursorPosition]
ld [wBillsPC_BackupCursorPosition], a
ld a, [wBillsPC_LoadedBox]
ld [wBillsPC_BackupLoadedBox], a
2015-11-11 20:38:57 -08:00
ld a, $4
ld [wJumptableIndex], a
ret
; e28a5
2015-12-16 09:32:08 -08:00
.Stats: ; e28a5
call LoadStandardMenuHeader
2015-12-16 09:32:08 -08:00
call BillsPC_StatsScreen
2015-11-11 20:38:57 -08:00
call ExitMenu
call PCMonInfo
2015-12-16 09:32:08 -08:00
call BillsPC_GetSelectedPokemonSpecies
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-06-06 15:23:00 -07:00
ld a, SCGB_BILLS_PC
2015-12-16 09:32:08 -08:00
call BillsPC_ApplyPalettes
2015-11-11 20:38:57 -08:00
ret
; e28bd
2015-12-16 09:32:08 -08:00
.Cancel: ; e28bd
2015-11-11 20:38:57 -08:00
ld a, $0
ld [wJumptableIndex], a
ret
; e28c3
.MenuHeader: ; 0xe28c3
db MENU_BACKUP_TILES ; flags
menu_coords 9, 4, SCREEN_WIDTH - 1, 13
dw .MenuData
2015-11-11 20:38:57 -08:00
db 1 ; default option
; 0xe28cb
.MenuData: ; 0xe28cb
db STATICMENU_CURSOR ; flags
2015-11-11 20:38:57 -08:00
db 3 ; items
db "MOVE@"
db "STATS@"
db "CANCEL@"
; 0xe28df
2015-12-16 09:32:08 -08:00
.PrepInsertCursor: ; e28df
2015-11-11 20:38:57 -08:00
xor a
ld [hBGMapMode], a
2015-12-16 09:32:08 -08:00
call CopyBoxmonSpecies
2015-11-11 20:38:57 -08:00
ld de, PCString_MoveToWhere
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
ld a, $5
2015-12-16 09:32:08 -08:00
ld [wBillsPC_NumMonsOnScreen], a
call BillsPC_RefreshTextboxes
call BillsPC_MoveMonWOMail_BoxNameAndArrows
2015-11-11 20:38:57 -08:00
call ClearSprites
2015-12-16 09:32:08 -08:00
call BillsPC_UpdateInsertCursor
2015-11-11 20:38:57 -08:00
call WaitBGMap
2015-12-16 09:32:08 -08:00
call BillsPC_IncrementJumptableIndex
2015-11-11 20:38:57 -08:00
ret
; e2903
2015-12-16 09:32:08 -08:00
.Joypad2: ; e2903
2015-11-11 20:38:57 -08:00
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
2015-12-16 09:32:08 -08:00
jr nz, .b_button_2
2015-11-11 20:38:57 -08:00
ld a, [hl]
and A_BUTTON
2015-12-16 09:32:08 -08:00
jr nz, .a_button_2
call MoveMonWithoutMail_DPad_2
2015-12-16 09:32:08 -08:00
jr c, .dpad_2
2015-11-11 20:38:57 -08:00
and a
ret z
2015-12-16 09:32:08 -08:00
call BillsPC_UpdateInsertCursor
2015-11-11 20:38:57 -08:00
xor a
ld [hBGMapMode], a
2015-12-16 09:32:08 -08:00
call BillsPC_RefreshTextboxes
2015-11-11 20:38:57 -08:00
ld a, $1
ld [hBGMapMode], a
call DelayFrame
call DelayFrame
ret
2015-12-16 09:32:08 -08:00
.dpad_2
2015-11-11 20:38:57 -08:00
xor a
2015-12-16 09:32:08 -08:00
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
2015-11-11 20:38:57 -08:00
ld a, $4
ld [wJumptableIndex], a
ret
2015-12-16 09:32:08 -08:00
.a_button_2
call BillsPC_CheckSpaceInDestination
jr c, .no_space
call MovePKMNWitoutMail_InsertMon
2015-11-11 20:38:57 -08:00
ld a, $0
ld [wJumptableIndex], a
ret
2015-12-16 09:32:08 -08:00
.no_space
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
dec [hl]
ret
2015-12-16 09:32:08 -08:00
.b_button_2
ld a, [wBillsPC_BackupScrollPosition]
ld [wBillsPC_ScrollPosition], a
ld a, [wBillsPC_BackupCursorPosition]
ld [wBillsPC_CursorPosition], a
ld a, [wBillsPC_BackupLoadedBox]
ld [wBillsPC_LoadedBox], a
2015-11-11 20:38:57 -08:00
ld a, $0
ld [wJumptableIndex], a
ret
; e2963
2015-12-16 09:32:08 -08:00
BillsPC_InitRAM: ; e2963 (38:6963)
2015-11-11 20:38:57 -08:00
call ClearBGPalettes
call ClearSprites
call ClearTileMap
2015-12-16 09:32:08 -08:00
call BillsPC_InitGFX
ld hl, wBillsPCPokemonList
2015-11-11 20:38:57 -08:00
ld bc, $338
xor a
call ByteFill
xor a
ld [wJumptableIndex], a
ld [wcf64], a
ld [wcf65], a
ld [wcf66], a
2015-12-16 09:32:08 -08:00
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
2015-11-11 20:38:57 -08:00
ret
2015-12-16 09:32:08 -08:00
BillsPC_IncrementJumptableIndex: ; e298d (38:698d)
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
inc [hl]
ret
2015-12-16 09:32:08 -08:00
BillsPC_EndJumptableLoop: ; e2992 (38:6992)
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
set 7, [hl]
ret
2015-12-16 09:32:08 -08:00
_StatsScreenDPad: ; e2998 (38:6998)
ld a, [wBillsPC_NumMonsOnScreen]
2015-11-11 20:38:57 -08:00
ld d, a
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_NumMonsInBox]
2015-11-11 20:38:57 -08:00
and a
2015-12-16 09:32:08 -08:00
jr z, .empty
2015-11-11 20:38:57 -08:00
dec a
cp $1
2015-12-16 09:32:08 -08:00
jr z, .empty
2015-11-11 20:38:57 -08:00
ld e, a
ld a, [hl]
and D_UP
2015-12-16 09:32:08 -08:00
jr nz, BillsPC_PressUp
2015-11-11 20:38:57 -08:00
ld a, [hl]
and D_DOWN
2015-12-16 09:32:08 -08:00
jr nz, BillsPC_PressDown
.empty
jp BillsPC_JoypadDidNothing
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
Withdraw_UpDown: ; e29b5 (38:69b5)
2015-11-11 20:38:57 -08:00
ld hl, hJoyLast
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_NumMonsOnScreen]
2015-11-11 20:38:57 -08:00
ld d, a
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_NumMonsInBox]
2015-11-11 20:38:57 -08:00
ld e, a
and a
2015-12-16 09:32:08 -08:00
jr z, .empty
2015-11-11 20:38:57 -08:00
ld a, [hl]
and D_UP
2015-12-16 09:32:08 -08:00
jr nz, BillsPC_PressUp
2015-11-11 20:38:57 -08:00
ld a, [hl]
and D_DOWN
2015-12-16 09:32:08 -08:00
jr nz, BillsPC_PressDown
.empty
jp BillsPC_JoypadDidNothing
2015-11-11 20:38:57 -08:00
; e29d0 (38:69d0)
MoveMonWithoutMail_DPad: ; e29d0
2015-11-11 20:38:57 -08:00
ld hl, hJoyLast
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_NumMonsOnScreen]
2015-11-11 20:38:57 -08:00
ld d, a
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_NumMonsInBox]
2015-11-11 20:38:57 -08:00
ld e, a
and a
2015-12-16 09:32:08 -08:00
jr z, .check_left_right
2015-11-11 20:38:57 -08:00
ld a, [hl]
and D_UP
2015-12-16 09:32:08 -08:00
jr nz, BillsPC_PressUp
2015-11-11 20:38:57 -08:00
ld a, [hl]
and D_DOWN
2015-12-16 09:32:08 -08:00
jr nz, BillsPC_PressDown
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
.check_left_right
2015-11-11 20:38:57 -08:00
ld a, [hl]
and D_LEFT
2015-12-16 09:32:08 -08:00
jr nz, BillsPC_PressLeft
2015-11-11 20:38:57 -08:00
ld a, [hl]
and D_RIGHT
2015-12-16 09:32:08 -08:00
jr nz, BillsPC_PressRight
jr BillsPC_JoypadDidNothing
2015-11-11 20:38:57 -08:00
MoveMonWithoutMail_DPad_2: ; e29f4
2015-11-11 20:38:57 -08:00
ld hl, hJoyLast
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_NumMonsOnScreen]
2015-11-11 20:38:57 -08:00
ld d, a
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_NumMonsInBox]
2015-11-11 20:38:57 -08:00
ld e, a
and a
2015-12-16 09:32:08 -08:00
jr z, .check_left_right
2015-11-11 20:38:57 -08:00
ld a, [hl]
and D_UP
2015-12-16 09:32:08 -08:00
jr nz, BillsPC_PressUp
2015-11-11 20:38:57 -08:00
ld a, [hl]
and D_DOWN
2015-12-16 09:32:08 -08:00
jr nz, BillsPC_PressDown
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
.check_left_right
2015-11-11 20:38:57 -08:00
ld a, [hl]
and D_LEFT
2015-12-16 09:32:08 -08:00
jr nz, BillsPC_PressLeft
2015-11-11 20:38:57 -08:00
ld a, [hl]
and D_RIGHT
2015-12-16 09:32:08 -08:00
jr nz, BillsPC_PressRight
jr BillsPC_JoypadDidNothing
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
BillsPC_PressUp: ; e2a18 (38:6a18)
ld hl, wBillsPC_CursorPosition
2015-11-11 20:38:57 -08:00
ld a, [hl]
and a
2015-12-16 09:32:08 -08:00
jr z, .top
2015-11-11 20:38:57 -08:00
dec [hl]
2015-12-16 09:32:08 -08:00
jr BillsPC_UpDownDidSomething
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
.top
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
ld a, [hl]
and a
2015-12-16 09:32:08 -08:00
jr z, BillsPC_JoypadDidNothing
2015-11-11 20:38:57 -08:00
dec [hl]
2015-12-16 09:32:08 -08:00
jr BillsPC_UpDownDidSomething
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
BillsPC_PressDown: ; e2a2c (38:6a2c)
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
inc a
cp e
2015-12-16 09:32:08 -08:00
jr nc, BillsPC_JoypadDidNothing
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
ld hl, wBillsPC_CursorPosition
2015-11-11 20:38:57 -08:00
ld a, [hl]
inc a
cp d
2015-12-16 09:32:08 -08:00
jr nc, .not_bottom
2015-11-11 20:38:57 -08:00
inc [hl]
2015-12-16 09:32:08 -08:00
jr BillsPC_UpDownDidSomething
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
.not_bottom
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
inc [hl]
2015-12-16 09:32:08 -08:00
jr BillsPC_UpDownDidSomething
2015-11-11 20:38:57 -08:00
; e2a48 (38:6a48)
2015-12-16 09:32:08 -08:00
BillsPC_PressLeft: ; e2a48
ld hl, wBillsPC_LoadedBox
2015-11-11 20:38:57 -08:00
ld a, [hl]
and a
2015-12-16 09:32:08 -08:00
jr z, .wrap_around
2015-11-11 20:38:57 -08:00
dec [hl]
2015-12-16 09:32:08 -08:00
jr BillsPC_LeftRightDidSomething
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
.wrap_around
ld [hl], NUM_BOXES
jr BillsPC_LeftRightDidSomething
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
BillsPC_PressRight: ; e2a56
ld hl, wBillsPC_LoadedBox
2015-11-11 20:38:57 -08:00
ld a, [hl]
2015-12-16 09:32:08 -08:00
cp NUM_BOXES
jr z, .wrap_around
2015-11-11 20:38:57 -08:00
inc [hl]
2015-12-16 09:32:08 -08:00
jr BillsPC_LeftRightDidSomething
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
.wrap_around
ld [hl], 0
jr BillsPC_LeftRightDidSomething
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
BillsPC_JoypadDidNothing: ; e2a65 (38:6a65)
2015-11-11 20:38:57 -08:00
xor a
and a
ret
2015-12-16 09:32:08 -08:00
BillsPC_UpDownDidSomething: ; e2a68 (38:6a68)
ld a, TRUE
2015-11-11 20:38:57 -08:00
and a
ret
; e2a6c (38:6a6c)
2015-12-16 09:32:08 -08:00
BillsPC_LeftRightDidSomething: ; e2a6c
2015-11-11 20:38:57 -08:00
scf
ret
; e2a6e
2015-12-16 09:32:08 -08:00
BillsPC_PlaceString: ; e2a6e (38:6a6e)
2015-11-11 20:38:57 -08:00
push de
hlcoord 0, 15
lb bc, 1, 18
call TextBox
pop de
hlcoord 1, 16
call PlaceString
ret
; e2a80 (38:6a80)
2015-12-16 09:32:08 -08:00
BillsPC_MoveMonWOMail_BoxNameAndArrows: ; e2a80
call BillsPC_BoxName
2015-11-11 20:38:57 -08:00
hlcoord 8, 1
ld [hl], $5f
hlcoord 19, 1
ld [hl], $5e
ret
; e2a8e
2015-12-16 09:32:08 -08:00
BillsPC_BoxName: ; e2a8e (38:6a8e)
2015-11-11 20:38:57 -08:00
hlcoord 8, 0
lb bc, 1, 10
call TextBox
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_LoadedBox]
2015-11-11 20:38:57 -08:00
and a
jr z, .party
cp NUM_BOXES + 1
jr nz, .gotbox
ld a, [wCurBox]
inc a
.gotbox
dec a
ld hl, wBoxNames
ld bc, BOX_NAME_LENGTH
call AddNTimes
ld e, l
ld d, h
jr .print
.party
2015-12-16 09:32:08 -08:00
ld de, .PartyPKMN
2015-11-11 20:38:57 -08:00
.print
hlcoord 10, 1
call PlaceString
ret
; e2abd (38:6abd)
2015-12-16 09:32:08 -08:00
.PartyPKMN:
2015-11-11 20:38:57 -08:00
db "PARTY <PK><MN>@"
; e2ac6
PCMonInfo: ; e2ac6 (38:6ac6)
; Display a monster's pic and
; attributes when highlighting
; it in a PC menu.
; Includes the neat cascading
; effect when showing the pic.
; Example: Species, level, gender,
; whether it's holding an item.
hlcoord 0, 0
lb bc, 15, 8
call ClearBox
hlcoord 8, 14
lb bc, 1, 3
call ClearBox
2015-12-16 09:32:08 -08:00
call BillsPC_GetSelectedPokemonSpecies
2015-11-11 20:38:57 -08:00
and a
ret z
2015-12-16 09:32:08 -08:00
cp -1
2015-11-11 20:38:57 -08:00
ret z
ld [wd265], a
hlcoord 1, 4
xor a
ld b, 7
2015-12-16 09:32:08 -08:00
.row
2015-11-11 20:38:57 -08:00
ld c, 7
push af
push hl
2015-12-16 09:32:08 -08:00
.col
2015-11-11 20:38:57 -08:00
ld [hli], a
add 7
dec c
2015-12-16 09:32:08 -08:00
jr nz, .col
2015-11-11 20:38:57 -08:00
pop hl
2015-12-16 09:32:08 -08:00
ld de, SCREEN_WIDTH
2015-11-11 20:38:57 -08:00
add hl, de
pop af
inc a
dec b
2015-12-16 09:32:08 -08:00
jr nz, .row
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
call BillsPC_LoadMonStats
2015-11-11 20:38:57 -08:00
ld a, [wd265]
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
ld [wCurSpecies], a
ld hl, wTempMonDVs
predef GetUnownLetter
2015-11-11 20:38:57 -08:00
call GetBaseData
2017-12-28 04:32:33 -08:00
ld de, vTiles2 tile $00
predef GetMonFrontpic
2015-11-11 20:38:57 -08:00
xor a
2015-12-16 09:32:08 -08:00
ld [wBillsPC_MonHasMail], a
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
2015-11-11 20:38:57 -08:00
ld [wd265], a
cp EGG
ret z
call GetBasePokemonName
hlcoord 1, 14
call PlaceString
hlcoord 1, 12
call PrintLevel
ld a, $3
2018-01-23 14:39:09 -08:00
ld [wMonType], a
farcall GetGender
2015-12-16 09:32:08 -08:00
jr c, .skip_gender
2015-11-11 20:38:57 -08:00
ld a, "♂"
jr nz, .printgender
ld a, "♀"
.printgender
hlcoord 5, 12
ld [hl], a
2015-12-16 09:32:08 -08:00
.skip_gender
2015-11-11 20:38:57 -08:00
2018-01-23 14:39:09 -08:00
ld a, [wTempMonItem]
2015-11-11 20:38:57 -08:00
and a
ret z
ld d, a
2017-12-24 09:47:30 -08:00
callfar ItemIsMail
2015-11-11 20:38:57 -08:00
jr c, .mail
ld a, $5d ; item icon
jr .printitem
.mail
ld a, $1
2015-12-16 09:32:08 -08:00
ld [wBillsPC_MonHasMail], a
2015-11-11 20:38:57 -08:00
ld a, $5c ; mail icon
.printitem
hlcoord 7, 12
ld [hl], a
ret
2015-12-16 09:32:08 -08:00
BillsPC_LoadMonStats: ; e2b6d (38:6b6d)
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
ld e, a
ld d, $0
ld hl, wBillsPCPokemonList + 1 ; box number
add hl, de
add hl, de
2015-11-11 20:38:57 -08:00
add hl, de
ld a, [hl]
and a
2015-12-16 09:32:08 -08:00
jr z, .party
cp NUM_BOXES + 1
jr z, .sBox
2015-11-11 20:38:57 -08:00
ld b, a
2015-11-17 20:29:14 -08:00
call GetBoxPointer
2015-11-11 20:38:57 -08:00
ld a, b
call GetSRAMBank
push hl
2015-11-17 20:29:14 -08:00
ld bc, sBoxMon1Level - sBox
2015-11-11 20:38:57 -08:00
add hl, bc
2015-11-17 20:29:14 -08:00
ld bc, BOXMON_STRUCT_LENGTH
2015-11-11 20:38:57 -08:00
ld a, e
call AddNTimes
ld a, [hl]
2018-01-23 14:39:09 -08:00
ld [wTempMonLevel], a
2015-11-11 20:38:57 -08:00
pop hl
push hl
2015-11-17 20:29:14 -08:00
ld bc, sBoxMon1Item - sBox
2015-11-11 20:38:57 -08:00
add hl, bc
2015-11-17 20:29:14 -08:00
ld bc, BOXMON_STRUCT_LENGTH
2015-11-11 20:38:57 -08:00
ld a, e
call AddNTimes
ld a, [hl]
2018-01-23 14:39:09 -08:00
ld [wTempMonItem], a
2015-11-11 20:38:57 -08:00
pop hl
2015-11-17 20:29:14 -08:00
ld bc, sBoxMon1DVs - sBox
2015-11-11 20:38:57 -08:00
add hl, bc
2015-11-17 20:29:14 -08:00
ld bc, BOXMON_STRUCT_LENGTH
2015-11-11 20:38:57 -08:00
ld a, e
call AddNTimes
2018-01-23 14:39:09 -08:00
ld de, wTempMonDVs
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
call CloseSRAM
ret
2015-12-16 09:32:08 -08:00
.party
2018-01-23 14:39:09 -08:00
ld hl, wPartyMon1Level
2015-11-17 20:29:14 -08:00
ld bc, PARTYMON_STRUCT_LENGTH
2015-11-11 20:38:57 -08:00
ld a, e
call AddNTimes
ld a, [hl]
2018-01-23 14:39:09 -08:00
ld [wTempMonLevel], a
ld hl, wPartyMon1Item
2015-11-17 20:29:14 -08:00
ld bc, PARTYMON_STRUCT_LENGTH
2015-11-11 20:38:57 -08:00
ld a, e
call AddNTimes
ld a, [hl]
2018-01-23 14:39:09 -08:00
ld [wTempMonItem], a
ld hl, wPartyMon1DVs
2015-11-17 20:29:14 -08:00
ld bc, PARTYMON_STRUCT_LENGTH
2015-11-11 20:38:57 -08:00
ld a, e
call AddNTimes
2018-01-23 14:39:09 -08:00
ld de, wTempMonDVs
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
ret
2015-12-16 09:32:08 -08:00
.sBox
2015-11-11 20:38:57 -08:00
ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBoxMon1Level
2015-11-17 20:29:14 -08:00
ld bc, BOXMON_STRUCT_LENGTH
2015-11-11 20:38:57 -08:00
ld a, e
call AddNTimes
ld a, [hl]
2018-01-23 14:39:09 -08:00
ld [wTempMonLevel], a
2015-11-11 20:38:57 -08:00
ld hl, sBoxMon1Item
2015-11-17 20:29:14 -08:00
ld bc, BOXMON_STRUCT_LENGTH
2015-11-11 20:38:57 -08:00
ld a, e
call AddNTimes
ld a, [hl]
2018-01-23 14:39:09 -08:00
ld [wTempMonItem], a
2015-11-11 20:38:57 -08:00
ld hl, sBoxMon1DVs
2015-11-17 20:29:14 -08:00
ld bc, BOXMON_STRUCT_LENGTH
2015-11-11 20:38:57 -08:00
ld a, e
call AddNTimes
2018-01-23 14:39:09 -08:00
ld de, wTempMonDVs
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
call CloseSRAM
ret
2015-12-16 09:32:08 -08:00
BillsPC_RefreshTextboxes: ; e2c2c (38:6c2c)
2015-11-11 20:38:57 -08:00
hlcoord 8, 2
lb bc, 10, 10
call TextBox
hlcoord 8, 2
ld [hl], "└"
hlcoord 19, 2
ld [hl], "┘"
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_ScrollPosition]
2015-11-11 20:38:57 -08:00
ld e, a
ld d, 0
2015-12-16 09:32:08 -08:00
ld hl, wBillsPCPokemonList
2015-11-11 20:38:57 -08:00
add hl, de
add hl, de
add hl, de
2015-11-11 20:38:57 -08:00
ld e, l
ld d, h
hlcoord 9, 4
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_NumMonsOnScreen]
.loop
2015-11-11 20:38:57 -08:00
push af
push de
push hl
2015-12-16 09:32:08 -08:00
call .PlaceNickname
2015-11-11 20:38:57 -08:00
pop hl
2015-12-16 09:32:08 -08:00
ld de, 2 * SCREEN_WIDTH
2015-11-11 20:38:57 -08:00
add hl, de
pop de
inc de
inc de
inc de
2015-11-11 20:38:57 -08:00
pop af
dec a
2015-12-16 09:32:08 -08:00
jr nz, .loop
2015-11-11 20:38:57 -08:00
ret
; e2c67 (38:6c67)
2015-12-16 09:32:08 -08:00
.CancelString:
2015-11-11 20:38:57 -08:00
db "CANCEL@"
; e2c6e
2015-12-16 09:32:08 -08:00
.PlaceNickname: ; e2c6e (38:6c6e)
2015-11-11 20:38:57 -08:00
ld a, [de]
and a
ret z
2015-12-16 09:32:08 -08:00
cp -1
jr nz, .get_nickname
ld de, .CancelString
2015-11-11 20:38:57 -08:00
call PlaceString
ret
2015-11-17 20:29:14 -08:00
2015-12-16 09:32:08 -08:00
.get_nickname
2015-11-11 20:38:57 -08:00
inc de
ld a, [de]
ld b, a
inc de
ld a, [de]
ld e, a
ld a, b
and a
2015-12-16 09:32:08 -08:00
jr z, .party
cp NUM_BOXES + 1
jr z, .sBox
2015-11-11 20:38:57 -08:00
push hl
2015-11-17 20:29:14 -08:00
call GetBoxPointer
2015-11-11 20:38:57 -08:00
ld a, b
call GetSRAMBank
push hl
2015-11-17 20:29:14 -08:00
ld bc, sBoxMons - sBox
2015-11-11 20:38:57 -08:00
add hl, bc
2015-11-17 20:29:14 -08:00
ld bc, BOXMON_STRUCT_LENGTH
2015-11-11 20:38:57 -08:00
ld a, e
call AddNTimes
ld a, [hl]
pop hl
and a
2015-12-16 09:32:08 -08:00
jr z, .boxfail
2015-11-17 20:29:14 -08:00
ld bc, sBoxMonNicknames - sBox
2015-11-11 20:38:57 -08:00
add hl, bc
2018-01-20 09:25:55 -08:00
ld bc, MON_NAME_LENGTH
2015-11-11 20:38:57 -08:00
ld a, e
call AddNTimes
2018-01-23 14:39:09 -08:00
ld de, wStringBuffer1
2018-01-20 09:25:55 -08:00
ld bc, MON_NAME_LENGTH
2015-11-11 20:38:57 -08:00
call CopyBytes
call CloseSRAM
pop hl
2018-01-23 14:39:09 -08:00
ld de, wStringBuffer1
2015-11-11 20:38:57 -08:00
call PlaceString
ret
2015-11-17 20:29:14 -08:00
2015-12-16 09:32:08 -08:00
.boxfail
2015-11-11 20:38:57 -08:00
call CloseSRAM
pop hl
2015-12-16 09:32:08 -08:00
jr .placeholder_string
2015-11-17 20:29:14 -08:00
2015-12-16 09:32:08 -08:00
.party
2015-11-11 20:38:57 -08:00
push hl
2018-01-23 14:39:09 -08:00
ld hl, wPartySpecies
2015-11-11 20:38:57 -08:00
ld d, $0
add hl, de
ld a, [hl]
and a
2015-12-16 09:32:08 -08:00
jr z, .partyfail
2018-01-23 14:39:09 -08:00
ld hl, wPartyMonNicknames
2018-01-20 09:25:55 -08:00
ld bc, MON_NAME_LENGTH
2015-11-11 20:38:57 -08:00
ld a, e
call AddNTimes
2018-01-23 14:39:09 -08:00
ld de, wStringBuffer1
2018-01-20 09:25:55 -08:00
ld bc, MON_NAME_LENGTH
2015-11-11 20:38:57 -08:00
call CopyBytes
pop hl
2018-01-23 14:39:09 -08:00
ld de, wStringBuffer1
2015-11-11 20:38:57 -08:00
call PlaceString
ret
2015-11-17 20:29:14 -08:00
2015-12-16 09:32:08 -08:00
.partyfail
2015-11-11 20:38:57 -08:00
pop hl
2015-12-16 09:32:08 -08:00
jr .placeholder_string
2015-11-17 20:29:14 -08:00
2015-12-16 09:32:08 -08:00
.sBox
2015-11-11 20:38:57 -08:00
push hl
ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBoxSpecies
ld d, $0
add hl, de
ld a, [hl]
and a
2015-12-16 09:32:08 -08:00
jr z, .sBoxFail
2015-11-11 20:38:57 -08:00
ld hl, sBoxMonNicknames
2018-01-20 09:25:55 -08:00
ld bc, MON_NAME_LENGTH
2015-11-11 20:38:57 -08:00
ld a, e
call AddNTimes
2018-01-23 14:39:09 -08:00
ld de, wStringBuffer1
2018-01-20 09:25:55 -08:00
ld bc, MON_NAME_LENGTH
2015-11-11 20:38:57 -08:00
call CopyBytes
call CloseSRAM
pop hl
2018-01-23 14:39:09 -08:00
ld de, wStringBuffer1
2015-11-11 20:38:57 -08:00
call PlaceString
ret
2015-11-17 20:29:14 -08:00
2015-12-16 09:32:08 -08:00
.sBoxFail
2015-11-11 20:38:57 -08:00
call CloseSRAM
pop hl
2015-12-16 09:32:08 -08:00
.placeholder_string
ld de, .Placeholder
2015-11-11 20:38:57 -08:00
call PlaceString
ret
; e2d2a (38:6d2a)
2015-12-16 09:32:08 -08:00
.Placeholder:
2015-11-11 20:38:57 -08:00
db "-----@"
; e2d30
2015-12-16 09:32:08 -08:00
copy_box_data: MACRO
.loop\@
2015-11-11 20:38:57 -08:00
ld a, [hl]
2015-12-16 09:32:08 -08:00
cp -1
jr z, .done\@
2015-11-11 20:38:57 -08:00
and a
2015-12-16 09:32:08 -08:00
jr z, .done\@
2015-11-11 20:38:57 -08:00
ld [de], a
inc de
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_LoadedBox]
2015-11-11 20:38:57 -08:00
ld [de], a
inc de
ld a, [wd003]
ld [de], a
inc a
ld [wd003], a
inc de
inc hl
ld a, [wd004]
inc a
ld [wd004], a
2015-12-16 09:32:08 -08:00
jr .loop\@
2015-11-17 20:29:14 -08:00
2015-12-16 09:32:08 -08:00
.done\@
if \1
2015-11-11 20:38:57 -08:00
call CloseSRAM
endc
2015-12-16 09:32:08 -08:00
ld a, -1
2015-11-11 20:38:57 -08:00
ld [de], a
ld a, [wd004]
inc a
2015-12-16 09:32:08 -08:00
ld [wBillsPC_NumMonsInBox], a
2017-12-28 13:31:16 -08:00
ENDM
2015-11-17 20:29:14 -08:00
2015-12-16 09:32:08 -08:00
CopyBoxmonSpecies: ; e2d30 (38:6d30)
xor a
ld hl, wBillsPCPokemonList
ld bc, 3 * 30
call ByteFill
ld de, wBillsPCPokemonList
xor a
2015-11-11 20:38:57 -08:00
ld [wd003], a
ld [wd004], a
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_LoadedBox]
and a
jr z, .party
cp NUM_BOXES + 1
jr z, .sBox
ld b, a
call GetBoxPointer
ld a, b
call GetSRAMBank
inc hl
copy_box_data 1
ret
2015-11-17 20:29:14 -08:00
2015-12-16 09:32:08 -08:00
.party
2018-01-23 14:39:09 -08:00
ld hl, wPartySpecies
2015-12-16 09:32:08 -08:00
copy_box_data 0
2015-11-11 20:38:57 -08:00
ret
2015-11-17 20:29:14 -08:00
2015-12-16 09:32:08 -08:00
.sBox
2015-11-11 20:38:57 -08:00
ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBoxSpecies
2015-12-16 09:32:08 -08:00
copy_box_data 1
2015-11-11 20:38:57 -08:00
ret
2015-12-16 09:32:08 -08:00
BillsPC_GetSelectedPokemonSpecies: ; e2def (38:6def)
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
ld e, a
ld d, $0
2015-12-16 09:32:08 -08:00
ld hl, wBillsPCPokemonList
2015-11-11 20:38:57 -08:00
add hl, de
add hl, de
add hl, de
2015-11-11 20:38:57 -08:00
ld a, [hl]
ret
2015-12-16 09:32:08 -08:00
BillsPC_UpdateSelectionCursor: ; e2e01 (38:6e01)
ld a, [wBillsPC_NumMonsInBox]
2015-11-11 20:38:57 -08:00
and a
2015-12-16 09:32:08 -08:00
jr nz, .place_cursor
2015-11-11 20:38:57 -08:00
call ClearSprites
ret
2015-11-17 20:29:14 -08:00
2015-12-16 09:32:08 -08:00
.place_cursor
ld hl, .OAM
2018-01-30 11:52:46 -08:00
ld de, wVirtualOAMSprite00
2015-11-17 20:29:14 -08:00
.loop
2015-11-11 20:38:57 -08:00
ld a, [hl]
2015-12-16 09:32:08 -08:00
cp -1
2015-11-11 20:38:57 -08:00
ret z
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_CursorPosition]
2015-11-11 20:38:57 -08:00
and $7
swap a
add [hl]
inc hl
2018-01-10 10:47:57 -08:00
ld [de], a ; y
2015-11-11 20:38:57 -08:00
inc de
rept SPRITEOAMSTRUCT_LENGTH + -1
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld [de], a
inc de
2015-12-16 09:32:08 -08:00
endr
2015-11-17 20:29:14 -08:00
jr .loop
2015-11-11 20:38:57 -08:00
; e2e2b (38:6e2b)
2015-12-16 09:32:08 -08:00
.OAM: ; e2e2b
2018-01-02 14:26:23 -08:00
dsprite 4, 6, 10, 0, $00, 0
dsprite 4, 6, 11, 0, $00, 0
dsprite 4, 6, 12, 0, $00, 0
dsprite 4, 6, 13, 0, $00, 0
dsprite 4, 6, 14, 0, $00, 0
dsprite 4, 6, 15, 0, $00, 0
dsprite 4, 6, 16, 0, $00, 0
dsprite 4, 6, 17, 0, $00, 0
dsprite 4, 6, 18, 0, $00, 0
dsprite 4, 6, 18, 7, $00, 0
dsprite 7, 1, 10, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 11, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 12, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 13, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 14, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 15, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 16, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 17, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 18, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 18, 7, $00, 0 | Y_FLIP
dsprite 5, 6, 9, 6, $01, 0
dsprite 6, 1, 9, 6, $01, 0 | Y_FLIP
dsprite 5, 6, 19, 1, $01, 0 | X_FLIP
dsprite 6, 1, 19, 1, $01, 0 | X_FLIP | Y_FLIP
2015-12-16 09:32:08 -08:00
db -1
2015-11-11 20:38:57 -08:00
; e2e8c
2015-12-16 09:32:08 -08:00
BillsPC_UpdateInsertCursor: ; e2e8c
ld hl, .OAM
2018-01-30 11:52:46 -08:00
ld de, wVirtualOAMSprite00
2015-12-16 09:32:08 -08:00
.loop
2015-11-11 20:38:57 -08:00
ld a, [hl]
2015-12-16 09:32:08 -08:00
cp -1
2015-11-11 20:38:57 -08:00
ret z
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_CursorPosition]
2015-11-11 20:38:57 -08:00
and $7
swap a
add [hl]
inc hl
2018-01-10 10:47:57 -08:00
ld [de], a ; y
2015-11-11 20:38:57 -08:00
inc de
rept SPRITEOAMSTRUCT_LENGTH + -1
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld [de], a
inc de
2015-12-16 09:32:08 -08:00
endr
jr .loop
2015-11-11 20:38:57 -08:00
; e2eac
2015-12-16 09:32:08 -08:00
.OAM: ; e2eac
2018-01-02 14:26:23 -08:00
dsprite 4, 7, 10, 0, $06, 0
dsprite 5, 3, 11, 0, $00, 0 | Y_FLIP
dsprite 5, 3, 12, 0, $00, 0 | Y_FLIP
dsprite 5, 3, 13, 0, $00, 0 | Y_FLIP
dsprite 5, 3, 14, 0, $00, 0 | Y_FLIP
dsprite 5, 3, 15, 0, $00, 0 | Y_FLIP
dsprite 5, 3, 16, 0, $00, 0 | Y_FLIP
dsprite 5, 3, 17, 0, $00, 0 | Y_FLIP
dsprite 5, 3, 18, 0, $00, 0 | Y_FLIP
dsprite 4, 7, 19, 0, $07, 0
2015-12-16 09:32:08 -08:00
db -1
2015-11-11 20:38:57 -08:00
; e2ed5
Unreferenced_BillsPC_FillBox: ; e2ed5
2015-12-16 09:32:08 -08:00
.row
2015-11-11 20:38:57 -08:00
push bc
push hl
2015-12-16 09:32:08 -08:00
.col
2015-11-11 20:38:57 -08:00
ld [hli], a
dec c
2015-12-16 09:32:08 -08:00
jr nz, .col
2015-11-11 20:38:57 -08:00
pop hl
ld bc, SCREEN_WIDTH
add hl, bc
pop bc
dec b
2015-12-16 09:32:08 -08:00
jr nz, .row
2015-11-11 20:38:57 -08:00
ret
; e2ee5
2015-12-16 09:32:08 -08:00
BillsPC_CheckSpaceInDestination: ; e2ee5
; If moving within a box, no need to be here.
ld hl, wBillsPC_LoadedBox
ld a, [wBillsPC_BackupLoadedBox]
2015-11-11 20:38:57 -08:00
cp [hl]
2015-12-16 09:32:08 -08:00
jr z, .same_box
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
; Exceeding box or party capacity is a big no-no.
ld a, [wBillsPC_LoadedBox]
and a
jr z, .party
ld e, MONS_PER_BOX + 1
jr .compare
2015-11-11 20:38:57 -08:00
2015-12-16 09:32:08 -08:00
.party
ld e, PARTY_LENGTH + 1
.compare
ld a, [wBillsPC_NumMonsInBox]
2015-11-11 20:38:57 -08:00
cp e
2015-12-16 09:32:08 -08:00
jr nc, .no_room
.same_box
2015-11-11 20:38:57 -08:00
and a
ret
2015-12-16 09:32:08 -08:00
.no_room
2015-11-11 20:38:57 -08:00
ld de, PCString_TheresNoRoom
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
ld de, SFX_WRONG
call WaitPlaySFX
call WaitSFX
ld c, 50
call DelayFrames
scf
ret
; e2f18
2015-12-16 09:32:08 -08:00
BillsPC_CheckMail_PreventBlackout: ; e2f18 (38:6f18)
ld a, [wBillsPC_LoadedBox]
2015-11-11 20:38:57 -08:00
and a
jr nz, .Okay
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_NumMonsInBox]
2015-11-11 20:38:57 -08:00
cp $3
jr c, .ItsYourLastPokemon
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
2018-01-23 14:39:09 -08:00
ld [wCurPartyMon], a
2017-12-24 09:47:30 -08:00
farcall CheckCurPartyMonFainted
2015-11-11 20:38:57 -08:00
jr c, .AllOthersFainted
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_MonHasMail]
2015-11-11 20:38:57 -08:00
and a
jr nz, .HasMail
.Okay:
2015-11-11 20:38:57 -08:00
and a
ret
2015-12-16 09:32:08 -08:00
.HasMail:
2015-11-11 20:38:57 -08:00
ld de, PCString_RemoveMail
jr .NotOkay
2015-12-16 09:32:08 -08:00
.AllOthersFainted:
2015-11-11 20:38:57 -08:00
ld de, PCString_NoMoreUsablePKMN
jr .NotOkay
2015-12-16 09:32:08 -08:00
.ItsYourLastPokemon:
2015-11-11 20:38:57 -08:00
ld de, PCString_ItsYourLastPKMN
.NotOkay:
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
ld de, SFX_WRONG
call WaitPlaySFX
call WaitSFX
ld c, 50
call DelayFrames
scf
ret
2015-12-16 09:32:08 -08:00
BillsPC_IsMonAnEgg: ; e2f5f (38:6f5f)
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
2015-11-11 20:38:57 -08:00
cp EGG
2015-12-16 09:32:08 -08:00
jr z, .egg
2015-11-11 20:38:57 -08:00
and a
ret
2015-12-16 09:32:08 -08:00
.egg
2015-11-11 20:38:57 -08:00
ld de, PCString_NoReleasingEGGS
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
ld de, SFX_WRONG
call WaitPlaySFX
call WaitSFX
ld c, 50
call DelayFrames
scf
ret
2015-12-16 09:32:08 -08:00
BillsPC_StatsScreen: ; e2f7e (38:6f7e)
2015-11-11 20:38:57 -08:00
call LowVolume
2015-12-16 09:32:08 -08:00
call BillsPC_CopyMon
2015-11-11 20:38:57 -08:00
ld a, $3
2018-01-23 14:39:09 -08:00
ld [wMonType], a
predef StatsScreenInit
2015-12-16 09:32:08 -08:00
call BillsPC_InitGFX
2015-11-11 20:38:57 -08:00
call MaxVolume
ret
2015-12-16 09:32:08 -08:00
StatsScreenDPad: ; e2f95 (38:6f95)
2015-11-11 20:38:57 -08:00
ld hl, hJoyPressed ; $ffa7
ld a, [hl]
and A_BUTTON | B_BUTTON | D_RIGHT | D_LEFT
2015-12-15 15:59:49 -08:00
ld [wMenuJoypad], a
2015-11-11 20:38:57 -08:00
jr nz, .pressed_a_b_right_left
ld a, [hl]
and D_DOWN | D_UP
2015-12-15 15:59:49 -08:00
ld [wMenuJoypad], a
2015-11-11 20:38:57 -08:00
jr nz, .pressed_down_up
jr .pressed_a_b_right_left
.pressed_down_up
2015-12-16 09:32:08 -08:00
call _StatsScreenDPad
2015-11-11 20:38:57 -08:00
and a
2015-12-16 09:32:08 -08:00
jr z, .did_nothing
call BillsPC_GetSelectedPokemonSpecies
2015-11-11 20:38:57 -08:00
ld [wd265], a
2015-12-16 09:32:08 -08:00
call BillsPC_LoadMonStats
2015-11-11 20:38:57 -08:00
ld a, [wd265]
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
ld [wCurSpecies], a
ld hl, wTempMonDVs
predef GetUnownLetter
2015-11-11 20:38:57 -08:00
call GetBaseData
2015-12-16 09:32:08 -08:00
call BillsPC_CopyMon
2015-11-11 20:38:57 -08:00
.pressed_a_b_right_left
ret
2015-12-16 09:32:08 -08:00
.did_nothing
2015-11-11 20:38:57 -08:00
xor a
2015-12-15 15:59:49 -08:00
ld [wMenuJoypad], a
2015-11-11 20:38:57 -08:00
ret
2015-12-16 09:32:08 -08:00
BillsPC_CopyMon: ; e2fd6 (38:6fd6)
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
2018-01-23 14:39:09 -08:00
ld [wCurPartyMon], a
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_LoadedBox]
2015-11-11 20:38:57 -08:00
and a
2015-12-16 09:32:08 -08:00
jr z, .party
cp NUM_BOXES + 1
jr nz, .box
2015-11-11 20:38:57 -08:00
ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBoxSpecies
2015-11-17 20:29:14 -08:00
call CopySpeciesToTemp
2015-11-11 20:38:57 -08:00
ld hl, sBoxMonNicknames
2015-11-17 20:29:14 -08:00
call CopyNicknameToTemp
2015-11-11 20:38:57 -08:00
ld hl, sBoxMonOT
2015-11-17 20:29:14 -08:00
call CopyOTNameToTemp
2015-11-11 20:38:57 -08:00
ld hl, sBoxMons
ld bc, BOXMON_STRUCT_LENGTH
2018-01-23 14:39:09 -08:00
ld a, [wCurPartyMon]
2015-11-11 20:38:57 -08:00
call AddNTimes
2015-12-16 09:32:08 -08:00
ld de, wBufferMon
2015-11-11 20:38:57 -08:00
ld bc, PARTYMON_STRUCT_LENGTH
call CopyBytes
call CloseSRAM
farcall CalcBufferMonStats
2015-11-11 20:38:57 -08:00
ret
2015-12-16 09:32:08 -08:00
.party
2018-01-23 14:39:09 -08:00
ld hl, wPartySpecies
2015-11-17 20:29:14 -08:00
call CopySpeciesToTemp
2018-01-23 14:39:09 -08:00
ld hl, wPartyMonNicknames
2015-11-17 20:29:14 -08:00
call CopyNicknameToTemp
2018-01-23 14:39:09 -08:00
ld hl, wPartyMonOT
2015-11-17 20:29:14 -08:00
call CopyOTNameToTemp
2018-01-23 14:39:09 -08:00
ld hl, wPartyMon1
2015-11-11 20:38:57 -08:00
ld bc, PARTYMON_STRUCT_LENGTH
2018-01-23 14:39:09 -08:00
ld a, [wCurPartyMon]
2015-11-11 20:38:57 -08:00
call AddNTimes
2015-12-16 09:32:08 -08:00
ld de, wBufferMon
2015-11-11 20:38:57 -08:00
ld bc, PARTYMON_STRUCT_LENGTH
call CopyBytes
ret
2015-12-16 09:32:08 -08:00
.box
2015-11-11 20:38:57 -08:00
ld b, a
2015-11-17 20:29:14 -08:00
call GetBoxPointer
2015-11-11 20:38:57 -08:00
ld a, b
call GetSRAMBank
push hl
inc hl
2015-11-17 20:29:14 -08:00
call CopySpeciesToTemp
2015-11-11 20:38:57 -08:00
pop hl
push hl
2015-11-17 20:29:14 -08:00
ld bc, sBoxMonNicknames - sBox
2015-11-11 20:38:57 -08:00
add hl, bc
2015-11-17 20:29:14 -08:00
call CopyNicknameToTemp
2015-11-11 20:38:57 -08:00
pop hl
push hl
2015-11-17 20:29:14 -08:00
ld bc, sBoxMonOT - sBox
2015-11-11 20:38:57 -08:00
add hl, bc
2015-11-17 20:29:14 -08:00
call CopyOTNameToTemp
2015-11-11 20:38:57 -08:00
pop hl
2015-11-17 20:29:14 -08:00
ld bc, sBoxMons - sBox
2015-11-11 20:38:57 -08:00
add hl, bc
2015-11-17 20:29:14 -08:00
ld bc, BOXMON_STRUCT_LENGTH
call CopyMonToTemp
2015-11-11 20:38:57 -08:00
call CloseSRAM
farcall CalcBufferMonStats
2015-11-11 20:38:57 -08:00
ret
2015-12-16 09:32:08 -08:00
DepositPokemon: ; e307c (38:707c)
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
2018-01-23 14:39:09 -08:00
ld [wCurPartyMon], a
ld hl, wPartyMonNicknames
ld a, [wCurPartyMon]
2015-11-11 20:38:57 -08:00
call GetNick
ld a, PC_DEPOSIT
ld [wPokemonWithdrawDepositParameter], a
predef SendGetMonIntoFromBox
2015-11-11 20:38:57 -08:00
jr c, .asm_boxisfull
xor a ; REMOVE_PARTY
2015-11-11 20:38:57 -08:00
ld [wPokemonWithdrawDepositParameter], a
2017-12-24 09:47:30 -08:00
farcall RemoveMonFromPartyOrBox
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
call PlayMonCry
2015-11-11 20:38:57 -08:00
hlcoord 0, 0
lb bc, 15, 8
call ClearBox
hlcoord 8, 14
lb bc, 1, 3
call ClearBox
hlcoord 0, 15
lb bc, 1, 18
call TextBox
call WaitBGMap
hlcoord 1, 16
ld de, PCString_Stored
call PlaceString
ld l, c
ld h, b
2018-01-23 14:39:09 -08:00
ld de, wStringBuffer1
2015-11-11 20:38:57 -08:00
call PlaceString
ld a, "!"
ld [bc], a
ld c, 50
call DelayFrames
and a
ret
.asm_boxisfull
ld de, PCString_BoxFull
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
ld de, SFX_WRONG
call WaitPlaySFX
call WaitSFX
ld c, 50
call DelayFrames
scf
ret
TryWithdrawPokemon: ; e30fa (38:70fa)
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
2018-01-23 14:39:09 -08:00
ld [wCurPartyMon], a
2015-11-11 20:38:57 -08:00
ld a, BANK(sBoxMonNicknames)
call GetSRAMBank
2018-01-23 14:39:09 -08:00
ld a, [wCurPartyMon]
2015-11-11 20:38:57 -08:00
ld hl, sBoxMonNicknames
call GetNick
call CloseSRAM
xor a
ld [wPokemonWithdrawDepositParameter], a
predef SendGetMonIntoFromBox
2015-11-11 20:38:57 -08:00
jr c, .PartyFull
ld a, REMOVE_BOX
2015-11-11 20:38:57 -08:00
ld [wPokemonWithdrawDepositParameter], a
2017-12-24 09:47:30 -08:00
farcall RemoveMonFromPartyOrBox
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
call PlayMonCry
2015-11-11 20:38:57 -08:00
hlcoord 0, 0
lb bc, 15, 8
call ClearBox
hlcoord 8, 14
lb bc, 1, 3
call ClearBox
hlcoord 0, 15
lb bc, 1, 18
call TextBox
call WaitBGMap
hlcoord 1, 16
ld de, PCString_Got
call PlaceString
ld l, c
ld h, b
2018-01-23 14:39:09 -08:00
ld de, wStringBuffer1
2015-11-11 20:38:57 -08:00
call PlaceString
ld a, $e7
ld [bc], a
ld c, 50
call DelayFrames
and a
ret
.PartyFull:
2015-11-11 20:38:57 -08:00
ld de, PCString_PartyFull
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceString
2015-11-11 20:38:57 -08:00
ld de, SFX_WRONG
call WaitPlaySFX
call WaitSFX
ld c, 50
call DelayFrames
scf
ret
2015-12-16 09:32:08 -08:00
ReleasePKMN_ByePKMN: ; e3180 (38:7180)
2015-11-11 20:38:57 -08:00
hlcoord 0, 0
lb bc, 15, 8
call ClearBox
hlcoord 8, 14
lb bc, 1, 3
call ClearBox
hlcoord 0, 15
lb bc, 1, 18
call TextBox
call WaitBGMap
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
2015-11-11 20:38:57 -08:00
call GetCryIndex
2015-12-16 09:32:08 -08:00
jr c, .skip_cry
2015-11-11 20:38:57 -08:00
ld e, c
ld d, b
call PlayCry
2015-12-16 09:32:08 -08:00
.skip_cry
2015-11-11 20:38:57 -08:00
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
2015-11-11 20:38:57 -08:00
ld [wd265], a
call GetPokemonName
hlcoord 1, 16
ld de, PCString_ReleasedPKMN
call PlaceString
ld c, 80
call DelayFrames
hlcoord 0, 15
lb bc, 1, 18
call TextBox
hlcoord 1, 16
ld de, PCString_Bye
call PlaceString
ld l, c
ld h, b
inc hl
2018-01-23 14:39:09 -08:00
ld de, wStringBuffer1
2015-11-11 20:38:57 -08:00
call PlaceString
ld l, c
ld h, b
ld [hl], $e7
ld c, 50
call DelayFrames
ret
; e31e7 (38:71e7)
2015-12-16 09:32:08 -08:00
MovePKMNWitoutMail_InsertMon: ; e31e7
2015-11-11 20:38:57 -08:00
push hl
push de
push bc
push af
hlcoord 0, 15
lb bc, 1, 18
call TextBox
hlcoord 1, 16
2015-12-16 09:32:08 -08:00
ld de, .Saving_LeaveOn
2015-11-11 20:38:57 -08:00
call PlaceString
ld c, 20
call DelayFrames
pop af
pop bc
pop de
pop hl
ld a, [wCurBox]
push af
ld bc, 0
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_BackupLoadedBox]
2015-11-11 20:38:57 -08:00
and a
2015-12-16 09:32:08 -08:00
jr nz, .moving_from_box
2015-11-11 20:38:57 -08:00
set 0, c
2015-12-16 09:32:08 -08:00
.moving_from_box
ld a, [wBillsPC_LoadedBox]
2015-11-11 20:38:57 -08:00
and a
2015-12-16 09:32:08 -08:00
jr nz, .moving_to_box
2015-11-11 20:38:57 -08:00
set 1, c
2015-12-16 09:32:08 -08:00
.moving_to_box
ld hl, .Jumptable
2015-11-11 20:38:57 -08:00
add hl, bc
add hl, bc
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
2015-12-26 18:59:03 -08:00
ld de, .dw_return
2015-11-11 20:38:57 -08:00
push de
jp hl
2015-11-11 20:38:57 -08:00
; e322a
.dw_return ; e322a
2015-11-11 20:38:57 -08:00
pop af
ld e, a
farcall MoveMonWOMail_InsertMon_SaveGame
2015-11-11 20:38:57 -08:00
ret
; e3233
2015-12-16 09:32:08 -08:00
.Saving_LeaveOn:
2015-11-11 20:38:57 -08:00
db "Saving… Leave ON!@"
; e3245
2015-12-16 09:32:08 -08:00
.Jumptable: ; e3245
2015-12-26 18:59:03 -08:00
dw .BoxToBox
dw .PartyToBox
dw .BoxToParty
dw .PartyToParty
2015-11-11 20:38:57 -08:00
; e324d
2015-12-16 09:32:08 -08:00
.BoxToBox: ; e324d
ld hl, wBillsPC_BackupLoadedBox
ld a, [wBillsPC_LoadedBox]
2015-11-11 20:38:57 -08:00
cp [hl]
2015-12-16 09:32:08 -08:00
jr z, .same_box
call .CopyFromBox
call .CopyToBox
2015-11-11 20:38:57 -08:00
ret
2015-12-16 09:32:08 -08:00
.same_box
call .CopyFromBox
call .CheckTrivialMove
call .CopyToBox
2015-11-11 20:38:57 -08:00
ret
; e3267
2015-12-16 09:32:08 -08:00
.PartyToBox: ; e3267
call .CopyFromParty
2015-11-11 20:38:57 -08:00
ld a, $1
ld [wGameLogicPaused], a
2017-12-24 09:47:30 -08:00
farcall SaveGameData
2015-11-11 20:38:57 -08:00
xor a
ld [wGameLogicPaused], a
2015-12-16 09:32:08 -08:00
call .CopyToBox
2015-11-11 20:38:57 -08:00
ret
; e327d
2015-12-16 09:32:08 -08:00
.BoxToParty: ; e327d
call .CopyFromBox
call .CopyToParty
2015-11-11 20:38:57 -08:00
ret
; e3284
2015-12-16 09:32:08 -08:00
.PartyToParty: ; e3284
call .CopyFromParty
call .CheckTrivialMove
call .CopyToParty
2015-11-11 20:38:57 -08:00
ret
; e328e
2015-12-16 09:32:08 -08:00
.CheckTrivialMove: ; e328e
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
ld e, a
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_BackupCursorPosition]
ld hl, wBillsPC_BackupScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
cp e
ret nc
2015-12-16 09:32:08 -08:00
ld hl, wBillsPC_CursorPosition
2015-11-11 20:38:57 -08:00
ld a, [hl]
and a
2015-12-16 09:32:08 -08:00
jr z, .top_of_screen
2015-11-11 20:38:57 -08:00
dec [hl]
ret
2015-12-16 09:32:08 -08:00
.top_of_screen
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
ld a, [hl]
and a
ret z
dec [hl]
ret
; e32b0
2015-12-16 09:32:08 -08:00
.CopyFromBox: ; e32b0
ld a, [wBillsPC_BackupLoadedBox]
2015-11-11 20:38:57 -08:00
dec a
ld e, a
farcall MoveMonWOMail_SaveGame
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_BackupCursorPosition]
ld hl, wBillsPC_BackupScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
2018-01-23 14:39:09 -08:00
ld [wCurPartyMon], a
ld a, BANK(sBox)
2015-11-11 20:38:57 -08:00
call GetSRAMBank
ld hl, sBoxSpecies
2015-11-17 20:29:14 -08:00
call CopySpeciesToTemp
2015-11-11 20:38:57 -08:00
ld hl, sBoxMonNicknames
2015-11-17 20:29:14 -08:00
call CopyNicknameToTemp
2015-11-11 20:38:57 -08:00
ld hl, sBoxMonOT
2015-11-17 20:29:14 -08:00
call CopyOTNameToTemp
2015-11-11 20:38:57 -08:00
ld hl, sBoxMons
ld bc, BOXMON_STRUCT_LENGTH
2015-11-17 20:29:14 -08:00
call CopyMonToTemp
2015-11-11 20:38:57 -08:00
call CloseSRAM
farcall CalcBufferMonStats
ld a, REMOVE_BOX
2015-11-11 20:38:57 -08:00
ld [wPokemonWithdrawDepositParameter], a
2017-12-24 09:47:30 -08:00
farcall RemoveMonFromPartyOrBox
2015-11-11 20:38:57 -08:00
ret
; e32fa
2015-12-16 09:32:08 -08:00
.CopyToBox: ; e32fa
ld a, [wBillsPC_LoadedBox]
2015-11-11 20:38:57 -08:00
dec a
ld e, a
farcall MoveMonWOMail_SaveGame
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
2018-01-23 14:39:09 -08:00
ld [wCurPartyMon], a
2017-12-24 09:47:30 -08:00
farcall InsertPokemonIntoBox
2015-11-11 20:38:57 -08:00
ret
; e3316
2015-12-16 09:32:08 -08:00
.CopyFromParty: ; e3316
ld a, [wBillsPC_BackupCursorPosition]
ld hl, wBillsPC_BackupScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
2018-01-23 14:39:09 -08:00
ld [wCurPartyMon], a
ld hl, wPartySpecies
2015-11-17 20:29:14 -08:00
call CopySpeciesToTemp
2018-01-23 14:39:09 -08:00
ld hl, wPartyMonNicknames
2015-11-17 20:29:14 -08:00
call CopyNicknameToTemp
2018-01-23 14:39:09 -08:00
ld hl, wPartyMonOT
2015-11-17 20:29:14 -08:00
call CopyOTNameToTemp
2018-01-23 14:39:09 -08:00
ld hl, wPartyMon1Species
2015-11-11 20:38:57 -08:00
ld bc, PARTYMON_STRUCT_LENGTH
2015-11-17 20:29:14 -08:00
call CopyMonToTemp
xor a ; REMOVE_PARTY
2015-11-11 20:38:57 -08:00
ld [wPokemonWithdrawDepositParameter], a
2017-12-24 09:47:30 -08:00
farcall RemoveMonFromPartyOrBox
2015-11-11 20:38:57 -08:00
ret
; e3346
2015-12-16 09:32:08 -08:00
.CopyToParty: ; e3346
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
2015-11-11 20:38:57 -08:00
add [hl]
2018-01-23 14:39:09 -08:00
ld [wCurPartyMon], a
2017-12-24 09:47:30 -08:00
farcall InsertPokemonIntoParty
2015-11-11 20:38:57 -08:00
ret
; e3357
2015-11-17 20:29:14 -08:00
CopySpeciesToTemp: ; e3357 (38:7357)
2018-01-23 14:39:09 -08:00
ld a, [wCurPartyMon]
2015-11-11 20:38:57 -08:00
ld c, a
ld b, $0
add hl, bc
ld a, [hl]
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2015-11-11 20:38:57 -08:00
ret
2015-11-17 20:29:14 -08:00
CopyNicknameToTemp: ; e3363 (38:7363)
2018-01-20 09:25:55 -08:00
ld bc, MON_NAME_LENGTH
2018-01-23 14:39:09 -08:00
ld a, [wCurPartyMon]
2015-11-11 20:38:57 -08:00
call AddNTimes
2015-12-16 09:32:08 -08:00
ld de, wBufferMonNick
2018-01-20 09:25:55 -08:00
ld bc, MON_NAME_LENGTH
2015-11-11 20:38:57 -08:00
call CopyBytes
ret
2015-11-17 20:29:14 -08:00
CopyOTNameToTemp: ; e3376 (38:7376)
ld bc, NAME_LENGTH
2018-01-23 14:39:09 -08:00
ld a, [wCurPartyMon]
2015-11-11 20:38:57 -08:00
call AddNTimes
2015-12-16 09:32:08 -08:00
ld de, wBufferMonOT
2015-11-17 20:29:14 -08:00
ld bc, NAME_LENGTH
2015-11-11 20:38:57 -08:00
call CopyBytes
ret
2015-11-17 20:29:14 -08:00
CopyMonToTemp: ; e3389 (38:7389)
2018-01-23 14:39:09 -08:00
ld a, [wCurPartyMon]
2015-11-11 20:38:57 -08:00
call AddNTimes
2015-12-16 09:32:08 -08:00
ld de, wBufferMon
2015-11-11 20:38:57 -08:00
call CopyBytes
ret
2015-11-17 20:29:14 -08:00
GetBoxPointer: ; e3396 (38:7396)
2015-11-11 20:38:57 -08:00
dec b
ld c, b
ld b, 0
2015-11-17 20:29:14 -08:00
ld hl, .boxes
2015-11-11 20:38:57 -08:00
add hl, bc
add hl, bc
add hl, bc
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld b, a
ld a, [hli]
ld h, [hl]
ld l, a
ret
; e33a6 (38:73a6)
.boxes ; e33a6
2015-11-11 20:38:57 -08:00
; bank, address
dba sBox1
dba sBox2
dba sBox3
dba sBox4
dba sBox5
dba sBox6
dba sBox7
dba sBox8
dba sBox9
dba sBox10
dba sBox11
dba sBox12
dba sBox13
dba sBox14
; e33d0
2015-12-16 09:32:08 -08:00
BillsPC_ApplyPalettes: ; e33d0 (38:73d0)
2015-11-11 20:38:57 -08:00
ld b, a
call GetSGBLayout
2015-12-16 09:32:08 -08:00
ld a, %11100100
2015-11-11 20:38:57 -08:00
call DmgToCgbBGPals
2015-12-16 09:32:08 -08:00
ld a, %11111100
2015-12-09 08:38:40 -08:00
call DmgToCgbObjPal0
2015-11-11 20:38:57 -08:00
ret
2015-12-16 09:32:08 -08:00
BillsPC_Jumptable: ; e33df (38:73df)
2015-11-11 20:38:57 -08:00
ld e, a
ld d, $0
add hl, de
add hl, de
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
ret
2015-12-16 09:32:08 -08:00
BillsPC_InitGFX: ; e33e8 (38:73e8)
2015-11-11 20:38:57 -08:00
call DisableLCD
2017-12-28 04:32:33 -08:00
ld hl, vTiles2 tile $00
2015-12-16 09:32:08 -08:00
ld bc, $31 tiles
2015-11-11 20:38:57 -08:00
xor a
call ByteFill
call LoadStandardFont
call LoadFontsBattleExtra
ld hl, PCMailGFX
2017-12-28 04:32:33 -08:00
ld de, vTiles2 tile $5c
2015-12-16 09:32:08 -08:00
ld bc, 4 tiles
2015-11-11 20:38:57 -08:00
call CopyBytes
ld hl, PCSelectLZ
2017-12-28 04:32:33 -08:00
ld de, vTiles0 tile $00
2015-11-11 20:38:57 -08:00
call Decompress
ld a, 6
call SkipMusic
call EnableLCD
ret
; e3419 (38:7419)
PCSelectLZ: INCBIN "gfx/pc/pc.2bpp.lz"
PCMailGFX: INCBIN "gfx/pc/pc_mail.2bpp"
2015-11-11 20:38:57 -08:00
; e34dd
PCString_ChooseaPKMN: db "Choose a <PK><MN>.@"
PCString_WhatsUp: db "What's up?@"
PCString_ReleasePKMN: db "Release <PK><MN>?@"
PCString_MoveToWhere: db "Move to where?@"
PCString_ItsYourLastPKMN: db "It's your last <PK><MN>!@"
PCString_TheresNoRoom: db "There's no room!@"
PCString_NoMoreUsablePKMN: db "No more usable <PK><MN>!@"
PCString_RemoveMail: db "Remove MAIL.@"
PCString_ReleasedPKMN: db "Released <PK><MN>.@"
PCString_Bye: db "Bye,@"
PCString_Stored: db "Stored @"
PCString_Got: db "Got @"
PCString_Non: db "Non.@"
PCString_BoxFull: db "The BOX is full.@"
PCString_PartyFull: db "The party's full!@"
PCString_NoReleasingEGGS: db "No releasing EGGS!@"
; e35aa
_ChangeBox: ; e35aa (38:75aa)
call LoadStandardMenuHeader
2015-12-16 09:32:08 -08:00
call BillsPC_ClearTilemap
2015-11-11 20:38:57 -08:00
.loop
xor a
ld [hBGMapMode], a
2015-12-16 09:32:08 -08:00
call BillsPC_PrintBoxName
call BillsPC_PlaceChooseABoxString
ld hl, _ChangeBox_MenuHeader
call CopyMenuHeader
2015-11-11 20:38:57 -08:00
xor a
2015-11-23 13:04:53 -08:00
ld [wMenuScrollPosition], a
2015-11-11 20:38:57 -08:00
hlcoord 0, 4
lb bc, 8, 9
call TextBox
2015-12-17 19:31:16 -08:00
call ScrollingMenu
2015-12-15 15:59:49 -08:00
ld a, [wMenuJoypad]
2015-12-16 09:32:08 -08:00
cp B_BUTTON
2015-11-11 20:38:57 -08:00
jr z, .done
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceWhatsUpString
call BillsPC_ChangeBoxSubmenu
2015-11-11 20:38:57 -08:00
jr .loop
.done
call CloseWindow
2015-11-11 20:38:57 -08:00
ret
2015-12-16 09:32:08 -08:00
BillsPC_ClearTilemap: ; e35e2 (38:75e2)
2015-11-11 20:38:57 -08:00
xor a
ld [hBGMapMode], a
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, " "
call ByteFill
ret
; e35f1 (38:75f1)
_ChangeBox_MenuHeader: ; 0xe35f1
db MENU_BACKUP_TILES ; flags
menu_coords 1, 5, 9, 12
dw .MenuData
2015-11-11 20:38:57 -08:00
db 1 ; default option
; 0xe35f9
.MenuData ; 0xe35f9
db MENU_UNUSED_1 | MENU_UNUSED_3 ; flags
2015-11-11 20:38:57 -08:00
db 4, 0
db 1
dba .boxes
dba .boxnames
dba NULL
2015-12-16 09:32:08 -08:00
dba BillsPC_PrintBoxCountAndCapacity
2015-11-11 20:38:57 -08:00
; e3609
.boxes ; e3609
2015-11-11 20:38:57 -08:00
db NUM_BOXES
x = 1
rept NUM_BOXES
db x
x = x + 1
endr
db -1
; e3619
.boxnames ; e3619
2015-11-11 20:38:57 -08:00
push de
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-11-11 20:38:57 -08:00
dec a
call GetBoxName
pop hl
call PlaceString
ret
; e3626
GetBoxName: ; e3626 (38:7626)
ld bc, BOX_NAME_LENGTH
ld hl, wBoxNames
call AddNTimes
ld d, h
ld e, l
ret
; e3632 (38:7632)
2015-12-16 09:32:08 -08:00
BillsPC_PrintBoxCountAndCapacity: ; e3632
2015-11-11 20:38:57 -08:00
hlcoord 11, 7
lb bc, 5, 7
call TextBox
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-11-11 20:38:57 -08:00
cp -1
ret z
hlcoord 12, 9
2015-12-16 09:32:08 -08:00
ld de, .Pokemon
2015-11-11 20:38:57 -08:00
call PlaceString
call GetBoxCount
ld [wd265], a
hlcoord 13, 11
ld de, wd265
lb bc, 1, 2
call PrintNum
2015-12-16 09:32:08 -08:00
ld de, .out_of_20
2015-11-11 20:38:57 -08:00
call PlaceString
ret
; e3663
2015-12-16 09:32:08 -08:00
.Pokemon: ; e3663
2015-11-11 20:38:57 -08:00
db "#MON@"
; e3668
.out_of_20 ; e3668
2015-11-11 20:38:57 -08:00
; db "/20@"
db "/"
db "0" + MONS_PER_BOX / 10 ; "2"
db "0" + MONS_PER_BOX % 10 ; "0"
db "@"
; e366c
GetBoxCount: ; e366c (38:766c)
ld a, [wCurBox]
ld c, a
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-11-11 20:38:57 -08:00
dec a
cp c
jr z, .activebox
ld c, a
ld b, 0
ld hl, .boxbanks
add hl, bc
add hl, bc
add hl, bc
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld b, a
call GetSRAMBank
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [hl]
call CloseSRAM
ld c, a
ld a, [wSavedAtLeastOnce]
and a
jr z, .newfile
ld a, c
ret
.newfile
xor a
ret
.activebox
ld a, BANK(sBoxCount)
ld b, a
call GetSRAMBank
ld hl, sBoxCount
ld a, [hl]
call CloseSRAM
ret
; e36a5 (38:76a5)
.boxbanks ; e36a5
2015-11-11 20:38:57 -08:00
dba sBox1
dba sBox2
dba sBox3
dba sBox4
dba sBox5
dba sBox6
dba sBox7
dba sBox8
dba sBox9
dba sBox10
dba sBox11
dba sBox12
dba sBox13
dba sBox14
; e36cf
2015-12-16 09:32:08 -08:00
BillsPC_PrintBoxName: ; e36cf (38:76cf)
2015-11-11 20:38:57 -08:00
hlcoord 0, 0
ld b, 2
ld c, 18
call TextBox
hlcoord 1, 2
2015-12-16 09:32:08 -08:00
ld de, .Current
2015-11-11 20:38:57 -08:00
call PlaceString
ld a, [wCurBox]
and $f
call GetBoxName
hlcoord 11, 2
call PlaceString
ret
; e36f1 (38:76f1)
2015-12-16 09:32:08 -08:00
.Current: ; e36f1
2015-11-11 20:38:57 -08:00
db "CURRENT@"
; e36f9
2015-12-16 09:32:08 -08:00
BillsPC_ChangeBoxSubmenu: ; e36f9 (38:76f9)
ld hl, .MenuHeader
call LoadMenuHeader
2015-12-15 15:59:49 -08:00
call VerticalMenu
2015-11-11 20:38:57 -08:00
call ExitMenu
ret c
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-11-11 20:38:57 -08:00
cp $1
2015-11-22 21:21:21 -08:00
jr z, .Switch
2015-11-11 20:38:57 -08:00
cp $2
2015-11-22 21:21:21 -08:00
jr z, .Name
2015-11-11 20:38:57 -08:00
cp $3
2015-11-22 21:21:21 -08:00
jr z, .Print
2015-11-11 20:38:57 -08:00
and a
ret
.Print:
2015-11-11 20:38:57 -08:00
call GetBoxCount
and a
2015-11-22 21:21:21 -08:00
jr z, .EmptyBox
2015-11-11 20:38:57 -08:00
ld e, l
ld d, h
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-11-11 20:38:57 -08:00
dec a
ld c, a
2017-12-24 09:47:30 -08:00
farcall PrintPCBox
2015-12-16 09:32:08 -08:00
call BillsPC_ClearTilemap
2015-11-11 20:38:57 -08:00
and a
ret
.EmptyBox:
2015-12-16 09:32:08 -08:00
call BillsPC_PlaceEmptyBoxString_SFX
2015-11-11 20:38:57 -08:00
and a
ret
.Switch:
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-11-11 20:38:57 -08:00
dec a
ld e, a
ld a, [wCurBox]
cp e
ret z
2017-12-24 09:47:30 -08:00
farcall ChangeBoxSaveGame
2015-11-11 20:38:57 -08:00
ret
.Name:
2015-11-22 21:21:21 -08:00
ld b, $4 ; box
2015-11-11 20:38:57 -08:00
ld de, wd002
2017-12-24 09:47:30 -08:00
farcall NamingScreen
2015-11-11 20:38:57 -08:00
call ClearTileMap
call LoadStandardFont
call LoadFontsBattleExtra
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-11-11 20:38:57 -08:00
dec a
call GetBoxName
ld e, l
ld d, h
ld hl, wd002
2015-12-16 09:32:08 -08:00
ld c, BOX_NAME_LENGTH - 1
2015-11-11 20:38:57 -08:00
call InitString
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-11-11 20:38:57 -08:00
dec a
call GetBoxName
ld de, wd002
call CopyName2
ret
; e3778 (38:7778)
hlcoord 11, 7 ; unused
2015-11-11 20:38:57 -08:00
.MenuHeader: ; 0xe377b
db MENU_BACKUP_TILES ; flags
menu_coords 11, 4, SCREEN_WIDTH - 1, 13
dw .MenuData
2015-11-11 20:38:57 -08:00
db 1 ; default option
; 0xe3783
.MenuData: ; 0xe3783
db STATICMENU_CURSOR ; flags
2015-11-11 20:38:57 -08:00
db 4 ; items
db "SWITCH@"
db "NAME@"
db "PRINT@"
db "QUIT@"
; 0xe379c
2015-12-16 09:32:08 -08:00
BillsPC_PlaceChooseABoxString: ; e379c (38:779c)
ld de, .ChooseABox
jr BillsPC_PlaceChangeBoxString
2015-11-11 20:38:57 -08:00
; e37a1 (38:77a1)
2015-12-16 09:32:08 -08:00
.ChooseABox: ; e37a1
2015-11-11 20:38:57 -08:00
db "Choose a BOX.@"
; e37af
2015-12-16 09:32:08 -08:00
BillsPC_PlaceWhatsUpString: ; e37af (38:77af)
ld de, .WhatsUp
jr BillsPC_PlaceChangeBoxString
2015-11-11 20:38:57 -08:00
; e37b4 (38:77b4)
2015-12-16 09:32:08 -08:00
.WhatsUp: ; e37b4
2015-11-11 20:38:57 -08:00
db "What's up?@"
; e37be
2015-12-16 09:32:08 -08:00
BillsPC_PlaceEmptyBoxString_SFX: ; e37be (38:77be)
ld de, .NoMonString
call BillsPC_PlaceChangeBoxString
2015-11-11 20:38:57 -08:00
ld de, SFX_WRONG
call WaitPlaySFX
call WaitSFX
ld c, 50
call DelayFrames
ret
; e37d3 (38:77d3)
2015-12-16 09:32:08 -08:00
.NoMonString: ; e37d3
2015-11-11 20:38:57 -08:00
db "There's no #MON.@"
; e37e3
2015-12-16 09:32:08 -08:00
BillsPC_PlaceChangeBoxString: ; e37e3 (38:77e3)
2015-11-11 20:38:57 -08:00
push de
hlcoord 0, 14
lb bc, 2, 18
call TextBox
pop de
hlcoord 1, 16
call PlaceString
ld a, $1
ld [hBGMapMode], a
ret