aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche
diff options
context:
space:
mode:
authoruruk2013-08-11 14:06:15 +0200
committeruruk2013-08-11 14:06:15 +0200
commit698dae201a38218de71888bc54326429be79013e (patch)
treef062b066d453c335aa2ea2ec9034149b8da1ed8a /engines/avalanche
parentee6119d07feea83718f7a3ce9073d92de2747750 (diff)
downloadscummvm-rg350-698dae201a38218de71888bc54326429be79013e.tar.gz
scummvm-rg350-698dae201a38218de71888bc54326429be79013e.tar.bz2
scummvm-rg350-698dae201a38218de71888bc54326429be79013e.zip
AVALANCHE: Introduce Graphics::drawText(). Rename raw to fontType, move it from Gyro to Graphics. Update the rest of the code using these two. Simplifying underlining of characters in Parser and Dropdown.
Diffstat (limited to 'engines/avalanche')
-rw-r--r--engines/avalanche/dropdown2.cpp21
-rw-r--r--engines/avalanche/graphics.cpp13
-rw-r--r--engines/avalanche/graphics.h6
-rw-r--r--engines/avalanche/gyro2.h4
-rw-r--r--engines/avalanche/parser.cpp27
-rw-r--r--engines/avalanche/scrolls2.cpp25
-rw-r--r--engines/avalanche/scrolls2.h2
-rw-r--r--engines/avalanche/timeout2.cpp4
8 files changed, 44 insertions, 58 deletions
diff --git a/engines/avalanche/dropdown2.cpp b/engines/avalanche/dropdown2.cpp
index bc8414d1a6..89eb231280 100644
--- a/engines/avalanche/dropdown2.cpp
+++ b/engines/avalanche/dropdown2.cpp
@@ -285,28 +285,25 @@ void Dropdown::chalk(int16 x, int16 y, char t, Common::String z, bool valid) {
else
ander = 170;
+ fontType font;
for (byte fv = 0; fv < z.size(); fv++)
- for (byte ff = 0; ff < 8; ff++) {
- byte pixel = ~(_vm->_gyro->characters[z[fv]][ff] & ander); // Note that it's the bitwise NOT operator!
- for (byte bit = 0; bit < 8; bit++) {
- byte pixelBit = (pixel >> bit) & 1;
- *_vm->_graphics->getPixel(x * 8 + fv * 8 + 7 - bit, y + ff) = pixelBit + (pixelBit << 1) + (pixelBit << 2);
- // We don't have to bother with the planes, since they all have the same value. See the original.
- // Note that it's the bitwise OR operator!
- }
- }
+ for (byte ff = 0; ff < 8; ff++)
+ font[z[fv]][ff] = _vm->_gyro->characters[z[fv]][ff] & ander;
+ _vm->_graphics->drawText(_vm->_graphics->_surface, z, font, 8, x * 8, y, black);
+
+ // Underline the selected character.
if (! z.contains(t))
return;
else {
byte fv;
for (fv = 0; z[fv] != t; fv++); // Search for the character in the string.
- // Similar to the cycle before.
- byte pixel = ~ ander;
+ byte pixel = ander;
for (byte bit = 0; bit < 8; bit++) {
byte pixelBit = (pixel >> bit) & 1;
- *_vm->_graphics->getPixel(x * 8 + fv * 8 + 7 - bit, y + 8) = pixelBit | (pixelBit << 1) | (pixelBit << 2);
+ if (pixelBit)
+ *_vm->_graphics->getPixel(x * 8 + fv * 8 + 7 - bit, y + 8) = black;
}
}
}
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp
index 42a36ff83c..4b30f6fdb2 100644
--- a/engines/avalanche/graphics.cpp
+++ b/engines/avalanche/graphics.cpp
@@ -249,6 +249,19 @@ void Graphics::drawTriangle(::Graphics::Surface &surface, Common::Point *p, byte
+void Graphics::drawText(::Graphics::Surface &surface, const Common::String &text, fontType font, byte fontHeight, int16 x, int16 y, byte color) {
+ for (byte i = 0; i < text.size(); i++)
+ for (byte j = 0; j < fontHeight; j++) {
+ byte pixel = font[text[i]][j];
+ for (byte bit = 0; bit < 8; bit++) {
+ byte pixelBit = (pixel >> bit) & 1;
+ if (pixelBit)
+ *(byte *)surface.getBasePtr(x + i * 8 + 7 - bit, y + j) = color;
+ }
+ }
+}
+
+
::Graphics::Surface Graphics::loadPictureGraphic(Common::File &file) {
// This function mimics Pascal's getimage().
diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h
index c4c1e85b02..7492141c43 100644
--- a/engines/avalanche/graphics.h
+++ b/engines/avalanche/graphics.h
@@ -36,6 +36,8 @@
namespace Avalanche {
class AvalancheEngine;
+typedef byte fontType[256][16]; // raw font type
+
typedef byte manitype[2049]; // manitype = array[5..2053] of byte;
// Be aware!!!
@@ -99,6 +101,10 @@ public:
+ void drawText(::Graphics::Surface &surface, const Common::String &text, fontType font, byte fontHeight, int16 x, int16 y, byte color);
+
+
+
// The caller has to .free() the returned Surfaces!!!
::Graphics::Surface loadPictureGraphic(Common::File &file); // Reads Graphic-planar EGA data.
diff --git a/engines/avalanche/gyro2.h b/engines/avalanche/gyro2.h
index 854b5dfcc8..390011c41e 100644
--- a/engines/avalanche/gyro2.h
+++ b/engines/avalanche/gyro2.h
@@ -200,8 +200,6 @@ public:
byte col;
};
-typedef byte raw[256][16]; /* raw_font_type */
-
enum controllers {cjoy, ckey};
typedef Common::String previoustype[20];
@@ -541,7 +539,7 @@ public:
Common::String atkey; /* For XTs, set to "alt-". For ATs, set to "f1". */
byte cp, ledstatus, defaultled;
- raw characters;
+ fontType characters;
bool alive;
byte buffer[2000];
uint16 bufsize;
diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp
index 86f46c1f08..4ce8249eb0 100644
--- a/engines/avalanche/parser.cpp
+++ b/engines/avalanche/parser.cpp
@@ -93,16 +93,7 @@ void Parser::plotText() {
_vm->_graphics->drawBar(24, 161, 640, 169, black); // Black out the line of the text.
- // Draw the text. Similar to chalk(), but here we don't have to bother with the color of the characters.
- for (byte i = 0; i < _vm->_parser->_inputText.size(); i++)
- for (byte j = 0; j < 8; j++) {
- byte pixel = _vm->_gyro->characters[_vm->_parser->_inputText[i]][j];
- for (byte bit = 0; bit < 8; bit++) {
- byte pixelBit = (pixel >> bit) & 1;
- if (pixelBit != 0)
- *_vm->_graphics->getPixel(24 + i * 8 + 7 - bit, 161 + j) = white;
- }
- }
+ _vm->_graphics->drawText(_vm->_graphics->_surface, _vm->_parser->_inputText, _vm->_gyro->characters, 8, 24, 161, white);
cursorOn();
_vm->_gyro->super_on();
@@ -134,19 +125,9 @@ int16 Parser::pos(const Common::String &crit, const Common::String &src) {
}
void Parser::drawCursor() {
- // Draw the '_' character. Similar to plotText().
- char cursor = '_';
-
- for (byte j = 0; j < 8; j++) {
- byte pixel = _vm->_gyro->characters[cursor][j];
- for (byte bit = 0; bit < 8; bit++) {
- byte pixelBit = (pixel >> bit) & 1;
- if (pixelBit != 0)
- *_vm->_graphics->getPixel(24 + _inputTextPos * 8 + 7 - bit, 161 + j) = white;
- }
- }
-
-
+ // Draw the '_' character.
+ for (byte bit = 0; bit < 8; bit++)
+ *_vm->_graphics->getPixel(24 + _inputTextPos * 8 + 7 - bit, 168) = white;
bytefield bf;
bf.x1 = _inputTextPos + 1;
diff --git a/engines/avalanche/scrolls2.cpp b/engines/avalanche/scrolls2.cpp
index 8a95d44887..5aa1cd50fe 100644
--- a/engines/avalanche/scrolls2.cpp
+++ b/engines/avalanche/scrolls2.cpp
@@ -103,9 +103,10 @@ void Scrolls::easteregg() {
}
void Scrolls::say(int16 x, int16 y, Common::String z) { /* Fancy FAST screenwriting */
- byte itw[12][80];
+ //byte itw[12][80];
+ Common::String text;
+ fontType itw;
byte lz = z.size();
- byte ox = 0;
_vm->_logger->log_scrollline();
@@ -123,28 +124,20 @@ void Scrolls::say(int16 x, int16 y, Common::String z) { /* Fancy FAST screenwrit
break;
default: {
for (byte yy = 0; yy < 12; yy++)
- itw[yy][ox] = ~ch[cfont][z[xx]][yy + 2];
- ox++;
+ itw[z[xx]][yy] = ch[cfont][z[xx]][yy + 2];
+
+ text += z[xx];
+
_vm->_logger->log_scrollchar(Common::String(z[xx]));
}
}
}
bool offset = x % 8 == 4;
- lz = ox;
x = x / 8;
y++;
- // Similar to Dropdown::chalk().
- for (byte fv = 0; fv < lz; fv++)
- for (byte ff = 0; ff < 12; ff++) {
- byte pixel = itw[ff][fv];
- for (byte bit = 0; bit < 8; bit++) {
- byte pixelBit = (pixel >> bit) & 1;
- uint16 xa = x * 8 + fv * 8 + 7 - bit + offset * 4;
- uint16 ya = y + ff;
- *(byte *)_vm->_graphics->_scrolls.getBasePtr(xa, ya) = pixelBit + (pixelBit << 1) + (pixelBit << 2);
- }
- }
+
+ _vm->_graphics->drawText(_vm->_graphics->_scrolls, text, itw, 12, x * 8 + offset *4, y, black);
}
/* Here are the procedures that Scroll calls */ /* So they must be... */ /*$F+*/
diff --git a/engines/avalanche/scrolls2.h b/engines/avalanche/scrolls2.h
index b267ff68f6..8af3402d96 100644
--- a/engines/avalanche/scrolls2.h
+++ b/engines/avalanche/scrolls2.h
@@ -103,7 +103,7 @@ private:
int16 dix, diy;
- raw ch[2];
+ fontType ch[2];
byte cfont; // Current font
int16 dodgex, dodgey;
diff --git a/engines/avalanche/timeout2.cpp b/engines/avalanche/timeout2.cpp
index 4debd16653..459f12415d 100644
--- a/engines/avalanche/timeout2.cpp
+++ b/engines/avalanche/timeout2.cpp
@@ -212,9 +212,7 @@ void Timeout::one_tick() {
}
void Timeout::lose_timer(byte which) {
- byte fv;
-
- for (fv = 0; fv < 7; fv++) {
+ for (byte fv = 0; fv < 7; fv++) {
if (times[fv].what_for == which)
times[fv].time_left = 0; // Cancel this one!
}