From 9683ced39efe6bb0033d18498f6e553506bf39e6 Mon Sep 17 00:00:00 2001 From: uruk Date: Mon, 15 Jul 2013 16:57:03 +0200 Subject: AVALANCHE: implement Lucerna::toolbar(), revise Graph::copySurface() and Graph::setPixel(), update Lucerna::load() accordingly. --- engines/avalanche/graph.cpp | 14 +++++------- engines/avalanche/graph.h | 6 ++--- engines/avalanche/lucerna2.cpp | 52 ++++++++++++++++++++++++------------------ 3 files changed, 39 insertions(+), 33 deletions(-) (limited to 'engines') diff --git a/engines/avalanche/graph.cpp b/engines/avalanche/graph.cpp index e101749027..1b0e56c5a4 100644 --- a/engines/avalanche/graph.cpp +++ b/engines/avalanche/graph.cpp @@ -70,20 +70,18 @@ byte *Graph::getPixel(int16 x, int16 y) { return (byte *)_surface.getBasePtr(x, y); } -void Graph::setPixel(byte *pixel, byte color) { - *pixel = color; +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); } -void Graph::copySurface(Graphics::Surface source) { - for (uint16 y = 0; y < _screenHeight / 2; y++) - for (uint16 x = 0; x < _screenWidth; x ++) { - for (byte j = 0; j < 2; j++) // We copy every line twice to reach 400 picture height. - *(byte *)_surface.getBasePtr(x, y * 2 + j) = *(byte *)source.getBasePtr(x, y); - } +void Graph::copySurface(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); } void Graph::refreshScreen() { diff --git a/engines/avalanche/graph.h b/engines/avalanche/graph.h index 559e78cb6f..3d819d1d3a 100644 --- a/engines/avalanche/graph.h +++ b/engines/avalanche/graph.h @@ -38,7 +38,7 @@ class AvalancheEngine; class Graph { public: static const int16 _screenWidth = 640; - static const int16 _screenHeight = 400; + static const int16 _screenHeight = 200; @@ -50,11 +50,11 @@ public: byte *getPixel(int16 x, int16 y); - void setPixel(byte *pixel, byte color); + void setPixel(int16 x, int16 y, byte color); void drawBar(int16 x1, int16 y1, int16 x2, int16 y2, int16 color); - void copySurface(Graphics::Surface source); + void copySurface(Graphics::Surface source, uint16 destX, uint16 destY); void refreshScreen(); diff --git a/engines/avalanche/lucerna2.cpp b/engines/avalanche/lucerna2.cpp index 16da58cf54..f665c54771 100644 --- a/engines/avalanche/lucerna2.cpp +++ b/engines/avalanche/lucerna2.cpp @@ -240,14 +240,16 @@ void Lucerna::load(byte n) { /* Load2, actually */ }*/ Graphics::Surface background; - background.create(_vm->_graph._screenWidth, _vm->_graph._screenHeight, Graphics::PixelFormat::createFormatCLUT8()); - + + uint16 backgroundWidht = _vm->_graph._screenWidth; byte backgroundHeight = 8 * 12080 / _vm->_graph._screenWidth; // 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 < _vm->_graph._screenWidth; x += 8) { + for (uint16 x = 0; x < backgroundWidht; x += 8) { byte pixel = f.readByte(); for (byte i = 0; i < 8; i++) { byte pixelBit = (pixel >> i) & 1; @@ -255,7 +257,7 @@ void Lucerna::load(byte n) { /* Load2, actually */ } } - _vm->_graph.copySurface(background); + _vm->_graph.copySurface(background, 0 ,0); background.free(); @@ -823,35 +825,41 @@ void Lucerna::load_digits() { /* Load the scoring digits & rwlites */ } void Lucerna::toolbar() { - uint16 s; - byte *p; - if (!f.open("useful.avd")) { warning("AVALANCHE: Lucerna: File not found: useful.avd"); return; } - s = f.size() - 40; - p = new byte[s]; f.seek(40); - f.read(p, s); - f.close(); + /* off;*/ - //setcolor(15); /* (And sent for chrysanthemums...) Yellow and white. */ - //setfillstyle(1, 6); - //for (byte fv = 0; fv <= 1; fv ++) { - // setactivepage(fv); - // putimage(5, 169, p, 0); - // if (demo) { - // bar(264, 177, 307, 190); - // outtextxy(268, 188, "Demo!"); /* well... actually only white now. */ - // } - //} + uint16 toolbarWidth = f.readUint16LE() + 1; + uint16 toolbarHeight = f.readUint16LE() + 1; + + 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); + + toolbar.free(); + + f.close(); + warning("STUB: Lucerna::toolbar()"); /* on;*/ - delete[] p; + _vm->_gyro.oldrw = 177; showrw(); } -- cgit v1.2.3