1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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.
*
* $URL$
* $Id$
*
*/
#include "be_base.h"
#include "common/config-file.h"
#include "common/config-manager.h"
#include "backends/saves/default/default-saves.h"
#include "backends/timer/default/default-timer.h"
#include "backends/fs/palmos/palmos-fs-factory.h"
#include "sound/mixer_intern.h"
#define DEFAULT_SAVE_PATH "/PALM/Programs/ScummVM/Saved/"
OSystem_PalmBase::OSystem_PalmBase() {
_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;
_setPalette = true;
_offScreenH = NULL;
_screenH = NULL;
_offScreenP = NULL;
_screenP = NULL;
_screenPitch = gVars->screenPitch;
_wasKey = false;
_lastKeyModifier = kModifierNone;
_lastKeyRepeat = 100;
_useNumPad = false;
_showBatLow = false;
_batCheckTicks = SysTicksPerSecond() * 15;
_batCheckLast = TimGetTicks();
_saveMgr = 0;
_timerMgr = 0;
_mixerMgr = 0;
_mouseDataP = NULL;
_mouseBackupP = NULL;
_mouseVisible = false;
_mouseDrawn = false;
MemSet(&_keyExtra, sizeof(_keyExtra), 0);
MemSet(&_mouseCurState, sizeof(_mouseCurState), 0);
MemSet(&_mouseOldState, sizeof(_mouseOldState), 0);
MemSet(&_timer, sizeof(TimerType), 0);
MemSet(&_sound, sizeof(SoundType), 0);
_keyExtraRepeat = 0;
_keyExtraPressed = 0;
_keyExtraDelay = (gVars->arrowKeys) ? computeMsecs(125) : computeMsecs(25);
}
static int timer_handler(int t) {
DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager();
tm->handler();
return t;
}
void OSystem_PalmBase::initBackend() {
if (gVars->autoSave != -1)
ConfMan.setInt("autosave_period", gVars->autoSave);
_keyExtra.bitUp = keyBitPageUp;
_keyExtra.bitDown = keyBitPageDown;
_keyExtra.bitLeft = keyBitHard2;
_keyExtra.bitRight = keyBitHard3;
int_initBackend();
_keyExtraMask = (_keyExtra.bitUp | _keyExtra.bitDown | _keyExtra.bitLeft | _keyExtra.bitRight | _keyExtra.bitActionA | _keyExtra.bitActionB);
// 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(DEFAULT_SAVE_PATH);
}
// Create and hook up the mixer, if none exists yet (we check for this to
// allow subclasses to provide their own).
if (_mixerMgr == 0) {
setupMixer();
}
// 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);
}
OSystem::initBackend();
}
void OSystem_PalmBase::getTimeAndDate(TimeDate &td) const {
time_t curTime = time(0);
struct tm t = *localtime(&curTime);
td.tm_sec = t.tm_sec;
td.tm_min = t.tm_min;
td.tm_hour = t.tm_hour;
td.tm_mday = t.tm_mday;
td.tm_mon = t.tm_mon;
td.tm_year = t.tm_year;
}
uint32 OSystem_PalmBase::getMillis() {
return TimGetTicks() * 1000 / SysTicksPerSecond();
}
void OSystem_PalmBase::delayMillis(uint msecs) {
Int32 delay = computeMsecs(msecs);
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;
_timer.active = true;
} else {
_timer.active = false;
}
}
void OSystem_PalmBase::quit() {
int_quit();
clearSoundCallback();
unload_gfx_mode();
if (_mouseDataP) {
MemPtrFree(_mouseBackupP);
MemPtrFree(_mouseDataP);
}
delete _saveMgr;
delete _timerMgr;
delete _mixerMgr;
exit(0);
}
Common::SaveFileManager *OSystem_PalmBase::getSavefileManager() {
return _saveMgr;
}
Audio::Mixer *OSystem_PalmBase::getMixer() {
return _mixerMgr;
}
Common::TimerManager *OSystem_PalmBase::getTimerManager() {
return _timerMgr;
}
FilesystemFactory *OSystem_PalmBase::getFilesystemFactory() {
return &PalmOSFilesystemFactory::instance();
}
#define PALMOS_CONFIG_FILE "/PALM/Programs/ScummVM/scummvm.ini"
Common::SeekableReadStream *OSystem_PalmBase::createConfigReadStream() {
Common::FSNode file(PALMOS_CONFIG_FILE);
return file.createReadStream();
}
Common::WriteStream *OSystem_PalmBase::createConfigWriteStream() {
Common::FSNode file(PALMOS_CONFIG_FILE);
return file.createWriteStream();
}
|