aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/frotz
diff options
context:
space:
mode:
authorPaul Gilbert2019-08-16 17:53:57 -0700
committerPaul Gilbert2019-08-16 18:26:27 -0700
commit45de5828df011a7dc33b6da3bb73324ac067eab2 (patch)
treee16128ab4e1b0c26e8d202fed87bf517f083890f /engines/glk/frotz
parent5c5814d544220d5539691a87fa764e354a610e88 (diff)
downloadscummvm-rg350-45de5828df011a7dc33b6da3bb73324ac067eab2.tar.gz
scummvm-rg350-45de5828df011a7dc33b6da3bb73324ac067eab2.tar.bz2
scummvm-rg350-45de5828df011a7dc33b6da3bb73324ac067eab2.zip
GLK: FROTZ: Proper pixel precision for V5+
Diffstat (limited to 'engines/glk/frotz')
-rw-r--r--engines/glk/frotz/glk_interface.cpp47
-rw-r--r--engines/glk/frotz/glk_interface.h5
-rw-r--r--engines/glk/frotz/processor.cpp1
-rw-r--r--engines/glk/frotz/processor_text.cpp2
-rw-r--r--engines/glk/frotz/windows.cpp55
5 files changed, 53 insertions, 57 deletions
diff --git a/engines/glk/frotz/glk_interface.cpp b/engines/glk/frotz/glk_interface.cpp
index 1e51933669..6f1f36e28d 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 67f0a86813..7f76eb6434 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 b253510d79..22ea530b64 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 c56524aca6..97957aca59 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 738bb43e2d..6fe67363be 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);
}
}