diff options
author | Bendegúz Nagy | 2016-06-22 20:32:30 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | 9538db0b6100b407d3ed1450256ffdc63efef4c2 (patch) | |
tree | bc2eb9a201803d43b9f4204072fa3783dcc2eb31 /engines/dm/text.cpp | |
parent | f46a588164f7a49767ed75cd108d16cfc6cf7410 (diff) | |
download | scummvm-rg350-9538db0b6100b407d3ed1450256ffdc63efef4c2.tar.gz scummvm-rg350-9538db0b6100b407d3ed1450256ffdc63efef4c2.tar.bz2 scummvm-rg350-9538db0b6100b407d3ed1450256ffdc63efef4c2.zip |
Add: TextMan, font loading and basic text display
Diffstat (limited to 'engines/dm/text.cpp')
-rw-r--r-- | engines/dm/text.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp new file mode 100644 index 0000000000..116058de35 --- /dev/null +++ b/engines/dm/text.cpp @@ -0,0 +1,37 @@ +#include "text.h" + + +namespace DM { + +TextMan::TextMan(DMEngine* vm) : _vm(vm) {} + +#define kLetterWidth 5 +#define kLetterHeight 6 + +void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, Color textColor, Color bgColor, char* text, uint16 destHeight, Viewport &viewport) { + uint16 textLength = strlen(text); + uint16 nextX = destX; + uint16 nextY = destY; + byte *srcBitmap = _vm->_displayMan->getBitmap(kFontGraphicIndice); + + + for (char *begin = text, *end = text + textLength; begin != end; ++begin) { + // Note: this does no wraps in the middle of words + if (nextX + kLetterWidth + 1 > destPixelWidth || (*begin == '\n')) { + nextX = destX; + nextY += kLetterHeight + 1; + } + if (nextY + kLetterHeight + 1 > destHeight) + break; + uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code + _vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, srcX, 0, destBitmap, destPixelWidth, + nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight + 1, kColorNoTransparency, viewport); + nextX += kLetterWidth + 1; + } +} + +void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, char* text, Viewport &viewport) { + printTextToBitmap(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport); +} + +} |