[Scummvm-cvs-logs] SF.net SVN: scummvm: [32042] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Mon May 12 00:32:37 CEST 2008


Revision: 32042
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32042&view=rev
Author:   lordhoto
Date:     2008-05-11 15:32:37 -0700 (Sun, 11 May 2008)

Log Message:
-----------
Consisteny fixes:
 - Renamed classes *_v1 -> *_LoK
 - Renamed files *_v1.* -> *_lok.*
 - Renamed WSAMovieV1 -> WSAMovie_v1
 - Renamed WSAMovieV2 -> WSAMovie_v2

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/debugger.cpp
    scummvm/trunk/engines/kyra/debugger.h
    scummvm/trunk/engines/kyra/detection.cpp
    scummvm/trunk/engines/kyra/gui_hof.cpp
    scummvm/trunk/engines/kyra/kyra_hof.cpp
    scummvm/trunk/engines/kyra/kyra_hof.h
    scummvm/trunk/engines/kyra/kyra_mr.cpp
    scummvm/trunk/engines/kyra/kyra_mr.h
    scummvm/trunk/engines/kyra/kyra_v2.h
    scummvm/trunk/engines/kyra/module.mk
    scummvm/trunk/engines/kyra/scene_hof.cpp
    scummvm/trunk/engines/kyra/seqplayer.cpp
    scummvm/trunk/engines/kyra/seqplayer.h
    scummvm/trunk/engines/kyra/sequences_hof.cpp
    scummvm/trunk/engines/kyra/sprites.cpp
    scummvm/trunk/engines/kyra/sprites.h
    scummvm/trunk/engines/kyra/staticres.cpp
    scummvm/trunk/engines/kyra/wsamovie.cpp
    scummvm/trunk/engines/kyra/wsamovie.h

Added Paths:
-----------
    scummvm/trunk/engines/kyra/animator_lok.cpp
    scummvm/trunk/engines/kyra/animator_lok.h
    scummvm/trunk/engines/kyra/gui_lok.cpp
    scummvm/trunk/engines/kyra/gui_lok.h
    scummvm/trunk/engines/kyra/items_lok.cpp
    scummvm/trunk/engines/kyra/kyra_lok.cpp
    scummvm/trunk/engines/kyra/kyra_lok.h
    scummvm/trunk/engines/kyra/saveload_lok.cpp
    scummvm/trunk/engines/kyra/scene_lok.cpp
    scummvm/trunk/engines/kyra/screen_lok.cpp
    scummvm/trunk/engines/kyra/screen_lok.h
    scummvm/trunk/engines/kyra/script_lok.cpp
    scummvm/trunk/engines/kyra/sequences_lok.cpp
    scummvm/trunk/engines/kyra/sound_lok.cpp
    scummvm/trunk/engines/kyra/text_lok.cpp
    scummvm/trunk/engines/kyra/timer_lok.cpp

Removed Paths:
-------------
    scummvm/trunk/engines/kyra/animator_v1.cpp
    scummvm/trunk/engines/kyra/animator_v1.h
    scummvm/trunk/engines/kyra/gui_v1.cpp
    scummvm/trunk/engines/kyra/gui_v1.h
    scummvm/trunk/engines/kyra/items_v1.cpp
    scummvm/trunk/engines/kyra/kyra_v1.cpp
    scummvm/trunk/engines/kyra/kyra_v1.h
    scummvm/trunk/engines/kyra/saveload_v1.cpp
    scummvm/trunk/engines/kyra/scene_v1.cpp
    scummvm/trunk/engines/kyra/screen_v1.cpp
    scummvm/trunk/engines/kyra/screen_v1.h
    scummvm/trunk/engines/kyra/script_v1.cpp
    scummvm/trunk/engines/kyra/sequences_v1.cpp
    scummvm/trunk/engines/kyra/sound_v1.cpp
    scummvm/trunk/engines/kyra/text_v1.cpp
    scummvm/trunk/engines/kyra/timer_v1.cpp

