aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authoruruk2013-08-21 18:01:31 +0200
committeruruk2013-08-21 18:01:31 +0200
commitc43373f7ae714e5640452db026a0195b304c8ec1 (patch)
tree159768ace367bd32beb076bd2cace92657e1717b /engines
parent44f7802777df8b3dce2eaa25b66bfe0d0f094bdf (diff)
downloadscummvm-rg350-c43373f7ae714e5640452db026a0195b304c8ec1.tar.gz
scummvm-rg350-c43373f7ae714e5640452db026a0195b304c8ec1.tar.bz2
scummvm-rg350-c43373f7ae714e5640452db026a0195b304c8ec1.zip
AVALANCHE: Implement opening of doors. Rethink a bit the graphics and the timer system to do so.
Diffstat (limited to 'engines')
-rw-r--r--engines/avalanche/acci2.cpp47
-rw-r--r--engines/avalanche/avalot.cpp2
-rw-r--r--engines/avalanche/celer2.cpp3
-rw-r--r--engines/avalanche/graphics.cpp4
-rw-r--r--engines/avalanche/graphics.h6
-rw-r--r--engines/avalanche/gyro2.h1
-rw-r--r--engines/avalanche/lucerna2.cpp32
-rw-r--r--engines/avalanche/sequence2.cpp5
-rw-r--r--engines/avalanche/timeout2.cpp4
-rw-r--r--engines/avalanche/timeout2.h2
-rw-r--r--engines/avalanche/trip6.cpp16
11 files changed, 58 insertions, 64 deletions
diff --git a/engines/avalanche/acci2.cpp b/engines/avalanche/acci2.cpp
index 087dd27cf8..baecec9fa6 100644
--- a/engines/avalanche/acci2.cpp
+++ b/engines/avalanche/acci2.cpp
@@ -758,7 +758,7 @@ void Acci::opendoor() { /* so whaddya THINK this does?! */
switch (_vm->_gyro->dna.room) { /* Special cases. */
case r__yours:
- if (_vm->_trip->infield(2)) {
+ if (_vm->_trip->infield(1)) {
/* Opening the box. */
thing = 54; /* The box. */ person = pardon;
examine();
@@ -777,33 +777,32 @@ void Acci::opendoor() { /* so whaddya THINK this does?! */
if ((!_vm->_gyro->dna.user_moves_avvy) && (_vm->_gyro->dna.room != r__lusties))
return; /* No doors can open if you can't move Avvy. */
- for (fv = 9; fv <= 15; fv++) {
+ for (fv = 8; fv < 15; fv++)
if (_vm->_trip->infield(fv)) {
- {
- _vm->_gyro->portals[fv];
- switch (_vm->_gyro->portals[fv].op) {
- case _vm->_gyro->exclaim:
- _vm->_trip->tr[1].bounce();
- _vm->_visa->dixi('x', _vm->_gyro->portals[fv].data);
- break;
- case _vm->_gyro->transport:
- _vm->_trip->fliproom((_vm->_gyro->portals[fv].data) >> 8 /*High byte*/, (_vm->_gyro->portals[fv].data) & 0x0F /*Low byte*/);
- break;
- case _vm->_gyro->unfinished:
- _vm->_trip->tr[1].bounce();
- _vm->_scrolls->display("Sorry. This place is not available yet!");
- break;
- case _vm->_gyro->special:
- _vm->_trip->call_special(_vm->_gyro->portals[fv].data);
- break;
- case _vm->_gyro->mopendoor:
- _vm->_trip->open_the_door((_vm->_gyro->portals[fv].data) >> 8, (_vm->_gyro->portals[fv].data) & 0x0F, fv);
- break;
- }
+ fv -= 8;
+
+ switch (_vm->_gyro->portals[fv].op) {
+ case _vm->_gyro->exclaim:
+ _vm->_trip->tr[0].bounce();
+ _vm->_visa->dixi('x', _vm->_gyro->portals[fv].data);
+ break;
+ case _vm->_gyro->transport:
+ _vm->_trip->fliproom((_vm->_gyro->portals[fv].data) >> 8 /*High byte*/, (_vm->_gyro->portals[fv].data) & 0x0F /*Low byte*/);
+ break;
+ case _vm->_gyro->unfinished:
+ _vm->_trip->tr[0].bounce();
+ _vm->_scrolls->display("Sorry. This place is not available yet!");
+ break;
+ case _vm->_gyro->special:
+ _vm->_trip->call_special(_vm->_gyro->portals[fv].data);
+ break;
+ case _vm->_gyro->mopendoor:
+ _vm->_trip->open_the_door((_vm->_gyro->portals[fv].data) >> 8, (_vm->_gyro->portals[fv].data) & 0x0F, fv);
+ break;
}
+
return;
}
- }
if (_vm->_gyro->dna.room == r__map)
_vm->_scrolls->display(Common::String("Avvy, you can complete the whole game without ever going "
diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp
index cb73123d2e..6968932cfb 100644
--- a/engines/avalanche/avalot.cpp
+++ b/engines/avalanche/avalot.cpp
@@ -223,8 +223,8 @@ void Avalot::run(Common::String arg) {
_vm->_trip->readstick();
_vm->_gyro->force_numlock();
_vm->_trip->get_back_loretta();
- _vm->_trip->trippancy_link();
_vm->_celer->pics_link();
+ _vm->_trip->trippancy_link();
_vm->_lucerna->checkclick();
_vm->_timeout->one_tick();
diff --git a/engines/avalanche/celer2.cpp b/engines/avalanche/celer2.cpp
index 061eb6b212..3667ae1840 100644
--- a/engines/avalanche/celer2.cpp
+++ b/engines/avalanche/celer2.cpp
@@ -347,7 +347,8 @@ void Celer::display_it(int16 x, int16 y, int16 xl, int16 yl, flavourtype flavour
break;
}
- _vm->_graphics->drawPicture(picture, x * 8, y);
+ // These pictures are practically parts of the background. -10 is for the drop-down menu.
+ _vm->_graphics->drawPicture(_vm->_graphics->_background, picture, x * 8, y - 10);
}
void Celer::show_one(byte which) {
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp
index 9ae040818d..3821536835 100644
--- a/engines/avalanche/graphics.cpp
+++ b/engines/avalanche/graphics.cpp
@@ -309,11 +309,11 @@ void Graphics::drawText(::Graphics::Surface &surface, const Common::String &text
return picture;
}
-void Graphics::drawPicture(const ::Graphics::Surface &picture, uint16 destX, uint16 destY) {
+void Graphics::drawPicture(const ::Graphics::Surface &target, const ::Graphics::Surface &picture, uint16 destX, uint16 destY) {
// Copy the picture to the given place on the screen.
for (uint16 y = 0; y < picture.h; y++)
for (uint16 x = 0; x < picture.w; x++)
- *getPixel(x + destX, y + destY) = *(byte *)picture.getBasePtr(x, y);
+ *(byte *)target.getBasePtr(x + destX, y + destY) = *(byte *)picture.getBasePtr(x, y);
}
void Graphics::refreshScreen() {
diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h
index 7492141c43..e8cf02a12d 100644
--- a/engines/avalanche/graphics.h
+++ b/engines/avalanche/graphics.h
@@ -60,6 +60,10 @@ public:
static const int16 kScreenWidth = 640;
static const int16 kScreenHeight = 200;
+ static const uint16 kBackgroundWidth = kScreenWidth;
+ static const byte kBackgroundHeight = 8 * 12080 / kScreenWidth; // With 640 width it's 151
+ // The 8 = number of bits in a byte, and 12080 comes from Lucerna::load().
+
::Graphics::Surface _surface;
::Graphics::Surface _background;
@@ -111,7 +115,7 @@ public:
::Graphics::Surface loadPictureRow(Common::File &file, uint16 width, uint16 height); // Reads Row-planar EGA data.
// Further information about these two: http://www.shikadi.net/moddingwiki/Raw_EGA_data
- void drawPicture(const ::Graphics::Surface &picture, uint16 destX, uint16 destY); // Can't call .free() here. See Lucerna::showscore() for example.
+ void drawPicture(const ::Graphics::Surface &target, const ::Graphics::Surface &picture, uint16 destX, uint16 destY); // Can't call .free() here. See Lucerna::showscore() for example.
void refreshScreen();
diff --git a/engines/avalanche/gyro2.h b/engines/avalanche/gyro2.h
index 547b324af0..09f5a92caf 100644
--- a/engines/avalanche/gyro2.h
+++ b/engines/avalanche/gyro2.h
@@ -479,6 +479,7 @@ public:
/* previous:^previoustype;*/
dnatype dna;
+ byte lineNum; // Number of lines.
linetype lines[50]; /* For Also. */
int16 c;
//registers r; // http://www.freepascal.org/docs-html/rtl/dos/registers.html
diff --git a/engines/avalanche/lucerna2.cpp b/engines/avalanche/lucerna2.cpp
index 3fcb1acf77..18e5858729 100644
--- a/engines/avalanche/lucerna2.cpp
+++ b/engines/avalanche/lucerna2.cpp
@@ -88,13 +88,11 @@ void Lucerna::draw_also_lines() {
CursorMan.showMouse(false);
_vm->_graphics->_magics.fillRect(Common::Rect(0, 0, 640, 200), 0);
- _vm->_graphics->_magics.frameRect(Common::Rect(0, 45, 639, 161), 15);
-
- for (ff = 0; ff < 50; ff++)
- if (_vm->_gyro->lines[ff].x1 != 32767 /*maxint*/)
- _vm->_graphics->_magics.drawLine(_vm->_gyro->lines[ff].x1, _vm->_gyro->lines[ff].y1, _vm->_gyro->lines[ff].x2, _vm->_gyro->lines[ff].y2, _vm->_gyro->lines[ff].col);
-
+ _vm->_graphics->_magics.frameRect(Common::Rect(0, 45, 640, 161), 15);
+ for (ff = 0; ff < _vm->_gyro->lineNum; ff++)
+ _vm->_graphics->_magics.drawLine(_vm->_gyro->lines[ff].x1, _vm->_gyro->lines[ff].y1, _vm->_gyro->lines[ff].x2, _vm->_gyro->lines[ff].y2, _vm->_gyro->lines[ff].col);
+
CursorMan.showMouse(true);
}
@@ -155,8 +153,8 @@ void Lucerna::load_also(Common::String n) {
memset(_vm->_gyro->lines, 0xFF, sizeof(_vm->_gyro->lines));
//fv = getpixel(0, 0);
- fv = f.readByte();
- for (byte i = 0; i < fv; i++) {
+ _vm->_gyro->lineNum = f.readByte();
+ for (byte i = 0; i < _vm->_gyro->lineNum; i++) {
_vm->_gyro->lines[i].x1 = f.readSint16LE();
_vm->_gyro->lines[i].y1 = f.readSint16LE();
_vm->_gyro->lines[i].x2 = f.readSint16LE();
@@ -171,7 +169,7 @@ void Lucerna::load_also(Common::String n) {
_vm->_gyro->peds[i].y = f.readSint16LE();
_vm->_gyro->peds[i].dir = f.readByte();
}
-
+
_vm->_gyro->numfields = f.readByte();
for (byte i = 0; i < _vm->_gyro->numfields; i++) {
_vm->_gyro->fields[i].x1 = f.readSint16LE();
@@ -251,13 +249,9 @@ void Lucerna::load(byte n) { /* Load2, actually */
- uint16 backgroundWidht = _vm->_graphics->kScreenWidth;
- byte backgroundHeight = 8 * 12080 / _vm->_graphics->kScreenWidth; // With 640 width it's 151
- // The 8 = number of bits in a byte, and 12080 comes from the original code (see above)
-
- _vm->_graphics->_background = _vm->_graphics->loadPictureRow(f, backgroundWidht, backgroundHeight);
+ _vm->_graphics->_background = _vm->_graphics->loadPictureRow(f, _vm->_graphics->kBackgroundWidth, _vm->_graphics->kBackgroundHeight);
- _vm->_graphics->drawPicture(_vm->_graphics->_background, 0, 10);
+ _vm->_graphics->drawPicture(_vm->_graphics->_surface, _vm->_graphics->_background, 0, 10);
f.close();
@@ -756,7 +750,7 @@ void Lucerna::thinkabout(byte z, bool th) { /* Hey!!! Get it and put it!!! *
::Graphics::Surface picture = _vm->_graphics->loadPictureGraphic(f);
- _vm->_graphics->drawPicture(picture, 205, 170);
+ _vm->_graphics->drawPicture(_vm->_graphics->_surface, picture, 205, 170);
picture.free();
@@ -813,7 +807,7 @@ void Lucerna::toolbar() {
::Graphics::Surface picture = _vm->_graphics->loadPictureGraphic(f);
- _vm->_graphics->drawPicture(picture, 5, 169);
+ _vm->_graphics->drawPicture(_vm->_graphics->_surface, picture, 5, 169);
picture.free();
@@ -849,7 +843,7 @@ void Lucerna::showscore() {
for (byte fv = 0; fv < 3; fv ++)
if (_vm->_gyro->lastscore[fv] != numbers[fv])
- _vm->_graphics->drawPicture(_vm->_gyro->digit[numbers[fv]], 250 + (fv + 1) * 15, 177);
+ _vm->_graphics->drawPicture(_vm->_graphics->_surface, _vm->_gyro->digit[numbers[fv]], 250 + (fv + 1) * 15, 177);
for (byte fv = 0; fv < 2; fv ++)
_vm->_trip->getset[fv].remember(scorespace);
@@ -1144,7 +1138,7 @@ void Lucerna::showrw() { // It's data is loaded in load_digits().
putimage(0, 161, rwlite[with.rw], 0);
}*/
- _vm->_graphics->drawPicture(_vm->_gyro->rwlite[_vm->_gyro->dna.rw], 0, 161);
+ _vm->_graphics->drawPicture(_vm->_graphics->_surface, _vm->_gyro->rwlite[_vm->_gyro->dna.rw], 0, 161);
CursorMan.showMouse(true);
//setactivepage(1 - cp);
diff --git a/engines/avalanche/sequence2.cpp b/engines/avalanche/sequence2.cpp
index bdc809e5ca..fcca72432f 100644
--- a/engines/avalanche/sequence2.cpp
+++ b/engines/avalanche/sequence2.cpp
@@ -54,8 +54,7 @@ void Sequence::first_show(byte what) {
}
void Sequence::then_show(byte what) {
- byte fv;
- for (fv = 1; fv <= seq_length; fv++) {
+ for (byte fv = 0; fv < seq_length; fv++) {
if (seq[fv] == 0) {
seq[fv] = what;
return;
@@ -103,7 +102,7 @@ void Sequence::call_sequencer() {
if ((seq[0] >= 1) && (seq[0] <= 176)) {
/* Show a frame. */
- _vm->_celer->show_one(seq[1]);
+ _vm->_celer->show_one(seq[0] - 1);
shove_left();
}
diff --git a/engines/avalanche/timeout2.cpp b/engines/avalanche/timeout2.cpp
index dba78870e9..ece531718d 100644
--- a/engines/avalanche/timeout2.cpp
+++ b/engines/avalanche/timeout2.cpp
@@ -57,7 +57,7 @@ Timeout::Timeout(AvalancheEngine *vm) {
}
void Timeout::set_up_timer(int32 howlong, byte whither, byte why) {
- if (_vm->_gyro->isLoaded == false) {
+ if ((_vm->_gyro->isLoaded == false) || (timerLost == true)) {
byte i = 0;
while ((i < 7) && (times[i].time_left != 0))
i++;
@@ -221,6 +221,8 @@ void Timeout::lose_timer(byte which) {
if (times[fv].what_for == which)
times[fv].time_left = 0; // Cancel this one!
}
+
+ timerLost = true;
}
/*function timer_is_on(which:byte):boolean;
diff --git a/engines/avalanche/timeout2.h b/engines/avalanche/timeout2.h
index d315d5964a..80f0677786 100644
--- a/engines/avalanche/timeout2.h
+++ b/engines/avalanche/timeout2.h
@@ -162,6 +162,8 @@ public:
timetype times[7];
+ bool timerLost; // Is the timer "lost"?
+
Timeout(AvalancheEngine *vm);
diff --git a/engines/avalanche/trip6.cpp b/engines/avalanche/trip6.cpp
index 0009477738..637c510399 100644
--- a/engines/avalanche/trip6.cpp
+++ b/engines/avalanche/trip6.cpp
@@ -1392,16 +1392,8 @@ void Trip::call_andexors() {
}
} while (!ok);
- // We redraw the background only if we have at least one moving character.
- bool drawBG = false;
- for (fv = 0; fv < 5; fv++) {
- if (order[fv] > -1) {
- drawBG = true;
- break;
- }
- }
- if (drawBG)
- _vm->_graphics->drawPicture(_vm->_graphics->_background, 0, 10);
+
+ _vm->_graphics->drawPicture(_vm->_graphics->_surface, _vm->_graphics->_background, 0, 10);
for (fv = 0; fv < 5; fv++) {
if (order[fv] > -1)
@@ -1646,9 +1638,9 @@ void Trip::fliproom(byte room, byte ped) {
bool Trip::infield(byte which) {
/* returns True if you're within field "which" */
- int16 yy = tr[1].y + tr[1]._info.yl;
+ int16 yy = tr[0].y + tr[0]._info.yl;
- return (tr[1].x >= _vm->_gyro->fields[which].x1) && (tr[1].x <= _vm->_gyro->fields[which].x2)
+ return (tr[0].x >= _vm->_gyro->fields[which].x1) && (tr[0].x <= _vm->_gyro->fields[which].x2)
&& (yy >= _vm->_gyro->fields[which].y1) && (yy <= _vm->_gyro->fields[which].y2);
}