X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=vm-dcpu16.c;h=b8a35327b0721bc75961fa86a3746ac227b7a3e5;hb=8b552fe61db48874f043bccfb589e5444509444c;hp=a463f7ac94858856c5a6e6a2697f44b44811f44f;hpb=a9cc197dc14d237e6bcea74591b81688de81ad66;p=dcpu16 diff --git a/vm-dcpu16.c b/vm-dcpu16.c index a463f7a..b8a3532 100644 --- a/vm-dcpu16.c +++ b/vm-dcpu16.c @@ -447,7 +447,7 @@ COMMAND_IMPL(run) { 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_; @@ -460,7 +460,7 @@ COMMAND_IMPL(run) { while (running_) { gettimeofday(&start_tv, NULL); - cycle_start = vm->cycle; + cycle_start = vm->cycle_; dcpu16_step(vm); if (opt_.verbose > 1) @@ -471,7 +471,7 @@ COMMAND_IMPL(run) { } /* 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; @@ -500,7 +500,7 @@ COMMAND_IMPL(run) { 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); @@ -533,7 +533,7 @@ COMMAND_IMPL(display) { 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; @@ -542,16 +542,12 @@ COMMAND_IMPL(display) { /* 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 */ @@ -564,7 +560,7 @@ COMMAND_IMPL(display) { 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; } @@ -577,13 +573,13 @@ COMMAND_IMPL(display) { if (lem1802_renderer_set(hw, renderer, renderer_data)) { fprintf(stderr, "failed to set back-end renderer for display\n"); - lem1802_del(&hw); + dcpu16_hw_del(&hw); return 0; } - 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; } @@ -611,7 +607,7 @@ COMMAND_IMPL(keyboard) { (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; @@ -625,15 +621,15 @@ COMMAND_IMPL(keyboard) { 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; } 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 */