Files
pokegold-spaceworld/home/toolgear.asm
luckytyphlosion e1659ecd41 Introduce linkerscript.
Addresses of sections will now be added to the linkerscript via `org`, and the section name will be the path/to/file. If there is more than one section in the file, then add a @SectionName after the path/to/file to describe the section.
2018-07-03 17:07:05 -04:00

188 lines
3.3 KiB
NASM
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

INCLUDE "constants.asm"
SECTION "home/toolgear.asm", ROM0
; local charmap, global charmap won't apply
; see https://github.com/rednex/rgbds/issues/265#issuecomment-395229694
charmap "", $66
charmap "", $67
charmap "", $68
charmap "", $69
charmap "", $6a
charmap "", $6b
charmap "", $6c
charmap "", $6d
charmap "", $6e
charmap "", $6f
; if debug coords shown
charmap "", $70
charmap "", $71
charmap "", $72
charmap "", $73
charmap "", $74
charmap "", $75
; small kana aren't actively loaded
; if clock shown
charmap "", $70
charmap "日", $71
charmap "月", $72
charmap "火", $73
charmap "水", $74
charmap "木", $75
charmap "金", $76
charmap "土", $77
charmap "⚡", $78 ; power
charmap "☎", $79 ; mobile
; active frame
charmap "┌", $79 ; only if debug coords shown
charmap "─", $7a
charmap "┐", $7b
charmap "│", $7c
charmap "└", $7d
charmap "┘", $7e
charmap " ", $7f
EnableToolgear:: ; 00:2018
ld hl, wd153
res 0, [hl]
ld hl, wToolgearFlags
set 0, [hl]
ret
DisableToolgear:: ; 00:2023
ld hl, wToolgearFlags
res 0, [hl]
xor a
ldh [hLCDCPointer], a
ret
InitToolgearBuffer:: ; 00:202c
xor a
ldh [hBGMapMode], a
ld hl, wToolgearFlags
bit 0, [hl]
jr z, .hide_window
res 7, [hl]
call LoadToolgearGraphics
bgcoord hl, 0, 0, wToolgearBuffer
ld a, "─"
ld bc, SCREEN_WIDTH
call ByteFill
bgcoord hl, 0, 1, wToolgearBuffer
ld a, " "
ld bc, SCREEN_WIDTH
call ByteFill
call UpdateToolgear
ld hl, vBGMap1
ld bc, $0004 ; 4 tiles = 2 rows
bgcoord de, 0, 0, wToolgearBuffer
call Get2bpp
ld a, $80
ldh [hLCDCPointer], a
ld a, $80
ldh [rWY], a
ldh [hWY], a
ret
.hide_window: ; 00:206b
xor a
ldh [hLCDCPointer], a
ld a, $90
ldh [rWY], a
ldh [hWY], a
ret
UpdateToolgear:: ; 2075
; Prepares a buffer for the clock display, which in the Debug ROM is displayed on the bottom of the screen.
; This function is called every frame, and loads special tiles into the $66-$7a space.
bgcoord hl, 0, 1, wToolgearBuffer
ld bc, SCREEN_WIDTH
ld a, " "
call ByteFill
if DEBUG
ld hl, wd153
bit 0, [hl]
jr z, .debug_show_time
ld hl, wXCoord
bgcoord de, 4, 1, wToolgearBuffer
ld c, $01
call .printHex
ld hl, wYCoord
bgcoord de, 8, 1, wToolgearBuffer
ld c, $01
call .printHex
ret
.debug_show_time:
endc
ld hl, hRTCHours
bgcoord de, 0, 1, wToolgearBuffer
call .printDec
ld hl, hRTCMinutes
bgcoord de, 3, 1, wToolgearBuffer
call .printDec
ldh a, [hRTCDays]
and 7
add "日" ; Sunday
ldbgcoord_a 6, 1, wToolgearBuffer
ld a, "⚡" ; power
ldbgcoord_a 9, 1, wToolgearBuffer
inc a ; mobile
ldbgcoord_a 11, 1, wToolgearBuffer
ldh a, [hRTCSeconds]
and 1
ret z
ld a, $70 ; :
ldbgcoord_a 2, 1, wToolgearBuffer
ret
.printHex:: ; 20cd
; .printHex
; print c hexadecimal digits from hl to de
; clobbers: a, b
ld a, [hli]
ld b, a
swap a
call .printDigit
ld a, b
call .printDigit
dec c
jr nz, .printHex
ret
.printDec:: ; 20dc
; .printDec
; print c decimal digits from hl to de
; clobbers: a, b
ld a, [hli]
ld b, 0
.mod10:
inc b
sub 10
jr nc, .mod10
dec b
add 10
push af
ld a, b
call .printDigit
pop af
call .printDigit
ret
.printDigit:: ; 20f1
; .printDigit
; print a hexadecimal digit for value in a to de
and $0f
add ""
ld [de], a
inc de
ret