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.
This commit is contained in:
parent
ee6119d07f
commit
698dae201a
8 changed files with 44 additions and 58 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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().
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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+*/
|
||||
|
|
|
@ -103,7 +103,7 @@ private:
|
|||
|
||||
|
||||
int16 dix, diy;
|
||||
raw ch[2];
|
||||
fontType ch[2];
|
||||
byte cfont; // Current font
|
||||
|
||||
int16 dodgex, dodgey;
|
||||
|
|
|
@ -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!
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue