From 1a93c1286df3469b0c3ba0f50beb94de755ddda4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 14 Oct 2021 21:52:26 -0700 Subject: [PATCH] CHEWY: Implementing character draw routines --- engines/chewy/mcga.cpp | 40 +++++++++++++++++++++++++++++------ engines/chewy/mcga.h | 3 +-- engines/chewy/mcga_grafik.cpp | 4 ---- engines/chewy/mcga_grafik.h | 2 -- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/engines/chewy/mcga.cpp b/engines/chewy/mcga.cpp index 9508598e78a..17ffbd965d2 100644 --- a/engines/chewy/mcga.cpp +++ b/engines/chewy/mcga.cpp @@ -326,20 +326,46 @@ void vors() { fontY = fvory; } -void zoom_img(byte *source, byte *dest, int16 xdiff_, int16 ydiff_) { - warning("STUB - zoom_img"); -} - void zoom_set(byte *source, int16 x, int16 y, int16 xdiff_, int16 ydiff_, int16 scrWidth) { warning("STUB - zoom_set"); } -void putcxy(int16 x, int16 y, char zeichen, int16 forcol, int16 backcol, int16 scrWidth) { - warning("STUB - putcxy"); +void putcxy(int16 x, int16 y, char c, int16 fgCol, int16 bgCol, int16 scrWidth) { + size_t charSize = (fontWidth / 8) * fontHeight; + byte *charSrcP = fontAddr + (c - fontFirst) * charSize; + + byte *destP; + int width; + if (scrWidth != 0) { + destP = screenP + (y * scrWidth) + x; + } else { + destP = screenP + (y * scrWidth) + x; + scrWidth = SCREEN_WIDTH; + } + + for (int y = 0; y < fontHeight; ++y, destP += scrWidth) { + byte *destLineP = destP; + + for (int byteCtr = 0, bits = *charSrcP++; + byteCtr < (fontWidth / 8); + bits = *charSrcP++) { + // Iterate through the 8 bits + for (int x = 0; x < 8; ++x, ++destLineP, bits <<= 1) { + if (bits & 0x80) + *destLineP = fgCol; + else + *destLineP = bgCol; + } + } + } + + if (screenP == (byte *)g_screen->getPixels()) + g_screen->addDirtyRect(Common::Rect( + x, y, x + fontWidth, y + fontHeight)); } void putz(char c, int16 fgCol, int16 bgCol, int16 scrWidth) { - warning("STUB - putz"); + putcxy(gcurx, gcury, c, fgCol, bgCol, scrWidth); } void init_svga(VesaInfo *vi_, byte *virt_screen) { diff --git a/engines/chewy/mcga.h b/engines/chewy/mcga.h index 622ad843849..93b008de70f 100644 --- a/engines/chewy/mcga.h +++ b/engines/chewy/mcga.h @@ -72,8 +72,7 @@ void zoom_img(byte *source, byte *dest, int16 xdiff, int16 ydiff); void zoom_set(byte *source, int16 x, int16 y, int16 xdiff, int16 ydiff, int16 scrWidth); -void putcxy(int16 x, int16 y, char zeichen, int16 forcol, - int16 backcol, int16 scrWidth); +void putcxy(int16 x, int16 y, char c, int16 fgCol, int16 bgCol, int16 scrWidth); void putz(char c, int16 fgCol, int16 bgCol, int16 scrWidth); void setfont(byte *addr, int16 width, int16 height, int16 first, int16 last); diff --git a/engines/chewy/mcga_grafik.cpp b/engines/chewy/mcga_grafik.cpp index aa6f1b1baea..47eab7448fe 100644 --- a/engines/chewy/mcga_grafik.cpp +++ b/engines/chewy/mcga_grafik.cpp @@ -1516,10 +1516,6 @@ int16 mcga_grafik::check_stellen_anz(char *zstring, int16 *pos, int16 stellen) { return (diff); } -void mcga_grafik::scale_image(byte *source, byte *dest, int16 xdiff_, int16 ydiff_) { - zoom_img(source, dest, xdiff_, ydiff_); -} - void mcga_grafik::scale_set(byte *sptr, int16 x, int16 y, int16 xdiff_, int16 ydiff_, int16 scrwidth) { if ((xdiff_) || (ydiff_)) zoom_set(sptr, x, y, xdiff_, ydiff_, scrwidth); diff --git a/engines/chewy/mcga_grafik.h b/engines/chewy/mcga_grafik.h index 87a1e987448..68b79f273df 100644 --- a/engines/chewy/mcga_grafik.h +++ b/engines/chewy/mcga_grafik.h @@ -124,8 +124,6 @@ public: int16 hoehe, int16 scrwidth); void blockcopy(byte *sptr, int16 x, int16 y, int16 scrwidth); void sprite_set(byte *sptr, int16 x, int16 y, int16 scrwidth); - void scale_image(byte *source, byte *dest, int16 xdiff, - int16 ydiff); void scale_set(byte *sptr, int16 x, int16 y, int16 xdiff, int16 ydiff, int16 scrwidth); void map_spr2screen(byte *sptr, int16 x, int16 y);