More menu-related functions

This commit is contained in:
PikalaxALT 2018-06-06 12:57:48 -04:00
parent 530e3e8069
commit e00b497917
6 changed files with 291 additions and 12 deletions

View File

@ -30,3 +30,4 @@ INCLUDE "constants/serial_constants.asm"
INCLUDE "constants/misc_constants.asm"
INCLUDE "constants/battle_anim_constants.asm"
INCLUDE "constants/menu_constants.asm"

View File

@ -0,0 +1,97 @@
; MenuHeader flags
const_def
shift_const MENU_RESTORE_TILES ; Will be set if MENU_BACKUP_TILES(_2) is set.
shift_const MENU_UNUSED_1
shift_const MENU_UNUSED_2
shift_const MENU_NO_CLICK_SFX
shift_const MENU_SPRITE_ANIMS
shift_const MENU_UNUSED_3
shift_const MENU_BACKUP_TILES
shift_const MENU_BACKUP_TILES_2
; VerticalMenu/DoNthMenu/SetUpMenu/_2DMenu MenuData flags
; Per flag the comment specifies which menus actually implement it
const_def
shift_const STATICMENU_DISABLE_B ; VerticalMenu/_2DMenu
shift_const STATICMENU_ENABLE_SELECT ; VerticalMenu/_2DMenu
shift_const STATICMENU_ENABLE_LEFT_RIGHT ; DoNthMenu/SetUpMenu
shift_const STATICMENU_ENABLE_START ; DoNthMenu/SetUpMenu
shift_const STATICMENU_PLACE_TITLE ; VerticalMenu
shift_const STATICMENU_WRAP ; All
shift_const STATICMENU_NO_TOP_SPACING ; VerticalMenu/_2DMenu
shift_const STATICMENU_CURSOR ; VerticalMenu/_2DMenu
; ScrollingMenu MenuData flags
const_def
shift_const SCROLLINGMENU_CALL_FUNCTION1_CANCEL
shift_const SCROLLINGMENU_CALL_FUNCTION3_NO_SWITCH
shift_const SCROLLINGMENU_ENABLE_LEFT
shift_const SCROLLINGMENU_ENABLE_RIGHT
shift_const SCROLLINGMENU_DISPLAY_ARROWS
shift_const SCROLLINGMENU_ENABLE_FUNCTION3
shift_const SCROLLINGMENU_ENABLE_START
shift_const SCROLLINGMENU_ENABLE_SELECT
; MonMenuOptions indexes (see data/mon_menu.asm)
; used by PokemonActionSubmenu (see engine/menus/start_menu.asm)
const_def 1
; moves
const MONMENUITEM_CUT ; 1
const MONMENUITEM_FLY ; 2
const MONMENUITEM_SURF ; 3
const MONMENUITEM_STRENGTH ; 4
const MONMENUITEM_WATERFALL ; 5
const MONMENUITEM_FLASH ; 6
const MONMENUITEM_WHIRLPOOL ; 7
const MONMENUITEM_DIG ; 8
const MONMENUITEM_TELEPORT ; 9
const MONMENUITEM_SOFTBOILED ; 10
const MONMENUITEM_HEADBUTT ; 11
const MONMENUITEM_ROCKSMASH ; 12
const MONMENUITEM_MILKDRINK ; 13
const MONMENUITEM_SWEETSCENT ; 14
; options
const MONMENUITEM_STATS ; 15
const MONMENUITEM_SWITCH ; 16
const MONMENUITEM_ITEM ; 17
const MONMENUITEM_CANCEL ; 18
const MONMENUITEM_MOVE ; 19
const MONMENUITEM_MAIL ; 20
const MONMENUITEM_ERROR ; 21
; MonMenuOptions categories
MONMENU_FIELD_MOVE EQU 0
MONMENU_MENUOPTION EQU 1
NUM_MONMENU_ITEMS EQU 8
; start/select menu return values
HMENURETURN_SCRIPT EQU %10000000
HMENURETURN_ASM EQU %11111111
; PartyMenuQualityPointers indexes (see data/party_menu_qualities.asm)
const_def
const PARTYMENUACTION_CHOOSE_POKEMON
const PARTYMENUACTION_HEALING_ITEM
const PARTYMENUACTION_SWITCH
const PARTYMENUACTION_TEACH_TMHM
const PARTYMENUACTION_MOVE
const PARTYMENUACTION_EVO_STONE
const PARTYMENUACTION_GIVE_MON
const PARTYMENUACTION_GIVE_MON_FEMALE ; unused
const PARTYMENUACTION_GIVE_ITEM
const PARTYMENUACTION_MOBILE ; mobile
; PrintPartyMenuActionText arguments (see engine/pokemon/party_menu.asm)
const_def $f0
const PARTYMENUTEXT_HEAL_PSN
const PARTYMENUTEXT_HEAL_BRN
const PARTYMENUTEXT_HEAL_FRZ
const PARTYMENUTEXT_HEAL_SLP
const PARTYMENUTEXT_HEAL_PAR
const PARTYMENUTEXT_HEAL_HP
const PARTYMENUTEXT_HEAL_ALL
const PARTYMENUTEXT_REVIVE
const PARTYMENUTEXT_LEVEL_UP
const PARTYMENUTEXT_HEAL_CONFUSION

View File

@ -90,7 +90,7 @@ PrintText::
ld b, TEXTBOX_INNERH
ld c, TEXTBOX_INNERW
call DrawTextBox
call Function17a8
call UpdateSprites
call WaitBGMap
pop hl
PrintTextBoxText::

View File

