From efdf25b3d28113b01e18ef0c69221194a1100e9e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 3 Jul 2019 21:56:09 -0700 Subject: GLK: ALAN3: Move term.cpp code into glkio.cpp --- engines/glk/alan3/exe.cpp | 1 - engines/glk/alan3/glkio.cpp | 39 ++++++++++++++++++- engines/glk/alan3/glkio.h | 4 ++ engines/glk/alan3/main.cpp | 1 - engines/glk/alan3/output.cpp | 13 ++++++- engines/glk/alan3/output.h | 1 + engines/glk/alan3/parse.cpp | 1 - engines/glk/alan3/readline.cpp | 1 - engines/glk/alan3/scan.cpp | 1 - engines/glk/alan3/term.cpp | 85 ------------------------------------------ engines/glk/alan3/term.h | 43 --------------------- 11 files changed, 55 insertions(+), 135 deletions(-) delete mode 100644 engines/glk/alan3/term.cpp delete mode 100644 engines/glk/alan3/term.h (limited to 'engines/glk/alan3') diff --git a/engines/glk/alan3/exe.cpp b/engines/glk/alan3/exe.cpp index f30ebc2c6b..e2555f505c 100644 --- a/engines/glk/alan3/exe.cpp +++ b/engines/glk/alan3/exe.cpp @@ -41,7 +41,6 @@ #include "glk/alan3/state.h" #include "glk/alan3/syserr.h" #include "glk/alan3/sysdep.h" -#include "glk/alan3/term.h" #include "glk/alan3/types.h" #include "glk/alan3/utils.h" #include "glk/alan3/word.h" diff --git a/engines/glk/alan3/glkio.cpp b/engines/glk/alan3/glkio.cpp index 6cc264f30a..f36c396ed0 100644 --- a/engines/glk/alan3/glkio.cpp +++ b/engines/glk/alan3/glkio.cpp @@ -20,15 +20,19 @@ * */ -#include "glk/alan3/alan3.h" #include "glk/alan3/glkio.h" #include "glk/alan3/acode.h" +#include "glk/alan3/current.h" +#include "glk/alan3/instance.h" +#include "glk/alan3/options.h" +#include "glk/alan3/output.h" namespace Glk { namespace Alan3 { winid_t glkMainWin; winid_t glkStatusWin; +bool onStatusLine; void glkio_printf(const char *fmt, ...) { // If there's a savegame being loaded from the launcher, ignore any text out @@ -97,5 +101,38 @@ void setStyle(int style) { } } +void statusline(CONTEXT) { + uint32 glkWidth; + char line[100]; + int pcol = col; + + if (!statusLineOption) return; + if (glkStatusWin == NULL) + return; + + g_vm->glk_set_window(glkStatusWin); + g_vm->glk_window_clear(glkStatusWin); + g_vm->glk_window_get_size(glkStatusWin, &glkWidth, NULL); + + onStatusLine = TRUE; + col = 1; + g_vm->glk_window_move_cursor(glkStatusWin, 1, 0); + CALL1(sayInstance, where(HERO, /*TRUE*/ TRANSITIVE)) + + // TODO Add status message1 & 2 as author customizable messages + if (header->maximumScore > 0) + sprintf(line, "Score %d(%d)/%d moves", current.score, (int)header->maximumScore, current.tick); + else + sprintf(line, "%d moves", current.tick); + g_vm->glk_window_move_cursor(glkStatusWin, glkWidth - strlen(line) - 1, 0); + g_vm->glk_put_string(line); + needSpace = FALSE; + + col = pcol; + onStatusLine = FALSE; + + g_vm->glk_set_window(glkMainWin); +} + } // End of namespace Alan3 } // End of namespace Glk diff --git a/engines/glk/alan3/glkio.h b/engines/glk/alan3/glkio.h index 32ce758d01..b0629ce8f8 100644 --- a/engines/glk/alan3/glkio.h +++ b/engines/glk/alan3/glkio.h @@ -24,6 +24,7 @@ #define GLK_ALAN3_GLKIO #include "glk/alan3/alan3.h" +#include "glk/alan3/jumps.h" #include "glk/windows.h" namespace Glk { @@ -31,6 +32,7 @@ namespace Alan3 { extern winid_t glkMainWin; extern winid_t glkStatusWin; +extern bool onStatusLine; #undef printf #define printf glkio_printf @@ -42,6 +44,8 @@ extern void playSound(int sound); extern void setStyle(int style); +extern void statusline(CONTEXT); + } // End of namespace Alan3 } // End of namespace Glk diff --git a/engines/glk/alan3/main.cpp b/engines/glk/alan3/main.cpp index c32693ef8b..de65b095d3 100644 --- a/engines/glk/alan3/main.cpp +++ b/engines/glk/alan3/main.cpp @@ -51,7 +51,6 @@ #include "glk/alan3/state.h" #include "glk/alan3/syserr.h" #include "glk/alan3/syntax.h" -#include "glk/alan3/term.h" #include "glk/alan3/utils.h" namespace Glk { diff --git a/engines/glk/alan3/output.cpp b/engines/glk/alan3/output.cpp index aa699c960c..15d4ff4f04 100644 --- a/engines/glk/alan3/output.cpp +++ b/engines/glk/alan3/output.cpp @@ -27,7 +27,6 @@ #include "glk/alan3/memory.h" #include "glk/alan3/word.h" #include "glk/alan3/lists.h" -#include "glk/alan3/term.h" #include "glk/alan3/syserr.h" #include "glk/alan3/dictionary.h" #include "glk/alan3/current.h" @@ -55,6 +54,18 @@ strid_t logFile; /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* + getPageSize() + + Try to get the current page size from the system, else use the ones + from the header. + + */ +void getPageSize(void) { + pageLength = 0; + pageWidth = 0; +} + /*----------------------------------------------------------------------*/ static int updateColumn(int currentColumn, const char *string) { diff --git a/engines/glk/alan3/output.h b/engines/glk/alan3/output.h index 6f52cfccf6..fc344909de 100644 --- a/engines/glk/alan3/output.h +++ b/engines/glk/alan3/output.h @@ -42,6 +42,7 @@ extern bool skipSpace; extern strid_t logFile; /* FUNCTIONS */ +extern void getPageSize(); extern void setSubHeaderStyle(void); extern void setNormalStyle(void); extern void newline(void); diff --git a/engines/glk/alan3/parse.cpp b/engines/glk/alan3/parse.cpp index 6618e9dde9..efa5464c33 100644 --- a/engines/glk/alan3/parse.cpp +++ b/engines/glk/alan3/parse.cpp @@ -43,7 +43,6 @@ #include "glk/alan3/syntax.h" #include "glk/alan3/scan.h" #include "glk/alan3/syserr.h" -#include "glk/alan3/term.h" #include "glk/alan3/utils.h" #include "glk/alan3/word.h" diff --git a/engines/glk/alan3/readline.cpp b/engines/glk/alan3/readline.cpp index 832f00d87e..7be20c7b9c 100644 --- a/engines/glk/alan3/readline.cpp +++ b/engines/glk/alan3/readline.cpp @@ -24,7 +24,6 @@ #include "glk/alan3/sysdep.h" #include "glk/alan3/output.h" -#include "glk/alan3/term.h" #include "glk/alan3/exe.h" #include "glk/alan3/save.h" #include "glk/alan3/location.h" diff --git a/engines/glk/alan3/scan.cpp b/engines/glk/alan3/scan.cpp index 6d1e7d408d..6cc1ef9076 100644 --- a/engines/glk/alan3/scan.cpp +++ b/engines/glk/alan3/scan.cpp @@ -35,7 +35,6 @@ #include "glk/alan3/params.h" #include "glk/alan3/readline.h" #include "glk/alan3/syserr.h" -#include "glk/alan3/term.h" #include "glk/alan3/word.h" namespace Glk { diff --git a/engines/glk/alan3/term.cpp b/engines/glk/alan3/term.cpp deleted file mode 100644 index 37f709e377..0000000000 --- a/engines/glk/alan3/term.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* 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. - * - */ - -#include "glk/alan3/current.h" -#include "glk/alan3/glkio.h" -#include "glk/alan3/instance.h" -#include "glk/alan3/memory.h" -#include "glk/alan3/output.h" -#include "glk/alan3/options.h" -#include "glk/alan3/sysdep.h" - -namespace Glk { -namespace Alan3 { - -/* PUBLIC DATA */ -bool onStatusLine = FALSE; /* To know if where printing the status line or not */ - -/*====================================================================== - - getPageSize() - - Try to get the current page size from the system, else use the ones - from the header. - - */ -void getPageSize(void) { - pageLength = 0; - pageWidth = 0; -} - -/*======================================================================*/ -void statusline(CONTEXT) { - uint32 glkWidth; - char line[100]; - int pcol = col; - - if (!statusLineOption) return; - if (glkStatusWin == NULL) - return; - - g_vm->glk_set_window(glkStatusWin); - g_vm->glk_window_clear(glkStatusWin); - g_vm->glk_window_get_size(glkStatusWin, &glkWidth, NULL); - - onStatusLine = TRUE; - col = 1; - g_vm->glk_window_move_cursor(glkStatusWin, 1, 0); - CALL1(sayInstance, where(HERO, /*TRUE*/ TRANSITIVE)) - - // TODO Add status message1 & 2 as author customizable messages - if (header->maximumScore > 0) - sprintf(line, "Score %d(%d)/%d moves", current.score, (int)header->maximumScore, current.tick); - else - sprintf(line, "%d moves", current.tick); - g_vm->glk_window_move_cursor(glkStatusWin, glkWidth - strlen(line) - 1, 0); - g_vm->glk_put_string(line); - needSpace = FALSE; - - col = pcol; - onStatusLine = FALSE; - - g_vm->glk_set_window(glkMainWin); -} - -} // End of namespace Alan3 -} // End of namespace Glk diff --git a/engines/glk/alan3/term.h b/engines/glk/alan3/term.h deleted file mode 100644 index 1f6dadc6b6..0000000000 --- a/engines/glk/alan3/term.h +++ /dev/null @@ -1,43 +0,0 @@ -/* 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_ALAN3_TERM -#define GLK_ALAN3_TERM - -/* Header file for terminal functions in ARUN, the Alan interpreter */ - -#include "glk/alan3/jumps.h" - -namespace Glk { -namespace Alan3 { - -/* DATA */ -extern bool onStatusLine; - -/* FUNCTIONS */ -extern void getPageSize(); -extern void statusline(CONTEXT); - -} // End of namespace Alan3 -} // End of namespace Glk - -#endif -- cgit v1.2.3