More work on the graphics subsystem

git-svn-id: svn://svn.cc65.org/cc65/trunk@1334 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2002-07-07 10:30:31 +00:00
parent 0fec0ce4d0
commit 104ce990cb
16 changed files with 209 additions and 102 deletions

View File

@@ -21,10 +21,13 @@ S_OBJS = tgi-kernel.o \
tgi_emu_bar.o \
tgi_getcolor.o \
tgi_getcolorcount.o \
tgi_getdefpalette.o \
tgi_geterror.o \
tgi_getmaxcolor.o \
tgi_getmaxx.o \
tgi_getmaxy.o \
tgi_getpagecount.o \
tgi_getpalette.o \
tgi_getpixel.o \
tgi_getset.o \
tgi_getxres.o \
@@ -37,6 +40,7 @@ S_OBJS = tgi-kernel.o \
tgi_map_mode.o \
tgi_setcolor.o \
tgi_setdrawpage.o \
tgi_setpalette.o \
tgi_setpixel.o \
tgi_setdrawpage.o \
tgi_unload.o

View File

@@ -16,36 +16,40 @@
.bss
_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_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_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_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
.data
; Jump table for the driver functions.
tgi_install: jmp $0000
tgi_deinstall: jmp $0000
tgi_init: jmp $0000
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
tgi_line: jmp $0000
tgi_bar: jmp $0000
tgi_circle: jmp $0000
tgi_install: jmp $0000
tgi_deinstall: jmp $0000
tgi_init: jmp $0000
tgi_done: jmp $0000
tgi_geterror: jmp $0000
tgi_control: jmp $0000
tgi_clear: jmp $0000
tgi_setviewpage: jmp $0000
tgi_setdrawpage: jmp $0000
tgi_setcolor: jmp $0000
tgi_setpalette: jmp $0000
tgi_getpalette: jmp $0000
tgi_getdefpalette: jmp $0000
tgi_setpixel: jmp $0000
tgi_getpixel: jmp $0000
tgi_line: jmp $0000
tgi_bar: jmp $0000
tgi_circle: jmp $0000
;----------------------------------------------------------------------------
@@ -103,27 +107,13 @@ _tgi_setup:
dex
bpl @L4
jsr tgi_install ; Call driver install routine
; jmp tgi_fetch_error
;----------------------------------------------------------------------------
; Fetch the error code from the driver and place it into the global error
; variable. The function will also return the error in A and the flags from
; loading the error code are set.
tgi_fetch_error:
jsr tgi_set_ptr
ldy #TGI_HDR_ERROR
lda (ptr1),y
sta _tgi_error
rts
jmp tgi_install ; Call driver install routine
;----------------------------------------------------------------------------
; Load the pointer to the tgi driver into ptr1.
tgi_set_ptr:
lda _tgi_drv
lda _tgi_drv
sta ptr1
lda _tgi_drv+1
sta ptr1+1

View File

@@ -5,6 +5,7 @@
; /* End graphics mode, switch back to text mode. Will NOT unload the driver! */
.include "tgi-kernel.inc"
.include "tgi-error.inc"
.export _tgi_done
@@ -12,7 +13,9 @@ _tgi_done:
lda _tgi_mode ; Is a graphics mode active?
beq @L1 ; Jump if not
jsr tgi_done ; Call the driver routine
jsr tgi_fetch_error ; Get the error code
jsr tgi_geterror ; Get the error code
sta _tgi_error ; Save it for reference
cmp #TGI_ERR_OK
bne @L1 ; Jump if we had an error
sta _tgi_mode ; Reset the current mode (A = 0)
@L1: rts

View File

@@ -9,7 +9,7 @@
_tgi_getcolorcount:
lda _tgi_colors
lda _tgi_colorcount
ldx #0
rts

View File

@@ -0,0 +1,15 @@
;
; Ullrich von Bassewitz, 23.06.2002
;
; const unsigned char* __fastcall__ tgi_getdefpalette (void);
; /* Return the default palette. Will return NULL for drivers that do not
; * support palettes.
; */
;
.include "tgi-kernel.inc"
.export _tgi_getdefpalette
_tgi_getdefpalette = tgi_getdefpalette ; Call the driver

View File

@@ -11,8 +11,11 @@
.export _tgi_geterror
_tgi_geterror:
ldx #0
lda _tgi_error
stx _tgi_error
rts
jsr tgi_geterror ; First call driver
ldx #$00 ; Clear high byte
ldy _tgi_error ; Test high level error code
beq @L1 ; Branch if no high level error code
tya ; Use high level code if we have one
stx _tgi_error ; Clear high level error code
@L1: rts

View File

@@ -4,14 +4,15 @@
; 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
ldx _tgi_colorcount
dex
txa
ldx #0

View File

@@ -0,0 +1,16 @@
;
; Ullrich von Bassewitz, 23.06.2002
;
; void __fastcall__ tgi_getpagecount (void);
; /* Returns the number of screen pages available. */
;
.include "tgi-kernel.inc"
.export _tgi_getpagecount
_tgi_getpagecount:
lda _tgi_pagecount
ldx #0
rts

View File

@@ -0,0 +1,17 @@
;
; Ullrich von Bassewitz, 23.06.2002
;
; const unsigned char* __fastcall__ tgi_getpalette (void);
; /* Return the current palette. Will return NULL for drivers that do not
; * support palettes.
; */
;
.include "tgi-kernel.inc"
.export _tgi_getpalette
_tgi_getpalette = tgi_getpalette ; Call the driver

View File

@@ -8,6 +8,7 @@
.include "tgi-kernel.inc"
.include "tgi-error.inc"
.importzp ptr1
.import _tgi_done
.import _tgi_setcolor
.export _tgi_init
@@ -18,14 +19,34 @@ _tgi_init:
pla
sta _tgi_mode ; Remember the mode
jsr tgi_init ; Go into graphics mode
jsr tgi_fetch_error ; Get the error code
bne @L1 ; Jump on error
ldx _tgi_colorcount
jsr tgi_geterror ; Get the error code
sta _tgi_error ; Save for later reference
cmp #TGI_ERR_OK
bne @L9 ; Jump on error
; Do driver initialization. First set the default palette.
jsr tgi_getdefpalette ; Get the default palette into A/X
sta ptr1
stx ptr1+1
ora ptr1+1 ; Do we have a default palette?
beq @L1 ; Jump if no
jsr tgi_setpalette ; Set the default palette
; Set the drawing color to the maximum color
@L1: ldx _tgi_colorcount
dex
txa
jmp _tgi_setcolor ; tgi_setcolor (tgi_getmaxcolor ());
jsr _tgi_setcolor ; tgi_setcolor (tgi_getmaxcolor ());
@L1: lda #$00
; Clear the screen
jmp tgi_clear
; Error exit
@L9: lda #$00
sta _tgi_mode ; Clear the mode if init was not successful
rts

View File

@@ -0,0 +1,21 @@
;
; Ullrich von Bassewitz, 23.06.2002
;
; void __fastcall__ tgi_setpalette (const unsigned char* palette);
; /* Set the palette (not available with all drivers/hardware). palette is
; * a pointer to as many entries as there are colors.
; */
;
.include "tgi-kernel.inc"
.importzp ptr1
.export _tgi_setpalette
_tgi_setpalette:
sta ptr1
stx ptr1+1
jmp tgi_setpalette ; Call the driver