[Scummvm-git-logs] scummvm master -> 47c0e2701796962edd946ae463ae92ba806c4280
sev-
sev at scummvm.org
Sat Aug 18 16:31:03 CEST 2018
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9cfc70e7fe COMMON: allow cos/sin number of points to be more flexible
e859a6f13e BLADERUNNER: Update cos/sin table constructor change
da57cef0c3 COMMON: FFT update cos/sin table constructor change
0805ac2be3 STARTREK: Update cos/sin table constructor change
47c0e27017 STARTREK: Simplify sine table usage
Commit: 9cfc70e7fe881cfbd680322b6beeb9a7ab7149c3
https://github.com/scummvm/scummvm/commit/9cfc70e7fe881cfbd680322b6beeb9a7ab7149c3
Author: David Fioramonti (dafioram at gmail.com)
Date: 2018-08-18T16:30:57+02:00
Commit Message:
COMMON: allow cos/sin number of points to be more flexible
Previously, the cos/sin table had to be a power of 2, but there
are many use cases where the number of points is not necessarily
a power of 2 so this change the constructor so it now takes
in the number of points rather than the number of points as the
exponent of a power of 2.
The restriction is that the size must be divisible by 4.
Changed paths:
common/cosinetables.cpp
common/cosinetables.h
common/sinetables.cpp
common/sinetables.h
diff --git a/common/cosinetables.cpp b/common/cosinetables.cpp
index 42c6e4e..589c7c7 100644
--- a/common/cosinetables.cpp
+++ b/common/cosinetables.cpp
@@ -27,12 +27,11 @@
namespace Common {
-CosineTable::CosineTable(int bitPrecision) {
- assert((bitPrecision >= 4) && (bitPrecision <= 16));
+CosineTable::CosineTable(int nPoints) {
+ assert((nPoints >= 16) && (nPoints <= 65536)); // log2 space is in [4,16]
+ assert(nPoints % 4 == 0);
- _bitPrecision = bitPrecision;
-
- _nPoints = 1 << _bitPrecision;
+ _nPoints = nPoints;
_radResolution = 2.0 * M_PI / _nPoints;
_refSize = _nPoints / 4;
_table = new float[_nPoints / 2];
diff --git a/common/cosinetables.h b/common/cosinetables.h
index c08bb4c..ac0aef8 100644
--- a/common/cosinetables.h
+++ b/common/cosinetables.h
@@ -28,40 +28,34 @@ namespace Common {
class CosineTable {
public:
/**
- * Construct a cosine table with the specified bit precision
+ * Construct a cosine table given the number of points
*
- * @param bitPrecision Precision of the table, which must be in range [4, 16]
+ * @param nPoints Number of distinct radian points, which must be in range [16,65536] and be divisible by 4
*/
- CosineTable(int bitPrecision);
+ CosineTable(int nPoints);
~CosineTable();
/**
* Get pointer to table.
*
- * This table contains 2^bitPrecision/2 entries.
+ * This table contains nPoints/2 entries.
* Prefer to use at()
* The layout of this table is as follows:
- * - Entries 0 up to (including) 2^bitPrecision/4:
+ * - Entries 0 up to (including) nPoints/4:
* cos(0) till (including) cos(1/2*pi)
- * - Entries (excluding) 2^bitPrecision/4 up to 2^bitPrecision/2:
+ * - Entries (excluding) nPoints/4 up to nPoints/2:
* (excluding) cos(3/2*pi) till (excluding) cos(2*pi)
*/
const float *getTable() { return _table; }
/**
- * Returns cos(2*pi * index / 2^bitPrecision )
- * Index must be in range [0,2^bitPrecision-1]
+ * Returns cos(2*pi * index / nPoints )
+ * Index must be in range [0, nPoints - 1]
*/
float at(int index) const;
- /**
- * Get bit precision
- */
- int getBitPrecision() { return _bitPrecision; }
-
private:
float *_table;
- int _bitPrecision;
double _radResolution; // Smallest radian increment
int _refSize; // _nPoints / 4
int _nPoints; // range of operator[]
diff --git a/common/sinetables.cpp b/common/sinetables.cpp
index c85a7bf..1dce529 100644
--- a/common/sinetables.cpp
+++ b/common/sinetables.cpp
@@ -27,12 +27,11 @@
namespace Common {
-SineTable::SineTable(int bitPrecision) {
- assert((bitPrecision >= 4) && (bitPrecision <= 16));
+SineTable::SineTable(int nPoints) {
+ assert((nPoints >= 16) && (nPoints <= 65536)); // log2 space is in [4,16]
+ assert(nPoints % 4 == 0);
- _bitPrecision = bitPrecision;
-
- _nPoints = 1 << _bitPrecision;
+ _nPoints = nPoints;
_radResolution = 2.0 * M_PI / _nPoints;
_refSize = _nPoints / 4;
_table = new float[_nPoints / 2];
diff --git a/common/sinetables.h b/common/sinetables.h
index f91592c..5a5f246 100644
--- a/common/sinetables.h
+++ b/common/sinetables.h
@@ -28,40 +28,34 @@ namespace Common {
class SineTable {
public:
/**
- * Construct a sine table with the specified bit precision
+ * Construct a sine table given the number of points
*
- * @param bitPrecision Precision of the table, which must be in range [4, 16]
+ * @param nPoints Number of distinct radian points, which must be in range [16,65536] and be divisible by 4
*/
- SineTable(int bitPrecision);
+ SineTable(int nPoints);
~SineTable();
/**
* Get pointer to table
*
- * This table contains 2^bitPrecision/2 entries.
+ * This table contains nPoints/2 entries.
* Prefer to use at()
* The layout of this table is as follows:
- * - Entries 0 up to (excluding) 2^bitPrecision/4:
+ * - Entries 0 up to (excluding) nPoints/4:
* sin(0) till (excluding) sin(1/2*pi)
- * - Entries 2^bitPrecision/4 up to 2^bitPrecision/2:
+ * - Entries 2_nPoints/4 up to nPoints/2:
* sin(pi) till (excluding) sin(3/2*pi)
*/
const float *getTable() { return _table; }
/**
- * Returns sin(2*pi * index / 2^bitPrecision )
- * Index must be in range [0,2^bitPrecision-1]
+ * Returns sin(2*pi * index / nPoints )
+ * Index must be in range [0, nPoints - 1]
*/
float at(int index) const;
- /**
- * Get bit precision
- */
- int getBitPrecision() { return _bitPrecision; }
-
private:
float *_table;
- int _bitPrecision;
double _radResolution; // Smallest radian increment
int _refSize; // _nPoints / 4
int _nPoints; // range of operator[]
Commit: e859a6f13e97a72407d031c60554550d5adb64d7
https://github.com/scummvm/scummvm/commit/e859a6f13e97a72407d031c60554550d5adb64d7
Author: David Fioramonti (dafioram at gmail.com)
Date: 2018-08-18T16:30:57+02:00
Commit Message:
BLADERUNNER: Update cos/sin table constructor change
They now take in the size rather than the power of 2 exponent.
Changed paths:
engines/bladerunner/bladerunner.cpp
diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index 4ad3ab0..362e0c4 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -315,8 +315,8 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
// Seed rand
// TODO: Sine and cosine lookup tables for intervals of 1.0, 4.0, and 12.0
- _cosTable1024 = new Common::CosineTable(10); // 10-bits = 1024 points for 2*PI;
- _sinTable1024 = new Common::SineTable(10);
+ _cosTable1024 = new Common::CosineTable(1024); // 10-bits = 1024 points for 2*PI;
+ _sinTable1024 = new Common::SineTable(1024);
_view = new View();
Commit: da57cef0c34162789100ea25eb0f4f3f7a1e90bf
https://github.com/scummvm/scummvm/commit/da57cef0c34162789100ea25eb0f4f3f7a1e90bf
Author: David Fioramonti (dafioram at gmail.com)
Date: 2018-08-18T16:30:57+02:00
Commit Message:
COMMON: FFT update cos/sin table constructor change
They now take in the size rather than the power of 2 exponent.
Changed paths:
common/fft.cpp
diff --git a/common/fft.cpp b/common/fft.cpp
index a750792..30e5449 100644
--- a/common/fft.cpp
+++ b/common/fft.cpp
@@ -37,6 +37,7 @@ FFT::FFT(int bits, int inverse) : _bits(bits), _inverse(inverse) {
assert((_bits >= 2) && (_bits <= 16));
int n = 1 << bits;
+ int nPoints;
_tmpBuf = new Complex[n];
_expTab = new Complex[n / 2];
@@ -48,8 +49,10 @@ FFT::FFT(int bits, int inverse) : _bits(bits), _inverse(inverse) {
_revTab[-splitRadixPermutation(i, n, _inverse) & (n - 1)] = i;
for (int i = 0; i < ARRAYSIZE(_cosTables); i++) {
- if (i+4 <= _bits)
- _cosTables[i] = new Common::CosineTable(i+4);
+ if (i + 4 <= _bits) {
+ nPoints = 1 << (i + 4);
+ _cosTables[i] = new Common::CosineTable(nPoints);
+ }
else
_cosTables[i] = nullptr;
}
Commit: 0805ac2be355659229f960f6fa3a889afa2d2ddc
https://github.com/scummvm/scummvm/commit/0805ac2be355659229f960f6fa3a889afa2d2ddc
Author: David Fioramonti (dafioram at gmail.com)
Date: 2018-08-18T16:30:57+02:00
Commit Message:
STARTREK: Update cos/sin table constructor change
They now take in the size rather than the power of 2 exponent.
Changed paths:
engines/startrek/startrek.cpp
diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp
index e0aef01..cbbadc2 100644
--- a/engines/startrek/startrek.cpp
+++ b/engines/startrek/startrek.cpp
@@ -53,7 +53,7 @@ StarTrekEngine::StarTrekEngine(OSystem *syst, const StarTrekGameDescription *gam
_spockActor(&_actorList[1]),
_mccoyActor(&_actorList[2]),
_redshirtActor(&_actorList[3]),
- _sineTable(10) {
+ _sineTable(1024) {
if (getPlatform() != Common::kPlatformDOS)
error("Only DOS versions of Star Trek: 25th Anniversary are currently supported");
Commit: 47c0e2701796962edd946ae463ae92ba806c4280
https://github.com/scummvm/scummvm/commit/47c0e2701796962edd946ae463ae92ba806c4280
Author: David Fioramonti (dafioram at gmail.com)
Date: 2018-08-18T16:30:57+02:00
Commit Message:
STARTREK: Simplify sine table usage
The if checks that StarTrekEngine::sin is doing to evaluate the
correct index for the sine table lookup are already done in
Common::SineTable::at().
Changed paths:
engines/startrek/math.cpp
diff --git a/engines/startrek/math.cpp b/engines/startrek/math.cpp
index 114ec5c..7770ed3 100644
--- a/engines/startrek/math.cpp
+++ b/engines/startrek/math.cpp
@@ -37,15 +37,7 @@ Fixed14 StarTrekEngine::sin(Angle angle) {
else if (i == 0x300)
return -1.0;
- float f = 0.0;
- if (i < 0x100)
- f = _sineTable.getTable()[i & 0xff];
- else if (i < 0x200)
- f = _sineTable.getTable()[256 - (i & 0xff)];
- else if (i < 0x300)
- f = -_sineTable.getTable()[i & 0xff];
- else if (i < 0x400)
- f = -_sineTable.getTable()[256 - (i & 0xff)];
+ float f = _sineTable.at(i);
return Fixed14(f);
}
More information about the Scummvm-git-logs
mailing list