Fixes #106 Bring back --trace option

This commit is contained in:
Stefan Arentz 2016-12-28 16:40:16 -05:00
parent 2c2cea17dc
commit 917feaaab5
2 changed files with 18 additions and 3 deletions

View File

@ -180,10 +180,12 @@ static bool ewm_one_step_cpu(struct ewm_one_t *one, int cycles) {
#define EWM_ONE_OPT_MODEL (0)
#define EWM_ONE_OPT_MEMORY (1)
#define EWM_ONE_OPT_TRACE (2)
static struct option one_options[] = {
{ "model", required_argument, NULL, EWM_ONE_OPT_MODEL },
{ "model", required_argument, NULL, EWM_ONE_OPT_MODEL },
{ "memory", required_argument, NULL, EWM_ONE_OPT_MEMORY },
{ "trace", optional_argument, NULL, EWM_ONE_OPT_TRACE },
{ NULL, 0, NULL, 0 }
};
@ -191,6 +193,7 @@ int ewm_one_main(int argc, char **argv) {
// Parse Apple 1 specific options
int model = EWM_ONE_MODEL_DEFAULT;
struct ewm_memory_option_t *extra_memory = NULL;
char *trace_path = NULL;
int ch;
while ((ch = getopt_long_only(argc, argv, "", one_options, NULL)) != -1) {
@ -215,11 +218,13 @@ int ewm_one_main(int argc, char **argv) {
extra_memory = m;
break;
}
case EWM_ONE_OPT_TRACE: {
trace_path = optarg ? optarg : "/dev/stderr";
break;
}
}
}
// Setup SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_EVENTS) < 0) {
@ -257,6 +262,8 @@ int ewm_one_main(int argc, char **argv) {
}
}
cpu_trace(one->cpu, trace_path);
cpu_reset(one->cpu);
// Main loop

View File

@ -497,6 +497,7 @@ static bool ewm_two_step_cpu(struct ewm_two_t *two, int cycles) {
#define EWM_TWO_OPT_COLOR (2)
#define EWM_TWO_OPT_FPS (3)
#define EWM_TWO_OPT_MEMORY (4)
#define EWM_TWO_OPT_TRACE (5)
static struct option one_options[] = {
{ "drive1", required_argument, NULL, EWM_TWO_OPT_DRIVE1 },
@ -504,6 +505,7 @@ static struct option one_options[] = {
{ "color", no_argument, NULL, EWM_TWO_OPT_COLOR },
{ "fps", required_argument, NULL, EWM_TWO_OPT_FPS },
{ "memory", required_argument, NULL, EWM_TWO_OPT_MEMORY },
{ "trace", optional_argument, NULL, EWM_TWO_OPT_TRACE },
{ NULL, 0, NULL, 0 }
};
@ -515,6 +517,7 @@ int ewm_two_main(int argc, char **argv) {
bool color = false;
uint32_t fps = EWM_TWO_FPS_DEFAULT;
struct ewm_memory_option_t *extra_memory = NULL;
char *trace_path = NULL;
int ch;
while ((ch = getopt_long_only(argc, argv, "", one_options, NULL)) != -1) {
@ -540,6 +543,9 @@ int ewm_two_main(int argc, char **argv) {
extra_memory = m;
break;
}
case EWM_TWO_OPT_TRACE:
trace_path = optarg ? optarg : "/dev/stderr";
break;
}
}
@ -605,6 +611,8 @@ int ewm_two_main(int argc, char **argv) {
}
}
cpu_trace(two->cpu, trace_path);
cpu_reset(two->cpu);
//