aboutsummaryrefslogtreecommitdiff
path: root/engines/startrek
diff options
context:
space:
mode:
authorMatthew Stewart2019-02-23 20:40:54 -0500
committerFilippos Karapetis2019-05-28 08:08:52 +0300
commit944370c349e60c47a23165057084de3faa414802 (patch)
tree1b45f02fd3f5bf219349a30bafad9917b4a36f21 /engines/startrek
parent552b88cbd5464d1468b6b3b7f3cf4cc44378b8fc (diff)
downloadscummvm-rg350-944370c349e60c47a23165057084de3faa414802.tar.gz
scummvm-rg350-944370c349e60c47a23165057084de3faa414802.tar.bz2
scummvm-rg350-944370c349e60c47a23165057084de3faa414802.zip
STARTREK: Fixes to drawR3Shape; red planet renders
Diffstat (limited to 'engines/startrek')
-rw-r--r--engines/startrek/space.cpp44
-rw-r--r--engines/startrek/space.h2
-rw-r--r--engines/startrek/startrek.cpp2
3 files changed, 24 insertions, 24 deletions
diff --git a/engines/startrek/space.cpp b/engines/startrek/space.cpp
index ec1c89dfb2..781993fb67 100644
--- a/engines/startrek/space.cpp
+++ b/engines/startrek/space.cpp
@@ -325,13 +325,13 @@ void StarTrekEngine::drawR3Shape(R3 *r3) {
int16 index1 = i;
int16 index2 = (i + 1) & 3;
- if (thing[index1 + 1] > thing[index2 + 1]) {
+ if (thing[index1 * 2 + 1] > thing[index2 * 2 + 1]) {
index1 = index2;
index2 = i;
}
- int16 top = ceil(thing[index1 + 1]);
- int16 bottom = floor(thing[index2 + 1]);
+ int16 top = ceil(thing[index1 * 2 + 1]);
+ int16 bottom = floor(thing[index2 * 2 + 1]);
if (top > bottom)
continue;
@@ -350,29 +350,29 @@ void StarTrekEngine::drawR3Shape(R3 *r3) {
shpImageBottom = bottom;
double dbl3f4;
- if (thing[index2 + 1] == thing[index1 + 1])
+ if (thing[index2 * 2 + 1] == thing[index1 * 2 + 1])
dbl3f4 = 0.0;
else
- dbl3f4 = (thing[index2] - thing[index1]) / (thing[index2 + 1] - thing[index1 + 1]);
+ dbl3f4 = (thing[index2 * 2] - thing[index1 * 2]) / (thing[index2 * 2 + 1] - thing[index1 * 2 + 1]);
- int32 var3ec = (int32)(0x10000 * dbl3f4);
- int32 var3e8 = (int32)(((top - thing[index1 + 1]) * dbl3f4 + thing[index1]) * 0x10000);
+ int32 boundDiff = (int32)(0x10000 * dbl3f4); // var3ec
+ int32 boundBase = (int32)(((top - thing[index1 * 2 + 1]) * dbl3f4 + thing[index1 * 2]) * 0x10000); // var3e8
for (int y = top; y <= bottom; y++) {
- int16 var3f6 = var3e8 >> 16;
- int16 var3f8 = (var3e8 + 0xffff) >> 16;
+ int16 rightBound = boundBase >> 16; // var3f6
+ int16 leftBound = (boundBase + 0xffff) >> 16; // var3f8
- if (var3f8 < _starfieldRect.left)
- var3f8 = _starfieldRect.left;
- if (var3f8 < leftBounds[y])
- leftBounds[y] = var3f8;
+ if (leftBound < _starfieldRect.left)
+ leftBound = _starfieldRect.left;
+ if (leftBound < leftBounds[y])
+ leftBounds[y] = leftBound;
- if (var3f6 > _starfieldRect.right - 1)
- var3f6 = _starfieldRect.right - 1;
- if (var3f6 > rightBounds[y])
- rightBounds[y] = var3f6;
+ if (rightBound > _starfieldRect.right - 1)
+ rightBound = _starfieldRect.right - 1;
+ if (rightBound > rightBounds[y])
+ rightBounds[y] = rightBound;
- var3e8 += var3ec;
+ boundBase += boundDiff;
}
}
@@ -389,7 +389,6 @@ void StarTrekEngine::drawR3Shape(R3 *r3) {
break;
}
- debug("Top: %d, Bot: %d", shpImageTop, shpImageBottom);
if (shpImageTop <= shpImageBottom) {
bool var3fa = false;
if (r3->field1e == 2) {
@@ -406,8 +405,10 @@ void StarTrekEngine::drawR3Shape(R3 *r3) {
}
}
+ // Amount added to X/Y positions after each pixel is drawn
int16 xDiff = (int16)(dbl60 * 256);
int16 yDiff = (int16)(dbl58 * 256);
+
int16 var3f2 = (int16)(dbl50 * 256);
int16 var3f4 = (int16)(dbl48 * 256);
@@ -447,6 +448,7 @@ void StarTrekEngine::drawR3Shape(R3 *r3) {
for (int y = shpImageTop; y <= shpImageBottom; y++) {
int16 leftBound = leftBounds[y];
int16 rowWidth = rightBounds[y] - leftBound;
+
int16 srcX = leftBound * xDiff + var3f6;
int16 srcY = leftBound * yDiff + var3f8;
var3f6 += var3f2;
@@ -458,8 +460,6 @@ void StarTrekEngine::drawR3Shape(R3 *r3) {
if (rowWidth == 0)
continue;
- debug("Width: %d", rowWidth);
-
if (var3fa) {
srcX += 0x80;
srcY += 0x80;
@@ -473,7 +473,7 @@ void StarTrekEngine::drawR3Shape(R3 *r3) {
cx += xDiff;
bx += yDiff;
if (b == 0)
- *(di++) = 8; // FIXME: shouldn't assign anything, fix after done testing
+ di++;
else
*(di++) = b;
}
diff --git a/engines/startrek/space.h b/engines/startrek/space.h
index d5a05d4b74..075ea0951d 100644
--- a/engines/startrek/space.h
+++ b/engines/startrek/space.h
@@ -136,7 +136,7 @@ public:
*this = *this * m2;
}
- TMatrix<T> invert() {
+ TMatrix<T> invert() const {
TMatrix<T> ret;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp
index 85129117ae..6160f9caf3 100644
--- a/engines/startrek/startrek.cpp
+++ b/engines/startrek/startrek.cpp
@@ -127,7 +127,7 @@ Common::Error StarTrekEngine::run() {
initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT, &format);
initializeEventsAndMouse();
- bool shouldPlayIntro = false;
+ bool shouldPlayIntro = true;
bool loadedSave = false;
if (ConfMan.hasKey("save_slot")) {