aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKari Salminen2007-06-20 23:56:08 +0000
committerKari Salminen2007-06-20 23:56:08 +0000
commitc8bbb6140f05b14515f132481dbbe5af09bdd4aa (patch)
tree41909c39325cde453a697bbc996f9c7fe46904ff
parent0ebf986a1ff35b4a13ab37485421f9634c032700 (diff)
downloadscummvm-rg350-c8bbb6140f05b14515f132481dbbe5af09bdd4aa.tar.gz
scummvm-rg350-c8bbb6140f05b14515f132481dbbe5af09bdd4aa.tar.bz2
scummvm-rg350-c8bbb6140f05b14515f132481dbbe5af09bdd4aa.zip
Add AGI256-2 support (On top of already present AGI256 support).
AGI256-2 means handling 256 color views/sprites (AGI256 means handling 256 color picture resources). The code can now handle both 16 color and 256 color views/sprites in the same game. FIXME: Background in AGI256-2 demo may be incorrect. svn-id: r27572
-rw-r--r--engines/agi/sprite.cpp12
-rw-r--r--engines/agi/sprite.h2
-rw-r--r--engines/agi/view.cpp16
-rw-r--r--engines/agi/view.h1
4 files changed, 21 insertions, 10 deletions
diff --git a/engines/agi/sprite.cpp b/engines/agi/sprite.cpp
index 7938d05052..3d69968075 100644
--- a/engines/agi/sprite.cpp
+++ b/engines/agi/sprite.cpp
@@ -136,7 +136,7 @@ void SpritesMgr::blitPixel(uint8 *p, uint8 *end, uint8 col, int spr, int width,
}
-int SpritesMgr::blitCel(int x, int y, int spr, ViewCel *c) {
+int SpritesMgr::blitCel(int x, int y, int spr, ViewCel *c, bool agi256_2) {
uint8 *p0, *p, *q = NULL, *end;
int i, j, t, m, col;
int hidden = true;
@@ -162,8 +162,8 @@ int SpritesMgr::blitCel(int x, int y, int spr, ViewCel *c) {
for (i = 0; i < c->height; i++) {
p = p0;
while (*q) {
- col = (*q & 0xf0) >> 4;
- for (j = *q & 0x0f; j; j--, p += 1 - 2 * m) {
+ col = agi256_2 ? *q : (*q & 0xf0) >> 4; // Uses whole byte for color info with AGI256-2
+ for (j = agi256_2 ? 1 : *q & 0x0f; j; j--, p += 1 - 2 * m) { // No RLE with AGI256-2
if (col != t) {
blitPixel(p, end, col, spr, _WIDTH, &hidden);
}
@@ -455,7 +455,7 @@ void SpritesMgr::blitSprites(SpriteList& l) {
Sprite *s = *iter;
objsSaveArea(s);
debugC(8, kDebugLevelSprites, "s->v->entry = %d (prio %d)", s->v->entry, s->v->priority);
- hidden = blitCel(s->xPos, s->yPos, s->v->priority, s->v->celData);
+ hidden = blitCel(s->xPos, s->yPos, s->v->priority, s->v->celData, s->v->viewData->agi256_2);
if (s->v->entry == 0) { /* if ego, update f1 */
_vm->setflag(fEgoInvisible, hidden);
}
@@ -613,7 +613,7 @@ void SpritesMgr::addToPic(int view, int loop, int cel, int x, int y, int pri, in
eraseBoth();
debugC(4, kDebugLevelSprites, "blit_cel (%d, %d, %d, c)", x, y, pri);
- blitCel(x1, y1, pri, c);
+ blitCel(x1, y1, pri, c, _vm->_game.views[view].agi256_2);
/* If margin is 0, 1, 2, or 3, the base of the cel is
* surrounded with a rectangle of the corresponding priority.
@@ -691,7 +691,7 @@ void SpritesMgr::showObj(int n) {
s.buffer = (uint8 *)malloc(s.xSize * s.ySize);
objsSaveArea(&s);
- blitCel(x1, y1, s.xSize, c);
+ blitCel(x1, y1, s.xSize, c, _vm->_game.views[n].agi256_2);
commitBlock(x1, y1, x2, y2);
_vm->messageBox(_vm->_game.views[n].descr);
objsRestoreArea(&s);
diff --git a/engines/agi/sprite.h b/engines/agi/sprite.h
index 2f703e352a..401446249b 100644
--- a/engines/agi/sprite.h
+++ b/engines/agi/sprite.h
@@ -56,7 +56,7 @@ private:
void *poolAlloc(int size);
void poolRelease(void *s);
void blitPixel(uint8 *p, uint8 *end, uint8 col, int spr, int width, int *hidden);
- int blitCel(int x, int y, int spr, ViewCel *c);
+ int blitCel(int x, int y, int spr, ViewCel *c, bool agi256_2);
void objsSaveArea(Sprite *s);
void objsRestoreArea(Sprite *s);
diff --git a/engines/agi/view.cpp b/engines/agi/view.cpp
index f80e4b6447..48e3ca5e3f 100644
--- a/engines/agi/view.cpp
+++ b/engines/agi/view.cpp
@@ -151,6 +151,7 @@ int AgiEngine::decodeView(int n) {
assert(v != NULL);
+ _game.views[n].agi256_2 = (READ_LE_UINT16(v) == 0xf00f); // Detect AGI256-2 views by their header bytes
_game.views[n].descr = READ_LE_UINT16(v + 3) ? (char *)(v + READ_LE_UINT16(v + 3)) : (char *)(v + 3);
/* if no loops exist, return! */
@@ -187,9 +188,18 @@ int AgiEngine::decodeView(int n) {
vc->width = *(v + cofs);
vc->height = *(v + cofs + 1);
- vc->transparency = *(v + cofs + 2) & 0xf;
- vc->mirrorLoop = (*(v + cofs + 2) >> 4) & 0x7;
- vc->mirror = (*(v + cofs + 2) >> 7) & 0x1;
+
+ if (!_game.views[n].agi256_2) {
+ vc->transparency = *(v + cofs + 2) & 0xf;
+ vc->mirrorLoop = (*(v + cofs + 2) >> 4) & 0x7;
+ vc->mirror = (*(v + cofs + 2) >> 7) & 0x1;
+ } else {
+ // Mirroring is disabled for AGI256-2 views because
+ // AGI256-2 uses whole 8 bits for the transparency variable.
+ vc->transparency = *(v + cofs + 2);
+ vc->mirrorLoop = 0;
+ vc->mirror = 0;
+ }
/* skip over width/height/trans|mirror data */
cofs += 3;
diff --git a/engines/agi/view.h b/engines/agi/view.h
index a20d63793a..f2efce0ec3 100644
--- a/engines/agi/view.h
+++ b/engines/agi/view.h
@@ -51,6 +51,7 @@ struct ViewLoop {
struct AgiView {
int numLoops;
struct ViewLoop *loop;
+ bool agi256_2;
char *descr;
uint8 *rdata;
};