From 6856fa2447195e8a65f6d5c7efa73543668d85b0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 22 May 2012 00:29:27 +1000 Subject: TONY: Implemented ScummVM debugger, with an initial 'scene' command --- engines/tony/debugger.cpp | 116 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 engines/tony/debugger.cpp (limited to 'engines/tony/debugger.cpp') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp new file mode 100644 index 0000000000..f358d51223 --- /dev/null +++ b/engines/tony/debugger.cpp @@ -0,0 +1,116 @@ +/* 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 "common/coroutines.h" +#include "tony/debugger.h" +#include "tony/globals.h" +#include "tony/tony.h" + +namespace Tony { + +Debugger::Debugger() : GUI::Debugger() { + DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); + DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_Scene)); +} + +static int strToInt(const char *s) { + if (!*s) + // No string at all + return 0; + else if (toupper(s[strlen(s) - 1]) != 'H') + // Standard decimal string + return atoi(s); + + // Hexadecimal string + uint tmp = 0; + int read = sscanf(s, "%xh", &tmp); + if (read < 1) + error("strToInt failed on string \"%s\"", s); + return (int)tmp; +} + +/** + * Support process for changing the scene + */ +struct ChangeSceneDetails { + int sceneNumber; + int x; + int y; +}; + +void DebugChangeScene(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + uint32 result; + const ChangeSceneDetails *details = (const ChangeSceneDetails *)param; + RMPoint scenePos(details->x, details->y); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(GLOBALS.UnloadLocation, false, &result); + + GLOBALS.LoadLocation(details->sceneNumber, scenePos, RMPoint(-1, -1)); + + MainEnableGUI(); + + CORO_END_CODE; +} + + +/** + * This command loads up the specified new scene number + */ +bool Debugger::Cmd_Scene(int argc, const char **argv) { + if (argc < 2) { + DebugPrintf("Usage: %s [ ]\n", argv[0]); + return true; + } + + int sceneNumber = strToInt(argv[1]); + if (sceneNumber >= _vm->_theBoxes.GetLocBoxesCount()) { + DebugPrintf("Invalid scene\n"); + return true; + } + + RMPoint scenePos; + if (argc >= 4) { + scenePos.x = strToInt(argv[2]); + scenePos.y = strToInt(argv[3]); + } else { + // Get the box areas for the scene, and choose one so as to have a default + // position for Tony that will be in the walkable areas + RMBoxLoc *box = _vm->_theBoxes.GetBoxes(sceneNumber); + scenePos.Set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); + } + + // Set up a process to change the scene + ChangeSceneDetails details; + details.sceneNumber = sceneNumber; + details.x = scenePos.x; + details.y = scenePos.y; + CoroScheduler.createProcess(DebugChangeScene, &details, sizeof(ChangeSceneDetails)); + + return false; +} + +} // End of namespace Tony -- cgit v1.2.3 From 93cba6d88049d73b965143130a1f7751e3dc79db Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jun 2012 01:15:25 +0200 Subject: TONY: Rename variables and functions in adv.h --- engines/tony/debugger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/tony/debugger.cpp') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index f358d51223..7dc32d9f61 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -71,7 +71,7 @@ void DebugChangeScene(CORO_PARAM, const void *param) { GLOBALS.LoadLocation(details->sceneNumber, scenePos, RMPoint(-1, -1)); - MainEnableGUI(); + mainEnableGUI(); CORO_END_CODE; } -- cgit v1.2.3 From 53bd99ce870ac5bd7f65d1e45641e13070f652d0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jun 2012 07:58:01 +0200 Subject: TONY: Rename variables and functions in loc.h and tonychar.h --- engines/tony/debugger.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/tony/debugger.cpp') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 7dc32d9f61..66fddf2834 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -87,7 +87,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { } int sceneNumber = strToInt(argv[1]); - if (sceneNumber >= _vm->_theBoxes.GetLocBoxesCount()) { + if (sceneNumber >= _vm->_theBoxes.getLocBoxesCount()) { DebugPrintf("Invalid scene\n"); return true; } @@ -99,7 +99,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { } else { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas - RMBoxLoc *box = _vm->_theBoxes.GetBoxes(sceneNumber); + RMBoxLoc *box = _vm->_theBoxes.getBoxes(sceneNumber); scenePos.Set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); } -- cgit v1.2.3 From f12ab3e521b01ed2b40e7d517753dd14bc6e6f0f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jun 2012 08:42:35 +0200 Subject: TONY: Rename variables and functions in utils.h --- engines/tony/debugger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/tony/debugger.cpp') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 66fddf2834..af2bffc459 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -100,7 +100,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas RMBoxLoc *box = _vm->_theBoxes.getBoxes(sceneNumber); - scenePos.Set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); + scenePos.set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); } // Set up a process to change the scene -- cgit v1.2.3 From 44ee26e6c99383dd9cec1392afae958faaf87b12 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 10 Jun 2012 23:56:37 +0200 Subject: TONY: Rename variables in loc.h and mpal.h --- engines/tony/debugger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/tony/debugger.cpp') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index af2bffc459..1a4dc16b75 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -100,7 +100,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas RMBoxLoc *box = _vm->_theBoxes.getBoxes(sceneNumber); - scenePos.set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); + scenePos.set(box->_boxes[0]._hotspot[0]._hotx, box->_boxes[0]._hotspot[0]._hoty); } // Set up a process to change the scene -- cgit v1.2.3 From 02c8ccebcb20aa904dba3151d65a7b4fa67998fe Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jun 2012 20:24:25 +0200 Subject: TONY: Rename variables in utils.h --- engines/tony/debugger.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/tony/debugger.cpp') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 1a4dc16b75..8beb7285a4 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -94,8 +94,8 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { RMPoint scenePos; if (argc >= 4) { - scenePos.x = strToInt(argv[2]); - scenePos.y = strToInt(argv[3]); + scenePos._x = strToInt(argv[2]); + scenePos._y = strToInt(argv[3]); } else { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas @@ -106,8 +106,8 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { // Set up a process to change the scene ChangeSceneDetails details; details.sceneNumber = sceneNumber; - details.x = scenePos.x; - details.y = scenePos.y; + details.x = scenePos._x; + details.y = scenePos._y; CoroScheduler.createProcess(DebugChangeScene, &details, sizeof(ChangeSceneDetails)); return false; -- cgit v1.2.3 From eef6b444df766b90d1323941c7ff9bd8355c111b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 22 Jun 2012 23:47:39 +1000 Subject: TONY: Created a debugger command 'dirty_rects' to show dirty rect areas on-screen --- engines/tony/debugger.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'engines/tony/debugger.cpp') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 8beb7285a4..75e58d68d4 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -30,6 +30,7 @@ namespace Tony { Debugger::Debugger() : GUI::Debugger() { DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_Scene)); + DCmd_Register("dirty_rects", WRAP_METHOD(Debugger, Cmd_DirtyRects)); } static int strToInt(const char *s) { @@ -113,4 +114,17 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { return false; } +/** + * Turns showing dirty rects on or off + */ +bool Debugger::Cmd_DirtyRects(int argc, const char **argv) { + if (argc != 2) { + DebugPrintf("Usage; %s [on | off]\n", argv[0]); + return true; + } else { + _vm->_window.showDirtyRects(strcmp(argv[1], "on") == 0); + return false; + } +} + } // End of namespace Tony -- cgit v1.2.3 From c3407390013b1e1826bdb31979a50f5e8a957f04 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 22 Aug 2012 14:00:46 +0200 Subject: TONY: Replace _vm with g_vm. --- engines/tony/debugger.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/tony/debugger.cpp') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 75e58d68d4..6355284ece 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -88,7 +88,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { } int sceneNumber = strToInt(argv[1]); - if (sceneNumber >= _vm->_theBoxes.getLocBoxesCount()) { + if (sceneNumber >= g_vm->_theBoxes.getLocBoxesCount()) { DebugPrintf("Invalid scene\n"); return true; } @@ -100,7 +100,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { } else { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas - RMBoxLoc *box = _vm->_theBoxes.getBoxes(sceneNumber); + RMBoxLoc *box = g_vm->_theBoxes.getBoxes(sceneNumber); scenePos.set(box->_boxes[0]._hotspot[0]._hotx, box->_boxes[0]._hotspot[0]._hoty); } @@ -122,7 +122,7 @@ bool Debugger::Cmd_DirtyRects(int argc, const char **argv) { DebugPrintf("Usage; %s [on | off]\n", argv[0]); return true; } else { - _vm->_window.showDirtyRects(strcmp(argv[1], "on") == 0); + g_vm->_window.showDirtyRects(strcmp(argv[1], "on") == 0); return false; } } -- cgit v1.2.3 From 142ac7600f61e193612ec81c7fd7070ec2ca5c0e Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 22:28:44 +0200 Subject: TONY: Remove most of the remaining global functions. --- engines/tony/debugger.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/tony/debugger.cpp') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 6355284ece..85d9469519 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -68,9 +68,9 @@ void DebugChangeScene(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(GLOBALS.UnloadLocation, false, &result); + CORO_INVOKE_2(g_vm->getEngine()->unloadLocation, false, &result); - GLOBALS.LoadLocation(details->sceneNumber, scenePos, RMPoint(-1, -1)); + g_vm->getEngine()->loadLocation(details->sceneNumber, scenePos, RMPoint(-1, -1)); mainEnableGUI(); -- cgit v1.2.3