Example #1
0
int main(){
	mountSDMC();
    u16 pressed = HID_PAD;
	if ((*(vu8 *)0x10010000 == 0) & !(pressed & BUTTON_R1)) // check if this is a coldboot and if key is pressed
		animationLoop();
	load_and_run();
	return 0;
}
Example #2
0
/*
 * This main function is quite high density, it's functions are:
 *  1) Configure the FE with the BE capabilities.
 *  2) Despatch arguments to FE and BE argument checkers.
 *  3) Open and read the BF file.
 *  4) Decode the BF into calls of the outrun() function.
 *  5) Run length encode calls to the outrun() function.
 *  6) Ensure that '[', ']' commands balance.
 *  7) Allow the '#' command only if enabled.
 *  8) If enabled; decode input RLE (a number prefix on the "+-<>" commands)
 *  9) If enabled; decode input quoted strings as BF print sequences.
 * 10) If enabled; convert the '=' command into '[-]'.
 */
int
main(int argc, char ** argv)
{
    int ar, mm=0;
    char * pgm = argv[0];
    char ** filelist = 0;
    int filecount = 0;

    filelist = calloc(argc, sizeof*filelist);

    for(ar=1;ar<argc;ar++) {
	if (argv[ar][0] != '-' || argv[ar][1] == '\0' || mm) {
	    filelist[filecount++] = argv[ar];

	} else if (strcmp(argv[ar], "-h") == 0) {

	    fprintf(stderr, "%s: [options] [File]\n", pgm);
	    fprintf(stderr, "%s\n",
		"\t"    "-h      This message");

	    if (!be_interface.bytesonly)
		fprintf(stderr, "%s\n",
		    "\t"    "-b      Force byte cells"
		    );

	    if (be_interface.hasdebug)
		fprintf(stderr, "%s\n",
		    "\t"    "-#      Turn on trace code."
		    );

	    fprintf(stderr, "%s%d%s\n",
	    "\t"    "-R      Decode rle on '+-<>', quoted strings and '='."
	    "\n\t"  "-m      Disable optimisation (including dead loop removal)"
	    "\n\t"  "-p      Optimise as part of a BF program"
	    "\n\t"  "-O      Enable optimisation"
	    "\n\t"  "-M<num> Set length of tape, default is ", TAPELEN,
	    ""
	    );

	    if (check_arg("-M"))
		printf("\t-M      Set the tape to dynamic\n");

	    check_arg(argv[ar]);
	    exit(0);
	} else if (check_argv(argv[ar])) {
	    ;
	} else if (strcmp(argv[ar], "--") == 0) {
	    mm = 1;
	} else {
	    char * ap = argv[ar]+1;
	    static char buf[4] = "-X";
	    while(*ap) {
		buf[1] = *ap;
		if (!check_argv(buf))
		    break;
		ap++;
	    }
	    if (*ap) {
		fprintf(stderr, "Unknown option '%s'; try -h for option list\n",
			argv[ar]);
		exit(1);
	    }
	}
    }

    check_arg("+init");	/* Callout to BE for soft init. */

    /* Defaults if not told */
    if (!opt_optim && be_interface.disable_fe_optim)
	opt_optim = disable_init_optim = 1;

    if (!opt_optim)
	opt_optim = enable_optim = 1;

    tapeinit = (!be_interface.disable_be_optim && !backend_only)?BOFF:0;

    if (be_interface.bytesonly) bytecell = 1;

    if (filecount == 0)
	filelist[filecount++] = "-";

    if (backend_only)
	pipe_to_be(filelist, filecount);
    else
	load_and_run(filelist, filecount);
    return 0;
}