mirror of
https://github.com/cc65/cc65.git
synced 2026-04-22 01:16:54 +00:00
Working on the TGI library
git-svn-id: svn://svn.cc65.org/cc65/trunk@1323 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -19,16 +19,20 @@ S_OBJS = tgi-kernel.o \
|
||||
tgi_clear.o \
|
||||
tgi_done.o \
|
||||
tgi_emu_bar.o \
|
||||
tgi_getcolor.o \
|
||||
tgi_getcolorcount.o \
|
||||
tgi_geterror.o \
|
||||
tgi_getmaxcolor.o \
|
||||
tgi_getmaxx.o \
|
||||
tgi_getmaxy.o \
|
||||
tgi_getpixel.o \
|
||||
tgi_getset.o \
|
||||
tgi_getxres.o \
|
||||
tgi_getyres.o \
|
||||
tgi_init.o \
|
||||
tgi_line.o \
|
||||
tgi_linepop.o \
|
||||
tgi_lineto.o \
|
||||
tgi_map_mode.o \
|
||||
tgi_setcolor.o \
|
||||
tgi_setdrawpage.o \
|
||||
|
||||
@@ -19,9 +19,13 @@
|
||||
_tgi_drv: .res 2 ; Pointer to driver
|
||||
_tgi_error: .res 1 ; Last error code
|
||||
_tgi_mode: .res 1 ; Graphics mode or zero
|
||||
_tgi_curx: .res 2 ; Current drawing cursor X
|
||||
_tgi_cury: .res 2 ; Current drawing cursor Y
|
||||
_tgi_color: .res 1 ; Current drawing color
|
||||
_tgi_bgcolor: .res 1 ; Current background color
|
||||
_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_colorcount:.res 1 ; Number of available colors
|
||||
_tgi_pagecount: .res 1 ; Number of available screen pages
|
||||
|
||||
|
||||
@@ -95,8 +99,10 @@ _tgi_setup:
|
||||
; Initialize variables
|
||||
|
||||
lda #$00
|
||||
sta _tgi_error
|
||||
sta _tgi_mode
|
||||
ldx #6-1
|
||||
@L4: sta _tgi_error,x ; Clear error/mode/curx/cury
|
||||
dex
|
||||
bpl @L4
|
||||
|
||||
jsr tgi_install ; Call driver install routine
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 22.06.2002
|
||||
;
|
||||
; unsigned char __fastcall__ tgi_getcolor (void);
|
||||
; /* Return the current drawing color */
|
||||
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
.export _tgi_getcolor
|
||||
|
||||
_tgi_getcolor:
|
||||
lda _tgi_color ; Get the current drawing color
|
||||
ldx #0 ; Clear high byte
|
||||
rts
|
||||
|
||||
@@ -7,18 +7,12 @@
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
|
||||
.import popax
|
||||
.importzp ptr1, ptr2
|
||||
.export _tgi_getpixel
|
||||
|
||||
_tgi_getpixel:
|
||||
sta ptr2 ; Get the coordinates
|
||||
stx ptr2+1
|
||||
jsr popax
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
|
||||
jsr tgi_getset ; Pop args, check range
|
||||
bcs @L9
|
||||
jmp tgi_getpixel ; Call the driver
|
||||
|
||||
@L9: rts
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 22.06.2002
|
||||
;
|
||||
; Helper function for getpixel/setpixel. Load X/Y from stack and check if
|
||||
; the coordinates are valid. Return carry clear if so.
|
||||
;
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
|
||||
.import popax
|
||||
.importzp ptr1, ptr2
|
||||
|
||||
|
||||
tgi_getset:
|
||||
sta ptr2 ; Y
|
||||
stx ptr2+1
|
||||
jsr popax
|
||||
sta ptr1 ; X
|
||||
stx ptr1+1
|
||||
|
||||
; Are the coordinates are out of range? First check if any ccord is negative.
|
||||
|
||||
txa
|
||||
ora ptr2+1
|
||||
asl a
|
||||
bcs @L9 ; Bail out if negative
|
||||
|
||||
; Check if X is larger than the maximum x coord. If so, bail out
|
||||
|
||||
lda ptr1
|
||||
cmp _tgi_xres
|
||||
txa
|
||||
sbc _tgi_xres+1
|
||||
bcs @L9
|
||||
|
||||
; Check if Y is larger than the maximum y coord.
|
||||
|
||||
lda ptr2
|
||||
cmp _tgi_yres
|
||||
lda ptr2+1
|
||||
sbc _tgi_yres+1
|
||||
@L9: rts
|
||||
|
||||
|
||||
+10
-4
@@ -9,6 +9,7 @@
|
||||
.include "tgi-error.inc"
|
||||
|
||||
.import _tgi_done
|
||||
.import _tgi_setcolor
|
||||
.export _tgi_init
|
||||
|
||||
_tgi_init:
|
||||
@@ -18,8 +19,13 @@ _tgi_init:
|
||||
sta _tgi_mode ; Remember the mode
|
||||
jsr tgi_init ; Go into graphics mode
|
||||
jsr tgi_fetch_error ; Get the error code
|
||||
beq @L1 ; Jump if no error
|
||||
lda #$00
|
||||
sta _tgi_mode ; Clear the mode if init was not successful
|
||||
@L1: rts
|
||||
bne @L1 ; Jump on error
|
||||
ldx _tgi_colorcount
|
||||
dex
|
||||
txa
|
||||
jmp _tgi_setcolor ; tgi_setcolor (tgi_getmaxcolor ());
|
||||
|
||||
@L1: lda #$00
|
||||
sta _tgi_mode ; Clear the mode if init was not successful
|
||||
rts
|
||||
|
||||
|
||||
@@ -8,15 +8,12 @@
|
||||
.include "tgi-kernel.inc"
|
||||
|
||||
.import popax
|
||||
.importzp ptr1, ptr2, ptr3, ptr4
|
||||
.importzp ptr1, ptr2
|
||||
.export _tgi_line
|
||||
|
||||
_tgi_line:
|
||||
sta ptr4 ; Get the coordinates
|
||||
stx ptr4+1
|
||||
jsr popax
|
||||
sta ptr3
|
||||
stx ptr3+1
|
||||
jsr tgi_linepop ; Pop/store Y2/X2
|
||||
|
||||
jsr popax
|
||||
sta ptr2
|
||||
stx ptr2+1
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 22.06.2002
|
||||
;
|
||||
; Helper function for tgi_line and tgi_lineto. Pops/stores X2/Y2.
|
||||
;
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
|
||||
.import popax
|
||||
.importzp ptr3, ptr4
|
||||
|
||||
tgi_linepop:
|
||||
sta ptr4 ; Y2
|
||||
stx ptr4+1
|
||||
sta _tgi_cury
|
||||
stx _tgi_cury+1
|
||||
jsr popax
|
||||
sta ptr3 ; X2
|
||||
stx ptr3+1
|
||||
sta _tgi_curx
|
||||
sta _tgi_curx+1
|
||||
rts
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 22.06.2002
|
||||
;
|
||||
; void __fastcall__ tgi_lineto (int x2, int y2);
|
||||
; /* Draw a line in the current drawing color from the graphics cursor to the
|
||||
; * new end point.
|
||||
; */
|
||||
|
||||
.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
|
||||
|
||||
jmp tgi_line ; Call the driver
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
.include "tgi-error.inc"
|
||||
.export _tgi_setcolor
|
||||
|
||||
_tgi_setcolor:
|
||||
cmp _tgi_colors ; Compare to available colors
|
||||
cmp _tgi_colorcount ; Compare to available colors
|
||||
bcs @L1
|
||||
sta _tgi_color ; Remember the drawing color
|
||||
jmp tgi_setcolor ; Call the driver
|
||||
@L1: jmp tgi_inv_arg ; Invalid argument
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,16 +7,13 @@
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
|
||||
.import popax
|
||||
.importzp ptr1, ptr2
|
||||
.export _tgi_setpixel
|
||||
|
||||
_tgi_setpixel:
|
||||
sta ptr2 ; Get the coordinates
|
||||
stx ptr2+1
|
||||
jsr popax
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
|
||||
jsr tgi_getset ; Pop args, check range
|
||||
bcs @L9
|
||||
jmp tgi_setpixel ; Call the driver
|
||||
@L9: rts
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user