mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 14:18:37 +00:00
TWINE: use constants for magic values
This commit is contained in:
parent
2cfad1618f
commit
9eb0c1fd10
@ -49,9 +49,9 @@ void Sound::setSamplePosition(int32 channelIdx, int32 x, int32 y, int32 z) {
|
||||
if (channelIdx < 0 || channelIdx >= NUM_CHANNELS) {
|
||||
return;
|
||||
}
|
||||
const int32 camX = _engine->_grid->newCameraX * 512;
|
||||
const int32 camY = _engine->_grid->newCameraY * 256;
|
||||
const int32 camZ = _engine->_grid->newCameraZ * 512;
|
||||
const int32 camX = _engine->_grid->newCameraX * BRICK_SIZE;
|
||||
const int32 camY = _engine->_grid->newCameraY * BRICK_HEIGHT;
|
||||
const int32 camZ = _engine->_grid->newCameraZ * BRICK_SIZE;
|
||||
int32 distance = _engine->_movements->getDistance3D(camX, camY, camZ, x, y, z);
|
||||
distance = _engine->_collision->getAverageValue(0, distance, 10000, 255);
|
||||
const byte targetVolume = CLIP<byte>(255 - distance, 0, 255);
|
||||
|
@ -717,7 +717,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
|
||||
if (brickShape != ShapeType::kSolid) {
|
||||
_engine->_collision->reajustActorPosition(brickShape);
|
||||
} /*else { // this shouldn't happen (collision should avoid it)
|
||||
actor->y = processActorY = (processActorY / 256) * 256 + 256; // go upper
|
||||
actor->y = processActorY = (processActorY / BRICK_HEIGHT) * BRICK_HEIGHT + BRICK_HEIGHT; // go upper
|
||||
}*/
|
||||
}
|
||||
|
||||
@ -777,7 +777,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
|
||||
if (brickShape == ShapeType::kSolid) {
|
||||
if (actor->dynamicFlags.bIsFalling) {
|
||||
_engine->_collision->stopFalling();
|
||||
_engine->_movements->processActorY = (_engine->_collision->collisionY * 256) + 256;
|
||||
_engine->_movements->processActorY = (_engine->_collision->collisionY * BRICK_HEIGHT) + BRICK_HEIGHT;
|
||||
} else {
|
||||
if (IS_HERO(actorIdx) && _engine->_actor->heroBehaviour == HeroBehaviourType::kAthletic && actor->anim == AnimationTypes::kForward && _engine->cfgfile.WallCollision) { // avoid wall hit damage
|
||||
_engine->_extra->addExtraSpecial(actor->x, actor->y + 1000, actor->z, ExtraSpecialType::kHitStars);
|
||||
|
@ -112,9 +112,9 @@ void Collision::reajustActorPosition(ShapeType brickShape) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int32 brkX = (collisionX * 512) - 256;
|
||||
const int32 brkY = collisionY * 256;
|
||||
const int32 brkZ = (collisionZ * 512) - 256;
|
||||
const int32 brkX = (collisionX * BRICK_SIZE) - BRICK_HEIGHT;
|
||||
const int32 brkY = collisionY * BRICK_HEIGHT;
|
||||
const int32 brkZ = (collisionZ * BRICK_SIZE) - BRICK_HEIGHT;
|
||||
|
||||
// double-side stairs
|
||||
if (brickShape >= ShapeType::kDoubleSideStairsTop1 && brickShape <= ShapeType::kDoubleSideStairsRight2) {
|
||||
|
@ -862,7 +862,7 @@ void Extra::processExtras() {
|
||||
|
||||
if (process) {
|
||||
const BoundingBox *bbox = _engine->_resources->spriteBoundingBox.bbox(extra->info0);
|
||||
extra->y = (_engine->_collision->collisionY * 256) + 256 - bbox->mins.y;
|
||||
extra->y = (_engine->_collision->collisionY * BRICK_HEIGHT) + BRICK_HEIGHT - bbox->mins.y;
|
||||
extra->type &= ~(ExtraType::STOP_COL | ExtraType::FLY);
|
||||
continue;
|
||||
}
|
||||
|
@ -268,9 +268,9 @@ bool GameState::saveGame(Common::WriteStream *file) {
|
||||
}
|
||||
|
||||
void GameState::processFoundItem(int32 item) {
|
||||
_engine->_grid->newCameraX = (_engine->_scene->sceneHero->x + 256) / 512;
|
||||
_engine->_grid->newCameraY = (_engine->_scene->sceneHero->y + 256) / 256;
|
||||
_engine->_grid->newCameraZ = (_engine->_scene->sceneHero->z + 256) / 512;
|
||||
_engine->_grid->newCameraX = (_engine->_scene->sceneHero->x + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
_engine->_grid->newCameraY = (_engine->_scene->sceneHero->y + BRICK_HEIGHT) / BRICK_HEIGHT;
|
||||
_engine->_grid->newCameraZ = (_engine->_scene->sceneHero->z + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
|
||||
// Hide hero in scene
|
||||
_engine->_scene->sceneHero->staticFlags.bIsHidden = 1;
|
||||
@ -279,19 +279,19 @@ void GameState::processFoundItem(int32 item) {
|
||||
|
||||
_engine->_screens->copyScreen(_engine->frontVideoBuffer, _engine->workVideoBuffer);
|
||||
|
||||
const int32 itemCameraX = _engine->_grid->newCameraX * 512;
|
||||
const int32 itemCameraY = _engine->_grid->newCameraY * 256;
|
||||
const int32 itemCameraZ = _engine->_grid->newCameraZ * 512;
|
||||
const int32 itemCameraX = _engine->_grid->newCameraX * BRICK_SIZE;
|
||||
const int32 itemCameraY = _engine->_grid->newCameraY * BRICK_HEIGHT;
|
||||
const int32 itemCameraZ = _engine->_grid->newCameraZ * BRICK_SIZE;
|
||||
|
||||
_engine->_renderer->renderIsoModel(_engine->_scene->sceneHero->x - itemCameraX, _engine->_scene->sceneHero->y - itemCameraY, _engine->_scene->sceneHero->z - itemCameraZ, 0, 0x80, 0, _engine->_actor->bodyTable[_engine->_scene->sceneHero->entity]);
|
||||
_engine->_interface->setClip(_engine->_redraw->renderRect);
|
||||
|
||||
const int32 itemX = (_engine->_scene->sceneHero->x + 256) / 512;
|
||||
int32 itemY = _engine->_scene->sceneHero->y / 256;
|
||||
const int32 itemX = (_engine->_scene->sceneHero->x + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
int32 itemY = _engine->_scene->sceneHero->y / BRICK_HEIGHT;
|
||||
if (_engine->_scene->sceneHero->brickShape() != ShapeType::kNone) {
|
||||
itemY++;
|
||||
}
|
||||
const int32 itemZ = (_engine->_scene->sceneHero->z + 256) / 512;
|
||||
const int32 itemZ = (_engine->_scene->sceneHero->z + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
|
||||
_engine->_grid->drawOverModelActor(itemX, itemY, itemZ);
|
||||
_engine->flip();
|
||||
|
@ -570,9 +570,9 @@ void Grid::drawBrickSprite(int32 index, int32 posX, int32 posY, const uint8 *ptr
|
||||
}
|
||||
|
||||
uint8 *Grid::getBlockBuffer(int32 x, int32 y, int32 z) {
|
||||
const int32 tempX = (x + 256) / 512;
|
||||
const int32 tempY = y / 256;
|
||||
const int32 tempZ = (z + 256) / 512;
|
||||
const int32 tempX = (x + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
const int32 tempY = y / BRICK_HEIGHT;
|
||||
const int32 tempZ = (z + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
return blockBuffer + tempY * 2 + tempX * GRID_SIZE_Y * 2 + (tempZ * GRID_SIZE_X) * GRID_SIZE_Y * 2;
|
||||
}
|
||||
|
||||
@ -592,7 +592,7 @@ const uint8 *Grid::getBlockBufferGround(int32 x, int32 y, int32 z, int16 &ground
|
||||
}
|
||||
|
||||
_engine->_collision->collisionY = tempY;
|
||||
ground = (int16)((tempY + 1) * 256);
|
||||
ground = (int16)((tempY + 1) * BRICK_HEIGHT);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
@ -659,9 +659,9 @@ void Grid::drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y,
|
||||
void Grid::redrawGrid() {
|
||||
blockMap *map = (blockMap *)blockBuffer;
|
||||
|
||||
cameraX = newCameraX * 512;
|
||||
cameraY = newCameraY * 256;
|
||||
cameraZ = newCameraZ * 512;
|
||||
cameraX = newCameraX * BRICK_SIZE;
|
||||
cameraY = newCameraY * BRICK_HEIGHT;
|
||||
cameraZ = newCameraZ * BRICK_SIZE;
|
||||
|
||||
_engine->_renderer->projectPositionOnScreen(-cameraX, -cameraY, -cameraZ);
|
||||
|
||||
@ -723,9 +723,9 @@ ShapeType Grid::getBrickShape(int32 x, int32 y, int32 z) {
|
||||
}
|
||||
|
||||
void Grid::updateCollisionCoordinates(int32 x, int32 y, int32 z) {
|
||||
_engine->_collision->collisionX = (x + 256) / 512;
|
||||
_engine->_collision->collisionY = y / 256;
|
||||
_engine->_collision->collisionZ = (z + 256) / 512;
|
||||
_engine->_collision->collisionX = (x + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
_engine->_collision->collisionY = y / BRICK_HEIGHT;
|
||||
_engine->_collision->collisionZ = (z + BRICK_HEIGHT) / BRICK_SIZE;
|
||||
}
|
||||
|
||||
ShapeType Grid::getBrickShapeFull(int32 x, int32 y, int32 z, int32 y2) {
|
||||
@ -761,7 +761,7 @@ ShapeType Grid::getBrickShapeFull(int32 x, int32 y, int32 z, int32 y2) {
|
||||
|
||||
const ShapeType brickShape = (ShapeType)*blockPtr;
|
||||
|
||||
const int32 newY = (y2 + 255) / 256;
|
||||
const int32 newY = (y2 + (BRICK_HEIGHT - 1)) / BRICK_HEIGHT;
|
||||
int32 currY = _engine->_collision->collisionY;
|
||||
|
||||
for (int32 i = 0; i < newY; i++) {
|
||||
@ -781,7 +781,7 @@ ShapeType Grid::getBrickShapeFull(int32 x, int32 y, int32 z, int32 y2) {
|
||||
}
|
||||
const ShapeType brickShape = (ShapeType) * (blockBufferPtr + 1);
|
||||
|
||||
const int32 newY = (y2 + 255) / 256;
|
||||
const int32 newY = (y2 + (BRICK_HEIGHT - 1)) / BRICK_HEIGHT;
|
||||
int32 currY = _engine->_collision->collisionY;
|
||||
|
||||
for (int32 i = 0; i < newY; i++) {
|
||||
|
@ -356,9 +356,9 @@ void Scene::changeScene() {
|
||||
_sampleAmbienceTime = 0;
|
||||
|
||||
ActorStruct *followedActor = getActor(currentlyFollowedActor);
|
||||
_engine->_grid->newCameraX = followedActor->x / 512;
|
||||
_engine->_grid->newCameraY = followedActor->y / 256;
|
||||
_engine->_grid->newCameraZ = followedActor->z / 512;
|
||||
_engine->_grid->newCameraX = followedActor->x / BRICK_SIZE;
|
||||
_engine->_grid->newCameraY = followedActor->y / BRICK_HEIGHT;
|
||||
_engine->_grid->newCameraZ = followedActor->z / BRICK_SIZE;
|
||||
|
||||
_engine->_gameState->magicBallIdx = -1;
|
||||
_engine->_movements->heroMoved = true;
|
||||
|
@ -614,13 +614,13 @@ void TwinEEngine::centerScreenOnActor() {
|
||||
}
|
||||
|
||||
ActorStruct *actor = _scene->getActor(_scene->currentlyFollowedActor);
|
||||
_renderer->projectPositionOnScreen(actor->x - (_grid->newCameraX * 512),
|
||||
actor->y - (_grid->newCameraY * 256),
|
||||
actor->z - (_grid->newCameraZ * 512));
|
||||
_renderer->projectPositionOnScreen(actor->x - (_grid->newCameraX * BRICK_SIZE),
|
||||
actor->y - (_grid->newCameraY * BRICK_HEIGHT),
|
||||
actor->z - (_grid->newCameraZ * BRICK_SIZE));
|
||||
if (_renderer->projPosX < 80 || _renderer->projPosX >= SCREEN_WIDTH - 60 || _renderer->projPosY < 80 || _renderer->projPosY >= SCREEN_HEIGHT - 50) {
|
||||
_grid->newCameraX = ((actor->x + 256) / 512) + (((actor->x + 256) / 512) - _grid->newCameraX) / 2;
|
||||
_grid->newCameraY = actor->y / 256;
|
||||
_grid->newCameraZ = ((actor->z + 256) / 512) + (((actor->z + 256) / 512) - _grid->newCameraZ) / 2;
|
||||
_grid->newCameraX = ((actor->x + BRICK_HEIGHT) / BRICK_SIZE) + (((actor->x + BRICK_HEIGHT) / BRICK_SIZE) - _grid->newCameraX) / 2;
|
||||
_grid->newCameraY = actor->y / BRICK_HEIGHT;
|
||||
_grid->newCameraZ = ((actor->z + BRICK_HEIGHT) / BRICK_SIZE) + (((actor->z + BRICK_HEIGHT) / BRICK_SIZE) - _grid->newCameraZ) / 2;
|
||||
|
||||
if (_grid->newCameraX >= GRID_SIZE_X) {
|
||||
_grid->newCameraX = GRID_SIZE_X - 1;
|
||||
@ -732,9 +732,9 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
|
||||
// Recenter Screen
|
||||
if (_input->isActionActive(TwinEActionType::RecenterScreenOnTwinsen) && !disableScreenRecenter) {
|
||||
const ActorStruct *currentlyFollowedActor = _scene->getActor(_scene->currentlyFollowedActor);
|
||||
_grid->newCameraX = currentlyFollowedActor->x / 512;
|
||||
_grid->newCameraY = currentlyFollowedActor->y / 256;
|
||||
_grid->newCameraZ = currentlyFollowedActor->z / 512;
|
||||
_grid->newCameraX = currentlyFollowedActor->x / BRICK_SIZE;
|
||||
_grid->newCameraY = currentlyFollowedActor->y / BRICK_HEIGHT;
|
||||
_grid->newCameraZ = currentlyFollowedActor->z / BRICK_SIZE;
|
||||
_redraw->reqBgRedraw = true;
|
||||
}
|
||||
|
||||
@ -876,9 +876,9 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
|
||||
_scene->needChangeScene = _scene->currentSceneIdx;
|
||||
_gameState->inventoryMagicPoints = _gameState->magicLevelIdx * 20;
|
||||
|
||||
_grid->newCameraX = (_scene->sceneHero->x / 512);
|
||||
_grid->newCameraY = (_scene->sceneHero->y / 256);
|
||||
_grid->newCameraZ = (_scene->sceneHero->z / 512);
|
||||
_grid->newCameraX = (_scene->sceneHero->x / BRICK_SIZE);
|
||||
_grid->newCameraY = (_scene->sceneHero->y / BRICK_HEIGHT);
|
||||
_grid->newCameraZ = (_scene->sceneHero->z / BRICK_SIZE);
|
||||
|
||||
_scene->heroPositionType = ScenePositionType::kReborn;
|
||||
|
||||
@ -990,7 +990,7 @@ void TwinEEngine::setPalette(const uint32 *palette) {
|
||||
out += 3;
|
||||
in += 4;
|
||||
}
|
||||
g_system->getPaletteManager()->setPalette(pal, 0, 256);
|
||||
g_system->getPaletteManager()->setPalette(pal, 0, NUMOFCOLORS);
|
||||
flip();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user