synced code with scummvm trunk

This commit is contained in:
Pawel Kolodziejski 2010-01-21 19:25:03 +00:00
parent c8436afa36
commit edadbb35be
140 changed files with 5146 additions and 2956 deletions

View file

@ -29,6 +29,9 @@ MODULES += \
backends \ backends \
common \ common \
ifdef USE_MT32EMU
MODULES += sound/softsynth/mt32
endif
###################################################################### ######################################################################
# The build rules follow - normally you should have no need to # The build rules follow - normally you should have no need to
@ -68,7 +71,7 @@ endif
# The build rule for the Residual executable # The build rule for the Residual executable
$(EXECUTABLE): $(OBJS) $(EXECUTABLE): $(OBJS)
$(QUIET_LINK)$(CXX) $(LDFLAGS) $(PRE_OBJS_FLAGS) $+ $(POST_OBJS_FLAGS) $(LIBS) -o $@ $(QUIET_LINK)$(LD) $(LDFLAGS) $(PRE_OBJS_FLAGS) $+ $(POST_OBJS_FLAGS) $(LIBS) -o $@
distclean: clean distclean: clean
$(RM) config.h config.mk config.log $(RM) config.h config.mk config.log
@ -90,7 +93,12 @@ ifdef CXX_UPDATE_DEP_FLAG
$(QUIET)$(MKDIR) $(*D)/$(DEPDIR) $(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
$(QUIET_CXX)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o $(QUIET_CXX)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
# Build rule for Objective-C files. Strictly speaking, this is for OS X only.
# Build rules for Objective-C and Objective-C++ files. Strictly speaking, this is for OS X only.
%.o: %.mm
$(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
$(QUIET_CXX)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
%.o: %.m %.o: %.m
$(QUIET)$(MKDIR) $(*D)/$(DEPDIR) $(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
$(QUIET_CXX)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(OBJCFLAGS) -c $(<) -o $*.o $(QUIET_CXX)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(OBJCFLAGS) -c $(<) -o $*.o
@ -104,18 +112,31 @@ else
endif endif
# Build rule for assembler files
%.o: %.s %.o: %.s
$(QUIET)$(MKDIR) $(*D)
$(QUIET_AS)$(AS) $(ASFLAGS) $(<) -o $*.o $(QUIET_AS)$(AS) $(ASFLAGS) $(<) -o $*.o
# Build rule for assembler files with preprocessing
%.o: %.S
$(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
$(QUIET_AS)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(ASFLAGS) -c $(<) -o $*.o
ifdef HAVE_NASM ifdef HAVE_NASM
# Build rule for NASM assembler files
%.o: %.asm %.o: %.asm
$(QUIET)$(MKDIR) $(*D)
$(QUIET_NASM)$(NASM) -O1 $(NASMFLAGS) -g -o $*.o $(<) $(QUIET_NASM)$(NASM) -O1 $(NASMFLAGS) -g -o $*.o $(<)
endif endif
# Include the dependency tracking files. # Include the dependency tracking files.
-include $(wildcard $(addsuffix /*.d,$(DEPDIRS))) -include $(wildcard $(addsuffix /*.d,$(DEPDIRS)))
# Mark *.d files and most *.mk files as PHONY. This stops make from trying to
# recreate them (which it can't), and in particular from looking for potential
# source files. This can save quite a bit of disk access time.
.PHONY: $(wildcard $(addsuffix /*.d,$(DEPDIRS))) $(addprefix $(srcdir)/, $(addsuffix /module.mk,$(MODULES))) \
$(srcdir)/$(port_mk) $(srcdir)/rules.mk $(srcdir)/engines/engines.mk
###################################################################### ######################################################################
# Get the current version information # Get the current version information

View file

@ -46,13 +46,15 @@ Common::EventManager *BaseBackend::getEventManager() {
} }
#if defined(UNIX) #if defined(UNIX)
#ifdef MACOSX #if defined(SAMSUNGTV)
#define DEFAULT_CONFIG_FILE "Library/Preferences/Residual Preferences" #define DEFAULT_CONFIG_FILE "/dtv/usb/sda1/.scummvmrc"
#else #else
#define DEFAULT_CONFIG_FILE ".residualrc" #define DEFAULT_CONFIG_FILE ".residualrc"
#endif #endif
#else #endif
#define DEFAULT_CONFIG_FILE "residual.ini"
#if !defined(UNIX)
#define DEFAULT_CONFIG_FILE "scummvm.ini"
#endif #endif
Common::SeekableReadStream *BaseBackend::createConfigReadStream() { Common::SeekableReadStream *BaseBackend::createConfigReadStream() {

View file

@ -172,7 +172,7 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(const Common::String &p) {
_nProt = pExd->Protection; _nProt = pExd->Protection;
if (EXD_IS_DIRECTORY(pExd)) { if (EXD_IS_DIRECTORY(pExd)) {
_bIsDirectory = true; _bIsDirectory = true;
_pFileLock = IDOS->Lock((CONST_STRPTR)_sPath.c_str(), SHARED_LOCK);; _pFileLock = IDOS->Lock((CONST_STRPTR)_sPath.c_str(), SHARED_LOCK);
_bIsValid = (_pFileLock != 0); _bIsValid = (_pFileLock != 0);
// Add a trailing slash if it is needed // Add a trailing slash if it is needed

View file

@ -20,77 +20,11 @@
* *
* $URL$ * $URL$
* $Id$ * $Id$
*
*/ */
#include "backends/fs/stdiostream.h" #include "backends/fs/stdiostream.h"
#include <errno.h>
#if defined(MACOSX) || defined(IPHONE)
#include "CoreFoundation/CoreFoundation.h"
#endif
#ifdef __PLAYSTATION2__
// for those replaced fopen/fread/etc functions
typedef unsigned long uint64;
typedef signed long int64;
#include "backends/platform/ps2/fileio.h"
#define fopen(a, b) ps2_fopen(a, b)
#define fclose(a) ps2_fclose(a)
#define fseek(a, b, c) ps2_fseek(a, b, c)
#define ftell(a) ps2_ftell(a)
#define feof(a) ps2_feof(a)
#define fread(a, b, c, d) ps2_fread(a, b, c, d)
#define fwrite(a, b, c, d) ps2_fwrite(a, b, c, d)
#define fprintf ps2_fprintf // used in common/util.cpp
#define fflush(a) ps2_fflush(a) // used in common/util.cpp
#define ferror(a) ps2_ferror(a)
#define clearerr(a) ps2_clearerr(a)
//#define fgetc(a) ps2_fgetc(a) // not used
//#define fgets(a, b, c) ps2_fgets(a, b, c) // not used
//#define fputc(a, b) ps2_fputc(a, b) // not used
//#define fputs(a, b) ps2_fputs(a, b) // not used
//#define fsize(a) ps2_fsize(a) // not used -- and it is not a standard function either
#endif
#ifdef __DS__
// These functions replace the standard library functions of the same name.
// As this header is included after the standard one, I have the chance to #define
// all of these to my own code.
//
// A #define is the only way, as redefinig the functions would cause linker errors.
// These functions need to be #undef'ed, as their original definition
// in devkitarm is done with #includes (ugh!)
#undef feof
#undef clearerr
//#undef getc
//#undef ferror
#include "backends/fs/ds/ds-fs.h"
// Only functions used in the ScummVM source have been defined here!
#define fopen(name, mode) DS::std_fopen(name, mode)
#define fclose(handle) DS::std_fclose(handle)
#define fread(ptr, size, items, file) DS::std_fread(ptr, size, items, file)
#define fwrite(ptr, size, items, file) DS::std_fwrite(ptr, size, items, file)
#define feof(handle) DS::std_feof(handle)
#define ftell(handle) DS::std_ftell(handle)
#define fseek(handle, offset, whence) DS::std_fseek(handle, offset, whence)
#define clearerr(handle) DS::std_clearerr(handle)
#define fflush(file) DS::std_fflush(file)
#undef ferror
#define ferror(handle) DS::std_ferror(handle)
#endif
StdioStream::StdioStream(void *handle) : _handle(handle) { StdioStream::StdioStream(void *handle) : _handle(handle) {
assert(handle); assert(handle);
} }

View file

@ -57,6 +57,6 @@ const HardwareKey *Action::getMappedKey() const {
return _hwKey; return _hwKey;
} }
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_KEYMAPPER #endif // #ifdef ENABLE_KEYMAPPER

View file

@ -119,7 +119,7 @@ struct ActionPriorityComp : public BinaryFunction<Action, Action, bool> {
} }
}; };
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_KEYMAPPER #endif // #ifdef ENABLE_KEYMAPPER

View file

@ -131,7 +131,7 @@ private:
}; };
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_KEYMAPPER #endif // #ifdef ENABLE_KEYMAPPER

View file

