diff options
| author | David Corrales | 2007-05-26 20:23:24 +0000 |
|---|---|---|
| committer | David Corrales | 2007-05-26 20:23:24 +0000 |
| commit | 3646c968c9578c2a94d65ebd5fb06ec835f8c51d (patch) | |
| tree | 8b57b339ebb31a1d7a67f1678aa5dc5c7759070a /backends/platform/PalmOS/Src | |
| parent | d1f56d93f934150f4b579c2e90564e2bf035f113 (diff) | |
| parent | ac45c5b33d834acbc9718f89be76e49d403a4d2c (diff) | |
| download | scummvm-rg350-3646c968c9578c2a94d65ebd5fb06ec835f8c51d.tar.gz scummvm-rg350-3646c968c9578c2a94d65ebd5fb06ec835f8c51d.tar.bz2 scummvm-rg350-3646c968c9578c2a94d65ebd5fb06ec835f8c51d.zip | |
Merged the fs branch with trunk. r26472:26948
svn-id: r26949
Diffstat (limited to 'backends/platform/PalmOS/Src')
63 files changed, 721 insertions, 1958 deletions
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); } |