Copied: scummvm/trunk/engines/kyra/animator_lok.cpp (from rev 32035, scummvm/trunk/engines/kyra/animator_v1.cpp)
===================================================================
--- scummvm/trunk/engines/kyra/animator_lok.cpp	                        (rev 0)
+++ scummvm/trunk/engines/kyra/animator_lok.cpp	2008-05-11 22:32:37 UTC (rev 32042)
@@ -0,0 +1,691 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/endian.h"
+
+#include "kyra/kyra_lok.h"
+#include "kyra/screen.h"
+#include "kyra/animator_lok.h"
+#include "kyra/sprites.h"
+
+#include "common/system.h"
+
+namespace Kyra {
+Animator_LoK::Animator_LoK(KyraEngine_LoK *vm, OSystem *system) {
+	_vm = vm;
+	_screen = vm->screen();
+	_initOk = false;
+	_updateScreen = false;
+	_system = system;
+	_screenObjects = _actors = _items = _sprites = _objectQueue = 0;
+	_noDrawShapesFlag = 0;
+
+	_actorBkgBackUp[0] = new uint8[_screen->getRectSize(8, 69)];
+	memset(_actorBkgBackUp[0], 0, _screen->getRectSize(8, 69));
+	_actorBkgBackUp[1] = new uint8[_screen->getRectSize(8, 69)];
+	memset(_actorBkgBackUp[1], 0, _screen->getRectSize(8, 69));
+}
+
+Animator_LoK::~Animator_LoK() {
+	close();
+	delete[] _actorBkgBackUp[0];
+	delete[] _actorBkgBackUp[1];
+}
+
+void Animator_LoK::init(int actors_, int items_, int sprites_) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::init(%d, %d, %d)", actors_, items_, sprites_);
+	_screenObjects = new AnimObject[actors_ + items_ + sprites_];
+	assert(_screenObjects);
+	memset(_screenObjects, 0, sizeof(AnimObject) * (actors_ + items_ + sprites_));
+	_actors = _screenObjects;
+	_sprites = &_screenObjects[actors_];
+	_items = &_screenObjects[actors_ + items_];
+	_brandonDrawFrame = 113;
+
+	_initOk = true;
+}
+
+void Animator_LoK::close() {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::close()");
+	if (_initOk) {
+		_initOk = false;
+		delete[] _screenObjects;
+		_screenObjects = _actors = _items = _sprites = _objectQueue = 0;
+	}
+}
+
+void Animator_LoK::initAnimStateList() {
+	AnimObject *animStates = _screenObjects;
+	animStates[0].index = 0;
+	animStates[0].active = 1;
+	animStates[0].flags = 0x800;
+	animStates[0].background = _actorBkgBackUp[0];
+	animStates[0].rectSize = _screen->getRectSize(4, 48);
+	animStates[0].width = 4;
+	animStates[0].height = 48;
+	animStates[0].width2 = 4;
+	animStates[0].height2 = 3;
+
+	for (int i = 1; i <= 4; ++i) {
+		animStates[i].index = i;
+		animStates[i].active = 0;
+		animStates[i].flags = 0x800;
+		animStates[i].background = _actorBkgBackUp[1];
+		animStates[i].rectSize = _screen->getRectSize(4, 64);
+		animStates[i].width = 4;
+		animStates[i].height = 48;
+		animStates[i].width2 = 4;
+		animStates[i].height2 = 3;
+	}
+
+	for (int i = 5; i < 16; ++i) {
+		animStates[i].index = i;
+		animStates[i].active = 0;
+		animStates[i].flags = 0;
+	}
+
+	for (int i = 16; i < 28; ++i) {
+		animStates[i].index = i;
+		animStates[i].flags = 0;
+		animStates[i].background = _vm->_shapes[345+i];
+		animStates[i].rectSize = _screen->getRectSize(3, 24);
+		animStates[i].width = 3;
+		animStates[i].height = 16;
+		animStates[i].width2 = 0;
+		animStates[i].height2 = 0;
+	}
+}
+
+void Animator_LoK::preserveAllBackgrounds() {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::preserveAllBackgrounds()");
+	uint8 curPage = _screen->_curPage;
+	_screen->_curPage = 2;
+
+	AnimObject *curObject = _objectQueue;
+	while (curObject) {
+		if (curObject->active && !curObject->disable) {
+			preserveOrRestoreBackground(curObject, false);
+			curObject->bkgdChangeFlag = 0;
+		}
+		curObject = curObject->nextAnimObject;
+	}
+	_screen->_curPage = curPage;
+}
+
+void Animator_LoK::flagAllObjectsForBkgdChange() {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::flagAllObjectsForBkgdChange()");
+	AnimObject *curObject = _objectQueue;
+	while (curObject) {
+		curObject->bkgdChangeFlag = 1;
+		curObject = curObject->nextAnimObject;
+	}
+}
+
+void Animator_LoK::flagAllObjectsForRefresh() {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::flagAllObjectsForRefresh()");
+	AnimObject *curObject = _objectQueue;
+	while (curObject) {
+		curObject->refreshFlag = 1;
+		curObject = curObject->nextAnimObject;
+	}
+}
+
+void Animator_LoK::restoreAllObjectBackgrounds() {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::restoreAllObjectBackground()");
+	AnimObject *curObject = _objectQueue;
+	_screen->_curPage = 2;
+
+	while (curObject) {
+		if (curObject->active && !curObject->disable) {
+			preserveOrRestoreBackground(curObject, true);
+			curObject->x2 = curObject->x1;
+			curObject->y2 = curObject->y1;
+		}
+		curObject = curObject->nextAnimObject;
+	}
+
+	_screen->_curPage = 0;
+}
+
+void Animator_LoK::preserveAnyChangedBackgrounds() {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::preserveAnyChangedBackgrounds()");
+	AnimObject *curObject = _objectQueue;
+	_screen->_curPage = 2;
+
+	while (curObject) {
+		if (curObject->active && !curObject->disable && curObject->bkgdChangeFlag) {
+			preserveOrRestoreBackground(curObject, false);
+			curObject->bkgdChangeFlag = 0;
+		}
+		curObject = curObject->nextAnimObject;
+	}
+
+	_screen->_curPage = 0;
+}
+
+void Animator_LoK::preserveOrRestoreBackground(AnimObject *obj, bool restore) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::preserveOrRestoreBackground(%p, %d)", (const void *)obj, restore);
+	int x = 0, y = 0, width = obj->width, height = obj->height;
+
+	if (restore) {
+		x = obj->x2 >> 3;
+		y = obj->y2;
+	} else {
+		x = obj->x1 >> 3;
+		y = obj->y1;
+	}
+
+	if (x < 0)
+		x = 0;
+	if (y < 0)
+		y = 0;
+
+	int temp;
+
+	temp = x + width;
+	if (temp >= 39)
+		x = 39 - width;
+	temp = y + height;
+	if (temp >= 136)
+		y = 136 - height;
+
+	if (restore)
+		_screen->copyBlockToPage(_screen->_curPage, x << 3, y, width << 3, height, obj->background);
+	else
+		_screen->copyRegionToBuffer(_screen->_curPage, x << 3, y, width << 3, height, obj->background);
+}
+
+void Animator_LoK::prepDrawAllObjects() {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::prepDrawAllObjects()");
+	AnimObject *curObject = _objectQueue;
+	int drawPage = 2;
+	int flagUnk1 = 0, flagUnk2 = 0, flagUnk3 = 0;
+	if (_noDrawShapesFlag)
+		return;
+	if (_vm->_brandonStatusBit & 0x20)
+		flagUnk1 = 0x200;
+	if (_vm->_brandonStatusBit & 0x40)
+		flagUnk2 = 0x4000;
+
+	while (curObject) {
+		if (curObject->active) {
+			int xpos = curObject->x1;
+			int ypos = curObject->y1;
+
+			int drawLayer = 0;
+			if (!(curObject->flags & 0x800))
+				drawLayer = 7;
+			else if (curObject->disable)
+				drawLayer = 0;
+			else
+				drawLayer = _vm->_sprites->getDrawLayer(curObject->drawY);
+
+			// talking head functionallity
+			if (_vm->_talkingCharNum != -1 && (_vm->_currentCharacter->currentAnimFrame != 88 || curObject->index != 0)) {
+				const int16 baseAnimFrameTable1[] = { 0x11, 0x35, 0x59, 0x00, 0x00, 0x00 };
+				const int16 baseAnimFrameTable2[] = { 0x15, 0x39, 0x5D, 0x00, 0x00, 0x00 };
+				const int8 xOffsetTable1[] = { 2, 4, 0, 5, 2, 0, 0, 0 };
+				const int8 xOffsetTable2[] = { 6, 4, 8, 3, 6, 0, 0, 0 };
+				const int8 yOffsetTable1[] = { 0, 8, 1, 1, 0, 0, 0, 0 };
+				const int8 yOffsetTable2[] = { 0, 8, 1, 1, 0, 0, 0, 0 };
+				if (curObject->index == 0 || curObject->index <= 4) {
+					int shapesIndex = 0;
+					if (curObject->index == _vm->_charSayUnk3) {
+						shapesIndex = _vm->_currHeadShape + baseAnimFrameTable1[curObject->index];
+					} else {
+						shapesIndex = baseAnimFrameTable2[curObject->index];
+						int temp2 = 0;
+						if (curObject->index == 2) {
+							if (_vm->_characterList[2].sceneId == 77 || _vm->_characterList[2].sceneId == 86)
+								temp2 = 1;
+							else
+								temp2 = 0;
+						} else {
+							temp2 = 1;
+						}
+
+						if (!temp2)
+							shapesIndex = -1;
+					}
+
+					xpos = curObject->x1;
+					ypos = curObject->y1;
+
+					int tempX = 0, tempY = 0;
+					if (curObject->flags & 0x1) {
+						tempX = (xOffsetTable1[curObject->index] * _brandonScaleX) >> 8;
+						tempY = yOffsetTable1[curObject->index];
+					} else {
+						tempX = (xOffsetTable2[curObject->index] * _brandonScaleX) >> 8;
+						tempY = yOffsetTable2[curObject->index];
+					}
+					tempY = (tempY * _brandonScaleY) >> 8;
+					xpos += tempX;
+					ypos += tempY;
+
+					if (_vm->_scaleMode && _brandonScaleX != 256)
+						++xpos;
+
+					if (curObject->index == 0 && shapesIndex != -1) {
+						if (!(_vm->_brandonStatusBit & 2)) {
+							flagUnk3 = 0x100;
+							if ((flagUnk1 & 0x200) || (flagUnk2 & 0x4000))
+								flagUnk3 = 0;
+
+							int tempFlags = 0;
+							if (flagUnk3 & 0x100) {
+								tempFlags = curObject->flags & 1;
+								tempFlags |= 0x800 | flagUnk1 | 0x100;
+							}
+
+							if (!(flagUnk3 & 0x100) && (flagUnk2 & 0x4000)) {
+								tempFlags = curObject->flags & 1;
+								tempFlags |= 0x900 | flagUnk1 | 0x4000;
+								_screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 4, _vm->_brandonPoisonFlagsGFX, int(1), int(_vm->_brandonInvFlag), drawLayer, _brandonScaleX, _brandonScaleY);
+							} else {
+								if (!(flagUnk2 & 0x4000)) {
+									tempFlags = curObject->flags & 1;
+									tempFlags |= 0x900 | flagUnk1;
+								}
+
+								_screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 4, _vm->_brandonPoisonFlagsGFX, int(1), drawLayer, _brandonScaleX, _brandonScaleY);
+							}
+						}
+					} else {
+						if (shapesIndex != -1) {
+							int tempFlags = 0;
+							if (curObject->flags & 1)
+								tempFlags = 1;
+							_screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 0x800, drawLayer);
+						}
+					}
+				}
+			}
+
+			xpos = curObject->x1;
+			ypos = curObject->y1;
+
+			curObject->flags |= 0x800;
+			if (curObject->index == 0) {
+				flagUnk3 = 0x100;
+
+				if (flagUnk1 & 0x200 || flagUnk2 & 0x4000)
+					flagUnk3 = 0;
+
+				if (_vm->_brandonStatusBit & 2)
+					curObject->flags &= 0xFFFFFFFE;
+
+				if (!_vm->_scaleMode) {
+					if (flagUnk3 & 0x100)
+						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x100, (uint8*)_vm->_brandonPoisonFlagsGFX, int(1), drawLayer);
+					else if (flagUnk2 & 0x4000)
+						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4000, int(_vm->_brandonInvFlag), drawLayer);
+					else
+						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1, drawLayer);
+				} else {
+					if (flagUnk3 & 0x100)
+						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x104, (uint8*)_vm->_brandonPoisonFlagsGFX, int(1), drawLayer, _brandonScaleX, _brandonScaleY);
+					else if (flagUnk2 & 0x4000)
+						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4004, int(_vm->_brandonInvFlag), drawLayer, _brandonScaleX, _brandonScaleY);
+					else
+						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4, drawLayer, _brandonScaleX, _brandonScaleY);
+				}
+			} else {
+				if (curObject->index >= 16 && curObject->index <= 27)
+					_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | 4, drawLayer, (int)_vm->_scaleTable[curObject->drawY], (int)_vm->_scaleTable[curObject->drawY]);
+				else
+					_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags, drawLayer);
+			}
+		}
+		curObject = curObject->nextAnimObject;
+	}
+}
+
+void Animator_LoK::copyChangedObjectsForward(int refreshFlag) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::copyChangedObjectsForward(%d)", refreshFlag);
+
+	for (AnimObject *curObject = _objectQueue; curObject; curObject = curObject->nextAnimObject) {
+		if (curObject->active) {
+			if (curObject->refreshFlag || refreshFlag) {
+				int xpos = 0, ypos = 0, width = 0, height = 0;
+				xpos = (curObject->x1>>3) - (curObject->width2>>3) - 1;
+				ypos = curObject->y1 - curObject->height2;
+				width = curObject->width + (curObject->width2>>3) + 2;
+				height = curObject->height + curObject->height2*2;
+
+				if (xpos < 1)
+					xpos = 1;
+				else if (xpos > 39)
+					continue;
+
+				if (xpos + width > 39)
+					width = 39 - xpos;
+
+				if (ypos < 8)
+					ypos = 8;
+				else if (ypos > 136)
+					continue;
+
+				if (ypos + height > 136)
+					height = 136 - ypos;
+
+				_screen->copyRegion(xpos << 3, ypos, xpos << 3, ypos, width << 3, height, 2, 0);
+				curObject->refreshFlag = 0;
+				_updateScreen = true;
+			}
+		}
+	}
+
+	if (_updateScreen) {
+		_screen->updateScreen();
+		_updateScreen = false;
+	}
+}
+
+void Animator_LoK::updateAllObjectShapes() {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::updateAllObjectShapes()");
+	restoreAllObjectBackgrounds();
+	preserveAnyChangedBackgrounds();
+	prepDrawAllObjects();
+	copyChangedObjectsForward(0);
+}
+
+void Animator_LoK::animRemoveGameItem(int index) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::animRemoveGameItem(%d)", index);
+	restoreAllObjectBackgrounds();
+
+	AnimObject *animObj = &_items[index];
+	animObj->sceneAnimPtr = 0;
+	animObj->animFrameNumber = -1;
+	animObj->refreshFlag = 1;
+	animObj->bkgdChangeFlag = 1;
+	updateAllObjectShapes();
+	animObj->active = 0;
+
+	objectRemoveQueue(_objectQueue, animObj);
+}
+
+void Animator_LoK::animAddGameItem(int index, uint16 sceneId) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::animRemoveGameItem(%d, %d)", index, sceneId);
+	restoreAllObjectBackgrounds();
+	assert(sceneId < _vm->_roomTableSize);
+	Room *currentRoom = &_vm->_roomTable[sceneId];
+	AnimObject *animObj = &_items[index];
+	animObj->active = 1;
+	animObj->refreshFlag = 1;
+	animObj->bkgdChangeFlag = 1;
+	animObj->drawY = currentRoom->itemsYPos[index];
+	animObj->sceneAnimPtr = _vm->_shapes[216+currentRoom->itemsTable[index]];
+	animObj->animFrameNumber = -1;
+	animObj->x1 = currentRoom->itemsXPos[index];
+	animObj->y1 = currentRoom->itemsYPos[index];
+	animObj->x1 -= fetchAnimWidth(animObj->sceneAnimPtr, _vm->_scaleTable[animObj->drawY]) >> 1;
+	animObj->y1 -= fetchAnimHeight(animObj->sceneAnimPtr, _vm->_scaleTable[animObj->drawY]);
+	animObj->x2 = animObj->x1;
+	animObj->y2 = animObj->y1;
+	animObj->width2 = 0;
+	animObj->height2 = 0;
+	_objectQueue = objectQueue(_objectQueue, animObj);
+	preserveAnyChangedBackgrounds();
+	animObj->refreshFlag = 1;
+	animObj->bkgdChangeFlag = 1;
+}
+
+void Animator_LoK::animAddNPC(int character) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::animAddNPC(%d)", character);
+	restoreAllObjectBackgrounds();
+	AnimObject *animObj = &_actors[character];
+	const Character *ch = &_vm->_characterList[character];
+
+	animObj->active = 1;
+	animObj->refreshFlag = 1;
+	animObj->bkgdChangeFlag = 1;
+	animObj->drawY = ch->y1;
+	animObj->sceneAnimPtr = _vm->_shapes[ch->currentAnimFrame];
+	animObj->x1 = animObj->x2 = ch->x1 + _vm->_defaultShapeTable[ch->currentAnimFrame-7].xOffset;
+	animObj->y1 = animObj->y2 = ch->y1 + _vm->_defaultShapeTable[ch->currentAnimFrame-7].yOffset;
+
+	if (ch->facing >= 1 && ch->facing <= 3)
+		animObj->flags |= 1;
+	else if (ch->facing >= 5 && ch->facing <= 7)
+		animObj->flags &= 0xFFFFFFFE;
+
+	_objectQueue = objectQueue(_objectQueue, animObj);
+	preserveAnyChangedBackgrounds();
+	animObj->refreshFlag = 1;
+	animObj->bkgdChangeFlag = 1;
+}
+
+Animator_LoK::AnimObject *Animator_LoK::objectRemoveQueue(AnimObject *queue, AnimObject *rem) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::objectRemoveQueue(%p, %p)", (const void *)queue, (const void *)rem);
+	AnimObject *cur = queue;
+	AnimObject *prev = queue;
+
+	while (cur != rem && cur) {
+		AnimObject *temp = cur->nextAnimObject;
+		if (!temp)
+			break;
+		prev = cur;
+		cur = temp;
+	}
+
+	if (cur == queue) {
+		if (!cur)
+			return 0;
+		return cur->nextAnimObject;
+	}
+
+	if (!cur->nextAnimObject) {
+		if (cur == rem) {
+			if (!prev)
+				return 0;
+			else
+				prev->nextAnimObject = 0;
+		}
+	} else {
+		if (cur == rem)
+			prev->nextAnimObject = rem->nextAnimObject;
+	}
+
+	return queue;
+}
+
+Animator_LoK::AnimObject *Animator_LoK::objectAddHead(AnimObject *queue, AnimObject *head) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::objectAddHead(%p, %p)", (const void *)queue, (const void *)head);
+	head->nextAnimObject = queue;
+	return head;
+}
+
+Animator_LoK::AnimObject *Animator_LoK::objectQueue(AnimObject *queue, AnimObject *add) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::objectQueue(%p, %p)", (const void *)queue, (const void *)add);
+	if (add->drawY <= queue->drawY || !queue) {
+		add->nextAnimObject = queue;
+		return add;
+	}
+	AnimObject *cur = queue;
+	AnimObject *prev = queue;
+	while (add->drawY > cur->drawY) {
+		AnimObject *temp = cur->nextAnimObject;
+		if (!temp)
+			break;
+		prev = cur;
+		cur = temp;
+	}
+
+	if (add->drawY <= cur->drawY) {
+		prev->nextAnimObject = add;
+		add->nextAnimObject = cur;
+	} else {
+		cur->nextAnimObject = add;
+		add->nextAnimObject = 0;
+	}
+	return queue;
+}
+
+void Animator_LoK::addObjectToQueue(AnimObject *object) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::addObjectToQueue(%p)", (const void *)object);
+	if (!_objectQueue)
+		_objectQueue = objectAddHead(0, object);
+	else
+		_objectQueue = objectQueue(_objectQueue, object);
+}
+
+void Animator_LoK::refreshObject(AnimObject *object) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::refreshObject(%p)", (const void *)object);
+	_objectQueue = objectRemoveQueue(_objectQueue, object);
+	if (_objectQueue)
+		_objectQueue = objectQueue(_objectQueue, object);
+	else
+		_objectQueue = objectAddHead(0, object);
+}
+
+void Animator_LoK::makeBrandonFaceMouse() {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::makeBrandonFaceMouse()");
+	Common::Point mouse = _vm->getMousePos();
+	if (mouse.x >= _vm->_currentCharacter->x1)
+		_vm->_currentCharacter->facing = 3;
+	else
+		_vm->_currentCharacter->facing = 5;
+	animRefreshNPC(0);
+	updateAllObjectShapes();
+}
+
+int16 Animator_LoK::fetchAnimWidth(const uint8 *shape, int16 mult) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::fetchAnimWidth(%p, %d)", (const void *)shape, mult);
+	if (_vm->gameFlags().useAltShapeHeader)
+		shape += 2;
+	return (((int16)READ_LE_UINT16((shape+3))) * mult) >> 8;
+}
+
+int16 Animator_LoK::fetchAnimHeight(const uint8 *shape, int16 mult) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::fetchAnimHeight(%p, %d)", (const void *)shape, mult);
+	if (_vm->gameFlags().useAltShapeHeader)
+		shape += 2;
+	return (int16)(((int8)*(shape+2)) * mult) >> 8;
+}
+
+void Animator_LoK::setBrandonAnimSeqSize(int width, int height) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::setBrandonAnimSeqSize(%d, %d)", width, height);
+	restoreAllObjectBackgrounds();
+	_brandonAnimSeqSizeWidth = _actors[0].width;
+	_brandonAnimSeqSizeHeight = _actors[0].height;
+	_actors[0].width = width + 1;
+	_actors[0].height = height;
+	preserveAllBackgrounds();
+}
+
+void Animator_LoK::resetBrandonAnimSeqSize() {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::resetBrandonAnimSeqSize()");
+	restoreAllObjectBackgrounds();
+	_actors[0].width = _brandonAnimSeqSizeWidth;
+	_actors[0].height = _brandonAnimSeqSizeHeight;
+	preserveAllBackgrounds();
+}
+
+void Animator_LoK::animRefreshNPC(int character) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::animRefreshNPC(%d)", character);
+	AnimObject *animObj = &_actors[character];
+	Character *ch = &_vm->characterList()[character];
+
+	animObj->refreshFlag = 1;
+	animObj->bkgdChangeFlag = 1;
+	int facing = ch->facing;
+	if (facing >= 1 && facing <= 3)
+		animObj->flags |= 1;
+	else if (facing >= 5 && facing <= 7)
+		animObj->flags &= 0xFFFFFFFE;
+
+	animObj->drawY = ch->y1;
+	animObj->sceneAnimPtr = _vm->shapes()[ch->currentAnimFrame];
+	animObj->animFrameNumber = ch->currentAnimFrame;
+	if (character == 0) {
+		if (_vm->brandonStatus() & 10) {
+			animObj->animFrameNumber = 88;
+			ch->currentAnimFrame = 88;
+		}
+		if (_vm->brandonStatus() & 2) {
+			animObj->animFrameNumber = _brandonDrawFrame;
+			ch->currentAnimFrame = _brandonDrawFrame;
+			animObj->sceneAnimPtr = _vm->shapes()[_brandonDrawFrame];
+			if (_vm->_brandonStatusBit0x02Flag) {
+				++_brandonDrawFrame;
+				// TODO: check this
+				if (_brandonDrawFrame >= 122) {
+					_brandonDrawFrame = 113;
+					_vm->_brandonStatusBit0x02Flag = 0;
+				}
+			}
+		}
+	}
+
+	int xOffset = _vm->_defaultShapeTable[ch->currentAnimFrame-7].xOffset;
+	int yOffset = _vm->_defaultShapeTable[ch->currentAnimFrame-7].yOffset;
+
+	if (_vm->_scaleMode) {
+		animObj->x1 = ch->x1;
+		animObj->y1 = ch->y1;
+
+		int newScale = _vm->_scaleTable[ch->y1];
+		_brandonScaleX = newScale;
+		_brandonScaleY = newScale;
+
+		animObj->x1 += (_brandonScaleX * xOffset) >> 8;
+		animObj->y1 += (_brandonScaleY * yOffset) >> 8;
+	} else {
+		animObj->x1 = ch->x1 + xOffset;
+		animObj->y1 = ch->y1 + yOffset;
+	}
+	animObj->width2 = 4;
+	animObj->height2 = 3;
+
+	refreshObject(animObj);
+}
+
+void Animator_LoK::setCharacterDefaultFrame(int character) {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::setCharacterDefaultFrame()");
+	static uint16 initFrameTable[] = {
+		7, 41, 77, 0, 0
+	};
+	assert(character < ARRAYSIZE(initFrameTable));
+	Character *edit = &_vm->characterList()[character];
+	edit->sceneId = 0xFFFF;
+	edit->facing = 0;
+	edit->currentAnimFrame = initFrameTable[character];
+	// edit->unk6 = 1;
+}
+
+void Animator_LoK::setCharactersHeight() {
+	debugC(9, kDebugLevelAnimator, "Animator_LoK::setCharactersHeight()");
+	static int8 initHeightTable[] = {
+		48, 40, 48, 47, 56,
+		44, 42, 47, 38, 35,
+		40
+	};
+	for (int i = 0; i < 11; ++i)
+		_vm->characterList()[i].height = initHeightTable[i];
+}
+
+} // end of namespace Kyra
+

