forked from unya/usim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusim.c
115 lines (96 loc) · 1.98 KB
/
usim.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <signal.h>
#include <string.h>
#include <stdbool.h>
#include <limits.h>
#include <unistd.h>
#include <sys/time.h>
#include "usim.h"
#include "ucode.h"
#include "lashup.h"
#include "iob.h"
#include "tv.h"
#include "kbd.h"
#include "chaos.h"
#include "ether.h"
#include "disk.h"
#include "syms.h"
#include "decode.h"
char *disk_filename = "disk.img";
char *mcrsym_filename = "../bands/ucadr.sym.841";
char *promsym_filename = "../bands/promh.sym.9";
bool run_ucode_flag = true;
bool save_state_flag = false;
bool warm_boot_flag = false;
bool stop_after_prom_flag = false;
bool prom_enabled_flag = true;
bool lashup_flag = false;
char *lashup_port = "/dev/ttyUSB0";
void
usage(void)
{
fprintf(stderr, "usage: usim [OPTION]...\n");
fprintf(stderr, "CADR simulator\n");
fprintf(stderr, "\n");
fprintf(stderr, " -i FILE set disk image\n");
fprintf(stderr, " -S save state\n");
fprintf(stderr, " -s halt after prom runs\n");
fprintf(stderr, " -w warm boot\n");
fprintf(stderr, " -l lashup\n");
fprintf(stderr, " -h help message\n");
}
extern char *optarg;
int
main(int argc, char *argv[])
{
int c;
printf("CADR emulator v0.9\n");
while ((c = getopt(argc, argv, "i:Sswl")) != -1) {
switch (c) {
case 'i':
disk_filename = strdup(optarg);
break;
case 'S':
save_state_flag = 1;
break;
case 's':
stop_after_prom_flag = 1;
break;
case 'w':
warm_boot_flag = 1;
break;
case 'l':
lashup_flag = 1;
break;
case 'h':
usage();
exit(0);
default:
usage();
exit(1);
}
}
argc -= optind;
argv += optind;
if (argc > 0) {
usage();
exit(1);
}
if (lashup_flag)
lashup_init(lashup_port);
tv_init();
tv_poll();
disk_init(disk_filename);
read_prom_files();
read_sym_files();
iob_init();
chaos_init();
ether_init();
if (warm_boot_flag)
kbd_warm_boot_key();
while (run())
tv_poll();
exit(0);
}