pokecrystal-board/engine/pokemon/mon_menu.asm

291 lines
4.0 KiB
NASM
Raw Normal View History

2018-01-23 07:46:26 -08:00
INCLUDE "data/mon_menu.asm"
2015-12-13 14:11:58 -08:00
2018-06-24 07:09:41 -07:00
MonSubmenu:
2015-12-13 14:11:58 -08:00
xor a
ld [hBGMapMode], a
call GetMonSubmenuItems
2017-12-24 09:47:30 -08:00
farcall FreezeMonIcons
ld hl, .MenuHeader
call LoadMenuHeader
2015-12-13 14:11:58 -08:00
call .GetTopCoord
call PopulateMonMenu
ld a, 1
ld [hBGMapMode], a
call MonMenuLoop
2018-01-23 14:39:09 -08:00
ld [wMenuSelection], a
2015-12-13 14:11:58 -08:00
call ExitMenu
ret
2018-06-24 07:09:41 -07:00
.MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 6, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
2015-12-13 14:11:58 -08:00
dw 0
db 1 ; default option
2018-06-24 07:09:41 -07:00
.GetTopCoord:
2015-12-13 14:11:58 -08:00
; TopCoord = 1 + BottomCoord - 2 * (NumSubmenuItems + 1)
2018-01-23 14:39:09 -08:00
ld a, [wBuffer1]
2015-12-13 14:11:58 -08:00
inc a
add a
ld b, a
ld a, [wMenuBorderBottomCoord]
sub b
inc a
ld [wMenuBorderTopCoord], a
call MenuBox
ret
2018-06-24 07:09:41 -07:00
MonMenuLoop:
2015-12-13 14:11:58 -08:00
.loop
ld a, MENU_UNUSED_3 | MENU_BACKUP_TILES_2 ; flags
ld [wMenuDataFlags], a
2018-01-23 14:39:09 -08:00
ld a, [wBuffer1] ; items
ld [wMenuDataItems], a
2015-12-15 15:59:49 -08:00
call InitVerticalMenuCursor
ld hl, w2DMenuFlags1
2015-12-13 14:11:58 -08:00
set 6, [hl]
2015-12-15 15:59:49 -08:00
call StaticMenuJoypad
2015-12-13 14:11:58 -08:00
ld de, SFX_READ_TEXT_2
call PlaySFX
ld a, [hJoyPressed]
2017-12-30 09:35:50 -08:00
bit A_BUTTON_F, a
2015-12-13 14:11:58 -08:00
jr nz, .select
2017-12-30 09:35:50 -08:00
bit B_BUTTON_F, a
2015-12-13 14:11:58 -08:00
jr nz, .cancel
jr .loop
.cancel
2018-01-23 07:46:26 -08:00
ld a, MONMENUITEM_CANCEL
2015-12-13 14:11:58 -08:00
ret
.select
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-12-13 14:11:58 -08:00
dec a
ld c, a
ld b, 0
2018-01-23 14:39:09 -08:00
ld hl, wBuffer2
2015-12-13 14:11:58 -08:00
add hl, bc
ld a, [hl]
ret
2018-06-24 07:09:41 -07:00
PopulateMonMenu:
2015-12-13 14:11:58 -08:00
call MenuBoxCoord2Tile
2018-01-23 07:46:26 -08:00
ld bc, 2 * SCREEN_WIDTH + 2
2015-12-13 14:11:58 -08:00
add hl, bc
2018-01-23 14:39:09 -08:00
ld de, wBuffer2
2015-12-13 14:11:58 -08:00
.loop
ld a, [de]
inc de
cp -1
ret z
push de
push hl
call GetMonMenuString
pop hl
call PlaceString
2018-01-23 07:46:26 -08:00
ld bc, 2 * SCREEN_WIDTH
2015-12-13 14:11:58 -08:00
add hl, bc
pop de
jr .loop
2018-06-24 07:09:41 -07:00
GetMonMenuString:
2015-12-13 14:11:58 -08:00
ld hl, MonMenuOptions + 1
ld de, 3
call IsInArray
dec hl
ld a, [hli]
2018-01-23 07:46:26 -08:00
cp MONMENU_MENUOPTION
2015-12-13 14:11:58 -08:00
jr z, .NotMove
inc hl
ld a, [hl]
ld [wd265], a
call GetMoveName
ret
.NotMove:
2015-12-13 14:11:58 -08:00
inc hl
ld a, [hl]
dec a
ld hl, MonMenuOptionStrings
call GetNthString
ld d, h
ld e, l
ret
2018-06-24 07:09:41 -07:00
GetMonSubmenuItems:
2015-12-13 14:11:58 -08:00
call ResetMonSubmenu
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
2015-12-13 14:11:58 -08:00
cp EGG
jr z, .egg
ld a, [wLinkMode]
and a
jr nz, .skip_moves
ld a, MON_MOVES
call GetPartyParamLocation
ld d, h
ld e, l
ld c, NUM_MOVES
.loop
push bc
push de
ld a, [de]
and a
jr z, .next
push hl
call IsFieldMove
pop hl
jr nc, .next
call AddMonMenuItem
.next
pop de
inc de
pop bc
dec c
jr nz, .loop
.skip_moves
2018-01-23 07:46:26 -08:00
ld a, MONMENUITEM_STATS
2015-12-13 14:11:58 -08:00
call AddMonMenuItem
2018-01-23 07:46:26 -08:00
ld a, MONMENUITEM_SWITCH
2015-12-13 14:11:58 -08:00
call AddMonMenuItem
2018-01-23 07:46:26 -08:00
ld a, MONMENUITEM_MOVE
2015-12-13 14:11:58 -08:00
call AddMonMenuItem
ld a, [wLinkMode]
and a
jr nz, .skip2
push hl
ld a, MON_ITEM
call GetPartyParamLocation
ld d, [hl]
2017-12-24 09:47:30 -08:00
farcall ItemIsMail
2015-12-13 14:11:58 -08:00
pop hl
2018-01-23 07:46:26 -08:00
ld a, MONMENUITEM_MAIL
2015-12-13 14:11:58 -08:00
jr c, .ok
2018-01-23 07:46:26 -08:00
ld a, MONMENUITEM_ITEM
2015-12-13 14:11:58 -08:00
.ok
call AddMonMenuItem
.skip2
2018-01-23 14:39:09 -08:00
ld a, [wBuffer1]
cp NUM_MONMENU_ITEMS
2015-12-13 14:11:58 -08:00
jr z, .ok2
2018-01-23 07:46:26 -08:00
ld a, MONMENUITEM_CANCEL
2015-12-13 14:11:58 -08:00
call AddMonMenuItem
.ok2
call TerminateMonSubmenu
ret
.egg
2018-01-23 07:46:26 -08:00
ld a, MONMENUITEM_STATS
2015-12-13 14:11:58 -08:00
call AddMonMenuItem
2018-01-23 07:46:26 -08:00
ld a, MONMENUITEM_SWITCH
2015-12-13 14:11:58 -08:00
call AddMonMenuItem
2018-01-23 07:46:26 -08:00
ld a, MONMENUITEM_CANCEL
2015-12-13 14:11:58 -08:00
call AddMonMenuItem
call TerminateMonSubmenu
ret
2018-06-24 07:09:41 -07:00
IsFieldMove:
2015-12-13 14:11:58 -08:00
ld b, a
ld hl, MonMenuOptions
.next
ld a, [hli]
cp -1
jr z, .nope
cp MONMENU_MENUOPTION
jr z, .nope
ld d, [hl]
inc hl
ld a, [hli]
cp b
jr nz, .next
ld a, d
scf
.nope
ret
2018-06-24 07:09:41 -07:00
ResetMonSubmenu:
2015-12-13 14:11:58 -08:00
xor a
2018-01-23 14:39:09 -08:00
ld [wBuffer1], a
ld hl, wBuffer2
ld bc, NUM_MONMENU_ITEMS + 1
2015-12-13 14:11:58 -08:00
call ByteFill
ret
2018-06-24 07:09:41 -07:00
TerminateMonSubmenu:
2018-01-23 14:39:09 -08:00
ld a, [wBuffer1]
2015-12-13 14:11:58 -08:00
ld e, a
2018-01-23 07:46:26 -08:00
ld d, 0
2018-01-23 14:39:09 -08:00
ld hl, wBuffer2
2015-12-13 14:11:58 -08:00
add hl, de
ld [hl], -1
ret
2018-06-24 07:09:41 -07:00
AddMonMenuItem:
2015-12-13 14:11:58 -08:00
push hl
push de
push af
2018-01-23 14:39:09 -08:00
ld a, [wBuffer1]
2015-12-13 14:11:58 -08:00
ld e, a
inc a
2018-01-23 14:39:09 -08:00
ld [wBuffer1], a
2018-01-23 07:46:26 -08:00
ld d, 0
2018-01-23 14:39:09 -08:00
ld hl, wBuffer2
2015-12-13 14:11:58 -08:00
add hl, de
pop af
ld [hl], a
pop de
pop hl
ret
2018-06-24 07:09:41 -07:00
BattleMonMenu:
ld hl, MenuHeader_0x24ed4
call CopyMenuHeader
2015-12-13 14:11:58 -08:00
xor a
ld [hBGMapMode], a
call MenuBox
call UpdateSprites
2015-12-15 15:59:49 -08:00
call PlaceVerticalMenuItems
2015-12-13 14:11:58 -08:00
call WaitBGMap
call CopyMenuData
ld a, [wMenuDataFlags]
2015-12-13 14:11:58 -08:00
bit 7, a
jr z, .set_carry
2015-12-15 15:59:49 -08:00
call InitVerticalMenuCursor
ld hl, w2DMenuFlags1
2015-12-13 14:11:58 -08:00
set 6, [hl]
2015-12-15 15:59:49 -08:00
call StaticMenuJoypad
2015-12-13 14:11:58 -08:00
ld de, SFX_READ_TEXT_2
call PlaySFX
ld a, [hJoyPressed]
bit B_BUTTON_F, a
jr z, .clear_carry
ret z
.set_carry
scf
ret
.clear_carry
and a
ret
2018-06-24 07:09:41 -07:00
MenuHeader_0x24ed4:
db 0 ; flags
menu_coords 11, 11, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw MenuData_0x24edc
2015-12-13 14:11:58 -08:00
db 1 ; default option
2018-06-24 07:09:41 -07:00
MenuData_0x24edc:
db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
2015-12-13 14:11:58 -08:00
db 3 ; items
db "SWITCH@"
db "STATS@"
db "CANCEL@"