[Scummvm-cvs-logs] SF.net SVN: scummvm: [22528] scummvm/trunk/engines/kyra
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Thu May 18 15:47:03 CEST 2006
Revision: 22528
Author: lordhoto
Date: 2006-05-18 15:46:34 -0700 (Thu, 18 May 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=22528&view=rev
Log Message:
-----------
- 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)
Modified Paths:
--------------
scummvm/trunk/engines/kyra/kyra.h
scummvm/trunk/engines/kyra/kyra3.cpp
scummvm/trunk/engines/kyra/screen.cpp
scummvm/trunk/engines/kyra/screen.h
scummvm/trunk/engines/kyra/staticres.cpp
scummvm/trunk/engines/kyra/vqa.cpp
scummvm/trunk/engines/kyra/wsamovie.h
Modified: scummvm/trunk/engines/kyra/kyra.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra.h 2006-05-18 21:48:47 UTC (rev 22527)
+++ scummvm/trunk/engines/kyra/kyra.h 2006-05-18 22:46:34 UTC (rev 22528)
@@ -1011,6 +1011,8 @@
};
// maybe subclass KyraEngine_v2 later
+class WSAMovieV3;
+
class KyraEngine_v3 : public KyraEngine {
public:
KyraEngine_v3(OSystem *system);
@@ -1036,6 +1038,12 @@
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
Modified: scummvm/trunk/engines/kyra/kyra3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra3.cpp 2006-05-18 21:48:47 UTC (rev 22527)
+++ scummvm/trunk/engines/kyra/kyra3.cpp 2006-05-18 22:46:34 UTC (rev 22528)
@@ -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 @@
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 @@
_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 @@
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 @@
}
}
+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
Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp 2006-05-18 21:48:47 UTC (rev 22527)
+++ scummvm/trunk/engines/kyra/screen.cpp 2006-05-18 22:46:34 UTC (rev 22528)
@@ -608,6 +608,10 @@
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::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
}
Modified: scummvm/trunk/engines/kyra/screen.h
===================================================================
--- scummvm/trunk/engines/kyra/screen.h 2006-05-18 21:48:47 UTC (rev 22527)
+++ scummvm/trunk/engines/kyra/screen.h 2006-05-18 22:46:34 UTC (rev 22528)
@@ -120,6 +120,7 @@
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 @@
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();
Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp 2006-05-18 21:48:47 UTC (rev 22527)
+++ scummvm/trunk/engines/kyra/staticres.cpp 2006-05-18 22:46:34 UTC (rev 22528)
@@ -791,6 +791,15 @@
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::_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
Modified: scummvm/trunk/engines/kyra/vqa.cpp
===================================================================
--- scummvm/trunk/engines/kyra/vqa.cpp 2006-05-18 21:48:47 UTC (rev 22527)
+++ scummvm/trunk/engines/kyra/vqa.cpp 2006-05-18 22:46:34 UTC (rev 22528)
@@ -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() {
- if (_opened)
- close();
+ close();
}
void VQAMovie::initBuffers() {
@@ -613,7 +613,7 @@
_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 @@
_system->delayMillis(10);
}
- _system->updateScreen();
+ _vm->screen()->updateScreen();
}
// TODO: Wait for the sound to finish?
Modified: scummvm/trunk/engines/kyra/wsamovie.h
===================================================================
--- scummvm/trunk/engines/kyra/wsamovie.h 2006-05-18 21:48:47 UTC (rev 22527)
+++ scummvm/trunk/engines/kyra/wsamovie.h 2006-05-18 22:46:34 UTC (rev 22528)
@@ -101,6 +101,12 @@
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 @@
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;
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