some BOMP support,

some fixes

svn-id: r3506
This commit is contained in:
Ludvig Strigeus 2001-11-27 17:56:04 +00:00
parent 38e2a886ce
commit 1c0a7cd2e7
11 changed files with 141 additions and 32 deletions

View file

@ -55,7 +55,7 @@ void Scumm::initActor(Actor *a, int mode) {
setActorWalkSpeed(a, 8, 2);
a->ignoreBoxes = 0;
a->neverZClip = 0;
a->forceClip = 0;
a->new_3 = 0;
a->initFrame = 1;
a->walkFrame = 2;
@ -773,6 +773,7 @@ void Scumm::processActors() {
a = *ac;
if (a->costume) {
CHECK_HEAP
getMaskFromBox(a->walkbox);
drawActorCostume(a);
CHECK_HEAP
actorAnimate(a);
@ -786,8 +787,8 @@ void Scumm::setupCostumeRenderer(CostumeRenderer *c, Actor *a) {
c->_zbuf = a->mask;
if (c->_zbuf > gdi._numZBuffer)
c->_zbuf = (byte)gdi._numZBuffer;
if (a->neverZClip)
c->_zbuf = a->neverZClip;
if (a->forceClip)
c->_zbuf = a->forceClip;
c->_scaleX = a->scalex;
c->_scaleY = a->scaley;
@ -1024,6 +1025,7 @@ void Scumm::startWalkActor(Actor *a, int x, int y, int dir) {
a->walkdata.destbox = (byte)abr.dist; /* a box */
a->walkdata.destdir = dir;
a->moving = (a->moving&2)|1;
a->walkdata.curbox = a->walkbox;
}
byte *Scumm::getActorName(Actor *a) {

View file

@ -384,6 +384,7 @@ const byte default_scale_table[768] = {
0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF,
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFE,
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
@ -416,6 +417,7 @@ const byte default_scale_table[768] = {
0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF,
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFE,
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,

View file

@ -198,7 +198,7 @@ void ScummDebugger::printActors(int act) {
a = &_s->actor[i];
if (a->visible)
printf("|%2d|%4d|%3d %3d|%4d|%3d|%5d|%3d|%3d|%2d|%5d|%5d|%3d|%3d|\n",
i,a->room,a->x,a->y,a->elevation,a->costume,a->width,a->walkbox,a->moving,a->neverZClip,a->frame,a->scalex,a->speedx,a->facing);
i,a->room,a->x,a->y,a->elevation,a->costume,a->width,a->walkbox,a->moving,a->forceClip,a->frame,a->scalex,a->speedx,a->facing);
}
}
printf("+--------------------------------------------------------------+\n");

91
gfx.cpp
View file

@ -1999,3 +1999,94 @@ int Scumm::remapPaletteColor(byte r, byte g, byte b, uint threshold) {
void Scumm::setupShadowPalette(int slot,int rfact,int gfact,int bfact,int from,int to) {
}
void Scumm::drawBomp(BompDrawData *bd) {
byte *dest = bd->out + bd->y * bd->outwidth, *src;
int h = bd->srcheight;
bool inside;
if (h==0 || bd->srcwidth==0)
return;
inside = (bd->x>=0) && (bd->y>=0) &&
(bd->x <= bd->outwidth - bd->srcwidth) &&
(bd->y <= bd->outheight - bd->srcheight);
assert(_objs[2].obj_nr == 36);
if (1 || bd->scale_x==255 && bd->scale_y==255) {
/* Routine used when no scaling is needed */
if (inside) {
dest += bd->x;
src = bd->dataptr;
do {
byte code,color;
uint len = bd->srcwidth, num, i;
byte *d = dest;
src += 2;
do {
code = *src++;
num = (code>>1)+1;
if (num>len) num=len;
len -= num;
if (code&1) {
color = *src++;
if (color!=255) {
do *d++ = color; while (--num);
} else {
d += num;
}
} else {
for(i=0;i<num; i++)
if ( (color=src[i]) != 255)
d[i] = color;
d += num;
src += num;
}
} while (len);
dest += bd->outwidth;
} while (--h);
} else {
uint y = bd->y;
src = bd->dataptr;
do {
byte color,code;
uint len, num;
uint x;
if ((uint)y >= (uint)bd->outheight) {
src += READ_LE_UINT16(src) + 2;
continue;
}
len = bd->srcwidth;
x = bd->x;
src += 2;
do {
byte code = *src++;
num = (code>>1)+1;
if (num>len) num=len;
len -= num;
if (code&1) {
if ((color = *src++)!=255) {
do {
if ((uint)x < (uint)bd->outwidth)
dest[x] = color;
} while (++x,--num);
} else {
x += num;
}
} else {
do {
if ((color=*src++) != 255 && (uint)x < (uint)bd->outwidth)
dest[x] = color;
} while (++x,--num);
}
} while (len);
} while (dest += bd->outwidth,y++,--h);
}
} else {
/* scaling of bomp images not supported yet */
}
CHECK_HEAP
assert(_objs[2].obj_nr == 36);
}

View file

@ -232,7 +232,7 @@ void Scumm::drawRoomObjects(int arg) {
for(i=1; i<=_numObjectsInRoom; i++) {
od = &_objs[i];
if (!od->obj_nr || !od->state || od->fl_object_index)
if (!od->obj_nr || !od->state)
continue;
do {
a = od->parentstate;
@ -921,6 +921,8 @@ void Scumm::drawEnqueuedObject(EnqueuedObject *eo) {
int x,y;
byte *dataptr;
BompDrawData bdd;
vs = &virtscr[0];
_lastXstart = vs->xstart;
@ -928,35 +930,40 @@ void Scumm::drawEnqueuedObject(EnqueuedObject *eo) {
if (eo->l==0) {
roomptr = getResourceAddress(1, _roomResource);
index = getObjectIndex(eo->a);
assert(index != -1);
ptr = roomptr + _objs[index].offs_obim_to_room;
} else if (eo->a!=0) {
od = &_objs[getObjectIndex(eo->a)];
ptr = getResourceAddress(rtFlObject, od->fl_object_index);
assert(ptr);
ptr = findResource(MKID('OBIM'), ptr);
} else {
warning("drawEnqueuedObject: invalid");
return;
}
assert(ptr);
ptr = findResource(MKID('IM01'), ptr);
assert(ptr);
bomp = findResource(MKID('BOMP'), ptr);
width = READ_LE_UINT16(&((BompHeader*)bomp)->width);
height = READ_LE_UINT16(&((BompHeader*)bomp)->height);
bdd.srcwidth = READ_LE_UINT16(&((BompHeader*)bomp)->width);
bdd.srcheight = READ_LE_UINT16(&((BompHeader*)bomp)->height);
outptr = getResourceAddress(rtBuffer, vs->number+1) + vs->xstart;
bdd.out = getResourceAddress(rtBuffer, vs->number+1) + vs->xstart;
bdd.outwidth = 320;
bdd.outheight = vs->height;
bdd.dataptr = bomp + 18;
bdd.x = eo->x;
bdd.y = eo->y;
bdd.scale_x = eo->j;
bdd.scale_y = eo->k;
x = eo->x;
y = eo->y;
updateDirtyRect(vs->number, bdd.x, bdd.x+bdd.srcwidth, bdd.y, bdd.y+bdd.srcheight, 0);
if (eo->a) {
dataptr = bomp + 18;
drawBomp(&bdd);
}
// debug(1, "drawEnqueuedObject(%d,%d,%d,%d,%d, %d,%d,%d,%d,%d,%d,%d)",
// eo->x, eo->y, eo->width, eo->height, eo->a, eo->b, eo->c, eo->d, eo->e, eo->j, eo->k, eo->l);
updateDirtyRect(vs->number, x, x+width,y,y+height,0);
}
void Scumm::removeEnqueuedObjects() {

View file

@ -223,7 +223,7 @@ void Scumm::saveOrLoad(Serializer *s) {
MKLINE(Actor,newDirection,sleUint16),
MKLINE(Actor,moving,sleByte),
MKLINE(Actor,ignoreBoxes,sleByte),
MKLINE(Actor,neverZClip,sleByte),
MKLINE(Actor,forceClip,sleByte),
MKLINE(Actor,initFrame,sleByte),
MKLINE(Actor,walkFrame,sleByte),
MKLINE(Actor,standFrame,sleByte),

View file

@ -439,21 +439,21 @@ void Scumm::o5_actorSet() {
a->needBgReset = true;
break;
case 18: /* neverzclip */
a->neverZClip = 0;
a->forceClip = 0;
break;
case 19: /* setzclip */
a->neverZClip = getVarOrDirectByte(0x80);
a->forceClip = getVarOrDirectByte(0x80);
break;
case 20: /* ignoreboxes */
a->ignoreBoxes = 1;
a->neverZClip = 0;
a->forceClip = 0;
FixRoom:
if (a->room==_currentRoom)
putActor(a, a->x, a->y, a->room);
break;
case 21: /* followboxes */
a->ignoreBoxes = 0;
a->neverZClip = 0;
a->forceClip = 0;
goto FixRoom;
case 22: /* animspeed */

View file

@ -729,7 +729,7 @@ void Scumm::o6_cursorCommand() {
break;
case 0x99:
a = pop();
setCursorImg(a, pop(), 1);
setCursorImg(pop(), a, 1);
break;
case 0x9A:
a = pop();
@ -1475,22 +1475,22 @@ void Scumm::o6_actorSet() {
a->needBgReset = true;
break;
case 93:
a->neverZClip = 0;
a->forceClip = 0;
break;
case 225:
case 94:
a->neverZClip = pop();
a->forceClip = pop();
break;
case 95:
a->ignoreBoxes = 1;
a->neverZClip = 0;
a->forceClip = 0;
FixRooms:;
if (a->room==_currentRoom)
putActor(a, a->x, a->y, a->room);
break;
case 96:
a->ignoreBoxes = 0;
a->neverZClip = 0;
a->forceClip = 0;
goto FixRooms;
case 97:
a->animSpeed = pop();

14
scumm.h
View file

@ -632,6 +632,15 @@ struct AkosRenderer {
byte palette[256];
};
struct BompDrawData {
byte *out;
int outwidth, outheight;
int x,y;
byte scale_x, scale_y;
byte *dataptr;
int srcwidth, srcheight;
};
struct CostumeRenderer {
Scumm *_vm;
byte *_ptr;
@ -702,7 +711,7 @@ struct Actor {
int16 newDirection;
byte moving;
byte ignoreBoxes;
byte neverZClip;
byte forceClip;
byte initFrame,walkFrame,standFrame,talkFrame1,talkFrame2;
bool needRedraw, needBgReset,costumeNeedsInit,visible;
byte unk1;
@ -2004,6 +2013,8 @@ struct Scumm {
int cost_frameToAnim(Actor *a, int frame);
void setupShadowPalette(int slot,int rfact,int gfact,int bfact,int from,int to);
void drawBomp(BompDrawData *bd);
};
enum AkosOpcodes{
@ -2111,6 +2122,7 @@ struct Serializer {
};
extern const uint32 IMxx_tags[];
extern const byte default_scale_table[768];
void outputdisplay2(Scumm *s, int disp);
extern const byte revBitMask[8];

View file

@ -75,9 +75,6 @@ void waitForTimer(Scumm *s, int msec_delay) {
SDL_Event event;
uint32 start_time;
if (msec_delay<0)
return;
if (s->_fastMode&2)
msec_delay = 0;
else if (s->_fastMode&1)

View file

@ -138,8 +138,6 @@ void Scumm::startTalkSound(uint32 offset, uint32 b, int mode) {
byte file_byte,file_byte_2;
uint16 elem;
return;
if (!_sfxFile) {
warning("startTalkSound: SFX file is not open");
return;