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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun Apr 15 18:41:21 CEST 2007


Revision: 26511
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26511&view=rev
Author:   lordhoto
Date:     2007-04-15 09:41:20 -0700 (Sun, 15 Apr 2007)

Log Message:
-----------
Formatting/Cleanup.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/animator.cpp
    scummvm/trunk/engines/kyra/animator.h
    scummvm/trunk/engines/kyra/debugger.cpp
    scummvm/trunk/engines/kyra/debugger.h
    scummvm/trunk/engines/kyra/gui.cpp
    scummvm/trunk/engines/kyra/items.cpp
    scummvm/trunk/engines/kyra/kyra.cpp
    scummvm/trunk/engines/kyra/kyra.h
    scummvm/trunk/engines/kyra/kyra_v2.cpp
    scummvm/trunk/engines/kyra/kyra_v2.h
    scummvm/trunk/engines/kyra/kyra_v3.cpp
    scummvm/trunk/engines/kyra/kyra_v3.h
    scummvm/trunk/engines/kyra/plugin.cpp
    scummvm/trunk/engines/kyra/resource.cpp
    scummvm/trunk/engines/kyra/resource.h
    scummvm/trunk/engines/kyra/saveload.cpp
    scummvm/trunk/engines/kyra/scene.cpp
    scummvm/trunk/engines/kyra/screen.cpp
    scummvm/trunk/engines/kyra/screen.h
    scummvm/trunk/engines/kyra/script_v1.cpp
    scummvm/trunk/engines/kyra/seqplayer.cpp
    scummvm/trunk/engines/kyra/seqplayer.h
    scummvm/trunk/engines/kyra/sequences_v1.cpp
    scummvm/trunk/engines/kyra/sequences_v2.cpp
    scummvm/trunk/engines/kyra/sound.cpp
    scummvm/trunk/engines/kyra/sound_adlib.cpp
    scummvm/trunk/engines/kyra/sound_digital.cpp
    scummvm/trunk/engines/kyra/sound_towns.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

Modified: scummvm/trunk/engines/kyra/animator.cpp
===================================================================
--- scummvm/trunk/engines/kyra/animator.cpp	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/animator.cpp	2007-04-15 16:41:20 UTC (rev 26511)
@@ -196,19 +196,16 @@
 	int temp;
 	
 	temp = x + width;
-	if (temp >= 39) {
+	if (temp >= 39)
 		x = 39 - width;
-	}
 	temp = y + height;
-	if (temp >= 136) {
+	if (temp >= 136)
 		y = 136 - height;
-	}
 
-	if (restore) {
+	if (restore)
 		_screen->copyBlockToPage(_screen->_curPage, x << 3, y, width << 3, height, obj->background);
-	} else {
+	else
 		_screen->copyRegionToBuffer(_screen->_curPage, x << 3, y, width << 3, height, obj->background);
-	}
 }
 
 void ScreenAnimator::prepDrawAllObjects() {
@@ -229,13 +226,12 @@
 			int ypos = curObject->y1;
 			
 			int drawLayer = 0;
-			if (!(curObject->flags & 0x800)) {
+			if (!(curObject->flags & 0x800))
 				drawLayer = 7;
-			} else if (curObject->disable) {
+			else if (curObject->disable)
 				drawLayer = 0;
-			} else {
+			else
 				drawLayer = _vm->_sprites->getDrawLayer(curObject->drawY);
-			}
 			
 			// talking head functionallity
 			if (_vm->_talkingCharNum != -1 && (_vm->_currentCharacter->currentAnimFrame != 88 || curObject->index != 0)) {
@@ -253,18 +249,16 @@
 						shapesIndex = baseAnimFrameTable2[curObject->index];
 						int temp2 = 0;
 						if (curObject->index == 2) {
-							if (_vm->_characterList[2].sceneId == 77 || _vm->_characterList[2].sceneId == 86) {
+							if (_vm->_characterList[2].sceneId == 77 || _vm->_characterList[2].sceneId == 86)
 								temp2 = 1;
-							} else {
+							else
 								temp2 = 0;
-							}
 						} else {
 							temp2 = 1;
 						}
 						
-						if (!temp2) {
+						if (!temp2)
 							shapesIndex = -1;
-						}
 					}
 						
 					xpos = curObject->x1;
@@ -282,16 +276,14 @@
 					xpos += tempX;
 					ypos += tempY;
 					
-					if (_vm->_scaleMode && _brandonScaleX != 256) {
+					if (_vm->_scaleMode && _brandonScaleX != 256)
 						++xpos;
-					}
 					
 					if (curObject->index == 0 && shapesIndex != -1) {
 						if (!(_vm->_brandonStatusBit & 2)) {
 							flagUnk3 = 0x100;
-							if ((flagUnk1 & 0x200) || (flagUnk2 & 0x4000)) {
+							if ((flagUnk1 & 0x200) || (flagUnk2 & 0x4000))
 								flagUnk3 = 0;
-							}
 							
 							int tempFlags = 0;
 							if (flagUnk3 & 0x100) {
@@ -315,9 +307,8 @@
 					} else {
 						if (shapesIndex != -1) {
 							int tempFlags = 0;
-							if (curObject->flags & 1) {
+							if (curObject->flags & 1)
 								tempFlags = 1;
-							}
 							_screen->drawShape(drawPage, _vm->_shapes[4+shapesIndex], xpos, ypos, 2, tempFlags | 0x800, drawLayer); 							
 						}
 					}
@@ -331,37 +322,32 @@
 			if (curObject->index == 0) {
 				flagUnk3 = 0x100;
 				
-				if (flagUnk1 & 0x200 || flagUnk2 & 0x4000) {
+				if (flagUnk1 & 0x200 || flagUnk2 & 0x4000)
 					flagUnk3 = 0;
-				}
 				
-				if (_vm->_brandonStatusBit & 2) {
+				if (_vm->_brandonStatusBit & 2)
 					curObject->flags &= 0xFFFFFFFE;
-				}
 				
 				if (!_vm->_scaleMode) {
-					if (flagUnk3 & 0x100) {
+					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) {
+					else if (flagUnk2 & 0x4000)
 						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4000, int(_vm->_brandonInvFlag), drawLayer);
-					} else {
+					else
 						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1, drawLayer);
-					}
 				} else {
-					if (flagUnk3 & 0x100) {
+					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) {
+					else if (flagUnk2 & 0x4000)
 						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4004, int(_vm->_brandonInvFlag), drawLayer, _brandonScaleX, _brandonScaleY);
-					} else {
+					else
 						_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4, drawLayer, _brandonScaleX, _brandonScaleY);
-					}
 				}
 			} else {
-				if (curObject->index >= 16 && curObject->index <= 27) {
+				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 {
+				else
 					_screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags, drawLayer);
-				}
 			}
 		}
 		curObject = curObject->nextAnimObject;
@@ -380,25 +366,21 @@
 				width = curObject->width + (curObject->width2>>3) + 2;
 				height = curObject->height + curObject->height2*2;
 				
-				if (xpos < 1) {
+				if (xpos < 1)
 					xpos = 1;
-				} else if (xpos > 39) {
+				else if (xpos > 39)
 					continue;
-				}
 
-				if (xpos + width > 39) {
+				if (xpos + width > 39)
 					width = 39 - xpos;
-				}
 				
-				if (ypos < 8) {
+				if (ypos < 8)
 					ypos = 8;
-				} else if (ypos > 136) {
+				else if (ypos > 136)
 					continue;
-				}
 
-				if (ypos + height > 136) {
+				if (ypos + height > 136)
 					height = 136 - ypos;
-				}
 				
 				_screen->copyRegion(xpos << 3, ypos, xpos << 3, ypos, width << 3, height, 2, 0, Screen::CR_CLIPPED);
 				curObject->refreshFlag = 0;
@@ -475,11 +457,12 @@
 	animObj->sceneAnimPtr = _vm->_shapes[4+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) {
+
+	if (ch->facing >= 1 && ch->facing <= 3)
 		animObj->flags |= 1;
-	} else if (ch->facing >= 5 && ch->facing <= 7) {
+	else if (ch->facing >= 5 && ch->facing <= 7)
 		animObj->flags &= 0xFFFFFFFE;
-	}	
+
 	_objectQueue = objectQueue(_objectQueue, animObj);
 	preserveAnyChangedBackgrounds();
 	animObj->refreshFlag = 1;
@@ -507,16 +490,14 @@
 	
 	if (!cur->nextAnimObject) {
 		if (cur == rem) {
-			if (!prev) {
+			if (!prev)
 				return 0;
-			} else {
+			else
 				prev->nextAnimObject = 0;
-			}
 		}
 	} else {
-		if (cur == rem) {
+		if (cur == rem)
 			prev->nextAnimObject = rem->nextAnimObject;
-		}
 	}
 	
 	return queue;
@@ -556,31 +537,28 @@
 
 void ScreenAnimator::addObjectToQueue(AnimObject *object) {
 	debugC(9, kDebugLevelAnimator, "ScreenAnimator::addObjectToQueue(%p)", (const void *)object);
-	if (!_objectQueue) {
+	if (!_objectQueue)
 		_objectQueue = objectAddHead(0, object);
-	} else {
+	else
 		_objectQueue = objectQueue(_objectQueue, object);
-	}
 }
 
 void ScreenAnimator::refreshObject(AnimObject *object) {
 	debugC(9, kDebugLevelAnimator, "ScreenAnimator::refreshObject(%p)", (const void *)object);
 	_objectQueue = objectRemoveQueue(_objectQueue, object);
-	if (_objectQueue) {
+	if (_objectQueue)
 		_objectQueue = objectQueue(_objectQueue, object);
-	} else {
+	else
 		_objectQueue = objectAddHead(0, object);
-	}
 }
 
 void ScreenAnimator::makeBrandonFaceMouse() {
 	debugC(9, kDebugLevelAnimator, "ScreenAnimator::makeBrandonFaceMouse()");
 	Common::Point mouse = _vm->getMousePos();
-	if (mouse.x >= _vm->_currentCharacter->x1) {
+	if (mouse.x >= _vm->_currentCharacter->x1)
 		_vm->_currentCharacter->facing = 3;
-	} else {
+	else
 		_vm->_currentCharacter->facing = 5;
-	}
 	animRefreshNPC(0);
 	updateAllObjectShapes();
 }
@@ -625,11 +603,10 @@
 	animObj->refreshFlag = 1;
 	animObj->bkgdChangeFlag = 1;
 	int facing = ch->facing;
-	if (facing >= 1 && facing <= 3) {
+	if (facing >= 1 && facing <= 3)
 		animObj->flags |= 1;
-	} else if (facing >= 5 && facing <= 7) {
+	else if (facing >= 5 && facing <= 7)
 		animObj->flags &= 0xFFFFFFFE;
-	}
 	
 	animObj->drawY = ch->y1;
 	animObj->sceneAnimPtr = _vm->shapes()[4+ch->currentAnimFrame];
@@ -645,9 +622,11 @@
 			animObj->sceneAnimPtr = _vm->shapes()[4+_brandonDrawFrame];
 			if (_vm->_brandonStatusBit0x02Flag) {
 				++_brandonDrawFrame;
-				if (_brandonDrawFrame >= 122)
+				// TODO: check this
+				if (_brandonDrawFrame >= 122) {
 					_brandonDrawFrame = 113;
 					_vm->_brandonStatusBit0x02Flag = 0;
+				}
 			}
 		}
 	}
@@ -695,9 +674,9 @@
 		44, 42, 47, 38, 35,
 		40
 	};
-	for (int i = 0; i < 11; ++i) {
+	for (int i = 0; i < 11; ++i)
 		_vm->characterList()[i].height = initHeightTable[i];
-	}
 }
 
 } // end of namespace Kyra
+

Modified: scummvm/trunk/engines/kyra/animator.h
===================================================================
--- scummvm/trunk/engines/kyra/animator.h	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/animator.h	2007-04-15 16:41:20 UTC (rev 26511)
@@ -124,3 +124,4 @@
 } // end of namespace Kyra
 
 #endif
+

Modified: scummvm/trunk/engines/kyra/debugger.cpp
===================================================================
--- scummvm/trunk/engines/kyra/debugger.cpp	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/debugger.cpp	2007-04-15 16:41:20 UTC (rev 26511)
@@ -119,8 +119,9 @@
 		else
 			_vm->setGameFlag(flag);
 		DebugPrintf("Flag %i is now %i\n", flag, _vm->queryGameFlag(flag)); 
-	} else
+	} else {
 		DebugPrintf("Syntax: toggleflag <flag>\n");
+	}
 
 	return true;
 }
@@ -129,8 +130,9 @@
 	if (argc > 1) {
 		uint flag = atoi(argv[1]);
 		DebugPrintf("Flag %i is %i\n", flag, _vm->queryGameFlag(flag)); 
-	} else
+	} else {
 		DebugPrintf("Syntax: queryflag <flag>\n");
+	}
 
 	return true;
 }
@@ -148,8 +150,9 @@
 		uint countdown = atoi(argv[2]);
 		_vm->setTimerCountdown(timer, countdown);	
 		DebugPrintf("Timer %i now has countdown %i\n", timer, _vm->_timers[timer].countdown); 
-	} else
+	} else {
 		DebugPrintf("Syntax: settimercountdown <timer> <countdown>\n");
+	}
 
 	return true;
 }
@@ -166,9 +169,11 @@
 
 		_vm->setMouseItem(item);
 		_vm->_itemInHand = item;
-	} else
+	} else {
 		DebugPrintf("Syntax: give <itemid>\n");
+	}
 		
 	return true;
 }
 } // End of namespace Kyra
+

Modified: scummvm/trunk/engines/kyra/debugger.h
===================================================================
--- scummvm/trunk/engines/kyra/debugger.h	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/debugger.h	2007-04-15 16:41:20 UTC (rev 26511)
@@ -53,3 +53,4 @@
 } // End of namespace Kyra
 
 #endif
+

Modified: scummvm/trunk/engines/kyra/gui.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui.cpp	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/gui.cpp	2007-04-15 16:41:20 UTC (rev 26511)
@@ -130,9 +130,8 @@
 void KyraEngine::initMainButtonList() {
 	_haveScrollButtons = false;
 	_buttonList = &_buttonData[0];
-	for (int i = 0; _buttonDataListPtr[i]; ++i) {
+	for (int i = 0; _buttonDataListPtr[i]; ++i)
 		_buttonList = initButton(_buttonList, _buttonDataListPtr[i]);
-	}
 }
 
 Button *KyraEngine::initButton(Button *list, Button *newButton) {
@@ -141,12 +140,13 @@
 	if (!list)
 		return newButton;
 	Button *cur = list;
+
 	while (true) {
-		if (!cur->nextButton) {
+		if (!cur->nextButton)
 			break;
-		}
 		cur = cur->nextButton;
 	}
+
 	cur->nextButton = newButton;
 	return list;
 }
@@ -231,9 +231,8 @@
 	_scriptClick->variables[6] = jewel;
 	_scriptInterpreter->startScript(_scriptClick, 4);
 	
-	while (_scriptInterpreter->validScript(_scriptClick)) {
+	while (_scriptInterpreter->validScript(_scriptClick))
 		_scriptInterpreter->runScript(_scriptClick);
-	}
 	
 	if (_scriptClick->variables[3])
 		return 1;
@@ -376,43 +375,37 @@
 	int flags = (button->flags2 & 5);
 	if (flags == 1) {
 		processType = button->process2;
-		if (processType == 1) {
+		if (processType == 1)
 			shape = button->process2PtrShape;
-		} else if (processType == 4) {
+		else if (processType == 4)
 			callback = button->process2PtrCallback;
-		}
 	} else if (flags == 4 || flags == 5) {
 		processType = button->process1;
-		if (processType == 1) {
+		if (processType == 1)
 			shape = button->process1PtrShape;
-		} else if (processType == 4) {
+		else if (processType == 4)
 			callback = button->process1PtrCallback;
-		}
 	} else {
 		processType = button->process0;
-		if (processType == 1) {
+		if (processType == 1)
 			shape = button->process0PtrShape;
-		} else if (processType == 4) {
+		else if (processType == 4)
 			callback = button->process0PtrCallback;
-		}
 	}
 	
 	int x = button->x;
 	int y = button->y;
 	assert(button->dimTableIndex < _screen->_screenDimTableCount);
-	if (x < 0) {
+	if (x < 0)
 		x += _screen->_screenDimTable[button->dimTableIndex].w << 3;
-	}
 	
-	if (y < 0) {
+	if (y < 0)
 		y += _screen->_screenDimTable[button->dimTableIndex].h;
-	}
 	
-	if (processType == 1 && shape) {
+	if (processType == 1 && shape)
 		_screen->drawShape(_screen->_curPage, shape, x, y, button->dimTableIndex, 0x10);
-	} else if (processType == 4 && callback) {
+	else if (processType == 4 && callback)
 		(this->*callback)(button);
-	}
 }
 
 void KyraEngine::processAllMenuButtons() {
@@ -421,9 +414,8 @@
 
 	Button *cur = _menuButtonList;
 	while (true) {
-		if (!cur->nextButton) {
+		if (!cur->nextButton)
 			break;
-		}
 		processMenuButton(cur);
 		cur = cur->nextButton;
 	}
@@ -434,7 +426,7 @@
 	if (!_displayMenu)
 		return;
 
-	if ( !button || (button->flags & 8))
+	if (!button || (button->flags & 8))
 		return;
 
 	if (button->flags2 & 1)
@@ -466,7 +458,6 @@
 }
 
 int KyraEngine::drawShadedBoxCallback(Button *button) {
-
 	if (!_displayMenu)
 		return 0;
 	
@@ -487,13 +478,12 @@
 	int menuLabelGarbageOffset = 0;
 	
 	if (_flags.isTalkie) {
-		if (_flags.lang == Common::EN_ANY) {
+		if (_flags.lang == Common::EN_ANY)
 			offset = 52;
-		} else if (_flags.lang == Common::DE_DEU) {
+		else if (_flags.lang == Common::DE_DEU)
 			offset = 30;
-		} else if (_flags.lang == Common::FR_FRA) {
+		else if (_flags.lang == Common::FR_FRA)
 			offset = 6;
-		}
 		offsetOn = offsetMainMenu = offsetOptions = offset;
 		walkspeedGarbageOffset = 48;
 	} else if (_flags.lang == Common::ES_ESP) {
@@ -558,10 +548,10 @@
 	// Main Menu
 	_menu[5].item[5].itemString = &_guiStrings[19 + offsetMainMenu][menuLabelGarbageOffset];
 	
-	if (_flags.isTalkie) {
+	if (_flags.isTalkie)
 		// Text & Voice
 		_voiceTextString = _guiStrings[28 + offset];
-	}
+
 	_textSpeedString = _guiStrings[25 + offsetOptions];
 	_onString =  _guiStrings[20 + offsetOn];
 	_offString =  _guiStrings[21 + offset];
@@ -607,9 +597,9 @@
 	_mousePressFlag = false;
 	
 	_toplevelMenu = 0;
-	if (_menuDirectlyToLoad)
+	if (_menuDirectlyToLoad) {
 		gui_loadGameMenu(0);
-	else {
+	} else {
 		if (!caller)
 			_toplevelMenu = 4;
 
@@ -627,9 +617,9 @@
 		gui_restorePalette();
 		_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
 		_animator->_updateScreen = true;
-	}
-	else
+	} else {
 		_screen->deletePageFromDisk(0);
+	}
 
 	return 0;
 }
@@ -663,7 +653,6 @@
 		if (!menu.item[i].enabled)
 			continue;
 
-
 		x1 = menu.x + menu.item[i].x;
 		y1 = menu.y + menu.item[i].y;
 
@@ -726,8 +715,9 @@
 		_scrollDownButton.nextButton = 0;
 		_menuButtonList = initButton(_menuButtonList, &_scrollDownButton);
 		processMenuButton(&_scrollDownButton);
-	} else
+	} else {
 		_haveScrollButtons = false;
+	}
 
 	_screen->showMouse();
 	_screen->updateScreen();
@@ -867,11 +857,10 @@
 	Common::InSaveFile *in;
 
 	for (int i = 1; i < 1000; i++) {
-		if ((in = _saveFileMan->openForLoading(getSavegameFilename(i)))) {
+		if ((in = _saveFileMan->openForLoading(getSavegameFilename(i))))
 			delete in;
-		} else {
+		else
 			return i;
-		}
 	}
 	warning("Didn't save: Ran out of savegame filenames");
 	return 0;
@@ -888,8 +877,9 @@
 		menu.item[0].enabled = 1;
 		menu.item[0].field_1b = 0;
 		startSlot = 1;
-	} else
+	} else {
 		startSlot = 0;
+	}
 
 	for (int i = startSlot; i < num; i++) {
 		if ((in = _saveFileMan->openForLoading(getSavegameFilename(i + _savegameOffset)))) {
@@ -949,9 +939,9 @@
 
 int KyraEngine::gui_loadGameMenu(Button *button) {
 	debugC(9, kDebugLevelGUI, "KyraEngine::gui_loadGameMenu()");
-	if (_menuDirectlyToLoad)
+	if (_menuDirectlyToLoad) {
 		_menu[2].item[5].enabled = false;
-	else {
+	} else {
 		processMenuButton(button);
 		_menu[2].item[5].enabled = true;
 	}
@@ -1109,9 +1099,9 @@
 	debugC(9, kDebugLevelGUI, "KyraEngine::gui_quitPlaying()");
 	processMenuButton(button);
 
-	if (gui_quitConfirm(_guiStrings[14])) // Are you sure you want to quit playing?
+	if (gui_quitConfirm(_guiStrings[14])) { // Are you sure you want to quit playing?
 		quitGame();
-	else {
+	} else {
 		initMenu(_menu[_toplevelMenu]);
 		processAllMenuButtons();
 	}
@@ -1455,9 +1445,8 @@
 
 	memcpy(_screen->getPalette(2), _screen->_currentPalette, 768);
 
-	for (int i = 0; i < 768; i++) {
-		_screen->_currentPalette[i] /= 2;
-	}
+	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);
@@ -1600,9 +1589,8 @@
 		
 	--w; --h;
 
-	if (fill) {
+	if (fill)
 		_screen->fillRect(x, y, x+w, y+h, colorTable[0]);
-	}
 	
 	_screen->drawClippedLine(x, y+h, x+w, y+h, colorTable[1]);
 	_screen->drawClippedLine(x+w, y, x+w, y+h, colorTable[1]);
@@ -1624,13 +1612,11 @@
 	vsprintf(string, format, vaList);
 	va_end(vaList);
 	
-	if (flags & 1) {
+	if (flags & 1)
 		x -= _screen->getTextWidth(string) >> 1;
-	}
 	
-	if (flags & 2) {
+	if (flags & 2)
 		x -= _screen->getTextWidth(string);
-	}
 	
 	if (flags & 4) {
 		_screen->printText(string, x - 1, y, 240, col2);

Modified: scummvm/trunk/engines/kyra/items.cpp
===================================================================
--- scummvm/trunk/engines/kyra/items.cpp	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/items.cpp	2007-04-15 16:41:20 UTC (rev 26511)
@@ -148,9 +148,8 @@
 			break;
 			
 		case 51:
-			if (room != 46) {
+			if (room != 46)
 				placeItem = true;
-			}
 			break;
 
 		default:
@@ -159,11 +158,10 @@
 		
 		if (placeItem) {
 			Room *roomPtr = &_roomTable[room];
-			if (roomPtr->northExit == 0xFFFF && roomPtr->eastExit == 0xFFFF && roomPtr->southExit == 0xFFFF && roomPtr->westExit == 0xFFFF) {
+			if (roomPtr->northExit == 0xFFFF && roomPtr->eastExit == 0xFFFF && roomPtr->southExit == 0xFFFF && roomPtr->westExit == 0xFFFF)
 				placeItem = false;
-			} else if (_currentCharacter->sceneId == room) {
+			else if (_currentCharacter->sceneId == room)
 				placeItem = false;
-			}
 		}
 		
 		if (placeItem) {
@@ -192,11 +190,10 @@
 
 void KyraEngine::setMouseItem(int item) {
 	debugC(9, kDebugLevelMain, "KyraEngine::setMouseItem(%d)", item);
-	if (item == -1) {
+	if (item == -1)
 		_screen->setMouseCursor(1, 1, _shapes[10]);
-	} else {
+	else
 		_screen->setMouseCursor(8, 15, _shapes[220+item]);
-	}
 }
 
 void KyraEngine::wipeDownMouseItem(int xpos, int ypos) {
@@ -233,9 +230,8 @@
 	Room *currentRoom = &_roomTable[sceneId];
 	for (int i = 0; i < 12; ++i) {
 		uint8 item = currentRoom->itemsTable[i];
-		if (item == 0xFF || !currentRoom->needInit[i]) {
+		if (item == 0xFF || !currentRoom->needInit[i])
 			continue;
-		}
 		
 		int xpos = 0;
 		int ypos = 0;
@@ -256,9 +252,8 @@
 			if (!stop) {
 				xpos = currentRoom->itemsXPos[i] = _rnd.getRandomNumberRng(24, 296);
 				ypos = currentRoom->itemsYPos[i] = _rnd.getRandomNumberRng(_northExitHeight & 0xFF, 130);
-				if (countItemsInScene(sceneId) >= 12) {
+				if (countItemsInScene(sceneId) >= 12)
 					break;
-				}
 			} else {
 				currentRoom->needInit[i] = 0;
 			}
@@ -274,9 +269,8 @@
 	int items = 0;
 	
 	for (int i = 0; i < 12; ++i) {
-		if (currentRoom->itemsTable[i] != 0xFF) {
+		if (currentRoom->itemsTable[i] != 0xFF)
 			++items;
-		}
 	}
 	
 	return items;
@@ -286,9 +280,8 @@
 	debugC(9, kDebugLevelMain, "KyraEngine::processItemDrop(%d, %d, %d, %d, %d, %d)", sceneId, item, x, y, unk1, unk2);
 	int freeItem = -1;
 	uint8 itemIndex = findItemAtPos(x, y);
-	if (unk1) {
+	if (unk1)
 		itemIndex = 0xFF;
-	}
 	
 	if (itemIndex != 0xFF) {
 		exchangeItemWithMouseItem(sceneId, itemIndex);
@@ -309,9 +302,8 @@
 		freeItem = _lastProcessedItem;
 	}
 
-	if (freeItem == -1) {
+	if (freeItem == -1)
 		return 0;
-	}
 	
 	if (sceneId != _currentCharacter->sceneId) {
 		addItemToRoom(sceneId, item, freeItem, x, y);
@@ -337,21 +329,18 @@
 			bool running2 = true;
 			
 			if (_screen->getDrawLayer(xpos, ypos) > 1) {
-				if (((_northExitHeight >> 8) & 0xFF) != ypos) {
+				if (((_northExitHeight >> 8) & 0xFF) != ypos)
 					running2 = false;
-				}
 			}
 			
 			if (_screen->getDrawLayer2(xpos, ypos, itemHeight) > 1) {
-				if (((_northExitHeight >> 8) & 0xFF) != ypos) {
+				if (((_northExitHeight >> 8) & 0xFF) != ypos)
 					running2 = false;
-				}
 			}
 			
 			if (!isDropable(xpos, ypos)) {
-				if (((_northExitHeight >> 8) & 0xFF) != ypos) {
+				if (((_northExitHeight >> 8) & 0xFF) != ypos)
 					running2 = false;
-				}
 			}
 			
 			int xpos2 = xpos;
@@ -384,14 +373,12 @@
 					continue;
 				
 				xpos2 -= 2;
-				if (xpos2 < 16) {
+				if (xpos2 < 16)
 					xpos2 = 16;
-				}
 				
 				xpos3 += 2;
-				if (xpos3 > 304) {
+				if (xpos3 > 304)
 					xpos3 = 304;
-				}
 				
 				if (xpos2 > 16)
 					continue;
@@ -405,23 +392,20 @@
 			running = 0;
 			destY -= _rnd.getRandomNumberRng(0, 3);
 			
-			if ((_northExitHeight & 0xFF) < destY) {
+			if ((_northExitHeight & 0xFF) < destY)
 				continue;
-			}
 			
 			destY = (_northExitHeight & 0xFF) + 1;
 			continue;
 		}		
 		ypos += 2;
-		if (((_northExitHeight >> 8) & 0xFF) >= ypos) {
+		if (((_northExitHeight >> 8) & 0xFF) >= ypos)
 			continue;
-		}
 		ypos = (_northExitHeight >> 8) & 0xFF;
 	}
 	
-	if (destX == -1 || destY == -1) {
+	if (destX == -1 || destY == -1)
 		return 0;
-	}
 	
 	if (unk1 == 3) {
 		currentRoom->itemsXPos[freeItem] = destX;
@@ -429,13 +413,11 @@
 		return 1;
 	}
 	
-	if (unk1 == 2) {
+	if (unk1 == 2)
 		itemSpecialFX(x, y, item);
-	}
 	
-	if (unk1 == 0) {
+	if (unk1 == 0)
 		destroyMouseItem();
-	}
 	
 	itemDropDown(x, y, destX, destY, freeItem, item);
 	
@@ -479,17 +461,14 @@
 
 int KyraEngine::checkNoDropRects(int x, int y) {
 	debugC(9, kDebugLevelMain, "KyraEngine::checkNoDropRects(%d, %d)", x, y);
-	if (_lastProcessedItemHeight < 1 || _lastProcessedItemHeight > 16) {
+	if (_lastProcessedItemHeight < 1 || _lastProcessedItemHeight > 16)
 		_lastProcessedItemHeight = 16;
-	}
-	if (_noDropRects[0].x == -1) {
+	if (_noDropRects[0].x == -1)
 		return 0;
-	}
 	
 	for (int i = 0; i < 11; ++i) {
-		if (_noDropRects[i].x == -1) {
+		if (_noDropRects[i].x == -1)
 			break;
-		}
 		
 		int xpos = _noDropRects[i].x;
 		int ypos = _noDropRects[i].y;
@@ -515,14 +494,12 @@
 	x -= 8;
 	y -= 1;
 	
-	if (checkNoDropRects(x, y)) {
+	if (checkNoDropRects(x, y))
 		return 0;
-	}
 	
 	for (int xpos = x; xpos < x + 16; ++xpos) {
-		if (_screen->getShapeFlag1(xpos, y) == 0) {
+		if (_screen->getShapeFlag1(xpos, y) == 0)
 			return 0;
-		}
 	}	
 	return 1;
 }
@@ -551,9 +528,8 @@
 		while (tempY < destY) {
 			_screen->restoreRect0(drawX, tempY - 16);
 			tempY += addY;
-			if (tempY > destY) {
+			if (tempY > destY)
 				tempY = destY;
-			}
 			++addY;
 			drawY = tempY - 16;
 			_screen->backUpRect0(drawX, drawY);
@@ -565,9 +541,8 @@
 		
 		bool skip = false;
 		if (x == destX) {
-			if (destY - y <= 16) {
+			if (destY - y <= 16)
 				skip = true;
-			}
 		}
 		
 		if (!skip) {
@@ -579,9 +554,8 @@
 			xDiff /= addY;
 			int startAddY = addY;
 			addY >>= 1;
-			if (destY - y <= 8) {
+			if (destY - y <= 8)
 				addY >>= 1;
-			}
 			addY = -addY;
 			int unkX = x << 4;
 			while (--startAddY) {
@@ -590,9 +564,8 @@
 				_screen->restoreRect0(drawX, drawY);
 				tempY += addY;
 				unkX += xDiff;
-				if (tempY > destY) {
+				if (tempY > destY)
 					tempY = destY;
-				}
 				++addY;
 				drawX = (unkX >> 4) - 8;
 				drawY = tempY - 16;
@@ -620,22 +593,19 @@
 	if (processItemDrop(_currentCharacter->sceneId, item, x, y, unk1, unk2))
 		return;
 	snd_playSoundEffect(54);
-	if (12 == countItemsInScene(_currentCharacter->sceneId)) {
-		assert(_noDropList);
+	assert(_noDropList);
+	if (12 == countItemsInScene(_currentCharacter->sceneId))
 		drawSentenceCommand(_noDropList[0], 6);
-	} else {
-		assert(_noDropList);
+	else
 		drawSentenceCommand(_noDropList[1], 6);
-	}
 }
 
 void KyraEngine::itemSpecialFX(int x, int y, int item) {
 	debugC(9, kDebugLevelMain, "KyraEngine::itemSpecialFX(%d, %d, %d)", x, y, item);
-	if (item == 41) {
+	if (item == 41)
 		itemSpecialFX1(x, y, item);
-	} else {
+	else
 		itemSpecialFX2(x, y, item);
-	}
 }
 
 void KyraEngine::itemSpecialFX1(int x, int y, int item) {
@@ -665,9 +635,8 @@
 	y -= 15;
 	int yAdd = (int8)(((16 - _itemTable[item].height) >> 1) & 0xFF);
 	_screen->backUpRect0(x, y);
-	if (item >= 80 && item <= 89) {
+	if (item >= 80 && item <= 89)
 		snd_playSoundEffect(55);
-	}
 	
 	for (int i = 201; i <= 205; ++i) {
 		_screen->restoreRect0(x, y);
@@ -702,9 +671,8 @@
 		y = _itemPosY[itemPos] - 3;
 	}
 	
-	if (_itemInHand == -1 && itemPos == -1) {
+	if (_itemInHand == -1 && itemPos == -1)
 		return;
-	}
 	
 	int tableIndex = 0, loopStart = 0, maxLoops = 0;
 	if (animIndex == 0) {
@@ -723,11 +691,10 @@
 		tableIndex = -1;
 	}
 	
-	if (animIndex == 2) {
+	if (animIndex == 2)
 		snd_playSoundEffect(0x5E);
-	} else {
+	else
 		snd_playSoundEffect(0x37);
-	}
 	_screen->hideMouse();
 	_screen->backUpRect1(x, y);
 
@@ -735,11 +702,10 @@
 		_screen->restoreRect1(x, y);
 		uint32 nextTime = _system->getMillis() + 4 * _tickLength;
 		_screen->drawShape(0, _shapes[220+_itemInHand], x + 4, y + 3, 0, 0);
-		if (tableIndex == -1) {
+		if (tableIndex == -1)
 			_screen->drawShape(0, _shapes[4+shape], x, y, 0, 0);
-		} else {
+		else
 			specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops);
-		}
 		_screen->updateScreen();
 		delayUntil(nextTime);
 	}
@@ -754,11 +720,10 @@
 		_screen->restoreRect1(x, y);
 		uint32 nextTime = _system->getMillis() + 4 * _tickLength;
 		_screen->drawShape(0, _shapes[220+_itemInHand], x + 4, y + 3, 0, 0);
-		if (tableIndex == -1) {
+		if (tableIndex == -1)
 			_screen->drawShape(0, _shapes[4+shape], x, y, 0, 0);
-		} else {
+		else
 			specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops);
-		}
 		_screen->updateScreen();
 		delayUntil(nextTime);
 	}
@@ -809,20 +774,18 @@
 	
 	_screen->hideMouse();
 	_screen->backUpRect1(x, y);
-	if (animIndex == 2) {
+	if (animIndex == 2)
 		snd_playSoundEffect(0x5E);
-	} else {
+	else
 		snd_playSoundEffect(0x37);
-	}
 	
 	for (int shape = _magicMouseItemStartFrame[animIndex]; shape <= _magicMouseItemEndFrame[animIndex]; ++shape) {
 		_screen->restoreRect1(x, y);
 		uint32 nextTime = _system->getMillis() + 4 * _tickLength;
-		if (tableIndex == -1) {
+		if (tableIndex == -1)
 			_screen->drawShape(0, _shapes[4+shape], x, y, 0, 0);
-		} else {
+		else
 			specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops);
-		}
 		_screen->updateScreen();
 		delayUntil(nextTime);
 	}
@@ -830,11 +793,10 @@
 	for (int shape = _magicMouseItemStartFrame2[animIndex]; shape <= _magicMouseItemEndFrame2[animIndex]; ++shape) {
 		_screen->restoreRect1(x, y);
 		uint32 nextTime = _system->getMillis() + 4 * _tickLength;
-		if (tableIndex == -1) {
+		if (tableIndex == -1)
 			_screen->drawShape(0, _shapes[4+shape], x, y, 0, 0);
-		} else {
+		else
 			specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops);
-		}
 		_screen->updateScreen();
 		delayUntil(nextTime);
 	}
@@ -864,15 +826,14 @@
 		0x7C, 0xD0, 0x74, 0x84, 0x87, 0x00, 0x00, 0x00
 	};
 	int tableValue = 0;
-	if (animIndex == 0) {
+	if (animIndex == 0)
 		tableValue = table1[tableIndex];
-	} else if (animIndex == 1) {
+	else if (animIndex == 1)
 		tableValue = table2[tableIndex];
-	} else if (animIndex == 2) {
+	else if (animIndex == 2)
 		tableValue = table3[tableIndex];
-	} else {
+	else
 		return;
-	}
 	processSpecialMouseItemFX(shape, x, y, tableValue, loopStart, maxLoops);
 }
 
@@ -882,14 +843,14 @@
 	uint8 *shapePtr = _shapes[4+shape] + 10;
 	if (_flags.useAltShapeHeader)
 		shapePtr += 2;
-	for (int i = 0; i < 16; ++i) {
+
+	for (int i = 0; i < 16; ++i)
 		shapeColorTable[i] = shapePtr[i];
-	}
+
 	for (int i = loopStart; i < loopStart + maxLoops; ++i) {
 		for (int i2 = 0; i2 < 16; ++i2) {
-			if (shapePtr[i2] == i) {
+			if (shapePtr[i2] == i)
 				shapeColorTable[i2] = (i + tableValue) - loopStart;
-			}
 		}
 	}
 	_screen->drawShape(0, _shapes[4+shape], x, y, 0, 0x8000, shapeColorTable);
@@ -924,16 +885,14 @@
 		_screen->showMouse();
 	}
 	
-	if (_itemInHand == 33) {
+	if (_itemInHand == 33)
 		magicOutMouseItem(2, -1);
-	}
 	
 	_screen->hideMouse();
 	for (int i = 0; i < 10; ++i) {
 		uint8 item = _currentCharacter->inventoryItems[i];
-		if (item == 33) {
+		if (item == 33)
 			magicOutMouseItem(2, i);
-		}
 	}
 	_screen->showMouse();
 }
@@ -955,3 +914,4 @@
 }
 
 } // end of namespace Kyra
