1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-04 13:29:35 +00:00

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
.if .defined(__ATARIXL__)
.import scrdev
.import findfreeiocb
.endif
.include "zeropage.inc"
@ -181,11 +182,9 @@ _exit: jsr donelib ; Run module destructors
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
@ -203,8 +202,10 @@ _exit: jsr donelib ; Run module destructors
lda #0
sta ICBLH,x
jsr CIOV_org
; add error checking here...
lda #CLOSE
sta ICCOM,x
jsr CIOV_org
.endif

View File

@ -122,7 +122,17 @@ sramprep:
; ... 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
@ -140,20 +150,18 @@ sramprep:
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
@ -266,6 +274,7 @@ no_copy:
.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)
@ -298,6 +307,21 @@ done: rts
.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: