109 lines
2.6 KiB
NASM
109 lines
2.6 KiB
NASM
; ***************************************************************************
|
|
; copyright : (C) 2025 by Martin Preuss
|
|
; email : martin@libchipcard.de
|
|
;
|
|
; ***************************************************************************
|
|
; * This file is part of the project "AqHome". *
|
|
; * Please see toplevel file COPYING of that project for license details. *
|
|
; ***************************************************************************
|
|
|
|
|
|
; ***************************************************************************
|
|
; code
|
|
|
|
.cseg
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine font8x8MonoHandlerFn
|
|
;
|
|
; Handler for 8x8 Mono Fonts
|
|
;
|
|
|
|
font8x8MonoHandlerFn:
|
|
cpi r23, FONT_FN_RENDER
|
|
breq font8x8MonoRenderCharacter
|
|
rjmp FONT_GenericHandler
|
|
; @end
|
|
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine font8x8RenderCharacter
|
|
|
|
; @param R16 character to write
|
|
; @param R1:R0 background color
|
|
; @param R3:R2 foreground color
|
|
; @param Z pointer to font
|
|
; @param X pointer to RAM to store data to
|
|
; @param r18 char width in pixel
|
|
; @param r19 char height in pixel
|
|
; @clobbers r17, r24, r25, x
|
|
|
|
font8x8MonoRenderCharacter:
|
|
push zl
|
|
push zh
|
|
rcall font8x8GetCharPosInFont8x8 ; (r17, r24, r25, z)
|
|
ldi r25, 8 ; 8 bytes
|
|
font8x8MonoRenderCharacter_loop1:
|
|
ldi r24, 8 ; 8 bits
|
|
lpm r17, Z+
|
|
font8x8MonoRenderCharacter_loop2:
|
|
lsr r17
|
|
brcs font8x8MonoRenderCharacter_writeForeground
|
|
st X+, r0
|
|
st X+, r1
|
|
rjmp font8x8MonoRenderCharacter_loop2end
|
|
font8x8MonoRenderCharacter_writeForeground:
|
|
st X+, r2
|
|
st X+, r3
|
|
font8x8MonoRenderCharacter_loop2end:
|
|
dec r24
|
|
brne font8x8MonoRenderCharacter_loop2
|
|
dec r25
|
|
brne font8x8MonoRenderCharacter_loop1
|
|
ldi r18, 8
|
|
ldi r19, 8
|
|
pop zh
|
|
pop zl
|
|
ret
|
|
; @end
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine font8x8GetCharPosInFont8x8
|
|
|
|
; @param R16 character to write
|
|
; @param Z pointer to font
|
|
; @return Z pointer to begin of char data
|
|
; @clobbers r17, r24, r25, z
|
|
|
|
font8x8GetCharPosInFont8x8:
|
|
mov r24, r16
|
|
adiw zh:zl, FONT_OFFS_FIRSTCHAR
|
|
lpm r24, Z+ ; first char num
|
|
lpm r25, Z+ ; num of chars
|
|
sub r16, r24
|
|
brcs font8x8GetCharPosInFont8x8_ret
|
|
cp r16, r25
|
|
brcc font8x8GetCharPosInFont8x8_ret
|
|
mov r24, r16
|
|
clr r25
|
|
lsl r24 ; x2
|
|
rol r25
|
|
lsl r24 ; x4
|
|
rol r25
|
|
lsl r24 ; x8
|
|
rol r25
|
|
add zl, r24
|
|
adc zh, r25
|
|
font8x8GetCharPosInFont8x8_ret:
|
|
ret
|
|
; @end
|
|
|
|
|
|
|