aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/preagi.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2007-09-02 01:45:59 +0000
committerFilippos Karapetis2007-09-02 01:45:59 +0000
commit2182d758d07432d990b0e18beb569d539b901e00 (patch)
tree84e1a4c7d54773801530e0236e11c9a8651fd8fc /engines/agi/preagi.cpp
parent38c21d65393690c1a392587ab4fbdd226bc32d6a (diff)
downloadscummvm-rg350-2182d758d07432d990b0e18beb569d539b901e00.tar.gz
scummvm-rg350-2182d758d07432d990b0e18beb569d539b901e00.tar.bz2
scummvm-rg350-2182d758d07432d990b0e18beb569d539b901e00.zip
Initial implementation of preagi string drawing functions. They still need work, though
svn-id: r28812
Diffstat (limited to 'engines/agi/preagi.cpp')
-rw-r--r--engines/agi/preagi.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp
index f24fbcd294..25e143e42f 100644
--- a/engines/agi/preagi.cpp
+++ b/engines/agi/preagi.cpp
@@ -39,6 +39,7 @@
#include "sound/mixer.h"
#include "agi/agi.h"
+#include "agi/font.h"
#include "agi/graphics.h"
#include "agi/sprite.h"
#include "agi/opcodes.h"
@@ -272,4 +273,61 @@ int PreAgiEngine::preAgiUnloadResource(int r, int n) {
return _loader->unloadResource(r, n);
}
+// String functions
+void PreAgiEngine::drawStr(int row, int col, int attr, char *buffer)
+{
+ int code;
+
+ for (int iChar = 0; iChar < (int)strlen(buffer); iChar++)
+ {
+ code = buffer[iChar];
+
+ switch (code)
+ {
+ case '\n':
+ case 0x8D:
+ if (++row == 200 / 8) return;
+ col = 0;
+ break;
+
+ case '|':
+ // swap attribute nibbles
+ break;
+
+ default:
+ drawChar(col * 8, row * 8, attr, code, (char*)mickey_fontdata);
+
+ if (++col == 320 / 8)
+ {
+ col = 0;
+ if (++row == 200 / 8) return;
+ }
+ }
+ }
+}
+
+void PreAgiEngine::drawStrMiddle(int row, int attr, char *buffer) {
+ int col = (25 / 2) - (strlen(buffer) / 2); // 25 = 320 / 8 (maximum column)
+ drawStr(row, col, attr, buffer);
+}
+
+void PreAgiEngine::drawChar(int x, int y, int attr, int code, char *fontdata)
+{
+ int cx, cy;
+ uint8 color;
+
+ for (cy = 0; cy < 8; cy++)
+ {
+ for (cx = 0; cx < 8; cx++)
+ {
+ if (fontdata[(code * 8) + cy] & (1 << (7 - cx)))
+ color = attr & 0x0f; // foreground color
+ else
+ color = (attr & 0xf0) / 0x10; // background color
+
+ _gfx->putPixelsA(x + cx, y + cy, 1, &color);
+ }
+ }
+}
+
} // End of namespace Agi