aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2004-01-26 22:44:47 +0000
committerEugene Sandulenko2004-01-26 22:44:47 +0000
commit498e0f4d6f088a77ad450ed782befc4a799cdf24 (patch)
tree0e37cbe6e8e3a446d55a63f9e134a19e8c88d84d
parent74901527146fef1de6f26f5e28152cf0f2c59917 (diff)
downloadscummvm-rg350-498e0f4d6f088a77ad450ed782befc4a799cdf24.tar.gz
scummvm-rg350-498e0f4d6f088a77ad450ed782befc4a799cdf24.tar.bz2
scummvm-rg350-498e0f4d6f088a77ad450ed782befc4a799cdf24.zip
o Implemented TRS handling
o Now you can succesfully reach the cave so FT is completable, but it crashes now in some particularly situations, so you should avoid them. svn-id: r12630
-rw-r--r--scumm/insane/insane.cpp94
-rw-r--r--scumm/insane/insane.h6
-rw-r--r--scumm/insane/insane_iact.cpp4
-rw-r--r--scumm/insane/insane_scenes.cpp19
-rw-r--r--scumm/smush/smush_player.cpp16
-rw-r--r--scumm/smush/smush_player.h7
6 files changed, 97 insertions, 49 deletions
diff --git a/scumm/insane/insane.cpp b/scumm/insane/insane.cpp
index fe10f9cb51..28c114c510 100644
--- a/scumm/insane/insane.cpp
+++ b/scumm/insane/insane.cpp
@@ -32,6 +32,7 @@
#include "scumm/imuse_digi/dimuse.h"
#include "scumm/smush/smush_player.h"
+#include "scumm/smush/smush_font.h"
#include "scumm/smush/chunk_type.h"
#include "scumm/smush/chunk.h"
@@ -39,7 +40,13 @@
// TODO (in no particular order):
// o Ben's velocity don't get zeroed after crash
-// o TRS file support. Everything is in place, I just need to figure out function parameters
+// o Mine road used to have correct behaviour with ESC but now is not.
+// Instead of skipping portions of road it just restarts
+// o Road signs are not aligned properly
+// o With goggles on there is a seek error
+// o SAUD complaining again
+// o Insane::postCase16() has workaround. Cockpit is not transparent so it is
+// disabled now
// o Code review/cleanup
// o DOS demo INSANE
@@ -76,9 +83,6 @@ Insane::Insane(ScummEngine_v6 *scumm) {
_smush_bensgoggNut->loadFont("bensgogg.nut", _vm->getGameDataPath());
_smush_bencutNut = new NutRenderer(_vm);
_smush_bencutNut->loadFont("bencut.nut", _vm->getGameDataPath());
-
- // FIXME: implement
- // openManyResource(0, 4, "specfnt.nut", "titlfnt.nut", "techfnt.nut", "scummfnt.nut");
}
Insane::~Insane(void) {
@@ -691,14 +695,6 @@ void Insane::readState(void) {
_enemy[EN_VULTF2].field_10 = readArray(339);
}
-void Insane::setTrsFile(int file) {
- // FIXME: we don't need it
-}
-
-void Insane::resetTrsFilePtr(void) {
- // FIXME: we don't need it
-}
-
void Insane::setupValues(void) {
_actor[0].x = 160;
_actor[0].y = 200;
@@ -844,7 +840,7 @@ void Insane::prepareScenePropScene(int32 scenePropNum, bool arg_4, bool arg_8) {
_sceneProp[idx + 1].counter = 0;
_currScenePropSubIdx = 1;
if (_sceneProp[idx + 1].trsId)
- _currTrsMsg = handleTrsTag(_trsFilePtr, _sceneProp[idx + 1].trsId);
+ _currTrsMsg = handleTrsTag(_sceneProp[idx + 1].trsId);
else
_currTrsMsg = 0;
@@ -1265,11 +1261,61 @@ void Insane::smlayer_overrideDrawActorAt(byte *arg_0, byte arg_4, byte arg_8) {
}
void Insane::smlayer_showStatusMsg(int32 arg_0, byte *renderBitmap, int32 codecparam,
- int32 x, int32 y, int32 arg_14, int32 arg_18,
- int32 arg_1C, const char *formatString, char *str) {
- // FIXME: implement
- // SmushPlayer::handleTextResource does the thing
- warning("stub Insane::smlayer_showStatusMsg(...)");
+ int32 pos_x, int32 pos_y, int32 arg_14, int32 arg_18,
+ int32 flags, const char *formatString, char *strng) {
+ SmushFont *sf = _player->_sf[0];
+ int color = 1, top = 0;
+ char *str = NULL, *string;
+ int len = strlen(formatString) + strlen(strng) + 16;
+
+ string = (char *)malloc(len);
+ str = string;
+
+ while (*strng == '/') {
+ strng++; // For text resources
+ }
+
+ snprintf(str, len, formatString, strng);
+
+ while (str[0] == '^') {
+ switch (str[1]) {
+ case 'f':
+ {
+ int id = str[3] - '0';
+ str += 4;
+ sf = _player->_sf[id];
+ }
+ break;
+ case 'c':
+ {
+ color = str[4] - '0' + 10 *(str[3] - '0');
+ str += 5;
+ }
+ break;
+ default:
+ error("invalid escape code in text string");
+ }
+ }
+
+ assert(sf != NULL);
+ sf->setColor(color);
+
+ // flags:
+ // bit 0 - center 1
+ // bit 1 - not used 2
+ // bit 2 - ??? 4
+ // bit 3 - wrap around 8
+ switch (flags & 9) {
+ case 0:
+ sf->drawStringAbsolute(str, renderBitmap, _player->_width, pos_x, pos_y);
+ break;
+ case 1:
+ sf->drawStringCentered(str, renderBitmap, _player->_width, _player->_height, pos_x, MAX(pos_y, top));
+ break;
+ default:
+ warning("Insane::smlayer_showStatusMsg. Not handled flags: %d", flags);
+ }
+ free (string);
}
void Insane::procSKIP(Chunk &b) {
@@ -1320,11 +1366,8 @@ void Insane::smlayer_setActorFacing(int actornum, int actnum, int frame, int dir
}
}
-char *Insane::handleTrsTag(int32 trsFilePtr, int32 trsId) {
- // FIXME: implement
- warning("stub Insane::handleTrsTag(0, %d)", trsId);
-
- return 0;
+char *Insane::handleTrsTag(int32 trsId) {
+ return _player->getString(trsId);;
}
bool Insane::smush_eitherNotStartNewFrame(void) {
@@ -1361,11 +1404,6 @@ bool Insane::smlayer_actorNeedRedraw(int actornum, int actnum) {
return a->needRedraw;
}
-void Insane::smush_setPaletteValue(int where, int r, int g, int b) {
- // FIXME: implement
- warning("stub Insane::smlayer_setPaletteValue(%d, %d, %d, %d)", where, r, g, b);
-}
-
int32 Insane::readArray (int item) {
return _vm->readArray(_numberArray, 0, item);
}
diff --git a/scumm/insane/insane.h b/scumm/insane/insane.h
index c5f075d1b1..e96c2883a0 100644
--- a/scumm/insane/insane.h
+++ b/scumm/insane/insane.h
@@ -122,7 +122,6 @@ class Insane {
bool _kickEnemyProgress;
bool _weaponEnemyJustSwitched;
int32 _enHdlVar[9][9];
- int32 _trsFilePtr; // FIXME: we don't need it
int32 _smlayer_room;
int32 _smlayer_room2;
byte *_smush_roadrashRip; // FIXME: combine them in array
@@ -278,8 +277,6 @@ class Insane {
void smush_warpMouse(int x, int y, int buttons);
void putActors(void);
void readState(void);
- void setTrsFile(int file); // FIXME: we don't need it
- void resetTrsFilePtr(void); // FIXME: we don't need it
int initScene(int sceneId);
void stopSceneSounds(int sceneId);
void shutCurrentScene(void);
@@ -422,8 +419,7 @@ class Insane {
int32 setBenState(void);
bool smlayer_actorNeedRedraw(int actornum, int actnum);
void reinitActors(void);
- void smush_setPaletteValue(int where, int r, int g, int b);
- char *handleTrsTag(int32 trsFilePtr, int32 trsId);
+ char *handleTrsTag(int32 trsId);
void ouchSoundBen(void);
void smush_setupSanWithFlu(const char *filename, int32 setupsan2, int32 step1,
int32 step2, int32 setupsan1, byte *fluPtr, int32 numFrames);
diff --git a/scumm/insane/insane_iact.cpp b/scumm/insane/insane_iact.cpp
index 99d5c4679b..34469ea836 100644
--- a/scumm/insane/insane_iact.cpp
+++ b/scumm/insane/insane_iact.cpp
@@ -578,7 +578,7 @@ void Insane::iactScene17(byte *renderBitmap, int32 codecparam, int32 setupsan12,
smlayer_startSfx(94);
smlayer_showStatusMsg(-1, renderBitmap, codecparam, 24, 167, 1,
- 2, 0, "%s", handleTrsTag(_trsFilePtr, 5000));
+ 2, 0, "%s", handleTrsTag(5000));
}
_val124_ = true;
break;
@@ -590,7 +590,7 @@ void Insane::iactScene17(byte *renderBitmap, int32 codecparam, int32 setupsan12,
smlayer_startSfx(94);
smlayer_showStatusMsg(-1, renderBitmap, codecparam, 24, 167, 1,
- 2, 0, "%s", handleTrsTag(_trsFilePtr, 5001));
+ 2, 0, "%s", handleTrsTag(5001));
}
_val124_ = true;
_val123_ = true;
diff --git a/scumm/insane/insane_scenes.cpp b/scumm/insane/insane_scenes.cpp
index 7a6c101b39..fce17465ad 100644
--- a/scumm/insane/insane_scenes.cpp
+++ b/scumm/insane/insane_scenes.cpp
@@ -34,11 +34,6 @@
namespace Scumm {
void Insane::runScene(int arraynum) {
- // procPtr5 = &procPtr5Body;
- // procPtr6 = &procPtr6Body;
- // procIact = &handleIact;
- // ptrMainLoop = &ptrMainLoopBody;
-
_insaneIsRunning = true;
_player = new SmushPlayer(_vm, _speed);
_player->insanity(true);
@@ -60,7 +55,6 @@ void Insane::runScene(int arraynum) {
smush_warpMouse(160, 100, -1);
putActors();
readState();
- setTrsFile(_trsFilePtr); // FIXME: we don't need it
debug(0, "INSANE Arg: %d", readArray(0));
@@ -137,7 +131,6 @@ void Insane::runScene(int arraynum) {
break;
}
- resetTrsFilePtr(); // FIXME: we don't need it
smush_proc39();
putActors();
smush_proc40();
@@ -1058,8 +1051,9 @@ void Insane::postCase16(byte *renderBitmap, int32 codecparam, int32 setupsan12,
sprintf(buf, "^f01%02o", curFrame & 0xff);
smlayer_showStatusMsg(-1, renderBitmap, codecparam, 140, 168, 1, 2, 0, "%s", buf);
smlayer_showStatusMsg(-1, renderBitmap, codecparam, 170, 43, 1, 2, 0, "%s", buf);
-
- smlayer_drawSomething(renderBitmap, codecparam, 0, 0, 1, _smush_bensgoggNut, 0, 0, 0);
+
+ // FIXME: it should be transparent
+ //smlayer_drawSomething(renderBitmap, codecparam, 0, 0, 1, _smush_bensgoggNut, 0, 0, 0);
if (!_val124_)
smlayer_drawSomething(renderBitmap, codecparam, 24, 170, 1,
@@ -1440,8 +1434,9 @@ void Insane::postCaseAll(byte *renderBitmap, int32 codecparam, int32 setupsan12,
if (!_actor[tsceneProp->actor].runningSound || ConfMan.getBool("subtitles")) {
if (_actor[tsceneProp->actor].act[3].state == 72 &&
_currTrsMsg) {
- smush_setPaletteValue(1, tsceneProp->r, tsceneProp->g, tsceneProp->b);
- smush_setPaletteValue(2, 0, 0, 0);
+ _player->setPaletteValue(0, tsceneProp->r, tsceneProp->g, tsceneProp->b);
+ _player->setPaletteValue(1, tsceneProp->r, tsceneProp->g, tsceneProp->b);
+ _player->setPaletteValue(0, 0, 0, 0);
smlayer_showStatusMsg(-1, renderBitmap, codecparam, 160, 20, 1, 2, 5,
"^f00%s", _currTrsMsg);
}
@@ -1452,7 +1447,7 @@ void Insane::postCaseAll(byte *renderBitmap, int32 codecparam, int32 setupsan12,
tsceneProp = &_sceneProp[_currScenePropIdx + _currScenePropSubIdx];
tsceneProp->counter = 0;
if (tsceneProp->trsId)
- _currTrsMsg = handleTrsTag(_trsFilePtr, tsceneProp->trsId);
+ _currTrsMsg = handleTrsTag(tsceneProp->trsId);
else
_currTrsMsg = 0;
diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp
index 74f7ad6d43..fa9dd24a15 100644
--- a/scumm/smush/smush_player.cpp
+++ b/scumm/smush/smush_player.cpp
@@ -589,6 +589,10 @@ void SmushPlayer::handleTextResource(Chunk &b) {
}
}
+const char *SmushPlayer::getString(int id) {
+ return _strings->get(id);
+}
+
bool SmushPlayer::readString(const char *file, const char *directory) {
const char *i = strrchr(file, '.');
if (i == NULL) {
@@ -822,9 +826,13 @@ void SmushPlayer::setupAnim(const char *file, const char *directory) {
if (_vm->_gameId == GID_FT) {
if (!(_vm->_features & GF_DEMO)) {
_sf[0] = new SmushFont(true, false);
+ _sf[1] = new SmushFont(true, false);
_sf[2] = new SmushFont(true, false);
+ _sf[3] = new SmushFont(true, false);
_sf[0]->loadFont("scummfnt.nut", directory);
+ _sf[1]->loadFont("techfnt.nut", directory);
_sf[2]->loadFont("titlfnt.nut", directory);
+ _sf[3]->loadFont("specfnt.nut", directory);
}
} else if (_vm->_gameId == GID_DIG) {
if (!(_vm->_features & GF_DEMO)) {
@@ -884,6 +892,14 @@ void SmushPlayer::setPalette(const byte *palette) {
_vm->_system->set_palette(palette_colors, 0, 256);
}
+void SmushPlayer::setPaletteValue(int n, byte r, byte g, byte b) {
+ _pal[n * 3 + 0] = r;
+ _pal[n * 3 + 1] = g;
+ _pal[n * 3 + 2] = b;
+
+ _vm->_system->set_palette(_pal, n, 1);
+}
+
void SmushPlayer::updateScreen() {
#ifdef DUMP_SMUSH_FRAMES
char fileName[100];
diff --git a/scumm/smush/smush_player.h b/scumm/smush/smush_player.h
index dcc592c84a..e3048c80d8 100644
--- a/scumm/smush/smush_player.h
+++ b/scumm/smush/smush_player.h
@@ -45,7 +45,6 @@ private:
int16 _deltaPal[0x300];
byte _pal[0x300];
StringResource *_strings;
- SmushFont *_sf[5];
Codec37Decoder _codec37;
Codec47Decoder _codec47;
FileChunk *_base;
@@ -65,7 +64,6 @@ private:
int _speed;
bool _outputSound;
- int _width, _height;
byte *_dst;
bool _updateNeeded;
bool _insanity;
@@ -78,9 +76,14 @@ public:
void play(const char *filename, const char *directory);
protected:
+ SmushFont *_sf[5];
+ int _width, _height;
+
void insanity(bool);
void setPalette(const byte *palette);
+ void setPaletteValue(int n, byte r, byte g, byte b);
void seekSan(const char *file, const char *directory, int32 pos, int32 contFrame);
+ const char *getString(int id);
private:
void updatePalette(void);