atarixl target: add support for interruptors, adapt TGI drivers

This commit is contained in:
Christian Groessler 2013-08-25 11:20:27 +02:00
parent 0e09c207e0
commit 4062cb6b6c
6 changed files with 93 additions and 33 deletions

View file

@ -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

View file

@ -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
; ------------------------------------------------------------------------

View file

@ -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

View file

@ -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+1
lda #>my_CIOV
sta CIOV+2
lda #$4C ; JMP opcode
sta SIOV
lda #<my_SIOV
sta SIOV+1
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 DBYTLO
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

View file

@ -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)

View file

@ -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