diff tools/lib64gfx.h @ 1668:1741717b1ae5

Big overhaul to the enc/dec operator system to be more flexible.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 31 May 2018 00:04:01 +0300
parents 7555c8803529
children a0986cfd6f9d
line wrap: on
line diff
--- a/tools/lib64gfx.h	Wed May 30 21:10:57 2018 +0300
+++ b/tools/lib64gfx.h	Thu May 31 00:04:01 2018 +0300
@@ -79,22 +79,37 @@
 };
 
 
-typedef struct
+// Different enc/dec operation types (op->type)
+enum
 {
-    BOOL multicolor, xexpand, yexpand;
-    int color, xc, yc;
-    Uint8 data[C64_SPR_HEIGHT][C64_SPR_WIDTH];
-} DMC64Sprite;
+    DO_COPY,               // Perform copy between memory (from/to offset) and subject
+    DO_SET_MEM,            // Set subject value or fill subject memory area to byte value from offset
+    DO_SET_OP,             // Like above but value from op->offs field instead
+
+    DO_DEC_FUNC,           // Execute specified decoding function (only for decoding operations)
+    DO_ENC_FUNC,           // Same, but for encoding
+
+    DO_CHAR_CFG,           // Set character mode configuration
+
+    DO_LAST,               // Last opcode, end processing
+};
 
 
+// "Subjects" of operations (op->subject)
 enum
 {
-    DC_D020,
-    DC_BGCOL,
-    DC_D021,
-    DC_D022,
-    DC_D023,
-    DC_D024,
+    DS_COLOR_RAM,
+    DS_BITMAP_RAM,
+    DS_SCREEN_RAM,
+    DS_EXTRA_DATA,
+    DS_CHAR_DATA,
+
+    DS_D020,
+    DS_BGCOL,
+    DS_D021,
+    DS_D022,
+    DS_D023,
+    DS_D024,
 };
 
 
@@ -105,6 +120,14 @@
 } DMC64MemBlock;
 
 
+typedef struct
+{
+    BOOL multicolor, xexpand, yexpand;
+    int color, xc, yc;
+    Uint8 data[C64_SPR_HEIGHT][C64_SPR_WIDTH];
+} DMC64Sprite;
+
+
 typedef struct _DMC64Image
 {
     int type,       // Image type (D64_FMT_*)
@@ -137,36 +160,21 @@
     const DMC64Image *img, const int bmoffs, const int scroffs,
     const int vshift, const int vbitmap, const int raster);
 
-enum
-{
-    DT_COLOR_RAM,
-    DT_BITMAP_RAM,
-    DT_SCREEN_RAM,
-    DT_COLOR_REG,
-    DT_COLOR_SET,
-    DT_EXTRA_DATA,
-
-    DT_DEC_FUNCTION,
-    DT_ENC_FUNCTION,
-
-    DT_CHAR_DATA,
-    DT_CHAR_CONFIG,
-
-    DT_LAST,
-};
-
-
 #define D64_MAX_ENCDEC_OPS 64
 
 
 typedef struct _DMC64ImageFormat DMC64ImageFormat;
 
+
 typedef struct _DMC64EncDecOp
 {
-    int    type;
+    int    type;     // Operation type (DO_*)
+    int    subject;  // Operation "subject" (DS_*)
+
     size_t offs;
     int    bank;
     size_t size;
+
     BOOL   (*decFunction)(DMC64Image *img, const struct _DMC64EncDecOp *op, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt);
     BOOL   (*encFunction)(const struct _DMC64EncDecOp *op, DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt);
 } DMC64EncDecOp;