2013-09-03 15:43:15 -07:00
|
|
|
; Functions used in displaying and handling menus.
|
|
|
|
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
LoadMenuDataHeader::
|
2015-07-15 12:48:44 -07:00
|
|
|
call CopyMenuDataHeader
|
2015-12-22 19:19:33 -08:00
|
|
|
call PushWindow
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
CopyMenuDataHeader::
|
2015-11-10 13:53:37 -08:00
|
|
|
ld de, wMenuDataHeader
|
|
|
|
ld bc, wMenuDataHeaderEnd - wMenuDataHeader
|
2013-09-03 15:43:15 -07:00
|
|
|
call CopyBytes
|
|
|
|
ld a, [hROMBank]
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [wMenuDataBank], a
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 0x1d4b
|
|
|
|
|
2015-12-16 09:32:08 -08:00
|
|
|
StoreTo_wMenuCursorBuffer:: ; 1d4b
|
2015-11-01 09:44:30 -08:00
|
|
|
ld [wMenuCursorBuffer], a
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 1d4f
|
|
|
|
|
|
|
|
|
2015-07-18 20:45:39 -07:00
|
|
|
MenuTextBox:: ; 1d4f
|
2013-09-03 15:43:15 -07:00
|
|
|
push hl
|
2015-07-18 20:45:39 -07:00
|
|
|
call LoadMenuTextBox
|
2013-09-03 15:43:15 -07:00
|
|
|
pop hl
|
|
|
|
jp PrintText
|
|
|
|
; 1d57
|
|
|
|
|
2015-12-13 11:15:16 -08:00
|
|
|
ret_1d57:: ; 1d57
|
|
|
|
; unreferenced
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 1d58
|
|
|
|
|
2015-07-18 20:45:39 -07:00
|
|
|
LoadMenuTextBox:: ; 1d58
|
2015-12-17 19:31:16 -08:00
|
|
|
ld hl, .MenuDataHeader
|
2013-09-03 15:43:15 -07:00
|
|
|
call LoadMenuDataHeader
|
|
|
|
ret
|
|
|
|
; 1d5f
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MenuDataHeader: ; 1d5f
|
2013-09-03 15:43:15 -07:00
|
|
|
db $40 ; tile backup
|
|
|
|
db 12, 0 ; start coords
|
|
|
|
db 17, 19 ; end coords
|
2017-12-28 04:32:33 -08:00
|
|
|
dw vTiles0
|
2013-09-03 15:43:15 -07:00
|
|
|
db 0 ; default option
|
|
|
|
; 1d67
|
|
|
|
|
2015-07-18 20:45:39 -07:00
|
|
|
MenuTextBoxBackup:: ; 1d67
|
|
|
|
call MenuTextBox
|
2015-12-24 19:58:42 -08:00
|
|
|
call CloseWindow
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 1d6e
|
|
|
|
|
2015-11-11 13:11:08 -08:00
|
|
|
LoadStandardMenuDataHeader:: ; 1d6e
|
2015-12-17 19:31:16 -08:00
|
|
|
ld hl, .MenuDataHeader
|
2013-09-03 15:43:15 -07:00
|
|
|
call LoadMenuDataHeader
|
|
|
|
ret
|
|
|
|
; 1d75
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MenuDataHeader: ; 1d75
|
2013-09-03 15:43:15 -07:00
|
|
|
db $40 ; tile backup
|
|
|
|
db 0, 0 ; start coords
|
|
|
|
db 17, 19 ; end coords
|
2015-11-02 11:37:02 -08:00
|
|
|
dw 0
|
2013-09-03 15:43:15 -07:00
|
|
|
db 1 ; default option
|
|
|
|
; 1d7d
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
Call_ExitMenu:: ; 1d7d
|
2015-07-20 00:51:52 -07:00
|
|
|
call ExitMenu
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 1d81
|
|
|
|
|
2015-12-15 15:59:49 -08:00
|
|
|
VerticalMenu::
|
2013-09-03 15:43:15 -07:00
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
2015-11-04 11:02:11 -08:00
|
|
|
call MenuBox
|
2015-07-22 12:57:02 -07:00
|
|
|
call UpdateSprites
|
2015-12-15 15:59:49 -08:00
|
|
|
call PlaceVerticalMenuItems
|
2015-11-25 07:16:29 -08:00
|
|
|
call ApplyTilemap
|
2015-11-10 13:53:37 -08:00
|
|
|
call CopyMenuData2
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [wMenuData2Flags]
|
2013-09-03 15:43:15 -07:00
|
|
|
bit 7, a
|
2015-10-24 07:34:19 -07:00
|
|
|
jr z, .cancel
|
2015-12-15 15:59:49 -08:00
|
|
|
call InitVerticalMenuCursor
|
|
|
|
call StaticMenuJoypad
|
|
|
|
call MenuClickSound
|
2013-09-03 15:43:15 -07:00
|
|
|
bit 1, a
|
2015-10-24 07:34:19 -07:00
|
|
|
jr z, .okay
|
2015-10-16 10:35:43 -07:00
|
|
|
.cancel
|
2013-09-03 15:43:15 -07:00
|
|
|
scf
|
|
|
|
ret
|
2015-12-15 15:59:49 -08:00
|
|
|
|
2015-10-16 10:35:43 -07:00
|
|
|
.okay
|
2013-09-03 15:43:15 -07:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 0x1dab
|
|
|
|
|
2015-07-19 01:58:31 -07:00
|
|
|
GetMenu2:: ; 1dab
|
2013-09-03 15:43:15 -07:00
|
|
|
call LoadMenuDataHeader
|
2015-12-15 15:59:49 -08:00
|
|
|
call VerticalMenu
|
2015-12-24 19:58:42 -08:00
|
|
|
call CloseWindow
|
2015-12-15 15:59:49 -08:00
|
|
|
ld a, [wMenuCursorY]
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 1db8
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
CopyNameFromMenu::
|
2013-09-03 15:43:15 -07:00
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
push af
|
2015-11-10 13:53:37 -08:00
|
|
|
ld hl, wMenuData2Pointer
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
inc hl
|
2016-01-05 05:46:37 -08:00
|
|
|
inc hl
|
2013-09-03 15:43:15 -07:00
|
|
|
pop af
|
|
|
|
call GetNthString
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
call CopyName1
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 0x1dcf
|
|
|
|
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
YesNoBox:: ; 1dcf
|
2015-11-10 13:53:37 -08:00
|
|
|
lb bc, SCREEN_WIDTH - 6, 7
|
2013-09-03 15:43:15 -07:00
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
PlaceYesNoBox:: ; 1dd2
|
2013-12-03 23:49:12 -08:00
|
|
|
jr _YesNoBox
|
2013-09-03 15:43:15 -07:00
|
|
|
|
2015-10-17 14:18:52 -07:00
|
|
|
PlaceGenericTwoOptionBox:: ; 1dd4
|
2013-09-03 15:43:15 -07:00
|
|
|
call LoadMenuDataHeader
|
2015-10-17 14:18:52 -07:00
|
|
|
jr InterpretTwoOptionMenu
|
2013-09-03 15:43:15 -07:00
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
_YesNoBox:: ; 1dd9
|
2013-12-03 23:49:12 -08:00
|
|
|
; Return nc (yes) or c (no).
|
2013-09-03 15:43:15 -07:00
|
|
|
push bc
|
2013-12-03 23:49:12 -08:00
|
|
|
ld hl, YesNoMenuDataHeader
|
2015-07-15 12:48:44 -07:00
|
|
|
call CopyMenuDataHeader
|
2013-09-03 15:43:15 -07:00
|
|
|
pop bc
|
2015-10-17 14:18:52 -07:00
|
|
|
; This seems to be an overflow prevention, but
|
|
|
|
; it was coded wrong.
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, b
|
2015-10-17 14:18:52 -07:00
|
|
|
cp SCREEN_WIDTH - 6
|
|
|
|
jr nz, .okay ; should this be "jr nc"?
|
|
|
|
ld a, SCREEN_WIDTH - 6
|
2013-09-03 15:43:15 -07:00
|
|
|
ld b, a
|
|
|
|
|
2015-10-17 14:18:52 -07:00
|
|
|
.okay
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, b
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wMenuBorderLeftCoord], a
|
2015-11-10 13:53:37 -08:00
|
|
|
add 5
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wMenuBorderRightCoord], a
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, c
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wMenuBorderTopCoord], a
|
2015-11-10 13:53:37 -08:00
|
|
|
add 4
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wMenuBorderBottomCoord], a
|
2015-12-22 19:19:33 -08:00
|
|
|
call PushWindow
|
2013-09-03 15:43:15 -07:00
|
|
|
|
2015-10-17 14:18:52 -07:00
|
|
|
InterpretTwoOptionMenu:: ; 1dfe
|
2015-12-15 15:59:49 -08:00
|
|
|
call VerticalMenu
|
2013-09-03 15:43:15 -07:00
|
|
|
push af
|
|
|
|
ld c, $f
|
|
|
|
call DelayFrames
|
2015-12-24 19:58:42 -08:00
|
|
|
call CloseWindow
|
2013-09-03 15:43:15 -07:00
|
|
|
pop af
|
2015-10-16 10:35:43 -07:00
|
|
|
jr c, .no
|
2015-12-15 15:59:49 -08:00
|
|
|
ld a, [wMenuCursorY]
|
2013-12-03 23:49:12 -08:00
|
|
|
cp 2 ; no
|
2015-10-16 10:35:43 -07:00
|
|
|
jr z, .no
|
2013-09-03 15:43:15 -07:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-10-16 10:35:43 -07:00
|
|
|
.no
|
|
|
|
ld a, 2
|
2015-12-15 15:59:49 -08:00
|
|
|
ld [wMenuCursorY], a
|
2013-09-03 15:43:15 -07:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 1e1d
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
YesNoMenuDataHeader:: ; 1e1d
|
2013-09-03 15:43:15 -07:00
|
|
|
db $40 ; tile backup
|
|
|
|
db 5, 10 ; start coords
|
|
|
|
db 9, 15 ; end coords
|
2015-12-17 19:31:16 -08:00
|
|
|
dw .MenuData2
|
2013-09-03 15:43:15 -07:00
|
|
|
db 1 ; default option
|
|
|
|
; 1e25
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MenuData2: ; 1e25
|
2013-09-03 15:43:15 -07:00
|
|
|
db $c0 ; flags
|
|
|
|
db 2
|
|
|
|
db "YES@"
|
|
|
|
db "NO@"
|
|
|
|
; 1e2e
|
|
|
|
|
2015-12-17 19:31:16 -08:00
|
|
|
OffsetMenuDataHeader:: ; 1e2e
|
|
|
|
call _OffsetMenuDataHeader
|
2015-12-22 19:19:33 -08:00
|
|
|
call PushWindow
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 1e35
|
|
|
|
|
2015-12-17 19:31:16 -08:00
|
|
|
_OffsetMenuDataHeader:: ; 1e35
|
2013-09-03 15:43:15 -07:00
|
|
|
push de
|
2015-07-15 12:48:44 -07:00
|
|
|
call CopyMenuDataHeader
|
2013-09-03 15:43:15 -07:00
|
|
|
pop de
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderLeftCoord]
|
2013-09-03 15:43:15 -07:00
|
|
|
ld h, a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderRightCoord]
|
2013-09-03 15:43:15 -07:00
|
|
|
sub h
|
|
|
|
ld h, a
|
|
|
|
ld a, d
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wMenuBorderLeftCoord], a
|
2013-09-03 15:43:15 -07:00
|
|
|
add h
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wMenuBorderRightCoord], a
|
|
|
|
ld a, [wMenuBorderTopCoord]
|
2013-09-03 15:43:15 -07:00
|
|
|
ld l, a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderBottomCoord]
|
2013-09-03 15:43:15 -07:00
|
|
|
sub l
|
|
|
|
ld l, a
|
|
|
|
ld a, e
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wMenuBorderTopCoord], a
|
2013-09-03 15:43:15 -07:00
|
|
|
add l
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wMenuBorderBottomCoord], a
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 1e5d
|
|
|
|
|
2015-11-16 18:46:36 -08:00
|
|
|
DoNthMenu:: ; 1e5d
|
2016-05-10 09:31:49 -07:00
|
|
|
call DrawVariableLengthMenuBox
|
2013-09-03 15:43:15 -07:00
|
|
|
call MenuWriteText
|
2016-05-10 09:31:49 -07:00
|
|
|
call InitMenuCursorAndButtonPermissions
|
2016-03-01 19:31:21 -08:00
|
|
|
call GetStaticMenuJoypad
|
2015-12-15 15:59:49 -08:00
|
|
|
call GetMenuJoypad
|
|
|
|
call MenuClickSound
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 1e70
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
SetUpMenu:: ; 1e70
|
2016-05-10 09:31:49 -07:00
|
|
|
call DrawVariableLengthMenuBox ; ???
|
2013-09-03 15:43:15 -07:00
|
|
|
call MenuWriteText
|
2016-05-10 09:31:49 -07:00
|
|
|
call InitMenuCursorAndButtonPermissions ; set up selection pointer
|
2015-12-17 19:31:16 -08:00
|
|
|
ld hl, w2DMenuFlags1
|
2013-09-03 15:43:15 -07:00
|
|
|
set 7, [hl]
|
|
|
|
ret
|
|
|
|
|
2016-05-10 09:31:49 -07:00
|
|
|
DrawVariableLengthMenuBox::
|
2015-11-10 13:53:37 -08:00
|
|
|
call CopyMenuData2
|
2015-12-18 17:07:09 -08:00
|
|
|
call GetMenuIndexSet
|
2016-05-10 09:31:49 -07:00
|
|
|
call AutomaticGetMenuBottomCoord
|
2015-11-04 11:02:11 -08:00
|
|
|
call MenuBox
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
MenuWriteText::
|
2013-09-03 15:43:15 -07:00
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
2015-12-18 17:07:09 -08:00
|
|
|
call GetMenuIndexSet ; sort out the text
|
2016-05-10 09:31:49 -07:00
|
|
|
call RunMenuItemPrintingFunction ; actually write it
|
|
|
|
call SafeUpdateSprites
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [hOAMUpdate]
|
|
|
|
push af
|
|
|
|
ld a, $1
|
|
|
|
ld [hOAMUpdate], a
|
2015-11-25 07:16:29 -08:00
|
|
|
call ApplyTilemap
|
2013-09-03 15:43:15 -07:00
|
|
|
pop af
|
|
|
|
ld [hOAMUpdate], a
|
|
|
|
ret
|
|
|
|
; 0x1ea6
|
|
|
|
|
2016-05-10 09:31:49 -07:00
|
|
|
AutomaticGetMenuBottomCoord:: ; 1ea6
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderLeftCoord]
|
2013-09-03 15:43:15 -07:00
|
|
|
ld c, a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderRightCoord]
|
2013-09-03 15:43:15 -07:00
|
|
|
sub c
|
|
|
|
ld c, a
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [wMenuData2Items]
|
2013-09-03 15:43:15 -07:00
|
|
|
add a
|
|
|
|
inc a
|
|
|
|
ld b, a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderTopCoord]
|
2013-09-03 15:43:15 -07:00
|
|
|
add b
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wMenuBorderBottomCoord], a
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 1ebd
|
|
|
|
|
2015-12-18 17:07:09 -08:00
|
|
|
GetMenuIndexSet:: ; 1ebd
|
2015-12-17 19:31:16 -08:00
|
|
|
ld hl, wMenuData2IndicesPointer
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-12-18 17:07:09 -08:00
|
|
|
ld a, [wWhichIndexSet]
|
2013-09-03 15:43:15 -07:00
|
|
|
and a
|
2015-12-17 19:31:16 -08:00
|
|
|
jr z, .skip
|
2013-09-03 15:43:15 -07:00
|
|
|
ld b, a
|
2015-12-17 19:31:16 -08:00
|
|
|
ld c, -1
|
|
|
|
.loop
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp c
|
2015-12-17 19:31:16 -08:00
|
|
|
jr nz, .loop
|
2013-09-03 15:43:15 -07:00
|
|
|
dec b
|
2015-12-17 19:31:16 -08:00
|
|
|
jr nz, .loop
|
2013-09-03 15:43:15 -07:00
|
|
|
|
2015-12-17 19:31:16 -08:00
|
|
|
.skip
|
2013-09-03 15:43:15 -07:00
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
ld a, [hl]
|
2015-11-04 11:02:11 -08:00
|
|
|
ld [wMenuData2Items], a
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 1eda
|
|
|
|
|
2016-05-10 09:31:49 -07:00
|
|
|
RunMenuItemPrintingFunction:: ; 1eda
|
2015-11-10 13:53:37 -08:00
|
|
|
call MenuBoxCoord2Tile
|
2015-12-17 19:31:16 -08:00
|
|
|
ld bc, 2 * SCREEN_WIDTH + 2
|
2013-09-03 15:43:15 -07:00
|
|
|
add hl, bc
|
2015-12-17 19:31:16 -08:00
|
|
|
.loop
|
2013-09-03 15:43:15 -07:00
|
|
|
inc de
|
|
|
|
ld a, [de]
|
2015-12-17 19:31:16 -08:00
|
|
|
cp -1
|
2013-09-03 15:43:15 -07:00
|
|
|
ret z
|
|
|
|
ld [MenuSelection], a
|
|
|
|
push de
|
|
|
|
push hl
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2015-12-17 19:31:16 -08:00
|
|
|
ld hl, wMenuData2DisplayFunctionPointer
|
2016-05-10 09:31:49 -07:00
|
|
|
call ._hl_
|
2013-09-03 15:43:15 -07:00
|
|
|
pop hl
|
2015-12-17 19:31:16 -08:00
|
|
|
ld de, 2 * SCREEN_WIDTH
|
2013-09-03 15:43:15 -07:00
|
|
|
add hl, de
|
|
|
|
pop de
|
2015-12-17 19:31:16 -08:00
|
|
|
jr .loop
|
2013-09-03 15:43:15 -07:00
|
|
|
; 1efb
|
|
|
|
|
2016-05-10 09:31:49 -07:00
|
|
|
._hl_ ; 1efb
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2017-06-09 14:01:10 -07:00
|
|
|
jp hl
|
2013-09-03 15:43:15 -07:00
|
|
|
; 1eff
|
|
|
|
|
2016-05-10 09:31:49 -07:00
|
|
|
InitMenuCursorAndButtonPermissions:: ; 1eff
|
2015-12-15 15:59:49 -08:00
|
|
|
call InitVerticalMenuCursor
|
2015-12-20 09:54:08 -08:00
|
|
|
ld hl, wMenuJoypadFilter
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [wMenuData2Flags]
|
2013-09-03 15:43:15 -07:00
|
|
|
bit 3, a
|
2015-12-20 09:54:08 -08:00
|
|
|
jr z, .disallow_select
|
|
|
|
set START_F, [hl]
|
2013-09-03 15:43:15 -07:00
|
|
|
|
2015-12-20 09:54:08 -08:00
|
|
|
.disallow_select
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [wMenuData2Flags]
|
2013-09-03 15:43:15 -07:00
|
|
|
bit 2, a
|
2015-12-20 09:54:08 -08:00
|
|
|
jr z, .disallow_left_right
|
|
|
|
set D_LEFT_F, [hl]
|
|
|
|
set D_RIGHT_F, [hl]
|
2013-09-03 15:43:15 -07:00
|
|
|
|
2015-12-20 09:54:08 -08:00
|
|
|
.disallow_left_right
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 1f1a
|
|
|
|
|
|
|
|
|
2016-03-01 19:31:21 -08:00
|
|
|
GetScrollingMenuJoypad:: ; 1f1a
|
2015-12-15 15:59:49 -08:00
|
|
|
call ScrollingMenuJoypad
|
2015-12-20 09:54:08 -08:00
|
|
|
ld hl, wMenuJoypadFilter
|
2013-09-03 15:43:15 -07:00
|
|
|
and [hl]
|
2016-03-01 19:31:21 -08:00
|
|
|
jr ContinueGettingMenuJoypad
|
2013-09-03 15:43:15 -07:00
|
|
|
; 1f23
|
|
|
|
|
2016-03-01 19:31:21 -08:00
|
|
|
GetStaticMenuJoypad:: ; 1f23
|
2013-09-03 15:43:15 -07:00
|
|
|
xor a
|
2015-12-15 15:59:49 -08:00
|
|
|
ld [wMenuJoypad], a
|
|
|
|
call StaticMenuJoypad
|
2013-09-03 15:43:15 -07:00
|
|
|
; 1f2a
|
|
|
|
|
2016-03-01 19:31:21 -08:00
|
|
|
ContinueGettingMenuJoypad:
|
2015-12-20 09:54:08 -08:00
|
|
|
bit A_BUTTON_F, a
|
|
|
|
jr nz, .a_button
|
|
|
|
bit B_BUTTON_F, a
|
|
|
|
jr nz, .b_start
|
|
|
|
bit START_F, a
|
|
|
|
jr nz, .b_start
|
|
|
|
bit D_RIGHT_F, a
|
|
|
|
jr nz, .d_right
|
|
|
|
bit D_LEFT_F, a
|
|
|
|
jr nz, .d_left
|
2013-09-03 15:43:15 -07:00
|
|
|
xor a
|
2015-12-15 15:59:49 -08:00
|
|
|
ld [wMenuJoypad], a
|
2015-12-20 09:54:08 -08:00
|
|
|
jr .done
|
2013-09-03 15:43:15 -07:00
|
|
|
|
2015-12-20 09:54:08 -08:00
|
|
|
.d_right
|
|
|
|
ld a, D_RIGHT
|
2015-12-15 15:59:49 -08:00
|
|
|
ld [wMenuJoypad], a
|
2015-12-20 09:54:08 -08:00
|
|
|
jr .done
|
2013-09-03 15:43:15 -07:00
|
|
|
|
2015-12-20 09:54:08 -08:00
|
|
|
.d_left
|
|
|
|
ld a, D_LEFT
|
2015-12-15 15:59:49 -08:00
|
|
|
ld [wMenuJoypad], a
|
2015-12-20 09:54:08 -08:00
|
|
|
jr .done
|
2013-09-03 15:43:15 -07:00
|
|
|
|
2015-12-20 09:54:08 -08:00
|
|
|
.a_button
|
|
|
|
ld a, A_BUTTON
|
2015-12-15 15:59:49 -08:00
|
|
|
ld [wMenuJoypad], a
|
2013-09-03 15:43:15 -07:00
|
|
|
|
2015-12-20 09:54:08 -08:00
|
|
|
.done
|
2015-12-18 17:07:09 -08:00
|
|
|
call GetMenuIndexSet
|
2015-12-15 15:59:49 -08:00
|
|
|
ld a, [wMenuCursorY]
|
2013-09-03 15:43:15 -07:00
|
|
|
ld l, a
|
|
|
|
ld h, $0
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [MenuSelection], a
|
2015-12-15 15:59:49 -08:00
|
|
|
ld a, [wMenuCursorY]
|
2015-11-01 09:44:30 -08:00
|
|
|
ld [wMenuCursorBuffer], a
|
2013-09-03 15:43:15 -07:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-12-20 09:54:08 -08:00
|
|
|
.b_start
|
|
|
|
ld a, B_BUTTON
|
2015-12-15 15:59:49 -08:00
|
|
|
ld [wMenuJoypad], a
|
2015-12-20 09:54:08 -08:00
|
|
|
ld a, -1
|
2013-09-03 15:43:15 -07:00
|
|
|
ld [MenuSelection], a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 1f79
|
|
|
|
|
2015-12-13 11:15:16 -08:00
|
|
|
PlaceMenuStrings:: ; 1f79
|
2013-09-03 15:43:15 -07:00
|
|
|
push de
|
2015-12-13 11:15:16 -08:00
|
|
|
ld hl, wMenuData2PointerTableAddr
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld a, [MenuSelection]
|
|
|
|
call GetNthString
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
|
|
|
call PlaceString
|
|
|
|
ret
|
|
|
|
; 1f8d
|
|
|
|
|
2015-11-16 18:46:36 -08:00
|
|
|
PlaceNthMenuStrings:: ; 1f8d
|
2013-09-03 15:43:15 -07:00
|
|
|
push de
|
|
|
|
ld a, [MenuSelection]
|
2015-12-13 11:15:16 -08:00
|
|
|
call GetMenuDataPointerTableEntry
|
2013-09-03 15:43:15 -07:00
|
|
|
inc hl
|
2016-01-05 05:46:37 -08:00
|
|
|
inc hl
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld d, [hl]
|
|
|
|
ld e, a
|
|
|
|
pop hl
|
|
|
|
call PlaceString
|
|
|
|
ret
|
|
|
|
; 1f9e
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
Function1f9e:: ; 1f9e
|
2015-12-13 11:15:16 -08:00
|
|
|
; unreferenced
|
|
|
|
call GetMenuDataPointerTableEntry
|
2013-09-03 15:43:15 -07:00
|
|
|
inc hl
|
2016-01-05 05:46:37 -08:00
|
|
|
inc hl
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld d, [hl]
|
|
|
|
ld e, a
|
|
|
|
ret
|
|
|
|
; 1fa7
|
|
|
|
|
2015-11-16 18:46:36 -08:00
|
|
|
MenuJumptable:: ; 1fa7
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [MenuSelection]
|
2015-12-13 11:15:16 -08:00
|
|
|
call GetMenuDataPointerTableEntry
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2017-06-09 14:01:10 -07:00
|
|
|
jp hl
|
2013-09-03 15:43:15 -07:00
|
|
|
; 1fb1
|
|
|
|
|
2015-12-13 11:15:16 -08:00
|
|
|
GetMenuDataPointerTableEntry:: ; 1fb1
|
2013-09-03 15:43:15 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, $0
|
2015-12-13 11:15:16 -08:00
|
|
|
ld hl, wMenuData2PointerTableAddr
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
add hl, de
|
2016-01-05 05:46:37 -08:00
|
|
|
add hl, de
|
|
|
|
add hl, de
|
|
|
|
add hl, de
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 1fbf
|
|
|
|
|
2015-12-19 11:48:30 -08:00
|
|
|
ClearWindowData:: ; 1fbf
|
2015-12-15 15:59:49 -08:00
|
|
|
ld hl, wWindowStackPointer
|
2015-10-17 17:49:34 -07:00
|
|
|
call .bytefill
|
2015-11-10 13:53:37 -08:00
|
|
|
ld hl, wMenuDataHeader
|
2015-10-17 17:49:34 -07:00
|
|
|
call .bytefill
|
2015-11-04 11:02:11 -08:00
|
|
|
ld hl, wMenuData2Flags
|
2015-10-17 17:49:34 -07:00
|
|
|
call .bytefill
|
2015-12-19 11:48:30 -08:00
|
|
|
ld hl, w2DMenuCursorInitY
|
2015-10-17 17:49:34 -07:00
|
|
|
call .bytefill
|
|
|
|
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
|
|
|
ld a, $7
|
|
|
|
ld [rSVBK], a
|
2015-10-17 17:49:34 -07:00
|
|
|
|
2013-09-03 15:43:15 -07:00
|
|
|
xor a
|
2015-12-15 15:59:49 -08:00
|
|
|
ld hl, wWindowStackBottom
|
2013-09-03 15:43:15 -07:00
|
|
|
ld [hld], a
|
2016-01-05 05:46:37 -08:00
|
|
|
ld [hld], a
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, l
|
2015-12-15 15:59:49 -08:00
|
|
|
ld [wWindowStackPointer], a
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, h
|
2015-12-15 15:59:49 -08:00
|
|
|
ld [wWindowStackPointer + 1], a
|
2015-10-17 17:49:34 -07:00
|
|
|
|
2013-09-03 15:43:15 -07:00
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
ret
|
|
|
|
; 1ff0
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.bytefill ; 1ff0
|
2018-01-09 12:39:48 -08:00
|
|
|
ld bc, $10
|
2013-09-03 15:43:15 -07:00
|
|
|
xor a
|
|
|
|
call ByteFill
|
|
|
|
ret
|
|
|
|
; 1ff8
|
|
|
|
|
2015-12-15 15:59:49 -08:00
|
|
|
MenuClickSound:: ; 1ff8
|
2013-09-03 15:43:15 -07:00
|
|
|
push af
|
2015-12-15 15:59:49 -08:00
|
|
|
and A_BUTTON | B_BUTTON
|
2015-10-16 10:35:43 -07:00
|
|
|
jr z, .nosound
|
2015-11-10 13:53:37 -08:00
|
|
|
ld hl, wMenuFlags
|
2013-09-03 15:43:15 -07:00
|
|
|
bit 3, [hl]
|
2015-10-16 10:35:43 -07:00
|
|
|
jr nz, .nosound
|
2013-09-03 15:43:15 -07:00
|
|
|
call PlayClickSFX
|
2015-10-16 10:35:43 -07:00
|
|
|
.nosound
|
2013-09-03 15:43:15 -07:00
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
; 2009
|
|
|
|
|
|
|
|
|
2015-07-18 20:45:39 -07:00
|
|
|
PlayClickSFX:: ; 2009
|
2013-09-03 15:43:15 -07:00
|
|
|
push de
|
|
|
|
ld de, SFX_READ_TEXT_2
|
2013-10-08 10:10:36 -07:00
|
|
|
call PlaySFX
|
2013-09-03 15:43:15 -07:00
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
; 0x2012
|
|
|
|
|
2015-11-18 15:35:44 -08:00
|
|
|
MenuTextBoxWaitButton:: ; 2012
|
2015-07-18 20:45:39 -07:00
|
|
|
call MenuTextBox
|
2015-11-25 07:16:29 -08:00
|
|
|
call WaitButton
|
2015-07-20 00:51:52 -07:00
|
|
|
call ExitMenu
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 201c
|
|
|
|
|
2015-12-15 15:59:49 -08:00
|
|
|
Place2DMenuItemName:: ; 201c
|
2013-09-03 15:43:15 -07:00
|
|
|
ld [hBuffer], a
|
|
|
|
ld a, [hROMBank]
|
|
|
|
push af
|
|
|
|
ld a, [hBuffer]
|
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
call PlaceString
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
ret
|
|
|
|
; 202a
|
|
|
|
|
2015-12-15 15:59:49 -08:00
|
|
|
_2DMenu:: ; 202a
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [hROMBank]
|
2015-12-15 15:59:49 -08:00
|
|
|
ld [wMenuData2_2DMenuItemStringsBank], a
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _2DMenu_
|
2015-11-01 09:44:30 -08:00
|
|
|
ld a, [wMenuCursorBuffer]
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 2039
|
|
|
|
|
2015-12-15 15:59:49 -08:00
|
|
|
InterpretBattleMenu:: ; 2039
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [hROMBank]
|
2015-12-15 15:59:49 -08:00
|
|
|
ld [wMenuData2_2DMenuItemStringsBank], a
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _InterpretBattleMenu
|
2015-11-01 09:44:30 -08:00
|
|
|
ld a, [wMenuCursorBuffer]
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 2048
|
|
|
|
|
2015-12-15 15:59:49 -08:00
|
|
|
InterpretMobileMenu:: ; 2048
|
2013-09-03 15:43:15 -07:00
|
|
|
ld a, [hROMBank]
|
2015-12-15 15:59:49 -08:00
|
|
|
ld [wMenuData2_2DMenuItemStringsBank], a
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _InterpretMobileMenu
|
2015-11-01 09:44:30 -08:00
|
|
|
ld a, [wMenuCursorBuffer]
|
2013-09-03 15:43:15 -07:00
|
|
|
ret
|
|
|
|
; 2057
|