diff options
author | Travis Howell | 2006-04-21 00:18:23 +0000 |
---|---|---|
committer | Travis Howell | 2006-04-21 00:18:23 +0000 |
commit | b80ef2cd8fddc0cf78ec1fbd283c79578fc08234 (patch) | |
tree | a136b64171aeac8ebe483e86b82f99384daf452d | |
parent | 564727be2cb68a758da61a8ebac32f16cb3f8ee3 (diff) | |
download | scummvm-rg350-b80ef2cd8fddc0cf78ec1fbd283c79578fc08234.tar.gz scummvm-rg350-b80ef2cd8fddc0cf78ec1fbd283c79578fc08234.tar.bz2 scummvm-rg350-b80ef2cd8fddc0cf78ec1fbd283c79578fc08234.zip |
Add some code for PanEvent in FF and cleanup
svn-id: r22062
-rw-r--r-- | engines/simon/icons.cpp | 4 | ||||
-rw-r--r-- | engines/simon/items.cpp | 14 | ||||
-rw-r--r-- | engines/simon/res.cpp | 56 | ||||
-rw-r--r-- | engines/simon/simon.cpp | 254 | ||||
-rw-r--r-- | engines/simon/simon.h | 37 | ||||
-rw-r--r-- | engines/simon/string.cpp | 6 | ||||
-rw-r--r-- | engines/simon/verb.cpp | 2 | ||||
-rw-r--r-- | engines/simon/vga.cpp | 55 |
8 files changed, 215 insertions, 213 deletions
diff --git a/engines/simon/icons.cpp b/engines/simon/icons.cpp index a6a133ba39..8bb28258a7 100644 --- a/engines/simon/icons.cpp +++ b/engines/simon/icons.cpp @@ -491,7 +491,7 @@ void SimonEngine::defineArrowBoxes(WindowBlock *window) { ha->window = window; ha->verb = 1; - kill_sprite_simon1(128); + stopAnimateSimon1(128); loadSprite(0, 1, 128, 0, 0, 14); } } @@ -575,7 +575,7 @@ void SimonEngine::removeIconArray(uint num) { } void SimonEngine::removeArrows(WindowBlock *window, uint num) { - kill_sprite_simon1(128); + stopAnimateSimon1(128); } } // End of namespace Simon diff --git a/engines/simon/items.cpp b/engines/simon/items.cpp index 8b0de816c4..d973bb86b6 100644 --- a/engines/simon/items.cpp +++ b/engines/simon/items.cpp @@ -1311,7 +1311,7 @@ void SimonEngine::o_screenTextMsg() { if (_speech && speechId != 0) playSpeech(speechId, vgaSpriteId); if ((getGameType() == GType_SIMON2) && (getFeatures() & GF_TALKIE) && speechId == 0) - kill_sprite_simon2(2, vgaSpriteId + 2); + stopAnimateSimon2(2, vgaSpriteId + 2); if (string_ptr != NULL && (speechId == 0 || _subtitles)) printScreenText(vgaSpriteId, color, (const char *)string_ptr, tl->x, tl->y, tl->width); @@ -1549,7 +1549,7 @@ void SimonEngine::o1_animate() { void SimonEngine::o1_stopAnimate() { // 99: kill sprite - kill_sprite_simon1(getVarOrWord()); + stopAnimateSimon1(getVarOrWord()); } void SimonEngine::o1_playTune() { @@ -1583,7 +1583,7 @@ void SimonEngine::o1_loadBeard() { if (_beardLoaded == false) { _beardLoaded = true; _lockWord |= 0x8000; - read_vga_from_datfile_1(328); + loadSimonVGAFile(328); _lockWord &= ~0x8000; } } @@ -1593,7 +1593,7 @@ void SimonEngine::o1_unloadBeard() { if (_beardLoaded == true) { _beardLoaded = false; _lockWord |= 0x8000; - read_vga_from_datfile_1(23); + loadSimonVGAFile(23); _lockWord &= ~0x8000; } } @@ -1654,7 +1654,7 @@ void SimonEngine::o2_stopAnimate() { // 99: kill sprite uint a = getVarOrWord(); uint b = getVarOrWord(); - kill_sprite_simon2(a, b); + stopAnimateSimon2(a, b); } void SimonEngine::o2_playTune() { @@ -2274,7 +2274,7 @@ void SimonEngine::setTextColor(uint color) { window->text_color = color; } -void SimonEngine::kill_sprite_simon1(uint a) { +void SimonEngine::stopAnimateSimon1(uint a) { uint16 b = to16Wrapper(a); _lockWord |= 0x8000; _vcPtr = (byte *)&b; @@ -2282,7 +2282,7 @@ void SimonEngine::kill_sprite_simon1(uint a) { _lockWord &= ~0x8000; } -void SimonEngine::kill_sprite_simon2(uint a, uint b) { +void SimonEngine::stopAnimateSimon2(uint a, uint b) { uint16 items[2]; items[0] = to16Wrapper(a); diff --git a/engines/simon/res.cpp b/engines/simon/res.cpp index e67258b464..96e1663371 100644 --- a/engines/simon/res.cpp +++ b/engines/simon/res.cpp @@ -439,6 +439,44 @@ byte *SimonEngine::readSingleOpcode(Common::File *in, byte *ptr) { } } +void SimonEngine::openGameFile() { + if (!(getFeatures() & GF_OLD_BUNDLE)) { + _gameFile = new File(); + _gameFile->open(gss->gme_filename); + + if (_gameFile->isOpen() == false) + error("Can't open game file '%s'", gss->gme_filename); + + uint32 size = _gameFile->readUint32LE(); + + _gameOffsetsPtr = (uint32 *)malloc(size); + if (_gameOffsetsPtr == NULL) + error("out of memory, game offsets"); + + readGameFile(_gameOffsetsPtr, 0, size); +#if defined(SCUMM_BIG_ENDIAN) + for (uint r = 0; r < size / 4; r++) + _gameOffsetsPtr[r] = FROM_LE_32(_gameOffsetsPtr[r]); +#endif + } + + if (getGameType() == GType_FF) + loadIconData(); + else + loadIconFile(); + + vc34_setMouseOff(); + + runSubroutine101(); + permitInput(); +} + +void SimonEngine::readGameFile(void *dst, uint32 offs, uint32 size) { + _gameFile->seek(offs, SEEK_SET); + if (_gameFile->read(dst, size) != size) + error("readGameFile(%d,%d) read failed", offs, size); +} + // Thanks to Stuart Caie for providing the original // C conversion upon which this decruncher is based. @@ -556,7 +594,7 @@ static bool decrunchFile(byte *src, byte *dst, uint32 size) { #undef SD_TYPE_LITERAL #undef SD_TYPE_MATCH -void SimonEngine::read_vga_from_datfile_1(uint vga_id) { +void SimonEngine::loadSimonVGAFile(uint vga_id) { uint32 offs, size; if (getFeatures() & GF_OLD_BUNDLE) { @@ -578,25 +616,25 @@ void SimonEngine::read_vga_from_datfile_1(uint vga_id) { in.open(filename); if (in.isOpen() == false) - error("read_vga_from_datfile_1: can't open %s", filename); + error("loadSimonVGAFile: can't open %s", filename); size = in.size(); if (getFeatures() & GF_CRUNCHED) { byte *srcBuffer = (byte *)malloc(size); if (in.read(srcBuffer, size) != size) - error("read_vga_from_datfile_1: read failed"); + error("loadSimonVGAFile: read failed"); decrunchFile(srcBuffer, _vgaBufferPointers[11].vgaFile2, size); free(srcBuffer); } else { if (in.read(_vgaBufferPointers[11].vgaFile2, size) != size) - error("read_vga_from_datfile_1: read failed"); + error("loadSimonVGAFile: read failed"); } in.close(); } else { offs = _gameOffsetsPtr[vga_id]; size = _gameOffsetsPtr[vga_id + 1] - offs; - resfile_read(_vgaBufferPointers[11].vgaFile2, offs, size); + readGameFile(_vgaBufferPointers[11].vgaFile2, offs, size); } } @@ -668,19 +706,13 @@ byte *SimonEngine::loadVGAFile(uint id, uint type, uint &dstSize) { dstSize = _gameOffsetsPtr[id + 1] - offs; dst = allocBlock(dstSize + extraBuffer); - resfile_read(dst, offs, dstSize); + readGameFile(dst, offs, dstSize); } dstSize += extraBuffer; return dst; } -void SimonEngine::resfile_read(void *dst, uint32 offs, uint32 size) { - _gameFile->seek(offs, SEEK_SET); - if (_gameFile->read(dst, size) != size) - error("resfile_read(%d,%d) read failed", offs, size); -} - void SimonEngine::loadSound(uint sound, uint pan, uint vol, uint type) { byte *dst; diff --git a/engines/simon/simon.cpp b/engines/simon/simon.cpp index dc9e6140fd..c1982c0901 100644 --- a/engines/simon/simon.cpp +++ b/engines/simon/simon.cpp @@ -1339,7 +1339,7 @@ uint SimonEngine::loadTextFile_gme(const char *filename, byte *dst) { offs = _gameOffsetsPtr[res]; size = _gameOffsetsPtr[res + 1] - offs; - resfile_read(dst, offs, size); + readGameFile(dst, offs, size); return size; } @@ -1796,7 +1796,7 @@ void SimonEngine::displayBoxStars() { ha = _hitAreas; count = ARRAYSIZE(_hitAreas); - timer_vga_sprites(); + animateSprites(); do { if (ha->id != 0 && ha->flags & kBFBoxInUse && !(ha->flags & kBFBoxDead)) { @@ -1866,7 +1866,7 @@ void SimonEngine::displayBoxStars() { dx_update_screen_and_palette(); delay(100); - timer_vga_sprites(); + animateSprites(); dx_update_screen_and_palette(); delay(100); } @@ -1979,7 +1979,6 @@ void SimonEngine::hitarea_stuff_helper() { } } -// Simon 2 specific void SimonEngine::hitarea_stuff_helper_2() { uint subr_id; Subroutine *sub; @@ -2334,7 +2333,7 @@ void SimonEngine::set_video_mode_internal(uint mode, uint vga_res_id) { } //dump_vga_script(_vcPtr, num, vga_res_id); - run_vga_script(); + runVgaScript(); _vcPtr = vc_ptr_org; @@ -2399,7 +2398,34 @@ void SimonEngine::fadeToBlack() { memcpy(_palette, _videoBuf1, 1024); } -void SimonEngine::delete_vga_timer(VgaTimerEntry * vte) { +void SimonEngine::addVgaEvent(uint16 num, const byte *code_ptr, uint16 cur_sprite, uint16 curZoneNum, int32 param) { + VgaTimerEntry *vte; + + // When Simon talks to the Golum about stew in French version of + // Simon the Sorcerer 1 the code_ptr is at wrong location for + // sprite 200. This was a bug in the original game, which + // caused several glitches in this scene. + // We work around the problem by correcting the code_ptr for sprite + // 200 in this scene, if it is wrong. + if (getGameType() == GType_SIMON1 && _language == Common::FR_FRA && + (code_ptr - _vgaBufferPointers[curZoneNum].vgaFile1 == 4) && (cur_sprite == 200) && (curZoneNum == 2)) + code_ptr += 0x66; + + _lockWord |= 1; + + for (vte = _vgaTimerList; vte->delay; vte++) { + } + + vte->delay = num; + vte->script_pointer = code_ptr; + vte->sprite_id = cur_sprite; + vte->cur_vga_file = curZoneNum; + vte->param = param; + + _lockWord &= ~1; +} + +void SimonEngine::deleteVgaEvent(VgaTimerEntry * vte) { _lockWord |= 1; if (vte + 1 <= _nextVgaTimerToProcess) { @@ -2414,7 +2440,7 @@ void SimonEngine::delete_vga_timer(VgaTimerEntry * vte) { _lockWord &= ~1; } -void SimonEngine::expire_vga_timers() { +void SimonEngine::processVgaEvents() { VgaTimerEntry *vte = _vgaTimerList; uint timer = (getGameType() == GType_FF) ? 5 : 1; @@ -2423,18 +2449,20 @@ void SimonEngine::expire_vga_timers() { while (vte->delay) { vte->delay -= timer; if (vte->delay <= 0) { - uint16 cur_file = vte->cur_vga_file; + uint16 curZoneNum = vte->cur_vga_file; uint16 cur_sprite = vte->sprite_id; const byte *script_ptr = vte->script_pointer; + int32 param = vte->param; _nextVgaTimerToProcess = vte + 1; - delete_vga_timer(vte); + deleteVgaEvent(vte); - if ((getGameType() == GType_SIMON2) && script_ptr == NULL) { - // special scroll timer - scroll_timeout(); + if (getGameType() == GType_FF && script_ptr == NULL) { + panEvent(curZoneNum, cur_sprite, param); + } else if (getGameType() == GType_SIMON2 && script_ptr == NULL) { + scrollEvent(); } else { - vcResumeSprite(script_ptr, cur_file, cur_sprite); + animateEvent(script_ptr, curZoneNum, cur_sprite); } vte = _nextVgaTimerToProcess; } else { @@ -2443,8 +2471,46 @@ void SimonEngine::expire_vga_timers() { } } -// Simon2 specific -void SimonEngine::scroll_timeout() { +void SimonEngine::animateEvent(const byte *code_ptr, uint16 curZoneNum, uint16 cur_sprite) { + VgaPointersEntry *vpe; + + _vgaCurSpriteId = cur_sprite; + + _vgaCurZoneNum = curZoneNum; + _zoneNumber = curZoneNum; + vpe = &_vgaBufferPointers[curZoneNum]; + + _curVgaFile1 = vpe->vgaFile1; + _curVgaFile2 = vpe->vgaFile2; + _curSfxFile = vpe->sfxFile; + + _vcPtr = code_ptr; + + runVgaScript(); +} + +void SimonEngine::panEvent(uint16 curZoneNum, uint16 cur_sprite, int32 param) { + _vgaCurSpriteId = cur_sprite; + _vgaCurZoneNum = curZoneNum; + + VgaSprite *vsp = findCurSprite(); + + param &= 0x10; + + int32 pan = (vsp->x - _scrollX + param) * 8 - 2560; + if (pan < -10000) + pan = -10000; + if (pan > 10000) + pan = 10000; + + //setSfxPan(param, pan); + + if (pan != 0) + addVgaEvent(10, NULL, _vgaCurSpriteId, _vgaCurZoneNum); /* pan event */ + debug(0, "panEvent: param %d pan %d", param, pan); +} + +void SimonEngine::scrollEvent() { if (_scrollCount == 0) return; @@ -2475,52 +2541,8 @@ void SimonEngine::scroll_timeout() { } } - add_vga_timer(6, NULL, 0, 0); - } -} - -void SimonEngine::vcResumeSprite(const byte *code_ptr, uint16 cur_file, uint16 cur_sprite) { - VgaPointersEntry *vpe; - - _vgaCurSpriteId = cur_sprite; - - _vgaCurZoneNum = cur_file; - _zoneNumber = cur_file; - vpe = &_vgaBufferPointers[cur_file]; - - _curVgaFile1 = vpe->vgaFile1; - _curVgaFile2 = vpe->vgaFile2; - _curSfxFile = vpe->sfxFile; - - _vcPtr = code_ptr; - - run_vga_script(); -} - -void SimonEngine::add_vga_timer(uint num, const byte *code_ptr, uint cur_sprite, uint cur_file) { - VgaTimerEntry *vte; - - // When Simon talks to the Golum about stew in French version of - // Simon the Sorcerer 1 the code_ptr is at wrong location for - // sprite 200. This was a bug in the original game, which - // caused several glitches in this scene. - // We work around the problem by correcting the code_ptr for sprite - // 200 in this scene, if it is wrong. - if (getGameType() == GType_SIMON1 && _language == Common::FR_FRA && - (code_ptr - _vgaBufferPointers[cur_file].vgaFile1 == 4) && (cur_sprite == 200) && (cur_file == 2)) - code_ptr += 0x66; - - _lockWord |= 1; - - for (vte = _vgaTimerList; vte->delay; vte++) { + addVgaEvent(6, NULL, 0, 0); /* scroll event */ } - - vte->delay = num; - vte->script_pointer = code_ptr; - vte->sprite_id = cur_sprite; - vte->cur_vga_file = cur_file; - - _lockWord &= ~1; } void SimonEngine::waitForSync(uint a) { @@ -2562,17 +2584,17 @@ void SimonEngine::skipSpeech() { _variableArray[103] = 5; loadSprite(4, 2, 13, 0, 0, 0); waitForSync(213); - kill_sprite_simon2(2, 1); + stopAnimateSimon2(2, 1); } else { _variableArray[100] = 5; loadSprite(4, 1, 30, 0, 0, 0); waitForSync(130); - kill_sprite_simon2(2, 1); + stopAnimateSimon2(2, 1); } } } -void SimonEngine::timer_vga_sprites() { +void SimonEngine::animateSprites() { VgaSprite *vsp; VgaPointersEntry *vpe; const byte *vc_ptr_org = _vcPtr; @@ -2582,10 +2604,10 @@ void SimonEngine::timer_vga_sprites() { _paletteFlag = 1; if (getGameType() == GType_FF && _scrollCount) { - scroll_timeout(); + scrollEvent(); } if (getGameType() == GType_SIMON2 && _scrollFlag) { - scrollEvent(); + scrollScreen(); } if (getGameType() == GType_FF && getBitFlag(84)) { @@ -2606,6 +2628,9 @@ void SimonEngine::timer_vga_sprites() { _vgaCurSpriteId = vsp->id; _vgaCurSpritePriority = vsp->priority; + if (_drawImagesDebug && vsp->image) + fprintf(_dumpFile, "id:%5d image:%3d base-color:%3d x:%3d y:%3d flags:%x\n", + vsp->id, vsp->image, vsp->palette, vsp->x, vsp->y, vsp->flags); params[0] = readUint16Wrapper(&vsp->image); params[1] = readUint16Wrapper(&vsp->palette); params[2] = readUint16Wrapper(&vsp->x); @@ -2630,7 +2655,7 @@ void SimonEngine::timer_vga_sprites() { _vcPtr = vc_ptr_org; } -void SimonEngine::scrollEvent() { +void SimonEngine::scrollScreen() { byte *dst = getFrontBuf(); const byte *src; uint x, y; @@ -2686,44 +2711,6 @@ void SimonEngine::scrollEvent() { _scrollFlag = 0; } -void SimonEngine::timer_vga_sprites_2() { - VgaSprite *vsp; - VgaPointersEntry *vpe; - const byte *vc_ptr_org = _vcPtr; - uint16 params[5]; // parameters to vc10_draw - - if (_paletteFlag == 2) - _paletteFlag = 1; - - vsp = _vgaSprites; - while (vsp->id != 0) { - vsp->windowNum &= 0x7FFF; - - vpe = &_vgaBufferPointers[vsp->zoneNum]; - _curVgaFile1 = vpe->vgaFile1; - _curVgaFile2 = vpe->vgaFile2; - _curSfxFile = vpe->sfxFile; - _windowNum = vsp->windowNum; - _vgaCurSpriteId = vsp->id; - - if (vsp->image) - fprintf(_dumpFile, "id:%5d image:%3d base-color:%3d x:%3d y:%3d flags:%x\n", - vsp->id, vsp->image, vsp->palette, vsp->x, vsp->y, vsp->flags); - params[0] = readUint16Wrapper(&vsp->image); - params[1] = readUint16Wrapper(&vsp->palette); - params[2] = readUint16Wrapper(&vsp->x); - params[3] = readUint16Wrapper(&vsp->y); - params[4] = readUint16Wrapper(&vsp->flags); - _vcPtr = (const byte *)params; - vc10_draw(); - - vsp++; - } - - _updateScreen++; - _vcPtr = vc_ptr_org; -} - void SimonEngine::timer_proc1() { _timer4++; @@ -2739,14 +2726,14 @@ void SimonEngine::timer_proc1() { _syncFlag2 ^= 1; if (!_syncFlag2) - expire_vga_timers(); + processVgaEvents(); } else { - expire_vga_timers(); - expire_vga_timers(); + processVgaEvents(); + processVgaEvents(); _syncFlag2 ^= 1; _cepeFlag ^= 1; if (!_cepeFlag) - expire_vga_timers(); + processVgaEvents(); if (_mouseHideCount != 0 && _syncFlag2) { _lockWord &= ~2; @@ -2755,16 +2742,13 @@ void SimonEngine::timer_proc1() { } } - timer_vga_sprites(); - if (_drawImagesDebug) - timer_vga_sprites_2(); + animateSprites(); if (_copyPartialMode == 1) { fillBackFromFront(80, 46, 208 - 80, 94 - 46); } if (_copyPartialMode == 2) { - // copy partial from attached to 2 fillFrontFromBack(176, 61, _screenWidth - 176, 134 - 61); _copyPartialMode = 0; } @@ -3222,7 +3206,7 @@ void SimonEngine::loadSprite(uint windowNum, uint zoneNum, uint vgaSpriteId, uin if (_startVgaScript) dump_vga_script(pp + READ_LE_UINT16(&((AnimationHeader_Feeble*)p)->scriptOffs), zoneNum, vgaSpriteId); - add_vga_timer(VGA_DELAY_BASE, pp + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, zoneNum); + addVgaEvent(VGA_DELAY_BASE, pp + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, zoneNum); break; } p += sizeof(AnimationHeader_Feeble); @@ -3231,7 +3215,7 @@ void SimonEngine::loadSprite(uint windowNum, uint zoneNum, uint vgaSpriteId, uin if (_startVgaScript) dump_vga_script(pp + READ_BE_UINT16(&((AnimationHeader_Simon*)p)->scriptOffs), zoneNum, vgaSpriteId); - add_vga_timer(VGA_DELAY_BASE, pp + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, zoneNum); + addVgaEvent(VGA_DELAY_BASE, pp + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, zoneNum); break; } p += sizeof(AnimationHeader_Simon); @@ -3262,9 +3246,9 @@ void SimonEngine::playSpeech(uint speech_id, uint vgaSpriteId) { if (_subtitles && _scriptVar2) { loadSprite(4, 2, 204, 0, 0, 0); waitForSync(204); - kill_sprite_simon1(204); + stopAnimateSimon1(204); } - kill_sprite_simon1(vgaSpriteId + 201); + stopAnimateSimon1(vgaSpriteId + 201); loadVoice(speech_id); loadSprite(4, 2, vgaSpriteId + 201, 0, 0, 0); } @@ -3288,48 +3272,16 @@ void SimonEngine::playSpeech(uint speech_id, uint vgaSpriteId) { if (_subtitles && _scriptVar2) { loadSprite(4, 2, 5, 0, 0, 0); waitForSync(205); - kill_sprite_simon2(2,5); + stopAnimateSimon2(2,5); } - kill_sprite_simon2(2, vgaSpriteId + 2); + stopAnimateSimon2(2, vgaSpriteId + 2); loadVoice(speech_id); loadSprite(4, 2, vgaSpriteId + 2, 0, 0, 0); } } } -void SimonEngine::openGameFile() { - if (!(getFeatures() & GF_OLD_BUNDLE)) { - _gameFile = new File(); - _gameFile->open(gss->gme_filename); - - if (_gameFile->isOpen() == false) - error("Can't open game file '%s'", gss->gme_filename); - - uint32 size = _gameFile->readUint32LE(); - - _gameOffsetsPtr = (uint32 *)malloc(size); - if (_gameOffsetsPtr == NULL) - error("out of memory, game offsets"); - - resfile_read(_gameOffsetsPtr, 0, size); -#if defined(SCUMM_BIG_ENDIAN) - for (uint r = 0; r < size / 4; r++) - _gameOffsetsPtr[r] = FROM_LE_32(_gameOffsetsPtr[r]); -#endif - } - - if (getGameType() == GType_FF) - loadIconData(); - else - loadIconFile(); - - vc34_setMouseOff(); - - runSubroutine101(); - permitInput(); -} - void SimonEngine::runSubroutine101() { Subroutine *sub; @@ -3419,7 +3371,7 @@ void SimonEngine::dx_update_screen_and_palette() { memcpy(_backBuf, _frontBuf, _screenWidth * _screenHeight); if (getGameType() == GType_FF && _scrollFlag) { - scrollEvent(); + scrollScreen(); } if (_paletteColorCount != 0) { diff --git a/engines/simon/simon.h b/engines/simon/simon.h index 9afc0d3056..19b30211a1 100644 --- a/engines/simon/simon.h +++ b/engines/simon/simon.h @@ -107,6 +107,7 @@ struct VgaTimerEntry { const byte *script_pointer; uint16 sprite_id; uint16 cur_vga_file; + int32 param; VgaTimerEntry() { memset(this, 0, sizeof(*this)); } }; @@ -561,11 +562,12 @@ protected: void unlinkItem(Item *item); void linkItem(Item *item, Item *parent); - void kill_sprite_simon1(uint a); - void kill_sprite_simon2(uint a, uint b); + void stopAnimateSimon1(uint a); + void stopAnimateSimon2(uint a, uint b); void changeWindow(uint a); void closeWindow(uint a); + void enableBox(uint hitarea); void disableBox(uint hitarea); void moveBox(uint hitarea, int x, int y); @@ -573,6 +575,7 @@ protected: void undefineBox(uint hitarea); void defineBox(int id, int x, int y, int width, int height, int flags, int verb, Item *item_ptr); HitArea *findEmptyHitArea(); + void resetVerbs(); void setVerb(HitArea * ha); void hitarea_leave(HitArea * ha, bool state = false); @@ -631,7 +634,6 @@ protected: void invokeTimeEvent(TimeEvent *te); bool kickoffTimeEvents(); - void clearName(); void endCutscene(); void runSubroutine101(); @@ -649,11 +651,10 @@ protected: void clearWindow(WindowBlock *window); void video_toggle_colors(HitArea * ha, byte a, byte b, byte c, byte d); - void read_vga_from_datfile_1(uint vga_id); - uint getWindowNum(WindowBlock *window); void boxController(uint x, uint y, uint mode); + void clearName(); void displayName(HitArea * ha); void displayBoxStars(); void hitarea_stuff(); @@ -677,6 +678,7 @@ protected: void loadIconData(); void loadIconFile(); + void processSpecialKeys(); void hitarea_stuff_helper(); @@ -713,7 +715,7 @@ protected: void setup_vga_file_buf_pointers(); - void run_vga_script(); + void runVgaScript(); public: bool getBitFlag(uint bit); @@ -1007,8 +1009,6 @@ protected: void horizontalScroll(VC10_state *state); void verticalScroll(VC10_state *state); - void delete_vga_timer(VgaTimerEntry * vte); - void vcResumeSprite(const byte *code_ptr, uint16 cur_file, uint16 cur_sprite); int vcReadVarOrWord(); uint vcReadNextWord(); uint vcReadNextByte(); @@ -1025,10 +1025,14 @@ protected: bool itemIsParentOf(uint16 a, uint16 b); bool vc_maybe_skip_proc_1(uint16 a, int16 b); - void add_vga_timer(uint num, const byte *code_ptr, uint cur_sprite, uint cur_file); - VgaSprite *findCurSprite(); + void addVgaEvent(uint16 num, const byte *code_ptr, uint16 cur_sprite, uint16 curZoneNum, int32 param = 0); + void deleteVgaEvent(VgaTimerEntry * vte); + void processVgaEvents(); + void animateEvent(const byte *code_ptr, uint16 curZoneNum, uint16 cur_sprite); + void panEvent(uint16 curZoneNum, uint16 cur_sprite, int32 param); + void scrollEvent(); - void expire_vga_timers(); + VgaSprite *findCurSprite(); bool isSpriteLoaded(uint16 id, uint16 zoneNum); @@ -1048,18 +1052,18 @@ protected: byte *getScaleBuf(); byte *loadVGAFile(uint id, uint type, uint &dstSize); - - void resfile_read(void *dst, uint32 offs, uint32 size); + void loadSimonVGAFile(uint vga_id); int init(); int go(); + void openGameFile(); + void readGameFile(void *dst, uint32 offs, uint32 size); void timer_callback(); void timer_proc1(); - void timer_vga_sprites(); - void timer_vga_sprites_2(); + void animateSprites(); void dx_clear_surfaces(uint num_lines); void dx_update_screen_and_palette(); @@ -1103,11 +1107,10 @@ protected: void pause(); void waitForMark(uint i); - void scrollEvent(); + void scrollScreen(); void decodeColumn(byte *dst, const byte *src, int height); void decodeRow(byte *dst, const byte *src, int width); - void scroll_timeout(); void hitarea_stuff_helper_2(); void fastFadeIn(); void slowFadeIn(); diff --git a/engines/simon/string.cpp b/engines/simon/string.cpp index cffebd0c67..ee709e88b2 100644 --- a/engines/simon/string.cpp +++ b/engines/simon/string.cpp @@ -172,7 +172,7 @@ void SimonEngine::printInteractText(uint16 num, const char *string) { _variableArray[53] = w; _variableArray[54] = height; - kill_sprite_simon2(2, num + 6); + stopAnimateSimon2(2, num + 6); renderString(num, 0, w, height, convertedString); loadSprite(4, 2, num + 6, x, _interactY, 12); @@ -294,9 +294,9 @@ void SimonEngine::printScreenText(uint vgaSpriteId, uint color, const char *stri } if (getGameType() == GType_SIMON1) - kill_sprite_simon1(vgaSpriteId + 199); + stopAnimateSimon1(vgaSpriteId + 199); else - kill_sprite_simon2(2, vgaSpriteId); + stopAnimateSimon2(2, vgaSpriteId); if (getGameType() == GType_FF) { renderString(1, color, width, height, convertedString); diff --git a/engines/simon/verb.cpp b/engines/simon/verb.cpp index 0fe0486d44..b42b743188 100644 --- a/engines/simon/verb.cpp +++ b/engines/simon/verb.cpp @@ -193,7 +193,7 @@ void SimonEngine::clearName() { HitArea *ha; if (getGameType() == GType_FF) { - kill_sprite_simon2(2, 6); + stopAnimateSimon2(2, 6); _lastNameOn = NULL; _animatePointer = 0; _mouseAnim = 1; diff --git a/engines/simon/vga.cpp b/engines/simon/vga.cpp index 8af321f5e8..79fc13d9de 100644 --- a/engines/simon/vga.cpp +++ b/engines/simon/vga.cpp @@ -124,7 +124,7 @@ void SimonEngine::setupVgaOpcodes() { } // Script parser -void SimonEngine::run_vga_script() { +void SimonEngine::runVgaScript() { for (;;) { uint opcode; @@ -295,7 +295,7 @@ void SimonEngine::vc2_call() { } //dump_vga_script(_vcPtr, res, num); - run_vga_script(); + runVgaScript(); _curVgaFile1 = old_file_1; _curVgaFile2 = old_file_2; @@ -402,9 +402,9 @@ void SimonEngine::vc3_loadSprite() { } if (getGameType() == GType_FF) { - add_vga_timer(VGA_DELAY_BASE, _curVgaFile1 + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, res); + addVgaEvent(VGA_DELAY_BASE, _curVgaFile1 + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, res); } else { - add_vga_timer(VGA_DELAY_BASE, _curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, res); + addVgaEvent(VGA_DELAY_BASE, _curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, res); } _curVgaFile1 = old_file_1; @@ -1436,7 +1436,7 @@ void SimonEngine::vc12_delay() { else num += VGA_DELAY_BASE; - add_vga_timer(num, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum); + addVgaEvent(num, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum); _vcPtr = (byte *)&_vc_get_out_of_code; } @@ -1457,7 +1457,7 @@ void SimonEngine::vc15_sync() { uint16 id = vcReadNextWord(); while (vfs->ident != 0) { if (vfs->ident == id) { - add_vga_timer(VGA_DELAY_BASE, vfs->code_ptr, vfs->sprite_id, vfs->cur_vga_file); + addVgaEvent(VGA_DELAY_BASE, vfs->code_ptr, vfs->sprite_id, vfs->cur_vga_file); vfs_tmp = vfs; do { memcpy(vfs_tmp, vfs_tmp + 1, sizeof(VgaSleepStruct)); @@ -1780,7 +1780,7 @@ void SimonEngine::vc40() { tmp = _scrollXMax - _scrollX; if (tmp < 20) _scrollCount = tmp; - add_vga_timer(6, NULL, 0, 0); /* special timer */ + addVgaEvent(6, NULL, 0, 0); /* scroll event */ } } no_scroll:; @@ -1806,7 +1806,7 @@ void SimonEngine::vc41() { _scrollCount = -20; if (_scrollX < 20) _scrollCount = -_scrollX; - add_vga_timer(6, NULL, 0, 0); /* special timer */ + addVgaEvent(6, NULL, 0, 0); /* scroll event */ } } no_scroll:; @@ -1818,7 +1818,7 @@ void SimonEngine::vc42_delayIfNotEQ() { uint val = vcReadVar(vcReadNextWord()); if (val != vcReadNextWord()) { - add_vga_timer(_frameRate + 1, _vcPtr - 4, _vgaCurSpriteId, _vgaCurZoneNum); + addVgaEvent(_frameRate + 1, _vcPtr - 4, _vgaCurSpriteId, _vgaCurZoneNum); _vcPtr = (byte *)&_vc_get_out_of_code; } } @@ -1984,11 +1984,26 @@ void SimonEngine::vc52_playSound() { } void SimonEngine::vc53_panSFX() { - // Start sound effect, panning it with the animation - int snd = vcReadNextWord(); - int xoffs = vcReadNextWord(); - int vol = vcReadNextWord(); - debug(0, "STUB: vc53_panSFX: snd %d xoffs %d vol %d", snd, xoffs, vol); + VgaSprite *vsp = findCurSprite(); + int32 pan; + + uint16 sound = vcReadNextWord(); + int16 xoffs = vcReadNextWord(); + uint16 vol = vcReadNextWord(); + + pan = (vsp->x - _scrollX + xoffs) * 8 - 2560; + if (pan < -10000) + pan = -10000; + if (pan > 10000) + pan = 10000; + + loadSound(sound, 0, vol, 1); + + if (xoffs != 2) + xoffs |= 0x10; + + addVgaEvent(10, NULL, _vgaCurSpriteId, _vgaCurZoneNum, xoffs); /* pan event */ + debug(0, "vc53_panSFX: snd %d xoffs %d vol %d", sound, xoffs, vol); } void SimonEngine::vc54_no_op() { @@ -2020,7 +2035,7 @@ void SimonEngine::vc55_moveBox() { void SimonEngine::vc56_delay() { uint num = vcReadVarOrWord() * _frameRate; - add_vga_timer(num + VGA_DELAY_BASE, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum); + addVgaEvent(num + VGA_DELAY_BASE, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum); _vcPtr = (byte *)&_vc_get_out_of_code; } @@ -2096,7 +2111,7 @@ void SimonEngine::vc_kill_sprite(uint file, uint sprite) { vte = _vgaTimerList; while (vte->delay != 0) { if (vte->sprite_id == _vgaCurSpriteId && ((getGameType() == GType_SIMON1) || vte->cur_vga_file == _vgaCurZoneNum)) { - delete_vga_timer(vte); + deleteVgaEvent(vte); break; } vte++; @@ -2109,15 +2124,15 @@ void SimonEngine::vc_kill_sprite(uint file, uint sprite) { } void SimonEngine::vc60_killSprite() { - uint file; + uint zoneNum; if (getGameType() == GType_SIMON1) { - file = _vgaCurZoneNum; + zoneNum = _vgaCurZoneNum; } else { - file = vcReadNextWord(); + zoneNum = vcReadNextWord(); } uint sprite = vcReadNextWord(); - vc_kill_sprite(file, sprite); + vc_kill_sprite(zoneNum, sprite); } void SimonEngine::vc61_setMaskImage() { |