diff options
author | Filippos Karapetis | 2007-09-02 21:31:51 +0000 |
---|---|---|
committer | Filippos Karapetis | 2007-09-02 21:31:51 +0000 |
commit | f50bdd1aa819b90c9b5eea94222374c2d3c18282 (patch) | |
tree | 59685e9b8d797e2d6b657e2eb51ab7ec8c49f56a /engines | |
parent | 0f34da6d26d97e9c06403443b5a80f77d03c07d7 (diff) | |
download | scummvm-rg350-f50bdd1aa819b90c9b5eea94222374c2d3c18282.tar.gz scummvm-rg350-f50bdd1aa819b90c9b5eea94222374c2d3c18282.tar.bz2 scummvm-rg350-f50bdd1aa819b90c9b5eea94222374c2d3c18282.zip |
Moved preagi common code to a more appropriate place (commit 1 of 2)
svn-id: r28831
Diffstat (limited to 'engines')
-rw-r--r-- | engines/agi/preagi.cpp | 66 | ||||
-rw-r--r-- | engines/agi/preagi_input.cpp | 70 |
2 files changed, 69 insertions, 67 deletions
diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp index 11a5a13155..f24fbcd294 100644 --- a/engines/agi/preagi.cpp +++ b/engines/agi/preagi.cpp @@ -39,7 +39,6 @@ #include "sound/mixer.h" #include "agi/agi.h" -#include "agi/font.h" #include "agi/graphics.h" #include "agi/sprite.h" #include "agi/opcodes.h" @@ -50,12 +49,6 @@ // preagi engines #include "agi/preagi_mickey.h" -// default attributes -#define IDA_DEFAULT 0x0F -#define IDA_DEFAULT_REV 0xF0 - -#define IDI_MAX_ROW_PIC 20 - namespace Agi { PreAgiEngine::PreAgiEngine(OSystem *syst) : AgiBase(syst) { @@ -279,63 +272,4 @@ int PreAgiEngine::preAgiUnloadResource(int r, int n) { return _loader->unloadResource(r, n); } -// String functions -// TODO: These need to be moved elsewhere - -void PreAgiEngine::drawStr(int row, int col, int attr, const 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, (const char*)mickey_fontdata); - - if (++col == 320 / 8) { - col = 0; - if (++row == 200 / 8) return; - } - } - } -} - -void PreAgiEngine::drawStrMiddle(int row, int attr, const char *buffer) { - int col = (25 / 2) - (strlen(buffer) / 2); // 25 = 320 / 8 (maximum column) - drawStr(row, col, attr, buffer); -} - -void PreAgiEngine::clearTextArea() { - // FIXME: this causes crashes, I imagine it's because we're not currently locking the screen in drawStr - for (int row = IDI_MAX_ROW_PIC; row < 200 / 8; row++) { - //drawStr(row, 0, IDA_DEFAULT, " "); // 40 spaces - } -} - -void PreAgiEngine::drawChar(int x, int y, int attr, int code, const 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 diff --git a/engines/agi/preagi_input.cpp b/engines/agi/preagi_input.cpp index 56bade1439..199401b85c 100644 --- a/engines/agi/preagi_input.cpp +++ b/engines/agi/preagi_input.cpp @@ -27,12 +27,80 @@ #include "common/events.h" #include "agi/agi.h" +#include "agi/font.h" #include "agi/graphics.h" #include "agi/keyboard.h" +// preagi engines +#include "agi/preagi_mickey.h" + +// default attributes +#define IDA_DEFAULT 0x0F +#define IDA_DEFAULT_REV 0xF0 + +#define IDI_MAX_ROW_PIC 20 + namespace Agi { -// Input +// String functions + +void PreAgiEngine::drawStr(int row, int col, int attr, const 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, (const char*)mickey_fontdata); + + if (++col == 320 / 8) { + col = 0; + if (++row == 200 / 8) return; + } + } + } +} + +void PreAgiEngine::drawStrMiddle(int row, int attr, const char *buffer) { + int col = (25 / 2) - (strlen(buffer) / 2); // 25 = 320 / 8 (maximum column) + drawStr(row, col, attr, buffer); +} + +void PreAgiEngine::clearTextArea() { + // FIXME: this causes crashes, I imagine it's because we're not currently locking the screen in drawStr + for (int row = IDI_MAX_ROW_PIC; row < 200 / 8; row++) { + //drawStr(row, 0, IDA_DEFAULT, " "); // 40 spaces + } +} + +void PreAgiEngine::drawChar(int x, int y, int attr, int code, const 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); + } + } +} + +// Input functions void PreAgiEngine::waitAnyKeyAnim() { waitAnyKey(true); |