Mercurial > hg > dmlib
changeset 542:1f39c01e2895
Add loading address to the encoding functionality.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 22 Nov 2012 22:25:44 +0200 |
parents | 7ca6abbbbb40 |
children | 8fa705277207 |
files | lib64gfx.c |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/lib64gfx.c Thu Nov 22 22:24:57 2012 +0200 +++ b/lib64gfx.c Thu Nov 22 22:25:44 2012 +0200 @@ -635,7 +635,7 @@ for (i = 0; i < fmt->nencdecOps; i++) { const DMC64EncDecOp *op = &fmt->encdecOps[i]; - Uint8 *dst = buf + op->offs; + Uint8 *dst = 2 + buf + op->offs; size_t size; if ((res = dmC64SanityCheckEncDecOp(i, op)) != DMERR_OK) @@ -643,11 +643,11 @@ size = (op->size == 0) ? dmC64DefaultSizes[op->type] : op->size; - if (op->offs + size > allocated) + if (2 + op->offs + size > allocated) { if ((buf = dmRealloc(buf, allocated)) == NULL) { - size_t diff = allocated - (op->offs + size), + size_t diff = allocated - (op->offs + size + 2), grow = (diff / (BUF_SIZE_GROW - 1)) * BUF_SIZE_GROW; allocated = allocated + grow; dmError("Could not re-allocate %d bytes of memory for C64 image encoding buffer.\n", @@ -657,8 +657,8 @@ } } - if (fmt->size == 0 && op->offs + size > *plen) - *plen = op->offs + size; + if (fmt->size == 0 && op->offs + size + 2 > *plen) + *plen = op->offs + size + 2; switch (op->type) { @@ -672,6 +672,8 @@ } } + buf[0] = DM_GET_ADDR_LO(fmt->addr); + buf[1] = DM_GET_ADDR_HI(fmt->addr); return DMERR_OK; error: