[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.152,1.153 animation.cpp,1.47,1.48 events.cpp,1.56,1.57 font.cpp,1.29,1.30 font.h,1.12,1.13 game.cpp,1.74,1.75 gfx.cpp,1.52,1.53 gfx.h,1.29,1.30 ihnm_introproc.cpp,1.43,1.44 interface.cpp,1.112,1.113 interface.h,1.62,1.63 isomap.cpp,1.54,1.55 isomap.h,1.23,1.24 objectmap.cpp,1.40,1.41 objectmap.h,1.21,1.22 palanim.cpp,1.23,1.24 palanim.h,1.9,1.10 puzzle.cpp,1.9,1.10 render.cpp,1.65,1.66 render.h,1.24,1.25 saga.h,1.103,1.104 scene.cpp,1.119,1.120 scene.h,1.60,1.61 sfuncs.cpp,1.136,1.137 sprite.cpp,1.56,1.57 sprite.h,1.20,1.21 text.cpp,1.12,1.13 transitions.cpp,1.14,1.15

Andrew Kurushin h00ligan at users.sourceforge.net
Sat Jul 9 09:25:03 CEST 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15646

Modified Files:
	actor.cpp animation.cpp events.cpp font.cpp font.h game.cpp 
	gfx.cpp gfx.h ihnm_introproc.cpp interface.cpp interface.h 
	isomap.cpp isomap.h objectmap.cpp objectmap.h palanim.cpp 
	palanim.h puzzle.cpp render.cpp render.h saga.h scene.cpp 
	scene.h sfuncs.cpp sprite.cpp sprite.h text.cpp 
	transitions.cpp 
Log Message:
gfx rearangement
code cleanups

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -d -r1.152 -r1.153
--- actor.cpp	8 Jul 2005 16:55:52 -0000	1.152
+++ actor.cpp	9 Jul 2005 16:23:44 -0000	1.153
@@ -62,7 +62,7 @@
 static int tileCommonObjectCompare(const CommonObjectDataPointer& obj1, const CommonObjectDataPointer& obj2) {
 	int p1 = -obj1->location.u() - obj1->location.v() - obj1->location.z;
 	int p2 = -obj2->location.u() - obj2->location.v() - obj2->location.z;
-	//TODO:  for kObjNotFlat obj Height*3 of sprite should be adde to p1 and p2
+	//TODO:  for kObjNotFlat obj Height*3 of sprite should be added to p1 and p2
 	//if (validObjId(obj1->id)) {
 
 	if (p1 == p2) {
@@ -1376,9 +1376,9 @@
 	int frameNumber;
 	SpriteList *spriteList;
 
-	SURFACE *back_buf;
+	Surface *backBuffer;
 
-	back_buf = _vm->_gfx->getBackBuffer();
+	backBuffer = _vm->_gfx->getBackBuffer();
 
 	createDrawOrderList();
 
@@ -1391,9 +1391,9 @@
 		
 		
 		if (_vm->_scene->getFlags() & kSceneFlagISO) {
-			_vm->_isoMap->drawSprite(back_buf, *spriteList, frameNumber, drawObject->location, drawObject->screenPosition, drawObject->screenScale);
+			_vm->_isoMap->drawSprite(backBuffer, *spriteList, frameNumber, drawObject->location, drawObject->screenPosition, drawObject->screenScale);
 		} else {
-			_vm->_sprite->drawOccluded(back_buf, _vm->_scene->getSceneClip(),*spriteList, frameNumber, drawObject->screenPosition, drawObject->screenScale, drawObject->screenDepth);
+			_vm->_sprite->drawOccluded(backBuffer, _vm->_scene->getSceneClip(),*spriteList, frameNumber, drawObject->screenPosition, drawObject->screenScale, drawObject->screenDepth);
 		}
 	}
 
@@ -1407,9 +1407,9 @@
 		char oneChar[2];
 		oneChar[1] = 0;
 		const char *outputString;
-		SURFACE *back_buf;
+		Surface *backBuffer;
 
-		back_buf = _vm->_gfx->getBackBuffer();
+		backBuffer = _vm->_gfx->getBackBuffer();
 
 		if (_activeSpeech.speechFlags & kSpeakSlow) {
 			outputString = oneChar;
@@ -1426,7 +1426,7 @@
 		if (_activeSpeech.actorIds[0] != 0) {
 			
 			for (i = 0; i < _activeSpeech.actorsCount; i++){
-				_vm->textDraw(MEDIUM_FONT_ID, back_buf, outputString,
+				_vm->textDraw(MEDIUM_FONT_ID, backBuffer, outputString,
 					_activeSpeech.speechCoords[i].x, 
 					_activeSpeech.speechCoords[i].y, 
 					_activeSpeech.speechColor[i], 
@@ -2647,7 +2647,7 @@
 void Actor::drawPathTest() {
 #ifdef ACTOR_DEBUG
 	int i;
-	SURFACE *surface;
+	Surface *surface;
 	surface = _vm->_gfx->getBackBuffer();
 	if (_debugPoints == NULL) {
 		return;

Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/animation.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- animation.cpp	25 Jun 2005 15:55:43 -0000	1.47
+++ animation.cpp	9 Jul 2005 16:23:44 -0000	1.48
@@ -117,7 +117,7 @@
 
 void Anim::play(uint16 animId, int vectorTime, bool playing) {
 	EVENT event;
-	BUFFER_INFO buf_info;
+	Surface *backGroundSurface;
 
 	byte *displayBuffer;
 
@@ -133,8 +133,8 @@
 
 	anim = getAnimation(animId);
 
-	_vm->_render->getBufferInfo(&buf_info);
-	displayBuffer = buf_info.bg_buf;
+	backGroundSurface = _vm->_render->getBackGroundSurface();
+	displayBuffer = (byte*)backGroundSurface->pixels;
 
 
 	if (playing) {

Index: events.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/events.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- events.cpp	8 Jul 2005 18:39:50 -0000	1.56
+++ events.cpp	9 Jul 2005 16:23:44 -0000	1.57
@@ -124,7 +124,7 @@
 	double event_pc = 0.0; // Event completion percentage
 	int event_done = 0;
 
-	BUFFER_INFO buf_info;
+	Surface *backGroundSurface;
 	BGInfo bgInfo;
 
 	event_pc = ((double)event->duration - event->time) / event->duration;
@@ -148,11 +148,11 @@
 	case PAL_EVENT:
 		switch (event->op) {
 		case EVENT_BLACKTOPAL:
-			_vm->_gfx->blackToPal((PALENTRY *)event->data, event_pc);
+			_vm->_gfx->blackToPal((PalEntry *)event->data, event_pc);
 			break;
 
 		case EVENT_PALTOBLACK:
-			_vm->_gfx->palToBlack((PALENTRY *)event->data, event_pc);
+			_vm->_gfx->palToBlack((PalEntry *)event->data, event_pc);
 			break;
 		default:
 			break;
@@ -161,11 +161,10 @@
 	case TRANSITION_EVENT:
 		switch (event->op) {
 		case EVENT_DISSOLVE:
-			_vm->_render->getBufferInfo(&buf_info);
+			backGroundSurface = _vm->_render->getBackGroundSurface();
 			_vm->_scene->getBGInfo(bgInfo);
-			_vm->transitionDissolve(buf_info.bg_buf, buf_info.bg_buf_w, 
-				buf_info.bg_buf_h, buf_info.bg_buf_w, bgInfo.buffer, bgInfo.bounds.width(), 
-					bgInfo.bounds.height(), 0, 0, 0, event_pc);
+			_vm->transitionDissolve((byte*)backGroundSurface->pixels, backGroundSurface->w, 
+				backGroundSurface->h, bgInfo.buffer, bgInfo.bounds.width(), bgInfo.bounds.height(), 0, 0, 0, event_pc);
 			break;
 		case EVENT_DISSOLVE_BGMASK:
 			// we dissolve it centered.
@@ -174,10 +173,10 @@
 			byte *mask_buf;
 			size_t len;
 
-			_vm->_render->getBufferInfo(&buf_info);
+			backGroundSurface = _vm->_render->getBackGroundSurface();
 			_vm->_scene->getBGMaskInfo(w, h, mask_buf, len);
-			_vm->transitionDissolve(buf_info.bg_buf, buf_info.bg_buf_w, 
-					buf_info.bg_buf_h, buf_info.bg_buf_w, mask_buf, w, h, 1, 
+			_vm->transitionDissolve((byte*)backGroundSurface->pixels, backGroundSurface->w, 
+					backGroundSurface->h, mask_buf, w, h, 1, 
 					(_vm->getDisplayWidth() - w) / 2, (_vm->getDisplayHeight() - h) / 2, event_pc);
 			break;
 		default:
@@ -221,11 +220,11 @@
 	case PAL_EVENT:
 		switch (event->op) {
 		case EVENT_BLACKTOPAL:
-			_vm->_gfx->blackToPal((PALENTRY *)event->data, event_pc);
+			_vm->_gfx->blackToPal((PalEntry *)event->data, event_pc);
 			break;
 
 		case EVENT_PALTOBLACK:
-			_vm->_gfx->palToBlack((PALENTRY *)event->data, event_pc);
+			_vm->_gfx->palToBlack((PalEntry *)event->data, event_pc);
 			break;
 		default:
 			break;
@@ -250,11 +249,10 @@
 }
 
 int Events::handleOneShot(EVENT *event) {
-	SURFACE *back_buf;
+	Surface *backBuffer;
 	ScriptThread *sthread;
 	Rect rect;
 
-	static BGInfo bgInfo;
 
 	if (event->time > 0) {
 		return EVENT_CONTINUE;
@@ -293,29 +291,19 @@
 		break;
 	case BG_EVENT:
 		{
-			BUFFER_INFO rbuf_info;
-			Point bg_pt;
+			Surface *backGroundSurface;
+			BGInfo bgInfo;
 
 			if (!(_vm->_scene->getFlags() & kSceneFlagISO)) {
 
-				back_buf = _vm->_gfx->getBackBuffer();
-
-				_vm->_render->getBufferInfo(&rbuf_info);
+				backBuffer = _vm->_gfx->getBackBuffer();
+				backGroundSurface = _vm->_render->getBackGroundSurface();
 				_vm->_scene->getBGInfo(bgInfo);
 
-				bg_pt.x = bgInfo.bounds.left;
-				bg_pt.y = bgInfo.bounds.top;
-
-				bufToBuffer(rbuf_info.bg_buf, rbuf_info.bg_buf_w, rbuf_info.bg_buf_h,
-					bgInfo.buffer, bgInfo.bounds.width(), bgInfo.bounds.height(), NULL, &bg_pt);
+				backGroundSurface->blit(bgInfo.bounds, bgInfo.buffer);
 
 				// If it is inset scene then draw black border
 				if (bgInfo.bounds.width() < _vm->getDisplayWidth() || bgInfo.bounds.height() < _vm->getSceneHeight()) {
-					SURFACE s;
-					s.pixels = rbuf_info.bg_buf;
-					s.w = s.pitch = rbuf_info.bg_buf_w;
-					s.h = rbuf_info.bg_buf_h;
-					s.bytesPerPixel = 1;
 					Common::Rect rect1(2, bgInfo.bounds.height() + 4);
 					Common::Rect rect2(bgInfo.bounds.width() + 4, 2);
 					Common::Rect rect3(2, bgInfo.bounds.height() + 4);
@@ -325,14 +313,14 @@
 					rect3.moveTo(bgInfo.bounds.right, bgInfo.bounds.top - 2);
 					rect4.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.bottom);
 
-					drawRect(&s, rect1, kITEColorBlack);
-					drawRect(&s, rect2, kITEColorBlack);
-					drawRect(&s, rect3, kITEColorBlack);
-					drawRect(&s, rect4, kITEColorBlack);
+					backGroundSurface->drawRect(rect1, kITEColorBlack);
+					backGroundSurface->drawRect(rect2, kITEColorBlack);
+					backGroundSurface->drawRect(rect3, kITEColorBlack);
+					backGroundSurface->drawRect(rect4, kITEColorBlack);
 				}
 
 				if (event->param == SET_PALETTE) {
-					PALENTRY *pal_p;
+					PalEntry *pal_p;
 					_vm->_scene->getBGPal(&pal_p);
 					_vm->_gfx->setPalette(pal_p);
 				}
@@ -450,7 +438,7 @@
 			rect.bottom = event->param3;
 			rect.left = event->param4;
 			rect.right = event->param5;
-			drawRect((SURFACE *)event->data, rect, event->param);
+			((Surface *)event->data)->drawRect(rect, event->param);
 			break;
 		case EVENT_SETFLAG:
 			_vm->_render->setFlag(event->param);

Index: font.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/font.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- font.cpp	5 Jul 2005 16:58:32 -0000	1.29
+++ font.cpp	9 Jul 2005 16:23:44 -0000	1.30
@@ -360,7 +360,7 @@
 	return width;
 }
 
-int Font::draw(int font_id, SURFACE *ds, const char *draw_str, size_t draw_str_ct,
+int Font::draw(int font_id, Surface *ds, const char *draw_str, size_t draw_str_ct,
 			int text_x, int text_y, int color, int effect_color, int flags) {
 	FONT *font;
 
@@ -387,7 +387,7 @@
 	return SUCCESS;
 }
 
-int Font::outFont(FONT_STYLE * draw_font, SURFACE * ds, const char *draw_str, size_t draw_str_ct,
+int Font::outFont(FONT_STYLE * draw_font, Surface *ds, const char *draw_str, size_t draw_str_ct,
 				  int text_x, int text_y, int color, int flags) {
 	const byte *draw_str_p;
 	byte *c_data_ptr;

Index: font.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/font.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- font.h	11 Jan 2005 21:10:19 -0000	1.12
+++ font.h	9 Jul 2005 16:23:44 -0000	1.13
@@ -101,7 +101,7 @@
  public:
 	Font(SagaEngine *vm);
 	~Font(void);
-	int draw(int font_id, SURFACE *ds, const char *draw_str, size_t draw_str_len,
+	int draw(int font_id, Surface *ds, const char *draw_str, size_t draw_str_len,
 				  int text_x, int text_y, int color, int effect_color, int flags);
 	int getStringWidth(int font_id, const char *test_str, size_t test_str_ct, int flags);
 	int getHeight(int font_id);
@@ -110,7 +110,7 @@
 
 	int loadFont(uint32 fontResourceId);
 	FONT_STYLE *createOutline(FONT_STYLE * src_font);
-	int outFont(FONT_STYLE *font, SURFACE * ds, const char *draw_str, size_t draw_str_ct,
+	int outFont(FONT_STYLE *font, Surface *ds, const char *draw_str, size_t draw_str_ct,
 				int text_x, int text_y, int color, int flags);
 	int getByteLen(int num_bits);
 

Index: game.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/game.cpp,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- game.cpp	9 Jul 2005 10:34:09 -0000	1.74
+++ game.cpp	9 Jul 2005 16:23:44 -0000	1.75
@@ -122,7 +122,7 @@
 	0,				// status x offset
 	137,			// status y offset
 	320,			// status width
-	12,				// status height
+	11,				// status height
 	2,				// status text y offset
 	186,			// status text color
 	15,				// status BG color

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/gfx.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- gfx.cpp	8 Jul 2005 16:55:54 -0000	1.52
+++ gfx.cpp	9 Jul 2005 16:23:44 -0000	1.53
@@ -32,8 +32,6 @@
 namespace Saga {
 
 Gfx::Gfx(OSystem *system, int width, int height, GameDetector &detector) : _system(system) {
-	SURFACE back_buf;
-
 	_system->beginGFXTransaction();
 		_vm->initCommonGFX(detector);
 		_system->initSize(width, height);
@@ -41,19 +39,9 @@
 
 	debug(5, "Init screen %dx%d", width, height);
 	// Convert surface data to R surface data
-	back_buf.pixels = calloc(1, width * height);
-	back_buf.w = width;
-	back_buf.h = height;
-	back_buf.pitch = width;
-	back_buf.bytesPerPixel = 1;
-
-	back_buf.clip_rect.left = 0;
-	back_buf.clip_rect.top = 0;
-	back_buf.clip_rect.right = width;
-	back_buf.clip_rect.bottom = height;
+	_backBuffer.create(width, height, 1);
 
 	// Set module data
-	_back_buf = back_buf;
 	_init = 1;
 
 	// For now, always show the mouse cursor.
@@ -61,376 +49,108 @@
 	_system->showMouse(true);
 }
 
-/*
-~Gfx() {
-  free(GfxModule.r_back_buf->pixels);
+
+Gfx::~Gfx() {
+  _backBuffer.free();
 }
- */
 
-int drawPalette(SURFACE *dst_s) {
+
+void Surface::drawPalette() {
 	int x;
 	int y;
 	int color = 0;
-
-	Rect pal_rect;
+	Rect palRect;
 
 	for (y = 0; y < 16; y++) {
-		pal_rect.top = (y * 8) + 4;
-		pal_rect.bottom = pal_rect.top + 8;
+		palRect.top = (y * 8) + 4;
+		palRect.bottom = palRect.top + 8;
 
 		for (x = 0; x < 16; x++) {
-			pal_rect.left = (x * 8) + 4;
-			pal_rect.right = pal_rect.left + 8;
+			palRect.left = (x * 8) + 4;
+			palRect.right = palRect.left + 8;
 
-			drawRect(dst_s, pal_rect, color);
+			drawRect(palRect, color);
 			color++;
 		}
 	}
-
-	return 0;
 }
 
-// TODO: I've fixed at least one clipping bug here, but I have a feeling there
-//       are several more. 
-
 // * Copies a rectangle from a raw 8 bit pixel buffer to the specified surface.
-// The buffer is of width 'src_w' and height 'src_h'. The rectangle to be 
-// copied is defined by 'src_rect'.  
-// The rectangle is copied to the destination surface at point 'dst_pt'.
-// - If dst_pt is NULL, the buffer is rectangle is copied to the destination 
-//    origin.
-// - If src_rect is NULL, the entire buffer is copied./
 // - The surface must match the logical dimensions of the buffer exactly.
-// - Returns FAILURE on error
-int bufToSurface(SURFACE *ds, const byte *src, int src_w, int src_h, 
-					 Rect *src_rect, Point *dst_pt) {
-	const byte *read_p;
-	byte *write_p;
-
-	int row;
-
-	Common::Rect s;
-	int d_x, d_y;
-
-	Common::Rect clip;
-
-	int dst_off_x, dst_off_y;
-	int src_off_x, src_off_y;
-	int src_draw_w, src_draw_h;
-
-	// Clamp source rectangle to source buffer
-	if (src_rect != NULL) {
-		src_rect->clip(src_w, src_h);
-
-		s = *src_rect;
-	} else {
-		s.left = 0;
-		s.top = 0;
-		s.right = src_w;
-		s.bottom = src_h;
-	}
-
-	if (s.width() <= 0 || s.height() <= 0) {
-		// Empty or negative region
-		return FAILURE;
-	}
-
-	// Get destination origin and clip rectangle
-	if (dst_pt != NULL) {
-		d_x = dst_pt->x;
-		d_y = dst_pt->y;
-	} else {
-		d_x = 0;
-		d_y = 0;
-	}
-
-	clip = ds->clip_rect;
-
-	if (clip.left == clip.right) {
-		clip.left = 0;
-		clip.right = ds->w;
-	}
-
-	if (clip.top == clip.bottom) {
-		clip.top = 0;
-		clip.bottom = ds->h;
-	}
-
-	// Clip source rectangle to destination surface
-	dst_off_x = d_x;
-	dst_off_y = d_y;
-	src_off_x = s.left;
-	src_off_y = s.top;
-	src_draw_w = s.width();
-	src_draw_h = s.height();
-
-	// Clip to left edge
-
-	if (d_x < clip.left) {
-		if (d_x <= (-src_draw_w)) {
-			// dst rect completely off left edge
-			return SUCCESS;
-		}
-
-		src_off_x += (clip.left - d_x);
-		src_draw_w -= (clip.left - d_x);
-
-		dst_off_x = clip.left;
-	}
-
-	// Clip to top edge
-
-	if (d_y < clip.top) {
-		if (d_y >= (-src_draw_h)) {
-			// dst rect completely off top edge
-			return SUCCESS;
-		}
-
-		src_off_y += (clip.top - d_y);
-		src_draw_h -= (clip.top - d_y);
-
-		dst_off_y = clip.top;
-	}
-
-	// Clip to right edge
-
-	if (d_x >= clip.right) {
-		// dst rect completely off right edge
-		return SUCCESS;
-	}
-
-	if ((d_x + src_draw_w) > clip.right) {
-		src_draw_w = clip.right - d_x;
-	}
-
-	// Clip to bottom edge
-
-	if (d_y > clip.bottom) {
-		// dst rect completely off bottom edge
-		return SUCCESS;
-	}
-
-	if ((d_y + src_draw_h) > clip.bottom) {
-		src_draw_h = clip.bottom - d_y;
-	}
-
-	// Transfer buffer data to surface
-	read_p = (src + src_off_x) + (src_w * src_off_y);
-	write_p = ((byte *)ds->pixels + dst_off_x) + (ds->pitch * dst_off_y);
-
-	for (row = 0; row < src_draw_h; row++) {
-		memcpy(write_p, read_p, src_draw_w);
-
-		write_p += ds->pitch;
-		read_p += src_w;
-	}
-
-	return SUCCESS;
-}
-
-int bufToBuffer(byte *dst_buf, int dst_w, int dst_h, const byte *src,
-					int src_w, int src_h, Rect *src_rect, Point *dst_pt) {
-	const byte *read_p;
-	byte *write_p;
-	int row;
-
-	Common::Rect s;
-	int d_x, d_y;
-	Common::Rect clip;
-
-	int dst_off_x, dst_off_y;
-	int src_off_x, src_off_y;
-	int src_draw_w, src_draw_h;
-
-	// Clamp source rectangle to source buffer
-	if (src_rect != NULL) {
-		src_rect->clip(src_w, src_h);
-
-		s.left = src_rect->left;
-		s.top = src_rect->top;
-		s.right = src_rect->right;
-		s.bottom = src_rect->bottom;
-	} else {
-		s.left = 0;
-		s.top = 0;
-		s.right = src_w;
-		s.bottom = src_h;
-	}
-
-	if (s.width() <= 0 || s.height() <= 0) {
-		// Empty or negative region
-		return FAILURE;
-	}
-
-	// Get destination origin and clip rectangle
-	if (dst_pt != NULL) {
-		d_x = dst_pt->x;
-		d_y = dst_pt->y;
-	} else {
-		d_x = 0;
-		d_y = 0;
-	}
-
-	clip.left = 0;
-	clip.top = 0;
-	clip.right = dst_w;
-	clip.bottom = dst_h;
-
-	// Clip source rectangle to destination surface
-	dst_off_x = d_x;
-	dst_off_y = d_y;
-	src_off_x = s.left;
-	src_off_y = s.top;
-	src_draw_w = s.width();
-	src_draw_h = s.height();
-
-	// Clip to left edge
-
-	if (d_x < clip.left) {
-		if (d_x <= (-src_draw_w)) {
-			// dst rect completely off left edge
-			return SUCCESS;
-		}
-
-		src_off_x += (clip.left - d_x);
-		src_draw_w -= (clip.left - d_x);
-
-		dst_off_x = clip.left;
-	}
-
-	// Clip to top edge
-
-	if (d_y < clip.top) {
-		if (d_y >= (-src_draw_h)) {
-			// dst rect completely off top edge
-			return SUCCESS;
-		}
-
-		src_off_y += (clip.top - d_y);
-		src_draw_h -= (clip.top - d_y);
-
-		dst_off_y = clip.top;
-	}
-
-	// Clip to right edge
-
-	if (d_x >= clip.right) {
-		// dst rect completely off right edge
-		return SUCCESS;
-	}
-
-	if ((d_x + src_draw_w) > clip.right) {
-		src_draw_w = clip.right - d_x;
-	}
-
-	// Clip to bottom edge
+void Surface::blit(const Common::Rect &destRect, const byte *sourceBuffer) {
+	const byte *readPointer;
+	byte *writePointer;
+	int row;	
+	ClipData clipData;
 
-	if (d_y >= clip.bottom) {
-		// dst rect completely off bottom edge
-		return SUCCESS;
-	}
+	clipData.sourceRect.left = 0;
+	clipData.sourceRect.top = 0;
+	clipData.sourceRect.right = destRect.width();
+	clipData.sourceRect.bottom = destRect.height();
 
-	if ((d_y + src_draw_h) > clip.bottom) {
-		src_draw_h = clip.bottom - d_y;
+	clipData.destPoint.x = destRect.left;
+	clipData.destPoint.y = destRect.top;
+	clipData.destRect.left = 0;
+	clipData.destRect.right = w;
+	clipData.destRect.top = 0;
+	clipData.destRect.bottom = h;
+	
+	if (!clipData.calcClip()) {
+		return;
 	}
-
+   
 	// Transfer buffer data to surface
-	read_p = (src + src_off_x) + (src_w * src_off_y);
-	write_p = (dst_buf + dst_off_x) + (dst_w * dst_off_y);
-
-	for (row = 0; row < src_draw_h; row++) {
-		memcpy(write_p, read_p, src_draw_w);
-
-		write_p += dst_w;
-		read_p += src_w;
-	}
+	readPointer = (sourceBuffer + clipData.drawSource.x) + 
+						(clipData.sourceRect.right * clipData.drawSource.y);
 
-	return SUCCESS;
-}
+	writePointer = ((byte *)pixels + clipData.drawDest.x) + (pitch * clipData.drawDest.y);
 
-// Fills a rectangle in the surface ds from point 'p1' to point 'p2' using
-// the specified color.
-int drawRect(SURFACE *ds, Rect &dst_rect, int color) {
-	dst_rect.clip(ds->w, ds->h);
+	for (row = 0; row < clipData.drawHeight; row++) {
+		memcpy(writePointer, readPointer, clipData.drawWidth);
 
-	if (!dst_rect.isValidRect()) {
-		// Empty or negative region
-		return FAILURE;
+		writePointer += pitch;
+		readPointer += clipData.sourceRect.right;
 	}
-	
-	ds->fillRect(dst_rect, color);
-
-	return SUCCESS;
 }
 
-int drawFrame(SURFACE *ds, const Point *p1, const Point *p2, int color) {
-	int min_x;
-	int max_x;
-	int min_y;
-	int max_y;
-
-	assert((ds != NULL) && (p1 != NULL) && (p2 != NULL));
-	
-	min_x = MIN(p1->x, p2->x);
-	max_x = MAX(p1->x, p2->x);
-	min_y = MIN(p1->y, p2->y);
-	max_y = MAX(p1->y, p2->y);
-
-	ds->frameRect(Common::Rect(min_x, min_y, max_x+1, max_y+1), color);
-
-	return SUCCESS;
-}
-
-int drawPolyLine(SURFACE *ds, const Point *pts, int pt_ct, int draw_color) {
-	assert((ds != NULL) & (pts != NULL));
+void Surface::drawPolyLine(const Point *points, int count, int color) {
+	int i;
+	if (count >= 3) {
+		for (i = 1; i < count; i++) {
+			drawLine(points[i].x, points[i].y, points[i - 1].x, points[i - 1].y, color);
+		}
 
-	if (pt_ct < 3) {
-		return FAILURE;
+		drawLine(points[count - 1].x, points[count - 1].y, points->x, points->y, color);
 	}
-
-	for (int i = 1; i < pt_ct; i++)
-		ds->drawLine(pts[i].x, pts[i].y, pts[i - 1].x, pts[i - 1].y, draw_color);
-
-	ds->drawLine(pts[pt_ct - 1].x, pts[pt_ct - 1].y, pts[0].x, pts[0].y, draw_color);
-
-	return SUCCESS;
 }
 
 
-SURFACE *Gfx::getBackBuffer() {
-	return &_back_buf;
-}
-
-int Gfx::setPalette(PALENTRY *pal) {
+void Gfx::setPalette(PalEntry *pal) {
 	int i;
 	byte *ppal;
 
-	for (i = 0, ppal = _cur_pal; i < PAL_ENTRIES; i++, ppal += 4) {
+	for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
 		ppal[0] = pal[i].red;
 		ppal[1] = pal[i].green;
 		ppal[2] = pal[i].blue;
 		ppal[3] = 0;
 	}
 
-	_system->setPalette(_cur_pal, 0, PAL_ENTRIES);
-
-	return SUCCESS;
+	_system->setPalette(_currentPal, 0, PAL_ENTRIES);
 }
 
-int Gfx::getCurrentPal(PALENTRY *src_pal) {
+void Gfx::getCurrentPal(PalEntry *src_pal) {
 	int i;
 	byte *ppal;
 
-	for (i = 0, ppal = _cur_pal; i < PAL_ENTRIES; i++, ppal += 4) {
+	for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
 		src_pal[i].red = ppal[0];
 		src_pal[i].green = ppal[1];
 		src_pal[i].blue = ppal[2];
 	}
-
-	return SUCCESS;
 }
 
-int Gfx::palToBlack(PALENTRY *src_pal, double percent) {
+void Gfx::palToBlack(PalEntry *src_pal, double percent) {
 	int i;
 	//int fade_max = 255;
 	int new_entry;
@@ -448,7 +168,7 @@
 	fpercent = 1.0 - fpercent;
 
 	// Use the correct percentage change per frame for each palette entry 
-	for (i = 0, ppal = _cur_pal; i < PAL_ENTRIES; i++, ppal += 4) {
+	for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
 		new_entry = (int)(src_pal[i].red * fpercent);
 
 		if (new_entry < 0) {
@@ -475,12 +195,10 @@
 		ppal[3] = 0;
 	}
 
-	_system->setPalette(_cur_pal, 0, PAL_ENTRIES);
-
-	return SUCCESS;
+	_system->setPalette(_currentPal, 0, PAL_ENTRIES);
 }
 
-int Gfx::blackToPal(PALENTRY *src_pal, double percent) {
+void Gfx::blackToPal(PalEntry *src_pal, double percent) {
 	int new_entry;
 	double fpercent;
 	int color_delta;
@@ -501,7 +219,7 @@
 	fpercent = 1.0 - fpercent;
 
 	// Use the correct percentage change per frame for each palette entry
-	for (i = 0, ppal = _cur_pal; i < PAL_ENTRIES; i++, ppal += 4) {
+	for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
 		new_entry = (int)(src_pal[i].red - src_pal[i].red * fpercent);
 
 		if (new_entry < 0) {
@@ -530,7 +248,7 @@
 
 	// Find the best white and black color indices again
 	if (percent >= 1.0) {
-		for (i = 0, ppal = _cur_pal; i < PAL_ENTRIES; i++, ppal += 4) {
+		for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
 			color_delta = ppal[0];
 			color_delta += ppal[1];
 			color_delta += ppal[2];
@@ -547,9 +265,7 @@
 		}
 	}
 
-	_system->setPalette(_cur_pal, 0, PAL_ENTRIES);
-
-	return SUCCESS;
+	_system->setPalette(_currentPal, 0, PAL_ENTRIES);
 }
 
 void Gfx::showCursor(bool state) {

Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/gfx.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- gfx.h	8 Jul 2005 16:55:54 -0000	1.29
+++ gfx.h	9 Jul 2005 16:23:44 -0000	1.30
@@ -40,10 +40,10 @@
 	Point destPoint;
 
 	// output members
-	Point sourceDraw;
-	Point destDraw;
-	int width;
-	int height;
+	Point drawSource;
+	Point drawDest;
+	int drawWidth;
+	int drawHeight;
 
 	bool calcClip() {
 		Common::Rect s;
@@ -61,34 +61,56 @@
 			return false;
 		}
 
-		sourceDraw.x = s.left - sourceRect.left - destPoint.x;
-		sourceDraw.y = s.top - sourceRect.top - destPoint.y;
-		destDraw.x = s.left;
-		destDraw.y = s.top;
-		width = s.width();
-		height = s.height();
+		drawSource.x = s.left - sourceRect.left - destPoint.x;
+		drawSource.y = s.top - sourceRect.top - destPoint.y;
+		drawDest.x = s.left;
+		drawDest.y = s.top;
+		drawWidth = s.width();
+		drawHeight = s.height();
 
 		return true;
 	}
 };
 
-struct PALENTRY {
+struct PalEntry {
 	byte red;
 	byte green;
 	byte blue;
 };
 
-struct COLOR {
+struct Color {
 	int red;
 	int green;
 	int blue;
 	int alpha;
 };
 
-struct SURFACE : Graphics::Surface {
-	Rect clip_rect;
+struct Surface : Graphics::Surface {
+	
+	void drawPalette();
+	void drawPolyLine(const Point *points, int count, int color);
+	void blit(const Common::Rect &destRect, const byte *sourceBuffer);
+
+	void getRect(Common::Rect &rect) {
+		rect.left = rect.top = 0;
+		rect.right = w;
+		rect.bottom = h;
+	}
+	void drawFrame(const Common::Point &p1, const Common::Point &p2, int color) {
+		Common::Rect rect(MIN(p1.x, p2.x), MIN(p1.y, p2.y), MAX(p1.x, p2.x) + 1, MAX(p1.y, p2.y) + 1);
+		frameRect(rect, color);
+	}
+	void drawRect(const Common::Rect &destRect, int color) {
+		Common::Rect rect(w , h);
+		rect.clip(destRect);
+
+		if (rect.isValidRect()) {
+			fillRect(rect, color);
+		}		
+	}
 };
 
+
 #define PAL_ENTRIES 256
 
 #define CURSOR_W 7
@@ -97,33 +119,29 @@
 #define CURSOR_ORIGIN_X 4
 #define CURSOR_ORIGIN_Y 4
 
-int drawPalette(SURFACE *dst_s);
-int bufToSurface(SURFACE *ds, const byte *src, int src_w, int src_h, Rect *src_rect, Point *dst_pt);
-int bufToBuffer(byte * dst_buf, int dst_w, int dst_h, const byte *src,
-	int src_w, int src_h, Rect *src_rect, Point *dst_pt);
-int drawRect(SURFACE *ds, Rect &dst_rect, int color);
-int drawFrame(SURFACE *ds, const Point *p1, const Point *p2, int color);
-int drawPolyLine(SURFACE *ds, const Point *pts, int pt_ct, int draw_color);
-
 bool hitTestPoly(const Point *points, unsigned int npoints, const Point& test_point);
 
 class Gfx {
 public:
 
 	Gfx(OSystem *system, int width, int height, GameDetector &detector);
-	SURFACE *getBackBuffer();
-	int setPalette(PALENTRY *pal);
-	int getCurrentPal(PALENTRY *src_pal);
-	int palToBlack(PALENTRY *src_pal, double percent);
-	int blackToPal(PALENTRY *src_pal, double percent);
+	~Gfx();
+	Surface *getBackBuffer() {
+		return &_backBuffer;
+	}
+
+	void setPalette(PalEntry *pal);
+	void getCurrentPal(PalEntry *src_pal);
+	void palToBlack(PalEntry *src_pal, double percent);
+	void blackToPal(PalEntry *src_pal, double percent);
 	void updateCursor() { setCursor(); }
 	void showCursor(bool state);
 
 private:
 	void setCursor();
 	int _init;
-	SURFACE _back_buf;
-	byte _cur_pal[PAL_ENTRIES * 4];
+	Surface _backBuffer;
+	byte _currentPal[PAL_ENTRIES * 4];
 	OSystem *_system;
 };
 

Index: ihnm_introproc.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/ihnm_introproc.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- ihnm_introproc.cpp	21 Jun 2005 21:59:24 -0000	1.43
+++ ihnm_introproc.cpp	9 Jul 2005 16:23:44 -0000	1.44
@@ -164,9 +164,9 @@
 int Scene::IHNMIntroMovieProc2(int param) {
 	EVENT event;
 	EVENT *q_event;
-	PALENTRY *pal;
+	PalEntry *pal;
 
-	static PALENTRY current_pal[PAL_ENTRIES];
+	static PalEntry current_pal[PAL_ENTRIES];
 
 	switch (param) {
 	case SCENE_BEGIN:
@@ -250,8 +250,8 @@
 int Scene::IHNMIntroMovieProc3(int param) {
 	EVENT event;
 	EVENT *q_event;
-	PALENTRY *pal;
-	static PALENTRY current_pal[PAL_ENTRIES];
+	PalEntry *pal;
+	static PalEntry current_pal[PAL_ENTRIES];
 
 	switch (param) {
 	case SCENE_BEGIN:

Index: interface.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.cpp,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -d -r1.112 -r1.113
--- interface.cpp	8 Jul 2005 16:55:54 -0000	1.112
+++ interface.cpp	9 Jul 2005 16:23:44 -0000	1.113
@@ -500,7 +500,7 @@
 	return _vm->_sprite->loadList(resourceId, _scenePortraits);
 }
 
-void Interface::drawVerbPanel(SURFACE *backBuffer, PanelButton* panelButton) {
+void Interface::drawVerbPanel(Surface *backBuffer, PanelButton* panelButton) {
 	PanelButton * rightButtonVerbPanelButton;
 	PanelButton * currentVerbPanelButton;
 	int textColor;
@@ -534,12 +534,12 @@
 }
 
 void Interface::draw() {
-	SURFACE *backBuffer;
+	Surface *backBuffer;
 	int i;
 
 	Point leftPortraitPoint;
 	Point rightPortraitPoint;	
-	Point origin;
+	Rect rect;
 
 	backBuffer = _vm->_gfx->getBackBuffer();
 
@@ -551,10 +551,9 @@
 
 	if (_panelMode == kPanelMain) {
 
-		origin.x = _mainPanel.x;
-		origin.y = _mainPanel.y;
+		_mainPanel.getRect(rect);		
+		backBuffer->blit(rect, _mainPanel.image);
 
-		bufToSurface(backBuffer, _mainPanel.image, _mainPanel.imageWidth, _mainPanel.imageHeight, NULL, &origin);
 		for (i = 0; i < kVerbTypesMax; i++) {
 			if (_verbTypeToPanelButton[i] != NULL) {
 				drawVerbPanel(backBuffer, _verbTypeToPanelButton[i]);
@@ -563,11 +562,8 @@
 	} else {
 		if (_panelMode == kPanelConverse) {	
 
-			origin.x = _conversePanel.x;
-			origin.y = _conversePanel.y;
-
-			bufToSurface(backBuffer, _conversePanel.image, _conversePanel.imageWidth,
-				_conversePanel.imageHeight, NULL, &origin);
+			_conversePanel.getRect(rect);
+			backBuffer->blit(rect, _conversePanel.image);
 
 			converseDisplayTextLines(backBuffer);
 		}
@@ -633,7 +629,7 @@
 	_optionSaveRectBottom.right--;
 }
 
-void Interface::drawPanelText(SURFACE *ds, InterfacePanel *panel, PanelButton *panelButton) {
+void Interface::drawPanelText(Surface *ds, InterfacePanel *panel, PanelButton *panelButton) {
 	const char *text;
 	int textWidth;
 	Rect rect;
@@ -651,22 +647,20 @@
 
 void Interface::drawOption() {
 	const char *text;
-	SURFACE *backBuffer;
+	Surface *backBuffer;
 	int i;
 	int fontHeight;
 	uint j, idx;
 	int fgColor;
 	int bgColor;
-	Point origin;
 	Rect rect;
 	Rect rect2;
 	PanelButton *panelButton;
 
 	backBuffer = _vm->_gfx->getBackBuffer();
-	origin.x = _vm->getDisplayInfo().optionPanelXOffset;
-	origin.y = _vm->getDisplayInfo().optionPanelYOffset;
 
-	bufToSurface(backBuffer, _optionPanel.image, _optionPanel.imageWidth, _optionPanel.imageHeight, NULL, &origin);
+	_optionPanel.getRect(rect);
+	backBuffer->blit(rect, _optionPanel.image);
 
 	for (i = 0; i < _optionPanel.buttonsCount; i++) {		
 		panelButton = &_optionPanel.buttons[i];
@@ -679,13 +673,13 @@
 	}	
 
 	if (_optionSaveRectTop.height() > 0) {
-		drawRect(backBuffer, _optionSaveRectTop, kITEColorDarkGrey);
+		backBuffer->drawRect(_optionSaveRectTop, kITEColorDarkGrey);
 	}
 	
 	drawButtonBox(backBuffer, _optionSaveRectSlider, kSlider, _optionSaveFileSlider->state > 0);
 
 	if (_optionSaveRectBottom.height() > 0) {
-		drawRect(backBuffer, _optionSaveRectBottom, kITEColorDarkGrey);
+		backBuffer->drawRect(_optionSaveRectBottom, kITEColorDarkGrey);
 	}
 
 	_optionPanel.calcPanelButtonRect(_optionSaveFilePanel, rect);
@@ -713,7 +707,7 @@
 }
 
 void Interface::drawQuit() {
-	SURFACE *backBuffer;
+	Surface *backBuffer;
 	Rect rect;
 	int i;
 	PanelButton *panelButton;
@@ -773,7 +767,7 @@
 }
 
 void Interface::drawLoad() {
-	SURFACE *backBuffer;
+	Surface *backBuffer;
 	Rect rect;
 	int i;
 	PanelButton *panelButton;
@@ -936,7 +930,7 @@
 	}
 }
 
-void Interface::drawTextInput(SURFACE *ds, InterfacePanel *panel, PanelButton *panelButton) {
+void Interface::drawTextInput(Surface *ds, InterfacePanel *panel, PanelButton *panelButton) {
 	Rect rect;
 	char ch[2];
 	int fgColor;
@@ -970,7 +964,7 @@
 }
 
 void Interface::drawSave() {
-	SURFACE *backBuffer;
+	Surface *backBuffer;
 	Rect rect;
 	int i;
 	PanelButton *panelButton;
@@ -1305,7 +1299,7 @@
 }
 
 void Interface::drawStatusBar() {
-	SURFACE *backBuffer;
+	Surface *backBuffer;
 	Rect rect;
 
 	int string_w;
@@ -1327,7 +1321,7 @@
 	rect.right = rect.left + _vm->getDisplayWidth();
 	rect.bottom = rect.top + _vm->getDisplayInfo().statusHeight;
 
-	drawRect(backBuffer, rect, _vm->getDisplayInfo().statusBGColor);
+	backBuffer->drawRect(rect, _vm->getDisplayInfo().statusBGColor);
 
 	string_w = _vm->_font->getStringWidth(SMALL_FONT_ID, _statusText, 0, 0);
 
@@ -1532,7 +1526,7 @@
 	return -1;
 }
 
-void Interface::drawInventory(SURFACE *backBuffer) {
+void Interface::drawInventory(Surface *backBuffer) {
 	if (_panelMode != kPanelMain)
 		return;
 	int i;
@@ -1576,7 +1570,7 @@
 	draw();
 }
 
-void Interface::drawButtonBox(SURFACE *ds, const Rect& rect, ButtonKind kind, bool down) {	
+void Interface::drawButtonBox(Surface *ds, const Rect& rect, ButtonKind kind, bool down) {	
 	byte cornerColor;
 	byte frameColor;
 	byte fillColor;
@@ -1670,7 +1664,7 @@
 	ds->fillRect(fill, solidColor);
 }
 
-void Interface::drawPanelButtonText(SURFACE *ds, InterfacePanel *panel, PanelButton *panelButton) {
+void Interface::drawPanelButtonText(Surface *ds, InterfacePanel *panel, PanelButton *panelButton) {
 	const char *text;
 	int textId;
 	int textWidth;
@@ -1712,7 +1706,7 @@
 		textColor, _vm->getDisplayInfo().verbTextShadowColor, FONT_SHADOW);
 }
 
-void Interface::drawPanelButtonArrow(SURFACE *ds, InterfacePanel *panel, PanelButton *panelButton) {
+void Interface::drawPanelButtonArrow(Surface *ds, InterfacePanel *panel, PanelButton *panelButton) {
 	Point point;
 	int spriteNumber;
 
@@ -1732,7 +1726,7 @@
 	_vm->_sprite->draw(ds, _vm->getDisplayClip(), _vm->_sprite->_mainSprites, spriteNumber, point, 256);
 }
 
-void Interface::drawVerbPanelText(SURFACE *ds, PanelButton *panelButton, int textColor, int textShadowColor) {
+void Interface::drawVerbPanelText(Surface *ds, PanelButton *panelButton, int textColor, int textShadowColor) {
 	const char *text;
 	int textWidth;
 	Point point;
@@ -1858,7 +1852,7 @@
 	}
 }
 
-void Interface::converseDisplayTextLines(SURFACE *ds) {
+void Interface::converseDisplayTextLines(Surface *ds) {
 	int relPos;
 	byte foregnd;
 	byte backgnd;
@@ -1878,7 +1872,7 @@
 	rect.moveTo(_conversePanel.x + _conversePanel.buttons[0].xOffset, 
 		_conversePanel.y + _conversePanel.buttons[0].yOffset);
 
-	drawRect(ds, rect, kITEColorDarkGrey); //fill bullet place
+	ds->drawRect(rect, kITEColorDarkGrey); //fill bullet place
 	
 	for (int i = 0; i < CONVERSE_TEXT_LINES; i++) {
 		relPos = _converseStartPos + i;
@@ -1897,7 +1891,7 @@
 
 		_conversePanel.calcPanelButtonRect(&_conversePanel.buttons[i], rect);
 		rect.left += 8;
-		drawRect(ds, rect, backgnd);
+		ds->drawRect(rect, backgnd);
 
 		str = _converseText[relPos].text;
 
@@ -2023,20 +2017,19 @@
 void Interface::mapPanelShow() {
 	byte *resource;
 	size_t resourceLength, imageLength;
-	SURFACE *backBuffer;
-	Point origin;
+	Surface *backBuffer;
+	Rect rect;
 	byte *image;
 	int imageWidth, imageHeight;
 	int result;
 	const byte *pal;
-	PALENTRY cPal[PAL_ENTRIES];
+	PalEntry cPal[PAL_ENTRIES];
 
 	_vm->_gfx->showCursor(false);
 
 	backBuffer = _vm->_gfx->getBackBuffer();
 
-	origin.x = 0;
-	origin.y = 0;
+	rect.left = rect.top = 0;
 
 	result = RSC_LoadResource(_interfaceContext, RID_ITE_TYCHO_MAP, &resource, &resourceLength);
 	if ((result != SUCCESS) || (resourceLength == 0)) {
@@ -2059,10 +2052,13 @@
 	for (int i = 0; i < PAL_ENTRIES; i++) {
 		cPal[i].red = *pal++;
 		cPal[i].green = *pal++;
-		cPal[i].blue = *pal++;
+		cPal[i].blue = *pal++;	
 	}
 
-	bufToSurface(backBuffer, image, imageWidth, imageHeight, NULL, &origin);
+	rect.setWidth(imageWidth);
+	rect.setHeight(imageHeight);
+
+	backBuffer->blit(rect, image);
 
 	// Evil Evil
 	for (int i = 0; i < 6 ; i++) {
@@ -2080,7 +2076,7 @@
 }
 
 void Interface::mapPanelClean() {
-	PALENTRY pal[PAL_ENTRIES];
+	PalEntry pal[PAL_ENTRIES];
 
 	_vm->_gfx->getCurrentPal(pal);
 
@@ -2104,7 +2100,7 @@
 }
 
 void Interface::mapPanelDrawCrossHair() {
-	SURFACE *backBuffer;
+	Surface *backBuffer;
 
 	backBuffer = _vm->_gfx->getBackBuffer();
 	_mapPanelCrossHairState = !_mapPanelCrossHairState;

Index: interface.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.h,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- interface.h	3 Jul 2005 20:02:56 -0000	1.62
+++ interface.h	9 Jul 2005 16:23:44 -0000	1.63
@@ -110,9 +110,9 @@
 	
 	void getRect(Rect &rect) {
 		rect.left = x;
-		rect.right = rect.left + imageWidth;
 		rect.top = y;
-		rect.bottom = rect.top + imageHeight;
+		rect.setWidth(imageWidth);
+		rect.setHeight(imageHeight);
 	}
  
 	void calcPanelButtonRect(const PanelButton* panelButton, Rect &rect) {
@@ -244,7 +244,7 @@
 private:
 	static void textInputRepeatCallback(void *refCon);
 
-	void drawInventory(SURFACE *backBuffer);
+	void drawInventory(Surface *backBuffer);
 	void updateInventory(int pos);
 	void inventoryChangePos(int chg);
 	void inventorySetPos(int key);
@@ -322,18 +322,18 @@
 	void setLoad(PanelButton *panelButton);
 	void setSave(PanelButton *panelButton);
 
-	void drawTextInput(SURFACE *ds, InterfacePanel *panel, PanelButton *panelButton);
-	void drawPanelText(SURFACE *ds, InterfacePanel *panel, PanelButton *panelButton);
-	void drawPanelButtonText(SURFACE *ds, InterfacePanel *panel, PanelButton *panelButton);
+	void drawTextInput(Surface *ds, InterfacePanel *panel, PanelButton *panelButton);
+	void drawPanelText(Surface *ds, InterfacePanel *panel, PanelButton *panelButton);
+	void drawPanelButtonText(Surface *ds, InterfacePanel *panel, PanelButton *panelButton);
 	enum ButtonKind {
 		kButton,
 		kSlider,
 		kEdit
 	};
-	void drawButtonBox(SURFACE *ds, const Rect &rect, ButtonKind kind, bool down);
-	void drawPanelButtonArrow(SURFACE *ds, InterfacePanel *panel, PanelButton *panelButton);
-	void drawVerbPanelText(SURFACE *ds, PanelButton *panelButton, int textColor, int textShadowColor);
-	void drawVerbPanel(SURFACE *backBuffer, PanelButton* panelButton);
+	void drawButtonBox(Surface *ds, const Rect &rect, ButtonKind kind, bool down);
+	void drawPanelButtonArrow(Surface *ds, InterfacePanel *panel, PanelButton *panelButton);
+	void drawVerbPanelText(Surface *ds, PanelButton *panelButton, int textColor, int textShadowColor);
+	void drawVerbPanel(Surface *backBuffer, PanelButton* panelButton);
 	void calcOptionSaveSlider();
 	void processTextInput(uint16 ascii);
 	void processStatusTextInput(uint16 ascii);
@@ -350,7 +350,7 @@
 	void converseSetPos(int key);
 
 private:
-	void converseDisplayTextLines(SURFACE *ds);
+	void converseDisplayTextLines(Surface *ds);
 	PanelButton *getPanelButtonByVerbType(int verb) {
 		if ((verb < 0) || (verb >= kVerbTypesMax)) {
 			error("Interface::getPanelButtonByVerbType wrong verb");
@@ -442,7 +442,7 @@
 	int _textInputRepeatPhase;
 	uint16 _textInputRepeatChar;
 
-	PALENTRY _mapSavedPal[PAL_ENTRIES];
+	PalEntry _mapSavedPal[PAL_ENTRIES];
 	bool _mapPanelCrossHairState;
 };
 

Index: isomap.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/isomap.cpp,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- isomap.cpp	8 Jul 2005 16:55:54 -0000	1.54
+++ isomap.cpp	9 Jul 2005 16:23:44 -0000	1.55
@@ -377,14 +377,11 @@
 	return 1;
 }
 
-int IsoMap::draw(SURFACE *ds) {
+void IsoMap::draw(Surface *ds) {
 	
-	Rect isoRect(_vm->_scene->getSceneClip());
-	drawRect(ds, isoRect, 0);
-	_tileClip = isoRect;
+	_tileClip = _vm->_scene->getSceneClip();
+	ds->drawRect(_tileClip, 0);
 	drawTiles(ds, NULL);
-
-	return SUCCESS;
 }
 
 void IsoMap::setMapPosition(int x, int y) {
@@ -392,7 +389,7 @@
 	_mapPosition.y = y;
 }
 
-void IsoMap::drawSprite(SURFACE *ds, SpriteList &spriteList, int spriteNumber, const Location &location, const Point &screenPosition, int scale) {
+void IsoMap::drawSprite(Surface *ds, SpriteList &spriteList, int spriteNumber, const Location &location, const Point &screenPosition, int scale) {
 	int width;
 	int height;
 	int xAlign;
@@ -429,7 +426,7 @@
 }
 
 
-void IsoMap::drawTiles(SURFACE *ds,  const Location *location) {
+void IsoMap::drawTiles(Surface *ds,  const Location *location) {
 	Point view1;
 	Point fineScroll;
 	Point tileScroll;
@@ -551,7 +548,7 @@
 
 }
 
-void IsoMap::drawSpriteMetaTile(SURFACE *ds, uint16 metaTileIndex, const Point &point, Location &location, int16 absU, int16 absV) {
+void IsoMap::drawSpriteMetaTile(Surface *ds, uint16 metaTileIndex, const Point &point, Location &location, int16 absU, int16 absV) {
 	MetaTileData * metaTile;
 	uint16 high;
 	int16 platformIndex;
@@ -578,7 +575,7 @@
 	}	
 }
 
-void IsoMap::drawMetaTile(SURFACE *ds, uint16 metaTileIndex, const Point &point, int16 absU, int16 absV) {
+void IsoMap::drawMetaTile(Surface *ds, uint16 metaTileIndex, const Point &point, int16 absU, int16 absV) {
 	MetaTileData * metaTile;
 	uint16 high;
 	int16 platformIndex;
@@ -605,7 +602,7 @@
 	}	
 }
 
-void IsoMap::drawSpritePlatform(SURFACE *ds, uint16 platformIndex, const Point &point, const Location &location, int16 absU, int16 absV, int16 absH) {
+void IsoMap::drawSpritePlatform(Surface *ds, uint16 platformIndex, const Point &point, const Location &location, int16 absU, int16 absV, int16 absH) {
 	TilePlatformData *tilePlatform;
 	int16 u, v;
 	Point s;
@@ -660,7 +657,7 @@
 	}
 }
 
-void IsoMap::drawPlatform(SURFACE *ds, uint16 platformIndex, const Point &point, int16 absU, int16 absV, int16 absH) {
+void IsoMap::drawPlatform(Surface *ds, uint16 platformIndex, const Point &point, int16 absU, int16 absV, int16 absH) {
 	TilePlatformData *tilePlatform;
 	int16 u, v;
 	Point s;
@@ -716,7 +713,7 @@
 #define THRESH8			8
 #define THRESH16		16
 
-void IsoMap::drawTile(SURFACE *ds, uint16 tileIndex, const Point &point, const Location *location) {
+void IsoMap::drawTile(Surface *ds, uint16 tileIndex, const Point &point, const Location *location) {
 	const byte *tilePointer;
 	const byte *readPointer;
 	byte *drawPointer;

Index: isomap.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/isomap.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- isomap.h	1 Jul 2005 17:29:23 -0000	1.23
+++ isomap.h	9 Jul 2005 16:23:44 -0000	1.24
@@ -158,8 +158,8 @@
 	void loadMetaTiles(const byte * resourcePointer, size_t resourceLength);
 	void loadMulti(const byte * resourcePointer, size_t resourceLength);
 	void freeMem();
-	int draw(SURFACE *ds);
-	void drawSprite(SURFACE *ds, SpriteList &spriteList, int spriteNumber, const Location &location, const Point &screenPosition, int scale);
+	void draw(Surface *ds);
+	void drawSprite(Surface *ds, SpriteList &spriteList, int spriteNumber, const Location &location, const Point &screenPosition, int scale);
 	void adjustScroll(bool jump);
 	void tileCoordsToScreenPoint(const Location &location, Point &position) {
 		position.x = location.u() - location.v() + (128 * SAGA_TILEMAP_W) - _viewScroll.x + 16;
@@ -177,12 +177,12 @@
 	int16 getTileIndex(int16 u, int16 v, int16 z);
 
 private:
-	void drawTiles(SURFACE *ds, const Location *location);
-	void drawMetaTile(SURFACE *ds, uint16 metaTileIndex, const Point &point, int16 absU, int16 absV);
-	void drawSpriteMetaTile(SURFACE *ds, uint16 metaTileIndex, const Point &point, Location &location, int16 absU, int16 absV);
-	void drawPlatform(SURFACE *ds, uint16 platformIndex, const Point &point, int16 absU, int16 absV, int16 absH);	
-	void drawSpritePlatform(SURFACE *ds, uint16 platformIndex, const Point &point, const Location &location, int16 absU, int16 absV, int16 absH);	
-	void drawTile(SURFACE *ds, uint16 tileIndex, const Point &point, const Location *location);
+	void drawTiles(Surface *ds, const Location *location);
+	void drawMetaTile(Surface *ds, uint16 metaTileIndex, const Point &point, int16 absU, int16 absV);
+	void drawSpriteMetaTile(Surface *ds, uint16 metaTileIndex, const Point &point, Location &location, int16 absU, int16 absV);
+	void drawPlatform(Surface *ds, uint16 platformIndex, const Point &point, int16 absU, int16 absV, int16 absH);	
+	void drawSpritePlatform(Surface *ds, uint16 platformIndex, const Point &point, const Location &location, int16 absU, int16 absV, int16 absH);	
+	void drawTile(Surface *ds, uint16 tileIndex, const Point &point, const Location *location);
 	int16 smoothSlide(int16 value, int16 min, int16 max) {
 		if (value < min) {
 			if (value < min - 100 || value > min - 4) {

Index: objectmap.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/objectmap.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- objectmap.cpp	3 Apr 2005 15:32:03 -0000	1.40
+++ objectmap.cpp	9 Jul 2005 16:23:44 -0000	1.41
@@ -132,7 +132,7 @@
 	return false;
 }
 
-void HitZone::draw(SURFACE *ds, int color) {
+void HitZone::draw(Surface *ds, int color) {
 	int i, pointsCount, j;
 	Location location;
 	HitZone::ClickArea *clickArea;
@@ -155,11 +155,11 @@
 
 		if (pointsCount == 2) {
 			// 2 points represent a box
-			drawFrame(ds, &points[0], &points[1], color);
+			ds->drawFrame(points[0], points[1], color);
 		} else {
 			if (pointsCount > 2) {
 				// Otherwise draw a polyline
-				drawPolyLine(ds, points, pointsCount, color);
+				ds->drawPolyLine(points, pointsCount, color);
 			}
 		}
 		if (_vm->_scene->getFlags() & kSceneFlagISO) {
@@ -214,7 +214,7 @@
 
 
 
-void ObjectMap::draw(SURFACE *ds, const Point& testPoint, int color, int color2) {
+void ObjectMap::draw(Surface *ds, const Point& testPoint, int color, int color2) {
 	int i;
 	int hitZoneIndex;
 	char txtBuf[32];

Index: objectmap.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/objectmap.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- objectmap.h	16 Apr 2005 20:59:24 -0000	1.21
+++ objectmap.h	9 Jul 2005 16:23:44 -0000	1.22
@@ -76,7 +76,7 @@
 		return objectIndexToId(kGameObjectStepZone, _index);
 	}
 	bool getSpecialPoint(Point &specialPoint) const;
-	void draw(SURFACE *ds, int color);	
+	void draw(Surface *ds, int color);	
 	bool hitTest(const Point &testPoint);
 
 private:
@@ -104,7 +104,7 @@
 	void load(const byte *resourcePointer, size_t resourceLength);
 	void freeMem(void);
 
-	void draw(SURFACE *drawSurface, const Point& testPoint, int color, int color2);
+	void draw(Surface *drawSurface, const Point& testPoint, int color, int color2);
 	int hitTest(const Point& testPoint);
 	HitZone *getHitZone(int16 index) {
 		if ((index < 0) || (index >= _hitZoneListCount)) {

Index: palanim.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/palanim.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- palanim.cpp	5 Jul 2005 16:58:33 -0000	1.23
+++ palanim.cpp	9 Jul 2005 16:23:44 -0000	1.24
@@ -95,13 +95,13 @@
 
 		debug(2, "PalAnim::loadPalAnim(): Entry %d: Loading %d SAGA_COLOR structures.", i, color_count);
 
-		test_p = calloc(1, sizeof(COLOR) * color_count);
+		test_p = calloc(1, sizeof(Color) * color_count);
 		if (test_p == NULL) {
 			warning("PalAnim::loadPalAnim(): Allocation failure");
 			return MEM;
 		}
 
-		_entries[i].colors = (COLOR *)test_p;
+		_entries[i].colors = (Color *)test_p;
 
 		for (p = 0; p < pal_count; p++) {
 			_entries[i].pal_index[p] = readS.readByte();
@@ -136,7 +136,7 @@
 }
 
 int PalAnim::cycleStep(int vectortime) {
-	static PALENTRY pal[256];
+	static PalEntry pal[256];
 	uint16 pal_index;
 	uint16 col_index;
 

Index: palanim.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/palanim.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- palanim.h	1 Jan 2005 16:18:36 -0000	1.9
+++ palanim.h	9 Jul 2005 16:23:44 -0000	1.10
@@ -35,7 +35,7 @@
 	uint16 color_count;
 	uint16 cycle;
 	byte *pal_index;
-	COLOR *colors;
+	Color *colors;
 };
 
 struct PALANIM_DATA {

Index: puzzle.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/puzzle.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- puzzle.cpp	8 Jul 2005 16:55:55 -0000	1.9
+++ puzzle.cpp	9 Jul 2005 16:23:44 -0000	1.10
@@ -261,7 +261,7 @@
 
 void Puzzle::showPieces(void) {
 	ActorData *puzzle = _vm->_actor->getActor(_vm->_actor->actorIndexToId(ITE_ACTOR_PUZZLE));
-	SURFACE *backBuffer = _vm->_gfx->getBackBuffer();
+	Surface *backBuffer = _vm->_gfx->getBackBuffer();
 
 	for (int j = PUZZLE_PIECES - 1 ; j >= 0; j--) {
 		int num = _piecePriority[j];
@@ -274,7 +274,7 @@
 
 void Puzzle::drawCurrentPiece() {
 	ActorData *puzzle = _vm->_actor->getActor(_vm->_actor->actorIndexToId(ITE_ACTOR_PUZZLE));
-	SURFACE *backBuffer = _vm->_gfx->getBackBuffer();
+	Surface *backBuffer = _vm->_gfx->getBackBuffer();
 
 	_vm->_sprite->draw(backBuffer, _vm->_scene->getSceneClip(), puzzle->spriteList, _puzzlePiece, 
 			   Point(_pieceInfo[_puzzlePiece].curX, _pieceInfo[_puzzlePiece].curY), 256);

Index: render.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/render.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- render.cpp	5 Jul 2005 15:15:34 -0000	1.65
+++ render.cpp	9 Jul 2005 16:23:44 -0000	1.66
@@ -46,37 +46,11 @@
 	_system = system;
 	_initialized = false;
 
-	int tmp_w, tmp_h, tmp_bytepp;
-
-
 	// Initialize FPS timer callback
 	Common::g_timer->installTimerProc(&fpsTimerCallback, 1000000, this);
 
-	// Create background buffer 
-	_bg_buf_w = _vm->getDisplayWidth();
-	_bg_buf_h = _vm->getDisplayHeight();
-	_bg_buf = (byte *)calloc(_vm->getDisplayWidth(), _vm->getDisplayHeight());
-
-	if (_bg_buf == NULL) {
-		memoryError("Render::Render");
-	}
-
-	// Allocate temp buffer for animation decoding, 
-	// graphics scalers (2xSaI), etc.
-	tmp_w = _vm->getDisplayWidth();
-	tmp_h = _vm->getDisplayHeight() + 4; // BG unbanking requres extra rows
-	tmp_bytepp = 1;
-
-	_tmp_buf = (byte *)calloc(1, tmp_w * tmp_h * tmp_bytepp);
-	if (_tmp_buf == NULL) {
-		free(_bg_buf);
-		return;
-	}
-
-	_tmp_buf_w = tmp_w;
-	_tmp_buf_h = tmp_h;
+	_backGroundSurface.create(_vm->getDisplayWidth(), _vm->getDisplayHeight(), 1);
 
-	_backbuf_surface = _vm->_gfx->getBackBuffer();
 	_flags = 0;
 
 	_initialized = true;
@@ -84,8 +58,7 @@
 
 Render::~Render(void) {
 	Common::g_timer->removeTimerProc(&fpsTimerCallback);
-	free(_bg_buf);
-	free(_tmp_buf);
+	_backGroundSurface.free();
 
 	_initialized = false;
 }
@@ -94,19 +67,17 @@
 	return _initialized;
 }
 
-int Render::drawScene() {
-	SURFACE *backbuf_surface;
+void Render::drawScene() {
+	Surface *backBufferSurface;
 	char txt_buf[20];
 	int fps_width;
 	Point mouse_pt;
 
-	if (!_initialized) {
-		return FAILURE;
-	}
+	assert(_initialized);
 
-	_framecount++;
+	_frameCount++;
 
-	backbuf_surface = _backbuf_surface;
+	backBufferSurface = _vm->_gfx->getBackBuffer();
 
 	// Get mouse coordinates
 	mouse_pt = _vm->mousePos();
@@ -127,9 +98,9 @@
 
 			if (getFlags() & RF_OBJECTMAP_TEST) {
 				if (_vm->_scene->_objectMap)
-					_vm->_scene->_objectMap->draw(backbuf_surface, mouse_pt, kITEColorBrightWhite, kITEColorBlack);
+					_vm->_scene->_objectMap->draw(backBufferSurface, mouse_pt, kITEColorBrightWhite, kITEColorBlack);
 				if (_vm->_scene->_actionMap)
-					_vm->_scene->_actionMap->draw(backbuf_surface, mouse_pt, kITEColorRed, kITEColorBlack);
+					_vm->_scene->_actionMap->draw(backBufferSurface, mouse_pt, kITEColorRed, kITEColorBlack);
 			}
 			if (getFlags() & RF_ACTOR_PATH_TEST) {
 				_vm->_actor->drawPathTest();
@@ -158,7 +129,7 @@
 	}
 
 	// Draw queued text strings
-	_vm->textDrawList(_vm->_scene->_textList, backbuf_surface);
+	_vm->textDrawList(_vm->_scene->_textList, backBufferSurface);
 
 	// Handle user input
 	_vm->processInput();
@@ -167,7 +138,7 @@
 	if (_flags & RF_SHOW_FPS) {
 		sprintf(txt_buf, "%d", _fps);
 		fps_width = _vm->_font->getStringWidth(SMALL_FONT_ID, txt_buf, 0, FONT_NORMAL);
-		_vm->_font->draw(SMALL_FONT_ID, backbuf_surface, txt_buf, 0, backbuf_surface->w - fps_width, 2,
+		_vm->_font->draw(SMALL_FONT_ID, backBufferSurface, txt_buf, 0, backBufferSurface->w - fps_width, 2,
 					kITEColorBrightWhite, kITEColorBlack, FONT_OUTLINE);
 	}
 
@@ -175,8 +146,8 @@
 	if (_flags & RF_RENDERPAUSE) {
 		int msg_len = strlen(PAUSEGAME_MSG);
 		int msg_w = _vm->_font->getStringWidth(BIG_FONT_ID, PAUSEGAME_MSG, msg_len, FONT_OUTLINE);
-		_vm->_font->draw(BIG_FONT_ID, backbuf_surface, PAUSEGAME_MSG, msg_len,
-				(backbuf_surface->w - msg_w) / 2, 90, kITEColorBrightWhite, kITEColorBlack, FONT_OUTLINE);
+		_vm->_font->draw(BIG_FONT_ID, backBufferSurface, PAUSEGAME_MSG, msg_len,
+				(backBufferSurface->w - msg_w) / 2, 90, kITEColorBrightWhite, kITEColorBlack, FONT_OUTLINE);
 	}
 
 	// Update user interface
@@ -185,32 +156,19 @@
 
 	// Display text formatting test, if applicable
 	if (_flags & RF_TEXT_TEST) {
-		_vm->textDraw(MEDIUM_FONT_ID, backbuf_surface, test_txt, mouse_pt.x, mouse_pt.y,
+		_vm->textDraw(MEDIUM_FONT_ID, backBufferSurface, test_txt, mouse_pt.x, mouse_pt.y,
 				kITEColorBrightWhite, kITEColorBlack, FONT_OUTLINE | FONT_CENTERED);
 	}
 
 	// Display palette test, if applicable
 	if (_flags & RF_PALETTE_TEST) {
-		drawPalette(backbuf_surface);
+		backBufferSurface->drawPalette();
 	}
 
-	_system->copyRectToScreen((byte *)backbuf_surface->pixels, backbuf_surface->w, 0, 0, 
-							  backbuf_surface->w, backbuf_surface->h);
+	_system->copyRectToScreen((byte *)backBufferSurface->pixels, backBufferSurface->w, 0, 0, 
+							  backBufferSurface->w, backBufferSurface->h);
 
 	_system->updateScreen();
-	return SUCCESS;
-}
-
-unsigned int Render::getFrameCount() {
-	return _framecount;
-}
-
-unsigned int Render::resetFrameCount() {
-	unsigned int framecount = _framecount;
-
-	_framecount = 0;
-
-	return framecount;
 }
 
 void Render::fpsTimerCallback(void *refCon) {
@@ -218,38 +176,8 @@
 }
 
 void Render::fpsTimer(void) {
-	_fps = _framecount;
-	_framecount = 0;
-}
-
-unsigned int Render::getFlags() {
-	return _flags;
-}
-
-void Render::setFlag(unsigned int flag) {
-	_flags |= flag;
-}
-
-void Render::clearFlag(unsigned int flag) {
-	_flags &= ~flag;
-}
-
-void Render::toggleFlag(unsigned int flag) {
-	_flags ^= flag;
-}
-
-int Render::getBufferInfo(BUFFER_INFO *bufinfo) {
-	assert(bufinfo != NULL);
-
-	bufinfo->bg_buf = _bg_buf;
-	bufinfo->bg_buf_w = _bg_buf_w;
-	bufinfo->bg_buf_h = _bg_buf_h;
-
-	bufinfo->tmp_buf = _tmp_buf;
-	bufinfo->tmp_buf_w = _tmp_buf_w;
-	bufinfo->tmp_buf_h = _tmp_buf_h;
-
-	return SUCCESS;
+	_fps = _frameCount;
+	_frameCount = 0;
 }
 
 } // End of namespace Saga

Index: render.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/render.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- render.h	5 Jul 2005 15:15:34 -0000	1.24
+++ render.h	9 Jul 2005 16:23:45 -0000	1.25
@@ -44,28 +44,32 @@
 	RF_DISABLE_ACTORS = (1 << 9)
 };
 
-struct BUFFER_INFO {
-	byte *bg_buf;
-	int bg_buf_w;
-	int bg_buf_h;
-	byte *tmp_buf;
-	int tmp_buf_w;
-	int tmp_buf_h;
-};
-
 class Render {
 public:
 	Render(SagaEngine *vm, OSystem *system);
 	~Render(void);
 	bool initialized();
-	int drawScene(void);
-	unsigned int getFlags(void);
-	void setFlag(unsigned int);
-	void clearFlag(unsigned int);
-	void toggleFlag(unsigned int);
-	unsigned int getFrameCount(void);
-	unsigned int resetFrameCount(void);
-	int getBufferInfo(BUFFER_INFO *);
+	void drawScene(void);
+
+	unsigned int getFlags() const {
+		return _flags;
+	}
+
+	void setFlag(unsigned int flag) {
+		_flags |= flag;
+	}
+
+	void clearFlag(unsigned int flag) {
+		_flags &= ~flag;
+	}
+
+	void toggleFlag(unsigned int flag) {
+		_flags ^= flag;
+	}
+
+	Surface *getBackGroundSurface() {
+		return &_backGroundSurface;
+	}
 
 private:
 	static void fpsTimerCallback(void *refCon);
@@ -76,19 +80,10 @@
 	bool _initialized;
 
 	// Module data
-	SURFACE *_backbuf_surface;
-
-	byte *_bg_buf;
-	int _bg_buf_w;
-	int _bg_buf_h;
-	byte *_tmp_buf;
-	int _tmp_buf_w;
-	int _tmp_buf_h;
-
-	SpriteList *_test_sprite;
+	Surface _backGroundSurface;
 
 	unsigned int _fps;
-	unsigned int _framecount;
+	unsigned int _frameCount;
 	uint32 _flags;
 };
 

Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- saga.h	9 Jul 2005 10:34:09 -0000	1.103
+++ saga.h	9 Jul 2005 16:23:45 -0000	1.104
@@ -577,15 +577,15 @@
 	TEXTLIST *textCreateList();
 	void textDestroyList(TEXTLIST *textlist);
 	void textClearList(TEXTLIST *textlist);
-	int textDrawList(TEXTLIST *textlist, SURFACE *ds);
+	int textDrawList(TEXTLIST *textlist, Surface *ds);
 	TEXTLIST_ENTRY *textAddEntry(TEXTLIST *textlist, TEXTLIST_ENTRY *entry);
 	int textDeleteEntry(TEXTLIST *textlist, TEXTLIST_ENTRY *entry);
 	int textSetDisplay(TEXTLIST_ENTRY *entry, int val);
-	int textDraw(int font_id, SURFACE *ds, const char *string, int text_x, int text_y, int color,
+	int textDraw(int font_id, Surface *ds, const char *string, int text_x, int text_y, int color,
 				  int effect_color, int flags);
 	int textProcessList(TEXTLIST *textlist, long ms);
 
-	int transitionDissolve(byte *dst_img, int dst_w, int dst_h, int dst_p, 
+	int transitionDissolve(byte *dst_img, int dst_w, int dst_h,
 			const byte *src_img, int src_w, int src_h, int flags, int x, int y, 
 			double percent);
 

Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.cpp,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- scene.cpp	9 Jul 2005 10:34:09 -0000	1.119
+++ scene.cpp	9 Jul 2005 16:23:45 -0000	1.120
@@ -284,7 +284,7 @@
 	bgInfo.bounds.setHeight(_bg.h);
 }
 
-int Scene::getBGPal(PALENTRY **pal) {
+int Scene::getBGPal(PalEntry **pal) {
 	assert(_initialized);
 	*pal = _bg.pal;
 
@@ -383,7 +383,7 @@
 	int i;
 	EVENT event;
 	EVENT *q_event;
-	static PALENTRY current_pal[PAL_ENTRIES];
+	static PalEntry current_pal[PAL_ENTRIES];
 
 	if (_sceneLoaded) {
 		error("Scene::loadScene(): Error, a scene is already loaded");
@@ -852,7 +852,7 @@
 			break;
 		case SAGA_PALETTE:
 			{
-				PALENTRY pal[PAL_ENTRIES];
+				PalEntry pal[PAL_ENTRIES];
 				byte *palPtr = resourceData;
 
 				if (resourceDataLength < 3 * PAL_ENTRIES)
@@ -875,27 +875,30 @@
 }
 
 void Scene::draw() {
-	SURFACE *backBuffer;
-	BUFFER_INFO buf_info;
-	Point bgPoint(0, 0);
-
-	assert(_initialized);
+	Surface *backBuffer;
+	Surface *backGroundSurface;
+	Rect rect;
 
 	backBuffer = _vm->_gfx->getBackBuffer();
 
-	_vm->_render->getBufferInfo(&buf_info);
+	backGroundSurface = _vm->_render->getBackGroundSurface();
 
 	if (_sceneDescription.flags & kSceneFlagISO) {
 		_vm->_isoMap->adjustScroll(false);
 		_vm->_isoMap->draw(backBuffer);
 	} else {
-		
-		bufToSurface(backBuffer, buf_info.bg_buf, buf_info.bg_buf_w,
-			_sceneClip.bottom < buf_info.bg_buf_h ? _vm->getSceneHeight() : buf_info.bg_buf_h, NULL, &bgPoint);
+		backGroundSurface->getRect(rect);
+		if (_sceneClip.bottom < rect.bottom) {
+			rect.bottom = _vm->getSceneHeight();
+		}
+		backBuffer->blit(rect, (const byte *)backGroundSurface->pixels);
 	}
 }
 
 void Scene::endScene() {
+	Surface *backBuffer;
+	Surface *backGroundSurface;
+	Rect rect;
 	int i;
 
 	if (!_sceneLoaded)
@@ -912,11 +915,11 @@
 	_vm->_script->_skipSpeeches = false;
 
 	// Copy current screen to render buffer so inset rooms will get proper background
-	SURFACE *back_buf = _vm->_gfx->getBackBuffer();
-	BUFFER_INFO rbuf_info;
+	backBuffer= _vm->_gfx->getBackBuffer();
+	backGroundSurface = _vm->_render->getBackGroundSurface();
+	backBuffer->getRect(rect);
 
-	_vm->_render->getBufferInfo(&rbuf_info);
-	bufToBuffer(rbuf_info.bg_buf, rbuf_info.bg_buf_w, rbuf_info.bg_buf_h, (byte *)back_buf->pixels, back_buf->w, back_buf->h, NULL, NULL);
+	backGroundSurface->blit(rect, (const byte *)backBuffer->pixels);
 	// Free scene background
 	if (_bg.loaded) {
 		free(_bg.buf);

Index: scene.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.h,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- scene.h	8 Jul 2005 18:39:53 -0000	1.60
+++ scene.h	9 Jul 2005 16:23:45 -0000	1.61
@@ -133,7 +133,7 @@
 	}
 };
 
-struct SCENE_IMAGE {
+struct SceneImage {
 	int loaded;
 	int w;
 	int h;
@@ -142,7 +142,7 @@
 	size_t buf_len;
 	byte *res_buf;
 	size_t res_len;
-	PALENTRY pal[256];
+	PalEntry pal[256];
 };
 
 
@@ -241,7 +241,7 @@
 	void initDoorsState();
 
 	void getBGInfo(BGInfo &bgInfo);
-	int getBGPal(PALENTRY **pal);
+	int getBGPal(PalEntry **pal);
 	void getSlopes(int &beginSlope, int &endSlope);
 
 	void clearSceneQueue(void) {
@@ -289,8 +289,8 @@
 	int _resListEntries;
 	SCENE_RESLIST *_resList;
 	SceneProc *_sceneProc;
-	SCENE_IMAGE _bg;
-	SCENE_IMAGE _bgMask;
+	SceneImage _bg;
+	SceneImage _bgMask;
 	Common::Rect _sceneClip;
 
 	int _sceneDoors[SCENE_DOORS_MAX];

Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -d -r1.136 -r1.137
--- sfuncs.cpp	9 Jul 2005 10:34:09 -0000	1.136
+++ sfuncs.cpp	9 Jul 2005 16:23:45 -0000	1.137
@@ -1192,9 +1192,9 @@
 // Param1: string rid
 void Script::sfPlacard(SCRIPTFUNC_PARAMS) {
 	int stringId;
-	SURFACE *back_buf = _vm->_gfx->getBackBuffer();
-	static PALENTRY cur_pal[PAL_ENTRIES];
-	PALENTRY *pal;
+	Surface *backBuffer = _vm->_gfx->getBackBuffer();
+	static PalEntry cur_pal[PAL_ENTRIES];
+	PalEntry *pal;
 	EVENT event;
 	EVENT *q_event;
 	
@@ -1238,7 +1238,7 @@
 	event.type = ONESHOT_EVENT;
 	event.code = GRAPHICS_EVENT;
 	event.op = EVENT_FILL_RECT;
-	event.data = back_buf;
+	event.data = backBuffer;
 	event.param = 138;
 	event.param2 = 0;
 	event.param3 = _vm->getSceneHeight();
@@ -1294,8 +1294,8 @@
 
 // Script function #49 (0x31)
 void Script::sfPlacardOff(SCRIPTFUNC_PARAMS) {
-	static PALENTRY cur_pal[PAL_ENTRIES];
-	PALENTRY *pal;
+	static PalEntry cur_pal[PAL_ENTRIES];
+	PalEntry *pal;
 	EVENT event;
 	EVENT *q_event;
 
@@ -1555,18 +1555,13 @@
 
 // Script function #62 (0x3E)
 void Script::sfEraseDelta(SCRIPTFUNC_PARAMS) {
-	BUFFER_INFO bufferInfo;
+	Surface *backGroundSurface;
 	BGInfo backGroundInfo;
-	Point backGroundPoint;
 
-	_vm->_render->getBufferInfo(&bufferInfo);
+	backGroundSurface = _vm->_render->getBackGroundSurface();
 	_vm->_scene->getBGInfo(backGroundInfo);
-	backGroundPoint.x = backGroundInfo.bounds.left;
-	backGroundPoint.y = backGroundInfo.bounds.top;
 
-	bufToBuffer(bufferInfo.bg_buf, bufferInfo.bg_buf_w, bufferInfo.bg_buf_h,
-				backGroundInfo.buffer, backGroundInfo.bounds.width(), backGroundInfo.bounds.height(), 
-				NULL, &backGroundPoint);
+	backGroundSurface->blit(backGroundInfo.bounds, backGroundInfo.buffer);
 }
 
 // Script function #63 (0x3F)

Index: sprite.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sprite.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- sprite.cpp	8 Jul 2005 16:56:01 -0000	1.56
+++ sprite.cpp	9 Jul 2005 16:23:45 -0000	1.57
@@ -170,7 +170,7 @@
 
 }
 
-void Sprite::drawClip(SURFACE *ds, const Rect &clipRect, const Point &spritePointer, int width, int height, const byte *spriteBuffer) {
+void Sprite::drawClip(Surface *ds, const Rect &clipRect, const Point &spritePointer, int width, int height, const byte *spriteBuffer) {
 	int clipWidth;
 	int clipHeight;
 
@@ -217,7 +217,7 @@
 	}
 }
 
-void Sprite::draw(SURFACE *ds, const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Point &screenCoord, int scale) {
+void Sprite::draw(Surface *ds, const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Point &screenCoord, int scale) {
 	const byte *spriteBuffer;
 	int width;
 	int height;
@@ -232,7 +232,7 @@
 	drawClip(ds, clipRect, spritePointer, width, height, spriteBuffer);
 }
 
-void Sprite::draw(SURFACE *ds, const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Rect &screenRect, int scale) {
+void Sprite::draw(Surface *ds, const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Rect &screenRect, int scale) {
 	const byte *spriteBuffer;
 	int width;
 	int height;
@@ -283,7 +283,7 @@
 	return *srcRowPointer != 0; 
 }
 
-void Sprite::drawOccluded(SURFACE *ds, const Rect &clipRect, SpriteList &spriteList, int spriteNumber, const Point &screenCoord, int scale, int depth) {
+void Sprite::drawOccluded(Surface *ds, const Rect &clipRect, SpriteList &spriteList, int spriteNumber, const Point &screenCoord, int scale, int depth) {
 	const byte *spriteBuffer;
 	int x, y;
 	byte *destRowPointer;
@@ -333,16 +333,16 @@
 	}
 
 	// Finally, draw the occluded sprite
-	sourceRowPointer = spriteBuffer + clipData.sourceDraw.x + (clipData.sourceDraw.y * width);
+	sourceRowPointer = spriteBuffer + clipData.drawSource.x + (clipData.drawSource.y * width);
 	
-	destRowPointer = (byte *)ds->pixels + clipData.destDraw.x + (clipData.destDraw.y * ds->pitch);
-	maskRowPointer = maskBuffer + clipData.destDraw.x + (clipData.destDraw.y * maskWidth);
+	destRowPointer = (byte *)ds->pixels + clipData.drawDest.x + (clipData.drawDest.y * ds->pitch);
+	maskRowPointer = maskBuffer + clipData.drawDest.x + (clipData.drawDest.y * maskWidth);
 
-	for (y = 0; y < clipData.height; y++) {
+	for (y = 0; y < clipData.drawHeight; y++) {
 		sourcePointer = sourceRowPointer;
 		destPointer = destRowPointer;
 		maskPointer = maskRowPointer;
-		for (x = 0; x < clipData.width; x++) {
+		for (x = 0; x < clipData.drawWidth; x++) {
 			if (*sourcePointer != 0) {
 				maskZ = *maskPointer & SPRITE_ZMASK;
 				if (maskZ > depth) {

Index: sprite.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sprite.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- sprite.h	8 Jul 2005 16:56:03 -0000	1.20
+++ sprite.h	9 Jul 2005 16:23:45 -0000	1.21
@@ -71,15 +71,15 @@
 	~Sprite(void);
 	
 	// draw scaled sprite using background scene mask
-	void drawOccluded(SURFACE *ds, const Rect &clipRect, SpriteList &spriteList, int spriteNumber, const Point &screenCoord, int scale, int depth);
+	void drawOccluded(Surface *ds, const Rect &clipRect, SpriteList &spriteList, int spriteNumber, const Point &screenCoord, int scale, int depth);
 
 	// draw scaled sprite using background scene mask
-	void draw(SURFACE *ds, const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Point &screenCoord, int scale);
+	void draw(Surface *ds, const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Point &screenCoord, int scale);
 
 	// main function
-	void drawClip(SURFACE *ds, const Rect &clipRect, const Point &spritePointer, int width, int height, const byte *spriteBuffer);
+	void drawClip(Surface *ds, const Rect &clipRect, const Point &spritePointer, int width, int height, const byte *spriteBuffer);
 
-	void draw(SURFACE *ds, const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Rect &screenRect, int scale);
+	void draw(Surface *ds, const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Rect &screenRect, int scale);
 
 	int loadList(int resourceId, SpriteList &spriteList); // load or append spriteList
 	bool hitTest(SpriteList &spriteList, int spriteNumber, const Point &screenCoord, int scale, const Point &testPoint);

Index: text.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/text.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- text.cpp	1 Jan 2005 16:18:36 -0000	1.12
+++ text.cpp	9 Jul 2005 16:23:45 -0000	1.13
@@ -32,7 +32,7 @@
 
 namespace Saga {
 
-int SagaEngine::textDraw(int font_id, SURFACE *ds, const char *string, int text_x, int text_y, int color,
+int SagaEngine::textDraw(int font_id, Surface *ds, const char *string, int text_x, int text_y, int color,
 				int effect_color, int flags) {
 	int string_w;
 	int string_len;
@@ -172,7 +172,7 @@
 	return;
 }
 
-int SagaEngine::textDrawList(TEXTLIST *textlist, SURFACE *ds) {
+int SagaEngine::textDrawList(TEXTLIST *textlist, Surface *ds) {
 	TEXTLIST_ENTRY *entry_p;
 
 	assert((textlist != NULL) && (ds != NULL));

Index: transitions.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/transitions.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- transitions.cpp	8 Jul 2005 16:56:03 -0000	1.14
+++ transitions.cpp	9 Jul 2005 16:23:45 -0000	1.15
@@ -30,7 +30,7 @@
  * Dissolve one image with another.
  * If flags if set to 1, do zero masking.
  */
-int SagaEngine::transitionDissolve(byte *dst_img, int dst_w, int dst_h, int dst_p, const byte *src_img,
+int SagaEngine::transitionDissolve(byte *dst_img, int dst_w, int dst_h, const byte *src_img,
 						int src_w, int src_h, int flags, int x, int y, 
 						double percent) {
 #define XOR_MASK 0xB400;





More information about the Scummvm-git-logs mailing list