aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2019-11-02 19:34:29 -0700
committerPaul Gilbert2019-11-11 18:20:29 -0800
commita3c646133f9c173b23ff775e03563e337be1cdaf (patch)
tree67d87f786f60c07f0197f7b42c200d446044b710 /engines
parentd51d3d40861446f849564bb6af07ab35cb2c3e77 (diff)
downloadscummvm-rg350-a3c646133f9c173b23ff775e03563e337be1cdaf.tar.gz
scummvm-rg350-a3c646133f9c173b23ff775e03563e337be1cdaf.tar.bz2
scummvm-rg350-a3c646133f9c173b23ff775e03563e337be1cdaf.zip
GLK: ARCHETYPE: Switch from original's Debug enum to debug channels
Diffstat (limited to 'engines')
-rw-r--r--engines/glk/archetype/archetype.cpp14
-rw-r--r--engines/glk/archetype/archetype.h7
-rw-r--r--engines/glk/archetype/misc.cpp5
-rw-r--r--engines/glk/archetype/misc.h8
-rw-r--r--engines/glk/archetype/sys_object.cpp16
5 files changed, 32 insertions, 18 deletions
diff --git a/engines/glk/archetype/archetype.cpp b/engines/glk/archetype/archetype.cpp
index 416cf6cc25..78ba906d3c 100644
--- a/engines/glk/archetype/archetype.cpp
+++ b/engines/glk/archetype/archetype.cpp
@@ -21,6 +21,7 @@
*/
#include "common/config-manager.h"
+#include "common/debug-channels.h"
#include "glk/archetype/archetype.h"
#include "glk/archetype/crypt.h"
#include "glk/archetype/expression.h"
@@ -41,6 +42,11 @@ Archetype *g_vm;
Archetype::Archetype(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc),
_saveSlot(-1) {
g_vm = this;
+
+ DebugMan.addDebugChannel(DEBUG_BYTES, "bytes", "Memory usage");
+ DebugMan.addDebugChannel(DEBUG_MSGS, "messages", "Messages debugging");
+ DebugMan.addDebugChannel(DEBUG_EXPR, "expressions", "Expressions debugging");
+ DebugMan.addDebugChannel(DEBUG_STMT, "statements", "Statements debugging");
}
void Archetype::runGame() {
@@ -268,12 +274,12 @@ bool Archetype::send_message(int transport, int message_sent, int recipient,
void *p;
ContextType c;
- if (message_sent == 0) {
+ if (message_sent == -1) {
cleanup(result);
return false;
}
- if ((Debug & DEBUG_MSGS) > 0) {
+ if (DebugMan.isDebugChannelEnabled(DEBUG_MSGS)) {
r._kind = IDENT;
r._data._ident.ident_kind = OBJECT_ID;
r._data._ident.ident_int = context.self;
@@ -673,7 +679,7 @@ void Archetype::eval_expr(ExprTree the_expr, ResultType &result, ContextType &co
cleanup(r1);
cleanup(r2);
- if ((Debug & DEBUG_EXPR) > 0) {
+ if (DebugMan.isDebugChannelEnabled(DEBUG_EXPR)) {
wrapout(" -- ", false);
display_expr(the_expr);
wrapout(" ==> ", false);
@@ -723,7 +729,7 @@ void Archetype::exec_stmt(StatementPtr the_stmt, ResultType &result, ContextType
undefine(r2);
cleanup(result);
- verbose = (Debug & DEBUG_STMT) > 0;
+ verbose = DebugMan.isDebugChannelEnabled(DEBUG_STMT);
if (verbose)
wrapout(" == ", false);
diff --git a/engines/glk/archetype/archetype.h b/engines/glk/archetype/archetype.h
index 85e3a4e8b3..8df78e58aa 100644
--- a/engines/glk/archetype/archetype.h
+++ b/engines/glk/archetype/archetype.h
@@ -33,6 +33,13 @@
namespace Glk {
namespace Archetype {
+enum DebugFlag {
+ DEBUG_BYTES = 0x01,
+ DEBUG_MSGS = 0x02,
+ DEBUG_EXPR = 0x04,
+ DEBUG_STMT = 0x08
+};
+
/**
* Archetype game interpreter
*/
diff --git a/engines/glk/archetype/misc.cpp b/engines/glk/archetype/misc.cpp
index c10bba1b33..3818e3107b 100644
--- a/engines/glk/archetype/misc.cpp
+++ b/engines/glk/archetype/misc.cpp
@@ -23,6 +23,7 @@
#include "glk/archetype/misc.h"
#include "glk/archetype/archetype.h"
#include "glk/quetzal.h"
+#include "common/debug-channels.h"
namespace Glk {
namespace Archetype {
@@ -31,7 +32,6 @@ const char *const VERSION_STUB = "Archetype version ";
const double VERSION_NUM = 1.02;
size_t Bytes;
-int Debug;
bool KeepLooking;
bool AllErrors;
@@ -43,7 +43,6 @@ void misc_init() {
//HeapError = @HeapFunc;
//Mark(Prior)
Bytes = 0;
- Debug = 0;
KeepLooking = true;
AllErrors = false;
}
@@ -126,7 +125,7 @@ void progfile::sourcePos() {
void add_bytes(int delta) {
Bytes += delta;
- if ((Debug & DEBUG_BYTES) != 0) {
+ if (DebugMan.isDebugChannelEnabled(DEBUG_BYTES)) {
if (delta >= 0)
g_vm->write("Allocated ");
else
diff --git a/engines/glk/archetype/misc.h b/engines/glk/archetype/misc.h
index 8d93ce7c9d..ee0809717c 100644
--- a/engines/glk/archetype/misc.h
+++ b/engines/glk/archetype/misc.h
@@ -34,13 +34,6 @@ namespace Archetype {
#define NULL_CH '\0'
#define NEWLINE_CH '\r'
-enum {
- DEBUG_BYTES = 0x01,
- DEBUG_MSGS = 0x02,
- DEBUG_EXPR = 0x04,
- DEBUG_STMT = 0x08
-};
-
enum AclType {
RESERVED, IDENT, MESSAGE, OPER, TEXT_LIT, QUOTE_LIT, NUMERIC, PUNCTUATION,
STR_PTR, ATTR_PTR, BAD_TOKEN, NEWLINE
@@ -113,7 +106,6 @@ enum ClassifyType { TYPE_ID, OBJECT_ID, ATTRIBUTE_ID, ENUMERATE_ID, UNDEFINED_ID
extern const char *const VERSION_STUB;
extern const double VERSION_NUM;
extern size_t Bytes; // Bytes consumed by allocated memory
-extern int Debug;
extern bool KeepLooking;
extern bool AllErrors;
diff --git a/engines/glk/archetype/sys_object.cpp b/engines/glk/archetype/sys_object.cpp
index d4191a3ca0..f4402fde59 100644
--- a/engines/glk/archetype/sys_object.cpp
+++ b/engines/glk/archetype/sys_object.cpp
@@ -27,6 +27,7 @@
#include "glk/archetype/parser.h"
#include "glk/archetype/wrap.h"
#include "common/algorithm.h"
+#include "common/debug-channels.h"
#include "common/savefile.h"
namespace Glk {
@@ -231,17 +232,26 @@ void send_to_system(int transport, String &strmsg, ResultType &result, ContextTy
break;
case DEBUG_MESSAGES:
- Debug = Debug ^ DEBUG_MSGS;
+ if (DebugMan.isDebugChannelEnabled(DEBUG_MSGS))
+ DebugMan.disableDebugChannel(DEBUG_MSGS);
+ else
+ DebugMan.enableDebugChannel(DEBUG_MSGS);
sys_state = IDLING;
break;
case DEBUG_EXPRESSIONS:
- Debug = Debug ^ DEBUG_EXPR;
+ if (DebugMan.isDebugChannelEnabled(DEBUG_EXPRESSIONS))
+ DebugMan.disableDebugChannel(DEBUG_EXPRESSIONS);
+ else
+ DebugMan.enableDebugChannel(DEBUG_EXPRESSIONS);
sys_state = IDLING;
break;
case DEBUG_STATEMENTS:
- Debug = Debug ^ DEBUG_STMT;
+ if (DebugMan.isDebugChannelEnabled(DEBUG_STATEMENTS))
+ DebugMan.disableDebugChannel(DEBUG_STATEMENTS);
+ else
+ DebugMan.enableDebugChannel(DEBUG_STATEMENTS);
sys_state = IDLING;
break;