diff options
Diffstat (limited to 'backends')
105 files changed, 1417 insertions, 2635 deletions
diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp index 5243099fbe..572f796f76 100644 --- a/backends/fs/ds/ds-fs.cpp +++ b/backends/fs/ds/ds-fs.cpp @@ -19,7 +19,6 @@ #include "stdafx.h" #include "str.h" -#include "fs.h" #include "common/util.h" //#include <NDS/ARM9/console.h> //basic print funcionality #include "ds-fs.h" diff --git a/backends/fs/palmos/palmos-fs.cpp b/backends/fs/palmos/palmos-fs.cpp index 52fe741d26..af09d79a12 100644 --- a/backends/fs/palmos/palmos-fs.cpp +++ b/backends/fs/palmos/palmos-fs.cpp @@ -21,12 +21,12 @@ #if defined(PALMOS_MODE) +#include "PalmVersion.h" +#include "globals.h" + #include "common/stdafx.h" #include "backends/fs/abstract-fs.h" -#include <stdio.h> -#include <stdlib.h> - /** * Implementation of the ScummVM file system API based on PalmOS VFS API. * diff --git a/backends/fs/posix/posix-fs-factory.cpp b/backends/fs/posix/posix-fs-factory.cpp index bed3dc5f8f..2ec3c84ec4 100644 --- a/backends/fs/posix/posix-fs-factory.cpp +++ b/backends/fs/posix/posix-fs-factory.cpp @@ -1,8 +1,6 @@ #include "backends/fs/posix/posix-fs-factory.h" #include "backends/fs/posix/posix-fs.cpp" -DECLARE_SINGLETON(POSIXFilesystemFactory); - AbstractFilesystemNode *POSIXFilesystemFactory::makeRootFileNode() const { return new POSIXFilesystemNode(); } diff --git a/backends/midi/zodiac.cpp b/backends/midi/zodiac.cpp index e626db687e..fe6cf0f7e9 100644 --- a/backends/midi/zodiac.cpp +++ b/backends/midi/zodiac.cpp @@ -25,8 +25,7 @@ #ifndef DISABLE_TAPWAVE -#include "TwTraps.h" -#include "TwMidi.h" +#include <tapwave.h> class MidiDriver_Zodiac:public MidiDriver_MPU401 { @@ -110,12 +109,13 @@ void MidiDriver_Zodiac::send(uint32 b) { } void MidiDriver_Zodiac::sysEx(const byte *msg, uint16 length) { -FIXME: We may have to add the 0xF0 / 0xF7 frame here. -Or not -- maybe TwMidiSysEx doesn't expect it either. -But since I couldn't find any documentation on this API, -I'll leave it to the porter to decide that. -- Fingolfin + unsigned char buf[256]; + + buf[0] = 0xF0; + memcpy(buf + 1, msg, length); + buf[length + 1] = 0xF7; - TwMidiSysEx(_midiHandle, 0, (byte *)msg, length); + TwMidiSysEx(_midiHandle, 0, (byte *)buf, length + 2); } MidiDriver *MidiDriver_Zodiac_create() { diff --git a/backends/platform/PalmOS/Rsc/Resource.Frk/Starter.rsrc b/backends/platform/PalmOS/Rsc/Resource.Frk/Starter.rsrc Binary files differindex f7661a3121..856fc32edb 100644 --- a/backends/platform/PalmOS/Rsc/Resource.Frk/Starter.rsrc +++ b/backends/platform/PalmOS/Rsc/Resource.Frk/Starter.rsrc diff --git a/backends/platform/PalmOS/Rsc/StarterRsc.h b/backends/platform/PalmOS/Rsc/StarterRsc.h index 58a1f79ab0..99836d4a77 100644 --- a/backends/platform/PalmOS/Rsc/StarterRsc.h +++ b/backends/platform/PalmOS/Rsc/StarterRsc.h @@ -3,7 +3,7 @@ // Header generated by Constructor for Palm OS (R) 1.9.1 // -// Generated at 17:51:34 on dimanche 14 janvier 2007 +// Generated at 13:30:37 on mardi 1 mai 2007 // // Generated for file: Starter.rsrc // @@ -200,7 +200,9 @@ #define EngineOkButton 1403 //(Left Origin = 4, Top Origin = 139, Width = 36, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard) #define EngineCancelButton 1420 //(Left Origin = 45, Top Origin = 139, Width = 36, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard) #define EngineUnnamed1402Label 1402 //(Left Origin = 4, Top Origin = 16, Usable = 1, Font = Bold) -#define EngineListList 1401 //(Left Origin = 4, Top Origin = 30, Width = 148, Usable = 1, Font = Standard, Visible Items = 9) +#define EngineUnnamed1404Label 1404 //(Left Origin = 4, Top Origin = 88, Usable = 1, Font = Bold) +#define EngineListList 1401 //(Left Origin = 4, Top Origin = 30, Width = 148, Usable = 1, Font = Standard, Visible Items = 5) +#define EngineSupportedList 1405 //(Left Origin = 4, Top Origin = 102, Width = 148, Usable = 1, Font = Standard, Visible Items = 3) // Resource: tFRM 4000 #define InfoForm 4000 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0) diff --git a/backends/platform/PalmOS/Src/base_event.cpp b/backends/platform/PalmOS/Src/base_event.cpp index 7da7cd5861..1f7d07f4ae 100644 --- a/backends/platform/PalmOS/Src/base_event.cpp +++ b/backends/platform/PalmOS/Src/base_event.cpp @@ -81,7 +81,7 @@ void OSystem_PalmBase::battery_handler() { } } -bool OSystem_PalmBase::pollEvent(Event &event) { +bool OSystem_PalmBase::pollEvent(Common::Event &event) { ::EventType ev; Boolean handled; UInt32 keyCurrentState; @@ -92,52 +92,60 @@ bool OSystem_PalmBase::pollEvent(Event &event) { sound_handler(); for(;;) { -#if defined(COMPILE_OS5) && defined(PALMOS_ARM) - SysEventGet(&ev, evtNoWait); -#else - EvtGetEvent(&ev, evtNoWait); -#endif - // check for hardkey repeat for mouse emulation - keyCurrentState = KeyCurrentState(); - // check_hard_keys(); + // if it was a key pressed, let the keyup event raise + if (_wasKey) { + // check for hardkey repeat for mouse emulation + keyCurrentState = KeyCurrentState(); - if (!(keyCurrentState & _keyMouseMask)) { - _lastKeyRepeat = 0; - } else { - if (getMillis() >= (_keyMouseRepeat + _keyMouseDelay)) { - _keyMouseRepeat = getMillis(); + if (!(keyCurrentState & _keyExtraMask)) { + _lastKeyRepeat = 0; + + } else if (getMillis() >= (_keyExtraRepeat + _keyExtraDelay)) { + _keyExtraRepeat = getMillis(); if (gVars->arrowKeys) { - event.kbd.keycode = 0; - - if (keyCurrentState & _keyMouse.bitUp) - event.kbd.keycode = 273; - else if (keyCurrentState & _keyMouse.bitDown) - event.kbd.keycode = 274; - else if (keyCurrentState & _keyMouse.bitLeft) - event.kbd.keycode = 276; - else if (keyCurrentState & _keyMouse.bitRight) - event.kbd.keycode = 275; - - if (event.kbd.keycode) { - event.type = Common::EVENT_KEYDOWN; - event.kbd.ascii = event.kbd.keycode; - event.kbd.flags = 0; - return true; +/* if HARD_KEY(Up, chrUpArrow) + else if HARD_KEY(Down, chrDownArrow) + else if HARD_KEY(Left, chrLeftArrow) + else if HARD_KEY(Right, chrRightArrow) +*/ + } else { + // button released ? + if (_keyExtraPressed) { + if (_keyExtraPressed & _keyExtra.bitActionA) { + if (!(keyCurrentState & _keyExtra.bitActionA)) { + _keyExtraPressed &= ~_keyExtra.bitActionA; + + event.type = Common::EVENT_LBUTTONUP; + event.mouse.x = _mouseCurState.x; + event.mouse.y = _mouseCurState.y; + return true; + } + } + + if (_keyExtraPressed & _keyExtra.bitActionB) { + if (!(keyCurrentState & _keyExtra.bitActionB)) { + _keyExtraPressed &= ~_keyExtra.bitActionB; + + event.type = Common::EVENT_RBUTTONUP; + event.mouse.x = _mouseCurState.x; + event.mouse.y = _mouseCurState.y; + return true; + } + } } - } else { Int8 sx = 0; Int8 sy = 0; - if (keyCurrentState & _keyMouse.bitUp) + if (keyCurrentState & _keyExtra.bitUp) sy = -1; - else if (keyCurrentState & _keyMouse.bitDown) + else if (keyCurrentState & _keyExtra.bitDown) sy = +1; - if (keyCurrentState & _keyMouse.bitLeft) + if (keyCurrentState & _keyExtra.bitLeft) sx = -1; - else if (keyCurrentState & _keyMouse.bitRight) + else if (keyCurrentState & _keyExtra.bitRight) sx = +1; if (sx || sy) { @@ -148,12 +156,42 @@ bool OSystem_PalmBase::pollEvent(Event &event) { warpMouse(x, y); return true; - } + } } } } - if (ev.eType == keyDownEvent) { +#if defined(COMPILE_OS5) && defined(PALMOS_ARM) + SysEventGet(&ev, evtNoWait); +#else + EvtGetEvent(&ev, evtNoWait); +#endif + + if (ev.eType == keyUpEvent) { + int k = 0; + switch (ev.data.keyUp.chr) { + + // arrow keys + case chrUpArrow: + k = 273; break; + case chrDownArrow: + k = 274; break; + case chrLeftArrow: + k = 275; break; + case chrRightArrow: + k = 276; break; + } + + if (k) { + event.type = Common::EVENT_KEYUP; + event.kbd.keycode = k; + event.kbd.ascii = k; + event.kbd.flags = 0; + return true; + } + + } else if (ev.eType == keyDownEvent) { + int k = 0; switch (ev.data.keyDown.chr) { // ESC key case vchrLaunch: @@ -180,6 +218,24 @@ bool OSystem_PalmBase::pollEvent(Event &event) { case vchrContrast: // do nothing return true; + + // arrow keys + case chrUpArrow: + k = 273; break; + case chrDownArrow: + k = 274; break; + case chrLeftArrow: + k = 275; break; + case chrRightArrow: + k = 276; break; + } + + if (k) { + event.type = Common::EVENT_KEYDOWN; + event.kbd.keycode = k; + event.kbd.ascii = k; + event.kbd.flags = 0; + return true; } } @@ -192,11 +248,13 @@ bool OSystem_PalmBase::pollEvent(Event &event) { ((ev.data.keyDown.chr == vchrAttnStateChanged) || (ev.data.keyDown.chr == vchrAttnUnsnooze))); + // graffiti strokes, auto-off, etc... if (!handled) if (SysHandleEvent(&ev)) continue; + switch(ev.eType) { case penMoveEvent: get_coordinates(&ev, x, y); @@ -222,7 +280,7 @@ bool OSystem_PalmBase::pollEvent(Event &event) { num += 9 - (3 - (3 * x / _screenWidth )) - (3 * (3 * y / _screenHeight)); - + event.type = Common::EVENT_KEYDOWN; event.kbd.keycode = num; event.kbd.ascii = num; @@ -252,7 +310,7 @@ bool OSystem_PalmBase::pollEvent(Event &event) { event.mouse.y = y; warpMouse(x, y); return true; - + case keyDownEvent: if (ev.data.keyDown.chr == vchrCommand && (ev.data.keyDown.modifiers & commandKeyMask)) { @@ -302,7 +360,7 @@ bool OSystem_PalmBase::pollEvent(Event &event) { } else if ((key == 'z' && mask == Common::KBD_CTRL) || (mask == Common::KBD_ALT && key == 'x')) { event.type = Common::EVENT_QUIT; return true; - + // num pad (indy fight mode) } else if (key == 'n' && mask == (Common::KBD_CTRL|Common::KBD_ALT) && !_overlayVisible) { _useNumPad = !_useNumPad; @@ -310,7 +368,7 @@ bool OSystem_PalmBase::pollEvent(Event &event) { displayMessageOnOSD(_useNumPad ? "Fight mode on." : "Fight mode off."); return false; } - + // other keys _wasKey = true; event.type = Common::EVENT_KEYDOWN; @@ -320,7 +378,7 @@ bool OSystem_PalmBase::pollEvent(Event &event) { return true; default: - if (_wasKey) { + if (_wasKey && ev.eType != keyHoldEvent) { event.type = Common::EVENT_KEYUP; _wasKey = false; return true; diff --git a/backends/platform/PalmOS/Src/base_mouse.cpp b/backends/platform/PalmOS/Src/base_mouse.cpp index 2f3d3f5476..99b89b7f8c 100644 --- a/backends/platform/PalmOS/Src/base_mouse.cpp +++ b/backends/platform/PalmOS/Src/base_mouse.cpp @@ -26,22 +26,53 @@ void OSystem_PalmBase::warpMouse(int x, int y) { if (x != _mouseCurState.x || y != _mouseCurState.y) { + x = x >= _screenWidth ? _screenWidth - 1 : x; + y = y >= _screenHeight ? _screenHeight - 1 : y; + _mouseCurState.x = x; _mouseCurState.y = y; - undraw_mouse(); } } bool OSystem_PalmBase::showMouse(bool visible) { - if (_mouseVisible == visible) - return visible; - bool last = _mouseVisible; _mouseVisible = visible; return last; } +void OSystem_PalmBase::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) { + if (w == 0 || h == 0) + return; + + _mouseHotspotX = hotspotX; + _mouseHotspotY = hotspotY; + + _mouseKeyColor = keycolor; + + if (_mouseCurState.w != w || _mouseCurState.h != h) { + _mouseCurState.w = w; + _mouseCurState.h = h; + + if (_mouseDataP) + free(_mouseDataP); + + if (_mouseBackupP) + free(_mouseBackupP); + + _mouseDataP = (byte *)malloc(w * h); + _mouseBackupP = (byte *)malloc(w * h * 2); // if 16bit = *2 + } + + if (!_mouseBackupP) { + free(_mouseDataP); + _mouseDataP = NULL; + } + + if (_mouseDataP) + memcpy(_mouseDataP, buf, w * h); +} + void OSystem_PalmBase::simulate_mouse(Common::Event &event, Int8 iHoriz, Int8 iVert, Coord *xr, Coord *yr) { Int16 x = _mouseCurState.x; Int16 y = _mouseCurState.y; diff --git a/backends/platform/PalmOS/Src/be_base.cpp b/backends/platform/PalmOS/Src/be_base.cpp index 8776376ee5..705a2597fd 100644 --- a/backends/platform/PalmOS/Src/be_base.cpp +++ b/backends/platform/PalmOS/Src/be_base.cpp @@ -1,7 +1,7 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend + * Copyright (C) 2001-2007 The ScummVM project + * Copyright (C) 2002-2007 Chris Apers - PalmOS Backend * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -64,16 +64,18 @@ OSystem_PalmBase::OSystem_PalmBase() { _mixerMgr = 0; _mouseDataP = NULL; + _mouseBackupP = NULL; _mouseVisible = false; _mouseDrawn = false; - MemSet(&_keyMouse, sizeof(_keyMouse), 0); + MemSet(&_keyExtra, sizeof(_keyExtra), 0); MemSet(&_mouseCurState, sizeof(_mouseCurState), 0); MemSet(&_mouseOldState, sizeof(_mouseOldState), 0); MemSet(&_timer, sizeof(TimerType), 0); MemSet(&_sound, sizeof(SoundType), 0); - _keyMouseRepeat = 0; - _keyMouseDelay = (gVars->arrowKeys) ? computeMsecs(125) : computeMsecs(25); + _keyExtraRepeat = 0; + _keyExtraPressed = 0; + _keyExtraDelay = (gVars->arrowKeys) ? computeMsecs(125) : computeMsecs(25); } static int timer_handler(int t) { @@ -86,13 +88,13 @@ void OSystem_PalmBase::initBackend() { if (gVars->autoSave != -1) ConfMan.setInt("autosave_period", gVars->autoSave); - _keyMouse.bitUp = keyBitPageUp; - _keyMouse.bitDown = keyBitPageDown; - _keyMouse.bitLeft = keyBitHard2; - _keyMouse.bitRight = keyBitHard3; + _keyExtra.bitUp = keyBitPageUp; + _keyExtra.bitDown = keyBitPageDown; + _keyExtra.bitLeft = keyBitHard2; + _keyExtra.bitRight = keyBitHard3; int_initBackend(); - _keyMouseMask = (_keyMouse.bitUp | _keyMouse.bitDown | _keyMouse.bitLeft | _keyMouse.bitRight); + _keyExtraMask = (_keyExtra.bitUp | _keyExtra.bitDown | _keyExtra.bitLeft | _keyExtra.bitRight | _keyExtra.bitActionA | _keyExtra.bitActionB); // Create the savefile manager, if none exists yet (we check for this to // allow subclasses to provide their own). @@ -143,7 +145,12 @@ void OSystem_PalmBase::quit() { int_quit(); clearSoundCallback(); unload_gfx_mode(); - + + if (_mouseDataP) { + MemPtrFree(_mouseBackupP); + MemPtrFree(_mouseDataP); + } + delete _saveMgr; delete _timerMgr; delete _mixerMgr; diff --git a/backends/platform/PalmOS/Src/be_base.h b/backends/platform/PalmOS/Src/be_base.h index cd4c38980e..65ed93d9a5 100644 --- a/backends/platform/PalmOS/Src/be_base.h +++ b/backends/platform/PalmOS/Src/be_base.h @@ -25,9 +25,13 @@ #ifndef BE_BASE_H #define BE_BASE_H +#include "PalmVersion.h" +#include "globals.h" + #include "common/stdafx.h" #include "common/scummsys.h" #include "common/system.h" +#include "common/events.h" namespace Audio { class Mixer; @@ -52,6 +56,12 @@ enum { kModifierCount }; +// Mouse button event +enum { + vchrMouseLeft = vchrHardKeyMax - 2, + vchrMouseRight = vchrHardKeyMax - 1 +}; + // OSD resource id #define kDrawKeyState 3000 #define kDrawNumPad 3010 @@ -94,7 +104,6 @@ private: virtual void draw_mouse() = 0; virtual void undraw_mouse() = 0; -// virtual bool check_hard_keys() = 0; virtual bool check_event(Common::Event &event, EventPtr ev) = 0; virtual void timer_handler(); @@ -107,12 +116,10 @@ private: virtual void clearSoundCallback() = 0; protected: + OSystem_PalmBase(); + virtual void draw_osd(UInt16 id, Int32 x, Int32 y, Boolean show, UInt8 color = 0); - enum { - MAX_MOUSE_W = 80, - MAX_MOUSE_H = 80 - }; struct MousePos { int16 x,y,w,h; }; @@ -145,13 +152,15 @@ protected: Boolean _overlayVisible; Boolean _redawOSD, _setPalette; - UInt32 _keyMouseMask, _keyMouseRepeat, _keyMouseDelay; + UInt32 _keyExtraMask, _keyExtraPressed, _keyExtraRepeat, _keyExtraDelay; struct { UInt32 bitUp; UInt32 bitDown; UInt32 bitLeft; UInt32 bitRight; - } _keyMouse; + UInt32 bitActionA; // left mouse button + UInt32 bitActionB; // right mouse button + } _keyExtra; bool _mouseVisible; bool _mouseDrawn; @@ -163,7 +172,7 @@ protected: byte *_mouseDataP, *_mouseBackupP; - eventsEnum _wasKey; + bool _wasKey; UInt8 _lastKeyModifier; UInt32 _lastKeyRepeat; Boolean _useNumPad, _showBatLow; @@ -172,7 +181,6 @@ protected: int _samplesPerSec; public: - OSystem_PalmBase(); void initBackend(); /* @@ -216,7 +224,7 @@ public: bool showMouse(bool visible); void warpMouse(int x, int y); - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) = 0; + void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale); virtual void showOverlay() = 0; virtual void hideOverlay() = 0; diff --git a/backends/platform/PalmOS/Src/be_os5.cpp b/backends/platform/PalmOS/Src/be_os5.cpp index 74551607b7..d3e1d3578f 100644 --- a/backends/platform/PalmOS/Src/be_os5.cpp +++ b/backends/platform/PalmOS/Src/be_os5.cpp @@ -23,11 +23,7 @@ */ #include "be_os5.h" - -#ifndef __TWKEYS_H__ -#include <PalmNavigator.h> #include <HsKeyCommon.h> -#endif OSystem_PalmOS5::OSystem_PalmOS5() : OSystem_PalmBase() { _sound.active = false; @@ -78,18 +74,12 @@ void OSystem_PalmOS5::calc_rect(Boolean fullscreen) { } void OSystem_PalmOS5::int_initBackend() { - if (OPTIONS_TST(kOpt5WayNavigatorV1)) { - _keyMouse.bitUp = keyBitPageUp; - _keyMouse.bitDown = keyBitPageDown; - _keyMouse.bitLeft = keyBitNavLeft; - _keyMouse.bitRight = keyBitNavRight; - - } else if (OPTIONS_TST(kOpt5WayNavigatorV2)) { - _keyMouse.bitUp = keyBitRockerUp|keyBitPageUp; - _keyMouse.bitDown = keyBitRockerDown|keyBitPageDown; - _keyMouse.bitLeft = keyBitRockerLeft; - _keyMouse.bitRight = keyBitRockerRight; - } + _keyExtra.bitUp = keyBitRockerUp|keyBitPageUp; + _keyExtra.bitDown = keyBitRockerDown|keyBitPageDown; + _keyExtra.bitLeft = keyBitRockerLeft; + _keyExtra.bitRight = keyBitRockerRight; + _keyExtra.bitActionA = keyBitHard3; + _keyExtra.bitActionB = keyBitHard4; } bool OSystem_PalmOS5::hasFeature(Feature f) { diff --git a/backends/platform/PalmOS/Src/be_os5.h b/backends/platform/PalmOS/Src/be_os5.h index e6c4227e71..b4b68bc920 100644 --- a/backends/platform/PalmOS/Src/be_os5.h +++ b/backends/platform/PalmOS/Src/be_os5.h @@ -99,6 +99,9 @@ typedef struct { extern SoundExType _soundEx; class OSystem_PalmOS5 : public OSystem_PalmBase { +protected: + int16 _nativePal[256], _mousePal[256]; + private: uint16 _scaleTableX[512]; uint32 _scaleTableY[512]; @@ -108,7 +111,6 @@ private: OverlayColor *_overlayP; WinHandle _overlayH, _workScreenH; - int16 _nativePal[256], _mousePal[256]; int16 *_workScreenP; Boolean _isSwitchable, _wasRotated; @@ -124,7 +126,7 @@ private: void draw_mouse(); void undraw_mouse(); virtual bool check_event(Common::Event &event, EventPtr ev); - virtual void extras_palette(uint8 index, uint8 r, uint8 g, uint8 b); + void extras_palette(uint8 index, uint8 r, uint8 g, uint8 b); void calc_scale(); void render_landscapeAny(RectangleType &r, PointType &p); @@ -168,8 +170,7 @@ public: void clearScreen(); bool grabRawScreen(Graphics::Surface *surf); - void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale); - virtual void setCursorPalette(const byte *colors, uint start, uint num); + void setCursorPalette(const byte *colors, uint start, uint num); void disableCursorPalette(bool disable); void showOverlay(); @@ -179,7 +180,7 @@ public: virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); - + void setWindowCaption(const char *caption); }; diff --git a/backends/platform/PalmOS/Src/be_os5ex.cpp b/backends/platform/PalmOS/Src/be_os5ex.cpp index f6f95ac06e..c498568ab3 100644 --- a/backends/platform/PalmOS/Src/be_os5ex.cpp +++ b/backends/platform/PalmOS/Src/be_os5ex.cpp @@ -38,7 +38,7 @@ OSystem_PalmOS5Ex::OSystem_PalmOS5Ex() : OSystem_PalmOS5() { _timerEx.timer = &_timer; _timerEx.ticks = SysTicksPerSecond(); } -/* + static SYSTEM_CALLBACK void timer_handler(void *userDataP) { CALLBACK_PROLOGUE TimerExPtr _timerEx = (TimerExPtr)userDataP; @@ -73,7 +73,7 @@ void OSystem_PalmOS5Ex::setTimerCallback(TimerProc callback, int timer) { if (!_timer.active) _timerEx.timerID = 0; } -*/ + OSystem::MutexRef OSystem_PalmOS5Ex::createMutex() { UInt32 mutexID; Err e = KALMutexCreate(&mutexID, appFileCreator); @@ -95,9 +95,8 @@ void OSystem_PalmOS5Ex::deleteMutex(MutexRef mutex) { if (mutex) KALMutexDelete((UInt32)mutex); } -/* + void OSystem_PalmOS5Ex::int_quit() { if (_timerEx.timerID) KALTimerDelete(_timerEx.timerID); } -*/
\ No newline at end of file diff --git a/backends/platform/PalmOS/Src/be_os5ex.h b/backends/platform/PalmOS/Src/be_os5ex.h index fb4027ccce..7d8cf4b607 100644 --- a/backends/platform/PalmOS/Src/be_os5ex.h +++ b/backends/platform/PalmOS/Src/be_os5ex.h @@ -45,9 +45,9 @@ typedef struct { class OSystem_PalmOS5Ex : public OSystem_PalmOS5 { private: -// void timer_handler() {}; - void sound_handler() {}; -// void int_quit(); + void timer_handler() {} + void sound_handler() {} + void int_quit(); SndStreamVariableBufferCallback sound_callback(); @@ -55,7 +55,7 @@ public: OSystem_PalmOS5Ex(); static OSystem *create(); -// void setTimerCallback(TimerProc callback, int interval); + void setTimerCallback(TimerProc callback, int interval); MutexRef createMutex(); void lockMutex(MutexRef mutex); diff --git a/backends/platform/PalmOS/Src/be_zodiac.cpp b/backends/platform/PalmOS/Src/be_zodiac.cpp index ce4dfa6013..76e3ed8562 100644 --- a/backends/platform/PalmOS/Src/be_zodiac.cpp +++ b/backends/platform/PalmOS/Src/be_zodiac.cpp @@ -33,10 +33,13 @@ OSystem_PalmZodiac::OSystem_PalmZodiac() : OSystem_PalmOS5Ex() { } void OSystem_PalmZodiac::int_initBackend() { - _keyMouse.bitUp = keyBitRockerUp; - _keyMouse.bitDown = keyBitRockerDown; - _keyMouse.bitLeft = keyBitRockerLeft; - _keyMouse.bitRight = keyBitRockerRight; + _keyExtra.bitUp = keyBitRockerUp; + _keyExtra.bitDown = keyBitRockerDown; + _keyExtra.bitLeft = keyBitRockerLeft; + _keyExtra.bitRight = keyBitRockerRight; + +// _keyExtra.bitActionA = keyBitActionD; +// _keyExtra.bitActionB = keyBitActionB; } void OSystem_PalmZodiac::calc_rect(Boolean fullscreen) { diff --git a/backends/platform/PalmOS/Src/be_zodiac.h b/backends/platform/PalmOS/Src/be_zodiac.h index 1d28afa493..c93004c89a 100644 --- a/backends/platform/PalmOS/Src/be_zodiac.h +++ b/backends/platform/PalmOS/Src/be_zodiac.h @@ -36,7 +36,6 @@ private: TwGfxType *_gfxH; TwGfxSurfaceType *_palmScreenP, *_tmpScreenP; TwGfxSurfaceType *_overlayP; - UInt16 _nativePal[256], _mousePal[256]; Boolean _fullscreen; TwGfxPointType _srcPos; @@ -53,7 +52,6 @@ private: void load_gfx_mode(); void hotswap_gfx_mode(int mode); - void extras_palette(uint8 index, uint8 r, uint8 g, uint8 b); void calc_rect(Boolean fullscreen); bool check_event(Common::Event &event, EventPtr ev); void draw_osd(UInt16 id, Int32 x, Int32 y, Boolean show, UInt8 color = 0); @@ -69,8 +67,6 @@ public: void updateScreen(); - void setCursorPalette(const byte *colors, uint start, uint num); - void clearOverlay(); void grabOverlay(OverlayColor *buf, int pitch); void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); diff --git a/backends/platform/PalmOS/Src/cdaudio.h b/backends/platform/PalmOS/Src/cdaudio.h index 1c1d42e7e9..206f6087c5 100644 --- a/backends/platform/PalmOS/Src/cdaudio.h +++ b/backends/platform/PalmOS/Src/cdaudio.h @@ -54,8 +54,8 @@ public: virtual void setVolume(int volume) { _volumeLevel = volume; } virtual int getVolume() const { return _volumeLevel; } - virtual void upVolume(int value) {}; - virtual void downVolume(int value) {}; + virtual void upVolume(int value) {} + virtual void downVolume(int value) {} protected: int _volumeLevel; diff --git a/backends/platform/PalmOS/Src/extend.cpp b/backends/platform/PalmOS/Src/extend.cpp index f2b9bbcc0a..0d7f19d582 100644 --- a/backends/platform/PalmOS/Src/extend.cpp +++ b/backends/platform/PalmOS/Src/extend.cpp @@ -22,14 +22,15 @@ * */ +#include "PalmVersion.h" #include <stdlib.h> #include "globals.h" #include "modulesrsc.h" -const Char *SCUMMVM_SAVEPATH = "/PALM/Programs/ScummVM/Saved"; +const char *SCUMMVM_SAVEPATH = "/PALM/Programs/ScummVM/Saved"; -void PalmFatalError(const Char *err) { +void PalmFatalError(const char *err) { WinSetDrawWindow(WinGetDisplayWindow()); WinPalette(winPaletteSetToDefault,0,0,0); WinSetBackColor(0); diff --git a/backends/platform/PalmOS/Src/extend.h b/backends/platform/PalmOS/Src/extend.h deleted file mode 100644 index c5c74852a2..0000000000 --- a/backends/platform/PalmOS/Src/extend.h +++ /dev/null @@ -1,34 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef EXTEND_H -#define EXTEND_H - -extern const Char *SCUMMVM_SAVEPATH; - -int main(int argc, char **argv); -void PalmFatalError(const Char *err); -void DrawStatus(Boolean show); - -#endif diff --git a/backends/platform/PalmOS/Src/launcher/app.cpp b/backends/platform/PalmOS/Src/launcher/app.cpp index ea028e6b7f..3f57f77125 100644 --- a/backends/platform/PalmOS/Src/launcher/app.cpp +++ b/backends/platform/PalmOS/Src/launcher/app.cpp @@ -1,7 +1,7 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend + * Copyright (C) 2001-2007 The ScummVM project + * Copyright (C) 2002-2007 Chris Apers - PalmOS Backend * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,6 +24,7 @@ #include <PalmOS.h> #include <SonyClie.h> +#include <SysGlue.h> #include "StarterRsc.h" #include "palmdefs.h" @@ -34,7 +35,6 @@ #include "mathlib.h" #include "formCards.h" #include "games.h" -#include "extend.h" #include "modules.h" #include "init_mathlib.h" @@ -172,6 +172,7 @@ static void AppStartCheckScreenSize() { OPTIONS_RST(kOptCollapsible); OPTIONS_RST(kOptModeWide); OPTIONS_RST(kOptModeLandscape); + OPTIONS_RST(kOptModeRotatable); // we are on a sony device if (OPTIONS_TST(kOptDeviceClie)) { @@ -186,6 +187,8 @@ static void AppStartCheckScreenSize() { OPTIONS_SET(kOptCollapsible); OPTIONS_SET(kOptModeWide); OPTIONS_SET((mode == PALM_LANDSCAPE) ? kOptModeLandscape : kOptNone); + // TODO: doesn't work with Sony + OPTIONS_SET(SysGlueTrapExists(pinSysSetOrientation) ? kOptModeRotatable :kOptNone); } } diff --git a/backends/platform/PalmOS/Src/launcher/forms/formCards.cpp b/backends/platform/PalmOS/Src/launcher/forms/formCards.cpp index ccb3d09f8a..15772c6aab 100644 --- a/backends/platform/PalmOS/Src/launcher/forms/formCards.cpp +++ b/backends/platform/PalmOS/Src/launcher/forms/formCards.cpp @@ -364,6 +364,7 @@ void CardSlotCreateDirs() { VFSDirCreate(gPrefs->card.volRefNum, "/PALM/Programs/ScummVM/Saved"); VFSDirCreate(gPrefs->card.volRefNum, "/PALM/Programs/ScummVM/Audio"); VFSDirCreate(gPrefs->card.volRefNum, "/PALM/Programs/ScummVM/Mods"); + VFSDirCreate(gPrefs->card.volRefNum, "/PALM/Programs/ScummVM/Themes"); } } diff --git a/backends/platform/PalmOS/Src/launcher/forms/formMisc.cpp b/backends/platform/PalmOS/Src/launcher/forms/formMisc.cpp index 9b4009294c..28ff9c6747 100644 --- a/backends/platform/PalmOS/Src/launcher/forms/formMisc.cpp +++ b/backends/platform/PalmOS/Src/launcher/forms/formMisc.cpp @@ -190,12 +190,14 @@ static void MiscFormInit() { TabAddContent(&frmP, tabP, "ScummVM", TabMiscScummVMForm); TabAddContent(&frmP, tabP, "More ...", TabMiscExtsForm); + if (OPTIONS_TST(kOptDeviceARM)) { + FrmRemoveObject(&frmP, FrmGetObjectIndex(frmP, TabMiscPalmOSStdPaletteCheckbox)); + TabMoveUpObject(frmP, TabMiscPalmOSAdvancedCheckbox, 12); + } + if (!OPTIONS_TST(kOptDeviceARM) || OPTIONS_TST(kOptDeviceZodiac)) FrmRemoveObject(&frmP, FrmGetObjectIndex(frmP, TabMiscPalmOSAdvancedCheckbox)); - if (OPTIONS_TST(kOptDeviceARM)) - FrmRemoveObject(&frmP, FrmGetObjectIndex(frmP, TabMiscPalmOSStdPaletteCheckbox)); - if (!OPTIONS_TST(kOptGoLcdAPI)) { FrmRemoveObject(&frmP, FrmGetObjectIndex(frmP, TabMiscExtsGolcdCheckbox)); // move lightspeed diff --git a/backends/platform/PalmOS/Src/launcher/forms/formSelect.cpp b/backends/platform/PalmOS/Src/launcher/forms/formSelect.cpp new file mode 100755 index 0000000000..179723f18a --- /dev/null +++ b/backends/platform/PalmOS/Src/launcher/forms/formSelect.cpp @@ -0,0 +1,276 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001-2007 The ScummVM project + * Copyright (C) 2002-2007 Chris Apers - PalmOS Backend + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include <PalmOS.h> +#include "StarterRsc.h" +#include "formUtil.h" +#include "games.h" +#include "start.h" +#include "common/util.h" + +static Char **items = NULL; +Int16 selectedEngine = -1; + +// Supported games +static const char *engine_agos[] = { + "Demon in my Pocket", + "Elvira - Mistress of the Dark", + "Elvira II - The Jaws of Cerberus", + "Jumble", + "NoPatience", + "Simon the Sorcerer I", + "Simon the Sorcerer II", + "Swampy Adventures", + "The Feeble Files", + "Waxworks" +}; + +static const char *engine_sky[] = { + "Floppy, CD and Demo" +}; + +static const char *engine_sword1[] = { + "The Shadow of the Templars (PC/Mac)", + "The Shadow of the Templars (Demo)" +}; + +static const char *engine_sword2[] = { + "The Smoking Mirror", + "The Smoking Mirror (Demo)" +}; + +static const char *engine_cine[] = { + "Future Wars", + "Operation Stealth" +}; + +static const char *engine_queen[] = { + "Flight of the Amazon Queen" +}; + +static const char *engine_lure[] = { + "Lure of the Tempress" +}; + +static const char *engine_gob[] = { + "Bargon Attack", + "Gobliiins", + "Gobliins 2", + "Goblins Quest 3", + "The Bizarre Adventures of Woodruff and the Schnibble", + "Ween: The Prophecy", +}; + +static const char *engine_kyra[] = { + "The Legend of Kyrandia", + "The Legend of Kyrandia: The Hand of Fate", + "The Legend of Kyrandia: Malcolm's Revenge" +}; + +static const char *engine_parallaction[] = { + "Nippon Safes Inc." +}; + +static const char *engine_saga[] = { + "I Have No Mouth And I Must Scream", + "Inherit the earth" +}; + +static const char *engine_scumm[] = { + "Day of the Tentacle", + "Indiana Jones and the Fate of Atlantis", + "Indiana Jones and the Last Crusade", + "Loom", + "Maniac Mansion", + "Monkey Island 2: LeChuck's Revenge", + "Passport to Adventure", + "Sam & Max Hit the Road", + "The Secret of Monkey Island" + "Zak McKracken and the Alien Mindbenders" +}; + +static const char *engine_agi[] = { + "AGI Tetris", + "Caitlyn's Destiny", + "Donald Duck's Playground", + "Fanmade AGI game", + "Gold Rush!", + "King's Quest I: Quest for the Crown", + "King's Quest II: Romancing the Throne", + "King's Quest III: To Heir Is Human", + "King's Quest IV: The Perils of Rosella", + "Leisure Suit Larry in the Land of the Lounge Lizards", + "Mixed-Up Mother Goose", + "Manhunter 1: New York", + "Manhunter 2: San Francisco", + "Police Quest I: In Pursuit of the Death Angel", + "Serguei's Destiny 1", + "Serguei's Destiny 2", + "Space Quest 0: Replicated", + "Space Quest I: The Sarien Encounter", + "Space Quest II: Vohaul's Revenge", + "Space Quest X: The Lost Chapter", + "The Black Cauldron", + "Xmas Card" +}; + +static const char *engine_touche[] = { + "Touche: The Adventures of the Fifth Musketeer" +}; + +static const char *engine_cruise[] = { + "Cruise for a Corpse" +}; + +static const struct { + int size; + const char **listP; +} supported[] = { + { ARRAYSIZE(engine_agos), engine_agos }, + { ARRAYSIZE(engine_sky), engine_sky }, + { ARRAYSIZE(engine_sword1), engine_sword1 }, + { ARRAYSIZE(engine_sword2), engine_sword2 }, + { ARRAYSIZE(engine_cine), engine_cine }, + { ARRAYSIZE(engine_queen), engine_queen }, + { ARRAYSIZE(engine_lure), engine_lure }, + { ARRAYSIZE(engine_gob), engine_gob }, + { ARRAYSIZE(engine_kyra), engine_kyra }, + { ARRAYSIZE(engine_parallaction), engine_parallaction }, + { ARRAYSIZE(engine_saga), engine_saga }, + { ARRAYSIZE(engine_scumm), engine_scumm }, + { ARRAYSIZE(engine_agi), engine_agi }, + { ARRAYSIZE(engine_touche), engine_touche }, + { ARRAYSIZE(engine_cruise), engine_cruise } +}; + +static void SelectorSetList(Int16 sel) { + ListType *listP; + FormPtr frmP = FrmGetActiveForm(); + + Boolean toBeDrawn = (items != NULL); + if (items) + MemPtrFree(items); + + listP = (ListType *)FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, EngineSupportedList)); + items = (Char **)MemPtrNew(supported[sel].size * sizeof(Char *)); + + for (int i = 0; i < supported[sel].size; i++) + items[i] = (Char *)supported[sel].listP[i]; + + LstSetListChoices (listP, items, supported[sel].size); + LstSetTopItem(listP, 0); + LstSetSelection(listP, -1); + + if (toBeDrawn) { + WinScreenLock(winLockCopy); + LstDrawList(listP); + WinScreenUnlock(); + } +} + +static void SelectorFormInit() { + ListType *listP; + FormPtr frmP = FrmGetActiveForm(); + + listP = (ListType *)FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, EngineListList)); + itemsText = (Char **)MemPtrNew(ENGINE_COUNT * sizeof(Char *)); + + for (int i = 0; i < ENGINE_COUNT; i++) + itemsText[i] = (Char *)engines[i].nameP; + + LstSetListChoices (listP, itemsText, ENGINE_COUNT); + LstSetSelection(listP, 0); + + SelectorSetList(0); + + FrmDrawForm(frmP); +} + +static void SelectorFormFree(bool quit) { + items = NULL; + + if (!quit) { + ListType *listP = (ListType *)GetObjectPtr(EngineListList); + Int16 sel = LstGetSelection(listP); + + FrmReturnToMain(); + StartScummVM(sel); + + } else { + FrmReturnToMain(); + + if (bDirectMode) { + // force exit if nothing selected + EventType event; + event.eType = keyDownEvent; + event.data.keyDown.chr = vchrLaunch; + event.data.keyDown.modifiers = commandKeyMask; + EvtAddUniqueEventToQueue(&event, 0, true); + } + } +} + +Boolean SelectorFormHandleEvent(EventPtr eventP) { + FormPtr frmP = FrmGetActiveForm(); + Boolean handled = false; + + switch (eventP->eType) { + case frmOpenEvent: + SelectorFormInit(); + handled = true; + break; + + case frmCloseEvent: + SelectorFormFree(true); + handled = true; + break; + + case lstSelectEvent: + if (eventP->data.lstSelect.listID == EngineSupportedList) + LstSetSelection(eventP->data.lstSelect.pList, -1); + else + SelectorSetList(eventP->data.lstSelect.selection); + handled = true; + break; + + case ctlSelectEvent: + switch (eventP->data.ctlSelect.controlID) + { + case EngineOkButton: + SelectorFormFree(false); + break; + + case EngineCancelButton: + SelectorFormFree(true); + break; + } + handled = true; + break; + + default: + break; + } + + return handled; +} diff --git a/backends/platform/PalmOS/Src/launcher/forms/formUtil.h b/backends/platform/PalmOS/Src/launcher/forms/formUtil.h index 90cf1ff37a..e9b87bc49f 100644 --- a/backends/platform/PalmOS/Src/launcher/forms/formUtil.h +++ b/backends/platform/PalmOS/Src/launcher/forms/formUtil.h @@ -4,6 +4,8 @@ #define frmRedrawUpdateMS (frmRedrawUpdateCode + 1) #define frmRedrawUpdateMSImport (frmRedrawUpdateCode + 2) +#define NO_ENGINE -1 + // form list draw #define ITEM_TYPE_UNKNOWN 'U' #define ITEM_TYPE_CARD 'C' diff --git a/backends/platform/PalmOS/Src/launcher/forms/formmain.cpp b/backends/platform/PalmOS/Src/launcher/forms/formmain.cpp index 1709b4c7a2..bd3263350d 100644 --- a/backends/platform/PalmOS/Src/launcher/forms/formmain.cpp +++ b/backends/platform/PalmOS/Src/launcher/forms/formmain.cpp @@ -299,8 +299,10 @@ Boolean MainFormHandleEvent(EventPtr eventP) case skinButtonGameStart: if (gPrefs->card.volRefNum == vfsInvalidVolRef) FrmCustomAlert(FrmWarnAlert,"Please select/insert a memory card.", 0, 0); + else if (GamGetSelected() != dmMaxRecordIndex) + StartScummVM(); else - bStartScumm = true; + FrmPopupForm(EngineForm); handled = true; break; diff --git a/backends/platform/PalmOS/Src/launcher/forms/forms.h b/backends/platform/PalmOS/Src/launcher/forms/forms.h index 0bdfd356c7..ca0089d8c1 100644 --- a/backends/platform/PalmOS/Src/launcher/forms/forms.h +++ b/backends/platform/PalmOS/Src/launcher/forms/forms.h @@ -18,5 +18,6 @@ HANDLER(CardSlot) HANDLER(Skins) HANDLER(Music) HANDLER(Info) +HANDLER(Selector) #endif diff --git a/backends/platform/PalmOS/Src/launcher/games.cpp b/backends/platform/PalmOS/Src/launcher/games.cpp index d0e162a4cc..c9fd0a661b 100644 --- a/backends/platform/PalmOS/Src/launcher/games.cpp +++ b/backends/platform/PalmOS/Src/launcher/games.cpp @@ -32,7 +32,6 @@ #include "games.h" #include "skin.h" -#include "extend.h" #include "StarterRsc.h" DmOpenRef gameDB = NULL; diff --git a/backends/platform/PalmOS/Src/launcher/games.h b/backends/platform/PalmOS/Src/launcher/games.h index c80c99eda3..235aca38de 100644 --- a/backends/platform/PalmOS/Src/launcher/games.h +++ b/backends/platform/PalmOS/Src/launcher/games.h @@ -170,6 +170,7 @@ enum { ENGINE_SCUMM, ENGINE_AGI, ENGINE_TOUCHE, + ENGINE_CRUISE, ENGINE_COUNT }; @@ -179,21 +180,21 @@ static const struct { } engines[] = { { "agos", "AGOS Engine" }, { "sky", "Beneath a Steel Sky" }, - { "sword1", "Broken Sword 1" }, - { "sword2", "Broken Sword 2" }, + { "sword1", "Broken Sword I" }, + { "sword2", "Broken Sword II" }, { "cine", "Delphine Cinematique v1.0" }, { "queen", "Flight of the Amazon Queen" }, { "lure", "Lure of the Tempress" }, - { "gob", "Gobliiins" }, + { "gob", "Gobliiins, Bargon Attack and more ..." }, { "kyra", "Kyrandia" }, { "parallaction", "Parallaction" }, { "saga", "SAGA Engine" }, { "scumm", "Scumm Games" }, { "agi", "Sierra AGI" }, { "touche", "Touche: The Adventures of the Fifth Musketeer" }, + { "cruise", "Cruise for a Corpse" }, }; - // protos Err GamOpenDatabase (); void GamImportDatabase (); diff --git a/backends/platform/PalmOS/Src/launcher/launch.cpp b/backends/platform/PalmOS/Src/launcher/launch.cpp index 7dd775d77d..8e5de05c8d 100644 --- a/backends/platform/PalmOS/Src/launcher/launch.cpp +++ b/backends/platform/PalmOS/Src/launcher/launch.cpp @@ -29,7 +29,6 @@ #include "games.h" #include "start.h" #include "rumble.h" -#include "extend.h" #include "globals.h" #include "features.h" #include "formUtil.h" @@ -188,54 +187,23 @@ onError: #undef CHECK_FILE #undef BUILD_FILE -Boolean StartScummVM() { +Boolean StartScummVM(Int16 engine) { Char **argvP; UInt8 lightspeed, argc = 0; UInt32 stackSize; Boolean toLauncher, direct, isARM; - UInt8 engine; Char num[6]; - UInt16 index = GamGetSelected(); - argvP = ArgsInit(); direct = false; // start command line (exec name) ArgsAdd(&argvP[argc], "-", NULL, &argc); + UInt16 index = GamGetSelected(); // no game selected if (index == dmMaxRecordIndex) { - ListPtr listP; - UInt16 whichButton; - - // init form - FormPtr frmP = FrmInitForm(EngineForm); - listP = (ListType *)FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, EngineListList)); - itemsText = (Char **)MemPtrNew(ENGINE_COUNT * sizeof(Char *)); - - for (int i = 0; i < ENGINE_COUNT; i++) - itemsText[i] = (Char *)engines[i].nameP; - - LstSetListChoices (listP, itemsText, ENGINE_COUNT); - LstSetSelection(listP, 0); - - whichButton = FrmDoDialog(frmP); - engine = LstGetSelection(listP); - - FrmDeleteForm(frmP); - MemPtrFree(itemsText); - itemsText = NULL; - - if (whichButton == EngineCancelButton) { - if (bDirectMode) { - // and force exit if nothing selected - EventType event; - event.eType = keyDownEvent; - event.data.keyDown.chr = vchrLaunch; - event.data.keyDown.modifiers = commandKeyMask; - EvtAddUniqueEventToQueue(&event, 0, true); - } + if (engine == NO_ENGINE) { // free args ArgsFree(argvP); return false; @@ -244,6 +212,7 @@ Boolean StartScummVM() { // default values if (bDirectMode) gPrefs->card.volRefNum = parseCards(); // always use the first removable card available (?) + gVars->filter = true; gVars->palmVolume = 50; gVars->fmQuality = FM_QUALITY_INI; @@ -455,7 +424,11 @@ Boolean StartScummVM() { // gVars values // (gVars->HRrefNum defined in checkHRmode on Clié) +#ifndef _DEBUG_ENGINE gVars->VFS.volRefNum = (gPrefs->card.autoDetect ? vfsInvalidVolRef : gPrefs->card.volRefNum); +#else + gVars->VFS.volRefNum = gPrefs->card.volRefNum; +#endif gVars->vibrator = gPrefs->vibrator; gVars->stdPalette = gPrefs->stdPalette; gVars->VFS.cacheSize = (gPrefs->card.useCache ? gPrefs->card.cacheSize : 0); diff --git a/backends/platform/PalmOS/Src/launcher/start.cpp b/backends/platform/PalmOS/Src/launcher/start.cpp index 076c24d6c2..e68228cc77 100644 --- a/backends/platform/PalmOS/Src/launcher/start.cpp +++ b/backends/platform/PalmOS/Src/launcher/start.cpp @@ -43,7 +43,6 @@ GlobalsPreferencePtr gPrefs; GlobalsDataPtr gVars; Boolean bDirectMode = false; -Boolean bStartScumm = false; Boolean bLaunched = false; /*********************************************************************** @@ -200,6 +199,10 @@ static Boolean AppHandleEvent(EventPtr eventP) { FrmSetEventHandler(frmP, InfoFormHandleEvent); break; + case EngineForm: + FrmSetEventHandler(frmP, SelectorFormHandleEvent); + break; + default: // ErrFatalDisplay("Invalid Form Load Event"); break; @@ -231,9 +234,6 @@ static void AppEventLoop(void) { do { EvtGetEvent(&event, evtNoWait); - if(bStartScumm) - bStartScumm = StartScummVM(); - if (! SysHandleEvent(&event)) if (! MenuHandleEvent(0, &event, &error)) if (! AppHandleEvent(&event)) @@ -330,7 +330,7 @@ static UInt32 ScummVMPalmMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { FrmGotoForm(MainForm); }else { GamUnselect(); - bStartScumm = true; + FrmGotoForm(EngineForm); } AppEventLoop(); diff --git a/backends/platform/PalmOS/Src/launcher/start.h b/backends/platform/PalmOS/Src/launcher/start.h index f08d551763..acf9081a83 100644 --- a/backends/platform/PalmOS/Src/launcher/start.h +++ b/backends/platform/PalmOS/Src/launcher/start.h @@ -79,7 +79,6 @@ typedef struct { extern GlobalsPreferencePtr gPrefs; extern Boolean bDirectMode; -extern Boolean bStartScumm; extern Boolean bLaunched; #define appPrefID 0x00 @@ -92,7 +91,7 @@ extern Boolean bLaunched; Err AppStart(void); void AppStop(void); -Boolean StartScummVM(); +Boolean StartScummVM(Int16 engine = -1); void SavePrefs(); Err SendDatabase (UInt16 cardNo, LocalID dbID, Char *nameP, Char *descriptionP); #endif diff --git a/backends/platform/PalmOS/Src/missing/assert.h b/backends/platform/PalmOS/Src/missing/assert.h deleted file mode 100644 index 7bc571ec15..0000000000 --- a/backends/platform/PalmOS/Src/missing/assert.h +++ /dev/null @@ -1,34 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef __ASSERT_H__ -#define __ASSERT_H__ - -#ifdef _DEBUG -#define assert(a) ErrFatalDisplayIf(!(a), "Assertion failed: " #a) -#else -#define assert(a) (void)0 -#endif - -#endif diff --git a/backends/platform/PalmOS/Src/missing/ext_stdio.c b/backends/platform/PalmOS/Src/missing/ext_stdio.c deleted file mode 100644 index f7d37a9140..0000000000 --- a/backends/platform/PalmOS/Src/missing/ext_stdio.c +++ /dev/null @@ -1,650 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include <stdio.h> -#include <stdlib.h> -#include <PmPalmOSNVFS.h> - -#define CACHE_SIZE 1024 -enum { - MODE_BUFREAD = 1, - MODE_BUFWRITE, - MODE_BUFNONE -}; - -FILE gStdioOutput = {0,0,0,0,0,0}; -static void dummy(Boolean) {}; - -static LedProc gStdioLedProc = dummy; -static UInt16 gStdioVolRefNum = vfsInvalidVolRef; -static UInt32 gCacheSize = CACHE_SIZE; - -// TODO : implement "errno" - -void StdioInit(UInt16 volRefNum, const Char *output) { // DONE - gStdioVolRefNum = volRefNum; - gStdioOutput.mode = MODE_BUFWRITE; - - VFSFileDelete(gStdioVolRefNum, output); - VFSFileCreate(gStdioVolRefNum, output); - VFSFileOpen (gStdioVolRefNum, output,vfsModeWrite, &gStdioOutput.fileRef); -} - -void StdioSetLedProc(LedProc ledProc) { // DONE - if (ledProc) - gStdioLedProc = ledProc; - else - gStdioLedProc = dummy; -} - -void StdioSetCacheSize(UInt32 s) { // DONE - gCacheSize = s; -} - -void StdioRelease() { // DONE - // there is no cache on stdout/stderr - VFSFileClose(gStdioOutput.fileRef); -} - -UInt16 fclose(FILE *stream) { // DONE - UInt32 numBytesWritten; - Err e; - - if (stream->cacheSize) { - if (stream->bufSize > 0 && stream->mode == MODE_BUFWRITE) - VFSFileWrite(stream->fileRef, stream->bufSize, stream->cache, &numBytesWritten); - - MemPtrFree(stream->cache); - } - - e = VFSFileClose(stream->fileRef); - e = MemPtrFree(stream); - - return e; -} - -UInt16 feof(FILE *stream) { // DONE - Err e; - - if (stream->cacheSize) { - switch (stream->mode) { - case MODE_BUFWRITE: - return 0; // never set in this mode - case MODE_BUFREAD: - if (stream->bufSize > 0) - return 0; - break; - } - } - - e = VFSFileEOF(stream->fileRef); - return e; -} - -UInt16 ferror(FILE *stream) { - return (stream->err); -} - -Int16 fgetc(FILE *stream) { - UInt32 numBytesRead; - Char c; - - numBytesRead = fread(&c, 1, 1, stream); - return (int)(numBytesRead == 1 ? c : EOF); -} - -Char *fgets(Char *s, UInt32 n, FILE *stream) { - UInt32 numBytesRead; - - numBytesRead = fread(s, n, 1, stream); - if (numBytesRead) { - UInt32 reset = 0; - Char *endLine = StrChr(s, '\n'); - - if (endLine >= s) { - reset = (endLine - s); - s[reset] = 0; - reset = numBytesRead - (reset + 1); - fseek(stream, -reset, SEEK_CUR); - } - - return s; - } - - return NULL; -} - -FILE *fopen(const Char *filename, const Char *type) { // DONE - Err err; - UInt16 openMode; - Boolean cache = true; - FILE *fileP = (FILE *)MemPtrNew(sizeof(FILE)); - - if (!fileP) - return NULL; - - MemSet(fileP, sizeof(FILE), 0); - - if (StrCompare(type,"r")==0 || StrCompare(type,"rb")==0) { - fileP->mode = MODE_BUFREAD; - openMode = vfsModeRead; - - } else if (StrCompare(type,"w")==0 || StrCompare(type,"wb")==0) { - fileP->mode = MODE_BUFWRITE; - openMode = vfsModeCreate|vfsModeWrite; - - } else { - cache = false; - fileP->mode = MODE_BUFNONE; - openMode = vfsModeReadWrite; - } - - if (cache) { - fileP->cacheSize = gCacheSize; - if (gCacheSize) fileP->cache = (UInt8 *)malloc(gCacheSize); // was MemGluePtrNew - if (!fileP->cache) fileP->cacheSize = 0; - } - - if (openMode & vfsModeRead) { - // if read file : - // first try to load from the specfied card - err = VFSFileOpen (gStdioVolRefNum, filename, openMode, &fileP->fileRef); - //if err (not found ?) parse each avalaible card for the specified file - if (err) { - UInt16 volRefNum; - UInt32 volIterator = vfsIteratorStart|vfsIncludePrivateVolumes; - while (volIterator != vfsIteratorStop) { - err = VFSVolumeEnumerate(&volRefNum, &volIterator); - - if (!err) { - err = VFSFileOpen (volRefNum, filename, openMode, &fileP->fileRef); - if (!err) - return fileP; - } - } - } else { - return fileP; - } - } else { - // if write file : - // use only the specified card - err = VFSFileDelete(gStdioVolRefNum, filename); // delete it if exists - err = VFSFileCreate(gStdioVolRefNum, filename); - openMode = vfsModeWrite; - if (!err) { - err = VFSFileOpen (gStdioVolRefNum, filename, openMode, &fileP->fileRef); - if (!err) - return fileP; - } - } - - if (fileP->cacheSize) - MemPtrFree(fileP->cache); - - MemPtrFree(fileP); // prevent memory leak - return NULL; -} - -UInt32 fread(void *ptr, UInt32 size, UInt32 nitems, FILE *stream) { // DONE - Err e = errNone; - UInt32 numBytesRead, rsize = (size * nitems); - - // try to read on a write only stream ? - if (stream->mode == MODE_BUFWRITE || !rsize) - return 0; - - // cached ? - if (stream->cacheSize) { - // empty buffer ? fill it if required - if (stream->bufSize == 0 && rsize < stream->cacheSize) { - gStdioLedProc(true); - e = VFSFileRead(stream->fileRef, stream->cacheSize, stream->cache, &numBytesRead); - gStdioLedProc(false); - stream->bufSize = numBytesRead; - stream->bufPos = 0; - } - - // we have the data in the cache - if (stream->bufSize >= rsize) { - MemMove(ptr, (stream->cache + stream->bufPos), rsize); - stream->bufPos += rsize; - stream->bufSize -= rsize; - numBytesRead = rsize; - - // not enough but something ? - } else if (stream->bufSize > 0) { - UInt8 *next = (UInt8 *)ptr; - MemMove(ptr, (stream->cache + stream->bufPos), stream->bufSize); - rsize -= stream->bufSize; - gStdioLedProc(true); - e = VFSFileRead(stream->fileRef, rsize, (next + stream->bufSize), &numBytesRead); - gStdioLedProc(false); - numBytesRead += stream->bufSize; - stream->bufSize = 0; - stream->bufPos = 0; - - // nothing in the cache ? - } else { - gStdioLedProc(true); - e = VFSFileRead(stream->fileRef, rsize, ptr, &numBytesRead); - gStdioLedProc(false); - } - - // no ? direct read - } else { - gStdioLedProc(true); - e = VFSFileRead(stream->fileRef, rsize, ptr, &numBytesRead); - gStdioLedProc(false); - } - - if (e == errNone || e == vfsErrFileEOF) - return (UInt32)(numBytesRead / size); - - return 0; -} - -UInt32 fwrite(const void *ptr, UInt32 size, UInt32 nitems, FILE *stream) { // DONE - Err e = errNone; - UInt32 numBytesWritten = (size * nitems); - - // try to write on a read only stream ? - if (stream->mode == MODE_BUFREAD || !numBytesWritten) - return 0; - - // cached ? - if (stream->cacheSize) { - // can cache it ? - if ((stream->bufSize + numBytesWritten) <= stream->cacheSize) { - MemMove((stream->cache + stream->bufSize), ptr, numBytesWritten); - stream->bufSize += numBytesWritten; - - // not enough room ? write cached data and new data - } else { - gStdioLedProc(true); - e = VFSFileWrite(stream->fileRef, stream->bufSize, stream->cache, &numBytesWritten); - e = VFSFileWrite(stream->fileRef, (size * nitems), ptr, &numBytesWritten); - gStdioLedProc(false); - stream->bufSize = 0; - } - - // no ? direct write - } else { - gStdioLedProc(true); - e = VFSFileWrite(stream->fileRef, (size * nitems), ptr, &numBytesWritten); - gStdioLedProc(false); - } - - if ((e == errNone || e == vfsErrFileEOF)) { - return (UInt32)(numBytesWritten / size); - } - - return 0; -} - -Int16 fseek(FILE *stream, Int32 offset, Int32 whence) { // DONE - UInt32 numBytesWritten; - Err e; - - if (stream->cacheSize) { - switch (stream->mode) { - case MODE_BUFWRITE: - e = VFSFileWrite(stream->fileRef, stream->bufSize, stream->cache, &numBytesWritten); - stream->bufSize = 0; - break; - - case MODE_BUFREAD: - // reposition file postion if needed - if (whence == SEEK_CUR) - e = VFSFileSeek(stream->fileRef, vfsOriginCurrent, -stream->bufSize); - stream->bufSize = 0; - stream->bufPos = 0; - break; - } - } - - e = VFSFileSeek(stream->fileRef, whence, offset); - return (e ? -1 : 0); -} - -Int32 ftell(FILE *stream) { // DONE - Err e; - UInt32 filePos; - - e = VFSFileTell(stream->fileRef ,&filePos); - - if (stream->cacheSize) { - switch (stream->mode) { - case MODE_BUFWRITE: - filePos += stream->bufSize; - break; - - case MODE_BUFREAD: - filePos -= stream->bufSize; - break; - } - } - - if (e) return -1; // errno = ? - return filePos; -} - -Int32 fprintf(FILE *stream, const Char *formatStr, ...) { // DONE - UInt32 numBytesWritten; - Char buf[256]; - va_list va; - - if (!stream->fileRef) - return 0; - - va_start(va, formatStr); - vsprintf(buf, formatStr, va); - va_end(va); - - numBytesWritten = fwrite(buf, StrLen(buf), 1, stream); - return numBytesWritten; -} - -Int32 printf(const Char *format, ...) { // DONE - UInt32 numBytesWritten; - Char buf[256]; - va_list va; - - if (!stdout->fileRef) - return 0; - - va_start(va, format); - vsprintf(buf, format, va); - va_end(va); - - numBytesWritten = fwrite(buf, StrLen(buf), 1, stdout); - return numBytesWritten; -} - -/* needed with 68k mode only, already defined in ARM MSL */ -#ifdef PALMOS_68K - -Int32 sprintf(Char* s, const Char* formatStr, ...) { - Int16 count; - va_list va; - - va_start(va, formatStr); - count = vsprintf(s, formatStr, va); - va_end(va); - - return count; -} - -Int32 snprintf(Char* s, UInt32 len, const Char* formatStr, ...) { - // len is ignored - Int16 count; - va_list va; - - va_start(va, formatStr); - count = vsprintf(s, formatStr, va); - va_end(va); - - return count; -} - - -/* WARNING : vsprintf - * ------- - * This function can handle only %[+- ][.0][field length][sxXdoiucp] format strings - * compiler option : 4byte int mode only ! - * - * TODO : check http://www.ijs.si/software/snprintf/ for a portable implementation of vsnprintf - * This one make use of sprintf so need to check if it works with PalmOS. - */ - -static Char *StrIToBase(Char *s, Int32 i, UInt8 b) { - const Char *conv = "0123456789ABCDEF"; - Char o; - Int16 c, n = 0; - Int32 div, mod; - - do { - div = i / b; - mod = i % b; - - s[n++] = *(conv + mod); - i = div; - - } while (i >= b); - - if (i > 0) { - s[n + 0] = *(conv + i); - s[n + 1] = 0; - } else { - s[n + 0] = 0; - n--; - } - - for (c=0; c <= (n >> 1); c++) { - o = s[c]; - s[c] = s[n - c]; - s[n - c]= o; - } - - return s; -} - -static void StrProcC_(Char *ioStr, UInt16 maxLen) { - Char *found; - Int16 length; - - while (found = StrStr(ioStr, "`c`")) { - if (found[3] == 0) { // if next char is NULL - length = maxLen - (found - ioStr + 2); - MemMove(found, found + 4, length); - maxLen -= 2; - } - } -} - -static void StrProcXO(Char *ioStr, UInt16 maxLen, Char *tmp) { - Char *found, *last, mod, fill; - Int16 len, count, next; - Int32 val; - - while (found = StrChr(ioStr, '`')) { - last = StrChr(found + 1, '`'); - - if (!last) - return; - - *last = 0; - next = 0; - fill = *(found + 1); - mod = *(found + 2); - count = StrAToI(found + 3); - - len = maxLen - (last - ioStr); - MemMove(found, (last + 1), len); - - // x and X always 8char on palmos ... o set to 8char (not supported on palmos) - while ((found[next] == '0' || found[next] == ' ') && next < 8) // WARNING : reduce size only (TODO ?) - next++; - - // convert to base 8 - if (mod == 'o') { - StrNCopy(tmp, found + next, 8 - next); - tmp[8 - next] = 0; - val = StrAToI(tmp); - StrIToBase(tmp, val, 8); // now we have the same but in octal - next = 8 - StrLen(tmp); - MemMove(found + next, tmp, StrLen(tmp)); - } else { - // if val is 0, keep last 0 - if (next == 8) - next = 7; - } - - if ((8 - next) > count) - count = 8 - next; - - if (count == 0) - count = 1; - - len = maxLen - (found - ioStr) - (8 - count); - MemSet(found, next, fill); - MemMove(found, found + (8 - count), len); - - // ... and upper case - if (mod == 'x') { - while (count--) { - if (*found >='A' && *found <='F') - *found = (*found + 32); - found++; - } - } - } -} - -Int32 vsprintf(Char* s, const Char* formatStr, _Palm_va_list argParam) { - Char format[256], result[256], tmp[32]; - - Char *found, *mod, *num; - UInt32 next; - Boolean zero; - Int16 count, len; - - MemSet(format, sizeof(format), 'x'); - MemSet(result, sizeof(result), 'y'); - MemSet(tmp, sizeof(tmp), 'z'); - - StrCopy(format,formatStr); // copy actual formatStr to temp buffer - next = 0; // start of the string - - while (found = StrChr(format + next, '%')) { - mod = found + 1; - - if (*mod == '%') { // just a % ? - mod++; - - } else { - if (*mod == '+' || - *mod == '-' || - *mod == ' ' ) // skip - mod++; - - if (*mod == '0' || - *mod == '.' ) { - *mod++ = '0'; - zero = true; - } else { - zero = false; - } - - num = mod; - while ( *mod >= '0' && - *mod <= '9' ) // search format char - mod++; - - // get the numeric value - if (num < mod) { - StrNCopy(tmp, num, mod - num); - tmp[mod - num] = 0; - count = StrAToI(tmp); - } else { - count = 0; - } - - if (*mod == 'l') // already set to %...l(x) ? - mod++; - - // prepare new format -//#if !defined(PALMOS_ARM) - if (*mod == 'c') { - StrCopy(tmp, "`c`%c%c"); - - } else -//#endif - if (*mod == 'p') { - StrCopy(tmp, "%08lX"); // %x = %08X in palmos - - } else { - len = 0; - - switch (*mod) { - case 'x': - case 'X': - case 'o': - tmp[0] = '`'; - tmp[1] = (zero) ? '0' : ' '; - tmp[2] = *mod; - StrIToA(tmp + 3, count); - len += StrLen(tmp); - tmp[len++] = '`'; - tmp[len] = 0; - - if (*mod == 'o') { // set as base 10 num and convert later - *mod = 'd'; - count = 8; // force 8char - } - - break; - } - - StrNCopy(tmp + len, found, (num - found)); - len += (num - found); - - if (count) { - StrIToA(tmp + len, count); - len += StrLen(tmp + len); - } - - if (*mod == 'd' || - *mod == 'i' || - *mod == 'x' || - *mod == 'X' || - *mod == 'u' - ) { - tmp[len++] = 'l'; - } - - tmp[len + 0] = *mod; - tmp[len + 1] = 0; - } - - mod++; - MemMove(found + StrLen(tmp), mod, StrLen(mod) + 1); - StrNCopy(found, tmp, StrLen(tmp)); - mod = found + StrLen(tmp); - } - - next = (mod - format); - } - - // Copy result in a temp buffer to process last formats - StrVPrintF(result, format, argParam); -//#if !defined(PALMOS_ARM) - StrProcC_(result, 256); -//#endif - StrProcXO(result, 256, tmp); - StrCopy(s, result); - - return StrLen(s); -} - -#endif diff --git a/backends/platform/PalmOS/Src/missing/ext_stdlib.c b/backends/platform/PalmOS/Src/missing/ext_stdlib.c deleted file mode 100644 index 701e3bca69..0000000000 --- a/backends/platform/PalmOS/Src/missing/ext_stdlib.c +++ /dev/null @@ -1,139 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include <stdlib.h> - -#ifdef STDLIB_TRACE_MEMORY -UInt32 __stdlib_trace_memory = 0; -#endif - -#define memNewChunkFlagAllowLarge 0x1000 -SysAppInfoPtr SysGetAppInfo(SysAppInfoPtr *uiAppPP, SysAppInfoPtr *actionCodeAppPP) SYS_TRAP(sysTrapSysGetAppInfo); - -#ifdef PALMOS68K -long strtol(const char *s, char **endptr, int base) { - // WARNING : only base = 10 supported - long val = StrAToI(s); - - if (endptr) { - Char str[maxStrIToALen]; - StrIToA(str, val); - - if (StrNCompare(s, str, StrLen(str)) == 0) - *endptr = (char *)s + StrLen(str); - } - - return val; -} -#endif - -MemPtr __malloc(UInt32 size) { - MemPtr newP = NULL; - - if (size <= 65000) { - newP = MemPtrNew(size); - } else { - SysAppInfoPtr appInfoP; - UInt16 ownerID; - UInt16 attr; - - ownerID = ((SysAppInfoPtr)SysGetAppInfo(&appInfoP, &appInfoP))->memOwnerID; - attr = ownerID|memNewChunkFlagAllowLarge|memNewChunkFlagNonMovable; - - newP = MemChunkNew(0, size, attr); - } - -#ifdef STDLIB_TRACE_MEMORY - __stdlib_trace_memory += size; -#endif - return newP; -} - -MemPtr calloc(UInt32 nelem, UInt32 elsize) { - MemPtr newP; - UInt32 size = (nelem * elsize); - - newP = malloc(size); // was MemGluePtrNew - - if (newP) - MemSet(newP,size,0); - -#ifdef STDLIB_TRACE_MEMORY - __stdlib_trace_memory += size; -#endif - return newP; -} - -Err free(MemPtr memP) { - if (memP) { -#ifdef STDLIB_TRACE_MEMORY - UInt32 sz = MemPtrSize(memP); - __stdlib_trace_memory -= sz; -#endif - return MemPtrFree(memP); - } - - return memErrInvalidParam; -} - -MemPtr realloc(MemPtr oldP, UInt32 size) { - MemPtr newP; - -#ifdef STDLIB_TRACE_MEMORY - UInt32 sz = MemPtrSize(oldP); - __stdlib_trace_memory -= sz; - __stdlib_trace_memory += size; -#endif - - if (oldP != NULL) - if (MemPtrResize(oldP, size) == 0) - return oldP; - - newP = malloc(size); // was MemPtrNew - - if (oldP!=NULL) { - MemMove(newP,oldP,MemPtrSize(oldP)); - MemPtrFree(oldP); - } - - return newP; -} - -ErrJumpBuf stdlib_errJumpBuf; -#define ERR_MAGIC 0xDADA - -void exit(Int16 status) { - EventType event; - event.eType = keyDownEvent; - - event.data.keyDown.chr = vchrLaunch; - event.data.keyDown.modifiers = commandKeyMask; -#ifdef PALMOS_ARM - SysEventAddUniqueToQueue(&event, 0, true); -#else - EvtAddUniqueEventToQueue(&event, 0, true); -#endif - - ErrLongJump(stdlib_errJumpBuf, status == 0 ? 0xDADA : status); -} diff --git a/backends/platform/PalmOS/Src/missing/ext_string.c b/backends/platform/PalmOS/Src/missing/ext_string.c deleted file mode 100644 index 319017f790..0000000000 --- a/backends/platform/PalmOS/Src/missing/ext_string.c +++ /dev/null @@ -1,45 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include <string.h> - -#ifdef PALMOS_68K -void *memchr(const void *s, int c, UInt32 n) { - UInt32 chr; - for(chr = 0; chr < n;chr++,((UInt8 *)s)++) - if ( *((UInt8 *)s) == c) - return (void *)s; - - return NULL; -} - -Char *strdup(const Char *s1) { - Char* buf = (Char *)MemPtrNew(StrLen(s1)+1); - - if(buf) - StrCopy(buf, s1); - - return buf; -} -#endif diff --git a/backends/platform/PalmOS/Src/missing/ext_time.c b/backends/platform/PalmOS/Src/missing/ext_time.c deleted file mode 100644 index 5de64062b0..0000000000 --- a/backends/platform/PalmOS/Src/missing/ext_time.c +++ /dev/null @@ -1,85 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include <time.h> - -time_t time(time_t *tloc) { - // get ROM version - UInt32 romVersion; - Err e = FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion); - - // since 1/1/1904 12AM. - UInt32 secs = TimGetSeconds(); - - // form 1/1/1904 12AM to 1/1/1970 12AM - DateTimeType Epoch = {0, 0, 0, 1, 1, 1970, 0}; - - secs -= TimDateTimeToSeconds(&Epoch); - - // DST really supported from OS v4.0 - if (romVersion >= sysMakeROMVersion(4,0,0,sysROMStageRelease,0)) - secs -= (PrefGetPreference(prefTimeZone) + PrefGetPreference(prefDaylightSavingAdjustment)) * 60; - else - secs -= (PrefGetPreference(prefMinutesWestOfGMT) - 720) * 60; - - if (tloc) - *tloc = secs; - - return (secs); -} - - -struct tm *localtime(const time_t *timer) { - static struct tm tmDate; - DateTimeType dt; - UInt32 secs = *timer; - - // get ROM version - UInt32 romVersion; - Err e = FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion); - - // form 1/1/1904 12AM to 1/1/1970 12AM - DateTimeType Epoch = {0, 0, 0, 1, 1, 1970, 0}; - - // timer supposed to be based on Epoch - secs += TimDateTimeToSeconds(&Epoch); - - // DST really supported from OS v4.0 - if (romVersion >= sysMakeROMVersion(4,0,0,sysROMStageRelease,0)) - secs += (PrefGetPreference(prefTimeZone) + PrefGetPreference(prefDaylightSavingAdjustment)) * 60; - else - secs += (PrefGetPreference(prefMinutesWestOfGMT) - 720) * 60; // no sure about this one - - TimSecondsToDateTime (secs, &dt); - - tmDate.tm_sec = dt.second; - tmDate.tm_min = dt.minute; - tmDate.tm_hour = dt.hour; - tmDate.tm_mday = dt.day; - tmDate.tm_mon = dt.month - 1; - tmDate.tm_year = dt.year - 1900; - tmDate.tm_wday = dt.weekDay; - - return &tmDate; -} diff --git a/backends/platform/PalmOS/Src/missing/ext_unistd.c b/backends/platform/PalmOS/Src/missing/ext_unistd.c deleted file mode 100644 index 91f2e8e3e5..0000000000 --- a/backends/platform/PalmOS/Src/missing/ext_unistd.c +++ /dev/null @@ -1,41 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include <unistd.h> - -const Char *gUnistdCWD = NULL; - -// currently used only to retreive savepath -Char *getcwd(Char *buf, UInt32 size) { - Char *copy = buf; - - if (gUnistdCWD) { - if (!copy) - copy = (Char *)MemPtrNew(StrLen(gUnistdCWD)); // this may never occured - - StrCopy(copy, gUnistdCWD); - } - - return copy; -}
\ No newline at end of file diff --git a/backends/platform/PalmOS/Src/missing/fcntl.h b/backends/platform/PalmOS/Src/missing/fcntl.h deleted file mode 100644 index 59daa2ae05..0000000000 --- a/backends/platform/PalmOS/Src/missing/fcntl.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef FCNTL_H -#define FCNTL_H - -#define O_TEXT 0x0 /* 960827: Added this for Visual C++ compatibility. */ -#define O_RDWR 0x1 /* open the file in read/write mode */ /*- mm 980420 -*/ -#define O_RDONLY 0x2 /* open the file in read only mode */ /*- mm 980420 -*/ -#define O_WRONLY 0x4 /* open the file in write only mode */ /*- mm 980420 -*/ -#define O_APPEND 0x0100 /* open the file in append mode */ -#define O_CREAT 0x0200 /* create the file if it doesn't exist */ -#define O_EXCL 0x0400 /* if the file already exists don't create it again */ -#define O_TRUNC 0x0800 /* truncate the file after opening it */ -#define O_NRESOLVE 0x1000 /* Don't resolve any aliases */ -#define O_ALIAS 0x2000 /* Open alias file (if the file is an alias) */ -#define O_RSRC 0x4000 /* Open the resource fork */ -#define O_BINARY 0x8000 /* open the file in binary mode (default is text mode) */ -#define F_DUPFD 0x0 /* return a duplicate file descriptor */ - -#endif diff --git a/backends/platform/PalmOS/Src/missing/math.h b/backends/platform/PalmOS/Src/missing/math.h deleted file mode 100644 index eca2d9de08..0000000000 --- a/backends/platform/PalmOS/Src/missing/math.h +++ /dev/null @@ -1,38 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef __MATH_H__ -#define __MATH_H__ - -#ifndef PALMOS_ARM -# include "mathlib.h" -#else -# include "matharm.h" -#endif - -#ifndef M_PI -# define M_PI 3.14159265358979323846 -#endif - -#endif diff --git a/backends/platform/PalmOS/Src/missing/memory.h b/backends/platform/PalmOS/Src/missing/memory.h deleted file mode 100644 index f57990b19d..0000000000 --- a/backends/platform/PalmOS/Src/missing/memory.h +++ /dev/null @@ -1,25 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - - #include "string.h"
\ No newline at end of file diff --git a/backends/platform/PalmOS/Src/missing/stdio.h b/backends/platform/PalmOS/Src/missing/stdio.h deleted file mode 100644 index 490da720a5..0000000000 --- a/backends/platform/PalmOS/Src/missing/stdio.h +++ /dev/null @@ -1,103 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef __STDIO_H__ -#define __STDIO_H__ - -#include "palmversion.h" -#include <stdarg.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*LedProc)(Boolean show); -typedef UInt32 size_t; - -typedef struct { - FileRef fileRef; - UInt32 cacheSize, bufSize, bufPos; - UInt8 *cache; - UInt16 mode, err; -} FILE; - -#undef stdin -#undef stdout -#undef stderr - -#define stdin 0 -#define stdout (&gStdioOutput) -#define stderr (&gStdioOutput) - -#undef SEEK_SET -#undef SEEK_CUR -#undef SEEK_END - -#define SEEK_SET vfsOriginBeginning -#define SEEK_CUR vfsOriginCurrent -#define SEEK_END vfsOriginEnd - -extern FILE gStdioOutput; - -void StdioInit (UInt16 volRefNum, const Char *output); -void StdioSetLedProc (LedProc ledProc); -void StdioSetCacheSize (UInt32 s); -void StdioRelease (); - -/* missing functions in 68k MSL (some are defined in ARM) */ -#define clearerr(a) -#define fflush(a) -#define getc(a) fgetc(a) -#define vsnprintf(a,b,c,d) vsprintf(a,c,d) - -UInt16 fclose (FILE *stream); -UInt16 feof (FILE *stream); -UInt16 ferror (FILE *stream); -Char *fgets (Char *s, UInt32 n, FILE *stream); -Int16 fgetc (FILE *stream); -FILE *fopen (const Char *filename, const Char *type); -UInt32 fread (void *ptr, UInt32 size, UInt32 nitems, FILE *stream); -UInt32 fwrite (const void *ptr, UInt32 size, UInt32 nitems, FILE *stream); -Int16 fseek (FILE *stream, Int32 offset, Int32 whence); -Int32 ftell (FILE *stream); - -Int32 fprintf (FILE *stream, const Char *formatStr, ...); -Int32 printf (const Char* formatStr, ...); -Int32 sprintf (Char* s, const Char* formatStr, ...); -Int32 snprintf (Char* s, UInt32 len, const Char* formatStr, ...); -Int32 vsprintf (Char* s, const Char* formatStr, _Palm_va_list argParam); - -/* ARM MSL only */ -#ifdef PALMOS_ARM -#undef vsnprintf - -int vsnprintf (char *str, size_t size, const char *format, va_list ap); -int sscanf ( char * buffer, const char * format, ...); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/backends/platform/PalmOS/Src/missing/stdlib.h b/backends/platform/PalmOS/Src/missing/stdlib.h deleted file mode 100644 index 95e65b3232..0000000000 --- a/backends/platform/PalmOS/Src/missing/stdlib.h +++ /dev/null @@ -1,93 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef STDLIB_H -#define STDLIB_H - -#include "palmversion.h" - -#ifdef PALMOS_68K -#include "MemGlue.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* malloc stuff */ -#ifdef STDLIB_TRACE_MEMORY -# define malloc __malloc - extern UInt32 __stdlib_trace_memory; -#else -# if defined(COMPILE_ZODIAC) -# define malloc MemPtrNew -# elif defined(COMPILE_OS5) && defined(PALMOS_ARM) -# define malloc __malloc -# else -# define malloc MemGluePtrNew -# endif -#endif - -/* custom exit (true exit !) */ -extern ErrJumpBuf stdlib_errJumpBuf; -#define DO_EXIT( code ) \ - if (ErrSetJump(stdlib_errJumpBuf) == 0) { code } - -/* mapped to system functions */ -#define atoi StrAToI -#define atol StrAToI -#define abs(a) ((a) < 0 ? -(a) : (a)) -#define qsort(a,b,c,d) SysQSort((a), (b), (c), (CmpFuncPtr)(&d), 0); -#define rand() SysRandom(0) -#define abort() -#define strtoul(a,b,c) ((unsigned long)strtol(a,b,c)) - -MemPtr __malloc (UInt32); -MemPtr calloc (UInt32 nelem, UInt32 elsize); -void exit (Int16 status); -Err free (MemPtr memP); -MemPtr realloc (MemPtr oldP, UInt32 size); -long strtol (const char *s, char **endptr, int base); - -/* already defined in MSL */ -void *bsearch (const void *key, const void *base, UInt32 nmemb, UInt32 size, int (*compar)(const void *, const void *)); - -/* ARM MSL only */ -#ifdef PALMOS_ARM -#undef qsort -#undef strtol -#undef strtoul - -typedef int (*_compare_function)(const void*, const void*); - -void qsort (void * table_base, UInt32 num_members, UInt32 member_size, _compare_function compare_members); -long int strtol (const char *nptr, char **endptr, int base); -unsigned long int strtoul (const char *nptr, char **endptr,int base); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/backends/platform/PalmOS/Src/missing/string.h b/backends/platform/PalmOS/Src/missing/string.h deleted file mode 100644 index bb250dfe9b..0000000000 --- a/backends/platform/PalmOS/Src/missing/string.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef PALM_STRING_H -#define PALM_STRING_H - -#include "palmversion.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* mapped to system functions */ -#define memcmp MemCmp -#define memcpy MemMove -#define memmove MemMove -#define memset(a,b,c) MemSet(a,c,b) -#define strcat StrCat -#define strncat StrNCat -#define strchr StrChr -#define strcmp StrCompare -#define strcpy StrCopy -#define strncpy StrNCopy -#define stricmp StrCaselessCompare -#define strnicmp StrNCaselessCompare -#define strlen StrLen -#define strncmp StrNCompare -#define strstr StrStr - -/* missing functions in 68k MSL */ -void *memchr (const void *s, int c, UInt32 n); -Char *strdup (const Char *strSource); - -/* already defined in MSL */ -Char *strtok (Char *str, const Char *sep); -Char *strrchr (const Char *s, int c); -Char *strpbrk (const Char *s1, const Char *s2); -UInt32 strspn (const Char *s1, const Char *s2); -UInt32 strcspn (const Char *s1, const Char *s2); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/backends/platform/PalmOS/Src/missing/sys/stat.h b/backends/platform/PalmOS/Src/missing/sys/stat.h deleted file mode 100644 index da84fa5f6b..0000000000 --- a/backends/platform/PalmOS/Src/missing/sys/stat.h +++ /dev/null @@ -1 +0,0 @@ -/* nothing */ diff --git a/backends/platform/PalmOS/Src/missing/time.h b/backends/platform/PalmOS/Src/missing/time.h deleted file mode 100644 index 3de16f4517..0000000000 --- a/backends/platform/PalmOS/Src/missing/time.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef __TIME_H__ -#define __TIME_H__ - -#include "palmversion.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef UInt32 time_t; - -struct tm { - Int16 tm_sec; // seconds [0,61] - Int16 tm_min; // minutes [0,59] - Int16 tm_hour; // hour [0,23] - Int16 tm_mday; // day of month [1,31] - Int16 tm_mon; // month of year [0,11] - Int16 tm_year; // years since 1900 - Int16 tm_wday; // day of week [0,6] (Sunday = 0) - Int16 tm_yday; // day of year [0,365] - Int16 tm_isdst; // daylight savings flag -}; - -time_t time(time_t *tloc); -struct tm *localtime(const time_t *timer); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/backends/platform/PalmOS/Src/missing/unistd.h b/backends/platform/PalmOS/Src/missing/unistd.h deleted file mode 100644 index 400b0e2c39..0000000000 --- a/backends/platform/PalmOS/Src/missing/unistd.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2006 The ScummVM project - * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef __UNISTD_H__ -#define __UNISTD_H__ - -#include "palmversion.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern const Char *gUnistdCWD; - -Char *getcwd(Char *buf, UInt32 size); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/backends/platform/PalmOS/Src/native/oscalls.cpp b/backends/platform/PalmOS/Src/native/oscalls.cpp index 4520d81c20..403eec40ab 100644 --- a/backends/platform/PalmOS/Src/native/oscalls.cpp +++ b/backends/platform/PalmOS/Src/native/oscalls.cpp @@ -29,19 +29,33 @@ GlobalsType global; PACE_CLASS_WRAPPER(Err) - StatShow_68k(void) { + __68k_StatShow(void) { PACE_PIN_EXEC_NP(pinStatShow, Err) } PACE_CLASS_WRAPPER(Err) - StatHide_68k(void) { + __68k_StatHide(void) { PACE_PIN_EXEC_NP(pinStatHide, Err) } PACE_CLASS_WRAPPER(Err) - PINSetInputAreaState_68k(UInt16 state) { + __68k_PINSetInputAreaState(UInt16 state) { PACE_PARAMS_INIT() PACE_PARAMS_ADD16(state) PACE_PARAMS_END() PACE_PIN_EXEC(pinPINSetInputAreaState, Err) } + +PACE_CLASS_WRAPPER(Err) + __68k_SysSetOrientation(UInt16 orientation) { + PACE_PARAMS_INIT() + PACE_PARAMS_ADD16(orientation) + PACE_PARAMS_END() + PACE_PIN_EXEC(pinSysSetOrientation, Err) +} + +PACE_CLASS_WRAPPER(UInt16) + __68k_SysGetOrientation(void) { + PACE_PIN_EXEC_NP(pinSysGetOrientation, UInt16) +} + diff --git a/backends/platform/PalmOS/Src/native/oscalls.h b/backends/platform/PalmOS/Src/native/oscalls.h index ae8f989337..0fb030b64a 100644 --- a/backends/platform/PalmOS/Src/native/oscalls.h +++ b/backends/platform/PalmOS/Src/native/oscalls.h @@ -29,9 +29,17 @@ extern "C" { #endif -Err StatShow_68k(); -Err StatHide_68k(); -Err PINSetInputAreaState_68k(UInt16 state); +#ifdef PALMOS_ARM +# define __68K(a) __68k_##a +#else +# define __68K(a) a +#endif + +Err __68k_StatShow(); +Err __68k_StatHide(); +Err __68k_PINSetInputAreaState(UInt16 state); +Err __68k_SysSetOrientation(UInt16 orientation); +UInt16 __68k_SysGetOrientation(void); #ifdef __cplusplus } diff --git a/backends/platform/PalmOS/Src/native/pnoARM.c b/backends/platform/PalmOS/Src/native/pnoARM.c index e072abca4d..e80e651462 100644 --- a/backends/platform/PalmOS/Src/native/pnoARM.c +++ b/backends/platform/PalmOS/Src/native/pnoARM.c @@ -56,29 +56,4 @@ unsigned long PNO_Main(const void *emulStateP, void *userData68KP, Call68KFuncTy return PilotMain(sysAppLaunchCmdNormalLaunch, userData68KP, 0); } - // - // The following functions provide malloc/free support to Metrowerks - // Standard Library (MSL). This feature requires the MSL library be - // built with _MSL_OS_DIRECT_MALLOC enabled. - // -void* -__sys_alloc(UInt32 size) -{ - void * ptr = malloc(size); - ErrFatalDisplayIf(ptr == NULL, "out of memory"); - return ptr; -} - -void -__sys_free(void* ptr) -{ - (void) MemPtrFree(ptr); -} - -UInt32 -__sys_pointer_size(void* ptr) -{ - return (UInt32) MemPtrSize(ptr); -} - #endif diff --git a/backends/platform/PalmOS/Src/native/zodiacARM.cpp b/backends/platform/PalmOS/Src/native/zodiacARM.cpp index 6bea511258..d98ed9bed9 100644 --- a/backends/platform/PalmOS/Src/native/zodiacARM.cpp +++ b/backends/platform/PalmOS/Src/native/zodiacARM.cpp @@ -22,12 +22,10 @@ * */ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> +#include "PalmVersion.h" +#include <MSL_PalmOS.h> #include "globals.h" -#include "extend.h" #include "args.h" #include "palmdefs.h" @@ -49,6 +47,7 @@ GlobalsDataPtr gVars = &g_vars; UInt32 g_stackSize; extern "C" void __destroy_global_chain(void); +extern void DrawStatus(Boolean show); static void palm_main(int argc, char **argvP) { #ifdef COMPILE_OS5 @@ -88,12 +87,11 @@ static void Go() { MemMove(gVars, tmp, sizeof(GlobalsDataType)); // init STDIO - StdioSetCacheSize(0); - StdioInit(gVars->VFS.volRefNum, "/PALM/Programs/ScummVM/scumm.log"); + stdio_set_cache(0); + stdio_init(gVars->VFS.volRefNum, "/PALM/Programs/ScummVM/scumm.log"); if (gVars->indicator.showLED) - StdioSetLedProc(DrawStatus); - StdioSetCacheSize(gVars->VFS.cacheSize); - gUnistdCWD = SCUMMVM_SAVEPATH; + stdio_set_led(DrawStatus); + stdio_set_cache(gVars->VFS.cacheSize); // get args FtrGet(appFileCreator, ftrArgsData, (UInt32 *)&argvP); @@ -108,7 +106,7 @@ static void Go() { // release if (HWR_INIT(INIT_VIBRATOR)) RumbleRelease(); - StdioRelease(); + stdio_release(); #ifdef DEBUG_ARM AdnDebugNativeUnregister(); diff --git a/backends/platform/PalmOS/Src/native/zodiacStartup.cpp b/backends/platform/PalmOS/Src/native/zodiacStartup.cpp index 9a898bacb0..5e018286b7 100644 --- a/backends/platform/PalmOS/Src/native/zodiacStartup.cpp +++ b/backends/platform/PalmOS/Src/native/zodiacStartup.cpp @@ -101,31 +101,6 @@ static void relocate(void) } /* - * The following functions provide malloc/free support to Metrowerks - * Standard Library (MSL). This feature requires the MSL library be - * built with _MSL_OS_DIRECT_MALLOC enabled. - */ -void* -__sys_alloc(size_t size) -{ - void * ptr = MemPtrNew(size); - ErrFatalDisplayIf(ptr == NULL, "out of memory"); - return ptr; -} - -void -__sys_free(void* ptr) -{ - (void) MemPtrFree(ptr); -} - -size_t -__sys_pointer_size(void* ptr) -{ - return (size_t) MemPtrSize(ptr); -} - -/* * This is the real entrypoint for Tapwave Native Application. It * depends on various CodeWarrior 9.2 compiler/linker/runtime features. */ diff --git a/backends/platform/PalmOS/Src/os5_event.cpp b/backends/platform/PalmOS/Src/os5_event.cpp index 8af2a717a7..85a3b49426 100644 --- a/backends/platform/PalmOS/Src/os5_event.cpp +++ b/backends/platform/PalmOS/Src/os5_event.cpp @@ -37,19 +37,12 @@ void OSystem_PalmOS5::get_coordinates(EventPtr ev, Coord &x, Coord &y) { } } -bool OSystem_PalmOS5::check_event(Event &event, EventPtr ev) { +bool OSystem_PalmOS5::check_event(Common::Event &event, EventPtr ev) { if (ev->eType == keyUpEvent) { - switch (ev->data.keyDown.chr) { + switch (ev->data.keyUp.chr) { case vchrHard3: - event.type = Common::EVENT_LBUTTONUP; - event.mouse.x = _mouseCurState.x; - event.mouse.y = _mouseCurState.y; - return true; - case vchrHard4: - event.type = Common::EVENT_RBUTTONUP; - event.mouse.x = _mouseCurState.x; - event.mouse.y = _mouseCurState.y; + // will be handled by hard keys return true; } @@ -59,23 +52,24 @@ bool OSystem_PalmOS5::check_event(Event &event, EventPtr ev) { // hot swap gfx // case 0x1B04: case vchrHard1: - printf("swap\n"); if (OPTIONS_TST(kOptCollapsible)) hotswap_gfx_mode(_mode == GFX_WIDE ? GFX_NORMAL: GFX_WIDE); return false; // not a key // case 0x1B05: case vchrHard2: - setFeatureState(kFeatureAspectRatioCorrection, 0); - return false; // not a key + setFeatureState(kFeatureAspectRatioCorrection, 0); + return false; // not a key case vchrHard3: - event.type = Common::EVENT_RBUTTONDOWN; + _keyExtraPressed |= _keyExtra.bitActionA; + event.type = Common::EVENT_LBUTTONDOWN; event.mouse.x = _mouseCurState.x; event.mouse.y = _mouseCurState.y; return true; case vchrHard4: + _keyExtraPressed |= _keyExtra.bitActionB; event.type = Common::EVENT_RBUTTONDOWN; event.mouse.x = _mouseCurState.x; event.mouse.y = _mouseCurState.y; diff --git a/backends/platform/PalmOS/Src/os5_gfx.cpp b/backends/platform/PalmOS/Src/os5_gfx.cpp index 295c753604..c68e5ea8c7 100644 --- a/backends/platform/PalmOS/Src/os5_gfx.cpp +++ b/backends/platform/PalmOS/Src/os5_gfx.cpp @@ -28,11 +28,6 @@ #include <PenInputMgr.h> #include <palmOneResources.h> -#ifdef PALMOS_ARM -#include <System/WIP.h> -#include <Libraries/AIA/palmOneStatusBarMgrARM.h> -#endif - #include "oscalls.h" void OSystem_PalmOS5::int_initSize(uint w, uint h) { @@ -63,8 +58,6 @@ void OSystem_PalmOS5::load_gfx_mode() { _ratio.width = (gVars->screenFullHeight * _screenWidth / _screenHeight); _ratio.height = (gVars->screenFullWidth * _screenHeight / _screenWidth); - _mouseBackupP = (byte *)MemPtrNew(MAX_MOUSE_W * MAX_MOUSE_H * 2); // *2 if 16bit - _mouseDataP = (byte *)MemPtrNew(MAX_MOUSE_W * MAX_MOUSE_H); _offScreenP = (byte *)malloc(_screenWidth * _screenHeight); MemSet(_offScreenP, _screenWidth * _screenHeight, 0); @@ -75,6 +68,11 @@ void OSystem_PalmOS5::load_gfx_mode() { WinScreenMode(winScreenModeSet, NULL, NULL, &depth, NULL); clearScreen(); + if (OPTIONS_TST(kOptModeRotatable)) { + _sysOldOrientation = __68K(SysGetOrientation()); + __68K(SysSetOrientation(sysOrientationLandscape)); + } + gVars->indicator.on = RGBToColor(0,255,0); gVars->indicator.off = RGBToColor(0,0,0); @@ -97,13 +95,6 @@ void OSystem_PalmOS5::hotswap_gfx_mode(int mode) { if (_mode != GFX_NORMAL && !_isSwitchable) return; -#ifdef PALMOS_ARM - UInt32 device; - Boolean isT3 = false; - if (!FtrGet(sysFileCSystem, sysFtrNumOEMDeviceID, &device)) - isT3 = (device == kPalmOneDeviceIDTungstenT3); -#endif - if (_workScreenH) WinDeleteWindow(_workScreenH, false); _workScreenH = NULL; @@ -117,17 +108,9 @@ void OSystem_PalmOS5::hotswap_gfx_mode(int mode) { _stretched = (_screenWidth > gVars->screenWidth); if (OPTIONS_TST(kOptCollapsible)) { -#ifdef PALMOS_ARM - if (isT3) { - //AiaSetInputAreaState(aiaInputAreaShow); - StatShow_68k(); - PINSetInputAreaState_68k(pinInputAreaOpen); - } else -#endif - { - StatShow(); - PINSetInputAreaState(pinInputAreaOpen); - } + //AiaSetInputAreaState(aiaInputAreaShow); // For T3 ?? + __68K(StatShow()); + __68K(PINSetInputAreaState(pinInputAreaOpen)); } if (_stretched) { @@ -143,18 +126,10 @@ void OSystem_PalmOS5::hotswap_gfx_mode(int mode) { _stretched = true; if (OPTIONS_TST(kOptCollapsible)) { -#ifdef PALMOS_ARM // T3 DIA library is 68k base, there is no possible native call - if (isT3) { - //AiaSetInputAreaState(aiaInputAreaFullScreen); - PINSetInputAreaState_68k(pinInputAreaClosed); - StatHide_68k(); - } else -#endif - { - PINSetInputAreaState(pinInputAreaClosed); - StatHide(); - } + //AiaSetInputAreaState(aiaInputAreaFullScreen); + __68K(PINSetInputAreaState(pinInputAreaClosed)); + __68K(StatHide()); } calc_rect(true); @@ -182,8 +157,7 @@ void OSystem_PalmOS5::unload_gfx_mode() { return; _gfxLoaded = false; - MemPtrFree(_mouseBackupP); - MemPtrFree(_mouseDataP); + // mouse data freed in quit() free(_offScreenP); if (_workScreenH) @@ -198,6 +172,9 @@ void OSystem_PalmOS5::unload_gfx_mode() { WinScreenMode(winScreenModeSet, NULL, NULL, &depth, NULL); clearScreen(); + if (OPTIONS_TST(kOptModeRotatable)) + __68K(SysSetOrientation(_sysOldOrientation)); + WinSetCoordinateSystem(_sysOldCoord); } diff --git a/backends/platform/PalmOS/Src/os5_mouse.cpp b/backends/platform/PalmOS/Src/os5_mouse.cpp index 20e725694c..a0b372bfad 100644 --- a/backends/platform/PalmOS/Src/os5_mouse.cpp +++ b/backends/platform/PalmOS/Src/os5_mouse.cpp @@ -37,130 +37,86 @@ void OSystem_PalmOS5::disableCursorPalette(bool disable) { _cursorPaletteDisabled = disable; } -void OSystem_PalmOS5::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) { - if (w == 0 || h == 0) - return; - -FIXME: The restriction on MAX_MOUSE_H / MAX_MOUSE_W is obsolete; -in particular, BS2 might use bigger cursors these days. -See also bug #1609058. 1607180 -Hence this code now might overwrite memory unchecked; at the -very least an assert should be inserted to cause a controlled -crash, but of course it would be better to remove the restriction -on "small" cursors. - - - _mouseCurState.w = w; - _mouseCurState.h = h; - - _mouseHotspotX = hotspotX; - _mouseHotspotY = hotspotY; - - _mouseKeyColor = keycolor; - - // copy new cursor - byte *dst = _mouseDataP; - memset(dst, MAX_MOUSE_W * MAX_MOUSE_H, keycolor); - while (h--) { - memcpy(dst, buf, w); - dst += MAX_MOUSE_W; - buf += w; - } -} - +// TODO: this code is almost the same as Zodiac version. void OSystem_PalmOS5::draw_mouse() { - if (_mouseDrawn || !_mouseVisible) + if (!_mouseDataP || _mouseDrawn || !_mouseVisible) return; - - byte *src = _mouseDataP; // Image representing the mouse - byte color; - int width; - - _mouseCurState.y = _mouseCurState.y >= _screenHeight ? _screenHeight - 1 : _mouseCurState.y; + + byte *src = _mouseDataP; int x = _mouseCurState.x - _mouseHotspotX; int y = _mouseCurState.y - _mouseHotspotY; int w = _mouseCurState.w; int h = _mouseCurState.h; - int draw_x = x; - int draw_y = y; - // clip the mouse rect - if (x < 0) { - w += x; - src -= x; - x = 0; - } if (y < 0) { + src -= y * w; h += y; - src -= y * MAX_MOUSE_W; y = 0; } - if (w > _screenWidth - x) - w = _screenWidth - x; + if (x < 0) { + src -= x; + w += x; + x = 0; + } + if (h > _screenHeight - y) h = _screenHeight - y; + if (w > _screenWidth - x) + w = _screenWidth - x; - // Quick check to see if anything has to be drawn at all if (w <= 0 || h <= 0) return; - // Store the bounding box so that undraw mouse can restore the area the - // mouse currently covers to its original content. + // store the bounding box so that undraw mouse can restore the area the + // mouse currently covers to its original content _mouseOldState.x = x; _mouseOldState.y = y; _mouseOldState.w = w; _mouseOldState.h = h; - // Quick check to see if anything has to be drawn at all - if (w <= 0 || h <= 0) - return; - - // Store the bounding box so that undraw mouse can restore the area the - // mouse currently covers to its original content. - _mouseOldState.x = x; - _mouseOldState.y = y; - _mouseOldState.w = w; - _mouseOldState.h = h; + byte color; + int ww; - // Backup the covered area draw the mouse cursor if (_overlayVisible) { - int16 *bak = (int16 *)_mouseBackupP; // Surface used to backup the area obscured by the mouse - int16 *dst = _overlayP + y * _screenWidth + x; + int16 *bak = (int16 *)_mouseBackupP; int16 *pal = _cursorPaletteDisabled ? _nativePal : _mousePal; + int16 *dst = _overlayP + y * _screenWidth + x; do { - width = w; + ww = w; do { *bak++ = *dst; color = *src++; - if (color != _mouseKeyColor) // transparent, don't draw + + // transparent, don't draw + if (color != _mouseKeyColor) *dst = pal[color]; dst++; - } while (--width); + } while (--ww); - src += MAX_MOUSE_W - w; - bak += MAX_MOUSE_W - w; + src += _mouseCurState.w - w; dst += _screenWidth - w; } while (--h); } else { - byte *bak = _mouseBackupP; // Surface used to backup the area obscured by the mouse - byte *dst =_offScreenP + y * _screenWidth + x; // Surface we are drawing into + byte *bak = _mouseBackupP; + byte *dst =_offScreenP + y * _screenWidth + x; do { - width = w; + ww = w; do { *bak++ = *dst; color = *src++; - if (color != _mouseKeyColor) // transparent, don't draw + + // transparent, don't draw + if (color != _mouseKeyColor) *dst = color; dst++; - } while (--width); + } while (--ww); - src += MAX_MOUSE_W - w; - bak += MAX_MOUSE_W - w; + src += _mouseCurState.w - w; dst += _screenWidth - w; } while (--h); } @@ -173,27 +129,28 @@ void OSystem_PalmOS5::undraw_mouse() { return; int h = _mouseOldState.h; - // No need to do clipping here, since draw_mouse() did that already + + // no need to do clipping here, since draw_mouse() did that already if (_overlayVisible) { - int16 *bak = (int16 *)_mouseBackupP; int16 *dst = _overlayP + _mouseOldState.y * _screenWidth + _mouseOldState.x; + int16 *bak = (int16 *)_mouseBackupP; do { - memcpy(dst, bak, _mouseOldState.w * 2); - bak += MAX_MOUSE_W; + MemMove(dst, bak, _mouseOldState.w * 2); dst += _screenWidth; + bak += _mouseOldState.w; } while (--h); } else { - byte *dst, *bak = _mouseBackupP; - dst = _offScreenP + _mouseOldState.y * _screenWidth + _mouseOldState.x; + byte *dst = _offScreenP + _mouseOldState.y * _screenWidth + _mouseOldState.x; + byte *bak = _mouseBackupP; do { - memcpy(dst, bak, _mouseOldState.w); - bak += MAX_MOUSE_W; + MemMove(dst, bak, _mouseOldState.w); dst += _screenWidth; + bak += _mouseOldState.w; } while (--h); } _mouseDrawn = false; -} +}
\ No newline at end of file diff --git a/backends/platform/PalmOS/Src/os5_overlay.cpp b/backends/platform/PalmOS/Src/os5_overlay.cpp index 93c6123cef..0eee6d167b 100644 --- a/backends/platform/PalmOS/Src/os5_overlay.cpp +++ b/backends/platform/PalmOS/Src/os5_overlay.cpp @@ -31,7 +31,7 @@ void OSystem_PalmOS5::showOverlay() { undraw_mouse(); _overlayVisible = true; - clearOverlay(); + clearOverlay(); } void OSystem_PalmOS5::hideOverlay() { diff --git a/backends/platform/PalmOS/Src/os5_sound.cpp b/backends/platform/PalmOS/Src/os5_sound.cpp index 4bdded13e7..7af173036f 100644 --- a/backends/platform/PalmOS/Src/os5_sound.cpp +++ b/backends/platform/PalmOS/Src/os5_sound.cpp @@ -134,7 +134,7 @@ void OSystem_PalmOS5::clearSoundCallback() { } if (_soundEx.dataP) - free(_soundEx.dataP); + MemPtrFree(_soundEx.dataP); } _sound.active = false; diff --git a/backends/platform/PalmOS/Src/palmversion.h b/backends/platform/PalmOS/Src/palmversion.h deleted file mode 100644 index d4362ddd61..0000000000 --- a/backends/platform/PalmOS/Src/palmversion.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef PALMVERSION_H -#define PALMVERSION_H - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(COMPILE_ZODIAC) -# include <tapwave.h> -#else -# include <PalmOS.h> -# include <VFSMgr.h> -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/backends/platform/PalmOS/Src/prefixes/compile.h b/backends/platform/PalmOS/Src/prefixes/compile.h index f54a56d2ca..f8c5ca1cbf 100644 --- a/backends/platform/PalmOS/Src/prefixes/compile.h +++ b/backends/platform/PalmOS/Src/prefixes/compile.h @@ -43,6 +43,7 @@ #define DISABLE_AGI #define DISABLE_TOUCHE #define DISABLE_PARALLACTION +#define DISABLE_CRUISE // ScummVM #define DISABLE_HQ_SCALERS @@ -50,23 +51,24 @@ //#define CT_NO_TRANSPARENCY //#define REDUCE_MEMORY_USAGE -// PalmOS -//#define STDLIB_TRACE_MEMORY -//#define _DEBUG - -#define PALMOS_MODE -//#define COMPILE_ZODIAC -#define COMPILE_OS5 +#include "compile_base.h" //#define DISABLE_ADLIB //#define DISABLE_LIGHTSPEED #ifdef COMPILE_ZODIAC -# define DISABLE_SONY +# undef DISABLE_FANCY_THEMES +# define USE_ZLIB +// set an external ZLIB since save/load implementation +// doesn't support built-in zodiac version which is 1.1.4 +// (seen inflateInit2 which err on "MAX_WBITS + 32") +# define USE_ZLIB_EXTERNAL +# define DISABLE_SONY #endif #ifdef COMPILE_OS5 -# define DISABLE_TAPWAVE +# define DISABLE_TAPWAVE +# define USE_ZLIB #endif #endif diff --git a/backends/platform/PalmOS/Src/prefixes/native_agi.h b/backends/platform/PalmOS/Src/prefixes/native_agi.h index 496cf7c85b..790f108efa 100644 --- a/backends/platform/PalmOS/Src/prefixes/native_agi.h +++ b/backends/platform/PalmOS/Src/prefixes/native_agi.h @@ -4,4 +4,8 @@ #include "native_common.h" #undef DISABLE_AGI +#undef USE_MAD +#undef USE_VORBIS +#undef USE_TREMOR + #endif diff --git a/backends/platform/PalmOS/Src/prefixes/native_cine.h b/backends/platform/PalmOS/Src/prefixes/native_cine.h index 212a5544d0..bacdfa2047 100644 --- a/backends/platform/PalmOS/Src/prefixes/native_cine.h +++ b/backends/platform/PalmOS/Src/prefixes/native_cine.h @@ -3,5 +3,10 @@ #include "native_common.h" #undef DISABLE_CINE +#define _DEBUG + +#undef USE_MAD +#undef USE_VORBIS +#undef USE_TREMOR #endif diff --git a/backends/platform/PalmOS/Src/prefixes/native_common.h b/backends/platform/PalmOS/Src/prefixes/native_common.h index c04f5e1538..af4db70932 100644 --- a/backends/platform/PalmOS/Src/prefixes/native_common.h +++ b/backends/platform/PalmOS/Src/prefixes/native_common.h @@ -2,8 +2,6 @@ #define ZNATIVE_COMMON_H #include "compile.h" -#include "palmmad.h" -#include "palmtremor.h" #define __TWNEW_H__ @@ -12,7 +10,7 @@ #define USE_MAD #define USE_TREMOR -//#define USE_VORBIS +#define USE_VORBIS //#define USE_MPEG2 // enable assert diff --git a/backends/platform/PalmOS/Src/prefixes/native_cruise.h b/backends/platform/PalmOS/Src/prefixes/native_cruise.h new file mode 100755 index 0000000000..9bc0cdac13 --- /dev/null +++ b/backends/platform/PalmOS/Src/prefixes/native_cruise.h @@ -0,0 +1,11 @@ +#ifndef PREFIX_H +#define PREFIX_H + +#include "native_common.h" +#undef DISABLE_CRUISE + +#undef USE_MAD +#undef USE_VORBIS +#undef USE_TREMOR + +#endif diff --git a/backends/platform/PalmOS/Src/prefixes/native_lure.h b/backends/platform/PalmOS/Src/prefixes/native_lure.h index 1d9005045c..b017c46fe6 100644 --- a/backends/platform/PalmOS/Src/prefixes/native_lure.h +++ b/backends/platform/PalmOS/Src/prefixes/native_lure.h @@ -4,4 +4,8 @@ #include "native_common.h" #undef DISABLE_LURE +#undef USE_MAD +#undef USE_VORBIS +#undef USE_TREMOR + #endif diff --git a/backends/platform/PalmOS/Src/prefixes/native_parallaction.h b/backends/platform/PalmOS/Src/prefixes/native_parallaction.h new file mode 100755 index 0000000000..545cdd36fd --- /dev/null +++ b/backends/platform/PalmOS/Src/prefixes/native_parallaction.h @@ -0,0 +1,11 @@ +#ifndef PREFIX_H +#define PREFIX_H + +#include "native_common.h" +#undef DISABLE_PARALLACTION + +#undef USE_MAD +#undef USE_VORBIS +#undef USE_TREMOR + +#endif diff --git a/backends/platform/PalmOS/Src/prefixes/prefix_frontend.h b/backends/platform/PalmOS/Src/prefixes/prefix_frontend.h index 6c7d749539..8473214746 100644 --- a/backends/platform/PalmOS/Src/prefixes/prefix_frontend.h +++ b/backends/platform/PalmOS/Src/prefixes/prefix_frontend.h @@ -3,6 +3,7 @@ #define PALMOS_68K #define PALMOS_MODE + //#define _DEBUG_ENGINE #endif diff --git a/backends/platform/PalmOS/Src/stuffs.h b/backends/platform/PalmOS/Src/stuffs.h index b6f5a3f38b..25bf17c8c6 100644 --- a/backends/platform/PalmOS/Src/stuffs.h +++ b/backends/platform/PalmOS/Src/stuffs.h @@ -19,6 +19,7 @@ enum { kOptSonyPa1LibAPI = 1 << 0x0D, kOptGoLcdAPI = 1 << 0x0E, kOptLightspeedAPI = 1 << 0x0F, + kOptModeRotatable = 1 << 0x10, kOptDeviceProcX86 = 1 << 0x1F // DEBUG only }; diff --git a/backends/platform/PalmOS/Src/zodiac_gfx.cpp b/backends/platform/PalmOS/Src/zodiac_gfx.cpp index d14f745657..c84a6af056 100644 --- a/backends/platform/PalmOS/Src/zodiac_gfx.cpp +++ b/backends/platform/PalmOS/Src/zodiac_gfx.cpp @@ -56,11 +56,9 @@ void OSystem_PalmZodiac::load_gfx_mode() { _ratio.adjustAspect = ConfMan.getBool("aspect_ratio") ? kRatioHeight : kRatioNone; // precalc ratio (WIDE mode) - _ratio.width = ((float)_screenWidth / _screenHeight * gVars->screenFullHeight); - _ratio.height = ((float)_screenHeight / _screenWidth * gVars->screenFullWidth); + _ratio.width = (gVars->screenFullHeight * _screenWidth / _screenHeight); + _ratio.height = (gVars->screenFullWidth * _screenHeight / _screenWidth); - _mouseBackupP = (byte *)MemPtrNew(MAX_MOUSE_W * MAX_MOUSE_H * 2); // *2 if 16bit - _mouseDataP = (byte *)MemPtrNew(MAX_MOUSE_W * MAX_MOUSE_H); _offScreenP = (byte *)MemPtrNew(_screenWidth * _screenHeight); MemSet(_offScreenP, _screenWidth * _screenHeight, 0); @@ -98,7 +96,7 @@ void OSystem_PalmZodiac::load_gfx_mode() { _srcBmp.rowBytes = _screenWidth; _srcBmp.pixelFormat = twGfxPixelFormat8bpp; _srcBmp.data = _offScreenP; - _srcBmp.palette = _nativePal; + _srcBmp.palette = (UInt16 *)_nativePal; _srcRect.x = 0; _srcRect.y = 0; @@ -192,8 +190,6 @@ void OSystem_PalmZodiac::unload_gfx_mode() { WinScreenMode(winScreenModeSet, NULL, NULL, &depth, NULL); clearScreen(); - MemPtrFree(_mouseBackupP); - MemPtrFree(_mouseDataP); MemPtrFree(_offScreenP); SysSetOrientation(_sysOldOrientation); @@ -217,7 +213,8 @@ void OSystem_PalmZodiac::updateScreen() { Err e; // draw the mouse pointer - draw_mouse(); + draw_mouse(); + // update the screen if (_overlayVisible) { if (_stretched) { @@ -247,6 +244,7 @@ void OSystem_PalmZodiac::updateScreen() { dst.y += _new_shake_pos; } e = TwGfxDrawBitmap(_tmpScreenP, &pos, &_srcBmp); + e = TwGfxWaitForVBlank(_gfxH); e = TwGfxStretchBlt2(_palmScreenP, &dst, _tmpScreenP, &_srcRect, twGfxStretchFast| (gVars->filter ? twGfxStretchSmooth : 0)); } else { @@ -264,13 +262,11 @@ void OSystem_PalmZodiac::updateScreen() { e = TwGfxDrawBitmap(_palmScreenP, &pos, &_srcBmp); } } + + // undraw the mouse undraw_mouse(); } -void OSystem_PalmZodiac::extras_palette(uint8 index, uint8 r, uint8 g, uint8 b) { - _nativePal[index] = TwGfxMakeDisplayRGB(r, g, b); -} - void OSystem_PalmZodiac::draw_osd(UInt16 id, Int32 x, Int32 y, Boolean show, UInt8 color) { if (_mode != GFX_NORMAL) return; diff --git a/backends/platform/PalmOS/Src/zodiac_mouse.cpp b/backends/platform/PalmOS/Src/zodiac_mouse.cpp index bd68be1ae7..52e2261e44 100644 --- a/backends/platform/PalmOS/Src/zodiac_mouse.cpp +++ b/backends/platform/PalmOS/Src/zodiac_mouse.cpp @@ -24,100 +24,90 @@ #include "be_zodiac.h" -void OSystem_PalmZodiac::setCursorPalette(const byte *colors, uint start, uint num) { - for(uint i = 0; i < num; i++) { - _mousePal[i + start] = TwGfxMakeDisplayRGB(colors[0], colors[1], colors[2]); - colors += 4; - } - _cursorPaletteDisabled = false; -} - void OSystem_PalmZodiac::draw_mouse() { - if (_mouseDrawn || !_mouseVisible) + if (!_mouseDataP || _mouseDrawn || !_mouseVisible) return; - - byte *src = _mouseDataP; // Image representing the mouse - byte color; - int width; - - _mouseCurState.y = _mouseCurState.y >= _screenHeight ? _screenHeight - 1 : _mouseCurState.y; + + byte *src = _mouseDataP; int x = _mouseCurState.x - _mouseHotspotX; int y = _mouseCurState.y - _mouseHotspotY; int w = _mouseCurState.w; int h = _mouseCurState.h; - int draw_x = x; - int draw_y = y; - // clip the mouse rect - if (x < 0) { - w += x; - src -= x; - x = 0; - } if (y < 0) { + src -= y * w; h += y; - src -= y * MAX_MOUSE_W; y = 0; } - if (w > _screenWidth - x) - w = _screenWidth - x; + if (x < 0) { + src -= x; + w += x; + x = 0; + } + if (h > _screenHeight - y) h = _screenHeight - y; + if (w > _screenWidth - x) + w = _screenWidth - x; - // Quick check to see if anything has to be drawn at all if (w <= 0 || h <= 0) return; - // Store the bounding box so that undraw mouse can restore the area the - // mouse currently covers to its original content. + // store the bounding box so that undraw mouse can restore the area the + // mouse currently covers to its original content _mouseOldState.x = x; _mouseOldState.y = y; _mouseOldState.w = w; _mouseOldState.h = h; - // Backup the covered area draw the mouse cursor + byte color; + int ww; + if (_overlayVisible) { - uint16 *bak = (uint16 *)_mouseBackupP; // Surface used to backup the area obscured by the mouse - uint16 *dst, *pal = _cursorPaletteDisabled ? _nativePal : _mousePal; + int16 *bak = (int16 *)_mouseBackupP; + int16 *pal = _cursorPaletteDisabled ? _nativePal : _mousePal; + int16 *dst; TwGfxLockSurface(_overlayP, (void **)&dst); dst += y * _screenWidth + x; do { - width = w; + ww = w; do { *bak++ = *dst; color = *src++; - if (color != _mouseKeyColor) // transparent, don't draw + + // transparent, don't draw + if (color != _mouseKeyColor) *dst = pal[color]; dst++; - } while (--width); + } while (--ww); - src += MAX_MOUSE_W - w; - bak += MAX_MOUSE_W - w; + src += _mouseCurState.w - w; dst += _screenWidth - w; } while (--h); TwGfxUnlockSurface(_overlayP, true); } else { - byte *bak = _mouseBackupP; // Surface used to backup the area obscured by the mouse - byte *dst =_offScreenP + y * _screenWidth + x; // Surface we are drawing into + byte *bak = _mouseBackupP; + byte *dst =_offScreenP + y * _screenWidth + x; do { - width = w; + ww = w; do { *bak++ = *dst; color = *src++; - if (color != _mouseKeyColor) // transparent, don't draw + + // transparent, don't draw + if (color != _mouseKeyColor) *dst = color; dst++; - } while (--width); + } while (--ww); - src += MAX_MOUSE_W - w; - bak += MAX_MOUSE_W - w; + src += _mouseCurState.w - w; dst += _screenWidth - w; } while (--h); } @@ -130,30 +120,31 @@ void OSystem_PalmZodiac::undraw_mouse() { return; int h = _mouseOldState.h; - // No need to do clipping here, since draw_mouse() did that already + + // no need to do clipping here, since draw_mouse() did that already if (_overlayVisible) { - uint16 *bak = (uint16 *)_mouseBackupP; uint16 *dst; + uint16 *bak = (uint16 *)_mouseBackupP; TwGfxLockSurface(_overlayP, (void **)&dst); dst += _mouseOldState.y * _screenWidth + _mouseOldState.x; do { - memcpy(dst, bak, _mouseOldState.w * 2); - bak += MAX_MOUSE_W; + MemMove(dst, bak, _mouseOldState.w * 2); dst += _screenWidth; + bak += _mouseOldState.w; } while (--h); TwGfxUnlockSurface(_overlayP, true); } else { - byte *dst, *bak = _mouseBackupP; - dst = _offScreenP + _mouseOldState.y * _screenWidth + _mouseOldState.x; - + byte *dst = _offScreenP + _mouseOldState.y * _screenWidth + _mouseOldState.x; + byte *bak = _mouseBackupP; + do { - memcpy(dst, bak, _mouseOldState.w); - bak += MAX_MOUSE_W; + MemMove(dst, bak, _mouseOldState.w); dst += _screenWidth; + bak += _mouseOldState.w; } while (--h); } diff --git a/backends/platform/PalmOS/Src/zodiac_overlay.cpp b/backends/platform/PalmOS/Src/zodiac_overlay.cpp index d1b2f7a558..09385c110a 100644 --- a/backends/platform/PalmOS/Src/zodiac_overlay.cpp +++ b/backends/platform/PalmOS/Src/zodiac_overlay.cpp @@ -34,7 +34,7 @@ void OSystem_PalmZodiac::clearOverlay() { TwGfxBitmapType bmp = { sizeof(TwGfxBitmapType), _screenWidth, _screenHeight, _screenWidth, twGfxPixelFormat8bpp, - (void *)_offScreenP, _nativePal + (void *)_offScreenP, (UInt16 *)_nativePal }; e = TwGfxDrawBitmap(_overlayP, &pos, &bmp); } diff --git a/backends/platform/PalmOS/scummvm.mcp b/backends/platform/PalmOS/scummvm.mcp Binary files differindex 286eec33bb..5dca766c86 100644 --- a/backends/platform/PalmOS/scummvm.mcp +++ b/backends/platform/PalmOS/scummvm.mcp diff --git a/backends/platform/dc/portdefs.h b/backends/platform/dc/portdefs.h index cedfd5c0fe..08bc900e6e 100644 --- a/backends/platform/dc/portdefs.h +++ b/backends/platform/dc/portdefs.h @@ -37,3 +37,6 @@ #ifdef Timer #undef Timer #endif +/* newlib ctype.h defines _X for hex digit flag. + This conflicts with the use of _X as a variable name. */ +#undef _X diff --git a/backends/platform/ds/arm9/source/blitters.cpp b/backends/platform/ds/arm9/source/blitters.cpp index 7d1e0e4402..ec33a5aab4 100644 --- a/backends/platform/ds/arm9/source/blitters.cpp +++ b/backends/platform/ds/arm9/source/blitters.cpp @@ -19,8 +19,11 @@ */ #include "stdafx.h" +#include "blitters.h" #define CHARSET_MASK_TRANSPARENCY 253 +//#define PERFECT_5_TO_4_RESCALING + namespace DS { void asmDrawStripToScreen(int height, int width, byte const* text, byte const* src, byte* dst, @@ -149,6 +152,7 @@ void ComputeDivBy5TableIFN() } } +#ifdef PERFECT_5_TO_4_RESCALING static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3, u16 s4, u16* dest) { @@ -223,6 +227,44 @@ static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3 ((u32*)dest)[0] = d10; ((u32*)dest)[1] = d32; } +#else +static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3, u16 s4, + u16* dest) +{ + u32 ar0bs0 = s0 & 0x7C1F; + u32 ar0bs1 = s1 & 0x7C1F; + u32 ar0bs2 = s2 & 0x7C1F; + u32 ar0bs3 = s3 & 0x7C1F; + u32 ar0bs4 = s4 & 0x7C1F; + + u32 gs0 = s0 & 0x03E0; + u32 gs1 = s1 & 0x03E0; + u32 gs2 = s2 & 0x03E0; + u32 gs3 = s3 & 0x03E0; + u32 gs4 = s4 & 0x03E0; + + u32 ar0bd0 = (3*ar0bs0 + ar0bs1) >> 2; + u32 ar0bd1 = ( ar0bs1 + ar0bs2) >> 1; + u32 ar0bd2 = ( ar0bs2 + ar0bs3) >> 1; + u32 ar0bd3 = ( ar0bs3 + 3*ar0bs4) >> 2; + + u32 gd0 = (3*gs0 + gs1) >> 2; + u32 gd1 = ( gs1 + gs2) >> 1; + u32 gd2 = ( gs2 + gs3) >> 1; + u32 gd3 = ( gs3 + 3*gs4) >> 2; + + u32 d0 = (ar0bd0 & 0xFC1F) | (gd0 & 0x03E0); + u32 d1 = (ar0bd1 & 0xFC1F) | (gd1 & 0x03E0); + u32 d2 = (ar0bd2 & 0xFC1F) | (gd2 & 0x03E0); + u32 d3 = (ar0bd3 & 0xFC1F) | (gd3 & 0x03E0); + + u32 d10 = 0x80008000 | (d1 << 16) | d0; + u32 d32 = 0x80008000 | (d3 << 16) | d2; + + ((u32*)dest)[0] = d10; + ((u32*)dest)[1] = d32; +} +#endif static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3, u32 s4, u16* dest) @@ -262,6 +304,7 @@ static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3 } // Can't work in place +#ifdef PERFECT_5_TO_4_RESCALING static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16* dest, const u8* src, const u32* palette) { ComputeDivBy5TableIFN(); @@ -277,6 +320,21 @@ static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16* dest, const RescaleBlock_5x8888_To_4x1555(s0, s1, s2, s3, s4, dest+4*i); } } +#else +static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16* dest, const u8* src, const u16* palette) +{ + for(size_t i=0; i<64; ++i) + { + u16 s0 = palette[src[5*i+0]]; + u16 s1 = palette[src[5*i+1]]; + u16 s2 = palette[src[5*i+2]]; + u16 s3 = palette[src[5*i+3]]; + u16 s4 = palette[src[5*i+4]]; + + RescaleBlock_5x1555_To_4x1555(s0, s1, s2, s3, s4, dest+4*i); + } +} +#endif // Can work in place, because it's a contraction @@ -296,6 +354,7 @@ static inline void Rescale_320x1555Scanline_To_256x1555Scanline(u16* dest, const } } +#ifdef PERFECT_5_TO_4_RESCALING void Rescale_320x256xPAL8_To_256x256x1555(u16* dest, const u8* src, const u16* palette, int destStride, int srcStride) { u32 fastRam[768]; @@ -316,6 +375,19 @@ void Rescale_320x256xPAL8_To_256x256x1555(u16* dest, const u8* src, const u16* p Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, fastRam); } } +#else +void Rescale_320x256xPAL8_To_256x256x1555(u16* dest, const u8* src, const u16* palette, int destStride, int srcStride) +{ + u16 fastRam[256]; + for(size_t i=0; i<128; ++i) + ((u32*)fastRam)[i] = ((const u32*)palette)[i]; + + for(size_t i=0; i<200; ++i) + { + Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, fastRam); + } +} +#endif void Rescale_320x256x1555_To_256x256x1555(u16* dest, const u16* src, int destStride, int srcStride) { diff --git a/backends/platform/ds/arm9/source/fat/disc_io.c b/backends/platform/ds/arm9/source/fat/disc_io.c index 3cb70f510b..c706cf8b3e 100644 --- a/backends/platform/ds/arm9/source/fat/disc_io.c +++ b/backends/platform/ds/arm9/source/fat/disc_io.c @@ -358,7 +358,7 @@ void disc_getDldiId(char* id) { bool disc_setDsSlotInterface (void) { #ifdef ARM9 - REG_EXEMEMCNT &= ~(1<<11); + REG_EXMEMCNT &= ~(1<<11); #endif #ifdef ARM7 REG_EXEMEMCNT |= (1<<11); diff --git a/backends/platform/ds/arm9/source/fat/io_dldi.h b/backends/platform/ds/arm9/source/fat/io_dldi.h index 053de3a94c..86c3407374 100644 --- a/backends/platform/ds/arm9/source/fat/io_dldi.h +++ b/backends/platform/ds/arm9/source/fat/io_dldi.h @@ -30,7 +30,7 @@ extern u8 _dldi_driver_name; static inline LPIO_INTERFACE DLDI_GetInterface(void) { #ifdef NDS // NDM: I'm really not sure about this change ARM9 - ARM7 - REG_EXEMEMCNT &= ~(ARM7_OWNS_ROM | ARM7_OWNS_CARD); + REG_EXMEMCNT &= ~(ARM7_OWNS_ROM | ARM7_OWNS_CARD); #endif // defined NDS return &_io_dldi; } diff --git a/backends/platform/gp2x/build/scummvm.gpe b/backends/platform/gp2x/build/scummvm.gpe new file mode 100644 index 0000000000..1e69c149b9 --- /dev/null +++ b/backends/platform/gp2x/build/scummvm.gpe @@ -0,0 +1,14 @@ +#!/bin/bash + +# Remount SD with forced Sync, does this really work? +mount -o sync,remount /dev/mmcsd/disc0/part1 /mnt/sd/ + +# Run ScummVM, important this bit. +./scummvm.gp2x + +# Sync the SD card to check that everything is written. +sync + +# Return to the GPH menu screen +cd /usr/gp2x +exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gp32/startup.c b/backends/platform/gp32/startup.c index b12cf3f077..6f74241e09 100644 --- a/backends/platform/gp32/startup.c +++ b/backends/platform/gp32/startup.c @@ -87,7 +87,7 @@ int main (int arg_len, char * arg_v) GpKernelStart (); GpAppExit (); - while (1) {}; + while (1) {} } void InitializeFont (void) diff --git a/backends/platform/maemo/maemo-sdl.h b/backends/platform/maemo/maemo-sdl.h index e342ead5f9..e497c2597d 100644 --- a/backends/platform/maemo/maemo-sdl.h +++ b/backends/platform/maemo/maemo-sdl.h @@ -33,7 +33,7 @@ class OSystem_MAEMO : public OSystem_SDL { public: - OSystem_MAEMO() {}; + OSystem_MAEMO() {} void loadGFXMode(); }; diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp index c13e8e56ff..cfccdb0531 100644 --- a/backends/platform/null/null.cpp +++ b/backends/platform/null/null.cpp @@ -21,8 +21,8 @@ */ #include "common/stdafx.h" -#include "common/scummsys.h" #include "common/system.h" +#include "base/main.h" #if defined(USE_NULL_DRIVER) @@ -51,13 +51,16 @@ public: virtual const GraphicsMode *getSupportedGraphicsModes() const; virtual int getDefaultGraphicsMode() const; bool setGraphicsMode(const char *name); + virtual bool setGraphicsMode(int mode); virtual int getGraphicsMode() const; virtual void initSize(uint width, uint height); virtual int16 getHeight(); virtual int16 getWidth(); virtual void setPalette(const byte *colors, uint start, uint num); + virtual void grabPalette(byte *colors, uint start, uint num); virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); virtual void updateScreen(); + virtual bool grabRawScreen(Graphics::Surface *surf); virtual void setShakePos(int shakeOffset); virtual void showOverlay(); @@ -74,7 +77,7 @@ public: virtual bool showMouse(bool visible); virtual void warpMouse(int x, int y); - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255); + virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int cursorTargetScale = 1); virtual bool pollEvent(Common::Event &event); virtual uint32 getMillis(); @@ -85,15 +88,11 @@ public: virtual void unlockMutex(MutexRef mutex); virtual void deleteMutex(MutexRef mutex); + typedef void (*SoundProc)(void *param, byte *buf, int len); + virtual bool setSoundCallback(SoundProc proc, void *param); + virtual void clearSoundCallback(); virtual int getOutputSampleRate() const; - virtual bool openCD(int drive); - virtual bool pollCD(); - - virtual void playCD(int track, int num_loops, int start_frame, int duration); - virtual void stopCD(); - virtual void updateCD(); - virtual void quit(); virtual void setWindowCaption(const char *caption); @@ -107,16 +106,6 @@ static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { {0, 0, 0} }; -int main(int argc, char *argv[]) { - g_system = OSystem_NULL_create(); - assert(g_system); - - // Invoke the actual ScummVM main entry point: - int res = scummvm_main(argc, argv); - g_system->quit(); // TODO: Consider removing / replacing this! - return res; -} - OSystem_NULL::OSystem_NULL() { _savefile = 0; _mixer = 0; @@ -161,6 +150,10 @@ int OSystem_NULL::getDefaultGraphicsMode() const { return -1; } +bool OSystem_NULL::setGraphicsMode(const char *mode) { + return true; +} + bool OSystem_NULL::setGraphicsMode(int mode) { return true; } @@ -183,28 +176,36 @@ int16 OSystem_NULL::getWidth() { void OSystem_NULL::setPalette(const byte *colors, uint start, uint num) { } +void OSystem_NULL::grabPalette(byte *colors, uint start, uint num) { + +} + void OSystem_NULL::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { } void OSystem_NULL::updateScreen() { } +bool OSystem_NULL::grabRawScreen(Graphics::Surface *surf) { + return false; +} + void OSystem_NULL::setShakePos(int shakeOffset) { } -void OSystem_NULL::showOverlay () { +void OSystem_NULL::showOverlay() { } -void OSystem_NULL::hideOverlay () { +void OSystem_NULL::hideOverlay() { } -void OSystem_NULL::clearOverlay () { +void OSystem_NULL::clearOverlay() { } -void OSystem_NULL::grabOverlay (OverlayColor *buf, int pitch) { +void OSystem_NULL::grabOverlay(OverlayColor *buf, int pitch) { } -void OSystem_NULL::copyRectToOverlay (const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void OSystem_NULL::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { } int16 OSystem_NULL::getOverlayHeight() { @@ -229,7 +230,7 @@ bool OSystem_NULL::showMouse(bool visible) { void OSystem_NULL::warpMouse(int x, int y) { } -void OSystem_NULL::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor) { +void OSystem_NULL::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) { } bool OSystem_NULL::pollEvent(Common::Event &event) { @@ -273,17 +274,17 @@ void OSystem_NULL::quit() { void OSystem_NULL::setWindowCaption(const char *caption) { } -Common::SaveFileManager *DefaulOSystem::getSavefileManager() { +Common::SaveFileManager *OSystem_NULL::getSavefileManager() { assert(_savefile); return _savefile; } -Audio::Mixer *DefaulOSystem::getMixer() { +Audio::Mixer *OSystem_NULL::getMixer() { assert(_mixer); return _mixer; } -Common::TimerManager *DefaulOSystem::getTimerManager() { +Common::TimerManager *OSystem_NULL::getTimerManager() { assert(_timer); return _timer; } @@ -291,6 +292,17 @@ Common::TimerManager *DefaulOSystem::getTimerManager() { OSystem *OSystem_NULL_create() { return new OSystem_NULL(); } + +int main(int argc, char *argv[]) { + g_system = OSystem_NULL_create(); + assert(g_system); + + // Invoke the actual ScummVM main entry point: + int res = scummvm_main(argc, argv); + g_system->quit(); // TODO: Consider removing / replacing this! + return res; +} + #else /* USE_NULL_DRIVER */ OSystem *OSystem_NULL_create() { diff --git a/backends/platform/ps2/savefile.cpp b/backends/platform/ps2/savefile.cpp index 71073bd23f..9c7d446d83 100644 --- a/backends/platform/ps2/savefile.cpp +++ b/backends/platform/ps2/savefile.cpp @@ -205,9 +205,9 @@ public: AutoSaveFile(Ps2SaveFileManager *saveMan, const char *filename); ~AutoSaveFile(void); virtual uint32 write(const void *ptr, uint32 size); - virtual void flush(void) { }; + virtual void flush(void) {} virtual bool ioFailed(void) { return false; }; - virtual void clearIOFailed(void) {}; + virtual void clearIOFailed(void) {} private: Ps2SaveFileManager *_saveMan; char _fileName[256]; diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index 8d01d0cf6e..772fc0807a 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -63,7 +63,7 @@ static int timer_handler(int t) { const OSystem::GraphicsMode OSystem_PSP::s_supportedGraphicsModes[] = { { "320x200 (centered)", "320x200 16-bit centered", CENTERED_320X200 }, - { "353x272 (best-fit, centered)", "353x272 16-bit centered", CENTERED_435X272 }, + { "435x272 (best-fit, centered)", "435x272 16-bit centered", CENTERED_435X272 }, { "480x272 (full screen)", "480x272 16-bit stretched", STRETCHED_480X272 }, { "362x272 (4:3, centered)", "362x272 16-bit centered", CENTERED_362X272 }, {0, 0, 0} diff --git a/backends/platform/psp/osys_psp_gu.cpp b/backends/platform/psp/osys_psp_gu.cpp index 0a8cd71dda..8baa4e021b 100644 --- a/backends/platform/psp/osys_psp_gu.cpp +++ b/backends/platform/psp/osys_psp_gu.cpp @@ -115,6 +115,8 @@ OSystem_PSP_GU::OSystem_PSP_GU() { _graphicMode = STRETCHED_480X272; _keySelected = 1; _keyboardMode = 0; + _mouseX = PSP_SCREEN_WIDTH >> 1; + _mouseY = PSP_SCREEN_HEIGHT >> 1; } OSystem_PSP_GU::~OSystem_PSP_GU() { @@ -267,8 +269,6 @@ void OSystem_PSP_GU::copyRectToScreen(const byte *buf, int pitch, int x, int y, } void OSystem_PSP_GU::updateScreen() { - float scale; - sceGuStart(0,list); sceGuClearColor(0xff000000); @@ -381,9 +381,14 @@ void OSystem_PSP_GU::updateScreen() { break; case CENTERED_435X272: { - scale = 435.0f / _screenWidth; - vertices[0].x = (PSP_SCREEN_WIDTH - 435) / 2 + mX * scale; vertices[0].y = mY * scale; vertices[0].z = 0; - vertices[1].x = vertices[0].x + _mouseWidth * scale; vertices[1].y = vertices[0].y + _mouseHeight * scale; vertices[0].z = 0; + float scalex, scaley; + + scalex = 435.0f / _screenWidth; + scaley = 272.0f / _screenHeight; + + vertices[0].x = (PSP_SCREEN_WIDTH - 435) / 2 + mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0; + vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0; + } break; case CENTERED_362X272: diff --git a/backends/platform/sdl/sdl-common.h b/backends/platform/sdl/sdl-common.h index 58ebb72bd1..7703a1a511 100644 --- a/backends/platform/sdl/sdl-common.h +++ b/backends/platform/sdl/sdl-common.h @@ -117,7 +117,7 @@ public: void disableCursorPalette(bool disable) { _cursorPaletteDisabled = disable; blitCursor(); - }; + } // Shaking is used in SCUMM. Set current shake position. void setShakePos(int shake_pos); diff --git a/backends/platform/symbian/AdaptAllMMPs.pl b/backends/platform/symbian/AdaptAllMMPs.pl index 1b8e8d126c..a692017d05 100644 --- a/backends/platform/symbian/AdaptAllMMPs.pl +++ b/backends/platform/symbian/AdaptAllMMPs.pl @@ -20,6 +20,7 @@ chdir("../../../"); "mmp/scummvm_agi.mmp", "mmp/scummvm_touche.mmp", "mmp/scummvm_parallaction.mmp", + "mmp/scummvm_cruise.mmp", "S60/ScummVM_S60.mmp", "S60v3/ScummVM_S60v3.mmp", "S80/ScummVM_S80.mmp", @@ -63,14 +64,16 @@ my @excludes_snd = ( "tables.cpp", "freeverb.cpp" ); -my @excludes_gui = ( + +my @excludes_graphics = ( +"iff.cpp" ); #arseModule(mmpStr, dirStr, ifdefArray, [exclusionsArray]) ParseModule("_base", "base", \@section_empty); # now in ./TRG/ScummVM_TRG.mmp, these never change anyways... ParseModule("_base", "common", \@section_empty); -ParseModule("_base", "gui", \@section_empty, \@excludes_gui); -ParseModule("_base", "graphics", \@section_empty); +ParseModule("_base", "gui", \@section_empty); +ParseModule("_base", "graphics", \@section_empty, \@excludes_graphics); ParseModule("_base", "sound", \@section_empty, \@excludes_snd); chdir("engines/"); @@ -80,7 +83,6 @@ ParseModule("_agos", "agos", \@section_empty); ParseModule("_sky", "sky", \@section_empty); ParseModule("_gob", "gob", \@section_empty); ParseModule("_saga", "saga", \@section_empty); - ParseModule("_kyra", "kyra", \@section_empty); ParseModule("_sword1", "sword1", \@section_empty); ParseModule("_sword2", "sword2", \@section_empty); @@ -89,6 +91,7 @@ ParseModule("_cine", "cine", \@section_empty); ParseModule("_agi", "agi", \@section_empty); ParseModule("_touche", "touche", \@section_empty); ParseModule("_parallaction","parallaction",\@section_empty); +ParseModule("_cruise", "cruise", \@section_empty); print " ======================================================================================= Done. Enjoy :P diff --git a/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl b/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl index a276b80223..bd2a3cf0dc 100644 --- a/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl +++ b/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl @@ -5,12 +5,13 @@ $DefaultTopMacros = " MACRO USE_ZLIB // LIB:zlib.lib MACRO USE_MAD // LIB:libmad.lib - //MACRO USE_TREMOR // LIB:libtremor.lib + MACRO USE_TREMOR // LIB:libtremor.lib "; $DefaultBottomMacros = " MACRO DISABLE_SWORD1 // LIB:scummvm_sword1.lib MACRO DISABLE_SWORD2 // LIB:scummvm_sword2.lib + MACRO DISABLE_PARALLACTION // LIB:scummvm_parallaction.lib "; ## @@ -125,7 +126,7 @@ if (1) # all regular combo's //MACRO DISABLE_TOUCHE // LIB:scummvm_touche.lib //MACRO DISABLE_CINE // LIB:scummvm_cine.lib //MACRO DISABLE_LURE // LIB:scummvm_lure.lib - + //MACRO DISABLE_CRUISE // LIB:scummvm_cruise.lib $DefaultBottomMacros"; # now one for each ready-for-release engine diff --git a/backends/platform/symbian/S60/ScummVM_S60.mmp.in b/backends/platform/symbian/S60/ScummVM_S60.mmp.in index d65aa88423..cf91b4b14e 100644 --- a/backends/platform/symbian/S60/ScummVM_S60.mmp.in +++ b/backends/platform/symbian/S60/ScummVM_S60.mmp.in @@ -94,6 +94,9 @@ SOURCE gui\Key.cpp SOURCE gui\KeysDialog.cpp SOURCE gui\Actions.cpp +// Special for graphics +source graphics\iff.cpp + // *** Dynamic Libraries LIBRARY cone.lib eikcore.lib diff --git a/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in b/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in index c680db130f..eebd4764f5 100644 --- a/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in +++ b/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in @@ -114,6 +114,9 @@ SOURCE gui\Key.cpp SOURCE gui\KeysDialog.cpp SOURCE gui\Actions.cpp +// Special for graphics +source graphics\iff.cpp + // *** Dynamic Libraries LIBRARY cone.lib eikcore.lib LIBRARY euser.lib apparc.lib fbscli.lib diff --git a/backends/platform/symbian/S80/ScummVM_S80.mmp.in b/backends/platform/symbian/S80/ScummVM_S80.mmp.in index 8825662575..4bcb64060b 100644 --- a/backends/platform/symbian/S80/ScummVM_S80.mmp.in +++ b/backends/platform/symbian/S80/ScummVM_S80.mmp.in @@ -92,6 +92,9 @@ SOURCE gui\Key.cpp SOURCE gui\KeysDialog.cpp SOURCE gui\Actions.cpp +// Special for graphics +source graphics\iff.cpp + // *** Dynamic Libraries LIBRARY cone.lib eikcore.lib diff --git a/backends/platform/symbian/S90/Scummvm_S90.mmp.in b/backends/platform/symbian/S90/Scummvm_S90.mmp.in index fecbfe4b82..e55acc63b1 100644 --- a/backends/platform/symbian/S90/Scummvm_S90.mmp.in +++ b/backends/platform/symbian/S90/Scummvm_S90.mmp.in @@ -92,6 +92,9 @@ SOURCE gui\Key.cpp SOURCE gui\KeysDialog.cpp SOURCE gui\Actions.cpp +// Special for graphics +source graphics\iff.cpp + // *** Dynamic Libraries LIBRARY cone.lib eikcore.lib diff --git a/backends/platform/symbian/UIQ2/ScummVM_UIQ2.mmp.in b/backends/platform/symbian/UIQ2/ScummVM_UIQ2.mmp.in index 62c3eb3aa2..c3ebae01d7 100644 --- a/backends/platform/symbian/UIQ2/ScummVM_UIQ2.mmp.in +++ b/backends/platform/symbian/UIQ2/ScummVM_UIQ2.mmp.in @@ -91,6 +91,9 @@ SOURCE gui\Key.cpp SOURCE gui\KeysDialog.cpp SOURCE gui\Actions.cpp +// Special for graphics +source graphics\iff.cpp + // *** Dynamic Libraries LIBRARY cone.lib eikcore.lib diff --git a/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in b/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in index 7fe7798080..8620237b3a 100644 --- a/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in +++ b/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in @@ -115,6 +115,9 @@ SOURCE gui\Key.cpp SOURCE gui\KeysDialog.cpp SOURCE gui\Actions.cpp +// Special for graphics +source graphics\iff.cpp + // *** Dynamic Libraries LIBRARY cone.lib eikcore.lib diff --git a/backends/platform/symbian/mmp/scummvm_base.mmp.in b/backends/platform/symbian/mmp/scummvm_base.mmp.in index fb62b4943e..a1f3f1b261 100644 --- a/backends/platform/symbian/mmp/scummvm_base.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_base.mmp.in @@ -56,6 +56,8 @@ OPTION GCC -Wno-multichar -Wno-reorder // don't optimize for ARM, platform way //MACRO DISABLE_CINE // LIB:scummvm_cine.lib //MACRO DISABLE_AGI // LIB:scummvm_agi.lib //MACRO DISABLE_PARALLACTION // LIB:scummvm_parallaction.lib + //MACRO DISABLE_CRUISE // LIB:scummvm_cruise.lib + //STOP_AUTO_MACROS_MASTER// diff --git a/backends/platform/symbian/mmp/scummvm_cruise.mmp.in b/backends/platform/symbian/mmp/scummvm_cruise.mmp.in new file mode 100644 index 0000000000..05092777b0 --- /dev/null +++ b/backends/platform/symbian/mmp/scummvm_cruise.mmp.in @@ -0,0 +1,54 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL + * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System + * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer + * Copyright (C) 2005-2007 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +// +// EPOC MMP makefile project for ScummVM +// + +// *** Definitions + +TARGET scummvm_cruise.lib +TARGETTYPE lib +OPTION MSVC /QIfist /Ob1 /Oy /GF // /QIfist disables use of __ftol2 to avoid linker probs with MS libc: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vcrefQIfistSuppress_ftol.asp +OPTION GCC -Wno-multichar -Wno-reorder // don't optimize for ARM, platform way too sensitive for that :( just turn off some common warnings + +//START_AUTO_MACROS_SLAVE// + + // empty base file, will be updated by Perl build scripts + +//STOP_AUTO_MACROS_SLAVE// + +// *** SOURCE files + +SOURCEPATH ..\..\..\..\engines\cruise + +//START_AUTO_OBJECTS_CRUISE_// + + // empty base file, will be updated by Perl build scripts + +//STOP_AUTO_OBJECTS_CRUISE_// + +// *** Include paths + +USERINCLUDE ..\..\..\..\engines +USERINCLUDE ..\..\..\.. ..\..\..\..\common ..\..\..\..\gui ..\..\..\..\sound ..\src +SYSTEMINCLUDE \epoc32\include \epoc32\include\libc ..\src diff --git a/backends/platform/wince/CEActionsPocket.cpp b/backends/platform/wince/CEActionsPocket.cpp index 73d8dfe334..6cddf62695 100644 --- a/backends/platform/wince/CEActionsPocket.cpp +++ b/backends/platform/wince/CEActionsPocket.cpp @@ -1,5 +1,5 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2001-2007 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,13 +24,9 @@ #include "common/stdafx.h" #include "CEActionsPocket.h" #include "EventsBuffer.h" - #include "gui/message.h" - #include "scumm/scumm.h" - #include "common/config-manager.h" - #include "gui/KeysDialog.h" #ifdef _WIN32_WCE @@ -42,20 +38,20 @@ const String pocketActionNames[] = { "Save", "Quit", "Skip", - "Hide", - "Keyboard", - "Sound", + "Hide Toolbar", + "Show Keyboard", + "Sound on/off", "Right click", - "Cursor", + "Show/Hide Cursor", "Free look", "Zoom up", "Zoom down", "FT Cheat", "Bind Keys", - "Up", - "Down", - "Left", - "Right", + "Cursor Up", + "Cursor Down", + "Cursor Left", + "Cursor Right", "Left Click", }; @@ -100,11 +96,11 @@ GUI::Actions() _action_enabled[POCKET_ACTION_DOWN] = true; _action_enabled[POCKET_ACTION_LEFT] = true; _action_enabled[POCKET_ACTION_RIGHT] = true; - _action_mapping[POCKET_ACTION_LEFTCLICK] = VK_RETURN; - _action_mapping[POCKET_ACTION_UP] = 0x111; - _action_mapping[POCKET_ACTION_DOWN] = 0x112; - _action_mapping[POCKET_ACTION_LEFT] = 0x114; - _action_mapping[POCKET_ACTION_RIGHT] = 0x113; + _action_mapping[POCKET_ACTION_LEFTCLICK] = SDLK_RETURN; + _action_mapping[POCKET_ACTION_UP] = SDLK_UP; + _action_mapping[POCKET_ACTION_DOWN] = SDLK_DOWN; + _action_mapping[POCKET_ACTION_LEFT] = SDLK_LEFT; + _action_mapping[POCKET_ACTION_RIGHT] = SDLK_RIGHT; } void CEActionsPocket::initInstanceMain(OSystem *mainSystem) { @@ -184,7 +180,7 @@ void CEActionsPocket::initInstanceGame() { // Freelook _action_enabled[POCKET_ACTION_FREELOOK] = true; // Zoom - if (is_sword1 || is_sword2 || is_comi) { + if (is_sword1 || is_sword2 || is_comi || is_touche) { _zoom_needed = true; _action_enabled[POCKET_ACTION_ZOOM_UP] = true; _action_enabled[POCKET_ACTION_ZOOM_DOWN] = true; @@ -244,9 +240,9 @@ bool CEActionsPocket::perform(GUI::ActionType action, bool pushed) { case POCKET_ACTION_CURSOR: _CESystem->swap_mouse_visibility(); return true; - case POCKET_ACTION_FREELOOK: - _CESystem->swap_freeLook(); - return true; + case POCKET_ACTION_FREELOOK: + _CESystem->swap_freeLook(); + return true; case POCKET_ACTION_ZOOM_UP: _CESystem->swap_zoom_up(); return true; @@ -270,7 +266,7 @@ bool CEActionsPocket::perform(GUI::ActionType action, bool pushed) { return true; case POCKET_ACTION_QUIT: { - GUI::MessageDialog alert("Do you want to quit ?", "Yes", "No"); + GUI::MessageDialog alert(" Are you sure you want to quit ? ", "Yes", "No"); if (alert.runModal() == GUI::kMessageOK) _mainSystem->quit(); return true; @@ -309,4 +305,3 @@ bool CEActionsPocket::needsZoomMapping() { else return (_action_mapping[POCKET_ACTION_ZOOM_UP] == 0 || _action_mapping[POCKET_ACTION_ZOOM_DOWN] == 0); } - diff --git a/backends/platform/wince/CEActionsPocket.h b/backends/platform/wince/CEActionsPocket.h index f3d8f482cb..d20829f3f6 100644 --- a/backends/platform/wince/CEActionsPocket.h +++ b/backends/platform/wince/CEActionsPocket.h @@ -1,5 +1,5 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2001-2007 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -26,37 +26,34 @@ #include "common/stdafx.h" #include "common/scummsys.h" #include "common/system.h" - - #include "wince-sdl.h" #include "gui/Key.h" - #include "gui/Actions.h" -#define POCKET_ACTION_VERSION 4 +#define POCKET_ACTION_VERSION 5 enum pocketActionType { - POCKET_ACTION_PAUSE = 0, - POCKET_ACTION_SAVE, - POCKET_ACTION_QUIT, - POCKET_ACTION_SKIP, - POCKET_ACTION_HIDE, - POCKET_ACTION_KEYBOARD, - POCKET_ACTION_SOUND, - POCKET_ACTION_RIGHTCLICK, - POCKET_ACTION_CURSOR, - POCKET_ACTION_FREELOOK, - POCKET_ACTION_ZOOM_UP, - POCKET_ACTION_ZOOM_DOWN, - POCKET_ACTION_FT_CHEAT, - POCKET_ACTION_BINDKEYS, - POCKET_ACTION_UP, - POCKET_ACTION_DOWN, - POCKET_ACTION_LEFT, - POCKET_ACTION_RIGHT, - POCKET_ACTION_LEFTCLICK, - - POCKET_ACTION_LAST + POCKET_ACTION_PAUSE = 0, + POCKET_ACTION_SAVE, + POCKET_ACTION_QUIT, + POCKET_ACTION_SKIP, + POCKET_ACTION_HIDE, + POCKET_ACTION_KEYBOARD, + POCKET_ACTION_SOUND, + POCKET_ACTION_RIGHTCLICK, + POCKET_ACTION_CURSOR, + POCKET_ACTION_FREELOOK, + POCKET_ACTION_ZOOM_UP, + POCKET_ACTION_ZOOM_DOWN, + POCKET_ACTION_FT_CHEAT, + POCKET_ACTION_BINDKEYS, + POCKET_ACTION_UP, + POCKET_ACTION_DOWN, + POCKET_ACTION_LEFT, + POCKET_ACTION_RIGHT, + POCKET_ACTION_LEFTCLICK, + + POCKET_ACTION_LAST }; class CEActionsPocket : public GUI::Actions { diff --git a/backends/platform/wince/CEActionsSmartphone.cpp b/backends/platform/wince/CEActionsSmartphone.cpp index 8d9b18b46c..1d53b01dc4 100644 --- a/backends/platform/wince/CEActionsSmartphone.cpp +++ b/backends/platform/wince/CEActionsSmartphone.cpp @@ -1,5 +1,5 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2001-2007 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,25 +20,15 @@ * */ -//#define SIMU_SMARTPHONE 1 - -//#ifdef WIN32_PLATFORM_WFSP - #include "common/stdafx.h" #include "CEActionsSmartphone.h" #include "EventsBuffer.h" - #include "gui/message.h" - #include "scumm/scumm.h" - #include "common/config-manager.h" - #include "gui/KeysDialog.h" -#ifdef _WIN32_WCE #define KEY_ALL_SKIP 3457 -#endif const String smartphoneActionNames[] = { "Up", @@ -53,14 +43,11 @@ const String smartphoneActionNames[] = { "FT Cheat", "Bind Keys", "Keyboard", - "Rotate" + "Rotate", + "Quit" }; -#ifdef SIMU_SMARTPHONE -const int ACTIONS_SMARTPHONE_DEFAULT[] = { 0x111, 0x112, 0x114, 0x113, 0x11a, 0x11b, VK_LWIN, VK_ESCAPE, VK_F8, 0, VK_RETURN, 0, 0 }; -#else -const int ACTIONS_SMARTPHONE_DEFAULT[] = { '4', '6', '8', '2', 0x11a, 0x11b, '0', VK_ESCAPE, '9', 0, VK_RETURN, 0, 0 }; -#endif +const int ACTIONS_SMARTPHONE_DEFAULT[] = { SDLK_UP, SDLK_DOWN, SDLK_LEFT, SDLK_RIGHT, SDLK_F1, SDLK_F2, SDLK_F3, SDLK_ESCAPE, SDLK_9, SDLK_8, SDLK_F4, SDLK_RETURN, SDLK_5, SDLK_0 }; void CEActionsSmartphone::init() { _instance = new CEActionsSmartphone(); @@ -98,22 +85,18 @@ void CEActionsSmartphone::initInstanceMain(OSystem *mainSystem) { _CESystem = static_cast<OSystem_WINCE3*>(mainSystem); GUI_Actions::initInstanceMain(mainSystem); - // Mouse Up + + // These actions are always on _action_enabled[SMARTPHONE_ACTION_UP] = true; - // Mouse Down _action_enabled[SMARTPHONE_ACTION_DOWN] = true; - // Mouse Left _action_enabled[SMARTPHONE_ACTION_LEFT] = true; - // Mouse Right _action_enabled[SMARTPHONE_ACTION_RIGHT] = true; - // Left Click _action_enabled[SMARTPHONE_ACTION_LEFTCLICK] = true; - // Right Click _action_enabled[SMARTPHONE_ACTION_RIGHTCLICK] = true; - // Show virtual keyboard _action_enabled[SMARTPHONE_ACTION_KEYBOARD] = true; - // Rotate display _action_enabled[SMARTPHONE_ACTION_ROTATE] = true; + _action_enabled[SMARTPHONE_ACTION_QUIT] = true; + _action_enabled[SMARTPHONE_ACTION_BINDKEYS] = true; } void CEActionsSmartphone::initInstanceGame() { @@ -239,9 +222,14 @@ bool CEActionsSmartphone::perform(GUI::ActionType action, bool pushed) { case SMARTPHONE_ACTION_ROTATE: _CESystem->smartphone_rotate_display(); return true; + case SMARTPHONE_ACTION_QUIT: + { + GUI::MessageDialog alert(" Are you sure you want to quit ? ", "Yes", "No"); + if (alert.runModal() == GUI::kMessageOK) + _mainSystem->quit(); + return true; + } } return false; } - -//#endif diff --git a/backends/platform/wince/CEActionsSmartphone.h b/backends/platform/wince/CEActionsSmartphone.h index b100680d9d..3ba57f1239 100644 --- a/backends/platform/wince/CEActionsSmartphone.h +++ b/backends/platform/wince/CEActionsSmartphone.h @@ -1,5 +1,5 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2001-2007 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -23,36 +23,32 @@ #ifndef CEACTIONSSMARTPHONE #define CEACTIONSSMARTPHONE -//#ifdef WIN32_PLATFORM_WFSP - #include "common/stdafx.h" #include "common/scummsys.h" #include "common/system.h" - - #include "wince-sdl.h" #include "gui/Key.h" - #include "gui/Actions.h" -#define SMARTPHONE_ACTION_VERSION 4 +#define SMARTPHONE_ACTION_VERSION 5 enum smartphoneActionType { - SMARTPHONE_ACTION_UP = 0, - SMARTPHONE_ACTION_DOWN, - SMARTPHONE_ACTION_LEFT, - SMARTPHONE_ACTION_RIGHT, - SMARTPHONE_ACTION_LEFTCLICK, - SMARTPHONE_ACTION_RIGHTCLICK, - SMARTPHONE_ACTION_SAVE, - SMARTPHONE_ACTION_SKIP, - SMARTPHONE_ACTION_ZONE, - SMARTPHONE_ACTION_FT_CHEAT, - SMARTPHONE_ACTION_BINDKEYS, - SMARTPHONE_ACTION_KEYBOARD, - SMARTPHONE_ACTION_ROTATE, - - SMARTPHONE_ACTION_LAST + SMARTPHONE_ACTION_UP = 0, + SMARTPHONE_ACTION_DOWN, + SMARTPHONE_ACTION_LEFT, + SMARTPHONE_ACTION_RIGHT, + SMARTPHONE_ACTION_LEFTCLICK, + SMARTPHONE_ACTION_RIGHTCLICK, + SMARTPHONE_ACTION_SAVE, + SMARTPHONE_ACTION_SKIP, + SMARTPHONE_ACTION_ZONE, + SMARTPHONE_ACTION_FT_CHEAT, + SMARTPHONE_ACTION_BINDKEYS, + SMARTPHONE_ACTION_KEYBOARD, + SMARTPHONE_ACTION_ROTATE, + SMARTPHONE_ACTION_QUIT, + + SMARTPHONE_ACTION_LAST }; @@ -78,5 +74,3 @@ class CEActionsSmartphone : public GUI::Actions { }; #endif - -//#endif diff --git a/backends/platform/wince/CEDevice.cpp b/backends/platform/wince/CEDevice.cpp index 495ba1b274..5a60c76bfe 100644 --- a/backends/platform/wince/CEDevice.cpp +++ b/backends/platform/wince/CEDevice.cpp @@ -1,5 +1,5 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2001-2007 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,9 +20,6 @@ * */ -//#define SIMU_SMARTPHONE 1 -//#define SIMU_SMARTPHONE_2005 1 - #include "common/stdafx.h" #include "CEDevice.h" @@ -30,52 +27,63 @@ #include "wince-sdl.h" -#define KEY_CALENDAR 0xc1 -#define KEY_CONTACTS 0xc2 -#define KEY_INBOX 0xc3 -#define KEY_TASK 0xc4 - -//#ifdef WIN32_PLATFORM_WFSP -const char* SMARTPHONE_KEYS_NAME[] = { - "1", "2", "3","4", "5", "6", "7", "8", "9", "*", "0", "#", - "Home", "Back", "Up", "Down", "Left", "Right", "Action", "Hang up", "Call", - "Soft 1", "Soft 2", "Power", "Volume Up" ,"Volume Down", "Record", "None", - 0 -}; - -// Old mapping from the previous (non SDL) version. To be forgotten. -/* -const int SMARTPHONE_KEYS_MAPPING[] = { - '1', '2', '3', '4', '5', '6', '7', '8', '9', VK_F8, '0', VK_F9, - VK_LWIN, VK_ESCAPE, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT, VK_RETURN, VK_F4, VK_F3, - VK_F1, VK_F2, VK_F18, VK_F6, VK_F7, VK_F10, 0xff, 0 -}; -*/ - -// FIXME : Home and Record are not mapped -const int SMARTPHONE_KEYS_MAPPING[] = { - '1', '2', '3', '4', '5', '6', '7', '8', '9', VK_F9, '0', VK_F10, - 0xFF, VK_ESCAPE, 0x113, 0x114, 0x111, 0x112, VK_RETURN, 0x11D, 0x11C, - 0x11A, 0x11B, 0x11D, 0x11F, 0x120, 0xFF, 0 -}; - 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; #ifdef __GNUC__ extern "C" void WINAPI SystemIdleTimerReset(void); -#define SPI_GETPLATFORMTYPE 257 +#define SPI_GETPLATFORMTYPE 257 +#define SPI_SETBATTERYIDLETIMEOUT 251 +#define SPI_GETBATTERYIDLETIMEOUT 252 #endif - #define TIMER_TRIGGER 9000 -//#endif +DWORD CEDevice::reg_access(TCHAR *key, TCHAR *val, DWORD data) { + HKEY regkey; + DWORD tmpval, cbdata; + + if (RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, 0, ®key) != ERROR_SUCCESS) + return data; + + cbdata = sizeof(DWORD); + if (RegQueryValueEx(regkey, val, NULL, NULL, (LPBYTE) &tmpval, &cbdata) != ERROR_SUCCESS) + { + RegCloseKey(regkey); + return data; + } + + cbdata = sizeof(DWORD); + if (RegSetValueEx(regkey, val, 0, REG_DWORD, (LPBYTE) &data, cbdata) != ERROR_SUCCESS) + { + RegCloseKey(regkey); + return data; + } + + RegCloseKey(regkey); + return tmpval; +} + +void CEDevice::backlight_xchg() { + HANDLE h; + + REG_bat = reg_access(TEXT("ControlPanel\\BackLight"), 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); + + h = CreateEvent(NULL, FALSE, FALSE, TEXT("BackLightChangeEvent")); + if (h) + { + SetEvent(h); + CloseHandle(h); + } +} -// Power management code borrowed from MoDaCo & Betaplayer. Thanks ! void CEDevice::init() { + // 2003+ power management code borrowed from MoDaCo & Betaplayer. Thanks ! HINSTANCE dll = LoadLibrary(TEXT("aygshell.dll")); if (dll) { *(FARPROC*)&_SHIdleTimerReset = GetProcAddress(dll, MAKEINTRESOURCE(2006)); @@ -89,12 +97,20 @@ void CEDevice::init() { if (_SetPowerRequirement) _hPowerManagement = _SetPowerRequirement((PVOID) TEXT("BKL1:"), 0, 1, (PVOID) NULL, 0); _lastTime = GetTickCount(); + + // older devices + REG_bat = REG_ac = REG_disp = 2 * 60 * 60 * 1000; // 2hrs should do it + backlight_xchg(); + SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, (void *) &bat_timeout, 0); + SystemParametersInfo(SPI_SETBATTERYIDLETIMEOUT, 60 * 60 * 2, NULL, SPIF_SENDCHANGE); } void CEDevice::end() { - if (_ReleasePowerRequirement && _hPowerManagement) { + if (_ReleasePowerRequirement && _hPowerManagement) _ReleasePowerRequirement(_hPowerManagement); - } + + backlight_xchg(); + SystemParametersInfo(SPI_SETBATTERYIDLETIMEOUT, bat_timeout, NULL, SPIF_SENDCHANGE); } void CEDevice::wakeUp() { @@ -107,97 +123,97 @@ void CEDevice::wakeUp() { } } +bool CEDevice::hasSquareQVGAResolution() { + return (OSystem_WINCE3::getScreenWidth() == 240 && OSystem_WINCE3::getScreenHeight() == 240); +} + bool CEDevice::hasPocketPCResolution() { -#ifdef SIMU_SMARTPHONE -#ifndef SIMU_SMARTPHONE_2005 - return false; -#else - return true; -#endif -#else if (OSystem_WINCE3::isOzone() && hasWideResolution()) return true; - return (OSystem_WINCE3::getScreenWidth() < 320 && OSystem_WINCE3::getScreenWidth() >= 240); -#endif + return (OSystem_WINCE3::getScreenWidth() <= 320 && OSystem_WINCE3::getScreenWidth() >= 240); } bool CEDevice::hasDesktopResolution() { -#ifdef SIMU_SMARTPHONE - return false; -#else if (OSystem_WINCE3::isOzone() && hasWideResolution()) return true; - return (OSystem_WINCE3::getScreenWidth() >= 320); -#endif + return (OSystem_WINCE3::getScreenWidth() > 320); } bool CEDevice::hasWideResolution() { -#ifdef SIMU_SMARTPHONE - return false; -#else return (OSystem_WINCE3::getScreenWidth() >= 640 || OSystem_WINCE3::getScreenHeight() >= 640); -#endif } bool CEDevice::hasSmartphoneResolution() { -#ifdef SIMU_SMARTPHONE -#ifndef SIMU_SMARTPHONE_2005 - return true; -#else - return false; -#endif -#else return (OSystem_WINCE3::getScreenWidth() < 240); -#endif } bool CEDevice::isSmartphone() { -#ifdef SIMU_SMARTPHONE - return true; -#else TCHAR platformType[100]; BOOL result = SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(platformType), platformType, 0); if (!result && GetLastError() == ERROR_ACCESS_DENIED) return true; return (_wcsnicmp(platformType, TEXT("SmartPhone"), 10) == 0); -#endif } Common::String CEDevice::getKeyName(unsigned int keyCode) { - char key_name[10]; - - if (!keyCode) - return "No key"; - - if (keyCode == KEY_CALENDAR) - return "Button Calendar"; - if (keyCode == KEY_CONTACTS) - return "Button Contacts"; - if (keyCode == KEY_INBOX) - return "Button Inbox"; - if (keyCode == KEY_TASK) - return "Button Tasks"; - if (keyCode == SDLK_F1) - return "F1 (hard 1)"; - if (keyCode == SDLK_F2) - return "F2 (hard 2)"; - if (keyCode == SDLK_F3) - return "F3 (hard 3)"; - if (keyCode == SDLK_F4) - return "F4 (hard 4)"; - -//#ifdef WIN32_PLATFORM_WFSP - if (hasSmartphoneResolution()) { - int i = 0; - while (SMARTPHONE_KEYS_MAPPING[i]) { - if (keyCode == SMARTPHONE_KEYS_MAPPING[i]) - return SMARTPHONE_KEYS_NAME[i]; - i++; - } + switch (keyCode) { + case SDLK_F1: + return "Softkey A"; + case SDLK_F2: + return "Softkey B"; + case SDLK_F3: + return "Talk"; + case SDLK_F4: + return "End"; + case SDLK_APP1: + return "Application 1"; + case SDLK_APP2: + return "Application 2"; + case SDLK_APP3: + return "Application 3"; + case SDLK_APP4: + return "Application 4"; + case SDLK_APP5: + return "Application 5"; + case SDLK_APP6: + return "Application 6"; + case SDLK_LSUPER: + return "Home"; + case SDLK_ESCAPE: + return "Back"; + case SDLK_UP: + return "Up"; + case SDLK_DOWN: + return "Down"; + case SDLK_LEFT: + return "Left"; + case SDLK_RIGHT: + return "Right"; + case SDLK_RETURN: + return "Action"; + case SDLK_F10: + return "Record"; + case SDLK_F6: + return "Volume Up"; + case SDLK_F7: + return "Volume Down"; + case SDLK_F17: + return "Flip"; + case SDLK_F18: + return "Power"; + case SDLK_F16: + return "Speaker"; + case SDLK_F8: + return "Star"; + case SDLK_F9: + return "Pound"; + case SDLK_F11: + return "Symbol"; + case SDLK_F19: + return "Red Key"; + case 0: + return "None"; + default: + return SDL_GetKeyName((SDLKey)keyCode); } -//#endif - - sprintf(key_name, "Key %.4x", keyCode); - return key_name; } - diff --git a/backends/platform/wince/CEDevice.h b/backends/platform/wince/CEDevice.h index 1165377caa..4dd86f1619 100644 --- a/backends/platform/wince/CEDevice.h +++ b/backends/platform/wince/CEDevice.h @@ -1,5 +1,5 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2001-2007 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,19 +28,22 @@ #include "common/system.h" #include "common/str.h" -//#include <gx.h> - class CEDevice { public: static void init(); static void end(); static void wakeUp(); static bool hasPocketPCResolution(); + static bool hasSquareQVGAResolution(); static bool hasDesktopResolution(); static bool hasWideResolution(); static bool hasSmartphoneResolution(); static bool isSmartphone(); static Common::String getKeyName(unsigned int keyCode); + + private: + static DWORD reg_access(TCHAR *key, TCHAR *val, DWORD data); + static void backlight_xchg(); }; #endif diff --git a/backends/platform/wince/CEKeysDialog.cpp b/backends/platform/wince/CEKeysDialog.cpp deleted file mode 100644 index 249f1f6fcd..0000000000 --- a/backends/platform/wince/CEKeysDialog.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001-2006 The ScummVM project - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include "common/stdafx.h" -#include "CEKeysDialog.h" -#include "CEDevice.h" -#include "gui/Actions.h" - -using GUI::ListWidget; -using GUI::kListNumberingZero; -using GUI::WIDGET_CLEARBG; -using GUI::kListSelectionChangedCmd; -using GUI::kCloseCmd; -using GUI::StaticTextWidget; -using GUI::kTextAlignCenter; -using GUI::CommandSender; -using GUI::Actions; - -enum { - kMapCmd = 'map ', - kOKCmd = 'ok ' -}; - - -CEKeysDialog::CEKeysDialog(const Common::String &title) - : GUI::Dialog(30, 20, 260, 160) { - addButton(this, 160, 20, "Map", kMapCmd, 'M'); // Map - addButton(this, 160, 40, "OK", kOKCmd, 'O'); // OK - addButton(this, 160, 60, "Cancel", kCloseCmd, 'C'); // Cancel - - _actionTitle = new StaticTextWidget(this, 10, 120, 240, 16, title, kTextAlignCenter); - _keyMapping = new StaticTextWidget(this, 10, 140, 240, 16, "", kTextAlignCenter); - - _actionTitle->setFlags(WIDGET_CLEARBG); - _keyMapping->setFlags(WIDGET_CLEARBG); - - _actionsList = new ListWidget(this, "Actions List"); - _actionsList->setNumberingMode(kListNumberingZero); - - // Get actions names - Common::StringList l; - - for (int i = 0; i < GUI_Actions::Instance()->size(); i++) - l.push_back(GUI_Actions::Instance()->actionName((GUI::ActionType)i)); - - _actionsList->setList(l); - - _actionSelected = -1; - GUI_Actions::Instance()->beginMapping(false); -} - -void CEKeysDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { - switch(cmd) { - - case kListSelectionChangedCmd: - if (_actionsList->getSelected() >= 0) { - char selection[100]; - - sprintf(selection, "Associated key : %s", CEDevice::getKeyName(GUI_Actions::Instance()->getMapping((GUI::ActionType)(_actionsList->getSelected()))).c_str()); - _keyMapping->setLabel(selection); - _keyMapping->draw(); - } - break; - case kMapCmd: - if (_actionsList->getSelected() < 0) { - _actionTitle->setLabel("Please select an action"); - } - else { - char selection[100]; - - _actionSelected = _actionsList->getSelected(); - sprintf(selection, "Associated key : %s", CEDevice::getKeyName(GUI_Actions::Instance()->getMapping((GUI::ActionType)_actionSelected)).c_str()); - _actionTitle->setLabel("Press the key to associate"); - _keyMapping->setLabel(selection); - _keyMapping->draw(); - GUI_Actions::Instance()->beginMapping(true); - _actionsList->setEnabled(false); - } - _actionTitle->draw(); - break; - case kOKCmd: - GUI_Actions::Instance()->saveMapping(); - close(); - break; - case kCloseCmd: - GUI_Actions::Instance()->loadMapping(); - close(); - break; - } -} - -void CEKeysDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { - if (modifiers == 0xff && GUI_Actions::Instance()->mappingActive()) { - // GAPI key was selected - char selection[100]; - - GUI_Actions::Instance()->setMapping((GUI::ActionType)_actionSelected, ascii); - - sprintf(selection, "Associated key : %s", CEDevice::getKeyName(GUI_Actions::Instance()->getMapping((GUI::ActionType)_actionSelected)).c_str()); - _actionTitle->setLabel("Choose an action to map"); - _keyMapping->setLabel(selection); - _keyMapping->draw(); - _actionSelected = -1; - _actionsList->setEnabled(true); - GUI_Actions::Instance()->beginMapping(false); - } -} diff --git a/backends/platform/wince/CEKeysDialog.h b/backends/platform/wince/CEKeysDialog.h deleted file mode 100644 index 37566bf431..0000000000 --- a/backends/platform/wince/CEKeysDialog.h +++ /dev/null @@ -1,46 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001-2006 The ScummVM project - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef CEKEYSDIALOG -#define CEKEYSDIALOG - -#include "gui/newgui.h" -#include "gui/dialog.h" -#include "gui/ListWidget.h" -#include "common/str.h" - -class CEKeysDialog : public GUI::Dialog { -public: - CEKeysDialog(const Common::String &title = "Choose an action to map"); - - virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); - virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers); - -protected: - - GUI::ListWidget *_actionsList; - GUI::StaticTextWidget *_actionTitle; - GUI::StaticTextWidget *_keyMapping; - int _actionSelected; -}; - -#endif diff --git a/backends/platform/wince/CEScaler.cpp b/backends/platform/wince/CEScaler.cpp index dac46b801a..85151dafe5 100644 --- a/backends/platform/wince/CEScaler.cpp +++ b/backends/platform/wince/CEScaler.cpp @@ -1,5 +1,5 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2001-2007 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -89,42 +89,39 @@ void PocketPCLandscapeAspect(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr unsigned int p2; uint16 * inbuf; uint16 * outbuf; - inbuf=(uint16 *)srcPtr; - outbuf=(uint16 *)dstPtr; + inbuf = (uint16 *)srcPtr; + outbuf = (uint16 *)dstPtr; uint16 srcPitch16 = (uint16)(srcPitch / sizeof(uint16)); uint16 dstPitch16 = (uint16)(dstPitch / sizeof(uint16)); - for (i=0; i<((height)/6); i++) { - for (j=0; j<width; j++) { - p1=*((uint16*)inbuf+j); - inbuf+=srcPitch16; - *((uint16*)outbuf+j)=p1; - outbuf+=dstPitch16; - p2=*((uint16*)inbuf+j); - inbuf+=srcPitch16; - *((uint16*)outbuf+j)=MAKEPIXEL(P20(RB(p1))+P80(RB(p2)),P20(G(p1))+P80(G(p2))); - outbuf+=dstPitch16; - p1=p2; - p2=*((uint16*)inbuf+j); - inbuf+=srcPitch16; - *((uint16*)outbuf+j)=MAKEPIXEL(P40(RB(p1))+P60(RB(p2)),P40(G(p1))+P60(G(p2))); - outbuf+=dstPitch16; - p1=p2; - p2=*((uint16*)inbuf+j); - inbuf+=srcPitch16; - *((uint16*)outbuf+j)=MAKEPIXEL(P60(RB(p1))+P40(RB(p2)),P60(G(p1))+P40(G(p2))); - outbuf+=dstPitch16; - p1=p2; - p2=*((uint16*)inbuf+j); - *((uint16*)outbuf+j)=MAKEPIXEL(P80(RB(p1))+P20(RB(p2)),P80(G(p1))+P20(G(p2))); - outbuf+=dstPitch16; - *((uint16*)outbuf+j)=p2; - inbuf=inbuf-srcPitch16*4; - outbuf=outbuf-dstPitch16*5; + for (i = 0; i < height/5; i++) { + for (j=0; j < width; j++) { + p1 = *((uint16*)inbuf+j); inbuf += srcPitch16; + *((uint16*)outbuf+j) = p1; outbuf += dstPitch16; + + p2 = *((uint16*)inbuf+j); inbuf += srcPitch16; + *((uint16*)outbuf+j) = MAKEPIXEL(P20(RB(p1))+P80(RB(p2)),P20(G(p1))+P80(G(p2))); outbuf += dstPitch16; + + p1 = p2; + p2 = *((uint16*)inbuf+j); inbuf += srcPitch16; + *((uint16*)outbuf+j) = MAKEPIXEL(P40(RB(p1))+P60(RB(p2)),P40(G(p1))+P60(G(p2))); outbuf += dstPitch16; + + p1 = p2; + p2 = *((uint16*)inbuf+j); inbuf += srcPitch16; + *((uint16*)outbuf+j) = MAKEPIXEL(P60(RB(p1))+P40(RB(p2)),P60(G(p1))+P40(G(p2))); outbuf += dstPitch16; + + p1 = p2; + p2 = *((uint16*)inbuf+j); + *((uint16*)outbuf+j) = MAKEPIXEL(P80(RB(p1))+P20(RB(p2)),P80(G(p1))+P20(G(p2))); outbuf += dstPitch16; + + *((uint16*)outbuf+j) = p2; + + inbuf = inbuf - srcPitch16*4; + outbuf = outbuf - dstPitch16*5; } - inbuf=inbuf+srcPitch16*5; - outbuf=outbuf+dstPitch16*6; + inbuf = inbuf + srcPitch16*5; + outbuf = outbuf + dstPitch16*6; } } @@ -190,7 +187,6 @@ void PocketPCHalfZoom(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint3 } } -//#ifdef WIN32_PLATFORM_WFSP void SmartphoneLandscape(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { uint8 *work; int i; @@ -221,5 +217,3 @@ void SmartphoneLandscape(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, ui } } } -//#endif - diff --git a/backends/platform/wince/CEgui/ItemAction.cpp b/backends/platform/wince/CEgui/ItemAction.cpp index 9bc9db65bb..7010d85ec0 100644 --- a/backends/platform/wince/CEgui/ItemAction.cpp +++ b/backends/platform/wince/CEgui/ItemAction.cpp @@ -1,5 +1,5 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2001-2007 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -39,7 +39,8 @@ namespace CEGUI { bool ItemAction::action(int x, int y, bool pushed) { if (checkInside(x, y) && _visible && pushed) { - GUI::Actions::Instance()->perform(_action); + GUI::Actions::Instance()->perform(_action, true); + GUI::Actions::Instance()->perform(_action, false); return true; } else diff --git a/backends/platform/wince/Makefile b/backends/platform/wince/Makefile index 1d08073b1d..44c4b597cf 100644 --- a/backends/platform/wince/Makefile +++ b/backends/platform/wince/Makefile @@ -3,6 +3,7 @@ # $URL$ # $Id$ +wince_gcc_root = /cygdrive/e/wince-gcc-root/ srcdir = ../../.. VPATH = $(srcdir) @@ -10,7 +11,7 @@ VPATH = $(srcdir) #DISABLE_SKY = 1 #DISABLE_QUEEN = 1 #DISABLE_GOB = 1 -#DISABLE_LURE = 1 +DISABLE_LURE = 1 #DISABLE_CINE = 1 #DISABLE_SAGA = 1 #DISABLE_KYRA = 1 @@ -20,8 +21,9 @@ VPATH = $(srcdir) #DISABLE_SWORD2 = 1 #DISABLE_TOUCHE = 1 DISABLE_PARALLACTION = 1 +DISABLE_CRUISE = 1 -DISABLE_HQ_SCALERS = 1 +#DISABLE_HQ_SCALERS = 1 CXX = arm-wince-pe-g++ LD = arm-wince-pe-g++ @@ -41,20 +43,20 @@ DEFINES += -D__stdcall= -Dcdecl= -D__cdecl__= -D__cdecl= -Wno-multichar #DEFINES += -DDEBUG -DUSE_WINDBG -g DEFINES += -O2 -INCLUDES := -I$(srcdir) -I. -I$(srcdir)/engines -Imissing/gcc -Ilibs/include -Ilibs/include/sdl -ICEgui -ICEkeys -I/cygdrive/e/wince-gcc-root/include +INCLUDES := -I$(srcdir) -I. -I$(srcdir)/engines -Imissing/gcc -Ilibs/include -Ilibs/include/sdl -ICEgui -ICEkeys -I$(wince_gcc_root)/include CFLAGS := CXXFLAGS := $(CFLAGS) -LDFLAGS := -Llibs/lib -L/cygdrive/e/wince-gcc-root/lib +LDFLAGS := -Llibs/lib -L$(wince_gcc_root)/lib LIBS := -lSDL -lzlib -lmad -lmpeg2 -ltremorce --entry WinMainCRTStartup TARGET = scummvm.exe OBJS := MODULE_DIRS += . -OBJS += CEActionsPocket.o CEDevice.o CEKeysDialog.o CEScaler.o \ +OBJS += CEActionsPocket.o CEDevice.o CEScaler.o \ CEActionsSmartphone.o CELauncherDialog.o wince-sdl.o OBJS += CEgui/GUIElement.o CEgui/Panel.o CEgui/SDL_ImageResource.o \ CEgui/ItemAction.o CEgui/PanelItem.o CEgui/Toolbar.o \ diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index f567b64b36..48eca8164e 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -1,5 +1,5 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2001-2007 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,6 +20,8 @@ * */ +// NOTE: formatted for tabstop=4 + #include "common/stdafx.h" #include "backends/platform/wince/wince-sdl.h" @@ -83,10 +85,11 @@ using namespace CEGUI; #define NAME_ITEM_ORIENTATION "Orientation" #define NAME_ITEM_BINDKEYS "Bindkeys" -// Given to the true main, needed for backend adaptation - -static FILE *stdout_file; -static FILE *stderr_file; +// stdin/err redirection +#define STDOUT_FNAME "\\scummvm_stdout.txt" +#define STDERR_FNAME "\\scummvm_stderr.txt" +static FILE *stdout_file = NULL, *stderr_file = NULL; +static char stdout_fname[MAX_PATH], stderr_fname[MAX_PATH]; // Static member inits typedef void (*SoundProc)(void *param, byte *buf, int len); @@ -124,8 +127,6 @@ static const OSystem::GraphicsMode s_supportedGraphicsModesHigh[] = { {0, 0, 0} }; -#define STDOUT_FNAME "\\scummvm_stdout.txt" -#define STDERR_FNAME "\\scummvm_stderr.txt" // ******************************************************************************************** @@ -134,6 +135,13 @@ bool isSmartphone() { return _hasSmartphoneResolution; } +const TCHAR *ASCIItoUnicode(const char *str) { + static TCHAR ustr[MAX_PATH]; // size good enough + + MultiByteToWideChar(CP_ACP, 0, str, strlen(str) + 1, ustr, sizeof(ustr) / sizeof(TCHAR)); + return ustr; +} + // MAIN #ifndef __GNUC__ int handleException(EXCEPTION_POINTERS *exceptionPointers) { @@ -153,7 +161,7 @@ OSystem *OSystem_WINCE3_create() { } int SDL_main(int argc, char **argv) { - + FILE *newfp = NULL; #ifdef __GNUC__ // Due to incomplete crt0.o implementation, we go through the constructor function // list provided by the linker and init all of them @@ -170,32 +178,35 @@ int SDL_main(int argc, char **argv) { CEDevice::init(); OSystem_WINCE3::initScreenInfos(); - /* Avoid print problems - this file will be put in RAM anyway */ + /* Redirect standard input and standard output */ + strcpy(stdout_fname, getcwd(NULL, MAX_PATH)); + strcpy(stderr_fname, getcwd(NULL, MAX_PATH)); + strcat(stdout_fname, STDOUT_FNAME); + strcat(stderr_fname, STDERR_FNAME); #ifndef __GNUC__ - stdout_file = fopen(STDOUT_FNAME, "w"); - stderr_file = fopen(STDERR_FNAME, "w"); + stdout_file = fopen(stdout_fname, "w"); + stderr_file = fopen(stderr_fname, "w"); #else - /* Redirect standard input and standard output */ - FILE *newfp = _wfreopen(TEXT(STDOUT_FNAME), TEXT("w"), stdout); + stdout_file = newfp = _wfreopen(ASCIItoUnicode(stdout_fname), TEXT("w"), stdout); if (newfp == NULL) { #if !defined(stdout) - stdout = fopen(STDOUT_FNAME, "w"); + stdout = fopen(stdout_fname, "w"); stdout_file = stdout; #else - newfp = fopen(STDOUT_FNAME, "w"); + newfp = fopen(stdout_fname, "w"); if (newfp) { *stdout = *newfp; stdout_file = stdout; } #endif } - newfp = _wfreopen(TEXT(STDERR_FNAME), TEXT("w"), stderr); + stderr_file = newfp = _wfreopen(ASCIItoUnicode(stderr_fname), TEXT("w"), stderr); if (newfp == NULL) { #if !defined(stderr) - stderr = fopen(STDERR_FNAME, "w"); + stderr = fopen(stderr_fname, "w"); stderr_file = stderr; #else - newfp = fopen(STDERR_FNAME, "w"); + newfp = fopen(stderr_fname, "w"); if (newfp) { *stderr = *newfp; stderr_file = stderr; @@ -214,7 +225,6 @@ int SDL_main(int argc, char **argv) { // Invoke the actual ScummVM main entry point: res = scummvm_main(argc, argv); - //res = scummvm_main(0, NULL); g_system->quit(); // TODO: Consider removing / replacing this! #if !defined(DEBUG) && !defined(__GNUC__) } @@ -258,7 +268,10 @@ void OSystem_WINCE3::initBackend() // Initialize global key mapping GUI::Actions::init(); GUI_Actions::Instance()->initInstanceMain(this); - GUI_Actions::Instance()->loadMapping(); + if (!GUI_Actions::Instance()->loadMapping()) { // error during loading means not present/wrong version + warning("Setting default action mappings."); + GUI_Actions::Instance()->saveMapping(); // write defaults + } loadDeviceConfiguration(); @@ -306,7 +319,7 @@ OSystem_WINCE3::OSystem_WINCE3() : OSystem_SDL(), _panelVisible(true), _panelStateForced(false), _forceHideMouse(false), _freeLook(false), _forcePanelInvisible(false), _toolbarHighDrawn(false), _zoomUp(false), _zoomDown(false), _scalersChanged(false), _monkeyKeyboard(false), _lastKeyPressed(0), _tapTime(0), - _saveToolbarState(false), _saveActiveToolbar(NAME_MAIN_PANEL), _rbutton(false), + _saveToolbarState(false), _saveActiveToolbar(NAME_MAIN_PANEL), _rbutton(false), _hasfocus(true), _usesEmulatedMouse(false), _mouseBackupOld(NULL), _mouseBackupToolbar(NULL), _mouseBackupDim(0) { _isSmartphone = CEDevice::isSmartphone(); @@ -320,10 +333,13 @@ OSystem_WINCE3::OSystem_WINCE3() : OSystem_SDL(), create_toolbar(); _mixer = 0; + _screen = NULL; } void OSystem_WINCE3::swap_panel_visibility() { //if (!_forcePanelInvisible && !_panelStateForced) { + if (_zoomDown || _zoomUp) return; + if (_panelVisible) { if (_toolbarHandler.activeName() == NAME_PANEL_KEYBOARD) _panelVisible = !_panelVisible; @@ -335,6 +351,7 @@ void OSystem_WINCE3::swap_panel_visibility() { _panelVisible = !_panelVisible; } _toolbarHandler.setVisible(_panelVisible); + _toolbarHighDrawn = false; if (_screenHeight > 240) addDirtyRect(0, 400, 640, 80); @@ -376,7 +393,10 @@ void OSystem_WINCE3::swap_smartphone_keyboard() { _toolbarHandler.setActive(NAME_PANEL_KEYBOARD); _panelVisible = !_panelVisible; _toolbarHandler.setVisible(_panelVisible); - addDirtyRect(0, 0, 320, 40); + if (_screenHeight > 240) + addDirtyRect(0, 0, 640, 80); + else + addDirtyRect(0, 0, 320, 40); internUpdateScreen(); } @@ -417,6 +437,7 @@ void OSystem_WINCE3::swap_zoom_up() { _scaleFactorYd = 2; _scalerProc = PocketPCHalf; _zoomUp = false; + _zoomDown = false; } else { @@ -430,9 +451,8 @@ void OSystem_WINCE3::swap_zoom_up() { _scaleFactorYd = 1; _scalerProc = PocketPCHalfZoom; } - else - _zoomDown = false; - + + _zoomDown = false; _zoomUp = true; } // redraw whole screen @@ -448,6 +468,7 @@ void OSystem_WINCE3::swap_zoom_down() { _scaleFactorYd = 2; _scalerProc = PocketPCHalf; _zoomDown = false; + _zoomUp = false; } else { @@ -461,9 +482,8 @@ void OSystem_WINCE3::swap_zoom_down() { _scaleFactorYd = 1; _scalerProc = PocketPCHalfZoom; } - else - _zoomUp = false; + _zoomUp = false; _zoomDown = true; } // redraw whole screen @@ -641,7 +661,7 @@ bool OSystem_WINCE3::setSoundCallback(SoundProc proc, void *param) { return false; } else - warning("Sound opened OK, mixing at %d Hz", _sampleRate); + debug(1, "Sound opened OK, mixing at %d Hz", _sampleRate); SDL_PauseAudio(0); return true; } @@ -851,18 +871,16 @@ void OSystem_WINCE3::update_game_settings() { panel->add(NAME_ITEM_BINDKEYS, new ItemAction(ITEM_BINDKEYS, POCKET_ACTION_BINDKEYS)); // portrait/landscape - screen dependent // FIXME : will still display the portrait/landscape icon when using a scaler (but will be disabled) - if (_screenWidth <= 320 && (isOzone() || !CEDevice::hasDesktopResolution())) { - if (ConfMan.hasKey("landscape")) - if (ConfMan.get("landscape")[0] > 57) { - _newOrientation = _orientationLandscape = ConfMan.getBool("landscape"); - //ConfMan.removeKey("landscape", ""); - ConfMan.setInt("landscape", _orientationLandscape); - } else - _newOrientation = _orientationLandscape = ConfMan.getInt("landscape"); - else - _newOrientation = _orientationLandscape = 0; - panel->add(NAME_ITEM_ORIENTATION, new ItemSwitch(ITEM_VIEW_LANDSCAPE, ITEM_VIEW_PORTRAIT, &_newOrientation, 2)); - } + if (ConfMan.hasKey("landscape")) + if (ConfMan.get("landscape")[0] > 57) { + _newOrientation = _orientationLandscape = ConfMan.getBool("landscape"); + //ConfMan.removeKey("landscape", ""); + ConfMan.setInt("landscape", _orientationLandscape); + } else + _newOrientation = _orientationLandscape = ConfMan.getInt("landscape"); + else + _newOrientation = _orientationLandscape = 0; + panel->add(NAME_ITEM_ORIENTATION, new ItemSwitch(ITEM_VIEW_LANDSCAPE, ITEM_VIEW_PORTRAIT, &_newOrientation, 2)); _toolbarHandler.add(NAME_MAIN_PANEL, *panel); _toolbarHandler.setActive(NAME_MAIN_PANEL); _toolbarHandler.setVisible(true); @@ -920,6 +938,9 @@ void OSystem_WINCE3::initSize(uint w, uint h) { if (w == 320 && h == 200 && !_hasSmartphoneResolution) h = 240; // use the extra 40 pixels height for the toolbar + if (h == 400) // touche engine fixup + h += 80; + if (!_hasSmartphoneResolution) if (h == 240) _toolbarHandler.setOffset(200); @@ -961,15 +982,15 @@ bool OSystem_WINCE3::update_scalers() { _adjustAspectRatio = false; if (CEDevice::hasPocketPCResolution()) { - if (!_orientationLandscape && (_screenWidth == 320 || !_screenWidth)) { + if ( (!_orientationLandscape && (_screenWidth == 320 || !_screenWidth)) + || CEDevice::hasSquareQVGAResolution() ) { _scaleFactorXm = 3; _scaleFactorXd = 4; _scaleFactorYm = 1; _scaleFactorYd = 1; _scalerProc = PocketPCPortrait; _modeFlags = 0; - } - if ( _orientationLandscape && (_screenWidth == 320 || !_screenWidth)) { + } else if ( _orientationLandscape && (_screenWidth == 320 || !_screenWidth)) { Common::String gameid(ConfMan.get("gameid")); // consider removing this check and start honoring the _adjustAspectRatio flag if (!_panelVisible && !_hasSmartphoneResolution && !_overlayVisible && !(strncmp(gameid.c_str(), "zak", 3) == 0)) { _scaleFactorXm = 1; @@ -987,16 +1008,14 @@ bool OSystem_WINCE3::update_scalers() { _scalerProc = Normal1x; _modeFlags = 0; } - } - if (_screenWidth == 640 && !(isOzone() && (getScreenWidth() >= 640 || getScreenHeight() >= 640))) { + } else if (_screenWidth == 640 && !(isOzone() && (getScreenWidth() >= 640 || getScreenHeight() >= 640))) { _scaleFactorXm = 1; _scaleFactorXd = 2; _scaleFactorYm = 1; _scaleFactorYd = 2; _scalerProc = PocketPCHalf; _modeFlags = 0; - } - if (_screenWidth == 640 && (isOzone() && (getScreenWidth() >= 640 || getScreenHeight() >= 640))) { + } else if (_screenWidth == 640 && (isOzone() && (getScreenWidth() >= 640 || getScreenHeight() >= 640))) { _scaleFactorXm = 1; _scaleFactorXd = 1; _scaleFactorYm = 1; @@ -1007,6 +1026,7 @@ bool OSystem_WINCE3::update_scalers() { return true; } + if (CEDevice::hasSmartphoneResolution()) { if (_screenWidth > 320) error("Game resolution not supported on Smartphone"); @@ -1174,49 +1194,44 @@ void OSystem_WINCE3::loadGFXMode() { // Create the surface that contains the 8 bit game data _screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth, _screenHeight, 8, 0, 0, 0, 0); if (_screen == NULL) - error("_screen failed"); + error("_screen failed (%s)", SDL_GetError()); // Create the surface that contains the scaled graphics in 16 bit mode - // Always use full screen mode to have a "clean screen" - displayWidth = _screenWidth * _scaleFactorXm / _scaleFactorXd; - displayHeight = _screenHeight * _scaleFactorYm / _scaleFactorYd; - if (_screenHeight == 400) // touche engine fixup - displayHeight += 80 * _scaleFactorYm / _scaleFactorYd; + if (!_adjustAspectRatio) { + displayWidth = _screenWidth * _scaleFactorXm / _scaleFactorXd; + displayHeight = _screenHeight * _scaleFactorYm / _scaleFactorYd; + } else { + displayWidth = _screenWidth; + displayHeight = _screenHeight; + } - // FIXME - if (displayWidth <= GetSystemMetrics(SM_CXSCREEN)) { // no rotation - displayWidth = GetSystemMetrics(SM_CXSCREEN); - displayHeight = GetSystemMetrics(SM_CYSCREEN); - } else if (displayHeight > GetSystemMetrics(SM_CXSCREEN)) // rotating, clip height - displayHeight = GetSystemMetrics(SM_CXSCREEN); - - if (_orientationLandscape == 2) flags |= SDL_FLIPVIDEO; + switch (_orientationLandscape) { + case 1: + flags |= SDL_LANDSCVIDEO; + break; + case 2: + flags |= SDL_INVLNDVIDEO; + break; + default: + flags |= SDL_PORTRTVIDEO; + } _hwscreen = SDL_SetVideoMode(displayWidth, displayHeight, 16, flags); if (_hwscreen == NULL) { - // DON'T use error(), as this tries to bring up the debug - // console, which WON'T WORK now that _hwscreen is hosed. - - // FIXME: We should be able to continue the game without - // shutting down or bringing up the debug console, but at - // this point we've already screwed up all our member vars. - // We need to find a way to call SDL_VideoModeOK *before* - // that happens and revert to all the old settings if we - // can't pull off the switch to the new settings. - // - // Fingolfin says: the "easy" way to do that is not to modify - // the member vars before we are sure everything is fine. Think - // of "transactions, commit, rollback" style... we use local vars - // in place of the member vars, do everything etc. etc.. In case - // of a failure, rollback is trivial. Only if everything worked fine - // do we "commit" the changed values to the member vars. - warning("SDL_SetVideoMode says we can't switch to that mode"); + warning("SDL_SetVideoMode says we can't switch to that mode (%s)", SDL_GetError()); quit(); } - // Create the surface used for the graphics in 16 bit before scaling, and also the overlay + // see what orientation sdl finally accepted + if (_hwscreen->flags & SDL_PORTRTVIDEO) + _orientationLandscape = _newOrientation = 0; + else if (_hwscreen->flags & SDL_LANDSCVIDEO) + _orientationLandscape = _newOrientation = 1; + else + _orientationLandscape = _newOrientation = 2; + // Create the surface used for the graphics in 16 bit before scaling, and also the overlay // Distinguish 555 and 565 mode if (_hwscreen->format->Rmask == 0x7C00) InitScalers(555); @@ -1228,38 +1243,39 @@ void OSystem_WINCE3::loadGFXMode() { _tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth + 3, _screenHeight + 3, 16, _hwscreen->format->Rmask, _hwscreen->format->Gmask, _hwscreen->format->Bmask, _hwscreen->format->Amask); if (_tmpscreen == NULL) - error("_tmpscreen creation failed"); + error("_tmpscreen creation failed (%s)", SDL_GetError()); // Overlay if (CEDevice::hasDesktopResolution()) { _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth * _scaleFactorXm / _scaleFactorXd, _overlayHeight * _scaleFactorYm / _scaleFactorYd, 16, 0, 0, 0, 0); if (_overlayscreen == NULL) - error("_overlayscreen failed"); + error("_overlayscreen failed (%s)", SDL_GetError()); _tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth * _scaleFactorXm / _scaleFactorXd + 3, _overlayHeight * _scaleFactorYm / _scaleFactorYd + 3, 16, 0, 0, 0, 0); if (_tmpscreen2 == NULL) - error("_tmpscreen2 failed"); + error("_tmpscreen2 failed (%s)", SDL_GetError()); } else { _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth, _overlayHeight, 16, 0, 0, 0, 0); if (_overlayscreen == NULL) - error("_overlayscreen failed"); + error("_overlayscreen failed (%s)", SDL_GetError()); _tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth + 3, _overlayHeight + 3, 16, 0, 0, 0, 0); if (_tmpscreen2 == NULL) - error("_tmpscreen2 failed"); + error("_tmpscreen2 failed (%s)", SDL_GetError()); } // Toolbar - uint16 *toolbar_screen = (uint16 *)calloc(320 * 40, sizeof(uint16)); + _toolbarHighDrawn = false; + uint16 *toolbar_screen = (uint16 *)calloc(320 * 40, sizeof(uint16)); // *not* leaking memory here _toolbarLow = SDL_CreateRGBSurfaceFrom(toolbar_screen, 320, 40, 16, 320 * 2, _hwscreen->format->Rmask, _hwscreen->format->Gmask, _hwscreen->format->Bmask, _hwscreen->format->Amask); if (_toolbarLow == NULL) - error("_toolbarLow failed"); + error("_toolbarLow failed (%s)", SDL_GetError()); if (_screenHeight > 240) { uint16 *toolbar_screen = (uint16 *)calloc(640 * 80, sizeof(uint16)); _toolbarHigh = SDL_CreateRGBSurfaceFrom(toolbar_screen, 640, 80, 16, 640 * 2, _hwscreen->format->Rmask, _hwscreen->format->Gmask, _hwscreen->format->Bmask, _hwscreen->format->Amask); if (_toolbarHigh == NULL) - error("_toolbarHigh failed"); + error("_toolbarHigh failed (%s)", SDL_GetError()); } else _toolbarHigh = NULL; @@ -1330,11 +1346,12 @@ void OSystem_WINCE3::hotswapGFXMode() { SDL_FreeSurface(old_overlayscreen); SDL_FreeSurface(old_tmpscreen2); - // Blit everything to the screen + // Blit everything back to the screen + _toolbarHighDrawn = false; internUpdateScreen(); - // Make sure that an Common::EVENT_SCREEN_CHANGED gets sent later - _modeChanged = true; + // Make sure that a Common::EVENT_SCREEN_CHANGED gets sent later -> FIXME this crashes when no game has been loaded. +// _modeChanged = true; } void OSystem_WINCE3::update_keyboard() { @@ -1355,8 +1372,17 @@ void OSystem_WINCE3::update_keyboard() { void OSystem_WINCE3::internUpdateScreen() { SDL_Surface *srcSurf, *origSurf; static bool old_overlayVisible = false; + int numRectsOut = 0; + int16 routx, routy, routw, routh; + assert(_hwscreen != NULL); + // bail if the application is minimized, be nice to OS + if (!_hasfocus) { + Sleep(20); + return; + } + update_keyboard(); // If the shake position changed, fill the dirty area with blackness @@ -1415,7 +1441,7 @@ void OSystem_WINCE3::internUpdateScreen() { // Only draw anything if necessary if (_numDirtyRects > 0) { - SDL_Rect *r; + SDL_Rect *r, *rout; SDL_Rect dst; uint32 srcPitch, dstPitch; SDL_Rect *last_rect = _dirtyRectList + _numDirtyRects; @@ -1424,8 +1450,9 @@ void OSystem_WINCE3::internUpdateScreen() { for (r = _dirtyRectList; r != last_rect; ++r) { dst = *r; - dst.x++; // Shift rect by one since 2xSai needs to acces the data around + dst.x++; // Shift rect by one since 2xSai needs to access the data around dst.y++; // any pixel to scale it, and we want to avoid mem access crashes. + // NOTE: This is also known as BLACK MAGIC, copied from the sdl backend if (SDL_BlitSurface(origSurf, r, srcSurf, &dst) != 0) error("SDL_BlitSurface failed: %s", SDL_GetError()); } @@ -1436,67 +1463,53 @@ void OSystem_WINCE3::internUpdateScreen() { srcPitch = srcSurf->pitch; dstPitch = _hwscreen->pitch; - for (r = _dirtyRectList; r != last_rect; ++r) { - register int dst_y = r->y + _currentShakePos; - register int dst_h = 0; - - // Check if the toolbar is overwritten - if (!_forceFull && toolbarVisible && r->y + r->h >= toolbarOffset) - _toolbarHandler.forceRedraw(); - - if (dst_y < _screenHeight) { - dst_h = r->h; - if (dst_h > _screenHeight - dst_y) - dst_h = _screenHeight - dst_y; - - dst_y *= _scaleFactorYm; - dst_y /= _scaleFactorYd; - - if (_adjustAspectRatio) - dst_h = real2Aspect(dst_h); - - // clip inside platform screen (landscape,bottom only) - if (_orientationLandscape && !_zoomDown && dst_y+dst_h > _screenHeight) - dst_h = _screenHeight - dst_y; - - if (!_zoomDown) - _scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, - (byte *)_hwscreen->pixels + (r->x * 2 * _scaleFactorXm / _scaleFactorXd) + dst_y * dstPitch, dstPitch, r->w, dst_h); - else { - _scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, - (byte *)_hwscreen->pixels + (r->x * 2 * _scaleFactorXm / _scaleFactorXd) + (dst_y - 240) * dstPitch, dstPitch, r->w, dst_h); + for (r = _dirtyRectList, rout = _dirtyRectOut; r != last_rect; ++r) { + // transform + routx = r->x * _scaleFactorXm / _scaleFactorXd; // locate position in scaled screen + routy = (r->y + _currentShakePos) * _scaleFactorYm / _scaleFactorYd; // adjust for shake offset + routw = r->w * _scaleFactorXm / _scaleFactorXd; + routh = r->h * _scaleFactorYm / _scaleFactorYd; + + // clipping destination rectangle inside device screen (more strict, also more tricky but more stable) + // note that all current scalers do not make dst rect exceed left/right, unless chosen badly (FIXME) + if (_zoomDown) routy -= 240; // adjust for zoom position + if (routy + routh < 0) continue; + if (routy < 0) { + routh += routy; + routy = 0; + } + if (_orientationLandscape) { + if (routy > _platformScreenWidth) continue; + if (routy + routh > _platformScreenWidth) { + routh = _platformScreenWidth - routy; + r->h = routh * _scaleFactorYd / _scaleFactorYm; + } + } else { + if (routy > _platformScreenHeight) continue; + if (routy + routh > _platformScreenHeight) { + routh = _platformScreenHeight - routy; + r->h = routh * _scaleFactorYd / _scaleFactorYm; } - } - r->x = r->x * _scaleFactorXm / _scaleFactorXd; - if (!_zoomDown) - r->y = dst_y; - else - r->y = dst_y - 240; - r->w = r->w * _scaleFactorXm / _scaleFactorXd; - if (!_adjustAspectRatio) - r->h = dst_h * _scaleFactorYm / _scaleFactorYd; - else - r->h = dst_h; + // check if the toolbar is overwritten + if (toolbarVisible && r->y + r->h >= toolbarOffset) + _toolbarHandler.forceRedraw(); + + // blit it (with added voodoo from the sdl backend, shifting the source rect again) + _scalerProc( (byte *)srcSurf->pixels + (r->x * 2 + 2)+ (r->y + 1) * srcPitch, srcPitch, + (byte *)_hwscreen->pixels + routx * 2 + routy * dstPitch, dstPitch, + r->w, r->h); + + // add this rect to output + rout->x = routx; rout->y = routy; + rout->w = routw; rout->h = routh; + numRectsOut++; + rout++; + } SDL_UnlockSurface(srcSurf); SDL_UnlockSurface(_hwscreen); - - // Readjust the dirty rect list in case we are doing a full update. - // This is necessary if shaking is active. - if (_forceFull) { - _dirtyRectList[0].y = 0; - _dirtyRectList[0].h = (_adjustAspectRatio ? 240 : (_zoomUp || _zoomDown ? _screenHeight / 2 : _screenHeight)) * _scaleFactorYm / _scaleFactorYd; - if (_orientationLandscape) - { - if (_dirtyRectList[0].h > _platformScreenWidth) - _dirtyRectList[0].h = _platformScreenWidth; // clip - } else { - if (_dirtyRectList[0].h > _platformScreenHeight) - _dirtyRectList[0].h = _platformScreenHeight; // clip - } - } } // Add the toolbar if needed SDL_Rect toolbar_rect[1]; @@ -1515,8 +1528,6 @@ void OSystem_WINCE3::internUpdateScreen() { SDL_UnlockSurface(_toolbarLow); _toolbarHighDrawn = true; } - else - _toolbarHighDrawn = false; toolbar_rect[0].w *= 2; toolbar_rect[0].h *= 2; toolbarSurface = _toolbarHigh; @@ -1548,8 +1559,8 @@ void OSystem_WINCE3::internUpdateScreen() { } // Finally, blit all our changes to the screen - if (_numDirtyRects > 0) - SDL_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList); + if (numRectsOut > 0) + SDL_UpdateRects(_hwscreen, numRectsOut, _dirtyRectOut); _numDirtyRects = 0; _forceFull = false; @@ -1563,30 +1574,6 @@ bool OSystem_WINCE3::saveScreenshot(const char *filename) { return true; } -// FIXME -// Reuse static or proper mapping - -static int mapKeyCE(SDLKey key, SDLMod mod, Uint16 unicode) -{ - if (GUI::Actions::Instance()->mappingActive()) - return key; - - if (key >= SDLK_F1 && key <= SDLK_F9) { - return key - SDLK_F1 + 315; - } else if (key >= SDLK_KP0 && key <= SDLK_KP9) { - return key - SDLK_KP0 + '0'; - } else if (key >= SDLK_UP && key <= SDLK_PAGEDOWN) { - return key; - } else if (unicode) { - return unicode; - } else if (key >= 'a' && key <= 'z' && mod & KMOD_SHIFT) { - return key & ~0x20; - } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) { - return 0; - } - return key; -} - void OSystem_WINCE3::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { assert (_transactionMode == kTransactionNone); @@ -2048,9 +2035,7 @@ void OSystem_WINCE3::addDirtyRect(int x, int y, int w, int h, bool mouseRect) { else h = 240 - y; } - } - else - if (_zoomDown) { + } else if (_zoomDown) { if (y + h >= 240) { if (y < 240) { h = 240 - y; @@ -2065,8 +2050,24 @@ void OSystem_WINCE3::addDirtyRect(int x, int y, int w, int h, bool mouseRect) { OSystem_SDL::addDirtyRect(x, y, w, h, false); } -// FIXME -// See if some SDL mapping can be useful for HPCs +static int mapKeyCE(SDLKey key, SDLMod mod, Uint16 unicode) +{ + if (GUI::Actions::Instance()->mappingActive()) + return key; + + if (key >= SDLK_KP0 && key <= SDLK_KP9) { + return key - SDLK_KP0 + '0'; + } else if (key >= SDLK_UP && key <= SDLK_PAGEDOWN) { + return key; + } else if (unicode) { + return unicode; + } else if (key >= 'a' && key <= 'z' && mod & KMOD_SHIFT) { + return key & ~0x20; + } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) { + return 0; + } + return key; +} bool OSystem_WINCE3::pollEvent(Common::Event &event) { SDL_Event ev; @@ -2096,6 +2097,7 @@ bool OSystem_WINCE3::pollEvent(Common::Event &event) { switch(ev.type) { case SDL_KEYDOWN: // KMOD_RESERVED is used if the key has been injected by an external buffer + debug(1, "Key down %X %s", ev.key.keysym.sym, SDL_GetKeyName((SDLKey)ev.key.keysym.sym)); if (ev.key.keysym.mod != KMOD_RESERVED) { keyEvent = true; _lastKeyPressed = ev.key.keysym.sym; @@ -2117,6 +2119,7 @@ bool OSystem_WINCE3::pollEvent(Common::Event &event) { case SDL_KEYUP: // KMOD_RESERVED is used if the key has been injected by an external buffer + debug(1, "Key up %X %s", ev.key.keysym.sym, SDL_GetKeyName((SDLKey)ev.key.keysym.sym)); if (ev.key.keysym.mod != KMOD_RESERVED) { keyEvent = true; _lastKeyPressed = 0; @@ -2181,12 +2184,13 @@ bool OSystem_WINCE3::pollEvent(Common::Event &event) { if (_toolbarHandler.action(temp_event.mouse.x, temp_event.mouse.y, true)) { if (!_toolbarHandler.drawn()) + _toolbarHighDrawn = false; internUpdateScreen(); - if (_newOrientation != _orientationLandscape && _mode == GFX_NORMAL) { + if (_newOrientation != _orientationLandscape){ _orientationLandscape = _newOrientation; + _toolbarHighDrawn = false; ConfMan.setInt("landscape", _orientationLandscape); ConfMan.flushToDisk(); - setGraphicsMode(GFX_NORMAL); hotswapGFXMode(); } } else { @@ -2213,6 +2217,7 @@ bool OSystem_WINCE3::pollEvent(Common::Event &event) { if (_toolbarHandler.action(temp_event.mouse.x, temp_event.mouse.y, false)) { if (!_toolbarHandler.drawn()) + _toolbarHighDrawn = false; internUpdateScreen(); } else { if (!_freeLook) @@ -2228,18 +2233,29 @@ bool OSystem_WINCE3::pollEvent(Common::Event &event) { case SDL_QUIT: event.type = Common::EVENT_QUIT; return true; + + case SDL_ACTIVEEVENT: + if (ev.active.state & SDL_APPMOUSEFOCUS) + debug(1, "%s mouse focus.", ev.active.gain ? "Got" : "Lost"); + if (ev.active.state & SDL_APPINPUTFOCUS) + debug(1, "%s input focus.", ev.active.gain ? "Got" : "Lost"); + if (ev.active.state & SDL_APPACTIVE) + debug(1, "%s total focus.", ev.active.gain ? "Got" : "Lost"); + if (ev.active.state & SDL_APPINPUTFOCUS) { + _hasfocus = ev.active.gain; + SDL_PauseAudio(!_hasfocus); + _forceFull |= _hasfocus; + } + break; } } - // Simulate repeated key for Smartphones - - if (!keyEvent) - if (_lastKeyPressed) - if (currentTime > _keyRepeatTime + _keyRepeatTrigger) { - _keyRepeatTime = currentTime; - _keyRepeat++; - GUI_Actions::Instance()->performMapped(_lastKeyPressed, true); - } + // Simulate repeated key for backend + if (!keyEvent && _lastKeyPressed && currentTime > _keyRepeatTime + _keyRepeatTrigger) { + _keyRepeatTime = currentTime; + _keyRepeat++; + GUI_Actions::Instance()->performMapped(_lastKeyPressed, true); + } return false; } @@ -2248,8 +2264,8 @@ void OSystem_WINCE3::quit() { fclose(stdout_file); fclose(stderr_file); if (gDebugLevel <= 0) { - DeleteFile(TEXT("\\scummvm_stdout.txt")); - DeleteFile(TEXT("\\scummvm_stderr.txt")); + DeleteFile(ASCIItoUnicode(stdout_fname)); + DeleteFile(ASCIItoUnicode(stderr_fname)); } CEDevice::end(); OSystem_SDL::quit(); diff --git a/backends/platform/wince/wince-sdl.h b/backends/platform/wince/wince-sdl.h index 7d797e5959..6f7cb7a0c1 100644 --- a/backends/platform/wince/wince-sdl.h +++ b/backends/platform/wince/wince-sdl.h @@ -206,7 +206,9 @@ private: int _scaleFactorXd; // scaler X / int _scaleFactorYm; // scaler Y * int _scaleFactorYd; // scaler Y / + SDL_Rect _dirtyRectOut[NUM_DIRTY_RECT]; bool _scalersChanged; + bool _hasfocus; // scummvm has the top window static int _platformScreenWidth; static int _platformScreenHeight; |