+

Modified: scummvm/trunk/engines/kyra/kyra.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra.cpp	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/kyra.cpp	2007-04-15 16:41:20 UTC (rev 26511)
@@ -130,9 +130,8 @@
 
 int KyraEngine::init() {
 	// Setup mixer
-	if (!_mixer->isReady()) {
+	if (!_mixer->isReady())
 		warning("Sound initialization failed.");
-	}
 
 	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
 	_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
@@ -161,9 +160,8 @@
 
 		MidiDriver *driver = MidiDriver::createMidi(midiDriver);
 		assert(driver);
-		if (native_mt32) {
+		if (native_mt32)
 			driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
-		}
 
 		SoundMidiPC *soundMidiPc = new SoundMidiPC(this, _mixer, driver);
 		_sound = soundMidiPc;
@@ -221,10 +219,11 @@
 	_currentCharacter = 0;
 	_characterList = new Character[11];
 	assert(_characterList);
-	for (int i = 0; i < 11; ++i) {
-		memset(&_characterList[i], 0, sizeof(Character));
+	memset(_characterList, 0, sizeof(Character)*11);
+
+	for (int i = 0; i < 11; ++i)
 		memset(_characterList[i].inventoryItems, 0xFF, sizeof(_characterList[i].inventoryItems));
-	}
+
 	_characterList[0].sceneId = 5;
 	_characterList[0].height = 48;
 	_characterList[0].facing = 3;
@@ -255,9 +254,8 @@
 	assert(_debugger);	
 	memset(_shapes, 0, sizeof(_shapes));
 
-	for (int i = 0; i < ARRAYSIZE(_movieObjects); ++i) {
+	for (int i = 0; i < ARRAYSIZE(_movieObjects); ++i)
 		_movieObjects[i] = createWSAMovie();
-	}
 
 	memset(_flagsTable, 0, sizeof(_flagsTable));
 
@@ -417,9 +415,9 @@
 			_shapes[i] = 0;
 		}
 	}
-	for (int i = 0; i < ARRAYSIZE(_sceneAnimTable); ++i) {
+
+	for (int i = 0; i < ARRAYSIZE(_sceneAnimTable); ++i)
 		delete [] _sceneAnimTable[i];
-	}
 }
 
 KyraEngine_v1::~KyraEngine_v1() {
@@ -427,10 +425,8 @@
 }
 
 int KyraEngine::go() {
-
-	if (_res->getFileSize("6.FNT")) {
+	if (_res->getFileSize("6.FNT"))
 		_screen->loadFont(Screen::FID_6_FNT, "6.FNT");
-	}
 	_screen->loadFont(Screen::FID_8_FNT, "8FAT.FNT");
 	_screen->setScreenDim(0);
 
@@ -484,6 +480,7 @@
 	memset(_shapes[2], 0, _screen->getRectSize(8, 69));
 	_shapes[3] = new uint8[_screen->getRectSize(8, 69)];
 	memset(_shapes[3], 0, _screen->getRectSize(8, 69));
+
 	for (int i = 0; i < _roomTableSize; ++i) {
 		for (int item = 0; item < 12; ++item) {
 			_roomTable[i].itemsTable[item] = 0xFF;
@@ -492,6 +489,7 @@
 			_roomTable[i].needInit[item] = 0;
 		}
 	}
+
 	loadCharacterShapes();
 	loadSpecialEffectShapes();
 	loadItems();
@@ -542,10 +540,8 @@
 
 		if (_currentCharacter->sceneId == 210) {
 			updateKyragemFading();
-			if (seq_playEnd()) {
-				if (_deathHandler != 8)
-					break;
-			}
+			if (seq_playEnd() && _deathHandler != 8)
+				break;
 		}
 		
 		if (_deathHandler != 0xFF) {
@@ -559,16 +555,13 @@
 			_deathHandler = 0xFF;
 		}
 		
-		if (_brandonStatusBit & 2) {
-			if (_brandonStatusBit0x02Flag)
-				_animator->animRefreshNPC(0);
+		if ((_brandonStatusBit & 2) && _brandonStatusBit0x02Flag)
+			_animator->animRefreshNPC(0);
+
+		if ((_brandonStatusBit & 0x20) && _brandonStatusBit0x20Flag) {
+			_animator->animRefreshNPC(0);
+			_brandonStatusBit0x20Flag = 0;
 		}
-		if (_brandonStatusBit & 0x20) {
-			if (_brandonStatusBit0x20Flag) {
-				_animator->animRefreshNPC(0);
-				_brandonStatusBit0x20Flag = 0;
-			}
-		}
 		
 		_screen->showMouse();
 
@@ -595,6 +588,7 @@
 	while (_system->getMillis() < timestamp && !_quitFlag) {
 		if (updateTimers)
 			updateGameTimers();
+
 		if (timestamp - _system->getMillis() >= 10)
 			delay(10, update, isMainLoop);
 	}
@@ -659,6 +653,7 @@
 				break;
 			}
 		}
+
 		if (_debugger->isAttached())
 			_debugger->onFrame();
 
@@ -669,22 +664,18 @@
 			updateMousePointer();
 		}
 
-		if (_currentCharacter && _currentCharacter->sceneId == 210 && update) {
+		if (_currentCharacter && _currentCharacter->sceneId == 210 && update)
 			updateKyragemFading();
-		}
 
 		if (_skipFlag && !_abortIntroFlag && !queryGameFlag(0xFE))
 			_skipFlag = false;
 			
-		if (amount > 0 && !_skipFlag && !_quitFlag) {
+		if (amount > 0 && !_skipFlag && !_quitFlag)
 			_system->delayMillis(10);
-		}
 
-		if (_skipFlag) {
+		if (_skipFlag)
 			_sound->voiceStop();
-		}
 	} while (!_skipFlag && _system->getMillis() < start + amount && !_quitFlag);
-	
 }
 
 Common::Point KyraEngine::getMousePos() const {
@@ -699,6 +690,7 @@
 void KyraEngine::waitForEvent() {
 	bool finished = false;
 	Common::Event event;
+
 	while (!finished && !_quitFlag) {
 		while (_eventMan->pollEvent(event)) {
 			switch (event.type) {
@@ -726,15 +718,19 @@
 
 void KyraEngine::delayWithTicks(int ticks) {
 	uint32 nextTime = _system->getMillis() + ticks * _tickLength;
+
 	while (_system->getMillis() < nextTime) {
 		_sprites->updateSceneAnims();
 		_animator->updateAllObjectShapes();
+
 		if (_currentCharacter->sceneId == 210) {
 			updateKyragemFading();
 			seq_playEnd();
 		}
+
 		if (_skipFlag)
 			break;
+
 		if (nextTime - _system->getMillis() >= 10)
 			delay(10);
 	}
@@ -746,9 +742,10 @@
 
 void KyraEngine::setupShapes123(const Shape *shapeTable, int endShape, int flags) {
 	debugC(9, kDebugLevelMain, "KyraEngine::setupShapes123(%p, %d, %d)", (const void *)shapeTable, endShape, flags);
-	for (int i = 123; i <= 172; ++i) {
-		_shapes[4+i] = NULL;
-	}
+
+	for (int i = 123; i <= 172; ++i)
+		_shapes[4+i] = 0;
+
 	uint8 curImage = 0xFF;
 	int curPageBackUp = _screen->_curPage;
 	_screen->_curPage = 8;	// we are using page 8 here in the original page 2 was backuped and then used for this stuff
@@ -774,9 +771,10 @@
 
 void KyraEngine::freeShapes123() {
 	debugC(9, kDebugLevelMain, "KyraEngine::freeShapes123()");
+
 	for (int i = 123; i <= 172; ++i) {
 		delete [] _shapes[4+i];
-		_shapes[4+i] = NULL;
+		_shapes[4+i] = 0;
 	}
 }
 
@@ -787,6 +785,7 @@
 Movie *KyraEngine::createWSAMovie() {
 	if (_flags.platform == Common::kPlatformAmiga)
 		return new WSAMovieAmiga(this);
+
 	return new WSAMovieV1(this);
 }
 
@@ -807,11 +806,13 @@
 void KyraEngine::setBrandonPoisonFlags(int reset) {
 	debugC(9, kDebugLevelMain, "KyraEngine::setBrandonPoisonFlags(%d)", reset);
 	_brandonStatusBit |= 1;
+
 	if (reset)
 		_poisonDeathCounter = 0;
-	for (int i = 0; i < 0x100; ++i) {
+
+	for (int i = 0; i < 0x100; ++i)
 		_brandonPoisonFlagsGFX[i] = i;
-	}
+
 	_brandonPoisonFlagsGFX[0x99] = 0x34;
 	_brandonPoisonFlagsGFX[0x9A] = 0x35;
 	_brandonPoisonFlagsGFX[0x9B] = 0x37;
@@ -822,9 +823,9 @@
 void KyraEngine::resetBrandonPoisonFlags() {
 	debugC(9, kDebugLevelMain, "KyraEngine::resetBrandonPoisonFlags()");
 	_brandonStatusBit = 0;
-	for (int i = 0; i < 0x100; ++i) {
+
+	for (int i = 0; i < 0x100; ++i)
 		_brandonPoisonFlagsGFX[i] = i;
-	}
 }
 
 #pragma mark -
@@ -839,9 +840,9 @@
 	debugC(9, kDebugLevelMain, "KyraEngine::processInput(%d, %d)", xpos, ypos);
 	_abortWalkFlag2 = false;
 
-	if (processInputHelper(xpos, ypos)) {
+	if (processInputHelper(xpos, ypos))
 		return;
-	}
+
 	uint8 item = findItemAtPos(xpos, ypos);
 	if (item == 0xFF) {
 		_changedScene = false;
@@ -931,9 +932,8 @@
 	_scriptClick->variables[4] = _itemInHand;
 	_scriptInterpreter->startScript(_scriptClick, 1);
 
-	while (_scriptInterpreter->validScript(_scriptClick)) {
+	while (_scriptInterpreter->validScript(_scriptClick))
 		_scriptInterpreter->runScript(_scriptClick);
-	}
 
 	return _scriptClick->variables[3];
 }
@@ -1053,14 +1053,15 @@
 
 bool KyraEngine::hasClickedOnExit(int xpos, int ypos) {
 	debugC(9, kDebugLevelMain, "KyraEngine::hasClickedOnExit(%d, %d)", xpos, ypos);
-	if (xpos < 16 || xpos >= 304) {
+	if (xpos < 16 || xpos >= 304)
 		return true;
-	}
+
 	if (ypos < 8)
 		return true;
-	if (ypos < 136 || ypos > 155) {
+
+	if (ypos < 136 || ypos > 155)
 		return false;
-	}
+
 	return true;
 }
 
@@ -1076,9 +1077,8 @@
 	_scriptClick->variables[4] = _itemInHand;
 	_scriptInterpreter->startScript(_scriptClick, 6);
 	
-	while (_scriptInterpreter->validScript(_scriptClick)) {
+	while (_scriptInterpreter->validScript(_scriptClick))
 		_scriptInterpreter->runScript(_scriptClick);
-	}
 }
 
 int KyraEngine::checkForNPCScriptRun(int xpos, int ypos) {
@@ -1096,13 +1096,11 @@
 	charTop = currentChar->y1 - addY;
 	charBottom = currentChar->y1;
 	
-	if (xpos >= charLeft && charRight >= xpos && charTop <= ypos && charBottom >= ypos) {
+	if (xpos >= charLeft && charRight >= xpos && charTop <= ypos && charBottom >= ypos)
 		return 0;
-	}
 	
-	if (xpos > 304 || xpos < 16) {
+	if (xpos > 304 || xpos < 16)
 		return -1;
-	}
 	
 	for (int i = 1; i < 5; ++i) {
 		currentChar = &_characterList[i];
@@ -1119,14 +1117,12 @@
 		charBottom = currentChar->y1;
 		// }
 		
-		if (xpos < charLeft || xpos > charRight || ypos < charTop || charBottom < ypos) {
+		if (xpos < charLeft || xpos > charRight || ypos < charTop || charBottom < ypos)
 			continue;
-		}
 		
 		if (returnValue != -1) {
-			if (currentChar->y1 >= _characterList[returnValue].y1) {
+			if (currentChar->y1 >= _characterList[returnValue].y1)
 				returnValue = i;
-			}
 		} else {
 			returnValue = i;
 		}
@@ -1143,19 +1139,20 @@
 	_npcScript->variables[4] = _itemInHand;
 	_npcScript->variables[5] = func;
 	
-	while (_scriptInterpreter->validScript(_npcScript)) {
+	while (_scriptInterpreter->validScript(_npcScript))
 		_scriptInterpreter->runScript(_npcScript);
-	}
 }
 
 int KyraEngine::runOpcode(ScriptState *script, uint8 opcode) {
 	debugC(9, kDebugLevelMain | kDebugLevelScript, "KyraEngine::runOpcode(%p, %d)", (void *)script, opcode);
+	assert(script);
 	assert(opcode < _opcodeTableSize);
+
 	if (_opcodeTable[opcode] == &KyraEngine::o1_dummy)
 		warning("calling unimplemented opcode(0x%.02X)", opcode);
-	int val = (this->*_opcodeTable[opcode])(script);
-	assert(script);
-	return val;
+
+	return (this->*_opcodeTable[opcode])(script);
 }
 
 } // End of namespace Kyra
+

Modified: scummvm/trunk/engines/kyra/kyra.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra.h	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/kyra.h	2007-04-15 16:41:20 UTC (rev 26511)
@@ -20,8 +20,8 @@
  *
  */
 
-#ifndef KYRA_H
-#define KYRA_H
+#ifndef KYRA_KYRA_H
+#define KYRA_KYRA_H
 
 #include "engines/engine.h"
 #include "common/rect.h"
@@ -264,6 +264,7 @@
 	typedef void (KyraEngine::*IntroProc)();
 	typedef int (KyraEngine::*OpcodeProc)(ScriptState *script);
 
+	// static data access
 	const char * const*seqWSATable() { return _seq_WSATable; }
 	const char * const*seqCPSTable() { return _seq_CPSTable; }
 	const char * const*seqCOLTable() { return _seq_COLTable; }
@@ -272,9 +273,60 @@
 	const uint8 * const*palTable1() { return &_specialPalettes[0]; }
 	const uint8 * const*palTable2() { return &_specialPalettes[29]; }
 
+	// sequences
+	// -> misc
 	bool seq_skipSequence() const;
+
+private:
+	// -> demo
+	void seq_demo();
+
+	// -> intro
+	void seq_intro();
+	void seq_introLogos();
+	void seq_introStory();
+	void seq_introMalcolmTree();
+	void seq_introKallakWriting();
+	void seq_introKallakMalcolm();
+
+	// -> ingame animations
+	void seq_createAmuletJewel(int jewel, int page, int noSound, int drawOnly);
+	void seq_brandonHealing();
+	void seq_brandonHealing2();
+	void seq_poisonDeathNow(int now);
+	void seq_poisonDeathNowAnim();
+	void seq_playFluteAnimation();
+	void seq_winterScroll1();
+	void seq_winterScroll2();
+	void seq_makeBrandonInv();
+	void seq_makeBrandonNormal();
+	void seq_makeBrandonNormal2();
+	void seq_makeBrandonWisp();
+	void seq_dispelMagicAnimation();
+	void seq_fillFlaskWithWater(int item, int type);
+	void seq_playDrinkPotionAnim(int item, int unk2, int flags);
+	void seq_brandonToStone();
+
+	// -> end fight
+	int seq_playEnd();
+	void seq_playEnding();
+
+	int handleMalcolmFlag();
+	int handleBeadState();
+	void initBeadState(int x, int y, int x2, int y2, int unk1, BeadState *ptr);
+	int processBead(int x, int y, int &x2, int &y2, BeadState *ptr);
+
+	// -> credits
+	void seq_playCredits();
+
+public:
+	// delay
 	void delayUntil(uint32 timestamp, bool updateGameTimers = false, bool update = false, bool isMainLoop = false);
 	void delay(uint32 millis, bool update = false, bool isMainLoop = false);
+	void delayWithTicks(int ticks);
+	void waitForEvent();
+
+	// TODO
 	void quitGame();
 
 	void registerDefaultSettings();
@@ -292,10 +344,6 @@
 	bool speechEnabled();
 	bool textEnabled();
 	
-	void drawSentenceCommand(const char *sentence, int unk1);
-	void updateSentenceCommand(const char *str1, const char *str2, int unk1);
-	void updateTextFade();
-
 	void updateGameTimers();
 	void clearNextEventTickCount();
 	void setTimerCountdown(uint8 timer, int32 countdown);
@@ -304,8 +352,6 @@
 	void enableTimer(uint8 timer);
 	void disableTimer(uint8 timer);
 
-	void delayWithTicks(int ticks);
-
 	void saveGame(const char *fileName, const char *saveName);
 	void loadGame(const char *fileName);
 
@@ -317,6 +363,7 @@
 	
 	virtual int runOpcode(ScriptState *script, uint8 opcode);
 protected:
+	// Opcodes
 	int o1_magicInMouseItem(ScriptState *script);
 	int o1_characterSays(ScriptState *script);
 	int o1_pauseTicks(ScriptState *script);
@@ -476,77 +523,80 @@
 	int o1_vocLoad(ScriptState *script);
 
 protected:
-
 	virtual int go();
 	virtual int init();
 
-	void startup();
-	void mainLoop();
-	int initCharacterChat(int8 charNum);
-	int8 getChatPartnerNum();
-	void backupChatPartnerAnimFrame(int8 charNum);
-	void restoreChatPartnerAnimFrame(int8 charNum);
-	void endCharacterChat(int8 charNum, int16 arg_4);
-	void waitForChatToFinish(int vocFile, int16 chatDuration, const char *str, uint8 charNum);
-	void characterSays(int vocFile, const char *chatStr, int8 charNum, int8 chatDuration);
+	// input
+	void processInput();
+	int processInputHelper(int xpos, int ypos);
+	int clickEventHandler(int xpos, int ypos);
+	void clickEventHandler2();
+	void updateMousePointer(bool forceUpdate = false);
+	bool hasClickedOnExit(int xpos, int ypos);
 
-	void setCharactersPositions(int character);
-	
-	void setupSceneResource(int sceneId);
-	
-	void enterNewScene(int sceneId, int facing, int unk1, int unk2, int brandonAlive);
-	void transcendScenes(int roomIndex, int roomName);
-	void setSceneFile(int roomIndex, int roomName);
-	void moveCharacterToPos(int character, int facing, int xpos, int ypos);
-	void setCharacterPositionWithUpdate(int character);
-	int setCharacterPosition(int character, int *facingTable);
-	void setCharacterPositionHelper(int character, int *facingTable);
-	int getOppositeFacingDirection(int dir);
+	// scene
+	// -> init
 	void loadSceneMsc();
 	void startSceneScript(int brandonAlive);
 	void setupSceneItems();
 	void initSceneData(int facing, int unk1, int brandonAlive);
-	void clearNoDropRects();
-	void addToNoDropRects(int x, int y, int w, int h);
-	byte findFreeItemInScene(int scene);
-	byte findItemAtPos(int x, int y);
-	void placeItemInGenericMapScene(int item, int index);
 	void initSceneObjectList(int brandonAlive);
 	void initSceneScreen(int brandonAlive);
-	int findDuplicateItemShape(int shape);
+	void setupSceneResource(int sceneId);
+
+	// -> process
+	void enterNewScene(int sceneId, int facing, int unk1, int unk2, int brandonAlive);
+	int handleSceneChange(int xpos, int ypos, int unk1, int frameReset);
+	int processSceneChange(int *table, int unk1, int frameReset);
+	int changeScene(int facing);
+
+	// -> modification
+	void transcendScenes(int roomIndex, int roomName);
+	void setSceneFile(int roomIndex, int roomName);
+
+	// -> pathfinder
 	int findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize);
 	int findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end);
 	int getFacingFromPointToPoint(int x, int y, int toX, int toY);
 	void changePosTowardsFacing(int &x, int &y, int facing);
 	bool lineIsPassable(int x, int y);
 	int getMoveTableSize(int *moveTable);
-	int handleSceneChange(int xpos, int ypos, int unk1, int frameReset);
-	int processSceneChange(int *table, int unk1, int frameReset);
-	int changeScene(int facing);
+
+	// -> item handling 
+	// --> misc
+	void addItemToRoom(uint16 sceneId, uint8 item, int itemIndex, int x, int y);
+
+	// --> drop handling
+	void itemDropDown(int x, int y, int destX, int destY, byte freeItem, int item);
+	int processItemDrop(uint16 sceneId, uint8 item, int x, int y, int unk1, int unk2);
+	void dropItem(int unk1, int item, int x, int y, int unk2);
+
+	// --> dropped item handling
+	int countItemsInScene(uint16 sceneId);
+	void exchangeItemWithMouseItem(uint16 sceneId, int itemIndex);
+	byte findFreeItemInScene(int scene);
+	byte findItemAtPos(int x, int y);
+
+	// --> drop area handling
+	void addToNoDropRects(int x, int y, int w, int h);
+	void clearNoDropRects();
+	int isDropable(int x, int y);
+	int checkNoDropRects(int x, int y);
+
+	// --> player items handling:
+	void updatePlayerItemsForScene();
+
+	// items
+	// -> misc
+	void placeItemInGenericMapScene(int item, int index);
+
+	// -> mouse item
 	void createMouseItem(int item);
 	void destroyMouseItem();
 	void setMouseItem(int item);
+
+	// -> graphics effects
 	void wipeDownMouseItem(int xpos, int ypos);
-	void setBrandonPoisonFlags(int reset);
-	void resetBrandonPoisonFlags();
-
-	void processInput();
-	int processInputHelper(int xpos, int ypos);
-	int clickEventHandler(int xpos, int ypos);
-	void clickEventHandler2();
-	void updateMousePointer(bool forceUpdate = false);
-	bool hasClickedOnExit(int xpos, int ypos);
-	int checkForNPCScriptRun(int xpos, int ypos);
-	void runNpcScript(int func);
-	
-	int countItemsInScene(uint16 sceneId);
-	int processItemDrop(uint16 sceneId, uint8 item, int x, int y, int unk1, int unk2);
-	void exchangeItemWithMouseItem(uint16 sceneId, int itemIndex);
-	void addItemToRoom(uint16 sceneId, uint8 item, int itemIndex, int x, int y);
-	int checkNoDropRects(int x, int y);
-	int isDropable(int x, int y);
-	void itemDropDown(int x, int y, int destX, int destY, byte freeItem, int item);
-	void dropItem(int unk1, int item, int x, int y, int unk2);
 	void itemSpecialFX(int x, int y, int item);
 	void itemSpecialFX1(int x, int y, int item);
 	void itemSpecialFX2(int x, int y, int item);
@@ -554,63 +604,78 @@
 	void magicInMouseItem(int animIndex, int item, int itemPos);
 	void specialMouseItemFX(int shape, int x, int y, int animIndex, int tableIndex, int loopStart, int maxLoops);
 	void processSpecialMouseItemFX(int shape, int x, int y, int tableValue, int loopStart, int maxLoops);
-	void updatePlayerItemsForScene();
+
+	// character
+	// -> movement
+	void moveCharacterToPos(int character, int facing, int xpos, int ypos);
+	void setCharacterPositionWithUpdate(int character);
+	int setCharacterPosition(int character, int *facingTable);
+	void setCharacterPositionHelper(int character, int *facingTable);
+	int getOppositeFacingDirection(int dir);
+	void setCharactersPositions(int character);
+
+	// -> brandon
+	void setBrandonPoisonFlags(int reset);
+	void resetBrandonPoisonFlags();
+
+	// chat
+	// -> process
+	void characterSays(int vocFile, const char *chatStr, int8 charNum, int8 chatDuration);
+	void waitForChatToFinish(int vocFile, int16 chatDuration, const char *str, uint8 charNum);
+
+	// -> initialization
+	int initCharacterChat(int8 charNum);
+	void backupChatPartnerAnimFrame(int8 charNum);
+	void restoreChatPartnerAnimFrame(int8 charNum);
+	int8 getChatPartnerNum();
+
+	// -> deinitialization
+	void endCharacterChat(int8 charNum, int16 arg_4);
+
+	// graphics
+	// -> misc
+	int findDuplicateItemShape(int shape);
+	void updateKyragemFading();
+
+	// -> interface
+	void loadMainScreen(int page = 3);
 	void redrawInventory(int page);
-	
+public:
+	void drawSentenceCommand(const char *sentence, int unk1);
+	void updateSentenceCommand(const char *str1, const char *str2, int unk1);
+	void updateTextFade();
+
+protected:
+	// -> amulet
 	void drawJewelPress(int jewel, int drawSpecial);
 	void drawJewelsFadeOutStart();
 	void drawJewelsFadeOutEnd(int jewel);
+
+	// -> shape handling
 	void setupShapes123(const Shape *shapeTable, int endShape, int flags);
 	void freeShapes123();
 
-	void seq_demo();
-	void seq_intro();
-	void seq_introLogos();
-	void seq_introStory();
-	void seq_introMalcolmTree();
-	void seq_introKallakWriting();
-	void seq_introKallakMalcolm();
-	void seq_createAmuletJewel(int jewel, int page, int noSound, int drawOnly);
-	void seq_brandonHealing();
-	void seq_brandonHealing2();
-	void seq_poisonDeathNow(int now);
-	void seq_poisonDeathNowAnim();
-	void seq_playFluteAnimation();
-	void seq_winterScroll1();
-	void seq_winterScroll2();
-	void seq_makeBrandonInv();
-	void seq_makeBrandonNormal();
-	void seq_makeBrandonNormal2();
-	void seq_makeBrandonWisp();
-	void seq_dispelMagicAnimation();
-	void seq_fillFlaskWithWater(int item, int type);
-	void seq_playDrinkPotionAnim(int item, int unk2, int flags);
-	int seq_playEnd();
-	void seq_brandonToStone();
-	void seq_playEnding();
-	void seq_playCredits();
-	void updateKyragemFading();
+	// misc (TODO)
+	void startup();
+	void mainLoop();
 	
+	int checkForNPCScriptRun(int xpos, int ypos);
+	void runNpcScript(int func);
+	
 	void setupOpcodeTable();
 	const OpcodeProc *_opcodeTable;
 	int _opcodeTableSize;
 	
-	void waitForEvent();
 	void loadMouseShapes();
 	void loadCharacterShapes();
 	void loadSpecialEffectShapes();
 	void loadItems();
 	void loadButtonShapes();
 	void initMainButtonList();
-	void loadMainScreen(int page = 3);
 	void setCharactersInDefaultScene();
 	void setupPanPages();
 	void freePanPages();
 	void closeFinalWsa();
-	int handleMalcolmFlag();
-	int handleBeadState();
-	void initBeadState(int x, int y, int x2, int y2, int unk1, BeadState *ptr);
-	int processBead(int x, int y, int &x2, int &y2, BeadState *ptr);
 	
 	void setTimer19();
 	void setupTimers();
@@ -702,7 +767,7 @@
 	bool _mousePressFlag;
 	int8 _mouseWheel;
 	uint8 _flagsTable[69];
-	uint8 *_shapes[377];
+	uint8 *_shapes[377]; // TODO: the first 4 entries seem to be screen backup rects, move them in the future out of the shape data
 	uint16 _gameSpeed;
 	uint16 _tickLength;
 	int _lang;
@@ -1013,3 +1078,4 @@
 } // End of namespace Kyra
 
 #endif
+

Modified: scummvm/trunk/engines/kyra/kyra_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.cpp	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/kyra_v2.cpp	2007-04-15 16:41:20 UTC (rev 26511)
@@ -43,20 +43,17 @@
 int KyraEngine_v2::init() {
 	KyraEngine::init();
 
-	if (_res->getFileSize("6.FNT")) {
+	if (_res->getFileSize("6.FNT"))
 		_screen->loadFont(Screen::FID_6_FNT, "6.FNT");
-	}
-	if (_res->getFileSize("8FAT.FNT")) {
+	if (_res->getFileSize("8FAT.FNT"))
 		_screen->loadFont(Screen::FID_8_FNT, "8FAT.FNT");
-	}
 	_screen->loadFont(Screen::FID_GOLDFONT_FNT, "GOLDFONT.FNT");
 	_screen->setAnimBlockPtr(3500);
 	_screen->setScreenDim(0);
 	
 	assert(_introStringsSize == 21);
-	for (int i = 0; i < 21; i++) {
+	for (int i = 0; i < 21; i++)
 		_introStringsDuration[i] = strlen(_introStrings[i]) * 8;
-	}
 	
 	// No mouse display in demo
 	if (_flags.isDemo)
@@ -127,3 +124,4 @@
 }
 
 } // end of namespace Kyra
+

Modified: scummvm/trunk/engines/kyra/kyra_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.h	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/kyra_v2.h	2007-04-15 16:41:20 UTC (rev 26511)
@@ -121,3 +121,4 @@
 } // end of namespace Kyra
 
 #endif
+

Modified: scummvm/trunk/engines/kyra/kyra_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v3.cpp	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/kyra_v3.cpp	2007-04-15 16:41:20 UTC (rev 26511)
@@ -117,9 +117,8 @@
 	_mouseSHPBuf = _res->fileData("MOUSE.SHP", 0);
 	assert(_mouseSHPBuf);
 
-	for (int i = 0; i <= 6; ++i) {
+	for (int i = 0; i <= 6; ++i)
 		_gameShapes[i] = _screen->getPtrToShape(_mouseSHPBuf, i);
-	}
 
 	initItems();
 
@@ -244,11 +243,10 @@
 	Common::File *handle = new Common::File();
 	uint32 temp = 0;
 	_res->getFileHandle(_menuAudioFile, &temp, *handle);
-	if (handle->isOpen()) {
+	if (handle->isOpen())
 		_musicSoundChannel = _soundDigital->playSound(handle, true);
-	} else {
+	else
 		delete handle;
-	}
 }
 
 void KyraEngine_v3::playMusicTrack(int track, int force) {
@@ -256,11 +254,10 @@
 	
 	// XXX byte_2C87C compare
 	
-	if (_musicSoundChannel != -1 && !_soundDigital->isPlaying(_musicSoundChannel)) {
+	if (_musicSoundChannel != -1 && !_soundDigital->isPlaying(_musicSoundChannel))
 		force = 1;
-	} else if (_musicSoundChannel == -1) {
+	else if (_musicSoundChannel == -1)
 		force = 1;
-	}
 	
 	if (track == _curMusicTrack && !force)
 		return;
@@ -273,11 +270,10 @@
 		Common::File *handle = new Common::File();
 		uint32 temp = 0;
 		_res->getFileHandle(_soundList[track], &temp, *handle);
-		if (handle->isOpen()) {
+		if (handle->isOpen())
 			_musicSoundChannel = _soundDigital->playSound(handle);
-		} else {
+		else
 			delete handle;
-		}
 	}
 	
 	_musicSoundChannel = track;
@@ -559,18 +555,16 @@
 		*(uint32*)(buf2 + 16) = unkValue1 + size;
 		memcpy(_tableBuffer1 + entries * 14 + 12, _tableBuffer1 + unk1 * 14 + 12, 14);
 	} else {
-		if (usedEntry > unk1) {
+		if (usedEntry > unk1)
 			memcpy(buf2 + 12, _tableBuffer1 + unk1 * 14 + 12, 14);
-		}
 		int temp = *(uint16*)(_tableBuffer1 + 2) - 1;
 		*(uint16*)(_tableBuffer1 + 2) = temp;
 		temp = *(uint16*)(_tableBuffer1 + 4) - 1;
 		*(uint16*)(_tableBuffer1 + 4) = temp;
 	}
 
-	for (int i = unk1; i > ok; --i) {
+	for (int i = unk1; i > ok; --i)
 		memcpy(_tableBuffer1 + i * 14 + 12, _tableBuffer1 + (i-1) * 14 + 12, 14);
-	}
 
 	buf2 = _tableBuffer1 + ok * 14;
 
@@ -613,9 +607,8 @@
 	uint32 idVal = id;
 	uint8 *ptr = (uint8*)bsearch(&idVal, _tableBuffer1 + 12, *(uint16*)(_tableBuffer1), 14, &tableIdCompare);
 
-	if (!ptr) {
+	if (!ptr)
 		return 0;
-	}
 
 	return _tableBuffer2 + *(uint32*)(ptr + 4);
 }
@@ -633,15 +626,13 @@
 
 	_screen->loadBitmap("ITEMS.CSH", 3, 3, 0);
 
-	for (int i = 248; i <= 319; ++i) {
+	for (int i = 248; i <= 319; ++i)
 		addShapeToTable(_screen->getCPagePtr(3), i, i-248);
-	}
 
 	_screen->loadBitmap("ITEMS2.CSH", 3, 3, 0);
 
-	for (int i = 320; i <= 397; ++i) {
+	for (int i = 320; i <= 397; ++i)
 		addShapeToTable(_screen->getCPagePtr(3), i, i-320);
-	}
 
 	uint32 size = 0;
 	uint8 *itemsDat = _res->fileData("_ITEMS.DAT", &size);
@@ -703,3 +694,4 @@
 }
 
 } // end of namespace Kyra
+

Modified: scummvm/trunk/engines/kyra/kyra_v3.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v3.h	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/kyra_v3.h	2007-04-15 16:41:20 UTC (rev 26511)
@@ -144,3 +144,4 @@
 } // end of namespace Kyra
 
 #endif
+

Modified: scummvm/trunk/engines/kyra/plugin.cpp
===================================================================
--- scummvm/trunk/engines/kyra/plugin.cpp	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/plugin.cpp	2007-04-15 16:41:20 UTC (rev 26511)
@@ -141,17 +141,15 @@
 	flags.platform = gd->desc.platform;
 
 	Common::Platform platform = Common::parsePlatform(ConfMan.get("platform"));
-	if (platform != Common::kPlatformUnknown) {
+	if (platform != Common::kPlatformUnknown)
 		flags.platform = platform;
-	}
 
 	if (flags.lang == Common::UNK_LANG) {
 		Common::Language lang = Common::parseLanguage(ConfMan.get("language"));
-		if (lang != Common::UNK_LANG) {
+		if (lang != Common::UNK_LANG)
 			flags.lang = lang;
-		} else {
+		else
 			flags.lang = Common::EN_ANY;
-		}
 	}
 
 	if (!scumm_stricmp("kyra1", gameid)) {
@@ -167,3 +165,4 @@
 }
 
 REGISTER_PLUGIN(KYRA, "Legend of Kyrandia Engine", "The Legend of Kyrandia (C) Westwood Studios");
+

Modified: scummvm/trunk/engines/kyra/resource.cpp
===================================================================
--- scummvm/trunk/engines/kyra/resource.cpp	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/resource.cpp	2007-04-15 16:41:20 UTC (rev 26511)
@@ -81,9 +81,8 @@
 		}
 
 		Common::List<ResourceFile*>::iterator start = _pakfiles.begin();
-		for (;start != _pakfiles.end(); ++start) {
+		for (;start != _pakfiles.end(); ++start)
 			(*start)->protect();
-		}
 	} else {
 		for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
 			Common::String filename = file->name();
@@ -94,9 +93,8 @@
 				continue;
 
 			if (filename.hasSuffix("PAK") || filename.hasSuffix("APK")) {
-				if (!loadPakFile(file->name())) {
+				if (!loadPakFile(file->name()))
 					error("couldn't open pakfile '%s'", file->name().c_str());
-				}
 			}
 		}
 
@@ -534,3 +532,4 @@
 }
 
 } // end of namespace Kyra
+

Modified: scummvm/trunk/engines/kyra/resource.h
===================================================================
--- scummvm/trunk/engines/kyra/resource.h	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/resource.h	2007-04-15 16:41:20 UTC (rev 26511)
@@ -303,3 +303,4 @@
 } // end of namespace Kyra
 
 #endif
+

Modified: scummvm/trunk/engines/kyra/saveload.cpp
===================================================================
--- scummvm/trunk/engines/kyra/saveload.cpp	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/saveload.cpp	2007-04-15 16:41:20 UTC (rev 26511)
@@ -126,19 +126,15 @@
 	_marbleVaseItem = in->readSint16BE();
 	_itemInHand = in->readByte();
 	
-	for (int i = 0; i < 4; ++i) {
+	for (int i = 0; i < 4; ++i)
 		_birthstoneGemTable[i] = in->readByte();
-	}
-	for (int i = 0; i < 3; ++i) {
+	for (int i = 0; i < 3; ++i)
 		_idolGemsTable[i] = in->readByte();
-	}
-	for (int i = 0; i < 3; ++i) {
+	for (int i = 0; i < 3; ++i)
 		_foyerItemTable[i] = in->readByte();
-	}
 	_cauldronState = in->readByte();
-	for (int i = 0; i < 2; ++i) {
+	for (int i = 0; i < 2; ++i)
 		_crystalState[i] = in->readByte();
-	}
 	
 	_brandonStatusBit = in->readUint16BE();
 	_brandonStatusBit0x02Flag = in->readByte();
@@ -207,7 +203,6 @@
 	if (version >= 7) {
 		_curSfxFile = in->readByte();
 
-
 		// In the first version there this entry was introduced,
 		// it wasn't made sure that _curSfxFile was initialized
 		// so if it's out of bounds we just set it to 0.
@@ -225,9 +220,8 @@
 		_screen->loadBitmap("AMULET3.CPS", 10, 10, 0);
 		if (!queryGameFlag(0xF1)) {
 			for (int i = 0x55; i <= 0x5A; ++i) {
-				if (queryGameFlag(i)) {
+				if (queryGameFlag(i))
 					seq_createAmuletJewel(i-0x55, 10, 1, 1);
-				}
 			}
 		}
 		_screen->copyRegion(0, 0, 0, 0, 320, 200, 10, 8);
@@ -308,19 +302,15 @@
 	out->writeSint16BE(_marbleVaseItem);
 	out->writeByte(_itemInHand);
 	
-	for (int i = 0; i < 4; ++i) {
+	for (int i = 0; i < 4; ++i)
 		out->writeByte(_birthstoneGemTable[i]);
-	}
-	for (int i = 0; i < 3; ++i) {
+	for (int i = 0; i < 3; ++i)
 		out->writeByte(_idolGemsTable[i]);
-	}
-	for (int i = 0; i < 3; ++i) {
+	for (int i = 0; i < 3; ++i)
 		out->writeByte(_foyerItemTable[i]);
-	}
 	out->writeByte(_cauldronState);
-	for (int i = 0; i < 2; ++i) {
+	for (int i = 0; i < 2; ++i)
 		out->writeByte(_crystalState[i]);
-	}
 	
 	out->writeUint16BE(_brandonStatusBit);
 	out->writeByte(_brandonStatusBit0x02Flag);
@@ -333,11 +323,10 @@
 	for (int i = 0; i < 32; i++) {
 		out->writeByte(_timers[i].active);
 		out->writeSint32BE(_timers[i].countdown);
-		if (_system->getMillis() >= _timers[i].nextRun) {
+		if (_system->getMillis() >= _timers[i].nextRun)
 			out->writeUint32BE(0);
-		} else {
+		else
 			out->writeUint32BE(_timers[i].nextRun - _system->getMillis());
-		}
 	}
 
 	out->writeUint32BE(sizeof(_flagsTable));
@@ -371,3 +360,4 @@
 	delete out;
 }
 } // end of namespace Kyra
+

Modified: scummvm/trunk/engines/kyra/scene.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene.cpp	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/scene.cpp	2007-04-15 16:41:20 UTC (rev 26511)
@@ -43,24 +43,23 @@
 	_handleInput = false;
 	_abortWalkFlag = false;
 	_abortWalkFlag2 = false;
-	// just used for fm towns version, it should only load the sfx music file there
+
 	if (_flags.platform == Common::kPlatformFMTowns) {
 		int newSfxFile = -1;
-		if (_currentCharacter->sceneId == 7 && sceneId == 24) {
+		if (_currentCharacter->sceneId == 7 && sceneId == 24)
 			newSfxFile = 2;
-		} else if (_currentCharacter->sceneId == 25 && sceneId == 109) {
+		else if (_currentCharacter->sceneId == 25 && sceneId == 109)
 			newSfxFile = 3;
-		} else if (_currentCharacter->sceneId == 120 && sceneId == 37) {
+		else if (_currentCharacter->sceneId == 120 && sceneId == 37)
 			newSfxFile = 4;
-		} else if (_currentCharacter->sceneId == 52 && sceneId == 199) {
+		else if (_currentCharacter->sceneId == 52 && sceneId == 199)
 			newSfxFile = 5;
-		} else if (_currentCharacter->sceneId == 37 && sceneId == 120) {
+		else if (_currentCharacter->sceneId == 37 && sceneId == 120)
 			newSfxFile = 3;
-		} else if (_currentCharacter->sceneId == 109 && sceneId == 25) {
+		else if (_currentCharacter->sceneId == 109 && sceneId == 25)
 			newSfxFile = 2;
-		} else if (_currentCharacter->sceneId == 24 && sceneId == 7) {
+		else if (_currentCharacter->sceneId == 24 && sceneId == 7)
 			newSfxFile = 1;
-		}
 		
 		if (newSfxFile != -1) {
 			_curSfxFile = newSfxFile;
@@ -128,16 +127,14 @@
 		moveCharacterToPos(0, facing, xpos, ypos);
 	}
 	
-	for (int i = 0; i < ARRAYSIZE(_movieObjects); ++i) {
+	for (int i = 0; i < ARRAYSIZE(_movieObjects); ++i)
 		_movieObjects[i]->close();
-	}
 	
 	if (!brandonAlive) {
 		_scriptInterpreter->initScript(_scriptClick, _scriptClickData);
 		_scriptInterpreter->startScript(_scriptClick, 5);
-		while (_scriptInterpreter->validScript(_scriptClick)) {
+		while (_scriptInterpreter->validScript(_scriptClick))
 			_scriptInterpreter->runScript(_scriptClick);
-		}
 	}
 	
 	memset(_entranceMouseCursorTracks, 0xFFFF, sizeof(uint16)*4);
@@ -166,22 +163,17 @@
 	_walkBlockSouth = currentRoom->southExit;
 	_walkBlockWest = currentRoom->westExit;
 	
-	if (_walkBlockNorth == 0xFFFF) {
+	if (_walkBlockNorth == 0xFFFF)
 		_screen->blockOutRegion(0, 0, 320, (_northExitHeight & 0xFF)+3);
-	}
-	if (_walkBlockEast == 0xFFFF) {
+	if (_walkBlockEast == 0xFFFF)
 		_screen->blockOutRegion(312, 0, 8, 139);
-	}
-	if (_walkBlockSouth == 0xFFFF) {
+	if (_walkBlockSouth == 0xFFFF)
 		_screen->blockOutRegion(0, 135, 320, 8);
-	}
-	if (_walkBlockWest == 0xFFFF) {
+	if (_walkBlockWest == 0xFFFF)
 		_screen->blockOutRegion(0, 0, 8, 139);
-	}
 	
-	if (!brandonAlive) {
+	if (!brandonAlive)
 		updatePlayerItemsForScene();
-	}
 
 	startSceneScript(brandonAlive);
 	setupSceneItems();
@@ -190,9 +182,8 @@
 	
 	_loopFlag2 = 0;
 	_screen->showMouse();
-	if (!brandonAlive) {
+	if (!brandonAlive)
 		seq_poisonDeathNow(0);
-	}
 	updateMousePointer(true);
 	_changedScene = true;
 }
@@ -200,6 +191,7 @@
 void KyraEngine::transcendScenes(int roomIndex, int roomName) {
 	debugC(9, kDebugLevelMain, "KyraEngine::transcendScenes(%d, %d)", roomIndex, roomName);
 	assert(roomIndex < _roomTableSize);
+
 	if (_flags.isTalkie) {
 		char file[32];
 		assert(roomIndex < _roomTableSize);
@@ -209,6 +201,7 @@
 		strcat(file, ".VRM");
 		_res->unloadPakFile(file);
 	}
+
 	_roomTable[roomIndex].nameIndex = roomName;
 	_unkScreenVar2 = 1;
 	_unkScreenVar3 = 1;
@@ -238,6 +231,7 @@
 	disableTimer(14);
 	disableTimer(18);
 	uint32 nextFrame = 0;
+
 	switch (facing) {
 	case 0:
 		while (ypos < ch->y1) {
@@ -274,6 +268,7 @@
 	default:
 		break;
 	}
+
 	enableTimer(19);
 	enableTimer(14);
 	enableTimer(18);
@@ -288,13 +283,13 @@
 	_animator->updateAllObjectShapes();
 	updateTextFade();
 
-	if (_currentCharacter->sceneId == 210) {
+	if (_currentCharacter->sceneId == 210)
 		updateKyragemFading();
-	}
 }
 
 int KyraEngine::setCharacterPosition(int character, int *facingTable) {
 	debugC(9, kDebugLevelMain, "KyraEngine::setCharacterPosition(%d, %p)", character, (const void *)facingTable);
+
 	if (character == 0) {
 		_currentCharacter->x1 += _charXPosTable[_currentCharacter->facing];
 		_currentCharacter->y1 += _charYPosTable[_currentCharacter->facing];
@@ -303,9 +298,8 @@
 	} else {
 		_characterList[character].x1 += _charXPosTable[_characterList[character].facing];
 		_characterList[character].y1 += _charYPosTable[_characterList[character].facing];
-		if (_characterList[character].sceneId == _currentCharacter->sceneId) {
+		if (_characterList[character].sceneId == _currentCharacter->sceneId)
 			setCharacterPositionHelper(character, 0);
-		}
 	}
 	return 0;
 }
@@ -335,24 +329,21 @@
 			if (facing - 1 != 0) {
 				if (facing != 4) {
 					if (facing == 3 || facing == 5) {
-						if (facingIsFour[character] > 2) {
+						if (facingIsFour[character] > 2)
 							facing = 4;
-						}
 						resetTables = true;
 					}
 				} else {
 					++facingIsFour[character];
 				}
 			} else {
-				if (facingIsZero[character] > 2) {
+				if (facingIsZero[character] > 2)
 					facing = 0;
-				}
 				resetTables = true;
 			}
 		} else {
-			if (facingIsZero[character] > 2) {
+			if (facingIsZero[character] > 2)
 				facing = 0;
-			}
 			resetTables = true;
 		}
 		
@@ -373,35 +364,26 @@
 	};
 	
 	if (facing == 0) {
-		if (maxAnimationFrame[36+character] > ch->currentAnimFrame) {
+		if (maxAnimationFrame[36+character] > ch->currentAnimFrame)
 			ch->currentAnimFrame = maxAnimationFrame[36+character];
-		}
-		if (maxAnimationFrame[30+character] < ch->currentAnimFrame) {
+		if (maxAnimationFrame[30+character] < ch->currentAnimFrame)
 			ch->currentAnimFrame = maxAnimationFrame[36+character];
-		}
 	} else if (facing == 4) {
-		if (maxAnimationFrame[18+character] > ch->currentAnimFrame) {
+		if (maxAnimationFrame[18+character] > ch->currentAnimFrame)
 			ch->currentAnimFrame = maxAnimationFrame[18+character];
-		}
-		if (maxAnimationFrame[12+character] < ch->currentAnimFrame) {
+		if (maxAnimationFrame[12+character] < ch->currentAnimFrame)
 			ch->currentAnimFrame = maxAnimationFrame[18+character];
-		}
 	} else {
-		if (maxAnimationFrame[18+character] < ch->currentAnimFrame) {
+		if (maxAnimationFrame[18+character] < ch->currentAnimFrame)
 			ch->currentAnimFrame = maxAnimationFrame[30+character];
-		}
-		if (maxAnimationFrame[character] == ch->currentAnimFrame) {
+		if (maxAnimationFrame[character] == ch->currentAnimFrame)
 			ch->currentAnimFrame = maxAnimationFrame[6+character];
-		}
-		if (maxAnimationFrame[character] < ch->currentAnimFrame) {
+		if (maxAnimationFrame[character] < ch->currentAnimFrame)
 			ch->currentAnimFrame = maxAnimationFrame[6+character]+2;
-		}
 	}
 	
-	if (character == 0) {
-		if (_brandonStatusBit & 0x10)
-			ch->currentAnimFrame = 88;
-	}
+	if (character == 0 && (_brandonStatusBit & 0x10))
+		ch->currentAnimFrame = 88;
 	
 	_animator->animRefreshNPC(character);
 }
@@ -455,9 +437,8 @@
 	_exitListPtr = 0;
 	
 	_scaleMode = 1;	
-	for (int i = 0; i < 145; ++i) {
+	for (int i = 0; i < 145; ++i)
 		_scaleTable[i] = 256;
-	}
 	
 	clearNoDropRects();
 	_scriptInterpreter->initScript(_scriptClick, _scriptClickData);
@@ -469,9 +450,8 @@
 	_scriptClick->variables[0] = _currentCharacter->sceneId;
 	_scriptClick->variables[7] = brandonAlive;
 	
-	while (_scriptInterpreter->validScript(_scriptClick)) {
+	while (_scriptInterpreter->validScript(_scriptClick))
 		_scriptInterpreter->runScript(_scriptClick);
-	}
 }
 
 void KyraEngine::initSceneData(int facing, int unk1, int brandonAlive) {
@@ -512,26 +492,20 @@
 			break;
 		}
 		
-		if ((uint8)(_northExitHeight & 0xFF) + 2 >= ypos) {
+		if ((uint8)(_northExitHeight & 0xFF) + 2 >= ypos)
 			ypos = (_northExitHeight & 0xFF) + 4;
-		}
-		if (xpos >= 308) {
+		if (xpos >= 308)
 			xpos = 304;
-		}
-		if ((uint8)(_northExitHeight >> 8) - 2 <= ypos) {
+		if ((uint8)(_northExitHeight >> 8) - 2 <= ypos)
 			ypos = (_northExitHeight >> 8) - 4;
-		}
-		if (xpos <= 12) {
+		if (xpos <= 12)
 			xpos = 16;
-		}
 	}
 	
-	if (_brandonPosX > -1) {
+	if (_brandonPosX > -1)
 		xpos = _brandonPosX;
-	}
-	if (_brandonPosY > -1) {
+	if (_brandonPosY > -1)
 		ypos = _brandonPosY;
-	}
 	
 	int16 ypos2 = 0;
 	if (_brandonPosX > -1 && _brandonPosY > -1) {
@@ -640,23 +614,20 @@
 	
 	initSceneObjectList(brandonAlive);
 	
-	if (unk1 && brandonAlive == 0) {
+	if (unk1 && brandonAlive == 0)
 		moveCharacterToPos(0, facing, xpos2, ypos2);
-	}
 	
 	_scriptClick->variables[4] = _itemInHand;
 	_scriptClick->variables[7] = brandonAlive;
 	_scriptInterpreter->startScript(_scriptClick, 3);
-	while (_scriptInterpreter->validScript(_scriptClick)) {
+	while (_scriptInterpreter->validScript(_scriptClick))
 		_scriptInterpreter->runScript(_scriptClick);
-	}
 }
 
 void KyraEngine::initSceneObjectList(int brandonAlive) {
 	debugC(9, kDebugLevelMain, "KyraEngine::initSceneObjectList(%d)", brandonAlive);
-	for (int i = 0; i < 28; ++i) {
+	for (int i = 0; i < 28; ++i)
 		_animator->actors()[i].active = 0;
-	}
 	
 	int startAnimFrame = 0;
 	
@@ -668,6 +639,7 @@
 	startAnimFrame = _currentCharacter->currentAnimFrame-7;
 	int xOffset = _defaultShapeTable[startAnimFrame].xOffset;
 	int yOffset = _defaultShapeTable[startAnimFrame].yOffset;
+
 	if (_scaleMode) {
 		curAnimState->x1 = _currentCharacter->x1;
 		curAnimState->y1 = _currentCharacter->y1;
@@ -681,6 +653,7 @@
 		curAnimState->x1 = _currentCharacter->x1 + xOffset;
 		curAnimState->y1 = _currentCharacter->y1 + yOffset;
 	}
+
 	curAnimState->x2 = curAnimState->x1;
 	curAnimState->y2 = curAnimState->y1;
 	curAnimState->refreshFlag = 1;
@@ -727,11 +700,10 @@
 		curAnimState->refreshFlag = 1;
 		curAnimState->bkgdChangeFlag = 1;
 		
-		if (ch->facing >= 1 && ch->facing <= 3) {
+		if (ch->facing >= 1 && ch->facing <= 3)
 			curAnimState->flags |= 1;
-		} else if (ch->facing >= 5 && ch->facing <= 7) {
+		else if (ch->facing >= 5 && ch->facing <= 7)
 			curAnimState->flags &= 0xFFFFFFFE;
-		}
 		
 		_animator->addObjectToQueue(curAnimState);
 		
@@ -827,9 +799,8 @@
 	if (_flags.platform == Common::kPlatformAmiga) {
 		if (_unkScreenVar1 && !queryGameFlag(0xF0)) {
 			memset(_screen->getPalette(2), 0, 32*3);
-			if (_currentCharacter->sceneId != 117 || !queryGameFlag(0xB3)) {
+			if (_currentCharacter->sceneId != 117 || !queryGameFlag(0xB3))
 				_screen->setScreenPalette(_screen->getPalette(2));
-			}
 		}
 
 		if (_unkScreenVar2 == 1)
@@ -838,13 +809,11 @@
 			_screen->copyRegion(8, 8, 8, 8, 304, 128, 2, 0);
 
 		if (_unkScreenVar1 && !queryGameFlag(0xA0)) {
-			if (_currentCharacter->sceneId == 45 && _paletteChanged) {
+			if (_currentCharacter->sceneId == 45 && _paletteChanged)
 				memcpy(_screen->getPalette(0) + 12*3, _screen->getPalette(4) + 12*3, 2);
-			}
 
-			if (_currentCharacter->sceneId >= 229 && _currentCharacter->sceneId <= 245 && (_brandonStatusBit & 1)) {
+			if (_currentCharacter->sceneId >= 229 && _currentCharacter->sceneId <= 245 && (_brandonStatusBit & 1))
 				memcpy(_screen->getPalette(0), _screen->getPalette(0) + 320*3, 64);
-			}
 
 			_screen->setScreenPalette(_screen->getPalette(0));
 		}
@@ -859,11 +828,10 @@
 			_screen->setScreenPalette(_screen->getPalette(0));
 		}
 
-		if (_unkScreenVar2 == 1) {
+		if (_unkScreenVar2 == 1)
 			_screen->shuffleScreen(8, 8, 304, 128, 2, 0, _unkScreenVar3, false);
-		} else {
+		else
 			_screen->copyRegion(8, 8, 8, 8, 304, 128, 2, 0);
-		}
 
 		if (_unkScreenVar1 && _paletteChanged) {
 			if (!queryGameFlag(0xA0)) {
@@ -902,11 +870,12 @@
 
 int KyraEngine::handleSceneChange(int xpos, int ypos, int unk1, int frameReset) {
 	debugC(9, kDebugLevelMain, "KyraEngine::handleSceneChange(%d, %d, %d, %d)", xpos, ypos, unk1, frameReset);
-	if (queryGameFlag(0xEF)) {
+	if (queryGameFlag(0xEF))
 		unk1 = 0;
-	}
+
 	int sceneId = _currentCharacter->sceneId;
 	_pathfinderFlag = 0;
+
 	if (xpos < 12) {
 		if (_roomTable[sceneId].westExit != 0xFFFF) {
 			xpos = 12;
@@ -938,31 +907,32 @@
 	int temp = xpos - _currentCharacter->x1;
 	if (ABS(temp) < 4) {
 		temp = ypos - _currentCharacter->y1;
-		if (ABS(temp) < 2) {
+		if (ABS(temp) < 2)
 			return 0;
-		}
 	}
 	
 	int x = (int16)(_currentCharacter->x1 & 0xFFFC);
 	int y = (int16)(_currentCharacter->y1 & 0xFFFE);
 	xpos = (int16)(xpos & 0xFFFC);
 	ypos = (int16)(ypos & 0xFFFE);
+	
 	int ret = findWay(x, y, xpos, ypos, _movFacingTable, 150);
 	_pathfinderFlag = 0;
-	if (ret >= _lastFindWayRet) {
+
+	if (ret >= _lastFindWayRet)
 		_lastFindWayRet = ret;
-	}
-	if (ret == 0x7D00 || ret == 0) {
+
+	if (ret == 0x7D00 || ret == 0)
 		return 0;
-	}
+
 	return processSceneChange(_movFacingTable, unk1, frameReset);
 }
 
 int KyraEngine::processSceneChange(int *table, int unk1, int frameReset) {
 	debugC(9, kDebugLevelMain, "KyraEngine::processSceneChange(%p, %d, %d)", (const void *)table, unk1, frameReset);
-	if (queryGameFlag(0xEF)) {
+	if (queryGameFlag(0xEF))
 		unk1 = 0;
-	}
+
 	int *tableStart = table;
 	_sceneChangeState = 0;
 	_loopFlag2 = 0;
@@ -1013,23 +983,22 @@
 			}
 		}
 		
-		if (forceContinue || !running) {
+		if (forceContinue || !running)
 			continue;
-		}
 		
 		int temp = 0;
-		if (table == tableStart || table[1] == 8) {
+		if (table == tableStart || table[1] == 8)
 			temp = setCharacterPosition(0, 0);
-		} else {
+		else
 			temp = setCharacterPosition(0, table);
-		}
-		if (temp) {
+
+		if (temp)
 			++table;
-		}
 		
 		nextFrame = getTimerDelay(5) * _tickLength + _system->getMillis();
 		while (_system->getMillis() < nextFrame) {
 			updateGameTimers();
+
 			if (_currentCharacter->sceneId == 210) {
 				updateKyragemFading();
 				if (seq_playEnd() || _beadStateVar == 4 || _beadStateVar == 5) {
@@ -1038,14 +1007,15 @@
 					break;
 				}
 			}
+
 			if ((nextFrame - _system->getMillis()) >= 10)
 				delay(10, true);
 		}
 	}
 	
-	if (frameReset && !(_brandonStatusBit & 2)) {
+	if (frameReset && !(_brandonStatusBit & 2))
 		_currentCharacter->currentAnimFrame = 7;
-	}
+
 	_animator->animRefreshNPC(0);
 	_animator->updateAllObjectShapes();
 	return returnValue;
@@ -1054,9 +1024,8 @@
 int KyraEngine::changeScene(int facing) {
 	debugC(9, kDebugLevelMain, "KyraEngine::changeScene(%d)", facing);
 	if (queryGameFlag(0xEF)) {
-		if (_currentCharacter->sceneId == 5) {
+		if (_currentCharacter->sceneId == 5)
 			return 0;
-		}
 	}
 	
 	int xpos = _charXPosTable[facing] + _currentCharacter->x1;
@@ -1069,7 +1038,7 @@
 	
 	if (_exitListPtr) {
 		int16 *ptr = _exitListPtr;
-		// this loop should be only entered on time, seems to be some hack in the original
+		// this loop should be only entered one time, seems to be some hack in the original
 		while (true) {
 			if (*ptr == -1)
 				break;
@@ -1078,12 +1047,14 @@
 				ptr += 10;
 				break;
 			}
+
 			_brandonPosX = ptr[6];
 			_brandonPosY = ptr[7];
 			uint16 sceneId = ptr[5];
 			facing = ptr[4];
 			int unk1 = ptr[8];
 			int unk2 = ptr[9];
+
 			if (sceneId == 0xFFFF) {
 				switch (facing) {
 				case 0:
@@ -1179,12 +1150,14 @@
 	for (int i = 1; i < 5; ++i) {
 		Character *cur = &_characterList[i];
 		//cur->field_20 = 0;
+
 		const uint32 *curTable = defaultSceneTable[i-1];
 		cur->sceneId = curTable[0];
-		if (cur->sceneId == _currentCharacter->sceneId) {
+
+		if (cur->sceneId == _currentCharacter->sceneId)
 			//++cur->field_20;
 			cur->sceneId = curTable[1/*cur->field_20*/];
-		}
+
 		//cur->field_23 = curTable[cur->field_20+1];
 	}
 }
@@ -1199,6 +1172,7 @@
 		0x67, 0x67, 0x60, 0x5A, 0x71,
 		0x76
 	};
+
 	assert(character < ARRAYSIZE(initXPosTable));
 	Character *edit = &_characterList[character];
 	edit->x1 = edit->x2 = initXPosTable[character];
@@ -1291,9 +1265,8 @@
 				}
 			}
 			
-			if (temp != 0x7D00 || tempValue != 0x7D00) {
+			if (temp != 0x7D00 || tempValue != 0x7D00)
 				break;
-			}
 		}
 		
 		if (temp < tempValue) {
@@ -1315,10 +1288,10 @@
 		}
 		x = curX;
 		y = curY;
-		if (curX == toX && curY == toY) {
+		if (curX == toX && curY == toY)
 			break;
-		}
 	}
+
 	delete [] pathTable1;
 	delete [] pathTable2;
 	moveTable[lastUsedEntry] = 8;
@@ -1351,9 +1324,8 @@
 		while (true) {
 			changePosTowardsFacing(xpos1, ypos1, facingTable1[start*8 + newFacing2]);
 			if (!lineIsPassable(xpos1, ypos1)) {
-				if (facingTable1[start*8 + newFacing2] == newFacing) {
+				if (facingTable1[start*8 + newFacing2] == newFacing)
 					return 0x7D00;
-				}
 				newFacing2 = facingTable1[start*8 + newFacing2];
 				xpos1 = x;
 				ypos1 = y;
@@ -1378,19 +1350,20 @@
 				}
 			}
 		}
+
 		moveTable[position++] = newFacing;
 		x = xpos1;
 		y = ypos1;
-		if (x == toX && y == toY) {
+
+		if (x == toX && y == toY)
 			return position;
-		}
 		
-		if (xpos1 == xpos2 && ypos1 == ypos2) {
+		if (xpos1 == xpos2 && ypos1 == ypos2)
 			break;
-		}
 		
 		newFacing = facingTable3[start*8 + newFacing];
 	}
+
 	return 0x7D00;
 }
 
@@ -1432,6 +1405,7 @@
 	} else {
 		facingEntry <<= 1;
 	}
+
 	assert(facingEntry < ARRAYSIZE(facingTable));
 	return facingTable[facingEntry];
 }
@@ -1471,13 +1445,11 @@
 			return true;
 	}
 	
-	if (y > 137) {
+	if (y > 137)
 		return false;
-	}
 
-	if (y < 0) {
+	if (y < 0)
 		y = 0;
-	}
 	
 	int ypos = 8;
 	if (_scaleMode) {
@@ -1541,19 +1513,19 @@
 			}
 			
 			if (tempPosition == moveTable && *tempPosition == 9) {
-				while (*tempPosition != 8 && *tempPosition == 9) {
+				while (*tempPosition != 8 && *tempPosition == 9)
 					++tempPosition;
-				}
-				if (*tempPosition == 8) {
+
+				if (*tempPosition == 8)
 					return 0;
-				}
 			}
 			
 			oldPosition = tempPosition;
 			curPosition = oldPosition+1;
-			while (*curPosition != 8 && *curPosition == 9) {
+
+			while (*curPosition != 8 && *curPosition == 9)
 				++curPosition;
-			}
+
 			continue;
 		}
 		
@@ -1566,20 +1538,19 @@
 				curPosition = oldPosition;
 				oldPosition = tempPosition;
 				while (true) {
-					if (tempPosition == moveTable) {
+					if (tempPosition == moveTable)
 						break;
-					}
+
 					--tempPosition;
-					if (*tempPosition != 9) {
+					if (*tempPosition != 9)
 						break;
-					}
+
 				}
 			} else {
 				while (true) {
 					++curPosition;
-					if (*curPosition != 9) {
+					if (*curPosition != 9)
 						break;
-					}
 				}
 			}
 			continue;
@@ -1588,11 +1559,11 @@
 		tempPosition = oldPosition;
 		oldPosition = curPosition;
 		++retValue;
+
 		while (true) {
 			++curPosition;
-			if (*curPosition != 9) {
+			if (*curPosition != 9)
 				break;
-			}
 		}
 	}
 
@@ -1614,9 +1585,11 @@
 		strcpy(file, _roomFilenameTable[tableId]);
 		strcat(file, ".VRM");
 		_res->unloadPakFile(file);
+
 		strcpy(file, _roomFilenameTable[tableId]);
 		strcat(file, ".PAK");
-		_res->unloadPakFile(file);	
+		_res->unloadPakFile(file);
+
 		strcpy(file, _roomFilenameTable[tableId]);
 		strcat(file, ".APK");
 		_res->unloadPakFile(file);
@@ -1632,10 +1605,12 @@
 	strcat(file, ".VRM");
 	if (Common::File::exists(file))
 		_res->loadPakFile(file);
+
 	strcpy(file, _roomFilenameTable[tableId]);
 	strcat(file, ".PAK");
 	if (Common::File::exists(file))
 		_res->loadPakFile(file);
+
 	strcpy(file, _roomFilenameTable[tableId]);
 	strcat(file, ".APK");
 	if (Common::File::exists(file))
@@ -1643,3 +1618,4 @@
 }
 
 } // end of namespace Kyra
+

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2007-04-15 16:40:28 UTC (rev 26510)
+++ scummvm/trunk/engines/kyra/screen.cpp	2007-04-15 16:41:20 UTC (rev 26511)
@@ -37,17 +37,19 @@
 }
 
 Screen::~Screen() {
-	for (int i = 0; i < SCREEN_OVLS_NUM; ++i) {
+	for (int i = 0; i < SCREEN_OVLS_NUM; ++i)
 		delete [] _sjisOverlayPtrs[i];
-	}
+
 	for (int pageNum = 0; pageNum < SCREEN_PAGE_NUM; pageNum += 2) {
 		delete [] _pagePtrs[pageNum];
 		_pagePtrs[pageNum] = _pagePtrs[pageNum + 1] = 0;
 	}
+
 	for (int f = 0; f < ARRAYSIZE(_fonts); ++f) {
 		delete[] _fonts[f].fontData;
 		_fonts[f].fontData = NULL;
 	}
+
 	delete [] _sjisFontData;
 	delete [] _sjisTempPage;
 	delete [] _currentPalette;
@@ -56,9 +58,8 @@
 	delete [] _animBlockPtr;
 
 	if (_vm->gameFlags().platform != Common::kPlatformAmiga) {
-		for (int i = 0; i < ARRAYSIZE(_palettes); ++i) {
+		for (int i = 0; i < ARRAYSIZE(_palettes); ++i)
 			delete [] _palettes[i];
-		}
 	}
 
 	delete [] _bitBlitRects;
@@ -135,9 +136,8 @@
 		assert(_currentPalette);
 		memset(_currentPalette, 0, 1248);
 
-		for (int i = 0; i < 6; ++i) {
+		for (int i = 0; i < 6; ++i)
 			_palettes[i] = _currentPalette + (i+1)*96;
-		}
 	} else {
 		_currentPalette = new uint8[768];
 		assert(_currentPalette);
@@ -154,9 +154,8 @@
 	_charWidth = 0;
 	_charOffset = 0;
 	memset(_fonts, 0, sizeof(_fonts));
-	for (int i = 0; i < ARRAYSIZE(_textColorsMap); ++i) {
+	for (int i = 0; i < ARRAYSIZE(_textColorsMap); ++i)
 		_textColorsMap[i] = i;
-	}
 	_decodeShapeBuffer = NULL;
 	_decodeShapeBufferSize = 0;
 	_animBlockPtr = NULL;
@@ -372,17 +371,18 @@
 			maxDiff = diff;
 		}
 	}
+
 	int16 delayInc = delay << 8;
-	if (maxDiff != 0) {
+	if (maxDiff != 0)
 		delayInc /= maxDiff;
-	}
+
 	delay = delayInc;
 	for (diff = 1; diff <= maxDiff; ++diff) {
-		if (delayInc >= 512) {
+		if (delayInc >= 512)
 			break;
-		}
 		delayInc += delay;
 	}
+
 	int delayAcc = 0;
 	while (!_vm->quit()) {
 		delayAcc += delayInc;
@@ -394,22 +394,23 @@
 				needRefresh = true;
 				if (c1 > c2) {
 					c2 += diff;
-					if (c1 < c2) {
+					if (c1 < c2)
 						c2 = c1;
-					}
 				}
+
 				if (c1 < c2) {
 					c2 -= diff;
-					if (c1 > c2) {
+					if (c1 > c2)
 						c2 = c1;
-					}
 				}
+
 				fadePal[i] = (uint8)c2;
 			}
 		}
-		if (!needRefresh) {
+
+		if (!needRefresh)
 			break;
-		}
+
 		setScreenPalette(fadePal);
 		_system->updateScreen();
 		//_system->delayMillis((delayAcc >> 8) * 1000 / 60);
@@ -511,9 +512,8 @@
 	if (flags & CR_X_FLIPPED) {
 		while (h--) {
 			for (int i = 0; i < w; ++i) {
-				if (src[i] || (flags & CR_NO_P_CHECK)) {
+				if (src[i] || (flags & CR_NO_P_CHECK))
 					dst[w-i] = src[i];
-				}
 			}
 			src += SCREEN_W;
 			dst += SCREEN_W;
@@ -521,9 +521,8 @@
 	} else {
 		while (h--) {
 			for (int i = 0; i < w; ++i) {
-				if (src[i] || (flags & CR_NO_P_CHECK)) {
+				if (src[i] || (flags & CR_NO_P_CHECK))
 					dst[i] = src[i];
-				}
 			}
 			src += SCREEN_W;
 			dst += SCREEN_W;
@@ -535,9 +534,9 @@
 	debugC(9, kDebugLevelScreen, "Screen::copyRegionToBuffer(%d, %d, %d, %d, %d)", pageNum, x, y, w, h);
 	assert(x >= 0 && x < Screen::SCREEN_W && y >= 0 && y < Screen::SCREEN_H && dest);
 	uint8 *pagePtr = getPagePtr(pageNum);
-	for (int i = y; i < y + h; i++) {
+
+	for (int i = y; i < y + h; i++)
 		memcpy(dest + (i - y) * w, pagePtr + i * SCREEN_W + x, w);
-	}
 }
 
 void Screen::copyPage(uint8 srcPage, uint8 dstPage) {
@@ -570,22 +569,22 @@
 
 void Screen::copyFromCurPageBlock(int x, int y, int w, int h, const uint8 *src) {
 	debugC(9, kDebugLevelScreen, "Screen::copyFromCurPageBlock(%d, %d, %d, %d, %p)", x, y, w, h, (const void *)src);
-	if (x < 0) {
+	if (x < 0)
 		x = 0;	
-	} else if (x >= 40) {
+	else if (x >= 40)
 		return;
-	}
-	if (x + w > 40) {
+
+	if (x + w > 40)
 		w = 40 - x;
-	}
-	if (y < 0) {
+
+	if (y < 0)
 		y = 0;
-	} else if (y >= 200) {
+	else if (y >= 200)
 		return;
-	}
-	if (y + h > 200) {
+
+	if (y + h > 200)
 		h = 200 - y;
-	}
+
 	uint8 *dst = getPagePtr(_curPage) + y * SCREEN_W + x * 8;
 	
 	if (_curPage == 0 || _curPage == 1)
@@ -603,22 +602,22 @@
 void Screen::copyCurPageBlock(int x, int y, int w, int h, uint8 *dst) {
 	debugC(9, kDebugLevelScreen, "Screen::copyCurPageBlock(%d, %d, %d, %d, %p)", x, y, w, h, (const void *)dst);
 	assert(dst);
-	if (x < 0) {
+	if (x < 0)
 		x = 0;	
-	} else if (x >= 40) {
+	else if (x >= 40)
 		return;
-	}
-	if (x + w > 40) {
+
+	if (x + w > 40)
 		w = 40 - x;
-	}
-	if (y < 0) {
+
+	if (y < 0)
 		y = 0;
-	} else if (y >= 200) {
+	else if (y >= 200)
 		return;
-	}
-	if (y + h > 200) {
+
+	if (y + h > 200)
 		h = 200 - y;
-	}
+
 	const uint8 *src = getPagePtr(_curPage) + y * SCREEN_W + x * 8;
 	while (h--) {
 		memcpy(dst, src, w*8);
@@ -632,9 +631,9 @@
 	assert(sx >= 0 && w <= SCREEN_W);
 	int x;
 	uint16 x_offs[SCREEN_W];
-	for (x = 0; x < SCREEN_W; ++x) {
+	for (x = 0; x < SCREEN_W; ++x)
 		x_offs[x] = x;
-	}
+
 	for (x = 0; x < w; ++x) {
 		int i = _vm->_rnd.getRandomNumber(w - 1);
 		SWAP(x_offs[x], x_offs[i]);
@@ -643,9 +642,9 @@
 	assert(sy >= 0 && h <= SCREEN_H);
 	int y;
 	uint8 y_offs[SCREEN_H];
-	for (y = 0; y < SCREEN_H; ++y) {
+	for (y = 0; y < SCREEN_H; ++y)
 		y_offs[y] = y;
-	}
+
 	for (y = 0; y < h; ++y) {
 		int i = _vm->_rnd.getRandomNumber(h - 1);
 		SWAP(y_offs[y], y_offs[i]);
@@ -660,22 +659,20 @@
 			int i = sx + x_offs[x];
 			int j = sy + y_offs[y_cur];
 			++y_cur;
-			if (y_cur >= h) {
+			if (y_cur >= h)
 				y_cur = 0;
-			}
+
 			uint8 color = getPagePixel(srcPage, i, j);
-			if (!transparent || color != 0) {
+			if (!transparent || color != 0)
 				setPagePixel(dstPage, i, j, color);
-			}
 		}
 		// forcing full update for now
 		_forceFullUpdate = true;
 		updateScreen();
 		now = (int32)_system->getMillis();
 		wait = ticks * _vm->tickLength() - (now - start);
-		if (wait > 0) {
+		if (wait > 0)
 			_vm->delay(wait);
-		}
 	}
 
 	copyOverlayRegion(sx, sy, sx, sy, w, h, srcPage, dstPage);
@@ -689,9 +686,9 @@
 void Screen::fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum) {
 	debugC(9, kDebugLevelScreen, "Screen::fillRect(%d, %d, %d, %d, %d, %d)", x1, y1, x2, y2, color, pageNum);
 	assert(x2 < SCREEN_W && y2 < SCREEN_H);
-	if (pageNum == -1) {
+	if (pageNum == -1)
 		pageNum = _curPage;
-	}
+
 	uint8 *dst = getPagePtr(pageNum) + y1 * SCREEN_W + x1;
 	
 	if (pageNum == 0 || pageNum == 1)
@@ -805,9 +802,7 @@
 
 void Screen::setTextColor(const uint8 *cmap, int a, int b) {
 	debugC(9, kDebugLevelScreen, "Screen::setTextColor(%p, %d, %d)", (const void *)cmap, a, b);
-	for (int i = a; i <= b; ++i) {
-		_textColorsMap[i] = *cmap++;
-	}
+	memcpy(&_textColorsMap[a], cmap, b-a+1);
 }
 
 bool Screen::loadFont(FontId fontId, const char *filename) {
@@ -922,17 +917,16 @@
 	const uint8 charHeightFnt = *(fnt->fontData + fnt->charSizeOffset + 4);
 	uint8 charHeight = 0;
 	
-	if (x < 0) {
+	if (x < 0)
 		x = 0;
-	} else if (x >= SCREEN_W) {
+	else if (x >= SCREEN_W)
 		return;
-	}
+
 	int x_start = x;
-	if (y < 0) {
+	if (y < 0)
 		y = 0;
-	} else if (y >= SCREEN_H) {
+	else if (y >= SCREEN_H)
 		return;
-	}
 
 	while (1) {
 		uint c = *str++;
@@ -970,18 +964,19 @@
 	debugC(9, kDebugLevelScreen, "Screen::drawChar('%c', %d, %d)", c, x, y);
 	Font *fnt = &_fonts[_currentFont];
 	uint8 *dst = getPagePtr(_curPage) + y * SCREEN_W + x;
+
 	uint16 bitmapOffset = READ_LE_UINT16(fnt->fontData + fnt->charBitmapOffset + c * 2);
-	if (bitmapOffset == 0) {
+	if (bitmapOffset == 0)
 		return;
-	}
+
 	uint8 charWidth = *(fnt->fontData + fnt->charWidthTableOffset + c);
-	if (charWidth + x > SCREEN_W) {
+	if (charWidth + x > SCREEN_W)
 		return;
-	}
+
 	uint8 charH0 = *(fnt->fontData + fnt->charSizeOffset + 4);
-	if (charH0 + y > SCREEN_H) {
+	if (charH0 + y > SCREEN_H)
 		return;
-	}
+
 	uint8 charH1 = *(fnt->fontData + fnt->charHeightTableOffset + c * 2);
 	uint8 charH2 = *(fnt->fontData + fnt->charHeightTableOffset + c * 2 + 1);
 	charH0 -= charH1 + charH2;
@@ -992,9 +987,8 @@
 	while (charH1--) {
 		uint8 col = _textColorsMap[0];
 		for (int i = 0; i < charWidth; ++i) {
-			if (col != 0) {
+			if (col != 0)
 				*dst = col;
-			}
 			++dst;
 		}
 		dst += pitch;
@@ -1021,9 +1015,8 @@
 	while (charH0--) {
 		uint8 col = _textColorsMap[0];
 		for (int i = 0; i < charWidth; ++i) {
-			if (col != 0) {
+			if (col != 0)
 				*dst = col;
-			}
 			++dst;
 		}
 		dst += pitch;
@@ -1067,19 +1060,21 @@
 	uint8 *table3 = 0;
 	uint8 *table4 = 0;
 	
-	if (flags & 0x8000) {
+	if (flags & 0x8000)
 		table2 = va_arg(args, uint8*);
-	}
+
 	if (flags & 0x100) {
 		table = va_arg(args, uint8*);
 		tableLoopCount = va_arg(args, int);
 		if (!tableLoopCount)
 			flags &= 0xFFFFFEFF;
 	}
+
 	if (flags & 0x1000) {
 		table3 = va_arg(args, uint8*);
 		table4 = va_arg(args, uint8*);
 	}
+
 	if (flags & 0x200) {
 		drawShapeVar1 += 1;
 		drawShapeVar1 &= 7;
@@ -1087,12 +1082,15 @@
 		drawShapeVar4 = 0;
 		drawShapeVar5 = 256;
 	}
+
 	if (flags & 0x4000) {
 		drawShapeVar5 = va_arg(args, int);
 	}
+
 	if (flags & 0x800) {
 		drawLayer = va_arg(args, int);
 	}
+
 	int scale_w, scale_h;
 	if (flags & DSF_SCALE) {
 		scale_w = va_arg(args, int);
@@ -1105,9 +1103,9 @@
 	int ppc = (flags >> 8) & 0x3F;
 	
 	const uint8 *src = shapeData;
-	if (_vm->gameFlags().useAltShapeHeader) {
+	if (_vm->gameFlags().useAltShapeHeader)
 		src += 2;
-	}
+
 	uint16 shapeFlags = READ_LE_UINT16(src); src += 2;
 	
 	int shapeHeight = *src++;
@@ -1132,9 +1130,9 @@
 	src += 3;
 	
 	uint16 frameSize = READ_LE_UINT16(src); src += 2;
-	if ((shapeFlags & 1) || (flags & 0x400)) {
+	if ((shapeFlags & 1) || (flags & 0x400))
 		src += 0x10;
-	}
+
 	if (!(shapeFlags & 2)) {
 		decodeFrame4(src, _animBlockPtr, frameSize);
 		src = _animBlockPtr;
@@ -1146,6 +1144,7 @@
 		_decodeShapeBuffer = new uint8[shapeSize];
 		_decodeShapeBufferSize = shapeSize;
 	}
+
 	if (!_decodeShapeBuffer) {
 		_decodeShapeBufferSize = 0;
 		va_end(args);
@@ -1156,9 +1155,8 @@
 	
 	// only used if shapeFlag & 1 is NOT zero
 	const uint8 *colorTable = shapeData + 10;
-	if (_vm->gameFlags().useAltShapeHeader) {
+	if (_vm->gameFlags().useAltShapeHeader)
 		colorTable += 2;
-	}
 	
 	for (int j = 0; j < shapeHeight; ++j) {
 		uint8 *dsbNextLine = decodedShapeFrame + shapeWidth;
@@ -1168,9 +1166,8 @@
 			if (code != 0) {
 				// this is guessed
 				if (shapeFlags & 1) {
-					if (code < 16) {
+					if (code < 16)
 						*decodedShapeFrame++ = colorTable[code];
-					}
 				} else {
 					*decodedShapeFrame++ = code;
 				}
@@ -1196,35 +1193,31 @@
 	int x1, x2;
 	if (x >= 0) {
 		x1 = 0;
-		if (x + scaledShapeWidth < sx2) {
+		if (x + scaledShapeWidth < sx2)
 			x2 = scaledShapeWidth;
-		} else {
+		else
 			x2 = sx2 - x;
-		}
 	} else {
 		x2 = scaledShapeWidth;
 		x1 = -x;
 		x = 0;
-		if (x2 > sx2) {
+		if (x2 > sx2)
 			x2 = sx2;
-		}
 	}
 	
 	int y1, y2;
 	if (y >= 0) {
 		y1 = 0;
-		if (y + scaledShapeHeight < sy2) {
+		if (y + scaledShapeHeight < sy2)
 			y2 = scaledShapeHeight;
-		} else {
+		else
 			y2 = sy2 - y;
-		}
 	} else {
 		y2 = scaledShapeHeight;
 		y1 = -y;
 		y = 0;
-		if (y2 > sy2) {
+		if (y2 > sy2)
 			y2 = sy2;
-		}
 	}
 
 	uint8 *dst = getPagePtr(pageNum) + y * SCREEN_W + x;
@@ -1235,34 +1228,31 @@
 	
 	int scaleYTable[SCREEN_H];
 	assert(y1 >= 0 && y2 < SCREEN_H);
-	for (y = y1; y < y2; ++y) {
+	for (y = y1; y < y2; ++y)
 		scaleYTable[y] = (y << 8) / scale_h;
-	}
+
 	int scaleXTable[SCREEN_W];
 	assert(x1 >= 0 && x2 < SCREEN_W);
-	for (x = x1; x < x2; ++x) {
+	for (x = x1; x < x2; ++x)
 		scaleXTable[x] = (x << 8) / scale_w;
-	}
 	
 	const uint8 *shapeBuffer = _decodeShapeBuffer;
-	if (flags & DSF_Y_FLIPPED) {
+	if (flags & DSF_Y_FLIPPED)
 		shapeBuffer += shapeWidth * (shapeHeight - 1);
-	}
-	if (flags & DSF_X_FLIPPED) {
+	if (flags & DSF_X_FLIPPED)
 		shapeBuffer += shapeWidth - 1;
-	}
 	
 	for (y = y1; y < y2; ++y) {
 		uint8 *dstNextLine = dst + SCREEN_W;
 		int j = scaleYTable[y];
-		if (flags & DSF_Y_FLIPPED) {
+		if (flags & DSF_Y_FLIPPED)
 			j = -j;
-		}
+
 		for (x = x1; x < x2; ++x) {
 			int xpos = scaleXTable[x];
-			if (flags & DSF_X_FLIPPED) {
+			if (flags & DSF_X_FLIPPED)
 				xpos = -xpos;
-			}
+
 			uint8 color = shapeBuffer[j * shapeWidth + xpos];
 			if (color != 0) {
 				switch (ppc) {
@@ -1271,9 +1261,8 @@
 					break;
 
 				case 1:
-					for (int i = 0; i < tableLoopCount; ++i) {
+					for (int i = 0; i < tableLoopCount; ++i)
 						color = table[color];
-					}
 					break;
 
 				case 2: {
@@ -1292,9 +1281,8 @@
 				case 7:
 				case 3:
 					color = *dst;
-					for (int i = 0; i < tableLoopCount; ++i) {
+					for (int i = 0; i < tableLoopCount; ++i)
 						color = table[color];
-					}
 					break;
 
 				case 4:
@@ -1303,9 +1291,8 @@
 
 				case 5:
 					color = table2[color];
-					for (int i = 0; i < tableLoopCount; ++i) {
+					for (int i = 0; i < tableLoopCount; ++i)
 						color = table[color];
-					}
 					break;
 
 				case 6: {
@@ -1327,9 +1314,8 @@
 						uint8 pixel = *(_shapePages[0] + offset);
 						pixel &= 0x7F;
 						pixel &= 0x87;
-						if (drawLayer < pixel) {
+						if (drawLayer < pixel)
 							color = *(_shapePages[1] + offset);
-						}
 					}
 					break;
 
@@ -1338,12 +1324,12 @@
 						uint8 pixel = *(_shapePages[0] + offset);
 						pixel &= 0x7F;
 						pixel &= 0x87;
+
 						if (drawLayer < pixel) {
 							color = *(_shapePages[1] + offset);
 						} else {
-							for (int i = 0; i < tableLoopCount; ++i) {
+							for (int i = 0; i < tableLoopCount; ++i)
 								color = table[color];
-							}
 						}
 					}
 					break;
@@ -1378,9 +1364,8 @@
 							color = *(_shapePages[1] + offset);
 						} else {
 							color = *dst;
-							for (int i = 0; i < tableLoopCount; ++i) {
+							for (int i = 0; i < tableLoopCount; ++i)
 								color = table[color];
-							}
 						}
 					}
 					break;
@@ -1407,9 +1392,8 @@
 							color = *(_shapePages[1] + offset);
 						} else {
 							color = table2[color];
-							for (int i = 0; i < tableLoopCount; ++i) {
+							for (int i = 0; i < tableLoopCount; ++i)
 								color = table[color];
-							}
 						}
 					}
 					break;
@@ -1447,9 +1431,9 @@
 					break;
 					
 				case 17: {
-						for (int i = 0; i < tableLoopCount; ++i) {
+						for (int i = 0; i < tableLoopCount; ++i)
 							color = table[color];
-						}
+
 						uint8 newColor = table3[color];
 						if (!(newColor & 0x80)) {
 							color = *dst;
@@ -1479,9 +1463,9 @@
 				case 23:
 				case 19: {
 						color = *dst;
-						for (int i = 0; i < tableLoopCount; ++i) {
+						for (int i = 0; i < tableLoopCount; ++i)
 							color = table[color];
-						}
+
 						uint8 newColor = table3[color];
 						if (!(newColor & 0x80)) {
 							color = *dst;
@@ -1502,9 +1486,9 @@
 					
 				case 21: {
 						color = table2[color];
-						for (int i = 0; i < tableLoopCount; ++i) {
+						for (int i = 0; i < tableLoopCount; ++i)
 							color = table[color];
-						}
+
 						uint8 newColor = table3[color];
 						if (!(newColor & 0x80)) {
 							color = *dst;
@@ -1542,9 +1526,9 @@
 						uint8 pixel = *(_shapePages[0] + offset);
 						pixel &= 0x7F;
 						pixel &= 0x87;
-						if (drawLayer < pixel) {
+						if (drawLayer < pixel)
 							color = *(_shapePages[1] + offset);
-						}
+
 						uint8 newColor = table3[color];
 						if (!(newColor & 0x80)) {
 							color = *dst;
@@ -1593,44 +1577,41 @@
 	uint8 *dstEnd = dst + dstSize;
 	while (1) {
 		int count = dstEnd - dst;
-		if (count == 0) {
+		if (count == 0)
 			break;
-		}
+
 		uint8 code = *src++;
 		if (!(code & 0x80)) { // 8th bit isn't set
 			int len = MIN(count, (code >> 4) + 3); //upper half of code is the length		
 			int offs = ((code & 0xF) << 8) | *src++; //lower half of code as byte 2 of offset.
 			const uint8 *dstOffs = dst - offs;
-			while (len--) {
+			while (len--)
 				*dst++ = *dstOffs++;
-			}
 		} else if (code & 0x40) { // 7th bit is set
 			int len = (code & 0x3F) + 3;
 			if (code == 0xFE) {
 				len = READ_LE_UINT16(src); src += 2;
-				if (len > count) {
+				if (len > count)
 					len = count;
-				}
+
 				memset(dst, *src++, len); dst += len;
 			} else {
-				if (code == 0xFF) {
+				if (code == 0xFF)
 					len = READ_LE_UINT16(src); src += 2;
-				}
+
 				int offs = READ_LE_UINT16(src); src += 2;
-				if (len > count) {
+				if (len > count)
 					len = count;
-				}
+
 				const uint8 *dstOffs = dstOrig + offs;
-				while (len--) {
+				while (len--)
 					*dst++ = *dstOffs++;
-				}
 			}
 		} else if (code != 0x80) { // not just the 8th bit set.
 			//Copy some bytes from source to dest.
 			int len = MIN(count, code & 0x3F);
-			while (len--) {
+			while (len--)
 				*dst++ = *src++;
-			}
 		} else {
 			break;
 		}
@@ -1784,6 +1765,7 @@
 				if (flagTable[x&7] & data[y*40+(x>>3)+i*5760])
 					layer = i;
 			}
+
 			if (layer)
 				dst[y*320+x] |= (layer+1);
 		}
@@ -1801,11 +1783,11 @@
 			uint8 len = *src++;
 			code = *src++;
 			while (len--) {
-				if (noXor) {
+				if (noXor)
 					*dst++ = code;
-				} else {
+				else
 					*dst++ ^= code;
-				}
+
 				if (++count == pitch) {
 					count = 0;
 					dstNext += SCREEN_W;
@@ -1833,11 +1815,11 @@
 						uint16 len = subcode - 0x4000;
 						code = *src++;
 						while (len--) {
-							if (noXor) {
+							if (noXor)
 								*dst++ = code;
-							} else {
+							else
 								*dst++ ^= code;
-							}
+
 							if (++count == pitch) {
 								count = 0;
 								dstNext += SCREEN_W;
@@ -1846,11 +1828,11 @@
 						}
 					} else {
 						while (subcode--) {
-							if (noXor) {
+							if (noXor)
 								*dst++ = *src++;
-							} else {
+							else
 								*dst++ ^= *src++;
-							}
+
 							if (++count == pitch) {
 								count = 0;
 								dstNext += SCREEN_W;
@@ -1872,11 +1854,11 @@
 			}
 		} else {
 			while (code--) {
-				if (noXor) {
+				if (noXor)
 					*dst++ = *src++;
-				} else {
+				else
 					*dst++ ^= *src++;
-				}
+
 				if (++count == pitch) {
 					count = 0;
 					dstNext += SCREEN_W;
@@ -1934,11 +1916,11 @@
 	}
 	
 	int16 shapeSize2 = shapeSize;
-	if (_vm->gameFlags().useAltShapeHeader) {
+	if (_vm->gameFlags().useAltShapeHeader)
 		shapeSize += 12;
-	} else {
+	else
 		shapeSize += 10;
-	}
+
 	if (flags & 1)
 		shapeSize += 16;
 	
@@ -1950,8 +1932,10 @@
 	assert(newShape);
 	
 	byte *dst = newShape;
+
 	if (_vm->gameFlags().useAltShapeHeader)
 		dst += 2;
+
 	WRITE_LE_UINT16(dst, (flags & 3)); dst += 2;
 	*dst = h; dst += 1;
 	WRITE_LE_UINT16(dst, w); dst += 2;
@@ -2018,20 +2002,19 @@
 	if (!(flags & 2)) {
 		if (shapeSize > _animBlockSize) {
 			dst = newShape;
-			if (_vm->gameFlags().useAltShapeHeader) {
+			if (_vm->gameFlags().useAltShapeHeader)
 				dst += 2;
-			}
+
 			flags = READ_LE_UINT16(dst);
 			flags |= 2;
 			WRITE_LE_UINT16(dst, flags);
 		} else {
 			src = newShape;
-			if (_vm->gameFlags().useAltShapeHeader) {
+			if (_vm->gameFlags().useAltShapeHeader)
 				src += 2;
-			}
-			if (flags & 1) {
+			if (flags & 1)
 				src += 16;
-			}
+
 			src += 10;
 			uint8 *shapePtrBackUp = src;
 			dst = _animBlockPtr;
@@ -2058,16 +2041,14 @@
 	}
 	
 	dst = newShape;
-	if (_vm->gameFlags().useAltShapeHeader) {
+	if (_vm->gameFlags().useAltShapeHeader)
 		dst += 2;
-	}
 	WRITE_LE_UINT16((dst + 6), shapeSize);
 	
 	if (flags & 1) {
 		dst = newShape + 10;
-		if (_vm->gameFlags().useAltShapeHeader) {
+		if (_vm->gameFlags().useAltShapeHeader)
 			dst += 2;
-		}
 		src = &table[0x100];
 		memcpy(dst, src, sizeof(uint8)*16);
 	}
@@ -2208,17 +2189,15 @@
 }
 
 int Screen::getRectSize(int x, int y) {
-	if (x < 1) {
+	if (x < 1)
 		x = 1;
-	} else if (x > 40) {
+	else if (x > 40)
 		x = 40;
-	}
 	
-	if (y < 1) {
+	if (y < 1)
 		y = 1;
-	} else if (y > 200) {
+	else if (y > 200)
 		y = 200;
-	}
 	
 	return ((x*y) << 3);
 }
@@ -2232,13 +2211,11 @@
 void Screen::showMouse() {
 	debugC(9, kDebugLevelScreen, "Screen::showMouse()");
 
-	if (_mouseLockCount == 1) {
+	if (_mouseLockCount == 1)
 		CursorMan.showMouse(true);
-	}
 
 	if (_mouseLockCount > 0)
 		_mouseLockCount--;
-
 }
 
 void Screen::setShapePages(int page1, int page2) {
@@ -2324,9 +2301,8 @@
 uint8 *Screen::getPalette(int num) {
 	debugC(9, kDebugLevelScreen, "Screen::getPalette(%d)", num);
 	assert(num >= 0 && num < (_vm->gameFlags().platform == Common::kPlatformAmiga ? 6 : 4));
-	if (num == 0) {
+	if (num == 0)
 		return _currentPalette;
-	}
 	
 	return _palettes[num-1];
 }
@@ -2354,6 +2330,7 @@
 	debugC(9, kDebugLevelScreen, "Screen::setNewShapeHeight(%p, %d)", (const void *)shape, height);
 	if (_vm->gameFlags().useAltShapeHeader)
 		shape += 2;
+
 	int oldHeight = shape[2];
 	shape[2] = height;
 	return oldHeight;
@@ -2363,6 +2340,7 @@
 	debugC(9, kDebugLevelScreen, "Screen::setNewShapeHeight(%p)", (const void *)shape);
 	if (_vm->gameFlags().useAltShapeHeader)
 		shape += 2;
+
 	int oldHeight = shape[2];
 	shape[2] = shape[5];
 	return oldHeight;
@@ -2370,9 +2348,9 @@
 
 void Screen::addBitBlitRect(int x, int y, int w, int h) {
 	debugC(9, kDebugLevelScreen, "Screen::addBitBlitRects(%d, %d, %d, %d)", x, y, w, h);
-	if (_bitBlitNum >= BITBLIT_RECTS) {
+	if (_bitBlitNum >= BITBLIT_RECTS)
 		error("too many bit blit rects");
-	}
+
 	_bitBlitRects[_bitBlitNum].x = x;
 	_bitBlitRects[_bitBlitNum].y = y;
 	_bitBlitRects[_bitBlitNum].x2 = w;
@@ -2419,9 +2397,8 @@
 	byte *toPtr = _shapePages[0] + (y * 320 + x);
 	for (int i = 0; i < height; ++i) {
 		byte *backUpTo = toPtr;
-		for (int i2 = 0; i2 < width; ++i2) {
+		for (int i2 = 0; i2 < width; ++i2)
 			*toPtr++ &= 0x7F;
-		}
 		toPtr = (backUpTo + 320);
 	}
 }
@@ -2432,24 +2409,22 @@
 	byte *toPtr = _shapePages[0] + (y * 320 + x);
 	for (int i = 0; i < height; ++i) {
 		byte *backUpTo = toPtr;
-		for (int i2 = 0; i2 < width; ++i2) {
+		for (int i2 = 0; i2 < width; ++i2)
 			*toPtr++ |= 0x80;
-		}
 		toPtr = (backUpTo + 320);
 	}
 }
 
 void Screen::rectClip(int &x, int &y, int w, int h) {
-	if (x < 0) {
+	if (x < 0)
 		x = 0;
-	} else if (x + w >= 320) {
+	else if (x + w >= 320)
 		x = 320 - w;
-	}
-	if (y < 0) {
+
+	if (y < 0)
 		y = 0;
-	} else if (y + h >= 200) {
+	else if (y + h >= 200)
 		y = 200 - h;
-	}
 }
 
 void Screen::backUpRect0(int xpos, int ypos) {
@@ -2481,14 +2456,15 @@
 	int xpos = x - 8;
 	int ypos = y - 1;
 	int layer = 1;
+
 	for (int curX = xpos; curX < xpos + 16; ++curX) {
 		int tempLayer = getShapeFlag2(curX, ypos);
-		if (layer < tempLayer) {
+
+		if (layer < tempLayer)
 			layer = tempLayer;
-		}
-		if (layer >= 7) {
+
+		if (layer >= 7)
 			return 7;
-		}
 	}
 	return layer;
 }
@@ -2502,13 +2478,12 @@
 	for (int useX = xpos; useX < xpos + 16; ++useX) {
 		for (int useY = ypos - height; useY < ypos; ++useY) {
 			int tempLayer = getShapeFlag2(useX, useY);
-			if (tempLayer > layer) {
+
+			if (tempLayer > layer)
 				layer = tempLayer;
-			}
 			
-			if (tempLayer >= 7) {
+			if (tempLayer >= 7)
 				return 7;
-			}
 		}
 	}	
 	return layer;
@@ -2527,6 +2502,7 @@
 		++x;
 	if (x == 19)
 		x = 17;
+
 	uint8 *ptr1 = _unkPtr1;
 	uint8 *ptr2 = _unkPtr2;
 	int oldVideoPage = _curPage;
@@ -2540,9 +2516,9 @@
 		copyRegionToBuffer(_curPage, tempX<<3, 8, 8, height, ptr1);
 		copyBlockToPage(_curPage, tempX<<3, 8, 8, height, ptr2);
 		int newXPos = curX + x;
-		if (newXPos > 37) {
+		if (newXPos > 37)
 			newXPos = newXPos % 38;
-		}
+
 		tempX = newXPos + 1;
 		copyRegionToBuffer(_curPage, tempX<<3, 8, 8, height, ptr2);
 		copyBlockToPage(_curPage, tempX<<3, 8, 8, height, ptr1);
@@ -2714,12 +2690,15 @@
 		w += x;
 		x = 0;
 	}
+
 	if (x + w >= 320)
 		w = 320 - x;
+
 	if (y < 0) {
 		h += y;
 		y = 0;
 	}
+
 	if (y + h >= 200)
 		h = 200 - y;
 	
@@ -3053,3 +3032,4 @@
 }
 

@@ 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