|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2018 [email protected]
4: //
5:
6: #include "header.h"
7: #include "mainapp.h"
8: #include "mpu.h"
9: #include "pluto.h"
10: #include "rtc.h"
11: #include "vm.h"
12:
13: // wxApp と相似にするためのクラス
14: class CLIApp
15: {
16: public:
17: bool OnInit();
18: bool Parse();
19: void OnCreate();
20:
21: int ac;
22: char **av;
23: };
24:
25: // コマンドラインオプションとか
26: const char *human68k_file = NULL;
27: char human68k_arg[256];
28:
29: void
30: usage()
31: {
32: printf("%s [<options>]\n", getprogname());
33: printf(" -b <addr> break point\n");
34: printf(" -B <rom#> benchmark mode\n");
35: printf(" -c <dir> vm directory\n");
36: printf(" -d debugger prompt on startup\n");
37: printf(" -f fast mode\n");
38: printf(" -L <name>=<loglevel> loglevel (-L help displays names)\n");
39: printf(" -X <human68k executable> human68k console emulation\n");
40: printf(" -v version\n");
41: }
42:
43: int
44: main(int ac, char *av[])
45: {
46: CLIApp *app = new CLIApp();
47:
48: // wxApp とよく似せるため
49: app->ac = ac;
50: app->av = av;
51: if (app->OnInit()) {
52: return 1;
53: }
54: return 0;
55: }
56:
57: // ここがエントリポイント(のつもり)
58: bool
59: CLIApp::OnInit()
60: {
61: debug_breakaddr = 0xffffffff;
62: vmdir = ".";
63:
64: if (!Parse()) {
65: return false;
66: }
67:
68: // CLI 版では常にコンソールに(も)ログを出力
69: if (!main_init<true>(true)) {
70: return false;
71: }
72:
73: // メインウィンドウに相当するところ
74: OnCreate();
75:
76: return true;
77: }
78:
79: // 引数をパースする。
80: // 知らない引数とかがあればこちらで usage を表示して false を返す。
81: bool
82: CLIApp::Parse()
83: {
84: int b;
85: int c;
86:
87: while ((c = getopt(ac, av, "b:B:c:dfL:X:v")) != -1) {
88: switch (c) {
89: case 'b':
90: debug_breakaddr = (uint32)strtoul(optarg, NULL, 16);
91: break;
92:
93: case 'B':
94: b = atoi(optarg);
95: if (b < 2 || b > 6) {
96: fprintf(stderr, "-B <benchmark_mode>: 2..6\n");
97: return false;
98: }
99: PlutoDevice::benchmark_mode = b;
100: break;
101:
102: case 'c':
103: vmdir = std::string(optarg);
104: break;
105:
106: case 'd':
107: debug_on_start = true;
108: break;
109:
110: case 'f':
111: fast_mode = true;
112: break;
113:
114: case 'L':
115: if (logopt[0] != '\0') {
116: strlcat(logopt, ",", sizeof(logopt));
117: }
118: strlcat(logopt, optarg, sizeof(logopt));
119: break;
120:
121: case 'X':
122: human68k_file = optarg;
123: for (int i = optind; i < ac; i++) {
124: if (i != optind) {
125: strlcat(human68k_arg, " ", sizeof(human68k_arg));
126: }
127: strlcat(human68k_arg, av[i], sizeof(human68k_arg));
128: }
129: optind = ac;
130: break;
131:
132: case 'v':
133: fprintf(stderr, "nono-cli version %d.%d.%d\n",
134: NONO_MAJOR_VER, NONO_MINOR_VER, NONO_PATCH_VER);
135: exit(0);
136:
137: default:
138: usage();
139: return false;
140: }
141: }
142:
143: return true;
144: }
145:
146: // メインウィンドウ作成後のイベントに相当するところ
147: void
148: CLIApp::OnCreate()
149: {
150: // 時刻開始?
151: // なるべく VM が開始する直前にしたい。
152: gRTC->InitRTC();
153:
154: // VM 実行開始
155: gVM->PowerButton();
156:
157: // ?
158: for (;;) {
159: sleep(1);
160: }
161: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.