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
This commit is contained in:
Kari Salminen 2007-06-20 23:56:08 +00:00
parent 0ebf986a1f
commit c8bbb6140f
4 changed files with 21 additions and 10 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -51,6 +51,7 @@ struct ViewLoop {
struct AgiView {
int numLoops;
struct ViewLoop *loop;
bool agi256_2;
char *descr;
uint8 *rdata;
};