1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-06-15 22:29:27 +00:00

Modified run6502 file modules to use drive letters instead of numbers

This commit is contained in:
Curtis F Kaylor 2020-09-21 20:12:44 -04:00
parent 083c83ee94
commit 86766be1fa
11 changed files with 79 additions and 97 deletions

View File

@ -4,7 +4,7 @@
***************************************/ ***************************************/
#define DRIVES 0 //Number of Disk Drives #define DRIVES 0 //Number of Disk Drives
const char drive[]; //Disk Drives const char drive[];
#define DISKS 0 //Number of Drives in Disk #define DISKS 0 //Number of Drives in Disk
const char disk[]; const char disk[];

View File

@ -33,11 +33,3 @@ CHDRV: LDA #$FF ;Return Result - Failure
;Returns: A = Drive# | Disk# (0=Failure) ;Returns: A = Drive# | Disk# (0=Failure)
; Y = Error Code (0 = None) ; Y = Error Code (0 = None)
GETDRV: ;Return Error - Not Implemented (Fall Through) GETDRV: ;Return Error - Not Implemented (Fall Through)
;drvnam(drv) - Get Drive Name
;Args: A = Drive Number
;Returns: A = Drive Name (0=Failure)
; Y = Error (0=None)
DRVNAM: LDA #$00 ;Return Result (None)
LDY #$FF ;and Error - Not Implemented
RTS

View File

