aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorjohndoe1232012-10-15 15:06:37 +0000
committerWillem Jan Palenstijn2013-05-08 20:47:07 +0200
commit9858705772f88af82a811979831aa46b107330cd (patch)
tree102a841e62dc33cb36ec38dc13d6d5fe75f9ec17 /engines
parent676c7569f67c8205b701f1b71202e226899ef036 (diff)
downloadscummvm-rg350-9858705772f88af82a811979831aa46b107330cd.tar.gz
scummvm-rg350-9858705772f88af82a811979831aa46b107330cd.tar.bz2
scummvm-rg350-9858705772f88af82a811979831aa46b107330cd.zip
NEVERHOOD: Graphics related changes/fixes:
- Add BitmapFlags enum - Merge unpackSpriteRle and unpackSpriteRleRepl - Implement Y flipping in unpackSpriteRle - Fix Y flipping in AsScene2804CrystalWaves
Diffstat (limited to 'engines')
-rw-r--r--engines/neverhood/gamemodule.cpp4
-rw-r--r--engines/neverhood/graphics.cpp76
-rw-r--r--engines/neverhood/graphics.h3
-rw-r--r--engines/neverhood/module2800.cpp5
-rw-r--r--engines/neverhood/resource.cpp7
5 files changed, 34 insertions, 61 deletions
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp
index afd01f7c0a..ca22c01eca 100644
--- a/engines/neverhood/gamemodule.cpp
+++ b/engines/neverhood/gamemodule.cpp
@@ -358,8 +358,8 @@ void GameModule::startup() {
#if 1
_vm->gameState().which = 0;
- _vm->gameState().sceneNum = 1;
- createModule(2900, 1);
+ _vm->gameState().sceneNum = 2;
+ createModule(2800, -1);
#endif
#if 0
_vm->gameState().sceneNum = 0;
diff --git a/engines/neverhood/graphics.cpp b/engines/neverhood/graphics.cpp
index 84aa3d67da..c5b136f039 100644
--- a/engines/neverhood/graphics.cpp
+++ b/engines/neverhood/graphics.cpp
@@ -207,6 +207,14 @@ int16 TextSurface::getStringWidth(const byte *string, int stringLen) {
// Misc
+enum BitmapFlags {
+ BF_RLE = 1,
+ BF_HAS_DIMENSIONS = 2,
+ BF_HAS_POSITION = 4,
+ BF_HAS_PALETTE = 8,
+ BF_HAS_IMAGE = 16
+};
+
void parseBitmapResource(byte *sprite, bool *rle, NDimensions *dimensions, NPoint *position, byte **palette, byte **pixels) {
uint16 flags;
@@ -215,9 +223,9 @@ void parseBitmapResource(byte *sprite, bool *rle, NDimensions *dimensions, NPoin
sprite += 2;
if (rle)
- *rle = flags & 1;
+ *rle = flags & BF_RLE;
- if (flags & 2) {
+ if (flags & BF_HAS_DIMENSIONS) {
if (dimensions) {
dimensions->width = READ_LE_UINT16(sprite);
dimensions->height = READ_LE_UINT16(sprite + 2);
@@ -228,7 +236,7 @@ void parseBitmapResource(byte *sprite, bool *rle, NDimensions *dimensions, NPoin
dimensions->height = 1;
}
- if (flags & 4) {
+ if (flags & BF_HAS_POSITION) {
if (position) {
position->x = READ_LE_UINT16(sprite);
position->y = READ_LE_UINT16(sprite + 2);
@@ -239,14 +247,14 @@ void parseBitmapResource(byte *sprite, bool *rle, NDimensions *dimensions, NPoin
position->y = 0;
}
- if (flags & 8) {
+ if (flags & BF_HAS_PALETTE) {
if (palette)
*palette = sprite;
sprite += 1024;
} else if (palette)
*palette = NULL;
- if (flags & 0x10) {
+ if (flags & BF_HAS_IMAGE) {
if (pixels)
*pixels = sprite;
} else if (pixels)
@@ -254,17 +262,22 @@ void parseBitmapResource(byte *sprite, bool *rle, NDimensions *dimensions, NPoin
}
-void unpackSpriteRle(byte *source, int width, int height, byte *dest, int destPitch, bool flipX, bool flipY) {
+void unpackSpriteRle(byte *source, int width, int height, byte *dest, int destPitch, bool flipX, bool flipY, byte oldColor, byte newColor) {
- // TODO: Flip Y
+ const bool replaceColors = oldColor != newColor;
int16 rows, chunks;
int16 skip, copy;
+ if (flipY) {
+ dest += destPitch * (height - 1);
+ destPitch = -destPitch;
+ }
+
rows = READ_LE_UINT16(source);
chunks = READ_LE_UINT16(source + 2);
source += 4;
-
+
do {
if (chunks == 0) {
dest += rows * destPitch;
@@ -286,49 +299,10 @@ void unpackSpriteRle(byte *source, int width, int height, byte *dest, int destPi
source += copy;
}
dest += destPitch;
- }
- }
- rows = READ_LE_UINT16(source);
- chunks = READ_LE_UINT16(source + 2);
- source += 4;
- } while (rows > 0);
-
-}
-
-void unpackSpriteRleRepl(byte *source, int width, int height, byte *dest, int destPitch, byte oldColor, byte newColor, bool flipX, bool flipY) {
-
- // TODO: Flip Y
-
- int16 rows, chunks;
- int16 skip, copy;
-
- rows = READ_LE_UINT16(source);
- chunks = READ_LE_UINT16(source + 2);
- source += 4;
-
- do {
- if (chunks == 0) {
- dest += rows * destPitch;
- } else {
- while (rows-- > 0) {
- uint16 rowChunks = chunks;
- while (rowChunks-- > 0) {
- skip = READ_LE_UINT16(source);
- copy = READ_LE_UINT16(source + 2);
- source += 4;
- if (!flipX) {
- for (int xc = 0; xc < copy; xc++) {
- dest[skip + xc] = source[xc] == oldColor ? newColor : source[xc];
- }
- } else {
- byte *flipDest = dest + width - skip - 1;
- for (int xc = 0; xc < copy; xc++) {
- *flipDest-- = source[xc] == oldColor ? newColor : source[xc];
- }
- }
- source += copy;
- }
- dest += destPitch;
+ if (replaceColors)
+ for (int xc = 0; xc < width; xc++)
+ if (dest[xc] == oldColor)
+ dest[xc] = newColor;
}
}
rows = READ_LE_UINT16(source);
diff --git a/engines/neverhood/graphics.h b/engines/neverhood/graphics.h
index 57c22509f8..08357ea8ca 100644
--- a/engines/neverhood/graphics.h
+++ b/engines/neverhood/graphics.h
@@ -160,8 +160,7 @@ protected:
// Misc
void parseBitmapResource(byte *sprite, bool *rle, NDimensions *dimensions, NPoint *position, byte **palette, byte **pixels);
-void unpackSpriteRle(byte *source, int width, int height, byte *dest, int destPitch, bool flipX, bool flipY);
-void unpackSpriteRleRepl(byte *source, int width, int height, byte *dest, int destPitch, byte oldColor, byte newColor, bool flipX, bool flipY);
+void unpackSpriteRle(byte *source, int width, int height, byte *dest, int destPitch, bool flipX, bool flipY, byte oldColor = 0, byte newColor = 0);
void unpackSpriteNormal(byte *source, int width, int height, byte *dest, int destPitch, bool flipX, bool flipY);
int calcDistance(int16 x1, int16 y1, int16 x2, int16 y2);
diff --git a/engines/neverhood/module2800.cpp b/engines/neverhood/module2800.cpp
index 1a51571fa3..28a0eb814a 100644
--- a/engines/neverhood/module2800.cpp
+++ b/engines/neverhood/module2800.cpp
@@ -416,6 +416,7 @@ Scene2801::Scene2801(NeverhoodEngine *vm, Module *parentModule, int which)
SetUpdateHandler(&Scene::update);
if (getGlobalVar(V_RING5_PULLED) == 0) {
+ // Display the disabled radio; only possible when the left door is open
insertStaticSprite(0x0001264C, 100);
}
@@ -627,7 +628,7 @@ uint32 Scene2802::handleMessage(int messageNum, const MessageParam &param, Entit
}
}
break;
- case 0x0002: // TODO Implement button up event
+ case 0x0002:
if (_countdown1 == 0)
_countdownType = 0;
else {
@@ -1545,7 +1546,7 @@ AsScene2804CrystalWaves::AsScene2804CrystalWaves(NeverhoodEngine *vm, uint cryst
_y = kAsScene2804CrystalWavesPoints[crystalIndex].y;
createSurface1(0x840C41F0, 1200);
if (crystalIndex & 1)
- setDoDeltaX(1);
+ setDoDeltaY(1);
setVisible(false);
_needRefresh = true;
SetUpdateHandler(&AnimatedSprite::update);
diff --git a/engines/neverhood/resource.cpp b/engines/neverhood/resource.cpp
index e009ff286e..aff3528b45 100644
--- a/engines/neverhood/resource.cpp
+++ b/engines/neverhood/resource.cpp
@@ -42,11 +42,10 @@ SpriteResource::~SpriteResource() {
void SpriteResource::draw(byte *dest, int destPitch, bool flipX, bool flipY) {
if (_pixels) {
- if (_rle) {
+ if (_rle)
unpackSpriteRle(_pixels, _dimensions.width, _dimensions.height, dest, destPitch, flipX, flipY);
- } else {
+ else
unpackSpriteNormal(_pixels, _dimensions.width, _dimensions.height, dest, destPitch, flipX, flipY);
- }
}
}
@@ -164,7 +163,7 @@ void AnimResource::draw(uint frameIndex, byte *dest, int destPitch, bool flipX,
_width = frameInfo.rect.width;
_height = frameInfo.rect.height;
if (_replEnabled && _replOldColor != _replNewColor)
- unpackSpriteRleRepl(_currSpriteData, _width, _height, dest, destPitch, _replOldColor, _replNewColor, flipX, flipY);
+ unpackSpriteRle(_currSpriteData, _width, _height, dest, destPitch, flipX, flipY, _replOldColor, _replNewColor);
else
unpackSpriteRle(_currSpriteData, _width, _height, dest, destPitch, flipX, flipY);
}