moved some utility functions out of class Scumm
svn-id: r4618
This commit is contained in:
parent
150ed1b8c6
commit
1749470ea7
5 changed files with 37 additions and 36 deletions
18
actor.cpp
18
actor.cpp
|
@ -109,7 +109,7 @@ int Scumm::getAngleFromPos(int x, int y)
|
||||||
{
|
{
|
||||||
if (_gameId == GID_DIG) {
|
if (_gameId == GID_DIG) {
|
||||||
double temp = atan2((double)x, (double)-y);
|
double temp = atan2((double)x, (double)-y);
|
||||||
return Scumm::normalizeAngle((int)(temp * 180 / 3.1415926535));
|
return normalizeAngle((int)(temp * 180 / 3.1415926535));
|
||||||
} else {
|
} else {
|
||||||
if (abs(y) * 2 < abs(x)) {
|
if (abs(y) * 2 < abs(x)) {
|
||||||
if (x > 0)
|
if (x > 0)
|
||||||
|
@ -189,7 +189,7 @@ int Actor::remapDirection(int dir)
|
||||||
if (specdir & 0x8000) {
|
if (specdir & 0x8000) {
|
||||||
dir = specdir & 0x3FFF;
|
dir = specdir & 0x3FFF;
|
||||||
} else {
|
} else {
|
||||||
error("getProgrDirChange: special dir not implemented");
|
error("remapDirection: special dir not implemented");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ int Actor::remapDirection(int dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Or 1024 in to signal direction interpolation should be done */
|
/* Or 1024 in to signal direction interpolation should be done */
|
||||||
return Scumm::normalizeAngle(dir) | 1024;
|
return normalizeAngle(dir) | 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Actor::updateActorDirection()
|
int Actor::updateActorDirection()
|
||||||
|
@ -245,12 +245,12 @@ int Actor::updateActorDirection()
|
||||||
|
|
||||||
dirType = _vm->akos_hasManyDirections(this);
|
dirType = _vm->akos_hasManyDirections(this);
|
||||||
|
|
||||||
from = Scumm::toSimpleDir(dirType, facing);
|
from = toSimpleDir(dirType, facing);
|
||||||
dir = remapDirection(newDirection);
|
dir = remapDirection(newDirection);
|
||||||
shouldInterpolate = (dir & 1024);
|
shouldInterpolate = (dir & 1024);
|
||||||
to = Scumm::toSimpleDir(dirType, dir & 1023);
|
to = toSimpleDir(dirType, dir & 1023);
|
||||||
diff = to - from;
|
diff = to - from;
|
||||||
num = Scumm::numSimpleDirDirections(dirType);
|
num = numSimpleDirDirections(dirType);
|
||||||
|
|
||||||
if (shouldInterpolate) {
|
if (shouldInterpolate) {
|
||||||
// Turn left or right, depending on which is shorter.
|
// Turn left or right, depending on which is shorter.
|
||||||
|
@ -266,7 +266,7 @@ int Actor::updateActorDirection()
|
||||||
} else
|
} else
|
||||||
from = to;
|
from = to;
|
||||||
|
|
||||||
dir = Scumm::fromSimpleDir(dirType, from & (num - 1));
|
dir = fromSimpleDir(dirType, from % num);
|
||||||
|
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
@ -464,7 +464,7 @@ void Actor::animateActor(int anim)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
cmd = anim >> 2;
|
cmd = anim >> 2;
|
||||||
dir = Scumm::oldDirToNewDir(anim & 3);
|
dir = oldDirToNewDir(anim & 3);
|
||||||
|
|
||||||
// Convert into old cmd code
|
// Convert into old cmd code
|
||||||
cmd = 0x3F - cmd + 2;
|
cmd = 0x3F - cmd + 2;
|
||||||
|
@ -497,7 +497,7 @@ void Actor::setDirection(int direction)
|
||||||
if (facing == direction)
|
if (facing == direction)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
facing = Scumm::normalizeAngle(direction);
|
facing = normalizeAngle(direction);
|
||||||
|
|
||||||
if (costume == 0)
|
if (costume == 0)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -725,7 +725,7 @@ void CostumeRenderer::proc6_ami()
|
||||||
byte width, height, pcolor;
|
byte width, height, pcolor;
|
||||||
int color;
|
int color;
|
||||||
int step = _scaleIndexXStep;
|
int step = _scaleIndexXStep;
|
||||||
int x;
|
uint x;
|
||||||
uint y;
|
uint y;
|
||||||
uint scrheight;
|
uint scrheight;
|
||||||
|
|
||||||
|
@ -1359,7 +1359,7 @@ void CostumeRenderer::setPalette(byte *palette)
|
||||||
|
|
||||||
void CostumeRenderer::setFacing(uint16 facing)
|
void CostumeRenderer::setFacing(uint16 facing)
|
||||||
{
|
{
|
||||||
_mirror = Scumm::newDirToOldDir(facing) != 0 || (_loaded._ptr[7] & 0x80);
|
_mirror = newDirToOldDir(facing) != 0 || (_loaded._ptr[7] & 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CostumeRenderer::setCostume(int costume)
|
void CostumeRenderer::setCostume(int costume)
|
||||||
|
|
19
scumm.h
19
scumm.h
|
@ -783,16 +783,7 @@ public:
|
||||||
|
|
||||||
uint32 *_classData;
|
uint32 *_classData;
|
||||||
|
|
||||||
static int newDirToOldDir(int dir);
|
|
||||||
static int oldDirToNewDir(int dir);
|
|
||||||
|
|
||||||
static int normalizeAngle(int angle);
|
|
||||||
int getAngleFromPos(int x, int y);
|
int getAngleFromPos(int x, int y);
|
||||||
static int fromSimpleDir(int dirtype, int dir);
|
|
||||||
static int toSimpleDir(int dirtype, int dir);
|
|
||||||
static int numSimpleDirDirections(int dirType);
|
|
||||||
void startAnimActorEx(Actor *a, int frame, int direction);
|
|
||||||
int getProgrDirChange(Actor *a, int mode);
|
|
||||||
|
|
||||||
void walkActors();
|
void walkActors();
|
||||||
void playActorSounds();
|
void playActorSounds();
|
||||||
|
@ -1491,4 +1482,14 @@ void CDECL warning(const char *s, ...);
|
||||||
void CDECL debug(int level, const char *s, ...);
|
void CDECL debug(int level, const char *s, ...);
|
||||||
void checkHeap();
|
void checkHeap();
|
||||||
|
|
||||||
|
/* Direction conversion functions (between old dir and new dir format) */
|
||||||
|
int newDirToOldDir(int dir);
|
||||||
|
int oldDirToNewDir(int dir);
|
||||||
|
|
||||||
|
int normalizeAngle(int angle);
|
||||||
|
int fromSimpleDir(int dirtype, int dir);
|
||||||
|
int toSimpleDir(int dirtype, int dir);
|
||||||
|
int numSimpleDirDirections(int dirType);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
30
scummvm.cpp
30
scummvm.cpp
|
@ -1103,7 +1103,16 @@ void Scumm::destroy()
|
||||||
free(_classData);
|
free(_classData);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Scumm::newDirToOldDir(int dir)
|
const int new_dir_table[4] = {
|
||||||
|
270,
|
||||||
|
90,
|
||||||
|
180,
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
|
const int16 many_direction_tab[16] = {71, 109, 251, 289, -1, -1, -1, -1, 22, 72, 107, 157, 202, 252, 287, 337};
|
||||||
|
|
||||||
|
int newDirToOldDir(int dir)
|
||||||
{
|
{
|
||||||
if (dir >= 71 && dir <= 109)
|
if (dir >= 71 && dir <= 109)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1114,29 +1123,20 @@ int Scumm::newDirToOldDir(int dir)
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int new_dir_table[4] = {
|
int oldDirToNewDir(int dir)
|
||||||
270,
|
|
||||||
90,
|
|
||||||
180,
|
|
||||||
0,
|
|
||||||
};
|
|
||||||
|
|
||||||
int Scumm::oldDirToNewDir(int dir)
|
|
||||||
{
|
{
|
||||||
return new_dir_table[dir];
|
return new_dir_table[dir];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Scumm::numSimpleDirDirections(int dirType)
|
int numSimpleDirDirections(int dirType)
|
||||||
{
|
{
|
||||||
return dirType ? 8 : 4;
|
return dirType ? 8 : 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int16 many_direction_tab[16] = {71, 109, 251, 289, -1, -1, -1, -1, 22, 72, 107, 157, 202, 252, 287, 337};
|
|
||||||
|
|
||||||
|
|
||||||
/* Convert an angle to a simple direction */
|
/* Convert an angle to a simple direction */
|
||||||
int Scumm::toSimpleDir(int dirType, int dir)
|
int toSimpleDir(int dirType, int dir)
|
||||||
{
|
{
|
||||||
int num = dirType ? 8 : 4;
|
int num = dirType ? 8 : 4;
|
||||||
const int16 *dirtab = &many_direction_tab[dirType * 8];
|
const int16 *dirtab = &many_direction_tab[dirType * 8];
|
||||||
|
@ -1149,7 +1149,7 @@ int Scumm::toSimpleDir(int dirType, int dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert a simple direction to an angle */
|
/* Convert a simple direction to an angle */
|
||||||
int Scumm::fromSimpleDir(int dirType, int dir)
|
int fromSimpleDir(int dirType, int dir)
|
||||||
{
|
{
|
||||||
if (!dirType)
|
if (!dirType)
|
||||||
return dir * 90;
|
return dir * 90;
|
||||||
|
@ -1158,7 +1158,7 @@ int Scumm::fromSimpleDir(int dirType, int dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Scumm::normalizeAngle(int angle)
|
int normalizeAngle(int angle)
|
||||||
{
|
{
|
||||||
int temp;
|
int temp;
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ OSystem *OSystem_SDL_create(int gfx_mode, bool full_screen) {
|
||||||
void OSystem_SDL::set_palette(const byte *colors, uint start, uint num) {
|
void OSystem_SDL::set_palette(const byte *colors, uint start, uint num) {
|
||||||
const byte *b = colors;
|
const byte *b = colors;
|
||||||
uint i;
|
uint i;
|
||||||
SDL_Color *base = _cur_pal + start;
|
|
||||||
for(i=0;i!=num;i++) {
|
for(i=0;i!=num;i++) {
|
||||||
fb2gl_palette(i+start,b[0],b[1],b[2]);
|
fb2gl_palette(i+start,b[0],b[1],b[2]);
|
||||||
b += 4;
|
b += 4;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue