changeset 2171:a39bf85308e5

Add helper function dmC64GetOpType() and use it to display operator type name instead of just number.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 11 Jun 2019 07:38:44 +0300
parents 7c4c9013e412
children de88333acc44
files tools/lib64gfx.c
diffstat 1 files changed, 30 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Tue Jun 11 07:37:56 2019 +0300
+++ b/tools/lib64gfx.c	Tue Jun 11 07:38:44 2019 +0300
@@ -903,6 +903,26 @@
 }
 
 
+const char *dmC64GetOpType(const int type)
+{
+    static const char *typeNames[DO_LAST] =
+    {
+        "COPY",
+        "SET_MEM",
+        "SET_OP",
+        "SET_MEM_HI",
+        "SET_MEM_LO",
+
+        "FUNC",
+        "CHAR_CFG",
+    };
+    if (type >= 0 && type < DO_LAST)
+        return typeNames[type];
+    else
+        return "ERROR";
+}
+
+
 const DMC64MemBlock * dmC64GetOpMemBlock(const DMC64Image *img, const int subject, const int bank)
 {
     if (bank >= 0 && bank < img->nbanks)
@@ -954,9 +974,9 @@
         if (op->type == DO_COPY && op->offs + size > buf->len + 1)
         {
             return dmError(DMERR_INVALID_DATA,
-                "Decode SRC out of bounds, op #%d type=%d, subj=%s, offs=%d ($%04x), "
+                "Decode SRC out of bounds, op #%d type=%s, subj=%s, offs=%d ($%04x), "
                 "bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
-                i, op->type, subjname, op->offs, op->offs, op->bank,
+                i, dmC64GetOpType(op->type), subjname, op->offs, op->offs, op->bank,
                 size, size, buf->len, buf->len);
         }
 
@@ -1011,9 +1031,9 @@
 
                             default:
                                 return dmError(DMERR_INTERNAL,
-                                    "Unhandled op type %d in "
+                                    "Unhandled op type %s in "
                                     "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
-                                    op->type, i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len);
+                                    dmC64GetOpType(op->type), i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len);
                         }
                         break;
 
@@ -1044,9 +1064,9 @@
 
                             default:
                                 return dmError(DMERR_INTERNAL,
-                                    "Unhandled op type %d in "
+                                    "Unhandled op type %s in "
                                     "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
-                                    op->type, i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len);
+                                    dmC64GetOpType(op->type), i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len);
                         }
                         switch (op->subject)
                         {
@@ -1213,9 +1233,9 @@
 
                             default:
                                 return dmError(DMERR_INTERNAL,
-                                    "Unhandled op type %d in "
+                                    "Unhandled op type %s in "
                                     "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
-                                    op->type, i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len);
+                                    dmC64GetOpType(op->type), i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len);
                         }
                         break;
 
@@ -1255,9 +1275,9 @@
 
                             default:
                                 return dmError(DMERR_INTERNAL,
-                                    "Unhandled op type %d in "
+                                    "Unhandled op type %s in "
                                     "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
-                                    op->type, i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len);
+                                    dmC64GetOpType(op->type), i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len);
                         }
                         break;