; *************************************************************************** ; 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 font16x26MonoHandlerFn ; ; Handler for 16x26 Mono Fonts ; font16x26MonoHandlerFn: cpi r23, FONT_FN_RENDER breq font16x26MonoRenderCharacter rjmp FONT_GenericHandler ; @end ; --------------------------------------------------------------------------- ; @routine font16x26RenderCharacter ; @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, r18, r24, r25, x font16x26MonoRenderCharacter: push zl push zh rcall font16x26GetCharPosInFont ; (r17, r24, r25, z) ldi r25, 26 ; 26 bytes height font16x26MonoRenderCharacter_loop1: ldi r24, 16 ; 16 bits font16x26MonoRenderCharacter_loop2: mov r23, r24 andi r23, 7 brne font16x26MonoRenderCharacter_haveByte lpm r17, Z+ font16x26MonoRenderCharacter_haveByte: lsr r17 brcs font16x26MonoRenderCharacter_writeForeground st X+, r0 st X+, r1 rjmp font16x26MonoRenderCharacter_loop2end font16x26MonoRenderCharacter_writeForeground: st X+, r2 st X+, r3 font16x26MonoRenderCharacter_loop2end: dec r24 brne font16x26MonoRenderCharacter_loop2 dec r25 brne font16x26MonoRenderCharacter_loop1 ldi r18, 16 ldi r19, 26 pop zh pop zl ret ; @end ; --------------------------------------------------------------------------- ; @routine font16x26GetCharPosInFont ; @param R16 character to write ; @param Z pointer to font ; @return Z pointer to begin of char data ; @clobbers r17, r24, r25, z font16x26GetCharPosInFont: 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 font16x26GetCharPosInFont_ret cp r16, r25 brcc font16x26GetCharPosInFont_ret mov r24, r16 clr r25 lsl r24 ; x2 rol r25 add r24, r16 ; x3 adc r25, r16 sub r25, r16 lsl r24 ; x6 rol r25 lsl r24 ; x12 rol r25 add r24, r16 ; x13 adc r25, r16 sub r25, r16 lsl r24 ; x26 rol r25 lsl r24 ; x52 rol r25 add zl, r24 adc zh, r25 font16x26GetCharPosInFont_ret: ret ; @end