@ -36,7 +36,7 @@ namespace Common {
Keymap::Keymap(const Keymap& km) : _actions(km._actions), _keymap(), _configDomain(0) { Keymap::Keymap(const Keymap& km) : _actions(km._actions), _keymap(), _configDomain(0) {
List<Action*>::iterator it; List<Action*>::iterator it;
for (it = _actions.begin(); it != _actions.end(); it++) { for (it = _actions.begin(); it != _actions.end(); ++it) {
const HardwareKey *hwKey = (*it)->getMappedKey(); const HardwareKey *hwKey = (*it)->getMappedKey();
if (hwKey) { if (hwKey) {
@ -48,7 +48,7 @@ Keymap::Keymap(const Keymap& km) : _actions(km._actions), _keymap(), _configDoma
Keymap::~Keymap() { Keymap::~Keymap() {
List<Action*>::iterator it; List<Action*>::iterator it;
for (it = _actions.begin(); it != _actions.end(); it++) for (it = _actions.begin(); it != _actions.end(); ++it)
delete *it; delete *it;
} }
@ -87,7 +87,7 @@ Action *Keymap::getAction(const char *id) {
Action *Keymap::findAction(const char *id) { Action *Keymap::findAction(const char *id) {
List<Action*>::iterator it; List<Action*>::iterator it;
for (it = _actions.begin(); it != _actions.end(); it++) { for (it = _actions.begin(); it != _actions.end(); ++it) {
if (strncmp((*it)->id, id, ACTION_ID_SIZE) == 0) if (strncmp((*it)->id, id, ACTION_ID_SIZE) == 0)
return *it; return *it;
} }
@ -97,7 +97,7 @@ Action *Keymap::findAction(const char *id) {
const Action *Keymap::findAction(const char *id) const { const Action *Keymap::findAction(const char *id) const {
List<Action*>::const_iterator it; List<Action*>::const_iterator it;
for (it = _actions.begin(); it != _actions.end(); it++) { for (it = _actions.begin(); it != _actions.end(); ++it) {
if (strncmp((*it)->id, id, ACTION_ID_SIZE) == 0) if (strncmp((*it)->id, id, ACTION_ID_SIZE) == 0)
return *it; return *it;
} }
@ -127,7 +127,7 @@ void Keymap::loadMappings(const HardwareKeySet *hwKeys) {
ConfigManager::Domain::iterator it; ConfigManager::Domain::iterator it;
String prefix = KEYMAP_KEY_PREFIX + _name + "_"; String prefix = KEYMAP_KEY_PREFIX + _name + "_";
for (it = _configDomain->begin(); it != _configDomain->end(); it++) { for (it = _configDomain->begin(); it != _configDomain->end(); ++it) {
const String& key = it->_key; const String& key = it->_key;
if (!key.hasPrefix(prefix.c_str())) if (!key.hasPrefix(prefix.c_str()))
@ -164,7 +164,7 @@ void Keymap::saveMappings() {
List<Action*>::const_iterator it; List<Action*>::const_iterator it;
String prefix = KEYMAP_KEY_PREFIX + _name + "_"; String prefix = KEYMAP_KEY_PREFIX + _name + "_";
for (it = _actions.begin(); it != _actions.end(); it++) { for (it = _actions.begin(); it != _actions.end(); ++it) {
uint actIdLen = strlen((*it)->id); uint actIdLen = strlen((*it)->id);
actIdLen = (actIdLen > ACTION_ID_SIZE) ? ACTION_ID_SIZE : actIdLen; actIdLen = (actIdLen > ACTION_ID_SIZE) ? ACTION_ID_SIZE : actIdLen;
@ -186,7 +186,7 @@ bool Keymap::isComplete(const HardwareKeySet *hwKeys) {
bool allMapped = true; bool allMapped = true;
uint numberMapped = 0; uint numberMapped = 0;
for (it = _actions.begin(); it != _actions.end(); it++) { for (it = _actions.begin(); it != _actions.end(); ++it) {
if ((*it)->getMappedKey()) { if ((*it)->getMappedKey()) {
numberMapped++; numberMapped++;
} else { } else {
@ -336,6 +336,6 @@ Action *Keymap::getParentMappedAction(KeyState key) {
} }
} }
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_KEYMAPPER #endif // #ifdef ENABLE_KEYMAPPER

View file

@ -147,7 +147,7 @@ private:
}; };
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_KEYMAPPER #endif // #ifdef ENABLE_KEYMAPPER

View file

@ -272,6 +272,6 @@ const HardwareKey *Keymapper::findHardwareKey(const KeyState& key) {
return (_hardwareKeys) ? _hardwareKeys->findHardwareKey(key) : 0; return (_hardwareKeys) ? _hardwareKeys->findHardwareKey(key) : 0;
} }
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_KEYMAPPER #endif // #ifdef ENABLE_KEYMAPPER

View file

@ -197,7 +197,7 @@ private:
}; };
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_KEYMAPPER #endif // #ifdef ENABLE_KEYMAPPER

View file

@ -94,7 +94,7 @@ void RemapDialog::open() {
if (_globalKeymaps) { if (_globalKeymaps) {
if (divider) if (divider)
_kmPopUp->appendEntry(""); _kmPopUp->appendEntry("");
for (it = _globalKeymaps->begin(); it != _globalKeymaps->end(); it++) { for (it = _globalKeymaps->begin(); it != _globalKeymaps->end(); ++it) {
_kmPopUp->appendEntry(it->_value->getName() + " (Global)", idx); _kmPopUp->appendEntry(it->_value->getName() + " (Global)", idx);
_keymapTable[idx++] = it->_value; _keymapTable[idx++] = it->_value;
} }
@ -104,7 +104,7 @@ void RemapDialog::open() {
if (_gameKeymaps) { if (_gameKeymaps) {
if (divider) if (divider)
_kmPopUp->appendEntry(""); _kmPopUp->appendEntry("");
for (it = _gameKeymaps->begin(); it != _gameKeymaps->end(); it++) { for (it = _gameKeymaps->begin(); it != _gameKeymaps->end(); ++it) {
_kmPopUp->appendEntry(it->_value->getName() + " (Game)", idx); _kmPopUp->appendEntry(it->_value->getName() + " (Game)", idx);
_keymapTable[idx++] = it->_value; _keymapTable[idx++] = it->_value;
} }
@ -317,7 +317,7 @@ void RemapDialog::loadKeymap() {
List<Action*>::iterator it; List<Action*>::iterator it;
for (it = km->getActions().begin(); it != km->getActions().end(); it++) { for (it = km->getActions().begin(); it != km->getActions().end(); ++it) {
ActionInfo info = {*it, false, (*it)->description}; ActionInfo info = {*it, false, (*it)->description};
_currentActions.push_back(info); _currentActions.push_back(info);
@ -380,6 +380,6 @@ void RemapDialog::refreshKeymap() {
} }
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_KEYMAPPER #endif // #ifdef ENABLE_KEYMAPPER

View file

@ -92,7 +92,7 @@ protected:
}; };
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_KEYMAPPER #endif // #ifdef ENABLE_KEYMAPPER

View file

@ -23,8 +23,8 @@
* *
*/ */
#ifndef COMMON_TYPES_H #ifndef KEYMAPPER_TYPES_H
#define COMMON_TYPES_H #define KEYMAPPER_TYPES_H
#include "common/scummsys.h" #include "common/scummsys.h"
@ -70,8 +70,8 @@ enum ActionType {
kActionTypeMax kActionTypeMax
}; };
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_KEYMAPPER #endif // #ifdef ENABLE_KEYMAPPER
#endif // #ifndef COMMON_TYPES_H #endif // #ifndef KEYMAPPER_TYPES_H

View file

@ -174,8 +174,6 @@ static byte SDLModToOSystemKeyFlags(SDLMod mod) {
bool OSystem_SDL::pollEvent(Common::Event &event) { bool OSystem_SDL::pollEvent(Common::Event &event) {
SDL_Event ev; SDL_Event ev;
int axis;
byte b = 0;
handleKbdMouse(); handleKbdMouse();
/* Residual doesn't support this /* Residual doesn't support this
@ -188,279 +186,308 @@ bool OSystem_SDL::pollEvent(Common::Event &event) {
*/ */
while (SDL_PollEvent(&ev)) { while (SDL_PollEvent(&ev)) {
preprocessEvents(&ev); preprocessEvents(&ev);
if (dispatchSDLEvent(ev, event))
switch (ev.type) {
case SDL_KEYDOWN:{
b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState());
/* Residual doesn't support this
// Alt-Return and Alt-Enter toggle full screen mode
if (b == Common::KBD_ALT && (ev.key.keysym.sym == SDLK_RETURN
|| ev.key.keysym.sym == SDLK_KP_ENTER)) {
beginGFXTransaction();
setFullscreenMode(!_videoMode.fullscreen);
endGFXTransaction();
#ifdef USE_OSD
if (_videoMode.fullscreen)
displayMessageOnOSD("Fullscreen mode");
else
displayMessageOnOSD("Windowed mode");
#endif
break;
}
// Alt-S: Create a screenshot
if (b == Common::KBD_ALT && ev.key.keysym.sym == 's') {
char filename[20];
for (int n = 0;; n++) {
SDL_RWops *file;
sprintf(filename, "scummvm%05d.bmp", n);
file = SDL_RWFromFile(filename, "r");
if (!file)
break;
SDL_RWclose(file);
}
if (saveScreenshot(filename))
printf("Saved '%s'\n", filename);
else
printf("Could not save screenshot!\n");
break;
}
*/
// Ctrl-m toggles mouse capture
if (b == Common::KBD_CTRL && ev.key.keysym.sym == 'm') {
toggleMouseGrab();
break;
}
#if defined(MACOSX)
// On Macintosh', Cmd-Q quits
if ((ev.key.keysym.mod & KMOD_META) && ev.key.keysym.sym == 'q') {
event.type = Common::EVENT_QUIT;
return true;
}
#elif defined(UNIX)
// On other unices, Control-Q quits
if ((ev.key.keysym.mod & KMOD_CTRL) && ev.key.keysym.sym == 'q') {
event.type = Common::EVENT_QUIT;
return true;
}
#else
// Ctrl-z and Alt-X quit
if ((b == Common::KBD_CTRL && ev.key.keysym.sym == 'z') || (b == Common::KBD_ALT && ev.key.keysym.sym == 'x')) {
event.type = Common::EVENT_QUIT;
return true;
}
#endif
if ((ev.key.keysym.mod & KMOD_CTRL) && ev.key.keysym.sym == 'u') {
event.type = Common::EVENT_MUTE;
return true;
}
/* Residual doesn't support this
// Ctrl-Alt-<key> will change the GFX mode
if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {
handleScalerHotkeys(ev.key);
break;
}*/
const bool event_complete = remapKey(ev, event);
if (event_complete)
return true;
event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
return true; return true;
}
case SDL_KEYUP:
{
const bool event_complete = remapKey(ev,event);
if (event_complete)
return true;
event.type = Common::EVENT_KEYUP;
event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState());
// Ctrl-Alt-<key> will change the GFX mode
if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {
// Swallow these key up events
break;
}
return true;
}
case SDL_MOUSEMOTION:
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, ev.motion.x, ev.motion.y);
//setMousePos(event.mouse.x, event.mouse.y);
return true;
case SDL_MOUSEBUTTONDOWN:
if (ev.button.button == SDL_BUTTON_LEFT)
event.type = Common::EVENT_LBUTTONDOWN;
else if (ev.button.button == SDL_BUTTON_RIGHT)
event.type = Common::EVENT_RBUTTONDOWN;
#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN)
else if (ev.button.button == SDL_BUTTON_WHEELUP)
event.type = Common::EVENT_WHEELUP;
else if (ev.button.button == SDL_BUTTON_WHEELDOWN)
event.type = Common::EVENT_WHEELDOWN;
#endif
#if defined(SDL_BUTTON_MIDDLE)
else if (ev.button.button == SDL_BUTTON_MIDDLE)
event.type = Common::EVENT_MBUTTONDOWN;
#endif
else
break;
fillMouseEvent(event, ev.button.x, ev.button.y);
return true;
case SDL_MOUSEBUTTONUP:
if (ev.button.button == SDL_BUTTON_LEFT)
event.type = Common::EVENT_LBUTTONUP;
else if (ev.button.button == SDL_BUTTON_RIGHT)
event.type = Common::EVENT_RBUTTONUP;
#if defined(SDL_BUTTON_MIDDLE)
else if (ev.button.button == SDL_BUTTON_MIDDLE)
event.type = Common::EVENT_MBUTTONUP;
#endif
else
break;
fillMouseEvent(event, ev.button.x, ev.button.y);
return true;
case SDL_JOYBUTTONDOWN:
if (ev.jbutton.button == JOY_BUT_LMOUSE) {
event.type = Common::EVENT_LBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
} else if (ev.jbutton.button == JOY_BUT_RMOUSE) {
event.type = Common::EVENT_RBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
} else {
event.type = Common::EVENT_KEYDOWN;
switch (ev.jbutton.button) {
case JOY_BUT_ESCAPE:
event.kbd.keycode = Common::KEYCODE_ESCAPE;
event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
break;
case JOY_BUT_PERIOD:
event.kbd.keycode = Common::KEYCODE_PERIOD;
event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
break;
case JOY_BUT_SPACE:
event.kbd.keycode = Common::KEYCODE_SPACE;
event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
break;
case JOY_BUT_F5:
event.kbd.keycode = Common::KEYCODE_F5;
event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
break;
}
}
return true;
case SDL_JOYBUTTONUP:
if (ev.jbutton.button == JOY_BUT_LMOUSE) {
event.type = Common::EVENT_LBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
} else if (ev.jbutton.button == JOY_BUT_RMOUSE) {
event.type = Common::EVENT_RBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
} else {
event.type = Common::EVENT_KEYUP;
switch (ev.jbutton.button) {
case JOY_BUT_ESCAPE:
event.kbd.keycode = Common::KEYCODE_ESCAPE;
event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
break;
case JOY_BUT_PERIOD:
event.kbd.keycode = Common::KEYCODE_PERIOD;
event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
break;
case JOY_BUT_SPACE:
event.kbd.keycode = Common::KEYCODE_SPACE;
event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
break;
case JOY_BUT_F5:
event.kbd.keycode = Common::KEYCODE_F5;
event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
break;
}
}
return true;
case SDL_JOYAXISMOTION:
axis = ev.jaxis.value;
if ( axis > JOY_DEADZONE) {
axis -= JOY_DEADZONE;
event.type = Common::EVENT_MOUSEMOVE;
} else if ( axis < -JOY_DEADZONE ) {
axis += JOY_DEADZONE;
event.type = Common::EVENT_MOUSEMOVE;
} else
axis = 0;
if ( ev.jaxis.axis == JOY_XAXIS) {
#ifdef JOY_ANALOG
_km.x_vel = axis/2000;
_km.x_down_count = 0;
#else
if (axis != 0) {
_km.x_vel = (axis > 0) ? 1:-1;
_km.x_down_count = 1;
} else {
_km.x_vel = 0;
_km.x_down_count = 0;
}
#endif
} else if (ev.jaxis.axis == JOY_YAXIS) {
#ifndef JOY_INVERT_Y
axis = -axis;
#endif
#ifdef JOY_ANALOG
_km.y_vel = -axis / 2000;
_km.y_down_count = 0;
#else
if (axis != 0) {
_km.y_vel = (-axis > 0) ? 1: -1;
_km.y_down_count = 1;
} else {
_km.y_vel = 0;
_km.y_down_count = 0;
}
#endif
}
fillMouseEvent(event, _km.x, _km.y);
return true;
case SDL_VIDEOEXPOSE:
event.type = Common::EVENT_SCREEN_CHANGED; // this two lines are Residual change
return true;
case SDL_QUIT:
event.type = Common::EVENT_QUIT;
return true;
}
} }
return false; return false;
} }
bool OSystem_SDL::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
switch (ev.type) {
case SDL_KEYDOWN:
return handleKeyDown(ev, event);
case SDL_KEYUP:
return handleKeyUp(ev, event);
case SDL_MOUSEMOTION:
return handleMouseMotion(ev, event);
case SDL_MOUSEBUTTONDOWN:
return handleMouseButtonDown(ev, event);
case SDL_MOUSEBUTTONUP:
return handleMouseButtonUp(ev, event);
case SDL_JOYBUTTONDOWN:
return handleJoyButtonDown(ev, event);
case SDL_JOYBUTTONUP:
return handleJoyButtonUp(ev, event);
case SDL_JOYAXISMOTION:
return handleJoyAxisMotion(ev, event);
case SDL_VIDEOEXPOSE:
//_forceFull = true;
break;
case SDL_QUIT:
event.type = Common::EVENT_QUIT;
return true;
}
return false;
}
bool OSystem_SDL::handleKeyDown(SDL_Event &ev, Common::Event &event) {
byte b = 0;
b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState());
/* Residual doesn't support this
// Alt-Return and Alt-Enter toggle full screen mode
if (b == Common::KBD_ALT && (ev.key.keysym.sym == SDLK_RETURN
|| ev.key.keysym.sym == SDLK_KP_ENTER)) {
beginGFXTransaction();
setFullscreenMode(!_videoMode.fullscreen);
endGFXTransaction();
#ifdef USE_OSD
if (_videoMode.fullscreen)
displayMessageOnOSD("Fullscreen mode");
else
displayMessageOnOSD("Windowed mode");
#endif
return false;
}
// Alt-S: Create a screenshot
if (b == Common::KBD_ALT && ev.key.keysym.sym == 's') {
char filename[20];
for (int n = 0;; n++) {
SDL_RWops *file;
sprintf(filename, "residual%05d.bmp", n);
file = SDL_RWFromFile(filename, "r");
if (!file)
break;
SDL_RWclose(file);
}
if (saveScreenshot(filename))
printf("Saved '%s'\n", filename);
else
printf("Could not save screenshot!\n");
return false;
}
*/
// Ctrl-m toggles mouse capture
if (b == Common::KBD_CTRL && ev.key.keysym.sym == 'm') {
toggleMouseGrab();
return false;
}
#if defined(MACOSX)
// On Macintosh', Cmd-Q quits
if ((ev.key.keysym.mod & KMOD_META) && ev.key.keysym.sym == 'q') {
event.type = Common::EVENT_QUIT;
return true;
}
#elif defined(UNIX)
// On other unices, Control-Q quits
if ((ev.key.keysym.mod & KMOD_CTRL) && ev.key.keysym.sym == 'q') {
event.type = Common::EVENT_QUIT;
return true;
}
#else
// Ctrl-z and Alt-X quit
if ((b == Common::KBD_CTRL && ev.key.keysym.sym == 'z') || (b == Common::KBD_ALT && ev.key.keysym.sym == 'x')) {
event.type = Common::EVENT_QUIT;
return true;
}
#endif
if ((ev.key.keysym.mod & KMOD_CTRL) && ev.key.keysym.sym == 'u') {
event.type = Common::EVENT_MUTE;
return true;
}
/* Residual doesn't support this
// Ctrl-Alt-<key> will change the GFX mode
if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {
if (handleScalerHotkeys(ev.key))
return false;
}*/
if (remapKey(ev, event))
return true;
event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
return true;
}
bool OSystem_SDL::handleKeyUp(SDL_Event &ev, Common::Event &event) {
if (remapKey(ev, event))
return true;
event.type = Common::EVENT_KEYUP;
event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
// Ctrl-Alt-<key> will change the GFX mode
byte b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState());
if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {
// Swallow these key up events
return false;
}
return true;
}
bool OSystem_SDL::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, ev.motion.x, ev.motion.y);
//setMousePos(event.mouse.x, event.mouse.y);
return true;
}
bool OSystem_SDL::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
if (ev.button.button == SDL_BUTTON_LEFT)
event.type = Common::EVENT_LBUTTONDOWN;
else if (ev.button.button == SDL_BUTTON_RIGHT)
event.type = Common::EVENT_RBUTTONDOWN;
#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN)
else if (ev.button.button == SDL_BUTTON_WHEELUP)
event.type = Common::EVENT_WHEELUP;
else if (ev.button.button == SDL_BUTTON_WHEELDOWN)
event.type = Common::EVENT_WHEELDOWN;
#endif
#if defined(SDL_BUTTON_MIDDLE)
else if (ev.button.button == SDL_BUTTON_MIDDLE)
event.type = Common::EVENT_MBUTTONDOWN;
#endif
else
return false;
fillMouseEvent(event, ev.button.x, ev.button.y);
return true;
}
bool OSystem_SDL::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
if (ev.button.button == SDL_BUTTON_LEFT)
event.type = Common::EVENT_LBUTTONUP;
else if (ev.button.button == SDL_BUTTON_RIGHT)
event.type = Common::EVENT_RBUTTONUP;
#if defined(SDL_BUTTON_MIDDLE)
else if (ev.button.button == SDL_BUTTON_MIDDLE)
event.type = Common::EVENT_MBUTTONUP;
#endif
else
return false;
fillMouseEvent(event, ev.button.x, ev.button.y);
return true;
}
bool OSystem_SDL::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
if (ev.jbutton.button == JOY_BUT_LMOUSE) {
event.type = Common::EVENT_LBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
} else if (ev.jbutton.button == JOY_BUT_RMOUSE) {
event.type = Common::EVENT_RBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
} else {
event.type = Common::EVENT_KEYDOWN;
switch (ev.jbutton.button) {
case JOY_BUT_ESCAPE:
event.kbd.keycode = Common::KEYCODE_ESCAPE;
event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
break;
case JOY_BUT_PERIOD:
event.kbd.keycode = Common::KEYCODE_PERIOD;
event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
break;
case JOY_BUT_SPACE:
event.kbd.keycode = Common::KEYCODE_SPACE;
event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
break;
case JOY_BUT_F5:
event.kbd.keycode = Common::KEYCODE_F5;
event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
break;
}
}
return true;
}
bool OSystem_SDL::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
if (ev.jbutton.button == JOY_BUT_LMOUSE) {
event.type = Common::EVENT_LBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
} else if (ev.jbutton.button == JOY_BUT_RMOUSE) {
event.type = Common::EVENT_RBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
} else {
event.type = Common::EVENT_KEYUP;
switch (ev.jbutton.button) {
case JOY_BUT_ESCAPE:
event.kbd.keycode = Common::KEYCODE_ESCAPE;
event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
break;
case JOY_BUT_PERIOD:
event.kbd.keycode = Common::KEYCODE_PERIOD;
event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
break;
case JOY_BUT_SPACE:
event.kbd.keycode = Common::KEYCODE_SPACE;
event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
break;
case JOY_BUT_F5:
event.kbd.keycode = Common::KEYCODE_F5;
event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
break;
}
}
return true;
}
bool OSystem_SDL::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
int axis = ev.jaxis.value;
if ( axis > JOY_DEADZONE) {
axis -= JOY_DEADZONE;
event.type = Common::EVENT_MOUSEMOVE;
} else if ( axis < -JOY_DEADZONE ) {
axis += JOY_DEADZONE;
event.type = Common::EVENT_MOUSEMOVE;
} else
axis = 0;
if ( ev.jaxis.axis == JOY_XAXIS) {
#ifdef JOY_ANALOG
_km.x_vel = axis/2000;
_km.x_down_count = 0;
#else
if (axis != 0) {
_km.x_vel = (axis > 0) ? 1:-1;
_km.x_down_count = 1;
} else {
_km.x_vel = 0;
_km.x_down_count = 0;
}
#endif
} else if (ev.jaxis.axis == JOY_YAXIS) {
#ifndef JOY_INVERT_Y
axis = -axis;
#endif
#ifdef JOY_ANALOG
_km.y_vel = -axis / 2000;
_km.y_down_count = 0;
#else
if (axis != 0) {
_km.y_vel = (-axis > 0) ? 1: -1;
_km.y_down_count = 1;
} else {
_km.y_vel = 0;
_km.y_down_count = 0;
}
#endif
}
fillMouseEvent(event, _km.x, _km.y);
return true;
}
bool OSystem_SDL::remapKey(SDL_Event &ev, Common::Event &event) { bool OSystem_SDL::remapKey(SDL_Event &ev, Common::Event &event) {
#ifdef LINUPY #ifdef LINUPY
// On Yopy map the End button to quit // On Yopy map the End button to quit

View file

@ -424,13 +424,18 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x,
_cursorFormat = Graphics::PixelFormat::createFormatCLUT8(); _cursorFormat = Graphics::PixelFormat::createFormatCLUT8();
else if (format->bytesPerPixel <= _screenFormat.bytesPerPixel) else if (format->bytesPerPixel <= _screenFormat.bytesPerPixel)
_cursorFormat = *format; _cursorFormat = *format;
keycolor &= (1 << (_cursorFormat.bytesPerPixel << 3)) - 1;
if (_cursorFormat.bytesPerPixel < 4)
assert(keycolor < (uint)(1 << (_cursorFormat.bytesPerPixel << 3)));
#else #else
keycolor &= 0xFF; assert(keycolor <= 0xFF);
#endif #endif
if (w == 0 || h == 0) if (w == 0 || h == 0)
return; return;
/* Residual doesn't support this /* Residual doesn't support this
_mouseCurState.hotX = hotspot_x; _mouseCurState.hotX = hotspot_x;
_mouseCurState.hotY = hotspot_y; _mouseCurState.hotY = hotspot_y;
@ -439,6 +444,22 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x,
_cursorTargetScale = cursorTargetScale; _cursorTargetScale = cursorTargetScale;
_mouseTextureId = new GLuint[1];
glGenTextures(1, _mouseTextureId);
glBindTexture(GL_TEXTURE_2D, _overlayTexIds[i]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, BITMAP_TEXTURE_SIZE, BITMAP_TEXTURE_SIZE, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
glPixelStorei(GL_UNPACK_ROW_LENGTH, _overlayWidth);
glBindTexture(GL_TEXTURE_2D, _overlayTexIds[curTexIdx]);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _mouseWidth, _mouseHeight, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, (byte *)buf + (y * 2 * _mouseWidth) + (2 * x));
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
if (_mouseCurState.w != (int)w || _mouseCurState.h != (int)h) { if (_mouseCurState.w != (int)w || _mouseCurState.h != (int)h) {
_mouseCurState.w = w; _mouseCurState.w = w;
_mouseCurState.h = h; _mouseCurState.h = h;
@ -446,10 +467,9 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x,
if (_mouseOrigSurface) if (_mouseOrigSurface)
SDL_FreeSurface(_mouseOrigSurface); SDL_FreeSurface(_mouseOrigSurface);
// Allocate bigger surface because AdvMame2x adds black pixel at [0,0]
_mouseOrigSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, _mouseOrigSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA,
_mouseCurState.w + 2, _mouseCurState.w,
_mouseCurState.h + 2, _mouseCurState.h,
16, 16,
_hwscreen->format->Rmask, _hwscreen->format->Rmask,
_hwscreen->format->Gmask, _hwscreen->format->Gmask,

View file

@ -23,23 +23,28 @@
* *
*/ */
// Fix for bug #2895217 "MSVC compilation broken with r47595":
// We need to keep this on top of the "common/scummsys.h" include,
// otherwise we will get errors about the windows headers redefining
// "ARRAYSIZE" for example.
#if defined(WIN32) && !defined(__SYMBIAN32__) #if defined(WIN32) && !defined(__SYMBIAN32__)
#include <windows.h> #include <windows.h>
// winnt.h defines ARRAYSIZE, but we want our own one... // winnt.h defines ARRAYSIZE, but we want our own one...
#undef ARRAYSIZE #undef ARRAYSIZE
#endif #endif
#include "common/sys.h"
// 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(__MAEMO__) && !defined(_WIN32_WCE) && !defined(GP2XWIZ)&& !defined(LINUXMOTO) && !defined(__SYMBIAN32__)
#include "backends/platform/sdl/sdl.h" #include "backends/platform/sdl/sdl.h"
#include "backends/plugins/sdl/sdl-provider.h" #include "backends/plugins/sdl/sdl-provider.h"
#include "base/main.h" #include "base/main.h"
#if defined(__SYMBIAN32__) #ifdef WIN32
#include "SymbianOs.h"
#endif
#if !defined(__MAEMO__) && !defined(_WIN32_WCE) && !defined(GP2XWIZ)&& !defined(LINUXMOTO)
#if defined (WIN32)
int __stdcall WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpCmdLine*/, int /*iShowCmd*/) { int __stdcall WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpCmdLine*/, int /*iShowCmd*/) {
SDL_SetModuleHandle(GetModuleHandle(NULL)); SDL_SetModuleHandle(GetModuleHandle(NULL));
return main(__argc, __argv); return main(__argc, __argv);
@ -48,56 +53,8 @@ int __stdcall WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpC
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
#if defined(__SYMBIAN32__)
//
// Set up redirects for stdout/stderr under Windows and Symbian.
// Code copied from SDL_main.
//
// Symbian does not like any output to the console through any *print* function
char STDOUT_FILE[256], STDERR_FILE[256]; // shhh, don't tell anybody :)
strcpy(STDOUT_FILE, Symbian::GetExecutablePath());
strcpy(STDERR_FILE, Symbian::GetExecutablePath());
strcat(STDOUT_FILE, "residual.stdout.txt");
strcat(STDERR_FILE, "residual.stderr.txt");
/* Flush the output in case anything is queued */
fclose(stdout);
fclose(stderr);
/* Redirect standard input and standard output */
FILE *newfp = freopen(STDOUT_FILE, "w", stdout);
if (newfp == NULL) { /* This happens on NT */
#if !defined(stdout)
stdout = fopen(STDOUT_FILE, "w");
#else
newfp = fopen(STDOUT_FILE, "w");
if (newfp) {
*stdout = *newfp;
}
#endif
}
newfp = freopen(STDERR_FILE, "w", stderr);
if (newfp == NULL) { /* This happens on NT */
#if !defined(stderr)
stderr = fopen(STDERR_FILE, "w");
#else
newfp = fopen(STDERR_FILE, "w");
if (newfp) {
*stderr = *newfp;
}
#endif
}
setbuf(stderr, NULL); /* No buffering */
#endif // defined(__SYMBIAN32__)
// Create our OSystem instance // Create our OSystem instance
#if defined(__SYMBIAN32__)
g_system = new OSystem_SDL_Symbian();
#else
g_system = new OSystem_SDL(); g_system = new OSystem_SDL();
#endif
assert(g_system); assert(g_system);
#ifdef DYNAMIC_MODULES #ifdef DYNAMIC_MODULES

View file

@ -68,6 +68,8 @@
#if defined(UNIX) #if defined(UNIX)
#ifdef MACOSX #ifdef MACOSX
#define DEFAULT_CONFIG_FILE "Library/Preferences/Residual Preferences" #define DEFAULT_CONFIG_FILE "Library/Preferences/Residual Preferences"
#elif defined(SAMSUNGTV)
#define DEFAULT_CONFIG_FILE "/dtv/usb/sda1/.residualrc"
#else #else
#define DEFAULT_CONFIG_FILE ".residualrc" #define DEFAULT_CONFIG_FILE ".residualrc"
#endif #endif
@ -177,7 +179,7 @@ OSystem_SDL::OSystem_SDL()
_cdrom(0), _cdrom(0),
_joystick(0), _joystick(0),
#ifdef MIXER_DOUBLE_BUFFERING #if MIXER_DOUBLE_BUFFERING
_soundMutex(0), _soundCond(0), _soundThread(0), _soundMutex(0), _soundCond(0), _soundThread(0),
_soundThreadIsRunning(false), _soundThreadShouldQuit(false), _soundThreadIsRunning(false), _soundThreadShouldQuit(false),
#endif #endif
@ -223,9 +225,15 @@ void OSystem_SDL::delayMillis(uint msecs) {
SDL_Delay(msecs); SDL_Delay(msecs);
} }
void OSystem_SDL::getTimeAndDate(struct tm &t) const { void OSystem_SDL::getTimeAndDate(TimeDate &td) const {
time_t curTime = time(0); time_t curTime = time(0);
t = *localtime(&curTime); struct tm t = *localtime(&curTime);
td.tm_sec = t.tm_sec;
td.tm_min = t.tm_min;
td.tm_hour = t.tm_hour;
td.tm_mday = t.tm_mday;
td.tm_mon = t.tm_mon;
td.tm_year = t.tm_year;
} }
Common::TimerManager *OSystem_SDL::getTimerManager() { Common::TimerManager *OSystem_SDL::getTimerManager() {
@ -398,6 +406,7 @@ void OSystem_SDL::quit() {
} }
if (_joystick) if (_joystick)
SDL_JoystickClose(_joystick); SDL_JoystickClose(_joystick);
SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_ENABLE);
SDL_RemoveTimer(_timerID); SDL_RemoveTimer(_timerID);
@ -412,6 +421,10 @@ void OSystem_SDL::quit() {
// recorded events // recorded events
delete getEventManager(); delete getEventManager();
delete _savefile; delete _savefile;
#if !defined(SAMSUNGTV)
exit(0);
#endif
} }
void OSystem_SDL::setupIcon() { void OSystem_SDL::setupIcon() {
@ -466,7 +479,7 @@ void OSystem_SDL::setupIcon() {
free(icon); free(icon);
} }
OSystem::MutexRef OSystem_SDL::createMutex(void) { OSystem::MutexRef OSystem_SDL::createMutex() {
return (MutexRef) SDL_CreateMutex(); return (MutexRef) SDL_CreateMutex();
} }
@ -486,7 +499,7 @@ void OSystem_SDL::deleteMutex(MutexRef mutex) {
#pragma mark --- Audio --- #pragma mark --- Audio ---
#pragma mark - #pragma mark -
#ifdef MIXER_DOUBLE_BUFFERING #if MIXER_DOUBLE_BUFFERING
void OSystem_SDL::mixerProducerThread() { void OSystem_SDL::mixerProducerThread() {
byte nextSoundBuffer; byte nextSoundBuffer;
@ -636,7 +649,7 @@ void OSystem_SDL::setupMixer() {
_mixer->setOutputRate(_samplesPerSec); _mixer->setOutputRate(_samplesPerSec);
_mixer->setReady(true); _mixer->setReady(true);
#ifdef MIXER_DOUBLE_BUFFERING #if MIXER_DOUBLE_BUFFERING
initThreadedMixer(_mixer, _obtainedRate.samples * 4); initThreadedMixer(_mixer, _obtainedRate.samples * 4);
#endif #endif
@ -654,7 +667,7 @@ void OSystem_SDL::closeMixer() {
delete _mixer; delete _mixer;
_mixer = 0; _mixer = 0;
#ifdef MIXER_DOUBLE_BUFFERING #if MIXER_DOUBLE_BUFFERING
deinitThreadedMixer(); deinitThreadedMixer();
#endif #endif

View file

@ -89,6 +89,25 @@ public:
// Returns true if an event was retrieved. // Returns true if an event was retrieved.
virtual bool pollEvent(Common::Event &event); // overloaded by CE backend virtual bool pollEvent(Common::Event &event); // overloaded by CE backend
protected:
virtual bool dispatchSDLEvent(SDL_Event &ev, Common::Event &event);
// Handlers for specific SDL events, called by pollEvent.
// This way, if a backend inherits fromt the SDL backend, it can
// change the behavior of only a single event, without having to override all
// of pollEvent.
virtual bool handleKeyDown(SDL_Event &ev, Common::Event &event);
virtual bool handleKeyUp(SDL_Event &ev, Common::Event &event);
virtual bool handleMouseMotion(SDL_Event &ev, Common::Event &event);
virtual bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event);
virtual bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event);
virtual bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event);
virtual bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);
virtual bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event);
public:
// Define all hardware keys for keymapper // Define all hardware keys for keymapper
virtual Common::HardwareKeySet *getHardwareKeySet(); virtual Common::HardwareKeySet *getHardwareKeySet();
@ -116,7 +135,7 @@ public:
// Quit // Quit
virtual void quit(); // overloaded by CE backend virtual void quit(); // overloaded by CE backend
virtual void getTimeAndDate(struct tm &t) const; virtual void getTimeAndDate(TimeDate &t) const;
virtual Common::TimerManager *getTimerManager(); virtual Common::TimerManager *getTimerManager();
// Mutex handling // Mutex handling
@ -232,7 +251,7 @@ protected:
virtual bool remapKey(SDL_Event &ev, Common::Event &event); virtual bool remapKey(SDL_Event &ev, Common::Event &event);
void handleScalerHotkeys(const SDL_KeyboardEvent &key); bool handleScalerHotkeys(const SDL_KeyboardEvent &key);
}; };
#endif #endif

View file

@ -44,6 +44,9 @@
POSIXSaveFileManager::POSIXSaveFileManager() { POSIXSaveFileManager::POSIXSaveFileManager() {
// Register default savepath based on HOME // Register default savepath based on HOME
#if defined(SAMSUNGTV)
ConfMan.registerDefault("savepath", "/dtv/usb/sda1/.residual");
#else
Common::String savePath; Common::String savePath;
const char *home = getenv("HOME"); const char *home = getenv("HOME");
if (home && *home && strlen(home) < MAXPATHLEN) { if (home && *home && strlen(home) < MAXPATHLEN) {
@ -51,6 +54,7 @@ POSIXSaveFileManager::POSIXSaveFileManager() {
savePath += "/" DEFAULT_SAVE_PATH; savePath += "/" DEFAULT_SAVE_PATH;
ConfMan.registerDefault("savepath", savePath); ConfMan.registerDefault("savepath", savePath);
} }
#endif
} }
/* /*
POSIXSaveFileManager::POSIXSaveFileManager(const Common::String &defaultSavepath) POSIXSaveFileManager::POSIXSaveFileManager(const Common::String &defaultSavepath)

View file

@ -54,6 +54,6 @@ bool Polygon::contains(int16 x, int16 y) const {
return inside_flag; return inside_flag;
} }
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_VKEYBD #endif // #ifdef ENABLE_VKEYBD

View file

@ -107,7 +107,7 @@ private:
Rect _bound; Rect _bound;
}; };
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_VKEYBD #endif // #ifdef ENABLE_VKEYBD

View file

@ -443,7 +443,7 @@ void VirtualKeyboardGUI::setupCursor() {
}; };
CursorMan.pushCursorPalette(palette, 0, 4); CursorMan.pushCursorPalette(palette, 0, 4);
CursorMan.pushCursor(NULL, 0, 0, 0, 0); CursorMan.pushCursor(NULL, 0, 0, 0, 0, 0);
CursorMan.showMouse(true); CursorMan.showMouse(true);
} }
@ -457,7 +457,7 @@ void VirtualKeyboardGUI::animateCursor() {
} }
} }
CursorMan.replaceCursor(_cursor, 16, 16, 7, 7); CursorMan.replaceCursor(_cursor, 16, 16, 7, 7, 255);
_cursorAnimateTimer = time; _cursorAnimateTimer = time;
_cursorAnimateCounter = (_cursorAnimateCounter + 1) % 4; _cursorAnimateCounter = (_cursorAnimateCounter + 1) % 4;
@ -469,6 +469,6 @@ void VirtualKeyboardGUI::removeCursor() {
CursorMan.popCursorPalette(); CursorMan.popCursorPalette();
} }
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_VKEYBD #endif // #ifdef ENABLE_VKEYBD

View file

@ -151,7 +151,7 @@ private:
}; };
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_VKEYBD #endif // #ifdef ENABLE_VKEYBD

View file

@ -154,8 +154,11 @@ bool VirtualKeyboardParser::parserCallback_mode(ParserNode *node) {
} else { } else {
// remove data relating to old resolution // remove data relating to old resolution
_mode->bitmapName.clear(); _mode->bitmapName.clear();
delete _mode->image; if (_mode->image) {
_mode->image = 0; _mode->image->free();
delete _mode->image;
_mode->image = 0;
}
_mode->imageMap.removeAllAreas(); _mode->imageMap.removeAllAreas();
_mode->displayArea = Rect(); _mode->displayArea = Rect();
} }
@ -371,6 +374,6 @@ bool VirtualKeyboardParser::parseRectAsPolygon(Polygon &poly, const String& coor
return true; return true;
} }
} // end of namespace GUI } // End of namespace GUI
#endif // #ifdef ENABLE_VKEYBD #endif // #ifdef ENABLE_VKEYBD

View file

@ -265,7 +265,7 @@ protected:
bool parseRectAsPolygon(Polygon &poly, const String& coords); bool parseRectAsPolygon(Polygon &poly, const String& coords);
}; };
} // end of namespace GUI } // End of namespace GUI
#endif // #ifdef ENABLE_VKEYBD #endif // #ifdef ENABLE_VKEYBD

View file

@ -416,7 +416,7 @@ bool VirtualKeyboard::KeyPressQueue::hasStringChanged() {
return ret; return ret;
} }
} // end of namespace Common } // End of namespace Common
#endif // #ifdef ENABLE_VKEYBD #endif // #ifdef ENABLE_VKEYBD

View file

@ -121,7 +121,13 @@ protected:
OverlayColor displayFontColor; OverlayColor displayFontColor;
Mode() : image(0) {} Mode() : image(0) {}
~Mode() { delete image; } ~Mode() {
if (image) {
image->free();
delete image;
image = 0;
}
}
}; };
typedef HashMap<String, Mode, IgnoreCase_Hash, IgnoreCase_EqualTo> ModeMap; typedef HashMap<String, Mode, IgnoreCase_Hash, IgnoreCase_EqualTo> ModeMap;

View file

@ -32,6 +32,8 @@
#include "common/system.h" #include "common/system.h"
#include "common/fs.h" #include "common/fs.h"
#include "sound/mididrv.h"
#include "gui/ThemeEngine.h" #include "gui/ThemeEngine.h"
#define DETECTOR_TESTING_HACK #define DETECTOR_TESTING_HACK
@ -69,6 +71,7 @@ static const char HELP_STRING[] =
" --gui-theme=THEME Select GUI theme\n" " --gui-theme=THEME Select GUI theme\n"
" --themepath=PATH Path to where GUI themes are stored\n" " --themepath=PATH Path to where GUI themes are stored\n"
" --list-themes Display list of all usable GUI themes\n" " --list-themes Display list of all usable GUI themes\n"
" -e, --music-driver=MODE Select music driver\n"
" -m, --music-volume=NUM Set the music volume, 0-127 (default: 127)\n" " -m, --music-volume=NUM Set the music volume, 0-127 (default: 127)\n"
" -s, --sfx-volume=NUM Set the sfx volume, 0-127 (default: 127)\n" " -s, --sfx-volume=NUM Set the sfx volume, 0-127 (default: 127)\n"
" -r, --speech-volume=NUM Set the speech volume, 0-127 (default: 127)\n" " -r, --speech-volume=NUM Set the speech volume, 0-127 (default: 127)\n"
@ -78,8 +81,15 @@ static const char HELP_STRING[] =
" --debugflags=FLAGS Enables engine specific debug flags\n" " --debugflags=FLAGS Enables engine specific debug flags\n"
" --savepath=PATH Path to where savegames are stored\n" " --savepath=PATH Path to where savegames are stored\n"
" --extrapath=PATH Extra path to additional game data\n" " --extrapath=PATH Extra path to additional game data\n"
" --soundfont=FILE Select the SoundFont for MIDI playback (only\n"
" supported by some MIDI drivers)\n"
" --multi-midi Enable combination AdLib and native MIDI\n"
" --native-mt32 True Roland MT-32 (disable GM emulation)\n"
" --enable-gs Enable Roland GS mode for MIDI playback\n"
" --output-rate=RATE Select output sample rate in Hz (e.g. 22050)\n" " --output-rate=RATE Select output sample rate in Hz (e.g. 22050)\n"
" --opl-driver=DRIVER Select AdLib (OPL) emulator (db, mame)\n"
" --show-fps=BOOL Set the turn on/off display FPS info: true/false\n" " --show-fps=BOOL Set the turn on/off display FPS info: true/false\n"
"\n" "\n"
; ;
#endif #endif
@ -115,6 +125,11 @@ void registerDefaults() {
ConfMan.registerDefault("speech_volume", 127); ConfMan.registerDefault("speech_volume", 127);
ConfMan.registerDefault("speech_mode", "3"); ConfMan.registerDefault("speech_mode", "3");
ConfMan.registerDefault("multi_midi", false);
ConfMan.registerDefault("native_mt32", false);
ConfMan.registerDefault("enable_gs", false);
ConfMan.registerDefault("midi_gain", 100);
ConfMan.registerDefault("path", "."); ConfMan.registerDefault("path", ".");
ConfMan.registerDefault("soft_renderer", "true"); ConfMan.registerDefault("soft_renderer", "true");
@ -260,12 +275,20 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
DO_LONG_OPTION("debugflags") DO_LONG_OPTION("debugflags")
END_OPTION END_OPTION
DO_OPTION('e', "music-driver")
if (MidiDriver::findMusicDriver(option) == 0)
usage("Unrecognized music driver '%s'", option);
END_OPTION
DO_LONG_OPTION_INT("output-rate") DO_LONG_OPTION_INT("output-rate")
END_OPTION END_OPTION
DO_OPTION_BOOL('f', "fullscreen") DO_OPTION_BOOL('f', "fullscreen")
END_OPTION END_OPTION
DO_LONG_OPTION("opl-driver")
END_OPTION
DO_OPTION_INT('m', "music-volume") DO_OPTION_INT('m', "music-volume")
END_OPTION END_OPTION
@ -289,6 +312,9 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
DO_OPTION_INT('r', "speech-volume") DO_OPTION_INT('r', "speech-volume")
END_OPTION END_OPTION
DO_LONG_OPTION_INT("midi-gain")
END_OPTION
DO_LONG_OPTION_INT("cdrom") DO_LONG_OPTION_INT("cdrom")
END_OPTION END_OPTION
@ -303,12 +329,33 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
DO_LONG_OPTION("soft-renderer") DO_LONG_OPTION("soft-renderer")
END_OPTION END_OPTION
DO_LONG_OPTION("soundfont")
Common::FSNode path(option);
if (!path.exists()) {
usage("Non-existent soundfont path '%s'", option);
} else if (!path.isReadable()) {
usage("Non-readable soundfont path '%s'", option);
}
END_OPTION
DO_LONG_OPTION_BOOL("disable-sdl-parachute") DO_LONG_OPTION_BOOL("disable-sdl-parachute")
END_OPTION END_OPTION
DO_LONG_OPTION("engine-speed") DO_LONG_OPTION("engine-speed")
END_OPTION END_OPTION
DO_LONG_OPTION_BOOL("multi-midi")
END_OPTION
DO_LONG_OPTION_BOOL("native-mt32")
END_OPTION
DO_LONG_OPTION_BOOL("enable-gs")
END_OPTION
DO_LONG_OPTION_BOOL("aspect-ratio")
END_OPTION
DO_LONG_OPTION("gamma") DO_LONG_OPTION("gamma")
END_OPTION END_OPTION

View file

@ -37,6 +37,7 @@
int pluginTypeVersions[PLUGIN_TYPE_MAX] = { int pluginTypeVersions[PLUGIN_TYPE_MAX] = {
PLUGIN_TYPE_ENGINE_VERSION, PLUGIN_TYPE_ENGINE_VERSION,
PLUGIN_TYPE_MUSIC_VERSION,
}; };
@ -297,3 +298,14 @@ GameList EngineManager::detectGames(const Common::FSList &fslist) const {
const EnginePlugin::List &EngineManager::getPlugins() const { const EnginePlugin::List &EngineManager::getPlugins() const {
return (const EnginePlugin::List &)PluginManager::instance().getPlugins(PLUGIN_TYPE_ENGINE); return (const EnginePlugin::List &)PluginManager::instance().getPlugins(PLUGIN_TYPE_ENGINE);
} }
// Music plugins
#include "sound/musicplugin.h"
DECLARE_SINGLETON(MusicManager);
const MusicPlugin::List &MusicManager::getPlugins() const {
return (const MusicPlugin::List &)PluginManager::instance().getPlugins(PLUGIN_TYPE_MUSIC);
}

View file

@ -64,6 +64,7 @@ namespace Common {
enum PluginType { enum PluginType {
PLUGIN_TYPE_ENGINE = 0, PLUGIN_TYPE_ENGINE = 0,
PLUGIN_TYPE_MUSIC,
PLUGIN_TYPE_MAX PLUGIN_TYPE_MAX
}; };
@ -71,6 +72,7 @@ enum PluginType {
// TODO: Make the engine API version depend on ScummVM's version // TODO: Make the engine API version depend on ScummVM's version
// because of the backlinking (posibly from the SVN revision) // because of the backlinking (posibly from the SVN revision)
#define PLUGIN_TYPE_ENGINE_VERSION 1 #define PLUGIN_TYPE_ENGINE_VERSION 1
#define PLUGIN_TYPE_MUSIC_VERSION 1
extern int pluginTypeVersions[PLUGIN_TYPE_MAX]; extern int pluginTypeVersions[PLUGIN_TYPE_MAX];

View file

@ -93,5 +93,9 @@ const char *gResidualFeatures = ""
#ifdef USE_ZLIB #ifdef USE_ZLIB
"zLib " "zLib "
#endif #endif
#ifdef USE_FLUIDSYNTH
"FluidSynth "
#endif
; ;

View file

@ -72,8 +72,7 @@ void EventDispatcher::dispatch() {
} }
void EventDispatcher::registerMapper(EventMapper *mapper) { void EventDispatcher::registerMapper(EventMapper *mapper) {
if (_mapper) delete _mapper;
delete _mapper;
_mapper = mapper; _mapper = mapper;
} }
@ -134,5 +133,5 @@ void EventDispatcher::dispatchEvent(const Event &event) {
} }
} }
} // end of namespace Common } // End of namespace Common

View file

@ -203,12 +203,8 @@ void EventRecorder::deinit() {
g_system->unlockMutex(_timeMutex); g_system->unlockMutex(_timeMutex);
g_system->unlockMutex(_recorderMutex); g_system->unlockMutex(_recorderMutex);
if (_playbackFile != NULL) { delete _playbackFile;
delete _playbackFile; delete _playbackTimeFile;
}
if (_playbackTimeFile != NULL) {
delete _playbackTimeFile;
}
if (_recordFile != NULL) { if (_recordFile != NULL) {
_recordFile->finalize(); _recordFile->finalize();
@ -363,5 +359,5 @@ bool EventRecorder::pollEvent(Common::Event &ev) {
return false; return false;
} }
} // end of namespace Common } // End of namespace Common

View file

@ -26,6 +26,7 @@
#define COMMON_ALGORITHM_H #define COMMON_ALGORITHM_H
#include "common/sys.h" #include "common/sys.h"
#include "common/func.h"
namespace Common { namespace Common {
@ -145,57 +146,81 @@ Op for_each(In first, In last, Op f) {
return f; return f;
} }
/** template<typename T>
* Simple sort function, modeled after std::sort. unsigned int distance(T *first, T *last) {
* Use it like this: sort(container.begin(), container.end()). return last - first;
* Also works on plain old i.e. int arrays etc. For comperance }
* operator < is used.
*/
template<class T>
void sort(T first, T last) {
if (first == last)
return;
// Simple selection sort template<typename T>
T i(first); unsigned int distance(T first, T last) {
for (; i != last; ++i) { unsigned int n = 0;
T minElem(i); while (first != last) {
T j(i); ++n;
++j; ++first;
for (; j != last; ++j)
if (*j < *minElem)
minElem = j;
if (minElem != i)
SWAP(*minElem, *i);
} }
return n;
}
template<typename T>
T *sortChoosePivot(T *first, T *last) {
return first + distance(first, last) / 2;
}
template<typename T>
T sortChoosePivot(T first, T last) {
unsigned int n = distance(first, last);
n /= 2;
while (n--)
++first;
return first;
}
template<typename T, class StrictWeakOrdering>
T sortPartition(T first, T last, T pivot, StrictWeakOrdering &comp) {
--last;
SWAP(*pivot, *last);
T sorted;
for (sorted = first; first != last; ++first) {
if (!comp(*last, *first)) {
if (first != sorted)
SWAP(*first, *sorted);
++sorted;
}
}
SWAP(*last, *sorted);
return sorted;
} }
/** /**
* Simple sort function, modeled after std::sort. * Simple sort function, modeled after std::sort.
* It compares data with the given comparator object comp. * It compares data with the given comparator object comp.
*
* Note: Using this with: Common::Less from common/func.h
* will give the same results as the plain sort function.
*/ */
template<class T, class StrictWeakOrdering> template<typename T, class StrictWeakOrdering>
void sort(T first, T last, StrictWeakOrdering comp) { void sort(T first, T last, StrictWeakOrdering comp) {
if (first == last) if (first == last)
return; return;
// Simple selection sort T pivot = sortChoosePivot(first, last);
T i(first); pivot = sortPartition(first, last, pivot, comp);
for (; i != last; ++i) { sort<T, StrictWeakOrdering>(first, pivot, comp);
T minElem(i); sort<T, StrictWeakOrdering>(++pivot, last, comp);
T j(i);
++j;
for (; j != last; ++j)
if (comp(*j, *minElem))
minElem = j;
if (minElem != i)
SWAP(*minElem, *i);
}
} }
} // end of namespace Common /**
* Simple sort function, modeled after std::sort.
*/
template<typename T>
void sort(T *first, T *last) {
sort(first, last, Common::Less<T>());
}
template<class T>
void sort(T first, T last) {
sort(first, last, Common::Less<typename T::ValueType>());
}
} // End of namespace Common
#endif #endif

View file

@ -50,13 +50,11 @@ int Archive::listMatchingMembers(ArchiveMemberList &list, const String &pattern)
int matches = 0; int matches = 0;
// need to match lowercase key
String lowercasePattern = pattern;
lowercasePattern.toLowercase();
ArchiveMemberList::iterator it = allNames.begin(); ArchiveMemberList::iterator it = allNames.begin();
for ( ; it != allNames.end(); ++it) { for ( ; it != allNames.end(); ++it) {
if ((*it)->getName().matchString(lowercasePattern, false, true)) { // TODO: We match case-insenstivie for now, our API does not define whether that's ok or not though...
// For our use case case-insensitive is probably what we want to have though.
if ((*it)->getName().matchString(pattern, true, true)) {
list.push_back(*it); list.push_back(*it);
matches++; matches++;
} }

View file

@ -199,6 +199,21 @@ public:
return (_size == 0); return (_size == 0);
} }
bool operator==(const Array<T> &other) const {
if (this == &other)
return true;
if (_size != other._size)
return false;
for (uint i = 0; i < _size; ++i) {
if (_storage[i] != other._storage[i])
return false;
}
return true;
}
bool operator!=(const Array<T> &other) const {
return !(*this == other);
}
iterator begin() { iterator begin() {
return _storage; return _storage;

View file

@ -98,7 +98,8 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) {
} else if (line[0] == '#') { } else if (line[0] == '#') {
// Accumulate comments here. Once we encounter either the start // Accumulate comments here. Once we encounter either the start
// of a new section, or a key-value-pair, we associate the value // of a new section, or a key-value-pair, we associate the value
// of the 'comment' variable with that entity. // of the 'comment' variable with that entity. The semicolon
// comment is used for Living Books games in Mohawk.
comment += line; comment += line;
#ifdef _WIN32 #ifdef _WIN32
comment += "\r\n"; comment += "\r\n";
@ -124,8 +125,9 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) {
const char *p = line.c_str() + 1; const char *p = line.c_str() + 1;
// Get the section name, and check whether it's valid (that // Get the section name, and check whether it's valid (that
// is, verify that it only consists of alphanumerics, // is, verify that it only consists of alphanumerics,
// dashes and underscores). // periods, dashes and underscores). Mohawk Living Books games
while (*p && (isalnum(*p) || *p == '-' || *p == '_')) // can have periods in their section names.
while (*p && (isalnum(*p) || *p == '-' || *p == '_' || *p == '.'))
p++; p++;
if (*p == '\0') if (*p == '\0')

View file

@ -40,17 +40,6 @@ static bool isValidDomainName(const Common::String &domName) {
namespace Common { namespace Common {
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
const String ConfigManager::kApplicationDomain("residual");
const String ConfigManager::kTransientDomain("__TRANSIENT");
#ifdef ENABLE_KEYMAPPER
const String ConfigManager::kKeymapperDomain("keymapper");
#endif
#else
const char *ConfigManager::kApplicationDomain = "residual"; const char *ConfigManager::kApplicationDomain = "residual";
const char *ConfigManager::kTransientDomain = "__TRANSIENT"; const char *ConfigManager::kTransientDomain = "__TRANSIENT";
@ -58,13 +47,10 @@ const char *ConfigManager::kTransientDomain = "__TRANSIENT";
const char *ConfigManager::kKeymapperDomain = "keymapper"; const char *ConfigManager::kKeymapperDomain = "keymapper";
#endif #endif
#endif
#pragma mark - #pragma mark -
ConfigManager::ConfigManager() ConfigManager::ConfigManager() : _activeDomain(0) {
: _activeDomain(0) {
} }
@ -426,11 +412,7 @@ const String & ConfigManager::get(const String &key) const {
else if (_defaultsDomain.contains(key)) else if (_defaultsDomain.contains(key))
return _defaultsDomain[key]; return _defaultsDomain[key];
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__)) return _emptyString;
return String::emptyString;
#else
return ConfMan._emptyString;
#endif
} }
const String & ConfigManager::get(const String &key, const String &domName) const { const String & ConfigManager::get(const String &key, const String &domName) const {
@ -453,11 +435,7 @@ const String & ConfigManager::get(const String &key, const String &domName) cons
if (!domain->contains(key)) { if (!domain->contains(key)) {
#if 1 #if 1
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__)) return _emptyString;
return String::emptyString;
#else
return ConfMan._emptyString;
#endif
#else #else
error("ConfigManager::get(%s,%s) called on non-existent key", error("ConfigManager::get(%s,%s) called on non-existent key",
key.c_str(), domName.c_str()); key.c_str(), domName.c_str());
@ -661,11 +639,7 @@ const String &ConfigManager::Domain::get(const String &key) const {
if (iter != end()) if (iter != end())
return iter->_value; return iter->_value;
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
return String::emptyString;
#else
return ConfMan._emptyString; return ConfMan._emptyString;
#endif
} }
void ConfigManager::Domain::setDomainComment(const String &comment) { void ConfigManager::Domain::setDomainComment(const String &comment) {

View file

@ -68,29 +68,15 @@ public:
typedef HashMap<String, Domain, IgnoreCase_Hash, IgnoreCase_EqualTo> DomainMap; typedef HashMap<String, Domain, IgnoreCase_Hash, IgnoreCase_EqualTo> DomainMap;
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
/** The name of the application domain (normally 'scummvm'). */ /** The name of the application domain (normally 'scummvm'). */
static const String kApplicationDomain; static const char *kApplicationDomain;
/** The transient (pseudo) domain. */ /** The transient (pseudo) domain. */
static const String kTransientDomain;
#ifdef ENABLE_KEYMAPPER
/** The name of keymapper domain used to store the key maps */
static const String kKeymapperDomain;
#endif
#else
static const char *kApplicationDomain;
static const char *kTransientDomain; static const char *kTransientDomain;
const String _emptyString;
#ifdef ENABLE_KEYMAPPER #ifdef ENABLE_KEYMAPPER
/** The name of keymapper domain used to store the key maps */ /** The name of keymapper domain used to store the key maps */
static const char *kKeymapperDomain; static const char *kKeymapperDomain;
#endif
#endif #endif
void loadDefaultConfigFile(); void loadDefaultConfigFile();
@ -179,6 +165,8 @@ private:
Domain * _activeDomain; Domain * _activeDomain;
String _filename; String _filename;
const String _emptyString;
}; };
} // End of namespace Common } // End of namespace Common

View file

@ -25,6 +25,7 @@
#include "common/debug.h" #include "common/debug.h"
#include "common/util.h" #include "common/util.h"
#include "common/hashmap.h" #include "common/hashmap.h"
#include "common/hash-str.h"
#include "engines/engine.h" #include "engines/engine.h"
@ -37,7 +38,6 @@
typedef signed long int64; typedef signed long int64;
#include "backends/platform/ps2/fileio.h" #include "backends/platform/ps2/fileio.h"
#define fprintf ps2_fprintf
#define fputs(str, file) ps2_fputs(str, file) #define fputs(str, file) ps2_fputs(str, file)
#define fflush(a) ps2_fflush(a) #define fflush(a) ps2_fflush(a)
#endif #endif
@ -45,14 +45,14 @@
#ifdef __DS__ #ifdef __DS__
#include "backends/fs/ds/ds-fs.h" #include "backends/fs/ds/ds-fs.h"
void std_fprintf(FILE* handle, const char* fmt, ...); #define fputs(str, file) DS::std_fwrite(str, strlen(str), 1, file)
void std_fflush(FILE* handle); #define fflush(file) DS::std_fflush(file)
#define fprintf(file, fmt, ...) do { char str[128]; sprintf(str, fmt, ##__VA_ARGS__); DS::std_fwrite(str, strlen(str), 1, file); } while(0)
#define fputs(str, file) DS::std_fwrite(str, strlen(str), 1, file)
#define fflush(file) DS::std_fflush(file)
#endif #endif
// TODO: Move gDebugLevel into namespace Common.
int gDebugLevel = -1;
namespace Common { namespace Common {
@ -142,11 +142,16 @@ bool isDebugChannelEnabled(const String &name) {
} }
static OutputFormatter s_debugOutputFormatter = 0;
void setDebugOutputFormatter(OutputFormatter f) {
s_debugOutputFormatter = f;
}
} // End of namespace Common } // End of namespace Common
int gDebugLevel = -1;
#ifndef DISABLE_TEXT_CONSOLE #ifndef DISABLE_TEXT_CONSOLE
static void debugHelper(const char *s, va_list va, bool caret = true) { static void debugHelper(const char *s, va_list va, bool caret = true) {
@ -156,8 +161,8 @@ static void debugHelper(const char *s, va_list va, bool caret = true) {
// Next, give the active engine (if any) a chance to augment the message, // Next, give the active engine (if any) a chance to augment the message,
// but only if not used from debugN. // but only if not used from debugN.
if (g_engine && caret) { if (Common::s_debugOutputFormatter) {
g_engine->errorString(in_buf, buf, STRINGBUFLEN); (*Common::s_debugOutputFormatter)(buf, in_buf, STRINGBUFLEN);
} else { } else {
strncpy(buf, in_buf, STRINGBUFLEN); strncpy(buf, in_buf, STRINGBUFLEN);
} }

View file

@ -26,6 +26,7 @@
#define COMMON_DEBUG_H #define COMMON_DEBUG_H
#include "common/sys.h" #include "common/sys.h"
#include "common/textconsole.h"
#include "common/list.h" #include "common/list.h"
#include "common/str.h" #include "common/str.h"
@ -96,6 +97,12 @@ bool isDebugChannelEnabled(uint32 level);
bool isDebugChannelEnabled(const String &name); bool isDebugChannelEnabled(const String &name);
/**
* Set the output formatter used by debug() and related functions.
*/
void setDebugOutputFormatter(OutputFormatter f);
} // End of namespace Common } // End of namespace Common

View file

@ -44,26 +44,26 @@ namespace Common {
* kPathInvalid, kPathIsInvalid, kInvalidPathError * kPathInvalid, kPathIsInvalid, kInvalidPathError
*/ */
enum Error { enum Error {
kNoError = 0, //!< No error occured kNoError = 0, ///< No error occured
kInvalidPathError, //!< Engine initialization: Invalid game path was passed kInvalidPathError, ///< Engine initialization: Invalid game path was passed
kNoGameDataFoundError, //!< Engine initialization: No game data was found in the specified location kNoGameDataFoundError, ///< Engine initialization: No game data was found in the specified location
kUnsupportedGameidError, //!< Engine initialization: Gameid not supported by this (Meta)Engine kUnsupportedGameidError, ///< Engine initialization: Gameid not supported by this (Meta)Engine
kUnsupportedColorMode, //!< Engine initialization: Engine does not support backend's color mode kUnsupportedColorMode, ///< Engine initialization: Engine does not support backend's color mode
kReadPermissionDenied, //!< Unable to read data due to missing read permission kReadPermissionDenied, ///< Unable to read data due to missing read permission
kWritePermissionDenied, //!< Unable to write data due to missing write permission kWritePermissionDenied, ///< Unable to write data due to missing write permission
// The following three overlap a bit with kInvalidPathError and each other. Which to keep? // The following three overlap a bit with kInvalidPathError and each other. Which to keep?
kPathDoesNotExist, //!< The specified path does not exist kPathDoesNotExist, ///< The specified path does not exist
kPathNotDirectory, //!< The specified path does not point to a directory kPathNotDirectory, ///< The specified path does not point to a directory
kPathNotFile, //!< The specified path does not point to a file kPathNotFile, ///< The specified path does not point to a file
kCreatingFileFailed, kCreatingFileFailed,
kReadingFailed, //!< Failed creating a (savestate) file kReadingFailed, ///< Failed creating a (savestate) file
kWritingFailed, //!< Failure to write data -- disk full? kWritingFailed, ///< Failure to write data -- disk full?
kUnknownError //!< Catch-all error, used if no other error code matches kUnknownError ///< Catch-all error, used if no other error code matches
}; };
} // End of namespace Common } // End of namespace Common

View file

@ -198,9 +198,9 @@ public:
virtual ~EventObserver() {} virtual ~EventObserver() {}
/** /**
* Notifies the source of an incoming event. * Notifies the observer of an incoming event.
* *
* An obeser is supposed to eat the event, with returning true, when * An observer is supposed to eat the event, with returning true, when
* it might want prevent other observers from preventing to receive * it might want prevent other observers from preventing to receive
* the event. An usage example here is the keymapper: * the event. An usage example here is the keymapper:
* If it processes an Event, it should 'eat' it and create a new * If it processes an Event, it should 'eat' it and create a new

View file

@ -314,6 +314,8 @@ int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &patt
// Cache dir data // Cache dir data
ensureCached(); ensureCached();
// need to match lowercase key, since all entries in our file cache are
// stored as lowercase.
String lowercasePattern(pattern); String lowercasePattern(pattern);
lowercasePattern.toLowercase(); lowercasePattern.toLowercase();

View file

@ -423,7 +423,7 @@ private:
* warning("Unimplemented opcode %d", opcodeNum); * warning("Unimplemented opcode %d", opcodeNum);
* *
* If you want to see an real world example check the kyra engine. * If you want to see an real world example check the kyra engine.
* Files: engines/kyra/script.cpp and .h and engine/kyra/script_*.cpp * Files: engines/kyra/script.cpp and .h and engines/kyra/script_*.cpp
* are interesting for that matter. * are interesting for that matter.
*/ */
template<class Arg, class Res> template<class Arg, class Res>

View file

@ -53,6 +53,7 @@ namespace ListInternal {
typedef Node<T> * NodePtr; typedef Node<T> * NodePtr;
typedef T & ValueRef; typedef T & ValueRef;
typedef T * ValuePtr; typedef T * ValuePtr;
typedef T ValueType;
NodeBase *_node; NodeBase *_node;

View file

@ -31,20 +31,19 @@
#include "common/file.h" #include "common/file.h"
#include "common/fs.h" #include "common/fs.h"
#include "common/md5.h" #include "common/md5.h"
#include "common/util.h"
#include "common/endian.h" #include "common/endian.h"
namespace Common { namespace Common {
typedef struct { struct md5_context {
uint32 total[2]; uint32 total[2];
uint32 state[4]; uint32 state[4];
uint8 buffer[64]; uint8 buffer[64];
} md5_context; };
void md5_starts(md5_context *ctx); static void md5_starts(md5_context *ctx);
void md5_update(md5_context *ctx, const uint8 *input, uint32 length); static void md5_update(md5_context *ctx, const uint8 *input, uint32 length);
void md5_finish(md5_context *ctx, uint8 digest[16]); static void md5_finish(md5_context *ctx, uint8 digest[16]);
#define GET_UINT32(n, b, i) (n) = READ_LE_UINT32(b + i) #define GET_UINT32(n, b, i) (n) = READ_LE_UINT32(b + i)
@ -246,41 +245,6 @@ void md5_finish(md5_context *ctx, uint8 digest[16]) {
PUT_UINT32(ctx->state[3], digest, 12); PUT_UINT32(ctx->state[3], digest, 12);
} }
bool md5_file(const FSNode &file, uint8 digest[16], uint32 length) {
if (!file.exists()) {
warning("md5_file: using an inexistent FSNode");
return false;
} else if (!file.isReadable()) {
warning("md5_file: using an unreadable FSNode");
return false;
} else if (file.isDirectory()) {
warning("md5_file: using a directory FSNode");
return false;
}
ReadStream *stream = file.createReadStream();
if (!stream) {
warning("md5_file: failed to open '%s'", file.getPath().c_str());
return false;
}
bool result = md5_file(*stream, digest, length);
delete stream;
return result;
}
bool md5_file(const char *name, uint8 digest[16], uint32 length) {
File f;
f.open(name);
if (!f.isOpen()) {
warning("md5_file couldn't open '%s'", name);
return false;
}
return md5_file(f, digest, length);
}
bool md5_file(ReadStream &stream, uint8 digest[16], uint32 length) { bool md5_file(ReadStream &stream, uint8 digest[16], uint32 length) {
@ -316,30 +280,6 @@ bool md5_file(ReadStream &stream, uint8 digest[16], uint32 length) {
return true; return true;
} }
bool md5_file_string(const FSNode &file, char *md5str, uint32 length) {
uint8 digest[16];
if (!md5_file(file, digest, length))
return false;
for (int i = 0; i < 16; i++) {
snprintf(md5str + i*2, 3, "%02x", (int)digest[i]);
}
return true;
}
bool md5_file_string(const char *name, char *md5str, uint32 length) {
uint8 digest[16];
if (!md5_file(name, digest, length))
return false;
for (int i = 0; i < 16; i++) {
snprintf(md5str + i*2, 3, "%02x", (int)digest[i]);
}
return true;
}
bool md5_file_string(ReadStream &stream, char *md5str, uint32 length) { bool md5_file_string(ReadStream &stream, char *md5str, uint32 length) {
uint8 digest[16]; uint8 digest[16];
if (!md5_file(stream, digest, length)) if (!md5_file(stream, digest, length))
@ -353,78 +293,3 @@ bool md5_file_string(ReadStream &stream, char *md5str, uint32 length) {
} }
} // End of namespace Common } // End of namespace Common
#ifdef TEST
#include <stdlib.h>
#include <stdio.h>
/*
* those are the standard RFC 1321 test vectors
*/
static const char *msg[] = {
"",
"a",
"abc",
"message digest",
"abcdefghijklmnopqrstuvwxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
"12345678901234567890123456789012345678901234567890123456789012" \
"345678901234567890"
};
static const char *val[] = {
"d41d8cd98f00b204e9800998ecf8427e",
"0cc175b9c0f1b6a831c399e269772661",
"900150983cd24fb0d6963f7d28e17f72",
"f96b697d7cb7938d525a2f31aaf161d0",
"c3fcd3d76192e4007dfb496cca67e13b",
"d174ab98d277d9f5a5611c2c9f419d9f",
"57edf4a22be3c955ac49da2e2107b67a"
};
int main(int argc, char *argv[]) {
int i, j;
char output[33];
md5_context ctx;
unsigned char md5sum[16];
if (argc < 2) {
printf("\n MD5 Validation Tests:\n\n");
for (i = 0; i < 7; i++) {
printf(" Test %d ", i + 1);
md5_starts(&ctx);
md5_update(&ctx, (const uint8 *)msg[i], strlen(msg[i]));
md5_finish(&ctx, md5sum);
for (j = 0; j < 16; j++) {
sprintf(output + j * 2, "%02x", md5sum[j]);
}
if (memcmp(output, val[i], 32)) {
printf("failed!\n");
return 1;
}
printf("passed.\n");
}
printf("\n");
} else {
for (i = 1; i < argc; i++) {
md5_file(argv[i], md5sum);
for (j = 0; j < 16; j++) {
printf("%02x", md5sum[j]);
}
printf(" %s\n", argv[i]);
}
}
return 0;
}
#endif

View file

@ -29,22 +29,16 @@
namespace Common { namespace Common {
class FSNode;
class ReadStream; class ReadStream;
bool md5_file(const char *name, uint8 digest[16], uint32 length = 0);
bool md5_file(const FSNode &file, uint8 digest[16], uint32 length = 0);
bool md5_file(ReadStream &stream, uint8 digest[16], uint32 length = 0); bool md5_file(ReadStream &stream, uint8 digest[16], uint32 length = 0);
// The following two methods work similar to the above two, but // The following method work similar to the above one, but
// instead of computing the binary MD5 digest, they produce // instead of computing the binary MD5 digest, it produces
// a human readable lowercase hexstring representing the digest. // a human readable lowercase hexstring representing the digest.
// The md5str parameter must point to a buffer of 32+1 chars. // The md5str parameter must point to a buffer of 32+1 chars.
bool md5_file_string(const char *name, char *md5str, uint32 length = 0);
bool md5_file_string(const FSNode &file, char *md5str, uint32 length = 0);
bool md5_file_string(ReadStream &stream, char *md5str, uint32 length = 0); bool md5_file_string(ReadStream &stream, char *md5str, uint32 length = 0);
} // End of namespace Common } // End of namespace Common
#endif #endif

View file

@ -32,13 +32,19 @@ enum {
INITIAL_CHUNKS_PER_PAGE = 8 INITIAL_CHUNKS_PER_PAGE = 8
}; };
static size_t adjustChunkSize(size_t chunkSize) {
MemoryPool::MemoryPool(size_t chunkSize) {
// You must at least fit the pointer in the node (technically unneeded considering the next rounding statement) // You must at least fit the pointer in the node (technically unneeded considering the next rounding statement)
_chunkSize = MAX(chunkSize, sizeof(void*)); chunkSize = MAX(chunkSize, sizeof(void*));
// There might be an alignment problem on some platforms when trying to load a void* on a non natural boundary // There might be an alignment problem on some platforms when trying to load a void* on a non natural boundary
// so we round to the next sizeof(void*) // so we round to the next sizeof(void*)
_chunkSize = (_chunkSize + sizeof(void*) - 1) & (~(sizeof(void*) - 1)); chunkSize = (chunkSize + sizeof(void*) - 1) & (~(sizeof(void*) - 1));
return chunkSize;
}
MemoryPool::MemoryPool(size_t chunkSize)
: _chunkSize(adjustChunkSize(chunkSize)) {
_next = NULL; _next = NULL;

View file

@ -32,6 +32,16 @@
namespace Common { namespace Common {
/**
* This class provides a pool of memory 'chunks' of identical size.
* The size of a chunk is determined when creating the memory pool.
*
* Using a memory pool may yield better performance and memory usage
* when allocating and deallocating many memory blocks of equal size.
* E.g. the Common::String class uses a memory pool for the refCount
* variables (each the size of an int) it allocates for each string
* instance.
*/
class MemoryPool { class MemoryPool {
protected: protected:
MemoryPool(const MemoryPool&); MemoryPool(const MemoryPool&);
@ -42,7 +52,7 @@ protected:
size_t numChunks; size_t numChunks;
}; };
size_t _chunkSize; const size_t _chunkSize;
Array<Page> _pages; Array<Page> _pages;
void *_next; void *_next;
size_t _chunksPerPage; size_t _chunksPerPage;
@ -52,17 +62,48 @@ protected:
bool isPointerInPage(void *ptr, const Page &page); bool isPointerInPage(void *ptr, const Page &page);
public: public:
/**
* Constructor for a memory pool with the given chunk size.
* @param chunkSize the chunk size of this memory pool
*/
MemoryPool(size_t chunkSize); MemoryPool(size_t chunkSize);
~MemoryPool(); ~MemoryPool();
/**
* Allocate a new chunk from the memory pool.
*/
void *allocChunk(); void *allocChunk();
/**
* Return a chunk to the memory pool. The given pointer must have
* been obtained from calling the allocChunk() method of the very
* same MemoryPool instance. Passing any other pointer (e.g. to
* a chunk from another MemoryPool, or a malloc'ed memory block)
* will lead to undefined behavior and may result in a crash (if
* you are lucky) or in silent data corruption.
*/
void freeChunk(void *ptr); void freeChunk(void *ptr);
/**
* Perform garbage collection. The memory pool stores all the
* chunks it manages in memory 'pages' obtained via the classic
* memory allocation APIs (i.e. malloc/free). Ordinarily, once
* a page has been allocated, it won't be released again during
* the life time of the memory pool. The exception is when this
* method is called.
*/
void freeUnusedPages(); void freeUnusedPages();
/**
* Return the chunk size used by this memory pool.
*/
size_t getChunkSize() const { return _chunkSize; } size_t getChunkSize() const { return _chunkSize; }
}; };
/**
* This is a memory pool which already contains in itself some storage
* space for a fixed number of chunks. Thus if the memory pool is only
* lightly used, no malloc() calls have to be made at all.
*/
template<size_t CHUNK_SIZE, size_t NUM_INTERNAL_CHUNKS = 32> template<size_t CHUNK_SIZE, size_t NUM_INTERNAL_CHUNKS = 32>
class FixedSizeMemoryPool : public MemoryPool { class FixedSizeMemoryPool : public MemoryPool {
private: private:
@ -80,32 +121,39 @@ public:
} }
}; };
// Ensure NUM_INTERNAL_CHUNKS == 0 results in a compile error
template<size_t CHUNK_SIZE> template<size_t CHUNK_SIZE>
class FixedSizeMemoryPool<CHUNK_SIZE,0> : public MemoryPool { class FixedSizeMemoryPool<CHUNK_SIZE,0> : public MemoryPool {
public: public:
FixedSizeMemoryPool() : MemoryPool(CHUNK_SIZE) {} FixedSizeMemoryPool() : MemoryPool(CHUNK_SIZE) {}
}; };
/**
* A memory pool for C++ objects.
*/
template<class T, size_t NUM_INTERNAL_CHUNKS = 32> template<class T, size_t NUM_INTERNAL_CHUNKS = 32>
class ObjectPool : public FixedSizeMemoryPool<sizeof(T), NUM_INTERNAL_CHUNKS> { class ObjectPool : public FixedSizeMemoryPool<sizeof(T), NUM_INTERNAL_CHUNKS> {
public: public:
/**
* Return the memory chunk used as storage for the given object back
* to the pool, after calling its destructor.
*/
void deleteChunk(T *ptr) { void deleteChunk(T *ptr) {
ptr->~T(); ptr->~T();
freeChunk(ptr); this->freeChunk(ptr);
} }
}; };
} // End of namespace Common } // End of namespace Common
// Provide a custom placement new operator, using an arbitrary /**
// MemoryPool. * A custom placement new operator, using an arbitrary MemoryPool.
// *
// This *should* work with all C++ implementations, but may not. * This *should* work with all C++ implementations, but may not.
// *
// For details on using placement new for custom allocators, see e.g. * For details on using placement new for custom allocators, see e.g.
// <http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.14> * <http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.14>
*/
inline void* operator new(size_t nbytes, Common::MemoryPool& pool) { inline void* operator new(size_t nbytes, Common::MemoryPool& pool) {
assert(nbytes <= pool.getChunkSize()); assert(nbytes <= pool.getChunkSize());
return pool.allocChunk(); return pool.allocChunk();

27
common/pack-end.h Normal file
View file

@ -0,0 +1,27 @@
/* Residual - A 3D game interpreter
*
* Residual is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the AUTHORS
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*/
#if defined(SCUMMVM_USE_PRAGMA_PACK)
#pragma pack()
#endif

27
common/pack-start.h Normal file
View file

@ -0,0 +1,27 @@
/* Residual - A 3D game interpreter
*
* Residual is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the AUTHORS
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*/
#if defined(SCUMMVM_USE_PRAGMA_PACK)
#pragma pack(1)
#endif

View file

@ -36,13 +36,13 @@ namespace Common {
* Simple class for handling both 2D position and size. * Simple class for handling both 2D position and size.
*/ */
struct Point { struct Point {
int16 x; //!< The horizontal part of the point int16 x; ///< The horizontal part of the point
int16 y; //!< The vertical part of the point int16 y; ///< The vertical part of the point
Point() : x(0), y(0) {} Point() : x(0), y(0) {}
Point(int16 x1, int16 y1) : x(x1), y(y1) {} Point(int16 x1, int16 y1) : x(x1), y(y1) {}
bool operator==(const Point & p) const { return x == p.x && y == p.y; }; bool operator==(const Point &p) const { return x == p.x && y == p.y; };
bool operator!=(const Point & p) const { return x != p.x || y != p.y; }; bool operator!=(const Point &p) const { return x != p.x || y != p.y; };
/** /**
* Return the square of the distance between this point and the point p. * Return the square of the distance between this point and the point p.
@ -50,7 +50,7 @@ struct Point {
* @param p the other point * @param p the other point
* @return the distance between this and p * @return the distance between this and p
*/ */
uint sqrDist(const Point & p) const { uint sqrDist(const Point &p) const {
int diffx = ABS(p.x - x); int diffx = ABS(p.x - x);
if (diffx >= 0x1000) if (diffx >= 0x1000)
return 0xFFFFFF; return 0xFFFFFF;
@ -59,7 +59,7 @@ struct Point {
if (diffy >= 0x1000) if (diffy >= 0x1000)
return 0xFFFFFF; return 0xFFFFFF;
return uint(diffx*diffx + diffy*diffy); return uint(diffx * diffx + diffy * diffy);
} }
}; };
@ -82,8 +82,8 @@ struct Point {
* When writing code using our Rect class, always keep this principle in mind! * When writing code using our Rect class, always keep this principle in mind!
*/ */
struct Rect { struct Rect {
int16 top, left; //!< The point at the top left of the rectangle (part of the rect). int16 top, left; ///< The point at the top left of the rectangle (part of the rect).
int16 bottom, right; //!< The point at the bottom right of the rectangle (not part of the rect). int16 bottom, right; ///< The point at the bottom right of the rectangle (not part of the rect).
Rect() : top(0), left(0), bottom(0), right(0) {} Rect() : top(0), left(0), bottom(0), right(0) {}
Rect(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {} Rect(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {}
@ -198,7 +198,7 @@ struct Rect {
else if (right < r.left) right = r.left; else if (right < r.left) right = r.left;
} }
void clip(int maxw, int maxh) { void clip(int16 maxw, int16 maxh) {
clip(Rect(0, 0, maxw, maxh)); clip(Rect(0, 0, maxw, maxh));
} }

View file

@ -37,13 +37,6 @@
namespace Common { namespace Common {
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
const String String::emptyString;
#else
const char *String::emptyString = "";
#endif
MemoryPool *g_refCountPool = 0; // FIXME: This is never freed right now MemoryPool *g_refCountPool = 0; // FIXME: This is never freed right now
static uint32 computeCapacity(uint32 len) { static uint32 computeCapacity(uint32 len) {
@ -464,6 +457,7 @@ String String::printf(const char *fmt, ...) {
len = vsnprintf(output._str, size, fmt, va); len = vsnprintf(output._str, size, fmt, va);
va_end(va); va_end(va);
} while (len == -1 || len >= size); } while (len == -1 || len >= size);
output._size = len;
} else if (len < (int)_builtinCapacity) { } else if (len < (int)_builtinCapacity) {
// vsnprintf succeeded // vsnprintf succeeded
output._size = len; output._size = len;

View file

@ -90,12 +90,6 @@ protected:
} }
public: public:
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
static const String emptyString;
#else
static const char *emptyString;
#endif
/** Construct a new empty string. */ /** Construct a new empty string. */
String() : _size(0), _str(_storage) { _storage[0] = 0; } String() : _size(0), _str(_storage) { _storage[0] = 0; }

View file

@ -37,7 +37,7 @@ MemoryReadStream *ReadStream::readStream(uint32 dataSize) {
void *buf = malloc(dataSize); void *buf = malloc(dataSize);
dataSize = read(buf, dataSize); dataSize = read(buf, dataSize);
assert(dataSize > 0); assert(dataSize > 0);
return new MemoryReadStream((byte *)buf, dataSize, true); return new MemoryReadStream((byte *)buf, dataSize, DisposeAfterUse::YES);
} }
@ -94,7 +94,7 @@ enum {
CR = 0x0D CR = 0x0D
}; };
char *SeekableReadStream::readLine_NEW(char *buf, size_t bufSize) { char *SeekableReadStream::readLine(char *buf, size_t bufSize) {
assert(buf != 0 && bufSize > 1); assert(buf != 0 && bufSize > 1);
char *p = buf; char *p = buf;
size_t len = 0; size_t len = 0;
@ -162,7 +162,7 @@ String SeekableReadStream::readLine() {
String line; String line;
while (line.lastChar() != '\n') { while (line.lastChar() != '\n') {
char buf[256]; char buf[256];
if (!readLine_NEW(buf, 256)) if (!readLine(buf, 256))
break; break;
line += buf; line += buf;
} }
@ -188,7 +188,7 @@ uint32 SubReadStream::read(void *dataPtr, uint32 dataSize) {
return dataSize; return dataSize;
} }
SeekableSubReadStream::SeekableSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end, bool disposeParentStream) SeekableSubReadStream::SeekableSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end, DisposeAfterUse::Flag disposeParentStream)
: SubReadStream(parentStream, end, disposeParentStream), : SubReadStream(parentStream, end, disposeParentStream),
_parentStream(parentStream), _parentStream(parentStream),
_begin(begin) { _begin(begin) {
@ -222,7 +222,7 @@ bool SeekableSubReadStream::seek(int32 offset, int whence) {
return ret; return ret;
} }
BufferedReadStream::BufferedReadStream(ReadStream *parentStream, uint32 bufSize, bool disposeParentStream) BufferedReadStream::BufferedReadStream(ReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream)
: _parentStream(parentStream), : _parentStream(parentStream),
_disposeParentStream(disposeParentStream), _disposeParentStream(disposeParentStream),
_pos(0), _pos(0),
@ -279,7 +279,7 @@ uint32 BufferedReadStream::read(void *dataPtr, uint32 dataSize) {
return alreadyRead + dataSize; return alreadyRead + dataSize;
} }
BufferedSeekableReadStream::BufferedSeekableReadStream(SeekableReadStream *parentStream, uint32 bufSize, bool disposeParentStream) BufferedSeekableReadStream::BufferedSeekableReadStream(SeekableReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream)
: BufferedReadStream(parentStream, bufSize, disposeParentStream), : BufferedReadStream(parentStream, bufSize, disposeParentStream),
_parentStream(parentStream) { _parentStream(parentStream) {
} }

View file

@ -28,6 +28,7 @@
#include "common/sys.h" #include "common/sys.h"
#include "common/endian.h" #include "common/endian.h"
#include "common/types.h"
namespace Common { namespace Common {
@ -176,12 +177,6 @@ public:
// The remaining methods all have default implementations; subclasses // The remaining methods all have default implementations; subclasses
// in general should not overload them. // in general should not overload them.
/**
* DEPRECATED
* Default implementation for backward compatibility
*/
inline bool ioFailed() { return (eos() || err()); }
/** /**
* Read an unsigned byte from the stream and return it. * Read an unsigned byte from the stream and return it.
* Performs no error checking. The return value is undefined * Performs no error checking. The return value is undefined
@ -380,7 +375,7 @@ public:
* @param bufSize the size of the buffer * @param bufSize the size of the buffer
* @return a pointer to the read string, or NULL if an error occurred * @return a pointer to the read string, or NULL if an error occurred
*/ */
virtual char *readLine_NEW(char *s, size_t bufSize); virtual char *readLine(char *s, size_t bufSize);
/** /**
@ -390,12 +385,13 @@ public:
* *
* Upon successful completion, return a string with the content * Upon successful completion, return a string with the content
* of the line, *without* the end of a line marker. This method * of the line, *without* the end of a line marker. This method
* does not indicate whether an error occured. Callers must use * does not indicate whether an error occurred. Callers must use
* err() or eos() to determine whether an exception occurred. * err() or eos() to determine whether an exception occurred.
*/ */
virtual String readLine(); virtual String readLine();
}; };
/** /**
* SubReadStream provides access to a ReadStream restricted to the range * SubReadStream provides access to a ReadStream restricted to the range
* [currentPosition, currentPosition+end). * [currentPosition, currentPosition+end).
@ -407,12 +403,12 @@ public:
class SubReadStream : virtual public ReadStream { class SubReadStream : virtual public ReadStream {
protected: protected:
ReadStream *_parentStream; ReadStream *_parentStream;
bool _disposeParentStream; DisposeAfterUse::Flag _disposeParentStream;
uint32 _pos; uint32 _pos;
uint32 _end; uint32 _end;
bool _eos; bool _eos;
public: public:
SubReadStream(ReadStream *parentStream, uint32 end, bool disposeParentStream = false) SubReadStream(ReadStream *parentStream, uint32 end, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO)
: _parentStream(parentStream), : _parentStream(parentStream),
_disposeParentStream(disposeParentStream), _disposeParentStream(disposeParentStream),
_pos(0), _pos(0),
@ -421,7 +417,8 @@ public:
assert(parentStream); assert(parentStream);
} }
~SubReadStream() { ~SubReadStream() {
if (_disposeParentStream) delete _parentStream; if (_disposeParentStream)
delete _parentStream;
} }
virtual bool eos() const { return _eos; } virtual bool eos() const { return _eos; }
@ -443,7 +440,7 @@ protected:
SeekableReadStream *_parentStream; SeekableReadStream *_parentStream;
uint32 _begin; uint32 _begin;
public: public:
SeekableSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end, bool disposeParentStream = false); SeekableSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO);
virtual int32 pos() const { return _pos - _begin; } virtual int32 pos() const { return _pos - _begin; }
virtual int32 size() const { return _end - _begin; } virtual int32 size() const { return _end - _begin; }
@ -463,7 +460,7 @@ private:
const bool _bigEndian; const bool _bigEndian;
public: public:
SeekableSubReadStreamEndian(SeekableReadStream *parentStream, uint32 begin, uint32 end, bool bigEndian = false, bool disposeParentStream = false) SeekableSubReadStreamEndian(SeekableReadStream *parentStream, uint32 begin, uint32 end, bool bigEndian = false, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO)
: SeekableSubReadStream(parentStream, begin, end, disposeParentStream), _bigEndian(bigEndian) { : SeekableSubReadStream(parentStream, begin, end, disposeParentStream), _bigEndian(bigEndian) {
} }
@ -496,14 +493,14 @@ public:
class BufferedReadStream : virtual public ReadStream { class BufferedReadStream : virtual public ReadStream {
protected: protected:
ReadStream *_parentStream; ReadStream *_parentStream;
bool _disposeParentStream; DisposeAfterUse::Flag _disposeParentStream;
byte *_buf; byte *_buf;
uint32 _pos; uint32 _pos;
uint32 _bufSize; uint32 _bufSize;
uint32 _realBufSize; uint32 _realBufSize;
public: public:
BufferedReadStream(ReadStream *parentStream, uint32 bufSize, bool disposeParentStream = false); BufferedReadStream(ReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO);
~BufferedReadStream(); ~BufferedReadStream();
virtual bool eos() const { return (_pos == _bufSize) && _parentStream->eos(); } virtual bool eos() const { return (_pos == _bufSize) && _parentStream->eos(); }
@ -521,7 +518,7 @@ class BufferedSeekableReadStream : public BufferedReadStream, public SeekableRea
protected: protected:
SeekableReadStream *_parentStream; SeekableReadStream *_parentStream;
public: public:
BufferedSeekableReadStream(SeekableReadStream *parentStream, uint32 bufSize, bool disposeParentStream = false); BufferedSeekableReadStream(SeekableReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO);
virtual int32 pos() const { return _parentStream->pos() - (_bufSize - _pos); } virtual int32 pos() const { return _parentStream->pos() - (_bufSize - _pos); }
virtual int32 size() const { return _parentStream->size(); } virtual int32 size() const { return _parentStream->size(); }
@ -542,7 +539,7 @@ private:
const uint32 _size; const uint32 _size;
uint32 _pos; uint32 _pos;
byte _encbyte; byte _encbyte;
bool _disposeMemory; DisposeAfterUse::Flag _disposeMemory;
bool _eos; bool _eos;
public: public:
@ -552,7 +549,7 @@ public:
* wraps it. If disposeMemory is true, the MemoryReadStream takes ownership * wraps it. If disposeMemory is true, the MemoryReadStream takes ownership
* of the buffer and hence free's it when destructed. * of the buffer and hence free's it when destructed.
*/ */
MemoryReadStream(const byte *dataPtr, uint32 dataSize, bool disposeMemory = false) : MemoryReadStream(const byte *dataPtr, uint32 dataSize, DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO) :
_ptrOrig(dataPtr), _ptrOrig(dataPtr),
_ptr(dataPtr), _ptr(dataPtr),
_size(dataSize), _size(dataSize),
@ -649,7 +646,7 @@ private:
byte *_ptr; byte *_ptr;
byte *_data; byte *_data;
uint32 _pos; uint32 _pos;
bool _disposeMemory; DisposeAfterUse::Flag _disposeMemory;
void ensureCapacity(uint32 new_len) { void ensureCapacity(uint32 new_len) {
if (new_len <= _capacity) if (new_len <= _capacity)
@ -670,7 +667,7 @@ private:
_size = new_len; _size = new_len;
} }
public: public:
MemoryWriteStreamDynamic(bool disposeMemory = false) : _capacity(0), _size(0), _ptr(0), _data(0), _pos(0), _disposeMemory(disposeMemory) {} MemoryWriteStreamDynamic(DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO) : _capacity(0), _size(0), _ptr(0), _data(0), _pos(0), _disposeMemory(disposeMemory) {}
~MemoryWriteStreamDynamic() { ~MemoryWriteStreamDynamic() {
if (_disposeMemory) if (_disposeMemory)

View file

@ -79,9 +79,6 @@
// - Define this on a big endian target // - Define this on a big endian target
// SYSTEM_NEED_ALIGNMENT // SYSTEM_NEED_ALIGNMENT
// - Define this if your system has problems reading e.g. an int32 from an odd address // - Define this if your system has problems reading e.g. an int32 from an odd address
// SYSTEM_USE_LONG_INT
// - Define this if your port needs to use 'long' for the int32 datatype
// (i.e. an integer with exactly 32 bits).
// SYSTEM_DONT_DEFINE_TYPES // SYSTEM_DONT_DEFINE_TYPES
// - Define this if you need to provide your own typedefs, e.g. because your // - Define this if you need to provide your own typedefs, e.g. because your
// system headers conflict with our typenames, or because you have odd // system headers conflict with our typenames, or because you have odd
@ -97,6 +94,20 @@
#endif #endif
//
// By default we try to use pragma push/pop to ensure various structs we use
// are "packed". If your compiler doesn't support this pragma, you are in for
// a problem. If you are lucky, there is a compiler switch, or another pragma,
// doing the same thing -- in that case, try to modify common/pack-begin.h and
// common/pack-end.h accordingly. Or maybe your port simply *always* packs
// everything, in which case you could #undefine SCUMMVM_USE_PRAGMA_PACK.
//
// If neither is possible, tough luck. Try to contact the team, maybe we can
// come up with a solution, though I wouldn't hold my breath on it :-/.
//
#define SYSTEM_USE_PRAGMA_PACK
#if defined(__SYMBIAN32__) #if defined(__SYMBIAN32__)
#define SYSTEM_LITTLE_ENDIAN #define SYSTEM_LITTLE_ENDIAN
@ -127,17 +138,17 @@
#define snprintf _snprintf #define snprintf _snprintf
#define SYSTEM_LITTLE_ENDIAN #define SYSTEM_LITTLE_ENDIAN
#define SYSTEM_NEED_ALIGNMENT
#ifndef __GNUC__
#define FORCEINLINE __forceinline
#define NORETURN_PRE __declspec(noreturn)
#endif
#define PLUGIN_EXPORT __declspec(dllexport)
#if _WIN32_WCE < 300 #if _WIN32_WCE < 300
#define SMALL_SCREEN_DEVICE #define SMALL_SCREEN_DEVICE
#endif #endif
typedef signed char int8_t;
typedef signed short int16_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#define strcasecmp stricmp #define strcasecmp stricmp
@ -145,15 +156,10 @@
#define SYSTEM_LITTLE_ENDIAN #define SYSTEM_LITTLE_ENDIAN
typedef signed char int8_t; #define FORCEINLINE __forceinline
typedef signed short int16_t; #define NORETURN_PRE __declspec(noreturn)
typedef unsigned char uint8_t; #define PLUGIN_EXPORT __declspec(dllexport)
typedef unsigned short uint16_t;
// #if !defined(SDL_COMPILEDVERSION) || (SDL_COMPILEDVERSION < 1210)
// typedef signed long int32_t;
// typedef unsigned long uint32_t;
// #endif
#elif defined(__MINGW32__) #elif defined(__MINGW32__)
@ -161,6 +167,8 @@
#define SYSTEM_LITTLE_ENDIAN #define SYSTEM_LITTLE_ENDIAN
#define PLUGIN_EXPORT __declspec(dllexport)
#elif defined(UNIX) #elif defined(UNIX)
#ifndef CONFIG_H #ifndef CONFIG_H
@ -233,6 +241,30 @@
#define SYSTEM_LITTLE_ENDIAN #define SYSTEM_LITTLE_ENDIAN
#define SYSTEM_NEED_ALIGNMENT #define SYSTEM_NEED_ALIGNMENT
#elif defined(__N64__)
#define scumm_stricmp strcasecmp
#define scumm_strnicmp strncasecmp
#define SCUMM_BIG_ENDIAN
#define SCUMM_NEED_ALIGNMENT
#define STRINGBUFLEN 256
#define SCUMMVM_DONT_DEFINE_TYPES
typedef unsigned char byte;
typedef unsigned char uint8;
typedef signed char int8;
typedef unsigned short int uint16;
typedef signed short int int16;
typedef unsigned int uint32;
typedef signed int int32;
typedef unsigned long long uint64;
typedef signed long long int64;
#elif defined(__PSP__) #elif defined(__PSP__)
@ -268,6 +300,7 @@
#endif #endif
// //
// GCC specific stuff // GCC specific stuff
// //
@ -291,8 +324,12 @@
#define PLUGIN_EXPORT #define PLUGIN_EXPORT
#endif #endif
#ifndef NORETURN #ifndef NORETURN_PRE
#define NORETURN #define NORETURN_PRE
#endif
#ifndef NORETURN_POST
#define NORETURN_POST
#endif #endif
#ifndef STRINGBUFLEN #ifndef STRINGBUFLEN
@ -303,32 +340,20 @@
#define MAXPATHLEN 256 #define MAXPATHLEN 256
#endif #endif
#ifndef NORETURN
#define NORETURN
#endif
// //
// Typedef our system types unless SYSTEM_DONT_DEFINE_TYPES is set. // Typedef our system types unless SYSTEM_DONT_DEFINE_TYPES is set.
// //
#ifndef SYSTEM_DONT_DEFINE_TYPES #ifndef SYSTEM_DONT_DEFINE_TYPES
typedef unsigned char byte; typedef unsigned char byte;
typedef unsigned char uint8; typedef unsigned char uint8;
typedef signed char int8; typedef signed char int8;
typedef unsigned short uint16; typedef unsigned short uint16;
typedef signed short int16; typedef signed short int16;
#ifdef SYSTEM_USE_LONG_INT
typedef unsigned long uint32;
typedef signed long int32;
typedef unsigned long uint;
#else
typedef unsigned int uint32; typedef unsigned int uint32;
typedef signed int int32; typedef signed int int32;
typedef unsigned int uint; typedef unsigned int uint;
#endif
#endif #endif
#endif // COMMON_SYS_H #endif // COMMON_SYS_H

View file

@ -55,6 +55,24 @@ namespace Common {
class FilesystemFactory; class FilesystemFactory;
/**
* A structure describing time and date. This is a clone of struct tm
* from time.h. We roll our own since not all systems provide time.h.
* We also do not imitate all files of struct tm, only those we
* actually need.
*
* @note For now, the members are named exactly as in struct tm to ease
* the transition.
*/
struct TimeDate {
int tm_sec; ///< seconds (0 - 60)
int tm_min; ///< minutes (0 - 59)
int tm_hour; ///< hours (0 - 23)
int tm_mday; ///< day of month (1 - 31)
int tm_mon; ///< month of year (0 - 11)
int tm_year; ///< year - 1900
};
/** /**
* Interface for Residual backends. * Interface for Residual backends.
*/ */
@ -183,6 +201,8 @@ public:
*/ */
virtual void launcherInitSize(uint width, uint height) = 0; virtual void launcherInitSize(uint width, uint height) = 0;
virtual int getScreenChangeID() const { return 0; }
/** /**
* Set the size of the screen. * Set the size of the screen.
@ -193,8 +213,6 @@ public:
*/ */
virtual byte *setupScreen(int screenW, int screenH, bool fullscreen, bool accel3d) = 0; virtual byte *setupScreen(int screenW, int screenH, bool fullscreen, bool accel3d) = 0;
int getScreenChangeID() const { return 0; }
/** /**
* Returns the currently set virtual screen height. * Returns the currently set virtual screen height.
* @see initSize * @see initSize
@ -300,7 +318,18 @@ public:
*/ */
//@{ //@{
/** Show or hide the mouse cursor. */ /**
* Show or hide the mouse cursor.
*
* Currently the backend is not required to immediately draw the
* mouse cursor on showMouse(true).
*
* TODO: We might want to reconsider this fact,
* check Graphics::CursorManager::showMouse for some details about
* this.
*
* @see Graphics::CursorManager::showMouse
*/
virtual bool showMouse(bool visible) = 0; virtual bool showMouse(bool visible) = 0;
/** /**
@ -314,16 +343,18 @@ public:
/** /**
* Set the bitmap used for drawing the cursor. * Set the bitmap used for drawing the cursor.
* *
* @param buf the pixmap data to be used (8bit/pixel) * @param buf the pixmap data to be used
* @param w width of the mouse cursor * @param w width of the mouse cursor
* @param h height of the mouse cursor * @param h height of the mouse cursor
* @param hotspotX horizontal offset from the left side to the hotspot * @param hotspotX horizontal offset from the left side to the hotspot
* @param hotspotY vertical offset from the top side to the hotspot * @param hotspotY vertical offset from the top side to the hotspot
* @param keycolor transparency color index * @param keycolor transparency color value. This should not exceed the maximum color value of the specified format.
* In case it does the behavior is undefined. The backend might just error out or simply ignore the
* value. (The SDL backend will just assert to prevent abuse of this).
* @param cursorTargetScale scale factor which cursor is designed for * @param cursorTargetScale scale factor which cursor is designed for
* @param format pointer to the pixel format which cursor graphic uses * @param format pointer to the pixel format which cursor graphic uses (0 means CLUT8)
*/ */
virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) = 0; virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) = 0;
//@} //@}
@ -343,7 +374,7 @@ public:
* Corresponds on many systems to the combination of time() * Corresponds on many systems to the combination of time()
* and localtime(). * and localtime().
*/ */
virtual void getTimeAndDate(struct tm &t) const = 0; virtual void getTimeAndDate(TimeDate &t) const = 0;
/** /**
* Return the timer manager singleton. For more information, refer * Return the timer manager singleton. For more information, refer

144
common/textconsole.cpp Normal file
View file

@ -0,0 +1,144 @@
/* Residual - A 3D game interpreter
*
* Residual is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the AUTHORS
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*/
#include "common/textconsole.h"
#include "common/system.h"
namespace Common {
static OutputFormatter s_errorOutputFormatter = 0;
void setErrorOutputFormatter(OutputFormatter f) {
s_errorOutputFormatter = f;
}
static ErrorHandler s_errorHandler = 0;
void setErrorHandler(ErrorHandler handler) {
s_errorHandler = handler;
}
} // End of namespace Common
#ifndef DISABLE_TEXT_CONSOLE
void warning(const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
va_start(va, s);
vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);
#if !defined (__SYMBIAN32__)
fputs("WARNING: ", stderr);
fputs(buf, stderr);
fputs("!\n", stderr);
#endif
#if defined( USE_WINDBG )
strcat(buf, "\n");
#if defined( _WIN32_WCE )
TCHAR buf_unicode[1024];
MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
OutputDebugString(buf_unicode);
#else
OutputDebugString(buf);
#endif
#endif
}
#endif
void NORETURN_PRE error(const char *s, ...) {
char buf_input[STRINGBUFLEN];
char buf_output[STRINGBUFLEN];
va_list va;
// Generate the full error message
va_start(va, s);
vsnprintf(buf_input, STRINGBUFLEN, s, va);
va_end(va);
// Next, give the active engine (if any) a chance to augment the message
if (Common::s_errorOutputFormatter) {
(*Common::s_errorOutputFormatter)(buf_output, buf_input, STRINGBUFLEN);
} else {
strncpy(buf_output, buf_input, STRINGBUFLEN);
}
buf_output[STRINGBUFLEN-3] = '\0';
buf_output[STRINGBUFLEN-2] = '\0';
buf_output[STRINGBUFLEN-1] = '\0';
strcat(buf_output, "!\n");
// Print the error message to stderr
fputs(buf_output, stderr);
// If there is an error handler, invoke it now
if (Common::s_errorHandler)
(*Common::s_errorHandler)(buf_output);
// TODO: Add a OSystem::fatalError() method and invoke it here.
// The default implementation would just call OSystem::quit().
#if defined( USE_WINDBG )
#if defined( _WIN32_WCE )
TCHAR buf_output_unicode[1024];
MultiByteToWideChar(CP_ACP, 0, buf_output, strlen(buf_output) + 1, buf_output_unicode, sizeof(buf_output_unicode));
OutputDebugString(buf_output_unicode);
#ifndef DEBUG
drawError(buf_output);
#else
int cmon_break_into_the_debugger_if_you_please = *(int *)(buf_output + 1); // bus error
printf("%d", cmon_break_into_the_debugger_if_you_please); // don't optimize the int out
#endif
#else
OutputDebugString(buf_output);
#endif
#endif
#ifdef PALMOS_MODE
extern void PalmFatalError(const char *err);
PalmFatalError(buf_output);
#endif
#ifdef __SYMBIAN32__
Symbian::FatalError(buf_output);
#endif
// Finally exit. quit() will terminate the program if g_system is present
if (g_system)
g_system->quit();
#if defined(SAMSUNGTV)
// FIXME
for (;;) {}
#else
exit(1);
#endif
}

85
common/textconsole.h Normal file
View file

@ -0,0 +1,85 @@
/* Residual - A 3D game interpreter
*
* Residual is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the AUTHORS
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*/
#ifndef COMMON_CONSOLE_H
#define COMMON_CONSOLE_H
#include "common/sys.h"
namespace Common {
/**
* An output formatter takes a source string and 'decorates' it with
* extra information, storing the result in a destination buffer.
* A typical use is to (optionally) enhance the output given by
* the error() and debug() functions with extra information on
* the state of the active engine.
*/
typedef void (*OutputFormatter)(char *dst, const char *src, size_t dstSize);
/**
* Set the output formatter used by error().
*/
void setErrorOutputFormatter(OutputFormatter f);
/**
* A callback which is invoked by error() just before aborting.
* A typical example would be a function which shows a debug
* console and displays the given message in it.
*/
typedef void (*ErrorHandler)(const char *msg);
/**
* Set a callback that is invoked by error() after the error
* message has been printed, but before the application is
* terminated.
* This can be used to e.g. show a debugger console.
*/
void setErrorHandler(ErrorHandler handler);
} // End of namespace Common
void NORETURN_PRE error(const char *s, ...) GCC_PRINTF(1, 2) NORETURN_POST;
#ifdef DISABLE_TEXT_CONSOLE
inline int printf(const char *s, ...) { return 0; }
inline void warning(const char *s, ...) {}
#else
/**
* Print a warning message to the text console (stderr).
* Automatically prepends the text "WARNING: " and appends
* an exclamation mark and a newline.
*/
void warning(const char *s, ...) GCC_PRINTF(1, 2);
#endif
#endif

35
common/types.h Normal file
View file

@ -0,0 +1,35 @@
/* Residual - A 3D game interpreter
*
* Residual is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the AUTHORS
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*/
#ifndef COMMON_TYPES_H
#define COMMON_TYPES_H
#include "common/sys.h"
namespace DisposeAfterUse {
enum Flag { NO, YES };
}
#endif

View file

@ -1442,7 +1442,7 @@ Common::SeekableReadStream *ZipArchive::createReadStreamForMember(const Common::
assert(buffer); assert(buffer);
unzReadCurrentFile(_zipFile, buffer, fileInfo.uncompressed_size); unzReadCurrentFile(_zipFile, buffer, fileInfo.uncompressed_size);
unzCloseCurrentFile(_zipFile); unzCloseCurrentFile(_zipFile);
return new Common::MemoryReadStream(buffer, fileInfo.uncompressed_size+1, true); return new Common::MemoryReadStream(buffer, fileInfo.uncompressed_size+1, DisposeAfterUse::YES);
// FIXME: instead of reading all into a memory stream, we could // FIXME: instead of reading all into a memory stream, we could
// instead create a new ZipStream class. But then we have to be // instead create a new ZipStream class. But then we have to be

View file

@ -25,14 +25,12 @@
#include "common/util.h" #include "common/util.h"
#include "common/system.h" #include "common/system.h"
#include "common/config-manager.h" #include "common/config-manager.h"
#include "gui/debugger.h"
#include "engines/engine.h"
#include <stdarg.h> // For va_list etc. #include <stdarg.h> // For va_list etc.
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
// This is required for the debugger attachment // This is required for the debugger attachment
extern bool isSmartphone(void); extern bool isSmartphone();
#endif #endif
#ifdef __PLAYSTATION2__ #ifdef __PLAYSTATION2__
@ -41,23 +39,15 @@ extern bool isSmartphone(void);
typedef signed long int64; typedef signed long int64;
#include "backends/platform/ps2/fileio.h" #include "backends/platform/ps2/fileio.h"
#define fprintf ps2_fprintf
#define fputs(str, file) ps2_fputs(str, file) #define fputs(str, file) ps2_fputs(str, file)
#define fflush(a) ps2_fflush(a)
#endif #endif
#ifdef __DS__ #ifdef __DS__
#include "backends/fs/ds/ds-fs.h" #include "backends/fs/ds/ds-fs.h"
void std_fprintf(FILE* handle, const char* fmt, ...); #define fputs(str, file) DS::std_fwrite(str, strlen(str), 1, file)
void std_fflush(FILE* handle);
#define fprintf(file, fmt, ...) do { char str[128]; sprintf(str, fmt, ##__VA_ARGS__); DS::std_fwrite(str, strlen(str), 1, file); } while(0)
#define fputs(str, file) DS::std_fwrite(str, strlen(str), 1, file)
#define fflush(file) DS::std_fflush(file)
#endif #endif
namespace Common { namespace Common {
StringTokenizer::StringTokenizer(const String &str, const String &delimiters) : _str(str), _delimiters(delimiters) { StringTokenizer::StringTokenizer(const String &str, const String &delimiters) : _str(str), _delimiters(delimiters) {
@ -150,7 +140,7 @@ String tag2string(uint32 tag) {
str[4] = '\0'; str[4] = '\0';
// Replace non-printable chars by dot // Replace non-printable chars by dot
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
if (!isprint(str[i])) if (!isprint((unsigned char)str[i]))
str[i] = '.'; str[i] = '.';
} }
return Common::String(str); return Common::String(str);
@ -178,7 +168,7 @@ uint RandomSource::getRandomNumber(uint max) {
return _randSeed % (max + 1); return _randSeed % (max + 1);
} }
uint RandomSource::getRandomBit(void) { uint RandomSource::getRandomBit() {
_randSeed = 0xDEADBF03 * (_randSeed + 1); _randSeed = 0xDEADBF03 * (_randSeed + 1);
_randSeed = (_randSeed >> 13) | (_randSeed << 19); _randSeed = (_randSeed >> 13) | (_randSeed << 19);
return _randSeed & 1; return _randSeed & 1;
@ -193,6 +183,7 @@ uint RandomSource::getRandomNumberRng(uint min, uint max) {
const LanguageDescription g_languages[] = { const LanguageDescription g_languages[] = {
{"zh-cn", "Chinese (China)", ZH_CNA},
{"zh", "Chinese (Taiwan)", ZH_TWN}, {"zh", "Chinese (Taiwan)", ZH_TWN},
{"cz", "Czech", CZ_CZE}, {"cz", "Czech", CZ_CZE},
{"nl", "Dutch", NL_NLD}, {"nl", "Dutch", NL_NLD},
@ -203,6 +194,7 @@ const LanguageDescription g_languages[] = {
{"de", "German", DE_DEU}, {"de", "German", DE_DEU},
{"gr", "Greek", GR_GRE}, {"gr", "Greek", GR_GRE},
{"hb", "Hebrew", HB_ISR}, {"hb", "Hebrew", HB_ISR},
{"hu", "Hungarian", HU_HUN},
{"it", "Italian", IT_ITA}, {"it", "Italian", IT_ITA},
{"jp", "Japanese", JA_JPN}, {"jp", "Japanese", JA_JPN},
{"kr", "Korean", KO_KOR}, {"kr", "Korean", KO_KOR},
@ -212,7 +204,6 @@ const LanguageDescription g_languages[] = {
{"ru", "Russian", RU_RUS}, {"ru", "Russian", RU_RUS},
{"es", "Spanish", ES_ESP}, {"es", "Spanish", ES_ESP},
{"se", "Swedish", SE_SWE}, {"se", "Swedish", SE_SWE},
{"hu", "Hungarian", HU_HUN},
{0, 0, UNK_LANG} {0, 0, UNK_LANG}
}; };
@ -252,7 +243,7 @@ const char *getLanguageDescription(Language id) {
const PlatformDescription g_platforms[] = { const PlatformDescription g_platforms[] = {
{"2gs", "2gs", "2gs", "Apple IIgs", kPlatformApple2GS }, {"2gs", "2gs", "2gs", "Apple IIgs", kPlatformApple2GS},
{"3do", "3do", "3do", "3DO", kPlatform3DO}, {"3do", "3do", "3do", "3DO", kPlatform3DO},
{"acorn", "acorn", "acorn", "Acorn", kPlatformAcorn}, {"acorn", "acorn", "acorn", "Acorn", kPlatformAcorn},
{"amiga", "ami", "amiga", "Amiga", kPlatformAmiga}, {"amiga", "ami", "amiga", "Amiga", kPlatformAmiga},
@ -270,12 +261,12 @@ const PlatformDescription g_platforms[] = {
{"linux", "linux", "linux", "Linux", kPlatformLinux}, {"linux", "linux", "linux", "Linux", kPlatformLinux},
{"macintosh", "mac", "mac", "Macintosh", kPlatformMacintosh}, {"macintosh", "mac", "mac", "Macintosh", kPlatformMacintosh},
{"pce", "pce", "pce", "PC-Engine", kPlatformPCEngine }, {"pce", "pce", "pce", "PC-Engine", kPlatformPCEngine},
{"nes", "nes", "nes", "NES", kPlatformNES}, {"nes", "nes", "nes", "NES", kPlatformNES},
{"segacd", "segacd", "sega", "SegaCD", kPlatformSegaCD}, {"segacd", "segacd", "sega", "SegaCD", kPlatformSegaCD},
{"windows", "win", "win", "Windows", kPlatformWindows}, {"windows", "win", "win", "Windows", kPlatformWindows},
{"playstation", "psx", "psx", "Sony PlayStation", kPlatformPSX}, {"playstation", "psx", "psx", "Sony PlayStation", kPlatformPSX},
{"cdi", "cdi", "cdi", "Phillips CD-i", kPlatformCDi},
{0, 0, 0, "Default", kPlatformUnknown} {0, 0, 0, "Default", kPlatformUnknown}
}; };
@ -430,106 +421,3 @@ void updateGameGUIOptions(const uint32 options) {
} }
} // End of namespace Common } // End of namespace Common
#ifndef DISABLE_TEXT_CONSOLE
void warning(const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
va_start(va, s);
vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);
#if !defined (__SYMBIAN32__)
fprintf(stderr, "WARNING: %s!\n", buf);
#endif
#if defined( USE_WINDBG )
strcat(buf, "\n");
#if defined( _WIN32_WCE )
TCHAR buf_unicode[1024];
MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
OutputDebugString(buf_unicode);
#else
OutputDebugString(buf);
#endif
#endif
}
#endif
void NORETURN error(const char *s, ...) {
char buf_input[STRINGBUFLEN];
char buf_output[STRINGBUFLEN];
va_list va;
// Generate the full error message
va_start(va, s);
vsnprintf(buf_input, STRINGBUFLEN, s, va);
va_end(va);
// Next, give the active engine (if any) a chance to augment the message
if (g_engine) {
g_engine->errorString(buf_input, buf_output, STRINGBUFLEN);
} else {
strncpy(buf_output, buf_input, STRINGBUFLEN);
}
buf_output[STRINGBUFLEN-3] = '\0';
buf_output[STRINGBUFLEN-2] = '\0';
buf_output[STRINGBUFLEN-1] = '\0';
strcat(buf_output, "!\n");
// Print the error message to stderr
fputs(buf_output, stderr);
// Unless this error -originated- within the debugger itself, we
// now invoke the debugger, if available / supported.
if (g_engine) {
GUI::Debugger *debugger = g_engine->getDebugger();
#ifdef _WIN32_WCE
if (isSmartphone())
debugger = 0;
#endif
if (debugger && !debugger->isAttached()) {
debugger->attach(buf_output);
debugger->onFrame();
}
}
#if defined( USE_WINDBG )
#if defined( _WIN32_WCE )
TCHAR buf_output_unicode[1024];
MultiByteToWideChar(CP_ACP, 0, buf_output, strlen(buf_output) + 1, buf_output_unicode, sizeof(buf_output_unicode));
OutputDebugString(buf_output_unicode);
#ifndef DEBUG
drawError(buf_output);
#else
int cmon_break_into_the_debugger_if_you_please = *(int *)(buf_output + 1); // bus error
printf("%d", cmon_break_into_the_debugger_if_you_please); // don't optimize the int out
#endif
#else
OutputDebugString(buf_output);
#endif
#endif
#ifdef PALMOS_MODE
extern void PalmFatalError(const char *err);
PalmFatalError(buf_output);
#endif
#ifdef __SYMBIAN32__
Symbian::FatalError(buf_output);
#endif
// Finally exit. quit() will terminate the program if g_system is present
if (g_system)
g_system->quit();
exit(1);
}

View file

@ -26,11 +26,9 @@
#define COMMON_UTIL_H #define COMMON_UTIL_H
#include "common/sys.h" #include "common/sys.h"
#include "common/textconsole.h"
#include "common/str.h" #include "common/str.h"
#if defined(WIN32)
#include <windows.h>
#endif
/** /**
* Check whether a given pointer is aligned correctly. * Check whether a given pointer is aligned correctly.
@ -89,15 +87,15 @@ public:
* @note Uses space, horizontal tab, carriage return, newline, form feed and vertical tab as delimiters by default. * @note Uses space, horizontal tab, carriage return, newline, form feed and vertical tab as delimiters by default.
*/ */
StringTokenizer(const String &str, const String &delimiters = " \t\r\n\f\v"); StringTokenizer(const String &str, const String &delimiters = " \t\r\n\f\v");
void reset(); //!< Resets the tokenizer to its initial state void reset(); ///< Resets the tokenizer to its initial state
bool empty() const; //!< Returns true if there are no more tokens left in the string, false otherwise bool empty() const; ///< Returns true if there are no more tokens left in the string, false otherwise
String nextToken(); //!< Returns the next token from the string (Or an empty string if there are no more tokens) String nextToken(); ///< Returns the next token from the string (Or an empty string if there are no more tokens)
private: private:
const String _str; //!< The string to be tokenized const String _str; ///< The string to be tokenized
const String _delimiters; //!< String containing all the delimiter characters const String _delimiters; ///< String containing all the delimiter characters
uint _tokenBegin; //!< Latest found token's begin (Valid after a call to nextToken(), zero otherwise) uint _tokenBegin; ///< Latest found token's begin (Valid after a call to nextToken(), zero otherwise)
uint _tokenEnd; //!< Latest found token's end (Valid after a call to nextToken(), zero otherwise) uint _tokenEnd; ///< Latest found token's end (Valid after a call to nextToken(), zero otherwise)
}; };
/** /**
@ -149,7 +147,7 @@ public:
* Identical to getRandomNumber(1), but faster, hopefully. * Identical to getRandomNumber(1), but faster, hopefully.
* @return a random bit, either 0 or 1 * @return a random bit, either 0 or 1
*/ */
uint getRandomBit(void); uint getRandomBit();
/** /**
* Generates a random unsigned integer in the interval [min, max]. * Generates a random unsigned integer in the interval [min, max].
* @param min the lower bound * @param min the lower bound
@ -163,6 +161,7 @@ public:
* List of game language. * List of game language.
*/ */
enum Language { enum Language {
ZH_CNA,
ZH_TWN, ZH_TWN,
CZ_CZE, CZ_CZE,
NL_NLD, NL_NLD,
@ -173,6 +172,7 @@ enum Language {
DE_DEU, DE_DEU,
GR_GRE, GR_GRE,
HB_ISR, HB_ISR,
HU_HUN,
IT_ITA, IT_ITA,
JA_JPN, JA_JPN,
KO_KOR, KO_KOR,
@ -182,7 +182,6 @@ enum Language {
RU_RUS, RU_RUS,
ES_ESP, ES_ESP,
SE_SWE, SE_SWE,
HU_HUN,
UNK_LANG = -1 // Use default language (i.e. none specified) UNK_LANG = -1 // Use default language (i.e. none specified)
}; };
@ -222,11 +221,11 @@ enum Platform {
kPlatformSegaCD, kPlatformSegaCD,
kPlatform3DO, kPlatform3DO,
kPlatformPCEngine, kPlatformPCEngine,
kPlatformApple2GS, kPlatformApple2GS,
kPlatformPC98, kPlatformPC98,
kPlatformWii, kPlatformWii,
kPlatformPSX, kPlatformPSX,
kPlatformCDi,
kPlatformUnknown = -1 kPlatformUnknown = -1
}; };
@ -303,28 +302,4 @@ void updateGameGUIOptions(const uint32 options);
} // End of namespace Common } // End of namespace Common
#if defined(__GNUC__)
void error(const char *s, ...) GCC_PRINTF(1, 2) NORETURN;
#else
void NORETURN error(const char *s, ...);
#endif
#ifdef DISABLE_TEXT_CONSOLE
inline int printf(const char *s, ...) { return 0; }
inline void warning(const char *s, ...) {}
#else
/**
* Print a warning message to the text console (stderr).
* Automatically prepends the text "WARNING: " and appends
* an exclamation mark and a newline.
*/
void warning(const char *s, ...) GCC_PRINTF(1, 2);
#endif
#endif #endif

View file

@ -48,7 +48,7 @@ bool XMLParser::loadFile(const FSNode &node) {
return true; return true;
} }
bool XMLParser::loadBuffer(const byte *buffer, uint32 size, bool disposable) { bool XMLParser::loadBuffer(const byte *buffer, uint32 size, DisposeAfterUse::Flag disposable) {
_stream = new MemoryReadStream(buffer, size, disposable); _stream = new MemoryReadStream(buffer, size, disposable);
_fileName = "Memory Stream"; _fileName = "Memory Stream";
return true; return true;

View file

@ -97,8 +97,6 @@ class FSNode;
* @see XMLParser::keyCallback() * @see XMLParser::keyCallback()
*/ */
class XMLParser { class XMLParser {
static const int kErrorMessageWidth = 512;
public: public:
/** /**
* Parser constructor. * Parser constructor.
@ -198,7 +196,7 @@ public:
* i.e. if it can be freed safely after it's * i.e. if it can be freed safely after it's
* no longer needed by the parser. * no longer needed by the parser.
*/ */
bool loadBuffer(const byte *buffer, uint32 size, bool disposable = false); bool loadBuffer(const byte *buffer, uint32 size, DisposeAfterUse::Flag disposable = DisposeAfterUse::NO);
bool loadStream(Common::SeekableReadStream *stream); bool loadStream(Common::SeekableReadStream *stream);

27
config.guess vendored
View file

@ -4,7 +4,7 @@
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc. # Free Software Foundation, Inc.
timestamp='2009-09-18' timestamp='2009-12-13'
# This file is free software; you can redistribute it and/or modify it # This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by # under the terms of the GNU General Public License as published by
@ -57,7 +57,7 @@ GNU config.guess ($timestamp)
Originally written by Per Bothner. Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -333,6 +333,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;; exit ;;
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
echo i386-pc-auroraux${UNAME_RELEASE}
exit ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
eval $set_cc_for_build eval $set_cc_for_build
SUN_ARCH="i386" SUN_ARCH="i386"
@ -807,12 +810,12 @@ EOF
i*:PW*:*) i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32 echo ${UNAME_MACHINE}-pc-pw32
exit ;; exit ;;
*:Interix*:[3456]*) *:Interix*:*)
case ${UNAME_MACHINE} in case ${UNAME_MACHINE} in
x86) x86)
echo i586-pc-interix${UNAME_RELEASE} echo i586-pc-interix${UNAME_RELEASE}
exit ;; exit ;;
EM64T | authenticamd | genuineintel) authenticamd | genuineintel | EM64T)
echo x86_64-unknown-interix${UNAME_RELEASE} echo x86_64-unknown-interix${UNAME_RELEASE}
exit ;; exit ;;
IA64) IA64)
@ -891,7 +894,15 @@ EOF
echo frv-unknown-linux-gnu echo frv-unknown-linux-gnu
exit ;; exit ;;
i*86:Linux:*:*) i*86:Linux:*:*)
echo ${UNAME_MACHINE}-pc-linux-gnu LIBC=gnu
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#ifdef __dietlibc__
LIBC=dietlibc
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
exit ;; exit ;;
ia64:Linux:*:*) ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-gnu
@ -918,11 +929,7 @@ EOF
#endif #endif
#endif #endif
EOF EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
/^CPU/{
s: ::g
p
}'`"
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;; ;;
or32:Linux:*:*) or32:Linux:*:*)

20
config.sub vendored
View file

@ -4,7 +4,7 @@
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc. # Free Software Foundation, Inc.
timestamp='2009-08-19' timestamp='2009-12-13'
# This file is (in principle) common to ALL GNU software. # This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software # The presence of a machine in this file suggests that SOME GNU software
@ -76,7 +76,7 @@ version="\
GNU config.sub ($timestamp) GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -287,6 +287,7 @@ case $basic_machine in
| pdp10 | pdp11 | pj | pjl \ | pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \ | pyramid \
| rx \
| score \ | score \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \ | sh64 | sh64le \
@ -294,13 +295,14 @@ case $basic_machine in
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu | strongarm \ | spu | strongarm \
| tahoe | thumb | tic4x | tic80 | tron \ | tahoe | thumb | tic4x | tic80 | tron \
| ubicom32 \
| v850 | v850e \ | v850 | v850e \
| we32k \ | we32k \
| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
| z8k | z80) | z8k | z80)
basic_machine=$basic_machine-unknown basic_machine=$basic_machine-unknown
;; ;;
m6811 | m68hc11 | m6812 | m68hc12) m6811 | m68hc11 | m6812 | m68hc12 | picochip)
# Motorola 68HC11/12. # Motorola 68HC11/12.
basic_machine=$basic_machine-unknown basic_machine=$basic_machine-unknown
os=-none os=-none
@ -371,7 +373,7 @@ case $basic_machine in
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \ | pyramid-* \
| romp-* | rs6000-* \ | romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
@ -380,6 +382,7 @@ case $basic_machine in
| tahoe-* | thumb-* \ | tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
| tron-* \ | tron-* \
| ubicom32-* \
| v850-* | v850e-* | vax-* \ | v850-* | v850e-* | vax-* \
| we32k-* \ | we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
@ -1253,6 +1256,9 @@ case $os in
# First match some system type aliases # First match some system type aliases
# that might get confused with valid system types. # that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception. # -solaris* is a basic system type, with this one exception.
-auroraux)
os=-auroraux
;;
-solaris1 | -solaris1.*) -solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'` os=`echo $os | sed -e 's|solaris1|sunos4|'`
;; ;;
@ -1274,8 +1280,8 @@ case $os in
# -sysv* is not here because it comes later, after sysvr4. # -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -kopensolaris* \ | -sym* | -kopensolaris* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \ | -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
@ -1296,7 +1302,7 @@ case $os in
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops*) | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
# Remember, each alternative MUST END IN *, to match a version number. # Remember, each alternative MUST END IN *, to match a version number.
;; ;;
-qnx*) -qnx*)

479
configure vendored
View file

@ -86,6 +86,13 @@ _vorbis=auto
_tremor=auto _tremor=auto
_flac=auto _flac=auto
_mad=auto _mad=auto
_alsa=auto
_fluidsynth=auto
# Default option behaviour yes/no
_debug_build=auto
_release_build=auto
_text_console=no
_mt32emu=yes
# Default vkeybd/keymapper options # Default vkeybd/keymapper options
_vkeybd=no _vkeybd=no
_keymapper=no _keymapper=no
@ -198,7 +205,7 @@ add_to_config_mk_if_no() {
# #
# Determine sdl-config # Determine sdl-config
# #
# TODO: small bit of code to test sdl useability # TODO: small bit of code to test sdl usability
find_sdlconfig() { find_sdlconfig() {
echo_n "Looking for sdl-config... " echo_n "Looking for sdl-config... "
sdlconfigs="$_sdlconfig:sdl-config:sdl11-config:sdl12-config" sdlconfigs="$_sdlconfig:sdl-config:sdl11-config:sdl12-config"
@ -248,7 +255,7 @@ get_system_exe_extension() {
gp2x-linux) gp2x-linux)
_exeext=".gp2x" _exeext=".gp2x"
;; ;;
dreamcast | wii | gamecube | nds | psp) dreamcast | wii | gamecube | nds | psp | ps2)
_exeext=".elf" _exeext=".elf"
;; ;;
*) *)
@ -504,7 +511,7 @@ Usage: $0 [OPTIONS]...
Configuration: Configuration:
-h, --help display this help and exit -h, --help display this help and exit
--backend=BACKEND backend to build (sdl, dc, gp2x, gp2xwiz, iphone, morphos, nds, psp, wii, wince, linuxmoto, null) [sdl] --backend=BACKEND backend to build (sdl, dc, gp2x, gp2xwiz, iphone, morphos, nds, psp, ps2, wii, wince, linuxmoto, null) [sdl]
Installation directories: Installation directories:
--prefix=DIR use this prefix for installing Residual [/usr/local] --prefix=DIR use this prefix for installing Residual [/usr/local]
@ -518,11 +525,12 @@ Special configuration feature:
special targets: linupy for Yopy PDA special targets: linupy for Yopy PDA
dreamcast for Sega Dreamcast dreamcast for Sega Dreamcast
wii for Nintendo Wii wii for Nintendo Wii
gamecube for Nintendo Gamecube gamecube for Nintendo GameCube
nds for Nintendo DS nds for Nintendo DS
iphone for Apple iPhone iphone for Apple iPhone
wince for Windows CE wince for Windows CE
psp for PlayStation Portable psp for PlayStation Portable
ps2 for PlayStation 2
Game engines: Game engines:
--enable-all-engines enable all engines --enable-all-engines enable all engines
@ -533,11 +541,16 @@ Optional Features:
--enable-Werror treat warnings as errors --enable-Werror treat warnings as errors
--enable-plugins enable the support for dynamic plugins --enable-plugins enable the support for dynamic plugins
--default-dynamic make plugins dynamic by default --default-dynamic make plugins dynamic by default
--disable-mt32emu don't enable the integrated MT-32 emulator
--enable-profiling enable building with gprof profile information --enable-profiling enable building with gprof profile information
--enable-release set flags to build release binary --enable-release set flags to build release binary
--enable-text-console use text console instead of graphical console
--enable-verbose-build enable regular echoing of commands during build process --enable-verbose-build enable regular echoing of commands during build process
Optional Libraries: Optional Libraries:
--with-alsa-prefix=DIR Prefix where alsa is installed (optional)
--disable-alsa disable ALSA midi sound support [autodetect]
--with-ogg-prefix=DIR Prefix where libogg is installed (optional) --with-ogg-prefix=DIR Prefix where libogg is installed (optional)
--with-vorbis-prefix=DIR Prefix where libvorbis is installed (optional) --with-vorbis-prefix=DIR Prefix where libvorbis is installed (optional)
--disable-vorbis disable Ogg Vorbis support [autodetect] --disable-vorbis disable Ogg Vorbis support [autodetect]
@ -552,6 +565,8 @@ Optional Libraries:
--disable-flac disable FLAC support [autodetect] --disable-flac disable FLAC support [autodetect]
--with-zlib-prefix=DIR Prefix where zlib is installed (optional) --with-zlib-prefix=DIR Prefix where zlib is installed (optional)
--with-fluidsynth-prefix=DIR Prefix where libfluidsynth is installed (optional)
--disable-fluidsynth disable fluidsynth MIDI driver [autodetect]
--with-sdl-prefix=DIR Prefix where the sdl-config script is installed (optional) --with-sdl-prefix=DIR Prefix where the sdl-config script is installed (optional)
@ -574,6 +589,8 @@ DEBFLAGS="-g"
for ac_option in $@; do for ac_option in $@; do
case "$ac_option" in case "$ac_option" in
--enable-alsa) _alsa=yes ;;
--disable-alsa) _alsa=no ;;
--enable-vorbis) _vorbis=yes ;; --enable-vorbis) _vorbis=yes ;;
--disable-vorbis) _vorbis=no ;; --disable-vorbis) _vorbis=no ;;
--enable-tremor) _tremor=yes ;; --enable-tremor) _tremor=yes ;;
@ -583,13 +600,28 @@ for ac_option in $@; do
--enable-mad) _mad=yes ;; --enable-mad) _mad=yes ;;
--disable-mad) _mad=no ;; --disable-mad) _mad=no ;;
--disable-fluidsynth) _fluidsynth=no ;;
--enable-verbose-build) _verbose_build=yes ;; --enable-verbose-build) _verbose_build=yes ;;
--enable-plugins) _dynamic_modules=yes ;; --enable-plugins) _dynamic_modules=yes ;;
--default-dynamic) _plugins_default=dynamic ;; --default-dynamic) _plugins_default=dynamic ;;
--enable-mt32emu) _mt32emu=yes ;;
--disable-mt32emu) _mt32emu=no ;;
--enable-vkeybd) _vkeybd=yes ;; --enable-vkeybd) _vkeybd=yes ;;
--disable-vkeybd) _vkeybd=no ;; --disable-vkeybd) _vkeybd=no ;;
--enable-keymapper) _keymapper=yes ;; --enable-keymapper) _keymapper=yes ;;
--disable-keymapper) _keymapper=no ;; --disable-keymapper) _keymapper=no ;;
--enable-text-console) _text_console=yes ;;
--disable-text-console) _text_console=no ;;
--with-fluidsynth-prefix=*)
arg=`echo $ac_option | cut -d '=' -f 2`
FLUIDSYNTH_CFLAGS="-I$arg/include"
FLUIDSYNTH_LIBS="-L$arg/lib"
;;
--with-alsa-prefix=*)
arg=`echo $ac_option | cut -d '=' -f 2`
ALSA_CFLAGS="-I$arg/include"
ALSA_LIBS="-L$arg/lib"
;;
--with-ogg-prefix=*) --with-ogg-prefix=*)
arg=`echo $ac_option | cut -d '=' -f 2` arg=`echo $ac_option | cut -d '=' -f 2`
OGG_CFLAGS="-I$arg/include" OGG_CFLAGS="-I$arg/include"
@ -703,6 +735,11 @@ motomagx)
_host_cpu=arm _host_cpu=arm
_host_alias=arm-linux-gnueabi _host_alias=arm-linux-gnueabi
;; ;;
samsungtv)
_host_os=linux
_host_cpu=arm
_host_alias=arm-linux-gnueabi
;;
arm-riscos) arm-riscos)
_host_os=riscos _host_os=riscos
_host_cpu=arm _host_cpu=arm
@ -765,8 +802,29 @@ psp)
_host_os=psp _host_os=psp
_host_cpu=mipsallegrexel _host_cpu=mipsallegrexel
_host_alias=psp _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" LDFLAGS="$LDFLAGS -L$PSPDEV/psp/sdk/lib -specs=$_srcdir/backends/platform/psp/psp.spec"
;; ;;
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
;;
*) *)
if test -n "$_host"; then if test -n "$_host"; then
guessed_host=`$_srcdir/config.sub $_host` guessed_host=`$_srcdir/config.sub $_host`
@ -824,8 +882,15 @@ wii | gamecube | nds)
fi fi
;; ;;
psp) psp)
if test -z "$PSPDEV"; then PSPSDK=$(psp-config --pspsdk-path)
echo "Please set PSPDEV in your environment. export PSPDEV=<path to psp toolchain>" if test -z "$PSPSDK"; then
echo "Please set the path to PSPSDK in your environment."
exit 1
fi
;;
ps2)
if test -z "$PS2SDK"; then
echo "Please set PS2SDK in your environment. export PS2SDK=<path to ps2 sdk>"
exit 1 exit 1
fi fi
;; ;;
@ -849,7 +914,7 @@ EOF
if test -n "$_host"; then if test -n "$_host"; then
# In cross-compiling mode, we cannot run the result # In cross-compiling mode, we cannot run the result
eval "$1 $CXXFLAGS $LDFLAGS -o tmp_cxx_compiler$HOSTEXEEXT tmp_cxx_compiler.cpp" 2> /dev/null && rm -f tmp_cxx_compiler$HOSTEXEEXT tmp_cxx_compiler.cpp eval "$1 $CXXFLAGS $LDFLAGS -o tmp_cxx_compiler$HOSTEXEEXT -c tmp_cxx_compiler.cpp" 2> /dev/null && rm -f tmp_cxx_compiler$HOSTEXEEXT tmp_cxx_compiler.cpp
else else
eval "$1 $CXXFLAGS $LDFLAGS -o tmp_cxx_compiler$HOSTEXEEXT tmp_cxx_compiler.cpp" 2> /dev/null && eval "./tmp_cxx_compiler$HOSTEXEEXT 2> /dev/null" && rm -rf tmp_cxx_compiler$HOSTEXEEXT tmp_cxx_compiler.dSYM tmp_cxx_compiler.cpp eval "$1 $CXXFLAGS $LDFLAGS -o tmp_cxx_compiler$HOSTEXEEXT tmp_cxx_compiler.cpp" 2> /dev/null && eval "./tmp_cxx_compiler$HOSTEXEEXT 2> /dev/null" && rm -rf tmp_cxx_compiler$HOSTEXEEXT tmp_cxx_compiler.dSYM tmp_cxx_compiler.cpp
fi fi
@ -882,6 +947,9 @@ if test -z "$CXX"; then
exit 1 exit 1
fi fi
# By default, use the C++ compiler as linker
LD=$CXX
# #
# Determine the compiler version # Determine the compiler version
# #
@ -1096,9 +1164,19 @@ echo "$_have_x86"
echo_n "Checking hosttype... " echo_n "Checking hosttype... "
echo $_host_os echo $_host_os
case $_host_os in case $_host_os in
linux* | uclinux* | openbsd* | netbsd* | bsd* | sunos* | hpux*) linux* | uclinux*)
# When not cross-compiling, enable large file support, but don't
# care if getconf doesn't exist or doesn't recognize LFS_CFLAGS.
if test -z "$_host"; then
CXXFLAGS="$CXXFLAGS $(getconf LFS_CFLAGS 2>/dev/null)"
fi
DEFINES="$DEFINES -DUNIX -DUSE_OPENGL" DEFINES="$DEFINES -DUNIX -DUSE_OPENGL"
LIBS="$LIBS -lGL -lGLU -L/usr/X11/lib" LIBS="$LIBS -lGL -lGLU -L/usr/X11/lib"
;;
openbsd* | netbsd* | bsd* | sunos* | hpux*)
DEFINES="$DEFINES -DUNIX -DUSE_OPENGL"
LIBS="$LIBS -lGL -lGLU -L/usr/X11/lib"
;; ;;
freebsd*) freebsd*)
DEFINES="$DEFINES -DUNIX -DUSE_OPENGL" DEFINES="$DEFINES -DUNIX -DUSE_OPENGL"
@ -1108,42 +1186,46 @@ case $_host_os in
;; ;;
beos*) beos*)
DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE" DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
# Needs -lbind -lsocket for the timidity MIDI driver
LDFLAGS="-L/boot/home/config/lib" LDFLAGS="-L/boot/home/config/lib"
CFLAGS="-I/boot/home/config/include" CFLAGS="-I/boot/home/config/include"
CXXFLAGS="$CXXFLAGS -fhuge-objects" CXXFLAGS="$CXXFLAGS -fhuge-objects"
type_1_byte='char' LIBS="$LIBS -lbind -lsocket"
type_2_byte='short' # FIXME: Please document why 'long' has to be used instead of int
type_4_byte='long' #type_4_byte='long'
;; ;;
haiku*) haiku*)
DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE" DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
# Needs -lnetwork for the timidity MIDI driver
LIBS="$LIBS -lnetwork"
CXXFLAGS="$CXXFLAGS -fhuge-objects" CXXFLAGS="$CXXFLAGS -fhuge-objects"
type_1_byte='char' # FIXME: Please document why 'long' has to be used instead of int
type_2_byte='short' #type_4_byte='long'
type_4_byte='long'
;; ;;
solaris*) solaris*)
DEFINES="$DEFINES -DUNIX -DSOLARIS -DSYSTEM_NOT_SUPPORTING_D_TYPE" DEFINES="$DEFINES -DUNIX -DSOLARIS -DSYSTEM_NOT_SUPPORTING_D_TYPE"
LIBS="$LIBS -lnsl" # Needs -lbind -lsocket for the timidity MIDI driver
LIBS="$LIBS -lnsl -lsocket"
;; ;;
irix*) irix*)
DEFINES="$DEFINES -DUNIX -DIRIX -DSYSTEM_NOT_SUPPORTING_D_TYPE" DEFINES="$DEFINES -DUNIX -DIRIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
LIBS="$LIBS -lmd" LIBS="$LIBS -lmd -lfastm -lm"
_ranlib=: _ranlib=:
;; ;;
darwin*) darwin*)
DEFINES="$DEFINES -DUNIX -DMACOSX -DUSE_OPENGL" DEFINES="$DEFINES -DUNIX -DMACOSX -DUSE_OPENGL"
LIBS="$LIBS -framework QuickTime -framework AudioUnit -framework AudioToolbox -framework Carbon -framework OpenGL \ LIBS="$LIBS -framework QuickTime -framework AudioUnit -framework AudioToolbox -framework Carbon -framework CoreMIDI -framework OpenGL \
-dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib" -dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"
add_line_to_config_mk 'MACOSX = 1'
;; ;;
mingw*) mingw*)
DEFINES="$DEFINES -DWIN32 -D__USE_MINGW_ANSI_STDIO=0 -DUSE_OPENGL" DEFINES="$DEFINES -DWIN32 -D__USE_MINGW_ANSI_STDIO=0 -DUSE_OPENGL"
LIBS="$LIBS -lmingw32 -lopengl32 -lglu32" LIBS="$LIBS -lmingw32 -lwinmm -lopengl32 -lglu32"
OBJS="$OBJS residualico.o" OBJS="$OBJS residualico.o"
;; ;;
cygwin*) cygwin*)
echo ERROR: Cygwin building is not supported by ScummVM anymore. Consider using MinGW. echo ERROR: Cygwin building is not supported by ScummVM anymore. Consider using MinGW.
exit 0 exit 1
;; ;;
os2-emx*) os2-emx*)
DEFINES="$DEFINES -DUNIX" DEFINES="$DEFINES -DUNIX"
@ -1156,8 +1238,8 @@ case $_host_os in
CXXFLAGS="$CXXFLAGS -mcrt=newlib -mstrict-align -mcpu=750 -mtune=7400" CXXFLAGS="$CXXFLAGS -mcrt=newlib -mstrict-align -mcpu=750 -mtune=7400"
LDFLAGS="$LDFLAGS -mcrt=newlib -use-dynld -Lsobjs:" LDFLAGS="$LDFLAGS -mcrt=newlib -use-dynld -Lsobjs:"
LIBS="$LIBS -lGL -lGLU" LIBS="$LIBS -lGL -lGLU"
type_1_byte='char' # We have to use 'long' for our 4 byte typedef because AmigaOS already typedefs (u)int32
type_2_byte='short' # as (unsigned) long, and consequently we'd get a compiler error otherwise.
type_4_byte='long' type_4_byte='long'
;; ;;
dreamcast) dreamcast)
@ -1177,13 +1259,20 @@ case $_host_os in
;; ;;
nds) nds)
# TODO nds # TODO nds
DEFINES="$DEFINES -D__DS__ -DNDS -DARM9 -DARM -DNONSTANDARD_PORT"
;; ;;
psp) psp)
CXXFLAGS="$CXXFLAGS -O3 -G0 -I$PSPDEV/psp/sdk/include -D_PSP_FW_VERSION=150" CXXFLAGS="$CXXFLAGS -O3 -I$PSPSDK/include -D_PSP_FW_VERSION=150"
;;
ps2)
# TODO ps2
CXXFLAGS="$CXXFLAGS -G2"
DEFINES="$DEFINES -D_EE -D__PLAYSTATION2__"
;; ;;
wince) wince)
CXXFLAGS="$CXXFLAGS -O3 -march=armv4 -mtune=xscale -D_WIN32_WCE=300 -D__ARM__ -D_ARM_ -DUNICODE -DFPM_DEFAULT -DNONSTANDARD_PORT" CXXFLAGS="$CXXFLAGS -O3 -march=armv4 -mtune=xscale"
CXXFLAGS="$CXXFLAGS -DWIN32 -Dcdecl= -D__cdecl__=" DEFINES="$DEFINES -D_WIN32_WCE=300 -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 # given this is a shell script assume some type of unix
*) *)
@ -1194,29 +1283,38 @@ esac
if test -n "$_host"; then if test -n "$_host"; then
# Cross-compiling mode - add your target here if needed # Cross-compiling mode - add your target here if needed
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
case "$_host" in case "$_host" in
linupy|arm-riscos) linupy|arm-riscos)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes" DEFINES="$DEFINES -DUNIX -DLINUPY"
DEFINES="$DEFINES -DUNIX" _need_memalign=yes
#not true for all ARM systems, but the interesting ones are all LE. Most (if not all) BE arm devices don't have a screen ;;
_endian=little arm-linux|arm*-linux-gnueabi|arm-*-linux|*-angstrom-linux)
DEFINES="$DEFINES -DUNIX"
_need_memalign=yes _need_memalign=yes
type_1_byte='char'
type_2_byte='short'
type_4_byte='int'
add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1'
add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1'
;; ;;
motoezx) samsungtv)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes" DEFINES="$DEFINES -DUNIX -DSAMSUNGTV -DDISABLE_COMMAND_LINE"
DEFINES="$DEFINES -DUNIX -DMOTOEZX" ASFLAGS="$ASFLAGS -mfpu=vfp"
#not true for all ARM systems, but the interesting ones are all LE. Most (if not all) BE arm devices don't have a screen HOSTEXEEXT=".so"
_need_memalign=yes
add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1'
add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1'
add_line_to_config_mk 'USE_ARM_GFX_ASM = 1'
add_line_to_config_mk 'USE_ARM_COSTUME_ASM = 1'
add_line_to_config_mk 'USE_ARM_SCALER_ASM = 1'
_backend="samsungtv"
_mt32emu="no"
_build_scalers="yes"
_build_hq_scalers="yes"
_vkeybd="yes"
;;
motoezx)
DEFINES="$DEFINES -DUNIX -DMOTOEZX"
ASFLAGS="$ASFLAGS -mfpu=vfp" ASFLAGS="$ASFLAGS -mfpu=vfp"
_endian=little
_need_memalign=yes _need_memalign=yes
type_1_byte='char'
type_2_byte='short'
type_4_byte='int'
add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1'
add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1'
add_line_to_config_mk 'USE_ARM_GFX_ASM = 1' add_line_to_config_mk 'USE_ARM_GFX_ASM = 1'
@ -1225,23 +1323,22 @@ if test -n "$_host"; then
_backend="linuxmoto" _backend="linuxmoto"
_build_hq_scalers="no" _build_hq_scalers="no"
_mt32emu="no" _mt32emu="no"
_vkeybd="yes"
_port_mk="backends/platform/linuxmoto/linuxmoto.mk" _port_mk="backends/platform/linuxmoto/linuxmoto.mk"
;; ;;
motomagx) motomagx)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
DEFINES="$DEFINES -DUNIX -DMOTOMAGX" DEFINES="$DEFINES -DUNIX -DMOTOMAGX"
#not true for all ARM systems, but the interesting ones are all LE. Most (if not all) BE arm devices don't have a screen
ASFLAGS="$ASFLAGS -mfpu=vfp" ASFLAGS="$ASFLAGS -mfpu=vfp"
_endian=little
_need_memalign=yes _need_memalign=yes
type_1_byte='char'
type_2_byte='short'
type_4_byte='int'
add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1'
add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1'
add_line_to_config_mk 'USE_ARM_GFX_ASM = 1'
add_line_to_config_mk 'USE_ARM_COSTUME_ASM = 1'
add_line_to_config_mk 'USE_ARM_SCALER_ASM = 1'
_backend="linuxmoto" _backend="linuxmoto"
_build_hq_scalers="no" _build_hq_scalers="no"
_mt32emu="no" _mt32emu="no"
_vkeybd="yes"
_port_mk="backends/platform/linuxmoto/linuxmoto.mk" _port_mk="backends/platform/linuxmoto/linuxmoto.mk"
;; ;;
bfin*) bfin*)
@ -1252,127 +1349,103 @@ if test -n "$_host"; then
_strip=$_host-strip _strip=$_host-strip
;; ;;
gp2xwiz) gp2xwiz)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
DEFINES="$DEFINES -DUNIX -DGP2XWIZ -DNDEBUG" DEFINES="$DEFINES -DUNIX -DGP2XWIZ -DNDEBUG"
CXXFLAGS="$CXXFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s" CXXFLAGS="$CXXFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
ASFLAGS="$ASFLAGS -mfloat-abi=soft"
LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS"
_endian=little
_need_memalign=yes _need_memalign=yes
type_1_byte='char'
type_2_byte='short'
type_4_byte='int'
add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1'
add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1'
add_line_to_config_mk 'USE_ARM_GFX_ASM = 1'
add_line_to_config_mk 'USE_ARM_SCALER_ASM = 1'
add_line_to_config_mk 'USE_ARM_COSTUME_ASM = 1'
_backend="gp2xwiz" _backend="gp2xwiz"
_build_hq_scalers="no" _build_hq_scalers="no"
_mt32emu="no" _mt32emu="no"
_vkeybd="yes"
;; ;;
gp2x) gp2x)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
DEFINES="$DEFINES -DUNIX -DGP2X -DNDEBUG" DEFINES="$DEFINES -DUNIX -DGP2X -DNDEBUG"
CXXFLAGS="$CXXFLAGS -march=armv4t" CXXFLAGS="$CXXFLAGS -march=armv4t"
ASFLAGS="$ASFLAGS -mfloat-abi=soft" ASFLAGS="$ASFLAGS -mfloat-abi=soft"
LDFLAGS="$LDFLAGS -static" LDFLAGS="$LDFLAGS -static"
_endian=little
_need_memalign=yes _need_memalign=yes
type_1_byte='char'
type_2_byte='short'
type_4_byte='int'
add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1'
add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1'
add_line_to_config_mk 'USE_ARM_GFX_ASM = 1'
add_line_to_config_mk 'USE_ARM_SCALER_ASM = 1'
add_line_to_config_mk 'USE_ARM_COSTUME_ASM = 1'
_backend="gp2x" _backend="gp2x"
_build_hq_scalers="no" _build_hq_scalers="no"
_mt32emu="no" _mt32emu="no"
_vkeybd="yes"
;; ;;
neuros) neuros)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
DEFINES="$DEFINES -DUNIX -DNEUROS" DEFINES="$DEFINES -DUNIX -DNEUROS"
_endian=little
_need_memalign=yes _need_memalign=yes
type_1_byte='char'
type_2_byte='short'
type_4_byte='int'
_backend='null' _backend='null'
_build_hq_scalers="no"
_mt32emu="no"
;; ;;
ppc-amigaos) ppc-amigaos)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
_endian=big _endian=big
_need_memalign=yes _need_memalign=yes
type_1_byte='char' # FIXME: Please document why 'long' has to be used instead of int
type_2_byte='short' #type_4_byte='long'
type_4_byte='long'
;; ;;
m68k-atari-mint) m68k-atari-mint)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE" DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
_endian=big _endian=big
_need_memalign=yes _need_memalign=yes
type_1_byte='char' # FIXME: Please document why 'long' has to be used instead of int
type_2_byte='short' #type_4_byte='long'
type_4_byte='long'
_ranlib=m68k-atari-mint-ranlib _ranlib=m68k-atari-mint-ranlib
_ar="m68k-atari-mint-ar cru" _ar="m68k-atari-mint-ar cru"
;; ;;
*mingw32*) *mingw32*)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
_endian=little
type_1_byte='char'
type_2_byte='short'
type_4_byte='int'
_sdlconfig=$_host-sdl-config _sdlconfig=$_host-sdl-config
_windres=$_host-windres _windres=$_host-windres
_ar="$_host-ar cru" _ar="$_host-ar cru"
_ranlib=$_host-ranlib _ranlib=$_host-ranlib
;; ;;
iphone) iphone)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
DEFINES="$DEFINES -DIPHONE -DUNIX" DEFINES="$DEFINES -DIPHONE -DUNIX"
_endian=little
_need_memalign=yes _need_memalign=yes
type_1_byte='char'
type_2_byte='short'
type_4_byte='int'
add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1'
add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1'
_backend="iphone" _backend="iphone"
_build_hq_scalers="no"
;; ;;
wince) wince)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
LDFLAGS="$LDFLAGS -Wl,-Map,scummvm.exe.map -Wl,--stack,65536" LDFLAGS="$LDFLAGS -Wl,-Map,scummvm.exe.map -Wl,--stack,65536"
_endian=little
_need_memalign=yes _need_memalign=yes
type_1_byte='char'
type_2_byte='short'
type_4_byte='int'
add_line_to_config_mk 'USE_TREMOLO = 1' add_line_to_config_mk 'USE_TREMOLO = 1'
add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1'
add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1'
add_line_to_config_mk 'USE_ARM_GFX_ASM = 1'
add_line_to_config_mk 'USE_ARM_COSTUME_ASM = 1'
add_line_to_config_mk 'USE_ARM_SCALER_ASM = 1'
_backend="wince" _backend="wince"
_mt32emu="no" _mt32emu="no"
_port_mk="backends/platform/wince/wince.mk" _port_mk="backends/platform/wince/wince.mk"
;; ;;
dreamcast) dreamcast)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
DEFINES="$DEFINES -DDISABLE_DEFAULT_SAVEFILEMANAGER -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE" 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" CXXFLAGS="$CXXFLAGS -O3 -funroll-loops -fschedule-insns2 -fomit-frame-pointer -fdelete-null-pointer-checks"
_endian=little
_need_memalign=yes _need_memalign=yes
type_1_byte='char'
type_2_byte='short'
type_4_byte='int'
_backend="dc" _backend="dc"
_build_scalers="no"
_build_hq_scalers="no"
_mad="yes" _mad="yes"
_zlib="yes" _zlib="yes"
add_line_to_config_mk 'include $(srcdir)/backends/platform/dc/dreamcast.mk' add_line_to_config_mk 'include $(srcdir)/backends/platform/dc/dreamcast.mk'
;; ;;
wii) wii)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
_endian=big _endian=big
_need_memalign=yes _need_memalign=yes
type_1_byte='char'
type_2_byte='short'
type_4_byte='int'
_backend="wii" _backend="wii"
_build_scalers="no"
_build_hq_scalers="no"
_port_mk="backends/platform/wii/wii.mk" _port_mk="backends/platform/wii/wii.mk"
add_line_to_config_mk 'GAMECUBE = 0' add_line_to_config_mk 'GAMECUBE = 0'
add_line_to_config_h "#define DEBUG_WII_USBGECKO" add_line_to_config_h "#define DEBUG_WII_USBGECKO"
@ -1383,13 +1456,12 @@ if test -n "$_host"; then
add_line_to_config_h "#define USE_WII_KBD" add_line_to_config_h "#define USE_WII_KBD"
;; ;;
gamecube) gamecube)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
_endian=big _endian=big
_need_memalign=yes _need_memalign=yes
type_1_byte='char'
type_2_byte='short'
type_4_byte='int'
_backend="wii" _backend="wii"
_build_scalers="no"
_build_hq_scalers="no"
_mt32emu="no"
_port_mk="backends/platform/wii/wii.mk" _port_mk="backends/platform/wii/wii.mk"
add_line_to_config_mk 'GAMECUBE = 1' add_line_to_config_mk 'GAMECUBE = 1'
add_line_to_config_h '#define GAMECUBE' add_line_to_config_h '#define GAMECUBE'
@ -1398,19 +1470,13 @@ if test -n "$_host"; then
add_line_to_config_h "/* #define DEBUG_WII_GDB */" add_line_to_config_h "/* #define DEBUG_WII_GDB */"
;; ;;
nds) nds)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
# TODO: complete this # TODO: complete this
# TODO: Maybe rename nds -> ds (would be more consistent with other backends) # TODO: Maybe rename nds -> ds (would be more consistent with other backends)
DEFINES="$DEFINES -D__DS__ -DNDS -DARM9 -DARM -DNONSTANDARD_PORT"
DEFINES="$DEFINES -DDISABLE_FANCY_THEMES -DVECTOR_RENDERER_FORMAT=1555" DEFINES="$DEFINES -DDISABLE_FANCY_THEMES -DVECTOR_RENDERER_FORMAT=1555"
DEFINES="$DEFINES -DDISABLE_DEFAULT_SAVEFILEMANAGER" DEFINES="$DEFINES -DDISABLE_DEFAULT_SAVEFILEMANAGER"
DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE" DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE"
DEFINES="$DEFINES -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE" DEFINES="$DEFINES -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE"
_endian=little
_need_memalign=yes _need_memalign=yes
type_1_byte='char'
type_2_byte='short'
type_4_byte='int'
_backend="nds" _backend="nds"
_build_hq_scalers="no" _build_hq_scalers="no"
_mt32emu="no" _mt32emu="no"
@ -1420,17 +1486,45 @@ if test -n "$_host"; then
add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1'
;; ;;
psp) psp)
echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
_endian=little
_need_memalign=yes _need_memalign=yes
type_1_byte='char'
type_2_byte='short'
type_4_byte='int'
_backend="psp" _backend="psp"
_build_scalers="no"
_build_hq_scalers="no"
_mt32emu="no"
_port_mk="backends/platform/psp/psp.mk" _port_mk="backends/platform/psp/psp.mk"
;; ;;
ps2)
# TODO: complete this
DEFINES="$DEFINES -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DDISABLE_DOSBOX_OPL"
_need_memalign=yes
_backend="ps2"
_build_scalers="no"
_build_hq_scalers="no"
_mt32emu="no"
# HACK to enable mad & zlib (they are not properly detected due to linker issues).
# This trick doesn't work for tremor right now, as the PS2 port the resulting library
# libtremor, while our code later on expects it to be called libvorbisidec.
# TODO: Enable tremor, e.g. by adding -ltremor or by renaming the lib.
_mad="yes"
_zlib="yes"
# HACK to fix compilation of C source files for now.
add_line_to_config_mk 'CC = ee-gcc'
# HACK to fix linking for now. It seems ee-g++ does not handle linking correctly.
LD=ee-gcc
if test "$_debug_build" = yes; then
# TODO: Setup debug build properly
DEFINES="$DEFINES -D__PS2_DEBUG__"
#INCLUDES="$INCLUDES -I$(PS2GDB)/ee"
#LDFLAGS="$LDFLAGS -L$(PS2GDB)/lib"
LDFLAGS="$LDFLAGS -lps2gdbStub -lps2ip -ldebug"
else
# If not building for debug mode, strip binaries.
CXXFLAGS="$CXXFLAGS -s"
fi
;;
*) *)
echo "Continuing with auto-detected values ... if you have problems, please add your target to configure." echo "WARNING: Unknown target, continuing with auto-detected values"
;; ;;
esac esac
@ -1621,6 +1715,23 @@ 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 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
PRE_OBJS_FLAGS := -Wl,--whole-archive PRE_OBJS_FLAGS := -Wl,--whole-archive
POST_OBJS_FLAGS := -Wl,--no-whole-archive POST_OBJS_FLAGS := -Wl,--no-whole-archive
'
;;
psp)
_def_plugin='
#define PLUGIN_PREFIX ""
#define PLUGIN_SUFFIX ".plg"
'
_mak_plugins='
DYNAMIC_MODULES := 1
PLUGIN_PREFIX :=
PLUGIN_SUFFIX := .plg
PLUGIN_EXTRA_DEPS = $(EXECUTABLE)
CXXFLAGS += -DDYNAMIC_MODULES
LDFLAGS += -Wl,-T$(srcdir)/backends/platform/psp/main_prog.ld
PLUGIN_LDFLAGS = -nostartfiles -Wl,-q,--just-symbols,$(EXECUTABLE),--retain-symbols-file,$(srcdir)/backends/platform/psp/plugin.syms,-T$(srcdir)/backends/platform/psp/plugin.ld -lstdc++ -lc -lm
PRE_OBJS_FLAGS := -Wl,--whole-archive
POST_OBJS_FLAGS := -Wl,--no-whole-archive
' '
;; ;;
*) *)
@ -1633,6 +1744,16 @@ POST_OBJS_FLAGS := -Wl,--no-whole-archive
fi fi
#
# Check whether integrated MT-32 emulator support is requested
#
if test "$_mt32emu" = no ; then
_def_mt32emu='#undef USE_MT32EMU'
else
_def_mt32emu='#define USE_MT32EMU'
fi
add_to_config_mk_if_yes "$_mt32emu" 'USE_MT32EMU = 1'
# #
# Check for math lib # Check for math lib
# #
@ -1745,6 +1866,27 @@ fi
add_to_config_mk_if_yes "$_mad" 'USE_MAD = 1' add_to_config_mk_if_yes "$_mad" 'USE_MAD = 1'
echo "$_mad" echo "$_mad"
#
# Check for ALSA
#
echocheck "ALSA >= 0.9"
if test "$_alsa" = auto ; then
_alsa=no
cat > $TMPC << EOF
#include <alsa/asoundlib.h>
int main(void) { return (!(SND_LIB_MAJOR==0 && SND_LIB_MINOR==9)); }
EOF
cc_check $LDFLAGS $CXXFLAGS $ALSA_CFLAGS $ALSA_LIBS -lasound && _alsa=yes
fi
if test "$_alsa" = yes ; then
_def_alsa='#define USE_ALSA'
LIBS="$LIBS $ALSA_LIBS -lasound"
INCLUDES="$INCLUDES $ALSA_CFLAGS"
else
_def_alsa='#undef USE_ALSA'
fi
echo "$_alsa"
# #
# Check for ZLib # Check for ZLib
# #
@ -1771,6 +1913,78 @@ fi
add_to_config_mk_if_yes "$_zlib" 'USE_ZLIB = 1' add_to_config_mk_if_yes "$_zlib" 'USE_ZLIB = 1'
echo "$_zlib" echo "$_zlib"
#
# Check for libfluidsynth
#
echocheck "libfluidsynth"
if test "$_fluidsynth" = auto ; then
_fluidsynth=no
cat > $TMPC << EOF
#include <fluidsynth.h>
int main(void) { return 0; }
EOF
cc_check $LDFLAGS $CXXFLAGS $FLUIDSYNTH_CFLAGS $FLUIDSYNTH_LIBS -lfluidsynth && _fluidsynth=yes
fi
if test "$_fluidsynth" = yes ; then
_def_fluidsynth='#define USE_FLUIDSYNTH'
case $_host_os in
mingw*)
LIBS="$LIBS $FLUIDSYNTH_LIBS -lfluidsynth -ldsound -lwinmm"
;;
*)
LIBS="$LIBS $FLUIDSYNTH_LIBS -lfluidsynth"
;;
esac
INCLUDES="$INCLUDES $FLUIDSYNTH_CFLAGS"
else
_def_fluidsynth='#undef USE_FLUIDSYNTH'
fi
echo "$_fluidsynth"
rm -rf $TMPC $TMPO$HOSTEXEEXT $TMPO.dSYM
#
# Check for readline if text_console is enabled
#
echocheck "readline"
if test "$_text_console" = yes ; then
_READLINE_LIBS="-lreadline"
if test "$_readline" = auto ; then
_readline=no
cat > $TMPC << EOF
#include <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>
int main(void) {
char *x = readline("");
}
EOF
cc_check $LDFLAGS $CXXFLAGS $READLINE_CFLAGS $READLINE_LIBS $_READLINE_LIBS && _readline=yes
if test "$_readline" = no ; then
_READLINE_LIBS="-lreadline -ltermcap"
cc_check $LDFLAGS $CXXFLAGS $READLINE_CFLAGS $READLINE_LIBS $_READLINE_LIBS && _readline=yes
fi
fi
echo "$_readline"
rm -rf $TMPC $TMPO$HOSTEXEEXT $TMPO.dSYM
else
_readline=no
echo "skipping (text console disabled)"
fi
if test "$_readline" = yes ; then
_def_readline='#define USE_READLINE'
LIBS="$LIBS $READLINE_LIBS $_READLINE_LIBS"
INCLUDES="$INCLUDES $READLINE_CFLAGS"
else
_def_readline='#undef USE_READLINE'
fi
if test "$_text_console" = yes ; then
_def_text_console='#define USE_TEXT_CONSOLE'
else
_def_text_console='#undef USE_TEXT_CONSOLE'
fi
rm -rf $TMPC $TMPO$EXEEXT $TMPO.dSYM rm -rf $TMPC $TMPO$EXEEXT $TMPO.dSYM
@ -1799,6 +2013,14 @@ DEFINES="$DEFINES -DPLUGIN_DIRECTORY=\\\"$_libdir/residual\\\""
echo_n "Backend... " echo_n "Backend... "
echo_n "$_backend" echo_n "$_backend"
echo echo
if test "$_mt32emu" = yes ; then
echo_n ", MT-32 emu"
fi
if test "$_text_console" = yes ; then
echo_n ", text console"
fi
if test "$_vkeybd" = yes ; then if test "$_vkeybd" = yes ; then
echo_n ", virtual keyboard" echo_n ", virtual keyboard"
fi fi
@ -1825,6 +2047,15 @@ case $_backend in
LIBS="$LIBS `$_sdlconfig --prefix="$_sdlpath" --libs`" LIBS="$LIBS `$_sdlconfig --prefix="$_sdlpath" --libs`"
DEFINES="$DEFINES -DSDL_BACKEND -DLINUXMOTO" DEFINES="$DEFINES -DSDL_BACKEND -DLINUXMOTO"
;; ;;
samsungtv)
_sdlconfig="arm-linux-gnueabi-sdl-config"
find_sdlconfig
INCLUDES="$INCLUDES `$_sdlconfig --cflags`"
LIBS="$LIBS `$_sdlconfig --libs`"
DEFINES="$DEFINES -DSDL_BACKEND -DSAMSUNGTV"
LDFLAGS="$LDFLAGS -shared -fpic -Wl,-whole-archive"
MODULES="$MODULES backends/platform/sdl"
;;
gp2x) gp2x)
find_sdlconfig find_sdlconfig
INCLUDES="$INCLUDES `$_sdlconfig --prefix="$_sdlpath" --cflags`" INCLUDES="$INCLUDES `$_sdlconfig --prefix="$_sdlpath" --cflags`"
@ -1869,7 +2100,21 @@ case $_backend in
psp) psp)
DEFINES="$DEFINES -D__PSP__ -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DDISABLE_DOSBOX_OPL" DEFINES="$DEFINES -D__PSP__ -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DDISABLE_DOSBOX_OPL"
INCLUDES="$INCLUDES -I$PSPDEV/psp/include/SDL" INCLUDES="$INCLUDES -I$PSPDEV/psp/include/SDL"
LIBS="$LIBS -lSDL" LIBS="$LIBS -lpng -lSDL -Wl,-Map,mapfile.txt"
SDLLIBS=$($PSPDEV/psp/bin/sdl-config --libs)
if `echo "$SDLLIBS" | grep ".*-lGL.*" 1>/dev/null 2>&1`
then
LIBS="$LIBS -lGL"
fi
;;
ps2)
# TODO ps2
DEFINES="$DEFINES -D_EE -DFORCE_RTL"
INCLUDES="$INCLUDES -I$PS2SDK/ee/include -I$PS2SDK/common/include -I$PS2SDK/ports/include"
LDFLAGS="$LDFLAGS -mno-crt0 $PS2SDK/ee/startup/crt0.o -T $PS2SDK/ee/startup/linkfile"
LDFLAGS="$LDFLAGS -L$PS2SDK/ee/lib -L$PS2SDK/ports/lib"
LIBS="$LIBS -lmc -lpad -lmouse -lhdd -lpoweroff -lsjpcm -lm -lc -lfileXio -lkernel -lstdc++ "
;; ;;
*) *)
echo "support for $_backend backend not implemented in configure script yet" echo "support for $_backend backend not implemented in configure script yet"
@ -1879,7 +2124,7 @@ esac
MODULES="$MODULES backends/platform/$_backend" MODULES="$MODULES backends/platform/$_backend"
# #
# Do CXXFLAGS now we know the compiler version # Do CXXFLAGS now that we know the compiler version
# #
if test "$have_gcc" = yes ; then if test "$have_gcc" = yes ; then
if test "$_cxx_major" -ge "3" ; then if test "$_cxx_major" -ge "3" ; then
@ -1920,6 +2165,9 @@ _engines_built_static=""
_engines_built_dynamic="" _engines_built_dynamic=""
_engines_skipped="" _engines_skipped=""
echo "dynamic modules = $_dynamic_modules"
echo "plugins default = $_plugins_default"
for engine in $_engines; do for engine in $_engines; do
if test "`get_engine_sub $engine`" = "no" ; then if test "`get_engine_sub $engine`" = "no" ; then
# It's a main engine # It's a main engine
@ -2021,7 +2269,14 @@ $_def_vorbis
$_def_tremor $_def_tremor
$_def_flac $_def_flac
$_def_mad $_def_mad
$_def_alsa
$_def_zlib $_def_zlib
$_def_fluidsynth
$_def_readline
/* Options */
$_def_text_console
$_def_mt32emu
/* Plugin settings */ /* Plugin settings */
$_def_plugin $_def_plugin
@ -2035,6 +2290,7 @@ cat > config.mk << EOF
CXX := $CXX CXX := $CXX
CXXFLAGS := $CXXFLAGS CXXFLAGS := $CXXFLAGS
LD := $LD
LIBS += $LIBS LIBS += $LIBS
RANLIB := $_ranlib RANLIB := $_ranlib
STRIP := $_strip STRIP := $_strip
@ -2082,7 +2338,7 @@ EOF
# Create a custom Makefile when building outside the source tree # Create a custom Makefile when building outside the source tree
# TODO: Add a better check than just looking for 'Makefile' # TODO: Add a better check than just looking for 'Makefile'
# #
if test ! -f Makefile ; then if test ! -f Makefile.common ; then
echo "Creating Makefile" echo "Creating Makefile"
cat > Makefile << EOF cat > Makefile << EOF
@ -2092,6 +2348,7 @@ vpath %.h \$(srcdir)
vpath %.cpp \$(srcdir) vpath %.cpp \$(srcdir)
vpath %.c \$(srcdir) vpath %.c \$(srcdir)
vpath %.m \$(srcdir) vpath %.m \$(srcdir)
vpath %.mm \$(srcdir)
vpath %.asm \$(srcdir) vpath %.asm \$(srcdir)
vpath %.s \$(srcdir) vpath %.s \$(srcdir)
vpath %.S \$(srcdir) vpath %.S \$(srcdir)

