Reimplemented the preliminary Dig features. Implemented actor with many direction. Fixed bomp bug

svn-id: r3661
This commit is contained in:
Vincent Hamm 2002-03-06 09:40:21 +00:00
parent c7d58aca84
commit 474c9e333b
7 changed files with 177 additions and 105 deletions

View file

@ -21,6 +21,7 @@
#include "stdafx.h"
#include "scumm.h"
#include "math.h"
void Scumm::initActor(Actor *a, int mode) {
if (mode==1) {
@ -154,7 +155,13 @@ int Scumm::calcMovementFactor(Actor *a, int newX, int newY) {
a->walkdata.xfrac = 0;
a->walkdata.yfrac = 0;
a->newDirection = getAngleFromPos(XYFactor, YXFactor);
if(_gameId==GID_DIG) {
float temp;
temp = atan2 (XYFactor, -YXFactor);
a->newDirection = normalizeAngle(temp * 1.8e2 / 3.14);
} else {
a->newDirection = getAngleFromPos(XYFactor, YXFactor);
}
return actorWalkStep(a);
}

View file

@ -35,10 +35,39 @@ bool Scumm::akos_hasManyDirections(Actor *a) {
return 0;
}
int Scumm::akos_findManyDirection(int16 ManyDirection, uint16 facing)
{
int32 direction;
int32 temp;
int32 temp_facing;
temp=many_direction_tab[ManyDirection];
direction=temp + ManyDirection * 8;
do{
if(facing>=many_direction_tab[direction+1])
{
if(facing<=many_direction_tab[direction+2])
{
return(temp);
}
}
--temp;
--direction;
}while(temp);
return(temp);
}
int Scumm::akos_frameToAnim(Actor *a, int frame) {
if (akos_hasManyDirections(a)) {
error("akos_frameToAnim: hasManyDirections not supported");
bool ManyDirection;
ManyDirection = akos_hasManyDirections(a);
if (ManyDirection){
frame*=many_direction_tab[ManyDirection];
return akos_findManyDirection(ManyDirection, a->facing) + frame;
} else {
return newDirToOldDir(a->facing) + frame * 4;
}
@ -1082,11 +1111,9 @@ bool Scumm::akos_compare(int a, int b, byte cmd) {
}
int Scumm::getAnimVar(Actor *a, byte var) {
assert(var>=0 && var<=15);
return a->animVariable[var];
}
void Scumm::setAnimVar(Actor *a, byte var, int value) {
assert(var>=0 && var<=15);
a->animVariable[var] = value;
}

165
gfx.cpp
View file

@ -38,7 +38,10 @@ void Scumm::getGraphicsPerformance() {
_vars[VAR_PERFORMANCE_2] = 0;//_scummTimer;
initScreens(0, 16, 320, 144);
if(_gameId == GID_DIG)
initScreens(0, 0, 320, 200);
else
initScreens(0, 16, 320, 144);
}
void Scumm::initScreens(int a, int b, int w, int h) {
@ -2318,92 +2321,92 @@ int Scumm::remapPaletteColor(int r, int g, int b, uint threshold) {
}
void Scumm::drawBomp(BompDrawData *bd) {
byte *dest = bd->out + bd->y * bd->outwidth, *src;
int h = bd->srcheight;
bool inside;
byte *dest = bd->out + bd->y * bd->outwidth, *src;
int h = bd->srcheight;
bool inside;
if (h==0 || bd->srcwidth==0)
return;
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);
inside = (bd->x>=0) && (bd->y>=0) &&
(bd->x <= bd->outwidth - bd->srcwidth) &&
(bd->y <= bd->outheight - bd->srcheight);
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);
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;
uint y = bd->y;
src = bd->dataptr;
do {
byte color;
uint len, num;
uint x;
if ((uint)y >= (uint)bd->outheight) {
src += READ_LE_UINT16(src) + 2;
continue;
}
len = bd->srcwidth;
x = bd->x;
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 */
}
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
}

View file

@ -1165,7 +1165,7 @@ void Scumm::drawEnqueuedObject(EnqueuedObject *eo) {
bdd.out = getResourceAddress(rtBuffer, vs->number+1) + vs->xstart;
bdd.outwidth = 320;
bdd.outheight = vs->height;
bdd.dataptr = bomp + 18;
bdd.dataptr = bomp + 10;
bdd.x = eo->x;
bdd.y = eo->y;
bdd.scale_x = (unsigned char)eo->j;

View file

@ -2692,6 +2692,17 @@ void Scumm::o6_kernelFunction() {
a = derefActorSafe(args[1], "o6_kernelFunction:212");
push(a->frame);
break;
case 215:
if(_extraBoxFlags[args[1]]&0x00FF==0x00C0)
{
push(_extraBoxFlags[args[1]]);
}
else
{
byte* temp = (byte*)getBoxBaseAddr(args[1]);
push((byte)(*(temp+17)));
}
break;
default:
error("o6_kernelFunction: default case %d", args[0]);
}

39
scumm.h
View file

@ -43,6 +43,43 @@ enum {
NUM_ACTORS = 30
};
const uint16 many_direction_tab[18] = {
4,
8,
71,
109,
251,
530,
0,
0,
0,
0,
22,
72,
107,
157,
202,
252,
287,
337 };
const int16 many_direction_tab_2 [16] = {
0,
90,
180,
270,
-1,
-1,
-1,
-1,
0,
45,
90,
135,
180,
225,
270,
315 };
struct Point {
int x,y;
@ -796,6 +833,8 @@ struct Scumm {
char *_exe_name;
char *_gameDataPath;
int akos_findManyDirection(int16 ManyDirection, uint16 facing);
byte _saveLoadFlag;
byte _saveLoadSlot;
bool _saveLoadCompatible;

View file

@ -1117,21 +1117,6 @@ int Scumm::oldDirToNewDir(int dir) {
}
const uint16 many_direction_tab[18] = {
71, 109, 251, 530,
0,
0,
0,
0,
22,72,107,
157,
202,
252,
287,
337
};
int Scumm::numSimpleDirDirections(int dirType) {
return dirType ? 8 : 4;
}
@ -1139,7 +1124,7 @@ int Scumm::numSimpleDirDirections(int dirType) {
/* Convert an angle to a simple direction */
int Scumm::toSimpleDir(int dirType, int dir) {
int num = dirType ? 8 : 4, i;
const uint16 *dirtab = &many_direction_tab[dirType*8];
const uint16 *dirtab = &many_direction_tab[dirType*8+2];
for(i=1;i<num;i++,dirtab++) {
if (dir >= dirtab[0] && dir <= dirtab[1])
return i;