// TODO:
// - Write a brief description of the machine being simulated. Only one thread, reduced RAM, no meaningful console when running as screensaver, etc.
-// CLI Flags:
-// -path-to-aout-binary
-// -path-to-font-file
-// -speed
-
// Ideas for sample programs to include:
// - Build list of integers on the stack (DUP, IM_1, ADD).
// - Calculate prime numbers, placing them on the stack.
nedsim->delay = get_integer_resource(nedsim->dpy, "delay", "Integer");
nedsim->delay *= 1000; /* Turn milliseconds into microseconds. */
- // TODO: Read in the a.out file. This should be done in the simulator's init function call?
- nedsim->nedstate = init_simulator();
+ // Load the program file specified by the user or, if none is specified,
+ // randomly select one of the included programs.
+ char * input_file = get_string_resource(nedsim->dpy, "binary", "String");
+ if (input_file == NULL) {
+ // TODO: Need to include some default programs and randomly select one to load into RAM.
+ nedsim->nedstate = init_simulator("./test.out");
+ } else {
+ nedsim->nedstate = init_simulator(input_file);
+ }
nedsim->gc = XCreateGC(nedsim->dpy, nedsim->win, GCForeground, &gcv);
static XrmOptionDescRec NEDsim_options[] = {
{ "-delay", ".delay", XrmoptionSepArg, 0 },
+ { "-binary", ".binary", XrmoptionSepArg, 0 },
{ 0, 0, 0, 0 }
};