changeset 535:ab8d9696225c

Add helper macros and use them to set the loading address while encoding.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 22 Nov 2012 22:15:34 +0200
parents fbfdc9e4fe2b
children 18fc2890ba4b
files lib64gfx.c
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib64gfx.c	Thu Nov 22 21:09:15 2012 +0200
+++ b/lib64gfx.c	Thu Nov 22 22:15:34 2012 +0200
@@ -57,10 +57,14 @@
 };
 
 
+#define DM_GET_ADDR_LO(addr) (addr & 0xff)
+#define DM_GET_ADDR_HI(addr) ((addr >> 8) & 0xff)
+
 
 static BOOL dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr)
 {
-    return (buf[offs] == (addr & 0xff)) && (buf[offs + 1] == ((addr >> 8) & 0xff));
+    return buf[offs] == DM_GET_ADDR_LO(addr) &&
+           buf[offs + 1] == DM_GET_ADDR_HI(addr);
 }
 
 
@@ -668,6 +672,10 @@
         }
     }
 
+    buf[0] = DM_GET_ADDR_LO(fmt->addr);
+    buf[1] = DM_GET_ADDR_HI(fmt->addr);
+
+    *pbuf = buf;
     return DMERR_OK;
 
 error: