aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorChris Apers2006-01-23 19:30:10 +0000
committerChris Apers2006-01-23 19:30:10 +0000
commit7935b9d946de1a502789f04abe824d57f907fe27 (patch)
treebdf87ed9a89f07817cd4759c1ef0fc720d796188 /backends
parent01fdeba50a219021ec8076db3a780a89596ad7ea (diff)
downloadscummvm-rg350-7935b9d946de1a502789f04abe824d57f907fe27.tar.gz
scummvm-rg350-7935b9d946de1a502789f04abe824d57f907fe27.tar.bz2
scummvm-rg350-7935b9d946de1a502789f04abe824d57f907fe27.zip
Advanced OS5 backend
- mutexes support - real thread support - real timer support svn-id: r20147
Diffstat (limited to 'backends')
-rwxr-xr-xbackends/PalmOS/Src/be_os5ex.cpp101
-rwxr-xr-xbackends/PalmOS/Src/be_os5ex.h64
-rwxr-xr-xbackends/PalmOS/Src/os5ex_sound.cpp36
3 files changed, 201 insertions, 0 deletions
diff --git a/backends/PalmOS/Src/be_os5ex.cpp b/backends/PalmOS/Src/be_os5ex.cpp
new file mode 100755
index 0000000000..605d7cab8a
--- /dev/null
+++ b/backends/PalmOS/Src/be_os5ex.cpp
@@ -0,0 +1,101 @@
+/* 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.
+ *
+ * $Header$
+ *
+ */
+
+// for DAL.h
+#define ALLOW_ACCESS_TO_INTERNALS_OF_BITMAPS
+
+#include "be_os5ex.h"
+#include "palmdefs.h"
+
+#include <System/WIP.h>
+#include <System/DAL.h>
+
+static TimerExType _timerEx;
+
+OSystem_PalmOS5Ex::OSystem_PalmOS5Ex() : OSystem_PalmOS5() {
+ _timerEx.timerID = 0;
+ _timerEx.timer = &_timer;
+ _timerEx.ticks = SysTicksPerSecond();
+}
+
+static SYSTEM_CALLBACK void timer_handler(void *userDataP) {
+ CALLBACK_PROLOGUE
+ TimerExPtr _timerEx = (TimerExPtr)userDataP;
+ TimerPtr _timer = _timerEx->timer;
+ _timer->duration = _timer->callback(_timer->duration);
+ KALTimerSet(_timerEx->timerID, (_timer->duration * _timerEx->ticks / 1000));
+ CALLBACK_EPILOGUE
+}
+
+void OSystem_PalmOS5Ex::setTimerCallback(TimerProc callback, int timer) {
+ if (_timer.active && _timerEx.timerID)
+ KALTimerDelete(_timerEx.timerID);
+
+ if (callback != NULL) {
+ Err e;
+ CALLBACK_INIT(_timerEx);
+ _timer.duration = timer;
+ _timer.callback = callback;
+
+ // create the timer
+ e = KALTimerCreate(&_timerEx.timerID, appFileCreator, &::timer_handler, &_timerEx);
+ if (!e) {
+ e = KALTimerSet(_timerEx.timerID, (timer * _timerEx.ticks / 1000));
+ if (e) KALTimerDelete(_timerEx.timerID);
+ }
+ _timer.active = (!e);
+
+ } else {
+ _timer.active = false;
+ }
+
+ if (!_timer.active)
+ _timerEx.timerID = 0;
+}
+
+OSystem::MutexRef OSystem_PalmOS5Ex::createMutex() {
+ UInt32 mutexID;
+ Err e = KALMutexCreate(&mutexID, appFileCreator);
+ return (MutexRef)(e ? NULL : mutexID);
+
+}
+
+void OSystem_PalmOS5Ex::lockMutex(MutexRef mutex) {
+ if (mutex)
+ KALMutexReserve((UInt32)mutex);
+}
+
+void OSystem_PalmOS5Ex::unlockMutex(MutexRef mutex) {
+ if (mutex)
+ KALMutexRelease((UInt32)mutex, 0);
+}
+
+void OSystem_PalmOS5Ex::deleteMutex(MutexRef mutex) {
+ if (mutex)
+ KALMutexDelete((UInt32)mutex);
+}
+
+void OSystem_PalmOS5Ex::int_quit() {
+ if (_timerEx.timerID)
+ KALTimerDelete(_timerEx.timerID);
+}
diff --git a/backends/PalmOS/Src/be_os5ex.h b/backends/PalmOS/Src/be_os5ex.h
new file mode 100755
index 0000000000..fe2199ffb0
--- /dev/null
+++ b/backends/PalmOS/Src/be_os5ex.h
@@ -0,0 +1,64 @@
+/* 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.
+ *
+ * $Header$
+ *
+ */
+
+#ifndef BE_OS5EX_H
+#define BE_OS5EX_H
+
+#include "be_os5.h"
+
+#ifndef PALMOS_ARM
+// Not usable with 68k mode (?), so ...
+#define OSystem_PalmOS5Ex OSystem_PalmOS5
+#else
+
+typedef struct {
+ UInt32 __r9;
+ UInt32 __r10;
+ UInt32 timerID;
+ UInt32 ticks;
+
+ TimerPtr timer;
+} TimerExType, *TimerExPtr;
+
+class OSystem_PalmOS5Ex : public OSystem_PalmOS5 {
+private:
+ void timer_handler() {};
+ void sound_handler() {};
+ void int_quit();
+
+ SndStreamVariableBufferCallback sound_callback();
+
+public:
+ OSystem_PalmOS5Ex();
+ static OSystem *create();
+
+ void setTimerCallback(TimerProc callback, int interval);
+
+ MutexRef createMutex();
+ void lockMutex(MutexRef mutex);
+ void unlockMutex(MutexRef mutex);
+ void deleteMutex(MutexRef mutex);
+};
+#endif
+
+#endif
diff --git a/backends/PalmOS/Src/os5ex_sound.cpp b/backends/PalmOS/Src/os5ex_sound.cpp
new file mode 100755
index 0000000000..996f782261
--- /dev/null
+++ b/backends/PalmOS/Src/os5ex_sound.cpp
@@ -0,0 +1,36 @@
+/* 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.
+ *
+ * $Header$
+ *
+ */
+
+#include "be_os5ex.h"
+
+static SYSTEM_CALLBACK Err sndCallbackEx(void* UserDataP, SndStreamRef stream, void* bufferP, UInt32 *bufferSizeP) {
+ CALLBACK_PROLOGUE
+ SoundType *_sound = ((SoundExType *)UserDataP)->sound;
+ ((OSystem::SoundProc)_sound->proc)(_sound->param, (byte *)bufferP, *bufferSizeP);
+ CALLBACK_EPILOGUE
+ return errNone;
+}
+
+SndStreamVariableBufferCallback OSystem_PalmOS5Ex::sound_callback() {
+ return sndCallbackEx;
+}