.import sram_init
.if .defined(__ATARIXL__)
.import scrdev
+ .import findfreeiocb
.endif
.include "zeropage.inc"
sta APPMHI+1
-
; ... issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers)
-
- ldx #$50 ; take any IOCB, hopefully free (@@@ fixme)
+ jsr findfreeiocb
; Reopen it in Graphics 0
lda #OPEN
lda #0
sta ICBLH,x
jsr CIOV_org
-
-
+; add error checking here...
+ lda #CLOSE
+ sta ICCOM,x
+ jsr CIOV_org
.endif
; ... 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
lda #OPEN
lda #>screen_device_length
sta ICBLH,x
jsr CIOV_org
- bpl okoko
+ bpl scrok
+; shouldn't happen(tm)
print_string "Internal error, aborting..."
jsr delay
jsr delay
jsr delay
-
+ jsr restore ; restore stuff we've changed
jmp (DOSVEC) ; abort loading
-okoko:
-
-
- ; Now close it again; we don't need it anymore :)
+scrok: ; now close it again -- we don't need it anymore
lda #CLOSE
sta ICCOM,x
jsr CIOV_org
.endif
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)
.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 ***************>>>>>>"
sramsize: