aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/avalanche/graph.cpp24
-rw-r--r--engines/avalanche/graph.h7
-rw-r--r--engines/avalanche/lucerna2.cpp39
3 files changed, 17 insertions, 53 deletions
diff --git a/engines/avalanche/graph.cpp b/engines/avalanche/graph.cpp
index fac96fec01..84dde5ae95 100644
--- a/engines/avalanche/graph.cpp
+++ b/engines/avalanche/graph.cpp
@@ -70,10 +70,6 @@ byte *Graph::getPixel(int16 x, int16 y) {
return (byte *)_surface.getBasePtr(x, y);
}
-void Graph::setPixel(int16 x, int16 y, byte color) {
- *(byte *)_surface.getBasePtr(x, y) = color;
-}
-
void Graph::drawBar(int16 x1, int16 y1, int16 x2, int16 y2, int16 color) {
_surface.fillRect(Common::Rect(x1, y1, x2, y2), color);
}
@@ -85,9 +81,9 @@ void Graph::drawSprite(const SpriteInfo &sprite, byte picnum, int16 x, int16 y)
warning("STUB: Graph::drawSprite()");
}
-Graphics::Surface *Graph::readImage(const byte *source) {
- Graphics::Surface *picture = new Graphics::Surface;
-
+void Graph::copySurface(const byte *source, uint16 destX, uint16 destY) {
+ Graphics::Surface picture;
+
uint32 i = 0;
uint16 pictureWidth = (source[i++] + 1);
@@ -95,7 +91,7 @@ Graphics::Surface *Graph::readImage(const byte *source) {
uint16 pictureHeight = (source[i++] + 1);
pictureHeight += (source[i++] << 8);
- picture->create(pictureWidth, pictureHeight, Graphics::PixelFormat::createFormatCLUT8());
+ 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.
@@ -103,17 +99,13 @@ Graphics::Surface *Graph::readImage(const byte *source) {
byte pixel = source[i++];
for (byte i = 0; i < 8; i++) {
byte pixelBit = (pixel >> i) & 1;
- *(byte *)picture->getBasePtr(x + 7 - i, y) += (pixelBit << plane);
+ *(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++)
- *(byte *)_surface.getBasePtr(x + destX, y + destY) = *(byte *)source.getBasePtr(x, y);
+ for (uint16 y = 0; y < picture.h; y++)
+ for (uint16 x = 0; x < picture.w; x++)
+ *(byte *)_surface.getBasePtr(x + destX, y + destY) = *(byte *)picture.getBasePtr(x, y);
}
void Graph::refreshScreen() {
diff --git a/engines/avalanche/graph.h b/engines/avalanche/graph.h
index b825f177b5..80f79130bf 100644
--- a/engines/avalanche/graph.h
+++ b/engines/avalanche/graph.h
@@ -69,16 +69,11 @@ public:
byte *getPixel(int16 x, int16 y);
- void setPixel(int16 x, int16 y, byte color);
-
void drawBar(int16 x1, int16 y1, int16 x2, int16 y2, int16 color);
void drawSprite(const SpriteInfo &sprite, byte picnum, int16 x, int16 y);
- // Must free the returned pointer!!!
- Graphics::Surface *readImage(const byte *source);
-
- void copySurface(const Graphics::Surface &source, uint16 destX, uint16 destY);
+ void copySurface(const byte *source, uint16 destX, uint16 destY);
void refreshScreen();
diff --git a/engines/avalanche/lucerna2.cpp b/engines/avalanche/lucerna2.cpp
index 6f65927d36..d58ddfc566 100644
--- a/engines/avalanche/lucerna2.cpp
+++ b/engines/avalanche/lucerna2.cpp
@@ -261,7 +261,9 @@ void Lucerna::load(byte n) { /* Load2, actually */
}
}
- _vm->_graph.copySurface(background, 0, 10);
+ for (uint16 y = 0; y < backgroundHeight; y++)
+ for (uint16 x = 0; x < backgroundWidht; x++)
+ *_vm->_graph.getPixel(x + 0, y + 10) = *(byte *)background.getBasePtr(x, y);
background.free();
@@ -764,13 +766,7 @@ void Lucerna::thinkabout(byte z, bool th) { /* Hey!!! Get it and put it!!! *
f.read(buffer, picsize);
- Graphics::Surface *picture = _vm->_graph.readImage(buffer);
-
- _vm->_graph.copySurface(*picture, 205, 170);
-
- picture->free();
-
- delete picture;
+ _vm->_graph.copySurface(buffer, 205, 170);
delete[] buffer;
@@ -827,13 +823,7 @@ void Lucerna::toolbar() {
f.read(buffer, bufferSize);
- Graphics::Surface *toolbar = _vm->_graph.readImage(buffer);
-
- _vm->_graph.copySurface(*toolbar, 5, 169);
-
- toolbar->free();
-
- delete toolbar;
+ _vm->_graph.copySurface(buffer, 5, 169);
delete[] buffer;
@@ -868,15 +858,8 @@ void Lucerna::showscore() {
//setactivepage(3);
for (byte fv = 0; fv < 3; fv ++)
- if (_vm->_gyro.lastscore[fv] != numbers[fv]) {
- Graphics::Surface *digit = _vm->_graph.readImage(_vm->_gyro.digit[numbers[fv]]);
-
- _vm->_graph.copySurface(*digit, 250 + (fv + 1) * 15, 177);
-
- digit->free();
-
- delete digit;
- }
+ if (_vm->_gyro.lastscore[fv] != numbers[fv])
+ _vm->_graph.copySurface(_vm->_gyro.digit[numbers[fv]], 250 + (fv + 1) * 15, 177);
for (byte fv = 0; fv < 2; fv ++)
_vm->_trip.getset[fv].remember(scorespace);
@@ -1069,13 +1052,7 @@ void Lucerna::showrw() { // It's data is loaded in load_digits().
putimage(0, 161, rwlite[with.rw], 0);
}*/
- Graphics::Surface *rwlite = _vm->_graph.readImage(_vm->_gyro.rwlite[_vm->_gyro.dna.rw]);
-
- _vm->_graph.copySurface(*rwlite, 0, 161);
-
- rwlite->free();
-
- delete rwlite;
+ _vm->_graph.copySurface(_vm->_gyro.rwlite[_vm->_gyro.dna.rw], 0, 161);
_vm->_gyro.on();
//setactivepage(1 - cp);