Copied: scummvm/trunk/engines/kyra/animator_lok.h (from rev 32035, scummvm/trunk/engines/kyra/animator_v1.h)
===================================================================
--- scummvm/trunk/engines/kyra/animator_lok.h	                        (rev 0)
+++ scummvm/trunk/engines/kyra/animator_lok.h	2008-05-11 22:32:37 UTC (rev 32042)
@@ -0,0 +1,132 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef KYRA_ANIMATOR_V1_H
+#define KYRA_ANIMATOR_V1_H
+
+namespace Kyra {
+class KyraEngine_LoK;
+class Screen;
+
+class Animator_LoK {
+public:
+	struct AnimObject {
+		uint8 index;
+		uint32 active;
+		uint32 refreshFlag;
+		uint32 bkgdChangeFlag;
+		bool disable;
+		uint32 flags;
+		int16 drawY;
+		uint8 *sceneAnimPtr;
+		int16 animFrameNumber;
+		uint8 *background;
+		uint16 rectSize;
+		int16 x1, y1;
+		int16 x2, y2;
+		uint16 width;
+		uint16 height;
+		uint16 width2;
+		uint16 height2;
+		AnimObject *nextAnimObject;
+	};
+
+	Animator_LoK(KyraEngine_LoK *vm, OSystem *system);
+	virtual ~Animator_LoK();
+
+	operator bool() const { return _initOk; }
+
+	void init(int actors, int items, int sprites);
+	void close();
+
+	AnimObject *objects() { return _screenObjects; }
+	AnimObject *actors() { return _actors; }
+	AnimObject *items() { return _items; }
+	AnimObject *sprites() { return _sprites; }
+
+	void initAnimStateList();
+	void preserveAllBackgrounds();
+	void flagAllObjectsForBkgdChange();
+	void flagAllObjectsForRefresh();
+	void restoreAllObjectBackgrounds();
+	void preserveAnyChangedBackgrounds();
+	virtual void prepDrawAllObjects();
+	void copyChangedObjectsForward(int refreshFlag);
+
+	void updateAllObjectShapes();
+	void animRemoveGameItem(int index);
+	void animAddGameItem(int index, uint16 sceneId);
+	void animAddNPC(int character);
+	void animRefreshNPC(int character);
+
+	void clearQueue() { _objectQueue = 0; }
+	void addObjectToQueue(AnimObject *object);
+	void refreshObject(AnimObject *object);
+
+	void makeBrandonFaceMouse();
+	void setBrandonAnimSeqSize(int width, int height);
+	void resetBrandonAnimSeqSize();
+	void setCharacterDefaultFrame(int character);
+	void setCharactersHeight();
+
+	int16 fetchAnimWidth(const uint8 *shape, int16 mult);
+	int16 fetchAnimHeight(const uint8 *shape, int16 mult);
+
+	int _noDrawShapesFlag;
+	bool _updateScreen;
+	uint16 _brandonDrawFrame;
+	int _brandonScaleX;
+	int _brandonScaleY;
+
+protected:
+	KyraEngine_LoK *_vm;
+	Screen *_screen;
+	OSystem *_system;
+	bool _initOk;
+
+	AnimObject *_screenObjects;
+
+	AnimObject *_actors;
+	AnimObject *_items;
+	AnimObject *_sprites;
+
+	uint8 *_actorBkgBackUp[2];
+
+	AnimObject *objectRemoveQueue(AnimObject *queue, AnimObject *rem);
+	AnimObject *objectAddHead(AnimObject *queue, AnimObject *head);
+	AnimObject *objectQueue(AnimObject *queue, AnimObject *add);
+
+	void preserveOrRestoreBackground(AnimObject *obj, bool restore);
+
+	AnimObject *_objectQueue;
+
+	int _brandonAnimSeqSizeWidth;
+	int _brandonAnimSeqSizeHeight;
+
+};
+} // end of namespace Kyra
+
+#endif
+

