Changeset - r8985:72eff2815e83
[Not reviewed]
master
0 6 0
rubidium - 16 years ago 2008-04-18 21:49:38
rubidium@openttd.org
(svn r12779) -Codechange: remove a few constants from openttd.h.
6 files changed with 26 insertions and 28 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -14,12 +14,13 @@
 
#include "texteff.hpp"
 
#include "blitter/factory.hpp"
 
#include "video/video_driver.hpp"
 
#include "strings_func.h"
 
#include "core/math_func.hpp"
 
#include "settings_type.h"
 
#include "core/alloc_func.hpp"
 

	
 
#include "table/palettes.h"
 
#include "table/sprites.h"
 
#include "table/control_codes.h"
 

	
 
byte _dirkeys;        ///< 1 = left, 2 = up, 4 = right, 8 = down
 
@@ -64,15 +65,15 @@ static Rect _invalid_rect;
 
static const byte *_color_remap_ptr;
 
static byte _string_colorremap[3];
 

	
 
enum {
 
	DIRTY_BLOCK_HEIGHT   = 8,
 
	DIRTY_BLOCK_WIDTH    = 64,
 
	DIRTY_BYTES_PER_LINE = MAX_SCREEN_WIDTH / DIRTY_BLOCK_WIDTH,
 
};
 
static byte _dirty_blocks[DIRTY_BYTES_PER_LINE * MAX_SCREEN_HEIGHT / DIRTY_BLOCK_HEIGHT];
 
static uint _dirty_bytes_per_line = 0;
 
static byte *_dirty_blocks = NULL;
 

	
 
void GfxScroll(int left, int top, int width, int height, int xo, int yo)
 
{
 
	Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
 

	
 
	if (xo == 0 && yo == 0) return;
 
@@ -931,12 +932,15 @@ byte GetCharacterWidth(FontSize size, WC
 
	return GetGlyphWidth(size, key);
 
}
 

	
 

	
 
void ScreenSizeChanged()
 
{
 
	_dirty_bytes_per_line = (_screen.width + DIRTY_BLOCK_WIDTH - 1) / DIRTY_BLOCK_WIDTH;
 
	_dirty_blocks = ReallocT<byte>(_dirty_blocks, _dirty_bytes_per_line * ((_screen.height + DIRTY_BLOCK_HEIGHT - 1) / DIRTY_BLOCK_HEIGHT));
 

	
 
	/* check the dirty rect */
 
	if (_invalid_rect.right >= _screen.width) _invalid_rect.right = _screen.width;
 
	if (_invalid_rect.bottom >= _screen.height) _invalid_rect.bottom = _screen.height;
 

	
 
	/* screen size changed and the old bitmap is invalid now, so we don't want to undraw it */
 
	_cursor.visible = false;
 
@@ -1056,13 +1060,13 @@ void DrawDirtyBlocks()
 
				byte *p = b;
 
				int h2;
 

	
 
				/* First try coalescing downwards */
 
				do {
 
					*p = 0;
 
					p += DIRTY_BYTES_PER_LINE;
 
					p += _dirty_bytes_per_line;
 
					bottom += DIRTY_BLOCK_HEIGHT;
 
				} while (bottom != h && *p != 0);
 

	
 
				/* Try coalescing to the right too. */
 
				h2 = (bottom - y) / DIRTY_BLOCK_HEIGHT;
 
				assert(h2 > 0);
 
@@ -1071,24 +1075,24 @@ void DrawDirtyBlocks()
 
				while (right != w) {
 
					byte *p2 = ++p;
 
					int h = h2;
 
					/* Check if a full line of dirty flags is set. */
 
					do {
 
						if (!*p2) goto no_more_coalesc;
 
						p2 += DIRTY_BYTES_PER_LINE;
 
						p2 += _dirty_bytes_per_line;
 
					} while (--h != 0);
 

	
 
					/* Wohoo, can combine it one step to the right!
 
					 * Do that, and clear the bits. */
 
					right += DIRTY_BLOCK_WIDTH;
 

	
 
					h = h2;
 
					p2 = p;
 
					do {
 
						*p2 = 0;
 
						p2 += DIRTY_BYTES_PER_LINE;
 
						p2 += _dirty_bytes_per_line;
 
					} while (--h != 0);
 
				}
 
				no_more_coalesc:
 

	
 
				left = x;
 
				top = y;
 
@@ -1101,13 +1105,13 @@ void DrawDirtyBlocks()
 
				if (left < right && top < bottom) {
 
					RedrawScreenRect(left, top, right, bottom);
 
				}
 

	
 
			}
 
		} while (b++, (x += DIRTY_BLOCK_WIDTH) != w);
 
	} while (b += -(w / DIRTY_BLOCK_WIDTH) + DIRTY_BYTES_PER_LINE, (y += DIRTY_BLOCK_HEIGHT) != h);
 
	} while (b += -(w / DIRTY_BLOCK_WIDTH) + _dirty_bytes_per_line, (y += DIRTY_BLOCK_HEIGHT) != h);
 

	
 
	_invalid_rect.left = w;
 
	_invalid_rect.top = h;
 
	_invalid_rect.right = 0;
 
	_invalid_rect.bottom = 0;
 

	
 
