tgi_bar.o \
tgi_circle.o \
tgi_clear.o \
+ tgi_curtoxy.o \
tgi_done.o \
tgi_emu_bar.o \
tgi_getcolor.o \
tgi_linepop.o \
tgi_lineto.o \
tgi_map_mode.o \
+ tgi_outtext.o \
+ tgi_outtextxy.o \
+ tgi_popxy.o \
+ tgi_popxy2.o \
tgi_setcolor.o \
tgi_setdrawpage.o \
tgi_setpalette.o \
tgi_setpixel.o \
tgi_setdrawpage.o \
+ tgi_textsize.o \
+ tgi_textstyle.o \
tgi_unload.o
@rm -f $(C_OBJS)
@rm -f $(S_OBJS)
+
_tgi_curx: .res 2 ; Current drawing cursor X
_tgi_cury: .res 2 ; Current drawing cursor Y
_tgi_color: .res 1 ; Current drawing color
+_tgi_textdir: .res 1 ; Current text direction
+_tgi_textmagx: .res 1 ; Text magnification in X dir
+_tgi_textmagy: .res 1 ; Text magnification in Y dir
+
+; The following variables are copied from the driver header for faster access
+tgi_driver_vars:
_tgi_xres: .res 2 ; X resolution of the current mode
_tgi_yres: .res 2 ; Y resolution of the current mode
_tgi_colorcount: .res 1 ; Number of available colors
_tgi_pagecount: .res 1 ; Number of available screen pages
+_tgi_fontsizex: .res 1 ; System font X size
+_tgi_fontsizey: .res 1 ; System font Y size
+tgi_driver_var_size = * - tgi_driver_vars
.data
tgi_line: jmp $0000
tgi_bar: jmp $0000
tgi_circle: jmp $0000
+tgi_textstyle: jmp $0000
+tgi_outtext: jmp $0000
;----------------------------------------------------------------------------
@L2: ldy #TGI_HDR_XRES
ldx #0
@L3: lda (ptr1),y
- sta _tgi_xres,x
+ sta tgi_driver_vars,x
iny
inx
- cpx #6
+ cpx #tgi_driver_var_size
bne @L3
; Initialize variables
lda #$00
- ldx #6-1
-@L4: sta _tgi_error,x ; Clear error/mode/curx/cury
+ ldx #7-1
+@L4: sta _tgi_error,x ; Clear error/mode/curx/cury/textdir
dex
bpl @L4
.include "tgi-kernel.inc"
.import popax
- .importzp ptr1, ptr2, tmp1
+ .importzp tmp1
.export _tgi_circle
_tgi_circle:
sta tmp1 ; Get the coordinates
jsr popax
- sta ptr2
- stx ptr2+1
- jsr popax
- sta ptr1
- stx ptr1+1
-
+ jsr tgi_popxy ; Pop X/Y into ptr1/ptr2
jmp tgi_circle ; Call the driver
--- /dev/null
+;
+; Ullrich von Bassewitz, 02.10.2002
+;
+; Helper function for tgi functions. Moves the current X/Y pos to ptr1/ptr2
+;
+
+ .include "tgi-kernel.inc"
+
+ .importzp ptr1, ptr2
+
+tgi_curtoxy:
+ ldy _tgi_curx ; X1
+ sty ptr1
+ ldy _tgi_curx+1
+ sty ptr1+1
+
+ ldy _tgi_cury ; Y1
+ sty ptr2
+ ldy _tgi_cury+1
+ sty ptr2+1
+ rts
+
tgi_getset:
- sta ptr2 ; Y
- stx ptr2+1
- jsr popax
- sta ptr1 ; X
- stx ptr1+1
+ jsr tgi_popxy ; Pop X/Y into ptr1/ptr2
-; Are the coordinates are out of range? First check if any ccord is negative.
+; Are the coordinates out of range? First check if any coord is negative.
txa
ora ptr2+1
- asl a
- bcs @L9 ; Bail out if negative
+ bmi @L9 ; Bail out if negative
; Check if X is larger than the maximum x coord. If so, bail out
txa
jsr _tgi_setcolor ; tgi_setcolor (tgi_getmaxcolor ());
+; Set the text style
+
+ lda #TGI_TEXT_HORIZONTAL
+ sta _tgi_textdir
+ ldx #1
+ stx _tgi_textmagx
+ ldy #1
+ sty _tgi_textmagy
+ jsr tgi_textstyle ; Tell the driver about the text style
+
; Clear the screen
jmp tgi_clear
.include "tgi-kernel.inc"
.import popax
- .importzp ptr1, ptr2
.export _tgi_line
_tgi_line:
jsr tgi_linepop ; Pop/store Y2/X2
-
- jsr popax
- sta ptr2
- stx ptr2+1
jsr popax
- sta ptr1
- stx ptr1+1
-
+ jsr tgi_popxy ; Pop/store X1/Y1 into ptr1/ptr2
jmp tgi_line ; Call the driver
.include "tgi-kernel.inc"
.import popax
- .importzp ptr1, ptr2, ptr3, ptr4
.export _tgi_lineto
_tgi_lineto:
- ldy _tgi_curx ; X1
- sty ptr1
- ldy _tgi_curx+1
- sty ptr1+1
-
- ldy _tgi_cury ; Y1
- sty ptr2
- ldy _tgi_cury+1
- sty ptr2+1
-
- jsr tgi_linepop
-
+ jsr tgi_curtoxy ; Copy curx/cury into ptr1/ptr2
+ jsr tgi_linepop ; Pop x2/y2 into ptr3/ptr4 and curx/cury
jmp tgi_line ; Call the driver
--- /dev/null
+;
+; Ullrich von Bassewitz, 21.06.2002
+;
+; void __fastcall__ tgi_outtext (const char* s);
+; /* Output text at the current graphics cursor position. */
+
+
+ .include "tgi-kernel.inc"
+
+ .import popax
+ .importzp ptr3
+ .export _tgi_outtext
+
+_tgi_outtext:
+ sta ptr3
+ stx ptr3+1 ; Save s
+ jsr tgi_curtoxy ; Copy curx/cury into ptr1/ptr2
+ jmp tgi_outtext ; Call the driver
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 21.06.2002
+;
+; void __fastcall__ tgi_outtextxy (int x, int y, const char* s);
+; /* Output text at the given position. */
+
+
+ .include "tgi-kernel.inc"
+
+ .import popax
+ .importzp ptr3
+ .export _tgi_outtextxy
+
+_tgi_outtextxy:
+ sta ptr3
+ stx ptr3+1 ; Save s
+ jsr tgi_popxy ; Pop x/y into ptr1/ptr2
+ jmp tgi_outtext ; Call the driver
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 02.10.2002
+;
+; Helper function for tgi functions. Pops X/Y from stack into ptr1/ptr2
+;
+
+ .include "tgi-kernel.inc"
+
+ .import popax
+ .importzp ptr1, ptr2
+
+tgi_popxy:
+ sta ptr2 ; Y
+ stx ptr2+1
+ jsr popax
+ sta ptr1 ; X
+ stx ptr1+1
+ rts
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 02.10.2002
+;
+; Helper function for tgi functions. Pops X/Y from stack into ptr3/ptr4
+;
+
+ .include "tgi-kernel.inc"
+
+ .import popax
+ .importzp ptr3, ptr4
+
+tgi_popxy2:
+ sta ptr4 ; Y
+ stx ptr4+1
+ jsr popax
+ sta ptr3 ; X
+ stx ptr3+1
+ rts
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 22.06.2002
+;
+
+
+ .include "tgi-kernel.inc"
+
+ .import _strlen, pushax, tosumulax
+ .export _tgi_textwidth
+ .export _tgi_textheight
+
+;-----------------------------------------------------------------------------
+; unsigned __fastcall__ tgi_textwidth (const char* s);
+; /* Calculate the width of the text in pixels according to the current text
+; * style.
+; */
+
+
+_tgi_textwidth:
+ ldy _tgi_textdir ; Get text direction
+ bne height
+
+; Result is
+;
+; strlen (s) * tgi_textmagx * tgi_fontsizex
+;
+; Since we don't expect textmagx to have large values, we do the multiplication
+; by looping.
+
+width: jsr _strlen
+ jsr pushax
+
+ lda #0
+ tax
+ ldy _tgi_textmagx
+@L1: clc
+ adc _tgi_fontsizex
+ bcc @L2
+ inx
+@L2: dey
+ bne @L1
+
+ jmp tosumulax ; Result * strlen (s)
+
+;-----------------------------------------------------------------------------
+; unsigned __fastcall__ tgi_textheight (const char* s);
+; /* Calculate the height of the text in pixels according to the current text
+; * style.
+; */
+
+_tgi_textheight:
+ ldy _tgi_textdir ; Get text direction
+ bne width ; Jump if vertical
+
+; Result is
+;
+; tgi_textmagy * tgi_fontsizey
+;
+; Since we don't expect textmagx to have large values, we do the multiplication
+; by looping.
+
+height: lda #0
+ tax
+ ldy _tgi_textmagy
+@L1: clc
+ adc _tgi_fontsizey
+ bcc @L2
+ inx
+@L2: dey
+ bne @L1
+ rts
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 22.06.2002
+;
+; void __fastcall__ tgi_textstyle (unsigned char magx, unsigned char magy,
+; unsigned char dir);
+; /* Set the style for text output. */
+
+
+ .include "tgi-kernel.inc"
+
+ .import popax, incsp2
+ .export _tgi_textstyle
+
+_tgi_textstyle:
+ pha
+ jsr popax ; Get magx/magy in one call
+ tay
+ pla
+
+; A = textdir, X = textmagx, Y = textmagy
+
+ cmp #TGI_TEXT_HORIZONTAL
+ beq DirOk
+ cmp #TGI_TEXT_VERTICAL
+ beq DirOk
+Fail: jmp tgi_inv_arg ; Invalid argument
+DirOk: cpy #$00
+ beq Fail ; Cannot have magnification of zero
+ cpx #$00
+ beq Fail ; Cannot have magnification of zero
+
+; Parameter check ok, store them
+
+ stx _tgi_textmagx
+ sty _tgi_textmagy
+ sta _tgi_textdir
+
+; Call the driver, parameters are passed in registers
+
+ jmp tgi_textstyle
+