@ -9,14 +9,6 @@
* 255 = Not Implemented */ * 255 = Not Implemented */
char chdrv(); char chdrv();
/* Drive Name *
* Args: char d - Drive ID | Disk # *
* Returns: char n - Drive Name *
* 0 = Invalid Device *
* char e - Error, 0=None *
* 255 = Not Implemented */
char drvnam();
/* Get Drive * /* Get Drive *
* Returns: char d - Current Drive/Disk * * Returns: char d - Current Drive/Disk *
* 0 = None or Error * * 0 = None or Error *

View File

@ -1,15 +1,15 @@
; C02 Module direct Assembly Language Routines for run6502 emulator ; C02 Module direct Assembly Language Routines for run6502 emulator
; This is the reference implementation of the direct module ; This is the reference implementation of the direct module
; Requires external function FSCMD and FSVDRV (fileio.h02) ; Requires external function FSCMD and FSDRVN (fileio.h02)
SUBROUTINE DIRECT SUBROUTINE DIRECT
;getcwd(drv, &dir) - Get Current Directory ;getcwd(drv, &dir) - Get Current Directory
;Args: A = Drive Identifier ;Args: A = Drive Identifier
; Y,X = Pointer to String ; Y,X = Pointer to String
;Returns: A = Result (0 = Succes, $FF = Failure) ;Returns: A = Result (0 = Success, $FF = Failure)
; Y = Error Code (0 = None) ; Y = Error Code (0 = None)
GETCWD: JSR FSVDRV ;Validate Drive Number GETCWD: JSR FSDRVN ;Convert Drive Letter to Drive Number
BCS .DRVERR ;If Invalid Return Error BCS .DRVERR ;If Invalid Return Error
LDA #'T' ;Set Command to GETCWD LDA #'T' ;Set Command to GETCWD
.FSCMDX JSR FSCMD ;Execute Command .FSCMDX JSR FSCMD ;Execute Command
@ -21,7 +21,7 @@ GETCWD: JSR FSVDRV ;Validate Drive Number
; Y,X = Pointer to String ; Y,X = Pointer to String
;Returns: A = Result (0 = Succes, $FF = Failure) ;Returns: A = Result (0 = Succes, $FF = Failure)
; Y = Error Code (0 = None) ; Y = Error Code (0 = None)
CHDIR: JSR FSVDRV ;Validate Drive Number CHDIR: JSR FSDRVN ;Convert Drive Letter to Drive Number
BCS .DRVERR ;If Invalid Return Error BCS .DRVERR ;If Invalid Return Error
LDA #'U' ;Set Command to GETCWD LDA #'U' ;Set Command to GETCWD
BNE .FSCMDX ;Execute Command and Return Result BNE .FSCMDX ;Execute Command and Return Result
@ -39,7 +39,7 @@ RMDIR: SEC ;Set Mode to RMDIR
;Returns: A = Error Code (0 = None) ;Returns: A = Error Code (0 = None)
MKDIR: CLC ;Set Mode to MKDIR MKDIR: CLC ;Set Mode to MKDIR
.MRDIR PHP ;Save Status Register .MRDIR PHP ;Save Status Register
JSR FSVDRV ;Validate Drive Number JSR FSDRVN ;Convert Drive Letter to Drive Number
BCS .DRVERR ;If Invalid Return Error BCS .DRVERR ;If Invalid Return Error
PLP ;Restore Status Register PLP ;Restore Status Register
LDA #'X' ;Set Command to MKRMDIR LDA #'X' ;Set Command to MKRMDIR

View File

@ -1,6 +1,6 @@
; C02 Module dirent Assembly Language Eoutines for run6502 emulator ; C02 Module dirent Assembly Language Eoutines for run6502 emulator
; This is the reference implementation of the dirent module ; This is the reference implementation of the dirent module
; Requires external functions FSADDR, FSCMD, and FSVDRV (fileio.h02) ; Requires external functions FSADDR, FSCMD, and FSDRVN (fileio.h02)
SUBROUTINE DIRENT SUBROUTINE DIRENT
@ -9,7 +9,7 @@
; Y,X = Pointer to Directory Name ; Y,X = Pointer to Directory Name
;Returns: A = File Pointer (0 = Not Opened) ;Returns: A = File Pointer (0 = Not Opened)
; Y = Error Code (0 = None) ; Y = Error Code (0 = None)
OPNDIR: JSR FSVDRV ;Validate Drive Number OPNDIR: JSR FSDRVN ;Convert Drive Letter to Drive Number
BCS .OPNERR ;If Invalid Return Error BCS .OPNERR ;If Invalid Return Error
LDA #'D' ;Set Command to OPENDIR LDA #'D' ;Set Command to OPENDIR
.FSCMDX JSR FSCMD ;Execute Command .FSCMDX JSR FSCMD ;Execute Command

View File

@ -10,7 +10,7 @@
SUBROUTINE FILEIO SUBROUTINE FILEIO
DRIVES EQU 26 ;Number of Disk Drives DRIVES EQU 26 ;Number of Disk Drives
DRIVE BYTE 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 DRIVE BYTE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;Disk Drive Letters
DISKS EQU 1 ;Number of Disks in Drive DISKS EQU 1 ;Number of Disks in Drive
DISK BYTE 0 DISK BYTE 0
@ -37,14 +37,15 @@ FFLUSH: TAY ;Set Channel Number
; Y,X = Pointer to File Name ; Y,X = Pointer to File Name
;Returns: A = File Channel (0=File Not Opened) ;Returns: A = File Channel (0=File Not Opened)
; Y = Error (0=None) ; Y = Error (0=None)
FOPEN: JSR FSVDRV ;Validate Drive Number FOPEN: JSR FSNAME ;Set Filename
BCS .DRVERR TAX ;Pass Mode to X
JSR FSNAME ;Set Filename JSR FSDRVN ;Convert Drive Letter to Drive Number
TAY ;and Pass in Y BCS .RETURN ;If Error, Return Carry Set
TAY ;Pass Drive Number in Y
LDA #'O' ;Set Command to OPEN LDA #'O' ;Set Command to OPEN
.FEXECX JSR FSCMD ;Execute Command .FEXECX JSR FSCMD ;Execute Command
TXA ;Return Channel in A TXA ;Return Channel in A
.DRVERR RTS RTS
;fclose(chan) - Close File ;fclose(chan) - Close File
;Args: A = Channel Number ;Args: A = Channel Number
@ -164,21 +165,25 @@ FERROR: JSR FSADDR ;Set Buffer Address
;File System Commands ;File System Commands
;Check fot Valid Drive Number ;Convert Drive Letter Into Drive Number
;Args: A = Drive Number ;Drive letters A-Z in DOS map to drive numbers 1-26
;Returns: A = Index into Drives ;A drice specifier of NULL - SPACE or @ maps to drive 0, which
;means the current drive in the run6502 File Command Processor.
;Args: A = Drive Letter
;Returns: A = Drive Number
; Carry Clear = Valid Drive Number ; Carry Clear = Valid Drive Number
; Carry Set = Invalid Drive Number ; Carry Set = Invalid Drive Number
FSVDRV: PHA FSDRVN: SEC
AND #$1F ;Isolate Drive Number SBC #' ' ;If Drive Specifier
CMP #DRIVES+2 ;Compare against Number of Drives BCS .FSDRVL ;is NULL through SPACE
PLA LDA #0 ; Return Drive Number 0
BCS .FSVERR RTS ; and Carry Clear
RTS .FSDRVL AND #$1F ;Convert A-Z, a-z to 1-26
CMP #DRIVES+2 ;If Drive Number is
.FSVERR LDA #$FF ;Return Operation Failed BCC .RETURN ;greater than 26
LDY #1 ;Error - Invalid Argument LDA #$FF ; Return Operation Failed
RTS LDY #1 ; and Error - Invalid Argument
.RETURN RTS
;fsinit() - Initialize File System ;fsinit() - Initialize File System
FSINIT: LDA #'I' ;Set Command to INITFS FSINIT: LDA #'I' ;Set Command to INITFS

View File

@ -1,6 +1,6 @@
; C02 Module filesys Assembly Language Eoutines for run6502 emulator ; C02 Module filesys Assembly Language Eoutines for run6502 emulator
; This is the reference implementation of the filesys module ; This is the reference implementation of the filesys module
; Requires external functions FSCMD and FSVDRV (fileio.h02) ; Requires external functions FSCMD and FSDRVN (fileio.h02)
SUBROUTINE FILESYS SUBROUTINE FILESYS
@ -9,11 +9,11 @@
;Args: A = Drive Identifier ;Args: A = Drive Identifier
; Y,X = Address of Directory Name String ; Y,X = Address of Directory Name String
;Returns: A = Error Code (0 = None) ;Returns: A = Error Code (0 = None)
REMOVE: JSR FSVDRV ;Validate Drive Number REMOVE: JSR FSDRVN ;Validate Drive Number
BCS .DRVERR ;If Invalid Return Error BCS .RETURN ;If Invalid Return Error
LDA #'K' ;Set Command to KILL (REMOVE) LDA #'K' ;Set Command to KILL (REMOVE)
.FSCMDX JSR FSCMD ;Execute Command .FSCMDX JSR FSCMD ;Execute Command
TXA ;Return Result TXA ;Return Result
RTS RTS
;rename(drv, &filnam) - Rename File to filnam ;rename(drv, &filnam) - Rename File to filnam
@ -21,10 +21,10 @@ REMOVE: JSR FSVDRV ;Validate Drive Number
;Args: A = Drive Identifier ;Args: A = Drive Identifier
; Y,X = Address of Directory Name String ; Y,X = Address of Directory Name String
;Returns: A = Error Code (0 = None) ;Returns: A = Error Code (0 = None)
RENAME: JSR FSVDRV ;Validate Drive Number RENAME: JSR FSDRVN ;Convert Drive Letter to Drive Number
BCS .DRVERR ;If Invalid Return Error BCS .RETURN ;If Invalid Return Error
LDA #'M' ;Set Command to KILL (REMOVE) LDA #'M' ;Set Command to KILL (REMOVE)
BNE .FSCMDX ;Execute Command and Return Result BNE .FSCMDX ;Execute Command and Return Result
;inidrv(drv) - Initialize Disk Drive ;inidrv(drv) - Initialize Disk Drive
;Args: A = Drive Identifier ;Args: A = Drive Identifier
@ -36,25 +36,19 @@ INIDRV: LDA #$FF ;Return Error - Not Implemented
;Args: A = Drive# | Disk# ;Args: A = Drive# | Disk#
;Returns: A = Result (0 - Success) ;Returns: A = Result (0 - Success)
; Y = Error Code (0 = None) ; Y = Error Code (0 = None)
CHDRV: JSR FSVDRV ;Validate Drive Number CHDRV: JSR FSDRVN ;Validate Drive Number
BCS .DRVERR ;If Invalid Return Error BCS .RETURN ;If Invalid Return Error
TAY ;Set Drive Number TAY ;Set Drive Number
SEC ;Set Mode to Change SEC ;Set Mode to Change
BCS .GETDRV ;Execute DRIVE Command and Return Result LDA #'V' ;Set Command to DRIVE
BNE .FSCMDX ;Execute Command and Return Result
;getdrv() - Get Current Drive/Disk ;getdrv() - Get Current Drive/Disk
;Returns: A = Drive# | Disk# (0=Failure) ;Returns: A = Drive# | Disk# (0=Failure)
; Y = Error Code (0 = None) ; Y = Error Code (0 = None)
GETDRV: CLC ;Set Mode to Get GETDRV: CLC ;Set Mode to Get
.GETDRV LDA #'V' ;Set Command to DRIVE LDA #'V' ;Set Command to DRIVE
BNE .FSCMDX ;Execute and Return Result JSR FSCMD ;Execute Command
TXA ;Copy Drive Number to A
;drvnam(drv) - Get Drive Name ADC #'@' ; Convert to Drive Letter
;Args: A = Drive Number .RETURN RTS
;Returns: A = Drive Name (0=Failure)
; Y = Error (0=None)
DRVNAM: JSR FSVDRV ;Validate Drive Number
BCS .DRVERR ;If Valid
LDY #0 ; Set Error to None
ADC #'@' ; Return Drive Letter
.DRVERR RTS

View File

@ -8,13 +8,6 @@
* char e - Error, 0=None */ * char e - Error, 0=None */
char chdrv(); char chdrv();
/* Drive Name *
* Args: char d - Drive ID | Disk # *
* Returns: char n - Drive Name *
* 0 = Invalid Device *
* char e - Error, 0=None */
char drvnam();
/* Get Drive * /* Get Drive *
* Returns: char d - Current Drive/Disk * * Returns: char d - Current Drive/Disk *
* 0 = None or Error * * 0 = None or Error *

View File

@ -13,11 +13,16 @@ Auxillary Files - Used by Batch Files
s2boot.dsk Apple 2 Bootable Disk Image - Used by A2.BAT s2boot.dsk Apple 2 Bootable Disk Image - Used by A2.BAT
xvic.ini VICE Configuration - Used bu V8K.BAT xvic.ini VICE Configuration - Used bu V8K.BAT
C02 Test & Demonstration Files C02 Test & Demonstration Programs
System Specific Header Test Progroams
echo.c02 Echo typed keys to screen echo.c02 Echo typed keys to screen
echohex.c02 Display ASCII code of typed keys in Hexadecimal echohex.c02 Display ASCII code of typed keys in Hexadecimal
System Library Module Test Programs
testsd.c02 Test module "stddef" functions
testsl.c02 Test module "stdlib" functions
conds.c02 Test C02 Conditional Expressions conds.c02 Test C02 Conditional Expressions
funcs.c02 Test C02 Function Calls and Parameter Passing funcs.c02 Test C02 Function Calls and Parameter Passing
loops.c02 Test C02 Loop Structures loops.c02 Test C02 Loop Structures
@ -25,7 +30,9 @@ C02 Test & Demonstration Files
forforpf.c02 Demo of printf function from "stringx" module forforpf.c02 Demo of printf function from "stringx" module
strings.c02 Demo of standard library "string" module strings.c02 Demo of standard library "string" module
testhdr.c02 Test system specific Header file functions
testsd.c02 Test module "stddef" functions
testsl.c02 Test module "stdlib" functions
testiox.c02 Test module "stdiox" functions testiox.c02 Test module "stdiox" functions
filetest.c02 Test module "fileio" functions
fstest.c02 Test module "filesys" functions
diskdir.c02 Test module "dirent" functions
dirtest.c02 Test module "direct" functions

View File

@ -24,7 +24,7 @@ main:
goto exit; goto exit;
void prtcwd() { void prtcwd() {
puts("GETCWD: "); puts("GETCWD(0)=");
n, err = getcwd(0, &s); n, err = getcwd(0, &s);
if (err) goto error; if (err) goto error;
putln(&s); putln(&s);

View File

@ -13,7 +13,6 @@
#include <fileio.h02> #include <fileio.h02>
#include <filesys.h02> #include <filesys.h02>
const char dir = "TEMPDIR"; const char dir = "TEMPDIR";
const char oldnam = "OLDFILE.TMP"; const char oldnam = "OLDFILE.TMP";
const char newnam = "NEWFILE.TMP"; const char newnam = "NEWFILE.TMP";
@ -27,51 +26,51 @@ main:
delfil(); delfil();
prtdrv(); prtdrv();
chgdrv(); chgdrv();
goto exit; goto exit;
void chkerr() { void chkerr(aa) {
puts(": "); puts(": ");
if (err) { if (err) {
e = ferror(0, &m); e = ferror(0, &m);
printf(e, "ERROR %d - "); printf(e, "ERROR %d - ");
putln(&m); putln(&m);
} }
else if (r) putln("FAILED"); else if (aa) putln("FAILED");
else putln("SUCCESS"); else putln("SUCCESS");
} }
void prtdrv() { void prtdrv() {
d, err = getdrv(); printf(d,"GETDRV: %d "); chkerr(); d, err = getdrv();
printf(drvnam(d), "DRVNAM: '%c'"); chkerr(); printf(d,"GETDRV()='%c'");
chkerr(0);
} }
void newfil() { void newfil() {
puts("CREATING FILE "); puts(oldnam); puts("CREATING FILE "); puts(oldnam);
f, err = fopen(#MWRITE, oldnam); chkerr(); f, err = fopen(#MWRITE, oldnam); chkerr(0);
puts("WRITING TO FILE "); puts("WRITING TO FILE");
n, err = fputln(f, "FILE CONTENTS"); chkerr(); n, err = fputln(f, "FILE CONTENTS"); chkerr(0);
puts("CLOSING FILE "); puts("CLOSING FILE");
err = fclose(f); chkerr(); err = fclose(f); chkerr(0);
} }
void renfil() { void renfil() {
puts("RENAMING "); puts(oldnam); puts("RENAMING "); puts(oldnam);
puts(" TO "); puts(newnam); puts(" TO "); puts(newnam);
fsname(oldnam); fsname(oldnam);
r, err = rename(newnam); chkerr(); r, err = rename(newnam); chkerr(r);
} }
void delfil() { void delfil() {
puts("REMOVING "); puts(newnam); puts("REMOVING "); puts(newnam);
r, err = remove(newnam); chkerr(); r, err = remove(newnam); chkerr(r);
} }
void chgdrv() { void chgdrv() {
for (i=0; i<#DRIVES; i++) { for (i=0; i<#DRIVES; i++) {
d = drive[i]; d = drive[i];
printf(d, "CHDRV(%d) "); printf(d, "CHDRV('%c') ");
printf(drvnam(d), "'%c'"); r, err = chdrv(d); chkerr(r);
r, err = chdrv(d); chkerr();
} }
} }