pokecrystal-board/engine/select_menu.asm
Rangi 32ed487a47 Merge branch 'master' of https://github.com/pret/pokecrystal
# Conflicts:
#	audio/engine.asm
#	constants/gfx_constants.asm
#	constants/map_data_constants.asm
#	constants/pokemon_data_constants.asm
#	constants/sprite_constants.asm
#	constants/wram_constants.asm
#	data/maps/data.asm
#	engine/battle/ai/scoring.asm
#	engine/battle/core.asm
#	engine/battle/effect_commands.asm
#	engine/battle/misc.asm
#	engine/battle_anims/getpokeballwobble.asm
#	engine/breeding.asm
#	engine/buy_sell_toss.asm
#	engine/decorations.asm
#	engine/events/battle_tower/battle_tower.asm
#	engine/events/battle_tower/rules.asm
#	engine/events/buena.asm
#	engine/events/bug_contest/contest_2.asm
#	engine/events/daycare.asm
#	engine/events/dratini.asm
#	engine/events/halloffame.asm
#	engine/events/happiness_egg.asm
#	engine/events/kurt.asm
#	engine/events/lucky_number.asm
#	engine/events/magnet_train.asm
#	engine/events/overworld.asm
#	engine/events/pokerus/pokerus.asm
#	engine/events/print_unown.asm
#	engine/events/print_unown_2.asm
#	engine/events/unown_walls.asm
#	engine/item_effects.asm
#	engine/link.asm
#	engine/mon_menu.asm
#	engine/player_object.asm
#	engine/routines/playslowcry.asm
#	engine/scripting.asm
#	engine/search.asm
#	engine/search2.asm
#	engine/specials.asm
#	engine/start_menu.asm
#	engine/timeset.asm
#	home/battle_vars.asm
#	home/map.asm
#	maps/GoldenrodUndergroundSwitchRoomEntrances.asm
#	maps/IlexForest.asm
#	maps/KrissHouse2F.asm
#	maps/Route39Barn.asm
#	mobile/mobile_12_2.asm
#	mobile/mobile_40.asm
#	mobile/mobile_5f.asm
#	wram.asm
2018-02-03 19:42:56 -05:00

192 lines
2.5 KiB
NASM
Executable File

SelectMenu:: ; 13327
call CheckRegisteredItem
jr c, .NotRegistered
jp UseRegisteredItem
.NotRegistered:
call OpenText
ld b, BANK(ItemMayBeRegisteredText)
ld hl, ItemMayBeRegisteredText
call MapTextbox
call WaitButton
jp CloseText
; 13340
ItemMayBeRegisteredText: ; 13340
text_jump UnknownText_0x1c1cf3
db "@"
; 13345
CheckRegisteredItem: ; 13345
ld a, [wWhichRegisteredItem]
and a
jr z, .NoRegisteredItem
and REGISTERED_POCKET
rlca
rlca
ld hl, .Pockets
rst JumpTable
ret
.Pockets:
; entries correspond to *_POCKET constants
dw .CheckItem
dw .CheckBall
dw .CheckKeyItem
dw .CheckTMHM
.CheckItem:
ld hl, wNumItems
call .CheckRegisteredNo
jr c, .NoRegisteredItem
inc hl
ld e, a
ld d, 0
add hl, de
add hl, de
call .IsSameItem
jr c, .NoRegisteredItem
and a
ret
.CheckKeyItem:
ld a, [wRegisteredItem]
ld hl, wKeyItems
ld de, 1
call IsInArray
jr nc, .NoRegisteredItem
ld a, [wRegisteredItem]
ld [wCurItem], a
and a
ret
.CheckBall:
ld hl, wNumBalls
call .CheckRegisteredNo
jr nc, .NoRegisteredItem
inc hl
ld e, a
ld d, 0
add hl, de
add hl, de
call .IsSameItem
jr c, .NoRegisteredItem
ret
.CheckTMHM:
jr .NoRegisteredItem
.NoRegisteredItem:
xor a
ld [wWhichRegisteredItem], a
ld [wRegisteredItem], a
scf
ret
; 133a6
.CheckRegisteredNo: ; 133a6
ld a, [wWhichRegisteredItem]
and REGISTERED_NUMBER
dec a
cp [hl]
jr nc, .NotEnoughItems
ld [wCurItemQuantity], a
and a
ret
.NotEnoughItems:
scf
ret
; 133b6
.IsSameItem: ; 133b6
ld a, [wRegisteredItem]
cp [hl]
jr nz, .NotSameItem
ld [wCurItem], a
and a
ret
.NotSameItem:
scf
ret
; 133c3
UseRegisteredItem: ; 133c3
farcall CheckItemMenu
ld a, [wItemAttributeParamBuffer]
ld hl, .SwitchTo
rst JumpTable
ret
.SwitchTo:
; entries correspond to ITEMMENU_* constants
dw .CantUse
dw .NoFunction
dw .NoFunction
dw .NoFunction
dw .Current
dw .Party
dw .Overworld
; 133df
.NoFunction: ; 133df
call OpenText
call CantUseItem
call CloseText
and a
ret
; 133ea
.Current: ; 133ea
call OpenText
call DoItemEffect
call CloseText
and a
ret
; 133f5
.Party: ; 133f5
call RefreshScreen
call FadeToMenu
call DoItemEffect
call CloseSubmenu
call CloseText
and a
ret
; 13406
.Overworld: ; 13406
call RefreshScreen
ld a, 1
ld [wUsingItemWithSelect], a
call DoItemEffect
xor a
ld [wUsingItemWithSelect], a
ld a, [wItemEffectSucceeded]
cp 1
jr nz, ._cantuse
scf
ld a, HMENURETURN_SCRIPT
ld [hMenuReturn], a
ret
; 13422
.CantUse: ; 13422
call RefreshScreen
._cantuse
call CantUseItem
call CloseText
and a
ret
; 1342d