consolidated log message callbacks
[dcpu16] / hw_lem1802.c
index 0b95d1180530d885e533a05b48a8d960d5d8ac0d..1ae7b57d049452da312165b70444d0fd41ba5ec8 100644 (file)
@@ -38,7 +38,7 @@
 #define VOIDFP(__x__) (__x__)
 #endif
 
-#define LEM1802_POWER_ON_CYCLES 100000 /* this should vary by, let us say, 10% */
+#define LEM1802_POWER_ON_CYCLES 100000 /* 'about one second' */
 
 #define PIX_X 160       /* pixels in display */
 #define PIX_Y 128       /* pixels in display */
@@ -72,7 +72,7 @@ struct pixel_ {
     unsigned char r;
     unsigned char g;
     unsigned char b;
-    unsigned char a;
+    unsigned char a; /* unused */
 };
 
 struct lem1802_ {
@@ -111,6 +111,7 @@ long long power_on_cycles_(void) {
 
 #if WANT_DELAY_START
     gettimeofday(&tv, NULL);
+    /* consider the 'about' in 'about one second' to be +/- 10% */
     r += LEM1802_POWER_ON_CYCLES - (LEM1802_POWER_ON_CYCLES / 10);
     r += tv.tv_usec % (LEM1802_POWER_ON_CYCLES / 5);
 #endif
@@ -139,7 +140,7 @@ static
 void pixbuf_border_paint_(struct pixel_ *pixbuf, struct pixel_ *border) {
     size_t x, y, i;
 
-    TRACE("%s>> painted border", __func__);
+    TRACE("%s>> painting border", __func__);
 
     /* top */
     for (y = 0; y < PIX_BORDER; y++) {
@@ -353,6 +354,8 @@ int pixbuf_render_vnc_(void *data, struct pixel_ *pixbuf, size_t x, size_t y) {
 
     (void)pixbuf;
 
+    TRACE("%s>> s:%p", __func__, s);
+
     /* derp */
     if (s)
         rfbMarkRectAsModified(s, 0, 0, x, y);
@@ -385,7 +388,7 @@ void lem1802_reset_(struct dcpu16 *vm, struct dcpu16_hw *hw) {
     display->cycle_state_ = 0;
 
 #if DEBUG
-    vm->trace_cb_("%s>>", __func__);
+    vm->msg_cb_(MSG_DEBUG, "%s>>", __func__);
 #endif /* DEBUG */
 }
 
@@ -536,13 +539,13 @@ int lem1802_data_init_(struct dcpu16_hw *hw, void *data) {
 
     hw->data = calloc(1, sizeof(struct lem1802_));
     if (hw->data == NULL) {
-        hw->vm->warn_cb_("%s():%s", "calloc", strerror(errno));
+        hw->vm->msg_cb_(MSG_ERROR, "%s():%s", "calloc", strerror(errno));
         return -1;
     }
 
     ((struct lem1802_ *)(hw->data))->pixbuf = calloc(PIX_X * PIX_Y, sizeof *((struct lem1802_ *)(hw->data))->pixbuf);
     if (((struct lem1802_ *)(hw->data))->pixbuf == NULL) {
-        hw->vm->warn_cb_("%s():%s", "calloc", strerror(errno));
+        hw->vm->msg_cb_(MSG_ERROR, "%s():%s", "calloc", strerror(errno));
         free(hw->data);
         hw->data = NULL;
         return -1;
@@ -672,7 +675,7 @@ int lem1802_data_ctl_(struct dcpu16_hw *hw, const char *cmd, void *data_in, void
             }
         }
 
-        hw->vm->warn_cb_("unknown renderer '%s'", renderer);
+        hw->vm->msg_cb_(MSG_ERROR, "unknown renderer '%s'", renderer);
 
         return -ENOENT;
     }