aboutsummaryrefslogtreecommitdiff
path: root/engines/gnap
diff options
context:
space:
mode:
authorStrangerke2016-04-03 17:29:06 +0200
committerEugene Sandulenko2016-05-10 09:54:21 +0200
commit66f5610c74710a298ae6a4166b37f438d25882bd (patch)
tree9e1854816fe3f3c00e3a202c22bb2927a4c5bd7e /engines/gnap
parent9d0caa4bdbf993dfde211c9a8c5c56c34809ae41 (diff)
downloadscummvm-rg350-66f5610c74710a298ae6a4166b37f438d25882bd.tar.gz
scummvm-rg350-66f5610c74710a298ae6a4166b37f438d25882bd.tar.bz2
scummvm-rg350-66f5610c74710a298ae6a4166b37f438d25882bd.zip
GNAP: Implement intro, currently disabled. Remove some Debug code.
Diffstat (limited to 'engines/gnap')
-rw-r--r--engines/gnap/gnap.cpp20
-rw-r--r--engines/gnap/gnap.h1
-rw-r--r--engines/gnap/module.mk1
-rw-r--r--engines/gnap/scenes/scene00.cpp174
-rw-r--r--engines/gnap/scenes/scene01.cpp1
-rw-r--r--engines/gnap/scenes/scenecore.cpp4
6 files changed, 184 insertions, 17 deletions
diff --git a/engines/gnap/gnap.cpp b/engines/gnap/gnap.cpp
index 95376fdf2b..ce9e680ee3 100644
--- a/engines/gnap/gnap.cpp
+++ b/engines/gnap/gnap.cpp
@@ -700,14 +700,16 @@ void GnapEngine::initGameFlags(int num) {
}
//DEBUG!
+#if 0
// setFlag(0); // Enable platypus
setFlag(25);
invClear();
invAdd(kItemMagazine);
+#endif
#if 0
invAdd(kItemDisguise);
#endif
-#if 1
+#if 0
//invAdd(kItemGas);
invAdd(kItemJoint);
//invAdd(kItemKeys);
@@ -741,14 +743,14 @@ void GnapEngine::mainLoop() {
invClear();
clearFlags();
_grabCursorSpriteIndex = -1;
- _grabCursorSprite = 0;
+ _grabCursorSprite = nullptr;
debug("MainLoop #1");
// > DEBUG BEGIN
- _currentSceneNum = 53;
- _newSceneNum = 48;
- _newCursorValue = 3;
+ _currentSceneNum = 0;
+ _newSceneNum = 1;
+ _newCursorValue = 1;
// < DEBUG END
loadStockDat();
@@ -890,7 +892,7 @@ void GnapEngine::checkGameKeys() {
updatePause();
}
// TODO? Debug input
- debug("facing %d", _gnapIdleFacing);
+// debug("facing %d", _gnapIdleFacing);
}
void GnapEngine::startSoundTimerA(int timerIndex) {
@@ -2172,12 +2174,6 @@ void GnapEngine::playSequences(int fullScreenSpriteId, int sequenceId1, int sequ
_gnapSequenceId = sequenceId3;
}
-// Scene 0
-
-int GnapEngine::scene00_init() {
- return 0x37C;
-}
-
void GnapEngine::toyUfoSetStatus(int flagNum) {
clearFlag(16);
clearFlag(17);
diff --git a/engines/gnap/gnap.h b/engines/gnap/gnap.h
index b96d27d4a1..4948c29988 100644
--- a/engines/gnap/gnap.h
+++ b/engines/gnap/gnap.h
@@ -550,6 +550,7 @@ public:
// Scene 0
int scene00_init();
+ void scene00_run();
// Scene 1
int _s01_pigsIdCtr, _s01_smokeIdCtr;
diff --git a/engines/gnap/module.mk b/engines/gnap/module.mk
index 78e2cce736..7a3fc3a9a0 100644
--- a/engines/gnap/module.mk
+++ b/engines/gnap/module.mk
@@ -9,6 +9,7 @@ MODULE_OBJS := \
menu.o \
resource.o \
sound.o \
+ scenes/scene00.o \
scenes/scene01.o \
scenes/scene02.o \
scenes/scene03.o \
diff --git a/engines/gnap/scenes/scene00.cpp b/engines/gnap/scenes/scene00.cpp
new file mode 100644
index 0000000000..c53f58c99a
--- /dev/null
+++ b/engines/gnap/scenes/scene00.cpp
@@ -0,0 +1,174 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "video/avi_decoder.h"
+
+#include "gnap/gnap.h"
+#include "gnap/gamesys.h"
+#include "gnap/resource.h"
+
+namespace Gnap {
+
+int GnapEngine::scene00_init() {
+ return 0x37C;
+}
+
+void GnapEngine::scene00_run() {
+ const int animIdArr[] = {
+ 0x356, 0x357, 0x358, 0x35A, 0x35F,
+ 0x360, 0x361, 0x362, 0x363, 0x364,
+ 0x365, 0x368, 0x369, 0x36B, 0x378,
+ 0x36C, 0x36D, 0x36E, 0x36F, 0x370,
+ 0x371, 0x372, 0x373, 0x374, 0x375,
+ 0x376, 0x377, 0x378, 0x379, 0x37A,
+ 0x37B, 0};
+
+ const int backgroundIdArr[] = {
+ 0x354, 0x355, 0, 1, 3,
+ 4, 5, 6, 7, 8,
+ 7, 9, 0xA, 0xB, 0xC,
+ 0xD, 0xE, 0xF, 0x10, 0x11,
+ 0x12, 0x13, 0x17, 0x14, 0x19,
+ 0x1A, 0x14, 0x15, 0x16, 0x14,
+ 0x19, 0};
+
+ int index = 0;
+ bool skip = false;
+ hideCursor();
+ _dat->open(1, "musop_n.dat");
+
+ Video::VideoDecoder *videoDecoder = new Video::AVIDecoder();
+ if (!videoDecoder->loadFile("hoffman.avi")) {
+ delete videoDecoder;
+ warning("Unable to open video 'hoffman.avi' - Skipping intro");
+ return;
+ }
+ videoDecoder->start();
+
+ int vidPosX = (800 - videoDecoder->getWidth()) / 2;
+ int vidPosY = (600 - videoDecoder->getHeight()) / 2;
+ bool skipVideo = false;
+
+ screenEffect(1, 255, 255, 255);
+
+ while (!shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) {
+ if (videoDecoder->needsUpdate()) {
+ const Graphics::Surface *frame = videoDecoder->decodeNextFrame();
+ if (frame) {
+ if (frame->format.bytesPerPixel == 1) {
+ _system->copyRectToScreen(frame->getPixels(), frame->pitch, vidPosX, vidPosY, frame->w, frame->h);
+ } else if (frame->format.bytesPerPixel != 4) {
+ Graphics::Surface *frame1 = frame->convertTo(_system->getScreenFormat());
+ _system->copyRectToScreen(frame1->getPixels(), frame1->pitch, vidPosX, vidPosY, frame1->w, frame1->h);
+ frame1->free();
+ delete frame1;
+ } else {
+ // The intro AVI is played upside down, it's the only video played in the English version
+ for (uint16 y = 0; y < frame->h / 2; y++) {
+ uint32 *ptrFrom = (uint32*)frame->getBasePtr(0, y);
+ uint32 *ptrTo = (uint32*)frame->getBasePtr(0, frame->h - y - 1);
+ for (uint16 x = 0; x < frame->w; x++) {
+ uint32 t = *ptrFrom;
+ *ptrFrom = *ptrTo;
+ *ptrTo = t;
+ ptrFrom++;
+ ptrTo++;
+ }
+ }
+
+ Graphics::Surface *frame1 = frame->convertTo(_system->getScreenFormat());
+ _system->copyRectToScreen(frame1->getPixels(), frame1->pitch, vidPosX, vidPosY, frame1->w, frame1->h);
+ frame1->free();
+ delete frame1;
+ }
+ _system->updateScreen();
+ }
+ }
+
+ Common::Event event;
+ while (g_system->getEventManager()->pollEvent(event)) {
+ if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) ||
+ event.type == Common::EVENT_LBUTTONUP)
+ skipVideo = true;
+ }
+
+ _system->delayMillis(10);
+ }
+
+ delete videoDecoder;
+
+ _gameSys->drawSpriteToBackground(0, 0, backgroundIdArr[index]);
+ _gameSys->insertSequence(0x356, 2, 0, 0, kSeqNone, 0, 0, 0);
+ _gameSys->setAnimation(0x356, 2, 0);
+
+ while (!_sceneDone) {
+ gameUpdateTick();
+
+ if (_gameSys->getAnimationStatus(0) == 2 || skip ) {
+ skip = false;
+ _gameSys->requestClear2(false);
+ _gameSys->requestClear1();
+ if ( index == 11 || index == 1 )
+ screenEffect(0, 0, 0, 0);
+
+ _gameSys->setAnimation(0, 0, 0);
+ if (++index >= 31)
+ _sceneDone = true;
+ else {
+ _gameSys->insertSequence(animIdArr[index], 2, 0, 0, kSeqNone, 0, 0, 0);
+ if (index == 2) {
+ playSound(0x10000, 0);
+ _gameSys->insertSequence(0x359, 2, 0, 0, 0, 0, 0, 0);
+ } else if (index == 3)
+ _gameSys->insertSequence(0x35B, 2, 0, 0, kSeqNone, 0, 0, 0);
+ else if (index == 12)
+ _gameSys->insertSequence(0x36A, 2, 0, 0, kSeqNone, 0, 0, 0);
+
+ _gameSys->drawSpriteToBackground(0, 0, backgroundIdArr[index]);
+ _gameSys->setAnimation(animIdArr[index], 2, 0);
+
+ if (index == 11)
+ stopSound(0x10000);
+ }
+ }
+
+ if (isKeyStatus1(Common::KEYCODE_ESCAPE) || isKeyStatus1(Common::KEYCODE_SPACE) || isKeyStatus1(29)) {
+ clearKeyStatus1(Common::KEYCODE_ESCAPE);
+ clearKeyStatus1(Common::KEYCODE_SPACE);
+ clearKeyStatus1(29);
+ if (index == 0) {
+ skip = true;
+ stopSound(0x3CF);
+ } else if (index == 1)
+ skip = true;
+ else
+ _sceneDone = true;
+ }
+ }
+
+ stopSound(0x10000);
+
+ _newSceneNum = 1;
+ _newCursorValue = 1;
+}
+
+} // End of namespace Gnap
diff --git a/engines/gnap/scenes/scene01.cpp b/engines/gnap/scenes/scene01.cpp
index 0e90e0bd5a..1d4bfee7be 100644
--- a/engines/gnap/scenes/scene01.cpp
+++ b/engines/gnap/scenes/scene01.cpp
@@ -81,7 +81,6 @@ void GnapEngine::scene01_updateHotspots() {
}
void GnapEngine::scene01_run() {
-
// NOTE Removed _s01_dword_474380 which was set when the mud was taken
// which is also set in the global game flags.
diff --git a/engines/gnap/scenes/scenecore.cpp b/engines/gnap/scenes/scenecore.cpp
index 2736addb31..0825937fff 100644
--- a/engines/gnap/scenes/scenecore.cpp
+++ b/engines/gnap/scenes/scenecore.cpp
@@ -31,12 +31,10 @@ int GnapEngine::initSceneLogic() {
int backgroundId = -1;
switch (_currentSceneNum) {
-#if 0 // TODO
case 0:
backgroundId = scene00_init();
_gameSys->setScaleValues(0, 500, 1, 1000);
break;
-#endif
case 1:
backgroundId = scene01_init();
scene01_updateHotspots();
@@ -347,12 +345,10 @@ int GnapEngine::initSceneLogic() {
void GnapEngine::runSceneLogic() {
switch (_currentSceneNum) {
case 0:
-#if 0 // TODO
scene00_run();
if (_newSceneNum == 55)
_newSceneNum = 8;
break;
-#endif
case 1:
scene01_run();
if (_newSceneNum == 55)