mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-01 15:09:47 +00:00
Bugfixes and changed field names in the player class to be more explanatory. Implemented Ctrl-T to turn the player - the original game used Ctrl-U, but this is reserved by ScummVM for toggle Mute.
svn-id: r50734
This commit is contained in:
parent
afd2850058
commit
dd5f6f13e2
@ -132,7 +132,7 @@ void MadsGameLogic::initialiseGlobals() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_madsVm->_player._direction = 8;
|
_madsVm->_player._direction = 8;
|
||||||
_madsVm->_player._direction2 = 8;
|
_madsVm->_player._newDirection = 8;
|
||||||
|
|
||||||
// TODO: unknown processing routine getting called for 'RXM' and 'ROX'
|
// TODO: unknown processing routine getting called for 'RXM' and 'ROX'
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ const int MadsPlayer::_directionListIndexes[32] = {
|
|||||||
MadsPlayer::MadsPlayer() {
|
MadsPlayer::MadsPlayer() {
|
||||||
_playerPos = Common::Point(160, 78);
|
_playerPos = Common::Point(160, 78);
|
||||||
_direction = 0;
|
_direction = 0;
|
||||||
_direction2 = 0;
|
_newDirection = 0;
|
||||||
_forceRefresh = true;
|
_forceRefresh = true;
|
||||||
_stepEnabled = true;
|
_stepEnabled = true;
|
||||||
_ticksAmount = 3;
|
_ticksAmount = 3;
|
||||||
@ -46,8 +46,8 @@ MadsPlayer::MadsPlayer() {
|
|||||||
_visible3 = false;
|
_visible3 = false;
|
||||||
_yScale = 0;
|
_yScale = 0;
|
||||||
_moving = false;
|
_moving = false;
|
||||||
|
_spriteListStart = 0;
|
||||||
_spriteListIdx = 0;
|
_spriteListIdx = 0;
|
||||||
_spriteListIdx2 = 0;
|
|
||||||
_spritesChanged = true;
|
_spritesChanged = true;
|
||||||
_currentScale = 0;
|
_currentScale = 0;
|
||||||
strcpy(_spritesPrefix, "");
|
strcpy(_spritesPrefix, "");
|
||||||
@ -93,7 +93,7 @@ bool MadsPlayer::loadSprites(const char *prefix) {
|
|||||||
|
|
||||||
int setIndex = _madsVm->scene()->_spriteSlots.addSprites(setName, true, SPRITE_SET_CHAR_INFO);
|
int setIndex = _madsVm->scene()->_spriteSlots.addSprites(setName, true, SPRITE_SET_CHAR_INFO);
|
||||||
if (setIndex < 0) {
|
if (setIndex < 0) {
|
||||||
if (idx < 7)
|
if (idx < 5)
|
||||||
break;
|
break;
|
||||||
_spriteSetsPresent[idx] = false;
|
_spriteSetsPresent[idx] = false;
|
||||||
} else {
|
} else {
|
||||||
@ -101,7 +101,7 @@ bool MadsPlayer::loadSprites(const char *prefix) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (idx == 0)
|
if (idx == 0)
|
||||||
_spriteListIdx = setIndex;
|
_spriteListStart = setIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
@ -141,7 +141,7 @@ void MadsPlayer::update() {
|
|||||||
MadsSpriteSlot slot;
|
MadsSpriteSlot slot;
|
||||||
slot.spriteType = FOREGROUND_SPRITE;
|
slot.spriteType = FOREGROUND_SPRITE;
|
||||||
slot.seqIndex = PLAYER_SEQ_INDEX;
|
slot.seqIndex = PLAYER_SEQ_INDEX;
|
||||||
slot.spriteListIndex = _spriteListIdx + _spriteListIdx2;
|
slot.spriteListIndex = _spriteListStart + _spriteListIdx;
|
||||||
slot.frameNumber = _frameOffset + _frameNum;
|
slot.frameNumber = _frameOffset + _frameNum;
|
||||||
slot.xp = _playerPos.x;
|
slot.xp = _playerPos.x;
|
||||||
slot.yp = _playerPos.y + (_yScale * newScale) / 100;
|
slot.yp = _playerPos.y + (_yScale * newScale) / 100;
|
||||||
@ -181,7 +181,7 @@ void MadsPlayer::update() {
|
|||||||
* Updates the animation frame for the player
|
* Updates the animation frame for the player
|
||||||
*/
|
*/
|
||||||
void MadsPlayer::updateFrame() {
|
void MadsPlayer::updateFrame() {
|
||||||
SpriteAsset &spriteSet = _madsVm->scene()->_spriteSlots.getSprite(_spriteListIdx + _spriteListIdx2);
|
SpriteAsset &spriteSet = _madsVm->scene()->_spriteSlots.getSprite(_spriteListStart + _spriteListIdx);
|
||||||
assert(spriteSet._charInfo);
|
assert(spriteSet._charInfo);
|
||||||
|
|
||||||
if (!spriteSet._charInfo->_numEntries) {
|
if (!spriteSet._charInfo->_numEntries) {
|
||||||
@ -214,14 +214,14 @@ void MadsPlayer::updateFrame() {
|
|||||||
void MadsPlayer::setupFrame() {
|
void MadsPlayer::setupFrame() {
|
||||||
resetActionList();
|
resetActionList();
|
||||||
_frameOffset = 0;
|
_frameOffset = 0;
|
||||||
_spriteListIdx2 = _directionListIndexes[_direction];
|
_spriteListIdx = _directionListIndexes[_direction];
|
||||||
if (!_spriteSetsPresent[_spriteListIdx2]) {
|
if (!_spriteSetsPresent[_spriteListIdx]) {
|
||||||
// Direction isn't present, so use alternate direction, with entries flipped
|
// Direction isn't present, so use alternate direction, with entries flipped
|
||||||
_spriteListIdx2 -= 4;
|
_spriteListIdx -= 4;
|
||||||
_frameOffset = 0x8000;
|
_frameOffset = 0x8000;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpriteAsset &spriteSet = _madsVm->scene()->_spriteSlots.getSprite(_spriteListIdx + _spriteListIdx2);
|
SpriteAsset &spriteSet = _madsVm->scene()->_spriteSlots.getSprite(_spriteListStart + _spriteListIdx);
|
||||||
assert(spriteSet._charInfo);
|
assert(spriteSet._charInfo);
|
||||||
_unk1 = MAX(spriteSet._charInfo->_unk1, 100);
|
_unk1 = MAX(spriteSet._charInfo->_unk1, 100);
|
||||||
setTicksAmount();
|
setTicksAmount();
|
||||||
@ -238,7 +238,7 @@ void MadsPlayer::setupFrame() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MadsPlayer::step() {
|
void MadsPlayer::step() {
|
||||||
if (_visible && _stepEnabled && !_moving && (_direction == _direction2) && (_madsVm->_currentTimer >= GET_GLOBAL32(2))) {
|
if (_visible && _stepEnabled && !_moving && (_direction == _newDirection) && (_madsVm->_currentTimer >= GET_GLOBAL32(2))) {
|
||||||
if (_actionIndex == 0) {
|
if (_actionIndex == 0) {
|
||||||
int randVal = _vm->_random->getRandomNumber(29999);
|
int randVal = _vm->_random->getRandomNumber(29999);
|
||||||
|
|
||||||
@ -347,7 +347,7 @@ int MadsPlayer::getSpriteSlot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MadsPlayer::setTicksAmount() {
|
void MadsPlayer::setTicksAmount() {
|
||||||
SpriteAsset &spriteSet = _madsVm->scene()->_spriteSlots.getSprite(_spriteListIdx + _spriteListIdx2);
|
SpriteAsset &spriteSet = _madsVm->scene()->_spriteSlots.getSprite(_spriteListStart + _spriteListIdx);
|
||||||
assert(spriteSet._charInfo);
|
assert(spriteSet._charInfo);
|
||||||
_madsVm->_player._ticksAmount = spriteSet._charInfo->_ticksAmount;
|
_madsVm->_player._ticksAmount = spriteSet._charInfo->_ticksAmount;
|
||||||
if (_madsVm->_player._ticksAmount == 0)
|
if (_madsVm->_player._ticksAmount == 0)
|
||||||
@ -363,7 +363,7 @@ void MadsPlayer::resetActionList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int MadsPlayer::queueAction(int action1, int action2) {
|
int MadsPlayer::queueAction(int action1, int action2) {
|
||||||
SpriteAsset &spriteSet = _madsVm->scene()->_spriteSlots.getSprite(_spriteListIdx + _spriteListIdx2);
|
SpriteAsset &spriteSet = _madsVm->scene()->_spriteSlots.getSprite(_spriteListStart + _spriteListIdx);
|
||||||
assert(spriteSet._charInfo);
|
assert(spriteSet._charInfo);
|
||||||
|
|
||||||
if ((action1 < spriteSet._charInfo->_numEntries) && (_actionIndex < 11)) {
|
if ((action1 < spriteSet._charInfo->_numEntries) && (_actionIndex < 11)) {
|
||||||
@ -377,13 +377,13 @@ int MadsPlayer::queueAction(int action1, int action2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MadsPlayer::idle() {
|
void MadsPlayer::idle() {
|
||||||
if (_direction != _direction2) {
|
if (_direction != _newDirection) {
|
||||||
// The direction has changed, so reset for new direction
|
// The direction has changed, so reset for new direction
|
||||||
dirChanged();
|
dirChanged();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpriteAsset &spriteSet = _madsVm->scene()->_spriteSlots.getSprite(_spriteListIdx + _spriteListIdx2);
|
SpriteAsset &spriteSet = _madsVm->scene()->_spriteSlots.getSprite(_spriteListStart + _spriteListIdx);
|
||||||
assert(spriteSet._charInfo);
|
assert(spriteSet._charInfo);
|
||||||
if (spriteSet._charInfo->_numEntries == 0)
|
if (spriteSet._charInfo->_numEntries == 0)
|
||||||
// No entries, so exit immediately
|
// No entries, so exit immediately
|
||||||
@ -418,34 +418,34 @@ void MadsPlayer::dirChanged() {
|
|||||||
int dirIndex = 0, dirIndex2 = 0;
|
int dirIndex = 0, dirIndex2 = 0;
|
||||||
int newDir = 0, newDir2 = 0;
|
int newDir = 0, newDir2 = 0;
|
||||||
|
|
||||||
if (_direction != _direction2) {
|
if (_direction != _newDirection) {
|
||||||
// Find the index for the given direction in the player direction list
|
// Find the index for the given direction in the player direction list
|
||||||
int tempDir = _direction;
|
int tempDir = _direction;
|
||||||
do {
|
do {
|
||||||
++dirIndex;
|
++dirIndex;
|
||||||
newDir += tempDir;
|
newDir += tempDir;
|
||||||
tempDir = _directionListIndexes[tempDir + 10];
|
tempDir = _directionListIndexes[tempDir + 10];
|
||||||
} while (tempDir != _direction2);
|
} while (tempDir != _newDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (_direction != _direction2) {
|
if (_direction != _newDirection) {
|
||||||
// Find the index for the given direction in the player direction list
|
// Find the index for the given direction in the player direction list
|
||||||
int tempDir = _direction;
|
int tempDir = _direction;
|
||||||
do {
|
do {
|
||||||
++dirIndex2;
|
++dirIndex2;
|
||||||
newDir2 += tempDir;
|
newDir2 += tempDir;
|
||||||
tempDir = _directionListIndexes[tempDir + 10];
|
tempDir = _directionListIndexes[tempDir + 20];
|
||||||
} while (tempDir != _direction2);
|
} while (tempDir != _newDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
int diff = dirIndex - dirIndex2;
|
int diff = dirIndex - dirIndex2;
|
||||||
if (diff == 0)
|
if (diff == 0)
|
||||||
diff = newDir - newDir2;
|
diff = newDir - newDir2;
|
||||||
|
|
||||||
_direction = (diff >= 0) ? _directionListIndexes[_direction] : _directionListIndexes[_direction + 10];
|
_direction = (diff >= 0) ? _directionListIndexes[_direction + 20] : _directionListIndexes[_direction + 10];
|
||||||
setupFrame();
|
setupFrame();
|
||||||
if ((_direction == _direction2) && !_moving)
|
if ((_direction == _newDirection) && !_moving)
|
||||||
updateFrame();
|
updateFrame();
|
||||||
|
|
||||||
_priorTimer += 1;
|
_priorTimer += 1;
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
Common::Point _destPos;
|
Common::Point _destPos;
|
||||||
uint32 _priorTimer;
|
uint32 _priorTimer;
|
||||||
uint _ticksAmount;
|
uint _ticksAmount;
|
||||||
int16 _direction, _direction2;
|
int16 _direction, _newDirection;
|
||||||
bool _stepEnabled;
|
bool _stepEnabled;
|
||||||
bool _visible, _priorVisible;
|
bool _visible, _priorVisible;
|
||||||
bool _visible3;
|
bool _visible3;
|
||||||
@ -58,7 +58,7 @@ public:
|
|||||||
int16 _currentScale;
|
int16 _currentScale;
|
||||||
int16 _yScale;
|
int16 _yScale;
|
||||||
int16 _currentDepth;
|
int16 _currentDepth;
|
||||||
int16 _spriteListIdx, _spriteListIdx2;
|
int16 _spriteListStart, _spriteListIdx;
|
||||||
bool _spritesChanged;
|
bool _spritesChanged;
|
||||||
uint16 _frameOffset, _frameNum;
|
uint16 _frameOffset, _frameNum;
|
||||||
bool _moving;
|
bool _moving;
|
||||||
|
@ -165,7 +165,7 @@ void MadsScene::loadScene(int sceneNumber) {
|
|||||||
|
|
||||||
// Miscellaneous player setup
|
// Miscellaneous player setup
|
||||||
_madsVm->_player._destPos = _madsVm->_player._destPos;
|
_madsVm->_player._destPos = _madsVm->_player._destPos;
|
||||||
_madsVm->_player._direction2 = _madsVm->_player._direction;
|
_madsVm->_player._newDirection = _madsVm->_player._direction;
|
||||||
_madsVm->_player.setupFrame();
|
_madsVm->_player.setupFrame();
|
||||||
_madsVm->_player.updateFrame();
|
_madsVm->_player.updateFrame();
|
||||||
|
|
||||||
@ -1192,9 +1192,9 @@ bool MadsInterfaceView::handleKeypress(int32 keycode) {
|
|||||||
warning("TODO: Activate sound");
|
warning("TODO: Activate sound");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Common::KEYCODE_u:
|
case Common::KEYCODE_t:
|
||||||
// Rotate player
|
// Rotate player - This was Ctrl-U in the original, but in ScummVM Ctrl-U is a global mute key
|
||||||
warning("TODO: Rotate player");
|
_madsVm->_player._newDirection = _madsVm->_player._directionListIndexes[_madsVm->_player._newDirection + 10];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Common::KEYCODE_v: {
|
case Common::KEYCODE_v: {
|
||||||
|
Loading…
Reference in New Issue
Block a user