aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Kołodziejski2003-03-06 16:27:06 +0000
committerPaweł Kołodziejski2003-03-06 16:27:06 +0000
commit6ce098172f3754a2c279e1e2d156f3354c612011 (patch)
tree5d55422c648e93f4b78e49c303ec1978819b3fa4
parent38e926cee3ec4a5066d41c0dc95231e156543b64 (diff)
downloadscummvm-rg350-6ce098172f3754a2c279e1e2d156f3354c612011.tar.gz
scummvm-rg350-6ce098172f3754a2c279e1e2d156f3354c612011.tar.bz2
scummvm-rg350-6ce098172f3754a2c279e1e2d156f3354c612011.zip
next pedantic cleanup code
svn-id: r6714
-rw-r--r--common/config-file.cpp60
-rw-r--r--common/engine.cpp21
-rw-r--r--common/engine.h2
-rw-r--r--common/file.cpp7
-rw-r--r--common/gameDetector.cpp78
-rw-r--r--common/gameDetector.h2
-rw-r--r--common/list.h58
-rw-r--r--common/main.cpp23
-rw-r--r--common/map.h65
-rw-r--r--common/scaler.cpp70
-rw-r--r--common/scummsys.h639
-rw-r--r--common/str.cpp96
-rw-r--r--common/str.h54
-rw-r--r--common/system.h16
-rw-r--r--common/timer.cpp9
-rw-r--r--common/util.cpp47
-rw-r--r--common/util.h10
17 files changed, 557 insertions, 700 deletions
diff --git a/common/config-file.cpp b/common/config-file.cpp
index 821d6e5b3c..51cc21392d 100644
--- a/common/config-file.cpp
+++ b/common/config-file.cpp
@@ -29,14 +29,12 @@
#define MAXLINELEN 256
-static char *ltrim(char *t)
-{
+static char *ltrim(char *t) {
for (; *t && (*t == ' '); t++);
return t;
}
-static char *rtrim(char *t)
-{
+static char *rtrim(char *t) {
int l;
for (l = strlen(t) - 1; l; l--) {
@@ -52,8 +50,7 @@ static char *rtrim(char *t)
// The config-class itself.
Config::Config (const String &cfg, const String &d)
- : filename(cfg), defaultDomain(d), willwrite(false)
-{
+ : filename(cfg), defaultDomain(d), willwrite(false) {
FILE *cfg_file;
char t[MAXLINELEN];
@@ -103,8 +100,7 @@ Config::Config (const String &cfg, const String &d)
}
}
-const char *Config::get(const String &key, const String &d) const
-{
+const char *Config::get(const String &key, const String &d) const {
String domain;
if (d.isEmpty())
@@ -119,26 +115,23 @@ const char *Config::get(const String &key, const String &d) const
return 0;
}
-const int Config::getInt(const String &key, int def, const String &d) const
-{
+const int Config::getInt(const String &key, int def, const String &d) const {
const char *value = get(key, d);
-
+
if (value)
return atoi(value);
return def;
}
-const bool Config::getBool(const String &key, bool def, const String &d) const
-{
+const bool Config::getBool(const String &key, bool def, const String &d) const {
const char *value = get(key, d);
-
+
if (value)
return !scumm_stricmp(value, "true");
return def;
}
-void Config::set(const String &key, const String &value, const String &d)
-{
+void Config::set(const String &key, const String &value, const String &d) {
String domain(d);
if (domain.isEmpty())
@@ -148,34 +141,29 @@ void Config::set(const String &key, const String &value, const String &d)
domains[domain][key] = value;
}
-void Config::setInt(const String &key, int value_i, const String &d)
-{
+void Config::setInt(const String &key, int value_i, const String &d) {
char value[MAXLINELEN];
sprintf(value, "%i", value_i);
set(key, String(value), d);
}
-void Config::setBool(const String &key, bool value_b, const String &d)
-{
+void Config::setBool(const String &key, bool value_b, const String &d) {
String value(value_b ? "true" : "false");
set(key, value, d);
}
-void Config::set_domain(const String &d)
-{
+void Config::set_domain(const String &d) {
defaultDomain = d;
defaultDomain.toLowercase();
}
-bool Config::has_domain(const String &d) const
-{
+bool Config::has_domain(const String &d) const {
String temp(d);
temp.toLowercase();
return domains.contains(temp);
}
-void Config::flush() const
-{
+void Config::flush() const {
FILE *cfg_file;
if (!willwrite)
@@ -187,7 +175,7 @@ void Config::flush() const
DomainMap::Iterator d;
for (d = domains.begin(); d != domains.end(); ++d) {
fprintf(cfg_file, "[%s]\n", d->_key.c_str());
-
+
const StringMap &data = d->_value;
StringMap::Iterator x;
for (x = data.begin(); x != data.end(); ++x) {
@@ -201,8 +189,7 @@ void Config::flush() const
}
}
-void Config::rename_domain(const String &oldD, const String &newD)
-{
+void Config::rename_domain(const String &oldD, const String &newD) {
String oldDomain(oldD);
String newDomain(newD);
oldDomain.toLowercase();
@@ -219,29 +206,24 @@ void Config::rename_domain(const String &oldD, const String &newD)
domains.remove(oldDomain);
}
-void Config::delete_domain(const String &d)
-{
+void Config::delete_domain(const String &d) {
String domain(d);
domain.toLowercase();
-
domains.remove(d);
}
-void Config::set_filename(const String &f)
-{
+void Config::set_filename(const String &f) {
filename = f;
}
-void Config::merge_config(const Config &c)
-{
+void Config::merge_config(const Config &c) {
DomainMap::Iterator d, end(c.domains.end());
for (d = c.domains.begin(); d != end; ++d) {
domains[d->_key].merge(d->_value);
}
}
-void Config::set_writing(bool w)
-{
+void Config::set_writing(bool w) {
willwrite = w;
}
@@ -260,7 +242,7 @@ ScummVM::StringList Config::get_domains() {
for (d = domains.begin(); d != end; ++d) {
domainNames.push_back(d->_key);
}
-
+
return domainNames;
}
diff --git a/common/engine.cpp b/common/engine.cpp
index 9602d24a59..25db1cba2b 100644
--- a/common/engine.cpp
+++ b/common/engine.cpp
@@ -30,8 +30,7 @@ OSystem *g_system = 0;
SoundMixer *g_mixer = 0;
Engine::Engine(GameDetector *detector, OSystem *syst)
- : _system(syst)
-{
+ : _system(syst) {
_mixer = new SoundMixer();
_gameDataPath = detector->_gameDataPath;
@@ -43,14 +42,12 @@ Engine::Engine(GameDetector *detector, OSystem *syst)
_timer->init();
}
-Engine::~Engine()
-{
+Engine::~Engine() {
delete _mixer;
delete _timer;
}
-const char *Engine::getSavePath() const
-{
+const char *Engine::getSavePath() const {
const char *dir = NULL;
#ifdef _WIN32_WCE
@@ -77,8 +74,7 @@ const char *Engine::getSavePath() const
return dir;
}
-Engine *Engine::createFromDetector(GameDetector *detector, OSystem *syst)
-{
+Engine *Engine::createFromDetector(GameDetector *detector, OSystem *syst) {
Engine *engine = NULL;
if (detector->_gameId >= GID_SIMON_FIRST && detector->_gameId <= GID_SIMON_LAST) {
@@ -97,8 +93,7 @@ Engine *Engine::createFromDetector(GameDetector *detector, OSystem *syst)
return engine;
}
-void CDECL warning(const char *s, ...)
-{
+void CDECL warning(const char *s, ...) {
char buf[1024];
va_list va;
@@ -119,8 +114,7 @@ void CDECL warning(const char *s, ...)
uint16 _debugLevel = 1;
-void CDECL debug(int level, const char *s, ...)
-{
+void CDECL debug(int level, const char *s, ...) {
char buf[1024];
va_list va;
@@ -140,8 +134,7 @@ void CDECL debug(int level, const char *s, ...)
fflush(stdout);
}
-void checkHeap()
-{
+void checkHeap() {
#if defined(WIN32)
if (_heapchk() != _HEAPOK) {
error("Heap is invalid!");
diff --git a/common/engine.h b/common/engine.h
index 57306e5833..4670a0d714 100644
--- a/common/engine.h
+++ b/common/engine.h
@@ -50,7 +50,7 @@ public:
// Invoke the main engine loop using this method
virtual void go() = 0;
-
+
// Get the save game dir path
const char *getSavePath() const;
diff --git a/common/file.cpp b/common/file.cpp
index 64b67c5632..b678acd356 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -56,7 +56,7 @@ FILE *File::fopenNoCase(const char *filename, const char *directory, const char
strcpy(buf, directory);
if (directory[0] != 0) {
#ifdef __MORPHOS__
- if (buf[strlen(buf)-1] != ':' && buf[strlen(buf)-1] != '/')
+ if (buf[strlen(buf) - 1] != ':' && buf[strlen(buf) - 1] != '/')
#endif
strcat(buf, "/");
}
@@ -97,7 +97,6 @@ File::~File() {
}
bool File::open(const char *filename, const char *directory, int mode, byte encbyte) {
-
if (_handle) {
debug(2, "File %s already opened", filename);
return false;
@@ -127,7 +126,7 @@ bool File::open(const char *filename, const char *directory, int mode, byte encb
}
_encbyte = encbyte;
-
+
int len = strlen(filename);
_name = new char[len+1];
memcpy(_name, filename, len+1);
@@ -181,7 +180,7 @@ uint32 File::size() {
fseek(_handle, 0, SEEK_END);
uint32 length = ftell(_handle);
fseek(_handle, oldPos, SEEK_SET);
-
+
return length;
}
diff --git a/common/gameDetector.cpp b/common/gameDetector.cpp
index 9feaf9dca0..6adefb779d 100644
--- a/common/gameDetector.cpp
+++ b/common/gameDetector.cpp
@@ -20,14 +20,12 @@
*
*/
-
#include "stdafx.h"
#include "sound/mididrv.h"
#include "common/engine.h"
#include "common/gameDetector.h"
#include "common/config-file.h"
-
#define CHECK_OPTION() if ((current_option != NULL) || (*s != '\0')) goto ShowHelpAndExit
#define HANDLE_OPTION() if ((*s == '\0') && (current_option == NULL)) goto ShowHelpAndExit; \
if ((*s != '\0') && (current_option != NULL)) goto ShowHelpAndExit; \
@@ -75,12 +73,9 @@ static const char USAGE_STRING[] =
"\t-u - dump scripts\n"
;
-
-
// This contains a pointer to a list of all supported games.
const VersionSettings *version_settings = NULL;
-
static const struct GraphicsModes gfx_modes[] = {
{"normal", "Normal (no scaling)", GFX_NORMAL},
{"1x", "Normal (no scaling)", GFX_NORMAL},
@@ -122,17 +117,14 @@ static const struct MusicDrivers music_drivers[] = {
{0, 0, 0}
};
-
-static int countVersions(const VersionSettings *v)
-{
+static int countVersions(const VersionSettings *v) {
int count;
for (count = 0; v->filename; v++, count++)
;
return count;
}
-GameDetector::GameDetector()
-{
+GameDetector::GameDetector() {
_fullScreen = false;
_gameId = 0;
@@ -205,9 +197,8 @@ GameDetector::GameDetector()
}
}
-void GameDetector::updateconfig()
-{
- const char * val;
+void GameDetector::updateconfig() {
+ const char *val;
_amiga = g_config->getBool("amiga", _amiga);
@@ -260,12 +251,9 @@ void GameDetector::updateconfig()
_gameTempo = strtol(val, NULL, 0);
_talkSpeed = g_config->getInt("talkspeed", _talkSpeed);
-
-
}
-void GameDetector::list_games()
-{
+void GameDetector::list_games() {
const VersionSettings *v = version_settings;
char config[4] = "";
@@ -292,8 +280,7 @@ void GameDetector::list_games()
}
-void GameDetector::parseCommandLine(int argc, char **argv)
-{
+void GameDetector::parseCommandLine(int argc, char **argv) {
int i;
char *s;
char *current_option = NULL;
@@ -354,7 +341,7 @@ void GameDetector::parseCommandLine(int argc, char **argv)
case 'l':
HANDLE_OPTION();
{
- Config * newconfig = new Config(option, "scummvm");
+ Config *newconfig = new Config(option, "scummvm");
g_config->merge_config(*newconfig);
delete newconfig;
updateconfig();
@@ -431,7 +418,7 @@ void GameDetector::parseCommandLine(int argc, char **argv)
break;
case 'y':
HANDLE_OPTION();
- _talkSpeed = atoi(option);
+ _talkSpeed = atoi(option);
g_config->setInt("talkspeed", _talkSpeed);
break;
case 'z':
@@ -458,13 +445,12 @@ void GameDetector::parseCommandLine(int argc, char **argv)
return;
- ShowHelpAndExit:
+ShowHelpAndExit:
printf(USAGE_STRING);
exit(1);
}
-void GameDetector::setGame(const String &name)
-{
+void GameDetector::setGame(const String &name) {
_gameFileName = name;
g_config->set_domain(name);
g_config->rename_domain(name, "game-specific");
@@ -472,8 +458,7 @@ void GameDetector::setGame(const String &name)
updateconfig();
}
-int GameDetector::parseGraphicsMode(const char *s)
-{
+int GameDetector::parseGraphicsMode(const char *s) {
const GraphicsModes *gm = gfx_modes;
while(gm->name) {
if (!scumm_stricmp(gm->name, s))
@@ -484,8 +469,7 @@ int GameDetector::parseGraphicsMode(const char *s)
return -1;
}
-int GameDetector::parseLanguage(const char *s)
-{
+int GameDetector::parseLanguage(const char *s) {
const Languages *l = languages;
while(l->name) {
if (!scumm_stricmp(l->name, s))
@@ -496,41 +480,38 @@ int GameDetector::parseLanguage(const char *s)
return -1;
}
-bool GameDetector::isMusicDriverAvailable(int drv)
-{
+bool GameDetector::isMusicDriverAvailable(int drv) {
switch(drv) {
case MD_AUTO:
- case MD_NULL: return true;
- case MD_ADLIB: return true;
+ case MD_NULL: return true;
+ case MD_ADLIB: return true;
#if defined(WIN32) && !defined(_WIN32_WCE)
- case MD_WINDOWS: return true;
+ case MD_WINDOWS: return true;
#endif
#if defined(__MORPHOS__)
- case MD_ETUDE: return true;
+ case MD_ETUDE: return true;
#endif
#if defined(UNIX) && !defined(__BEOS__) && !defined(MACOSX)
- case MD_SEQ: return true;
+ case MD_SEQ: return true;
#endif
#if defined(MACOSX) || defined(macintosh)
- case MD_QTMUSIC: return true;
+ case MD_QTMUSIC: return true;
#endif
#if defined(MACOSX)
- case MD_COREAUDIO: return true;
+ case MD_COREAUDIO: return true;
#endif
#if defined(UNIX) && defined(USE_ALSA)
- case MD_ALSA: return true;
+ case MD_ALSA: return true;
#endif
}
return false;
}
-const MusicDrivers *GameDetector::getMusicDrivers()
-{
+const MusicDrivers *GameDetector::getMusicDrivers() {
return music_drivers;
}
-bool GameDetector::parseMusicDriver(const char *s)
-{
+bool GameDetector::parseMusicDriver(const char *s) {
const MusicDrivers *md = music_drivers;
while (md->name) {
@@ -545,15 +526,14 @@ bool GameDetector::parseMusicDriver(const char *s)
return false;
}
-bool GameDetector::detectGame()
-{
+bool GameDetector::detectGame() {
const VersionSettings *gnl = version_settings;
char *realGame;
_gameId = 0;
_gameText.clear();
- if (!(realGame = (char*)g_config->get("gameid")))
- realGame = (char*)_gameFileName.c_str();
+ if (!(realGame = (char *)g_config->get("gameid")))
+ realGame = (char *)_gameFileName.c_str();
printf("Looking for %s\n", realGame);
do {
@@ -576,8 +556,7 @@ bool GameDetector::detectGame()
return false;
}
-const ScummVM::String& GameDetector::getGameName()
-{
+const ScummVM::String& GameDetector::getGameName() {
if (_gameText.isEmpty()) {
_gameText = "Unknown game: \"";
_gameText += _gameFileName;
@@ -586,8 +565,7 @@ const ScummVM::String& GameDetector::getGameName()
return _gameText;
}
-int GameDetector::detectMain()
-{
+int GameDetector::detectMain() {
if (_gameFileName.isEmpty()) {
warning("No game was specified...");
return (-1);
diff --git a/common/gameDetector.h b/common/gameDetector.h
index fa27c75835..33218b58cf 100644
--- a/common/gameDetector.h
+++ b/common/gameDetector.h
@@ -113,7 +113,7 @@ public:
public:
GameDetector();
-
+
void parseCommandLine(int argc, char **argv);
int detectMain();
void setGame(const String &name);
diff --git a/common/list.h b/common/list.h
index 9c04b8ef8b..2decd860a6 100644
--- a/common/list.h
+++ b/common/list.h
@@ -29,35 +29,31 @@ namespace ScummVM {
template <class T>
class List {
protected:
- int _capacity;
- int _size;
- T *_data;
+ int _capacity;
+ int _size;
+ T *_data;
public:
List<T>() : _capacity(0), _size(0), _data(0) {}
- List<T>(const List<T>& list) : _capacity(0), _size(0), _data(0)
- {
+ List<T>(const List<T>& list) : _capacity(0), _size(0), _data(0) {
_size = list._size;
_capacity = _size + 32;
_data = new T[_capacity];
for (int i = 0; i < _size; i++)
_data[i] = list._data[i];
}
-
- ~List<T>()
- {
+
+ ~List<T>() {
if (_data)
delete [] _data;
}
-
- void push_back(const T& element)
- {
+
+ void push_back(const T& element) {
ensureCapacity(_size + 1);
_data[_size++] = element;
}
-
- void insert_at(int idx, const T& element)
- {
+
+ void insert_at(int idx, const T& element) {
assert(idx >= 0 && idx <= _size);
ensureCapacity(_size + 1);
// The following loop is not efficient if you can just memcpy things around.
@@ -70,23 +66,20 @@ public:
_size++;
}
-
+
// TODO: insert, remove, ...
-
- T& operator [](int idx)
- {
+
+ T& operator [](int idx) {
assert(idx >= 0 && idx < _size);
return _data[idx];
}
- const T& operator [](int idx) const
- {
+ const T& operator [](int idx) const {
assert(idx >= 0 && idx < _size);
return _data[idx];
}
- List<T>& operator =(const List<T>& list)
- {
+ List<T>& operator =(const List<T>& list) {
if (_data)
delete [] _data;
_size = list._size;
@@ -98,10 +91,11 @@ public:
return *this;
}
- int size() const { return _size; }
+ int size() const {
+ return _size;
+ }
- void clear()
- {
+ void clear() {
if (_data) {
delete [] _data;
_data = 0;
@@ -110,18 +104,19 @@ public:
_capacity = 0;
}
- bool isEmpty() const { return (_size == 0); }
+ bool isEmpty() const {
+ return (_size == 0);
+ }
protected:
- void ensureCapacity(int new_len)
- {
+ void ensureCapacity(int new_len) {
if (new_len <= _capacity)
return;
-
+
T *old_data = _data;
_capacity = new_len + 32;
_data = new T[_capacity];
-
+
if (old_data) {
// Copy old data
for (int i = 0; i < _size; i++)
@@ -131,7 +126,6 @@ protected:
}
};
-
-}; // End of namespace ScummVM
+};// End of namespace ScummVM
#endif
diff --git a/common/main.cpp b/common/main.cpp
index b411bca065..8f99028375 100644
--- a/common/main.cpp
+++ b/common/main.cpp
@@ -31,7 +31,6 @@
Config *g_config = 0;
NewGui *g_gui = 0;
-
#if defined(QTOPIA)
// FIXME - why exactly is this needed?
extern "C" int main(int argc, char *argv[]);
@@ -99,8 +98,7 @@ static void do_memory_test(void) {
#endif
-static void launcherDialog(GameDetector &detector, OSystem *system)
-{
+static void launcherDialog(GameDetector &detector, OSystem *system) {
// FIXME - we need to call init_size() here so that we can display for example
// the launcher dialog. But the Engine object will also call it again (possibly
// with a different widht/height!9 However, this method is not for all OSystem
@@ -143,8 +141,7 @@ static void launcherDialog(GameDetector &detector, OSystem *system)
dlg.runModal();
}
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[]) {
GameDetector detector;
OSystem::Property prop;
@@ -157,12 +154,12 @@ int main(int argc, char *argv[])
sprintf(scummhome,"%s/%s", getenv("HOME"), DEFAULT_CONFIG_FILE);
else strcpy(scummhome,DEFAULT_CONFIG_FILE);
#else
- char scummhome[256];
+ char scummhome[256];
#if defined (WIN32) && !defined(_WIN32_WCE)
GetWindowsDirectory(scummhome, 256);
strcat(scummhome, "\\");
strcat(scummhome, DEFAULT_CONFIG_FILE);
- #else
+ #else
strcpy(scummhome, DEFAULT_CONFIG_FILE);
#endif
#endif
@@ -170,7 +167,7 @@ int main(int argc, char *argv[])
// Read the config file
g_config = new Config(scummhome, "scummvm");
g_config->set("versioninfo", SCUMMVM_VERSION);
-
+
// Parse the command line information
detector._saveconfig = false;
detector.updateconfig();
@@ -193,9 +190,9 @@ int main(int argc, char *argv[])
// Verify the given game name
if (detector.detectMain()) {
system->quit();
- return (-1);
+ return -1;
}
-
+
// Set the window caption to the game name
prop.caption = detector.getGameName().c_str();
system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop);
@@ -205,15 +202,15 @@ int main(int argc, char *argv[])
// Run the game engine
engine->go();
-
+
// Free up memory
delete engine;
delete g_gui;
delete g_config;
-
+
// ...and quit (the return 0 should never be reached)
system->quit();
-
+
return 0;
}
diff --git a/common/map.h b/common/map.h
index ffa54e5994..1698847c79 100644
--- a/common/map.h
+++ b/common/map.h
@@ -50,8 +50,7 @@ protected:
const Node &operator *() const { assert(_node != 0); return *_node; }
const Node *operator->() const { assert(_node != 0); return _node; }
bool operator !=(const Iterator &iter) const { return _node != iter._node; }
- void operator ++()
- {
+ void operator ++() {
if (!_node)
return;
if (_node->_right) {
@@ -64,25 +63,23 @@ protected:
_node = parent;
parent = _node->_parent;
}
-
+
if (_node->_right != parent)
_node = parent;
}
-
+
if (_node->_parent == 0)
_node = 0;
}
};
public:
- Map<Key, Value>() : _root(0)
- {
+ Map<Key, Value>() : _root(0) {
_header = new Node();
_header->_right = _header->_left = _header;
}
- ~Map<Key, Value>()
- {
+ ~Map<Key, Value>() {
clearNodes(_root);
delete _header;
_root = _header = 0;
@@ -92,8 +89,7 @@ public:
* Return the object for the given key. If no match is found, a new entry
* with the given key and the default data value is inserted.
*/
- Value &operator [](const Key &key)
- {
+ Value &operator [](const Key &key) {
Node *node;
if (!_root)
node = _root = new Node(key, _header);
@@ -102,38 +98,33 @@ public:
return node->_value;
}
- const Value &operator [](const Key &key) const
- {
+ const Value &operator [](const Key &key) const {
Node *node = findNode(_root, key);
assert(node != 0);
return node->_value;
}
-
- bool contains(const Key &key) const
- {
+
+ bool contains(const Key &key) const {
return (findNode(_root, key) != 0);
}
- void clear()
- {
+ void clear() {
clearNodes(_root);
_root = 0;
}
- bool isEmpty() const
- {
+ bool isEmpty() const {
return (_root == 0);
}
- void remove(const Key &key)
- {
+ void remove(const Key &key) {
// TODO - implement efficiently. Indeed, maybe switch to using red-black trees?
// For now, just a lame, bad remove algorithm. Rule: don't remove elements
// from one of our maps if you need to be efficient :-)
Node *node = findNode(_root, key);
if (!node)
return;
-
+
// Now we have to remove 'node'. There are two simple cases and one hard.
Node *parent = node->_parent;
Node *rep;
@@ -144,9 +135,9 @@ public:
} else {
// We have to do it the hard way since both children are present.
Node *n2;
-
+
n2 = rep = node->_right;
-
+
// Now insert the left child leftmost into our right child
while (n2->_left)
n2 = n2->_left;
@@ -167,9 +158,8 @@ public:
// Finally free the allocated memory
delete node;
}
-
- void merge(const Map<Key, Value> &map)
- {
+
+ void merge(const Map<Key, Value> &map) {
// FIXME - this is a very bad algorithm.
// Right now we insert the items from 'map' using the default iterator,
// which gives us the objects ordered, leading to an unbalanced tree.
@@ -182,9 +172,8 @@ public:
(*this)[x->_key] = x->_value;
}
}
-
- Iterator begin() const
- {
+
+ Iterator begin() const {
Node *node = _root;
if (node) {
while (node->_left)
@@ -192,16 +181,14 @@ public:
}
return Iterator(node);
}
-
- Iterator end() const
- {
+
+ Iterator end() const {
return Iterator();
}
protected:
// Find the node matching the given key, if any
- Node *findNode(Node *node, const Key &key) const
- {
+ Node *findNode(Node *node, const Key &key) const {
while (node && (key != node->_key)) {
if (key < node->_key) {
node = node->_left;
@@ -212,8 +199,7 @@ protected:
return node;
}
- Node *createNode(Node *node, const Key &key)
- {
+ Node *createNode(Node *node, const Key &key) {
Node *prevNode = 0;
bool left = true;
while (node) {
@@ -236,9 +222,8 @@ protected:
}
return node;
}
-
- void clearNodes(Node *node)
- {
+
+ void clearNodes(Node *node) {
if (!node)
return;
diff --git a/common/scaler.cpp b/common/scaler.cpp
index 78cd5aee53..935ead3e06 100644
--- a/common/scaler.cpp
+++ b/common/scaler.cpp
@@ -33,21 +33,20 @@ static uint32 redblueMask = 0xF81F;
static uint32 greenMask = 0x7E0;
static const uint16 dotmatrix_565[16] = {
- 0x01E0, 0x0007, 0x3800, 0x0000,
- 0x39E7, 0x0000, 0x39E7, 0x0000,
- 0x3800, 0x0000, 0x01E0, 0x0007,
- 0x39E7, 0x0000, 0x39E7, 0x0000
+ 0x01E0, 0x0007, 0x3800, 0x0000,
+ 0x39E7, 0x0000, 0x39E7, 0x0000,
+ 0x3800, 0x0000, 0x01E0, 0x0007,
+ 0x39E7, 0x0000, 0x39E7, 0x0000
};
static const uint16 dotmatrix_555[16] = {
- 0x00E0, 0x0007, 0x1C00, 0x0000,
- 0x1CE7, 0x0000, 0x1CE7, 0x0000,
- 0x1C00, 0x0000, 0x00E0, 0x0007,
- 0x1CE7, 0x0000, 0x1CE7, 0x0000
+ 0x00E0, 0x0007, 0x1C00, 0x0000,
+ 0x1CE7, 0x0000, 0x1CE7, 0x0000,
+ 0x1C00, 0x0000, 0x00E0, 0x0007,
+ 0x1CE7, 0x0000, 0x1CE7, 0x0000
};
static const uint16 *dotmatrix;
-int Init_2xSaI(uint32 BitFormat)
-{
+int Init_2xSaI(uint32 BitFormat) {
if (BitFormat == 565) {
colorMask = 0xF7DEF7DE;
lowPixelMask = 0x08210821;
@@ -71,8 +70,7 @@ int Init_2xSaI(uint32 BitFormat)
return 1;
}
-static inline int GetResult1(uint32 A, uint32 B, uint32 C, uint32 D, uint32 /* E */ )
-{
+static inline int GetResult1(uint32 A, uint32 B, uint32 C, uint32 D, uint32 /* E */ ) {
int x = 0;
int y = 0;
int r = 0;
@@ -92,8 +90,7 @@ static inline int GetResult1(uint32 A, uint32 B, uint32 C, uint32 D, uint32 /* E
return r;
}
-static inline int GetResult2(uint32 A, uint32 B, uint32 C, uint32 D, uint32 /* E */ )
-{
+static inline int GetResult2(uint32 A, uint32 B, uint32 C, uint32 D, uint32 /* E */ ) {
int x = 0;
int y = 0;
int r = 0;
@@ -113,8 +110,7 @@ static inline int GetResult2(uint32 A, uint32 B, uint32 C, uint32 D, uint32 /* E
return r;
}
-static inline int GetResult(uint32 A, uint32 B, uint32 C, uint32 D)
-{
+static inline int GetResult(uint32 A, uint32 B, uint32 C, uint32 D) {
int x = 0;
int y = 0;
int r = 0;
@@ -134,16 +130,14 @@ static inline int GetResult(uint32 A, uint32 B, uint32 C, uint32 D)
return r;
}
-static inline uint32 INTERPOLATE(uint32 A, uint32 B)
-{
+static inline uint32 INTERPOLATE(uint32 A, uint32 B) {
if (A != B) {
return (((A & colorMask) >> 1) + ((B & colorMask) >> 1) + (A & B & lowPixelMask));
} else
return A;
}
-static inline uint32 Q_INTERPOLATE(uint32 A, uint32 B, uint32 C, uint32 D)
-{
+static inline uint32 Q_INTERPOLATE(uint32 A, uint32 B, uint32 C, uint32 D) {
register uint32 x = ((A & qcolorMask) >> 2) +
((B & qcolorMask) >> 2) + ((C & qcolorMask) >> 2) + ((D & qcolorMask) >> 2);
register uint32 y = (A & qlowpixelMask) +
@@ -162,8 +156,7 @@ static inline uint32 Q_INTERPOLATE(uint32 A, uint32 B, uint32 C, uint32 D)
#define GREEN_MASK555 0x03E003E0
void Super2xSaI(uint8 *srcPtr, uint32 srcPitch,
- uint8 *deltaPtr, uint8 *dstPtr, uint32 dstPitch, int width, int height)
-{
+ uint8 *deltaPtr, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
uint16 *bP;
uint8 *dP;
uint32 inc_bP;
@@ -281,8 +274,7 @@ void Super2xSaI(uint8 *srcPtr, uint32 srcPitch,
}
void SuperEagle(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,
- uint8 *dstPtr, uint32 dstPitch, int width, int height)
-{
+ uint8 *dstPtr, uint32 dstPitch, int width, int height) {
uint8 *dP;
uint16 *bP;
uint32 inc_bP;
@@ -401,13 +393,11 @@ void SuperEagle(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,
}
void _2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,
- uint8 *dstPtr, uint32 dstPitch, int width, int height)
-{
+ uint8 *dstPtr, uint32 dstPitch, int width, int height) {
uint8 *dP;
uint16 *bP;
uint32 inc_bP;
-
{
inc_bP = 1;
@@ -554,8 +544,7 @@ void _2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,
}
}
-static uint32 Bilinear(uint32 A, uint32 B, uint32 x)
-{
+static uint32 Bilinear(uint32 A, uint32 B, uint32 x) {
unsigned long areaA, areaB;
unsigned long result;
@@ -571,11 +560,9 @@ static uint32 Bilinear(uint32 A, uint32 B, uint32 x)
result = ((areaA * A) + (areaB * B)) >> 5;
return (result & redblueMask) | ((result >> 16) & greenMask);
-
}
-static uint32 Bilinear4(uint32 A, uint32 B, uint32 C, uint32 D, uint32 x, uint32 y)
-{
+static uint32 Bilinear4(uint32 A, uint32 B, uint32 C, uint32 D, uint32 x, uint32 y) {
unsigned long areaA, areaB, areaC, areaD;
unsigned long result, xy;
@@ -600,8 +587,7 @@ static uint32 Bilinear4(uint32 A, uint32 B, uint32 C, uint32 D, uint32 x, uint32
void Scale_2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 * /* deltaPtr */ ,
uint8 *dstPtr, uint32 dstPitch,
- uint32 dstWidth, uint32 dstHeight, int width, int height)
-{
+ uint32 dstWidth, uint32 dstHeight, int width, int height) {
uint8 *dP;
uint16 *bP;
@@ -732,8 +718,7 @@ void Scale_2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 * /* deltaPtr */ ,
}
void AdvMame2x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint32 dstPitch,
- int width, int height)
-{
+ int width, int height) {
unsigned int nextlineSrc = srcPitch / sizeof(short);
short *p = (short *)srcPtr;
@@ -762,10 +747,8 @@ void AdvMame2x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint3
}
}
-
void Normal1x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint32 dstPitch,
- int width, int height)
-{
+ int width, int height) {
while (height--) {
memcpy(dstPtr, srcPtr, 2 * width);
srcPtr += srcPitch;
@@ -774,8 +757,7 @@ void Normal1x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint32
}
void Normal2x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint32 dstPitch,
- int width, int height)
-{
+ int width, int height) {
uint8 *r;
while (height--) {
@@ -794,8 +776,7 @@ void Normal2x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint32
}
void Normal3x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint32 dstPitch,
- int width, int height)
-{
+ int width, int height) {
uint8 *r;
uint32 dstPitch2 = dstPitch * 2;
uint32 dstPitch3 = dstPitch * 3;
@@ -821,8 +802,7 @@ void Normal3x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint32
}
void TV2x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint32 dstPitch,
- int width, int height)
-{
+ int width, int height) {
unsigned int nextlineSrc = srcPitch / sizeof(uint16);
uint16 *p = (uint16 *)srcPtr;
diff --git a/common/scummsys.h b/common/scummsys.h
index 1c63b4f838..b52497992e 100644
--- a/common/scummsys.h
+++ b/common/scummsys.h
@@ -31,356 +31,353 @@
#endif
#if defined(_MSC_VER)
-
- //#pragma warning (disable: 4244)
- //#pragma warning (disable: 4101)
-
- #define scumm_stricmp stricmp
- #define snprintf _snprintf
-
- #if defined(CHECK_HEAP)
- #undef CHECK_HEAP
- #define CHECK_HEAP checkHeap();
- #else
- #define CHECK_HEAP
- #endif
-
- #define SCUMM_LITTLE_ENDIAN
-
- #define FORCEINLINE __forceinline
- #define NORETURN _declspec(noreturn)
-
- typedef unsigned char byte;
- typedef unsigned char uint8;
- typedef unsigned short uint16;
- typedef unsigned long uint32;
- typedef unsigned int uint;
- typedef signed char int8;
- typedef signed short int16;
- typedef signed long int32;
-
- #define START_PACK_STRUCTS pack (push,1)
- #define END_PACK_STRUCTS pack(pop)
- #define GCC_PACK
+
+ //#pragma warning (disable: 4244)
+ //#pragma warning (disable: 4101)
+
+ #define scumm_stricmp stricmp
+ #define snprintf _snprintf
+
+ #if defined(CHECK_HEAP)
+ #undef CHECK_HEAP
+ #define CHECK_HEAP checkHeap();
+ #else
+ #define CHECK_HEAP
+ #endif
+
+ #define SCUMM_LITTLE_ENDIAN
+
+ #define FORCEINLINE __forceinline
+ #define NORETURN _declspec(noreturn)
+
+ typedef unsigned char byte;
+ typedef unsigned char uint8;
+ typedef unsigned short uint16;
+ typedef unsigned long uint32;
+ typedef unsigned int uint;
+ typedef signed char int8;
+ typedef signed short int16;
+ typedef signed long int32;
+
+ #define START_PACK_STRUCTS pack(push, 1)
+ #define END_PACK_STRUCTS pack(pop)
+ #define GCC_PACK
#if defined(_WIN32_WCE) && _WIN32_WCE < 300
- #define CDECL __cdecl
+ #define CDECL __cdecl
#endif
#elif defined(__MINGW32__)
-
- #define scumm_stricmp stricmp
- #define CHECK_HEAP
- #define SCUMM_LITTLE_ENDIAN
-
- #define FORCEINLINE inline
- #define NORETURN __attribute__((__noreturn__))
- #define GCC_PACK __attribute__((packed))
- #define _HEAPOK 0
-
- typedef unsigned char byte;
- typedef unsigned char uint8;
- typedef unsigned short uint16;
- typedef unsigned int uint32;
- typedef unsigned int uint;
- typedef signed char int8;
- typedef signed short int16;
- typedef signed int int32;
-
- #define START_PACK_STRUCTS pack (push,1)
- #define END_PACK_STRUCTS pack(pop)
-
+
+ #define scumm_stricmp stricmp
+ #define CHECK_HEAP
+ #define SCUMM_LITTLE_ENDIAN
+
+ #define FORCEINLINE inline
+ #define NORETURN __attribute__((__noreturn__))
+ #define GCC_PACK __attribute__((packed))
+ #define _HEAPOK 0
+
+ typedef unsigned char byte;
+ typedef unsigned char uint8;
+ typedef unsigned short uint16;
+ typedef unsigned int uint32;
+ typedef unsigned int uint;
+ typedef signed char int8;
+ typedef signed short int16;
+ typedef signed int int32;
+
+ #define START_PACK_STRUCTS pack (push, 1)
+ #define END_PACK_STRUCTS pack(pop)
+
#elif defined(UNIX)
-
- #define scumm_stricmp strcasecmp
-
- #define CHECK_HEAP
-
- #ifdef X11_BACKEND
-
- /* You need to set those manually */
-// #define SCUMM_LITTLE_ENDIAN
- /* #define SCUMM_NEED_ALIGNMENT */
-
- #else
- /* need this for the SDL_BYTEORDER define */
- #include <SDL_byteorder.h>
-
- #if SDL_BYTEORDER == SDL_LIL_ENDIAN
- #define SCUMM_LITTLE_ENDIAN
- #elif SDL_BYTEORDER == SDL_BIG_ENDIAN
- #define SCUMM_BIG_ENDIAN
- #define SCUMM_NEED_ALIGNMENT
- #else
- #error Neither SDL_BIG_ENDIAN nor SDL_LITTLE_ENDIAN is set.
- #endif
- #endif
-
- #define FORCEINLINE inline
- #define CDECL
-
- #ifndef CONFIG_H
- typedef unsigned char byte;
- typedef unsigned char uint8;
- typedef unsigned short uint16;
- typedef unsigned int uint;
- typedef unsigned int uint32;
- typedef signed char int8;
- typedef signed short int16;
- typedef signed int int32;
- #endif
-
-
- # if defined(__DECCXX) // Assume alpha architecture
- # define INVERSE_MKID
- # define SCUMM_NEED_ALIGNMENT
- # endif
-
-
- #if defined(__GNUC__)
- #define START_PACK_STRUCTS
- #define END_PACK_STRUCTS
- #define GCC_PACK __attribute__((packed))
- #define NORETURN __attribute__((__noreturn__))
- #else
- #define START_PACK_STRUCTS pack (1)
- #define END_PACK_STRUCTS pack ()
- #define GCC_PACK
- #define NORETURN
- #endif
-
+
+ #define scumm_stricmp strcasecmp
+
+ #define CHECK_HEAP
+
+ #ifdef X11_BACKEND
+
+ /* You need to set those manually */
+// #define SCUMM_LITTLE_ENDIAN
+ /* #define SCUMM_NEED_ALIGNMENT */
+
+ #else
+ /* need this for the SDL_BYTEORDER define */
+ #include <SDL_byteorder.h>
+
+ #if SDL_BYTEORDER == SDL_LIL_ENDIAN
+ #define SCUMM_LITTLE_ENDIAN
+ #elif SDL_BYTEORDER == SDL_BIG_ENDIAN
+ #define SCUMM_BIG_ENDIAN
+ #define SCUMM_NEED_ALIGNMENT
+ #else
+ #error Neither SDL_BIG_ENDIAN nor SDL_LITTLE_ENDIAN is set.
+ #endif
+ #endif
+
+ #define FORCEINLINE inline
+ #define CDECL
+
+ #ifndef CONFIG_H
+ typedef unsigned char byte;
+ typedef unsigned char uint8;
+ typedef unsigned short uint16;
+ typedef unsigned int uint;
+ typedef unsigned int uint32;
+ typedef signed char int8;
+ typedef signed short int16;
+ typedef signed int int32;
+ #endif
+
+ #if defined(__DECCXX) // Assume alpha architecture
+ #define INVERSE_MKID
+ #define SCUMM_NEED_ALIGNMENT
+ #endif
+
+ #if defined(__GNUC__)
+ #define START_PACK_STRUCTS
+ #define END_PACK_STRUCTS
+ #define GCC_PACK __attribute__((packed))
+ #define NORETURN __attribute__((__noreturn__))
+ #else
+ #define START_PACK_STRUCTS pack (1)
+ #define END_PACK_STRUCTS pack ()
+ #define GCC_PACK
+ #define NORETURN
+ #endif
+
#elif defined(macintosh)
- #include <stdio.h>
-
- #include "macos.h"
-
- #define scumm_stricmp strcmp// FIXME - this is definitly wrong. Try strcasecmp?
-
- #define CHECK_HEAP
- #define SCUMM_BIG_ENDIAN
-
- #define FORCEINLINE inline
- #define CDECL
-
- typedef unsigned char byte;
- typedef unsigned char uint8;
- typedef unsigned short uint16;
- typedef unsigned long uint32;
- typedef unsigned int uint;
- typedef signed char int8;
- typedef signed short int16;
- typedef signed long int32;
-
- #define START_PACK_STRUCTS pack (1)
- #define END_PACK_STRUCTS pack ()
- #define GCC_PACK
- #define NORETURN
- #define USE_QTMUSIC
- #define NEED_STRDUP
+ #include <stdio.h>
+
+ #include "macos.h"
+
+ #define scumm_stricmp strcmp// FIXME - this is definitly wrong. Try strcasecmp?
+
+ #define CHECK_HEAP
+ #define SCUMM_BIG_ENDIAN
+
+ #define FORCEINLINE inline
+ #define CDECL
+
+ typedef unsigned char byte;
+ typedef unsigned char uint8;
+ typedef unsigned short uint16;
+ typedef unsigned long uint32;
+ typedef unsigned int uint;
+ typedef signed char int8;
+ typedef signed short int16;
+ typedef signed long int32;
+
+ #define START_PACK_STRUCTS pack (1)
+ #define END_PACK_STRUCTS pack ()
+ #define GCC_PACK
+ #define NORETURN
+ #define USE_QTMUSIC
+ #define NEED_STRDUP
#elif defined(__MORPHOS__)
- #define scumm_stricmp stricmp
- #define CHECK_HEAP
-
- #define SCUMM_BIG_ENDIAN
- #define SCUMM_NEED_ALIGNMENT
-
- #define FORCEINLINE inline
- #define CDECL
-
- typedef unsigned char byte;
- typedef unsigned char uint8;
- typedef unsigned short uint16;
- typedef unsigned long uint32;
- typedef unsigned int uint;
- typedef signed char int8;
- typedef signed short int16;
- typedef signed long int32;
-
- #if defined(__GNUC__)
- #define START_PACK_STRUCTS
- #define END_PACK_STRUCTS
- #define GCC_PACK __attribute__((packed))
- #define NORETURN __attribute__((__noreturn__))
- #else
- #define START_PACK_STRUCTS pack (1)
- #define END_PACK_STRUCTS pack ()
- #define GCC_PACK
- #define NORETURN
- #endif
- #define main morphos_main
+ #define scumm_stricmp stricmp
+ #define CHECK_HEAP
+
+ #define SCUMM_BIG_ENDIAN
+ #define SCUMM_NEED_ALIGNMENT
+
+ #define FORCEINLINE inline
+ #define CDECL
+
+ typedef unsigned char byte;
+ typedef unsigned char uint8;
+ typedef unsigned short uint16;
+ typedef unsigned long uint32;
+ typedef unsigned int uint;
+ typedef signed char int8;
+ typedef signed short int16;
+ typedef signed long int32;
+
+ #if defined(__GNUC__)
+ #define START_PACK_STRUCTS
+ #define END_PACK_STRUCTS
+ #define GCC_PACK __attribute__((packed))
+ #define NORETURN __attribute__((__noreturn__))
+ #else
+ #define START_PACK_STRUCTS pack (1)
+ #define END_PACK_STRUCTS pack ()
+ #define GCC_PACK
+ #define NORETURN
+ #endif
+ #define main morphos_main
#elif defined(__DC__)
- #define scumm_stricmp strcasecmp
- #define CHECK_HEAP
- #define SCUMM_LITTLE_ENDIAN
- #define SCUMM_NEED_ALIGNMENT
-
- #define FORCEINLINE inline
- #define NORETURN __attribute__((__noreturn__))
- #define GCC_PACK __attribute__((packed))
- #define CDECL
-
- typedef unsigned char byte;
- typedef unsigned char uint8;
- typedef unsigned short uint16;
- typedef unsigned long uint32;
- typedef unsigned int uint;
- typedef signed char int8;
- typedef signed short int16;
- typedef signed long int32;
-
- #define START_PACK_STRUCTS pack (push,1)
- #define END_PACK_STRUCTS pack(pop)
-
+ #define scumm_stricmp strcasecmp
+ #define CHECK_HEAP
+ #define SCUMM_LITTLE_ENDIAN
+ #define SCUMM_NEED_ALIGNMENT
+
+ #define FORCEINLINE inline
+ #define NORETURN __attribute__((__noreturn__))
+ #define GCC_PACK __attribute__((packed))
+ #define CDECL
+
+ typedef unsigned char byte;
+ typedef unsigned char uint8;
+ typedef unsigned short uint16;
+ typedef unsigned long uint32;
+ typedef unsigned int uint;
+ typedef signed char int8;
+ typedef signed short int16;
+ typedef signed long int32;
+
+ #define START_PACK_STRUCTS pack (push, 1)
+ #define END_PACK_STRUCTS pack(pop)
+
#elif defined __GP32__ //ph0x
- #define CDECL
+ #define CDECL
#define SCUMM_NEED_ALIGNMENT
- #define SCUMM_LITTLE_ENDIAN
-
- #define scumm_stricmp stricmp
- #define CHECK_HEAP
-
- #define FORCEINLINE inline
- #define NORETURN __attribute__((__noreturn__))
- #define GCC_PACK __attribute__((packed))
- #define _HEAPOK 0
-
- typedef unsigned char byte;
- typedef unsigned char uint8;
- typedef unsigned short uint16;
- typedef unsigned long uint32;
- typedef unsigned int uint;
- typedef signed char int8;
- typedef signed short int16;
- typedef signed long int32;
-
- #define START_PACK_STRUCTS pack (push,1)
- #define END_PACK_STRUCTS pack(pop)
+ #define SCUMM_LITTLE_ENDIAN
+
+ #define scumm_stricmp stricmp
+ #define CHECK_HEAP
+
+ #define FORCEINLINE inline
+ #define NORETURN __attribute__((__noreturn__))
+ #define GCC_PACK __attribute__((packed))
+ #define _HEAPOK 0
+
+ typedef unsigned char byte;
+ typedef unsigned char uint8;
+ typedef unsigned short uint16;
+ typedef unsigned long uint32;
+ typedef unsigned int uint;
+ typedef signed char int8;
+ typedef signed short int16;
+ typedef signed long int32;
+
+ #define START_PACK_STRUCTS pack (push, 1)
+ #define END_PACK_STRUCTS pack(pop)
#else
- #error No system type defined
+ #error No system type defined
#endif
-#define SWAP_BYTES(a) ((((a)>>24)&0xFF) | (((a)>>8)&0xFF00) | (((a)<<8)&0xFF0000) | (((a)<<24)&0xFF000000))
+#define SWAP_BYTES(a) ((((a) >> 24) & 0xFF) | (((a) >> 8) & 0xFF00) | \
+ (((a) << 8) & 0xFF0000) | (((a) << 24) & 0xFF000000))
#if defined(SCUMM_LITTLE_ENDIAN)
-
- #define PROTO_MKID(a) SWAP_BYTES(a)
- #define PROTO_MKID_BE(a) (a & 0xffffffff)
-
- #if defined(INVERSE_MKID)
- # define MKID(a) PROTO_MKID_BE(a)
- # define MKID_BE(a) PROTO_MKID(a)
- #else
- # define MKID(a) PROTO_MKID(a)
- # define MKID_BE(a) PROTO_MKID_BE(a)
- #endif
-
-
- #if defined(SCUMM_NEED_ALIGNMENT)
- FORCEINLINE uint READ_LE_UINT16(void *ptr) {
- return (((byte*)ptr)[1]<<8)|((byte*)ptr)[0];
- }
- #else
- FORCEINLINE uint READ_LE_UINT16(void *ptr) {
- return *(uint16*)(ptr);
- }
- #endif
-
- FORCEINLINE uint READ_BE_UINT16(void *ptr) {
- return (((byte*)ptr)[0]<<8)|((byte*)ptr)[1];
- }
-
- #if defined(SCUMM_NEED_ALIGNMENT)
- FORCEINLINE uint32 READ_LE_UINT32(void *ptr) {
- byte *b = (byte*)ptr;
- return (b[3]<<24)+(b[2]<<16)+(b[1]<<8)+(b[0]);
- }
- #else
- FORCEINLINE uint32 READ_LE_UINT32(void *ptr) {
- return *(uint32*)(ptr);
- }
- #endif
-
- FORCEINLINE uint32 READ_BE_UINT32(void *ptr) {
- byte *b = (byte*)ptr;
- return (b[0]<<24)+(b[1]<<16)+(b[2]<<8)+(b[3]);
- }
-
- #define READ_BE_UINT32_UNALIGNED READ_BE_UINT32
- #define READ_BE_UINT16_UNALIGNED READ_BE_UINT16
-
- #define READ_UINT32_UNALIGNED(a) READ_LE_UINT32(a)
-
- #define FROM_LE_32(__a__) __a__
- #define FROM_LE_16(__a__) __a__
-
- #define TO_LE_32(__a__) __a__
- #define TO_LE_16(__a__) __a__
-
- #define TO_BE_32(a) SWAP_BYTES(a)
-
- uint16 FORCEINLINE TO_BE_16(uint16 a) { return (a>>8) | (a<<8); }
+
+ #define PROTO_MKID(a) SWAP_BYTES(a)
+ #define PROTO_MKID_BE(a) (a & 0xffffffff)
+
+ #if defined(INVERSE_MKID)
+ # define MKID(a) PROTO_MKID_BE(a)
+ # define MKID_BE(a) PROTO_MKID(a)
+ #else
+ # define MKID(a) PROTO_MKID(a)
+ # define MKID_BE(a) PROTO_MKID_BE(a)
+ #endif
+
+ #if defined(SCUMM_NEED_ALIGNMENT)
+ FORCEINLINE uint READ_LE_UINT16(void *ptr) {
+ return (((byte *)ptr)[1] << 8)|((byte *)ptr)[0];
+ }
+ #else
+ FORCEINLINE uint READ_LE_UINT16(void *ptr) {
+ return *(uint16 *)(ptr);
+ }
+ #endif
+
+ FORCEINLINE uint READ_BE_UINT16(void *ptr) {
+ return (((byte *)ptr)[0] << 8)|((byte *)ptr)[1];
+ }
+
+ #if defined(SCUMM_NEED_ALIGNMENT)
+ FORCEINLINE uint32 READ_LE_UINT32(void *ptr) {
+ byte *b = (byte *)ptr;
+ return (b[3] << 24) + (b[2] <<16) + (b[1] << 8) + (b[0]);
+ }
+ #else
+ FORCEINLINE uint32 READ_LE_UINT32(void *ptr) {
+ return *(uint32 *)(ptr);
+ }
+ #endif
+
+ FORCEINLINE uint32 READ_BE_UINT32(void *ptr) {
+ byte *b = (byte *)ptr;
+ return (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + (b[3]);
+ }
+
+ #define READ_BE_UINT32_UNALIGNED READ_BE_UINT32
+ #define READ_BE_UINT16_UNALIGNED READ_BE_UINT16
+
+ #define READ_UINT32_UNALIGNED(a) READ_LE_UINT32(a)
+
+ #define FROM_LE_32(__a__) __a__
+ #define FROM_LE_16(__a__) __a__
+
+ #define TO_LE_32(__a__) __a__
+ #define TO_LE_16(__a__) __a__
+
+ #define TO_BE_32(a) SWAP_BYTES(a)
+
+ uint16 FORCEINLINE TO_BE_16(uint16 a) { return (a >> 8) | (a << 8); }
#elif defined(SCUMM_BIG_ENDIAN)
- #define MKID(a) (a)
- #define MKID_BE(a) (a)
- //#define MKID_BE(a) SWAP_BYTES(a)
-
- uint32 FORCEINLINE FROM_LE_32(uint32 a) {
- return ((a>>24)&0xFF) + ((a>>8)&0xFF00) + ((a<<8)&0xFF0000) + ((a<<24)&0xFF000000);
- }
-
- uint16 FORCEINLINE FROM_LE_16(uint16 a) {
- return ((a>>8)&0xFF) + ((a<<8)&0xFF00);
- }
-
- #define TO_LE_32 FROM_LE_32
- #define TO_LE_16 FROM_LE_16
-
- uint32 FORCEINLINE READ_LE_UINT32(void *ptr) {
- byte *b = (byte*)ptr;
- return (b[3]<<24)+(b[2]<<16)+(b[1]<<8)+(b[0]);
- }
-
- uint32 FORCEINLINE READ_BE_UINT32(void *ptr) {
- return *(uint32*)(ptr);
- }
-
- uint FORCEINLINE READ_LE_UINT16(void *ptr) {
- byte *b = (byte*)ptr;
- return (b[1]<<8) + b[0];
- }
-
- uint FORCEINLINE READ_BE_UINT16(void *ptr) {
- return *(uint16*)(ptr);
- }
-
- uint FORCEINLINE READ_BE_UINT16_UNALIGNED(void *ptr) {
- return (((byte*)ptr)[0]<<8)|((byte*)ptr)[1];
- }
-
- uint32 FORCEINLINE READ_BE_UINT32_UNALIGNED(void *ptr) {
- byte *b = (byte*)ptr;
- return (b[0]<<24)+(b[1]<<16)+(b[2]<<8)+(b[3]);
- }
-
- #define READ_UINT32_UNALIGNED READ_BE_UINT32_UNALIGNED
-
- #define TO_BE_32(a) (a)
- #define TO_BE_16(a) (a)
+ #define MKID(a) (a)
+ #define MKID_BE(a) (a)
+ //#define MKID_BE(a) SWAP_BYTES(a)
-#else
+ uint32 FORCEINLINE FROM_LE_32(uint32 a) {
+ return ((a >> 24) & 0xFF) + ((a >> 8) & 0xFF00) + (( a<< 8) & 0xFF0000) \
+ + ((a<<24)&0xFF000000);
+ }
- #error No endianness defined
+ uint16 FORCEINLINE FROM_LE_16(uint16 a) {
+ return ((a >> 8) & 0xFF) + ((a << 8) & 0xFF00);
+ }
-#endif
+ #define TO_LE_32 FROM_LE_32
+ #define TO_LE_16 FROM_LE_16
+
+ uint32 FORCEINLINE READ_LE_UINT32(void *ptr) {
+ byte *b = (byte *)ptr;
+ return (b[3] << 24) + (b[2] << 16) + (b[1] << 8) + (b[0]);
+ }
+
+ uint32 FORCEINLINE READ_BE_UINT32(void *ptr) {
+ return *(uint32 *)(ptr);
+ }
+
+ uint FORCEINLINE READ_LE_UINT16(void *ptr) {
+ byte *b = (byte *)ptr;
+ return (b[1] << 8) + b[0];
+ }
+ uint FORCEINLINE READ_BE_UINT16(void *ptr) {
+ return *(uint16 *)(ptr);
+ }
+ uint FORCEINLINE READ_BE_UINT16_UNALIGNED(void *ptr) {
+ return (((byte *)ptr)[0] << 8)|((byte *)ptr)[1];
+ }
+
+ uint32 FORCEINLINE READ_BE_UINT32_UNALIGNED(void *ptr) {
+ byte *b = (byte*)ptr;
+ return (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + (b[3]);
+ }
+
+ #define READ_UINT32_UNALIGNED READ_BE_UINT32_UNALIGNED
+
+ #define TO_BE_32(a) (a)
+ #define TO_BE_16(a) (a)
+
+#else
+
+ #error No endianness defined
+
+#endif
/* Initialized operator new */
// FIXME - get rid of these new/delete overrides!!! They conflict with the
diff --git a/common/str.cpp b/common/str.cpp
index ffb8c298b0..6838be21f3 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -30,8 +30,7 @@
namespace ScummVM {
-String::String(const char *str, int len)
-{
+String::String(const char *str, int len) {
_refCount = new int(1);
if (str && len != 0) {
if (len > 0)
@@ -47,8 +46,7 @@ String::String(const char *str, int len)
}
}
-String::String(const ConstString &str)
-{
+String::String(const ConstString &str) {
printf("String::String(const ConstString &str)\n");
_refCount = new int(1);
if (str._str) {
@@ -61,8 +59,7 @@ String::String(const ConstString &str)
}
}
-String::String(const String &str)
-{
+String::String(const String &str) {
++(*str._refCount);
_refCount = str._refCount;
@@ -71,13 +68,11 @@ String::String(const String &str)
_str = str._str;
}
-String::~String()
-{
+String::~String() {
decRefCount();
}
-void String::decRefCount()
-{
+void String::decRefCount() {
--(*_refCount);
if (*_refCount <= 0) {
delete _refCount;
@@ -86,17 +81,16 @@ void String::decRefCount()
}
}
-String& String::operator =(const char* str)
-{
+String& String::operator =(const char *str) {
int len = strlen(str);
if (len > 0) {
ensureCapacity(len, false);
-
+
_len = len;
memcpy(_str, str, _len + 1);
} else if (_len > 0) {
decRefCount();
-
+
_refCount = new int(1);
_capacity = 0;
_len = 0;
@@ -105,12 +99,11 @@ String& String::operator =(const char* str)
return *this;
}
-String& String::operator =(const String& str)
-{
+String &String::operator =(const String &str) {
++(*str._refCount);
decRefCount();
-
+
_refCount = str._refCount;
_capacity = str._capacity;
_len = str._len;
@@ -119,8 +112,7 @@ String& String::operator =(const String& str)
return *this;
}
-String& String::operator +=(const char* str)
-{
+String &String::operator +=(const char *str) {
int len = strlen(str);
if (len > 0) {
ensureCapacity(_len + len, true);
@@ -131,8 +123,7 @@ String& String::operator +=(const char* str)
return *this;
}
-String& String::operator +=(const String& str)
-{
+String &String::operator +=(const String &str) {
int len = str._len;
if (len > 0) {
ensureCapacity(_len + len, true);
@@ -143,10 +134,9 @@ String& String::operator +=(const String& str)
return *this;
}
-String& String::operator +=(char c)
-{
+String &String::operator += (char c) {
ensureCapacity(_len + 1, true);
-
+
_str[_len++] = c;
_str[_len] = 0;
@@ -160,8 +150,7 @@ void String::deleteLastChar() {
}
}
-void String::deleteChar(int p)
-{
+void String::deleteChar(int p) {
if (p >= 0 && p < _len) {
ensureCapacity(_len - 1, true);
while (p++ < _len)
@@ -170,11 +159,10 @@ void String::deleteChar(int p)
}
}
-void String::clear()
-{
+void String::clear() {
if (_capacity) {
decRefCount();
-
+
_refCount = new int(1);
_capacity = 0;
_len = 0;
@@ -182,8 +170,7 @@ void String::clear()
}
}
-void String::insertChar(char c, int p)
-{
+void String::insertChar(char c, int p) {
if (p >= 0 && p <= _len) {
ensureCapacity(++_len, true);
for (int i = _len; i > p; i--) {
@@ -193,26 +180,23 @@ void String::insertChar(char c, int p)
}
}
-void String::toLowercase()
-{
+void String::toLowercase() {
if (_str == 0 || _len == 0)
return;
-
+
for (int i = 0; i < _len; ++i)
_str[i] = tolower(_str[i]);
}
-void String::toUppercase()
-{
+void String::toUppercase() {
if (_str == 0 || _len == 0)
return;
-
+
for (int i = 0; i < _len; ++i)
_str[i] = toupper(_str[i]);
}
-void String::ensureCapacity(int new_len, bool keep_old)
-{
+void String::ensureCapacity(int new_len, bool keep_old) {
// If there is not enough space, or if we are not the only owner
// of the current data, then we have to reallocate it.
if (new_len <= _capacity && *_refCount == 1)
@@ -227,23 +211,19 @@ void String::ensureCapacity(int new_len, bool keep_old)
_len = 0;
decRefCount();
-
+
_refCount = new int(1);
_capacity = newCapacity;
_str = newStr;
}
-
#pragma mark -
-
-bool ConstString::operator ==(const ConstString& x) const
-{
+bool ConstString::operator ==(const ConstString &x) const {
return (_len == x._len) && ((_len == 0) || (0 == strcmp(_str, x._str)));
}
-bool ConstString::operator ==(const char* x) const
-{
+bool ConstString::operator ==(const char *x) const {
if (_str == 0)
return (x == 0) || (*x == 0);
if (x == 0)
@@ -251,13 +231,11 @@ bool ConstString::operator ==(const char* x) const
return (0 == strcmp(_str, x));
}
-bool ConstString::operator !=(const ConstString& x) const
-{
+bool ConstString::operator !=(const ConstString &x) const {
return (_len != x._len) || ((_len != 0) && (0 != strcmp(_str, x._str)));
}
-bool ConstString::operator !=(const char* x) const
-{
+bool ConstString::operator !=(const char *x) const {
if (_str == 0)
return (x != 0) && (*x != 0);
if (x == 0)
@@ -265,37 +243,31 @@ bool ConstString::operator !=(const char* x) const
return (0 != strcmp(_str, x));
}
-bool ConstString::operator < (const ConstString& x) const
-{
+bool ConstString::operator < (const ConstString &x) const {
if (!_len || !x._len) // Any or both empty?
return !_len && x._len; // Less only if this string is empty and the other isn't
return scumm_stricmp(_str, x._str) < 0;
}
-bool ConstString::operator <= (const ConstString& x) const
-{
+bool ConstString::operator <= (const ConstString &x) const {
if (!_len || !x._len) // Any or both empty?
return !_len; // Less or equal unless the other string is empty and this one isn't
return scumm_stricmp(_str, x._str) <= 0;
}
-bool ConstString::operator > (const ConstString& x) const
-{
+bool ConstString::operator > (const ConstString &x) const {
return (x < *this);
}
-bool ConstString::operator >= (const ConstString& x) const
-{
+bool ConstString::operator >= (const ConstString &x) const {
return (x <= *this);
}
-bool operator == (const char* y, const ConstString& x)
-{
+bool operator == (const char* y, const ConstString &x) {
return (x == y);
}
-bool operator != (const char* y, const ConstString& x)
-{
+bool operator != (const char* y, const ConstString &x) {
return x != y;
}
diff --git a/common/str.h b/common/str.h
index 8ff84c3b5d..6ac5498296 100644
--- a/common/str.h
+++ b/common/str.h
@@ -49,20 +49,19 @@ protected:
public:
ConstString() : _str(0), _len(0) {}
- ConstString(const char *str, int len = -1) : _str((char*)str) { _len = str ? (len >= 0 ? len : strlen(str)) : 0; }
+ ConstString(const char *str, int len = -1) : _str((char *)str) { _len = str ? (len >= 0 ? len : strlen(str)) : 0; }
virtual ~ConstString() {}
- bool operator ==(const ConstString& x) const;
- bool operator ==(const char* x) const;
- bool operator !=(const ConstString& x) const;
- bool operator !=(const char* x) const;
- bool operator <(const ConstString& x) const;
- bool operator <=(const ConstString& x) const;
- bool operator >(const ConstString& x) const;
- bool operator >=(const ConstString& x) const;
-
- char operator [](int idx) const
- {
+ bool operator ==(const ConstString &x) const;
+ bool operator ==(const char *x) const;
+ bool operator !=(const ConstString &x) const;
+ bool operator !=(const char *x) const;
+ bool operator <(const ConstString &x) const;
+ bool operator <=(const ConstString &x) const;
+ bool operator >(const ConstString &x) const;
+ bool operator >=(const ConstString &x) const;
+
+ char operator [](int idx) const {
assert(_str && idx >= 0 && idx < _len);
return _str[idx];
}
@@ -85,26 +84,24 @@ public:
String(const String &str);
virtual ~String();
- String& operator =(const char* str);
+ String &operator =(const char *str);
// TODO - We should use RTTI here - that is, not real C++ RTTI but maybe some magic
// constant in each string object. We want to be able to optimize the case when
// a real 'String' object is passed to a function as a ConstString obj and then
// assigned to a 'String' object.
// An alternative would be to add private clone() and cloneMutable methods that
// would do the right thing.
- String& operator =(const String& str);
- String& operator +=(const char* str);
- String& operator +=(const String& str);
- String& operator +=(char c);
+ String &operator =(const String &str);
+ String &operator +=(const char *str);
+ String &operator +=(const String &str);
+ String &operator +=(char c);
- char operator [](int idx) const
- {
+ char operator [](int idx) const {
assert(_str && idx >= 0 && idx < _len);
return _str[idx];
}
- char &operator [](int idx)
- {
+ char &operator [](int idx) {
assert(_str && idx >= 0 && idx < _len);
return _str[idx];
}
@@ -113,7 +110,7 @@ public:
void deleteChar(int p);
void clear();
void insertChar(char c, int p);
-
+
void toLowercase();
void toUppercase();
@@ -123,25 +120,22 @@ protected:
};
// Some useful additional comparision operators for Strings
-bool operator == (const char* x, const ConstString& y);
-bool operator != (const char* x, const ConstString& y);
+bool operator == (const char *x, const ConstString &y);
+bool operator != (const char *x, const ConstString &y);
class StringList : public List<String> {
public:
- void push_back(const char* str)
- {
+ void push_back(const char *str) {
ensureCapacity(_size + 1);
_data[_size++] = str;
}
- void push_back(const ConstString& str)
- {
+ void push_back(const ConstString &str) {
ensureCapacity(_size + 1);
_data[_size++] = str;
}
- void push_back(const String& str)
- {
+ void push_back(const String &str) {
ensureCapacity(_size + 1);
_data[_size++] = str;
}
diff --git a/common/system.h b/common/system.h
index 5e729551ea..dacb9bb61f 100644
--- a/common/system.h
+++ b/common/system.h
@@ -182,25 +182,21 @@ public:
// Methods that convert RBG to/from colors suitable for the overlay.
// Default implementation assumes 565 mode.
- virtual int16 RBGToColor(uint8 r, uint8 g, uint8 b)
- {
- return ((((r>>3)&0x1F) << 11) | (((g>>2)&0x3F) << 5) | ((b>>3)&0x1F));
+ virtual int16 RBGToColor(uint8 r, uint8 g, uint8 b) {
+ return ((((r >> 3) & 0x1F) << 11) | (((g >> 2) & 0x3F) << 5) | ((b >> 3) & 0x1F));
}
- virtual void colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b)
- {
- r = (((color>>11)&0x1F) << 3);
- g = (((color>>5)&0x3F) << 2);
+ virtual void colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b) {
+ r = (((color >> 11) & 0x1F) << 3);
+ g = (((color >> 5) & 0x3F) << 2);
b = ((color&0x1F) << 3);
}
// Savefile management
- virtual SaveFileManager *get_savefile_manager()
- {
+ virtual SaveFileManager *get_savefile_manager() {
return new SaveFileManager();
}
};
-
/* Factory functions. This means we don't have to include the
* OSystem_SDL header file. (which in turn would require the SDL headers)
*/
diff --git a/common/timer.cpp b/common/timer.cpp
index 568a27a673..940bd0e206 100644
--- a/common/timer.cpp
+++ b/common/timer.cpp
@@ -36,8 +36,7 @@ Timer::~Timer() {
release();
}
-static int timer_handler (int t)
-{
+static int timer_handler (int t) {
eng->_timer->handler(&t);
return t;
}
@@ -68,9 +67,9 @@ bool Timer::init() {
int32 l;
if (_engine->_system == NULL) {
- printf("Timer: OSystem not initialized !\n");
- return false;
- }
+ printf("Timer: OSystem not initialized !\n");
+ return false;
+}
if (_initialized == true)
return true;
diff --git a/common/util.cpp b/common/util.cpp
index ef0e2fb7a0..90c9d84a6e 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -30,8 +30,7 @@ static int BlendCache[256][256];
// Find the entry in the given palette which matches the color defined by
// the tripel (r,b,g) most closely.
//
-int RGBMatch(byte *palette, int r, int g, int b)
-{
+int RGBMatch(byte *palette, int r, int g, int b) {
int i, bestidx = 0, besterr = 0xFFFFFF;
int error = 0;
@@ -54,49 +53,45 @@ int RGBMatch(byte *palette, int r, int g, int b)
//
// Blend two 8 bit colors into a third, all colors being defined by palette indices.
//
-int Blend(int src, int dst, byte *palette)
-{
+int Blend(int src, int dst, byte *palette) {
int r, g, b;
int alpha = 128; // Level of transparency [0-256]
- byte *srcpal = palette + (dst * 3);
+ byte *srcpal = palette + (dst * 3);
byte *dstpal = palette + (src * 3);
if (BlendCache[dst][src] > -1)
return BlendCache[dst][src];
r = (*srcpal++ * alpha);
- r += (*dstpal++ * (256-alpha));
- r /= 256;
+ r += (*dstpal++ * (256 - alpha));
+ r /= 256;
- g = (*srcpal++ * alpha);
- g += (*dstpal++ * (256-alpha));
- g /= 256;
+ g = (*srcpal++ * alpha);
+ g += (*dstpal++ * (256 - alpha));
+ g /= 256;
+
+ b = (*srcpal++ * alpha);
+ b += (*dstpal++ * (256 - alpha));
+ b /= 256;
- b = (*srcpal++ * alpha);
- b += (*dstpal++ * (256-alpha));
- b /= 256;
-
return (BlendCache[dst][src] = RGBMatch(palette, r , g , b ));
}
//
// Reset the blending cache
//
-void ClearBlendCache(byte *palette, int weight)
-{
+void ClearBlendCache(byte *palette, int weight) {
for (int i = 0; i < 256; i++)
- for (int j = 0 ; j < 256 ; j++)
+ for (int j = 0 ; j < 256 ; j++)
// BlendCache[i][j] = i; // No alphablending
// BlendCache[i][j] = j; // 100% translucent
BlendCache[i][j] = -1; // Enable alphablending
}
-
//
// Print hexdump of the data passed in, 8 bytes a row
//
-void hexdump(const byte * data, int len)
-{
+void hexdump(const byte * data, int len) {
int i;
byte c;
while (len >= 8) {
@@ -133,26 +128,22 @@ void hexdump(const byte * data, int len)
printf("|\n");
}
-RandomSource::RandomSource(uint32 seed)
-{
+RandomSource::RandomSource(uint32 seed) {
_randSeed = seed;
}
-void RandomSource::setSeed(uint32 seed)
-{
+void RandomSource::setSeed(uint32 seed) {
_randSeed = seed;
}
-uint RandomSource::getRandomNumber(uint max)
-{
+uint RandomSource::getRandomNumber(uint max) {
/* TODO: my own random number generator */
_randSeed = 0xDEADBF03 * (_randSeed + 1);
_randSeed = (_randSeed >> 13) | (_randSeed << 19);
return _randSeed % (max + 1);
}
-uint RandomSource::getRandomNumberRng(uint min, uint max)
-{
+uint RandomSource::getRandomNumberRng(uint min, uint max) {
return getRandomNumber(max - min) + min;
}
diff --git a/common/util.h b/common/util.h
index ee03684410..ab04d1f54f 100644
--- a/common/util.h
+++ b/common/util.h
@@ -24,19 +24,19 @@
#include "scummsys.h"
#ifndef ABS
-#define ABS(x) ((x)>=0?(x):-(x))
+#define ABS(x) ((x) >= 0 ? (x) : -(x))
#endif
#ifndef MIN
-#define MIN(a,b) (((a)<(b))?(a):(b))
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef MAX
-#define MAX(a,b) (((a)>(b))?(a):(b))
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
-static inline void SWAP(int &a, int &b) { int tmp=a; a=b; b=tmp; }
-#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
+static inline void SWAP(int &a, int &b) { int tmp = a; a = b; b = tmp; }
+#define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0]))
int RGBMatch(byte *palette, int r, int g, int b);
int Blend(int src, int dst, byte *palette);