X-Git-Url: http://git.squeep.com/?p=dcpu16;a=blobdiff_plain;f=vm-dcpu16.c;h=1e3a49656757f8e68cd90ebae13a12bd75018ed1;hp=537452af9af8f11066f00dd43aa0eb33961eb00d;hb=bca632cc1c329a45dde32f476b0ef9f6ef5db05a;hpb=9cf5993655d58da3c9f508ede3ac43a29e6cc6b5 diff --git a/vm-dcpu16.c b/vm-dcpu16.c index 537452a..1e3a496 100644 --- a/vm-dcpu16.c +++ b/vm-dcpu16.c @@ -12,6 +12,7 @@ #include "dcpu16.h" #include "common.h" +#include "display.h" /* * shell-like driver for dcpu16 core @@ -364,6 +365,45 @@ COMMAND_HELP(run) { "May be interrupted with SIGINT.\n"); } +COMMAND_IMPL(display) { + (void)arg_count, (void)arg_vector; + + static DPIX *pixbuf = NULL; + + if (pixbuf) { + printf("display already enabled..\n"); + return 0; + } + + pixbuf = display_init_pixbuf(); + if (pixbuf == NULL) { + fprintf(stderr, "failed to initialize display buffer\n"); + return 0; + } + + if (dcpu16_acct_add(vm, DCPU16_ACCT_EV_WRITE, display_fn, pixbuf)) { + fprintf(stderr, "failed to register display update callback\n"); + return 0; + } + + if (dcpu16_acct_add(vm, DCPU16_ACCT_EV_RESET, display_reset_fn, pixbuf)) { + fprintf(stderr, "failed to register display reset callback\n"); + return 0; + } + + /* init display as if reset occurred */ + display_reset_fn(vm, DCPU16_ACCT_EV_RESET, 0, pixbuf); + + return 0; +} +COMMAND_HELP(display) { + fprintf(f, "\tdisplay\n"); + if (summary) return; + + fprintf(f, "Begins updating a PNM of current display contents...\n" + "This is not a fully-baked feature...\n"); +} + /* gather all these together into a searchable table */ /* help command gets some assistance in declarations */ @@ -379,6 +419,7 @@ static struct command_ command_table_[] = { COMMAND_ENTRY(step, 0, 1), COMMAND_ENTRY(run, 0, 0), COMMAND_ENTRY(reset, 0, 0), + COMMAND_ENTRY(display, 0, 0), { NULL, 0, 0, NULL, NULL } };