2020-09-22 20:58:57 +00:00
|
|
|
%target c64
|
|
|
|
%import textio
|
|
|
|
%import syslib
|
|
|
|
%zeropage dontuse
|
|
|
|
|
|
|
|
; This example shows the directory contents of disk drive 8.
|
|
|
|
|
|
|
|
main {
|
|
|
|
sub start() {
|
|
|
|
%asm {{
|
|
|
|
lda #$01
|
|
|
|
ldx #<dirname
|
|
|
|
ldy #>dirname
|
|
|
|
jsr c64.SETNAM
|
2020-09-22 21:22:20 +00:00
|
|
|
lda #1
|
|
|
|
ldx #8
|
|
|
|
ldy #0
|
|
|
|
jsr c64.SETLFS
|
|
|
|
jsr c64.OPEN ; OPEN 1,8,0
|
|
|
|
ldx #1
|
|
|
|
jsr c64.CHKIN ; define input channel
|
2020-09-22 20:58:57 +00:00
|
|
|
ldy #$04
|
2020-09-22 21:22:20 +00:00
|
|
|
labl1 jsr c64.CHRIN ; input byte on serial bus
|
2020-09-22 20:58:57 +00:00
|
|
|
dey
|
|
|
|
bne labl1 ; get rid of Y bytes
|
|
|
|
lda $C6 ; key pressed?
|
|
|
|
ora $90 ; or EOF?
|
|
|
|
bne labl2 ; if yes exit
|
2020-09-22 21:22:20 +00:00
|
|
|
jsr c64.CHRIN ; now get the size of the file
|
2020-09-22 20:58:57 +00:00
|
|
|
pha
|
2020-09-22 21:22:20 +00:00
|
|
|
jsr c64.CHRIN
|
2020-09-22 20:58:57 +00:00
|
|
|
tay
|
|
|
|
pla
|
|
|
|
jsr txt.print_uw
|
|
|
|
lda #32
|
|
|
|
jsr c64.CHROUT
|
2020-09-22 21:22:20 +00:00
|
|
|
labl3 jsr c64.CHRIN ; now the filename
|
2020-09-22 20:58:57 +00:00
|
|
|
jsr c64.CHROUT ; put a character to screen
|
|
|
|
cmp #0
|
|
|
|
bne labl3 ; while not 0 encountered
|
|
|
|
lda #13
|
|
|
|
jsr c64.CHROUT ; put a CR , end line
|
|
|
|
ldy #$02 ; set 2 bytes to skip
|
|
|
|
bne labl1 ; repeat
|
2020-09-22 21:22:20 +00:00
|
|
|
labl2 lda #1
|
|
|
|
jsr c64.CLOSE ; close serial bus device
|
2020-09-22 20:58:57 +00:00
|
|
|
jsr c64.CLRCHN ; restore I/O devices to default
|
|
|
|
rts
|
|
|
|
|
|
|
|
dirname .byte "$"
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
}
|