[Scummvm-git-logs] scummvm master -> 0e641ed19118fa28dc5276a067cba75bff32877a
AndywinXp
noreply at scummvm.org
Sun Sep 24 19:19:00 UTC 2023
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0d0a8ad11e SWORD1: Add more toggleable debug information
0e641ed191 SWORD1: Fix mouse scrolling not stopping in save menu
Commit: 0d0a8ad11e11c34d9006860fa4ab4a21db9902fb
https://github.com/scummvm/scummvm/commit/0d0a8ad11e11c34d9006860fa4ab4a21db9902fb
Author: AndywinXp (andywinxp at gmail.com)
Date: 2023-09-24T21:18:36+02:00
Commit Message:
SWORD1: Add more toggleable debug information
Pressing SHIFT-M shows a debug mouse cursor, and
pressing CTRL-G shows the walk grid.
Also, moved the showDebugInfo() function to sword1.cpp
because it seemed more appropriate.
Changed paths:
engines/sword1/logic.cpp
engines/sword1/logic.h
engines/sword1/screen.cpp
engines/sword1/screen.h
engines/sword1/sword1.cpp
engines/sword1/sword1.h
engines/sword1/text.cpp
engines/sword1/text.h
diff --git a/engines/sword1/logic.cpp b/engines/sword1/logic.cpp
index bdc0395d432..ffa8d58592f 100644
--- a/engines/sword1/logic.cpp
+++ b/engines/sword1/logic.cpp
@@ -1848,6 +1848,58 @@ bool Logic::canShowDebugTextNumber() {
return _speechRunning || _textRunning;
}
+void Logic::plotRouteGrid(Object *megaObject) {
+ WalkGridHeader floorHeader;
+
+ // Load the floor grid for the input megaObject
+ Object *floorObject = _objMan->fetchObject(megaObject->o_place);
+
+ uint8 *fPolygrid = (uint8 *)_resMan->openFetchRes(floorObject->o_resource);
+
+ fPolygrid += sizeof(Header);
+ memmove(&floorHeader, fPolygrid, sizeof(WalkGridHeader));
+ fPolygrid += sizeof(WalkGridHeader);
+
+ _router->_nBars = floorHeader.numBars;
+ if (_router->_nBars >= O_GRID_SIZE) {
+ debug(3, "Logic::plotRouteGrid(): RouteFinder: too many bars %d", _router->_nBars);
+ _resMan->resClose(floorObject->o_resource);
+ return;
+ }
+
+ _router->_nNodes = floorHeader.numNodes + 1;
+ if (_router->_nNodes >= O_GRID_SIZE) {
+ debug(3, "Logic::plotRouteGrid(): RouteFinder: too many nodes %d", _router->_nNodes);
+ _resMan->resClose(floorObject->o_resource);
+ return;
+ }
+
+ memmove(&_router->_bars[0], fPolygrid, _router->_nBars * sizeof(BarData));
+ fPolygrid += _router->_nBars * sizeof(BarData);
+
+ // Parse the grid...
+ for (int j = 1; j < _router->_nNodes; j++) {
+ memmove(&_router->_node[j].x, fPolygrid, 2 * sizeof(int16));
+ fPolygrid += 2 * sizeof(int16);
+ }
+
+ // Draw the grid (color 254)...
+ for (int j = 0; j < _router->_nBars; j++) {
+ _screen->plotLine(_router->_bars[j].x1 - 128, _router->_bars[j].y1 - 128, _router->_bars[j].x2 - 128, _router->_bars[j].y2 - 128, 254);
+ }
+
+ // Draw the nodes (color 255)...
+ for (int j = 1; j < _router->_nNodes; j++) {
+ _screen->plotPoint(_router->_node[j].x - 128, _router->_node[j].y - 128, 255);
+ }
+
+ // At this point the original code plotted more lines related to the collision engine,
+ // which was coded but never used in the game, so we skip right through the end of the
+ // function and deallocate the previously opened resource.
+
+ _resMan->resClose(floorObject->o_resource);
+}
+
const uint32 Logic::_scriptVarInit[NON_ZERO_SCRIPT_VARS][2] = {
{ 42, 448}, { 43, 378}, { 51, 1}, { 92, 1}, { 147, 71}, { 201, 1},
{ 209, 1}, { 215, 1}, { 242, 2}, { 244, 1}, { 246, 3}, { 247, 1},
diff --git a/engines/sword1/logic.h b/engines/sword1/logic.h
index 69f54b2caf3..523fc13c7a3 100644
--- a/engines/sword1/logic.h
+++ b/engines/sword1/logic.h
@@ -64,6 +64,7 @@ public:
void runMouseScript(Object *cpt, int32 scriptId);
void startPositions(uint32 pos);
bool canShowDebugTextNumber();
+ void plotRouteGrid(Object *megaObject);
static uint32 _scriptVars[NUM_SCRIPT_VARS];
// public for mouse (menu looking)
diff --git a/engines/sword1/screen.cpp b/engines/sword1/screen.cpp
index 8c1ec72e19c..51ac9adb729 100644
--- a/engines/sword1/screen.cpp
+++ b/engines/sword1/screen.cpp
@@ -99,6 +99,10 @@ void Screen::useTextManager(Text *pTextMan) {
_textMan = pTextMan;
}
+void Screen::printDebugLine(uint8 *ascii, uint8 first, int x, int y) {
+ _textMan->printDebugLine(ascii, first, x, y);
+}
+
void Screen::setScrolling(int16 offsetX, int16 offsetY) {
offsetX = CLIP<int32>(offsetX, 0, Logic::_scriptVars[MAX_SCROLL_OFFSET_X]);
offsetY = CLIP<int32>(offsetY, 0, Logic::_scriptVars[MAX_SCROLL_OFFSET_Y]);
@@ -579,8 +583,6 @@ void Screen::draw() {
processImage(_foreList[cnt]);
_backLength = _sortLength = _foreLength = 0;
-
- _textMan->showDebugInfo();
}
void Screen::initFadePaletteServer() {
@@ -1438,139 +1440,127 @@ void Screen::showFrame(uint16 x, uint16 y, uint32 resId, uint32 frameNo, const b
_system->copyRectToScreen(frame, 40, x, y, 40, 40);
}
-// ------------------- router debugging code --------------------------------
+// ------------------- Router debugging code --------------------------------
-void Screen::vline(uint16 x, uint16 y1, uint16 y2) {
- for (uint16 cnty = y1; cnty <= y2; cnty++)
- _screenBuf[x + _scrnSizeX * cnty] = 0;
-}
+void Screen::bresenhamLine(int32 x1, int32 y1, int32 x2, int32 y2, uint8 color) {
+ int32 tmpX, tmpY;
+ uint8 *dstPt1, *dstPt2;
+ int32 dx, dy;
+ int32 screenWidth = _scrnSizeX;
+ int32 screenHeight = _scrnSizeY;
-void Screen::hline(uint16 x1, uint16 x2, uint16 y) {
- for (uint16 cntx = x1; cntx <= x2; cntx++)
- _screenBuf[y * _scrnSizeX + cntx] = 0;
-}
+ if (x1 != x2 || y1 != y2) {
+ if (x1 >= x2) {
+ tmpX = x1; x1 = x2; x2 = tmpX;
+ tmpY = y1; y1 = y2; y2 = tmpY;
+ }
-void Screen::bsubline_1(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
- int x, y, ddx, ddy, e;
- ddx = ABS(x2 - x1);
- ddy = ABS(y2 - y1) << 1;
- e = ddx - ddy;
- ddx <<= 1;
-
- if (x1 > x2) {
- uint16 tmp;
- tmp = x1; x1 = x2; x2 = tmp;
- tmp = y1; y1 = y2; y2 = tmp;
- }
+ if (x1 >= 0 && x2 < screenWidth) {
+ dstPt1 = &_screenBuf[x1 + screenWidth * y1];
+ dstPt2 = &_screenBuf[x2 + screenWidth * y2];
- for (x = x1, y = y1; x <= x2; x++) {
- _screenBuf[y * _scrnSizeX + x] = 0;
- if (e < 0) {
- y++;
- e += ddx - ddy;
- } else {
- e -= ddy;
- }
- }
-}
+ if (y2 < y1) {
+ screenWidth = -screenWidth;
+ tmpY = y1; y1 = y2; y2 = tmpY;
+ }
-void Screen::bsubline_2(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
- int x, y, ddx, ddy, e;
- ddx = ABS(x2 - x1) << 1;
- ddy = ABS(y2 - y1);
- e = ddy - ddx;
- ddy <<= 1;
-
- if (y1 > y2) {
- uint16 tmp;
- tmp = x1; x1 = x2; x2 = tmp;
- tmp = y1; y1 = y2; y2 = tmp;
- }
+ if (y1 >= 0 && y2 < screenHeight) {
+ dx = 2 * (x2 - x1);
+ dy = 2 * (y2 - y1);
+ if (dx < dy) {
+ for (int i = dx - (dy >> 1); true; i += dx) {
+ *dstPt1 = color;
- for (y = y1, x = x1; y <= y2; y++) {
- _screenBuf[y * _scrnSizeX + x] = 0;
- if (e < 0) {
- x++;
- e += ddy - ddx;
- } else {
- e -= ddx;
- }
- }
-}
+ if (dstPt1 == dstPt2)
+ break;
-void Screen::bsubline_3(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
- int x, y, ddx, ddy, e;
- ddx = ABS(x1 - x2) << 1;
- ddy = ABS(y2 - y1);
- e = ddy - ddx;
- ddy <<= 1;
-
- if (y1 > y2) {
- uint16 tmp;
- tmp = x1; x1 = x2; x2 = tmp;
- tmp = y1; y1 = y2; y2 = tmp;
- }
+ if (i >= 0) {
+ ++dstPt1;
+ i -= dy;
+ }
- for (y = y1, x = x1; y <= y2; y++) {
- _screenBuf[y * _scrnSizeX + x] = 0;
- if (e < 0) {
- x--;
- e += ddy - ddx;
- } else {
- e -= ddx;
+ dstPt1 += screenWidth;
+ }
+ } else {
+ for (int j = dy - (dx >> 1); true; j += dy) {
+ *dstPt1 = color;
+
+ if (dstPt1 == dstPt2)
+ break;
+
+ if (j >= 0) {
+ dstPt1 += screenWidth;
+ j -= dx;
+ }
+
+ ++dstPt1;
+ }
+ }
+ }
}
}
}
-void Screen::bsubline_4(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
- int x, y, ddx, ddy, e;
- ddy = ABS(y2 - y1) << 1;
- ddx = ABS(x1 - x2);
- e = ddx - ddy;
- ddx <<= 1;
-
- if (x1 > x2) {
- uint16 tmp;
- tmp = x1; x1 = x2; x2 = tmp;
- tmp = y1; y1 = y2; y2 = tmp;
- }
+void Screen::plotPoint(int32 x, int32 y, uint8 color) {
+ if (x >= 0 && x <= _scrnSizeX && y >= 0 && y <= _scrnSizeY)
+ _screenBuf[_scrnSizeX * y + x] = color;
+}
- for (x = x1, y = y1; x <= x2; x++) {
- _screenBuf[y * _scrnSizeX + x] = 0;
- if (e < 0) {
- y--;
- e += ddx - ddy;
- } else {
- e -= ddy;
- }
+void Screen::plotLine(int32 x1, int32 y1, int32 x2, int32 y2, uint8 color) {
+#define SWAP(a, b) \
+ temp = a; \
+ a = b; \
+ b = temp;
+#define DX (x2 - x1)
+#define DY (y2 - y1)
+
+ int32 temp;
+ int32 screenWidth = _scrnSizeX;
+ int32 screenHeight = _scrnSizeY;
+
+ //sort line to go down
+ if (y2 < y1) { // its was going up so swap ends
+ SWAP(x1, x2);
+ SWAP(y1, y2);
}
-}
-void Screen::drawLine(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
- if ((x1 == x2) && (y1 == y2)) {
- _screenBuf[x1 + y1 * _scrnSizeX] = 0;
+ if ((y2 < 0) || (y1 >= screenHeight))
+ return; // all of line off screen
+
+ if (y1 < 0) { // clip to top
+ temp = (-y1) * DX / DY;
+ x1 = x1 + temp;
+ y1 = 0;
}
- if (x1 == x2) {
- vline(x1, MIN(y1, y2), MAX(y1, y2));
- return;
+
+ if (y2 >= screenHeight) { // clip to bottom
+ temp = (y2 - screenHeight - 1) * DX / DY;
+ x2 = x2 - temp;
+ y2 = screenHeight - 1;
}
- if (y1 == y2) {
- hline(MIN(x1, x2), MAX(x1, x2), y1);
- return;
+ //sort line to go left right
+ if (x2 < x1) { //it was going left so swap ends
+ SWAP(x1, x2);
+ SWAP(y1, y2);
}
- float k = float(y2 - y1) / float(x2 - x1);
+ if ((x2 < 0) || (x1 >= screenWidth))
+ return; //all of line off screen
- if ((k >= 0) && (k <= 1)) {
- bsubline_1(x1, y1, x2, y2);
- } else if (k > 1) {
- bsubline_2(x1, y1, x2, y2);
- } else if ((k < 0) && (k >= -1)) {
- bsubline_4(x1, y1, x2, y2);
- } else {
- bsubline_3(x1, y1, x2, y2);
+ if (x1 < 0) { //clip to left
+ temp = (-x1) * DY / DX;
+ y1 = y1 + temp;
+ x1 = 0;
}
+
+ if (x2 >= screenWidth) { //clip to right
+ temp = (x2 - screenWidth - 1) * DY / DX;
+ y2 = y2 - temp;
+ x2 = screenWidth - 1;
+ }
+
+ bresenhamLine(x1, y1, x2, y2, color);
}
} // End of namespace Sword1
diff --git a/engines/sword1/screen.h b/engines/sword1/screen.h
index e9d5c9e1746..6701bf28f7a 100644
--- a/engines/sword1/screen.h
+++ b/engines/sword1/screen.h
@@ -104,6 +104,13 @@ public:
static void decompressHIF(uint8 *src, uint8 *dest);
+ void printDebugLine(uint8 *ascii, uint8 first, int x, int y);
+
+ // Functions used by the router debug visualization routines
+ void plotLine(int32 x1, int32 y1, int32 x2, int32 y2, uint8 color);
+ void plotPoint(int32 x, int32 y, uint8 color);
+ void bresenhamLine(int32 x1, int32 y1, int32 x2, int32 y2, uint8 color);
+
private:
// The original values are 6-bit RGB numbers, so they have to be shifted,
// except for white, which for some reason has to stay unshifted in order
@@ -128,15 +135,6 @@ private:
PaletteFadeInfo _paletteFadeInfo;
- // for router debugging
- void drawLine(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
- void vline(uint16 x, uint16 y1, uint16 y2);
- void hline(uint16 x1, uint16 x2, uint16 y);
- void bsubline_1(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
- void bsubline_2(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
- void bsubline_3(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
- void bsubline_4(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-
void verticalMask(uint16 x, uint16 y, uint16 bWidth, uint16 bHeight);
void blitBlockClear(uint16 x, uint16 y, uint8 *data);
void renderParallax(uint8 *data);
diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp
index 66def168fa7..688b3dee5db 100644
--- a/engines/sword1/sword1.cpp
+++ b/engines/sword1/sword1.cpp
@@ -158,6 +158,8 @@ Common::Error SwordEngine::init() {
_systemVars.gamePaused = false;
_systemVars.displayDebugText = false;
+ _systemVars.displayDebugMouse = false;
+ _systemVars.displayDebugGrid = false;
_systemVars.framesPerSecondCounter = 0;
_systemVars.gameCycle = 0;
@@ -310,6 +312,16 @@ void SwordEngine::checkKeys() {
if (_keyPressed.hasFlags(Common::KBD_CTRL))
_systemVars.displayDebugText = !_systemVars.displayDebugText;
break;
+ case Common::KEYCODE_m: // SHIFT-M: Toggles debug mouse tracking
+ // This was originally CTRL-M, but ScummVM steals that event to
+ // lock the mouse cursor within the window boundaries.
+ if (_keyPressed.hasFlags(Common::KBD_SHIFT))
+ _systemVars.displayDebugMouse = !_systemVars.displayDebugMouse;
+ break;
+ case Common::KEYCODE_g: // CTRL-G: Toggles walkgrid displaying
+ if (_keyPressed.hasFlags(Common::KBD_CTRL))
+ _systemVars.displayDebugGrid = !_systemVars.displayDebugGrid;
+ break;
case Common::KEYCODE_1: // Slow mode
{
if (_systemVars.slowMode) {
@@ -346,10 +358,6 @@ void SwordEngine::checkKeys() {
}
}
-const uint8 *SwordEngine::getPauseString() {
- return _control->getPauseString();
-}
-
static const char *const errorMsgs[] = {
"The file \"%s\" is missing and the game doesn't work without it.\n"
"Please copy it from CD %d and try starting the game again.\n"
@@ -738,6 +746,173 @@ Common::Error SwordEngine::go() {
return Common::kNoError;
}
+void SwordEngine::showDebugInfo() {
+ Object *playerCompact = _objectMan->fetchObject(PLAYER);
+
+ // Screen coordinates for game cycle string
+ int32 gameCycleX = Logic::_scriptVars[SCROLL_OFFSET_X] + 130;
+ int32 gameCycleY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 125;
+
+ // Screen coordinates for mouse coordinates string
+ int32 mouseCoordsX = Logic::_scriptVars[SCROLL_OFFSET_X] + 220;
+ int32 mouseCoordsY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 125;
+
+ // Screen coordinates for special item string
+ int32 specialItemX = Logic::_scriptVars[SCROLL_OFFSET_X] + 350;
+ int32 specialItemY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 125;
+
+ // Screen coordinates for player coordinates string
+ int32 playerCoordsX = Logic::_scriptVars[SCROLL_OFFSET_X] + 475;
+ int32 playerCoordsY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 125;
+
+ // Screen coordinates for Paris flag string
+ int32 parisFlagX = Logic::_scriptVars[SCROLL_OFFSET_X] + 590;
+ int32 parisFlagY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 125;
+
+ // Screen coordinates for player's script level string
+ int32 scriptLevelX = Logic::_scriptVars[SCROLL_OFFSET_X] + 660;
+ int32 scriptLevelY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 125;
+
+ // Screen coordinates for the talk flag string
+ int32 talkFlagX = Logic::_scriptVars[SCROLL_OFFSET_X] + 720;
+ int32 talkFlagY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 125;
+
+ // Screen coordinates for FPS counter string
+ int32 fpsX = Logic::_scriptVars[SCROLL_OFFSET_X] + 130;
+ int32 fpsY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 145;
+
+ // Screen coordinates for game speed string
+ int32 gameSpeedX = Logic::_scriptVars[SCROLL_OFFSET_X] + 220;
+ int32 gameSpeedY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 145;
+
+ // Screen coordinates for screen number string
+ int32 screenX = Logic::_scriptVars[SCROLL_OFFSET_X] + 350;
+ int32 screenY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 145;
+
+ // Screen coordinates for current CD string
+ int32 currentCDX = Logic::_scriptVars[SCROLL_OFFSET_X] + 475;
+ int32 currentCDY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 145;
+
+ // Screen coordinates for the end sequence phase string
+ int32 endSceneX = Logic::_scriptVars[SCROLL_OFFSET_X] + 590;
+ int32 endSceneY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 145;
+
+ // Screen coordinates for the current text line number string
+ int32 textNoX = Logic::_scriptVars[SCROLL_OFFSET_X] + 130;
+ int32 textNoY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 165;
+
+ // Screen coordinates for debug flags string
+ int32 debugFlagsX = Logic::_scriptVars[SCROLL_OFFSET_X] + 130;
+ int32 debugFlagsY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 185;
+
+ // Screen coordinates for the paused message string
+ int32 pausedX = Logic::_scriptVars[SCROLL_OFFSET_X] + 400;
+ int32 pausedY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 315;
+
+ uint8 buf[255];
+
+ if (_systemVars.gamePaused) {
+ Common::sprintf_s(buf, "%s", _control->getPauseString());
+ _screen->printDebugLine(buf, ' ', pausedX, pausedY);
+ }
+
+ if ((_systemVars.displayDebugText) && (!_systemVars.isDemo)) {
+ // Game cycle
+ Common::sprintf_s(buf, "%d", _systemVars.gameCycle);
+ _screen->printDebugLine(buf, ' ', gameCycleX, gameCycleY);
+
+ // Mouse coordinates
+ Common::sprintf_s(buf, "m %d,%d", Logic::_scriptVars[MOUSE_X], Logic::_scriptVars[MOUSE_Y]);
+ _screen->printDebugLine(buf, ' ', mouseCoordsX, mouseCoordsY);
+
+ // Special item
+ Common::sprintf_s(buf, "id %d", Logic::_scriptVars[SPECIAL_ITEM]);
+ _screen->printDebugLine(buf, ' ', specialItemX, specialItemY);
+
+ // Player coordinates
+ Common::sprintf_s(buf, "G %d,%d", playerCompact->o_xcoord, playerCompact->o_ycoord);
+ _screen->printDebugLine(buf, ' ', playerCoordsX, playerCoordsY);
+
+ // Paris status flag
+ Common::sprintf_s(buf, "pf %d", Logic::_scriptVars[PARIS_FLAG]);
+ _screen->printDebugLine(buf, ' ', parisFlagX, parisFlagY);
+
+ // Player script level
+ Common::sprintf_s(buf, "lv %d", playerCompact->o_tree.o_script_level);
+ _screen->printDebugLine(buf, ' ', scriptLevelX, scriptLevelY);
+
+ // Talk flag
+ Common::sprintf_s(buf, "tf %d", Logic::_scriptVars[TALK_FLAG]);
+ _screen->printDebugLine(buf, ' ', talkFlagX, talkFlagY);
+
+ // Frames per second
+ Common::sprintf_s(buf, "%u fps", _systemVars.framesPerSecondCounter);
+ _screen->printDebugLine(buf, ' ', fpsX, fpsY);
+
+ // Debug game speed (based on pressing keys '1' & '4')
+ if (_systemVars.slowMode) {
+ Common::sprintf_s(buf, "(slow)");
+ } else if (_systemVars.fastMode) {
+ Common::sprintf_s(buf, "(fast)");
+ } else {
+ Common::sprintf_s(buf, "(norm)");
+ }
+
+ _screen->printDebugLine(buf, ' ', gameSpeedX, gameSpeedY);
+
+ // Screen number
+ Common::sprintf_s(buf, "screen %d", Logic::_scriptVars[SCREEN]);
+ _screen->printDebugLine(buf, ' ', screenX, screenY);
+
+ // CD in use
+ Common::sprintf_s(buf, "CD-%d", _systemVars.currentCD);
+ _screen->printDebugLine(buf, ' ', currentCDX, currentCDY);
+
+ // End sequence scene number
+ if (Logic::_scriptVars[END_SCENE]) {
+ Common::sprintf_s(buf, "scene %d", Logic::_scriptVars[END_SCENE]);
+ _screen->printDebugLine(buf, ' ', endSceneX, endSceneY);
+ }
+
+ // Debug flags
+ if ((Logic::_scriptVars[DEBUG_FLAG_1] > 0) || (Logic::_scriptVars[DEBUG_FLAG_2] > 0) || (Logic::_scriptVars[DEBUG_FLAG_3] > 0)) {
+ Common::sprintf_s(buf, "debug flags: %d, %d, %d",
+ Logic::_scriptVars[DEBUG_FLAG_1],
+ Logic::_scriptVars[DEBUG_FLAG_2],
+ Logic::_scriptVars[DEBUG_FLAG_3]);
+ _screen->printDebugLine(buf, ' ', debugFlagsX, debugFlagsY);
+ }
+ }
+
+ if (_systemVars.displayDebugText) {
+ // Text line number
+ if (_logic->canShowDebugTextNumber()) {
+ Common::sprintf_s(buf, "TEXT %d", _systemVars.textNumber);
+ _screen->printDebugLine(buf, ' ', textNoX, textNoY);
+ }
+ }
+
+ if (_systemVars.displayDebugGrid) {
+ _logic->plotRouteGrid(playerCompact);
+ }
+
+ if (_systemVars.displayDebugMouse) {
+ // Draw a cross shaped cursor under the mouse cursor
+ _screen->plotPoint(Logic::_scriptVars[MOUSE_X] - 128, Logic::_scriptVars[MOUSE_Y] - 128, 255);
+ _screen->plotPoint(Logic::_scriptVars[MOUSE_X] - 130, Logic::_scriptVars[MOUSE_Y] - 128, 255);
+ _screen->plotPoint(Logic::_scriptVars[MOUSE_X] - 128, Logic::_scriptVars[MOUSE_Y] - 130, 255);
+ _screen->plotPoint(Logic::_scriptVars[MOUSE_X] - 128, Logic::_scriptVars[MOUSE_Y] - 126, 255);
+ _screen->plotPoint(Logic::_scriptVars[MOUSE_X] - 126, Logic::_scriptVars[MOUSE_Y] - 128, 255);
+
+ // Draw a cross shaped cursor on the player coordinates
+ _screen->plotPoint(playerCompact->o_xcoord - 128, playerCompact->o_ycoord - 128, 255);
+ _screen->plotPoint(playerCompact->o_xcoord - 130, playerCompact->o_ycoord - 128, 255);
+ _screen->plotPoint(playerCompact->o_xcoord - 128, playerCompact->o_ycoord - 130, 255);
+ _screen->plotPoint(playerCompact->o_xcoord - 128, playerCompact->o_ycoord - 126, 255);
+ _screen->plotPoint(playerCompact->o_xcoord - 126, playerCompact->o_ycoord - 128, 255);
+ }
+}
+
void SwordEngine::checkCd() {
uint8 needCd = _cdList[Logic::_scriptVars[NEW_SCREEN]];
if (_systemVars.runningFromCd) { // are we running from cd?
@@ -855,6 +1030,9 @@ uint8 SwordEngine::mainLoop() {
_logic->updateScreenParams(); // sets scrolling
_screen->draw();
+
+ showDebugInfo();
+
_mouse->animate();
if (!Logic::_scriptVars[NEW_PALETTE]) {
diff --git a/engines/sword1/sword1.h b/engines/sword1/sword1.h
index a05238788b8..8b1b448e2e6 100644
--- a/engines/sword1/sword1.h
+++ b/engines/sword1/sword1.h
@@ -83,6 +83,8 @@ struct SystemVars {
bool parallaxOn;
bool gamePaused;
bool displayDebugText;
+ bool displayDebugMouse;
+ bool displayDebugGrid;
uint32 framesPerSecondCounter;
uint32 gameCycle;
};
@@ -122,7 +124,7 @@ public:
void startFadePaletteUp(int speed);
void waitForFade();
- const uint8 *getPauseString();
+ void showDebugInfo();
protected:
// Engine APIs
diff --git a/engines/sword1/text.cpp b/engines/sword1/text.cpp
index 7bea6e4bce2..89b01d6336b 100644
--- a/engines/sword1/text.cpp
+++ b/engines/sword1/text.cpp
@@ -227,7 +227,7 @@ void Text::releaseText(uint32 id, bool updateCount) {
}
}
-void Text::printDebugLine(uint8 *ascii, uint8 *resourceAddress, uint8 first, int x, int y) {
+void Text::printDebugLine(uint8 *ascii, uint8 first, int x, int y) {
FrameHeader *head;
int chr;
@@ -235,7 +235,7 @@ void Text::printDebugLine(uint8 *ascii, uint8 *resourceAddress, uint8 first, int
chr = (int)*(ascii);
chr -= first;
- head = (FrameHeader *)_resMan->fetchFrame(resourceAddress, chr);
+ head = (FrameHeader *)_resMan->fetchFrame(_font, chr);
uint8 *sprData = (uint8 *)head + sizeof(FrameHeader);
@@ -260,152 +260,4 @@ void Text::printDebugLine(uint8 *ascii, uint8 *resourceAddress, uint8 first, int
} while (*ascii);
}
-void Text::showDebugInfo() {
-
- Object *playerCompact = _objMan->fetchObject(PLAYER);
-
- // Screen coordinates for game cycle string
- int32 gameCycleX = Logic::_scriptVars[SCROLL_OFFSET_X] + 130;
- int32 gameCycleY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 125;
-
- // Screen coordinates for mouse coordinates string
- int32 mouseCoordsX = Logic::_scriptVars[SCROLL_OFFSET_X] + 220;
- int32 mouseCoordsY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 125;
-
- // Screen coordinates for special item string
- int32 specialItemX = Logic::_scriptVars[SCROLL_OFFSET_X] + 350;
- int32 specialItemY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 125;
-
- // Screen coordinates for player coordinates string
- int32 playerCoordsX = Logic::_scriptVars[SCROLL_OFFSET_X] + 475;
- int32 playerCoordsY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 125;
-
- // Screen coordinates for Paris flag string
- int32 parisFlagX = Logic::_scriptVars[SCROLL_OFFSET_X] + 590;
- int32 parisFlagY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 125;
-
- // Screen coordinates for player's script level string
- int32 scriptLevelX = Logic::_scriptVars[SCROLL_OFFSET_X] + 660;
- int32 scriptLevelY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 125;
-
- // Screen coordinates for the talk flag string
- int32 talkFlagX = Logic::_scriptVars[SCROLL_OFFSET_X] + 720;
- int32 talkFlagY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 125;
-
- // Screen coordinates for FPS counter string
- int32 fpsX = Logic::_scriptVars[SCROLL_OFFSET_X] + 130;
- int32 fpsY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 145;
-
- // Screen coordinates for game speed string
- int32 gameSpeedX = Logic::_scriptVars[SCROLL_OFFSET_X] + 220;
- int32 gameSpeedY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 145;
-
- // Screen coordinates for screen number string
- int32 screenX = Logic::_scriptVars[SCROLL_OFFSET_X] + 350;
- int32 screenY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 145;
-
- // Screen coordinates for current CD string
- int32 currentCDX = Logic::_scriptVars[SCROLL_OFFSET_X] + 475;
- int32 currentCDY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 145;
-
- // Screen coordinates for the end sequence phase string
- int32 endSceneX = Logic::_scriptVars[SCROLL_OFFSET_X] + 590;
- int32 endSceneY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 145;
-
- // Screen coordinates for the current text line number string
- int32 textNoX = Logic::_scriptVars[SCROLL_OFFSET_X] + 130;
- int32 textNoY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 165;
-
- // Screen coordinates for debug flags string
- int32 debugFlagsX = Logic::_scriptVars[SCROLL_OFFSET_X] + 130;
- int32 debugFlagsY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 185;
-
- // Screen coordinates for the paused message string
- int32 pausedX = Logic::_scriptVars[SCROLL_OFFSET_X] + 400;
- int32 pausedY = Logic::_scriptVars[SCROLL_OFFSET_Y] + 315;
-
- uint8 buf[255];
-
- if (SwordEngine::_systemVars.gamePaused) {
- Common::sprintf_s(buf, "%s", _vm->getPauseString());
- printDebugLine(buf, _font, ' ', pausedX, pausedY);
- }
-
- if ((SwordEngine::_systemVars.displayDebugText) && (!SwordEngine::_systemVars.isDemo)) {
- // Game cycle
- Common::sprintf_s(buf, "%d", SwordEngine::_systemVars.gameCycle);
- printDebugLine(buf, _font, ' ', gameCycleX, gameCycleY);
-
- // Mouse coordinates
- Common::sprintf_s(buf, "m %d,%d", Logic::_scriptVars[MOUSE_X], Logic::_scriptVars[MOUSE_Y]);
- printDebugLine(buf, _font, ' ', mouseCoordsX, mouseCoordsY);
-
- // Special item
- Common::sprintf_s(buf, "id %d", Logic::_scriptVars[SPECIAL_ITEM]);
- printDebugLine(buf, _font, ' ', specialItemX, specialItemY);
-
- // Player coordinates
- Common::sprintf_s(buf, "G %d,%d", playerCompact->o_xcoord, playerCompact->o_ycoord);
- printDebugLine(buf, _font, ' ', playerCoordsX, playerCoordsY);
-
- // Paris flag
- Common::sprintf_s(buf, "pf %d", Logic::_scriptVars[PARIS_FLAG]);
- printDebugLine(buf, _font, ' ', parisFlagX, parisFlagY);
-
- // Player script level
- Common::sprintf_s(buf, "lv %d", playerCompact->o_tree.o_script_level);
- printDebugLine(buf, _font, ' ', scriptLevelX, scriptLevelY);
-
- // Talk flag
- Common::sprintf_s(buf, "tf %d", Logic::_scriptVars[TALK_FLAG]);
- printDebugLine(buf, _font, ' ', talkFlagX, talkFlagY);
-
- // Frames per second
- Common::sprintf_s(buf, "%u fps", SwordEngine::_systemVars.framesPerSecondCounter);
- printDebugLine(buf, _font, ' ', fpsX, fpsY);
-
- // Debug game speed (based on pressing keys '1' & '4')
- if (SwordEngine::_systemVars.slowMode) {
- Common::sprintf_s(buf, "(slow)");
- } else if (SwordEngine::_systemVars.fastMode) {
- Common::sprintf_s(buf, "(fast)");
- } else {
- Common::sprintf_s(buf, "(norm)");
- }
-
- printDebugLine(buf, _font, ' ', gameSpeedX, gameSpeedY);
-
- // Screen number
- Common::sprintf_s(buf, "screen %d", Logic::_scriptVars[SCREEN]);
- printDebugLine(buf, _font, ' ', screenX, screenY);
-
- // CD in use
- Common::sprintf_s(buf, "CD-%d", SwordEngine::_systemVars.currentCD);
- printDebugLine(buf, _font, ' ', currentCDX, currentCDY);
-
- // End sequence scene number
- if (Logic::_scriptVars[END_SCENE]) {
- Common::sprintf_s(buf, "scene %d", Logic::_scriptVars[END_SCENE]);
- printDebugLine(buf, _font, ' ', endSceneX, endSceneY);
- }
-
- // Debug flags
- if ((Logic::_scriptVars[DEBUG_FLAG_1] > 0) || (Logic::_scriptVars[DEBUG_FLAG_2] > 0) || (Logic::_scriptVars[DEBUG_FLAG_3] > 0)) {
- Common::sprintf_s(buf, "debug flags: %d, %d, %d",
- Logic::_scriptVars[DEBUG_FLAG_1],
- Logic::_scriptVars[DEBUG_FLAG_2],
- Logic::_scriptVars[DEBUG_FLAG_3]);
- printDebugLine(buf, _font, ' ', debugFlagsX, debugFlagsY);
- }
- }
-
- if (SwordEngine::_systemVars.displayDebugText) {
- // Text line number
- if (_logic->canShowDebugTextNumber()) {
- Common::sprintf_s(buf, "TEXT %d", SwordEngine::_systemVars.textNumber);
- printDebugLine(buf, _font, ' ', textNoX, textNoY);
- }
- }
-}
-
} // End of namespace Sword1
diff --git a/engines/sword1/text.h b/engines/sword1/text.h
index 96a4aaa3f48..1cee43bba7b 100644
--- a/engines/sword1/text.h
+++ b/engines/sword1/text.h
@@ -53,13 +53,12 @@ public:
uint32 lowTextManager(uint8 *text, int32 width, uint8 pen);
void makeTextSprite(uint8 slot, const uint8 *text, uint16 maxWidth, uint8 pen);
void releaseText(uint32 id, bool updateCount = true);
- void showDebugInfo();
+ void printDebugLine(uint8 *ascii, uint8 first, int x, int y);
private:
uint16 analyzeSentence(const uint8 *text, uint16 maxWidth, LineInfo *info);
uint16 charWidth(uint8 ch);
uint16 copyChar(uint8 ch, uint8 *sprPtr, uint16 sprWidth, uint8 pen);
- void printDebugLine(uint8 *ascii, uint8 *resourceAddress, uint8 first, int x, int y);
uint8 *_font;
uint8 _textCount;
Commit: 0e641ed19118fa28dc5276a067cba75bff32877a
https://github.com/scummvm/scummvm/commit/0e641ed19118fa28dc5276a067cba75bff32877a
Author: AndywinXp (andywinxp at gmail.com)
Date: 2023-09-24T21:18:55+02:00
Commit Message:
SWORD1: Fix mouse scrolling not stopping in save menu
Changed paths:
engines/sword1/control.cpp
diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp
index 40220ae508e..07b7f09e821 100644
--- a/engines/sword1/control.cpp
+++ b/engines/sword1/control.cpp
@@ -1950,6 +1950,9 @@ void Control::implementSave() {
}
}
+ if (useWheelScroll)
+ _scroll = 0;
+
if ((_mouseState & BS1L_BUTTON_UP) && (_buttonPressed)) {
if (_buttonPressed > SAVEBUTTONS - 6) {
switch (_buttonPressed) {
@@ -2355,6 +2358,9 @@ void Control::implementRestore() {
}
}
+ if (useWheelScroll)
+ _scroll = 0;
+
if ((_mouseState & BS1L_BUTTON_UP) && (_buttonPressed)) {
if (_buttonPressed > SAVEBUTTONS - 6) {
switch (_buttonPressed) {
More information about the Scummvm-git-logs
mailing list