From c4e5cdd8dfc48cab327492e91e177a7d520db3ef Mon Sep 17 00:00:00 2001 From: Chris Apers Date: Sat, 5 Nov 2005 11:55:24 +0000 Subject: Obsolete files svn-id: r19460 --- backends/PalmOS/Src/palm.cpp | 302 ------------------- backends/PalmOS/Src/palm.h | 322 -------------------- backends/PalmOS/Src/palmevt.cpp | 424 -------------------------- backends/PalmOS/Src/palmgfx.cpp | 654 ---------------------------------------- backends/PalmOS/Src/palmmos.cpp | 188 ------------ backends/PalmOS/Src/palmovl.cpp | 126 -------- backends/PalmOS/Src/palmrdr.cpp | 278 ----------------- backends/PalmOS/Src/palmsnd.cpp | 186 ------------ 8 files changed, 2480 deletions(-) delete mode 100644 backends/PalmOS/Src/palm.cpp delete mode 100644 backends/PalmOS/Src/palm.h delete mode 100644 backends/PalmOS/Src/palmevt.cpp delete mode 100644 backends/PalmOS/Src/palmgfx.cpp delete mode 100644 backends/PalmOS/Src/palmmos.cpp delete mode 100644 backends/PalmOS/Src/palmovl.cpp delete mode 100644 backends/PalmOS/Src/palmrdr.cpp delete mode 100644 backends/PalmOS/Src/palmsnd.cpp diff --git a/backends/PalmOS/Src/palm.cpp b/backends/PalmOS/Src/palm.cpp deleted file mode 100644 index b58cf1ec86..0000000000 --- a/backends/PalmOS/Src/palm.cpp +++ /dev/null @@ -1,302 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2005 The ScummVM project - * - * 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 "common/stdafx.h" -#include "palm.h" - -#include "scumm.h" -#include "common/scaler.h" - -#include "cd_msa.h" -#include "cd_default.h" -#include "cd_pockettunes.h" - -#include -#ifndef DISABLE_TAPWAVE -#include -#endif - -OSystem *OSystem_PALMOS_create() { - return OSystem_PALMOS::create(); -} - -OSystem *OSystem_PALMOS::create() { - return new OSystem_PALMOS(); -} - -uint32 OSystem_PALMOS::getMillis() { - uint32 ticks = TimGetTicks(); - ticks = ticks * 1000 / SysTicksPerSecond(); - return ticks; - -} - -void OSystem_PALMOS::delayMillis(uint msecs) { - UInt32 current = getMillis(); - UInt32 last = current + msecs; - - do { - timer_handler(current); - sound_handler(); - current = getMillis(); - } while (current < last); -} - -OSystem::MutexRef OSystem_PALMOS::createMutex() {return NULL;} -void OSystem_PALMOS::lockMutex(MutexRef mutex) {} -void OSystem_PALMOS::unlockMutex(MutexRef mutex) {} -void OSystem_PALMOS::deleteMutex(MutexRef mutex) {} - -void OSystem_PALMOS::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); - } -} - -void OSystem_PALMOS::timer_handler(UInt32 current_msecs) { - if (_timer.active && (current_msecs >= _timer.nextExpiry)) { - _timer.duration = _timer.callback(_timer.duration); - _timer.nextExpiry = current_msecs + _timer.duration; - } -} - -void OSystem_PALMOS::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; - } -} - -void OSystem_PALMOS::setWindowCaption(const char *caption) { - Char *loading = "Loading, please wait\0"; - Coord h = FntLineHeight() + 2; - Coord w, y; - - WinSetActiveWindow(WinGetDisplayWindow()); - WinSetBackColor(0); - WinSetTextColor(255); - - // erase the screen - WinEraseWindow(); - - if (_useHRmode) { - y = 160 - (h >> 1) - 10; - HRFntSetFont(gVars->HRrefNum,hrTinyBoldFont); - w = FntCharsWidth(loading,StrLen(loading)); - w = (320 - w) >> 1; - HRWinDrawChars(gVars->HRrefNum, loading, StrLen(loading), w, y + h); - - HRFntSetFont(gVars->HRrefNum,hrTinyFont); - w = FntCharsWidth(caption, StrLen(caption)); - w = (320 - w) >> 1; - HRWinDrawChars(gVars->HRrefNum, caption, StrLen(caption), w, y); - } else { - Err e; - UInt16 size = 1; - - if (OPTIONS_TST(kOptModeHiDensity)) - if (WinGetCoordinateSystem() == kCoordinatesNative) { - size = 2; - h = (h - 2) / 2 + 2; - } - - BitmapTypeV3 *bmp2P; - BitmapType *bmp1P = BmpCreate(320, (h << 1), 8, NULL, &e); - WinHandle tmpH = WinCreateBitmapWindow(bmp1P, &e); - - WinSetDrawWindow(tmpH); - WinEraseWindow(); - - FntSetFont(boldFont); - w = FntCharsWidth(loading, StrLen(loading)); - w = (320 - w) >> 1; - WinDrawChars(loading, StrLen(loading), w, 0 + h); - - FntSetFont(stdFont); - w = FntCharsWidth(caption, StrLen(caption)); - w = (320 - w) >> 1; - WinDrawChars(caption, StrLen(caption), w, 0); - - WinSetDrawWindow(WinGetDisplayWindow()); - bmp2P = BmpCreateBitmapV3(bmp1P, kDensityDouble, BmpGetBits(bmp1P), NULL); - y = (80 - (h >> 2) - 5) * size; - WinDrawBitmap((BitmapPtr)bmp2P, 0, y); - - BmpDelete((BitmapPtr)bmp2P); - WinDeleteWindow(tmpH,0); - BmpDelete(bmp1P); - } -} - -bool OSystem_PALMOS::hasFeature(Feature f) { - return (f == kFeatureFullscreenMode && OPTIONS_TST(kOptModeWide)) || - (f == kFeatureAspectRatioCorrection); -} - -void OSystem_PALMOS::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 && OPTIONS_TST(kOptDeviceZodiac)) { - _adjustAspectRatio ^= true; - clearScreen(); - } - break; - } -} - -bool OSystem_PALMOS::getFeatureState(Feature f) { - switch (f) { - case kFeatureAspectRatioCorrection: - return _adjustAspectRatio; - default: - return false; - } -} - -void OSystem_PALMOS::quit() { - free(_currentPalette); - free(_mouseBackupP); - free(_mouseDataP); - - if (_cdPlayer) { - _cdPlayer->release(); - _cdPlayer = NULL; - } - - unload_gfx_mode(); - clearSoundCallback(); - - exit(0); -} - -OSystem_PALMOS::OSystem_PALMOS() { - _current_shake_pos = 0; - _new_shake_pos = 0; - - _paletteDirtyStart = 0; - _paletteDirtyEnd = 0; - - memset(&_sound, 0, sizeof(SoundDataType)); - - _currentPalette = NULL; - _modeChanged = false; - _gfxLoaded = false; - - _lastKeyPressed = kLastKeyNone; - _lastKeyRepeat = 100; - _lastKeyModifier = MD_NONE; - - _useNumPad = false; - _showBatLow = false; - - // mouse - memset(&_mouseOldState,0,sizeof(MousePos)); - memset(&_mouseCurState,0,sizeof(MousePos)); - _mouseDrawn = false; - _mouseBackupP = NULL; - _mouseVisible = false; - _mouseDataP = NULL; - - _currentPalette = (RGBColorType*)calloc(sizeof(RGBColorType), 256); - _mouseBackupP = (byte*)malloc(MAX_MOUSE_W * MAX_MOUSE_H); - - // overlay - _tmpScreenP = NULL; - _tmpBackupP = NULL; - - // HiRes - _useHRmode = (gVars->HRrefNum != sysInvalidRefNum); - - // mouse emu - // TODO : add UX50 arrow keys - if (OPTIONS_TST(kOpt5WayNavigator)) { - _keyMouse.bitUp = keyBitPageUp; - _keyMouse.bitDown = keyBitPageDown; - _keyMouse.bitLeft = keyBitNavLeft; - _keyMouse.bitRight = keyBitNavRight; - _keyMouse.bitButLeft= keyBitNavSelect; - } else { - _keyMouse.bitUp = keyBitPageUp; - _keyMouse.bitDown = keyBitPageDown; - _keyMouse.bitLeft = keyBitHard1; - _keyMouse.bitRight = keyBitHard2; - _keyMouse.bitButLeft= keyBitHard3|0x00100000; // keyBitRockerCenter on TwKeys.h but conflict with palmnavigator.h - } - _keyMask = (_keyMouse.bitUp | _keyMouse.bitDown | _keyMouse.bitLeft | _keyMouse.bitRight | _keyMouse.bitButLeft); - - // enable cdrom ? - _cdPlayer = NULL; - if (gVars->CD.enable) { - switch (gVars->CD.driver) { - case 0: // No CD - _cdPlayer = new DefaultCDPlayer(this); - break; - case 1: // MSA Library - _cdPlayer = new MsaCDPlayer(this); - break; - case 2: // Pocket Tunes API - _cdPlayer = new PckTunesCDPlayer(this); - break; - } - - if (_cdPlayer) { - if (!_cdPlayer->init()) { - _cdPlayer->release(); - _cdPlayer = NULL; - } - } - } - - // sound - memset(&_sound,0,sizeof(SoundDataType)); -} - diff --git a/backends/PalmOS/Src/palm.h b/backends/PalmOS/Src/palm.h deleted file mode 100644 index fb4a18526f..0000000000 --- a/backends/PalmOS/Src/palm.h +++ /dev/null @@ -1,322 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2005 The ScummVM project - * - * 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 PALM_H -#define PALM_H - -#include -#include "common/system.h" -#include "cdaudio.h" -//#include "arm/native.h" - -typedef struct { - void *proc; - void *param; - - void *handle; // sound handle - UInt32 size; // buffer size - UInt32 slot; - UInt32 active, // is the sound handler active - set, // is the buffer filled - wait; // do we need to wait for sound completion - void *dataP, // main buffer - *tmpP; // tmp buffer (convertion) -} SoundDataType; - -// OSD resource id -#define kDrawKeyState 3000 -#define kDrawNumPad 3010 -#define kDrawBatLow 3020 - -// OSD key state -enum { - MD_NONE = 0, - MD_CMD, - MD_ALT, - MD_CTRL -}; - -// gfx modes -enum { - GFX_NORMAL = 0, - GFX_FLIPPING = 100, // Palmos - GFX_BUFFERED = 101, // Palmos - GFX_WIDE = 102 // palmos -}; - -class OSystem_PALMOS : public OSystem { -public: - // Set colors of the palette - void setPalette(const byte *colors, uint start, uint num); - - const GraphicsMode *getSupportedGraphicsModes() const; - bool setGraphicsMode(int mode); - int getGraphicsMode() const; - int getDefaultGraphicsMode() const; - - int getOutputSampleRate() const; - bool openCD(int drive); - void setWindowCaption(const char *caption); // TODO : _inGame = true = don't set - - bool hasFeature(Feature f); - void setFeatureState(Feature f, bool enable); - bool getFeatureState(Feature f); - - // Set the size of the video bitmap. - // Typically, 320x200 - void initSize(uint w, uint h, int overlayScale); - - // Draw a bitmap to screen. - // The screen will not be updated to reflect the new bitmap - void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); - - // Update the dirty areas of the screen - void updateScreen(); - - void clearScreen(); - - // Either show or hide the mouse cursor - bool showMouse(bool visible); - - // Set the position of the mouse cursor - void set_mouse_pos(int x, int y); - - // Warp the mouse cursor. Where set_mouse_pos() only informs the - // backend of the mouse cursor's current position, this function - // actually moves the cursor to the specified position. - void warpMouse(int x, int y); - - - // Set the bitmap that's used when drawing the cursor. - void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor); - - // Shaking is used in SCUMM. Set current shake position. - void setShakePos(int shake_pos); - - // Get the number of milliseconds since the program was started. - uint32 getMillis(); - - // Delay for a specified amount of milliseconds - void delayMillis(uint msecs); - - // Get the next event. - // Returns true if an event was retrieved. - bool pollEvent(Event &event); - - void SimulateArrowKeys(Event &event, Int8 iHoriz, Int8 iVert); - - /** @name Sound */ - //@{ - /** - * Set the audio callback which is invoked whenever samples need to be generated. - * Currently, only the 16-bit signed mode is ever used for Simon & Scumm - * @param proc pointer to the callback. - * @param param an arbitrary parameter which is stored and passed to proc. - */ - bool setSoundCallback(SoundProc proc, void *param); - - /** - * Remove any audio callback previously set via setSoundCallback, thus effectively - * stopping all audio output immediately. - * @see setSoundCallback - */ - void clearSoundCallback(); - //@} - - // Poll cdrom status - // Returns true if cd audio is playing - bool pollCD(); - - // Play cdrom audio track - void playCD(int track, int num_loops, int start_frame, int duration); - - // Stop cdrom audio track - void stopCD(); - - // Update cdrom audio status - void updateCD(); - - // Add a callback timer - void setTimerCallback(TimerProc callback, int timer); - - // Mutex handling - MutexRef createMutex(); - void lockMutex(MutexRef mutex); - void unlockMutex(MutexRef mutex); - void deleteMutex(MutexRef mutex); - - // Quit - void quit(); - - // Overlay - void showOverlay(); - void hideOverlay(); - void clearOverlay(); - void grabOverlay(byte *buf, int pitch); - void copyRectToOverlay(const byte *buf, int pitch, int x, int y, int w, int h); - - int16 getWidth(); - int16 getHeight(); - byte RGBToColor(uint8 r, uint8 g, uint8 b); - void ColorToRGB(byte color, uint8 &r, uint8 &g, uint8 &b); - - // Savefile management - Common::SaveFileManager *getSavefileManager(); - - static OSystem *create(); - -protected: - byte *_tmpScreenP, *_tmpBackupP, *_tmpHotSwapP; // TODO : rename _tmpScreenP - bool _overlayVisible; - -private: - typedef void (OSystem_PALMOS::*RendererProc)(); - RendererProc _renderer_proc; - - void updateScreen_flipping(); - void updateScreen_buffered(); - void updateScreen_direct(); - void updateScreen_widePortrait(); - void updateScreen_wideLandscape(); - void updateScreen_wideZodiac(); - - void *ptrP[5]; // various ptr - - WinHandle _screenH, _offScreenH; - Boolean _fullscreen, _adjustAspectRatio, _wide; - struct { - Coord x; - Coord y; - UInt32 addr; - } _screenOffset; - - byte *_screenP, *_offScreenP; - int _offScreenPitch; - int _screenPitch; - - - bool _mouseVisible; - bool _mouseDrawn; - - enum { - MAX_MOUSE_W = 40, // must be 80x80 with 640x480 games ? - MAX_MOUSE_H = 40 - }; - - int _screenWidth, _screenHeight; - - struct MousePos { - int16 x,y,w,h; - }; - - UInt16 _mode, _initMode, _setMode; - Boolean _modeChanged, _gfxLoaded; - byte *_mouseDataP; - byte *_mouseBackupP; - MousePos _mouseCurState; - MousePos _mouseOldState; - int16 _mouseHotspotX; - int16 _mouseHotspotY; - int _current_shake_pos; - int _new_shake_pos; - byte _mouseKeyColor; - - UInt32 _exit_delay; - - struct { - uint32 duration, nextExpiry; - bool active; - TimerProc callback; - } _timer; - - // Audio - int _samplesPerSec; - SoundDataType _sound; - - // Palette data - RGBColorType *_currentPalette; - uint _paletteDirtyStart, _paletteDirtyEnd; - - void draw_mouse(); - void undraw_mouse(); - - void sound_handler(); - void timer_handler(UInt32 current_msecs); - - void getCoordinates(EventPtr event, Coord *x, Coord *y); - void draw1BitGfx(UInt16 id, Int32 x, Int32 y, Boolean clear); - - void load_gfx_mode(); - void hotswap_gfx_mode(int mode); - void unload_gfx_mode(); - - // Battery - Boolean _showBatLow; - void battery_handler(); - - // Alarm -/* Boolean _alarmRaised; - void alarm_handler(); -*/ - CDAudio *_cdPlayer; - // PALM spec - - enum { - kLastKeyNone = 0, - kLastKeyMouse = 1 << 0, - - kLastKeyCalc = 1 << 30, - kLastKeyAny = 1 << 31 - }; - - - UInt32 _keyMask; - struct { - UInt32 bitUp; - UInt32 bitDown; - UInt32 bitLeft; - UInt32 bitRight; - UInt32 bitButLeft; - } _keyMouse; - - Int32 _lastKeyPressed; - UInt32 _lastKeyRepeat; - UInt8 _lastKeyModifier; - - Boolean _useNumPad; - Boolean _useHRmode; - - eventsEnum _lastEvent; - - OSystem_PALMOS(); - void init_intern(); -}; - -Err HwrDisplayPalette(UInt8 operation, Int16 startIndex, - UInt16 paletteEntries, RGBColorType *tableP) - SYS_TRAP(sysTrapHwrDisplayPalette); - -// Sound -void pcm2adpcm(Int16 *src, UInt8 *dst, UInt32 length); -Err sndCallback(void* UserDataP, SndStreamRef stream, void* bufferP, UInt32 *bufferSizeP); - -#endif diff --git a/backends/PalmOS/Src/palmevt.cpp b/backends/PalmOS/Src/palmevt.cpp deleted file mode 100644 index a0f2079b8e..0000000000 --- a/backends/PalmOS/Src/palmevt.cpp +++ /dev/null @@ -1,424 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2005 The ScummVM project - * - * 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 "common/stdafx.h" -#include "palm.h" -#include "common/scaler.h" - -#include - -#ifndef DISABLE_TAPWAVE -#include -#endif - -#define EXITDELAY (500) // delay to exit : calc button : double tap 1/500 sec - -void OSystem_PALMOS::SimulateArrowKeys(Event &event, Int8 iHoriz, Int8 iVert) { - Int16 x = _mouseCurState.x; - Int16 y = _mouseCurState.y; - Int16 slow; - - if (_lastKeyPressed != kLastKeyNone) { - _lastKeyRepeat++; - - if (_lastKeyRepeat > 16) - _lastKeyRepeat = 16; - } - else - _lastKeyRepeat = 0; - - slow = (iHoriz && iVert) ? 2 : 1; - - x += iHoriz * (_lastKeyRepeat >> 1) / slow; - y += iVert * (_lastKeyRepeat >> 1) / slow; - - x = (x < 0 ) ? 0 : x; - x = (x >= _screenWidth ) ? _screenWidth - 1 : x; - y = (y < 0 ) ? 0 : y; - y = (y >= _screenHeight ) ? _screenHeight - 1 : y; - - event.type = EVENT_MOUSEMOVE; - event.mouse.x = x; - event.mouse.y = y; - set_mouse_pos(x, y); -} - -void OSystem_PALMOS::getCoordinates(EventPtr event, Coord *x, Coord *y) { - if (OPTIONS_TST(kOptModeHiDensity)) { - Boolean dummy; - EvtGetPenNative(WinGetDisplayWindow(), &event->screenX, &event->screenY, &dummy); - } else { - event->screenX <<= 1; - event->screenY <<= 1; - } - - if (_mode == GFX_WIDE) { - // wide landscape - if (OPTIONS_TST(kOptModeLandscape)) { - - // zodiac have mutliple ratio - if (OPTIONS_TST(kOptDeviceZodiac)) { - Int32 w,h; - - h = (_adjustAspectRatio ? ((_screenHeight == 200) ? 300 : 360) : 320); - w = gVars->screenFullWidth; - - *x = ((event->screenX - _screenOffset.x) << 8) / ((w << 8) / _screenWidth); - *y = ((event->screenY - _screenOffset.y) << 8) / ((h << 8) / _screenHeight); - - // default (NR, NZ, NX, UX50, TT3, ...), wide only for 320x200 - } else { - *x = ((event->screenX - _screenOffset.x) << 1) / 3; - *y = ((event->screenY - _screenOffset.y) << 1) / 3; - } - - // wide portrait, only for 320x200 - } else { - *y = ((event->screenX - _screenOffset.y) << 1) / 3; - *x = 320 - ((event->screenY - _screenOffset.x) << 1) / 3 - 1; - } - - // normal coord - } else { - *x = (event->screenX - _screenOffset.x); - *y = (event->screenY - _screenOffset.y); - } -} - -bool OSystem_PALMOS::pollEvent(Event &event) { - ::EventType ev; - Boolean handled; - UInt32 keyCurrentState; - Coord x, y; - - battery_handler(); - sound_handler(); - timer_handler(getMillis()); - - for(;;) { - EvtGetEvent(&ev, evtNoWait); - - // check for hardkey repeat for mouse emulation - keyCurrentState = KeyCurrentState(); - - // arrow keys emulation - if ((keyCurrentState & _keyMask)) { - Int8 sx = 0; - Int8 sy = 0; - - if (keyCurrentState & _keyMouse.bitButLeft) { - event.type = EVENT_LBUTTONDOWN; - event.mouse.x = _mouseCurState.x; - event.mouse.y = _mouseCurState.y; - _lastKeyPressed = kLastKeyNone; - return true; - } - - 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; - - SimulateArrowKeys(event, sx, sy); - updateScreen(); - updateCD(); - _lastKeyPressed = kLastKeyMouse; - return true; - - } else if (_lastKeyPressed != kLastKeyCalc) { - _lastKeyPressed = kLastKeyNone; - } - - if (ev.eType == nilEvent) { - // force CD update, useful when the game is paused in some cases - updateCD(); - return false; - } - - if (ev.eType == keyDownEvent) { - switch (ev.data.keyDown.chr) { - - // ESC key - case vchrLaunch: - _lastKeyPressed = kLastKeyNone; - event.type = EVENT_KEYDOWN; - event.kbd.keycode = 27; - event.kbd.ascii = 27; - event.kbd.flags = 0; - return true; - - // F5 = menu - case vchrJogPushRepeat: - case vchrMenu: - case vchrThumbWheelBack: // Tapwave back button - _lastKeyPressed = kLastKeyNone; - event.type = EVENT_KEYDOWN; - event.kbd.keycode = 319; - event.kbd.ascii = 319; - event.kbd.flags = 0; - return true; - - case vchrCalc: - if (_lastKeyPressed & kLastKeyCalc) - if ((getMillis() - _exit_delay) <= (EXITDELAY)) - event.type = EVENT_QUIT; - - _exit_delay = getMillis(); - _lastKeyPressed = kLastKeyCalc; - return true; - - // mouse button - case vchrJogBack: - case vchrHard4: // right button -#ifndef DISABLE_TAPWAVE - case vchrActionRight: -#endif - event.type = EVENT_RBUTTONDOWN; - event.mouse.x = _mouseCurState.x; - event.mouse.y = _mouseCurState.y; - _lastKeyPressed = kLastKeyNone; - return true; - - case vchrJogPushedUp: - case vchrJogPushedDown: // hot swap gfx mode - if (_initMode == GFX_WIDE) - hotswap_gfx_mode(_mode == GFX_WIDE ? GFX_NORMAL: GFX_WIDE); - else - setFeatureState(kFeatureFullscreenMode, !_fullscreen); - return true; - - // wheel - case vchrJogUp: - event.type = EVENT_WHEELUP; - return true; - - case vchrJogDown: - event.type = EVENT_WHEELDOWN; - return true; - - - // if hotsync pressed, etc... - case vchrHardCradle: - case vchrHardCradle2: - case vchrLowBattery: - case vchrFind: - case vchrBrightness: - case vchrContrast: - // do nothing - return true; - - // trun off - case vchrAutoOff: - case vchrPowerOff: - // pause the sound thread if any - if (OPTIONS_TST(kOptPalmSoundAPI) && _sound.active) - SndStreamPause(*((SndStreamRef *)_sound.handle), true); - break; - - case vchrLateWakeup: - // resume the sound thread if any - if (OPTIONS_TST(kOptPalmSoundAPI) && _sound.active) - SndStreamPause(*((SndStreamRef *)_sound.handle), false); - break; - } - - if (OPTIONS_TST(kOpt5WayNavigator)) { - // mouse emulation for device with 5-Way navigator - switch (ev.data.keyDown.chr) { - // hot swap gfx - case vchrHard1: - if (_initMode == GFX_WIDE) - hotswap_gfx_mode(_mode == GFX_WIDE ? GFX_NORMAL: GFX_WIDE); - else - setFeatureState(kFeatureFullscreenMode, !_fullscreen); - return true; - - // ESC key - case vchrHard2: - _lastKeyPressed = kLastKeyNone; - event.type = EVENT_KEYDOWN; - event.kbd.keycode = 27; - event.kbd.ascii = 27; - event.kbd.flags = 0; - return true; - - // F5 = menu - case vchrHard3: - _lastKeyPressed = kLastKeyNone; - event.type = EVENT_KEYDOWN; - event.kbd.keycode = 319; - event.kbd.ascii = 319; - event.kbd.flags = 0; - return true; - } - } - } - - // 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; - - // others events - switch(ev.eType) { - - case keyDownEvent: { - _lastEvent = keyDownEvent; - _lastKeyPressed = kLastKeyNone; - - if (ev.data.keyDown.chr == vchrCommand && (ev.data.keyDown.modifiers & commandKeyMask)) { - _lastKeyModifier++; - _lastKeyModifier %= 4; - - if (_lastKeyModifier) - draw1BitGfx((kDrawKeyState + _lastKeyModifier - 1), 2, _screenHeight + 2, true); - else - draw1BitGfx(kDrawKeyState, 2, _screenHeight + 2, false); - - } else { - int keycode; - byte b = 0; - - if (_lastKeyModifier == MD_CMD) b = KBD_CTRL|KBD_ALT; - if (_lastKeyModifier == MD_ALT) b = KBD_ALT; - if (_lastKeyModifier == MD_CTRL) b = KBD_CTRL; - - keycode = ev.data.keyDown.chr; - - // F1 -> F10 key - if (keycode >= '0' && keycode <= '9' && b == (KBD_CTRL|KBD_ALT)) { - keycode = keycode == '0' ? 324 : (315 + keycode - '1'); - b = 0; - - } else if ((keycode == 'z' && b == KBD_CTRL) || (b == KBD_ALT && keycode == 'x')) { - event.type = EVENT_QUIT; - return true; - - } else if (keycode == 'n' && b == KBD_CTRL) { - UInt8 *scr = _screenP + _screenWidth * (_screenHeight + 2); - _useNumPad = !_useNumPad; - draw1BitGfx(kDrawNumPad, (_screenWidth >> 1) - 32, _screenHeight + 2, _useNumPad); - return true; - -#ifndef DISABLE_TAPWAVE - // Zodiac only keys - } else if (keycode == vchrTriggerRight) { - setFeatureState(kFeatureAspectRatioCorrection, 0); - return true; - - } else if (keycode == vchrTriggerLeft && _screenWidth != 640) { - if (_initMode == GFX_WIDE) - hotswap_gfx_mode(_mode == GFX_WIDE ? GFX_NORMAL: GFX_WIDE); - else - setFeatureState(kFeatureFullscreenMode, !_fullscreen); -#endif - } - - event.type = EVENT_KEYDOWN; - event.kbd.keycode = keycode; - event.kbd.ascii = keycode; //(keycode>='a' && keycode<='z' && (event.kbd.flags & KBD_SHIFT) ? keycode &~ 0x20 : keycode); - event.kbd.flags = b; - - if (_lastKeyModifier) { - _lastKeyModifier = MD_NONE; - draw1BitGfx(kDrawKeyState, 2, getHeight() + 2, false); - } - } - return true; - } - - case penMoveEvent: - getCoordinates(&ev, &x, &y); - - if (y > _screenHeight || y < 0 || x > _screenWidth || x < 0) - return true; - - if (_lastEvent != penMoveEvent && (abs(y - event.mouse.y) <= 2 || abs(x - event.mouse.x) <= 2)) // move only if - return true; - - _lastEvent = penMoveEvent; - event.type = EVENT_MOUSEMOVE; - event.mouse.x = x; - event.mouse.y = y; - set_mouse_pos(event.mouse.x, event.mouse.y); - return true; - - case penDownEvent: - getCoordinates(&ev, &x, &y); - - if (_useNumPad) { - Coord x2 = (_screenWidth >> 1) - 20; - Coord y2 = _screenHeight + 2; - - if (y >= y2 && y < (y2 + 34) && x >= x2 && x < (x2 + 40)) { // numpad location - UInt8 key = '1'; - key += 9 - ( (3 - ((x - x2) / 13)) + (3 * ((y - y2) / 11)) ); - - _lastEvent = keyDownEvent; - _lastKeyPressed = kLastKeyNone; - - event.type = EVENT_KEYDOWN; - event.kbd.keycode = key; - event.kbd.ascii = key; - event.kbd.flags = 0; - return true; - } - } - - _lastEvent = penDownEvent; - if (y > _screenHeight || y < 0 || x > _screenWidth || x < 0) - return true; - - event.type = EVENT_LBUTTONDOWN; - event.mouse.x = x; - event.mouse.y = y; - set_mouse_pos(event.mouse.x, event.mouse.y); - return true; - - case penUpEvent: - getCoordinates(&ev, &x, &y); - event.type = EVENT_LBUTTONUP; - - if (y > _screenHeight || y < 0 || x > _screenWidth || x < 0) - return true; - - event.mouse.x = x; - event.mouse.y = y; - set_mouse_pos(event.mouse.x, event.mouse.y); - return true; - - default: - return false; - } - } -} diff --git a/backends/PalmOS/Src/palmgfx.cpp b/backends/PalmOS/Src/palmgfx.cpp deleted file mode 100644 index 63077626b5..0000000000 --- a/backends/PalmOS/Src/palmgfx.cpp +++ /dev/null @@ -1,654 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2005 The ScummVM project - * - * 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 "common/stdafx.h" -#include "palm.h" - -#include "common/scaler.h" -#include "common/util.h" -#include "common/config-manager.h" - -#include -#include "palmdefs.h" -#include "features.h" -#include "globals.h" - -#ifndef DISABLE_TAPWAVE -#include -#include "i_zodiac.h" -#endif - -#include "init_arm.h" -#include "arm/native.h" -#include "arm/macros.h" - -static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { - {"normal", "Normal (no scaling)", GFX_NORMAL}, - {"flipping", "Page Flipping", GFX_FLIPPING}, - {"buffered", "Buffered", GFX_BUFFERED}, - {"wide", "Wide (HiRes+ only)", GFX_WIDE}, - {0, 0, 0} -}; - -int OSystem_PALMOS::getDefaultGraphicsMode() const { - return GFX_NORMAL;//GFX_WIDE; -} - -const OSystem::GraphicsMode *OSystem_PALMOS::getSupportedGraphicsModes() const { - return s_supportedGraphicsModes; -} - -int OSystem_PALMOS::getGraphicsMode() const { - return _mode; -} - -bool OSystem_PALMOS::setGraphicsMode(int mode) { - switch(mode) { - case GFX_NORMAL: - case GFX_FLIPPING: - case GFX_BUFFERED: - case GFX_WIDE: - _setMode = mode; - break; - - default: - warning("unknown gfx mode %d", mode); - _setMode = GFX_NORMAL; - return false; - } - - return true; -} - -void OSystem_PALMOS::initSize(uint w, uint h, int overlayScale) { - _screenWidth = w; - _screenHeight = h; - _offScreenPitch = gVars->screenPitch; // direct screen / flipping use this, reset later if buffered - _screenPitch = gVars->screenPitch; - - _overlayVisible = false; - - // lock the graffiti sizer - if (gVars->slkRefNum != sysInvalidRefNum) { - if (gVars->slkVersion == vskVersionNum1) - SilkLibDisableResize(gVars->slkRefNum); - else - VskSetState(gVars->slkRefNum, vskStateEnable, vskResizeDisable); - - // Tapwave Zodiac and other DIA compatible devices - } else if (OPTIONS_TST(kOptModeWide)) { - PINSetInputTriggerState(pinInputTriggerDisabled); - } - - // don't allow orientation change - if (OPTIONS_TST(kOptCollapsible)) - SysSetOrientationTriggerState(sysOrientationTriggerDisabled); - - set_mouse_pos(200,150); - - unload_gfx_mode(); - - // force WIDE mode for 640x480 games - if (h == 480) - _setMode = GFX_WIDE; - - _mode = _setMode; - _initMode = _mode; - load_gfx_mode(); -} - -int16 OSystem_PALMOS::getHeight() { - return _screenHeight; -} - -int16 OSystem_PALMOS::getWidth() { - return _screenWidth; -} - -static void HotSwap16bitMode(Boolean swap) { - UInt32 width = hrWidth; - UInt32 height= hrHeight; - UInt32 depth = swap ? 16 : 8; - Boolean color = true; - - if (OPTIONS_TST(kOptMode16Bit)) { - WinScreenMode(winScreenModeSet, &width, &height, &depth, &color); - OPTIONS_SET(kOptDisableOnScrDisp); - } -} - -void OSystem_PALMOS::load_gfx_mode() { - Err e; - - if (!_modeChanged) { - // get command line config - _fullscreen = (ConfMan.getBool("fullscreen") && OPTIONS_TST(kOptModeWide)); - _adjustAspectRatio = ConfMan.getBool("aspect_ratio"); - - // get the actual palette - WinPalette(winPaletteGet, 0, 256, _currentPalette); - - // set only if _mode not changed - const byte startupPalette[] = { - 0 ,0 ,0 ,0, - 0 ,0 ,171,0, - 0 ,171, 0 ,0, - 0 ,171,171,0, - 171 ,0 ,0 ,0, - 171 ,0 ,171,0, - 171 ,87 ,0 ,0, - 171 ,171,171,0, - 87 ,87 ,87 ,0, - 87 ,87 ,255,0, - 87 ,255,87 ,0, - 87 ,255,255,0, - 255 ,87 ,87 ,0, - 255 ,87 ,255,0, - 255 ,255,87 ,0, - 255 ,255,255,0 - }; - - // palette for preload dialog - setPalette(startupPalette, 0, 16); - } - - // check HiRes+ - if (_mode == GFX_WIDE) { - if (OPTIONS_TST(kOptModeWide)) { - Boolean std = true; - -#ifndef DISABLE_TAPWAVE - // check Zodiac - if (OPTIONS_TST(kOptDeviceZodiac)) { - if (ZodiacInit(ptrP, _screenWidth, _screenHeight)) { - OPTIONS_RST(kOptDeviceZodiac); - warning("Failed to initialize Zodiac device, switching to standard GFX_WIDE mode."); - } else { - std = false; - } - } -#endif - if (std) { - // 640x480 only on Zodiac and in GFX_WIDE mode - if (_screenWidth == 640) - error("640x480 games can only be run on Zodiac in wide mode."); - - // only for 320x200 games - if (!(_screenWidth == 320 && _screenHeight == 200)) { - warning("Wide display not available for this game, switching to GFX_NORMAL mode."); - _mode = GFX_NORMAL; - } - } - - } else { - warning("HiRes+ not available on this device, switching to GFX_NORMAL mode."); - _mode = GFX_NORMAL; - } - } - - if (_fullscreen || _mode == GFX_WIDE) { - // Sony wide - if (gVars->slkRefNum != sysInvalidRefNum) { - if (gVars->slkVersion == vskVersionNum1) { - SilkLibEnableResize (gVars->slkRefNum); - SilkLibResizeDispWin(gVars->slkRefNum, silkResizeMax); - SilkLibDisableResize(gVars->slkRefNum); - } else { - VskSetState(gVars->slkRefNum, vskStateEnable, (gVars->slkVersion != vskVersionNum3 ? vskResizeVertically : vskResizeHorizontally)); - VskSetState(gVars->slkRefNum, vskStateResize, vskResizeNone); - VskSetState(gVars->slkRefNum, vskStateEnable, vskResizeDisable); - } - - // Tapwave Zodiac and other DIA compatible devices - } else if (OPTIONS_TST(kOptModeWide)) { - PINSetInputAreaState(pinInputAreaClosed); - StatHide(); - } - } - - if (_modeChanged) { - WinSetBackColor(RGBToColor(0,0,0)); - WinEraseWindow(); - } - - if (_mode == GFX_WIDE) { - OPTIONS_SET(kOptDisableOnScrDisp); - _fullscreen = false; - _wide = true; - - if (OPTIONS_TST(kOptDeviceZodiac)) { - // landscape - _screenOffset.x = 0; - _screenOffset.y = (_adjustAspectRatio) ? 10 : 0; - _screenOffset.addr = _screenOffset.y * _screenPitch; - - // others only for 320x200 - } else { - _wide = false; - - _screenOffset.x = 0; - _screenOffset.y = 10; - _screenOffset.addr = (OPTIONS_TST(kOptModeLandscape) ? _screenOffset.y : _screenOffset.x) * _screenPitch; - } - - } else { - OPTIONS_RST(kOptDisableOnScrDisp); - - _screenOffset.x = ((_fullscreen ? gVars->screenFullWidth : gVars->screenWidth) - _screenWidth) >> 1; - _screenOffset.y = ((_fullscreen ? gVars->screenFullHeight : gVars->screenHeight) - _screenHeight) >> 1; - _screenOffset.addr = _screenOffset.x + _screenOffset.y * _screenPitch; - } - - if (OPTIONS_TST(kOptModeHiDensity)) - WinSetCoordinateSystem(kCoordinatesNative); - - // init screens - switch(_mode) { - case GFX_FLIPPING: - gVars->screenLocked = true; - _offScreenP = WinScreenLock(winLockErase) + _screenOffset.addr; - _screenP = _offScreenP; - _offScreenH = WinGetDisplayWindow(); - _screenH = _offScreenH; - _renderer_proc = &OSystem_PALMOS::updateScreen_flipping; - break; - case GFX_WIDE: - case GFX_BUFFERED: - _screenH = WinGetDisplayWindow(); - _offScreenH = WinCreateOffscreenWindow(_screenWidth, _screenHeight, nativeFormat, &e); - _offScreenP = (byte *)(BmpGetBits(WinGetBitmap(_offScreenH))); - - if (_mode == GFX_WIDE) { -#ifndef DISABLE_TAPWAVE - if (OPTIONS_TST(kOptDeviceZodiac)) { - HotSwap16bitMode(true); - clearScreen(); - _twBmpV3 = (void *)WinGetBitmap(_offScreenH); - - // TODO : change _screenP with the correct value (never used in this mode ?) - _screenP = (byte *)(BmpGetBits(WinGetBitmap(_screenH))); - _renderer_proc = &OSystem_PALMOS::updateScreen_wideZodiac; - } else -#endif - { - gVars->screenLocked = true; - _screenP = WinScreenLock(winLockErase) + _screenOffset.addr; - - _renderer_proc = (OPTIONS_TST(kOptModeLandscape)) ? - &OSystem_PALMOS::updateScreen_wideLandscape : - &OSystem_PALMOS::updateScreen_widePortrait; - } - - } else { - _screenP = (byte *)(BmpGetBits(WinGetBitmap(_screenH))) + _screenOffset.addr; - _renderer_proc = &OSystem_PALMOS::updateScreen_buffered; - } - _offScreenPitch = _screenWidth; - break; - - case GFX_NORMAL: - default: - _offScreenH = WinGetDisplayWindow(); - _screenH = _offScreenH; - _offScreenP = (byte *)(BmpGetBits(WinGetBitmap(_offScreenH))) + _screenOffset.addr; - _screenP = _offScreenP; - _renderer_proc = &OSystem_PALMOS::updateScreen_direct; - break; - } - - if (!_modeChanged) { - // try to allocate on storage heap, TODO : error if failed - FtrPtrNew(appFileCreator, ftrBufferOverlay, _screenWidth * _screenHeight, (void **)&_tmpScreenP); - FtrPtrNew(appFileCreator, ftrBufferBackup, _screenWidth * _screenHeight, (void **)&_tmpBackupP); - // only if wide mode available - if OPTIONS_TST(kOptModeWide) - FtrPtrNew(appFileCreator, ftrBufferHotSwap, _screenWidth * _screenHeight, (void **)&_tmpHotSwapP); - - _gfxLoaded = true; - } - -} - -void OSystem_PALMOS::unload_gfx_mode() { - if (!_gfxLoaded) - return; - - WinSetDrawWindow(WinGetDisplayWindow()); - - if (OPTIONS_TST(kOptModeHiDensity)) - WinSetCoordinateSystem(kCoordinatesStandard); - - switch (_mode) { - case GFX_FLIPPING: - WinScreenUnlock(); - gVars->screenLocked = false; - break; - - case GFX_WIDE: -#ifndef DISABLE_TAPWAVE - if (OPTIONS_TST(kOptDeviceZodiac)) { - ZodiacRelease(ptrP); - HotSwap16bitMode(false); - clearScreen(); - } else -#endif - { - WinScreenUnlock(); - gVars->screenLocked = false; - } - // continue to GFX_BUFFERED - - case GFX_BUFFERED: - WinDeleteWindow(_offScreenH, false); - break; - } - - // restore silkarea - // -- Sony wide - if (gVars->slkRefNum != sysInvalidRefNum) { - if (gVars->slkVersion == vskVersionNum1) { - SilkLibEnableResize (gVars->slkRefNum); - SilkLibResizeDispWin(gVars->slkRefNum, silkResizeNormal); - SilkLibDisableResize(gVars->slkRefNum); - } else { - VskSetState(gVars->slkRefNum, vskStateEnable, (gVars->slkVersion != vskVersionNum3 ? vskResizeVertically : vskResizeHorizontally)); - VskSetState(gVars->slkRefNum, vskStateResize, vskResizeMax); - VskSetState(gVars->slkRefNum, vskStateEnable, vskResizeDisable); - } - - // -- Tapwave Zodiac and other DIA compatible devices - } else if (OPTIONS_TST(kOptModeWide)) { - StatShow(); - PINSetInputAreaState(pinInputAreaOpen); - } - - if (!_modeChanged) { - // free only if _mode not changed - if (_tmpScreenP) - FtrPtrFree(appFileCreator, ftrBufferOverlay); - - if (_tmpBackupP) - FtrPtrFree(appFileCreator, ftrBufferBackup); - - if OPTIONS_TST(kOptModeWide) - if (_tmpHotSwapP) - FtrPtrFree(appFileCreator, ftrBufferHotSwap); - } -} - -void OSystem_PALMOS::hotswap_gfx_mode(int mode) { - // save current offscreen - byte *src = _offScreenP; - byte *dst = _tmpHotSwapP; - int h = _screenHeight; - - undraw_mouse(); - - UInt32 offset = 0; - do { - DmWrite(dst, offset, src, _screenWidth); - offset += _screenWidth; - src += _offScreenPitch; - } while (--h); - _modeChanged = true; - - // reset offscreen pitch - _offScreenPitch = gVars->screenPitch; - - // free old mode memory - unload_gfx_mode(); - - // load new gfx mode - _mode = mode; - load_gfx_mode(); - - // restore offscreen - WinPalette(winPaletteSet, 0, 256, _currentPalette); - clearScreen(); - copyRectToScreen(_tmpHotSwapP, _screenWidth, 0, 0, _screenWidth, _screenHeight); - _modeChanged = false; - - // force palette update - _paletteDirtyStart = 0; - _paletteDirtyEnd = 256; - - updateScreen(); -} - -// TODO : move GFX functions here - -void OSystem_PALMOS::setPalette(const byte *colors, uint start, uint num) { - const byte *b = colors; - uint i; - RGBColorType *base = _currentPalette + start; - for(i=0; i < num; i++) { - base[i].r = b[0]; - base[i].g = b[1]; - base[i].b = b[2]; - b += 4; - } - - if (start < _paletteDirtyStart) - _paletteDirtyStart = start; - - if (start + num > _paletteDirtyEnd) - _paletteDirtyEnd = start + num; -} - -byte OSystem_PALMOS::RGBToColor(uint8 r, uint8 g, uint8 b) { - byte color; - - if (gVars->stdPalette) { - RGBColorType rgb = {0, r, g, b}; - color = WinRGBToIndex(&rgb); - - } else { - byte nearest = 255; - byte check; - byte r2, g2, b2; - - color = 255; - - for (int i = 0; i < 256; i++) - { - r2 = _currentPalette[i].r; - g2 = _currentPalette[i].g; - b2 = _currentPalette[i].b; - - check = (ABS(r2 - r) + ABS(g2 - g) + ABS(b2 - b)) / 3; - - if (check == 0) // perfect match - return i; - else if (check < nearest) { // else save and continue - color = i; - nearest = check; - } - } - } - - return color; -} - -void OSystem_PALMOS::ColorToRGB(byte color, uint8 &r, uint8 &g, uint8 &b) { - r = _currentPalette[color].r; - g = _currentPalette[color].g; - b = _currentPalette[color].b; -} - -void OSystem_PALMOS::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; - - /* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */ - if (_mouseDrawn) - undraw_mouse(); - - byte *dst = _offScreenP + y * _offScreenPitch + x; - - // if ARM - ARM_CHECK_EXEC(w > 8 && h > 8) - ARM_START(CopyRectangleType) - ARM_INIT(COMMON_COPYRECT) - ARM_ADDM(dst) - ARM_ADDM(buf) - ARM_ADDM(pitch) - ARM_ADDM(_offScreenPitch) - ARM_ADDM(w) - ARM_ADDM(h) - ARM_CALL(ARM_COMMON, PNO_DATA()); - ARM_END() - ARM_CHECK_END() - // if no ARM - if (w == pitch && w == _offScreenPitch) { - MemMove(dst, buf, w*h); - } else { - do { - MemMove(dst, buf, w); - dst += _offScreenPitch; - buf += pitch; - } while (--h); - } -} - -void OSystem_PALMOS::updateScreen() { - // Check whether the palette was changed in the meantime and update the - // screen surface accordingly. - if (_paletteDirtyEnd != 0) { - UInt8 oldCol; - - if (gVars->stdPalette) { - WinSetDrawWindow(WinGetDisplayWindow()); // hack by Doug - WinPalette(winPaletteSet, _paletteDirtyStart, _paletteDirtyEnd - _paletteDirtyStart,_currentPalette + _paletteDirtyStart); - } else { - HwrDisplayPalette(winPaletteSet, _paletteDirtyStart, _paletteDirtyEnd - _paletteDirtyStart,_currentPalette + _paletteDirtyStart); - } - _paletteDirtyEnd = 0; - 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); - } - } - - // Make sure the mouse is drawn, if it should be drawn. - draw_mouse(); - - if (_overlayVisible) { - byte *src = _tmpScreenP; - byte *dst = _offScreenP; - UInt16 h = _screenHeight; - - do { - memcpy(dst, src, _screenWidth); - dst += _offScreenPitch; - src += _screenWidth; - } while (--h); - } - - // redraw the screen - ((this)->*(_renderer_proc))(); -} - -void OSystem_PALMOS::draw1BitGfx(UInt16 id, Int32 x, Int32 y, Boolean show) { - if (OPTIONS_TST(kOptDisableOnScrDisp)) - return; - - 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); - BmpGlueGetDimensions(bmTemp, &w, &h, 0); - - 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; - } - - MemPtrUnlock(bmTemp); - DmReleaseResource(hTemp); - } -} - -void OSystem_PALMOS::clearScreen() { - Coord w, h; - RectangleType r; - - WinSetDrawWindow(WinGetDisplayWindow()); - WinGetDisplayExtent(&w, &h); - RctSetRectangle(&r, 0, 0, w, h); - WinSetForeColor(RGBToColor(0,0,0)); - WinDrawRectangle(&r,0); -} diff --git a/backends/PalmOS/Src/palmmos.cpp b/backends/PalmOS/Src/palmmos.cpp deleted file mode 100644 index 2b45015348..0000000000 --- a/backends/PalmOS/Src/palmmos.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2005 The ScummVM project - * - * 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 "common/stdafx.h" -#include "palm.h" - -bool OSystem_PALMOS::showMouse(bool visible) { - if (_mouseVisible == visible) - return visible; - - bool last = _mouseVisible; - _mouseVisible = visible; - - if (visible) - draw_mouse(); - else - undraw_mouse(); - - return last; -} - -void OSystem_PALMOS::warpMouse(int x, int y) { - set_mouse_pos(x, y); -} - -void OSystem_PALMOS::set_mouse_pos(int x, int y) { - if (x != _mouseCurState.x || y != _mouseCurState.y) { - _mouseCurState.x = x; - _mouseCurState.y = y; - undraw_mouse(); - } -} - -void OSystem_PALMOS::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor) { - _mouseCurState.w = w; - _mouseCurState.h = h; - - _mouseHotspotX = hotspot_x; - _mouseHotspotY = hotspot_y; - - _mouseKeyColor = keycolor; - - if (_mouseDataP) - free(_mouseDataP); - - _mouseDataP = (byte *)malloc(w * h); - memcpy(_mouseDataP, buf, w * h); - - undraw_mouse(); -} - -void OSystem_PALMOS::draw_mouse() { - if (_mouseDrawn || !_mouseVisible) - return; - - _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; - byte color; - 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 - int width; - - // clip the mouse rect, and addjust the src pointer accordingly - if (x < 0) { - w += x; - src -= x; - x = 0; - } - if (y < 0) { - h += y; - src -= y * _mouseCurState.w; - 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; - - // Draw the mouse cursor; backup the covered area in "bak" - if (!_overlayVisible) { - dst = _offScreenP + y * _offScreenPitch + x; - - while (h > 0) { - width = w; - while (width > 0) { - *bak++ = *dst; - color = *src++; - if (color != _mouseKeyColor) // transparent, don't draw - *dst = color; - dst++; - width--; - } - src += _mouseCurState.w - w; - bak += MAX_MOUSE_W - w; - dst += _offScreenPitch - w; - h--; - } - } else { - int offset = y * _screenWidth + x; - dst = _tmpScreenP; - - while (h > 0) { - width = w; - while (width > 0) { - *bak++ = *(dst + offset); - color = *src++; - if (color != _mouseKeyColor) // transparent, don't draw - DmWrite(dst, offset, &color, 1); - offset++; - width--; - } - src += _mouseCurState.w - w; - bak += MAX_MOUSE_W - w; - offset += _screenWidth - w; - h--; - } - } - - // Finally, set the flag to indicate the mouse has been drawn - _mouseDrawn = true; -} - -void OSystem_PALMOS::undraw_mouse() { - if (!_mouseDrawn) - return; - - _mouseDrawn = false; - - byte *dst, *bak = _mouseBackupP; - const int old_mouse_x = _mouseOldState.x; - const int old_mouse_y = _mouseOldState.y; - const int old_mouse_w = _mouseOldState.w; - int old_mouse_h = _mouseOldState.h; - - // No need to do clipping here, since draw_mouse() did that already - if (!_overlayVisible) { - dst = _offScreenP + old_mouse_y * _offScreenPitch + old_mouse_x; - do { - memcpy(dst, bak, old_mouse_w); - bak += MAX_MOUSE_W; - dst += _offScreenPitch; - } while (--old_mouse_h); - - } else { - int offset = old_mouse_y * _screenWidth + old_mouse_x; - do { - DmWrite(_tmpScreenP, offset, bak, old_mouse_w); - bak += MAX_MOUSE_W; - offset += _screenWidth; - } while (--old_mouse_h); - } -} - diff --git a/backends/PalmOS/Src/palmovl.cpp b/backends/PalmOS/Src/palmovl.cpp deleted file mode 100644 index 37ed97d3e9..0000000000 --- a/backends/PalmOS/Src/palmovl.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2005 The ScummVM project - * - * 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 "common/stdafx.h" -#include "palm.h" - -void OSystem_PALMOS::showOverlay() { - // hide the mouse - undraw_mouse(); - // save background - byte *src = _offScreenP; - byte *dst = _tmpBackupP; - int h = _screenHeight; - - UInt32 offset = 0; - do { - DmWrite(dst, offset, src, _screenWidth); - offset += _screenWidth; - src += _offScreenPitch; - } while (--h); - - _overlayVisible = true; - clearOverlay(); -} - -void OSystem_PALMOS::hideOverlay() { - // hide the mouse - undraw_mouse(); - - _overlayVisible = false; - copyRectToScreen(_tmpBackupP, _screenWidth, 0, 0, _screenWidth, _screenHeight); -} - -void OSystem_PALMOS::clearOverlay() { - if (!_overlayVisible) - return; - - // hide the mouse - undraw_mouse(); - // restore background - DmWrite(_tmpScreenP, 0, _tmpBackupP, _screenWidth * _screenHeight); -} - -void OSystem_PALMOS::grabOverlay(byte *buf, int pitch) { - if (!_overlayVisible) - return; - - // hide the mouse - undraw_mouse(); - - byte *src = _tmpScreenP; - int h = _screenHeight; - - do { - memcpy(buf, src, _screenWidth); - src += _screenWidth; - buf += pitch; - } while (--h); -} - -void OSystem_PALMOS::copyRectToOverlay(const byte *buf, int pitch, int x, int y, int w, int h) { - if (!_overlayVisible) - return; - - if (!_tmpScreenP) - return; - - // 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; - - /* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */ - if (_mouseDrawn) { -/* RectangleType mouse = {_mouseCurState.x, _mouseCurState.y, _mouseCurState.w, _mouseCurState.h}; - RectangleType copy = {x, y, w, h}; - RectangleType result; - - RctGetIntersection(&mouse, ©, &result); - - if (result.extent.x !=0 && result.extent.y !=0)*/ - undraw_mouse(); - } - - byte *dst = _tmpScreenP; - int offset = y * _screenWidth + x; - do { - DmWrite(dst, offset, buf, w); - offset += _screenWidth; - buf += pitch; - } while (--h); -} diff --git a/backends/PalmOS/Src/palmrdr.cpp b/backends/PalmOS/Src/palmrdr.cpp deleted file mode 100644 index 906e551f8b..0000000000 --- a/backends/PalmOS/Src/palmrdr.cpp +++ /dev/null @@ -1,278 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2005 The ScummVM project - * - * 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 "common/stdafx.h" -#include "palm.h" - -#include "rumble.h" -#include "shared.h" - -#ifndef DISABLE_TAPWAVE -#include "tapwave.h" -#include "i_zodiac.h" -#endif - -#include "init_arm.h" -#include "arm/native.h" -#include "arm/macros.h" - -static void rumblePack(Boolean active) { - if (!gVars->vibrator) - return; - - RumbleRun(active); -} - - -void OSystem_PALMOS::setShakePos(int shake_pos) { - _new_shake_pos = shake_pos; - - if (shake_pos == 0) - rumblePack(false); -} - -#ifndef DISABLE_TAPWAVE -void OSystem_PALMOS::updateScreen_wideZodiac() { - Err e; - TwGfxRectType destRect, srcRect; - TwGfxPointType destPoint = {0,0}; - Int32 h; - - if (_screenHeight == 200) - h = (_adjustAspectRatio ? 300 : 320); // 320x200 - else - h = (_adjustAspectRatio ? 360 : 320); // 640x480, 320x240 - - srcRect.x = 0; - srcRect.y = 0; - srcRect.w = _screenWidth; - srcRect.h = _screenHeight; - - destRect.w = 480; - destRect.h = h; - destRect.x = 0; - destRect.y = ((gVars->screenFullHeight - destRect.h) / 2); - - _screenOffset.y = destRect.y; - - // shake screen - if (_current_shake_pos != _new_shake_pos) { - RectangleType r; - - WinSetBackColor(0); - // clear top - RctSetRectangle(&r, 0, _screenOffset.y, 480, _new_shake_pos); - WinFillRectangle(&r, 0); - // clear bottom - RctSetRectangle(&r, 0, _screenOffset.y + h, 480, _current_shake_pos); - WinFillRectangle(&r, 0); - - destRect.y += _new_shake_pos; - _screenOffset.y += _new_shake_pos; - - rumblePack(_new_shake_pos >= 3); - _current_shake_pos = _new_shake_pos; - } - - // update screen - WinSetDrawWindow(WinGetDisplayWindow()); - e = TwGfxDrawPalmBitmap((TwGfxSurfaceType *)_twSrc, &destPoint, (BitmapPtr)_twBmpV3); - e = TwGfxStretchBlt2((TwGfxSurfaceType *)_twDst, &destRect, (TwGfxSurfaceType *)_twSrc, &srcRect, twGfxStretchFast| (gVars->filter ? twGfxStretchSmooth : 0)); -} -#endif - -void OSystem_PALMOS::updateScreen_widePortrait() { - UInt8 *dst = _screenP + _screenOffset.y; - UInt8 *src = _offScreenP + WIDE_PITCH - 1; - - // shake screen - if (_current_shake_pos != _new_shake_pos) { - RectangleType r; - - WinSetBackColor(0); - // clear top - RctSetRectangle(&r, _screenOffset.y, 0, _new_shake_pos, 480); - WinFillRectangle(&r, 0); - // clear bottom - RctSetRectangle(&r, _screenOffset.y + 300, 0, _current_shake_pos, 480); - WinFillRectangle(&r, 0); - - dst += _new_shake_pos; - - rumblePack(_new_shake_pos >= 3); - _current_shake_pos = _new_shake_pos; - } - - // update screen - ARM_START(WideType) - ARM_INIT(COMMON_WPORTRAIT) - ARM_ADDM(dst) - ARM_ADDM(src) - ARM_CALL(ARM_COMMON, PNO_DATA()) - ARM_CONTINUE() - { - Coord x, y; - UInt8 *src2 = src; - - for (x = 0; x < WIDE_HALF_WIDTH; x++) { - for (y = 0; y < WIDE_HALF_HEIGHT; y++) { - *dst++ = *src; - src += WIDE_PITCH; - *dst++ = *src; - *dst++ = *src; - src += WIDE_PITCH; - } - src = --src2; - dst += 20; // we draw 200pix scaled to 1.5 = 300, screen width=320, so next is 20 - - for (y = 0; y < WIDE_HALF_HEIGHT; y++) { - *dst++ = *src; - src += WIDE_PITCH; - *dst++ = *src; - *dst++ = *src; - src += WIDE_PITCH; - } - src = --src2; - dst += 20; - - MemMove(dst, dst - WIDE_PITCH, 300); // 300 = 200 x 1.5 - dst += WIDE_PITCH; - } - } - - WinScreenUnlock(); - _screenP = WinScreenLock(winLockCopy) + _screenOffset.addr; -} - -void OSystem_PALMOS::updateScreen_wideLandscape() { - UInt8 *dst = _screenP; - UInt8 *src = _offScreenP; - - // shake screen - if (_current_shake_pos != _new_shake_pos) { - RectangleType r; - - WinSetBackColor(0); - // clear top - RctSetRectangle(&r, 0, _screenOffset.y, 480, _new_shake_pos); - WinFillRectangle(&r, 0); - // clear bottom - RctSetRectangle(&r, 0, _screenOffset.y + 300, 480, _current_shake_pos); - WinFillRectangle(&r, 0); - - dst += _new_shake_pos * 480; - - rumblePack(_new_shake_pos >= 3); - _current_shake_pos = _new_shake_pos; - } - - // update screen - ARM_START(WideType) - ARM_INIT(COMMON_WLANDSCAPE) - ARM_ADDM(dst) - ARM_ADDM(src) - ARM_CALL(ARM_COMMON, PNO_DATA()) - ARM_CONTINUE() - { - Coord x, y; - - for (y = 0; y < WIDE_HALF_HEIGHT; y++) { - // draw 2 lines - for (x = 0; x < WIDE_FULL_WIDTH; x++) { - *dst++ = *src++; - *dst++ = *src; - *dst++ = *src++; - } - // copy the second to the next line - MemMove(dst, dst - 480, 480); - dst += 480; - } - } - - WinScreenUnlock(); - _screenP = WinScreenLock(winLockCopy) + _screenOffset.addr; -} - -void OSystem_PALMOS::updateScreen_flipping() { - RectangleType r, dummy; - Boolean shaked = false; - - // shake screen - if (_current_shake_pos != _new_shake_pos) { - RctSetRectangle(&r, _screenOffset.x, _screenOffset.y - _new_shake_pos, _screenWidth, _screenHeight + (_new_shake_pos << 2)); - - if (_useHRmode) - HRWinScrollRectangle(gVars->HRrefNum, &r, winDown, _new_shake_pos, &dummy); - else - WinScrollRectangle(&r, winDown, _new_shake_pos, &dummy); - - rumblePack(_new_shake_pos >= 3); - _current_shake_pos = _new_shake_pos; - shaked = true; - } - - // update screen - WinScreenUnlock(); - _offScreenP = WinScreenLock(winLockCopy) + _screenOffset.addr; - _screenP = _offScreenP; - - if (shaked) { - if (_useHRmode) - HRWinScrollRectangle(gVars->HRrefNum, &r, winUp, _new_shake_pos, &dummy); - else - WinScrollRectangle(&r, winUp, _new_shake_pos, &dummy); - } - -} - -void OSystem_PALMOS::updateScreen_buffered() { - RectangleType r; - - // shake screen - if (_current_shake_pos != _new_shake_pos) { - if (_new_shake_pos != 0) { - RctSetRectangle(&r, _screenOffset.x, _screenOffset.y + _screenHeight, _screenWidth, _new_shake_pos); - - if (OPTIONS_TST(kOptModeHiDensity)) - WinCopyRectangle(_screenH, _screenH, &r, _screenOffset.x, _screenOffset.y, winPaint); - else - HRWinCopyRectangle(gVars->HRrefNum, _screenH, _screenH, &r, _screenOffset.x, _screenOffset.y, winPaint); - } - - rumblePack(_new_shake_pos >= 3); - _current_shake_pos = _new_shake_pos; - } - - // update screen - RctSetRectangle(&r, 0, 0, _screenWidth, _screenHeight - _current_shake_pos); - - if (OPTIONS_TST(kOptModeHiDensity)) - WinCopyRectangle(_offScreenH, _screenH, &r, _screenOffset.x, _screenOffset.y + _current_shake_pos, winPaint); - else - HRWinCopyRectangle(gVars->HRrefNum, _offScreenH, _screenH, &r, _screenOffset.x, _screenOffset.y + _current_shake_pos, winPaint); -} - -void OSystem_PALMOS::updateScreen_direct() { - if (_current_shake_pos != _new_shake_pos) { - rumblePack(_new_shake_pos >= 3); - _current_shake_pos = _new_shake_pos; - } -} diff --git a/backends/PalmOS/Src/palmsnd.cpp b/backends/PalmOS/Src/palmsnd.cpp deleted file mode 100644 index fce551c8b2..0000000000 --- a/backends/PalmOS/Src/palmsnd.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2005 The ScummVM project - * - * 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 "common/stdafx.h" -#include "common/config-manager.h" - -#include "palm.h" -#include "pa1lib.h" - -#define SND_BLOCK (3072) - -#define ADPCM_8_KHZ 1 -#define ADPCM_MODE_NONCONTINUOUS_PB 0x01 -#define ADPCM_MODE_INTERRUPT_MODE 0x02 - - -int OSystem_PALMOS::getOutputSampleRate() const { - return _samplesPerSec; -} - -static void ClieSoundCallback(UInt32 UserData) { - SoundDataType *snd = (SoundDataType *)UserData; - snd->set = false; -} - -bool OSystem_PALMOS::setSoundCallback(SoundProc proc, void *param) { - Boolean success = false; - - if (!_sound.active) { - _sound.proc = proc; - _sound.param = param; - _sound.active = true; // always true when we call this function - _sound.dataP = NULL; // required by sound_handler - _sound.handle = NULL; - - if (ConfMan.hasKey("output_rate")) - _samplesPerSec = ConfMan.getInt("output_rate"); - else - _samplesPerSec = 8000; // default value - - // try to create sound stream - if (OPTIONS_TST(kOptPalmSoundAPI)) { - void *sndFuncP; - - _sound.handle = MemPtrNew(sizeof(SndStreamRef)); - sndFuncP = sndCallback; - - Err e = SndStreamCreateExtended( - (SndStreamRef *)_sound.handle, - sndOutput, - sndFormatPCM, - _samplesPerSec, - sndInt16Little, - sndStereo, - (SndStreamVariableBufferCallback)sndFuncP, - &_sound, - 8192, - false); - - e = e ? e : SndStreamStart(*((SndStreamRef *)_sound.handle)); - e = e ? e : SndStreamSetVolume(*((SndStreamRef *)_sound.handle), 32767 / 2); - - _sound.size = 0; // set by the callback - _sound.set = false; - _sound.wait = true; - success = (e == errNone); - - } else if (OPTIONS_TST(kOptSonyPa1LibAPI)) { - static CallbackInfoType cbData; - _sound.handle = MemPtrNew(sizeof(UInt8)); - - cbData.funcP = &ClieSoundCallback; - cbData.dwUserData = (UInt32)&_sound; - - _sound.size = SND_BLOCK; - _sound.set = false; - _sound.wait = true; - _sound.dataP = MemPtrNew(SND_BLOCK); - _sound.tmpP = MemPtrNew(SND_BLOCK / 8); - - success = true; // don't generate samples - - Pa1Lib_adpcmOpen(ADPCM_8_KHZ, (UInt8 *)_sound.tmpP, MemPtrSize(_sound.tmpP), &cbData, (UInt8 *)_sound.handle); - } - // failed or not supported - if (!success) { - _sound.size = SND_BLOCK; - _sound.set = false; - _sound.wait = false; - success = false; // don't generate samples - } - } - - return true; // if not true some scenes (indy3 256,...) may freeze (ESC to skip) -} - -void OSystem_PALMOS::clearSoundCallback() { - if (_sound.active) { - - if (OPTIONS_TST(kOptPalmSoundAPI)) { - SndStreamStop(*((SndStreamRef *)_sound.handle)); - SndStreamDelete(*((SndStreamRef *)_sound.handle)); - } - - free(_sound.dataP); - free(_sound.tmpP); - free(_sound.handle); - } - - - _sound.active = false; - _sound.dataP = NULL; - _sound.tmpP = NULL; - _sound.handle = NULL; -} - -void OSystem_PALMOS::sound_handler() { - if (_sound.active) { - if (_sound.size && (!_sound.set || !_sound.wait)) { - - if (!_sound.dataP) - _sound.dataP = MemPtrNew(_sound.size); - - ((SoundProc)_sound.proc)(_sound.param, (byte *)_sound.dataP, _sound.size); - - if (OPTIONS_TST(kOptSonyPa1LibAPI)) { - pcm2adpcm((Int16 *)_sound.dataP, (UInt8 *)_sound.tmpP, _sound.size); - _sound.set = Pa1Lib_adpcmStart(*((UInt8 *)_sound.handle), ADPCM_MODE_NONCONTINUOUS_PB|ADPCM_MODE_INTERRUPT_MODE); - } else { - _sound.set = true; - } - } - } -} - -bool OSystem_PALMOS::openCD(int drive) { - // TODO : add a function to CDAudio to init the MP3 driver (?) - return false; -} - -void OSystem_PALMOS::stopCD() { - if (!_cdPlayer) - return; - - _cdPlayer->stop(); -} - -void OSystem_PALMOS::playCD(int track, int num_loops, int start_frame, int duration) { - if (!_cdPlayer) - return; - - _cdPlayer->play(track, num_loops, start_frame, duration); -} - -bool OSystem_PALMOS::pollCD() { - if (!_cdPlayer) - return false; - - return _cdPlayer->poll(); -} - -void OSystem_PALMOS::updateCD() { - if (!_cdPlayer) - return; - - _cdPlayer->update(); -} -- cgit v1.2.3