diff options
author | Chris Apers | 2005-12-11 19:56:31 +0000 |
---|---|---|
committer | Chris Apers | 2005-12-11 19:56:31 +0000 |
commit | 701bdbda9dabac0884bbf7de14bea3593a7377ce (patch) | |
tree | 8860800ce4dc4a2a084b7171231aaa5f7f79240b | |
parent | 0ba6f84374d4c9df5946e918e625f5b8d224ff06 (diff) | |
download | scummvm-rg350-701bdbda9dabac0884bbf7de14bea3593a7377ce.tar.gz scummvm-rg350-701bdbda9dabac0884bbf7de14bea3593a7377ce.tar.bz2 scummvm-rg350-701bdbda9dabac0884bbf7de14bea3593a7377ce.zip |
Added true timer support
New OS5 ARM backend, preliminary support
svn-id: r19783
-rwxr-xr-x | backends/PalmOS/Src/be_base.h | 24 | ||||
-rwxr-xr-x | backends/PalmOS/Src/be_os5.cpp | 78 | ||||
-rwxr-xr-x | backends/PalmOS/Src/be_os5.h | 79 |
3 files changed, 162 insertions, 19 deletions
diff --git a/backends/PalmOS/Src/be_base.h b/backends/PalmOS/Src/be_base.h index e11e0aa445..7684f3cdf7 100755 --- a/backends/PalmOS/Src/be_base.h +++ b/backends/PalmOS/Src/be_base.h @@ -50,14 +50,16 @@ enum { #define kDrawBatLow 3020 #define kDrawFight 3030 +typedef struct { + uint32 duration, nextExpiry; + bool active; + OSystem::TimerProc callback; +} TimerType, *TimerPtr; + +extern "C" void SysEventGet(EventType *, Int32); + 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; @@ -77,14 +79,15 @@ private: // virtual bool check_hard_keys() = 0; virtual bool check_event(Event &event, EventPtr ev) = 0; - void timer_handler(); + virtual 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: + virtual void draw_osd(UInt16 id, Int32 x, Int32 y, Boolean show, UInt8 color = 0); + enum { kKeyNone = 0, kKeyMouseMove = 1 << 0, @@ -101,6 +104,8 @@ protected: int16 x,y,w,h; }; + TimerType _timer; + RGBColorType _currentPalette[256]; uint _paletteDirtyStart, _paletteDirtyEnd; @@ -129,6 +134,7 @@ protected: UInt32 bitLeft; UInt32 bitRight; UInt32 bitButLeft; + Boolean hasMore; } _keyMouse; bool _mouseVisible; @@ -214,7 +220,7 @@ public: virtual uint32 getMillis(); virtual void delayMillis(uint msecs); - void setTimerCallback(TimerProc callback, int interval); + virtual void setTimerCallback(TimerProc callback, int interval); MutexRef createMutex() { return NULL; } void lockMutex(MutexRef mutex) {} diff --git a/backends/PalmOS/Src/be_os5.cpp b/backends/PalmOS/Src/be_os5.cpp index c2432883d1..49e841a6c5 100755 --- a/backends/PalmOS/Src/be_os5.cpp +++ b/backends/PalmOS/Src/be_os5.cpp @@ -22,16 +22,92 @@ */ #include "be_os5.h" +#include "oscalls.h" +#include "palmdefs.h" + +#ifndef __TWKEYS_H__ +#include <PalmNavigator.h> +#include <HsKeyCommon.h> +#endif + +static TimerExType _timerEx; OSystem_PalmOS5::OSystem_PalmOS5() : OSystem_PalmBase() { _sound.active = false; + _timerEx.timerID = 0; + _timerEx.timer = &_timer; + +#ifdef PALMOS_ARM + // CHECK : is this ok for OS5 too ? + if (HALHRTimerTicksPerSecond(&_timerEx.ticks)) + _timerEx.ticks = SysTicksPerSecond(); +#endif +} + +#ifdef PALMOS_ARM + +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_PalmOS5::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; +} + +#endif + void OSystem_PalmOS5::int_initBackend() { + if (OPTIONS_TST(kOpt5WayNavigatorV1)) { + _keyMouse.bitUp = keyBitPageUp; + _keyMouse.bitDown = keyBitPageDown; + _keyMouse.bitLeft = keyBitNavLeft; + _keyMouse.bitRight = keyBitNavRight; + _keyMouse.bitButLeft= keyBitNavSelect; + _keyMouse.hasMore = true; + + } else if (OPTIONS_TST(kOpt5WayNavigatorV2)) { + _keyMouse.bitUp = keyBitRockerUp; + _keyMouse.bitDown = keyBitRockerDown; + _keyMouse.bitLeft = keyBitRockerLeft; + _keyMouse.bitRight = keyBitRockerRight; + _keyMouse.bitButLeft= keyBitRockerCenter; + _keyMouse.hasMore = true; + } } void OSystem_PalmOS5::int_quit() { - unload_gfx_mode(); +#ifdef PALMOS_ARM + if (_timerEx.timerID) + KALTimerDelete(_timerEx.timerID); +#endif clearSoundCallback(); + unload_gfx_mode(); exit(0); } diff --git a/backends/PalmOS/Src/be_os5.h b/backends/PalmOS/Src/be_os5.h index 57ef9c1528..574548d5b0 100755 --- a/backends/PalmOS/Src/be_os5.h +++ b/backends/PalmOS/Src/be_os5.h @@ -26,9 +26,51 @@ #include "be_base.h" +#if !defined(SYSTEM_CALLBACK) || defined(PALMOS_68K) +# define SYSTEM_CALLBACK +# ifdef PALMOS_ARM +# define CALLBACK_PROLOGUE \ + __asm { \ + stmfd r13!,{r9,r10}; \ + ldr r9,[r0]; \ + ldr r10,[r0,#4]; \ + } +# define CALLBACK_EPILOGUE __asm { ldmfd r13!,{r9,r10} } +# define CALLBACK_INIT(regs) \ + __asm { \ + ldr r0, = regs; \ + add r0,r0,r10; \ + str r9,[r0]; \ + str r10,[r0,#4]; \ + } +# else +# define CALLBACK_PROLOGUE \ + asm ( \ + movem.l a4-a5, -(sp); \ + move.l UserDataP, a0; \ + move.l 0(a0), a4; \ + move.l 4(a0), a5; \ + ); +# define CALLBACK_EPILOGUE asm ( movem.l (sp)+, a4-a5 ); +# define CALLBACK_INIT(regs) \ + { \ + void *ptr = ®s; \ + asm ( \ + move.l ptr, a0; \ + move.l a4, 0(a0); \ + move.l a5, 4(a0); \ + ); \ + } +# endif +#else +# define CALLBACK_PROLOGUE +# define CALLBACK_EPILOGUE +# define CALLBACK_INIT(regs) +#endif + typedef struct { - UInt32 __a4; - UInt32 __a5; + UInt32 __reg1; + UInt32 __reg2; void *proc; void *param; @@ -36,9 +78,21 @@ typedef struct { SndStreamRef handle; Boolean active; } SoundDataType; +extern SoundDataType _sound; + +typedef struct { + UInt32 __r9; + UInt32 __r10; + TimerPtr timer; + UInt32 timerID; + UInt32 ticks; +} TimerExType, *TimerExPtr; class OSystem_PalmOS5 : public OSystem_PalmBase { private: + byte *_overlayP; + WinHandle _overlayH; + virtual void int_initBackend(); virtual void int_updateScreen(); virtual void int_initSize(uint w, uint h, int overlayScale); @@ -49,11 +103,14 @@ private: 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;} + virtual bool check_event(Event &event, EventPtr ev); + +#ifdef PALMOS_ARM + void timer_handler() {}; +#endif protected: UInt16 _sysOldCoord, _sysOldOrientation; - SoundDataType _sound; public: OSystem_PalmOS5(); @@ -64,14 +121,18 @@ public: 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 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); +#ifdef PALMOS_ARM + void setTimerCallback(TimerProc callback, int interval); +#endif + bool setSoundCallback(SoundProc proc, void *param); void clearSoundCallback(); |