1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-05 06:28:57 +00:00

Use the new TGI_HDR structure.

Added an interrupt entry point for the drivers.
Rewrote tgi_unload to avoid problems with the tgi_drv pointer.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3284 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2004-11-07 11:30:26 +00:00
parent 3088254f57
commit 8b0c3d3425
2 changed files with 51 additions and 33 deletions

View File

@ -7,8 +7,8 @@
.include "tgi-kernel.inc" .include "tgi-kernel.inc"
.include "tgi-error.inc" .include "tgi-error.inc"
.export tgi_clear_ptr
.importzp ptr1 .importzp ptr1
.interruptor tgi_irq ; Export as IRQ handler
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -34,7 +34,6 @@ _tgi_colorcount: .res 1 ; Number of available colors
_tgi_pagecount: .res 1 ; Number of available screen pages _tgi_pagecount: .res 1 ; Number of available screen pages
_tgi_fontsizex: .res 1 ; System font X size _tgi_fontsizex: .res 1 ; System font X size
_tgi_fontsizey: .res 1 ; System font Y size _tgi_fontsizey: .res 1 ; System font Y size
tgi_driver_var_size = * - tgi_driver_vars
.data .data
@ -61,11 +60,11 @@ tgi_bar: jmp $0000
tgi_circle: jmp $0000 tgi_circle: jmp $0000
tgi_textstyle: jmp $0000 tgi_textstyle: jmp $0000
tgi_outtext: jmp $0000 tgi_outtext: jmp $0000
tgi_irq: .byte $60, $00, $00 ; RTS plus two dummy bytes
; Driver header signature ; Driver header signature
.rodata .rodata
tgi_sig: .byte $74, $67, $69, TGI_API_VERSION ; "tgi", version tgi_sig: .byte $74, $67, $69, TGI_API_VERSION ; "tgi", version
tgi_sig_len = * - tgi_sig
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@ -81,7 +80,7 @@ _tgi_install:
; Check the driver signature ; Check the driver signature
ldy #tgi_sig_len-1 ldy #.sizeof(tgi_sig)-1
@L0: lda (ptr1),y @L0: lda (ptr1),y
cmp tgi_sig,y cmp tgi_sig,y
bne tgi_inv_drv bne tgi_inv_drv
@ -90,39 +89,44 @@ _tgi_install:
; Copy the jump vectors ; Copy the jump vectors
ldy #TGI_HDR_JUMPTAB ldy #TGI_HDR::JUMPTAB
ldx #0 ldx #0
@L1: inx ; Skip JMP opcode @L1: inx ; Skip JMP opcode
jsr copy ; Copy one byte jsr copy ; Copy one byte
jsr copy ; Copy one byte jsr copy ; Copy one byte
cpx #(TGI_HDR_JUMPCOUNT*3) cpx #(TGI_HDR::JUMPTAB + .sizeof(TGI_HDR::JUMPTAB))
bne @L1 bne @L1
; Call the driver install routine ; Call the driver install routine. It may update header variables, so we copy
; them after this call.
jsr tgi_install
; Copy variables from the driver header for faster access.
jsr tgi_install ; Call driver install routine, may...
; ...update variables
jsr tgi_set_ptr ; Set ptr1 to tgi_drv jsr tgi_set_ptr ; Set ptr1 to tgi_drv
ldy #(TGI_HDR::VARS + .sizeof(TGI_HDR::VARS) - 1)
; Copy variables. Beware: We are using internal knowledge about variable ldx #.sizeof(TGI_HDR::VARS)-1
; layout here!
ldy #TGI_HDR_XRES
ldx #0
@L3: lda (ptr1),y @L3: lda (ptr1),y
sta tgi_driver_vars,x sta tgi_driver_vars,x
iny dey
inx dex
cpx #tgi_driver_var_size bpl @L3
bne @L3
; Initialize variables ; Install the IRQ vector if the driver needs it.
lda tgi_irq+2 ; Check high byte of IRQ vector
beq @L4 ; Jump if vector invalid
lda #$4C ; Jump opcode
sta tgi_irq ; Activate IRQ routine
; Initialize some other variables
lda #$00 lda #$00
ldx #7-1 @L4: ldx #8-1
@L4: sta _tgi_error,x ; Clear error/mode/curx/cury/textdir @L5: sta _tgi_error,x ; Clear error/mode/curx/cury/textdir
dex dex
bpl @L4 bpl @L5
rts rts
@ -168,11 +172,14 @@ tgi_set_ptr:
_tgi_uninstall: _tgi_uninstall:
jsr _tgi_done ; Switch off graphics jsr _tgi_done ; Switch off graphics
jsr tgi_uninstall ; Allow the driver to clean up jsr tgi_uninstall ; Allow the driver to clean up
lda #$60 ; RTS opcode
sta tgi_irq ; Disable IRQ entry point
; Clear driver pointer and error code ; Clear driver pointer and error code
tgi_clear_ptr: ; External entry point
lda #$00 lda #$00
sta _tgi_drv sta _tgi_drv
sta _tgi_drv+1 sta _tgi_drv+1

View File

@ -6,20 +6,31 @@
.include "tgi-kernel.inc" .include "tgi-kernel.inc"
.include "tgi-error.inc"
.include "modload.inc" .include "modload.inc"
.import tgi_clear_ptr
.proc _tgi_unload _tgi_unload:
jsr _tgi_done ; Switch off graphics
jsr tgi_uninstall ; Allow the driver to clean up
lda _tgi_drv lda _tgi_drv
ldx _tgi_drv+1 ora _tgi_drv
jsr _mod_free ; Free the driver beq no_driver ; No driver
jmp tgi_clear_ptr ; Clear the driver pointer and exit lda _tgi_drv
pha
lda _tgi_drv+1
pha ; Save pointer to driver
jsr _tgi_uninstall ; Uninstall the driver
pla
tax
pla
jmp _mod_free ; Free the driver
no_driver:
lda #<TGI_ERR_NO_DRIVER
sta _tgi_error
rts
.endproc