2015-12-22 19:19:33 -08:00
|
|
|
PushWindow:: ; 1c00
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar _PushWindow
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
; 1c07
|
|
|
|
|
|
|
|
ExitMenu:: ; 0x1c07
|
|
|
|
push af
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar _ExitMenu
|
2015-10-24 07:34:19 -07:00
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2015-12-15 15:59:49 -08:00
|
|
|
InitVerticalMenuCursor:: ; 0x1c10
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar _InitVerticalMenuCursor
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2015-12-24 19:58:42 -08:00
|
|
|
CloseWindow:: ; 0x1c17
|
2015-10-24 07:34:19 -07:00
|
|
|
push af
|
|
|
|
call ExitMenu
|
2015-11-25 07:16:29 -08:00
|
|
|
call ApplyTilemap
|
2015-10-24 07:34:19 -07:00
|
|
|
call UpdateSprites
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
|
|
|
RestoreTileBackup:: ; 0x1c23
|
2015-11-10 13:53:37 -08:00
|
|
|
call MenuBoxCoord2Tile
|
2015-10-24 07:34:19 -07:00
|
|
|
call .copy
|
2015-11-10 13:53:37 -08:00
|
|
|
call MenuBoxCoord2Attr
|
2015-10-24 07:34:19 -07:00
|
|
|
call .copy
|
|
|
|
ret
|
|
|
|
; 0x1c30
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.copy ; 0x1c30
|
2015-10-24 07:34:19 -07:00
|
|
|
call GetMenuBoxDims
|
2013-11-26 03:44:05 -08:00
|
|
|
inc b
|
|
|
|
inc c
|
2015-10-24 07:34:19 -07:00
|
|
|
|
|
|
|
.row
|
2013-11-26 03:44:05 -08:00
|
|
|
push bc
|
|
|
|
push hl
|
2015-10-24 07:34:19 -07:00
|
|
|
|
|
|
|
.col
|
2013-11-26 03:44:05 -08:00
|
|
|
ld a, [de]
|
|
|
|
ld [hli], a
|
|
|
|
dec de
|
|
|
|
dec c
|
2015-10-24 07:34:19 -07:00
|
|
|
jr nz, .col ; 0x1c3b $fa
|
|
|
|
|
2013-11-26 03:44:05 -08:00
|
|
|
pop hl
|
2015-10-24 07:34:19 -07:00
|
|
|
ld bc, SCREEN_WIDTH
|
2013-11-26 03:44:05 -08:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec b
|
2015-10-24 07:34:19 -07:00
|
|
|
jr nz, .row ; 0x1c44 $ef
|
|
|
|
|
2013-11-26 03:44:05 -08:00
|
|
|
ret
|
|
|
|
|
2015-12-15 15:59:49 -08:00
|
|
|
PopWindow:: ; 0x1c47
|
2013-11-26 03:44:05 -08:00
|
|
|
ld b, $10
|
2015-11-10 13:53:37 -08:00
|
|
|
ld de, wMenuFlags
|
2015-10-24 07:34:19 -07:00
|
|
|
.loop
|
2013-11-26 03:44:05 -08:00
|
|
|
ld a, [hld]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec b
|
2015-10-24 07:34:19 -07:00
|
|
|
jr nz, .loop ; 0x1c50 $fa
|
2013-11-26 03:44:05 -08:00
|
|
|
ret
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
GetMenuBoxDims:: ; 0x1c53
|
|
|
|
ld a, [wMenuBorderTopCoord] ; top
|
2013-11-26 03:44:05 -08:00
|
|
|
ld b, a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderBottomCoord] ; bottom
|
2013-11-26 03:44:05 -08:00
|
|
|
sub b
|
|
|
|
ld b, a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderLeftCoord] ; left
|
2013-11-26 03:44:05 -08:00
|
|
|
ld c, a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderRightCoord] ; right
|
2013-11-26 03:44:05 -08:00
|
|
|
sub c
|
|
|
|
ld c, a
|
|
|
|
ret
|
|
|
|
; 0x1c66
|
|
|
|
|
2018-01-23 13:08:43 -08:00
|
|
|
CopyMenuData:: ; 1c66
|
2013-11-26 03:44:05 -08:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push af
|
2018-01-23 13:08:43 -08:00
|
|
|
ld hl, wMenuDataPointer
|
2013-11-26 03:44:05 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2018-01-23 13:08:43 -08:00
|
|
|
ld de, wMenuDataFlags
|
|
|
|
ld bc, wMenuDataEnd - wMenuDataFlags
|
2013-11-26 03:44:05 -08:00
|
|
|
call CopyBytes
|
|
|
|
pop af
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 1c7e
|
|
|
|
|
2015-12-15 15:59:49 -08:00
|
|
|
GetWindowStackTop:: ; 1c7e
|
|
|
|
ld hl, wWindowStackPointer
|
2013-11-26 03:44:05 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
inc hl
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ret
|
|
|
|
; 1c89
|
|
|
|
|
2015-12-15 15:59:49 -08:00
|
|
|
PlaceVerticalMenuItems:: ; 1c89
|
2018-01-23 13:08:43 -08:00
|
|
|
call CopyMenuData
|
|
|
|
ld hl, wMenuDataPointer
|
2013-11-26 03:44:05 -08:00
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
2015-11-10 13:53:37 -08:00
|
|
|
call GetMenuTextStartCoord
|
2018-01-30 11:05:25 -08:00
|
|
|
call Coord2Tile ; hl now contains the tilemap address where we will start printing text.
|
2013-11-26 03:44:05 -08:00
|
|
|
inc de
|
2015-11-10 13:53:37 -08:00
|
|
|
ld a, [de] ; Number of items
|
2013-11-26 03:44:05 -08:00
|
|
|
inc de
|
|
|
|
ld b, a
|
2015-11-10 13:53:37 -08:00
|
|
|
.loop
|
2013-11-26 03:44:05 -08:00
|
|
|
push bc
|
|
|
|
call PlaceString
|
|
|
|
inc de
|
2015-11-10 13:53:37 -08:00
|
|
|
ld bc, 2 * SCREEN_WIDTH
|
2013-11-26 03:44:05 -08:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec b
|
2015-11-10 13:53:37 -08:00
|
|
|
jr nz, .loop
|
2015-12-15 15:59:49 -08:00
|
|
|
|
2018-01-23 13:08:43 -08:00
|
|
|
ld a, [wMenuDataFlags]
|
2013-11-26 03:44:05 -08:00
|
|
|
bit 4, a
|
|
|
|
ret z
|
2015-11-10 13:53:37 -08:00
|
|
|
|
|
|
|
call MenuBoxCoord2Tile
|
2013-11-26 03:44:05 -08:00
|
|
|
ld a, [de]
|
|
|
|
ld c, a
|
|
|
|
inc de
|
|
|
|
ld b, $0
|
|
|
|
add hl, bc
|
|
|
|
jp PlaceString
|
|
|
|
; 1cbb
|
|
|
|
|
2015-11-04 11:02:11 -08:00
|
|
|
MenuBox:: ; 1cbb
|
2015-11-10 13:53:37 -08:00
|
|
|
call MenuBoxCoord2Tile
|
2015-10-24 07:34:19 -07:00
|
|
|
call GetMenuBoxDims
|
2013-11-26 03:44:05 -08:00
|
|
|
dec b
|
|
|
|
dec c
|
|
|
|
jp TextBox
|
|
|
|
; 1cc6
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
GetMenuTextStartCoord:: ; 1cc6
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderTopCoord]
|
2013-11-26 03:44:05 -08:00
|
|
|
ld b, a
|
|
|
|
inc b
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderLeftCoord]
|
2013-11-26 03:44:05 -08:00
|
|
|
ld c, a
|
|
|
|
inc c
|
2015-11-10 13:53:37 -08:00
|
|
|
; bit 6: if not set, leave extra room on top
|
2018-01-23 13:08:43 -08:00
|
|
|
ld a, [wMenuDataFlags]
|
2013-11-26 03:44:05 -08:00
|
|
|
bit 6, a
|
2015-11-10 13:53:37 -08:00
|
|
|
jr nz, .bit_6_set
|
2013-11-26 03:44:05 -08:00
|
|
|
inc b
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
.bit_6_set
|
|
|
|
; bit 7: if set, leave extra room on the left
|
2018-01-23 13:08:43 -08:00
|
|
|
ld a, [wMenuDataFlags]
|
2013-11-26 03:44:05 -08:00
|
|
|
bit 7, a
|
2015-11-10 13:53:37 -08:00
|
|
|
jr z, .bit_7_clear
|
2013-11-26 03:44:05 -08:00
|
|
|
inc c
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
.bit_7_clear
|
2013-11-26 03:44:05 -08:00
|
|
|
ret
|
|
|
|
; 1ce1
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
ClearMenuBoxInterior:: ; 1ce1
|
|
|
|
call MenuBoxCoord2Tile
|
|
|
|
ld bc, SCREEN_WIDTH + 1
|
2013-11-26 03:44:05 -08:00
|
|
|
add hl, bc
|
2015-10-24 07:34:19 -07:00
|
|
|
call GetMenuBoxDims
|
2013-11-26 03:44:05 -08:00
|
|
|
dec b
|
|
|
|
dec c
|
|
|
|
call ClearBox
|
|
|
|
ret
|
|
|
|
; 1cf1
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
ClearWholeMenuBox:: ; 1cf1
|
|
|
|
call MenuBoxCoord2Tile
|
2015-10-24 07:34:19 -07:00
|
|
|
call GetMenuBoxDims
|
2013-11-26 03:44:05 -08:00
|
|
|
inc c
|
|
|
|
inc b
|
|
|
|
call ClearBox
|
|
|
|
ret
|
|
|
|
; 1cfd
|
|
|
|
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
MenuBoxCoord2Tile:: ; 1cfd
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderLeftCoord]
|
2013-11-26 03:44:05 -08:00
|
|
|
ld c, a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderTopCoord]
|
2013-11-26 03:44:05 -08:00
|
|
|
ld b, a
|
|
|
|
; 1d05
|
|
|
|
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
Coord2Tile:: ; 1d05
|
2018-01-23 14:39:09 -08:00
|
|
|
; Return the address of wTileMap(c, b) in hl.
|
2013-11-26 03:44:05 -08:00
|
|
|
xor a
|
|
|
|
ld h, a
|
|
|
|
ld l, b
|
|
|
|
ld a, c
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
add hl, hl
|
2015-12-26 18:59:03 -08:00
|
|
|
add hl, hl
|
2013-11-26 03:44:05 -08:00
|
|
|
add hl, bc
|
|
|
|
add hl, hl
|
2015-12-26 18:59:03 -08:00
|
|
|
add hl, hl
|
2013-11-26 03:44:05 -08:00
|
|
|
ld c, a
|
|
|
|
xor a
|
|
|
|
ld b, a
|
|
|
|
add hl, bc
|
2015-07-22 12:57:02 -07:00
|
|
|
bccoord 0, 0
|
2013-11-26 03:44:05 -08:00
|
|
|
add hl, bc
|
|
|
|
ret
|
|
|
|
; 1d19
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
MenuBoxCoord2Attr:: ; 1d19
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderLeftCoord]
|
2013-11-26 03:44:05 -08:00
|
|
|
ld c, a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderTopCoord]
|
2013-11-26 03:44:05 -08:00
|
|
|
ld b, a
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
Coord2Attr:: ; 1d21
|
2018-01-23 14:39:09 -08:00
|
|
|
; Return the address of wAttrMap(c, b) in hl.
|
2013-11-26 03:44:05 -08:00
|
|
|
xor a
|
|
|
|
ld h, a
|
|
|
|
ld l, b
|
|
|
|
ld a, c
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
add hl, hl
|
2015-12-26 18:59:03 -08:00
|
|
|
add hl, hl
|
2013-11-26 03:44:05 -08:00
|
|
|
add hl, bc
|
|
|
|
add hl, hl
|
2015-12-26 18:59:03 -08:00
|
|
|
add hl, hl
|
2013-11-26 03:44:05 -08:00
|
|
|
ld c, a
|
|
|
|
xor a
|
|
|
|
ld b, a
|
|
|
|
add hl, bc
|
2018-01-23 14:39:09 -08:00
|
|
|
bccoord 0, 0, wAttrMap
|
2013-11-26 03:44:05 -08:00
|
|
|
add hl, bc
|
|
|
|
ret
|
|
|
|
; 1d35
|