I've got a font in DrDnar's Monochrome Font Editor that I want to use in a program. I can export it into a file that has the following format:
Code:
So... how do I put text on the screen? Thank you all so much... I really am an ASM noob. ¯\_(ツ)_/¯
EDIT: Never mind, I think I made my own routine!
Here it is in case anyone else wants it. It works pretty much out of the box with a 9x14 font using the format described above, but can be easily modified to support any two-byte width and any height. In my 9x14 font, it will print the extra 7 pixels that have data specified but are blank. So if you are using this with a font width not a multiple of eight, you might get some extra spaces on the end. No biggie.
Code:
Also, while making this I found out if you want to print mirror text, just change rla to rra.
Code:
; Font is 14x9
Font_CharData:
.db $00, $00 ; Right arrow
.db $00, $00
.db $00, $00
.db $0C, $00
.db $06, $00
.db $7F, $00
.db $06, $00
.db $0C, $00
.db $00, $00
.db $00, $00
.db $00, $00
.db $00, $00
.db $00, $00
.db $00, $00
; etc with all other characters...
So... how do I put text on the screen? Thank you all so much... I really am an ASM noob. ¯\_(ツ)_/¯
EDIT: Never mind, I think I made my own routine!

Code:
; DrawString - INPUTS
; (XPos) = X position (pixels)
; (YPos) = Y position (pixels)
; HL = string
; OUTPUTS
; DE = next string
; Destroys EVERYTHING
DrawString:
ld a,(hl)
inc hl
or a
jp z,FinishDrawString
; cp 1
; jp z,DrawString_NewLine
push hl
call DrawChar
ld hl,(XPos)
ld bc,9
add hl,bc
ld (XPos),hl
pop hl
jr DrawString
FinishDrawString:
push hl
pop de
ret
; DrawChar - INPUTS
; A = Character to be drawn
; (XPos) = X position (pixels)
; (YPos) = Y position (pixels)
; Destroys EVERYTHING
DrawChar:
; First get the memory location of the character data
sbc hl,hl
ld l,a
; Each character is 28 bytes total, so we will multiply by 28
add hl,hl ; x2
add hl,hl ; x4
push hl
pop bc
add hl,hl ; x8
add hl,hl ; x16
add hl,hl ; x32
sbc hl,bc ; x28
; Add in the actual RAM location
ld bc,Font_CharData
add hl,bc
push hl
pop de
; Now get the memory location of the top-left screen pixel
; Multiply Y pos by screen width
ld hl,(YPos)
push hl
pop bc
add hl,hl ; x2
add hl,hl ; x4
add hl,bc ; x5
add hl,hl ; x10
add hl,hl ; x20
add hl,hl ; x40
add hl,hl ; x80
add hl,hl ; x160
add hl,hl ; x320
; Add in the X pos and vRAM location
ld bc,(XPos)
add hl,bc
ld bc,vRAM
add hl,bc
ld b,14 ; Font height
DrawChar_LoopV:
push bc
ld b,2 ; Font width (bytes)
DrawChar_LoopH:
ld a,(de) ; Grab next byte of character
push bc
ld b,8 ; Bytes per pixel
DrawChar_LoopPixel:
push bc
ld b,BgColor
ld (hl),b
rla
jr nc,DrawChar_PixelOff
ld b,CharColor
ld (hl),b
DrawChar_PixelOff:
inc hl
pop bc
djnz DrawChar_LoopPixel
pop bc
inc de
djnz DrawChar_LoopH
ld bc,304 ; 320 (screen width) minus 16 (char width rounded up)
add hl,bc ; This will advance us the next row of pixels
pop bc
djnz DrawChar_LoopV
ret
Also, while making this I found out if you want to print mirror text, just change rla to rra.
