PalmOS changes

svn-id: r7224
This commit is contained in:
Max Horn 2003-04-30 13:23:31 +00:00
parent 30e3a81618
commit 2b74abd2c9
11 changed files with 422 additions and 48 deletions

View File

@ -377,6 +377,9 @@ void SaveLoadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
_scumm->optionsDialog();
break;
case kQuitCmd:
#ifdef __PALM_OS__
close();
#endif
_scumm->_system->quit();
break;
default:
@ -398,6 +401,7 @@ void SaveLoadDialog::fillList() {
char name[32];
uint i = _saveMode ? 1 : 0;
bool avail_saves[81];
SaveFileManager *mgr = _scumm->_system->get_savefile_manager();
_scumm->listSavegames(avail_saves, ARRAYSIZE(avail_saves), mgr);

View File

@ -82,7 +82,9 @@ struct TransitionEffect {
int8 deltaTable[16]; // four times l / t / r / b
byte stripTable[16]; // ditto
};
#ifdef __PALM_OS__
static const TransitionEffect *transitionEffects;
#else
static const TransitionEffect transitionEffects[4] = {
// Iris effect (looks like an opening/closing camera iris)
{
@ -153,7 +155,7 @@ static const TransitionEffect transitionEffects[4] = {
}
}
};
#endif
/*
* Mouse cursor cycle colors (for the default crosshair).
@ -162,7 +164,7 @@ static const byte default_cursor_colors[4] = {
15, 15, 7, 8
};
static const uint16 default_cursor_images[4][16] = {
static const uint16 default_cursor_images[5][16] = {
/* cross-hair */
{ 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0000, 0x7e3f,
0x0000, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0000 },
@ -175,10 +177,18 @@ static const uint16 default_cursor_images[4][16] = {
/* hand */
{ 0x1e00, 0x1200, 0x1200, 0x1200, 0x1200, 0x13ff, 0x1249, 0x1249,
0xf249, 0x9001, 0x9001, 0x9001, 0x8001, 0x8001, 0x8001, 0xffff },
/* cross-hair zak256 - chrilith palmos */
/*
{ 0x0080, 0x0080, 0x02a0, 0x01c0, 0x0080, 0x1004, 0x0808, 0x7c1f,
0x0808, 0x1004, 0x0080, 0x01c0, 0x02a0, 0x0080, 0x0080, 0x0000 },
*/
{ 0x0080, 0x02a0, 0x01c0, 0x0080, 0x0000, 0x2002, 0x1004, 0x780f,
0x1004, 0x2002, 0x0000, 0x0080, 0x01c0, 0x02a0, 0x0080, 0x0000 },
};
static const byte default_cursor_hotspots[8] = {
8, 7, 8, 7, 1, 1, 5, 0
static const byte default_cursor_hotspots[10] = {
8, 7, 8, 7, 1, 1, 5, 0,
8, 7, //zak256
};
@ -859,7 +869,7 @@ void Gdi::drawBitmap(byte *ptr, VirtScreen *vs, int x, int y, const int h,
else {
numzbuf = _numZBuffer;
assert(numzbuf <= (int)ARRAYSIZE(zplane_list));
if (_vm->_features & GF_OLD256) {
zplane_list[1] = smap_ptr + READ_LE_UINT32(smap_ptr);
if (0 == READ_LE_UINT32(zplane_list[1]))
@ -3450,14 +3460,21 @@ void Scumm::decompressDefaultCursor(int idx) {
_grabbedCursor[i * 8 + j] = color;
}
} else {
byte currentCursor = _currentCursor;
#ifdef __PALM_OS__
if (_gameId == GID_ZAK256 && currentCursor == 0)
currentCursor = 4;
#endif
_cursor.width = 16;
_cursor.height = 16;
_cursor.hotspotX = default_cursor_hotspots[2 * _currentCursor];
_cursor.hotspotY = default_cursor_hotspots[2 * _currentCursor + 1];
_cursor.hotspotX = default_cursor_hotspots[2 * currentCursor];
_cursor.hotspotY = default_cursor_hotspots[2 * currentCursor + 1];
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) {
if (default_cursor_images[_currentCursor][i] & (1 << j))
if (default_cursor_images[currentCursor][i] & (1 << j))
_grabbedCursor[16 * i + 15 - j] = color;
}
}
@ -3804,3 +3821,12 @@ void Scumm::drawBomp(BompDrawData *bd, int decode_mode, int mask) {
break;
}
}
#ifdef __PALM_OS__
#include "scumm_globals.h" // init globals
void Gfx_initGlobals() {
GSETPTR(transitionEffects, GBVARS_TRANSITIONEFFECTS_INDEX, TransitionEffect, GBVARS_SCUMM)
}
void Gfx_releaseGlobals() { GRELEASEPTR(GBVARS_TRANSITIONEFFECTS_INDEX, GBVARS_SCUMM)}
#endif

View File

@ -154,6 +154,11 @@ struct Player {
int fade_vol(byte vol, int time);
bool is_fading_out();
void sequencer_timer();
Player() {
memset(this,0,sizeof(Player)); // palmos
}
};
struct VolumeFader {
@ -171,6 +176,10 @@ struct VolumeFader {
}
void on_timer(bool probe);
byte fading_to();
VolumeFader() {
memset(this,0,sizeof(VolumeFader)); //palmos
}
};
struct SustainingNotes {
@ -255,6 +264,10 @@ struct Part {
void update_pris();
void changed(uint16 what);
Part() {
memset(this,0,sizeof(Part));
}
};
struct ImTrigger {
@ -433,6 +446,9 @@ private:
void unlock();
public:
IMuseInternal() {
memset(this,0,sizeof(IMuseInternal)); // palmos
}
~IMuseInternal();
Part *parts_ptr() {
@ -2967,6 +2983,10 @@ int IMuseInternal::save_or_load(Serializer *ser, Scumm *scumm) {
#ifdef _WIN32_WCE // Don't break savegames made with andys' build
if (!ser->isSaving() && ser->checkEOFLoadStream())
return 0;
#elif defined(__PALM_OS__) // previous PalmOS ver. without imuse implementation or not saved(Oopps...forgot it !), is this really working ? will we have sound with old saved game ?
if (!ser->isSaving() && ser->checkEOFLoadStream())
return 0; //palmfixme
#endif
ser->_ref_me = this;
@ -3241,6 +3261,8 @@ void Part::set_instrument(uint b) {
IMuseDriver::IMuseDriver (MidiDriver *midi) {
int i;
memset(this,0,sizeof(IMuseDriver)); //palmos
// Initialize our "last" trackers with impossible
// values, so that they don't accidentally match
// any changes that are sent (which would cause

View File

@ -72,6 +72,15 @@ struct imuse_music_map {
int16 unk4;
};
#ifdef __PALM_OS__
// these games are currently not supported under PalmOS so we can save this space
// to prevent full data segement
static const imuse_music_map *_digStateMusicMap;
static const imuse_music_table *_digStateMusicTable;
static const imuse_music_table *_comiStateMusicTable;
static const imuse_music_table *_comiSeqMusicTable;
static const imuse_music_table *_digSeqMusicTable;
#else
static const imuse_music_map _digStateMusicMap[] = {
{0, 0, 0, 0, 0, 0 },
{1, 0, 0, 0, 0, 0 },
@ -516,6 +525,7 @@ static const imuse_music_table _digSeqMusicTable[] = {
{2450, "seqFinale9a", "Seq (finale 9a)", "SE313B~5.IMU", 4},
{-1, "", "", "", 0},
};
#endif
struct imuse_ft_music_table {
int16 index;
@ -525,6 +535,12 @@ struct imuse_ft_music_table {
char name[30];
};
#ifdef __PALM_OS__
// these games are currently not supported under PalmOS so we can save this space
// to prevent full data segement
static const imuse_ft_music_table *_ftStateMusicTable;
static const imuse_ft_music_table *_ftSeqMusicTable;
#else
static const imuse_ft_music_table _ftStateMusicTable[] = {
{0, "", 0, 0, "STATE_NULL" },
{1, "", 4, 127, "stateKstandOutside" },
@ -634,6 +650,7 @@ static const imuse_ft_music_table _ftSeqMusicTable[] = {
{52, "", 0, 0, "seqCredits" },
{-1, "", 0, 0, "" },
};
#endif
void IMuseDigital::handler() {
uint32 l = 0, i = 0;
@ -813,16 +830,16 @@ void IMuseDigital::startSound(int sound) {
} else if (READ_UINT32_UNALIGNED(ptr) == MKID('iMUS')) {
ptr += 16;
for (;;) {
tag = READ_BE_UINT32(ptr); ptr += 4;
tag = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4;
switch(tag) {
case MKID_BE('FRMT'):
ptr += 12;
_channel[l]._bits = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._freq = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._channels = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._bits = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4;
_channel[l]._freq = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4;
_channel[l]._channels = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4;
break;
case MKID_BE('TEXT'):
size = READ_BE_UINT32(ptr); ptr += size + 4;
size = READ_BE_UINT32_UNALIGNED(ptr); ptr += size + 4;
break;
case MKID_BE('REGN'):
ptr += 4;
@ -831,13 +848,13 @@ void IMuseDigital::startSound(int sound) {
ptr += 8;
break;
}
_channel[l]._region[_channel[l]._numRegions]._offset = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._region[_channel[l]._numRegions]._length = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._region[_channel[l]._numRegions]._offset = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4;
_channel[l]._region[_channel[l]._numRegions]._length = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4;
_channel[l]._numRegions++;
break;
case MKID_BE('STOP'):
ptr += 4;
_channel[l]._offsetStop = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._offsetStop = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4;
break;
case MKID_BE('JUMP'):
ptr += 4;
@ -846,15 +863,15 @@ void IMuseDigital::startSound(int sound) {
ptr += 16;
break;
}
_channel[l]._jump[_channel[l]._numJumps]._offset = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._jump[_channel[l]._numJumps]._dest = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._jump[_channel[l]._numJumps]._id = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._jump[_channel[l]._numJumps]._numLoops = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._jump[_channel[l]._numJumps]._offset = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4;
_channel[l]._jump[_channel[l]._numJumps]._dest = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4;
_channel[l]._jump[_channel[l]._numJumps]._id = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4;
_channel[l]._jump[_channel[l]._numJumps]._numLoops = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4;
_channel[l]._isJump = true;
_channel[l]._numJumps++;
break;
case MKID_BE('DATA'):
size = READ_BE_UINT32(ptr); ptr += 4;
size = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4;
break;
default:
error("IMuseDigital::startSound(%d) Unknown sfx header %c%c%c%c", tag>>24, tag>>16, tag>>8, tag);
@ -1170,3 +1187,27 @@ int IMuseDigital::getSoundStatus(int sound) {
return 0;
}
#ifdef __PALM_OS__
#include "scumm_globals.h" // init globals
void IMuseDigital_initGlobals() {
GSETPTR(_digStateMusicMap, GBVARS_DIGSTATEMUSICMAP_INDEX, imuse_music_map , GBVARS_SCUMM)
GSETPTR(_digStateMusicTable, GBVARS_DIGSTATEMUSICTABLE_INDEX, imuse_music_table , GBVARS_SCUMM)
GSETPTR(_comiStateMusicTable, GBVARS_COMISTATEMUSICTABLE_INDEX, imuse_music_table , GBVARS_SCUMM)
GSETPTR(_comiSeqMusicTable, GBVARS_COMISEQMUSICTABLE_INDEX, imuse_music_table , GBVARS_SCUMM)
GSETPTR(_digSeqMusicTable, GBVARS_DIGSEQMUSICTABLE_INDEX, imuse_music_table , GBVARS_SCUMM)
GSETPTR(_ftStateMusicTable, GBVARS_FTSTATEMUSICTABLE_INDEX, imuse_ft_music_table, GBVARS_SCUMM)
GSETPTR(_ftSeqMusicTable, GBVARS_FTSEQMUSICTABLE_INDEX, imuse_ft_music_table, GBVARS_SCUMM)
}
void IMuseDigital_releaseGlobals() {
GRELEASEPTR(GBVARS_DIGSTATEMUSICMAP_INDEX , GBVARS_SCUMM)
GRELEASEPTR(GBVARS_DIGSTATEMUSICTABLE_INDEX , GBVARS_SCUMM)
GRELEASEPTR(GBVARS_COMISTATEMUSICTABLE_INDEX , GBVARS_SCUMM)
GRELEASEPTR(GBVARS_COMISEQMUSICTABLE_INDEX , GBVARS_SCUMM)
GRELEASEPTR(GBVARS_DIGSEQMUSICTABLE_INDEX , GBVARS_SCUMM)
GRELEASEPTR(GBVARS_FTSTATEMUSICTABLE_INDEX , GBVARS_SCUMM)
GRELEASEPTR(GBVARS_FTSEQMUSICTABLE_INDEX , GBVARS_SCUMM)
}
#endif

View File

@ -550,7 +550,7 @@ void Scumm::nukeCharset(int i) {
}
void Scumm::ensureResourceLoaded(int type, int i) {
void *addr;
void *addr = NULL;
debug(9, "ensureResourceLoaded(%s,%d)", resTypeFromId(type), i);
@ -561,7 +561,9 @@ void Scumm::ensureResourceLoaded(int type, int i) {
if (i == 0)
return;
addr = res.address[type][i];
if (i <= res.num[type])
addr = res.address[type][i];
if (addr)
return;
@ -1001,7 +1003,7 @@ int Scumm::readSoundResourceSmallHeader(int type, int idx) {
ptr = createResource(type, idx, best_size);
_fileHandle.read(ptr, best_size);
ticks = READ_BE_UINT16(ptr + 9);
ticks = READ_BE_UINT16_UNALIGNED(ptr + 9);
size = best_size;
if (size < 0x98) {
// FIXME: OLD256 music file w/o instruments

View File

@ -73,6 +73,13 @@ bool Scumm::saveState(int slot, bool compat, SaveFileManager *mgr) {
Serializer ser(out, true, CURRENT_VER);
saveOrLoad(&ser, CURRENT_VER);
#ifdef __PALM_OS__
if (_imuse) { // moved here to prevent stack overflow on palmos
_imuse->save_or_load(&ser, this);
_imuse->set_master_volume (_sound->_sound_volume_master);
_imuse->set_music_volume (_sound->_sound_volume_music);
}
#endif
delete out;
debug(1, "State saved as '%s'", filename);
@ -142,6 +149,13 @@ bool Scumm::loadState(int slot, bool compat, SaveFileManager *mgr) {
Serializer ser(out, false, hdr.ver);
saveOrLoad(&ser, hdr.ver);
#ifdef __PALM_OS__
if (_imuse) { // moved here to prevent stack overflow on palmos
_imuse->save_or_load(&ser, this);
_imuse->set_master_volume (_sound->_sound_volume_master);
_imuse->set_music_volume (_sound->_sound_volume_music);
}
#endif
delete out;
sb = _screenB;
@ -179,7 +193,6 @@ bool Scumm::loadState(int slot, bool compat, SaveFileManager *mgr) {
CHECK_HEAP debug(1, "State loaded from '%s'", filename);
_sound->pauseSounds(false);
return true;
@ -188,7 +201,11 @@ bool Scumm::loadState(int slot, bool compat, SaveFileManager *mgr) {
void Scumm::makeSavegameName(char *out, int slot, bool compatible) {
const char *dir = getSavePath();
#ifndef __PALM_OS__
sprintf(out, "%s%s.%c%.2d", dir, _game_name, compatible ? 'c' : 's', slot);
#else
sprintf(out, "%s%s.%s%.2d", dir, _game_name, compatible ? "c" : "s", slot);
#endif
}
void Scumm::listSavegames(bool *marks, int num, SaveFileManager *mgr) {
@ -667,12 +684,14 @@ void Scumm::saveOrLoad(Serializer *s, uint32 savegameVersion) {
res.flags[r][s->loadWord()] |= RF_LOCK;
}
}
#ifndef __PALM_OS__// moved to ::loadState/saveState to prevent stack overflow on palmos
if (_imuse) {
_imuse->save_or_load(s, this);
_imuse->set_master_volume (_sound->_sound_volume_master);
_imuse->set_music_volume (_sound->_sound_volume_music);
}
#endif
}
void Scumm::saveLoadResource(Serializer *ser, int type, int idx) {
@ -730,7 +749,14 @@ bool Serializer::checkEOFLoadStream() {
_saveLoadStream->fseek(-1, SEEK_CUR);
return false;
}
#elif defined(__PALM_OS__)
bool Serializer::checkEOFLoadStream() {
if (_saveLoadStream->feof())
return true;
return false;
}
#endif

View File

@ -289,7 +289,7 @@ void Scumm::executeScript() {
}
_opcode = fetchScriptByte();
vm.slot[_currentScript].didexec = 1;
debug(7, " Script %d, offset 0x%x: [%X] %s()",
debug(7, "Script %d, offset 0x%x: [%X] %s()",
vm.slot[_currentScript].number,
_scriptPointer - _scriptOrgPointer,
_opcode,

View File

@ -425,15 +425,14 @@ void Scumm::writeArray(int array, int idx, int base, int value) {
} else if (_features & GF_AFTER_V8) {
#if defined(SCUMM_NEED_ALIGNMENT)
uint32 tmp = TO_LE_32(value);
memcpy(&((uint32*)ah->data)[base], &tmp, 4);
memcpy(&((uint32 *)ah->data)[base], &tmp, 4);
#else
((uint32 *)ah->data)[base] = TO_LE_32(value);
#endif
} else {
#if defined(SCUMM_NEED_ALIGNMENT)
uint16 tmp = TO_LE_16(value);
memcpy(&((uint16*)ah->data)[base], &tmp, 2);
memcpy(&((uint16 *)ah->data)[base], &tmp, 2);
#else
((uint16 *)ah->data)[base] = TO_LE_16(value);
#endif
@ -2281,7 +2280,8 @@ void Scumm_v6::o6_dim2() {
}
void Scumm_v6::o6_abs() {
push(abs(pop()));
int a = pop(); // palmos: prevent multi pop if we use an abs function defined as : #define abs(a) ((a) < 0 ? -(a) : (a))
push(abs(a));
}
void Scumm_v6::o6_distObjectObject() {

View File

@ -350,6 +350,9 @@ public:
void shutDown(int i);
void setOptions(void);
#ifdef __PALM_OS__
bool _quit; // try to exit properly
#endif
// GUI
NewGui *_newgui;
@ -599,7 +602,6 @@ protected:
bool isResourceInUse(int type, int i);
void initRoomSubBlocks();
void clearRoomObjects();
void loadRoomObjects();
void loadRoomObjectsSmall();
void loadRoomObjectsOldBundle();

View File

@ -49,7 +49,7 @@ extern void drawError(char*);
// Use g_scumm from error() ONLY
Scumm *g_scumm = 0;
ScummDebugger g_debugger;
ScummDebugger *g_debugger;
extern NewGui *g_gui;
extern uint16 _debugLevel;
@ -182,9 +182,225 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
: Engine(detector, syst), _pauseDialog(0), _optionsDialog(0), _saveLoadDialog(0) {
OSystem::Property prop;
// Init all vars - maybe now we can get rid of our custom new/delete operators?
_imuse = NULL;
_imuseDigital = NULL;
_features = 0;
_verbs = NULL;
_objs = NULL;
_debugger = NULL;
_bundle = NULL;
_timer =NULL;
_sound= NULL;
memset(&res, 0, sizeof(res));
memset(&vm, 0, sizeof(vm));
memset(&mouse, 0, sizeof(mouse));
_smushFrameRate = 0;
_insaneState = 0;
_videoFinished = 0;
_smushPlay = 0;
#ifdef __PALM_OS__
_quit = false;
#endif
_newgui = NULL;
_pauseDialog = NULL;
_optionsDialog = NULL;
_saveLoadDialog = NULL;
_debuggerDialog = NULL;
_fastMode = 0;
memset(&_rnd, 0, sizeof(RandomSource));
_gameId = 0;
memset(&gdi,0,sizeof(Gdi));
_actors = NULL;
_inventory = NULL;
_arrays = NULL;
_newNames = NULL;
_vars = NULL;
_varwatch = 0;
_bitVars = NULL;
_numVariables = 0;
_numBitVariables = 0;
_numLocalObjects = 0;
_numGlobalObjects = 0;
_numArray = 0;
_numVerbs = 0;
_numFlObject = 0;
_numInventory = 0;
_numRooms = 0;
_numScripts = 0;
_numSounds = 0;
_numCharsets = 0;
_numNewNames = 0;
_numGlobalScripts = 0;
NUM_ACTORS = 0;
_numCostumes = 0;
_audioNames = NULL;
_numAudioNames = 0;
_curActor = 0;
_curVerb = 0;
_curVerbSlot = 0;
_curPalIndex = 0;
_currentRoom = 0;
_egoPositioned = false;
_keyPressed = 0;
_lastKeyHit = 0;
_mouseButStat = 0;
_leftBtnPressed = 0;
_rightBtnPressed = 0;
_virtual_mouse_x = 0;
_virtual_mouse_y = 0;
_bootParam = 0;
_dumpScripts = false;
_debugMode = 0;
_soundCardType = 0;
_language = 0;
_objectOwnerTable = NULL;
_objectRoomTable = NULL;
_objectStateTable = NULL;
memset(&_objectIDMap,0,sizeof(ObjectIDMap));
_numObjectsInRoom = 0;
_userPut = 0;
_resourceHeaderSize = 0;
_saveLoadFlag = 0;
_saveLoadSlot = 0;
_lastSaveTime = 0;
_saveLoadCompatible = false;
memset(_saveLoadName,0,sizeof(_saveLoadName));
_maxHeapThreshold = 0;
_minHeapThreshold = 0;
memset(_localScriptList,0,sizeof(_localScriptList));
_scriptPointer = NULL;
_scriptOrgPointer = NULL;
_opcode = 0;
_numNestedScripts = 0;
_currentScript = 0;
_curExecScript = 0;
_lastCodePtr = NULL;
_resultVarNumber = 0;
_scummStackPos = 0;
memset(_localParamList,0,sizeof(_localParamList));
memset(_scummStack,0,sizeof(_scummStack));
_keyScriptKey = 0;
_keyScriptNo = 0;
_encbyte = 0;
memset(&_fileHandle,0,sizeof(File));
_fileOffset = 0;
_exe_name = NULL;
_game_name = NULL;
_dynamicRoomOffsets = false;
memset(_resourceMapper,0,sizeof(_resourceMapper));
_allocatedSize = 0;
_expire_counter = 0;
_lastLoadedRoom = 0;
_roomResource = 0;
OF_OWNER_ROOM = 0;
_verbMouseOver = 0;
_inventoryOffset = 0;
_classData = NULL;
_actorToPrintStrFor = 0;
_sentenceNum = 0;
memset(_sentence,0,sizeof(_sentence));
memset(_string,0,sizeof(_string));
_screenB = 0;
_screenH = 0;
_scrHeight = 0;
_scrWidth = 0;
_realHeight = 0;
_realWidth = 0;
memset(virtscr,0,sizeof(virtscr));
memset(&camera,0,sizeof(CameraData));
memset(_colorCycle,0,sizeof(_colorCycle));
_ENCD_offs = 0;
_EXCD_offs = 0;
_CLUT_offs = 0;
_IM00_offs = 0;
_PALS_offs = 0;
_fullRedraw = false;
_BgNeedsRedraw = false;
_verbRedraw = false;
_screenEffectFlag = false;
_completeScreenRedraw = false;
memset(&_cursor,0,sizeof(_cursor));
memset(_grabbedCursor,0,sizeof(_grabbedCursor));
_currentCursor = 0;
_newEffect = 0;
_switchRoomEffect2 = 0;
_switchRoomEffect = 0;
_doEffect = false;
memset(&_flashlight,0,sizeof(_flashlight));
_flashlightXStrips = 0;
_flashlightYStrips = 0;
_flashlightIsDrawn = false;
_bompScaleRight = 0;
_bompScaleBottom = 0;
_bompScallingXPtr = NULL;
_bompScallingYPtr = NULL;
_bompMaskPtr = NULL;
_bompActorPalletePtr = NULL;
_shakeEnabled= false;
_shakeFrame = 0;
_screenStartStrip = 0;
_screenEndStrip = 0;
_screenLeft = 0;
_screenTop = 0;
_blastObjectQueuePos = 0;
memset(_blastObjectQueue,0,sizeof(_blastObjectQueue));
_blastTextQueuePos = 0;
memset(_blastTextQueue,0,sizeof(_blastTextQueue));
_drawObjectQueNr = 0;
memset(_drawObjectQue,0,sizeof(_drawObjectQue));
_palManipStart = 0;
_palManipEnd = 0;
_palManipCounter = 0;
_palManipPalette = NULL;
_palManipIntermediatePal = NULL;
memset(gfxUsageBits,0,sizeof(gfxUsageBits));
_shadowPalette = NULL;
_shadowPaletteSize = 0;
memset(_currentPalette,0,sizeof(_currentPalette));
memset(_proc_special_palette,0,sizeof(_proc_special_palette));
_palDirtyMin = 0;
_palDirtyMax = 0;
_haveMsg = 0;
_useTalkAnims = false;
_defaultTalkDelay = 0;
_use_adlib = false;
tempMusic = 0;
_silentDigitalImuse = 0;
_noDigitalSamples = 0;
_saveSound = 0;
current_cd_sound = 0;
_maxBoxVertexHeap = 0;
_boxPathVertexHeapIndex = 0;
_boxMatrixItem = 0;
_boxPathVertexHeap = NULL;
_boxMatrixPtr1 = NULL;
_boxMatrixPtr3 = NULL;
memset(_extraBoxFlags,0,sizeof(_extraBoxFlags));
memset(_scaleSlots,0,sizeof(_scaleSlots));
_charset = NULL;
_charsetColor = 0;
memset(_charsetColorMap,0,sizeof(_charsetColorMap));
memset(_charsetData,0,sizeof(_charsetData));
_charsetBufPos = 0;
memset(_charsetBuffer,0,sizeof(_charsetBuffer));
_noSubtitles = false;
_numInMsgStack = 0;
_msgPtrToAdd = NULL;
_messagePtr = NULL;
_talkDelay = 0;
_keepText = false;
_existLanguageFile = false;
_languageBuffer = NULL;
_languageIndex = NULL;
_languageStrCount = 0;
memset(_transText,0,sizeof(_transText));
// Use g_scumm from error() ONLY
g_scumm = this;
g_debugger = new ScummDebugger;
_debugMode = detector->_debugMode;
_debugLevel = detector->_debugLevel;
_dumpScripts = detector->_dumpScripts;
@ -305,6 +521,13 @@ Scumm::~Scumm ()
delete _imuseDigital;
delete _languageBuffer;
delete _audioNames;
if (_shadowPalette)
free(_shadowPalette);
destroy();
delete g_debugger;
}
void Scumm::scummInit() {
@ -468,7 +691,6 @@ void Scumm::initScummVars() {
_vars[VAR_SOUNDPARAM] = 0;
_vars[VAR_SOUNDPARAM2] = 0;
_vars[VAR_SOUNDPARAM3] = 0;
if (_features & GF_AFTER_V6)
_vars[VAR_V6_EMSSPACE] = 10000;
@ -478,7 +700,7 @@ void Scumm::initScummVars() {
// Setup light
_vars[VAR_CURRENT_LIGHTS] = LIGHTMODE_actor_base | LIGHTMODE_actor_color | LIGHTMODE_screen;
} else {
_vars[VAR_V6_EMSSPACE] = 10000;
_vars[VAR_V6_EMSSPACE] = 10000;
}
if (_features & GF_AFTER_V8) { // Fixme: How do we deal with non-cd installs?
@ -492,7 +714,11 @@ void Scumm::initScummVars() {
void Scumm::checkRange(int max, int min, int no, const char *str) {
if (no < min || no > max) {
#ifdef __PALM_OS__
char buf[256]; // 1024 is too big overflow the stack
#else
char buf[1024];
#endif
sprintf(buf, str, no);
error("Value %d is out of bounds (%d,%d) in script %d (%s)", no, min,
max, vm.slot[_curExecScript].number, buf);
@ -610,7 +836,11 @@ load_game:
displayError(false, errMsg, filename);
} else if (_saveLoadFlag == 1 && _saveLoadSlot != 0 && !_saveLoadCompatible) {
// Display "Save succesful" message, except for auto saves
#ifdef __PALM_OS__
char buf[256]; // 1024 is too big overflow the stack
#else
char buf[1024];
#endif
sprintf(buf, errMsg, filename);
Dialog *dialog = new MessageDialog(_newgui, buf, 1500, false);
@ -1331,7 +1561,11 @@ void Scumm::optionsDialog() {
}
char Scumm::displayError(bool showCancel, const char *message, ...) {
#ifdef __PALM_OS__
char buf[256], result; // 1024 is too big overflow the stack
#else
char buf[1024], result;
#endif
va_list va;
va_start(va, message);
@ -1446,7 +1680,7 @@ void Scumm::processKbd() {
_vars[VAR_CHARINC] = _defaultTalkDelay / 20;
} else if (_lastKeyHit == '~' || _lastKeyHit == '#') { // Debug console
g_debugger.attach(this, NULL);
g_debugger->attach(this, NULL);
}
_mouseButStat = _lastKeyHit;
@ -1638,14 +1872,13 @@ void Scumm::errorString(const char *buf1, char *buf2) {
strcpy(buf2, buf1);
}
// Unless an error -originated- within the debugger, spawn the debugger. Otherwise
// exit out normally.
if (!_debugger) {
printf("%s", buf2); // (Print it again in-case debugger segfaults)
g_debugger.attach(this, buf2);
g_debugger.on_frame();
}
// Unless an error -originated- within the debugger, spawn the debugger. Otherwise
// exit out normally.
if (!_debugger) {
printf("%s", buf2); // (Print it again in-case debugger segfaults)
g_debugger->attach(this, buf2);
g_debugger->on_frame();
}
}
void Scumm::waitForTimer(int msec_delay) {
@ -1693,7 +1926,7 @@ void Scumm::parseEvents() {
else if (event.kbd.keycode == 'g')
_fastMode ^= 2;
else if ((event.kbd.keycode == 'd') && (!_system->property(OSystem::PROP_GET_FULLSCREEN, 0)))
g_debugger.attach(this, NULL);
g_debugger->attach(this, NULL);
else if (event.kbd.keycode == 's')
resourceStats();
else
@ -1716,7 +1949,7 @@ void Scumm::parseEvents() {
case OSystem::EVENT_LBUTTONDOWN:
_leftBtnPressed |= msClicked|msDown;
#ifdef _WIN32_WCE
#if defined(_WIN32_WCE) || defined(__PALM_OS__)
mouse.x = event.mouse.x;
mouse.y = event.mouse.y;
#endif
@ -1724,7 +1957,7 @@ void Scumm::parseEvents() {
case OSystem::EVENT_RBUTTONDOWN:
_rightBtnPressed |= msClicked|msDown;
#ifdef _WIN32_WCE
#if defined(_WIN32_WCE) || defined(__PALM_OS__)
mouse.x = event.mouse.x;
mouse.y = event.mouse.y;
#endif
@ -1798,6 +2031,10 @@ void Scumm::mainRun() {
int new_time;
for(;;) {
#ifdef __PALM_OS__
if (_quit) // palmfixme : need to check for autosave on exit
return;
#endif
updatePalette();
_system->update_screen();
@ -1813,12 +2050,20 @@ void Scumm::mainRun() {
void Scumm::launch() {
gdi._vm = this;
#ifdef __PALM_OS__
// PALMOS : check if this value is correct with palm,
// old value 450000 doesn't work anymore (return _fntPtr = NULL in zak256, not tested with others)
// 1500000 is too big and make ScummVM crashes : MemMove to NULL or immediate exit if try to allocate
// memory with new operator
_maxHeapThreshold = 550000;
#else
// Since the new costumes are very big, we increase the heap limit, to avoid having
// to constantly reload stuff from the data files.
if (_features & GF_NEW_COSTUMES)
_maxHeapThreshold = 1500000;
else
_maxHeapThreshold = 450000;
#endif
_minHeapThreshold = 400000;
_verbRedraw = false;

View File

@ -32,6 +32,8 @@
#include "common/util.h"
Sound::Sound(Scumm *parent) {
memset(this,0,sizeof(Sound)); // palmos
_scumm = parent;
_nameBundleMusic = NULL;
_musicBundleBufFinal = NULL;
@ -41,6 +43,10 @@ Sound::Sound(Scumm *parent) {
}
Sound::~Sound() {
if (_sfxFile) {
_sfxFile->close();
delete _sfxFile;
}
}
void Sound::addSoundToQueue(int sound) {