aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2018-11-24 16:53:04 -0800
committerPaul Gilbert2018-12-08 19:05:59 -0800
commit77468312de507fcd7e01c95f1135afc33a6f4b24 (patch)
treed9ff037883a24a045c4079267d6854510f2e473f /engines
parent62af5ea8919a5148154413eaec80a9e686d64114 (diff)
downloadscummvm-rg350-77468312de507fcd7e01c95f1135afc33a6f4b24.tar.gz
scummvm-rg350-77468312de507fcd7e01c95f1135afc33a6f4b24.tar.bz2
scummvm-rg350-77468312de507fcd7e01c95f1135afc33a6f4b24.zip
GLK: FROTZ: Beyond Zork title screen now showing
Diffstat (limited to 'engines')
-rw-r--r--engines/glk/frotz/glk_interface.cpp22
-rw-r--r--engines/glk/frotz/glk_interface.h5
-rw-r--r--engines/glk/frotz/pics_decoder.cpp20
-rw-r--r--engines/glk/picture.cpp31
-rw-r--r--engines/glk/window_graphics.cpp5
5 files changed, 58 insertions, 25 deletions
diff --git a/engines/glk/frotz/glk_interface.cpp b/engines/glk/frotz/glk_interface.cpp
index c046bb4d1e..c2d6ca2703 100644
--- a/engines/glk/frotz/glk_interface.cpp
+++ b/engines/glk/frotz/glk_interface.cpp
@@ -165,13 +165,11 @@ void GlkInterface::initialize() {
h_interpreter_number = h_version == 6 ? INTERP_MSDOS : INTERP_AMIGA;
h_interpreter_version = 'F';
- {
- // Set these per spec 8.3.2.
- h_default_foreground = WHITE_COLOUR;
- h_default_background = BLACK_COLOUR;
- if (h_flags & COLOUR_FLAG)
- h_flags &= ~COLOUR_FLAG;
- }
+ // Set these per spec 8.3.2.
+ h_default_foreground = WHITE_COLOUR;
+ h_default_background = BLACK_COLOUR;
+ if (h_flags & COLOUR_FLAG)
+ h_flags &= ~COLOUR_FLAG;
/*
* Open the windows
@@ -451,11 +449,11 @@ void GlkInterface::gos_cancel_pending_line() {
void GlkInterface::showBeyondZorkTitle() {
uint winW, winH, imgW, imgH;
- winid_t win = glk_window_open(0, 0, 0, wintype_TextGrid, 0);
- glk_window_get_size(gos_lower, &winW, &winH);
+ winid_t win = glk_window_open(0, 0, 0, wintype_Graphics, 0);
+ glk_window_get_size(win, &winW, &winH);
if (os_picture_data(1, &imgW, &imgH)) {
- os_draw_picture(1, win, Common::Point(1, 1));
+ os_draw_picture(1, win, Common::Rect(0, 0, winW, winH));
_events->waitForPress();
}
@@ -466,6 +464,10 @@ void GlkInterface::os_draw_picture(int picture, winid_t win, const Common::Point
glk_image_draw(win, picture, pos.x - 1, pos.y - 1);
}
+void GlkInterface::os_draw_picture(int picture, winid_t win, const Common::Rect &r) {
+ glk_image_draw_scaled(win, picture, r.left, r.top, r.width(), r.height());
+}
+
zchar GlkInterface::os_read_key(int timeout, bool show_cursor) {
event_t ev;
winid_t win = gos_curwin ? gos_curwin : gos_lower;
diff --git a/engines/glk/frotz/glk_interface.h b/engines/glk/frotz/glk_interface.h
index b279ec87a3..4e531ee40b 100644
--- a/engines/glk/frotz/glk_interface.h
+++ b/engines/glk/frotz/glk_interface.h
@@ -169,6 +169,11 @@ protected:
void os_draw_picture(int picture, winid_t win, const Common::Point &pos);
/**
+ * Display a picture using the specified bounds
+ */
+ void os_draw_picture(int picture, winid_t win, const Common::Rect &r);
+
+ /**
* Call the IO interface to play a sample.
*/
void start_sample(int number, int volume, int repeats, zword eos);
diff --git a/engines/glk/frotz/pics_decoder.cpp b/engines/glk/frotz/pics_decoder.cpp
index dbe8aed627..d601874ca5 100644
--- a/engines/glk/frotz/pics_decoder.cpp
+++ b/engines/glk/frotz/pics_decoder.cpp
@@ -42,8 +42,8 @@ Common::SeekableReadStream *PictureDecoder::decode(Common::ReadStream &src, uint
Common::MemoryWriteStreamDynamic out(DisposeAfterUse::NO);
byte buf[512];
byte transparent;
-// int colour_shift;
-// int first_colour;
+ int colour_shift;
+ int first_colour;
int code, prev_code = 0;
int next_entry;
int bits_per_code;
@@ -66,7 +66,7 @@ Common::SeekableReadStream *PictureDecoder::decode(Common::ReadStream &src, uint
* Colours 0 and 1 were used for text; changing the text colours actually changed
* palette entries 0 and 1. This interface uses the same trick in Amiga mode.)
*/
-/*
+
switch (display) {
case CGA:
colour_shift = -2;
@@ -85,7 +85,11 @@ Common::SeekableReadStream *PictureDecoder::decode(Common::ReadStream &src, uint
default:
break;
}
- */
+
+ // Note: we don't actually use paletted indexes, so adjust colour_shift
+ // relative to first_colour
+ colour_shift -= first_colour;
+
out.writeUint16LE(palette.size() / 3);
if (!palette.empty())
out.write(&palette[0], palette.size());
@@ -162,6 +166,12 @@ next_code:
if (code == 0)
goto reset_table;
if (code == 1) {
+ bool t[256];
+ // *******DEBUG*******
+ Common::fill(&t[0], &t[256], false);
+ for (uint idx = 0; idx < out.size(); ++idx)
+ t[*((byte *)out.getData() + idx)] = true;
+
return new Common::MemoryReadStream(out.getData(), out.size(), DisposeAfterUse::YES);
}
@@ -217,7 +227,7 @@ reverse_buffer:
byte v = code;
if (v != transparent) {
- //v += colour_shift;
+ v += colour_shift;
if (display != MCGA) {
// TODO
diff --git a/engines/glk/picture.cpp b/engines/glk/picture.cpp
index c8dcbc5462..34043152a5 100644
--- a/engines/glk/picture.cpp
+++ b/engines/glk/picture.cpp
@@ -106,6 +106,7 @@ Picture *Pictures::load(uint32 id) {
RawDecoder raw;
const Graphics::Surface *img;
const byte *palette = nullptr;
+ int palCount = 0;
Picture *pic;
// Check if the picture is already in the store
@@ -114,30 +115,46 @@ Picture *Pictures::load(uint32 id) {
return pic;
Common::File f;
- if (f.open(Common::String::format("PIC%u.png", id))) {
+ if (f.open(Common::String::format("pic%u.png", id))) {
png.loadStream(f);
img = png.getSurface();
palette = png.getPalette();
- } else if (f.open(Common::String::format("PIC%u.jpg", id))) {
+ palCount = png.getPaletteColorCount();
+ } else if (f.open(Common::String::format("pic%u.jpg", id))) {
jpg.loadStream(f);
img = jpg.getSurface();
- } else if (f.open(Common::String::format("PIC%u.raw", id))) {
+ } else if (f.open(Common::String::format("pic%u.raw", id))) {
raw.loadStream(f);
img = raw.getSurface();
palette = raw.getPalette();
+ palCount = raw.getPaletteColorCount();
} else {
// No such picture
return nullptr;
}
- pic = new Picture(img->w, img->h, img->format);
+ pic = new Picture(img->w, img->h, g_system->getScreenFormat());
pic->_refCount = 1;
pic->_id = id;
pic->_scaled = false;
- pic->blitFrom(*img);
- if (palette)
- pic->convertToInPlace(g_system->getScreenFormat(), palette);
+ if (!palette) {
+ pic->blitFrom(*img);
+ } else {
+ uint pal[256];
+ for (uint idx = 0; idx < palCount; ++idx)
+ pal[idx] = pic->format.RGBToColor(palette[idx * 3],
+ palette[idx * 3 + 1], palette[idx * 3 + 2]);
+
+ byte *srcP = (byte *)img->getPixels(), *destP = (byte *)pic->getPixels();
+ for (int idx = 0; idx < img->w * img->h; ++idx, srcP++, destP += pic->format.bytesPerPixel) {
+ uint val = (*srcP >= palCount) ? 0 : pal[*srcP];
+ if (pic->format.bytesPerPixel == 2)
+ WRITE_LE_UINT16(destP, val);
+ else
+ WRITE_LE_UINT32(destP, val);
+ }
+ }
store(pic);
return pic;
diff --git a/engines/glk/window_graphics.cpp b/engines/glk/window_graphics.cpp
index 92224b6a4d..7343d51607 100644
--- a/engines/glk/window_graphics.cpp
+++ b/engines/glk/window_graphics.cpp
@@ -62,8 +62,7 @@ void GraphicsWindow::rearrange(const Rect &box) {
if (newhgt < bothhgt)
bothhgt = newhgt;
- newSurface = new Graphics::ManagedSurface(newwid, newhgt,
- Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0));
+ newSurface = new Graphics::ManagedSurface(newwid, newhgt, g_system->getScreenFormat());
// If the new surface is equal or bigger than the old one, copy it over
if (_surface && bothwid && bothhgt)
@@ -231,7 +230,7 @@ void GraphicsWindow::drawPicture(Picture *src, int x0, int y0, int width, int h
w = sx1 - sx0;
h = sy1 - sy0;
- _surface->blitFrom(*g_vm->_screen, Rect(sx0, sy0, sx0 + w, sy0 + h), Point(0, 0));
+ _surface->blitFrom(*src, Rect(sx0, sy0, sx0 + w, sy0 + h), Point(0, 0));
}
void GraphicsWindow::getSize(glui32 *width, glui32 *height) const {