1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-06-30 17:29:31 +00:00
C02/include/run6502/direct.a02

50 lines
1.9 KiB
Plaintext

; C02 Module direct Assembly Language Routines for run6502 emulator
; This is the reference implementation of the direct module
; Requires external function FSCMD and FSDRVN (fileio.h02)
SUBROUTINE DIRECT
;getcwd(drv, &dir) - Get Current Directory
;Args: A = Drive Identifier
; Y,X = Pointer to String
;Returns: A = Result (0 = Success, $FF = Failure)
; Y = Error Code (0 = None)
GETCWD: JSR FSDRVN ;Convert Drive Letter to Drive Number
BCS .DRVERR ;If Invalid Return Error
LDA #'T' ;Set Command to GETCWD
.FSCMDX JSR FSCMD ;Execute Command
TXA ;Return Length of Name
.DRVERR RTS
;chdir(drv, &dir) - Get Current Directory
;Args: A = Drive Identifier
; Y,X = Pointer to String
;Returns: A = Result (0 = Succes, $FF = Failure)
; Y = Error Code (0 = None)
CHDIR: JSR FSDRVN ;Convert Drive Letter to Drive Number
BCS .DRVERR ;If Invalid Return Error
LDA #'U' ;Set Command to GETCWD
BNE .FSCMDX ;Execute Command and Return Result
;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
.MRDIR PHP ;Save Status Register
JSR FSDRVN ;Convert Drive Letter to Drive Number
BCS .DRVERR ;If Invalid Return Error
PLP ;Restore Status Register
LDA #'X' ;Set Command to MKRMDIR
BNE .FSCMDX ;Execute Command and Return Result
.PLAERR PLP ;Restore Status Register
RTS ;and Return