Deleted: scummvm/trunk/engines/kyra/animator_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/animator_v1.cpp	2008-05-11 22:08:32 UTC (rev 32041)
+++ scummvm/trunk/engines/kyra/animator_v1.cpp	2008-05-11 22:32:37 UTC (rev 32042)
@@ -1,691 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/endian.h"
-
-#include "kyra/kyra_v1.h"
-#include "kyra/screen.h"
-#include "kyra/animator_v1.h"
-#include "kyra/sprites.h"
-
-#include "common/system.h"
-
-namespace Kyra {
-Animator_v1::Animator_v1(KyraEngine_v1 *vm, OSystem *system) {
-	_vm = vm;
-	_screen = vm->screen();
-	_initOk = false;
-	_updateScreen = false;
-	_system = system;
-	_screenObjects = _actors = _items = _sprites = _objectQueue = 0;
-	_noDrawShapesFlag = 0;
-
-	_actorBkgBackUp[0] = new uint8[_screen->getRectSize(8, 69)];
-	memset(_actorBkgBackUp[0], 0, _screen->getRectSize(8, 69));
-	_actorBkgBackUp[1] = new uint8[_screen->getRectSize(8, 69)];
-	memset(_actorBkgBackUp[1], 0, _screen->getRectSize(8, 69));
-}
-
-Animator_v1::~Animator_v1() {
-	close();
-	delete[] _actorBkgBackUp[0];
-	delete[] _actorBkgBackUp[1];
-}
-
-void Animator_v1::init(int actors_, int items_, int sprites_) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::init(%d, %d, %d)", actors_, items_, sprites_);
-	_screenObjects = new AnimObject[actors_ + items_ + sprites_];
-	assert(_screenObjects);
-	memset(_screenObjects, 0, sizeof(AnimObject) * (actors_ + items_ + sprites_));
-	_actors = _screenObjects;
-	_sprites = &_screenObjects[actors_];
-	_items = &_screenObjects[actors_ + items_];
-	_brandonDrawFrame = 113;
-
-	_initOk = true;
-}
-
-void Animator_v1::close() {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::close()");
-	if (_initOk) {
-		_initOk = false;
-		delete[] _screenObjects;
-		_screenObjects = _actors = _items = _sprites = _objectQueue = 0;
-	}
-}
-
-void Animator_v1::initAnimStateList() {
-	AnimObject *animStates = _screenObjects;
-	animStates[0].index = 0;
-	animStates[0].active = 1;
-	animStates[0].flags = 0x800;
-	animStates[0].background = _actorBkgBackUp[0];
-	animStates[0].rectSize = _screen->getRectSize(4, 48);
-	animStates[0].width = 4;
-	animStates[0].height = 48;
-	animStates[0].width2 = 4;
-	animStates[0].height2 = 3;
-
-	for (int i = 1; i <= 4; ++i) {
-		animStates[i].index = i;
-		animStates[i].active = 0;
-		animStates[i].flags = 0x800;
-		animStates[i].background = _actorBkgBackUp[1];
-		animStates[i].rectSize = _screen->getRectSize(4, 64);
-		animStates[i].width = 4;
-		animStates[i].height = 48;
-		animStates[i].width2 = 4;
-		animStates[i].height2 = 3;
-	}
-
-	for (int i = 5; i < 16; ++i) {
-		animStates[i].index = i;
-		animStates[i].active = 0;
-		animStates[i].flags = 0;
-	}
-
-	for (int i = 16; i < 28; ++i) {
-		animStates[i].index = i;
-		animStates[i].flags = 0;
-		animStates[i].background = _vm->_shapes[345+i];
-		animStates[i].rectSize = _screen->getRectSize(3, 24);
-		animStates[i].width = 3;
-		animStates[i].height = 16;
-		animStates[i].width2 = 0;
-		animStates[i].height2 = 0;
-	}
-}
-
-void Animator_v1::preserveAllBackgrounds() {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::preserveAllBackgrounds()");
-	uint8 curPage = _screen->_curPage;
-	_screen->_curPage = 2;
-
-	AnimObject *curObject = _objectQueue;
-	while (curObject) {
-		if (curObject->active && !curObject->disable) {
-			preserveOrRestoreBackground(curObject, false);
-			curObject->bkgdChangeFlag = 0;
-		}
-		curObject = curObject->nextAnimObject;
-	}
-	_screen->_curPage = curPage;
-}
-
-void Animator_v1::flagAllObjectsForBkgdChange() {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::flagAllObjectsForBkgdChange()");
-	AnimObject *curObject = _objectQueue;
-	while (curObject) {
-		curObject->bkgdChangeFlag = 1;
-		curObject = curObject->nextAnimObject;
-	}
-}
-
-void Animator_v1::flagAllObjectsForRefresh() {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::flagAllObjectsForRefresh()");
-	AnimObject *curObject = _objectQueue;
-	while (curObject) {
-		curObject->refreshFlag = 1;
-		curObject = curObject->nextAnimObject;
-	}
-}
-
-void Animator_v1::restoreAllObjectBackgrounds() {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::restoreAllObjectBackground()");
-	AnimObject *curObject = _objectQueue;
-	_screen->_curPage = 2;
-
-	while (curObject) {
-		if (curObject->active && !curObject->disable) {
-			preserveOrRestoreBackground(curObject, true);
-			curObject->x2 = curObject->x1;
-			curObject->y2 = curObject->y1;
-		}
-		curObject = curObject->nextAnimObject;
-	}
-
-	_screen->_curPage = 0;
-}
-
-void Animator_v1::preserveAnyChangedBackgrounds() {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::preserveAnyChangedBackgrounds()");
-	AnimObject *curObject = _objectQueue;
-	_screen->_curPage = 2;
-
-	while (curObject) {
-		if (curObject->active && !curObject->disable && curObject->bkgdChangeFlag) {
-			preserveOrRestoreBackground(curObject, false);
-			curObject->bkgdChangeFlag = 0;
-		}
-		curObject = curObject->nextAnimObject;
-	}
-
-	_screen->_curPage = 0;
-}
-
-void Animator_v1::preserveOrRestoreBackground(AnimObject *obj, bool restore) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::preserveOrRestoreBackground(%p, %d)", (const void *)obj, restore);
-	int x = 0, y = 0, width = obj->width, height = obj->height;
-
-	if (restore) {
-		x = obj->x2 >> 3;
-		y = obj->y2;
-	} else {
-		x = obj->x1 >> 3;
-		y = obj->y1;
-	}
-
-	if (x < 0)
-		x = 0;
-	if (y < 0)
-		y = 0;
-
-	int temp;
-
-	temp = x + width;
-	if (temp >= 39)
-		x = 39 - width;
-	temp = y + height;
-	if (temp >= 136)
-		y = 136 - height;
-
-	if (restore)
-		_screen->copyBlockToPage(_screen->_curPage, x << 3, y, width << 3, height, obj->background);
-	else
-		_screen->copyRegionToBuffer(_screen->_curPage, x << 3, y, width << 3, height, obj->background);
-}
-
-void Animator_v1::prepDrawAllObjects() {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::prepDrawAllObjects()");
-	AnimObject *curObject = _objectQueue;
-	int drawPage = 2;
-	int flagUnk1 = 0, flagUnk2 = 0, flagUnk3 = 0;
-	if (_noDrawShapesFlag)
-		return;
-	if (_vm->_brandonStatusBit & 0x20)
-		flagUnk1 = 0x200;
-	if (_vm->_brandonStatusBit & 0x40)
-		flagUnk2 = 0x4000;
-
-	while (curObject) {
-		if (curObject->active) {
-			int xpos = curObject->x1;
-			int ypos = curObject->y1;
-
-			int drawLayer = 0;
-			if (!(curObject->flags & 0x800))
-				drawLayer = 7;
-			else if (curObject->disable)
-				drawLayer = 0;
-			else
-				drawLayer = _vm->_sprites->getDrawLayer(curObject->drawY);
-
-			// talking head functionallity
-			if (_vm->_talkingCharNum != -1 && (_vm->_currentCharacter->currentAnimFrame != 88 || curObject->index != 0)) {
-				const int16 baseAnimFrameTable1[] = { 0x11, 0x35, 0x59, 0x00, 0x00, 0x00 };
-				const int16 baseAnimFrameTable2[] = { 0x15, 0x39, 0x5D, 0x00, 0x00, 0x00 };
-				const int8 xOffsetTable1[] = { 2, 4, 0, 5, 2, 0, 0, 0 };
-				const int8 xOffsetTable2[] = { 6, 4, 8, 3, 6, 0, 0, 0 };
-				const int8 yOffsetTable1[] = { 0, 8, 1, 1, 0, 0, 0, 0 };
-				const int8 yOffsetTable2[] = { 0, 8, 1, 1, 0, 0, 0, 0 };
-				if (curObject->index == 0 || curObject->index <= 4) {
-					int shapesIndex = 0;
-					if (curObject->index == _vm->_charSayUnk3) {
-						shapesIndex = _vm->_currHeadShape + baseAnimFrameTable1[curObject->index];
-					} else {
-						shapesIndex = baseAnimFrameTable2[curObject->index];
-						int temp2 = 0;
-						if (curObject->index == 2) {
-							if (_vm->_characterList[2].sceneId == 77 || _vm->_characterList[2].sceneId == 86)
-								temp2 = 1;
-							else
-								temp2 = 0;
-						} else {
-							temp2 = 1;
-						}
-
-						if (!temp2)
-							shapesIndex = -1;
-					}
-
-					xpos = curObject->x1;
-					ypos = curObject->y1;
-
-					int tempX = 0, tempY = 0;
-					if (curObject->flags & 0x1) {
-						tempX = (xOffsetTable1[curObject->index] * _brandonScaleX) >> 8;
-						tempY = yOffsetTable1[curObject->index];
-					} else {
-						tempX = (xOffsetTable2[curObject->index] * _brandonScaleX) >> 8;
-						tempY = yOffsetTable2[curObject->index];
-					}
-					tempY = (tempY * _brandonScaleY) >> 8;
-					xpos += tempX;
-					ypos += tempY;
-
-					if (_vm->_scaleMode && _brandonScaleX != 256)
-						++xpos;
-
-					if (curObject->index == 0 && shapesIndex != -1) {
-						if (!(_vm->_brandonStatusBit & 2)) {
-							flagUnk3 = 0x100;
-							if ((flagUnk1 & 0x200) || (flagUnk2 & 0x4000))
-								flagUnk3 = 0;
-
-							int tempFlags = 0;
-							if (flagUnk3 & 0x100) {
-								tempFlags = curObject->flags & 1;
-								tempFlags |= 0x800 | flagUnk1 | 0x100;
-							}
-
-							if (!(flagUnk3 & 0x100) && (flagUnk2 & 0x4000)) {
-								tempFlags = curObject->flags & 1;
-								tempFlags |= 0x900 | flagUnk1 | 0x4000;
-								_screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 4, _vm->_brandonPoisonFlagsGFX, int(1), int(_vm->_brandonInvFlag), drawLayer, _brandonScaleX, _brandonScaleY);
-							} else {
-								if (!(flagUnk2 & 0x4000)) {
-									tempFlags = curObject->flags & 1;
-									tempFlags |= 0x900 | flagUnk1;
-								}
-
-								_screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 4, _vm->_brandonPoisonFlagsGFX, int(1), drawLayer, _brandonScaleX, _brandonScaleY);
-							}
-						}
-					} else {
-						if (shapesIndex != -1) {
-							int tempFlags = 0;
-							if (curObject->flags & 1)
-								tempFlags = 1;
-							_screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 0x800, drawLayer);
-						}
-					}
-				}
-			}
-
-			xpos = curObject->x1;
-			ypos = curObject->y1;
-
-			curObject->flags |= 0x800;
-			if (curObject->index == 0) {
-				flagUnk3 = 0x100;
-
-				if (flagUnk1 & 0x200 || flagUnk2 & 0x4000)
-					flagUnk3 = 0;
-
-				if (_vm->_brandonStatusBit & 2)
-					curObject->flags &= 0xFFFFFFFE;
-
-				if (!_vm->_scaleMode) {
-					if (flagUnk3 & 0x100)
-						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x100, (uint8*)_vm->_brandonPoisonFlagsGFX, int(1), drawLayer);
-					else if (flagUnk2 & 0x4000)
-						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4000, int(_vm->_brandonInvFlag), drawLayer);
-					else
-						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1, drawLayer);
-				} else {
-					if (flagUnk3 & 0x100)
-						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x104, (uint8*)_vm->_brandonPoisonFlagsGFX, int(1), drawLayer, _brandonScaleX, _brandonScaleY);
-					else if (flagUnk2 & 0x4000)
-						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4004, int(_vm->_brandonInvFlag), drawLayer, _brandonScaleX, _brandonScaleY);
-					else
-						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4, drawLayer, _brandonScaleX, _brandonScaleY);
-				}
-			} else {
-				if (curObject->index >= 16 && curObject->index <= 27)
-					_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | 4, drawLayer, (int)_vm->_scaleTable[curObject->drawY], (int)_vm->_scaleTable[curObject->drawY]);
-				else
-					_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags, drawLayer);
-			}
-		}
-		curObject = curObject->nextAnimObject;
-	}
-}
-
-void Animator_v1::copyChangedObjectsForward(int refreshFlag) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::copyChangedObjectsForward(%d)", refreshFlag);
-
-	for (AnimObject *curObject = _objectQueue; curObject; curObject = curObject->nextAnimObject) {
-		if (curObject->active) {
-			if (curObject->refreshFlag || refreshFlag) {
-				int xpos = 0, ypos = 0, width = 0, height = 0;
-				xpos = (curObject->x1>>3) - (curObject->width2>>3) - 1;
-				ypos = curObject->y1 - curObject->height2;
-				width = curObject->width + (curObject->width2>>3) + 2;
-				height = curObject->height + curObject->height2*2;
-
-				if (xpos < 1)
-					xpos = 1;
-				else if (xpos > 39)
-					continue;
-
-				if (xpos + width > 39)
-					width = 39 - xpos;
-
-				if (ypos < 8)
-					ypos = 8;
-				else if (ypos > 136)
-					continue;
-
-				if (ypos + height > 136)
-					height = 136 - ypos;
-
-				_screen->copyRegion(xpos << 3, ypos, xpos << 3, ypos, width << 3, height, 2, 0);
-				curObject->refreshFlag = 0;
-				_updateScreen = true;
-			}
-		}
-	}
-
-	if (_updateScreen) {
-		_screen->updateScreen();
-		_updateScreen = false;
-	}
-}
-
-void Animator_v1::updateAllObjectShapes() {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::updateAllObjectShapes()");
-	restoreAllObjectBackgrounds();
-	preserveAnyChangedBackgrounds();
-	prepDrawAllObjects();
-	copyChangedObjectsForward(0);
-}
-
-void Animator_v1::animRemoveGameItem(int index) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::animRemoveGameItem(%d)", index);
-	restoreAllObjectBackgrounds();
-
-	AnimObject *animObj = &_items[index];
-	animObj->sceneAnimPtr = 0;
-	animObj->animFrameNumber = -1;
-	animObj->refreshFlag = 1;
-	animObj->bkgdChangeFlag = 1;
-	updateAllObjectShapes();
-	animObj->active = 0;
-
-	objectRemoveQueue(_objectQueue, animObj);
-}
-
-void Animator_v1::animAddGameItem(int index, uint16 sceneId) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::animRemoveGameItem(%d, %d)", index, sceneId);
-	restoreAllObjectBackgrounds();
-	assert(sceneId < _vm->_roomTableSize);
-	Room *currentRoom = &_vm->_roomTable[sceneId];
-	AnimObject *animObj = &_items[index];
-	animObj->active = 1;
-	animObj->refreshFlag = 1;
-	animObj->bkgdChangeFlag = 1;
-	animObj->drawY = currentRoom->itemsYPos[index];
-	animObj->sceneAnimPtr = _vm->_shapes[216+currentRoom->itemsTable[index]];
-	animObj->animFrameNumber = -1;
-	animObj->x1 = currentRoom->itemsXPos[index];
-	animObj->y1 = currentRoom->itemsYPos[index];
-	animObj->x1 -= fetchAnimWidth(animObj->sceneAnimPtr, _vm->_scaleTable[animObj->drawY]) >> 1;
-	animObj->y1 -= fetchAnimHeight(animObj->sceneAnimPtr, _vm->_scaleTable[animObj->drawY]);
-	animObj->x2 = animObj->x1;
-	animObj->y2 = animObj->y1;
-	animObj->width2 = 0;
-	animObj->height2 = 0;
-	_objectQueue = objectQueue(_objectQueue, animObj);
-	preserveAnyChangedBackgrounds();
-	animObj->refreshFlag = 1;
-	animObj->bkgdChangeFlag = 1;
-}
-
-void Animator_v1::animAddNPC(int character) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::animAddNPC(%d)", character);
-	restoreAllObjectBackgrounds();
-	AnimObject *animObj = &_actors[character];
-	const Character *ch = &_vm->_characterList[character];
-
-	animObj->active = 1;
-	animObj->refreshFlag = 1;
-	animObj->bkgdChangeFlag = 1;
-	animObj->drawY = ch->y1;
-	animObj->sceneAnimPtr = _vm->_shapes[ch->currentAnimFrame];
-	animObj->x1 = animObj->x2 = ch->x1 + _vm->_defaultShapeTable[ch->currentAnimFrame-7].xOffset;
-	animObj->y1 = animObj->y2 = ch->y1 + _vm->_defaultShapeTable[ch->currentAnimFrame-7].yOffset;
-
-	if (ch->facing >= 1 && ch->facing <= 3)
-		animObj->flags |= 1;
-	else if (ch->facing >= 5 && ch->facing <= 7)
-		animObj->flags &= 0xFFFFFFFE;
-
-	_objectQueue = objectQueue(_objectQueue, animObj);
-	preserveAnyChangedBackgrounds();
-	animObj->refreshFlag = 1;
-	animObj->bkgdChangeFlag = 1;
-}
-
-Animator_v1::AnimObject *Animator_v1::objectRemoveQueue(AnimObject *queue, AnimObject *rem) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::objectRemoveQueue(%p, %p)", (const void *)queue, (const void *)rem);
-	AnimObject *cur = queue;
-	AnimObject *prev = queue;
-
-	while (cur != rem && cur) {
-		AnimObject *temp = cur->nextAnimObject;
-		if (!temp)
-			break;
-		prev = cur;
-		cur = temp;
-	}
-
-	if (cur == queue) {
-		if (!cur)
-			return 0;
-		return cur->nextAnimObject;
-	}
-
-	if (!cur->nextAnimObject) {
-		if (cur == rem) {
-			if (!prev)
-				return 0;
-			else
-				prev->nextAnimObject = 0;
-		}
-	} else {
-		if (cur == rem)
-			prev->nextAnimObject = rem->nextAnimObject;
-	}
-
-	return queue;
-}
-
-Animator_v1::AnimObject *Animator_v1::objectAddHead(AnimObject *queue, AnimObject *head) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::objectAddHead(%p, %p)", (const void *)queue, (const void *)head);
-	head->nextAnimObject = queue;
-	return head;
-}
-
-Animator_v1::AnimObject *Animator_v1::objectQueue(AnimObject *queue, AnimObject *add) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::objectQueue(%p, %p)", (const void *)queue, (const void *)add);
-	if (add->drawY <= queue->drawY || !queue) {
-		add->nextAnimObject = queue;
-		return add;
-	}
-	AnimObject *cur = queue;
-	AnimObject *prev = queue;
-	while (add->drawY > cur->drawY) {
-		AnimObject *temp = cur->nextAnimObject;
-		if (!temp)
-			break;
-		prev = cur;
-		cur = temp;
-	}
-
-	if (add->drawY <= cur->drawY) {
-		prev->nextAnimObject = add;
-		add->nextAnimObject = cur;
-	} else {
-		cur->nextAnimObject = add;
-		add->nextAnimObject = 0;
-	}
-	return queue;
-}
-
-void Animator_v1::addObjectToQueue(AnimObject *object) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::addObjectToQueue(%p)", (const void *)object);
-	if (!_objectQueue)
-		_objectQueue = objectAddHead(0, object);
-	else
-		_objectQueue = objectQueue(_objectQueue, object);
-}
-
-void Animator_v1::refreshObject(AnimObject *object) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::refreshObject(%p)", (const void *)object);
-	_objectQueue = objectRemoveQueue(_objectQueue, object);
-	if (_objectQueue)
-		_objectQueue = objectQueue(_objectQueue, object);
-	else
-		_objectQueue = objectAddHead(0, object);
-}
-
-void Animator_v1::makeBrandonFaceMouse() {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::makeBrandonFaceMouse()");
-	Common::Point mouse = _vm->getMousePos();
-	if (mouse.x >= _vm->_currentCharacter->x1)
-		_vm->_currentCharacter->facing = 3;
-	else
-		_vm->_currentCharacter->facing = 5;
-	animRefreshNPC(0);
-	updateAllObjectShapes();
-}
-
-int16 Animator_v1::fetchAnimWidth(const uint8 *shape, int16 mult) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::fetchAnimWidth(%p, %d)", (const void *)shape, mult);
-	if (_vm->gameFlags().useAltShapeHeader)
-		shape += 2;
-	return (((int16)READ_LE_UINT16((shape+3))) * mult) >> 8;
-}
-
-int16 Animator_v1::fetchAnimHeight(const uint8 *shape, int16 mult) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::fetchAnimHeight(%p, %d)", (const void *)shape, mult);
-	if (_vm->gameFlags().useAltShapeHeader)
-		shape += 2;
-	return (int16)(((int8)*(shape+2)) * mult) >> 8;
-}
-
-void Animator_v1::setBrandonAnimSeqSize(int width, int height) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::setBrandonAnimSeqSize(%d, %d)", width, height);
-	restoreAllObjectBackgrounds();
-	_brandonAnimSeqSizeWidth = _actors[0].width;
-	_brandonAnimSeqSizeHeight = _actors[0].height;
-	_actors[0].width = width + 1;
-	_actors[0].height = height;
-	preserveAllBackgrounds();
-}
-
-void Animator_v1::resetBrandonAnimSeqSize() {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::resetBrandonAnimSeqSize()");
-	restoreAllObjectBackgrounds();
-	_actors[0].width = _brandonAnimSeqSizeWidth;
-	_actors[0].height = _brandonAnimSeqSizeHeight;
-	preserveAllBackgrounds();
-}
-
-void Animator_v1::animRefreshNPC(int character) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::animRefreshNPC(%d)", character);
-	AnimObject *animObj = &_actors[character];
-	Character *ch = &_vm->characterList()[character];
-
-	animObj->refreshFlag = 1;
-	animObj->bkgdChangeFlag = 1;
-	int facing = ch->facing;
-	if (facing >= 1 && facing <= 3)
-		animObj->flags |= 1;
-	else if (facing >= 5 && facing <= 7)
-		animObj->flags &= 0xFFFFFFFE;
-
-	animObj->drawY = ch->y1;
-	animObj->sceneAnimPtr = _vm->shapes()[ch->currentAnimFrame];
-	animObj->animFrameNumber = ch->currentAnimFrame;
-	if (character == 0) {
-		if (_vm->brandonStatus() & 10) {
-			animObj->animFrameNumber = 88;
-			ch->currentAnimFrame = 88;
-		}
-		if (_vm->brandonStatus() & 2) {
-			animObj->animFrameNumber = _brandonDrawFrame;
-			ch->currentAnimFrame = _brandonDrawFrame;
-			animObj->sceneAnimPtr = _vm->shapes()[_brandonDrawFrame];
-			if (_vm->_brandonStatusBit0x02Flag) {
-				++_brandonDrawFrame;
-				// TODO: check this
-				if (_brandonDrawFrame >= 122) {
-					_brandonDrawFrame = 113;
-					_vm->_brandonStatusBit0x02Flag = 0;
-				}
-			}
-		}
-	}
-
-	int xOffset = _vm->_defaultShapeTable[ch->currentAnimFrame-7].xOffset;
-	int yOffset = _vm->_defaultShapeTable[ch->currentAnimFrame-7].yOffset;
-
-	if (_vm->_scaleMode) {
-		animObj->x1 = ch->x1;
-		animObj->y1 = ch->y1;
-
-		int newScale = _vm->_scaleTable[ch->y1];
-		_brandonScaleX = newScale;
-		_brandonScaleY = newScale;
-
-		animObj->x1 += (_brandonScaleX * xOffset) >> 8;
-		animObj->y1 += (_brandonScaleY * yOffset) >> 8;
-	} else {
-		animObj->x1 = ch->x1 + xOffset;
-		animObj->y1 = ch->y1 + yOffset;
-	}
-	animObj->width2 = 4;
-	animObj->height2 = 3;
-
-	refreshObject(animObj);
-}
-
-void Animator_v1::setCharacterDefaultFrame(int character) {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::setCharacterDefaultFrame()");
-	static uint16 initFrameTable[] = {
-		7, 41, 77, 0, 0
-	};
-	assert(character < ARRAYSIZE(initFrameTable));
-	Character *edit = &_vm->characterList()[character];
-	edit->sceneId = 0xFFFF;
-	edit->facing = 0;
-	edit->currentAnimFrame = initFrameTable[character];
-	// edit->unk6 = 1;
-}
-
-void Animator_v1::setCharactersHeight() {
-	debugC(9, kDebugLevelAnimator, "Animator_v1::setCharactersHeight()");
-	static int8 initHeightTable[] = {
-		48, 40, 48, 47, 56,
-		44, 42, 47, 38, 35,
-		40
-	};
-	for (int i = 0; i < 11; ++i)
-		_vm->characterList()[i].height = initHeightTable[i];
-}
-
-} // end of namespace Kyra
-

Deleted: scummvm/trunk/engines/kyra/animator_v1.h
===================================================================
--- scummvm/trunk/engines/kyra/animator_v1.h	2008-05-11 22:08:32 UTC (rev 32041)
+++ scummvm/trunk/engines/kyra/animator_v1.h	2008-05-11 22:32:37 UTC (rev 32042)
@@ -1,132 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef KYRA_ANIMATOR_V1_H
-#define KYRA_ANIMATOR_V1_H
-
-namespace Kyra {
-class KyraEngine_v1;
-class Screen;
-
-class Animator_v1 {
-public:
-	struct AnimObject {
-		uint8 index;
-		uint32 active;
-		uint32 refreshFlag;
-		uint32 bkgdChangeFlag;
-		bool disable;
-		uint32 flags;
-		int16 drawY;
-		uint8 *sceneAnimPtr;
-		int16 animFrameNumber;
-		uint8 *background;
-		uint16 rectSize;
-		int16 x1, y1;
-		int16 x2, y2;
-		uint16 width;
-		uint16 height;
-		uint16 width2;
-		uint16 height2;
-		AnimObject *nextAnimObject;
-	};
-
-	Animator_v1(KyraEngine_v1 *vm, OSystem *system);
-	virtual ~Animator_v1();
-
-	operator bool() const { return _initOk; }
-
-	void init(int actors, int items, int sprites);
-	void close();
-
-	AnimObject *objects() { return _screenObjects; }
-	AnimObject *actors() { return _actors; }
-	AnimObject *items() { return _items; }
-	AnimObject *sprites() { return _sprites; }
-
-	void initAnimStateList();
-	void preserveAllBackgrounds();
-	void flagAllObjectsForBkgdChange();
-	void flagAllObjectsForRefresh();
-	void restoreAllObjectBackgrounds();
-	void preserveAnyChangedBackgrounds();
-	virtual void prepDrawAllObjects();
-	void copyChangedObjectsForward(int refreshFlag);
-
-	void updateAllObjectShapes();
-	void animRemoveGameItem(int index);
-	void animAddGameItem(int index, uint16 sceneId);
-	void animAddNPC(int character);
-	void animRefreshNPC(int character);
-
-	void clearQueue() { _objectQueue = 0; }
-	void addObjectToQueue(AnimObject *object);
-	void refreshObject(AnimObject *object);
-
-	void makeBrandonFaceMouse();
-	void setBrandonAnimSeqSize(int width, int height);
-	void resetBrandonAnimSeqSize();
-	void setCharacterDefaultFrame(int character);
-	void setCharactersHeight();
-
-	int16 fetchAnimWidth(const uint8 *shape, int16 mult);
-	int16 fetchAnimHeight(const uint8 *shape, int16 mult);
-
-	int _noDrawShapesFlag;
-	bool _updateScreen;
-	uint16 _brandonDrawFrame;
-	int _brandonScaleX;
-	int _brandonScaleY;
-
-protected:
-	KyraEngine_v1 *_vm;
-	Screen *_screen;
-	OSystem *_system;
-	bool _initOk;
-
-	AnimObject *_screenObjects;
-
-	AnimObject *_actors;
-	AnimObject *_items;
-	AnimObject *_sprites;
-
-	uint8 *_actorBkgBackUp[2];
-
-	AnimObject *objectRemoveQueue(AnimObject *queue, AnimObject *rem);
-	AnimObject *objectAddHead(AnimObject *queue, AnimObject *head);
-	AnimObject *objectQueue(AnimObject *queue, AnimObject *add);
-
-	void preserveOrRestoreBackground(AnimObject *obj, bool restore);
-
-	AnimObject *_objectQueue;
-
-	int _brandonAnimSeqSizeWidth;
-	int _brandonAnimSeqSizeHeight;
-
-};
-} // end of namespace Kyra
-
-#endif
-

