C_OBJS = tgi_load.o
-S_OBJS = tgi-kernel.o \
- tgi_bar.o \
- tgi_circle.o \
- tgi_clear.o \
- tgi_done.o \
- tgi_geterror.o \
- tgi_getmaxx.o \
- tgi_getmaxy.o \
- tgi_getpixel.o \
- tgi_getxres.o \
- tgi_getyres.o \
- tgi_init.o \
- tgi_line.o \
- tgi_map_mode.o \
- tgi_setcolor.o \
- tgi_setpixel.o \
+S_OBJS = tgi-kernel.o \
+ tgi_bar.o \
+ tgi_circle.o \
+ tgi_clear.o \
+ tgi_done.o \
+ tgi_emu_bar.o \
+ tgi_getcolorcount.o \
+ tgi_geterror.o \
+ tgi_getmaxcolor.o \
+ tgi_getmaxx.o \
+ tgi_getmaxy.o \
+ tgi_getpixel.o \
+ tgi_getxres.o \
+ tgi_getyres.o \
+ tgi_init.o \
+ tgi_line.o \
+ tgi_map_mode.o \
+ tgi_setcolor.o \
+ tgi_setdrawpage.o \
+ tgi_setpixel.o \
+ tgi_setdrawpage.o \
tgi_unload.o
;
.include "tgi-kernel.inc"
+ .include "tgi-error.inc"
.export _tgi_setup
.importzp ptr1
_tgi_mode: .res 1 ; Graphics mode or zero
_tgi_xres: .res 2 ; X resolution of the current mode
_tgi_yres: .res 2 ; Y resolution of the current mode
-
+_tgi_colors: .res 1 ; Number of available colors
+_tgi_pagecount: .res 1 ; Number of available screen pages
+
.data
tgi_done: jmp $0000
tgi_control: jmp $0000
tgi_clear: jmp $0000
+tgi_setviewpage:jmp $0000
+tgi_setdrawpage:jmp $0000
tgi_setcolor: jmp $0000
tgi_setpixel: jmp $0000
tgi_getpixel: jmp $0000
cpx #(TGI_HDR_JUMPCOUNT*3)
bne @L1
-; Copy the screen dimensions
+; Check for emulation vectors needed
- ldy #TGI_HDR_XRES
- lda (ptr1),y
- sta _tgi_xres
- iny
- lda (ptr1),y
- sta _tgi_xres+1
- ldy #TGI_HDR_YRES
- lda (ptr1),y
- sta _tgi_yres
+ lda tgi_bar+1
+ ora tgi_bar+2 ; Do we have a BAR vector?
+ bne @L2 ; Jump if yes
+ lda #<tgi_emu_bar ; Use emulation if no
+ sta tgi_bar+1
+ lda #>tgi_emu_bar
+ sta tgi_bar+2
+
+; Copy variables. Beware: We are using internal knowledge about variable
+; layout here!
+
+@L2: ldy #TGI_HDR_XRES
+ ldx #0
+@L3: lda (ptr1),y
+ sta _tgi_xres,x
iny
- lda (ptr1),y
- sta _tgi_yres+1
+ inx
+ cpx #6
+ bne @L3
; Initialize variables
sta ptr1+1
rts
+;----------------------------------------------------------------------------
+; Set an invalid argument error
+
+tgi_inv_arg:
+ lda #TGI_ERR_INV_ARG
+ sta _tgi_error
+ rts
+
; Check if X1 is negative. If so, clip it to the left border (zero).
- lda #$00
bit ptr1+1
bpl @L3
+ lda #$00
sta ptr1
sta ptr1+1
+ beq @L4 ; Branch always, skip following test
+
+; Check if X1 is beyond the right border. If so, the bar is invisible.
+
+@L3: lda ptr1
+ cmp _tgi_xres
+ lda ptr1+1
+ sbc _tgi_xres
+ bcs @L9 ; Bail out if invisible
-; Dito for Y1
+; Check if Y1 is negative. If so, clip it to the top border (zero).
-@L3: bit ptr2+1
- bpl @L4
+@L4: bit ptr2+1
+ bpl @L5
+ lda #$00
sta ptr2
sta ptr2+1
+ beq @L6 ; Branch always, skip following test
+
+; Check if Y1 is beyond the bottom border. If so, the bar is invisible.
+
+@L5: lda ptr2
+ cmp _tgi_yres
+ lda ptr2+1
+ sbc _tgi_yres
+ bcs @L9 ; Bail out if invisible
; Check if X2 is larger than the maximum x coord. If so, clip it.
-@L4: lda ptr3
+@L6: lda ptr3
cmp _tgi_xres
lda ptr3+1
sbc _tgi_xres+1
- bcs @L5
+ bcc @L7
jsr _tgi_getmaxx
sta ptr3
stx ptr3+1
; Check if Y2 is larger than the maximum y coord. If so, clip it.
-@L5: lda ptr4
+@L7: lda ptr4
cmp _tgi_yres
lda ptr4+1
sbc _tgi_yres+1
- bcs @L6
+ bcc @L8
jsr _tgi_getmaxy
sta ptr4
stx ptr4+1
; The coordinates are now valid. Call the driver.
-@L6: jmp tgi_bar
+@L8: jmp tgi_bar
; Error exit
--- /dev/null
+;
+; Ullrich von Bassewitz, 22.06.2002
+;
+; Emulation for tgi_bar.
+;
+
+ .include "tgi-kernel.inc"
+
+ .importzp ptr1, ptr2, ptr3, ptr4
+ .export tgi_emu_bar
+
+tgi_emu_bar:
+ lda ptr4
+ sta Y2
+ lda ptr4+1
+ sta Y2+1
+
+ lda ptr3
+ sta X2
+ lda ptr3+1
+ sta X2+1
+
+ lda ptr2
+ sta ptr4
+ sta Y1
+ lda ptr2+1
+ sta ptr4+1
+ sta Y1+1
+
+ lda ptr1
+ sta X1
+ lda ptr1+1
+ sta X1+1
+
+@L1: jsr tgi_line
+
+ lda Y1
+ cmp Y2
+ bne @L2
+ lda Y1
+ cmp Y2
+ beq @L4
+
+@L2: inc Y1
+ bne @L3
+ inc Y1+1
+
+@L3: lda Y1
+ sta ptr2
+ sta ptr4
+ lda Y1+1
+ sta ptr2+1
+ sta ptr4+1
+
+ lda X1
+ sta ptr1
+ lda X1+1
+ sta ptr1+1
+
+ lda X2
+ sta ptr3
+ lda X2+1
+ sta ptr3+1
+ jmp @L1
+
+@L4: rts
+
+;-----------------------------------------------------------------------------
+; Data
+
+.bss
+
+DY: .res 2
+X1: .res 2
+X2: .res 2
+Y1: .res 2
+Y2: .res 2
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 22.06.2002
+;
+; unsigned char __fastcall__ tgi_getcolorcount (void);
+; /* Get the number of available colors */
+
+ .include "tgi-kernel.inc"
+ .export _tgi_getcolorcount
+
+
+_tgi_getcolorcount:
+ lda _tgi_colors
+ ldx #0
+ rts
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 22.06.2002
+;
+; unsigned char __fastcall__ tgi_getmaxcolor (void);
+; /* Return the maximum supported color number (the number of colors would
+; * then be getmaxcolor()+1).
+; */
+
+ .include "tgi-kernel.inc"
+ .export _tgi_getmaxcolor
+
+
+_tgi_getmaxcolor:
+ ldx _tgi_colors
+ dex
+ txa
+ ldx #0
+ rts
+
+
+
.include "tgi-kernel.inc"
-
+ .include "tgi-error.inc"
.export _tgi_setcolor
-_tgi_setcolor = tgi_setcolor ; Call the driver
-
+_tgi_setcolor:
+ cmp _tgi_colors ; Compare to available colors
+ bcs @L1
+ jmp tgi_setcolor ; Call the driver
+@L1: jmp tgi_inv_arg ; Invalid argument
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 22.06.2002
+;
+; void __fastcall__ tgi_setdrawpage (unsigned char page);
+; /* Set the drawable page */
+
+
+ .include "tgi-kernel.inc"
+ .export _tgi_setdrawpage
+
+_tgi_setdrawpage:
+ cmp _tgi_pagecount ; Compare to available pages
+ bcs @L1
+ jmp tgi_setdrawpage ; Call the driver
+@L1: jmp tgi_inv_arg ; Invalid argument
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 22.06.2002
+;
+; void __fastcall__ tgi_setviewpage (unsigned char page);
+; /* Set the visible page. */
+
+
+
+ .include "tgi-kernel.inc"
+ .export _tgi_setviewpage
+
+_tgi_setviewpage:
+ cmp _tgi_pagecount ; Compare to available pages
+ bcs @L1
+ jmp tgi_setviewpage ; Call the driver
+@L1: jmp tgi_inv_arg ; Invalid argument
+
+