[Scummvm-git-logs] scummvm master -> e655c50d17fdaea56567226187d0bf389047811a

dreammaster paulfgilbert at gmail.com
Sat Jan 5 03:05:12 CET 2019


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

Summary:
18768f164a GLK: FROTZ: Cleanup of image drawing code
e655c50d17 GLK: FROTZ: Simplified getting/setting window properties


Commit: 18768f164a35d1d0d25da20f55c70f2c0d306b47
    https://github.com/scummvm/scummvm/commit/18768f164a35d1d0d25da20f55c70f2c0d306b47
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-01-04T17:12:30-08:00

Commit Message:
GLK: FROTZ: Cleanup of image drawing code

Changed paths:
    engines/glk/frotz/glk_interface.cpp
    engines/glk/frotz/glk_interface.h
    engines/glk/frotz/processor_windows.cpp
    engines/glk/picture.cpp


diff --git a/engines/glk/frotz/glk_interface.cpp b/engines/glk/frotz/glk_interface.cpp
index d6059ff..ef1917b 100644
--- a/engines/glk/frotz/glk_interface.cpp
+++ b/engines/glk/frotz/glk_interface.cpp
@@ -489,25 +489,20 @@ void GlkInterface::showBeyondZorkTitle() {
 	int saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
 
 	if (saveSlot == -1) {
-		uint winW, winH, imgW, imgH;
 		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::Rect(0, 0, winW, winH));
-			_events->waitForPress();
-		}
+		glk_image_draw_scaled(win, 1, 0, 0, g_vm->_screen->w, g_vm->_screen->h);
 
+		_events->waitForPress();
 		glk_window_close(win, nullptr);
 	}
 }
 
