mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-06-08 21:29:30 +00:00
Added test/fileread.c02 for VIC-20 and C64
This commit is contained in:
parent
0e149b7798
commit
33a19c7a87
|
@ -5,7 +5,7 @@ IF EXIST %1.c02 GOTO COMPILE
|
||||||
|
|
||||||
:COMPILE
|
:COMPILE
|
||||||
ECHO Compiling File %1.c02 for Commodore 64
|
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
|
IF %ERRORLEVEL% NEQ 0 GOTO EOF
|
||||||
ECHO Assembling File %1.asm
|
ECHO Assembling File %1.asm
|
||||||
C:\Programs\dasm %1.asm -f1 -o%1.prg -l%1.lst -s%1.sym
|
C:\Programs\dasm %1.asm -f1 -o%1.prg -l%1.lst -s%1.sym
|
||||||
|
|
109
test/fileread.c02
Normal file
109
test/fileread.c02
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
/*********************************
|
||||||
|
* FILES - File Module Test/Demo *
|
||||||
|
* currently coded for CBM 8-bit *
|
||||||
|
*********************************/
|
||||||
|
|
||||||
|
//Specify System Header using -H option
|
||||||
|
#include <screen.h02>
|
||||||
|
#include <stddef.h02>
|
||||||
|
#include <stdlib.h02>
|
||||||
|
#include <stdio.h02>
|
||||||
|
#include <stdiox.h02>
|
||||||
|
#include <string.h02>
|
||||||
|
#include <fileio.h02>
|
||||||
|
|
||||||
|
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<READING CHANNEL %d>%n");
|
||||||
|
while(!feof(bfp)) {
|
||||||
|
ch, err = fgetc(bfp);
|
||||||
|
if (err) break;
|
||||||
|
puthex(ch); putspc();
|
||||||
|
}
|
||||||
|
newlin();
|
||||||
|
if (err) printf(err,"<ERROR %d READING FILE>%n");
|
||||||
|
else putln("<END OF FILE>");
|
||||||
|
newlin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void rdtxtf() {
|
||||||
|
printf(tfp, "<READING CHANNEL %d>%n");
|
||||||
|
while(!feof(tfp)) {
|
||||||
|
n, err = fgets(tfp, &s);
|
||||||
|
if (err) break;
|
||||||
|
printf(n,"%l %s%n");
|
||||||
|
}
|
||||||
|
if (err) printf(err,"<ERROR %d READING FILE>%n");
|
||||||
|
else putln("<END OF FILE>");
|
||||||
|
newlin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void rdblkf() {
|
||||||
|
printf(kfp, "<READING CHANNEL %d>%n");
|
||||||
|
while(!feof(kfp)) {
|
||||||
|
setdst(&r);
|
||||||
|
n, err = fread(kfp, 16);
|
||||||
|
if (err) break;
|
||||||
|
printf(n,"%l ");
|
||||||
|
for (i=0; i<n; i++) putc(r[i]);
|
||||||
|
newlin();
|
||||||
|
}
|
||||||
|
if (err) printf(err,"<ERROR %d READING FILE>%n");
|
||||||
|
else putln("<END OF FILE>");
|
||||||
|
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");
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ IF EXIST %1.c02 GOTO COMPILE
|
||||||
|
|
||||||
:COMPILE
|
:COMPILE
|
||||||
ECHO Compiling File %1.c02 for VIC 20 +8k
|
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
|
IF %ERRORLEVEL% NEQ 0 GOTO EOF
|
||||||
ECHO Assembling File %1.asm
|
ECHO Assembling File %1.asm
|
||||||
C:\Programs\dasm %1.asm -f1 -o%1.prg -l%1.lst -s%1.sym
|
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
|
IF %ERRORLEVEL% NEQ 0 GOTO EOF
|
||||||
|
|
||||||
ECHO Starting Emulator
|
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
|
:EOF
|
|
@ -1,4 +1,6 @@
|
||||||
[C64]
|
[C64]
|
||||||
|
InitialDefaultDir="C:\Users\Curtis\Dropbox\projects\C02\test"
|
||||||
|
InitialTapeDir="C:\Users\Curtis\Dropbox\projects\C02\test"
|
||||||
Window0Xpos=572
|
Window0Xpos=572
|
||||||
Window0Ypos=19
|
Window0Ypos=19
|
||||||
Window0Width=735
|
Window0Width=735
|
||||||
|
@ -13,9 +15,10 @@ VICIIFilter=0
|
||||||
SidEngine=1
|
SidEngine=1
|
||||||
SidModel=1
|
SidModel=1
|
||||||
IECDevice8=1
|
IECDevice8=1
|
||||||
AutostartBasicLoad=1
|
|
||||||
AutostartRunWithColon=1
|
|
||||||
AutostartWarp=0
|
AutostartWarp=0
|
||||||
|
FileSystemDevice9=1
|
||||||
|
IECDevice9=1
|
||||||
|
FSDevice9Dir="C:\Users\Curtis\Dropbox\projects\C02\test"
|
||||||
DriveTrueEmulation=0
|
DriveTrueEmulation=0
|
||||||
ETHERNETCARTBase=56832
|
ETHERNETCARTBase=56832
|
||||||
Acia1Base=56832
|
Acia1Base=56832
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
[VIC20]
|
[VIC20]
|
||||||
|
InitialDefaultDir="C:\Users\Curtis\Dropbox\projects\C02\test"
|
||||||
|
InitialTapeDir="C:\Users\Curtis\Dropbox\projects\C02\test"
|
||||||
Window0Xpos=523
|
Window0Xpos=523
|
||||||
Window0Ypos=58
|
Window0Ypos=58
|
||||||
Window0Width=618
|
Window0Width=618
|
||||||
|
@ -16,8 +18,9 @@ VICFilter=0
|
||||||
SidEngine=1
|
SidEngine=1
|
||||||
SidModel=0
|
SidModel=0
|
||||||
JoyDevice1=1
|
JoyDevice1=1
|
||||||
|
FileSystemDevice9=1
|
||||||
|
FSDevice9Dir="C:\Users\Curtis\Dropbox\projects\C02\test"
|
||||||
DriveTrueEmulation=0
|
DriveTrueEmulation=0
|
||||||
ETHERNET_DISABLED=1
|
ETHERNET_DISABLED=1
|
||||||
ETHERNETCARTBase=38912
|
ETHERNETCARTBase=38912
|
||||||
Acia1Base=38912
|
Acia1Base=38912
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user