[Scummvm-cvs-logs] SF.net SVN: scummvm: [26123] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Tue Mar 13 21:41:40 CET 2007
Revision: 26123
http://scummvm.svn.sourceforge.net/scummvm/?rev=26123&view=rev
Author: peres001
Date: 2007-03-13 13:41:40 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Moved inventory surface management into inventory.cpp, thus removing Graphics::kBit3. Some duplicated code now exists in graphics.cpp and inventory.cpp.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/graphics.cpp
scummvm/trunk/engines/parallaction/graphics.h
scummvm/trunk/engines/parallaction/inventory.cpp
Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp 2007-03-13 20:08:31 UTC (rev 26122)
+++ scummvm/trunk/engines/parallaction/graphics.cpp 2007-03-13 20:41:40 UTC (rev 26123)
@@ -25,7 +25,6 @@
#include "parallaction/graphics.h"
#include "parallaction/parser.h"
#include "parallaction/parallaction.h"
-#include "parallaction/inventory.h"
#include "parallaction/disk.h"
#include "parallaction/zone.h"
@@ -312,7 +311,6 @@
return;
}
-
void Gfx::copyRect(Gfx::Buffers srcbuffer, uint16 sx, uint16 sy, Gfx::Buffers dstbuffer, uint16 dx, uint16 dy, uint16 w, uint16 h) {
byte *s = _buffers[srcbuffer] + (sx + sy * SCREEN_WIDTH);
@@ -957,23 +955,6 @@
}
-void Gfx::drawBorder(Gfx::Buffers buffer, uint16 x, uint16 y, uint16 w, uint16 h, byte color) {
-
- byte *d = _buffers[buffer] + x + SCREEN_WIDTH * y;
-
- memset(d, color, w);
-
- for (uint16 i = 0; i < h; i++) {
- d[i * SCREEN_WIDTH] = color;
- d[i * SCREEN_WIDTH + w - 1] = color;
- }
-
- d = _buffers[buffer] + x + SCREEN_WIDTH * (y + h - 1);
- memset(d, color, w);
-
- return;
-}
-
void Gfx::grabRect(Gfx::Buffers srcbuffer, byte *dst, uint16 x, uint16 y, uint16 w, uint16 h, uint16 pitch) {
byte *s = _buffers[srcbuffer] + x + SCREEN_WIDTH * y;
@@ -1035,8 +1016,6 @@
_buffers[kBitFront] = (byte*)malloc(SCREEN_SIZE);
_buffers[kBitBack] = (byte*)malloc(SCREEN_SIZE);
_buffers[kBit2] = (byte*)malloc(SCREEN_SIZE);
- _buffers[kBit3] = (byte*)malloc(SCREEN_SIZE); // this buffer is also used by menu so it must stay this size
-
_buffers[kMask0] = (byte*)malloc(SCREENMASK_WIDTH * SCREEN_HEIGHT);
return;
@@ -1073,7 +1052,6 @@
free(_buffers[kBitFront]);
free(_buffers[kBitBack]);
free(_buffers[kBit2]);
- free(_buffers[kBit3]);
freeCnv(&_font);
Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h 2007-03-13 20:08:31 UTC (rev 26122)
+++ scummvm/trunk/engines/parallaction/graphics.h 2007-03-13 20:41:40 UTC (rev 26123)
@@ -72,7 +72,6 @@
kBitFront,
kBitBack,
kBit2,
- kBit3,
// mask buffers
kMask0
};
Modified: scummvm/trunk/engines/parallaction/inventory.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/inventory.cpp 2007-03-13 20:08:31 UTC (rev 26122)
+++ scummvm/trunk/engines/parallaction/inventory.cpp 2007-03-13 20:41:40 UTC (rev 26123)
@@ -31,8 +31,7 @@
namespace Parallaction {
//
-// inventory is kept in Gfx::kBit3 at 0 offset
-// it is a grid made of (at most) 30 cells, 24x24 pixels each,
+// inventory is a grid made of (at most) 30 cells, 24x24 pixels each,
// arranged in 6 lines
//
// inventory items are stored in cnv files in a 32x24 grid
@@ -51,9 +50,10 @@
#define INVENTORY_WIDTH (INVENTORY_ITEMS_PER_LINE*INVENTORYITEM_WIDTH)
#define INVENTORY_HEIGHT (INVENTORY_LINES*INVENTORYITEM_HEIGHT)
-extern Cnv _yourObjects;
-uint16 _numInvLines = 0;
-static Point _invPosition = { 0, 0 };
+static byte *_buffer;
+extern Cnv _yourObjects;
+uint16 _numInvLines = 0;
+static Point _invPosition = { 0, 0 };
InventoryItem _inventory[INVENTORY_MAX_ITEMS] = {
{ kZoneDoor, 1 }, // open/close icon
@@ -187,20 +187,36 @@
uint16 line = pos / INVENTORY_ITEMS_PER_LINE;
uint16 col = pos % INVENTORY_ITEMS_PER_LINE;
- _vm->_gfx->copyRect(
- Gfx::kBit3,
- col * INVENTORYITEM_WIDTH,
- line * _yourObjects._height,
- INVENTORYITEM_WIDTH,
- _yourObjects._height,
- _yourObjects._array[item->_index],
- INVENTORYITEM_PITCH
- );
+ // FIXME: this will end up in a general blit function
+ byte* s = _yourObjects._array[item->_index];
+ byte* d = _buffer + col * INVENTORYITEM_WIDTH + line * _yourObjects._height * INVENTORY_WIDTH;
+ for (uint32 i = 0; i < INVENTORYITEM_HEIGHT; i++) {
+ memcpy(d, s, INVENTORYITEM_WIDTH);
+ d += INVENTORY_WIDTH;
+ s += INVENTORYITEM_PITCH;
+ }
+
return;
}
+void drawBorder(const Common::Rect& r, byte *buffer, byte color) {
+ byte *d = buffer + r.left + INVENTORY_WIDTH * r.top;
+
+ memset(d, color, r.width());
+
+ for (uint16 i = 0; i < r.height(); i++) {
+ d[i * INVENTORY_WIDTH] = color;
+ d[i * INVENTORY_WIDTH + r.width() - 1] = color;
+ }
+
+ d = buffer + r.left + INVENTORY_WIDTH * (r.bottom - 1);
+ memset(d, color, r.width());
+
+ return;
+}
+
//
// draws a color border around the specified position in the inventory
//
@@ -213,15 +229,11 @@
uint16 line = pos / INVENTORY_ITEMS_PER_LINE;
uint16 col = pos % INVENTORY_ITEMS_PER_LINE;
- _vm->_gfx->drawBorder(
- Gfx::kBit3,
- col * INVENTORYITEM_WIDTH,
- line * _yourObjects._height,
- INVENTORYITEM_WIDTH,
- _yourObjects._height,
- color
- );
+ Common::Rect r(INVENTORYITEM_WIDTH, _yourObjects._height);
+ r.moveTo(col * INVENTORYITEM_WIDTH, line * _yourObjects._height);
+ drawBorder(r, _buffer, color);
+
return;
}
@@ -234,16 +246,16 @@
int16 line = pos / INVENTORY_ITEMS_PER_LINE;
int16 col = pos % INVENTORY_ITEMS_PER_LINE;
- _vm->_gfx->grabRect(
- Gfx::kBit3,
- dst,
- col * INVENTORYITEM_WIDTH,
- line * _yourObjects._height,
- INVENTORYITEM_WIDTH,
- _yourObjects._height,
- INVENTORYITEM_PITCH
- );
+ // FIXME: this will end up in a general blit function
+ byte* d = dst;
+ byte* s = _buffer + col * INVENTORYITEM_WIDTH + line * _yourObjects._height * INVENTORY_WIDTH;
+ for (uint32 i = 0; i < INVENTORYITEM_HEIGHT; i++) {
+ memcpy(d, s, INVENTORYITEM_WIDTH);
+ s += INVENTORY_WIDTH;
+ d += INVENTORYITEM_PITCH;
+ }
+
return;
}
@@ -257,19 +269,15 @@
_numInvLines = (_numInvLines + 4) / INVENTORY_ITEMS_PER_LINE;
_vm->_gfx->copyRect(
- Gfx::kBit3,
- 0,
- 0,
Gfx::kBitBack,
_invPosition._x,
_invPosition._y,
INVENTORY_WIDTH,
- _numInvLines * INVENTORYITEM_HEIGHT
+ _numInvLines * INVENTORYITEM_HEIGHT,
+ _buffer,
+ INVENTORY_WIDTH
);
-
-// printf("done\n");
-
return;
}
@@ -355,6 +363,7 @@
}
void initInventory() {
+ _buffer = (byte*)malloc(INVENTORY_WIDTH * INVENTORY_HEIGHT); // this buffer is also used by menu so it must stay this size
_yourObjects._count = 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list