2005-10-08 22:18:29 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2001-2006 The ScummVM project
|
2006-02-11 09:26:04 +00:00
|
|
|
* Copyright (C) 2002-2006 Chris Apers - PalmOS Backend
|
2005-10-08 22:18:29 +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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-10-08 22:18:29 +00:00
|
|
|
*
|
2006-02-11 09:26:04 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2005-10-08 22:18:29 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "be_base.h"
|
|
|
|
#include "common/config-file.h"
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
|
2006-10-28 14:30:42 +00:00
|
|
|
#include "backends/saves/default/default-saves.h"
|
|
|
|
#include "backends/timer/default/default-timer.h"
|
|
|
|
#include "sound/mixer.h"
|
|
|
|
|
2005-11-05 10:15:41 +00:00
|
|
|
OSystem_PalmBase::OSystem_PalmBase() {
|
2005-10-08 22:18:29 +00:00
|
|
|
_overlayVisible = false;
|
|
|
|
|
|
|
|
_current_shake_pos = 0;
|
|
|
|
_new_shake_pos = 0;
|
|
|
|
|
|
|
|
_paletteDirtyStart = 0;
|
|
|
|
_paletteDirtyEnd = 0;
|
|
|
|
|
|
|
|
_gfxLoaded = false;
|
|
|
|
_modeChanged = false;
|
|
|
|
_setMode = GFX_NORMAL;
|
|
|
|
_mode = _setMode;
|
|
|
|
_redawOSD = false;
|
2006-02-11 09:26:04 +00:00
|
|
|
_setPalette = true;
|
2005-10-08 22:18:29 +00:00
|
|
|
|
|
|
|
_offScreenH = NULL;
|
|
|
|
_screenH = NULL;
|
|
|
|
_offScreenP = NULL;
|
|
|
|
_screenP = NULL;
|
|
|
|
_screenPitch = gVars->screenPitch;
|
|
|
|
|
|
|
|
_lastEvent = nilEvent;
|
|
|
|
_lastKey = kKeyNone;
|
|
|
|
_lastKeyModifier = kModifierNone;
|
|
|
|
_lastKeyRepeat = 100;
|
|
|
|
_useNumPad = false;
|
2005-10-12 20:24:30 +00:00
|
|
|
_showBatLow = false;
|
|
|
|
_batCheckTicks = SysTicksPerSecond() * 15;
|
|
|
|
_batCheckLast = TimGetTicks();
|
2005-10-08 22:18:29 +00:00
|
|
|
|
2006-10-28 14:30:42 +00:00
|
|
|
_saveMgr = 0;
|
|
|
|
_timerMgr = 0;
|
|
|
|
_mixerMgr = 0;
|
|
|
|
|
2005-10-08 22:18:29 +00:00
|
|
|
_mouseDataP = NULL;
|
|
|
|
_mouseVisible = false;
|
|
|
|
_mouseDrawn = false;
|
|
|
|
MemSet(&_keyMouse, sizeof(_keyMouse), 0);
|
|
|
|
MemSet(&_mouseCurState, sizeof(_mouseCurState), 0);
|
|
|
|
MemSet(&_mouseOldState, sizeof(_mouseOldState), 0);
|
2005-12-11 19:49:22 +00:00
|
|
|
MemSet(&_timer, sizeof(TimerType), 0);
|
2006-02-11 09:26:04 +00:00
|
|
|
MemSet(&_sound, sizeof(SoundType), 0);
|
2006-06-05 19:17:30 +00:00
|
|
|
|
|
|
|
_keyMouseRepeat = 0;
|
|
|
|
_keyMouseDelay = (gVars->arrowKeys) ? computeMsecs(125) : computeMsecs(25);
|
2005-11-05 10:15:41 +00:00
|
|
|
}
|
|
|
|
|
2006-10-28 14:30:42 +00:00
|
|
|
static int timer_handler(int t) {
|
|
|
|
DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager();
|
|
|
|
tm->handler();
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2005-12-11 19:49:22 +00:00
|
|
|
void OSystem_PalmBase::initBackend() {
|
|
|
|
if (gVars->autoSave != -1)
|
2006-06-03 11:14:12 +00:00
|
|
|
ConfMan.setInt("autosave_period", gVars->autoSave);
|
2005-12-11 19:49:22 +00:00
|
|
|
|
|
|
|
_keyMouse.bitUp = keyBitPageUp;
|
|
|
|
_keyMouse.bitDown = keyBitPageDown;
|
|
|
|
_keyMouse.bitLeft = keyBitHard1;
|
|
|
|
_keyMouse.bitRight = keyBitHard2;
|
|
|
|
_keyMouse.bitButLeft= keyBitHard3;
|
|
|
|
_keyMouse.hasMore = false;
|
|
|
|
|
2005-10-08 22:18:29 +00:00
|
|
|
int_initBackend();
|
|
|
|
_keyMouseMask = (_keyMouse.bitUp | _keyMouse.bitDown | _keyMouse.bitLeft | _keyMouse.bitRight | _keyMouse.bitButLeft);
|
2006-10-22 15:42:29 +00:00
|
|
|
|
2006-10-28 14:30:42 +00:00
|
|
|
// Create the savefile manager, if none exists yet (we check for this to
|
|
|
|
// allow subclasses to provide their own).
|
|
|
|
if (_saveMgr == 0) {
|
|
|
|
_saveMgr = new DefaultSaveFileManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create and hook up the mixer, if none exists yet (we check for this to
|
|
|
|
// allow subclasses to provide their own).
|
|
|
|
if (_mixerMgr == 0) {
|
|
|
|
_mixerMgr = new Audio::Mixer();
|
|
|
|
setSoundCallback(Audio::Mixer::mixCallback, _mixerMgr);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create and hook up the timer manager, if none exists yet (we check for
|
|
|
|
// this to allow subclasses to provide their own).
|
|
|
|
if (_timerMgr == 0) {
|
|
|
|
_timerMgr = new DefaultTimerManager();
|
|
|
|
setTimerCallback(::timer_handler, 10);
|
|
|
|
}
|
|
|
|
|
2006-10-22 15:42:29 +00:00
|
|
|
OSystem::initBackend();
|
2005-10-08 22:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32 OSystem_PalmBase::getMillis() {
|
|
|
|
return TimGetTicks() * 1000 / SysTicksPerSecond();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_PalmBase::delayMillis(uint msecs) {
|
2006-06-05 19:17:30 +00:00
|
|
|
Int32 delay = computeMsecs(msecs);
|
2005-10-08 22:18:29 +00:00
|
|
|
|
|
|
|
if (delay > 0)
|
|
|
|
SysTaskDelay(delay);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_PalmBase::setTimerCallback(TimerProc callback, int timer) {
|
|
|
|
if (callback != NULL) {
|
|
|
|
_timer.duration = timer;
|
|
|
|
_timer.nextExpiry = getMillis() + timer;
|
|
|
|
_timer.callback = callback;
|
2005-12-11 19:49:22 +00:00
|
|
|
_timer.active = true;
|
2005-10-08 22:18:29 +00:00
|
|
|
} else {
|
|
|
|
_timer.active = false;
|
|
|
|
}
|
|
|
|
}
|
2006-02-11 09:26:04 +00:00
|
|
|
|
|
|
|
void OSystem_PalmBase::quit() {
|
|
|
|
int_quit();
|
|
|
|
clearSoundCallback();
|
|
|
|
unload_gfx_mode();
|
2006-10-28 14:30:42 +00:00
|
|
|
|
|
|
|
delete _saveMgr;
|
|
|
|
delete _timerMgr;
|
|
|
|
delete _mixerMgr;
|
|
|
|
|
2006-02-11 09:26:04 +00:00
|
|
|
exit(0);
|
|
|
|
}
|
2006-10-28 14:30:42 +00:00
|
|
|
|
|
|
|
Common::SaveFileManager *OSystem_PalmBase::getSavefileManager() {
|
|
|
|
return _saveMgr;
|
|
|
|
}
|
|
|
|
|
|
|
|
Audio::Mixer * OSystem_PalmBase::getMixer() {
|
|
|
|
return _mixerMgr;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::TimerManager * OSystem_PalmBase::getTimerManager() {
|
|
|
|
return _timerMgr;
|
|
|
|
}
|