pokegold-spaceworld/home/print_hex.asm
2020-08-09 15:16:31 -04:00

42 lines
570 B
NASM
Raw Permalink Blame History

This file contains ambiguous Unicode characters

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/print_hex.asm", ROM0
PrintHexBytes:
; Print c hex bytes located at de to hl
.loop
push bc
call PrintHexByte
pop bc
dec c
jr nz, .loop
ret
PrintHexByte::
; Print one hex byte located at de to hl
ld a, [de]
swap a
and $0f
call GetHexDigit
ld [hli], a
ld a, [de]
and $0f
call GetHexDigit
ld [hli], a
inc de
ret
GetHexDigit:
; Get a hex digit tile number in a
ld bc, .hexDigitTable
add c
ld c, a
ld a, $00
adc b
ld b, a
ld a, [bc]
ret
.hexDigitTable:
db ""