-void GlkInterface::os_draw_picture(int picture, winid_t win, const Common::Point &pos) {
-	glk_image_draw(win, picture, pos.x - 1, pos.y - 1);
+void GlkInterface::os_draw_picture(int picture, const Common::Point &pos) {
+	glk_image_draw(_wp._background, 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());
+void GlkInterface::os_draw_picture(int picture, const Common::Rect &r) {
+	glk_image_draw_scaled(_wp._background, picture, r.left, r.top, r.width(), r.height());
 }
 
 zchar GlkInterface::os_read_key(int timeout, bool show_cursor) {
diff --git a/engines/glk/frotz/glk_interface.h b/engines/glk/frotz/glk_interface.h
index 5027edb..d380801 100644
--- a/engines/glk/frotz/glk_interface.h
+++ b/engines/glk/frotz/glk_interface.h
@@ -171,12 +171,12 @@ protected:
 	/**
 	 * Display a picture at the given coordinates. Top left is (1,1).
 	 */
-	void os_draw_picture(int picture, winid_t win, const Common::Point &pos);
+	void os_draw_picture(int picture, const Common::Point &pos);
 
 	/**
 	 * Display a picture using the specified bounds
 	 */
-	void os_draw_picture(int picture, winid_t win, const Common::Rect &r);
+	void os_draw_picture(int picture, const Common::Rect &r);
 
 	/**
 	 * Call the IO interface to play a sample.
diff --git a/engines/glk/frotz/processor_windows.cpp b/engines/glk/frotz/processor_windows.cpp
index 74ffdcc..9842368 100644
--- a/engines/glk/frotz/processor_windows.cpp
+++ b/engines/glk/frotz/processor_windows.cpp
@@ -48,21 +48,19 @@ void Processor::z_draw_picture() {
 
 	flush_buffer();
 
+	Window &win = _wp[cwin];
 	if (!x || !y) {
-		// Currently I only support getting the cursor for the text grid area
-		assert(cwin == 1);
-		winid_t win = _wp._upper;
-		Point cursPos = win->getCursor();
+
 		// use cursor column if x-coordinate is 0
 		if (!x)
-			x = cursPos.x;
+			x = win[X_CURSOR];
 		// use cursor line if y-coordinate is 0
 		if (!y)
-			y = cursPos.y;
+			y = win[Y_CURSOR];
 	}
 
-//	y += cwp->y_pos - 1;
-//	x += cwp->x_pos - 1;
+	y += win[Y_POS] - 1;
+	x += win[X_POS] - 1;
 
 	/* The following is necessary to make Amiga and Macintosh story
 	 * files work with MCGA graphics files.  Some screen-filling
@@ -83,18 +81,18 @@ void Processor::z_draw_picture() {
 			if (_storyId == ARTHUR && pic == 54)
 			delta = h_screen_width / 160;
 
-			os_draw_picture(mapper[i].pic1, _wp._lower, Point(x + delta, y + height1));
-			os_draw_picture(mapper[i].pic2, _wp._lower, Point(x + width1 - width2 - delta, y + height1));
+			os_draw_picture(mapper[i].pic1, Point(x + delta, y + height1));
+			os_draw_picture(mapper[i].pic2, Point(x + width1 - width2 - delta, y + height1));
 		}
 	}
 
-	os_draw_picture(pic, _wp._lower, Point(x, y));
+	os_draw_picture(pic, Point(x, y));
 
 	if (_storyId == SHOGUN && pic == 3) {
 		uint height, width;
 
 		os_picture_data(59, &height, &width);
-		os_draw_picture(59, _wp._lower, Point(h_screen_width - width + 1, y));
+		os_draw_picture(59, Point(h_screen_width - width + 1, y));
 	}
 }
 
diff --git a/engines/glk/picture.cpp b/engines/glk/picture.cpp
index c7c8f70..2cebcb2 100644
--- a/engines/glk/picture.cpp
+++ b/engines/glk/picture.cpp
@@ -32,8 +32,10 @@ namespace Glk {
 
 void Pictures::clear() {
 	for (uint idx = 0; idx < _store.size(); ++idx) {
-		_store[idx]._picture->decrement();
-		_store[idx]._scaled->decrement();
+		if (_store[idx]._picture)
+			_store[idx]._picture->decrement();
+		if (_store[idx]._scaled)
+			_store[idx]._scaled->decrement();
 	}
 
 	_store.clear();


Commit: e655c50d17fdaea56567226187d0bf389047811a
    https://github.com/scummvm/scummvm/commit/e655c50d17fdaea56567226187d0bf389047811a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-01-04T18:04:54-08:00

Commit Message:
GLK: FROTZ: Simplified getting/setting window properties

Changed paths:
    engines/glk/frotz/processor_windows.cpp
    engines/glk/frotz/windows.cpp
    engines/glk/frotz/windows.h


diff --git a/engines/glk/frotz/processor_windows.cpp b/engines/glk/frotz/processor_windows.cpp
index 9842368..4045a97 100644
--- a/engines/glk/frotz/processor_windows.cpp
+++ b/engines/glk/frotz/processor_windows.cpp
@@ -228,14 +228,16 @@ void Processor::z_get_wind_prop() {
 }
 
 void Processor::z_put_wind_prop() {
-#ifdef TODO
 	flush_buffer();
 
-	if (zargs[1] >= 16)
+	zword win = winarg0();
+	WindowProperty prop = (WindowProperty)zargs[1];
+	zword val = zargs[2];
+
+	if (prop >= TRUE_FG_COLOR)
 		runtimeError(ERR_ILL_WIN_PROP);
 
-	((zword *)(wp + winarg0()))[zargs[1]] = zargs[2];
-#endif
+	_wp[win][prop] = val;
 }
 
 void Processor::z_scroll_window() {
diff --git a/engines/glk/frotz/windows.cpp b/engines/glk/frotz/windows.cpp
index c1a4163..54f4c4a 100644
--- a/engines/glk/frotz/windows.cpp
+++ b/engines/glk/frotz/windows.cpp
@@ -110,15 +110,18 @@ void Window::setPosition(const Point &newPos) {
 		_win->setPosition(Point((newPos.x - 1) * g_conf->_monoInfo._cellW, (newPos.y - 1) * g_conf->_monoInfo._cellH));
 }
 
-const uint16 &Window::getProperty(WindowProperty propType) {
+const zword &Window::getProperty(WindowProperty propType) {
 	if (_win)
 		update();
 
 	return _properties[propType];
 }
 
-void Window::setProperty(WindowProperty propType, uint16 value) {
-	// TODO
+void Window::setProperty(WindowProperty propType, zword value) {
+	switch (propType) {
+	default:
+		warning("Setting window property %d not yet supported", (int)propType);
+	}
 }
 
 void Window::checkRepositionLower() {
diff --git a/engines/glk/frotz/windows.h b/engines/glk/frotz/windows.h
index 56e0f99..001fb50 100644
--- a/engines/glk/frotz/windows.h
+++ b/engines/glk/frotz/windows.h
@@ -24,6 +24,7 @@
 #define GLK_FROTZ_WINDOWS
 
 #include "glk/windows.h"
+#include "glk/frotz/frotz_types.h"
 
 namespace Glk {
 namespace Frotz {
@@ -45,20 +46,49 @@ class Windows;
  */
 class Window {
 	friend class Windows;
+
+	/**
+	 * Stub class for accessing window properties via the square brackets operator
+	 */
+	class PropertyAccessor {
+	private:
+		Window *_owner;
+		WindowProperty _prop;
+	public:
+		/**
+		 * Constructor
+		 */
+		PropertyAccessor(Window *owner, WindowProperty prop) : _owner(owner), _prop(prop) {}
+
+		/**
+		 * Get
+		 */
+		operator zword() const {
+			return _owner->getProperty(_prop);
+		}
+
+		/**
+		 * Set
+		 */
+		PropertyAccessor &operator=(zword val) {
+			_owner->setProperty(_prop, val);
+			return *this;
+		}
+	};
 private:
 	Windows *_windows;
 	winid_t _win;
-	uint16 _properties[TRUE_BG_COLOR + 1];
+	zword _properties[TRUE_BG_COLOR + 1];
 private:
 	/**
 	 * Get a property value
 	 */
-	const uint16 &getProperty(WindowProperty propType);
+	const zword &getProperty(WindowProperty propType);
 
 	/**
 	 * Set a property value
 	 */
-	void setProperty(WindowProperty propType, uint16 value);
+	void setProperty(WindowProperty propType, zword value);
 
 	/**
 	 * Called when trying to reposition or resize windows. Does special handling for the lower window
@@ -99,7 +129,7 @@ public:
 	/**
 	 * Property accessor
 	 */
-	const uint16 &operator[](WindowProperty propType) { return getProperty(propType); }
+	PropertyAccessor operator[](WindowProperty propType) { return PropertyAccessor(this, propType); }
 
 	/**
 	 * Set the window size





More information about the Scummvm-git-logs mailing list