File diff suppressed because it is too large Load diff

View file

@ -142,15 +142,23 @@ GameDescriptor findGameID(
static GameDescriptor toGameDescriptor(const ADGameDescription &g, const PlainGameDescriptor *sg) { static GameDescriptor toGameDescriptor(const ADGameDescription &g, const PlainGameDescriptor *sg) {
const char *title = 0; const char *title = 0;
const char *extra;
while (sg->gameid) { if (g.flags & ADGF_USEEXTRAASTITLE) {
if (!strcasecmp(g.gameid, sg->gameid)) title = g.extra;
title = sg->description; extra = "";
sg++; } else {
while (sg->gameid) {
if (!strcasecmp(g.gameid, sg->gameid))
title = sg->description;
sg++;
}
extra = g.extra;
} }
GameDescriptor gd(g.gameid, title, g.language, g.platform); GameDescriptor gd(g.gameid, title, g.language, g.platform);
gd.updateDesc(g.extra); gd.updateDesc(extra);
return gd; return gd;
} }
@ -370,17 +378,19 @@ static ADGameDescList detectGame(const Common::FSList &fslist, const ADParams &p
debug(3, "+ %s", fname.c_str()); debug(3, "+ %s", fname.c_str());
SizeMD5 tmp; SizeMD5 tmp;
if (!md5_file_string(allFiles[fname], tmp.md5, params.md5Bytes)) Common::File testFile;
if (testFile.open(allFiles[fname])) {
tmp.size = (int32)testFile.size();
if (!md5_file_string(testFile, tmp.md5, params.md5Bytes))
tmp.md5[0] = 0;
} else {
tmp.size = -1;
tmp.md5[0] = 0; tmp.md5[0] = 0;
}
debug(3, "> '%s': '%s'", fname.c_str(), tmp.md5); debug(3, "> '%s': '%s'", fname.c_str(), tmp.md5);
Common::File testFile;
if (testFile.open(allFiles[fname]))
tmp.size = (int32)testFile.size();
else
tmp.size = -1;
filesSizeMD5[fname] = tmp; filesSizeMD5[fname] = tmp;
} }
} }

