From bc8a755c67b733d974afc05af1dabec21c862e3b Mon Sep 17 00:00:00 2001 From: Chris Apers Date: Sun, 17 Sep 2006 09:59:31 +0000 Subject: Fixed back mouse in GUI adding cursor palette support Fixed cursor redraw in GUI Fixed cursor glitches problem in BS because of too small buffer Cleanup svn-id: r23908 --- backends/platform/PalmOS/Src/base_mouse.cpp | 5 ----- backends/platform/PalmOS/Src/be_base.cpp | 1 - backends/platform/PalmOS/Src/be_base.h | 6 +++--- backends/platform/PalmOS/Src/be_os5.cpp | 10 ++++++++++ backends/platform/PalmOS/Src/be_os5.h | 8 ++++++-- backends/platform/PalmOS/Src/be_zodiac.h | 5 ++++- backends/platform/PalmOS/Src/os5_event.cpp | 2 ++ backends/platform/PalmOS/Src/os5_mouse.cpp | 19 +++++++++++++++++-- backends/platform/PalmOS/Src/zodiac_mouse.cpp | 16 ++++++++++++---- 9 files changed, 54 insertions(+), 18 deletions(-) (limited to 'backends/platform/PalmOS/Src') diff --git a/backends/platform/PalmOS/Src/base_mouse.cpp b/backends/platform/PalmOS/Src/base_mouse.cpp index 1fb00e1551..691d66605f 100644 --- a/backends/platform/PalmOS/Src/base_mouse.cpp +++ b/backends/platform/PalmOS/Src/base_mouse.cpp @@ -39,11 +39,6 @@ bool OSystem_PalmBase::showMouse(bool visible) { bool last = _mouseVisible; _mouseVisible = visible; - if (visible) - draw_mouse(); - else - undraw_mouse(); - return last; } diff --git a/backends/platform/PalmOS/Src/be_base.cpp b/backends/platform/PalmOS/Src/be_base.cpp index 938b3b98c6..ea3f28a45f 100644 --- a/backends/platform/PalmOS/Src/be_base.cpp +++ b/backends/platform/PalmOS/Src/be_base.cpp @@ -57,7 +57,6 @@ OSystem_PalmBase::OSystem_PalmBase() { _batCheckTicks = SysTicksPerSecond() * 15; _batCheckLast = TimGetTicks(); - _mouseDataH = NULL; _mouseDataP = NULL; _mouseVisible = false; _mouseDrawn = false; diff --git a/backends/platform/PalmOS/Src/be_base.h b/backends/platform/PalmOS/Src/be_base.h index bfbe8e9b23..87f9b2ded0 100644 --- a/backends/platform/PalmOS/Src/be_base.h +++ b/backends/platform/PalmOS/Src/be_base.h @@ -102,8 +102,8 @@ protected: kKeyAny = 1 << 31 }; enum { - MAX_MOUSE_W = 40, - MAX_MOUSE_H = 40 + MAX_MOUSE_W = 48, + MAX_MOUSE_H = 48 }; struct MousePos { int16 x,y,w,h; @@ -151,7 +151,7 @@ protected: int16 _mouseHotspotY; byte _mouseKeyColor; byte *_mouseDataP, *_mouseBackupP; - WinHandle _mouseDataH, _mouseBackupH; + eventsEnum _lastEvent; WChar _lastKey; diff --git a/backends/platform/PalmOS/Src/be_os5.cpp b/backends/platform/PalmOS/Src/be_os5.cpp index 6b00351f49..975f394b64 100644 --- a/backends/platform/PalmOS/Src/be_os5.cpp +++ b/backends/platform/PalmOS/Src/be_os5.cpp @@ -37,6 +37,7 @@ OSystem_PalmOS5::OSystem_PalmOS5() : OSystem_PalmBase() { _overlayH = NULL; _isSwitchable = false; _wasRotated = false; + _cursorPaletteDisabled = true; MemSet(&_soundEx, sizeof(SoundExType), 0); _soundEx.sound = &_sound; @@ -61,6 +62,15 @@ void OSystem_PalmOS5::int_initBackend() { } } +bool OSystem_PalmOS5::hasFeature(Feature f) { + switch (f) { + case kFeatureCursorHasPalette: + return true; + } + + return false; +} + void OSystem_PalmOS5::setWindowCaption(const char *caption) { Err e; Char buf[64]; diff --git a/backends/platform/PalmOS/Src/be_os5.h b/backends/platform/PalmOS/Src/be_os5.h index 40a8340820..e6067fc6ff 100644 --- a/backends/platform/PalmOS/Src/be_os5.h +++ b/backends/platform/PalmOS/Src/be_os5.h @@ -105,7 +105,7 @@ private: OverlayColor *_overlayP; WinHandle _overlayH, _workScreenH; - int16 _nativePal[256]; + int16 _nativePal[256], _mousePal[256]; int16 *_workScreenP; Boolean _isSwitchable, _wasRotated; @@ -135,16 +135,20 @@ private: protected: UInt16 _sysOldCoord, _sysOldOrientation; - Boolean _stretched; + Boolean _stretched, _cursorPaletteDisabled; public: OSystem_PalmOS5(); static OSystem *create(); + bool hasFeature(Feature f); + void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); void clearScreen(); void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale); + virtual void setCursorPalette(const byte *colors, uint start, uint num); + void disableCursorPalette(bool disable); void showOverlay(); void hideOverlay(); diff --git a/backends/platform/PalmOS/Src/be_zodiac.h b/backends/platform/PalmOS/Src/be_zodiac.h index 7f5290bed1..73f5b55e24 100644 --- a/backends/platform/PalmOS/Src/be_zodiac.h +++ b/backends/platform/PalmOS/Src/be_zodiac.h @@ -46,7 +46,7 @@ private: TwGfxType *_gfxH; TwGfxSurfaceType *_palmScreenP, *_tmpScreenP; TwGfxSurfaceType *_overlayP; - UInt16 _nativePal[256]; + UInt16 _nativePal[256], _mousePal[256]; Boolean _fullscreen; TwGfxPointType _srcPos; @@ -75,11 +75,14 @@ public: static OSystem *create(); void setFeatureState(Feature f, bool enable); + int getDefaultGraphicsMode() const; void updateScreen(); bool grabRawScreen(Graphics::Surface *surf); + void setCursorPalette(const byte *colors, uint start, uint num); + void clearOverlay(); void grabOverlay(OverlayColor *buf, int pitch); void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); diff --git a/backends/platform/PalmOS/Src/os5_event.cpp b/backends/platform/PalmOS/Src/os5_event.cpp index 99e5867450..ee0464f8f8 100644 --- a/backends/platform/PalmOS/Src/os5_event.cpp +++ b/backends/platform/PalmOS/Src/os5_event.cpp @@ -56,7 +56,9 @@ bool OSystem_PalmOS5::check_event(Event &event, EventPtr ev) { if (_keyMouse.hasMore) { switch (ev->data.keyDown.chr) { // hot swap gfx + case 0x1B04: case vchrHard1: + printf("swap\n"); if (OPTIONS_TST(kOptCollapsible)) hotswap_gfx_mode(_mode == GFX_WIDE ? GFX_NORMAL: GFX_WIDE); return false; // not a key diff --git a/backends/platform/PalmOS/Src/os5_mouse.cpp b/backends/platform/PalmOS/Src/os5_mouse.cpp index 363658e47c..375dc125ce 100644 --- a/backends/platform/PalmOS/Src/os5_mouse.cpp +++ b/backends/platform/PalmOS/Src/os5_mouse.cpp @@ -24,6 +24,19 @@ #include "be_os5.h" +void OSystem_PalmOS5::setCursorPalette(const byte *colors, uint start, uint num) { + for(uint i = 0; i < num; i++) { + _mousePal[i + start] = gfxMakeDisplayRGB(colors[0], colors[1], colors[2]); + colors += 4; + } + + _cursorPaletteDisabled = false; +} + +void OSystem_PalmOS5::disableCursorPalette(bool disable) { + _cursorPaletteDisabled = disable; +} + void OSystem_PalmOS5::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) { if (w == 0 || h == 0) return; @@ -38,6 +51,7 @@ void OSystem_PalmOS5::setMouseCursor(const byte *buf, uint w, uint h, int hotspo // copy new cursor byte *dst = _mouseDataP; + memset(dst, MAX_MOUSE_W * MAX_MOUSE_H, keycolor); while (h--) { memcpy(dst, buf, w); dst += MAX_MOUSE_W; @@ -105,14 +119,15 @@ void OSystem_PalmOS5::draw_mouse() { if (_overlayVisible) { int16 *bak = (int16 *)_mouseBackupP; // Surface used to backup the area obscured by the mouse int16 *dst = _overlayP + y * _screenWidth + x; - + int16 *pal = _cursorPaletteDisabled ? _nativePal : _mousePal; + do { width = w; do { *bak++ = *dst; color = *src++; if (color != _mouseKeyColor) // transparent, don't draw - *dst = _nativePal[color]; + *dst = pal[color]; dst++; } while (--width); diff --git a/backends/platform/PalmOS/Src/zodiac_mouse.cpp b/backends/platform/PalmOS/Src/zodiac_mouse.cpp index 813da9d56a..bd68be1ae7 100644 --- a/backends/platform/PalmOS/Src/zodiac_mouse.cpp +++ b/backends/platform/PalmOS/Src/zodiac_mouse.cpp @@ -24,6 +24,14 @@ #include "be_zodiac.h" +void OSystem_PalmZodiac::setCursorPalette(const byte *colors, uint start, uint num) { + for(uint i = 0; i < num; i++) { + _mousePal[i + start] = TwGfxMakeDisplayRGB(colors[0], colors[1], colors[2]); + colors += 4; + } + _cursorPaletteDisabled = false; +} + void OSystem_PalmZodiac::draw_mouse() { if (_mouseDrawn || !_mouseVisible) return; @@ -72,18 +80,18 @@ void OSystem_PalmZodiac::draw_mouse() { // Backup the covered area draw the mouse cursor if (_overlayVisible) { uint16 *bak = (uint16 *)_mouseBackupP; // Surface used to backup the area obscured by the mouse - uint16 *dst; + uint16 *dst, *pal = _cursorPaletteDisabled ? _nativePal : _mousePal; TwGfxLockSurface(_overlayP, (void **)&dst); dst += y * _screenWidth + x; - + do { width = w; do { *bak++ = *dst; color = *src++; if (color != _mouseKeyColor) // transparent, don't draw - *dst = _nativePal[color]; + *dst = pal[color]; dst++; } while (--width); @@ -126,7 +134,7 @@ void OSystem_PalmZodiac::undraw_mouse() { if (_overlayVisible) { uint16 *bak = (uint16 *)_mouseBackupP; uint16 *dst; - + TwGfxLockSurface(_overlayP, (void **)&dst); dst += _mouseOldState.y * _screenWidth + _mouseOldState.x; -- cgit v1.2.3