aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Skovlund2011-03-09 20:19:50 +0100
committerLars Skovlund2011-03-09 20:19:50 +0100
commit354e7d05888c69f1af9778ecd065ffc02505fa4b (patch)
tree2e2ea11e871cada74dccbfacc320cc7104c9f37c
parenta55a211ddc270e8f9f292874b1a8e5881b572294 (diff)
parent0d271324db406bcdfe51ae4b8ebf30eebef32860 (diff)
downloadscummvm-rg350-354e7d05888c69f1af9778ecd065ffc02505fa4b.tar.gz
scummvm-rg350-354e7d05888c69f1af9778ecd065ffc02505fa4b.tar.bz2
scummvm-rg350-354e7d05888c69f1af9778ecd065ffc02505fa4b.zip
Merge branch 'master' of github.com:scummvm/scummvm
-rw-r--r--backends/events/wincesdl/wincesdl-events.cpp80
-rw-r--r--backends/events/wincesdl/wincesdl-events.h11
-rw-r--r--backends/platform/wince/CEActionsPocket.cpp16
-rw-r--r--backends/platform/wince/CEActionsSmartphone.cpp180
-rw-r--r--backends/platform/wince/CEDevice.cpp16
-rw-r--r--backends/platform/wince/CEException.cpp22
-rw-r--r--backends/platform/wince/CELauncherDialog.cpp9
-rw-r--r--backends/platform/wince/CEgui/GUIElement.cpp9
-rw-r--r--backends/platform/wince/CEgui/ItemAction.cpp2
-rw-r--r--backends/platform/wince/CEgui/ItemSwitch.cpp6
-rw-r--r--backends/platform/wince/CEgui/Panel.cpp11
-rw-r--r--backends/platform/wince/CEgui/Panel.h2
-rw-r--r--backends/platform/wince/CEgui/PanelItem.h2
-rw-r--r--backends/platform/wince/CEgui/PanelKeyboard.cpp21
-rw-r--r--backends/platform/wince/CEgui/SDL_ImageResource.cpp4
-rw-r--r--backends/platform/wince/CEgui/SDL_ImageResource.h4
-rw-r--r--backends/platform/wince/CEgui/ToolbarHandler.cpp13
-rw-r--r--backends/platform/wince/CEgui/ToolbarHandler.h2
-rw-r--r--backends/platform/wince/CEkeys/EventsBuffer.cpp98
-rw-r--r--backends/platform/wince/CEkeys/EventsBuffer.h16
-rw-r--r--backends/platform/wince/missing/io.h6
-rw-r--r--backends/platform/wince/missing/missing.cpp56
-rw-r--r--backends/platform/wince/missing/time.h7
-rw-r--r--backends/platform/wince/portdefs.h38
-rw-r--r--backends/platform/wince/wince-sdl.cpp73
-rw-r--r--backends/platform/wince/wince-sdl.h8
-rw-r--r--engines/mohawk/graphics.cpp75
-rw-r--r--engines/mohawk/graphics.h11
-rw-r--r--engines/mohawk/riven_external.cpp55
-rw-r--r--engines/mohawk/riven_external.h4
-rw-r--r--engines/sci/engine/kevent.cpp26
-rw-r--r--engines/sci/event.cpp335
-rw-r--r--engines/sci/event.h12
-rw-r--r--engines/sci/graphics/menu.cpp22
-rw-r--r--engines/sci/graphics/view.cpp212
35 files changed, 795 insertions, 669 deletions
diff --git a/backends/events/wincesdl/wincesdl-events.cpp b/backends/events/wincesdl/wincesdl-events.cpp
index d89f83d6a4..2505b0fb31 100644
--- a/backends/events/wincesdl/wincesdl-events.cpp
+++ b/backends/events/wincesdl/wincesdl-events.cpp
@@ -30,7 +30,6 @@
#include "common/config-manager.h"
#include "backends/events/wincesdl/wincesdl-events.h"
-#include "backends/graphics/wincesdl/wincesdl-graphics.h"
#include "backends/platform/wince/CEActionsPocket.h"
#include "backends/platform/wince/CEActionsSmartphone.h"
#include "backends/platform/wince/CEDevice.h"
@@ -39,7 +38,12 @@
WINCESdlEventSource::WINCESdlEventSource()
: _tapTime(0), _closeClick(false), _rbutton(false),
- _freeLook(false) {
+ _freeLook(false), _graphicsMan(0) {
+}
+
+void WINCESdlEventSource::init(WINCESdlGraphicsManager *graphicsMan) {
+ assert(graphicsMan);
+ _graphicsMan = graphicsMan;
}
void WINCESdlEventSource::fillMouseEvent(Common::Event &event, int x, int y) {
@@ -51,11 +55,11 @@ void WINCESdlEventSource::fillMouseEvent(Common::Event &event, int x, int y) {
_km.y = event.mouse.y;
// Adjust for the screen scaling
- if (((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_zoomDown)
+ if (_graphicsMan->_zoomDown)
event.mouse.y += 240;
- event.mouse.x = event.mouse.x * ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_scaleFactorXd / ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_scaleFactorXm;
- event.mouse.y = event.mouse.y * ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_scaleFactorYd / ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_scaleFactorYm;
+ event.mouse.x = event.mouse.x * _graphicsMan->_scaleFactorXd / _graphicsMan->_scaleFactorXm;
+ event.mouse.y = event.mouse.y * _graphicsMan->_scaleFactorYd / _graphicsMan->_scaleFactorYm;
}
bool WINCESdlEventSource::pollEvent(Common::Event &event) {
@@ -70,7 +74,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
handleKbdMouse();
// If the screen changed, send an Common::EVENT_SCREEN_CHANGED
- int screenID = ((OSystem_SDL *)g_system)->getGraphicsManager()->getScreenChangeID();
+ int screenID = _graphicsMan->getScreenChangeID();
if (screenID != _lastScreenID) {
_lastScreenID = screenID;
event.type = Common::EVENT_SCREEN_CHANGED;
@@ -88,9 +92,9 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
// KMOD_RESERVED is used if the key has been injected by an external buffer
if (ev.key.keysym.mod != KMOD_RESERVED && !GUI::Actions::Instance()->mappingActive()) {
keyEvent = true;
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_lastKeyPressed = ev.key.keysym.sym;
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_keyRepeatTime = currentTime;
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_keyRepeat = 0;
+ _graphicsMan->_lastKeyPressed = ev.key.keysym.sym;
+ _graphicsMan->_keyRepeatTime = currentTime;
+ _graphicsMan->_keyRepeat = 0;
if (!GUI_Actions::Instance()->mappingActive() && GUI_Actions::Instance()->performMapped(ev.key.keysym.sym, true))
return true;
@@ -99,7 +103,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
if (GUI_Actions::Instance()->mappingActive())
event.kbd.flags = 0xFF;
else if (ev.key.keysym.sym == SDLK_PAUSE) {
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_lastKeyPressed = 0;
+ _graphicsMan->_lastKeyPressed = 0;
event.type = Common::EVENT_PREDICTIVE_DIALOG;
return true;
}
@@ -122,7 +126,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
// KMOD_RESERVED is used if the key has been injected by an external buffer
if (ev.key.keysym.mod != KMOD_RESERVED && !GUI::Actions::Instance()->mappingActive()) {
keyEvent = true;
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_lastKeyPressed = 0;
+ _graphicsMan->_lastKeyPressed = 0;
if (!GUI_Actions::Instance()->mappingActive() && GUI_Actions::Instance()->performMapped(ev.key.keysym.sym, false))
return true;
@@ -131,7 +135,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
if (GUI_Actions::Instance()->mappingActive())
event.kbd.flags = 0xFF;
else if (ev.key.keysym.sym == SDLK_PAUSE) {
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_lastKeyPressed = 0;
+ _graphicsMan->_lastKeyPressed = 0;
return false; // chew up the show agi dialog key up event
}
@@ -152,7 +156,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
case SDL_MOUSEMOTION:
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, ev.motion.x, ev.motion.y);
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->setMousePos(event.mouse.x, event.mouse.y);
+ _graphicsMan->setMousePos(event.mouse.x, event.mouse.y);
return true;
@@ -181,10 +185,10 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
if (_tapTime) { // second tap
if (_closeClick && (GetTickCount() - _tapTime < 1000)) {
if (event.mouse.y <= 20 &&
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_panelInitialized) {
+ _graphicsMan->_panelInitialized) {
// top of screen (show panel)
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_panel_visibility();
- } else if (!((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_noDoubleTapRMB) {
+ _graphicsMan->swap_panel_visibility();
+ } else if (!_graphicsMan->_noDoubleTapRMB) {
// right click
event.type = Common::EVENT_RBUTTONDOWN;
_rbutton = true;
@@ -204,21 +208,21 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
_tapX = event.mouse.x;
_tapY = event.mouse.y;
event.type = Common::EVENT_MOUSEMOVE;
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->setMousePos(event.mouse.x, event.mouse.y);
+ _graphicsMan->setMousePos(event.mouse.x, event.mouse.y);
}
- if (((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_toolbarHandler.action(event.mouse.x, event.mouse.y, true)) {
- if (!((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_toolbarHandler.drawn()) {
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_toolbarHighDrawn = false;
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->internUpdateScreen();
+ if (_graphicsMan->_toolbarHandler.action(event.mouse.x, event.mouse.y, true)) {
+ if (!_graphicsMan->_toolbarHandler.drawn()) {
+ _graphicsMan->_toolbarHighDrawn = false;
+ _graphicsMan->internUpdateScreen();
}
- if (((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_newOrientation != ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_orientationLandscape) {
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_orientationLandscape = ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_newOrientation;
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_toolbarHighDrawn = false;
- ConfMan.setInt("landscape", ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_orientationLandscape);
+ if (_graphicsMan->_newOrientation != _graphicsMan->_orientationLandscape) {
+ _graphicsMan->_orientationLandscape = _graphicsMan->_newOrientation;
+ _graphicsMan->_toolbarHighDrawn = false;
+ ConfMan.setInt("landscape", _graphicsMan->_orientationLandscape);
ConfMan.flushToDisk();
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->hotswapGFXMode();
+ _graphicsMan->hotswapGFXMode();
}
return false;
}
@@ -244,13 +248,13 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
_tapX = event.mouse.x;
_tapY = event.mouse.y;
event.type = Common::EVENT_MOUSEMOVE;
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->setMousePos(event.mouse.x, event.mouse.y);
+ _graphicsMan->setMousePos(event.mouse.x, event.mouse.y);
}
- if (((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_toolbarHandler.action(event.mouse.x, event.mouse.y, false)) {
- if (!((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_toolbarHandler.drawn()) {
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_toolbarHighDrawn = false;
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->internUpdateScreen();
+ if (_graphicsMan->_toolbarHandler.action(event.mouse.x, event.mouse.y, false)) {
+ if (!_graphicsMan->_toolbarHandler.drawn()) {
+ _graphicsMan->_toolbarHighDrawn = false;
+ _graphicsMan->internUpdateScreen();
}
return false;
@@ -274,9 +278,9 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
if (ev.active.state & SDL_APPACTIVE)
debug(2, "%s total focus.", ev.active.gain ? "Got" : "Lost");
if (ev.active.state & SDL_APPINPUTFOCUS) {
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_hasfocus = ev.active.gain;
- SDL_PauseAudio(!((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_hasfocus);
- if (((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_hasfocus) {
+ _graphicsMan->_hasfocus = ev.active.gain;
+ SDL_PauseAudio(!_graphicsMan->_hasfocus);
+ if (_graphicsMan->_hasfocus) {
event.type = (Common::EventType)OSystem_SDL::kSdlEventExpose;
}
}
@@ -285,10 +289,10 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
}
// Simulate repeated key for backend
- if (!keyEvent && ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_lastKeyPressed && (int)currentTime > ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_keyRepeatTime + ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_keyRepeatTrigger) {
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_keyRepeatTime = currentTime;
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_keyRepeat++;
- GUI_Actions::Instance()->performMapped(((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->_lastKeyPressed, true);
+ if (!keyEvent && _graphicsMan->_lastKeyPressed && (int)currentTime > _graphicsMan->_keyRepeatTime + _graphicsMan->_keyRepeatTrigger) {
+ _graphicsMan->_keyRepeatTime = currentTime;
+ _graphicsMan->_keyRepeat++;
+ GUI_Actions::Instance()->performMapped(_graphicsMan->_lastKeyPressed, true);
}
return false;
diff --git a/backends/events/wincesdl/wincesdl-events.h b/backends/events/wincesdl/wincesdl-events.h
index da15b96fe1..f5b1026c46 100644
--- a/backends/events/wincesdl/wincesdl-events.h
+++ b/backends/events/wincesdl/wincesdl-events.h
@@ -26,7 +26,12 @@
#ifndef BACKENDS_EVENTS_SDL_WINCE_H
#define BACKENDS_EVENTS_SDL_WINCE_H
+#include "common/scummsys.h"
+
+#ifdef _WIN32_WCE
+
#include "backends/events/sdl/sdl-events.h"
+#include "backends/graphics/wincesdl/wincesdl-graphics.h"
extern bool _isSmartphone;
@@ -34,6 +39,8 @@ class WINCESdlEventSource : public SdlEventSource {
public:
WINCESdlEventSource();
+ void init(WINCESdlGraphicsManager *graphicsMan);
+
void loadDeviceConfiguration();
// Overloaded from SDL backend (toolbar handling)
@@ -48,6 +55,8 @@ protected:
private:
int mapKeyCE(SDLKey key, SDLMod mod, Uint16 unicode, bool unfilter);
+ WINCESdlGraphicsManager *_graphicsMan;
+
// Keyboard tap
int _tapX;
int _tapY;
@@ -59,4 +68,6 @@ private:
};
+#endif
+
#endif /* BACKENDS_EVENTS_SDL_WINCE_H */
diff --git a/backends/platform/wince/CEActionsPocket.cpp b/backends/platform/wince/CEActionsPocket.cpp
index b3ac10429b..3895c7d6fa 100644
--- a/backends/platform/wince/CEActionsPocket.cpp
+++ b/backends/platform/wince/CEActionsPocket.cpp
@@ -38,7 +38,7 @@
#ifdef _WIN32_WCE
-#define KEY_ALL_SKIP 3457
+#define KEY_ALL_SKIP 3457
#endif
const Common::String pocketActionNames[] = {
@@ -85,14 +85,14 @@ int CEActionsPocket::version() {
}
CEActionsPocket::CEActionsPocket(const Common::String &gameid) :
-GUI::Actions() {
+ GUI::Actions() {
int i;
_right_click_needed = false;
_hide_toolbar_needed = false;
_zoom_needed = false;
- for (i=0; i<POCKET_ACTION_LAST; i++) {
+ for (i = 0; i < POCKET_ACTION_LAST; i++) {
_action_mapping[i] = 0;
_action_enabled[i] = false;
}
@@ -112,7 +112,7 @@ GUI::Actions() {
void CEActionsPocket::initInstanceMain(OSystem *mainSystem) {
// Nothing generic to do for Pocket PC
- _CESystem = static_cast<OSystem_WINCE3*>(mainSystem);
+ _CESystem = static_cast<OSystem_WINCE3 *>(mainSystem);
GUI_Actions::initInstanceMain(mainSystem);
}
@@ -126,7 +126,7 @@ void CEActionsPocket::initInstanceGame() {
bool is_comi = (strncmp(gameid.c_str(), "comi", 4) == 0);
bool is_gob = (strncmp(gameid.c_str(), "gob", 3) == 0);
bool is_saga = (gameid == "saga");
- bool is_kyra = (strncmp(gameid.c_str(), "kyra",4) == 0);
+ bool is_kyra = (strncmp(gameid.c_str(), "kyra", 4) == 0);
bool is_samnmax = (gameid == "samnmax");
bool is_cine = (gameid == "cine");
bool is_touche = (gameid == "touche");
@@ -134,7 +134,7 @@ void CEActionsPocket::initInstanceGame() {
bool is_parallaction = (gameid == "parallaction");
bool is_lure = (gameid == "lure");
bool is_feeble = (gameid == "feeble");
- bool is_drascula = (strncmp(gameid.c_str(), "drascula",8) == 0);
+ bool is_drascula = (strncmp(gameid.c_str(), "drascula", 8) == 0);
bool is_tucker = (gameid == "tucker");
bool is_groovie = (gameid == "groovie");
bool is_tinsel = (gameid == "tinsel");
@@ -145,7 +145,7 @@ void CEActionsPocket::initInstanceGame() {
// See if a right click mapping could be needed
if (is_sword1 || is_sword2 || is_sky || is_queen || is_comi || is_gob || is_tinsel ||
- is_samnmax || is_cine || is_touche || is_parallaction || is_drascula || is_cruise)
+ is_samnmax || is_cine || is_touche || is_parallaction || is_drascula || is_cruise)
_right_click_needed = true;
// See if a "hide toolbar" mapping could be needed
@@ -187,7 +187,7 @@ void CEActionsPocket::initInstanceGame() {
if (!is_cine && !is_parallaction && !is_groovie && !is_cruise && !is_made)
_action_enabled[POCKET_ACTION_SKIP] = true;
if (is_simon || is_sky || is_sword2 || is_queen || is_sword1 || is_gob || is_tinsel ||
- is_saga || is_kyra || is_touche || is_lure || is_feeble || is_drascula || is_tucker)
+ is_saga || is_kyra || is_touche || is_lure || is_feeble || is_drascula || is_tucker)
_key_action[POCKET_ACTION_SKIP].setKey(VK_ESCAPE);
else
_key_action[POCKET_ACTION_SKIP].setKey(KEY_ALL_SKIP);
diff --git a/backends/platform/wince/CEActionsSmartphone.cpp b/backends/platform/wince/CEActionsSmartphone.cpp
index a8684293f4..413c52af2b 100644
--- a/backends/platform/wince/CEActionsSmartphone.cpp
+++ b/backends/platform/wince/CEActionsSmartphone.cpp
@@ -36,7 +36,7 @@
#include "common/translation.h"
-#define KEY_ALL_SKIP 3457
+#define KEY_ALL_SKIP 3457
const String smartphoneActionNames[] = {
_s("Up"),
@@ -79,10 +79,10 @@ int CEActionsSmartphone::version() {
}
CEActionsSmartphone::CEActionsSmartphone()
-: GUI::Actions() {
+ : GUI::Actions() {
int i;
- for (i=0; i<SMARTPHONE_ACTION_LAST; i++) {
+ for (i = 0; i < SMARTPHONE_ACTION_LAST; i++) {
_action_mapping[i] = ACTIONS_SMARTPHONE_DEFAULT[i];
_action_enabled[i] = false;
}
@@ -90,7 +90,7 @@ CEActionsSmartphone::CEActionsSmartphone()
}
void CEActionsSmartphone::initInstanceMain(OSystem *mainSystem) {
- _CESystem = static_cast<OSystem_WINCE3*>(mainSystem);
+ _CESystem = static_cast<OSystem_WINCE3 *>(mainSystem);
GUI_Actions::initInstanceMain(mainSystem);
@@ -117,7 +117,7 @@ void CEActionsSmartphone::initInstanceGame() {
bool is_comi = (strncmp(gameid.c_str(), "comi", 4) == 0);
bool is_gob = (strncmp(gameid.c_str(), "gob", 3) == 0);
bool is_saga = (gameid == "saga");
- bool is_kyra = (strncmp(gameid.c_str(), "kyra",4) == 0);
+ bool is_kyra = (strncmp(gameid.c_str(), "kyra", 4) == 0);
bool is_samnmax = (gameid == "samnmax");
bool is_cine = (gameid == "cine");
bool is_touche = (gameid == "touche");
@@ -125,7 +125,7 @@ void CEActionsSmartphone::initInstanceGame() {
bool is_parallaction = (gameid == "parallaction");
bool is_lure = (gameid == "lure");
bool is_feeble = (gameid == "feeble");
- bool is_drascula = (strncmp(gameid.c_str(), "drascula",8) == 0);
+ bool is_drascula = (strncmp(gameid.c_str(), "drascula", 8) == 0);
bool is_tucker = (gameid == "tucker");
bool is_groovie = (gameid == "groovie");
bool is_tinsel = (gameid == "tinsel");
@@ -136,7 +136,7 @@ void CEActionsSmartphone::initInstanceGame() {
// See if a right click mapping could be needed
if (is_sword1 || is_sword2 || is_sky || is_queen || is_comi || is_gob || is_tinsel ||
- is_samnmax || is_cine || is_touche || is_parallaction || is_drascula || is_cruise)
+ is_samnmax || is_cine || is_touche || is_parallaction || is_drascula || is_cruise)
_right_click_needed = true;
// Initialize keys for different actions
@@ -168,8 +168,8 @@ void CEActionsSmartphone::initInstanceGame() {
// Skip
_action_enabled[SMARTPHONE_ACTION_SKIP] = true;
if (is_simon || is_sky || is_sword2 || is_queen || is_sword1 || is_gob || is_tinsel ||
- is_saga || is_kyra || is_touche || is_lure || is_feeble || is_drascula || is_tucker ||
- is_groovie || is_cruise || is_made)
+ is_saga || is_kyra || is_touche || is_lure || is_feeble || is_drascula || is_tucker ||
+ is_groovie || is_cruise || is_made)
_key_action[SMARTPHONE_ACTION_SKIP].setKey(VK_ESCAPE);
else
_key_action[SMARTPHONE_ACTION_SKIP].setKey(KEY_ALL_SKIP);
@@ -204,92 +204,92 @@ bool CEActionsSmartphone::perform(GUI::ActionType action, bool pushed) {
if (!pushed) {
switch (action) {
- case SMARTPHONE_ACTION_RIGHTCLICK:
- //_CESystem->add_right_click(false);
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_right_click(false);
- return true;
- case SMARTPHONE_ACTION_LEFTCLICK:
- //_CESystem->add_left_click(false);
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_left_click(false);
- return true;
- case SMARTPHONE_ACTION_SAVE:
- case SMARTPHONE_ACTION_SKIP:
- case SMARTPHONE_ACTION_MULTI:
- EventsBuffer::simulateKey(&_key_action[action], false);
- return true;
- }
- return false;
- }
-
- switch (action) {
- case SMARTPHONE_ACTION_SAVE:
- case SMARTPHONE_ACTION_SKIP:
- case SMARTPHONE_ACTION_MULTI:
- if (action == SMARTPHONE_ACTION_SAVE && ConfMan.get("gameid") == "parallaction") {
- // FIXME: This is a temporary solution. The engine should handle its own menus.
- // Note that the user can accomplish this via the virtual keyboard as well, this is just for convenience
- GUI::MessageDialog alert(_("Do you want to load or save the game?"), _("Load"), _("Save"));
- if (alert.runModal() == GUI::kMessageOK)
- _key_action[action].setKey(SDLK_l);
- else
- _key_action[action].setKey(SDLK_s);
- }
- EventsBuffer::simulateKey(&_key_action[action], true);
- return true;
case SMARTPHONE_ACTION_RIGHTCLICK:
- //_CESystem->add_right_click(true);
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_right_click(true);
+ //_CESystem->add_right_click(false);
+ ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_right_click(false);
return true;
case SMARTPHONE_ACTION_LEFTCLICK:
- //_CESystem->add_left_click(true);
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_left_click(true);
- return true;
- case SMARTPHONE_ACTION_UP:
- //_CESystem->move_cursor_up();
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_up();
- return true;
- case SMARTPHONE_ACTION_DOWN:
- //_CESystem->move_cursor_down();
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_down();
- return true;
- case SMARTPHONE_ACTION_LEFT:
- //_CESystem->move_cursor_left();
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_left();
- return true;
- case SMARTPHONE_ACTION_RIGHT:
- //_CESystem->move_cursor_right();
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_right();
- return true;
- case SMARTPHONE_ACTION_ZONE:
- //_CESystem->switch_zone();
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->switch_zone();
+ //_CESystem->add_left_click(false);
+ ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_left_click(false);
return true;
- case SMARTPHONE_ACTION_BINDKEYS:
- if (!keydialogrunning) {
- keydialogrunning = true;
- GUI::KeysDialog *keysDialog = new GUI::KeysDialog();
- keysDialog->runModal();
- delete keysDialog;
- keydialogrunning = false;
- }
- return true;
- case SMARTPHONE_ACTION_KEYBOARD:
- //_CESystem->swap_smartphone_keyboard();
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_smartphone_keyboard();
- return true;
- case SMARTPHONE_ACTION_ROTATE:
- //_CESystem->smartphone_rotate_display();
- ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->smartphone_rotate_display();
- return true;
- case SMARTPHONE_ACTION_QUIT:
- if (!quitdialog) {
- quitdialog = true;
- GUI::MessageDialog alert(_(" Are you sure you want to quit ? "), _("Yes"), _("No"));
- if (alert.runModal() == GUI::kMessageOK)
- _mainSystem->quit();
- quitdialog = false;
- }
+ case SMARTPHONE_ACTION_SAVE:
+ case SMARTPHONE_ACTION_SKIP:
+ case SMARTPHONE_ACTION_MULTI:
+ EventsBuffer::simulateKey(&_key_action[action], false);
return true;
+ }
+ return false;
+ }
+
+ switch (action) {
+ case SMARTPHONE_ACTION_SAVE:
+ case SMARTPHONE_ACTION_SKIP:
+ case SMARTPHONE_ACTION_MULTI:
+ if (action == SMARTPHONE_ACTION_SAVE && ConfMan.get("gameid") == "parallaction") {
+ // FIXME: This is a temporary solution. The engine should handle its own menus.
+ // Note that the user can accomplish this via the virtual keyboard as well, this is just for convenience
+ GUI::MessageDialog alert(_("Do you want to load or save the game?"), _("Load"), _("Save"));
+ if (alert.runModal() == GUI::kMessageOK)
+ _key_action[action].setKey(SDLK_l);
+ else
+ _key_action[action].setKey(SDLK_s);
+ }
+ EventsBuffer::simulateKey(&_key_action[action], true);
+ return true;
+ case SMARTPHONE_ACTION_RIGHTCLICK:
+ //_CESystem->add_right_click(true);
+ ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_right_click(true);
+ return true;
+ case SMARTPHONE_ACTION_LEFTCLICK:
+ //_CESystem->add_left_click(true);
+ ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_left_click(true);
+ return true;
+ case SMARTPHONE_ACTION_UP:
+ //_CESystem->move_cursor_up();
+ ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_up();
+ return true;
+ case SMARTPHONE_ACTION_DOWN:
+ //_CESystem->move_cursor_down();
+ ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_down();
+ return true;
+ case SMARTPHONE_ACTION_LEFT:
+ //_CESystem->move_cursor_left();
+ ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_left();
+ return true;
+ case SMARTPHONE_ACTION_RIGHT:
+ //_CESystem->move_cursor_right();
+ ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_right();
+ return true;
+ case SMARTPHONE_ACTION_ZONE:
+ //_CESystem->switch_zone();
+ ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->switch_zone();
+ return true;
+ case SMARTPHONE_ACTION_BINDKEYS:
+ if (!keydialogrunning) {
+ keydialogrunning = true;
+ GUI::KeysDialog *keysDialog = new GUI::KeysDialog();
+ keysDialog->runModal();
+ delete keysDialog;
+ keydialogrunning = false;
+ }
+ return true;
+ case SMARTPHONE_ACTION_KEYBOARD:
+ //_CESystem->swap_smartphone_keyboard();
+ ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_smartphone_keyboard();
+ return true;
+ case SMARTPHONE_ACTION_ROTATE:
+ //_CESystem->smartphone_rotate_display();
+ ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->smartphone_rotate_display();
+ return true;
+ case SMARTPHONE_ACTION_QUIT:
+ if (!quitdialog) {
+ quitdialog = true;
+ GUI::MessageDialog alert(_(" Are you sure you want to quit ? "), _("Yes"), _("No"));
+ if (alert.runModal() == GUI::kMessageOK)
+ _mainSystem->quit();
+ quitdialog = false;
+ }
+ return true;
}
return false;
diff --git a/backends/platform/wince/CEDevice.cpp b/backends/platform/wince/CEDevice.cpp
index f90d5e2966..ffe2523b47 100644
--- a/backends/platform/wince/CEDevice.cpp
+++ b/backends/platform/wince/CEDevice.cpp
@@ -29,17 +29,17 @@
#include "backends/platform/wince/wince-sdl.h"
-static void (WINAPI* _SHIdleTimerReset)(void) = NULL;
-static HANDLE (WINAPI* _SetPowerRequirement)(PVOID,int,ULONG,PVOID,ULONG) = NULL;
-static DWORD (WINAPI* _ReleasePowerRequirement)(HANDLE) = NULL;
+static void (WINAPI *_SHIdleTimerReset)(void) = NULL;
+static HANDLE(WINAPI *_SetPowerRequirement)(PVOID, int, ULONG, PVOID, ULONG) = NULL;
+static DWORD (WINAPI *_ReleasePowerRequirement)(HANDLE) = NULL;
static HANDLE _hPowerManagement = NULL;
static DWORD _lastTime = 0;
static DWORD REG_bat = 0, REG_ac = 0, REG_disp = 0, bat_timeout = 0;
static bool REG_tampered = false;
#ifdef __GNUC__
extern "C" void WINAPI SystemIdleTimerReset(void);
-#define SPI_SETBATTERYIDLETIMEOUT 251
-#define SPI_GETBATTERYIDLETIMEOUT 252
+#define SPI_SETBATTERYIDLETIMEOUT 251
+#define SPI_GETBATTERYIDLETIMEOUT 252
#endif
#define TIMER_TRIGGER 9000
@@ -70,7 +70,7 @@ DWORD CEDevice::reg_access(const TCHAR *key, const TCHAR *val, DWORD data) {
void CEDevice::backlight_xchg() {
HANDLE h;
- REG_bat = reg_access(TEXT("ControlPanel\\BackLight"), (const TCHAR*)TEXT("BatteryTimeout"), REG_bat);
+ REG_bat = reg_access(TEXT("ControlPanel\\BackLight"), (const TCHAR *)TEXT("BatteryTimeout"), REG_bat);
REG_ac = reg_access(TEXT("ControlPanel\\BackLight"), TEXT("ACTimeout"), REG_ac);
REG_disp = reg_access(TEXT("ControlPanel\\Power"), TEXT("Display"), REG_disp);
@@ -89,7 +89,7 @@ void CEDevice::init() {
}
dll = LoadLibrary(TEXT("coredll.dll"));
if (dll) {
- _SetPowerRequirement = (HANDLE (*)(PVOID,int,ULONG,PVOID,ULONG))GetProcAddress(dll, TEXT("SetPowerRequirement"));
+ _SetPowerRequirement = (HANDLE (*)(PVOID, int, ULONG, PVOID, ULONG))GetProcAddress(dll, TEXT("SetPowerRequirement"));
_ReleasePowerRequirement = (DWORD (*)(HANDLE))GetProcAddress(dll, TEXT("ReleasePowerRequirement"));
}
if (_SetPowerRequirement)
@@ -97,7 +97,7 @@ void CEDevice::init() {
_lastTime = GetTickCount();
// older devices
- REG_bat = REG_ac = REG_disp = 2 * 60 * 60 * 1000; // 2hrs should do it
+ REG_bat = REG_ac = REG_disp = 2 * 60 * 60 * 1000; // 2hrs should do it
backlight_xchg();
REG_tampered = true;
SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, (void *) &bat_timeout, 0);
diff --git a/backends/platform/wince/CEException.cpp b/backends/platform/wince/CEException.cpp
index 421db4960c..08a327136f 100644
--- a/backends/platform/wince/CEException.cpp
+++ b/backends/platform/wince/CEException.cpp
@@ -36,7 +36,7 @@ void CEException::writeBreak(HANDLE file) {
int i;
memset(tempo, 0, sizeof(tempo));
- for (i=0; i<40; i++)
+ for (i = 0; i < 40; i++)
tempo[i] = '-';
writeString(file, tempo);
}
@@ -51,23 +51,23 @@ void CEException::dumpContext(HANDLE file, HANDLE hProcess, CONTEXT *context) {
writeBreak(file);
writeString(file, "Context dump");
sprintf(tempo, "R0=%.8x R1=%.8x R2=%.8x R3=%.8x R4=%.8x", context->R0, context->R1,
- context->R2, context->R3, context->R4);
+ context->R2, context->R3, context->R4);
writeString(file, tempo);
sprintf(tempo, "R5=%.8x R6=%.8x R7=%.8x R8=%.8x R9=%.8x", context->R5, context->R6,
- context->R7, context->R8, context->R9);
+ context->R7, context->R8, context->R9);
writeString(file, tempo);
sprintf(tempo, "R10=%.8x R11=%.8x R12=%.8x", context->R10, context->R11,
- context->R12);
+ context->R12);
writeString(file, tempo);
sprintf(tempo, "Sp=%.8x Lr=%.8x Pc=%.8x Psr=%.8x", context->Sp, context->Lr,
- context->Pc, context->Psr);
+ context->Pc, context->Psr);
writeString(file, tempo);
writeBreak(file);
sprintf(tempo, "Memory dump at %.8x", context->Pc - (sizeof(memoryDump) / 2));
writeString(file, tempo);
if (ReadProcessMemory(hProcess, (LPCVOID)(context->Pc - (sizeof(memoryDump) / 2)), memoryDump, sizeof(memoryDump), &size)) {
- for (i=0; i<size; i+=8) {
+ for (i = 0; i < size; i += 8) {
int j;
char digit[4];
int max;
@@ -75,7 +75,7 @@ void CEException::dumpContext(HANDLE file, HANDLE hProcess, CONTEXT *context) {
if (max > 8)
max = 8;
tempo[0] = '\0';
- for (j=0; j<max; j++) {
+ for (j = 0; j < max; j++) {
sprintf(digit, "%.2x ", memoryDump[i + j]);
strcat(tempo, digit);
}
@@ -121,10 +121,10 @@ void CEException::dumpException(HANDLE file, EXCEPTION_RECORD *exceptionRecord)
break;
}
sprintf(tempo, "Exception %s Flags %.8x Address %.8x", exceptionName, exceptionRecord->ExceptionFlags,
- exceptionRecord->ExceptionAddress);
+ exceptionRecord->ExceptionAddress);
writeString(file, tempo);
if (exceptionRecord->NumberParameters) {
- for (i=0; i<exceptionRecord->NumberParameters; i++) {
+ for (i = 0; i < exceptionRecord->NumberParameters; i++) {
sprintf(tempo, "Parameter %d %.8x", i, exceptionRecord->ExceptionInformation[i]);
writeString(file, tempo);
}
@@ -144,8 +144,8 @@ bool CEException::writeException(TCHAR *path, EXCEPTION_POINTERS *exceptionPoint
GetSystemTime(&systemTime);
wsprintf(dumpFileName, TEXT("%s_%.2d_%.2d_%.4d_%.2d_%.2d_%.2d.txt"),
- path, systemTime.wDay, systemTime.wMonth, systemTime.wYear,
- systemTime.wHour, systemTime.wMinute, systemTime.wSecond);
+ path, systemTime.wDay, systemTime.wMonth, systemTime.wYear,
+ systemTime.wHour, systemTime.wMinute, systemTime.wSecond);
dumpFile = CreateFile(dumpFileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (dumpFile == INVALID_HANDLE_VALUE)
return false;
diff --git a/backends/platform/wince/CELauncherDialog.cpp b/backends/platform/wince/CELauncherDialog.cpp
index de1bb2f1f6..8824af732f 100644
--- a/backends/platform/wince/CELauncherDialog.cpp
+++ b/backends/platform/wince/CELauncherDialog.cpp
@@ -48,14 +48,14 @@ using namespace Common;
class CEAboutDialog : public Dialog {
public:
CEAboutDialog()
- : Dialog(10, 60, 300, 77) {
+ : Dialog(10, 60, 300, 77) {
char tempo[100];
// FIXME: Fingolfin asks: why is there a FIXME here? Please either clarify what
// needs fixing, or remove it!
const int buttonWidth = g_gui.xmlEval()->getVar("Globals.Button.Width", 0);
const int buttonHeight = g_gui.xmlEval()->getVar("Globals.Button.Height", 0);
- new ButtonWidget(this, (_w - buttonWidth) / 2, 45, buttonWidth, buttonHeight, _("OK"), 0, kCloseCmd, '\r'); // Close dialog - FIXME
+ new ButtonWidget(this, (_w - buttonWidth) / 2, 45, buttonWidth, buttonHeight, _("OK"), 0, kCloseCmd, '\r'); // Close dialog - FIXME
Common::String videoDriver(_("Using SDL driver "));
SDL_VideoDriverName(tempo, sizeof(tempo));
@@ -106,14 +106,13 @@ void CELauncherDialog::addGame() {
MessageDialog alert(_("Do you want to perform an automatic scan ?"), _("Yes"), _("No"));
if (alert.runModal() == kMessageOK && _browser->runModal() > 0) {
// Clear existing domains
- ConfigManager::DomainMap &domains = (ConfigManager::DomainMap&)ConfMan.getGameDomains();
+ ConfigManager::DomainMap &domains = (ConfigManager::DomainMap &)ConfMan.getGameDomains();
domains.clear();
ConfMan.flushToDisk();
automaticScanDirectory(_browser->getResult());
ConfMan.flushToDisk();
updateListing();
draw();
- }
- else
+ } else
GUILauncherDialog::addGame();
}
diff --git a/backends/platform/wince/CEgui/GUIElement.cpp b/backends/platform/wince/CEgui/GUIElement.cpp
index dd463c22a1..e7ffc8d473 100644
--- a/backends/platform/wince/CEgui/GUIElement.cpp
+++ b/backends/platform/wince/CEgui/GUIElement.cpp
@@ -32,7 +32,7 @@
namespace CEGUI {
GUIElement::GUIElement(int x, int y, int width, int height) :
-_background(0), _drawn(false), _visible(true), _x(x), _y(y), _width(width), _height(height) {
+ _background(0), _drawn(false), _visible(true), _x(x), _y(y), _width(width), _height(height) {
}
bool GUIElement::setBackground(WORD backgroundReference) {
@@ -45,9 +45,7 @@ bool GUIElement::setBackground(WORD backgroundReference) {
if (!_height && !_width) {
_height = _background->height();
_width = _background->width();
- }
- else
- if (_background->height() != _height || _background->width() != _width) {
+ } else if (_background->height() != _height || _background->width() != _width) {
delete _background;
_background = NULL;
return false;
@@ -74,8 +72,7 @@ bool GUIElement::draw(SDL_Surface *surface) {
_drawn = true;
return true;
- }
- else
+ } else
return false;
}
diff --git a/backends/platform/wince/CEgui/ItemAction.cpp b/backends/platform/wince/CEgui/ItemAction.cpp
index 55805744e6..efbc43ce00 100644
--- a/backends/platform/wince/CEgui/ItemAction.cpp
+++ b/backends/platform/wince/CEgui/ItemAction.cpp
@@ -28,7 +28,7 @@
namespace CEGUI {
ItemAction::ItemAction(WORD reference, GUI::ActionType action) :
-PanelItem(reference) {
+ PanelItem(reference) {
_action = action;
if (!GUI::Actions::Instance()->isEnabled(_action))
_visible = false;
diff --git a/backends/platform/wince/CEgui/ItemSwitch.cpp b/backends/platform/wince/CEgui/ItemSwitch.cpp
index d4648f7556..8eb62bf365 100644
--- a/backends/platform/wince/CEgui/ItemSwitch.cpp
+++ b/backends/platform/wince/CEgui/ItemSwitch.cpp
@@ -40,7 +40,7 @@ void ItemSwitch::init(WORD referenceTrue, WORD referenceFalse) {
}
ItemSwitch::ItemSwitch(WORD referenceTrue, WORD referenceFalse, bool *item) :
-PanelItem(referenceTrue) {
+ PanelItem(referenceTrue) {
init(referenceTrue, referenceFalse);
_item = item;
_itemmax = -1;
@@ -49,8 +49,8 @@ PanelItem(referenceTrue) {
}
ItemSwitch::ItemSwitch(WORD referenceTrue, WORD referenceFalse, int *item, int max) :
-PanelItem(referenceTrue) {
- init(referenceTrue, referenceFalse);
+ PanelItem(referenceTrue) {
+ init(referenceTrue, referenceFalse);
_itemmultiple = item;
_itemmax = max;
if (!*item)
diff --git a/backends/platform/wince/CEgui/Panel.cpp b/backends/platform/wince/CEgui/Panel.cpp
index dfdd6526be..576da23029 100644
--- a/backends/platform/wince/CEgui/Panel.cpp
+++ b/backends/platform/wince/CEgui/Panel.cpp
@@ -34,7 +34,7 @@ Panel::Panel(int interleave_first, int interleave) : Toolbar() {
bool Panel::add(const String &name, const PanelItem *item) {
- _itemsMap[name] = (PanelItem*)item;
+ _itemsMap[name] = (PanelItem *)item;
_itemsMap[name]->move(_currentItem, _y + 10);
_itemsMap[name]->setPanel(this);
_currentItem += _interleave;
@@ -47,11 +47,10 @@ bool Panel::draw(SDL_Surface *surface) {
if (!_drawn && _visible) {
GUIElement::draw(surface);
for (iterator = _itemsMap.begin(); iterator != _itemsMap.end(); ++iterator) {
- ((GUIElement*)(iterator->_value))->draw(surface);
+ ((GUIElement *)(iterator->_value))->draw(surface);
}
return true;
- }
- else
+ } else
return false;
}
@@ -59,7 +58,7 @@ void Panel::forceRedraw() {
ItemMap::const_iterator iterator;
GUIElement::forceRedraw();
for (iterator = _itemsMap.begin(); iterator != _itemsMap.end(); ++iterator)
- ((GUIElement*)(iterator->_value))->forceRedraw();
+ ((GUIElement *)(iterator->_value))->forceRedraw();
}
bool Panel::action(int x, int y, bool pushed) {
@@ -69,7 +68,7 @@ bool Panel::action(int x, int y, bool pushed) {
return false;
for (iterator = _itemsMap.begin(); !result && iterator != _itemsMap.end(); ++iterator)
- result = ((GUIElement*)(iterator->_value))->action(x, y, pushed);
+ result = ((GUIElement *)(iterator->_value))->action(x, y, pushed);
return result;
}
diff --git a/backends/platform/wince/CEgui/Panel.h b/backends/platform/wince/CEgui/Panel.h
index e6b693360d..1a8a580dba 100644
--- a/backends/platform/wince/CEgui/Panel.h
+++ b/backends/platform/wince/CEgui/Panel.h
@@ -51,7 +51,7 @@ public:
virtual bool action(int x, int y, bool pushed);
private:
- typedef HashMap<String, PanelItem*, Common::IgnoreCase_Hash , Common::IgnoreCase_EqualTo> ItemMap;
+ typedef HashMap<String, PanelItem *, Common::IgnoreCase_Hash , Common::IgnoreCase_EqualTo> ItemMap;
ItemMap _itemsMap;
int _interleave;
diff --git a/backends/platform/wince/CEgui/PanelItem.h b/backends/platform/wince/CEgui/PanelItem.h
index 14b62f0f20..9968aa8d5e 100644
--- a/backends/platform/wince/CEgui/PanelItem.h
+++ b/backends/platform/wince/CEgui/PanelItem.h
@@ -36,7 +36,7 @@ namespace CEGUI {
class Panel;
class PanelItem : public GUIElement {
-friend class Panel;
+ friend class Panel;
public:
PanelItem(WORD reference);
virtual ~PanelItem();
diff --git a/backends/platform/wince/CEgui/PanelKeyboard.cpp b/backends/platform/wince/CEgui/PanelKeyboard.cpp
index 5ca125898d..3512b34da3 100644
--- a/backends/platform/wince/CEgui/PanelKeyboard.cpp
+++ b/backends/platform/wince/CEgui/PanelKeyboard.cpp
@@ -30,8 +30,9 @@ namespace CEGUI {
const char KEYBOARD_MAPPING_ALPHA[][14] = { {"abcdefghijklm"}, {"nopqrstuvwxyz"} };
const char KEYBOARD_MAPPING_NUMERIC[][6] = { {"12345"}, {"67890"} };
-const int KEYBOARD_MAPPING_SPECIAL[][3][2] = { { {1,SDLK_ESCAPE}, {224,SDLK_UP}, {32,SDLK_SPACE} },
- { {224,SDLK_LEFT}, {224,SDLK_DOWN}, {224,SDLK_RIGHT} } };
+const int KEYBOARD_MAPPING_SPECIAL[][3][2] = { { {1, SDLK_ESCAPE}, {224, SDLK_UP}, {32, SDLK_SPACE} },
+ { {224, SDLK_LEFT}, {224, SDLK_DOWN}, {224, SDLK_RIGHT} }
+};
PanelKeyboard::PanelKeyboard(WORD reference) : Toolbar() {
setBackground(reference);
@@ -51,21 +52,23 @@ bool PanelKeyboard::action(int x, int y, bool pushed) {
int keyCode = 0;
if (x < 185) {
// Alpha selection
- keyCode = keyAscii = KEYBOARD_MAPPING_ALPHA[y >= _y+20][((x + 10) / 14) - 1];
+ keyCode = keyAscii = KEYBOARD_MAPPING_ALPHA[y >= _y + 20][((x + 10) / 14) - 1];
} else if (x >= 186 && x <= 255) {
// Numeric selection
- keyCode = keyAscii = KEYBOARD_MAPPING_NUMERIC[y >= _y+20][((x - 187 + 10) / 14) - 1];
+ keyCode = keyAscii = KEYBOARD_MAPPING_NUMERIC[y >= _y + 20][((x - 187 + 10) / 14) - 1];
} else if (x >= 258 && x <= 300) {
// Special keys
- keyAscii = KEYBOARD_MAPPING_SPECIAL[y >= _y+20][((x - 259 + 10) / 14) - 1][0];
- keyCode = KEYBOARD_MAPPING_SPECIAL[y >= _y+20][((x - 259 + 10) / 14) - 1][1];
+ keyAscii = KEYBOARD_MAPPING_SPECIAL[y >= _y + 20][((x - 259 + 10) / 14) - 1][0];
+ keyCode = KEYBOARD_MAPPING_SPECIAL[y >= _y + 20][((x - 259 + 10) / 14) - 1][1];
} else if (x >= 302 && x <= 316) {
- if (y < _y +20) {
+ if (y < _y + 20) {
// Backspace
- keyAscii = VK_BACK; keyCode = keyAscii;
+ keyAscii = VK_BACK;
+ keyCode = keyAscii;
} else {
// Enter
- keyAscii = 13; keyCode = 13;
+ keyAscii = 13;
+ keyCode = 13;
}
}
diff --git a/backends/platform/wince/CEgui/SDL_ImageResource.cpp b/backends/platform/wince/CEgui/SDL_ImageResource.cpp
index 8dad5f0a0c..872b94a442 100644
--- a/backends/platform/wince/CEgui/SDL_ImageResource.cpp
+++ b/backends/platform/wince/CEgui/SDL_ImageResource.cpp
@@ -32,7 +32,7 @@ SDL_ImageResource::SDL_ImageResource() :
_surface(0) {
}
-SDL_Surface* SDL_ImageResource::load(WORD resourceID) {
+SDL_Surface *SDL_ImageResource::load(WORD resourceID) {
HRSRC resource;
HGLOBAL resourceGlobal;
LPVOID resourcePointer;
@@ -62,7 +62,7 @@ SDL_Surface* SDL_ImageResource::load(WORD resourceID) {
return _surface;
}
-SDL_Surface* SDL_ImageResource::get() {
+SDL_Surface *SDL_ImageResource::get() {
return _surface;
}
diff --git a/backends/platform/wince/CEgui/SDL_ImageResource.h b/backends/platform/wince/CEgui/SDL_ImageResource.h
index 5affd5c33c..397ced1434 100644
--- a/backends/platform/wince/CEgui/SDL_ImageResource.h
+++ b/backends/platform/wince/CEgui/SDL_ImageResource.h
@@ -36,8 +36,8 @@ namespace CEGUI {
class SDL_ImageResource {
public:
SDL_ImageResource();
- SDL_Surface* load(WORD resourceID);
- SDL_Surface* get();
+ SDL_Surface *load(WORD resourceID);
+ SDL_Surface *get();
int height();
int width();
virtual ~SDL_ImageResource();
diff --git a/backends/platform/wince/CEgui/ToolbarHandler.cpp b/backends/platform/wince/CEgui/ToolbarHandler.cpp
index 78f69119c3..ed2a72245a 100644
--- a/backends/platform/wince/CEgui/ToolbarHandler.cpp
+++ b/backends/platform/wince/CEgui/ToolbarHandler.cpp
@@ -29,15 +29,15 @@
namespace CEGUI {
ToolbarHandler::ToolbarHandler():
-_current(""), _active(NULL) {
+ _current(""), _active(NULL) {
}
bool ToolbarHandler::add(const String &name, const Toolbar &toolbar) {
- _toolbarMap[name] = (Toolbar*)&toolbar;
+ _toolbarMap[name] = (Toolbar *)&toolbar;
if (!_active) {
- _active = &((Toolbar&)toolbar);
+ _active = &((Toolbar &)toolbar);
_current = name;
}
@@ -53,7 +53,7 @@ bool ToolbarHandler::setActive(const String &name) {
return false;
if (_current == name)
return true;
- _active->action(0, 0, false); // make sure any items are unpushed when changing toolbars (e.g. forced VK->main panel)
+ _active->action(0, 0, false); // make sure any items are unpushed when changing toolbars (e.g. forced VK->main panel)
_current = name;
_active = _toolbarMap[name];
_active->forceRedraw();
@@ -67,8 +67,7 @@ bool ToolbarHandler::action(int x, int y, bool pushed) {
return _active->action(x / 2, (y - _offset) / 2, pushed);
else
return _active->action(x, y - _offset, pushed);
- }
- else
+ } else
return false;
}
@@ -118,7 +117,7 @@ int ToolbarHandler::getOffset() {
return _offset;
}
-Toolbar* ToolbarHandler::active() {
+Toolbar *ToolbarHandler::active() {
return _active;
}
diff --git a/backends/platform/wince/CEgui/ToolbarHandler.h b/backends/platform/wince/CEgui/ToolbarHandler.h
index e3bf590768..0f794d7d61 100644
--- a/backends/platform/wince/CEgui/ToolbarHandler.h
+++ b/backends/platform/wince/CEgui/ToolbarHandler.h
@@ -57,7 +57,7 @@ public:
virtual ~ToolbarHandler();
private:
- HashMap<String, Toolbar*, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _toolbarMap;
+ HashMap<String, Toolbar *, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _toolbarMap;
String _current;
Toolbar *_active;
int _offset;
diff --git a/backends/platform/wince/CEkeys/EventsBuffer.cpp b/backends/platform/wince/CEkeys/EventsBuffer.cpp
index c9f4af2304..beea272d2b 100644
--- a/backends/platform/wince/CEkeys/EventsBuffer.cpp
+++ b/backends/platform/wince/CEkeys/EventsBuffer.cpp
@@ -29,55 +29,55 @@
namespace CEKEYS {
- bool EventsBuffer::simulateKey(GUI::Key *key, bool pushed) {
- SDL_Event ev = {0};
-
- if (!key->keycode())
- key->setKey(key->ascii(), key->ascii());
- else if (!key->ascii())
- key->setKey(key->keycode());
-
- ev.type = (pushed ? SDL_KEYDOWN : SDL_KEYUP);
- ev.key.keysym.unicode = (SDLMod)key->flags(); // HACK: put the flags into the unused unicode field
- ev.key.keysym.sym = (SDLKey)key->keycode();
- ev.key.keysym.mod = KMOD_RESERVED;
- return (SDL_PushEvent(&ev) == 0);
- }
-
- bool EventsBuffer::simulateMouseMove(int x, int y) {
- SDL_Event ev = {0};
-
- ev.type = SDL_MOUSEMOTION;
- ev.motion.x = x;
- ev.motion.y = y;
- return (SDL_PushEvent(&ev) == 0);
- }
-
- bool EventsBuffer::simulateMouseLeftClick(int x, int y, bool pushed) {
- SDL_Event ev = {0};
- static bool state = false;
-
- if (pushed == state) return 0;
- state = pushed;
- ev.type = (pushed ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP);
- ev.button.button = SDL_BUTTON_LEFT;
- ev.button.x = x;
- ev.button.y = y;
- return (SDL_PushEvent(&ev) == 0);
- }
-
- bool EventsBuffer::simulateMouseRightClick(int x, int y, bool pushed) {
- SDL_Event ev = {0};
- static bool state = false;
-
- if (pushed == state) return 0;
- state = pushed;
- ev.type = (pushed ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP);
- ev.button.button = SDL_BUTTON_RIGHT;
- ev.button.x = x;
- ev.button.y = y;
- return (SDL_PushEvent(&ev) == 0);
- }
+bool EventsBuffer::simulateKey(GUI::Key *key, bool pushed) {
+ SDL_Event ev = {0};
+
+ if (!key->keycode())
+ key->setKey(key->ascii(), key->ascii());
+ else if (!key->ascii())
+ key->setKey(key->keycode());
+
+ ev.type = (pushed ? SDL_KEYDOWN : SDL_KEYUP);
+ ev.key.keysym.unicode = (SDLMod)key->flags(); // HACK: put the flags into the unused unicode field
+ ev.key.keysym.sym = (SDLKey)key->keycode();
+ ev.key.keysym.mod = KMOD_RESERVED;
+ return (SDL_PushEvent(&ev) == 0);
+}
+
+bool EventsBuffer::simulateMouseMove(int x, int y) {
+ SDL_Event ev = {0};
+
+ ev.type = SDL_MOUSEMOTION;
+ ev.motion.x = x;
+ ev.motion.y = y;
+ return (SDL_PushEvent(&ev) == 0);
+}
+
+bool EventsBuffer::simulateMouseLeftClick(int x, int y, bool pushed) {
+ SDL_Event ev = {0};
+ static bool state = false;
+
+ if (pushed == state) return 0;
+ state = pushed;
+ ev.type = (pushed ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP);
+ ev.button.button = SDL_BUTTON_LEFT;
+ ev.button.x = x;
+ ev.button.y = y;
+ return (SDL_PushEvent(&ev) == 0);
+}
+
+bool EventsBuffer::simulateMouseRightClick(int x, int y, bool pushed) {
+ SDL_Event ev = {0};
+ static bool state = false;
+
+ if (pushed == state) return 0;
+ state = pushed;
+ ev.type = (pushed ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP);
+ ev.button.button = SDL_BUTTON_RIGHT;
+ ev.button.x = x;
+ ev.button.y = y;
+ return (SDL_PushEvent(&ev) == 0);
+}
}
diff --git a/backends/platform/wince/CEkeys/EventsBuffer.h b/backends/platform/wince/CEkeys/EventsBuffer.h
index 22590db03c..9b766c6ca9 100644
--- a/backends/platform/wince/CEkeys/EventsBuffer.h
+++ b/backends/platform/wince/CEkeys/EventsBuffer.h
@@ -34,14 +34,14 @@
namespace CEKEYS {
- class EventsBuffer {
- public:
- static bool simulateKey(GUI::Key *key, bool pushed);
- static bool simulateMouseMove(int x, int y);
- static bool simulateMouseLeftClick(int x, int y, bool pushed);
- static bool simulateMouseRightClick(int x, int y, bool pushed);
-
- };
+class EventsBuffer {
+public:
+ static bool simulateKey(GUI::Key *key, bool pushed);
+ static bool simulateMouseMove(int x, int y);
+ static bool simulateMouseLeftClick(int x, int y, bool pushed);
+ static bool simulateMouseRightClick(int x, int y, bool pushed);
+
+};
}
#endif
diff --git a/backends/platform/wince/missing/io.h b/backends/platform/wince/missing/io.h
index 8c66e9405b..96bc6a9ea1 100644
--- a/backends/platform/wince/missing/io.h
+++ b/backends/platform/wince/missing/io.h
@@ -5,9 +5,9 @@
#define strdup _strdup
#ifndef _FILE_DEFINED
- typedef void FILE;
- #define _FILE_DEFINED
+typedef void FILE;
+#define _FILE_DEFINED
#endif
-FILE* wce_fopen(const char* fname, const char* fmode);
+FILE *wce_fopen(const char *fname, const char *fmode);
#define fopen wce_fopen
diff --git a/backends/platform/wince/missing/missing.cpp b/backends/platform/wince/missing/missing.cpp
index 7de706b23f..c855247ae1 100644
--- a/backends/platform/wince/missing/missing.cpp
+++ b/backends/platform/wince/missing/missing.cpp
@@ -50,7 +50,7 @@ char *strdup(const char *strSource);
// common missing functions required by both gcc and evc
void *bsearch(const void *key, const void *base, size_t nmemb,
- size_t size, int (*compar)(const void *, const void *)) {
+ size_t size, int (*compar)(const void *, const void *)) {
// Perform binary search
size_t lo = 0;
size_t hi = nmemb;
@@ -69,11 +69,11 @@ void *bsearch(const void *key, const void *base, size_t nmemb,
return NULL;
}
-static char cwd[MAX_PATH+1] = "";
+static char cwd[MAX_PATH + 1] = "";
EXT_C char *getcwd(char *buffer, int maxlen) {
- TCHAR fileUnc[MAX_PATH+1];
- char* plast;
+ TCHAR fileUnc[MAX_PATH + 1];
+ char *plast;
if (cwd[0] == 0) {
GetModuleFileName(NULL, fileUnc, MAX_PATH);
@@ -94,7 +94,7 @@ EXT_C char *getcwd(char *buffer, int maxlen) {
#undef GetCurrentDirectory
#endif
EXT_C void GetCurrentDirectory(int len, char *buf) {
- getcwd(buf,len);
+ getcwd(buf, len);
}
/*
@@ -103,8 +103,8 @@ fully qualified paths refer to root folder rather
than current folder (concept not implemented in CE).
*/
#undef fopen
-EXT_C FILE *wce_fopen(const char* fname, const char* fmode) {
- char fullname[MAX_PATH+1];
+EXT_C FILE *wce_fopen(const char *fname, const char *fmode) {
+ char fullname[MAX_PATH + 1];
if (!fname || fname[0] == '\0')
return NULL;
@@ -118,8 +118,8 @@ EXT_C FILE *wce_fopen(const char* fname, const char* fmode) {
}
/* Remove file by name */
-int remove(const char* path) {
- TCHAR pathUnc[MAX_PATH+1];
+int remove(const char *path) {
+ TCHAR pathUnc[MAX_PATH + 1];
MultiByteToWideChar(CP_ACP, 0, path, -1, pathUnc, MAX_PATH);
return !DeleteFile(pathUnc);
}
@@ -128,15 +128,15 @@ int remove(const char* path) {
/* check out file access permissions */
int _access(const char *path, int mode) {
TCHAR fname[MAX_PATH];
- char fullname[MAX_PATH+1];
+ char fullname[MAX_PATH + 1];
if (path[0] != '\\' && path[0] != '/') {
getcwd(fullname, MAX_PATH);
strcat(fullname, "\\");
strcat(fullname, path);
- MultiByteToWideChar(CP_ACP, 0, fullname, -1, fname, sizeof(fname)/sizeof(TCHAR));
+ MultiByteToWideChar(CP_ACP, 0, fullname, -1, fname, sizeof(fname) / sizeof(TCHAR));
} else
- MultiByteToWideChar(CP_ACP, 0, path, -1, fname, sizeof(fname)/sizeof(TCHAR));
+ MultiByteToWideChar(CP_ACP, 0, path, -1, fname, sizeof(fname) / sizeof(TCHAR));
WIN32_FIND_DATA ffd;
HANDLE h = FindFirstFile(fname, &ffd);
@@ -144,10 +144,10 @@ int _access(const char *path, int mode) {
if (h == INVALID_HANDLE_VALUE) {
// WORKAROUND: WinCE 3.0 doesn't find paths ending in '\'
- if (path[strlen(path)-1] == '\\') {
+ if (path[strlen(path) - 1] == '\\') {
char p2[MAX_PATH];
- strncpy(p2, path, strlen(path)-1);
- p2[strlen(path) - 1]= '\0';
+ strncpy(p2, path, strlen(path) - 1);
+ p2[strlen(path) - 1] = '\0';
return _access(p2, mode);
} else
return -1; //Can't find file
@@ -170,13 +170,13 @@ int _access(const char *path, int mode) {
return 0; //Always return success if target is directory and exists
}
switch (mode) {
- case 00: //Check existence
- return 0;
- case 06: //Check Read & Write permission
- case 02: //Check Write permission
- return ffd.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? -1 : 0;
- case 04: //Check Read permission
- return 0; //Assume always have read permission
+ case 00: //Check existence
+ return 0;
+ case 06: //Check Read & Write permission
+ case 02: //Check Write permission
+ return ffd.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? -1 : 0;
+ case 04: //Check Read permission
+ return 0; //Assume always have read permission
}
//Bad mode value supplied, return failure
return -1;
@@ -188,7 +188,7 @@ int _access(const char *path, int mode) {
char *strdup(const char *strSource) {
char *buffer;
size_z len = strlen(strSource) + 1;
- buffer = (char*)malloc(len);
+ buffer = (char *)malloc(len);
if (buffer)
memcpy(buffer, strSource, len);
return buffer;
@@ -199,25 +199,25 @@ char *strdup(const char *strSource) {
#ifndef __MINGW32CE__
int islower(int c) {
- return (c>='a' && c<='z');
+ return (c >= 'a' && c <= 'z');
}
int isspace(int c) {
- return (c==' ' || c=='\f' || c=='\n' || c=='\r' || c=='\t' || c=='\v');
+ return (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v');
}
int isalpha(int c) {
- return ((c>='a' && c<='z') || (c>='A' && c<='Z'));
+ return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
}
int isalnum(int c) {
- return ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9'));
+ return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'));
}
int isprint(int c) {
//static const char punct[] = "!\"#%&'();<=>?[\\]*+,-./:^_{|}~";
//return (isalnum(c) || strchr(punct, c));
- return (32 <= c && c <= 126); // based on BSD manpage
+ return (32 <= c && c <= 126); // based on BSD manpage
}
#endif
diff --git a/backends/platform/wince/missing/time.h b/backends/platform/wince/missing/time.h
index f2bc5e4f89..a0ba6c246e 100644
--- a/backends/platform/wince/missing/time.h
+++ b/backends/platform/wince/missing/time.h
@@ -6,8 +6,7 @@
#include <stdlib.h>
#ifndef __MINGW32CE__
-struct tm
-{
+struct tm {
short tm_year;
short tm_mon;
short tm_mday;
@@ -23,8 +22,8 @@ struct tm
#define EXT_C
#endif
-EXT_C time_t time(time_t* dummy);
-EXT_C struct tm* localtime(time_t* dummy);
+EXT_C time_t time(time_t *dummy);
+EXT_C struct tm *localtime(time_t *dummy);
unsigned int clock();
diff --git a/backends/platform/wince/portdefs.h b/backends/platform/wince/portdefs.h
index cbf2006be2..8ad643946f 100644
--- a/backends/platform/wince/portdefs.h
+++ b/backends/platform/wince/portdefs.h
@@ -34,10 +34,10 @@ int isprint(int c);
int isspace(int c);
char *strrchr(const char *s, int c);
char *strdup(const char *s);
-int _stricmp( const char *string1, const char *string2 );
-int stricmp( const char *string1, const char *string2 );
-void assert( void* expression );
-void assert( int expression );
+int _stricmp(const char *string1, const char *string2);
+int stricmp(const char *string1, const char *string2);
+void assert(void *expression);
+void assert(int expression);
long int strtol(const char *nptr, char **endptr, int base);
char *_strdup(const char *s);
char *strpbrk(const char *s, const char *accept);
@@ -47,20 +47,20 @@ char *strpbrk(const char *s, const char *accept);
#ifdef _WIN32_WCE
#ifndef __GNUC__
- void *bsearch(const void *, const void *, size_t, size_t, int (*x) (const void *, const void *));
- char *getcwd(char *buf, int size);
- typedef int ptrdiff_t;
- void GetCurrentDirectory(int len, char *buf);
- #define INVALID_FILE_ATTRIBUTES 0xffffffff
+void *bsearch(const void *, const void *, size_t, size_t, int (*x)(const void *, const void *));
+char *getcwd(char *buf, int size);
+typedef int ptrdiff_t;
+void GetCurrentDirectory(int len, char *buf);
+#define INVALID_FILE_ATTRIBUTES 0xffffffff
#else
- #include <math.h>
- #undef GetCurrentDirectory
- extern "C" void GetCurrentDirectory(int len, char *buf);
- #define stricmp _stricmp
- #define strnicmp _strnicmp
- #define snprintf _snprintf
- #define strdup _strdup
- #define fopen wce_fopen
+#include <math.h>
+#undef GetCurrentDirectory
+extern "C" void GetCurrentDirectory(int len, char *buf);
+#define stricmp _stricmp
+#define strnicmp _strnicmp
+#define snprintf _snprintf
+#define strdup _strdup
+#define fopen wce_fopen
#endif
#include <windows.h>
@@ -75,12 +75,12 @@ char *strpbrk(const char *s, const char *accept);
//#include <direct.h>
#ifdef __MINGW32CE__
- void *bsearch(const void *, const void *, size_t, size_t, int (*x) (const void *, const void *));
+void *bsearch(const void *, const void *, size_t, size_t, int (*x)(const void *, const void *));
#endif
int remove(const char *path);
int _access(const char *path, int mode);
-void drawError(char*);
+void drawError(char *);
#define vsnprintf _vsnprintf
diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp
index 45aa63529f..b829686cb0 100644
--- a/backends/platform/wince/wince-sdl.cpp
+++ b/backends/platform/wince/wince-sdl.cpp
@@ -69,7 +69,7 @@
#endif
#ifdef __GNUC__
-extern "C" _CRTIMP FILE* __cdecl _wfreopen (const wchar_t*, const wchar_t*, FILE*);
+extern "C" _CRTIMP FILE *__cdecl _wfreopen(const wchar_t *, const wchar_t *, FILE *);
#endif
using namespace CEGUI;
@@ -99,7 +99,7 @@ bool isSmartphone() {
}
const TCHAR *ASCIItoUnicode(const char *str) {
- static TCHAR ustr[MAX_PATH]; // size good enough
+ static TCHAR ustr[MAX_PATH]; // size good enough
MultiByteToWideChar(CP_ACP, 0, str, strlen(str) + 1, ustr, sizeof(ustr) / sizeof(TCHAR));
return ustr;
@@ -128,7 +128,7 @@ int SDL_main(int argc, char **argv) {
// thanks to joostp and DJWillis
extern void (*__CTOR_LIST__)();
void (**constructor)() = &__CTOR_LIST__;
- constructor++; // First item in list of constructors has special meaning (platform dependent), ignore it.
+ constructor++; // First item in list of constructors has special meaning (platform dependent), ignore it.
while (*constructor) {
(*constructor)();
constructor++;
@@ -193,10 +193,10 @@ int SDL_main(int argc, char **argv) {
res = scummvm_main(argc, argv);
// Free OSystem
- delete (OSystem_WINCE3 *)g_system;
+ delete(OSystem_WINCE3 *)g_system;
#if !defined(DEBUG) && !defined(__GNUC__)
}
- __except (handleException(GetExceptionInformation())) {
+ __except(handleException(GetExceptionInformation())) {
}
#endif
@@ -219,22 +219,22 @@ int console_main(int argc, char *argv[]) {
char *bufp, *appname;
appname = argv[0];
- if ( (bufp=strrchr(argv[0], '\\')) != NULL )
+ if ((bufp = strrchr(argv[0], '\\')) != NULL)
appname = bufp + 1;
- else if ( (bufp=strrchr(argv[0], '/')) != NULL )
+ else if ((bufp = strrchr(argv[0], '/')) != NULL)
appname = bufp + 1;
- if ( (bufp=strrchr(appname, '.')) == NULL )
+ if ((bufp = strrchr(appname, '.')) == NULL)
n = strlen(appname);
else
- n = (bufp-appname);
+ n = (bufp - appname);
bufp = (char *) alloca(n + 1);
strncpy(bufp, appname, n);
bufp[n] = '\0';
appname = bufp;
- if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) {
+ if (SDL_Init(SDL_INIT_NOPARACHUTE) < 0) {
error("WinMain() error: %d", SDL_GetError());
return(FALSE);
}
@@ -299,31 +299,31 @@ int dynamic_modules_main(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR szCmdLine, int
int nLen;
if (wcsncmp(szCmdLine, TEXT("\\"), 1)) {
- nLen = wcslen(szCmdLine)+128+1;
- bufp = (wchar_t *) alloca(nLen*2);
- wcscpy (bufp, TEXT("\""));
- GetModuleFileName(NULL, bufp+1, 128-3);
- wcscpy (bufp+wcslen(bufp), TEXT("\" "));
- wcsncpy(bufp+wcslen(bufp), szCmdLine,nLen-wcslen(bufp));
+ nLen = wcslen(szCmdLine) + 128 + 1;
+ bufp = (wchar_t *) alloca(nLen * 2);
+ wcscpy(bufp, TEXT("\""));
+ GetModuleFileName(NULL, bufp + 1, 128 - 3);
+ wcscpy(bufp + wcslen(bufp), TEXT("\" "));
+ wcsncpy(bufp + wcslen(bufp), szCmdLine, nLen - wcslen(bufp));
} else
bufp = szCmdLine;
- nLen = wcslen(bufp)+1;
+ nLen = wcslen(bufp) + 1;
cmdline = (char *) alloca(nLen);
WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL);
// Parse command line into argv and argc
argc = ParseCommandLine(cmdline, NULL);
- argv = (char **) alloca((argc+1)*(sizeof *argv));
+ argv = (char **) alloca((argc + 1) * (sizeof * argv));
ParseCommandLine(cmdline, argv);
// fix gdb-emulator combo
while (argc > 1 && !strstr(argv[0], ".exe")) {
OutputDebugString(TEXT("SDL: gdb argv[0] fixup\n"));
- *(argv[1]-1) = ' ';
+ *(argv[1] - 1) = ' ';
int i;
- for (i=1; i<argc; i++)
- argv[i] = argv[i+1];
+ for (i = 1; i < argc; i++)
+ argv[i] = argv[i + 1];
argc--;
}
@@ -378,11 +378,13 @@ void OSystem_WINCE3::initBackend() {
if (_graphicsManager == 0)
_graphicsManager = new WINCESdlGraphicsManager(_eventSource);
+ ((WINCESdlEventSource *)_eventSource)->init((WINCESdlGraphicsManager *)_graphicsManager);
+
// Create the timer. CE SDL does not support multiple timers (SDL_AddTimer).
// We work around this by using the SetTimer function, since we only use
// one timer in scummvm (for the time being)
_timer = _int_timer = new DefaultTimerManager();
- //_timerID = NULL; // OSystem_SDL will call removetimer with this, it's ok
+ //_timerID = NULL; // OSystem_SDL will call removetimer with this, it's ok
SDL_SetTimer(10, &timer_handler_wrapper);
// Chain init
@@ -391,9 +393,9 @@ void OSystem_WINCE3::initBackend() {
// Initialize global key mapping
GUI::Actions::init();
GUI_Actions::Instance()->initInstanceMain(this);
- if (!GUI_Actions::Instance()->loadMapping()) { // error during loading means not present/wrong version
+ if (!GUI_Actions::Instance()->loadMapping()) { // error during loading means not present/wrong version
warning("Setting default action mappings");
- GUI_Actions::Instance()->saveMapping(); // write defaults
+ GUI_Actions::Instance()->saveMapping(); // write defaults
}
// Call parent implementation of this method
@@ -435,8 +437,7 @@ Common::String OSystem_WINCE3::getDefaultConfigFileName() {
OSystem_WINCE3::OSystem_WINCE3() : OSystem_SDL(),
- _forcePanelInvisible(false)
-{
+ _forcePanelInvisible(false) {
// Initialze File System Factory
_fsFactory = new WindowsFilesystemFactory();
_mixer = 0;
@@ -456,8 +457,8 @@ void OSystem_WINCE3::swap_sound_master() {
//WINCESdlGraphicsManager _graphicsManager
- if (((WINCESdlGraphicsManager*)_graphicsManager)->_toolbarHandler.activeName() == NAME_MAIN_PANEL)
- ((WINCESdlGraphicsManager*)_graphicsManager)->_toolbarHandler.forceRedraw(); // redraw sound icon
+ if (((WINCESdlGraphicsManager *)_graphicsManager)->_toolbarHandler.activeName() == NAME_MAIN_PANEL)
+ ((WINCESdlGraphicsManager *)_graphicsManager)->_toolbarHandler.forceRedraw(); // redraw sound icon
}
@@ -478,7 +479,7 @@ void OSystem_WINCE3::check_mappings() {
return;
GUI_Actions::Instance()->initInstanceGame();
- instance = (CEActionsPocket*)GUI_Actions::Instance();
+ instance = (CEActionsPocket *)GUI_Actions::Instance();
// Some games need to map the right click button, signal it here if it wasn't done
if (instance->needsRightClickMapping()) {
@@ -518,7 +519,7 @@ void OSystem_WINCE3::check_mappings() {
// Extra warning for Zak Mc Kracken
if (strncmp(gameid.c_str(), "zak", 3) == 0 &&
- !GUI_Actions::Instance()->getMapping(POCKET_ACTION_HIDE)) {
+ !GUI_Actions::Instance()->getMapping(POCKET_ACTION_HIDE)) {
GUI::MessageDialog alert(_("Don't forget to map a key to 'Hide Toolbar' action to see the whole inventory"));
alert.runModal();
}
@@ -568,12 +569,12 @@ void OSystem_WINCE3::getTimeAndDate(TimeDate &t) const {
SYSTEMTIME systime;
GetLocalTime(&systime);
- t.tm_year = systime.wYear - 1900;
- t.tm_mon = systime.wMonth - 1;
- t.tm_mday = systime.wDay;
- t.tm_hour = systime.wHour;
- t.tm_min = systime.wMinute;
- t.tm_sec = systime.wSecond;
+ t.tm_year = systime.wYear - 1900;
+ t.tm_mon = systime.wMonth - 1;
+ t.tm_mday = systime.wDay;
+ t.tm_hour = systime.wHour;
+ t.tm_min = systime.wMinute;
+ t.tm_sec = systime.wSecond;
}
int OSystem_WINCE3::_platformScreenWidth;
diff --git a/backends/platform/wince/wince-sdl.h b/backends/platform/wince/wince-sdl.h
index 34672f84df..d7ede8ca81 100644
--- a/backends/platform/wince/wince-sdl.h
+++ b/backends/platform/wince/wince-sdl.h
@@ -70,8 +70,8 @@ public:
static void initScreenInfos();
static bool isOzone();
- static bool _soundMaster; // turn off sound after all calculations
- // static since needed by the SDL callback
+ static bool _soundMaster; // turn off sound after all calculations
+ // static since needed by the SDL callback
protected:
void initSDL();
@@ -82,11 +82,11 @@ protected:
private:
void check_mappings();
- bool _forcePanelInvisible; // force panel visibility for some cases
+ bool _forcePanelInvisible; // force panel visibility for some cases
static int _platformScreenWidth;
static int _platformScreenHeight;
- static bool _isOzone; // true if running on Windows 2003 SE
+ static bool _isOzone; // true if running on Windows 2003 SE
};
diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp
index 897ca79d0e..19882c4f1c 100644
--- a/engines/mohawk/graphics.cpp
+++ b/engines/mohawk/graphics.cpp
@@ -246,6 +246,13 @@ void GraphicsManager::copyAnimImageSectionToScreen(MohawkSurface *image, Common:
getVM()->_system->unlockScreen();
}
+void GraphicsManager::addImageToCache(uint16 id, MohawkSurface *surface) {
+ if (_cache.contains(id))
+ error("Image %d already in cache", id);
+
+ _cache[id] = surface;
+}
+
MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : GraphicsManager(), _vm(vm) {
_bmpDecoder = new MystBitmap();
@@ -630,6 +637,9 @@ RivenGraphics::RivenGraphics(MohawkEngine_Riven* vm) : GraphicsManager(), _vm(vm
_scheduledTransition = -1; // no transition
_dirtyScreen = false;
_inventoryDrawn = false;
+
+ _creditsImage = 302;
+ _creditsPos = 0;
}
RivenGraphics::~RivenGraphics() {
@@ -840,6 +850,17 @@ void RivenGraphics::runScheduledTransition() {
_scheduledTransition = -1; // Clear scheduled transition
}
+void RivenGraphics::clearMainScreen() {
+ _mainScreen->fillRect(Common::Rect(0, 0, 608, 392), _pixelFormat.RGBToColor(0, 0, 0));
+}
+
+void RivenGraphics::fadeToBlack() {
+ // Self-explanatory
+ scheduleTransition(16);
+ clearMainScreen();
+ runScheduledTransition();
+}
+
void RivenGraphics::showInventory() {
// Don't redraw the inventory
if (_inventoryDrawn)
@@ -955,6 +976,60 @@ void RivenGraphics::drawExtrasImage(uint16 id, Common::Rect dstRect) {
_dirtyScreen = true;
}
+void RivenGraphics::beginCredits() {
+ // Clear the old cache
+ clearCache();
+
+ // Now cache all the credits images
+ for (uint16 i = 302; i <= 320; i++) {
+ MohawkSurface *surface = _bitmapDecoder->decodeImage(_vm->getExtrasResource(ID_TBMP, i));
+ surface->convertToTrueColor();
+ addImageToCache(i, surface);
+ }
+
+ // And clear our screen too
+ clearMainScreen();
+}
+
+void RivenGraphics::updateCredits() {
+ if ((_creditsImage == 303 || _creditsImage == 304) && _creditsPos == 0)
+ fadeToBlack();
+
+ if (_creditsImage < 304) {
+ // For the first two credit images, they are faded from black to the image and then out again
+ scheduleTransition(16);
+
+ Graphics::Surface *frame = findImage(_creditsImage++)->getSurface();
+
+ for (int y = 0; y < frame->h; y++)
+ memcpy(_mainScreen->getBasePtr(124, y), frame->getBasePtr(0, y), frame->pitch);
+
+ runScheduledTransition();
+ } else {
+ // Otheriwse, we're scrolling
+ // Move the screen up one row
+ memmove(_mainScreen->pixels, _mainScreen->getBasePtr(0, 1), _mainScreen->pitch * (_mainScreen->h - 1));
+
+ // Only update as long as we're not before the last frame
+ // Otherwise, we're just moving up a row (which we already did)
+ if (_creditsImage <= 320) {
+ // Copy the next row to the bottom of the screen
+ Graphics::Surface *frame = findImage(_creditsImage)->getSurface();
+ memcpy(_mainScreen->getBasePtr(124, _mainScreen->h - 1), frame->getBasePtr(0, _creditsPos), frame->pitch);
+ _creditsPos++;
+
+ if (_creditsPos == _mainScreen->h) {
+ _creditsImage++;
+ _creditsPos = 0;
+ }
+ }
+
+ // Now flush the new screen
+ _vm->_system->copyRectToScreen((byte *)_mainScreen->pixels, _mainScreen->pitch, 0, 0, _mainScreen->w, _mainScreen->h);
+ _vm->_system->updateScreen();
+ }
+}
+
LBGraphics::LBGraphics(MohawkEngine_LivingBooks *vm, uint16 width, uint16 height) : GraphicsManager(), _vm(vm) {
_bmpDecoder = _vm->isPreMohawk() ? new OldMohawkBitmap() : new MohawkBitmap();
diff --git a/engines/mohawk/graphics.h b/engines/mohawk/graphics.h
index 89189d442a..fbac2f2ea1 100644
--- a/engines/mohawk/graphics.h
+++ b/engines/mohawk/graphics.h
@@ -110,6 +110,7 @@ protected:
virtual Common::Array<MohawkSurface *> decodeImages(uint16 id);
virtual MohawkEngine *getVM() = 0;
+ void addImageToCache(uint16 id, MohawkSurface *surface);
private:
// An image cache that stores images until clearCache() is called
@@ -195,11 +196,17 @@ public:
// Transitions
void scheduleTransition(uint16 id, Common::Rect rect = Common::Rect(0, 0, 608, 392));
void runScheduledTransition();
+ void fadeToBlack();
// Inventory
void showInventory();
void hideInventory();
+ // Credits
+ void beginCredits();
+ void updateCredits();
+ uint getCurCreditsImage() { return _creditsImage; }
+
protected:
MohawkSurface *decodeImage(uint16 id);
MohawkEngine *getVM() { return (MohawkEngine *)_vm; }
@@ -224,6 +231,10 @@ private:
Graphics::Surface *_mainScreen;
bool _dirtyScreen;
Graphics::PixelFormat _pixelFormat;
+ void clearMainScreen();
+
+ // Credits
+ uint _creditsImage, _creditsPos;
};
class LBGraphics : public GraphicsManager {
diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp
index e6ea25c9a6..5424a07a3c 100644
--- a/engines/mohawk/riven_external.cpp
+++ b/engines/mohawk/riven_external.cpp
@@ -216,20 +216,37 @@ void RivenExternal::runDemoBoundaryDialog() {
dialog.runModal();
}
-void RivenExternal::runEndGame(uint16 video) {
+void RivenExternal::runEndGame(uint16 video, uint32 delay) {
_vm->_sound->stopAllSLST();
_vm->_video->playMovieRiven(video);
- runCredits(video);
+ runCredits(video, delay);
}
-void RivenExternal::runCredits(uint16 video) {
- // TODO: Play until the last frame and then run the credits
+void RivenExternal::runCredits(uint16 video, uint32 delay) {
+ // Initialize our credits state
+ _vm->_cursor->hideCursor();
+ _vm->_gfx->beginCredits();
+ uint nextCreditsFrameStart = 0;
VideoHandle videoHandle = _vm->_video->findVideoHandleRiven(video);
- while (!_vm->_video->endOfVideo(videoHandle) && !_vm->shouldQuit()) {
- if (_vm->_video->updateMovies())
- _vm->_system->updateScreen();
+ while (!_vm->shouldQuit() && _vm->_gfx->getCurCreditsImage() <= 320) {
+ if (_vm->_video->getCurFrame(videoHandle) >= (int32)_vm->_video->getFrameCount(videoHandle) - 1) {
+ if (nextCreditsFrameStart == 0) {
+ // Set us up to start after delay ms
+ nextCreditsFrameStart = _vm->_system->getMillis() + delay;
+ } else if (_vm->_system->getMillis() >= nextCreditsFrameStart) {
+ // the first two frames stay on for 5 seconds
+ // the rest of the scroll updates happen at 30Hz
+ if (_vm->_gfx->getCurCreditsImage() < 304)
+ nextCreditsFrameStart = _vm->_system->getMillis() + 5000;
+ else
+ nextCreditsFrameStart = _vm->_system->getMillis() + 1000 / 30;
+
+ _vm->_gfx->updateCredits();
+ }
+ } else if (_vm->_video->updateMovies())
+ _vm->_system->updateScreen();
Common::Event event;
while (_vm->_system->getEventManager()->pollEvent(event))
@@ -1838,11 +1855,11 @@ void RivenExternal::xorollcredittime(uint16 argc, uint16 *argv) {
uint32 *gehnState = _vm->getVar("agehn");
if (*gehnState == 0) // Gehn who?
- runEndGame(1);
+ runEndGame(1, 9500);
else if (*gehnState == 4) // You freed him? Are you kidding me?
- runEndGame(2);
+ runEndGame(2, 12000);
else // You already spoke with Gehn. What were you thinking?
- runEndGame(3);
+ runEndGame(3, 8000);
}
void RivenExternal::xbookclick(uint16 argc, uint16 *argv) {
@@ -1923,7 +1940,7 @@ void RivenExternal::xbookclick(uint16 argc, uint16 *argv) {
*_vm->getVar("agehn") = 4; // Set Gehn to the trapped state
*_vm->getVar("atrapbook") = 1; // We've got the trap book again
_vm->_sound->playSound(0); // Play the link sound again
- _vm->changeToCard(_vm->matchRMAPToCard(0x2885)); // Link out! (TODO: Shouldn't this card change?)
+ _vm->changeToCard(_vm->matchRMAPToCard(0x2885)); // Link out!
return;
}
break;
@@ -1951,7 +1968,7 @@ void RivenExternal::xbookclick(uint16 argc, uint16 *argv) {
// Run the credits from here.
if (*_vm->getVar("agehn") == 3) {
_vm->_scriptMan->stopAllScripts();
- runCredits(argv[0]);
+ runCredits(argv[0], 5000);
return;
}
@@ -2126,7 +2143,7 @@ void RivenExternal::xrcredittime(uint16 argc, uint16 *argv) {
// For the record, when agehn == 4, Gehn will thank you for
// showing him the rebel age and then leave you to die.
// Otherwise, the rebels burn the book. Epic fail either way.
- runEndGame(1);
+ runEndGame(1, 1500);
}
void RivenExternal::xrshowinventory(uint16 argc, uint16 *argv) {
@@ -2166,30 +2183,26 @@ void RivenExternal::xtexterior300_telescopedown(uint16 argc, uint16 *argv) {
if (*_vm->getVar("pcage") == 2) {
// The best ending: Catherine is free, Gehn is trapped, Atrus comes to rescue you.
// And now we fall back to Earth... all the way...
- warning("xtexterior300_telescopedown: Good ending");
_vm->_video->activateMLST(8, _vm->getCurCard());
- runEndGame(8);
+ runEndGame(8, 5000);
} else if (*_vm->getVar("agehn") == 4) {
// The ok ending: Catherine is still trapped, Gehn is trapped, Atrus comes to rescue you.
// Nice going! Catherine and the islanders are all dead now! Just go back to your home...
- warning("xtexterior300_telescopedown: OK ending");
_vm->_video->activateMLST(9, _vm->getCurCard());
- runEndGame(9);
+ runEndGame(9, 5000);
} else if (*_vm->getVar("atrapbook") == 1) {
// The bad ending: Catherine is trapped, Gehn is free, Atrus gets shot by Gehn,
// And then you get shot by Cho. Nice going! Catherine and the islanders are dead
// and you have just set Gehn free from Riven, not to mention you're dead.
- warning("xtexterior300_telescopedown: Bad ending");
_vm->_video->activateMLST(10, _vm->getCurCard());
- runEndGame(10);
+ runEndGame(10, 5000);
} else {
// The impossible ending: You don't have Catherine's journal and yet you were somehow
// able to open the hatch on the telescope. The game provides an ending for those who
// cheat, load a saved game with the combo, or just guess the telescope combo. Atrus
// doesn't come and you just fall into the fissure.
- warning("xtexterior300_telescopedown: Wtf ending");
_vm->_video->activateMLST(11, _vm->getCurCard());
- runEndGame(11);
+ runEndGame(11, 5000);
}
} else {
// ...the telescope can't move down anymore.
diff --git a/engines/mohawk/riven_external.h b/engines/mohawk/riven_external.h
index 818bc06c54..90fdc664c1 100644
--- a/engines/mohawk/riven_external.h
+++ b/engines/mohawk/riven_external.h
@@ -61,8 +61,8 @@ private:
// Supplementary Functions
int jspitElevatorLoop();
void runDemoBoundaryDialog();
- void runEndGame(uint16 video);
- void runCredits(uint16 video);
+ void runEndGame(uint16 video, uint32 delay);
+ void runCredits(uint16 video, uint32 delay);
void runDomeCheck();
void runDomeButtonMovie();
void resetDomeSliders(uint16 soundId, uint16 startHotspot);
diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp
index e5a9931605..2540861a93 100644
--- a/engines/sci/engine/kevent.cpp
+++ b/engines/sci/engine/kevent.cpp
@@ -46,17 +46,18 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
SegManager *segMan = s->_segMan;
Common::Point mousePos;
- // Limit the mouse cursor position, if necessary
- g_sci->_gfxCursor->refreshPosition();
- mousePos = g_sci->_gfxCursor->getPosition();
-#ifdef ENABLE_SCI32
- if (getSciVersion() >= SCI_VERSION_2_1)
- g_sci->_gfxCoordAdjuster->fromDisplayToScript(mousePos.y, mousePos.x);
-#endif
-
// If there's a simkey pending, and the game wants a keyboard event, use the
// simkey instead of a normal event
if (g_debug_simulated_key && (mask & SCI_EVENT_KEYBOARD)) {
+ // In case we use a simulated event we query the current mouse position
+ mousePos = g_sci->_gfxCursor->getPosition();
+#ifdef ENABLE_SCI32
+ if (getSciVersion() >= SCI_VERSION_2_1)
+ g_sci->_gfxCoordAdjuster->fromDisplayToScript(mousePos.y, mousePos.x);
+#endif
+ // Limit the mouse cursor position, if necessary
+ g_sci->_gfxCursor->refreshPosition();
+
writeSelectorValue(segMan, obj, SELECTOR(type), SCI_EVENT_KEYBOARD); // Keyboard event
writeSelectorValue(segMan, obj, SELECTOR(message), g_debug_simulated_key);
writeSelectorValue(segMan, obj, SELECTOR(modifiers), SCI_KEYMOD_NUMLOCK); // Numlock on
@@ -68,6 +69,15 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
curEvent = g_sci->getEventManager()->getSciEvent(mask);
+ // For a real event we use its associated mouse position
+ mousePos = curEvent.mousePos;
+#ifdef ENABLE_SCI32
+ if (getSciVersion() >= SCI_VERSION_2_1)
+ g_sci->_gfxCoordAdjuster->fromDisplayToScript(mousePos.y, mousePos.x);
+#endif
+ // Limit the mouse cursor position, if necessary
+ g_sci->_gfxCursor->refreshPosition();
+
if (g_sci->getVocabulary())
g_sci->getVocabulary()->parser_event = NULL_REG; // Invalidate parser event
diff --git a/engines/sci/event.cpp b/engines/sci/event.cpp
index d607a5314f..cb0e6b3c03 100644
--- a/engines/sci/event.cpp
+++ b/engines/sci/event.cpp
@@ -35,12 +35,6 @@
namespace Sci {
-EventManager::EventManager(bool fontIsExtended) : _fontIsExtended(fontIsExtended), _modifierStates(0) {
-}
-
-EventManager::~EventManager() {
-}
-
struct ScancodeRow {
int offset;
const char *keys;
@@ -52,27 +46,6 @@ const ScancodeRow s_scancodeRows[] = {
{ 0x2c, "ZXCVBNM,./" }
};
-static int altify(int ch) {
- // Calculates a PC keyboard scancode from a character */
- int row;
- int c = toupper((char)ch);
-
- for (row = 0; row < ARRAYSIZE(s_scancodeRows); row++) {
- const char *keys = s_scancodeRows[row].keys;
- int offset = s_scancodeRows[row].offset;
-
- while (*keys) {
- if (*keys == c)
- return offset << 8;
-
- offset++;
- keys++;
- }
- }
-
- return ch;
-}
-
const byte codepagemap_88591toDOS[0x80] = {
'?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', // 0x8x
'?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', // 0x9x
@@ -120,147 +93,178 @@ const SciKeyConversion keyMappings[] = {
{ Common::KEYCODE_KP_DIVIDE , '/' , '/' },
};
+struct MouseEventConversion {
+ Common::EventType commonType;
+ short sciType;
+ short data;
+};
+
+const MouseEventConversion mouseEventMappings[] = {
+ { Common::EVENT_LBUTTONDOWN, SCI_EVENT_MOUSE_PRESS, 1 },
+ { Common::EVENT_RBUTTONDOWN, SCI_EVENT_MOUSE_PRESS, 2 },
+ { Common::EVENT_MBUTTONDOWN, SCI_EVENT_MOUSE_PRESS, 3 },
+ { Common::EVENT_LBUTTONUP, SCI_EVENT_MOUSE_RELEASE, 1 },
+ { Common::EVENT_LBUTTONUP, SCI_EVENT_MOUSE_RELEASE, 2 },
+ { Common::EVENT_LBUTTONUP, SCI_EVENT_MOUSE_RELEASE, 3 }
+};
+
+EventManager::EventManager(bool fontIsExtended) : _fontIsExtended(fontIsExtended) {
+}
+
+EventManager::~EventManager() {
+}
+
+static int altify(int ch) {
+ // Calculates a PC keyboard scancode from a character */
+ int row;
+ int c = toupper((char)ch);
+
+ for (row = 0; row < ARRAYSIZE(s_scancodeRows); row++) {
+ const char *keys = s_scancodeRows[row].keys;
+ int offset = s_scancodeRows[row].offset;
+
+ while (*keys) {
+ if (*keys == c)
+ return offset << 8;
+
+ offset++;
+ keys++;
+ }
+ }
+
+ return ch;
+}
+
SciEvent EventManager::getScummVMEvent() {
- SciEvent input = { SCI_EVENT_NONE, 0, 0, 0 };
+ SciEvent input = { SCI_EVENT_NONE, 0, 0, 0, Common::Point(0, 0) };
+ SciEvent noEvent = { SCI_EVENT_NONE, 0, 0, 0, Common::Point(0, 0) };
Common::EventManager *em = g_system->getEventManager();
Common::Event ev;
bool found = em->pollEvent(ev);
- Common::Point p = ev.mouse;
// Don't generate events for mouse movement
- while (found && ev.type == Common::EVENT_MOUSEMOVE) {
+ while (found && ev.type == Common::EVENT_MOUSEMOVE)
found = em->pollEvent(ev);
+
+ // Save the mouse position
+ //
+ // We call getMousePos of the event manager here, since we also want to
+ // store the mouse position in case of keyboard events, which do not feature
+ // any mouse position information itself.
+ // This should be safe, since the mouse position in the event manager should
+ // only be updated when a mouse related event has been taken from the queue
+ // via pollEvent.
+ noEvent.mousePos = input.mousePos = em->getMousePos();
+
+ if (!found || ev.type == Common::EVENT_MOUSEMOVE)
+ return noEvent;
+
+ if (ev.type == Common::EVENT_QUIT) {
+ input.type = SCI_EVENT_QUIT;
+ return input;
}
- if (found && ev.type != Common::EVENT_MOUSEMOVE) {
- int modifiers = em->getModifierState();
- bool numlockOn = (ev.kbd.flags & Common::KBD_NUM);
-
- // We add the modifier key status to buckybits
- //TODO: SCI_EVM_INSERT
-
- input.modifiers =
- ((modifiers & Common::KBD_ALT) ? SCI_KEYMOD_ALT : 0) |
- ((modifiers & Common::KBD_CTRL) ? SCI_KEYMOD_CTRL : 0) |
- ((modifiers & Common::KBD_SHIFT) ? SCI_KEYMOD_LSHIFT | SCI_KEYMOD_RSHIFT : 0) |
- ((ev.kbd.flags & Common::KBD_CAPS) ? SCI_KEYMOD_CAPSLOCK : 0) |
- ((ev.kbd.flags & Common::KBD_SCRL) ? SCI_KEYMOD_SCRLOCK : 0) |
- _modifierStates;
-
- switch (ev.type) {
- // Keyboard events
- case Common::EVENT_KEYDOWN:
- input.data = ev.kbd.keycode;
- input.character = ev.kbd.ascii;
-
- // Debug console
- if (ev.kbd.hasFlags(Common::KBD_CTRL) && ev.kbd.keycode == Common::KEYCODE_d) {
- // Open debug console
- Console *con = g_sci->getSciDebugger();
- con->attach();
-
- // Clear keyboard event
- input.type = SCI_EVENT_NONE;
- input.character = 0;
- input.data = 0;
- input.modifiers = 0;
-
- return input;
- }
+ // Handle mouse events
+ for (int i = 0; i < ARRAYSIZE(mouseEventMappings); i++) {
+ if (mouseEventMappings[i].commonType == ev.type) {
+ input.type = mouseEventMappings[i].sciType;
+ input.data = mouseEventMappings[i].data;
+ return input;
+ }
+ }
- if (!(input.data & 0xFF00)) {
- // Directly accept most common keys without conversion
- input.type = SCI_EVENT_KEYBOARD;
- if ((input.character >= 0x80) && (input.character <= 0xFF)) {
- // If there is no extended font, we will just clear the current event
- // Sierra SCI actually accepted those characters, but didn't display them inside textedit-controls
- // because the characters were missing inside the font(s)
- // We filter them out for non-multilingual games because of that
- if (!_fontIsExtended) {
- input.type = SCI_EVENT_NONE;
- input.character = 0;
- input.data = 0;
- input.modifiers = 0;
- return input;
- }
- // We get a 8859-1 character, we need dos (cp850/437) character for multilingual sci01 games
- input.character = codepagemap_88591toDOS[input.character & 0x7f];
- }
- if (input.data == Common::KEYCODE_TAB) {
- // Tab
- input.type = SCI_EVENT_KEYBOARD;
- input.data = SCI_KEY_TAB;
- if (input.modifiers & (SCI_KEYMOD_LSHIFT | SCI_KEYMOD_RSHIFT))
- input.character = SCI_KEY_SHIFT_TAB;
- else
- input.character = SCI_KEY_TAB;
- }
- if (input.data == Common::KEYCODE_DELETE) {
- // Delete key
- input.type = SCI_EVENT_KEYBOARD;
- input.data = input.character = SCI_KEY_DELETE;
- }
- } else if ((input.data >= Common::KEYCODE_F1) && input.data <= Common::KEYCODE_F10) {
- // F1-F10
- input.type = SCI_EVENT_KEYBOARD;
- // SCI_K_F1 == 59 << 8
- // SCI_K_SHIFT_F1 == 84 << 8
- input.data = SCI_KEY_F1 + ((input.data - Common::KEYCODE_F1)<<8);
- if (input.modifiers & (SCI_KEYMOD_LSHIFT | SCI_KEYMOD_RSHIFT))
- input.character = input.data + 0x1900;
- else
- input.character = input.data;
- } else {
- // Special keys that need conversion
- input.type = SCI_EVENT_KEYBOARD;
- for (int i = 0; i < ARRAYSIZE(keyMappings); i++) {
- if (keyMappings[i].scummVMKey == ev.kbd.keycode) {
- input.data = numlockOn ? keyMappings[i].sciKeyNumlockOn : keyMappings[i].sciKeyNumlockOff;
- break;
- }
- }
- input.character = input.data;
- }
- break;
+ // If we reached here, make sure that it's a keydown event
+ if (ev.type != Common::EVENT_KEYDOWN)
+ return noEvent;
- // Mouse events
- case Common::EVENT_LBUTTONDOWN:
- input.type = SCI_EVENT_MOUSE_PRESS;
- input.data = 1;
- break;
- case Common::EVENT_RBUTTONDOWN:
- input.type = SCI_EVENT_MOUSE_PRESS;
- input.data = 2;
- break;
- case Common::EVENT_MBUTTONDOWN:
- input.type = SCI_EVENT_MOUSE_PRESS;
- input.data = 3;
- break;
- case Common::EVENT_LBUTTONUP:
- input.type = SCI_EVENT_MOUSE_RELEASE;
- input.data = 1;
- break;
- case Common::EVENT_RBUTTONUP:
- input.type = SCI_EVENT_MOUSE_RELEASE;
- input.data = 2;
- break;
- case Common::EVENT_MBUTTONUP:
- input.type = SCI_EVENT_MOUSE_RELEASE;
- input.data = 3;
- break;
-
- // Misc events
- case Common::EVENT_QUIT:
- input.type = SCI_EVENT_QUIT;
- break;
+ // Check for Control-D (debug console)
+ if (ev.kbd.hasFlags(Common::KBD_CTRL) && ev.kbd.keycode == Common::KEYCODE_d) {
+ // Open debug console
+ Console *con = g_sci->getSciDebugger();
+ con->attach();
+ return noEvent;
+ }
- default:
- break;
+ // Process keyboard events
+
+ int modifiers = em->getModifierState();
+ bool numlockOn = (ev.kbd.flags & Common::KBD_NUM);
+
+ input.data = ev.kbd.keycode;
+ input.character = ev.kbd.ascii;
+ input.type = SCI_EVENT_KEYBOARD;
+
+ input.modifiers =
+ ((modifiers & Common::KBD_ALT) ? SCI_KEYMOD_ALT : 0) |
+ ((modifiers & Common::KBD_CTRL) ? SCI_KEYMOD_CTRL : 0) |
+ ((modifiers & Common::KBD_SHIFT) ? SCI_KEYMOD_LSHIFT | SCI_KEYMOD_RSHIFT : 0);
+
+ // Caps lock and Scroll lock have been removed, cause we already handle upper
+ // case keys ad Scroll lock doesn't seem to be used anywhere
+ //((ev.kbd.flags & Common::KBD_CAPS) ? SCI_KEYMOD_CAPSLOCK : 0) |
+ //((ev.kbd.flags & Common::KBD_SCRL) ? SCI_KEYMOD_SCRLOCK : 0) |
+
+ if (!(input.data & 0xFF00)) {
+ // Directly accept most common keys without conversion
+ if ((input.character >= 0x80) && (input.character <= 0xFF)) {
+ // If there is no extended font, we will just clear the
+ // current event.
+ // Sierra SCI actually accepted those characters, but
+ // didn't display them inside text edit controls because
+ // the characters were missing inside the font(s).
+ // We filter them out for non-multilingual games because
+ // of that.
+ if (!_fontIsExtended)
+ return noEvent;
+ // Convert 8859-1 characters to DOS (cp850/437) for
+ // multilingual SCI01 games
+ input.character = codepagemap_88591toDOS[input.character & 0x7f];
+ }
+ if (input.data == Common::KEYCODE_TAB) {
+ input.character = input.data = SCI_KEY_TAB;
+ if (modifiers & Common::KBD_SHIFT)
+ input.character = SCI_KEY_SHIFT_TAB;
+ }
+ if (input.data == Common::KEYCODE_DELETE)
+ input.data = input.character = SCI_KEY_DELETE;
+ } else if ((input.data >= Common::KEYCODE_F1) && input.data <= Common::KEYCODE_F10) {
+ // SCI_K_F1 == 59 << 8
+ // SCI_K_SHIFT_F1 == 84 << 8
+ input.character = input.data = SCI_KEY_F1 + ((input.data - Common::KEYCODE_F1)<<8);
+ if (modifiers & Common::KBD_SHIFT)
+ input.character = input.data + 0x1900;
+ } else {
+ // Special keys that need conversion
+ for (int i = 0; i < ARRAYSIZE(keyMappings); i++) {
+ if (keyMappings[i].scummVMKey == ev.kbd.keycode) {
+ input.character = input.data = numlockOn ? keyMappings[i].sciKeyNumlockOn : keyMappings[i].sciKeyNumlockOff;
+ break;
+ }
}
}
+
+ // When Ctrl AND Alt are pressed together with a regular key, Linux will give us control-key, Windows will give
+ // us the actual key. My opinion is that windows is right, because under DOS the keys worked the same, anyway
+ // we support the other case as well
+ if ((modifiers & Common::KBD_SHIFT) && input.character < 27)
+ input.character += 96; // 0x01 -> 'a'
+
+ if (getSciVersion() <= SCI_VERSION_1_MIDDLE) {
+ // TODO: find out if altify is also not needed for sci1late+, couldnt find any game that uses those keys
+ // Scancodify if appropriate
+ if (modifiers & Common::KBD_ALT)
+ input.character = altify(input.character);
+ else if ((modifiers & Common::KBD_CTRL) && input.character > 0 && input.character < 27)
+ input.character += 96; // 0x01 -> 'a'
+ }
+ // If no actual key was pressed (e.g. if only a modifier key was pressed),
+ // ignore the event
+ if (!input.character)
+ return noEvent;
+
return input;
}
@@ -282,8 +286,7 @@ void EventManager::updateScreen() {
}
SciEvent EventManager::getSciEvent(unsigned int mask) {
- //sci_event_t error_event = { SCI_EVT_ERROR, 0, 0, 0 };
- SciEvent event = { 0, 0, 0, 0 };
+ SciEvent event = { 0, 0, 0, 0, Common::Point(0, 0) };
EventManager::updateScreen();
@@ -304,9 +307,8 @@ SciEvent EventManager::getSciEvent(unsigned int mask) {
event = *iter;
// If not peeking at the queue, remove the event
- if (!(mask & SCI_EVENT_PEEK)) {
+ if (!(mask & SCI_EVENT_PEEK))
_events.erase(iter);
- }
} else {
// No event found: we must return a SCI_EVT_NONE event.
@@ -314,29 +316,6 @@ SciEvent EventManager::getSciEvent(unsigned int mask) {
// there is no need to change it.
}
- if (event.type == SCI_EVENT_KEYBOARD) {
- // Do we still have to translate the key?
-
- // When Ctrl AND Alt are pressed together with a regular key, Linux will give us control-key, Windows will give
- // us the actual key. My opinion is that windows is right, because under DOS the keys worked the same, anyway
- // we support the other case as well
- if (event.modifiers & SCI_KEYMOD_ALT) {
- if (event.character < 27)
- event.character += 96; // 0x01 -> 'a'
- }
-
- if (getSciVersion() <= SCI_VERSION_1_MIDDLE) {
- // TODO: find out if altify is also not needed for sci1late+, couldnt find any game that uses those keys
- // Scancodify if appropriate
- if (event.modifiers & SCI_KEYMOD_ALT) {
- event.character = altify(event.character);
- } else if (event.modifiers & SCI_KEYMOD_CTRL) {
- if (event.character < 27)
- event.character += 96; // 0x01 -> 'a'
- }
- }
- }
-
return event;
}
diff --git a/engines/sci/event.h b/engines/sci/event.h
index 7c83476294..be0322f2a4 100644
--- a/engines/sci/event.h
+++ b/engines/sci/event.h
@@ -27,6 +27,7 @@
#define SCI_EVENT_H
#include "common/list.h"
+#include "common/rect.h"
namespace Sci {
@@ -46,6 +47,13 @@ struct SciEvent {
* PC keyboard scancodes.
*/
short character;
+
+ /**
+ * The mouse position at the time the event was created.
+ *
+ * These are display coordinates!
+ */
+ Common::Point mousePos;
};
/*Values for type*/
@@ -56,11 +64,8 @@ struct SciEvent {
#define SCI_EVENT_DIRECTION (1<<6)
#define SCI_EVENT_SAID (1<<7)
/*Fake values for other events*/
-#define SCI_EVENT_ERROR (1<<10)
#define SCI_EVENT_QUIT (1<<11)
#define SCI_EVENT_PEEK (1<<15)
-/* The QUIT event may be used to signal an external 'quit' command being
-** issued to the gfx driver. */
#define SCI_EVENT_ANY 0x7fff
/* Keycodes of special keys: */
@@ -121,7 +126,6 @@ private:
SciEvent getScummVMEvent();
const bool _fontIsExtended;
- int _modifierStates;
Common::List<SciEvent> _events;
};
diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp
index b2e564c288..b0d12038e8 100644
--- a/engines/sci/graphics/menu.cpp
+++ b/engines/sci/graphics/menu.cpp
@@ -399,7 +399,6 @@ void GfxMenu::calculateMenuAndItemWidth() {
reg_t GfxMenu::kernelSelect(reg_t eventObject, bool pauseSound) {
int16 eventType = readSelectorValue(_segMan, eventObject, SELECTOR(type));
int16 keyPress, keyModifier;
- Common::Point mousePosition;
GuiMenuItemList::iterator itemIterator = _itemList.begin();
GuiMenuItemList::iterator itemEnd = _itemList.end();
GuiMenuItemEntry *itemEntry = NULL;
@@ -457,15 +456,17 @@ reg_t GfxMenu::kernelSelect(reg_t eventObject, bool pauseSound) {
itemEntry = NULL;
break;
- case SCI_EVENT_MOUSE_PRESS:
- mousePosition = _cursor->getPosition();
+ case SCI_EVENT_MOUSE_PRESS: {
+ Common::Point mousePosition;
+ mousePosition.x = readSelectorValue(_segMan, eventObject, SELECTOR(x));
+ mousePosition.y = readSelectorValue(_segMan, eventObject, SELECTOR(y));
if (mousePosition.y < 10) {
interactiveStart(pauseSound);
itemEntry = interactiveWithMouse();
interactiveEnd(pauseSound);
forceClaimed = true;
}
- break;
+ } break;
}
if (!_menuSaveHandle.isNull()) {
@@ -715,7 +716,6 @@ GuiMenuItemEntry *GfxMenu::interactiveWithKeyboard() {
uint16 newItemId = _curItemId;
GuiMenuItemEntry *curItemEntry = findItem(_curMenuId, _curItemId);
GuiMenuItemEntry *newItemEntry = curItemEntry;
- Common::Point mousePosition;
// We don't 100% follow Sierra here: we select last item instead of
// selecting first item of first menu every time. Also sierra sci didn't
@@ -793,9 +793,9 @@ GuiMenuItemEntry *GfxMenu::interactiveWithKeyboard() {
}
break;
- case SCI_EVENT_MOUSE_PRESS:
- mousePosition = _cursor->getPosition();
- if (_cursor->getPosition().y < 10) {
+ case SCI_EVENT_MOUSE_PRESS: {
+ Common::Point mousePosition = curEvent.mousePos;
+ if (mousePosition.y < 10) {
// Somewhere on the menubar
newMenuId = mouseFindMenuSelection(mousePosition);
if (newMenuId) {
@@ -824,7 +824,8 @@ GuiMenuItemEntry *GfxMenu::interactiveWithKeyboard() {
}
newItemId = curItemEntry->id;
}
- break;
+ } break;
+
case SCI_EVENT_NONE:
g_sci->sleep(2500 / 1000);
break;
@@ -840,7 +841,6 @@ GuiMenuItemEntry *GfxMenu::interactiveWithMouse() {
SciEvent curEvent;
uint16 newMenuId = 0, newItemId = 0;
uint16 curMenuId = 0, curItemId = 0;
- Common::Point mousePosition = _cursor->getPosition();
bool firstMenuChange = true;
GuiMenuItemEntry *curItemEntry = NULL;
@@ -871,7 +871,7 @@ GuiMenuItemEntry *GfxMenu::interactiveWithMouse() {
}
// Find out where mouse is currently pointing to
- mousePosition = _cursor->getPosition();
+ Common::Point mousePosition = curEvent.mousePos;
if (mousePosition.y < 10) {
// Somewhere on the menubar
newMenuId = mouseFindMenuSelection(mousePosition);
diff --git a/engines/sci/graphics/view.cpp b/engines/sci/graphics/view.cpp
index fd74714495..b99861319a 100644
--- a/engines/sci/graphics/view.cpp
+++ b/engines/sci/graphics/view.cpp
@@ -375,116 +375,138 @@ void unpackCelData(byte *inBuffer, byte *celBitmap, byte clearColor, int pixelCo
byte *outPtr = celBitmap;
byte curByte, runLength;
byte *rlePtr = inBuffer + rlePos;
+ // The existence of a literal position pointer signifies data with two
+ // separate streams, most likely a SCI1.1 view
byte *literalPtr = inBuffer + literalPos;
int pixelNr = 0;
memset(celBitmap, clearColor, pixelCount);
- if (!literalPos) {
- // decompression for data that has only one combined stream
- switch (viewType) {
- case kViewEga:
- while (pixelNr < pixelCount) {
- curByte = *rlePtr++;
- runLength = curByte >> 4;
- memset(outPtr + pixelNr, curByte & 0x0F, MIN<uint16>(runLength, pixelCount - pixelNr));
- pixelNr += runLength;
+ // View unpacking:
+ //
+ // EGA:
+ // Each byte is like XXXXYYYY (XXXX: 0 - 15, YYYY: 0 - 15)
+ // Set the next XXXX pixels to YYYY
+ //
+ // Amiga:
+ // Each byte is like XXXXXYYY (XXXXX: 0 - 31, YYY: 0 - 7)
+ // - Case A: YYY != 0
+ // Set the next YYY pixels to XXXXX
+ // - Case B: YYY == 0
+ // Skip the next XXXXX pixels (i.e. transparency)
+ //
+ // Amiga 64:
+ // Each byte is like XXYYYYYY (XX: 0 - 3, YYYYYY: 0 - 63)
+ // - Case A: XX != 0
+ // Set the next XX pixels to YYYYYY
+ // - Case B: XX == 0
+ // Skip the next YYYYYY pixels (i.e. transparency)
+ //
+ // VGA:
+ // Each byte is like XXYYYYYY (YYYYY: 0 - 63)
+ // - Case A: XX == 00 (binary)
+ // Copy next YYYYYY bytes as-is
+ // - Case B: XX == 01 (binary)
+ // Same as above, copy YYYYYY + 64 bytes as-is
+ // - Case C: XX == 10 (binary)
+ // Set the next YYYYY pixels to the next byte value
+ // - Case D: XX == 11 (binary)
+ // Skip the next YYYYY pixels (i.e. transparency)
+
+ if (literalPos && isMacSci11ViewData) {
+ // KQ6/Freddy Pharkas use byte lengths, all others use uint16
+ // The SCI devs must have realized that a max of 255 pixels wide
+ // was not very good for 320 or 640 width games.
+ bool hasByteLengths = (g_sci->getGameId() == GID_KQ6 || g_sci->getGameId() == GID_FREDDYPHARKAS);
+
+ // compression for SCI1.1+ Mac
+ while (pixelNr < pixelCount) {
+ uint32 pixelLine = pixelNr;
+
+ if (hasByteLengths) {
+ pixelNr += *rlePtr++;
+ runLength = *rlePtr++;
+ } else {
+ pixelNr += READ_BE_UINT16(rlePtr);
+ runLength = READ_BE_UINT16(rlePtr + 2);
+ rlePtr += 4;
}
- break;
- case kViewAmiga:
- while (pixelNr < pixelCount) {
- curByte = *rlePtr++;
- if (curByte & 0x07) { // fill with color
- runLength = curByte & 0x07;
- curByte = curByte >> 3;
- while (runLength-- && pixelNr < pixelCount)
- outPtr[pixelNr++] = curByte;
- } else { // fill with transparent
- runLength = curByte >> 3;
- pixelNr += runLength;
- }
+
+ while (runLength-- && pixelNr < pixelCount)
+ outPtr[pixelNr++] = *literalPtr++;
+
+ pixelNr = pixelLine + width;
+ }
+ return;
+ }
+
+ switch (viewType) {
+ case kViewEga:
+ while (pixelNr < pixelCount) {
+ curByte = *rlePtr++;
+ runLength = curByte >> 4;
+ memset(outPtr + pixelNr, curByte & 0x0F, MIN<uint16>(runLength, pixelCount - pixelNr));
+ pixelNr += runLength;
+ }
+ break;
+ case kViewAmiga:
+ while (pixelNr < pixelCount) {
+ curByte = *rlePtr++;
+ if (curByte & 0x07) { // fill with color
+ runLength = curByte & 0x07;
+ curByte = curByte >> 3;
+ memset(outPtr + pixelNr, curByte, MIN<uint16>(runLength, pixelCount - pixelNr));
+ } else { // skip the next pixels (transparency)
+ runLength = curByte >> 3;
}
- break;
- case kViewAmiga64:
- // TODO: This isn't 100% right. Implement it fully.
- while (pixelNr < pixelCount) {
- curByte = *rlePtr++;
+ pixelNr += runLength;
+ }
+ break;
+ case kViewAmiga64:
+ while (pixelNr < pixelCount) {
+ curByte = *rlePtr++;
+ if (curByte & 0xC0) { // fill with color
runLength = curByte >> 6;
- memset(outPtr + pixelNr, curByte & 0x3F, MIN<uint16>(runLength, pixelCount - pixelNr));
- pixelNr += runLength;
- }
- break;
- case kViewVga:
- case kViewVga11:
- while (pixelNr < pixelCount) {
- curByte = *rlePtr++;
+ memset(outPtr + pixelNr, curByte & 0x3F, MIN<uint16>(runLength, pixelCount - pixelNr));
+ } else { // skip the next pixels (transparency)
runLength = curByte & 0x3F;
- switch (curByte & 0xC0) {
- case 0: // copy bytes as-is
- while (runLength-- && pixelNr < pixelCount)
- outPtr[pixelNr++] = *rlePtr++;
- break;
- case 0x40: // copy bytes as is (In copy case, runLength can go upto 127 i.e. pixel & 0x40). Fixes bug #3135872.
- runLength += 64;
- break;
- case 0x80: // fill with color
- memset(outPtr + pixelNr, *rlePtr++, MIN<uint16>(runLength, pixelCount - pixelNr));
- pixelNr += runLength;
- break;
- case 0xC0: // fill with transparent
- pixelNr += runLength;
- break;
- }
}
- break;
- default:
- error("Unsupported picture viewtype");
+ pixelNr += runLength;
}
- } else {
- // decompression for data that has two separate streams (probably a SCI 1.1 view)
- if (isMacSci11ViewData) {
- // KQ6/Freddy Pharkas use byte lengths, all others use uint16
- // The SCI devs must have realized that a max of 255 pixels wide
- // was not very good for 320 or 640 width games.
- bool hasByteLengths = (g_sci->getGameId() == GID_KQ6 || g_sci->getGameId() == GID_FREDDYPHARKAS);
-
- // compression for SCI1.1+ Mac
- while (pixelNr < pixelCount) {
- uint32 pixelLine = pixelNr;
-
- if (hasByteLengths) {
- pixelNr += *rlePtr++;
- runLength = *rlePtr++;
+ break;
+ case kViewVga:
+ case kViewVga11:
+ while (pixelNr < pixelCount) {
+ curByte = *rlePtr++;
+ runLength = curByte & 0x3F;
+
+ switch (curByte & 0xC0) {
+ case 0x40: // copy bytes as is (In copy case, runLength can go up to 127 i.e. pixel & 0x40). Fixes bug #3135872.
+ runLength += 64;
+ case 0x00: // copy bytes as-is
+ if (!literalPos) {
+ memcpy(outPtr + pixelNr, rlePtr, MIN<uint16>(runLength, pixelCount - pixelNr));
+ rlePtr += runLength;
} else {
- pixelNr += READ_BE_UINT16(rlePtr);
- runLength = READ_BE_UINT16(rlePtr + 2);
- rlePtr += 4;
- }
-
- while (runLength-- && pixelNr < pixelCount)
- outPtr[pixelNr++] = *literalPtr++;
-
- pixelNr = pixelLine + width;
- }
- } else {
- while (pixelNr < pixelCount) {
- curByte = *rlePtr++;
- runLength = curByte & 0x3F;
- switch (curByte & 0xC0) {
- case 0: // copy bytes as-is
- while (runLength-- && pixelNr < pixelCount)
- outPtr[pixelNr++] = *literalPtr++;
- break;
- case 0x80: // fill with color
+ memcpy(outPtr + pixelNr, literalPtr, MIN<uint16>(runLength, pixelCount - pixelNr));
+ literalPtr += runLength;
+ }
+ break;
+ case 0x80: // fill with color
+ if (!literalPos)
+ memset(outPtr + pixelNr, *rlePtr++, MIN<uint16>(runLength, pixelCount - pixelNr));
+ else
memset(outPtr + pixelNr, *literalPtr++, MIN<uint16>(runLength, pixelCount - pixelNr));
- pixelNr += runLength;
- break;
- case 0xC0: // fill with transparent
- pixelNr += runLength;
- break;
- }
+ break;
+ case 0xC0: // skip the next pixels (transparency)
+ break;
}
+
+ pixelNr += runLength;
}
+ break;
+ default:
+ error("Unsupported picture viewtype");
}
}