@@ -1151,25 +1155,25 @@ void SetDirtyBlocks(int left, int top, i
 
	if (right  > _invalid_rect.right ) _invalid_rect.right  = right;
 
	if (bottom > _invalid_rect.bottom) _invalid_rect.bottom = bottom;
 

	
 
	left /= DIRTY_BLOCK_WIDTH;
 
	top  /= DIRTY_BLOCK_HEIGHT;
 

	
 
	b = _dirty_blocks + top * DIRTY_BYTES_PER_LINE + left;
 
	b = _dirty_blocks + top * _dirty_bytes_per_line + left;
 

	
 
	width  = ((right  - 1) / DIRTY_BLOCK_WIDTH)  - left + 1;
 
	height = ((bottom - 1) / DIRTY_BLOCK_HEIGHT) - top  + 1;
 

	
 
	assert(width > 0 && height > 0);
 

	
 
	do {
 
		int i = width;
 

	
 
		do b[--i] = 0xFF; while (i);
 

	
 
		b += DIRTY_BYTES_PER_LINE;
 
		b += _dirty_bytes_per_line;
 
	} while (--height != 0);
 
}
 

	
 
/*!
 
 * This function mark the whole screen as dirty. This results in repainting
 
 * the whole screen. Use this with care as this function will break the
src/main_gui.cpp
Show inline comments
 
@@ -446,10 +446,10 @@ void ShowVitalWindows()
 
 * Adapt the game screen-size, re-allocate the open windows, and repaint everything
 
 */
 
void GameSizeChanged()
 
{
 
	_cur_resolution[0] = _screen.width;
 
	_cur_resolution[1] = _screen.height;
 
	ScreenSizeChanged();
 
	RelocateAllWindows(_screen.width, _screen.height);
 
	ScreenSizeChanged();
 
	MarkWholeScreenDirty();
 
}
src/openttd.cpp
Show inline comments
 
@@ -255,14 +255,14 @@ static void ParseResolution(int res[2], 
 
	const char *t = strchr(s, 'x');
 
	if (t == NULL) {
 
		ShowInfoF("Invalid resolution '%s'", s);
 
		return;
 
	}
 

	
 
	res[0] = Clamp(strtoul(s, NULL, 0), 64, MAX_SCREEN_WIDTH);
 
	res[1] = Clamp(strtoul(t + 1, NULL, 0), 64, MAX_SCREEN_HEIGHT);
 
	res[0] = max(strtoul(s, NULL, 0), 64UL);
 
	res[1] = max(strtoul(t + 1, NULL, 0), 64UL);
 
}
 

	
 
static void InitializeDynamicVariables()
 
