changeset 811:aebc2f8b2c2d

Add some comments.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 16 May 2014 03:01:51 +0300
parents cbe263ad963c
children 1e5cf1144f36
files lib64gfx.c
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lib64gfx.c	Thu May 15 02:05:53 2014 +0300
+++ b/lib64gfx.c	Fri May 16 03:01:51 2014 +0300
@@ -562,11 +562,14 @@
         size_t size;
         int res;
 
+        // Check operation validity
         if ((res = dmC64SanityCheckEncDecOp(i, op)) != DMERR_OK)
             return res;
         
+        // Check size
         size = (op->size == 0) ? dmC64DefaultSizes[op->type] : op->size;
-        
+
+        // Do we need to reallocate some more space?
         if (op->offs + size > len)
         {
             dmError("Decode out of bounds, op #%d type=%d, offs=%d ($%04x), "
@@ -574,9 +577,10 @@
                 i, op->type, op->offs, op->offs, op->bank, size, size, len, len);
             return DMERR_INVALID_DATA;
         }
-        
+
         src = buf + op->offs;
-        
+
+        // Perform operation
         switch (op->type)
         {
             case DT_COLOR_RAM:   memcpy(img->color[op->bank], src, size); break;
@@ -638,11 +642,14 @@
         Uint8 *dst = 2 + buf + op->offs;
         size_t size;
 
+        // Check operation validity
         if ((res = dmC64SanityCheckEncDecOp(i, op)) != DMERR_OK)
             goto error;
 
+        // Check size
         size = (op->size == 0) ? dmC64DefaultSizes[op->type] : op->size;
 
+        // Do we need to reallocate some more space?
         if (2 + op->offs + size > allocated)
         {
             if ((buf = dmRealloc(buf, allocated)) == NULL)
@@ -660,6 +667,7 @@
         if (fmt->size == 0 && op->offs + size + 2 > *plen)
             *plen = op->offs + size + 2;
 
+        // Perform operation
         switch (op->type)
         {
             case DT_COLOR_RAM:   memcpy(dst, img->color[op->bank], size); break;
@@ -723,6 +731,7 @@
 
         if ((src->type & D64_FMT_MC) == D64_FMT_HIRES)
         {
+            // Hi-res bitmap
             for (xc = 0; xc < dst->width; xc++)
             {
                 const int x = xc / 8;
@@ -738,6 +747,7 @@
         }
         else
         {
+            // Multicolor variants
             const int
                 wdivisor = doubleMC ? 2 : 1,
                 divisor  = doubleMC ? 4 : 8;