2003-04-30 21:08:44 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2004-01-06 12:45:34 +00:00
|
|
|
* Copyright (C) 2001-2004 The ScummVM project
|
2003-04-30 21:08:44 +00:00
|
|
|
*
|
|
|
|
* 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$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
#include "backends/intern.h"
|
2003-04-30 11:37:10 +00:00
|
|
|
#include "scumm.h"
|
|
|
|
#include "common/scaler.h"
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
#include "start.h"
|
2003-04-30 11:37:10 +00:00
|
|
|
#include "palm.h"
|
2003-05-06 08:24:21 +00:00
|
|
|
#include "vibrate.h"
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
#include "cd_msa.h"
|
2003-11-28 09:30:46 +00:00
|
|
|
//#undef DISABLE_TAPWAVE
|
2003-09-23 16:01:52 +00:00
|
|
|
|
|
|
|
#ifndef DISABLE_TAPWAVE
|
2003-11-03 16:13:00 +00:00
|
|
|
#include "tapwave.h"
|
2003-09-23 16:01:52 +00:00
|
|
|
//#include "cd_zodiac.h"
|
|
|
|
#endif
|
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
#define EXITDELAY (500) // delay to exit : calc button : double tap 1/500 sec
|
|
|
|
#define ftrOverlayPtr (1000)
|
|
|
|
#define ftrBackupPtr (1001)
|
2003-11-03 16:13:00 +00:00
|
|
|
//#define SND_BLOCK (8192)
|
2003-08-18 10:47:14 +00:00
|
|
|
#define SND_BLOCK (3072)
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
OSystem *OSystem_PALMOS::create(UInt16 gfx_mode, bool full_screen) {
|
2003-04-30 11:37:10 +00:00
|
|
|
OSystem_PALMOS *syst = new OSystem_PALMOS();
|
|
|
|
syst->_mode = gfx_mode;
|
|
|
|
syst->_vibrate = gVars->vibrator;
|
2003-09-23 16:01:52 +00:00
|
|
|
syst->_fullscreen = (full_screen && (gVars->options & optHasWideMode));
|
2003-04-30 11:37:10 +00:00
|
|
|
return syst;
|
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
OSystem *OSystem_PALMOS_create(int gfx_mode, bool full_screen) {
|
|
|
|
return OSystem_PALMOS::create(gfx_mode, full_screen);
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
void OSystem_PALMOS::set_palette(const byte *colors, uint start, uint num) {
|
2003-11-28 09:30:46 +00:00
|
|
|
if (_quitCount)
|
2003-09-23 16:01:52 +00:00
|
|
|
return;
|
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
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;
|
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
void OSystem_PALMOS::load_gfx_mode() {
|
|
|
|
Err e;
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
// init screens
|
|
|
|
switch(_mode) {
|
2003-04-30 11:37:10 +00:00
|
|
|
case GFX_FLIPPING:
|
2003-05-28 18:42:16 +00:00
|
|
|
gVars->screenLocked = true;
|
2003-08-18 10:47:14 +00:00
|
|
|
_offScreenP = WinScreenLock(winLockErase) + _screenOffset.addr;
|
2003-05-06 08:24:21 +00:00
|
|
|
_screenP = _offScreenP;
|
2003-05-28 18:42:16 +00:00
|
|
|
_offScreenH = WinGetDisplayWindow();
|
|
|
|
_screenH = _offScreenH;
|
2003-04-30 11:37:10 +00:00
|
|
|
_renderer_proc = &update_screen__flipping;
|
|
|
|
break;
|
2003-05-28 18:42:16 +00:00
|
|
|
case GFX_WIDE:
|
2003-04-30 11:37:10 +00:00
|
|
|
case GFX_DOUBLEBUFFER:
|
2003-05-06 08:24:21 +00:00
|
|
|
_screenH = WinGetDisplayWindow();
|
2003-11-03 16:13:00 +00:00
|
|
|
_offScreenH = WinCreateOffscreenWindow(_screenWidth, _screenHeight,screenFormat, &e);
|
2003-05-06 08:24:21 +00:00
|
|
|
_offScreenP = (byte *)(BmpGetBits(WinGetBitmap(_offScreenH)));
|
2003-05-28 18:42:16 +00:00
|
|
|
|
|
|
|
if (_mode == GFX_WIDE) {
|
|
|
|
gVars->screenLocked = true;
|
2003-08-18 10:47:14 +00:00
|
|
|
_screenP = WinScreenLock(winLockErase) + _screenOffset.addr;
|
2003-05-28 18:42:16 +00:00
|
|
|
_renderer_proc = &update_screen__wide;
|
|
|
|
} else {
|
2003-08-18 10:47:14 +00:00
|
|
|
_screenP = (byte *)(BmpGetBits(WinGetBitmap(_screenH))) + _screenOffset.addr;
|
2003-05-28 18:42:16 +00:00
|
|
|
_renderer_proc = &update_screen__dbuffer;
|
2003-08-18 10:47:14 +00:00
|
|
|
_offScreenPitch = _screenWidth;
|
2003-05-28 18:42:16 +00:00
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
break;
|
2003-05-28 18:42:16 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
case GFX_NORMAL:
|
|
|
|
default:
|
2003-05-06 08:24:21 +00:00
|
|
|
_offScreenH = WinGetDisplayWindow();
|
2003-05-28 18:42:16 +00:00
|
|
|
_screenH = _offScreenH;
|
2003-08-18 10:47:14 +00:00
|
|
|
_offScreenP = (byte *)(BmpGetBits(WinGetBitmap(_offScreenH))) + _screenOffset.addr;
|
2003-05-06 08:24:21 +00:00
|
|
|
_screenP = _offScreenP;
|
2003-04-30 11:37:10 +00:00
|
|
|
_renderer_proc = &update_screen__direct;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-07-07 08:45:20 +00:00
|
|
|
// palette for preload dialog
|
|
|
|
set_palette(startupPalette,0,16);
|
2003-09-23 16:01:52 +00:00
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
// try to allocate on storage heap
|
|
|
|
FtrPtrNew(appFileCreator, ftrOverlayPtr, _screenWidth * _screenHeight, (void **)&_tmpScreenP);
|
2003-08-18 10:47:14 +00:00
|
|
|
FtrPtrNew(appFileCreator, ftrBackupPtr, _screenWidth * _screenHeight, (void **)&_tmpBackupP);
|
2003-05-06 08:24:21 +00:00
|
|
|
// failed ? dynamic heap
|
2003-08-18 10:47:14 +00:00
|
|
|
if (!_tmpScreenP) _tmpScreenP = (byte *)malloc(_screenWidth * _screenHeight);
|
|
|
|
if (!_tmpBackupP) _tmpBackupP = (byte *)malloc(_screenWidth * _screenHeight);
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
void OSystem_PALMOS::unload_gfx_mode() {
|
|
|
|
switch (_mode)
|
|
|
|
{
|
|
|
|
case GFX_FLIPPING:
|
|
|
|
WinScreenUnlock();
|
|
|
|
break;
|
2003-05-28 18:42:16 +00:00
|
|
|
|
|
|
|
case GFX_WIDE:
|
|
|
|
WinScreenUnlock();
|
|
|
|
// continue to GFX_DOUBLEBUFFER
|
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
case GFX_DOUBLEBUFFER:
|
2003-05-06 08:24:21 +00:00
|
|
|
WinDeleteWindow(_offScreenH,false);
|
2003-04-30 11:37:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
if (_tmpScreenP)
|
|
|
|
if (MemPtrDataStorage(_tmpScreenP))
|
|
|
|
FtrPtrFree(appFileCreator, ftrOverlayPtr);
|
|
|
|
else
|
|
|
|
free(_tmpScreenP);
|
2003-05-28 18:42:16 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
if (_tmpBackupP)
|
|
|
|
if (MemPtrDataStorage(_tmpBackupP))
|
|
|
|
FtrPtrFree(appFileCreator, ftrBackupPtr);
|
|
|
|
else
|
|
|
|
free(_tmpBackupP);
|
2003-05-28 18:42:16 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
void OSystem_PALMOS::init_size(uint w, uint h) {
|
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
_screenWidth = w;
|
|
|
|
_screenHeight = h;
|
2003-11-28 09:30:46 +00:00
|
|
|
_offScreenPitch = gVars->screenPitch; // direct screen / flipping use this, set later if double buffer
|
|
|
|
_screenPitch = gVars->screenPitch;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
_overlayVisible = false;
|
2003-11-28 09:30:46 +00:00
|
|
|
_quitCount = 0;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-11-28 09:30:46 +00:00
|
|
|
if (OPTIONS(optIsCollapsible))
|
|
|
|
SysSetOrientationTriggerState(sysOrientationTriggerDisabled);
|
2003-05-28 18:42:16 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
// check HiRes+
|
2003-05-28 18:42:16 +00:00
|
|
|
if (_mode == GFX_WIDE) {
|
2003-08-18 10:47:14 +00:00
|
|
|
if (gVars->slkRefNum != sysInvalidRefNum) {
|
|
|
|
if (!(w == 320 && h == 200 && gVars->slkVersion != vskVersionNum3)) { // only for 320x200 games and not for UX50 at this time
|
2003-05-28 18:42:16 +00:00
|
|
|
warning("Wide display not avalaible for this game, switching to GFX_NORMAL mode.");
|
|
|
|
_mode = GFX_NORMAL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
warning("HiRes+ not avalaible on this device, switching to GFX_NORMAL mode.");
|
|
|
|
_mode = GFX_NORMAL;
|
|
|
|
}
|
|
|
|
}
|
2003-08-18 10:47:14 +00:00
|
|
|
|
|
|
|
if (_fullscreen || _mode == GFX_WIDE) {
|
2003-09-23 16:01:52 +00:00
|
|
|
// 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
|
2003-11-28 09:30:46 +00:00
|
|
|
} else if (OPTIONS(optHasWideMode)) {
|
2003-09-23 16:01:52 +00:00
|
|
|
/* UInt32 width = hrWidth;
|
|
|
|
UInt32 height= hrHeight;
|
|
|
|
UInt32 depth = 16;
|
|
|
|
Boolean color = true;
|
2003-11-28 09:30:46 +00:00
|
|
|
Err e;
|
|
|
|
e = WinScreenMode (winScreenModeSet, &width, &height, &depth, &color );
|
|
|
|
*/ //SysSetOrientation(sysOrientationLandscape);
|
2003-09-23 16:01:52 +00:00
|
|
|
PINSetInputAreaState(pinInputAreaClosed);
|
2003-11-28 09:30:46 +00:00
|
|
|
StatHide();
|
2003-11-03 16:13:00 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
}
|
|
|
|
}
|
2003-05-28 18:42:16 +00:00
|
|
|
|
|
|
|
if (_mode == GFX_WIDE) {
|
2003-08-18 10:47:14 +00:00
|
|
|
_screenOffset.x = 0;
|
|
|
|
_screenOffset.y = 10;
|
|
|
|
_screenOffset.addr = _screenOffset.y;
|
2003-05-28 18:42:16 +00:00
|
|
|
} else {
|
2003-08-18 10:47:14 +00:00
|
|
|
_screenOffset.x = ((_fullscreen ? gVars->screenFullWidth : gVars->screenWidth) - w) >> 1;
|
|
|
|
_screenOffset.y = ((_fullscreen ? gVars->screenFullHeight : gVars->screenHeight) - h) >> 1;
|
|
|
|
_screenOffset.addr = _screenOffset.x + _screenOffset.y * _screenPitch;
|
2003-05-28 18:42:16 +00:00
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
set_mouse_pos(200,150);
|
|
|
|
|
|
|
|
_currentPalette = (RGBColorType*)calloc(sizeof(RGBColorType), 256);
|
2003-05-06 08:24:21 +00:00
|
|
|
_mouseBackupP = (byte*)malloc(MAX_MOUSE_W * MAX_MOUSE_H);
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
load_gfx_mode();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_PALMOS::copy_rect(const byte *buf, int pitch, int x, int y, int w, int h) {
|
2003-06-08 09:18:21 +00:00
|
|
|
/* 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;
|
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
/* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */
|
2003-05-06 08:24:21 +00:00
|
|
|
if (_mouseDrawn)
|
2003-04-30 11:37:10 +00:00
|
|
|
undraw_mouse();
|
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
byte *dst = _offScreenP + y * _offScreenPitch + x;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
if (_offScreenPitch == pitch && pitch == w) {
|
2003-06-08 09:18:21 +00:00
|
|
|
memcpy (dst, buf, h * w);
|
|
|
|
} else {
|
|
|
|
do {
|
|
|
|
memcpy(dst, buf, w);
|
2003-08-18 10:47:14 +00:00
|
|
|
dst += _offScreenPitch;
|
2003-06-08 09:18:21 +00:00
|
|
|
buf += pitch;
|
|
|
|
} while (--h);
|
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-08-06 08:33:38 +00:00
|
|
|
// only avalaible for 320x200 games, so use values instead of vars
|
|
|
|
#define WIDE_PITCH 320
|
|
|
|
#define WIDE_HALF_HEIGHT 100 // 200 / 2
|
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
void OSystem_PALMOS::update_screen__wide() {
|
|
|
|
Coord x, y;
|
2003-08-18 10:47:14 +00:00
|
|
|
UInt32 next = _screenOffset.y << 1;
|
2003-05-28 18:42:16 +00:00
|
|
|
UInt8 *dst = _screenP;
|
2003-08-06 08:33:38 +00:00
|
|
|
UInt8 *src1 = _offScreenP + WIDE_PITCH - 1;
|
2003-05-28 18:42:16 +00:00
|
|
|
UInt8 *src2 = src1;
|
|
|
|
|
2003-08-06 08:33:38 +00:00
|
|
|
for (x = 0; x < _screenWidth >> 1; x++)
|
|
|
|
{
|
|
|
|
for (y = 0; y < WIDE_HALF_HEIGHT; y++)
|
|
|
|
{
|
2003-05-28 18:42:16 +00:00
|
|
|
*dst++ = *src1;
|
2003-08-06 08:33:38 +00:00
|
|
|
src1 += WIDE_PITCH;
|
|
|
|
*dst++ = *src1;
|
|
|
|
*dst++ = *src1;
|
|
|
|
src1 += WIDE_PITCH;
|
2003-05-28 18:42:16 +00:00
|
|
|
}
|
|
|
|
src1 = --src2;
|
|
|
|
dst += next;
|
|
|
|
|
2003-08-06 08:33:38 +00:00
|
|
|
for (y = 0; y < WIDE_HALF_HEIGHT; y++)
|
|
|
|
{
|
|
|
|
*dst++ = *src1;
|
|
|
|
src1 += WIDE_PITCH;
|
|
|
|
*dst++ = *src1;
|
|
|
|
*dst++ = *src1;
|
|
|
|
src1 += WIDE_PITCH;
|
2003-05-28 18:42:16 +00:00
|
|
|
}
|
2003-08-06 08:33:38 +00:00
|
|
|
src1 = --src2;
|
|
|
|
dst += next;
|
|
|
|
|
|
|
|
MemMove(dst, dst - WIDE_PITCH, 300); // 300 = 200 x 1.5
|
|
|
|
dst += WIDE_PITCH;
|
|
|
|
}
|
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
WinScreenUnlock();
|
2003-08-18 10:47:14 +00:00
|
|
|
_screenP = WinScreenLock(winLockCopy) + _screenOffset.addr;
|
2003-05-28 18:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_PALMOS::update_screen__flipping() {
|
|
|
|
RectangleType r, dummy;
|
2003-04-30 11:37:10 +00:00
|
|
|
UInt8 *screen;
|
2003-08-18 10:47:14 +00:00
|
|
|
UInt32 size = _screenWidth * _screenHeight + 6400; // 10 pix top and bottom border, see TODO
|
2003-04-30 11:37:10 +00:00
|
|
|
Boolean shaked = false;
|
|
|
|
UInt32 move = 0;
|
|
|
|
|
|
|
|
// shake screen
|
|
|
|
if (_current_shake_pos != _new_shake_pos) {
|
2003-05-28 18:42:16 +00:00
|
|
|
if (_useHRmode) {
|
2003-08-18 10:47:14 +00:00
|
|
|
RctSetRectangle(&r, _screenOffset.x, _screenOffset.y - _new_shake_pos, _screenWidth, _screenHeight + (_new_shake_pos << 2));
|
2003-05-28 18:42:16 +00:00
|
|
|
HRWinScrollRectangle(gVars->HRrefNum, &r, winDown, _new_shake_pos, &dummy);
|
2003-04-30 11:37:10 +00:00
|
|
|
} else {
|
2003-08-18 10:47:14 +00:00
|
|
|
// TODO : need to change this to line copy if palm give us an HiRes+ device and change 3200/6400 value to the good one depending on the screen pitch
|
2003-05-06 08:24:21 +00:00
|
|
|
move = (_new_shake_pos * _screenWidth);
|
|
|
|
screen = _offScreenP - 3200;
|
2003-04-30 11:37:10 +00:00
|
|
|
MemMove(screen + move, screen, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_vibrate) {
|
|
|
|
Boolean active = (_new_shake_pos >= 3);
|
|
|
|
HwrVibrateAttributes(1, kHwrVibrateActive, &active);
|
|
|
|
}
|
|
|
|
|
|
|
|
_current_shake_pos = _new_shake_pos;
|
|
|
|
shaked = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// update screen
|
|
|
|
WinScreenUnlock();
|
2003-08-18 10:47:14 +00:00
|
|
|
_offScreenP = WinScreenLock(winLockCopy) + _screenOffset.addr;
|
2003-05-06 08:24:21 +00:00
|
|
|
_screenP = _offScreenP;
|
2003-04-30 11:37:10 +00:00
|
|
|
if (shaked) {
|
2003-05-28 18:42:16 +00:00
|
|
|
if (_useHRmode) {
|
|
|
|
HRWinScrollRectangle(gVars->HRrefNum, &r, winUp, _new_shake_pos, &dummy);
|
2003-04-30 11:37:10 +00:00
|
|
|
} else {
|
2003-08-18 10:47:14 +00:00
|
|
|
// TODO : need to change this to line copy if palm give us an HiRes+ device
|
2003-05-06 08:24:21 +00:00
|
|
|
screen = _offScreenP - 3200;
|
2003-04-30 11:37:10 +00:00
|
|
|
MemMove(screen, screen + move, size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
void OSystem_PALMOS::update_screen__dbuffer() {
|
2003-04-30 11:37:10 +00:00
|
|
|
UInt32 move = 0;
|
2003-05-06 08:24:21 +00:00
|
|
|
UInt32 size = _screenWidth * _screenHeight;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
// shake screen
|
|
|
|
if (_current_shake_pos != _new_shake_pos) {
|
2003-08-18 10:47:14 +00:00
|
|
|
move = (_new_shake_pos * _screenPitch);
|
2003-04-30 11:37:10 +00:00
|
|
|
// copy clear bottom of the screen to top to cover shaking image
|
2003-08-18 10:47:14 +00:00
|
|
|
|
|
|
|
if (_screenPitch == _screenWidth) {
|
|
|
|
MemMove(_screenP, _screenP + size , move);
|
|
|
|
MemMove(_screenP + move, _offScreenP, size - move);
|
|
|
|
} else if (_new_shake_pos != 0) {
|
|
|
|
UInt16 h = _new_shake_pos;
|
|
|
|
byte *src = _screenP + _screenPitch * _screenHeight;
|
|
|
|
byte *dst = _screenP;
|
|
|
|
do {
|
|
|
|
memcpy(dst, src, _screenWidth);
|
|
|
|
dst += _screenPitch;
|
|
|
|
src += _screenPitch;
|
|
|
|
} while (--h);
|
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
if (_vibrate) {
|
|
|
|
Boolean active = (_new_shake_pos >= 3);
|
|
|
|
HwrVibrateAttributes(1, kHwrVibrateActive, &active);
|
|
|
|
}
|
|
|
|
|
|
|
|
_current_shake_pos = _new_shake_pos;
|
|
|
|
}
|
|
|
|
// update screen
|
2003-08-18 10:47:14 +00:00
|
|
|
if (_screenPitch == _screenWidth) {
|
|
|
|
MemMove(_screenP + move, _offScreenP, size - move);
|
|
|
|
} else {
|
2003-11-28 09:30:46 +00:00
|
|
|
#ifndef DISABLE_TAPWAVE
|
2003-09-23 16:01:52 +00:00
|
|
|
Err e;
|
|
|
|
TwGfxSurfaceType *src;
|
|
|
|
TwGfxSurfaceType *dst;
|
|
|
|
TwGfxRectType d = {0,0,480,300}, s = {0,0,320,200};
|
|
|
|
TwGfxSurfaceInfoType t;
|
2003-11-03 16:13:00 +00:00
|
|
|
TwGfxPointType dd = {0,0};
|
2003-11-28 09:30:46 +00:00
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
t.size = sizeof(TwGfxSurfaceInfoType);
|
|
|
|
t.width = 320;
|
|
|
|
t.height = 200;
|
2003-11-03 16:13:00 +00:00
|
|
|
t.rowBytes = 640;
|
2003-09-23 16:01:52 +00:00
|
|
|
t.location = twGfxLocationAcceleratorMemory;
|
|
|
|
t.pixelFormat = twGfxPixelFormatRGB565_LE;
|
2003-11-28 09:30:46 +00:00
|
|
|
/*
|
|
|
|
ColorTableType table;
|
|
|
|
RGBColorType *rgb = ColorTableEntries (table);
|
|
|
|
table.numEntries = 256;
|
|
|
|
*rgb = _currentPalette;
|
|
|
|
*/
|
|
|
|
//BitmapType *newBmp =
|
2003-09-23 16:01:52 +00:00
|
|
|
|
2003-11-03 16:13:00 +00:00
|
|
|
|
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
TwGfxType *gfx;
|
|
|
|
e = TwGfxOpen(&gfx, NULL);
|
|
|
|
e = TwGfxAllocSurface(gfx, &src, &t);
|
2003-11-03 16:13:00 +00:00
|
|
|
e = TwGfxDrawPalmBitmap(src, &dd, WinGetBitmap(_offScreenH));
|
2003-09-23 16:01:52 +00:00
|
|
|
|
|
|
|
e = TwGfxGetPalmDisplaySurface(gfx, &dst);
|
|
|
|
e = TwGfxStretchBlt(dst, &d, src, &s);
|
|
|
|
e = TwGfxFreeSurface(src);
|
|
|
|
e = TwGfxClose(gfx);
|
2003-11-28 09:30:46 +00:00
|
|
|
#endif
|
2003-09-23 16:01:52 +00:00
|
|
|
//#if 0
|
2003-08-18 10:47:14 +00:00
|
|
|
byte *src = _offScreenP;
|
|
|
|
byte *dst = _screenP + move;
|
|
|
|
UInt16 h = _screenHeight - _new_shake_pos;
|
|
|
|
do {
|
|
|
|
memcpy(dst, src, _screenWidth);
|
|
|
|
dst += _screenPitch;
|
2003-11-28 09:30:46 +00:00
|
|
|
src += _offScreenPitch;
|
2003-08-18 10:47:14 +00:00
|
|
|
} while (--h);
|
2003-09-23 16:01:52 +00:00
|
|
|
//#endif
|
2003-08-18 10:47:14 +00:00
|
|
|
}
|
2003-09-23 16:01:52 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
void OSystem_PALMOS::update_screen__direct() {
|
2003-04-30 11:37:10 +00:00
|
|
|
if (_current_shake_pos != _new_shake_pos) {
|
|
|
|
if (_vibrate) {
|
|
|
|
Boolean active = (_new_shake_pos >= 3);
|
|
|
|
HwrVibrateAttributes(1, kHwrVibrateActive, &active);
|
|
|
|
}
|
|
|
|
_current_shake_pos = _new_shake_pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-19 11:02:59 +00:00
|
|
|
#define MD_NONE 0
|
|
|
|
#define MD_CTRL 1
|
|
|
|
#define MD_ALT 2
|
|
|
|
|
|
|
|
static void drawKeyState(OSystem_PALMOS *sys, UInt8 state) {
|
|
|
|
UInt8 i,j;
|
|
|
|
UInt16 bmpID = 3000 + state - 1;
|
|
|
|
|
|
|
|
MemHandle hTemp;
|
|
|
|
BitmapType *bmTemp;
|
|
|
|
UInt32 *bmData;
|
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
UInt32 pitch = sys->_screenPitch;
|
|
|
|
UInt8 *scr = sys->_screenP + sys->_screenPitch * (sys->get_height() + 2) + 2;
|
2003-05-19 11:02:59 +00:00
|
|
|
|
|
|
|
hTemp = DmGetResource(bitmapRsc,bmpID);
|
|
|
|
|
|
|
|
if (hTemp) { // draw
|
|
|
|
bmTemp = (BitmapType *)MemHandleLock(hTemp);
|
|
|
|
bmData = (UInt32 *)BmpGetBits(bmTemp);
|
|
|
|
|
|
|
|
for (i = 0; i < 7; i++) {
|
|
|
|
for (j = 0; j < 32; j++) {
|
|
|
|
if (*bmData & (1 << (31-j)))
|
|
|
|
*scr++ = gVars->indicator.on;
|
|
|
|
else
|
|
|
|
*scr++ = gVars->indicator.off;
|
|
|
|
}
|
|
|
|
scr += pitch - 32;
|
|
|
|
bmData++;
|
|
|
|
}
|
|
|
|
|
|
|
|
MemPtrUnlock(bmTemp);
|
|
|
|
DmReleaseResource(hTemp);
|
|
|
|
} else { // undraw
|
|
|
|
for (i = 0; i < 7; i++) {
|
|
|
|
for (j = 0; j < 32; j++) {
|
|
|
|
*scr++ = gVars->indicator.off;
|
|
|
|
}
|
|
|
|
scr += pitch - 32;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drawNumPad(OSystem_PALMOS *sys, UInt8 color) {
|
|
|
|
UInt8 i,j,k;
|
|
|
|
UInt16 bmpID = 3010; // numPadBitmap 64x34
|
|
|
|
|
|
|
|
MemHandle hTemp;
|
|
|
|
BitmapType *bmTemp;
|
|
|
|
UInt32 *bmData;
|
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
UInt32 pitch = sys->_screenPitch;
|
|
|
|
UInt8 *scr = sys->_screenP + sys->_screenPitch * (sys->get_height() + 2);
|
|
|
|
|
2003-11-03 16:13:00 +00:00
|
|
|
scr += (sys->get_width() >> 1) - 32;
|
2003-05-19 11:02:59 +00:00
|
|
|
hTemp = DmGetResource(bitmapRsc,bmpID);
|
|
|
|
|
|
|
|
if (hTemp) {
|
|
|
|
bmTemp = (BitmapType *)MemHandleLock(hTemp);
|
|
|
|
bmData = (UInt32 *)BmpGetBits(bmTemp);
|
|
|
|
|
|
|
|
for (i = 0; i < 34; i++) {
|
|
|
|
for (k = 0; k < 2; k++) {
|
|
|
|
for (j = 0; j < 32; j++) {
|
|
|
|
if (*bmData & (1 << (31-j)))
|
|
|
|
*scr++ = color;
|
|
|
|
else
|
|
|
|
*scr++ = 0;
|
|
|
|
}
|
|
|
|
bmData++;
|
|
|
|
}
|
|
|
|
scr += pitch - 64;
|
|
|
|
}
|
|
|
|
|
|
|
|
MemPtrUnlock(bmTemp);
|
|
|
|
DmReleaseResource(hTemp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
void OSystem_PALMOS::update_screen() {
|
2003-11-28 09:30:46 +00:00
|
|
|
if(_quitCount)
|
2003-04-30 11:37:10 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Make sure the mouse is drawn, if it should be drawn.
|
|
|
|
draw_mouse();
|
|
|
|
|
|
|
|
// Check whether the palette was changed in the meantime and update the
|
|
|
|
// screen surface accordingly.
|
|
|
|
if (_paletteDirtyEnd != 0) {
|
2003-05-19 11:02:59 +00:00
|
|
|
UInt8 oldCol;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-05-19 11:02:59 +00:00
|
|
|
if (gVars->stdPalette) {
|
|
|
|
WinSetDrawWindow(WinGetDisplayWindow()); // hack by Doug
|
|
|
|
WinPalette(winPaletteSet, _paletteDirtyStart, _paletteDirtyEnd - _paletteDirtyStart,_currentPalette + _paletteDirtyStart);
|
|
|
|
} else {
|
|
|
|
HwrDisplayPalette(winPaletteSet, _paletteDirtyStart, _paletteDirtyEnd - _paletteDirtyStart,_currentPalette + _paletteDirtyStart);
|
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
_paletteDirtyEnd = 0;
|
2003-05-19 11:02:59 +00:00
|
|
|
oldCol = gVars->indicator.on;
|
2003-04-30 11:37:10 +00:00
|
|
|
gVars->indicator.on = RGBToColor(0,255,0);
|
2003-05-19 11:02:59 +00:00
|
|
|
|
|
|
|
if (oldCol != gVars->indicator.on) {
|
|
|
|
// redraw if needed
|
2003-05-28 18:42:16 +00:00
|
|
|
if (_lastKeyModifier)
|
|
|
|
drawKeyState(this, _lastKeyModifier);
|
2003-05-19 11:02:59 +00:00
|
|
|
|
|
|
|
if(_useNumPad)
|
|
|
|
drawNumPad(this, gVars->indicator.on);
|
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-07-07 08:45:20 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
if (_overlayVisible) {
|
|
|
|
byte *src = _tmpScreenP;
|
|
|
|
byte *dst = _offScreenP;
|
|
|
|
UInt16 h = _screenHeight;
|
|
|
|
|
|
|
|
do {
|
|
|
|
memcpy(dst, src, _screenWidth);
|
|
|
|
dst += _offScreenPitch;
|
|
|
|
src += _screenWidth;
|
|
|
|
} while (--h);
|
|
|
|
}
|
|
|
|
|
2003-07-07 08:45:20 +00:00
|
|
|
// redraw the screen
|
|
|
|
((this)->*(_renderer_proc))();
|
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
bool OSystem_PALMOS::show_mouse(bool visible) {
|
2003-05-06 08:24:21 +00:00
|
|
|
if (_mouseVisible == visible)
|
2003-04-30 11:37:10 +00:00
|
|
|
return visible;
|
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
bool last = _mouseVisible;
|
|
|
|
_mouseVisible = visible;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
if (visible)
|
|
|
|
draw_mouse();
|
|
|
|
else
|
|
|
|
undraw_mouse();
|
|
|
|
|
|
|
|
return last;
|
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-08-06 08:33:38 +00:00
|
|
|
void OSystem_PALMOS::warp_mouse(int x, int y) {}
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
void OSystem_PALMOS::set_mouse_pos(int x, int y) {
|
2003-05-06 08:24:21 +00:00
|
|
|
if (x != _mouseCurState.x || y != _mouseCurState.y) {
|
|
|
|
_mouseCurState.x = x;
|
|
|
|
_mouseCurState.y = y;
|
2003-04-30 11:37:10 +00:00
|
|
|
undraw_mouse();
|
|
|
|
}
|
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
void OSystem_PALMOS::set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) {
|
2003-05-06 08:24:21 +00:00
|
|
|
_mouseCurState.w = w;
|
|
|
|
_mouseCurState.h = h;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
_mouseHotspotX = hotspot_x;
|
|
|
|
_mouseHotspotY = hotspot_y;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
_mouseDataP = (byte*)buf;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
undraw_mouse();
|
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
void OSystem_PALMOS::set_shake_pos(int shake_pos) {
|
|
|
|
_new_shake_pos = shake_pos;
|
|
|
|
|
|
|
|
if (shake_pos == 0 && _vibrate)
|
|
|
|
{
|
|
|
|
Boolean active = false;
|
|
|
|
HwrVibrateAttributes(1, kHwrVibrateActive, &active);
|
|
|
|
}
|
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
uint32 OSystem_PALMOS::get_msecs() {
|
|
|
|
uint32 ticks = TimGetTicks();
|
|
|
|
ticks *= (1000/SysTicksPerSecond());
|
|
|
|
return ticks;
|
|
|
|
|
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
void OSystem_PALMOS::delay_msecs(uint msecs) {
|
2003-11-28 09:30:46 +00:00
|
|
|
UInt32 delay = (SysTicksPerSecond() * msecs) / 1000;
|
|
|
|
|
|
|
|
if (delay)
|
|
|
|
SysTaskDelay(delay);
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-09-27 16:54:11 +00:00
|
|
|
void OSystem_PALMOS::set_timer(TimerProc callback, int timer) {
|
2003-04-30 11:37:10 +00:00
|
|
|
if (callback != NULL) {
|
|
|
|
_timer.duration = timer;
|
2003-11-28 09:30:46 +00:00
|
|
|
_timer.nextExpiry = get_msecs() + timer;
|
2003-04-30 11:37:10 +00:00
|
|
|
_timer.callback = callback;
|
|
|
|
_timer.active = true;
|
|
|
|
} else {
|
|
|
|
_timer.active = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mutex handling */
|
2003-07-07 08:45:20 +00:00
|
|
|
OSystem::MutexRef OSystem_PALMOS::create_mutex() {return NULL;}
|
|
|
|
void OSystem_PALMOS::lock_mutex(MutexRef mutex) {}
|
|
|
|
void OSystem_PALMOS::unlock_mutex(MutexRef mutex) {}
|
|
|
|
void OSystem_PALMOS::delete_mutex(MutexRef mutex) {}
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
void OSystem_PALMOS::SimulateArrowKeys(Event *event, Int8 iHoriz, Int8 iVert) {
|
2003-05-06 08:24:21 +00:00
|
|
|
Int16 x = _mouseCurState.x;
|
|
|
|
Int16 y = _mouseCurState.y;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
if (_lastKeyPressed != -1) {
|
2003-05-28 18:42:16 +00:00
|
|
|
_lastKeyRepeat += 100;
|
2003-08-18 10:47:14 +00:00
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
if (_lastKeyRepeat > 3200)
|
|
|
|
_lastKeyRepeat = 3200;
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
else
|
2003-05-28 18:42:16 +00:00
|
|
|
_lastKeyRepeat = 100;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
x = x + iHoriz * (_lastKeyRepeat / 100);
|
|
|
|
y = y + iVert * (_lastKeyRepeat / 100);
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
x = (x < 0 ) ? 0 : x;
|
|
|
|
x = (x >= _screenWidth ) ? _screenWidth - 1 : x;
|
|
|
|
y = (y < 0 ) ? 0 : y;
|
|
|
|
y = (y >= _screenHeight ) ? _screenHeight - 1 : y;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
event->event_code = EVENT_MOUSEMOVE;
|
|
|
|
event->mouse.x = x;
|
|
|
|
event->mouse.y = y;
|
2003-08-18 10:47:14 +00:00
|
|
|
set_mouse_pos(x, y);
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
static void getCoordinates(EventPtr event, Boolean wide, Coord *x, Coord *y) {
|
|
|
|
if (wide) {
|
2003-08-18 10:47:14 +00:00
|
|
|
*y = (event->screenX << 2) / 3;
|
|
|
|
*x = 320 - (event->screenY << 2) / 3 - 1; // wide only for 320x200, so ...
|
2003-05-28 18:42:16 +00:00
|
|
|
} else {
|
|
|
|
*x = event->screenX << 1;
|
|
|
|
*y = event->screenY << 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
bool OSystem_PALMOS::poll_event(Event *event) {
|
|
|
|
EventType ev;
|
|
|
|
Boolean handled;
|
2003-07-07 08:45:20 +00:00
|
|
|
UInt32 current_msecs;
|
2003-05-28 18:42:16 +00:00
|
|
|
UInt32 keyCurrentState;
|
2003-05-19 11:02:59 +00:00
|
|
|
Coord x, y;
|
2003-07-22 08:33:13 +00:00
|
|
|
|
2003-11-28 09:30:46 +00:00
|
|
|
if(_quitCount) {
|
|
|
|
if (_quitCount >= 10)
|
|
|
|
SysReset();
|
|
|
|
else
|
|
|
|
_quitCount++;
|
|
|
|
|
|
|
|
event->event_code = EVENT_QUIT;
|
2003-07-22 08:33:13 +00:00
|
|
|
exit(0); // resend an exit event
|
2003-05-19 11:02:59 +00:00
|
|
|
return false;
|
2003-07-22 08:33:13 +00:00
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-05-12 12:14:13 +00:00
|
|
|
current_msecs = get_msecs();
|
|
|
|
|
|
|
|
// sound handler
|
|
|
|
if(_sound.active)
|
|
|
|
check_sound();
|
2003-11-03 16:13:00 +00:00
|
|
|
|
2003-05-12 12:14:13 +00:00
|
|
|
// timer handler
|
2003-11-28 09:30:46 +00:00
|
|
|
// if (_timer.active)
|
|
|
|
// _timer.callback(_timer.duration);
|
|
|
|
if (_timer.active && (current_msecs >= _timer.nextExpiry)) {
|
2003-05-12 12:14:13 +00:00
|
|
|
_timer.duration = _timer.callback(_timer.duration);
|
2003-11-28 09:30:46 +00:00
|
|
|
_timer.nextExpiry = current_msecs + _timer.duration;
|
2003-05-12 12:14:13 +00:00
|
|
|
}
|
2003-11-28 09:30:46 +00:00
|
|
|
|
2003-11-03 16:13:00 +00:00
|
|
|
/*
|
|
|
|
if (_timer.active) {
|
|
|
|
if (current_msecs - _timer.next_expiry >= 10)
|
|
|
|
_timer.sleep = false;
|
|
|
|
|
|
|
|
if (!_timer.sleep) {
|
|
|
|
_timer.sleep = true;
|
|
|
|
while (_timer.next_expiry < current_msecs) {
|
|
|
|
_timer.next_expiry += 10;
|
|
|
|
_timer.duration = _timer.callback(_timer.duration);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2003-07-22 08:33:13 +00:00
|
|
|
if (_selfQuit)
|
|
|
|
quit();
|
|
|
|
|
2003-05-12 12:14:13 +00:00
|
|
|
for(;;) {
|
|
|
|
EvtGetEvent(&ev, evtNoWait);
|
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
// check for hardkey repeat
|
|
|
|
keyCurrentState = KeyCurrentState();
|
|
|
|
if (_lastKeyPressed != -1 && _lastKeyPressed != vchrCalc &&
|
|
|
|
!( (keyCurrentState & keyBitHard2) ||
|
|
|
|
(keyCurrentState & keyBitPageUp) ||
|
|
|
|
(keyCurrentState & keyBitPageDown) ||
|
|
|
|
(keyCurrentState & keyBitHard3)
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
_lastKeyPressed = -1;
|
|
|
|
}
|
|
|
|
|
2003-05-12 12:14:13 +00:00
|
|
|
if (ev.eType == nilEvent)
|
|
|
|
return false;
|
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
if (ev.eType == keyDownEvent) {
|
|
|
|
switch (ev.data.keyDown.chr) {
|
|
|
|
case vchrLaunch:
|
2003-05-28 18:42:16 +00:00
|
|
|
_lastKeyPressed = -1;
|
2003-04-30 11:37:10 +00:00
|
|
|
event->event_code = EVENT_KEYDOWN;
|
|
|
|
event->kbd.keycode = 27;
|
|
|
|
event->kbd.ascii = 27;
|
|
|
|
event->kbd.flags = 0;
|
|
|
|
return true;
|
2003-05-19 11:02:59 +00:00
|
|
|
|
2003-06-08 09:18:21 +00:00
|
|
|
case vchrJogPushRepeat:
|
2003-04-30 11:37:10 +00:00
|
|
|
case vchrMenu:
|
2003-05-28 18:42:16 +00:00
|
|
|
_lastKeyPressed = -1;
|
2003-04-30 11:37:10 +00:00
|
|
|
event->event_code = EVENT_KEYDOWN;
|
|
|
|
event->kbd.keycode = 319;
|
|
|
|
event->kbd.ascii = 319;
|
|
|
|
event->kbd.flags = 0;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case vchrBrightness:
|
|
|
|
case vchrContrast:
|
|
|
|
case vchrFind:
|
|
|
|
WinPalette(winPaletteSet, 0, 256, _currentPalette);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case vchrCalc:
|
2003-05-28 18:42:16 +00:00
|
|
|
if (_lastKeyPressed == vchrCalc)
|
2003-11-28 09:30:46 +00:00
|
|
|
if ((get_msecs() - _exit_delay) <= (EXITDELAY)) {
|
|
|
|
event->event_code = EVENT_QUIT;
|
2003-07-07 08:45:20 +00:00
|
|
|
_selfQuit = true;
|
2003-11-28 09:30:46 +00:00
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
_exit_delay = get_msecs();
|
2003-05-28 18:42:16 +00:00
|
|
|
_lastKeyPressed = vchrCalc;
|
2003-04-30 11:37:10 +00:00
|
|
|
return true;
|
|
|
|
|
2003-11-03 16:13:00 +00:00
|
|
|
// wheel
|
2003-04-30 11:37:10 +00:00
|
|
|
case vchrJogUp:
|
|
|
|
event->event_code = EVENT_WHEELUP;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case vchrJogDown:
|
|
|
|
event->event_code = EVENT_WHEELDOWN;
|
|
|
|
return true;
|
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
// if hotsync pressed
|
2003-04-30 11:37:10 +00:00
|
|
|
case vchrHardCradle:
|
2003-07-07 08:45:20 +00:00
|
|
|
case vchrHardCradle2:
|
|
|
|
_selfQuit = true;
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-11-03 16:13:00 +00:00
|
|
|
|
|
|
|
// if (gVars->options & opt5WayNavigator)*/ {
|
|
|
|
// } else {
|
|
|
|
// mouse emulation for device without 5-Way navigator
|
|
|
|
switch (ev.data.keyDown.chr) {
|
|
|
|
case vchrJogBack:
|
|
|
|
case vchrHard4: // right button
|
|
|
|
event->event_code = EVENT_RBUTTONDOWN;
|
|
|
|
event->mouse.x = _mouseCurState.x;
|
|
|
|
event->mouse.y = _mouseCurState.y;
|
|
|
|
_lastKeyPressed = -1;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case vchrJogPush:
|
|
|
|
case vchrHard1: // left button
|
|
|
|
event->event_code = EVENT_LBUTTONDOWN;
|
|
|
|
event->mouse.x = _mouseCurState.x;
|
|
|
|
event->mouse.y = _mouseCurState.y;
|
|
|
|
_lastKeyPressed = -1;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case vchrHard2: // move left
|
|
|
|
SimulateArrowKeys(event, -1, 0);
|
|
|
|
_lastKeyPressed = vchrHard2;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case vchrPageUp: // move up
|
|
|
|
SimulateArrowKeys(event, 0, -1);
|
|
|
|
_lastKeyPressed = vchrPageUp;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case vchrPageDown: // move down
|
|
|
|
SimulateArrowKeys(event, 0, 1);
|
|
|
|
_lastKeyPressed = vchrPageDown;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case vchrHard3: // move right
|
|
|
|
SimulateArrowKeys(event, 1, 0);
|
|
|
|
_lastKeyPressed = vchrHard3;
|
|
|
|
return true;
|
|
|
|
// }
|
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-08-18 10:47:14 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
// 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)));
|
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
// graffiti strokes, auto-off, etc...
|
2003-05-12 12:14:13 +00:00
|
|
|
if (!handled)
|
2003-04-30 11:37:10 +00:00
|
|
|
if (SysHandleEvent(&ev))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// others events
|
|
|
|
switch(ev.eType) {
|
|
|
|
|
|
|
|
case keyDownEvent: {
|
2003-05-28 18:42:16 +00:00
|
|
|
_lastEvent = keyDownEvent;
|
|
|
|
_lastKeyPressed = -1;
|
2003-04-30 11:37:10 +00:00
|
|
|
//if (ev.data.keyDown.modifiers & shiftKeyMask) b |= KBD_SHIFT;
|
|
|
|
|
2003-05-12 12:14:13 +00:00
|
|
|
if (ev.data.keyDown.chr == vchrCommand && (ev.data.keyDown.modifiers & commandKeyMask)) {
|
2003-05-28 18:42:16 +00:00
|
|
|
_lastKeyModifier++;
|
|
|
|
_lastKeyModifier %= 3;
|
|
|
|
drawKeyState(this, _lastKeyModifier);
|
2003-05-12 12:14:13 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
} else {
|
|
|
|
byte b = 0;
|
2003-08-18 10:47:14 +00:00
|
|
|
if (_lastKeyModifier == MD_CTRL) b = KBD_CTRL;
|
|
|
|
if (_lastKeyModifier == MD_ALT) b = KBD_ALT;
|
2003-05-12 12:14:13 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
if ((ev.data.keyDown.chr == 'z' && b == KBD_CTRL) || (b == KBD_ALT && ev.data.keyDown.chr == 'x')) {
|
2003-11-28 09:30:46 +00:00
|
|
|
event->event_code = EVENT_QUIT;
|
2003-07-07 08:45:20 +00:00
|
|
|
_selfQuit = true;
|
2003-05-28 18:42:16 +00:00
|
|
|
|
2003-05-19 11:02:59 +00:00
|
|
|
} else if (ev.data.keyDown.chr == 'n' && b == KBD_CTRL) {
|
|
|
|
UInt8 *scr = _screenP + _screenWidth * (_screenHeight + 2);
|
|
|
|
_useNumPad = !_useNumPad;
|
|
|
|
drawNumPad(this, _useNumPad ? gVars->indicator.on : 0);
|
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
event->event_code = EVENT_KEYDOWN;
|
|
|
|
event->kbd.keycode = ev.data.keyDown.chr;
|
2003-05-12 12:14:13 +00:00
|
|
|
event->kbd.ascii = (ev.data.keyDown.chr>='a' && ev.data.keyDown.chr<='z' && (event->kbd.flags & KBD_SHIFT) ? ev.data.keyDown.chr &~ 0x20 : ev.data.keyDown.chr);
|
2003-04-30 11:37:10 +00:00
|
|
|
event->kbd.flags = b;
|
2003-05-28 18:42:16 +00:00
|
|
|
_lastKeyModifier = MD_NONE;
|
|
|
|
drawKeyState(this, _lastKeyModifier);
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
case penMoveEvent:
|
2003-08-18 10:47:14 +00:00
|
|
|
getCoordinates(&ev, (_mode == GFX_WIDE), &x, &y);
|
2003-05-19 11:02:59 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
if ((y - _screenOffset.y) > _screenHeight || (y - _screenOffset.y) < 0 || (x - _screenOffset.x) > _screenWidth || (x - _screenOffset.x) < 0)
|
2003-04-30 11:37:10 +00:00
|
|
|
return true;
|
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
if (_lastEvent != penMoveEvent && (abs(y - event->mouse.y) <= 2 || abs(x - event->mouse.x) <= 2)) // move only if
|
2003-04-30 11:37:10 +00:00
|
|
|
return true;
|
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
_lastEvent = penMoveEvent;
|
2003-04-30 11:37:10 +00:00
|
|
|
event->event_code = EVENT_MOUSEMOVE;
|
2003-08-18 10:47:14 +00:00
|
|
|
event->mouse.x = x - _screenOffset.x;
|
|
|
|
event->mouse.y = y - _screenOffset.y;
|
2003-08-02 00:36:38 +00:00
|
|
|
set_mouse_pos(event->mouse.x, event->mouse.y);
|
2003-04-30 11:37:10 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
case penDownEvent:
|
2003-08-18 10:47:14 +00:00
|
|
|
getCoordinates(&ev, (_mode == GFX_WIDE), &x, &y);
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-05-19 11:02:59 +00:00
|
|
|
if (_useNumPad) {
|
2003-11-03 16:13:00 +00:00
|
|
|
Coord x2 = _screenOffset.x + (_screenWidth >> 1) - 20; // - 64 / 2 + 12
|
2003-08-18 10:47:14 +00:00
|
|
|
Coord y2 = _screenOffset.y + _screenHeight + 2;
|
2003-11-03 16:13:00 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
if (y >= y2 && y < (y2 + 34) && x >= x2 && x < (x2 + 64)) { // numpad location
|
2003-05-19 11:02:59 +00:00
|
|
|
UInt8 key = '1';
|
2003-11-03 16:13:00 +00:00
|
|
|
key += 9 - ( (3 - ((x - x2) / 13)) + (3 * ((y - y2) / 11)) );
|
2003-05-19 11:02:59 +00:00
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
_lastEvent = keyDownEvent;
|
|
|
|
_lastKeyPressed = -1;
|
2003-05-19 11:02:59 +00:00
|
|
|
|
|
|
|
event->event_code = EVENT_KEYDOWN;
|
|
|
|
event->kbd.keycode = key;
|
|
|
|
event->kbd.ascii = key;
|
|
|
|
event->kbd.flags = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
_lastEvent = penDownEvent;
|
2003-08-18 10:47:14 +00:00
|
|
|
if ((y - _screenOffset.y) > _screenHeight || (y - _screenOffset.y) < 0 || (x - _screenOffset.x) > _screenWidth || (x - _screenOffset.x) < 0)
|
2003-04-30 11:37:10 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
event->event_code = EVENT_LBUTTONDOWN;
|
2003-08-18 10:47:14 +00:00
|
|
|
event->mouse.x = x - _screenOffset.x;
|
|
|
|
event->mouse.y = y - _screenOffset.y;
|
2003-04-30 11:37:10 +00:00
|
|
|
set_mouse_pos(event->mouse.x, event->mouse.y);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case penUpEvent:
|
2003-08-18 10:47:14 +00:00
|
|
|
getCoordinates(&ev, (_mode == GFX_WIDE), &x, &y);
|
2003-04-30 11:37:10 +00:00
|
|
|
event->event_code = EVENT_LBUTTONUP;
|
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
if ((y - _screenOffset.y) > _screenHeight || (y - _screenOffset.y) < 0 || (x - _screenOffset.x) > _screenWidth || (x - _screenOffset.x) < 0)
|
2003-04-30 11:37:10 +00:00
|
|
|
return true;
|
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
event->mouse.x = x - _screenOffset.x;
|
|
|
|
event->mouse.y = y - _screenOffset.y;
|
2003-04-30 11:37:10 +00:00
|
|
|
set_mouse_pos(event->mouse.x, event->mouse.y);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
uint32 OSystem_PALMOS::property(int param, Property *value) {
|
|
|
|
switch(param) {
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
case PROP_SET_WINDOW_CAPTION:
|
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
Char *caption = "Loading, please wait\0";
|
|
|
|
Coord h = FntLineHeight() + 2;
|
|
|
|
Coord w, y;
|
|
|
|
|
|
|
|
// quick erase the screen
|
|
|
|
WinScreenLock(winLockErase);
|
|
|
|
WinScreenUnlock();
|
2003-05-06 08:24:21 +00:00
|
|
|
|
|
|
|
WinSetTextColor(255);
|
|
|
|
WinSetForeColor(255);
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
if (_useHRmode) {
|
2003-11-03 16:13:00 +00:00
|
|
|
y = 160 - (h >> 1) - 10;
|
2003-04-30 11:37:10 +00:00
|
|
|
HRFntSetFont(gVars->HRrefNum,hrTinyBoldFont);
|
2003-08-18 10:47:14 +00:00
|
|
|
w = FntCharsWidth(caption,StrLen(caption));
|
|
|
|
w = (320 - w) >> 1;
|
2003-09-23 16:01:52 +00:00
|
|
|
HRWinDrawChars(gVars->HRrefNum, caption, StrLen(caption), w, y + h);
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
HRFntSetFont(gVars->HRrefNum,hrTinyFont);
|
2003-08-18 10:47:14 +00:00
|
|
|
w = FntCharsWidth(value->caption, StrLen(value->caption));
|
|
|
|
w = (320 - w) >> 1;
|
|
|
|
HRWinDrawChars(gVars->HRrefNum, value->caption, StrLen(value->caption), w, y);
|
2003-04-30 11:37:10 +00:00
|
|
|
} else {
|
2003-09-23 16:01:52 +00:00
|
|
|
Err e;
|
|
|
|
BitmapTypeV3 *bmp2P;
|
|
|
|
BitmapType *bmp1P = BmpCreate(320, (h << 1), 8, NULL, &e);
|
|
|
|
WinHandle tmpH = WinCreateBitmapWindow(bmp1P, &e);
|
|
|
|
|
|
|
|
WinSetDrawWindow(tmpH);
|
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
FntSetFont(boldFont);
|
2003-11-03 16:13:00 +00:00
|
|
|
y = 80 - (h >> 2) - 5;
|
2003-08-18 10:47:14 +00:00
|
|
|
w = FntCharsWidth(caption, StrLen(caption));
|
2003-09-23 16:01:52 +00:00
|
|
|
w = (320 - w) >> 1;
|
|
|
|
WinDrawChars(caption, StrLen(caption), w, 0 + h);
|
|
|
|
|
|
|
|
FntSetFont(stdFont);
|
|
|
|
w = FntCharsWidth(value->caption, StrLen(value->caption));
|
|
|
|
w = (320 - w) >> 1;
|
|
|
|
WinDrawChars(value->caption, StrLen(value->caption), w, 0);
|
|
|
|
|
|
|
|
WinSetDrawWindow(WinGetDisplayWindow());
|
|
|
|
bmp2P = BmpCreateBitmapV3(bmp1P, kDensityDouble, BmpGetBits(bmp1P), NULL);
|
|
|
|
WinDrawBitmap((BitmapPtr)bmp2P, 0, y);
|
|
|
|
|
|
|
|
BmpDelete((BitmapPtr)bmp2P);
|
|
|
|
WinDeleteWindow(tmpH,0);
|
|
|
|
BmpDelete(bmp1P);
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case PROP_OPEN_CD:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_GET_SAMPLE_RATE:
|
2003-07-07 08:45:20 +00:00
|
|
|
return 8000;
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
void OSystem_PALMOS::quit() {
|
2003-11-28 09:30:46 +00:00
|
|
|
// There is no exit(.) function under PalmOS, to exit an app
|
|
|
|
// we need to send an 'exit' event to the event handler
|
|
|
|
// and then the system return to the launcher. But this event
|
|
|
|
// is not handled by the main loop and so we need to force exit.
|
|
|
|
// In other systems like Windows ScummVM exit immediatly and so this doesn't appear.
|
|
|
|
|
|
|
|
if (_quitCount)
|
2003-04-30 11:37:10 +00:00
|
|
|
return;
|
2003-05-06 08:24:21 +00:00
|
|
|
|
2003-11-03 16:13:00 +00:00
|
|
|
if (_selfQuit && Scumm::g_scumm)
|
|
|
|
Scumm::g_scumm->_quit = true;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-07-07 08:45:20 +00:00
|
|
|
free(_currentPalette);
|
|
|
|
free(_mouseBackupP);
|
|
|
|
// free(_sndDataP);
|
|
|
|
free(_sndTempP);
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
if (_cdPlayer) {
|
|
|
|
_cdPlayer->release();
|
|
|
|
_cdPlayer = NULL;
|
2003-07-23 20:17:07 +00:00
|
|
|
}
|
2003-06-08 09:18:21 +00:00
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
unload_gfx_mode();
|
2003-11-28 09:30:46 +00:00
|
|
|
_quitCount++;
|
2003-07-07 08:45:20 +00:00
|
|
|
exit(1);
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
void OSystem_PALMOS::draw_mouse() {
|
2003-11-28 09:30:46 +00:00
|
|
|
if (_mouseDrawn || !_mouseVisible || _quitCount)
|
2003-04-30 11:37:10 +00:00
|
|
|
return;
|
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
_mouseCurState.y = _mouseCurState.y >= _screenHeight ? _screenHeight - 1 : _mouseCurState.y;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
int x = _mouseCurState.x - _mouseHotspotX;
|
|
|
|
int y = _mouseCurState.y - _mouseHotspotY;
|
|
|
|
int w = _mouseCurState.w;
|
|
|
|
int h = _mouseCurState.h;
|
2003-04-30 11:37:10 +00:00
|
|
|
byte color;
|
2003-05-06 08:24:21 +00:00
|
|
|
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
|
2003-08-18 10:47:14 +00:00
|
|
|
int width;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
// clip the mouse rect, and addjust the src pointer accordingly
|
|
|
|
if (x < 0) {
|
|
|
|
w += x;
|
|
|
|
src -= x;
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
if (y < 0) {
|
|
|
|
h += y;
|
2003-05-06 08:24:21 +00:00
|
|
|
src -= y * _mouseCurState.w;
|
2003-04-30 11:37:10 +00:00
|
|
|
y = 0;
|
|
|
|
}
|
2003-05-06 08:24:21 +00:00
|
|
|
if (w > _screenWidth - x)
|
|
|
|
w = _screenWidth - x;
|
|
|
|
if (h > _screenHeight - y)
|
|
|
|
h = _screenHeight - y;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
// Quick check to see if anything has to be drawn at all
|
|
|
|
if (w <= 0 || h <= 0)
|
|
|
|
return;
|
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
// 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;
|
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
// Draw the mouse cursor; backup the covered area in "bak"
|
2003-08-18 10:47:14 +00:00
|
|
|
if (!_overlayVisible) {
|
|
|
|
dst = _offScreenP + y * _offScreenPitch + x;
|
|
|
|
|
|
|
|
while (h > 0) {
|
|
|
|
width = w;
|
|
|
|
while (width > 0) {
|
|
|
|
*bak++ = *dst;
|
|
|
|
color = *src++;
|
|
|
|
if (color != 0xFF) // 0xFF = transparent, don't draw
|
|
|
|
*dst = color;
|
|
|
|
dst++;
|
|
|
|
width--;
|
|
|
|
}
|
|
|
|
src += _mouseCurState.w - w;
|
|
|
|
bak += MAX_MOUSE_W - w;
|
|
|
|
dst += _offScreenPitch - w;
|
|
|
|
h--;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (MemPtrDataStorage(_tmpScreenP)) {
|
|
|
|
int offset = y * _screenWidth + x;
|
|
|
|
dst = _tmpScreenP;
|
|
|
|
|
|
|
|
while (h > 0) {
|
|
|
|
width = w;
|
|
|
|
while (width > 0) {
|
|
|
|
*bak++ = *(dst + offset);
|
|
|
|
color = *src++;
|
|
|
|
if (color != 0xFF)
|
|
|
|
DmWrite(dst, offset, &color, 1);
|
|
|
|
offset++;
|
|
|
|
width--;
|
|
|
|
}
|
|
|
|
src += _mouseCurState.w - w;
|
|
|
|
bak += MAX_MOUSE_W - w;
|
|
|
|
offset += _screenWidth - w;
|
|
|
|
h--;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dst = _tmpScreenP + y * _screenWidth + x;
|
|
|
|
|
|
|
|
while (h > 0) {
|
|
|
|
width = w;
|
|
|
|
while (width > 0) {
|
|
|
|
*bak++ = *dst;
|
|
|
|
color = *src++;
|
|
|
|
if (color != 0xFF)
|
|
|
|
*dst = color;
|
|
|
|
dst++;
|
|
|
|
width--;
|
|
|
|
}
|
|
|
|
src += _mouseCurState.w - w;
|
|
|
|
bak += MAX_MOUSE_W - w;
|
|
|
|
dst += _screenWidth - w;
|
|
|
|
h--;
|
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finally, set the flag to indicate the mouse has been drawn
|
2003-05-06 08:24:21 +00:00
|
|
|
_mouseDrawn = true;
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
void OSystem_PALMOS::undraw_mouse() {
|
2003-11-28 09:30:46 +00:00
|
|
|
if (!_mouseDrawn || _quitCount)
|
2003-04-30 11:37:10 +00:00
|
|
|
return;
|
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
_mouseDrawn = false;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
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;
|
2003-08-18 10:47:14 +00:00
|
|
|
int old_mouse_h = _mouseOldState.h;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
// No need to do clipping here, since draw_mouse() did that already
|
2003-08-18 10:47:14 +00:00
|
|
|
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 {
|
|
|
|
if (MemPtrDataStorage(_tmpScreenP)) {
|
|
|
|
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);
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
} else {
|
|
|
|
dst = _tmpScreenP + old_mouse_y * _screenWidth + old_mouse_x;
|
|
|
|
do {
|
|
|
|
memcpy(dst, bak, old_mouse_w);
|
|
|
|
bak += MAX_MOUSE_W;
|
|
|
|
dst += _screenWidth;
|
|
|
|
} while (--old_mouse_h);
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
void OSystem_PALMOS::stop_cdrom() {
|
|
|
|
if (!_cdPlayer)
|
|
|
|
return;
|
2003-06-08 09:18:21 +00:00
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
_cdPlayer->stop();
|
2003-07-07 08:45:20 +00:00
|
|
|
}
|
|
|
|
|
2003-07-22 20:36:43 +00:00
|
|
|
void OSystem_PALMOS::play_cdrom(int track, int num_loops, int start_frame, int duration) {
|
2003-09-23 16:01:52 +00:00
|
|
|
if (!_cdPlayer)
|
2003-06-08 09:18:21 +00:00
|
|
|
return;
|
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
_cdPlayer->play(track, num_loops, start_frame, duration);
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
bool OSystem_PALMOS::poll_cdrom() {
|
2003-09-23 16:01:52 +00:00
|
|
|
if (!_cdPlayer)
|
2003-06-08 09:18:21 +00:00
|
|
|
return false;
|
2003-09-23 16:01:52 +00:00
|
|
|
|
|
|
|
return _cdPlayer->poll();
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
void OSystem_PALMOS::update_cdrom() {
|
2003-09-23 16:01:52 +00:00
|
|
|
if (!_cdPlayer)
|
2003-08-18 10:47:14 +00:00
|
|
|
return;
|
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
_cdPlayer->update();
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
|
2003-05-02 15:30:06 +00:00
|
|
|
OSystem_PALMOS::OSystem_PALMOS() {
|
2003-11-28 09:30:46 +00:00
|
|
|
_quitCount = 0;
|
2003-07-07 08:45:20 +00:00
|
|
|
_selfQuit = false; // prevent illegal access to g_scumm
|
2003-04-30 11:37:10 +00:00
|
|
|
_current_shake_pos = 0;
|
|
|
|
_new_shake_pos = 0;
|
|
|
|
|
|
|
|
_paletteDirtyStart = 0;
|
|
|
|
_paletteDirtyEnd = 0;
|
|
|
|
|
2003-07-13 11:03:33 +00:00
|
|
|
memset(&_sound, 0, sizeof(SoundDataType));
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
_currentPalette = NULL;
|
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
_lastKeyPressed = -1;
|
|
|
|
_lastKeyRepeat = 100;
|
|
|
|
_lastKeyModifier = MD_NONE;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-05-19 11:02:59 +00:00
|
|
|
_useNumPad = false;
|
2003-08-18 10:47:14 +00:00
|
|
|
|
|
|
|
// mouse
|
|
|
|
memset(&_mouseOldState,0,sizeof(MousePos));
|
|
|
|
memset(&_mouseCurState,0,sizeof(MousePos));
|
|
|
|
_mouseDrawn = false;
|
|
|
|
_mouseBackupP = NULL;
|
2003-09-23 16:01:52 +00:00
|
|
|
_mouseVisible = false;
|
2003-05-19 11:02:59 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
// overlay
|
|
|
|
_tmpScreenP = NULL;
|
|
|
|
_tmpBackupP = NULL;
|
|
|
|
|
|
|
|
// HiRes
|
2003-05-28 18:42:16 +00:00
|
|
|
_useHRmode = (gVars->HRrefNum != sysInvalidRefNum);
|
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
// enable cdrom ?
|
|
|
|
// TODO : defaultTrackLength player
|
|
|
|
_cdPlayer = NULL;
|
|
|
|
if (gVars->music.MP3) {
|
|
|
|
_cdPlayer = new MsaCDPlayer(this);
|
|
|
|
// _cdPlayer = new ZodiacCDPlayer(this);
|
|
|
|
_cdPlayer->init();
|
|
|
|
|
|
|
|
// TODO : use setDefaultTrackLength
|
|
|
|
// _isCDRomAvalaible = _cdPlayer->init();
|
|
|
|
// if (!_isCDRomAvalaible)
|
|
|
|
// _cdPlayer->release();
|
|
|
|
}
|
2003-06-08 09:18:21 +00:00
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
// sound
|
|
|
|
_isSndPlaying = false;
|
2003-11-28 09:30:46 +00:00
|
|
|
_sndTempP = (UInt8 *)calloc(SND_BLOCK,1);
|
2003-05-28 18:42:16 +00:00
|
|
|
_sndDataP = NULL;
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-05-02 15:30:06 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
void OSystem_PALMOS::move_screen(int dx, int dy, int height) {
|
2003-05-28 18:42:16 +00:00
|
|
|
// Short circuit check - do we have to do anything anyway?
|
|
|
|
if ((dx == 0 && dy == 0) || height <= 0)
|
2003-04-30 11:37:10 +00:00
|
|
|
return;
|
|
|
|
|
2003-05-28 18:42:16 +00:00
|
|
|
// Hide the mouse
|
|
|
|
if (_mouseDrawn)
|
|
|
|
undraw_mouse();
|
|
|
|
|
|
|
|
RectangleType r, dummy;
|
|
|
|
WinSetDrawWindow(_offScreenH);
|
2003-09-23 16:01:52 +00:00
|
|
|
RctSetRectangle(&r, ((_offScreenH != _screenH) ? 0 : _screenOffset.x), ((_offScreenH != _screenH) ? 0 : _screenOffset.y), _screenWidth, _screenHeight);
|
|
|
|
// FIXME : use this only if the Hi-Density feature is present ?
|
|
|
|
if (!_useHRmode) WinSetCoordinateSystem(kCoordinatesNative);
|
2003-05-28 18:42:16 +00:00
|
|
|
|
|
|
|
// vertical movement
|
|
|
|
if (dy > 0) {
|
|
|
|
// move down - copy from bottom to top
|
|
|
|
if (_useHRmode) {
|
|
|
|
// need to set the draw window
|
|
|
|
HRWinScrollRectangle(gVars->HRrefNum, &r, winDown, dy, &dummy);
|
2003-04-30 11:37:10 +00:00
|
|
|
} else {
|
2003-09-23 16:01:52 +00:00
|
|
|
WinScrollRectangle(&r, winDown, dy, &dummy);
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-05-28 18:42:16 +00:00
|
|
|
} else if (dy < 0) {
|
|
|
|
// move up - copy from top to bottom
|
|
|
|
dy = -dy;
|
|
|
|
if (_useHRmode) {
|
|
|
|
// need to set the draw window
|
|
|
|
HRWinScrollRectangle(gVars->HRrefNum, &r, winUp, dy, &dummy);
|
2003-04-30 11:37:10 +00:00
|
|
|
} else {
|
2003-09-23 16:01:52 +00:00
|
|
|
WinScrollRectangle(&r, winUp, dy, &dummy);
|
2003-05-28 18:42:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// horizontal movement
|
|
|
|
if (dx > 0) {
|
|
|
|
// move right - copy from right to left
|
|
|
|
if (_useHRmode) {
|
|
|
|
// need to set the draw window
|
|
|
|
HRWinScrollRectangle(gVars->HRrefNum, &r, winRight, dx, &dummy);
|
|
|
|
} else {
|
2003-09-23 16:01:52 +00:00
|
|
|
WinScrollRectangle(&r, winRight, dx, &dummy);
|
2003-05-28 18:42:16 +00:00
|
|
|
}
|
|
|
|
} else if (dx < 0) {
|
|
|
|
// move left - copy from left to right
|
|
|
|
dx = -dx;
|
|
|
|
if (_useHRmode) {
|
|
|
|
// need to set the draw window
|
|
|
|
HRWinScrollRectangle(gVars->HRrefNum, &r, winLeft, dx, &dummy);
|
|
|
|
} else {
|
2003-09-23 16:01:52 +00:00
|
|
|
WinScrollRectangle(&r, winLeft, dx, &dummy);
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-23 16:01:52 +00:00
|
|
|
|
|
|
|
// FIXME : use this only if the Hi-Density feature is present ?
|
|
|
|
if (!_useHRmode) WinSetCoordinateSystem(kCoordinatesStandard);
|
2003-05-28 18:42:16 +00:00
|
|
|
WinSetDrawWindow(_screenH);
|
2003-09-23 16:01:52 +00:00
|
|
|
// Prevent crash on Clie device using successive [HR]WinScrollRectangle !
|
|
|
|
SysTaskDelay(1);
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
2003-11-28 09:30:46 +00:00
|
|
|
/*
|
|
|
|
typedef struct {
|
|
|
|
bool played;
|
|
|
|
void *data;
|
|
|
|
UInt8 count;
|
|
|
|
} CallbackDataType;
|
|
|
|
|
|
|
|
CallbackDataType mycallback = {true, NULL, 0};
|
|
|
|
|
|
|
|
static Err sndCallback(void* UserDataP, SndStreamRef stream, void* bufferP, UInt32 frameCount) {
|
|
|
|
// SoundDataType *snd = (SoundDataType *)UserDataP;
|
|
|
|
// snd->proc(snd->param, (UInt8 *)bufferP, frameCount);
|
|
|
|
|
|
|
|
CallbackDataType *ptr = (CallbackDataType *)UserDataP;
|
|
|
|
MemSet(bufferP,frameCount,0);
|
|
|
|
|
|
|
|
if (!ptr->played) {
|
|
|
|
MemMove(bufferP, ptr->data, SND_BLOCK * 3);
|
|
|
|
ptr->played = true;
|
|
|
|
} else {
|
|
|
|
MemSet(bufferP,SND_BLOCK,0);
|
|
|
|
}
|
|
|
|
return errNone;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
//FILE *mf = NULL;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-09-27 16:54:11 +00:00
|
|
|
bool OSystem_PALMOS::set_sound_proc(SoundProc proc, void *param, SoundFormat format) {
|
2003-04-30 11:37:10 +00:00
|
|
|
_sound.active = true;
|
|
|
|
_sound.proc = proc;
|
|
|
|
_sound.param = param;
|
2003-06-08 09:18:21 +00:00
|
|
|
_sound.format = format;
|
2003-11-28 09:30:46 +00:00
|
|
|
/*
|
|
|
|
mycallback.data = _sndTempP;
|
|
|
|
|
|
|
|
Err e;
|
|
|
|
//_sound.active = false;
|
|
|
|
e = SndStreamCreate(&_sound.sndRefNum, sndOutput, 8000, sndInt16Big, sndStereo, sndCallback, &mycallback, SND_BLOCK *3, false);
|
|
|
|
e = SndStreamStart(_sound.sndRefNum);
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-11-28 09:30:46 +00:00
|
|
|
//mf = fopen("/PALM/Programs/ScummVM/dump.wav","wb");
|
|
|
|
*/
|
2003-05-28 18:42:16 +00:00
|
|
|
return _sound.active;
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
|
2003-06-09 09:48:53 +00:00
|
|
|
void OSystem_PALMOS::clear_sound_proc() {
|
2003-11-28 09:30:46 +00:00
|
|
|
/* SndStreamStop(_sound.sndRefNum);
|
|
|
|
SndStreamDelete(_sound.sndRefNum);
|
|
|
|
*/
|
|
|
|
//fclose(mf);
|
|
|
|
|
2003-06-09 09:48:53 +00:00
|
|
|
_sound.active = false;
|
|
|
|
}
|
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
void OSystem_PALMOS::check_sound() {
|
2003-05-02 15:30:06 +00:00
|
|
|
// currently not supported
|
2003-05-12 12:14:13 +00:00
|
|
|
// but i need to use this function to prevent out of memory
|
2003-09-23 16:01:52 +00:00
|
|
|
// on games because the sound buffer growns and it's never
|
2003-05-12 12:14:13 +00:00
|
|
|
// freed.
|
2003-11-28 09:30:46 +00:00
|
|
|
// if (mycallback.played) {
|
|
|
|
_sound.proc(_sound.param, _sndTempP, SND_BLOCK);
|
|
|
|
/*
|
|
|
|
if (mycallback.count == 3) {
|
|
|
|
mycallback.played = false;
|
|
|
|
mycallback.count = 0;
|
|
|
|
}
|
|
|
|
//if (mf)
|
|
|
|
// fwrite(_sndTempP, SND_BLOCK, 1, mf);
|
|
|
|
}*/
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
void OSystem_PALMOS::show_overlay() {
|
2003-04-30 11:37:10 +00:00
|
|
|
// hide the mouse
|
|
|
|
undraw_mouse();
|
2003-08-18 10:47:14 +00:00
|
|
|
// save background
|
|
|
|
byte *src = _offScreenP;
|
|
|
|
byte *dst = _tmpBackupP;
|
|
|
|
int h = _screenHeight;
|
|
|
|
|
|
|
|
if (MemPtrDataStorage(_tmpScreenP)) {
|
|
|
|
UInt32 offset = 0;
|
|
|
|
do {
|
|
|
|
DmWrite(dst, offset, src, _screenWidth);
|
|
|
|
offset += _screenWidth;
|
|
|
|
src += _offScreenPitch;
|
|
|
|
} while (--h);
|
|
|
|
} else {
|
|
|
|
do {
|
|
|
|
memcpy(dst, src, _screenWidth);
|
|
|
|
dst += _screenWidth;
|
|
|
|
src += _offScreenPitch;
|
|
|
|
} while (--h);
|
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
_overlayVisible = true;
|
2003-04-30 11:37:10 +00:00
|
|
|
clear_overlay();
|
|
|
|
}
|
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
void OSystem_PALMOS::hide_overlay() {
|
2003-04-30 11:37:10 +00:00
|
|
|
// hide the mouse
|
|
|
|
undraw_mouse();
|
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
_overlayVisible = false;
|
|
|
|
copy_rect(_tmpBackupP, _screenWidth, 0, 0, _screenWidth, _screenHeight);
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
void OSystem_PALMOS::clear_overlay() {
|
2003-08-18 10:47:14 +00:00
|
|
|
if (!_overlayVisible)
|
2003-04-30 11:37:10 +00:00
|
|
|
return;
|
2003-08-18 10:47:14 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
// hide the mouse
|
|
|
|
undraw_mouse();
|
2003-08-18 10:47:14 +00:00
|
|
|
// restore background
|
|
|
|
if (MemPtrDataStorage(_tmpScreenP))
|
|
|
|
DmWrite(_tmpScreenP, 0, _tmpBackupP, _screenWidth * _screenHeight);
|
|
|
|
else
|
|
|
|
MemMove(_tmpScreenP, _tmpBackupP, _screenWidth * _screenHeight);
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
void OSystem_PALMOS::grab_overlay(byte *buf, int pitch) {
|
2003-08-18 10:47:14 +00:00
|
|
|
if (!_overlayVisible)
|
2003-04-30 11:37:10 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// hide the mouse
|
|
|
|
undraw_mouse();
|
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
byte *src = _tmpScreenP;
|
|
|
|
int h = _screenHeight;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
|
|
|
do {
|
2003-05-06 08:24:21 +00:00
|
|
|
memcpy(buf, src, _screenWidth);
|
|
|
|
src += _screenWidth;
|
2003-04-30 11:37:10 +00:00
|
|
|
buf += pitch;
|
|
|
|
} while (--h);
|
|
|
|
}
|
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
void OSystem_PALMOS::copy_rect_overlay(const byte *buf, int pitch, int x, int y, int w, int h) {
|
2003-08-18 10:47:14 +00:00
|
|
|
if (!_overlayVisible)
|
2003-04-30 11:37:10 +00:00
|
|
|
return;
|
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
if (!_tmpScreenP)
|
|
|
|
return;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
// Clip the coordinates
|
|
|
|
if (x < 0) {
|
|
|
|
w += x;
|
|
|
|
buf -= x;
|
|
|
|
x = 0;
|
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-08-18 10:47:14 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
undraw_mouse();
|
|
|
|
|
|
|
|
if (MemPtrDataStorage(_tmpScreenP)) {
|
|
|
|
byte *dst = _tmpScreenP;
|
|
|
|
int offset = y * _screenWidth + x;
|
|
|
|
do {
|
|
|
|
DmWrite(dst, offset, buf, w);
|
|
|
|
offset += _screenWidth;
|
|
|
|
buf += pitch;
|
|
|
|
} while (--h);
|
|
|
|
} else {
|
|
|
|
byte *dst = _tmpScreenP + y * _screenWidth + x;
|
|
|
|
do {
|
|
|
|
memcpy(dst, buf, w);
|
|
|
|
dst += _screenWidth;
|
|
|
|
buf += pitch;
|
|
|
|
} while (--h);
|
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int16 OSystem_PALMOS::get_height() {
|
2003-05-06 08:24:21 +00:00
|
|
|
return _screenHeight;
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int16 OSystem_PALMOS::get_width() {
|
2003-05-06 08:24:21 +00:00
|
|
|
return _screenWidth;
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
byte OSystem_PALMOS::RGBToColor(uint8 r, uint8 g, uint8 b) {
|
2003-09-23 16:01:52 +00:00
|
|
|
byte color;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
if (gVars->stdPalette) {
|
|
|
|
RGBColorType rgb = {0, r, g, b};
|
|
|
|
color = WinRGBToIndex(&rgb);
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
} else {
|
|
|
|
byte nearest = 255;
|
|
|
|
byte check;
|
|
|
|
byte r2, g2, b2;
|
|
|
|
|
|
|
|
color = 255;
|
2003-04-30 11:37:10 +00:00
|
|
|
|
2003-09-23 16:01:52 +00:00
|
|
|
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;
|
|
|
|
}
|
2003-04-30 11:37:10 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-23 16:01:52 +00:00
|
|
|
|
2003-04-30 11:37:10 +00:00
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
2003-05-06 08:24:21 +00:00
|
|
|
void OSystem_PALMOS::ColorToRGB(byte color, uint8 &r, uint8 &g, uint8 &b) {
|
2003-04-30 11:37:10 +00:00
|
|
|
r = _currentPalette[color].r;
|
|
|
|
g = _currentPalette[color].g;
|
|
|
|
b = _currentPalette[color].b;
|
2003-09-23 16:01:52 +00:00
|
|
|
}
|