running_ = 1;
gettimeofday(&run_start_tv, NULL);
- run_cycle_start = vm->cycle;
+ run_cycle_start = vm->cycle_;
memset(&act, 0, sizeof act);
act.sa_handler = sigint_handler_;
while (running_) {
gettimeofday(&start_tv, NULL);
- cycle_start = vm->cycle;
+ cycle_start = vm->cycle_;
dcpu16_step(vm);
if (opt_.verbose > 1)
}
/* how many cycles did this instr use? */
- cycles_to_wait = vm->cycle - cycle_start;
+ cycles_to_wait = vm->cycle_ - cycle_start;
if (cycles_to_wait == 0)
continue;
run_usec = diff_tv.tv_sec * 1000000;
run_usec += diff_tv.tv_usec;
fprintf(stderr, "ran %llu cycles in %lds %dus (%lldus)\n",
- vm->cycle - run_cycle_start,
+ vm->cycle_ - run_cycle_start,
diff_tv.tv_sec,
diff_tv.tv_usec,
run_usec);
if (arg_count == 3)
renderer_arg = arg_vector[2];
- hw = lem1802_new(vm);
+ hw = dcpu16_hw_new(vm, &dcpu16_hw_module_lem1802, NULL);
if (hw == NULL) {
fprintf(stderr, "failed to initialize new display\n");
return 0;
/* handle per-renderer setup of data.. */
/* FIXME: these are awkward */
if (strcmp(renderer, "pnm") == 0) {
- if (renderer_arg == NULL)
- renderer_arg = display_filename_default_;
- renderer_data = (void *)renderer_arg;
+ renderer_data = (void *)(renderer_arg ? renderer_arg : display_filename_default_);
}
#ifdef HAVE_LIBPNG
if (strcmp(renderer, "png") == 0) {
- if (renderer_arg == NULL)
- renderer_arg = display_filename_default_;
- renderer_data = (void *)renderer_arg;
+ renderer_data = (void *)(renderer_arg ? renderer_arg : display_filename_default_);
}
#endif /* HAVE_LIBPNG */
s = rfbScreen_next_available_display_(&rfbScreens_, argc, argv);
if (s == NULL) {
fprintf(stderr, "failed to initialize vnc\n");
- lem1802_del(&hw);
+ dcpu16_hw_del(&hw);
return 0;
}
- lem1802_vnc_associate(hw, s->screen);
+ if (dcpu16_hw_ctl(hw, "associate_rfbScreen", s->screen, NULL)) {
+ fprintf(stderr, "failed to configure display/vnc");
+ dcpu16_hw_del(&hw);
+ return 0;
+ }
s->attached_display = hw;
rfbScreen_start(s->screen);
renderer_data = s->screen;
}
#endif /* HAVE_LIBVNCSERVER */
- if (lem1802_renderer_set(hw, renderer, renderer_data)) {
- fprintf(stderr, "failed to set back-end renderer for display\n");
- lem1802_del(&hw);
- return 0;
- }
+ dcpu16_hw_ctl(hw, "renderer", (char *)renderer, NULL);
+ dcpu16_hw_ctl(hw, "renderer_data", renderer_data, NULL);
- if (dcpu16_hw_add(vm, hw)) {
+ if (dcpu16_hw_attach(vm, hw)) {
fprintf(stderr, "failed to attach new display\n");
- lem1802_del(&hw);
+ dcpu16_hw_del(&hw);
return 0;
}
return 0;
}
COMMAND_HELP(display) {
+ struct renderer_ {
+ char *name;
+ char *args;
+ int (*renderer)(void *, void *, size_t, size_t);
+ } *r;
char *name, *args;
void *iter;
);
fprintf(f, "Supported renderers:\n");
+
+ if (dcpu16_hw_module_lem1802.ctl(NULL, "get_renderers", NULL, &r)) {
+ fprintf(stderr, "error fetching list of renderers\n");
+ return;
+ }
+
+ while (r->name) {
+ fprintf(f, "name:%s args:%s\n", r->name, r->args);
+ }
+
iter = NULL;
while ( (lem1802_renderers_iter(&iter, &name, &args)) ) {
fprintf(f, "\t%s %s\n", name, args);
(void)arg_count, (void)arg_vector;
- hw = keyboard_new(vm);
+ hw = dcpu16_hw_new(vm, &dcpu16_hw_module_keyboard, NULL);
if (hw == NULL) {
fprintf(stderr, "failed to initialize new keyboard\n");
return 0;
s = rfbScreen_next_available_keyboard_(&rfbScreens_, argc, argv);
if (s == NULL) {
fprintf(stderr, "failed to initialize vnc\n");
- keyboard_del(&hw);
+ dcpu16_hw_del(&hw);
+ return 0;
+ }
+ if (dcpu16_hw_ctl(hw, "associate_rfbScreen", s->screen, NULL)) {
+ fprintf(stderr, "failed to configure keyboard/vnc\n");
+ dcpu16_hw_del(&hw);
return 0;
}
- keyboard_vnc_associate(hw, s->screen);
s->attached_keyboard = hw;
- if (dcpu16_hw_add(vm, hw)) {
+ if (dcpu16_hw_attach(vm, hw)) {
fprintf(stderr, "failed to attach new keyboard\n");
- keyboard_del(&hw);
+ dcpu16_hw_del(&hw);
return 0;
}
#endif /* HAVE_LIBVNCSERVER */