[Scummvm-git-logs] scummvm master -> 3e218edde3f1ef90c3118157fc0f11dc50c19be2

dreammaster paulfgilbert at gmail.com
Fri Aug 7 02:51:31 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
3e218edde3 GLK: MAGNETIC: Fix image display


Commit: 3e218edde3f1ef90c3118157fc0f11dc50c19be2
    https://github.com/scummvm/scummvm/commit/3e218edde3f1ef90c3118157fc0f11dc50c19be2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-08-06T19:50:21-07:00

Commit Message:
GLK: MAGNETIC: Fix image display

Changed paths:
    engines/glk/magnetic/emu.cpp
    engines/glk/magnetic/glk.cpp
    engines/glk/magnetic/magnetic.cpp


diff --git a/engines/glk/magnetic/emu.cpp b/engines/glk/magnetic/emu.cpp
index 1c92054642..bb2b34dd2d 100644
--- a/engines/glk/magnetic/emu.cpp
+++ b/engines/glk/magnetic/emu.cpp
@@ -164,7 +164,8 @@ type8 Magnetic::init_gfx1(type8 *header) {
 #ifdef SAVEMEM
 	if (!(gfx_data = (type8 *)malloc(128))) {
 #else
-	if (!(gfx_data = (type8 *)malloc(read_l(header + 4) - 8))) {
+	size_t dataSize = read_l(header + 4) - 8;
+	if (!(gfx_data = (type8 *)malloc(dataSize))) {
 #endif
 		free(gfx_buf);
 		delete gfx_fp;
@@ -175,7 +176,7 @@ type8 Magnetic::init_gfx1(type8 *header) {
 #ifdef SAVEMEM
 	if (!fp.read(gfx_data, 128, 1, gfx_fp)) {
 #else
-	if (gfx_fp->read(gfx_data, read_l(header + 4)) != read_l(header + 4)) {
+	if (gfx_fp->read(gfx_data, dataSize) != dataSize) {
 #endif
 		free(gfx_data);
 		free(gfx_buf);
diff --git a/engines/glk/magnetic/glk.cpp b/engines/glk/magnetic/glk.cpp
index 68a7a3e692..37cbc5c3ed 100644
--- a/engines/glk/magnetic/glk.cpp
+++ b/engines/glk/magnetic/glk.cpp
@@ -465,11 +465,8 @@ void Magnetic::gms_graphics_split_color(glui32 color, gms_rgbref_t rgb_color) {
 }
 
 glui32 Magnetic::gms_graphics_combine_color(gms_rgbref_t rgb_color) {
-	glui32 color;
-	assert(rgb_color);
-
-	color = (rgb_color->red << 16) | (rgb_color->green << 8) | rgb_color->blue;
-	return color;
+	assert(rgb_color && _screen->format.bytesPerPixel == 2);
+	return  _screen->format.RGBToColor(rgb_color->red, rgb_color->green, rgb_color->blue);
 }
 
 int Magnetic::gms_graphics_color_luminance(gms_rgbref_t rgb_color) {
@@ -1083,19 +1080,22 @@ break_y_max:
 void Magnetic::gms_graphics_paint_everything(winid_t glk_window,
         glui32 palette[], type8 off_screen[], int x_offset, int y_offset,
         type16 width, type16 height) {
-	type8       pixel;          /* Reference pixel color */
-	int     x, y;
+	type16 x, y;
+	glui32 pixel;
+
+	Graphics::ManagedSurface s(width, height, _screen->format);
 
 	for (y = 0; y < height; y++) {
-		for (x = 0; x < width; x ++) {
-			pixel = off_screen[ y * width + x ];
-			glk_window_fill_rect(glk_window,
-			                           palette[ pixel ],
-			                           x * GMS_GRAPHICS_PIXEL + x_offset,
-			                           y * GMS_GRAPHICS_PIXEL + y_offset,
-			                           GMS_GRAPHICS_PIXEL, GMS_GRAPHICS_PIXEL);
+		uint16 *lineP = (uint16 *)s.getBasePtr(0, y);
+
+		for (x = 0; x < width; ++x, ++lineP) {
+			pixel = palette[off_screen[y * width + x]];
+			*lineP = pixel;
 		}
 	}
+
+	glk_image_draw_scaled(glk_window, s, (uint)-1, x_offset, y_offset,
+		width * GMS_GRAPHICS_PIXEL, height * GMS_GRAPHICS_PIXEL);
 }
 
 void Magnetic::gms_graphics_timeout() {
diff --git a/engines/glk/magnetic/magnetic.cpp b/engines/glk/magnetic/magnetic.cpp
index 4ddeec0b8c..2822053356 100644
--- a/engines/glk/magnetic/magnetic.cpp
+++ b/engines/glk/magnetic/magnetic.cpp
@@ -32,7 +32,7 @@ Magnetic *g_vm;
 Magnetic::Magnetic(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc),
 		gms_gamma_mode(GAMMA_NORMAL), gms_animation_enabled(true),
 		gms_prompt_enabled(true), gms_abbreviations_enabled(true), gms_commands_enabled(true),
-		gms_graphics_enabled(false), GMS_PORT_VERSION(0x00010601),
+		gms_graphics_enabled(true), GMS_PORT_VERSION(0x00010601),
 		gms_main_window(nullptr), gms_status_window(nullptr), gms_graphics_window(nullptr),
 		gms_hint_menu_window(nullptr), gms_hint_text_window(nullptr),
 		gms_transcript_stream(nullptr), gms_readlog_stream(nullptr),




More information about the Scummvm-git-logs mailing list