2020-09-21 16:10:29 +00:00
|
|
|
; C02 Module dirent Assembly Language Eoutines for run6502 emulator
|
|
|
|
; This is the reference implementation of the dirent module
|
2020-09-22 00:12:44 +00:00
|
|
|
; Requires external functions FSADDR, FSCMD, and FSDRVN (fileio.h02)
|
2020-09-21 16:10:29 +00:00
|
|
|
|
2020-10-14 14:59:25 +00:00
|
|
|
ATTRD BYTE "AHRDS" ;File Attribute Descriptions
|
|
|
|
|
2020-09-21 16:10:29 +00:00
|
|
|
SUBROUTINE DIRENT
|
|
|
|
|
|
|
|
;opndir() - Open Directory for Reading
|
|
|
|
;Args: A = Drive Identifier
|
|
|
|
; Y,X = Pointer to Directory Name
|
|
|
|
;Returns: A = File Pointer (0 = Not Opened)
|
|
|
|
; Y = Error Code (0 = None)
|
2020-10-14 14:59:25 +00:00
|
|
|
OPNDIR: JSR FSNAME ;Set File Name
|
|
|
|
TAY ;Set Drive Letter
|
|
|
|
SEC ;Set Mode to OPENDIR
|
|
|
|
LDA #'O' ;Set Command to OPEN
|
2020-09-21 16:10:29 +00:00
|
|
|
.FSCMDX JSR FSCMD ;Execute Command
|
|
|
|
TXA ;Return Channel
|
|
|
|
RTS
|
|
|
|
|
|
|
|
.OPNERR LDA #0 ;Directory Not Opened
|
|
|
|
RTS
|
|
|
|
|
|
|
|
;rdhdr() - Read Directory Header
|
|
|
|
;Note: Call once before first readdir
|
|
|
|
;Args: A = Directory File Pointer
|
|
|
|
; Y,X = Pointer to HDRENT buffer
|
|
|
|
;Returns: A = Length of Header (0=None)
|
|
|
|
; Y = Error Code (0=None)
|
|
|
|
RDHDR: SEC ;Set Mode to HEADER
|
|
|
|
BCS .RDDIR ;Execute READDIR
|
|
|
|
|
|
|
|
;rddir() - Read Directory Entry
|
|
|
|
;Args: A = Directory File Pointer
|
|
|
|
; Y,X = Pointer to dirent structure
|
|
|
|
;Returns: A = Length of Entry (0=None)
|
|
|
|
; Y = Error Cooe (0=None)
|
|
|
|
RDDIR: CLC ;Set Mode to ENTRY
|
|
|
|
.RDDIR JSR FSADDR ;Save Address
|
|
|
|
TAY ;Set Channel
|
2020-10-14 14:59:25 +00:00
|
|
|
LDA #'D' ;Set Command to READDIR
|
2020-09-21 16:10:29 +00:00
|
|
|
BNE .FSCMDX ;Execute and Return Result
|
|
|
|
|
|
|
|
;clsdir() - Close Directory File
|
|
|
|
;Args: A = Directory File Pointer
|
|
|
|
;Returns: A = Error Code (0 = Success)
|
|
|
|
CLSDIR: TAY ;Set Channel
|
2020-10-14 14:59:25 +00:00
|
|
|
SEC ;Set Mode to CLOSEDIR
|
|
|
|
LDA #'C' ;Set Command to CLOSE
|
2020-09-21 16:10:29 +00:00
|
|
|
JSR FSCMD ;Execute Command
|
|
|
|
TYA ;and Return Error Code
|
|
|
|
RTS
|