#include #include #include #include #define MAX_FILES 1024 static char *png_filenames[MAX_FILES]; static char *zx02_aux_filenames[MAX_FILES]; static char *zx02_main_filenames[MAX_FILES]; static char *labels[MAX_FILES]; /* Format: file_label FILE.ZX02 file.png */ int main(int argc, char **argv) { char *result; char string[BUFSIZ]; int num_files=0; int i,j,count,line=0; char temp_png[BUFSIZ]; char temp_zx02[BUFSIZ]; char temp_label[BUFSIZ]; char s_filename[BUFSIZ]; char filename_base[BUFSIZ]; char temp[BUFSIZ]; FILE *sss; /******************************************/ /* parse command line */ /******************************************/ if (argc>1) { strcpy(filename_base,argv[1]); } else { strcpy(filename_base,"dlores_plain"); } sprintf(s_filename,"%s.s",filename_base); /******************************************/ /* scan in data */ /******************************************/ while(1) { line++; result=fgets(string,BUFSIZ,stdin); if (result==NULL) { break; } if (result[0]=='#') continue; count=sscanf(string,"%s %s %s",temp_label,temp_zx02,temp_png); if (count!=3) { fprintf(stderr,"WARNING! weird input line %d (%d)\n",line,count); fprintf(stderr,"\t%s",string); } else { labels[num_files]=strdup(temp_label); png_filenames[num_files]=strdup(temp_png); sprintf(temp,"%s.AUX.ZX02",temp_zx02); zx02_aux_filenames[num_files]=strdup(temp); sprintf(temp,"%s.MAIN.ZX02",temp_zx02); zx02_main_filenames[num_files]=strdup(temp); num_files++; if (num_files>=MAX_FILES) { fprintf(stderr,"ERROR! Too many files!\n"); exit(-1); } } } if (num_files==0) { fprintf(stderr,"ERROR! No files found!\n"); exit(-1); } /******************************************/ /* generate S file */ /******************************************/ sss=fopen(s_filename,"w"); if (sss==NULL) { fprintf(stderr,"ERRROR opening %s\n",s_filename); exit(-1); } fprintf(sss,"; Some nice double lores images\n\n"); fprintf(sss,".include \"../dlores_main.s\"\n\n"); fprintf(sss,"MAX_FILES = %d\n\n",num_files); fprintf(sss,"main_filenames_low:\n"); for(i=0;i%s_filename_main\n",labels[i]); } fprintf(sss,"\n"); fprintf(sss,"aux_filenames_low:\n"); for(i=0;i%s_filename_aux\n",labels[i]); } fprintf(sss,"\n"); fprintf(sss,"; filename to open is 30-character Apple text:\n"); for(i=0;i HELLO\n\n"); fprintf(sss,"####\n\n"); fprintf(sss,"%s.dsk:\tHELLO DLORES\\\n",filename_base); for(i=0;i