# HG changeset patch # User truelight # Date 1179156050 0 # Node ID 269c76b5b987742828848dbe5827e6340b6f1fde # Parent 1f93361485448b829e1b70213d3fb4ddbd375755 (svn r9835) -Codechange: use Pixel typedef instead of byte where ever possible diff -r 1f9336148544 -r 269c76b5b987 src/gfx.cpp --- a/src/gfx.cpp Mon May 14 14:06:46 2007 +0000 +++ b/src/gfx.cpp Mon May 14 15:20:50 2007 +0000 @@ -64,12 +64,12 @@ void memcpy_pitch(void *dst, void *src, int w, int h, int srcpitch, int dstpitch) { - byte *dstp = (byte*)dst; - byte *srcp = (byte*)src; + Pixel *dstp = (Pixel *)dst; + Pixel *srcp = (Pixel *)src; assert(h >= 0); for (; h != 0; --h) { - memcpy(dstp, srcp, w); + memcpy(dstp, srcp, w * sizeof(Pixel)); dstp += dstpitch; srcp += srcpitch; } @@ -110,7 +110,7 @@ } for (ht = height; ht > 0; --ht) { - memcpy(dst, src, width); + memcpy(dst, src, width * sizeof(Pixel)); src -= p; dst -= p; } @@ -136,7 +136,7 @@ /* the y-displacement may be 0 therefore we have to use memmove, * because source and destination may overlap */ for (ht = height; ht > 0; --ht) { - memmove(dst, src, width); + memmove(dst, src, width * sizeof(Pixel)); src += p; dst += p; } @@ -175,7 +175,7 @@ if (!HASBIT(color, PALETTE_MODIFIER_GREYOUT)) { if (!HASBIT(color, USE_COLORTABLE)) { do { - memset(dst, color, right); + memset(dst, color, right * sizeof(Pixel)); dst += dpi->pitch; } while (--bottom); } else { diff -r 1f9336148544 -r 269c76b5b987 src/screenshot.cpp --- a/src/screenshot.cpp Mon May 14 14:06:46 2007 +0000 +++ b/src/screenshot.cpp Mon May 14 15:20:50 2007 +0000 @@ -449,7 +449,7 @@ 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); + memcpy(buf, _screen.dst_ptr + y * _screen.pitch, _screen.width * sizeof(Pixel)); ++y; buf += pitch; } diff -r 1f9336148544 -r 269c76b5b987 src/video/dedicated_v.cpp --- a/src/video/dedicated_v.cpp Mon May 14 14:06:46 2007 +0000 +++ b/src/video/dedicated_v.cpp Mon May 14 15:20:50 2007 +0000 @@ -112,7 +112,7 @@ #endif -static void *_dedicated_video_mem; +static Pixel *_dedicated_video_mem; extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm); extern void SwitchMode(int new_mode); @@ -122,7 +122,7 @@ { _screen.width = _screen.pitch = _cur_resolution[0]; _screen.height = _cur_resolution[1]; - _dedicated_video_mem = malloc(_cur_resolution[0]*_cur_resolution[1]); + _dedicated_video_mem = (Pixel *)malloc(_cur_resolution[0] * _cur_resolution[1] * sizeof(Pixel)); SetDebugString("net=6"); @@ -283,7 +283,7 @@ next_tick = cur_ticks + 30; GameLoop(); - _screen.dst_ptr = (Pixel*)_dedicated_video_mem; + _screen.dst_ptr = _dedicated_video_mem; UpdateWindows(); } CSleep(1); diff -r 1f9336148544 -r 269c76b5b987 src/video/null_v.cpp --- a/src/video/null_v.cpp Mon May 14 14:06:46 2007 +0000 +++ b/src/video/null_v.cpp Mon May 14 15:20:50 2007 +0000 @@ -7,13 +7,13 @@ #include "../window.h" #include "null_v.h" -static void* _null_video_mem = NULL; +static Pixel *_null_video_mem = NULL; static const char* NullVideoStart(const char* const* parm) { _screen.width = _screen.pitch = _cur_resolution[0]; _screen.height = _cur_resolution[1]; - _null_video_mem = malloc(_cur_resolution[0] * _cur_resolution[1]); + _null_video_mem = (Pixel *)malloc(_cur_resolution[0] * _cur_resolution[1] * sizeof(Pixel)); return NULL; } @@ -27,7 +27,7 @@ for (i = 0; i < 1000; i++) { GameLoop(); - _screen.dst_ptr = (Pixel*)_null_video_mem; + _screen.dst_ptr = _null_video_mem; UpdateWindows(); } } diff -r 1f9336148544 -r 269c76b5b987 src/video/sdl_v.cpp --- a/src/video/sdl_v.cpp Mon May 14 14:06:46 2007 +0000 +++ b/src/video/sdl_v.cpp Mon May 14 15:20:50 2007 +0000 @@ -195,7 +195,7 @@ _screen.width = newscreen->w; _screen.height = newscreen->h; - _screen.pitch = newscreen->pitch; + _screen.pitch = newscreen->pitch / sizeof(Pixel); _sdl_screen = newscreen; InitPalette(); diff -r 1f9336148544 -r 269c76b5b987 src/video/win32_v.cpp --- a/src/video/win32_v.cpp Mon May 14 14:06:46 2007 +0000 +++ b/src/video/win32_v.cpp Mon May 14 15:20:50 2007 +0000 @@ -671,7 +671,7 @@ if (_wnd.double_size) { w = ALIGN(w, 4); - _wnd.alloced_bits = _wnd.buffer_bits = (Pixel*)malloc(w * h); + _wnd.alloced_bits = _wnd.buffer_bits = (Pixel *)malloc(w * h * sizeof(Pixel)); w *= 2; h *= 2; }