[Scummvm-git-logs] scummvm master -> c37c46921ddd510bd04a659e1780295afe8e50f6
mgerhardy
martin.gerhardy at gmail.com
Fri Oct 8 18:07:07 UTC 2021
This automated email contains information about 12 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e28dd8db29 TWINE: renamed method
12441a9aae TWINE: read sample balance opcode for fla files
54cca2d549 TWINE: replaced magic number
902de4633a TWINE: renamed variables
3813b49a72 TWINE: renamed variables
08833c3d0f TWINE: renamed variables
a2b1ae288f TWINE: improved renderHolomapPolygons readability
bc7beae631 TWINE: reuse loop var in prepareHolomapProjectedPositions
34ed1dc02f TWINE: fixed holomap gap
26b828beb9 TWINE: fixed holomap rotation keys
ae010f210c TWINE: todo comment about unhandled balance value for fla samples
c37c46921d TWINE: fixed and renamed fla opcodes
Commit: e28dd8db295936d9d6d8b133faefde8d0983c5f0
https://github.com/scummvm/scummvm/commit/e28dd8db295936d9d6d8b133faefde8d0983c5f0
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-10-08T18:42:27+02:00
Commit Message:
TWINE: renamed method
Changed paths:
engines/twine/holomap.cpp
engines/twine/menu/menu.cpp
engines/twine/renderer/screens.cpp
engines/twine/renderer/screens.h
engines/twine/scene/gamestate.cpp
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index c2783b76bf..a674e19173 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -170,23 +170,23 @@ void Holomap::prepareHolomapSurface(Common::SeekableReadStream *holomapSurfaceSt
void Holomap::prepareHolomapProjectedPositions() {
int projectedIndex = 0;
- for (int32 angle = -ANGLE_90; angle <= ANGLE_90; angle += ANGLE_11_25) {
+ for (int32 alpha = -ANGLE_90; alpha <= ANGLE_90; alpha += ANGLE_11_25) {
int rotation = 0;
- for (int32 i = 0; i < ANGLE_11_25; ++i) {
- _projectedSurfacePositions[projectedIndex].x2 = _engine->_screens->crossDot(0, 0xffff, ANGLE_360 - 1, rotation);
- if (angle == ANGLE_90) {
+ for (int32 beta = 0; beta < ANGLE_11_25; ++beta) {
+ _projectedSurfacePositions[projectedIndex].x2 = _engine->_screens->lerp(0, 0xffff, ANGLE_360 - 1, rotation);
+ if (alpha == ANGLE_90) {
_projectedSurfacePositions[projectedIndex].y2 = -1;
} else {
- _projectedSurfacePositions[projectedIndex].y2 = ((angle + ANGLE_90) * ANGLE_90) / 2;
+ _projectedSurfacePositions[projectedIndex].y2 = ((alpha + ANGLE_90) * ANGLE_90) / 2;
}
rotation += ANGLE_11_25;
++projectedIndex;
}
_projectedSurfacePositions[projectedIndex].x2 = -1;
- if (angle == ANGLE_90) {
+ if (alpha == ANGLE_90) {
_projectedSurfacePositions[projectedIndex].y2 = -1;
} else {
- _projectedSurfacePositions[projectedIndex].y2 = ((angle + ANGLE_90) * ANGLE_90) / 2;
+ _projectedSurfacePositions[projectedIndex].y2 = ((alpha + ANGLE_90) * ANGLE_90) / 2;
}
++projectedIndex;
}
diff --git a/engines/twine/menu/menu.cpp b/engines/twine/menu/menu.cpp
index 795489ba06..b123497ab6 100644
--- a/engines/twine/menu/menu.cpp
+++ b/engines/twine/menu/menu.cpp
@@ -256,22 +256,22 @@ void Menu::drawButtonGfx(const MenuSettings *menuSettings, const Common::Rect &r
switch (buttonId) {
case MenuButtonTypes::kMusicVolume: {
const int volume = _engine->_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kMusicSoundType);
- newWidth = _engine->_screens->crossDot(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, volume);
+ newWidth = _engine->_screens->lerp(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, volume);
break;
}
case MenuButtonTypes::kSoundVolume: {
const int volume = _engine->_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kSFXSoundType);
- newWidth = _engine->_screens->crossDot(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, volume);
+ newWidth = _engine->_screens->lerp(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, volume);
break;
}
case MenuButtonTypes::kCDVolume: {
const AudioCDManager::Status status = _engine->_system->getAudioCDManager()->getStatus();
- newWidth = _engine->_screens->crossDot(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, status.volume);
+ newWidth = _engine->_screens->lerp(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, status.volume);
break;
}
case MenuButtonTypes::kSpeechVolume: {
const int volume = _engine->_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kSpeechSoundType);
- newWidth = _engine->_screens->crossDot(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, volume);
+ newWidth = _engine->_screens->lerp(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, volume);
break;
}
}
@@ -832,7 +832,7 @@ int32 Menu::giveupMenu() {
void Menu::drawHealthBar(int32 left, int32 right, int32 top, int32 barLeftPadding, int32 barHeight) {
_engine->_grid->drawSprite(left, top + 3, _engine->_resources->_spriteData[SPRITEHQR_LIFEPOINTS]);
const int32 barLeft = left + barLeftPadding;
- const int32 healthBarRight = _engine->_screens->crossDot(barLeft, right, 50, _engine->_scene->_sceneHero->_life);
+ const int32 healthBarRight = _engine->_screens->lerp(barLeft, right, 50, _engine->_scene->_sceneHero->_life);
const int32 barBottom = top + barHeight;
_engine->_interface->drawFilledRect(Common::Rect(barLeft, top, healthBarRight, barBottom), COLOR_91);
drawRectBorders(Common::Rect(barLeft, top, right, barBottom));
@@ -841,13 +841,13 @@ void Menu::drawHealthBar(int32 left, int32 right, int32 top, int32 barLeftPaddin
void Menu::drawCloverLeafs(int32 newBoxLeft, int32 boxRight, int32 top) {
// Clover leaf boxes
for (int32 i = 0; i < _engine->_gameState->_inventoryNumLeafsBox; i++) {
- const int32 leftSpritePos = _engine->_screens->crossDot(newBoxLeft, boxRight, 10, i);
+ const int32 leftSpritePos = _engine->_screens->lerp(newBoxLeft, boxRight, 10, i);
_engine->_grid->drawSprite(leftSpritePos, top + 58, _engine->_resources->_spriteData[SPRITEHQR_CLOVERLEAFBOX]);
}
// Clover leafs
for (int32 i = 0; i < _engine->_gameState->_inventoryNumLeafs; i++) {
- const int32 leftSpritePos = _engine->_screens->crossDot(newBoxLeft, boxRight, 10, i);
+ const int32 leftSpritePos = _engine->_screens->lerp(newBoxLeft, boxRight, 10, i);
_engine->_grid->drawSprite(leftSpritePos + 2, top + 60, _engine->_resources->_spriteData[SPRITEHQR_CLOVERLEAF]);
}
}
@@ -865,7 +865,7 @@ void Menu::drawMagicPointsBar(int32 left, int32 right, int32 top, int32 barLeftP
}
const int32 barLeft = left + barLeftPadding;
const int32 barBottom = top + barHeight;
- const int32 barRight = _engine->_screens->crossDot(barLeft, right, 80, _engine->_gameState->_inventoryMagicPoints);
+ const int32 barRight = _engine->_screens->lerp(barLeft, right, 80, _engine->_gameState->_inventoryMagicPoints);
const Common::Rect pointsRect(barLeft, top, barRight, barBottom);
_engine->_interface->drawFilledRect(pointsRect, COLOR_75);
drawRectBorders(barLeft, top, barLeft + _engine->_gameState->_magicLevelIdx * 80, barBottom);
diff --git a/engines/twine/renderer/screens.cpp b/engines/twine/renderer/screens.cpp
index 8267e89f34..80c12ff2bf 100644
--- a/engines/twine/renderer/screens.cpp
+++ b/engines/twine/renderer/screens.cpp
@@ -122,11 +122,11 @@ void Screens::fadeOut(const uint32 *pal) {
#endif
}
-int32 Screens::crossDot(int32 modifier, int32 color, int32 param, int32 intensity) {
- if (!param) {
- return color;
+int32 Screens::lerp(int32 value, int32 start, int32 end, int32 t) {
+ if (!end) {
+ return start;
}
- return (((color - modifier) * intensity) / param) + modifier;
+ return (((start - value) * t) / end) + value;
}
void Screens::adjustPalette(uint8 r, uint8 g, uint8 b, const uint32 *rgbaPal, int32 intensity) {
@@ -142,9 +142,9 @@ void Screens::adjustPalette(uint8 r, uint8 g, uint8 b, const uint32 *rgbaPal, in
uint8 *newA = &paletteOut[3];
for (int32 i = 0; i < NUMOFCOLORS; i++) {
- *newR = crossDot(r, paletteIn[counter], 100, intensity);
- *newG = crossDot(g, paletteIn[counter + 1], 100, intensity);
- *newB = crossDot(b, paletteIn[counter + 2], 100, intensity);
+ *newR = lerp(r, paletteIn[counter], 100, intensity);
+ *newG = lerp(g, paletteIn[counter + 1], 100, intensity);
+ *newB = lerp(b, paletteIn[counter + 2], 100, intensity);
*newA = 0xFF;
newR += 4;
@@ -178,9 +178,9 @@ void Screens::adjustCrossPalette(const uint32 *pal1, const uint32 *pal2) {
uint8 *newA = &paletteOut[counter + 3];
for (int32 i = 0; i < NUMOFCOLORS; i++) {
- *newR = crossDot(pal1p[counter + 0], pal2p[counter + 0], 100, intensity);
- *newG = crossDot(pal1p[counter + 1], pal2p[counter + 1], 100, intensity);
- *newB = crossDot(pal1p[counter + 2], pal2p[counter + 2], 100, intensity);
+ *newR = lerp(pal1p[counter + 0], pal2p[counter + 0], 100, intensity);
+ *newG = lerp(pal1p[counter + 1], pal2p[counter + 1], 100, intensity);
+ *newB = lerp(pal1p[counter + 2], pal2p[counter + 2], 100, intensity);
*newA = 0xFF;
newR += 4;
diff --git a/engines/twine/renderer/screens.h b/engines/twine/renderer/screens.h
index 5430908073..afc0eb9350 100644
--- a/engines/twine/renderer/screens.h
+++ b/engines/twine/renderer/screens.h
@@ -112,14 +112,15 @@ public:
void fadeOut(const uint32 *palette);
/**
- * Calculate a new color component according with an intensity
- * @param modifier color compenent
- * @param color color value
- * @param param unknown
- * @param intensity intensity value to adjust
- * @return new color component
+ * Linear interpolation of the given value between start and end
+ * @param value color component
+ * @param start lower range
+ * @param end upper range
+ * @param t the location in given range
+ * @return the lerped value
+ * @note Doesn't clamp
*/
- int32 crossDot(int32 modifier, int32 color, int32 param, int32 intensity);
+ int32 lerp(int32 value, int32 start, int32 end, int32 t);
/**
* Adjust between two palettes
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index 18255cca4a..c2e2531764 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -512,7 +512,7 @@ void GameState::processGameoverAnimation() {
}
const int32 avg = _engine->_collision->getAverageValue(40000, 3200, 500, _engine->_lbaTime - startLbaTime);
- const int32 cdot = _engine->_screens->crossDot(1, 1024, 100, (_engine->_lbaTime - startLbaTime) % 100);
+ const int32 cdot = _engine->_screens->lerp(1, 1024, 100, (_engine->_lbaTime - startLbaTime) % 100);
_engine->blitWorkToFront(rect);
_engine->_renderer->setCameraAngle(0, 0, 0, 0, -cdot, 0, avg);
Commit: 12441a9aaeaa093e1c5fc3631160f2d6d1bbdd28
https://github.com/scummvm/scummvm/commit/12441a9aaeaa093e1c5fc3631160f2d6d1bbdd28
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-10-08T18:42:27+02:00
Commit Message:
TWINE: read sample balance opcode for fla files
Changed paths:
engines/twine/movies.cpp
diff --git a/engines/twine/movies.cpp b/engines/twine/movies.cpp
index a357a9b04a..f551609350 100644
--- a/engines/twine/movies.cpp
+++ b/engines/twine/movies.cpp
@@ -45,7 +45,7 @@ enum FlaFrameOpcode {
kLoadPalette = 1,
kFade = 2,
kPlaySample = 3,
- kFlaUnknown4 = 4,
+ kSampleBalance = 4,
kStopSample = 5,
kDeltaFrame = 6,
kFlaUnknown7 = 7,
@@ -62,12 +62,9 @@ struct FLASampleStruct {
int16 freq = 0;
/** Numbers of time to repeat */
int16 repeat = 0;
- /** Dummy variable */
- int8 dummy = 0;
- /** Unknown x */
- uint8 x = 0;
- /** Unknown y */
- uint8 y = 0;
+ uint8 balance = 0;
+ uint8 volumeLeft = 0;
+ uint8 volumeRight = 0;
};
/** FLA movie extension */
@@ -221,14 +218,15 @@ void Movies::processFrame() {
sample.sampleNum = stream.readSint16LE();
sample.freq = stream.readSint16LE();
sample.repeat = stream.readSint16LE();
- sample.dummy = stream.readSByte();
- sample.x = stream.readByte();
- sample.y = stream.readByte();
- _engine->_sound->playFlaSample(sample.sampleNum, sample.repeat, sample.x, sample.y);
+ sample.balance = stream.readByte();
+ sample.volumeLeft = stream.readByte();
+ sample.volumeRight = stream.readByte();
+ _engine->_sound->playFlaSample(sample.sampleNum, sample.repeat, sample.volumeLeft, sample.volumeRight);
break;
}
case kStopSample: {
- _engine->_sound->stopSample(sample.sampleNum);
+ const uint16 sampleNum = stream.readUint16LE();
+ _engine->_sound->stopSample(sampleNum);
break;
}
case kDeltaFrame: {
@@ -260,7 +258,14 @@ void Movies::processFrame() {
_engine->_frontVideoBuffer.addDirtyRect(rect);
break;
}
- case kFlaUnknown4:
+ case kSampleBalance: {
+ /* int16 num = */ stream.readSint16LE();
+ /* uint8 offset = */ stream.readByte();
+ /* int16 balance = */ stream.readSint16LE();
+ /* uint8 volumeLeft = */ stream.readByte();
+ /* uint8 volumeRight = */ stream.readByte();
+ break;
+ }
default: {
break;
}
Commit: 54cca2d54998b0f8cfed7fb54d40e01fd49cd2f1
https://github.com/scummvm/scummvm/commit/54cca2d54998b0f8cfed7fb54d40e01fd49cd2f1
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-10-08T19:00:01+02:00
Commit Message:
TWINE: replaced magic number
Changed paths:
engines/twine/holomap.cpp
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index a674e19173..325616c4f3 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -234,12 +234,13 @@ bool Holomap::isTriangleVisible(const Vertex *vertices) const {
return iVar2 - iVar1 != 0 && iVar1 <= iVar2;
}
+#define SURFACE_POS_OFFSET ((ANGLE_360 / ANGLE_11_25) + 1)
void Holomap::renderHolomapSurfacePolygons(uint8 *holomapImage, uint32 holomapImageSize) {
prepareHolomapPolygons();
for (int32 i = 0; i < ARRAYSIZE(_holomapSort); ++i) {
assert(_holomapSort[i].projectedPosIdx + 34 < _projectedSurfaceIndex);
const HolomapProjectedPos &pos1 = _projectedSurfacePositions[_holomapSort[i].projectedPosIdx + 0];
- const HolomapProjectedPos &pos2 = _projectedSurfacePositions[_holomapSort[i].projectedPosIdx + 33];
+ const HolomapProjectedPos &pos2 = _projectedSurfacePositions[_holomapSort[i].projectedPosIdx + 0 + SURFACE_POS_OFFSET];
const HolomapProjectedPos &pos3 = _projectedSurfacePositions[_holomapSort[i].projectedPosIdx + 1];
Vertex vertexCoordinates[3];
vertexCoordinates[0].x = pos1.x1;
@@ -258,8 +259,8 @@ void Holomap::renderHolomapSurfacePolygons(uint8 *holomapImage, uint32 holomapIm
vertexCoordinates2[2].y = pos3.y2;
_engine->_renderer->renderHolomapVertices(vertexCoordinates, vertexCoordinates2, holomapImage, holomapImageSize);
}
- const HolomapProjectedPos &pos4 = _projectedSurfacePositions[_holomapSort[i].projectedPosIdx + 33];
- const HolomapProjectedPos &pos5 = _projectedSurfacePositions[_holomapSort[i].projectedPosIdx + 34];
+ const HolomapProjectedPos &pos4 = _projectedSurfacePositions[_holomapSort[i].projectedPosIdx + 0 + SURFACE_POS_OFFSET];
+ const HolomapProjectedPos &pos5 = _projectedSurfacePositions[_holomapSort[i].projectedPosIdx + 1 + SURFACE_POS_OFFSET];
const HolomapProjectedPos &pos6 = _projectedSurfacePositions[_holomapSort[i].projectedPosIdx + 1];
vertexCoordinates[0].x = pos4.x1;
vertexCoordinates[0].y = pos4.y1;
Commit: 902de4633a74b1d1709eff5eda7ad3c4991f85f8
https://github.com/scummvm/scummvm/commit/902de4633a74b1d1709eff5eda7ad3c4991f85f8
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-10-08T19:00:01+02:00
Commit Message:
TWINE: renamed variables
Changed paths:
engines/twine/holomap.cpp
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 325616c4f3..553a586f29 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -250,14 +250,14 @@ void Holomap::renderHolomapSurfacePolygons(uint8 *holomapImage, uint32 holomapIm
vertexCoordinates[2].x = pos3.x1;
vertexCoordinates[2].y = pos3.y1;
if (isTriangleVisible(vertexCoordinates)) {
- Vertex vertexCoordinates2[3];
- vertexCoordinates2[0].x = pos1.x2;
- vertexCoordinates2[0].y = pos1.y2;
- vertexCoordinates2[1].x = pos2.x2;
- vertexCoordinates2[1].y = pos2.y2;
- vertexCoordinates2[2].x = pos3.x2;
- vertexCoordinates2[2].y = pos3.y2;
- _engine->_renderer->renderHolomapVertices(vertexCoordinates, vertexCoordinates2, holomapImage, holomapImageSize);
+ Vertex textureCoordinates[3];
+ textureCoordinates[0].x = pos1.x2;
+ textureCoordinates[0].y = pos1.y2;
+ textureCoordinates[1].x = pos2.x2;
+ textureCoordinates[1].y = pos2.y2;
+ textureCoordinates[2].x = pos3.x2;
+ textureCoordinates[2].y = pos3.y2;
+ _engine->_renderer->renderHolomapVertices(vertexCoordinates, textureCoordinates, holomapImage, holomapImageSize);
}
const HolomapProjectedPos &pos4 = _projectedSurfacePositions[_holomapSort[i].projectedPosIdx + 0 + SURFACE_POS_OFFSET];
const HolomapProjectedPos &pos5 = _projectedSurfacePositions[_holomapSort[i].projectedPosIdx + 1 + SURFACE_POS_OFFSET];
@@ -269,14 +269,14 @@ void Holomap::renderHolomapSurfacePolygons(uint8 *holomapImage, uint32 holomapIm
vertexCoordinates[2].x = pos6.x1;
vertexCoordinates[2].y = pos6.y1;
if (isTriangleVisible(vertexCoordinates)) {
- Vertex vertexCoordinates2[3];
- vertexCoordinates2[0].x = pos4.x2;
- vertexCoordinates2[0].y = pos4.y2;
- vertexCoordinates2[1].x = pos5.x2;
- vertexCoordinates2[1].y = pos5.y2;
- vertexCoordinates2[2].x = pos6.x2;
- vertexCoordinates2[2].y = pos6.y2;
- _engine->_renderer->renderHolomapVertices(vertexCoordinates, vertexCoordinates2, holomapImage, holomapImageSize);
+ Vertex textureCoordinates[3];
+ textureCoordinates[0].x = pos4.x2;
+ textureCoordinates[0].y = pos4.y2;
+ textureCoordinates[1].x = pos5.x2;
+ textureCoordinates[1].y = pos5.y2;
+ textureCoordinates[2].x = pos6.x2;
+ textureCoordinates[2].y = pos6.y2;
+ _engine->_renderer->renderHolomapVertices(vertexCoordinates, textureCoordinates, holomapImage, holomapImageSize);
}
}
}
Commit: 3813b49a72c496adb50ffafe63d14fb9b3a859bb
https://github.com/scummvm/scummvm/commit/3813b49a72c496adb50ffafe63d14fb9b3a859bb
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-10-08T19:00:01+02:00
Commit Message:
TWINE: renamed variables
Changed paths:
engines/twine/holomap.cpp
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 553a586f29..5f8bcfd2f9 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -196,12 +196,12 @@ void Holomap::prepareHolomapPolygons() {
int holomapSortArrayIdx = 0;
int holomapSurfaceArrayIdx = 0;
_projectedSurfaceIndex = 0;
- for (int32 angle = -ANGLE_90; angle <= ANGLE_90; angle += ANGLE_11_25) {
+ for (int32 alpha = -ANGLE_90; alpha <= ANGLE_90; alpha += ANGLE_11_25) {
int rotation = ANGLE_0;
- for (int32 stepWidth = 0; stepWidth < ANGLE_11_25; ++stepWidth) {
+ for (int32 beta = 0; beta < ANGLE_11_25; ++beta) {
IVec3 *vec = &_holomapSurface[holomapSurfaceArrayIdx++];
const IVec3 &destPos = _engine->_renderer->getBaseRotationPosition(vec->x, vec->y, vec->z);
- if (angle != ANGLE_90) {
+ if (alpha != ANGLE_90) {
_holomapSort[holomapSortArrayIdx].z = destPos.z;
_holomapSort[holomapSortArrayIdx].projectedPosIdx = _projectedSurfaceIndex;
++holomapSortArrayIdx;
Commit: 08833c3d0f595eb3143dab20eac8fb3a56150706
https://github.com/scummvm/scummvm/commit/08833c3d0f595eb3143dab20eac8fb3a56150706
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-10-08T19:00:01+02:00
Commit Message:
TWINE: renamed variables
Changed paths:
engines/twine/renderer/renderer.cpp
engines/twine/renderer/renderer.h
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index a6b8f93b01..8d5d853585 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -1660,7 +1660,7 @@ void Renderer::computeHolomapPolygon(int32 top, int32 x1, int32 bottom, int32 x2
}
}
-void Renderer::fillHolomapPolygons(const Vertex &vertex1, const Vertex &vertex2, const Vertex &angles1, const Vertex &angles2, int32 &top, int32 &bottom) {
+void Renderer::fillHolomapPolygons(const Vertex &vertex1, const Vertex &vertex2, const Vertex &texCoord1, const Vertex &texCoord2, int32 &top, int32 &bottom) {
const int32 yBottom = vertex1.y;
const int32 yTop = vertex2.y;
if (yBottom == yTop) {
@@ -1676,7 +1676,7 @@ void Renderer::fillHolomapPolygons(const Vertex &vertex1, const Vertex &vertex2,
bottom = yTop;
}
computeHolomapPolygon(yTop, vertex2.x, yBottom, vertex1.x, _holomap_polytab_1_1);
- computeHolomapPolygon(yTop, (uint32)(uint16)angles2.x, yBottom, (uint32)(uint16)angles1.x, _holomap_polytab_1_2);
+ computeHolomapPolygon(yTop, (uint32)(uint16)texCoord2.x, yBottom, (uint32)(uint16)texCoord1.x, _holomap_polytab_1_2);
polygonTabPtr = _holomap_polytab_1_3;
} else {
if (bottom < yBottom) {
@@ -1686,18 +1686,18 @@ void Renderer::fillHolomapPolygons(const Vertex &vertex1, const Vertex &vertex2,
top = yTop;
}
computeHolomapPolygon(yTop, vertex2.x, yBottom, vertex1.x, _holomap_polytab_2_1);
- computeHolomapPolygon(yTop, (uint32)(uint16)angles2.x, yBottom, (uint32)(uint16)angles1.x, _holomap_polytab_2_2);
+ computeHolomapPolygon(yTop, (uint32)(uint16)texCoord2.x, yBottom, (uint32)(uint16)texCoord1.x, _holomap_polytab_2_2);
polygonTabPtr = _holomap_polytab_2_3;
}
- computeHolomapPolygon(yTop, (uint32)(uint16)angles2.y, yBottom, (uint32)(uint16)angles1.y, polygonTabPtr);
+ computeHolomapPolygon(yTop, (uint32)(uint16)texCoord2.y, yBottom, (uint32)(uint16)texCoord1.y, polygonTabPtr);
}
-void Renderer::renderHolomapVertices(const Vertex vertexCoordinates[3], const Vertex vertexCoordinates2[3], uint8 *holomapImage, uint32 holomapImageSize) {
+void Renderer::renderHolomapVertices(const Vertex vertexCoordinates[3], const Vertex textureCoordinates[3], uint8 *holomapImage, uint32 holomapImageSize) {
int32 top = SCENE_SIZE_MAX;
int32 bottom = SCENE_SIZE_MIN;
- fillHolomapPolygons(vertexCoordinates[0], vertexCoordinates[1], vertexCoordinates2[0], vertexCoordinates2[1], top, bottom);
- fillHolomapPolygons(vertexCoordinates[1], vertexCoordinates[2], vertexCoordinates2[1], vertexCoordinates2[2], top, bottom);
- fillHolomapPolygons(vertexCoordinates[2], vertexCoordinates[0], vertexCoordinates2[2], vertexCoordinates2[0], top, bottom);
+ fillHolomapPolygons(vertexCoordinates[0], vertexCoordinates[1], textureCoordinates[0], textureCoordinates[1], top, bottom);
+ fillHolomapPolygons(vertexCoordinates[1], vertexCoordinates[2], textureCoordinates[1], textureCoordinates[2], top, bottom);
+ fillHolomapPolygons(vertexCoordinates[2], vertexCoordinates[0], textureCoordinates[2], textureCoordinates[0], top, bottom);
renderHolomapPolygons(top, bottom, holomapImage, holomapImageSize);
}
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 8ce42a01ed..8242cc4070 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -204,7 +204,7 @@ private:
void renderHolomapPolygons(int32 top, int32 bottom, uint8 *holomapImage, uint32 holomapImageSize);
void computeHolomapPolygon(int32 y1, int32 x1, int32 y2, int32 x2, int16 *polygonTabPtr);
- void fillHolomapPolygons(const Vertex &vertex1, const Vertex &vertex2, const Vertex &vertex3, const Vertex &vertex4, int32 &top, int32 &bottom);
+ void fillHolomapPolygons(const Vertex &vertex1, const Vertex &vertex2, const Vertex &texCoord1, const Vertex &texCoord2, int32 &top, int32 &bottom);
public:
Renderer(TwinEEngine *engine);
@@ -261,7 +261,7 @@ public:
void renderInventoryItem(int32 x, int32 y, const BodyData &bodyData, int32 angle, int32 param);
- void renderHolomapVertices(const Vertex vertexCoordinates[3], const Vertex vertexCoordinates2[3], uint8 *holomapImage, uint32 holomapImageSize);
+ void renderHolomapVertices(const Vertex vertexCoordinates[3], const Vertex textureCoordinates[3], uint8 *holomapImage, uint32 holomapImageSize);
};
inline void Renderer::setBaseRotationPos(int32 x, int32 y, int32 z) {
Commit: a2b1ae288fdf96036d30acd56c072a0dbfc21bcd
https://github.com/scummvm/scummvm/commit/a2b1ae288fdf96036d30acd56c072a0dbfc21bcd
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-10-08T19:00:01+02:00
Commit Message:
TWINE: improved renderHolomapPolygons readability
Changed paths:
engines/twine/renderer/renderer.cpp
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 8d5d853585..9af6b33448 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -1702,8 +1702,6 @@ void Renderer::renderHolomapVertices(const Vertex vertexCoordinates[3], const Ve
}
void Renderer::renderHolomapPolygons(int32 top, int32 bottom, uint8 *holomapImage, uint32 holomapImageSize) {
- const void *pixelBegin = _engine->_frontVideoBuffer.getBasePtr(0, 0);
- const void *pixelEnd = _engine->_frontVideoBuffer.getBasePtr(_engine->_frontVideoBuffer.w - 1, _engine->_frontVideoBuffer.h - 1);
if (top < 0 || top >= _engine->_frontVideoBuffer.h) {
return;
}
@@ -1718,29 +1716,29 @@ void Renderer::renderHolomapPolygons(int32 top, int32 bottom, uint8 *holomapImag
int32 yHeight = bottom - top;
while (yHeight > -1) {
+ int32 u;
+ int32 v;
const int16 left = *lholomap_polytab_1_1++;
const int16 right = *lholomap_polytab_2_1++;
- const uint16 x_1_2 = *lholomap_polytab_1_2++;
- const uint16 x_1_3 = *lholomap_polytab_1_3++;
- const uint16 x_2_2 = *lholomap_polytab_2_2++;
- const uint16 x_2_3 = *lholomap_polytab_2_3++;
+ const uint32 u0 = u = *lholomap_polytab_1_2++;
+ const uint32 v0 = v = *lholomap_polytab_1_3++;
+ const uint32 u1 = *lholomap_polytab_2_2++;
+ const uint32 v1 = *lholomap_polytab_2_3++;
const int16 width = right - left;
if (width > 0) {
uint8 *pixelBufPtr = screenBufPtr + left;
- const int32 iWidth = (int32)width;
- uint32 uVar1 = (uint32)x_1_3;
- uint32 uVar3 = (uint32)x_1_2;
+
+ int32 ustep = ((int32)u1 - (int32)u0 + 1) / width;
+ int32 vstep = ((int32)v1 - (int32)v0 + 1) / width;
+
for (int16 i = 0; i < width; ++i) {
- const uint32 holomapImageOffset = (uint32)((int32)uVar3 >> 8 & 0xffU) | (uVar1 & 0xff00);
- assert(holomapImageOffset < holomapImageSize);
- if (pixelBufPtr < pixelBegin || pixelBufPtr > pixelEnd) {
- ++pixelBufPtr;
- } else {
- //debug("holomapImageOffset: %i", holomapImageOffset);
- *pixelBufPtr++ = holomapImage[holomapImageOffset];
- }
- uVar1 += (int32)(((uint32)x_2_3 - (uint32)x_1_3) + 1) / iWidth;
- uVar3 += (int32)(((uint32)x_2_2 - (uint32)x_1_2) + 1) / iWidth;
+ // u0 & 0xFF00 is the x position on the image * 256
+ // v0 & 0xFF00 is the y position on the image * 256
+ const uint32 idx = ((u >> 8) & 0xff) | (v & 0xff00);
+ assert(idx < holomapImageSize);
+ *pixelBufPtr++ = holomapImage[idx];
+ u += ustep;
+ v += vstep;
}
}
screenBufPtr += _engine->_frontVideoBuffer.pitch;
Commit: bc7beae63147051825c13fd4ddafdb94d5dfb89c
https://github.com/scummvm/scummvm/commit/bc7beae63147051825c13fd4ddafdb94d5dfb89c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-10-08T19:00:01+02:00
Commit Message:
TWINE: reuse loop var in prepareHolomapProjectedPositions
Changed paths:
engines/twine/holomap.cpp
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 5f8bcfd2f9..67c3437028 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -171,15 +171,13 @@ void Holomap::prepareHolomapSurface(Common::SeekableReadStream *holomapSurfaceSt
void Holomap::prepareHolomapProjectedPositions() {
int projectedIndex = 0;
for (int32 alpha = -ANGLE_90; alpha <= ANGLE_90; alpha += ANGLE_11_25) {
- int rotation = 0;
- for (int32 beta = 0; beta < ANGLE_11_25; ++beta) {
- _projectedSurfacePositions[projectedIndex].x2 = _engine->_screens->lerp(0, 0xffff, ANGLE_360 - 1, rotation);
+ for (int32 beta = 0; beta < ANGLE_360; beta += ANGLE_11_25) {
+ _projectedSurfacePositions[projectedIndex].x2 = _engine->_screens->lerp(0, 0xffff, ANGLE_360 - 1, beta);
if (alpha == ANGLE_90) {
_projectedSurfacePositions[projectedIndex].y2 = -1;
} else {
_projectedSurfacePositions[projectedIndex].y2 = ((alpha + ANGLE_90) * ANGLE_90) / 2;
}
- rotation += ANGLE_11_25;
++projectedIndex;
}
_projectedSurfacePositions[projectedIndex].x2 = -1;
Commit: 34ed1dc02f604be82c178809e2e6d2ff57f2caf7
https://github.com/scummvm/scummvm/commit/34ed1dc02f604be82c178809e2e6d2ff57f2caf7
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-10-08T19:00:01+02:00
Commit Message:
TWINE: fixed holomap gap
Changed paths:
engines/twine/holomap.cpp
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 67c3437028..3810f43ee6 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -154,18 +154,24 @@ void Holomap::loadHolomapGFX() {
void Holomap::prepareHolomapSurface(Common::SeekableReadStream *holomapSurfaceStream) {
int holomapSurfaceArrayIdx = 0;
_engine->_renderer->setBaseRotation(0, 0, 0);
- for (int angle = -ANGLE_90; angle <= ANGLE_90; angle += ANGLE_11_25) {
- int rotation = 0;
- for (int i = 0; i <= ANGLE_11_25; ++i, rotation += ANGLE_11_25) {
+ for (int alpha = -ANGLE_90; alpha <= ANGLE_90; alpha += ANGLE_11_25) {
+ const int64 pos = holomapSurfaceStream->pos();
+ for (int beta = 0; beta < ANGLE_360; beta += ANGLE_11_25) {
const int32 rotX = holomapSurfaceStream->readByte();
- const IVec3 &rotVec = _engine->_renderer->getHolomapRotation(rotX, angle, rotation);
+ const IVec3 &rotVec = _engine->_renderer->getHolomapRotation(rotX, alpha, beta);
_holomapSurface[holomapSurfaceArrayIdx].x = rotVec.x;
_holomapSurface[holomapSurfaceArrayIdx].y = rotVec.y;
_holomapSurface[holomapSurfaceArrayIdx].z = rotVec.z;
++holomapSurfaceArrayIdx;
}
+ holomapSurfaceStream->seek(pos);
+ const int32 rotX = holomapSurfaceStream->readByte();
+ const IVec3 &rotVec = _engine->_renderer->getHolomapRotation(rotX, alpha, 0);
+ _holomapSurface[holomapSurfaceArrayIdx].x = rotVec.x;
+ _holomapSurface[holomapSurfaceArrayIdx].y = rotVec.y;
+ _holomapSurface[holomapSurfaceArrayIdx].z = rotVec.z;
+ ++holomapSurfaceArrayIdx;
}
- assert(holomapSurfaceStream->eos());
}
void Holomap::prepareHolomapProjectedPositions() {
Commit: 26b828beb9952edf1b60127dabad97d4917a1982
https://github.com/scummvm/scummvm/commit/26b828beb9952edf1b60127dabad97d4917a1982
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-10-08T19:00:01+02:00
Commit Message:
TWINE: fixed holomap rotation keys
Changed paths:
engines/twine/holomap.cpp
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 3810f43ee6..60ef66d899 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -574,21 +574,21 @@ void Holomap::processHolomap() {
}
}
- if (_engine->_input->isActionActive(TwinEActionType::HolomapLeft)) {
+ if (_engine->_input->isActionActive(TwinEActionType::HolomapDown)) {
xRot += ANGLE_2;
rotate = true;
time = _engine->_lbaTime;
- } else if (_engine->_input->isActionActive(TwinEActionType::HolomapRight)) {
+ } else if (_engine->_input->isActionActive(TwinEActionType::HolomapUp)) {
xRot -= ANGLE_2;
rotate = true;
time = _engine->_lbaTime;
}
- if (_engine->_input->isActionActive(TwinEActionType::HolomapUp)) {
+ if (_engine->_input->isActionActive(TwinEActionType::HolomapRight)) {
yRot += ANGLE_2;
rotate = true;
time = _engine->_lbaTime;
- } else if (_engine->_input->isActionActive(TwinEActionType::HolomapDown)) {
+ } else if (_engine->_input->isActionActive(TwinEActionType::HolomapLeft)) {
yRot -= ANGLE_2;
rotate = true;
time = _engine->_lbaTime;
Commit: ae010f210c53d4895baaa74c0d9aea157ce42bc6
https://github.com/scummvm/scummvm/commit/ae010f210c53d4895baaa74c0d9aea157ce42bc6
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-10-08T19:06:37+02:00
Commit Message:
TWINE: todo comment about unhandled balance value for fla samples
Changed paths:
engines/twine/audio/sound.cpp
engines/twine/audio/sound.h
engines/twine/movies.cpp
diff --git a/engines/twine/audio/sound.cpp b/engines/twine/audio/sound.cpp
index 61b294dece..a162b3bf7c 100644
--- a/engines/twine/audio/sound.cpp
+++ b/engines/twine/audio/sound.cpp
@@ -60,7 +60,7 @@ void Sound::setSamplePosition(int32 channelIdx, int32 x, int32 y, int32 z) {
_engine->_system->getMixer()->setChannelVolume(samplesPlaying[channelIdx], targetVolume);
}
-void Sound::playFlaSample(int32 index, int32 repeat, int32 x, int32 y) {
+void Sound::playFlaSample(int32 index, int32 repeat, uint8 balance, int32 volumeLeft, int32 volumeRight) {
if (!_engine->_cfgfile.Sound) {
return;
}
@@ -158,7 +158,11 @@ bool Sound::playSample(int channelIdx, int index, uint8 *sampPtr, int32 sampSize
if (loop == -1) {
loop = 0;
}
- _engine->_system->getMixer()->playStream(soundType, &samplesPlaying[channelIdx], Audio::makeLoopingAudioStream(audioStream, loop), index);
+ Audio::AudioStream *loopStream = Audio::makeLoopingAudioStream(audioStream, loop);
+ Audio::SoundHandle *handle = &samplesPlaying[channelIdx];
+ const byte volume = Audio::Mixer::kMaxChannelVolume;
+ // TODO: implement balance
+ _engine->_system->getMixer()->playStream(soundType, handle, loopStream, index, volume);
return true;
}
diff --git a/engines/twine/audio/sound.h b/engines/twine/audio/sound.h
index db6f4cfd36..74a3771d0d 100644
--- a/engines/twine/audio/sound.h
+++ b/engines/twine/audio/sound.h
@@ -81,10 +81,8 @@ public:
* Play FLA movie samples
* @param index sample index under flasamp.hqr file
* @param repeat number of times to repeat the sample
- * @param x unknown x variable
- * @param y unknown y variable
*/
- void playFlaSample(int32 index, int32 repeat, int32 x, int32 y);
+ void playFlaSample(int32 index, int32 repeat, uint8 balance, int32 volumeLeft, int32 volumeRight);
/** Update sample position in channel */
void setSamplePosition(int32 channelIdx, int32 x, int32 y, int32 z);
diff --git a/engines/twine/movies.cpp b/engines/twine/movies.cpp
index f551609350..5e0468e9ec 100644
--- a/engines/twine/movies.cpp
+++ b/engines/twine/movies.cpp
@@ -221,7 +221,7 @@ void Movies::processFrame() {
sample.balance = stream.readByte();
sample.volumeLeft = stream.readByte();
sample.volumeRight = stream.readByte();
- _engine->_sound->playFlaSample(sample.sampleNum, sample.repeat, sample.volumeLeft, sample.volumeRight);
+ _engine->_sound->playFlaSample(sample.sampleNum, sample.repeat, sample.balance, sample.volumeLeft, sample.volumeRight);
break;
}
case kStopSample: {
Commit: c37c46921ddd510bd04a659e1780295afe8e50f6
https://github.com/scummvm/scummvm/commit/c37c46921ddd510bd04a659e1780295afe8e50f6
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-10-08T19:12:51+02:00
Commit Message:
TWINE: fixed and renamed fla opcodes
Changed paths:
engines/twine/movies.cpp
diff --git a/engines/twine/movies.cpp b/engines/twine/movies.cpp
index 5e0468e9ec..ef70aa0664 100644
--- a/engines/twine/movies.cpp
+++ b/engines/twine/movies.cpp
@@ -48,10 +48,10 @@ enum FlaFrameOpcode {
kSampleBalance = 4,
kStopSample = 5,
kDeltaFrame = 6,
- kFlaUnknown7 = 7,
+ kBlackFrame = 7,
kKeyFrame = 8,
- kFlaUnknown9 = 9,
- kFlaUnknown16SameAs9 = 16
+ kCopy = 9,
+ kCopy2 = 16
};
/** FLA movie sample structure */
@@ -193,7 +193,7 @@ void Movies::processFrame() {
case kFade: {
int16 innerOpcpde = stream.readSint16LE();
switch (innerOpcpde) {
- case 1:
+ case 1: // fla flute
_engine->_music->playMidiMusic(26);
break;
case 2:
@@ -225,8 +225,12 @@ void Movies::processFrame() {
break;
}
case kStopSample: {
- const uint16 sampleNum = stream.readUint16LE();
- _engine->_sound->stopSample(sampleNum);
+ const int16 sampleNum = stream.readSint16LE();
+ if (sampleNum == -1) {
+ _engine->_sound->stopSamples();
+ } else {
+ _engine->_sound->stopSample(sampleNum);
+ }
break;
}
case kDeltaFrame: {
@@ -240,13 +244,13 @@ void Movies::processFrame() {
drawKeyFrame(stream, FLASCREEN_WIDTH, FLASCREEN_HEIGHT);
break;
}
- case kFlaUnknown7: {
+ case kBlackFrame: {
const Common::Rect rect(0, 0, 79, 199);
_engine->_interface->drawFilledRect(rect, 0);
break;
}
- case kFlaUnknown9:
- case kFlaUnknown16SameAs9: {
+ case kCopy:
+ case kCopy2: {
const Common::Rect rect(0, 0, 80, 200);
byte *ptr = (byte *)_engine->_frontVideoBuffer.getPixels();
for (int y = rect.top; y < rect.bottom; ++y) {
@@ -264,6 +268,7 @@ void Movies::processFrame() {
/* int16 balance = */ stream.readSint16LE();
/* uint8 volumeLeft = */ stream.readByte();
/* uint8 volumeRight = */ stream.readByte();
+ // TODO: change balance
break;
}
default: {
More information about the Scummvm-git-logs
mailing list