pokecrystal-board/engine/pokemon/bills_pc.asm

2488 lines
39 KiB
NASM
Raw Normal View History

2018-06-24 07:09:41 -07:00
_DepositPKMN:
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
ldh a, [hInMenu]
2015-11-11 20:38:57 -08:00
push af
ld a, $1
ldh [hInMenu], a
2015-11-11 20:38:57 -08:00
xor a
ldh [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
ldh [hInMenu], a
2015-11-11 20:38:57 -08:00
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
2018-06-24 07:09:41 -07:00
.RunJumptable:
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
2018-06-24 07:09:41 -07:00
.Jumptable:
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
2018-06-24 07:09:41 -07:00
.Init:
2015-11-11 20:38:57 -08:00
xor a
ldh [hBGMapMode], a
2015-11-11 20:38:57 -08:00
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
ld a, CGB_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
2018-06-24 07:09:41 -07:00
.HandleJoypad:
2018-08-25 11:39:24 -07:00
ld hl, hJoyPressed
2015-11-11 20:38:57 -08:00
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
ldh [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
ldh [hBGMapMode], a
2015-11-11 20:38:57 -08:00
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
.go_back ; unreferenced
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
2018-06-24 07:09:41 -07:00
.WhatsUp:
2015-11-11 20:38:57 -08:00
xor a
ldh [hBGMapMode], a
2015-11-11 20:38:57 -08:00
call ClearSprites
2015-12-16 09:32:08 -08:00
call BillsPC_GetSelectedPokemonSpecies
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
ld a, CGB_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
2018-06-24 07:09:41 -07:00
.Submenu:
ld hl, BillsPCDepositMenuHeader
call CopyMenuHeader
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
call StoreMenuCursorPosition
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
2018-06-24 07:09:41 -07:00
BillsPCDepositJumptable:
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
2018-06-24 07:09:41 -07:00
BillsPCDepositFuncDeposit:
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
2018-06-24 07:09:41 -07:00
BillsPCDepositFuncStats:
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
ld a, CGB_BILLS_PC
2015-12-16 09:32:08 -08:00
call BillsPC_ApplyPalettes
2015-11-11 20:38:57 -08:00
ret
2018-06-24 07:09:41 -07:00
BillsPCDepositFuncRelease:
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
2018-06-24 07:09:41 -07:00
BillsPCDepositFuncCancel:
2015-11-11 20:38:57 -08:00
ld a, $0
ld [wJumptableIndex], a
ret
2018-06-24 18:39:23 -07:00
BillsPCDepositMenuHeader:
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
2018-06-24 18:39:23 -07:00
.MenuData:
db STATICMENU_CURSOR ; flags
2015-11-11 20:38:57 -08:00
db 4 ; items
db "DEPOSIT@"
db "STATS@"
db "RELEASE@"
db "CANCEL@"
BillsPCClearThreeBoxes: ; unreferenced
2015-11-11 20:38:57 -08:00
hlcoord 0, 0
2019-06-04 04:31:22 -07: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
2019-06-04 04:31:22 -07:00
ld c, 9
2015-11-11 20:38:57 -08:00
call ClearBox
hlcoord 0, 14
2019-06-04 04:31:22 -07:00
ld b, 2
ld c, 8
2015-11-11 20:38:57 -08:00
call ClearBox
ret
2018-06-24 07:09:41 -07:00
_WithdrawPKMN:
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
ldh a, [hInMenu]
2015-11-11 20:38:57 -08:00
push af
ld a, $1
ldh [hInMenu], a
2015-11-11 20:38:57 -08:00
xor a
ldh [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
ldh [hInMenu], a
2015-11-11 20:38:57 -08:00
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
2018-06-24 07:09:41 -07:00
.RunJumptable:
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
2018-06-24 07:09:41 -07:00
.Jumptable:
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
2018-06-24 07:09:41 -07:00
.Init:
2015-12-16 09:32:08 -08:00
ld a, NUM_BOXES + 1
ld [wBillsPC_LoadedBox], a
2015-11-11 20:38:57 -08:00
xor a
ldh [hBGMapMode], a
2015-11-11 20:38:57 -08:00
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
ld a, CGB_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
2018-06-24 07:09:41 -07:00
.Joypad:
2018-08-25 11:39:24 -07:00
ld hl, hJoyPressed
2015-11-11 20:38:57 -08:00
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
ldh [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
ldh [hBGMapMode], a
2015-11-11 20:38:57 -08:00
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
2018-06-24 07:09:41 -07:00
ret
2015-11-11 20:38:57 -08:00
.go_back ; unreferenced
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
2018-06-24 07:09:41 -07:00
.PrepSubmenu:
2015-11-11 20:38:57 -08:00
xor a
ldh [hBGMapMode], a
2015-11-11 20:38:57 -08:00
call ClearSprites
2015-12-16 09:32:08 -08:00
call BillsPC_GetSelectedPokemonSpecies
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
ld a, CGB_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
2018-06-24 07:09:41 -07:00
BillsPC_Withdraw:
ld hl, .MenuHeader
call CopyMenuHeader
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
call StoreMenuCursorPosition
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
2018-06-24 18:39:23 -07:00
.dw
2015-11-11 20:38:57 -08:00
dw .withdraw ; Withdraw
dw .stats ; Stats
dw .release ; Release
dw .cancel ; Cancel
2018-06-24 07:09:41 -07:00
.withdraw
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
2018-06-24 07:09:41 -07:00
.stats
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
ld a, CGB_BILLS_PC
2015-12-16 09:32:08 -08:00
call BillsPC_ApplyPalettes
2015-11-11 20:38:57 -08:00
ret
2018-06-24 07:09:41 -07:00
.release
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
2018-06-24 07:09:41 -07:00
.cancel
2015-11-11 20:38:57 -08:00
ld a, $0
ld [wJumptableIndex], a
ret
.MenuHeader:
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
.MenuData:
db STATICMENU_CURSOR ; flags
2015-11-11 20:38:57 -08:00
db 4 ; items
db "WITHDRAW@"
db "STATS@"
db "RELEASE@"
db "CANCEL@"
2018-06-24 07:09:41 -07:00
_MovePKMNWithoutMail:
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
ldh a, [hInMenu]
2015-11-11 20:38:57 -08:00
push af
ld a, $1
ldh [hInMenu], a
2015-11-11 20:38:57 -08:00
xor a
ldh [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
2020-10-04 16:43:28 -07:00
.loop
2015-11-11 20:38:57 -08:00
call JoyTextDelay
ld a, [wJumptableIndex]
bit 7, a
2020-10-04 16:43:28 -07:00
jr nz, .done
2015-12-16 09:32:08 -08:00
call .RunJumptable
2015-11-11 20:38:57 -08:00
call DelayFrame
2020-10-04 16:43:28 -07:00
jr .loop
2015-11-11 20:38:57 -08:00
2020-10-04 16:43:28 -07:00
.done
2015-11-11 20:38:57 -08:00
call ClearSprites
pop af
ldh [hInMenu], a
2015-11-11 20:38:57 -08:00
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
2018-06-24 07:09:41 -07:00
.RunJumptable:
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
2018-06-24 07:09:41 -07:00
.Jumptable:
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
2018-06-24 07:09:41 -07:00
.Init:
2015-11-11 20:38:57 -08:00
xor a
ldh [hBGMapMode], a
2015-11-11 20:38:57 -08:00
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
ld a, CGB_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
2018-06-24 07:09:41 -07:00
.Joypad:
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
ldh [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
ldh [hBGMapMode], a
2015-11-11 20:38:57 -08:00
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
.go_back ; unreferenced
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
2018-06-24 07:09:41 -07:00
.PrepSubmenu:
2015-11-11 20:38:57 -08:00
xor a
ldh [hBGMapMode], a
2015-11-11 20:38:57 -08:00
call ClearSprites
2015-12-16 09:32:08 -08:00
call BillsPC_GetSelectedPokemonSpecies
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
ld a, CGB_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
2018-06-24 07:09:41 -07:00
.MoveMonWOMailSubmenu:
ld hl, .MenuHeader
call CopyMenuHeader
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
call StoreMenuCursorPosition
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
2018-06-24 07:09:41 -07:00
.Jumptable2:
2015-12-16 09:32:08 -08:00
dw .Move
dw .Stats
dw .Cancel
2015-11-11 20:38:57 -08:00
2018-06-24 07:09:41 -07:00
.Move:
2015-12-16 09:32:08 -08:00
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
2018-06-24 07:09:41 -07:00
.Stats:
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
ld a, CGB_BILLS_PC
2015-12-16 09:32:08 -08:00
call BillsPC_ApplyPalettes
2015-11-11 20:38:57 -08:00
ret
2018-06-24 07:09:41 -07:00
.Cancel:
2015-11-11 20:38:57 -08:00
ld a, $0
ld [wJumptableIndex], a
ret
.MenuHeader:
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
.MenuData:
db STATICMENU_CURSOR ; flags
2015-11-11 20:38:57 -08:00
db 3 ; items
db "MOVE@"
db "STATS@"
db "CANCEL@"
2018-06-24 07:09:41 -07:00
.PrepInsertCursor:
2015-11-11 20:38:57 -08:00
xor a
ldh [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
2018-06-24 07:09:41 -07:00
.Joypad2:
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
ldh [hBGMapMode], a
2015-12-16 09:32:08 -08:00
call BillsPC_RefreshTextboxes
2015-11-11 20:38:57 -08:00
ld a, $1
ldh [hBGMapMode], a
2015-11-11 20:38:57 -08:00
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
2022-04-17 08:36:30 -07:00
call MovePKMNWithoutMail_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
2018-06-24 07:09:41 -07:00
BillsPC_InitRAM:
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
2019-04-19 15:55:04 -07:00
ld hl, wBillsPCData
ld bc, wBillsPCDataEnd - wBillsPCData
2015-11-11 20:38:57 -08:00
xor a
call ByteFill
xor a
ld [wJumptableIndex], 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
2018-06-24 07:09:41 -07:00
BillsPC_IncrementJumptableIndex:
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
inc [hl]
ret
2018-06-24 07:09:41 -07:00
BillsPC_EndJumptableLoop:
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
set 7, [hl]
ret
2018-06-24 07:09:41 -07:00
_StatsScreenDPad:
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
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
2018-06-24 07:09:41 -07:00
Withdraw_UpDown:
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
2018-06-24 07:09:41 -07:00
MoveMonWithoutMail_DPad:
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
2018-06-24 07:09:41 -07:00
MoveMonWithoutMail_DPad_2:
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
2018-06-24 07:09:41 -07:00
BillsPC_PressUp:
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
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
2018-06-24 07:09:41 -07:00
BillsPC_PressDown:
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]
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
2018-06-24 07:09:41 -07:00
BillsPC_PressLeft:
2015-12-16 09:32:08 -08:00
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
2018-06-24 07:09:41 -07:00
BillsPC_PressRight:
2015-12-16 09:32:08 -08:00
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
2018-06-24 07:09:41 -07:00
BillsPC_JoypadDidNothing:
2015-11-11 20:38:57 -08:00
xor a
and a
ret
2018-06-24 07:09:41 -07:00
BillsPC_UpDownDidSomething:
2015-12-16 09:32:08 -08:00
ld a, TRUE
2015-11-11 20:38:57 -08:00
and a
ret
2018-06-24 07:09:41 -07:00
BillsPC_LeftRightDidSomething:
2015-11-11 20:38:57 -08:00
scf
ret
2018-06-24 07:09:41 -07:00
BillsPC_PlaceString:
2015-11-11 20:38:57 -08:00
push de
hlcoord 0, 15
lb bc, 1, 18
call Textbox1bpp
2015-11-11 20:38:57 -08:00
pop de
hlcoord 1, 16
call PlaceString
ret
2018-06-24 07:09:41 -07:00
BillsPC_MoveMonWOMail_BoxNameAndArrows:
2015-12-16 09:32:08 -08:00
call BillsPC_BoxName
2015-11-11 20:38:57 -08:00
hlcoord 8, 1
ld [hl], $5f
hlcoord 19, 1
ld [hl], $5e
ret
2018-06-24 07:09:41 -07:00
BillsPC_BoxName:
2015-11-11 20:38:57 -08:00
hlcoord 8, 0
lb bc, 1, 10
call Textbox1bpp
2015-11-11 20:38:57 -08:00
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
2015-12-16 09:32:08 -08:00
.PartyPKMN:
2015-11-11 20:38:57 -08:00
db "PARTY <PK><MN>@"
2018-06-24 07:09:41 -07:00
PCMonInfo:
2015-11-11 20:38:57 -08:00
; 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 [wTempSpecies], a
2015-11-11 20:38:57 -08:00
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
ld a, [wTempSpecies]
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]
ld [wTempSpecies], a
2015-11-11 20:38:57 -08:00
cp EGG
ret z
call GetBasePokemonName
hlcoord 1, 14
call PlaceString
hlcoord 1, 12
call PrintLevel
ld a, TEMPMON
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
2018-06-24 07:09:41 -07:00
BillsPC_LoadMonStats:
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]
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 OpenSRAM
2015-11-11 20:38:57 -08:00
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 OpenSRAM
2015-11-11 20:38:57 -08:00
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
2018-06-24 07:09:41 -07:00
BillsPC_RefreshTextboxes:
2015-11-11 20:38:57 -08:00
hlcoord 8, 2
lb bc, 10, 10
call Textbox1bpp
2015-11-11 20:38:57 -08:00
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
2015-12-16 09:32:08 -08:00
.CancelString:
2015-11-11 20:38:57 -08:00
db "CANCEL@"
2018-06-24 07:09:41 -07:00
.PlaceNickname:
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 OpenSRAM
2015-11-11 20:38:57 -08:00
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 OpenSRAM
2015-11-11 20:38:57 -08:00
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
2015-12-16 09:32:08 -08:00
.Placeholder:
2015-11-11 20:38:57 -08:00
db "-----@"
MACRO copy_box_data
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
jr z, .done\@
2015-11-11 20:38:57 -08:00
and a
2015-12-16 09:32:08 -08:00
jr z, .done\@
ld [de], a ; species
2015-11-11 20:38:57 -08:00
inc de
2015-12-16 09:32:08 -08:00
ld a, [wBillsPC_LoadedBox]
ld [de], a ; box number
2015-11-11 20:38:57 -08:00
inc de
ld a, [wBillsPCTempListIndex]
ld [de], a ; list index
2015-11-11 20:38:57 -08:00
inc a
ld [wBillsPCTempListIndex], a
2015-11-11 20:38:57 -08:00
inc de
inc hl
ld a, [wBillsPCTempBoxCount]
2015-11-11 20:38:57 -08:00
inc a
ld [wBillsPCTempBoxCount], 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
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, [wBillsPCTempBoxCount]
2015-11-11 20:38:57 -08:00
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
2018-06-24 07:09:41 -07:00
CopyBoxmonSpecies:
2015-12-16 09:32:08 -08:00
xor a
ld hl, wBillsPCPokemonList
ld bc, 3 * 30
call ByteFill
ld de, wBillsPCPokemonList
xor a
ld [wBillsPCTempListIndex], a
ld [wBillsPCTempBoxCount], 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 OpenSRAM
2015-12-16 09:32:08 -08:00
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 OpenSRAM
2015-11-11 20:38:57 -08:00
ld hl, sBoxSpecies
2015-12-16 09:32:08 -08:00
copy_box_data 1
2015-11-11 20:38:57 -08:00
ret
2018-06-24 07:09:41 -07:00
BillsPC_GetSelectedPokemonSpecies:
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]
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
2018-06-24 07:09:41 -07:00
BillsPC_UpdateSelectionCursor:
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 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
ld de, wShadowOAMSprite00
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
2018-06-24 07:09:41 -07:00
.OAM:
dbsprite 10, 4, 0, 6, $00, 0
dbsprite 11, 4, 0, 6, $00, 0
dbsprite 12, 4, 0, 6, $00, 0
dbsprite 13, 4, 0, 6, $00, 0
dbsprite 14, 4, 0, 6, $00, 0
dbsprite 15, 4, 0, 6, $00, 0
dbsprite 16, 4, 0, 6, $00, 0
dbsprite 17, 4, 0, 6, $00, 0
dbsprite 18, 4, 0, 6, $00, 0
dbsprite 18, 4, 7, 6, $00, 0
dbsprite 10, 7, 0, 1, $00, 0 | Y_FLIP
dbsprite 11, 7, 0, 1, $00, 0 | Y_FLIP
dbsprite 12, 7, 0, 1, $00, 0 | Y_FLIP
dbsprite 13, 7, 0, 1, $00, 0 | Y_FLIP
dbsprite 14, 7, 0, 1, $00, 0 | Y_FLIP
dbsprite 15, 7, 0, 1, $00, 0 | Y_FLIP
dbsprite 16, 7, 0, 1, $00, 0 | Y_FLIP
dbsprite 17, 7, 0, 1, $00, 0 | Y_FLIP
dbsprite 18, 7, 0, 1, $00, 0 | Y_FLIP
dbsprite 18, 7, 7, 1, $00, 0 | Y_FLIP
dbsprite 9, 5, 6, 6, $01, 0
dbsprite 9, 6, 6, 1, $01, 0 | Y_FLIP
dbsprite 19, 5, 1, 6, $01, 0 | X_FLIP
dbsprite 19, 6, 1, 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
2018-06-24 07:09:41 -07:00
BillsPC_UpdateInsertCursor:
2015-12-16 09:32:08 -08:00
ld hl, .OAM
ld de, wShadowOAMSprite00
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
2018-06-24 07:09:41 -07:00
.OAM:
dbsprite 10, 4, 0, 7, $06, 0
dbsprite 11, 5, 0, 3, $00, 0 | Y_FLIP
dbsprite 12, 5, 0, 3, $00, 0 | Y_FLIP
dbsprite 13, 5, 0, 3, $00, 0 | Y_FLIP
dbsprite 14, 5, 0, 3, $00, 0 | Y_FLIP
dbsprite 15, 5, 0, 3, $00, 0 | Y_FLIP
dbsprite 16, 5, 0, 3, $00, 0 | Y_FLIP
dbsprite 17, 5, 0, 3, $00, 0 | Y_FLIP
dbsprite 18, 5, 0, 3, $00, 0 | Y_FLIP
dbsprite 19, 4, 0, 7, $07, 0
2015-12-16 09:32:08 -08:00
db -1
2015-11-11 20:38:57 -08:00
2018-06-24 07:09:41 -07:00
BillsPC_CheckSpaceInDestination:
2015-12-16 09:32:08 -08:00
; 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
2018-06-24 07:09:41 -07:00
BillsPC_CheckMail_PreventBlackout:
2015-12-16 09:32:08 -08:00
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
2018-06-24 07:09:41 -07:00
BillsPC_IsMonAnEgg:
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
2018-06-24 07:09:41 -07:00
BillsPC_StatsScreen:
2015-11-11 20:38:57 -08:00
call LowVolume
2015-12-16 09:32:08 -08:00
call BillsPC_CopyMon
ld a, TEMPMON
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
2018-06-24 07:09:41 -07:00
StatsScreenDPad:
2018-08-25 11:39:24 -07:00
ld hl, hJoyPressed
2015-11-11 20:38:57 -08:00
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
ld [wTempSpecies], a
2015-12-16 09:32:08 -08:00
call BillsPC_LoadMonStats
ld a, [wTempSpecies]
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
2018-06-24 07:09:41 -07:00
BillsPC_CopyMon:
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-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 OpenSRAM
2015-11-11 20:38:57 -08:00
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
ld hl, sBoxMonOTs
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
ld hl, wPartyMonOTs
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 OpenSRAM
2015-11-11 20:38:57 -08:00
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
ld bc, sBoxMonOTs - 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
2018-06-24 07:09:41 -07:00
DepositPokemon:
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 hl, wPartyMonNicknames
ld a, [wCurPartyMon]
call GetNickname
2015-11-11 20:38:57 -08:00
ld a, PC_DEPOSIT
ld [wPokemonWithdrawDepositParameter], a
predef SendGetMonIntoFromBox
2020-10-06 10:50:02 -07:00
jr c, .BoxFull
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 Textbox1bpp
2015-11-11 20:38:57 -08:00
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
2020-10-06 10:50:02 -07:00
.BoxFull:
2015-11-11 20:38:57 -08:00
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
2018-06-24 07:09:41 -07:00
TryWithdrawPokemon:
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 OpenSRAM
2018-01-23 14:39:09 -08:00
ld a, [wCurPartyMon]
2015-11-11 20:38:57 -08:00
ld hl, sBoxMonNicknames
call GetNickname
2015-11-11 20:38:57 -08:00
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 Textbox1bpp
2015-11-11 20:38:57 -08:00
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
2019-06-04 04:31:22 -07:00
ld a, "!"
2015-11-11 20:38:57 -08:00
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
2018-06-24 07:09:41 -07:00
ReleasePKMN_ByePKMN:
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 Textbox1bpp
2015-11-11 20:38:57 -08:00
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]
ld [wTempSpecies], a
2015-11-11 20:38:57 -08:00
call GetPokemonName
hlcoord 1, 16
ld de, PCString_ReleasedPKMN
call PlaceString
ld c, 80
call DelayFrames
hlcoord 0, 15
lb bc, 1, 18
call Textbox1bpp
2015-11-11 20:38:57 -08:00
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
2019-06-04 04:31:22 -07:00
ld [hl], "!"
2015-11-11 20:38:57 -08:00
ld c, 50
call DelayFrames
ret
2022-04-17 08:36:30 -07:00
MovePKMNWithoutMail_InsertMon:
2015-11-11 20:38:57 -08:00
push hl
push de
push bc
push af
hlcoord 0, 15
lb bc, 1, 18
call Textbox1bpp
2015-11-11 20:38:57 -08:00
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
2018-06-24 07:09:41 -07:00
.dw_return
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
2015-12-16 09:32:08 -08:00
.Saving_LeaveOn:
2015-11-11 20:38:57 -08:00
db "Saving… Leave ON!@"
2018-06-24 07:09:41 -07:00
.Jumptable:
2015-12-26 18:59:03 -08:00
dw .BoxToBox
dw .PartyToBox
dw .BoxToParty
dw .PartyToParty
2015-11-11 20:38:57 -08:00
2018-06-24 07:09:41 -07:00
.BoxToBox:
2015-12-16 09:32:08 -08:00
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
2018-06-24 07:09:41 -07:00
.PartyToBox:
2015-12-16 09:32:08 -08:00
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
2018-06-24 07:09:41 -07:00
.BoxToParty:
2015-12-16 09:32:08 -08:00
call .CopyFromBox
call .CopyToParty
2015-11-11 20:38:57 -08:00
ret
2018-06-24 07:09:41 -07:00
.PartyToParty:
2015-12-16 09:32:08 -08:00
call .CopyFromParty
call .CheckTrivialMove
call .CopyToParty
2015-11-11 20:38:57 -08:00
ret
2018-06-24 07:09:41 -07:00
.CheckTrivialMove:
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]
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
2018-06-24 07:09:41 -07:00
.CopyFromBox:
2015-12-16 09:32:08 -08:00
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)
call OpenSRAM
2015-11-11 20:38:57 -08:00
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
ld hl, sBoxMonOTs
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
2018-06-24 07:09:41 -07:00
.CopyToBox:
2015-12-16 09:32:08 -08:00
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
2018-06-24 07:09:41 -07:00
.CopyFromParty:
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 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
ld hl, wPartyMonOTs
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
2018-06-24 07:09:41 -07:00
.CopyToParty:
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 InsertPokemonIntoParty
2015-11-11 20:38:57 -08:00
ret
2018-06-24 07:09:41 -07:00
CopySpeciesToTemp:
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
2015-11-11 20:38:57 -08:00
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
2018-06-24 07:09:41 -07:00
CopyNicknameToTemp:
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
ld de, wBufferMonNickname
2018-01-20 09:25:55 -08:00
ld bc, MON_NAME_LENGTH
2015-11-11 20:38:57 -08:00
call CopyBytes
ret
2018-06-24 07:09:41 -07:00
CopyOTNameToTemp:
2015-11-17 20:29:14 -08:00
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
2018-06-24 07:09:41 -07:00
CopyMonToTemp:
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
2018-06-24 07:09:41 -07:00
GetBoxPointer:
2015-11-11 20:38:57 -08:00
dec b
ld c, b
ld b, 0
ld hl, .BoxBankAddresses
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
.BoxBankAddresses:
table_width 3, GetBoxPointer.BoxBankAddresses
for n, 1, NUM_BOXES + 1
dba sBox{d:n}
endr
assert_table_length NUM_BOXES
2015-11-11 20:38:57 -08:00
2018-06-24 07:09:41 -07:00
BillsPC_ApplyPalettes:
2015-11-11 20:38:57 -08:00
ld b, a
call GetCGBLayout
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
2018-06-24 07:09:41 -07:00
BillsPC_Jumptable:
2015-11-11 20:38:57 -08:00
ld e, a
ld d, 0
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
ret
2018-06-24 07:09:41 -07:00
BillsPC_InitGFX:
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
PCSelectLZ: INCBIN "gfx/pc/pc.2bpp.lz"
PCMailGFX: INCBIN "gfx/pc/pc_mail.2bpp"
2015-11-11 20:38:57 -08:00
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.@" ; unreferenced
2015-11-11 20:38:57 -08:00
PCString_BoxFull: db "The BOX is full.@"
PCString_PartyFull: db "The party's full!@"
PCString_NoReleasingEGGS: db "No releasing EGGS!@"
2018-06-24 07:09:41 -07:00
_ChangeBox:
call LoadStandardMenuHeader
2015-12-16 09:32:08 -08:00
call BillsPC_ClearTilemap
2015-11-11 20:38:57 -08:00
.loop
xor a
ldh [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 Textbox1bpp
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
2018-06-24 07:09:41 -07:00
BillsPC_ClearTilemap:
2015-11-11 20:38:57 -08:00
xor a
ldh [hBGMapMode], a
2015-11-11 20:38:57 -08:00
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, " "
call ByteFill
ret
_ChangeBox_MenuHeader:
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
.MenuData:
db SCROLLINGMENU_CALL_FUNCTION3_NO_SWITCH | SCROLLINGMENU_ENABLE_FUNCTION3 ; flags
db 4, 0 ; rows, columns
db SCROLLINGMENU_ITEMS_NORMAL ; item format
dba .Boxes
dba .PrintBoxNames
2015-11-11 20:38:57 -08:00
dba NULL
2015-12-16 09:32:08 -08:00
dba BillsPC_PrintBoxCountAndCapacity
2015-11-11 20:38:57 -08:00
.Boxes:
2015-11-11 20:38:57 -08:00
db NUM_BOXES
2021-04-19 13:31:37 -07:00
for x, NUM_BOXES
db x + 1
2015-11-11 20:38:57 -08:00
endr
db -1
.PrintBoxNames:
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
2018-06-24 07:09:41 -07:00
GetBoxName:
2015-11-11 20:38:57 -08:00
ld bc, BOX_NAME_LENGTH
ld hl, wBoxNames
call AddNTimes
ld d, h
ld e, l
ret
2018-06-24 07:09:41 -07:00
BillsPC_PrintBoxCountAndCapacity:
2015-11-11 20:38:57 -08:00
hlcoord 11, 7
lb bc, 5, 7
call Textbox1bpp
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 [wTextDecimalByte], a
2015-11-11 20:38:57 -08:00
hlcoord 13, 11
ld de, wTextDecimalByte
2015-11-11 20:38:57 -08:00
lb bc, 1, 2
call PrintNum
ld de, .OutOf20
2015-11-11 20:38:57 -08:00
call PlaceString
ret
2018-06-24 07:09:41 -07:00
.Pokemon:
2015-11-11 20:38:57 -08:00
db "#MON@"
.OutOf20:
db "/{d:MONS_PER_BOX}@" ; "/20@"
2015-11-11 20:38:57 -08:00
2018-06-24 07:09:41 -07:00
GetBoxCount:
2015-11-11 20:38:57 -08:00
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, .BoxBankAddresses
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
call OpenSRAM
2015-11-11 20:38:57 -08:00
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 OpenSRAM
2015-11-11 20:38:57 -08:00
ld hl, sBoxCount
ld a, [hl]
call CloseSRAM
ret
.BoxBankAddresses:
table_width 3, GetBoxCount.BoxBankAddresses
for n, 1, NUM_BOXES + 1
dba sBox{d:n}
endr
assert_table_length NUM_BOXES
2015-11-11 20:38:57 -08:00
2018-06-24 07:09:41 -07:00
BillsPC_PrintBoxName:
2015-11-11 20:38:57 -08:00
hlcoord 0, 0
ld b, 2
ld c, 18
call Textbox1bpp
2015-11-11 20:38:57 -08:00
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
2018-06-24 07:09:41 -07:00
.Current:
2015-11-11 20:38:57 -08:00
db "CURRENT@"
2018-06-24 07:09:41 -07:00
BillsPC_ChangeBoxSubmenu:
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:
2018-09-16 13:02:58 -07:00
ld b, NAME_BOX
ld de, wBoxNameBuffer
2017-12-24 09:47:30 -08:00
farcall NamingScreen
call ClearTilemap
2015-11-11 20:38:57 -08:00
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, wBoxNameBuffer
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, wBoxNameBuffer
2015-11-11 20:38:57 -08:00
call CopyName2
ret
hlcoord 11, 7 ; unreferenced
2015-11-11 20:38:57 -08:00
.MenuHeader:
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
.MenuData:
db STATICMENU_CURSOR ; flags
2015-11-11 20:38:57 -08:00
db 4 ; items
db "SWITCH@"
db "NAME@"
db "PRINT@"
db "QUIT@"
2018-06-24 07:09:41 -07:00
BillsPC_PlaceChooseABoxString:
2015-12-16 09:32:08 -08:00
ld de, .ChooseABox
jr BillsPC_PlaceChangeBoxString
2015-11-11 20:38:57 -08:00
2018-06-24 07:09:41 -07:00
.ChooseABox:
2015-11-11 20:38:57 -08:00
db "Choose a BOX.@"
2018-06-24 07:09:41 -07:00
BillsPC_PlaceWhatsUpString:
2015-12-16 09:32:08 -08:00
ld de, .WhatsUp
jr BillsPC_PlaceChangeBoxString
2015-11-11 20:38:57 -08:00
2018-06-24 07:09:41 -07:00
.WhatsUp:
2015-11-11 20:38:57 -08:00
db "What's up?@"
2018-06-24 07:09:41 -07:00
BillsPC_PlaceEmptyBoxString_SFX:
2015-12-16 09:32:08 -08:00
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
2018-06-24 07:09:41 -07:00
.NoMonString:
2015-11-11 20:38:57 -08:00
db "There's no #MON.@"
2018-06-24 07:09:41 -07:00
BillsPC_PlaceChangeBoxString:
2015-11-11 20:38:57 -08:00
push de
hlcoord 0, 14
lb bc, 2, 18
call Textbox1bpp
2015-11-11 20:38:57 -08:00
pop de
hlcoord 1, 16
call PlaceString
ld a, $1
ldh [hBGMapMode], a
2015-11-11 20:38:57 -08:00
ret