(svn r2571) Add explicit type Pixel for ... Pixels
authortron
Fri, 15 Jul 2005 14:16:14 +0000
changeset 2062 00f7d339fdcb
parent 2061 f67a12c65223
child 2063 95259a31ceb5
(svn r2571) Add explicit type Pixel for ... Pixels
gfx.c
gfx.h
screenshot.c
smallmap_gui.c
texteff.c
win32.c
--- a/gfx.c	Fri Jul 15 12:16:16 2005 +0000
+++ b/gfx.c	Fri Jul 15 14:16:14 2005 +0000
@@ -11,7 +11,7 @@
 static void GfxMainBlitter(const Sprite *sprite, int x, int y, int mode);
 
 static int _stringwidth_out;
-static byte _cursor_backup[64*64];
+static Pixel _cursor_backup[64 * 64];
 static Rect _invalid_rect;
 static const byte *_color_remap_ptr;
 static byte _string_colorremap[3];
@@ -37,8 +37,8 @@
 
 void GfxScroll(int left, int top, int width, int height, int xo, int yo)
 {
-	byte *src;
-	byte *dst;
+	const Pixel *src;
+	Pixel *dst;
 	int p;
 	int ht;
 
@@ -109,7 +109,7 @@
 void GfxFillRect(int left, int top, int right, int bottom, int color)
 {
 	DrawPixelInfo *dpi = _cur_dpi;
-	byte *dst;
+	Pixel *dst;
 	const int otop = top;
 	const int oleft = left;
 
@@ -574,7 +574,7 @@
 	int start_x, start_y;
 	const byte* sprite;
 	const byte* sprite_org;
-	byte *dst;
+	Pixel *dst;
 	int mode;
 	int width, height;
 	int width_org;
@@ -589,7 +589,7 @@
 	const byte* src;
 	int num, skip;
 	byte done;
-	byte *dst;
+	Pixel *dst;
 	const byte* ctab;
 
 	if (bp->mode & 1) {
@@ -718,7 +718,7 @@
 static void GfxBlitZoomInUncomp(BlitterParams *bp)
 {
 	const byte *src = bp->sprite;
-	byte *dst = bp->dst;
+	Pixel *dst = bp->dst;
 	int height = bp->height;
 	int width = bp->width;
 	int i;
@@ -791,7 +791,7 @@
 	const byte* src;
 	int num, skip;
 	byte done;
-	byte *dst;
+	Pixel *dst;
 	const byte* ctab;
 
 	if (bp->mode & 1) {
@@ -945,7 +945,7 @@
 static void GfxBlitZoomMediumUncomp(BlitterParams *bp)
 {
 	const byte *src = bp->sprite;
-	byte *dst = bp->dst;
+	Pixel *dst = bp->dst;
 	int height = bp->height;
 	int width = bp->width;
 	int i;
@@ -996,7 +996,7 @@
 	const byte* src;
 	int num, skip;
 	byte done;
-	byte *dst;
+	Pixel *dst;
 	const byte* ctab;
 
 	if (bp->mode & 1) {
@@ -1209,7 +1209,7 @@
 static void GfxBlitZoomOutUncomp(BlitterParams *bp)
 {
 	const byte* src = bp->sprite;
-	byte *dst = bp->dst;
+	Pixel *dst = bp->dst;
 	int height = bp->height;
 	int width = bp->width;
 	int i;
--- a/gfx.h	Fri Jul 15 12:16:16 2005 +0000
+++ b/gfx.h	Fri Jul 15 14:16:14 2005 +0000
@@ -1,6 +1,7 @@
 #ifndef GFX_H
 #define GFX_H
 
+typedef byte Pixel;
 
 typedef struct ColorList {
 	byte unk0, unk1, unk2;
@@ -10,7 +11,7 @@
 } ColorList;
 
 struct DrawPixelInfo {
-	byte *dst_ptr;
+	Pixel *dst_ptr;
 	int left, top, width, height;
 	int pitch;
 	uint16 zoom;
--- a/screenshot.c	Fri Jul 15 12:16:16 2005 +0000
+++ b/screenshot.c	Fri Jul 15 14:16:14 2005 +0000
@@ -57,7 +57,7 @@
 	BitmapFileHeader bfh;
 	BitmapInfoHeader bih;
 	RgbQuad rq[256];
-	byte *buff;
+	Pixel *buff;
 	FILE *f;
 	uint i, padw;
 	uint n, maxlines;
@@ -159,7 +159,7 @@
 static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
 {
 	png_color rq[256];
-	byte *buff;
+	Pixel *buff;
 	FILE *f;
 	uint i, y, n;
 	uint maxlines;
@@ -272,7 +272,7 @@
 
 static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
 {
-	byte *buff;
+	Pixel *buff;
 	FILE *f;
 	uint maxlines;
 	uint y;
@@ -330,14 +330,14 @@
 
 		// write them to pcx
 		for (i = 0; i != n; i++) {
-			const byte* bufp = buff + i * w;
+			const Pixel* bufp = buff + i * w;
 			byte runchar = bufp[0];
 			uint runcount = 1;
 			uint j;
 
 			// for each pixel...
 			for (j = 1; j < w; j++) {
-				byte ch = bufp[j];
+				Pixel ch = bufp[j];
 
 				if (ch != runchar || runcount >= 0x3f) {
 					if (runcount > 1 || (runchar & 0xC0) == 0xC0)
@@ -426,7 +426,7 @@
 }
 
 // screenshot generator that dumps the current video buffer
-static void CurrentScreenCallback(void *userdata, byte *buf, uint y, uint pitch, uint n)
+static void CurrentScreenCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n)
 {
 	for (; n > 0; --n) {
 		memcpy(buf, _screen.dst_ptr + y * _screen.pitch, _screen.width);
@@ -436,7 +436,7 @@
 }
 
 // generate a large piece of the world
-static void LargeWorldCallback(void *userdata, byte *buf, uint y, uint pitch, uint n)
+static void LargeWorldCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n)
 {
 	ViewPort *vp = (ViewPort *)userdata;
 	DrawPixelInfo dpi, *old_dpi;
--- a/smallmap_gui.c	Fri Jul 15 12:16:16 2005 +0000
+++ b/smallmap_gui.c	Fri Jul 15 14:16:14 2005 +0000
@@ -190,9 +190,8 @@
 };
 
 #if defined(TTD_ALIGNMENT_4)
-	static inline void WRITE_PIXELS(void *dst, uint32 val)
+	static inline void WRITE_PIXELS(Pixel* d, uint32 val)
 	{
-		byte *d = (byte*)dst;
 #	if defined(TTD_BIG_ENDIAN)
 		d[0] = (byte)(val >> 24);
 		d[1] = (byte)(val >> 16);
@@ -207,9 +206,8 @@
 	}
 
 /* need to use OR, otherwise we will overwrite the wrong pixels at the edges :( */
-	static inline void WRITE_PIXELS_OR(void *dst, uint32 val)
+	static inline void WRITE_PIXELS_OR(Pixel* d, uint32 val)
 	{
-		byte *d = (byte*)dst;
 #	if defined(TTD_BIG_ENDIAN)
 		d[0] |= (byte)(val >> 24);
 		d[1] |= (byte)(val >> 16);
@@ -324,9 +322,9 @@
  * @param proc Pointer to the colour function
  * @see GetSmallMapPixels(TileIndex)
  */
-static void DrawSmallMapStuff(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask, GetSmallMapPixels *proc)
+static void DrawSmallMapStuff(Pixel *dst, uint xc, uint yc, int pitch, int reps, uint32 mask, GetSmallMapPixels *proc)
 {
-	byte *dst_ptr_end = _screen.dst_ptr + _screen.width * _screen.height - _screen.width;
+	Pixel *dst_ptr_end = _screen.dst_ptr + _screen.width * _screen.height - _screen.width;
 
 	do {
 		// check if the tile (xc,yc) is within the map range
@@ -589,7 +587,7 @@
 {
 	DrawPixelInfo *old_dpi;
 	int dx,dy, x, y, x2, y2;
-	byte *ptr;
+	Pixel *ptr;
 	int tile_x;
 	int tile_y;
 	ViewPort *vp;
--- a/texteff.c	Fri Jul 15 12:16:16 2005 +0000
+++ b/texteff.c	Fri Jul 15 14:16:14 2005 +0000
@@ -43,7 +43,7 @@
 const int _textmessage_box_bottom = 30; // Pixels from bottom
 const int _textmessage_box_max_width = 400; // Max width of box
 
-static byte _textmessage_backup[150*400]; // (y * max_width)
+static Pixel _textmessage_backup[150 * 400]; // (y * max_width)
 
 extern void memcpy_pitch(void *d, void *s, int w, int h, int spitch, int dpitch);
 
--- a/win32.c	Fri Jul 15 12:16:16 2005 +0000
+++ b/win32.c	Fri Jul 15 14:16:14 2005 +0000
@@ -21,9 +21,9 @@
 static struct {
 	HWND main_wnd;
 	HBITMAP dib_sect;
-	void *bitmap_bits;
-	void *buffer_bits;
-	void *alloced_bits;
+	Pixel *bitmap_bits;
+	Pixel *buffer_bits;
+	Pixel *alloced_bits;
 	HPALETTE gdi_palette;
 	int width,height;
 	int width_org, height_org;
@@ -568,7 +568,7 @@
 		DeleteObject(_wnd.dib_sect);
 
 	dc = GetDC(0);
-	_wnd.dib_sect = CreateDIBSection(dc, bi, DIB_RGB_COLORS, &_wnd.bitmap_bits, NULL, 0);
+	_wnd.dib_sect = CreateDIBSection(dc, bi, DIB_RGB_COLORS, (void**)&_wnd.bitmap_bits, NULL, 0);
 	if (_wnd.dib_sect == NULL)
 		error("CreateDIBSection failed");
 	ReleaseDC(0, dc);
@@ -665,8 +665,8 @@
 static void filter(int left, int top, int width, int height)
 {
 	uint p = _screen.pitch;
-	byte *s = (byte*)_wnd.buffer_bits + top * p + left;
-	byte *d = (byte*)_wnd.bitmap_bits + top * p * 4 + left * 2;
+	const Pixel *s = _wnd.buffer_bits + top * p + left;
+	Pixel *d = _wnd.bitmap_bits + top * p * 4 + left * 2;
 
 	for (; height > 0; height--) {
 		int i;