[Scummvm-cvs-logs] CVS: scummvm/queen debug.h,NONE,1.1 debug.cpp,NONE,1.1 input.cpp,1.10,1.11 input.h,1.6,1.7 logic.h,1.63,1.64 logic.cpp,1.86,1.87 module.mk,1.13,1.14
Gregory Montoir
cyx at users.sourceforge.net
Sun Nov 9 12:51:02 CET 2003
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/queen logic.cpp,1.85,1.86 logic.h,1.62,1.63 structs.h,1.20,1.21 talk.cpp,1.34,1.35 talk.h,1.19,1.20 xref.txt,1.34,1.35
- Next message: [Scummvm-cvs-logs] CVS: scummvm/queen cutaway.cpp,1.60,1.61
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv24697
Modified Files:
input.cpp input.h logic.h logic.cpp module.mk
Added Files:
debug.h debug.cpp
Log Message:
enable (some of) the original debug passwords
--- NEW FILE: debug.h ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 The ScummVM project
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /cvsroot/scummvm/scummvm/queen/debug.h,v 1.1 2003/11/09 20:50:03 cyx Exp $
*
*/
#ifndef QUEENDEBUG_H
#define QUEENDEBUG_H
#include "queen/queen.h"
namespace Queen {
class Input;
class Logic;
class Graphics;
class Debug {
public:
typedef void (Debug::*DebugFunc)();
Debug(Input *, Logic *, Graphics *);
void registerStub(const char *password, DebugFunc debugFunc);
void update(int c);
void jumpToRoom();
void toggleFastMode();
void printInfo();
void toggleAreasDrawing();
void changeGameState();
void printGameState();
void giveAllItems();
static void digitKeyPressed(void *refCon, int key);
struct DebugStub {
const char *password;
DebugFunc function;
};
enum {
MAX_STUB = 5
};
private:
char _password[16];
uint _passwordCharCount;
char _digitText[50];
uint _digitTextCount;
DebugStub _stub[MAX_STUB];
uint _stubCount;
Input *_input;
Logic *_logic;
Graphics *_graphics;
};
} // End of namespace Queen
#endif
--- NEW FILE: debug.cpp ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 The ScummVM project
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /cvsroot/scummvm/scummvm/queen/debug.cpp,v 1.1 2003/11/09 20:50:03 cyx Exp $
*
*/
#include "stdafx.h"
#include "queen/debug.h"
#include "queen/defs.h"
#include "queen/graphics.h"
#include "queen/logic.h"
#include "queen/resource.h"
#include "queen/structs.h"
namespace Queen {
Debug::Debug(Input *input, Logic *logic, Graphics *graphics)
: _passwordCharCount(0), _stubCount(0), _input(input), _logic(logic), _graphics(graphics) {
memset(_password, 0, sizeof(_password));
registerStub("zeroxpark", &Debug::jumpToRoom);
registerStub("grimley", &Debug::printInfo);
registerStub("kowamori", &Debug::toggleFastMode);
}
void Debug::registerStub(const char *password, DebugFunc debugFunc) {
assert(_stubCount < MAX_STUB);
_stub[_stubCount].password = password;
_stub[_stubCount].function = debugFunc;
++_stubCount;
}
void Debug::update(int c) {
if (c >= 'a' && c <= 'z') {
_password[_passwordCharCount] = (char)c;
++_passwordCharCount;
_passwordCharCount &= 15;
uint k;
for (k = 0; k < _stubCount; ++k) {
const char *pass = _stub[k].password;
int i = strlen(pass) - 1;
int j = _passwordCharCount - 1;
bool match = true;
for (; i >= 0; --i, --j) {
if (_password[j & 15] != pass[i]) {
match = false;
break;
}
}
if (match) {
(this->*(_stub[k].function))();
break;
}
}
}
}
void Debug::jumpToRoom() {
debug(9, "Debug::jumpToRoom()");
_graphics->textCurrentColor(INK_JOE);
_graphics->textSet(0, 142, "Enter new room");
_logic->update();
int room;
_digitTextCount = 0;
if (_input->waitForNumber(room, digitKeyPressed, this)) {
_logic->joeX(0);
_logic->joeY(0);
_logic->newRoom(room);
_logic->entryObj(_logic->roomData(room) + 1);
_graphics->textClear(0, 199);
}
}
void Debug::toggleFastMode() {
debug(9, "Debug::toggleFastMode()");
_input->fastMode(!_input->fastMode());
}
void Debug::printInfo() {
debug(9, "Debug::printInfo()");
_graphics->textClear(0, 199);
_graphics->textCurrentColor(INK_JOE);
char buf[100];
snprintf(buf, sizeof(buf), "Version : %s", _logic->resource()->JASVersion());
_graphics->textSet(110, 20, buf);
snprintf(buf, sizeof(buf), "Room number : %d", _logic->currentRoom());
_graphics->textSet(110, 40, buf);
snprintf(buf, sizeof(buf), "Room name : %s", _logic->roomName(_logic->currentRoom()));
_graphics->textSet(110, 60, buf);
_logic->update();
char c;
if (_input->waitForCharacter(c)) {
switch (c) {
case 'a':
toggleAreasDrawing();
break;
case 's' :
changeGameState();
break;
case 'x' :
printGameState();
break;
case 'i' :
giveAllItems();
break;
}
}
_graphics->textClear(0, 199);
}
void Debug::toggleAreasDrawing() {
debug(9, "Debug::toggleAreasDrawing()");
warning("Debug::toggleAreasDrawing() unimplemented");
}
void Debug::changeGameState() {
debug(9, "Debug::changeGameState()");
_graphics->textSet(0, 142, "Set GAMESTATE");
_logic->update();
int slot, value;
_digitTextCount = 0;
if (_input->waitForNumber(slot, digitKeyPressed, this)) {
_graphics->textClear(0, 199);
_graphics->textSet(0, 142, "to");
_logic->update();
_digitTextCount = 0;
if (_input->waitForNumber(value, digitKeyPressed, this)) {
_logic->gameState(slot, value);
}
}
}
void Debug::printGameState() {
debug(9, "Debug::printGameState()");
_graphics->textSet(0, 142, "Show GAMESTATE");
_logic->update();
int slot;
_digitTextCount = 0;
if (_input->waitForNumber(slot, digitKeyPressed, this)) {
_graphics->textClear(0, 199);
char buf[50];
snprintf(buf, sizeof(buf), "Currently - %d", _logic->gameState(slot));
_graphics->textSet(0, 142, buf);
_logic->update();
char c;
_input->waitForCharacter(c);
}
}
void Debug::giveAllItems() {
debug(9, "Debug::giveAllItems()");
int n = _logic->itemDataCount();
ItemData *item = _logic->itemData(1);
while (n--) {
item->name = ABS(item->name);
++item;
}
}
void Debug::digitKeyPressed(void *refCon, int key) {
Debug *debug = (Debug *)refCon;
if(key != -1 && debug->_digitTextCount < sizeof(debug->_digitText) - 1) {
debug->_digitText[debug->_digitTextCount] = (char)key;
++debug->_digitTextCount;
}
else if (debug->_digitTextCount > 0) {
--debug->_digitTextCount;
}
debug->_digitText[debug->_digitTextCount] = '\0';
debug->_graphics->textSet(0, 151, debug->_digitText);
debug->_logic->update();
}
}
Index: input.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/input.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- input.cpp 8 Nov 2003 23:45:45 -0000 1.10
+++ input.cpp 9 Nov 2003 20:50:03 -0000 1.11
@@ -126,7 +126,7 @@
} while (cur < start + amount);
}
-void Input::checkKeys() {
+int Input::checkKeys() {
if (_inKey)
debug(0, "[Input::checkKeys] _inKey = %i", _inKey);
@@ -205,8 +205,48 @@
_keyVerb = Verb(VERB_USE);
break;
}
-
+
+ int inKey = _inKey;
_inKey = 0; //reset
+ return inKey;
+}
+
+
+bool Input::waitForNumber(int &i, keyPressedCallback callback, void *refCon) {
+
+ i = 0;
+ int key = 0;
+ do {
+ delay(DELAY_SHORT);
+ key = _inKey;
+ _inKey = 0;
+ if (key >= '0' && key <= '9') {
+ i = i * 10 + key - '0';
+ (*callback)(refCon, key);
+ }
+ else if (key == KEY_BACKSPACE) {
+ i /= 10;
+ (*callback)(refCon, -1);
+ }
+ } while (key != KEY_ESCAPE && key != KEY_RETURN);
+ return key != KEY_ESCAPE;
+}
+
+
+bool Input::waitForCharacter(char &c) {
+
+ int key = 0;
+ do {
+ delay(DELAY_SHORT);
+ if (_inKey >= 'a' && _inKey <= 'z' || _inKey == KEY_ESCAPE) {
+ key = _inKey;
+ if (_inKey != KEY_ESCAPE) {
+ c = (char)_inKey;
+ }
+ }
+ _inKey = 0;
+ } while (key == 0);
+ return key != KEY_ESCAPE;
}
Index: input.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/input.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- input.h 2 Nov 2003 20:42:36 -0000 1.6
+++ input.h 9 Nov 2003 20:50:03 -0000 1.7
@@ -34,6 +34,8 @@
public:
+ typedef void (*keyPressedCallback)(void *refCon, int key);
+
//! Adjust here to change delays!
enum {
DELAY_SHORT = 10,
@@ -54,7 +56,7 @@
void delay(uint amount);
//! convert input to verb
- void checkKeys();
+ int checkKeys();
//! use instead of KEYVERB=0
void clearKeyVerb() { _keyVerb = Verb(VERB_NONE); }
@@ -70,6 +72,7 @@
bool talkQuit() const { return _talkQuit; }
void talkQuitReset() { _talkQuit = false; }
+ bool fastMode() const { return _fastMode; }
void fastMode(bool fm) { _fastMode = fm; }
Verb keyVerb() const { return _keyVerb; }
@@ -80,6 +83,9 @@
int mouseButton() const { return _mouseButton; }
void clearMouseButton() { _mouseButton = 0; }
+ bool waitForNumber(int &i, keyPressedCallback callback, void *refCon);
+ bool waitForCharacter(char &c);
+
private:
enum KeyCode {
@@ -92,7 +98,9 @@
KEY_DIGIT_3 = '3',
KEY_DIGIT_4 = '4',
- KEY_ESCAPE = 27,
+ KEY_ESCAPE = 27,
+ KEY_RETURN = 13,
+ KEY_BACKSPACE = 8,
KEY_F1 = 282
};
Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- logic.h 9 Nov 2003 14:16:46 -0000 1.63
+++ logic.h 9 Nov 2003 20:50:03 -0000 1.64
@@ -108,6 +108,7 @@
class Command;
+class Debug;
class Display;
class Input;
class Graphics;
@@ -150,6 +151,7 @@
uint16 objMax(int room);
GraphicData *graphicData(int index);
ItemData *itemData(int index) const { return &_itemData[index]; }
+ uint16 itemDataCount() const { return _numItems; }
uint16 findBob(uint16 obj);
uint16 findFrame(uint16 obj);
@@ -264,6 +266,7 @@
Walk *walk() const { return _walk; }
Display *display() const { return _display; }
Command *command() const { return _cmd; }
+ Resource *resource() const { return _resource; }
uint16 findObjectRoomNumber(uint16 zoneNum) const;
uint16 findObjectGlobalNumber(uint16 zoneNum) const;
@@ -434,6 +437,7 @@
Resource *_resource;
Graphics *_graphics;
+ Debug *_dbg;
Display *_display;
Input *_input;
Sound *_sound;
@@ -443,6 +447,7 @@
//! Verbs (in order) available in panel
static const VerbEnum PANEL_VERBS[];
};
+
} // End of namespace Queen
Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- logic.cpp 9 Nov 2003 14:16:46 -0000 1.86
+++ logic.cpp 9 Nov 2003 20:50:03 -0000 1.87
@@ -24,6 +24,7 @@
#include "queen/command.h"
#include "queen/cutaway.h"
#include "queen/defs.h"
+#include "queen/debug.h"
#include "queen/display.h"
#include "queen/graphics.h"
#include "queen/input.h"
@@ -174,8 +175,8 @@
Common::RandomSource Logic::randomizer;
-Logic::Logic(Resource *resource, Graphics *graphics, Display *theDisplay, Input *input, Sound *sound)
- : _resource(resource), _graphics(graphics), _display(theDisplay),
+Logic::Logic(Resource *theResource, Graphics *graphics, Display *theDisplay, Input *input, Sound *sound)
+ : _resource(theResource), _graphics(graphics), _display(theDisplay),
_input(input), _sound(sound) {
_settings.talkSpeed = DEFAULT_TALK_SPEED;
_jas = _resource->loadFile("QUEEN.JAS", 20);
@@ -183,6 +184,7 @@
_joe.scale = 100;
_walk = new Walk(this, _graphics);
_cmd = new Command(this, _graphics, _input, _walk);
+ _dbg = new Debug(_input, this, _graphics);
memset(_gameState, 0, sizeof(_gameState));
memset(_talkSelected, 0, sizeof(_talkSelected));
initialise();
@@ -192,6 +194,7 @@
delete[] _jas;
delete _walk;
delete _cmd;
+ delete _dbg;
}
void Logic::initialise() {
@@ -2317,7 +2320,7 @@
_display->palCustomScroll(_currentRoom);
BobSlot *joe = _graphics->bob(0);
_display->update(joe->active, joe->x, joe->y);
- _input->checkKeys();
+ _dbg->update(_input->checkKeys());
}
void Logic::sceneStart(bool showMouseCursor) {
Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/module.mk,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- module.mk 31 Oct 2003 13:46:45 -0000 1.13
+++ module.mk 9 Nov 2003 20:50:03 -0000 1.14
@@ -3,6 +3,7 @@
MODULE_OBJS = \
queen/command.o \
queen/cutaway.o \
+ queen/debug.o \
queen/display.o \
queen/graphics.o \
queen/input.o \
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/queen logic.cpp,1.85,1.86 logic.h,1.62,1.63 structs.h,1.20,1.21 talk.cpp,1.34,1.35 talk.h,1.19,1.20 xref.txt,1.34,1.35
- Next message: [Scummvm-cvs-logs] CVS: scummvm/queen cutaway.cpp,1.60,1.61
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list