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
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
.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
.global tgi_line
.global tgi_bar
.global tgi_circle
-
+ .global tgi_textstyle
+ .global tgi_outtext
;------------------------------------------------------------------------------
; ASM functions
.global tgi_inv_arg
.global tgi_linepop
.global tgi_set_ptr
+ .global tgi_popxy
+ .global tgi_popxy2
+ .global tgi_curtoxy
+
-
+/*****************************************************************************/
+/* Definitions */
+/*****************************************************************************/
+
+
+
+/* Constants used for tgi_textstyle */
+#define TGI_TEXT_HORIZONTAL 0
+#define TGI_TEXT_VERTICAL 1
+
+
+
/*****************************************************************************/
/* Functions */
/*****************************************************************************/
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 */
.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
.word LINE
.word 0 ; BAR
.word CIRCLE
-
+ .word TEXTSTYLE
+ .word OUTTEXT
; ------------------------------------------------------------------------
; Data.
CHUNK2: .res 1
OLDCH2: .res 1
+; Text output stuff
+TEXTMAGX: .res 1
+TEXTMAGY: .res 1
+TEXTDIR: .res 1
+
; Constants and tables
.rodata
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
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
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