Added check for disk in drive on chdir().
git-svn-id: svn://svn.cc65.org/cc65/trunk@5859 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
53
libsrc/cbm/diskinit.s
Normal file
53
libsrc/cbm/diskinit.s
Normal file
@@ -0,0 +1,53 @@
|
||||
;
|
||||
; Oliver Schmidt, 2012-10-17
|
||||
;
|
||||
|
||||
.export diskinit
|
||||
.import opencmdchannel, closecmdchannel
|
||||
.import writefndiskcmd, readdiskerror
|
||||
.import isdisk, fnunit, fncmd
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; diskinit
|
||||
|
||||
.proc diskinit
|
||||
|
||||
; Save device
|
||||
|
||||
sta fnunit
|
||||
|
||||
; Check for disk device
|
||||
|
||||
tax
|
||||
jsr isdisk
|
||||
bcc open
|
||||
lda #9 ; "Ilegal device"
|
||||
rts
|
||||
|
||||
; Open channel
|
||||
|
||||
open: jsr opencmdchannel
|
||||
bne done
|
||||
|
||||
; Write command
|
||||
|
||||
lda #'i' ; Init command
|
||||
sta fncmd
|
||||
jsr writefndiskcmd
|
||||
bne close
|
||||
|
||||
; Read error
|
||||
|
||||
ldx fnunit
|
||||
jsr readdiskerror
|
||||
|
||||
; Close channel
|
||||
|
||||
close: pha
|
||||
ldx fnunit
|
||||
jsr closecmdchannel
|
||||
pla
|
||||
|
||||
done: rts
|
||||
|
||||
.endproc
|
||||
Reference in New Issue
Block a user