/* Load a basic script */ void LoadScript(void){ FILE *fp; char line[80]; int i; char loadingString[255]; char one_line[80]; /* did GetArguments find a script? */ if(script_found) { printf("Located .bas script path: %s\n\n", script_path); } else { strcpy(script_path, DEFAULT_BAS_SCRIPT); printf("No .bas script provided. Loading the default script.\n\n", DEFAULT_BAS_SCRIPT); } fp = fopen(script_path, "r"); if(fp != NULL) { /* Display file loading info onscreen */ sprintf(one_line, "Load \"%s\"", script_path); PrintTextLine(one_line); /* Clean out the old program */ for(i=0;i<MAX_SCRIPT_LENGTH-1;i++) { program[i] = 0; } /* Read in the new program */ while(fgets(line, sizeof(line), fp)){ strcat(program, line); /* printf("%s\n", line); */ /* sprintf(one_line, "%s", line); */ /* PrintTextLine(one_line); */ /* Display program line onscreen */ } printf("--------------------------------------------\n"); printf("Loading Script: \"%s\"\n", script_path); printf("--------------------------------------------\n"); printf("%s",program); printf("--------------------------------------------\n"); } else { printf("Error: Sorry, I can't open the script.\n"); PrintTextLine("Sorry, I can't open the script."); } fclose(fp); }
int main (int argc, char *argv[]) { int inc=0; start_time = time(NULL); GetArguments(argc, argv); /* Get the script filename */ PrintVersion(); /* Print info */ InitGFX(); /* Setup SDL */ DisplayTitle(); /* Show the irixbasic titles */ DisplayReady(); /* Display the ready text */ LoadScript(); SDL_Flip(screen); ubasic_init(program); /* Setup uBasic */ /* Start the program when the user is ready */ PrintTextLine("Click to Run."); SDL_Delay(200); do { GetInput(); /* Read the inputs */ }while (!GetMouseButton()); do { GetInput(); /* Read the inputs */ ubasic_run(); /* Process a line of code*/ }while (!ubasic_finished() && !done); PrintTextLine(""); PrintTextLine("Click or Press ESC to quit."); SDL_Flip(screen); while(!done && !GetMouseButton()){ GetInput(); } TTF_CloseFont( fntc64 ); return 0; }
void PrintTextRaw (void *xtbuf, unsigned char *text, int indent, time_t stamp) { char *last_text = text; int len = 0; int beep_done = FALSE; /* split the text into separate lines */ while (1) { switch (*text) { case 0: PrintTextLine (xtbuf, last_text, len, indent, stamp); return; case '\n': PrintTextLine (xtbuf, last_text, len, indent, stamp); text++; if (*text == 0) return; last_text = text; len = 0; break; case ATTR_BEEP: *text = ' '; if (!beep_done) /* beeps may be slow, so only do 1 per line */ { beep_done = TRUE; if (!prefs.filterbeep) gdk_beep (); } default: text++; len++; } } }
void DisplayReady() { PrintTextLine("Ready"); /* Make sure everything is displayed on screen */ SDL_Flip(screen); }