fixed debug areas display ; some minor cleanup

svn-id: r18007
This commit is contained in:
Gregory Montoir 2005-05-09 18:25:28 +00:00
parent c804ec2b67
commit da06fe93a9
10 changed files with 50 additions and 66 deletions

View File

@ -28,7 +28,9 @@ namespace Queen {
BankManager::BankManager(Resource *res)
: _res(res) {
flush();
memset(_frames, 0, sizeof(_frames));
memset(_banks, 0, sizeof(_banks));
memset(_loadedBanks, 0, sizeof(_loadedBanks));
}
BankManager::~BankManager() {
@ -112,12 +114,6 @@ void BankManager::close(uint32 bankslot) {
_loadedBanks[bankslot][0] = '\0';
}
void BankManager::flush() {
memset(_frames, 0, sizeof(_frames));
memset(_banks, 0, sizeof(_banks));
memset(_loadedBanks, 0, sizeof(_loadedBanks));
}
BobFrame *BankManager::fetchFrame(uint32 index) {
debug(9, "BankManager::fetchFrame(%d)", index);
assert(index < MAX_FRAMES_NUMBER);

View File

@ -47,9 +47,6 @@ public:
//! close a bank
void close(uint32 bankslot);
//! reset this BankManager
void flush();
//! get a reference to unpacked frame
BobFrame *fetchFrame(uint32 index);

View File

@ -161,7 +161,7 @@ void Command::executeCurrentAction() {
_cmdText.addObject(_vm->logic()->objectName(od->name));
}
// make sure that command is always highlighted when actioned!
// always highlight the current command when actioned
_cmdText.display(INK_CMD_SELECT);
_state.selNoun = _state.noun;
@ -172,7 +172,7 @@ void Command::executeCurrentAction() {
return;
}
// get the commands associated with object/item
// get the commands associated with this object/item
uint16 comMax = 0;
uint16 matchingCmds[MAX_MATCHING_CMDS];
CmdListData *cmdList = &_cmdList[1];
@ -253,10 +253,6 @@ void Command::updatePlayer() {
_state.verb = _vm->input()->keyVerb();
if (isVerbInv(_state.verb)) {
_state.noun = _state.selNoun = 0;
// Clear old noun and old verb in case we're pointing at an
// object (noun) or item (verb) and we want to use an item
// on it. This was the command will be redisplayed with the
// object/item that the cursor is currently on.
_state.oldNoun = 0;
_state.oldVerb = VERB_NONE;
grabSelectedItem();
@ -361,7 +357,7 @@ int16 Command::executeCommand(uint16 comId, int16 condResult) {
setAreas(comId);
}
// Don't grab if action is TALK or WALK
// don't try to grab if action is TALK or WALK
if (_state.selAction != VERB_TALK_TO && _state.selAction != VERB_WALK_TO) {
int i;
for (i = 0; i < 2; ++i) {
@ -953,15 +949,11 @@ void Command::openOrCloseAssociatedObject(Verb action, int16 otherObj) {
int16 Command::setConditions(uint16 command, bool lastCmd) {
debug(9, "Command::setConditions(%d, %d)", command, lastCmd);
// Test conditions, if FAIL write && exit, Return -1
// if (Joe speaks before he returns, -2 is returned
// This way a -1 return will allow Joe to speak normal description
uint16 temp[21];
memset(temp, 0, sizeof(temp));
uint16 tempInd = 0;
int16 ret = 0;
uint16 cmdState[21];
memset(cmdState, 0, sizeof(cmdState));
uint16 cmdStateCount = 0;
uint16 i;
CmdGameState *cmdGs = &_cmdGameState[1];
for (i = 1; i <= _numCmdGameState; ++i, ++cmdGs) {
@ -974,8 +966,8 @@ int16 Command::setConditions(uint16 command, bool lastCmd) {
break;
}
} else {
temp[tempInd] = i;
++tempInd;
cmdState[cmdStateCount] = i;
++cmdStateCount;
}
}
}
@ -991,13 +983,14 @@ int16 Command::setConditions(uint16 command, bool lastCmd) {
}
ret = -2;
} else {
// return -1 so Joe will be able to speak a normal description
ret = -1;
}
} else {
ret = 0;
// all tests were okay, now set gamestates
for (i = 0; i < tempInd; ++i) {
cmdGs = &_cmdGameState[temp[i]];
for (i = 0; i < cmdStateCount; ++i) {
cmdGs = &_cmdGameState[cmdState[i]];
_vm->logic()->gameState(ABS(cmdGs->gameStateSlot), cmdGs->gameStateValue);
// set return value for Joe to say something
ret = cmdGs->speakValue;
@ -1010,8 +1003,7 @@ void Command::setAreas(uint16 command) {
debug(9, "Command::setAreas(%d)", command);
CmdArea *cmdArea = &_cmdArea[1];
uint16 i;
for (i = 1; i <= _numCmdArea; ++i, ++cmdArea) {
for (uint16 i = 1; i <= _numCmdArea; ++i, ++cmdArea) {
if (cmdArea->id == command) {
uint16 areaNum = ABS(cmdArea->area);
Area *area = _vm->grid()->area(cmdArea->room, areaNum);
@ -1030,8 +1022,7 @@ void Command::setObjects(uint16 command) {
debug(9, "Command::setObjects(%d)", command);
CmdObject *cmdObj = &_cmdObject[1];
uint16 i;
for (i = 1; i <= _numCmdObject; ++i, ++cmdObj) {
for (uint16 i = 1; i <= _numCmdObject; ++i, ++cmdObj) {
if (cmdObj->id == command) {
// found an object
@ -1101,10 +1092,9 @@ void Command::setObjects(uint16 command) {
void Command::setItems(uint16 command) {
debug(9, "Command::setItems(%d)", command);
CmdInventory *cmdInv = &_cmdInventory[1];
ItemData *items = _vm->logic()->itemData(0);
uint16 i;
for (i = 1; i <= _numCmdInventory; ++i, ++cmdInv) {
CmdInventory *cmdInv = &_cmdInventory[1];
for (uint16 i = 1; i <= _numCmdInventory; ++i, ++cmdInv) {
if (cmdInv->id == command) {
uint16 dstItem = ABS(cmdInv->dstItem);
// found an item

View File

@ -151,8 +151,6 @@ void Cutaway::load(const char *filename) {
}
void Cutaway::loadStrings(uint16 offset) {
int i,j;
int bankNameCount = READ_BE_UINT16(_fileData + offset);
offset += 2;
@ -163,7 +161,7 @@ void Cutaway::loadStrings(uint16 offset) {
the original source code.
*/
for (i = 0, j = 0; i < bankNameCount; i++) {
for (int i = 0, j = 0; i < bankNameCount; i++) {
Talk::getString(_fileData, offset, _bankNames[j], MAX_FILENAME_LENGTH);
if (_bankNames[j][0]) {
debug(6, "Bank name %i = '%s'", j, _bankNames[j]);

View File

@ -36,7 +36,7 @@
namespace Queen {
Debugger::Debugger(QueenEngine *vm)
: _drawAreas(false), _vm(vm) {
: _vm(vm), _flags(0) {
DCmd_Register("exit", &Debugger::Cmd_Exit);
DCmd_Register("help", &Debugger::Cmd_Help);
@ -96,8 +96,8 @@ bool Debugger::Cmd_Asm(int argc, const char **argv) {
}
bool Debugger::Cmd_Areas(int argc, const char **argv) {
_drawAreas = !_drawAreas;
DebugPrintf("Room areas display %s\n", _drawAreas ? "on" : "off");
_flags ^= DF_DRAW_AREAS;
DebugPrintf("Room areas display %s\n", (_flags & DF_DRAW_AREAS) != 0 ? "on" : "off");
return true;
}

View File

@ -33,7 +33,11 @@ public:
Debugger(QueenEngine *vm);
bool _drawAreas;
int flags() const { return _flags; }
enum {
DF_DRAW_AREAS = 1 << 0
};
protected:
@ -55,6 +59,7 @@ protected:
private:
QueenEngine *_vm;
int _flags;
};
} // End of namespace Queen

View File

@ -756,7 +756,7 @@ void Display::fill(uint8 *dstBuf, uint16 dstPitch, uint16 x, uint16 y, uint16 w,
void Display::readPCX(uint8 *dst, uint16 dstPitch, const uint8 *src, uint16 w, uint16 h) {
while (h--) {
uint8 *p = dst;
while (p < dst + w ) {
while (p < dst + w) {
uint8 col = *src++;
if ((col & 0xC0) == 0xC0) {
uint8 len = col & 0x3F;
@ -939,14 +939,17 @@ void Display::drawText(uint16 x, uint16 y, uint8 color, const char *text, bool o
}
void Display::drawBox(int16 x1, int16 y1, int16 x2, int16 y2, uint8 col) {
uint8 *p = _screenBuf;
int i;
for (i = y1; i <= y2; ++i) {
*(p + i * SCREEN_W + x1) = *(p + i * SCREEN_W + x2) = col;
_screenBuf[i * SCREEN_W + x1] = _screenBuf[i * SCREEN_W + x2] = col;
}
setDirtyBlock(x1, y1, 1, y2 - y1);
setDirtyBlock(x2, y1, 1, y2 - y1);
for (i = x1; i <= x2; ++i) {
*(p + y1 * SCREEN_W + i) = *(p + y2 * SCREEN_W + i) = col;
_screenBuf[y1 * SCREEN_W + i] = _screenBuf[y2 * SCREEN_W + i] = col;
}
setDirtyBlock(x1, y1, x2 - x1, 1);
setDirtyBlock(x1, y2, x2 - x1, 1);
}
void Display::shake(bool reset) {
@ -1010,13 +1013,9 @@ void Display::blankScreenEffect2() {
c = *(p + SCREEN_W + 1);
break;
}
uint8 *buf = p;
int j = 2;
while (j--) {
memset(p, c, 2);
p += SCREEN_W;
}
_system->copyRectToScreen(buf, SCREEN_W, x, y, 2, 2);
memset(p, c, 2);
memset(p + SCREEN_W, c, 2);
_system->copyRectToScreen(p, SCREEN_W, x, y, 2, 2);
_system->updateScreen();
_vm->input()->delay(10);
}
@ -1037,14 +1036,10 @@ void Display::blankScreenEffect3() {
uint8 p2 = *(p + SCREEN_W);
uint8 p3 = *(p + SCREEN_W + 1);
uint8 c = (p0 + p1 + p2 + p3) / 4;
uint8 *buf = p;
int j = 2;
while (j--) {
memset(p, c, 2);
p += SCREEN_W;
}
memset(p, c, 2);
memset(p + SCREEN_W, c, 2);
++i;
_system->copyRectToScreen(buf, SCREEN_W, x, y, 2, 2);
_system->copyRectToScreen(p, SCREEN_W, x, y, 2, 2);
}
_system->updateScreen();
_vm->input()->delay(10);

View File

@ -109,6 +109,7 @@ void Input::delay(uint amount) {
_inKey = event.kbd.keycode;
}
break;
case OSystem::EVENT_MOUSEMOVE:
_mouse_x = event.mouse.x;
_mouse_y = event.mouse.y;

View File

@ -919,8 +919,8 @@ void Logic::inventoryRefresh() {
for (int i = 0; i < 4; ++i) {
uint16 itemNum = _inventoryItem[i];
if (itemNum != 0) {
// 1st object in inventory uses frame 8,
// whereas 2nd, 3rd and 4th uses frame 9
// 1st object in inventory uses frame 9,
// whereas 2nd, 3rd and 4th uses frame 8
uint16 dstFrame = (itemNum != 0) ? 8 : 9;
// unpack frame for object and draw it
_vm->bankMan()->unpack(_itemData[itemNum].frame, dstFrame, 14);
@ -1213,7 +1213,7 @@ void Logic::handlePinnacleRoom() {
joe->frameNum = _vm->input()->mousePosX() / 36 + 45;
// bobs have been unpacked from animating objects, we don't need them
// to animate anymore ; so turn animating off
// to animate anymore ; so turn animation off
joe->animating = piton->animating = false;
_vm->update();
@ -1297,7 +1297,7 @@ void Logic::update() {
if (_credits)
_credits->update();
if (_vm->debugger()->_drawAreas) {
if (_vm->debugger()->flags() & Debugger::DF_DRAW_AREAS) {
_vm->grid()->drawZones();
}
}

View File

@ -159,6 +159,7 @@ public:
//! play the specified cutaway
void playCutaway(const char *cutFile, char *next = NULL);
//! initialize the inventory
void inventorySetup();
//! get the inventory item for the specified inventory slot
@ -181,7 +182,7 @@ public:
//! handle a particular event when Joe walks on this area
void handleSpecialArea(Direction facing, uint16 areaNum, uint16 walkDataNum);
//! handle the pinnacle room (in jungle)
//! handle the pinnacle room (== room chooser in the jungle)
void handlePinnacleRoom();
void update();
@ -189,6 +190,7 @@ public:
void saveState(byte *&ptr);
void loadState(uint32 ver, byte *&ptr);
//! called after a save state has been loaded
void setupRestoredGame();
//! ugly hack from original code