diff options
Diffstat (limited to 'common')
92 files changed, 333 insertions, 658 deletions
diff --git a/common/EventDispatcher.cpp b/common/EventDispatcher.cpp index d295cb9f81..e97068c0d0 100644 --- a/common/EventDispatcher.cpp +++ b/common/EventDispatcher.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/events.h" diff --git a/common/EventRecorder.cpp b/common/EventRecorder.cpp index d2ad4bc475..eb22e1ea88 100644 --- a/common/EventRecorder.cpp +++ b/common/EventRecorder.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/EventRecorder.h" @@ -254,7 +251,7 @@ void EventRecorder::deinit() { g_system->deleteMutex(_recorderMutex); } -void EventRecorder::registerRandomSource(RandomSource &rnd, const char *name) { +void EventRecorder::registerRandomSource(RandomSource &rnd, const String &name) { if (_recordMode == kRecorderRecord) { RandomSourceRecord rec; rec.name = name; diff --git a/common/EventRecorder.h b/common/EventRecorder.h index 19272c4e29..8377d9e8bd 100644 --- a/common/EventRecorder.h +++ b/common/EventRecorder.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_EVENTRECORDER_H @@ -54,7 +51,7 @@ public: void deinit(); /** Register random source so it can be serialized in game test purposes */ - void registerRandomSource(RandomSource &rnd, const char *name); + void registerRandomSource(RandomSource &rnd, const String &name); /** TODO: Add documentation, this is only used by the backend */ void processMillis(uint32 &millis); diff --git a/common/algorithm.h b/common/algorithm.h index e5c5f81433..be810d6e9d 100644 --- a/common/algorithm.h +++ b/common/algorithm.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_ALGORITHM_H diff --git a/common/archive.cpp b/common/archive.cpp index c2c9c8e702..0ef3893a8c 100644 --- a/common/archive.cpp +++ b/common/archive.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/archive.h" diff --git a/common/archive.h b/common/archive.h index 375136fa15..3c75970d60 100644 --- a/common/archive.h +++ b/common/archive.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_ARCHIVE_H diff --git a/common/array.h b/common/array.h index e3aab66dc6..7ab4a1b042 100644 --- a/common/array.h +++ b/common/array.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_ARRAY_H @@ -27,6 +24,7 @@ #include "common/scummsys.h" #include "common/algorithm.h" +#include "common/textconsole.h" // For error() namespace Common { @@ -75,8 +73,7 @@ public: Array(const Array<T> &array) : _capacity(array._size), _size(array._size), _storage(0) { if (array._storage) { - _storage = new T[_capacity]; - assert(_storage); + allocCapacity(_size); copy(array._storage, array._storage + _size, _storage); } } @@ -86,9 +83,8 @@ public: */ template<class T2> Array(const T2 *data, int n) { - _capacity = _size = n; - _storage = new T[_capacity]; - assert(_storage); + _size = n; + allocCapacity(n); copy(data, data + _size, _storage); } @@ -182,9 +178,7 @@ public: delete[] _storage; _size = array._size; - _capacity = _size + 32; - _storage = new T[_capacity]; - assert(_storage); + allocCapacity(_size); copy(array._storage, array._storage + _size, _storage); return *this; @@ -241,15 +235,13 @@ public: if (newCapacity <= _capacity) return; - T *old_storage = _storage; - _capacity = newCapacity; - _storage = new T[newCapacity]; - assert(_storage); + T *oldStorage = _storage; + allocCapacity(newCapacity); - if (old_storage) { + if (oldStorage) { // Copy old data - copy(old_storage, old_storage + _size, _storage); - delete[] old_storage; + copy(oldStorage, oldStorage + _size, _storage); + delete[] oldStorage; } } @@ -270,6 +262,17 @@ protected: return capa; } + void allocCapacity(uint capacity) { + _capacity = capacity; + if (capacity) { + _storage = new T[capacity]; + if (!_storage) + ::error("Common::Array: failure to allocate %d bytes", capacity); + } else { + _storage = 0; + } + } + /** * Insert a range of elements coming from this or another array. * Unlike std::vector::insert, this method does not accept @@ -289,29 +292,28 @@ protected: const uint n = last - first; if (n) { const uint idx = pos - _storage; - T *newStorage = _storage; - if (_size + n > _capacity) { + T *oldStorage = _storage; + if (_size + n > _capacity || (_storage <= first && first <= _storage + _size) ) { // If there is not enough space, allocate more and // copy old elements over. - uint newCapacity = roundUpCapacity(_size + n); - newStorage = new T[newCapacity]; - assert(newStorage); - copy(_storage, _storage + idx, newStorage); - pos = newStorage + idx; + // Likewise, if this is a self-insert, we allocate new + // storage to avoid conflicts. This is not the most efficient + // way to ensure that, but probably the simplest on. + allocCapacity(roundUpCapacity(_size + n)); + copy(oldStorage, oldStorage + idx, _storage); + pos = _storage + idx; } // Make room for the new elements by shifting back // existing ones. - copy_backward(_storage + idx, _storage + _size, newStorage + _size + n); + copy_backward(oldStorage + idx, oldStorage + _size, _storage + _size + n); // Insert the new elements. copy(first, last, pos); // Finally, update the internal state - if (newStorage != _storage) { - delete[] _storage; - _capacity = roundUpCapacity(_size + n); - _storage = newStorage; + if (_storage != oldStorage) { + delete[] oldStorage; } _size += n; } diff --git a/common/bufferedstream.h b/common/bufferedstream.h index bb09e77d1d..55ea8dc13b 100644 --- a/common/bufferedstream.h +++ b/common/bufferedstream.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_BUFFEREDSTREAM_H diff --git a/common/config-file.cpp b/common/config-file.cpp index cd8f0989fc..55941131ac 100644 --- a/common/config-file.cpp +++ b/common/config-file.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/config-file.h" diff --git a/common/config-file.h b/common/config-file.h index 231162fb3c..d28ad34036 100644 --- a/common/config-file.h +++ b/common/config-file.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_CONFIG_FILE_H diff --git a/common/config-manager.cpp b/common/config-manager.cpp index 5f5c14f8de..03fcb20abf 100644 --- a/common/config-manager.cpp +++ b/common/config-manager.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/config-manager.h" diff --git a/common/config-manager.h b/common/config-manager.h index b9e4e32399..6f3f554459 100644 --- a/common/config-manager.h +++ b/common/config-manager.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_CONFIG_MANAGER_H diff --git a/common/dcl.cpp b/common/dcl.cpp index efe1de0415..b75f7f3fa6 100644 --- a/common/dcl.cpp +++ b/common/dcl.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/dcl.h" diff --git a/common/dcl.h b/common/dcl.h index 88cf9335cf..12c4e12772 100644 --- a/common/dcl.h +++ b/common/dcl.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ /** diff --git a/common/debug-channels.h b/common/debug-channels.h index 445d0e0261..54de9d491e 100644 --- a/common/debug-channels.h +++ b/common/debug-channels.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_DEBUG_CHANNELS_H diff --git a/common/debug.cpp b/common/debug.cpp index a8711055fd..dbbb204deb 100644 --- a/common/debug.cpp +++ b/common/debug.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #include "common/debug.h" diff --git a/common/debug.h b/common/debug.h index 03de7f4f77..dc94839082 100644 --- a/common/debug.h +++ b/common/debug.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_DEBUG_H diff --git a/common/endian.h b/common/endian.h index e6c39d3a4c..9cb703858a 100644 --- a/common/endian.h +++ b/common/endian.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_ENDIAN_H @@ -149,51 +146,57 @@ */ #define MKTAG(a0,a1,a2,a3) ((uint32)((a3) | ((a2) << 8) | ((a1) << 16) | ((a0) << 24))) -// Functions for reading/writing native Integers, -// this transparently handles the need for alignment +// Functions for reading/writing native integers. +// They also transparently handle the need for alignment. -#if !defined(SCUMM_NEED_ALIGNMENT) +// Test for GCC >= 4.0. These implementations will automatically use +// CPU-specific instructions for unaligned data when they are available (eg. +// MIPS). See also this email thread on scummvm-devel for details: +// <http://thread.gmane.org/gmane.games.devel.scummvm/8063> +// +// Moreover, we activate this code for GCC >= 3.3 but *only* if unaligned access +// is allowed. +#if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3 && !defined(SCUMM_NEED_ALIGNMENT))) FORCEINLINE uint16 READ_UINT16(const void *ptr) { - return *(const uint16 *)(ptr); + struct Unaligned16 { uint16 val; } __attribute__ ((__packed__, __may_alias__)); + return ((const Unaligned16 *)ptr)->val; } FORCEINLINE uint32 READ_UINT32(const void *ptr) { - return *(const uint32 *)(ptr); + struct Unaligned32 { uint32 val; } __attribute__ ((__packed__, __may_alias__)); + return ((const Unaligned32 *)ptr)->val; } FORCEINLINE void WRITE_UINT16(void *ptr, uint16 value) { - *(uint16 *)(ptr) = value; + struct Unaligned16 { uint16 val; } __attribute__ ((__packed__, __may_alias__)); + ((Unaligned16 *)ptr)->val = value; } FORCEINLINE void WRITE_UINT32(void *ptr, uint32 value) { - *(uint32 *)(ptr) = value; + struct Unaligned32 { uint32 val; } __attribute__ ((__packed__, __may_alias__)); + ((Unaligned32 *)ptr)->val = value; } -// test for GCC >= 4.0. these implementations will automatically use CPU-specific -// instructions for unaligned data when they are available (eg. MIPS) -#elif defined(__GNUC__) && (__GNUC__ >= 4) +#elif !defined(SCUMM_NEED_ALIGNMENT) FORCEINLINE uint16 READ_UINT16(const void *ptr) { - struct Unaligned16 { uint16 val; } __attribute__ ((__packed__, __may_alias__)); - return ((const Unaligned16 *)ptr)->val; + return *(const uint16 *)(ptr); } FORCEINLINE uint32 READ_UINT32(const void *ptr) { - struct Unaligned32 { uint32 val; } __attribute__ ((__packed__, __may_alias__)); - return ((const Unaligned32 *)ptr)->val; + return *(const uint32 *)(ptr); } FORCEINLINE void WRITE_UINT16(void *ptr, uint16 value) { - struct Unaligned16 { uint16 val; } __attribute__ ((__packed__, __may_alias__)); - ((Unaligned16 *)ptr)->val = value; + *(uint16 *)(ptr) = value; } FORCEINLINE void WRITE_UINT32(void *ptr, uint32 value) { - struct Unaligned32 { uint32 val; } __attribute__ ((__packed__, __may_alias__)); - ((Unaligned32 *)ptr)->val = value; + *(uint32 *)(ptr) = value; } + // use software fallback by loading each byte explicitely #else diff --git a/common/error.cpp b/common/error.cpp index b07e5ebd74..f150f268c0 100644 --- a/common/error.cpp +++ b/common/error.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/error.h" diff --git a/common/error.h b/common/error.h index 1ffbba723a..c06cec4a0b 100644 --- a/common/error.h +++ b/common/error.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_ERROR_H diff --git a/common/events.h b/common/events.h index 120d7d9dea..11eb0c316e 100644 --- a/common/events.h +++ b/common/events.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_EVENTS_H diff --git a/common/file.cpp b/common/file.cpp index 485255bbdb..381bf12ecf 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/archive.h" diff --git a/common/file.h b/common/file.h index c3805baed7..86c67c077c 100644 --- a/common/file.h +++ b/common/file.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_FILE_H diff --git a/common/forbidden.h b/common/forbidden.h index af22b2ee21..d769ff38be 100644 --- a/common/forbidden.h +++ b/common/forbidden.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_FORBIDDEN_H @@ -247,6 +244,43 @@ #define setvbuf(a,b,c,d) FORBIDDEN_SYMBOL_REPLACEMENT #endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_tmpfile +#undef tmpfile +#define tmpfile() FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_tmpnam +#undef tmpnam +#define tmpnam(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_tempnam +#undef tempnam +#define tempnam(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_rand +#undef rand +#define rand() FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_srand +#undef srand +#define srand(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_random +#undef random +#define random() FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_srandom +#undef srandom +#define srandom(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + + /* * We also would like to disable the following symbols; * however, these are also frequently used in regular code, diff --git a/common/frac.h b/common/frac.h index b1e6c518d1..d402878825 100644 --- a/common/frac.h +++ b/common/frac.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_FRAC_H diff --git a/common/fs.cpp b/common/fs.cpp index d3cdc0697f..3dc8c289aa 100644 --- a/common/fs.cpp +++ b/common/fs.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #include "common/system.h" diff --git a/common/fs.h b/common/fs.h index f93c11159e..aeaa14718e 100644 --- a/common/fs.h +++ b/common/fs.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_FS_H diff --git a/common/func.h b/common/func.h index b89a64e5fb..e09ab1a438 100644 --- a/common/func.h +++ b/common/func.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_FUNC_H diff --git a/common/hash-str.h b/common/hash-str.h index 40557037e7..1b8a57827a 100644 --- a/common/hash-str.h +++ b/common/hash-str.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_HASH_STR_H diff --git a/common/hashmap.cpp b/common/hashmap.cpp index 5fe18f33ee..ff8f9db9ce 100644 --- a/common/hashmap.cpp +++ b/common/hashmap.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ // The hash map (associative array) implementation in this file is diff --git a/common/hashmap.h b/common/hashmap.h index 907a107163..f2a4d843b8 100644 --- a/common/hashmap.h +++ b/common/hashmap.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ // The hash map (associative array) implementation in this file is diff --git a/common/iff_container.cpp b/common/iff_container.cpp index c447d93f12..02b445ae05 100644 --- a/common/iff_container.cpp +++ b/common/iff_container.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/iff_container.h" diff --git a/common/iff_container.h b/common/iff_container.h index 43a551a239..1b12ef70e5 100644 --- a/common/iff_container.h +++ b/common/iff_container.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_IFF_CONTAINER_H diff --git a/common/keyboard.h b/common/keyboard.h index 40491fda6b..74b8775a0f 100644 --- a/common/keyboard.h +++ b/common/keyboard.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_KEYBOARD_H diff --git a/common/list.h b/common/list.h index ad6193c297..a1e761f55d 100644 --- a/common/list.h +++ b/common/list.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_LIST_H diff --git a/common/list_intern.h b/common/list_intern.h index b7fbaffc47..daa7446781 100644 --- a/common/list_intern.h +++ b/common/list_intern.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_LIST_INTERN_H diff --git a/common/macresman.cpp b/common/macresman.cpp index 489f8f93ce..70c6e0a7ce 100644 --- a/common/macresman.cpp +++ b/common/macresman.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/scummsys.h" @@ -550,132 +547,4 @@ void MacResManager::readMap() { } } -void MacResManager::convertCrsrCursor(SeekableReadStream *data, byte **cursor, int &w, int &h, int &hotspotX, - int &hotspotY, int &keycolor, bool colored, byte **palette, int &palSize) { - - data->readUint16BE(); // type - data->readUint32BE(); // offset to pixel map - data->readUint32BE(); // offset to pixel data - data->readUint32BE(); // expanded cursor data - data->readUint16BE(); // expanded data depth - data->readUint32BE(); // reserved - - // Grab B/W icon data - *cursor = new byte[16 * 16]; - for (int i = 0; i < 32; i++) { - byte imageByte = data->readByte(); - for (int b = 0; b < 8; b++) - cursor[0][i * 8 + b] = (byte)((imageByte & (0x80 >> b)) > 0 ? 0x0F : 0x00); - } - - // Apply mask data - for (int i = 0; i < 32; i++) { - byte imageByte = data->readByte(); - for (int b = 0; b < 8; b++) - if ((imageByte & (0x80 >> b)) == 0) - cursor[0][i * 8 + b] = 0xff; - } - - hotspotY = data->readUint16BE(); - hotspotX = data->readUint16BE(); - w = h = 16; - keycolor = 0xff; - - // Use b/w cursor on backends which don't support cursor palettes - if (!colored) - return; - - data->readUint32BE(); // reserved - data->readUint32BE(); // cursorID - - // Color version of cursor - data->readUint32BE(); // baseAddr - - // Keep only lowbyte for now - data->readByte(); - int iconRowBytes = data->readByte(); - - if (!iconRowBytes) - return; - - int iconBounds[4]; - iconBounds[0] = data->readUint16BE(); - iconBounds[1] = data->readUint16BE(); - iconBounds[2] = data->readUint16BE(); - iconBounds[3] = data->readUint16BE(); - - data->readUint16BE(); // pmVersion - data->readUint16BE(); // packType - data->readUint32BE(); // packSize - - data->readUint32BE(); // hRes - data->readUint32BE(); // vRes - - data->readUint16BE(); // pixelType - data->readUint16BE(); // pixelSize - data->readUint16BE(); // cmpCount - data->readUint16BE(); // cmpSize - - data->readUint32BE(); // planeByte - data->readUint32BE(); // pmTable - data->readUint32BE(); // reserved - - // Pixel data for cursor - int iconDataSize = iconRowBytes * (iconBounds[3] - iconBounds[1]); - byte *iconData = new byte[iconDataSize]; - - if (!iconData) { - error("Cannot allocate iconData in macresman.cpp"); - } - - data->read(iconData, iconDataSize); - - // Color table - data->readUint32BE(); // ctSeed - data->readUint16BE(); // ctFlag - uint16 ctSize = data->readUint16BE() + 1; - - *palette = new byte[ctSize * 3]; - - // Read just high byte of 16-bit color - for (int c = 0; c < ctSize; c++) { - // We just use indices 0..ctSize, so ignore color ID - data->readUint16BE(); // colorID[c] - - palette[0][c * 3 + 0] = data->readByte(); - data->readByte(); - - palette[0][c * 3 + 1] = data->readByte(); - data->readByte(); - - palette[0][c * 3 + 2] = data->readByte(); - data->readByte(); - } - - palSize = ctSize; - - int pixelsPerByte = (iconBounds[2] - iconBounds[0]) / iconRowBytes; - int bpp = 8 / pixelsPerByte; - - // build a mask to make sure the pixels are properly shifted out - int bitmask = 0; - for (int m = 0; m < bpp; m++) { - bitmask <<= 1; - bitmask |= 1; - } - - // Extract pixels from bytes - for (int j = 0; j < iconDataSize; j++) - for (int b = 0; b < pixelsPerByte; b++) { - int idx = j * pixelsPerByte + (pixelsPerByte - 1 - b); - - if (cursor[0][idx] != 0xff) // if mask is not there - cursor[0][idx] = (byte)((iconData[j] >> (b * bpp)) & bitmask); - } - - delete[] iconData; - - assert(data->size() - data->pos() == 0); -} - } // End of namespace Common diff --git a/common/macresman.h b/common/macresman.h index fdb3ce491d..4d86e46d11 100644 --- a/common/macresman.h +++ b/common/macresman.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ /** @@ -152,25 +149,6 @@ public: String getBaseFileName() const { return _baseFileName; } /** - * Convert cursor from crsr format to format suitable for feeding to CursorMan - * @param data Pointer to the cursor datax - * @param cursor Pointer to memory where result cursor will be stored. The memory - * block will be malloc()'ed - * @param w Pointer to int where the cursor width will be stored - * @param h Pointer to int where the cursor height will be stored - * @param hotspotX Storage for cursor hotspot X coordinate - * @param hotspotY Storage for cursor hotspot Y coordinate - * @param keycolor Pointer to int where the transpared color value will be stored - * @param colored If set to true then colored cursor will be returned (if any). - * b/w version will be used otherwise - * @param palette Pointer to memory where the cursor palette will be stored. - * The memory will be malloc()'ed - * @param palSize Pointer to integer where the palette size will be stored. - */ - static void convertCrsrCursor(SeekableReadStream *data, byte **cursor, int &w, int &h, int &hotspotX, - int &hotspotY, int &keycolor, bool colored, byte **palette, int &palSize); - - /** * Return list of resource IDs with specified type ID */ MacResIDArray getResIDArray(uint32 typeID); diff --git a/common/md5.cpp b/common/md5.cpp index bea9ca0dc5..52fe8b8f8d 100644 --- a/common/md5.cpp +++ b/common/md5.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ /* diff --git a/common/md5.h b/common/md5.h index e613028a5e..d1be8c8e39 100644 --- a/common/md5.h +++ b/common/md5.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_MD5_H diff --git a/common/memorypool.cpp b/common/memorypool.cpp index c4dbb5fbbd..3a570ac50e 100644 --- a/common/memorypool.cpp +++ b/common/memorypool.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/memorypool.h" diff --git a/common/memorypool.h b/common/memorypool.h index e19d982913..5ba09cebed 100644 --- a/common/memorypool.h +++ b/common/memorypool.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_MEMORYPOOL_H diff --git a/common/memstream.h b/common/memstream.h index ac42e1bad9..69fe6ec18e 100644 --- a/common/memstream.h +++ b/common/memstream.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_MEMSTREAM_H diff --git a/common/mutex.cpp b/common/mutex.cpp index 8ebfa2254b..4e6316528c 100644 --- a/common/mutex.cpp +++ b/common/mutex.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/debug.h" diff --git a/common/mutex.h b/common/mutex.h index 3addaa6b18..26f69a3996 100644 --- a/common/mutex.h +++ b/common/mutex.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_MUTEX_H diff --git a/common/noncopyable.h b/common/noncopyable.h index f639d9abf7..0cbe41388a 100644 --- a/common/noncopyable.h +++ b/common/noncopyable.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_NONCOPYABLE_H diff --git a/common/pack-end.h b/common/pack-end.h index 701b12dccc..04633b7635 100644 --- a/common/pack-end.h +++ b/common/pack-end.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #if defined(SCUMMVM_USE_PRAGMA_PACK) diff --git a/common/pack-start.h b/common/pack-start.h index 0b2c3eff82..631a6529d3 100644 --- a/common/pack-start.h +++ b/common/pack-start.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #if defined(SCUMMVM_USE_PRAGMA_PACK) diff --git a/common/ptr.h b/common/ptr.h index 4d7fff1fc2..e0d026f964 100644 --- a/common/ptr.h +++ b/common/ptr.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_PTR_H diff --git a/common/queue.h b/common/queue.h index df8dcfe04c..3a2d6aad4b 100644 --- a/common/queue.h +++ b/common/queue.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_QUEUE_H diff --git a/common/random.cpp b/common/random.cpp index 9fd9c33e30..55fa3cbd30 100644 --- a/common/random.cpp +++ b/common/random.cpp @@ -17,23 +17,26 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #include "common/random.h" #include "common/system.h" +#include "common/EventRecorder.h" namespace Common { -RandomSource::RandomSource() { +RandomSource::RandomSource(const String &name) { // Use system time as RNG seed. Normally not a good idea, if you are using // a RNG for security purposes, but good enough for our purposes. assert(g_system); uint32 seed = g_system->getMillis(); setSeed(seed); + + // Register this random source with the event recorder. This may end + // up querying or resetting the current seed, so we must call it + // *after* the initial seed has been set. + g_eventRec.registerRandomSource(*this, name); } void RandomSource::setSeed(uint32 seed) { diff --git a/common/random.h b/common/random.h index 8fc5c4cf7d..90f2ed5cb0 100644 --- a/common/random.h +++ b/common/random.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_RANDOM_H @@ -29,6 +26,8 @@ namespace Common { +class String; + /** * Simple random number generator. Although it is definitely not suitable for * cryptographic purposes, it serves our purposes just fine. @@ -38,10 +37,17 @@ private: uint32 _randSeed; public: - RandomSource(); + /** + * Construct a new randomness source with the specific name. + * The name used name must be globally unique, and is used to + * register the randomness source with the active event recorder, + * if any. + */ + RandomSource(const String &name); + void setSeed(uint32 seed); - uint32 getSeed() { + uint32 getSeed() const { return _randSeed; } @@ -51,12 +57,14 @@ public: * @return a random number in the interval [0, max] */ uint getRandomNumber(uint max); + /** * Generates a random bit, i.e. either 0 or 1. - * Identical to getRandomNumber(1), but faster, hopefully. + * Identical to getRandomNumber(1), but potentially faster. * @return a random bit, either 0 or 1 */ uint getRandomBit(); + /** * Generates a random unsigned integer in the interval [min, max]. * @param min the lower bound diff --git a/common/rational.cpp b/common/rational.cpp index af38dd9144..cb287869bb 100644 --- a/common/rational.cpp +++ b/common/rational.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #include "common/debug.h" diff --git a/common/rational.h b/common/rational.h index bee09d8ddb..45aa6a7a20 100644 --- a/common/rational.h +++ b/common/rational.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_RATIONAL_H diff --git a/common/rect.h b/common/rect.h index 03ad02d27a..768d1ebbb9 100644 --- a/common/rect.h +++ b/common/rect.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_RECT_H diff --git a/common/savefile.h b/common/savefile.h index 793aec3ba9..40f316267f 100644 --- a/common/savefile.h +++ b/common/savefile.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_SAVEFILE_H diff --git a/common/scummsys.h b/common/scummsys.h index 46f900b942..2420349245 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_SCUMMSYS_H @@ -110,9 +107,19 @@ #include "config.h" #endif -// make sure we really are compiling for WIN32 -#ifndef WIN32 -#undef _MSC_VER +// +// Define scumm_stricmp and scumm_strnicmp +// +#if defined(_WIN32_WCE) || defined(_MSC_VER) + #define scumm_stricmp stricmp + #define scumm_strnicmp _strnicmp + #define snprintf _snprintf +#elif defined(__MINGW32__) || defined(__GP32__) || defined(__DS__) + #define scumm_stricmp stricmp + #define scumm_strnicmp strnicmp +#else + #define scumm_stricmp strcasecmp + #define scumm_strnicmp strncasecmp #endif @@ -126,20 +133,10 @@ // - Define this on a big endian target // SCUMM_NEED_ALIGNMENT // - Define this if your system has problems reading e.g. an int32 from an odd address -// SCUMMVM_DONT_DEFINE_TYPES -// - Define this if you need to provide your own typedefs, e.g. because your -// system headers conflict with our typenames, or because you have odd -// type requirements. // SMALL_SCREEN_DEVICE // - ... // ... -// We define all types in config.h, so we don't want to typedef those types -// here again! -#ifdef HAVE_CONFIG_H -#define SCUMMVM_DONT_DEFINE_TYPES -#endif - // // By default we try to use pragma push/pop to ensure various structs we use @@ -155,206 +152,84 @@ #define SCUMMVM_USE_PRAGMA_PACK -#if defined(__SYMBIAN32__) +#if defined(HAVE_CONFIG_H) + // All settings should have been set in config.h - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp +#elif defined(__SYMBIAN32__) #define SCUMM_LITTLE_ENDIAN #define SCUMM_NEED_ALIGNMENT - #define SMALL_SCREEN_DEVICE - - // Enable Symbians own datatypes - // This is done for two reasons - // a) uint is already defined by Symbians libc component - // b) Symbian is using its "own" datatyping, and the Scummvm port - // should follow this to ensure the best compability possible. - #define SCUMMVM_DONT_DEFINE_TYPES - typedef unsigned char byte; - - typedef unsigned char uint8; - typedef signed char int8; - - typedef unsigned short int uint16; - typedef signed short int int16; - - typedef unsigned long int uint32; - typedef signed long int int32; - #elif defined(_WIN32_WCE) - #define scumm_stricmp stricmp - #define scumm_strnicmp _strnicmp - #define snprintf _snprintf - #define SCUMM_LITTLE_ENDIAN - #ifndef __GNUC__ - #define FORCEINLINE __forceinline - #define NORETURN_PRE __declspec(noreturn) - #endif - #define PLUGIN_EXPORT __declspec(dllexport) - - #if _WIN32_WCE < 300 - #define SMALL_SCREEN_DEVICE - #endif - #elif defined(_MSC_VER) - #define scumm_stricmp stricmp - #define scumm_strnicmp _strnicmp - #define snprintf _snprintf - #define SCUMM_LITTLE_ENDIAN - #define FORCEINLINE __forceinline - #define NORETURN_PRE __declspec(noreturn) - #define PLUGIN_EXPORT __declspec(dllexport) - - #elif defined(__MINGW32__) - #define scumm_stricmp stricmp - #define scumm_strnicmp strnicmp - #define SCUMM_LITTLE_ENDIAN - #define PLUGIN_EXPORT __declspec(dllexport) - -#elif defined(UNIX) - - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp - - #ifndef CONFIG_H - /* 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 - #else - #error Neither SDL_BIG_ENDIAN nor SDL_LIL_ENDIAN is set. - #endif - #endif +#elif defined(SDL_BACKEND) + /* need this for the SDL_BYTEORDER define */ + #include <SDL_byteorder.h> - // You need to set this manually if necessary -// #define SCUMM_NEED_ALIGNMENT - - // Very BAD hack following, used to avoid triggering an assert in uClibc dingux library - // "toupper" when pressing keyboard function keys. - #if defined(DINGUX) - #undef toupper - #define toupper(c) (((c & 0xFF) >= 97) && ((c & 0xFF) <= 122) ? ((c & 0xFF) - 32) : (c & 0xFF)) + #if SDL_BYTEORDER == SDL_LIL_ENDIAN + #define SCUMM_LITTLE_ENDIAN + #elif SDL_BYTEORDER == SDL_BIG_ENDIAN + #define SCUMM_BIG_ENDIAN + #else + #error Neither SDL_BIG_ENDIAN nor SDL_LIL_ENDIAN is set. #endif #elif defined(__DC__) - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp - #define SCUMM_LITTLE_ENDIAN #define SCUMM_NEED_ALIGNMENT #elif defined(__GP32__) - #define scumm_stricmp stricmp - #define scumm_strnicmp strnicmp - #define SCUMM_LITTLE_ENDIAN #define SCUMM_NEED_ALIGNMENT - // Override typenames. uint is already defined by system header files. - #define SCUMMVM_DONT_DEFINE_TYPES - typedef unsigned char byte; - - typedef unsigned char uint8; - typedef signed char int8; - - typedef unsigned short int uint16; - typedef signed short int int16; - - typedef unsigned long int uint32; - typedef signed long int int32; - #elif defined(__PLAYSTATION2__) - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp - #define SCUMM_LITTLE_ENDIAN #define SCUMM_NEED_ALIGNMENT #elif defined(__N64__) - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp - #define SCUMM_BIG_ENDIAN #define SCUMM_NEED_ALIGNMENT - #define STRINGBUFLEN 256 - - #define SCUMMVM_DONT_DEFINE_TYPES - typedef unsigned char byte; - - typedef unsigned char uint8; - typedef signed char int8; - - typedef unsigned short int uint16; - typedef signed short int int16; - - typedef unsigned int uint32; - typedef signed int int32; - - typedef unsigned long long uint64; - typedef signed long long int64; - #elif defined(__PSP__) - #include <malloc.h> - #include "backends/platform/psp/memory.h" - - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp - #define SCUMM_LITTLE_ENDIAN #define SCUMM_NEED_ALIGNMENT - /* to make an efficient, inlined memcpy implementation */ - #define memcpy(dst, src, size) psp_memcpy(dst, src, size) - #elif defined(__amigaos4__) - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp - #define SCUMM_BIG_ENDIAN #define SCUMM_NEED_ALIGNMENT -#elif defined (__DS__) - - #define scumm_stricmp stricmp - #define scumm_strnicmp strnicmp +#elif defined(__DS__) #define SCUMM_NEED_ALIGNMENT #define SCUMM_LITTLE_ENDIAN - #define SCUMMVM_DONT_DEFINE_TYPES - - #define STRINGBUFLEN 256 -// #define printf(fmt, ...) consolePrintf(fmt, ##__VA_ARGS__) - #elif defined(__WII__) - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp - #define SCUMM_BIG_ENDIAN #define SCUMM_NEED_ALIGNMENT +#elif defined(IPHONE) + + #define SCUMM_LITTLE_ENDIAN + #define SCUMM_NEED_ALIGNMENT + + #else #error No system type defined @@ -362,47 +237,96 @@ // -// GCC specific stuff +// Some more system specific settings. +// TODO/FIXME: All of these should be moved to backend specific files (such as portdefs.h) // -#if defined(__GNUC__) - #define NORETURN_POST __attribute__((__noreturn__)) - #define PACKED_STRUCT __attribute__((__packed__)) - #define GCC_PRINTF(x,y) __attribute__((__format__(__printf__, x, y))) +#if defined(__SYMBIAN32__) - #if !defined(FORCEINLINE) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) - #define FORCEINLINE inline __attribute__((__always_inline__)) + #define SMALL_SCREEN_DEVICE + +#elif defined(_WIN32_WCE) + + #if _WIN32_WCE < 300 + #define SMALL_SCREEN_DEVICE #endif -#elif defined(__INTEL_COMPILER) - #define NORETURN_POST __attribute__((__noreturn__)) - #define PACKED_STRUCT __attribute__((__packed__)) - #define GCC_PRINTF(x,y) __attribute__((__format__(__printf__, x, y))) -#else - #define PACKED_STRUCT - #define GCC_PRINTF(x,y) + +#elif defined(DINGUX) + + // Very BAD hack following, used to avoid triggering an assert in uClibc dingux library + // "toupper" when pressing keyboard function keys. + #undef toupper + #define toupper(c) (((c & 0xFF) >= 97) && ((c & 0xFF) <= 122) ? ((c & 0xFF) - 32) : (c & 0xFF)) + +#elif defined(__PSP__) + + #include <malloc.h> + #include "backends/platform/psp/memory.h" + + /* to make an efficient, inlined memcpy implementation */ + #define memcpy(dst, src, size) psp_memcpy(dst, src, size) + #endif // // Fallbacks / default values for various special macros // +#ifndef GCC_PRINTF + #if defined(__GNUC__) || defined(__INTEL_COMPILER) + #define GCC_PRINTF(x,y) __attribute__((__format__(__printf__, x, y))) + #else + #define GCC_PRINTF(x,y) + #endif +#endif + +#ifndef PACKED_STRUCT + #if defined(__GNUC__) || defined(__INTEL_COMPILER) + #define PACKED_STRUCT __attribute__((__packed__)) + #else + #define PACKED_STRUCT + #endif +#endif + #ifndef FORCEINLINE -#define FORCEINLINE inline + #if defined(_MSC_VER) + #define FORCEINLINE __forceinline + #elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) + #define FORCEINLINE inline __attribute__((__always_inline__)) + #else + #define FORCEINLINE inline + #endif #endif #ifndef PLUGIN_EXPORT -#define PLUGIN_EXPORT + #if defined(_MSC_VER) || defined(_WIN32_WCE) || defined(__MINGW32__) + #define PLUGIN_EXPORT __declspec(dllexport) + #else + #define PLUGIN_EXPORT + #endif #endif #ifndef NORETURN_PRE -#define NORETURN_PRE + #if defined(_MSC_VER) + #define NORETURN_PRE __declspec(noreturn) + #else + #define NORETURN_PRE + #endif #endif #ifndef NORETURN_POST -#define NORETURN_POST + #if defined(__GNUC__) || defined(__INTEL_COMPILER) + #define NORETURN_POST __attribute__((__noreturn__)) + #else + #define NORETURN_POST + #endif #endif #ifndef STRINGBUFLEN -#define STRINGBUFLEN 1024 + #if defined(__N64__) || defined(__DS__) + #define STRINGBUFLEN 256 + #else + #define STRINGBUFLEN 1024 + #endif #endif #ifndef MAXPATHLEN @@ -411,17 +335,73 @@ // -// Typedef our system types unless SCUMMVM_DONT_DEFINE_TYPES is set. +// Typedef our system types // -#ifndef SCUMMVM_DONT_DEFINE_TYPES - typedef unsigned char byte; - typedef unsigned char uint8; - typedef signed char int8; - typedef unsigned short uint16; - typedef signed short int16; - typedef unsigned int uint32; - typedef signed int int32; - typedef unsigned int uint; +#if !defined(HAVE_CONFIG_H) + + #if defined(__SYMBIAN32__) + + // Enable Symbians own datatypes + // This is done for two reasons + // a) uint is already defined by Symbians libc component + // b) Symbian is using its "own" datatyping, and the Scummvm port + // should follow this to ensure the best compability possible. + typedef unsigned char byte; + + typedef unsigned char uint8; + typedef signed char int8; + + typedef unsigned short int uint16; + typedef signed short int int16; + + typedef unsigned long int uint32; + typedef signed long int int32; + + #elif defined(__GP32__) + + // Override typenames. uint is already defined by system header files. + typedef unsigned char byte; + + typedef unsigned char uint8; + typedef signed char int8; + + typedef unsigned short int uint16; + typedef signed short int int16; + + typedef unsigned long int uint32; + typedef signed long int int32; + + #elif defined(__N64__) + + typedef unsigned char byte; + + typedef unsigned char uint8; + typedef signed char int8; + + typedef unsigned short int uint16; + typedef signed short int int16; + + typedef unsigned int uint32; + typedef signed int int32; + + #elif defined(__DS__) + + // Do nothing, the SDK defines all types we need in nds/ndstypes.h, + // which we include in our portsdef.h + + #else + + typedef unsigned char byte; + typedef unsigned char uint8; + typedef signed char int8; + typedef unsigned short uint16; + typedef signed short int16; + typedef unsigned int uint32; + typedef signed int int32; + typedef unsigned int uint; + + #endif + #endif @@ -437,6 +417,6 @@ typedef uint16 OverlayColor; #endif -#include "common/forbidden.h" +#include "common/forbidden.h" #endif diff --git a/common/serializer.h b/common/serializer.h index b8c62727d4..b874624d38 100644 --- a/common/serializer.h +++ b/common/serializer.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_SERIALIZER_H diff --git a/common/singleton.h b/common/singleton.h index c5aa35f68d..2f5fa41877 100644 --- a/common/singleton.h +++ b/common/singleton.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_SINGLETON_H diff --git a/common/stack.h b/common/stack.h index 5d447d5424..0d13049f2e 100644 --- a/common/stack.h +++ b/common/stack.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_STACK_H diff --git a/common/str-array.h b/common/str-array.h index 5c8324bdea..57c76bf305 100644 --- a/common/str-array.h +++ b/common/str-array.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_STRING_ARRAY_H diff --git a/common/str.cpp b/common/str.cpp index c21e4412db..08a6cb6822 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #include "common/str.h" diff --git a/common/str.h b/common/str.h index 21c0483a04..b76e4f8448 100644 --- a/common/str.h +++ b/common/str.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_STRING_H diff --git a/common/stream.cpp b/common/stream.cpp index e870e68b2d..60b40d0df2 100644 --- a/common/stream.cpp +++ b/common/stream.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/stream.h" @@ -242,6 +239,13 @@ bool SeekableSubReadStream::seek(int32 offset, int whence) { return ret; } +uint32 SafeSubReadStream::read(void *dataPtr, uint32 dataSize) { + // Make sure the parent stream is at the right position + seek(0, SEEK_CUR); + + return SeekableSubReadStream::read(dataPtr, dataSize); +} + #pragma mark - diff --git a/common/stream.h b/common/stream.h index 530b50e431..26c04e5bf6 100644 --- a/common/stream.h +++ b/common/stream.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_STREAM_H @@ -45,12 +42,18 @@ public: * Returns true if an I/O failure occurred. * This flag is never cleared automatically. In order to clear it, * client code has to call clearErr() explicitly. + * + * @note The semantics of any implementation of this method are + * supposed to match those of ISO C ferror(). */ virtual bool err() const { return false; } /** * Reset the I/O error status as returned by err(). * For a ReadStream, also reset the end-of-stream status returned by eos(). + * + * @note The semantics of any implementation of this method are + * supposed to match those of ISO C clearerr(). */ virtual void clearErr() {} }; @@ -64,6 +67,9 @@ public: * Write data into the stream. Subclasses must implement this * method; all other write methods are implemented using it. * + * @note The semantics of any implementation of this method are + * supposed to match those of ISO C fwrite(). + * * @param dataPtr pointer to the data to be written * @param dataSize number of bytes to be written * @return the number of bytes which were actually written. @@ -75,6 +81,9 @@ public: * storage medium; unbuffered streams can use the default * implementation. * + * @note The semantics of any implementation of this method are + * supposed to match those of ISO C fflush(). + * * @return true on success, false in case of a failure */ virtual bool flush() { return true; } @@ -158,6 +167,11 @@ public: * Returns true if a read failed because the stream end has been reached. * This flag is cleared by clearErr(). * For a SeekableReadStream, it is also cleared by a successful seek. + * + * @note The semantics of any implementation of this method are + * supposed to match those of ISO C feof(). In particular, in a stream + * with N bytes, reading exactly N bytes from the start should *not* + * set eos; only reading *beyond* the available data should set it. */ virtual bool eos() const = 0; @@ -165,6 +179,10 @@ public: * Read data from the stream. Subclasses must implement this * method; all other read methods are implemented using it. * + * @note The semantics of any implementation of this method are + * supposed to match those of ISO C fread(), in particular where + * it concerns setting error and end of file/stream flags. + * * @param dataPtr pointer to a buffer into which the data is read * @param dataSize number of bytes to be read * @return the number of bytes which were actually read. @@ -338,6 +356,9 @@ public: * position indicator, or end-of-file, respectively. A successful call * to the seek() method clears the end-of-file indicator for the stream. * + * @note The semantics of any implementation of this method are + * supposed to match those of ISO C fseek(). + * * @param offset the relative offset in bytes * @param whence the seek reference: SEEK_SET, SEEK_CUR, or SEEK_END * @return true on success, false in case of a failure diff --git a/common/substream.h b/common/substream.h index ecf11c54c9..f4f79ff02f 100644 --- a/common/substream.h +++ b/common/substream.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_SUBSTREAM_H @@ -102,6 +99,25 @@ public: } }; +/** + * A seekable substream that removes the exclusivity demand required by the + * normal SeekableSubReadStream, at the cost of seek()ing the parent stream + * before each read(). + * + * More than one SafeSubReadStream to the same parent stream can be used + * at the same time; they won't mess up each other. They will, however, + * reposition the parent stream, so don't depend on its position to be + * the same after a read() or seek() on one of its SafeSubReadStream. + */ +class SafeSubReadStream : public SeekableSubReadStream { +public: + SafeSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO) : + SeekableSubReadStream(parentStream, begin, end, disposeParentStream) { + } + + virtual uint32 read(void *dataPtr, uint32 dataSize); +}; + } // End of namespace Common diff --git a/common/system.cpp b/common/system.cpp index 4e902bcb14..1f2f8cc6d5 100644 --- a/common/system.cpp +++ b/common/system.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ // Disable symbol overrides so that we can use system headers. diff --git a/common/system.h b/common/system.h index 540ffde5a5..e02779fe47 100644 --- a/common/system.h +++ b/common/system.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_SYSTEM_H diff --git a/common/textconsole.cpp b/common/textconsole.cpp index 8d62cd4cb2..0bd233d206 100644 --- a/common/textconsole.cpp +++ b/common/textconsole.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #include "common/textconsole.h" diff --git a/common/textconsole.h b/common/textconsole.h index 5a535f3206..364c49b2e9 100644 --- a/common/textconsole.h +++ b/common/textconsole.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_CONSOLE_H diff --git a/common/timer.h b/common/timer.h index c87c2b3240..40438f078c 100644 --- a/common/timer.h +++ b/common/timer.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_TIMER_H diff --git a/common/tokenizer.cpp b/common/tokenizer.cpp index 8bca133b5b..395ff0767a 100644 --- a/common/tokenizer.cpp +++ b/common/tokenizer.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #include "common/tokenizer.h" diff --git a/common/tokenizer.h b/common/tokenizer.h index 0ee6e37da7..8485094997 100644 --- a/common/tokenizer.h +++ b/common/tokenizer.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_TOKENIZER_H diff --git a/common/translation.cpp b/common/translation.cpp index 5494849f4c..dc71ddc52f 100644 --- a/common/translation.cpp +++ b/common/translation.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifdef WIN32 diff --git a/common/translation.h b/common/translation.h index f8183b6350..9e5245702e 100644 --- a/common/translation.h +++ b/common/translation.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_TRANSLATION_H diff --git a/common/types.h b/common/types.h index bed204ae1b..ab86f3afc2 100644 --- a/common/types.h +++ b/common/types.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_TYPES_H diff --git a/common/unarj.cpp b/common/unarj.cpp index 4bda7ac753..f45dddaa38 100644 --- a/common/unarj.cpp +++ b/common/unarj.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ // diff --git a/common/unarj.h b/common/unarj.h index fe23ba5694..2be514c936 100644 --- a/common/unarj.h +++ b/common/unarj.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ /** diff --git a/common/unzip.cpp b/common/unzip.cpp index d56893f3cd..f0590dcbfd 100644 --- a/common/unzip.cpp +++ b/common/unzip.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ /* unzip.c -- IO on .zip files using zlib diff --git a/common/unzip.h b/common/unzip.h index fe7acdcc54..06480b0054 100644 --- a/common/unzip.h +++ b/common/unzip.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_UNZIP_H diff --git a/common/util.cpp b/common/util.cpp index 1248336d08..eed7009f90 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #include "common/util.h" diff --git a/common/util.h b/common/util.h index 4493455a8c..5d965c4d31 100644 --- a/common/util.h +++ b/common/util.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef COMMON_UTIL_H diff --git a/common/winexe.cpp b/common/winexe.cpp index 9602e84c88..7cfc140452 100644 --- a/common/winexe.cpp +++ b/common/winexe.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/str.h" diff --git a/common/winexe.h b/common/winexe.h index ce2f19cb81..bec156d2e7 100644 --- a/common/winexe.h +++ b/common/winexe.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_WINEXE_H diff --git a/common/winexe_ne.cpp b/common/winexe_ne.cpp index 844127b0e1..80266ba87e 100644 --- a/common/winexe_ne.cpp +++ b/common/winexe_ne.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/debug.h" diff --git a/common/winexe_ne.h b/common/winexe_ne.h index 2988132040..4a1b2343df 100644 --- a/common/winexe_ne.h +++ b/common/winexe_ne.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_WINEXE_NE_H diff --git a/common/winexe_pe.cpp b/common/winexe_pe.cpp index 6bb831b9c6..e5f6a24bcd 100644 --- a/common/winexe_pe.cpp +++ b/common/winexe_pe.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/array.h" diff --git a/common/winexe_pe.h b/common/winexe_pe.h index 60c4adb916..cc1d0c9770 100644 --- a/common/winexe_pe.h +++ b/common/winexe_pe.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_WINEXE_PE_H diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp index e2e1dbdfc7..9bd052fb3d 100644 --- a/common/xmlparser.cpp +++ b/common/xmlparser.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ // FIXME: Avoid using fprintf diff --git a/common/xmlparser.h b/common/xmlparser.h index c456fd0826..84fca294a0 100644 --- a/common/xmlparser.h +++ b/common/xmlparser.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef XML_PARSER_H diff --git a/common/zlib.cpp b/common/zlib.cpp index 96e9f8cb15..b047586af0 100644 --- a/common/zlib.cpp +++ b/common/zlib.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ // Disable symbol overrides so that we can use zlib.h diff --git a/common/zlib.h b/common/zlib.h index 641d4553cf..1925034310 100644 --- a/common/zlib.h +++ b/common/zlib.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_ZLIB_H |