View file

@ -43,11 +43,12 @@ struct ADGameFileDescription {
enum ADGameFlags { enum ADGameFlags {
ADGF_NO_FLAGS = 0, ADGF_NO_FLAGS = 0,
ADGF_USEEXTRAASTITLE = (1 << 26), // Extra field value will be used as main game title, not gameid
ADGF_KEEPMATCH = (1 << 27), // this entry is kept even when there are matched ADGF_KEEPMATCH = (1 << 27), // this entry is kept even when there are matched
// entries with more files // entries with more files
ADGF_DROPLANGUAGE = (1 << 28), // don't add language to gameid ADGF_DROPLANGUAGE = (1 << 28), // don't add language to gameid
ADGF_CD = (1 << 29), // add "-cd" to gameid ADGF_CD = (1 << 29), // add "-cd" to gameid
ADGF_DEMO = (1 << 30) // add "-demo" to gameid ADGF_DEMO = (1 << 30) // add "-demo" to gameid
}; };
struct ADGameDescription { struct ADGameDescription {
@ -102,7 +103,16 @@ enum ADFlags {
* not equal to english) and platform (if not equal to PC). * not equal to english) and platform (if not equal to PC).
*/ */
kADFlagDontAugmentPreferredTarget = (1 << 0), kADFlagDontAugmentPreferredTarget = (1 << 0),
/**
* Warn user about new variant if his version was detected with fallback
*/
kADFlagPrintWarningOnFileBasedFallback = (1 << 1), kADFlagPrintWarningOnFileBasedFallback = (1 << 1),
/**
* Store value of extra field in config file, and use it as a hint
* on subsequent runs. Could be used when there is no way to autodetect
* game (when more than one game sits in same directory), and user picks
* up a variant manually.
*/
kADFlagUseExtraAsHint = (1 << 2) kADFlagUseExtraAsHint = (1 << 2)
}; };

View file

@ -22,7 +22,7 @@
* $Id$ * $Id$
*/ */
#if defined(WIN32) #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
#include <windows.h> #include <windows.h>
#include <direct.h> #include <direct.h>
// winnt.h defines ARRAYSIZE, but we want our own one... // winnt.h defines ARRAYSIZE, but we want our own one...
@ -31,11 +31,13 @@
#include "engines/engine.h" #include "engines/engine.h"
#include "common/config-manager.h" #include "common/config-manager.h"
#include "common/debug.h"
#include "common/events.h" #include "common/events.h"
#include "common/file.h" #include "common/file.h"
#include "common/timer.h" #include "common/timer.h"
#include "common/savefile.h" #include "common/savefile.h"
#include "common/system.h" #include "common/system.h"
#include "gui/debugger.h"
#include "gui/message.h" #include "gui/message.h"
#include "gui/GuiManager.h" #include "gui/GuiManager.h"
#include "sound/mixer.h" #include "sound/mixer.h"
@ -43,12 +45,38 @@
#include "engines/metaengine.h" #include "engines/metaengine.h"
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
extern bool isSmartphone(void); extern bool isSmartphone();
#endif #endif
// FIXME: HACK for MidiEmu & error() // FIXME: HACK for MidiEmu & error()
Engine *g_engine = 0; Engine *g_engine = 0;
// Output formatter for debug() and error() which invokes
// the errorString method of the active engine, if any.
static void defaultOutputFormatter(char *dst, const char *src, size_t dstSize) {
if (g_engine) {
g_engine->errorString(src, dst, dstSize);
} else {
strncpy(dst, src, dstSize);
}
}
static void defaultErrorHandler(const char *msg) {
// Unless this error -originated- within the debugger itself, we
// now invoke the debugger, if available / supported.
if (g_engine) {
GUI::Debugger *debugger = g_engine->getDebugger();
#ifdef _WIN32_WCE
if (isSmartphone())
debugger = 0;
#endif
if (debugger && !debugger->isAttached()) {
debugger->attach(msg);
debugger->onFrame();
}
}
}
Engine::Engine(OSystem *syst) Engine::Engine(OSystem *syst)
: _system(syst), : _system(syst),
@ -62,6 +90,9 @@ Engine::Engine(OSystem *syst)
_mainMenuDialog(NULL) { _mainMenuDialog(NULL) {
g_engine = this; g_engine = this;
Common::setDebugOutputFormatter(defaultOutputFormatter);
Common::setErrorOutputFormatter(defaultOutputFormatter);
Common::setErrorHandler(defaultErrorHandler);
// FIXME: Get rid of the following again. It is only here temporarily. // FIXME: Get rid of the following again. It is only here temporarily.
// We really should never run with a non-working Mixer, so ought to handle // We really should never run with a non-working Mixer, so ought to handle
@ -91,7 +122,7 @@ void GUIErrorMessage(const Common::String msg) {
} }
void Engine::checkCD() { void Engine::checkCD() {
#if defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
// It is a known bug under Windows that games that play CD audio cause // It is a known bug under Windows that games that play CD audio cause
// ScummVM to crash if the data files are read from the same CD. Check // ScummVM to crash if the data files are read from the same CD. Check
// if this appears to be the case and issue a warning. // if this appears to be the case and issue a warning.
@ -177,7 +208,7 @@ void Engine::pauseEngine(bool pause) {
else else
_pauseLevel--; _pauseLevel--;
if (_pauseLevel == 1) { if (_pauseLevel == 1 && pause) {
pauseEngineIntern(true); pauseEngineIntern(true);
} else if (_pauseLevel == 0) { } else if (_pauseLevel == 0) {
pauseEngineIntern(false); pauseEngineIntern(false);

View file

@ -255,6 +255,7 @@ protected:
}; };
// FIXME: HACK for MidiEmu & error()
extern Engine *g_engine; extern Engine *g_engine;
#endif #endif

View file

@ -23,6 +23,13 @@
* *
*/ */
#if defined(WIN32)
#include <windows.h>
// winnt.h defines ARRAYSIZE, but we want our own one... - this is needed before including util.h
#undef ARRAYSIZE
#endif
#include "common/events.h" #include "common/events.h"
#include "common/file.h" #include "common/file.h"
#include "common/config-manager.h" #include "common/config-manager.h"

View file

@ -30,6 +30,10 @@
#include "engines/grim/imuse/imuse.h" #include "engines/grim/imuse/imuse.h"
#include "sound/audiostream.h"
#include "sound/mixer.h"
#include "sound/raw.h"
namespace Grim { namespace Grim {
Imuse *g_imuse = NULL; Imuse *g_imuse = NULL;
@ -139,8 +143,10 @@ void Imuse::restoreState(SaveGame *savedState) {
if (channels == 2) if (channels == 2)
track->mixerFlags |= kFlagStereo | kFlagReverseStereo; track->mixerFlags |= kFlagStereo | kFlagReverseStereo;
track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->mixerFlags)); track->stream = Audio::makeQueuingAudioStream(freq, (track->mixerFlags & kFlagStereo) != 0);
g_system->getMixer()->playInputStream(track->getType(), &track->handle, track->stream, -1, track->getVol(), track->getPan()); g_system->getMixer()->playInputStream(track->getType(), &track->handle, track->stream, -1, track->getVol(),
track->getPan(), DisposeAfterUse::YES, false,
(track->mixerFlags & kFlagReverseStereo) != 0);
g_system->getMixer()->pauseHandle(track->handle, true); g_system->getMixer()->pauseHandle(track->handle, true);
} }
savedState->endSection(); savedState->endSection();
@ -188,14 +194,14 @@ void Imuse::saveState(SaveGame *savedState) {
int32 Imuse::makeMixerFlags(int32 flags) { int32 Imuse::makeMixerFlags(int32 flags) {
int32 mixerFlags = 0; int32 mixerFlags = 0;
if (flags & kFlagUnsigned)
mixerFlags |= Audio::FLAG_UNSIGNED;
if (flags & kFlag16Bits) if (flags & kFlag16Bits)
mixerFlags |= Audio::Mixer::FLAG_16BITS; mixerFlags |= Audio::FLAG_16BITS;
if (flags & kFlagLittleEndian) if (flags & kFlagLittleEndian)
mixerFlags |= Audio::Mixer::FLAG_LITTLE_ENDIAN; mixerFlags |= Audio::FLAG_LITTLE_ENDIAN;
if (flags & kFlagStereo) if (flags & kFlagStereo)
mixerFlags |= Audio::Mixer::FLAG_STEREO; mixerFlags |= Audio::FLAG_STEREO;
if (flags & kFlagReverseStereo)
mixerFlags |= Audio::Mixer::FLAG_REVERSE_STEREO;
return mixerFlags; return mixerFlags;
} }
@ -301,7 +307,7 @@ void Imuse::callback() {
result = mixer_size; result = mixer_size;
if (g_system->getMixer()->isReady()) { if (g_system->getMixer()->isReady()) {
track->stream->queueBuffer(data, result); track->stream->queueBuffer(data, result, DisposeAfterUse::YES, makeMixerFlags(track->mixerFlags));
track->regionOffset += result; track->regionOffset += result;
} else } else
delete[] data; delete[] data;

View file

@ -137,8 +137,10 @@ bool Imuse::startSound(const char *soundName, int volGroupId, int hookId, int vo
track->regionOffset = otherTrack->regionOffset; track->regionOffset = otherTrack->regionOffset;
} }
track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->mixerFlags)); track->stream = Audio::makeQueuingAudioStream(freq, track->mixerFlags & kFlagStereo);
g_system->getMixer()->playInputStream(track->getType(), &track->handle, track->stream, -1, track->getVol(), track->getPan()); g_system->getMixer()->playInputStream(track->getType(), &track->handle, track->stream, -1,
track->getVol(), track->getPan(), DisposeAfterUse::YES,
false, (track->mixerFlags & kFlagReverseStereo) != 0);
track->used = true; track->used = true;
return true; return true;
@ -374,8 +376,10 @@ Track *Imuse::cloneToFadeOutTrack(Track *track, int fadeDelay) {
fadeTrack->volFadeUsed = true; fadeTrack->volFadeUsed = true;
// Create an appendable output buffer // Create an appendable output buffer
fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundDesc), makeMixerFlags(fadeTrack->mixerFlags)); fadeTrack->stream = Audio::makeQueuingAudioStream(_sound->getFreq(fadeTrack->soundDesc), track->mixerFlags & kFlagStereo);
g_system->getMixer()->playInputStream(track->getType(), &fadeTrack->handle, fadeTrack->stream, -1, fadeTrack->getVol(), fadeTrack->getPan()); g_system->getMixer()->playInputStream(track->getType(), &fadeTrack->handle, fadeTrack->stream, -1, fadeTrack->getVol(),
fadeTrack->getPan(), DisposeAfterUse::YES, false,
(track->mixerFlags & kFlagReverseStereo) != 0);
fadeTrack->used = true; fadeTrack->used = true;
return fadeTrack; return fadeTrack;

View file

@ -66,7 +66,7 @@ struct Track {
ImuseSndMgr::SoundDesc *soundDesc; ImuseSndMgr::SoundDesc *soundDesc;
Audio::SoundHandle handle; Audio::SoundHandle handle;
Audio::AppendableAudioStream *stream; Audio::QueuingAudioStream *stream;
Track() : used(false), stream(NULL) { Track() : used(false), stream(NULL) {
soundName[0] = 0; soundName[0] = 0;

View file

@ -319,7 +319,7 @@ static void io_write() {
} }
static void io_date() { static void io_date() {
tm t; TimeDate t;
char b[BUFSIZ]; char b[BUFSIZ];
g_system->getTimeAndDate(t); g_system->getTimeAndDate(t);

View file

@ -1889,7 +1889,7 @@ static void TextFileGetLine() {
int pos = (int)lua_getnumber(posObj); int pos = (int)lua_getnumber(posObj);
file->seek(pos, SEEK_SET); file->seek(pos, SEEK_SET);
memset(textBuf, 0, 1000); memset(textBuf, 0, 1000);
file->readLine_NEW(textBuf, 1000); file->readLine(textBuf, 1000);
delete file; delete file;
lua_pushstring(textBuf); lua_pushstring(textBuf);
@ -1923,7 +1923,7 @@ static void TextFileGetLineCount() {
int pos = file->pos(); int pos = file->pos();
lua_pushnumber(pos); lua_pushnumber(pos);
lua_settable(); lua_settable();
file->readLine_NEW(textBuf, 1000); file->readLine(textBuf, 1000);
line++; line++;
} }
delete file; delete file;

View file

@ -28,6 +28,10 @@
#include "common/file.h" #include "common/file.h"
#include "common/events.h" #include "common/events.h"
#include "sound/audiostream.h"
#include "sound/mixer.h"
#include "sound/raw.h"
#include "engines/grim/smush/smush.h" #include "engines/grim/smush/smush.h"
#include "engines/grim/grim.h" #include "engines/grim/grim.h"
@ -127,16 +131,16 @@ void Smush::handleWave(const byte *src, uint32 size) {
int16 *dst = new int16[size * _channels]; int16 *dst = new int16[size * _channels];
decompressVima(src, dst, size * _channels * 2, smushDestTable); decompressVima(src, dst, size * _channels * 2, smushDestTable);
int flags = Audio::Mixer::FLAG_16BITS; int flags = Audio::FLAG_16BITS;
if (_channels == 2) if (_channels == 2)
flags |= Audio::Mixer::FLAG_STEREO; flags |= Audio::FLAG_STEREO;
if (!_stream) { if (!_stream) {
_stream = Audio::makeAppendableAudioStream(_freq, flags); _stream = Audio::makeQueuingAudioStream(_freq, (_channels == 2));
g_system->getMixer()->playInputStream(Audio::Mixer::kMusicSoundType, &_soundHandle, _stream); g_system->getMixer()->playInputStream(Audio::Mixer::kMusicSoundType, &_soundHandle, _stream);
} }
if (g_system->getMixer()->isReady()) { if (g_system->getMixer()->isReady()) {
_stream->queueBuffer((byte *)dst, size * _channels * 2); _stream->queueBuffer((byte *)dst, size * _channels * 2, DisposeAfterUse::YES, flags);
} else { } else {
delete[] dst; delete[] dst;
} }
@ -297,10 +301,10 @@ void Smush::handleIACT(const byte *src, int32 size) {
} while (--count); } while (--count);
if (!_stream) { if (!_stream) {
_stream = Audio::makeAppendableAudioStream(22050, Audio::Mixer::FLAG_STEREO | Audio::Mixer::FLAG_16BITS); _stream = Audio::makeQueuingAudioStream(22050, true);
g_system->getMixer()->playInputStream(Audio::Mixer::kSFXSoundType, &_soundHandle, _stream); g_system->getMixer()->playInputStream(Audio::Mixer::kSFXSoundType, &_soundHandle, _stream);
} }
_stream->queueBuffer(output_data, 0x1000); _stream->queueBuffer(output_data, 0x1000, DisposeAfterUse::YES, Audio::FLAG_STEREO | Audio::FLAG_16BITS);
bsize -= len; bsize -= len;
d_src += len; d_src += len;
@ -571,7 +575,7 @@ bool zlibFile::setPos(struct SavePos *pos) {
return false; return false;
} }
_handle->seek(pos->filePos, SEEK_SET); _handle->seek(pos->filePos, SEEK_SET);
if (_handle->ioFailed()) { if (_handle->err()) {
warning("Unable to rewind SMUSH movie (seek failed)"); warning("Unable to rewind SMUSH movie (seek failed)");
return false; return false;
} }

View file

@ -80,7 +80,7 @@ private:
zlibFile _file; zlibFile _file;
Common::File _f; Common::File _f;
Audio::SoundHandle _soundHandle; Audio::SoundHandle _soundHandle;
Audio::AppendableAudioStream *_stream; Audio::QueuingAudioStream *_stream;
int32 _frame; int32 _frame;
bool _updateNeeded; bool _updateNeeded;

View file

@ -146,4 +146,4 @@ void VectorRenderer::stepGetPositions(const DrawStep &step, const Common::Rect &
} }
} }
} // end of namespace Graphics } // End of namespace Graphics

View file

@ -493,6 +493,6 @@ protected:
int _gradientBytes[3]; /**< Color bytes of the active gradient, used to speed up calculation */ int _gradientBytes[3]; /**< Color bytes of the active gradient, used to speed up calculation */
}; };
} // end of namespace Graphics } // End of namespace Graphics
#endif #endif

View file

@ -116,10 +116,18 @@ struct ColorMasks<555> {
kGreenBits = 5, kGreenBits = 5,
kBlueBits = 5, kBlueBits = 5,
#ifdef __N64__
/* Nintendo 64 uses a BGR555 color format for 16bit display */
kAlphaShift = 0,
kRedShift = kBlueBits+kGreenBits+1,
kGreenShift = kBlueBits + 1,
kBlueShift = 1,
#else /* RGB555 */
kAlphaShift = 0, kAlphaShift = 0,
kRedShift = kGreenBits+kBlueBits, kRedShift = kGreenBits+kBlueBits,
kGreenShift = kBlueBits, kGreenShift = kBlueBits,
kBlueShift = 0, kBlueShift = 0,
#endif
kAlphaMask = ((1 << kAlphaBits) - 1) << kAlphaShift, kAlphaMask = ((1 << kAlphaBits) - 1) << kAlphaShift,
kRedMask = ((1 << kRedBits) - 1) << kRedShift, kRedMask = ((1 << kRedBits) - 1) << kRedShift,
@ -321,6 +329,6 @@ PixelFormat createPixelFormat() {
} }
} // end of namespace Graphics } // End of namespace Graphics
#endif #endif

