mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
NEVERHOOD: Graphics related changes/fixes:
- Add BitmapFlags enum - Merge unpackSpriteRle and unpackSpriteRleRepl - Implement Y flipping in unpackSpriteRle - Fix Y flipping in AsScene2804CrystalWaves
This commit is contained in:
parent
676c7569f6
commit
9858705772
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 ¶m, 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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user