2020-09-22 20:58:57 +00:00
|
|
|
%import textio
|
|
|
|
%import syslib
|
2020-09-27 14:26:02 +00:00
|
|
|
%option no_sysinit
|
2020-09-22 22:22:36 +00:00
|
|
|
%zeropage basicsafe
|
2020-09-22 20:58:57 +00:00
|
|
|
|
|
|
|
; This example shows the directory contents of disk drive 8.
|
2020-10-07 00:22:25 +00:00
|
|
|
; Note: this program is compatible with C64 and CX16.
|
2020-09-22 20:58:57 +00:00
|
|
|
|
|
|
|
main {
|
|
|
|
sub start() {
|
2020-09-22 22:22:36 +00:00
|
|
|
txt.print("directory of disk drive #8:\n\n")
|
|
|
|
diskdir(8)
|
|
|
|
}
|
|
|
|
|
|
|
|
sub diskdir(ubyte drivenumber) {
|
|
|
|
c64.SETNAM(1, "$")
|
|
|
|
c64.SETLFS(1, drivenumber, 0)
|
2020-10-06 23:21:41 +00:00
|
|
|
void c64.OPEN() ; open 1,8,0,"$"
|
|
|
|
if_cs
|
|
|
|
goto io_error
|
|
|
|
void c64.CHKIN(1) ; use #1 as input channel
|
|
|
|
if_cs
|
|
|
|
goto io_error
|
2020-09-22 22:22:36 +00:00
|
|
|
|
|
|
|
repeat 4 {
|
|
|
|
void c64.CHRIN() ; skip the 4 prologue bytes
|
|
|
|
}
|
|
|
|
|
|
|
|
; while not key pressed / EOF encountered, read data.
|
2020-10-05 17:14:32 +00:00
|
|
|
ubyte status = c64.READST()
|
2020-10-06 23:21:41 +00:00
|
|
|
while not status {
|
2020-09-22 22:22:36 +00:00
|
|
|
txt.print_uw(mkword(c64.CHRIN(), c64.CHRIN()))
|
|
|
|
txt.chrout(' ')
|
|
|
|
ubyte @zp char
|
|
|
|
do {
|
|
|
|
char = c64.CHRIN()
|
|
|
|
txt.chrout(char)
|
|
|
|
} until char==0
|
|
|
|
txt.chrout('\n')
|
2020-10-07 00:22:25 +00:00
|
|
|
void c64.CHRIN() ; skip 2 bytes
|
|
|
|
void c64.CHRIN()
|
2020-10-05 17:14:32 +00:00
|
|
|
status = c64.READST()
|
2020-10-07 19:55:00 +00:00
|
|
|
void c64.STOP()
|
2020-10-06 23:21:41 +00:00
|
|
|
if_nz
|
|
|
|
break
|
2020-09-22 22:22:36 +00:00
|
|
|
}
|
2020-09-22 20:58:57 +00:00
|
|
|
|
2020-10-06 23:21:41 +00:00
|
|
|
io_error:
|
|
|
|
status = c64.READST()
|
2020-09-22 22:22:36 +00:00
|
|
|
c64.CLRCHN() ; restore default i/o devices
|
2020-10-07 19:55:00 +00:00
|
|
|
c64.CLOSE(1)
|
2020-10-05 17:14:32 +00:00
|
|
|
|
|
|
|
if status and status != 64 { ; 64=end of file
|
|
|
|
txt.print("\ni/o error, status: ")
|
|
|
|
txt.print_ub(status)
|
|
|
|
txt.chrout('\n')
|
|
|
|
}
|
2020-09-22 20:58:57 +00:00
|
|
|
}
|
|
|
|
}
|