; Font data loaded directly from file
.struct TGI_VECTORFONT
TOP .byte ; Height of char
- BASELINE .byte ; Character baseline
- BOTTOM .byte ; Descender
+ BOTTOM .byte ; Descender
+ HEIGHT .byte ; Maximum char height
WIDTHS .byte ::TGI_VF_CCOUNT ; Char widths
CHARS .word ::TGI_VF_CCOUNT ; Pointer to character defs
OPS .byte ; Actually dynamic
; Ullrich von Bassewitz, 2009-10-30
;
-
+
.include "tgi-kernel.inc"
.include "tgi-vectorfont.inc"
.include "zeropage.inc"
stx ptr1
lda _tgi_vectorfont+1
sta ptr1+1
- ldy #TGI_VECTORFONT::TOP
- lda (ptr1),y
- ldy #TGI_VECTORFONT::BOTTOM
- clc
- adc (ptr1),y ; Total font height is top + bottom
+ ldy #TGI_VECTORFONT::HEIGHT
+ lda (ptr1),y ; Get height of font
sta ptr1
lda #0
* .byte $54, $43, $48, $00 ; "TCH" version
* .word <size of data portion>
* Data portion:
- * .byte <top> ; Value from $88
- * .byte <baseline> ; Value from $89
- * .byte <bottom> ; Negative value from $8A
+ * .byte <top> ; Baseline to top
+ * .byte <bottom> ; Baseline to bottom
+ * .byte <height> ; Maximum char height
* .byte <width>, ... ; $5F width bytes
* .word <char definition offset>, ... ; $5F char def offsets
* Character definitions:
* .word <converted opcode>, ...
* .byte $80
*
+ * The baseline of the character is assume to be at position zero. top and
+ * bottom are both positive values. The former extends in positive, the other
+ * in negative direction of the baseline. height contains the sum of top and
+ * bottom and is stored here just for easier handling.
+ *
* The opcodes get converted for easier handling: END is marked by bit 7
* set in the first byte. The second byte of this opcode is not needed.
* Bit 7 of the second byte marks a MOVE (bit 7 = 0) or DRAW (bit 7 = 1).
TchHeader[4] = Offs & 0xFF;
TchHeader[5] = (Offs >> 8) & 0xFF;
TchHeader[6] = Buf[0x88];
- TchHeader[7] = Buf[0x89];
- TchHeader[8] = (unsigned char) -(signed char)(Buf[0x8A]);
+ TchHeader[7] = (unsigned char) -(signed char)(Buf[0x8A]);
+ TchHeader[8] = TchHeader[6] + TchHeader[7];
+
+ /* The baseline must be zero, otherwise we cannot convert */
+ if (Buf[0x89] != 0) {
+ Error ("Baseline of font in `%s' is not zero", Input);
+ }
/* If the output file is NULL, use the name of the input file with ".tch"
* appended.