# HG changeset patch # User Matti Hamalainen # Date 1595464711 -10800 # Node ID 5f76cf36e5c56ff2388c3b7b1168b079bd7d0fbe # Parent 78ece6187a7cdccbf3c3047d3c7ab8412b19f873 Clean up SupeRES decoder loop a bit. diff -r 78ece6187a7c -r 5f76cf36e5c5 tools/lib64fmts.c --- 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; }