Skip to content

Commit

Permalink
GLK: FROTZ: Beginnings of setting window positions and size
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jan 2, 2019
1 parent b4c3df6 commit c02d1f5
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 20 deletions.
20 changes: 2 additions & 18 deletions engines/glk/frotz/processor_windows.cpp
Expand Up @@ -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() {
Expand Down
45 changes: 44 additions & 1 deletion engines/glk/frotz/windows.cpp
Expand Up @@ -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
28 changes: 27 additions & 1 deletion engines/glk/frotz/windows.h
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -86,6 +107,11 @@ class Windows {
*/
Windows();

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

/**
* Array access
*/
Expand Down

0 comments on commit c02d1f5

Please sign in to comment.