diff -Nur old/input64.c new/input64.c --- old/input64.c Tue Sep 7 17:30:34 1999 +++ new/input64.c Thu May 9 13:17:33 2002 @@ -11,7 +11,7 @@ static struct input64info_t input64info; -static void reset_input64() { +static void reset_input64(void) { input64info.middle_count = 0; input64info.bits_in_byte = 0; input64info.header_count = 0; @@ -23,7 +23,7 @@ } -static void init_input64() { +static void init_input64(void) { reset_input64(); } diff -Nur old/input64.h new/input64.h --- old/input64.h Tue Sep 7 18:06:30 1999 +++ new/input64.h Thu May 9 13:17:33 2002 @@ -22,10 +22,6 @@ long parity_count; }; -static void reset_input64(); -static void init_input64(); -static void analyse_input64(prg_t * ,tap_t); - extern struct loader_t input64; #endif diff -Nur old/loader.h new/loader.h --- old/loader.h Tue Sep 7 13:08:18 1999 +++ new/loader.h Thu May 9 13:17:33 2002 @@ -31,8 +31,8 @@ struct loader_t { - void (*reset_loader)(); - void (*init_loader)(); + void (*reset_loader)(void); + void (*init_loader)(void); void (*analyse_loader)(prg_t *, tap_t); }; diff -Nur old/novaload.c new/novaload.c --- old/novaload.c Tue Sep 7 13:27:58 1999 +++ new/novaload.c Thu May 9 13:17:33 2002 @@ -12,10 +12,9 @@ static struct novaloadinfo_t novaloadinfo; -static void reset_novaload() { +static void reset_novaload(void) { novaloadinfo.bit0_in_a_row = 0; novaloadinfo.checksum = 0; - novaloadinfo.byteborder = 0; novaloadinfo.actualbyte = 0; novaloadinfo.actualbit = 0; novaloadinfo.byteborder = 0; @@ -24,7 +23,7 @@ } -static void init_novaload() { +static void init_novaload(void) { reset_novaload(); } diff -Nur old/novaload.h new/novaload.h --- old/novaload.h Tue Sep 7 18:06:30 1999 +++ new/novaload.h Thu May 9 13:17:33 2002 @@ -21,10 +21,6 @@ unsigned long subblockcounter; }; -static void reset_novaload(); -static void init_novaload(); -static void analyse_novaload(prg_t * ,tap_t); - extern struct loader_t novaload; #endif diff -Nur old/rom.c new/rom.c --- old/rom.c Tue Sep 7 17:58:38 1999 +++ new/rom.c Thu May 9 13:17:33 2002 @@ -25,7 +25,7 @@ static unsigned char romheader[72]; -static void reset_rom() { +static void reset_rom(void) { rominfo.nextheaderbyte = rominfo.lastheaderbyte = 0; rominfo.nextbit = 0; rominfo.actualbyte = 0; @@ -33,7 +33,7 @@ } -static void init_rom() { +static void init_rom(void) { int byte, bit; reset_rom(); for (byte=0;byte<9;byte++) @@ -47,7 +47,7 @@ char actualbit; char bytefull; char couldbeheader; - long i; + long i = 0; if ((p->state!=headersearch)&&(p->type!=prg_rom)) return; diff -Nur old/rom.h new/rom.h --- old/rom.h Tue Sep 7 18:06:02 1999 +++ new/rom.h Thu May 9 13:17:33 2002 @@ -26,10 +26,6 @@ char bitparity; }; -static void reset_rom(); -static void init_rom(); -static void analyse_rom(prg_t *p,tap_t t); - extern struct loader_t rom; #endif diff -Nur old/smakefile new/smakefile --- old/smakefile Thu Jan 1 01:00:00 1970 +++ new/smakefile Thu May 9 13:17:34 2002 @@ -0,0 +1,44 @@ +# makefile for Amiga SAS-C +OBJDIR = T: +OBJECTS = $(OBJDIR)tape64.o $(OBJDIR)loader.o $(OBJDIR)turbotape.o $(OBJDIR)input64.o $(OBJDIR)rom.o $(OBJDIR)novaload.o +OBJECTSPPC = $(OBJDIR)tape64.op $(OBJDIR)loader.op $(OBJDIR)turbotape.op $(OBJDIR)input64.op $(OBJDIR)rom.op $(OBJDIR)novaload.op +SCOPTS = RESOPT ANSI CPU=68060 NOVERSION STACKEXTEND STACKCHECK PARAMETERS=REGISTERS OPTIMIZE \ +OPTIMIZERINLINELOCAL MEMORYSIZE=HUGE +SCOPTSPPC = RESOPT ANSI HUNKOBJ NOVERSION STACKEXTEND STACKCHECK PARAMETERS=REGISTERS OPTIMIZE \ +OPTIMIZERINLINELOCAL MEMORYSIZE=HUGE + +all: tape64 + +tape64: $(OBJECTS) + slink STRIPDEBUG SMALLDATA SMALLCODE NOICONS QUIET TO $@ FROM LIB:c.o $(OBJECTS) LIB LIB:scm.lib LIB:sc.lib + +$(OBJDIR)tape64.o: tape64.c + sc $(SCOPTS) $< OBJNAME=$(OBJDIR)$>.o +$(OBJDIR)loader.o: loader.c + sc $(SCOPTS) $< OBJNAME=$(OBJDIR)$>.o +$(OBJDIR)turbotape.o: turbotape.c + sc $(SCOPTS) $< OBJNAME=$(OBJDIR)$>.o +$(OBJDIR)input64.o: input64.c + sc $(SCOPTS) $< OBJNAME=$(OBJDIR)$>.o +$(OBJDIR)rom.o: rom.c + sc $(SCOPTS) $< OBJNAME=$(OBJDIR)$>.o +$(OBJDIR)novaload.o: novaload.c + sc $(SCOPTS) $< OBJNAME=$(OBJDIR)$>.o + +tape64ppc: $(OBJECTSPPC) + slinkppc PPC STRIPDEBUG NOICONS QUIET TO $@ FROM LIB:c.o $(OBJECTSPPC) LIB LIB:scppc.lib + +$(OBJDIR)tape64.op: tape64.c + scppc $(SCOPTSPPC) $< OBJNAME=$(OBJDIR)$>.op +$(OBJDIR)loader.op: loader.c + scppc $(SCOPTSPPC) $< OBJNAME=$(OBJDIR)$>.op +$(OBJDIR)turbotape.op: turbotape.c + scppc $(SCOPTSPPC) $< OBJNAME=$(OBJDIR)$>.op +$(OBJDIR)input64.op: input64.c + scppc $(SCOPTSPPC) $< OBJNAME=$(OBJDIR)$>.op +$(OBJDIR)rom.op: rom.c + scppc $(SCOPTSPPC) $< OBJNAME=$(OBJDIR)$>.op +$(OBJDIR)novaload.op: novaload.c + scppc $(SCOPTSPPC) $< OBJNAME=$(OBJDIR)$>.op + + Binary files old/tape64 and new/tape64 differ diff -Nur old/tape64.c new/tape64.c --- old/tape64.c Tue Sep 7 18:17:28 1999 +++ new/tape64.c Thu May 9 13:17:34 2002 @@ -15,9 +15,74 @@ static unsigned long tapsinbuffer; static cbmlist_t *cbmfirst,*cbmlast; +#define EndPutI32(a, b) {register unsigned long epu32 = (b); \ + (a)[3] = (unsigned char) (epu32 >> 24); \ + (a)[2] = (unsigned char) (epu32 >> 16); \ + (a)[1] = (unsigned char) (epu32 >> 8); \ + (a)[0] = (unsigned char) epu32;} +#define EndPutI16(a, b) {register unsigned short epu16 = (b); \ + (a)[1] = (unsigned char) (epu16 >> 8); \ + (a)[0] = (unsigned char) epu16;} + +static size_t writeShort(unsigned short *val, FILE *fh) +{ + unsigned char buf[2]; + + EndPutI16(buf, *val); + return fwrite(buf, sizeof(buf), 1, fh); +} + +static size_t writeLong(unsigned long *val, FILE *fh) +{ + unsigned char buf[4]; + + EndPutI32(buf, *val); + return fwrite(buf, sizeof(buf), 1, fh); +} + +static size_t writeTapHeader(tapheader_t *t, FILE *fh) +{ + unsigned char buf[12+1+3+4]; + + memcpy(buf, t->identifier, 12); + buf[12] = t->version; + buf[13] = 0; + buf[14] = 0; + buf[15] = 0; + EndPutI32(buf+16, t->filesize); + return fwrite(buf, sizeof(buf), 1, fh); +} + +static size_t writeT64Header(t64header_t *t, FILE *fh) +{ + unsigned char buf[32+1+1+2+2+2+24]; + + memcpy(buf, t->identifier, 32); + buf[32] = t->major_version; + buf[33] = t->minor_version; + EndPutI16(buf+34, t->max_entries); + EndPutI16(buf+36, t->used_entries); + buf[38] = buf[39] = 0; + memcpy(buf+40, t->tape_name, 24); + return fwrite(buf, sizeof(buf), 1, fh); +} + +static size_t writeT64Dir(t64dir_t *t, FILE *fh) +{ + unsigned char buf[1+1+2+2+2+4+4+16]; + + buf[0] = t->c64stype; + buf[1] = t->filetype; + EndPutI16(buf+2, t->begin); + EndPutI16(buf+4, t->end); + buf[6] = buf[7] = 0; + EndPutI32(buf+8, t->offset); + buf[12] = buf[13] = buf[14] = buf[15] = 0; + memcpy(buf+16, t->name, 16); + return fwrite(buf, sizeof(buf), 1, fh); +} -static char *strupr(char *s) { - char *ret = s; +static char *mystrupr(char *s) { while (*s) { if ((*s>='a')&&(*s<='z')) { *s = *s - 'a' + 'A'; @@ -28,7 +93,7 @@ } -static BOOL initvars() { +static BOOL initvars(void) { /* default parameters */ parameter.sample_freq = 44100; parameter.sample_width = 256; /* 8-bit */ @@ -66,7 +131,7 @@ } -static void syntax() { +static void syntax(void) { printf("tape64 %s (c) %s by Andreas Matthies\n\n",VERSION,LAST_CHANGE); printf("Syntax: tape64 -i: [options]\n"); printf("\n is a sample of a C2N-tape (usually a .wav-file)\n"); @@ -98,7 +163,7 @@ printf("\n"); while (ok && (i */ @@ -205,7 +270,7 @@ } -static check_parameters() { +static int check_parameters(void) { int fehler = 0; if (parameter.inputtype==sample) { /* check sample-parameters */ @@ -230,7 +295,7 @@ } -static void post_output() { +static void post_output(void) { printf("\nResults of processing:\n----------------------\n"); printf("Input: %s ",parameter.inputname); printf("Type: %s\n",parameter.inputtype==sample?"Sample-File":"TAP-File"); @@ -295,7 +360,8 @@ char c; FILE *f; c = 'Y'; - if (strchr(mode,'w') && !parameter.automatic_yes && fopen(wname,"r")) { + if (strchr(mode,'w') && !parameter.automatic_yes && (f = fopen(wname,"r"))) { + fclose(f); printf("%s exists; ok to overwrite? [Y,N] ",wname); while (!strchr("YyNn",c = getchar())); while (getchar()!='\n'); @@ -314,7 +380,6 @@ static void analyse_inputheader(FILE *wf) { tapheader_t tapheader; unsigned short header[20],info[100]; - BOOL iswav = 0, istap = 0; char wavheader_id[10]; unsigned long chunklength; /* read header */ @@ -325,7 +390,7 @@ } /* CHECK FOR WAV-HEADER */ strncpy(wavheader_id,(char *)&header[4],4); - strupr(wavheader_id); + mystrupr(wavheader_id); if (!strncmp(wavheader_id,"WAVE",4)) { /* its a sample-input with wav-header */ parameter.inputtype = sample; @@ -337,7 +402,7 @@ } chunklength = *(unsigned long*)&header[2]; strncpy(wavheader_id,(char *)header,4); - strupr(wavheader_id); + mystrupr(wavheader_id); if (!strncmp(wavheader_id,"DATA",4)) return; if (!strncmp(wavheader_id,"FMT",3)) { @@ -387,7 +452,7 @@ } -static readinput(unsigned char *i,FILE *wf) { +static int readinput(unsigned char *i,FILE *wf) { if (inputbuffer_next>=inputbuffer_last) { if (feof(wf)) inputbuffer_last = 0; @@ -446,12 +511,12 @@ -static BOOL cbmlist_save(prg_t *prg) { +static void cbmlist_save(prg_t *prg) { long i; cbmlist_t *cnew; cnew = malloc(sizeof(cbmlist_t)); if (!cnew) - return 0; + return; cnew->begin = prg->begin; cnew->end = prg->end; strncpy(cnew->c64name,prg->name,16); @@ -466,7 +531,7 @@ } -static init_p00mode() { +static init_p00mode(void) { FILE *tempfile; char tempfilename[256]; strcpy(tempfilename,parameter.p00dirname); @@ -483,9 +548,9 @@ } -static finish_p00mode() { +static int finish_p00mode(void) { FILE *binfile; - char binfilename[256],extension[10],petfile[17]; + unsigned char binfilename[256],extension[10],petfile[17]; cbmlist_t *cbm; unsigned short cbmlength; short i,number = 0; @@ -498,7 +563,7 @@ strncpy(petfile,cbm->c64name,16); pet_to_pc(petfile); for (i=15; i>=0; i--) - if ((petfile[i]==(char)0x20) || (petfile[i]==(char)0xa0)) + if (petfile[i]==0x20 || petfile[i] == 0xa0) petfile[i] = 0; else i=0; @@ -507,7 +572,7 @@ if (parameter.p00numerate) number++; if (!(binfile = openfile(binfilename,"wb")) - || !(fwrite(&cbm->begin,sizeof(short),1,binfile) == 1) + || !(writeShort(&cbm->begin,binfile) == 1) || !(fwrite(&cbm->data,sizeof(char),cbmlength,binfile) == cbmlength)) { printf("error - couldn't write binary file %s\n",binfilename); errors++; @@ -531,7 +596,7 @@ tapsinbuffer = 0; tf = openfile(parameter.tapname, "wb"); if (tf) - fwrite(tap,sizeof(tapheader_t),1,tf); + writeTapHeader(tap,tf); return tf; } @@ -541,7 +606,6 @@ BOOL ok=1; int j,i=0; unsigned char c[4]; - ok = 1; if (tap/8 <= 255) c[i++] = (unsigned char)(tap/8); else { @@ -567,7 +631,7 @@ /* flush buffer and write length-information */ ok = (fwrite(tapbuffer,sizeof(unsigned char),tapsinbuffer,tf)==tapsinbuffer) && !fseek(tf,16L,SEEK_SET) - && (fwrite(&tap->filesize,sizeof(long),1,tf)); + && (writeLong(&tap->filesize,tf)); fclose(tf); free(tapbuffer); return ok; @@ -606,7 +670,7 @@ t64dir.evennotused = 0; t64->used_entries = entries; t64->max_entries = t64->used_entries; - if (fwrite(t64,sizeof(t64header_t),1,t64file)!=1) { + if (writeT64Header(t64,t64file)!=1) { printf("error: couldn't write t64-header\n"); return 0; } @@ -618,7 +682,7 @@ t64dir.begin = cbm->begin; t64dir.end = cbm->end; t64dir.offset = current_offset; - if (fwrite(&t64dir,sizeof(t64dir_t),1,t64file)!=1) { + if (writeT64Dir(&t64dir,t64file)!=1) { printf("error: couldn't write t64-directory\n"); return 0; } @@ -655,8 +719,8 @@ } -static read_trigger_from_file(tap_t *tr, FILE *f, samplestate_t *ss) { - unsigned char t1,t2,t3,t4; +static BOOL read_trigger_from_file(tap_t *tr, FILE *f, samplestate_t *ss) { + unsigned char t1,t2=0,t3=0,t4=0; BOOL ok; if ((ok = readinput(&t1,f)) && (!t1) && (parameter.tap_version>=1)) { ok = (readinput(&t2,f) && readinput(&t3,f) && readinput(&t4,f)); @@ -672,10 +736,10 @@ } -static readsample(unsigned char *sa, FILE *f) { - BOOL ok; +static BOOL readsample(unsigned char *sa, FILE *f) { + BOOL ok = 0; char channel; - unsigned char by[2]; + unsigned char by[2] = {0,0}; for (channel=0;channel256) { @@ -694,7 +758,7 @@ } -static read_trigger_from_sample(tap_t *tr, FILE *f, samplestate_t *ss) { +static BOOL read_trigger_from_sample(tap_t *tr, FILE *f, samplestate_t *ss) { double tempf; unsigned char samplebyte; BOOL found = 0; @@ -730,12 +794,13 @@ return read_trigger_from_sample(tr,f,ss); if(parameter.inputtype==tap) return read_trigger_from_file(tr,f,ss); + return 0; } int main(int argc, char *argv[]) { - FILE *inputfile=NULL, *t64file=NULL, *tapfile=NULL; - BOOL p00_okay; + FILE *inputfile, *t64file=NULL, *tapfile=NULL; + BOOL p00_okay = 0; samplestate_t samplestate; tapheader_t tapheader; t64header_t t64header; @@ -751,10 +816,10 @@ if (!initvars() || !getparams(argc, argv) || !(inputfile=openfile(parameter.inputname, "rb"))) - return leaveprog(-1); + return leaveprog(10); analyse_inputheader(inputfile); if (!check_parameters()) - return leaveprog(-2); + return leaveprog(11); if (parameter.p00output) p00_okay = init_p00mode(); if (parameter.tapoutput) diff -Nur old/tape64.h new/tape64.h --- old/tape64.h Tue Sep 7 15:32:10 1999 +++ new/tape64.h Thu May 9 13:17:34 2002 @@ -11,7 +11,7 @@ #include "loader.h" #define VERSION "V1.2" -#define LAST_CHANGE "07/09/1999" +#define LAST_CHANGE "2002-05-09" #define MAXINPUTBUFFER 1000000 #define MAXTAPBUFFER 100000 @@ -43,8 +43,7 @@ double tapespeed; } param_t; - -const char TAP_IDENTIFIER[12] = "C64-TAPE-RAW"; +#define TAP_IDENTIFIER "C64-TAPE-RAW" typedef struct { char identifier[12]; unsigned char version; @@ -52,7 +51,7 @@ unsigned long filesize; } tapheader_t; -const char T64_IDENTIFIER[32] = "C64S tape image file\0\0\0\0\0\0\0\0\0\0\0\0"; +#define T64_IDENTIFIER "C64S tape image file\0\0\0\0\0\0\0\0\0\0\0\0" typedef struct { char identifier[32]; char major_version, minor_version; @@ -72,6 +71,7 @@ unsigned char name[16]; } t64dir_t; +#define c64_pulse 985248.0 typedef struct cbm { unsigned short begin; @@ -80,10 +80,6 @@ unsigned char data[MAXPRGSIZE]; struct cbm *next; } cbmlist_t; - - -const char allowedfilechars[] = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!§$%&()=',.-_;~+"; -const double c64_pulse = 985248.0; typedef struct { sample_t last_sample, sample; diff -Nur old/turbotape.c new/turbotape.c --- old/turbotape.c Tue Sep 7 17:58:54 1999 +++ new/turbotape.c Thu May 9 13:17:34 2002 @@ -24,7 +24,7 @@ static unsigned char ttheader[72]; -static void reset_turbotape() { +static void reset_turbotape(void) { ttinfo.nextheaderbyte = ttinfo.lastheaderbyte = 0; ttinfo.nextbit = 0; ttinfo.actualbyte = 0; @@ -33,7 +33,7 @@ -static void init_turbotape() { +static void init_turbotape(void) { int byte, bit; reset_turbotape(); for (byte=0;byte<9;byte++) @@ -47,7 +47,7 @@ char actualbit; char bytefull; char couldbeheader; - long i; + long i = 0; if ((p->state!=headersearch)&&(p->type!=prg_turbotape)) return; diff -Nur old/turbotape.h new/turbotape.h --- old/turbotape.h Tue Sep 7 18:06:02 1999 +++ new/turbotape.h Thu May 9 13:17:34 2002 @@ -20,10 +20,6 @@ unsigned char nextbit; }; -static void reset_turbotape(); -static void init_turbotape(); -static void analyse_turbotape(prg_t *p,tap_t t); - extern struct loader_t turbotape; #endif