1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-15 17:08:51 +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
const char drive[]; //Disk Drives
const char drive[];
#define DISKS 0 //Number of Drives in Disk
const char disk[];

View File

@ -33,11 +33,3 @@ CHDRV: LDA #$FF ;Return Result - Failure
;Returns: A = Drive# | Disk# (0=Failure)
; Y = Error Code (0 = None)
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 */
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 *
* Returns: char d - Current Drive/Disk *
* 0 = None or Error *

View File

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

View File

@ -1,6 +1,6 @@
; C02 Module dirent Assembly Language Eoutines for run6502 emulator
; 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
@ -9,7 +9,7 @@
; Y,X = Pointer to Directory Name
;Returns: A = File Pointer (0 = Not Opened)
; 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
LDA #'D' ;Set Command to OPENDIR
.FSCMDX JSR FSCMD ;Execute Command

View File

@ -10,7 +10,7 @@
SUBROUTINE FILEIO
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
DISK BYTE 0
@ -37,14 +37,15 @@ FFLUSH: TAY ;Set Channel Number
; Y,X = Pointer to File Name
;Returns: A = File Channel (0=File Not Opened)
; Y = Error (0=None)
FOPEN: JSR FSVDRV ;Validate Drive Number
BCS .DRVERR
JSR FSNAME ;Set Filename
TAY ;and Pass in Y
FOPEN: JSR FSNAME ;Set Filename
TAX ;Pass Mode to X
JSR FSDRVN ;Convert Drive Letter to Drive Number
BCS .RETURN ;If Error, Return Carry Set
TAY ;Pass Drive Number in Y
LDA #'O' ;Set Command to OPEN
.FEXECX JSR FSCMD ;Execute Command
TXA ;Return Channel in A
.DRVERR RTS
RTS
;fclose(chan) - Close File
;Args: A = Channel Number
@ -164,21 +165,25 @@ FERROR: JSR FSADDR ;Set Buffer Address
;File System Commands
;Check fot Valid Drive Number
;Args: A = Drive Number
;Returns: A = Index into Drives
;Convert Drive Letter Into Drive Number
;Drive letters A-Z in DOS map to drive numbers 1-26
;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 Set = Invalid Drive Number
FSVDRV: PHA
AND #$1F ;Isolate Drive Number
CMP #DRIVES+2 ;Compare against Number of Drives
PLA
BCS .FSVERR
RTS
.FSVERR LDA #$FF ;Return Operation Failed
LDY #1 ;Error - Invalid Argument
RTS
FSDRVN: SEC
SBC #' ' ;If Drive Specifier
BCS .FSDRVL ;is NULL through SPACE
LDA #0 ; Return Drive Number 0
RTS ; and Carry Clear
.FSDRVL AND #$1F ;Convert A-Z, a-z to 1-26
CMP #DRIVES+2 ;If Drive Number is
BCC .RETURN ;greater than 26
LDA #$FF ; Return Operation Failed
LDY #1 ; and Error - Invalid Argument
.RETURN RTS
;fsinit() - Initialize File System
FSINIT: LDA #'I' ;Set Command to INITFS

View File

@ -1,6 +1,6 @@
; C02 Module filesys Assembly Language Eoutines for run6502 emulator
; 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
@ -9,11 +9,11 @@
;Args: A = Drive Identifier
; Y,X = Address of Directory Name String
;Returns: A = Error Code (0 = None)
REMOVE: JSR FSVDRV ;Validate Drive Number
BCS .DRVERR ;If Invalid Return Error
LDA #'K' ;Set Command to KILL (REMOVE)
.FSCMDX JSR FSCMD ;Execute Command
TXA ;Return Result
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
@ -21,10 +21,10 @@ REMOVE: JSR FSVDRV ;Validate Drive Number
;Args: A = Drive Identifier
; Y,X = Address of Directory Name String
;Returns: A = Error Code (0 = None)
RENAME: JSR FSVDRV ;Validate Drive Number
BCS .DRVERR ;If Invalid Return Error
LDA #'M' ;Set Command to KILL (REMOVE)
BNE .FSCMDX ;Execute Command and Return Result
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
@ -36,25 +36,19 @@ INIDRV: LDA #$FF ;Return Error - Not Implemented
;Args: A = Drive# | Disk#
;Returns: A = Result (0 - Success)
; Y = Error Code (0 = None)
CHDRV: JSR FSVDRV ;Validate Drive Number
BCS .DRVERR ;If Invalid Return Error
CHDRV: JSR FSDRVN ;Validate Drive Number
BCS .RETURN ;If Invalid Return Error
TAY ;Set Drive Number
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
;Returns: A = Drive# | Disk# (0=Failure)
; Y = Error Code (0 = None)
GETDRV: CLC ;Set Mode to Get
.GETDRV LDA #'V' ;Set Command to DRIVE
BNE .FSCMDX ;Execute and Return Result
;drvnam(drv) - Get Drive Name
;Args: A = Drive Number
;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
LDA #'V' ;Set Command to DRIVE
JSR FSCMD ;Execute Command
TXA ;Copy Drive Number to A
ADC #'@' ; Convert to Drive Letter
.RETURN RTS

View File

@ -8,13 +8,6 @@
* char e - Error, 0=None */
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 *
* Returns: char d - Current Drive/Disk *
* 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
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
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
funcs.c02 Test C02 Function Calls and Parameter Passing
loops.c02 Test C02 Loop Structures
@ -25,7 +30,9 @@ C02 Test & Demonstration Files
forforpf.c02 Demo of printf function from "stringx" 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
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;
void prtcwd() {
puts("GETCWD: ");
puts("GETCWD(0)=");
n, err = getcwd(0, &s);
if (err) goto error;
putln(&s);

View File

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