Modified: scummvm/trunk/engines/kyra/debugger.cpp
===================================================================
--- scummvm/trunk/engines/kyra/debugger.cpp	2008-05-11 22:08:32 UTC (rev 32041)
+++ scummvm/trunk/engines/kyra/debugger.cpp	2008-05-11 22:32:37 UTC (rev 32042)
@@ -27,7 +27,7 @@
 #include "common/config-manager.h"
 #include "common/system.h"
 #include "kyra/debugger.h"
-#include "kyra/kyra_v1.h"
+#include "kyra/kyra_lok.h"
 #include "kyra/kyra_v2.h"
 #include "kyra/kyra_hof.h"
 #include "kyra/screen.h"
@@ -190,22 +190,22 @@
 
 #pragma mark -
 
-Debugger_v1::Debugger_v1(KyraEngine_v1 *vm)
+Debugger_LoK::Debugger_LoK(KyraEngine_LoK *vm)
 	: Debugger(vm), _vm(vm) {
-	DCmd_Register("rooms",				WRAP_METHOD(Debugger_v1, cmd_listRooms));
-	DCmd_Register("give",				WRAP_METHOD(Debugger_v1, cmd_giveItem));
-	DCmd_Register("birthstones",		WRAP_METHOD(Debugger_v1, cmd_listBirthstones));
+	DCmd_Register("rooms",				WRAP_METHOD(Debugger_LoK, cmd_listRooms));
+	DCmd_Register("give",				WRAP_METHOD(Debugger_LoK, cmd_giveItem));
+	DCmd_Register("birthstones",		WRAP_METHOD(Debugger_LoK, cmd_listBirthstones));
 }
 
