#include #include #include "cpu.h" #include "present.h" int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "argc < 2\n"); return -1; } FILE * f; size_t ret; f = fopen(argv[1], "r"); const int program_location = 0x0200; ret = fread(cpu_memory + program_location, 1, 0x10000 - program_location, f); fprintf(stderr, "loaded %ld program bytes at %x\n", ret, program_location); fclose(f); cpu_memory[0xfffc] = (program_location >> 0) & 0xff; cpu_memory[0xfffd] = (program_location >> 8) & 0xff; cpu_reset(); return present_main(); }