Skip to content

Commit

Permalink
GOT: Further fixes for Story display
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster authored and bluegr committed Jan 12, 2025
1 parent 3593a2c commit a2bb5c8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
27 changes: 14 additions & 13 deletions engines/got/gfx/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,23 @@ void Font::drawString(Graphics::ManagedSurface *src, const Common::Point &pos,
}

void Font::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const {
const Graphics::ManagedSurface &glyph = _font[chr];
// Character drawing is done twice in the original:
// first at y + 1 with color 0, then at y with the given color
rawDrawChar(dst, chr, x, y + 1, 0);
rawDrawChar(dst, chr, x, y, color);
}

// Character drawing is done twice in the original:
// first at y + 1 with color 0, then at y with the given color
for (int pass = 0; pass < 2; ++pass) {
int col = (pass == 0) ? 0 : color;
void Font::rawDrawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const {
const Graphics::ManagedSurface &glyph = _font[chr];

for (int yp = 0; yp < glyph.h; ++yp) {
int startY = y + yp + (pass == 0 ? 1 : 0);
const byte *srcP = (const byte *)glyph.getBasePtr(0, yp);
byte *destP = (byte *)dst->getBasePtr(x, startY);
for (int yp = 0; yp < glyph.h; ++yp) {
int startY = y + yp;
const byte *srcP = (const byte *)glyph.getBasePtr(0, yp);
byte *destP = (byte *)dst->getBasePtr(x, startY);

for (int xp = 0; xp < glyph.w; ++xp, ++srcP, ++destP) {
if (*srcP)
*destP = col;
}
for (int xp = 0; xp < glyph.w; ++xp, ++srcP, ++destP) {
if (*srcP)
*destP = color;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions engines/got/gfx/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Font : public Graphics::Font {
void drawChar(Graphics::ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const override {
Graphics::Font::drawChar(dst, chr, x, y, color);
}
void rawDrawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const;

void drawString(Graphics::ManagedSurface *src, const Common::Point &pos,
const Common::String &text, int color);
Expand Down
4 changes: 4 additions & 0 deletions engines/got/gfx/gfx_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ void GfxSurface::printChar(uint32 chr, int x, int y, uint32 color) {
_G(font).drawChar(this, chr, x, y, color);
}

void GfxSurface::rawPrintChar(uint32 chr, int x, int y, uint32 color) {
_G(font).rawDrawChar(surfacePtr(), chr, x, y, color);
}

} // namespace Gfx
} // namespace Got
1 change: 1 addition & 0 deletions engines/got/gfx/gfx_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class GfxSurface : public Graphics::ManagedSurface {
*/
void print(const Common::Point &pos, const Common::String &text, int color);
void printChar(uint32 chr, int x, int y, uint32 color);
void rawPrintChar(uint32 chr, int x, int y, uint32 color);
};

} // namespace Gfx
Expand Down
21 changes: 9 additions & 12 deletions engines/got/views/story.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ bool Story::msgFocus(const FocusMessage &msg) {
res_read(Common::String::format("STORY%d", _G(area)), _G(tmp_buff));

res_read("STORYPAL", _G(pbuff));
_G(pbuff)[2] = 0;
_G(pbuff)[1] = 0;
_G(pbuff)[0] = 0;

for (int i = 0; i < PALETTE_SIZE; ++i)
_G(pbuff)[i] = ((int)_G(pbuff)[i] * 255 + 31) / 63;
Expand Down Expand Up @@ -76,15 +73,15 @@ bool Story::msgFocus(const FocusMessage &msg) {
s[3] = 0;
color = atoi(s);
} else if (*p != '\r') {
_surface.printChar(*p, x - 1, y - 1, 255);
_surface.printChar(*p, x + 1, y + 1, 255);
_surface.printChar(*p, x - 1, y + 1, 255);
_surface.printChar(*p, x + 1, y - 1, 255);
_surface.printChar(*p, x, y - 1, 255);
_surface.printChar(*p, x, y + 1, 255);
_surface.printChar(*p, x - 1, y, 255);
_surface.printChar(*p, x + 1, y, 255);
_surface.printChar(*p, x, y, color);
_surface.rawPrintChar(*p, x - 1, y - 1, 255);
_surface.rawPrintChar(*p, x + 1, y + 1, 255);
_surface.rawPrintChar(*p, x - 1, y + 1, 255);
_surface.rawPrintChar(*p, x + 1, y - 1, 255);
_surface.rawPrintChar(*p, x, y - 1, 255);
_surface.rawPrintChar(*p, x, y + 1, 255);
_surface.rawPrintChar(*p, x - 1, y, 255);
_surface.rawPrintChar(*p, x + 1, y, 255);
_surface.rawPrintChar(*p, x, y, color);
x += 8;
}

Expand Down

0 comments on commit a2bb5c8

Please sign in to comment.