2020-09-21 16:10:29 +00:00
|
|
|
; C02 Module direct Assembly Language Routines for run6502 emulator
|
|
|
|
; This is the reference implementation of the direct module
|
2020-09-22 00:12:44 +00:00
|
|
|
; Requires external function FSCMD and FSDRVN (fileio.h02)
|
2020-09-21 16:10:29 +00:00
|
|
|
|
|
|
|
SUBROUTINE DIRECT
|
|
|
|
|
2020-10-14 14:59:25 +00:00
|
|
|
TOPDIR BYTE "/",0 ;Root Directory
|
|
|
|
UPDIR BYTE "..",0 ;Parent Directory
|
|
|
|
|
2020-09-21 16:10:29 +00:00
|
|
|
;getcwd(drv, &dir) - Get Current Directory
|
|
|
|
;Args: A = Drive Identifier
|
|
|
|
; Y,X = Pointer to String
|
2020-10-14 14:59:25 +00:00
|
|
|
;Returns: A = Length of Directory Name
|
2020-09-21 16:10:29 +00:00
|
|
|
; Y = Error Code (0 = None)
|
2020-10-14 14:59:25 +00:00
|
|
|
GETCWD: JSR FSADDR ;Set String Buffer Address
|
|
|
|
TAY ;Set Drive ID
|
|
|
|
CLC ;Set Mode to GETCWD
|
|
|
|
LDA #'U' ;Set Command to GETSETDIR
|
2020-09-21 16:10:29 +00:00
|
|
|
.FSCMDX JSR FSCMD ;Execute Command
|
|
|
|
TXA ;Return Length of Name
|
2020-10-14 14:59:25 +00:00
|
|
|
RTS
|
2020-09-21 16:10:29 +00:00
|
|
|
|
2020-10-14 14:59:25 +00:00
|
|
|
;chdir(drv, &dir) - Set Current Directory
|
2020-09-21 16:10:29 +00:00
|
|
|
;Args: A = Drive Identifier
|
|
|
|
; Y,X = Pointer to String
|
2020-10-14 14:59:25 +00:00
|
|
|
;Returns: A = Error Code (0 = None)
|
|
|
|
CHDIR: JSR FSNAME ;Set Directory Name
|
|
|
|
TAY ;Set Drive ID
|
|
|
|
SEC ;Set Mode to CHDIR
|
|
|
|
LDA #'U' ;Set Command to GETSETDIR
|
|
|
|
.FSCMDY JSR FSCMD ;Execute Command
|
|
|
|
TYA ;Return Length of Name
|
|
|
|
RTS
|
2020-09-21 16:10:29 +00:00
|
|
|
|
|
|
|
;rmdir(drv, &dir) - Create Directory
|
|
|
|
;Args: A = Drive Identifier
|
|
|
|
; Y,X = Address of Directory Name String
|
|
|
|
;Returns: A = Error Code (0 = None)
|
|
|
|
RMDIR: SEC ;Set Mode to RMDIR
|
|
|
|
BCS .MRDIR ;Execute MKRMDIR and Return Result
|
|
|
|
|
|
|
|
;mkdir(drv, &dir) - Create Directory
|
|
|
|
;Args: A = Drive Identifier
|
|
|
|
; Y,X = Address of Directory Name String
|
|
|
|
;Returns: A = Error Code (0 = None)
|
|
|
|
MKDIR: CLC ;Set Mode to MKDIR
|
2020-10-14 14:59:25 +00:00
|
|
|
.MRDIR JSR FSNAME ;Set Directory Name
|
|
|
|
TAY ;Set Drive ID
|
2020-09-21 16:10:29 +00:00
|
|
|
LDA #'X' ;Set Command to MKRMDIR
|
2020-10-14 14:59:25 +00:00
|
|
|
BNE .FSCMDY ;Execute Command and Return Result
|