Permalink
Browse files

GLK: FROTZ: Beginnings of setting window positions and size

  • Loading branch information...
dreammaster committed Jan 2, 2019
1 parent b4c3df6 commit c02d1f543282a5fe277302700c53e63a1213c319
Showing with 73 additions and 20 deletions.
  1. +2 −18 engines/glk/frotz/processor_windows.cpp
  2. +44 −1 engines/glk/frotz/windows.cpp
  3. +27 −1 engines/glk/frotz/windows.h
@@ -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() {
@@ -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
@@ -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 @@ class Window {
* 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:
@@ -86,6 +107,11 @@ class Windows {
*/
Windows();

/**
* Returns the number of allowable windows
*/
size_t size() const;

/**
* Array access
*/

0 comments on commit c02d1f5

Please sign in to comment.