2018-06-24 14:09:41 +00:00
|
|
|
PushWindow::
|
2018-04-05 04:35:14 +00:00
|
|
|
callfar _PushWindow
|
|
|
|
ret
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
ExitMenu::
|
2018-04-05 04:35:14 +00:00
|
|
|
push af
|
|
|
|
callfar _ExitMenu
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
InitVerticalMenuCursor::
|
2018-04-05 04:35:14 +00:00
|
|
|
callfar _InitVerticalMenuCursor
|
|
|
|
ret
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
CloseWindow::
|
2018-04-05 04:35:14 +00:00
|
|
|
push af
|
|
|
|
call ExitMenu
|
|
|
|
call ApplyTilemap
|
|
|
|
call UpdateSprites
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
RestoreTileBackup::
|
2018-04-05 04:35:14 +00:00
|
|
|
call MenuBoxCoord2Tile
|
|
|
|
call .copy
|
|
|
|
call MenuBoxCoord2Attr
|
|
|
|
call .copy
|
|
|
|
ret
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
.copy
|
2018-04-05 04:35:14 +00:00
|
|
|
call GetMenuBoxDims
|
|
|
|
inc b
|
|
|
|
inc c
|
|
|
|
|
|
|
|
.row
|
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
|
|
|
|
.col
|
|
|
|
ld a, [de]
|
|
|
|
ld [hli], a
|
|
|
|
dec de
|
|
|
|
dec c
|
2018-06-25 01:39:23 +00:00
|
|
|
jr nz, .col
|
2018-04-05 04:35:14 +00:00
|
|
|
|
|
|
|
pop hl
|
|
|
|
ld bc, SCREEN_WIDTH
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec b
|
2018-06-25 01:39:23 +00:00
|
|
|
jr nz, .row
|
2018-04-05 04:35:14 +00:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
PopWindow::
|
2018-04-05 04:35:14 +00:00
|
|
|
ld b, $10
|
|
|
|
ld de, wMenuFlags
|
|
|
|
.loop
|
|
|
|
ld a, [hld]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec b
|
2018-06-25 01:39:23 +00:00
|
|
|
jr nz, .loop
|
2018-04-05 04:35:14 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
GetMenuBoxDims::
|
2018-04-05 04:35:14 +00:00
|
|
|
ld a, [wMenuBorderTopCoord] ; top
|
|
|
|
ld b, a
|
|
|
|
ld a, [wMenuBorderBottomCoord] ; bottom
|
|
|
|
sub b
|
|
|
|
ld b, a
|
|
|
|
ld a, [wMenuBorderLeftCoord] ; left
|
|
|
|
ld c, a
|
|
|
|
ld a, [wMenuBorderRightCoord] ; right
|
|
|
|
sub c
|
|
|
|
ld c, a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CopyMenuData::
|
2018-04-05 04:35:14 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push af
|
|
|
|
ld hl, wMenuDataPointer
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld de, wMenuDataFlags
|
|
|
|
ld bc, wMenuDataEnd - wMenuDataFlags
|
|
|
|
call CopyBytes
|
|
|
|
pop af
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
GetWindowStackTop::
|
2018-04-05 04:35:14 +00:00
|
|
|
ld hl, wWindowStackPointer
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
inc hl
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
PlaceVerticalMenuItems::
|
2018-04-05 04:35:14 +00:00
|
|
|
call CopyMenuData
|
|
|
|
ld hl, wMenuDataPointer
|
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
|
|
|
call GetMenuTextStartCoord
|
|
|
|
call Coord2Tile ; hl now contains the tilemap address where we will start printing text.
|
|
|
|
inc de
|
|
|
|
ld a, [de] ; Number of items
|
|
|
|
inc de
|
|
|
|
ld b, a
|
|
|
|
.loop
|
|
|
|
push bc
|
|
|
|
call PlaceString
|
|
|
|
inc de
|
|
|
|
ld bc, 2 * SCREEN_WIDTH
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
ld a, [wMenuDataFlags]
|
|
|
|
bit 4, a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
call MenuBoxCoord2Tile
|
|
|
|
ld a, [de]
|
|
|
|
ld c, a
|
|
|
|
inc de
|
|
|
|
ld b, $0
|
|
|
|
add hl, bc
|
|
|
|
jp PlaceString
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
MenuBox::
|
2018-04-05 04:35:14 +00:00
|
|
|
call MenuBoxCoord2Tile
|
|
|
|
call GetMenuBoxDims
|
|
|
|
dec b
|
|
|
|
dec c
|
2019-04-08 12:15:10 +00:00
|
|
|
jp Textbox
|
2018-04-05 04:35:14 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
GetMenuTextStartCoord::
|
2018-04-05 04:35:14 +00:00
|
|
|
ld a, [wMenuBorderTopCoord]
|
|
|
|
ld b, a
|
|
|
|
inc b
|
|
|
|
ld a, [wMenuBorderLeftCoord]
|
|
|
|
ld c, a
|
|
|
|
inc c
|
|
|
|
; bit 6: if not set, leave extra room on top
|
|
|
|
ld a, [wMenuDataFlags]
|
|
|
|
bit 6, a
|
|
|
|
jr nz, .bit_6_set
|
|
|
|
inc b
|
|
|
|
|
|
|
|
.bit_6_set
|
|
|
|
; bit 7: if set, leave extra room on the left
|
|
|
|
ld a, [wMenuDataFlags]
|
|
|
|
bit 7, a
|
|
|
|
jr z, .bit_7_clear
|
|
|
|
inc c
|
|
|
|
|
|
|
|
.bit_7_clear
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
ClearMenuBoxInterior::
|
2018-04-05 04:35:14 +00:00
|
|
|
call MenuBoxCoord2Tile
|
|
|
|
ld bc, SCREEN_WIDTH + 1
|
|
|
|
add hl, bc
|
|
|
|
call GetMenuBoxDims
|
|
|
|
dec b
|
|
|
|
dec c
|
|
|
|
call ClearBox
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
ClearWholeMenuBox::
|
2018-04-05 04:35:14 +00:00
|
|
|
call MenuBoxCoord2Tile
|
|
|
|
call GetMenuBoxDims
|
|
|
|
inc c
|
|
|
|
inc b
|
|
|
|
call ClearBox
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
MenuBoxCoord2Tile::
|
2018-04-05 04:35:14 +00:00
|
|
|
ld a, [wMenuBorderLeftCoord]
|
|
|
|
ld c, a
|
|
|
|
ld a, [wMenuBorderTopCoord]
|
|
|
|
ld b, a
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Coord2Tile::
|
2018-04-05 04:35:14 +00:00
|
|
|
; Return the address of wTileMap(c, b) in hl.
|
|
|
|
xor a
|
|
|
|
ld h, a
|
|
|
|
ld l, b
|
|
|
|
ld a, c
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
add hl, hl
|
|
|
|
add hl, hl
|
|
|
|
add hl, bc
|
|
|
|
add hl, hl
|
|
|
|
add hl, hl
|
|
|
|
ld c, a
|
|
|
|
xor a
|
|
|
|
ld b, a
|
|
|
|
add hl, bc
|
|
|
|
bccoord 0, 0
|
|
|
|
add hl, bc
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
MenuBoxCoord2Attr::
|
2018-04-05 04:35:14 +00:00
|
|
|
ld a, [wMenuBorderLeftCoord]
|
|
|
|
ld c, a
|
|
|
|
ld a, [wMenuBorderTopCoord]
|
|
|
|
ld b, a
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Coord2Attr::
|
2018-04-05 04:35:14 +00:00
|
|
|
; Return the address of wAttrMap(c, b) in hl.
|
|
|
|
xor a
|
|
|
|
ld h, a
|
|
|
|
ld l, b
|
|
|
|
ld a, c
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
add hl, hl
|
|
|
|
add hl, hl
|
|
|
|
add hl, bc
|
|
|
|
add hl, hl
|
|
|
|
add hl, hl
|
|
|
|
ld c, a
|
|
|
|
xor a
|
|
|
|
ld b, a
|
|
|
|
add hl, bc
|
|
|
|
bccoord 0, 0, wAttrMap
|
|
|
|
add hl, bc
|
|
|
|
ret
|