@ -1,9 +1,188 @@
include "constants.asm"
SECTION "Window related functions", ROM0 [$1E58]
SECTION "Window related functions", ROM0 [$1d49]
LoadMenuHeader:: ; 00:1d49
call CopyMenuHeader
call PushWindow
ret
CopyMenuHeader:: ; 00:1d50
ld de, wMenuDataHeader
ld bc, $10
jp CopyBytes
MenuTextBox:: ; 00:1d59
push hl
ld hl, .Data
call LoadMenuHeader
pop hl
jp PrintText
; unused
ret
.Data: ; 00:1d65
db MENU_BACKUP_TILES ; flags
menu_coords 0, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw VRAM_Begin
db 0 ; default option
MenuTextBoxBackup::
call MenuTextBox
call CloseWindow
ret
LoadStandardMenuHeader::
ld hl, .Data
call LoadMenuHeader
ret
.Data: ; 00:1d7b
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw 0
db 1 ; default option
Call_ExitMenu::
call ExitMenu
ret
VerticalMenu:: ; 00:1d87
xor a
ldh [hBGMapMode], a
call MenuBox
call UpdateSprites
call PlaceVerticalMenuItems
call WaitBGMap
call CopyMenuData
ld a, [wMenuData2]
bit 7, a
jr z, .asm_1daa
call InitVerticalMenuCursor
call Function1a7c
bit 1, a
jr z, .asm_1dac
.asm_1daa: ; 00:1daa
scf
ret
.asm_1dac: ; 00:1dac
and a
ret
GetMenu2::
call LoadMenuHeader
call VerticalMenu
call CloseWindow
ld a, [wMenuCursorY]
ret
CopyNameFromMenu::
push hl
push bc
push af
ld hl, wMenuDataPointer
ld a, [hli]
ld h, [hl]
ld l, a
inc hl
inc hl
pop af
call GetNthString
ld d, h
ld e, l
call CopyStringToCD31
pop bc
pop hl
ret
YesNoBox::
lb bc, 14, 7
jr asm_1ddc
PlaceGenericTwoOptionBox::
call LoadMenuHeader
jr asm_1df9
asm_1ddc: ; 00:1ddc
push bc
ld hl, YesNoMenuHeader
call CopyMenuHeader
pop bc
ld a, b
ld [wMenuBorderLeftCoord], a
add 5
ld [wMenuBorderRightCoord], a
ld a, c
ld [wMenuBorderTopCoord], a
add 4
ld [wMenuBorderBottomCoord], a
call PushWindow
asm_1df9: ; 00:1df9
call VerticalMenu
push af
ld c, 15
call DelayFrames
call CloseWindow
pop af
jr c, .asm_1e11
ld a, [wMenuCursorY]
cp $2
jr z, .asm_1e11
and a
ret
.asm_1e11: ; 00:1e11
ld a, $2
ld [wMenuCursorY], a
scf
ret
YesNoMenuHeader:: ; 00:1e18
db MENU_BACKUP_TILES ; flags
menu_coords 10, 5, 15, 9
dw .MenuData
db 1 ; default option
.MenuData:
db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 2
db "はい@"
db "いいえ@"
OffsetMenuHeader::
call _OffsetMenuHeader
call PushWindow
ret
_OffsetMenuHeader:: ; 00:1e30
push de
call CopyMenuHeader
pop de
ld a, [wMenuBorderLeftCoord]
ld h, a
ld a, [wMenuBorderRightCoord]
sub h
.asm_1e3d: ; 00:1e3d
ld h, a
ld a, d
ld [wMenuBorderLeftCoord], a
add h
ld [wMenuBorderRightCoord], a
ld a, [wMenuBorderTopCoord]
ld l, a
ld a, [wMenuBorderBottomCoord]
sub l
ld l, a
ld a, e
ld [wMenuBorderTopCoord], a
add l
ld [wMenuBorderBottomCoord], a
ret
OpenMenu:: ; 00:1e58
call Function1c96
call CopyMenuData
call GetMenuIndexSet
push de
ld a, [wMenuCursorBuffer]
@ -12,15 +191,15 @@ OpenMenu:: ; 00:1e58
pop af
ld [wMenuCursorBuffer], a
call AutomaticGetMenuBottomCoord
call Function1bf4
call Function1ceb
call PushWindow
call MenuBox
pop de
call GetMenuIndexSet
push de
call RunMenuItemPrintingFunction
ld a, $1
ldh [hBGMapMode], a
call Function17a8
call UpdateSprites
call GetMenuIndexSet
pop de
call Function1f27

View File

@ -1,19 +1,21 @@
; ROM0
00:15BE GetMapObject
00:1720 CheckObjectVisibility
00:17A8 Function17a8
00:17A8 UpdateSprites
00:17BF GetObjectStruct
00:1A7C Function1a7c
00:1BF4 Function1bf4
00:1BF4 PushWindow
00:1BFC ExitMenu
00:1C44 InitVerticalMenuCursor
00:1C4C CloseWindow
00:1C60 Function1c60 ; PopWindow?
00:1C7A Function1c7a ; HandleWindow?
00:1C86 Function1c86
00:1C96 Function1c96 ; CopyMenuData?
00:1C96 CopyMenuData
00:1CAE Function1cae ; PushWindow?
00:1CEB Function1ceb
00:1CB9 PlaceVerticalMenuItems
00:1CEB MenuBox
00:1D2D MenuBoxCoord2Tile
00:1D49 LoadMenuHeader
00:202C Function202c
00:23DC LoadWildMons

View File

@ -268,7 +268,7 @@ wMenuBorderTopCoord:: db ; cc03
wMenuBorderLeftCoord:: db ; cc04
wMenuBorderBottomCoord:: db ; cc05
wMenuBorderRightCoord:: db ; cc06
ds 2 ; TODO
wMenuDataPointer:: dw ; cc07
wMenuCursorBuffer:: db ; cc09
; cc0a
ds 8 ; TODO