pokecrystal-board/home/tilemap.asm

261 lines
3.3 KiB
NASM
Raw Normal View History

2015-10-24 07:34:19 -07:00
BackUpTiles:: ; 1c00
callab _BackUpTiles
ret
; 1c07
ExitMenu:: ; 0x1c07
push af
callab Function243e8
pop af
ret
Function1c10:: ; 0x1c10
callab Function2446d
ret
WriteBackup:: ; 0x1c17
push af
call ExitMenu
call Function321c
call UpdateSprites
pop af
ret
RestoreTileBackup:: ; 0x1c23
call MenuBoxCoord2Tile
2015-10-24 07:34:19 -07:00
call .copy
call MenuBoxCoord2Attr
2015-10-24 07:34:19 -07:00
call .copy
ret
; 0x1c30
.copy: ; 0x1c30
call GetMenuBoxDims
inc b
inc c
2015-10-24 07:34:19 -07:00
.row
push bc
push hl
2015-10-24 07:34:19 -07:00
.col
ld a, [de]
ld [hli], a
dec de
dec c
2015-10-24 07:34:19 -07:00
jr nz, .col ; 0x1c3b $fa
pop hl
2015-10-24 07:34:19 -07:00
ld bc, SCREEN_WIDTH
add hl, bc
pop bc
dec b
2015-10-24 07:34:19 -07:00
jr nz, .row ; 0x1c44 $ef
ret
Function1c47:: ; 0x1c47
ld b, $10
ld de, wMenuFlags
2015-10-24 07:34:19 -07:00
.loop
ld a, [hld]
ld [de], a
inc de
dec b
2015-10-24 07:34:19 -07:00
jr nz, .loop ; 0x1c50 $fa
ret
2015-10-24 07:34:19 -07:00
GetMenuBoxDims:: ; 0x1c53
ld a, [wMenuBorderTopCoord] ; top
ld b, a
2015-10-24 07:34:19 -07:00
ld a, [wMenuBorderBottomCoord] ; bottom
sub b
ld b, a
2015-10-24 07:34:19 -07:00
ld a, [wMenuBorderLeftCoord] ; left
ld c, a
2015-10-24 07:34:19 -07:00
ld a, [wMenuBorderRightCoord] ; right
sub c
ld c, a
ret
; 0x1c66
CopyMenuData2:: ; 1c66
push hl
push de
push bc
push af
ld hl, wMenuData2Pointer
ld a, [hli]
ld h, [hl]
ld l, a
2015-11-04 11:02:11 -08:00
ld de, wMenuData2Flags
ld bc, wMenuData2End - wMenuData2Flags
call CopyBytes
pop af
pop bc
pop de
pop hl
ret
; 1c7e
Function1c7e:: ; 1c7e
2015-02-10 15:14:41 -08:00
ld hl, wcf71
ld a, [hli]
ld h, [hl]
ld l, a
inc hl
ld a, [hli]
ld h, [hl]
ld l, a
ret
; 1c89
Function1c89:: ; 1c89
call CopyMenuData2
ld hl, wMenuData2Pointer
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
2015-11-04 11:02:11 -08:00
ld a, [wMenuData2Flags]
bit 4, a
ret z
call MenuBoxCoord2Tile
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
call MenuBoxCoord2Tile
2015-10-24 07:34:19 -07:00
call GetMenuBoxDims
dec b
dec c
jp TextBox
; 1cc6
GetMenuTextStartCoord:: ; 1cc6
2015-10-24 07:34:19 -07:00
ld a, [wMenuBorderTopCoord]
ld b, a
inc b
2015-10-24 07:34:19 -07:00
ld a, [wMenuBorderLeftCoord]
ld c, a
inc c
; bit 6: if not set, leave extra room on top
2015-11-04 11:02:11 -08:00
ld a, [wMenuData2Flags]
bit 6, a
jr nz, .bit_6_set
inc b
.bit_6_set
; bit 7: if set, leave extra room on the left
2015-11-04 11:02:11 -08:00
ld a, [wMenuData2Flags]
bit 7, a
jr z, .bit_7_clear
inc c
.bit_7_clear
ret
; 1ce1
ClearMenuBoxInterior:: ; 1ce1
call MenuBoxCoord2Tile
ld bc, SCREEN_WIDTH + 1
add hl, bc
2015-10-24 07:34:19 -07:00
call GetMenuBoxDims
dec b
dec c
call ClearBox
ret
; 1cf1
ClearWholeMenuBox:: ; 1cf1
call MenuBoxCoord2Tile
2015-10-24 07:34:19 -07:00
call GetMenuBoxDims
inc c
inc b
call ClearBox
ret
; 1cfd
MenuBoxCoord2Tile:: ; 1cfd
2015-10-24 07:34:19 -07:00
ld a, [wMenuBorderLeftCoord]
ld c, a
2015-10-24 07:34:19 -07:00
ld a, [wMenuBorderTopCoord]
ld b, a
; 1d05
Coord2Tile:: ; 1d05
; Return the address of TileMap(c, b) in hl.
xor a
ld h, a
ld l, b
ld a, c
ld b, h
ld c, l
2015-07-20 19:18:18 -07:00
rept 2
add hl, hl
2015-07-20 19:18:18 -07:00
endr
add hl, bc
2015-07-20 19:18:18 -07:00
rept 2
add hl, hl
2015-07-20 19:18:18 -07:00
endr
ld c, a
xor a
ld b, a
add hl, bc
bccoord 0, 0
add hl, bc
ret
; 1d19
MenuBoxCoord2Attr:: ; 1d19
2015-10-24 07:34:19 -07:00
ld a, [wMenuBorderLeftCoord]
ld c, a
2015-10-24 07:34:19 -07:00
ld a, [wMenuBorderTopCoord]
ld b, a
Coord2Attr:: ; 1d21
; Return the address of AttrMap(c, b) in hl.
xor a
ld h, a
ld l, b
ld a, c
ld b, h
ld c, l
2015-07-20 19:18:18 -07:00
rept 2
add hl, hl
2015-07-20 19:18:18 -07:00
endr
add hl, bc
2015-07-20 19:18:18 -07:00
rept 2
add hl, hl
2015-07-20 19:18:18 -07:00
endr
ld c, a
xor a
ld b, a
add hl, bc
bccoord 0, 0, AttrMap
add hl, bc
ret
; 1d35