All but one TGI drivers didn't use IRQs. Especially when the TGI driver kernel was the only .interruptor this meant quite some unnecessary overhead because it pulled in the whole IRQ infrastructure.
The one driver using IRQs (the graphics driver for the 160x102x16 mode on the Lynx) now uses a library reference to set up a JMP to its IRQ handler.
BAR .addr ; BAR routine
TEXTSTYLE .addr ; TEXTSTYLE routine
OUTTEXT .addr ; OUTTEXT routine
- IRQ .addr ; IRQ routine
.endstruct
.endstruct
;------------------------------------------------------------------------------
; The TGI API version, stored at TGI_HDR_VERSION
-TGI_API_VERSION = $05
+TGI_API_VERSION = $06
;------------------------------------------------------------------------------
; Bitmapped tgi driver flags, stored in TGI_HDR::VARS::FLAGS.
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
- .addr 0 ; IRQ entry is unused
; ------------------------------------------------------------------------
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
- .addr 0 ; IRQ entry is unused
; ------------------------------------------------------------------------
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
- .addr 0 ; IRQ entry is unused
; ******************************************************************************
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
- .addr 0 ; IRQ entry is unused
; ------------------------------------------------------------------------
; Data.
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
- .addr 0 ; IRQ entry is unused
; ------------------------------------------------------------------------
; Data.
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
- .addr 0 ; IRQ entry is unused
; ------------------------------------------------------------------------
; Data.
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
- .addr 0 ; IRQ entry is unused
; ------------------------------------------------------------------------
; Data.
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
- .addr 0 ; IRQ entry is unused
; ------------------------------------------------------------------------
; Data.
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
- .addr 0 ; IRQ entry is unused
; ------------------------------------------------------------------------
; Data.
; Oliver Schmidt, 2013-05-31
;
- .export joy_libref, ser_libref, tgi_libref
+ .export joy_libref, ser_libref
.import _exit
joy_libref := _exit
ser_libref := _exit
-tgi_libref := _exit
.byte $74, $67, $69 ; "tgi"
.byte TGI_API_VERSION ; TGI API version number
- .addr $0000 ; Library reference
+libref: .addr $0000 ; Library reference
.word 160 ; X resolution
.word 102 ; Y resolution
.byte 16 ; Number of drawing colors
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
- .addr IRQ
; ------------------------------------------------------------------------
stz BGINDEX
stz DRAWPAGE
stz SWAPREQUEST
+ lda libref
+ ldx libref+1
+ sta ptr1
+ stx ptr1+1
+ ldy #1
+ lda #<irq
+ sta (ptr1),y
+ iny
+ lda #>irq
+ sta (ptr1),y
+ lda #$4C ; Jump opcode
+ sta (ptr1) ; Activate IRQ routine
rts
;
UNINSTALL:
+ lda libref
+ ldx libref+1
+ sta ptr1
+ stx ptr1+1
+ lda #$60 ; RTS opcode
+ sta (ptr1) ; Disable IRQ routine
rts
stx DRAWPAGEH
rts
-; ------------------------------------------------------------------------
-; IRQ: VBL interrupt handler
-;
-
-IRQ:
+irq:
lda INTSET ; Poll all pending interrupts
and #VBL_INTERRUPT
- beq IRQEND ; Exit if not a VBL interrupt
+ beq @L0 ; Exit if not a VBL interrupt
lda SWAPREQUEST
beq @L0
jsr SETDRAWPAGE
stz SWAPREQUEST
@L0:
-IRQEND:
clc
rts
--- /dev/null
+;
+; Oliver Schmidt, 2018-02-02
+;
+
+ .export tgi_libref
+ .interruptor tgi_irq ; Export as IRQ handler
+
+ .data
+
+tgi_libref:
+tgi_irq: .byte $60, $00, $00 ; RTS plus two dummy bytes
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
- .addr 0 ; IRQ entry is unused
; ------------------------------------------------------------------------
; Data.
.addr CIRCLE
.addr TEXTSTYLE
.addr OUTTEXT
- .addr 0 ; IRQ entry is unused
; ------------------------------------------------------------------------
; Data.
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
- .addr 0 ; IRQ entry is unused
; ------------------------------------------------------------------------
; Data.
.import tgi_libref
.importzp ptr1
- .interruptor tgi_irq ; Export as IRQ handler
.include "tgi-kernel.inc"
.include "tgi-error.inc"
tgi_bar: jmp $0000
tgi_textstyle: jmp $0000
tgi_outtext: jmp $0000
-tgi_irq: .byte $60, $00, $00 ; RTS plus two dummy bytes
; Driver header signature
.rodata
dex
bpl @L3
-; 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
-@L4: ldx #csize-1
-@L5: sta cstart,x ; Clear error/mode/curx/cury/...
+ ldx #csize-1
+@L4: sta cstart,x ; Clear error/mode/curx/cury/...
dex
- bpl @L5
+ bpl @L4
rts
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
tgi_clear_ptr: