changeset 2535:5f76cf36e5c5

Clean up SupeRES decoder loop a bit.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 23 Jul 2020 03:38:31 +0300
parents 78ece6187a7c
children fa826ee09b33
files tools/lib64fmts.c
diffstat 1 files changed, 40 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64fmts.c	Sun Jul 12 01:01:37 2020 +0300
+++ b/tools/lib64fmts.c	Thu Jul 23 03:38:31 2020 +0300
@@ -136,52 +136,49 @@
     Uint8 tmp;
     int res;
 
-lcont:
-
-    if ((res = fmtSupeResGetByte(ctx, &tmp, 1)) != DMERR_OK)
-        goto out;
-
-    if (tmp == 0x21)
-    {
-        // ????
-        ctx->offs = 0xffff;
-        goto out;
-    }
-    else
-    if (tmp == 0x20)
+    do
     {
-        if ((res = fmtSupeResGetByte(ctx, &tmp, 2)) != DMERR_OK)
-            goto out;
-
-        ctx->repcount = tmp - 0x26;
-
-        if ((res = fmtSupeResGetByte(ctx, &tmp, 3)) != DMERR_OK ||
-            (res = fmtDecodeSupeRes24_25(ctx, tmp)) != DMERR_OK)
-            goto out;
-
-        for (int cnt = 0; cnt < ctx->repcount; cnt++)
+        if ((res = fmtSupeResGetByte(ctx, &tmp, 1)) != DMERR_OK)
+            break;
+
+        if (tmp == 0x21)
         {
-            ctx->dstBuf[ctx->offs++] = ctx->dbyte;
-            if (ctx->offs >= ctx->end_offs)
-                goto out;
+            // ????
+            ctx->offs = 0xffff;
+            break;
         }
-
-        if (ctx->offs < ctx->end_offs)
-            goto lcont;
-
-        ctx->offs--;
-
-        goto out;
-    }
-    else
-    {
-        res = fmtDecodeSupeRes24_25(ctx, tmp);
-        goto out;
-    }
-
-    goto lcont;
-
-out:
+        else
+        if (tmp == 0x20)
+        {
+            if ((res = fmtSupeResGetByte(ctx, &tmp, 2)) != DMERR_OK)
+                break;
+
+            ctx->repcount = tmp - 0x26;
+
+            if ((res = fmtSupeResGetByte(ctx, &tmp, 3)) != DMERR_OK ||
+                (res = fmtDecodeSupeRes24_25(ctx, tmp)) != DMERR_OK)
+                break;
+
+            for (int cnt = 0; cnt < ctx->repcount; cnt++)
+            {
+                ctx->dstBuf[ctx->offs++] = ctx->dbyte;
+                if (ctx->offs >= ctx->end_offs)
+                    break;
+            }
+
+            if (ctx->offs >= ctx->end_offs)
+            {
+                ctx->offs--;
+                break;
+            }
+        }
+        else
+        {
+            res = fmtDecodeSupeRes24_25(ctx, tmp);
+            break;
+        }
+    } while (1);
+
     return res;
 }