From 928f675e4ba064bf59dc603fb8df45485bd8472c Mon Sep 17 00:00:00 2001 From: uz Date: Sun, 17 Jul 2011 17:15:54 +0000 Subject: [PATCH] Small change in the vector font format. git-svn-id: svn://svn.cc65.org/cc65/trunk@5088 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- asminc/tgi-vectorfont.inc | 4 ++-- libsrc/tgi/tgi_textheight.s | 9 +++------ src/chrcvt/main.c | 20 +++++++++++++++----- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/asminc/tgi-vectorfont.inc b/asminc/tgi-vectorfont.inc index b70adcd51..ffe6ac686 100644 --- a/asminc/tgi-vectorfont.inc +++ b/asminc/tgi-vectorfont.inc @@ -54,8 +54,8 @@ TGI_VF_CCOUNT = (TGI_VF_LASTCHAR - TGI_VF_FIRSTCHAR + 1) ; 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 diff --git a/libsrc/tgi/tgi_textheight.s b/libsrc/tgi/tgi_textheight.s index 7bd4216bd..7e0aee935 100644 --- a/libsrc/tgi/tgi_textheight.s +++ b/libsrc/tgi/tgi_textheight.s @@ -2,7 +2,7 @@ ; Ullrich von Bassewitz, 2009-10-30 ; - + .include "tgi-kernel.inc" .include "tgi-vectorfont.inc" .include "zeropage.inc" @@ -36,11 +36,8 @@ 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 diff --git a/src/chrcvt/main.c b/src/chrcvt/main.c index 6c2354cc3..8cc32cc88 100644 --- a/src/chrcvt/main.c +++ b/src/chrcvt/main.c @@ -129,15 +129,20 @@ * .byte $54, $43, $48, $00 ; "TCH" version * .word * Data portion: - * .byte ; Value from $88 - * .byte ; Value from $89 - * .byte ; Negative value from $8A + * .byte ; Baseline to top + * .byte ; Baseline to bottom + * .byte ; Maximum char height * .byte , ... ; $5F width bytes * .word , ... ; $5F char def offsets * Character definitions: * .word , ... * .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). @@ -411,8 +416,13 @@ static void ConvertFile (const char* Input, const char* Output) 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.