From dacee3b9edd1167a050add3dc5be4e661d1d877c Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Fri, 2 Feb 2018 18:15:45 +0100 Subject: [PATCH] Removed IRQ support from TGI drivers. 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. --- asminc/tgi-kernel.inc | 3 +-- libsrc/apple2/tgi/a2.hi.s | 1 - libsrc/apple2/tgi/a2.lo.s | 1 - libsrc/atari/tgi/atari_tgi_common.inc | 1 - libsrc/atmos/tgi/atmos-228-200-3.s | 1 - libsrc/atmos/tgi/atmos-240-200-2.s | 1 - libsrc/c128/tgi/c128-vdc.s | 1 - libsrc/c128/tgi/c128-vdc2.s | 1 - libsrc/c64/tgi/c64-hi.s | 1 - libsrc/geos-cbm/tgi/geos-tgi.s | 1 - libsrc/lynx/libref.s | 3 +-- libsrc/lynx/tgi/lynx-160-102-16.s | 30 +++++++++++++++------- libsrc/lynx/tgi_irq.s | 11 ++++++++ libsrc/nes/tgi/nes-64-56-2.s | 1 - libsrc/telestrat/tgi/telestrat-228-200-3.s | 1 - libsrc/telestrat/tgi/telestrat-240-200-2.s | 1 - libsrc/tgi/tgi-kernel.s | 18 +++---------- 17 files changed, 37 insertions(+), 40 deletions(-) create mode 100644 libsrc/lynx/tgi_irq.s diff --git a/asminc/tgi-kernel.inc b/asminc/tgi-kernel.inc index e9f2f6aa9..fba78afff 100644 --- a/asminc/tgi-kernel.inc +++ b/asminc/tgi-kernel.inc @@ -70,14 +70,13 @@ 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. diff --git a/libsrc/apple2/tgi/a2.hi.s b/libsrc/apple2/tgi/a2.hi.s index 18f5724b5..e06b4a617 100644 --- a/libsrc/apple2/tgi/a2.hi.s +++ b/libsrc/apple2/tgi/a2.hi.s @@ -115,7 +115,6 @@ pages: .byte 2 ; Number of screens available .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ diff --git a/libsrc/apple2/tgi/a2.lo.s b/libsrc/apple2/tgi/a2.lo.s index 045b0044f..7238463a9 100644 --- a/libsrc/apple2/tgi/a2.lo.s +++ b/libsrc/apple2/tgi/a2.lo.s @@ -85,7 +85,6 @@ Y2 := ptr4 .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ diff --git a/libsrc/atari/tgi/atari_tgi_common.inc b/libsrc/atari/tgi/atari_tgi_common.inc index f4ef68165..cd486d91b 100644 --- a/libsrc/atari/tgi/atari_tgi_common.inc +++ b/libsrc/atari/tgi/atari_tgi_common.inc @@ -68,7 +68,6 @@ libref: .addr $0000 ; Library reference .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ****************************************************************************** diff --git a/libsrc/atmos/tgi/atmos-228-200-3.s b/libsrc/atmos/tgi/atmos-228-200-3.s index ae9b0f775..98d2cef96 100644 --- a/libsrc/atmos/tgi/atmos-228-200-3.s +++ b/libsrc/atmos/tgi/atmos-228-200-3.s @@ -59,7 +59,6 @@ YSIZE = 8 ; System font height .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/atmos/tgi/atmos-240-200-2.s b/libsrc/atmos/tgi/atmos-240-200-2.s index 943ec5389..2643e08fd 100644 --- a/libsrc/atmos/tgi/atmos-240-200-2.s +++ b/libsrc/atmos/tgi/atmos-240-200-2.s @@ -59,7 +59,6 @@ YSIZE = 8 ; System font height .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/c128/tgi/c128-vdc.s b/libsrc/c128/tgi/c128-vdc.s index 5100f7f7d..f48b530f6 100644 --- a/libsrc/c128/tgi/c128-vdc.s +++ b/libsrc/c128/tgi/c128-vdc.s @@ -88,7 +88,6 @@ pages: .byte 1 ; Number of screens available .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/c128/tgi/c128-vdc2.s b/libsrc/c128/tgi/c128-vdc2.s index a7238e877..4b7b17c57 100644 --- a/libsrc/c128/tgi/c128-vdc2.s +++ b/libsrc/c128/tgi/c128-vdc2.s @@ -89,7 +89,6 @@ pages: .byte 0 ; Number of screens available .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/c64/tgi/c64-hi.s b/libsrc/c64/tgi/c64-hi.s index 580220ecc..8368c6ba2 100644 --- a/libsrc/c64/tgi/c64-hi.s +++ b/libsrc/c64/tgi/c64-hi.s @@ -57,7 +57,6 @@ .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/geos-cbm/tgi/geos-tgi.s b/libsrc/geos-cbm/tgi/geos-tgi.s index 5a1af65e4..08927e6c1 100644 --- a/libsrc/geos-cbm/tgi/geos-tgi.s +++ b/libsrc/geos-cbm/tgi/geos-tgi.s @@ -74,7 +74,6 @@ aspect: .word $00D4 ; Aspect ratio (based on 4/3 display) .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/lynx/libref.s b/libsrc/lynx/libref.s index 62c78b8c5..0bda1e7e8 100644 --- a/libsrc/lynx/libref.s +++ b/libsrc/lynx/libref.s @@ -2,9 +2,8 @@ ; 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 diff --git a/libsrc/lynx/tgi/lynx-160-102-16.s b/libsrc/lynx/tgi/lynx-160-102-16.s index e6659631b..04bdaae04 100644 --- a/libsrc/lynx/tgi/lynx-160-102-16.s +++ b/libsrc/lynx/tgi/lynx-160-102-16.s @@ -29,7 +29,7 @@ .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 @@ -64,7 +64,6 @@ .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr IRQ ; ------------------------------------------------------------------------ @@ -164,6 +163,18 @@ INSTALL: stz BGINDEX stz DRAWPAGE stz SWAPREQUEST + lda libref + ldx libref+1 + sta ptr1 + stx ptr1+1 + ldy #1 + lda #irq + sta (ptr1),y + lda #$4C ; Jump opcode + sta (ptr1) ; Activate IRQ routine rts @@ -175,6 +186,12 @@ INSTALL: ; UNINSTALL: + lda libref + ldx libref+1 + sta ptr1 + stx ptr1+1 + lda #$60 ; RTS opcode + sta (ptr1) ; Disable IRQ routine rts @@ -466,14 +483,10 @@ SETDRAWPAGE: 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 @@ -485,7 +498,6 @@ IRQ: jsr SETDRAWPAGE stz SWAPREQUEST @L0: -IRQEND: clc rts diff --git a/libsrc/lynx/tgi_irq.s b/libsrc/lynx/tgi_irq.s new file mode 100644 index 000000000..3968dc0b5 --- /dev/null +++ b/libsrc/lynx/tgi_irq.s @@ -0,0 +1,11 @@ +; +; 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 diff --git a/libsrc/nes/tgi/nes-64-56-2.s b/libsrc/nes/tgi/nes-64-56-2.s index 70e23e119..e4dcb56ce 100644 --- a/libsrc/nes/tgi/nes-64-56-2.s +++ b/libsrc/nes/tgi/nes-64-56-2.s @@ -60,7 +60,6 @@ yres: .word 56 ; Max Y resolution .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/telestrat/tgi/telestrat-228-200-3.s b/libsrc/telestrat/tgi/telestrat-228-200-3.s index 09c308e26..ce501f0bf 100644 --- a/libsrc/telestrat/tgi/telestrat-228-200-3.s +++ b/libsrc/telestrat/tgi/telestrat-228-200-3.s @@ -58,7 +58,6 @@ YSIZE = 8 ; System font height .addr CIRCLE .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/telestrat/tgi/telestrat-240-200-2.s b/libsrc/telestrat/tgi/telestrat-240-200-2.s index 8a30ddd45..3ee918c4f 100644 --- a/libsrc/telestrat/tgi/telestrat-240-200-2.s +++ b/libsrc/telestrat/tgi/telestrat-240-200-2.s @@ -58,7 +58,6 @@ YSIZE = 8 ; System font height .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/tgi/tgi-kernel.s b/libsrc/tgi/tgi-kernel.s index ed65760af..3a388b6dc 100644 --- a/libsrc/tgi/tgi-kernel.s +++ b/libsrc/tgi/tgi-kernel.s @@ -6,7 +6,6 @@ .import tgi_libref .importzp ptr1 - .interruptor tgi_irq ; Export as IRQ handler .include "tgi-kernel.inc" .include "tgi-error.inc" @@ -81,7 +80,6 @@ tgi_line: jmp $0000 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 @@ -144,20 +142,13 @@ _tgi_install: 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 @@ -206,9 +197,6 @@ _tgi_uninstall: 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: -- 2.39.5