#include #define SCR_WIDTH 160 #define FONT_WIDTH 6 #define MAX_CHARS (SCR_WIDTH/FONT_WIDTH) void PrintUsage(void) { printf(" TextScroll Tool by Malcolm Smith Takes an input text file, and formats it into an array of strings for use with the Oblivion text scroller. Usage: textScroll inputfile outputfile array_name * inputfile and outputfile are normally Text (.TXT) files. * array_name must be a standard C array name. It cannot begin with a number, and must be alphanumeric and the underscore (_). No spaces. "); } int main(int argc, char *argv[]) { FILE *f,*out; short a = 0, len, t; short count = 0; char *buffer; char marquee_cur[MAX_CHARS+1]; unsigned short length=0; if(argc!=4) {PrintUsage();return 1;} f = fopen(argv[1],"rt"); if(!f) {PrintUsage();return 1;} out = fopen(argv[2],"wt"); if(!out) {PrintUsage();fclose(f);return 1;} while(!feof(f)) { fgetc(f); length++; } rewind(f); buffer = (char*)malloc(length); fprintf(out,"const char* const %s[] = {\n",argv[3]); while (1) { if (fgets(buffer, length, f) == NULL) break; for(t=0;tMAX_CHARS?MAX_CHARS:strlen(buffer); //Quit if length is 0 if(!len) break; t=0; //Go forward until the end of a word, and while it's less than len while(buffer[t]!=' ' && t