aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision
diff options
context:
space:
mode:
authorrichiesams2013-07-30 14:25:31 -0500
committerrichiesams2013-08-04 13:32:55 -0500
commitf1135292d0d714187b719988dba8d5a7d487fe94 (patch)
tree57f6a7e185dbfadefac514c8a8d1cdd4d6dc721b /engines/zvision
parent89d8496dbac2fb1fc5fc77d5b26fa2a9405f9d77 (diff)
downloadscummvm-rg350-f1135292d0d714187b719988dba8d5a7d487fe94.tar.gz
scummvm-rg350-f1135292d0d714187b719988dba8d5a7d487fe94.tar.bz2
scummvm-rg350-f1135292d0d714187b719988dba8d5a7d487fe94.zip
ZVISION: Optimize integer type usages
The general thought is int is faster than int16 or byte. So if you can afford the space, use it over int16 or byte. Also, only use int32 when you specifically need the 32 bits.
Diffstat (limited to 'engines/zvision')
-rw-r--r--engines/zvision/action_node.cpp2
-rw-r--r--engines/zvision/action_node.h2
-rw-r--r--engines/zvision/actions.cpp2
-rw-r--r--engines/zvision/actions.h32
-rw-r--r--engines/zvision/control.cpp8
-rw-r--r--engines/zvision/events.cpp2
-rw-r--r--engines/zvision/lzss_read_stream.cpp6
-rw-r--r--engines/zvision/lzss_read_stream.h4
-rw-r--r--engines/zvision/puzzle.h2
-rw-r--r--engines/zvision/render_table.cpp14
-rw-r--r--engines/zvision/render_table.h4
-rw-r--r--engines/zvision/scr_file_handling.cpp4
-rw-r--r--engines/zvision/script_manager.cpp12
-rw-r--r--engines/zvision/script_manager.h16
-rw-r--r--engines/zvision/utility.h2
-rw-r--r--engines/zvision/video.cpp14
-rw-r--r--engines/zvision/zork_raw.cpp4
-rw-r--r--engines/zvision/zork_raw.h4
-rw-r--r--engines/zvision/zvision.cpp2
-rw-r--r--engines/zvision/zvision.h2
20 files changed, 69 insertions, 69 deletions
diff --git a/engines/zvision/action_node.cpp b/engines/zvision/action_node.cpp
index dec52d9615..1a51690b3f 100644
--- a/engines/zvision/action_node.cpp
+++ b/engines/zvision/action_node.cpp
@@ -28,7 +28,7 @@
namespace ZVision {
-NodeTimer::NodeTimer(uint32 key, uint32 timeInSeconds)
+NodeTimer::NodeTimer(uint32 key, uint timeInSeconds)
: _key(key), _timeLeft(timeInSeconds * 1000) {}
bool NodeTimer::process(ZVision *engine, uint32 deltaTimeInMillis) {
diff --git a/engines/zvision/action_node.h b/engines/zvision/action_node.h
index 324dba279d..5b4430c3a4 100644
--- a/engines/zvision/action_node.h
+++ b/engines/zvision/action_node.h
@@ -37,7 +37,7 @@ public:
class NodeTimer : public ActionNode {
public:
- NodeTimer(uint32 key, uint32 timeInSeconds);
+ NodeTimer(uint32 key, uint timeInSeconds);
/**
* Decrement the timer by the delta time. If the timer is finished, set the status
* in _globalState and let this node be deleted
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 0cec6af76e..2e1334c38b 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -174,7 +174,7 @@ ResultAction *ActionRandom::clone() const {
}
bool ActionRandom::execute(ZVision *engine) {
- uint32 randNumber = engine->getRandomSource()->getRandomNumber(_max);
+ uint randNumber = engine->getRandomSource()->getRandomNumber(_max);
engine->getScriptManager()->setStateValue(_key, randNumber);
return true;
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 83f871d4e7..8380f1587a 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -79,7 +79,7 @@ public:
private:
uint32 _key;
- byte _value;
+ uint _value;
};
class ActionAssign : public ResultAction {
@@ -90,7 +90,7 @@ public:
private:
uint32 _key;
- byte _value;
+ uint _value;
};
class ActionAttenuate : public ResultAction {
@@ -101,7 +101,7 @@ public:
private:
uint32 _key;
- int16 _attenuation;
+ int _attenuation;
};
class ActionChangeLocation : public ResultAction {
@@ -115,7 +115,7 @@ private:
char _room;
char _node;
char _view;
- int16 _x;
+ uint32 _x;
};
class ActionCrossfade : public ResultAction {
@@ -127,11 +127,11 @@ public:
private:
uint32 _keyOne;
uint32 _keyTwo;
- byte _oneStartVolume;
- byte _twoStartVolume;
- byte _oneEndVolume;
- byte _twoEndVolume;
- uint16 _timeInMillis;
+ uint _oneStartVolume;
+ uint _twoStartVolume;
+ uint _oneEndVolume;
+ uint _twoEndVolume;
+ uint _timeInMillis;
};
class ActionDelayRender : public ResultAction {
@@ -142,7 +142,7 @@ public:
private:
// TODO: Check if this should actually be frames or if it should be milliseconds/seconds
- byte framesToDelay;
+ uint32 framesToDelay;
};
class ActionPlayAnimation : public ResultAction {
@@ -160,8 +160,8 @@ private:
uint32 _height;
uint32 _start;
uint32 _end;
- uint32 _mask;
- byte _framerate;
+ uint _mask;
+ uint _framerate;
bool _loop;
};
@@ -174,8 +174,8 @@ public:
private:
uint32 _key;
Common::String _fileName;
- uint32 _mask;
- byte _framerate;
+ uint _mask;
+ uint _framerate;
};
// TODO: See if this exists in ZGI. It doesn't in ZNem
@@ -193,7 +193,7 @@ public:
private:
uint32 _key;
- uint32 _max;
+ uint _max;
};
class ActionTimer : public ResultAction {
@@ -204,7 +204,7 @@ public:
private:
uint32 _key;
- uint32 _time;
+ uint _time;
};
} // End of namespace ZVision
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index 59ef14eb07..af384cbf2f 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -54,8 +54,8 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &
sscanf(line.c_str(), "angle(%f)", &scale);
renderTable->setPanoramaScale(scale);
} else if (line.matchString("reversepana*", true)) {
- byte reverse;
- sscanf(line.c_str(), "reversepana(%hhu)", &reverse);
+ uint reverse;
+ sscanf(line.c_str(), "reversepana(%u)", &reverse);
if (reverse == 1) {
renderTable->setPanoramaReverse(true);
}
@@ -86,8 +86,8 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
sscanf(line.c_str(), "angle(%f)", &scale);
renderTable->setTiltScale(scale);
} else if (line.matchString("reversepana*", true)) {
- byte reverse;
- sscanf(line.c_str(), "reversepana(%hhu)", &reverse);
+ uint reverse;
+ sscanf(line.c_str(), "reversepana(%u)", &reverse);
if (reverse == 1) {
renderTable->setTiltReverse(true);
}
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index a01ea74cd0..e392d3c78a 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -87,7 +87,7 @@ void ZVision::onMouseMove(const Common::Point &pos) {
}
-void ZVision::onKeyDown(uint16 keyCode) {
+void ZVision::onKeyDown(uint keyCode) {
}
diff --git a/engines/zvision/lzss_read_stream.cpp b/engines/zvision/lzss_read_stream.cpp
index d169620a25..8518c8fff9 100644
--- a/engines/zvision/lzss_read_stream.cpp
+++ b/engines/zvision/lzss_read_stream.cpp
@@ -42,9 +42,9 @@ uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes)
byte flagbyte = _source->readByte();
if (_source->eos())
break;
- byte mask = 1;
+ uint mask = 1;
- for (uint32 i = 0; i < 8; i++) {
+ for (int i = 0; i < 8; i++) {
if ((flagbyte & mask) == mask)
{
byte data = _source->readByte();
@@ -70,7 +70,7 @@ uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes)
uint16 length = (high & 0xF) + 2;
uint16 offset = low | ((high & 0xF0)<<4);
- for(byte j = 0; j <= length; j++)
+ for(int j = 0; j <= length; j++)
{
byte temp = _window[(offset + j) & 0xFFF];
_window[_windowCursor] = temp;
diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h
index 0814220728..25bb66339e 100644
--- a/engines/zvision/lzss_read_stream.h
+++ b/engines/zvision/lzss_read_stream.h
@@ -49,8 +49,8 @@ public:
private:
Common::SeekableReadStream *_source;
- char _window[_blockSize];
- uint16 _windowCursor;
+ byte _window[BLOCK_SIZE];
+ uint _windowCursor;
bool _eosFlag;
public:
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index fba139c0a6..c73a345c3a 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -70,7 +70,7 @@ public:
Common::List<Criteria> criteriaList;
// This has to be list of pointers because ResultAction is abstract
Common::List<ResultAction *> resultActions;
- byte flags;
+ uint flags;
// Used by the ScriptManager to allow unique-ification of _referenceTable
// The unique-ification is done by sorting, then iterating and removing duplicates
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index adf1d647b7..531114cdbe 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -29,7 +29,7 @@
namespace ZVision {
-RenderTable::RenderTable(uint32 numColumns, uint32 numRows)
+RenderTable::RenderTable(uint numColumns, uint numRows)
: _numRows(numRows),
_numColumns(numColumns),
_renderState(FLAT) {
@@ -85,10 +85,10 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 i
bool isTransposed = _renderState == RenderTable::PANORAMA || _renderState == RenderTable::TILT;
for (int y = subRectangle.top; y < subRectangle.bottom; y++) {
- uint32 normalizedY = y - subRectangle.top;
+ uint normalizedY = y - subRectangle.top;
for (int x = subRectangle.left; x < subRectangle.right; x++) {
- uint32 normalizedX = x - subRectangle.left;
+ uint normalizedX = x - subRectangle.left;
uint32 index = (y + destRectangle.top) * _numColumns + (x + destRectangle.left);
@@ -137,15 +137,15 @@ void RenderTable::generatePanoramaLookupTable() {
float tanOverHalfHeight = tan(fovRadians) / halfHeight;
// TODO: Change the algorithm to write a whole row at a time instead of a whole column at a time. AKA: for(y) { for(x) {}} instead of for(x) { for(y) {}}
- for (uint32 x = 0; x < _numColumns; x++) {
+ for (uint x = 0; x < _numColumns; x++) {
// Add an offset of 0.01 to overcome zero tan/atan issue (vertical line on half of screen)
float temp = atan(tanOverHalfHeight * ((float)x - halfWidth + 0.01f));
- int32 newX = floor((halfHeightOverTan * _panoramaOptions.linearScale * temp) + halfWidth);
+ int32 newX = int32(floor((halfHeightOverTan * _panoramaOptions.linearScale * temp) + halfWidth));
float cosX = cos(temp);
- for (uint32 y = 0; y < _numRows; y++) {
- int32 newY = floor(halfHeight + (y - halfHeight) * cosX);
+ for (uint y = 0; y < _numRows; y++) {
+ int32 newY = int32(floor(halfHeight + ((float)y - halfHeight) * cosX));
uint32 index = y * _numColumns + x;
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index e5535a0544..82bea62769 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -32,7 +32,7 @@ namespace ZVision {
class RenderTable {
public:
- RenderTable(uint32 numRows, uint32 numColumns);
+ RenderTable(uint numRows, uint numColumns);
~RenderTable();
public:
@@ -43,7 +43,7 @@ public:
};
private:
- uint32 _numColumns, _numRows;
+ uint _numColumns, _numRows;
Vector2 *_internalBuffer;
RenderState _renderState;
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 5f2140d45a..fe78a82d8f 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -267,8 +267,8 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
return;
}
-byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
- byte flags;
+uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
+ uint flags = 0;
// Loop until we find the closing brace
Common::String line = stream.readLine();
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 0ff0509737..90bc202dac 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -60,7 +60,7 @@ void ScriptManager::createReferenceTable() {
}
}
-void ScriptManager::updateNodes(uint32 deltaTimeMillis) {
+void ScriptManager::updateNodes(uint deltaTimeMillis) {
// If process() returns true, it means the node can be deleted
for (Common::List<ActionNode *>::iterator iter = _activeNodes.begin(); iter != _activeNodes.end();) {
if ((*iter)->process(_engine, deltaTimeMillis)) {
@@ -82,7 +82,7 @@ void ScriptManager::checkPuzzleCriteria() {
bool criteriaMet = false;
for (Common::List<Puzzle::Criteria>::iterator iter = puzzle->criteriaList.begin(); iter != puzzle->criteriaList.end(); iter++) {
// Get the value to compare against
- byte argumentValue;
+ uint argumentValue;
if ((*iter).argument)
argumentValue = getStateValue(iter->argument);
else
@@ -119,16 +119,16 @@ void ScriptManager::checkPuzzleCriteria() {
}
}
-byte ScriptManager::getStateValue(uint32 key) {
+uint ScriptManager::getStateValue(uint32 key) {
return _globalState[key];
}
// TODO: Add logic to check _referenceTable and add to _puzzlesToCheck if necessary
-void ScriptManager::setStateValue(uint32 key, byte value) {
+void ScriptManager::setStateValue(uint32 key, uint value) {
_globalState[key] = value;
}
-void ScriptManager::addToStateValue(uint32 key, byte valueToAdd) {
+void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) {
_globalState[key] += valueToAdd;
}
@@ -136,7 +136,7 @@ void ScriptManager::addActionNode(ActionNode *node) {
_activeNodes.push_back(node);
}
-void ScriptManager::changeLocation(char world, char room, char node, char view, uint16 x) {
+void ScriptManager::changeLocation(char world, char room, char node, char view, uint32 x) {
// Clear all the containers
_referenceTable.clear();
_puzzlesToCheck.clear();
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 3e054ff68a..e8a8324a5c 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -50,7 +50,7 @@ private:
* mutators getStateValue() and setStateValue(). This ensures that Puzzles that reference a
* particular state key are checked after the key is modified.
*/
- Common::HashMap<uint32, byte> _globalState;
+ Common::HashMap<uint32, uint> _globalState;
/** Holds the currently active ActionNodes */
Common::List<ActionNode *> _activeNodes;
/** References _globalState keys to Puzzles */
@@ -65,16 +65,16 @@ private:
public:
void initialize();
- void updateNodes(uint32 deltaTimeMillis);
+ void updateNodes(uint deltaTimeMillis);
void checkPuzzleCriteria();
- byte getStateValue(uint32 key);
- void setStateValue(uint32 key, byte value);
- void addToStateValue(uint32 key, byte valueToAdd);
+ uint getStateValue(uint32 key);
+ void setStateValue(uint32 key, uint value);
+ void addToStateValue(uint32 key, uint valueToAdd);
void addActionNode(ActionNode *node);
- void changeLocation(char world, char room, char node, char view, uint16 x);
+ void changeLocation(char world, char room, char node, char view, uint32 x);
private:
void createReferenceTable();
@@ -118,9 +118,9 @@ private:
* Helper method for parsePuzzle. Parses the stream into a bitwise or of the StateFlags enum
*
* @param stream Scr file stream
- * @return Bitwise or of all the flags set within the puzzle
+ * @return Bitwise OR of all the flags set within the puzzle
*/
- byte parseFlags(Common::SeekableReadStream &stream) const;
+ uint parseFlags(Common::SeekableReadStream &stream) const;
/**
* Helper method for parseScrFile. Parses the stream into a Control object
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 58a7ec3ab7..e68d0de449 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -70,7 +70,7 @@ template<class T>
void removeDuplicateEntries(Common::Array<T> *container) {
Common::sort(container->front(), container->back());
- for (uint32 i = 0; i < container->size(); i++) {
+ for (int i = 0; i < container->size(); i++) {
while (container[i] == container[i +1]) {
container->remove_at(i + 1);
}
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index caf43ae0b5..1ccf736970 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -33,15 +33,15 @@
namespace ZVision {
// Taken from SCI
-void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte bytesPerPixel) {
+void scale2x(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel) {
assert(bytesPerPixel == 1 || bytesPerPixel == 2);
- const int newWidth = srcWidth * 2;
- const int pitch = newWidth * bytesPerPixel;
+ const uint32 newWidth = srcWidth * 2;
+ const uint32 pitch = newWidth * bytesPerPixel;
const byte *srcPtr = src;
if (bytesPerPixel == 1) {
- for (int y = 0; y < srcHeight; y++) {
- for (int x = 0; x < srcWidth; x++) {
+ for (uint32 y = 0; y < srcHeight; y++) {
+ for (uint32 x = 0; x < srcWidth; x++) {
const byte color = *srcPtr++;
dst[0] = color;
dst[1] = color;
@@ -52,8 +52,8 @@ void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte b
dst += newWidth;
}
} else if (bytesPerPixel == 2) {
- for (int y = 0; y < srcHeight; y++) {
- for (int x = 0; x < srcWidth; x++) {
+ for (uint32 y = 0; y < srcHeight; y++) {
+ for (uint32 x = 0; x < srcWidth; x++) {
const byte color = *srcPtr++;
const byte color2 = *srcPtr++;
dst[0] = color;
diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 03a35e09ab..742ba188ac 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -73,10 +73,10 @@ RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag dis
}
int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
- uint32 bytesRead = 0;
+ int bytesRead = 0;
// 0: Left, 1: Right
- byte channel = 0;
+ uint channel = 0;
while (bytesRead < numSamples) {
byte encodedSample = _stream->readByte();
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 6d25d197ee..4e40a5716a 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -36,7 +36,7 @@ class ZVision;
struct SoundParams {
char identifier;
- uint16 rate;
+ uint32 rate;
bool stereo;
bool packed;
};
@@ -73,7 +73,7 @@ private:
Audio::Timestamp _playtime; // Calculated total play time
Common::DisposablePtr<Common::SeekableReadStream> _stream; // Stream to read data from
bool _endOfData; // Whether the stream end has been reached
- byte _stereo;
+ uint _stereo;
/**
* Holds the frequency and index from the last sample
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index fa91f8ca29..ca43549f50 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -117,7 +117,7 @@ Common::Error ZVision::run() {
// Main loop
uint32 currentTime = _system->getMillis();
uint32 lastTime = currentTime;
- const uint32 desiredFrameTime = 33; // ~30 fps
+ const uint desiredFrameTime = 33; // ~30 fps
while (!shouldQuit()) {
processEvents();
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 2e6ec11a53..9588623f56 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -83,7 +83,7 @@ private:
void processEvents();
void onMouseDown(const Common::Point &pos);
void onMouseMove(const Common::Point &pos);
- void onKeyDown(uint16 keyCode);
+ void onKeyDown(uint keyCode);
};
} // End of namespace ZVision