2018-06-24 14:09:41 +00:00
|
|
|
_2DMenu_::
|
2018-01-23 21:08:43 +00:00
|
|
|
ld hl, CopyMenuData
|
|
|
|
ld a, [wMenuData_2DMenuItemStringsBank]
|
2015-11-04 19:02:11 +00:00
|
|
|
rst FarCall
|
2015-12-15 23:59:49 +00:00
|
|
|
|
|
|
|
call Draw2DMenu
|
2015-11-04 19:02:11 +00:00
|
|
|
call UpdateSprites
|
2015-11-25 15:16:29 +00:00
|
|
|
call ApplyTilemap
|
2015-12-15 23:59:49 +00:00
|
|
|
call Get2DMenuSelection
|
2015-11-04 19:02:11 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
_InterpretBattleMenu::
|
2018-01-23 21:08:43 +00:00
|
|
|
ld hl, CopyMenuData
|
|
|
|
ld a, [wMenuData_2DMenuItemStringsBank]
|
2015-11-04 19:02:11 +00:00
|
|
|
rst FarCall
|
2015-12-15 23:59:49 +00:00
|
|
|
|
|
|
|
call Draw2DMenu
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall MobileTextBorder
|
2015-11-04 19:02:11 +00:00
|
|
|
call UpdateSprites
|
2015-11-25 15:16:29 +00:00
|
|
|
call ApplyTilemap
|
2015-12-15 23:59:49 +00:00
|
|
|
call Get2DMenuSelection
|
2015-11-04 19:02:11 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
_InterpretMobileMenu::
|
2018-01-23 21:08:43 +00:00
|
|
|
ld hl, CopyMenuData
|
|
|
|
ld a, [wMenuData_2DMenuItemStringsBank]
|
2015-11-04 19:02:11 +00:00
|
|
|
rst FarCall
|
2015-12-15 23:59:49 +00:00
|
|
|
|
|
|
|
call Draw2DMenu
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall MobileTextBorder
|
2015-11-04 19:02:11 +00:00
|
|
|
call UpdateSprites
|
2015-11-25 15:16:29 +00:00
|
|
|
call ApplyTilemap
|
2015-12-15 23:59:49 +00:00
|
|
|
call Init2DMenuCursorPosition
|
|
|
|
ld hl, w2DMenuFlags1
|
2015-11-04 19:02:11 +00:00
|
|
|
set 7, [hl]
|
2015-12-15 23:59:49 +00:00
|
|
|
.loop
|
2015-11-04 19:02:11 +00:00
|
|
|
call DelayFrame
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall Function10032e
|
2015-11-04 19:02:11 +00:00
|
|
|
ld a, [wcd2b]
|
|
|
|
and a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr nz, .quit
|
|
|
|
call MobileMenuJoypad
|
2015-12-20 17:54:08 +00:00
|
|
|
ld a, [wMenuJoypadFilter]
|
2015-11-04 19:02:11 +00:00
|
|
|
and c
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .loop
|
|
|
|
call Mobile_GetMenuSelection
|
2015-11-04 19:02:11 +00:00
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.quit
|
|
|
|
ld a, [w2DMenuNumCols]
|
2015-11-04 19:02:11 +00:00
|
|
|
ld c, a
|
2015-12-15 23:59:49 +00:00
|
|
|
ld a, [w2DMenuNumRows]
|
2015-11-04 19:02:11 +00:00
|
|
|
call SimpleMultiply
|
|
|
|
ld [wMenuCursorBuffer], a
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Draw2DMenu:
|
2015-11-04 19:02:11 +00:00
|
|
|
xor a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hBGMapMode], a
|
2015-11-04 19:02:11 +00:00
|
|
|
call MenuBox
|
2015-12-15 23:59:49 +00:00
|
|
|
call Place2DMenuItemStrings
|
2015-11-04 19:02:11 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Get2DMenuSelection:
|
2015-12-15 23:59:49 +00:00
|
|
|
call Init2DMenuCursorPosition
|
|
|
|
call StaticMenuJoypad
|
|
|
|
call MenuClickSound
|
2018-06-24 14:09:41 +00:00
|
|
|
Mobile_GetMenuSelection:
|
2018-01-23 21:08:43 +00:00
|
|
|
ld a, [wMenuDataFlags]
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 1, a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .skip
|
|
|
|
call GetMenuJoypad
|
|
|
|
bit SELECT_F, a
|
|
|
|
jr nz, .quit1
|
2015-11-04 19:02:11 +00:00
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.skip
|
2018-01-23 21:08:43 +00:00
|
|
|
ld a, [wMenuDataFlags]
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 0, a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr nz, .skip2
|
|
|
|
call GetMenuJoypad
|
|
|
|
bit B_BUTTON_F, a
|
|
|
|
jr nz, .quit2
|
2015-11-04 19:02:11 +00:00
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.skip2
|
|
|
|
ld a, [w2DMenuNumCols]
|
2015-11-04 19:02:11 +00:00
|
|
|
ld c, a
|
2015-12-15 23:59:49 +00:00
|
|
|
ld a, [wMenuCursorY]
|
2015-11-04 19:02:11 +00:00
|
|
|
dec a
|
|
|
|
call SimpleMultiply
|
|
|
|
ld c, a
|
2015-12-15 23:59:49 +00:00
|
|
|
ld a, [wMenuCursorX]
|
2015-11-04 19:02:11 +00:00
|
|
|
add c
|
|
|
|
ld [wMenuCursorBuffer], a
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.quit1
|
2015-11-04 19:02:11 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.quit2
|
2015-11-04 19:02:11 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Get2DMenuNumberOfColumns:
|
2018-01-23 21:08:43 +00:00
|
|
|
ld a, [wMenuData_2DMenuDimensions]
|
2015-11-04 19:02:11 +00:00
|
|
|
and $f
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Get2DMenuNumberOfRows:
|
2018-01-23 21:08:43 +00:00
|
|
|
ld a, [wMenuData_2DMenuDimensions]
|
2015-11-04 19:02:11 +00:00
|
|
|
swap a
|
|
|
|
and $f
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Place2DMenuItemStrings:
|
2018-01-23 21:08:43 +00:00
|
|
|
ld hl, wMenuData_2DMenuItemStringsAddr
|
2015-11-04 19:02:11 +00:00
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
2015-11-10 21:53:37 +00:00
|
|
|
call GetMenuTextStartCoord
|
|
|
|
call Coord2Tile
|
2017-12-30 11:23:20 +00:00
|
|
|
call Get2DMenuNumberOfRows
|
2015-11-04 19:02:11 +00:00
|
|
|
ld b, a
|
2015-12-15 23:59:49 +00:00
|
|
|
.row
|
2015-11-04 19:02:11 +00:00
|
|
|
push bc
|
|
|
|
push hl
|
2017-12-30 11:23:20 +00:00
|
|
|
call Get2DMenuNumberOfColumns
|
2015-11-04 19:02:11 +00:00
|
|
|
ld c, a
|
2015-12-15 23:59:49 +00:00
|
|
|
.col
|
2015-11-04 19:02:11 +00:00
|
|
|
push bc
|
2018-01-23 21:08:43 +00:00
|
|
|
ld a, [wMenuData_2DMenuItemStringsBank]
|
2015-12-15 23:59:49 +00:00
|
|
|
call Place2DMenuItemName
|
2015-11-04 19:02:11 +00:00
|
|
|
inc de
|
2018-01-23 21:08:43 +00:00
|
|
|
ld a, [wMenuData_2DMenuSpacing]
|
2015-11-04 19:02:11 +00:00
|
|
|
ld c, a
|
2015-12-15 23:59:49 +00:00
|
|
|
ld b, 0
|
2015-11-04 19:02:11 +00:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec c
|
2015-12-15 23:59:49 +00:00
|
|
|
jr nz, .col
|
2015-11-04 19:02:11 +00:00
|
|
|
pop hl
|
2015-12-15 23:59:49 +00:00
|
|
|
ld bc, 2 * SCREEN_WIDTH
|
2015-11-04 19:02:11 +00:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec b
|
2015-12-15 23:59:49 +00:00
|
|
|
jr nz, .row
|
2018-01-23 21:08:43 +00:00
|
|
|
ld hl, wMenuData_2DMenuFunctionAddr
|
2015-11-04 19:02:11 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
or h
|
|
|
|
ret z
|
2018-01-23 21:08:43 +00:00
|
|
|
ld a, [wMenuData_2DMenuFunctionBank]
|
2015-11-04 19:02:11 +00:00
|
|
|
rst FarCall
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Init2DMenuCursorPosition:
|
2015-11-10 21:53:37 +00:00
|
|
|
call GetMenuTextStartCoord
|
2015-11-04 19:02:11 +00:00
|
|
|
ld a, b
|
2015-12-15 23:59:49 +00:00
|
|
|
ld [w2DMenuCursorInitY], a
|
2015-11-04 19:02:11 +00:00
|
|
|
dec c
|
|
|
|
ld a, c
|
2015-12-15 23:59:49 +00:00
|
|
|
ld [w2DMenuCursorInitX], a
|
2017-12-30 11:23:20 +00:00
|
|
|
call Get2DMenuNumberOfRows
|
2015-12-15 23:59:49 +00:00
|
|
|
ld [w2DMenuNumRows], a
|
2017-12-30 11:23:20 +00:00
|
|
|
call Get2DMenuNumberOfColumns
|
2015-12-15 23:59:49 +00:00
|
|
|
ld [w2DMenuNumCols], a
|
|
|
|
call .InitFlags_a
|
|
|
|
call .InitFlags_b
|
|
|
|
call .InitFlags_c
|
|
|
|
ld a, [w2DMenuNumCols]
|
2015-11-04 19:02:11 +00:00
|
|
|
ld e, a
|
|
|
|
ld a, [wMenuCursorBuffer]
|
|
|
|
ld b, a
|
|
|
|
xor a
|
2015-12-15 23:59:49 +00:00
|
|
|
ld d, 0
|
|
|
|
.loop
|
2015-11-04 19:02:11 +00:00
|
|
|
inc d
|
|
|
|
add e
|
|
|
|
cp b
|
2015-12-15 23:59:49 +00:00
|
|
|
jr c, .loop
|
2015-11-04 19:02:11 +00:00
|
|
|
sub e
|
|
|
|
ld c, a
|
|
|
|
ld a, b
|
|
|
|
sub c
|
|
|
|
and a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .reset1
|
2015-11-04 19:02:11 +00:00
|
|
|
cp e
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .okay1
|
|
|
|
jr c, .okay1
|
|
|
|
.reset1
|
|
|
|
ld a, 1
|
|
|
|
.okay1
|
|
|
|
ld [wMenuCursorX], a
|
|
|
|
ld a, [w2DMenuNumRows]
|
2015-11-04 19:02:11 +00:00
|
|
|
ld e, a
|
|
|
|
ld a, d
|
|
|
|
and a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .reset2
|
2015-11-04 19:02:11 +00:00
|
|
|
cp e
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .okay2
|
|
|
|
jr c, .okay2
|
|
|
|
.reset2
|
|
|
|
ld a, 1
|
|
|
|
.okay2
|
|
|
|
ld [wMenuCursorY], a
|
2015-11-04 19:02:11 +00:00
|
|
|
xor a
|
2015-12-15 23:59:49 +00:00
|
|
|
ld [wCursorOffCharacter], a
|
|
|
|
ld [wCursorCurrentTile], a
|
|
|
|
ld [wCursorCurrentTile + 1], a
|
2015-11-04 19:02:11 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.InitFlags_a:
|
2015-11-04 19:02:11 +00:00
|
|
|
xor a
|
2015-12-15 23:59:49 +00:00
|
|
|
ld hl, w2DMenuFlags1
|
2015-11-04 19:02:11 +00:00
|
|
|
ld [hli], a
|
|
|
|
ld [hld], a
|
2018-01-23 21:08:43 +00:00
|
|
|
ld a, [wMenuDataFlags]
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 5, a
|
|
|
|
ret z
|
|
|
|
set 5, [hl]
|
|
|
|
set 4, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.InitFlags_b:
|
2018-01-23 21:08:43 +00:00
|
|
|
ld a, [wMenuData_2DMenuSpacing]
|
2015-12-21 19:10:16 +00:00
|
|
|
or $20
|
|
|
|
ld [w2DMenuCursorOffsets], a
|
2015-11-04 19:02:11 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.InitFlags_c:
|
2018-01-23 21:08:43 +00:00
|
|
|
ld hl, wMenuDataFlags
|
2015-12-20 17:54:08 +00:00
|
|
|
ld a, A_BUTTON
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 0, [hl]
|
2015-12-15 23:59:49 +00:00
|
|
|
jr nz, .skip
|
2015-12-20 17:54:08 +00:00
|
|
|
or B_BUTTON
|
2015-12-15 23:59:49 +00:00
|
|
|
.skip
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 1, [hl]
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .skip2
|
2015-12-20 17:54:08 +00:00
|
|
|
or SELECT
|
2015-12-15 23:59:49 +00:00
|
|
|
.skip2
|
2015-12-20 17:54:08 +00:00
|
|
|
ld [wMenuJoypadFilter], a
|
2015-11-04 19:02:11 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
_StaticMenuJoypad::
|
2015-12-15 23:59:49 +00:00
|
|
|
call Place2DMenuCursor
|
2018-06-24 14:09:41 +00:00
|
|
|
_ScrollingMenuJoypad::
|
2015-12-15 23:59:49 +00:00
|
|
|
ld hl, w2DMenuFlags2
|
2015-11-04 19:02:11 +00:00
|
|
|
res 7, [hl]
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hBGMapMode]
|
2015-11-04 19:02:11 +00:00
|
|
|
push af
|
2015-12-15 23:59:49 +00:00
|
|
|
call MenuJoypadLoop
|
2015-11-04 19:02:11 +00:00
|
|
|
pop af
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hBGMapMode], a
|
2015-11-04 19:02:11 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
MobileMenuJoypad:
|
2015-12-15 23:59:49 +00:00
|
|
|
ld hl, w2DMenuFlags2
|
2015-11-04 19:02:11 +00:00
|
|
|
res 7, [hl]
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hBGMapMode]
|
2015-11-04 19:02:11 +00:00
|
|
|
push af
|
2015-12-15 23:59:49 +00:00
|
|
|
call Move2DMenuCursor
|
|
|
|
call Do2DMenuRTCJoypad
|
|
|
|
jr nc, .skip_joypad
|
|
|
|
call _2DMenuInterpretJoypad
|
|
|
|
.skip_joypad
|
2015-11-04 19:02:11 +00:00
|
|
|
pop af
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hBGMapMode], a
|
2015-12-15 23:59:49 +00:00
|
|
|
call GetMenuJoypad
|
2015-11-04 19:02:11 +00:00
|
|
|
ld c, a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Unreferenced_Function241d5:
|
2015-12-15 23:59:49 +00:00
|
|
|
call Place2DMenuCursor
|
2015-11-04 19:02:11 +00:00
|
|
|
.loop
|
2015-12-15 23:59:49 +00:00
|
|
|
call Move2DMenuCursor
|
2020-02-13 17:30:13 +00:00
|
|
|
call HDMATransferTilemapToWRAMBank3 ; BUG: This function is in another bank.
|
2015-11-04 19:02:11 +00:00
|
|
|
; Pointer in current bank (9) is bogus.
|
2015-12-15 23:59:49 +00:00
|
|
|
call .loop2
|
2015-11-04 19:02:11 +00:00
|
|
|
jr nc, .done
|
2015-12-15 23:59:49 +00:00
|
|
|
call _2DMenuInterpretJoypad
|
2015-11-04 19:02:11 +00:00
|
|
|
jr c, .done
|
2015-12-15 23:59:49 +00:00
|
|
|
ld a, [w2DMenuFlags1]
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 7, a
|
|
|
|
jr nz, .done
|
2015-12-15 23:59:49 +00:00
|
|
|
call GetMenuJoypad
|
2015-11-04 19:02:11 +00:00
|
|
|
ld c, a
|
2015-12-20 17:54:08 +00:00
|
|
|
ld a, [wMenuJoypadFilter]
|
2015-11-04 19:02:11 +00:00
|
|
|
and c
|
|
|
|
jr z, .loop
|
|
|
|
|
|
|
|
.done
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.loop2
|
|
|
|
call Menu_WasButtonPressed
|
2015-11-04 19:02:11 +00:00
|
|
|
ret c
|
|
|
|
ld c, 1
|
|
|
|
ld b, 3
|
2016-05-08 18:11:24 +00:00
|
|
|
call AdvanceMobileInactivityTimerAndCheckExpired ; BUG: This function is in another bank.
|
2015-11-04 19:02:11 +00:00
|
|
|
; Pointer in current bank (9) is bogus.
|
|
|
|
ret c
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall Function100337
|
2015-11-04 19:02:11 +00:00
|
|
|
ret c
|
2015-12-15 23:59:49 +00:00
|
|
|
ld a, [w2DMenuFlags1]
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 7, a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .loop2
|
2015-11-04 19:02:11 +00:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
MenuJoypadLoop:
|
2015-12-15 23:59:49 +00:00
|
|
|
.loop
|
|
|
|
call Move2DMenuCursor
|
|
|
|
call .BGMap_OAM
|
|
|
|
call Do2DMenuRTCJoypad
|
|
|
|
jr nc, .done
|
|
|
|
call _2DMenuInterpretJoypad
|
|
|
|
jr c, .done
|
|
|
|
ld a, [w2DMenuFlags1]
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 7, a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr nz, .done
|
|
|
|
call GetMenuJoypad
|
2015-11-04 19:02:11 +00:00
|
|
|
ld b, a
|
2015-12-20 17:54:08 +00:00
|
|
|
ld a, [wMenuJoypadFilter]
|
2015-11-04 19:02:11 +00:00
|
|
|
and b
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .loop
|
2015-11-04 19:02:11 +00:00
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.done
|
2015-11-04 19:02:11 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.BGMap_OAM:
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hOAMUpdate]
|
2015-11-04 19:02:11 +00:00
|
|
|
push af
|
|
|
|
ld a, $1
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hOAMUpdate], a
|
2015-11-04 19:02:11 +00:00
|
|
|
call WaitBGMap
|
|
|
|
pop af
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hOAMUpdate], a
|
2015-11-04 19:02:11 +00:00
|
|
|
xor a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hBGMapMode], a
|
2015-11-04 19:02:11 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Do2DMenuRTCJoypad:
|
2015-12-15 23:59:49 +00:00
|
|
|
.loopRTC
|
2020-02-19 18:08:40 +00:00
|
|
|
call UpdateTimeAndPals
|
2015-12-15 23:59:49 +00:00
|
|
|
call Menu_WasButtonPressed
|
2015-11-04 19:02:11 +00:00
|
|
|
ret c
|
2015-12-15 23:59:49 +00:00
|
|
|
ld a, [w2DMenuFlags1]
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 7, a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .loopRTC
|
2015-11-04 19:02:11 +00:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Menu_WasButtonPressed:
|
2015-12-15 23:59:49 +00:00
|
|
|
ld a, [w2DMenuFlags1]
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 6, a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .skip_to_joypad
|
2017-12-24 17:47:30 +00:00
|
|
|
callfar PlaySpriteAnimationsAndDelayFrame
|
2015-11-04 19:02:11 +00:00
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.skip_to_joypad
|
2015-11-04 19:02:11 +00:00
|
|
|
call JoyTextDelay
|
2015-12-15 23:59:49 +00:00
|
|
|
call GetMenuJoypad
|
2015-11-04 19:02:11 +00:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
_2DMenuInterpretJoypad:
|
2015-12-15 23:59:49 +00:00
|
|
|
call GetMenuJoypad
|
|
|
|
bit A_BUTTON_F, a
|
|
|
|
jp nz, .a_b_start_select
|
|
|
|
bit B_BUTTON_F, a
|
|
|
|
jp nz, .a_b_start_select
|
|
|
|
bit SELECT_F, a
|
|
|
|
jp nz, .a_b_start_select
|
|
|
|
bit START_F, a
|
|
|
|
jp nz, .a_b_start_select
|
|
|
|
bit D_RIGHT_F, a
|
|
|
|
jr nz, .d_right
|
|
|
|
bit D_LEFT_F, a
|
|
|
|
jr nz, .d_left
|
|
|
|
bit D_UP_F, a
|
|
|
|
jr nz, .d_up
|
|
|
|
bit D_DOWN_F, a
|
|
|
|
jr nz, .d_down
|
2015-11-04 19:02:11 +00:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.set_bit_7
|
2015-12-15 23:59:49 +00:00
|
|
|
ld hl, w2DMenuFlags2
|
2015-11-04 19:02:11 +00:00
|
|
|
set 7, [hl]
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.d_down
|
|
|
|
ld hl, wMenuCursorY
|
|
|
|
ld a, [w2DMenuNumRows]
|
2015-11-04 19:02:11 +00:00
|
|
|
cp [hl]
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .check_wrap_around_down
|
2015-11-04 19:02:11 +00:00
|
|
|
inc [hl]
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.check_wrap_around_down
|
|
|
|
ld a, [w2DMenuFlags1]
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 5, a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr nz, .wrap_around_down
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 3, a
|
2015-12-15 23:59:49 +00:00
|
|
|
jp nz, .set_bit_7
|
2015-11-04 19:02:11 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.wrap_around_down
|
2015-11-04 19:02:11 +00:00
|
|
|
ld [hl], $1
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.d_up
|
|
|
|
ld hl, wMenuCursorY
|
2015-11-04 19:02:11 +00:00
|
|
|
ld a, [hl]
|
|
|
|
dec a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .check_wrap_around_up
|
2015-11-04 19:02:11 +00:00
|
|
|
ld [hl], a
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.check_wrap_around_up
|
|
|
|
ld a, [w2DMenuFlags1]
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 5, a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr nz, .wrap_around_up
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 2, a
|
2015-12-15 23:59:49 +00:00
|
|
|
jp nz, .set_bit_7
|
2015-11-04 19:02:11 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.wrap_around_up
|
|
|
|
ld a, [w2DMenuNumRows]
|
2015-11-04 19:02:11 +00:00
|
|
|
ld [hl], a
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.d_left
|
|
|
|
ld hl, wMenuCursorX
|
2015-11-04 19:02:11 +00:00
|
|
|
ld a, [hl]
|
|
|
|
dec a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .check_wrap_around_left
|
2015-11-04 19:02:11 +00:00
|
|
|
ld [hl], a
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.check_wrap_around_left
|
|
|
|
ld a, [w2DMenuFlags1]
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 4, a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr nz, .wrap_around_left
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 1, a
|
2015-12-15 23:59:49 +00:00
|
|
|
jp nz, .set_bit_7
|
2015-11-04 19:02:11 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.wrap_around_left
|
|
|
|
ld a, [w2DMenuNumCols]
|
2015-11-04 19:02:11 +00:00
|
|
|
ld [hl], a
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.d_right
|
|
|
|
ld hl, wMenuCursorX
|
|
|
|
ld a, [w2DMenuNumCols]
|
2015-11-04 19:02:11 +00:00
|
|
|
cp [hl]
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .check_wrap_around_right
|
2015-11-04 19:02:11 +00:00
|
|
|
inc [hl]
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.check_wrap_around_right
|
|
|
|
ld a, [w2DMenuFlags1]
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 4, a
|
2015-12-15 23:59:49 +00:00
|
|
|
jr nz, .wrap_around_right
|
2015-11-04 19:02:11 +00:00
|
|
|
bit 0, a
|
2015-12-15 23:59:49 +00:00
|
|
|
jp nz, .set_bit_7
|
2015-11-04 19:02:11 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.wrap_around_right
|
2015-11-04 19:02:11 +00:00
|
|
|
ld [hl], $1
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.a_b_start_select
|
2015-11-04 19:02:11 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Move2DMenuCursor:
|
2015-12-15 23:59:49 +00:00
|
|
|
ld hl, wCursorCurrentTile
|
2015-11-04 19:02:11 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld a, [hl]
|
2015-12-15 23:59:49 +00:00
|
|
|
cp "▶"
|
|
|
|
jr nz, Place2DMenuCursor
|
|
|
|
ld a, [wCursorOffCharacter]
|
2015-11-04 19:02:11 +00:00
|
|
|
ld [hl], a
|
2018-06-24 14:09:41 +00:00
|
|
|
Place2DMenuCursor:
|
2015-12-15 23:59:49 +00:00
|
|
|
ld a, [w2DMenuCursorInitY]
|
2015-11-04 19:02:11 +00:00
|
|
|
ld b, a
|
2015-12-15 23:59:49 +00:00
|
|
|
ld a, [w2DMenuCursorInitX]
|
2015-11-04 19:02:11 +00:00
|
|
|
ld c, a
|
2015-11-10 21:53:37 +00:00
|
|
|
call Coord2Tile
|
2015-12-21 19:10:16 +00:00
|
|
|
ld a, [w2DMenuCursorOffsets]
|
2015-11-04 19:02:11 +00:00
|
|
|
swap a
|
|
|
|
and $f
|
|
|
|
ld c, a
|
2015-12-15 23:59:49 +00:00
|
|
|
ld a, [wMenuCursorY]
|
2015-11-04 19:02:11 +00:00
|
|
|
ld b, a
|
|
|
|
xor a
|
|
|
|
dec b
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .got_row
|
|
|
|
.row_loop
|
2015-11-04 19:02:11 +00:00
|
|
|
add c
|
|
|
|
dec b
|
2015-12-15 23:59:49 +00:00
|
|
|
jr nz, .row_loop
|
2015-11-04 19:02:11 +00:00
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.got_row
|
|
|
|
ld c, SCREEN_WIDTH
|
2015-11-04 19:02:11 +00:00
|
|
|
call AddNTimes
|
2015-12-21 19:10:16 +00:00
|
|
|
ld a, [w2DMenuCursorOffsets]
|
2015-11-04 19:02:11 +00:00
|
|
|
and $f
|
|
|
|
ld c, a
|
2015-12-15 23:59:49 +00:00
|
|
|
ld a, [wMenuCursorX]
|
2015-11-04 19:02:11 +00:00
|
|
|
ld b, a
|
|
|
|
xor a
|
|
|
|
dec b
|
2015-12-15 23:59:49 +00:00
|
|
|
jr z, .got_col
|
|
|
|
.col_loop
|
2015-11-04 19:02:11 +00:00
|
|
|
add c
|
|
|
|
dec b
|
2015-12-15 23:59:49 +00:00
|
|
|
jr nz, .col_loop
|
2015-11-04 19:02:11 +00:00
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.got_col
|
2015-11-04 19:02:11 +00:00
|
|
|
ld c, a
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-12-15 23:59:49 +00:00
|
|
|
cp "▶"
|
|
|
|
jr z, .cursor_on
|
|
|
|
ld [wCursorOffCharacter], a
|
|
|
|
ld [hl], "▶"
|
2015-11-04 19:02:11 +00:00
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
.cursor_on
|
2015-11-04 19:02:11 +00:00
|
|
|
ld a, l
|
2015-12-15 23:59:49 +00:00
|
|
|
ld [wCursorCurrentTile], a
|
2015-11-04 19:02:11 +00:00
|
|
|
ld a, h
|
2015-12-15 23:59:49 +00:00
|
|
|
ld [wCursorCurrentTile + 1], a
|
2015-11-04 19:02:11 +00:00
|
|
|
ret
|
2015-12-15 23:59:49 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
_PushWindow::
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rSVBK]
|
2015-12-15 23:59:49 +00:00
|
|
|
push af
|
2018-01-04 00:12:45 +00:00
|
|
|
ld a, BANK(wWindowStack)
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2015-12-15 23:59:49 +00:00
|
|
|
|
|
|
|
ld hl, wWindowStackPointer
|
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
|
|
|
push de
|
|
|
|
|
|
|
|
ld b, $10
|
|
|
|
ld hl, wMenuFlags
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
dec de
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
; If bit 6 or 7 of the menu flags is set, set bit 0 of the address
|
|
|
|
; at 7:[wWindowStackPointer], and draw the menu using the coordinates from the header.
|
|
|
|
; Otherwise, reset bit 0 of 7:[wWindowStackPointer].
|
|
|
|
ld a, [wMenuFlags]
|
|
|
|
bit 6, a
|
|
|
|
jr nz, .bit_6
|
|
|
|
bit 7, a
|
|
|
|
jr z, .not_bit_7
|
|
|
|
|
|
|
|
.bit_6
|
|
|
|
ld hl, wWindowStackPointer
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
set 0, [hl]
|
|
|
|
call MenuBoxCoord2Tile
|
|
|
|
call .copy
|
|
|
|
call MenuBoxCoord2Attr
|
|
|
|
call .copy
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.not_bit_7
|
|
|
|
pop hl ; last-pushed register was de
|
|
|
|
push hl
|
|
|
|
ld a, [hld]
|
|
|
|
ld l, [hl]
|
|
|
|
ld h, a
|
|
|
|
res 0, [hl]
|
|
|
|
|
|
|
|
.done
|
|
|
|
pop hl
|
|
|
|
call .ret ; empty function
|
|
|
|
ld a, h
|
|
|
|
ld [de], a
|
|
|
|
dec de
|
|
|
|
ld a, l
|
|
|
|
ld [de], a
|
|
|
|
dec de
|
|
|
|
ld hl, wWindowStackPointer
|
|
|
|
ld [hl], e
|
|
|
|
inc hl
|
|
|
|
ld [hl], d
|
|
|
|
|
|
|
|
pop af
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2015-12-15 23:59:49 +00:00
|
|
|
ld hl, wWindowStackSize
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.copy
|
2015-12-15 23:59:49 +00:00
|
|
|
call GetMenuBoxDims
|
|
|
|
inc b
|
|
|
|
inc c
|
|
|
|
call .ret ; empty function
|
|
|
|
|
|
|
|
.row
|
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
|
|
|
|
.col
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
dec de
|
|
|
|
dec c
|
|
|
|
jr nz, .col
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
ld bc, SCREEN_WIDTH
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec b
|
|
|
|
jr nz, .row
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.ret
|
2015-12-15 23:59:49 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
_ExitMenu::
|
2015-12-15 23:59:49 +00:00
|
|
|
xor a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hBGMapMode], a
|
2015-12-15 23:59:49 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rSVBK]
|
2015-12-15 23:59:49 +00:00
|
|
|
push af
|
2018-01-04 00:12:45 +00:00
|
|
|
ld a, BANK(wWindowStack)
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2015-12-15 23:59:49 +00:00
|
|
|
|
|
|
|
call GetWindowStackTop
|
|
|
|
ld a, l
|
|
|
|
or h
|
|
|
|
jp z, Error_Cant_ExitMenu
|
|
|
|
ld a, l
|
|
|
|
ld [wWindowStackPointer], a
|
|
|
|
ld a, h
|
|
|
|
ld [wWindowStackPointer + 1], a
|
|
|
|
call PopWindow
|
|
|
|
ld a, [wMenuFlags]
|
|
|
|
bit 0, a
|
2015-12-16 17:32:08 +00:00
|
|
|
jr z, .loop
|
2015-12-15 23:59:49 +00:00
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
call RestoreTileBackup
|
|
|
|
|
2015-12-16 17:32:08 +00:00
|
|
|
.loop
|
2015-12-15 23:59:49 +00:00
|
|
|
call GetWindowStackTop
|
|
|
|
ld a, h
|
|
|
|
or l
|
|
|
|
jr z, .done
|
|
|
|
call PopWindow
|
|
|
|
|
|
|
|
.done
|
|
|
|
pop af
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2015-12-15 23:59:49 +00:00
|
|
|
ld hl, wWindowStackSize
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Unreferenced_Function24423:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wVramState]
|
2015-12-15 23:59:49 +00:00
|
|
|
bit 0, a
|
|
|
|
ret z
|
2018-01-09 04:07:46 +00:00
|
|
|
xor a ; sScratch
|
2015-12-15 23:59:49 +00:00
|
|
|
call GetSRAMBank
|
|
|
|
hlcoord 0, 0
|
|
|
|
ld de, sScratch
|
|
|
|
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
|
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
call OverworldTextModeSwitch
|
2018-01-09 04:07:46 +00:00
|
|
|
xor a ; sScratch
|
2015-12-15 23:59:49 +00:00
|
|
|
call GetSRAMBank
|
|
|
|
ld hl, sScratch
|
|
|
|
decoord 0, 0
|
|
|
|
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
|
2015-12-16 17:32:08 +00:00
|
|
|
.loop
|
2015-12-15 23:59:49 +00:00
|
|
|
ld a, [hl]
|
|
|
|
cp $61
|
2015-12-16 17:32:08 +00:00
|
|
|
jr c, .next
|
2015-12-15 23:59:49 +00:00
|
|
|
ld [de], a
|
2015-12-16 17:32:08 +00:00
|
|
|
.next
|
2015-12-15 23:59:49 +00:00
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
dec bc
|
|
|
|
ld a, c
|
|
|
|
or b
|
2015-12-16 17:32:08 +00:00
|
|
|
jr nz, .loop
|
2015-12-15 23:59:49 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Error_Cant_ExitMenu:
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, .WindowPoppingErrorText
|
2015-12-15 23:59:49 +00:00
|
|
|
call PrintText
|
|
|
|
call WaitBGMap
|
2019-10-20 22:24:17 +00:00
|
|
|
.infinite_loop
|
|
|
|
jr .infinite_loop
|
2015-12-15 23:59:49 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
.WindowPoppingErrorText:
|
|
|
|
text_far _WindowPoppingErrorText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2015-12-15 23:59:49 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
_InitVerticalMenuCursor::
|
2018-01-23 21:08:43 +00:00
|
|
|
ld a, [wMenuDataFlags]
|
2015-12-15 23:59:49 +00:00
|
|
|
ld b, a
|
|
|
|
ld hl, w2DMenuCursorInitY
|
|
|
|
ld a, [wMenuBorderTopCoord]
|
|
|
|
inc a
|
|
|
|
bit 6, b
|
|
|
|
jr nz, .skip_offset
|
|
|
|
inc a
|
|
|
|
.skip_offset
|
|
|
|
ld [hli], a
|
|
|
|
; w2DMenuCursorInitX
|
|
|
|
ld a, [wMenuBorderLeftCoord]
|
|
|
|
inc a
|
|
|
|
ld [hli], a
|
|
|
|
; w2DMenuNumRows
|
2018-01-23 21:08:43 +00:00
|
|
|
ld a, [wMenuDataItems]
|
2015-12-15 23:59:49 +00:00
|
|
|
ld [hli], a
|
|
|
|
; w2DMenuNumCols
|
|
|
|
ld a, 1
|
|
|
|
ld [hli], a
|
|
|
|
; w2DMenuFlags1
|
|
|
|
ld [hl], $0
|
|
|
|
bit 5, b
|
|
|
|
jr z, .skip_bit_5
|
|
|
|
set 5, [hl]
|
|
|
|
.skip_bit_5
|
|
|
|
ld a, [wMenuFlags]
|
|
|
|
bit 4, a
|
|
|
|
jr z, .skip_bit_6
|
|
|
|
set 6, [hl]
|
|
|
|
.skip_bit_6
|
|
|
|
inc hl
|
|
|
|
; w2DMenuFlags2
|
|
|
|
xor a
|
|
|
|
ld [hli], a
|
2015-12-21 19:10:16 +00:00
|
|
|
; w2DMenuCursorOffsets
|
|
|
|
ln a, 2, 0
|
2015-12-15 23:59:49 +00:00
|
|
|
ld [hli], a
|
2015-12-20 17:54:08 +00:00
|
|
|
; wMenuJoypadFilter
|
|
|
|
ld a, A_BUTTON
|
2015-12-15 23:59:49 +00:00
|
|
|
bit 0, b
|
|
|
|
jr nz, .skip_bit_1
|
2015-12-20 17:54:08 +00:00
|
|
|
add B_BUTTON
|
2015-12-15 23:59:49 +00:00
|
|
|
.skip_bit_1
|
|
|
|
ld [hli], a
|
|
|
|
; wMenuCursorY
|
|
|
|
ld a, [wMenuCursorBuffer]
|
|
|
|
and a
|
|
|
|
jr z, .load_at_the_top
|
|
|
|
ld c, a
|
2018-01-23 21:08:43 +00:00
|
|
|
ld a, [wMenuDataItems]
|
2015-12-15 23:59:49 +00:00
|
|
|
cp c
|
|
|
|
jr nc, .load_position
|
|
|
|
.load_at_the_top
|
|
|
|
ld c, 1
|
|
|
|
.load_position
|
|
|
|
ld [hl], c
|
|
|
|
inc hl
|
|
|
|
; wMenuCursorX
|
|
|
|
ld a, 1
|
|
|
|
ld [hli], a
|
|
|
|
; wCursorOffCharacter, wCursorCurrentTile
|
|
|
|
xor a
|
|
|
|
ld [hli], a
|
2016-05-10 16:31:49 +00:00
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
2015-12-15 23:59:49 +00:00
|
|
|
ret
|