changeset 1645:262300a0359b

Add helper functions dmReverse{Get,Put}Byte().
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 30 May 2018 00:57:21 +0300
parents 9d9a0e852b3d
children 415c732dc14c
files tools/lib64gfx.c tools/lib64gfx.h
diffstat 2 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Wed May 30 00:56:32 2018 +0300
+++ b/tools/lib64gfx.c	Wed May 30 00:57:21 2018 +0300
@@ -100,6 +100,30 @@
 }
 
 
+BOOL dmReverseGetByte(const Uint8 *buf, size_t *offs, Uint8 *data)
+{
+    if (*offs > 0)
+    {
+        *data = buf[--(*offs)];
+        return TRUE;
+    }
+    else
+        return FALSE;
+}
+
+
+BOOL dmReversePutByte(Uint8 *buf, size_t *offs, const Uint8 data)
+{
+    if (*offs > 0)
+    {
+        buf[--(*offs)] = data;
+        return TRUE;
+    }
+    else
+        return FALSE;
+}
+
+
 int dmC64MemBlockAlloc(DMC64MemBlock *blk, const size_t size)
 {
     if ((blk->data = dmMalloc0(size)) == NULL)
--- a/tools/lib64gfx.h	Wed May 30 00:56:32 2018 +0300
+++ b/tools/lib64gfx.h	Wed May 30 00:57:21 2018 +0300
@@ -234,6 +234,8 @@
 void      dmSetDefaultC64Palette(DMImage *img);
 BOOL      dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr);
 int       dmC64ImageGetNumBanks(const DMC64ImageFormat *fmt);
+BOOL      dmReverseGetByte(const Uint8 *buf, size_t *offs, Uint8 *data);
+BOOL      dmReversePutByte(Uint8 *buf, size_t *offs, const Uint8 data);
 
 // C64 bitmap image allocation/freeing
 int       dmC64MemBlockAlloc(DMC64MemBlock *blk, const size_t size);