aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood/resource.cpp
diff options
context:
space:
mode:
authorjohndoe1232013-01-17 09:50:10 +0000
committerWillem Jan Palenstijn2013-05-08 20:47:40 +0200
commitf945448c7ba3884cded68314a13aa2132603121d (patch)
tree01287dcf95c60ab21bc35551a1cb6084f7f0c2bc /engines/neverhood/resource.cpp
parent57497817e1f086a62471587e3601d8f0f7d7f13b (diff)
downloadscummvm-rg350-f945448c7ba3884cded68314a13aa2132603121d.tar.gz
scummvm-rg350-f945448c7ba3884cded68314a13aa2132603121d.tar.bz2
scummvm-rg350-f945448c7ba3884cded68314a13aa2132603121d.zip
NEVERHOOD: Change graphic resource draw method to get a Surface instead of separate pixels/pitch
- Merge SpriteResource::load and load2
Diffstat (limited to 'engines/neverhood/resource.cpp')
-rw-r--r--engines/neverhood/resource.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/engines/neverhood/resource.cpp b/engines/neverhood/resource.cpp
index 6cbbf12a25..3350b80e61 100644
--- a/engines/neverhood/resource.cpp
+++ b/engines/neverhood/resource.cpp
@@ -37,8 +37,10 @@ SpriteResource::~SpriteResource() {
unload();
}
-void SpriteResource::draw(byte *dest, int destPitch, bool flipX, bool flipY) {
+void SpriteResource::draw(Graphics::Surface *destSurface, bool flipX, bool flipY) {
if (_pixels) {
+ byte *dest = (byte*)destSurface->pixels;
+ const int destPitch = destSurface->pitch;
if (_rle)
unpackSpriteRle(_pixels, _dimensions.width, _dimensions.height, dest, destPitch, flipX, flipY);
else
@@ -46,27 +48,15 @@ void SpriteResource::draw(byte *dest, int destPitch, bool flipX, bool flipY) {
}
}
-bool SpriteResource::load(uint32 fileHash) {
+bool SpriteResource::load(uint32 fileHash, bool doLoadPosition) {
debug(2, "SpriteResource::load(%08X)", fileHash);
- // TODO: Later merge with load2 and make the mode a parameter
unload();
_vm->_res->queryResource(fileHash, _resourceHandle);
if (_resourceHandle.isValid() && _resourceHandle.type() == kResTypeBitmap) {
_vm->_res->loadResource(_resourceHandle);
const byte *spriteData = _resourceHandle.data();
- parseBitmapResource(spriteData, &_rle, &_dimensions, NULL, NULL, &_pixels);
- }
- return _pixels != NULL;
-}
-
-bool SpriteResource::load2(uint32 fileHash) {
- debug(2, "SpriteResource::load2(%08X)", fileHash);
- unload();
- _vm->_res->queryResource(fileHash, _resourceHandle);
- if (_resourceHandle.isValid() && _resourceHandle.type() == kResTypeBitmap) {
- _vm->_res->loadResource(_resourceHandle);
- const byte *spriteData = _resourceHandle.data();
- parseBitmapResource(spriteData, &_rle, &_dimensions, &_position, NULL, &_pixels);
+ NPoint *position = doLoadPosition ? &_position : NULL;
+ parseBitmapResource(spriteData, &_rle, &_dimensions, position, NULL, &_pixels);
}
return _pixels != NULL;
}
@@ -128,8 +118,10 @@ AnimResource::~AnimResource() {
unload();
}
-void AnimResource::draw(uint frameIndex, byte *dest, int destPitch, bool flipX, bool flipY) {
+void AnimResource::draw(uint frameIndex, Graphics::Surface *destSurface, bool flipX, bool flipY) {
const AnimFrameInfo frameInfo = _frames[frameIndex];
+ byte *dest = (byte*)destSurface->pixels;
+ const int destPitch = destSurface->pitch;
_currSpriteData = _spriteData + frameInfo.spriteDataOffs;
_width = frameInfo.drawOffset.width;
_height = frameInfo.drawOffset.height;
@@ -305,10 +297,12 @@ NDrawRect& MouseCursorResource::getRect() {
return _rect;
}
-void MouseCursorResource::draw(int frameNum, byte *dest, int destPitch) {
+void MouseCursorResource::draw(int frameNum, Graphics::Surface *destSurface) {
if (_cursorSprite.getPixels()) {
- int sourcePitch = (_cursorSprite.getDimensions().width + 3) & 0xFFFC; // 4 byte alignment
+ const int sourcePitch = (_cursorSprite.getDimensions().width + 3) & 0xFFFC; // 4 byte alignment
+ const int destPitch = destSurface->pitch;
const byte *source = _cursorSprite.getPixels() + _cursorNum * (sourcePitch * 32) + frameNum * 32;
+ byte *dest = (byte*)destSurface->pixels;
for (int16 yc = 0; yc < 32; yc++) {
memcpy(dest, source, 32);
source += sourcePitch;