Talk:Read disk directory from 64 and 128
From C64-Wiki
Jump to navigationJump to searchA different version that uses the tape buffer at 828
033c .SYS828:
033c A9 01 LDA #$01
033e A2 A8 LDX #$A8
0340 A0 F5 LDY #$F5
0342 20 BD FF JSR .SETNAM ; using "$" at Kernal addr $F5A8
0345 A9 02 LDA #$02
0347 AE BA 00 LDX .CURRDEV ; get current device X
034a D0 02 BNE .DEVOK
034c A2 08 LDX #$08 ; default to 8
034e .DEVOK:
034e A0 00 LDY #$00
0350 20 BA FF JSR .SETLFS
0353 20 C0 FF JSR .OPEN ; OPEN 2,X,0,"$"
0356 B0 33 BCS .CLEANUP
0358 A2 02 LDX #$02 ; Set active channel #2
035a 20 C6 FF JSR .CHKIN
035d A0 04 LDY #$04 ; Skip load addr and next line pointer
035f D0 02 BNE .LOOPSKIP
0361 .LOOPLINE:
0361 A0 02 LDY #$02 ; Skip next line pointer
0363 .LOOPSKIP:
0363 20 94 03 JSR .READIN ; read and discard
0366 88 DEY
0367 D0 FA BNE .LOOPSKIP
0369 20 94 03 JSR .READIN ; read line number lsb
036c A8 TAY
036d 20 94 03 JSR .READIN ; read line number msb
0370 48 PHA
0371 98 TYA
0372 AA TAX
0373 68 PLA
0374 20 CD BD JSR .PRINTAX ; print line number A*256+X
0377 A9 20 LDA #$20
0379 .LOOPFILE:
0379 20 D2 FF JSR .CHROUT
037c 20 94 03 JSR .READIN
037f D0 F8 BNE .LOOPFILE ; get and print until \0
0381 A9 0D LDA #$0D
0383 20 D2 FF JSR .CHROUT
0386 20 E1 FF JSR .STOP ; break key?
0389 D0 D6 BNE .LOOPLINE
038b .CLEANUP:
038b A9 02 LDA #$02 ; CLOSE#2
038d 20 C3 FF JSR .CLOSE
0390 20 CC FF JSR .CLRCHN
0393 60 RTS ; GOODBYE
0394 .READIN:
0394 20 B7 FF JSR .READST
0397 D0 03 BNE .NOCHR
0399 4C CF FF JMP .CHRIN
039c .NOCHR: ; EOF or disk error
039c 68 PLA ; unstack call to .READIN
039d 68 PLA
039e 4C 8B 03 JMP .CLEANUP