AGOS: Move topaz 9 double height draw from AGOS to amigafont

This commit is contained in:
Robert Megone
2026-04-08 12:17:52 +01:00
committed by Filippos Karapetis
parent 0629e6e220
commit 33894ae504
3 changed files with 47 additions and 45 deletions
+1 -42
View File
@@ -3061,47 +3061,6 @@ static inline void pnSqueezeGlyph8Rows(const byte *src8, byte *dst8) {
dst8[i] = pnSqueezeRow(src8[i], anyBit1SetAcrossGlyph);
}
static void drawPnAmigaDoubleHeightTopazChar(const Graphics::AmigaFont *font, Graphics::Surface *dst, byte chr, int x, int y, byte color) {
enum {
kPnAmigaTopazScratchWidth = 16,
kPnAmigaTopazScratchHeight = 16
};
const int glyphWidth = font->getCharRenderWidth(chr);
const int rawHeight = font->getFontHeight();
const int drawOffset = font->getCharDrawOffset(chr);
const int glyphLeft = MIN<int>(0, drawOffset);
const int glyphOriginX = drawOffset - glyphLeft;
if (glyphWidth <= 0 || rawHeight <= 0)
return;
assert(glyphWidth <= kPnAmigaTopazScratchWidth);
assert(rawHeight <= kPnAmigaTopazScratchHeight);
byte glyphPixels[kPnAmigaTopazScratchWidth * kPnAmigaTopazScratchHeight];
memset(glyphPixels, 0, sizeof(glyphPixels));
Graphics::Surface glyphSurface;
glyphSurface.init(glyphWidth, rawHeight, glyphWidth, glyphPixels, Graphics::PixelFormat::createFormatCLUT8());
font->drawChar(&glyphSurface, chr, glyphOriginX, 0, 1);
for (int srcY = 0; srcY < rawHeight; ++srcY) {
for (int srcX = 0; srcX < glyphWidth; ++srcX) {
if (glyphPixels[srcY * glyphWidth + srcX] == 0)
continue;
const int dstX = x + glyphLeft + srcX;
if (dstX < 0 || dstX >= dst->w)
continue;
for (int repeat = 0; repeat < 2; ++repeat) {
const int dstY = y + srcY * 2 + repeat;
if (dstY >= 0 && dstY < dst->h)
*(byte *)dst->getBasePtr(dstX, dstY) = color;
}
}
}
}
void AGOSEngine::drawPnAmigaTopazChar(WindowBlock *window, byte chr) {
PnAmigaTextPlane *plane = getPnAmigaTextPlane(window);
if (plane == nullptr || plane->pixels == nullptr)
@@ -3130,7 +3089,7 @@ void AGOSEngine::drawPnAmigaTopazChar(WindowBlock *window, byte chr) {
return;
if (usePnAmigaDoubleHeightTopaz())
drawPnAmigaDoubleHeightTopazChar(font, &surface, chr, x, y, window->textColor);
font->drawCharDoubleHeight(&surface, chr, x, y, window->textColor);
else
font->drawChar(&surface, chr, x + font->getCharDrawOffset(chr), y, window->textColor);
}
+44 -2
View File
@@ -27,8 +27,9 @@
namespace Graphics {
// Topaz 8
// For the data source and license look into gui/themes/fonts/topaz in ScummVM distribution
static const byte amigaTopazFont[2600] = {
static const byte amigaTopaz8Font[2600] = {
0x00, 0x00, 0x03, 0xf3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x79, 0x00, 0x00, 0x03, 0xe9, 0x00, 0x00, 0x02, 0x79,
0x70, 0xff, 0x4e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
@@ -298,7 +299,7 @@ static const byte amigaTopaz9Font[] = {
AmigaFont::AmigaFont(Common::SeekableReadStream *stream) {
Common::SeekableReadStream *tmp;
if (!stream) {
tmp = new Common::MemoryReadStream(amigaTopazFont, sizeof(amigaTopazFont), DisposeAfterUse::NO);
tmp = new Common::MemoryReadStream(amigaTopaz8Font, sizeof(amigaTopaz8Font), DisposeAfterUse::NO);
} else {
tmp = stream;
}
@@ -497,6 +498,47 @@ void drawCharIntern(byte *ptr, uint32 pitch, int num, int bitOffset, byte *charD
}
}
void AmigaFont::drawCharDoubleHeight(Surface *dst, uint32 chr, int x, int y, uint32 color) const {
enum {
kAmigaFontScratchWidth = 16,
kAmigaFontScratchHeight = 16
};
const int glyphWidth = getCharRenderWidth(chr);
const int rawHeight = getFontHeight();
const int drawOffset = getCharDrawOffset(chr);
const int glyphLeft = MIN<int>(0, drawOffset);
const int glyphOriginX = drawOffset - glyphLeft;
if (glyphWidth <= 0 || rawHeight <= 0)
return;
assert(glyphWidth <= kAmigaFontScratchWidth);
assert(rawHeight <= kAmigaFontScratchHeight);
byte glyphPixels[kAmigaFontScratchWidth * kAmigaFontScratchHeight];
memset(glyphPixels, 0, sizeof(glyphPixels));
Surface glyphSurface;
glyphSurface.init(glyphWidth, rawHeight, glyphWidth, glyphPixels, PixelFormat::createFormatCLUT8());
drawChar(&glyphSurface, chr, glyphOriginX, 0, 1);
for (int srcY = 0; srcY < rawHeight; ++srcY) {
for (int srcX = 0; srcX < glyphWidth; ++srcX) {
if (glyphPixels[srcY * glyphWidth + srcX] == 0)
continue;
const int dstX = x + glyphLeft + srcX;
if (dstX < 0 || dstX >= dst->w)
continue;
for (int repeat = 0; repeat < 2; ++repeat) {
const int dstY = y + srcY * 2 + repeat;
if (dstY >= 0 && dstY < dst->h)
*(byte *)dst->getBasePtr(dstX, dstY) = color;
}
}
}
}
void AmigaFont::drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const {
chr = mapChar(chr);
+2 -1
View File
@@ -88,7 +88,7 @@ public:
* Create font in Amiga format.
*
* @param stream Stream with the font data. If NULL, then the built-in
* Topaz font is used.
* Topaz 8 font is used.
*/
AmigaFont(Common::SeekableReadStream *stream = NULL);
AmigaFont(Topaz9Builtin);
@@ -102,6 +102,7 @@ public:
int getCharDrawOffset(uint32 chr) const;
int getCharInkWidth(uint32 chr) const;
int getCharRenderWidth(uint32 chr) const;
void drawCharDoubleHeight(Surface *dst, uint32 chr, int x, int y, uint32 color) const;
virtual void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const;
int getLoChar() const { return _font->_loChar; }