diff options
Diffstat (limited to 'sword2/debug.cpp')
-rw-r--r-- | sword2/debug.cpp | 217 |
1 files changed, 87 insertions, 130 deletions
diff --git a/sword2/debug.cpp b/sword2/debug.cpp index f1d6ef60db..098072c06c 100644 --- a/sword2/debug.cpp +++ b/sword2/debug.cpp @@ -36,75 +36,32 @@ namespace Sword2 { -bool displayDebugText = false; // "INFO" -bool displayWalkGrid = false; // "WALKGRID" -bool displayMouseMarker = false; // "MOUSE" -bool displayTime = false; // "TIME" -bool displayPlayerMarker = false; // "PLAYER" -bool displayTextNumbers = false; // "TEXT" -uint8 renderSkip = 0; // Toggled on 'S' key - to render only - // 1 in 4 frames, to speed up game - -bool definingRectangles = false; // "RECT" -uint8 draggingRectangle = 0; // 0 = waiting to start new rect; - // 1 = currently dragging a rectangle -int16 rect_x1 = 0; -int16 rect_y1 = 0; -int16 rect_x2 = 0; -int16 rect_y2 = 0; -bool rectFlicker = false; - -bool testingSnR = false; // "SAVEREST" - for system to kill all - // object resources (except player) in - // fnAddHuman() - -int32 startTime = 0; // "TIMEON" & "TIMEOFF" - system start - // time. -int32 gameCycle = 0; // Counter for game clocks. - -int32 textNumber = 0; // Current system text line number - -int32 showVar[MAX_SHOWVARS]; // "SHOWVAR" - -Object_graphic playerGraphic; // For displaying player object's - // current graphical info -uint32 player_graphic_no_frames = 0; // No. of frames in currently displayed - // anim - -uint8 debug_text_blocks[MAX_DEBUG_TEXT_BLOCKS]; - -void Clear_debug_text_blocks(void); -void Make_debug_text_block(char *text, int16 x, int16 y); -void Plot_cross_hair(int16 x, int16 y, uint8 pen); -void DrawRect(int16 x, int16 y, int16 x2, int16 y2, uint8 pen); - -void Clear_debug_text_blocks(void) { +void Debugger::clearDebugTextBlocks(void) { uint8 blockNo = 0; - while (blockNo < MAX_DEBUG_TEXT_BLOCKS && debug_text_blocks[blockNo] > 0) { + while (blockNo < MAX_DEBUG_TEXT_BLOCKS && _debugTextBlocks[blockNo] > 0) { // kill the system text block - fontRenderer.killTextBloc(debug_text_blocks[blockNo]); + fontRenderer.killTextBloc(_debugTextBlocks[blockNo]); // clear this element of our array of block numbers - debug_text_blocks[blockNo] = 0; + _debugTextBlocks[blockNo] = 0; blockNo++; } } -void Make_debug_text_block(char *text, int16 x, int16 y) { +void Debugger::makeDebugTextBlock(char *text, int16 x, int16 y) { uint8 blockNo = 0; - while (blockNo < MAX_DEBUG_TEXT_BLOCKS && debug_text_blocks[blockNo] > 0) + while (blockNo < MAX_DEBUG_TEXT_BLOCKS && _debugTextBlocks[blockNo] > 0) blockNo++; - if (blockNo == MAX_DEBUG_TEXT_BLOCKS) - error("ERROR: debug_text_blocks[] full in Make_debug_text_block()"); + assert(blockNo < MAX_DEBUG_TEXT_BLOCKS); - debug_text_blocks[blockNo] = fontRenderer.buildNewBloc((uint8 *) text, x, y, 640 - x, 0, RDSPR_DISPLAYALIGN, CONSOLE_FONT_ID, NO_JUSTIFICATION); + _debugTextBlocks[blockNo] = fontRenderer.buildNewBloc((uint8 *) text, x, y, 640 - x, 0, RDSPR_DISPLAYALIGN, CONSOLE_FONT_ID, NO_JUSTIFICATION); } -void Build_debug_text(void) { +void Debugger::buildDebugText(void) { char buf[128]; int32 showVarNo; // for variable watching @@ -113,7 +70,7 @@ void Build_debug_text(void) { int32 *varTable; // clear the array of text block numbers for the debug text - Clear_debug_text_blocks(); + clearDebugTextBlocks(); // mouse coords /* @@ -121,82 +78,82 @@ void Build_debug_text(void) { if (displayMouseMarker) { sprintf(buf, "%d,%d", mousex + this_screen.scroll_offset_x, mousey + this_screen.scroll_offset_y); if (mousex>560) - Make_debug_text_block(buf, mousex - 50, mousey - 15); + makeDebugTextBlock(buf, mousex - 50, mousey - 15); else - Make_debug_text_block(buf, mousex + 5, mousey - 15); + makeDebugTextBlock(buf, mousex + 5, mousey - 15); } */ // mouse area coords // defining a mouse area the easy way, by creating a box on-screen - if (draggingRectangle || SYSTEM_TESTING_ANIMS) { + if (_draggingRectangle || SYSTEM_TESTING_ANIMS) { // so we can see what's behind the lines - rectFlicker = !rectFlicker; + _rectFlicker = !_rectFlicker; - sprintf (buf, "x1=%d", rect_x1); - Make_debug_text_block(buf, 0, 120); + sprintf(buf, "x1=%d", _rectX1); + makeDebugTextBlock(buf, 0, 120); - sprintf (buf, "y1=%d", rect_y1); - Make_debug_text_block(buf, 0, 135); + sprintf(buf, "y1=%d", _rectY1); + makeDebugTextBlock(buf, 0, 135); - sprintf (buf, "x2=%d", rect_x2); - Make_debug_text_block(buf, 0, 150); + sprintf(buf, "x2=%d", _rectX2); + makeDebugTextBlock(buf, 0, 150); - sprintf (buf, "y2=%d", rect_y2); - Make_debug_text_block(buf, 0, 165); + sprintf(buf, "y2=%d", _rectY2); + makeDebugTextBlock(buf, 0, 165); } // testingSnR indicator - if (testingSnR) { // see fnAddHuman() - sprintf (buf, "TESTING LOGIC STABILITY!"); - Make_debug_text_block(buf, 0, 105); + if (_testingSnR) { // see fnAddHuman() + sprintf(buf, "TESTING LOGIC STABILITY!"); + makeDebugTextBlock(buf, 0, 105); } // speed-up indicator - if (renderSkip) { // see sword.cpp - sprintf (buf, "SKIPPING FRAMES FOR SPEED-UP!"); - Make_debug_text_block(buf, 0, 120); + if (g_sword2->_renderSkip) { // see sword.cpp + sprintf(buf, "SKIPPING FRAMES FOR SPEED-UP!"); + makeDebugTextBlock(buf, 0, 120); } // debug info at top of screen - enabled/disabled as one complete unit - if (displayTime) { + if (_displayTime) { int32 time = SVM_timeGetTime(); - if ((time - startTime) / 1000 >= 10000) - startTime = time; + if ((time - _startTime) / 1000 >= 10000) + _startTime = time; - time -= startTime; + time -= _startTime; sprintf(buf, "Time %.2d:%.2d:%.2d.%.3d", (time / 3600000) % 60, (time / 60000) % 60, (time / 1000) % 60, time % 1000); - Make_debug_text_block(buf, 500, 360); - sprintf(buf, "Game %d", gameCycle); - Make_debug_text_block(buf, 500, 380); + makeDebugTextBlock(buf, 500, 360); + sprintf(buf, "Game %d", g_sword2->_gameCycle); + makeDebugTextBlock(buf, 500, 380); } // current text number & speech-sample resource id - if (displayTextNumbers) { - if (textNumber) { + if (_displayTextNumbers) { + if (_textNumber) { if (SYSTEM_TESTING_TEXT) { if (SYSTEM_WANT_PREVIOUS_LINE) sprintf(buf, "backwards"); else sprintf(buf, "forwards"); - Make_debug_text_block(buf, 0, 340); + makeDebugTextBlock(buf, 0, 340); } - sprintf(buf, "res: %d", textNumber / SIZE); - Make_debug_text_block(buf, 0, 355); + sprintf(buf, "res: %d", _textNumber / SIZE); + makeDebugTextBlock(buf, 0, 355); - sprintf(buf, "pos: %d", textNumber & 0xffff); - Make_debug_text_block(buf, 0, 370); + sprintf(buf, "pos: %d", _textNumber & 0xffff); + makeDebugTextBlock(buf, 0, 370); sprintf(buf, "TEXT: %d", officialTextNumber); - Make_debug_text_block(buf, 0, 385); + makeDebugTextBlock(buf, 0, 385); } } @@ -204,16 +161,16 @@ void Build_debug_text(void) { if (SYSTEM_TESTING_ANIMS) { sprintf(buf, "trying resource %d", SYSTEM_TESTING_ANIMS); - Make_debug_text_block(buf, 0, 90); + makeDebugTextBlock(buf, 0, 90); } // general debug info - if (displayDebugText) { + if (_displayDebugText) { /* // CD in use - sprintf (buf, "CD-%d", currentCD); - Make_debug_text_block(buf, 0, 0); + sprintf(buf, "CD-%d", currentCD); + makeDebugTextBlock(buf, 0, 0); */ // mouse coords & object pointed to @@ -226,7 +183,7 @@ void Build_debug_text(void) { sprintf(buf, "last click at %d,%d (---)", MOUSE_X, MOUSE_Y); - Make_debug_text_block(buf, 0, 15); + makeDebugTextBlock(buf, 0, 15); if (mouse_touching) sprintf(buf, "mouse %d,%d (id %d: %s)", @@ -239,75 +196,75 @@ void Build_debug_text(void) { g_display->_mouseX + this_screen.scroll_offset_x, g_display->_mouseY + this_screen.scroll_offset_y); - Make_debug_text_block(buf, 0, 30); + makeDebugTextBlock(buf, 0, 30); // player coords & graphic info // if player objct has a graphic - if (playerGraphic.anim_resource) + if (_playerGraphic.anim_resource) sprintf(buf, "player %d,%d %s (%d) #%d/%d", this_screen.player_feet_x, this_screen.player_feet_y, - FetchObjectName(playerGraphic.anim_resource), - playerGraphic.anim_resource, - playerGraphic.anim_pc, - player_graphic_no_frames); + FetchObjectName(_playerGraphic.anim_resource), + _playerGraphic.anim_resource, + _playerGraphic.anim_pc, + _playerGraphicNoFrames); else sprintf(buf, "player %d,%d --- %d", this_screen.player_feet_x, this_screen.player_feet_y, - playerGraphic.anim_pc); + _playerGraphic.anim_pc); - Make_debug_text_block(buf, 0, 45); + makeDebugTextBlock(buf, 0, 45); // frames-per-second counter sprintf(buf, "fps %d", g_sword2->_fps); - Make_debug_text_block(buf, 440, 0); + makeDebugTextBlock(buf, 440, 0); // location number sprintf(buf, "location=%d", LOCATION); - Make_debug_text_block(buf, 440, 15); + makeDebugTextBlock(buf, 440, 15); // "result" variable sprintf(buf, "result=%d", RESULT); - Make_debug_text_block(buf, 440, 30); + makeDebugTextBlock(buf, 440, 30); // no. of events in event list - sprintf(buf, "events=%d", CountEvents()); - Make_debug_text_block(buf, 440, 45); + sprintf(buf, "events=%d", g_sword2->countEvents()); + makeDebugTextBlock(buf, 440, 45); // sprite list usage sprintf(buf, "bgp0: %d/%d", g_sword2->_curBgp0, MAX_bgp0_sprites); - Make_debug_text_block(buf, 560, 0); + makeDebugTextBlock(buf, 560, 0); sprintf(buf, "bgp1: %d/%d", g_sword2->_curBgp1, MAX_bgp1_sprites); - Make_debug_text_block(buf, 560, 15); + makeDebugTextBlock(buf, 560, 15); sprintf(buf, "back: %d/%d", g_sword2->_curBack, MAX_back_sprites); - Make_debug_text_block(buf, 560, 30); + makeDebugTextBlock(buf, 560, 30); sprintf(buf, "sort: %d/%d", g_sword2->_curSort, MAX_sort_sprites); - Make_debug_text_block(buf, 560, 45); + makeDebugTextBlock(buf, 560, 45); sprintf(buf, "fore: %d/%d", g_sword2->_curFore, MAX_fore_sprites); - Make_debug_text_block(buf, 560, 60); + makeDebugTextBlock(buf, 560, 60); sprintf(buf, "fgp0: %d/%d", g_sword2->_curFgp0, MAX_fgp0_sprites); - Make_debug_text_block(buf, 560, 75); + makeDebugTextBlock(buf, 560, 75); sprintf(buf, "fgp1: %d/%d", g_sword2->_curFgp1, MAX_fgp1_sprites); - Make_debug_text_block(buf, 560, 90); + makeDebugTextBlock(buf, 560, 90); // largest layer & sprite // NB. Strings already constructed in Build_display.cpp - Make_debug_text_block(g_sword2->_largestLayerInfo, 0, 60); - Make_debug_text_block(g_sword2->_largestSpriteInfo, 0, 75); + makeDebugTextBlock(g_sword2->_largestLayerInfo, 0, 60); + makeDebugTextBlock(g_sword2->_largestSpriteInfo, 0, 75); // "waiting for person" indicator - set form fnTheyDo and // fnTheyDoWeWait @@ -316,7 +273,7 @@ void Build_debug_text(void) { sprintf(buf, "script waiting for %s (%d)", FetchObjectName(speechScriptWaiting), speechScriptWaiting); - Make_debug_text_block(buf, 0, 90); + makeDebugTextBlock(buf, 0, 90); } // variable watch display @@ -327,14 +284,14 @@ void Build_debug_text(void) { varTable = (int32 *) (res_man.open(1) + sizeof(_standardHeader)); for (showVarNo = 0; showVarNo < MAX_SHOWVARS; showVarNo++) { - varNo = showVar[showVarNo]; // get variable number + varNo = _showVar[showVarNo]; // get variable number // if non-zero ie. cannot watch 'id' but not needed // anyway because it changes throughout the logic loop if (varNo) { sprintf(buf, "var(%d) = %d", varNo, varTable[varNo]); - Make_debug_text_block(buf, 530, showVarPos); + makeDebugTextBlock(buf, 530, showVarPos); showVarPos += 15; // next line down } } @@ -345,40 +302,40 @@ void Build_debug_text(void) { // sprite blocks above! memory.memoryString(buf); - Make_debug_text_block(buf, 0, 0); + makeDebugTextBlock(buf, 0, 0); } } -void Draw_debug_graphics(void) { +void Debugger::drawDebugGraphics(void) { // walk-grid - if (displayWalkGrid) + if (_displayWalkGrid) router.plotWalkGrid(); // player feet coord marker - if (displayPlayerMarker) - Plot_cross_hair(this_screen.player_feet_x, this_screen.player_feet_y, 215); + if (_displayPlayerMarker) + plotCrossHair(this_screen.player_feet_x, this_screen.player_feet_y, 215); // mouse marker & coords - if (displayMouseMarker) - Plot_cross_hair(g_display->_mouseX + this_screen.scroll_offset_x, g_display->_mouseY + this_screen.scroll_offset_y, 215); + if (_displayMouseMarker) + plotCrossHair(g_display->_mouseX + this_screen.scroll_offset_x, g_display->_mouseY + this_screen.scroll_offset_y, 215); // mouse area rectangle / sprite box rectangle when testing anims if (SYSTEM_TESTING_ANIMS) { // draw box around current frame - DrawRect(rect_x1, rect_y1, rect_x2, rect_y2, 184); - } else if (draggingRectangle) { + drawRect(_rectX1, _rectY1, _rectX2, _rectY2, 184); + } else if (_draggingRectangle) { // defining a mouse area the easy way, by creating a box // on-screen - if (rectFlicker) - DrawRect(rect_x1, rect_y1, rect_x2, rect_y2, 184); + if (_rectFlicker) + drawRect(_rectX1, _rectY1, _rectX2, _rectY2, 184); } } -void Plot_cross_hair(int16 x, int16 y, uint8 pen) { +void Debugger::plotCrossHair(int16 x, int16 y, uint8 pen) { g_display->plotPoint(x, y, pen); // driver function g_display->drawLine(x - 2, y, x - 5, y, pen); // driver function @@ -388,14 +345,14 @@ void Plot_cross_hair(int16 x, int16 y, uint8 pen) { g_display->drawLine(x, y + 2, x, y + 5, pen); } -void DrawRect(int16 x1, int16 y1, int16 x2, int16 y2, uint8 pen) { +void Debugger::drawRect(int16 x1, int16 y1, int16 x2, int16 y2, uint8 pen) { g_display->drawLine(x1, y1, x2, y1, pen); // top edge g_display->drawLine(x1, y2, x2, y2, pen); // bottom edge g_display->drawLine(x1, y1, x1, y2, pen); // left edge g_display->drawLine(x2, y1, x2, y2, pen); // right edge } -void Print_current_info(void) { +void Debugger::printCurrentInfo(void) { // prints general stuff about the screen, etc. if (this_screen.background_layer_id) { |