aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2006-05-18 22:46:34 +0000
committerJohannes Schickel2006-05-18 22:46:34 +0000
commit570b9e2c9dd9bb13ef01fae5e7deb8e038d7067f (patch)
tree49899896302b373b50927ca563a84eaa9922b96f
parentfac7a13cf5c2dd128f5f5b46f3d9c52a534a2322 (diff)
downloadscummvm-rg350-570b9e2c9dd9bb13ef01fae5e7deb8e038d7067f.tar.gz
scummvm-rg350-570b9e2c9dd9bb13ef01fae5e7deb8e038d7067f.tar.bz2
scummvm-rg350-570b9e2c9dd9bb13ef01fae5e7deb8e038d7067f.zip
- load fonts for kyra3
- adds screen dim tables for kyra3 - adds palette / screen backup for the vqa player - small changes in the vqa player to use the Kyra::Screen functions - adds (partially implemented/unimplemented) main menu drawing/handling functions (nothing to see yet) svn-id: r22528
-rw-r--r--engines/kyra/kyra.h8
-rw-r--r--engines/kyra/kyra3.cpp139
-rw-r--r--engines/kyra/screen.cpp13
-rw-r--r--engines/kyra/screen.h5
-rw-r--r--engines/kyra/staticres.cpp27
-rw-r--r--engines/kyra/vqa.cpp8
-rw-r--r--engines/kyra/wsamovie.h15
7 files changed, 184 insertions, 31 deletions
diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h
index c003131189..794d1f6901 100644
--- a/engines/kyra/kyra.h
+++ b/engines/kyra/kyra.h
@@ -1011,6 +1011,8 @@ public:
};
// maybe subclass KyraEngine_v2 later
+class WSAMovieV3;
+
class KyraEngine_v3 : public KyraEngine {
public:
KyraEngine_v3(OSystem *system);
@@ -1036,6 +1038,12 @@ private:
int _musicSoundChannel;
const char *_menuAudioFile;
+
+ // gui/menu specific
+private:
+ static const char *_mainMenuStrings[];
+ int handleMainMenu(WSAMovieV3 *logo);
+ void drawMainMenu(const char * const *strings, int unk1);
};
} // End of namespace Kyra
diff --git a/engines/kyra/kyra3.cpp b/engines/kyra/kyra3.cpp
index dbd1f9bde5..c7bf6e12b8 100644
--- a/engines/kyra/kyra3.cpp
+++ b/engines/kyra/kyra3.cpp
@@ -24,6 +24,7 @@
#include "kyra/screen.h"
#include "kyra/wsamovie.h"
#include "kyra/sound.h"
+#include "kyra/text.h"
#include "common/system.h"
@@ -48,6 +49,11 @@ int KyraEngine_v3::init() {
assert(_soundDigital);
assert(_soundDigital->init());
+ uint32 sz;
+ _screen->loadFont(Screen::FID_6_FNT, _res->fileData("6.FNT", &sz));
+ _screen->loadFont(Screen::FID_8_FNT, _res->fileData("8FAT.FNT", &sz));
+ _screen->setScreenDim(0);
+
return 0;
}
@@ -55,11 +61,10 @@ int KyraEngine_v3::go() {
_screen->_curPage = 0;
_screen->clearPage(0);
- byte *pal = new byte[768];
- assert(pal);
- memset(pal, 0, sizeof(byte)*768);
+ uint8 pal[768];
+ memset(pal, 0, sizeof(pal));
- Movie *logo = createWSAMovie();
+ WSAMovieV3 *logo = new WSAMovieV3(this);
logo->open("REVENGE.WSA", 1, pal);
assert(logo->opened());
@@ -73,35 +78,46 @@ int KyraEngine_v3::go() {
logo->setX(0); logo->setY(0);
logo->setDrawPage(0);
- for (int i = 0; i < 29; ++i) {
+ for (int i = 0; i < 64; ++i) {
uint32 nextRun = _system->getMillis() + 3 * _tickLength;
logo->displayFrame(i);
_screen->updateScreen();
delayUntil(nextRun);
}
- while (1) {
- for (int i = 29; i < 64; ++i) {
- uint32 nextRun = _system->getMillis() + 3 * _tickLength;
- logo->displayFrame(i);
- _screen->updateScreen();
- delayUntil(nextRun);
- }
+ for (int i = 64; i > 29; --i) {
+ uint32 nextRun = _system->getMillis() + 3 * _tickLength;
+ logo->displayFrame(i);
+ _screen->updateScreen();
+ delayUntil(nextRun);
+ }
- for (int i = 64; i > 29; --i) {
- uint32 nextRun = _system->getMillis() + 3 * _tickLength;
- logo->displayFrame(i);
- _screen->updateScreen();
- delayUntil(nextRun);
- }
+ switch (handleMainMenu(logo)) {
+ case 0:
+ break;
+
+ case 1:
+ break;
+
+ case 2:
+ break;
+
+ case 3:
+ break;
+
+ default:
+ break;
}
- delete [] pal;
+ delete logo;
return 0;
}
void KyraEngine_v3::playMenuAudioFile() {
+ if (_soundDigital->isPlaying(_musicSoundChannel))
+ return;
+
Common::File *handle = new Common::File();
uint32 temp = 0;
_res->fileHandle(_menuAudioFile, &temp, *handle);
@@ -110,18 +126,99 @@ void KyraEngine_v3::playMenuAudioFile() {
}
}
+int KyraEngine_v3::handleMainMenu(WSAMovieV3 *logo) {
+ int command = -1;
+
+ const char * const *strings = &_mainMenuStrings[/*_lang*4*/0];
+ Screen::FontId oldFont = _screen->setFont(Screen::FID_8_FNT);
+ int charWidthBackUp = _screen->_charWidth;
+
+ _screen->setScreenDim(3);
+ _screen->copyCurPageBlock(_screen->_curDim->sx, _screen->_curDim->sy, _screen->_curDim->w, _screen->_curDim->h, _screen->getPagePtr(3));
+
+ int left = _screen->_curDim->sx << 3; int top = _screen->_curDim->sy;
+ int right = left + (_screen->_curDim->w << 3); int bottom = top + _screen->_curDim->h;
+
+ // XXX
+ // gui_unk1(left, top, right, bottom, 1, 0);
+ // gui_unk1(left + 1, top + 1, right - 1, bottom - 1, 0, 0);
+
+ int curFrame = 29, frameAdd = 1;
+ uint32 nextRun = 0;
+
+ drawMainMenu(strings, 0xFFFF);
+
+ while (command == -1) {
+ // yes 2 * _tickLength here not 3 * like in the first draw
+ nextRun = _system->getMillis() + 2 * _tickLength;
+ logo->displayFrame(curFrame);
+ _screen->updateScreen();
+
+ curFrame += frameAdd;
+ if (curFrame < 29) {
+ curFrame = 29;
+ frameAdd = 1;
+ } else if (curFrame > 63) {
+ curFrame = 64;
+ frameAdd = -1;
+ }
+
+ // XXX
+
+ while (_system->getMillis() < nextRun) {
+ // XXX
+ _screen->updateScreen();
+ if ((int32)nextRun - (int32)_system->getMillis() >= 10)
+ delay(10);
+ }
+ }
+
+ _screen->copyBlockToPage(_screen->_curPage, _screen->_curDim->sx, _screen->_curDim->sy, _screen->_curDim->w, _screen->_curDim->h, _screen->getPagePtr(3));
+ _screen->_charWidth = charWidthBackUp;
+ _screen->setFont(oldFont);
+
+ if (command == 3) {
+ _screen->fadeToBlack();
+ _soundDigital->stopSound(_musicSoundChannel);
+ _musicSoundChannel = -1;
+ }
+
+ return command;
+}
+
+void KyraEngine_v3::drawMainMenu(const char * const *strings, int unk1) {
+ static const uint16 _menuTable[] = { 0x01, 0x04, 0x0C, 0x04, 0x00, 0xFF, 0x00, 0x01, 0x02, 0x03 };
+
+ int left = _screen->_curDim->sx << 3; int top = _screen->_curDim->sy;
+ int width = _screen->_curDim->w << 3; int height = _screen->_curDim->h;
+
+ top += _menuTable[1];
+
+ for (int i = 0; i < _menuTable[3]; ++i) {
+ int curY = top + i * _screen->getFontHeight();
+ // XXX
+ }
+}
+
void KyraEngine_v3::playVQA(const char *filename) {
VQAMovie vqa(this, _system);
- // TODO: Save the palette
+ uint8 pal[768];
+ memcpy(pal, _screen->_currentPalette, sizeof(pal));
+ if (_screen->_curPage == 0)
+ _screen->copyCurPageBlock(0, 0, 320, 200, _screen->getPagePtr(3));
vqa.open(filename, 0, NULL);
if (vqa.opened()) {
+ vqa.setX(0); vqa.setY(0);
+ vqa.setDrawPage(0);
vqa.play();
vqa.close();
}
- // TODO: Restore the palette
+ if (_screen->_curPage == 0)
+ _screen->copyBlockToPage(0, 0, 0, 320, 200, _screen->getPagePtr(3));
+ _screen->setScreenPalette(pal);
}
} // end of namespace Kyra
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index a03f90864e..bc3f4bf115 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -608,6 +608,10 @@ Screen::FontId Screen::setFont(FontId fontId) {
return prev;
}
+int Screen::getFontHeight() const {
+ return (int)(_fonts[_currentFont].charBoxHeight);
+}
+
int Screen::getCharWidth(uint8 c) const {
debugC(9, kDebugLevelScreen, "Screen::getCharWidth('%c')", c);
return (int)_fonts[_currentFont].charWidthTable[c] + _charWidth;
@@ -744,8 +748,13 @@ void Screen::drawChar(uint8 c, int x, int y) {
void Screen::setScreenDim(int dim) {
debugC(9, kDebugLevelScreen, "setScreenDim(%d)", dim);
- assert(dim < _screenDimTableCount);
- _curDim = &_screenDimTable[dim];
+ if (_vm->game() != GI_KYRA3) {
+ assert(dim < _screenDimTableCount);
+ _curDim = &_screenDimTable[dim];
+ } else {
+ assert(dim < _screenDimTableCountK3);
+ _curDim = &_screenDimTableK3[dim];
+ }
// XXX
}
diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h
index 2e208c0ca1..6810ad7389 100644
--- a/engines/kyra/screen.h
+++ b/engines/kyra/screen.h
@@ -120,6 +120,7 @@ public:
void setTextColor(const uint8 *cmap, int a, int b);
void loadFont(FontId fontId, uint8 *fontData);
FontId setFont(FontId fontId);
+ int getFontHeight() const;
int getCharWidth(uint8 c) const;
int getTextWidth(const char *str) const;
void printText(const char *str, int x, int y, uint8 color1, uint8 color2);
@@ -179,6 +180,10 @@ public:
static const ScreenDim _screenDimTable[];
static const int _screenDimTableCount;
+
+ // maybe subclass screen for kyra3
+ static const ScreenDim _screenDimTableK3[];
+ static const int _screenDimTableCountK3;
private:
int16 encodeShapeAndCalculateSize(uint8 *from, uint8 *to, int size);
void restoreMouseRect();
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index cec6a17a2f..04695c4464 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -791,6 +791,15 @@ const ScreenDim Screen::_screenDimTable[] = {
const int Screen::_screenDimTableCount = ARRAYSIZE(_screenDimTable);
+const ScreenDim Screen::_screenDimTableK3[] = {
+ { 0x00, 0x00, 0x28, 0xC8, 0xFF, 0xF0, 0x00, 0x00 },
+ { 0x08, 0x48, 0x18, 0x38, 0xFF, 0xF0, 0x00, 0x00 },
+ { 0x00, 0x00, 0x28, 0xBC, 0xFF, 0xF0, 0x00, 0x00 },
+ { 0x0A, 0x96, 0x14, 0x30, 0x19, 0xF0, 0x00, 0x00 }
+};
+
+const int Screen::_screenDimTableCountK3 = ARRAYSIZE(_screenDimTableK3);
+
// CD Version *could* use an different opcodeTable
#define Opcode(x) &KyraEngine::x
KyraEngine::OpcodeProc KyraEngine::_opcodeTable[] = {
@@ -1195,4 +1204,22 @@ const uint16 KyraEngine::_amuletY[] = { 170, 170, 159, 181 };
const uint16 KyraEngine::_amuletX2[] = { 0x000, 0x0FD, 0x0E7, 0x0FD, 0x113, 0x000 };
const uint16 KyraEngine::_amuletY2[] = { 0x000, 0x09F, 0x0AA, 0x0B5, 0x0AA, 0x000 };
+
+// kyra 3 static res
+const char *KyraEngine_v3::_mainMenuStrings[] = {
+ "Start a new game",
+ "Introduction",
+ "Load a game",
+ "Exit the game",
+ "Nouvelle Partie",
+ "Introduction",
+ "Charger une partie",
+ "Quitter le jeu",
+ "Neues Spiel starten",
+ "Intro",
+ "Spielstand laden",
+ "Spiel beenden",
+ 0
+};
+
} // End of namespace Kyra
diff --git a/engines/kyra/vqa.cpp b/engines/kyra/vqa.cpp
index 23fee5db6e..b7e3e780db 100644
--- a/engines/kyra/vqa.cpp
+++ b/engines/kyra/vqa.cpp
@@ -35,6 +35,7 @@
#include "sound/mixer.h"
#include "kyra/sound.h"
#include "kyra/wsamovie.h"
+#include "kyra/screen.h"
namespace Kyra {
@@ -43,8 +44,7 @@ VQAMovie::VQAMovie(KyraEngine *vm, OSystem *system) : Movie(vm) {
}
VQAMovie::~VQAMovie() {
- if (_opened)
- close();
+ close();
}
void VQAMovie::initBuffers() {
@@ -613,7 +613,7 @@ void VQAMovie::displayFrame(int frameNum) {
_partialCodeBookSize = 0;
}
- _system->copyRectToScreen(_frame, _header.width, _x, _y, _header.width, _header.height);
+ _vm->screen()->copyBlockToPage(_drawPage, _x, _y, _header.width, _header.height, _frame);
}
void VQAMovie::play() {
@@ -712,7 +712,7 @@ void VQAMovie::play() {
_system->delayMillis(10);
}
- _system->updateScreen();
+ _vm->screen()->updateScreen();
}
// TODO: Wait for the sound to finish?
diff --git a/engines/kyra/wsamovie.h b/engines/kyra/wsamovie.h
index eb1058d504..ba803317d7 100644
--- a/engines/kyra/wsamovie.h
+++ b/engines/kyra/wsamovie.h
@@ -101,6 +101,12 @@ public:
void setX(int x) { _x = x + _xAdd; }
void setY(int y) { _y = y + _yAdd; }
+
+ int xAdd() const { return _xAdd; }
+ int yAdd() const { return _yAdd; }
+
+ int width() const { return _width; }
+ int height() const { return _height; }
protected:
KyraEngine_v3 *_vm3;
@@ -115,15 +121,16 @@ public:
VQAMovie(KyraEngine *vm, OSystem *system);
~VQAMovie();
+ // Only the first parameter is used.
+ void open(const char *filename, int offscreen, uint8 *palette);
+ void close();
+
int frames() { return _opened ? _header.numFrames : -1; }
+ // should not be used (maybe don't use Movie as a baseclass then?)
void displayFrame(int frameNum);
- // Only the first parameter is used.
- virtual void open(const char *filename, int offscreen, uint8 *palette);
- void close();
void play();
-
protected:
OSystem *_system;