On 2010-03-29, at 13:35, Groepaz wrote: > > it becomes an advantage at the very moment you try to interact with > files > "from the real world" from within your cc65 program. then all of a > sudden most > files you will deal with are PRG. even SEQ is a special case that > most people > never use. USR is just completely alien to pretty much everyone, and > totally > useless if you want to work on it with some other program which is > not written > with cc65. > I am somehow surprised by what you write. You are right that USR was rarely used in the "real world" but those files are read and written just the regular way. PRG was probably most common due to the possibility of using KERNAL' s relatively fast, and easy to use LOAD routine. But - anyway - if you want to support some "real world" program, which requires PRG (or whatever) even for pure data, then AFAIR you can set the filetype "on the fly" rather than patching the runtime, isn't it so: #include <stdio.h> #include <cbm.h> void main(void) { FILE *file; printf("\n\nOpening PRG file... "); _filetype = 'p'; if(file = fopen("write", "w")) { printf("PRG file opened fine.\nWriting to it...\n"); fprintf(file, "This is a PRG file content"); fclose(file); printf("Done.\n"); } else { printf("Error opening PRG file!\n"); } printf("\n\nOpening SEQ file... "); _filetype = 's'; if(file = fopen("writes", "w")) { printf("SEQ file opened fine.\nWriting to it...\n"); fprintf(file, "This is a SEQ file content"); fclose(file); printf("Done.\n"); } else { printf("Error opening SEQ file!\n"); } printf("\n\nOpening USR file... "); _filetype = 'u'; if(file = fopen("writeu", "w")) { printf("USR file opened fine.\nWriting to it...\n"); fprintf(file, "This is a USR file content"); fclose(file); printf("Done.\n"); } else { printf("Error opening USR file!\n"); } } If OTOH you write generic/portable program with no legacy support - then USR is just as fine (or even finer due to lack of ambiguity/doubt about the first two bytes) as PRG. Using the files created above: #include <stdio.h> void main(void) { FILE *file; printf("\n\nOpening PRG file...\n"); if(file = fopen("write", "r")) { printf("PRG file opened fine.\nReading content \n***************************\n\n"); while(!feof(file)) { putchar(fgetc(file)); } fclose(file); printf("\n\nDone."); } else { printf("Error opening PRG file!\n"); } printf("\n\nOpening SEQ file...\n"); if(file = fopen("writes", "r")) { printf("SEQ file opened fine.\nReading content \n***************************\n\n"); while(!feof(file)) { putchar(fgetc(file)); } fclose(file); printf("\n\nDone."); } else { printf("Error opening SEQ file!\n"); } printf("\n\nOpening USR file...\n"); if(file = fopen("writeu", "r")) { printf("USR file opened fine.\nReading content \n***************************\n\n"); while(!feof(file)) { putchar(fgetc(file)); } fclose(file); printf("\n\nDone."); } else { printf("Error opening USR file!\n"); } } So my question was more about what is the real advantage of having the patched runtime vs. setting the file type from within the code itself? -- SD! ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Mon Mar 29 15:25:57 2010
This archive was generated by hypermail 2.1.8 : 2010-03-29 15:26:00 CEST