aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authoruruk2013-07-26 13:32:08 +0200
committeruruk2013-07-26 13:32:08 +0200
commit6e8dec45dd946b365d095029072f09fa1ed4c675 (patch)
treef987fbca61b8c3f4534c5166ad14b9bb7079e5f9 /engines
parentb0d4019ceabd1180f41447c2b232c5328f181c4e (diff)
downloadscummvm-rg350-6e8dec45dd946b365d095029072f09fa1ed4c675.tar.gz
scummvm-rg350-6e8dec45dd946b365d095029072f09fa1ed4c675.tar.bz2
scummvm-rg350-6e8dec45dd946b365d095029072f09fa1ed4c675.zip
AVALANCHE: Add loadPictureGraphic, loadPictureRow, revise drawPicture in Graphics, update almost everything accordingly.
Diffstat (limited to 'engines')
-rw-r--r--engines/avalanche/celer2.cpp19
-rw-r--r--engines/avalanche/graphics.cpp52
-rw-r--r--engines/avalanche/graphics.h11
-rw-r--r--engines/avalanche/gyro2.cpp8
-rw-r--r--engines/avalanche/gyro2.h9
-rw-r--r--engines/avalanche/lucerna2.cpp52
6 files changed, 101 insertions, 50 deletions
diff --git a/engines/avalanche/celer2.cpp b/engines/avalanche/celer2.cpp
index 5fc029e9aa..52b57b3725 100644
--- a/engines/avalanche/celer2.cpp
+++ b/engines/avalanche/celer2.cpp
@@ -326,12 +326,13 @@ void Celer::forget_chunks() {
}
void Celer::display_it(int16 x, int16 y, int16 xl, int16 yl, flavourtype flavour, byte *p) {
+ r.x1 = x;
+ r.y1 = y;
+ r.y2 = y + yl;
+
switch (flavour) {
case ch_natural_image: {
- r.x1 = x;
- r.y1 = y;
r.x2 = x + xl + 1;
- r.y2 = y + yl;
x *= 8;
xl *= 8;
@@ -342,19 +343,15 @@ void Celer::display_it(int16 x, int16 y, int16 xl, int16 yl, flavourtype flavour
}
break;
case ch_bgi : {
- _vm->_graphics->drawPicture(p, x * 8, y);
- //putimage(x * 8, y, p, 0);
- r.x1 = x;
- r.y1 = y;
r.x2 = x + xl + 1;
- r.y2 = y + yl;
+
+ _vm->_graphics->drawPicture_old(p, x * 8, y);
+ //putimage(x * 8, y, p, 0);
}
break;
case ch_ega : {
- r.x1 = x;
- r.y1 = y;
r.x2 = x + xl;
- r.y2 = y + yl;
+
x *= 8;
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp
index eb93423f98..0fcfdac023 100644
--- a/engines/avalanche/graphics.cpp
+++ b/engines/avalanche/graphics.cpp
@@ -116,7 +116,55 @@ void Graphics::drawSprite(const SpriteInfo &sprite, byte picnum, int16 x, int16
}
}
-void Graphics::drawPicture(const byte *source, uint16 destX, uint16 destY) {
+::Graphics::Surface Graphics::loadPictureGraphic(Common::File &file) {
+ // The height and the width are stored in 2-2 bytes. We have to add 1 to each because Pascal stores the value of them -1.
+ uint16 pictureWidth = file.readUint16LE() + 1;
+ uint16 pictureHeight = file.readUint16LE() + 1;
+
+ ::Graphics::Surface picture; // We make a Surface object for the picture itself.
+
+ picture.create(pictureWidth, pictureHeight, ::Graphics::PixelFormat::createFormatCLUT8());
+
+ // Produce the picture.
+ 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 = file.readByte();
+ for (byte bit = 0; bit < 8; bit++) {
+ byte pixelBit = (pixel >> bit) & 1;
+ *(byte *)picture.getBasePtr(x + 7 - bit, y) += (pixelBit << plane);
+ }
+ }
+
+ return picture;
+}
+
+::Graphics::Surface Graphics::loadPictureRow(Common::File &file, uint16 width, uint16 height) {
+ ::Graphics::Surface picture;
+
+ picture.create(width, height, ::Graphics::PixelFormat::createFormatCLUT8());
+
+ for (byte plane = 0; plane < 4; plane++)
+ for (uint16 y = 0; y < height; y++)
+ for (uint16 x = 0; x < width; x += 8) {
+ byte pixel = file.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 Graphics::drawPicture(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);
+}
+
+void Graphics::drawPicture_old(const byte *source, uint16 destX, uint16 destY) {
// The height and the width are stored in 2-2 bytes. We have to add 1 to each because Pascal stores the value of them -1.
uint16 pictureWidth = READ_LE_UINT16(source) + 1;
uint16 pictureHeight = READ_LE_UINT16(source + 2) + 1;
@@ -141,7 +189,7 @@ void Graphics::drawPicture(const byte *source, uint16 destX, uint16 destY) {
// Copy the picture to a given place on the screen.
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);
+ *getPixel(x + destX, y + destY) = *(byte *)picture.getBasePtr(x, y);
picture.free();
}
diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h
index 14eb3fa5c4..dfd06a4ad0 100644
--- a/engines/avalanche/graphics.h
+++ b/engines/avalanche/graphics.h
@@ -77,7 +77,16 @@ public:
void drawSprite(const SpriteInfo &sprite, byte picnum, int16 x, int16 y);
- void drawPicture(const byte *source, uint16 destX, uint16 destY);
+
+ // The caller has to .free() the returned Surfaces!!!
+ ::Graphics::Surface loadPictureGraphic(Common::File &file); // Reads Graphic-planar EGA data.
+
+ ::Graphics::Surface loadPictureRow(Common::File &file, uint16 width, uint16 height); // Reads Row-planar EGA data.
+
+
+ void drawPicture(const ::Graphics::Surface &picture, uint16 destX, uint16 destY); // Can't call .free() here. See Lucerna::showscore() for example.
+
+ void drawPicture_old(const byte *source, uint16 destX, uint16 destY);
void refreshScreen();
diff --git a/engines/avalanche/gyro2.cpp b/engines/avalanche/gyro2.cpp
index fa1298a322..76640739af 100644
--- a/engines/avalanche/gyro2.cpp
+++ b/engines/avalanche/gyro2.cpp
@@ -261,10 +261,16 @@ Gyro::~Gyro() {
delete[] vmc.andpic;
delete[] vmc.xorpic;
- for (int fv = 0; fv < 2; fv ++) {
+ for (byte fv = 0; fv < 2; fv ++) {
delete[] vmc.backpic[fv];
}
+ for (byte i = 0; i < 9; i++) {
+ digit[i].free();
+ rwlite[i].free();
+ }
+ digit[9].free();
+
}
void Gyro::newpointer(byte m) {
diff --git a/engines/avalanche/gyro2.h b/engines/avalanche/gyro2.h
index a99d4c6600..b2fc47fbf5 100644
--- a/engines/avalanche/gyro2.h
+++ b/engines/avalanche/gyro2.h
@@ -34,6 +34,8 @@
#include "common/scummsys.h"
#include "common/file.h"
+#include "graphics/surface.h"
+
#include "avalanche/roomnums.h"
#include "avalanche/color.h"
@@ -521,8 +523,11 @@ public:
bool ontoolbar, seescroll; // TODO: maybe this means we're interacting with the toolbar / a scroll?
char objlist[10];
- byte *digit[10]; // digitsize and rwlitesize are defined in Lucerna::load_digits() !!!
- byte *rwlite[9]; // Maybe it will be needed to move them to the class itself instead.
+
+ ::Graphics::Surface digit[10]; // digitsize and rwlitesize are defined in Lucerna::load_digits() !!!
+ ::Graphics::Surface rwlite[9]; // Maybe it will be needed to move them to the class itself instead.
+ // Called .free() for them in ~Gyro().
+
byte oldrw;
int8 lastscore[3];
byte cmp; /* current mouse-void **/
diff --git a/engines/avalanche/lucerna2.cpp b/engines/avalanche/lucerna2.cpp
index 6ca03b073e..c1136ed20c 100644
--- a/engines/avalanche/lucerna2.cpp
+++ b/engines/avalanche/lucerna2.cpp
@@ -241,27 +241,15 @@ void Lucerna::load(byte n) { /* Load2, actually */
move(a0, a1, 12080);
}*/
- ::Graphics::Surface background;
+
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)
- background.create(backgroundWidht, backgroundHeight, ::Graphics::PixelFormat::createFormatCLUT8());
-
- for (byte plane = 0; plane < 4; plane++)
- for (uint16 y = 0; y < backgroundHeight; y++)
- for (uint16 x = 0; x < backgroundWidht; x += 8) {
- byte pixel = f.readByte();
- for (byte i = 0; i < 8; i++) {
- byte pixelBit = (pixel >> i) & 1;
- *(byte *)background.getBasePtr(x + 7 - i, y) += (pixelBit << plane);
- }
- }
+ ::Graphics::Surface background = _vm->_graphics->loadPictureRow(f, backgroundWidht, backgroundHeight);
- for (uint16 y = 0; y < backgroundHeight; y++)
- for (uint16 x = 0; x < backgroundWidht; x++)
- *_vm->_graphics->getPixel(x + 0, y + 10) = *(byte *)background.getBasePtr(x, y);
+ _vm->_graphics->drawPicture(background, 0, 10);
background.free();
@@ -759,15 +747,13 @@ void Lucerna::thinkabout(byte z, bool th) { /* Hey!!! Get it and put it!!! *
}
f.seek(z * picsize + 65);
+
+ ::Graphics::Surface picture = _vm->_graphics->loadPictureGraphic(f);
- byte *buffer = new byte[picsize];
-
- f.read(buffer, picsize);
-
- _vm->_graphics->drawPicture(buffer, 205, 170);
-
- delete[] buffer;
+ _vm->_graphics->drawPicture(picture, 205, 170);
+ picture.free();
+
f.close();
_vm->_gyro->off();
@@ -793,13 +779,17 @@ void Lucerna::load_digits() { /* Load the scoring digits & rwlites */
}
for (byte fv = 0; fv < 10; fv ++) {
- _vm->_gyro->digit[fv] = new byte[digitsize];
- f.read(_vm->_gyro->digit[fv], digitsize);
+ f.seek(fv * digitsize);
+ /*_vm->_gyro->digit[fv] = new byte[digitsize];
+ f.read(_vm->_gyro->digit[fv], digitsize);*/
+ _vm->_gyro->digit[fv] = _vm->_graphics->loadPictureGraphic(f);
}
for (byte ff = 0; ff < 9; ff ++) {
- _vm->_gyro->rwlite[ff] = new byte[rwlitesize];
- f.read(_vm->_gyro->rwlite[ff], rwlitesize);
+ f.seek(10 * digitsize + ff * rwlitesize);
+ /*_vm->_gyro->rwlite[ff] = new byte[rwlitesize];
+ f.read(_vm->_gyro->rwlite[ff], rwlitesize);*/
+ _vm->_gyro->rwlite[ff] = _vm->_graphics->loadPictureGraphic(f);
}
f.close();
@@ -815,15 +805,11 @@ void Lucerna::toolbar() {
/* off;*/
- uint32 bufferSize = f.size()-40;
-
- byte *buffer = new byte[bufferSize];
-
- f.read(buffer, bufferSize);
+ ::Graphics::Surface picture = _vm->_graphics->loadPictureGraphic(f);
- _vm->_graphics->drawPicture(buffer, 5, 169);
+ _vm->_graphics->drawPicture(picture, 5, 169);
- delete[] buffer;
+ picture.free();
f.close();