More moving of stuff into classes. I had to make a few changes/cleanups to
events.cpp, so there could be regressions. svn-id: r11053
This commit is contained in:
parent
e9ae86bb76
commit
db9b8070f6
18 changed files with 471 additions and 552 deletions
|
@ -155,7 +155,7 @@ void Sword2Engine::buildDisplay(void) {
|
||||||
// walkgrid, mouse & player markers & mouse area
|
// walkgrid, mouse & player markers & mouse area
|
||||||
// rectangle
|
// rectangle
|
||||||
|
|
||||||
Draw_debug_graphics();
|
_debugger->drawDebugGraphics();
|
||||||
|
|
||||||
// text blocks
|
// text blocks
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ void Sword2Engine::displayMsg(uint8 *text, int time) {
|
||||||
_palEntry oldPal[256];
|
_palEntry oldPal[256];
|
||||||
uint32 rv; // drivers error return value
|
uint32 rv; // drivers error return value
|
||||||
|
|
||||||
warning("DisplayMsg: %s", (char *) text);
|
debug(2, "DisplayMsg: %s", (char *) text);
|
||||||
|
|
||||||
if (g_display->getFadeStatus() != RDFADE_BLACK) {
|
if (g_display->getFadeStatus() != RDFADE_BLACK) {
|
||||||
g_display->fadeDown();
|
g_display->fadeDown();
|
||||||
|
@ -499,10 +499,10 @@ void Sword2Engine::processImage(buildit *build_unit) {
|
||||||
spriteInfo.y = 1;
|
spriteInfo.y = 1;
|
||||||
|
|
||||||
// create box to surround sprite - just outside sprite box
|
// create box to surround sprite - just outside sprite box
|
||||||
rect_x1 = spriteInfo.x - 1;
|
_debugger->_rectX1 = spriteInfo.x - 1;
|
||||||
rect_y1 = spriteInfo.y - 1;
|
_debugger->_rectY1 = spriteInfo.y - 1;
|
||||||
rect_x2 = spriteInfo.x + spriteInfo.scaledWidth;
|
_debugger->_rectX2 = spriteInfo.x + spriteInfo.scaledWidth;
|
||||||
rect_y2 = spriteInfo.y + spriteInfo.scaledHeight;
|
_debugger->_rectY2 = spriteInfo.y + spriteInfo.scaledHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #ifdef _SWORD2_DEBUG
|
// #ifdef _SWORD2_DEBUG
|
||||||
|
@ -588,11 +588,11 @@ void Sword2Engine::registerFrame(int32 *params, buildit *build_unit) {
|
||||||
|
|
||||||
// update player graphic details for on-screen debug info
|
// update player graphic details for on-screen debug info
|
||||||
if (ID == CUR_PLAYER_ID) {
|
if (ID == CUR_PLAYER_ID) {
|
||||||
playerGraphic.type = ob_graph->type;
|
_debugger->_playerGraphic.type = ob_graph->type;
|
||||||
playerGraphic.anim_resource = ob_graph->anim_resource;
|
_debugger->_playerGraphic.anim_resource = ob_graph->anim_resource;
|
||||||
// counting 1st frame as 'frame 1'
|
// counting 1st frame as 'frame 1'
|
||||||
playerGraphic.anim_pc = ob_graph->anim_pc + 1;
|
_debugger->_playerGraphic.anim_pc = ob_graph->anim_pc + 1;
|
||||||
player_graphic_no_frames = anim_head->noAnimFrames;
|
_debugger->_playerGraphicNoFrames = anim_head->noAnimFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill in the buildit structure for this frame
|
// fill in the buildit structure for this frame
|
||||||
|
|
|
@ -35,13 +35,11 @@
|
||||||
|
|
||||||
namespace Sword2 {
|
namespace Sword2 {
|
||||||
|
|
||||||
bool wantSfxDebug = false; // sfx debug enabled/disabled from console
|
void Debugger::varGet(int var) {
|
||||||
|
|
||||||
static void Var_check(int var) {
|
|
||||||
Debug_Printf("%d\n", VAR(var));
|
Debug_Printf("%d\n", VAR(var));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Var_set(int var, int val) {
|
void Debugger::varSet(int var, int val) {
|
||||||
Debug_Printf("was %d, ", VAR(var));
|
Debug_Printf("was %d, ", VAR(var));
|
||||||
VAR(var) = val;
|
VAR(var) = val;
|
||||||
Debug_Printf("now %d\n", VAR(var));
|
Debug_Printf("now %d\n", VAR(var));
|
||||||
|
@ -51,6 +49,36 @@ Debugger::Debugger(Sword2Engine *s)
|
||||||
: Common::Debugger<Debugger>() {
|
: Common::Debugger<Debugger>() {
|
||||||
_vm = s;
|
_vm = s;
|
||||||
|
|
||||||
|
memset(_debugTextBlocks, 0, sizeof(_debugTextBlocks));
|
||||||
|
memset(_showVar, 0, sizeof(_showVar));
|
||||||
|
|
||||||
|
_displayDebugText = false; // "INFO"
|
||||||
|
_displayWalkGrid = false; // "WALKGRID"
|
||||||
|
_displayMouseMarker = false; // "MOUSE"
|
||||||
|
_displayTime = false; // "TIME"
|
||||||
|
_displayPlayerMarker = false; // "PLAYER"
|
||||||
|
_displayTextNumbers = false; // "TEXT"
|
||||||
|
|
||||||
|
_definingRectangles = false; // "RECT"
|
||||||
|
_draggingRectangle = 0; // 0 = waiting to start new rect
|
||||||
|
// 1 = currently dragging a rectangle
|
||||||
|
|
||||||
|
_rectX1 = _rectY1 = 0;
|
||||||
|
_rectX2 = _rectY2 = 0;
|
||||||
|
_rectFlicker = false;
|
||||||
|
|
||||||
|
_testingSnR = false; // "SAVEREST" - for system to kill all
|
||||||
|
// object resources (except player) in
|
||||||
|
// fnAddHuman()
|
||||||
|
|
||||||
|
_startTime = 0; // "TIMEON" & "TIMEOFF" - system start
|
||||||
|
// time
|
||||||
|
|
||||||
|
_textNumber = 0; // Current system text line number
|
||||||
|
|
||||||
|
_playerGraphicNoFrames = 0; // No. of frames in currently displayed
|
||||||
|
// anim
|
||||||
|
|
||||||
// Register commands
|
// Register commands
|
||||||
|
|
||||||
DCmd_Register("continue", &Debugger::Cmd_Exit);
|
DCmd_Register("continue", &Debugger::Cmd_Exit);
|
||||||
|
@ -121,7 +149,6 @@ void Debugger::postEnter() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
// Now the fun stuff:
|
// Now the fun stuff:
|
||||||
|
|
||||||
|
@ -188,9 +215,9 @@ bool Debugger::Cmd_Start(int argc, const char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Debugger::Cmd_Info(int argc, const char **argv) {
|
bool Debugger::Cmd_Info(int argc, const char **argv) {
|
||||||
displayDebugText = !displayDebugText;
|
_displayDebugText = !_displayDebugText;
|
||||||
|
|
||||||
if (displayDebugText)
|
if (_displayDebugText)
|
||||||
DebugPrintf("Info text on\n");
|
DebugPrintf("Info text on\n");
|
||||||
else
|
else
|
||||||
DebugPrintf("Info Text off\n");
|
DebugPrintf("Info Text off\n");
|
||||||
|
@ -199,9 +226,9 @@ bool Debugger::Cmd_Info(int argc, const char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Debugger::Cmd_WalkGrid(int argc, const char **argv) {
|
bool Debugger::Cmd_WalkGrid(int argc, const char **argv) {
|
||||||
displayWalkGrid = !displayWalkGrid;
|
_displayWalkGrid = !_displayWalkGrid;
|
||||||
|
|
||||||
if (displayWalkGrid)
|
if (_displayWalkGrid)
|
||||||
DebugPrintf("Walk-grid display on\n");
|
DebugPrintf("Walk-grid display on\n");
|
||||||
else
|
else
|
||||||
DebugPrintf("Walk-grid display off\n");
|
DebugPrintf("Walk-grid display off\n");
|
||||||
|
@ -210,9 +237,9 @@ bool Debugger::Cmd_WalkGrid(int argc, const char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Debugger::Cmd_Mouse(int argc, const char **argv) {
|
bool Debugger::Cmd_Mouse(int argc, const char **argv) {
|
||||||
displayMouseMarker = !displayMouseMarker;
|
_displayMouseMarker = !_displayMouseMarker;
|
||||||
|
|
||||||
if (displayMouseMarker)
|
if (_displayMouseMarker)
|
||||||
DebugPrintf("Mouse marker on\n");
|
DebugPrintf("Mouse marker on\n");
|
||||||
else
|
else
|
||||||
DebugPrintf("Mouse marker off\n");
|
DebugPrintf("Mouse marker off\n");
|
||||||
|
@ -221,9 +248,9 @@ bool Debugger::Cmd_Mouse(int argc, const char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Debugger::Cmd_Player(int argc, const char **argv) {
|
bool Debugger::Cmd_Player(int argc, const char **argv) {
|
||||||
displayPlayerMarker = !displayPlayerMarker;
|
_displayPlayerMarker = !_displayPlayerMarker;
|
||||||
|
|
||||||
if (displayPlayerMarker)
|
if (_displayPlayerMarker)
|
||||||
DebugPrintf("Player feet marker on\n");
|
DebugPrintf("Player feet marker on\n");
|
||||||
else
|
else
|
||||||
DebugPrintf("Player feet marker off\n");
|
DebugPrintf("Player feet marker off\n");
|
||||||
|
@ -240,7 +267,7 @@ bool Debugger::Cmd_ResLook(int argc, const char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Debugger::Cmd_CurrentInfo(int argc, const char **argv) {
|
bool Debugger::Cmd_CurrentInfo(int argc, const char **argv) {
|
||||||
Print_current_info();
|
printCurrentInfo();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,10 +293,10 @@ bool Debugger::Cmd_Nuke(int argc, const char **argv) {
|
||||||
bool Debugger::Cmd_Var(int argc, const char **argv) {
|
bool Debugger::Cmd_Var(int argc, const char **argv) {
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 2:
|
case 2:
|
||||||
Var_check(atoi(argv[1]));
|
varGet(atoi(argv[1]));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
Var_set(atoi(argv[1]), atoi(argv[2]));
|
varSet(atoi(argv[1]), atoi(argv[2]));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DebugPrintf("Usage: %s number value\n", argv[0]);
|
DebugPrintf("Usage: %s number value\n", argv[0]);
|
||||||
|
@ -280,14 +307,14 @@ bool Debugger::Cmd_Var(int argc, const char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Debugger::Cmd_Rect(int argc, const char **argv) {
|
bool Debugger::Cmd_Rect(int argc, const char **argv) {
|
||||||
definingRectangles = !definingRectangles;
|
_definingRectangles = !_definingRectangles;
|
||||||
|
|
||||||
if (definingRectangles)
|
if (_definingRectangles)
|
||||||
DebugPrintf("Mouse rectangles enabled\n");
|
DebugPrintf("Mouse rectangles enabled\n");
|
||||||
else
|
else
|
||||||
DebugPrintf("Mouse rectangles disabled\n");
|
DebugPrintf("Mouse rectangles disabled\n");
|
||||||
|
|
||||||
draggingRectangle = 0;
|
_draggingRectangle = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,29 +324,29 @@ bool Debugger::Cmd_Clear(int argc, const char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Debugger::Cmd_DebugOn(int argc, const char **argv) {
|
bool Debugger::Cmd_DebugOn(int argc, const char **argv) {
|
||||||
displayDebugText = true;
|
_displayDebugText = true;
|
||||||
displayWalkGrid = true;
|
_displayWalkGrid = true;
|
||||||
displayMouseMarker = true;
|
_displayMouseMarker = true;
|
||||||
displayPlayerMarker = true;
|
_displayPlayerMarker = true;
|
||||||
displayTextNumbers = true;
|
_displayTextNumbers = true;
|
||||||
DebugPrintf("Enabled all on-screen debug info\n");
|
DebugPrintf("Enabled all on-screen debug info\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Debugger::Cmd_DebugOff(int argc, const char **argv) {
|
bool Debugger::Cmd_DebugOff(int argc, const char **argv) {
|
||||||
displayDebugText = false;
|
_displayDebugText = false;
|
||||||
displayWalkGrid = false;
|
_displayWalkGrid = false;
|
||||||
displayMouseMarker = false;
|
_displayMouseMarker = false;
|
||||||
displayPlayerMarker = false;
|
_displayPlayerMarker = false;
|
||||||
displayTextNumbers = false;
|
_displayTextNumbers = false;
|
||||||
DebugPrintf("Disabled all on-screen debug info\n");
|
DebugPrintf("Disabled all on-screen debug info\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Debugger::Cmd_SaveRest(int argc, const char **argv) {
|
bool Debugger::Cmd_SaveRest(int argc, const char **argv) {
|
||||||
testingSnR = !testingSnR;
|
_testingSnR = !_testingSnR;
|
||||||
|
|
||||||
if (testingSnR)
|
if (_testingSnR)
|
||||||
DebugPrintf("Enabled S&R logic_script stability checking\n");
|
DebugPrintf("Enabled S&R logic_script stability checking\n");
|
||||||
else
|
else
|
||||||
DebugPrintf("Disabled S&R logic_script stability checking\n");
|
DebugPrintf("Disabled S&R logic_script stability checking\n");
|
||||||
|
@ -440,24 +467,24 @@ bool Debugger::Cmd_BltFxOff(int argc, const char **argv) {
|
||||||
|
|
||||||
bool Debugger::Cmd_TimeOn(int argc, const char **argv) {
|
bool Debugger::Cmd_TimeOn(int argc, const char **argv) {
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
startTime = SVM_timeGetTime() - atoi(argv[1]) * 1000;
|
_startTime = SVM_timeGetTime() - atoi(argv[1]) * 1000;
|
||||||
else if (startTime == 0)
|
else if (_startTime == 0)
|
||||||
startTime = SVM_timeGetTime();
|
_startTime = SVM_timeGetTime();
|
||||||
displayTime = true;
|
_displayTime = true;
|
||||||
DebugPrintf("Timer display on\n");
|
DebugPrintf("Timer display on\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Debugger::Cmd_TimeOff(int argc, const char **argv) {
|
bool Debugger::Cmd_TimeOff(int argc, const char **argv) {
|
||||||
displayTime = false;
|
_displayTime = false;
|
||||||
DebugPrintf("Timer display off\n");
|
DebugPrintf("Timer display off\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Debugger::Cmd_Text(int argc, const char **argv) {
|
bool Debugger::Cmd_Text(int argc, const char **argv) {
|
||||||
displayTextNumbers = !displayTextNumbers;
|
_displayTextNumbers = !_displayTextNumbers;
|
||||||
|
|
||||||
if (displayTextNumbers)
|
if (_displayTextNumbers)
|
||||||
DebugPrintf("Text numbers on\n");
|
DebugPrintf("Text numbers on\n");
|
||||||
else
|
else
|
||||||
DebugPrintf("Text numbers off\n");
|
DebugPrintf("Text numbers off\n");
|
||||||
|
@ -479,14 +506,14 @@ bool Debugger::Cmd_ShowVar(int argc, const char **argv) {
|
||||||
// search for a spare slot in the watch-list, but also watch out for
|
// search for a spare slot in the watch-list, but also watch out for
|
||||||
// this variable already being in the list
|
// this variable already being in the list
|
||||||
|
|
||||||
while (showVarNo < MAX_SHOWVARS && showVar[showVarNo] != 0 && showVar[showVarNo] != varNo)
|
while (showVarNo < MAX_SHOWVARS && _showVar[showVarNo] != 0 && _showVar[showVarNo] != varNo)
|
||||||
showVarNo++;
|
showVarNo++;
|
||||||
|
|
||||||
// if we've found a spare slot or the variable's already there
|
// if we've found a spare slot or the variable's already there
|
||||||
if (showVarNo < MAX_SHOWVARS) {
|
if (showVarNo < MAX_SHOWVARS) {
|
||||||
if (showVar[showVarNo] == 0) {
|
if (_showVar[showVarNo] == 0) {
|
||||||
// empty slot - add it to the list at this slot
|
// empty slot - add it to the list at this slot
|
||||||
showVar[showVarNo] = varNo;
|
_showVar[showVarNo] = varNo;
|
||||||
DebugPrintf("var(%d) added to the watch-list\n", varNo);
|
DebugPrintf("var(%d) added to the watch-list\n", varNo);
|
||||||
} else
|
} else
|
||||||
DebugPrintf("var(%d) already in the watch-list!\n", varNo);
|
DebugPrintf("var(%d) already in the watch-list!\n", varNo);
|
||||||
|
@ -508,12 +535,12 @@ bool Debugger::Cmd_HideVar(int argc, const char **argv) {
|
||||||
varNo = atoi(argv[1]);
|
varNo = atoi(argv[1]);
|
||||||
|
|
||||||
// search for 'varNo' in the watch-list
|
// search for 'varNo' in the watch-list
|
||||||
while (showVarNo < MAX_SHOWVARS && showVar[showVarNo] != varNo)
|
while (showVarNo < MAX_SHOWVARS && _showVar[showVarNo] != varNo)
|
||||||
showVarNo++;
|
showVarNo++;
|
||||||
|
|
||||||
if (showVarNo < MAX_SHOWVARS) {
|
if (showVarNo < MAX_SHOWVARS) {
|
||||||
// We've found 'varNo' in the list - clear this slot
|
// We've found 'varNo' in the list - clear this slot
|
||||||
showVar[showVarNo] = 0;
|
_showVar[showVarNo] = 0;
|
||||||
DebugPrintf("var(%d) removed from watch-list\n", varNo);
|
DebugPrintf("var(%d) removed from watch-list\n", varNo);
|
||||||
} else
|
} else
|
||||||
DebugPrintf("Sorry - can't find var(%d) in the list\n", varNo);
|
DebugPrintf("Sorry - can't find var(%d) in the list\n", varNo);
|
||||||
|
@ -588,7 +615,7 @@ bool Debugger::Cmd_AnimTest(int argc, const char **argv) {
|
||||||
Con_start(32);
|
Con_start(32);
|
||||||
|
|
||||||
// Same as typing "VAR 912 <value>" at the console
|
// Same as typing "VAR 912 <value>" at the console
|
||||||
Var_set(912, atoi(argv[1]));
|
varSet(912, atoi(argv[1]));
|
||||||
|
|
||||||
DebugPrintf("Setting flag 'system_testing_anims'\n");
|
DebugPrintf("Setting flag 'system_testing_anims'\n");
|
||||||
return true;
|
return true;
|
||||||
|
@ -604,9 +631,9 @@ bool Debugger::Cmd_TextTest(int argc, const char **argv) {
|
||||||
Con_start(33);
|
Con_start(33);
|
||||||
|
|
||||||
// Same as typing "VAR 1230 <value>" at the console
|
// Same as typing "VAR 1230 <value>" at the console
|
||||||
Var_set(1230, atoi(argv[1]));
|
varSet(1230, atoi(argv[1]));
|
||||||
|
|
||||||
displayTextNumbers = true;
|
_displayTextNumbers = true;
|
||||||
|
|
||||||
DebugPrintf("Setting flag 'system_testing_text'\n");
|
DebugPrintf("Setting flag 'system_testing_text'\n");
|
||||||
DebugPrintf("Text numbers on\n");
|
DebugPrintf("Text numbers on\n");
|
||||||
|
@ -623,12 +650,12 @@ bool Debugger::Cmd_LineTest(int argc, const char **argv) {
|
||||||
Con_start(33);
|
Con_start(33);
|
||||||
|
|
||||||
// Same as typing "VAR 1230 <value>" at the console
|
// Same as typing "VAR 1230 <value>" at the console
|
||||||
Var_set(1230, atoi(argv[1]));
|
varSet(1230, atoi(argv[1]));
|
||||||
|
|
||||||
// Same as typing "VAR 1264 <value>" at the console
|
// Same as typing "VAR 1264 <value>" at the console
|
||||||
Var_set(1264, atoi(argv[2]));
|
varSet(1264, atoi(argv[2]));
|
||||||
|
|
||||||
displayTextNumbers = true;
|
_displayTextNumbers = true;
|
||||||
|
|
||||||
DebugPrintf("Setting flag 'system_testing_text'\n");
|
DebugPrintf("Setting flag 'system_testing_text'\n");
|
||||||
DebugPrintf("Setting flag 'system_test_line_no'\n");
|
DebugPrintf("Setting flag 'system_test_line_no'\n");
|
||||||
|
@ -640,9 +667,9 @@ bool Debugger::Cmd_Grab(int argc, const char **argv) {
|
||||||
DebugPrintf("FIXME: Continuous screen-grabbing not implemented\n");
|
DebugPrintf("FIXME: Continuous screen-grabbing not implemented\n");
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
grabbingSequences = !grabbingSequences;
|
g_sword2->_grabbingSequences = !g_sword2->_grabbingSequences;
|
||||||
|
|
||||||
if (grabbingSequences)
|
if (g_sword2->_grabbingSequences)
|
||||||
DebugPrintf("PCX-grabbing enabled\n");
|
DebugPrintf("PCX-grabbing enabled\n");
|
||||||
else
|
else
|
||||||
DebugPrintf("PCX-grabbing disabled\n");
|
DebugPrintf("PCX-grabbing disabled\n");
|
||||||
|
@ -655,9 +682,9 @@ bool Debugger::Cmd_Events(int argc, const char **argv) {
|
||||||
DebugPrintf("EVENT LIST:\n");
|
DebugPrintf("EVENT LIST:\n");
|
||||||
|
|
||||||
for (uint32 i = 0; i < MAX_events; i++) {
|
for (uint32 i = 0; i < MAX_events; i++) {
|
||||||
if (event_list[i].id) {
|
if (g_sword2->_eventList[i].id) {
|
||||||
uint32 target = event_list[i].id;
|
uint32 target = g_sword2->_eventList[i].id;
|
||||||
uint32 script = event_list[i].interact_id;
|
uint32 script = g_sword2->_eventList[i].interact_id;
|
||||||
|
|
||||||
DebugPrintf("slot %d: id = %s (%d)\n", i, FetchObjectName(target), target);
|
DebugPrintf("slot %d: id = %s (%d)\n", i, FetchObjectName(target), target);
|
||||||
DebugPrintf(" script = %s (%d) pos %d\n", FetchObjectName(script / 65536), script / 65536, script % 65536);
|
DebugPrintf(" script = %s (%d) pos %d\n", FetchObjectName(script / 65536), script / 65536, script % 65536);
|
||||||
|
@ -668,9 +695,9 @@ bool Debugger::Cmd_Events(int argc, const char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Debugger::Cmd_Sfx(int argc, const char **argv) {
|
bool Debugger::Cmd_Sfx(int argc, const char **argv) {
|
||||||
wantSfxDebug = !wantSfxDebug;
|
g_sword2->_wantSfxDebug = !g_sword2->_wantSfxDebug;
|
||||||
|
|
||||||
if (wantSfxDebug)
|
if (g_sword2->_wantSfxDebug)
|
||||||
DebugPrintf("SFX logging activated\n");
|
DebugPrintf("SFX logging activated\n");
|
||||||
else
|
else
|
||||||
DebugPrintf("SFX logging deactivated\n");
|
DebugPrintf("SFX logging deactivated\n");
|
||||||
|
|
|
@ -21,21 +21,62 @@
|
||||||
#define C_ONSOLE_H
|
#define C_ONSOLE_H
|
||||||
|
|
||||||
#include "common/debugger.h"
|
#include "common/debugger.h"
|
||||||
#include "sword2/memory.h"
|
#include "sword2/debug.h"
|
||||||
|
#include "sword2/object.h"
|
||||||
|
|
||||||
#define Debug_Printf g_sword2->_debugger->DebugPrintf
|
#define Debug_Printf g_sword2->_debugger->DebugPrintf
|
||||||
|
|
||||||
namespace Sword2 {
|
namespace Sword2 {
|
||||||
|
|
||||||
extern bool grabbingSequences;
|
|
||||||
extern bool wantSfxDebug; // sfx debug file enabled/disabled from console
|
|
||||||
|
|
||||||
class Sword2Engine;
|
class Sword2Engine;
|
||||||
|
|
||||||
class Debugger : public Common::Debugger<Debugger> {
|
class Debugger : public Common::Debugger<Debugger> {
|
||||||
|
private:
|
||||||
|
void varGet(int var);
|
||||||
|
void varSet(int var, int val);
|
||||||
|
|
||||||
|
bool _displayDebugText;
|
||||||
|
bool _displayWalkGrid;
|
||||||
|
bool _displayMouseMarker;
|
||||||
|
bool _displayTime;
|
||||||
|
bool _displayPlayerMarker;
|
||||||
|
bool _displayTextNumbers;
|
||||||
|
|
||||||
|
bool _rectFlicker;
|
||||||
|
|
||||||
|
int32 _startTime;
|
||||||
|
|
||||||
|
int32 _showVar[MAX_SHOWVARS];
|
||||||
|
|
||||||
|
uint8 _debugTextBlocks[MAX_DEBUG_TEXT_BLOCKS];
|
||||||
|
|
||||||
|
void clearDebugTextBlocks(void);
|
||||||
|
void makeDebugTextBlock(char *text, int16 x, int16 y);
|
||||||
|
|
||||||
|
void printCurrentInfo(void);
|
||||||
|
|
||||||
|
void plotCrossHair(int16 x, int16 y, uint8 pen);
|
||||||
|
void drawRect(int16 x, int16 y, int16 x2, int16 y2, uint8 pen);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Debugger(Sword2Engine *s);
|
Debugger(Sword2Engine *s);
|
||||||
|
|
||||||
|
int16 _rectX1, _rectY1;
|
||||||
|
int16 _rectX2, _rectY2;
|
||||||
|
|
||||||
|
uint8 _draggingRectangle;
|
||||||
|
bool _definingRectangles;
|
||||||
|
|
||||||
|
bool _testingSnR;
|
||||||
|
|
||||||
|
int32 _textNumber;
|
||||||
|
|
||||||
|
Object_graphic _playerGraphic;
|
||||||
|
uint32 _playerGraphicNoFrames;
|
||||||
|
|
||||||
|
void buildDebugText(void);
|
||||||
|
void drawDebugGraphics(void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Sword2Engine *_vm;
|
Sword2Engine *_vm;
|
||||||
|
|
||||||
|
|
217
sword2/debug.cpp
217
sword2/debug.cpp
|
@ -36,75 +36,32 @@
|
||||||
|
|
||||||
namespace Sword2 {
|
namespace Sword2 {
|
||||||
|
|
||||||
bool displayDebugText = false; // "INFO"
|
void Debugger::clearDebugTextBlocks(void) {
|
||||||
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) {
|
|
||||||
uint8 blockNo = 0;
|
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
|
// kill the system text block
|
||||||
fontRenderer.killTextBloc(debug_text_blocks[blockNo]);
|
fontRenderer.killTextBloc(_debugTextBlocks[blockNo]);
|
||||||
|
|
||||||
// clear this element of our array of block numbers
|
// clear this element of our array of block numbers
|
||||||
debug_text_blocks[blockNo] = 0;
|
_debugTextBlocks[blockNo] = 0;
|
||||||
|
|
||||||
blockNo++;
|
blockNo++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Make_debug_text_block(char *text, int16 x, int16 y) {
|
void Debugger::makeDebugTextBlock(char *text, int16 x, int16 y) {
|
||||||
uint8 blockNo = 0;
|
uint8 blockNo = 0;
|
||||||
|
|
||||||
while (blockNo < MAX_DEBUG_TEXT_BLOCKS && debug_text_blocks[blockNo] > 0)
|
while (blockNo < MAX_DEBUG_TEXT_BLOCKS && _debugTextBlocks[blockNo] > 0)
|
||||||
blockNo++;
|
blockNo++;
|
||||||
|
|
||||||
if (blockNo == MAX_DEBUG_TEXT_BLOCKS)
|
assert(blockNo < MAX_DEBUG_TEXT_BLOCKS);
|
||||||
error("ERROR: debug_text_blocks[] full in Make_debug_text_block()");
|
|
||||||
|
|
||||||
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];
|
char buf[128];
|
||||||
|
|
||||||
int32 showVarNo; // for variable watching
|
int32 showVarNo; // for variable watching
|
||||||
|
@ -113,7 +70,7 @@ void Build_debug_text(void) {
|
||||||
int32 *varTable;
|
int32 *varTable;
|
||||||
|
|
||||||
// clear the array of text block numbers for the debug text
|
// clear the array of text block numbers for the debug text
|
||||||
Clear_debug_text_blocks();
|
clearDebugTextBlocks();
|
||||||
|
|
||||||
// mouse coords
|
// mouse coords
|
||||||
/*
|
/*
|
||||||
|
@ -121,82 +78,82 @@ void Build_debug_text(void) {
|
||||||
if (displayMouseMarker) {
|
if (displayMouseMarker) {
|
||||||
sprintf(buf, "%d,%d", mousex + this_screen.scroll_offset_x, mousey + this_screen.scroll_offset_y);
|
sprintf(buf, "%d,%d", mousex + this_screen.scroll_offset_x, mousey + this_screen.scroll_offset_y);
|
||||||
if (mousex>560)
|
if (mousex>560)
|
||||||
Make_debug_text_block(buf, mousex - 50, mousey - 15);
|
makeDebugTextBlock(buf, mousex - 50, mousey - 15);
|
||||||
else
|
else
|
||||||
Make_debug_text_block(buf, mousex + 5, mousey - 15);
|
makeDebugTextBlock(buf, mousex + 5, mousey - 15);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// mouse area coords
|
// mouse area coords
|
||||||
|
|
||||||
// defining a mouse area the easy way, by creating a box on-screen
|
// 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
|
// so we can see what's behind the lines
|
||||||
rectFlicker = !rectFlicker;
|
_rectFlicker = !_rectFlicker;
|
||||||
|
|
||||||
sprintf (buf, "x1=%d", rect_x1);
|
sprintf(buf, "x1=%d", _rectX1);
|
||||||
Make_debug_text_block(buf, 0, 120);
|
makeDebugTextBlock(buf, 0, 120);
|
||||||
|
|
||||||
sprintf (buf, "y1=%d", rect_y1);
|
sprintf(buf, "y1=%d", _rectY1);
|
||||||
Make_debug_text_block(buf, 0, 135);
|
makeDebugTextBlock(buf, 0, 135);
|
||||||
|
|
||||||
sprintf (buf, "x2=%d", rect_x2);
|
sprintf(buf, "x2=%d", _rectX2);
|
||||||
Make_debug_text_block(buf, 0, 150);
|
makeDebugTextBlock(buf, 0, 150);
|
||||||
|
|
||||||
sprintf (buf, "y2=%d", rect_y2);
|
sprintf(buf, "y2=%d", _rectY2);
|
||||||
Make_debug_text_block(buf, 0, 165);
|
makeDebugTextBlock(buf, 0, 165);
|
||||||
}
|
}
|
||||||
|
|
||||||
// testingSnR indicator
|
// testingSnR indicator
|
||||||
|
|
||||||
if (testingSnR) { // see fnAddHuman()
|
if (_testingSnR) { // see fnAddHuman()
|
||||||
sprintf (buf, "TESTING LOGIC STABILITY!");
|
sprintf(buf, "TESTING LOGIC STABILITY!");
|
||||||
Make_debug_text_block(buf, 0, 105);
|
makeDebugTextBlock(buf, 0, 105);
|
||||||
}
|
}
|
||||||
|
|
||||||
// speed-up indicator
|
// speed-up indicator
|
||||||
|
|
||||||
if (renderSkip) { // see sword.cpp
|
if (g_sword2->_renderSkip) { // see sword.cpp
|
||||||
sprintf (buf, "SKIPPING FRAMES FOR SPEED-UP!");
|
sprintf(buf, "SKIPPING FRAMES FOR SPEED-UP!");
|
||||||
Make_debug_text_block(buf, 0, 120);
|
makeDebugTextBlock(buf, 0, 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
// debug info at top of screen - enabled/disabled as one complete unit
|
// debug info at top of screen - enabled/disabled as one complete unit
|
||||||
|
|
||||||
if (displayTime) {
|
if (_displayTime) {
|
||||||
int32 time = SVM_timeGetTime();
|
int32 time = SVM_timeGetTime();
|
||||||
|
|
||||||
if ((time - startTime) / 1000 >= 10000)
|
if ((time - _startTime) / 1000 >= 10000)
|
||||||
startTime = time;
|
_startTime = time;
|
||||||
|
|
||||||
time -= startTime;
|
time -= _startTime;
|
||||||
sprintf(buf, "Time %.2d:%.2d:%.2d.%.3d", (time / 3600000) % 60, (time / 60000) % 60, (time / 1000) % 60, time % 1000);
|
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);
|
makeDebugTextBlock(buf, 500, 360);
|
||||||
sprintf(buf, "Game %d", gameCycle);
|
sprintf(buf, "Game %d", g_sword2->_gameCycle);
|
||||||
Make_debug_text_block(buf, 500, 380);
|
makeDebugTextBlock(buf, 500, 380);
|
||||||
}
|
}
|
||||||
|
|
||||||
// current text number & speech-sample resource id
|
// current text number & speech-sample resource id
|
||||||
|
|
||||||
if (displayTextNumbers) {
|
if (_displayTextNumbers) {
|
||||||
if (textNumber) {
|
if (_textNumber) {
|
||||||
if (SYSTEM_TESTING_TEXT) {
|
if (SYSTEM_TESTING_TEXT) {
|
||||||
if (SYSTEM_WANT_PREVIOUS_LINE)
|
if (SYSTEM_WANT_PREVIOUS_LINE)
|
||||||
sprintf(buf, "backwards");
|
sprintf(buf, "backwards");
|
||||||
else
|
else
|
||||||
sprintf(buf, "forwards");
|
sprintf(buf, "forwards");
|
||||||
|
|
||||||
Make_debug_text_block(buf, 0, 340);
|
makeDebugTextBlock(buf, 0, 340);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(buf, "res: %d", textNumber / SIZE);
|
sprintf(buf, "res: %d", _textNumber / SIZE);
|
||||||
Make_debug_text_block(buf, 0, 355);
|
makeDebugTextBlock(buf, 0, 355);
|
||||||
|
|
||||||
sprintf(buf, "pos: %d", textNumber & 0xffff);
|
sprintf(buf, "pos: %d", _textNumber & 0xffff);
|
||||||
Make_debug_text_block(buf, 0, 370);
|
makeDebugTextBlock(buf, 0, 370);
|
||||||
|
|
||||||
sprintf(buf, "TEXT: %d", officialTextNumber);
|
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) {
|
if (SYSTEM_TESTING_ANIMS) {
|
||||||
sprintf(buf, "trying resource %d", 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
|
// general debug info
|
||||||
|
|
||||||
if (displayDebugText) {
|
if (_displayDebugText) {
|
||||||
/*
|
/*
|
||||||
// CD in use
|
// CD in use
|
||||||
sprintf (buf, "CD-%d", currentCD);
|
sprintf(buf, "CD-%d", currentCD);
|
||||||
Make_debug_text_block(buf, 0, 0);
|
makeDebugTextBlock(buf, 0, 0);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// mouse coords & object pointed to
|
// mouse coords & object pointed to
|
||||||
|
@ -226,7 +183,7 @@ void Build_debug_text(void) {
|
||||||
sprintf(buf, "last click at %d,%d (---)",
|
sprintf(buf, "last click at %d,%d (---)",
|
||||||
MOUSE_X, MOUSE_Y);
|
MOUSE_X, MOUSE_Y);
|
||||||
|
|
||||||
Make_debug_text_block(buf, 0, 15);
|
makeDebugTextBlock(buf, 0, 15);
|
||||||
|
|
||||||
if (mouse_touching)
|
if (mouse_touching)
|
||||||
sprintf(buf, "mouse %d,%d (id %d: %s)",
|
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->_mouseX + this_screen.scroll_offset_x,
|
||||||
g_display->_mouseY + this_screen.scroll_offset_y);
|
g_display->_mouseY + this_screen.scroll_offset_y);
|
||||||
|
|
||||||
Make_debug_text_block(buf, 0, 30);
|
makeDebugTextBlock(buf, 0, 30);
|
||||||
|
|
||||||
// player coords & graphic info
|
// player coords & graphic info
|
||||||
// if player objct has a graphic
|
// if player objct has a graphic
|
||||||
|
|
||||||
if (playerGraphic.anim_resource)
|
if (_playerGraphic.anim_resource)
|
||||||
sprintf(buf, "player %d,%d %s (%d) #%d/%d",
|
sprintf(buf, "player %d,%d %s (%d) #%d/%d",
|
||||||
this_screen.player_feet_x,
|
this_screen.player_feet_x,
|
||||||
this_screen.player_feet_y,
|
this_screen.player_feet_y,
|
||||||
FetchObjectName(playerGraphic.anim_resource),
|
FetchObjectName(_playerGraphic.anim_resource),
|
||||||
playerGraphic.anim_resource,
|
_playerGraphic.anim_resource,
|
||||||
playerGraphic.anim_pc,
|
_playerGraphic.anim_pc,
|
||||||
player_graphic_no_frames);
|
_playerGraphicNoFrames);
|
||||||
else
|
else
|
||||||
sprintf(buf, "player %d,%d --- %d",
|
sprintf(buf, "player %d,%d --- %d",
|
||||||
this_screen.player_feet_x,
|
this_screen.player_feet_x,
|
||||||
this_screen.player_feet_y,
|
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
|
// frames-per-second counter
|
||||||
|
|
||||||
sprintf(buf, "fps %d", g_sword2->_fps);
|
sprintf(buf, "fps %d", g_sword2->_fps);
|
||||||
Make_debug_text_block(buf, 440, 0);
|
makeDebugTextBlock(buf, 440, 0);
|
||||||
|
|
||||||
// location number
|
// location number
|
||||||
|
|
||||||
sprintf(buf, "location=%d", LOCATION);
|
sprintf(buf, "location=%d", LOCATION);
|
||||||
Make_debug_text_block(buf, 440, 15);
|
makeDebugTextBlock(buf, 440, 15);
|
||||||
|
|
||||||
// "result" variable
|
// "result" variable
|
||||||
|
|
||||||
sprintf(buf, "result=%d", RESULT);
|
sprintf(buf, "result=%d", RESULT);
|
||||||
Make_debug_text_block(buf, 440, 30);
|
makeDebugTextBlock(buf, 440, 30);
|
||||||
|
|
||||||
// no. of events in event list
|
// no. of events in event list
|
||||||
|
|
||||||
sprintf(buf, "events=%d", CountEvents());
|
sprintf(buf, "events=%d", g_sword2->countEvents());
|
||||||
Make_debug_text_block(buf, 440, 45);
|
makeDebugTextBlock(buf, 440, 45);
|
||||||
|
|
||||||
// sprite list usage
|
// sprite list usage
|
||||||
|
|
||||||
sprintf(buf, "bgp0: %d/%d", g_sword2->_curBgp0, MAX_bgp0_sprites);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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
|
// largest layer & sprite
|
||||||
|
|
||||||
// NB. Strings already constructed in Build_display.cpp
|
// NB. Strings already constructed in Build_display.cpp
|
||||||
Make_debug_text_block(g_sword2->_largestLayerInfo, 0, 60);
|
makeDebugTextBlock(g_sword2->_largestLayerInfo, 0, 60);
|
||||||
Make_debug_text_block(g_sword2->_largestSpriteInfo, 0, 75);
|
makeDebugTextBlock(g_sword2->_largestSpriteInfo, 0, 75);
|
||||||
|
|
||||||
// "waiting for person" indicator - set form fnTheyDo and
|
// "waiting for person" indicator - set form fnTheyDo and
|
||||||
// fnTheyDoWeWait
|
// fnTheyDoWeWait
|
||||||
|
@ -316,7 +273,7 @@ void Build_debug_text(void) {
|
||||||
sprintf(buf, "script waiting for %s (%d)",
|
sprintf(buf, "script waiting for %s (%d)",
|
||||||
FetchObjectName(speechScriptWaiting),
|
FetchObjectName(speechScriptWaiting),
|
||||||
speechScriptWaiting);
|
speechScriptWaiting);
|
||||||
Make_debug_text_block(buf, 0, 90);
|
makeDebugTextBlock(buf, 0, 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
// variable watch display
|
// variable watch display
|
||||||
|
@ -327,14 +284,14 @@ void Build_debug_text(void) {
|
||||||
varTable = (int32 *) (res_man.open(1) + sizeof(_standardHeader));
|
varTable = (int32 *) (res_man.open(1) + sizeof(_standardHeader));
|
||||||
|
|
||||||
for (showVarNo = 0; showVarNo < MAX_SHOWVARS; showVarNo++) {
|
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
|
// if non-zero ie. cannot watch 'id' but not needed
|
||||||
// anyway because it changes throughout the logic loop
|
// anyway because it changes throughout the logic loop
|
||||||
|
|
||||||
if (varNo) {
|
if (varNo) {
|
||||||
sprintf(buf, "var(%d) = %d", varNo, varTable[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
|
showVarPos += 15; // next line down
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,40 +302,40 @@ void Build_debug_text(void) {
|
||||||
// sprite blocks above!
|
// sprite blocks above!
|
||||||
|
|
||||||
memory.memoryString(buf);
|
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
|
// walk-grid
|
||||||
|
|
||||||
if (displayWalkGrid)
|
if (_displayWalkGrid)
|
||||||
router.plotWalkGrid();
|
router.plotWalkGrid();
|
||||||
|
|
||||||
// player feet coord marker
|
// player feet coord marker
|
||||||
|
|
||||||
if (displayPlayerMarker)
|
if (_displayPlayerMarker)
|
||||||
Plot_cross_hair(this_screen.player_feet_x, this_screen.player_feet_y, 215);
|
plotCrossHair(this_screen.player_feet_x, this_screen.player_feet_y, 215);
|
||||||
|
|
||||||
// mouse marker & coords
|
// mouse marker & coords
|
||||||
|
|
||||||
if (displayMouseMarker)
|
if (_displayMouseMarker)
|
||||||
Plot_cross_hair(g_display->_mouseX + this_screen.scroll_offset_x, g_display->_mouseY + this_screen.scroll_offset_y, 215);
|
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
|
// mouse area rectangle / sprite box rectangle when testing anims
|
||||||
|
|
||||||
if (SYSTEM_TESTING_ANIMS) {
|
if (SYSTEM_TESTING_ANIMS) {
|
||||||
// draw box around current frame
|
// draw box around current frame
|
||||||
DrawRect(rect_x1, rect_y1, rect_x2, rect_y2, 184);
|
drawRect(_rectX1, _rectY1, _rectX2, _rectY2, 184);
|
||||||
} else if (draggingRectangle) {
|
} else if (_draggingRectangle) {
|
||||||
// defining a mouse area the easy way, by creating a box
|
// defining a mouse area the easy way, by creating a box
|
||||||
// on-screen
|
// on-screen
|
||||||
if (rectFlicker)
|
if (_rectFlicker)
|
||||||
DrawRect(rect_x1, rect_y1, rect_x2, rect_y2, 184);
|
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->plotPoint(x, y, pen); // driver function
|
||||||
|
|
||||||
g_display->drawLine(x - 2, y, x - 5, 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);
|
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, y1, x2, y1, pen); // top edge
|
||||||
g_display->drawLine(x1, y2, x2, y2, pen); // bottom edge
|
g_display->drawLine(x1, y2, x2, y2, pen); // bottom edge
|
||||||
g_display->drawLine(x1, y1, x1, y2, pen); // left edge
|
g_display->drawLine(x1, y1, x1, y2, pen); // left edge
|
||||||
g_display->drawLine(x2, y1, x2, y2, pen); // right 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.
|
// prints general stuff about the screen, etc.
|
||||||
|
|
||||||
if (this_screen.background_layer_id) {
|
if (this_screen.background_layer_id) {
|
||||||
|
|
|
@ -20,46 +20,12 @@
|
||||||
#ifndef D_DEBUG
|
#ifndef D_DEBUG
|
||||||
#define D_DEBUG
|
#define D_DEBUG
|
||||||
|
|
||||||
#include "sword2/object.h"
|
|
||||||
|
|
||||||
// FIXME: I don't know how large this constant used to be
|
// FIXME: I don't know how large this constant used to be
|
||||||
#define MAX_DEBUG_TEXT_BLOCKS 50
|
#define MAX_DEBUG_TEXT_BLOCKS 50
|
||||||
|
|
||||||
namespace Sword2 {
|
|
||||||
|
|
||||||
extern bool displayDebugText;
|
|
||||||
extern bool displayWalkGrid;
|
|
||||||
extern bool displayMouseMarker;
|
|
||||||
extern bool displayPlayerMarker;
|
|
||||||
extern bool displayTime;
|
|
||||||
extern bool displayTextNumbers;
|
|
||||||
extern bool definingRectangles;
|
|
||||||
extern uint8 draggingRectangle;
|
|
||||||
extern int32 startTime;
|
|
||||||
extern int32 gameCycle;
|
|
||||||
extern uint8 renderSkip;
|
|
||||||
|
|
||||||
extern int16 rect_x1;
|
|
||||||
extern int16 rect_y1;
|
|
||||||
extern int16 rect_x2;
|
|
||||||
extern int16 rect_y2;
|
|
||||||
|
|
||||||
extern bool testingSnR;
|
|
||||||
|
|
||||||
extern int32 textNumber;
|
|
||||||
|
|
||||||
extern Object_graphic playerGraphic;
|
|
||||||
extern uint32 player_graphic_no_frames;
|
|
||||||
|
|
||||||
#define MAX_SHOWVARS 15
|
#define MAX_SHOWVARS 15
|
||||||
|
|
||||||
extern int32 showVar[MAX_SHOWVARS];
|
namespace Sword2 {
|
||||||
|
|
||||||
void Build_debug_text(void);
|
|
||||||
void Draw_debug_graphics(void);
|
|
||||||
|
|
||||||
void Print_current_info(void);
|
|
||||||
|
|
||||||
} // End of namespace Sword2
|
} // End of namespace Sword2
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,32 +25,99 @@
|
||||||
#include "sword2/events.h"
|
#include "sword2/events.h"
|
||||||
#include "sword2/interpreter.h"
|
#include "sword2/interpreter.h"
|
||||||
#include "sword2/logic.h"
|
#include "sword2/logic.h"
|
||||||
#include "sword2/memory.h"
|
|
||||||
#include "sword2/object.h"
|
#include "sword2/object.h"
|
||||||
#include "sword2/sync.h"
|
|
||||||
|
|
||||||
namespace Sword2 {
|
namespace Sword2 {
|
||||||
|
|
||||||
_event_unit event_list[MAX_events];
|
void Sword2Engine::initEventSystem(void) {
|
||||||
|
memset(_eventList, 0, sizeof(_eventList));
|
||||||
void Init_event_system(void) {
|
|
||||||
for (int i = 0; i < MAX_events; i++) {
|
|
||||||
//denotes free slot
|
|
||||||
event_list[i].id = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 CountEvents(void) {
|
uint32 Sword2Engine::countEvents(void) {
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
|
|
||||||
for (int i = 0; i < MAX_events; i++) {
|
for (int i = 0; i < MAX_events; i++) {
|
||||||
if (event_list[i].id)
|
if (_eventList[i].id)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sword2Engine::sendEvent(uint32 id, uint32 interact_id) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_events; i++) {
|
||||||
|
if (_eventList[i].id == id)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!_eventList[i].id)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(i < MAX_events);
|
||||||
|
|
||||||
|
// found that slot
|
||||||
|
|
||||||
|
// id of person to stop
|
||||||
|
_eventList[i].id = id;
|
||||||
|
|
||||||
|
// full script id
|
||||||
|
_eventList[i].interact_id = interact_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sword2Engine::setPlayerActionEvent(uint32 id, uint32 interact_id) {
|
||||||
|
// Full script id of action script number 2
|
||||||
|
sendEvent(id, (interact_id << 16) | 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Sword2Engine::checkEventWaiting(void) {
|
||||||
|
for (int i = 0; i < MAX_events; i++) {
|
||||||
|
if (_eventList[i].id == ID)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sword2Engine::startEvent(void) {
|
||||||
|
// call this from stuff like fnWalk
|
||||||
|
// you must follow with a return IR_TERMINATE
|
||||||
|
|
||||||
|
for (int i = 0; i < MAX_events; i++) {
|
||||||
|
if (_eventList[i].id == ID) {
|
||||||
|
// run 3rd script of target object on level 1
|
||||||
|
g_logic.logicOne(_eventList[i].interact_id);
|
||||||
|
|
||||||
|
// clear the slot
|
||||||
|
_eventList[i].id = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// oh dear - stop the system
|
||||||
|
error("Start_event can't find event for id %d", ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sword2Engine::clearEvent(uint32 id) {
|
||||||
|
for (int i = 0; i < MAX_events; i++) {
|
||||||
|
if (_eventList[i].id == id) {
|
||||||
|
// clear the slot
|
||||||
|
_eventList[i].id = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sword2Engine::killAllIdsEvents(uint32 id) {
|
||||||
|
for (int i = 0; i < MAX_events; i++) {
|
||||||
|
if (_eventList[i].id == id) {
|
||||||
|
// clear the slot
|
||||||
|
_eventList[i].id = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32 Logic::fnRequestSpeech(int32 *params) {
|
int32 Logic::fnRequestSpeech(int32 *params) {
|
||||||
// change current script - must be followed by a TERMINATE script
|
// change current script - must be followed by a TERMINATE script
|
||||||
// directive
|
// directive
|
||||||
|
@ -58,53 +125,11 @@ int32 Logic::fnRequestSpeech(int32 *params) {
|
||||||
// params: 0 id of target to catch the event and startup speech
|
// params: 0 id of target to catch the event and startup speech
|
||||||
// servicing
|
// servicing
|
||||||
|
|
||||||
int i;
|
// Full script id to interact with - megas run their own 7th script
|
||||||
|
g_sword2->sendEvent(params[0], (params[0] << 16) | 6);
|
||||||
for (i = 0; i < MAX_events; i++) {
|
|
||||||
if (event_list[i].id == (uint32) params[0])
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!event_list[i].id)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == MAX_events)
|
|
||||||
error("fnSetEvent out of event slots");
|
|
||||||
|
|
||||||
// found that slot
|
|
||||||
|
|
||||||
// id of person to stop
|
|
||||||
event_list[i].id = params[0];
|
|
||||||
|
|
||||||
// full script id to interact with - megas run their own 7th script
|
|
||||||
event_list[i].interact_id = (params[0] * 65536) + 6;
|
|
||||||
|
|
||||||
return IR_CONT;
|
return IR_CONT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set_player_action_event(uint32 id, uint32 interact_id) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_events; i++) {
|
|
||||||
if (event_list[i].id == id)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!event_list[i].id)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == MAX_events)
|
|
||||||
error("Set_event out of event slots");
|
|
||||||
|
|
||||||
// found that slot
|
|
||||||
|
|
||||||
// id of person to stop
|
|
||||||
event_list[i].id = id;
|
|
||||||
|
|
||||||
// full script id of action script number 2
|
|
||||||
event_list[i].interact_id = (interact_id * 65536) + 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 Logic::fnSetPlayerActionEvent(int32 *params) {
|
int32 Logic::fnSetPlayerActionEvent(int32 *params) {
|
||||||
// we want to intercept the player character and have him interact
|
// we want to intercept the player character and have him interact
|
||||||
// with an object - from script this code is the same as the mouse
|
// with an object - from script this code is the same as the mouse
|
||||||
|
@ -115,29 +140,7 @@ int32 Logic::fnSetPlayerActionEvent(int32 *params) {
|
||||||
|
|
||||||
// params: 0 id to interact with
|
// params: 0 id to interact with
|
||||||
|
|
||||||
// search for an existing event or a slot
|
g_sword2->setPlayerActionEvent(CUR_PLAYER_ID, params[0]);
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_events; i++) {
|
|
||||||
if (event_list[i].id == CUR_PLAYER_ID)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!event_list[i].id)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == MAX_events)
|
|
||||||
error("Set_event out of event slots");
|
|
||||||
|
|
||||||
// found that slot
|
|
||||||
|
|
||||||
// id of person to stop
|
|
||||||
event_list[i].id = CUR_PLAYER_ID;
|
|
||||||
|
|
||||||
// full script id of action script number 2
|
|
||||||
event_list[i].interact_id = (params[0] * 65536) + 2;
|
|
||||||
|
|
||||||
return IR_CONT;
|
return IR_CONT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,29 +151,7 @@ int32 Logic::fnSendEvent(int32 *params) {
|
||||||
// params: 0 id to recieve event
|
// params: 0 id to recieve event
|
||||||
// 1 script to run
|
// 1 script to run
|
||||||
|
|
||||||
// search for an existing event or a slot
|
g_sword2->sendEvent(params[0], params[1]);
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_events; i++) {
|
|
||||||
if (event_list[i].id == (uint32) params[0])
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!event_list[i].id)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == MAX_events)
|
|
||||||
error("fnSendEvent out of event slots");
|
|
||||||
|
|
||||||
// found that slot
|
|
||||||
|
|
||||||
// id of person to stop
|
|
||||||
event_list[i].id = params[0];
|
|
||||||
|
|
||||||
//full script id
|
|
||||||
event_list[i].interact_id = params[1];
|
|
||||||
|
|
||||||
return IR_CONT;
|
return IR_CONT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,14 +160,10 @@ int32 Logic::fnCheckEventWaiting(int32 *params) {
|
||||||
|
|
||||||
// params: none
|
// params: none
|
||||||
|
|
||||||
RESULT = 0;
|
if (g_sword2->checkEventWaiting())
|
||||||
|
RESULT = 1;
|
||||||
for (int i = 0; i < MAX_events; i++) {
|
else
|
||||||
if (event_list[i].id == ID) {
|
RESULT = 0;
|
||||||
RESULT = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return IR_CONT;
|
return IR_CONT;
|
||||||
}
|
}
|
||||||
|
@ -197,18 +174,11 @@ int32 Logic::fnCheckEventWaiting(int32 *params) {
|
||||||
int32 Logic::fnCheckForEvent(int32 *params) {
|
int32 Logic::fnCheckForEvent(int32 *params) {
|
||||||
// params: none
|
// params: none
|
||||||
|
|
||||||
for (int i = 0; i < MAX_events; i++) {
|
if (!g_sword2->checkEventWaiting())
|
||||||
if (event_list[i].id == ID) {
|
return IR_CONT;
|
||||||
// start the event
|
|
||||||
// run 3rd script of target object on level 1
|
|
||||||
logicOne(event_list[i].interact_id);
|
|
||||||
// clear the event slot
|
|
||||||
event_list[i].id = 0;
|
|
||||||
return IR_TERMINATE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return IR_CONT;
|
g_sword2->startEvent();
|
||||||
|
return IR_TERMINATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// combination of fnPause and fnCheckForEvent
|
// combination of fnPause and fnCheckForEvent
|
||||||
|
@ -220,23 +190,17 @@ int32 Logic::fnPauseForEvent(int32 *params) {
|
||||||
// params: 0 pointer to object's logic structure
|
// params: 0 pointer to object's logic structure
|
||||||
// 1 number of game-cycles to pause
|
// 1 number of game-cycles to pause
|
||||||
|
|
||||||
Object_logic *ob_logic = (Object_logic *)params[0];
|
Object_logic *ob_logic = (Object_logic *) params[0];
|
||||||
|
|
||||||
// first, check for an event
|
// first, check for an event
|
||||||
|
|
||||||
for (int i = 0; i < MAX_events; i++) {
|
if (g_sword2->checkEventWaiting()) {
|
||||||
if (event_list[i].id == ID) {
|
// reset the 'looping' flag
|
||||||
// reset the 'looping' flag
|
ob_logic->looping = 0;
|
||||||
ob_logic->looping = 0;
|
|
||||||
|
|
||||||
// start the event
|
// start the event - run 3rd script of target object on level 1
|
||||||
// run 3rd script of target object on level 1
|
g_sword2->startEvent();
|
||||||
logicOne(event_list[i].interact_id);
|
return IR_TERMINATE;
|
||||||
|
|
||||||
// clear the event slot
|
|
||||||
event_list[i].id = 0;
|
|
||||||
return IR_TERMINATE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// no event, so do the fnPause bit
|
// no event, so do the fnPause bit
|
||||||
|
@ -264,73 +228,18 @@ int32 Logic::fnPauseForEvent(int32 *params) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Check_event_waiting(void) {
|
|
||||||
for (int i = 0; i < MAX_events; i++) {
|
|
||||||
if (event_list[i].id == ID)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 Logic::fnClearEvent(int32 *params) {
|
int32 Logic::fnClearEvent(int32 *params) {
|
||||||
// params: none
|
// params: none
|
||||||
|
|
||||||
for (int i = 0; i < MAX_events; i++) {
|
g_sword2->clearEvent(ID);
|
||||||
if (event_list[i].id == ID) {
|
|
||||||
//clear the slot
|
|
||||||
event_list[i].id = 0;
|
|
||||||
return IR_CONT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return IR_CONT;
|
return IR_CONT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start_event(void) {
|
|
||||||
// call this from stuff like fnWalk
|
|
||||||
// you must follow with a return IR_TERMINATE
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_events; i++) {
|
|
||||||
if (event_list[i].id == ID) {
|
|
||||||
// run 3rd script of target object on level 1
|
|
||||||
g_logic.logicOne(event_list[i].interact_id);
|
|
||||||
|
|
||||||
//clear the slot
|
|
||||||
event_list[i].id = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// oh dear - stop the system
|
|
||||||
error("Start_event can't find event for id %d", ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 Logic::fnStartEvent(int32 *params) {
|
int32 Logic::fnStartEvent(int32 *params) {
|
||||||
// params: none
|
// params: none
|
||||||
|
|
||||||
for (int i = 0; i < MAX_events; i++)
|
g_sword2->startEvent();
|
||||||
if (event_list[i].id == ID) {
|
return IR_TERMINATE;
|
||||||
// run 3rd script of target object on level 1
|
|
||||||
logicOne(event_list[i].interact_id);
|
|
||||||
|
|
||||||
// clear the slot
|
|
||||||
event_list[i].id = 0;
|
|
||||||
return IR_TERMINATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// oh dear - stop the system
|
|
||||||
error("fnStartEvent can't find event for id %d", ID);
|
|
||||||
return 0; // never called - but lets stop them bloody errors
|
|
||||||
}
|
|
||||||
|
|
||||||
void Kill_all_ids_events(uint32 id) {
|
|
||||||
for (int i = 0; i < MAX_events; i++) {
|
|
||||||
if (event_list[i].id == id) {
|
|
||||||
// clear the slot
|
|
||||||
event_list[i].id = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace Sword2
|
} // End of namespace Sword2
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#ifndef _EVENTS
|
#ifndef _EVENTS
|
||||||
#define _EVENTS
|
#define _EVENTS
|
||||||
|
|
||||||
#include "sword2/object.h"
|
#define MAX_events 10
|
||||||
|
|
||||||
namespace Sword2 {
|
namespace Sword2 {
|
||||||
|
|
||||||
|
@ -29,18 +29,6 @@ struct _event_unit {
|
||||||
uint32 interact_id;
|
uint32 interact_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_events 10
|
|
||||||
|
|
||||||
extern _event_unit event_list[MAX_events];
|
|
||||||
|
|
||||||
void Init_event_system(void);
|
|
||||||
void Set_player_action_event(uint32 id, uint32 interact_id);
|
|
||||||
void Start_event(void);
|
|
||||||
bool Check_event_waiting(void);
|
|
||||||
void Kill_all_ids_events(uint32 id);
|
|
||||||
|
|
||||||
uint32 CountEvents(void);
|
|
||||||
|
|
||||||
} // End of namespace Sword2
|
} // End of namespace Sword2
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,9 +35,6 @@
|
||||||
|
|
||||||
namespace Sword2 {
|
namespace Sword2 {
|
||||||
|
|
||||||
Object_graphic engine_graph; // global for engine
|
|
||||||
Object_mega engine_mega; // global for engine
|
|
||||||
|
|
||||||
int32 Logic::fnTestFunction(int32 *params) {
|
int32 Logic::fnTestFunction(int32 *params) {
|
||||||
// params: 0 address of a flag
|
// params: 0 address of a flag
|
||||||
return IR_CONT;
|
return IR_CONT;
|
||||||
|
@ -85,7 +82,7 @@ int32 Logic::fnInteract(int32 *params) {
|
||||||
PLAYER_ACTION = 0;
|
PLAYER_ACTION = 0;
|
||||||
|
|
||||||
// 3rd script of clicked on id
|
// 3rd script of clicked on id
|
||||||
logicUp((params[0] * 65536) + 2);
|
logicUp((params[0] < 16) | 2);
|
||||||
|
|
||||||
// out, up and around again - pc is saved for current level to be
|
// out, up and around again - pc is saved for current level to be
|
||||||
// returned to
|
// returned to
|
||||||
|
@ -207,7 +204,7 @@ int32 Logic::fnPassGraph(int32 *params) {
|
||||||
|
|
||||||
// params: 0 pointer to a graphic structure (might not need this?)
|
// params: 0 pointer to a graphic structure (might not need this?)
|
||||||
|
|
||||||
memcpy(&engine_graph, (uint8 *) params[0], sizeof(Object_graphic));
|
memcpy(&g_sword2->_engineGraph, (uint8 *) params[0], sizeof(Object_graphic));
|
||||||
|
|
||||||
// makes no odds
|
// makes no odds
|
||||||
return IR_CONT;
|
return IR_CONT;
|
||||||
|
@ -223,7 +220,7 @@ int32 Logic::fnPassMega(int32 *params) {
|
||||||
|
|
||||||
// params: 0 pointer to a mega structure
|
// params: 0 pointer to a mega structure
|
||||||
|
|
||||||
memcpy(&engine_mega, (uint8 *) params[0], sizeof(Object_mega));
|
memcpy(&g_sword2->_engineMega, (uint8 *) params[0], sizeof(Object_mega));
|
||||||
|
|
||||||
// makes no odds
|
// makes no odds
|
||||||
return IR_CONT;
|
return IR_CONT;
|
||||||
|
@ -246,17 +243,19 @@ int32 Logic::fnSetValue(int32 *params) {
|
||||||
return IR_CONT;
|
return IR_CONT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _SWORD2_DEBUG
|
||||||
#define BLACK 0
|
#define BLACK 0
|
||||||
#define WHITE 1
|
#define WHITE 1
|
||||||
#define RED 2
|
#define RED 2
|
||||||
#define GREEN 3
|
#define GREEN 3
|
||||||
#define BLUE 4
|
#define BLUE 4
|
||||||
|
|
||||||
uint8 black[4] = { 0, 0, 0, 0 };
|
static uint8 black[4] = { 0, 0, 0, 0 };
|
||||||
uint8 white[4] = { 255, 255, 255, 0 };
|
static uint8 white[4] = { 255, 255, 255, 0 };
|
||||||
uint8 red[4] = { 255, 0, 0, 0 };
|
static uint8 red[4] = { 255, 0, 0, 0 };
|
||||||
uint8 green[4] = { 0, 255, 0, 0 };
|
static uint8 green[4] = { 0, 255, 0, 0 };
|
||||||
uint8 blue[4] = { 0, 0, 255, 0 };
|
static uint8 blue[4] = { 0, 0, 255, 0 };
|
||||||
|
#endif
|
||||||
|
|
||||||
int32 Logic::fnFlash(int32 *params) {
|
int32 Logic::fnFlash(int32 *params) {
|
||||||
// flash colour 0 (ie. border) - useful during script development
|
// flash colour 0 (ie. border) - useful during script development
|
||||||
|
|
|
@ -20,13 +20,8 @@
|
||||||
#ifndef _FUNCTION
|
#ifndef _FUNCTION
|
||||||
#define _FUNCTION
|
#define _FUNCTION
|
||||||
|
|
||||||
#include "sword2/object.h"
|
|
||||||
|
|
||||||
namespace Sword2 {
|
namespace Sword2 {
|
||||||
|
|
||||||
extern Object_graphic engine_graph; // global for engine
|
|
||||||
extern Object_mega engine_mega; // global for engine
|
|
||||||
|
|
||||||
} // End of namespace Sword2
|
} // End of namespace Sword2
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,24 +28,14 @@
|
||||||
|
|
||||||
namespace Sword2 {
|
namespace Sword2 {
|
||||||
|
|
||||||
// tempory list
|
|
||||||
menu_object temp_list[TOTAL_engine_pockets];
|
|
||||||
uint32 total_temp = 0;
|
|
||||||
|
|
||||||
menu_object master_menu_list[TOTAL_engine_pockets];
|
|
||||||
uint32 total_masters=0;
|
|
||||||
|
|
||||||
int32 Logic::fnAddMenuObject(int32 *params) {
|
int32 Logic::fnAddMenuObject(int32 *params) {
|
||||||
// params: 0 pointer to a menu_object structure to copy down
|
// params: 0 pointer to a menu_object structure to copy down
|
||||||
|
|
||||||
#ifdef _SWORD2_DEBUG
|
assert(g_sword2->_totalTemp < TOTAL_engine_pockets);
|
||||||
if (total_temp == TOTAL_engine_pockets)
|
|
||||||
error("TOTAL_engine_pockets exceeded!");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// copy the structure to our in-the-engine list
|
// copy the structure to our in-the-engine list
|
||||||
memcpy(&temp_list[total_temp], (uint8 *) params[0], sizeof(menu_object));
|
memcpy(&g_sword2->_tempList[g_sword2->_totalTemp], (uint8 *) params[0], sizeof(menu_object));
|
||||||
total_temp++;
|
g_sword2->_totalTemp++;
|
||||||
|
|
||||||
// script continue
|
// script continue
|
||||||
return IR_CONT;
|
return IR_CONT;
|
||||||
|
@ -65,14 +55,14 @@ int32 Logic::fnRefreshInventory(int32 *params) {
|
||||||
// so that the icon in 'object_held' is coloured while the rest are
|
// so that the icon in 'object_held' is coloured while the rest are
|
||||||
// grey
|
// grey
|
||||||
examining_menu_icon = 1;
|
examining_menu_icon = 1;
|
||||||
Build_menu();
|
g_sword2->buildMenu();
|
||||||
examining_menu_icon = 0;
|
examining_menu_icon = 0;
|
||||||
|
|
||||||
// script continue
|
// script continue
|
||||||
return IR_CONT;
|
return IR_CONT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Build_menu(void) {
|
void Sword2Engine::buildMenu(void) {
|
||||||
// create and start the inventory menu - NOW AT THE BOTTOM OF THE
|
// create and start the inventory menu - NOW AT THE BOTTOM OF THE
|
||||||
// SCREEN!
|
// SCREEN!
|
||||||
|
|
||||||
|
@ -84,15 +74,15 @@ void Build_menu(void) {
|
||||||
uint32 res;
|
uint32 res;
|
||||||
|
|
||||||
// reset temp list which will be totally rebuilt
|
// reset temp list which will be totally rebuilt
|
||||||
total_temp = 0;
|
_totalTemp = 0;
|
||||||
|
|
||||||
debug(5, "build top menu %d", total_masters);
|
debug(5, "build top menu %d", _totalMasters);
|
||||||
|
|
||||||
// clear the temp list before building a new temp list in-case list
|
// clear the temp list before building a new temp list in-case list
|
||||||
// gets smaller. check each master
|
// gets smaller. check each master
|
||||||
|
|
||||||
for (j = 0; j < TOTAL_engine_pockets; j++)
|
for (j = 0; j < TOTAL_engine_pockets; j++)
|
||||||
temp_list[j].icon_resource = 0;
|
_tempList[j].icon_resource = 0;
|
||||||
|
|
||||||
// Call menu builder script which will register all carried menu
|
// Call menu builder script which will register all carried menu
|
||||||
// objects. Run the 'build_menu' script in the 'menu_master' object
|
// objects. Run the 'build_menu' script in the 'menu_master' object
|
||||||
|
@ -104,23 +94,23 @@ void Build_menu(void) {
|
||||||
// Compare new with old. Anything in master thats not in new gets
|
// Compare new with old. Anything in master thats not in new gets
|
||||||
// removed from master - if found in new too, remove from temp
|
// removed from master - if found in new too, remove from temp
|
||||||
|
|
||||||
if (total_masters) {
|
if (_totalMasters) {
|
||||||
// check each master
|
// check each master
|
||||||
|
|
||||||
for (j = 0; j < total_masters; j++) {
|
for (j = 0; j < _totalMasters; j++) {
|
||||||
for (k = 0; k < TOTAL_engine_pockets; k++) {
|
for (k = 0; k < TOTAL_engine_pockets; k++) {
|
||||||
res = 0;
|
res = 0;
|
||||||
// if master is in temp
|
// if master is in temp
|
||||||
if (master_menu_list[j].icon_resource == temp_list[k].icon_resource) {
|
if (_masterMenuList[j].icon_resource == _tempList[k].icon_resource) {
|
||||||
// kill it in the temp
|
// kill it in the temp
|
||||||
temp_list[k].icon_resource = 0;
|
_tempList[k].icon_resource = 0;
|
||||||
res = 1;
|
res = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!res) {
|
if (!res) {
|
||||||
// otherwise not in temp so kill in main
|
// otherwise not in temp so kill in main
|
||||||
master_menu_list[j].icon_resource = 0;
|
_masterMenuList[j].icon_resource = 0;
|
||||||
debug(5, "Killed menu %d", j);
|
debug(5, "Killed menu %d", j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,20 +118,20 @@ void Build_menu(void) {
|
||||||
|
|
||||||
// merge master downwards
|
// merge master downwards
|
||||||
|
|
||||||
total_masters = 0;
|
_totalMasters = 0;
|
||||||
|
|
||||||
//check each master slot
|
//check each master slot
|
||||||
|
|
||||||
for (j = 0; j < TOTAL_engine_pockets; j++) {
|
for (j = 0; j < TOTAL_engine_pockets; j++) {
|
||||||
// not current end - meaning out over the end so move down
|
// not current end - meaning out over the end so move down
|
||||||
if (master_menu_list[j].icon_resource && j != total_masters) {
|
if (_masterMenuList[j].icon_resource && j != _totalMasters) {
|
||||||
memcpy(&master_menu_list[total_masters++], &master_menu_list[j], sizeof(menu_object));
|
memcpy(&_masterMenuList[_totalMasters++], &_masterMenuList[j], sizeof(menu_object));
|
||||||
|
|
||||||
// moved down now so kill here
|
// moved down now so kill here
|
||||||
master_menu_list[j].icon_resource = 0;
|
_masterMenuList[j].icon_resource = 0;
|
||||||
} else if (master_menu_list[j].icon_resource) {
|
} else if (_masterMenuList[j].icon_resource) {
|
||||||
// skip full slots
|
// skip full slots
|
||||||
total_masters++;
|
_totalMasters++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,18 +141,18 @@ void Build_menu(void) {
|
||||||
// check each master slot
|
// check each master slot
|
||||||
|
|
||||||
for (j = 0; j < TOTAL_engine_pockets; j++) {
|
for (j = 0; j < TOTAL_engine_pockets; j++) {
|
||||||
if (temp_list[j].icon_resource) {
|
if (_tempList[j].icon_resource) {
|
||||||
// here's a new temp
|
// here's a new temp
|
||||||
memcpy(&master_menu_list[total_masters++], &temp_list[j], sizeof(menu_object));
|
memcpy(&_masterMenuList[_totalMasters++], &_tempList[j], sizeof(menu_object));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// init top menu from master list
|
// init top menu from master list
|
||||||
|
|
||||||
for (j = 0; j < 15; j++) {
|
for (j = 0; j < 15; j++) {
|
||||||
if (master_menu_list[j].icon_resource) {
|
if (_masterMenuList[j].icon_resource) {
|
||||||
// 'res' is now the resource id of the icon
|
// 'res' is now the resource id of the icon
|
||||||
res = master_menu_list[j].icon_resource;
|
res = _masterMenuList[j].icon_resource;
|
||||||
|
|
||||||
if (examining_menu_icon) {
|
if (examining_menu_icon) {
|
||||||
// WHEN AN ICON HAS BEEN RIGHT-CLICKED FOR
|
// WHEN AN ICON HAS BEEN RIGHT-CLICKED FOR
|
||||||
|
@ -201,7 +191,7 @@ void Build_menu(void) {
|
||||||
icon_coloured = 1;
|
icon_coloured = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
icon = res_man.open(master_menu_list[j].icon_resource) + sizeof(_standardHeader);
|
icon = res_man.open(_masterMenuList[j].icon_resource) + sizeof(_standardHeader);
|
||||||
|
|
||||||
// The coloured icon is stored directly after the
|
// The coloured icon is stored directly after the
|
||||||
// greyed out one.
|
// greyed out one.
|
||||||
|
@ -221,7 +211,7 @@ void Build_menu(void) {
|
||||||
g_display->showMenu(RDMENU_BOTTOM);
|
g_display->showMenu(RDMENU_BOTTOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Build_system_menu(void) {
|
void Sword2Engine::buildSystemMenu(void) {
|
||||||
// start a fresh top system menu
|
// start a fresh top system menu
|
||||||
|
|
||||||
uint8 *icon;
|
uint8 *icon;
|
||||||
|
|
|
@ -22,24 +22,19 @@
|
||||||
|
|
||||||
#include "sword2/object.h"
|
#include "sword2/object.h"
|
||||||
|
|
||||||
namespace Sword2 {
|
|
||||||
|
|
||||||
#define MENU_MASTER_OBJECT 44
|
#define MENU_MASTER_OBJECT 44
|
||||||
#define TOTAL_subjects (375 - 256 + 1) // the speech subject bar
|
#define TOTAL_subjects (375 - 256 + 1) // the speech subject bar
|
||||||
#define TOTAL_engine_pockets (15 + 10) // +10 for overflow
|
#define TOTAL_engine_pockets (15 + 10) // +10 for overflow
|
||||||
|
|
||||||
|
namespace Sword2 {
|
||||||
|
|
||||||
// define these in a script and then register them with the system
|
// define these in a script and then register them with the system
|
||||||
|
|
||||||
typedef struct {
|
struct menu_object {
|
||||||
int32 icon_resource; // icon graphic graphic
|
int32 icon_resource; // icon graphic graphic
|
||||||
int32 luggage_resource; // luggage icon resource (for attaching to
|
int32 luggage_resource; // luggage icon resource (for attaching to
|
||||||
// mouse pointer)
|
// mouse pointer)
|
||||||
} menu_object;
|
};
|
||||||
|
|
||||||
extern menu_object master_menu_list[TOTAL_engine_pockets];
|
|
||||||
|
|
||||||
void Build_menu(void);
|
|
||||||
void Build_system_menu(void);
|
|
||||||
|
|
||||||
} // End of namespace Sword2
|
} // End of namespace Sword2
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#define _LOGIC
|
#define _LOGIC
|
||||||
|
|
||||||
#include "sword2/header.h"
|
#include "sword2/header.h"
|
||||||
|
#include "sword2/memory.h"
|
||||||
#include "sword2/driver/driver96.h"
|
#include "sword2/driver/driver96.h"
|
||||||
|
|
||||||
namespace Sword2 {
|
namespace Sword2 {
|
||||||
|
|
|
@ -133,7 +133,7 @@ void Mouse_engine(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Set_mouse(NORMAL_MOUSE_ID);
|
Set_mouse(NORMAL_MOUSE_ID);
|
||||||
Build_system_menu();
|
g_sword2->buildSystemMenu();
|
||||||
}
|
}
|
||||||
System_menu_mouse();
|
System_menu_mouse();
|
||||||
return;
|
return;
|
||||||
|
@ -265,7 +265,7 @@ void System_menu_mouse(void) {
|
||||||
g_display->hideMenu(RDMENU_TOP);
|
g_display->hideMenu(RDMENU_TOP);
|
||||||
} else {
|
} else {
|
||||||
Set_mouse(NORMAL_MOUSE_ID);
|
Set_mouse(NORMAL_MOUSE_ID);
|
||||||
Build_system_menu();
|
g_sword2->buildSystemMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear the screen & restore the location
|
// clear the screen & restore the location
|
||||||
|
@ -368,7 +368,7 @@ void Drag_mouse(void) {
|
||||||
|
|
||||||
CLICKED_ID = mouse_touching;
|
CLICKED_ID = mouse_touching;
|
||||||
|
|
||||||
Set_player_action_event(CUR_PLAYER_ID, mouse_touching);
|
g_sword2->setPlayerActionEvent(CUR_PLAYER_ID, mouse_touching);
|
||||||
|
|
||||||
debug(5, "USED \"%s\" ICON ON %s", FetchObjectName(OBJECT_HELD), FetchObjectName(CLICKED_ID));
|
debug(5, "USED \"%s\" ICON ON %s", FetchObjectName(OBJECT_HELD), FetchObjectName(CLICKED_ID));
|
||||||
|
|
||||||
|
@ -384,7 +384,7 @@ void Drag_mouse(void) {
|
||||||
pos = (g_display->_mouseX - 24) / 40;
|
pos = (g_display->_mouseX - 24) / 40;
|
||||||
|
|
||||||
//clicked on something - what button?
|
//clicked on something - what button?
|
||||||
if (master_menu_list[pos].icon_resource) {
|
if (g_sword2->_masterMenuList[pos].icon_resource) {
|
||||||
// always back into menu mode
|
// always back into menu mode
|
||||||
mouse_mode = MOUSE_menu;
|
mouse_mode = MOUSE_menu;
|
||||||
|
|
||||||
|
@ -405,8 +405,8 @@ void Drag_mouse(void) {
|
||||||
//what we clicked on, not what
|
//what we clicked on, not what
|
||||||
// we're dragging
|
// we're dragging
|
||||||
|
|
||||||
COMBINE_BASE = master_menu_list[pos].icon_resource;
|
COMBINE_BASE = g_sword2->_masterMenuList[pos].icon_resource;
|
||||||
Set_player_action_event(CUR_PLAYER_ID, MENU_MASTER_OBJECT);
|
g_sword2->setPlayerActionEvent(CUR_PLAYER_ID, MENU_MASTER_OBJECT);
|
||||||
|
|
||||||
// turn off mouse now, to
|
// turn off mouse now, to
|
||||||
// prevent player trying to
|
// prevent player trying to
|
||||||
|
@ -419,7 +419,7 @@ void Drag_mouse(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// refresh the menu
|
// refresh the menu
|
||||||
Build_menu();
|
g_sword2->buildMenu();
|
||||||
debug(5, "switch to menu mode");
|
debug(5, "switch to menu mode");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -454,13 +454,13 @@ void Menu_mouse(void) {
|
||||||
pos = (g_display->_mouseX - 24) / 40;
|
pos = (g_display->_mouseX - 24) / 40;
|
||||||
|
|
||||||
// clicked on something - what button?
|
// clicked on something - what button?
|
||||||
if (master_menu_list[pos].icon_resource) {
|
if (g_sword2->_masterMenuList[pos].icon_resource) {
|
||||||
if (me->buttons & RD_RIGHTBUTTONDOWN) {
|
if (me->buttons & RD_RIGHTBUTTONDOWN) {
|
||||||
// right button look
|
// right button look
|
||||||
examining_menu_icon = 1;
|
examining_menu_icon = 1;
|
||||||
|
|
||||||
// id the object via its graphic
|
// id the object via its graphic
|
||||||
OBJECT_HELD = master_menu_list[pos].icon_resource;
|
OBJECT_HELD = g_sword2->_masterMenuList[pos].icon_resource;
|
||||||
|
|
||||||
// Must clear this so next click on
|
// Must clear this so next click on
|
||||||
// exit becomes 1st click again
|
// exit becomes 1st click again
|
||||||
|
@ -469,10 +469,10 @@ void Menu_mouse(void) {
|
||||||
|
|
||||||
debug(5, "RIGHT-CLICKED ON \"%s\" ICON", FetchObjectName(OBJECT_HELD));
|
debug(5, "RIGHT-CLICKED ON \"%s\" ICON", FetchObjectName(OBJECT_HELD));
|
||||||
|
|
||||||
Set_player_action_event(CUR_PLAYER_ID, MENU_MASTER_OBJECT);
|
g_sword2->setPlayerActionEvent(CUR_PLAYER_ID, MENU_MASTER_OBJECT);
|
||||||
|
|
||||||
// refresh the menu
|
// refresh the menu
|
||||||
Build_menu();
|
g_sword2->buildMenu();
|
||||||
|
|
||||||
// turn off mouse now, to prevent
|
// turn off mouse now, to prevent
|
||||||
// player trying to click elsewhere
|
// player trying to click elsewhere
|
||||||
|
@ -488,13 +488,13 @@ void Menu_mouse(void) {
|
||||||
// mouse_on_off()
|
// mouse_on_off()
|
||||||
|
|
||||||
menu_selected_pos = pos;
|
menu_selected_pos = pos;
|
||||||
current_luggage_resource = master_menu_list[pos].luggage_resource;
|
current_luggage_resource = g_sword2->_masterMenuList[pos].luggage_resource;
|
||||||
|
|
||||||
mouse_mode = MOUSE_drag;
|
mouse_mode = MOUSE_drag;
|
||||||
debug(5, "setting OH in menu");
|
debug(5, "setting OH in menu");
|
||||||
|
|
||||||
// id the object via its graphic
|
// id the object via its graphic
|
||||||
OBJECT_HELD = master_menu_list[pos].icon_resource;
|
OBJECT_HELD = g_sword2->_masterMenuList[pos].icon_resource;
|
||||||
|
|
||||||
// must clear this so next click on
|
// must clear this so next click on
|
||||||
// exit becomes 1st click again
|
// exit becomes 1st click again
|
||||||
|
@ -502,9 +502,9 @@ void Menu_mouse(void) {
|
||||||
EXIT_CLICK_ID = 0;
|
EXIT_CLICK_ID = 0;
|
||||||
|
|
||||||
// refresh the menu
|
// refresh the menu
|
||||||
Build_menu();
|
g_sword2->buildMenu();
|
||||||
|
|
||||||
Set_luggage(master_menu_list[pos].luggage_resource);
|
Set_luggage(g_sword2->_masterMenuList[pos].luggage_resource);
|
||||||
debug(5, "switch to drag mode");
|
debug(5, "switch to drag mode");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -530,7 +530,7 @@ void Normal_mouse(void) {
|
||||||
|
|
||||||
// reset mouse cursor - in case we're between mice
|
// reset mouse cursor - in case we're between mice
|
||||||
Set_mouse(NORMAL_MOUSE_ID);
|
Set_mouse(NORMAL_MOUSE_ID);
|
||||||
Build_system_menu();
|
g_sword2->buildSystemMenu();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,7 +560,7 @@ void Normal_mouse(void) {
|
||||||
|
|
||||||
// reset mouse cursor
|
// reset mouse cursor
|
||||||
Set_mouse(NORMAL_MOUSE_ID);
|
Set_mouse(NORMAL_MOUSE_ID);
|
||||||
Build_menu();
|
g_sword2->buildMenu();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,27 +572,27 @@ void Normal_mouse(void) {
|
||||||
|
|
||||||
me = MouseEvent();
|
me = MouseEvent();
|
||||||
|
|
||||||
if (definingRectangles) {
|
if (g_sword2->_debugger->_definingRectangles) {
|
||||||
if (draggingRectangle == 0) {
|
if (g_sword2->_debugger->_draggingRectangle == 0) {
|
||||||
// not yet dragging a rectangle, so need click to start
|
// not yet dragging a rectangle, so need click to start
|
||||||
|
|
||||||
if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN))) {
|
if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN))) {
|
||||||
// set both (x1,y1) and (x2,y2) to this point
|
// set both (x1,y1) and (x2,y2) to this point
|
||||||
rect_x1 = rect_x2 = (uint32) g_display->_mouseX + this_screen.scroll_offset_x;
|
g_sword2->_debugger->_rectX1 = g_sword2->_debugger->_rectX2 = (uint32) g_display->_mouseX + this_screen.scroll_offset_x;
|
||||||
rect_y1 = rect_y2 = (uint32) g_display->_mouseY + this_screen.scroll_offset_y;
|
g_sword2->_debugger->_rectY1 = g_sword2->_debugger->_rectY2 = (uint32) g_display->_mouseY + this_screen.scroll_offset_y;
|
||||||
draggingRectangle = 1;
|
g_sword2->_debugger->_draggingRectangle = 1;
|
||||||
}
|
}
|
||||||
} else if (draggingRectangle == 1) {
|
} else if (g_sword2->_debugger->_draggingRectangle == 1) {
|
||||||
// currently dragging a rectangle - click means reset
|
// currently dragging a rectangle - click means reset
|
||||||
|
|
||||||
if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN))) {
|
if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN))) {
|
||||||
// lock rectangle, so you can let go of mouse
|
// lock rectangle, so you can let go of mouse
|
||||||
// to type in the coords
|
// to type in the coords
|
||||||
draggingRectangle = 2;
|
g_sword2->_debugger->_draggingRectangle = 2;
|
||||||
} else {
|
} else {
|
||||||
// drag rectangle
|
// drag rectangle
|
||||||
rect_x2 = (uint32) g_display->_mouseX + this_screen.scroll_offset_x;
|
g_sword2->_debugger->_rectX2 = (uint32) g_display->_mouseX + this_screen.scroll_offset_x;
|
||||||
rect_y2 = (uint32) g_display->_mouseY + this_screen.scroll_offset_y;
|
g_sword2->_debugger->_rectY2 = (uint32) g_display->_mouseY + this_screen.scroll_offset_y;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// currently locked to avoid knocking out of place
|
// currently locked to avoid knocking out of place
|
||||||
|
@ -600,7 +600,7 @@ void Normal_mouse(void) {
|
||||||
|
|
||||||
if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN))) {
|
if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN))) {
|
||||||
// click means reset - back to start again
|
// click means reset - back to start again
|
||||||
draggingRectangle = 0;
|
g_sword2->_debugger->_draggingRectangle = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -673,7 +673,7 @@ void Normal_mouse(void) {
|
||||||
EXIT_CLICK_ID = 0;
|
EXIT_CLICK_ID = 0;
|
||||||
EXIT_FADING = 0;
|
EXIT_FADING = 0;
|
||||||
|
|
||||||
Set_player_action_event(CUR_PLAYER_ID, mouse_touching);
|
g_sword2->setPlayerActionEvent(CUR_PLAYER_ID, mouse_touching);
|
||||||
|
|
||||||
if (OBJECT_HELD)
|
if (OBJECT_HELD)
|
||||||
debug(5, "USED \"%s\" ICON ON %s", FetchObjectName(OBJECT_HELD), FetchObjectName(CLICKED_ID));
|
debug(5, "USED \"%s\" ICON ON %s", FetchObjectName(OBJECT_HELD), FetchObjectName(CLICKED_ID));
|
||||||
|
@ -738,7 +738,6 @@ void Mouse_on_off(void) {
|
||||||
|
|
||||||
// setup luggage icon
|
// setup luggage icon
|
||||||
if (OBJECT_HELD) {
|
if (OBJECT_HELD) {
|
||||||
// Set_luggage(master_menu_list[menu_selected_pos].luggage_resource);
|
|
||||||
Set_luggage(current_luggage_resource);
|
Set_luggage(current_luggage_resource);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -1127,7 +1126,7 @@ int32 Logic::fnAddHuman(int32 *params) {
|
||||||
// enabled/disabled from console; status printed with on-screen debug
|
// enabled/disabled from console; status printed with on-screen debug
|
||||||
// info
|
// info
|
||||||
|
|
||||||
if (testingSnR) {
|
if (g_sword2->_debugger->_testingSnR) {
|
||||||
uint8 black[4] = { 0, 0, 0, 0 };
|
uint8 black[4] = { 0, 0, 0, 0 };
|
||||||
uint8 white[4] = { 255, 255, 255, 0 };
|
uint8 white[4] = { 255, 255, 255, 0 };
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ int32 Logic::fnPlayFx(int32 *params) {
|
||||||
_standardHeader *header;
|
_standardHeader *header;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (wantSfxDebug) {
|
if (g_sword2->_wantSfxDebug) {
|
||||||
char type[10];
|
char type[10];
|
||||||
|
|
||||||
switch (params[1]) { // 'type'
|
switch (params[1]) { // 'type'
|
||||||
|
|
|
@ -582,9 +582,9 @@ int32 Logic::fnTimedWait(int32 *params) {
|
||||||
// not ok
|
// not ok
|
||||||
RESULT = 1;
|
RESULT = 1;
|
||||||
|
|
||||||
//clear the event that hasn't been picked up - in theory,
|
// clear the event that hasn't been picked up - in theory,
|
||||||
// none of this should ever happen
|
// none of this should ever happen
|
||||||
Kill_all_ids_events(target);
|
g_sword2->killAllIdsEvents(target);
|
||||||
|
|
||||||
debug(5, "EVENT timed out");
|
debug(5, "EVENT timed out");
|
||||||
|
|
||||||
|
@ -972,7 +972,7 @@ int32 Logic::fnISpeak(int32 *params) {
|
||||||
} else
|
} else
|
||||||
cycle_skip = 0;
|
cycle_skip = 0;
|
||||||
|
|
||||||
textNumber = params[S_TEXT]; // for debug info
|
g_sword2->_debugger->_textNumber = params[S_TEXT]; // for debug info
|
||||||
|
|
||||||
// For testing all text & speech!
|
// For testing all text & speech!
|
||||||
// A script loop can send any text number to fnISpeak and it
|
// A script loop can send any text number to fnISpeak and it
|
||||||
|
@ -1343,7 +1343,7 @@ int32 Logic::fnISpeak(int32 *params) {
|
||||||
ob_logic->looping = 0;
|
ob_logic->looping = 0;
|
||||||
|
|
||||||
// reset for debug info
|
// reset for debug info
|
||||||
textNumber = 0;
|
g_sword2->_debugger->_textNumber = 0;
|
||||||
|
|
||||||
// reset to zero, in case text line not even extracted (since
|
// reset to zero, in case text line not even extracted (since
|
||||||
// this number comes from the text line)
|
// this number comes from the text line)
|
||||||
|
|
|
@ -150,6 +150,17 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
|
||||||
_fps = 0;
|
_fps = 0;
|
||||||
_cycleTime = 0;
|
_cycleTime = 0;
|
||||||
_frameCount = 0;
|
_frameCount = 0;
|
||||||
|
|
||||||
|
_wantSfxDebug = false;
|
||||||
|
_grabbingSequences = false;
|
||||||
|
|
||||||
|
// For the menus
|
||||||
|
|
||||||
|
_totalTemp = 0;
|
||||||
|
memset(_tempList, 0, sizeof(_tempList));
|
||||||
|
|
||||||
|
_totalMasters = 0;
|
||||||
|
memset(_masterMenuList, 0, sizeof(_masterMenuList));
|
||||||
}
|
}
|
||||||
|
|
||||||
Sword2Engine::~Sword2Engine() {
|
Sword2Engine::~Sword2Engine() {
|
||||||
|
@ -220,7 +231,7 @@ int32 Sword2Engine::InitialiseGame(void) {
|
||||||
Init_sync_system();
|
Init_sync_system();
|
||||||
|
|
||||||
debug(5, "CALLING: Init_event_system");
|
debug(5, "CALLING: Init_event_system");
|
||||||
Init_event_system();
|
initEventSystem();
|
||||||
|
|
||||||
// initialise the sound fx queue
|
// initialise the sound fx queue
|
||||||
|
|
||||||
|
@ -322,6 +333,11 @@ void Sword2Engine::go() {
|
||||||
debug(5, "CALLING: initialiseRenderCycle");
|
debug(5, "CALLING: initialiseRenderCycle");
|
||||||
g_display->initialiseRenderCycle();
|
g_display->initialiseRenderCycle();
|
||||||
|
|
||||||
|
_renderSkip = false; // Toggled on 'S' key, to render only
|
||||||
|
// 1 in 4 frames, to speed up game
|
||||||
|
|
||||||
|
_gameCycle = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (_debugger->isAttached())
|
if (_debugger->isAttached())
|
||||||
_debugger->onFrame();
|
_debugger->onFrame();
|
||||||
|
@ -331,7 +347,7 @@ void Sword2Engine::go() {
|
||||||
#ifdef _SWORD2_DEBUG
|
#ifdef _SWORD2_DEBUG
|
||||||
// FIXME: If we want this, we should re-work it to use the backend's
|
// FIXME: If we want this, we should re-work it to use the backend's
|
||||||
// screenshot functionality.
|
// screenshot functionality.
|
||||||
// if (grabbingSequences && !console_status)
|
// if (_debugger->_grabbingSequences && !console_status)
|
||||||
// GrabScreenShot();
|
// GrabScreenShot();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -388,7 +404,7 @@ void Sword2Engine::go() {
|
||||||
else if (c == 'S') {
|
else if (c == 'S') {
|
||||||
// 'S' toggles speed up (by skipping
|
// 'S' toggles speed up (by skipping
|
||||||
// display rendering)
|
// display rendering)
|
||||||
renderSkip = 1 - renderSkip;
|
_renderSkip = !_renderSkip;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -396,7 +412,7 @@ void Sword2Engine::go() {
|
||||||
// skip GameCycle if we're paused
|
// skip GameCycle if we're paused
|
||||||
if (gamePaused == 0) {
|
if (gamePaused == 0) {
|
||||||
#ifdef _SWORD2_DEBUG
|
#ifdef _SWORD2_DEBUG
|
||||||
gameCycle++;
|
_gameCycle++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (GameCycle()) {
|
if (GameCycle()) {
|
||||||
|
@ -406,13 +422,13 @@ void Sword2Engine::go() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// creates the debug text blocks
|
// creates the debug text blocks
|
||||||
Build_debug_text();
|
_debugger->buildDebugText();
|
||||||
|
|
||||||
#ifdef _SWORD2_DEBUG
|
#ifdef _SWORD2_DEBUG
|
||||||
// if not in console & 'renderSkip' is set, only render
|
// if not in console & '_renderSkip' is set, only render
|
||||||
// display once every 4 game-cycles
|
// display once every 4 game-cycles
|
||||||
|
|
||||||
if (console_status || renderSkip == 0 || (gameCycle % 4) == 0)
|
if (console_status || !_renderSkip || (_gameCycle % 4) == 0)
|
||||||
g_sword2->buildDisplay(); // create and flip the screen
|
g_sword2->buildDisplay(); // create and flip the screen
|
||||||
#else
|
#else
|
||||||
// create and flip the screen
|
// create and flip the screen
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
#include "common/str.h"
|
#include "common/str.h"
|
||||||
#include "sword2/build_display.h"
|
#include "sword2/build_display.h"
|
||||||
#include "sword2/console.h"
|
#include "sword2/console.h"
|
||||||
|
#include "sword2/events.h"
|
||||||
|
#include "sword2/icons.h"
|
||||||
|
#include "sword2/object.h"
|
||||||
#include "sword2/driver/d_sound.h"
|
#include "sword2/driver/d_sound.h"
|
||||||
#include "sword2/driver/d_draw.h"
|
#include "sword2/driver/d_draw.h"
|
||||||
|
|
||||||
|
@ -181,8 +184,41 @@ public:
|
||||||
uint32 _cycleTime;
|
uint32 _cycleTime;
|
||||||
uint32 _frameCount;
|
uint32 _frameCount;
|
||||||
|
|
||||||
|
bool _wantSfxDebug;
|
||||||
|
bool _grabbingSequences;
|
||||||
|
|
||||||
|
int32 _gameCycle;
|
||||||
|
bool _renderSkip;
|
||||||
|
|
||||||
int32 initBackground(int32 res, int32 new_palette);
|
int32 initBackground(int32 res, int32 new_palette);
|
||||||
|
|
||||||
|
_event_unit _eventList[MAX_events];
|
||||||
|
|
||||||
|
void initEventSystem(void);
|
||||||
|
void sendEvent(uint32 id, uint32 interact_id);
|
||||||
|
void setPlayerActionEvent(uint32 id, uint32 interact_id);
|
||||||
|
void startEvent(void);
|
||||||
|
bool checkEventWaiting(void);
|
||||||
|
void clearEvent(uint32 id);
|
||||||
|
void killAllIdsEvents(uint32 id);
|
||||||
|
|
||||||
|
uint32 countEvents(void);
|
||||||
|
|
||||||
|
// These two are set by fnPassGraph() and fnPassMega().
|
||||||
|
// FIXME: _engineGraph isn't used at all, is it?
|
||||||
|
|
||||||
|
Object_graphic _engineGraph;
|
||||||
|
Object_mega _engineMega;
|
||||||
|
|
||||||
|
menu_object _tempList[TOTAL_engine_pockets];
|
||||||
|
uint32 _totalTemp;
|
||||||
|
|
||||||
|
menu_object _masterMenuList[TOTAL_engine_pockets];
|
||||||
|
uint32 _totalMasters;
|
||||||
|
|
||||||
|
void buildMenu(void);
|
||||||
|
void buildSystemMenu(void);
|
||||||
|
|
||||||
void errorString(const char *buf_input, char *buf_output);
|
void errorString(const char *buf_input, char *buf_output);
|
||||||
void initialiseFontResourceFlags(void);
|
void initialiseFontResourceFlags(void);
|
||||||
void initialiseFontResourceFlags(uint8 language);
|
void initialiseFontResourceFlags(uint8 language);
|
||||||
|
|
|
@ -174,7 +174,7 @@ int32 Logic::fnWalk(int32 *params) {
|
||||||
// if stopping the walk early, overwrite the next step with a
|
// if stopping the walk early, overwrite the next step with a
|
||||||
// slow-out, then finish
|
// slow-out, then finish
|
||||||
|
|
||||||
if (Check_event_waiting()) {
|
if (g_sword2->checkEventWaiting()) {
|
||||||
if (walkAnim[walk_pc].step == 0 && walkAnim[walk_pc + 1].step == 1) {
|
if (walkAnim[walk_pc].step == 0 && walkAnim[walk_pc + 1].step == 1) {
|
||||||
// at the beginning of a step
|
// at the beginning of a step
|
||||||
ob_walkdata = (Object_walkdata *) params[3];
|
ob_walkdata = (Object_walkdata *) params[3];
|
||||||
|
@ -213,8 +213,8 @@ int32 Logic::fnWalk(int32 *params) {
|
||||||
// was only run if a function that always returned zero
|
// was only run if a function that always returned zero
|
||||||
// returned non-zero.
|
// returned non-zero.
|
||||||
|
|
||||||
if (Check_event_waiting()) {
|
if (g_sword2->checkEventWaiting()) {
|
||||||
Start_event();
|
g_sword2->startEvent();
|
||||||
RESULT = 1; // 1 means didn't finish walk
|
RESULT = 1; // 1 means didn't finish walk
|
||||||
return IR_TERMINATE;
|
return IR_TERMINATE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -615,13 +615,13 @@ int32 Logic::fnFaceMega(int32 *params) {
|
||||||
|
|
||||||
res_man.close(params[4]);
|
res_man.close(params[4]);
|
||||||
|
|
||||||
// engine_mega is now the Object_mega of mega we want to turn
|
// engineMega is now the Object_mega of mega we want to turn
|
||||||
// to face
|
// to face
|
||||||
|
|
||||||
pars[3] = params[3];
|
pars[3] = params[3];
|
||||||
pars[4] = ob_mega->feet_x;
|
pars[4] = ob_mega->feet_x;
|
||||||
pars[5] = ob_mega->feet_y;
|
pars[5] = ob_mega->feet_y;
|
||||||
pars[6] = What_target(ob_mega->feet_x, ob_mega->feet_y, engine_mega.feet_x, engine_mega.feet_y);
|
pars[6] = What_target(ob_mega->feet_x, ob_mega->feet_y, g_sword2->_engineMega.feet_x, g_sword2->_engineMega.feet_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
pars[0] = params[0];
|
pars[0] = params[0];
|
||||||
|
@ -678,11 +678,11 @@ int32 Logic::fnWalkToTalkToMega(int32 *params) {
|
||||||
|
|
||||||
res_man.close(params[4]);
|
res_man.close(params[4]);
|
||||||
|
|
||||||
// engine_mega is now the Object_mega of mega we want to
|
// engineMega is now the Object_mega of mega we want to
|
||||||
// route to
|
// route to
|
||||||
|
|
||||||
// stand exactly beside the mega, ie. at same y-coord
|
// stand exactly beside the mega, ie. at same y-coord
|
||||||
pars[5] = engine_mega.feet_y;
|
pars[5] = g_sword2->_engineMega.feet_y;
|
||||||
|
|
||||||
// apply scale factor to walk distance
|
// apply scale factor to walk distance
|
||||||
// Ay+B gives 256 * scale ie. 256 * 256 * true_scale for even
|
// Ay+B gives 256 * scale ie. 256 * 256 * true_scale for even
|
||||||
|
@ -693,20 +693,20 @@ int32 Logic::fnWalkToTalkToMega(int32 *params) {
|
||||||
mega_seperation= (mega_seperation * scale) / 256;
|
mega_seperation= (mega_seperation * scale) / 256;
|
||||||
|
|
||||||
debug(5, "seperation %d", mega_seperation);
|
debug(5, "seperation %d", mega_seperation);
|
||||||
debug(5, " target x %d, y %d", engine_mega.feet_x, engine_mega.feet_y);
|
debug(5, " target x %d, y %d", g_sword2->_engineMega.feet_x, g_sword2->_engineMega.feet_y);
|
||||||
|
|
||||||
if (engine_mega.feet_x < ob_mega->feet_x)
|
if (g_sword2->_engineMega.feet_x < ob_mega->feet_x)
|
||||||
{
|
{
|
||||||
// Target is left of us, so aim to stand to their
|
// Target is left of us, so aim to stand to their
|
||||||
// right. Face down_left
|
// right. Face down_left
|
||||||
|
|
||||||
pars[4] = engine_mega.feet_x + mega_seperation;
|
pars[4] = g_sword2->_engineMega.feet_x + mega_seperation;
|
||||||
pars[6] = 5;
|
pars[6] = 5;
|
||||||
} else {
|
} else {
|
||||||
// Ok, must be right of us so aim to stand to their
|
// Ok, must be right of us so aim to stand to their
|
||||||
// left. Face down_right.
|
// left. Face down_right.
|
||||||
|
|
||||||
pars[4] = engine_mega.feet_x - mega_seperation;
|
pars[4] = g_sword2->_engineMega.feet_x - mega_seperation;
|
||||||
pars[6] = 3;
|
pars[6] = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue