From 7fffd12f11d6f4111fa00fe22d02f3a1e3a26cfd Mon Sep 17 00:00:00 2001 From: cuz Date: Thu, 3 Oct 2002 11:18:49 +0000 Subject: [PATCH] Started to add tgi text output functions git-svn-id: svn://svn.cc65.org/cc65/trunk@1428 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- asminc/tgi-kernel.inc | 27 +++++++++++++++++++++---- include/tgi.h | 36 +++++++++++++++++++++++++++++++++ libsrc/c64/c64-320-200-2.s | 41 ++++++++++++++++++++++++++++++++++---- 3 files changed, 96 insertions(+), 8 deletions(-) diff --git a/asminc/tgi-kernel.inc b/asminc/tgi-kernel.inc index a4c55db93..aca870087 100644 --- a/asminc/tgi-kernel.inc +++ b/asminc/tgi-kernel.inc @@ -42,7 +42,9 @@ TGI_HDR_XRES = 4 ; X resolution TGI_HDR_YRES = 6 ; Y resolution TGI_HDR_COLORCOUNT = 8 ; Number of available colors TGI_HDR_PAGECOUNT = 9 ; Number of screens available -TGI_HDR_RES = 10 ; Reserved for extensions +TGI_HDR_FONTSIZE_X = 10 ; System font size in X direction +TGI_HDR_FONTSIZE_Y = 11 ; System font size in Y direction +TGI_HDR_RES = 12 ; Reserved for extensions TGI_HDR_JUMPTAB = 16 TGI_HDR_INSTALL = TGI_HDR_JUMPTAB+0 ; INSTALL routine @@ -64,8 +66,16 @@ TGI_HDR_HORLINE = TGI_HDR_JUMPTAB+30 ; HORLINE routine TGI_HDR_LINE = TGI_HDR_JUMPTAB+32 ; LINE routine TGI_HDR_BAR = TGI_HDR_JUMPTAB+34 ; BAR routine TGI_HDR_CIRCLE = TGI_HDR_JUMPTAB+36 ; CIRCLE routine +TGI_HDR_TEXTSTYLE = TGI_HDR_JUMPTAB+39 ; TEXTSTYLE routine +TGI_HDR_OUTTEXT = TGI_HDR_JUMPTAB+42 ; OUTTEXT routine -TGI_HDR_JUMPCOUNT = 19 ; Number of jump vectors +TGI_HDR_JUMPCOUNT = 21 ; Number of jump vectors + +;------------------------------------------------------------------------------ +; Text style constants + +TGI_TEXT_HORIZONTAL = 0 +TGI_TEXT_VERTICAL = 1 ;------------------------------------------------------------------------------ ; Variables @@ -76,10 +86,15 @@ TGI_HDR_JUMPCOUNT = 19 ; Number of jump vectors .global _tgi_curx ; Current drawing cursor X .global _tgi_cury ; Current drawing cursor Y .global _tgi_color ; Current drawing color + .global _tgi_textdir ; Current text direction + .global _tgi_textmagx ; Text magnification in X dir + .global _tgi_textmagy ; Text magnification in Y dir .global _tgi_xres ; X resolution of the current mode .global _tgi_yres ; Y resolution of the current mode .global _tgi_colorcount ; Number of available colors .global _tgi_pagecount ; Number of available screen pages + .global _tgi_fontsizex ; System font X size + .global _tgi_fontsizey ; System font Y size ;------------------------------------------------------------------------------ ; Driver entry points @@ -103,7 +118,8 @@ TGI_HDR_JUMPCOUNT = 19 ; Number of jump vectors .global tgi_line .global tgi_bar .global tgi_circle - + .global tgi_textstyle + .global tgi_outtext ;------------------------------------------------------------------------------ ; ASM functions @@ -113,5 +129,8 @@ TGI_HDR_JUMPCOUNT = 19 ; Number of jump vectors .global tgi_inv_arg .global tgi_linepop .global tgi_set_ptr + .global tgi_popxy + .global tgi_popxy2 + .global tgi_curtoxy + - diff --git a/include/tgi.h b/include/tgi.h index fe3fdb9a5..367aa4d83 100644 --- a/include/tgi.h +++ b/include/tgi.h @@ -47,6 +47,18 @@ +/*****************************************************************************/ +/* Definitions */ +/*****************************************************************************/ + + + +/* Constants used for tgi_textstyle */ +#define TGI_TEXT_HORIZONTAL 0 +#define TGI_TEXT_VERTICAL 1 + + + /*****************************************************************************/ /* Functions */ /*****************************************************************************/ @@ -163,6 +175,30 @@ void __fastcall__ tgi_outtext (int x, int y, const char* text); void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2); /* Draw a bar (a filled rectangle) using the current color. */ +void __fastcall__ tgi_textstyle (unsigned char magx, unsigned char magy, + unsigned char dir); +/* Set the style for text output. */ + +unsigned __fastcall__ tgi_textwidth (const char* s); +/* Calculate the width of the text in pixels according to the current text + * style. + */ + +unsigned __fastcall__ tgi_textheight (const char* s); +/* Calculate the height of the text in pixels according to the current text + * style. + */ + +void __fastcall__ tgi_outtext (const char* s); +/* Output text at the current graphics cursor position. The graphics cursor + * is moved to the end of the text. + */ + +void __fastcall__ tgi_outtextxy (int x, int y, const char* s); +/* Output text at the given cursor position. The graphics cursor is moved to + * the end of the text. + */ + /* End of tgi.h */ diff --git a/libsrc/c64/c64-320-200-2.s b/libsrc/c64/c64-320-200-2.s index 8872d2515..4ab678c3e 100644 --- a/libsrc/c64/c64-320-200-2.s +++ b/libsrc/c64/c64-320-200-2.s @@ -28,7 +28,9 @@ .word 200 ; Y resolution .byte 2 ; Number of drawing colors .byte 1 ; Number of screens available - .res 6, $00 ; Reserved for future extensions + .byte 8 ; System font X size + .byte 8 ; System font Y size + .res 4, $00 ; Reserved for future extensions ; Next comes the jump table. Currently all entries must be valid and may point ; to an RTS for test versions (function not implemented). A future version may @@ -55,7 +57,8 @@ .word LINE .word 0 ; BAR .word CIRCLE - + .word TEXTSTYLE + .word OUTTEXT ; ------------------------------------------------------------------------ ; Data. @@ -109,6 +112,11 @@ OLDCH1: .res 1 CHUNK2: .res 1 OLDCH2: .res 1 +; Text output stuff +TEXTMAGX: .res 1 +TEXTMAGY: .res 1 +TEXTDIR: .res 1 + ; Constants and tables .rodata @@ -450,7 +458,7 @@ GETPIXEL: rts ; ------------------------------------------------------------------------ -; HORLINE: Draw a horizontal line from X1/Y to X2/Y, where X1 = ptr1, +; HORLINE: Draw a horizontal line from X1/Y to X2/Y, where X1 = ptr1, ; Y = ptr2 and X2 = ptr3, using the current drawing color. ; ; This is a special line drawing entry used when the line is know to be @@ -686,7 +694,7 @@ XFIXC: sta TEMP bmi @C1 ;Skip if column is negative cmp #39 ;End if move past end of screen bcs EXIT -@C1: lda POINT +@C1: lda POINT adc #8 sta POINT bcc @CONT @@ -1139,6 +1147,31 @@ PCHUNK2: sta (X2),y EXIT3: rts +; ------------------------------------------------------------------------ +; TEXTSTYLE: Set the style used when calling OUTTEXT. Text scaling in X and Y +; direction is passend in X/Y, the text direction is passed in A. +; +; Must set an error code: NO +; + +TEXTSTYLE: + stx TEXTMAGX + sty TEXTMAGY + sta TEXTDIR + rts + + +; ------------------------------------------------------------------------ +; OUTTEXT: Output text at X/Y = ptr1/ptr2 using the current color and the +; current text style. The text to output is given as a zero terminated +; string with address in ptr3. +; +; Must set an error code: NO +; + +OUTTEXT: + rts + ; ------------------------------------------------------------------------ ; Calculate all variables to plot the pixel at X1/Y1. If the point is out ; of range, a carry is returned and INRANGE is set to a value !0 zero. If -- 2.39.5