Changeset - r6615:56681ed23403
[Not reviewed]
master
0 6 0
truelight - 17 years ago 2007-05-14 15:20:50
truelight@openttd.org
(svn r9835) -Codechange: use Pixel typedef instead of byte where ever possible
6 files changed with 15 insertions and 15 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -61,18 +61,18 @@ static byte _string_colorremap[3];
 

	
 
#define DIRTY_BYTES_PER_LINE (MAX_SCREEN_WIDTH / 64)
 
static byte _dirty_blocks[DIRTY_BYTES_PER_LINE * MAX_SCREEN_HEIGHT / 8];
 

	
 
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;
 
	}
 
}
 

	
 
void GfxScroll(int left, int top, int width, int height, int xo, int yo)
 
@@ -107,13 +107,13 @@ void GfxScroll(int left, int top, int wi
 
		} else {
 
			src -= xo;
 
			width += xo;
 
		}
 

	
 
		for (ht = height; ht > 0; --ht) {
 
			memcpy(dst, src, width);
 
			memcpy(dst, src, width * sizeof(Pixel));
 
			src -= p;
 
			dst -= p;
 
		}
 
	} else {
 
		/* Calculate pointers */
 
		dst = _screen.dst_ptr + top * p + left;
 
@@ -133,13 +133,13 @@ void GfxScroll(int left, int top, int wi
 
			width += xo;
 
		}
 

	
 
		/* 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;
 
		}
 
	}
 
	/* This part of the screen is now dirty. */
 
	_video_driver->make_dirty(left, top, width, height);
 
@@ -172,13 +172,13 @@ void GfxFillRect(int left, int top, int 
 

	
 
	dst = dpi->dst_ptr + top * dpi->pitch + left;
 

	
 
	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 {
 
			/* use colortable mode */
 
			const byte* ctab = GetNonSprite(GB(color, 0, PALETTE_WIDTH)) + 1;
 

	
src/screenshot.cpp
Show inline comments
 
@@ -446,13 +446,13 @@ void SetScreenshotFormat(int i)
 
}
 

	
 
/* screenshot generator that dumps the current video buffer */
 
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;
 
	}
 
}
 

	
 
/* generate a large piece of the world */
src/video/dedicated_v.cpp
Show inline comments
 
@@ -109,23 +109,23 @@ static void CloseWindowsConsoleThread()
 
	DEBUG(driver, 2, "Windows console thread shut down");
 
}
 

	
 
#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);
 

	
 

	
 
static const char *DedicatedVideoStart(const char * const *parm)
 
{
 
	_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");
 

	
 
#ifdef WIN32
 
	// For win32 we need to allocate a console (debug mode does the same)
 
	CreateConsole();
 
@@ -280,13 +280,13 @@ static void DedicatedVideoMainLoop()
 

	
 
		cur_ticks = GetTime();
 
		if (cur_ticks >= next_tick || cur_ticks < prev_cur_ticks) {
 
			next_tick = cur_ticks + 30;
 

	
 
			GameLoop();
 
			_screen.dst_ptr = (Pixel*)_dedicated_video_mem;
 
			_screen.dst_ptr = _dedicated_video_mem;
 
			UpdateWindows();
 
		}
 
		CSleep(1);
 
	}
 
}
 

	
src/video/null_v.cpp
Show inline comments
 
@@ -4,19 +4,19 @@
 
#include "../openttd.h"
 
#include "../gfx.h"
 
#include "../variables.h"
 
#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;
 
}
 

	
 
static void NullVideoStop() { free(_null_video_mem); }
 

	
 
static void NullVideoMakeDirty(int left, int top, int width, int height) {}
 
@@ -24,13 +24,13 @@ static void NullVideoMakeDirty(int left,
 
static void NullVideoMainLoop()
 
{
 
	uint i;
 

	
 
	for (i = 0; i < 1000; i++) {
 
		GameLoop();
 
		_screen.dst_ptr = (Pixel*)_null_video_mem;
 
		_screen.dst_ptr = _null_video_mem;
 
		UpdateWindows();
 
	}
 
}
 

	
 
static bool NullVideoChangeRes(int w, int h) { return false; }
 
static void NullVideoFullScreen(bool fs) {}
src/video/sdl_v.cpp
Show inline comments
 
@@ -192,13 +192,13 @@ static bool CreateMainSurface(int w, int
 
	newscreen = SDL_CALL SDL_SetVideoMode(w, h, 8, SDL_SWSURFACE | SDL_HWPALETTE | (_fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE));
 
	if (newscreen == NULL)
 
		return false;
 

	
 
	_screen.width = newscreen->w;
 
	_screen.height = newscreen->h;
 
	_screen.pitch = newscreen->pitch;
 
	_screen.pitch = newscreen->pitch / sizeof(Pixel);
 

	
 
	_sdl_screen = newscreen;
 
	InitPalette();
 

	
 
	snprintf(caption, sizeof(caption), "OpenTTD %s", _openttd_revision);
 
	SDL_CALL SDL_WM_SetCaption(caption, caption);
src/video/win32_v.cpp
Show inline comments
 
@@ -668,13 +668,13 @@ static bool AllocateDibSection(int w, in
 
	bi = (BITMAPINFO*)alloca(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256);
 
	memset(bi, 0, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256);
 
	bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 

	
 
	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;
 
	}
 

	
 
	bi->bmiHeader.biWidth = _wnd.width = w;
 
	bi->bmiHeader.biHeight = -(_wnd.height = h);
0 comments (0 inline, 0 general)