#define BUF_SZ 32
+#ifdef WANT_VARIADIC_VOIDP_CAST
+#define VOIDP(__x__) ((void *)(__x__))
+#else
+#define VOIDP(__x__) (__x__)
+#endif
+
static dcpu16_hw_signal_t keyboard_reset_;
static dcpu16_hw_signal_t keyboard_cycle_;
static dcpu16_hw_signal_t keyboard_hwi_;
keysym_rfbtodcpu(key, &dcpu_key);
- fprintf(stderr, "%s: down:%u key:0x%04x dcpu_key:0x%04x\n", __func__,
- down, key, dcpu_key);
+ fprintf(stderr, "%s: down:%u key:0x%04x dcpu_key:0x%04x\n",
+ __func__,
+ down,
+ key,
+ dcpu_key);
- fprintf(stderr, "%s: hw:%p name:%s vm:%p\n", __func__, hw, hw->name_, hw->vm);
+ fprintf(stderr, "%s: hw:%p name:%s vm:%p\n",
+ __func__,
+ VOIDP(hw),
+ hw->name_,
+ VOIDP(hw->vm));
keyboard->keys_pressed[dcpu_key] = (down ? 1 : 0);
if (down) {
void keyboard_del(struct dcpu16_hw **hw) {
if (hw) {
- free(((struct keyboard_ *)((*hw)->data))->buf);
- ((struct keyboard_ *)((*hw)->data))->buf = NULL;
-
- free((*hw)->data);
- (*hw)->data = NULL;
-
- free(*hw);
- *hw = NULL;
+ if (*hw) {
+ if ((*hw)->data) {
+ free(((struct keyboard_ *)((*hw)->data))->buf);
+ ((struct keyboard_ *)((*hw)->data))->buf = NULL;
+
+ free((*hw)->data);
+ (*hw)->data = NULL;
+ }
+ free(*hw);
+ *hw = NULL;
+ }
}
}
#define TRACE(...) do {} while (0)
#endif /* DEBUG */
+#ifdef WANT_VARIADIC_VOIDP_CAST
+#define VOIDP(__x__) ((void *)(__x__))
+#define VOIDFP(__x__) ((void *)(size_t)(__x__))
+#else
+#define VOIDP(__x__) (__x__)
+#define VOIDFP(__x__) (__x__)
+#endif
+
static dcpu16_hw_signal_t lem1802_reset_;
static dcpu16_hw_signal_t lem1802_cycle_;
static dcpu16_hw_signal_t lem1802_hwi_;
mem,
display->video_base,
display->video_base + tile,
- display->palette_base ? mem + display->palette_base : palette_default_,
- display->font_base ? mem + display->font_base : (unsigned short *)chargen_4x8_glyphs,
+ display->palette_base ? mem + display->palette_base : (DCPU16_WORD *)palette_default_,
+ display->font_base ? mem + display->font_base : (DCPU16_WORD *)chargen_4x8_glyphs,
display->blink_state);
}
}
s->httpDir = "../classes";
#endif
- TRACE("%s>> s:%p", __func__, s);
- TRACE("%s>> s->kbdAddEvent:%p s->frameBuffer:%p", __func__, s->kbdAddEvent, s->frameBuffer);
+ TRACE("%s>> s:%p", __func__, VOIDP(s));
+ TRACE("%s>> s->kbdAddEvent:%p s->frameBuffer:%p", __func__, VOIDFP(s->kbdAddEvent), s->frameBuffer);
return s;
}
s->desktopName = "NYA ELEKTRISKA LEM1802";
s->frameBuffer = (char *)display->pixbuf;
- TRACE("%s>> s:%p\n", __func__, s);
+ TRACE("%s>> s:%p\n", __func__, VOIDP(s));
}
/* notify rfb server that pixels may have changed */
TRACE("%s>> copy_to_ram words:%zu src:%p dst_addr:0x%04x",
__func__,
display->cycle_state_copy_words_,
- display->cycle_state_copy_src_ptr_,
+ VOIDP(display->cycle_state_copy_src_ptr_),
display->cycle_state_copy_dst_addr_);
vm->ram[display->cycle_state_copy_dst_addr_] = *display->cycle_state_copy_src_ptr_;
display->cycle_state_copy_dst_addr_++;
memcpy(hw, &hw_, sizeof *hw);
- hw->data = calloc(1, sizeof(struct dcpu16_hw));
+ hw->data = calloc(1, sizeof(struct lem1802_));
if (hw->data == NULL) {
vm->warn_cb_("%s():%s", "calloc", strerror(errno));
free(hw);
(*hw)->data = NULL;
}
free(*hw);
+ *hw = NULL;
}
- *hw = NULL;
}
}
break;
}
}
+
+struct dcpu16_hw *spc2000_new(struct dcpu16 *vm) {
+ struct dcpu16_hw *hw;
+
+ hw = calloc(1, sizeof *hw);
+ if (hw == NULL) {
+ vm->warn_cb_("%s():%s", "calloc", strerror(errno));
+ return NULL;
+ }
+
+ memcpy(hw, &hw_, sizeof *hw);
+
+ hw->data = calloc(1, sizeof(struct spc2000_));
+ if (hw->data == NULL) {
+ vm->warn_cb_("%s():%s", "calloc", strerror(errno));
+ free(hw);
+ return NULL;
+ }
+
+ hw->vm = vm;
+
+ return hw;
+}
+
+void spc2000_del(struct dcpu16_hw **hw) {
+ if (hw) {
+ if (*hw) {
+ if ((*hw)->data) {
+ free((*hw)->data);
+ (*hw)->data = NULL;
+ }
+ free(*hw);
+ *hw = NULL;
+ }
+ }
+}