aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/avalanche/graph.cpp21
-rw-r--r--engines/avalanche/graph.h5
-rw-r--r--engines/avalanche/lucerna2.cpp81
-rw-r--r--engines/avalanche/lucerna2.h2
4 files changed, 53 insertions, 56 deletions
diff --git a/engines/avalanche/graph.cpp b/engines/avalanche/graph.cpp
index 712e3a6990..2272fb6144 100644
--- a/engines/avalanche/graph.cpp
+++ b/engines/avalanche/graph.cpp
@@ -78,6 +78,27 @@ void Graph::drawBar(int16 x1, int16 y1, int16 x2, int16 y2, int16 color) {
_surface.fillRect(Common::Rect(x1, y1, x2, y2), color);
}
+Graphics::Surface *Graph::readImage(Common::File &f) {
+ Graphics::Surface *picture = new Graphics::Surface;
+
+ uint16 pictureWidth = f.readUint16LE() + 1;
+ uint16 pictureHeight = f.readUint16LE() + 1;
+
+ picture->create(pictureWidth, pictureHeight, Graphics::PixelFormat::createFormatCLUT8());
+
+ for (byte y = 0; y < pictureHeight; y++)
+ for (int8 plane = 3; plane >= 0; plane--) // The planes are in the opposite way.
+ for (uint16 x = 0; x < pictureWidth; x += 8) {
+ byte pixel = f.readByte();
+ for (byte i = 0; i < 8; i++) {
+ byte pixelBit = (pixel >> i) & 1;
+ *(byte *)picture->getBasePtr(x + 7 - i, y) += (pixelBit << plane);
+ }
+ }
+
+ return picture;
+}
+
void Graph::copySurface(const Graphics::Surface &source, uint16 destX, uint16 destY) {
for (uint16 y = 0; y < source.h; y++)
for (uint16 x = 0; x < source.w; x++)
diff --git a/engines/avalanche/graph.h b/engines/avalanche/graph.h
index 7c09071115..7d5f12f20f 100644
--- a/engines/avalanche/graph.h
+++ b/engines/avalanche/graph.h
@@ -30,6 +30,8 @@
#ifndef GRAPH_H
#define GRAPH_H
+#include "common/file.h"
+
#include "graphics/surface.h"
namespace Avalanche {
@@ -54,6 +56,9 @@ public:
void drawBar(int16 x1, int16 y1, int16 x2, int16 y2, int16 color);
+ // Must free the returened pointer!!!
+ Graphics::Surface *readImage(Common::File &f);
+
void copySurface(const Graphics::Surface &source, uint16 destX, uint16 destY);
void refreshScreen();
diff --git a/engines/avalanche/lucerna2.cpp b/engines/avalanche/lucerna2.cpp
index f665c54771..fb54376060 100644
--- a/engines/avalanche/lucerna2.cpp
+++ b/engines/avalanche/lucerna2.cpp
@@ -732,71 +732,56 @@ void Lucerna::enterroom(byte x, byte ped) {
}
-void Lucerna::thinkabout(char z, bool th) { /* Hey!!! Get it and put it!!! */
+void Lucerna::thinkabout(byte z, bool th) { /* Hey!!! Get it and put it!!! */
const int16 x = 205;
const int16 y = 170;
const int16 picsize = 966;
const bytefield thinkspace = {25, 170, 32, 200};
- byte *p;
- byte fv;
-
_vm->_gyro.thinks = z;
z--;
+ _vm->_gyro.wait();
+
if (th) {
- /* Things */
- _vm->_gyro.wait();
-
- p = new byte[picsize];
-
if (!f.open("thinks.avd")) {
warning("AVALANCHE: Lucerna: File not found: thinks.avd");
return;
}
-
- f.seek(z * picsize + 65);
-
- f.read(p, picsize);
-
- _vm->_gyro.off();
-
- f.close();
} else {
- /* People */
- _vm->_gyro.wait();
-
- p = new byte[picsize];
-
if (!f.open("folk.avd")) {
warning("AVALANCHE: Lucerna: File not found: folk.avd");
return;
}
- fv = z - 149;
- if (fv >= 25)
- fv -= 8;
- if (fv == 20)
- fv--; /* Last time... */
+ z = z - 149;
+ if (z >= 25)
+ z -= 8;
+ if (z == 20)
+ z--; /* Last time... */
- f.seek(fv * picsize + 65);
+ }
- f.read(p, picsize);
+ f.seek(z * picsize + 65);
- _vm->_gyro.off();
+ Graphics::Surface *picture = _vm->_graph.readImage(f);
- f.close();
- }
+ _vm->_graph.copySurface(*picture, x, y);
+
+ picture->free();
+
+ delete picture;
+
+ f.close();
+
+ _vm->_gyro.off();
/*setactivepage(3);
putimage(x, y, p, 0);
setactivepage(1 - cp);*/
- warning("STUB: Lucerna::thinkabout()");
- for (fv = 0; fv <= 1; fv ++)
+ for (byte fv = 0; fv <= 1; fv ++)
_vm->_trip.getset[fv].remember(thinkspace);
-
- delete[] p;
_vm->_gyro.on();
_vm->_gyro.thinkthing = th;
@@ -834,29 +819,15 @@ void Lucerna::toolbar() {
/* off;*/
- uint16 toolbarWidth = f.readUint16LE() + 1;
- uint16 toolbarHeight = f.readUint16LE() + 1;
+ Graphics::Surface *toolbar = _vm->_graph.readImage(f);
- Graphics::Surface toolbar;
- toolbar.create(toolbarWidth, toolbarHeight, Graphics::PixelFormat::createFormatCLUT8());
-
- for (byte y = 0; y < toolbarHeight; y++)
- for (int8 plane = 3; plane >= 0; plane--) // The planes are in the opposite way.
- for (uint16 x = 0; x < toolbarWidth; x += 8) {
- byte pixel = f.readByte();
- for (byte i = 0; i < 8; i++) {
- byte pixelBit = (pixel >> i) & 1;
- *(byte *)toolbar.getBasePtr(x + 7 - i, y) += (pixelBit << plane);
- }
- }
-
- _vm->_graph.copySurface(toolbar, 5, 169);
+ _vm->_graph.copySurface(*toolbar, 5, 169);
- toolbar.free();
+ toolbar->free();
- f.close();
+ delete toolbar;
- warning("STUB: Lucerna::toolbar()");
+ f.close();
/* on;*/
diff --git a/engines/avalanche/lucerna2.h b/engines/avalanche/lucerna2.h
index 94da2dba26..ca2384577d 100644
--- a/engines/avalanche/lucerna2.h
+++ b/engines/avalanche/lucerna2.h
@@ -58,7 +58,7 @@ public:
void enterroom(byte x, byte ped);
- void thinkabout(char z, bool th); /* Hey!!! Get it and put it!!! */
+ void thinkabout(byte z, bool th); /* Hey!!! Get it and put it!!! */
void load_digits(); /* Load the scoring digits & rwlites */