From 4062cb6b6ccd6e3a32ca6be4cc75579526fb8601 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Sun, 25 Aug 2013 11:20:27 +0200 Subject: [PATCH] atarixl target: add support for interruptors, adapt TGI drivers --- asminc/atari.inc | 11 ++++-- libsrc/atari/irq.s | 12 +++++++ libsrc/atari/libref.s | 5 +++ libsrc/atari/shadow_ram_handlers.s | 50 ++++++++++++++++----------- libsrc/atari/shadow_ram_prepare.s | 11 ++++-- libsrc/atari/tgi/atari_tgi_common.inc | 37 +++++++++++++++----- 6 files changed, 93 insertions(+), 33 deletions(-) diff --git a/asminc/atari.inc b/asminc/atari.inc index da524baad..864b59808 100644 --- a/asminc/atari.inc +++ b/asminc/atari.inc @@ -1003,15 +1003,20 @@ CASETV = $E440 ;cassette handler vector table DISKIV = $E450 ;vector to initialize DIO DSKINV = $E453 ;vector to DIO .if .defined(__ATARIXL__) -CIOV = $C0 -SIOV = $C3 +.ifndef SHRAM_HANDLERS +.import CIO_handler, SIO_handler, SETVBV_handler +.endif +.define CIOV CIO_handler +.define SIOV SIO_handler +.define SETVBV SETVBV_handler CIOV_org = $E456 ;vector to CIO SIOV_org = $E459 ;vector to SIO +SETVBV_org = $E45C ;vector to set VBLANK parameters .else CIOV = $E456 ;vector to CIO SIOV = $E459 ;vector to SIO -.endif SETVBV = $E45C ;vector to set VBLANK parameters +.endif SYSVBV = $E45F ;vector to process immediate VBLANK XITVBV = $E462 ;vector to process deferred VBLANK SIOINV = $E465 ;vector to initialize SIO diff --git a/libsrc/atari/irq.s b/libsrc/atari/irq.s index 9a433ca00..597ad9d60 100644 --- a/libsrc/atari/irq.s +++ b/libsrc/atari/irq.s @@ -39,7 +39,19 @@ doneirq: IRQStub: cld ; Just to be sure +.if .defined(__ATARIXL__) + pha + lda PORTB + pha + and #$fe + sta PORTB ; disable ROM @@@ TODO: update CHARGEN +.endif jsr callirq ; Call the functions +.if .defined(__ATARIXL__) + pla + sta PORTB + pla +.endif jmp IRQInd ; Jump to the saved IRQ vector ; ------------------------------------------------------------------------ diff --git a/libsrc/atari/libref.s b/libsrc/atari/libref.s index 8d9ff3e08..6d93a0b8e 100644 --- a/libsrc/atari/libref.s +++ b/libsrc/atari/libref.s @@ -7,4 +7,9 @@ em_libref := _exit joy_libref := _exit +.if .defined(__ATARIXL__) + .import CIO_handler +tgi_libref := CIO_handler +.else tgi_libref := _exit +.endif diff --git a/libsrc/atari/shadow_ram_handlers.s b/libsrc/atari/shadow_ram_handlers.s index 048a5a5c0..32b493ac0 100644 --- a/libsrc/atari/shadow_ram_handlers.s +++ b/libsrc/atari/shadow_ram_handlers.s @@ -8,6 +8,7 @@ DEBUG = 1 .if .defined(__ATARIXL__) + SHRAM_HANDLERS = 1 .include "atari.inc" .include "save_area.inc" .include "zeropage.inc" @@ -15,8 +16,12 @@ DEBUG = 1 .export sram_init .export KEYBDV_wrapper + .export CIO_handler + .export SIO_handler + .export SETVBV_handler -BUFSZ = 256 ; bounce buffer size +BUFSZ = 128 ; bounce buffer size +BUFSZ_SIO = 256 .macro disable_rom lda PORTB @@ -65,20 +70,6 @@ sram_init: lda #>my_NMI_han sta $fffb -; setup pointers to CIOV and SIOV wrappers - lda #$4C ; JMP opcode - sta CIOV - lda #my_CIOV - sta CIOV+2 - lda #$4C ; JMP opcode - sta SIOV - lda #my_SIOV - sta SIOV+2 - ; enable interrupts lda #$40 sta NMIEN @@ -94,7 +85,7 @@ zpptr1: .res 2 .segment "LOWBUFS" ; bounce buffers for CIO and SIO calls -bounce_buffer: .res BUFSZ +bounce_buffer: .res BUFSZ_SIO .segment "LOWCODE" @@ -240,7 +231,7 @@ CIOV_call: ; ; FIXME: Currently only the requests used by the runtime lib are handled. -my_CIOV: +CIO_handler: ; @@@ TODO: check X for valid IOCB index ((X < $80) and ((X & $F) == 0)) @@ -707,7 +698,7 @@ setup_zpptr1: ; These are the only functions used by the runtime library currently. ; For other function we return NVALID status code. -my_SIOV: +SIO_handler: lda DCOMND ; get command cmp #SIO_STAT beq SIO_stat @@ -839,9 +830,9 @@ sio_write_copy: ; CF - 0/1 for larger/not larger cmp_sio_len_bnc_bufsz: sec - lda #BUFSZ + lda #>BUFSZ_SIO sbc DBYTHI rts @@ -888,6 +879,24 @@ kret: pha pla rts +;--------------------------------------------------------- + +SETVBV_handler: + + pha + lda PORTB + sta cur_SETVBV_PORTB + enable_rom + pla + jsr SETVBV_org + php + pha + lda cur_SETVBV_PORTB + sta PORTB + pla + plp + rts + CIO_a: .res 1 CIO_x: .res 1 CIO_y: .res 1 @@ -895,6 +904,7 @@ CIO_p: .res 1 cur_CIOV_PORTB: .res 1 cur_SIOV_PORTB: .res 1 cur_KEYBDV_PORTB: .res 1 +cur_SETVBV_PORTB: .res 1 orig_ptr: .res 2 orig_len: .res 2 req_len: .res 2 diff --git a/libsrc/atari/shadow_ram_prepare.s b/libsrc/atari/shadow_ram_prepare.s index da83a1df9..ed30d4b2b 100644 --- a/libsrc/atari/shadow_ram_prepare.s +++ b/libsrc/atari/shadow_ram_prepare.s @@ -97,13 +97,20 @@ sramprep: ldx lowadr stx MEMTOP - stx APPMHI lda lowadr+1 sta MEMTOP+1 - sta APPMHI+1 lda lodadr+1 sta RAMTOP + ; set APPMHI to MEMLO (+ 1 for sanity) + lda MEMLO + clc + adc #1 + sta APPMHI + lda MEMLO+1 + adc #0 + sta APPMHI+1 + ; ... issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers) diff --git a/libsrc/atari/tgi/atari_tgi_common.inc b/libsrc/atari/tgi/atari_tgi_common.inc index 7dba884fa..7151d2d1e 100644 --- a/libsrc/atari/tgi/atari_tgi_common.inc +++ b/libsrc/atari/tgi/atari_tgi_common.inc @@ -4,6 +4,12 @@ .macpack longbranch +.if .defined(__ATARIXL__) + CIO_vec := my_CIOV +.else + CIO_vec := CIOV +.endif + ; ****************************************************************************** ; ---------------------------------------------------------------------- @@ -18,7 +24,7 @@ .byte $74, $67, $69 ; "tgi" .byte TGI_API_VERSION ; TGI API version number - .addr $0000 ; Library reference +libref: .addr $0000 ; Library reference .word x_res ; X resolution .word y_res ; Y resolution .byte colors ; Number of drawing colors @@ -111,6 +117,10 @@ text_dir: .byte 0 ; Text direction, +.if .defined(__ATARIXL__) + my_CIOV: + .byte $4C, 0, 0 +.endif .code ; ****************************************************************************** @@ -161,6 +171,17 @@ screen_device_length := * - screen_device stx mask +.if .defined(__ATARIXL__) + + ; setup pointer to CIO + + lda libref + sta my_CIOV+1 + lda libref+1 + sta my_CIOV+2 +.endif + + ; Find a free IOCB lda #$70 search: tax @@ -202,7 +223,7 @@ switch: lda #OPEN sta ICBLL,x lda #>screen_device_length sta ICBLH,x - jsr CIOV + jsr CIO_vec .if ::pages = 2 ; Reserve 8K of high memory @@ -212,7 +233,7 @@ switch: lda #OPEN ; Close and reopen graphics lda #CLOSE sta ICCOM,x - jsr CIOV + jsr CIO_vec ; Reopen graphics lda #OPEN sta ICCOM,x @@ -228,7 +249,7 @@ switch: lda #OPEN sta ICBLL,x lda #>screen_device_length sta ICBLH,x - jsr CIOV + jsr CIO_vec ; Save screen pointers lda SAVMSC + 1 sta p0scr @@ -271,7 +292,7 @@ exit: sta error ; Close the S: device lda #CLOSE sta ICCOM,x - jsr CIOV + jsr CIO_vec ; Reopen it in Graphics 0 lda #OPEN @@ -288,12 +309,12 @@ exit: sta error sta ICBLL,x lda #>screen_device_length sta ICBLH,x - jsr CIOV + jsr CIO_vec ; Now close it again; we don't need it anymore :) lda #CLOSE sta ICCOM,x - jmp CIOV + jmp CIO_vec .endproc ; ****************************************************************************** @@ -640,7 +661,7 @@ done10: .endif sta ATACHR - jmp CIOV + jmp CIO_vec .else ; USE_CIO_LINE -- 2.39.5