aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorChris Apers2005-10-08 22:18:29 +0000
committerChris Apers2005-10-08 22:18:29 +0000
commit41b0ba9f95e87b6a2c3ad448440dfec5fdcd4e51 (patch)
tree2b00b0bc44ea91dec1e32f13dcc36bf383a797ad /backends
parent18d33dc07847cbb5e8c525103d37efe231b5f1d0 (diff)
downloadscummvm-rg350-41b0ba9f95e87b6a2c3ad448440dfec5fdcd4e51.tar.gz
scummvm-rg350-41b0ba9f95e87b6a2c3ad448440dfec5fdcd4e51.tar.bz2
scummvm-rg350-41b0ba9f95e87b6a2c3ad448440dfec5fdcd4e51.zip
New PalmOS backends
svn-id: r18981
Diffstat (limited to 'backends')
-rwxr-xr-xbackends/PalmOS/Src/base_event.cpp273
-rwxr-xr-xbackends/PalmOS/Src/base_gfx.cpp206
-rwxr-xr-xbackends/PalmOS/Src/base_mouse.cpp75
-rwxr-xr-xbackends/PalmOS/Src/be_base.cpp87
-rwxr-xr-xbackends/PalmOS/Src/be_base.h238
-rwxr-xr-xbackends/PalmOS/Src/be_create.cpp41
-rwxr-xr-xbackends/PalmOS/Src/be_os5.cpp33
-rwxr-xr-xbackends/PalmOS/Src/be_os5.h82
-rwxr-xr-xbackends/PalmOS/Src/be_save.cpp148
-rwxr-xr-xbackends/PalmOS/Src/be_zodiac.cpp102
-rwxr-xr-xbackends/PalmOS/Src/be_zodiac.h91
-rwxr-xr-xbackends/PalmOS/Src/os5_event.cpp32
-rwxr-xr-xbackends/PalmOS/Src/os5_gfx.cpp130
-rwxr-xr-xbackends/PalmOS/Src/os5_mouse.cpp133
-rwxr-xr-xbackends/PalmOS/Src/os5_overlay.cpp37
-rwxr-xr-xbackends/PalmOS/Src/os5_sound.cpp124
-rwxr-xr-xbackends/PalmOS/Src/zodiac_event.cpp114
-rwxr-xr-xbackends/PalmOS/Src/zodiac_gfx.cpp364
-rwxr-xr-xbackends/PalmOS/Src/zodiac_mouse.cpp199
-rwxr-xr-xbackends/PalmOS/Src/zodiac_overlay.cpp91
20 files changed, 2600 insertions, 0 deletions
diff --git a/backends/PalmOS/Src/base_event.cpp b/backends/PalmOS/Src/base_event.cpp
new file mode 100755
index 0000000000..061d1c1c7e
--- /dev/null
+++ b/backends/PalmOS/Src/base_event.cpp
@@ -0,0 +1,273 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_base.h"
+
+void OSystem_PalmBase::timer_handler() {
+ UInt32 msecs = getMillis();
+
+ if (_timer.active && (msecs >= _timer.nextExpiry)) {
+ _timer.duration = _timer.callback(_timer.duration);
+ _timer.nextExpiry = msecs + _timer.duration;
+ }
+}
+
+void OSystem_PalmBase::battery_handler() {
+// UInt16 voltage, warnThreshold, criticalThreshold;
+// voltage = SysBatteryInfo(false, &warnThreshold, &criticalThreshold, NULL, NULL, NULL, NULL);
+
+/*
+ if (voltage <= warnThreshold) {
+ if (!_showBatLow) {
+ _showBatLow = true;
+ draw1BitGfx(kDrawBatLow, (getWidth() >> 1), -16, true);
+ }
+ } else {
+ if (_showBatLow) {
+ _showBatLow = false;
+ draw1BitGfx(kDrawBatLow, (getWidth() >> 1), -16, false);
+ }
+ }
+*//*
+ if (voltage <= criticalThreshold) {
+ ::EventType event;
+ event.eType = keyDownEvent;
+ event.data.keyDown.chr = vchrAutoOff;
+ event.data.keyDown.modifiers = commandKeyMask;
+ EvtAddUniqueEventToQueue(&event, 0, true);
+ }*/
+}
+
+bool OSystem_PalmBase::pollEvent(Event &event) {
+ ::EventType ev;
+ Boolean handled;
+ UInt32 keyCurrentState;
+ Coord x, y;
+
+ battery_handler();
+ timer_handler();
+ sound_handler();
+
+ for(;;) {
+ EvtGetEvent(&ev, evtNoWait);
+
+ // check for hardkey repeat for mouse emulation
+ keyCurrentState = KeyCurrentState();
+ // check_hard_keys();
+
+ if ((keyCurrentState & _keyMouseMask)) {
+ Int8 sx = 0;
+ Int8 sy = 0;
+
+ if (keyCurrentState & _keyMouse.bitUp)
+ sy = -1;
+ else if (keyCurrentState & _keyMouse.bitDown)
+ sy = +1;
+
+ if (keyCurrentState & _keyMouse.bitLeft)
+ sx = -1;
+ else if (keyCurrentState & _keyMouse.bitRight)
+ sx = +1;
+
+ simulate_mouse(event, sx, sy, &x, &y);
+ warpMouse(x, y);
+ updateScreen();
+ // updateCD();
+ event.type = EVENT_MOUSEMOVE;
+ event.mouse.x = x;
+ event.mouse.y = y;
+
+ _lastKey = kKeyMouseMove;
+ return true;
+ }
+
+ if (ev.eType == keyDownEvent) {
+ switch (ev.data.keyDown.chr) {
+ // ESC key
+ case vchrLaunch:
+ _lastKey = kKeyNone;
+ event.type = EVENT_KEYDOWN;
+ event.kbd.keycode = 27;
+ event.kbd.ascii = 27;
+ event.kbd.flags = 0;
+ return true;
+
+ // F5 = menu
+ case vchrMenu:
+ _lastKey = kKeyNone;
+ event.type = EVENT_KEYDOWN;
+ event.kbd.keycode = 319;
+ event.kbd.ascii = 319;
+ event.kbd.flags = 0;
+ return true;
+
+ // if hotsync pressed, etc...
+ case vchrHardCradle:
+ case vchrHardCradle2:
+ case vchrLowBattery:
+ case vchrFind:
+// case vchrBrightness: // volume control on Zodiac, let other backends disable it
+ case vchrContrast:
+ // do nothing
+ _lastKey = kKeyNone;
+ return true;
+ }
+ }
+
+ if (check_event(event, &ev))
+ return true;
+ _lastKey = kKeyNone;
+
+ // prevent crash when alarm is raised
+ handled = ((ev.eType == keyDownEvent) &&
+ (ev.data.keyDown.modifiers & commandKeyMask) &&
+ ((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);
+
+ if (y > _screenHeight || y < 0 || x > _screenWidth || x < 0)
+ return false;
+
+ if (_lastEvent != penMoveEvent && (abs(y - event.mouse.y) <= 2 || abs(x - event.mouse.x) <= 2)) // move only if
+ return false;
+
+ _lastEvent = penMoveEvent;
+ event.type = EVENT_MOUSEMOVE;
+ event.mouse.x = x;
+ event.mouse.y = y;
+ warpMouse(x, y);
+ return true;
+
+ case penDownEvent:
+ get_coordinates(&ev, x, y);
+
+ // indy fight mode
+ if (_useNumPad && !_overlayVisible) {
+ char num = '1';
+ num += 9 -
+ (3 - (3 * x / _screenWidth )) -
+ (3 * (3 * y / _screenHeight));
+
+ event.type = EVENT_KEYDOWN;
+ event.kbd.keycode = num;
+ event.kbd.ascii = num;
+ event.kbd.flags = 0;
+
+ _lastEvent = keyDownEvent;
+ return true;
+ }
+
+ _lastEvent = penDownEvent;
+ if (y > _screenHeight || y < 0 || x > _screenWidth || x < 0)
+ return false;
+
+ event.type = ((gVars->stylusClick || _overlayVisible) ? EVENT_LBUTTONDOWN : EVENT_MOUSEMOVE);
+ event.mouse.x = x;
+ event.mouse.y = y;
+ warpMouse(x, y);
+ return true;
+
+ case penUpEvent:
+ get_coordinates(&ev, x, y);
+
+ event.type = ((gVars->stylusClick || _overlayVisible) ? EVENT_LBUTTONUP : EVENT_MOUSEMOVE);
+ if (y > _screenHeight || y < 0 || x > _screenWidth || x < 0)
+ return false;
+
+ event.mouse.x = x;
+ event.mouse.y = y;
+ warpMouse(x, y);
+ return true;
+
+ case keyDownEvent:
+ if (ev.data.keyDown.chr == vchrCommand &&
+ (ev.data.keyDown.modifiers & commandKeyMask)) {
+
+ _lastKeyModifier++;
+ _lastKeyModifier %= kModifierCount;
+
+ if (_lastKeyModifier)
+ draw_osd((kDrawKeyState + _lastKeyModifier - 1), 2, _screenDest.h + 2, true);
+ else
+ draw_osd(kDrawKeyState, 2, _screenDest.h + 2, false);
+
+ return false;
+ }
+
+ char mask = 0;
+ UInt16 key = ev.data.keyDown.chr;
+
+ if (_lastKeyModifier == kModifierNone) {
+ // for keyboard mode
+ if (ev.data.keyDown.modifiers & shiftKeyMask) mask |= KBD_SHIFT;
+ if (ev.data.keyDown.modifiers & controlKeyMask) mask |= KBD_CTRL;
+ if (ev.data.keyDown.modifiers & optionKeyMask) mask |= KBD_ALT;
+ if (ev.data.keyDown.modifiers & commandKeyMask) mask |= KBD_CTRL|KBD_ALT;
+ } else {
+ // for grafiti mode
+ if (_lastKeyModifier == kModifierCommand) mask = KBD_CTRL|KBD_ALT;
+ if (_lastKeyModifier == kModifierAlt) mask = KBD_ALT;
+ if (_lastKeyModifier == kModifierCtrl) mask = KBD_CTRL;
+ }
+
+ if (_lastKeyModifier)
+ draw_osd(kDrawKeyState, 2, _screenDest.h + 2, false);
+ _lastKeyModifier = kModifierNone;
+
+ // F1 -> F10 key
+ if (key >= '0' && key <= '9' && mask == (KBD_CTRL|KBD_ALT)) {
+ key = (key == '0') ? 324 : (315 + key - '1');
+ mask = 0;
+
+ // exit
+ } else if ((key == 'z' && mask == KBD_CTRL) || (mask == KBD_ALT && key == 'x')) {
+ event.type = EVENT_QUIT;
+ return true;
+
+ // num pad (indy fight mode)
+ } else if (key == 'n' && mask == KBD_CTRL|KBD_ALT && !_overlayVisible) {
+ _useNumPad = !_useNumPad;
+ draw_osd(kDrawFight, _screenDest.w - 34, _screenDest.h + 2, _useNumPad, 1);
+ return false;
+ }
+
+ // other keys
+ event.type = EVENT_KEYDOWN;
+ event.kbd.keycode = key;
+ event.kbd.ascii = key;
+ event.kbd.flags = mask;
+ return true;
+
+ default:
+ return false;
+ };
+ }
+}
diff --git a/backends/PalmOS/Src/base_gfx.cpp b/backends/PalmOS/Src/base_gfx.cpp
new file mode 100755
index 0000000000..39555433e0
--- /dev/null
+++ b/backends/PalmOS/Src/base_gfx.cpp
@@ -0,0 +1,206 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_base.h"
+
+#ifdef PALMOS_68K
+# include <BmpGlue.h>
+#endif
+
+/*
+ * Graphics modes
+ *
+ */
+
+static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
+ {"normal", "Normal", GFX_NORMAL},
+ {"wide", "Wide", GFX_WIDE},
+ {0, 0, 0}
+};
+
+int OSystem_PalmBase::getDefaultGraphicsMode() const {
+ return GFX_NORMAL;
+}
+
+const OSystem::GraphicsMode *OSystem_PalmBase::getSupportedGraphicsModes() const {
+ return int_getSupportedGraphicsModes();
+}
+
+const OSystem::GraphicsMode *OSystem_PalmBase::int_getSupportedGraphicsModes() const {
+ return s_supportedGraphicsModes;
+}
+
+int OSystem_PalmBase::getGraphicsMode() const {
+ return _mode;
+}
+
+bool OSystem_PalmBase::setGraphicsMode(int mode) {
+ switch(mode) {
+ case GFX_NORMAL:
+ case GFX_WIDE:
+ _setMode = mode;
+ break;
+
+ default:
+ warning("unknown gfx mode %d", mode);
+ _setMode = GFX_NORMAL;
+ return false;
+ }
+
+ return true;
+}
+
+/*
+ * Init
+ *
+ */
+
+void OSystem_PalmBase::initSize(uint w, uint h, int overlayScale) {
+ _screenWidth = w;
+ _screenHeight = h;
+
+ _screenDest.w = _screenWidth;
+ _screenDest.h = _screenHeight;
+
+ unload_gfx_mode();
+ _mode = _setMode;
+ load_gfx_mode();
+
+ warpMouse(200, 150);
+ int_initSize(w, h, overlayScale);
+}
+
+/*
+ * Palette
+ *
+ */
+void OSystem_PalmBase::setPalette(const byte *colors, uint start, uint num) {
+ RGBColorType *base = _currentPalette + start;
+
+ for(uint i = 0; i < num; i++) {
+ base[i].r = colors[0];
+ base[i].g = colors[1];
+ base[i].b = colors[2];
+
+ extras_palette(i + start, colors[0], colors[1], colors[2]);
+ colors += 4;
+ }
+
+ if (start < _paletteDirtyStart)
+ _paletteDirtyStart = start;
+
+ if (start + num > _paletteDirtyEnd)
+ _paletteDirtyEnd = start + num;
+}
+
+/*
+ * Screen
+ *
+ */
+
+void OSystem_PalmBase::setShakePos(int shakeOffset) {
+ _new_shake_pos = shakeOffset;
+ int_setShakePos(shakeOffset);
+}
+
+void OSystem_PalmBase::updateScreen() {
+ // Check whether the palette was changed in the meantime and update the
+ // screen surface accordingly.
+ if (_paletteDirtyEnd != 0) {
+ WinSetDrawWindow(WinGetDisplayWindow());
+ WinPalette(winPaletteSet, _paletteDirtyStart, _paletteDirtyEnd - _paletteDirtyStart, _currentPalette + _paletteDirtyStart);
+ _paletteDirtyEnd = 0;
+
+/* UInt8 oldCol;
+ oldCol = gVars->indicator.on;
+ gVars->indicator.on = RGBToColor(0,255,0);
+
+ if (oldCol != gVars->indicator.on) {
+ // redraw if needed
+ if (_lastKeyModifier)
+ draw1BitGfx((kDrawKeyState + _lastKeyModifier - 1), 2, getHeight() + 2, true);
+
+ if(_useNumPad)
+ draw1BitGfx(kDrawNumPad, (getWidth() >> 1) - 32, getHeight() + 2, true);
+
+ if (_showBatLow)
+ draw1BitGfx(kDrawBatLow, (getWidth() >> 1), -16, true);
+ }
+*/ }
+
+ int_updateScreen();
+ draw_mouse();
+}
+
+void OSystem_PalmBase::clearScreen() {
+ WinSetDrawWindow(WinGetDisplayWindow());
+ WinSetBackColor(RGBToColor(0,0,0));
+ WinEraseWindow();
+}
+
+void OSystem_PalmBase::draw_osd(UInt16 id, Int32 x, Int32 y, Boolean show, UInt8 color) {
+ MemHandle hTemp = DmGetResource(bitmapRsc, id);
+
+ if (hTemp) {
+ BitmapType *bmTemp;
+ UInt32 *bmData;
+ UInt8 ih, iw, ib;
+ Coord w, h;
+ Int16 blocks, next;
+
+ UInt8 *scr = _screenP + x + _screenPitch * y;
+ bmTemp = (BitmapType *)MemHandleLock(hTemp);
+ bmData = (UInt32 *)BmpGetBits(bmTemp);
+
+#ifdef PALMOS_68K
+ BmpGlueGetDimensions(bmTemp, &w, &h, 0);
+#else
+ BmpGetDimensions(bmTemp, &w, &h, 0);
+#endif
+
+ blocks = w >> 5;
+ next = w - (blocks << 5);
+
+ if (next)
+ blocks++;
+
+ for (ih = 0; ih < h; ih++) { // line
+ for (ib = 0; ib < blocks; ib++) { // 32pix block
+ next = w - (ib << 5);
+ next = MIN(next, (Coord)32);
+
+ for (iw = 0; iw < next; iw++) { // row
+ *scr++ = ((*bmData & (1 << (31 - iw))) && show) ?
+ gVars->indicator.on :
+ gVars->indicator.off;
+ }
+
+ bmData++;
+ }
+ scr += _screenPitch - w;
+ }
+
+ MemHandleUnlock(hTemp);
+ DmReleaseResource(hTemp);
+ }
+}
diff --git a/backends/PalmOS/Src/base_mouse.cpp b/backends/PalmOS/Src/base_mouse.cpp
new file mode 100755
index 0000000000..3b5d552fdf
--- /dev/null
+++ b/backends/PalmOS/Src/base_mouse.cpp
@@ -0,0 +1,75 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_base.h"
+
+void OSystem_PalmBase::warpMouse(int x, int y) {
+ if (x != _mouseCurState.x || y != _mouseCurState.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;
+
+ if (visible)
+ draw_mouse();
+ else
+ undraw_mouse();
+
+ return last;
+}
+
+void OSystem_PalmBase::simulate_mouse(Event &event, Int8 iHoriz, Int8 iVert, Coord *xr, Coord *yr) {
+ Int16 x = _mouseCurState.x;
+ Int16 y = _mouseCurState.y;
+ Int16 slow;
+
+ if (_lastKey != kKeyNone) {
+ _lastKeyRepeat++;
+
+ if (_lastKeyRepeat > 16)
+ _lastKeyRepeat = 16;
+ }
+ else
+ _lastKeyRepeat = 0;
+
+ slow = (iHoriz && iVert) ? 2 : 1;
+
+ x += iHoriz * (_lastKeyRepeat >> 2) / slow;
+ y += iVert * (_lastKeyRepeat >> 2) / slow;
+
+ x = (x < 0 ) ? 0 : x;
+ x = (x >= _screenWidth ) ? _screenWidth - 1 : x;
+ y = (y < 0 ) ? 0 : y;
+ y = (y >= _screenHeight ) ? _screenHeight - 1 : y;
+
+ *xr = x;
+ *yr = y;
+}
diff --git a/backends/PalmOS/Src/be_base.cpp b/backends/PalmOS/Src/be_base.cpp
new file mode 100755
index 0000000000..89757fe0f5
--- /dev/null
+++ b/backends/PalmOS/Src/be_base.cpp
@@ -0,0 +1,87 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_base.h"
+#include "common/config-file.h"
+#include "common/config-manager.h"
+
+void OSystem_PalmBase::initBackend() {
+ _overlayVisible = false;
+
+ _current_shake_pos = 0;
+ _new_shake_pos = 0;
+
+ _paletteDirtyStart = 0;
+ _paletteDirtyEnd = 0;
+
+ _gfxLoaded = false;
+ _modeChanged = false;
+ _setMode = GFX_NORMAL;
+ _mode = _setMode;
+ _redawOSD = false;
+
+ _offScreenH = NULL;
+ _screenH = NULL;
+ _offScreenP = NULL;
+ _screenP = NULL;
+ _screenPitch = gVars->screenPitch;
+
+ _lastEvent = nilEvent;
+ _lastKey = kKeyNone;
+ _lastKeyModifier = kModifierNone;
+ _lastKeyRepeat = 100;
+ _useNumPad = false;
+
+ _mouseDataH = NULL;
+ _mouseDataP = NULL;
+ _mouseVisible = false;
+ _mouseDrawn = false;
+ MemSet(&_keyMouse, sizeof(_keyMouse), 0);
+ MemSet(&_mouseCurState, sizeof(_mouseCurState), 0);
+ MemSet(&_mouseOldState, sizeof(_mouseOldState), 0);
+
+ int_initBackend();
+ _keyMouseMask = (_keyMouse.bitUp | _keyMouse.bitDown | _keyMouse.bitLeft | _keyMouse.bitRight | _keyMouse.bitButLeft);
+}
+
+uint32 OSystem_PalmBase::getMillis() {
+ return TimGetTicks() * 1000 / SysTicksPerSecond();
+}
+
+void OSystem_PalmBase::delayMillis(uint msecs) {
+ Int32 delay = (SysTicksPerSecond() * msecs) / 1000;
+
+ if (delay > 0)
+ SysTaskDelay(delay);
+}
+
+void OSystem_PalmBase::setTimerCallback(TimerProc callback, int timer) {
+ if (callback != NULL) {
+ _timer.duration = timer;
+ _timer.nextExpiry = getMillis() + timer;
+ _timer.callback = callback;
+ _timer.active = true;
+ } else {
+ _timer.active = false;
+ }
+}
diff --git a/backends/PalmOS/Src/be_base.h b/backends/PalmOS/Src/be_base.h
new file mode 100755
index 0000000000..bcd0ac22df
--- /dev/null
+++ b/backends/PalmOS/Src/be_base.h
@@ -0,0 +1,238 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#ifndef BE_BASE_H
+#define BE_BASE_H
+
+#define ALLOW_ACCESS_TO_INTERNALS_OF_BITMAPS
+
+#include "common/stdafx.h"
+#include "common/scummsys.h"
+#include "common/system.h"
+
+enum {
+ GFX_NORMAL = 0,
+ GFX_WIDE,
+};
+
+// OSD key state
+enum {
+ kModifierNone = 0,
+ kModifierCommand,
+ kModifierAlt,
+ kModifierCtrl,
+ kModifierCount
+};
+
+// OSD resource id
+#define kDrawKeyState 3000
+#define kDrawNumPad 3010
+#define kDrawBatLow 3020
+#define kDrawFight 3030
+
+class OSystem_PalmBase : public OSystem {
+private:
+ struct {
+ uint32 duration, nextExpiry;
+ bool active;
+ TimerProc callback;
+ } _timer;
+
+ virtual void int_initBackend() { }
+
+ virtual const GraphicsMode *int_getSupportedGraphicsModes() const;
+ virtual void int_updateScreen() = 0;
+ virtual void int_initSize(uint w, uint h, int overlayScale) = 0;
+ virtual void int_setShakePos(int shakeOffset) { }
+
+ virtual void extras_palette(uint8 index, uint8 r, uint8 g, uint8 b) { }
+ virtual void int_quit() { }
+
+ virtual void unload_gfx_mode() = 0;
+ virtual void load_gfx_mode() = 0;
+
+ virtual void draw_mouse() = 0;
+ virtual void undraw_mouse() = 0;
+
+// virtual bool check_hard_keys() = 0;
+ virtual bool check_event(Event &event, EventPtr ev) = 0;
+
+ void timer_handler();
+ void battery_handler();
+ virtual void get_coordinates(EventPtr ev, Coord &x, Coord &y) = 0;
+ void simulate_mouse(Event &event, Int8 iHoriz, Int8 iVert, Coord *xr, Coord *yr);
+ virtual void sound_handler() {};
+ virtual void draw_osd(UInt16 id, Int32 x, Int32 y, Boolean show, UInt8 color = 0);
+
+protected:
+ enum {
+ kKeyNone = 0,
+ kKeyMouseMove = 1 << 0,
+ kKeyMouseLButton = 1 << 1,
+
+ kKeyCalc = 1 << 30,
+ kKeyAny = 1 << 31
+ };
+ enum {
+ MAX_MOUSE_W = 40, // should be 80x80 with 640x480 games ?
+ MAX_MOUSE_H = 40
+ };
+ struct MousePos {
+ int16 x,y,w,h;
+ };
+
+ RGBColorType _currentPalette[256];
+ uint _paletteDirtyStart, _paletteDirtyEnd;
+
+ int _mode, _setMode;
+ int16 _screenWidth, _screenHeight;
+ Boolean _modeChanged, _gfxLoaded;
+ UInt32 _screenPitch;
+
+ PointType _screenOffset;
+ struct {
+ Coord w, h;
+ } _screenDest;
+ byte *_screenP, *_offScreenP;
+ WinHandle _screenH, _offScreenH;
+
+ int _current_shake_pos;
+ int _new_shake_pos;
+
+ Boolean _overlayVisible;
+ Boolean _redawOSD;
+
+ UInt32 _keyMouseMask;
+ struct {
+ UInt32 bitUp;
+ UInt32 bitDown;
+ UInt32 bitLeft;
+ UInt32 bitRight;
+ UInt32 bitButLeft;
+ } _keyMouse;
+
+ bool _mouseVisible;
+ bool _mouseDrawn;
+ MousePos _mouseCurState;
+ MousePos _mouseOldState;
+ int16 _mouseHotspotX;
+ int16 _mouseHotspotY;
+ byte _mouseKeyColor;
+ byte *_mouseDataP, *_mouseBackupP;
+ WinHandle _mouseDataH, _mouseBackupH;
+
+ eventsEnum _lastEvent;
+ WChar _lastKey;
+ UInt8 _lastKeyModifier;
+ UInt32 _lastKeyRepeat;
+ Boolean _useNumPad;
+
+ int _samplesPerSec;
+
+public:
+ void initBackend();
+
+/*
+ virtual void setFeatureState(Feature f, bool enable) {};
+
+
+ bool hasFeature(Feature f);
+ bool getFeatureState(Feature f);
+
+ virtual void beginGFXTransaction();
+ virtual void endGFXTransaction();
+ virtual bool grabRawScreen(Graphics::Surface *surf);
+
+ virtual int16 getOverlayHeight();
+ virtual int16 getOverlayWidth();
+ virtual int screenToOverlayX(int x);
+ virtual int screenToOverlayY(int y);
+ virtual int overlayToScreenX(int x);
+ virtual int overlayToScreenY(int y);
+
+ virtual OverlayColor ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b);
+ virtual void colorToARGB(OverlayColor color, uint8 &a, uint8 &r, uint8 &g, uint8 &b);
+
+ virtual void setCursorPalette(const byte *colors, uint start, uint num);
+ virtual void disableCursorPalette(bool disable);
+
+ virtual void displayMessageOnOSD(const char *msg);
+*/
+ const GraphicsMode *getSupportedGraphicsModes() const;
+ int getGraphicsMode() const;
+ int getDefaultGraphicsMode() const;
+ virtual bool setGraphicsMode(int mode);
+
+ void initSize(uint w, uint h, int overlayScale);
+ int16 getWidth() { return _screenWidth; }
+ int16 getHeight() { return _screenHeight; }
+
+ void setShakePos(int shakeOffset);
+ virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) = 0;
+ virtual void updateScreen();
+ virtual void clearScreen();
+
+ 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;
+
+ virtual void showOverlay() = 0;
+ virtual void hideOverlay() = 0;
+ virtual void clearOverlay() = 0;
+ virtual void grabOverlay(OverlayColor *buf, int pitch) = 0;
+ virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) = 0;
+
+ void setPalette(const byte *colors, uint start, uint num);
+ void grabPalette(byte *colors, uint start, uint num) { /* TODO */ };
+ virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b) = 0;
+ virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) = 0;
+
+ bool pollEvent(Event &event);
+
+ virtual uint32 getMillis();
+ virtual void delayMillis(uint msecs);
+
+ void setTimerCallback(TimerProc callback, int interval);
+
+ MutexRef createMutex() { return NULL; }
+ void lockMutex(MutexRef mutex) {}
+ void unlockMutex(MutexRef mutex) {}
+ void deleteMutex(MutexRef mutex) {}
+
+ virtual bool setSoundCallback(SoundProc proc, void *param) = 0;
+ virtual void clearSoundCallback() = 0;
+ int getOutputSampleRate() const { return _samplesPerSec; }
+
+ bool openCD(int drive) { return true;};
+ bool pollCD() { return true;};
+ void playCD(int track, int num_loops, int start_frame, int duration) {};
+ void stopCD() {};
+ void updateCD() {};
+
+ void quit() { int_quit(); }
+ virtual void setWindowCaption(const char *caption) = 0;
+
+ Common::SaveFileManager *getSavefileManager();
+};
+
+#endif
diff --git a/backends/PalmOS/Src/be_create.cpp b/backends/PalmOS/Src/be_create.cpp
new file mode 100755
index 0000000000..46543a9afc
--- /dev/null
+++ b/backends/PalmOS/Src/be_create.cpp
@@ -0,0 +1,41 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_os5.h"
+#include "be_zodiac.h"
+
+OSystem *OSystem_PalmOS5_create() {
+ return OSystem_PalmOS5::create();
+}
+
+OSystem *OSystem_PalmOS5::create() {
+ return new OSystem_PalmOS5();
+}
+
+OSystem *OSystem_PalmZodiac_create() {
+ return OSystem_PalmZodiac::create();
+}
+
+OSystem *OSystem_PalmZodiac::create() {
+ return new OSystem_PalmZodiac();
+}
diff --git a/backends/PalmOS/Src/be_os5.cpp b/backends/PalmOS/Src/be_os5.cpp
new file mode 100755
index 0000000000..a3f4a3dda3
--- /dev/null
+++ b/backends/PalmOS/Src/be_os5.cpp
@@ -0,0 +1,33 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_os5.h"
+
+void OSystem_PalmOS5::int_initBackend() {
+}
+
+void OSystem_PalmOS5::int_quit() {
+ unload_gfx_mode();
+ clearSoundCallback();
+ exit(0);
+}
diff --git a/backends/PalmOS/Src/be_os5.h b/backends/PalmOS/Src/be_os5.h
new file mode 100755
index 0000000000..0d49dacb94
--- /dev/null
+++ b/backends/PalmOS/Src/be_os5.h
@@ -0,0 +1,82 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#ifndef BE_OS5_H
+#define BE_OS5_H
+
+#include "be_base.h"
+
+typedef struct {
+ UInt32 __a4;
+ UInt32 __a5;
+
+ void *proc;
+ void *param;
+
+ SndStreamRef handle;
+ Boolean active;
+} SoundDataType;
+
+class OSystem_PalmOS5 : public OSystem_PalmBase {
+private:
+ virtual void int_initBackend();
+ virtual void int_updateScreen();
+ virtual void int_initSize(uint w, uint h, int overlayScale);
+
+ virtual void unload_gfx_mode();
+ virtual void load_gfx_mode();
+
+ void draw_mouse();
+ void undraw_mouse();
+ virtual void get_coordinates(EventPtr ev, Coord &x, Coord &y);
+ virtual bool check_event(Event &event, EventPtr ev) { return false;}
+
+protected:
+ UInt16 _sysOldCoord, _sysOldOrientation;
+ SoundDataType _sound;
+
+public:
+ static OSystem *create();
+
+ void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
+ void clearScreen();
+
+ virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale);
+
+ virtual void showOverlay() {};
+ virtual void hideOverlay() {};
+ virtual void clearOverlay() {};
+ virtual void grabOverlay(OverlayColor *buf, int pitch) {};
+ 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);
+
+ bool setSoundCallback(SoundProc proc, void *param);
+ void clearSoundCallback();
+
+ void int_quit();
+ void setWindowCaption(const char *caption) {};
+
+};
+
+#endif
diff --git a/backends/PalmOS/Src/be_save.cpp b/backends/PalmOS/Src/be_save.cpp
new file mode 100755
index 0000000000..77eda30aeb
--- /dev/null
+++ b/backends/PalmOS/Src/be_save.cpp
@@ -0,0 +1,148 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_base.h"
+#include "common/savefile.h"
+
+// SaveFile class
+
+class PalmSaveFile : public Common::SaveFile {
+private:
+ FILE *fh;
+public:
+ PalmSaveFile(const char *filename, bool saveOrLoad) {
+ fh = ::fopen(filename, (saveOrLoad? "wb" : "rb"));
+ }
+ ~PalmSaveFile() {
+ if (fh) ::fclose(fh);
+ }
+
+ bool eos() const { return feof(fh) != 0; }
+ bool ioFailed() const { return ferror(fh) != 0; }
+ void clearIOFailed() { clearerr(fh); }
+
+ bool isOpen() const { return fh != NULL; }
+
+ uint32 read(void *buf, uint32 size);
+ uint32 write(const void *buf, uint32 size);
+
+ void skip(uint32 offset) {
+ ::fseek(fh, offset, SEEK_CUR);
+ }
+};
+
+uint32 PalmSaveFile::read(void *buf, uint32 size) {
+ // we must return the size, where fread return nitems upon success ( 1 <=> size)
+ if (fh) return (::fread(buf, 1, size, fh));
+ return 0;
+}
+
+uint32 PalmSaveFile::write(const void *buf, uint32 size) {
+ // we must return the size, where fwrite return nitems upon success ( 1 <=> size)
+ if (fh) return ::fwrite(buf, 1, size, fh);
+ return 0;
+}
+
+
+
+
+
+// SaveFileManager class
+
+class PalmSaveFileManager : public Common::SaveFileManager {
+public:
+ virtual Common::OutSaveFile *openForSaving(const char *filename) {
+ return openSavefile(filename, true);
+ }
+ virtual Common::InSaveFile *openForLoading(const char *filename) {
+ return openSavefile(filename, false);
+ }
+
+ Common::SaveFile *openSavefile(const char *filename, bool saveOrLoad);
+ void listSavefiles(const char *prefix, bool *marks, int num);
+
+protected:
+ Common::SaveFile *makeSaveFile(const char *filename, bool saveOrLoad);
+};
+
+Common::SaveFile *PalmSaveFileManager::openSavefile(const char *filename, bool saveOrLoad) {
+ char buf[256];
+
+ strncpy(buf, getSavePath(), sizeof(buf));
+ strncat(buf, filename, sizeof(buf));
+
+ return makeSaveFile(buf, saveOrLoad);
+}
+
+void PalmSaveFileManager::listSavefiles(const char *prefix, bool *marks, int num) {
+ FileRef fileRef;
+ // try to open the dir
+ Err e = VFSFileOpen(gVars->VFS.volRefNum, getSavePath(), vfsModeRead, &fileRef);
+ memset(marks, false, num*sizeof(bool));
+
+ if (e != errNone)
+ return;
+
+ // enumerate all files
+ UInt32 dirEntryIterator = vfsIteratorStart;
+ Char filename[32];
+ FileInfoType info = {0, filename, 32};
+ UInt16 length = StrLen(prefix);
+ int slot = 0;
+
+ while (dirEntryIterator != vfsIteratorStop) {
+ e = VFSDirEntryEnumerate (fileRef, &dirEntryIterator, &info);
+
+ if (e != expErrEnumerationEmpty) { // there is something
+
+ if (StrLen(info.nameP) == (length + 2)) { // consider max 99, filename length is ok
+ if (StrNCaselessCompare(prefix, info.nameP, length) == 0) { // this seems to be a save file
+ if (isdigit(info.nameP[length]) && isdigit(info.nameP[length+1])) {
+
+ slot = StrAToI(filename + length);
+ if (slot >= 0 && slot < num)
+ *(marks+slot) = true;
+
+ }
+ }
+ }
+
+ }
+ }
+
+ VFSFileClose(fileRef);
+}
+
+Common::SaveFile *PalmSaveFileManager::makeSaveFile(const char *filename, bool saveOrLoad) {
+ PalmSaveFile *sf = new PalmSaveFile(filename, saveOrLoad);
+
+ if (!sf->isOpen()) {
+ delete sf;
+ sf = 0;
+ }
+ return sf;
+}
+
+Common::SaveFileManager *OSystem_PalmBase::getSavefileManager() {
+ return new PalmSaveFileManager();
+}
diff --git a/backends/PalmOS/Src/be_zodiac.cpp b/backends/PalmOS/Src/be_zodiac.cpp
new file mode 100755
index 0000000000..b3a40ed1f8
--- /dev/null
+++ b/backends/PalmOS/Src/be_zodiac.cpp
@@ -0,0 +1,102 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_zodiac.h"
+
+void OSystem_PalmZodiac::int_initBackend() {
+ _sound.active = false;
+
+
+ _gfxH = NULL;
+ _overlayP = NULL;
+ _palmScreenP = NULL;
+ _tmpScreenP = NULL;
+ _stretched = false;
+ _tmpScreenP = NULL;
+
+ _keyMouse.bitUp = keyBitRockerUp;
+ _keyMouse.bitDown = keyBitRockerDown;
+ _keyMouse.bitLeft = keyBitRockerLeft;
+ _keyMouse.bitRight = keyBitRockerRight;
+ _keyMouse.bitButLeft= keyBitRockerCenter;
+}
+/*
+uint32 OSystem_PalmZodiac::getMillis() {
+ return TwGetMicroSeconds();
+}
+
+void OSystem_PalmZodiac::delayMillis(uint msecs) {
+ Int32 delay = (SysTicksPerSecond() * msecs) / 1000;
+
+ if (delay > 0)
+ SysTaskDelay(delay);
+}
+*/
+
+void OSystem_PalmZodiac::calc_rect(Boolean fullscreen) {
+ Int32 w, h;
+
+ if (fullscreen) {
+ w = (_ratio.adjustAspect == kRatioWidth) ? _ratio.width : gVars->screenFullWidth;
+ h = (_ratio.adjustAspect == kRatioHeight) ? _ratio.height : gVars->screenFullHeight;
+
+ _screenOffset.x = (_ratio.adjustAspect == kRatioWidth) ? (gVars->screenFullWidth - _ratio.width) / 2 : 0;
+ _screenOffset.y = (_ratio.adjustAspect == kRatioHeight) ? (gVars->screenFullHeight - _ratio.height) / 2 : 0;
+
+ } else {
+ w = gVars->screenWidth;
+ h = gVars->screenHeight;
+
+ _screenOffset.x = 0;
+ _screenOffset.y = 0;
+ }
+
+ _dstRect.x = _screenOffset.x;
+ _dstRect.y = _screenOffset.y;
+ _dstRect.w = w;
+ _dstRect.h = h;
+
+ _screenDest.w = _dstRect.w;
+ _screenDest.h = _dstRect.h;
+}
+
+void OSystem_PalmZodiac::setFeatureState(Feature f, bool enable) {
+ switch (f) {
+/* case kFeatureFullscreenMode:
+ if (_gfxLoaded)
+ if (OPTIONS_TST(kOptModeWide) && _initMode != GFX_WIDE) {
+ _fullscreen = enable;
+ hotswap_gfx_mode(_mode);
+ }
+ break;
+*/
+ case kFeatureAspectRatioCorrection:
+ if (_mode == GFX_WIDE) {
+ _ratio.adjustAspect = (_ratio.adjustAspect + 1) % 3;
+ calc_rect(true);
+ TwGfxSetClip(_palmScreenP, &_dstRect);
+ clearScreen();
+ }
+ break;
+ }
+}
diff --git a/backends/PalmOS/Src/be_zodiac.h b/backends/PalmOS/Src/be_zodiac.h
new file mode 100755
index 0000000000..d7ae7d5dd5
--- /dev/null
+++ b/backends/PalmOS/Src/be_zodiac.h
@@ -0,0 +1,91 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#ifndef BE_ZODIAC_H
+#define BE_ZODIAC_H
+
+#include "be_os5.h"
+#include <tapwave.h>
+
+class OSystem_PalmZodiac : public OSystem_PalmOS5 {
+private:
+ enum {
+ kRatioNone = 0,
+ kRatioHeight,
+ kRatioWidth
+ };
+ struct {
+ UInt8 adjustAspect;
+ Coord width; // (width x 320)
+ Coord height; // (480 x height)
+ } _ratio;
+
+ TwGfxType *_gfxH;
+ TwGfxSurfaceType *_palmScreenP, *_tmpScreenP;
+ TwGfxSurfaceType *_overlayP;
+ UInt16 _nativePal[256];
+ Boolean _fullscreen;
+
+ TwGfxPointType _srcPos;
+ TwGfxRectType _srcRect, _dstRect;
+ TwGfxBitmapType _srcBmp;
+ Boolean _stretched;
+
+ void int_initBackend();
+ void int_setShakePos(int shakeOffset);
+
+ void draw_mouse();
+ void undraw_mouse();
+
+ void unload_gfx_mode();
+ 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);
+ void get_coordinates(EventPtr ev, Coord &x, Coord &y);
+ bool check_event(Event &event, EventPtr ev);
+ void draw_osd(UInt16 id, Int32 x, Int32 y, Boolean show, UInt8 color = 0);
+
+public:
+ static OSystem *create();
+
+ void setFeatureState(Feature f, bool enable);
+
+ void updateScreen();
+
+ void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale);
+
+ void showOverlay();
+ void hideOverlay();
+ void clearOverlay();
+ void grabOverlay(OverlayColor *buf, int pitch);
+ void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
+ OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b);
+ void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b);
+// uint32 getMillis();
+// void delayMillis(uint msecs);
+
+};
+
+#endif
diff --git a/backends/PalmOS/Src/os5_event.cpp b/backends/PalmOS/Src/os5_event.cpp
new file mode 100755
index 0000000000..f447e86f07
--- /dev/null
+++ b/backends/PalmOS/Src/os5_event.cpp
@@ -0,0 +1,32 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_os5.h"
+
+void OSystem_PalmOS5::get_coordinates(EventPtr ev, Coord &x, Coord &y) {
+ Boolean dummy;
+ EvtGetPenNative(WinGetDisplayWindow(), &ev->screenX, &ev->screenY, &dummy);
+
+ x = (ev->screenX - _screenOffset.x);
+ y = (ev->screenY - _screenOffset.y);
+}
diff --git a/backends/PalmOS/Src/os5_gfx.cpp b/backends/PalmOS/Src/os5_gfx.cpp
new file mode 100755
index 0000000000..23a8432320
--- /dev/null
+++ b/backends/PalmOS/Src/os5_gfx.cpp
@@ -0,0 +1,130 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_os5.h"
+
+#ifdef PALMOS_ARM
+#include "pace.h"
+#include "oscalls.h"
+#endif
+
+void OSystem_PalmOS5::int_initSize(uint w, uint h, int overlayScale) {
+}
+
+void OSystem_PalmOS5::load_gfx_mode() {
+ Err e;
+
+ if (_gfxLoaded)
+ return;
+ _gfxLoaded = true;
+
+ _sysOldCoord = WinSetCoordinateSystem(kCoordinatesNative);
+
+#ifdef PALMOS_68K
+ // init mouse (must be here, after WinSetCoordinateSystem)
+ _mouseBackupH = WinCreateOffscreenWindow(MAX_MOUSE_W, MAX_MOUSE_H, nativeFormat, &e);
+ _mouseBackupP = (byte *)(BmpGetBits(WinGetBitmap(_mouseBackupH)));
+
+ _offScreenH = WinCreateOffscreenWindow(_screenWidth, _screenHeight, nativeFormat, &e);
+ _screenH = WinGetDisplayWindow();
+ _offScreenP = (byte *)(BmpGetBits(WinGetBitmap(_offScreenH)));
+ _screenP = (byte *)(BmpGetBits(WinGetBitmap(_screenH)));
+#endif
+
+ _screenOffset.x = (gVars->screenWidth - _screenWidth) / 2;
+ _screenOffset.y = (gVars->screenHeight - _screenHeight) / 2;
+}
+
+void OSystem_PalmOS5::unload_gfx_mode() {
+ if (!_gfxLoaded)
+ return;
+ _gfxLoaded = false;
+
+ if (_mouseBackupH)
+ WinDeleteWindow(_mouseBackupH, false);
+}
+
+void OSystem_PalmOS5::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
+ // Clip the coordinates
+ if (x < 0) {
+ w += x;
+ buf -= x;
+ x = 0;
+ }
+
+ if (y < 0) {
+ h += y;
+ buf -= y * pitch;
+ y = 0;
+ }
+
+ if (w > _screenWidth - x)
+ w = _screenWidth - x;
+
+ if (h > _screenHeight - y)
+ h = _screenHeight - y;
+
+ if (w <= 0 || h <= 0)
+ return;
+
+#ifdef PALMOS_68K
+ BitmapTypeV1 nfo = {
+ w, h, pitch,
+ {0,0,0,0,0,0,0,0,0},
+ 8, BitmapVersionOne, 0
+ };
+
+ BitmapTypeV3 *v3 = BmpCreateBitmapV3((BitmapType*)&nfo, kDensityDouble, (void *)buf, 0);
+
+ WinSetDrawWindow(_offScreenH);
+ WinDrawBitmap((BitmapPtr)v3, x, y);
+ BmpDelete((BitmapPtr)v3);
+#else
+ byte *dst = _offScreenP + y * _screenWidth + x;
+
+ if (w == pitch && w == _screenWidth) {
+ MemMove(dst, buf, w*h);
+ } else {
+ do {
+ MemMove(dst, buf, w);
+ dst += _screenWidth;
+ buf += pitch;
+ } while (--h);
+ }
+#endif
+}
+
+void OSystem_PalmOS5::int_updateScreen() {
+#ifdef PALMOS_68K
+ RectangleType r;
+ RctSetRectangle(&r, 0, 0, _screenWidth, _screenHeight - _current_shake_pos);
+ WinCopyRectangle(_offScreenH, _screenH, &r, _screenOffset.x, _screenOffset.y + _current_shake_pos, winPaint);
+#endif
+}
+
+void OSystem_PalmOS5::clearScreen() {
+ RGBColorType rgb = { 0,0,0,0 };
+ WinSetDrawWindow(WinGetDisplayWindow());
+ WinSetBackColorRGB(&rgb, 0);
+ WinEraseWindow();
+}
diff --git a/backends/PalmOS/Src/os5_mouse.cpp b/backends/PalmOS/Src/os5_mouse.cpp
new file mode 100755
index 0000000000..856975ed4d
--- /dev/null
+++ b/backends/PalmOS/Src/os5_mouse.cpp
@@ -0,0 +1,133 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_os5.h"
+
+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;
+
+ _mouseCurState.w = w;
+ _mouseCurState.h = h;
+
+ _mouseHotspotX = hotspotX;
+ _mouseHotspotY = hotspotY;
+
+ _mouseKeyColor = keycolor;
+
+#ifdef PALMOS_68K
+ // free old cursor if any
+ if (_mouseDataH)
+ WinDeleteWindow(_mouseDataH, false);
+
+ // allocate new cursor
+ Err e;
+ _mouseDataH = WinCreateOffscreenWindow(w, h, nativeFormat, &e);
+ _mouseDataP = (byte *)BmpGetBits(WinGetBitmap(_mouseDataH));
+
+ // set bitmap transparency
+ BmpSetTransparentValue(WinGetBitmap(_mouseDataH), _mouseKeyColor);
+
+ // copy new cursor
+ BitmapTypeV1 nfo = {
+ w, h, w,
+ {0,0,0,0,0,0,0,0,0},
+ 8, BitmapVersionOne, 0
+ };
+
+ BitmapTypeV3 *v3 = BmpCreateBitmapV3((BitmapType*)&nfo, kDensityDouble, (void *)buf, 0);
+
+ WinSetDrawWindow(_mouseDataH);
+ WinDrawBitmap((BitmapPtr)v3, 0, 0);
+ BmpDelete((BitmapPtr)v3);
+#endif
+}
+
+void OSystem_PalmOS5::draw_mouse() {
+ if (_mouseDrawn || !_mouseVisible)
+ return;
+ _mouseDrawn = true;
+
+ _mouseCurState.y = _mouseCurState.y >= _screenHeight ? _screenHeight - 1 : _mouseCurState.y;
+
+ 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;
+ x = 0;
+ }
+ if (y < 0) {
+ h += y;
+ y = 0;
+ }
+ if (w > _screenWidth - x)
+ w = _screenWidth - x;
+ if (h > _screenHeight - y)
+ h = _screenHeight - y;
+
+ // 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;
+
+#ifdef PALMOS_68K
+ // Backup the covered area draw the mouse cursor
+ if (_overlayVisible) {
+ } else {
+ // backup...
+ RectangleType r = {x, y, w, h};
+ WinCopyRectangle(_offScreenH, _mouseBackupH, &r, 0, 0, winPaint);
+ // ...and draw
+ WinSetDrawWindow(_offScreenH);
+ WinDrawBitmap(WinGetBitmap(_mouseDataH), draw_x, draw_y);
+ }
+#endif
+}
+
+void OSystem_PalmOS5::undraw_mouse() {
+ if (!_mouseDrawn)
+ return;
+ _mouseDrawn = false;
+
+#ifdef PALMOS_68K
+ // No need to do clipping here, since draw_mouse() did that already
+ if (_overlayVisible) {
+ } else {
+ RectangleType r = {0, 0, _mouseOldState.w, _mouseOldState.h};
+ WinCopyRectangle(_mouseBackupH, _offScreenH, &r, _mouseOldState.x, _mouseOldState.y, winPaint);
+ }
+#endif
+}
diff --git a/backends/PalmOS/Src/os5_overlay.cpp b/backends/PalmOS/Src/os5_overlay.cpp
new file mode 100755
index 0000000000..2282568013
--- /dev/null
+++ b/backends/PalmOS/Src/os5_overlay.cpp
@@ -0,0 +1,37 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_os5.h"
+
+OverlayColor OSystem_PalmOS5::RGBToColor(uint8 r, uint8 g, uint8 b) {
+ RGBColorType rgb = {0, r, g, b};
+ OverlayColor color = WinRGBToIndex(&rgb);
+
+ return color;
+}
+
+void OSystem_PalmOS5::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) {
+ r = _currentPalette[color].r;
+ g = _currentPalette[color].g;
+ b = _currentPalette[color].b;
+}
diff --git a/backends/PalmOS/Src/os5_sound.cpp b/backends/PalmOS/Src/os5_sound.cpp
new file mode 100755
index 0000000000..ab81a0827d
--- /dev/null
+++ b/backends/PalmOS/Src/os5_sound.cpp
@@ -0,0 +1,124 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_os5.h"
+#include "common/config-manager.h"
+
+#ifdef PALMOS_68K
+static void initRegs(void *addr) {
+ asm (
+ move.l addr, a0
+ move.l a4, 0(a0)
+ move.l a5, 4(a0)
+ );
+}
+
+static Err sndCallback(void* UserDataP, SndStreamRef stream, void* bufferP, UInt32 *bufferSizeP) {
+ asm (
+// movem.l a4-a5, -(sp)
+ move.l UserDataP, a0
+ move.l 0(a0), a4
+ move.l 4(a0), a5
+ );
+
+ SoundDataType *_sound = (SoundDataType *)UserDataP;
+ ((OSystem::SoundProc)_sound->proc)(_sound->param, (byte *)bufferP, *bufferSizeP);
+
+// asm ( movem.l (sp)+, a4-a5 );
+ return errNone;
+}
+
+#else
+
+static SYSTEM_CALLBACK Err sndCallback(void* UserDataP, SndStreamRef stream, void* bufferP, UInt32 *bufferSizeP) {
+ SoundDataType *_sound = (SoundDataType *)UserDataP;
+ ((OSystem::SoundProc)_sound->proc)(_sound->param, (byte *)bufferP, *bufferSizeP);
+ return errNone;
+}
+#endif
+
+
+bool OSystem_PalmOS5::setSoundCallback(SoundProc proc, void *param) {
+ Err e;
+ Boolean success = false;
+
+ if (!_sound.active) {
+ _sound.proc = proc;
+ _sound.param = param;
+ _sound.active = true; // always true when we call this function, false when sound is off
+ _sound.handle = NULL;
+
+
+ if (ConfMan.hasKey("output_rate"))
+ _samplesPerSec = ConfMan.getInt("output_rate");
+ else
+#ifdef PALMOS_ARM
+ _samplesPerSec = 22050; // default value
+#else
+ _samplesPerSec = 8000; // default value
+#endif
+
+ // try to create sound stream
+ if (1 || OPTIONS_TST(kOptPalmSoundAPI)) {
+#ifdef PALMOS_68K
+ initRegs(&_sound);
+#endif
+ e = SndStreamCreateExtended(
+ &_sound.handle,
+ sndOutput,
+ sndFormatPCM,
+ _samplesPerSec,
+#ifdef PALMOS_ARM
+ sndInt16Little,
+#else
+ sndInt16Big,
+#endif
+ sndStereo,
+ (SndStreamVariableBufferCallback)sndCallback,
+ &_sound,
+ 8192
+#ifdef PALMOS_68K
+ ,false
+#endif
+ );
+
+ e = e ? e : SndStreamStart(_sound.handle);
+ e = e ? e : SndStreamSetVolume(_sound.handle, (32767L / 16) * gVars->palmVolume / 100);
+ success = (e == errNone);
+ }
+ }
+ // if not true some scenes (indy3 256,...) may freeze (ESC to skip)
+ return true;
+}
+
+void OSystem_PalmOS5::clearSoundCallback() {
+ if (_sound.active) {
+ if (1 || OPTIONS_TST(kOptPalmSoundAPI)) {
+ SndStreamStop(_sound.handle);
+ SndStreamDelete(_sound.handle);
+ }
+ }
+
+ _sound.active = false;
+ _sound.handle = NULL;
+}
diff --git a/backends/PalmOS/Src/zodiac_event.cpp b/backends/PalmOS/Src/zodiac_event.cpp
new file mode 100755
index 0000000000..3b6fae2b4d
--- /dev/null
+++ b/backends/PalmOS/Src/zodiac_event.cpp
@@ -0,0 +1,114 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_zodiac.h"
+
+void OSystem_PalmZodiac::get_coordinates(EventPtr ev, Coord &x, Coord &y) {
+ Boolean dummy;
+ EvtGetPenNative(WinGetDisplayWindow(), &ev->screenX, &ev->screenY, &dummy);
+
+ x = (ev->screenX - _screenOffset.x);
+ y = (ev->screenY - _screenOffset.y);
+
+ if (_stretched) {
+ Int32 w, h;
+
+ h = (_ratio.adjustAspect == kRatioHeight ? _ratio.height : gVars->screenFullHeight);
+ w = (_ratio.adjustAspect == kRatioWidth ? _ratio.width : gVars->screenFullWidth);
+ x = (_screenWidth * x) / w;
+ y = (_screenHeight * y) / h;
+ }
+}
+
+bool OSystem_PalmZodiac::check_event(Event &event, EventPtr ev) {
+ if (ev->eType == keyDownEvent) {
+ switch (ev->data.keyDown.chr) {
+ // F5 = menu
+ case vchrThumbWheelBack:
+ _lastKey = kKeyNone;
+ event.type = EVENT_KEYDOWN;
+ event.kbd.keycode = 319;
+ event.kbd.ascii = 319;
+ event.kbd.flags = 0;
+ return true;
+
+ case vchrTriggerLeft:
+ hotswap_gfx_mode(_mode == GFX_WIDE ? GFX_NORMAL: GFX_WIDE);
+ return false; // not a key
+
+ case vchrTriggerRight:
+ setFeatureState(kFeatureAspectRatioCorrection, 0);
+ return false; // not a key
+
+ case vchrRockerCenter:
+ case vchrActionLeft:
+ _lastKey = kKeyMouseLButton;
+ event.type = EVENT_LBUTTONDOWN;
+ event.mouse.x = _mouseCurState.x;
+ event.mouse.y = _mouseCurState.y;
+ return true;
+
+ case vchrActionRight:
+ _lastKey = kKeyNone;
+ event.type = EVENT_RBUTTONDOWN;
+ event.mouse.x = _mouseCurState.x;
+ event.mouse.y = _mouseCurState.y;
+ return true;
+
+ // skip text
+ case vchrActionDown:
+ event.type = EVENT_KEYDOWN;
+ event.kbd.keycode = '.';
+ event.kbd.ascii = '.';
+ event.kbd.flags = 0;
+ return true;
+
+ // trun off
+ case vchrAutoOff:
+ case vchrPowerOff:
+ // pause the sound thread if any
+ if (_sound.active)
+ SndStreamPause(_sound.handle, true);
+ break;
+
+ case vchrLateWakeup:
+ // resume the sound thread if any
+ if (_sound.active)
+ SndStreamPause(_sound.handle, false);
+ break;
+ }
+
+ } else if (_overlayVisible) {
+ switch (_lastKey) {
+ case kKeyMouseLButton:
+ _lastKey = kKeyNone;
+ event.type = EVENT_LBUTTONUP;
+ event.mouse.x = _mouseCurState.x;
+ event.mouse.y = _mouseCurState.y;
+ return true;
+
+ }
+ }
+
+ return false;
+}
diff --git a/backends/PalmOS/Src/zodiac_gfx.cpp b/backends/PalmOS/Src/zodiac_gfx.cpp
new file mode 100755
index 0000000000..93c660b9de
--- /dev/null
+++ b/backends/PalmOS/Src/zodiac_gfx.cpp
@@ -0,0 +1,364 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_zodiac.h"
+#include "common/config-manager.h"
+#include "rumble.h"
+
+#ifdef PALMOS_68K
+#include "globals.h"
+#include "arm/native.h"
+#include "arm/macros.h"
+
+static Err _TwGfxOpen(void** aResult, void* aInfoResult) {
+#if !defined(SIMULATOR_MODE)
+ ARM_START(TwHackGfxType)
+ ARM_INIT(COMMON_ZODIACGFX)
+ ARM_ADDM(aResult)
+ ARM_ADDM(aInfoResult)
+ ARM_CALL_RET(ARM_COMMON, PNO_DATA())
+ ARM_END_RET(Err)
+#endif
+ return TwGfxOpen((TwGfxType**)aResult, (TwGfxInfoType *)aInfoResult);
+}
+
+#else
+static asm Err _TwGfxOpen(void **aResult, void *aInfoResult) {
+ stmfd sp!, {r4-r11,lr}
+ ldr r9, [r9]
+ ldr r9, [r9]
+ sub sp, sp, #0x24
+ mov r6, r0
+ mov r7, r1
+ ldr pc, =0x200995F0
+}
+#endif
+
+void OSystem_PalmZodiac::load_gfx_mode() {
+ Err e;
+
+ if (_gfxLoaded)
+ return;
+ _gfxLoaded = true;
+
+ OPTIONS_RST(kOptDisableOnScrDisp); // TODO
+
+ // get command line config
+ _fullscreen = ConfMan.getBool("fullscreen"); // (NORMAL 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);
+
+ _sysOldCoord = WinSetCoordinateSystem(kCoordinatesNative);
+ _sysOldOrientation = SysGetOrientation();
+ SysSetOrientation(sysOrientationLandscape);
+
+#ifdef PALMOS_68K
+ // init mouse (must be here, after WinSetCoordinateSystem)
+ _mouseBackupH = WinCreateOffscreenWindow(MAX_MOUSE_W, MAX_MOUSE_H, nativeFormat, &e);
+ _mouseBackupP = (byte *)(BmpGetBits(WinGetBitmap(_mouseBackupH)));
+
+ _mouseDataH = WinCreateOffscreenWindow(MAX_MOUSE_W, MAX_MOUSE_H, nativeFormat, &e);
+ _mouseDataP = (byte *)BmpGetBits(WinGetBitmap(_mouseDataH));
+
+ _offScreenH = WinCreateOffscreenWindow(_screenWidth, _screenHeight, nativeFormat, &e);
+ _offScreenP = (byte *)(BmpGetBits(WinGetBitmap(_offScreenH)));
+#else
+ _mouseBackupP = (byte *)MemPtrNew(MAX_MOUSE_W * MAX_MOUSE_H);
+ _mouseDataP = (byte *)MemPtrNew(MAX_MOUSE_W * MAX_MOUSE_H);
+ _offScreenP = (byte *)MemPtrNew(_screenWidth * _screenHeight);
+#endif
+
+ MemSet(_offScreenP, _screenWidth * _screenHeight, 0);
+ MemSet(_nativePal, sizeof(_nativePal), 0);
+ MemSet(_currentPalette, sizeof(_currentPalette), 0);
+
+ UInt32 depth = 16;
+ WinScreenMode(winScreenModeSet, NULL, NULL, &depth, NULL);
+ _screenH = WinGetDisplayWindow();
+ _screenP = (byte *)WinScreenLock(winLockDontCare);
+ WinScreenUnlock();
+
+ e = _TwGfxOpen((void **)&_gfxH, 0);
+ e = TwGfxGetPalmDisplaySurface(_gfxH, &_palmScreenP);
+
+ // overlay buffer
+ TwGfxSurfaceInfoType nfo = {
+ sizeof(TwGfxSurfaceInfoType),
+ _screenWidth, _screenHeight, _screenWidth * 2,
+ twGfxLocationAcceleratorMemory,
+ twGfxPixelFormatRGB565_LE
+ };
+ e = TwGfxAllocSurface(_gfxH, &_overlayP, &nfo);
+
+ // prepare main bitmap
+ _srcBmp.size = sizeof(TwGfxBitmapType);
+ _srcBmp.width = _screenWidth;
+ _srcBmp.height = _screenHeight;
+ _srcBmp.rowBytes = _screenWidth;
+ _srcBmp.pixelFormat = twGfxPixelFormat8bpp;
+ _srcBmp.data = _offScreenP;
+ _srcBmp.palette = _nativePal;
+
+ _srcRect.x = 0;
+ _srcRect.y = 0;
+ _srcRect.w = _screenWidth;
+ _srcRect.h = _screenHeight;
+
+ hotswap_gfx_mode(_mode);
+}
+
+void OSystem_PalmZodiac::hotswap_gfx_mode(int mode) {
+ Err e;
+ TwGfxSetClip(_palmScreenP, 0);
+ WinSetDrawWindow(_screenH);
+
+ _screenDest.w = _screenWidth;
+ _screenDest.h = _screenHeight;
+
+ // prevent bad DIA redraw (Stat part)
+ WinSetCoordinateSystem(kCoordinatesStandard);
+ if (mode == GFX_NORMAL) {
+ _redawOSD = true;
+ _stretched = (_screenWidth > gVars->screenWidth);
+ StatShow();
+ PINSetInputAreaState(pinInputAreaOpen);
+
+ if (_stretched) {
+ calc_rect(false);
+ } else {
+ // offsets
+ _screenOffset.x = (gVars->screenWidth - _screenWidth) / 2;
+ _screenOffset.y = (gVars->screenHeight - _screenHeight) / 2;
+
+ // clip Tapwave API
+ TwGfxRectType rt = { _screenOffset.x, _screenOffset.y, _screenWidth, _screenHeight };
+ TwGfxSetClip(_palmScreenP, &rt);
+ }
+
+ } else {
+ _redawOSD = false;
+ _stretched = true;
+ PINSetInputAreaState(pinInputAreaClosed);
+ StatHide();
+
+ calc_rect(true);
+ }
+ WinSetCoordinateSystem(kCoordinatesNative);
+
+ if (_stretched) {
+ TwGfxSetClip(_palmScreenP, &_dstRect);
+
+ if (!_tmpScreenP) {
+ // wide buffer
+ TwGfxSurfaceInfoType nfo = {
+ sizeof(TwGfxSurfaceInfoType),
+ _screenWidth, _screenHeight, _screenWidth * 2,
+ twGfxLocationAcceleratorMemory,
+ twGfxPixelFormatRGB565_LE
+ };
+ e = TwGfxAllocSurface(_gfxH, &_tmpScreenP, &nfo);
+ }
+ } else {
+ if (_tmpScreenP) {
+ e = TwGfxFreeSurface(_tmpScreenP);
+ _tmpScreenP = NULL;
+ }
+ }
+
+ _mode = mode;
+ _srcPos.x = _screenOffset.x;
+ _srcPos.y = _screenOffset.y;
+ clearScreen();
+}
+
+void OSystem_PalmZodiac::unload_gfx_mode() {
+ Err e;
+
+ if (!_gfxLoaded)
+ return;
+ _gfxLoaded = false;
+
+ if (_tmpScreenP) {
+ e = TwGfxFreeSurface(_tmpScreenP);
+ _tmpScreenP = NULL;
+ }
+
+ e = TwGfxFreeSurface(_overlayP);
+ e = TwGfxClose(_gfxH);
+
+ UInt32 depth = 8;
+ WinScreenMode(winScreenModeSet, NULL, NULL, &depth, NULL);
+ clearScreen();
+
+#ifdef PALMOS_68K
+ WinDeleteWindow(_mouseBackupH, 0);
+ WinDeleteWindow(_mouseDataH, 0);
+ WinDeleteWindow(_offScreenH, 0);
+#else
+ MemPtrFree(_mouseBackupP);
+ MemPtrFree(_mouseDataP);
+ MemPtrFree(_offScreenP);
+#endif
+
+ SysSetOrientation(_sysOldOrientation);
+ WinSetCoordinateSystem(_sysOldCoord);
+ StatShow();
+ PINSetInputAreaState(pinInputAreaOpen);
+}
+
+static void rumblePack(Boolean active) {
+ if (!gVars->vibrator)
+ return;
+
+ RumbleRun(active);
+}
+
+void OSystem_PalmZodiac::int_setShakePos(int shakeOffset) {
+ if (shakeOffset == 0)
+ rumblePack(false);
+}
+
+void OSystem_PalmZodiac::updateScreen() {
+ Err e;
+
+ if (_redawOSD) {
+ _redawOSD = false;
+ if (!_overlayVisible)
+ draw_osd(kDrawFight, _screenDest.w - 34, _screenDest.h + 2, _useNumPad, 1);
+ // + battery
+ }
+
+ if (_overlayVisible) {
+ // update the palette only with overlay, since it is in 16bit mode, this
+ // is needed so that the cursor has the correct colors. Hopefully Zodiac
+ // set the palette even in 16bit mode, where other OS5 devices don't :(
+ // FIXME : seems to corrupt the Stat grafiti panel
+ if (_paletteDirtyEnd != 0) {
+ WinSetDrawWindow(_screenH);
+// no cursor for now
+// WinPalette(winPaletteSet, _paletteDirtyStart, _paletteDirtyEnd - _paletteDirtyStart, _currentPalette + _paletteDirtyStart);
+ _paletteDirtyEnd = 0;
+ }
+
+ if (_stretched) {
+ TwGfxRectType dst = {_dstRect.x, _dstRect.y, _dstRect.w, _dstRect.h};
+ // TODO : where is the mouse :)
+ e = TwGfxStretchBlt2(_palmScreenP, &dst, _overlayP, &_srcRect, twGfxStretchFast| (gVars->filter ? twGfxStretchSmooth : 0));
+
+ } else {
+ // not really time sensitive, can use WinScreenLock/Unlock, this prevent use
+ // of a additional backpup buffer to draw the mouse
+ WinScreenLock(winLockCopy);
+ e = TwGfxBitBlt(_palmScreenP, &_srcPos, _overlayP, &_srcRect);
+ draw_mouse();
+ WinScreenUnlock();
+ }
+
+ } else {
+ draw_mouse();
+ if (_stretched) {
+ TwGfxPointType pos = {0, 0};
+ TwGfxRectType dst = {_dstRect.x, _dstRect.y, _dstRect.w, _dstRect.h};
+
+ if (_new_shake_pos != _current_shake_pos) {
+ TwGfxRectType r = { _screenOffset.x, _screenOffset.y, _dstRect.w, _new_shake_pos };
+
+ if (_new_shake_pos != 0) {
+ TwGfxFillRect(_palmScreenP, &r, 0);
+ rumblePack(_new_shake_pos >= 3);
+ }
+ r.y += dst.h;
+ r.h = _current_shake_pos;
+ TwGfxFillRect(_palmScreenP, &r, 0);
+
+ _current_shake_pos = _new_shake_pos;
+ dst.y += _new_shake_pos;
+ }
+ e = TwGfxDrawBitmap(_tmpScreenP, &pos, &_srcBmp);
+ e = TwGfxStretchBlt2(_palmScreenP, &dst, _tmpScreenP, &_srcRect, twGfxStretchFast| (gVars->filter ? twGfxStretchSmooth : 0));
+
+ } else {
+ TwGfxPointType pos = {_srcPos.x, _srcPos.y};
+
+ if (_new_shake_pos != _current_shake_pos) {
+ if (_new_shake_pos != 0) {
+ TwGfxRectType r = { _screenOffset.x, _screenOffset.y, _screenWidth, _new_shake_pos };
+ TwGfxFillRect(_palmScreenP, &r, 0);
+ rumblePack(_new_shake_pos >= 3);
+ }
+ _current_shake_pos = _new_shake_pos;
+ pos.y += _new_shake_pos;
+ }
+ e = TwGfxDrawBitmap(_palmScreenP, &pos, &_srcBmp);
+ }
+ 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;
+
+ MemHandle hTemp = DmGetResource(bitmapRsc, id + 100);
+
+ if (hTemp) {
+ static const UInt32 pal[2] = {
+ (TwGfxComponentsToPackedRGB(0,255,0)),
+ (TwGfxComponentsToPackedRGB(255,0,0))
+ };
+
+ BitmapType *bmTemp;
+ bmTemp = (BitmapType *)MemHandleLock(hTemp);
+
+ Coord w, h;
+ BmpGetDimensions(bmTemp, &w, &h, 0);
+ TwGfxPointType dst = { _screenOffset.x + x, _screenOffset.y + y };
+ TwGfxRectType r = { dst.x, dst.y, w, h };
+
+ TwGfxRectType c;
+ TwGfxGetClip(_palmScreenP, &c);
+ TwGfxSetClip(_palmScreenP, 0);
+ if (show) {
+ WinSetDrawWindow(_screenH);
+ TwGfxFillRect(_palmScreenP, &r, pal[color]);
+ WinSetDrawMode(winOverlay);
+ WinPaintBitmap(bmTemp,dst.x, dst.y);
+ WinSetDrawMode(winPaint);
+
+ } else {
+ TwGfxFillRect(_palmScreenP, &r, 0);
+ }
+ TwGfxSetClip(_palmScreenP, &c);
+
+ MemPtrUnlock(bmTemp);
+ DmReleaseResource(hTemp);
+
+ }
+}
diff --git a/backends/PalmOS/Src/zodiac_mouse.cpp b/backends/PalmOS/Src/zodiac_mouse.cpp
new file mode 100755
index 0000000000..dc505dd311
--- /dev/null
+++ b/backends/PalmOS/Src/zodiac_mouse.cpp
@@ -0,0 +1,199 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_zodiac.h"
+
+void OSystem_PalmZodiac::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) {
+ if (w == 0 || h == 0)
+ return;
+
+ _mouseCurState.w = w;
+ _mouseCurState.h = h;
+
+ _mouseHotspotX = hotspotX;
+ _mouseHotspotY = hotspotY;
+
+ _mouseKeyColor = keycolor;
+
+#ifdef PALMOS_68K
+ // set bitmap transparency
+ WinSetDrawWindow(_mouseDataH);
+ WinSetBackColor(_mouseKeyColor);
+ WinEraseWindow();
+ BmpSetTransparentValue(WinGetBitmap(_mouseDataH), _mouseKeyColor);
+
+ if (w & 1) {
+ // copy new cursor
+ byte *dst = _mouseDataP;
+ while (h--) {
+ memcpy(dst, buf, w);
+ dst += MAX_MOUSE_W;
+ buf += w;
+ }
+
+ } else {
+ // copy new cursor
+ BitmapTypeV1 nfo = {
+ w, h, w,
+ {0,0,0,0,0,0,0,0,0},
+ 8, BitmapVersionOne, 0
+ };
+
+ BitmapTypeV3 *v3 = BmpCreateBitmapV3((BitmapType*)&nfo, kDensityDouble, (void *)buf, 0);
+ WinDrawBitmap((BitmapPtr)v3, 0, 0);
+ BmpDelete((BitmapPtr)v3);
+ }
+#else
+
+ // copy new cursor
+ byte *dst = _mouseDataP;
+ while (h--) {
+ memcpy(dst, buf, w);
+ dst += MAX_MOUSE_W;
+ buf += w;
+ }
+#endif
+}
+
+void OSystem_PalmZodiac::draw_mouse() {
+ if (_mouseDrawn || !_mouseVisible)
+ return;
+
+#ifdef PALMOS_ARM
+ byte *src = _mouseDataP; // Image representing the mouse
+ byte *bak = _mouseBackupP; // Surface used to backup the area obscured by the mouse
+ byte *dst; // Surface we are drawing into
+ byte color;
+ int width;
+#endif
+
+ _mouseCurState.y = _mouseCurState.y >= _screenHeight ? _screenHeight - 1 : _mouseCurState.y;
+
+ 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;
+#ifdef PALMOS_ARM
+ src -= x;
+#endif
+ x = 0;
+ }
+ if (y < 0) {
+ h += y;
+#ifdef PALMOS_ARM
+ src -= y * MAX_MOUSE_W;
+#endif
+ y = 0;
+ }
+ if (w > _screenWidth - x)
+ w = _screenWidth - x;
+ if (h > _screenHeight - y)
+ h = _screenHeight - y;
+
+ // 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;
+
+ // Backup the covered area draw the mouse cursor
+#ifdef PALMOS_68K
+ if (_overlayVisible) {
+ WinSetDrawWindow(_screenH);
+ WinDrawBitmap(WinGetBitmap(_mouseDataH), draw_x + _screenOffset.x, draw_y + _screenOffset.y);
+ // force mouse redraw at each frame so that an extra buffer is not needed
+ _mouseDrawn = false;
+
+ } else {
+ // backup...
+ RectangleType r = {x, y, w, h};
+ WinCopyRectangle(_offScreenH, _mouseBackupH, &r, 0, 0, winPaint);
+ // ...and draw
+ WinSetDrawWindow(_offScreenH);
+ WinDrawBitmap(WinGetBitmap(_mouseDataH), draw_x, draw_y);
+ _mouseDrawn = true;
+ }
+#else
+ if (_overlayVisible) {
+ // where is the mouse ...
+ } else {
+ dst = _offScreenP + y * _screenWidth + x;
+
+ do {
+ width = w;
+ do {
+ *bak++ = *dst;
+ color = *src++;
+ if (color != _mouseKeyColor) // transparent, don't draw
+ *dst = color;
+ dst++;
+ } while (--width);
+
+ src += MAX_MOUSE_W - w;
+ bak += MAX_MOUSE_W - w;
+ dst += _screenWidth - w;
+ } while (--h);
+ _mouseDrawn = true;
+ }
+#endif
+}
+
+void OSystem_PalmZodiac::undraw_mouse() {
+ if (!_mouseDrawn)
+ return;
+ _mouseDrawn = false;
+
+ // No need to do clipping here, since draw_mouse() did that already
+#ifdef PALMOS_68K
+ if (_overlayVisible) {
+ } else {
+ RectangleType r = {0, 0, _mouseOldState.w, _mouseOldState.h};
+ WinCopyRectangle(_mouseBackupH, _offScreenH, &r, _mouseOldState.x, _mouseOldState.y, winPaint);
+ }
+#else
+ if (_overlayVisible) {
+ } else {
+ int h = _mouseOldState.h;
+ byte *dst, *bak = _mouseBackupP;
+ dst = _offScreenP + _mouseOldState.y * _screenWidth + _mouseOldState.x;
+
+ do {
+ memcpy(dst, bak, _mouseOldState.w);
+ bak += MAX_MOUSE_W;
+ dst += _screenWidth;
+ } while (--h);
+ }
+#endif
+}
diff --git a/backends/PalmOS/Src/zodiac_overlay.cpp b/backends/PalmOS/Src/zodiac_overlay.cpp
new file mode 100755
index 0000000000..73056a3f85
--- /dev/null
+++ b/backends/PalmOS/Src/zodiac_overlay.cpp
@@ -0,0 +1,91 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2005 The ScummVM project
+ * Copyright (C) 2002-2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_zodiac.h"
+
+void OSystem_PalmZodiac::showOverlay() {
+ draw_osd(kDrawFight, _screenDest.w - 34, _screenDest.h + 2, false);
+ undraw_mouse();
+ _overlayVisible = true;
+ clearOverlay();
+}
+
+void OSystem_PalmZodiac::hideOverlay() {
+ draw_osd(kDrawFight, _screenDest.w - 34, _screenDest.h + 2, _useNumPad, 1);
+ undraw_mouse();
+ _overlayVisible = false;
+}
+
+void OSystem_PalmZodiac::clearOverlay() {
+ if (!_overlayVisible)
+ return;
+
+ Err e;
+ TwGfxPointType pos = {0, 0};
+ TwGfxBitmapType bmp = {
+ sizeof(TwGfxBitmapType),
+ _screenWidth, _screenHeight, _screenWidth, twGfxPixelFormat8bpp,
+ (void *)_offScreenP, _nativePal
+ };
+ e = TwGfxDrawBitmap(_overlayP, &pos, &bmp);
+}
+
+void OSystem_PalmZodiac::grabOverlay(OverlayColor *buf, int pitch) {
+ Err e;
+ OverlayColor *src;
+
+ e = TwGfxLockSurface(_overlayP, (void **)&src);
+ int h = _screenHeight;
+ do {
+ memcpy(buf, src, _screenWidth * 2);
+ src += _screenWidth;
+ buf += pitch;
+ } while (--h);
+
+ e = TwGfxUnlockSurface(_overlayP, 0);
+}
+
+void OSystem_PalmZodiac::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
+ Err e;
+ TwGfxPointType pos = {x, y};
+ TwGfxBitmapType bmp = {
+ sizeof(TwGfxBitmapType),
+ w, h, pitch * 2 , twGfxPixelFormatRGB565_LE,
+ (void *)buf, 0
+ };
+ e = TwGfxDrawBitmap(_overlayP, &pos, &bmp);
+}
+
+OverlayColor OSystem_PalmZodiac::RGBToColor(uint8 r, uint8 g, uint8 b) {
+ return TwGfxMakeDisplayRGB(r, g, b);
+}
+
+void OSystem_PalmZodiac::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) {
+#ifdef PALMOS_68K
+ color = SWAP_BYTES_16(color);
+#endif
+ r = ((color >> 8) & 0xF8);
+ g = ((color >> 3) & 0xFC);
+ b = ((color << 3) & 0xF8);
+}
+