diff options
author | Nicola Mettifogo | 2007-07-09 19:19:56 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2007-07-09 19:19:56 +0000 |
commit | 945be6e5f220a92e92cf715c80ee72a108cfe9b6 (patch) | |
tree | a02ff212ad28a6702a31db4de8f2b46710773bdf | |
parent | 11b43f877d47965773fa9b0f7127cc22f7000db6 (diff) | |
download | scummvm-rg350-945be6e5f220a92e92cf715c80ee72a108cfe9b6.tar.gz scummvm-rg350-945be6e5f220a92e92cf715c80ee72a108cfe9b6.tar.bz2 scummvm-rg350-945be6e5f220a92e92cf715c80ee72a108cfe9b6.zip |
Moved mouse cursor tampering from inventory.cpp to Gfx class, and some cleanup.
svn-id: r27996
-rw-r--r-- | engines/parallaction/graphics.cpp | 32 | ||||
-rw-r--r-- | engines/parallaction/graphics.h | 6 | ||||
-rw-r--r-- | engines/parallaction/inventory.cpp | 33 | ||||
-rw-r--r-- | engines/parallaction/inventory.h | 11 |
4 files changed, 45 insertions, 37 deletions
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 59645381b6..51ec65f792 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -438,8 +438,8 @@ void Gfx::initMouse(uint16 arg_0) { _mouseComposedArrow = _vm->_disk->loadPointer(); - byte temp[16*16]; - memcpy(temp, _mouseArrow, 16*16); + byte temp[MOUSEARROW_WIDTH*MOUSEARROW_HEIGHT]; + memcpy(temp, _mouseArrow, MOUSEARROW_WIDTH*MOUSEARROW_HEIGHT); uint16 k = 0; for (uint16 i = 0; i < 4; i++) { @@ -449,20 +449,40 @@ void Gfx::initMouse(uint16 arg_0) { return; } +// NOTE: this routine will be moved into Gfx as soon as enough clarity +// is made regarding the field _id and _index of InventoryItem. +// +void extractInventoryGraphics(int16 pos, byte *dst) { +// printf("extractInventoryGraphics(%i)\n", pos); + + + return; +} + + void Gfx::setMousePointer(int16 index) { if (index == kCursorArrow) { // standard mouse pointer - g_system->setMouseCursor(_mouseArrow, 16, 16, 0, 0, 0); + g_system->setMouseCursor(_mouseArrow, MOUSEARROW_WIDTH, MOUSEARROW_HEIGHT, 0, 0, 0); g_system->showMouse(true); } else { // inventory item pointer byte *v8 = _mouseComposedArrow->_data0; - // FIXME: target offseting is not clear - extractInventoryGraphics(index, v8 + 7 + 32 * 7); - g_system->setMouseCursor(v8, 32, 32, 0, 0, 0); + // FIXME: destination offseting is not clear + byte* s = _vm->_char._objs->getFramePtr(getInventoryItemIndex(index)); + byte* d = v8 + 7 + MOUSECOMBO_WIDTH * 7; + + for (uint32 i = 0; i < INVENTORYITEM_HEIGHT; i++) { + memcpy(d, s, INVENTORYITEM_WIDTH); + + s += INVENTORYITEM_PITCH; + d += MOUSECOMBO_WIDTH; + } + + g_system->setMouseCursor(v8, MOUSECOMBO_WIDTH, MOUSECOMBO_HEIGHT, 0, 0, 0); } return; diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index d535d3cf05..05b7dac2ec 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -57,6 +57,12 @@ namespace Parallaction { #define BASE_PALETTE_SIZE BASE_PALETTE_COLORS*3 #define PALETTE_SIZE PALETTE_COLORS*3 +#define MOUSEARROW_WIDTH 16 +#define MOUSEARROW_HEIGHT 16 + +#define MOUSECOMBO_WIDTH 32 // sizes for cursor + selected inventory item +#define MOUSECOMBO_HEIGHT 32 + #include "common/pack-start.h" // START STRUCT PACKING struct PaletteFxRange { diff --git a/engines/parallaction/inventory.cpp b/engines/parallaction/inventory.cpp index d45b831a23..b7ff835dcc 100644 --- a/engines/parallaction/inventory.cpp +++ b/engines/parallaction/inventory.cpp @@ -42,10 +42,6 @@ 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 -#define INVENTORYITEM_HEIGHT 24 - #define INVENTORY_ITEMS_PER_LINE 5 #define INVENTORY_LINES 6 @@ -89,7 +85,6 @@ InventoryItem _inventory[INVENTORY_MAX_ITEMS] = { { 0, 0 } }; -void drawInventoryItem(uint16 pos, InventoryItem *item); int16 getNumUsedSlots() { int16 num = 0; @@ -224,30 +219,14 @@ void highlightInventoryItem(int16 pos, byte color) { } +int16 getInventoryItemIndex(int16 pos) { + // TODO: should assert against the number of items actually contained, + // not the theoretical limit. + assert(pos >= 0 && pos < INVENTORY_MAX_ITEMS); + return _inventory[pos]._index; +} -void extractInventoryGraphics(int16 pos, byte *dst) { -// printf("extractInventoryGraphics(%i)\n", pos); - - // NOTE: this refresh is needed because we are reading graphics data from the - // inventory buffer instead than from the inventory icons storage. - refreshInventory(); - - int16 line = pos / INVENTORY_ITEMS_PER_LINE; - int16 col = pos % INVENTORY_ITEMS_PER_LINE; - - // FIXME: this will end up in a general blit function - byte* d = dst; - byte* s = _buffer + col * INVENTORYITEM_WIDTH + line * _vm->_char._objs->_height * INVENTORY_WIDTH; - for (uint32 i = 0; i < INVENTORYITEM_HEIGHT; i++) { - memcpy(d, s, INVENTORYITEM_WIDTH); - - s += INVENTORY_WIDTH; - d += INVENTORYITEM_PITCH; - } - - return; -} void jobShowInventory(void *parm, Job *j) { // printf("job_showInventory()..."); diff --git a/engines/parallaction/inventory.h b/engines/parallaction/inventory.h index 7b2e93efa7..4a3e07cc97 100644 --- a/engines/parallaction/inventory.h +++ b/engines/parallaction/inventory.h @@ -34,10 +34,14 @@ namespace Parallaction { struct Cnv; struct InventoryItem { - uint32 _id; // lowest 16 bits are always zero - uint16 _index; + uint32 _id; // object name (lowest 16 bits are always zero) + uint16 _index; // index to frame in objs file }; +#define INVENTORYITEM_PITCH 32 +#define INVENTORYITEM_WIDTH 24 +#define INVENTORYITEM_HEIGHT 24 + #define MAKE_INVENTORY_ID(x) (((x) & 0xFFFF) << 16) @@ -50,10 +54,9 @@ void closeInventory(); void cleanInventory(); void addInventoryItem(uint16 item); +int16 getInventoryItemIndex(int16 pos); void highlightInventoryItem(int16 pos, byte color); -void extractInventoryGraphics(int16 pos, byte *dst); - } // namespace Parallaction |