View file

@ -31,14 +31,13 @@ DECLARE_SINGLETON(Graphics::CursorManager);
namespace Graphics { namespace Graphics {
static bool g_initialized = false; CursorManager::~CursorManager() {
for (int i = 0; i < _cursorStack.size(); ++i)
CursorManager::CursorManager() { delete _cursorStack[i];
if (!g_initialized) { _cursorStack.clear();
g_initialized = true; for (int i = 0; i < _cursorPaletteStack.size(); ++i)
_cursorStack.clear(); delete _cursorPaletteStack[i];
_cursorPaletteStack.clear(); _cursorPaletteStack.clear();
}
} }
bool CursorManager::isVisible() { bool CursorManager::isVisible() {
@ -157,4 +156,50 @@ void CursorManager::replaceCursorPalette(const byte *colors, uint start, uint nu
return; return;
} }
CursorManager::Cursor::Cursor(const byte *data, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, const Graphics::PixelFormat *format) {
#ifdef USE_RGB_COLOR
if (!format)
_format = Graphics::PixelFormat::createFormatCLUT8();
else
_format = *format;
_size = w * h * _format.bytesPerPixel;
_keycolor = keycolor & ((1 << (_format.bytesPerPixel << 3)) - 1);
#else
_format = Graphics::PixelFormat::createFormatCLUT8();
_size = w * h;
_keycolor = keycolor & 0xFF;
#endif
_data = new byte[_size];
if (data && _data)
memcpy(_data, data, _size);
_width = w;
_height = h;
_hotspotX = hotspotX;
_hotspotY = hotspotY;
_targetScale = targetScale;
}
CursorManager::Cursor::~Cursor() {
delete[] _data;
}
CursorManager::Palette::Palette(const byte *colors, uint start, uint num) {
_start = start;
_num = num;
_size = 4 * num;
if (num) {
_data = new byte[_size];
memcpy(_data, colors, _size);
} else {
_data = NULL;
}
_disabled = false;
}
CursorManager::Palette::~Palette() {
delete[] _data;
}
} // End of namespace Graphics } // End of namespace Graphics

View file

@ -67,7 +67,8 @@ public:
* @param h the height * @param h the height
* @param hotspotX the hotspot X coordinate * @param hotspotX the hotspot X coordinate
* @param hotspotY the hotspot Y coordinate * @param hotspotY the hotspot Y coordinate
* @param keycolor the index for the transparent color * @param keycolor the color value for the transparent color. This may not exceed
* the maximum color value as defined by format.
* @param targetScale the scale for which the cursor is designed * @param targetScale the scale for which the cursor is designed
* @param format a pointer to the pixel format which the cursor graphic uses, * @param format a pointer to the pixel format which the cursor graphic uses,
* CLUT8 will be used if this is NULL or not specified. * CLUT8 will be used if this is NULL or not specified.
@ -75,7 +76,7 @@ public:
* useful to push a "dummy" cursor and modify it later. The * useful to push a "dummy" cursor and modify it later. The
* cursor will be added to the stack, but not to the backend. * cursor will be added to the stack, but not to the backend.
*/ */
void pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, const Graphics::PixelFormat *format = NULL); void pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale = 1, const Graphics::PixelFormat *format = NULL);
/** /**
* Pop a cursor from the stack, and restore the previous one to the * Pop a cursor from the stack, and restore the previous one to the
@ -93,12 +94,13 @@ public:
* @param h the height * @param h the height
* @param hotspotX the hotspot X coordinate * @param hotspotX the hotspot X coordinate
* @param hotspotY the hotspot Y coordinate * @param hotspotY the hotspot Y coordinate
* @param keycolor the index for the transparent color * @param keycolor the color value for the transparent color. This may not exceed
* the maximum color value as defined by format.
* @param targetScale the scale for which the cursor is designed * @param targetScale the scale for which the cursor is designed
* @param format a pointer to the pixel format which the cursor graphic uses, * @param format a pointer to the pixel format which the cursor graphic uses,
* CLUT8 will be used if this is NULL or not specified. * CLUT8 will be used if this is NULL or not specified.
*/ */
void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, const Graphics::PixelFormat *format = NULL); void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale = 1, const Graphics::PixelFormat *format = NULL);
/** /**
* Pop all of the cursors and cursor palettes from their respective stacks. * Pop all of the cursors and cursor palettes from their respective stacks.
@ -164,7 +166,11 @@ public:
private: private:
friend class Common::Singleton<SingletonBaseType>; friend class Common::Singleton<SingletonBaseType>;
CursorManager(); // Even though this is basically the default constructor we implement it
// ourselves, so it is private and thus there is no way to create this class
// except from the Singleton code.
CursorManager() {}
~CursorManager();
struct Cursor { struct Cursor {
byte *_data; byte *_data;
@ -175,35 +181,12 @@ private:
int _hotspotY; int _hotspotY;
uint32 _keycolor; uint32 _keycolor;
Graphics::PixelFormat _format; Graphics::PixelFormat _format;
byte _targetScale; int _targetScale;
uint _size; uint _size;
Cursor(const byte *data, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, const Graphics::PixelFormat *format = NULL) {
#ifdef USE_RGB_COLOR
if (!format)
_format = Graphics::PixelFormat::createFormatCLUT8();
else
_format = *format;
_size = w * h * _format.bytesPerPixel;
_keycolor = keycolor & ((1 << (_format.bytesPerPixel << 3)) - 1);
#else
_format = Graphics::PixelFormat::createFormatCLUT8();
_size = w * h;
_keycolor = keycolor & 0xFF;
#endif
_data = new byte[_size];
if (data && _data)
memcpy(_data, data, _size);
_width = w;
_height = h;
_hotspotX = hotspotX;
_hotspotY = hotspotY;
_targetScale = targetScale;
}
~Cursor() { Cursor(const byte *data, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale = 1, const Graphics::PixelFormat *format = NULL);
delete[] _data; ~Cursor();
}
}; };
struct Palette { struct Palette {
@ -214,24 +197,8 @@ private:
bool _disabled; bool _disabled;
Palette(const byte *colors, uint start, uint num) { Palette(const byte *colors, uint start, uint num);
_start = start; ~Palette();
_num = num;
_size = 4 * num;
if (num) {
_data = new byte[_size];
memcpy(_data, colors, _size);
} else {
_data = NULL;
}
_disabled = false;
}
~Palette() {
delete[] _data;
}
}; };
Common::Stack<Cursor *> _cursorStack; Common::Stack<Cursor *> _cursorStack;
Common::Stack<Palette *> _cursorPaletteStack; Common::Stack<Palette *> _cursorPaletteStack;

View file

@ -524,7 +524,7 @@ int bdf_read_bitmaps(Common::SeekableReadStream &fp, NewFontData* pf) {
} }
/* read the next non-comment line, returns buf or NULL if EOF*/ /* read the next non-comment line, returns buf or NULL if EOF*/
// TODO: Can we use SeekableReadStream::readLine resp. readLine_NEW instead? // TODO: Can we use SeekableReadStream::readLine instead?
char *bdf_getline(Common::SeekableReadStream &fp, char *buf, int len) { char *bdf_getline(Common::SeekableReadStream &fp, char *buf, int len) {
int c; int c;
char *b; char *b;
@ -782,20 +782,31 @@ int Font::getStringWidth(const Common::String &str) const {
return space; return space;
} }
void Font::drawString(Surface *dst, const Common::String &s, int x, int y, int w, uint32 color, TextAlign align, int deltax, bool useEllipsis) const { void Font::drawString(Surface *dst, const Common::String &sOld, int x, int y, int w, uint32 color, TextAlign align, int deltax, bool useEllipsis) const {
assert(dst != 0); assert(dst != 0);
const int leftX = x, rightX = x + w; const int leftX = x, rightX = x + w;
uint i; uint i;
Common::String s = sOld;
int width = getStringWidth(s); int width = getStringWidth(s);
Common::String str; Common::String str;
if (useEllipsis && width > w && s.hasSuffix("...")) {
// String is too wide. Check whether it ends in an ellipsis
// ("..."). If so, remove that and try again!
s.deleteLastChar();
s.deleteLastChar();
s.deleteLastChar();
width = getStringWidth(s);
}
if (useEllipsis && width > w) { if (useEllipsis && width > w) {
// String is too wide. So we shorten it "intellegently", by replacing // String is too wide. So we shorten it "intelligently" by
// parts of it by an ellipsis ("..."). There are three possibilities // replacing parts of the string by an ellipsis. There are
// for this: replace the start, the end, or the middle of the string. // three possibilities for this: replace the start, the end, or
// What is best really depends on the context; but unless we want to // the middle of the string. What is best really depends on the
// make this configurable, replacing the middle probably is a good // context; but unless we want to make this configurable,
// compromise. // replacing the middle seems to be a good compromise.
const int ellipsisWidth = getStringWidth("..."); const int ellipsisWidth = getStringWidth("...");
// SLOW algorithm to remove enough of the middle. But it is good enough // SLOW algorithm to remove enough of the middle. But it is good enough
@ -816,7 +827,7 @@ void Font::drawString(Surface *dst, const Common::String &s, int x, int y, int w
// The original string is width wide. Of those we already skipped past // The original string is width wide. Of those we already skipped past
// w2 pixels, which means (width - w2) remain. // w2 pixels, which means (width - w2) remain.
// The new str is (w2+ellipsisWidth) wide, so we can accomodate about // The new str is (w2+ellipsisWidth) wide, so we can accommodate about
// (w - (w2+ellipsisWidth)) more pixels. // (w - (w2+ellipsisWidth)) more pixels.
// Thus we skip ((width - w2) - (w - (w2+ellipsisWidth))) = // Thus we skip ((width - w2) - (w - (w2+ellipsisWidth))) =
// (width + ellipsisWidth - w) // (width + ellipsisWidth - w)
@ -831,7 +842,6 @@ void Font::drawString(Surface *dst, const Common::String &s, int x, int y, int w
} }
width = getStringWidth(str); width = getStringWidth(str);
} else { } else {
str = s; str = s;
} }

View file

@ -37,9 +37,9 @@ namespace Graphics {
/** Text alignment modes */ /** Text alignment modes */
enum TextAlign { enum TextAlign {
kTextAlignInvalid, kTextAlignInvalid,
kTextAlignLeft, //!< Text should be aligned to the left kTextAlignLeft, ///< Text should be aligned to the left
kTextAlignCenter, //!< Text should be centered kTextAlignCenter, ///< Text should be centered
kTextAlignRight //!< Text should be aligned to the right kTextAlignRight ///< Text should be aligned to the right
}; };
/** /**
@ -140,17 +140,18 @@ public:
static NewFont *loadFromCache(Common::SeekableReadStream &stream); static NewFont *loadFromCache(Common::SeekableReadStream &stream);
}; };
#if (defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__)) #define DEFINE_FONT(n) \
# define DEFINE_FONT(n) \ const NewFont *n = 0; \
const NewFont *n; \
void create_##n() { \ void create_##n() { \
n = new NewFont(desc); \ n = new NewFont(desc); \
} }
# define INIT_FONT(n) \ #define FORWARD_DECLARE_FONT(n) \
extern void create_##n(); \ extern const NewFont *n; \
extern void create_##n();
#define INIT_FONT(n) \
create_##n(); create_##n();
#endif
} // End of namespace Graphics } // End of namespace Graphics

View file

@ -29,38 +29,34 @@ DECLARE_SINGLETON(Graphics::FontManager);
namespace Graphics { namespace Graphics {
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__)) const ScummFont *g_scummfont = 0;
const ScummFont g_scummfont; FORWARD_DECLARE_FONT(g_sysfont)
extern const NewFont g_sysfont; FORWARD_DECLARE_FONT(g_sysfont_big)
extern const NewFont g_sysfont_big; FORWARD_DECLARE_FONT(g_consolefont)
extern const NewFont g_consolefont;
FontManager::FontManager() { 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
// reset to 0 in the desctructor of this class).
assert(g_scummfont == 0);
g_scummfont = new ScummFont;
INIT_FONT(g_sysfont)
INIT_FONT(g_sysfont_big)
INIT_FONT(g_consolefont)
} }
#else FontManager::~FontManager() {
const ScummFont *g_scummfont; delete g_scummfont;
extern const NewFont *g_sysfont; g_scummfont = 0;
extern const NewFont *g_sysfont_big; delete g_sysfont;
extern const NewFont *g_consolefont; g_sysfont = 0;
delete g_sysfont_big;
static bool g_initialized = false; g_sysfont_big = 0;
void initfonts() { delete g_consolefont;
if (!g_initialized) { g_consolefont = 0;
// FIXME : this need to be freed
g_initialized = true;
g_scummfont = new ScummFont;
INIT_FONT(g_sysfont)
INIT_FONT(g_sysfont_big)
INIT_FONT(g_consolefont)
}
} }
FontManager::FontManager() {
initfonts();
}
#endif
const Font *FontManager::getFontByName(const Common::String &name) const { const Font *FontManager::getFontByName(const Common::String &name) const {
if (!_fontMap.contains(name)) if (!_fontMap.contains(name))
return 0; return 0;
@ -69,16 +65,6 @@ const Font *FontManager::getFontByName(const Common::String &name) const {
const Font *FontManager::getFontByUsage(FontUsage usage) const { const Font *FontManager::getFontByUsage(FontUsage usage) const {
switch (usage) { switch (usage) {
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
case kOSDFont:
return &g_scummfont;
case kConsoleFont:
return &g_consolefont;
case kGUIFont:
return &g_sysfont;
case kBigGUIFont:
return &g_sysfont_big;
#else
case kOSDFont: case kOSDFont:
return g_scummfont; return g_scummfont;
case kConsoleFont: case kConsoleFont:
@ -87,7 +73,6 @@ const Font *FontManager::getFontByUsage(FontUsage usage) const {
return g_sysfont; return g_sysfont;
case kBigGUIFont: case kBigGUIFont:
return g_sysfont_big; return g_sysfont_big;
#endif
} }
return 0; return 0;

View file

@ -83,6 +83,7 @@ public:
private: private:
friend class Common::Singleton<SingletonBaseType>; friend class Common::Singleton<SingletonBaseType>;
FontManager(); FontManager();
~FontManager();
Common::HashMap<Common::String, const Font *> _fontMap; Common::HashMap<Common::String, const Font *> _fontMap;
}; };

View file

@ -5651,10 +5651,6 @@ static const FontDesc desc = {
sizeof(_font_bits)/sizeof(bitmap_t) sizeof(_font_bits)/sizeof(bitmap_t)
}; };
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
extern const NewFont g_consolefont(desc);
#else
DEFINE_FONT(g_consolefont) DEFINE_FONT(g_consolefont)
#endif
} // End of namespace Graphics } // End of namespace Graphics

View file

@ -7435,10 +7435,6 @@ static const FontDesc desc = {
sizeof(_font_bits)/sizeof(bitmap_t) sizeof(_font_bits)/sizeof(bitmap_t)
}; };
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
extern const NewFont g_sysfont(desc);
#else
DEFINE_FONT(g_sysfont) DEFINE_FONT(g_sysfont)
#endif
} // End of namespace Graphics } // End of namespace Graphics

View file

@ -5539,10 +5539,6 @@ static const FontDesc desc = {
sizeof(_font_bits)/sizeof(bitmap_t) sizeof(_font_bits)/sizeof(bitmap_t)
}; };
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
extern const NewFont g_sysfont_big(desc);
#else
DEFINE_FONT(g_sysfont_big) DEFINE_FONT(g_sysfont_big)
#endif
} // End of namespace Graphics } // End of namespace Graphics

View file

@ -175,4 +175,4 @@ Surface *ImageDecoder::loadFile(Common::SeekableReadStream &stream, const PixelF
return decoder->decodeImage(stream, format); return decoder->decodeImage(stream, format);
} }
} // end of namespace Graphics } // End of namespace Graphics

View file

@ -61,7 +61,7 @@ public:
*/ */
virtual Surface *decodeImage(Common::SeekableReadStream &stream, const PixelFormat &format) = 0; virtual Surface *decodeImage(Common::SeekableReadStream &stream, const PixelFormat &format) = 0;
}; };
} // end of namespace Graphics } // End of namespace Graphics
#endif #endif

View file

@ -27,7 +27,6 @@
#define GRAPHICS_PIXELFORMAT_H #define GRAPHICS_PIXELFORMAT_H
#include "common/sys.h" #include "common/sys.h"
#include "common/list.h"
namespace Graphics { namespace Graphics {
@ -148,26 +147,6 @@ struct PixelFormat {
} }
}; };
/** } // End of namespace Graphics
* Determines the first matching format between two lists.
*
* @param backend The higher priority list, meant to be a list of formats supported by the backend
* @param frontend The lower priority list, meant to be a list of formats supported by the engine
* @return The first item on the backend list that also occurs on the frontend list
* or PixelFormat::createFormatCLUT8() if no matching formats were found.
*/
inline PixelFormat findCompatibleFormat(Common::List<PixelFormat> backend, Common::List<PixelFormat> frontend) {
#ifdef USE_RGB_COLOR
for (Common::List<PixelFormat>::iterator i = backend.begin(); i != backend.end(); ++i) {
for (Common::List<PixelFormat>::iterator j = frontend.begin(); j != frontend.end(); ++j) {
if (*i == *j)
return *i;
}
}
#endif
return PixelFormat::createFormatCLUT8();
}
} // end of namespace Graphics
#endif #endif

View file

@ -166,5 +166,5 @@ bool saveThumbnail(Common::WriteStream &out, const Graphics::Surface &thumb) {
return true; return true;
} }
} // end of namespace Graphics } // End of namespace Graphics

Some files were not shown because too many files have changed in this diff Show more