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

dreammaster paulfgilbert at gmail.com
Sat Aug 17 03:49:38 CEST 2019


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

Summary:
5c5814d544 GLK: FROTZ: Only call Glk move cursor for Glk text grid windows
45de5828df GLK: FROTZ: Proper pixel precision for V5+
a6c5caf1fb GLK: FROTZ: Properly implement os_char_width


Commit: 5c5814d544220d5539691a87fa764e354a610e88
    https://github.com/scummvm/scummvm/commit/5c5814d544220d5539691a87fa764e354a610e88
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-08-16T18:26:27-07:00

Commit Message:
GLK: FROTZ: Only call Glk move cursor for Glk text grid windows

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


diff --git a/engines/glk/frotz/windows.cpp b/engines/glk/frotz/windows.cpp
index 9f7e691..738bb43 100644
--- a/engines/glk/frotz/windows.cpp
+++ b/engines/glk/frotz/windows.cpp
@@ -211,7 +211,8 @@ void Window::setCursor(const Point &newPos) {
 }
 
 void Window::setCursor() {
-	g_vm->glk_window_move_cursor(_win, _properties[X_CURSOR] - 1, _properties[Y_CURSOR] - 1);
+	if (dynamic_cast<TextGridWindow *>(_win))
+		g_vm->glk_window_move_cursor(_win, _properties[X_CURSOR] - 1, _properties[Y_CURSOR] - 1);
 }
 
 void Window::clear() {


Commit: 45de5828df011a7dc33b6da3bb73324ac067eab2
    https://github.com/scummvm/scummvm/commit/45de5828df011a7dc33b6da3bb73324ac067eab2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-08-16T18:26:27-07:00

Commit Message:
GLK: FROTZ: Proper pixel precision for V5+

Changed paths:
    engines/glk/frotz/glk_interface.cpp
    engines/glk/frotz/glk_interface.h
    engines/glk/frotz/processor.cpp
    engines/glk/frotz/processor_text.cpp
    engines/glk/frotz/windows.cpp


diff --git a/engines/glk/frotz/glk_interface.cpp b/engines/glk/frotz/glk_interface.cpp
index 1e51933..6f1f36e 100644
--- a/engines/glk/frotz/glk_interface.cpp
+++ b/engines/glk/frotz/glk_interface.cpp
@@ -46,8 +46,6 @@ GlkInterface::~GlkInterface() {
 }
 
 void GlkInterface::initialize() {
-	uint width, height;
-
 	/* Setup options */
 	UserOptions::initialize(h_version, _storyId);
 
@@ -123,23 +121,14 @@ void GlkInterface::initialize() {
 	 * Get the screen size
 	 */
 
-	_wp._lower = glk_window_open(0, 0, 0, wintype_TextGrid, 0);
-	if (!_wp._lower)
-		_wp._lower = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
-	glk_window_get_size(_wp._lower, &width, &height);
-	glk_window_close(_wp._lower, nullptr);
-	_wp._lower = nullptr;
-
 	gos_channel = nullptr;
 
-	h_screen_cols = width;
-	h_screen_rows = height;
-
-	h_screen_height = h_screen_rows;
-	h_screen_width = h_screen_cols;
-
-	h_font_width = 1;
-	h_font_height = 1;
+	h_screen_width = g_system->getWidth();
+	h_screen_height = g_system->getHeight();
+	h_font_width = g_conf->_monoInfo._cellW;
+	h_font_height = g_conf->_monoInfo._cellH;
+	h_screen_cols = h_screen_width / h_font_width;
+	h_screen_rows = h_screen_height / h_font_height;
 
 	// Must be after screen dimensions are computed
 	if (g_conf->_graphics) {
@@ -333,11 +322,8 @@ bool GlkInterface::os_picture_data(int picture, uint *height, uint *width) {
 		uint fullWidth, fullHeight;
 		bool result = glk_image_get_info(picture, &fullWidth, &fullHeight);
 
-		int x_scale = g_system->getWidth();
-		int y_scale = g_system->getHeight();
-
-		*width = roundDiv(fullWidth * h_screen_cols, x_scale);
-		*height = roundDiv(fullHeight * h_screen_rows, y_scale);
+		*width = fullWidth;
+		*height = fullHeight;
 
 		return result;
 	}
@@ -543,22 +529,19 @@ void GlkInterface::showBeyondZorkTitle() {
 void GlkInterface::os_draw_picture(int picture, const Common::Point &pos) {
 	if (pos.x && pos.y) {
 		_wp._background->bringToFront();
-		glk_image_draw(_wp._background, picture,
-			(pos.x - 1) * g_conf->_monoInfo._cellW,
-			(pos.y - 1) * g_conf->_monoInfo._cellH);
+		Point pt(pos.x - 1, pos.y - 1);
+		if (h_version < V5) {
+			pt.x *= g_conf->_monoInfo._cellW;
+			pt.y *= g_conf->_monoInfo._cellH;
+		}
+
+		glk_image_draw(_wp._background, picture, pt.x, pt.y);
 	} else {
 		// Picture embedded within the lower text area
 		_wp.currWin().imageDraw(picture, imagealign_MarginLeft, 0);
 	}
 }
 
-void GlkInterface::os_draw_picture(int picture, const Common::Rect &r) {
-	Point cell(g_conf->_monoInfo._cellW, g_conf->_monoInfo._cellH);
-
-	glk_image_draw_scaled(_wp._background, picture, (r.left - 1) * cell.x, (r.top - 1) * cell.y,
-		r.width() * cell.x, r.height() * cell.y);
-}
-
 int GlkInterface::os_peek_color() {
 	if (_color_enabled) {
 		return _defaultBackground;
diff --git a/engines/glk/frotz/glk_interface.h b/engines/glk/frotz/glk_interface.h
index 67f0a86..7f76eb6 100644
--- a/engines/glk/frotz/glk_interface.h
+++ b/engines/glk/frotz/glk_interface.h
@@ -176,11 +176,6 @@ protected:
 	void os_draw_picture(int picture, const Common::Point &pos);
 
 	/**
-	 * Display a picture using the specified bounds
-	 */
-	void os_draw_picture(int picture, const Common::Rect &r);
-
-	/**
 	 * Return the colour of the pixel below the cursor. This is used by V6 games to print
 	 * text on top of pictures. The coulor need not be in the standard set of Z-machine colours.
 	 */
diff --git a/engines/glk/frotz/processor.cpp b/engines/glk/frotz/processor.cpp
index b253510..22ea530 100644
--- a/engines/glk/frotz/processor.cpp
+++ b/engines/glk/frotz/processor.cpp
@@ -246,6 +246,7 @@ void Processor::load_all_operands(zbyte specifier) {
 void Processor::interpret() {
 	do {
 		zbyte opcode;
+//		debug("%.6x", pcp - zmp);
 		CODE_BYTE(opcode);
 		zargc = 0;
 
diff --git a/engines/glk/frotz/processor_text.cpp b/engines/glk/frotz/processor_text.cpp
index c56524a..97957ac 100644
--- a/engines/glk/frotz/processor_text.cpp
+++ b/engines/glk/frotz/processor_text.cpp
@@ -839,7 +839,7 @@ void Processor::z_print_addr() {
 }
 
 void Processor::z_print_char() {
-	print_char (translate_from_zscii(zargs[0]));
+	print_char(translate_from_zscii(zargs[0]));
 }
 
 void Processor::z_print_form() {
diff --git a/engines/glk/frotz/windows.cpp b/engines/glk/frotz/windows.cpp
index 738bb43..6fe6736 100644
--- a/engines/glk/frotz/windows.cpp
+++ b/engines/glk/frotz/windows.cpp
@@ -53,8 +53,8 @@ void Windows::setup(bool isVersion6) {
 		_background->setBackgroundColor(0xffffff);
 
 		Window &w = _windows[0];
-		w[X_SIZE] = g_system->getWidth() / mi._cellW;
-		w[Y_SIZE] = g_system->getHeight() / mi._cellH;
+		w[X_SIZE] = g_vm->h_screen_width;
+		w[Y_SIZE] = g_vm->h_screen_height;
 	} else {
 		_lower = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
 		_upper = g_vm->glk_window_open(_lower, winmethod_Above | winmethod_Fixed, 0, wintype_TextGrid, 0);
@@ -114,22 +114,24 @@ Window::Window() : _windows(nullptr), _win(nullptr), _quotes(0), _dashes(0), _sp
 
 void Window::update() {
 	assert(_win);
+	int cellW = (g_vm->h_version < V5) ? g_vm->h_font_width : 1;
+	int cellH = (g_vm->h_version < V5) ? g_vm->h_font_height : 1;
 
-	_properties[X_POS] = _win->_bbox.left / g_conf->_monoInfo._cellW + 1;
-	_properties[Y_POS] = _win->_bbox.top / g_conf->_monoInfo._cellH + 1;
-	_properties[X_SIZE] = _win->_bbox.width() / g_conf->_monoInfo._cellW;
-	_properties[Y_SIZE] = _win->_bbox.height() / g_conf->_monoInfo._cellH;
+	_properties[X_POS] = _win->_bbox.left / cellW + 1;
+	_properties[Y_POS] = _win->_bbox.top / cellH + 1;
+	_properties[X_SIZE] = _win->_bbox.width() / cellW;
+	_properties[Y_SIZE] = _win->_bbox.height() / cellH;
 
 	Point pt = _win->getCursor();
-	_properties[X_CURSOR] = (g_vm->h_version != V6) ? pt.x + 1 : pt.x / g_conf->_monoInfo._cellW + 1;
-	_properties[Y_CURSOR] = (g_vm->h_version != V6) ? pt.y + 1 : pt.y / g_conf->_monoInfo._cellH + 1;
+	_properties[X_CURSOR] = (g_vm->h_version != V6) ? pt.x + 1 : pt.x / cellW + 1;
+	_properties[Y_CURSOR] = (g_vm->h_version != V6) ? pt.y + 1 : pt.y / cellH + 1;
 
 	TextBufferWindow *win = dynamic_cast<TextBufferWindow *>(_win);
-	_properties[LEFT_MARGIN] = (win ? win->_ladjw : 0) / g_conf->_monoInfo._cellW;
-	_properties[RIGHT_MARGIN] = (win ? win->_radjw : 0) / g_conf->_monoInfo._cellW;
+	_properties[LEFT_MARGIN] = (win ? win->_ladjw : 0) / cellW;
+	_properties[RIGHT_MARGIN] = (win ? win->_radjw : 0) / cellW;
 	_properties[FONT_SIZE] = (g_conf->_monoInfo._cellH << 8) | g_conf->_monoInfo._cellW;
 }
-
+ 
 Window &Window::operator=(winid_t win) {
 	_win = win;
 
@@ -165,8 +167,15 @@ void Window::setSize(const Point &newSize) {
 }
 
 void Window::setSize() {
-	if (_win)
-		_win->setSize(Point(_properties[X_SIZE] * g_conf->_monoInfo._cellW, _properties[Y_SIZE] * g_conf->_monoInfo._cellH));
+	if (_win) {
+		Point newSize(_properties[X_SIZE], _properties[Y_SIZE]);
+		if (g_vm->h_version < V5) {
+			newSize.x *= g_conf->_monoInfo._cellW;
+			newSize.y *= g_conf->_monoInfo._cellH;
+		}
+
+		_win->setSize(newSize);
+	}
 }
 
 void Window::setPosition(const Point &newPos) {
@@ -179,8 +188,15 @@ void Window::setPosition(const Point &newPos) {
 }
 
 void Window::setPosition() {
-	if (_win)
-		_win->setPosition(Point((_properties[X_POS] - 1) * g_conf->_monoInfo._cellW, (_properties[Y_POS] - 1) * g_conf->_monoInfo._cellH));
+	if (_win) {
+		Point newPos(_properties[X_POS] - 1, _properties[Y_POS] - 1);
+		if (g_vm->h_version < V5) {
+			newPos.x *= g_conf->_monoInfo._cellW;
+			newPos.y *= g_conf->_monoInfo._cellH;
+		}
+
+		_win->setPosition(newPos);
+	}
 }
 
 void Window::setCursor(const Point &newPos) {
@@ -211,8 +227,10 @@ void Window::setCursor(const Point &newPos) {
 }
 
 void Window::setCursor() {
-	if (dynamic_cast<TextGridWindow *>(_win))
-		g_vm->glk_window_move_cursor(_win, _properties[X_CURSOR] - 1, _properties[Y_CURSOR] - 1);
+	if (dynamic_cast<TextGridWindow *>(_win)) {
+		g_vm->glk_window_move_cursor(_win, (_properties[X_CURSOR] - 1) / g_vm->h_font_width,
+			(_properties[Y_CURSOR] - 1) / g_vm->h_font_height);
+	}
 }
 
 void Window::clear() {
@@ -220,8 +238,7 @@ void Window::clear() {
 		g_vm->glk_window_clear(_win);
 
 	if (_windows->_background) {
-		Rect r(_properties[X_SIZE] * g_conf->_monoInfo._cellW, _properties[Y_SIZE] * g_conf->_monoInfo._cellH);
-		r.moveTo((_properties[X_POS] - 1) * g_conf->_monoInfo._cellW, (_properties[Y_POS] - 1) * g_conf->_monoInfo._cellH);
+		Rect r = _windows->_background->_bbox;
 		_windows->_background->fillRect(g_conf->_windowColor, r);
 	}
 }


Commit: a6c5caf1fbcad5a1b096a6dc666d7bc9c9096dd0
    https://github.com/scummvm/scummvm/commit/a6c5caf1fbcad5a1b096a6dc666d7bc9c9096dd0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-08-16T18:26:27-07:00

Commit Message:
GLK: FROTZ: Properly implement os_char_width

This fixes a memory corruption in the Arthur startup

Changed paths:
    engines/glk/frotz/glk_interface.cpp
    engines/glk/frotz/processor.cpp


diff --git a/engines/glk/frotz/glk_interface.cpp b/engines/glk/frotz/glk_interface.cpp
index 6f1f36e..8bbd154 100644
--- a/engines/glk/frotz/glk_interface.cpp
+++ b/engines/glk/frotz/glk_interface.cpp
@@ -248,9 +248,7 @@ bool GlkInterface::initPictures() {
 }
 
 int GlkInterface::os_char_width(zchar z) {
-	// Note: I'm presuming this is 1 because Glk Text Grid windows take care of font sizes internally,
-	// so we can pretend that any font has a 1x1 size
-	return 1;
+	return g_conf->_monoInfo._cellW;
 }
 
 int GlkInterface::os_string_width(const zchar *s) {
diff --git a/engines/glk/frotz/processor.cpp b/engines/glk/frotz/processor.cpp
index 22ea530..b253510 100644
--- a/engines/glk/frotz/processor.cpp
+++ b/engines/glk/frotz/processor.cpp
@@ -246,7 +246,6 @@ void Processor::load_all_operands(zbyte specifier) {
 void Processor::interpret() {
 	do {
 		zbyte opcode;
-//		debug("%.6x", pcp - zmp);
 		CODE_BYTE(opcode);
 		zargc = 0;
 





More information about the Scummvm-git-logs mailing list