diff --git a/.gitignore b/.gitignore index 45ee942b0d7..b624d5c4543 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,8 @@ lib*.a /.project /.cproject /.settings + +/build /dists/codeblocks/*.cbp /dists/codeblocks/*.depend /dists/codeblocks/*.layout diff --git a/Makefile.common b/Makefile.common index 996662486ec..87103e6ba6c 100644 --- a/Makefile.common +++ b/Makefile.common @@ -63,14 +63,15 @@ endif ifneq ($(findstring $(MAKEFLAGS),s),s) ifneq ($(VERBOSE_BUILD),1) ifneq ($(VERBOSE_BUILD),yes) -QUIET_CXX = @echo ' ' C++ ' ' $@; -QUIET_AS = @echo ' ' AS ' ' $@; -QUIET_NASM = @echo ' ' NASM ' ' $@; -QUIET_AR = @echo ' ' AR ' ' $@; -QUIET_RANLIB = @echo ' ' RANLIB ' ' $@; -QUIET_PLUGIN = @echo ' ' PLUGIN ' ' $@; -QUIET_LINK = @echo ' ' LINK ' ' $@; -QUIET = @ +QUIET_CXX = @echo ' ' C++ ' ' $@; +QUIET_AS = @echo ' ' AS ' ' $@; +QUIET_NASM = @echo ' ' NASM ' ' $@; +QUIET_AR = @echo ' ' AR ' ' $@; +QUIET_RANLIB = @echo ' ' RANLIB ' ' $@; +QUIET_PLUGIN = @echo ' ' PLUGIN ' ' $@; +QUIET_LINK = @echo ' ' LINK ' ' $@; +QUIET_WINDRES = @echo ' ' WINDRES '' $@; +QUIET = @ endif endif endif diff --git a/audio/softsynth/mt32.cpp b/audio/softsynth/mt32.cpp index a9ea3665d72..f5f0e84e81a 100644 --- a/audio/softsynth/mt32.cpp +++ b/audio/softsynth/mt32.cpp @@ -357,7 +357,7 @@ void MidiDriver_MT32::send(uint32 b) { void MidiDriver_MT32::setPitchBendRange(byte channel, uint range) { if (range > 24) { - printf("setPitchBendRange() called with range > 24: %d", range); + warning("setPitchBendRange() called with range > 24: %d", range); } byte benderRangeSysex[9]; benderRangeSysex[0] = 0x41; // Roland diff --git a/audio/softsynth/mt32/synth.cpp b/audio/softsynth/mt32/synth.cpp index 4d1c612942e..112527cc71b 100644 --- a/audio/softsynth/mt32/synth.cpp +++ b/audio/softsynth/mt32/synth.cpp @@ -19,6 +19,12 @@ * IN THE SOFTWARE. */ +// FIXME: Avoid using printf +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + +// FIXME: Avoid using vprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_vprintf + #include #include #include diff --git a/audio/softsynth/sid.cpp b/audio/softsynth/sid.cpp index de8f0eeac5f..40dc50e972c 100644 --- a/audio/softsynth/sid.cpp +++ b/audio/softsynth/sid.cpp @@ -109,7 +109,7 @@ void WaveformGenerator::reset() { msb_rising = false; } -RESID_INLINE void WaveformGenerator::clock(cycle_count delta_t) { +RESID_INLINE void WaveformGenerator::updateClock(cycle_count delta_t) { // No operation if test bit is set. if (test) { return; @@ -164,10 +164,10 @@ RESID_INLINE void WaveformGenerator::clock(cycle_count delta_t) { /** * Synchronize oscillators. - * This must be done after all the oscillators have been clock()'ed since the + * This must be done after all the oscillators have been updateClock()'ed since the * oscillators operate in parallel. * Note that the oscillators must be clocked exactly on the cycle when the - * MSB is set high for hard sync to operate correctly. See SID::clock(). + * MSB is set high for hard sync to operate correctly. See SID::updateClock(). */ RESID_INLINE void WaveformGenerator::synchronize() { // A special case occurs when a sync source is synced itself on the same @@ -591,7 +591,7 @@ void Filter::set_Q() { _1024_div_Q = static_cast(1024.0/(0.707 + 1.0*res/0x0f)); } -RESID_INLINE void Filter::clock(cycle_count delta_t, +RESID_INLINE void Filter::updateClock(cycle_count delta_t, sound_sample voice1, sound_sample voice2, sound_sample voice3) @@ -887,7 +887,7 @@ reg8 EnvelopeGenerator::readENV() { return output(); } -RESID_INLINE void EnvelopeGenerator::clock(cycle_count delta_t) { +RESID_INLINE void EnvelopeGenerator::updateClock(cycle_count delta_t) { // Check for ADSR delay bug. // If the rate counter comparison value is set below the current value of the // rate counter, the counter will continue counting up until it wraps around @@ -1026,7 +1026,7 @@ void ExternalFilter::reset() { Vo = 0; } -RESID_INLINE void ExternalFilter::clock(cycle_count delta_t, sound_sample Vi) { +RESID_INLINE void ExternalFilter::updateClock(cycle_count delta_t, sound_sample Vi) { // This is handy for testing. if (!enabled) { // Remove maximum DC level since there is no filter to do it. @@ -1316,7 +1316,7 @@ bool SID::set_sampling_parameters(double clock_freq, return true; } -void SID::clock(cycle_count delta_t) { +void SID::updateClock(cycle_count delta_t) { int i; if (delta_t <= 0) { @@ -1332,7 +1332,7 @@ void SID::clock(cycle_count delta_t) { // Clock amplitude modulators. for (i = 0; i < 3; i++) { - voice[i].envelope.clock(delta_t); + voice[i].envelope.updateClock(delta_t); } // Clock and synchronize oscillators. @@ -1372,7 +1372,7 @@ void SID::clock(cycle_count delta_t) { // Clock oscillators. for (i = 0; i < 3; i++) { - voice[i].wave.clock(delta_t_min); + voice[i].wave.updateClock(delta_t_min); } // Synchronize oscillators. @@ -1384,11 +1384,11 @@ void SID::clock(cycle_count delta_t) { } // Clock filter. - filter.clock(delta_t, + filter.updateClock(delta_t, voice[0].output(), voice[1].output(), voice[2].output()); // Clock external filter. - extfilt.clock(delta_t, filter.output()); + extfilt.updateClock(delta_t, filter.output()); } @@ -1396,7 +1396,7 @@ void SID::clock(cycle_count delta_t) { * SID clocking with audio sampling. * Fixpoint arithmetics is used. */ -int SID::clock(cycle_count& delta_t, short* buf, int n, int interleave) { +int SID::updateClock(cycle_count& delta_t, short* buf, int n, int interleave) { int s = 0; for (;;) { @@ -1408,13 +1408,13 @@ int SID::clock(cycle_count& delta_t, short* buf, int n, int interleave) { if (s >= n) { return s; } - clock(delta_t_sample); + updateClock(delta_t_sample); delta_t -= delta_t_sample; sample_offset = (next_sample_offset & FIXP_MASK) - (1 << (FIXP_SHIFT - 1)); buf[s++*interleave] = output(); } - clock(delta_t); + updateClock(delta_t); sample_offset -= delta_t << FIXP_SHIFT; delta_t = 0; return s; diff --git a/audio/softsynth/sid.h b/audio/softsynth/sid.h index c78f5384419..d6e402dc3b8 100644 --- a/audio/softsynth/sid.h +++ b/audio/softsynth/sid.h @@ -60,7 +60,7 @@ public: void set_sync_source(WaveformGenerator*); - void clock(cycle_count delta_t); + void updateClock(cycle_count delta_t); void synchronize(); void reset(); @@ -133,7 +133,7 @@ public: void enable_filter(bool enable); - void clock(cycle_count delta_t, + void updateClock(cycle_count delta_t, sound_sample voice1, sound_sample voice2, sound_sample voice3); void reset(); @@ -201,7 +201,7 @@ public: enum State { ATTACK, DECAY_SUSTAIN, RELEASE }; - void clock(cycle_count delta_t); + void updateClock(cycle_count delta_t); void reset(); void writeCONTROL_REG(reg8); @@ -246,7 +246,7 @@ public: void enable_filter(bool enable); void set_sampling_parameter(double pass_freq); - void clock(cycle_count delta_t, sound_sample Vi); + void updateClock(cycle_count delta_t, sound_sample Vi); void reset(); // Audio output (20 bits). @@ -312,8 +312,8 @@ public: double sample_freq, double pass_freq = -1, double filter_scale = 0.97); - void clock(cycle_count delta_t); - int clock(cycle_count& delta_t, short* buf, int n, int interleave = 1); + void updateClock(cycle_count delta_t); + int updateClock(cycle_count& delta_t, short* buf, int n, int interleave = 1); void reset(); // Read/write registers. diff --git a/backends/fs/amigaos4/amigaos4-fs-factory.cpp b/backends/fs/amigaos4/amigaos4-fs-factory.cpp index 2c7dc612788..51c2c294d42 100644 --- a/backends/fs/amigaos4/amigaos4-fs-factory.cpp +++ b/backends/fs/amigaos4/amigaos4-fs-factory.cpp @@ -23,8 +23,9 @@ */ #if defined(__amigaos4__) + #include "backends/fs/amigaos4/amigaos4-fs-factory.h" -#include "backends/fs/amigaos4/amigaos4-fs.cpp" +#include "backends/fs/amigaos4/amigaos4-fs.h" AbstractFSNode *AmigaOSFilesystemFactory::makeRootFileNode() const { return new AmigaOSFilesystemNode(); diff --git a/backends/fs/amigaos4/amigaos4-fs.cpp b/backends/fs/amigaos4/amigaos4-fs.cpp index 8a57a3cf1c9..4f763ef9e8f 100644 --- a/backends/fs/amigaos4/amigaos4-fs.cpp +++ b/backends/fs/amigaos4/amigaos4-fs.cpp @@ -23,96 +23,15 @@ */ #if defined(__amigaos4__) -#ifdef __USE_INLINE__ -#undef __USE_INLINE__ -#endif - -#include -#include -#include - -#ifndef USE_NEWLIB -#include -#endif +#include "backends/fs/amigaos4/amigaos4-fs.h" +#include "backends/fs/stdiostream.h" #include "common/debug.h" #include "common/util.h" -#include "backends/fs/abstract-fs.h" -#include "backends/fs/stdiostream.h" #define ENTER() /* debug(6, "Enter") */ #define LEAVE() /* debug(6, "Leave") */ -/** - * Implementation of the ScummVM file system API. - * - * Parts of this class are documented in the base interface class, AbstractFSNode. - */ -class AmigaOSFilesystemNode : public AbstractFSNode { -protected: - BPTR _pFileLock; - Common::String _sDisplayName; - Common::String _sPath; - bool _bIsDirectory; - bool _bIsValid; - uint32 _nProt; - - /** - * Creates a list with all the volumes present in the root node. - */ - virtual AbstractFSList listVolumes() const; - -public: - /** - * Creates an AmigaOSFilesystemNode with the root node as path. - */ - AmigaOSFilesystemNode(); - - /** - * Creates an AmigaOSFilesystemNode for a given path. - * - * @param path Common::String with the path the new node should point to. - */ - AmigaOSFilesystemNode(const Common::String &p); - - /** - * Creates an AmigaOSFilesystemNode given its lock and display name - * - * @param pLock BPTR to the lock. - * @param pDisplayName name to be used for display, in case not supplied the FilePart() of the filename will be used. - * - * @note This shouldn't even be public as it's only internally, at best it should have been protected if not private - */ - AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName = 0); - - /** - * Copy constructor. - * - * @note Needed because it duplicates the file lock - */ - AmigaOSFilesystemNode(const AmigaOSFilesystemNode &node); - - /** - * Destructor. - */ - virtual ~AmigaOSFilesystemNode(); - - virtual bool exists() const; - virtual Common::String getDisplayName() const { return _sDisplayName; }; - virtual Common::String getName() const { return _sDisplayName; }; - virtual Common::String getPath() const { return _sPath; }; - virtual bool isDirectory() const { return _bIsDirectory; }; - virtual bool isReadable() const; - virtual bool isWritable() const; - - virtual AbstractFSNode *getChild(const Common::String &n) const; - virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFSNode *getParent() const; - - virtual Common::SeekableReadStream *createReadStream(); - virtual Common::WriteStream *createWriteStream(); -}; - /** * Returns the last component of a given path. * @@ -497,11 +416,11 @@ AbstractFSList AmigaOSFilesystemNode::listVolumes() const { } Common::SeekableReadStream *AmigaOSFilesystemNode::createReadStream() { - return StdioStream::makeFromPath(getPath().c_str(), false); + return StdioStream::makeFromPath(getPath(), false); } Common::WriteStream *AmigaOSFilesystemNode::createWriteStream() { - return StdioStream::makeFromPath(getPath().c_str(), true); + return StdioStream::makeFromPath(getPath(), true); } #endif //defined(__amigaos4__) diff --git a/backends/fs/amigaos4/amigaos4-fs.h b/backends/fs/amigaos4/amigaos4-fs.h new file mode 100644 index 00000000000..83188f89f1d --- /dev/null +++ b/backends/fs/amigaos4/amigaos4-fs.h @@ -0,0 +1,113 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 AMIGAOS_FILESYSTEM_H +#define AMIGAOS_FILESYSTEM_H + +#ifdef __USE_INLINE__ +#undef __USE_INLINE__ +#endif + +#include +#include +#include + +#ifndef USE_NEWLIB +#include +#endif + +#include "backends/fs/abstract-fs.h" + +/** + * Implementation of the ScummVM file system API. + * + * Parts of this class are documented in the base interface class, AbstractFSNode. + */ +class AmigaOSFilesystemNode : public AbstractFSNode { +protected: + BPTR _pFileLock; + Common::String _sDisplayName; + Common::String _sPath; + bool _bIsDirectory; + bool _bIsValid; + uint32 _nProt; + + /** + * Creates a list with all the volumes present in the root node. + */ + virtual AbstractFSList listVolumes() const; + +public: + /** + * Creates an AmigaOSFilesystemNode with the root node as path. + */ + AmigaOSFilesystemNode(); + + /** + * Creates an AmigaOSFilesystemNode for a given path. + * + * @param path Common::String with the path the new node should point to. + */ + AmigaOSFilesystemNode(const Common::String &p); + + /** + * Creates an AmigaOSFilesystemNode given its lock and display name + * + * @param pLock BPTR to the lock. + * @param pDisplayName name to be used for display, in case not supplied the FilePart() of the filename will be used. + * + * @note This shouldn't even be public as it's only internally, at best it should have been protected if not private + */ + AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName = 0); + + /** + * Copy constructor. + * + * @note Needed because it duplicates the file lock + */ + AmigaOSFilesystemNode(const AmigaOSFilesystemNode &node); + + /** + * Destructor. + */ + virtual ~AmigaOSFilesystemNode(); + + virtual bool exists() const; + virtual Common::String getDisplayName() const { return _sDisplayName; }; + virtual Common::String getName() const { return _sDisplayName; }; + virtual Common::String getPath() const { return _sPath; }; + virtual bool isDirectory() const { return _bIsDirectory; }; + virtual bool isReadable() const; + virtual bool isWritable() const; + + virtual AbstractFSNode *getChild(const Common::String &n) const; + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; + virtual AbstractFSNode *getParent() const; + + virtual Common::SeekableReadStream *createReadStream(); + virtual Common::WriteStream *createWriteStream(); +}; + + +#endif diff --git a/backends/fs/posix/posix-fs-factory.cpp b/backends/fs/posix/posix-fs-factory.cpp index df21d41dda1..639f57ac06a 100644 --- a/backends/fs/posix/posix-fs-factory.cpp +++ b/backends/fs/posix/posix-fs-factory.cpp @@ -23,8 +23,15 @@ */ #if defined(UNIX) + +// Re-enable some forbidden symbols to avoid clashes with stat.h and unistd.h. +// Also with clock() in sys/time.h in some Mac OS X SDKs. +#define FORBIDDEN_SYMBOL_EXCEPTION_time_h +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h +#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir + #include "backends/fs/posix/posix-fs-factory.h" -#include "backends/fs/posix/posix-fs.cpp" +#include "backends/fs/posix/posix-fs.h" AbstractFSNode *POSIXFilesystemFactory::makeRootFileNode() const { return new POSIXFilesystemNode("/"); diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index b218e9dd591..34edb785048 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -24,6 +24,12 @@ #if defined(UNIX) +// Re-enable some forbidden symbols to avoid clashes with stat.h and unistd.h. +// Also with clock() in sys/time.h in some Mac OS X SDKs. +#define FORBIDDEN_SYMBOL_EXCEPTION_time_h +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h +#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir + #include "backends/fs/posix/posix-fs.h" #include "backends/fs/stdiostream.h" #include "common/algorithm.h" @@ -238,11 +244,11 @@ AbstractFSNode *POSIXFilesystemNode::getParent() const { } Common::SeekableReadStream *POSIXFilesystemNode::createReadStream() { - return StdioStream::makeFromPath(getPath().c_str(), false); + return StdioStream::makeFromPath(getPath(), false); } Common::WriteStream *POSIXFilesystemNode::createWriteStream() { - return StdioStream::makeFromPath(getPath().c_str(), true); + return StdioStream::makeFromPath(getPath(), true); } #endif //#if defined(UNIX) diff --git a/backends/fs/posix/posix-fs.h b/backends/fs/posix/posix-fs.h index 859e8973b36..003a0b38d01 100644 --- a/backends/fs/posix/posix-fs.h +++ b/backends/fs/posix/posix-fs.h @@ -83,4 +83,4 @@ private: virtual void setFlags(); }; -#endif /*POSIX_FILESYSTEM_H*/ +#endif diff --git a/backends/fs/windows/windows-fs-factory.cpp b/backends/fs/windows/windows-fs-factory.cpp index ae9485a1215..0b240bcbcf3 100644 --- a/backends/fs/windows/windows-fs-factory.cpp +++ b/backends/fs/windows/windows-fs-factory.cpp @@ -22,13 +22,13 @@ * $Id$ */ +#if defined(WIN32) + // Disable symbol overrides so that we can use system headers. #define FORBIDDEN_SYMBOL_ALLOW_ALL -#if defined(WIN32) - #include "backends/fs/windows/windows-fs-factory.h" -#include "backends/fs/windows/windows-fs.cpp" +#include "backends/fs/windows/windows-fs.h" AbstractFSNode *WindowsFilesystemFactory::makeRootFileNode() const { return new WindowsFilesystemNode(); diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp index 00f72773c35..8345c9d7b41 100644 --- a/backends/fs/windows/windows-fs.cpp +++ b/backends/fs/windows/windows-fs.cpp @@ -22,23 +22,13 @@ * $Id$ */ -#ifdef WIN32 +#if defined(WIN32) -#if defined(ARRAYSIZE) -#undef ARRAYSIZE -#endif -#include -// winnt.h defines ARRAYSIZE, but we want our own one... -#undef ARRAYSIZE -#ifdef _WIN32_WCE -#undef GetCurrentDirectory -#endif -#include "backends/fs/abstract-fs.h" +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include "backends/fs/windows/windows-fs.h" #include "backends/fs/stdiostream.h" -#include -#include -#include -#include // F_OK, R_OK and W_OK are not defined under MSVC, so we define them here // For more information on the modes used by MSVC, check: @@ -55,84 +45,17 @@ #define W_OK 2 #endif -/** - * Implementation of the ScummVM file system API based on Windows API. - * - * Parts of this class are documented in the base interface class, AbstractFSNode. - */ -class WindowsFilesystemNode : public AbstractFSNode { -protected: - Common::String _displayName; - Common::String _path; - bool _isDirectory; - bool _isPseudoRoot; - bool _isValid; +bool WindowsFilesystemNode::exists() const { + return _access(_path.c_str(), F_OK) == 0; +} -public: - /** - * Creates a WindowsFilesystemNode with the root node as path. - * - * In regular windows systems, a virtual root path is used "". - * In windows CE, the "\" root is used instead. - */ - WindowsFilesystemNode(); +bool WindowsFilesystemNode::isReadable() const { + return _access(_path.c_str(), R_OK) == 0; +} - /** - * Creates a WindowsFilesystemNode for a given path. - * - * Examples: - * path=c:\foo\bar.txt, currentDir=false -> c:\foo\bar.txt - * path=c:\foo\bar.txt, currentDir=true -> current directory - * path=NULL, currentDir=true -> current directory - * - * @param path Common::String with the path the new node should point to. - * @param currentDir if true, the path parameter will be ignored and the resulting node will point to the current directory. - */ - WindowsFilesystemNode(const Common::String &path, const bool currentDir); - - virtual bool exists() const { return _access(_path.c_str(), F_OK) == 0; } - virtual Common::String getDisplayName() const { return _displayName; } - virtual Common::String getName() const { return _displayName; } - virtual Common::String getPath() const { return _path; } - virtual bool isDirectory() const { return _isDirectory; } - virtual bool isReadable() const { return _access(_path.c_str(), R_OK) == 0; } - virtual bool isWritable() const { return _access(_path.c_str(), W_OK) == 0; } - - virtual AbstractFSNode *getChild(const Common::String &n) const; - virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFSNode *getParent() const; - - virtual Common::SeekableReadStream *createReadStream(); - virtual Common::WriteStream *createWriteStream(); - -private: - /** - * Adds a single WindowsFilesystemNode to a given list. - * This method is used by getChildren() to populate the directory entries list. - * - * @param list List to put the file entry node in. - * @param mode Mode to use while adding the file entry to the list. - * @param base Common::String with the directory being listed. - * @param find_data Describes a file that the FindFirstFile, FindFirstFileEx, or FindNextFile functions find. - */ - static void addFile(AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data); - - /** - * Converts a Unicode string to Ascii format. - * - * @param str Common::String to convert from Unicode to Ascii. - * @return str in Ascii format. - */ - static char *toAscii(TCHAR *str); - - /** - * Converts an Ascii string to Unicode format. - * - * @param str Common::String to convert from Ascii to Unicode. - * @return str in Unicode format. - */ - static const TCHAR* toUnicode(const char *str); -}; +bool WindowsFilesystemNode::isWritable() const { + return _access(_path.c_str(), W_OK) == 0; +} void WindowsFilesystemNode::addFile(AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data) { WindowsFilesystemNode entry; @@ -314,11 +237,11 @@ AbstractFSNode *WindowsFilesystemNode::getParent() const { } Common::SeekableReadStream *WindowsFilesystemNode::createReadStream() { - return StdioStream::makeFromPath(getPath().c_str(), false); + return StdioStream::makeFromPath(getPath(), false); } Common::WriteStream *WindowsFilesystemNode::createWriteStream() { - return StdioStream::makeFromPath(getPath().c_str(), true); + return StdioStream::makeFromPath(getPath(), true); } #endif //#ifdef WIN32 diff --git a/backends/fs/windows/windows-fs.h b/backends/fs/windows/windows-fs.h new file mode 100644 index 00000000000..8e4880ce234 --- /dev/null +++ b/backends/fs/windows/windows-fs.h @@ -0,0 +1,123 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 WINDOWS_FILESYSTEM_H +#define WINDOWS_FILESYSTEM_H + +#include "backends/fs/abstract-fs.h" + +#if defined(ARRAYSIZE) +#undef ARRAYSIZE +#endif +#include +// winnt.h defines ARRAYSIZE, but we want our own one... +#undef ARRAYSIZE +#ifdef _WIN32_WCE +#undef GetCurrentDirectory +#endif +#include +#include +#include +#include + +/** + * Implementation of the ScummVM file system API based on Windows API. + * + * Parts of this class are documented in the base interface class, AbstractFSNode. + */ +class WindowsFilesystemNode : public AbstractFSNode { +protected: + Common::String _displayName; + Common::String _path; + bool _isDirectory; + bool _isPseudoRoot; + bool _isValid; + +public: + /** + * Creates a WindowsFilesystemNode with the root node as path. + * + * In regular windows systems, a virtual root path is used "". + * In windows CE, the "\" root is used instead. + */ + WindowsFilesystemNode(); + + /** + * Creates a WindowsFilesystemNode for a given path. + * + * Examples: + * path=c:\foo\bar.txt, currentDir=false -> c:\foo\bar.txt + * path=c:\foo\bar.txt, currentDir=true -> current directory + * path=NULL, currentDir=true -> current directory + * + * @param path Common::String with the path the new node should point to. + * @param currentDir if true, the path parameter will be ignored and the resulting node will point to the current directory. + */ + WindowsFilesystemNode(const Common::String &path, const bool currentDir); + + virtual bool exists() const; + virtual Common::String getDisplayName() const { return _displayName; } + virtual Common::String getName() const { return _displayName; } + virtual Common::String getPath() const { return _path; } + virtual bool isDirectory() const { return _isDirectory; } + virtual bool isReadable() const; + virtual bool isWritable() const; + + virtual AbstractFSNode *getChild(const Common::String &n) const; + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; + virtual AbstractFSNode *getParent() const; + + virtual Common::SeekableReadStream *createReadStream(); + virtual Common::WriteStream *createWriteStream(); + +private: + /** + * Adds a single WindowsFilesystemNode to a given list. + * This method is used by getChildren() to populate the directory entries list. + * + * @param list List to put the file entry node in. + * @param mode Mode to use while adding the file entry to the list. + * @param base Common::String with the directory being listed. + * @param find_data Describes a file that the FindFirstFile, FindFirstFileEx, or FindNextFile functions find. + */ + static void addFile(AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data); + + /** + * Converts a Unicode string to Ascii format. + * + * @param str Common::String to convert from Unicode to Ascii. + * @return str in Ascii format. + */ + static char *toAscii(TCHAR *str); + + /** + * Converts an Ascii string to Unicode format. + * + * @param str Common::String to convert from Ascii to Unicode. + * @return str in Unicode format. + */ + static const TCHAR* toUnicode(const char *str); +}; + +#endif diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp index 64f598da4a5..01b17fcdff8 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -32,14 +32,15 @@ #include "backends/platform/sdl/sdl.h" #include "common/config-manager.h" #include "common/mutex.h" +#include "common/textconsole.h" #include "common/translation.h" #include "common/util.h" -#include "common/textconsole.h" #ifdef USE_RGB_COLOR #include "common/list.h" #endif #include "graphics/font.h" #include "graphics/fontman.h" +#include "graphics/scaler.h" #include "graphics/surface.h" SdlGraphicsManager::SdlGraphicsManager(SdlEventSource *sdlEventSource) diff --git a/backends/midi/alsa.cpp b/backends/midi/alsa.cpp index 5b0d25f4ea6..d060454586e 100644 --- a/backends/midi/alsa.cpp +++ b/backends/midi/alsa.cpp @@ -183,6 +183,11 @@ void MidiDriver_ALSA::close() { } void MidiDriver_ALSA::send(uint32 b) { + if (!_isOpen) { + warning("MidiDriver_ALSA: Got event while not open"); + return; + } + unsigned int midiCmd[4]; ev.type = SND_SEQ_EVENT_OSS; @@ -256,6 +261,11 @@ void MidiDriver_ALSA::send(uint32 b) { } void MidiDriver_ALSA::sysEx(const byte *msg, uint16 length) { + if (!_isOpen) { + warning("MidiDriver_ALSA: Got SysEx while not open"); + return; + } + unsigned char buf[266]; assert(length + 2 <= ARRAYSIZE(buf)); diff --git a/backends/midi/dmedia.cpp b/backends/midi/dmedia.cpp index dd8199e8f80..9bbb6019a6b 100644 --- a/backends/midi/dmedia.cpp +++ b/backends/midi/dmedia.cpp @@ -34,9 +34,10 @@ #if defined(IRIX) -#include "common/scummsys.h" -#include "common/util.h" #include "common/config-manager.h" +#include "common/error.h" +#include "common/textconsole.h" +#include "common/util.h" #include "audio/musicplugin.h" #include "audio/mpu401.h" diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index 8b4451af4bd..a0416123032 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -23,6 +23,9 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#define FORBIDDEN_SYMBOL_EXCEPTION_time_h //On IRIX, sys/stat.h includes sys/time.h + #include "common/scummsys.h" #ifdef UNIX @@ -34,6 +37,7 @@ #include #include + OSystem_POSIX::OSystem_POSIX(Common::String baseConfigName) : _baseConfigName(baseConfigName) { diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index ea30ad8199d..aab8a013b33 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -23,6 +23,8 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_time_h + #ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 45dea72ee79..fe94822218f 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -39,6 +39,8 @@ #include "backends/platform/sdl/win32/win32.h" #include "backends/fs/windows/windows-fs-factory.h" +#include "common/memstream.h" + #define DEFAULT_CONFIG_FILE "residual.ini" //#define HIDE_CONSOLE @@ -170,4 +172,88 @@ Common::WriteStream *OSystem_Win32::createLogFile() { } } +namespace { + +class Win32ResourceArchive : public Common::Archive { + friend BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam); +public: + Win32ResourceArchive(); + + virtual bool hasFile(const Common::String &name); + virtual int listMembers(Common::ArchiveMemberList &list); + virtual Common::ArchiveMemberPtr getMember(const Common::String &name); + virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; +private: + typedef Common::List FilenameList; + + FilenameList _files; +}; + +BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam) { + if (IS_INTRESOURCE(lpszName)) + return TRUE; + + Win32ResourceArchive *arch = (Win32ResourceArchive *)lParam; + arch->_files.push_back(lpszName); + return TRUE; +} + +Win32ResourceArchive::Win32ResourceArchive() { + EnumResourceNames(NULL, MAKEINTRESOURCE(256), &EnumResNameProc, (LONG_PTR)this); +} + +bool Win32ResourceArchive::hasFile(const Common::String &name) { + for (FilenameList::const_iterator i = _files.begin(); i != _files.end(); ++i) { + if (i->equalsIgnoreCase(name)) + return true; + } + + return false; +} + +int Win32ResourceArchive::listMembers(Common::ArchiveMemberList &list) { + int count = 0; + + for (FilenameList::const_iterator i = _files.begin(); i != _files.end(); ++i, ++count) + list.push_back(Common::ArchiveMemberPtr(new Common::GenericArchiveMember(*i, this))); + + return count; +} + +Common::ArchiveMemberPtr Win32ResourceArchive::getMember(const Common::String &name) { + return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); +} + +Common::SeekableReadStream *Win32ResourceArchive::createReadStreamForMember(const Common::String &name) const { + HRSRC resource = FindResource(NULL, name.c_str(), MAKEINTRESOURCE(256)); + + if (resource == NULL) + return 0; + + HGLOBAL handle = LoadResource(NULL, resource); + + if (handle == NULL) + return 0; + + const byte *data = (const byte *)LockResource(handle); + + if (data == NULL) + return 0; + + uint32 size = SizeofResource(NULL, resource); + + if (size == 0) + return 0; + + return new Common::MemoryReadStream(data, size); +} + +} // End of anonymous namespace + +void OSystem_Win32::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { + s.add("Win32Res", new Win32ResourceArchive()); + + OSystem_SDL::addSysArchivesToSearchSet(s, priority); +} + #endif diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h index 8379c494377..25cb6bfbba4 100644 --- a/backends/platform/sdl/win32/win32.h +++ b/backends/platform/sdl/win32/win32.h @@ -32,6 +32,7 @@ class OSystem_Win32 : public OSystem_SDL { public: virtual void init(); + virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); protected: virtual Common::String getDefaultConfigFileName(); virtual Common::WriteStream *createLogFile(); diff --git a/backends/plugins/sdl/sdl-provider.h b/backends/plugins/sdl/sdl-provider.h index b546b028a2e..350261a37ff 100644 --- a/backends/plugins/sdl/sdl-provider.h +++ b/backends/plugins/sdl/sdl-provider.h @@ -35,6 +35,6 @@ protected: Plugin* createPlugin(const Common::FSNode &node) const; }; -#endif // defined(DYNAMIC_MODULES) && defined(UNIX) +#endif // defined(DYNAMIC_MODULES) && defined(SDL_BACKEND) #endif diff --git a/backends/saves/posix/posix-saves.cpp b/backends/saves/posix/posix-saves.cpp index 11799214bad..e8ab7558249 100644 --- a/backends/saves/posix/posix-saves.cpp +++ b/backends/saves/posix/posix-saves.cpp @@ -23,6 +23,11 @@ * */ + +// Enable mkdir +#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#define FORBIDDEN_SYMBOL_EXCEPTION_time_h //On IRIX, sys/stat.h includes sys/time.h + #include "common/scummsys.h" #if defined(UNIX) && !defined(DISABLE_DEFAULT_SAVEFILEMANAGER) diff --git a/backends/vkeybd/virtual-keyboard-gui.cpp b/backends/vkeybd/virtual-keyboard-gui.cpp index 050ab5c5a2d..9ffda6e3a79 100644 --- a/backends/vkeybd/virtual-keyboard-gui.cpp +++ b/backends/vkeybd/virtual-keyboard-gui.cpp @@ -36,7 +36,7 @@ namespace Common { static void blit(Graphics::Surface *surf_dst, Graphics::Surface *surf_src, int16 x, int16 y, OverlayColor transparent) { - if (surf_dst->bytesPerPixel != sizeof(OverlayColor) || surf_src->bytesPerPixel != sizeof(OverlayColor)) + if (surf_dst->format.bytesPerPixel != sizeof(OverlayColor) || surf_src->format.bytesPerPixel != sizeof(OverlayColor)) return; const OverlayColor *src = (const OverlayColor *)surf_src->pixels; @@ -133,7 +133,7 @@ void VirtualKeyboardGUI::setupDisplayArea(Rect& r, OverlayColor forecolor) { _dispI = 0; _dispForeColor = forecolor; _dispBackColor = _dispForeColor + 0xFF; - _dispSurface.create(r.width(), _dispFont->getFontHeight(), sizeof(OverlayColor)); + _dispSurface.create(r.width(), _dispFont->getFontHeight(), _system->getOverlayFormat()); _dispSurface.fillRect(Rect(_dispSurface.w, _dispSurface.h), _dispBackColor); _displayEnabled = true; } @@ -163,7 +163,7 @@ void VirtualKeyboardGUI::run() { _system->showOverlay(); _system->clearOverlay(); } - _overlayBackup.create(_screenW, _screenH, sizeof(OverlayColor)); + _overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat()); _system->grabOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w); setupCursor(); @@ -265,7 +265,7 @@ void VirtualKeyboardGUI::screenChanged() { _screenW = newScreenW; _screenH = newScreenH; - _overlayBackup.create(_screenW, _screenH, sizeof(OverlayColor)); + _overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat()); _system->grabOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w); if (!_kbd->checkModeResolutions()) { @@ -358,7 +358,7 @@ void VirtualKeyboardGUI::redraw() { if (w <= 0 || h <= 0) return; Graphics::Surface surf; - surf.create(w, h, sizeof(OverlayColor)); + surf.create(w, h, _system->getOverlayFormat()); OverlayColor *dst = (OverlayColor *)surf.pixels; const OverlayColor *src = (OverlayColor *) _overlayBackup.getBasePtr(_dirtyRect.left, _dirtyRect.top); diff --git a/backends/vkeybd/virtual-keyboard.cpp b/backends/vkeybd/virtual-keyboard.cpp index 2971c8d528f..e1a25474e7b 100644 --- a/backends/vkeybd/virtual-keyboard.cpp +++ b/backends/vkeybd/virtual-keyboard.cpp @@ -137,7 +137,7 @@ bool VirtualKeyboard::loadKeyboardPack(const String &packName) { _loaded = _parser->parse(); if (_loaded) { - printf("Keyboard pack '%s' loaded successfully!\n", packName.c_str()); + debug("Keyboard pack '%s' loaded successfully", packName.c_str()); } else { warning("Error parsing the keyboard pack '%s'", packName.c_str()); diff --git a/base/commandLine.cpp b/base/commandLine.cpp index b4566d2cea2..79e13a0ce73 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -23,6 +23,9 @@ * */ +// FIXME: Avoid using printf +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "engines/metaengine.h" #include "base/commandLine.h" #include "base/plugins.h" diff --git a/base/main.cpp b/base/main.cpp index 434a3b2df2c..be31e954f7a 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -31,6 +31,9 @@ * of almost all the classes, methods and variables, and how they interact. */ +// FIXME: Avoid using printf +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "engines/engine.h" #include "engines/metaengine.h" #include "base/commandLine.h" @@ -340,7 +343,8 @@ extern "C" int residual_main(int argc, const char * const argv[]) { // TODO: deal with settings that require plugins to be loaded res = Base::processSettings(command, settings); if (res.getCode() != Common::kArgumentNotProcessed) { - warning("%s", res.getDesc().c_str()); + if (res.getCode() != Common::kNoError) + warning("%s", res.getDesc().c_str()); return res.getCode(); } diff --git a/common/forbidden.h b/common/forbidden.h new file mode 100644 index 00000000000..af22b2ee213 --- /dev/null +++ b/common/forbidden.h @@ -0,0 +1,264 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * 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_FORBIDDEN_H +#define COMMON_FORBIDDEN_H + +/** + * @file + * This header file is meant to help ensure that engines and + * infrastructure code do not make use of certain "forbidden" APIs, such + * as fopen(), setjmp(), etc. + * This is achieved by re-#defining various symbols to a "garbage" + * string which then trigers a compiler error. + * + * Backend files may #define FORBIDDEN_SYMBOL_ALLOW_ALL if they + * have to access functions like fopen, fread etc. + * Regular code, esp. code in engines/, should never do that. + */ + +#ifndef FORBIDDEN_SYMBOL_ALLOW_ALL + +// Make sure scummsys.h is always included first +#include "common/scummsys.h" + + +/** + * The garbage string to use as replacement for forbidden symbols. + * + * The reason for this particular string is the following: + * By including a space and some non-alphanumeric symbols we trigger + * a compiler error. By including the words "forbidden symbol" (which + * the compiler will hopefully print along with its own error message), + * we try to make clear what is causing the error. + */ +#define FORBIDDEN_SYMBOL_REPLACEMENT FORBIDDEN SYMBOL !%* + + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_printf +#undef printf +#define printf FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_fprintf +#undef fprintf +#define fprintf FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_vprintf +#undef vprintf +#define vprintf FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_vfprintf +#undef vfprintf +#define vfprintf FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_FILE +#undef FILE +#define FILE FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_fopen +#undef fopen +#define fopen(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_fclose +#undef fclose +#define fclose(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_fread +#undef fread +#define fread(a,b,c,d) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_fwrite +#undef fwrite +#define fwrite(a,b,c,d) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_fseek +#undef fseek +#define fseek(a,b,c) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_ftell +#undef ftell +#define ftell(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_feof +#undef feof +#define feof(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_fgetc +#undef fgetc +#define fgetc(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_fputc +#undef fputc +#define fputc(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#undef setjmp +#define setjmp(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_longjmp +#undef longjmp +#define longjmp(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_system +#undef system +#define system(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + + +// +// Disable various symbols from time.h +// +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_h + + /* + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_t + #undef time_t + #define time_t FORBIDDEN_SYMBOL_REPLACEMENT + #endif + */ + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_asctime + #undef asctime + #define asctime(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_clock + #undef clock + #define clock() FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_ctime + #undef ctime + #define ctime(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_difftime + #undef difftime + #define difftime(a,b) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_getdate + #undef getdate + #define getdate(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_gmtime + #undef gmtime + #define gmtime(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_localtime + #undef localtime + #define localtime(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_mktime + #undef mktime + #define mktime(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_time + #undef time + #define time(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + +#endif // FORBIDDEN_SYMBOL_EXCEPTION_time_h + +// +// Disable various symbols from unistd.h +// +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_unistd_h + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_chdir + #undef chdir + #define chdir(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_getcwd + #undef getcwd + #define getcwd(a,b) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_getwd + #undef getwd + #define getwd(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_unlink + #undef unlink + #define unlink(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + +#endif // FORBIDDEN_SYMBOL_EXCEPTION_unistd_h + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#undef mkdir +#define mkdir(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +/* +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_setlocale +#undef setlocale +#define setlocale(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif +*/ + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_setvbuf +#undef setvbuf +#define setvbuf(a,b,c,d) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +/* + * We also would like to disable the following symbols; + * however, these are also frequently used in regular code, + * e.g. for method names, so we don't override them. + * - read + * - remove + * - write + * - ... + */ + + +#endif + + +#endif diff --git a/common/macresman.cpp b/common/macresman.cpp index 489f8f93ce0..0ecb430532f 100644 --- a/common/macresman.cpp +++ b/common/macresman.cpp @@ -550,132 +550,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 fdb3ce491d1..f588d8f8539 100644 --- a/common/macresman.h +++ b/common/macresman.h @@ -151,25 +151,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 */ diff --git a/common/scummsys.h b/common/scummsys.h index aa074bfa7ea..13b1b189f43 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -367,7 +367,7 @@ #if defined(__GNUC__) #define NORETURN_POST __attribute__((__noreturn__)) #define PACKED_STRUCT __attribute__((__packed__)) - #define GCC_PRINTF(x,y) __attribute__((__format__(printf, x, y))) + #define GCC_PRINTF(x,y) __attribute__((__format__(__printf__, x, y))) #if !defined(FORCEINLINE) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) #define FORCEINLINE inline __attribute__((__always_inline__)) @@ -375,7 +375,7 @@ #elif defined(__INTEL_COMPILER) #define NORETURN_POST __attribute__((__noreturn__)) #define PACKED_STRUCT __attribute__((__packed__)) - #define GCC_PRINTF(x,y) __attribute__((__format__(printf, x, y))) + #define GCC_PRINTF(x,y) __attribute__((__format__(__printf__, x, y))) #else #define PACKED_STRUCT #define GCC_PRINTF(x,y) @@ -441,4 +441,6 @@ typedef uint16 OverlayColor; #endif +#include "common/forbidden.h" + #endif diff --git a/common/stream.cpp b/common/stream.cpp index e870e68b2df..a785ac51648 100644 --- a/common/stream.cpp +++ b/common/stream.cpp @@ -242,6 +242,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/substream.h b/common/substream.h index ecf11c54c94..8b83dbda2ee 100644 --- a/common/substream.h +++ b/common/substream.h @@ -102,6 +102,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/textconsole.h b/common/textconsole.h index 963d674c3b7..5a535f32062 100644 --- a/common/textconsole.h +++ b/common/textconsole.h @@ -66,8 +66,6 @@ void NORETURN_PRE error(const char *s, ...) GCC_PRINTF(1, 2) NORETURN_POST; #ifdef DISABLE_TEXT_CONSOLE -inline int printf(const char *s, ...) { return 0; } - inline void warning(const char *s, ...) {} #else diff --git a/common/unzip.cpp b/common/unzip.cpp index a55dfd1cad2..d56893f3cdc 100644 --- a/common/unzip.cpp +++ b/common/unzip.cpp @@ -68,6 +68,8 @@ PkWare has also a specification at : ftp://ftp.pkware.com/probdesc.zip */ +// Disable symbol overrides so that we can use zlib.h +#define FORBIDDEN_SYMBOL_ALLOW_ALL #include "common/scummsys.h" diff --git a/common/util.cpp b/common/util.cpp index a41e943981b..caf7e834462 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -214,7 +214,7 @@ const PlatformDescription g_platforms[] = { { "windows", "win", "win", "Windows", kPlatformWindows }, { "playstation", "psx", "psx", "Sony PlayStation", kPlatformPSX }, { "playstation2", "ps2", "ps2", "Sony PlayStation 2", kPlatformPS2 }, - { "cdi", "cdi", "cdi", "Phillips CD-i", kPlatformCDi }, + { "cdi", "cdi", "cdi", "Philips CD-i", kPlatformCDi }, { 0, 0, 0, "Default", kPlatformUnknown } }; diff --git a/common/util.h b/common/util.h index b487494a9de..08235eb516d 100644 --- a/common/util.h +++ b/common/util.h @@ -178,8 +178,8 @@ enum Platform { kPlatformPC98, kPlatformWii, kPlatformPSX, - kPlatformCDi, kPlatformPS2, + kPlatformCDi, kPlatformUnknown = -1 }; diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp index 7a6e794e11e..e2e1dbdfc73 100644 --- a/common/xmlparser.cpp +++ b/common/xmlparser.cpp @@ -23,6 +23,13 @@ * */ +// FIXME: Avoid using fprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf + +// FIXME: Avoid using vfprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_vfprintf + + #include "common/xmlparser.h" #include "common/archive.h" #include "common/fs.h" diff --git a/common/zlib.cpp b/common/zlib.cpp index 98ecc10c1d6..96e9f8cb159 100644 --- a/common/zlib.cpp +++ b/common/zlib.cpp @@ -23,6 +23,9 @@ * */ +// Disable symbol overrides so that we can use zlib.h +#define FORBIDDEN_SYMBOL_ALLOW_ALL + #include "common/zlib.h" #include "common/util.h" #include "common/stream.h" diff --git a/configure b/configure index 3fc9147c5ad..c2b71834f4d 100755 --- a/configure +++ b/configure @@ -1011,6 +1011,10 @@ webos) _host_os=webos _host_cpu=arm _host_alias=arm-none-linux-gnueabi + test "x$prefix" = xNONE && prefix=/media/cryptofs/apps/usr/palm/applications/org.scummvm.scummvm + datarootdir='${prefix}/data' + datadir='${datarootdir}' + docdir='${prefix}/doc' ;; wii) _host_os=wii @@ -1427,6 +1431,7 @@ echo_n "Checking hosttype... " echo $_host_os case $_host_os in amigaos*) + LDFLAGS="$LDFLAGS -use-dynld -L/sdk/local/newlib/lib" # We have to use 'long' for our 4 byte typedef because AmigaOS already typedefs (u)int32 # as (unsigned) long, and consequently we'd get a compiler error otherwise. type_4_byte='long' @@ -1499,9 +1504,9 @@ case $_host_os in if test "$_dynamic_modules" = no ; then LDFLAGS="$LDFLAGS -Wl,--gc-sections" else - LDFLAGS="$LDFLAGS -Wl,--no-gc-sections" - # TODO automate this required 2 step linking phase - # LDFLAGS="$LDFLAGS -Wl,--retain-symbols-file,ds.syms" + LDFLAGS="$LDFLAGS -Wl,--no-gc-sections" + # TODO automate this required 2 step linking phase + # LDFLAGS="$LDFLAGS -Wl,--retain-symbols-file,ds.syms" fi LDFLAGS="$LDFLAGS -L$DEVKITPRO/libnds/lib" LIBS="$LIBS -lnds9" @@ -1548,7 +1553,7 @@ case $_host_os in mingw*) DEFINES="$DEFINES -DWIN32 -D__USE_MINGW_ANSI_STDIO=0" LIBS="$LIBS -lmingw32 -lwinmm" - OBJS="$OBJS residualico.o" + OBJS="$OBJS residualwinres.o" add_line_to_config_mk 'WIN32 = 1' ;; mint*) @@ -1730,7 +1735,7 @@ if test -n "$_host"; then ;; gp2x) # This uses the GPH backend. - DEFINES="$DEFINES -DGPH_DEVICE" + DEFINES="$DEFINES -DGPH_DEVICE" DEFINES="$DEFINES -DGP2X -DREDUCE_MEMORY_USAGE" if test "$_debug_build" = yes; then DEFINES="$DEFINES -DGPH_DEBUG" @@ -2747,6 +2752,9 @@ case $_backend in # Add ../plugins as a path so plugins can be found when running from a .PND. DEFINES="$DEFINES -DPLUGIN_DIRECTORY=\\\"../plugins\\\"" ;; + webos) + DEFINES="$DEFINES -DPLUGIN_DIRECTORY=\\\"$libdir\\\"" + ;; *) DEFINES="$DEFINES -DPLUGIN_DIRECTORY=\\\"$libdir/residual\\\"" ;; @@ -2878,6 +2886,7 @@ case $_backend in INCLUDES="$INCLUDES `$_sdlconfig --prefix="$_sdlpath" --cflags`" LIBS="$LIBS `$_sdlconfig --prefix="$_sdlpath" --libs`" LDFLAGS="$LDFLAGS" + DEFINES="$DEFINES -DSDL_BACKEND" ;; ps2) # TODO ps2 diff --git a/devtools/create_project/config.h b/devtools/create_project/config.h index 9155bea9e5b..c29043f87d2 100644 --- a/devtools/create_project/config.h +++ b/devtools/create_project/config.h @@ -31,7 +31,7 @@ #define LIBS_DEFINE "RESIDUAL_LIBS" // Name of the include environment variable #define REVISION_DEFINE "RESIDUAL_INTERNAL_REVISION" -#define HAS_VIDEO_FOLDER 0 +#define HAS_VIDEO_FOLDER 1 #define ADDITIONAL_LIBRARY "glu32" #define NEEDS_RTTI 1 diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp index 4c7e9022ae9..368a5e2f4a8 100644 --- a/devtools/create_project/create_project.cpp +++ b/devtools/create_project/create_project.cpp @@ -245,6 +245,9 @@ int main(int argc, char *argv[]) { } else if (!std::strcmp(argv[i], "--build-events")) { setup.runBuildEvents = true; + } else if (!std::strcmp(argv[i], "--installer")) { + setup.runBuildEvents = true; + setup.createInstaller = true; } else { std::cerr << "ERROR: Unknown parameter \"" << argv[i] << "\"\n"; return -1; @@ -516,6 +519,8 @@ void displayHelp(const char *exe) { " The default is \"9\", thus \"Visual Studio 2008\"\n" " --build-events Run custom build events as part of the build\n" " (default: false)\n" + " --installer Create NSIS installer after the build (implies --build-events)\n" + " (default: false)\n" "\n" "Engines settings:\n" " --list-engines list all available engines and their default state\n" @@ -1220,10 +1225,20 @@ void ProjectProvider::createModuleList(const std::string &moduleDir, const Strin tokens = tokenize(line); i = tokens.begin(); } else { - if (shouldInclude.top()) - includeList.push_back(moduleDir + "/" + unifyPath(*i)); - else - excludeList.push_back(moduleDir + "/" + unifyPath(*i)); + const std::string filename = moduleDir + "/" + unifyPath(*i); + + if (shouldInclude.top()) { + // In case we should include a file, we need to make + // sure it is not in the exclude list already. If it + // is we just drop it from the exclude list. + excludeList.remove(filename); + + includeList.push_back(filename); + } else if (std::find(includeList.begin(), includeList.end(), filename) == includeList.end()) { + // We only add the file to the exclude list in case it + // has not yet been added to the include list. + excludeList.push_back(filename); + } ++i; } } diff --git a/devtools/create_project/create_project.h b/devtools/create_project/create_project.h index f4d2a0a66a4..e4ccd7313aa 100644 --- a/devtools/create_project/create_project.h +++ b/devtools/create_project/create_project.h @@ -192,10 +192,12 @@ struct BuildSetup { StringList defines; ///< List of all defines for the build. StringList libraries; ///< List of all external libraries required for the build. - bool runBuildEvents; + bool runBuildEvents; ///< Run build events as part of the build (generate revision number and copy engine/theme data & needed files to the build folder + bool createInstaller; ///< Create NSIS installer after the build BuildSetup() { - runBuildEvents = false; + runBuildEvents = false; + createInstaller = false; } }; diff --git a/devtools/create_project/msbuild.cpp b/devtools/create_project/msbuild.cpp index 06425dd4aac..f9a2e936f03 100644 --- a/devtools/create_project/msbuild.cpp +++ b/devtools/create_project/msbuild.cpp @@ -283,7 +283,7 @@ void MSBuildProvider::outputProjectSettings(std::ofstream &project, const std::s // Copy data files to the build folder project << "\t\t\n" "\t\t\tCopy data files to the build folder\n" - "\t\t\t" << getPostBuildEvent(isWin32) << "\n" + "\t\t\t" << getPostBuildEvent(isWin32, setup.createInstaller) << "\n" "\t\t\n"; } } @@ -340,7 +340,6 @@ void MSBuildProvider::outputGlobalPropFile(std::ofstream &properties, int bits, "\t\t\tWinMainCRTStartup\n" "\t\t\n" "\t\t\n" - "\t\t\tHAS_INCLUDE_SET;%(PreprocessorDefinitions)\n" "\t\t\t" << prefix << ";%(AdditionalIncludeDirectories)\n" "\t\t\n" "\t\n" diff --git a/devtools/create_project/msvc.cpp b/devtools/create_project/msvc.cpp index 49998cd7388..9ac58ab05c0 100644 --- a/devtools/create_project/msvc.cpp +++ b/devtools/create_project/msvc.cpp @@ -158,7 +158,7 @@ std::string MSVCProvider::getPreBuildEvent() const { return cmdLine; } -std::string MSVCProvider::getPostBuildEvent(bool isWin32) const { +std::string MSVCProvider::getPostBuildEvent(bool isWin32, bool createInstaller) const { std::string cmdLine = ""; cmdLine = "@echo off\n" @@ -168,7 +168,10 @@ std::string MSVCProvider::getPostBuildEvent(bool isWin32) const { cmdLine += (isWin32) ? "x86" : "x64"; - cmdLine += " %SCUMMVM_LIBS%"; + cmdLine += " %RESIDUAL_LIBS% "; + + // Specify if installer needs to be built or not + cmdLine += (createInstaller ? "1" : "0"); cmdLine += "\n" "EXIT /B0"; diff --git a/devtools/create_project/msvc.h b/devtools/create_project/msvc.h index b2f2a5d33fe..6c8ac33a760 100644 --- a/devtools/create_project/msvc.h +++ b/devtools/create_project/msvc.h @@ -89,11 +89,14 @@ protected: std::string getPreBuildEvent() const; /** - * Get the command line for copying data files to the build directory + * Get the command line for copying data files to the build directory. * - * @param isWin32 Bitness of property file + * @param isWin32 Bitness of property file. + * @param createInstaller true to NSIS create installer + * + * @return The post build event. */ - std::string getPostBuildEvent(bool isWin32) const; + std::string getPostBuildEvent(bool isWin32, bool createInstaller) const; }; } // End of CreateProjectTool namespace diff --git a/devtools/create_project/msvc10/create_project.vcxproj b/devtools/create_project/msvc10/create_project.vcxproj index 15ce217bfca..bf5e415b5dd 100644 --- a/devtools/create_project/msvc10/create_project.vcxproj +++ b/devtools/create_project/msvc10/create_project.vcxproj @@ -108,6 +108,7 @@ xcopy /Y $(TargetPath) $(SolutionDir)\..\..\..\dists\codeblocks\ + diff --git a/devtools/create_project/msvc10/create_project.vcxproj.filters b/devtools/create_project/msvc10/create_project.vcxproj.filters index 42db5aa97e9..b5e870824ee 100644 --- a/devtools/create_project/msvc10/create_project.vcxproj.filters +++ b/devtools/create_project/msvc10/create_project.vcxproj.filters @@ -58,5 +58,8 @@ scripts + + scripts + \ No newline at end of file diff --git a/devtools/create_project/msvc8/create_project.vcproj b/devtools/create_project/msvc8/create_project.vcproj index 9cd833ea234..639b23d6e78 100644 --- a/devtools/create_project/msvc8/create_project.vcproj +++ b/devtools/create_project/msvc8/create_project.vcproj @@ -232,6 +232,10 @@ RelativePath="..\scripts\revision.vbs" > + + diff --git a/devtools/create_project/msvc9/create_project.vcproj b/devtools/create_project/msvc9/create_project.vcproj index 4e0375c35e2..f56cbd711c3 100644 --- a/devtools/create_project/msvc9/create_project.vcproj +++ b/devtools/create_project/msvc9/create_project.vcproj @@ -233,6 +233,10 @@ RelativePath="..\scripts\revision.vbs" > + + diff --git a/devtools/create_project/scripts/installer.vbs b/devtools/create_project/scripts/installer.vbs new file mode 100644 index 00000000000..6bcd794bef4 --- /dev/null +++ b/devtools/create_project/scripts/installer.vbs @@ -0,0 +1,196 @@ +' +' ScummVM - Graphic Adventure Engine +' +' ScummVM is the legal property of its developers, whose names +' are too numerous to list here. Please refer to the COPYRIGHT +' file distributed with this source distribution. +' +' This program is free software; you can redistribute it and/or +' modify it under the terms of the GNU General Public License +' as published by the Free Software Foundation, version 2 +' of the License. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' 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. +' +'/ + +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +' This script calls the makensis tool to generate a NSIS Windows installer for ScummVM +' +' It tries to read the NSIS installation folder from the registry and then calls the +' command line script compiler to create the installer. +' +' This is called from the postbuild.cmd batch file +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +'================================================================ +' TODO: Reduce duplication with revision.vbs script +' (ReadRegistryKey and ParseCommandLine are identical) +'================================================================ + +Option Explicit + +Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject") +Dim WshShell : Set WshShell = CreateObject("WScript.Shell") + +' Folders +Dim rootFolder : rootFolder = "" +Dim targetFolder : targetFolder = "" +Dim arch : arch = "" + +' Parse our command line arguments +If ParseCommandLine() Then + CreateInstaller() +End If + +'//////////////////////////////////////////////////////////////// +'// Installer creation +'//////////////////////////////////////////////////////////////// +Sub CreateInstaller() + ' Get nsis installation folder + Dim nsisPath : nsisPath = GetNSISPath() + If (nsisPath = "") Then + Exit Sub + End If + + ' Preprocess architecture + Select Case arch + Case "x86" + arch = "win32" + + Case "x64" + arch = "win64" + End Select + + ' Build command line + Dim commandLine : commandLine = """" & nsisPath & "\makensis.exe"" /V2" & _ + " /Dtop_srcdir=""" & rootFolder & """" & _ + " /Dbuild_dir=""" & targetFolder & """" & _ + " /Dtext_dir=""" & targetFolder & """" & _ + " /DARCH=""" & arch & """" & _ + " """ & rootFolder & "\dists\nsis\scummvm.nsi""" + + Dim oExec: Set oExec = WshShell.Exec(commandline) + If Err.Number <> 0 Then + Wscript.StdErr.WriteLine "Error running makensis.exe!" + Exit Sub + End If + + ' Wait till the application is finished ... + Dim ostdOut : Set oStdOut = oExec.StdOut + Do While oExec.Status = 0 + If Not ostdOut.AtEndOfStream Then + Wscript.StdErr.WriteLine ostdOut.ReadAll + End If + + WScript.Sleep 100 + Loop + + If oExec.ExitCode <> 0 Then + Wscript.StdErr.WriteLine "Error while creating installer!" + Exit Sub + End If +End Sub + +Function GetNSISPath() + ' Get the directory where NSIS (should) reside(s) + Dim sNSIS + + ' First, try with 32-bit architecture + sNSIS = ReadRegistryKey("HKLM", "SOFTWARE\NSIS", "", 32) + + If sNSIS = "" Or IsNull(sNSIS) Then + ' No 32-bit version of TortoiseSVN installed, try 64-bit version (doesn't hurt on 32-bit machines, it returns nothing or is ignored) + sNSIS = ReadRegistryKey("HKLM", "SOFTWARE\NSIS", "", 64) + End If + + ' Check if Tortoise is present + If sNSIS = "" Then + Wscript.StdErr.WriteLine "NSIS not installed!" + Exit Function + End If + + GetNSISPath = sNSIS +End Function + +'//////////////////////////////////////////////////////////////// +'// Utilities +'//////////////////////////////////////////////////////////////// +Function ParseCommandLine() + ParseCommandLine = True + + If Wscript.Arguments.Count <> 3 Then + Wscript.StdErr.WriteLine "[Error] Invalid number of arguments (was: " & Wscript.Arguments.Count & ", expected: 3)" + + ParseCommandLine = False + Exit Function + End If + + ' Get our arguments + rootFolder = Wscript.Arguments.Item(0) + targetFolder = Wscript.Arguments.Item(1) + arch = Wscript.Arguments.Item(2) + + ' Check that the folders are valid + If Not FSO.FolderExists(rootFolder) Then + Wscript.StdErr.WriteLine "[Error] Invalid root folder (" & rootFolder & ")" + + ParseCommandLine = False + Exit Function + End If + + If Not FSO.FolderExists(targetFolder) Then + Wscript.StdErr.WriteLine "[Error] Invalid target folder (" & targetFolder & ")" + + ParseCommandLine = False + Exit Function + End If + + ' Set absolute paths + rootFolder = FSO.GetAbsolutePathName(rootFolder) + targetFolder = FSO.GetAbsolutePathName(targetFolder) +End Function + +Function ReadRegistryKey(shive, subkey, valuename, architecture) + Dim hiveKey, objCtx, objLocator, objServices, objReg, Inparams, Outparams + + ' First, get the Registry Provider for the requested architecture + Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet") + objCtx.Add "__ProviderArchitecture", architecture ' Must be 64 of 32 + Set objLocator = CreateObject("Wbemscripting.SWbemLocator") + Set objServices = objLocator.ConnectServer("","root\default","","",,,,objCtx) + Set objReg = objServices.Get("StdRegProv") + + ' Check the hive and give it the right value + Select Case shive + Case "HKCR", "HKEY_CLASSES_ROOT" + hiveKey = &h80000000 + Case "HKCU", "HKEY_CURRENT_USER" + hiveKey = &H80000001 + Case "HKLM", "HKEY_LOCAL_MACHINE" + hiveKey = &h80000002 + Case "HKU", "HKEY_USERS" + hiveKey = &h80000003 + Case "HKCC", "HKEY_CURRENT_CONFIG" + hiveKey = &h80000005 + Case "HKDD", "HKEY_DYN_DATA" ' Only valid for Windows 95/98 + hiveKey = &h80000006 + Case Else + MsgBox "Hive not valid (ReadRegistryKey)" + End Select + + Set Inparams = objReg.Methods_("GetStringValue").Inparameters + Inparams.Hdefkey = hiveKey + Inparams.Ssubkeyname = subkey + Inparams.Svaluename = valuename + Set Outparams = objReg.ExecMethod_("GetStringValue", Inparams,,objCtx) + + ReadRegistryKey = Outparams.SValue +End Function diff --git a/devtools/create_project/scripts/postbuild.cmd b/devtools/create_project/scripts/postbuild.cmd index c5ecc3889c9..dcdbbf89cd5 100644 --- a/devtools/create_project/scripts/postbuild.cmd +++ b/devtools/create_project/scripts/postbuild.cmd @@ -1,36 +1,52 @@ -REM @echo off +@echo off REM --------------------------------------------------------------- REM -- Post-Build Script REM --------------------------------------------------------------- REM REM Copy engine data, themes, translation and required dlls to the -REM output folder. +REM output folder and optionally create an installer REM REM Expected parameters REM Root folder REM Output folder REM Architecture REM Libs folder +REM Installer ("1" to build, "0" to skip) if "%~1"=="" goto error_root if "%~2"=="" goto error_output if "%~3"=="" goto error_arch if "%~4"=="" goto error_libs +if "%~5"=="" goto error_installer echo Copying data files echo. -REM Copy files -xcopy /F /Y "%~1/dists/engine-data/*.dat" %~2 > NUL 2>&1 -xcopy /F /Y "%~1/dists/engine-data/*.tbl" %~2 > NUL 2>&1 -xcopy /F /Y "%~1/dists/engine-data/*.cpt" %~2 > NUL 2>&1 -xcopy /F /Y "%~1/dists/engine-data/README" %~2 > NUL 2>&1 -xcopy /F /Y "%~1/gui/themes/*.zip" %~2 > NUL 2>&1 +xcopy /F /Y "%~1/AUTHORS" %~2 > NUL 2>&1 +xcopy /F /Y "%~1/COPYING.GPL" %~2 > NUL 2>&1 +xcopy /F /Y "%~1/COPYING" %~2 > NUL 2>&1 +xcopy /F /Y "%~1/COPYING.LGPL" %~2 > NUL 2>&1 +xcopy /F /Y "%~1/COPYRIGHT" %~2 > NUL 2>&1 +xcopy /F /Y "%~1/NEWS" %~2 > NUL 2>&1 +xcopy /F /Y "%~1/README" %~2 > NUL 2>&1 + +xcopy /F /Y "%~1/dists/engine-data/*.dat" %~2 > NUL 2>&1 +xcopy /F /Y "%~1/dists/engine-data/*.tbl" %~2 > NUL 2>&1 +xcopy /F /Y "%~1/dists/engine-data/*.cpt" %~2 > NUL 2>&1 +xcopy /F /Y "%~1/gui/themes/*.zip" %~2 > NUL 2>&1 xcopy /F /Y "%~1/gui/themes/translations.dat" %~2 > NUL 2>&1 -xcopy /F /Y "%~4/lib/%~3/SDL.dll" %~2 > NUL 2>&1 +xcopy /F /Y "%~4/lib/%~3/SDL.dll" %~2 > NUL 2>&1 +xcopy /F /Y "%~4/README-SDL" %~2 > NUL 2>&1 xcopy /F /Y "%~1/backends/vkeybd/packs/vkeybd_default.zip" %~2 > NUL 2>&1 + +if "%~5"=="0" goto done + +echo Running installer script +echo. +@call cscript "%~1/devtools/create_project/scripts/installer.vbs" %~1 %~2 %~3 1>NUL +if not %errorlevel% == 0 goto error_script goto done :error_root @@ -49,5 +65,13 @@ goto done echo Invalid libs folder (%~4)! goto done +:error_installer +echo Invalid installer parameter. Should be "0" or "1" (was %~5)! +goto done + +:error_script: +echo An error occured while running the installer script! +goto done + :done exit /B0 diff --git a/devtools/create_project/scripts/revision.vbs b/devtools/create_project/scripts/revision.vbs index 9c29a88f2d7..3e1212521cc 100644 --- a/devtools/create_project/scripts/revision.vbs +++ b/devtools/create_project/scripts/revision.vbs @@ -23,6 +23,21 @@ ' '/ +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +' This script tries to determine a revision number based on the current working tree +' by trying revision control tools in the following order: +' - git (with hg-git detection) +' - mercurial +' - TortoiseSVN +' - SVN +' +' It then writes a new header file to be included during build, with the revision +' information, the current branch, the revision control system (when not git) and +' a flag when the tree is dirty. +' +' This is called from the prebuild.cmd batch file +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Option Explicit ' Working copy check priority: @@ -82,14 +97,15 @@ Sub DetermineRevision() End If End If End If - - Wscript.StdErr.WriteLine "Found revision " & revision & " on branch " & branch & vbCrLf - + + Dim outputInfo : outputInfo = "Found revision " & revision & " on branch " & branch + ' Setup our revision string Dim revisionString : revisionString = revision If (modified) Then revisionString = revisionString & "-dirty" + outputInfo = outputInfo & " (dirty)" End If ' If we are not on trunk, add the branch name to the revision string @@ -100,7 +116,10 @@ Sub DetermineRevision() ' Add the DVCS name at the end (when not git) If (tool <> "git") Then revisionString = revisionString & "-" & tool + outputInfo = outputInfo & " using " & tool End If + + Wscript.StdErr.WriteLine outputInfo & vbCrLf ' Output revision header file FSO.CopyFile rootFolder & "\\base\\internal_revision.h.in", targetFolder & "\\internal_revision.h" @@ -213,10 +232,11 @@ Function DetermineGitVersion() Err.Clear On Error Resume Next DetermineGitVersion = False + Dim line Wscript.StdErr.Write " Git... " tool = "git" - ' First check if we have both a .git & .svn folders (in case hg-git has been set up to have the git folder at the working copy level) + ' First check if we have both a .git & .hg folders (in case hg-git has been set up to have the git folder at the working copy level) If FSO.FolderExists(rootFolder & "/.git") And FSO.FolderExists(rootFolder & "/.hg") Then Wscript.StdErr.WriteLine "Mercurial clone with git repository in tree!" Exit Function @@ -250,10 +270,10 @@ Function DetermineGitVersion() End If ' Get the version hash - Dim hash: hash = oExec.StdOut.ReadLine() + Dim hash : hash = oExec.StdOut.ReadLine() ' Make sure index is in sync with disk - Set oExec = WshShell.Exec(gitPath & "update-index --refresh") + Set oExec = WshShell.Exec(gitPath & "update-index --refresh --unmerged") If Err.Number = 0 Then ' Wait till the application is finished ... Do While oExec.Status = 0 @@ -261,7 +281,7 @@ Function DetermineGitVersion() Loop End If - Set oExec = WshShell.Exec(gitPath & "diff-index --exit-code --quiet HEAD " & rootFolder) + Set oExec = WshShell.Exec(gitPath & "diff-index --quiet HEAD " & rootFolder) If oExec.ExitCode <> 0 Then Wscript.StdErr.WriteLine "Error parsing git revision!" Exit Function @@ -279,14 +299,24 @@ Function DetermineGitVersion() ' Get branch name Set oExec = WshShell.Exec(gitPath & "symbolic-ref HEAD") If Err.Number = 0 Then - Dim line: line = oExec.StdOut.ReadLine() + line = oExec.StdOut.ReadLine() line = Mid(line, InStrRev(line, "/") + 1) If line <> "master" Then branch = line End If End If - ' Fallback to abbreviated revision number + ' Get revision description + Set oExec = WshShell.Exec(gitPath & "describe --match desc/*") + If Err.Number = 0 Then + line = oExec.StdOut.ReadLine() + line = Mid(line, InStr(line, "-") + 1) + If line <> "" Then + revision = line + End If + End If + + ' Fallback to abbreviated revision number if needed If revision = "" Then revision = Mid(hash, 1, 7) End If diff --git a/devtools/create_project/visualstudio.cpp b/devtools/create_project/visualstudio.cpp index 77af8aeca13..8642f071fff 100644 --- a/devtools/create_project/visualstudio.cpp +++ b/devtools/create_project/visualstudio.cpp @@ -148,7 +148,7 @@ void VisualStudioProvider::createProjectFile(const std::string &name, const std: void VisualStudioProvider::outputConfiguration(std::ostream &project, const BuildSetup &setup, const std::string &libraries, const std::string &config, const std::string &platform, const std::string &props, const bool isWin32) { project << "\t\t\n" "\t\t\t\n" - "\t\t\t\n"; outputBuildEvents(project, setup, isWin32); @@ -167,7 +167,7 @@ void VisualStudioProvider::outputBuildEvents(std::ostream &project, const BuildS "\t\t\t\tCommandLine=\"" << getPreBuildEvent() << "\"\n" "\t\t\t/>\n" "\t\t\t\n"; } } @@ -223,8 +223,7 @@ void VisualStudioProvider::outputGlobalPropFile(std::ofstream &properties, int b properties << "\t\tRuntimeTypeInfo=\"false\"\n"; #endif - properties << "\t\tRuntimeTypeInfo=\"false\"\n" - "\t\tWarningLevel=\"4\"\n" + properties << "\t\tWarningLevel=\"4\"\n" "\t\tWarnAsError=\"false\"\n" "\t\tCompileAs=\"0\"\n" "\t\t/>\n" @@ -241,7 +240,6 @@ void VisualStudioProvider::outputGlobalPropFile(std::ofstream &properties, int b "\t/>\n" "\t\n" "\n"; diff --git a/dists/residual.rc b/dists/residual.rc index ff3040289e3..b8d46a2ecd1 100644 --- a/dists/residual.rc +++ b/dists/residual.rc @@ -1,9 +1,17 @@ #include "winresrc.h" -#if defined (__MINGW32__) || defined(__CYGWIN32__) || defined(HAS_INCLUDE_SET) +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#define FILE 256 + IDI_ICON ICON DISCARDABLE "icons/residual.ico" -#else -IDI_ICON ICON DISCARDABLE "../../icons/residual.ico" + +modern.zip FILE "gui/themes/modern.zip" +#ifdef USE_TRANSLATION +translations.dat FILE "gui/themes/translations.dat" +#endif #endif VS_VERSION_INFO VERSIONINFO diff --git a/dists/residual.rc.in b/dists/residual.rc.in index bc1ec4eeed7..5f745def0e0 100644 --- a/dists/residual.rc.in +++ b/dists/residual.rc.in @@ -1,9 +1,18 @@ #include "winresrc.h" -#if defined (__MINGW32__) || defined(__CYGWIN32__) || defined(HAS_INCLUDE_SET) +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#define FILE 256 + IDI_ICON ICON DISCARDABLE "icons/residual.ico" -#else -IDI_ICON ICON DISCARDABLE "../../icons/residual.ico" + +modern.zip FILE "gui/themes/modern.zip" +#ifdef USE_TRANSLATION +translations.dat FILE "gui/themes/translations.dat" +#endif + #endif VS_VERSION_INFO VERSIONINFO diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp index 6add3a9cde6..f4230cb3b41 100644 --- a/engines/advancedDetector.cpp +++ b/engines/advancedDetector.cpp @@ -23,6 +23,9 @@ * */ +// FIXME: Avoid using printf +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "common/debug.h" #include "common/util.h" #include "common/hash-str.h" diff --git a/engines/engine.cpp b/engines/engine.cpp index a0e94e0572a..52cd07cbd84 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -22,6 +22,8 @@ * $Id$ */ +#define FORBIDDEN_SYMBOL_EXCEPTION_getcwd + #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) #define WIN32_LEAN_AND_MEAN #include diff --git a/engines/grim/actor.cpp b/engines/grim/actor.cpp index 709efde457b..5b4abaf497e 100644 --- a/engines/grim/actor.cpp +++ b/engines/grim/actor.cpp @@ -23,6 +23,8 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "graphics/line3d.h" #include "engines/grim/actor.h" diff --git a/engines/grim/bitmap.cpp b/engines/grim/bitmap.cpp index 081c1e00d80..947da467747 100644 --- a/engines/grim/bitmap.cpp +++ b/engines/grim/bitmap.cpp @@ -23,6 +23,8 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "common/endian.h" #include "engines/grim/grim.h" diff --git a/engines/grim/costume.cpp b/engines/grim/costume.cpp index 09c714b408d..7e113d54ebf 100644 --- a/engines/grim/costume.cpp +++ b/engines/grim/costume.cpp @@ -23,6 +23,8 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "common/endian.h" #include "engines/grim/colormap.h" diff --git a/engines/grim/grim.cpp b/engines/grim/grim.cpp index 985737c4145..a5394212b74 100644 --- a/engines/grim/grim.cpp +++ b/engines/grim/grim.cpp @@ -23,6 +23,11 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_printf +#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_fgetc #if defined(WIN32) #include diff --git a/engines/grim/imuse/imuse.cpp b/engines/grim/imuse/imuse.cpp index b5bd21e9167..2cb78ef8435 100644 --- a/engines/grim/imuse/imuse.cpp +++ b/engines/grim/imuse/imuse.cpp @@ -23,6 +23,10 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_printf +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp + #include "common/timer.h" #include "engines/grim/grim.h" diff --git a/engines/grim/imuse/imuse_music.cpp b/engines/grim/imuse/imuse_music.cpp index 1561bcf2304..590138c9f5b 100644 --- a/engines/grim/imuse/imuse_music.cpp +++ b/engines/grim/imuse/imuse_music.cpp @@ -23,6 +23,8 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "engines/grim/grim.h" #include "engines/grim/colormap.h" diff --git a/engines/grim/imuse/imuse_script.cpp b/engines/grim/imuse/imuse_script.cpp index 81cd595d217..dbf0c1fceb5 100644 --- a/engines/grim/imuse/imuse_script.cpp +++ b/engines/grim/imuse/imuse_script.cpp @@ -23,6 +23,8 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "engines/grim/imuse/imuse.h" #include "engines/grim/grim.h" diff --git a/engines/grim/imuse/imuse_track.cpp b/engines/grim/imuse/imuse_track.cpp index 4a71ad92757..0f87d2a6a41 100644 --- a/engines/grim/imuse/imuse_track.cpp +++ b/engines/grim/imuse/imuse_track.cpp @@ -23,6 +23,8 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "engines/grim/grim.h" #include "engines/grim/colormap.h" diff --git a/engines/grim/keyframe.cpp b/engines/grim/keyframe.cpp index 3dfdc982d3c..5c03c2c844e 100644 --- a/engines/grim/keyframe.cpp +++ b/engines/grim/keyframe.cpp @@ -23,6 +23,8 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "common/endian.h" #include "engines/grim/grim.h" diff --git a/engines/grim/lua/lapi.cpp b/engines/grim/lua/lapi.cpp index 92e2af4d69e..355abc385cd 100644 --- a/engines/grim/lua/lapi.cpp +++ b/engines/grim/lua/lapi.cpp @@ -4,6 +4,8 @@ ** See Copyright Notice in lua.h */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp #include "engines/grim/lua/lapi.h" #include "engines/grim/lua/lauxlib.h" diff --git a/engines/grim/lua/lbuffer.cpp b/engines/grim/lua/lbuffer.cpp index 064af0f9efe..c9e0f197443 100644 --- a/engines/grim/lua/lbuffer.cpp +++ b/engines/grim/lua/lbuffer.cpp @@ -4,6 +4,8 @@ ** See Copyright Notice in lua.h */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp #include "engines/grim/lua/lauxlib.h" #include "engines/grim/lua/lmem.h" diff --git a/engines/grim/lua/lbuiltin.cpp b/engines/grim/lua/lbuiltin.cpp index 07a75bf0833..2e16afd28ab 100644 --- a/engines/grim/lua/lbuiltin.cpp +++ b/engines/grim/lua/lbuiltin.cpp @@ -4,6 +4,9 @@ ** See Copyright Notice in lua.h */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_printf #include "engines/grim/lua/lapi.h" #include "engines/grim/lua/lauxlib.h" diff --git a/engines/grim/lua/ldo.cpp b/engines/grim/lua/ldo.cpp index 5ebc4e07108..d8c2a97d070 100644 --- a/engines/grim/lua/ldo.cpp +++ b/engines/grim/lua/ldo.cpp @@ -4,6 +4,13 @@ ** See Copyright Notice in lua.h */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf + +#ifdef _MSC_VER +#pragma warning(disable:4611) +#endif #include "engines/grim/lua/ldo.h" #include "engines/grim/lua/lfunc.h" diff --git a/engines/grim/lua/lfunc.cpp b/engines/grim/lua/lfunc.cpp index 570288dec0b..6b68e57b97a 100644 --- a/engines/grim/lua/lfunc.cpp +++ b/engines/grim/lua/lfunc.cpp @@ -4,7 +4,8 @@ ** See Copyright Notice in lua.h */ - +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp #include "engines/grim/lua/lfunc.h" #include "engines/grim/lua/lmem.h" diff --git a/engines/grim/lua/lgc.cpp b/engines/grim/lua/lgc.cpp index b18ea361f03..86a0a762702 100644 --- a/engines/grim/lua/lgc.cpp +++ b/engines/grim/lua/lgc.cpp @@ -4,6 +4,8 @@ ** See Copyright Notice in lua.h */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp #include "engines/grim/lua/ldo.h" #include "engines/grim/lua/lfunc.h" diff --git a/engines/grim/lua/liolib.cpp b/engines/grim/lua/liolib.cpp index 3e28e9c6ee3..b6df7e8b98a 100644 --- a/engines/grim/lua/liolib.cpp +++ b/engines/grim/lua/liolib.cpp @@ -4,6 +4,14 @@ ** See Copyright Notice in lua.h */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_time_h +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h +#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#define FORBIDDEN_SYMBOL_EXCEPTION_fread +#define FORBIDDEN_SYMBOL_EXCEPTION_fwrite +#define FORBIDDEN_SYMBOL_EXCEPTION_fseek #include "common/savefile.h" #include "common/fs.h" diff --git a/engines/grim/lua/llex.cpp b/engines/grim/lua/llex.cpp index b5ab07d69f2..8c1d1d5105e 100644 --- a/engines/grim/lua/llex.cpp +++ b/engines/grim/lua/llex.cpp @@ -4,6 +4,8 @@ ** See Copyright Notice in lua.h */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp #include "engines/grim/lua/lauxlib.h" #include "engines/grim/lua/llex.h" diff --git a/engines/grim/lua/lmem.cpp b/engines/grim/lua/lmem.cpp index 6c3c8f10214..197848e86cf 100644 --- a/engines/grim/lua/lmem.cpp +++ b/engines/grim/lua/lmem.cpp @@ -4,6 +4,8 @@ ** See Copyright Notice in lua.h */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp #include "engines/grim/lua/lmem.h" #include "engines/grim/lua/lstate.h" diff --git a/engines/grim/lua/lobject.cpp b/engines/grim/lua/lobject.cpp index aea0081a3dc..b14b87a9270 100644 --- a/engines/grim/lua/lobject.cpp +++ b/engines/grim/lua/lobject.cpp @@ -4,6 +4,9 @@ ** See Copyright Notice in lua.h */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp + #include "engines/grim/lua/lobject.h" #include "engines/grim/lua/lua.h" #include "engines/grim/lua/lstring.h" diff --git a/engines/grim/lua/lrestore.cpp b/engines/grim/lua/lrestore.cpp index ef57ce2682a..103d4b98c81 100644 --- a/engines/grim/lua/lrestore.cpp +++ b/engines/grim/lua/lrestore.cpp @@ -1,3 +1,6 @@ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp + #include "common/endian.h" #include "common/debug.h" diff --git a/engines/grim/lua/lsave.cpp b/engines/grim/lua/lsave.cpp index f8a00982ef9..1d52d938287 100644 --- a/engines/grim/lua/lsave.cpp +++ b/engines/grim/lua/lsave.cpp @@ -1,3 +1,6 @@ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp + #include "common/endian.h" #include "common/debug.h" diff --git a/engines/grim/lua/lstate.cpp b/engines/grim/lua/lstate.cpp index 5daa19dcf15..ebd2b894b48 100644 --- a/engines/grim/lua/lstate.cpp +++ b/engines/grim/lua/lstate.cpp @@ -4,6 +4,14 @@ ** See Copyright Notice in lua.h */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_stdin +#define FORBIDDEN_SYMBOL_EXCEPTION_stdout +#define FORBIDDEN_SYMBOL_EXCEPTION_stderror +#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_FILE + #include "common/endian.h" #include "engines/grim/actor.h" diff --git a/engines/grim/lua/lstring.cpp b/engines/grim/lua/lstring.cpp index dcba95242d5..96209efc70c 100644 --- a/engines/grim/lua/lstring.cpp +++ b/engines/grim/lua/lstring.cpp @@ -4,6 +4,9 @@ ** See Copyright Notice in lua.h */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp + #include "common/util.h" #include "engines/grim/lua/lmem.h" diff --git a/engines/grim/lua/lstx.cpp b/engines/grim/lua/lstx.cpp index db560c4653c..8835326c33a 100644 --- a/engines/grim/lua/lstx.cpp +++ b/engines/grim/lua/lstx.cpp @@ -10,6 +10,9 @@ by GNU Bison version 1.25 // generated by using command: bison -o lstx.c -p luaY_ -d lua.stx // removed platform depend not used code, formated code too +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp + #include "engines/grim/lua/lauxlib.h" #include "engines/grim/lua/ldo.h" #include "engines/grim/lua/lfunc.h" diff --git a/engines/grim/lua/ltable.cpp b/engines/grim/lua/ltable.cpp index 25ab390fa1b..9dbab41367d 100644 --- a/engines/grim/lua/ltable.cpp +++ b/engines/grim/lua/ltable.cpp @@ -4,6 +4,9 @@ ** See Copyright Notice in lua.h */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp + #include "engines/grim/lua/lauxlib.h" #include "engines/grim/lua/lmem.h" #include "engines/grim/lua/lobject.h" diff --git a/engines/grim/lua/ltask.cpp b/engines/grim/lua/ltask.cpp index 8d9ef59e244..2364937b629 100644 --- a/engines/grim/lua/ltask.cpp +++ b/engines/grim/lua/ltask.cpp @@ -1,3 +1,9 @@ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp + +#ifdef _MSC_VER +#pragma warning(disable:4611) +#endif #include "engines/grim/lua/ltask.h" #include "engines/grim/lua/lapi.h" diff --git a/engines/grim/lua/ltm.cpp b/engines/grim/lua/ltm.cpp index bd0ab67e1d7..4f76017125b 100644 --- a/engines/grim/lua/ltm.cpp +++ b/engines/grim/lua/ltm.cpp @@ -4,6 +4,9 @@ ** See Copyright Notice in lua.h */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf #include "engines/grim/lua/lauxlib.h" #include "engines/grim/lua/lmem.h" diff --git a/engines/grim/lua/lvm.cpp b/engines/grim/lua/lvm.cpp index 0bf1b889aa3..68671169c07 100644 --- a/engines/grim/lua/lvm.cpp +++ b/engines/grim/lua/lvm.cpp @@ -4,6 +4,8 @@ ** See Copyright Notice in lua.h */ +#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp +#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp #include "engines/grim/lua/lauxlib.h" #include "engines/grim/lua/ldo.h" diff --git a/engines/grim/lua_v1.cpp b/engines/grim/lua_v1.cpp index 16053760d38..71e15a25c3b 100644 --- a/engines/grim/lua_v1.cpp +++ b/engines/grim/lua_v1.cpp @@ -23,6 +23,8 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "common/endian.h" #include "common/system.h" diff --git a/engines/grim/lua_v1_text.cpp b/engines/grim/lua_v1_text.cpp index 2d6392acdc6..83536459215 100644 --- a/engines/grim/lua_v1_text.cpp +++ b/engines/grim/lua_v1_text.cpp @@ -23,6 +23,9 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_fgetc + #include "engines/grim/grim.h" #include "engines/grim/lua.h" #include "engines/grim/localize.h" diff --git a/engines/grim/scene.cpp b/engines/grim/scene.cpp index 2516cb098a2..21575f08741 100644 --- a/engines/grim/scene.cpp +++ b/engines/grim/scene.cpp @@ -23,6 +23,8 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "engines/grim/scene.h" #include "engines/grim/textsplit.h" #include "engines/grim/colormap.h" @@ -306,10 +308,10 @@ void Scene::Setup::load(TextSplitter &ts) { _bkgndBm = g_resourceloader->getBitmap(buf); if (!_bkgndBm) { if (gDebugLevel == DEBUG_BITMAPS || gDebugLevel == DEBUG_ERROR || gDebugLevel == DEBUG_ALL) - printf("Unable to load scene bitmap: %s\n", buf); + warning("Unable to load scene bitmap: %s\n", buf); } else { if (gDebugLevel == DEBUG_BITMAPS || gDebugLevel == DEBUG_NORMAL || gDebugLevel == DEBUG_ALL) - printf("Loaded scene bitmap: %s\n", buf); + warning("Loaded scene bitmap: %s\n", buf); } // ZBuffer is optional diff --git a/engines/grim/smush/smush.cpp b/engines/grim/smush/smush.cpp index 327947768dd..dfb6301842b 100644 --- a/engines/grim/smush/smush.cpp +++ b/engines/grim/smush/smush.cpp @@ -23,6 +23,8 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "common/endian.h" #include "common/timer.h" #include "common/file.h" @@ -193,12 +195,12 @@ void Smush::handleFrame() { // Lola engine room (loops a limited number of times?): // MakeAnim animation type 'Bl16' parameters: 6000;8000;90;1;0;0;0;0;2;0; if (gDebugLevel == DEBUG_SMUSH || gDebugLevel == DEBUG_NORMAL || gDebugLevel == DEBUG_ALL) - printf("Announcement data: %s\n", anno); + debug("Announcement data: %s\n", anno); // It looks like the announcement data is actually for setting some of the // header parameters, not for any looping purpose } else { if (gDebugLevel == DEBUG_SMUSH || gDebugLevel == DEBUG_NORMAL || gDebugLevel == DEBUG_ALL) - printf("Announcement header not understood: %s\n", anno); + debug("Announcement header not understood: %s\n", anno); } delete[] anno; tag = _file.readUint32BE(); diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp index 87ef2249385..e3ca0bf5886 100644 --- a/graphics/VectorRenderer.cpp +++ b/graphics/VectorRenderer.cpp @@ -23,15 +23,9 @@ * */ -#include "common/util.h" -#include "common/system.h" -#include "common/events.h" #include "common/textconsole.h" +#include "common/util.h" -#include "graphics/surface.h" -#include "graphics/colormasks.h" - -#include "gui/ThemeEngine.h" #include "graphics/VectorRenderer.h" #define VECTOR_RENDERER_FAST_TRIANGLES diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index 0a783a077de..9285fa21c50 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -26,16 +26,19 @@ #ifndef VECTOR_RENDERER_H #define VECTOR_RENDERER_H +#include "common/rect.h" #include "common/scummsys.h" -#include "common/system.h" +#include "common/str.h" #include "graphics/surface.h" -#include "graphics/pixelformat.h" #include "gui/ThemeEngine.h" +class OSystem; + namespace Graphics { class VectorRenderer; +struct DrawStep; typedef void (VectorRenderer::*DrawingFunctionCallback)(const Common::Rect &, const Graphics::DrawStep &); diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index 0ee13033af3..3eb8b1345f3 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -25,7 +25,6 @@ #include "common/util.h" #include "common/system.h" -#include "common/events.h" #include "common/frac.h" #include "graphics/surface.h" @@ -277,7 +276,7 @@ copyFrame(OSystem *sys, const Common::Rect &r) { sys->copyRectToOverlay( (const OverlayColor *)_activeSurface->getBasePtr(r.left, r.top), - _activeSurface->pitch / _activeSurface->bytesPerPixel, + _activeSurface->pitch / _activeSurface->format.bytesPerPixel, r.left, r.top, r.width(), r.height() ); } @@ -337,8 +336,8 @@ blitAlphaBitmap(const Graphics::Surface *source, const Common::Rect &r) { PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(x, y); const PixelType *src_ptr = (const PixelType *)source->getBasePtr(0, 0); - int dst_pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel; - int src_pitch = source->pitch / source->bytesPerPixel; + int dst_pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; + int src_pitch = source->pitch / source->format.bytesPerPixel; int w, h = source->h; @@ -485,7 +484,7 @@ drawLine(int x1, int y1, int x2, int y2) { return; PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x1, y1); - int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel; + int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; int st = Base::_strokeWidth >> 1; if (dy == 0) { // horizontal lines @@ -733,7 +732,7 @@ void VectorRendererSpec:: drawTabAlg(int x1, int y1, int w, int h, int r, PixelType color, VectorRenderer::FillMode fill_m, int baseLeft, int baseRight) { int f, ddF_x, ddF_y; int x, y, px, py; - int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel; + int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; int sw = 0, sp = 0, hp = 0; PixelType *ptr_tl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + r); @@ -831,7 +830,7 @@ drawTabAlg(int x1, int y1, int w, int h, int r, PixelType color, VectorRenderer: template void VectorRendererSpec:: drawBevelTabAlg(int x, int y, int w, int h, int bevel, PixelType top_color, PixelType bottom_color, int baseLeft, int baseRight) { - int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel; + int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; int i, j; PixelType *ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y); @@ -876,7 +875,7 @@ template void VectorRendererSpec:: drawSquareAlg(int x, int y, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) { PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x, y); - int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel; + int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; int max_h = h; if (fill_m != kFillDisabled) { @@ -908,7 +907,7 @@ drawSquareAlg(int x, int y, int w, int h, PixelType color, VectorRenderer::FillM template void VectorRendererSpec:: drawBevelSquareAlg(int x, int y, int w, int h, int bevel, PixelType top_color, PixelType bottom_color, bool fill) { - int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel; + int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; int height = h; PixelType *ptr_fill = (PixelType *)_activeSurface->getBasePtr(x, y); @@ -965,7 +964,7 @@ template void VectorRendererSpec:: drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color) { PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x1, y1); - int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel; + int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; int xdir = (x2 > x1) ? 1 : -1; *ptr = (PixelType)color; @@ -1013,7 +1012,7 @@ template void VectorRendererSpec:: drawTriangleVertAlg(int x1, int y1, int w, int h, bool inverted, PixelType color, VectorRenderer::FillMode fill_m) { int dx = w >> 1, dy = h, gradient_h = 0; - int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel; + int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; PixelType *ptr_right = 0, *ptr_left = 0; if (inverted) { @@ -1094,7 +1093,7 @@ drawTriangleVertAlg(int x1, int y1, int w, int h, bool inverted, PixelType color template void VectorRendererSpec:: drawTriangleFast(int x1, int y1, int size, bool inverted, PixelType color, VectorRenderer::FillMode fill_m) { - int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel; + int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; int hstep = 0, dy = size; bool grad = (fill_m == kFillGradient); @@ -1143,7 +1142,7 @@ void VectorRendererSpec:: drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) { int f, ddF_x, ddF_y; int x, y, px, py; - int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel; + int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; int sw = 0, sp = 0, hp = h * pitch; PixelType *ptr_tl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + r); @@ -1234,7 +1233,7 @@ void VectorRendererSpec:: drawCircleAlg(int x1, int y1, int r, PixelType color, VectorRenderer::FillMode fill_m) { int f, ddF_x, ddF_y; int x, y, px, py, sw = 0; - int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel; + int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1); if (fill_m == kFillDisabled) { @@ -1284,7 +1283,7 @@ template void VectorRendererSpec:: drawSquareShadow(int x, int y, int w, int h, int blur) { PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x + w - 1, y + blur); - int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel; + int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; int i, j; i = h - blur; @@ -1321,7 +1320,7 @@ void VectorRendererSpec:: drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int blur) { int f, ddF_x, ddF_y; int x, y, px, py; - int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel; + int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; int alpha = 102; x1 += blur; @@ -1368,7 +1367,7 @@ template void VectorRendererSpec:: drawRoundedSquareFakeBevel(int x1, int y1, int r, int w, int h, int amount) { int x, y; - const int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel; + const int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; int px, py; int sw = 0, sp = 0; @@ -1438,7 +1437,7 @@ void VectorRendererAA:: drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color) { PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1); - int pitch = Base::_activeSurface->pitch / Base::_activeSurface->bytesPerPixel; + int pitch = Base::_activeSurface->pitch / Base::_activeSurface->format.bytesPerPixel; int xdir = (x2 > x1) ? 1 : -1; uint16 error_tmp, error_acc, gradient; uint8 alpha; @@ -1489,7 +1488,7 @@ template void VectorRendererAA:: drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) { int x, y; - const int pitch = Base::_activeSurface->pitch / Base::_activeSurface->bytesPerPixel; + const int pitch = Base::_activeSurface->pitch / Base::_activeSurface->format.bytesPerPixel; int px, py; int sw = 0, sp = 0, hp = h * pitch; @@ -1566,7 +1565,7 @@ template void VectorRendererAA:: drawCircleAlg(int x1, int y1, int r, PixelType color, VectorRenderer::FillMode fill_m) { int x, y, sw = 0; - const int pitch = Base::_activeSurface->pitch / Base::_activeSurface->bytesPerPixel; + const int pitch = Base::_activeSurface->pitch / Base::_activeSurface->format.bytesPerPixel; int px, py; uint32 rsq = r*r; diff --git a/graphics/font.cpp b/graphics/font.cpp index 9d450e881c5..7fa39d07db8 100644 --- a/graphics/font.cpp +++ b/graphics/font.cpp @@ -78,7 +78,7 @@ void NewFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const assert(dst != 0); assert(desc.bits != 0 && desc.maxwidth <= 16); - assert(dst->bytesPerPixel == 1 || dst->bytesPerPixel == 2); + assert(dst->format.bytesPerPixel == 1 || dst->format.bytesPerPixel == 2); // If this character is not included in the font, use the default char. if (chr < desc.firstchar || chr >= desc.firstchar + desc.size) { @@ -110,9 +110,9 @@ void NewFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const tmp += bbh - y; y -= MAX(0, ty + desc.ascent - bby - dst->h); - if (dst->bytesPerPixel == 1) + if (dst->format.bytesPerPixel == 1) drawCharIntern(ptr, dst->pitch, tmp, y, MAX(0, -(tx + bbx)), MIN(bbw, dst->w - tx - bbx), color); - else if (dst->bytesPerPixel == 2) + else if (dst->format.bytesPerPixel == 2) drawCharIntern(ptr, dst->pitch, tmp, y, MAX(0, -(tx + bbx)), MIN(bbw, dst->w - tx - bbx), color); } diff --git a/graphics/fonts/scummfont.cpp b/graphics/fonts/scummfont.cpp index ea1935cea55..3331b72c477 100644 --- a/graphics/fonts/scummfont.cpp +++ b/graphics/fonts/scummfont.cpp @@ -303,9 +303,9 @@ void ScummFont::drawChar(Surface *dst, byte chr, int tx, int ty, uint32 color) c } c = ((buffer & mask) != 0); if (c) { - if (dst->bytesPerPixel == 1) + if (dst->format.bytesPerPixel == 1) ptr[x] = color; - else if (dst->bytesPerPixel == 2) + else if (dst->format.bytesPerPixel == 2) ((uint16 *)ptr)[x] = color; } } diff --git a/graphics/imagedec.cpp b/graphics/imagedec.cpp index 91da83cc634..f45f0ce5ef3 100644 --- a/graphics/imagedec.cpp +++ b/graphics/imagedec.cpp @@ -118,7 +118,7 @@ Surface *BMPDecoder::decodeImage(Common::SeekableReadStream &stream, const Pixel uint8 r = 0, g = 0, b = 0; Surface *newSurf = new Surface; assert(newSurf); - newSurf->create(info.width, info.height, sizeof(OverlayColor)); + newSurf->create(info.width, info.height, format); assert(newSurf->pixels); OverlayColor *curPixel = (OverlayColor*)newSurf->pixels + (newSurf->h-1) * newSurf->w; int pitchAdd = info.width % 4; diff --git a/graphics/surface.cpp b/graphics/surface.cpp index 7e9250029dd..88bdcfc8224 100644 --- a/graphics/surface.cpp +++ b/graphics/surface.cpp @@ -24,7 +24,7 @@ #include "common/algorithm.h" #include "common/util.h" -#include "common/endian.h" +#include "common/rect.h" #include "common/textconsole.h" #include "graphics/primitives.h" #include "graphics/surface.h" @@ -41,23 +41,23 @@ static void plotPoint(int x, int y, int color, void *data) { } void Surface::drawLine(int x0, int y0, int x1, int y1, uint32 color) { - if (bytesPerPixel == 1) + if (format.bytesPerPixel == 1) Graphics::drawLine(x0, y0, x1, y1, color, plotPoint, this); - else if (bytesPerPixel == 2) + else if (format.bytesPerPixel == 2) Graphics::drawLine(x0, y0, x1, y1, color, plotPoint, this); else error("Surface::drawLine: bytesPerPixel must be 1 or 2"); } -void Surface::create(uint16 width, uint16 height, uint8 bytesPP) { +void Surface::create(uint16 width, uint16 height, const PixelFormat &f) { free(); w = width; h = height; - bytesPerPixel = bytesPP; - pitch = w * bytesPP; + format = f; + pitch = w * format.bytesPerPixel; - pixels = calloc(width * height, bytesPP); + pixels = calloc(width * height, format.bytesPerPixel); assert(pixels); } @@ -65,11 +65,11 @@ void Surface::free() { ::free(pixels); pixels = 0; w = h = pitch = 0; - bytesPerPixel = 0; + format = PixelFormat(); } void Surface::copyFrom(const Surface &surf) { - create(surf.w, surf.h, surf.bytesPerPixel); + create(surf.w, surf.h, surf.format); memcpy(pixels, surf.pixels, h * pitch); } @@ -89,10 +89,10 @@ void Surface::hLine(int x, int y, int x2, uint32 color) { if (x2 < x) return; - if (bytesPerPixel == 1) { + if (format.bytesPerPixel == 1) { byte *ptr = (byte *)getBasePtr(x, y); memset(ptr, (byte)color, x2-x+1); - } else if (bytesPerPixel == 2) { + } else if (format.bytesPerPixel == 2) { uint16 *ptr = (uint16 *)getBasePtr(x, y); Common::set_to(ptr, ptr + (x2-x+1), (uint16)color); } else { @@ -113,13 +113,13 @@ void Surface::vLine(int x, int y, int y2, uint32 color) { if (y2 >= h) y2 = h - 1; - if (bytesPerPixel == 1) { + if (format.bytesPerPixel == 1) { byte *ptr = (byte *)getBasePtr(x, y); while (y++ <= y2) { *ptr = (byte)color; ptr += pitch; } - } else if (bytesPerPixel == 2) { + } else if (format.bytesPerPixel == 2) { uint16 *ptr = (uint16 *)getBasePtr(x, y); while (y++ <= y2) { *ptr = (uint16)color; @@ -141,13 +141,13 @@ void Surface::fillRect(Common::Rect r, uint32 color) { int height = r.height(); bool useMemset = true; - if (bytesPerPixel == 2) { + if (format.bytesPerPixel == 2) { lineLen *= 2; if ((uint16)color != ((color & 0xff) | (color & 0xff) << 8)) useMemset = false; - } else if (bytesPerPixel == 4) { + } else if (format.bytesPerPixel == 4) { useMemset = false; - } else if (bytesPerPixel != 1) { + } else if (format.bytesPerPixel != 1) { error("Surface::fillRect: bytesPerPixel must be 1, 2 or 4"); } @@ -158,7 +158,7 @@ void Surface::fillRect(Common::Rect r, uint32 color) { ptr += pitch; } } else { - if (bytesPerPixel == 2) { + if (format.bytesPerPixel == 2) { uint16 *ptr = (uint16 *)getBasePtr(r.left, r.top); while (height--) { Common::set_to(ptr, ptr + width, (uint16)color); @@ -186,7 +186,7 @@ void Surface::move(int dx, int dy, int height) { if ((dx == 0 && dy == 0) || height <= 0) return; - if (bytesPerPixel != 1 && bytesPerPixel != 2) + if (format.bytesPerPixel != 1 && format.bytesPerPixel != 2) error("Surface::move: bytesPerPixel must be 1 or 2"); byte *src, *dst; @@ -216,37 +216,37 @@ void Surface::move(int dx, int dy, int height) { // horizontal movement if (dx > 0) { // move right - copy from right to left - dst = (byte *)pixels + (pitch - bytesPerPixel); - src = dst - (dx * bytesPerPixel); + dst = (byte *)pixels + (pitch - format.bytesPerPixel); + src = dst - (dx * format.bytesPerPixel); for (y = 0; y < height; y++) { for (x = dx; x < w; x++) { - if (bytesPerPixel == 1) { + if (format.bytesPerPixel == 1) { *dst-- = *src--; - } else if (bytesPerPixel == 2) { + } else if (format.bytesPerPixel == 2) { *(uint16 *)dst = *(const uint16 *)src; src -= 2; dst -= 2; } } - src += pitch + (pitch - dx * bytesPerPixel); - dst += pitch + (pitch - dx * bytesPerPixel); + src += pitch + (pitch - dx * format.bytesPerPixel); + dst += pitch + (pitch - dx * format.bytesPerPixel); } } else if (dx < 0) { // move left - copy from left to right dst = (byte *)pixels; - src = dst - (dx * bytesPerPixel); + src = dst - (dx * format.bytesPerPixel); for (y = 0; y < height; y++) { for (x = -dx; x < w; x++) { - if (bytesPerPixel == 1) { + if (format.bytesPerPixel == 1) { *dst++ = *src++; - } else if (bytesPerPixel == 2) { + } else if (format.bytesPerPixel == 2) { *(uint16 *)dst = *(const uint16 *)src; src += 2; dst += 2; } } - src += pitch - (pitch + dx * bytesPerPixel); - dst += pitch - (pitch + dx * bytesPerPixel); + src += pitch - (pitch + dx * format.bytesPerPixel); + dst += pitch - (pitch + dx * format.bytesPerPixel); } } } diff --git a/graphics/surface.h b/graphics/surface.h index f9cb6cc4745..1b54690aa9b 100644 --- a/graphics/surface.h +++ b/graphics/surface.h @@ -26,7 +26,12 @@ #define GRAPHICS_SURFACE_H #include "common/scummsys.h" -#include "common/rect.h" + +namespace Common { +struct Rect; +} + +#include "graphics/pixelformat.h" namespace Graphics { @@ -65,14 +70,14 @@ struct Surface { void *pixels; /** - * How many bytes a single pixel occupies. + * The pixel format of the surface. */ - uint8 bytesPerPixel; + PixelFormat format; /** * Construct a simple Surface object. */ - Surface() : w(0), h(0), pitch(0), pixels(0), bytesPerPixel(0) { + Surface() : w(0), h(0), pitch(0), pixels(0), format() { } /** @@ -83,7 +88,7 @@ struct Surface { * @return Pointer to the pixel. */ inline const void *getBasePtr(int x, int y) const { - return (const byte *)(pixels) + y * pitch + x * bytesPerPixel; + return (const byte *)(pixels) + y * pitch + x * format.bytesPerPixel; } /** @@ -94,7 +99,7 @@ struct Surface { * @return Pointer to the pixel. */ inline void *getBasePtr(int x, int y) { - return static_cast(pixels) + y * pitch + x * bytesPerPixel; + return static_cast(pixels) + y * pitch + x * format.bytesPerPixel; } /** @@ -105,9 +110,9 @@ struct Surface { * * @param width Width of the surface object. * @param height Height of the surface object. - * @param bytePP The number of bytes a single pixel uses. + * @param format The pixel format the surface should use. */ - void create(uint16 width, uint16 height, uint8 bytesPP); + void create(uint16 width, uint16 height, const PixelFormat &format); /** * Release the memory used by the pixels memory of this surface. This is the diff --git a/graphics/thumbnail.cpp b/graphics/thumbnail.cpp index 0d3749dddde..c151d5fb49c 100644 --- a/graphics/thumbnail.cpp +++ b/graphics/thumbnail.cpp @@ -108,10 +108,10 @@ bool loadThumbnail(Common::SeekableReadStream &in, Graphics::Surface &to) { return false; } - to.create(header.width, header.height, sizeof(OverlayColor)); + Graphics::PixelFormat format = g_system->getOverlayFormat(); + to.create(header.width, header.height, format); OverlayColor *pixels = (OverlayColor *)to.pixels; - Graphics::PixelFormat format = g_system->getOverlayFormat(); for (int y = 0; y < to.h; ++y) { for (int x = 0; x < to.w; ++x) { uint8 r, g, b; @@ -140,18 +140,18 @@ bool saveThumbnail(Common::WriteStream &out) { } bool saveThumbnail(Common::WriteStream &out, const Graphics::Surface &thumb) { - if (thumb.bytesPerPixel != 2) { + if (thumb.format.bytesPerPixel != 2) { warning("trying to save thumbnail with bpp different than 2"); return false; } ThumbnailHeader header; header.type = MKTAG('T','H','M','B'); - header.size = ThumbnailHeaderSize + thumb.w*thumb.h*thumb.bytesPerPixel; + header.size = ThumbnailHeaderSize + thumb.w*thumb.h*thumb.format.bytesPerPixel; header.version = THMB_VERSION; header.width = thumb.w; header.height = thumb.h; - header.bpp = thumb.bytesPerPixel; + header.bpp = thumb.format.bytesPerPixel; out.writeUint32BE(header.type); out.writeUint32BE(header.size); diff --git a/graphics/tinygl/get.cpp b/graphics/tinygl/get.cpp index 0f404f79614..87490617e8b 100644 --- a/graphics/tinygl/get.cpp +++ b/graphics/tinygl/get.cpp @@ -1,3 +1,4 @@ +#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf #include "graphics/tinygl/zgl.h" diff --git a/graphics/tinygl/list.cpp b/graphics/tinygl/list.cpp index f7e5aca0051..1f30a3cae5d 100644 --- a/graphics/tinygl/list.cpp +++ b/graphics/tinygl/list.cpp @@ -1,3 +1,6 @@ +#define FORBIDDEN_SYMBOL_EXCEPTION_FILE +#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_fputc #include "graphics/tinygl/zgl.h" diff --git a/graphics/tinygl/matrix.cpp b/graphics/tinygl/matrix.cpp index 518575fe054..9d031f53933 100644 --- a/graphics/tinygl/matrix.cpp +++ b/graphics/tinygl/matrix.cpp @@ -1,3 +1,4 @@ +#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf #include "graphics/tinygl/zgl.h" diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 83a69387547..b1ff977d097 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -371,8 +371,8 @@ const char *ThemeEngine::findModeConfigName(GraphicsMode mode) { bool ThemeEngine::init() { // reset everything and reload the graphics _initOk = false; - setGraphicsMode(_graphicsMode); _overlayFormat = _system->getOverlayFormat(); + setGraphicsMode(_graphicsMode); if (_screen.pixels && _backBuffer.pixels) { _initOk = true; @@ -391,7 +391,7 @@ bool ThemeEngine::init() { Common::FSNode node(_themeFile); if (node.isDirectory()) { _themeArchive = new Common::FSDirectory(node); - } else if (_themeFile.hasSuffix(".zip")) { + } else if (_themeFile.matchString("*.zip", true)) { // TODO: Also use "node" directly? // Look for the zip file via SearchMan Common::ArchiveMemberPtr member = SearchMan.getMember(_themeFile); @@ -497,10 +497,10 @@ void ThemeEngine::setGraphicsMode(GraphicsMode mode) { uint32 height = _system->getOverlayHeight(); _backBuffer.free(); - _backBuffer.create(width, height, _bytesPerPixel); + _backBuffer.create(width, height, _overlayFormat); _screen.free(); - _screen.create(width, height, _bytesPerPixel); + _screen.create(width, height, _overlayFormat); delete _vectorRenderer; _vectorRenderer = Graphics::createRenderer(mode); @@ -1474,20 +1474,23 @@ Common::String ThemeEngine::genLocalizedFontFilename(const Common::String &filen #ifndef USE_TRANSLATION return filename; #else - Common::String result; - bool pointPassed = false; + // We will transform the font filename in the following way: + // name.bdf + // will become: + // name-charset.bdf + // Note that name should not contain any dot here! - for (const char *p = filename.c_str(); *p != 0; p++) { - if (!pointPassed && *p == '.') { - result += "-"; - result += TransMan.getCurrentCharset(); - result += *p; + // In the first step we look for the dot. In case there is none we will + // return the normal filename. + Common::String::const_iterator dot = Common::find(filename.begin(), filename.end(), '.'); + if (dot == filename.end()) + return filename; - pointPassed = true; - } else { - result += *p; - } - } + // Put the translated font filename string back together. + Common::String result(filename.begin(), dot); + result += '-'; + result += TransMan.getCurrentCharset(); + result += dot; return result; #endif @@ -1531,7 +1534,7 @@ bool ThemeEngine::themeConfigUsable(const Common::ArchiveMember &member, Common: Common::File stream; bool foundHeader = false; - if (member.getName().hasSuffix(".zip")) { + if (member.getName().matchString("*.zip", true)) { Common::Archive *zipArchive = Common::makeZipArchive(member.createReadStream()); if (zipArchive && zipArchive->hasFile("THEMERC")) { @@ -1553,7 +1556,7 @@ bool ThemeEngine::themeConfigUsable(const Common::FSNode &node, Common::String & Common::File stream; bool foundHeader = false; - if (node.getName().hasSuffix(".zip") && !node.isDirectory()) { + if (node.getName().matchString("*.zip", true) && !node.isDirectory()) { Common::Archive *zipArchive = Common::makeZipArchive(node); if (zipArchive && zipArchive->hasFile("THEMERC")) { // Open THEMERC from the ZIP file. @@ -1639,7 +1642,7 @@ void ThemeEngine::listUsableThemes(Common::Archive &archive, Common::ListgetPath().hasSuffix(".zip")) + if (!i->getPath().matchString("*.zip", true)) continue; td.name.clear(); @@ -1686,7 +1689,7 @@ void ThemeEngine::listUsableThemes(const Common::FSNode &node, Common::ListsetLabel(buf); - snprintf(buf, sizeof(buf), _("Discovered %d new games."), _games.size()); + snprintf(buf, sizeof(buf), _("Discovered %d new games, ignored %d previously added games."), _games.size(), _oldGamesCount); _gameProgressText->setLabel(buf); } else { snprintf(buf, sizeof(buf), _("Scanned %d directories ..."), _dirsScanned); _dirProgressText->setLabel(buf); - snprintf(buf, sizeof(buf), _("Discovered %d new games ..."), _games.size()); + snprintf(buf, sizeof(buf), _("Discovered %d new games, ignored %d previously added games ..."), _games.size(), _oldGamesCount); _gameProgressText->setLabel(buf); } diff --git a/gui/massadd.h b/gui/massadd.h index 3dbab43df18..6aad392b0d6 100644 --- a/gui/massadd.h +++ b/gui/massadd.h @@ -62,6 +62,7 @@ private: Common::HashMap _pathToTargets; int _dirsScanned; + int _oldGamesCount; Widget *_okButton; StaticTextWidget *_dirProgressText; diff --git a/gui/widget.cpp b/gui/widget.cpp index f0e91718eba..d3c8d3402db 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -347,7 +347,7 @@ void PicButtonWidget::setGfx(const Graphics::Surface *gfx) { void PicButtonWidget::drawWidget() { g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), "", _state, getFlags()); - if (sizeof(OverlayColor) == _gfx.bytesPerPixel && _gfx.pixels) { + if (sizeof(OverlayColor) == _gfx.format.bytesPerPixel && _gfx.pixels) { const int x = _x + (_w - _gfx.w) / 2; const int y = _y + (_h - _gfx.h) / 2; @@ -575,11 +575,12 @@ void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) { if (h == -1) h = _h; + Graphics::PixelFormat overlayFormat = g_system->getOverlayFormat(); + _gfx.free(); - _gfx.create(w, h, sizeof(OverlayColor)); + _gfx.create(w, h, overlayFormat); OverlayColor *dst = (OverlayColor *)_gfx.pixels; - Graphics::PixelFormat overlayFormat = g_system->getOverlayFormat(); OverlayColor fillCol = overlayFormat.RGBToColor(r, g, b); while (h--) { for (int i = 0; i < w; ++i) { @@ -589,7 +590,7 @@ void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) { } void GraphicsWidget::drawWidget() { - if (sizeof(OverlayColor) == _gfx.bytesPerPixel && _gfx.pixels) { + if (sizeof(OverlayColor) == _gfx.format.bytesPerPixel && _gfx.pixels) { const int x = _x + (_w - _gfx.w) / 2; const int y = _y + (_h - _gfx.h) / 2; diff --git a/ports.mk b/ports.mk index 2477779e2e8..e89dda86024 100644 --- a/ports.mk +++ b/ports.mk @@ -167,8 +167,8 @@ osxsnap: bundle # Windows specific # -residualico.o: $(srcdir)/icons/residual.ico - $(WINDRES) $(WINDRESFLAGS) -I$(srcdir) $(srcdir)/dists/residual.rc residualico.o +residualwinres.o: $(srcdir)/icons/residual.ico $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(srcdir)/dists/residual.rc + $(QUIET_WINDRES)$(WINDRES) -DHAVE_CONFIG_H $(WINDRESFLAGS) $(DEFINES) -I. -I$(srcdir) $(srcdir)/dists/residual.rc residualwinres.o # Special target to create a win32 snapshot binary win32dist: $(EXECUTABLE) @@ -186,7 +186,9 @@ endif cp $(srcdir)/README $(WIN32PATH)/README.txt cp /usr/local/README-SDL.txt $(WIN32PATH) cp /usr/local/bin/SDL.dll $(WIN32PATH) - u2d $(WIN32PATH)/*.txt + cp $(srcdir)/icons/residual.ico $(WIN32PATH) + cp $(srcdir)/dists/win32/residual.iss $(WIN32PATH) + unix2dos $(WIN32PATH)/*.txt # Special target to create a win32 snapshot binary under Debian Linux using cross mingw32 toolchain crosswin32dist: $(EXECUTABLE)