added v1 gfx codec, (not working)

svn-id: r8329
This commit is contained in:
Paweł Kołodziejski 2003-06-05 17:22:15 +00:00
parent 41c03fa082
commit 94bbf1b9a0
5 changed files with 112 additions and 36 deletions

View file

@ -66,7 +66,7 @@ struct TransitionEffect {
#ifdef __PALM_OS__ #ifdef __PALM_OS__
static const TransitionEffect *transitionEffects; static const TransitionEffect *transitionEffects;
#else #else
static const TransitionEffect transitionEffects[5] = { static const TransitionEffect transitionEffects[4] = {
// Iris effect (looks like an opening/closing camera iris) // Iris effect (looks like an opening/closing camera iris)
{ {
13, // Number of iterations 13, // Number of iterations
@ -134,23 +134,6 @@ static const TransitionEffect transitionEffects[5] = {
38, 0, 38, 24, 38, 0, 38, 24,
255, 0, 0, 0 255, 0, 0, 0
} }
},
// Inverse iris effect, specially tailored for V2 games
{
8, // Number of iterations
{
-1, -1, 1, -1,
-1, 1, 1, 1,
-1, -1, -1, 1,
1, -1, 1, 1
},
{
7, 7, 32, 7,
7, 8, 32, 8,
7, 8, 7, 8,
32, 7, 32, 8
}
} }
}; };
#endif #endif
@ -993,7 +976,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi
// dificult to draw only parts of a room/object. We handle the V2 graphics // dificult to draw only parts of a room/object. We handle the V2 graphics
// differently from all other (newer) graphic formats for this reason. // differently from all other (newer) graphic formats for this reason.
// //
if (_vm->_features & GF_AFTER_V2) { if ((_vm->_features & GF_AFTER_V2) && !(_vm->_features & GF_AFTER_V1)) {
if (vs->alloctwobuffers) if (vs->alloctwobuffers)
bgbak_ptr = _vm->getResourceAddress(rtBuffer, vs->number + 5) + (y * _numStrips + x) * 8; bgbak_ptr = _vm->getResourceAddress(rtBuffer, vs->number + 5) + (y * _numStrips + x) * 8;
@ -1138,7 +1121,9 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi
else else
bgbak_ptr = backbuff_ptr; bgbak_ptr = backbuff_ptr;
if (!(_vm->_features & GF_AFTER_V2)) { if (_vm->_features & GF_AFTER_V1) {
drawStripC64Background(bgbak_ptr, stripnr, height);
} else if (!(_vm->_features & GF_AFTER_V2)) {
if (_vm->_features & GF_16COLOR) { if (_vm->_features & GF_16COLOR) {
decodeStripEGA(bgbak_ptr, smap_ptr + READ_LE_UINT16(smap_ptr + stripnr * 2 + 2), height); decodeStripEGA(bgbak_ptr, smap_ptr + READ_LE_UINT16(smap_ptr + stripnr * 2 + 2), height);
} else if (_vm->_features & GF_SMALL_HEADER) { } else if (_vm->_features & GF_SMALL_HEADER) {
@ -1166,7 +1151,10 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi
} }
CHECK_HEAP; CHECK_HEAP;
if (_vm->_features & GF_AFTER_V2) { if (_vm->_features & GF_AFTER_V1) {
mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + y * _numStrips + x + _imgBufOffs[1];
// drawStripC64Mask(mask_ptr, stripnr, height);
} else if (_vm->_features & GF_AFTER_V2) {
// Do nothing here for V2 games - zplane was handled already. // Do nothing here for V2 games - zplane was handled already.
} else if (flag & dbDrawMaskOnAll) { } else if (flag & dbDrawMaskOnAll) {
// Sam & Max uses dbDrawMaskOnAll for things like the inventory // Sam & Max uses dbDrawMaskOnAll for things like the inventory
@ -1351,6 +1339,59 @@ StripTable *Gdi::generateStripTable(const byte *src, int width, int height, Stri
return table; return table;
} }
void Gdi::drawStripC64Background(byte *dst, int stripnr, int height) {
for(int y = 0; y < (height >> 3); y++) {
_C64Colors[3] = (_C64ColorMap[y + stripnr * (height >> 3)] & 7);
for(int i = 0; i < 8; i++) {
for(int j = 7; j >= 0; j--) {
*(dst + (7 - j) + stripnr * 8 + (y * 8 + i) * _vm->_screenWidth) =
_C64Colors[((_C64CharMap[_C64PicMap[y + stripnr * (height >> 3)] * 8 + i] >> (j & 6)) & 3)];
}
}
}
}
void Gdi::drawStripC64Mask(byte *dst, int stripnr, int height) {
for(int y = 0; y < (height / 8); y++) {
for(int i = 0; i < 8; i++) {
for(int j = 7; j >= 0; j--) {
*(dst + (7 - j) + stripnr * 8 + (y * 8 + i) * _vm->_screenWidth) =
((_C64MaskChar[_C64MaskMap[y + stripnr * (height >> 3)] * 8 + i] >> (j & 6)) & 3);
}
}
}
}
void Gdi::decodeC64Gfx(byte *src, byte *dst, int size) {
int x, z;
byte color, run, common[4];
for(z = 0; z < 4; z++) {
common[z] = *src++;
}
x = 0;
while(x < size){
color = *src++;
if (color < 0x40) {
for (z = 0; z <= color; z++) {
dst[x++] = *src++;
}
} else if (color < 0x80) {
color &= 0x3F;
run = *src++;
for (z = 0; z <= color; z++) {
dst[x++] = run;
}
} else {
run = common[(color >> 5) & 3];
color &= 0x1F;
for (z = 0; z <= color; z++) {
dst[x++] = run;
}
}
}
}
void Gdi::decodeStripEGA(byte *dst, const byte *src, int height) { void Gdi::decodeStripEGA(byte *dst, const byte *src, int height) {
byte color = 0; byte color = 0;
@ -2088,14 +2129,6 @@ void Scumm::fadeIn(int effect) {
case 2: case 2:
case 3: case 3:
case 4: case 4:
case 5:
// Some of the transition effects won't work properly unless
// the screen is marked as clean first. At first I thought I
// could safely do this every time fadeIn() was called, but
// that broke the FOA intro. Probably other things as well.
//
// Hopefully it's safe to do it at this point, at least.
virtscr[0].setDirtyRange(0, 0);
transitionEffect(effect - 1); transitionEffect(effect - 1);
break; break;
case 128: case 128:
@ -2140,7 +2173,6 @@ void Scumm::fadeOut(int effect) {
case 2: case 2:
case 3: case 3:
case 4: case 4:
case 5:
transitionEffect(effect - 1); transitionEffect(effect - 1);
break; break;
case 128: case 128:
@ -2214,8 +2246,6 @@ void Scumm::transitionEffect(int a) {
continue; continue;
if (b > bottom) if (b > bottom)
b = bottom; b = bottom;
if (t < 0)
t = 0;
virtscr[0].tdirty[l] = t << 3; virtscr[0].tdirty[l] = t << 3;
virtscr[0].bdirty[l] = (b + 1) << 3; virtscr[0].bdirty[l] = (b + 1) << 3;
} }
@ -2471,6 +2501,25 @@ void Scumm::setupEGAPalette() {
setPalColor(15, 252, 252, 252); setPalColor(15, 252, 252, 252);
} }
void Scumm::setupC64Palette() {
setPalColor( 0, 0, 0, 0);
setPalColor( 1, 252, 252, 252);
setPalColor( 2, 204, 0, 0);
setPalColor( 3, 0, 252, 204);
setPalColor( 4, 252, 0, 252);
setPalColor( 5, 0, 204, 0);
setPalColor( 6, 0, 0, 204);
setPalColor( 7, 252, 252, 252);
setPalColor( 8, 252, 136, 0);
setPalColor( 9, 136, 68, 0);
setPalColor(10, 252, 136, 136);
setPalColor(11, 68, 68, 68);
setPalColor(12, 136, 136, 136);
setPalColor(13, 136, 252, 136);
setPalColor(14, 136, 136, 252);
setPalColor(15, 204, 204, 204);
}
void Scumm::setPaletteFromPtr(const byte *ptr) { void Scumm::setPaletteFromPtr(const byte *ptr) {
int i; int i;
byte *dest, r, g, b; byte *dest, r, g, b;

View file

@ -122,9 +122,15 @@ protected:
bool _zbufferDisabled; bool _zbufferDisabled;
byte _C64Colors[4], _C64CharMap[256 * 8], _C64PicMap[4096], _C64ColorMap[4096];
byte _C64MaskMap[4096], _C64MaskChar[4096];
/* Bitmap decompressors */ /* Bitmap decompressors */
bool decompressBitmap(byte *bgbak_ptr, const byte *src, int numLinesToProcess); bool decompressBitmap(byte *bgbak_ptr, const byte *src, int numLinesToProcess);
void decodeStripEGA(byte *dst, const byte *src, int height); void decodeStripEGA(byte *dst, const byte *src, int height);
void decodeC64Gfx(byte *src, byte *dst, int size);
void drawStripC64Background(byte *dst, int stripnr, int height);
void drawStripC64Mask(byte *dst, int stripnr, int height);
void unkDecodeA(byte *dst, const byte *src, int height); void unkDecodeA(byte *dst, const byte *src, int height);
void unkDecodeA_trans(byte *dst, const byte *src, int height); void unkDecodeA_trans(byte *dst, const byte *src, int height);
void unkDecodeB(byte *dst, const byte *src, int height); void unkDecodeB(byte *dst, const byte *src, int height);

View file

@ -162,7 +162,10 @@ bool Scumm::loadState(int slot, bool compat, SaveFileManager *mgr) {
_completeScreenRedraw = true; _completeScreenRedraw = true;
if (_features & GF_16COLOR) { if (_features & GF_AFTER_V1) {
setupC64Palette();
setDirtyColors(0, 15);
} else if (_features & GF_16COLOR) {
// HACK: There was a time when ScummVM didn't store the // HACK: There was a time when ScummVM didn't store the
// palette in _currentPalette for 16-color games. To avoid // palette in _currentPalette for 16-color games. To avoid
// breaking savegame compatibility, always set up the default // breaking savegame compatibility, always set up the default

View file

@ -841,6 +841,7 @@ protected:
const byte *getPalettePtr(); const byte *getPalettePtr();
void setupEGAPalette(); void setupEGAPalette();
void setupC64Palette();
void setPalette(int pal); void setPalette(int pal);
void setPaletteFromPtr(const byte *ptr); void setPaletteFromPtr(const byte *ptr);
void setPaletteFromRes(); void setPaletteFromRes();

View file

@ -766,7 +766,11 @@ void Scumm::scummInit() {
initScreens(0, 16, _screenWidth, 144); initScreens(0, 16, _screenWidth, 144);
} }
if (_features & GF_16COLOR) { if (_features & GF_AFTER_V1) {
for (i = 0; i < 16; i++)
_shadowPalette[i] = i;
setupC64Palette();
} else if (_features & GF_16COLOR) {
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
_shadowPalette[i] = i; _shadowPalette[i] = i;
setupEGAPalette(); setupEGAPalette();
@ -1397,7 +1401,10 @@ void Scumm::initRoomSubBlocks() {
else else
rmhd = (const RoomHeader *)findResourceData(MKID('RMHD'), roomptr); rmhd = (const RoomHeader *)findResourceData(MKID('RMHD'), roomptr);
if (_features & GF_AFTER_V8) { if (_features & GF_AFTER_V1) {
_roomWidth = roomptr[4] * 8;
_roomHeight = roomptr[5] * 8;
} else if (_features & GF_AFTER_V8) {
_roomWidth = READ_LE_UINT32(&(rmhd->v8.width)); _roomWidth = READ_LE_UINT32(&(rmhd->v8.width));
_roomHeight = READ_LE_UINT32(&(rmhd->v8.height)); _roomHeight = READ_LE_UINT32(&(rmhd->v8.height));
} else if (_features & GF_AFTER_V7) { } else if (_features & GF_AFTER_V7) {
@ -1411,7 +1418,17 @@ void Scumm::initRoomSubBlocks() {
// //
// Find the room image data // Find the room image data
// //
if (_features & GF_OLD_BUNDLE) { if (_features & GF_AFTER_V1) {
_IM00_offs = 0;
for(i = 0; i < 4; i++){
gdi._C64Colors[i] = roomptr[6 + i];
}
gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 10), gdi._C64CharMap, 256 * 8);
gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 12), gdi._C64PicMap, roomptr[4] * roomptr[5]);
gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 14), gdi._C64ColorMap, roomptr[4] * roomptr[5]);
gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 16), gdi._C64MaskMap, roomptr[4] * roomptr[5]);
gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 18), gdi._C64MaskChar, READ_LE_UINT16(roomptr + 18));
} else if (_features & GF_OLD_BUNDLE) {
_IM00_offs = READ_LE_UINT16(roomptr + 0x0A); _IM00_offs = READ_LE_UINT16(roomptr + 0x0A);
if (_features & GF_AFTER_V2) if (_features & GF_AFTER_V2)
_roomStrips = gdi.generateStripTable(roomptr + _IM00_offs, _roomWidth, _roomHeight, _roomStrips); _roomStrips = gdi.generateStripTable(roomptr + _IM00_offs, _roomWidth, _roomHeight, _roomStrips);