{
 
	/* Dynamic stuff needs to be initialized somewhere... */
 
	_town_sort     = NULL;
src/openttd.h
Show inline comments
 
@@ -94,17 +94,12 @@ enum {
 
	SORT_BY_DATE    = 0,
 
	SORT_BY_NAME    = 2
 
};
 

	
 
extern byte _savegame_sort_order;
 

	
 
enum {
 
	MAX_SCREEN_WIDTH  = 2048,
 
	MAX_SCREEN_HEIGHT = 1200,
 
};
 

	
 
/* In certain windows you navigate with the arrow keys. Do not scroll the
 
 * gameview when here. Bitencoded variable that only allows scrolling if all
 
 * elements are zero */
 
enum {
 
	SCROLL_CON  = 0,
 
	SCROLL_EDIT = 1,
src/video/sdl_v.cpp
Show inline comments
 
@@ -124,14 +124,13 @@ static void GetVideoModes()
 
		_num_resolutions = lengthof(default_resolutions);
 
	} else {
 
		int n = 0;
 
		for (i = 0; modes[i]; i++) {
 
			int w = modes[i]->w;
 
			int h = modes[i]->h;
 
			if (IsInsideMM(w, 640, MAX_SCREEN_WIDTH + 1) &&
 
					IsInsideMM(h, 480, MAX_SCREEN_HEIGHT + 1)) {
 
			if (w >= 640 && h >= 480) {
 
				int j;
 
				for (j = 0; j < n; j++) {
 
					if (_resolutions[j][0] == w && _resolutions[j][1] == h) break;
 
				}
 

	
 
				if (j == n) {
 
@@ -416,14 +415,14 @@ static int PollEvent()
 
			} else {
 
				HandleKeypress(ConvertSdlKeyIntoMy(&ev.key.keysym));
 
			}
 
			break;
 

	
 
		case SDL_VIDEORESIZE: {
 
			int w = Clamp(ev.resize.w, 64, MAX_SCREEN_WIDTH);
 
			int h = Clamp(ev.resize.h, 64, MAX_SCREEN_HEIGHT);
 
			int w = max(ev.resize.w, 64);
 
			int h = max(ev.resize.h, 64);
 
			ChangeResInGame(w, h);
 
			break;
 
		}
 
	}
 
	return -1;
 
}
src/video/win32_v.cpp
Show inline comments
 
@@ -542,14 +542,14 @@ static LRESULT CALLBACK WndProcGdi(HWND 
 

	
 
			SetRect(&r2, 0, 0, 0, 0);
 
			AdjustWindowRect(&r2, GetWindowLong(hwnd, GWL_STYLE), FALSE);
 

	
 
			w = r->right - r->left - (r2.right - r2.left);
 
			h = r->bottom - r->top - (r2.bottom - r2.top);
 
			w = Clamp(w, 64, MAX_SCREEN_WIDTH);
 
			h = Clamp(h, 64, MAX_SCREEN_HEIGHT);
 
			w = max(w, 64);
 
			h = max(h, 64);
 
			SetRect(&r2, 0, 0, w, h);
 

	
 
			AdjustWindowRect(&r2, GetWindowLong(hwnd, GWL_STYLE), FALSE);
 
			w = r2.right - r2.left;
 
			h = r2.bottom - r2.top;
 

	
 
@@ -674,14 +674,14 @@ static void RegisterWndClass()
 
static bool AllocateDibSection(int w, int h)
 
{
 
	BITMAPINFO *bi;
 
	HDC dc;
 
	int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
 

	
 
	w = Clamp(w, 64, MAX_SCREEN_WIDTH);
 
	h = Clamp(h, 64, MAX_SCREEN_HEIGHT);
 
	w = max(w, 64);
 
	h = max(h, 64);
 

	
 
	if (bpp == 0) error("Can't use a blitter that blits 0 bpp for normal visuals");
 

	
 
	if (w == _screen.width && h == _screen.height)
 
		return false;
 

	
 
@@ -734,14 +734,14 @@ static void FindResolutions()
 
	DEVMODEA dm;
 

	
 
	/* XXX - EnumDisplaySettingsW crashes with unicows.dll on Windows95
 
	 * Doesn't really matter since we don't pass a string anyways, but still
 
	 * a letdown */
 
	for (i = 0; EnumDisplaySettingsA(NULL, i, &dm) != 0; i++) {
 
		if (dm.dmBitsPerPel == BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() && IsInsideMM(dm.dmPelsWidth, 640, MAX_SCREEN_WIDTH + 1) &&
 
				IsInsideMM(dm.dmPelsHeight, 480, MAX_SCREEN_HEIGHT + 1)) {
 
		if (dm.dmBitsPerPel == BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() &&
 
				dm.dmPelsWidth >= 640 && dm.dmPelsHeight >= 480) {
 
			uint j;
 

	
 
			for (j = 0; j < n; j++) {
 
				if (_resolutions[j][0] == dm.dmPelsWidth && _resolutions[j][1] == dm.dmPelsHeight) break;
 
			}
 

	
 
@@ -784,15 +784,15 @@ const char *VideoDriver_Win32::Start(con
 

	
 
	// fullscreen uses those
 
	_wnd.width_org = _cur_resolution[0];
 
	_wnd.height_org = _cur_resolution[1];
 

	
 
	AllocateDibSection(_cur_resolution[0], _cur_resolution[1]);
 
	MarkWholeScreenDirty();
 
	MakeWindow(_fullscreen);
 

	
 
	MakeWindow(_fullscreen);
 
	MarkWholeScreenDirty();
 

	
 
	return NULL;
 
}
 

	
 
void VideoDriver_Win32::Stop()
 
{
0 comments (0 inline, 0 general)