diff options
author | Paul Gilbert | 2014-03-15 08:41:17 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-03-15 08:41:17 -0400 |
commit | c9661ca88cbe3554a455c320fe7bcdcb203823a5 (patch) | |
tree | 8330ec65534da44ddb7b12fa9afd8605a7c39be2 /engines | |
parent | 37bb5150d0d2c901b9bb88ec009a348f1de3d5b0 (diff) | |
download | scummvm-rg350-c9661ca88cbe3554a455c320fe7bcdcb203823a5.tar.gz scummvm-rg350-c9661ca88cbe3554a455c320fe7bcdcb203823a5.tar.bz2 scummvm-rg350-c9661ca88cbe3554a455c320fe7bcdcb203823a5.zip |
MADS: Fix off by 1 frame references in srite drawing
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mads/interface.cpp | 6 | ||||
-rw-r--r-- | engines/mads/palette.cpp | 71 | ||||
-rw-r--r-- | engines/mads/palette.h | 3 | ||||
-rw-r--r-- | engines/mads/sequence.cpp | 3 | ||||
-rw-r--r-- | engines/mads/sprites.cpp | 9 |
5 files changed, 53 insertions, 39 deletions
diff --git a/engines/mads/interface.cpp b/engines/mads/interface.cpp index 0c983dc133..8ea8913b69 100644 --- a/engines/mads/interface.cpp +++ b/engines/mads/interface.cpp @@ -53,9 +53,9 @@ void InterfaceSurface::load(const Common::String &resName) { byte *palP = &_vm->_palette->_mainPalette[0]; for (int i = 0; i < 16; ++i, gamePalP++, palP += 3) { - palP[0] = palStream->readByte(); - palP[1] = palStream->readByte(); - palP[2] = palStream->readByte(); + palP[0] = VGA_COLOR_TRANS(palStream->readByte()); + palP[1] = VGA_COLOR_TRANS(palStream->readByte()); + palP[2] = VGA_COLOR_TRANS(palStream->readByte()); *gamePalP |= 1; palStream->skip(3); } diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp index b42fa144e7..9f6e3c77ae 100644 --- a/engines/mads/palette.cpp +++ b/engines/mads/palette.cpp @@ -28,8 +28,6 @@ namespace MADS { -#define VGA_COLOR_TRANS(x) (((((int)(x)) + 1) << 2) - 1) - void RGB6::load(Common::SeekableReadStream *f) { r = VGA_COLOR_TRANS(f->readByte()); g = VGA_COLOR_TRANS(f->readByte()); @@ -573,38 +571,47 @@ void Palette::initPalette() { _rgbList.reset(); } +const uint32 DEFAULT_VGA_PALETTE[PALETTE_COUNT] = { + 0x000000, 0x0000a8, 0x00a800, 0x00a8a8, 0xa80000, 0xa800a8, 0xa85400, 0xa8a8a8, + 0x545454, 0x5454fc, 0x54fc54, 0x54fcfc, 0xfc5454, 0xfc54fc, 0xfcfc54, 0xfcfcfc, + 0x000000, 0x141414, 0x202020, 0x2c2c2c, 0x383838, 0x444444, 0x505050, 0x606060, + 0x707070, 0x808080, 0x909090, 0xa0a0a0, 0xb4b4b4, 0xc8c8c8, 0xe0e0e0, 0xfcfcfc, + 0x0000fc, 0x4000fc, 0x7c00fc, 0xbc00fc, 0xfc00fc, 0xfc00bc, 0xfc007c, 0xfc0040, + 0xfc0000, 0xfc4000, 0xfc7c00, 0xfcbc00, 0xfcfc00, 0xbcfc00, 0x7cfc00, 0x40fc00, + 0x00fc00, 0x00fc40, 0x00fc7c, 0x00fcbc, 0x00fcfc, 0x00bcfc, 0x007cfc, 0x0040fc, + 0x7c7cfc, 0x9c7cfc, 0xbc7cfc, 0xdc7cfc, 0xfc7cfc, 0xfc7cdc, 0xfc7cbc, 0xfc7c9c, + 0xfc7c7c, 0xfc9c7c, 0xfcbc7c, 0xfcdc7c, 0xfcfc7c, 0xdcfc7c, 0xbcfc7c, 0x9cfc7c, + 0x7cfc7c, 0x7cfc9c, 0x7cfcbc, 0x7cfcdc, 0x7cfcfc, 0x7cdcfc, 0x7cbcfc, 0x7c9cfc, + 0xb4b4fc, 0xc4b4fc, 0xd8b4fc, 0xe8b4fc, 0xfcb4fc, 0xfcb4e8, 0xfcb4d8, 0xfcb4c4, + 0xfcb4b4, 0xfcc4b4, 0xfcd8b4, 0xfce8b4, 0xfcfcb4, 0xe8fcb4, 0xd8fcb4, 0xc4fcb4, + 0xb4fcb4, 0xb4fcc4, 0xb4fcd8, 0xb4fce8, 0xb4fcfc, 0xb4e8fc, 0xb4d8fc, 0xb4c4fc, + 0x000070, 0x1c0070, 0x380070, 0x540070, 0x700070, 0x700054, 0x700038, 0x70001c, + 0x700000, 0x701c00, 0x703800, 0x705400, 0x707000, 0x547000, 0x387000, 0x1c7000, + 0x007000, 0x00701c, 0x007038, 0x007054, 0x007070, 0x005470, 0x003870, 0x001c70, + 0x383870, 0x443870, 0x543870, 0x603870, 0x703870, 0x703860, 0x703854, 0x703844, + 0x703838, 0x704438, 0x705438, 0x706038, 0x707038, 0x607038, 0x547038, 0x447038, + 0x387038, 0x387044, 0x387054, 0x387060, 0x387070, 0x386070, 0x385470, 0x384470, + 0x505070, 0x585070, 0x605070, 0x685070, 0x705070, 0x705068, 0x705060, 0x705058, + 0x705050, 0x705850, 0x706050, 0x706850, 0x707050, 0x687050, 0x607050, 0x587050, + 0x507050, 0x507058, 0x507060, 0x507068, 0x507070, 0x506870, 0x506070, 0x505870, + 0x000040, 0x100040, 0x200040, 0x300040, 0x400040, 0x400030, 0x400020, 0x400010, + 0x400000, 0x401000, 0x402000, 0x403000, 0x404000, 0x304000, 0x204000, 0x104000, + 0x004000, 0x004010, 0x004020, 0x004030, 0x004040, 0x003040, 0x002040, 0x001040, + 0x202040, 0x282040, 0x302040, 0x382040, 0x402040, 0x402038, 0x402030, 0x402028, + 0x402020, 0x402820, 0x403020, 0x403820, 0x404020, 0x384020, 0x304020, 0x284020, + 0x204020, 0x204028, 0x204030, 0x204038, 0x204040, 0x203840, 0x203040, 0x202840, + 0x2c2c40, 0x302c40, 0x342c40, 0x3c2c40, 0x402c40, 0x402c3c, 0x402c34, 0x402c30, + 0x402c2c, 0x40302c, 0x40342c, 0x403c2c, 0x40402c, 0x3c402c, 0x34402c, 0x30402c, + 0x2c402c, 0x2c4030, 0x2c4034, 0x2c403c, 0x2c4040, 0x2c3c40, 0x2c3440, 0x2c3040, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000 +}; + void Palette::initVGAPalette(byte *palette) { - int var6 = 0; - int vdx = 0; - int vbx = 0; byte *destP = palette; - - do { - int vdi = (vdx == 1) ? 0x3F : 0x2A; - int var8 = 0; - int varE = vbx; - int var10 = vdx; - do { - vdx = 0; - do { - int vcx = 0; - int var4 = vdx; - do { - *destP++ = VGA_COLOR_TRANS((var8) ? vdi & 0xFF : vbx & 0XFF); - *destP++ = VGA_COLOR_TRANS((var4) ? vdi & 0xFF : vbx & 0XFF); - *destP++ = VGA_COLOR_TRANS((vcx) ? vdi & 0xFF : vbx & 0XFF); - } while (++vcx < 2); - - var6 += 2; - vdx = var4; - } while (++vdx < 2); - } while (++var8 < 2); - - vdx = var10 + 1; - vbx = varE + 21; - } while (vbx < 42); - - palette[19] = 21; + for (int palIndex = 0; palIndex < PALETTE_COUNT; ++palIndex) { + for (int byteCtr = 2; byteCtr >= 0; --byteCtr) + *destP++ = ((DEFAULT_VGA_PALETTE[palIndex] >> (8 * byteCtr)) & 0xff) >> 2; + } } void Palette::setLowRange() { diff --git a/engines/mads/palette.h b/engines/mads/palette.h index 906f62c3f3..1a540755d7 100644 --- a/engines/mads/palette.h +++ b/engines/mads/palette.h @@ -32,6 +32,9 @@ class MADSEngine; #define PALETTE_USAGE_COUNT 4 +//#define VGA_COLOR_TRANS(x) (((((int)(x)) + 1) << 2) - 1) +#define VGA_COLOR_TRANS(x) (x) + struct RGB4 { byte r; byte g; diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp index c7cbf19693..1b4f8a9e6e 100644 --- a/engines/mads/sequence.cpp +++ b/engines/mads/sequence.cpp @@ -188,7 +188,8 @@ void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) { if (!timerEntry._nonFixed) { spriteSlot._position = timerEntry._msgPos; } else { - MSprite *sprite = spriteSet.getFrame(spriteSlot._frameNumber); + assert(spriteSlot._frameNumber > 0); + MSprite *sprite = spriteSet.getFrame(spriteSlot._frameNumber - 1); spriteSlot._position = sprite->_offset; } } diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp index 2d318c5ae2..78743e6a87 100644 --- a/engines/mads/sprites.cpp +++ b/engines/mads/sprites.cpp @@ -246,11 +246,12 @@ void SpriteSlots::drawBackground() { dirtyArea._active = true; dirtyArea.setSpriteSlot(&spriteSlot); - SpriteAsset *asset = scene._sprites[spriteSlot._spritesIndex]; - MSprite *frame = asset->getFrame(spriteSlot._frameNumber); - if (spriteSlot._spriteType == ST_BACKGROUND) { // Background object, so need to draw it + assert(spriteSlot._frameNumber > 0); + SpriteAsset *asset = scene._sprites[spriteSlot._spritesIndex]; + MSprite *frame = asset->getFrame(spriteSlot._frameNumber - 1); + Common::Point pt = spriteSlot._position; if (spriteSlot._scale != -1) { // Adjust the drawing position @@ -315,6 +316,8 @@ void SpriteSlots::drawForeground(MSurface *s) { // Get the sprite frame int frameNumber = slot._frameNumber & 0x7fff; bool flipped = (slot._frameNumber & 0x8000) != 0; + + assert(frameNumber > 0); MSprite *sprite = spriteSet.getFrame(frameNumber - 1); MSurface *spr = sprite; |