comparison lib64gfx.c @ 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
comparison
equal deleted inserted replaced
534:fbfdc9e4fe2b 535:ab8d9696225c
55 1, 55 1,
56 C64_SCR_EXTRADATA, 56 C64_SCR_EXTRADATA,
57 }; 57 };
58 58
59 59
60 #define DM_GET_ADDR_LO(addr) (addr & 0xff)
61 #define DM_GET_ADDR_HI(addr) ((addr >> 8) & 0xff)
62
60 63
61 static BOOL dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr) 64 static BOOL dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr)
62 { 65 {
63 return (buf[offs] == (addr & 0xff)) && (buf[offs + 1] == ((addr >> 8) & 0xff)); 66 return buf[offs] == DM_GET_ADDR_LO(addr) &&
67 buf[offs + 1] == DM_GET_ADDR_HI(addr);
64 } 68 }
65 69
66 70
67 int dmC64ConvertCSData(DMImage *img, 71 int dmC64ConvertCSData(DMImage *img,
68 int xoffs, int yoffs, const Uint8 *buf, 72 int xoffs, int yoffs, const Uint8 *buf,
666 case DT_ENC_FUNCTION: 670 case DT_ENC_FUNCTION:
667 break; 671 break;
668 } 672 }
669 } 673 }
670 674
675 buf[0] = DM_GET_ADDR_LO(fmt->addr);
676 buf[1] = DM_GET_ADDR_HI(fmt->addr);
677
678 *pbuf = buf;
671 return DMERR_OK; 679 return DMERR_OK;
672 680
673 error: 681 error:
674 dmFree(*pbuf); 682 dmFree(*pbuf);
675 *pbuf = NULL; 683 *pbuf = NULL;