2020-09-21 16:10:29 +00:00
|
|
|
; C02 Module filesys Assembly Language Eoutines for run6502 emulator
|
|
|
|
; This is the reference implementation of the filesys module
|
2020-09-22 00:12:44 +00:00
|
|
|
; Requires external functions FSCMD and FSDRVN (fileio.h02)
|
2020-09-21 16:10:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
SUBROUTINE FILESYS
|
|
|
|
|
|
|
|
;remove(drv, &filnam) - Remove File filnam
|
|
|
|
;Args: A = Drive Identifier
|
|
|
|
; Y,X = Address of Directory Name String
|
|
|
|
;Returns: A = Error Code (0 = None)
|
2020-09-22 00:12:44 +00:00
|
|
|
REMOVE: JSR FSDRVN ;Validate Drive Number
|
|
|
|
BCS .RETURN ;If Invalid Return Error
|
|
|
|
LDA #'K' ;Set Command to KILL (REMOVE)
|
|
|
|
.FSCMDX JSR FSCMD ;Execute Command
|
|
|
|
TXA ;Return Result
|
2020-09-21 16:10:29 +00:00
|
|
|
RTS
|
|
|
|
|
|
|
|
;rename(drv, &filnam) - Rename File to filnam
|
|
|
|
;Setup: Call FSNAME with Address of Old Name
|
|
|
|
;Args: A = Drive Identifier
|
|
|
|
; Y,X = Address of Directory Name String
|
|
|
|
;Returns: A = Error Code (0 = None)
|
2020-09-22 00:12:44 +00:00
|
|
|
RENAME: JSR FSDRVN ;Convert Drive Letter to Drive Number
|
|
|
|
BCS .RETURN ;If Invalid Return Error
|
|
|
|
LDA #'M' ;Set Command to KILL (REMOVE)
|
|
|
|
BNE .FSCMDX ;Execute Command and Return Result
|
2020-09-21 16:10:29 +00:00
|
|
|
|
|
|
|
;inidrv(drv) - Initialize Disk Drive
|
|
|
|
;Args: A = Drive Identifier
|
|
|
|
;Returns: A = Error Code (0 = None)
|
|
|
|
INIDRV: LDA #$FF ;Return Error - Not Implemented
|
|
|
|
RTS
|
|
|
|
|
|
|
|
;chdrv() - Set Current Drive/Disk
|
|
|
|
;Args: A = Drive# | Disk#
|
|
|
|
;Returns: A = Result (0 - Success)
|
|
|
|
; Y = Error Code (0 = None)
|
2020-09-22 00:12:44 +00:00
|
|
|
CHDRV: JSR FSDRVN ;Validate Drive Number
|
|
|
|
BCS .RETURN ;If Invalid Return Error
|
2020-09-21 16:10:29 +00:00
|
|
|
TAY ;Set Drive Number
|
|
|
|
SEC ;Set Mode to Change
|
2020-09-22 00:12:44 +00:00
|
|
|
LDA #'V' ;Set Command to DRIVE
|
|
|
|
BNE .FSCMDX ;Execute Command and Return Result
|
|
|
|
|
2020-09-21 16:10:29 +00:00
|
|
|
;getdrv() - Get Current Drive/Disk
|
|
|
|
;Returns: A = Drive# | Disk# (0=Failure)
|
|
|
|
; Y = Error Code (0 = None)
|
|
|
|
GETDRV: CLC ;Set Mode to Get
|
2020-09-22 00:12:44 +00:00
|
|
|
LDA #'V' ;Set Command to DRIVE
|
|
|
|
JSR FSCMD ;Execute Command
|
|
|
|
TXA ;Copy Drive Number to A
|
|
|
|
ADC #'@' ; Convert to Drive Letter
|
|
|
|
.RETURN RTS
|