[Scummvm-cvs-logs] SF.net SVN: scummvm: [31704] scummvm/trunk/engines/kyra
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Thu Apr 24 23:11:56 CEST 2008
Revision: 31704
http://scummvm.svn.sourceforge.net/scummvm/?rev=31704&view=rev
Author: lordhoto
Date: 2008-04-24 14:11:55 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
Implemented opcode 56: o3_updateScore.
Modified Paths:
--------------
scummvm/trunk/engines/kyra/gui_v3.cpp
scummvm/trunk/engines/kyra/kyra_v3.cpp
scummvm/trunk/engines/kyra/kyra_v3.h
scummvm/trunk/engines/kyra/script_v3.cpp
scummvm/trunk/engines/kyra/staticres.cpp
Modified: scummvm/trunk/engines/kyra/gui_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_v3.cpp 2008-04-24 20:25:18 UTC (rev 31703)
+++ scummvm/trunk/engines/kyra/gui_v3.cpp 2008-04-24 21:11:55 UTC (rev 31704)
@@ -110,7 +110,7 @@
redrawInventory(30);
drawMalcolmsMoodPointer(-1, 30);
- //XXX
+ drawScore(30, 215, 191);
if (queryGameFlag(0x97))
drawJestersStaff(1, 30);
@@ -312,6 +312,70 @@
_screen->drawShape(page, getShapePtr(shape), 217, y, 0, 0);
}
+void KyraEngine_v3::drawScore(int page, int x, int y) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::drawScore(%d, %d, %d)", page, x, y);
+ if (page == 30) {
+ page = 2;
+ y -= 144;
+ }
+
+ int shape1 = _score / 100;
+ int shape2 = (_score - shape1*100) / 10;
+ int shape3 = _score % 10;
+
+ _screen->drawShape(page, getShapePtr(shape1+433), x, y, 0, 0);
+ x += 8;
+ _screen->drawShape(page, getShapePtr(shape2+433), x, y, 0, 0);
+ x += 8;
+ _screen->drawShape(page, getShapePtr(shape3+433), x, y, 0, 0);
+}
+
+void KyraEngine_v3::drawScoreCounting(int oldScore, int newScore, int drawOld, const int x) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::drawScoreCounting(%d, %d, %d, %d)", oldScore, newScore, drawOld, x);
+ int y = 189;
+ if (_inventoryState)
+ y -= 44;
+
+ int old100 = oldScore / 100;
+ int old010 = (oldScore - old100*100) / 10;
+ int old001 = oldScore % 10;
+
+ int new100 = newScore / 100;
+ int new010 = (newScore - new100*100) / 10;
+ int new001 = newScore % 10;
+
+ if (drawOld) {
+ _screen->drawShape(0, getShapePtr(old100+433), x + 0, y, 0, 0);
+ _screen->drawShape(0, getShapePtr(old010+433), x + 8, y, 0, 0);
+ _screen->drawShape(0, getShapePtr(old001+433), x + 16, y, 0, 0);
+ }
+
+ if (old100 != new100)
+ _screen->drawShape(0, getShapePtr(old100+443), x + 0, y, 0, 0);
+
+ if (old010 != new010)
+ _screen->drawShape(0, getShapePtr(old010+443), x + 8, y, 0, 0);
+
+ _screen->drawShape(0, getShapePtr(old001+443), x + 16, y, 0, 0);
+
+ _screen->drawShape(0, getShapePtr(new100+433), x + 0, y, 0, 0);
+ _screen->drawShape(0, getShapePtr(new010+433), x + 8, y, 0, 0);
+ _screen->drawShape(0, getShapePtr(new001+433), x + 16, y, 0, 0);
+}
+
+int KyraEngine_v3::getScoreX(const char *str) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::getScoreX('%s')", str);
+ Screen::FontId oldFont = _screen->setFont(Screen::FID_8_FNT);
+ _screen->_charWidth = -2;
+
+ int width = _screen->getTextWidth(str);
+ int x = 160 + (width / 2) - 32;
+
+ _screen->setFont(oldFont);
+ _screen->_charWidth = 0;
+ return x;
+}
+
void KyraEngine_v3::redrawInventory(int page) {
debugC(9, kDebugLevelMain, "KyraEngine_v3::redrawInventory(%d)", page);
int yOffset = 0;
Modified: scummvm/trunk/engines/kyra/kyra_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v3.cpp 2008-04-24 20:25:18 UTC (rev 31703)
+++ scummvm/trunk/engines/kyra/kyra_v3.cpp 2008-04-24 21:11:55 UTC (rev 31704)
@@ -128,6 +128,8 @@
_inventoryScrollSpeed = -1;
_invWsa = 0;
_invWsaFrame = -1;
+ _score = 0;
+ memset(_scoreFlagTable, 0, sizeof(_scoreFlagTable));
}
KyraEngine_v3::~KyraEngine_v3() {
@@ -544,11 +546,13 @@
musicUpdate(0);
if (!loadLanguageFile("ITEMS.", _itemFile))
- error("couldn't load ITEMS");
+ error("Couldn't load ITEMS");
+ if (!loadLanguageFile("SCORE.", _scoreFile))
+ error("Couldn't load SCORE");
if (!loadLanguageFile("C_CODE.", _cCodeFile))
- error("couldn't load C_CODE");
+ error("Couldn't load C_CODE");
if (!loadLanguageFile("SCENES.", _scenesFile))
- error("couldn't load SCENES");
+ error("Couldn't load SCENES");
//XXX
@@ -605,7 +609,11 @@
clearAnimObjects();
- //XXX
+ _scoreMax = 0;
+ for (int i = 0; i < _scoreTableSize; ++i) {
+ if (_scoreTable[i] > 0)
+ _scoreMax += _scoreTable[i];
+ }
musicUpdate(0);
memset(_hiddenItems, -1, sizeof(_hiddenItems));
@@ -1594,6 +1602,64 @@
_scriptInterpreter->unloadScript(&_temporaryScriptData);
}
+#pragma mark -
+
+bool KyraEngine_v3::updateScore(int scoreId, int strId) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::updateScore(%d, %d)", scoreId, strId);
+
+ int scoreIndex = (scoreId >> 3);
+ int scoreBit = scoreId & 7;
+ if ((_scoreFlagTable[scoreIndex] & (1 << scoreBit)) != 0)
+ return false;
+
+ setNextIdleAnimTimer();
+ _scoreFlagTable[scoreIndex] |= (1 << scoreBit);
+
+ _screen->hideMouse();
+ strcpy(_stringBuffer, (const char*)getTableEntry(_scoreFile, strId));
+ strcat(_stringBuffer, ": ");
+
+ assert(scoreId < _scoreTableSize);
+
+ int count = _scoreTable[scoreId];
+ if (count > 0)
+ scoreIncrease(count, _stringBuffer);
+
+ _screen->showMouse();
+ setNextIdleAnimTimer();
+ return true;
+}
+
+void KyraEngine_v3::scoreIncrease(int count, const char *str) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::scoreIncrease(%d, '%s')", count, str);
+ int drawOld = 1;
+ _screen->hideMouse();
+
+ showMessage(str, 0xFF, 0xF0);
+ const int x = getScoreX(str);
+
+ for (int i = 0; i < count; ++i) {
+ int oldScore = _score;
+ int newScore = ++_score;
+
+ if (newScore > _scoreMax) {
+ _score = _scoreMax;
+ break;
+ }
+
+ drawScoreCounting(oldScore, newScore, drawOld, x);
+ if (_inventoryState)
+ drawScore(0, 215, 191);
+ _screen->updateScreen();
+ delay(20, true);
+
+ playSoundEffect(0x0E, 0xC8);
+ drawOld = 0;
+ }
+
+ _screen->showMouse();
+}
+
#pragma mark -
Movie *KyraEngine_v3::createWSAMovie() {
Modified: scummvm/trunk/engines/kyra/kyra_v3.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v3.h 2008-04-24 20:25:18 UTC (rev 31703)
+++ scummvm/trunk/engines/kyra/kyra_v3.h 2008-04-24 21:11:55 UTC (rev 31704)
@@ -266,6 +266,10 @@
void drawMalcolmsMoodText();
void drawMalcolmsMoodPointer(int frame, int page);
void drawJestersStaff(int type, int page);
+
+ void drawScore(int page, int x, int y);
+ void drawScoreCounting(int oldScore, int newScore, int drawOld, const int x);
+ int getScoreX(const char *str);
static const uint8 _inventoryX[];
static const uint8 _inventoryY[];
@@ -650,6 +654,15 @@
char *_stringBuffer;
+ int _score;
+ int _scoreMax;
+
+ static const int8 _scoreTable[];
+ static const int _scoreTableSize;
+ int8 _scoreFlagTable[26];
+ bool updateScore(int scoreId, int strId);
+ void scoreIncrease(int count, const char *str);
+
// opcodes
int o3_getMalcolmShapes(ScriptState *script);
int o3_setCharacterPos(ScriptState *script);
@@ -684,6 +697,7 @@
int o3_wipeDownMouseItem(ScriptState *script);
int o3_setMalcolmsMood(ScriptState *script);
int o3_delay(ScriptState *script);
+ int o3_updateScore(ScriptState *script);
int o3_setSceneFilename(ScriptState *script);
int o3_drawSceneShape(ScriptState *script);
int o3_checkInRect(ScriptState *script);
Modified: scummvm/trunk/engines/kyra/script_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_v3.cpp 2008-04-24 20:25:18 UTC (rev 31703)
+++ scummvm/trunk/engines/kyra/script_v3.cpp 2008-04-24 21:11:55 UTC (rev 31704)
@@ -317,6 +317,11 @@
return 0;
}
+int KyraEngine_v3::o3_updateScore(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_updateScore(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
+ return updateScore(stackPos(0), stackPos(1)) ? 1 : 0;
+}
+
int KyraEngine_v3::o3_setSceneFilename(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_setSceneFilename(%p) (%d, '%s')", (const void *)script, stackPos(0), stackPosString(1));
strcpy(_sceneList[stackPos(0)].filename1, stackPosString(1));
@@ -1093,8 +1098,8 @@
Opcode(o3_dummy);
Opcode(o3_delay);
// 0x38
+ Opcode(o3_updateScore);
OpcodeUnImpl();
- OpcodeUnImpl();
Opcode(o3_setSceneFilename);
OpcodeUnImpl();
// 0x3c
Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp 2008-04-24 20:25:18 UTC (rev 31703)
+++ scummvm/trunk/engines/kyra/staticres.cpp 2008-04-24 21:11:55 UTC (rev 31704)
@@ -2400,5 +2400,35 @@
0x6, 0x9, 0x2, 0xC
};
+const int8 KyraEngine_v3::_scoreTable[] = {
+ 10, 8, 5, 9, 10, 10, 7, 8,
+ 9, 9, 8, 8, 7, 8, 5, 9,
+ 6, 10, 7, 8, 5, 9, 6, 6,
+ 7, 8, 5, 9, 6, 8, 7, 8,
+ 5, 9, 6, 10, 7, 8, 5, 5,
+ 5, 7, 5, 7, 10, 5, 10, 5,
+ 5, 8, 6, 8, 7, 5, 5, 8,
+ 6, 9, 5, 7, 6, 5, 5, 7,
+ 7, 7, 6, 5, 8, 6, 10, 5,
+ 7, 5, 10, 5, 5, 5, 5, 7,
+ 5, 8, 9, 7, 7, 6, 10, 6,
+ 5, 10, 8, 5, 8, 6, 10, 5,
+ 5, 8, 8, 5, 7, 7, 7, 6,
+ 8, 9, 8, 8, 6, 5, 7, 6,
+ 5, 8, 15, 7, 9, 6, 6, 8,
+ 5, 8, 15, 15, 5, 15, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+const int KyraEngine_v3::_scoreTableSize = ARRAYSIZE(KyraEngine_v3::_scoreTable);
+
} // End of namespace Kyra
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