aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction
diff options
context:
space:
mode:
authorNicola Mettifogo2007-05-13 14:56:44 +0000
committerNicola Mettifogo2007-05-13 14:56:44 +0000
commita1733f8bbec378a44883de20cdc2b4792a2a33a8 (patch)
treef53f9667de255971a4a1cc01df597c21988bf483 /engines/parallaction
parentae63466446af9b906d7a1795aaeb866956bd0c13 (diff)
downloadscummvm-rg350-a1733f8bbec378a44883de20cdc2b4792a2a33a8.tar.gz
scummvm-rg350-a1733f8bbec378a44883de20cdc2b4792a2a33a8.tar.bz2
scummvm-rg350-a1733f8bbec378a44883de20cdc2b4792a2a33a8.zip
More cleanup.
svn-id: r26835
Diffstat (limited to 'engines/parallaction')
-rw-r--r--engines/parallaction/graphics.cpp16
-rw-r--r--engines/parallaction/inventory.cpp91
-rw-r--r--engines/parallaction/location.cpp39
3 files changed, 50 insertions, 96 deletions
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index 0a6d00f24b..6f03e7030d 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -31,21 +31,7 @@
extern OSystem *g_system;
namespace Parallaction {
-/*
-//
-// proportional font glyphs width
-//
-const byte _glyphWidths[126] = {
- 0x04, 0x03, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x04, 0x04, 0x06, 0x06, 0x03, 0x05, 0x03, 0x05,
- 0x06, 0x06, 0x06, 0x06, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x03, 0x03, 0x05, 0x04, 0x05, 0x05,
- 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x07, 0x05, 0x06, 0x05, 0x08, 0x07,
- 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x03, 0x04, 0x05, 0x05, 0x06, 0x06, 0x05,
- 0x05, 0x06, 0x05, 0x05, 0x05, 0x05, 0x06, 0x07, 0x05, 0x05, 0x05, 0x05, 0x02, 0x05, 0x05, 0x07,
- 0x08, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04,
- 0x05, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x06, 0x05, 0x05, 0x05, 0x05
-};
-*/
+
byte * Gfx::_buffers[];
#define BALLOON_WIDTH 12
diff --git a/engines/parallaction/inventory.cpp b/engines/parallaction/inventory.cpp
index 70a0349d89..09c49bb20d 100644
--- a/engines/parallaction/inventory.cpp
+++ b/engines/parallaction/inventory.cpp
@@ -37,6 +37,7 @@ namespace Parallaction {
//
#define INVENTORY_MAX_ITEMS 30
+#define INVENTORY_FIRST_ITEM 4 // first four entries are used up by verbs
#define INVENTORYITEM_PITCH 32
#define INVENTORYITEM_WIDTH 24
@@ -93,52 +94,50 @@ void drawInventoryItem(uint16 pos, InventoryItem *item);
//
int16 Parallaction::getHoverInventoryItem(int16 x, int16 y) {
- int16 _di = x;
-
- int16 _si = -1;
+ int16 slot = -1;
do {
- _si++;
- } while (_inventory[_si]._id != 0);
+ slot++;
+ } while (_inventory[slot]._id != 0);
- _si = (_si + 4) / INVENTORY_ITEMS_PER_LINE;
+ slot = (slot + 4) / INVENTORY_ITEMS_PER_LINE;
- if (_invPosition.x >= _di) return -1;
- if ((_invPosition.x + INVENTORY_WIDTH) <= _di) return -1;
+ if (_invPosition.x >= x) return -1;
+ if ((_invPosition.x + INVENTORY_WIDTH) <= x) return -1;
if (_invPosition.y >= y) return -1;
- if ((_si * INVENTORYITEM_HEIGHT + _invPosition.y) <= y) return -1;
+ if ((slot * INVENTORYITEM_HEIGHT + _invPosition.y) <= y) return -1;
- return ((_di - _invPosition.x) / INVENTORYITEM_WIDTH) + (INVENTORY_ITEMS_PER_LINE * ((y - _invPosition.y) / INVENTORYITEM_HEIGHT));
+ return ((x - _invPosition.x) / INVENTORYITEM_WIDTH) + (INVENTORY_ITEMS_PER_LINE * ((y - _invPosition.y) / INVENTORYITEM_HEIGHT));
}
void refreshInventory(const char *character) {
- for (uint16 _si = 0; _si < INVENTORY_MAX_ITEMS; _si++) {
- drawInventoryItem(_si, &_inventory[_si]);
+ for (uint16 i = 0; i < INVENTORY_MAX_ITEMS; i++) {
+ drawInventoryItem(i, &_inventory[i]);
}
-
return;
}
void refreshInventoryItem(const char *character, uint16 index) {
drawInventoryItem(index, &_inventory[index]);
-
return;
}
int Parallaction::addInventoryItem(uint16 item) {
- uint16 _si = 0;
- while (_inventory[_si]._id != 0) _si++;
- if (_si == INVENTORY_MAX_ITEMS)
+ uint16 slot = 0;
+ while (_inventory[slot]._id != 0)
+ slot++;
+
+ if (slot == INVENTORY_MAX_ITEMS)
return -1;
- _inventory[_si]._id = MAKE_INVENTORY_ID(item);
- _inventory[_si]._index = item;
+ _inventory[slot]._id = MAKE_INVENTORY_ID(item);
+ _inventory[slot]._index = item;
- refreshInventoryItem(_characterName, _si);
+ refreshInventoryItem(_characterName, slot);
return 0;
}
@@ -146,16 +145,16 @@ int Parallaction::addInventoryItem(uint16 item) {
void Parallaction::dropItem(uint16 v) {
- uint16 _di = 0;
- for (uint16 _si = 0; _si < INVENTORY_MAX_ITEMS - 1; _si++) {
+ bool found = false;
+ for (uint16 slot = 0; slot < INVENTORY_MAX_ITEMS - 1; slot++) {
- if (v + 4 == _inventory[_si]._index) {
- _di = 1;
+ if (v + INVENTORY_FIRST_ITEM == _inventory[slot]._index) {
+ found = true;
}
- if (_di == 0) continue;
+ if (!found) continue;
- memcpy(&_inventory[_si], &_inventory[_si+1], sizeof(InventoryItem));
+ memcpy(&_inventory[slot], &_inventory[slot+1], sizeof(InventoryItem));
}
refreshInventory(_characterName);
@@ -166,8 +165,8 @@ void Parallaction::dropItem(uint16 v) {
int16 Parallaction::isItemInInventory(int32 v) {
- for (uint16 _si = 0; _si < INVENTORY_MAX_ITEMS; _si++) {
- if (_inventory[_si]._id == (uint)v)
+ for (uint16 slot = 0; slot < INVENTORY_MAX_ITEMS; slot++) {
+ if (_inventory[slot]._id == (uint)v)
return 1;
}
@@ -259,13 +258,13 @@ void extractInventoryGraphics(int16 pos, byte *dst) {
void jobShowInventory(void *parm, Job *j) {
// printf("job_showInventory()...");
- _numInvLines = 0;
-
- while (_inventory[_numInvLines]._id != 0) _numInvLines++;
+ uint16 slots = 0;
+ while (_inventory[slots]._id != 0)
+ slots++;
- _numInvLines = (_numInvLines + 4) / INVENTORY_ITEMS_PER_LINE;
+ uint16 lines = (slots + 4) / INVENTORY_ITEMS_PER_LINE;
- Common::Rect r(INVENTORY_WIDTH, _numInvLines * INVENTORYITEM_HEIGHT);
+ Common::Rect r(INVENTORY_WIDTH, lines * INVENTORYITEM_HEIGHT);
r.moveTo(_invPosition);
_vm->_gfx->copyRect(
@@ -305,14 +304,13 @@ void jobHideInventory(void *parm, Job *j) {
void openInventory() {
-// printf("openInventory()\n");
-
- uint16 _si = 0;
_engineFlags |= kEngineInventory;
- while (_inventory[_si]._id != 0) _si++;
+ uint16 slot = 0;
+ while (_inventory[slot]._id != 0)
+ slot++;
- uint16 _LOCALinventory_lines = (_si + 4) / INVENTORY_ITEMS_PER_LINE;
+ uint16 lines = (slot + 4) / INVENTORY_ITEMS_PER_LINE;
_invPosition.x = _vm->_mousePos.x - (INVENTORY_WIDTH / 2);
if (_invPosition.x < 0)
@@ -321,12 +319,12 @@ void openInventory() {
if ((_invPosition.x + INVENTORY_WIDTH) > SCREEN_WIDTH)
_invPosition.x = SCREEN_WIDTH - INVENTORY_WIDTH;
- _invPosition.y = _vm->_mousePos.y - 2 - (_LOCALinventory_lines * INVENTORYITEM_HEIGHT);
+ _invPosition.y = _vm->_mousePos.y - 2 - (lines * INVENTORYITEM_HEIGHT);
if (_invPosition.y < 0)
_invPosition.y = 0;
- if (_invPosition.y > SCREEN_HEIGHT - _LOCALinventory_lines * INVENTORYITEM_HEIGHT)
- _invPosition.y = SCREEN_HEIGHT - _LOCALinventory_lines * INVENTORYITEM_HEIGHT;
+ if (_invPosition.y > SCREEN_HEIGHT - lines * INVENTORYITEM_HEIGHT)
+ _invPosition.y = SCREEN_HEIGHT - lines * INVENTORYITEM_HEIGHT;
return;
@@ -335,21 +333,18 @@ void openInventory() {
void closeInventory() {
-// printf("closeInventory()\n");
-
_engineFlags &= ~kEngineInventory;
}
void initInventory() {
- _buffer = (byte*)malloc(INVENTORY_WIDTH * INVENTORY_HEIGHT); // this buffer is also used by menu so it must stay this size
-
+ _buffer = (byte*)malloc(INVENTORY_WIDTH * INVENTORY_HEIGHT);
}
void cleanInventory() {
- for (uint16 _si = 4; _si < 30; _si++) {
- _inventory[_si]._id = 0;
- _inventory[_si]._index = 0;
+ for (uint16 slot = INVENTORY_FIRST_ITEM; slot < INVENTORY_MAX_ITEMS; slot++) {
+ _inventory[slot]._id = 0;
+ _inventory[slot]._index = 0;
}
return;
diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp
index 14d8a6ab43..b353dffd28 100644
--- a/engines/parallaction/location.cpp
+++ b/engines/parallaction/location.cpp
@@ -27,13 +27,8 @@
namespace Parallaction {
-void resolveLocationForwards();
-void switchBackground(const char* background, const char* mask);
-
-
void Parallaction::parseLocation(const char *filename) {
-// printf("parseLocation(%s)", filename);
debugC(1, kDebugLocation, "parseLocation('%s')", filename);
uint16 _si = 1;
@@ -43,7 +38,6 @@ void Parallaction::parseLocation(const char *filename) {
fillBuffers(*_locationScript, true);
while (scumm_stricmp(_tokens[0], "ENDLOCATION")) {
-// printf("token[0] = %s", _tokens[0]);
if (!scumm_stricmp(_tokens[0], "LOCATION")) {
// The parameter for location is 'location.mask'.
@@ -163,8 +157,6 @@ void Parallaction::parseLocation(const char *filename) {
}
void Parallaction::resolveLocationForwards() {
-// printf("resolveLocationForwards()");
-// printf("# forwards: %i", _numForwards);
for (uint16 _si = 0; _forwardedCommands[_si]; _si++) {
_forwardedCommands[_si]->u._animation = findAnimation(_forwardedAnimationNames[_si]);
@@ -189,31 +181,21 @@ void Parallaction::freeLocation() {
_localFlagNames = new Table(120);
_localFlagNames->addData("visited");
- debugC(7, kDebugLocation, "freeLocation: localflags names freed");
-
_location._walkNodes.clear();
- debugC(7, kDebugLocation, "freeLocation: walk nodes freed");
// TODO (LIST): helperNode should be rendered useless by the use of a Common::List<>
// to store Zones and Animations. Right now, it holds a list of Zones to be preserved
// but that'll pretty meaningless with a single list approach.
freeZones();
- debugC(7, kDebugLocation, "freeLocation: zones freed");
-
freeAnimations();
- debugC(7, kDebugLocation, "freeLocation: animations freed");
if (_location._comment) {
free(_location._comment);
}
_location._comment = NULL;
- debugC(7, kDebugLocation, "freeLocation: comments freed");
_location._commands.clear();
- debugC(7, kDebugLocation, "freeLocation: commands freed");
-
_location._aCommands.clear();
- debugC(7, kDebugLocation, "freeLocation: acommands freed");
return;
}
@@ -417,7 +399,8 @@ void Parallaction::changeLocation(char *location) {
void Parallaction::doLocationEnterTransition() {
debugC(1, kDebugLocation, "doLocationEnterTransition");
- if (_localFlags[_currentLocationIndex] & kFlagsVisited) return; // visited
+ if (_localFlags[_currentLocationIndex] & kFlagsVisited)
+ return; // visited
byte pal[PALETTE_SIZE];
_gfx->buildBWPalette(pal);
@@ -431,21 +414,15 @@ void Parallaction::doLocationEnterTransition() {
_gfx->swapBuffers();
_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack);
- int16 v7C, v7A;
- _gfx->getStringExtent(_location._comment, 130, &v7C, &v7A);
+ int16 w, h;
+ _gfx->getStringExtent(_location._comment, 130, &w, &h);
- Common::Rect r(10 + v7C, 5 + v7A);
+ Common::Rect r(10 + w, 5 + h);
r.moveTo(5, 5);
_gfx->floodFill(Gfx::kBitFront, r, 0);
r.grow(-1);
_gfx->floodFill(Gfx::kBitFront, r, 1);
_gfx->displayWrappedString(_location._comment, 3, 5, 130, 0);
- // FIXME: ???
-#if 0
- do {
- mouseFunc1();
- } while (_mouseButtons != kMouseLeftUp);
-#endif
_gfx->updateScreen();
waitUntilLeftClick();
@@ -454,9 +431,9 @@ void Parallaction::doLocationEnterTransition() {
// fades maximum intensity palette towards approximation of main palette
for (uint16 _si = 0; _si<6; _si++) {
- waitTime( 1 );
_gfx->quickFadePalette(pal);
_gfx->setPalette(pal);
+ waitTime( 1 );
}
debugC(1, kDebugLocation, "doLocationEnterTransition completed");
@@ -464,8 +441,4 @@ void Parallaction::doLocationEnterTransition() {
return;
}
-void mouseFunc1() {
- // FIXME: implement this
-}
-
} // namespace Parallaction