swissChili | 6c61a79 | 2020-07-28 16:29:20 -0700 | [diff] [blame] | 1 | #include "cpu.h" |
| 2 | |
| 3 | #include <ctype.h> |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <unistd.h> |
| 7 | |
| 8 | int main(int argc, char **argv) |
| 9 | { |
| 10 | printf("6502 Emulator\n"); |
| 11 | |
| 12 | uint8_t disflag = 0, |
| 13 | runflag = 0, |
| 14 | helpflag = 0; |
| 15 | |
| 16 | char c; |
| 17 | |
| 18 | while ((c = getopt(argc, argv, "drh")) != -1) |
| 19 | { |
| 20 | switch (c) |
| 21 | { |
| 22 | case 'd': |
| 23 | disflag = 1; |
| 24 | break; |
| 25 | case 'r': |
| 26 | runflag = 1; |
| 27 | break; |
| 28 | case 'h': |
| 29 | case '?': |
| 30 | helpflag = 1; |
| 31 | break; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | if (helpflag) |
| 36 | { |
| 37 | printf("-r to run, -d to disassemble"); |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | cpu_t cpu = new_cpu(); |
| 42 | fread(cpu.mem, 0xFFFF, 1, stdin); |
| 43 | |
| 44 | if (disflag) |
| 45 | { |
| 46 | disas(&cpu); |
| 47 | } |
| 48 | |
| 49 | free_cpu(&cpu); |
| 50 | } |