aboutsummaryrefslogtreecommitdiff
path: root/engines/glk
diff options
context:
space:
mode:
authorPaul Gilbert2019-01-01 22:40:32 -0800
committerPaul Gilbert2019-01-01 22:40:32 -0800
commitc02d1f543282a5fe277302700c53e63a1213c319 (patch)
tree1111cb3e7f88fe4ff7a9430d4e9b3fe373a9cf65 /engines/glk
parentb4c3df62e32e0c25001b8149bbd8311b54f953f0 (diff)
downloadscummvm-rg350-c02d1f543282a5fe277302700c53e63a1213c319.tar.gz
scummvm-rg350-c02d1f543282a5fe277302700c53e63a1213c319.tar.bz2
scummvm-rg350-c02d1f543282a5fe277302700c53e63a1213c319.zip
GLK: FROTZ: Beginnings of setting window positions and size
Diffstat (limited to 'engines/glk')
-rw-r--r--engines/glk/frotz/processor_windows.cpp20
-rw-r--r--engines/glk/frotz/windows.cpp45
-rw-r--r--engines/glk/frotz/windows.h28
3 files changed, 73 insertions, 20 deletions
diff --git a/engines/glk/frotz/processor_windows.cpp b/engines/glk/frotz/processor_windows.cpp
index 7b042d9c93..f0f6ffaa66 100644
--- a/engines/glk/frotz/processor_windows.cpp
+++ b/engines/glk/frotz/processor_windows.cpp
@@ -178,35 +178,19 @@ void Processor::z_set_margins() {
}
void Processor::z_move_window(void) {
-#ifdef TODO
zword win = winarg0();
flush_buffer();
- wp[win].y_pos = zargs[1];
- wp[win].x_pos = zargs[2];
-
- if (win == cwin)
- update_cursor();
-#endif
+ _wp[win].setPosition(Point(zargs[2], zargs[1]));
}
void Processor::z_window_size() {
-#ifdef TODO
zword win = winarg0();
flush_buffer();
- wp[win].y_size = zargs[1];
- wp[win].x_size = zargs[2];
-
- /* Keep the cursor within the window */
-
- if (wp[win].y_cursor > zargs[1] || wp[win].x_cursor > zargs[2])
- reset_cursor(win);
-
- os_window_height(win, wp[win].y_size);
-#endif
+ _wp[win].setSize(Point(zargs[2], zargs[1]));
}
void Processor::z_window_style() {
diff --git a/engines/glk/frotz/windows.cpp b/engines/glk/frotz/windows.cpp
index e30f61ebdf..fdcfcf16b1 100644
--- a/engines/glk/frotz/windows.cpp
+++ b/engines/glk/frotz/windows.cpp
@@ -21,17 +21,60 @@
*/
#include "glk/frotz/windows.h"
+#include "glk/frotz/frotz.h"
namespace Glk {
namespace Frotz {
Windows::Windows() : _lower(_windows[0]), _upper(_windows[1]) {
+ for (size_t idx = 0; idx < 8; ++idx)
+ _windows[idx]._windows = this;
+}
+
+size_t Windows::size() const {
+ return (g_vm->h_version < 6) ? 2 : 8;
}
Window &Windows::operator[](uint idx) {
- assert(idx < 8);
+ assert(idx < size());
return _windows[idx];
}
+/*--------------------------------------------------------------------------*/
+
+winid_t Window::getWindow() {
+ if (!_win) {
+ // Window doesn't exist, so create it
+ // TODO
+ }
+
+ return _win;
+}
+
+void Window::setSize(const Point &newSize) {
+ winid_t win = getWindow();
+
+/* TODO
+ y_size = zargs[1];
+ _wp[win].x_size = zargs[2];
+
+ // Keep the cursor within the window
+ if (wp[win].y_cursor > zargs[1] || wp[win].x_cursor > zargs[2])
+ reset_cursor(win);
+
+ os_window_height(win, _wp[win].y_size);
+ */
+}
+
+void Window::setPosition(const Point &newPos) {
+ winid_t win = getWindow();
+
+ /* TODO
+ if (win == cwin)
+ update_cursor();
+ */
+}
+
+
} // End of namespace Frotz
} // End of namespace Glk
diff --git a/engines/glk/frotz/windows.h b/engines/glk/frotz/windows.h
index e685c4faf4..c94a1edce3 100644
--- a/engines/glk/frotz/windows.h
+++ b/engines/glk/frotz/windows.h
@@ -29,13 +29,23 @@ namespace Glk {
namespace Frotz {
#include "glk/windows.h"
+#include "glk/utils.h"
+
+class Windows;
/**
* Represents one of the virtual windows
*/
class Window {
+ friend class Windows;
private:
+ Windows *_windows;
winid_t _win;
+private:
+ /**
+ * Gets a reference to the window, creating a new one if one doesn't already exist
+ */
+ winid_t getWindow();
public:
/**
* Constructor
@@ -69,10 +79,21 @@ public:
* 4 y cursor 10 text style 16 true foreground colour
* 5 x cursor 11 colour data 17 true background colour
*/
+ //zword &operator[](uint idx);
+
+ /**
+ * Set the window size
+ */
+ void setSize(const Point &newSize);
+
+ /**
+ * Set the position of a window
+ */
+ void setPosition(const Point &newPos);
};
/**
- * The Z-machine has 8 virtual windows
+ * Windows manager
*/
class Windows {
private:
@@ -87,6 +108,11 @@ public:
Windows();
/**
+ * Returns the number of allowable windows
+ */
+ size_t size() const;
+
+ /**
* Array access
*/
Window &operator[](uint idx);