2005-01-17 10:57:15 +00:00
|
|
|
/* Copyright (C) 1994-1998 Revolution Software Ltd.
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2003-2006 The ScummVM project
|
2003-07-28 01:44:38 +00:00
|
|
|
*
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-07-28 01:44:38 +00:00
|
|
|
*
|
2006-02-09 15:12:44 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2003-07-28 01:44:38 +00:00
|
|
|
*/
|
|
|
|
|
2003-11-16 14:18:29 +00:00
|
|
|
#include "common/stdafx.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "common/rect.h"
|
|
|
|
|
2003-10-28 19:51:30 +00:00
|
|
|
#include "sword2/sword2.h"
|
|
|
|
#include "sword2/defs.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "sword2/header.h"
|
|
|
|
#include "sword2/console.h"
|
2004-02-05 14:19:07 +00:00
|
|
|
#include "sword2/logic.h"
|
|
|
|
#include "sword2/maketext.h"
|
2004-11-14 15:00:01 +00:00
|
|
|
#include "sword2/memory.h"
|
2005-02-19 14:02:16 +00:00
|
|
|
#include "sword2/mouse.h"
|
2004-02-05 14:19:07 +00:00
|
|
|
#include "sword2/resman.h"
|
2004-11-14 15:00:01 +00:00
|
|
|
#include "sword2/router.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "sword2/screen.h"
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
namespace Sword2 {
|
|
|
|
|
2005-02-22 07:37:50 +00:00
|
|
|
void Debugger::clearDebugTextBlocks() {
|
2003-09-27 11:02:58 +00:00
|
|
|
uint8 blockNo = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
while (blockNo < MAX_DEBUG_TEXTS && _debugTextBlocks[blockNo] > 0) {
|
2003-09-27 11:02:58 +00:00
|
|
|
// kill the system text block
|
2003-11-16 14:18:29 +00:00
|
|
|
_vm->_fontRenderer->killTextBloc(_debugTextBlocks[blockNo]);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-27 11:02:58 +00:00
|
|
|
// clear this element of our array of block numbers
|
2003-11-02 15:58:45 +00:00
|
|
|
_debugTextBlocks[blockNo] = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
blockNo++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
void Debugger::makeDebugTextBlock(char *text, int16 x, int16 y) {
|
2003-09-27 11:02:58 +00:00
|
|
|
uint8 blockNo = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
while (blockNo < MAX_DEBUG_TEXTS && _debugTextBlocks[blockNo] > 0)
|
2003-07-28 01:44:38 +00:00
|
|
|
blockNo++;
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
assert(blockNo < MAX_DEBUG_TEXTS);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-05-12 13:12:15 +00:00
|
|
|
_debugTextBlocks[blockNo] = _vm->_fontRenderer->buildNewBloc((byte *)text, x, y, 640 - x, 0, RDSPR_DISPLAYALIGN, CONSOLE_FONT_ID, NO_JUSTIFICATION);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2005-02-22 07:37:50 +00:00
|
|
|
void Debugger::buildDebugText() {
|
2003-07-28 01:44:38 +00:00
|
|
|
char buf[128];
|
|
|
|
|
2003-09-27 11:02:58 +00:00
|
|
|
int32 showVarNo; // for variable watching
|
2003-07-28 01:44:38 +00:00
|
|
|
int32 showVarPos;
|
|
|
|
int32 varNo;
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
ScreenInfo *screenInfo = _vm->_screen->getScreenInfo();
|
|
|
|
|
2003-09-27 11:02:58 +00:00
|
|
|
// clear the array of text block numbers for the debug text
|
2003-11-02 15:58:45 +00:00
|
|
|
clearDebugTextBlocks();
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// mouse coords
|
2003-09-27 11:02:58 +00:00
|
|
|
// print mouse coords beside mouse-marker, if it's being displayed
|
2005-02-19 14:02:16 +00:00
|
|
|
if (_displayMouseMarker) {
|
|
|
|
int mouseX, mouseY;
|
|
|
|
|
|
|
|
_vm->_mouse->getPos(mouseX, mouseY);
|
|
|
|
|
|
|
|
sprintf(buf, "%d,%d", mouseX + screenInfo->scroll_offset_x, mouseY + screenInfo->scroll_offset_y);
|
|
|
|
if (mouseX > 560)
|
|
|
|
makeDebugTextBlock(buf, mouseX - 50, mouseY - 15);
|
2003-07-28 01:44:38 +00:00
|
|
|
else
|
2005-02-19 14:02:16 +00:00
|
|
|
makeDebugTextBlock(buf, mouseX + 5, mouseY - 15);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// mouse area coords
|
|
|
|
|
2003-09-27 11:02:58 +00:00
|
|
|
// defining a mouse area the easy way, by creating a box on-screen
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (_draggingRectangle || _vm->_logic->readVar(SYSTEM_TESTING_ANIMS)) {
|
2003-09-27 11:02:58 +00:00
|
|
|
// so we can see what's behind the lines
|
2003-11-02 15:58:45 +00:00
|
|
|
_rectFlicker = !_rectFlicker;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
sprintf(buf, "x1=%d", _rectX1);
|
|
|
|
makeDebugTextBlock(buf, 0, 120);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
sprintf(buf, "y1=%d", _rectY1);
|
|
|
|
makeDebugTextBlock(buf, 0, 135);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
sprintf(buf, "x2=%d", _rectX2);
|
|
|
|
makeDebugTextBlock(buf, 0, 150);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
sprintf(buf, "y2=%d", _rectY2);
|
|
|
|
makeDebugTextBlock(buf, 0, 165);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// testingSnR indicator
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_testingSnR) { // see fnAddHuman()
|
|
|
|
sprintf(buf, "TESTING LOGIC STABILITY!");
|
|
|
|
makeDebugTextBlock(buf, 0, 105);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2004-11-16 09:15:25 +00:00
|
|
|
#ifdef SWORD2_DEBUG
|
2003-07-28 01:44:38 +00:00
|
|
|
// speed-up indicator
|
|
|
|
|
2004-11-16 09:15:25 +00:00
|
|
|
if (_vm->_renderSkip) { // see sword2.cpp
|
2003-11-02 15:58:45 +00:00
|
|
|
sprintf(buf, "SKIPPING FRAMES FOR SPEED-UP!");
|
|
|
|
makeDebugTextBlock(buf, 0, 120);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2004-11-16 09:15:25 +00:00
|
|
|
#endif
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// debug info at top of screen - enabled/disabled as one complete unit
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_displayTime) {
|
2005-01-10 22:06:49 +00:00
|
|
|
int32 time = _vm->getMillis();
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
if ((time - _startTime) / 1000 >= 10000)
|
|
|
|
_startTime = time;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
time -= _startTime;
|
2003-09-27 11:02:58 +00:00
|
|
|
sprintf(buf, "Time %.2d:%.2d:%.2d.%.3d", (time / 3600000) % 60, (time / 60000) % 60, (time / 1000) % 60, time % 1000);
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 500, 360);
|
2003-11-08 15:47:51 +00:00
|
|
|
sprintf(buf, "Game %d", _vm->_gameCycle);
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 500, 380);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// current text number & speech-sample resource id
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_displayTextNumbers) {
|
|
|
|
if (_textNumber) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (_vm->_logic->readVar(SYSTEM_TESTING_TEXT)) {
|
|
|
|
if (_vm->_logic->readVar(SYSTEM_WANT_PREVIOUS_LINE))
|
2003-10-26 15:42:49 +00:00
|
|
|
sprintf(buf, "backwards");
|
2003-07-28 01:44:38 +00:00
|
|
|
else
|
2003-10-26 15:42:49 +00:00
|
|
|
sprintf(buf, "forwards");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 0, 340);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
sprintf(buf, "res: %d", _textNumber / SIZE);
|
|
|
|
makeDebugTextBlock(buf, 0, 355);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
sprintf(buf, "pos: %d", _textNumber & 0xffff);
|
|
|
|
makeDebugTextBlock(buf, 0, 370);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-15 09:38:00 +00:00
|
|
|
sprintf(buf, "TEXT: %d", _vm->_logic->_officialTextNumber);
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 0, 385);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// resource number currently being checking for animation
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (_vm->_logic->readVar(SYSTEM_TESTING_ANIMS)) {
|
|
|
|
sprintf(buf, "trying resource %d", _vm->_logic->readVar(SYSTEM_TESTING_ANIMS));
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 0, 90);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// general debug info
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_displayDebugText) {
|
2004-04-24 12:29:35 +00:00
|
|
|
byte name[NAME_LEN];
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
/*
|
|
|
|
// CD in use
|
2003-11-02 15:58:45 +00:00
|
|
|
sprintf(buf, "CD-%d", currentCD);
|
|
|
|
makeDebugTextBlock(buf, 0, 0);
|
2003-07-28 01:44:38 +00:00
|
|
|
*/
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// mouse coords & object pointed to
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (_vm->_logic->readVar(CLICKED_ID))
|
2003-09-27 11:02:58 +00:00
|
|
|
sprintf(buf, "last click at %d,%d (id %d: %s)",
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_vm->_logic->readVar(MOUSE_X),
|
|
|
|
_vm->_logic->readVar(MOUSE_Y),
|
|
|
|
_vm->_logic->readVar(CLICKED_ID),
|
|
|
|
_vm->_resman->fetchName(_vm->_logic->readVar(CLICKED_ID), name));
|
2003-07-28 01:44:38 +00:00
|
|
|
else
|
2003-09-27 11:02:58 +00:00
|
|
|
sprintf(buf, "last click at %d,%d (---)",
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_vm->_logic->readVar(MOUSE_X),
|
|
|
|
_vm->_logic->readVar(MOUSE_Y));
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 0, 15);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
uint32 mouseTouching = _vm->_mouse->getMouseTouching();
|
|
|
|
|
|
|
|
int mouseX, mouseY;
|
|
|
|
|
|
|
|
_vm->_mouse->getPos(mouseX, mouseY);
|
|
|
|
|
|
|
|
if (mouseTouching)
|
2003-09-27 11:02:58 +00:00
|
|
|
sprintf(buf, "mouse %d,%d (id %d: %s)",
|
2005-02-19 14:02:16 +00:00
|
|
|
mouseX + screenInfo->scroll_offset_x,
|
|
|
|
mouseY + screenInfo->scroll_offset_y,
|
|
|
|
mouseTouching,
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_vm->_resman->fetchName(mouseTouching, name));
|
2003-07-28 01:44:38 +00:00
|
|
|
else
|
2003-09-27 11:02:58 +00:00
|
|
|
sprintf(buf, "mouse %d,%d (not touching)",
|
2005-02-19 14:02:16 +00:00
|
|
|
mouseX + screenInfo->scroll_offset_x,
|
|
|
|
mouseY + screenInfo->scroll_offset_y);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 0, 30);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// player coords & graphic info
|
2003-09-27 11:02:58 +00:00
|
|
|
// if player objct has a graphic
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (_graphAnimRes)
|
2003-09-27 11:02:58 +00:00
|
|
|
sprintf(buf, "player %d,%d %s (%d) #%d/%d",
|
2005-02-19 14:02:16 +00:00
|
|
|
screenInfo->player_feet_x,
|
|
|
|
screenInfo->player_feet_y,
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_vm->_resman->fetchName(_graphAnimRes, name),
|
|
|
|
_graphAnimRes,
|
|
|
|
_graphAnimPc,
|
|
|
|
_graphNoFrames);
|
2003-07-28 01:44:38 +00:00
|
|
|
else
|
2003-09-27 11:02:58 +00:00
|
|
|
sprintf(buf, "player %d,%d --- %d",
|
2005-02-19 14:02:16 +00:00
|
|
|
screenInfo->player_feet_x,
|
|
|
|
screenInfo->player_feet_y,
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_graphAnimPc);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 0, 45);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// frames-per-second counter
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
sprintf(buf, "fps %d", _vm->_screen->getFps());
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 440, 0);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// location number
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
sprintf(buf, "location=%d", _vm->_logic->readVar(LOCATION));
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 440, 15);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// "result" variable
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
sprintf(buf, "result=%d", _vm->_logic->readVar(RESULT));
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 440, 30);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// no. of events in event list
|
|
|
|
|
2003-11-15 09:38:00 +00:00
|
|
|
sprintf(buf, "events=%d", _vm->_logic->countEvents());
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 440, 45);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// sprite list usage
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
sprintf(buf, "bgp0: %d/%d", _vm->_screen->getCurBgp0(), MAX_bgp0_sprites);
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 560, 0);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
sprintf(buf, "bgp1: %d/%d", _vm->_screen->getCurBgp1(), MAX_bgp1_sprites);
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 560, 15);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
sprintf(buf, "back: %d/%d", _vm->_screen->getCurBack(), MAX_back_sprites);
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 560, 30);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
sprintf(buf, "sort: %d/%d", _vm->_screen->getCurSort(), MAX_sort_sprites);
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 560, 45);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
sprintf(buf, "fore: %d/%d", _vm->_screen->getCurFore(), MAX_fore_sprites);
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 560, 60);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
sprintf(buf, "fgp0: %d/%d", _vm->_screen->getCurFgp0(), MAX_fgp0_sprites);
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 560, 75);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
sprintf(buf, "fgp1: %d/%d", _vm->_screen->getCurFgp1(), MAX_fgp1_sprites);
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 560, 90);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// largest layer & sprite
|
|
|
|
|
|
|
|
// NB. Strings already constructed in Build_display.cpp
|
2005-02-19 14:02:16 +00:00
|
|
|
makeDebugTextBlock(_vm->_screen->getLargestLayerInfo(), 0, 60);
|
|
|
|
makeDebugTextBlock(_vm->_screen->getLargestSpriteInfo(), 0, 75);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-18 08:11:50 +00:00
|
|
|
// "waiting for person" indicator - set form fnTheyDo and
|
|
|
|
// fnTheyDoWeWait
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-05-05 07:06:18 +00:00
|
|
|
if (_speechScriptWaiting) {
|
2003-09-27 11:02:58 +00:00
|
|
|
sprintf(buf, "script waiting for %s (%d)",
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_vm->_resman->fetchName(_speechScriptWaiting, name),
|
2004-05-05 07:06:18 +00:00
|
|
|
_speechScriptWaiting);
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 0, 90);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// variable watch display
|
|
|
|
|
|
|
|
showVarPos = 115; // y-coord for first showVar
|
|
|
|
|
2003-09-27 11:02:58 +00:00
|
|
|
for (showVarNo = 0; showVarNo < MAX_SHOWVARS; showVarNo++) {
|
2003-11-02 15:58:45 +00:00
|
|
|
varNo = _showVar[showVarNo]; // get variable number
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-27 11:02:58 +00:00
|
|
|
// if non-zero ie. cannot watch 'id' but not needed
|
|
|
|
// anyway because it changes throughout the logic loop
|
|
|
|
|
|
|
|
if (varNo) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
sprintf(buf, "var(%d) = %d", varNo, _vm->_logic->readVar(varNo));
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 530, showVarPos);
|
2003-07-28 01:44:38 +00:00
|
|
|
showVarPos += 15; // next line down
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-27 11:02:58 +00:00
|
|
|
// memory indicator - this should come last, to show all the
|
|
|
|
// sprite blocks above!
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-22 07:37:50 +00:00
|
|
|
uint32 totAlloc = _vm->_memory->getTotAlloc();
|
|
|
|
int16 numBlocks = _vm->_memory->getNumBlocks();
|
|
|
|
|
|
|
|
if (totAlloc < 1024)
|
|
|
|
sprintf(buf, "%u bytes in %d memory blocks", totAlloc, numBlocks);
|
|
|
|
else if (totAlloc < 1024 * 1024)
|
|
|
|
sprintf(buf, "%uK in %d memory blocks", totAlloc / 1024, numBlocks);
|
|
|
|
else
|
|
|
|
sprintf(buf, "%.02fM in %d memory blocks", totAlloc / 1048576., numBlocks);
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
makeDebugTextBlock(buf, 0, 0);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-22 07:37:50 +00:00
|
|
|
void Debugger::drawDebugGraphics() {
|
2005-02-19 14:02:16 +00:00
|
|
|
ScreenInfo *screenInfo = _vm->_screen->getScreenInfo();
|
2003-07-28 01:44:38 +00:00
|
|
|
// walk-grid
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_displayWalkGrid)
|
2005-07-30 21:11:48 +00:00
|
|
|
_vm->_logic->_router->plotWalkGrid();
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// player feet coord marker
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_displayPlayerMarker)
|
2005-02-19 14:02:16 +00:00
|
|
|
plotCrossHair(screenInfo->player_feet_x, screenInfo->player_feet_y, 215);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// mouse marker & coords
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
if (_displayMouseMarker) {
|
|
|
|
int mouseX, mouseY;
|
|
|
|
|
|
|
|
_vm->_mouse->getPos(mouseX, mouseY);
|
|
|
|
|
|
|
|
plotCrossHair(mouseX + screenInfo->scroll_offset_x, mouseY + screenInfo->scroll_offset_y, 215);
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// mouse area rectangle / sprite box rectangle when testing anims
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (_vm->_logic->readVar(SYSTEM_TESTING_ANIMS)) {
|
2003-09-27 11:02:58 +00:00
|
|
|
// draw box around current frame
|
2003-11-02 15:58:45 +00:00
|
|
|
drawRect(_rectX1, _rectY1, _rectX2, _rectY2, 184);
|
|
|
|
} else if (_draggingRectangle) {
|
2003-09-27 11:02:58 +00:00
|
|
|
// defining a mouse area the easy way, by creating a box
|
|
|
|
// on-screen
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_rectFlicker)
|
|
|
|
drawRect(_rectX1, _rectY1, _rectX2, _rectY2, 184);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
void Debugger::plotCrossHair(int16 x, int16 y, uint8 pen) {
|
2005-02-19 14:02:16 +00:00
|
|
|
_vm->_screen->plotPoint(x, y, pen);
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
_vm->_screen->drawLine(x - 2, y, x - 5, y, pen);
|
|
|
|
_vm->_screen->drawLine(x + 2, y, x + 5, y, pen);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
_vm->_screen->drawLine(x, y - 2, x, y - 5, pen);
|
|
|
|
_vm->_screen->drawLine(x, y + 2, x, y + 5, pen);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
void Debugger::drawRect(int16 x1, int16 y1, int16 x2, int16 y2, uint8 pen) {
|
2005-02-19 14:02:16 +00:00
|
|
|
_vm->_screen->drawLine(x1, y1, x2, y1, pen); // top edge
|
|
|
|
_vm->_screen->drawLine(x1, y2, x2, y2, pen); // bottom edge
|
|
|
|
_vm->_screen->drawLine(x1, y1, x1, y2, pen); // left edge
|
|
|
|
_vm->_screen->drawLine(x2, y1, x2, y2, pen); // right edge
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
} // End of namespace Sword2
|