1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-19 21:32:19 +00:00

Added emulation and more clipping for the BAR function.

Copy colors and page count into local storage from the driver.
Added more functions.


git-svn-id: svn://svn.cc65.org/cc65/trunk@1322 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2002-06-22 13:10:02 +00:00
parent dcbd059858
commit 897c1d8523
9 changed files with 241 additions and 41 deletions

View File

@ -13,22 +13,27 @@
C_OBJS = tgi_load.o C_OBJS = tgi_load.o
S_OBJS = tgi-kernel.o \ S_OBJS = tgi-kernel.o \
tgi_bar.o \ tgi_bar.o \
tgi_circle.o \ tgi_circle.o \
tgi_clear.o \ tgi_clear.o \
tgi_done.o \ tgi_done.o \
tgi_geterror.o \ tgi_emu_bar.o \
tgi_getmaxx.o \ tgi_getcolorcount.o \
tgi_getmaxy.o \ tgi_geterror.o \
tgi_getpixel.o \ tgi_getmaxcolor.o \
tgi_getxres.o \ tgi_getmaxx.o \
tgi_getyres.o \ tgi_getmaxy.o \
tgi_init.o \ tgi_getpixel.o \
tgi_line.o \ tgi_getxres.o \
tgi_map_mode.o \ tgi_getyres.o \
tgi_setcolor.o \ tgi_init.o \
tgi_setpixel.o \ tgi_line.o \
tgi_map_mode.o \
tgi_setcolor.o \
tgi_setdrawpage.o \
tgi_setpixel.o \
tgi_setdrawpage.o \
tgi_unload.o tgi_unload.o

View File

@ -5,6 +5,7 @@
; ;
.include "tgi-kernel.inc" .include "tgi-kernel.inc"
.include "tgi-error.inc"
.export _tgi_setup .export _tgi_setup
.importzp ptr1 .importzp ptr1
@ -20,7 +21,9 @@ _tgi_error: .res 1 ; Last error code
_tgi_mode: .res 1 ; Graphics mode or zero _tgi_mode: .res 1 ; Graphics mode or zero
_tgi_xres: .res 2 ; X resolution of the current mode _tgi_xres: .res 2 ; X resolution of the current mode
_tgi_yres: .res 2 ; Y 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 .data
@ -32,6 +35,8 @@ tgi_init: jmp $0000
tgi_done: jmp $0000 tgi_done: jmp $0000
tgi_control: jmp $0000 tgi_control: jmp $0000
tgi_clear: jmp $0000 tgi_clear: jmp $0000
tgi_setviewpage:jmp $0000
tgi_setdrawpage:jmp $0000
tgi_setcolor: jmp $0000 tgi_setcolor: jmp $0000
tgi_setpixel: jmp $0000 tgi_setpixel: jmp $0000
tgi_getpixel: jmp $0000 tgi_getpixel: jmp $0000
@ -65,20 +70,27 @@ _tgi_setup:
cpx #(TGI_HDR_JUMPCOUNT*3) cpx #(TGI_HDR_JUMPCOUNT*3)
bne @L1 bne @L1
; Copy the screen dimensions ; Check for emulation vectors needed
ldy #TGI_HDR_XRES lda tgi_bar+1
lda (ptr1),y ora tgi_bar+2 ; Do we have a BAR vector?
sta _tgi_xres 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 iny
lda (ptr1),y inx
sta _tgi_xres+1 cpx #6
ldy #TGI_HDR_YRES bne @L3
lda (ptr1),y
sta _tgi_yres
iny
lda (ptr1),y
sta _tgi_yres+1
; Initialize variables ; Initialize variables
@ -112,3 +124,11 @@ tgi_set_ptr:
sta ptr1+1 sta ptr1+1
rts rts
;----------------------------------------------------------------------------
; Set an invalid argument error
tgi_inv_arg:
lda #TGI_ERR_INV_ARG
sta _tgi_error
rts

View File

@ -68,44 +68,63 @@ _tgi_bar:
; Check if X1 is negative. If so, clip it to the left border (zero). ; Check if X1 is negative. If so, clip it to the left border (zero).
lda #$00
bit ptr1+1 bit ptr1+1
bpl @L3 bpl @L3
lda #$00
sta ptr1 sta ptr1
sta ptr1+1 sta ptr1+1
beq @L4 ; Branch always, skip following test
; Dito for Y1 ; Check if X1 is beyond the right border. If so, the bar is invisible.
@L3: bit ptr2+1 @L3: lda ptr1
bpl @L4 cmp _tgi_xres
lda ptr1+1
sbc _tgi_xres
bcs @L9 ; Bail out if invisible
; Check if Y1 is negative. If so, clip it to the top border (zero).
@L4: bit ptr2+1
bpl @L5
lda #$00
sta ptr2 sta ptr2
sta ptr2+1 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. ; Check if X2 is larger than the maximum x coord. If so, clip it.
@L4: lda ptr3 @L6: lda ptr3
cmp _tgi_xres cmp _tgi_xres
lda ptr3+1 lda ptr3+1
sbc _tgi_xres+1 sbc _tgi_xres+1
bcs @L5 bcc @L7
jsr _tgi_getmaxx jsr _tgi_getmaxx
sta ptr3 sta ptr3
stx ptr3+1 stx ptr3+1
; Check if Y2 is larger than the maximum y coord. If so, clip it. ; Check if Y2 is larger than the maximum y coord. If so, clip it.
@L5: lda ptr4 @L7: lda ptr4
cmp _tgi_yres cmp _tgi_yres
lda ptr4+1 lda ptr4+1
sbc _tgi_yres+1 sbc _tgi_yres+1
bcs @L6 bcc @L8
jsr _tgi_getmaxy jsr _tgi_getmaxy
sta ptr4 sta ptr4
stx ptr4+1 stx ptr4+1
; The coordinates are now valid. Call the driver. ; The coordinates are now valid. Call the driver.
@L6: jmp tgi_bar @L8: jmp tgi_bar
; Error exit ; Error exit

80
libsrc/tgi/tgi_emu_bar.s Normal file
View File

@ -0,0 +1,80 @@
;
; 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

View File

@ -0,0 +1,15 @@
;
; 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

View File

@ -0,0 +1,21 @@
;
; 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

View File

@ -6,9 +6,13 @@
.include "tgi-kernel.inc" .include "tgi-kernel.inc"
.include "tgi-error.inc"
.export _tgi_setcolor .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

View File

@ -0,0 +1,18 @@
;
; 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

View File

@ -0,0 +1,18 @@
;
; 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