-void Debugger_v1::preEnter() {
+void Debugger_LoK::preEnter() {
 	//_vm->midi.pause(1);
 }
 
-void Debugger_v1::postEnter() {
+void Debugger_LoK::postEnter() {
 	//_vm->midi.pause(0);
 }
 
-bool Debugger_v1::cmd_enterRoom(int argc, const char **argv) {
+bool Debugger_LoK::cmd_enterRoom(int argc, const char **argv) {
 	uint direction = 0;
 	if (argc > 1) {
 		int room = atoi(argv[1]);
@@ -244,7 +244,7 @@
 	return true;
 }
 
-bool Debugger_v1::cmd_listRooms(int argc, const char **argv) {
+bool Debugger_LoK::cmd_listRooms(int argc, const char **argv) {
 	for (int i = 0; i < _vm->_roomTableSize; i++) {
 		DebugPrintf("%-3i: %-10s", i, _vm->_roomFilenameTable[_vm->_roomTable[i].nameIndex]);
 		if (!(i % 8))
@@ -255,7 +255,7 @@
 	return true;
 }
 
-bool Debugger_v1::cmd_giveItem(int argc, const char **argv) {
+bool Debugger_LoK::cmd_giveItem(int argc, const char **argv) {
 	if (argc == 2) {
 		int item = atoi(argv[1]);
 
@@ -274,7 +274,7 @@
 	return true;
 }
 
-bool Debugger_v1::cmd_listBirthstones(int argc, const char **argv) {
+bool Debugger_LoK::cmd_listBirthstones(int argc, const char **argv) {
 	DebugPrintf("Needed Birthstone gems:\n");
 	for (int i = 0; i < ARRAYSIZE(_vm->_birthstoneGemTable); ++i)
 		DebugPrintf("%-2d '%s'\n", _vm->_birthstoneGemTable[i], _vm->_itemList[_vm->_birthstoneGemTable[i]]);

Modified: scummvm/trunk/engines/kyra/debugger.h
===================================================================
--- scummvm/trunk/engines/kyra/debugger.h	2008-05-11 22:08:32 UTC (rev 32041)
+++ scummvm/trunk/engines/kyra/debugger.h	2008-05-11 22:32:37 UTC (rev 32042)
@@ -31,7 +31,7 @@
 namespace Kyra {
 
 class KyraEngine;
-class KyraEngine_v1;
+class KyraEngine_LoK;
 class KyraEngine_v2;
 class KyraEngine_HoF;
 
@@ -54,13 +54,13 @@
 	bool cmd_setTimerCountdown(int argc, const char **argv);
 };
 
-class Debugger_v1 : public Debugger {
+class Debugger_LoK : public Debugger {
 public:
-	Debugger_v1(KyraEngine_v1 *vm);
-	virtual ~Debugger_v1() {}  // we need this for __SYMBIAN32__ archaic gcc/UIQ
+	Debugger_LoK(KyraEngine_LoK *vm);
+	virtual ~Debugger_LoK() {}  // we need this for __SYMBIAN32__ archaic gcc/UIQ
 
 protected:
-	KyraEngine_v1 *_vm;
+	KyraEngine_LoK *_vm;
 
 	virtual void preEnter();
 	virtual void postEnter();

Modified: scummvm/trunk/engines/kyra/detection.cpp
===================================================================
--- scummvm/trunk/engines/kyra/detection.cpp	2008-05-11 22:08:32 UTC (rev 32041)
+++ scummvm/trunk/engines/kyra/detection.cpp	2008-05-11 22:32:37 UTC (rev 32042)
@@ -23,7 +23,7 @@
  */
 
 #include "kyra/kyra.h"
-#include "kyra/kyra_v1.h"
+#include "kyra/kyra_lok.h"
 #include "kyra/kyra_hof.h"
 #include "kyra/kyra_mr.h"
 
@@ -506,7 +506,7 @@
 
 	switch (flags.gameID) {
 	case Kyra::GI_KYRA1:
-		*engine = new Kyra::KyraEngine_v1(syst, flags);
+		*engine = new Kyra::KyraEngine_LoK(syst, flags);
 		break;
 	case Kyra::GI_KYRA2:
 		*engine = new Kyra::KyraEngine_HoF(syst, flags);

Modified: scummvm/trunk/engines/kyra/gui_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_hof.cpp	2008-05-11 22:08:32 UTC (rev 32041)
+++ scummvm/trunk/engines/kyra/gui_hof.cpp	2008-05-11 22:32:37 UTC (rev 32042)
@@ -271,7 +271,7 @@
 }
 
 void KyraEngine_HoF::scrollInventoryWheel() {
-	WSAMovieV2 movie(this, _screen);
+	WSAMovie_v2 movie(this, _screen);
 	movie.open("INVWHEEL.WSA", 0, 0);
 	int frames = movie.opened() ? movie.frames() : 6;
 	memcpy(_screenBuffer, _screen->getCPagePtr(2), 64000);

Copied: scummvm/trunk/engines/kyra/gui_lok.cpp (from rev 32035, scummvm/trunk/engines/kyra/gui_v1.cpp)
===================================================================
--- scummvm/trunk/engines/kyra/gui_lok.cpp	                        (rev 0)
+++ scummvm/trunk/engines/kyra/gui_lok.cpp	2008-05-11 22:32:37 UTC (rev 32042)
@@ -0,0 +1,1115 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "kyra/kyra_lok.h"
+#include "kyra/screen.h"
+#include "kyra/script.h"
+#include "kyra/text.h"
+#include "kyra/animator_lok.h"
+#include "kyra/sound.h"
+#include "kyra/gui_lok.h"
+#include "kyra/timer.h"
+
+#include "common/config-manager.h"
+#include "common/savefile.h"
+#include "common/events.h"
+#include "common/system.h"
+
+namespace Kyra {
+
+void KyraEngine_LoK::initMainButtonList() {
+	_buttonList = &_buttonData[0];
+	for (int i = 0; _buttonDataListPtr[i]; ++i)
+		_buttonList = _gui->addButtonToList(_buttonList, _buttonDataListPtr[i]);
+}
+
+int KyraEngine_LoK::buttonInventoryCallback(Button *caller) {
+	int itemOffset = caller->index - 2;
+	uint8 inventoryItem = _currentCharacter->inventoryItems[itemOffset];
+	if (_itemInHand == -1) {
+		if (inventoryItem == 0xFF) {
+			snd_playSoundEffect(0x36);
+			return 0;
+		} else {
+			_screen->hideMouse();
+			_screen->fillRect(_itemPosX[itemOffset], _itemPosY[itemOffset], _itemPosX[itemOffset] + 15, _itemPosY[itemOffset] + 15, 12);
+			snd_playSoundEffect(0x35);
+			setMouseItem(inventoryItem);
+			updateSentenceCommand(_itemList[inventoryItem], _takenList[0], 179);
+			_itemInHand = inventoryItem;
+			_screen->showMouse();
+			_currentCharacter->inventoryItems[itemOffset] = 0xFF;
+		}
+	} else {
+		if (inventoryItem != 0xFF) {
+			snd_playSoundEffect(0x35);
+			_screen->hideMouse();
+			_screen->fillRect(_itemPosX[itemOffset], _itemPosY[itemOffset], _itemPosX[itemOffset] + 15, _itemPosY[itemOffset] + 15, 12);
+			_screen->drawShape(0, _shapes[216+_itemInHand], _itemPosX[itemOffset], _itemPosY[itemOffset], 0, 0);
+			setMouseItem(inventoryItem);
+			updateSentenceCommand(_itemList[inventoryItem], _takenList[1], 179);
+			_screen->showMouse();
+			_currentCharacter->inventoryItems[itemOffset] = _itemInHand;
+			_itemInHand = inventoryItem;
+		} else {
+			snd_playSoundEffect(0x32);
+			_screen->hideMouse();
+			_screen->drawShape(0, _shapes[216+_itemInHand], _itemPosX[itemOffset], _itemPosY[itemOffset], 0, 0);
+			_screen->setMouseCursor(1, 1, _shapes[0]);
+			updateSentenceCommand(_itemList[_itemInHand], _placedList[0], 179);
+			_screen->showMouse();
+			_currentCharacter->inventoryItems[itemOffset] = _itemInHand;
+			_itemInHand = -1;
+		}
+	}
+	_screen->updateScreen();
+	// XXX clearKyrandiaButtonIO
+	return 0;
+}
+
+int KyraEngine_LoK::buttonAmuletCallback(Button *caller) {
+	if (!(_deathHandler & 8))
+		return 1;
+	int jewel = caller->index - 0x14;
+	if (_currentCharacter->sceneId == 210) {
+		if (_beadStateVar == 4 || _beadStateVar == 6)
+			return 1;
+	}
+	if (!queryGameFlag(0x2D))
+		return 1;
+	if (_itemInHand != -1) {
+		assert(_putDownFirst);
+		characterSays(2000, _putDownFirst[0], 0, -2);
+		return 1;
+	}
+	if (queryGameFlag(0xF1)) {
+		assert(_waitForAmulet);
+		characterSays(2001, _waitForAmulet[0], 0, -2);
+		return 1;
+	}
+	if (!queryGameFlag(0x55+jewel)) {
+		assert(_blackJewel);
+		_animator->makeBrandonFaceMouse();
+		drawJewelPress(jewel, 1);
+		characterSays(2002, _blackJewel[0], 0, -2);
+		return 1;
+	}
+	drawJewelPress(jewel, 0);
+	drawJewelsFadeOutStart();
+	drawJewelsFadeOutEnd(jewel);
+
+	_emc->init(&_scriptClick, &_scriptClickData);
+	_scriptClick.regs[3] = 0;
+	_scriptClick.regs[6] = jewel;
+	_emc->start(&_scriptClick, 4);
+
+	while (_emc->isValid(&_scriptClick))
+		_emc->run(&_scriptClick);
+
+	if (_scriptClick.regs[3])
+		return 1;
+
+	_unkAmuletVar = 1;
+	switch (jewel-1) {
+	case 0:
+		if (_brandonStatusBit & 1) {
+			seq_brandonHealing2();
+		} else if (_brandonStatusBit == 0) {
+			seq_brandonHealing();
+			assert(_healingTip);
+			characterSays(2003, _healingTip[0], 0, -2);
+		}
+		break;
+
+	case 1:
+		seq_makeBrandonInv();
+		break;
+
+	case 2:
+		if (_brandonStatusBit & 1) {
+			assert(_wispJewelStrings);
+			characterSays(2004, _wispJewelStrings[0], 0, -2);
+		} else {
+			if (_brandonStatusBit & 2) {
+				// XXX
+				seq_makeBrandonNormal2();
+				// XXX
+			} else {
+				// do not check for item in hand again as in the original since some strings are missing
+				// in the cd version
+				if (_currentCharacter->sceneId >= 109 && _currentCharacter->sceneId <= 198) {
+					snd_playWanderScoreViaMap(1, 0);
+					seq_makeBrandonWisp();
+					snd_playWanderScoreViaMap(17, 0);
+				} else {
+					seq_makeBrandonWisp();
+				}
+				setGameFlag(0x9E);
+			}
+		}
+		break;
+
+	case 3:
+		seq_dispelMagicAnimation();
+		assert(_magicJewelString);
+		characterSays(2007, _magicJewelString[0], 0, -2);
+		break;
+
+	default:
+		break;
+	}
+	_unkAmuletVar = 0;
+	// XXX clearKyrandiaButtonIO (!used before every return in this function!)
+	return 1;
+}
+
+#pragma mark -
+
+GUI_LoK::GUI_LoK(KyraEngine_LoK *vm, Screen_LoK *screen) : GUI(vm), _vm(vm), _screen(screen) {
+	_menu = 0;
+	initStaticResource();
+	_scrollUpFunctor = BUTTON_FUNCTOR(GUI_LoK, this, &GUI_LoK::scrollUp);
+	_scrollDownFunctor = BUTTON_FUNCTOR(GUI_LoK, this, &GUI_LoK::scrollDown);
+}
+
+GUI_LoK::~GUI_LoK() {
+	delete[] _menu;
+}
+
+int GUI_LoK::processButtonList(Button *list, uint16 inputFlag, int8 mouseWheel) {
+	while (list) {
+		if (list->flags & 8) {
+			list = list->nextButton;
+			continue;
+		}
+
+		if (mouseWheel && list->mouseWheel == mouseWheel && list->buttonCallback) {
+			if ((*list->buttonCallback.get())(list)) {
+				break;
+			}
+		}
+
+		int x = list->x;
+		int y = list->y;
+		assert(_screen->getScreenDim(list->dimTableIndex) != 0);
+		if (x < 0) {
+			x += _screen->getScreenDim(list->dimTableIndex)->w << 3;
+		}
+		x += _screen->getScreenDim(list->dimTableIndex)->sx << 3;
+
+		if (y < 0) {
+			y += _screen->getScreenDim(list->dimTableIndex)->h;
+		}
+		y += _screen->getScreenDim(list->dimTableIndex)->sy;
+
+		Common::Point mouse = _vm->getMousePos();
+		if (mouse.x >= x && mouse.y >= y && x + list->width >= mouse.x && y + list->height >= mouse.y) {
+			int processMouseClick = 0;
+			if (list->flags & 0x400) {
+				if (_vm->_mousePressFlag) {
+					if (!(list->flags2 & 1)) {
+						list->flags2 |= 1;
+						list->flags2 |= 4;
+						processButton(list);
+						_screen->updateScreen();
+					}
+				} else {
+					if (list->flags2 & 1) {
+						list->flags2 &= 0xFFFE;
+						processButton(list);
+						processMouseClick = 1;
+					}
+				}
+			} else if (_vm->_mousePressFlag) {
+				processMouseClick = 1;
+			}
+
+			if (processMouseClick) {
+				if (list->buttonCallback) {
+					if ((*list->buttonCallback.get())(list)) {
+						break;
+					}
+				}
+			}
+		} else {
+			if (list->flags2 & 1) {
+				list->flags2 &= 0xFFFE;
+				processButton(list);
+			}
+			if (list->flags2 & 4) {
+				list->flags2 &= 0xFFFB;
+				processButton(list);
+				_screen->updateScreen();
+			}
+			list = list->nextButton;
+			continue;
+		}
+
+		list = list->nextButton;
+	}
+	return 0;
+}
+
+void GUI_LoK::processButton(Button *button) {
+	if (!button)
+		return;
+
+	int processType = 0;
+	const uint8 *shape = 0;
+	Button::Callback callback;
+
+	int flags = (button->flags2 & 5);
+	if (flags == 1) {
+		processType = button->data2Val1;
+		if (processType == 1)
+			shape = button->data2ShapePtr;
+		else if (processType == 4)
+			callback = button->data2Callback;
+	} else if (flags == 4 || flags == 5) {
+		processType = button->data1Val1;
+		if (processType == 1)
+			shape = button->data1ShapePtr;
+		else if (processType == 4)
+			callback = button->data1Callback;
+	} else {
+		processType = button->data0Val1;
+		if (processType == 1)
+			shape = button->data0ShapePtr;
+		else if (processType == 4)
+			callback = button->data0Callback;
+	}
+
+	int x = button->x;
+	int y = button->y;
+	assert(_screen->getScreenDim(button->dimTableIndex) != 0);
+	if (x < 0)
+		x += _screen->getScreenDim(button->dimTableIndex)->w << 3;
+
+	if (y < 0)
+		y += _screen->getScreenDim(button->dimTableIndex)->h;
+
+	if (processType == 1 && shape)
+		_screen->drawShape(_screen->_curPage, shape, x, y, button->dimTableIndex, 0x10);
+	else if (processType == 4 && callback)
+		(*callback.get())(button);
+}
+
+void GUI_LoK::setGUILabels() {
+	int offset = 0;
+	int offsetOptions = 0;
+	int offsetMainMenu = 0;
+	int offsetOn = 0;
+
+	int walkspeedGarbageOffset = 36;
+	int menuLabelGarbageOffset = 0;
+
+	if (_vm->gameFlags().isTalkie) {
+		if (_vm->gameFlags().lang == Common::EN_ANY)
+			offset = 52;
+		else if (_vm->gameFlags().lang == Common::DE_DEU)
+			offset = 30;
+		else if (_vm->gameFlags().lang == Common::FR_FRA || _vm->gameFlags().lang == Common::IT_ITA)
+			offset = 6;
+		offsetOn = offsetMainMenu = offsetOptions = offset;
+		walkspeedGarbageOffset = 48;
+	} else if (_vm->gameFlags().lang == Common::ES_ESP) {
+		offsetOn = offsetMainMenu = offsetOptions = offset = -4;
+		menuLabelGarbageOffset = 72;
+	} else if (_vm->gameFlags().lang == Common::DE_DEU) {
+		offset = offsetMainMenu = offsetOn = offsetOptions = 24;
+	} else if (_vm->gameFlags().platform == Common::kPlatformFMTowns || _vm->gameFlags().platform == Common::kPlatformPC98) {
+		offset = 1;
+		offsetOptions = 10;
+		offsetOn = 0;
+		walkspeedGarbageOffset = 0;
+	}
+
+	assert(offset + 27 < _vm->_guiStringsSize);
+
+	// The Legend of Kyrandia
+	_menu[0].menuNameString = _vm->_guiStrings[0];
+	// Load a Game
+	_menu[0].item[0].itemString = _vm->_guiStrings[1];
+	// Save a Game
+	_menu[0].item[1].itemString = _vm->_guiStrings[2];
+	// Game controls
+	_menu[0].item[2].itemString = _vm->_guiStrings[3];
+	// Quit playing
+	_menu[0].item[3].itemString = _vm->_guiStrings[4];
+	// Resume game
+	_menu[0].item[4].itemString = _vm->_guiStrings[5];
+
+	// Cancel
+	_menu[2].item[5].itemString = _vm->_guiStrings[10];
+
+	// Enter a description of your saved game:
+	_menu[3].menuNameString = _vm->_guiStrings[11];
+	// Save
+	_menu[3].item[0].itemString = _vm->_guiStrings[12];
+	// Cancel
+	_menu[3].item[1].itemString = _vm->_guiStrings[10];
+
+	// Rest in peace, Brandon
+	_menu[4].menuNameString = _vm->_guiStrings[13];
+	// Load a game
+	_menu[4].item[0].itemString = _vm->_guiStrings[1];
+	// Quit playing
+	_menu[4].item[1].itemString = _vm->_guiStrings[4];
+
+	// Game Controls
+	_menu[5].menuNameString = _vm->_guiStrings[6];
+	// Yes
+	_menu[1].item[0].itemString = _vm->_guiStrings[22 + offset];
+	// No
+	_menu[1].item[1].itemString = _vm->_guiStrings[23 + offset];
+
+	// Music is
+	_menu[5].item[0].labelString = _vm->_guiStrings[26 + offsetOptions];
+	// Sounds are
+	_menu[5].item[1].labelString = _vm->_guiStrings[27 + offsetOptions];
+	// Walk speed
+	_menu[5].item[2].labelString = &_vm->_guiStrings[24 + offsetOptions][walkspeedGarbageOffset];
+	// Text speed
+	_menu[5].item[4].labelString = _vm->_guiStrings[25 + offsetOptions];
+	// Main Menu
+	_menu[5].item[5].itemString = &_vm->_guiStrings[19 + offsetMainMenu][menuLabelGarbageOffset];
+
+	if (_vm->gameFlags().isTalkie)
+		// Text & Voice
+		_voiceTextString = _vm->_guiStrings[28 + offset];
+
+	_textSpeedString = _vm->_guiStrings[25 + offsetOptions];
+	_onString =  _vm->_guiStrings[20 + offsetOn];
+	_offString =  _vm->_guiStrings[21 + offset];
+	_onCDString = _vm->_guiStrings[21];
+}
+
+int GUI_LoK::buttonMenuCallback(Button *caller) {
+	PauseTimer pause(*_vm->_timer);
+
+	_displayMenu = true;
+
+	assert(_vm->_guiStrings);
+	assert(_vm->_configStrings);
+
+	/*
+	for (int i = 0; i < _vm->_guiStringsSize; i++)
+		debug("GUI string %i: %s", i, _vm->_guiStrings[i]);
+
+	for (int i = 0; i < _vm->_configStringsSize; i++)
+		debug("Config string %i: %s", i, _vm->_configStrings[i]);
+	*/
+
+	setGUILabels();
+	if (_vm->_currentCharacter->sceneId == 210 && _vm->_deathHandler == 0xFF) {
+		_vm->snd_playSoundEffect(0x36);
+		return 0;
+	}
+	// XXX
+	_screen->setPaletteIndex(0xFE, 60, 60, 0);
+	for (int i = 0; i < 6; i++) {
+		_menuButtonData[i].data0Val1 = _menuButtonData[i].data1Val1 = _menuButtonData[i].data2Val1 = 4;
+		_menuButtonData[i].data0Callback = _redrawShadedButtonFunctor;
+		_menuButtonData[i].data1Callback = _redrawButtonFunctor;
+		_menuButtonData[i].data2Callback = _redrawButtonFunctor;
+	}
+
+	_screen->savePageToDisk("SEENPAGE.TMP", 0);
+	fadePalette();
+
+	for (int i = 0; i < 5; i++)
+		initMenuLayout(_menu[i]);
+
+	_menuRestoreScreen = true;
+	_keyPressed.reset();
+	_vm->_mousePressFlag = false;
+
+	_toplevelMenu = 0;
+	if (_vm->_menuDirectlyToLoad) {
+		loadGameMenu(0);
+	} else {
+		if (!caller)
+			_toplevelMenu = 4;
+
+		initMenu(_menu[_toplevelMenu]);
+		updateAllMenuButtons();
+	}
+
+	while (_displayMenu && !_vm->_quitFlag) {
+		Common::Point mouse = _vm->getMousePos();
+		processHighlights(_menu[_toplevelMenu], mouse.x, mouse.y);
+		processButtonList(_menuButtonList, 0, 0);
+		getInput();
+	}
+
+	if (_menuRestoreScreen) {
+		restorePalette();
+		_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+		_vm->_animator->_updateScreen = true;
+	} else {
+		_screen->deletePageFromDisk(0);
+	}
+
+	return 0;
+}
+
+void GUI_LoK::getInput() {
+	Common::Event event;
+	static uint32 lastScreenUpdate = 0;
+	uint32 now = _vm->_system->getMillis();
+
+	_mouseWheel = 0;
+	while (_vm->_eventMan->pollEvent(event)) {
+		switch (event.type) {
+		case Common::EVENT_QUIT:
+			_vm->quitGame();
+			break;
+		case Common::EVENT_LBUTTONDOWN:
+			_vm->_mousePressFlag = true;
+			break;
+		case Common::EVENT_LBUTTONUP:
+			_vm->_mousePressFlag = false;
+			break;
+		case Common::EVENT_MOUSEMOVE:
+			_vm->_system->updateScreen();
+			lastScreenUpdate = now;
+			break;
+		case Common::EVENT_WHEELUP:
+			_mouseWheel = -1;
+			break;
+		case Common::EVENT_WHEELDOWN:
+			_mouseWheel = 1;
+			break;
+		case Common::EVENT_KEYDOWN:
+			_keyPressed = event.kbd;
+			break;
+		default:
+			break;
+		}
+	}
+
+	if (now - lastScreenUpdate > 50) {
+		_vm->_system->updateScreen();
+		lastScreenUpdate = now;
+	}
+
+	_vm->_system->delayMillis(3);
+}
+
+int GUI_LoK::resumeGame(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::resumeGame()");
+	updateMenuButton(button);
+	_displayMenu = false;
+
+	return 0;
+}
+
+void GUI_LoK::setupSavegames(Menu &menu, int num) {
+	Common::InSaveFile *in;
+	static char savenames[5][31];
+	uint8 startSlot;
+	assert(num <= 5);
+
+	if (_savegameOffset == 0) {
+		menu.item[0].itemString = _specialSavegameString;
+		menu.item[0].enabled = 1;
+		menu.item[0].saveSlot = 0;
+		startSlot = 1;
+	} else {
+		startSlot = 0;
+	}
+
+	for (int i = startSlot; i < num; ++i)
+		menu.item[i].enabled = 0;
+
+	KyraEngine::SaveHeader header;
+	for (int i = startSlot; i < num && uint(_savegameOffset + i) < _saveSlots.size(); i++) {
+		if ((in = _vm->openSaveForReading(_vm->getSavegameFilename(_saveSlots[i + _savegameOffset]), header))) {
+			strncpy(savenames[i], header.description.c_str(), 31);
+			menu.item[i].itemString = savenames[i];
+			menu.item[i].enabled = 1;
+			menu.item[i].saveSlot = _saveSlots[i + _savegameOffset];
+			delete in;
+		}
+	}
+}
+
+int GUI_LoK::saveGameMenu(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::saveGameMenu()");
+	updateSaveList();
+
+	updateMenuButton(button);
+	_menu[2].item[5].enabled = true;
+
+	_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+	_screen->savePageToDisk("SEENPAGE.TMP", 0);
+
+	_menu[2].menuNameString = _vm->_guiStrings[8]; // Select a position to save to:
+	_specialSavegameString = _vm->_guiStrings[9]; // [ EMPTY SLOT ]
+	for (int i = 0; i < 5; i++)
+		_menu[2].item[i].callback = BUTTON_FUNCTOR(GUI_LoK, this, &GUI_LoK::saveGame);
+
+	_savegameOffset = 0;
+	setupSavegames(_menu[2], 5);
+
+	initMenu(_menu[2]);
+	updateAllMenuButtons();
+
+	_displaySubMenu = true;
+	_cancelSubMenu = false;
+
+	while (_displaySubMenu && !_vm->_quitFlag) {
+		getInput();
+		Common::Point mouse = _vm->getMousePos();
+		processHighlights(_menu[2], mouse.x, mouse.y);
+		processButtonList(_menuButtonList, 0, _mouseWheel);
+	}
+
+	_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+	_screen->savePageToDisk("SEENPAGE.TMP", 0);
+
+	if (_cancelSubMenu) {
+		initMenu(_menu[0]);
+		updateAllMenuButtons();
+	} else {
+		_displayMenu = false;
+	}
+	return 0;
+}
+
+int GUI_LoK::loadGameMenu(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::loadGameMenu()");
+	updateSaveList();
+
+	if (_vm->_menuDirectlyToLoad) {
+		_menu[2].item[5].enabled = false;
+	} else {
+		updateMenuButton(button);
+		_menu[2].item[5].enabled = true;
+	}
+
+	_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+	_screen->savePageToDisk("SEENPAGE.TMP", 0);
+
+	_specialSavegameString = _vm->_newGameString[0]; //[ START A NEW GAME ]
+	_menu[2].menuNameString = _vm->_guiStrings[7]; // Which game would you like to reload?
+	for (int i = 0; i < 5; i++)
+		_menu[2].item[i].callback = BUTTON_FUNCTOR(GUI_LoK, this, &GUI_LoK::loadGame);
+
+	_savegameOffset = 0;
+	setupSavegames(_menu[2], 5);
+
+	initMenu(_menu[2]);
+	updateAllMenuButtons();
+
+	_displaySubMenu = true;
+	_cancelSubMenu = false;
+
+	_vm->_gameToLoad = -1;
+
+	while (_displaySubMenu && !_vm->_quitFlag) {
+		getInput();
+		Common::Point mouse = _vm->getMousePos();
+		processHighlights(_menu[2], mouse.x, mouse.y);
+		processButtonList(_menuButtonList, 0, _mouseWheel);
+	}
+
+	_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+	_screen->savePageToDisk("SEENPAGE.TMP", 0);
+
+	if (_cancelSubMenu) {
+		initMenu(_menu[_toplevelMenu]);
+		updateAllMenuButtons();
+	} else {
+		restorePalette();
+		if (_vm->_gameToLoad != -1)
+			_vm->loadGame(_vm->getSavegameFilename(_vm->_gameToLoad));
+		_displayMenu = false;
+		_menuRestoreScreen = false;
+	}
+	return 0;
+}
+
+void GUI_LoK::redrawTextfield() {
+	_screen->fillRect(38, 91, 287, 102, 250);
+	_text->printText(_savegameName, 38, 92, 253, 0, 0);
+
+	_screen->_charWidth = -2;
+	int width = _screen->getTextWidth(_savegameName);
+	_screen->fillRect(39 + width, 93, 45 + width, 100, 254);
+	_screen->_charWidth = 0;
+
+	_screen->updateScreen();
+}
+
+void GUI_LoK::updateSavegameString() {
+	int length;
+
+	if (_keyPressed.keycode) {
+		length = strlen(_savegameName);
+
+		if (_keyPressed.ascii > 31 && _keyPressed.ascii < 127) {
+			if (length < 31) {
+				_savegameName[length] = _keyPressed.ascii;
+				_savegameName[length+1] = 0;
+				redrawTextfield();
+			}
+		} else if (_keyPressed.keycode == Common::KEYCODE_BACKSPACE ||
+		           _keyPressed.keycode == Common::KEYCODE_DELETE) {
+			if (length > 0) {
+				_savegameName[length-1] = 0;
+				redrawTextfield();
+			}
+		} else if (_keyPressed.keycode == Common::KEYCODE_RETURN ||
+		           _keyPressed.keycode == Common::KEYCODE_KP_ENTER) {
+			_displaySubMenu = false;
+		}
+	}
+
+	_keyPressed.reset();
+}
+
+int GUI_LoK::saveGame(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::saveGame()");
+	updateMenuButton(button);
+	_vm->_gameToLoad = _menu[2].item[button->index-0xC].saveSlot;
+
+	_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+	_screen->savePageToDisk("SEENPAGE.TMP", 0);
+
+	initMenu(_menu[3]);
+	updateAllMenuButtons();
+
+	_displaySubMenu = true;
+	_cancelSubMenu = false;
+
+	if (_savegameOffset == 0 && _vm->_gameToLoad == 0) {
+		_savegameName[0] = 0;
+	} else {
+		for (int i = 0; i < 5; i++) {
+			if (_menu[2].item[i].saveSlot == _vm->_gameToLoad) {
+				strncpy(_savegameName, _menu[2].item[i].itemString, 31);
+				break;
+			}
+		}
+	}
+	redrawTextfield();
+
+	while (_displaySubMenu && !_vm->_quitFlag) {
+		getInput();
+		updateSavegameString();
+		Common::Point mouse = _vm->getMousePos();
+		processHighlights(_menu[3], mouse.x, mouse.y);
+		processButtonList(_menuButtonList, 0, 0);
+	}
+
+	if (_cancelSubMenu) {
+		_displaySubMenu = true;
+		_cancelSubMenu = false;
+		initMenu(_menu[2]);
+		updateAllMenuButtons();
+	} else {
+		if (_savegameOffset == 0 && _vm->_gameToLoad == 0)
+			_vm->_gameToLoad = getNextSavegameSlot();
+		if (_vm->_gameToLoad > 0)
+			_vm->saveGame(_vm->getSavegameFilename(_vm->_gameToLoad), _savegameName);
+	}
+
+	return 0;
+}
+
+int GUI_LoK::savegameConfirm(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::savegameConfirm()");
+	updateMenuButton(button);
+	_displaySubMenu = false;
+
+	return 0;
+}
+
+int GUI_LoK::loadGame(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::loadGame()");
+	updateMenuButton(button);
+	_displaySubMenu = false;
+	_vm->_gameToLoad = _menu[2].item[button->index-0xC].saveSlot;
+
+	return 0;
+}
+
+int GUI_LoK::cancelSubMenu(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::cancelSubMenu()");
+	updateMenuButton(button);
+	_displaySubMenu = false;
+	_cancelSubMenu = true;
+
+	return 0;
+}
+
+int GUI_LoK::quitPlaying(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::quitPlaying()");
+	updateMenuButton(button);
+
+	if (quitConfirm(_vm->_guiStrings[14])) { // Are you sure you want to quit playing?
+		_vm->quitGame();
+	} else {
+		initMenu(_menu[_toplevelMenu]);
+		updateAllMenuButtons();
+	}
+
+	return 0;
+}
+
+bool GUI_LoK::quitConfirm(const char *str) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::quitConfirm()");
+
+	_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+	_screen->savePageToDisk("SEENPAGE.TMP", 0);
+
+	_menu[1].menuNameString = str;
+	initMenuLayout(_menu[1]);
+	initMenu(_menu[1]);
+
+	_displaySubMenu = true;
+	_cancelSubMenu = true;
+
+	while (_displaySubMenu && !_vm->_quitFlag) {
+		getInput();
+		Common::Point mouse = _vm->getMousePos();
+		processHighlights(_menu[1], mouse.x, mouse.y);
+		processButtonList(_menuButtonList, 0, 0);
+	}
+
+	_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+	_screen->savePageToDisk("SEENPAGE.TMP", 0);
+
+	return !_cancelSubMenu;
+}
+
+int GUI_LoK::quitConfirmYes(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::quitConfirmYes()");
+	updateMenuButton(button);
+	_displaySubMenu = false;
+	_cancelSubMenu = false;
+
+	return 0;
+}
+
+int GUI_LoK::quitConfirmNo(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::quitConfirmNo()");
+	updateMenuButton(button);
+	_displaySubMenu = false;
+	_cancelSubMenu = true;
+
+	return 0;
+}
+
+int GUI_LoK::gameControlsMenu(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::gameControlsMenu()");
+
+	_vm->readSettings();
+
+	_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+	_screen->savePageToDisk("SEENPAGE.TMP", 0);
+
+	if (_vm->gameFlags().isTalkie) {
+		//_menu[5].width = 230;
+
+		for (int i = 0; i < 5; i++) {
+			//_menu[5].item[i].labelX = 24;
+			//_menu[5].item[i].x = 115;
+			//_menu[5].item[i].width = 94;
+		}
+
+		_menu[5].item[3].labelString = _voiceTextString; //"Voice / Text "
+		_menu[5].item[3].callback = BUTTON_FUNCTOR(GUI_LoK, this, &GUI_LoK::controlsChangeVoice);
+
+	} else {
+		//_menu[5].height = 136;
+		//_menu[5].item[5].y = 110;
+		_menu[5].item[4].enabled = 0;
+		_menu[5].item[3].labelString = _textSpeedString; // "Text speed "
+		_menu[5].item[3].callback = BUTTON_FUNCTOR(GUI_LoK, this, &GUI_LoK::controlsChangeText);
+	}
+
+	setupControls(_menu[5]);
+
+	updateAllMenuButtons();
+
+	_displaySubMenu = true;
+	_cancelSubMenu = false;
+
+	while (_displaySubMenu && !_vm->_quitFlag) {
+		getInput();
+		Common::Point mouse = _vm->getMousePos();
+		processHighlights(_menu[5], mouse.x, mouse.y);
+		processButtonList(_menuButtonList, 0, 0);
+	}
+
+	_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+	_screen->savePageToDisk("SEENPAGE.TMP", 0);
+
+	if (_cancelSubMenu) {
+		initMenu(_menu[_toplevelMenu]);
+		updateAllMenuButtons();
+	}
+	return 0;
+}
+
+void GUI_LoK::setupControls(Menu &menu) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::setupControls()");
+
+	switch (_vm->_configMusic) {
+		case 0:
+			menu.item[0].itemString = _offString; //"Off"
+			break;
+		case 1:
+			menu.item[0].itemString = _onString; //"On"
+			break;
+		case 2:
+			menu.item[0].itemString = _onCDString; //"On + CD"
+			break;
+	}
+
+	if (_vm->_configSounds)
+		menu.item[1].itemString = _onString; //"On"
+	else
+		menu.item[1].itemString = _offString; //"Off"
+
+
+	switch (_vm->_configWalkspeed) {
+	case 0:
+		menu.item[2].itemString = _vm->_configStrings[0]; //"Slowest"
+		break;
+	case 1:
+		menu.item[2].itemString = _vm->_configStrings[1]; //"Slow"
+		break;
+	case 2:
+		menu.item[2].itemString = _vm->_configStrings[2]; //"Normal"
+		break;
+	case 3:
+		menu.item[2].itemString = _vm->_configStrings[3]; //"Fast"
+		break;
+	case 4:
+		menu.item[2].itemString = _vm->_configStrings[4]; //"Fastest"
+		break;
+	default:
+		menu.item[2].itemString = "ERROR";
+		break;
+	}
+
+	int textControl = 3;
+	int clickableOffset = 8;
+	if (_vm->gameFlags().isTalkie) {
+		textControl = 4;
+		clickableOffset = 11;
+
+		if (_vm->_configVoice == 0) {
+			menu.item[4].enabled = 1;
+			menu.item[4].labelString = _textSpeedString;
+		} else {
+			menu.item[4].enabled = 0;
+			menu.item[4].labelString = 0;
+		}
+
+		switch (_vm->_configVoice) {
+		case 0:
+			menu.item[3].itemString = _vm->_configStrings[5]; //"Text only"
+			break;
+		case 1:
+			menu.item[3].itemString = _vm->_configStrings[6]; //"Voice only"
+			break;
+		case 2:
+			menu.item[3].itemString = _vm->_configStrings[7]; //"Voice & Text"
+			break;
+		default:
+			menu.item[3].itemString = "ERROR";
+			break;
+		}
+	} else {
+		menu.item[4].enabled = 0;
+		menu.item[4].labelString = 0;
+	}
+
+	switch (_vm->_configTextspeed) {
+	case 0:
+		menu.item[textControl].itemString = _vm->_configStrings[1]; //"Slow"
+		break;
+	case 1:
+		menu.item[textControl].itemString = _vm->_configStrings[2]; //"Normal"
+		break;
+	case 2:
+		menu.item[textControl].itemString = _vm->_configStrings[3]; //"Fast"
+		break;
+	case 3:
+		menu.item[textControl].itemString = _vm->_configStrings[clickableOffset]; //"Clickable"
+		break;
+	default:
+		menu.item[textControl].itemString = "ERROR";
+		break;
+	}
+
+	initMenuLayout(menu);
+	initMenu(menu);
+}
+
+int GUI_LoK::controlsChangeMusic(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::controlsChangeMusic()");
+	updateMenuButton(button);
+
+	_vm->_configMusic = ++_vm->_configMusic % ((_vm->gameFlags().platform == Common::kPlatformFMTowns || _vm->gameFlags().platform == Common::kPlatformPC98) ? 3 : 2);
+	setupControls(_menu[5]);
+	return 0;
+}
+
+int GUI_LoK::controlsChangeSounds(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::controlsChangeSounds()");
+	updateMenuButton(button);
+
+	_vm->_configSounds = !_vm->_configSounds;
+	setupControls(_menu[5]);
+	return 0;
+}
+
+int GUI_LoK::controlsChangeWalk(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::controlsChangeWalk()");
+	updateMenuButton(button);
+
+	_vm->_configWalkspeed = ++_vm->_configWalkspeed % 5;
+	_vm->setWalkspeed(_vm->_configWalkspeed);
+	setupControls(_menu[5]);
+	return 0;
+}
+
+int GUI_LoK::controlsChangeText(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::controlsChangeText()");
+	updateMenuButton(button);
+
+	_vm->_configTextspeed = ++_vm->_configTextspeed % 4;
+	setupControls(_menu[5]);
+	return 0;
+}
+
+int GUI_LoK::controlsChangeVoice(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::controlsChangeVoice()");
+	updateMenuButton(button);
+
+	_vm->_configVoice = ++_vm->_configVoice % 3;
+	setupControls(_menu[5]);
+	return 0;
+}
+
+int GUI_LoK::controlsApply(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::controlsApply()");
+	_vm->writeSettings();
+	return cancelSubMenu(button);
+}
+
+int GUI_LoK::scrollUp(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::scrollUp()");
+	updateMenuButton(button);
+
+	if (_savegameOffset > 0) {
+		_savegameOffset--;
+		setupSavegames(_menu[2], 5);
+		initMenu(_menu[2]);
+	}
+	return 0;
+}
+
+int GUI_LoK::scrollDown(Button *button) {
+	debugC(9, kDebugLevelGUI, "GUI_LoK::scrollDown()");
+	updateMenuButton(button);
+
+	_savegameOffset++;
+	if (uint(_savegameOffset + 5) >= _saveSlots.size())
+		_savegameOffset = MAX<int>(_saveSlots.size() - 5, 0);
+	setupSavegames(_menu[2], 5);
+	initMenu(_menu[2]);
+
+	return 0;
+}
+
+void GUI_LoK::fadePalette() {
+	if (_vm->gameFlags().platform == Common::kPlatformAmiga)
+		return;
+
+	static int16 menuPalIndexes[] = {248, 249, 250, 251, 252, 253, 254, -1};
+	int index = 0;
+
+	memcpy(_screen->getPalette(2), _screen->_currentPalette, 768);
+
+	for (int i = 0; i < 768; i++)
+		_screen->_currentPalette[i] >>= 1;
+
+	while (menuPalIndexes[index] != -1) {
+		memcpy(&_screen->_currentPalette[menuPalIndexes[index]*3], &_screen->getPalette(2)[menuPalIndexes[index]*3], 3);
+		index++;
+	}
+
+	_screen->fadePalette(_screen->_currentPalette, 2);
+}
+
+void GUI_LoK::restorePalette() {
+	if (_vm->gameFlags().platform == Common::kPlatformAmiga)
+		return;
+
+	memcpy(_screen->_currentPalette, _screen->getPalette(2), 768);
+	_screen->fadePalette(_screen->_currentPalette, 2);
+}
+
+#pragma mark -
+
+void KyraEngine_LoK::drawAmulet() {
+	debugC(9, kDebugLevelMain, "KyraEngine_LoK::drawAmulet()");
+	static const int16 amuletTable1[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x150, 0x155, 0x15A, 0x15F, 0x164, 0x145, -1};
+	static const int16 amuletTable3[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x14F, 0x154, 0x159, 0x15E, 0x163, 0x144, -1};
+	static const int16 amuletTable2[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x152, 0x157, 0x15C, 0x161, 0x166, 0x147, -1};
+	static const int16 amuletTable4[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x151, 0x156, 0x15B, 0x160, 0x165, 0x146, -1};
+
+	resetGameFlag(0xF1);
+	_screen->hideMouse();
+
+	int i = 0;
+	while (amuletTable1[i] != -1) {
+		if (queryGameFlag(87))
+			_screen->drawShape(0, _shapes[amuletTable1[i]], _amuletX[0], _amuletY[0], 0, 0);
+
+		if (queryGameFlag(89))
+			_screen->drawShape(0, _shapes[amuletTable2[i]], _amuletX[1], _amuletY[1], 0, 0);
+
+		if (queryGameFlag(86))
+			_screen->drawShape(0, _shapes[amuletTable3[i]], _amuletX[2], _amuletY[2], 0, 0);
+
+		if (queryGameFlag(88))
+			_screen->drawShape(0, _shapes[amuletTable4[i]], _amuletX[3], _amuletY[3], 0, 0);
+
+		_screen->updateScreen();
+		delayWithTicks(3);
+		i++;
+	}
+	_screen->showMouse();
+}
+
+} // end of namespace Kyra
+

Copied: scummvm/trunk/engines/kyra/gui_lok.h (from rev 32035, scummvm/trunk/engines/kyra/gui_v1.h)
===================================================================
--- scummvm/trunk/engines/kyra/gui_lok.h	                        (rev 0)
+++ scummvm/trunk/engines/kyra/gui_lok.h	2008-05-11 22:32:37 UTC (rev 32042)
@@ -0,0 +1,177 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef KYRA_GUI_V1_H
+#define KYRA_GUI_V1_H
+
+#include "kyra/gui.h"
+
+namespace Kyra {
+
+#define GUI_V1_BUTTON(button, a, b, c, d, e, f, g, h, i, j, k) \
+	button.nextButton = 0; \
+	button.index = a; \
+	button.unk6 = button.unk8 = 0; \
+	button.data0Val1 = b; \
+	button.data1Val1 = c; \
+	button.data2Val1 = d; \
+	button.data0ShapePtr = button.data1ShapePtr = button.data2ShapePtr = 0; \
+	button.flags = e; \
+	button.dimTableIndex = f; \
+	button.x = g; \
+	button.y = h; \
+	button.width = i; \
+	button.height = j; \
+	button.flags2 = k; \
+	button.mouseWheel = 0
+
+#define GUI_V1_MENU(menu, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) \
+	menu.x = a; \
+	menu.y = b; \
+	menu.width = c; \
+	menu.height = d; \
+	menu.bkgdColor = e; \
+	menu.color1 = f; \
+	menu.color2 = g; \
+	menu.menuNameString = h; \
+	menu.textColor = i; \
+	menu.titleX = j; \
+	menu.titleY = k; \
+	menu.highlightedItem = l; \
+	menu.numberOfItems = m; \
+	menu.scrollUpButtonX = n; \
+	menu.scrollUpButtonY = o; \
+	menu.scrollDownButtonX = p; \
+	menu.scrollDownButtonY = q
+
+#define GUI_V1_MENU_ITEM(item, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) \
+	item.enabled = a; \
+	item.itemString = d; \
+	item.x = e; \
+	item.y = g; \
+	item.width = h; \
+	item.height = i; \
+	item.textColor = j; \
+	item.highlightColor = k; \
+	item.titleX = l; \
+	item.bkgdColor = n; \
+	item.color1 = o; \
+	item.color2 = p; \
+	item.saveSlot = q; \
+	item.labelString = r; \
+	item.labelX = s; \
+	item.labelY = t; \
+	item.unk1F = v
+
+class KyraEngine_LoK;
+
+class GUI_LoK : public GUI {
+	friend class KyraEngine_LoK;
+public:
+	GUI_LoK(KyraEngine_LoK *vm, Screen_LoK *screen);
+	~GUI_LoK();
+
+	void processButton(Button *button);
+	int processButtonList(Button *buttonList, uint16 inputFlags, int8 mouseWheel);
+
+	int buttonMenuCallback(Button *caller);
+private:
+	void initStaticResource();
+
+	Button _menuButtonData[6];
+	Button _scrollUpButton;
+	Button _scrollDownButton;
+	Button *getButtonListData() { return _menuButtonData; }
+	Button *getScrollUpButton() { return &_scrollUpButton; }
+	Button *getScrollDownButton() { return &_scrollDownButton; }
+
+	Menu *_menu;
+
+	void setGUILabels();
+
+	void setupSavegames(Menu &menu, int num);
+
+	int resumeGame(Button *button);
+	int loadGameMenu(Button *button);
+	int saveGameMenu(Button *button);
+	int gameControlsMenu(Button *button);
+	int quitPlaying(Button *button);
+	int quitConfirmYes(Button *button);
+	int quitConfirmNo(Button *button);
+	int loadGame(Button *button);
+	int saveGame(Button *button);
+	int savegameConfirm(Button *button);
+	int cancelSubMenu(Button *button);
+	int scrollUp(Button *button);
+	int scrollDown(Button *button);
+	int controlsChangeMusic(Button *button);
+	int controlsChangeSounds(Button *button);
+	int controlsChangeWalk(Button *button);
+	int controlsChangeText(Button *button);
+	int controlsChangeVoice(Button *button);
+	int controlsApply(Button *button);
+
+	bool quitConfirm(const char *str);
+	void getInput();
+	void updateSavegameString();
+	void redrawTextfield();
+	void fadePalette();
+	void restorePalette();
+	void setupControls(Menu &menu);
+
+	uint8 defaultColor1() const { return 12; }
+	uint8 defaultColor2() const { return 248; }
+
+	const char *getMenuTitle(const Menu &menu) { return menu.menuNameString; }
+	const char *getMenuItemTitle(const MenuItem &menuItem) { return menuItem.itemString; }
+	const char *getMenuItemLabel(const MenuItem &menuItem) { return menuItem.labelString; }
+
+	KyraEngine_LoK *_vm;
+	Screen_LoK *_screen;
+
+	bool _menuRestoreScreen;
+	uint8 _toplevelMenu;
+	int _savegameOffset;
+	char _savegameName[31];
+	const char *_specialSavegameString;
+	Common::KeyState _keyPressed;
+	int8 _mouseWheel;
+
+	Button::Callback _scrollUpFunctor;
+	Button::Callback _scrollDownFunctor;
+	Button::Callback getScrollUpButtonHandler() const { return _scrollUpFunctor; }
+	Button::Callback getScrollDownButtonHandler() const { return _scrollDownFunctor; }
+
+	const char *_voiceTextString;
+	const char *_textSpeedString;
+	const char *_onString;
+	const char *_offString;
+	const char *_onCDString;
+};
+
+} // end of namespace Kyra
+
+#endif
+

Deleted: scummvm/trunk/engines/kyra/gui_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_v1.cpp	2008-05-11 22:08:32 UTC (rev 32041)
+++ scummvm/trunk/engines/kyra/gui_v1.cpp	2008-05-11 22:32:37 UTC (rev 32042)
@@ -1,1115 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "kyra/kyra_v1.h"
-#include "kyra/screen.h"
-#include "kyra/script.h"
-#include "kyra/text.h"
-#include "kyra/animator_v1.h"
-#include "kyra/sound.h"
-#include "kyra/gui_v1.h"
-#include "kyra/timer.h"
-
-#include "common/config-manager.h"
-#include "common/savefile.h"
-#include "common/events.h"
-#include "common/system.h"
-
-namespace Kyra {
-
-void KyraEngine_v1::initMainButtonList() {
-	_buttonList = &_buttonData[0];
-	for (int i = 0; _buttonDataListPtr[i]; ++i)
-		_buttonList = _gui->addButtonToList(_buttonList, _buttonDataListPtr[i]);
-}
-
-int KyraEngine_v1::buttonInventoryCallback(Button *caller) {
-	int itemOffset = caller->index - 2;
-	uint8 inventoryItem = _currentCharacter->inventoryItems[itemOffset];
-	if (_itemInHand == -1) {
-		if (inventoryItem == 0xFF) {
-			snd_playSoundEffect(0x36);
-			return 0;
-		} else {
-			_screen->hideMouse();
-			_screen->fillRect(_itemPosX[itemOffset], _itemPosY[itemOffset], _itemPosX[itemOffset] + 15, _itemPosY[itemOffset] + 15, 12);
-			snd_playSoundEffect(0x35);
-			setMouseItem(inventoryItem);
-			updateSentenceCommand(_itemList[inventoryItem], _takenList[0], 179);
-			_itemInHand = inventoryItem;
-			_screen->showMouse();
-			_currentCharacter->inventoryItems[itemOffset] = 0xFF;
-		}
-	} else {
-		if (inventoryItem != 0xFF) {
-			snd_playSoundEffect(0x35);
-			_screen->hideMouse();
-			_screen->fillRect(_itemPosX[itemOffset], _itemPosY[itemOffset], _itemPosX[itemOffset] + 15, _itemPosY[itemOffset] + 15, 12);
-			_screen->drawShape(0, _shapes[216+_itemInHand], _itemPosX[itemOffset], _itemPosY[itemOffset], 0, 0);
-			setMouseItem(inventoryItem);
-			updateSentenceCommand(_itemList[inventoryItem], _takenList[1], 179);
-			_screen->showMouse();
-			_currentCharacter->inventoryItems[itemOffset] = _itemInHand;
-			_itemInHand = inventoryItem;
-		} else {
-			snd_playSoundEffect(0x32);
-			_screen->hideMouse();
-			_screen->drawShape(0, _shapes[216+_itemInHand], _itemPosX[itemOffset], _itemPosY[itemOffset], 0, 0);
-			_screen->setMouseCursor(1, 1, _shapes[0]);
-			updateSentenceCommand(_itemList[_itemInHand], _placedList[0], 179);
-			_screen->showMouse();
-			_currentCharacter->inventoryItems[itemOffset] = _itemInHand;
-			_itemInHand = -1;
-		}
-	}
-	_screen->updateScreen();
-	// XXX clearKyrandiaButtonIO
-	return 0;
-}
-
-int KyraEngine_v1::buttonAmuletCallback(Button *caller) {
-	if (!(_deathHandler & 8))
-		return 1;
-	int jewel = caller->index - 0x14;
-	if (_currentCharacter->sceneId == 210) {
-		if (_beadStateVar == 4 || _beadStateVar == 6)
-			return 1;
-	}
-	if (!queryGameFlag(0x2D))
-		return 1;
-	if (_itemInHand != -1) {
-		assert(_putDownFirst);
-		characterSays(2000, _putDownFirst[0], 0, -2);
-		return 1;
-	}
-	if (queryGameFlag(0xF1)) {
-		assert(_waitForAmulet);
-		characterSays(2001, _waitForAmulet[0], 0, -2);
-		return 1;
-	}
-	if (!queryGameFlag(0x55+jewel)) {
-		assert(_blackJewel);
-		_animator->makeBrandonFaceMouse();
-		drawJewelPress(jewel, 1);
-		characterSays(2002, _blackJewel[0], 0, -2);
-		return 1;
-	}
-	drawJewelPress(jewel, 0);
-	drawJewelsFadeOutStart();
-	drawJewelsFadeOutEnd(jewel);
-
-	_emc->init(&_scriptClick, &_scriptClickData);
-	_scriptClick.regs[3] = 0;
-	_scriptClick.regs[6] = jewel;
-	_emc->start(&_scriptClick, 4);
-
-	while (_emc->isValid(&_scriptClick))
-		_emc->run(&_scriptClick);
-
-	if (_scriptClick.regs[3])
-		return 1;
-
-	_unkAmuletVar = 1;
-	switch (jewel-1) {
-	case 0:
-		if (_brandonStatusBit & 1) {
-			seq_brandonHealing2();
-		} else if (_brandonStatusBit == 0) {
-			seq_brandonHealing();
-			assert(_healingTip);
-			characterSays(2003, _healingTip[0], 0, -2);
-		}
-		break;
-
-	case 1:
-		seq_makeBrandonInv();
-		break;
-
-	case 2:
-		if (_brandonStatusBit & 1) {
-			assert(_wispJewelStrings);
-			characterSays(2004, _wispJewelStrings[0], 0, -2);
-		} else {
-			if (_brandonStatusBit & 2) {
-				// XXX
-				seq_makeBrandonNormal2();
-				// XXX
-			} else {
-				// do not check for item in hand again as in the original since some strings are missing
-				// in the cd version
-				if (_currentCharacter->sceneId >= 109 && _currentCharacter->sceneId <= 198) {
-					snd_playWanderScoreViaMap(1, 0);
-					seq_makeBrandonWisp();
-					snd_playWanderScoreViaMap(17, 0);
-				} else {
-					seq_makeBrandonWisp();
-				}
-				setGameFlag(0x9E);
-			}
-		}
-		break;
-
-	case 3:
-		seq_dispelMagicAnimation();
-		assert(_magicJewelString);
-		characterSays(2007, _magicJewelString[0], 0, -2);
-		break;
-
-	default:
-		break;
-	}
-	_unkAmuletVar = 0;
-	// XXX clearKyrandiaButtonIO (!used before every return in this function!)
-	return 1;
-}
-
-#pragma mark -
-
-GUI_v1::GUI_v1(KyraEngine_v1 *vm, Screen_v1 *screen) : GUI(vm), _vm(vm), _screen(screen) {
-	_menu = 0;
-	initStaticResource();
-	_scrollUpFunctor = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::scrollUp);
-	_scrollDownFunctor = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::scrollDown);
-}
-
-GUI_v1::~GUI_v1() {
-	delete[] _menu;
-}
-
-int GUI_v1::processButtonList(Button *list, uint16 inputFlag, int8 mouseWheel) {
-	while (list) {
-		if (list->flags & 8) {
-			list = list->nextButton;
-			continue;
-		}
-
-		if (mouseWheel && list->mouseWheel == mouseWheel && list->buttonCallback) {
-			if ((*list->buttonCallback.get())(list)) {
-				break;
-			}
-		}
-
-		int x = list->x;
-		int y = list->y;
-		assert(_screen->getScreenDim(list->dimTableIndex) != 0);
-		if (x < 0) {
-			x += _screen->getScreenDim(list->dimTableIndex)->w << 3;
-		}
-		x += _screen->getScreenDim(list->dimTableIndex)->sx << 3;
-
-		if (y < 0) {
-			y += _screen->getScreenDim(list->dimTableIndex)->h;
-		}
-		y += _screen->getScreenDim(list->dimTableIndex)->sy;
-
-		Common::Point mouse = _vm->getMousePos();
-		if (mouse.x >= x && mouse.y >= y && x + list->width >= mouse.x && y + list->height >= mouse.y) {
-			int processMouseClick = 0;
-			if (list->flags & 0x400) {
-				if (_vm->_mousePressFlag) {
-					if (!(list->flags2 & 1)) {
-						list->flags2 |= 1;
-						list->flags2 |= 4;
-						processButton(list);
-						_screen->updateScreen();
-					}
-				} else {
-					if (list->flags2 & 1) {
-						list->flags2 &= 0xFFFE;
-						processButton(list);
-						processMouseClick = 1;
-					}
-				}
-			} else if (_vm->_mousePressFlag) {
-				processMouseClick = 1;
-			}
-
-			if (processMouseClick) {
-				if (list->buttonCallback) {
-					if ((*list->buttonCallback.get())(list)) {
-						break;
-					}
-				}
-			}
-		} else {
-			if (list->flags2 & 1) {
-				list->flags2 &= 0xFFFE;
-				processButton(list);
-			}
-			if (list->flags2 & 4) {
-				list->flags2 &= 0xFFFB;
-				processButton(list);
-				_screen->updateScreen();
-			}
-			list = list->nextButton;
-			continue;
-		}
-
-		list = list->nextButton;
-	}
-	return 0;
-}
-
-void GUI_v1::processButton(Button *button) {
-	if (!button)
-		return;
-
-	int processType = 0;
-	const uint8 *shape = 0;
-	Button::Callback callback;
-
-	int flags = (button->flags2 & 5);
-	if (flags == 1) {
-		processType = button->data2Val1;
-		if (processType == 1)
-			shape = button->data2ShapePtr;
-		else if (processType == 4)
-			callback = button->data2Callback;
-	} else if (flags == 4 || flags == 5) {
-		processType = button->data1Val1;
-		if (processType == 1)
-			shape = button->data1ShapePtr;
-		else if (processType == 4)
-			callback = button->data1Callback;
-	} else {
-		processType = button->data0Val1;
-		if (processType == 1)
-			shape = button->data0ShapePtr;
-		else if (processType == 4)
-			callback = button->data0Callback;
-	}
-
-	int x = button->x;
-	int y = button->y;
-	assert(_screen->getScreenDim(button->dimTableIndex) != 0);
-	if (x < 0)
-		x += _screen->getScreenDim(button->dimTableIndex)->w << 3;
-
-	if (y < 0)
-		y += _screen->getScreenDim(button->dimTableIndex)->h;
-
-	if (processType == 1 && shape)
-		_screen->drawShape(_screen->_curPage, shape, x, y, button->dimTableIndex, 0x10);

@@ Diff output truncated at 100000 characters. @@

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list