diff options
author | Joost Peters | 2003-03-11 18:32:58 +0000 |
---|---|---|
committer | Joost Peters | 2003-03-11 18:32:58 +0000 |
commit | 5af41d1bc657d071fa939bd3f326c3562f4d4850 (patch) | |
tree | 8c02b96a435f2cb261829f3636e74404fae298fa | |
parent | d7f21b46e84c259f28c6382cba1b074fddd52839 (diff) | |
download | scummvm-rg350-5af41d1bc657d071fa939bd3f326c3562f4d4850.tar.gz scummvm-rg350-5af41d1bc657d071fa939bd3f326c3562f4d4850.tar.bz2 scummvm-rg350-5af41d1bc657d071fa939bd3f326c3562f4d4850.zip |
added timers, full cd-intro and fixed some minor issues
svn-id: r6797
-rw-r--r-- | sky/cd_intro.cpp | 629 | ||||
-rw-r--r-- | sky/disk.cpp | 12 | ||||
-rw-r--r-- | sky/module.mk | 1 | ||||
-rw-r--r-- | sky/sky.cpp | 2 | ||||
-rw-r--r-- | sky/sky.h | 14 | ||||
-rw-r--r-- | sky/sound.cpp | 19 | ||||
-rw-r--r-- | sky/sound.h | 8 | ||||
-rw-r--r-- | sky/timer.cpp | 85 |
8 files changed, 746 insertions, 24 deletions
diff --git a/sky/cd_intro.cpp b/sky/cd_intro.cpp index a9f8f61b65..2b9b8f2ee9 100644 --- a/sky/cd_intro.cpp +++ b/sky/cd_intro.cpp @@ -190,12 +190,22 @@ #define cd_104 60097 #define cd_105 60098 +#define START_VOICE ( delay(200), _sound->playVoice(vocBuffer, loadedVocSize) ) +#define START_BG ( _sound->playBgSound(bgVocBuffer, bgVocSize) ) +#define LOAD_NEW_VOICE(num) ( free (vocBuffer), vocBuffer = (byte *)loadFile(num, NULL), loadedVocSize = _lastLoadedFileSize ) +#define LOAD_NEW_BG(num) ( free (bgVocBuffer), bgVocBuffer = (byte *)loadFile(num, NULL), bgVocSize = _lastLoadedFileSize ) +#define WAIT_VOICE while (_sound->_voiceHandle != 0) { delay(50); } +#define WAIT_SEQUENCE while (_tseqFrames != 0) { delay(50); } +#define WAIT_RELATIVE(x) ( delay(20 * (x)) ) +#define COPY_SCREEN ( memcpy(_workScreen, workScreen2, GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT) ) void SkyState::doCDIntro() { uint32 loadedVocSize, bgVocSize; - byte *vocBuffer, *bgVocBuffer, *cd2_seq_data_1; + byte *vocBuffer, *bgVocBuffer, *cd2_seq_data_1, *cd2_seq_data_2; + assert(_isCDVersion); + vocBuffer = (byte *)loadFile(cdv_00, NULL); loadedVocSize = _lastLoadedFileSize; @@ -209,22 +219,623 @@ void SkyState::doCDIntro() { delay(2000); //keep gibbons screen up for 2 seconds fn_fade_down(0); //and fade out - _sound->playVoice(vocBuffer, loadedVocSize); - _sound->playVoice(bgVocBuffer, bgVocSize); + START_VOICE; + START_BG; free (vocBuffer); vocBuffer = (byte *)loadFile(cdv_01, NULL); loadedVocSize = _lastLoadedFileSize; - //waitForVoc(0); - delay(5500); //hack! + WAIT_VOICE; //wait for the voice to finish + START_VOICE; + START_BG; + showScreen(); + paletteFadeUp(_tempPal); + startTimerSequence(cd2_seq_data_1); + LOAD_NEW_VOICE(cdv_02); + WAIT_VOICE; + START_VOICE; + START_BG; + cd2_seq_data_2 = (byte *)loadFile(cd_2, NULL); //load seq 2 while 1 is playing + LOAD_NEW_VOICE(cdv_03); + //WAIT_SEQUENCE; + WAIT_VOICE; + startTimerSequence(cd2_seq_data_2); //start second sequence + START_VOICE; //03 + START_BG; + + LOAD_NEW_VOICE(cdv_04); + + WAIT_VOICE; //03 + START_VOICE; //04 + START_BG; + + free(cd2_seq_data_1); + cd2_seq_data_1 = (byte *)loadFile(cd_3, NULL); + LOAD_NEW_VOICE(cdv_05); + + WAIT_SEQUENCE; //2 + WAIT_VOICE; //4 + + START_VOICE; //5 + START_BG; + + WAIT_RELATIVE(100); + + startTimerSequence(cd2_seq_data_1); + LOAD_NEW_VOICE(cdv_06); + WAIT_VOICE; //5 + START_VOICE; //6 + START_BG; + + free (cd2_seq_data_2); + cd2_seq_data_2 = (byte *)loadFile(cd_5, NULL); + LOAD_NEW_VOICE(cdv_07); + + WAIT_SEQUENCE; //3 + WAIT_VOICE; //6 + + START_VOICE; //7 + startTimerSequence(cd2_seq_data_2); //5 + START_BG; + + LOAD_NEW_VOICE(cdv_08); + WAIT_VOICE; //7 + START_VOICE; //8 + START_BG; + LOAD_NEW_VOICE(cdv_09); + WAIT_VOICE; //8 + START_VOICE; //9 + START_BG; + + free (cd2_seq_data_1); + cd2_seq_data_1 = (byte *)loadFile(cd_7, NULL); + LOAD_NEW_VOICE(cdv_10); + + WAIT_SEQUENCE; //5 + WAIT_VOICE; //9 - _sound->playVoice(vocBuffer, loadedVocSize); - _sound->playVoice(bgVocBuffer, bgVocSize); - free (vocBuffer); + START_VOICE; //10 + startTimerSequence(cd2_seq_data_1); //7 + START_BG; + loadFile(cd_11_pal, _tempPal); + byte *workScreen2 = (byte *)loadFile(cd_11_log, NULL); //need an extra screen or else the sequence will get messed up + free (cd2_seq_data_2); + cd2_seq_data_2 = (byte *)loadFile(cd_11, NULL); + LOAD_NEW_VOICE(cdv_11); + + WAIT_VOICE; //10 + START_VOICE; //11 + START_BG; + + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + + LOAD_NEW_VOICE(cdv_12); + WAIT_SEQUENCE; //7 + WAIT_VOICE; //11 + START_VOICE; //12 + START_BG; + + WAIT_RELATIVE(80); + startTimerSequence(cd2_seq_data_2); //11 + + LOAD_NEW_VOICE(cdv_13); + WAIT_VOICE; //12 + START_VOICE; //13 + START_BG; + + free(cd2_seq_data_1); + cd2_seq_data_1 = (byte *)loadFile(cd_13, NULL); + LOAD_NEW_VOICE(cdv_14); + + LOAD_NEW_BG(59498); + + WAIT_SEQUENCE; //11 + WAIT_VOICE; //13 + + START_VOICE; //14 + startTimerSequence(cd2_seq_data_1); //13 + START_BG; + + LOAD_NEW_VOICE(cdv_15); + loadFile(cd_15_pal, _tempPal); + loadFile(cd_15_log, workScreen2); + + WAIT_SEQUENCE; //13 + WAIT_VOICE; //14 + + START_VOICE; //15 + START_BG; + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + + LOAD_NEW_VOICE(cdv_16); + WAIT_VOICE; //15 + START_VOICE; //16 + START_BG; + + loadFile(cd_17_log, workScreen2); + free (cd2_seq_data_2); + cd2_seq_data_2 = (byte *)loadFile(cd_17, NULL); + LOAD_NEW_VOICE(cdv_17); + + WAIT_VOICE; //16 + START_VOICE; //17 + + WAIT_RELATIVE(40); + COPY_SCREEN; + showScreen(); + + LOAD_NEW_VOICE(cdv_18); + LOAD_NEW_BG(59497); //Loud heli + + WAIT_VOICE; //17 + startTimerSequence(cd2_seq_data_2); //17 + START_VOICE; //18 + START_BG; + + LOAD_NEW_VOICE(cdv_19); + loadFile(cd_19_pal, _tempPal); + loadFile(cd_19_log, workScreen2); + START_BG; + LOAD_NEW_BG(59496); //loud heli to quiet + + WAIT_SEQUENCE; //17 + WAIT_VOICE; //18 + + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + + START_VOICE; //19 + START_BG; + LOAD_NEW_VOICE(cdv_20); + loadFile(cd_20_log, workScreen2); + LOAD_NEW_BG(59496); //quiet heli + + WAIT_VOICE; //19 + START_VOICE; //20 + START_BG; + + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + + LOAD_NEW_VOICE(cdv_21); + loadFile(cd_21_log, workScreen2); + + START_BG; + WAIT_SEQUENCE; //19 + WAIT_VOICE; //20 + START_VOICE; //21 + START_BG; + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + + LOAD_NEW_VOICE(cdv_22); + LOAD_NEW_BG(59494); //heli whine + + WAIT_SEQUENCE; //20 + WAIT_VOICE; //21 + + START_VOICE; //22 + START_BG; + LOAD_NEW_VOICE(cdv_23); + WAIT_VOICE; //22 + START_VOICE; //23 + fn_fade_down(0); + + loadFile(cd_23_pal, _tempPal); + loadFile(cd_24_log, workScreen2); + LOAD_NEW_VOICE(cdv_24); + WAIT_VOICE; //23 + + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + START_VOICE; //24 + showScreen(); + LOAD_NEW_VOICE(cdv_25); + WAIT_VOICE; //24 + START_VOICE; //25 + LOAD_NEW_VOICE(cdv_26); + WAIT_VOICE; //25 + START_VOICE; //26 + + free (cd2_seq_data_1); + cd2_seq_data_1 = (byte *)loadFile(cd_27, NULL); + LOAD_NEW_VOICE(cdv_27); + loadFile(cd_27_pal, _tempPal); + loadFile(cd_27_log, workScreen2); + WAIT_VOICE; //26 + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + START_VOICE; //27 + LOAD_NEW_VOICE(cdv_29); + WAIT_VOICE; //27 + START_VOICE; //29 + LOAD_NEW_VOICE(cdv_30); + WAIT_VOICE; //29 + START_VOICE; //30 + LOAD_NEW_VOICE(cdv_31); + WAIT_VOICE; //30 + startTimerSequence(cd2_seq_data_1); + START_VOICE; //31 + LOAD_NEW_VOICE(cdv_32); + WAIT_VOICE; //31 + START_VOICE; //32 + LOAD_NEW_VOICE(cdv_33); + WAIT_VOICE; //32 + START_VOICE; //33 + LOAD_NEW_VOICE(cdv_34); + WAIT_VOICE; //33 + START_VOICE; //34 + LOAD_NEW_VOICE(cdv_35); + WAIT_SEQUENCE; //27 + WAIT_VOICE; //34 + START_VOICE; //35 + + free (cd2_seq_data_2); + cd2_seq_data_2 = (byte *)loadFile(cd_35, NULL); + LOAD_NEW_VOICE(cdv_36); + loadFile(cd_35_pal, _tempPal); + loadFile(cd_35_log, workScreen2); + WAIT_VOICE; //35 + START_VOICE; //36 + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + + LOAD_NEW_VOICE(cdv_37); + WAIT_VOICE; //36 + startTimerSequence(cd2_seq_data_2); + START_VOICE; //37 + + free (cd2_seq_data_1); + cd2_seq_data_1 = (byte *)loadFile(cd_37, NULL); + LOAD_NEW_VOICE(cdv_38); + + WAIT_SEQUENCE; //35 + WAIT_VOICE; //37 + START_VOICE; //38 + startTimerSequence(cd2_seq_data_1); + LOAD_NEW_VOICE(cdv_39); + WAIT_SEQUENCE; //37 + WAIT_VOICE; //38 + START_VOICE; //39 + + LOAD_NEW_VOICE(cdv_40); + loadFile(cd_40_pal, _tempPal); + loadFile(cd_40_log, workScreen2); + WAIT_VOICE; //39 + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + + START_VOICE; //40 + LOAD_NEW_VOICE(cdv_41); + WAIT_VOICE; //40 + START_VOICE; //41 + LOAD_NEW_VOICE(cdv_42); + WAIT_VOICE; //41 + START_VOICE; //42 + LOAD_NEW_VOICE(cdv_43); + + loadFile(cd_43_pal, _tempPal); + loadFile(cd_43_log, workScreen2); + WAIT_VOICE; //42 + + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + + START_VOICE; //43 + free (cd2_seq_data_2); + cd2_seq_data_2 = (byte *)loadFile(cd_43, NULL); + WAIT_VOICE; //43 + startTimerSequence(cd2_seq_data_2); + LOAD_NEW_VOICE(cdv_45); + loadFile(cd_45_pal, _tempPal); + loadFile(cd_45_log, workScreen2); + WAIT_SEQUENCE; //43 + START_VOICE; //45 + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + free (cd2_seq_data_1); + cd2_seq_data_1 = (byte *)loadFile(cd_45, NULL); + LOAD_NEW_VOICE(cdv_46); + WAIT_VOICE; //45 + startTimerSequence(cd2_seq_data_1); + START_VOICE; //46 + LOAD_NEW_VOICE(cdv_47); + + loadFile(cd_47_pal, _tempPal); + loadFile(cd_47_log, workScreen2); + + WAIT_SEQUENCE; //45 + WAIT_VOICE; //46 + + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + START_VOICE; //47 + LOAD_NEW_VOICE(cdv_48); + loadFile(cd_48_pal, _tempPal); + loadFile(cd_48_log, workScreen2); + WAIT_VOICE; //47 + START_VOICE; //48 + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + + free (cd2_seq_data_2); + cd2_seq_data_2 = (byte *)loadFile(cd_48, NULL); + LOAD_NEW_VOICE(cdv_49); + WAIT_VOICE; //48 + startTimerSequence(cd2_seq_data_2); + START_VOICE; //49 + LOAD_NEW_VOICE(cdv_50); + WAIT_VOICE; //49 + START_VOICE; //50 + free (cd2_seq_data_1); + cd2_seq_data_1 = (byte *)loadFile(cd_49, NULL); + LOAD_NEW_VOICE(cdv_51); + WAIT_SEQUENCE; //48 + WAIT_VOICE; //50 + START_VOICE; //51 + startTimerSequence(cd2_seq_data_1); + LOAD_NEW_VOICE(cdv_52); + WAIT_VOICE; //51 + START_VOICE; //52 + LOAD_NEW_VOICE(cdv_53); + WAIT_VOICE; //52 + START_VOICE; //53 + LOAD_NEW_VOICE(cdv_54); + free (cd2_seq_data_2); + cd2_seq_data_2 = (byte *)loadFile(cd_50, NULL); + WAIT_VOICE; //53 + WAIT_SEQUENCE; //49 + + START_VOICE; //54 + startTimerSequence(cd2_seq_data_2); + LOAD_NEW_VOICE(cdv_55); + WAIT_SEQUENCE; //50 + WAIT_VOICE; //54 + START_VOICE; //55 + + loadFile(cd_55_pal, _tempPal); + loadFile(cd_55_log, workScreen2); + LOAD_NEW_VOICE(cdv_56); + WAIT_VOICE; //55 + START_VOICE; //56 + + fn_fade_down(0); + COPY_SCREEN; showScreen(); paletteFadeUp(_tempPal); -} + LOAD_NEW_VOICE(cdv_57); + WAIT_VOICE; //56 + START_VOICE; //57 + + LOAD_NEW_VOICE(cdv_58); + loadFile(cd_58_pal, _tempPal); + loadFile(cd_58_log, workScreen2); + + WAIT_VOICE; //57 + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + START_VOICE; //58 + LOAD_NEW_VOICE(cdv_59); + WAIT_VOICE; //48 + START_VOICE; //59 + free (cd2_seq_data_1); + cd2_seq_data_1 = (byte *)loadFile(cd_58, NULL); + WAIT_VOICE; //59 + LOAD_NEW_VOICE(cdv_60); + START_VOICE; //60 + LOAD_NEW_VOICE(cdv_61); + WAIT_VOICE; //60 + START_VOICE; //61 + LOAD_NEW_VOICE(cdv_62); + WAIT_VOICE; //61 + START_VOICE; //62 + startTimerSequence(cd2_seq_data_1); //58 + LOAD_NEW_VOICE(cdv_63); + WAIT_VOICE; //62 + START_VOICE; //63 + LOAD_NEW_VOICE(cdv_64); + WAIT_VOICE; //63 + START_VOICE; //64 + LOAD_NEW_VOICE(cdv_65); + WAIT_SEQUENCE; //58 + WAIT_VOICE; //64 + START_VOICE; //65 + fn_fade_down(0); + LOAD_NEW_VOICE(cdv_66); + loadFile(cd_66_pal, _tempPal); + loadFile(cd_66_log, _workScreen); + WAIT_VOICE; //65 + showScreen(); + paletteFadeUp(_tempPal); + START_VOICE; //66 + LOAD_NEW_VOICE(cdv_67); + WAIT_VOICE; //66 + START_VOICE; //67 + loadFile(cd_67_pal, _tempPal); + loadFile(cd_67_log, workScreen2); + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + LOAD_NEW_VOICE(cdv_68); + WAIT_VOICE; //67 + START_VOICE; //68 + free (cd2_seq_data_2); + cd2_seq_data_2 = (byte *)loadFile(cd_69, NULL); + LOAD_NEW_VOICE(cdv_69); + loadFile(cd_69_pal, _tempPal); + loadFile(cd_69_log, workScreen2); + WAIT_VOICE; //68 + START_VOICE; //69 + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + LOAD_NEW_VOICE(cdv_70); + WAIT_VOICE; //69 + startTimerSequence(cd2_seq_data_2); + START_VOICE; //70 + LOAD_NEW_VOICE(cdv_71); + WAIT_VOICE; //70 + fn_fade_down(0); + START_VOICE; //71 + loadFile(cd_72_pal, _tempPal); + loadFile(cd_72_log, _workScreen); + WAIT_VOICE; //71 + showScreen(); + paletteFadeUp(_tempPal); + LOAD_NEW_VOICE(cdv_72); + START_VOICE; //72 + + loadFile(cd_73_pal, _tempPal); + loadFile(cd_73_log, _workScreen); + LOAD_NEW_VOICE(cdv_73); + WAIT_VOICE; //72 + fn_fade_down(0); + showScreen(); + paletteFadeUp(_tempPal); + START_VOICE; //73 + LOAD_NEW_VOICE(cdv_74); + WAIT_VOICE; //73 + START_VOICE; //74 + LOAD_NEW_VOICE(cdv_75); + WAIT_VOICE; //74 + START_VOICE; //75 + loadFile(cd_76_pal, _tempPal); + free (workScreen2); + workScreen2 = (byte *)loadFile(cd_76_log, NULL); + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + + LOAD_NEW_VOICE(cdv_76); + WAIT_VOICE; //75 + START_VOICE; //76 + LOAD_NEW_VOICE(cdv_77); + WAIT_VOICE; //76 + START_VOICE; //77 + + free (cd2_seq_data_1); + cd2_seq_data_1 = (byte *)loadFile(cd_100, NULL); + loadFile(cd_78_pal, _tempPal); + free (workScreen2); + workScreen2 = (byte *)loadFile(cd_78_log, NULL); + LOAD_NEW_VOICE(cdv_78); + WAIT_VOICE; //77 + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + START_VOICE; //78 + LOAD_NEW_VOICE(cdv_79); + WAIT_VOICE; //78 + START_VOICE; //79 + LOAD_NEW_VOICE(cdv_80); + WAIT_VOICE; //79 + START_VOICE; //80 + startTimerSequence(cd2_seq_data_1); + LOAD_NEW_VOICE(cdv_81); + WAIT_VOICE; //80 + START_VOICE; //81 + LOAD_NEW_VOICE(cdv_82); + WAIT_VOICE; //81 + START_VOICE; //82 + LOAD_NEW_VOICE(cdv_83); + WAIT_VOICE; //82 + loadFile(cd_101_log, workScreen2); + free (cd2_seq_data_2); + cd2_seq_data_2 = (byte *)loadFile(cd_101, NULL); + WAIT_SEQUENCE; //100 + COPY_SCREEN; + showScreen(); + startTimerSequence(cd2_seq_data_2); + START_VOICE; //83 + LOAD_NEW_VOICE(cdv_84); + WAIT_VOICE; //83 + START_VOICE; //84 + LOAD_NEW_VOICE(cdv_85); + WAIT_VOICE; //84 + START_VOICE; //85 + LOAD_NEW_VOICE(cdv_86); + WAIT_VOICE; //85 + + free (workScreen2); + workScreen2 = (byte *)loadFile(cd_102_log, NULL); + free (cd2_seq_data_1); + cd2_seq_data_1 = (byte *)loadFile(cd_102, NULL); + WAIT_SEQUENCE; //101 + COPY_SCREEN; + showScreen(); + startTimerSequence(cd2_seq_data_1); + START_VOICE; //86 + LOAD_NEW_VOICE(cdv_87); + loadFile(cd_103_pal, _tempPal); + free (workScreen2); + workScreen2 = (byte *)loadFile(cd_103_log, NULL); + free (cd2_seq_data_2); + cd2_seq_data_2 = (byte *)loadFile(cd_103, NULL); + WAIT_SEQUENCE; //102 + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + startTimerSequence(cd2_seq_data_2); + WAIT_VOICE; //86 + START_VOICE; //87 + loadFile(cd_104_pal, _tempPal); + free (workScreen2); + workScreen2 = (byte *)loadFile(cd_104_log, NULL); + free (cd2_seq_data_1); + cd2_seq_data_1 = (byte *)loadFile(cd_104, NULL); + WAIT_SEQUENCE; //103 + + //fn_start_music(2); + fn_fade_down(0); + COPY_SCREEN; + showScreen(); + paletteFadeUp(_tempPal); + startTimerSequence(cd2_seq_data_1); + free (cd2_seq_data_2); + cd2_seq_data_2 = (byte *)loadFile(cd_105, NULL); + WAIT_SEQUENCE; //104 + startTimerSequence(cd2_seq_data_2); + WAIT_SEQUENCE; //105 + + free (cd2_seq_data_1); + free (cd2_seq_data_2); + free (workScreen2); +} diff --git a/sky/disk.cpp b/sky/disk.cpp index cabc6155a4..6fff6b1382 100644 --- a/sky/disk.cpp +++ b/sky/disk.cpp @@ -87,7 +87,7 @@ uint16 *SkyState::loadFile(uint16 fileNr, uint8 *dest) { #endif compFile = fileNr; - debug(1, "load file %d,%d (%d)", (fileNr >> 11), (fileNr & 2047), fileNr); + debug(2, "load file %d,%d (%d)", (fileNr >> 11), (fileNr & 2047), fileNr); filePtr = (uint8 *)getFileInfo(fileNr); if (filePtr == NULL) { @@ -131,11 +131,11 @@ uint16 *SkyState::loadFile(uint16 fileNr, uint8 *dest) { //if cflag == 0 then file is compressed, 1 == uncompressed if (!cflag) { - debug(1, "File is compressed..."); + debug(2, "File is compressed..."); memcpy(&fileHeader, fileDest, sizeof(struct dataFileHeader)); if ( (uint8)((FROM_LE_16(fileHeader.flag) >> 7) & 0x1) ) { - debug(1, "with RNC!"); + debug(2, "with RNC!"); decompSize = (FROM_LE_16(fileHeader.flag) & 0xFFFFFF00) << 8; decompSize |= FROM_LE_16((uint16)fileHeader.s_tot_size); @@ -157,7 +157,7 @@ uint16 *SkyState::loadFile(uint16 fileNr, uint8 *dest) { RncDecoder rncDecoder; int32 unPackLen = rncDecoder.unpackM1(inputPtr, outputPtr, 0); - debug(2, "UnpackM1 returned: %d", unPackLen); + debug(3, "UnpackM1 returned: %d", unPackLen); if (unPackLen == 0) { //Unpack returned 0: file was probably not packed. if (fixedDest == NULL) @@ -180,7 +180,7 @@ uint16 *SkyState::loadFile(uint16 fileNr, uint8 *dest) { free(fileDest); } else - debug(1, "but not with RNC! (?!)"); + debug(2, "but not with RNC! (?!)"); } else return (uint16 *)fileDest; @@ -194,7 +194,7 @@ uint16 *SkyState::getFileInfo(uint16 fileNr) { for (i = 0; i < dinnerTableEntries; i++) { if (READ_LE_UINT16(dnrTbl16Ptr + (i * 4)) == fileNr) { - debug(1, "file %d found!", fileNr); + debug(2, "file %d found!", fileNr); return (dnrTbl16Ptr + (i * 4)); } } diff --git a/sky/module.mk b/sky/module.mk index 702c0c5daf..b8503f5404 100644 --- a/sky/module.mk +++ b/sky/module.mk @@ -4,6 +4,7 @@ MODULE_OBJS = \ sky/sky.o \ sky/disk.o \ sky/screen.o \ + sky/timer.o \ sky/intro.o \ sky/cd_intro.o \ sky/rnc_deco.o \ diff --git a/sky/sky.cpp b/sky/sky.cpp index a390197cc0..a7cc700d14 100644 --- a/sky/sky.cpp +++ b/sky/sky.cpp @@ -94,7 +94,7 @@ void SkyState::go() { void SkyState::initialise(void) { //initialise_memory(); - //init_timer(); + initTimer(); //init_music(); _sound = new SkySound(_mixer); @@ -25,6 +25,7 @@ #include <stdio.h> #include "common/engine.h" #include "common/util.h" +#include "common/timer.h" #include "sound/mixer.h" #include "sky/sound.h" @@ -36,6 +37,10 @@ protected: bool _isDemo; byte _key_pressed; + uint32 _tseqFrames; + byte *_tseqData; + uint32 _tseqCounter; + uint16 _debugMode; uint16 _debugLevel; uint16 _language; @@ -50,7 +55,8 @@ protected: uint32 _lastLoadedFileSize; -// int _timer_id; + Timer *_timer; + //int _timer_id; FILE *_dump_file; @@ -81,6 +87,7 @@ protected: void convertPalette(uint8 *inpal, uint8* outpal); void initialise(); + void initTimer(); void initialiseDisk(); void initialiseScreen(); void initialiseGrids(); @@ -96,7 +103,10 @@ protected: void intro(); void doCDIntro(); void showScreen(); - + void startTimerSequence(byte *sequence); + static void timerHandler(void *ptr); + void doTimerSequence(); + static int CDECL game_thread_proc(void *param); void shutdown(); diff --git a/sky/sound.cpp b/sky/sound.cpp index 99f4106336..33ca456f5d 100644 --- a/sky/sound.cpp +++ b/sky/sound.cpp @@ -27,17 +27,30 @@ SkySound::SkySound(SoundMixer *mixer) { _mixer = mixer; + _voiceHandle = 0; + _effectHandle = 0; + _bgSoundHandle = 0; } int SkySound::playVoice(byte *sound, uint32 size) { + return playSound(sound, size, &_voiceHandle); +} + + +int SkySound::playBgSound(byte *sound, uint32 size) { + + size -= 512; //Hack to get rid of the annoying pop at the end of some bg sounds + return playSound(sound, size, &_bgSoundHandle); +} + +int SkySound::playSound(byte *sound, uint32 size, PlayingSoundHandle *handle) { + byte flags = 0; flags |= SoundMixer::FLAG_UNSIGNED|SoundMixer::FLAG_AUTOFREE; size -= sizeof(struct dataFileHeader); byte *buffer = (byte *)malloc(size); memcpy(buffer, sound+sizeof(struct dataFileHeader), size); - return _mixer->playRaw(NULL, buffer, size, 11025, flags); - + return _mixer->playRaw(handle, buffer, size, 11025, flags); } - diff --git a/sky/sound.h b/sky/sound.h index 26d8d8080f..a1083a67bc 100644 --- a/sky/sound.h +++ b/sky/sound.h @@ -25,19 +25,21 @@ class SkySound { protected: - bool _voiceIsPlaying; - public: SoundMixer *_mixer; - + PlayingSoundHandle _voiceHandle; + PlayingSoundHandle _effectHandle; + PlayingSoundHandle _bgSoundHandle; protected: + int playSound(byte *sound, uint32 size, PlayingSoundHandle *handle); public: SkySound(SoundMixer *mixer); int playVoice(byte *sound, uint32 size); + int playBgSound(byte *sound, uint32 size); }; diff --git a/sky/timer.cpp b/sky/timer.cpp new file mode 100644 index 0000000000..053935aae8 --- /dev/null +++ b/sky/timer.cpp @@ -0,0 +1,85 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2003 The ScummVM project + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header$ + * + */ + +#include "stdafx.h" +#include "sky/sky.h" +#include "sky/skydefs.h" + + +void SkyState::initTimer(void) { + + _tseqFrames = 0; + _timer = Engine::_timer; + _timer->installProcedure(&timerHandler, 1000000 / 50); //call 50 times per second + +} + +void SkyState::timerHandler(void *ptr) { + + SkyState *_this = (SkyState *)ptr; + + //music_command(0x300); + _this->doTimerSequence(); +} + +void SkyState::startTimerSequence(byte *sequence) { + + _tseqFrames = *sequence++; + _tseqData = sequence; + _tseqCounter = SEQUENCE_COUNT; + debug(1, "Starting new sequence of %d frames.", _tseqFrames); + +} + +void SkyState::doTimerSequence(void) { + + byte nrToSkip, nrToDo, tmp; + byte *scrPtr = _workScreen; + + if (_tseqFrames == 0) + return; + + _tseqCounter--; + if (_tseqCounter != 0) + return; + + _tseqCounter = SEQUENCE_COUNT; + + debug(2, "Number of frames left: %d\n", _tseqFrames); + + do { + do { + nrToSkip = *_tseqData++; + scrPtr += nrToSkip; + } while (nrToSkip == 255); + do { + nrToDo = *_tseqData++; + tmp = nrToDo; + while (tmp--) { + *scrPtr++ = *_tseqData++; + } + } while (nrToDo == 255); + } while ((scrPtr - _workScreen) < (GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT)); + + showScreen(); + _tseqFrames--; + +} |