aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2019-05-08 17:29:07 +1000
committerPaul Gilbert2019-05-10 12:11:05 +1000
commit2765ba9afa4918e46ab0835c0f6e9183c57b612a (patch)
tree6ab7770ab6a4338a65a7a9961fdd9597dcae63f0 /engines
parent19a9b9aa31cad3920bc258ebe79d1e1c9a7b537c (diff)
downloadscummvm-rg350-2765ba9afa4918e46ab0835c0f6e9183c57b612a.tar.gz
scummvm-rg350-2765ba9afa4918e46ab0835c0f6e9183c57b612a.tar.bz2
scummvm-rg350-2765ba9afa4918e46ab0835c0f6e9183c57b612a.zip
GLK: HUGO: Added Glk interface methods
Diffstat (limited to 'engines')
-rw-r--r--engines/glk/hugo/heglk.cpp571
-rw-r--r--engines/glk/hugo/hugo.cpp12
-rw-r--r--engines/glk/hugo/hugo.h136
-rw-r--r--engines/glk/hugo/hugo_defines.h127
-rw-r--r--engines/glk/hugo/hugo_types.h18
5 files changed, 833 insertions, 31 deletions
diff --git a/engines/glk/hugo/heglk.cpp b/engines/glk/hugo/heglk.cpp
index 8b56f32de0..86be90c268 100644
--- a/engines/glk/hugo/heglk.cpp
+++ b/engines/glk/hugo/heglk.cpp
@@ -44,13 +44,578 @@ void Hugo::hugo_init_screen() {
SCREENWIDTH/FIXEDCHARWIDTH, SCREENHEIGHT/FIXEDLINEHEIGHT);
}
-void Hugo::hugo_cleanup_screen() {
- // No implementation
+void Hugo::hugo_getline(const char *prmpt) {
+ event_t ev;
+ char gotline = 0;
+
+ /* Just in case we try to get line input from a Glk-illegal
+ window that hasn't been created, switch as a failsafe
+ to mainwin
+ */
+ if (currentwin == NULL)
+ glk_set_window(currentwin = mainwin);
+
+ /* Print prompt */
+ glk_put_string(prmpt);
+
+ /* Request line input */
+ glk_request_line_event(currentwin, buffer, MAXBUFFER, 0);
+
+ while (!gotline)
+ {
+ /* Grab an event */
+ glk_select(&ev);
+
+ switch (ev.type)
+ {
+ case evtype_LineInput:
+ /* (Will always be currentwin, but anyway) */
+ if (ev.window == currentwin) {
+ gotline = true;
+ }
+ break;
+ }
+ }
+
+ /* The line we have received in commandbuf is not null-terminated */
+ buffer[ev.val1] = '\0'; /* i.e., the length */
+
+ /* Copy the input to the script file (if open) */
+ if (script) {
+ Common::String line = Common::String::format("%s%s\n", prompt, buffer);
+ script->putBuffer(line.c_str(), line.size());
+ }
+}
+
+int Hugo::hugo_waitforkey() {
+ event_t ev;
+ char gotchar = 0;
+
+ /* Just in case we try to get key input from a Glk-illegal
+ window that hasn't been created, switch as a failsafe
+ to mainwin
+ */
+ if (currentwin == NULL)
+ glk_set_window(currentwin = mainwin);
+
+#if defined (NO_KEYPRESS_CURSOR)
+ if (currentwin != mainwin)
+ {
+ glk_window_move_cursor(currentwin, currentpos / CHARWIDTH, currentline - 1);
+ hugo_print("*");
+ glk_window_move_cursor(currentwin, currentpos / CHARWIDTH, currentline - 1);
+ }
+#endif
+
+ glk_request_char_event(currentwin);
+
+ while (!gotchar)
+ {
+ /* Grab an event */
+ glk_select(&ev);
+
+ switch (ev.type)
+ {
+ case evtype_CharInput:
+ /* (Will always be mainwin, but anyway) */
+ if (ev.window == currentwin) {
+ gotchar = true;
+ }
+ break;
+ }
+ }
+
+ /* Convert Glk special keycodes: */
+ switch (ev.val1)
+ {
+ case keycode_Left: ev.val1 = 8; break;
+ case keycode_Right: ev.val1 = 21; break;
+ case keycode_Up: ev.val1 = 11; break;
+ case keycode_Down: ev.val1 = 10; break;
+ case keycode_Return: ev.val1 = 13; break;
+ case keycode_Escape: ev.val1 = 27; break;
+ }
+
+#if defined (NO_KEYPRESS_CURSOR)
+ if (currentwin != mainwin)
+ {
+ glk_window_move_cursor(currentwin, currentpos / CHARWIDTH, currentline - 1);
+ hugo_print(" ");
+ glk_window_move_cursor(currentwin, currentpos / CHARWIDTH, currentline - 1);
+ }
+#endif
+
+ return ev.val1;
+}
+
+int Hugo::hugo_iskeywaiting() {
+ var[system_status] = STAT_UNAVAILABLE;
+ return 0;
+}
+
+int Hugo::hugo_timewait(int n) {
+ uint32 millisecs;
+ event_t ev;
+
+ if (!glk_gestalt(gestalt_Timer, 0))
+ return false;
+ if (n == 0) return true;
+
+
+ millisecs = 1000 / n;
+ if (millisecs == 0)
+ millisecs = 1;
+
+ // For the time being, we're going to disallow
+ // millisecond delays in Glk (1) because there's no
+ // point, and (2) so that we can tell we're running
+ // under Glk.
+ if (millisecs < 1000) return false;
+
+ glk_request_timer_events(millisecs);
+ while (1)
+ {
+ glk_select(&ev);
+ if (ev.type == evtype_Timer)
+ break;
+ }
+ glk_request_timer_events(0);
+ return true;
+}
+
+void Hugo::hugo_clearfullscreen() {
+ glk_window_clear(mainwin);
+ if (secondwin) glk_window_clear(secondwin);
+ if (auxwin) glk_window_clear(auxwin);
+
+ /* See hugo_print() for the need for this */
+ if (currentwin == mainwin) mainwin_bgcolor = glk_bgcolor;
+
+ /* Must be set: */
+ currentpos = 0;
+ currentline = 1;
+
+ if (!inwindow) just_cleared_screen = true;
+}
+
+void Hugo::hugo_clearwindow() {
+ /* Clears the currently defined window, moving the cursor to the top-left
+ corner of the window */
+
+ /* If the engine thinks we're in a window, but Glk was
+ unable to comply, don't clear the window, because it's
+ not really a window
+ */
+ if (inwindow && currentwin == mainwin) return;
+ if (currentwin == NULL) return;
+
+ glk_window_clear(currentwin);
+
+ /* See hugo_print() for the need for this */
+ if (currentwin == mainwin) mainwin_bgcolor = glk_bgcolor;
+
+ /* If we're in a fixed-font (i.e., textgrid) auxiliary
+ window when we call for a clear, close auxwin and reset
+ the current window to mainwin
+ */
+ if (auxwin)
+ {
+ stream_result_t sr;
+
+ glk_window_close(auxwin, &sr);
+ auxwin = NULL;
+ glk_set_window(currentwin = mainwin);
+ }
+
+ /* Must be set: */
+ currentpos = 0;
+ currentline = 1;
+
+ if (!inwindow) just_cleared_screen = true;
+}
+
+void Hugo::hugo_settextmode() {
+ charwidth = FIXEDCHARWIDTH;
+ lineheight = FIXEDLINEHEIGHT;
}
void Hugo::hugo_settextwindow(int left, int top, int right, int bottom) {
- // TODO
+ /* Hugo's arbitrarily positioned windows don't currently
+ mesh with what Glk has to offer, so we have to ignore any
+ non-Glk-ish Windows and just maintain the current
+ parameters
+ */
+ if ((top != 1 || bottom >= physical_windowbottom / FIXEDLINEHEIGHT + 1)
+ /* Pre-v2.4 didn't support proper windowing */
+ && (game_version >= 24 || !inwindow))
+ {
+ in_valid_window = false;
+
+ /* Glk-illegal floating window; setting currentwin
+ to NULL will tell hugo_print() not to print in it:
+ */
+ if (bottom<physical_windowbottom / FIXEDLINEHEIGHT + 1)
+ {
+ currentwin = NULL;
+ glk_set_window(mainwin);
+ return;
+ }
+ else
+ glk_set_window(currentwin = mainwin);
+ }
+
+ /* Otherwise this is a valid window (positioned along the
+ top of the screen a la a status window), so... */
+ else
+ {
+ /* Arbitrary height of 4 lines for pre-v2.4 windows */
+ if (game_version < 24) bottom = 4;
+
+ /* ...either create a new window if none exists... */
+ if (!secondwin)
+ {
+ glk_stylehint_set(wintype_TextGrid, style_Normal, stylehint_ReverseColor, 1);
+ glk_stylehint_set(wintype_TextGrid, style_Subheader, stylehint_ReverseColor, 1);
+ glk_stylehint_set(wintype_TextGrid, style_Emphasized, stylehint_ReverseColor, 1);
+
+ winid_t p;
+
+ p = glk_window_get_parent(mainwin);
+ secondwin = glk_window_open(mainwin,//p,
+ winmethod_Above | winmethod_Fixed,
+ bottom,
+ wintype_TextGrid,
+ 0);
+ }
+
+ /* ...or resize the existing one if necessary */
+ else if (bottom != secondwin_bottom)
+ {
+ winid_t p;
+
+ p = glk_window_get_parent(secondwin);
+ glk_window_set_arrangement(p,
+ winmethod_Above | winmethod_Fixed,
+ bottom,
+ secondwin);
+ }
+
+ if (secondwin)
+ {
+ if (game_version < 24)
+ glk_window_clear(secondwin);
+
+ glk_set_window(currentwin = secondwin);
+ in_valid_window = true;
+ secondwin_bottom = bottom;
+ }
+ else
+ {
+ currentwin = NULL;
+ glk_set_window(mainwin);
+ secondwin_bottom = 0;
+ return;
+ }
+ }
+
+ physical_windowleft = (left - 1)*FIXEDCHARWIDTH;
+ physical_windowtop = (top - 1)*FIXEDLINEHEIGHT;
+ physical_windowright = right*FIXEDCHARWIDTH - 1;
+ physical_windowbottom = bottom*FIXEDLINEHEIGHT - 1;
+ physical_windowwidth = (right - left + 1)*FIXEDCHARWIDTH;
+ physical_windowheight = (bottom - top + 1)*FIXEDLINEHEIGHT;
+}
+
+int Hugo::heglk_get_linelength() {
+ static uint32 width;
+
+ // Try to use whatever fixed-width linelength is available
+ if (secondwin)
+ glk_window_get_size(secondwin, &width, NULL);
+ else if (auxwin)
+ glk_window_get_size(auxwin, &width, NULL);
+
+ // Otherwise try to approximate it by the proportionally spaced linelength
+ else
+ glk_window_get_size(mainwin, &width, NULL);
+
+ // -1 to override automatic line wrapping
+ return width - 1;
+}
+
+int Hugo::heglk_get_screenheight() {
+ static uint32 height = 0, mainheight = 0;
+
+ if (secondwin)
+ glk_window_get_size(secondwin, NULL, &height);
+ else if (auxwin)
+ glk_window_get_size(auxwin, NULL, &height);
+
+ glk_window_get_size(mainwin, NULL, &mainheight);
+
+ return height + mainheight;
+}
+
+void Hugo::hugo_settextpos(int x, int y) {
+ if (currentwin == NULL) return;
+
+ // Try to determine if we're trying to position fixed-width text in the main window,
+ // as in a menu, for example
+ if (!just_cleared_screen && !inwindow &&
+ !(glk_current_font & PROP_FONT)
+ && y != 1 /* not just cls */
+ && y < SCREENHEIGHT - 0x0f) /* 0x0f is arbitrary */
+ {
+ /* See if we're already in the auxiliary window */
+ if (currentwin != auxwin)
+ {
+ /* If not, create it, making it 100% of
+ mainwin's height
+ */
+ if (auxwin == NULL)
+ {
+ auxwin = glk_window_open(mainwin,
+ winmethod_Below | winmethod_Proportional,
+ 100,
+ wintype_TextGrid,
+ 0);
+ }
+ else
+ glk_window_clear(auxwin);
+
+ glk_set_window(currentwin = auxwin);
+ }
+ }
+
+ /* On the other hand, if we were in a textgrid window and
+ no longer need to be, get out
+ */
+ else if (auxwin)
+ {
+ stream_result_t sr;
+
+ /* Close auxwin */
+ glk_window_close(auxwin, &sr);
+ auxwin = NULL;
+
+ /* Clear the screen (both windows) */
+ glk_window_clear(mainwin);
+ glk_window_clear(secondwin);
+
+ glk_set_window(currentwin = mainwin);
+ }
+
+ just_cleared_screen = false;
+
+ /* Can only move the Glk cursor in a textgrid window */
+ if (currentwin != mainwin)
+ glk_window_move_cursor(currentwin, x - 1, y - 1);
+
+ /* Must be set: */
+ currentline = y;
+ currentpos = (x - 1)*CHARWIDTH; /* Note: zero-based */
+}
+
+void Hugo::hugo_print(const char *a) {
+ static char just_printed_linefeed = false;
+ /* static already_modified_style = false; */
+
+ /* Can't print in a Glk-illegal window since it hasn't been
+ created
+ */
+ if (currentwin == NULL) return;
+
+ /* In lieu of colors, in case we're highlighting something
+ such as a menu selection:
+ */
+ /*
+ if (!inwindow and glk_bgcolor!=mainwin_bgcolor)
+ {
+ if (!already_modified_style)
+ {
+ if (glk_current_font & BOLD_FONT)
+ glk_set_style(style_Normal);
+ else
+ glk_set_style(style_Emphasized);
+ }
+ already_modified_style = true;
+ }
+ else
+ already_modified_style = false;
+ */
+
+ if (a[0] == '\n')
+ {
+ if (!just_printed_linefeed)
+ {
+ glk_put_string("\n");
+ }
+ else
+ just_printed_linefeed = false;
+ }
+ else if (a[0] == '\r')
+ {
+ if (!just_printed_linefeed)
+ {
+ glk_put_string("\n");
+ just_printed_linefeed = true;
+ }
+ else
+ just_printed_linefeed = false;
+ }
+ else
+ {
+ glk_put_string(a);
+ just_printed_linefeed = false;
+ }
+}
+
+void Hugo::hugo_font(int f) {
+ static char using_prop_font = false;
+
+ glk_current_font = f;
+
+ glk_set_style(style_Normal);
+
+ if (f & BOLD_FONT)
+ glk_set_style(style_Subheader);
+
+ if (f & UNDERLINE_FONT)
+ glk_set_style(style_Emphasized);
+
+ if (f & ITALIC_FONT)
+ glk_set_style(style_Emphasized);
+
+ if (f & PROP_FONT)
+ using_prop_font = true;
+
+ /* Have to comment this out, it seems, because it will mess up the
+ alignment of the input in the main window
+ if (!(f & PROP_FONT))
+ glk_set_style(style_Preformatted);
+ */
+
+ /* Workaround to decide if we have to open auxwin for positioned
+ non-proportional text:
+ */
+ if (!(f & PROP_FONT))
+ {
+ /* If at top of screen, and changing to a fixed-
+ width font (a situation which wouldn't normally
+ be adjusted for by hugo_settextpos())
+ */
+ if (!inwindow && currentline == 1 && currentpos == 0 && using_prop_font)
+ {
+ just_cleared_screen = false;
+ hugo_settextpos(1, 2);
+ glk_window_move_cursor(currentwin, 0, 0);
+ }
+ }
+}
+
+void Hugo::hugo_settextcolor(int c) {
+ // Set the foreground color to hugo_color(c)
+ glk_fcolor = hugo_color(c);
}
+void Hugo::hugo_setbackcolor(int c) {
+ // Set the background color to hugo_color(c)
+ glk_bgcolor = hugo_color(c);
+}
+
+int Hugo::hugo_color(int c) {
+ if (c == 16) c = DEF_FCOLOR;
+ else if (c == 17) c = DEF_BGCOLOR;
+ else if (c == 18) c = DEF_SLFCOLOR;
+ else if (c == 19) c = DEF_SLBGCOLOR;
+ else if (c == 20) c = hugo_color(fcolor); /* match foreground */
+
+ /* Uncomment this block of code and change "c = ..." values if the system
+ palette differs from the Hugo palette.
+
+ If colors are unavailable on the system in question, it may suffice
+ to have black, white, and brightwhite (i.e. boldface). It is expected
+ that colored text will be visible on any other-colored background.
+
+ switch (c)
+ {
+ case HUGO_BLACK: c = 0; break;
+ case HUGO_BLUE: c = 1; break;
+ case HUGO_GREEN: c = 2; break;
+ case HUGO_CYAN: c = 3; break;
+ case HUGO_RED: c = 4; break;
+ case HUGO_MAGENTA: c = 5; break;
+ case HUGO_BROWN: c = 6; break;
+ case HUGO_WHITE: c = 7; break;
+ case HUGO_DARK_GRAY: c = 8; break;
+ case HUGO_LIGHT_BLUE: c = 9; break;
+ case HUGO_LIGHT_GREEN: c = 10; break;
+ case HUGO_LIGHT_CYAN: c = 11; break;
+ case HUGO_LIGHT_RED: c = 12; break;
+ case HUGO_LIGHT_MAGENTA: c = 13; break;
+ case HUGO_YELLOW: c = 14; break;
+ case HUGO_BRIGHT_WHITE: c = 15; break;
+ */
+ return c;
+}
+
+int Hugo::hugo_charwidth(char a) const {
+ if (a == FORCED_SPACE)
+ return CHARWIDTH; /* same as ' ' */
+
+ else if ((unsigned char)a >= ' ') /* alphanumeric characters */
+
+ return CHARWIDTH; /* for non-proportional */
+
+ return 0;
+}
+
+int Hugo::hugo_textwidth(const char *a) const {
+ int i, slen, len = 0;
+
+ slen = (int)strlen(a);
+
+ for (i = 0; i<slen; i++)
+ {
+ if (a[i] == COLOR_CHANGE) i += 2;
+ else if (a[i] == FONT_CHANGE) i++;
+ else
+ len += hugo_charwidth(a[i]);
+ }
+
+ return len;
+}
+
+int Hugo::hugo_strlen(const char *a) const {
+ int i, slen, len = 0;
+
+ slen = (int)strlen(a);
+
+ for (i = 0; i<slen; i++)
+ {
+ if (a[i] == COLOR_CHANGE) i += 2;
+ else if (a[i] == FONT_CHANGE) i++;
+ else len++;
+ }
+
+ return len;
+}
+
+/*
+ * Replacements for things the Glk port doesn't support:
+ *
+ */
+
+void Hugo::hugo_setgametitle(const char *t) {}
+
+int Hugo::hugo_hasvideo() const { return false; }
+
+int Hugo::hugo_playvideo(HUGO_FILE infile, long reslength, char loop_flag, char background, int volume) {
+ delete infile;
+ return true;
+}
+
+void Hugo::hugo_stopvideo(void) {}
+
} // End of namespace Hugo
} // End of namespace Glk
diff --git a/engines/glk/hugo/hugo.cpp b/engines/glk/hugo/hugo.cpp
index 3f63d3b6b2..afc788e59c 100644
--- a/engines/glk/hugo/hugo.cpp
+++ b/engines/glk/hugo/hugo.cpp
@@ -26,7 +26,7 @@ namespace Glk {
namespace Hugo {
Hugo::Hugo(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc),
- mainwin(nullptr), currentwin(nullptr), address_scale(16),
+ mainwin(nullptr), currentwin(nullptr), secondwin(nullptr), auxwin(nullptr), address_scale(16),
SCREENWIDTH(0), SCREENHEIGHT(0), FIXEDCHARWIDTH(0), FIXEDLINEHEIGHT(0),
game_version(0), object_size(0), game(nullptr), script(nullptr), save(nullptr),
playback(nullptr), record(nullptr), io(nullptr), ioblock('\0'), ioerror('\0'),
@@ -40,18 +40,16 @@ Hugo::Hugo(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gam
physical_windowwidth(0), physical_windowheight(0), physical_windowtop(0),
physical_windowleft(0), physical_windowbottom(0), physical_windowright(0),
inwindow(0), charwidth(0), lineheight(0), current_text_x(0), current_text_y(0),
- undoptr(0), undoturn(0), undoinvalid(0), undorecord(0),
+ undoptr(0), undoturn(0), undoinvalid(0), undorecord(0), context_commands(0),
in_valid_window(false), glk_fcolor(DEF_FCOLOR), glk_bgcolor(DEF_BGCOLOR),
- mainwin_bgcolor(0), glk_current_font(0), just_cleared_screen(false) {
-#if !defined (COMPILE_V25)
+ mainwin_bgcolor(0), glk_current_font(0), just_cleared_screen(false), secondwin_bottom(0) {
Common::fill(&context_command[0][0], &context_command[MAX_CONTEXT_COMMANDS][64], 0);
- context_commands = 0;
-#endif
-
Common::fill(&id[0], &id[3], '\0');
Common::fill(&serial[0], &serial[9], '\0');
Common::fill(&pbuffer[0], &pbuffer[MAXBUFFER * 2 + 1], 0);
Common::fill(&undostack[0][0], &undostack[MAXUNDO][5], 0);
+ Common::fill(&buffer[0], &buffer[MAXBUFFER + MAXWORDS], '\0');
+ Common::fill(&var[0], &var[MAXLOCALS + MAXGLOBALS], 0);
}
// TODO: Proper method implementations
diff --git a/engines/glk/hugo/hugo.h b/engines/glk/hugo/hugo.h
index f94931f653..7d12646e7a 100644
--- a/engines/glk/hugo/hugo.h
+++ b/engines/glk/hugo/hugo.h
@@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "glk/glk_api.h"
+#include "glk/hugo/hugo_defines.h"
#include "glk/hugo/hugo_types.h"
namespace Glk {
@@ -36,6 +37,7 @@ namespace Hugo {
class Hugo : public GlkAPI {
private:
winid_t mainwin, currentwin;
+ winid_t secondwin, auxwin;
/**
* address_scale refers to the factor by which addresses are multiplied to
@@ -74,10 +76,8 @@ private:
int events;
int dictcount;
int syncount;
-#if !defined (COMPILE_V25)
char context_command[MAX_CONTEXT_COMMANDS][64];
int context_commands;
-#endif
unsigned char *mem;
int loaded_in_memory;
unsigned int defseg;
@@ -111,6 +111,13 @@ private:
int mainwin_bgcolor;
int glk_current_font;
bool just_cleared_screen;
+ int secondwin_bottom;
+
+ // heparse
+ char buffer[MAXBUFFER + MAXWORDS];
+
+ // heexpr
+ int var[MAXLOCALS + MAXGLOBALS];
private:
/**
* \defgroup heglk
@@ -125,10 +132,133 @@ private:
/**
* Does whatever has to be done to clean up the display pre-termination
*/
- void hugo_cleanup_screen();
+ void hugo_cleanup_screen() {
+ // No implementation
+ }
+
+ int hugo_getkey() const {
+ // Not needed here--single-character events are handled solely by hugo_waitforkey(), below
+ return 0;
+ }
+
+ /**
+ * Gets a line of input from the keyboard, storing it in <buffer>.
+ */
+ void hugo_getline(const char *prmpt);
+
+ /**
+ * Provided to be replaced by multitasking systems where cycling while waiting
+ * for a keystroke may not be such a hot idea.
+ */
+ int hugo_waitforkey();
+
+ /**
+ * Returns true if a keypress is waiting to be retrieved.
+ */
+ int hugo_iskeywaiting();
+
+ /**
+ * Waits for 1/n seconds. Returns false if waiting is unsupported.
+ */
+ int hugo_timewait(int n);
+
+ /**
+ * Clears everything on the screen, moving the cursor to the top-left corner of the screen
+ */
+ void hugo_clearfullscreen();
+
+ /**
+ * Clears the currently defined window, moving the cursor to the top-left corner of the window
+ */
+ void hugo_clearwindow();
+
+ /**
+ * This function does whatever is necessary to set the system up for a standard text display
+ */
+ void hugo_settextmode();
void hugo_settextwindow(int left, int top, int right, int bottom);
+ /**
+ * Specially accommodated in GetProp() While the engine thinks that the linelength is 0x7fff,
+ this tells things like the display object the actual length. (Defined as ACTUAL_LINELENGTH)
+ */
+ int heglk_get_linelength();
+
+ /**
+ * Similar to heglk_get_linelength(). (Defined as ACTUAL_SCREENHEIGHT)
+ */
+ int heglk_get_screenheight();
+
+ void hugo_settextpos(int x, int y);
+
+ /**
+ * Essentially the same as printf() without formatting, since printf() generally doesn't take
+ * into account color setting, font changes, windowing, etc.
+ *
+ * The newline character '\n' must be explicitly included at the end of a line in order to
+ * produce a linefeed. The new cursor position is set to the end of this printed text.
+ * Upon hitting the right edge of the screen, the printing position wraps to the start
+ * of the next line.
+ */
+ void hugo_print(const char *a);
+
+ /**
+ * Scroll the text window
+ */
+ void hugo_scrollwindowup() {
+ // No implementation. Glk takes care of it
+ }
+
+ /**
+ * Set the font
+ * @param f The <f> argument is a mask containing any or none of:
+ * BOLD_FONT, UNDERLINE_FONT, ITALIC_FONT, PROP_FONT.
+ */
+ void hugo_font(int f);
+
+ /**
+ * Set the foreground (print) color
+ */
+ void hugo_settextcolor(int c);
+
+ /**
+ * Set the background color
+ */
+ void hugo_setbackcolor(int c);
+
+ /**
+ * Color-setting functions should always pass the color through hugo_color()
+ * in order to properly set default fore/background colors
+ */
+ int hugo_color(int c);
+
+ /**
+ * Get the width of a character
+ * @remarks As given here, this function works only for non-proportional printing.
+ * For proportional printing, hugo_charwidth() should return the width of the supplied
+ * character in the current font and style.
+ */
+ int hugo_charwidth(char a) const;
+
+ /**
+ * Return the width of a string
+ */
+ int hugo_textwidth(const char *a) const;
+
+ /**
+ * Return the length of a string
+ */
+ int hugo_strlen(const char *a) const;
+
+ void hugo_setgametitle(const char *t);
+
+ int hugo_hasvideo() const;
+
+ int hugo_playvideo(HUGO_FILE infile, long reslength, char loop_flag, char background, int volume);
+
+ void hugo_stopvideo();
+
/**@}*/
private:
/**
diff --git a/engines/glk/hugo/hugo_defines.h b/engines/glk/hugo/hugo_defines.h
new file mode 100644
index 0000000000..caa1755b82
--- /dev/null
+++ b/engines/glk/hugo/hugo_defines.h
@@ -0,0 +1,127 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef GLK_HUGO_DEFINES
+#define GLK_HUGO_DEFINES
+
+#include "common/scummsys.h"
+
+namespace Glk {
+namespace Hugo {
+
+#define MAX_CONTEXT_COMMANDS 32
+#define MAXBUFFER 255
+#define MAXUNDO 1024
+#define CHARWIDTH 1
+#define STAT_UNAVAILABLE (-1)
+
+#define HUGO_FILE strid_t
+#define MAXPATH 256
+#define MAXFILENAME 256
+#define MAXDRIVE 256
+#define MAXDIR 256
+#define MAXEXT 256
+
+#define DEF_PRN ""
+#define DEF_FCOLOR 0
+#define DEF_BGCOLOR 15
+#define DEF_SLFCOLOR 15
+#define DEF_SLBGCOLOR 1
+
+/* These static values are not changeable--they depend largely on internals of the Engine. */
+#define MAXATTRIBUTES 128
+#define MAXGLOBALS 240
+#define MAXLOCALS 16
+#define MAXPOBJECTS 256 /* contenders for disambiguation */
+#define MAXWORDS 32 /* in an input line */
+#define MAXSTACKDEPTH 256 /* for nesting {...} */
+
+
+/* The positions of various data in the header: */
+#define H_GAMEVERSION 0x00
+#define H_ID 0x01
+#define H_SERIAL 0x03
+#define H_CODESTART 0x0B
+
+#define H_OBJTABLE 0x0D /* data tables */
+#define H_PROPTABLE 0x0F
+#define H_EVENTTABLE 0x11
+#define H_ARRAYTABLE 0x13
+#define H_DICTTABLE 0x15
+#define H_SYNTABLE 0x17
+
+#define H_INIT 0x19 /* junction routines */
+#define H_MAIN 0x1B
+#define H_PARSE 0x1D
+#define H_PARSEERROR 0x1F
+#define H_FINDOBJECT 0x21
+#define H_ENDGAME 0x23
+#define H_SPEAKTO 0x25
+#define H_PERFORM 0x27
+
+#define H_TEXTBANK 0x29
+
+/* additional debugger header information */
+#define H_DEBUGGABLE 0x3A
+#define H_DEBUGDATA 0x3B
+#define H_DEBUGWORKSPACE 0x3E
+
+/* Printing control codes--embedded in strings printed by AP(). */
+#define FONT_CHANGE 1
+#define COLOR_CHANGE 2
+#define NO_CONTROLCHAR 3
+#define NO_NEWLINE 30
+#define FORCED_SPACE 31 /* Can't be <= # colors/font codes + 1
+(See AP() for the reason) */
+
+/* Font control codes--these bitmasks follow FONT_CHANGE codes. */
+#define NORMAL_FONT 0
+#define BOLD_FONT 1
+#define ITALIC_FONT 2
+#define UNDERLINE_FONT 4
+#define PROP_FONT 8
+
+/* CHAR_TRANSLATION is simply a value that is added to an ASCII character
+in order to encode the text, i.e., make it unreadable to casual
+browsing.
+*/
+#define CHAR_TRANSLATION 0x14
+
+/* Passed to GetWord() */
+#define PARSE_STRING_VAL 0xFFF0
+#define SERIAL_STRING_VAL 0xFFF1
+
+/* Returned by FindWord() */
+#define UNKNOWN_WORD 0xFFFF
+
+/* Bitmasks for certain qualities of properties */
+#define ADDITIVE_FLAG 1
+#define COMPLEX_FLAG 2
+
+/* Property-table indicators */
+#define PROP_END 255
+#define PROP_ROUTINE 255
+
+} // End of namespace Hugo
+} // End of namespace Glk
+
+#endif
diff --git a/engines/glk/hugo/hugo_types.h b/engines/glk/hugo/hugo_types.h
index 8082842cc4..43b2899f93 100644
--- a/engines/glk/hugo/hugo_types.h
+++ b/engines/glk/hugo/hugo_types.h
@@ -28,24 +28,6 @@
namespace Glk {
namespace Hugo {
-#define MAX_CONTEXT_COMMANDS 32
-#define MAXBUFFER 255
-#define MAXUNDO 1024
-#define CHARWIDTH 1
-
-#define HUGO_FILE strid_t
-#define MAXPATH 256
-#define MAXFILENAME 256
-#define MAXDRIVE 256
-#define MAXDIR 256
-#define MAXEXT 256
-
-#define DEF_PRN ""
-#define DEF_FCOLOR 0
-#define DEF_BGCOLOR 15
-#define DEF_SLFCOLOR 15
-#define DEF_SLBGCOLOR 1
-
/**
* Library/engine globals
*/