diff --git a/actor.cpp b/actor.cpp index bc85cef7c0d..bea7a669e44 100644 --- a/actor.cpp +++ b/actor.cpp @@ -109,7 +109,7 @@ int Scumm::getAngleFromPos(int x, int y) { if (_gameId == GID_DIG) { double temp = atan2((double)x, (double)-y); - return Scumm::normalizeAngle((int)(temp * 180 / 3.1415926535)); + return normalizeAngle((int)(temp * 180 / 3.1415926535)); } else { if (abs(y) * 2 < abs(x)) { if (x > 0) @@ -189,7 +189,7 @@ int Actor::remapDirection(int dir) if (specdir & 0x8000) { dir = specdir & 0x3FFF; } 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 */ - return Scumm::normalizeAngle(dir) | 1024; + return normalizeAngle(dir) | 1024; } int Actor::updateActorDirection() @@ -245,12 +245,12 @@ int Actor::updateActorDirection() dirType = _vm->akos_hasManyDirections(this); - from = Scumm::toSimpleDir(dirType, facing); + from = toSimpleDir(dirType, facing); dir = remapDirection(newDirection); shouldInterpolate = (dir & 1024); - to = Scumm::toSimpleDir(dirType, dir & 1023); + to = toSimpleDir(dirType, dir & 1023); diff = to - from; - num = Scumm::numSimpleDirDirections(dirType); + num = numSimpleDirDirections(dirType); if (shouldInterpolate) { // Turn left or right, depending on which is shorter. @@ -266,7 +266,7 @@ int Actor::updateActorDirection() } else from = to; - dir = Scumm::fromSimpleDir(dirType, from & (num - 1)); + dir = fromSimpleDir(dirType, from % num); return dir; } @@ -464,7 +464,7 @@ void Actor::animateActor(int anim) } else { cmd = anim >> 2; - dir = Scumm::oldDirToNewDir(anim & 3); + dir = oldDirToNewDir(anim & 3); // Convert into old cmd code cmd = 0x3F - cmd + 2; @@ -497,7 +497,7 @@ void Actor::setDirection(int direction) if (facing == direction) return; - facing = Scumm::normalizeAngle(direction); + facing = normalizeAngle(direction); if (costume == 0) return; diff --git a/costume.cpp b/costume.cpp index ad005e823ec..f440c151972 100644 --- a/costume.cpp +++ b/costume.cpp @@ -725,7 +725,7 @@ void CostumeRenderer::proc6_ami() byte width, height, pcolor; int color; int step = _scaleIndexXStep; - int x; + uint x; uint y; uint scrheight; @@ -1359,7 +1359,7 @@ void CostumeRenderer::setPalette(byte *palette) 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) diff --git a/scumm.h b/scumm.h index 29be4fa217b..f65a6b6e704 100644 --- a/scumm.h +++ b/scumm.h @@ -783,16 +783,7 @@ public: uint32 *_classData; - static int newDirToOldDir(int dir); - static int oldDirToNewDir(int dir); - - static int normalizeAngle(int angle); 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 playActorSounds(); @@ -1491,4 +1482,14 @@ void CDECL warning(const char *s, ...); void CDECL debug(int level, const char *s, ...); 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 diff --git a/scummvm.cpp b/scummvm.cpp index e09fdd4e3cc..ae8341dcf44 100644 --- a/scummvm.cpp +++ b/scummvm.cpp @@ -1103,7 +1103,16 @@ void Scumm::destroy() 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) return 1; @@ -1114,29 +1123,20 @@ int Scumm::newDirToOldDir(int dir) return 3; } -const int new_dir_table[4] = { - 270, - 90, - 180, - 0, -}; - -int Scumm::oldDirToNewDir(int dir) +int oldDirToNewDir(int dir) { return new_dir_table[dir]; } -int Scumm::numSimpleDirDirections(int dirType) +int numSimpleDirDirections(int dirType) { 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 */ -int Scumm::toSimpleDir(int dirType, int dir) +int toSimpleDir(int dirType, int dir) { int num = dirType ? 8 : 4; 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 */ -int Scumm::fromSimpleDir(int dirType, int dir) +int fromSimpleDir(int dirType, int dir) { if (!dirType) 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; diff --git a/sdl_gl.cpp b/sdl_gl.cpp index cb4905972c2..ebdbe6398b8 100644 --- a/sdl_gl.cpp +++ b/sdl_gl.cpp @@ -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) { const byte *b = colors; uint i; - SDL_Color *base = _cur_pal + start; + for(i=0;i!=num;i++) { fb2gl_palette(i+start,b[0],b[1],b[2]); b += 4;