svn-id: r22320
This commit is contained in:
Travis Howell 2006-05-04 02:23:52 +00:00
parent 84c99c8242
commit e87de5898b
10 changed files with 190 additions and 230 deletions

View file

@ -185,7 +185,7 @@ void SimonEngine::dump_video_script(const byte *src, bool one_opcode_only) {
opcode = *src++; opcode = *src++;
} }
if (opcode >= NUM_VIDEO_OP_CODES) { if (opcode >= _numVideoOpcodes) {
error("Invalid opcode %x\n", opcode); error("Invalid opcode %x\n", opcode);
return; return;
} }

View file

@ -422,8 +422,6 @@ void SimonEngine::fillBackGroundFromBack(uint lines) {
} }
void SimonEngine::dx_update_screen_and_palette() { void SimonEngine::dx_update_screen_and_palette() {
_numScreenUpdates++;
if (_paletteColorCount == 0 && _paletteFlag == 1) { if (_paletteColorCount == 0 && _paletteFlag == 1) {
_paletteFlag = 0; _paletteFlag = 0;
if (memcmp(_palette, _paletteBackup, 1024) != 0) { if (memcmp(_palette, _paletteBackup, 1024) != 0) {
@ -486,8 +484,7 @@ void SimonEngine::slowFadeIn() {
dst++; dst++;
} }
_system->setPalette(_videoBuf1, 0, _videoNumPalColors); _system->setPalette(_videoBuf1, 0, _videoNumPalColors);
if (_fade) _system->updateScreen();
_system->updateScreen();
delay(5); delay(5);
} }
_paletteColorCount = 0; _paletteColorCount = 0;

View file

@ -1630,8 +1630,7 @@ void SimonEngine::o1_specialFade() {
paletteFadeOut((uint32 *)_videoBuf1 + 32 + 16 + 144 + 16, 48); paletteFadeOut((uint32 *)_videoBuf1 + 32 + 16 + 144 + 16, 48);
_system->setPalette(_videoBuf1, 0, 256); _system->setPalette(_videoBuf1, 0, 256);
if (_fade) _system->updateScreen();
_system->updateScreen();
delay(5); delay(5);
} while (--i); } while (--i);

View file

@ -380,14 +380,14 @@ void SimonEngine::saveUserGame(int slot) {
windowBackSpace(_windowArray[3]); windowBackSpace(_windowArray[3]);
if (_keyPressed == 27) { if (_keyPressed == 27) {
writeVariable(55, _keyPressed); _variableArray[55] = _keyPressed;
break; break;
} }
if (_keyPressed == 10 || _keyPressed == 13) { if (_keyPressed == 10 || _keyPressed == 13) {
if (!saveGame(readVariable(55), name)) if (!saveGame(readVariable(55), name))
writeVariable(55, 0xFFFF); _variableArray[55] = 0xFFFF;
else else
writeVariable(55, 0); _variableArray[55] = 0;
break; break;
} }
if (_keyPressed == 8 && len != 0) { if (_keyPressed == 8 && len != 0) {

View file

@ -487,16 +487,6 @@ void SimonEngine::openGameFile() {
_gameOffsetsPtr[r] = FROM_LE_32(_gameOffsetsPtr[r]); _gameOffsetsPtr[r] = FROM_LE_32(_gameOffsetsPtr[r]);
#endif #endif
} }
if (getGameType() == GType_FF)
loadIconData();
else
loadIconFile();
vc34_setMouseOff();
runSubroutine101();
permitInput();
} }
void SimonEngine::readGameFile(void *dst, uint32 offs, uint32 size) { void SimonEngine::readGameFile(void *dst, uint32 offs, uint32 size) {

View file

@ -106,7 +106,7 @@ SimonEngine::SimonEngine(OSystem *syst)
_codePtr = 0; _codePtr = 0;
_localStringtable = 0; _localStringtable = 0;
_stringIdLocalMin = 1; _stringIdLocalMin = 0;
_stringIdLocalMax = 0; _stringIdLocalMax = 0;
_tablesHeapPtr = 0; _tablesHeapPtr = 0;
@ -142,29 +142,28 @@ SimonEngine::SimonEngine(OSystem *syst)
_inCallBack = 0; _inCallBack = 0;
_cepeFlag = 0; _cepeFlag = 0;
_copyPartialMode = 0; _copyPartialMode = 0;
_speed = 1;
_fastMode = 0; _fastMode = 0;
_useBackGround = 0; _useBackGround = 0;
_debugMode = 0; _debugMode = 0;
_pause = 0; _startMainScript = false;
_startMainScript = 0; _continousMainScript = false;
_continousMainScript = 0; _startVgaScript = false;
_startVgaScript = 0; _continousVgaScript = false;
_continousVgaScript = 0; _drawImagesDebug = false;
_drawImagesDebug = 0; _dumpImages = false;
_dumpImages = 0;
_speech = true; _pause = false;
_subtitles = true; _speech = false;
_fade = true; _subtitles = false;
_animatePointer = 0; _animatePointer = 0;
_mouseCursor = 0; _mouseCursor = 0;
_mouseAnim = 0; _mouseAnim = 0;
_mouseAnimMax = 0; _mouseAnimMax = 0;
_oldMouseCursor = 0; _oldMouseCursor = 0;
_currentMouseCursor = 255; _currentMouseCursor = 0;
_currentMouseAnim = 255; _currentMouseAnim = 0;
_oldMouseAnimMax = 0; _oldMouseAnimMax = 0;
_vgaVar9 = 0; _vgaVar9 = 0;
@ -243,7 +242,7 @@ SimonEngine::SimonEngine(OSystem *syst)
_paletteColorCount = 0; _paletteColorCount = 0;
_noOverWrite = 0xFFFF; _noOverWrite = 0;
_rejectCount = 0; _rejectCount = 0;
_rejectBlock = false; _rejectBlock = false;
@ -253,8 +252,8 @@ SimonEngine::SimonEngine(OSystem *syst)
_paletteFlag = 0; _paletteFlag = 0;
_soundFileId = 0; _soundFileId = 0;
_lastMusicPlayed = -1; _lastMusicPlayed = 0;
_nextMusicToPlay = -1; _nextMusicToPlay = 0;
_showPreposition = 0; _showPreposition = 0;
_showMessageFlag = 0; _showMessageFlag = 0;
@ -277,7 +276,7 @@ SimonEngine::SimonEngine(OSystem *syst)
_timer5 = 0; _timer5 = 0;
_timer4 = 0; _timer4 = 0;
_frameRate = 1; _frameRate = 0;
_zoneNumber = 0; _zoneNumber = 0;
_vgaWaitFor = 0; _vgaWaitFor = 0;
@ -343,7 +342,6 @@ SimonEngine::SimonEngine(OSystem *syst)
memset(_lettersToPrintBuf, 0, sizeof(_lettersToPrintBuf)); memset(_lettersToPrintBuf, 0, sizeof(_lettersToPrintBuf));
_numScreenUpdates = 0;
_vgaTickCounter = 0; _vgaTickCounter = 0;
_moviePlay = 0; _moviePlay = 0;
@ -383,10 +381,16 @@ SimonEngine::SimonEngine(OSystem *syst)
"\x5\x5\x4\x6\x5\x3\x4\x5\x6\x3\x5\x5\x4\x6\x5\x3\x4\x6\x5\x6\x6\x6\x5\x5\x5\x6\x5\x6\x6\x6\x6\x6", 32); "\x5\x5\x4\x6\x5\x3\x4\x5\x6\x3\x5\x5\x4\x6\x5\x3\x4\x6\x5\x6\x6\x6\x5\x5\x5\x6\x5\x6\x6\x6\x6\x6", 32);
// Add default file directories for Acorn version // Add default file directories for Acorn version of
// Simon the Sorcerer 1
File::addDefaultDirectory(_gameDataPath + "execute/"); File::addDefaultDirectory(_gameDataPath + "execute/");
File::addDefaultDirectory(_gameDataPath + "EXECUTE/"); File::addDefaultDirectory(_gameDataPath + "EXECUTE/");
// Add default file directories for Amiga/Macintosh
// verisons of Simon the Sorcerer 2
File::addDefaultDirectory(_gameDataPath + "voices/");
File::addDefaultDirectory(_gameDataPath + "VOICES/");
// Add default file directories for Amiga & Macintosh // Add default file directories for Amiga & Macintosh
// versions of The Feeble Files // versions of The Feeble Files
File::addDefaultDirectory(_gameDataPath + "gfx/"); File::addDefaultDirectory(_gameDataPath + "gfx/");
@ -400,7 +404,6 @@ SimonEngine::SimonEngine(OSystem *syst)
} }
int SimonEngine::init() { int SimonEngine::init() {
// Detect game // Detect game
if (!initGame()) { if (!initGame()) {
GUIErrorMessage("No valid games were found in the specified directory."); GUIErrorMessage("No valid games were found in the specified directory.");
@ -417,6 +420,14 @@ int SimonEngine::init() {
_screenHeight = 200; _screenHeight = 200;
} }
_system->beginGFXTransaction();
initCommonGFX(getGameType() == GType_FF);
_system->initSize(_screenWidth, _screenHeight);
_system->endGFXTransaction();
// FIXME Use auto dirty rects cleanup code to reduce CPU usage
g_system->setFeatureState(OSystem::kFeatureAutoComputeDirtyRects, true);
// Setup mixer // Setup mixer
if (!_mixer->isReady()) if (!_mixer->isReady())
warning("Sound initialization failed. " warning("Sound initialization failed. "
@ -424,15 +435,10 @@ int SimonEngine::init() {
set_volume(ConfMan.getInt("sfx_volume")); set_volume(ConfMan.getInt("sfx_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
_system->beginGFXTransaction();
initCommonGFX(getGameType() == GType_FF);
_system->initSize(_screenWidth, _screenHeight);
_system->endGFXTransaction();
// Setup midi driver // Setup midi driver
MidiDriver *driver = 0; MidiDriver *driver = 0;
if (getPlatform() == Common::kPlatformAmiga) { if (getGameType() == GType_FF || getGameId() == GID_SIMON1CD32) {
driver = MidiDriver::createMidi(MD_NULL); // Create fake MIDI driver for Simon1Amiga and Simon2CD32 for now driver = MidiDriver::createMidi(MD_NULL);
_native_mt32 = false; _native_mt32 = false;
} else { } else {
int midiDriver = MidiDriver::detectMusicDriver(MDT_ADLIB | MDT_MIDI); int midiDriver = MidiDriver::detectMusicDriver(MDT_ADLIB | MDT_MIDI);
@ -451,12 +457,97 @@ int SimonEngine::init() {
warning ("MIDI Player init failed: \"%s\"", midi.getErrorName (ret)); warning ("MIDI Player init failed: \"%s\"", midi.getErrorName (ret));
midi.set_volume(ConfMan.getInt("music_volume")); midi.set_volume(ConfMan.getInt("music_volume"));
_debugMode = (gDebugLevel >= 0);
_language = Common::parseLanguage(ConfMan.get("language"));
if (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute") == 1) if (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute") == 1)
midi.pause(_musicPaused ^= 1); midi.pause(_musicPaused ^= 1);
_currentMouseCursor = 255;
_currentMouseAnim = 255;
_dumpFile = stdout;
_frameRate = 1;
_lastMusicPlayed = -1;
_nextMusicToPlay = -1;
_noOverWrite = 0xFFFF;
_stringIdLocalMin = 1;
_variableArrayPtr = _variableArray;
if (getGameType() == GType_FF) {
gss = PTR(feeblefiles_settings);
_numTextBoxes = 40;
_numVideoOpcodes = 85;
#ifndef PALMOS_68K
_vgaMemSize = 7500000;
#else
_vgaMemSize = gVars->memory[kMemSimon2Games];
#endif
_tableMemSize = 200000;
_vgaBaseDelay = 5;
} else if (getGameType() == GType_SIMON2) {
gss = PTR(simon2_settings);
_tableIndexBase = 1580 / 4;
_textIndexBase = 1500 / 4;
_numTextBoxes = 20;
_numVideoOpcodes = 75;
#ifndef PALMOS_68K
_vgaMemSize = 2000000;
#else
_vgaMemSize = gVars->memory[kMemSimon2Games];
#endif
_tableMemSize = 100000;
// Check whether to use MT-32 MIDI tracks in Simon the Sorcerer 2
if ((getGameType() == GType_SIMON2) && _native_mt32)
_musicIndexBase = (1128 + 612) / 4;
else
_musicIndexBase = 1128 / 4;
_soundIndexBase = 1660 / 4;
_vgaBaseDelay = 1;
} else {
gss = PTR(simon1_settings);
_tableIndexBase = 1576 / 4;
_textIndexBase = 1460 / 4;
_numTextBoxes = 20;
_numVideoOpcodes = 64;
#ifndef PALMOS_68K
_vgaMemSize = 1000000;
#else
_vgaMemSize = gVars->memory[kMemSimon1Games];
#endif
_tableMemSize = 50000;
_musicIndexBase = 1316 / 4;
_soundIndexBase = 0;
_vgaBaseDelay = 1;
}
// allocate buffers
_backGroundBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
_frontBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
_backBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
if (getGameType() == GType_FF)
_scaleBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
allocItemHeap();
allocTablesHeap();
setZoneBuffers();
_debugger = new Debugger(this);
_moviePlay = new MoviePlayer(this, _mixer);
_sound = new Sound(this, gss, _mixer);
if (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute") == 1) {
if (getGameId() == GID_SIMON1DOS)
midi._enable_sfx ^= 1;
else
_sound->effectsPause(_effectsPaused ^= 1);
}
_language = Common::parseLanguage(ConfMan.get("language"));
if (getFeatures() & GF_TALKIE) { if (getFeatures() & GF_TALKIE) {
_speech = !ConfMan.getBool("speech_mute"); _speech = !ConfMan.getBool("speech_mute");
_subtitles = ConfMan.getBool("subtitles"); _subtitles = ConfMan.getBool("subtitles");
@ -478,90 +569,15 @@ int SimonEngine::init() {
_subtitles = true; _subtitles = true;
} }
if (ConfMan.hasKey("fade") && ConfMan.getBool("fade") == 0) _debugMode = (gDebugLevel >= 0);
_fade = 0; if (gDebugLevel == 2)
_continousMainScript = true;
if (ConfMan.hasKey("slow_down") && ConfMan.getInt("slow_down") >= 1) if (gDebugLevel == 3)
_speed = ConfMan.getInt("slow_down"); _continousVgaScript = true;
if (gDebugLevel == 4)
// FIXME Use auto dirty rects cleanup code to reduce CPU usage _startMainScript = true;
g_system->setFeatureState(OSystem::kFeatureAutoComputeDirtyRects, true); if (gDebugLevel == 5)
_startVgaScript = true;
if (getGameType() == GType_FF) {
NUM_VIDEO_OP_CODES = 85;
#ifndef PALMOS_68K
VGA_MEM_SIZE = 7500000;
#else
VGA_MEM_SIZE = gVars->memory[kMemSimon2Games];
#endif
TABLES_MEM_SIZE = 200000;
VGA_DELAY_BASE = 5;
} else if (getGameType() == GType_SIMON2) {
TABLE_INDEX_BASE = 1580 / 4;
TEXT_INDEX_BASE = 1500 / 4;
NUM_VIDEO_OP_CODES = 75;
#ifndef PALMOS_68K
VGA_MEM_SIZE = 2000000;
#else
VGA_MEM_SIZE = gVars->memory[kMemSimon2Games];
#endif
TABLES_MEM_SIZE = 100000;
// Check whether to use MT-32 MIDI tracks in Simon the Sorcerer 2
if ((getGameType() == GType_SIMON2) && _native_mt32)
MUSIC_INDEX_BASE = (1128 + 612) / 4;
else
MUSIC_INDEX_BASE = 1128 / 4;
SOUND_INDEX_BASE = 1660 / 4;
VGA_DELAY_BASE = 1;
} else {
TABLE_INDEX_BASE = 1576 / 4;
TEXT_INDEX_BASE = 1460 / 4;
NUM_VIDEO_OP_CODES = 64;
#ifndef PALMOS_68K
VGA_MEM_SIZE = 1000000;
#else
VGA_MEM_SIZE = gVars->memory[kMemSimon1Games];
#endif
TABLES_MEM_SIZE = 50000;
MUSIC_INDEX_BASE = 1316 / 4;
SOUND_INDEX_BASE = 0;
VGA_DELAY_BASE = 1;
}
if (getGameType() == GType_FF) {
gss = PTR(feeblefiles_settings);
} else if (getGameType() == GType_SIMON2) {
if (getFeatures() & GF_TALKIE) {
// Add default file directories
File::addDefaultDirectory(_gameDataPath + "voices/");
File::addDefaultDirectory(_gameDataPath + "VOICES/");
}
gss = PTR(simon2_settings);
} else if (getGameType() == GType_SIMON1) {
gss = PTR(simon1_settings);
}
if ((getGameType() == GType_SIMON1) && (getFeatures() & GF_TALKIE)) {
// Add default file directories
switch (_language) {
case Common::HB_ISR:
File::addDefaultDirectory(_gameDataPath + "hebrew/");
File::addDefaultDirectory(_gameDataPath + "HEBREW/");
break;
case Common::ES_ESP:
File::addDefaultDirectory(_gameDataPath + "spanish/");
File::addDefaultDirectory(_gameDataPath + "SPANISH/");
break;
case Common::IT_ITA:
File::addDefaultDirectory(_gameDataPath + "italian/");
File::addDefaultDirectory(_gameDataPath + "ITALIAN/");
break;
case Common::FR_FRA:
File::addDefaultDirectory(_gameDataPath + "french/");
File::addDefaultDirectory(_gameDataPath + "FRENCH/");
break;
}
}
return 0; return 0;
} }
@ -717,9 +733,9 @@ void SimonEngine::allocItemHeap() {
} }
void SimonEngine::allocTablesHeap() { void SimonEngine::allocTablesHeap() {
_tablesHeapSize = TABLES_MEM_SIZE; _tablesHeapSize = _tableMemSize;
_tablesHeapCurPos = 0; _tablesHeapCurPos = 0;
_tablesHeapPtr = (byte *)calloc(TABLES_MEM_SIZE, 1); _tablesHeapPtr = (byte *)calloc(_tableMemSize, 1);
} }
void SimonEngine::setItemState(Item *item, int value) { void SimonEngine::setItemState(Item *item, int value) {
@ -1279,13 +1295,13 @@ void SimonEngine::loadZone(uint vga_res) {
void SimonEngine::setZoneBuffers() { void SimonEngine::setZoneBuffers() {
byte *alloced; byte *alloced;
alloced = (byte *)malloc(VGA_MEM_SIZE); alloced = (byte *)malloc(_vgaMemSize);
_vgaBufFreeStart = alloced; _vgaBufFreeStart = alloced;
_vgaBufStart = alloced; _vgaBufStart = alloced;
_vgaFileBufOrg = alloced; _vgaFileBufOrg = alloced;
_vgaFileBufOrg2 = alloced; _vgaFileBufOrg2 = alloced;
_vgaBufEnd = alloced + VGA_MEM_SIZE; _vgaBufEnd = alloced + _vgaMemSize;
} }
byte *SimonEngine::allocBlock(uint32 size) { byte *SimonEngine::allocBlock(uint32 size) {
@ -1785,7 +1801,7 @@ void SimonEngine::loadSprite(uint windowNum, uint zoneNum, uint vgaSpriteId, uin
if (_startVgaScript) if (_startVgaScript)
dump_vga_script(pp + READ_LE_UINT16(&((AnimationHeader_Feeble*)p)->scriptOffs), zoneNum, vgaSpriteId); dump_vga_script(pp + READ_LE_UINT16(&((AnimationHeader_Feeble*)p)->scriptOffs), zoneNum, vgaSpriteId);
addVgaEvent(VGA_DELAY_BASE, pp + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, zoneNum); addVgaEvent(_vgaBaseDelay, pp + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, zoneNum);
break; break;
} }
p += sizeof(AnimationHeader_Feeble); p += sizeof(AnimationHeader_Feeble);
@ -1794,7 +1810,7 @@ void SimonEngine::loadSprite(uint windowNum, uint zoneNum, uint vgaSpriteId, uin
if (_startVgaScript) if (_startVgaScript)
dump_vga_script(pp + READ_BE_UINT16(&((AnimationHeader_Simon*)p)->scriptOffs), zoneNum, vgaSpriteId); dump_vga_script(pp + READ_BE_UINT16(&((AnimationHeader_Simon*)p)->scriptOffs), zoneNum, vgaSpriteId);
addVgaEvent(VGA_DELAY_BASE, pp + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, zoneNum); addVgaEvent(_vgaBaseDelay, pp + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, zoneNum);
break; break;
} }
p += sizeof(AnimationHeader_Simon); p += sizeof(AnimationHeader_Simon);
@ -1862,61 +1878,21 @@ void SimonEngine::playSpeech(uint speech_id, uint vgaSpriteId) {
} }
int SimonEngine::go() { int SimonEngine::go() {
if (!_dumpFile)
_dumpFile = stdout;
// allocate buffers
_backGroundBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
_frontBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
_backBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
if (getGameType() == GType_FF)
_scaleBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
allocItemHeap();
allocTablesHeap();
setZoneBuffers();
_debugger = new Debugger(this);
_moviePlay = new MoviePlayer(this, _mixer);
_sound = new Sound(this, gss, _mixer);
if (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute") == 1) {
if (getGameId() == GID_SIMON1DOS)
midi._enable_sfx ^= 1;
else
_sound->effectsPause(_effectsPaused ^= 1);
}
loadGamePcFile(); loadGamePcFile();
addTimeEvent(0, 1); addTimeEvent(0, 1);
openGameFile(); openGameFile();
_lastMusicPlayed = -1;
_frameRate = 1;
if (getGameType() == GType_FF) if (getGameType() == GType_FF)
_numTextBoxes = 40; loadIconData();
else else
_numTextBoxes = 20; loadIconFile();
_variableArrayPtr = _variableArray; vc34_setMouseOff();
_startMainScript = false; runSubroutine101();
_continousMainScript = false; permitInput();
_startVgaScript = false;
_continousVgaScript = false;
_drawImagesDebug = false;
if (gDebugLevel == 2)
_continousMainScript = true;
if (gDebugLevel == 3)
_continousVgaScript = true;
if (gDebugLevel == 4)
_startMainScript = true;
if (gDebugLevel == 5)
_startVgaScript = true;
while (1) { while (1) {
hitarea_stuff(); hitarea_stuff();
@ -1956,9 +1932,9 @@ void SimonEngine::delay(uint amount) {
if (_fastMode) if (_fastMode)
vga_period = 10; vga_period = 10;
else if (getGameType() == GType_SIMON2) else if (getGameType() == GType_SIMON2)
vga_period = 45 * _speed; vga_period = 45;
else else
vga_period = 50 * _speed; vga_period = 50;
_rnd.getRandomNumber(2); _rnd.getRandomNumber(2);
@ -2047,12 +2023,11 @@ void SimonEngine::delay(uint amount) {
if (amount == 0) if (amount == 0)
break; break;
{ this_delay = _fastMode ? 1 : 20;
this_delay = _fastMode ? 1 : 20 * _speed; if (this_delay > amount)
if (this_delay > amount) this_delay = amount;
this_delay = amount; _system->delayMillis(this_delay);
_system->delayMillis(this_delay);
}
cur = _system->getMillis(); cur = _system->getMillis();
} while (cur < start + amount); } while (cur < start + amount);
} }
@ -2060,28 +2035,31 @@ void SimonEngine::delay(uint amount) {
void SimonEngine::loadMusic(uint music) { void SimonEngine::loadMusic(uint music) {
char buf[4]; char buf[4];
if (getPlatform() == Common::kPlatformAmiga) { if (getGameType() == GType_SIMON2) { // Simon 2 music
if (getFeatures() & GF_CRUNCHED) {
// TODO Add support for decruncher
debug(5,"loadMusic - Decrunch %dtune attempt", music);
}
// TODO Add Protracker support for simon1amiga/cd32
debug(5,"playMusic - Load %dtune attempt", music);
} else if (getGameType() == GType_SIMON2) { // Simon 2 music
midi.stop(); midi.stop();
_gameFile->seek(_gameOffsetsPtr[MUSIC_INDEX_BASE + music - 1], SEEK_SET); _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
_gameFile->read(buf, 4); _gameFile->read(buf, 4);
if (!memcmp(buf, "FORM", 4)) { if (!memcmp(buf, "FORM", 4)) {
_gameFile->seek(_gameOffsetsPtr[MUSIC_INDEX_BASE + music - 1], SEEK_SET); _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
midi.loadXMIDI (_gameFile); midi.loadXMIDI (_gameFile);
} else { } else {
_gameFile->seek(_gameOffsetsPtr[MUSIC_INDEX_BASE + music - 1], SEEK_SET); _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
midi.loadMultipleSMF (_gameFile); midi.loadMultipleSMF (_gameFile);
} }
_lastMusicPlayed = music; _lastMusicPlayed = music;
_nextMusicToPlay = -1; _nextMusicToPlay = -1;
} else if (getGameType() == GType_SIMON1) { // Simon 1 music } else if (getGameType() == GType_SIMON1) { // Simon 1 music
if (getPlatform() == Common::kPlatformAmiga) {
if (getFeatures() & GF_CRUNCHED) {
// TODO Add support for decruncher
debug(5,"loadMusic - Decrunch %dtune attempt", music);
}
// TODO Add Protracker support for simon1amiga/cd32
debug(5,"playMusic - Load %dtune attempt", music);
return;
}
midi.stop(); midi.stop();
midi.setLoop (true); // Must do this BEFORE loading music. (GMF may have its own override.) midi.setLoop (true); // Must do this BEFORE loading music. (GMF may have its own override.)
@ -2094,13 +2072,13 @@ void SimonEngine::loadMusic(uint music) {
if (music == 35) if (music == 35)
midi.setLoop (false); midi.setLoop (false);
_gameFile->seek(_gameOffsetsPtr[MUSIC_INDEX_BASE + music], SEEK_SET); _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET);
_gameFile->read(buf, 4); _gameFile->read(buf, 4);
if (!memcmp(buf, "GMF\x1", 4)) { if (!memcmp(buf, "GMF\x1", 4)) {
_gameFile->seek(_gameOffsetsPtr[MUSIC_INDEX_BASE + music], SEEK_SET); _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET);
midi.loadSMF (_gameFile, music); midi.loadSMF (_gameFile, music);
} else { } else {
_gameFile->seek(_gameOffsetsPtr[MUSIC_INDEX_BASE + music], SEEK_SET); _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET);
midi.loadMultipleSMF (_gameFile); midi.loadMultipleSMF (_gameFile);
} }

View file

@ -179,14 +179,14 @@ protected:
uint32 *_gameOffsetsPtr; uint32 *_gameOffsetsPtr;
uint VGA_DELAY_BASE; uint _vgaBaseDelay;
uint TABLE_INDEX_BASE; uint _tableIndexBase;
uint TEXT_INDEX_BASE; uint _textIndexBase;
uint NUM_VIDEO_OP_CODES; uint _numVideoOpcodes;
uint VGA_MEM_SIZE; uint _vgaMemSize;
uint TABLES_MEM_SIZE; uint _tableMemSize;
uint MUSIC_INDEX_BASE; uint _musicIndexBase;
uint SOUND_INDEX_BASE; uint _soundIndexBase;
const GameSpecificSettings *gss; const GameSpecificSettings *gss;
byte _keyPressed; byte _keyPressed;
@ -253,7 +253,6 @@ protected:
bool _inCallBack; bool _inCallBack;
bool _cepeFlag; bool _cepeFlag;
byte _copyPartialMode; byte _copyPartialMode;
uint _speed;
bool _fastMode; bool _fastMode;
bool _useBackGround; bool _useBackGround;
@ -268,7 +267,6 @@ protected:
bool _dumpImages; bool _dumpImages;
bool _speech; bool _speech;
bool _subtitles; bool _subtitles;
bool _fade;
bool _vgaVar9; bool _vgaVar9;
int16 _chanceModifier; int16 _chanceModifier;
bool _restoreWindow6; bool _restoreWindow6;
@ -446,7 +444,6 @@ protected:
MidiPlayer midi; MidiPlayer midi;
bool _native_mt32; bool _native_mt32;
int _numScreenUpdates;
int _vgaTickCounter; int _vgaTickCounter;
MoviePlayer *_moviePlay; MoviePlayer *_moviePlay;

View file

@ -112,7 +112,7 @@ uint SimonEngine::loadTextFile_gme(const char *filename, byte *dst) {
uint32 offs; uint32 offs;
uint32 size; uint32 size;
res = atoi(filename + 4) + TEXT_INDEX_BASE - 1; res = atoi(filename + 4) + _textIndexBase - 1;
offs = _gameOffsetsPtr[res]; offs = _gameOffsetsPtr[res];
size = _gameOffsetsPtr[res + 1] - offs; size = _gameOffsetsPtr[res + 1] - offs;

View file

@ -91,7 +91,7 @@ File *SimonEngine::openTablesFile_gme(const char *filename) {
uint res; uint res;
uint32 offs; uint32 offs;
res = atoi(filename + 6) + TABLE_INDEX_BASE - 1; res = atoi(filename + 6) + _tableIndexBase - 1;
offs = _gameOffsetsPtr[res]; offs = _gameOffsetsPtr[res];
_gameFile->seek(offs, SEEK_SET); _gameFile->seek(offs, SEEK_SET);
@ -138,7 +138,7 @@ void SimonEngine::loadTablesIntoMem(uint subr_id) {
if (getGameType() == GType_FF) { if (getGameType() == GType_FF) {
// TODO // TODO
} else if (getGameType() == GType_SIMON2) { } else if (getGameType() == GType_SIMON2) {
_sound->loadSfxTable(_gameFile, _gameOffsetsPtr[atoi(filename + 6) - 1 + SOUND_INDEX_BASE]); _sound->loadSfxTable(_gameFile, _gameOffsetsPtr[atoi(filename + 6) - 1 + _soundIndexBase]);
} else if (getPlatform() == Common::kPlatformWindows) { } else if (getPlatform() == Common::kPlatformWindows) {
memcpy(filename, "SFXXXX", 6); memcpy(filename, "SFXXXX", 6);
_sound->readSfxFile(filename); _sound->readSfxFile(filename);

View file

@ -143,7 +143,7 @@ void SimonEngine::runVgaScript() {
opcode = *_vcPtr++; opcode = *_vcPtr++;
} }
if (opcode >= NUM_VIDEO_OP_CODES) if (opcode >= _numVideoOpcodes)
error("Invalid VGA opcode '%d' encountered", opcode); error("Invalid VGA opcode '%d' encountered", opcode);
if (opcode == 0) if (opcode == 0)
@ -455,9 +455,9 @@ void SimonEngine::vc3_loadSprite() {
} }
if (getGameType() == GType_FF) { if (getGameType() == GType_FF) {
addVgaEvent(VGA_DELAY_BASE, _curVgaFile1 + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, res); addVgaEvent(_vgaBaseDelay, _curVgaFile1 + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, res);
} else { } else {
addVgaEvent(VGA_DELAY_BASE, _curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, res); addVgaEvent(_vgaBaseDelay, _curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, res);
} }
_curVgaFile1 = old_file_1; _curVgaFile1 = old_file_1;
@ -1487,7 +1487,7 @@ void SimonEngine::vc12_delay() {
if ((getGameType() == GType_SIMON1) && vsp->id == 128) if ((getGameType() == GType_SIMON1) && vsp->id == 128)
num = 0; num = 0;
else else
num += VGA_DELAY_BASE; num += _vgaBaseDelay;
addVgaEvent(num, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum); addVgaEvent(num, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum);
_vcPtr = (byte *)&_vc_get_out_of_code; _vcPtr = (byte *)&_vc_get_out_of_code;
@ -1510,7 +1510,7 @@ void SimonEngine::vc15_sync() {
uint16 id = vcReadNextWord(); uint16 id = vcReadNextWord();
while (vfs->ident != 0) { while (vfs->ident != 0) {
if (vfs->ident == id) { if (vfs->ident == id) {
addVgaEvent(VGA_DELAY_BASE, vfs->code_ptr, vfs->sprite_id, vfs->cur_vga_file); addVgaEvent(_vgaBaseDelay, vfs->code_ptr, vfs->sprite_id, vfs->cur_vga_file);
vfs_tmp = vfs; vfs_tmp = vfs;
do { do {
memcpy(vfs_tmp, vfs_tmp + 1, sizeof(VgaSleepStruct)); memcpy(vfs_tmp, vfs_tmp + 1, sizeof(VgaSleepStruct));
@ -2087,7 +2087,7 @@ void SimonEngine::vc55_moveBox() {
void SimonEngine::vc56_delay() { void SimonEngine::vc56_delay() {
uint16 num = vcReadVarOrWord() * _frameRate; uint16 num = vcReadVarOrWord() * _frameRate;
addVgaEvent(num + VGA_DELAY_BASE, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum); addVgaEvent(num + _vgaBaseDelay, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum);
_vcPtr = (byte *)&_vc_get_out_of_code; _vcPtr = (byte *)&_vc_get_out_of_code;
} }
@ -2217,8 +2217,7 @@ void SimonEngine::vc62_fastFadeOut() {
for (i = NUM_PALETTE_FADEOUT; i != 0; --i) { for (i = NUM_PALETTE_FADEOUT; i != 0; --i) {
paletteFadeOut((uint32 *)_videoBuf1, _videoNumPalColors); paletteFadeOut((uint32 *)_videoBuf1, _videoNumPalColors);
_system->setPalette(_videoBuf1, 0, _videoNumPalColors); _system->setPalette(_videoBuf1, 0, _videoNumPalColors);
if (_fade) _system->updateScreen();
_system->updateScreen();
delay(5); delay(5);
} }