diff options
author | Martin Kiewitz | 2015-06-12 23:12:42 +0200 |
---|---|---|
committer | Martin Kiewitz | 2015-06-12 23:12:42 +0200 |
commit | 132f33a3065afd931e81af5728cdee0368b6b5fe (patch) | |
tree | cf77ee6801d963b4b09334591cf94d96c43eb9d4 | |
parent | 765dbe647cb97cd8a728bd3bbdbf3e8f97718af2 (diff) | |
download | scummvm-rg350-132f33a3065afd931e81af5728cdee0368b6b5fe.tar.gz scummvm-rg350-132f33a3065afd931e81af5728cdee0368b6b5fe.tar.bz2 scummvm-rg350-132f33a3065afd931e81af5728cdee0368b6b5fe.zip |
SHERLOCK: 3DO: font support
not perfect yet because 3DO has built-in anti-aliasing
and it seems the fonts were designed with this in mind
-rw-r--r-- | engines/sherlock/image_file.cpp | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/engines/sherlock/image_file.cpp b/engines/sherlock/image_file.cpp index a42b443e3c..47fe387038 100644 --- a/engines/sherlock/image_file.cpp +++ b/engines/sherlock/image_file.cpp @@ -842,8 +842,16 @@ void ImageFile3DO::loadFont(Common::SeekableReadStream &stream) { uint32 curCharHeightLeft = 0; uint32 curCharWidthLeft = 0; byte curBits = 0; + byte curBitsReversed = 0; + byte curPosX = 0; - for (curChar = 0; curChar < header_charCount; curChar++) { + assert(bitsTableSize >= (header_maxChar * header_fontHeight * header_bytesPerLine)); // Security + + // first frame needs to be "!" (33 decimal) + // our font code is subtracting 33 from the actual character code + curBitsLinePtr += (33 * (header_fontHeight * header_bytesPerLine)); + + for (curChar = 33; curChar < header_charCount; curChar++) { // create frame { ImageFrame imageFrame; @@ -861,37 +869,40 @@ void ImageFile3DO::loadFont(Common::SeekableReadStream &stream) { uint16 *dest = (uint16 *)imageFrame._frame.getPixels(); Common::fill(dest, dest + imageFrame._width * imageFrame._height, 0); -#if 0 curCharHeightLeft = header_fontHeight; while (curCharHeightLeft) { curCharWidthLeft = widthTablePtr[curChar]; curBitsPtr = curBitsLinePtr; curBitsLeft = 8; + curPosX = 0; while (curCharWidthLeft) { - curBits = celGetBits(curBitsPtr, 2, curBitsLeft); - switch (curBits) { - case 0: // Transparent - break; - case 1: // regular color - *dest = 0xFFFF; - break; - case 2: // front - //*dest = 0xFFFF; //0x333; - break; - case 3: // shadow - //*dest = 0x1111; - break; + if (!(curPosX & 1)) { + curBits = *curBitsPtr >> 4; + } else { + curBits = *curBitsPtr & 0x0F; + curBitsPtr++; } + // doing this properly is complicated + // the 3DO has built-in anti-aliasing + // this here at least results in somewhat readable text + // TODO: make it better + if (curBits) { + curBitsReversed = (curBits >> 3) | ((curBits & 0x04) >> 1) | ((curBits & 0x02) << 1) | ((curBits & 0x01) << 3); + curBits = 20 - curBits; + } + + byte curIntensity = curBits; + *dest = (curIntensity << 11) | (curIntensity << 6) | curIntensity; dest++; curCharWidthLeft--; + curPosX++; } curCharHeightLeft--; curBitsLinePtr += header_bytesPerLine; } -#endif push_back(imageFrame); } |