1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-22 16:34:15 +00:00
C02/include/run6502/filesys.a02

55 lines
2.0 KiB
Plaintext
Raw Normal View History

; C02 Module filesys Assembly Language Eoutines for run6502 emulator
; This is the reference implementation of the filesys module
; Requires external functions FSCMD and FSDRVN (fileio.h02)
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)
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
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)
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
;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)
CHDRV: JSR FSDRVN ;Validate Drive Number
BCS .RETURN ;If Invalid Return Error
TAY ;Set Drive Number
SEC ;Set Mode to Change
LDA #'V' ;Set Command to DRIVE
BNE .FSCMDX ;Execute Command and Return Result
;getdrv() - Get Current Drive/Disk
;Returns: A = Drive# | Disk# (0=Failure)
; Y = Error Code (0 = None)
GETDRV: CLC ;Set Mode to Get
LDA #'V' ;Set Command to DRIVE
JSR FSCMD ;Execute Command
TXA ;Copy Drive Number to A
ADC #'@' ; Convert to Drive Letter
.RETURN RTS