Skip to content

Commit

Permalink
GLK: FROTZ: Cleanup of image drawing code
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jan 5, 2019
1 parent c41c6f3 commit 18768f1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 27 deletions.
17 changes: 6 additions & 11 deletions engines/glk/frotz/glk_interface.cpp
Expand Up @@ -489,25 +489,20 @@ void GlkInterface::showBeyondZorkTitle() {
int saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;

if (saveSlot == -1) {
uint winW, winH, imgW, imgH;
winid_t win = glk_window_open(0, 0, 0, wintype_Graphics, 0);
glk_window_get_size(win, &winW, &winH);

if (os_picture_data(1, &imgW, &imgH)) {
os_draw_picture(1, win, Common::Rect(0, 0, winW, winH));
_events->waitForPress();
}
glk_image_draw_scaled(win, 1, 0, 0, g_vm->_screen->w, g_vm->_screen->h);

_events->waitForPress();
glk_window_close(win, nullptr);
}
}

void GlkInterface::os_draw_picture(int picture, winid_t win, const Common::Point &pos) {
glk_image_draw(win, picture, pos.x - 1, pos.y - 1);
void GlkInterface::os_draw_picture(int picture, const Common::Point &pos) {
glk_image_draw(_wp._background, picture, pos.x - 1, pos.y - 1);
}

void GlkInterface::os_draw_picture(int picture, winid_t win, const Common::Rect &r) {
glk_image_draw_scaled(win, picture, r.left, r.top, r.width(), r.height());
void GlkInterface::os_draw_picture(int picture, const Common::Rect &r) {
glk_image_draw_scaled(_wp._background, picture, r.left, r.top, r.width(), r.height());
}

zchar GlkInterface::os_read_key(int timeout, bool show_cursor) {
Expand Down
4 changes: 2 additions & 2 deletions engines/glk/frotz/glk_interface.h
Expand Up @@ -171,12 +171,12 @@ class GlkInterface : public GlkAPI, public virtual UserOptions, public virtual M
/**
* Display a picture at the given coordinates. Top left is (1,1).
*/
void os_draw_picture(int picture, winid_t win, const Common::Point &pos);
void os_draw_picture(int picture, const Common::Point &pos);

/**
* Display a picture using the specified bounds
*/
void os_draw_picture(int picture, winid_t win, const Common::Rect &r);
void os_draw_picture(int picture, const Common::Rect &r);

/**
* Call the IO interface to play a sample.
Expand Down
22 changes: 10 additions & 12 deletions engines/glk/frotz/processor_windows.cpp
Expand Up @@ -48,21 +48,19 @@ void Processor::z_draw_picture() {

flush_buffer();

Window &win = _wp[cwin];
if (!x || !y) {
// Currently I only support getting the cursor for the text grid area
assert(cwin == 1);
winid_t win = _wp._upper;
Point cursPos = win->getCursor();

// use cursor column if x-coordinate is 0
if (!x)
x = cursPos.x;
x = win[X_CURSOR];
// use cursor line if y-coordinate is 0
if (!y)
y = cursPos.y;
y = win[Y_CURSOR];
}

// y += cwp->y_pos - 1;
// x += cwp->x_pos - 1;
y += win[Y_POS] - 1;
x += win[X_POS] - 1;

/* The following is necessary to make Amiga and Macintosh story
* files work with MCGA graphics files. Some screen-filling
Expand All @@ -83,18 +81,18 @@ void Processor::z_draw_picture() {
if (_storyId == ARTHUR && pic == 54)
delta = h_screen_width / 160;

os_draw_picture(mapper[i].pic1, _wp._lower, Point(x + delta, y + height1));
os_draw_picture(mapper[i].pic2, _wp._lower, Point(x + width1 - width2 - delta, y + height1));
os_draw_picture(mapper[i].pic1, Point(x + delta, y + height1));
os_draw_picture(mapper[i].pic2, Point(x + width1 - width2 - delta, y + height1));
}
}

os_draw_picture(pic, _wp._lower, Point(x, y));
os_draw_picture(pic, Point(x, y));

if (_storyId == SHOGUN && pic == 3) {
uint height, width;

os_picture_data(59, &height, &width);
os_draw_picture(59, _wp._lower, Point(h_screen_width - width + 1, y));
os_draw_picture(59, Point(h_screen_width - width + 1, y));
}
}

Expand Down
6 changes: 4 additions & 2 deletions engines/glk/picture.cpp
Expand Up @@ -32,8 +32,10 @@ namespace Glk {

void Pictures::clear() {
for (uint idx = 0; idx < _store.size(); ++idx) {
_store[idx]._picture->decrement();
_store[idx]._scaled->decrement();
if (_store[idx]._picture)
_store[idx]._picture->decrement();
if (_store[idx]._scaled)
_store[idx]._scaled->decrement();
}

_store.clear();
Expand Down

0 comments on commit 18768f1

Please sign in to comment.