base:reading_the_directory
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | base:reading_the_directory [2015-04-17 04:33] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Reading the directory ====== | ||
+ | |||
+ | Just a simple routine which reads the directory file from a device and prints it to screen. | ||
+ | |||
+ | < | ||
+ | LDA # | ||
+ | LDX #< | ||
+ | LDY #> | ||
+ | JSR $FFBD ; call SETNAM | ||
+ | |||
+ | LDA #$02 ; filenumber 2 | ||
+ | LDX $BA | ||
+ | BNE .skip | ||
+ | LDX #$08 ; default to device number 8 | ||
+ | .skip LDY #$00 ; secondary address 0 (required for dir reading!) | ||
+ | JSR $FFBA ; call SETLFS | ||
+ | |||
+ | JSR $FFC0 ; call OPEN (open the directory) | ||
+ | BCS .error | ||
+ | |||
+ | LDX #$02 ; filenumber 2 | ||
+ | JSR $FFC6 ; call CHKIN | ||
+ | |||
+ | LDY #$04 ; skip 4 bytes on the first dir line | ||
+ | BNE .skip2 | ||
+ | .next | ||
+ | LDY #$02 ; skip 2 bytes on all other lines | ||
+ | .skip2 | ||
+ | DEY | ||
+ | BNE .skip2 | ||
+ | |||
+ | JSR getbyte | ||
+ | TAY | ||
+ | JSR getbyte | ||
+ | PHA | ||
+ | TYA ; transfer Y to X without changing Akku | ||
+ | TAX | ||
+ | PLA | ||
+ | JSR $BDCD ; print basic line number | ||
+ | LDA #$20 ; print a space first | ||
+ | .char | ||
+ | JSR $FFD2 ; call CHROUT (print character) | ||
+ | JSR getbyte | ||
+ | BNE .char ; continue until end of line | ||
+ | |||
+ | LDA #$0D | ||
+ | JSR $FFD2 ; print RETURN | ||
+ | JSR $FFE1 ; RUN/STOP pressed? | ||
+ | BNE .next ; no RUN/STOP -> continue | ||
+ | .error | ||
+ | ; Akkumulator contains BASIC error code | ||
+ | |||
+ | ; most likely error: | ||
+ | ; A = $05 (DEVICE NOT PRESENT) | ||
+ | exit: | ||
+ | LDA #$02 ; filenumber 2 | ||
+ | JSR $FFC3 ; call CLOSE | ||
+ | |||
+ | JSR $FFCC ; call CLRCHN | ||
+ | RTS | ||
+ | |||
+ | getbyte: | ||
+ | JSR $FFB7 ; call READST (read status byte) | ||
+ | BNE .end ; read error or end of file | ||
+ | JMP $FFCF ; call CHRIN (read byte from directory) | ||
+ | .end | ||
+ | PLA ; don't return to dir reading loop | ||
+ | PLA | ||
+ | JMP exit | ||
+ | |||
+ | dirname: | ||
+ | .TEXT " | ||
+ | dirname_end: | ||
+ | </ | ||
base/reading_the_directory.txt · Last modified: 2015-04-17 04:33 by 127.0.0.1