From 33a19c7a873788cad2debd241e9bb17eaa6109ad Mon Sep 17 00:00:00 2001 From: Curtis F Kaylor Date: Fri, 29 Mar 2019 19:09:04 -0400 Subject: [PATCH] Added test/fileread.c02 for VIC-20 and C64 --- test/c64.bat | 2 +- test/fileread.c02 | 109 ++++++++++++++++++++++++++++++++++++++++++++++ test/v8k.bat | 4 +- test/x64.ini | 7 ++- test/xvic.ini | 5 ++- 5 files changed, 121 insertions(+), 6 deletions(-) create mode 100644 test/fileread.c02 diff --git a/test/c64.bat b/test/c64.bat index 5c620fe..e76e61a 100644 --- a/test/c64.bat +++ b/test/c64.bat @@ -5,7 +5,7 @@ IF EXIST %1.c02 GOTO COMPILE :COMPILE ECHO Compiling File %1.c02 for Commodore 64 -..\c02.exe -h c64 -s c64 %1 >%1.dbg +..\c02.exe -h c64 -s c64 -s cbm %1 >%1.dbg IF %ERRORLEVEL% NEQ 0 GOTO EOF ECHO Assembling File %1.asm C:\Programs\dasm %1.asm -f1 -o%1.prg -l%1.lst -s%1.sym diff --git a/test/fileread.c02 b/test/fileread.c02 new file mode 100644 index 0000000..bd12b37 --- /dev/null +++ b/test/fileread.c02 @@ -0,0 +1,109 @@ +/********************************* + * FILES - File Module Test/Demo * + * currently coded for CBM 8-bit * + *********************************/ + +//Specify System Header using -H option +#include +#include +#include +#include +#include +#include +#include + +const char binfil = "BNRYFILE.TXT"; +const char txtfil = "TEXTFILE.TXT"; +const char blkfil = "BLCKFILE.TXT"; +const char device = #DRIVE2; +char bfp; //Binary File Pointer +char tfp; //Text File Pointer +char kfp; //Block File Pointer +char err; //Error Code +char ch; //Character Read from File +char i; //Loop Index Variable +char n; //Number of Characters Read +char s[128]; //String Read from File +char r[255]; //Array Buffer for Read +char aa,xx,yy; //Function Arguments + +main: + clrscr(); + bfp = opnfil(device, &binfil); + tfp = opnfil(device, &txtfil); + kfp = opnfil(device, &blkfil); + if (bfp) rdbinf(); + if (tfp) rdtxtf(); + if (kfp) rdblkf(); + clsfil(bfp); + clsfil(tfp); + clsfil(kfp); +goto exit; + +void opnfil(aa,yy,xx) { + puts("OPENING "); putln(*,yy,xx); + printf(aa, " ON DEVICE %d%n"); + aa, yy = fopen(aa, yy, xx); + if (aa) printf(aa, "OPENED ON CHANNEL %d%n"); + else printf(yy, "ERROR %d OPENING FILE%n"); + newlin(); + return aa; +} + +void clsfil(aa) { + printf(aa, "CLOSING CHANNEL %d%n"); + fclose(aa); +} + +void rdbinf() { + printf(bfp, "%n%n"); + while(!feof(bfp)) { + ch, err = fgetc(bfp); + if (err) break; + puthex(ch); putspc(); + } + newlin(); + if (err) printf(err,"%n"); + else putln(""); + newlin(); +} + +void rdtxtf() { + printf(tfp, "%n"); + while(!feof(tfp)) { + n, err = fgets(tfp, &s); + if (err) break; + printf(n,"%l %s%n"); + } + if (err) printf(err,"%n"); + else putln(""); + newlin(); +} + +void rdblkf() { + printf(kfp, "%n"); + while(!feof(kfp)) { + setdst(&r); + n, err = fread(kfp, 16); + if (err) break; + printf(n,"%l "); + for (i=0; i%n"); + else putln(""); + newlin(); +} + +/* Print File System Info */ +void prtfsi() { + printf(fslfno, ".LFN=%d, "); printf(fsdvno, "DEV=%d, "); printf(fssadr, "SA=%d%n"); + setdst(*,fsfnhi,fsfnlo); printf(".NAME='%s'%n.ADR=$%w, "); + printf(fsfnln,"LEN=%d%n"); + prtopf(); +} + +/* Print Number of Open Files */ +void prtopf() { + printf(fsnofl,".OPEN FILES: %d%n"); +} \ No newline at end of file diff --git a/test/v8k.bat b/test/v8k.bat index 953afb4..1680e0a 100644 --- a/test/v8k.bat +++ b/test/v8k.bat @@ -5,7 +5,7 @@ IF EXIST %1.c02 GOTO COMPILE :COMPILE ECHO Compiling File %1.c02 for VIC 20 +8k -..\c02.exe -h vic8k -s vic %1 >%1.dbg +..\c02.exe -h vic8k -s vic -s cbm %1 >%1.dbg IF %ERRORLEVEL% NEQ 0 GOTO EOF ECHO Assembling File %1.asm C:\Programs\dasm %1.asm -f1 -o%1.prg -l%1.lst -s%1.sym @@ -13,6 +13,6 @@ C:\Programs\dasm %1.asm -f1 -o%1.prg -l%1.lst -s%1.sym IF %ERRORLEVEL% NEQ 0 GOTO EOF ECHO Starting Emulator -@start C:\Programs\WinVICE\xvic.exe -config xvic.ini %1.prg +@start C:\Programs\WinVICE\xvic.exe -config xvic.ini -1 testtape.t64 -10 geosdisk.d64 %1.prg :EOF \ No newline at end of file diff --git a/test/x64.ini b/test/x64.ini index a9d7858..7083ac1 100644 --- a/test/x64.ini +++ b/test/x64.ini @@ -1,4 +1,6 @@ [C64] +InitialDefaultDir="C:\Users\Curtis\Dropbox\projects\C02\test" +InitialTapeDir="C:\Users\Curtis\Dropbox\projects\C02\test" Window0Xpos=572 Window0Ypos=19 Window0Width=735 @@ -13,9 +15,10 @@ VICIIFilter=0 SidEngine=1 SidModel=1 IECDevice8=1 -AutostartBasicLoad=1 -AutostartRunWithColon=1 AutostartWarp=0 +FileSystemDevice9=1 +IECDevice9=1 +FSDevice9Dir="C:\Users\Curtis\Dropbox\projects\C02\test" DriveTrueEmulation=0 ETHERNETCARTBase=56832 Acia1Base=56832 diff --git a/test/xvic.ini b/test/xvic.ini index 62e5ac6..6310c96 100644 --- a/test/xvic.ini +++ b/test/xvic.ini @@ -1,4 +1,6 @@ [VIC20] +InitialDefaultDir="C:\Users\Curtis\Dropbox\projects\C02\test" +InitialTapeDir="C:\Users\Curtis\Dropbox\projects\C02\test" Window0Xpos=523 Window0Ypos=58 Window0Width=618 @@ -16,8 +18,9 @@ VICFilter=0 SidEngine=1 SidModel=0 JoyDevice1=1 +FileSystemDevice9=1 +FSDevice9Dir="C:\Users\Curtis\Dropbox\projects\C02\test" DriveTrueEmulation=0 ETHERNET_DISABLED=1 ETHERNETCARTBase=38912 Acia1Base=38912 -