aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/glk/advsys/advsys.cpp11
-rw-r--r--engines/glk/advsys/advsys.h7
-rw-r--r--engines/glk/advsys/glk_interface.cpp14
-rw-r--r--engines/glk/advsys/glk_interface.h15
-rw-r--r--engines/glk/advsys/vm.cpp4
5 files changed, 26 insertions, 25 deletions
diff --git a/engines/glk/advsys/advsys.cpp b/engines/glk/advsys/advsys.cpp
index fe02e25181..0c63ff8dfb 100644
--- a/engines/glk/advsys/advsys.cpp
+++ b/engines/glk/advsys/advsys.cpp
@@ -26,10 +26,6 @@
namespace Glk {
namespace AdvSys {
-void execute(int offset) {
- // TODO: Stub
-}
-
bool getInput() {
// TODO: Stub
return false;
@@ -75,8 +71,7 @@ void AdvSys::runGame() {
bool AdvSys::initialize() {
// Create a Glk window for the game
- _window = glk_window_open(0, 0, 0, wintype_TextBuffer, 1);
- if (!_window)
+ if (!GlkInterface::initialize())
return false;
// Load the game's header
@@ -89,10 +84,6 @@ bool AdvSys::initialize() {
void AdvSys::deinitialize() {
}
-void AdvSys::print(const char *msg) {
- glk_put_string_stream(glk_window_get_stream(_window), msg);
-}
-
Common::Error AdvSys::loadGameData(strid_t save) {
return Common::kNoError;
}
diff --git a/engines/glk/advsys/advsys.h b/engines/glk/advsys/advsys.h
index a6e9a5b075..50977a6a3a 100644
--- a/engines/glk/advsys/advsys.h
+++ b/engines/glk/advsys/advsys.h
@@ -34,8 +34,6 @@ namespace AdvSys {
*/
class AdvSys : public VM {
private:
- winid_t _window;
-private:
/**
* Engine initialization
*/
@@ -45,11 +43,6 @@ private:
* Engine cleanup
*/
void deinitialize();
-
- /**
- * Print a string to the window
- */
- void print(const char *msg);
public:
/**
* Constructor
diff --git a/engines/glk/advsys/glk_interface.cpp b/engines/glk/advsys/glk_interface.cpp
index fff6bd12ed..c83f0c137c 100644
--- a/engines/glk/advsys/glk_interface.cpp
+++ b/engines/glk/advsys/glk_interface.cpp
@@ -25,12 +25,18 @@
namespace Glk {
namespace AdvSys {
-void GlkInterface::printString(int offset) {
- // TODO
+bool GlkInterface::initialize() {
+ _window = glk_window_open(0, 0, 0, wintype_TextBuffer, 1);
+ return !_window;
}
-void GlkInterface::printNumber(int number) {
- // TODO
+void GlkInterface::print(const Common::String &msg) {
+ glk_put_string_stream(glk_window_get_stream(_window), msg.c_str());
+}
+
+void GlkInterface::print(int number) {
+ Common::String s = Common::String::format("%d", number);
+ print(s);
}
} // End of namespace AdvSys
diff --git a/engines/glk/advsys/glk_interface.h b/engines/glk/advsys/glk_interface.h
index b54a35b250..b316f1f84f 100644
--- a/engines/glk/advsys/glk_interface.h
+++ b/engines/glk/advsys/glk_interface.h
@@ -33,18 +33,25 @@ namespace AdvSys {
* input and output
*/
class GlkInterface : public GlkAPI {
+private:
+ winid_t _window;
protected:
/**
+ * GLK initialization
+ */
+ bool initialize();
+
+ /**
* Print a string
- * @param offset String offset
+ * @param msg String
*/
- void printString(int offset);
+ void print(const Common::String &msg);
/**
* Print a number
- * @param number Number to print
+ * @param number Number to print
*/
- void printNumber(int number);
+ void print(int number);
public:
/**
* Constructor
diff --git a/engines/glk/advsys/vm.cpp b/engines/glk/advsys/vm.cpp
index be2fed9ee7..0e59fe34e0 100644
--- a/engines/glk/advsys/vm.cpp
+++ b/engines/glk/advsys/vm.cpp
@@ -225,12 +225,16 @@ void VM::opSET() {
}
void VM::opPRINT() {
+ Common::String msg = readString(_stack.top());
+ print(msg);
}
void VM::opTERPRI() {
+ print("\n");
}
void VM::opPNUMBER() {
+ print(_stack.top());
}
void VM::opFINISH() {