[Scummvm-git-logs] scummvm master -> 468ca9e00e21f04c70e881bac42e0c2572fc2f46
bluegr
bluegr at gmail.com
Sun Jul 26 21:55:11 UTC 2020
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b9d33f4f93 STARTREK: Fix MIDI driver initialization
bf80aa1ed0 STARTREK: Some work and stubs for the game intro
e219042fb8 STARTREK: More work on the intro and credits. Remove custom math functions.
468ca9e00e STARTREK: Hook bridge function stubs
Commit: b9d33f4f93497b92003f321c60f8a2ef69a8651e
https://github.com/scummvm/scummvm/commit/b9d33f4f93497b92003f321c60f8a2ef69a8651e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-07-27T00:54:49+03:00
Commit Message:
STARTREK: Fix MIDI driver initialization
Changed paths:
engines/startrek/sound.cpp
diff --git a/engines/startrek/sound.cpp b/engines/startrek/sound.cpp
index 7976d05dc8..794a42db39 100644
--- a/engines/startrek/sound.cpp
+++ b/engines/startrek/sound.cpp
@@ -43,7 +43,6 @@ Sound::Sound(StarTrekEngine *vm) : _vm(vm) {
_midiDevice = MidiDriver::detectDevice(MDT_PCSPK | MDT_ADLIB | MDT_MIDI | MDT_PREFER_MT32);
_midiDriver = MidiDriver::createMidi(_midiDevice);
_midiDriver->open();
- _midiDriver->setTimerCallback(this, Sound::midiDriverCallback);
for (int i = 0; i < NUM_MIDI_SLOTS; i++) {
_midiSlots[i].slot = i;
@@ -58,6 +57,8 @@ Sound::Sound(StarTrekEngine *vm) : _vm(vm) {
_midiSlots[i].midiParser->setMidiDriver(_midiDriver);
_midiSlots[i].midiParser->setTimerRate(_midiDriver->getBaseTempo());
}
+
+ _midiDriver->setTimerCallback(this, Sound::midiDriverCallback);
}
_soundHandle = new Audio::SoundHandle();
Commit: bf80aa1ed0b7c95ca2200dbe363e078cb099cb70
https://github.com/scummvm/scummvm/commit/bf80aa1ed0b7c95ca2200dbe363e078cb099cb70
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-07-27T00:54:49+03:00
Commit Message:
STARTREK: Some work and stubs for the game intro
Changed paths:
engines/startrek/intro.cpp
diff --git a/engines/startrek/intro.cpp b/engines/startrek/intro.cpp
index 26f23557f9..4f95613a25 100644
--- a/engines/startrek/intro.cpp
+++ b/engines/startrek/intro.cpp
@@ -120,19 +120,19 @@ void StarTrekEngine::playIntro() {
}
switch (frame) {
- case 0:
+ case 0: // Starfield is shown
starfieldZoomSpeed = 10;
_sound->playMidiMusicTracks(MIDITRACK_0, -1);
_byte_45b3c = 0;
break;
- case 30:
+ case 30: // Kirk starts narrating
_sound->playVoc("kirkintr");
- loadSubtitleSprite(0, &subtitleSprite);
+ loadSubtitleSprite(0, &subtitleSprite); // "Space..."
break;
case 36:
- loadSubtitleSprite(1, &subtitleSprite);
+ loadSubtitleSprite(1, &subtitleSprite); // "The final frontier"
break;
case 42: // Enterprise moves toward camera
@@ -157,11 +157,93 @@ void StarTrekEngine::playIntro() {
starfieldZoomSpeed = 0;
break;
+ case 90:
+ loadSubtitleSprite(3, &subtitleSprite);
+ planetR3.field22 = 5000;
+ planetR3.field24 = 5000 / _starfieldPointDivisor;
+ // TODO: planet x/y
+ initIntroR3ObjectToMove(&_enterpriseR3, -30, 450, 45, 540, 54);
+ break;
+
+ case 108:
+ loadSubtitleSprite(4, &subtitleSprite);
+ break;
+
+ case 126:
+ loadSubtitleSprite(5, &subtitleSprite);
+ break;
+
+ case 144:
+ break;
+
+ case 150:
+ break;
+
+ case 162:
+ break;
+
+ case 168:
+ break;
+
case 186:
delR3(&_enterpriseR3);
// TODO: the rest
break;
+ case 204:
+ break;
+
+ case 216:
+ break;
+
+ case 222:
+ break;
+
+ case 228:
+ break;
+
+ case 240:
+ break;
+
+ case 252:
+ break;
+
+ case 264:
+ break;
+
+ case 276:
+ break;
+
+ case 288:
+ break;
+
+ case 300:
+ break;
+
+ case 312:
+ break;
+
+ case 324:
+ break;
+
+ case 330:
+ break;
+
+ case 336:
+ break;
+
+ case 342:
+ break;
+
+ case 348:
+ break;
+
+ case 354:
+ break;
+
+ case 360:
+ break;
+
case 366:
delete planetR3.bitmap;
planetR3.bitmap = nullptr;
Commit: e219042fb8bb8a674fac23d59b2908da5874428e
https://github.com/scummvm/scummvm/commit/e219042fb8bb8a674fac23d59b2908da5874428e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-07-27T00:54:49+03:00
Commit Message:
STARTREK: More work on the intro and credits. Remove custom math functions.
Changed paths:
R engines/startrek/math.cpp
engines/startrek/intro.cpp
engines/startrek/module.mk
engines/startrek/space.cpp
engines/startrek/startrek.h
diff --git a/engines/startrek/intro.cpp b/engines/startrek/intro.cpp
index 4f95613a25..14c2d556f8 100644
--- a/engines/startrek/intro.cpp
+++ b/engines/startrek/intro.cpp
@@ -120,24 +120,25 @@ void StarTrekEngine::playIntro() {
}
switch (frame) {
- case 0: // Starfield is shown
+ case 0: // Starfield is shown
starfieldZoomSpeed = 10;
_sound->playMidiMusicTracks(MIDITRACK_0, -1);
_byte_45b3c = 0;
break;
- case 30: // Kirk starts narrating
+ case 30: // Kirk starts narrating
_sound->playVoc("kirkintr");
- loadSubtitleSprite(0, &subtitleSprite); // "Space..."
+ loadSubtitleSprite(0, &subtitleSprite); // "Space..."
break;
case 36:
- loadSubtitleSprite(1, &subtitleSprite); // "The final frontier"
+ loadSubtitleSprite(1, &subtitleSprite); // "The final frontier"
break;
case 42: // Enterprise moves toward camera
loadSubtitleSprite(-1, &subtitleSprite);
addR3(&_enterpriseR3);
+ _enterpriseR3.bitmap = nullptr;
_enterpriseR3.field1e = 2;
initIntroR3ObjectToMove(&_enterpriseR3, 330, 5000, 0, 0, 18);
break;
@@ -159,9 +160,9 @@ void StarTrekEngine::playIntro() {
case 90:
loadSubtitleSprite(3, &subtitleSprite);
- planetR3.field22 = 5000;
- planetR3.field24 = 5000 / _starfieldPointDivisor;
- // TODO: planet x/y
+ initIntroR3ObjectToMove(&planetR3, 0, 5000, 0, 5000, 0);
+ planetR3.pos.y = -2500;
+ planetR3.pos.z = -1;
initIntroR3ObjectToMove(&_enterpriseR3, -30, 450, 45, 540, 54);
break;
@@ -174,79 +175,106 @@ void StarTrekEngine::playIntro() {
break;
case 144:
+ loadSubtitleSprite(6, &subtitleSprite);
+ initIntroR3ObjectToMove(&planetR3, 30, 5600, 30, 5600, 0);
+ planetR3.pos.y = -2500;
+ planetR3.pos.z = -1;
+ initIntroR3ObjectToMove(&_enterpriseR3, -10, 800, 155, 600, 18);
break;
case 150:
+ loadSubtitleSprite(6, &subtitleSprite);
break;
case 162:
+ delR3(&planetR3);
break;
case 168:
+ loadSubtitleSprite(-1, &subtitleSprite);
+ initIntroR3ObjectToMove(&_enterpriseR3, 340, 5000, 0, 0, 18);
break;
case 186:
delR3(&_enterpriseR3);
+ showCreditsScreen(&planetR3, 0, false);
+ initIntroR3ObjectToMove(&planetR3, 0, 0, 0, _starfieldPointDivisor, 18);
// TODO: the rest
break;
case 204:
+ // TODO
break;
case 216:
+ // TODO
break;
case 222:
+ delR3(&planetR3);
break;
case 228:
+ showCreditsScreen(&planetR3, 1, false);
break;
case 240:
+ showCreditsScreen(&planetR3, 2);
break;
case 252:
+ showCreditsScreen(&planetR3, 3);
break;
case 264:
+ showCreditsScreen(&planetR3, 4);
break;
case 276:
+ showCreditsScreen(&planetR3, 5);
break;
case 288:
+ showCreditsScreen(&planetR3, 6);
break;
case 300:
+ showCreditsScreen(&planetR3, 7);
break;
case 312:
+ showCreditsScreen(&planetR3, 8);
break;
case 324:
+ showCreditsScreen(&planetR3, 9);
break;
case 330:
+ showCreditsScreen(&planetR3, 10);
break;
case 336:
+ showCreditsScreen(&planetR3, 11);
break;
case 342:
+ showCreditsScreen(&planetR3, 12);
break;
case 348:
+ showCreditsScreen(&planetR3, 13);
break;
case 354:
+ showCreditsScreen(&planetR3, 14);
break;
case 360:
+ showCreditsScreen(&planetR3, 15);
break;
case 366:
- delete planetR3.bitmap;
- planetR3.bitmap = nullptr;
delR3(&planetR3);
break;
@@ -281,19 +309,28 @@ void StarTrekEngine::playIntro() {
// TODO: the rest
}
-void StarTrekEngine::initIntroR3ObjectToMove(R3 *r3, int16 srcAngle, int16 srcDepth, int16 destAngle, int16 destDepth, int16 ticks) {
- Fixed8 a1 = Fixed8::fromRaw((srcAngle << 8) / 90);
- Fixed8 a2 = Fixed8::fromRaw((destAngle << 8) / 90);
-
- r3->pos.x = sin(a1).multToInt(srcDepth) + _starfieldPosition.x;
- r3->pos.z = cos(a1).multToInt(srcDepth) + _starfieldPosition.z;
- r3->pos.y = 0;
-
- int32 deltaX = sin(a2).multToInt(destDepth) + _starfieldPosition.x - r3->pos.x;
- int32 deltaZ = cos(a2).multToInt(destDepth) + _starfieldPosition.z - r3->pos.z;
- debug("Z: %d, %d", r3->pos.z - _starfieldPosition.z, cos(a2).multToInt(destDepth));
+void StarTrekEngine::showCreditsScreen(R3 *creditsBuffer, int index, bool deletePrevious) {
+ if (deletePrevious) {
+ delR3(creditsBuffer);
+ }
+ creditsBuffer->bitmap = new Bitmap(loadFile(Common::String::format("credit%02d.shp", index)));
+ creditsBuffer->field1e = 3;
+ creditsBuffer->field22 = 1;
+ creditsBuffer->field24 = 1;
+ addR3(creditsBuffer);
+}
+void StarTrekEngine::initIntroR3ObjectToMove(R3 *r3, int16 srcAngle, int16 srcDepth, int16 destAngle, int16 destDepth, int16 ticks) {
+ int32 srcAngleX = (int32)floor((double)_sineTable.at(srcAngle / 90) * srcDepth);
+ int32 srcAngleZ = (int32)floor((double)_cosineTable.at(srcAngle / 90) * srcDepth);
+ r3->pos = Point3(srcAngleX + _starfieldPosition.x, 0, srcAngleZ + _starfieldPosition.z);
+
+ int32 destAngleX = (int32)floor((double)_sineTable.at(destAngle / 90) * destDepth);
+ int32 destAngleZ = (int32)floor((double)_cosineTable.at(destAngle / 90) * destDepth);
+ int32 deltaX = destAngleX + _starfieldPosition.x - r3->pos.x;
+ int32 deltaZ = destAngleZ + _starfieldPosition.z - r3->pos.z;
Angle angle = atan2(deltaX, deltaZ);
+
r3->matrix = initSpeedMatrixForXZMovement(angle, initMatrix());
debugCN(5, kDebugSpace, "initIntroR3ObjectToMove: pos %x,%x,%x; ", r3->pos.x, r3->pos.y, r3->pos.z);
diff --git a/engines/startrek/math.cpp b/engines/startrek/math.cpp
deleted file mode 100644
index f9527dd413..0000000000
--- a/engines/startrek/math.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "startrek/startrek.h"
-
-namespace StarTrek {
-
-Fixed14 StarTrekEngine::sin(Angle angle) {
- int16 i = angle.raw();
- if (angle < 0) {
- i %= 0x400;
- i += 0x400;
- }
- i &= 0x3ff;
-
- if (i == 0x100)
- return 1.0;
- else if (i == 0x300)
- return -1.0;
-
- float f = _sineTable.at(i);
- return Fixed14(f);
-}
-
-Fixed14 StarTrekEngine::cos(Angle angle) {
- return sin(angle + 1.0);
-}
-
-Angle StarTrekEngine::atan2(int32 deltaX, int32 deltaY) {
- static const int16 atanTable[] = {
- 0x0000, 0x0064, 0x00c9, 0x012d, 0x0192, 0x01f6, 0x025b, 0x02c0,
- 0x0324, 0x0389, 0x03ee, 0x0453, 0x04b8, 0x051d, 0x0582, 0x05e8,
- 0x064d, 0x06b3, 0x0718, 0x077e, 0x07e4, 0x084a, 0x08b1, 0x0917,
- 0x097e, 0x09e5, 0x0a4c, 0x0ab3, 0x0b1a, 0x0b82, 0x0bea, 0x0c52,
- 0x0cba, 0x0d23, 0x0d8c, 0x0df5, 0x0e5f, 0x0ec8, 0x0f32, 0x0f9d,
- 0x1007, 0x1072, 0x10de, 0x114a, 0x11b6, 0x1222, 0x128f, 0x12fc,
- 0x136a, 0x13d8, 0x1446, 0x14b5, 0x1524, 0x1594, 0x1604, 0x1675,
- 0x16e6, 0x1757, 0x17ca, 0x183c, 0x18b0, 0x1923, 0x1998, 0x1a0c,
- 0x1a82, 0x1af8, 0x1b6f, 0x1be6, 0x1c5e, 0x1cd7, 0x1d50, 0x1dca,
- 0x1e45, 0x1ec0, 0x1f3c, 0x1fb9, 0x2037, 0x20b5, 0x2134, 0x21b4,
- 0x2235, 0x22b7, 0x2339, 0x23bd, 0x2441, 0x24c6, 0x254c, 0x25d4,
- 0x265c, 0x26e5, 0x276f, 0x27fa, 0x2887, 0x2914, 0x29a2, 0x2a32,
- 0x2ac3, 0x2b55, 0x2be8, 0x2c7d, 0x2d12, 0x2da9, 0x2e42, 0x2edc,
- 0x2f77, 0x3013, 0x30b1, 0x3151, 0x31f2, 0x3294, 0x3338, 0x33de,
- 0x3486, 0x352f, 0x35d9, 0x3686, 0x3734, 0x37e5, 0x3897, 0x394b,
- 0x3a01, 0x3ab9, 0x3b73, 0x3c30, 0x3cee, 0x3daf, 0x3e72, 0x3f38,
- 0x4000
- };
-
- if (deltaX == 0 && deltaY == 0)
- return 0.0;
-
- bool deltaYNegative = deltaY <= 0;
- bool deltaXNegative = deltaX <= 0;
-
- deltaY = abs(deltaY);
- deltaX = abs(deltaX);
-
- Fixed14 ratio;
- if (deltaY > deltaX)
- ratio = Fixed14::fromRaw(((deltaX & 0xffff0000) >> 2) / deltaY);
- else
- ratio = Fixed14::fromRaw(((deltaY & 0xffff0000) >> 2) / deltaX);
-
- int16 endIndex = 128;
- int16 index = 0;
- int16 angle = 0;
- while (index <= endIndex) {
- angle = (index + endIndex) / 2;
- Fixed14 tableValue = Fixed14::fromRaw(atanTable[angle]);
- if (tableValue > ratio)
- endIndex = angle - 1;
- else if (tableValue < ratio)
- index = angle + 1;
- else
- break;
- }
-
- if (deltaY > deltaX) {
- if (deltaYNegative && deltaXNegative)
- angle = angle - 512;
- else if (deltaYNegative && !deltaXNegative)
- angle = 512 - angle;
- else if (!deltaYNegative && deltaXNegative)
- angle = -angle;
- // else if (!deltaYNegative && !deltaXNegative)
- // angle remains the same i.e. angle = angle
- } else {
- if (deltaYNegative && deltaXNegative)
- angle = -256 - angle;
- else if (deltaYNegative && !deltaXNegative)
- angle = 256 + angle;
- else if (!deltaYNegative && deltaXNegative)
- angle = -256 + angle;
- else // if (!deltaYNegative && !deltaXNegative)
- angle = 256 - angle;
- }
-
- return Angle::fromRaw(angle);
-}
-
-} // End of namespace StarTrek
diff --git a/engines/startrek/module.mk b/engines/startrek/module.mk
index cc4b32a5fc..a86d7efd0a 100644
--- a/engines/startrek/module.mk
+++ b/engines/startrek/module.mk
@@ -13,7 +13,6 @@ MODULE_OBJS = \
intro.o \
iwfile.o \
lzss.o \
- math.o \
menu.o \
room.o \
saveload.o \
diff --git a/engines/startrek/space.cpp b/engines/startrek/space.cpp
index 6da45f7170..21942113af 100644
--- a/engines/startrek/space.cpp
+++ b/engines/startrek/space.cpp
@@ -59,6 +59,9 @@ void StarTrekEngine::addR3(R3 *r3) {
}
void StarTrekEngine::delR3(R3 *r3) {
+ delete r3->bitmap;
+ r3->bitmap = nullptr;
+
for (int i = 0; i < NUM_SPACE_OBJECTS; i++) {
if (_r3List[i] == r3) {
_r3List[i] = nullptr;
@@ -499,9 +502,9 @@ void StarTrekEngine::drawR3Shape(R3 *r3) {
}
bool StarTrekEngine::sub_1c022(R3 *r3) {
- Point3 point = r3->field36;
- if (point.z < _flt_50898)
- return false;
+ //Point3 point = r3->field36;
+ //if (point.z < _flt_50898)
+ // return false;
return true; // TODO: finish this properly
}
@@ -535,6 +538,8 @@ Point3 StarTrekEngine::matrixMult(const Point3 &point, const Matrix &weight) {
}
int32 StarTrekEngine::scaleSpacePosition(int32 x, int32 z) {
+ if (x == 0 || z == 0)
+ return 0;
return (x * _starfieldPointDivisor) / z;
}
@@ -547,8 +552,8 @@ Matrix StarTrekEngine::initMatrix() {
}
Matrix StarTrekEngine::initSpeedMatrixForXZMovement(Angle angle, const Matrix &matrix) {
- Fixed14 sinVal = sin(angle);
- Fixed14 cosVal = cos(angle);
+ Fixed14 sinVal = sin(angle.toDouble());
+ Fixed14 cosVal = cos(angle.toDouble());
Matrix matrix1 = initMatrix();
matrix1[0].x = cosVal;
diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h
index 8b27c07042..d9e7a77b1b 100644
--- a/engines/startrek/startrek.h
+++ b/engines/startrek/startrek.h
@@ -23,6 +23,7 @@
#ifndef STARTREK_H
#define STARTREK_H
+#include "common/cosinetables.h"
#include "common/events.h"
#include "common/list.h"
#include "common/ptr.h"
@@ -259,15 +260,6 @@ public:
*/
Common::String getLoadedText(int textIndex);
-
- // math.cpp
- /**
- * Unit of the angle is "quadrants" (90 degrees = 1.0)
- */
- Fixed14 sin(Angle angle);
- Fixed14 cos(Angle angle);
- Angle atan2(int32 deltaX, int32 deltaZ);
-
// awaymission.cpp
void initAwayMission();
void runAwayMission();
@@ -292,7 +284,6 @@ public:
Fixed8 getActorScaleAtPosition(int16 y);
void addAction(const Action &action);
void addAction(byte type, byte b1, byte b2, byte b3);
- bool checkItemInteractionExists(int action, int activeItem, int passiveItem, int16 arg6);
void handleAwayMissionAction();
void checkTouchedLoadingZone(int16 x, int16 y);
@@ -314,6 +305,7 @@ public:
// intro.cpp
private:
void playIntro();
+ void showCreditsScreen(R3 *creditsBuffer, int index, bool deletePrevious = true);
/**
* Initializes an object to spawn at one position and move toward another position.
* @param ticks The number of ticks it should take for the object to reach the destination
@@ -768,6 +760,7 @@ public:
private:
Common::RandomSource _randomSource;
Common::SineTable _sineTable;
+ Common::CosineTable _cosineTable;
Room *_room;
Common::MacResManager *_macResFork;
};
Commit: 468ca9e00e21f04c70e881bac42e0c2572fc2f46
https://github.com/scummvm/scummvm/commit/468ca9e00e21f04c70e881bac42e0c2572fc2f46
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-07-27T00:54:49+03:00
Commit Message:
STARTREK: Hook bridge function stubs
Changed paths:
engines/startrek/startrek.cpp
diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp
index 6dfcbca151..6bbc3c1b0c 100644
--- a/engines/startrek/startrek.cpp
+++ b/engines/startrek/startrek.cpp
@@ -53,7 +53,8 @@ StarTrekEngine::StarTrekEngine(OSystem *syst, const StarTrekGameDescription *gam
_spockActor(&_actorList[1]),
_mccoyActor(&_actorList[2]),
_redshirtActor(&_actorList[3]),
- _sineTable(1024) {
+ _sineTable(1024),
+ _cosineTable(1024) {
if (getPlatform() != Common::kPlatformDOS)
error("Only DOS versions of Star Trek: 25th Anniversary are currently supported");
@@ -190,7 +191,7 @@ Common::Error StarTrekEngine::runGameMode(int mode, bool resume) {
// Cleanup previous game mode
switch (_lastGameMode) {
case GAMEMODE_BRIDGE:
- //cleanupBridge();
+ cleanupBridge();
break;
case GAMEMODE_AWAYMISSION:
@@ -209,7 +210,7 @@ Common::Error StarTrekEngine::runGameMode(int mode, bool resume) {
switch (_gameMode) {
case GAMEMODE_BRIDGE:
_sound->loadMusicFile("bridge");
- //initBridge();
+ initBridge(false); // TODO: param
break;
case GAMEMODE_AWAYMISSION:
More information about the Scummvm-git-logs
mailing list