; 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 FSNAME ;Set File Buffer to New Name TAY ;Set Drive ID LDA #'K' ;Set Command to KILL (REMOVE) .FEXECY JSR FSCMD ;Execute Command TYA ;Return Errno RTS ;rename(drv, &new) - Rename File to filnam ;Setup: Call FSNAME with Address of Old Name ;Args: A = Drive Identifier ; Y,X = Address of New Name ;Returns: A = Error Code (0 = None) RENAME: JSR FSBUFF ;Set File Buffer to New Name TAY ;Set Drive ID LDA #'M' ;Set Command to KILL (REMOVE) BNE .FEXECY ;Execute Command and Return Errno ;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: 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 .FEXECY ;Execute Command and Return Errno ;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