use first free IOCB for "GRAPHICS 0" call instead of using a hard-coded one

This commit is contained in:
Christian Groessler
2013-06-25 01:27:47 +02:00
parent df1165e0e0
commit a03b3574b6
2 changed files with 37 additions and 12 deletions

View File

@@ -20,6 +20,7 @@
.import sram_init .import sram_init
.if .defined(__ATARIXL__) .if .defined(__ATARIXL__)
.import scrdev .import scrdev
.import findfreeiocb
.endif .endif
.include "zeropage.inc" .include "zeropage.inc"
@@ -181,11 +182,9 @@ _exit: jsr donelib ; Run module destructors
sta APPMHI+1 sta APPMHI+1
; ... issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers) ; ... issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers)
jsr findfreeiocb
ldx #$50 ; take any IOCB, hopefully free (@@@ fixme)
; Reopen it in Graphics 0 ; Reopen it in Graphics 0
lda #OPEN lda #OPEN
@@ -203,8 +202,10 @@ _exit: jsr donelib ; Run module destructors
lda #0 lda #0
sta ICBLH,x sta ICBLH,x
jsr CIOV_org jsr CIOV_org
; add error checking here...
lda #CLOSE
sta ICCOM,x
jsr CIOV_org
.endif .endif

View File

@@ -122,7 +122,17 @@ sramprep:
; ... issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers) ; ... issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers)
ldx #$50 ; take any IOCB, hopefully free (@@@ fixme) jsr findfreeiocb
.ifdef DEBUG ; only check in debug version, this shouldn't happen normally(tm)
beq iocbok
print_string "Internal error, no free IOCB!"
jsr delay
jsr delay
jsr delay
jsr restore ; restore stuff we've changed
jmp (DOSVEC) ; abort loading
iocbok:
.endif
; Reopen it in Graphics 0 ; Reopen it in Graphics 0
lda #OPEN lda #OPEN
@@ -140,20 +150,18 @@ sramprep:
lda #>screen_device_length lda #>screen_device_length
sta ICBLH,x sta ICBLH,x
jsr CIOV_org jsr CIOV_org
bpl okoko bpl scrok
; shouldn't happen(tm)
print_string "Internal error, aborting..." print_string "Internal error, aborting..."
jsr delay jsr delay
jsr delay jsr delay
jsr delay jsr delay
jsr restore ; restore stuff we've changed
jmp (DOSVEC) ; abort loading jmp (DOSVEC) ; abort loading
okoko: scrok: ; now close it again -- we don't need it anymore
; Now close it again; we don't need it anymore :)
lda #CLOSE lda #CLOSE
sta ICCOM,x sta ICCOM,x
jsr CIOV_org jsr CIOV_org
@@ -266,6 +274,7 @@ no_copy:
.endif .endif
rts rts
.include "findfreeiocb.inc"
; my 6502 fu is rusty, so I took a routine from the internet (http://www.obelisk.demon.co.uk/6502/algorithms.html) ; my 6502 fu is rusty, so I took a routine from the internet (http://www.obelisk.demon.co.uk/6502/algorithms.html)
@@ -298,6 +307,21 @@ done: rts
.endproc .endproc
; clean up after a fatal error
restore:lda RAMTOP_save
sta RAMTOP
lda MEMTOP_save
sta MEMTOP
lda MEMTOP_save+1
sta MEMTOP+1
lda APPMHI_save
sta APPMHI
lda APPMHI_save+1
sta APPMHI+1
rts
.byte "HERE ****************** HERE ***************>>>>>>" .byte "HERE ****************** HERE ***************>>>>>>"
sramsize: sramsize: