aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Eriksson2004-01-05 11:58:20 +0000
committerDavid Eriksson2004-01-05 11:58:20 +0000
commitc21e5d797cbcd19a949eed9a94ebee283af90a24 (patch)
tree54ab54fc138cd668b57f206f75e1ce9c810ee205
parent8dabcaaef10227cc87c62a84598df87e814357dc (diff)
downloadscummvm-rg350-c21e5d797cbcd19a949eed9a94ebee283af90a24.tar.gz
scummvm-rg350-c21e5d797cbcd19a949eed9a94ebee283af90a24.tar.bz2
scummvm-rg350-c21e5d797cbcd19a949eed9a94ebee283af90a24.zip
At last - credits!
svn-id: r12155
-rw-r--r--queen/credits.cpp157
-rw-r--r--queen/credits.h70
-rw-r--r--queen/cutaway.cpp7
-rw-r--r--queen/logic.cpp43
-rw-r--r--queen/logic.h9
-rw-r--r--queen/module.mk1
-rw-r--r--queen/resource.cpp32
-rw-r--r--queen/resource.h14
8 files changed, 304 insertions, 29 deletions
diff --git a/queen/credits.cpp b/queen/credits.cpp
new file mode 100644
index 0000000000..c7139e2a43
--- /dev/null
+++ b/queen/credits.cpp
@@ -0,0 +1,157 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2003 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "stdafx.h"
+#include "queen/credits.h"
+
+#include "queen/graphics.h"
+#include "queen/queen.h"
+#include "queen/resource.h"
+
+namespace Queen {
+
+Credits::Credits(QueenEngine *vm, const char* filename) :
+ _vm(vm), _running(true), _count(0), _pause(0), _justify(0), _fontSize(0), _color(0), _zone(0) {
+ _credits = new LineReader(
+ (char*)_vm->resource()->loadFile(filename));
+}
+
+Credits::~Credits() {
+ _vm->graphics()->textClear(0, 199);
+ delete _credits;
+}
+
+void Credits::nextRoom() {
+ if (-1 == _pause) {
+ _pause = 0;
+ _vm->graphics()->textClear(0, 199);
+ }
+}
+
+void Credits::update() {
+ if (!_running)
+ return;
+
+ if (_pause > 0) {
+ _pause--;
+ if (!_pause)
+ _vm->graphics()->textClear(0, 199);
+ return;
+ }
+
+ /* wait until next room */
+ if (-1 == _pause)
+ return;
+
+ for (;;) {
+ char *line = _credits->nextLine();
+
+ if (0 == memcmp(line, "EN", 2)) {
+ _running = false;
+ return;
+ }
+
+ if ('.' == line[0]) {
+ int i;
+
+ switch (tolower(line[1])) {
+
+ case 'l' :
+ _justify = 0;
+ break;
+ case 'c' :
+ _justify = 1;
+ break;
+ case 'r' :
+ _justify = 2;
+ break;
+
+ case 's' :
+ _fontSize = 0;
+ break;
+ case 'b' :
+ _fontSize = 1;
+ break;
+
+ case 'p' :
+ sscanf(&line[3], "%d\n", &_pause);
+ _pause *= 10;
+
+ /* wait until next room */
+ if (0 == _pause)
+ _pause = -1;
+
+
+ for(i = 0; i < _count; i++)
+ {
+ _vm->graphics()->textCurrentColor(_list[i].color);
+ _vm->graphics()->textSet(_list[i].x, _list[i].y, _list[i].text);
+ }
+
+ _count = 0;
+ return;
+
+ case 'i' :
+ sscanf(&line[3], "%d\n", &_color);
+ break;
+
+ case '1' :
+ case '2' :
+ case '3' :
+ case '4' :
+ case '5' :
+ case '6' :
+ case '7' :
+ case '8' :
+ case '9' :
+ _zone = line[1] - '1';
+ break;
+ }
+
+ }
+ else {
+ _list[_count].text = line;
+ _list[_count].color = _color;
+ _list[_count].fontSize = _fontSize;
+
+ switch (_justify) {
+ case 0:
+ _list[_count].x = (_zone % 3) * (320 / 3) + 8;
+ break;
+ case 1:
+ _list[_count].x = (_zone % 3) * (320 / 3) + 54 - _vm->graphics()->textWidth(line) / 2;
+ if (_list[_count].x < 8)
+ _list[_count].x = 8;
+ break;
+ case 2:
+ _list[_count].x = (_zone % 3) * (320 / 3) + 100 - _vm->graphics()->textWidth(line);
+ break;
+ }
+
+ _list[_count].y = (_zone / 3) * (200 / 3) + (_count * 10);
+ _count++;
+ }
+ }
+}
+
+
+} // End of namespace Queen
+
diff --git a/queen/credits.h b/queen/credits.h
new file mode 100644
index 0000000000..9c8b7863af
--- /dev/null
+++ b/queen/credits.h
@@ -0,0 +1,70 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2003 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#ifndef CREDITS_H
+#define CREDITS_H
+
+#include "common/util.h"
+#include "queen/defs.h"
+
+namespace Queen {
+
+class QueenEngine;
+class LineReader;
+
+class Credits {
+
+public:
+
+ Credits(QueenEngine *vm, const char* filename);
+ ~Credits();
+
+ void update();
+ void nextRoom();
+
+ bool running() const { return _running; }
+
+private:
+
+ QueenEngine *_vm;
+ LineReader *_credits;
+
+ struct Line
+ {
+ short x,y,color,fontSize;
+ char *text;
+ };
+
+ Line _list[15];
+
+ bool _running;
+ int _count;
+ int _pause;
+ int _justify;
+ int _fontSize;
+ int _color;
+ int _zone;
+
+};
+
+} // End of namespace Queen
+
+#endif
diff --git a/queen/cutaway.cpp b/queen/cutaway.cpp
index e294a71ab4..b9e56facb1 100644
--- a/queen/cutaway.cpp
+++ b/queen/cutaway.cpp
@@ -22,6 +22,7 @@
#include "stdafx.h"
#include "queen/cutaway.h"
+#include "queen/credits.h"
#include "queen/display.h"
#include "queen/graphics.h"
#include "queen/input.h"
@@ -820,8 +821,8 @@ void Cutaway::handlePersonRecord(
if (0 != strcmp(sentence, "*")) {
if (sentence[0] == '#') {
- warning("Credit scripting system not yet implemented");
- // XXX Cinit(sentence + 1);
+ debug(0, "Starting credits");
+ _vm->logic()->startCredits(sentence + 1);
}
else {
if (object.objectNumber > 0) {
@@ -1095,7 +1096,7 @@ void Cutaway::stop() {
int i;
// Stop the credits from running
- // XXX CFlag = 0;
+ _vm->logic()->stopCredits();
_vm->graphics()->bobStopAll();
diff --git a/queen/logic.cpp b/queen/logic.cpp
index 4dba02ad37..8ff4e4f0b0 100644
--- a/queen/logic.cpp
+++ b/queen/logic.cpp
@@ -24,6 +24,7 @@
#include "common/config-manager.h"
#include "queen/command.h"
+#include "queen/credits.h"
#include "queen/cutaway.h"
#include "queen/debug.h"
#include "queen/defs.h"
@@ -42,7 +43,7 @@
namespace Queen {
Logic::Logic(QueenEngine *vm)
- : _vm(vm) {
+ : _queen2jas(NULL), _vm(vm), _credits(NULL) {
_joe.x = _joe.y = 0;
_joe.scale = 100;
memset(_gameState, 0, sizeof(_gameState));
@@ -61,6 +62,10 @@ Logic::Logic(QueenEngine *vm)
}
}
+Logic::~Logic() {
+ delete _credits;
+ delete _queen2jas;
+}
void Logic::initialise() {
@@ -72,6 +77,8 @@ void Logic::initialise() {
uint8 *jas = _vm->resource()->loadFile("QUEEN.JAS", 20);
uint8 *ptr = jas;
+ _queen2jas = new LineReader((char*)_vm->resource()->loadFile("QUEEN2.JAS"));
+
_numRooms = READ_BE_UINT16(ptr); ptr += 2;
_numNames = READ_BE_UINT16(ptr); ptr += 2;
_numObjects = READ_BE_UINT16(ptr); ptr += 2;
@@ -215,7 +222,7 @@ void Logic::initialise() {
_objDescription = new char*[_numDescriptions + 1];
_objDescription[0] = 0;
for (i = 1; i <= _numDescriptions; i++)
- _objDescription[i] = _vm->resource()->getJAS2Line();
+ _objDescription[i] = _queen2jas->nextLine();
//Patch for German text bug
if (_vm->resource()->getLanguage() == GERMAN) {
@@ -227,35 +234,35 @@ void Logic::initialise() {
_objName = new char*[_numNames + 1];
_objName[0] = 0;
for (i = 1; i <= _numNames; i++)
- _objName[i] = _vm->resource()->getJAS2Line();
+ _objName[i] = _queen2jas->nextLine();
_roomName = new char*[_numRooms + 1];
_roomName[0] = 0;
for (i = 1; i <= _numRooms; i++)
- _roomName[i] = _vm->resource()->getJAS2Line();
+ _roomName[i] = _queen2jas->nextLine();
_verbName[0] = 0;
for (i = 1; i <= 12; i++)
- _verbName[i] = _vm->resource()->getJAS2Line();
+ _verbName[i] = _queen2jas->nextLine();
_joeResponse[0] = 0;
for (i = 1; i <= JOE_RESPONSE_MAX; i++)
- _joeResponse[i] = _vm->resource()->getJAS2Line();
+ _joeResponse[i] = _queen2jas->nextLine();
_aAnim = new char*[_numAAnim + 1];
_aAnim[0] = 0;
for (i = 1; i <= _numAAnim; i++)
- _aAnim[i] = _vm->resource()->getJAS2Line();
+ _aAnim[i] = _queen2jas->nextLine();
_aName = new char*[_numAName + 1];
_aName[0] = 0;
for (i = 1; i <= _numAName; i++)
- _aName[i] = _vm->resource()->getJAS2Line();
+ _aName[i] = _queen2jas->nextLine();
_aFile = new char*[_numAFile + 1];
_aFile[0] = 0;
for (i = 1; i <= _numAFile; i++)
- _aFile[i] = _vm->resource()->getJAS2Line();
+ _aFile[i] = _queen2jas->nextLine();
// Step 3 : initialise game state / variables
@@ -978,6 +985,9 @@ void Logic::roomDisplay(uint16 room, RoomDisplayMode mode, uint16 scale, int com
roomErase();
+ if (_credits)
+ _credits->nextRoom();
+
roomSetup(roomName(room), comPanel, inCutaway);
ObjectData *pod = NULL;
if (mode != RDM_FADE_NOJOE) {
@@ -2078,6 +2088,8 @@ void Logic::update() {
}
_vm->graphics()->update(_currentRoom);
+ if (_credits)
+ _credits->update();
_vm->input()->delay();
@@ -3180,6 +3192,19 @@ void Logic::asmEndInterview() {
OSystem::instance()->quit();
}
+void Logic::startCredits(const char *filename) {
+
+ stopCredits();
+ _credits = new Credits(_vm, filename);
+}
+
+void Logic::stopCredits() {
+ if (_credits) {
+ delete _credits;
+ _credits = NULL;
+ }
+}
+
} // End of namespace Queen
diff --git a/queen/logic.h b/queen/logic.h
index 6af4a033d5..1ad67b5b40 100644
--- a/queen/logic.h
+++ b/queen/logic.h
@@ -25,6 +25,7 @@
#include "common/util.h"
#include "queen/defs.h"
#include "queen/structs.h"
+#include "queen/resource.h"
namespace Queen {
@@ -53,11 +54,13 @@ struct ZoneSlot {
};
class QueenEngine;
+class Credits;
class Logic {
public:
Logic(QueenEngine *vm);
+ ~Logic();
uint16 currentRoom() const { return _currentRoom; }
void currentRoom(uint16 room) {
@@ -296,6 +299,9 @@ public:
void asmInterviewIntro();
void asmEndInterview();
+ void startCredits(const char *filename);
+ void stopCredits();
+
typedef bool (Logic::*ExecuteSpecialMoveProc)(uint16);
typedef bool (Logic::*PreChangeRoomProc)();
@@ -312,6 +318,8 @@ protected:
void initialise();
+ LineReader *_queen2jas;
+
uint16 _currentRoom;
uint16 _oldRoom;
uint16 _newRoom;
@@ -440,6 +448,7 @@ protected:
PreChangeRoomProc _preChangeRoom;
QueenEngine *_vm;
+ Credits *_credits;
};
diff --git a/queen/module.mk b/queen/module.mk
index c3fa7b6659..ba2eba5e75 100644
--- a/queen/module.mk
+++ b/queen/module.mk
@@ -2,6 +2,7 @@ MODULE := queen
MODULE_OBJS = \
queen/command.o \
+ queen/credits.o \
queen/cutaway.o \
queen/debug.o \
queen/display.o \
diff --git a/queen/resource.cpp b/queen/resource.cpp
index 2785450836..ad565b0248 100644
--- a/queen/resource.cpp
+++ b/queen/resource.cpp
@@ -44,14 +44,13 @@ const GameVersion Resource::_gameVersions[] = {
Resource::Resource(const Common::String &datafilePath, SaveFileManager *mgr, const char *savePath)
- : _JAS2Pos(0), _datafilePath(datafilePath), _savePath(savePath), _resourceEntries(0), _resourceTable(NULL), _saveFileManager(mgr) {
+ : _datafilePath(datafilePath), _savePath(savePath), _resourceEntries(0), _resourceTable(NULL), _saveFileManager(mgr) {
_resourceFile = new File();
if (!findCompressedVersion() && !findNormalVersion())
error("Could not open resource file '%s%s'", _datafilePath.c_str(), "queen.1");
checkJASVersion();
debug(5, "Detected game version: %s, which has %d resource entries", _versionString, _resourceEntries);
- _JAS2Ptr = (char *)loadFile("QUEEN2.JAS", 0);
}
Resource::~Resource() {
@@ -59,7 +58,6 @@ Resource::~Resource() {
delete _resourceFile;
if(_resourceTable != _resourceTablePEM10)
delete[] _resourceTable;
- delete[] _JAS2Ptr;
delete _saveFileManager;
}
@@ -112,17 +110,6 @@ ResourceEntry *Resource::resourceEntry(const char *filename) const {
return NULL;
}
-char *Resource::getJAS2Line() {
- assert(_JAS2Pos < resourceEntry("QUEEN2.JAS")->size);
- char *startOfLine = _JAS2Ptr + _JAS2Pos;
- char *curPos = startOfLine;
- while (*curPos++ != 0xd) ;
- *(curPos - 1) = '\0'; // '\r'
- *curPos = '\0'; // '\n'
- _JAS2Pos = (curPos - _JAS2Ptr) + 1;
- return startOfLine;
-}
-
uint8 *Resource::loadFile(const char *filename, uint32 skipBytes, byte *dstBuf) {
ResourceEntry *re = resourceEntry(filename);
assert(re != NULL);
@@ -295,5 +282,22 @@ bool Resource::readSave(uint16 slot, byte *&ptr) {
return true;
}
+LineReader::LineReader(char *buffer) : _buffer(buffer), _current(0) {
+}
+
+LineReader::~LineReader() {
+ delete[] _buffer;
+}
+
+char* LineReader::nextLine() {
+ char *startOfLine = _buffer + _current;
+ char *curPos = startOfLine;
+ while (*curPos++ != 0xd) ;
+ *(curPos - 1) = '\0'; // '\r'
+ *curPos = '\0'; // '\n'
+ _current = (curPos - _buffer) + 1;
+ return startOfLine;
+}
+
} // End of namespace Queen
diff --git a/queen/resource.h b/queen/resource.h
index d4b9f0f319..04b360f2f7 100644
--- a/queen/resource.h
+++ b/queen/resource.h
@@ -61,6 +61,17 @@ struct GameVersion {
uint32 dataFileSize;
};
+class LineReader {
+
+public:
+ LineReader(char *buffer);
+ ~LineReader();
+ char* nextLine();
+
+private:
+ char *_buffer;
+ int _current;
+};
class Resource {
@@ -81,7 +92,6 @@ public:
uint8 compression() const { return _compression; }
const char *JASVersion() const { return _versionString; }
Language getLanguage() const;
- char *getJAS2Line();
bool writeSave(uint16 slot, const byte *saveData, uint32 size);
bool readSave(uint16 slot, byte *&ptr);
@@ -94,8 +104,6 @@ public:
protected:
File *_resourceFile;
- char *_JAS2Ptr;
- uint32 _JAS2Pos;
uint8 _compression;
const Common::String _datafilePath;
char _versionString[6];