From 7329a5d164b866367ffa00be2eb55c429c7b367d Mon Sep 17 00:00:00 2001 From: Pawel Kolodziejski Date: Thu, 9 Jun 2011 11:17:15 +0200 Subject: [PATCH] ALL: sync with scummvm --- .gitignore | 13 +- COPYING | 17 +- COPYRIGHT | 3 +- audio/audiostream.cpp | 2 +- audio/decoders/flac.cpp | 2 +- audio/fmopl.h | 5 +- audio/mididrv.cpp | 207 ++- audio/mididrv.h | 4 + audio/musicplugin.h | 7 + audio/softsynth/adlib.cpp | 1 + audio/softsynth/mt32.cpp | 26 +- audio/softsynth/mt32/partial.cpp | 2 +- audio/softsynth/mt32/synth.cpp | 22 +- audio/softsynth/mt32/synth.h | 2 +- audio/softsynth/mt32/tables.cpp | 20 +- audio/softsynth/mt32/tables.h | 4 +- audio/softsynth/opl/mame.cpp | 16 +- audio/softsynth/opl/mame.h | 2 +- backends/audiocd/audiocd.h | 2 +- backends/events/sdl/sdl-events.cpp | 8 +- backends/fs/posix/posix-fs-factory.cpp | 3 +- backends/fs/posix/posix-fs.cpp | 6 +- backends/fs/windows/windows-fs.h | 1 + backends/graphics/sdl/sdl-graphics.h | 1 + backends/midi/alsa.cpp | 4 +- backends/mixer/sdl/sdl-mixer.cpp | 2 + backends/modular-backend.cpp | 48 +- backends/modular-backend.h | 23 +- backends/module.mk | 44 +- backends/platform/sdl/macosx/macosx.cpp | 27 +- backends/platform/sdl/macosx/macosx.h | 4 + backends/platform/sdl/main.cpp | 3 +- backends/platform/sdl/module.mk | 2 +- backends/platform/sdl/posix/posix-main.cpp | 2 +- backends/platform/sdl/posix/posix.cpp | 79 +- backends/platform/sdl/posix/posix.h | 21 +- backends/platform/sdl/sdl.cpp | 18 +- backends/platform/sdl/sdl.h | 11 +- backends/platform/sdl/win32/win32.cpp | 54 +- backends/platform/sdl/win32/win32.h | 15 + backends/plugins/posix/posix-provider.cpp | 6 +- backends/plugins/posix/posix-provider.h | 6 +- backends/plugins/win32/win32-provider.cpp | 21 +- backends/saves/posix/posix-saves.cpp | 35 +- backends/saves/posix/posix-saves.h | 3 +- backends/vkeybd/image-map.h | 3 +- backends/vkeybd/polygon.h | 3 +- backends/vkeybd/virtual-keyboard-gui.h | 3 +- backends/vkeybd/virtual-keyboard-parser.cpp | 15 +- backends/vkeybd/virtual-keyboard-parser.h | 3 +- backends/vkeybd/virtual-keyboard.h | 3 +- base/commandLine.cpp | 48 +- base/commandLine.h | 21 +- base/main.cpp | 3 +- base/plugins.h | 4 +- base/version.cpp | 4 + common/algorithm.h | 11 + common/error.cpp | 3 - common/error.h | 3 - common/events.h | 2 +- common/forbidden.h | 106 +- common/macresman.cpp | 5 +- common/savefile.h | 2 +- common/scummsys.h | 261 ++-- common/str.cpp | 87 +- common/str.h | 5 +- common/system.cpp | 98 +- common/system.h | 154 ++- common/textconsole.cpp | 2 + common/unzip.cpp | 10 +- common/util.cpp | 1 + common/util.h | 1 + common/xmlparser.cpp | 23 +- common/xmlparser.h | 2 +- configure | 1151 +++++++++-------- .../codeblocks/create_project.cbp | 2 + devtools/create_project/create_project.cpp | 44 +- devtools/create_project/module.mk | 8 +- devtools/create_project/msbuild.cpp | 1 + .../msvc10/create_project.vcxproj | 8 +- .../msvc10/create_project.vcxproj.filters | 6 + .../msvc8/create_project.vcproj | 8 + .../msvc9/create_project.vcproj | 8 + devtools/create_project/scripts/postbuild.cmd | 24 +- devtools/create_project/visualstudio.cpp | 1 + .../create_project.xcodeproj/project.pbxproj | 255 ++++ devtools/module.mk | 25 +- engines/advancedDetector.cpp | 41 +- engines/advancedDetector.h | 5 - engines/dialogs.cpp | 6 +- engines/engine.cpp | 2 +- engines/engine.h | 2 +- engines/grim/gfx_opengl.h | 1 + engines/grim/grim.cpp | 2 + engines/grim/lua/ldo.cpp | 2 + engines/grim/lua/liolib.cpp | 4 + engines/grim/lua/ltm.cpp | 1 + engines/grim/lua_v1_text.cpp | 2 + engines/savestate.cpp | 12 +- engines/savestate.h | 4 +- graphics/cursorman.h | 4 +- graphics/font.cpp | 100 +- graphics/font.h | 22 +- graphics/fontman.cpp | 100 +- graphics/fontman.h | 24 +- graphics/fonts/scummfont.cpp | 313 ----- graphics/surface.cpp | 48 +- graphics/tinygl/get.cpp | 1 + graphics/tinygl/list.cpp | 1 + graphics/tinygl/matrix.cpp | 1 + gui/ThemeEngine.cpp | 28 +- gui/ThemeEngine.h | 1 - gui/ThemeParser.cpp | 28 +- gui/console.h | 4 +- gui/debugger.cpp | 28 +- gui/debugger.h | 9 +- gui/gui-manager.cpp | 11 +- gui/launcher.cpp | 15 +- gui/massadd.cpp | 13 +- gui/options.cpp | 14 +- gui/saveload.cpp | 13 +- gui/widget.cpp | 4 +- gui/widgets/list.cpp | 11 +- po/POTFILES | 3 +- ports.mk | 6 +- rules.mk | 5 +- 126 files changed, 2443 insertions(+), 1679 deletions(-) create mode 100644 devtools/create_project/xcode/create_project.xcodeproj/project.pbxproj delete mode 100644 graphics/fonts/scummfont.cpp diff --git a/.gitignore b/.gitignore index 87f15c0cf4f..f117c76f933 100644 --- a/.gitignore +++ b/.gitignore @@ -23,12 +23,23 @@ lib*.a /.project /.cproject /.settings +/Icon.* /build /dists/codeblocks/*.cbp /dists/codeblocks/*.depend /dists/codeblocks/*.layout -/dists/codeblocks/scummvm* +/dists/codeblocks/residual* + +#Ignore XCode user data and build files +xcuserdata +project.xcworkspace +/dists/iphone/build +/dists/iphone/residual.xcodeproj +/dists/iphone/create_project +/dists/macosx/build +/dists/macosx/residual.xcodeproj +/dists/macosx/create_project /dists/msvc*/[Dd]ebug*/ /dists/msvc*/[Rr]elease*/ diff --git a/COPYING b/COPYING index b6f92f3dbfa..75a1ad8761e 100644 --- a/COPYING +++ b/COPYING @@ -1,8 +1,8 @@ GNU GENERAL PUBLIC LICENSE Version 2, June 1991 - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to +the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not @@ -303,10 +303,9 @@ the "copyright" line and a pointer to where the full notice is found. 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 - + 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. Also add information on how to contact you by electronic and paper mail. @@ -336,5 +335,5 @@ necessary. Here is a sample; alter the names: This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. \ No newline at end of file diff --git a/COPYRIGHT b/COPYRIGHT index 2b05821e25f..14b0ca42fd9 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -66,10 +66,10 @@ Travis Howell Janne Huttunen Felix Jakschitsch Jeroen Janssen -Willem Jan Palenstijn Florian Kagerer Filippos Karapetis Andreas Karlsson +Ismail Khatib Oliver Kiehl Martin Kiewitz Pawel Kolodziejski @@ -84,6 +84,7 @@ Gregory Montoir Kostas Nakos Mikesch Nepomuk Nicolas Noble +Willem Jan Palenstijn Lars Persson Joost Peters Tim Phillips diff --git a/audio/audiostream.cpp b/audio/audiostream.cpp index e6587a65432..c2fd17bf2ab 100644 --- a/audio/audiostream.cpp +++ b/audio/audiostream.cpp @@ -48,7 +48,7 @@ struct StreamFileFormat { }; static const StreamFileFormat STREAM_FILEFORMATS[] = { - /* decoderName, fileExt, openStreamFuntion */ + /* decoderName, fileExt, openStreamFunction */ #ifdef USE_FLAC { "FLAC", ".flac", makeFLACStream }, { "FLAC", ".fla", makeFLACStream }, diff --git a/audio/decoders/flac.cpp b/audio/decoders/flac.cpp index b818d4f7e94..d06a7b9c0e6 100644 --- a/audio/decoders/flac.cpp +++ b/audio/decoders/flac.cpp @@ -303,7 +303,7 @@ int FLACStream::readBuffer(int16 *buffer, const int numSamples) { const uint numChannels = getChannels(); if (numChannels == 0) { - warning("FLACStream: Stream not successfully initialised, cant playback"); + warning("FLACStream: Stream not successfully initialized, cant playback"); return -1; // streaminfo wasnt read! } diff --git a/audio/fmopl.h b/audio/fmopl.h index fbce36f077a..b88325a52ea 100644 --- a/audio/fmopl.h +++ b/audio/fmopl.h @@ -23,7 +23,10 @@ #define SOUND_FMOPL_H #include "common/scummsys.h" -#include "common/str.h" + +namespace Common { +class String; +} namespace OPL { diff --git a/audio/mididrv.cpp b/audio/mididrv.cpp index 7beb76352ca..80981eeccb2 100644 --- a/audio/mididrv.cpp +++ b/audio/mididrv.cpp @@ -25,7 +25,9 @@ #include "common/str.h" #include "common/system.h" #include "common/textconsole.h" +#include "common/translation.h" #include "common/util.h" +#include "gui/message.h" #include "audio/mididrv.h" #include "audio/musicplugin.h" @@ -110,6 +112,8 @@ Common::String MidiDriver::getDeviceString(DeviceHandle handle, DeviceStringType return d->getMusicDriverName(); else if (type == kDriverId) return d->getMusicDriverId(); + else if (type == kDeviceName) + return d->getCompleteName(); else if (type == kDeviceId) return d->getCompleteId(); else @@ -125,6 +129,7 @@ Common::String MidiDriver::getDeviceString(DeviceHandle handle, DeviceStringType MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { // Query the selected music device (defaults to MT_AUTO device). DeviceHandle hdl = getDeviceHandle(ConfMan.get("music_driver")); + DeviceHandle reslt = 0; _forceTypeMT32 = false; @@ -133,148 +138,234 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { switch (getMusicType(hdl)) { case MT_PCSPK: if (flags & MDT_PCSPK) - return hdl; + reslt = hdl; break; case MT_PCJR: if (flags & MDT_PCJR) - return hdl; + reslt = hdl; break; case MT_CMS: if (flags & MDT_CMS) - return hdl; + reslt = hdl; break; case MT_ADLIB: if (flags & MDT_ADLIB) - return hdl; + reslt = hdl; break; case MT_C64: if (flags & MDT_C64) - return hdl; + reslt = hdl; break; case MT_AMIGA: if (flags & MDT_AMIGA) - return hdl; + reslt = hdl; break; case MT_APPLEIIGS: if (flags & MDT_APPLEIIGS) - return hdl; + reslt = hdl; break; case MT_TOWNS: if (flags & MDT_TOWNS) - return hdl; + reslt = hdl; break; case MT_PC98: if (flags & MDT_PC98) - return hdl; + reslt = hdl; break; case MT_GM: case MT_GS: case MT_MT32: if (flags & MDT_MIDI) - return hdl; + reslt = hdl; break; case MT_NULL: - return hdl; + reslt = hdl; + break; default: break; } + Common::String failedDevStr; + if (getMusicType(hdl) == MT_INVALID) { + // If the expressly selected driver or device cannot be found (no longer compiled in, turned off, etc.) + // we display a warning and continue. + failedDevStr = ConfMan.get("music_driver"); + Common::String warningMsg = Common::String::format(_("The selected audio device '%s' was not found (e.g. might be turned off or disconnected). Attempting to fall back to the next available device..."), failedDevStr.c_str()); + GUI::MessageDialog dialog(warningMsg); + dialog.runModal(); + } + + MusicType tp = getMusicType(reslt); + if (tp != MT_INVALID && tp != MT_AUTO) { + if (checkDevice(reslt)) { + return reslt; + } else { + // If the expressly selected device cannot be used we display a warning and continue. + failedDevStr = getDeviceString(hdl, MidiDriver::kDeviceName); + Common::String warningMsg = Common::String::format(_("The selected audio device '%s' cannot be used. See log file for more information. Attempting to fall back to the next available device..."), failedDevStr.c_str()); + GUI::MessageDialog dialog(warningMsg); + dialog.runModal(); + } + } + + reslt = 0; + // If the selected driver did not match the flags setting, // we try to determine a suitable and "optimal" music driver. const MusicPlugin::List p = MusicMan.getPlugins(); // If only MDT_MIDI but not MDT_PREFER_MT32 or MDT_PREFER_GM is set we prefer the other devices (which will always be - // detected since they are hard coded and cannot be disabled. - for (int l = (flags & (MDT_PREFER_GM | MDT_PREFER_MT32)) ? 1 : 0; l < 2; ++l) { - if ((flags & MDT_MIDI) && (l == 1)) { - // If a preferred MT32 or GM device has been selected that device gets returned - if (flags & MDT_PREFER_MT32) - hdl = getDeviceHandle(ConfMan.get("mt32_device")); + // detected since they are hard coded and cannot be disabled). + bool skipMidi = !(flags & (MDT_PREFER_GM | MDT_PREFER_MT32)); + while (flags != MDT_NONE) { + if ((flags & MDT_MIDI) && !skipMidi) { + // If a preferred MT32 or GM device has been selected that device gets returned if available. + Common::String devStr; + if (flags & MDT_PREFER_MT32) + devStr = ConfMan.get("mt32_device"); else if (flags & MDT_PREFER_GM) - hdl = getDeviceHandle(ConfMan.get("gm_device")); + devStr = ConfMan.get("gm_device"); else - hdl = getDeviceHandle("auto"); + devStr = "auto"; + hdl = getDeviceHandle(devStr); const MusicType type = getMusicType(hdl); - // If have a "Don't use GM/MT-32" setting we skip this part and jump + // If we have a "Don't use GM/MT-32" setting we skip this part and jump // to AdLib, PC Speaker etc. detection right away. if (type != MT_NULL) { - if (type != MT_AUTO && type != MT_INVALID) { - if (flags & MDT_PREFER_MT32) - // If we have a preferred MT32 device we disable the gm/mt32 mapping (more about this in mididrv.h) - _forceTypeMT32 = true; - - return hdl; + if (type == MT_INVALID) { + // If the preferred (expressly requested) selected driver or device cannot be found (no longer compiled in, turned off, etc.) + // we display a warning and continue. Don't warn about the missing device if we did already (this becomes relevant if the + // missing device is selected as preferred device and also as GM or MT-32 device). + if (failedDevStr != devStr) { + Common::String warningMsg = Common::String::format(_("The preferred audio device '%s' was not found (e.g. might be turned off or disconnected). Attempting to fall back to the next available device..."), devStr.c_str()); + GUI::MessageDialog dialog(warningMsg); + dialog.runModal(); + } + } else if (type != MT_AUTO) { + if (checkDevice(hdl)) { + if (flags & MDT_PREFER_MT32) + // If we have a preferred MT32 device we disable the gm/mt32 mapping (more about this in mididrv.h). + _forceTypeMT32 = true; + return hdl; + } else { + // If the preferred (expressly requested) device cannot be used we display a warning and continue. + // Don't warn about the failing device if we did already (this becomes relevant if the failing + // device is selected as preferred device and also as GM or MT-32 device). + if (failedDevStr != getDeviceString(hdl, MidiDriver::kDeviceName)) { + Common::String warningMsg = Common::String::format(_("The preferred audio device '%s' cannot be used. See log file for more information. Attempting to fall back to the next available device..."), getDeviceString(hdl, MidiDriver::kDeviceName).c_str()); + GUI::MessageDialog dialog(warningMsg); + dialog.runModal(); + } + hdl = 0; + } } - // If we have no specific device selected (neither in the scummvm nor in the game domain) - // and no preferred MT32 or GM device selected we arrive here. - // If MT32 is preferred we try for the first available device with music type 'MT_MT32' (usually the mt32 emulator) + // If no specific device is selected (neither in the scummvm nor in the game domain) + // and there is no preferred MT32 or GM device selected either or if the detected device is unavailable we arrive here. + // If MT32 is preferred we try for the first available device with music type 'MT_MT32' (usually the mt32 emulator). if (flags & MDT_PREFER_MT32) { for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); ++m) { MusicDevices i = (**m)->getDevices(); for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) { - if (d->getMusicType() == MT_MT32) - return d->getHandle(); + if (d->getMusicType() == MT_MT32) { + hdl = d->getHandle(); + if (checkDevice(hdl)) + return hdl; + else + // No warning here, since the user hasn't expressly requested anything. + hdl = 0; + } } } } - // Now we default to the first available device with music type 'MT_GM' - for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); ++m) { - MusicDevices i = (**m)->getDevices(); - for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) { - if (d->getMusicType() == MT_GM || d->getMusicType() == MT_GS) - return d->getHandle(); + // Now we default to the first available device with music type 'MT_GM' if not + // MT-32 is preferred or if MT-32 is preferred but all other devices have failed. + if (!(flags & MDT_PREFER_MT32) || flags == (MDT_PREFER_MT32 | MDT_MIDI)) { + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); ++m) { + MusicDevices i = (**m)->getDevices(); + for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) { + if (d->getMusicType() == MT_GM || d->getMusicType() == MT_GS) { + hdl = d->getHandle(); + if (checkDevice(hdl)) + return hdl; + else + // No warning here, since the user hasn't expressly requested anything. + hdl = 0; + } + } } + // Detection flags get removed after final detection attempt to avoid further attempts. + flags &= ~(MDT_MIDI | MDT_PREFER_GM | MDT_PREFER_MT32); } } } - MusicType tp = MT_AUTO; - if (flags & MDT_TOWNS) + // The order in this list is important, since this is the order of preference + // (e.g. MT_ADLIB is checked before MT_PCJR and MT_PCSPK for a good reason). + // Detection flags get removed after detection attempt to avoid further attempts. + if (flags & MDT_TOWNS) { tp = MT_TOWNS; - else if (flags & MDT_PC98) + flags &= ~MDT_TOWNS; + } else if (flags & MDT_PC98) { tp = MT_PC98; - else if (flags & MDT_ADLIB) + flags &= ~MDT_PC98; + } else if (flags & MDT_ADLIB) { tp = MT_ADLIB; - else if (flags & MDT_PCJR) + flags &= ~MDT_ADLIB; + } else if (flags & MDT_PCJR) { tp = MT_PCJR; - else if (flags & MDT_PCSPK) + flags &= ~MDT_PCJR; + } else if (flags & MDT_PCSPK) { tp = MT_PCSPK; - else if (flags & MDT_C64) + flags &= ~MDT_PCSPK; + } else if (flags & MDT_C64) { tp = MT_C64; - else if (flags & MDT_AMIGA) + flags &= ~MDT_C64; + } else if (flags & MDT_AMIGA) { tp = MT_AMIGA; - else if (flags & MDT_APPLEIIGS) + flags &= ~MDT_AMIGA; + } else if (flags & MDT_APPLEIIGS) { tp = MT_APPLEIIGS; - else if (l == 0) - // if we haven't tried to find a MIDI device yet we do this now. + flags &= ~MDT_APPLEIIGS; + } else if (flags & MDT_MIDI) { + // If we haven't tried to find a MIDI device yet we do this now. + skipMidi = false; continue; - else + } else if (flags) { + // Invalid flags. Set them to MDT_NONE to leave detection loop. + flags = MDT_NONE; tp = MT_AUTO; + } for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); ++m) { MusicDevices i = (**m)->getDevices(); for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) { - if (d->getMusicType() == tp) - return d->getHandle(); + if (d->getMusicType() == tp) { + hdl = d->getHandle(); + if (checkDevice(hdl)) + return hdl; + else + // No warning here, since the user hasn't expressly requested anything. + hdl = 0; + } } } } - return 0; + return reslt; } MidiDriver *MidiDriver::createMidi(MidiDriver::DeviceHandle handle) { @@ -288,11 +379,21 @@ MidiDriver *MidiDriver::createMidi(MidiDriver::DeviceHandle handle) { return driver; } +bool MidiDriver::checkDevice(MidiDriver::DeviceHandle handle) { + const MusicPlugin::List p = MusicMan.getPlugins(); + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { + if (getDeviceString(handle, MidiDriver::kDriverId).equals((**m)->getId())) + return (**m)->checkDevice(handle); + } + + return false; +} + MidiDriver::DeviceHandle MidiDriver::getDeviceHandle(const Common::String &identifier) { const MusicPlugin::List p = MusicMan.getPlugins(); if (p.begin() == p.end()) - error("Music plugins must be loaded prior to calling this method"); + error("MidiDriver::getDeviceHandle: Music plugins must be loaded prior to calling this method"); for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { MusicDevices i = (**m)->getDevices(); diff --git a/audio/mididrv.h b/audio/mididrv.h index 7369cab26b4..e3f6461be9f 100644 --- a/audio/mididrv.h +++ b/audio/mididrv.h @@ -142,6 +142,7 @@ public: enum DeviceStringType { kDriverName, kDriverId, + kDeviceName, kDeviceId }; @@ -156,6 +157,9 @@ public: /** Find the music driver matching the given driver name/description. */ static DeviceHandle getDeviceHandle(const Common::String &identifier); + /** Check whether the device with the given handle is available. */ + static bool checkDevice(DeviceHandle handle); + /** Get the music type matching the given device handle, or MT_AUTO if there is no match. */ static MusicType getMusicType(DeviceHandle handle); diff --git a/audio/musicplugin.h b/audio/musicplugin.h index 2a25962b87a..307293a7c9f 100644 --- a/audio/musicplugin.h +++ b/audio/musicplugin.h @@ -89,6 +89,13 @@ public: */ virtual MusicDevices getDevices() const = 0; + /** + * Checks whether a device can actually be used. Currently this is only + * implemented for the MT-32 emulator to check whether the required rom + * files are present. + */ + virtual bool checkDevice(MidiDriver::DeviceHandle) const { return true; } + /** * Tries to instantiate a MIDI Driver instance based on the device * previously detected via MidiDriver::detectDevice() diff --git a/audio/softsynth/adlib.cpp b/audio/softsynth/adlib.cpp index 60de8fad609..4025a667acd 100644 --- a/audio/softsynth/adlib.cpp +++ b/audio/softsynth/adlib.cpp @@ -857,6 +857,7 @@ void AdLibPercussionChannel::sysEx_customInstrument(uint32 type, const byte *ins // Allocate memory for the new instruments if (!_customInstruments[note]) { _customInstruments[note] = new AdLibInstrument; + memset(_customInstruments[note], 0, sizeof(AdLibInstrument)); } // Save the new instrument data diff --git a/audio/softsynth/mt32.cpp b/audio/softsynth/mt32.cpp index 7a91bce62a6..5f278c4029a 100644 --- a/audio/softsynth/mt32.cpp +++ b/audio/softsynth/mt32.cpp @@ -20,6 +20,7 @@ */ #include "common/scummsys.h" +#include "common/system.h" #ifdef USE_MT32EMU @@ -62,7 +63,7 @@ protected: void generateSamples(int16 *buf, int len); public: - bool _initialising; + bool _initializing; MidiDriver_MT32(Audio::Mixer *mixer); virtual ~MidiDriver_MT32(); @@ -218,7 +219,7 @@ static MT32Emu::File *MT32_OpenFile(void *userData, const char *filename, MT32Em } static void MT32_PrintDebug(void *userData, const char *fmt, va_list list) { - if (((MidiDriver_MT32 *)userData)->_initialising) { + if (((MidiDriver_MT32 *)userData)->_initializing) { char buf[512]; vsnprintf(buf, 512, fmt, list); @@ -242,7 +243,7 @@ static int MT32_Report(void *userData, MT32Emu::ReportType type, const void *rep error("Failed to load MT32_PCM.ROM"); break; case MT32Emu::ReportType_progressInit: - if (((MidiDriver_MT32 *)userData)->_initialising) { + if (((MidiDriver_MT32 *)userData)->_initializing) { drawProgress(*((const float *)reportData)); return eatSystemEvents(); } @@ -286,7 +287,7 @@ MidiDriver_MT32::MidiDriver_MT32(Audio::Mixer *mixer) : MidiDriver_Emulated(mixe // at rates other than 32KHz, thus we produce data at 32KHz and // rely on Mixer to convert. _outputRate = 32000; //_mixer->getOutputRate(); - _initialising = false; + _initializing = false; } MidiDriver_MT32::~MidiDriver_MT32() { @@ -329,11 +330,11 @@ int MidiDriver_MT32::open() { //g_system->setPalette(dummy_palette, 0, 3); } - _initialising = true; - drawMessage(-1, _s("Initialising MT-32 Emulator")); + _initializing = true; + drawMessage(-1, _s("Initializing MT-32 Emulator")); if (!_synth->open(prop)) return MERR_DEVICE_NOT_AVAILABLE; - _initialising = false; + _initializing = false; // TODO implement in Residual /* if (screenFormat.bytesPerPixel > 1) @@ -553,6 +554,7 @@ public: } MusicDevices getDevices() const; + bool checkDevice(MidiDriver::DeviceHandle) const; Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const; }; @@ -562,6 +564,16 @@ MusicDevices MT32EmuMusicPlugin::getDevices() const { return devices; } +bool MT32EmuMusicPlugin::checkDevice(MidiDriver::DeviceHandle) const { + if (!((Common::File::exists("MT32_CONTROL.ROM") && Common::File::exists("MT32_PCM.ROM")) || + (Common::File::exists("CM32L_CONTROL.ROM") && Common::File::exists("CM32L_PCM.ROM")))) { + warning("The MT-32 emulator requires one of the two following file sets (not bundled with ScummVM):\n Either 'MT32_CONTROL.ROM' and 'MT32_PCM.ROM' or 'CM32L_CONTROL.ROM' and 'CM32L_PCM.ROM'"); + return false; + } + + return true; +} + Common::Error MT32EmuMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const { if (ConfMan.hasKey("extrapath")) SearchMan.addDirectory("extrapath", ConfMan.get("extrapath")); diff --git a/audio/softsynth/mt32/partial.cpp b/audio/softsynth/mt32/partial.cpp index d06634dc916..c4f2e94ebe3 100644 --- a/audio/softsynth/mt32/partial.cpp +++ b/audio/softsynth/mt32/partial.cpp @@ -164,7 +164,7 @@ void Partial::startPartial(dpoly *usePoly, const PatchCache *useCache, Partial * structurePosition = patchCache->structurePosition; play = true; - initKeyFollow(poly->freqnum); // Initialises noteVal, filtVal and realVal + initKeyFollow(poly->freqnum); // Initializes noteVal, filtVal and realVal #if MT32EMU_ACCURATENOTES == 0 noteLookup = &synth->tables.noteLookups[noteVal - LOWEST_NOTE]; #else diff --git a/audio/softsynth/mt32/synth.cpp b/audio/softsynth/mt32/synth.cpp index 5e74b262aee..322b864b6ee 100644 --- a/audio/softsynth/mt32/synth.cpp +++ b/audio/softsynth/mt32/synth.cpp @@ -426,36 +426,36 @@ bool Synth::open(SynthProperties &useProp) { } } - printDebug("Initialising Timbre Bank A"); + printDebug("Initializing Timbre Bank A"); if (!initTimbres(controlROMMap->timbreAMap, controlROMMap->timbreAOffset, 0)) { return false; } - printDebug("Initialising Timbre Bank B"); + printDebug("Initializing Timbre Bank B"); if (!initTimbres(controlROMMap->timbreBMap, controlROMMap->timbreBOffset, 64)) { return false; } - printDebug("Initialising Timbre Bank R"); + printDebug("Initializing Timbre Bank R"); if (!initRhythmTimbres(controlROMMap->timbreRMap, controlROMMap->timbreRCount)) { return false; } - printDebug("Initialising Timbre Bank M"); - // CM-64 seems to initialise all bytes in this bank to 0. + printDebug("Initializing Timbre Bank M"); + // CM-64 seems to initialize all bytes in this bank to 0. memset(&mt32ram.timbres[128], 0, sizeof (mt32ram.timbres[128]) * 64); partialManager = new PartialManager(this); pcmWaves = new PCMWaveEntry[controlROMMap->pcmCount]; - printDebug("Initialising PCM List"); + printDebug("Initializing PCM List"); initPCMList(controlROMMap->pcmTable, controlROMMap->pcmCount); - printDebug("Initialising Rhythm Temp"); + printDebug("Initializing Rhythm Temp"); memcpy(mt32ram.rhythmSettings, &controlROMData[controlROMMap->rhythmSettings], controlROMMap->rhythmSettingsCount * 4); - printDebug("Initialising Patches"); + printDebug("Initializing Patches"); for (Bit8u i = 0; i < 128; i++) { PatchParam *patch = &mt32ram.patches[i]; patch->timbreGroup = i / 64; @@ -468,9 +468,9 @@ bool Synth::open(SynthProperties &useProp) { patch->dummy = 0; } - printDebug("Initialising System"); + printDebug("Initializing System"); // The MT-32 manual claims that "Standard pitch" is 442Hz. - mt32ram.system.masterTune = 0x40; // Confirmed on CM-64 as 0x4A, but SCUMM games use 0x40 and we don't want to initialise twice + mt32ram.system.masterTune = 0x40; // Confirmed on CM-64 as 0x4A, but SCUMM games use 0x40 and we don't want to initialize twice mt32ram.system.reverbMode = 0; // Confirmed mt32ram.system.reverbTime = 5; // Confirmed mt32ram.system.reverbLevel = 3; // Confirmed @@ -792,7 +792,7 @@ void Synth::writeSysex(unsigned char device, const Bit8u *sysex, Bit32u len) { for (;;) { // Find the appropriate memory region int regionNum; - const MemoryRegion *region = NULL; // Initialised to please compiler + const MemoryRegion *region = NULL; // Initialized to please compiler for (regionNum = 0; regionNum < NUM_REGIONS; regionNum++) { region = &memoryRegions[regionNum]; if (region->contains(addr)) { diff --git a/audio/softsynth/mt32/synth.h b/audio/softsynth/mt32/synth.h index edda4462879..0ef2c9d135d 100644 --- a/audio/softsynth/mt32/synth.h +++ b/audio/softsynth/mt32/synth.h @@ -263,7 +263,7 @@ public: Synth(); ~Synth(); - // Used to initialise the MT-32. Must be called before any other function. + // Used to initialize the MT-32. Must be called before any other function. // Returns true if initialization was sucessful, otherwise returns false. bool open(SynthProperties &useProp); diff --git a/audio/softsynth/mt32/tables.cpp b/audio/softsynth/mt32/tables.cpp index 25ee0436dbb..9fdb595467c 100644 --- a/audio/softsynth/mt32/tables.cpp +++ b/audio/softsynth/mt32/tables.cpp @@ -203,7 +203,7 @@ void Tables::initEnvelopes(float samplerate) { void Tables::initMT32ConstantTables(Synth *synth) { int lf; - synth->printDebug("Initialising Pitch Tables"); + synth->printDebug("Initializing Pitch Tables"); for (lf = -108; lf <= 108; lf++) { tvfKeyfollowMult[lf + 108] = (int)(256 * powf(2.0f, (float)(lf / 24.0f))); //synth->printDebug("KT %d = %d", f, keytable[f+108]); @@ -668,7 +668,7 @@ bool Tables::initNotes(Synth *synth, PCMWaveEntry *pcmWaves, float rate, float m bool abort = false; synth->report(ReportType_progressInit, &progress); for (int f = LOWEST_NOTE; f <= HIGHEST_NOTE; f++) { - synth->printDebug("Initialising note %s%d", NoteNames[f % 12], (f / 12) - 2); + synth->printDebug("Initializing note %s%d", NoteNames[f % 12], (f / 12) - 2); NoteLookup *noteLookup = ¬eLookups[f - LOWEST_NOTE]; file = initNote(synth, noteLookup, (float)f, rate, masterTune, pcmWaves, file); progress = (f - LOWEST_NOTE + 1) / (float)NUM_NOTES; @@ -723,12 +723,12 @@ void Tables::freeNotes() { } } } - initialisedMasterTune = 0.0f; + initializedMasterTune = 0.0f; } Tables::Tables() { - initialisedSampleRate = 0.0f; - initialisedMasterTune = 0.0f; + initializedSampleRate = 0.0f; + initializedMasterTune = 0.0f; memset(¬eLookups, 0, sizeof(noteLookups)); } @@ -737,23 +737,23 @@ bool Tables::init(Synth *synth, PCMWaveEntry *pcmWaves, float sampleRate, float synth->printDebug("Bad sampleRate (%f <= 0.0f)", (double)sampleRate); return false; } - if (initialisedSampleRate == 0.0f) { + if (initializedSampleRate == 0.0f) { initMT32ConstantTables(synth); } - if (initialisedSampleRate != sampleRate) { + if (initializedSampleRate != sampleRate) { initFiltCoeff(sampleRate); initEnvelopes(sampleRate); for (int key = 12; key <= 108; key++) { initDep(&keyLookups[key - 12], (float)key); } } - if (initialisedSampleRate != sampleRate || initialisedMasterTune != masterTune) { + if (initializedSampleRate != sampleRate || initializedMasterTune != masterTune) { freeNotes(); if (!initNotes(synth, pcmWaves, sampleRate, masterTune)) { return false; } - initialisedSampleRate = sampleRate; - initialisedMasterTune = masterTune; + initializedSampleRate = sampleRate; + initializedMasterTune = masterTune; } return true; } diff --git a/audio/softsynth/mt32/tables.h b/audio/softsynth/mt32/tables.h index d9af5114b24..9950323e7be 100644 --- a/audio/softsynth/mt32/tables.h +++ b/audio/softsynth/mt32/tables.h @@ -69,8 +69,8 @@ struct KeyLookup { }; class Tables { - float initialisedSampleRate; - float initialisedMasterTune; + float initializedSampleRate; + float initializedMasterTune; void initMT32ConstantTables(Synth *synth); static Bit16s clampWF(Synth *synth, const char *n, float ampVal, double input); static File *initWave(Synth *synth, NoteLookup *noteLookup, float ampsize, float div2, File *file); diff --git a/audio/softsynth/opl/mame.cpp b/audio/softsynth/opl/mame.cpp index b380a153450..74699ba4c63 100644 --- a/audio/softsynth/opl/mame.cpp +++ b/audio/softsynth/opl/mame.cpp @@ -546,7 +546,7 @@ inline void OPL_CALC_RH(FM_OPL *OPL, OPL_CH *CH) { // but EG_STEP = 96.0/EG_ENT, and WHITE_NOISE_db=6.0. So, that's equivalent to // int(OPL->rnd.getRandomBit() * EG_ENT/16). We know that EG_ENT is 4096, or 1024, // or 128, so we can safely avoid any FP ops. - int whitenoise = OPL->rnd.getRandomBit() * (EG_ENT>>4); + int whitenoise = OPL->rnd->getRandomBit() * (EG_ENT>>4); int tone8; @@ -754,8 +754,10 @@ static int OPLOpenTable(void) { } static void OPLCloseTable(void) { +#ifndef __DS__ free(TL_TABLE); free(SIN_TABLE); +#endif free(AMS_TABLE); free(VIB_TABLE); free(ENV_CURVE); @@ -1126,6 +1128,15 @@ FM_OPL *OPLCreate(int type, int clock, int rate) { OPL->rate = rate; OPL->max_ch = max_ch; + // Init the random source. Note: We use a fixed name for it here. + // So if multiple FM_OPL objects exist in parallel, then their + // random sources will have an equal name. At least in the + // current EventRecorder implementation, this causes no problems; + // but this is probably not guaranteed. + // Alas, it does not seem worthwhile to bother much with this + // at the time, so I am leaving it as it is. + OPL->rnd = new Common::RandomSource("mame"); + /* init grobal tables */ OPL_initalize(OPL); @@ -1134,9 +1145,10 @@ FM_OPL *OPLCreate(int type, int clock, int rate) { return OPL; } -/* ---------- Destroy one of vietual YM3812 ---------- */ +/* ---------- Destroy one of virtual YM3812 ---------- */ void OPLDestroy(FM_OPL *OPL) { OPL_UnLockTable(); + delete OPL->rnd; free(OPL); } diff --git a/audio/softsynth/opl/mame.h b/audio/softsynth/opl/mame.h index 4c409494832..803ca897e7b 100644 --- a/audio/softsynth/opl/mame.h +++ b/audio/softsynth/opl/mame.h @@ -147,7 +147,7 @@ typedef struct fm_opl_f { OPL_UPDATEHANDLER UpdateHandler; /* stream update handler */ int UpdateParam; /* stream update parameter */ - Common::RandomSource rnd; + Common::RandomSource *rnd; } FM_OPL; /* ---------- Generic interface section ---------- */ diff --git a/backends/audiocd/audiocd.h b/backends/audiocd/audiocd.h index a4aeb41e741..92b7598cb5d 100644 --- a/backends/audiocd/audiocd.h +++ b/backends/audiocd/audiocd.h @@ -108,7 +108,7 @@ public: //@{ /** - * Initialise the specified CD drive for audio playback. + * Initialize the specified CD drive for audio playback. * @param drive the drive id * @return true if the CD drive was inited succesfully */ diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index a53fdf6510b..79811f10620 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -63,7 +63,7 @@ SdlEventSource::SdlEventSource() // Enable joystick if (SDL_NumJoysticks() > 0) { - printf("Using joystick: %s\n", SDL_JoystickName(0)); + debug("Using joystick: %s", SDL_JoystickName(0)); _joystick = SDL_JoystickOpen(joystick_num); } }*/ @@ -281,7 +281,7 @@ bool SdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_QUIT; return true; } -#elif defined(UNIX) +#elif defined(POSIX) // On other *nix systems, Control-Q quits if ((ev.key.keysym.mod & KMOD_CTRL) && ev.key.keysym.sym == 'q') { event.type = Common::EVENT_QUIT; @@ -325,7 +325,7 @@ bool SdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) { if (ev.key.keysym.sym == 'm' || // Ctrl-m toggles mouse capture #if defined(MACOSX) // Meta - Q, handled below -#elif defined(UNIX) +#elif defined(POSIX) ev.key.keysym.sym == 'q' || // On other *nix systems, Control-Q quits #else ev.key.keysym.sym == 'z' || // Ctrl-z quit @@ -338,7 +338,7 @@ bool SdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) { #if defined(MACOSX) if ((mod & KMOD_META) && ev.key.keysym.sym == 'q') return false; // On Macintosh, Cmd-Q quits -#elif defined(UNIX) +#elif defined(POSIX) // Control Q has already been handled above #else if ((mod & KMOD_ALT) && ev.key.keysym.sym == 'x') diff --git a/backends/fs/posix/posix-fs-factory.cpp b/backends/fs/posix/posix-fs-factory.cpp index c94e90ccde4..829355be843 100644 --- a/backends/fs/posix/posix-fs-factory.cpp +++ b/backends/fs/posix/posix-fs-factory.cpp @@ -19,13 +19,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if defined(UNIX) +#if defined(POSIX) // 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 +#define FORBIDDEN_SYMBOL_EXCEPTION_exit //Needed for IRIX's unistd.h #include "backends/fs/posix/posix-fs-factory.h" #include "backends/fs/posix/posix-fs.h" diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 4d69a51a03b..0b94c37b165 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -19,13 +19,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if defined(UNIX) +#if defined(POSIX) // 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 +#define FORBIDDEN_SYMBOL_EXCEPTION_getenv +#define FORBIDDEN_SYMBOL_EXCEPTION_exit //Needed for IRIX's unistd.h #include "backends/fs/posix/posix-fs.h" #include "backends/fs/stdiostream.h" @@ -248,4 +250,4 @@ Common::WriteStream *POSIXFilesystemNode::createWriteStream() { return StdioStream::makeFromPath(getPath(), true); } -#endif //#if defined(UNIX) +#endif //#if defined(POSIX) diff --git a/backends/fs/windows/windows-fs.h b/backends/fs/windows/windows-fs.h index 37d1e9099be..071b767f6aa 100644 --- a/backends/fs/windows/windows-fs.h +++ b/backends/fs/windows/windows-fs.h @@ -37,6 +37,7 @@ #include #include #include +#undef ARRAYSIZE /** * Implementation of the ScummVM file system API based on Windows API. diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h index 73d620c1389..5668c7ef144 100644 --- a/backends/graphics/sdl/sdl-graphics.h +++ b/backends/graphics/sdl/sdl-graphics.h @@ -26,6 +26,7 @@ #ifdef USE_OPENGL #include #endif +#undef ARRAYSIZE #include "backends/graphics/graphics.h" #include "graphics/pixelformat.h" diff --git a/backends/midi/alsa.cpp b/backends/midi/alsa.cpp index c416f5775e1..acfa3d69df3 100644 --- a/backends/midi/alsa.cpp +++ b/backends/midi/alsa.cpp @@ -164,7 +164,7 @@ int MidiDriver_ALSA::open() { } printf("Connected to Alsa sequencer client [%d:%d]\n", seq_client, seq_port); - printf("ALSA client initialised [%d:0]\n", my_client); + printf("ALSA client initialized [%d:0]\n", my_client); return 0; } @@ -382,7 +382,7 @@ MusicDevices AlsaMusicPlugin::getDevices() const { AlsaDevices alsaDevices = getAlsaDevices(); - // Since the default behaviour is to use the first device in the list, + // Since the default behavior is to use the first device in the list, // try to put something sensible there. We used to have 17:0 and 65:0 // as defaults. diff --git a/backends/mixer/sdl/sdl-mixer.cpp b/backends/mixer/sdl/sdl-mixer.cpp index 61e7f051e52..16e7f22db5c 100644 --- a/backends/mixer/sdl/sdl-mixer.cpp +++ b/backends/mixer/sdl/sdl-mixer.cpp @@ -20,6 +20,8 @@ * */ +#include "common/scummsys.h" + #if defined(SDL_BACKEND) #include "backends/mixer/sdl/sdl-mixer.h" diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index 04fdb1c64fa..e7d7f3f182a 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -20,46 +20,29 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_exit + #include "backends/modular-backend.h" -#include "backends/fs/fs-factory.h" -#include "backends/audiocd/audiocd.h" #include "backends/graphics/graphics.h" #include "backends/mutex/mutex.h" #include "audio/mixer.h" -#include "common/events.h" -#include "gui/message.h" #include "graphics/pixelformat.h" ModularBackend::ModularBackend() : - _fsFactory(0), - _eventManager(0), - _savefileManager(0), - _timerManager(0), _mutexManager(0), _graphicsManager(0), - _mixer(0), - _audiocdManager(0) { + _mixer(0) { } ModularBackend::~ModularBackend() { - delete _fsFactory; - _fsFactory = 0; delete _graphicsManager; _graphicsManager = 0; - delete _eventManager; - _eventManager = 0; delete _mixer; _mixer = 0; - delete _audiocdManager; - _audiocdManager = 0; - delete _savefileManager; - _savefileManager = 0; - delete _timerManager; - _timerManager = 0; delete _mutexManager; _mutexManager = 0; } @@ -145,16 +128,6 @@ void ModularBackend::setMouseCursor(const byte *buf, uint w, uint h, int hotspot _graphicsManager->setMouseCursor(buf, w, h, hotspotX, hotspotY, keycolor, cursorTargetScale, format); } -Common::TimerManager *ModularBackend::getTimerManager() { - assert(_timerManager); - return _timerManager; -} - -Common::EventManager *ModularBackend::getEventManager() { - assert(_eventManager); - return _eventManager; -} - OSystem::MutexRef ModularBackend::createMutex() { assert(_mutexManager); return _mutexManager->createMutex(); @@ -180,21 +153,10 @@ Audio::Mixer *ModularBackend::getMixer() { return (Audio::Mixer *)_mixer; } -AudioCDManager *ModularBackend::getAudioCDManager() { - assert(_audiocdManager); - return _audiocdManager; -} - void ModularBackend::displayMessageOnOSD(const char *msg) { _graphicsManager->displayMessageOnOSD(msg); } -Common::SaveFileManager *ModularBackend::getSavefileManager() { - assert(_savefileManager); - return _savefileManager; -} - -FilesystemFactory *ModularBackend::getFilesystemFactory() { - assert(_fsFactory); - return _fsFactory; +void ModularBackend::quit() { + exit(0); } diff --git a/backends/modular-backend.h b/backends/modular-backend.h index 9161bd92de6..4eaea1ec9fa 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -24,8 +24,6 @@ #define BACKENDS_MODULAR_BACKEND_H #include "common/system.h" -#include "common/timer.h" -#include "common/savefile.h" class GraphicsManager; class MutexManager; @@ -39,8 +37,6 @@ class MutexManager; * A backend derivated from this class, will need to implement * these functions on its own: * OSystem::pollEvent() - * OSystem::createConfigReadStream() - * OSystem::createConfigWriteStream() * OSystem::getMillis() * OSystem::delayMillis() * OSystem::getTimeAndDate() @@ -91,8 +87,6 @@ public: /** @name Events and Time */ //@{ - virtual Common::TimerManager *getTimerManager(); - virtual Common::EventManager *getEventManager(); virtual Common::HardwareKeySet *getHardwareKeySet() { return 0; } //@} @@ -114,20 +108,10 @@ public: //@} - /** @name Audio CD */ - //@{ - - virtual AudioCDManager *getAudioCDManager(); - - //@} - /** @name Miscellaneous */ //@{ - virtual Common::SaveFileManager *getSavefileManager(); - virtual FilesystemFactory *getFilesystemFactory(); - virtual void quit() { exit(0); } - virtual void setWindowCaption(const char *caption) {} + virtual void quit(); virtual void displayMessageOnOSD(const char *msg); //@} @@ -136,14 +120,9 @@ protected: /** @name Managers variables */ //@{ - FilesystemFactory *_fsFactory; - Common::EventManager *_eventManager; - Common::SaveFileManager *_savefileManager; - Common::TimerManager *_timerManager; MutexManager *_mutexManager; GraphicsManager *_graphicsManager; Audio::Mixer *_mixer; - AudioCDManager *_audiocdManager; //@} }; diff --git a/backends/module.mk b/backends/module.mk index 8867a1de3c5..ffd3b531912 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -6,10 +6,6 @@ MODULE_OBJS := \ events/default/default-events.o \ fs/abstract-fs.o \ fs/stdiostream.o \ - keymapper/action.o \ - keymapper/keymap.o \ - keymapper/keymapper.o \ - keymapper/remap-dialog.o \ log/log.o \ midi/alsa.o \ midi/dmedia.o \ @@ -18,20 +14,42 @@ MODULE_OBJS := \ midi/timidity.o \ saves/savefile.o \ saves/default/default-saves.o \ - timer/default/default-timer.o \ + timer/default/default-timer.o + + +ifdef USE_ELF_LOADER +MODULE_OBJS += \ + plugins/elf/arm-loader.o \ + plugins/elf/elf-loader.o \ + plugins/elf/elf-provider.o \ + plugins/elf/memory-manager.o \ + plugins/elf/mips-loader.o \ + plugins/elf/ppc-loader.o \ + plugins/elf/shorts-segment-manager.o \ + plugins/elf/version.o +endif + +ifdef ENABLE_KEYMAPPER +MODULE_OBJS += \ + keymapper/action.o \ + keymapper/keymap.o \ + keymapper/keymapper.o \ + keymapper/remap-dialog.o +endif + +ifdef ENABLE_VKEYBD +MODULE_OBJS += \ vkeybd/image-map.o \ vkeybd/polygon.o \ vkeybd/virtual-keyboard.o \ vkeybd/virtual-keyboard-gui.o \ vkeybd/virtual-keyboard-parser.o +endif # SDL specific source files. # We cannot just check $BACKEND = sdl, as various other backends # derive from the SDL backend, and they all need the following files. -# TODO: Add SDL_BACKEND to config.mk; this would match the fact that -# we also add -DSDL_BACKEND to the DEFINES. -# However, the latter is only done for *most* SDL based stuff, not always -# so we really should unify the relevant code in configure. +ifdef SDL_BACKEND MODULE_OBJS += \ audiocd/sdl/sdl-audiocd.o \ events/sdl/sdl-events.o \ @@ -41,8 +59,9 @@ MODULE_OBJS += \ mutex/sdl/sdl-mutex.o \ plugins/sdl/sdl-provider.o \ timer/sdl/sdl-timer.o +endif -ifdef UNIX +ifdef POSIX MODULE_OBJS += \ fs/posix/posix-fs.o \ fs/posix/posix-fs-factory.o \ @@ -134,9 +153,10 @@ MODULE_OBJS += \ timer/psp/timer.o endif -ifeq ($(BACKEND),samsungstv) +ifeq ($(BACKEND),samsungtv) MODULE_OBJS += \ - events/samsungtvsdl/samsungtvsdl-events.o + events/samsungtvsdl/samsungtvsdl-events.o \ + graphics/samsungtvsdl/samsungtvsdl-graphics.o endif ifeq ($(BACKEND),webos) diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index f455c27d5af..67af92dda03 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -33,7 +33,9 @@ #include "common/archive.h" #include "common/fs.h" -#include "CoreFoundation/CoreFoundation.h" +#include "ApplicationServices/ApplicationServices.h" // for LSOpenFSRef +#include "CoreFoundation/CoreFoundation.h" // for CF* stuff +#include "CoreServices/CoreServices.h" // for FSPathMakeRef OSystem_MacOSX::OSystem_MacOSX() : @@ -75,4 +77,27 @@ void OSystem_MacOSX::setupIcon() { // Don't set icon on OS X, as we use a nicer external icon there. } +bool OSystem_MacOSX::hasFeature(Feature f) { + if (f == kFeatureDisplayLogFile) + return true; + return OSystem_POSIX::hasFeature(f); +} + +bool OSystem_MacOSX::displayLogFile() { + // Use LaunchServices to open the log file, if possible. + + if (_logFilePath.empty()) + return false; + + FSRef ref; + OSStatus err; + + err = FSPathMakeRef((const UInt8 *)_logFilePath.c_str(), &ref, NULL); + if (err == noErr) { + err = LSOpenFSRef(&ref, NULL); + } + + return err != noErr; +} + #endif diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h index 6d78427522b..86c70297ecc 100644 --- a/backends/platform/sdl/macosx/macosx.h +++ b/backends/platform/sdl/macosx/macosx.h @@ -29,6 +29,10 @@ class OSystem_MacOSX : public OSystem_POSIX { public: OSystem_MacOSX(); + virtual bool hasFeature(Feature f); + + virtual bool displayLogFile(); + virtual void initBackend(); virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); virtual void setupIcon(); diff --git a/backends/platform/sdl/main.cpp b/backends/platform/sdl/main.cpp index 0b8701ff8b4..e2b428ba67e 100644 --- a/backends/platform/sdl/main.cpp +++ b/backends/platform/sdl/main.cpp @@ -24,7 +24,7 @@ // Several SDL based ports use a custom main, and hence do not want to compile // of this file. The following "#if" ensures that. -#if !defined(UNIX) && \ +#if !defined(POSIX) && \ !defined(WIN32) && \ !defined(__MAEMO__) && \ !defined(__SYMBIAN32__) && \ @@ -33,6 +33,7 @@ !defined(DINGUX) && \ !defined(CAANOO) && \ !defined(LINUXMOTO) && \ + !defined(SAMSUNGTV) && \ !defined(OPENPANDORA) #include "backends/platform/sdl/sdl.h" diff --git a/backends/platform/sdl/module.mk b/backends/platform/sdl/module.mk index 87a0e3d658e..efc5168d5b3 100644 --- a/backends/platform/sdl/module.mk +++ b/backends/platform/sdl/module.mk @@ -5,7 +5,7 @@ MODULE_OBJS := \ main.o \ sdl.o -ifdef UNIX +ifdef POSIX MODULE_OBJS += \ posix/posix-main.o \ posix/posix.o diff --git a/backends/platform/sdl/posix/posix-main.cpp b/backends/platform/sdl/posix/posix-main.cpp index 6bdbe3b028d..2ee48151a00 100644 --- a/backends/platform/sdl/posix/posix-main.cpp +++ b/backends/platform/sdl/posix/posix-main.cpp @@ -22,7 +22,7 @@ #include "common/scummsys.h" -#if defined(UNIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(WEBOS) && !defined(LINUXMOTO) && !defined(GPH_DEVICE) && !defined(GP2X) && !defined(DINGUX) && !defined(OPENPANDORA) +#if defined(POSIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(WEBOS) && !defined(LINUXMOTO) && !defined(GPH_DEVICE) && !defined(GP2X) && !defined(DINGUX) && !defined(OPENPANDORA) #include "backends/platform/sdl/posix/posix.h" #include "backends/plugins/sdl/sdl-provider.h" diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index ebd6ec41db2..58dd52b552b 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -20,12 +20,15 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_getenv #define FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#define FORBIDDEN_SYMBOL_EXCEPTION_exit +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h #define FORBIDDEN_SYMBOL_EXCEPTION_time_h //On IRIX, sys/stat.h includes sys/time.h #include "common/scummsys.h" -#ifdef UNIX +#ifdef POSIX #include "backends/platform/sdl/posix/posix.h" #include "backends/saves/posix/posix-saves.h" @@ -33,6 +36,8 @@ #include #include +#include +#include OSystem_POSIX::OSystem_POSIX(Common::String baseConfigName) @@ -57,10 +62,16 @@ void OSystem_POSIX::initBackend() { OSystem_SDL::initBackend(); } +bool OSystem_POSIX::hasFeature(Feature f) { + if (f == kFeatureDisplayLogFile) + return true; + return OSystem_SDL::hasFeature(f); +} + Common::String OSystem_POSIX::getDefaultConfigFileName() { char configFile[MAXPATHLEN]; - // On UNIX type systems, by default we store the config file inside + // On POSIX type systems, by default we store the config file inside // to the HOME directory of the user. const char *home = getenv("HOME"); if (home != NULL && strlen(home) < MAXPATHLEN) @@ -72,6 +83,10 @@ Common::String OSystem_POSIX::getDefaultConfigFileName() { } Common::WriteStream *OSystem_POSIX::createLogFile() { + // Start out by resetting _logFilePath, so that in case + // of a failure, we know that no log file is open. + _logFilePath.clear(); + const char *home = getenv("HOME"); if (home == NULL) return 0; @@ -82,6 +97,9 @@ Common::WriteStream *OSystem_POSIX::createLogFile() { #else logFile += "/.residual"; #endif +#ifdef SAMSUNGTV + logFile = "/mtd_ram"; +#endif struct stat sb; @@ -124,7 +142,62 @@ Common::WriteStream *OSystem_POSIX::createLogFile() { logFile += "/residual.log"; Common::FSNode file(logFile); - return file.createWriteStream(); + Common::WriteStream *stream = file.createWriteStream(); + if (stream) + _logFilePath = logFile; + return stream; } +bool OSystem_POSIX::displayLogFile() { + if (_logFilePath.empty()) + return false; + + // FIXME: This may not work perfectly when in fullscreen mode. + // On my system it drops from fullscreen without ScummVM noticing, + // so the next Alt-Enter does nothing, going from windowed to windowed. + // (wjp, 20110604) + + pid_t pid = fork(); + if (pid < 0) { + // failed to fork + return false; + } else if (pid == 0) { + + // Try xdg-open first + execlp("xdg-open", "xdg-open", _logFilePath.c_str(), (char*)0); + + // If we're here, that clearly failed. + + // TODO: We may also want to try detecting the case where + // xdg-open is successfully executed but returns an error code. + + // Try xterm+less next + + execlp("xterm", "xterm", "-e", "less", _logFilePath.c_str(), (char*)0); + + // TODO: If less does not exist we could fall back to 'more'. + // However, we'll have to use 'xterm -hold' for that to prevent the + // terminal from closing immediately (for short log files) or + // unexpectedly. + + exit(127); + } + + int status; + // Wait for viewer to close. + // (But note that xdg-open may have spawned a viewer in the background.) + + // FIXME: We probably want the viewer to always open in the background. + // This may require installing a SIGCHLD handler. + pid = waitpid(pid, &status, 0); + + if (pid < 0) { + // Probably nothing sensible to do in this error situation + return false; + } + + return WIFEXITED(status) && WEXITSTATUS(status) == 0; +} + + #endif diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h index f2b4975a544..4c88500aae1 100644 --- a/backends/platform/sdl/posix/posix.h +++ b/backends/platform/sdl/posix/posix.h @@ -31,14 +31,31 @@ public: OSystem_POSIX(Common::String baseConfigName = ".residualrc"); virtual ~OSystem_POSIX() {} + virtual bool hasFeature(Feature f); + + virtual bool displayLogFile(); + virtual void init(); virtual void initBackend(); protected: - // Base string for creating the default path and filename - // for the configuration file + /** + * Base string for creating the default path and filename for the + * configuration file. This allows the Mac OS X subclass to override + * the config file path and name. + */ Common::String _baseConfigName; + /** + * The path of the currently open log file, if any. + * + * @note This is currently a string and not an FSNode for simplicity; + * e.g. we don't need to include fs.h here, and currently the + * only use of this value is to use it to open the log file in an + * editor; for that, we need it only as a string anyway. + */ + Common::String _logFilePath; + virtual Common::String getDefaultConfigFileName(); virtual Common::WriteStream *createLogFile(); diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index e59b492b0c4..c7da131eeeb 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -20,7 +20,7 @@ * */ -#define FORBIDDEN_SYMBOL_EXCEPTION_time_h +#define FORBIDDEN_SYMBOL_ALLOW_ALL #ifdef WIN32 #define WIN32_LEAN_AND_MEAN @@ -160,6 +160,8 @@ void OSystem_SDL::initBackend() { setupIcon(); _inited = true; + + ModularBackend::initBackend(); } void OSystem_SDL::initSDL() { @@ -198,20 +200,6 @@ void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) } -Common::String OSystem_SDL::getDefaultConfigFileName() { - return "residual.ini"; -} - -Common::SeekableReadStream *OSystem_SDL::createConfigReadStream() { - Common::FSNode file(getDefaultConfigFileName()); - return file.createReadStream(); -} - -Common::WriteStream *OSystem_SDL::createConfigWriteStream() { - Common::FSNode file(getDefaultConfigFileName()); - return file.createWriteStream(); -} - void OSystem_SDL::setWindowCaption(const char *caption) { Common::String cap; byte c; diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 1d7d8d1774b..089df8b2db5 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -27,6 +27,7 @@ #ifdef USE_OPENGL #include #endif +#undef ARRAYSIZE #include "backends/modular-backend.h" #include "backends/mixer/sdl/sdl-mixer.h" @@ -68,8 +69,6 @@ public: virtual void setWindowCaption(const char *caption); virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); - virtual Common::SeekableReadStream *createConfigReadStream(); - virtual Common::WriteStream *createConfigWriteStream(); virtual uint32 getMillis(); virtual void delayMillis(uint msecs); virtual void getTimeAndDate(TimeDate &td) const; @@ -96,6 +95,8 @@ protected: */ SdlEventSource *_eventSource; + virtual Common::EventSource *getDefaultEventSource() { return _eventSource; } + /** * Initialze the SDL library. */ @@ -106,12 +107,6 @@ protected: */ virtual void setupIcon(); - /** - * Get the file path where the user configuration - * of ScummVM will be saved. - */ - virtual Common::String getDefaultConfigFileName(); - // Logging virtual Common::WriteStream *createLogFile() { return 0; } Backends::Log::Log *_logger; diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 8e573b70b27..c239c6c83fa 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -32,6 +32,7 @@ #define WIN32_LEAN_AND_MEAN #include #undef ARRAYSIZE // winnt.h defines ARRAYSIZE, but we want our own one... +#include #include "backends/platform/sdl/win32/win32.h" #include "backends/fs/windows/windows-fs-factory.h" @@ -87,6 +88,49 @@ void OSystem_Win32::init() { OSystem_SDL::init(); } + +bool OSystem_Win32::hasFeature(Feature f) { + if (f == kFeatureDisplayLogFile) + return true; + + return OSystem_SDL::hasFeature(f); +} + +bool OSystem_Win32::displayLogFile() { + if (_logFilePath.empty()) + return false; + + // Try opening the log file with the default text editor + // log files should be registered as "txtfile" by default and thus open in the default text editor + HINSTANCE shellExec = ShellExecute(NULL, NULL, _logFilePath.c_str(), NULL, NULL, SW_SHOWNORMAL); + if ((intptr_t)shellExec > 32) + return true; + + // ShellExecute with the default verb failed, try the "Open with..." dialog + PROCESS_INFORMATION processInformation; + STARTUPINFO startupInfo; + memset(&processInformation, 0, sizeof(processInformation)); + memset(&startupInfo, 0, sizeof(startupInfo)); + startupInfo.cb = sizeof(startupInfo); + + char cmdLine[MAX_PATH * 2]; // CreateProcess may change the contents of cmdLine + sprintf(cmdLine, "rundll32 shell32.dll,OpenAs_RunDLL %s", _logFilePath.c_str()); + BOOL result = CreateProcess(NULL, + cmdLine, + NULL, + NULL, + FALSE, + NORMAL_PRIORITY_CLASS, + NULL, + NULL, + &startupInfo, + &processInformation); + if (result) + return true; + + return false; +} + Common::String OSystem_Win32::getDefaultConfigFileName() { char configFile[MAXPATHLEN]; @@ -136,6 +180,10 @@ Common::String OSystem_Win32::getDefaultConfigFileName() { } Common::WriteStream *OSystem_Win32::createLogFile() { + // Start out by resetting _logFilePath, so that in case + // of a failure, we know that no log file is open. + _logFilePath.clear(); + char logFile[MAXPATHLEN]; OSVERSIONINFO win32OsVersion; @@ -163,7 +211,11 @@ Common::WriteStream *OSystem_Win32::createLogFile() { strcat(logFile, "\\residual.log"); Common::FSNode file(logFile); - return file.createWriteStream(); + Common::WriteStream *stream = file.createWriteStream(); + if (stream) + _logFilePath= logFile; + + return stream; } else { return 0; } diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h index 268449eeff4..ef7b6af3f1a 100644 --- a/backends/platform/sdl/win32/win32.h +++ b/backends/platform/sdl/win32/win32.h @@ -30,7 +30,22 @@ public: virtual void init(); virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); + + virtual bool hasFeature(Feature f); + + virtual bool displayLogFile(); + protected: + /** + * The path of the currently open log file, if any. + * + * @note This is currently a string and not an FSNode for simplicity; + * e.g. we don't need to include fs.h here, and currently the + * only use of this value is to use it to open the log file in an + * editor; for that, we need it only as a string anyway. + */ + Common::String _logFilePath; + virtual Common::String getDefaultConfigFileName(); virtual Common::WriteStream *createLogFile(); }; diff --git a/backends/plugins/posix/posix-provider.cpp b/backends/plugins/posix/posix-provider.cpp index 39ed247436e..a68a792fa48 100644 --- a/backends/plugins/posix/posix-provider.cpp +++ b/backends/plugins/posix/posix-provider.cpp @@ -22,7 +22,7 @@ #include "common/scummsys.h" -#if defined(DYNAMIC_MODULES) && defined(UNIX) +#if defined(DYNAMIC_MODULES) && defined(POSIX) #include "backends/plugins/posix/posix-provider.h" #include "backends/plugins/dynamic-plugin.h" @@ -77,9 +77,9 @@ public: }; -Plugin* POSIXPluginProvider::createPlugin(const Common::FSNode &node) const { +Plugin *POSIXPluginProvider::createPlugin(const Common::FSNode &node) const { return new POSIXPlugin(node.getPath()); } -#endif // defined(DYNAMIC_MODULES) && defined(UNIX) +#endif // defined(DYNAMIC_MODULES) && defined(POSIX) diff --git a/backends/plugins/posix/posix-provider.h b/backends/plugins/posix/posix-provider.h index 7d6d6ada4de..b1186ccf3fd 100644 --- a/backends/plugins/posix/posix-provider.h +++ b/backends/plugins/posix/posix-provider.h @@ -25,13 +25,13 @@ #include "base/plugins.h" -#if defined(DYNAMIC_MODULES) && defined(UNIX) +#if defined(DYNAMIC_MODULES) && defined(POSIX) class POSIXPluginProvider : public FilePluginProvider { protected: - Plugin* createPlugin(const Common::FSNode &node) const; + Plugin *createPlugin(const Common::FSNode &node) const; }; -#endif // defined(DYNAMIC_MODULES) && defined(UNIX) +#endif // defined(DYNAMIC_MODULES) && defined(POSIX) #endif diff --git a/backends/plugins/win32/win32-provider.cpp b/backends/plugins/win32/win32-provider.cpp index 765391e0bca..9cbff085203 100644 --- a/backends/plugins/win32/win32-provider.cpp +++ b/backends/plugins/win32/win32-provider.cpp @@ -31,6 +31,7 @@ #define WIN32_LEAN_AND_MEAN #include +#undef ARRAYSIZE // winnt.h defines ARRAYSIZE, but we want our own one... class Win32Plugin : public DynamicPlugin { @@ -67,19 +68,11 @@ public: bool loadPlugin() { assert(!_dlHandle); - #ifndef _WIN32_WCE +#ifndef _WIN32_WCE _dlHandle = LoadLibrary(_filename.c_str()); - #else - if (!_filename.hasSuffix("residual.dll") && - !_filename.hasSuffix("libstdc++-6.dll") && - !_filename.hasSuffix("libgcc_s_sjlj-1.dll")) { - // skip loading the core scummvm module and runtime dlls - _dlHandle = LoadLibrary(toUnicode(_filename.c_str())); - } else { - // do not generate misleading error message - return false; - } - #endif +#else + _dlHandle = LoadLibrary(toUnicode(_filename.c_str())); +#endif if (!_dlHandle) { debug("Failed loading plugin '%s' (error code %d)", _filename.c_str(), (int32) GetLastError()); @@ -111,7 +104,11 @@ Plugin* Win32PluginProvider::createPlugin(const Common::FSNode &node) const { bool Win32PluginProvider::isPluginFilename(const Common::FSNode &node) const { // Check the plugin suffix Common::String filename = node.getName(); +#ifndef _WIN32_WCE if (!filename.hasSuffix(".dll")) +#else + if (!filename.hasSuffix(".plugin")) +#endif return false; return true; diff --git a/backends/saves/posix/posix-saves.cpp b/backends/saves/posix/posix-saves.cpp index 9e7a9c26f39..1966215e0bd 100644 --- a/backends/saves/posix/posix-saves.cpp +++ b/backends/saves/posix/posix-saves.cpp @@ -21,13 +21,14 @@ */ -// Enable mkdir +// Enable getenv, mkdir and time.h stuff +#define FORBIDDEN_SYMBOL_EXCEPTION_getenv #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) +#if defined(POSIX) && !defined(DISABLE_DEFAULT_SAVEFILEMANAGER) #include "backends/saves/posix/posix-saves.h" @@ -50,7 +51,7 @@ POSIXSaveFileManager::POSIXSaveFileManager() { // Register default savepath based on HOME #if defined(SAMSUNGTV) - ConfMan.registerDefault("savepath", "/dtv/usb/sda1/.residual"); + ConfMan.registerDefault("savepath", "/mtd_wiselink/residual savegames"); #else Common::String savePath; const char *home = getenv("HOME"); @@ -59,15 +60,30 @@ POSIXSaveFileManager::POSIXSaveFileManager() { savePath += "/" DEFAULT_SAVE_PATH; ConfMan.registerDefault("savepath", savePath); } + + // The user can override the savepath with the SCUMMVM_SAVEPATH + // environment variable. This is weaker than a --savepath on the + // command line, but overrides the default savepath. + // + // To ensure that the command line option (if given) has precedence, + // we only set the value in the transient domain if it is not + // yet present there. + if (!ConfMan.hasKey("savepath", Common::ConfigManager::kTransientDomain)) { + const char *dir = getenv("RESIDUAL_SAVEPATH"); + if (dir && *dir && strlen(dir) < MAXPATHLEN) { + Common::FSNode saveDir(dir); + if (!saveDir.exists()) { + warning("Ignoring non-existent RESIDUAL_SAVEPATH '%s'", dir); + } else if (!saveDir.isWritable()) { + warning("Ignoring non-writable RESIDUAL_SAVEPATH '%s'", dir); + } else { + ConfMan.set("savepath", dir, Common::ConfigManager::kTransientDomain); + } + } + } #endif } -/* -POSIXSaveFileManager::POSIXSaveFileManager(const Common::String &defaultSavepath) - : DefaultSaveFileManager(defaultSavepath) { -} -*/ -#if defined(UNIX) void POSIXSaveFileManager::checkPath(const Common::FSNode &dir) { const Common::String path = dir.getPath(); clearError(); @@ -132,6 +148,5 @@ void POSIXSaveFileManager::checkPath(const Common::FSNode &dir) { } } } -#endif #endif diff --git a/backends/saves/posix/posix-saves.h b/backends/saves/posix/posix-saves.h index b7ee7ff5b8e..160075d3db0 100644 --- a/backends/saves/posix/posix-saves.h +++ b/backends/saves/posix/posix-saves.h @@ -25,7 +25,7 @@ #include "backends/saves/default/default-saves.h" -#if defined(UNIX) +#if defined(POSIX) && !defined(DISABLE_DEFAULT_SAVEFILEMANAGER) /** * Customization of the DefaultSaveFileManager for POSIX platforms. * The only two differences are that the default constructor sets @@ -35,7 +35,6 @@ class POSIXSaveFileManager : public DefaultSaveFileManager { public: POSIXSaveFileManager(); -// POSIXSaveFileManager(const Common::String &defaultSavepath); protected: /** diff --git a/backends/vkeybd/image-map.h b/backends/vkeybd/image-map.h index 020bf70c67a..3bd8cfa0dbc 100644 --- a/backends/vkeybd/image-map.h +++ b/backends/vkeybd/image-map.h @@ -23,9 +23,10 @@ #ifndef COMMON_IMAGEMAP_H #define COMMON_IMAGEMAP_H +#include "common/scummsys.h" + #ifdef ENABLE_VKEYBD -#include "common/scummsys.h" #include "common/hashmap.h" #include "common/hash-str.h" diff --git a/backends/vkeybd/polygon.h b/backends/vkeybd/polygon.h index bc76dfb4d7d..19a12a04098 100644 --- a/backends/vkeybd/polygon.h +++ b/backends/vkeybd/polygon.h @@ -23,9 +23,10 @@ #ifndef COMMON_POLYGON_H #define COMMON_POLYGON_H +#include "common/scummsys.h" + #ifdef ENABLE_VKEYBD -#include "common/scummsys.h" #include "common/array.h" #include "common/rect.h" diff --git a/backends/vkeybd/virtual-keyboard-gui.h b/backends/vkeybd/virtual-keyboard-gui.h index e3798569fb5..da80ef22232 100644 --- a/backends/vkeybd/virtual-keyboard-gui.h +++ b/backends/vkeybd/virtual-keyboard-gui.h @@ -23,10 +23,11 @@ #ifndef COMMON_VIRTUAL_KEYBOARD_GUI_H #define COMMON_VIRTUAL_KEYBOARD_GUI_H +#include "common/scummsys.h" + #ifdef ENABLE_VKEYBD #include "backends/vkeybd/virtual-keyboard.h" -#include "common/scummsys.h" #include "common/rect.h" #include "common/system.h" #include "graphics/font.h" diff --git a/backends/vkeybd/virtual-keyboard-parser.cpp b/backends/vkeybd/virtual-keyboard-parser.cpp index e2b35132dcd..5e4ce11fe49 100644 --- a/backends/vkeybd/virtual-keyboard-parser.cpp +++ b/backends/vkeybd/virtual-keyboard-parser.cpp @@ -59,8 +59,7 @@ bool VirtualKeyboardParser::closedKeyCallback(ParserNode *node) { return parserError("Initial mode of keyboard pack not defined"); } else if (node->name.equalsIgnoreCase("mode")) { if (!_layoutParsed) { - return parserError("'%s' layout missing from '%s' mode", - _mode->resolution.c_str(), _mode->name.c_str()); + return parserError("'" + _mode->resolution + "' layout missing from '" + _mode->name + "' mode"); } } return true; @@ -105,7 +104,7 @@ bool VirtualKeyboardParser::parserCallback_mode(ParserNode *node) { if (_parseMode == kParseFull) { // if full parse then add new mode to keyboard if (_keyboard->_modes.contains(name)) - return parserError("Mode '%s' has already been defined", name.c_str()); + return parserError("Mode '" + name + "' has already been defined"); VirtualKeyboard::Mode mode; mode.name = name; @@ -177,7 +176,7 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) { String name = node->values["name"]; if (_mode->events.contains(name)) - return parserError("Event '%s' has already been defined", name.c_str()); + return parserError("Event '" + name + "' has already been defined"); VirtualKeyboard::VKEvent *evt = new VirtualKeyboard::VKEvent(); evt->name = name; @@ -235,7 +234,7 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) { evt->type = VirtualKeyboard::kVKEventMoveRight; } else { delete evt; - return parserError("Event type '%s' not known", type.c_str()); + return parserError("Event type '" + type + "' not known"); } _mode->events[name] = evt; @@ -257,7 +256,7 @@ bool VirtualKeyboardParser::parserCallback_layout(ParserNode *node) { SeekableReadStream *file = _keyboard->_fileArchive->createReadStreamForMember(_mode->bitmapName); if (!file) - return parserError("Bitmap '%s' not found", _mode->bitmapName.c_str()); + return parserError("Bitmap '" + _mode->bitmapName + "' not found"); const Graphics::PixelFormat format = g_system->getOverlayFormat(); @@ -265,7 +264,7 @@ bool VirtualKeyboardParser::parserCallback_layout(ParserNode *node) { delete file; if (!_mode->image) - return parserError("Error loading bitmap '%s'", _mode->bitmapName.c_str()); + return parserError("Error loading bitmap '" + _mode->bitmapName + "'"); int r, g, b; if (node->values.contains("transparent_color")) { @@ -313,7 +312,7 @@ bool VirtualKeyboardParser::parserCallback_area(ParserNode *node) { Polygon *poly = _mode->imageMap.createArea(target); return parsePolygon(*poly, coords); } - return parserError("Area shape '%s' not known", shape.c_str()); + return parserError("Area shape '" + shape + "' not known"); } byte VirtualKeyboardParser::parseFlags(const String& flags) { diff --git a/backends/vkeybd/virtual-keyboard-parser.h b/backends/vkeybd/virtual-keyboard-parser.h index a5d0e0e4f16..eb25ebe6fdb 100644 --- a/backends/vkeybd/virtual-keyboard-parser.h +++ b/backends/vkeybd/virtual-keyboard-parser.h @@ -23,9 +23,10 @@ #ifndef COMMON_VIRTUAL_KEYBOARD_PARSER_H #define COMMON_VIRTUAL_KEYBOARD_PARSER_H +#include "common/scummsys.h" + #ifdef ENABLE_VKEYBD -#include "common/scummsys.h" #include "common/xmlparser.h" #include "backends/vkeybd/virtual-keyboard.h" diff --git a/backends/vkeybd/virtual-keyboard.h b/backends/vkeybd/virtual-keyboard.h index 4936275e233..21db5a47dae 100644 --- a/backends/vkeybd/virtual-keyboard.h +++ b/backends/vkeybd/virtual-keyboard.h @@ -23,11 +23,12 @@ #ifndef COMMON_VIRTUAL_KEYBOARD_H #define COMMON_VIRTUAL_KEYBOARD_H +#include "common/scummsys.h" + #ifdef ENABLE_VKEYBD class OSystem; -#include "common/scummsys.h" #include "common/events.h" #include "common/hashmap.h" #include "common/hash-str.h" diff --git a/base/commandLine.cpp b/base/commandLine.cpp index 68679da5bea..6ed8d610e93 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -23,6 +23,8 @@ // FIXME: Avoid using printf #define FORBIDDEN_SYMBOL_EXCEPTION_printf +#define FORBIDDEN_SYMBOL_EXCEPTION_exit + #include "engines/metaengine.h" #include "base/commandLine.h" #include "base/plugins.h" @@ -50,7 +52,7 @@ static const char USAGE_STRING[] = ; // DONT FIXME: DO NOT ORDER ALPHABETICALLY, THIS IS ORDERED BY IMPORTANCE/CATEGORY! :) -#if defined(__SYMBIAN32__) || defined(__GP32__) || defined(ANDROID) +#if defined(__SYMBIAN32__) || defined(__GP32__) || defined(ANDROID) || defined(__DS__) static const char HELP_STRING[] = "NoUsageString"; // save more data segment space #else static const char HELP_STRING[] = @@ -111,7 +113,7 @@ static void usage(const char *s, ...) { vsnprintf(buf, STRINGBUFLEN, s, va); va_end(va); -#if !(defined(__GP32__) || defined (__SYMBIAN32__)) +#if !(defined(__GP32__) || defined (__SYMBIAN32__) || defined(__DS__)) printf(USAGE_STRING, s_appName, buf, s_appName, s_appName); #endif exit(1); @@ -797,7 +799,8 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha #endif // DISABLE_COMMAND_LINE -Common::Error processSettings(Common::String &command, Common::StringMap &settings) { +bool processSettings(Common::String &command, Common::StringMap &settings, Common::Error &err) { + err = Common::kNoError; #ifndef DISABLE_COMMAND_LINE @@ -806,33 +809,34 @@ Common::Error processSettings(Common::String &command, Common::StringMap &settin // have been loaded. if (command == "list-targets") { listTargets(); - return Common::kNoError; + return true; } else if (command == "list-games") { listGames(); - return Common::kNoError; + return true; } else if (command == "list-saves") { - return listSaves(settings["list-saves"].c_str()); + err = listSaves(settings["list-saves"].c_str()); + return true; } else if (command == "list-themes") { listThemes(); - return Common::kNoError; + return true; } else if (command == "version") { printf("%s\n", gResidualFullVersion); printf("Features compiled in: %s\n", gResidualFeatures); - return Common::kNoError; + return true; } else if (command == "help") { printf(HELP_STRING, s_appName); - return Common::kNoError; + return true; } #ifdef DETECTOR_TESTING_HACK else if (command == "test-detector") { runDetectorTest(); - return Common::kNoError; + return true; } #endif #ifdef UPGRADE_ALL_TARGETS_HACK else if (command == "upgrade-targets") { upgradeTargets(); - return Common::kNoError; + return true; } #endif @@ -870,26 +874,6 @@ Common::Error processSettings(Common::String &command, Common::StringMap &settin } - // The user can override the savepath with the SCUMMVM_SAVEPATH - // environment variable. This is weaker than a --savepath on the - // command line, but overrides the default savepath, hence it is - // handled here, just before the command line gets parsed. -#if !defined(_WIN32_WCE) && !defined(__GP32__) && !defined(ANDROID) - if (!settings.contains("savepath")) { - const char *dir = getenv("RESIDUAL_SAVEPATH"); - if (dir && *dir && strlen(dir) < MAXPATHLEN) { - Common::FSNode saveDir(dir); - if (!saveDir.exists()) { - warning("Non-existent RESIDUAL_SAVEPATH save path. It will be ignored."); - } else if (!saveDir.isWritable()) { - warning("Non-writable RESIDUAL_SAVEPATH save path. It will be ignored."); - } else { - settings["savepath"] = dir; - } - } - } -#endif - // Finally, store the command line settings into the config manager. for (Common::StringMap::const_iterator x = settings.begin(); x != settings.end(); ++x) { Common::String key(x->_key); @@ -904,7 +888,7 @@ Common::Error processSettings(Common::String &command, Common::StringMap &settin ConfMan.set(key, value, Common::ConfigManager::kTransientDomain); } - return Common::kArgumentNotProcessed; + return false; } } // End of namespace Base diff --git a/base/commandLine.h b/base/commandLine.h index 4e611d97bfa..2798ab09349 100644 --- a/base/commandLine.h +++ b/base/commandLine.h @@ -32,9 +32,28 @@ class String; namespace Base { +/** + * Register various defaults with the ConfigManager. + */ void registerDefaults(); + +/** + * Parse the command line for options and a command; the options + * are stored in the map 'settings, the command (if any) is returned. + */ Common::String parseCommandLine(Common::StringMap &settings, int argc, const char * const *argv); -Common::Error processSettings(Common::String &command, Common::StringMap &settings); + +/** + * Process the command line options and arguments. + * Returns true if everything was handled and ScummVM should quit + * (e.g. because "--help" was specified, and handled). + * + * @param[in] command the command as returned by parseCommandLine + * @param[in] settings the settings as returned by parseCommandLine + * @param[out] err indicates whether any error occurred, and which + * @return true if the command was completely processed and ScummVM should quit, false otherwise + */ +bool processSettings(Common::String &command, Common::StringMap &settings, Common::Error &err); } // End of namespace Base diff --git a/base/main.cpp b/base/main.cpp index c8cc4cc9410..febe732e975 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -338,8 +338,7 @@ extern "C" int residual_main(int argc, const char * const argv[]) { Common::Error res; // TODO: deal with settings that require plugins to be loaded - res = Base::processSettings(command, settings); - if (res.getCode() != Common::kArgumentNotProcessed) { + if (Base::processSettings(command, settings, res)) { if (res.getCode() != Common::kNoError) warning("%s", res.getDesc().c_str()); return res.getCode(); diff --git a/base/plugins.h b/base/plugins.h index b3bd9ccef30..e5482c0f79d 100644 --- a/base/plugins.h +++ b/base/plugins.h @@ -80,7 +80,7 @@ extern int pluginTypeVersions[PLUGIN_TYPE_MAX]; (ENABLE_##ID && !PLUGIN_ENABLED_DYNAMIC(ID)) #define PLUGIN_ENABLED_DYNAMIC(ID) \ - (ENABLE_##ID && (ENABLE_##ID == DYNAMIC_PLUGIN) && DYNAMIC_MODULES) + (ENABLE_##ID && (ENABLE_##ID == DYNAMIC_PLUGIN) && defined(DYNAMIC_MODULES)) // see comments in backends/plugins/elf/elf-provider.cpp #if defined(USE_ELF_LOADER) && defined(ELF_LOADER_CXA_ATEXIT) @@ -92,7 +92,7 @@ extern int pluginTypeVersions[PLUGIN_TYPE_MAX]; #ifdef USE_ELF_LOADER #define PLUGIN_DYNAMIC_BUILD_DATE \ - PLUGIN_EXPORT const char *PLUGIN_getBuildDate() { return gResidualPluginBuildDate; } + PLUGIN_EXPORT const char *PLUGIN_getBuildDate() { return gScummVMPluginBuildDate; } #else #define PLUGIN_DYNAMIC_BUILD_DATE #endif diff --git a/base/version.cpp b/base/version.cpp index 48ca6fd64c9..114e8ac7aab 100644 --- a/base/version.cpp +++ b/base/version.cpp @@ -112,5 +112,9 @@ const char *gResidualFeatures = "" #ifdef USE_THEORADEC "Theora " #endif + +#ifdef USE_FAAD + "AAC " +#endif ; diff --git a/common/algorithm.h b/common/algorithm.h index be810d6e9df..00c0e1c98f3 100644 --- a/common/algorithm.h +++ b/common/algorithm.h @@ -234,6 +234,13 @@ void sort(T first, T last) { sort(first, last, Common::Less()); } +// MSVC is complaining about the minus operator being applied to an unsigned type +// We disable this warning for the affected section of code +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable: 4146) +#endif + /** * Euclid's algorithm to compute the greatest common divisor. */ @@ -256,6 +263,10 @@ T gcd(T a, T b) { return b; } +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + } // End of namespace Common #endif diff --git a/common/error.cpp b/common/error.cpp index f150f268c08..a6c52a0ce95 100644 --- a/common/error.cpp +++ b/common/error.cpp @@ -67,9 +67,6 @@ static String errorToString(ErrorCode errorCode) { case kEnginePluginNotSupportSaves: return _s("Engine plugin does not support save states"); - case kArgumentNotProcessed: - return _s("Command line argument not processed"); - case kUnknownError: default: return _s("Unknown error"); diff --git a/common/error.h b/common/error.h index c06cec4a0b2..23c12b67e4c 100644 --- a/common/error.h +++ b/common/error.h @@ -47,7 +47,6 @@ enum ErrorCode { kUnsupportedGameidError, ///< Engine initialization: Gameid not supported by this (Meta)Engine kUnsupportedColorMode, ///< Engine initialization: Engine does not support backend's color mode - kReadPermissionDenied, ///< Unable to read data due to missing read permission kWritePermissionDenied, ///< Unable to write data due to missing write permission @@ -63,8 +62,6 @@ enum ErrorCode { kEnginePluginNotFound, ///< Failed to find plugin to handle target kEnginePluginNotSupportSaves, ///< Failed if plugin does not support listing save states - kArgumentNotProcessed, ///< Used in command line parsing - kUnknownError ///< Catch-all error, used if no other error code matches }; diff --git a/common/events.h b/common/events.h index 11eb0c316ee..371080c1b27 100644 --- a/common/events.h +++ b/common/events.h @@ -306,7 +306,7 @@ public: /** - * Initialise the event manager. + * Initialize the event manager. * @note called after graphics system has been set up */ virtual void init() {} diff --git a/common/forbidden.h b/common/forbidden.h index d769ff38bef..9cba19cf5e0 100644 --- a/common/forbidden.h +++ b/common/forbidden.h @@ -34,6 +34,9 @@ * 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. + * To ease transition, though, we allow re-enabling selected symbols + * in frontend code. However, this should only be used as a temporary + * measure. Especially new code should avoid this at all costs. */ #ifndef FORBIDDEN_SYMBOL_ALLOW_ALL @@ -51,7 +54,7 @@ * 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 !%* +#define FORBIDDEN_SYMBOL_REPLACEMENT FORBIDDEN_look_at_common_forbidden_h_for_more_info SYMBOL !%* #ifndef FORBIDDEN_SYMBOL_EXCEPTION_printf @@ -79,6 +82,21 @@ #define FILE FORBIDDEN_SYMBOL_REPLACEMENT #endif +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_stdin +#undef stdin +#define stdin FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_stdout +#undef stdout +#define stdout FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_stderr +#undef stderr +#define stderr FORBIDDEN_SYMBOL_REPLACEMENT +#endif + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_fopen #undef fopen #define fopen(a,b) FORBIDDEN_SYMBOL_REPLACEMENT @@ -124,6 +142,46 @@ #define fputc(a,b) FORBIDDEN_SYMBOL_REPLACEMENT #endif +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_fgets +#undef fgets +#define fgets(a,b,c) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_fputs +#undef fputs +#define fputs(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_getc +#undef getc +#define getc(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_putc +#undef putc +#define putc(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_gets +#undef gets +#define gets(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_puts +#undef puts +#define puts(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_getchar +#undef getchar +#define getchar() FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_putchar +#undef putchar +#define putchar(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_setjmp #undef setjmp @@ -140,6 +198,31 @@ #define system(a) FORBIDDEN_SYMBOL_REPLACEMENT #endif +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_exit +#undef exit +#define exit(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_getenv +#undef getenv +#define getenv(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_putenv +#undef putenv +#define putenv(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_setenv +#undef setenv +#define setenv(a,b,c) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_unsetenv +#undef unsetenv +#define unsetenv(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + // // Disable various symbols from time.h @@ -281,6 +364,27 @@ #endif +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_stricmp +#undef stricmp +#define stricmp(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_strnicmp +#undef strnicmp +#define strnicmp(a,b,c) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_strcasecmp +#undef strcasecmp +#define strcasecmp(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_strncasecmp +#undef strncasecmp +#define strncasecmp(a,b,c) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + + /* * We also would like to disable the following symbols; * however, these are also frequently used in regular code, diff --git a/common/macresman.cpp b/common/macresman.cpp index 70c6e0a7ce5..6cbc08da192 100644 --- a/common/macresman.cpp +++ b/common/macresman.cpp @@ -32,7 +32,6 @@ #ifdef MACOSX #include "common/config-manager.h" -#include "backends/fs/stdiostream.h" #endif namespace Common { @@ -108,7 +107,7 @@ bool MacResManager::open(String filename) { #ifdef MACOSX // Check the actual fork on a Mac computer String fullPath = ConfMan.get("path") + "/" + filename + "/..namedfork/rsrc"; - SeekableReadStream *macResForkRawStream = StdioStream::makeFromPath(fullPath, false); + SeekableReadStream *macResForkRawStream = FSNode(fullPath).createReadStream();; if (macResForkRawStream && loadFromRawFork(*macResForkRawStream)) { _baseFileName = filename; @@ -168,7 +167,7 @@ bool MacResManager::open(FSNode path, String filename) { #ifdef MACOSX // Check the actual fork on a Mac computer String fullPath = path.getPath() + "/" + filename + "/..namedfork/rsrc"; - SeekableReadStream *macResForkRawStream = StdioStream::makeFromPath(fullPath, false); + SeekableReadStream *macResForkRawStream = FSNode(fullPath).createReadStream(); if (macResForkRawStream && loadFromRawFork(*macResForkRawStream)) { _baseFileName = filename; diff --git a/common/savefile.h b/common/savefile.h index 40f316267fa..03a7b52add4 100644 --- a/common/savefile.h +++ b/common/savefile.h @@ -142,7 +142,7 @@ public: /** * Request a list of available savegames with a given DOS-style pattern, - * also known as "glob" in the UNIX world. Refer to the Common::matchString() + * also known as "glob" in the POSIX world. Refer to the Common::matchString() * function to learn about the precise pattern format. * @param pattern Pattern to match. Wildcards like * or ? are available. * @return list of strings for all present file names. diff --git a/common/scummsys.h b/common/scummsys.h index 7d15f19a9bb..04e1b52b768 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -40,10 +40,42 @@ #if defined(WIN32) #ifdef _MSC_VER - // vsnprintf is already defined in Visual Studio 2008 - #if (_MSC_VER < 1500) - #define vsnprintf _vsnprintf - #endif + + // FIXME: The placement of the workaround functions for MSVC below + // require us to include stdio.h and stdarg.h for MSVC here. This + // is not exactly nice... + // We should think of a better way of doing this. + #include + #include + + // MSVC's vsnprintf is either non-existant (2003) or bugged since it + // does not always include a terminating NULL (2005+). To work around + // that we fix up the _vsnprintf included. Note that the return value + // will still not match C99's specs! + inline int vsnprintf_msvc(char *str, size_t size, const char *format, va_list args) { + // We do not pass size - 1 here, to ensure we would get the same + // return value as when we would use _vsnprintf directly, since + // for example Common::String::format relies on this. + int retValue = _vsnprintf(str, size, format, args); + str[size - 1] = 0; + return retValue; + } + + #define vsnprintf vsnprintf_msvc + + // Visual Studio does not include snprintf in its standard C library. + // Instead it includes a function called _snprintf with somewhat + // similar semantics. The minor difference is that the return value in + // case the formatted string exceeds the buffer size is different. + // A much more dangerous one is that _snprintf does not always include + // a terminating null (Whoops!). Instead we map to our fixed vsnprintf. + inline int snprintf(char *str, size_t size, const char *format, ...) { + va_list args; + va_start(args, format); + int len = vsnprintf(str, size, format, args); + va_end(args); + return len; + } #endif #if !defined(_WIN32_WCE) @@ -107,21 +139,6 @@ #include "config.h" #endif -// -// Define scumm_stricmp and scumm_strnicmp -// -#if defined(_WIN32_WCE) || defined(_MSC_VER) - #define scumm_stricmp stricmp - #define scumm_strnicmp _strnicmp - #define snprintf _snprintf -#elif defined(__MINGW32__) || defined(__GP32__) || defined(__DS__) - #define scumm_stricmp stricmp - #define scumm_strnicmp strnicmp -#else - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp -#endif - // In the following we configure various targets, in particular those // which can't use our "configure" tool and hence don't use config.h. @@ -151,88 +168,50 @@ // #define SCUMMVM_USE_PRAGMA_PACK +// +// Determine the host endianess and whether memory alignment is required. +// +#if !defined(HAVE_CONFIG_H) -#if defined(HAVE_CONFIG_H) - // All settings should have been set in config.h + #if defined(__DC__) || \ + defined(__DS__) || \ + defined(__GP32__) || \ + defined(IPHONE) || \ + defined(__PLAYSTATION2__) || \ + defined(__PSP__) || \ + defined(__SYMBIAN32__) -#elif defined(__SYMBIAN32__) + #define SCUMM_LITTLE_ENDIAN + #define SCUMM_NEED_ALIGNMENT - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT + #elif defined(_WIN32_WCE) || defined(_MSC_VER) || defined(__MINGW32__) -#elif defined(_WIN32_WCE) + #define SCUMM_LITTLE_ENDIAN - #define SCUMM_LITTLE_ENDIAN + #elif defined(__amigaos4__) || defined(__N64__) || defined(__WII__) -#elif defined(_MSC_VER) + #define SCUMM_BIG_ENDIAN + #define SCUMM_NEED_ALIGNMENT - #define SCUMM_LITTLE_ENDIAN + #elif defined(SDL_BACKEND) + // On SDL based ports, we try to use SDL_BYTEORDER to determine the + // endianess. We explicitly do this as the *last* thing we try, so that + // platform specific settings have precedence. + #include -#elif defined(__MINGW32__) + #if SDL_BYTEORDER == SDL_LIL_ENDIAN + #define SCUMM_LITTLE_ENDIAN + #elif SDL_BYTEORDER == SDL_BIG_ENDIAN + #define SCUMM_BIG_ENDIAN + #else + #error Neither SDL_BIG_ENDIAN nor SDL_LIL_ENDIAN is set. + #endif - #define SCUMM_LITTLE_ENDIAN - -#elif defined(SDL_BACKEND) - /* need this for the SDL_BYTEORDER define */ - #include - - #if SDL_BYTEORDER == SDL_LIL_ENDIAN - #define SCUMM_LITTLE_ENDIAN - #elif SDL_BYTEORDER == SDL_BIG_ENDIAN - #define SCUMM_BIG_ENDIAN #else - #error Neither SDL_BIG_ENDIAN nor SDL_LIL_ENDIAN is set. + + #error No system type defined, host endianess unknown. + #endif - -#elif defined(__DC__) - - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(__GP32__) - - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(__PLAYSTATION2__) - - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(__N64__) - - #define SCUMM_BIG_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(__PSP__) - - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(__amigaos4__) - - #define SCUMM_BIG_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(__DS__) - - #define SCUMM_NEED_ALIGNMENT - #define SCUMM_LITTLE_ENDIAN - -#elif defined(__WII__) - - #define SCUMM_BIG_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(IPHONE) - - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - - -#else - #error No system type defined - #endif @@ -240,17 +219,7 @@ // Some more system specific settings. // TODO/FIXME: All of these should be moved to backend specific files (such as portdefs.h) // -#if defined(__SYMBIAN32__) - - #define SMALL_SCREEN_DEVICE - -#elif defined(_WIN32_WCE) - - #if _WIN32_WCE < 300 - #define SMALL_SCREEN_DEVICE - #endif - -#elif defined(DINGUX) +#if defined(DINGUX) // Very BAD hack following, used to avoid triggering an assert in uClibc dingux library // "toupper" when pressing keyboard function keys. @@ -309,7 +278,7 @@ #if defined(_MSC_VER) #define NORETURN_PRE __declspec(noreturn) #else - #define NORETURN_PRE + #define NORETURN_PRE #endif #endif @@ -317,7 +286,7 @@ #if defined(__GNUC__) || defined(__INTEL_COMPILER) #define NORETURN_POST __attribute__((__noreturn__)) #else - #define NORETURN_POST + #define NORETURN_POST #endif #endif @@ -339,87 +308,25 @@ // -// Typedef our system types +// Typedef our system types unless they have already been defined by config.h, +// or SCUMMVM_DONT_DEFINE_TYPES is set. // -#if !defined(HAVE_CONFIG_H) - - #if defined(__SYMBIAN32__) - - // Enable Symbians own datatypes - // This is done for two reasons - // a) uint is already defined by Symbians libc component - // b) Symbian is using its "own" datatyping, and the Scummvm port - // should follow this to ensure the best compability possible. - typedef unsigned char byte; - - typedef unsigned char uint8; - typedef signed char int8; - - typedef unsigned short int uint16; - typedef signed short int int16; - - typedef unsigned long int uint32; - typedef signed long int int32; - - #elif defined(__GP32__) - - // Override typenames. uint is already defined by system header files. - typedef unsigned char byte; - - typedef unsigned char uint8; - typedef signed char int8; - - typedef unsigned short int uint16; - typedef signed short int int16; - - typedef unsigned long int uint32; - typedef signed long int int32; - - #elif defined(__N64__) - - typedef unsigned char byte; - - typedef unsigned char uint8; - typedef signed char int8; - - typedef unsigned short int uint16; - typedef signed short int int16; - - typedef unsigned int uint32; - typedef signed int int32; - - #elif defined(__DS__) - - // Do nothing, the SDK defines all types we need in nds/ndstypes.h, - // which we include in our portsdef.h - - #else - - typedef unsigned char byte; - typedef unsigned char uint8; - typedef signed char int8; - typedef unsigned short uint16; - typedef signed short int16; - typedef unsigned int uint32; - typedef signed int int32; - typedef unsigned int uint; - - #endif - +#if !defined(HAVE_CONFIG_H) && !defined(SCUMMVM_DONT_DEFINE_TYPES) + typedef unsigned char byte; + typedef unsigned char uint8; + typedef signed char int8; + typedef unsigned short uint16; + typedef signed short int16; + typedef unsigned int uint32; + typedef signed int int32; + typedef unsigned int uint; #endif - // // Overlay color type (FIXME: shouldn't be declared here) // -#if defined(NEWGUI_256) - // 256 color only on PalmOS - typedef byte OverlayColor; -#else - // 15/16 bit color mode everywhere else... - typedef uint16 OverlayColor; -#endif +typedef uint16 OverlayColor; #include "common/forbidden.h" diff --git a/common/str.cpp b/common/str.cpp index 08a6cb6822f..223188bdd68 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -19,11 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "common/str.h" #include "common/hash-str.h" -#include "common/util.h" - +#include "common/list.h" #include "common/memorypool.h" +#include "common/str.h" +#include "common/util.h" #include @@ -256,7 +256,7 @@ String &String::operator=(char c) { String &String::operator+=(const char *str) { if (_str <= str && str <= _str + _size) - return operator+=(Common::String(str)); + return operator+=(String(str)); int len = strlen(str); if (len > 0) { @@ -270,7 +270,7 @@ String &String::operator+=(const char *str) { String &String::operator+=(const String &str) { if (&str == this) - return operator+=(Common::String(str)); + return operator+=(String(str)); int len = str._size; if (len > 0) { @@ -612,7 +612,7 @@ char *trim(char *t) { return rtrim(ltrim(t)); } -Common::String lastPathComponent(const Common::String &path, const char sep) { +String lastPathComponent(const String &path, const char sep) { const char *str = path.c_str(); const char *last = str + path.size(); @@ -622,7 +622,7 @@ Common::String lastPathComponent(const Common::String &path, const char sep) { // Path consisted of only slashes -> return empty string if (last == str) - return Common::String(); + return String(); // Now scan the whole component const char *first = last - 1; @@ -632,24 +632,26 @@ Common::String lastPathComponent(const Common::String &path, const char sep) { if (*first == sep) first++; - return Common::String(first, last); + return String(first, last); } -Common::String normalizePath(const Common::String &path, const char sep) { +String normalizePath(const String &path, const char sep) { if (path.empty()) return path; const char *cur = path.c_str(); - Common::String result; + String result; // If there is a leading slash, preserve that: if (*cur == sep) { result += sep; + // Skip over multiple leading slashes, so "//" equals "/" while (*cur == sep) ++cur; } - // Scan till the end of the String + // Scan for path components till the end of the String + List comps; while (*cur != 0) { const char *start = cur; @@ -657,18 +659,16 @@ Common::String normalizePath(const Common::String &path, const char sep) { while (*cur != sep && *cur != 0) cur++; - const Common::String component(start, cur); + const String component(start, cur); - // Skip empty components and dot components, add all others - if (!component.empty() && component != ".") { - // Add a separator before the component, unless the result - // string already ends with one (which happens only if the - // path *starts* with a separator). - if (!result.empty() && result.lastChar() != sep) - result += sep; - - // Add the component - result += component; + if (component.empty() || component == ".") { + // Skip empty components and dot components + } else if (!comps.empty() && component == ".." && comps.back() != "..") { + // If stack is non-empty and top is not "..", remove top + comps.pop_back(); + } else { + // Add the component to the stack + comps.push_back(component); } // Skip over separator chars @@ -676,6 +676,14 @@ Common::String normalizePath(const Common::String &path, const char sep) { cur++; } + // Finally, assemble all components back into a path + while (!comps.empty()) { + result += comps.front(); + comps.pop_front(); + if (!comps.empty()) + result += sep; + } + return result; } @@ -749,7 +757,7 @@ String tag2string(uint32 tag) { if (!isprint((unsigned char)str[i])) str[i] = '.'; } - return Common::String(str); + return String(str); } size_t strlcpy(char *dst, const char *src, size_t size) { @@ -833,3 +841,36 @@ size_t strlcat(char *dst, const char *src, size_t size) { } } // End of namespace Common + +// Portable implementation of stricmp / strcasecmp / strcmpi. +// TODO: Rename this to Common::strcasecmp +int scumm_stricmp(const char *s1, const char *s2) { + byte l1, l2; + do { + // Don't use ++ inside tolower, in case the macro uses its + // arguments more than once. + l1 = (byte)*s1++; + l1 = tolower(l1); + l2 = (byte)*s2++; + l2 = tolower(l2); + } while (l1 == l2 && l1 != 0); + return l1 - l2; +} + +// Portable implementation of strnicmp / strncasecmp / strncmpi. +// TODO: Rename this to Common::strncasecmp +int scumm_strnicmp(const char *s1, const char *s2, uint n) { + byte l1, l2; + do { + if (n-- == 0) + return 0; // no difference found so far -> signal equality + + // Don't use ++ inside tolower, in case the macro uses its + // arguments more than once. + l1 = (byte)*s1++; + l1 = tolower(l1); + l2 = (byte)*s2++; + l2 = tolower(l2); + } while (l1 == l2 && l1 != 0); + return l1 - l2; +} diff --git a/common/str.h b/common/str.h index b76e4f8448a..7b97dfe9456 100644 --- a/common/str.h +++ b/common/str.h @@ -38,7 +38,7 @@ namespace Common { * a certain length do we allocate a buffer on the heap. * * The presence of \0 characters in the string will cause undefined - * behaviour in some operations. + * behavior in some operations. */ class String { protected: @@ -378,4 +378,7 @@ size_t strlcat(char *dst, const char *src, size_t size); } // End of namespace Common +extern int scumm_stricmp(const char *s1, const char *s2); +extern int scumm_strnicmp(const char *s1, const char *s2, uint n); + #endif diff --git a/common/system.cpp b/common/system.cpp index 1df0532ed51..1dc34fe4ab3 100644 --- a/common/system.cpp +++ b/common/system.cpp @@ -20,34 +20,71 @@ * */ -// Disable symbol overrides so that we can use system headers. -// FIXME: Necessary for the PS2 port, should get rid of this eventually. -#define FORBIDDEN_SYMBOL_ALLOW_ALL +#define FORBIDDEN_SYMBOL_EXCEPTION_exit +#define FORBIDDEN_SYMBOL_EXCEPTION_FILE +#define FORBIDDEN_SYMBOL_EXCEPTION_fputs +#define FORBIDDEN_SYMBOL_EXCEPTION_fflush +#define FORBIDDEN_SYMBOL_EXCEPTION_stdout +#define FORBIDDEN_SYMBOL_EXCEPTION_stderr #include "common/system.h" +#include "common/events.h" +#include "common/fs.h" +#include "common/savefile.h" #include "common/str.h" +#include "common/textconsole.h" -#ifdef __PLAYSTATION2__ - // for those replaced fopen/fread/etc functions - #include "backends/platform/ps2/fileio.h" - - #define fputs(str, file) ps2_fputs(str, file) - #define fflush(a) ps2_fflush(a) -#endif - -#ifdef __DS__ - #include "backends/fs/ds/ds-fs.h" - - #define fputs(str, file) DS::std_fwrite(str, strlen(str), 1, file) - #define fflush(file) DS::std_fflush(file) -#endif +#include "backends/audiocd/default/default-audiocd.h" +#include "backends/fs/fs-factory.h" +#include "backends/timer/default/default-timer.h" OSystem *g_system = 0; OSystem::OSystem() { + _audiocdManager = 0; + _eventManager = 0; + _timerManager = 0; + _savefileManager = 0; + _fsFactory = 0; } OSystem::~OSystem() { + delete _audiocdManager; + _audiocdManager = 0; + + delete _eventManager; + _eventManager = 0; + + delete _timerManager; + _timerManager = 0; + + delete _savefileManager; + _savefileManager = 0; + + delete _fsFactory; + _fsFactory = 0; +} + +void OSystem::initBackend() { + // Verify all managers has been set + if (!_audiocdManager) + error("Backend failed to instantiate audio CD manager"); + if (!_eventManager) + error("Backend failed to instantiate event manager"); + if (!_timerManager) + error("Backend failed to instantiate timer manager"); + + // TODO: We currently don't check _savefileManager, because at least + // on the Nintendo DS, it is possible that none is set. That should + // probably be treated as "saving is not possible". Or else the NDS + // port needs to be changed to always set a _savefileManager +// if (!_savefileManager) +// error("Backend failed to instantiate savefile manager"); + + // TODO: We currently don't check _fsFactory because not all ports + // set it. +// if (!_fsFactory) +// error("Backend failed to instantiate fs factory"); } void OSystem::fatalError() { @@ -55,16 +92,41 @@ void OSystem::fatalError() { exit(1); } +FilesystemFactory *OSystem::getFilesystemFactory() { + assert(_fsFactory); + return _fsFactory; +} + +Common::SeekableReadStream *OSystem::createConfigReadStream() { + Common::FSNode file(getDefaultConfigFileName()); + return file.createReadStream(); +} + +Common::WriteStream *OSystem::createConfigWriteStream() { +#ifdef __DC__ + return 0; +#else + Common::FSNode file(getDefaultConfigFileName()); + return file.createWriteStream(); +#endif +} + +Common::String OSystem::getDefaultConfigFileName() { + return "residual.ini"; +} + void OSystem::logMessage(LogMessageType::Type type, const char *message) { +#if !defined(__PLAYSTATION2__) && !defined(__DS__) FILE *output = 0; - if (type == LogMessageType::kDebug) + if (type == LogMessageType::kInfo || type == LogMessageType::kDebug) output = stdout; else output = stderr; fputs(message, output); fflush(output); +#endif } Common::String OSystem::getSystemLanguage() const { diff --git a/common/system.h b/common/system.h index d29299a0877..fd708d07846 100644 --- a/common/system.h +++ b/common/system.h @@ -73,6 +73,7 @@ struct TimeDate { namespace LogMessageType { enum Type { + kInfo, kError, kWarning, kDebug @@ -95,6 +96,72 @@ protected: OSystem(); virtual ~OSystem(); +protected: + /** + * @name Module slots + * + * For backend authors only, the following pointers (= "slots) to various + * subsystem managers / factories / etc. can and should be set to + * a suitable instance of the respective type. + * + * For some of the slots, a default instance is set if your backend + * does not do so. For details, please look at the documentation of + * each slot. + * + * A backend may setup slot values in its initBackend() method, + * its constructor or somewhere in between. But it must a slot's value + * no later than in its initBackend() implementation, because + * OSystem::initBackend() will create any default instances if + * none has been set yet (and for other slots, will verify that + * one has been set; if not, an error may be generated). + */ + //@{ + + /** + * No default value is provided for _audiocdManager by OSystem. + * However, BaseBackend::initBackend() does set a default value + * if none has been set before. + * + * @note _audiocdManager is deleted by the OSystem destructor. + */ + AudioCDManager *_audiocdManager; + + /** + * No default value is provided for _eventManager by OSystem. + * However, BaseBackend::initBackend() does set a default value + * if none has been set before. + * + * @note _eventManager is deleted by the OSystem destructor. + */ + Common::EventManager *_eventManager; + + /** + * No default value is provided for _timerManager by OSystem. + * + * @note _timerManager is deleted by the OSystem destructor. + */ + Common::TimerManager *_timerManager; + + /** + * No default value is provided for _savefileManager by OSystem. + * + * @note _savefileManager is deleted by the OSystem destructor. + */ + Common::SaveFileManager *_savefileManager; + + /** + * No default value is provided for _fsFactory by OSystem. + * + * Note that _fsFactory is typically required very early on, + * so it usually should be set in the backends constructor or shortly + * thereafter, and before initBackend() is called. + * + * @note _fsFactory is deleted by the OSystem destructor. + */ + FilesystemFactory *_fsFactory; + + //@} + public: /** @@ -105,7 +172,7 @@ public: * parent class. They should do so near the end of their own * implementation. */ - virtual void initBackend() { } + virtual void initBackend(); /** * Allows the backend to perform engine specific init. @@ -128,11 +195,19 @@ public: * - fullscreen mode * - aspect ration correction * - a virtual keyboard for text entry (on PDAs) + * + * One has to distinguish between the *availability* of a feature, + * which can be checked using hasFeature(), and its *state*. + * For example, the SDL backend *has* the kFeatureFullscreenMode, + * so hasFeature returns true for it. On the other hand, + * fullscreen mode may be active or not; this can be determined + * by checking the state via getFeatureState(). Finally, to + * switch between fullscreen and windowed mode, use setFeatureState(). */ enum Feature { /** - * If your backend supports both a windowed and a fullscreen mode, - * then this feature flag can be used to switch between the two. + * If supported, this feature flag can be used to switch between + * windowed and fullscreen mode. */ kFeatureFullscreenMode, @@ -152,12 +227,24 @@ public: * phone-like keypad temporarily unmap all user actions which leads to * comfortable word entry. Conversely, when the dialog exits the feature * is set to false. + * + * TODO: The word 'beneficial' above is very unclear. Beneficial to + * whom and for what??? Just giving an example is not enough. + * * TODO: Fingolfin suggests that the way the feature is used can be * generalized in this sense: Have a keyboard mapping feature, which the * engine queries for to assign keys to actions ("Here's my default key * map for these actions, what do you want them set to?"). */ - kFeatureDisableKeyFiltering + kFeatureDisableKeyFiltering, + + /** + * The presence of this feature indicates whether the displayLogFile() + * call is supported. + * + * This feature has no associated state. + */ + kFeatureDisplayLogFile }; /** @@ -379,13 +466,17 @@ public: * Return the timer manager singleton. For more information, refer * to the TimerManager documentation. */ - virtual Common::TimerManager *getTimerManager() = 0; + inline Common::TimerManager *getTimerManager() { + return _timerManager; + } /** * Return the event manager singleton. For more information, refer * to the EventManager documentation. */ - virtual Common::EventManager *getEventManager() = 0; + inline Common::EventManager *getEventManager() { + return _eventManager; + } /** * Register hardware keys with keymapper @@ -475,7 +566,9 @@ public: * Return the audio cd manager. For more information, refer to the * AudioCDManager documentation. */ - virtual AudioCDManager *getAudioCDManager() = 0; + inline AudioCDManager *getAudioCDManager() { + return _audiocdManager; + } //@} @@ -509,7 +602,8 @@ public: * rectangle over the regular screen content; or in a message box beneath * it; etc.). * - * Currently, only pure ASCII messages can be expected to show correctly. + * The message is expected to be provided in the current TranslationManager + * charset. * * @note There is a default implementation in BaseBackend which uses a * TimedMessageDialog to display the message. Hence implementing @@ -524,14 +618,16 @@ public: * and other modifiable persistent game data. For more information, * refer to the SaveFileManager documentation. */ - virtual Common::SaveFileManager *getSavefileManager() = 0; + inline Common::SaveFileManager *getSavefileManager() { + return _savefileManager; + } /** * Returns the FilesystemFactory object, depending on the current architecture. * * @return the FSNode factory for the current architecture */ - virtual FilesystemFactory *getFilesystemFactory() = 0; + virtual FilesystemFactory *getFilesystemFactory(); /** * Add system specific Common::Archive objects to the given SearchSet. @@ -550,7 +646,7 @@ public: * ReadStream instance. It is the callers responsiblity to delete * the stream after use. */ - virtual Common::SeekableReadStream *createConfigReadStream() = 0; + virtual Common::SeekableReadStream *createConfigReadStream(); /** * Open the default config file for writing, by returning a suitable @@ -559,7 +655,14 @@ public: * * May return 0 to indicate that writing to config file is not possible. */ - virtual Common::WriteStream *createConfigWriteStream() = 0; + virtual Common::WriteStream *createConfigWriteStream(); + + /** + * Get the default file name (or even path) where the user configuration + * of ScummVM will be saved. + * Note that not all ports may use this. + */ + virtual Common::String getDefaultConfigFileName(); /** * Logs a given message. @@ -575,6 +678,33 @@ public: */ virtual void logMessage(LogMessageType::Type type, const char *message); + /** + * Open the log file in a way that allows the user to review it, + * and possibly email it (or parts of it) to the ScummVM team, + * e.g. as part of a bug report. + * + * On a desktop operating system, this would typically launch + * some kind of (external) text editor / viewer. + * On a phone, it might also cause a context switch to another + * application. Finally, on some ports, it might not be supported + * at all, and so do nothing. + * + * The kFeatureDisplayLogFile feature flag can be used to + * test whether this call has been implemented by the active + * backend. + * + * @return true if all seems to have gone fine, false if an error occurred + * + * @note An error could mean that the log file did not exist, + * or the editor could not launch. However, a return value of true does + * not guarantee that the user actually will see the log file. + * + * @note It is up to the backend to ensure that the system is in a state + * that allows the user to actually see the displayed log files. This + * might for example require leaving fullscreen mode. + */ + virtual bool displayLogFile() { return false; } + /** * Returns the locale of the system. * diff --git a/common/textconsole.cpp b/common/textconsole.cpp index 0bd233d206e..f2325ac9ad9 100644 --- a/common/textconsole.cpp +++ b/common/textconsole.cpp @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#define FORBIDDEN_SYMBOL_EXCEPTION_exit + #include "common/textconsole.h" #include "common/system.h" #include "common/str.h" diff --git a/common/unzip.cpp b/common/unzip.cpp index f0590dcbfd4..91f352f40a9 100644 --- a/common/unzip.cpp +++ b/common/unzip.cpp @@ -349,7 +349,7 @@ typedef struct { z_stream stream; /* zLib stream structure for inflate */ uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ - uLong stream_initialised; /* flag set if stream structure is initialised*/ + uLong stream_initialized; /* flag set if stream structure is initialized*/ uLong offset_local_extrafield;/* offset of the local extra field */ uInt size_local_extrafield;/* size of the local extra field */ @@ -1073,7 +1073,7 @@ int unzOpenCurrentFile (unzFile file) { return UNZ_INTERNALERROR; } - pfile_in_zip_read_info->stream_initialised=0; + pfile_in_zip_read_info->stream_initialized=0; if ((s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) @@ -1096,7 +1096,7 @@ int unzOpenCurrentFile (unzFile file) { err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); if (err == Z_OK) - pfile_in_zip_read_info->stream_initialised = 1; + pfile_in_zip_read_info->stream_initialized = 1; /* windowBits is passed < 0 to tell that there is no zlib header. * Note that in this case inflate *requires* an extra "dummy" byte * after the compressed stream in order to complete decompression and @@ -1365,7 +1365,7 @@ int unzCloseCurrentFile(unzFile file) { if (pfile_in_zip_read_info->crc32_data != pfile_in_zip_read_info->crc32_wait) err=UNZ_CRCERROR; } - if (pfile_in_zip_read_info->stream_initialised) + if (pfile_in_zip_read_info->stream_initialized) inflateEnd(&pfile_in_zip_read_info->stream); #endif @@ -1373,7 +1373,7 @@ int unzCloseCurrentFile(unzFile file) { free(pfile_in_zip_read_info->read_buffer); pfile_in_zip_read_info->read_buffer = NULL; - pfile_in_zip_read_info->stream_initialised = 0; + pfile_in_zip_read_info->stream_initialized = 0; free(pfile_in_zip_read_info); s->pfile_in_zip_read=NULL; diff --git a/common/util.cpp b/common/util.cpp index f78ef4da0af..0204be29247 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -212,6 +212,7 @@ const PlatformDescription g_platforms[] = { { "playstation", "psx", "psx", "Sony PlayStation", kPlatformPSX }, { "playstation2", "ps2", "ps2", "Sony PlayStation 2", kPlatformPS2 }, { "cdi", "cdi", "cdi", "Philips CD-i", kPlatformCDi }, + { "ios", "ios", "ios", "Apple iOS", kPlatformIOS }, { 0, 0, 0, "Default", kPlatformUnknown } }; diff --git a/common/util.h b/common/util.h index 12ecb0fa7ed..e3f6246d01b 100644 --- a/common/util.h +++ b/common/util.h @@ -177,6 +177,7 @@ enum Platform { kPlatformPSX, kPlatformPS2, kPlatformCDi, + kPlatformIOS, kPlatformUnknown = -1 }; diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp index 9bd052fb3df..5217c4e82ce 100644 --- a/common/xmlparser.cpp +++ b/common/xmlparser.cpp @@ -22,9 +22,7 @@ // FIXME: Avoid using fprintf #define FORBIDDEN_SYMBOL_EXCEPTION_fprintf - -// FIXME: Avoid using vfprintf -#define FORBIDDEN_SYMBOL_EXCEPTION_vfprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_stderr #include "common/xmlparser.h" @@ -83,7 +81,7 @@ void XMLParser::close() { _stream = 0; } -bool XMLParser::parserError(const char *errorString, ...) { +bool XMLParser::parserError(const Common::String &errStr) { _state = kParserError; const int startPosition = _stream->pos(); @@ -134,12 +132,7 @@ bool XMLParser::parserError(const char *errorString, ...) { fprintf(stderr, "%c", _stream->readByte()); fprintf(stderr, "\n\nParser error: "); - - va_list args; - va_start(args, errorString); - vfprintf(stderr, errorString, args); - va_end(args); - + fprintf(stderr, "%s", errStr.c_str()); fprintf(stderr, "\n\n"); return false; @@ -181,16 +174,16 @@ bool XMLParser::parseActiveKey(bool closed) { for (List::const_iterator i = key->layout->properties.begin(); i != key->layout->properties.end(); ++i) { if (i->required && !localMap.contains(i->name)) - return parserError("Missing required property '%s' inside key '%s'", i->name.c_str(), key->name.c_str()); + return parserError("Missing required property '" + i->name + "' inside key '" + key->name + "'"); else if (localMap.contains(i->name)) keyCount--; } if (keyCount > 0) - return parserError("Unhandled property inside key '%s'.", key->name.c_str()); + return parserError("Unhandled property inside key '" + key->name + "'."); } else { - return parserError("Unexpected key in the active scope ('%s').", key->name.c_str()); + return parserError("Unexpected key in the active scope ('" + key->name + "')."); } // check if any of the parents must be ignored. @@ -205,7 +198,7 @@ bool XMLParser::parseActiveKey(bool closed) { // when keyCallback() fails, a parserError() must be set. // We set it manually in that case. if (_state != kParserError) - parserError("Unhandled exception when parsing '%s' key.", key->name.c_str()); + parserError("Unhandled exception when parsing '" + key->name + "' key."); return false; } @@ -395,7 +388,7 @@ bool XMLParser::parse() { case kParserNeedPropertyName: if (activeClosure) { if (!closeKey()) { - parserError("Missing data when closing key '%s'.", _activeKey.top()->name.c_str()); + parserError("Missing data when closing key '" + _activeKey.top()->name + "'."); break; } diff --git a/common/xmlparser.h b/common/xmlparser.h index 84fca294a09..7923e43a371 100644 --- a/common/xmlparser.h +++ b/common/xmlparser.h @@ -274,7 +274,7 @@ protected: * Parser error always returns "false" so we can pass the return value * directly and break down the parsing. */ - bool parserError(const char *errorString, ...) GCC_PRINTF(2, 3); + bool parserError(const Common::String &errStr); /** * Skips spaces/whitelines etc. diff --git a/configure b/configure index 08070e190b0..30d0f878534 100755 --- a/configure +++ b/configure @@ -20,8 +20,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -# $URL$ -# $Id$ # Save the current environment variables for next runs SAVED_CONFIGFLAGS=$@ @@ -99,13 +97,12 @@ _readline=auto # Default option behaviour yes/no _debug_build=auto _release_build=auto +_verbose_build=no _text_console=no _mt32emu=no -_arm_asm=no + _enable_prof=no -_unix=no _global_constructors=no -_elf_loader=no # Default vkeybd/keymapper options _vkeybd=no _keymapper=no @@ -113,12 +110,11 @@ _keymapper=no _translation=no # Default platform settings _backend=sdl -_endian=unknown -_need_memalign=no -_have_x86=no -_verbose_build=no _dynamic_modules=no +_elf_loader=no _plugins_default=static +_plugin_prefix= +_plugin_suffix= _nasm=auto # Default commands _ranlib=ranlib @@ -134,6 +130,15 @@ _sdlpath="$PATH" _nasmpath="$PATH" NASMFLAGS="" NASM="" +# The following variables are automatically detected, and should not +# be modified otherwise. Consider them read-only. +_posix=no +_endian=unknown +_need_memalign=yes +_have_x86=no +_arm_asm=no + + # Directories for installing Residual. # This list is closely based on what GNU autoconf does, @@ -902,29 +907,11 @@ gp2x) _host_os=gph-linux _host_cpu=arm _host_alias=arm-open2x-linux - if test "$_debug_build" = auto; then - # If you want to debug on the GP2X use '--disable-release --enable-debug' - _debug_build=no - fi - - if test "$_release_build" = auto; then - # Enable release build by default. - _release_build=yes - fi ;; gp2xwiz) _host_os=gph-linux _host_cpu=arm _host_alias=arm-open2x-linux - if test "$_debug_build" = auto; then - # If you want to debug on the GP2XWiz use '--disable-release --enable-debug' - _debug_build=no - fi - - if test "$_release_build" = auto; then - # Enable release build by default. - _release_build=yes - fi ;; i586-mingw32msvc) _host_os=mingw32msvc @@ -962,15 +949,6 @@ openpandora) _host_os=linux _host_cpu=arm _host_alias=arm-angstrom-linux-gnueabi - if test "$_debug_build" = auto; then - # If you want to debug on the OP use '--disable-release --enable-debug' - _debug_build=no - fi - - if test "$_release_build" = auto; then - # Enable release build by default. - _release_build=yes - fi ;; ppc-amigaos) _host_os=amigaos @@ -980,28 +958,11 @@ ps2) _host_os=ps2 _host_cpu=mips64r5900el _host_alias=ee - if test "$_debug_build" = auto; then - # Disable debug mode by default. The resulting binaries are far too big in general, - # and one has to disable multiple engines to make it usable. - _debug_build=no - fi - - if test "$_release_build" = auto; then - # Enable release build by default. - _release_build=yes - fi ;; psp) _host_os=psp _host_cpu=mipsallegrexel _host_alias=psp - if test -z "$PSPDEV"; then - PSPDEV=`psp-config --pspdev-path` - fi - if test -d "$PSPDEV/psp/lib"; then - LDFLAGS="$LDFLAGS -L$PSPDEV/psp/lib" - fi - LDFLAGS="$LDFLAGS -L$PSPDEV/psp/sdk/lib -specs=$_srcdir/backends/platform/psp/psp.spec" ;; samsungtv) _host_os=linux @@ -1058,6 +1019,20 @@ fi # Determine extra build flags for debug and/or release builds # +case $_host in +caanoo | gp2x | gp2xwiz | openpandora | ps2) + if test "$_debug_build" = auto; then + # If you want to debug one of these platforms, use '--disable-release --enable-debug' + _debug_build=no + fi + + if test "$_release_build" = auto; then + # Enable release build by default. + _release_build=yes + fi + ;; +esac + if test "$_debug_build" != no; then # debug mode not explicitly disabled -> compile with -g CXXFLAGS="$CXXFLAGS -g" @@ -1068,7 +1043,9 @@ if test "$_release_build" = yes; then # makes it possible to use -Wuninitialized, so let's do that. # We will also add a define, which indicates we are doing # an build for a release version. - CXXFLAGS="$CXXFLAGS -O2 -Wuninitialized -DRELEASE_BUILD" + CXXFLAGS="$CXXFLAGS -O2" + CXXFLAGS="$CXXFLAGS -Wuninitialized" + DEFINES="$DEFINES -DRELEASE_BUILD" fi @@ -1124,9 +1101,15 @@ ps2) fi ;; psp) - PSPSDK=`psp-config --pspsdk-path` + if test -z "$PSPDEV"; then + PSPDEV=`psp-config --pspdev-path` + fi + # TODO: Should we also insist on a valid PSPDEV value? if test -z "$PSPSDK"; then - echo "Please set the path to PSPSDK in your environment." + PSPSDK=`psp-config --pspsdk-path` + fi + if test -z "$PSPSDK"; then + echo "Please set PSPSDK in your environment. export PSPSDK=" exit 1 fi ;; @@ -1289,6 +1272,9 @@ fi echo "$cxx_version" +# +# Bail out now if now useable compiler was found. +# if test "$cxx_verc_fail" = yes ; then echo echo "The version of your compiler is not supported at this time" @@ -1296,6 +1282,54 @@ if test "$cxx_verc_fail" = yes ; then exit 1 fi +# +# Setup compiler specific CXXFLAGS now that we know the compiler version. +# Foremost, this means enabling various warnings. +# In addition, we set CXX_UPDATE_DEP_FLAG for GCC >= 3.0 and for ICC. +# +if test "$have_gcc" = yes ; then + if test "$_cxx_major" -ge "3" ; then + case $_host_os in + # newlib-based system include files suppress non-C89 function + # declarations under __STRICT_ANSI__ + amigaos* | android | dreamcast | ds | gamecube | mingw* | n64 | psp | ps2 | wii | wince ) + ;; + *) + CXXFLAGS="$CXXFLAGS -ansi" + ;; + esac + CXXFLAGS="$CXXFLAGS -W -Wno-unused-parameter" + add_line_to_config_mk 'HAVE_GCC3 = 1' + add_line_to_config_mk 'CXX_UPDATE_DEP_FLAG = -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" -MQ "$@" -MP' + fi; + + if test "$_cxx_major" -eq 4 && test "$_cxx_minor" -ge 3 || \ + test "$_cxx_major" -gt 4 ; then + CXXFLAGS="$CXXFLAGS -Wno-empty-body" + else + CXXFLAGS="$CXXFLAGS -Wconversion" + fi; +elif test "$have_icc" = yes ; then + add_line_to_config_mk 'CXX_UPDATE_DEP_FLAG = -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" -MQ "$@" -MP' +fi; + +# By default, we add -pedantic to the CXXFLAGS to catch some potentially +# non-portable constructs, like use of GNU extensions. +# However, some platforms use GNU extensions in system header files, so +# for these we must not use -pedantic. +case $_host_os in +android | gamecube | psp | wii) + ;; +*) + # ICC does not support pedantic, while GCC and clang do. + if test "$have_icc" = no ; then + CXXFLAGS="$CXXFLAGS -pedantic" + fi + ;; +esac + +# If possible, we want to use -Wglobal-constructors +# However, not all compilers support that, so check whether the active one does. echocheck "whether -Wglobal-constructors work" cat > $TMPC << EOF int main() { return 0; } @@ -1312,23 +1346,37 @@ echo $_global_constructors # echo_n "Checking endianness... " cat > tmp_endianness_check.cpp << EOF -short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; -short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +unsigned short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +unsigned short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; void _ascii() { char* s = (char*) ascii_mm; s = (char*) ascii_ii; } -short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; -short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +unsigned short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +unsigned short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; void _ebcdic() { char* s = (char*) ebcdic_mm; s = (char*) ebcdic_ii; } int main() { _ascii (); _ebcdic (); return 0; } EOF $CXX $CXXFLAGS -c -o $TMPO.o tmp_endianness_check.cpp if strings $TMPO.o | grep BIGenDianSyS >/dev/null; then _endian=big -else +elif strings $TMPO.o | grep LiTTleEnDian >/dev/null; then _endian=little fi echo $_endian; cc_check_clean tmp_endianness_check.cpp +case $_endian in + big) + add_line_to_config_h '#undef SCUMM_LITTLE_ENDIAN' + add_line_to_config_h '#define SCUMM_BIG_ENDIAN' + ;; + little) + add_line_to_config_h '#define SCUMM_LITTLE_ENDIAN' + add_line_to_config_h '#undef SCUMM_BIG_ENDIAN' + ;; + *) + exit 1 + ;; +esac + # # Determine a data type with the given length # @@ -1417,6 +1465,50 @@ else add_line_to_config_h "#define TARGET_64BITS" fi +# +# Check whether memory alignment is required +# +# For some CPU types, unaligned memory access is either not supported at +# all (and so leads to a crash), requires a super-slow emulation via an +# exception handler, or just results in incorrect results. +# On the other hand, accessing data in a manner that works regardless of +# alignment can be a lot slower than regular access, so we don't want +# to use it if we don't have to. +# +# So we do the following: For CPU families where we know whether unaligned +# access is safe & fast, we enable / disable unaligned access accordingly. +# Otherwise, we just disable memory alignment. +# +# NOTE: In the past, for non-cross compiled builds, we would also run some code +# which would try to test whether unaligned access worked or not. But this test +# could not reliably determine whether unaligned access really worked in all +# situations (and across different implementations of the target CPU arch), nor +# whether it was fast (as opposed to slowly emulated by fault handlers). Hence, +# we do not use this approach anymore. +# +# NOTE: The only kinds of unaligned access we allow are for 2 byte and 4 +# byte loads / stores. No promises are made for bigger sizes, such as 8 +# or 16 byte loads, for which architectures may behave differently than +# for the smaller sizes. +echo_n "Alignment required... " +case $_host_cpu in + i[3-6]86 | x86_64 | ppc*) + # Unaligned access should work + _need_memalign=no + ;; + alpha* | arm* | bfin* | hp* | mips* | sh* | sparc* | ia64 | nv1*) + # Unaligned access is not supported or extremely slow. + _need_memalign=yes + ;; + *) + # Status of unaligned access is unknown, so assume the worst. + _need_memalign=yes + ;; +esac +echo "$_need_memalign" + +define_in_config_h_if_yes $_need_memalign 'SCUMM_NEED_ALIGNMENT' + # # Check whether we can use x86 asm routines # @@ -1430,6 +1522,27 @@ case $_host_cpu in ;; esac echo "$_have_x86" +define_in_config_h_if_yes $_have_x86 'HAVE_X86' + +# +# Check whether to use optimized ARM asm +# +echo_n "Compiling for ARM... " +case $_host_cpu in + arm*) + _arm_asm=yes + ;; + *) + _arm_asm=no + ;; +esac +echo "$_arm_asm" +define_in_config_if_yes "$_arm_asm" 'USE_ARM_SCALER_ASM' +define_in_config_if_yes "$_arm_asm" 'USE_ARM_SOUND_ASM' +define_in_config_if_yes "$_arm_asm" 'USE_ARM_SMUSH_ASM' +define_in_config_if_yes "$_arm_asm" 'USE_ARM_GFX_ASM' +define_in_config_if_yes "$_arm_asm" 'USE_ARM_COSTUME_ASM' + # # Determine build settings @@ -1438,7 +1551,8 @@ echo_n "Checking hosttype... " echo $_host_os case $_host_os in amigaos*) - LDFLAGS="$LDFLAGS -use-dynld -L/sdk/local/newlib/lib" + LDFLAGS="$LDFLAGS -use-dynld" + LDFLAGS="$LDFLAGS -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' @@ -1447,30 +1561,41 @@ case $_host_os in android) case $_host in android) - CXXFLAGS="$CXXFLAGS -march=armv5te -mtune=xscale -msoft-float" + CXXFLAGS="$CXXFLAGS -march=armv5te" + CXXFLAGS="$CXXFLAGS -mtune=xscale" + CXXFLAGS="$CXXFLAGS -msoft-float" ;; android-v7a) - CXXFLAGS="$CXXFLAGS -march=armv7-a -mfloat-abi=softfp -mfpu=vfp" + CXXFLAGS="$CXXFLAGS -march=armv7-a" + CXXFLAGS="$CXXFLAGS -mfloat-abi=softfp" + CXXFLAGS="$CXXFLAGS -mfpu=vfp" LDFLAGS="$LDFLAGS -Wl,--fix-cortex-a8" ;; esac CXXFLAGS="$CXXFLAGS --sysroot=$ANDROID_NDK/platforms/android-4/arch-arm" - CXXFLAGS="$CXXFLAGS -fpic -ffunction-sections -funwind-tables" + CXXFLAGS="$CXXFLAGS -fpic" + CXXFLAGS="$CXXFLAGS -ffunction-sections" + CXXFLAGS="$CXXFLAGS -funwind-tables" if test "$_debug_build" = yes; then - CXXFLAGS="$CXXFLAGS -fno-omit-frame-pointer -fno-strict-aliasing" + CXXFLAGS="$CXXFLAGS -fno-omit-frame-pointer" + CXXFLAGS="$CXXFLAGS -fno-strict-aliasing" else - CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -fstrict-aliasing" + CXXFLAGS="$CXXFLAGS -fomit-frame-pointer" + CXXFLAGS="$CXXFLAGS -fstrict-aliasing" fi CXXFLAGS="$CXXFLAGS -finline-limit=300" - CXXFLAGS="$CXXFLAGS -Os -mthumb-interwork" - CXXFLAGS="$CXXFLAGS -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__" - CXXFLAGS="$CXXFLAGS -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__" + CXXFLAGS="$CXXFLAGS -Os" + CXXFLAGS="$CXXFLAGS -mthumb-interwork" + # FIXME: Why is the following in CXXFLAGS and not in DEFINES? Change or document this. + CXXFLAGS="$CXXFLAGS -D__ARM_ARCH_5__" + CXXFLAGS="$CXXFLAGS -D__ARM_ARCH_5T__" + CXXFLAGS="$CXXFLAGS -D__ARM_ARCH_5E__" + CXXFLAGS="$CXXFLAGS -D__ARM_ARCH_5TE__" # supress 'mangling of 'va_list' has changed in GCC 4.4' CXXFLAGS="$CXXFLAGS -Wno-psabi" LDFLAGS="$LDFLAGS --sysroot=$ANDROID_NDK/platforms/android-4/arch-arm" LDFLAGS="$LDFLAGS -mthumb-interwork" add_line_to_config_mk "ANDROID_SDK = $ANDROID_SDK" - _unix=yes _seq_midi=no ;; beos*) @@ -1480,12 +1605,8 @@ case $_host_os in CFLAGS="-I/boot/home/config/include" CXXFLAGS="$CXXFLAGS -fhuge-objects" LIBS="$LIBS -lbind -lsocket" - _unix=yes _seq_midi=no ;; - bsd* | hpux* | netbsd* | openbsd* | sunos*) - _unix=yes - ;; cygwin*) echo ERROR: Cygwin building is not supported by ScummVM anymore. Consider using MinGW. exit 1 @@ -1494,19 +1615,31 @@ case $_host_os in DEFINES="$DEFINES -DMACOSX" LIBS="$LIBS -framework AudioUnit -framework AudioToolbox -framework Carbon -framework CoreMIDI" add_line_to_config_mk 'MACOSX = 1' - _unix=yes ;; dreamcast) - DEFINES="$DEFINES -D__DC__ -DNONSTANDARD_PORT" + DEFINES="$DEFINES -D__DC__" + DEFINES="$DEFINES -DNONSTANDARD_PORT" ;; ds) - # TODO Nintendo DS - DEFINES="$DEFINES -D__DS__ -DNDS -DARM9 -DARM -DNONSTANDARD_PORT" - CXXFLAGS="$CXXFLAGS -isystem $DEVKITPRO/libnds/include -isystem $DEVKITPRO/devkitARM/arm-eabi/include" - CXXFLAGS="$CXXFLAGS -mcpu=arm9tdmi -mtune=arm9tdmi -fomit-frame-pointer -mthumb-interwork" - CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections -fno-strict-aliasing" + DEFINES="$DEFINES -D__DS__" + DEFINES="$DEFINES -DNDS" + DEFINES="$DEFINES -DARM9" + DEFINES="$DEFINES -DARM" + DEFINES="$DEFINES -DNONSTANDARD_PORT" + CXXFLAGS="$CXXFLAGS -isystem $DEVKITPRO/libnds/include" + CXXFLAGS="$CXXFLAGS -isystem $DEVKITPRO/devkitARM/arm-eabi/include" + CXXFLAGS="$CXXFLAGS -mcpu=arm9tdmi" + CXXFLAGS="$CXXFLAGS -mtune=arm9tdmi" + CXXFLAGS="$CXXFLAGS -fomit-frame-pointer" + CXXFLAGS="$CXXFLAGS -mthumb-interwork" + CXXFLAGS="$CXXFLAGS -ffunction-sections" + CXXFLAGS="$CXXFLAGS -fdata-sections" + CXXFLAGS="$CXXFLAGS -fno-strict-aliasing" CXXFLAGS="$CXXFLAGS -fuse-cxa-atexit" - LDFLAGS="$LDFLAGS -specs=ds_arm9.specs -mthumb-interwork -mno-fpu -Wl,-Map,map.txt" + LDFLAGS="$LDFLAGS -specs=ds_arm9.specs" + LDFLAGS="$LDFLAGS -mthumb-interwork" + LDFLAGS="$LDFLAGS -mno-fpu" + LDFLAGS="$LDFLAGS -Wl,-Map,map.txt" if test "$_dynamic_modules" = no ; then LDFLAGS="$LDFLAGS -Wl,--gc-sections" else @@ -1520,15 +1653,23 @@ case $_host_os in freebsd*) LDFLAGS="$LDFLAGS -L/usr/local/lib" CXXFLAGS="$CXXFLAGS -I/usr/local/include" - _unix=yes ;; gamecube) - CXXFLAGS="$CXXFLAGS -Os -mogc -mcpu=750 -meabi -mhard-float" - CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections -fmodulo-sched" + CXXFLAGS="$CXXFLAGS -Os" + CXXFLAGS="$CXXFLAGS -mogc" + CXXFLAGS="$CXXFLAGS -mcpu=750" + CXXFLAGS="$CXXFLAGS -meabi" + CXXFLAGS="$CXXFLAGS -mhard-float" + CXXFLAGS="$CXXFLAGS -ffunction-sections" + CXXFLAGS="$CXXFLAGS -fdata-sections" + CXXFLAGS="$CXXFLAGS -fmodulo-sched" CXXFLAGS="$CXXFLAGS -fuse-cxa-atexit" CXXFLAGS="$CXXFLAGS -I$DEVKITPRO/libogc/include" # libogc is required to link the cc tests (includes _start()) - LDFLAGS="$LDFLAGS -mogc -mcpu=750 -L$DEVKITPRO/libogc/lib/cube -logc" + LDFLAGS="$LDFLAGS -mogc" + LDFLAGS="$LDFLAGS -mcpu=750" + LDFLAGS="$LDFLAGS -L$DEVKITPRO/libogc/lib/cube" + LDFLAGS="$LDFLAGS -logc" if test "$_dynamic_modules" = "yes" ; then # retarded toolchain patch forces --gc-sections, overwrite it LDFLAGS="$LDFLAGS -Wl,--no-gc-sections" @@ -1538,14 +1679,13 @@ case $_host_os in DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE" # Needs -lnetwork for the timidity MIDI driver LIBS="$LIBS -lnetwork" - _unix=yes _seq_midi=no ;; irix*) - DEFINES="$DEFINES -DIRIX -DSYSTEM_NOT_SUPPORTING_D_TYPE" + DEFINES="$DEFINES -DIRIX" + DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE" LIBS="$LIBS -lmd -lfastm -lm" _ranlib=: - _unix=yes ;; linux* | uclinux*) # When not cross-compiling, enable large file support, but don't @@ -1553,74 +1693,101 @@ case $_host_os in if test -z "$_host"; then CXXFLAGS="$CXXFLAGS $(getconf LFS_CFLAGS 2>/dev/null)" fi - _unix=yes - DEFINES="$DEFINES -DLUA_USE_POSIX" ;; mingw*) - DEFINES="$DEFINES -DWIN32 -D__USE_MINGW_ANSI_STDIO=0" + DEFINES="$DEFINES -DWIN32" + DEFINES="$DEFINES -D__USE_MINGW_ANSI_STDIO=0" LIBS="$LIBS -lmingw32 -lwinmm" OBJS="$OBJS residualwinres.o" add_line_to_config_mk 'WIN32 = 1' ;; mint*) DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE" - _unix=yes ;; n64) - DEFINES="$DEFINES -D__N64__ -DLIMIT_FPS -DNONSTANDARD_PORT" - DEFINES="$DEFINES -DDISABLE_DEFAULT_SAVEFILEMANAGER -DDISABLE_COMMAND_LINE" - DEFINES="$DEFINES -DDISABLE_FANCY_THEMES -DDISABLE_DOSBOX_OPL -DDISABLE_SID -DDISABLE_NES_APU" + DEFINES="$DEFINES -D__N64__" + DEFINES="$DEFINES -DLIMIT_FPS" + DEFINES="$DEFINES -DNONSTANDARD_PORT" + DEFINES="$DEFINES -DDISABLE_COMMAND_LINE" + DEFINES="$DEFINES -DDISABLE_DEFAULT_SAVEFILEMANAGER" + DEFINES="$DEFINES -DDISABLE_DOSBOX_OPL" + DEFINES="$DEFINES -DDISABLE_FANCY_THEMES" + DEFINES="$DEFINES -DDISABLE_NES_APU" + DEFINES="$DEFINES -DDISABLE_SID" DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE" ;; - os2-emx*) - _unix=yes # FIXME??? Why?? - ;; ps2) - # TODO ps2 CXXFLAGS="$CXXFLAGS -G2" - DEFINES="$DEFINES -D_EE -D__PLAYSTATION2__" + DEFINES="$DEFINES -D_EE" + DEFINES="$DEFINES -D__PLAYSTATION2__" ;; psp) - CXXFLAGS="$CXXFLAGS -O3 -I$PSPSDK/include -D_PSP_FW_VERSION=150" + if test -d "$PSPDEV/psp/lib"; then + LDFLAGS="$LDFLAGS -L$PSPDEV/psp/lib" + fi + LDFLAGS="$LDFLAGS -L$PSPSDK/lib" + LDFLAGS="$LDFLAGS -specs=$_srcdir/backends/platform/psp/psp.spec" + CXXFLAGS="$CXXFLAGS -O3" + CXXFLAGS="$CXXFLAGS -I$PSPSDK/include" + # FIXME: Why is the following in CXXFLAGS and not in DEFINES? Change or document this. + CXXFLAGS="$CXXFLAGS -D_PSP_FW_VERSION=150" ;; solaris*) - DEFINES="$DEFINES -DSOLARIS -DSYSTEM_NOT_SUPPORTING_D_TYPE" + DEFINES="$DEFINES -DSOLARIS" + DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE" # Needs -lbind -lsocket for the timidity MIDI driver LIBS="$LIBS -lnsl -lsocket" - _unix=yes ;; webos) - CXXFLAGS="$CXXFLAGS -I$WEBOS_PDK/include -I$WEBOS_PDK/include/SDL -I$WEBOS_PDK/device/usr/include" + CXXFLAGS="$CXXFLAGS -I$WEBOS_PDK/include" + CXXFLAGS="$CXXFLAGS -I$WEBOS_PDK/include/SDL" + CXXFLAGS="$CXXFLAGS -I$WEBOS_PDK/device/usr/include" # These compiler options are needed to support the Palm Pixi - CXXFLAGS="$CXXFLAGS -mcpu=arm1136jf-s -mfpu=vfp -mfloat-abi=softfp" - LDFLAGS="$LDFLAGS -L$WEBOS_PDK/device/lib -L$WEBOS_PDK/device/usr/lib" + CXXFLAGS="$CXXFLAGS -mcpu=arm1136jf-s" + CXXFLAGS="$CXXFLAGS -mfpu=vfp " + CXXFLAGS="$CXXFLAGS -mfloat-abi=softfp" + LDFLAGS="$LDFLAGS -L$WEBOS_PDK/device/lib" + LDFLAGS="$LDFLAGS -L$WEBOS_PDK/device/usr/lib" LDFLAGS="$LDFLAGS -Wl,--allow-shlib-undefined" LDFLAGS="$LDFLAGS --sysroot=$WEBOS_PDK/arm-gcc/sysroot" add_line_to_config_mk "WEBOS_SDK = $WEBOS_SDK" - _unix=yes _seq_midi=no ;; wii) - CXXFLAGS="$CXXFLAGS -Os -mrvl -mcpu=750 -meabi -mhard-float" - CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections -fmodulo-sched" + CXXFLAGS="$CXXFLAGS -Os" + CXXFLAGS="$CXXFLAGS -mrvl" + CXXFLAGS="$CXXFLAGS -mcpu=750" + CXXFLAGS="$CXXFLAGS -meabi" + CXXFLAGS="$CXXFLAGS -mhard-float" + CXXFLAGS="$CXXFLAGS -ffunction-sections" + CXXFLAGS="$CXXFLAGS -fdata-sections" + CXXFLAGS="$CXXFLAGS -fmodulo-sched" CXXFLAGS="$CXXFLAGS -fuse-cxa-atexit" CXXFLAGS="$CXXFLAGS -I$DEVKITPRO/libogc/include" # libogc is required to link the cc tests (includes _start()) - LDFLAGS="$LDFLAGS -mrvl -mcpu=750 -L$DEVKITPRO/libogc/lib/wii -logc" + LDFLAGS="$LDFLAGS -mrvl" + LDFLAGS="$LDFLAGS -mcpu=750" + LDFLAGS="$LDFLAGS -L$DEVKITPRO/libogc/lib/wii" + LDFLAGS="$LDFLAGS -logc" if test "$_dynamic_modules" = "yes" ; then # retarded toolchain patch forces --gc-sections, overwrite it LDFLAGS="$LDFLAGS -Wl,--no-gc-sections" fi ;; wince) - CXXFLAGS="$CXXFLAGS -O3 -fno-inline-functions -march=armv4 -mtune=xscale -D_WIN32_WCE=300 " - DEFINES="$DEFINES -D__ARM__ -D_ARM_ -DUNICODE -DFPM_DEFAULT -DNONSTANDARD_PORT" - DEFINES="$DEFINES -DWIN32 -Dcdecl= -D__cdecl__=" - ;; - # given this is a shell script assume some type of unix - *) - echo "WARNING: could not establish system type, assuming unix like" - _unix=yes + CXXFLAGS="$CXXFLAGS -O3" + CXXFLAGS="$CXXFLAGS -fno-inline-functions" + CXXFLAGS="$CXXFLAGS -march=armv4" + CXXFLAGS="$CXXFLAGS -mtune=xscale" + DEFINES="$DEFINES -D_WIN32_WCE=300" + DEFINES="$DEFINES -D__ARM__" + DEFINES="$DEFINES -D_ARM_" + DEFINES="$DEFINES -DUNICODE" + DEFINES="$DEFINES -DFPM_DEFAULT" + DEFINES="$DEFINES -DNONSTANDARD_PORT" + DEFINES="$DEFINES -DWIN32" + DEFINES="$DEFINES -Dcdecl=" + DEFINES="$DEFINES -D__cdecl__=" ;; esac @@ -1629,48 +1796,39 @@ if test -n "$_host"; then echo "Cross-compiling to $_host" case "$_host" in android | android-v7a) - _unix=yes - _need_memalign=yes # we link a .so as default - LDFLAGS="$LDFLAGS -shared -Wl,-Bsymbolic,--no-undefined" + LDFLAGS="$LDFLAGS -shared" + LDFLAGS="$LDFLAGS -Wl,-Bsymbolic,--no-undefined" HOSTEXEPRE=lib HOSTEXEEXT=.so _backend="android" _port_mk="backends/platform/android/android.mk" - _arm_asm=yes _build_scalers=no _seq_midi=no _mt32emu=no _timidity=no ;; arm-linux|arm*-linux-gnueabi|arm-*-linux) - _unix=yes - _need_memalign=yes - _arm_asm=yes ;; arm-riscos|linupy) DEFINES="$DEFINES -DLINUPY" - _unix=yes - _need_memalign=yes ;; bfin*) - _need_memalign=yes ;; caanoo) # This uses the GPH backend. DEFINES="$DEFINES -DGPH_DEVICE" - DEFINES="$DEFINES -DCAANOO -DREDUCE_MEMORY_USAGE" + DEFINES="$DEFINES -DCAANOO" + DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE" if test "$_debug_build" = yes; then DEFINES="$DEFINES -DGPH_DEBUG" else # Use -O3 on the Caanoo for non-debug builds. CXXFLAGS="$CXXFLAGS -O3" fi - CXXFLAGS="$CXXFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s" + CXXFLAGS="$CXXFLAGS -mcpu=arm926ej-s" + CXXFLAGS="$CXXFLAGS -mtune=arm926ej-s" ASFLAGS="$ASFLAGS" - _unix=yes - _need_memalign=yes - _arm_asm=yes _backend="gph" _build_hq_scalers=no _vkeybd=yes @@ -1684,10 +1842,12 @@ if test -n "$_host"; then _strip=$_host-strip ;; dingux) - DEFINES="$DEFINES -DUNIX -DDINGUX -DDISABLE_DOSBOX_OPL -DREDUCE_MEMORY_USAGE" + DEFINES="$DEFINES -DDINGUX" + DEFINES="$DEFINES -DDISABLE_DOSBOX_OPL" + DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE" ASFLAGS="$ASFLAGS" - CXXFLAGS="$CXXFLAGS -msoft-float -mips32" - _need_memalign=yes + CXXFLAGS="$CXXFLAGS -msoft-float" + CXXFLAGS="$CXXFLAGS -mips32" _backend="dingux" _mt32emu=no _vkeybd=yes @@ -1700,9 +1860,17 @@ if test -n "$_host"; then _port_mk="backends/platform/dingux/dingux.mk" ;; dreamcast) - DEFINES="$DEFINES -DDISABLE_DEFAULT_SAVEFILEMANAGER -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE" - CXXFLAGS="$CXXFLAGS -O3 -funroll-loops -fschedule-insns2 -fomit-frame-pointer -fdelete-null-pointer-checks" - _need_memalign=yes + DEFINES="$DEFINES -DDISABLE_DEFAULT_SAVEFILEMANAGER" + DEFINES="$DEFINES -DDISABLE_TEXT_CONSOLE" + DEFINES="$DEFINES -DDISABLE_COMMAND_LINE" + if test "$_release_build" = yes; then + DEFINES="$DEFINES -DNOSERIAL" + fi + CXXFLAGS="$CXXFLAGS -O3" + CXXFLAGS="$CXXFLAGS -funroll-loops" + CXXFLAGS="$CXXFLAGS -fschedule-insns2" + CXXFLAGS="$CXXFLAGS -fomit-frame-pointer" + CXXFLAGS="$CXXFLAGS -fdelete-null-pointer-checks" _backend="dc" _build_scalers=no _mad=yes @@ -1711,23 +1879,22 @@ if test -n "$_host"; then _port_mk="backends/platform/dc/dreamcast.mk" ;; ds) - # TODO: complete this - DEFINES="$DEFINES -DDISABLE_FANCY_THEMES -DVECTOR_RENDERER_FORMAT=1555" - DEFINES="$DEFINES -DDISABLE_DEFAULT_SAVEFILEMANAGER" - DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE -DSTREAM_AUDIO_FROM_DISK" - DEFINES="$DEFINES -DDISABLE_DOSBOX_OPL -DDISABLE_SID -DDISABLE_NES_APU" DEFINES="$DEFINES -DDISABLE_COMMAND_LINE" - _need_memalign=yes - _arm_asm=yes - add_line_to_config_h '#define DISABLE_TEXT_CONSOLE' + DEFINES="$DEFINES -DDISABLE_DEFAULT_SAVEFILEMANAGER" + DEFINES="$DEFINES -DDISABLE_DOSBOX_OPL" + DEFINES="$DEFINES -DDISABLE_FANCY_THEMES" + DEFINES="$DEFINES -DDISABLE_SID" + DEFINES="$DEFINES -DDISABLE_NES_APU" + DEFINES="$DEFINES -DDISABLE_TEXT_CONSOLE" + DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE" + DEFINES="$DEFINES -DSTREAM_AUDIO_FROM_DISK" + DEFINES="$DEFINES -DVECTOR_RENDERER_FORMAT=1555" _backend="ds" _build_scalers=no _mt32emu=no _port_mk="backends/platform/ds/ds.mk" ;; gamecube) - _endian=big - _need_memalign=yes _backend="wii" _build_scalers=no _mt32emu=no @@ -1743,16 +1910,14 @@ if test -n "$_host"; then gp2x) # This uses the GPH backend. DEFINES="$DEFINES -DGPH_DEVICE" - DEFINES="$DEFINES -DGP2X -DREDUCE_MEMORY_USAGE" + DEFINES="$DEFINES -DGP2X" + DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE" if test "$_debug_build" = yes; then DEFINES="$DEFINES -DGPH_DEBUG" fi CXXFLAGS="$CXXFLAGS -march=armv4t" ASFLAGS="$ASFLAGS -mfloat-abi=soft" LDFLAGS="$LDFLAGS -static" - _unix=yes - _need_memalign=yes - _arm_asm=yes _backend="gph" _build_hq_scalers=no _vkeybd=yes @@ -1764,15 +1929,14 @@ if test -n "$_host"; then gp2xwiz) # This uses the GPH backend. DEFINES="$DEFINES -DGPH_DEVICE" - DEFINES="$DEFINES -DGP2XWIZ -DREDUCE_MEMORY_USAGE" + DEFINES="$DEFINES -DGP2XWIZ" + DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE" if test "$_debug_build" = yes; then DEFINES="$DEFINES -DGPH_DEBUG" fi - CXXFLAGS="$CXXFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s" + CXXFLAGS="$CXXFLAGS -mcpu=arm926ej-s" + CXXFLAGS="$CXXFLAGS -mtune=arm926ej-s" ASFLAGS="$ASFLAGS -mfloat-abi=soft" - _unix=yes - _need_memalign=yes - _arm_asm=yes _backend="gph" _build_hq_scalers=no _vkeybd=yes @@ -1783,18 +1947,12 @@ if test -n "$_host"; then ;; iphone) DEFINES="$DEFINES -DIPHONE" - _unix=yes - _need_memalign=yes - _arm_asm=yes _backend="iphone" _build_hq_scalers=no _seq_midi=no ;; m68k-atari-mint) DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE" - _unix=yes - _endian=big - _need_memalign=yes _ranlib=m68k-atari-mint-ranlib _ar="m68k-atari-mint-ar cru" _seq_midi=no @@ -1808,15 +1966,10 @@ if test -n "$_host"; then mips-sgi*) LDFLAGS="$LDFLAGS -static-libgcc" LIBS="$LIBS -laudio" - _endian=big - _need_memalign=yes ;; motoezx) DEFINES="$DEFINES -DMOTOEZX" ASFLAGS="$ASFLAGS -mfpu=vfp" - _unix=yes - _need_memalign=yes - _arm_asm=yes _backend="linuxmoto" _build_hq_scalers=no _mt32emu=no @@ -1827,9 +1980,6 @@ if test -n "$_host"; then motomagx) DEFINES="$DEFINES -DMOTOMAGX" ASFLAGS="$ASFLAGS -mfpu=vfp" - _unix=yes - _need_memalign=yes - _arm_asm=yes _backend="linuxmoto" _build_hq_scalers=no _mt32emu=no @@ -1838,16 +1988,23 @@ if test -n "$_host"; then _port_mk="backends/platform/linuxmoto/linuxmoto.mk" ;; n64) - CXXFLAGS="$CXXFLAGS -mno-extern-sdata --param max-inline-insns-auto=20 -fomit-frame-pointer" - CXXFLAGS="$CXXFLAGS -march=vr4300 -mtune=vr4300 -mhard-float" - LDFLAGS="$LDFLAGS -march=vr4300 -mtune=vr4300 -nodefaultlibs -nostartfiles -mno-crt0" - LDFLAGS="$LDFLAGS -L$N64SDK/hkz-libn64 -L$N64SDK/lib" + CXXFLAGS="$CXXFLAGS -mno-extern-sdata" + CXXFLAGS="$CXXFLAGS --param max-inline-insns-auto=20" + CXXFLAGS="$CXXFLAGS -fomit-frame-pointer" + CXXFLAGS="$CXXFLAGS -march=vr4300" + CXXFLAGS="$CXXFLAGS -mtune=vr4300" + CXXFLAGS="$CXXFLAGS -mhard-float" + LDFLAGS="$LDFLAGS -march=vr4300" + LDFLAGS="$LDFLAGS -mtune=vr4300" + LDFLAGS="$LDFLAGS -nodefaultlibs" + LDFLAGS="$LDFLAGS -nostartfiles" + LDFLAGS="$LDFLAGS -mno-crt0" + LDFLAGS="$LDFLAGS -L$N64SDK/hkz-libn64" + LDFLAGS="$LDFLAGS -L$N64SDK/lib" LDFLAGS="$LDFLAGS -T n64ld_cpp.x -Xlinker -Map -Xlinker scummvm.map" _backend="n64" - _need_memalign=yes _mt32emu=no _build_scalers=no - _indeo3=no _translation=no _keymapper=no _text_console=no @@ -1862,25 +2019,23 @@ if test -n "$_host"; then ;; neuros) DEFINES="$DEFINES -DNEUROS" - _unix=yes - _need_memalign=yes _backend='null' _build_hq_scalers=no _mt32emu=no ;; openpandora) - DEFINES="$DEFINES -DOPENPANDORA -DREDUCE_MEMORY_USAGE" + DEFINES="$DEFINES -DOPENPANDORA" + DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE" if test "$_release_build" = no; then DEFINES="$DEFINES -DOP_DEBUG" else # Use -O3 on the OpenPandora for non-debug builds. CXXFLAGS="$CXXFLAGS -O3" fi - CXXFLAGS="$CXXFLAGS -march=armv7-a -mtune=cortex-a8 -mfpu=neon" + CXXFLAGS="$CXXFLAGS -march=armv7-a" + CXXFLAGS="$CXXFLAGS -mtune=cortex-a8" + CXXFLAGS="$CXXFLAGS -mfpu=neon" ASFLAGS="$ASFLAGS -mfloat-abi=soft" - _unix=yes - _need_memalign=yes - _arm_asm=yes _backend="openpandora" _build_hq_scalers=yes _vkeybd=no @@ -1889,15 +2044,13 @@ if test -n "$_host"; then _port_mk="backends/platform/openpandora/op-bundle.mk" ;; ppc-amigaos) - _endian=big - # AmigaOS exec allocates memory always in an aligned way - _need_memalign=yes ;; ps2) - # TODO: complete this - DEFINES="$DEFINES -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DDISABLE_DOSBOX_OPL" - DEFINES="$DEFINES -DDISABLE_SID -DDISABLE_NES_APU" - _need_memalign=yes + DEFINES="$DEFINES -DDISABLE_TEXT_CONSOLE" + DEFINES="$DEFINES -DDISABLE_COMMAND_LINE" + DEFINES="$DEFINES -DDISABLE_DOSBOX_OPL" + DEFINES="$DEFINES -DDISABLE_SID" + DEFINES="$DEFINES -DDISABLE_NES_APU" _backend="ps2" _build_scalers=no _mt32emu=no @@ -1917,34 +2070,30 @@ if test -n "$_host"; then DEFINES="$DEFINES -D__PS2_DEBUG__" #INCLUDES="$INCLUDES -I$(PS2GDB)/ee" #LDFLAGS="$LDFLAGS -L$(PS2GDB)/lib" - LDFLAGS="$LDFLAGS -lps2gdbStub -lps2ip -ldebug" + LDFLAGS="$LDFLAGS -lps2gdbStub" + LDFLAGS="$LDFLAGS -lps2ip" + LDFLAGS="$LDFLAGS -ldebug" else # If not building for debug mode, strip binaries. CXXFLAGS="$CXXFLAGS -s" fi ;; psp) - _need_memalign=yes _backend="psp" _build_scalers=no _mt32emu=no _port_mk="backends/platform/psp/psp.mk" ;; samsungtv) - DEFINES="$DEFINES -DSAMSUNGTV -DDISABLE_COMMAND_LINE" + DEFINES="$DEFINES -DSAMSUNGTV" + DEFINES="$DEFINES -DDISABLE_COMMAND_LINE" ASFLAGS="$ASFLAGS -mfpu=vfp" HOSTEXEEXT=".so" - _unix=yes - _need_memalign=yes - _arm_asm=yes _backend="samsungtv" _mt32emu=no _vkeybd=yes ;; webos) - _unix=yes - _need_memalign=yes - _arm_asm=yes _backend="webos" _port_mk="backends/platform/webos/webos.mk" _build_scalers=no @@ -1955,8 +2104,6 @@ if test -n "$_host"; then _keymapper=yes ;; wii) - _endian=big - _need_memalign=yes _backend="wii" _build_scalers=no _port_mk="backends/platform/wii/wii.mk" @@ -1971,8 +2118,6 @@ if test -n "$_host"; then ;; wince) LDFLAGS="$LDFLAGS -Wl,--stack,65536" - _need_memalign=yes - _arm_asm=yes _tremolo=yes _backend="wince" _mt32emu=no @@ -1982,80 +2127,200 @@ if test -n "$_host"; then echo "WARNING: Unknown target, continuing with auto-detected values" ;; esac - -else - # - # Check whether memory alignment is required - # - echo_n "Alignment required... " - case $_host_cpu in - alpha*) - # Hardcode alignment requirements for Alpha processsors - _need_memalign=yes - ;; - arm*) - _need_memalign=yes - ;; - mips*) - # Hardcode alignment requirements for MIPS processsors. - # While these can emulate unaligned memory access, this - # emulation is rather slow. - _need_memalign=yes - ;; - sh*) - # Hardcode alignment requirements for SH processsors. - # While these can emulate unaligned memory access, this - # emulation is rather slow. - _need_memalign=yes - ;; - *) - # Try to auto-detect.... - cat > $TMPC << EOF -#include -#include -int main(int argc, char **argv) { - unsigned char test[8] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 }; - signal(SIGBUS, exit); - signal(SIGABRT, exit); - signal(SIGSEGV, exit); - if (*((unsigned int *)(test + 1)) != 0x55443322 && *((unsigned int *)(test + 1)) != 0x22334455) { - return 1; - } - return 0; -} -EOF - _need_memalign=yes - cc_check_no_clean && $TMPO$HOSTEXEEXT && _need_memalign=no - cc_check_clean - ;; - esac - echo "$_need_memalign" fi # -# Add the results of the above checks to config.h +# Backend related stuff # -case $_endian in - big) - add_line_to_config_h '#undef SCUMM_LITTLE_ENDIAN' - add_line_to_config_h '#define SCUMM_BIG_ENDIAN' +case $_backend in + android) + # ssp at this point so the cxxtests link + if test "$_debug_build" = yes; then + CXXFLAGS="$CXXFLAGS -fstack-protector" + else + CXXFLAGS="$CXXFLAGS -fno-stack-protector" + fi + CXXFLAGS="$CXXFLAGS -Wa,--noexecstack" + LDFLAGS="$LDFLAGS -Wl,-z,noexecstack" + + DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE" ;; - little) - add_line_to_config_h '#define SCUMM_LITTLE_ENDIAN' - add_line_to_config_h '#undef SCUMM_BIG_ENDIAN' + dc) + INCLUDES="$INCLUDES "'-I$(srcdir)/backends/platform/dc' + INCLUDES="$INCLUDES "'-isystem $(ronindir)/include' + LDFLAGS="$LDFLAGS -Wl,-Ttext,0x8c010000" + LDFLAGS="$LDFLAGS -nostartfiles" + LDFLAGS="$LDFLAGS "'$(ronindir)/lib/crt0.o' + LDFLAGS="$LDFLAGS "'-L$(ronindir)/lib' + if test "$_release_build" = yes; then + LIBS="$LIBS -lronin-noserial -lm" + else + LIBS="$LIBS -lronin -lm" + fi + ;; + dingux) + DEFINES="$DEFINES -DDINGUX" + ;; + ds) + INCLUDES="$INCLUDES "'-I$(srcdir)/backends/platform/ds/arm9/source' + INCLUDES="$INCLUDES "'-I$(srcdir)/backends/platform/ds/commoninclude' + INCLUDES="$INCLUDES "'-Ibackends/platform/ds/arm9/data' + ;; + gp2x) + ;; + gph) + ;; + iphone) + OBJCFLAGS="$OBJCFLAGS --std=c99" + LIBS="$LIBS -lobjc -framework UIKit -framework CoreGraphics -framework OpenGLES" + LIBS="$LIBS -framework QuartzCore -framework GraphicsServices -framework CoreFoundation" + LIBS="$LIBS -framework Foundation -framework AudioToolbox -framework CoreAudio" + ;; + linuxmoto) + DEFINES="$DEFINES -DLINUXMOTO" + ;; + n64) + INCLUDES="$INCLUDES "'-I$(N64SDK)/include' + INCLUDES="$INCLUDES "'-I$(N64SDK)/mips64/include' + INCLUDES="$INCLUDES "'-I$(N64SDK)/hkz-libn64' + INCLUDES="$INCLUDES "'-I$(srcdir)/backends/platform/n64' + LIBS="$LIBS -lpakfs -lframfs -ln64 -ln64utils -lromfs" + LIBS="$LIBS -lm -lstdc++ -lz" + ;; + null) + DEFINES="$DEFINES -DUSE_NULL_DRIVER" + ;; + openpandora) + ;; + ps2) + DEFINES="$DEFINES -D_EE" + DEFINES="$DEFINES -DFORCE_RTL" + INCLUDES="$INCLUDES -I$PS2SDK/ee/include" + INCLUDES="$INCLUDES -I$PS2SDK/common/include" + INCLUDES="$INCLUDES -I$PS2SDK/ports/include" + if test "$_dynamic_modules" = no ; then + LDFLAGS="$LDFLAGS -mno-crt0" + LDFLAGS="$LDFLAGS $PS2SDK/ee/startup/crt0.o" + LDFLAGS="$LDFLAGS -T $PS2SDK/ee/startup/linkfile" + fi + LDFLAGS="$LDFLAGS -L$PS2SDK/ee/lib" + LDFLAGS="$LDFLAGS -L$PS2SDK/ports/lib" + LIBS="$LIBS -lmc -lpad -lmouse -lhdd -lpoweroff -lsjpcm" + LIBS="$LIBS -lm -lc -lfileXio -lkernel -lstdc++" + ;; + psp) + DEFINES="$DEFINES -D__PSP__" + DEFINES="$DEFINES -DDISABLE_COMMAND_LINE" + DEFINES="$DEFINES -DDISABLE_DOSBOX_OPL" + LIBS="$LIBS -lpng" + LIBS="$LIBS -Wl,-Map,mapfile.txt" + ;; + samsungtv) + DEFINES="$DEFINES -DSAMSUNGTV" + LDFLAGS="$LDFLAGS -shared" + LDFLAGS="$LDFLAGS -fpic" + ;; + webos) + # There is no sdl-config in the WebOS PDK so we don't use find_sdlconfig here. + LIBS="$LIBS -lSDL" + DEFINES="$DEFINES -DWEBOS" + DEFINES="$DEFINES -DSDL_BACKEND" + add_line_to_config_mk "SDL_BACKEND = 1" + MODULES="$MODULES backends/platform/sdl" + ;; + wii) + DEFINES="$DEFINES -D__WII__" + DEFINES="$DEFINES -DGEKKO" + case $_host_os in + gamecube) + LIBS="$LIBS -lgxflux -liso9660 -lfat -logc -ldb" + ;; + *) + LIBS="$LIBS -lgxflux -ldi -liso9660 -ltinysmb -lfat -lwiiuse -lbte -logc -lwiikeyboard -ldb" + ;; + esac + ;; + wince) + INCLUDES="$INCLUDES "'-I$(srcdir)/backends/platform/wince' + INCLUDES="$INCLUDES "'-I$(srcdir)/backends/platform/wince/CEgui' + INCLUDES="$INCLUDES "'-I$(srcdir)/backends/platform/wince/CEkeys' + LIBS="$LIBS -static -lSDL" + DEFINES="$DEFINES -DSDL_BACKEND" + add_line_to_config_mk "SDL_BACKEND = 1" + ;; + sdl) ;; *) + echo "support for $_backend backend not implemented in configure script yet" exit 1 ;; esac +MODULES="$MODULES backends/platform/$_backend" -define_in_config_h_if_yes $_have_x86 'HAVE_X86' +# +# Setup SDL specifics for SDL based backends +# +case $_backend in + dingux | gp2x | gph | linuxmoto | openpandora | samsungtv | sdl) + find_sdlconfig + INCLUDES="$INCLUDES `$_sdlconfig --prefix="$_sdlpath" --cflags`" + LIBS="$LIBS `$_sdlconfig --prefix="$_sdlpath" --libs`" + DEFINES="$DEFINES -DSDL_BACKEND" + add_line_to_config_mk "SDL_BACKEND = 1" + ;; +esac -define_in_config_h_if_yes $_need_memalign 'SCUMM_NEED_ALIGNMENT' -if test "$_unix" = yes ; then - DEFINES="$DEFINES -DUNIX" - add_line_to_config_mk 'UNIX = 1' +# +# Enable 16bit support only for backends which support it +# +case $_backend in + android | dingux | dreamcast | gph | openpandora | psp | samsungtv | sdl | webos | wii) + if test "$_16bit" = auto ; then + _16bit=yes + else + _16bit=no + fi + ;; + *) + _16bit=no + ;; +esac + + +# +# Determine whether host is POSIX compliant, or at least POSIX +# compatible enough to support our POSIX code (including dlsym(), +# mkdir() and some other APIs). +# +# TODO: Instead of basing this on the host name, we should really base +# this on the presence of features (such as the dlsym and mkdir APIs). +# +echo_n "Checking if host is POSIX compliant... " +case $_host_os in + amigaos* | cygwin* | dreamcast | ds | gamecube | mingw* | n64 | ps2 | psp | wii | wince) + _posix=no + ;; + android | beos* | bsd* | darwin* | freebsd* | gph-linux | haiku* | hpux* | iphone | irix* | linux* | mint* | netbsd* | openbsd* | solaris* | sunos* | uclinux* | webos) + _posix=yes + ;; + os2-emx*) + _posix=yes # FIXME: Really??? + ;; + *) + # given this is a shell script, we might assume some type of posix. + # However, the host system might be a totally different one, so + # we can assume nothing about it. + # Indeed, as mentioned further above, we really should test for the + # presences of relevant APIs on the host anyway... + _posix=no + ;; +esac +echo $_posix + +if test "$_posix" = yes ; then + DEFINES="$DEFINES -DPOSIX" + add_line_to_config_mk 'POSIX = 1' fi # @@ -2071,16 +2336,15 @@ add_to_config_mk_if_yes "$_verbose_build" 'VERBOSE_BUILD = 1' echo_n "Checking whether building plugins was requested... " echo "$_dynamic_modules" _mak_plugins= -_def_plugin="/* -> plugins disabled */" if test "$_dynamic_modules" = yes ; then echo_n "Checking whether building plugins is supported... " case $_host_os in android) -_def_plugin=' -#define PLUGIN_PREFIX "lib" -#define PLUGIN_SUFFIX ".so" -' + _plugin_prefix="lib" + _plugin_suffix=".so" + CXXFLAGS="$CXXFLAGS -fpic" + LIBS="$LIBS -ldl" # Work around an Android 2.0+ run-time linker bug: # The linker doesn't actually look in previously # loaded libraries when trying to resolve symbols - @@ -2090,47 +2354,29 @@ _def_plugin=' # (otherwise unnecessary) dependency from plugins back # to the main libscummvm.so. _mak_plugins=' -DYNAMIC_MODULES := 1 -PLUGIN_PREFIX := lib -PLUGIN_SUFFIX := .so -PLUGIN_EXTRA_DEPS = libresidual.so -CXXFLAGS += -DDYNAMIC_MODULES -CXXFLAGS += -fpic -PLUGIN_LDFLAGS += $(LDFLAGS) -L. -lresidual +PLUGIN_EXTRA_DEPS = libscummvm.so +PLUGIN_LDFLAGS += $(LDFLAGS) -L. -lscummvm PRE_OBJS_FLAGS := -Wl,-export-dynamic -Wl,-whole-archive POST_OBJS_FLAGS := -Wl,-no-whole-archive -LIBS += -ldl ' ;; darwin*) -_def_plugin=' -#define PLUGIN_PREFIX "" -#define PLUGIN_SUFFIX ".plugin" -' + _plugin_prefix="" + _plugin_suffix=".plugin" + LIBS="$LIBS -ldl" _mak_plugins=' -DYNAMIC_MODULES := 1 -PLUGIN_PREFIX := -PLUGIN_SUFFIX := .plugin PLUGIN_EXTRA_DEPS = $(EXECUTABLE) -CXXFLAGS += -DDYNAMIC_MODULES PLUGIN_LDFLAGS += -bundle -bundle_loader $(EXECUTABLE) -exported_symbols_list "$(srcdir)/plugin.exp" PRE_OBJS_FLAGS := -all_load POST_OBJS_FLAGS := -LIBS += -ldl ' ;; dreamcast) -_def_plugin=' -#define PLUGIN_PREFIX "" -#define PLUGIN_SUFFIX ".plg" -' + _plugin_prefix="" + _plugin_suffix=".plg" _mak_plugins=' -DYNAMIC_MODULES := 1 -PLUGIN_PREFIX := -PLUGIN_SUFFIX := .plg PLUGIN_EXTRA_DEPS = $(abspath $(srcdir)/backends/platform/dc/plugin.x $(srcdir)/backends/platform/dc/plugin.syms) $(EXECUTABLE) backends/platform/dc/plugin_head.o -CXXFLAGS += -DDYNAMIC_MODULES -PLUGIN_LDFLAGS = -ml -m4-single-only -nostartfiles -Wl,-q,-T$(srcdir)/backends/platform/dc/plugin.x,--just-symbols,$(EXECUTABLE),--retain-symbols-file,$(srcdir)/backends/platform/dc/plugin.syms -L$(ronindir)/lib backends/platform/dc/plugin_head.o +PLUGIN_LDFLAGS = -ml -m4-single-only -nostartfiles -Wl,-q,-T$(srcdir)/backends/platform/dc/plugin.x,--just-symbols,$(EXECUTABLE),--retain-symbols-file,$(srcdir)/backends/platform/dc/plugin.syms backends/platform/dc/plugin_head.o PRE_OBJS_FLAGS := -Wl,--whole-archive POST_OBJS_FLAGS := -Wl,--no-whole-archive ' @@ -2143,17 +2389,11 @@ PLUGIN_LDFLAGS += -Wl,-T$(srcdir)/backends/plugins/ds/plugin.ld -mthumb-interwo ' ;; freebsd*) -_def_plugin=' -#define PLUGIN_PREFIX "lib" -#define PLUGIN_SUFFIX ".so" -' + _plugin_prefix="lib" + _plugin_suffix=".so" + CXXFLAGS="$CXXFLAGS -fpic" _mak_plugins=' -DYNAMIC_MODULES := 1 -PLUGIN_PREFIX := lib -PLUGIN_SUFFIX := .so PLUGIN_EXTRA_DEPS = -CXXFLAGS += -DDYNAMIC_MODULES -CXXFLAGS += -fpic PLUGIN_LDFLAGS += -shared PRE_OBJS_FLAGS := -Wl,-export-dynamic -Wl,-whole-archive POST_OBJS_FLAGS := -Wl,-no-whole-archive @@ -2167,52 +2407,34 @@ PLUGIN_LDFLAGS += -Wl,-T$(srcdir)/backends/plugins/wii/plugin.ld ' ;; gph*) -_def_plugin=' -#define PLUGIN_PREFIX "" -#define PLUGIN_SUFFIX ".plugin" -' + _plugin_prefix="" + _plugin_suffix=".plugin" + CXXFLAGS="$CXXFLAGS -fpic" + LIBS="$LIBS -ldl" _mak_plugins=' -DYNAMIC_MODULES := 1 -PLUGIN_PREFIX := -PLUGIN_SUFFIX := .plugin PLUGIN_EXTRA_DEPS = $(EXECUTABLE) -CXXFLAGS += -DDYNAMIC_MODULES -CXXFLAGS += -fpic PLUGIN_LDFLAGS += -shared PRE_OBJS_FLAGS := -Wl,-export-dynamic -Wl,-whole-archive POST_OBJS_FLAGS := -Wl,-no-whole-archive -LIBS += -ldl ' ;; linux*) -_def_plugin=' -#define PLUGIN_PREFIX "lib" -#define PLUGIN_SUFFIX ".so" -' + _plugin_prefix="lib" + _plugin_suffix=".so" + CXXFLAGS="$CXXFLAGS -fpic" + LIBS="$LIBS -ldl" _mak_plugins=' -DYNAMIC_MODULES := 1 -PLUGIN_PREFIX := lib -PLUGIN_SUFFIX := .so PLUGIN_EXTRA_DEPS = -CXXFLAGS += -DDYNAMIC_MODULES -CXXFLAGS += -fpic PLUGIN_LDFLAGS += -shared PRE_OBJS_FLAGS := -Wl,-export-dynamic -Wl,-whole-archive POST_OBJS_FLAGS := -Wl,-no-whole-archive -LIBS += -ldl ' ;; *mingw32*) -_def_plugin=' -#define PLUGIN_PREFIX "" -#define PLUGIN_SUFFIX ".dll" -' + _plugin_prefix="" + _plugin_suffix=".dll" _mak_plugins=' -DYNAMIC_MODULES := 1 -PLUGIN_PREFIX := -PLUGIN_SUFFIX := .dll PLUGIN_EXTRA_DEPS = $(EXECUTABLE) -CXXFLAGS += -DDYNAMIC_MODULES PLUGIN_LDFLAGS := -Wl,--enable-auto-import -shared ./libscummvm.a PRE_OBJS_FLAGS := -Wl,--whole-archive POST_OBJS_FLAGS := -Wl,--export-all-symbols -Wl,--no-whole-archive -Wl,--out-implib,./libscummvm.a @@ -2221,17 +2443,11 @@ POST_OBJS_FLAGS := -Wl,--export-all-symbols -Wl,--no-whole-archive -Wl,--out-im wince) DEFINES="$DEFINES -DUNCACHED_PLUGINS" HOSTEXEEXT=".dll" -_def_plugin=' -#define PLUGIN_PREFIX "" -#define PLUGIN_SUFFIX ".dll" -' + _plugin_prefix="" + _plugin_suffix=".plugin" _mak_plugins=' -DYNAMIC_MODULES := 1 -PLUGIN_PREFIX := -PLUGIN_SUFFIX := .dll PLUGIN_EXTRA_DEPS = $(EXECUTABLE) -CXXFLAGS += -DDYNAMIC_MODULES -PLUGIN_LDFLAGS := -shared -lresidual -L. +PLUGIN_LDFLAGS := -shared -lscummvm -L. PRE_OBJS_FLAGS := -Wl,--whole-archive POST_OBJS_FLAGS := -Wl,--export-all-symbols -Wl,--no-whole-archive -Wl,--out-implib,./libscummvm.a -shared ' @@ -2240,7 +2456,7 @@ POST_OBJS_FLAGS := -Wl,--export-all-symbols -Wl,--no-whole-archive -Wl,--out-im _elf_loader=yes DEFINES="$DEFINES -DMIPS_TARGET" _mak_plugins=' -LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -T$(srcdir)/backends/plugins/ps2/main_prog.ld +LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -Wl,-T$(srcdir)/backends/plugins/ps2/main_prog.ld PLUGIN_LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -Wl,-T$(srcdir)/backends/plugins/ps2/plugin.ld -lstdc++ -lc ' ;; @@ -2253,27 +2469,20 @@ PLUGIN_LDFLAGS += -Wl,-T$(srcdir)/backends/plugins/psp/plugin.ld -lstdc++ -lc ' ;; webos) -_def_plugin=' -#define PLUGIN_PREFIX "lib" -#define PLUGIN_SUFFIX ".so" -' + _plugin_prefix="lib" + _plugin_suffix=".so" + CXXFLAGS="$CXXFLAGS -fpic" + LIBS="$LIBS -ldl" _mak_plugins=' -DYNAMIC_MODULES := 1 -PLUGIN_PREFIX := lib -PLUGIN_SUFFIX := .so PLUGIN_EXTRA_DEPS = -CXXFLAGS += -DDYNAMIC_MODULES -CXXFLAGS += -fpic PLUGIN_LDFLAGS += -shared $(LDFLAGS) PRE_OBJS_FLAGS := -Wl,-export-dynamic -Wl,-whole-archive POST_OBJS_FLAGS := -Wl,-no-whole-archive -LIBS += -ldl ' ;; *) _dynamic_modules=no _mak_plugins= - _def_plugin= ;; esac echo "$_dynamic_modules" @@ -2285,15 +2494,9 @@ fi define_in_config_if_yes "$_elf_loader" 'USE_ELF_LOADER' if test "$_elf_loader" = yes; then - CXXFLAGS="$CXXFLAGS -DDYNAMIC_MODULES" - _def_plugin=' -#define PLUGIN_PREFIX "" -#define PLUGIN_SUFFIX ".plg" -' + _plugin_prefix="" + _plugin_suffix=".plg" _mak_plugins=' -DYNAMIC_MODULES := 1 -PLUGIN_PREFIX := -PLUGIN_SUFFIX := .plg PLUGIN_EXTRA_DEPS = $(EXECUTABLE) PLUGIN_LDFLAGS = -nostartfiles backends/plugins/elf/version.o -Wl,-q,--just-symbols,$(EXECUTABLE),--retain-symbols-file,$(srcdir)/backends/plugins/elf/plugin.syms PRE_OBJS_FLAGS := -Wl,--whole-archive @@ -2301,19 +2504,38 @@ POST_OBJS_FLAGS := -Wl,--no-whole-archive '"$_mak_plugins" fi +# +# Set up some common plugin settings in config.h and config.mk, if enabled +# +define_in_config_if_yes "$_dynamic_modules" 'DYNAMIC_MODULES' + +if test "$_dynamic_modules" = yes ; then + add_line_to_config_h "#define PLUGIN_PREFIX \"$_plugin_prefix\"" + add_line_to_config_h "#define PLUGIN_SUFFIX \"$_plugin_suffix\"" + add_line_to_config_mk "PLUGIN_PREFIX := $_plugin_prefix" + add_line_to_config_mk "PLUGIN_SUFFIX := $_plugin_suffix" +fi + + # # Check whether integrated MT-32 emulator support is requested # define_in_config_if_yes "$_mt32emu" 'USE_MT32EMU' +# +# Check whether 16bit color support is requested +# +define_in_config_if_yes "$_16bit" 'USE_RGB_COLOR' # -# Check whether to use optimized ARM asm +# Check whether to enable the (hq) scalers # -define_in_config_if_yes "$_arm_asm" 'USE_ARM_SOUND_ASM' -define_in_config_if_yes "$_arm_asm" 'USE_ARM_SMUSH_ASM' -define_in_config_if_yes "$_arm_asm" 'USE_ARM_GFX_ASM' +if test "$_build_scalers" = no ; then + _build_hq_scalers=no +fi +define_in_config_if_yes "$_build_scalers" 'USE_SCALERS' +define_in_config_if_yes "$_build_hq_scalers" 'USE_HQ_SCALERS' # # Check for math lib @@ -2452,9 +2674,9 @@ echo "$_alsa" echocheck "SEQ MIDI" if test "$_seq_midi" = auto ; then # TODO: Test for /dev/sequencer presence? Or maybe just for /dev ? - # For now, we just always enable it when "unix" mode is on (backends + # For now, we just always enable it when "posix" mode is on (backends # that do not want it can disable it by setting _seq_midi=no). - _seq_midi="$_unix" + _seq_midi="$_posix" fi define_in_config_h_if_yes "$_seq_midi" 'USE_SEQ_MIDI' echo "$_seq_midi" @@ -2467,7 +2689,7 @@ if test "$_timidity" = auto ; then # TODO: Is there a good possibility of auto detecting whether we # should include TiMidity support? It can only be used on Unix # currently so we use that as "detection" for now. - _timidity="$_unix" + _timidity="$_posix" fi define_in_config_h_if_yes "$_timidity" 'USE_TIMIDITY' echo "$_timidity" @@ -2600,7 +2822,7 @@ if test "$_readline" = yes ; then fi define_in_config_h_if_yes "$_readline" 'USE_READLINE' -define_in_config_h_if_yes "$_text_console" 'USE_TEXT_CONSOLE' +define_in_config_h_if_yes "$_text_console" 'USE_TEXT_CONSOLE_FOR_DEBUGGER' # # Check for OpenGL (ES) @@ -2681,6 +2903,7 @@ fi define_in_config_if_yes "$_opengl" "USE_OPENGL" define_in_config_if_yes "$_opengles" "USE_GLES" + # # Check for nasm # @@ -2742,12 +2965,8 @@ define_in_config_if_yes $_nasm 'USE_NASM' # # Enable vkeybd / keymapper # -if test "$_vkeybd" = yes ; then - DEFINES="$DEFINES -DENABLE_VKEYBD" -fi -if test "$_keymapper" = yes ; then - DEFINES="$DEFINES -DENABLE_KEYMAPPER" -fi +define_in_config_if_yes $_vkeybd 'ENABLE_VKEYBD' +define_in_config_if_yes $_keymapper 'ENABLE_KEYMAPPER' # Check whether to build translation support # @@ -2831,24 +3050,16 @@ else fi # -# Backend related stuff +# Some last-minute backend specific stuff, executed +# after all of CXXFLAGS, LDFLAGS, LIBS etc. have been setup # case $_backend in android) - # ssp at this point so the cxxtests link - if test "$_debug_build" = yes; then - CXXFLAGS="$CXXFLAGS -fstack-protector" - else - CXXFLAGS="$CXXFLAGS -fno-stack-protector" - fi - CXXFLAGS="$CXXFLAGS -Wa,--noexecstack" - LDFLAGS="$LDFLAGS -Wl,-z,noexecstack" - static_libs='' system_libs='' for lib in $LIBS; do case $lib in - -lz|-lm) + -lz|-lm|-ldl) system_libs="$system_libs $lib" ;; *) @@ -2860,167 +3071,15 @@ case $_backend in # -lgcc is carefully placed here - we want to catch # all toolchain symbols in *our* libraries rather # than pick up anything unhygenic from the Android libs. - LIBS="-Wl,-Bstatic $static_libs" - LIBS="$LIBS -Wl,-Bdynamic -lgcc $system_libs -llog -lGLESv1_CM" - DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE" - ;; - dc) - INCLUDES="$INCLUDES "'-I$(srcdir)/backends/platform/dc -isystem $(ronindir)/include' - LDFLAGS="$LDFLAGS -Wl,-Ttext,0x8c010000 -nostartfiles "'$(ronindir)/lib/crt0.o -L$(ronindir)/lib' - LIBS="$LIBS -lronin -lm" - ;; - dingux) - find_sdlconfig - INCLUDES="$INCLUDES `$_sdlconfig --prefix="$_sdlpath" --cflags`" - LIBS="$LIBS `$_sdlconfig --prefix="$_sdlpath" --libs`" - DEFINES="$DEFINES -DSDL_BACKEND -DDINGUX" - LDFLAGS="$LDFLAGS " - MODULES="$MODULES backends/platform/sdl" - ;; - ds) - # TODO ds - INCLUDES="$INCLUDES "'-I$(srcdir)/backends/platform/ds/arm9/source' - INCLUDES="$INCLUDES "'-I$(srcdir)/backends/platform/ds/commoninclude' - INCLUDES="$INCLUDES "'-Ibackends/platform/ds/arm9/data' - ;; - gp2x) - find_sdlconfig - INCLUDES="$INCLUDES `$_sdlconfig --prefix="$_sdlpath" --cflags`" - LIBS="$LIBS `$_sdlconfig --prefix="$_sdlpath" --libs`" - LDFLAGS="$LDFLAGS" - DEFINES="$DEFINES -DSDL_BACKEND" - ;; - gph) - find_sdlconfig - INCLUDES="$INCLUDES `$_sdlconfig --prefix="$_sdlpath" --cflags`" - LIBS="$LIBS `$_sdlconfig --prefix="$_sdlpath" --libs`" - LDFLAGS="$LDFLAGS" - DEFINES="$DEFINES -DSDL_BACKEND" - ;; - iphone) - OBJCFLAGS="$OBJCFLAGS --std=c99" - LIBS="$LIBS -lobjc -framework UIKit -framework CoreGraphics -framework OpenGLES -framework QuartzCore -framework GraphicsServices -framework CoreFoundation -framework Foundation -framework AudioToolbox -framework CoreAudio" - ;; - linuxmoto) - find_sdlconfig - INCLUDES="$INCLUDES `$_sdlconfig --prefix="$_sdlpath" --cflags`" - LIBS="$LIBS `$_sdlconfig --prefix="$_sdlpath" --libs`" - DEFINES="$DEFINES -DSDL_BACKEND -DLINUXMOTO" + LIBS="-Wl,-Bstatic $static_libs -Wl,-Bdynamic -lgcc $system_libs -llog -lGLESv1_CM" ;; n64) - INCLUDES="$INCLUDES "'-I$(N64SDK)/include' - INCLUDES="$INCLUDES "'-I$(N64SDK)/mips64/include' - INCLUDES="$INCLUDES "'-I$(N64SDK)/hkz-libn64' - INCLUDES="$INCLUDES "'-I$(srcdir)/backends/platform/n64' - LIBS="$LIBS -lpakfs -lframfs -ln64 -ln64utils -lromfs -lm -lstdc++ -lc -lgcc -lz -lnosys" - ;; - null) - DEFINES="$DEFINES -DUSE_NULL_DRIVER" - ;; - openpandora) - find_sdlconfig - INCLUDES="$INCLUDES `$_sdlconfig --prefix="$_sdlpath" --cflags`" - LIBS="$LIBS `$_sdlconfig --prefix="$_sdlpath" --libs`" - LDFLAGS="$LDFLAGS" - DEFINES="$DEFINES -DSDL_BACKEND" - ;; - ps2) - # TODO ps2 - DEFINES="$DEFINES -D_EE -DFORCE_RTL" - INCLUDES="$INCLUDES -I$PS2SDK/ee/include -I$PS2SDK/common/include -I$PS2SDK/ports/include" - if test "$_dynamic_modules" = no ; then - LDFLAGS="$LDFLAGS -mno-crt0 $PS2SDK/ee/startup/crt0.o -T $PS2SDK/ee/startup/linkfile" - fi - LDFLAGS="$LDFLAGS -L$PS2SDK/ee/lib -L$PS2SDK/ports/lib" - LIBS="$LIBS -lmc -lpad -lmouse -lhdd -lpoweroff -lsjpcm -lm -lc -lfileXio -lkernel -lstdc++ " - ;; - psp) - DEFINES="$DEFINES -D__PSP__ -DDISABLE_COMMAND_LINE -DDISABLE_DOSBOX_OPL" - LIBS="$LIBS -lpng -Wl,-Map,mapfile.txt" - ;; - samsungtv) - find_sdlconfig - INCLUDES="$INCLUDES `$_sdlconfig --prefix="$_sdlpath" --cflags`" - LIBS="$LIBS `$_sdlconfig --prefix="$_sdlpath" --libs`" - DEFINES="$DEFINES -DSDL_BACKEND -DSAMSUNGTV" - LDFLAGS="$LDFLAGS -shared -fpic" - MODULES="$MODULES backends/platform/sdl" - ;; - sdl) - find_sdlconfig - INCLUDES="$INCLUDES `$_sdlconfig --prefix="$_sdlpath" --cflags`" - LIBS="$LIBS `$_sdlconfig --prefix="$_sdlpath" --libs`" - DEFINES="$DEFINES -DSDL_BACKEND" - ;; - webos) - # There is no sdl-config in the WebOS PDK so we don't use find_sdlconfig here. - LIBS="$LIBS -lSDL" - DEFINES="$DEFINES -DSDL_BACKEND -DWEBOS" - MODULES="$MODULES backends/platform/sdl" - ;; - wii) - DEFINES="$DEFINES -D__WII__ -DGEKKO" - case $_host_os in - gamecube) - LIBS="$LIBS -lgxflux -liso9660 -lfat -logc -ldb" - ;; - *) - LIBS="$LIBS -lgxflux -ldi -liso9660 -ltinysmb -lfat -lwiiuse -lbte -logc -lwiikeyboard -ldb" - ;; - esac - ;; - wince) - INCLUDES="$INCLUDES "'-I$(srcdir) -I$(srcdir)/backends/platform/wince -I$(srcdir)/engines -I$(srcdir)/backends/platform/wince/missing/gcc -I$(srcdir)/backends/platform/wince/CEgui -I$(srcdir)/backends/platform/wince/CEkeys' - LIBS="$LIBS -static -lSDL" - DEFINES="$DEFINES -DSDL_BACKEND" - ;; - *) - echo "support for $_backend backend not implemented in configure script yet" - exit 1 + # Move some libs down here, otherwise some symbols requires by libvorbis aren't found + # during linking stage + LIBS="$LIBS -lc -lgcc -lnosys" ;; esac -MODULES="$MODULES backends/platform/$_backend" -# -# Do CXXFLAGS now that we know the compiler version -# -if test "$have_gcc" = yes ; then - if test "$_cxx_major" -ge "3" ; then - case $_host_os in - # newlib-based system include files suppress non-C89 function - # declarations under __STRICT_ANSI__ - amigaos* | android | dreamcast | ds | gamecube | mingw* | n64 | psp | ps2 | wii | wince ) - CXXFLAGS="$CXXFLAGS -W -Wno-unused-parameter" - ;; - *) - CXXFLAGS="$CXXFLAGS -ansi -W -Wno-unused-parameter" - ;; - esac - add_line_to_config_mk 'HAVE_GCC3 = 1' - add_line_to_config_mk 'CXX_UPDATE_DEP_FLAG = -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" -MQ "$@" -MP' - fi; - - if test "$_cxx_major" -eq 4 && test "$_cxx_minor" -ge 3 || \ - test "$_cxx_major" -gt 4 ; then - CXXFLAGS="$CXXFLAGS -Wno-empty-body" - else - CXXFLAGS="$CXXFLAGS -Wconversion" - fi; -elif test "$have_icc" = yes ; then - add_line_to_config_mk 'CXX_UPDATE_DEP_FLAG = -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" -MQ "$@" -MP' -fi; - -# Some platforms use certain GNU extensions in header files -case $_host_os in -android | gamecube | psp | wii) - ;; -*) - # ICC does not support pedantic - if test "$have_icc" = no ; then - CXXFLAGS="$CXXFLAGS -pedantic" - fi - ;; -esac # # Engine selection diff --git a/devtools/create_project/codeblocks/create_project.cbp b/devtools/create_project/codeblocks/create_project.cbp index 25b12d8cc27..1b592d5e96a 100644 --- a/devtools/create_project/codeblocks/create_project.cbp +++ b/devtools/create_project/codeblocks/create_project.cbp @@ -47,6 +47,8 @@ + + diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp index 7b58aae00f4..9e4988a4cf5 100644 --- a/devtools/create_project/create_project.cpp +++ b/devtools/create_project/create_project.cpp @@ -28,11 +28,12 @@ #include "config.h" #include "create_project.h" -#include "codeblocks.h" +#include "codeblocks.h" #include "msvc.h" #include "visualstudio.h" #include "msbuild.h" +#include "xcode.h" #include #include @@ -107,13 +108,14 @@ typedef std::list FileList; enum ProjectType { kProjectNone, kProjectCodeBlocks, - kProjectMSVC + kProjectMSVC, + kProjectXcode }; int main(int argc, char *argv[]) { #ifndef USE_WIN32_API // Initialize random number generator for UUID creation - std::srand(std::time(0)); + std::srand((uint)std::time(0)); #endif if (argc < 2) { @@ -175,6 +177,14 @@ int main(int argc, char *argv[]) { projectType = kProjectMSVC; + } else if (!std::strcmp(argv[i], "--xcode")) { + if (projectType != kProjectNone) { + std::cerr << "ERROR: You cannot pass more than one project type!\n"; + return -1; + } + + projectType = kProjectXcode; + } else if (!std::strcmp(argv[i], "--msvc-version")) { if (i + 1 >= argc) { std::cerr << "ERROR: Missing \"version\" parameter for \"--msvc-version\"!\n"; @@ -463,6 +473,31 @@ int main(int argc, char *argv[]) { provider = new CreateProjectTool::MSBuildProvider(globalWarnings, projectWarnings, msvcVersion); break; + + case kProjectXcode: + //////////////////////////////////////////////////////////////////////////// + // Xcode is also using GCC behind the scenes. See Code::Blocks comment + // for info on all warnings + //////////////////////////////////////////////////////////////////////////// + globalWarnings.push_back("-Wall"); + globalWarnings.push_back("-Wno-long-long"); + globalWarnings.push_back("-Wno-multichar"); + globalWarnings.push_back("-Wno-unknown-pragmas"); + globalWarnings.push_back("-Wno-reorder"); + globalWarnings.push_back("-Wpointer-arith"); + globalWarnings.push_back("-Wcast-qual"); + globalWarnings.push_back("-Wcast-align"); + globalWarnings.push_back("-Wshadow"); + globalWarnings.push_back("-Wimplicit"); + globalWarnings.push_back("-Wnon-virtual-dtor"); + globalWarnings.push_back("-Wwrite-strings"); + // The following are not warnings at all... We should consider adding them to + // a different list of parameters. + globalWarnings.push_back("-fno-exceptions"); + globalWarnings.push_back("-fcheck-new"); + + provider = new CreateProjectTool::XCodeProvider(globalWarnings, projectWarnings); + break; } provider->createProject(setup); @@ -501,6 +536,7 @@ void displayHelp(const char *exe) { "Project specific settings:\n" " --codeblock build Code::Blocks project files\n" " --msvc build Visual Studio project files\n" + " --xcode build XCode project files\n" " --file-prefix prefix allow overwriting of relative file prefix in the\n" " MSVC project files. By default the prefix is the\n" " \"path\\to\\source\" argument\n" @@ -636,7 +672,7 @@ bool setEngineBuildState(const std::string &name, EngineDescList &engines, bool if (engine != engines.end()) { engine->enable = enable; - // When we disable an einge, we also need to disable all the sub engines. + // When we disable an engine, we also need to disable all the sub engines. if (!enable && !engine->subEngines.empty()) { for (StringList::const_iterator j = engine->subEngines.begin(); j != engine->subEngines.end(); ++j) { EngineDescList::iterator subEngine = std::find(engines.begin(), engines.end(), *j); diff --git a/devtools/create_project/module.mk b/devtools/create_project/module.mk index 4238452c5de..0db070fa7c7 100644 --- a/devtools/create_project/module.mk +++ b/devtools/create_project/module.mk @@ -6,11 +6,17 @@ MODULE_OBJS := \ codeblocks.o \ msvc.o \ visualstudio.o \ - msbuild.o + msbuild.o \ + xcode.o # Set the name of the executable TOOL_EXECUTABLE := create_project +# Set custom build flags for create_project.o: It uses C++ iostreams, +# which make use of global constructors. So we don't want warnings for +# that. +$(srcdir)/devtools/create_project/create_project.o: CXXFLAGS:=$(filter-out -Wglobal-constructors,$(CXXFLAGS)) + # Include common rules include $(srcdir)/rules.mk diff --git a/devtools/create_project/msbuild.cpp b/devtools/create_project/msbuild.cpp index f8ce80acfdb..bdbc0a4074d 100644 --- a/devtools/create_project/msbuild.cpp +++ b/devtools/create_project/msbuild.cpp @@ -373,6 +373,7 @@ void MSBuildProvider::createBuildProp(const BuildSetup &setup, bool isRelease, b "\t\t\ttrue\n" "\t\t\tfalse\n" "\t\t\t\n" + "\t\t\tMultiThreaded\n" "\t\t\t" << (enableAnalysis ? "true" : "false") << "\n" "\t\t\n" "\t\t\n" diff --git a/devtools/create_project/msvc10/create_project.vcxproj b/devtools/create_project/msvc10/create_project.vcxproj index bf5e415b5dd..3d7f8fdd3db 100644 --- a/devtools/create_project/msvc10/create_project.vcxproj +++ b/devtools/create_project/msvc10/create_project.vcxproj @@ -58,10 +58,12 @@ MachineX86 - xcopy /Y $(TargetPath) $(SolutionDir)\..\..\..\dists\msvc10\ + @echo off +xcopy /Y $(TargetPath) $(SolutionDir)\..\..\..\dists\msvc10\ xcopy /Y $(TargetPath) $(SolutionDir)\..\..\..\dists\msvc9\ xcopy /Y $(TargetPath) $(SolutionDir)\..\..\..\dists\msvc8\ -xcopy /Y $(TargetPath) $(SolutionDir)\..\..\..\dists\codeblocks\ +xcopy /Y $(TargetPath) $(SolutionDir)\..\..\..\dists\codeblocks\ +xcopy /Y $(TargetPath) $(SolutionDir)\..\..\..\dists\iphone\ @@ -98,6 +100,7 @@ xcopy /Y $(TargetPath) $(SolutionDir)\..\..\..\dists\codeblocks\ + @@ -106,6 +109,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 b5e870824ee..5ecd6c3dde8 100644 --- a/devtools/create_project/msvc10/create_project.vcxproj.filters +++ b/devtools/create_project/msvc10/create_project.vcxproj.filters @@ -27,6 +27,9 @@ Header Files + + Header Files + Header Files @@ -47,6 +50,9 @@ Source Files + + Source Files + diff --git a/devtools/create_project/msvc8/create_project.vcproj b/devtools/create_project/msvc8/create_project.vcproj index 639b23d6e78..6e9e0d5cb03 100644 --- a/devtools/create_project/msvc8/create_project.vcproj +++ b/devtools/create_project/msvc8/create_project.vcproj @@ -184,6 +184,10 @@ RelativePath="..\visualstudio.cpp" > + + + + + + + + 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 +REM xcopy /F /Y "%~1/AUTHORS" %~2 1>NUL 2>&1 +REM xcopy /F /Y "%~1/COPYING.GPL" %~2 1>NUL 2>&1 +REM xcopy /F /Y "%~1/COPYING" %~2 1>NUL 2>&1 +REM xcopy /F /Y "%~1/COPYING.LGPL" %~2 1>NUL 2>&1 +REM xcopy /F /Y "%~1/COPYRIGHT" %~2 1>NUL 2>&1 +REM xcopy /F /Y "%~1/NEWS" %~2 1>NUL 2>&1 +REM xcopy /F /Y "%~1/README" %~2 1>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 +REM xcopy /F /Y "%~1/dists/engine-data/*.dat" %~2 1>NUL 2>&1 +REM xcopy /F /Y "%~1/dists/engine-data/*.tbl" %~2 1>NUL 2>&1 +REM xcopy /F /Y "%~1/dists/engine-data/*.cpt" %~2 1>NUL 2>&1 +REM xcopy /F /Y "%~1/gui/themes/*.zip" %~2 1>NUL 2>&1 +REM xcopy /F /Y "%~1/gui/themes/translations.dat" %~2 1>NUL 2>&1 xcopy /F /Y "%~4/lib/%~3/SDL.dll" "%~2" 1>NUL 2>&1 xcopy /F /Y "%~4/README-SDL" "%~2" 1>NUL 2>&1 diff --git a/devtools/create_project/visualstudio.cpp b/devtools/create_project/visualstudio.cpp index 4fadfd25098..b4c2b46ba4f 100644 --- a/devtools/create_project/visualstudio.cpp +++ b/devtools/create_project/visualstudio.cpp @@ -269,6 +269,7 @@ void VisualStudioProvider::createBuildProp(const BuildSetup &setup, bool isRelea "\t\tStringPooling=\"true\"\n" "\t\tBufferSecurityCheck=\"false\"\n" "\t\tDebugInformationFormat=\"0\"\n" + "\t\tRuntimeLibrary=\"0\"\n" "\t\tAdditionalOption=\"" << (enableAnalysis ? "/analyze" : "") << "\"\n" "\t/>\n" "\t $(srcdir)/AUTHORS +# $(srcdir)/devtools/credits.pl --rtf > $(srcdir)/Credits.rtf + $(srcdir)/devtools/credits.pl --cpp > $(srcdir)/gui/credits.h + $(srcdir)/devtools/credits.pl --xml-website > $(srcdir)/../../web/trunk/data/credits.xml +# $(srcdir)/devtools/credits.pl --xml-docbook > $(srcdir)/../../docs/trunk/docbook/credits.xml + + +.PHONY: clean-devtools devtools credits diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp index 650213d5932..7402c3e37de 100644 --- a/engines/advancedDetector.cpp +++ b/engines/advancedDetector.cpp @@ -20,9 +20,6 @@ * */ -// FIXME: Avoid using printf -#define FORBIDDEN_SYMBOL_EXCEPTION_printf - #include "common/debug.h" #include "common/util.h" #include "common/hash-str.h" @@ -30,7 +27,9 @@ #include "common/macresman.h" #include "common/md5.h" #include "common/config-manager.h" +#include "common/system.h" #include "common/textconsole.h" +#include "common/translation.h" #include "engines/advancedDetector.h" @@ -196,12 +195,10 @@ static void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription * desc["gameid"] = params.singleid; } - if (!(params.flags & kADFlagDontAugmentPreferredTarget)) { - if (!desc.contains("preferredtarget")) - desc["preferredtarget"] = desc["gameid"]; + if (!desc.contains("preferredtarget")) + desc["preferredtarget"] = desc["gameid"]; - desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], realDesc); - } + desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], realDesc); if (params.flags & kADFlagUseExtraAsHint) desc["extra"] = realDesc->extra; @@ -226,7 +223,7 @@ bool cleanupPirated(ADGameDescList &matched) { // We ruled out all variants and now have nothing if (matched.empty()) { - warning("Illegitimate copy of the game detected. We give no support in such cases %d", matched.size()); + warning("Illegitimate game copy detected. We give no support in such cases %d", matched.size()); return true; } @@ -368,14 +365,18 @@ static void reportUnknown(const Common::FSNode &path, const SizeMD5Map &filesSiz // // Might also be helpful to display the full path (for when this is used // from the mass detector). - printf("The game in '%s' seems to be unknown.\n", path.getPath().c_str()); - printf("Please, report the following data to the Residual team along with name\n"); - printf("of the game you tried to add and its version/language/etc.:\n"); + Common::String report = Common::String::format(_("The game in '%s' seems to be unknown."), path.getPath().c_str()) + "\n"; + report += _("Please, report the following data to the Residual team along with name"); + report += "\n"; + report += _("of the game you tried to add and its version/language/etc.:"); + report += "\n"; for (SizeMD5Map::const_iterator file = filesSizeMD5.begin(); file != filesSizeMD5.end(); ++file) - printf(" {\"%s\", 0, \"%s\", %d},\n", file->_key.c_str(), file->_value.md5.c_str(), file->_value.size); + report += Common::String::format(" {\"%s\", 0, \"%s\", %d},\n", file->_key.c_str(), file->_value.md5.c_str(), file->_value.size); - printf("\n"); + report += "\n"; + + g_system->logMessage(LogMessageType::kInfo, report.c_str()); } static ADGameDescList detectGameFilebased(const FileMap &allFiles, const ADParams ¶ms); @@ -628,10 +629,14 @@ static ADGameDescList detectGameFilebased(const FileMap &allFiles, const ADParam if (matchedDesc) { // We got a match matched.push_back(matchedDesc); if (params.flags & kADFlagPrintWarningOnFileBasedFallback) { - printf("Your game version has been detected using filename matching as a\n"); - printf("variant of %s.\n", matchedDesc->gameid); - printf("If this is an original and unmodified version, please report any\n"); - printf("information previously printed by Residual to the team.\n"); + Common::String report = Common::String::format(_("Your game version has been detected using " + "filename matching as a variant of %s."), matchedDesc->gameid); + report += "\n"; + report += _("If this is an original and unmodified version, please report any"); + report += "\n"; + report += _("information previously printed by Residual to the team."); + report += "\n"; + g_system->logMessage(LogMessageType::kInfo, report.c_str()); } } diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h index 6ee0822f47e..408c46556d5 100644 --- a/engines/advancedDetector.h +++ b/engines/advancedDetector.h @@ -100,11 +100,6 @@ struct ADFileBasedFallback { enum ADFlags { - /** - * Generate/augment preferred target with information on the language (if - * not equal to english) and platform (if not equal to PC). - */ - kADFlagDontAugmentPreferredTarget = (1 << 0), /** * Warn user about new variant if his version was detected with fallback */ diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp index 107f0d736c9..90b2fe95043 100644 --- a/engines/dialogs.cpp +++ b/engines/dialogs.cpp @@ -227,11 +227,11 @@ void MainMenuDialog::save() { Common::String result(_saveDialog->getResultString()); if (result.empty()) { // If the user was lazy and entered no save name, come up with a default name. - char buf[20]; - snprintf(buf, 20, "Save %d", slot + 1); + Common::String buf; + buf = Common::String::format("Save %d", slot + 1); _engine->saveGameState(slot, buf); } else { - _engine->saveGameState(slot, result.c_str()); + _engine->saveGameState(slot, result); } close(); diff --git a/engines/engine.cpp b/engines/engine.cpp index b76c3158792..ec8306d998d 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -310,7 +310,7 @@ bool Engine::canLoadGameStateCurrently() { return false; } -Common::Error Engine::saveGameState(int slot, const char *desc) { +Common::Error Engine::saveGameState(int slot, const Common::String &desc) { // Do nothing by default return Common::kNoError; } diff --git a/engines/engine.h b/engines/engine.h index 375df2b0a35..d7d971ad97f 100644 --- a/engines/engine.h +++ b/engines/engine.h @@ -196,7 +196,7 @@ public: * @param desc a description for the savestate, entered by the user * @return returns kNoError on success, else an error code. */ - virtual Common::Error saveGameState(int slot, const char *desc); + virtual Common::Error saveGameState(int slot, const Common::String &desc); /** * Indicates whether a game state can be saved. diff --git a/engines/grim/gfx_opengl.h b/engines/grim/gfx_opengl.h index 3f9c2b9f02c..0ddfd431786 100644 --- a/engines/grim/gfx_opengl.h +++ b/engines/grim/gfx_opengl.h @@ -29,6 +29,7 @@ #if defined (SDL_BACKEND) && !defined(__amigaos4__) #include +#undef ARRAYSIZE #else #include #include diff --git a/engines/grim/grim.cpp b/engines/grim/grim.cpp index 38029074a10..3e1cf674560 100644 --- a/engines/grim/grim.cpp +++ b/engines/grim/grim.cpp @@ -30,6 +30,8 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_getwd #define FORBIDDEN_SYMBOL_EXCEPTION_mkdir #define FORBIDDEN_SYMBOL_EXCEPTION_unlink +#define FORBIDDEN_SYMBOL_EXCEPTION_stderr +#define FORBIDDEN_SYMBOL_EXCEPTION_stdin #if defined(WIN32) #include diff --git a/engines/grim/lua/ldo.cpp b/engines/grim/lua/ldo.cpp index d14beb26a82..469c48d2a13 100644 --- a/engines/grim/lua/ldo.cpp +++ b/engines/grim/lua/ldo.cpp @@ -6,6 +6,8 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_setjmp #define FORBIDDEN_SYMBOL_EXCEPTION_longjmp #define FORBIDDEN_SYMBOL_EXCEPTION_fprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_stderr +#define FORBIDDEN_SYMBOL_EXCEPTION_exit #ifdef _MSC_VER #pragma warning(disable:4611) diff --git a/engines/grim/lua/liolib.cpp b/engines/grim/lua/liolib.cpp index 0a3adf1051b..de0a9cc0c6b 100644 --- a/engines/grim/lua/liolib.cpp +++ b/engines/grim/lua/liolib.cpp @@ -11,6 +11,10 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_fread #define FORBIDDEN_SYMBOL_EXCEPTION_fwrite #define FORBIDDEN_SYMBOL_EXCEPTION_fseek +#define FORBIDDEN_SYMBOL_EXCEPTION_stderr +#define FORBIDDEN_SYMBOL_EXCEPTION_stdin +#define FORBIDDEN_SYMBOL_EXCEPTION_stdout +#define FORBIDDEN_SYMBOL_EXCEPTION_exit #include "common/savefile.h" #include "common/fs.h" diff --git a/engines/grim/lua/ltm.cpp b/engines/grim/lua/ltm.cpp index 5509bd9cbeb..7211385dfc2 100644 --- a/engines/grim/lua/ltm.cpp +++ b/engines/grim/lua/ltm.cpp @@ -6,6 +6,7 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_setjmp #define FORBIDDEN_SYMBOL_EXCEPTION_longjmp #define FORBIDDEN_SYMBOL_EXCEPTION_fprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_stderr #include "engines/grim/lua/lauxlib.h" #include "engines/grim/lua/lmem.h" diff --git a/engines/grim/lua_v1_text.cpp b/engines/grim/lua_v1_text.cpp index 8a5e7cfec7c..11527dffa48 100644 --- a/engines/grim/lua_v1_text.cpp +++ b/engines/grim/lua_v1_text.cpp @@ -22,6 +22,8 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_fprintf #define FORBIDDEN_SYMBOL_EXCEPTION_fgetc +#define FORBIDDEN_SYMBOL_EXCEPTION_stderr +#define FORBIDDEN_SYMBOL_EXCEPTION_stdin #include "engines/grim/grim.h" #include "engines/grim/lua.h" diff --git a/engines/savestate.cpp b/engines/savestate.cpp index 9ed8356d3be..551c39b8804 100644 --- a/engines/savestate.cpp +++ b/engines/savestate.cpp @@ -52,20 +52,20 @@ void SaveStateDescriptor::setWriteProtectedFlag(bool state) { } void SaveStateDescriptor::setSaveDate(int year, int month, int day) { - char buffer[32]; - snprintf(buffer, 32, "%.2d.%.2d.%.4d", day, month, year); + Common::String buffer; + buffer = Common::String::format("%.2d.%.2d.%.4d", day, month, year); setVal("save_date", buffer); } void SaveStateDescriptor::setSaveTime(int hour, int min) { - char buffer[32]; - snprintf(buffer, 32, "%.2d:%.2d", hour, min); + Common::String buffer; + buffer = Common::String::format("%.2d:%.2d", hour, min); setVal("save_time", buffer); } void SaveStateDescriptor::setPlayTime(int hours, int minutes) { - char buffer[32]; - snprintf(buffer, 32, "%.2d:%.2d", hours, minutes); + Common::String buffer; + buffer = Common::String::format("%.2d:%.2d", hours, minutes); setVal("play_time", buffer); } diff --git a/engines/savestate.h b/engines/savestate.h index ce78bc4ba38..df017320584 100644 --- a/engines/savestate.h +++ b/engines/savestate.h @@ -49,9 +49,7 @@ public: } SaveStateDescriptor(int s, const Common::String &d) : _thumbnail() { - char buf[16]; - sprintf(buf, "%d", s); - setVal("save_slot", buf); + setVal("save_slot", Common::String::format("%d", s)); setVal("description", d); } diff --git a/graphics/cursorman.h b/graphics/cursorman.h index 1e7ce836119..543a5d0a5c3 100644 --- a/graphics/cursorman.h +++ b/graphics/cursorman.h @@ -108,9 +108,9 @@ public: * Test whether cursor palettes are supported. * * This is just an convenience wrapper for checking for - * OSystem::kFeatureCursorHasPalette to be supported by OSystem. + * OSystem::kFeatureCursorPalette to be supported by OSystem. * - * @see OSystem::kFeatureCursorHasPalette + * @see OSystem::kFeatureCursorPalette * @see OSystem::hasFeature */ bool supportsCursorPalettes(); diff --git a/graphics/font.cpp b/graphics/font.cpp index 5f5a9b2fcaf..cdf90906252 100644 --- a/graphics/font.cpp +++ b/graphics/font.cpp @@ -30,23 +30,23 @@ namespace Graphics { -void free_font(NewFontData* pf); +void free_font(NewFontData *pf); NewFont::~NewFont() { - if (font) { - free_font(font); + if (_font) { + free_font(_font); } } int NewFont::getCharWidth(byte chr) const { // If no width table is specified, return the maximum width - if (!desc.width) - return desc.maxwidth; + if (!_desc.width) + return _desc.maxwidth; // If this character is not included in the font, use the default char. - if (chr < desc.firstchar || desc.firstchar + desc.size < chr) { - chr = desc.defaultchar; + if (chr < _desc.firstchar || _desc.firstchar + _desc.size < chr) { + chr = _desc.defaultchar; } - return desc.width[chr - desc.firstchar]; + return _desc.width[chr - _desc.firstchar]; } @@ -74,38 +74,38 @@ void drawCharIntern(byte *ptr, uint pitch, const bitmap_t *src, int h, int minX, void NewFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const uint32 color) const { assert(dst != 0); - assert(desc.bits != 0 && desc.maxwidth <= 16); + assert(_desc.bits != 0 && _desc.maxwidth <= 16); 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) { - chr = desc.defaultchar; + if (chr < _desc.firstchar || chr >= _desc.firstchar + _desc.size) { + chr = _desc.defaultchar; } - chr -= desc.firstchar; + chr -= _desc.firstchar; int bbw, bbh, bbx, bby; // Get the bounding box of the character - if (!desc.bbx) { - bbw = desc.fbbw; - bbh = desc.fbbh; - bbx = desc.fbbx; - bby = desc.fbby; + if (!_desc.bbx) { + bbw = _desc.fbbw; + bbh = _desc.fbbh; + bbx = _desc.fbbx; + bby = _desc.fbby; } else { - bbw = desc.bbx[chr].w; - bbh = desc.bbx[chr].h; - bbx = desc.bbx[chr].x; - bby = desc.bbx[chr].y; + bbw = _desc.bbx[chr].w; + bbh = _desc.bbx[chr].h; + bbx = _desc.bbx[chr].x; + bby = _desc.bbx[chr].y; } - byte *ptr = (byte *)dst->getBasePtr(tx + bbx, ty + desc.ascent - bby - bbh); + byte *ptr = (byte *)dst->getBasePtr(tx + bbx, ty + _desc.ascent - bby - bbh); - const bitmap_t *tmp = desc.bits + (desc.offset ? desc.offset[chr] : (chr * desc.fbbh)); + const bitmap_t *tmp = _desc.bits + (_desc.offset ? _desc.offset[chr] : (chr * _desc.fbbh)); - int y = MIN(bbh, ty + desc.ascent - bby); + int y = MIN(bbh, ty + _desc.ascent - bby); tmp += bbh - y; - y -= MAX(0, ty + desc.ascent - bby - dst->h); + y -= MAX(0, ty + _desc.ascent - bby - dst->h); if (dst->format.bytesPerPixel == 1) drawCharIntern(ptr, dst->pitch, tmp, y, MAX(0, -(tx + bbx)), MIN(bbw, dst->w - tx - bbx), color); @@ -615,47 +615,47 @@ bool NewFont::cacheFontData(const NewFont &font, const Common::String &filename) return false; } - cacheFile.writeUint16BE(font.desc.maxwidth); - cacheFile.writeUint16BE(font.desc.height); - cacheFile.writeUint16BE(font.desc.fbbw); - cacheFile.writeUint16BE(font.desc.fbbh); - cacheFile.writeSint16BE(font.desc.fbbx); - cacheFile.writeSint16BE(font.desc.fbby); - cacheFile.writeUint16BE(font.desc.ascent); - cacheFile.writeUint16BE(font.desc.firstchar); - cacheFile.writeUint16BE(font.desc.size); - cacheFile.writeUint16BE(font.desc.defaultchar); - cacheFile.writeUint32BE(font.desc.bits_size); + cacheFile.writeUint16BE(font._desc.maxwidth); + cacheFile.writeUint16BE(font._desc.height); + cacheFile.writeUint16BE(font._desc.fbbw); + cacheFile.writeUint16BE(font._desc.fbbh); + cacheFile.writeSint16BE(font._desc.fbbx); + cacheFile.writeSint16BE(font._desc.fbby); + cacheFile.writeUint16BE(font._desc.ascent); + cacheFile.writeUint16BE(font._desc.firstchar); + cacheFile.writeUint16BE(font._desc.size); + cacheFile.writeUint16BE(font._desc.defaultchar); + cacheFile.writeUint32BE(font._desc.bits_size); - for (long i = 0; i < font.desc.bits_size; ++i) { - cacheFile.writeUint16BE(font.desc.bits[i]); + for (long i = 0; i < font._desc.bits_size; ++i) { + cacheFile.writeUint16BE(font._desc.bits[i]); } - if (font.desc.offset) { + if (font._desc.offset) { cacheFile.writeByte(1); - for (int i = 0; i < font.desc.size; ++i) { - cacheFile.writeUint32BE(font.desc.offset[i]); + for (int i = 0; i < font._desc.size; ++i) { + cacheFile.writeUint32BE(font._desc.offset[i]); } } else { cacheFile.writeByte(0); } - if (font.desc.width) { + if (font._desc.width) { cacheFile.writeByte(1); - for (int i = 0; i < font.desc.size; ++i) { - cacheFile.writeByte(font.desc.width[i]); + for (int i = 0; i < font._desc.size; ++i) { + cacheFile.writeByte(font._desc.width[i]); } } else { cacheFile.writeByte(0); } - if (font.desc.bbx) { + if (font._desc.bbx) { cacheFile.writeByte(1); - for (int i = 0; i < font.desc.size; ++i) { - cacheFile.writeByte(font.desc.bbx[i].w); - cacheFile.writeByte(font.desc.bbx[i].h); - cacheFile.writeByte(font.desc.bbx[i].x); - cacheFile.writeByte(font.desc.bbx[i].y); + for (int i = 0; i < font._desc.size; ++i) { + cacheFile.writeByte(font._desc.bbx[i].w); + cacheFile.writeByte(font._desc.bbx[i].h); + cacheFile.writeByte(font._desc.bbx[i].x); + cacheFile.writeByte(font._desc.bbx[i].y); } } else { cacheFile.writeByte(0); diff --git a/graphics/font.h b/graphics/font.h index f68f49175f9..dc75f86e1f3 100644 --- a/graphics/font.h +++ b/graphics/font.h @@ -114,18 +114,6 @@ public: int wordWrapText(const Common::String &str, int maxWidth, Common::Array &lines) const; }; -/** - * A SCUMM style font. - */ -class ScummFont : public Font { -public: - virtual int getFontHeight() const { return 8; } - virtual int getMaxCharWidth() const { return 8; } - - virtual int getCharWidth(byte chr) const; - virtual void drawChar(Surface *dst, byte chr, int x, int y, uint32 color) const; -}; - typedef uint16 bitmap_t; /* bitmap image unit size*/ struct BBX { @@ -157,15 +145,15 @@ struct NewFontData; class NewFont : public Font { protected: - FontDesc desc; - NewFontData *font; + FontDesc _desc; + NewFontData *_font; public: - NewFont(const FontDesc &d, NewFontData *font_ = 0) : desc(d), font(font_) {} + NewFont(const FontDesc &desc, NewFontData *font = 0) : _desc(desc), _font(font) {} ~NewFont(); - virtual int getFontHeight() const { return desc.height; } - virtual int getMaxCharWidth() const { return desc.maxwidth; } + virtual int getFontHeight() const { return _desc.height; } + virtual int getMaxCharWidth() const { return _desc.maxwidth; } virtual int getCharWidth(byte chr) const; virtual void drawChar(Surface *dst, byte chr, int x, int y, uint32 color) const; diff --git a/graphics/fontman.cpp b/graphics/fontman.cpp index f937e55b69e..f40cf976029 100644 --- a/graphics/fontman.cpp +++ b/graphics/fontman.cpp @@ -21,12 +21,12 @@ #include "graphics/font.h" #include "graphics/fontman.h" +#include "common/translation.h" DECLARE_SINGLETON(Graphics::FontManager); namespace Graphics { -const ScummFont *g_scummfont = 0; FORWARD_DECLARE_FONT(g_sysfont); FORWARD_DECLARE_FONT(g_sysfont_big); FORWARD_DECLARE_FONT(g_consolefont); @@ -34,18 +34,15 @@ FORWARD_DECLARE_FONT(g_consolefont); FontManager::FontManager() { // This assert should *never* trigger, because // FontManager is a singleton, thus there is only - // one instance of it per time. (g_scummfont gets + // one instance of it per time. (g_sysfont gets // reset to 0 in the desctructor of this class). - assert(g_scummfont == 0); - g_scummfont = new ScummFont; + assert(g_sysfont == 0); INIT_FONT(g_sysfont); INIT_FONT(g_sysfont_big); INIT_FONT(g_consolefont); } FontManager::~FontManager() { - delete g_scummfont; - g_scummfont = 0; delete g_sysfont; g_sysfont = 0; delete g_sysfont_big; @@ -58,7 +55,6 @@ const struct { const char *name; FontManager::FontUsage id; } builtinFontNames[] = { - { "builtinOSD", FontManager::kOSDFont }, { "builtinConsole", FontManager::kConsoleFont }, { "fixed5x8.bdf", FontManager::kConsoleFont }, { "fixed5x8-iso-8859-1.bdf", FontManager::kConsoleFont }, @@ -69,32 +65,112 @@ const struct { { "helvB12.bdf", FontManager::kBigGUIFont }, { "helvB12-iso-8859-1.bdf", FontManager::kBigGUIFont }, { "helvB12-ascii.bdf", FontManager::kBigGUIFont }, - { 0, FontManager::kOSDFont } + { 0, FontManager::kConsoleFont } }; +bool FontManager::assignFontToName(const Common::String &name, const Font *font) { + Common::String lowercaseName = name; + lowercaseName.toLowercase(); + _fontMap[lowercaseName] = font; + return true; +} + +void FontManager::removeFontName(const Common::String &name) { + Common::String lowercaseName = name; + lowercaseName.toLowercase(); + _fontMap.erase(lowercaseName); +} + const Font *FontManager::getFontByName(const Common::String &name) const { for (int i = 0; builtinFontNames[i].name; i++) if (!scumm_stricmp(name.c_str(), builtinFontNames[i].name)) return getFontByUsage(builtinFontNames[i].id); - if (!_fontMap.contains(name)) + Common::String lowercaseName = name; + lowercaseName.toLowercase(); + if (!_fontMap.contains(lowercaseName)) return 0; - return _fontMap[name]; + return _fontMap[lowercaseName]; } const Font *FontManager::getFontByUsage(FontUsage usage) const { switch (usage) { - case kOSDFont: - return g_scummfont; case kConsoleFont: return g_consolefont; case kGUIFont: return g_sysfont; case kBigGUIFont: return g_sysfont_big; + case kLocalizedFont: + { + // First try to find a kBigGUIFont + Common::String fontName = getLocalizedFontNameByUsage(kBigGUIFont); + if (!fontName.empty()) { + const Font *font = getFontByName(fontName); + if (font) + return font; + } + // Try kGUIFont + fontName = getLocalizedFontNameByUsage(kGUIFont); + if (!fontName.empty()) { + const Font *font = getFontByName(fontName); + if (font) + return font; + } +#ifdef USE_TRANSLATION + // Accept any other font that has the charset in its name + for (Common::HashMap::const_iterator it = _fontMap.begin() ; it != _fontMap.end() ; ++it) { + if (it->_key.contains(TransMan.getCurrentCharset())) + return it->_value; + } +#endif + // Fallback: return a non localized kGUIFont. + // Maybe we should return a null pointer instead? + return g_sysfont; + } } return 0; } +Common::String FontManager::getLocalizedFontNameByUsage(FontUsage usage) const { + // We look for a name that matches the usage and that ends in .bdf. + // It should also not contain "-ascii" or "-iso-" in its name. + // We take the first name that matches. + for (int i = 0; builtinFontNames[i].name; i++) { + if (builtinFontNames[i].id == usage) { + Common::String fontName(builtinFontNames[i].name); + if (!fontName.contains("-ascii") && !fontName.contains("-iso-") && fontName.contains(".bdf")) + return genLocalizedFontFilename(fontName); + } + } + return Common::String(); +} + +Common::String FontManager::genLocalizedFontFilename(const Common::String &filename) const { +#ifndef USE_TRANSLATION + return filename; +#else + // 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! + + // 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; + + // Put the translated font filename string back together. + Common::String result(filename.begin(), dot); + result += '-'; + result += TransMan.getCurrentCharset(); + result += dot; + + return result; +#endif +} + } // End of namespace Graphics diff --git a/graphics/fontman.h b/graphics/fontman.h index d3b84ffa7ca..858a733d45e 100644 --- a/graphics/fontman.h +++ b/graphics/fontman.h @@ -36,7 +36,7 @@ class Font; class FontManager : public Common::Singleton { public: enum FontUsage { - kOSDFont = 0, + kLocalizedFont = 0, kConsoleFont = 1, kGUIFont = 2, kBigGUIFont = 3 @@ -57,14 +57,14 @@ public: * @param font the font object * @return true on success, false on failure */ - bool assignFontToName(const Common::String &name, const Font *font) { _fontMap[name] = font; return true; } + bool assignFontToName(const Common::String &name, const Font *font); /** * Removes binding from name to font * * @param name name which should be removed */ - void removeFontName(const Common::String &name) { _fontMap.erase(name); } + void removeFontName(const Common::String &name); /** * Retrieve a font object based on what it is supposed @@ -75,8 +75,26 @@ public: */ const Font *getFontByUsage(FontUsage usage) const; + /** + * Get the localized font for the current TranslationManager charset from the + * non localized font name + * + * @param filename the non-localized font file name. + * @return The localized font file name. + */ + Common::String genLocalizedFontFilename(const Common::String &filename) const; + //const Font *getFontBySize(int size???) const; +protected: + /** + * Get the name of the localized font for the given usage. There is no garanty that + * the font exists. If the usage is kLocalizedFont it returns an empty string. + * + * @param usage a FontUsage enum value indicating what the font will be used for. + * @return the name of a localized font or an empty string if no suitable font was found. + */ + Common::String getLocalizedFontNameByUsage(FontUsage usage) const; private: friend class Common::Singleton; diff --git a/graphics/fonts/scummfont.cpp b/graphics/fonts/scummfont.cpp deleted file mode 100644 index 1ff1e51fdc1..00000000000 --- a/graphics/fonts/scummfont.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/* 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. - */ - -#include "graphics/font.h" -#include "graphics/surface.h" - -namespace Graphics { - -// Built-in font -static const byte guifont[] = { - // Header - 0, 0, 99, 1, 226, 8, - // Character width table - 4, 8, 6, 8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8, 2, 1, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 3, 7, 8, 7, 7, 8, 4, 5, 5, 8, 7, 4, 7, 3, 8, - 7, 7, 7, 7, 8, 7, 7, 7, 7, 7, 3, 4, 7, 5, 7, 7, - 8, 7, 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 8, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 8, 7, 7, 7, 5, 8, 5, 8, 8, - 7, 7, 7, 6, 7, 7, 7, 7, 7, 5, 6, 7, 5, 8, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 8, 7, 7, 7, 5, 3, 5, 7, 8, - 7, 7, 7, 7, 7, 7, 0, 6, 7, 7, 7, 5, 5, 5, 7, 0, - 6, 8, 8, 7, 7, 7, 7, 7, 0, 7, 7, 0, 0, 0, 0, 0, - 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 7, - // Character table - 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 1, 3, 6, 12, 24, 62, 3, 0, // 1 - 128, 192, 96, 48, 24, 124, 192, 0, // 2 - 0, 3, 62, 24, 12, 6, 3, 1, // 3 - 0, 192, 124, 24, 48, 96, 192, 128, // 4 - 0, 0, 0, 0, 0, 0, 0, 0, // 5 - 0, 0, 0, 0, 0, 0, 0, 0, // 6 - 0, 0, 0, 0, 0, 0, 0, 0, // 7 - 0, 0, 0, 0, 0, 0, 0, 0, // 8 - 0, 0, 0, 0, 0, 0, 0, 0, // 9 - 0, 0, 0, 0, 0, 0, 0, 0, // 10 - 0, 0, 0, 0, 0, 0, 0, 0, // 11 - 0, 0, 0, 0, 0, 0, 0, 0, // 12 - 0, 0, 0, 0, 0, 0, 0, 0, // 13 - 0, 0, 0, 0, 0, 0, 0, 0, // 14 - 0, 0, 0, 0, 0, 0, 0, 0, // 15 - 237, 74, 72, 0, 0, 0, 0, 0, // 16 - 128, 128, 128, 0, 0, 0, 0, 0, // 17 - 0, 0, 0, 0, 0, 0, 0, 0, // 18 - 60, 66, 153, 161, 161, 153, 66, 60, // 19 - 0, 0, 0, 0, 0, 0, 0, 0, // 20 - 0, 0, 0, 0, 0, 0, 0, 0, // 21 - 0, 0, 0, 0, 0, 0, 0, 0, // 22 - 0, 0, 0, 0, 0, 0, 0, 0, // 23 - 0, 0, 0, 0, 0, 0, 0, 0, // 24 - 0, 0, 0, 0, 0, 0, 0, 0, // 25 - 0, 0, 0, 0, 0, 0, 0, 0, // 26 - 0, 0, 0, 0, 0, 0, 0, 0, // 27 - 0, 0, 0, 0, 0, 0, 0, 0, // 28 - 0, 0, 0, 0, 0, 0, 0, 0, // 29 - 0, 0, 0, 0, 0, 0, 0, 0, // 30 - 0, 0, 0, 0, 0, 0, 0, 0, // 31 - 0, 0, 0, 0, 0, 0, 0, 0, // 32 - 96, 96, 96, 96, 0, 0, 96, 0, // 33 - 102, 102, 102, 0, 0, 0, 0, 0, // 34 - 102, 102, 255, 102, 255, 102, 102, 0, // 35 - 24, 62, 96, 60, 6, 124, 24, 0, // 36 - 98, 102, 12, 24, 48, 102, 70, 0, // 37 - 60, 102, 60, 56, 103, 102, 63, 0, // 38 - 96, 48, 16, 0, 0, 0, 0, 0, // 39 - 24, 48, 96, 96, 96, 48, 24, 0, // 40 - 96, 48, 24, 24, 24, 48, 96, 0, // 41 - 0, 102, 60, 255, 60, 102, 0, 0, // 42 - 0, 24, 24, 126, 24, 24, 0, 0, // 43 - 0, 0, 0, 0, 0, 48, 48, 96, // 44 - 0, 0, 0, 126, 0, 0, 0, 0, // 45 - 0, 0, 0, 0, 0, 96, 96, 0, // 46 - 0, 3, 6, 12, 24, 48, 96, 0, // 47 - 60, 102, 102, 102, 102, 102, 60, 0, // 48 - 24, 24, 56, 24, 24, 24, 126, 0, // 49 - 60, 102, 6, 12, 48, 96, 126, 0, // 50 - 60, 102, 6, 28, 6, 102, 60, 0, // 51 - 6, 14, 30, 102, 127, 6, 6, 0, // 52 - 126, 96, 124, 6, 6, 102, 60, 0, // 53 - 60, 102, 96, 124, 102, 102, 60, 0, // 54 - 126, 102, 12, 24, 24, 24, 24, 0, // 55 - 60, 102, 102, 60, 102, 102, 60, 0, // 56 - 60, 102, 102, 62, 6, 102, 60, 0, // 57 - 0, 0, 96, 0, 0, 96, 0, 0, // 58 - 0, 0, 48, 0, 0, 48, 48, 96, // 59 - 14, 24, 48, 96, 48, 24, 14, 0, // 60 - 0, 0, 120, 0, 120, 0, 0, 0, // 61 - 112, 24, 12, 6, 12, 24, 112, 0, // 62 - 60, 102, 6, 12, 24, 0, 24, 0, // 63 - 0, 0, 0, 255, 255, 0, 0, 0, // 64 - 24, 60, 102, 126, 102, 102, 102, 0, // 65 - 124, 102, 102, 124, 102, 102, 124, 0, // 66 - 60, 102, 96, 96, 96, 102, 60, 0, // 67 - 120, 108, 102, 102, 102, 108, 120, 0, // 68 - 126, 96, 96, 120, 96, 96, 126, 0, // 69 - 126, 96, 96, 120, 96, 96, 96, 0, // 70 - 60, 102, 96, 110, 102, 102, 60, 0, // 71 - 102, 102, 102, 126, 102, 102, 102, 0, // 72 - 120, 48, 48, 48, 48, 48, 120, 0, // 73 - 30, 12, 12, 12, 12, 108, 56, 0, // 74 - 102, 108, 120, 112, 120, 108, 102, 0, // 75 - 96, 96, 96, 96, 96, 96, 126, 0, // 76 - 99, 119, 127, 107, 99, 99, 99, 0, // 77 - 102, 118, 126, 126, 110, 102, 102, 0, // 78 - 60, 102, 102, 102, 102, 102, 60, 0, // 79 - 124, 102, 102, 124, 96, 96, 96, 0, // 80 - 60, 102, 102, 102, 102, 60, 14, 0, // 81 - 124, 102, 102, 124, 120, 108, 102, 0, // 82 - 60, 102, 96, 60, 6, 102, 60, 0, // 83 - 126, 24, 24, 24, 24, 24, 24, 0, // 84 - 102, 102, 102, 102, 102, 102, 60, 0, // 85 - 102, 102, 102, 102, 102, 60, 24, 0, // 86 - 99, 99, 99, 107, 127, 119, 99, 0, // 87 - 102, 102, 60, 24, 60, 102, 102, 0, // 88 - 102, 102, 102, 60, 24, 24, 24, 0, // 89 - 126, 6, 12, 24, 48, 96, 126, 0, // 90 - 120, 96, 96, 96, 96, 96, 120, 0, // 91 - 3, 6, 12, 24, 48, 96, 192, 0, // 92 - 120, 24, 24, 24, 24, 24, 120, 0, // 93 - 0, 0, 0, 0, 0, 219, 219, 0, // 94 - 0, 0, 0, 0, 0, 0, 0, 255, // 95 - 102, 102, 102, 0, 0, 0, 0, 0, // 96 - 0, 0, 60, 6, 62, 102, 62, 0, // 97 - 0, 96, 96, 124, 102, 102, 124, 0, // 98 - 0, 0, 60, 96, 96, 96, 60, 0, // 99 - 0, 6, 6, 62, 102, 102, 62, 0, // 100 - 0, 0, 60, 102, 126, 96, 60, 0, // 101 - 0, 14, 24, 62, 24, 24, 24, 0, // 102 - 0, 0, 62, 102, 102, 62, 6, 124, // 103 - 0, 96, 96, 124, 102, 102, 102, 0, // 104 - 0, 48, 0, 112, 48, 48, 120, 0, // 105 - 0, 12, 0, 12, 12, 12, 12, 120, // 106 - 0, 96, 96, 108, 120, 108, 102, 0, // 107 - 0, 112, 48, 48, 48, 48, 120, 0, // 108 - 0, 0, 102, 127, 127, 107, 99, 0, // 109 - 0, 0, 124, 102, 102, 102, 102, 0, // 110 - 0, 0, 60, 102, 102, 102, 60, 0, // 111 - 0, 0, 124, 102, 102, 124, 96, 96, // 112 - 0, 0, 62, 102, 102, 62, 6, 6, // 113 - 0, 0, 124, 102, 96, 96, 96, 0, // 114 - 0, 0, 62, 96, 60, 6, 124, 0, // 115 - 0, 24, 126, 24, 24, 24, 14, 0, // 116 - 0, 0, 102, 102, 102, 102, 62, 0, // 117 - 0, 0, 102, 102, 102, 60, 24, 0, // 118 - 0, 0, 99, 107, 127, 62, 54, 0, // 119 - 0, 0, 102, 60, 24, 60, 102, 0, // 120 - 0, 0, 102, 102, 102, 62, 12, 120, // 121 - 0, 0, 126, 12, 24, 48, 126, 0, // 122 - 24, 48, 48, 96, 48, 48, 24, 0, // 123 - 96, 96, 96, 0, 96, 96, 96, 0, // 124 - 96, 48, 48, 24, 48, 48, 96, 0, // 125 - 0, 0, 97, 153, 134, 0, 0, 0, // 126 - 8, 12, 14, 255, 255, 14, 12, 8, // 127 - 60, 102, 96, 96, 102, 60, 24, 56, // 128 - 102, 0, 102, 102, 102, 102, 62, 0, // 129 - 12, 24, 60, 102, 126, 96, 60, 0, // 130 - 24, 36, 60, 6, 62, 102, 62, 0, // 131 - 102, 0, 60, 6, 62, 102, 62, 0, // 132 - 48, 24, 60, 6, 62, 102, 62, 0, // 133 - 0, 0, 0, 0, 0, 0, 0, 0, // 134 - 0, 60, 96, 96, 96, 60, 24, 56, // 135 - 24, 36, 60, 102, 126, 96, 60, 0, // 136 - 102, 0, 60, 102, 126, 96, 60, 0, // 137 - 48, 24, 60, 102, 126, 96, 60, 0, // 138 - 0, 216, 0, 112, 48, 48, 120, 0, // 139 - 48, 72, 0, 112, 48, 48, 120, 0, // 140 - 96, 48, 0, 112, 48, 48, 120, 0, // 141 - 102, 24, 60, 102, 126, 102, 102, 0, // 142 - 0, 0, 0, 0, 0, 0, 0, 0, // 143 - 24, 48, 124, 96, 120, 96, 124, 0, // 144 - 0, 0, 108, 26, 126, 216, 110, 0, // 145 - 30, 40, 40, 126, 72, 136, 142, 0, // 146 - 24, 36, 60, 102, 102, 102, 60, 0, // 147 - 102, 0, 60, 102, 102, 102, 60, 0, // 148 - 48, 24, 60, 102, 102, 102, 60, 0, // 149 - 24, 36, 0, 102, 102, 102, 62, 0, // 150 - 48, 24, 102, 102, 102, 102, 62, 0, // 151 - 0, 0, 0, 0, 0, 0, 0, 0, // 152 - 102, 60, 102, 102, 102, 102, 60, 0, // 153 - 102, 0, 102, 102, 102, 102, 60, 0, // 154 - 0, 0, 0, 0, 0, 0, 0, 0, // 155 - 0, 0, 0, 0, 0, 0, 0, 0, // 156 - 0, 0, 0, 0, 0, 0, 0, 0, // 157 - 0, 0, 0, 0, 0, 0, 0, 0, // 158 - 0, 0, 0, 0, 0, 0, 0, 0, // 159 - 12, 24, 60, 6, 62, 102, 62, 0, // 160 - 0, 0, 0, 0, 0, 0, 0, 0, // 161 - 0, 0, 0, 0, 0, 0, 0, 0, // 162 - 0, 0, 0, 0, 0, 0, 0, 0, // 163 - 0, 0, 0, 0, 0, 0, 0, 0, // 164 - 0, 0, 0, 0, 0, 0, 0, 0, // 165 - 0, 0, 0, 0, 0, 0, 0, 0, // 166 - 0, 0, 0, 0, 0, 0, 0, 0, // 167 - 0, 0, 0, 0, 0, 0, 0, 0, // 168 - 0, 0, 0, 0, 0, 0, 0, 0, // 169 - 0, 0, 0, 0, 0, 0, 0, 0, // 170 - 0, 0, 0, 0, 0, 0, 0, 0, // 171 - 0, 0, 0, 0, 0, 0, 0, 0, // 172 - 0, 0, 0, 0, 0, 0, 0, 0, // 173 - 0, 0, 0, 0, 0, 0, 0, 0, // 174 - 0, 0, 0, 0, 0, 0, 0, 0, // 175 - 0, 0, 0, 0, 0, 0, 0, 0, // 176 - 0, 0, 0, 0, 0, 0, 0, 0, // 177 - 0, 0, 0, 0, 0, 0, 0, 0, // 178 - 0, 0, 0, 0, 0, 0, 0, 0, // 179 - 0, 0, 0, 0, 0, 0, 0, 0, // 180 - 0, 0, 0, 0, 0, 0, 0, 0, // 181 - 0, 0, 0, 0, 0, 0, 0, 0, // 182 - 0, 0, 0, 0, 0, 0, 0, 0, // 183 - 0, 0, 0, 0, 0, 0, 0, 0, // 184 - 0, 0, 0, 0, 0, 0, 0, 0, // 185 - 0, 0, 0, 0, 0, 0, 0, 0, // 186 - 0, 0, 0, 0, 0, 0, 0, 0, // 187 - 0, 0, 0, 0, 0, 0, 0, 0, // 188 - 0, 0, 0, 0, 0, 0, 0, 0, // 189 - 0, 0, 0, 0, 0, 0, 0, 0, // 190 - 0, 0, 0, 0, 0, 0, 0, 0, // 191 - 0, 0, 0, 0, 0, 0, 0, 0, // 192 - 0, 0, 0, 0, 0, 0, 0, 0, // 193 - 0, 0, 0, 0, 0, 0, 0, 0, // 194 - 0, 0, 0, 0, 0, 0, 0, 0, // 195 - 0, 0, 0, 0, 0, 0, 0, 0, // 196 - 0, 0, 0, 0, 0, 0, 0, 0, // 197 - 0, 0, 0, 0, 0, 0, 0, 0, // 198 - 0, 0, 0, 0, 0, 0, 0, 0, // 199 - 0, 0, 0, 0, 0, 0, 0, 0, // 200 - 0, 0, 0, 0, 0, 0, 0, 0, // 201 - 0, 0, 0, 0, 0, 0, 0, 0, // 202 - 0, 0, 0, 0, 0, 0, 0, 0, // 203 - 0, 0, 0, 0, 0, 0, 0, 0, // 204 - 0, 0, 0, 0, 0, 0, 0, 0, // 205 - 0, 0, 0, 0, 0, 0, 0, 0, // 206 - 0, 0, 0, 0, 0, 0, 0, 0, // 207 - 0, 0, 0, 0, 0, 0, 0, 0, // 208 - 0, 0, 0, 0, 0, 0, 0, 0, // 209 - 0, 0, 0, 0, 0, 0, 0, 0, // 210 - 0, 0, 0, 0, 0, 0, 0, 0, // 211 - 0, 0, 0, 0, 0, 0, 0, 0, // 212 - 0, 0, 0, 0, 0, 0, 0, 0, // 213 - 0, 0, 0, 0, 0, 0, 0, 0, // 214 - 0, 0, 0, 0, 0, 0, 0, 0, // 215 - 0, 0, 0, 0, 0, 0, 0, 0, // 216 - 0, 0, 0, 0, 0, 0, 0, 0, // 217 - 0, 0, 0, 0, 0, 0, 0, 0, // 218 - 0, 0, 0, 0, 0, 0, 0, 0, // 219 - 0, 0, 0, 0, 0, 0, 0, 0, // 220 - 0, 0, 0, 0, 0, 0, 0, 0, // 221 - 0, 0, 0, 0, 0, 0, 0, 0, // 222 - 0, 0, 0, 0, 0, 0, 0, 0, // 223 - 0, 0, 0, 0, 0, 0, 0, 0, // 224 - 28, 54, 54, 124, 102, 102, 124, 64, // 225 - 0, 0, 0 // ??? -}; - -int ScummFont::getCharWidth(byte chr) const { - return guifont[chr+6]; -} - -void ScummFont::drawChar(Surface *dst, byte chr, int tx, int ty, uint32 color) const { - assert(dst != 0); - byte *ptr = (byte *)dst->getBasePtr(tx, ty); - - const byte *tmp = guifont + 6 + guifont[4] + chr * 8; - uint buffer = 0; - uint mask = 0; - - for (int y = 0; y < 8; y++) { - if (ty + y < 0 || ty + y >= dst->h) - continue; - for (int x = 0; x < 8; x++) { - if (tx + x < 0 || tx + x >= dst->w) - continue; - unsigned char c; - mask >>= 1; - if (mask == 0) { - buffer = *tmp++; - mask = 0x80; - } - c = ((buffer & mask) != 0); - if (c) { - if (dst->format.bytesPerPixel == 1) - ptr[x] = color; - else if (dst->format.bytesPerPixel == 2) - ((uint16 *)ptr)[x] = color; - } - } - ptr += dst->pitch; - } -} - -} // End of namespace Graphics diff --git a/graphics/surface.cpp b/graphics/surface.cpp index 3f53ce56f4d..cee8e614381 100644 --- a/graphics/surface.cpp +++ b/graphics/surface.cpp @@ -42,8 +42,10 @@ void Surface::drawLine(int x0, int y0, int x1, int y1, uint32 color) { Graphics::drawLine(x0, y0, x1, y1, color, plotPoint, this); else if (format.bytesPerPixel == 2) Graphics::drawLine(x0, y0, x1, y1, color, plotPoint, this); + else if (format.bytesPerPixel == 4) + Graphics::drawLine(x0, y0, x1, y1, color, plotPoint, this); else - error("Surface::drawLine: bytesPerPixel must be 1 or 2"); + error("Surface::drawLine: bytesPerPixel must be 1, 2, or 4"); } void Surface::create(uint16 width, uint16 height, const PixelFormat &f) { @@ -88,12 +90,15 @@ void Surface::hLine(int x, int y, int x2, uint32 color) { if (format.bytesPerPixel == 1) { byte *ptr = (byte *)getBasePtr(x, y); - memset(ptr, (byte)color, x2-x+1); + memset(ptr, (byte)color, x2 - x + 1); } else if (format.bytesPerPixel == 2) { uint16 *ptr = (uint16 *)getBasePtr(x, y); - Common::set_to(ptr, ptr + (x2-x+1), (uint16)color); + Common::set_to(ptr, ptr + (x2 - x + 1), (uint16)color); + } else if (format.bytesPerPixel == 4) { + uint32 *ptr = (uint32 *)getBasePtr(x, y); + Common::set_to(ptr, ptr + (x2 - x + 1), color); } else { - error("Surface::hLine: bytesPerPixel must be 1 or 2"); + error("Surface::hLine: bytesPerPixel must be 1, 2, or 4"); } } @@ -120,10 +125,17 @@ void Surface::vLine(int x, int y, int y2, uint32 color) { uint16 *ptr = (uint16 *)getBasePtr(x, y); while (y++ <= y2) { *ptr = (uint16)color; - ptr += pitch/2; + ptr += pitch / 2; + } + + } else if (format.bytesPerPixel == 4) { + uint32 *ptr = (uint32 *)getBasePtr(x, y); + while (y++ <= y2) { + *ptr = color; + ptr += pitch / 4; } } else { - error("Surface::vLine: bytesPerPixel must be 1 or 2"); + error("Surface::vLine: bytesPerPixel must be 1, 2, or 4"); } } @@ -145,7 +157,7 @@ void Surface::fillRect(Common::Rect r, uint32 color) { } else if (format.bytesPerPixel == 4) { useMemset = false; } else if (format.bytesPerPixel != 1) { - error("Surface::fillRect: bytesPerPixel must be 1, 2 or 4"); + error("Surface::fillRect: bytesPerPixel must be 1, 2, or 4"); } if (useMemset) { @@ -159,7 +171,7 @@ void Surface::fillRect(Common::Rect r, uint32 color) { uint16 *ptr = (uint16 *)getBasePtr(r.left, r.top); while (height--) { Common::set_to(ptr, ptr + width, (uint16)color); - ptr += pitch/2; + ptr += pitch / 2; } } else { uint32 *ptr = (uint32 *)getBasePtr(r.left, r.top); @@ -172,10 +184,10 @@ void Surface::fillRect(Common::Rect r, uint32 color) { } void Surface::frameRect(const Common::Rect &r, uint32 color) { - hLine(r.left, r.top, r.right-1, color); - hLine(r.left, r.bottom-1, r.right-1, color); - vLine(r.left, r.top, r.bottom-1, color); - vLine(r.right-1, r.top, r.bottom-1, color); + hLine(r.left, r.top, r.right - 1, color); + hLine(r.left, r.bottom - 1, r.right - 1, color); + vLine(r.left, r.top, r.bottom - 1, color); + vLine(r.right - 1, r.top, r.bottom - 1, color); } void Surface::move(int dx, int dy, int height) { @@ -183,8 +195,8 @@ void Surface::move(int dx, int dy, int height) { if ((dx == 0 && dy == 0) || height <= 0) return; - if (format.bytesPerPixel != 1 && format.bytesPerPixel != 2) - error("Surface::move: bytesPerPixel must be 1 or 2"); + if (format.bytesPerPixel != 1 && format.bytesPerPixel != 2 && format.bytesPerPixel != 4) + error("Surface::move: bytesPerPixel must be 1, 2, or 4"); byte *src, *dst; int x, y; @@ -223,6 +235,10 @@ void Surface::move(int dx, int dy, int height) { *(uint16 *)dst = *(const uint16 *)src; src -= 2; dst -= 2; + } else if (format.bytesPerPixel == 4) { + *(uint32 *)dst = *(const uint32 *)src; + src -= 4; + dst -= 4; } } src += pitch + (pitch - dx * format.bytesPerPixel); @@ -240,6 +256,10 @@ void Surface::move(int dx, int dy, int height) { *(uint16 *)dst = *(const uint16 *)src; src += 2; dst += 2; + } else if (format.bytesPerPixel == 4) { + *(uint32 *)dst = *(const uint32 *)src; + src += 4; + dst += 4; } } src += pitch - (pitch + dx * format.bytesPerPixel); diff --git a/graphics/tinygl/get.cpp b/graphics/tinygl/get.cpp index 87490617e8b..971d1da16b3 100644 --- a/graphics/tinygl/get.cpp +++ b/graphics/tinygl/get.cpp @@ -1,4 +1,5 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_fprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_stderr #include "graphics/tinygl/zgl.h" diff --git a/graphics/tinygl/list.cpp b/graphics/tinygl/list.cpp index 1f30a3cae5d..6c6f8b5abf3 100644 --- a/graphics/tinygl/list.cpp +++ b/graphics/tinygl/list.cpp @@ -1,6 +1,7 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_FILE #define FORBIDDEN_SYMBOL_EXCEPTION_fprintf #define FORBIDDEN_SYMBOL_EXCEPTION_fputc +#define FORBIDDEN_SYMBOL_EXCEPTION_stderr #include "graphics/tinygl/zgl.h" diff --git a/graphics/tinygl/matrix.cpp b/graphics/tinygl/matrix.cpp index 9d031f53933..bbf8ee378ec 100644 --- a/graphics/tinygl/matrix.cpp +++ b/graphics/tinygl/matrix.cpp @@ -1,4 +1,5 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_fprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_stderr #include "graphics/tinygl/zgl.h" diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index e7f340bf432..ef9c75eb9cd 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -561,7 +561,7 @@ bool ThemeEngine::addFont(TextData textId, const Common::String &file) { if (file == "default") { _texts[textId]->_fontPtr = _font; } else { - Common::String localized = genLocalizedFontFilename(file); + Common::String localized = FontMan.genLocalizedFontFilename(file); // Try built-in fonts _texts[textId]->_fontPtr = FontMan.getFontByName(localized); @@ -1467,32 +1467,6 @@ Common::String ThemeEngine::genCacheFilename(const Common::String &filename) con return Common::String(); } -Common::String ThemeEngine::genLocalizedFontFilename(const Common::String &filename) const { -#ifndef USE_TRANSLATION - return filename; -#else - // 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! - - // 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; - - // Put the translated font filename string back together. - Common::String result(filename.begin(), dot); - result += '-'; - result += TransMan.getCurrentCharset(); - result += dot; - - return result; -#endif -} - /********************************************************** * Static Theme XML functions diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index 8a67c633404..1dab76b59de 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -539,7 +539,6 @@ protected: const Graphics::Font *loadFontFromArchive(const Common::String &filename); const Graphics::Font *loadCachedFontFromArchive(const Common::String &filename); Common::String genCacheFilename(const Common::String &filename) const; - Common::String genLocalizedFontFilename(const Common::String &filename) const; /** * Actual Dirty Screen handling function. diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp index 56ee6df5ccd..5b1faa40750 100644 --- a/gui/ThemeParser.cpp +++ b/gui/ThemeParser.cpp @@ -232,7 +232,7 @@ bool ThemeParser::parserCallback_bitmap(ParserNode *node) { } if (!_theme->addBitmap(node->values["filename"])) - return parserError("Error loading Bitmap file '%s'", node->values["filename"].c_str()); + return parserError("Error loading Bitmap file '" + node->values["filename"] + "'"); return true; } @@ -252,7 +252,7 @@ bool ThemeParser::parserCallback_text(ParserNode *node) { TextColor textColorId = parseTextColorId(node->values["text_color"]); if (!_theme->addTextData(id, textDataId, textColorId, alignH, alignV)) - return parserError("Error adding Text Data for '%s'.", id.c_str()); + return parserError("Error adding Text Data for '" + id + "'."); return true; } @@ -279,13 +279,13 @@ bool ThemeParser::parserCallback_color(ParserNode *node) { Common::String name = node->values["name"]; if (_palette.contains(name)) - return parserError("Color '%s' has already been defined.", name.c_str()); + return parserError("Color '" + name + "' has already been defined."); int red, green, blue; if (parseIntegerKey(node->values["rgb"], 3, &red, &green, &blue) == false || red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255) - return parserError("Error parsing RGB values for palette color '%s'", name.c_str());\ + return parserError("Error parsing RGB values for palette color '" + name + "'"); _palette[name].r = red; _palette[name].g = green; @@ -332,7 +332,7 @@ bool ThemeParser::parserCallback_drawstep(ParserNode *node) { drawstep->drawingCall = getDrawingFunctionCallback(functionName); if (drawstep->drawingCall == 0) - return parserError("%s is not a valid drawing function name", functionName.c_str()); + return parserError(functionName + " is not a valid drawing function name"); if (!parseDrawStep(node, drawstep, true)) return false; @@ -385,11 +385,11 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst #define __PARSER_ASSIGN_INT(struct_name, key_name, force) \ if (stepNode->values.contains(key_name)) { \ if (!parseIntegerKey(stepNode->values[key_name], 1, &x)) \ - return parserError("Error parsing key value for '%s'.", key_name); \ + return parserError("Error parsing key value for '" + Common::String(key_name) + "'."); \ \ drawstep->struct_name = x; \ } else if (force) { \ - return parserError("Missing necessary key '%s'.", key_name); \ + return parserError("Missing necessary key '" + Common::String(key_name) + "'."); \ } /** @@ -410,7 +410,7 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst blue = _palette[val].b; \ } else if (parseIntegerKey(val, 3, &red, &green, &blue) == false || \ red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255) \ - return parserError("Error parsing color struct '%s'", val.c_str());\ + return parserError("Error parsing color struct '" + val + "'");\ \ drawstep->struct_name.r = red; \ drawstep->struct_name.g = green; \ @@ -466,7 +466,7 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst else if (val == "right") drawstep->extraData = Graphics::VectorRenderer::kTriangleRight; else - return parserError("'%s' is not a valid value for triangle orientation.", val.c_str()); + return parserError("'" + val + "' is not a valid value for triangle orientation."); } } @@ -545,7 +545,7 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst else if (val == "gradient") drawstep->fillMode = Graphics::VectorRenderer::kFillGradient; else - return parserError("'%s' is not a valid fill mode for a shape.", stepNode->values["fill"].c_str()); + return parserError("'" + stepNode->values["fill"] + "' is not a valid fill mode for a shape."); } #undef __PARSER_ASSIGN_INT @@ -567,7 +567,7 @@ bool ThemeParser::parserCallback_def(ParserNode *node) { value = _theme->getEvaluator()->getVar(node->values["value"]); else if (!parseIntegerKey(node->values["value"], 1, &value)) - return parserError("Invalid definition for '%s'.", var.c_str()); + return parserError("Invalid definition for '" + var + "'."); _theme->getEvaluator()->setVar(var, value); return true; @@ -585,7 +585,7 @@ bool ThemeParser::parserCallback_widget(ParserNode *node) { var = "Globals." + node->values["name"] + "."; if (!parseCommonLayoutProps(node, var)) - return parserError("Error parsing Layout properties of '%s'.", var.c_str()); + return parserError("Error parsing Layout properties of '" + var + "'."); } else { // FIXME: Shouldn't we distinguish the name/id and the label of a widget? @@ -606,7 +606,7 @@ bool ThemeParser::parserCallback_widget(ParserNode *node) { width = _theme->getEvaluator()->getVar(node->values["width"]); else if (!parseIntegerKey(node->values["width"], 1, &width)) - return parserError("Corrupted width value in key for %s", var.c_str()); + return parserError("Corrupted width value in key for " + var); } if (node->values.contains("height")) { @@ -614,7 +614,7 @@ bool ThemeParser::parserCallback_widget(ParserNode *node) { height = _theme->getEvaluator()->getVar(node->values["height"]); else if (!parseIntegerKey(node->values["height"], 1, &height)) - return parserError("Corrupted height value in key for %s", var.c_str()); + return parserError("Corrupted height value in key for " + var); } Graphics::TextAlign alignH = Graphics::kTextAlignLeft; diff --git a/gui/console.h b/gui/console.h index 442047ef786..50a00a1ad15 100644 --- a/gui/console.h +++ b/gui/console.h @@ -31,7 +31,7 @@ class ScrollBarWidget; /* FIXME #1: The console dialog code has some fundamental problems. First of, note the conflict between the (constant) value kCharsPerLine, and the - (variable) value _pageWidth. Look a bit at the code get familiar with them, + (variable) value _pageWidth. Look a bit at the code to get familiar with them, then return... Now, why don't we just drop kCharsPerLine? Because of the problem of resizing! When the user changes the scaler, the console will get resized. If the dialog @@ -47,7 +47,7 @@ class ScrollBarWidget; of making things like scrolling, drawing etc. more complicated. Either way, the current situation is bad, and we should resolve it one way - or the other (and if you can think of a thirds, feel free to suggest it). + or the other (and if you can think of a third, feel free to suggest it). diff --git a/gui/debugger.cpp b/gui/debugger.cpp index ab3fcef6b2f..3973583d381 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -29,7 +29,7 @@ #include "engines/engine.h" #include "gui/debugger.h" -#ifndef USE_TEXT_CONSOLE +#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER #include "gui/console.h" #elif defined(USE_READLINE) #include @@ -44,7 +44,7 @@ Debugger::Debugger() { _isActive = false; _errStr = NULL; _firstTime = true; -#ifndef USE_TEXT_CONSOLE +#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER _debuggerDialog = new GUI::ConsoleDialog(1.0f, 0.67f); _debuggerDialog->setInputCallback(debuggerInputCallback, this); _debuggerDialog->setCompletionCallback(debuggerCompletionCallback, this); @@ -59,6 +59,7 @@ Debugger::Debugger() { DCmd_Register("quit", WRAP_METHOD(Debugger, Cmd_Exit)); DCmd_Register("help", WRAP_METHOD(Debugger, Cmd_Help)); + DCmd_Register("openlog", WRAP_METHOD(Debugger, Cmd_OpenLog)); DCmd_Register("debugflag_list", WRAP_METHOD(Debugger, Cmd_DebugFlagsList)); DCmd_Register("debugflag_enable", WRAP_METHOD(Debugger, Cmd_DebugFlagEnable)); @@ -66,7 +67,7 @@ Debugger::Debugger() { } Debugger::~Debugger() { -#ifndef USE_TEXT_CONSOLE +#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER delete _debuggerDialog; #endif } @@ -78,7 +79,7 @@ int Debugger::DebugPrintf(const char *format, ...) { va_start(argptr, format); int count; -#ifndef USE_TEXT_CONSOLE +#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER count = _debuggerDialog->vprintFormat(1, format, argptr); #else count = ::vprintf(format, argptr); @@ -125,7 +126,7 @@ void Debugger::onFrame() { } } -#if defined(USE_TEXT_CONSOLE) && defined(USE_READLINE) +#if defined(USE_TEXT_CONSOLE_FOR_DEBUGGER) && defined(USE_READLINE) namespace { Debugger *g_readline_debugger; @@ -140,7 +141,7 @@ void Debugger::enter() { // TODO: Having three I/O methods #ifdef-ed in this file is not the // cleanest approach to this... -#ifndef USE_TEXT_CONSOLE +#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER if (_firstTime) { DebugPrintf("Debugger started, type 'exit' to return to the game.\n"); DebugPrintf("Type 'help' to see a little list of commands and variables.\n"); @@ -363,7 +364,7 @@ bool Debugger::tabComplete(const char *input, Common::String &completion) const return true; } -#if defined(USE_TEXT_CONSOLE) && defined(USE_READLINE) +#if defined(USE_TEXT_CONSOLE_FOR_DEBUGGER) && defined(USE_READLINE) char *Debugger::readlineComplete(const char *input, int state) { static CommandsMap::const_iterator iter; @@ -417,7 +418,7 @@ bool Debugger::Cmd_Exit(int argc, const char **argv) { // Print a list of all registered commands (and variables, if any), // nicely word-wrapped. bool Debugger::Cmd_Help(int argc, const char **argv) { -#ifndef USE_TEXT_CONSOLE +#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER const int charsPerLine = _debuggerDialog->getCharsPerLine(); #elif defined(USE_READLINE) int charsPerLine, rows; @@ -475,6 +476,15 @@ bool Debugger::Cmd_Help(int argc, const char **argv) { return true; } +bool Debugger::Cmd_OpenLog(int argc, const char **argv) { + if (g_system->hasFeature(OSystem::kFeatureDisplayLogFile)) + g_system->displayLogFile(); + else + DebugPrintf("Opening the log file not supported on this system\n"); + return true; +} + + bool Debugger::Cmd_DebugFlagsList(int argc, const char **argv) { const Common::DebugManager::DebugChannelList &debugLevels = DebugMan.listDebugChannels(); @@ -520,7 +530,7 @@ bool Debugger::Cmd_DebugFlagDisable(int argc, const char **argv) { } // Console handler -#ifndef USE_TEXT_CONSOLE +#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER bool Debugger::debuggerInputCallback(GUI::ConsoleDialog *console, const char *input, void *refCon) { Debugger *debugger = (Debugger *)refCon; diff --git a/gui/debugger.h b/gui/debugger.h index c6fce87107a..b74b0d6f0f0 100644 --- a/gui/debugger.h +++ b/gui/debugger.h @@ -29,7 +29,7 @@ namespace GUI { -#ifndef USE_TEXT_CONSOLE +#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER class ConsoleDialog; #endif @@ -69,7 +69,7 @@ protected: typedef Common::Functor2 Debuglet; /** - * Convenience macro that makes it either to register a method + * Convenience macro that makes it easier to register a method * of a debugger subclass as a command. * Usage example: * DCmd_Register("COMMAND", WRAP_METHOD(MyDebugger, MyCmd)); @@ -144,7 +144,7 @@ private: */ bool _firstTime; -#ifndef USE_TEXT_CONSOLE +#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER GUI::ConsoleDialog *_debuggerDialog; #endif @@ -190,11 +190,12 @@ private: protected: bool Cmd_Exit(int argc, const char **argv); bool Cmd_Help(int argc, const char **argv); + bool Cmd_OpenLog(int argc, const char **argv); bool Cmd_DebugFlagsList(int argc, const char **argv); bool Cmd_DebugFlagEnable(int argc, const char **argv); bool Cmd_DebugFlagDisable(int argc, const char **argv); -#ifndef USE_TEXT_CONSOLE +#ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER private: static bool debuggerInputCallback(GUI::ConsoleDialog *console, const char *input, void *refCon); static bool debuggerCompletionCallback(GUI::ConsoleDialog *console, const char *input, Common::String &completion, void *refCon); diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp index 0b3e8187420..5d87f13d959 100644 --- a/gui/gui-manager.cpp +++ b/gui/gui-manager.cpp @@ -74,6 +74,14 @@ GuiManager::GuiManager() : _redrawStatus(kRedrawDisabled), _stateIsSaved(false), ConfMan.registerDefault("gui_renderer", ThemeEngine::findModeConfigName(ThemeEngine::_defaultRendererMode)); ThemeEngine::GraphicsMode gfxMode = (ThemeEngine::GraphicsMode)ThemeEngine::findMode(ConfMan.get("gui_renderer")); +#ifdef __DS__ + // Searching for the theme file takes ~10 seconds on the DS. + // Disable this search here because external themes are not supported. + if (!loadNewTheme("builtin", gfxMode)) { + // Loading the built-in theme failed as well. Bail out + error("Failed to load any GUI theme, aborting"); + } +#else // Try to load the theme if (!loadNewTheme(themefile, gfxMode)) { // Loading the theme failed, try to load the built-in theme @@ -82,6 +90,7 @@ GuiManager::GuiManager() : _redrawStatus(kRedrawDisabled), _stateIsSaved(false), error("Failed to load any GUI theme, aborting"); } } +#endif } GuiManager::~GuiManager() { @@ -297,7 +306,7 @@ void GuiManager::runLoop() { // dialog-related events since they were probably generated while the old dialog // was still visible, and therefore not intended for the new one. // - // This hopefully fixes strange behaviour/crashes with pop-up widgets. (Most easily + // This hopefully fixes strange behavior/crashes with pop-up widgets. (Most easily // triggered in 3x mode or when running ScummVM under Valgrind.) if (activeDialog != getTopDialog() && event.type != Common::EVENT_SCREEN_CHANGED) continue; diff --git a/gui/launcher.cpp b/gui/launcher.cpp index f4dfa2b562d..444a2ad6af1 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -425,6 +425,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat break; case kCmdGlobalAudioOverride: setAudioSettingsState(data != 0); + setSubtitleSettingsState(data != 0); if (_globalVolumeOverride == NULL) setVolumeSettingsState(data != 0); draw(); @@ -684,10 +685,7 @@ void LauncherDialog::updateListing() { } if (description.empty()) { - char tmp[200]; - - snprintf(tmp, 200, "Unknown (target %s, gameid %s)", iter->_key.c_str(), gameid.c_str()); - description = tmp; + description = Common::String::format("Unknown (target %s, gameid %s)", iter->_key.c_str(), gameid.c_str()); } if (!gameid.empty() && !description.empty()) { @@ -717,6 +715,8 @@ void LauncherDialog::updateListing() { void LauncherDialog::addGame() { int modifiers = g_system->getEventManager()->getModifierState(); + +#ifndef DISABLE_MASS_ADD const bool massAdd = (modifiers & Common::KBD_SHIFT) != 0; if (massAdd) { @@ -745,6 +745,7 @@ void LauncherDialog::addGame() { updateButtons(); return; } +#endif // Allow user to add a new game to the list. // 1) show a dir selection dialog which lets the user pick the directory @@ -837,12 +838,10 @@ Common::String addGameToConf(const GameDescriptor &result) { assert(!domain.empty()); if (ConfMan.hasGameDomain(domain)) { int suffixN = 1; - char suffix[16]; Common::String gameid(domain); while (ConfMan.hasGameDomain(domain)) { - snprintf(suffix, 16, "-%d", suffixN); - domain = gameid + suffix; + domain = gameid + Common::String::format("-%d", suffixN); suffixN++; } } @@ -917,7 +916,7 @@ void LauncherDialog::loadGame(int item) { gameId = _domains[item]; const EnginePlugin *plugin = 0; - + EngineMan.findGame(gameId, &plugin); String target = _domains[item]; diff --git a/gui/massadd.cpp b/gui/massadd.cpp index 7b641d71e5b..b0adce3f478 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -31,7 +31,7 @@ #include "gui/widget.h" #include "gui/widgets/list.h" - +#ifndef DISABLE_MASS_ADD namespace GUI { /* @@ -234,23 +234,23 @@ void MassAddDialog::handleTickle() { // Update the dialog - char buf[256]; + Common::String buf; if (_scanStack.empty()) { // Enable the OK button _okButton->setEnabled(true); - snprintf(buf, sizeof(buf), "%s", _("Scan complete!")); + buf = _("Scan complete!"); _dirProgressText->setLabel(buf); - snprintf(buf, sizeof(buf), _("Discovered %d new games, ignored %d previously added games."), _games.size(), _oldGamesCount); + buf = Common::String::format(_("Discovered %d new games, ignored %d previously added games."), _games.size(), _oldGamesCount); _gameProgressText->setLabel(buf); } else { - snprintf(buf, sizeof(buf), _("Scanned %d directories ..."), _dirsScanned); + buf = Common::String::format(_("Scanned %d directories ..."), _dirsScanned); _dirProgressText->setLabel(buf); - snprintf(buf, sizeof(buf), _("Discovered %d new games, ignored %d previously added games ..."), _games.size(), _oldGamesCount); + buf = Common::String::format(_("Discovered %d new games, ignored %d previously added games ..."), _games.size(), _oldGamesCount); _gameProgressText->setLabel(buf); } @@ -264,3 +264,4 @@ void MassAddDialog::handleTickle() { } // End of namespace GUI +#endif // DISABLE_MASS_ADD diff --git a/gui/options.cpp b/gui/options.cpp index 549127224ea..fd8d8fa52f4 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -138,7 +138,7 @@ void OptionsDialog::init() { _subSpeedDesc = 0; _subSpeedSlider = 0; _subSpeedLabel = 0; - _oldTheme = ConfMan.get("gui_theme"); + _oldTheme = g_gui.theme()->getThemeId(); // Retrieve game GUI options _guioptions = 0; @@ -196,11 +196,8 @@ void OptionsDialog::open() { } // MIDI gain setting - char buf[10]; - _midiGainSlider->setValue(ConfMan.getInt("midi_gain", _domain)); - sprintf(buf, "%.2f", (double)_midiGainSlider->getValue() / 100.0); - _midiGainLabel->setLabel(buf); + _midiGainLabel->setLabel(Common::String::format("%.2f", (double)_midiGainSlider->getValue() / 100.0)); } // MT-32 options @@ -324,12 +321,9 @@ void OptionsDialog::close() { } void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { - char buf[10]; - switch (cmd) { case kMidiGainChanged: - sprintf(buf, "%.2f", (double)_midiGainSlider->getValue() / 100.0); - _midiGainLabel->setLabel(buf); + _midiGainLabel->setLabel(Common::String::format("%.2f", (double)_midiGainSlider->getValue() / 100.0)); _midiGainLabel->draw(); break; case kMusicVolumeChanged: @@ -1043,7 +1037,7 @@ void GlobalOptionsDialog::close() { // only become active *after* the options dialog has closed. g_gui.loadNewTheme(g_gui.theme()->getThemeId(), ThemeEngine::kGfxDisabled, true); #else - MessageDialog error(_("You have to restart Residual to take the effect.")); + MessageDialog error(_("You have to restart Residual before your changes will take effect.")); error.runModal(); #endif } diff --git a/gui/saveload.cpp b/gui/saveload.cpp index 7c7394a71d7..460246e5fcd 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -359,8 +359,19 @@ void SaveLoadChooser::updateSaveList() { } // Fill the rest of the save slots with empty saves + + int maximumSaveSlots = (*_plugin)->getMaximumSaveSlot(); + +#ifdef __DS__ + // Low memory on the DS means too many save slots are impractical, so limit + // the maximum here. + if (maximumSaveSlots > 99) { + maximumSaveSlots = 99; + } +#endif + Common::String emptyDesc; - for (int i = curSlot; i <= (*_plugin)->getMaximumSaveSlot(); i++) { + for (int i = curSlot; i <= maximumSaveSlots; i++) { saveNames.push_back(emptyDesc); SaveStateDescriptor dummySave(i, ""); _saveList.push_back(dummySave); diff --git a/gui/widget.cpp b/gui/widget.cpp index 29838961dfe..8420391a3ff 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -240,9 +240,7 @@ StaticTextWidget::StaticTextWidget(GuiObject *boss, const Common::String &name, } void StaticTextWidget::setValue(int value) { - char buf[256]; - sprintf(buf, "%d", value); - _label = buf; + _label = Common::String::format("%d", value); } void StaticTextWidget::setLabel(const Common::String &label) { diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp index 065b2404718..2a0d4afff06 100644 --- a/gui/widgets/list.cpp +++ b/gui/widgets/list.cpp @@ -38,7 +38,7 @@ ListWidget::ListWidget(Dialog *boss, const String &name, const char *tooltip, ui _scrollBar = NULL; _textWidth = NULL; - // This ensures that _entriesPerPage is properly initialised. + // This ensures that _entriesPerPage is properly initialized. reflowLayout(); _scrollBar = new ScrollBarWidget(this, _w - _scrollBarWidth + 1, 0, _scrollBarWidth, _h); @@ -70,7 +70,7 @@ ListWidget::ListWidget(Dialog *boss, int x, int y, int w, int h, const char *too _scrollBar = NULL; _textWidth = NULL; - // This ensures that _entriesPerPage is properly initialised. + // This ensures that _entriesPerPage is properly initialized. reflowLayout(); _scrollBar = new ScrollBarWidget(this, _w - _scrollBarWidth + 1, 0, _scrollBarWidth, _h); @@ -499,9 +499,7 @@ void ListWidget::drawWidget() { // If in numbering mode, we first print a number prefix if (_numberingMode != kListNumberingOff) { - char temp[10]; - sprintf(temp, "%2d. ", (pos + _numberingMode)); - buffer = temp; + buffer = Common::String::format("%2d. ", (pos + _numberingMode)); g_gui.theme()->drawText(Common::Rect(_x, y, _x + r.left + _leftPadding, y + fontHeight - 2), buffer, _state, Graphics::kTextAlignLeft, inverted, _leftPadding, true); pad = 0; @@ -543,9 +541,8 @@ Common::Rect ListWidget::getEditRect() const { r.bottom += offset; if (_numberingMode != kListNumberingOff) { - char temp[10]; // FIXME: Assumes that all digits have the same width. - sprintf(temp, "%2d. ", (_list.size() - 1 + _numberingMode)); + Common::String temp = Common::String::format("%2d. ", (_list.size() - 1 + _numberingMode)); r.left += g_gui.getStringWidth(temp) + _leftPadding; } diff --git a/po/POTFILES b/po/POTFILES index d0e7e628d39..1a49907d35d 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -19,9 +19,11 @@ base/main.cpp common/error.cpp common/util.cpp +engines/advancedDetector.cpp engines/dialogs.cpp audio/fmopl.cpp +audio/mididrv.cpp audio/musicplugin.cpp audio/null.h audio/null.cpp @@ -30,7 +32,6 @@ audio/softsynth/appleiigs.cpp audio/softsynth/sid.cpp audio/softsynth/mt32.cpp audio/softsynth/pcspk.cpp -audio/softsynth/ym2612.cpp backends/keymapper/remap-dialog.cpp backends/midi/windows.cpp diff --git a/ports.mk b/ports.mk index 2a941c35d3a..e5a31196b39 100644 --- a/ports.mk +++ b/ports.mk @@ -4,7 +4,7 @@ # -# UNIX specific +# POSIX specific # install: $(INSTALL) -d "$(DESTDIR)$(bindir)" @@ -110,6 +110,10 @@ ifdef USE_THEORADEC OSX_STATIC_LIBS += $(STATICLIBPATH)/lib/libtheoradec.a endif +ifdef USE_FAAD +OSX_STATIC_LIBS += $(STATICLIBPATH)/lib/libfaad.a +endif + ifdef USE_ZLIB OSX_ZLIB ?= -lz endif diff --git a/rules.mk b/rules.mk index d03f549405d..5ab3754768c 100644 --- a/rules.mk +++ b/rules.mk @@ -20,11 +20,12 @@ ifdef TOOL_EXECUTABLE # TODO: Refactor this, so that even our master executable can use this rule? ################################################ TOOL-$(MODULE) := $(MODULE)/$(TOOL_EXECUTABLE)$(EXEEXT) -$(TOOL-$(MODULE)): $(MODULE_OBJS-$(MODULE)) +$(TOOL-$(MODULE)): $(MODULE_OBJS-$(MODULE)) $(TOOL_DEPS) $(QUIET_CXX)$(CXX) $(LDFLAGS) $+ -o $@ -# Reset TOOL_EXECUTABLE var +# Reset TOOL_* vars TOOL_EXECUTABLE:= +TOOL_DEPS:= # Add to "devtools" target devtools: $(TOOL-$(MODULE))