pokecrystal/engine/overworld/select_menu.asm

173 lines
2.3 KiB
NASM
Raw Normal View History

2018-06-24 14:09:41 +00:00
SelectMenu::
2015-11-11 21:11:08 +00:00
call CheckRegisteredItem
jr c, .NotRegistered
jp UseRegisteredItem
.NotRegistered:
2015-12-09 23:25:44 +00:00
call OpenText
ld b, BANK(MayRegisterItemText)
ld hl, MayRegisterItemText
2015-11-11 21:11:08 +00:00
call MapTextbox
2015-11-25 15:16:29 +00:00
call WaitButton
jp CloseText
2015-11-11 21:11:08 +00:00
MayRegisterItemText:
text_far _MayRegisterItemText
text_end
2015-11-11 21:11:08 +00:00
2018-06-24 14:09:41 +00:00
CheckRegisteredItem:
2018-01-23 22:39:09 +00:00
ld a, [wWhichRegisteredItem]
2015-11-11 21:11:08 +00:00
and a
jr z, .NoRegisteredItem
and REGISTERED_POCKET
rlca
rlca
ld hl, .Pockets
rst JumpTable
ret
.Pockets:
2018-01-26 03:19:24 +00:00
; entries correspond to *_POCKET constants
2015-11-11 21:11:08 +00:00
dw .CheckItem
dw .CheckBall
dw .CheckKeyItem
dw .CheckTMHM
.CheckItem:
2018-01-23 22:39:09 +00:00
ld hl, wNumItems
2015-11-11 21:11:08 +00:00
call .CheckRegisteredNo
jr c, .NoRegisteredItem
inc hl
ld e, a
ld d, 0
add hl, de
add hl, de
2015-11-11 21:11:08 +00:00
call .IsSameItem
jr c, .NoRegisteredItem
and a
ret
.CheckKeyItem:
2018-01-23 22:39:09 +00:00
ld a, [wRegisteredItem]
ld hl, wKeyItems
2015-11-11 21:11:08 +00:00
ld de, 1
call IsInArray
jr nc, .NoRegisteredItem
2018-01-23 22:39:09 +00:00
ld a, [wRegisteredItem]
ld [wCurItem], a
2015-11-11 21:11:08 +00:00
and a
ret
.CheckBall:
2018-01-23 22:39:09 +00:00
ld hl, wNumBalls
2015-11-11 21:11:08 +00:00
call .CheckRegisteredNo
jr nc, .NoRegisteredItem
inc hl
ld e, a
ld d, 0
add hl, de
add hl, de
2015-11-11 21:11:08 +00:00
call .IsSameItem
jr c, .NoRegisteredItem
ret
.CheckTMHM:
2015-11-11 21:11:08 +00:00
jr .NoRegisteredItem
.NoRegisteredItem:
2015-11-11 21:11:08 +00:00
xor a
2018-01-23 22:39:09 +00:00
ld [wWhichRegisteredItem], a
ld [wRegisteredItem], a
2015-11-11 21:11:08 +00:00
scf
ret
2018-06-24 14:09:41 +00:00
.CheckRegisteredNo:
2018-01-23 22:39:09 +00:00
ld a, [wWhichRegisteredItem]
2015-11-11 21:11:08 +00:00
and REGISTERED_NUMBER
dec a
cp [hl]
jr nc, .NotEnoughItems
2018-01-23 22:39:09 +00:00
ld [wCurItemQuantity], a
2015-11-11 21:11:08 +00:00
and a
ret
.NotEnoughItems:
2015-11-11 21:11:08 +00:00
scf
ret
2018-06-24 14:09:41 +00:00
.IsSameItem:
2018-01-23 22:39:09 +00:00
ld a, [wRegisteredItem]
2015-11-11 21:11:08 +00:00
cp [hl]
jr nz, .NotSameItem
2018-01-23 22:39:09 +00:00
ld [wCurItem], a
2015-11-11 21:11:08 +00:00
and a
ret
.NotSameItem:
2015-11-11 21:11:08 +00:00
scf
ret
2018-06-24 14:09:41 +00:00
UseRegisteredItem:
2017-12-24 17:47:30 +00:00
farcall CheckItemMenu
ld a, [wItemAttributeValue]
2015-11-11 21:11:08 +00:00
ld hl, .SwitchTo
rst JumpTable
ret
.SwitchTo:
2018-01-26 03:19:24 +00:00
; entries correspond to ITEMMENU_* constants
2015-11-11 21:11:08 +00:00
dw .CantUse
dw .NoFunction
dw .NoFunction
dw .NoFunction
dw .Current
dw .Party
dw .Overworld
2018-06-24 14:09:41 +00:00
.NoFunction:
2015-12-09 23:25:44 +00:00
call OpenText
2015-11-11 21:11:08 +00:00
call CantUseItem
2015-11-25 15:16:29 +00:00
call CloseText
2015-11-11 21:11:08 +00:00
and a
ret
2018-06-24 14:09:41 +00:00
.Current:
2015-12-09 23:25:44 +00:00
call OpenText
2015-11-11 21:11:08 +00:00
call DoItemEffect
2015-11-25 15:16:29 +00:00
call CloseText
2015-11-11 21:11:08 +00:00
and a
ret
2018-06-24 14:09:41 +00:00
.Party:
call RefreshScreen
2015-11-11 21:11:08 +00:00
call FadeToMenu
call DoItemEffect
call CloseSubmenu
2015-11-25 15:16:29 +00:00
call CloseText
2015-11-11 21:11:08 +00:00
and a
ret
2018-06-24 14:09:41 +00:00
.Overworld:
call RefreshScreen
2015-11-11 21:11:08 +00:00
ld a, 1
2015-12-17 22:51:32 +00:00
ld [wUsingItemWithSelect], a
2015-11-11 21:11:08 +00:00
call DoItemEffect
xor a
2015-12-17 22:51:32 +00:00
ld [wUsingItemWithSelect], a
ld a, [wItemEffectSucceeded]
2015-11-11 21:11:08 +00:00
cp 1
jr nz, ._cantuse
scf
ld a, HMENURETURN_SCRIPT
ldh [hMenuReturn], a
2015-11-11 21:11:08 +00:00
ret
2018-06-24 14:09:41 +00:00
.CantUse:
call RefreshScreen
2015-11-11 21:11:08 +00:00
._cantuse
call CantUseItem
2015-11-25 15:16:29 +00:00
call CloseText
2015-11-11 21:11:08 +00:00
and a
ret