diff options
| -rw-r--r-- | sky/cd_intro.cpp | 428 | ||||
| -rw-r--r-- | sky/disk.cpp | 66 | ||||
| -rw-r--r-- | sky/disk.h | 13 | ||||
| -rw-r--r-- | sky/intro.cpp | 270 | ||||
| -rw-r--r-- | sky/screen.cpp | 202 | ||||
| -rw-r--r-- | sky/screen.h | 93 | ||||
| -rw-r--r-- | sky/sky.cpp | 17 | ||||
| -rw-r--r-- | sky/sky.h | 40 | ||||
| -rw-r--r-- | sky/timer.cpp | 83 | 
9 files changed, 632 insertions, 580 deletions
diff --git a/sky/cd_intro.cpp b/sky/cd_intro.cpp index 03e690c7bc..34d7a892ee 100644 --- a/sky/cd_intro.cpp +++ b/sky/cd_intro.cpp @@ -195,30 +195,28 @@  #define LOAD_NEW_VOICE(num)	( free (vocBuffer), vocBuffer = _skyDisk->loadFile(num, NULL), loadedVocSize = _skyDisk->_lastLoadedFileSize )   #define LOAD_NEW_BG(num)	( free (bgVocBuffer), bgVocBuffer = _skyDisk->loadFile(num, NULL), bgVocSize = _skyDisk->_lastLoadedFileSize )  #define WAIT_VOICE	while (_skySound->_voiceHandle != 0) { delay(50); CHECK_ESC } -#define WAIT_SEQUENCE	while (_tseqFrames != 0) { delay(50); CHECK_ESC } -#define CHECK_ESC	if (_key_pressed == 27) { _tseqFrames = 0; return; } +#define CHECK_ESC if (_key_pressed == 27) { _skyScreen->stopSequence(); return; } +#define WAIT_SEQUENCE while (_skyScreen->sequenceRunning()) { delay(50); CHECK_ESC }  #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, *cd2_seq_data_2; +	byte *vocBuffer, *bgVocBuffer;  	assert(isCDVersion(_gameVersion));  	vocBuffer = _skyDisk->loadFile(cdv_00, NULL);  	loadedVocSize = _skyDisk->_lastLoadedFileSize; -	_tempPal = _skyDisk->loadFile(cd_pal, NULL); -	_workScreen = _skyDisk->loadFile(cd_1_log, NULL); -	 -	cd2_seq_data_1 = _skyDisk->loadFile(cd_1, NULL); +	_skyDisk->prefetchFile(cd_pal); +	_skyDisk->prefetchFile(cd_1_log); +	_skyDisk->prefetchFile(cd_1); +  	bgVocBuffer = _skyDisk->loadFile(59499, NULL);  	bgVocSize = _skyDisk->_lastLoadedFileSize; -  	delay(2000); //keep gibbons screen up for 2 seconds -	fnFadeDown(0); //and fade out +	_skyScreen->fnFadeDown(0); //and fade out  	START_VOICE;  	START_BG;  @@ -226,22 +224,22 @@ void SkyState::doCDIntro() {  	vocBuffer = _skyDisk->loadFile(cdv_01, NULL);  	loadedVocSize = _skyDisk->_lastLoadedFileSize; -	  	WAIT_VOICE; //wait for the voice to finish +  	START_VOICE;  	START_BG;  -	showScreen(); -	paletteFadeUp(_tempPal); -	startTimerSequence(cd2_seq_data_1); +	_skyScreen->showScreen(cd_1_log); +	_skyScreen->paletteFadeUp(cd_pal); +	_skyScreen->startSequence(cd_1); +  	LOAD_NEW_VOICE(cdv_02);  	WAIT_VOICE;  	START_VOICE;  	START_BG;  -	cd2_seq_data_2 = _skyDisk->loadFile(cd_2, NULL); //load seq 2 while 1 is playing +	_skyDisk->prefetchFile(cd_2); //load seq 2 while 1 is playing  	LOAD_NEW_VOICE(cdv_03); -	//WAIT_SEQUENCE;  	WAIT_VOICE; -	startTimerSequence(cd2_seq_data_2); //start second sequence +	_skyScreen->startSequence(cd_2); //start second sequence  	START_VOICE; //03  	START_BG; @@ -251,8 +249,7 @@ void SkyState::doCDIntro() {  	START_VOICE; //04  	START_BG; -	free(cd2_seq_data_1); -	cd2_seq_data_1 = _skyDisk->loadFile(cd_3, NULL); +	_skyDisk->prefetchFile(cd_3);  	LOAD_NEW_VOICE(cdv_05);  	WAIT_SEQUENCE; //2 @@ -263,21 +260,20 @@ void SkyState::doCDIntro() {  	WAIT_RELATIVE(100);  -	startTimerSequence(cd2_seq_data_1); +	_skyScreen->startSequence(cd_3);  	LOAD_NEW_VOICE(cdv_06);  	WAIT_VOICE; //5  	START_VOICE; //6  	START_BG; -	free (cd2_seq_data_2); -	cd2_seq_data_2 = _skyDisk->loadFile(cd_5, NULL); +	_skyDisk->prefetchFile(cd_5);  	LOAD_NEW_VOICE(cdv_07);  	WAIT_SEQUENCE; //3  	WAIT_VOICE; //6  	START_VOICE; //7 -	startTimerSequence(cd2_seq_data_2); //5 +	_skyScreen->startSequence(cd_5);  	START_BG;  	LOAD_NEW_VOICE(cdv_08); @@ -289,31 +285,28 @@ void SkyState::doCDIntro() {  	START_VOICE; //9  	START_BG; -	free (cd2_seq_data_1); -	cd2_seq_data_1 = _skyDisk->loadFile(cd_7, NULL); +	_skyDisk->prefetchFile(cd_7);  	LOAD_NEW_VOICE(cdv_10);  	WAIT_SEQUENCE; //5  	WAIT_VOICE; //9  	START_VOICE; //10 -	startTimerSequence(cd2_seq_data_1); //7 +	_skyScreen->startSequence(cd_7);  	START_BG; -	_skyDisk->loadFile(cd_11_pal, _tempPal); -	byte *workScreen2 = _skyDisk->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 = _skyDisk->loadFile(cd_11, NULL); +	_skyDisk->prefetchFile(cd_11_pal); +	_skyDisk->prefetchFile(cd_11_log); +	_skyDisk->prefetchFile(cd_11);  	LOAD_NEW_VOICE(cdv_11);  	WAIT_VOICE; //10  	START_VOICE; //11  	START_BG; -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_11_log); +	_skyScreen->paletteFadeUp(cd_11_pal);  	LOAD_NEW_VOICE(cdv_12);  	WAIT_SEQUENCE; //7 @@ -322,15 +315,14 @@ void SkyState::doCDIntro() {  	START_BG;  	WAIT_RELATIVE(80); -	startTimerSequence(cd2_seq_data_2); //11 +	_skyScreen->startSequence(cd_11);  	LOAD_NEW_VOICE(cdv_13);  	WAIT_VOICE; //12  	START_VOICE; //13  	START_BG; -	free(cd2_seq_data_1); -	cd2_seq_data_1 = _skyDisk->loadFile(cd_13, NULL); +	_skyDisk->prefetchFile(cd_13);  	LOAD_NEW_VOICE(cdv_14);  	LOAD_NEW_BG(59498); @@ -339,89 +331,85 @@ void SkyState::doCDIntro() {  	WAIT_VOICE; //13  	START_VOICE; //14 -	startTimerSequence(cd2_seq_data_1); //13 +	_skyScreen->startSequence(cd_13);  	START_BG;  	LOAD_NEW_VOICE(cdv_15); -	_skyDisk->loadFile(cd_15_pal, _tempPal); -	_skyDisk->loadFile(cd_15_log, workScreen2); +	_skyDisk->prefetchFile(cd_15_pal); +	_skyDisk->prefetchFile(cd_15_log);  	WAIT_SEQUENCE; //13  	WAIT_VOICE; //14  	START_VOICE; //15  	START_BG; -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_15_log); +	_skyScreen->paletteFadeUp(cd_15_pal);  	LOAD_NEW_VOICE(cdv_16);  	WAIT_VOICE; //15  	START_VOICE; //16  	START_BG; -	_skyDisk->loadFile(cd_17_log, workScreen2); -	free (cd2_seq_data_2); -	cd2_seq_data_2 = _skyDisk->loadFile(cd_17, NULL); +	_skyDisk->prefetchFile(cd_17_log); +	_skyDisk->prefetchFile(cd_17);  	LOAD_NEW_VOICE(cdv_17);  	WAIT_VOICE; //16  	START_VOICE; //17  	WAIT_RELATIVE(40); -	COPY_SCREEN; -	showScreen(); +	_skyScreen->showScreen(cd_17_log);  	LOAD_NEW_VOICE(cdv_18);  	LOAD_NEW_BG(59497); //Loud heli  	WAIT_VOICE; //17 -	startTimerSequence(cd2_seq_data_2); //17 +	_skyScreen->startSequence(cd_17);  	START_VOICE; //18  	START_BG;  	LOAD_NEW_VOICE(cdv_19); -	_skyDisk->loadFile(cd_19_pal, _tempPal); -	_skyDisk->loadFile(cd_19_log, workScreen2); +	_skyDisk->prefetchFile(cd_19_pal); +	_skyDisk->prefetchFile(cd_19_log);  	START_BG;  	LOAD_NEW_BG(59496); //loud heli to quiet  	WAIT_SEQUENCE; //17  	WAIT_VOICE; //18 -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_19_log); +	_skyScreen->paletteFadeUp(cd_19_pal);  	START_VOICE; //19  	START_BG;  	LOAD_NEW_VOICE(cdv_20); -	_skyDisk->loadFile(cd_20_log, workScreen2);  	LOAD_NEW_BG(59496); //quiet heli +	_skyDisk->prefetchFile(cd_20_log); +	_skyDisk->prefetchFile(cd_19_pal);  	WAIT_VOICE; //19  	START_VOICE; //20  	START_BG; -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_20_log); +	_skyScreen->paletteFadeUp(cd_19_pal);  	LOAD_NEW_VOICE(cdv_21); -	_skyDisk->loadFile(cd_21_log, workScreen2); +	_skyDisk->prefetchFile(cd_21_log);  	START_BG; +	_skyDisk->prefetchFile(cd_19_pal);  	WAIT_SEQUENCE; //19  	WAIT_VOICE; //20  	START_VOICE; //21  	START_BG; -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_21_log); +	_skyScreen->paletteFadeUp(cd_19_pal);  	LOAD_NEW_VOICE(cdv_22);  	LOAD_NEW_BG(59494); //heli whine @@ -434,18 +422,16 @@ void SkyState::doCDIntro() {  	LOAD_NEW_VOICE(cdv_23);  	WAIT_VOICE; //22  	START_VOICE; //23 -	fnFadeDown(0); +	_skyScreen->fnFadeDown(0); -	_skyDisk->loadFile(cd_23_pal, _tempPal); -	_skyDisk->loadFile(cd_24_log, workScreen2); +	_skyDisk->prefetchFile(cd_23_pal); +	_skyDisk->prefetchFile(cd_24_log);  	LOAD_NEW_VOICE(cdv_24);  	WAIT_VOICE; //23 -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->showScreen(cd_24_log); +	_skyScreen->paletteFadeUp(cd_23_pal);  	START_VOICE; //24 -	showScreen();  	LOAD_NEW_VOICE(cdv_25);  	WAIT_VOICE; //24  	START_VOICE; //25 @@ -453,16 +439,14 @@ void SkyState::doCDIntro() {  	WAIT_VOICE; //25  	START_VOICE; //26 -	free (cd2_seq_data_1); -	cd2_seq_data_1 = _skyDisk->loadFile(cd_27, NULL); +	_skyDisk->prefetchFile(cd_27);  	LOAD_NEW_VOICE(cdv_27); -	_skyDisk->loadFile(cd_27_pal, _tempPal); -	_skyDisk->loadFile(cd_27_log, workScreen2); +	_skyDisk->prefetchFile(cd_27_pal); +	_skyDisk->prefetchFile(cd_27_log);  	WAIT_VOICE; //26 -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen();	 -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_27_log); +	_skyScreen->paletteFadeUp(cd_27_pal);  	START_VOICE; //27  	LOAD_NEW_VOICE(cdv_29);  	WAIT_VOICE; //27 @@ -472,7 +456,8 @@ void SkyState::doCDIntro() {  	START_VOICE; //30  	LOAD_NEW_VOICE(cdv_31);  	WAIT_VOICE; //30 -	startTimerSequence(cd2_seq_data_1); + +	_skyScreen->startSequence(cd_27);  	START_VOICE; //31  	LOAD_NEW_VOICE(cdv_32);  	WAIT_VOICE; //31 @@ -488,44 +473,40 @@ void SkyState::doCDIntro() {  	WAIT_VOICE; //34  	START_VOICE; //35 -	free (cd2_seq_data_2); -	cd2_seq_data_2 = _skyDisk->loadFile(cd_35, NULL); +	_skyDisk->prefetchFile(cd_35);  	LOAD_NEW_VOICE(cdv_36); -	_skyDisk->loadFile(cd_35_pal, _tempPal); -	_skyDisk->loadFile(cd_35_log, workScreen2); +	_skyDisk->prefetchFile(cd_35_pal); +	_skyDisk->prefetchFile(cd_35_log);  	WAIT_VOICE; //35  	START_VOICE; //36 -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_35_log); +	_skyScreen->paletteFadeUp(cd_35_pal);  	LOAD_NEW_VOICE(cdv_37);  	WAIT_VOICE; //36 -	startTimerSequence(cd2_seq_data_2); +	_skyScreen->startSequence(cd_35);  	START_VOICE; //37 -	free (cd2_seq_data_1); -	cd2_seq_data_1 = _skyDisk->loadFile(cd_37, NULL); +	_skyDisk->prefetchFile(cd_37);  	LOAD_NEW_VOICE(cdv_38);  	WAIT_SEQUENCE; //35  	WAIT_VOICE; //37  	START_VOICE; //38 -	startTimerSequence(cd2_seq_data_1); +	_skyScreen->startSequence(cd_37);  	LOAD_NEW_VOICE(cdv_39);  	WAIT_SEQUENCE; //37  	WAIT_VOICE; //38  	START_VOICE; //39  	LOAD_NEW_VOICE(cdv_40); -	_skyDisk->loadFile(cd_40_pal, _tempPal); -	_skyDisk->loadFile(cd_40_log, workScreen2); +	_skyDisk->prefetchFile(cd_40_pal); +	_skyDisk->prefetchFile(cd_40_log);  	WAIT_VOICE; //39 -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_40_log); +	_skyScreen->paletteFadeUp(cd_40_pal);  	START_VOICE; //40  	LOAD_NEW_VOICE(cdv_41); @@ -536,74 +517,66 @@ void SkyState::doCDIntro() {  	START_VOICE; //42  	LOAD_NEW_VOICE(cdv_43); -	_skyDisk->loadFile(cd_43_pal, _tempPal); -	_skyDisk->loadFile(cd_43_log, workScreen2); +	_skyDisk->prefetchFile(cd_43_pal); +	_skyDisk->prefetchFile(cd_43_log);  	WAIT_VOICE; //42 -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_43_log); +	_skyScreen->paletteFadeUp(cd_43_pal);  	START_VOICE; //43 -	free (cd2_seq_data_2); -	cd2_seq_data_2 = _skyDisk->loadFile(cd_43, NULL); +	_skyDisk->prefetchFile(cd_43);  	WAIT_VOICE; //43 -	startTimerSequence(cd2_seq_data_2); +	_skyScreen->startSequence(cd_43);  	LOAD_NEW_VOICE(cdv_45); -	_skyDisk->loadFile(cd_45_pal, _tempPal); -	_skyDisk->loadFile(cd_45_log, workScreen2); +	_skyDisk->prefetchFile(cd_45_pal); +	_skyDisk->prefetchFile(cd_45_log);  	WAIT_SEQUENCE; //43  	START_VOICE; //45 -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); -	free (cd2_seq_data_1); -	cd2_seq_data_1 = _skyDisk->loadFile(cd_45, NULL); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_45_log); +	_skyScreen->paletteFadeUp(cd_45_pal); +	_skyDisk->prefetchFile(cd_45);  	LOAD_NEW_VOICE(cdv_46);  	WAIT_VOICE; //45 -	startTimerSequence(cd2_seq_data_1); +	_skyScreen->startSequence(cd_45);  	START_VOICE; //46  	LOAD_NEW_VOICE(cdv_47); -	_skyDisk->loadFile(cd_47_pal, _tempPal); -	_skyDisk->loadFile(cd_47_log, workScreen2); +	_skyDisk->prefetchFile(cd_47_pal); +	_skyDisk->prefetchFile(cd_47_log);  	WAIT_SEQUENCE; //45  	WAIT_VOICE; //46 -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_47_log); +	_skyScreen->paletteFadeUp(cd_47_pal);  	START_VOICE; //47  	LOAD_NEW_VOICE(cdv_48); -	_skyDisk->loadFile(cd_48_pal, _tempPal); -	_skyDisk->loadFile(cd_48_log, workScreen2); +	_skyDisk->prefetchFile(cd_48_pal); +	_skyDisk->prefetchFile(cd_48_log);  	WAIT_VOICE; //47  	START_VOICE; //48 -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_48_log); +	_skyScreen->paletteFadeUp(cd_48_pal); -	free (cd2_seq_data_2); -	cd2_seq_data_2 = _skyDisk->loadFile(cd_48, NULL); +	_skyDisk->prefetchFile(cd_48);  	LOAD_NEW_VOICE(cdv_49);  	WAIT_VOICE; //48 -	startTimerSequence(cd2_seq_data_2); +	_skyScreen->startSequence(cd_48);  	START_VOICE; //49  	LOAD_NEW_VOICE(cdv_50);  	WAIT_VOICE; //49  	START_VOICE; //50 -	free (cd2_seq_data_1); -	cd2_seq_data_1 = _skyDisk->loadFile(cd_49, NULL); +	_skyDisk->prefetchFile(cd_49);  	LOAD_NEW_VOICE(cdv_51);  	WAIT_SEQUENCE; //48  	WAIT_VOICE; //50  	START_VOICE; //51 -	startTimerSequence(cd2_seq_data_1); +	_skyScreen->startSequence(cd_49);  	LOAD_NEW_VOICE(cdv_52);  	WAIT_VOICE; //51  	START_VOICE; //52 @@ -611,48 +584,44 @@ void SkyState::doCDIntro() {  	WAIT_VOICE; //52  	START_VOICE; //53  	LOAD_NEW_VOICE(cdv_54); -	free (cd2_seq_data_2); -	cd2_seq_data_2 = _skyDisk->loadFile(cd_50, NULL); +	_skyDisk->prefetchFile(cd_50);  	WAIT_VOICE; //53  	WAIT_SEQUENCE; //49  	START_VOICE; //54 -	startTimerSequence(cd2_seq_data_2); +	_skyScreen->startSequence(cd_50);  	LOAD_NEW_VOICE(cdv_55);  	WAIT_SEQUENCE; //50  	WAIT_VOICE; //54  	START_VOICE; //55 -	_skyDisk->loadFile(cd_55_pal, _tempPal); -	_skyDisk->loadFile(cd_55_log, workScreen2); +	_skyDisk->prefetchFile(cd_55_pal); +	_skyDisk->prefetchFile(cd_55_log);  	LOAD_NEW_VOICE(cdv_56);  	WAIT_VOICE; //55  	START_VOICE; //56 -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_55_log); +	_skyScreen->paletteFadeUp(cd_55_pal);  	LOAD_NEW_VOICE(cdv_57);  	WAIT_VOICE; //56  	START_VOICE; //57  	LOAD_NEW_VOICE(cdv_58); -	_skyDisk->loadFile(cd_58_pal, _tempPal); -	_skyDisk->loadFile(cd_58_log, workScreen2); +	_skyDisk->prefetchFile(cd_58_pal); +	_skyDisk->prefetchFile(cd_58_log);  	WAIT_VOICE; //57 -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_58_log); +	_skyScreen->paletteFadeUp(cd_58_pal);  	START_VOICE; //58  	LOAD_NEW_VOICE(cdv_59);  	WAIT_VOICE; //48  	START_VOICE; //59 -	free (cd2_seq_data_1); -	cd2_seq_data_1 = _skyDisk->loadFile(cd_58, NULL); +	_skyDisk->prefetchFile(cd_58);  	WAIT_VOICE; //59  	LOAD_NEW_VOICE(cdv_60);  	START_VOICE; //60 @@ -662,7 +631,7 @@ void SkyState::doCDIntro() {  	LOAD_NEW_VOICE(cdv_62);  	WAIT_VOICE; //61  	START_VOICE; //62 -	startTimerSequence(cd2_seq_data_1); //58 +	_skyScreen->startSequence(cd_58);  	LOAD_NEW_VOICE(cdv_63);  	WAIT_VOICE; //62  	START_VOICE; //63 @@ -673,60 +642,57 @@ void SkyState::doCDIntro() {  	WAIT_SEQUENCE; //58  	WAIT_VOICE; //64  	START_VOICE; //65 -	fnFadeDown(0); +	_skyScreen->fnFadeDown(0);  	LOAD_NEW_VOICE(cdv_66); -	_skyDisk->loadFile(cd_66_pal, _tempPal); -	_skyDisk->loadFile(cd_66_log, _workScreen); +	_skyDisk->prefetchFile(cd_66_pal); +	_skyDisk->prefetchFile(cd_66_log);  	WAIT_VOICE; //65 -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->showScreen(cd_66_log); +	_skyScreen->paletteFadeUp(cd_66_pal);  	START_VOICE; //66  	LOAD_NEW_VOICE(cdv_67);  	WAIT_VOICE; //66  	START_VOICE; //67 -	_skyDisk->loadFile(cd_67_pal, _tempPal); -	_skyDisk->loadFile(cd_67_log, workScreen2); -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyDisk->prefetchFile(cd_67_pal); +	_skyDisk->prefetchFile(cd_67_log); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_67_log); +	_skyScreen->paletteFadeUp(cd_67_pal);  	LOAD_NEW_VOICE(cdv_68);  	WAIT_VOICE; //67  	START_VOICE; //68 -	free (cd2_seq_data_2); -	cd2_seq_data_2 = _skyDisk->loadFile(cd_69, NULL); +	_skyDisk->prefetchFile(cd_69);  	LOAD_NEW_VOICE(cdv_69); -	_skyDisk->loadFile(cd_69_pal, _tempPal); -	_skyDisk->loadFile(cd_69_log, workScreen2); +	_skyDisk->prefetchFile(cd_69_pal); +	_skyDisk->prefetchFile(cd_69_log);  	WAIT_VOICE; //68  	START_VOICE; //69 -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_69_log); +	_skyScreen->paletteFadeUp(cd_69_pal);  	LOAD_NEW_VOICE(cdv_70);  	WAIT_VOICE; //69 -	startTimerSequence(cd2_seq_data_2); +	_skyScreen->startSequence(cd_69);  	START_VOICE; //70  	LOAD_NEW_VOICE(cdv_71);  	WAIT_VOICE; //70 -	fnFadeDown(0); +	_skyScreen->fnFadeDown(0);  	START_VOICE; //71 -	_skyDisk->loadFile(cd_72_pal, _tempPal); -	_skyDisk->loadFile(cd_72_log, _workScreen); +	_skyDisk->prefetchFile(cd_72_pal); +	_skyDisk->prefetchFile(cd_72_log);  	WAIT_VOICE; //71 -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->showScreen(cd_72_log); +	_skyScreen->paletteFadeUp(cd_72_pal);  	LOAD_NEW_VOICE(cdv_72);  	START_VOICE; //72 -	_skyDisk->loadFile(cd_73_pal, _tempPal); -	_skyDisk->loadFile(cd_73_log, _workScreen); +	_skyDisk->prefetchFile(cd_73_pal); +	_skyDisk->prefetchFile(cd_73_log);  	LOAD_NEW_VOICE(cdv_73);  	WAIT_VOICE; //72 -	fnFadeDown(0); -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_73_log); +	_skyScreen->paletteFadeUp(cd_73_pal);  	START_VOICE; //73  	LOAD_NEW_VOICE(cdv_74);  	WAIT_VOICE; //73 @@ -734,13 +700,11 @@ void SkyState::doCDIntro() {  	LOAD_NEW_VOICE(cdv_75);  	WAIT_VOICE; //74  	START_VOICE; //75 -	_skyDisk->loadFile(cd_76_pal, _tempPal); -	free (workScreen2); -	workScreen2 = _skyDisk->loadFile(cd_76_log, NULL); -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyDisk->prefetchFile(cd_76_pal); +	_skyDisk->prefetchFile(cd_76_log); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_76_log); +	_skyScreen->paletteFadeUp(cd_76_pal);  	LOAD_NEW_VOICE(cdv_76);  	WAIT_VOICE; //75 @@ -749,17 +713,14 @@ void SkyState::doCDIntro() {  	WAIT_VOICE; //76  	START_VOICE; //77 -	free (cd2_seq_data_1); -	cd2_seq_data_1 = _skyDisk->loadFile(cd_100, NULL); -	_skyDisk->loadFile(cd_78_pal, _tempPal); -	free (workScreen2); -	workScreen2 = _skyDisk->loadFile(cd_78_log, NULL); +	_skyDisk->prefetchFile(cd_100); +	_skyDisk->prefetchFile(cd_78_pal); +	_skyDisk->prefetchFile(cd_78_log);  	LOAD_NEW_VOICE(cdv_78);  	WAIT_VOICE; //77 -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen();	 -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_78_log); +	_skyScreen->paletteFadeUp(cd_78_pal);  	START_VOICE; //78  	LOAD_NEW_VOICE(cdv_79);  	WAIT_VOICE; //78 @@ -767,7 +728,7 @@ void SkyState::doCDIntro() {  	LOAD_NEW_VOICE(cdv_80);  	WAIT_VOICE; //79  	START_VOICE; //80 -	startTimerSequence(cd2_seq_data_1); +	_skyScreen->startSequence(cd_100);  	LOAD_NEW_VOICE(cdv_81);  	WAIT_VOICE; //80  	START_VOICE; //81 @@ -776,13 +737,11 @@ void SkyState::doCDIntro() {  	START_VOICE; //82  	LOAD_NEW_VOICE(cdv_83);  	WAIT_VOICE; //82 -	_skyDisk->loadFile(cd_101_log, workScreen2); -	free (cd2_seq_data_2); -	cd2_seq_data_2 = _skyDisk->loadFile(cd_101, NULL); +	_skyDisk->prefetchFile(cd_101_log); +	_skyDisk->prefetchFile(cd_101);  	WAIT_SEQUENCE; //100 -	COPY_SCREEN; -	showScreen(); -	startTimerSequence(cd2_seq_data_2); +	_skyScreen->showScreen(cd_101_log); +	_skyScreen->startSequence(cd_101);  	START_VOICE; //83  	LOAD_NEW_VOICE(cdv_84);  	WAIT_VOICE; //83 @@ -793,50 +752,35 @@ void SkyState::doCDIntro() {  	LOAD_NEW_VOICE(cdv_86);  	WAIT_VOICE; //85 -	free (workScreen2); -	workScreen2 = _skyDisk->loadFile(cd_102_log, NULL); -	free (cd2_seq_data_1); -	cd2_seq_data_1 = _skyDisk->loadFile(cd_102, NULL); +	_skyDisk->prefetchFile(cd_102_log); +	_skyDisk->prefetchFile(cd_102);  	WAIT_SEQUENCE; //101 -	COPY_SCREEN; -	showScreen(); -	startTimerSequence(cd2_seq_data_1); +	_skyScreen->showScreen(cd_102_log); +	_skyScreen->startSequence(cd_102);  	START_VOICE; //86  	LOAD_NEW_VOICE(cdv_87); -	_skyDisk->loadFile(cd_103_pal, _tempPal); -	free (workScreen2); -	workScreen2 = _skyDisk->loadFile(cd_103_log, NULL); -	free (cd2_seq_data_2); -	cd2_seq_data_2 = _skyDisk->loadFile(cd_103, NULL); +	_skyDisk->prefetchFile(cd_103_pal); +	_skyDisk->prefetchFile(cd_103_log); +	_skyDisk->prefetchFile(cd_103);  	WAIT_SEQUENCE; //102 -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); -	startTimerSequence(cd2_seq_data_2); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_103_log); +	_skyScreen->paletteFadeUp(cd_103_pal); +	_skyScreen->startSequence(cd_103);  	WAIT_VOICE; //86  	START_VOICE; //87 -	_skyDisk->loadFile(cd_104_pal, _tempPal); -	free (workScreen2); -	workScreen2 = _skyDisk->loadFile(cd_104_log, NULL); -	free (cd2_seq_data_1); -	cd2_seq_data_1 = _skyDisk->loadFile(cd_104, NULL); +	_skyDisk->prefetchFile(cd_104_pal); +	_skyDisk->prefetchFile(cd_104_log); +	_skyDisk->prefetchFile(cd_104);  	WAIT_SEQUENCE; //103  	_skyMusic->startMusic(2); -	fnFadeDown(0); -	COPY_SCREEN; -	showScreen(); -	paletteFadeUp(_tempPal); -	startTimerSequence(cd2_seq_data_1); -	free (cd2_seq_data_2); -	cd2_seq_data_2 = _skyDisk->loadFile(cd_105, NULL); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(cd_104_log); +	_skyScreen->paletteFadeUp(cd_104_pal); +	_skyScreen->startSequence(cd_104); +	_skyDisk->prefetchFile(cd_105);  	WAIT_SEQUENCE; //104 -	startTimerSequence(cd2_seq_data_2); +	_skyScreen->startSequence(cd_105);  	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 88a180e7b1..3300bd6be1 100644 --- a/sky/disk.cpp +++ b/sky/disk.cpp @@ -31,6 +31,7 @@ static const char *dataFilename = "sky.dsk";  static const char *dinnerFilename = "sky.dnr";  SkyDisk::SkyDisk(char *gameDataPath) { +	_prefRoot = NULL;  	_gameDataPath = gameDataPath;  	_dataDiskHandle = new File(); @@ -58,6 +59,21 @@ SkyDisk::SkyDisk(char *gameDataPath) {  		error("Error opening %s%s!\n", _gameDataPath, dataFilename);  } +SkyDisk::~SkyDisk(void) { + +	prefFile **fEntry = &_prefRoot; +	while (*fEntry) { +		free((*fEntry)->data); +		prefFile *fTemp = *fEntry; +		fEntry = &((*fEntry)->next); +		delete fTemp; +	} +	if (_dnrHandle->isOpen()) _dnrHandle->close(); +	if (_dataDiskHandle->isOpen()) _dataDiskHandle->close(); +	delete _dnrHandle; +	delete _dataDiskHandle; +} +  //load in file file_nr to address dest  //if dest == NULL, then allocate memory for this file  uint8 *SkyDisk::loadFile(uint16 fileNr, uint8 *dest) { @@ -67,6 +83,16 @@ uint8 *SkyDisk::loadFile(uint16 fileNr, uint8 *dest) {  	uint8 *filePtr, *inputPtr, *outputPtr;  	dataFileHeader fileHeader; +	uint8 *prefData = givePrefetched(fileNr, &_lastLoadedFileSize); +	if (prefData) { +		if (dest == NULL) return prefData; +		else { +			memcpy(dest, prefData, _lastLoadedFileSize); +			free(prefData); +			return dest; +		} +	} +  	#ifdef file_order_chk  		warning("File order checking not implemented yet!\n");  	#endif @@ -172,6 +198,45 @@ uint8 *SkyDisk::loadFile(uint16 fileNr, uint8 *dest) {  	return _compDest;  } +void SkyDisk::prefetchFile(uint16 fileNr) { + +    prefFile **fEntry = &_prefRoot; +	bool found = false; +	while (*fEntry) { +		if ((*fEntry)->fileNr == fileNr) found = true; +		fEntry = &((*fEntry)->next); +	} +	if (found) { +		debug(1,"SkyDisk::prefetchFile: File %d was already prefetched.\n",fileNr); +		return ; +	} +	*fEntry = new prefFile; +	(*fEntry)->data = loadFile(fileNr, NULL); +	(*fEntry)->fileSize = _lastLoadedFileSize; +	(*fEntry)->fileNr = fileNr; +	(*fEntry)->next = NULL; +} + +uint8 *SkyDisk::givePrefetched(uint16 fileNr, uint32 *fSize) { +	 +	prefFile **fEntry = &_prefRoot; +	bool found = false; +	while ((*fEntry) && (!found)) { +		if ((*fEntry)->fileNr == fileNr) found = true; +		else fEntry = &((*fEntry)->next); +	} +	if (!found) { +		*fSize = 0; +		return NULL; +	} +	uint8 *retPtr = (*fEntry)->data; +	prefFile *retStr = *fEntry; +	*fEntry = (*fEntry)->next; +	*fSize = retStr->fileSize; +	delete retStr; +    return retPtr; +} +  uint8 *SkyDisk::getFileInfo(uint16 fileNr) {  	uint16 i; @@ -237,4 +302,3 @@ uint32 SkyDisk::determineGameVersion() {  		break;  	}  } - diff --git a/sky/disk.h b/sky/disk.h index a824748433..38801ad8cf 100644 --- a/sky/disk.h +++ b/sky/disk.h @@ -26,15 +26,28 @@  #define MAX_FILES_IN_LIST		60 +typedef struct __prefFile { +	uint8 *data; +	uint16 fileNr; +	uint32 fileSize; +	struct __prefFile *next; +} prefFile; +  class SkyDisk {  public:  	SkyDisk(char *gameDataPath); +	~SkyDisk(void);  	uint8 *loadFile(uint16 fileNr, uint8 *dest); +	void prefetchFile(uint16 fileNr); +  	uint32 determineGameVersion();  	uint32 _lastLoadedFileSize;  protected: +	prefFile *_prefRoot; +    uint8 *givePrefetched(uint16 fileNr, uint32 *fSize); +  	uint8 *getFileInfo(uint16 fileNr);  	void dumpFile(uint16 fileNr); diff --git a/sky/intro.cpp b/sky/intro.cpp index e3de93dc92..61c683f553 100644 --- a/sky/intro.cpp +++ b/sky/intro.cpp @@ -25,10 +25,10 @@  #include "sky/skydefs.h"  #include "sky/sky.h" -#define WAIT_SEQUENCE	while (_tseqFrames != 0) { checkCommands(commandPtr); delay(50); CHECK_ESC } -#define CHECK_ESC	if (_key_pressed == 27) { _tseqFrames = 0; REMOVE_INTRO return; } +//#define WAIT_SEQUENCE	while (_tseqFrames != 0) { checkCommands(commandPtr); delay(50); CHECK_ESC } +//#define CHECK_ESC	if (_key_pressed == 27) { _tseqFrames = 0; REMOVE_INTRO return; }  #define FREE_IF_NOT_0(ptr)	if (ptr != NULL) { free (ptr); ptr = 0; } -#define REMOVE_INTRO	commandPtr = (uint32 *)zeroCommands; \ +/*#define REMOVE_INTRO	commandPtr = (uint32 *)zeroCommands; \  			FREE_IF_NOT_0(_vgaData) \  			FREE_IF_NOT_0(_diffData) \  			FREE_IF_NOT_0(_workBase) \ @@ -36,7 +36,12 @@  			FREE_IF_NOT_0(seq1) \  			FREE_IF_NOT_0(seq2) \  			FREE_IF_NOT_0(_introTextSpace) \ -			FREE_IF_NOT_0(_introTextSave)  +			FREE_IF_NOT_0(_introTextSave) */ +#define REMOVE_INTRO	commandPtr = (uint32 *)zeroCommands; \ +			FREE_IF_NOT_0(_introTextSpace) \ +			FREE_IF_NOT_0(_introTextSave) +#define CHECK_ESC if (_key_pressed == 27) { _skyScreen->stopSequence(); REMOVE_INTRO return; } +#define WAIT_SEQUENCE while (_skyScreen->sequenceRunning()) { checkCommands(commandPtr); delay(50); CHECK_ESC }  #define INTRO_TEXT_WIDTH    128 @@ -192,28 +197,16 @@ static const commandRoutinesProc commandRoutines[] = {  void SkyState::initVirgin() { -	_tempPal = _skyDisk->loadFile(60111, NULL); -	if (_tempPal != NULL) -		setPalette(_tempPal); - -	_workScreen = _skyDisk->loadFile(60110, NULL); - -	if (_workScreen != NULL) -		showScreen(); - -	// free the memory that was malloc'ed indirectly via load_file -	free(_workScreen); -	free(_tempPal); +	_skyScreen->setPalette(60111); +	_skyScreen->showScreen(60110);  }  void SkyState::intro(void) { -	uint8 *seq1 = 0; -	uint8 *seq2 = 0;  	uint32 *commandPtr = (uint32 *)zeroCommands; -	_workScreen = _skyDisk->loadFile(60112, NULL); //while virgin screen is up, load rev screen -	_tempPal = _skyDisk->loadFile(60113, NULL); +	_skyDisk->prefetchFile(60112); // revolution screen +	_skyDisk->prefetchFile(60113); // revolution palette  	_skyMusic->loadSectionMusic(0); @@ -225,15 +218,15 @@ void SkyState::intro(void) {  	delay(3000); //and another 3 seconds.  	CHECK_ESC -	fnFadeDown(0); //remove virgin screen -	showScreen(); -	paletteFadeUp(_tempPal); -	free (_tempPal); -	free (_workScreen); +	_skyScreen->fnFadeDown(0); //remove virgin screen +	 +	_skyScreen->showScreen(60112); +	_skyScreen->paletteFadeUp(60113); +  	//while rev is up, load gibbons screen -	_workScreen = _skyDisk->loadFile(60114, NULL); -	_tempPal = _skyDisk->loadFile(60115, NULL); +	_skyDisk->prefetchFile(60114); // gibbo screen +	_skyDisk->prefetchFile(60115); // gibbo palette  	_introTextSpace = (uint8 *)calloc(10000, 1);  	_introTextSave = (uint8 *)calloc(10000, 1); @@ -243,220 +236,165 @@ void SkyState::intro(void) {  	delay(8000); // keep revolution up for 8 seconds  	CHECK_ESC -	fnFadeDown(0); -	showScreen(); -	paletteFadeUp(_tempPal); +	_skyScreen->fnFadeDown(0); +	_skyScreen->showScreen(60114); +	_skyScreen->paletteFadeUp(60115); -	free (_tempPal); -	free (_workScreen);  	if (isCDVersion(_gameVersion)) {  		doCDIntro();  	} else { - -		_tempPal = _skyDisk->loadFile(FN_A_PAL, NULL); -		_workScreen = _skyDisk->loadFile(FN_1A_LOG, NULL); -		seq2 = _skyDisk->loadFile(FN_1A, NULL); +		_skyDisk->prefetchFile(FN_A_PAL); +		_skyDisk->prefetchFile(FN_1A_LOG); +		_skyDisk->prefetchFile(FN_1A);  		//keep gibbo up for 2 seconds  		delay(2000);  		CHECK_ESC -		fnFadeDown(0); -		showScreen(); -		paletteFadeUp(_tempPal); +		_skyScreen->fnFadeDown(0); -		startTimerSequence(seq2); -		free(_tempPal); -		 -		seq1 = _skyDisk->loadFile(FN_1B, NULL); +		_skyScreen->showScreen(FN_1A_LOG); +		_skyScreen->paletteFadeUp(FN_A_PAL); +		_skyScreen->startSequence(FN_1A);	 +		_skyDisk->prefetchFile(FN_1B);  		WAIT_SEQUENCE; -		free (seq2); -		seq2 = _skyDisk->loadFile(FN_1C, NULL); -		startTimerSequence(seq1); -		WAIT_SEQUENCE; -		startTimerSequence(seq2); +		_skyScreen->startSequence(FN_1B); +		_skyDisk->prefetchFile(FN_1C);  		WAIT_SEQUENCE; -		free(seq1); -		free(seq2); -		seq1 = _skyDisk->loadFile(FN_1D, NULL); -		seq2 = _skyDisk->loadFile(FN_1E, NULL); +		_skyScreen->startSequence(FN_1C); +		_skyDisk->prefetchFile(FN_1D); +		WAIT_SEQUENCE; -		startTimerSequence(seq1); +		_skyScreen->startSequence(FN_1D); +		_skyDisk->prefetchFile(FN_1E);  		WAIT_SEQUENCE; -		startTimerSequence(seq2); -		free(seq1); +		_skyScreen->startSequence(FN_1E); -		_vgaData = _skyDisk->loadFile(60100, NULL); -		_vgaPointer = _vgaData; -		_diffData = _skyDisk->loadFile(60101, NULL); -	 -		_noFrames = READ_LE_UINT16(_diffData); -		_diffPointer = _diffData + 2; +		uint8 *vgaData, *diffData, *vgaPointer, *diffPointer, *scrollData; +		uint8 *currScreenPos; +		vgaData = _skyDisk->loadFile(60100, NULL); +		vgaPointer = vgaData; +		diffData = _skyDisk->loadFile(60101, NULL); +		diffPointer = diffData + 2; +		uint16 noFrames = READ_LE_UINT16(diffData); -		seq1 = _skyDisk->loadFile(FN_4A, NULL); +		_skyDisk->prefetchFile(FN_4A);  		WAIT_SEQUENCE;		 -		free (seq2);  		//set up the scrolling intro -		_workBase = (byte *)malloc(GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT * 2); - +		scrollData = (byte *)malloc(GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT * 2);  		//clear the base -		memset(_workBase, 0, GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT);	 - -		WAIT_SEQUENCE;	//1e - -		memcpy(_workBase + (GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT), _workScreen, GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT);  -		free(_workScreen);  -		_workScreen = _workBase + (GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT); -		_workScreenEnd = _workScreen + (GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT);	 - -		_frameCounter = 1; +		memset(scrollData, 0, GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT);	 +		memcpy(scrollData + (GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT), _skyScreen->giveCurrent(), GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT);  +		currScreenPos = scrollData + (GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT);  		byte scrollByte;  - -		while (_frameCounter < _noFrames) { -	 -			scrollByte = *_diffPointer++; -			if (scrollByte) { -				_workScreen -= scrollByte * GAME_SCREEN_WIDTH; -				_workScreenEnd -= scrollByte * GAME_SCREEN_WIDTH; -			} +		for (uint16 frameCounter = 1; frameCounter < noFrames; frameCounter++) { +			scrollByte = *diffPointer++; +			if (scrollByte) +				currScreenPos -= scrollByte * GAME_SCREEN_WIDTH;  			delay(40);   			if (_key_pressed == 27) { -				_workScreen = (byte *)calloc(FULL_SCREEN_WIDTH * FULL_SCREEN_HEIGHT, 1);  				REMOVE_INTRO;  				return;  			}  			//non-scrolling frame update -			introFrame(); - +			introFrame(&diffPointer, &vgaPointer, currScreenPos); +			_skyScreen->showScreen(currScreenPos);  		} - -		startTimerSequence(seq1); -		free(_vgaData); -		_vgaData = 0; -		free(_diffData); -		_diffData = 0; +		memcpy(_skyScreen->giveCurrent(), currScreenPos, GAME_SCREEN_HEIGHT * GAME_SCREEN_WIDTH); +		_skyScreen->startSequence(FN_4A); +		free(scrollData); +		free(vgaData); +		free(diffData);  		WAIT_SEQUENCE; -		free(_workBase); -		_workBase = 0; -		_workScreen = _skyDisk->loadFile(FN_4B_LOG, NULL); -		seq2 = _skyDisk->loadFile(FN_4B, NULL);	 - -		showScreen(); +		_skyDisk->prefetchFile(FN_4B); +		_skyScreen->showScreen(FN_4B_LOG); -		commandPtr = (uint32 *)anim4aCommands;  -		WAIT_SEQUENCE;  +		/*commandPtr = (uint32 *)anim4aCommands;  +		WAIT_SEQUENCE; */ +		printf("anim 4A commands skipped.\n");  		commandPtr = (uint32 *)cockpitCommands; -		startTimerSequence(seq2);  +		_skyScreen->startSequence(FN_4B);  		checkCommands(commandPtr);  		checkCommands(commandPtr);  		WAIT_SEQUENCE; //4b -		free (_workScreen); -		_workScreen = 0; -		free (seq1); -		_workScreen = _skyDisk->loadFile(FN_4C_LOG, NULL); -		seq1 = _skyDisk->loadFile(FN_4C, NULL); +		_skyDisk->prefetchFile(FN_4C); -		showScreen(); -		startTimerSequence(seq1); -		free(seq2); +		_skyScreen->showScreen(FN_4C_LOG); +		_skyScreen->startSequence(FN_4C);  		commandPtr = (uint32 *)anim4cCommands;  		WAIT_SEQUENCE; //4c -		free (_workScreen); -		_tempPal = _skyDisk->loadFile(FN_5_PAL, NULL); -		_workScreen = _skyDisk->loadFile(FN_5_LOG, NULL); -		seq2 = _skyDisk->loadFile(FN_5, NULL); +		_skyDisk->prefetchFile(FN_5_PAL); +		_skyDisk->prefetchFile(FN_5_LOG); +		_skyDisk->prefetchFile(FN_5); -		fnFadeDown(0); -		showScreen(); -		paletteFadeUp(_tempPal); +		_skyScreen->fnFadeDown(0); +		_skyScreen->showScreen(FN_5_LOG); +		_skyScreen->paletteFadeUp(FN_5_PAL); -		startTimerSequence(seq2); -		free (_tempPal); -		free (seq1); +		_skyScreen->startSequence(FN_5);  		commandPtr = (uint32 *)anim5Commands;  		WAIT_SEQUENCE; -		free (_workScreen); -		_tempPal = _skyDisk->loadFile(FN_6_PAL, NULL); -		_workScreen = _skyDisk->loadFile(FN_6_LOG, NULL); -		seq1 = _skyDisk->loadFile(FN_6A, NULL); +		_skyDisk->prefetchFile(FN_6_PAL); +		_skyDisk->prefetchFile(FN_6_LOG); +		_skyDisk->prefetchFile(FN_6A); -		fnFadeDown(0); -		showScreen(); +		_skyScreen->fnFadeDown(0); +		_skyScreen->showScreen(FN_6_LOG);  		_skyMusic->startMusic(2); -		paletteFadeUp(_tempPal); +		_skyScreen->paletteFadeUp(FN_6_PAL); -		startTimerSequence(seq1); -		free (seq2); -		seq2 = _skyDisk->loadFile(FN_6B, NULL); +		_skyScreen->startSequence(FN_6A); +		_skyDisk->prefetchFile(FN_6B);  		commandPtr = (uint32 *)anim6aCommands;  		WAIT_SEQUENCE; //6a -		free (seq1); -		free (_tempPal); -		 -		startTimerSequence(seq2); +		_skyScreen->startSequence(FN_6B);  		commandPtr = (uint32 *)anim6bCommands;  		WAIT_SEQUENCE; //6b -		free (seq2); -  	} - -} - -void SkyState::showScreen(void) { -	 -	_system->copy_rect(_workScreen, 320, 0, 0, GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT); -	_system->update_screen();  } -void SkyState::introFrame(void) { +void SkyState::introFrame(uint8 **diffPtr, uint8 **vgaPtr, uint8 *screenData) { -	_frameCounter++; -	byte *diffPtr = _diffPointer; -	byte *vgaPtr = _vgaPointer; -	byte *scrPtr = _workScreen; -	byte count; +	uint32 scrPos = 0; +	uint8 nrToSkip, nrToDo;  	do {  		do { -			count = *diffPtr++; -			scrPtr += count; -		} while (count == 255); +			nrToSkip = **diffPtr; +			(*diffPtr)++; +			scrPos += nrToSkip; +		} while (nrToSkip == 255);  		do { -			count = *diffPtr++; -			memcpy(scrPtr, vgaPtr, count); -			scrPtr += count; -			vgaPtr += count; -		} while (*(diffPtr - 1) == 255); - -	} while (scrPtr < _workScreenEnd); - -	_diffPointer = diffPtr; -	_vgaPointer = vgaPtr; - -	showScreen(); - +			nrToDo = **diffPtr; +			(*diffPtr)++; +			memcpy(screenData + scrPos, *vgaPtr, nrToDo); +			scrPos += nrToDo; +			*vgaPtr += nrToDo; +		} while (nrToDo == 255); + +	} while (scrPos < GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT);  }  void SkyState::checkCommands(uint32 *&cmdPtr) { @@ -466,7 +404,7 @@ void SkyState::checkCommands(uint32 *&cmdPtr) {  	uint32 afterFrame = *(cmdPtr); -	if (afterFrame >= _tseqFrames) {  +	if (afterFrame >= _skyScreen->seqFramesLeft()) {   		//do a command  		uint32 command = *(cmdPtr + 1); @@ -482,6 +420,7 @@ void SkyState::prepareText(uint32 *&cmdPtr) {  	cmdPtr += 3;    } +#define _workScreen _skyScreen->giveCurrent()  void SkyState::showIntroText(uint32 *&cmdPtr) {  	uint32 xPos = *(cmdPtr + 2);  @@ -550,6 +489,7 @@ void SkyState::removeText(uint32 *&cmdPtr) {  	cmdPtr += 2;  } +#undef _workScreen  void SkyState::introFx(uint32 *&cmdPtr) { diff --git a/sky/screen.cpp b/sky/screen.cpp index b3db1d4d9e..5acc188ad3 100644 --- a/sky/screen.cpp +++ b/sky/screen.cpp @@ -19,18 +19,9 @@   *   */ -#include "stdafx.h" -#include <string.h> -#include "common/scummsys.h" -#include "sky/skydefs.h" -#include "sky/sky.h" +#include "screen.h" -#define SCROLL_JUMP		16 - -#define VGA_COLOURS		256 -#define GAME_COLOURS		240 - -uint8 top16Colours[] = +uint8 SkyScreen::_top16Colours[16*3] =  {  	0, 0, 0,  	38, 38, 38, @@ -50,39 +41,76 @@ uint8 top16Colours[] =  	63, 63, 63  }; -void SkyState::initialiseScreen(void) { -	 +SkyScreen::SkyScreen(OSystem *pSystem, SkyDisk *pDisk) { + +	_system = pSystem; +	_skyDisk = pDisk; +  	int i;  	uint8 tmpPal[1024];  	_system->init_size(FULL_SCREEN_WIDTH, FULL_SCREEN_HEIGHT); -	_backScreen = (uint8 *)malloc(FULL_SCREEN_WIDTH * FULL_SCREEN_HEIGHT); -	//_gameGrid = (uint8 *)malloc(GRID_X * GRID_Y * 2); -	_workPalette = (uint8 *)malloc(VGA_COLOURS * 3); +	_gameGrid = (uint8 *)malloc(GRID_X * GRID_Y * 2); +	_currentScreen = NULL;  	//blank the first 240 colors of the palette   	memset(tmpPal, 0, GAME_COLOURS * 4);  	//set the remaining colors  	for (i = 0; i < (VGA_COLOURS-GAME_COLOURS); i++) { -		tmpPal[4 * GAME_COLOURS + i * 4] = (top16Colours[i * 3] << 2) + (top16Colours[i * 3] & 3); -		tmpPal[4 * GAME_COLOURS + i * 4 + 1] = (top16Colours[i * 3 + 1] << 2) + (top16Colours[i * 3 + 1] & 3); -		tmpPal[4 * GAME_COLOURS + i * 4 + 2] = (top16Colours[i * 3 + 2] << 2) + (top16Colours[i * 3 + 2] & 3); +		tmpPal[4 * GAME_COLOURS + i * 4] = (_top16Colours[i * 3] << 2) + (_top16Colours[i * 3] & 3); +		tmpPal[4 * GAME_COLOURS + i * 4 + 1] = (_top16Colours[i * 3 + 1] << 2) + (_top16Colours[i * 3 + 1] & 3); +		tmpPal[4 * GAME_COLOURS + i * 4 + 2] = (_top16Colours[i * 3 + 2] << 2) + (_top16Colours[i * 3 + 2] & 3);  		tmpPal[4 * GAME_COLOURS + i * 4 + 3] = 0x00;   	}  	//set the palette  	_system->set_palette(tmpPal, 0, VGA_COLOURS); + +	_seqInfo.framesLeft = 0; +	_seqInfo.seqData = _seqInfo.seqDataPos = NULL; +	_seqInfo.running = false; +} + +SkyScreen::~SkyScreen(void) { + +	free(_gameGrid); +	if (_currentScreen) free(_currentScreen);  }  //set a new palette, pal is a pointer to dos vga rgb components 0..63 -void SkyState::setPalette(uint8 *pal) { +void SkyScreen::setPalette(uint8 *pal) {  	convertPalette(pal, _palette);  	_system->set_palette(_palette, 0, GAME_COLOURS); +	_system->update_screen(); +} + +void SkyScreen::setPalette(uint16 fileNum) { + +	uint8 *tmpPal = _skyDisk->loadFile(fileNum, NULL); +	if (tmpPal) { +		setPalette(tmpPal); +		free(tmpPal); +	} else warning("SkyScreen::setPalette: can't load file nr. %d\n",fileNum); +} + +void SkyScreen::showScreen(uint16 fileNum) { + +	if (_currentScreen) free(_currentScreen); +	_currentScreen = _skyDisk->loadFile(fileNum, NULL); +	 +	if (_currentScreen) showScreen(_currentScreen); +	else warning("SkyScreen::showScreen: can't load file nr. %d\n",fileNum); +} + +void SkyScreen::showScreen(uint8 *pScreen) { + +	_system->copy_rect(pScreen, 320, 0, 0, GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT); +	_system->update_screen();  } -void SkyState::convertPalette(uint8 *inPal, uint8* outPal) { //convert 3 byte 0..63 rgb to 4byte 0..255 rgbx +void SkyScreen::convertPalette(uint8 *inPal, uint8* outPal) { //convert 3 byte 0..63 rgb to 4byte 0..255 rgbx  	int i; @@ -97,30 +125,24 @@ void SkyState::convertPalette(uint8 *inPal, uint8* outPal) { //convert 3 byte 0.  //action = 0, simply fade out  //action = 1, scroll left  //action = 2, scroll right -void SkyState::fnFadeDown(uint8 action) { +void SkyScreen::fnFadeDown(uint8 action) {  	if (action) {  		//do scroll +		warning("SkyScreen::fnFadeDown: Scrolling not yet implemented!\n");  	} else { -	 -		int i = 32; - -		do { +		for (uint8 cnt = 0; cnt < 32; cnt++) {  			palette_fadedown_helper((uint32 *)_palette, GAME_COLOURS);  			_system->set_palette(_palette, 0, GAME_COLOURS);  			_system->update_screen(); -			delay(10); -			 -		} while (--i); -	 +			waitForTimer();			 +		}  	} - -	  } -void SkyState::palette_fadedown_helper(uint32 *pal, uint num) { +void SkyScreen::palette_fadedown_helper(uint32 *pal, uint num) {  	byte *p = (byte *)pal;  	do { @@ -140,42 +162,43 @@ void SkyState::palette_fadedown_helper(uint32 *pal, uint num) {  	} while (--num);  } -void SkyState::paletteFadeUp(uint8 *pal) { +void SkyScreen::paletteFadeUp(uint16 fileNr) { + +	uint8 *pal = _skyDisk->loadFile(fileNr, NULL); +	if (pal) { +		paletteFadeUp(pal); +        free(pal); +	} else printf("SkyScreen::paletteFadeUp: Can't load palette #%d\n",fileNr); +} + +void SkyScreen::paletteFadeUp(uint8 *pal) {  	byte tmpPal[1024];  	convertPalette(pal, tmpPal); -	int i = 32; - -	do { - +	for (uint8 cnt = 0; cnt < 32; cnt++) {  		palette_fadeup_helper((uint32 *)_palette, (uint32 *)tmpPal, GAME_COLOURS);  		_system->set_palette(_palette, 0, GAME_COLOURS);  		_system->update_screen(); -		delay(10);	 -	} while (--i); -	 +		waitForTimer(); +	}	  } -void SkyState::palette_fadeup_helper(uint32 *realPal, uint32 *desiredPal, int num) { +void SkyScreen::palette_fadeup_helper(uint32 *realPal, uint32 *desiredPal, int num) {  	byte *r = (byte *)realPal;  	byte *d = (byte *)desiredPal;  	do { -		if (r[0] < d[0]-8) -			r[0] += 8; -		else -			r[0] = d[0]; -		if (r[1] < d[1]-8) -			r[1] += 8; -		else -			r[1] = d[1]; -		if (r[2] < d[2]-8) -			r[2] += 8; -		else -			r[2] = d[2]; +		if (r[0] < d[0]-8) r[0] += 8; +		else r[0] = d[0]; + +		if (r[1] < d[1]-8) r[1] += 8; +		else r[1] = d[1]; + +		if (r[2] < d[2]-8) r[2] += 8; +		else r[2] = d[2];  		r += sizeof(uint32);  		d += sizeof(uint32); @@ -183,3 +206,74 @@ void SkyState::palette_fadeup_helper(uint32 *realPal, uint32 *desiredPal, int nu  } +void SkyScreen::waitForTimer(void) { + +	_gotTick = false; +	while (!_gotTick) +		_system->delay_msecs(10); +} + +void SkyScreen::handleTimer(void) { + +	_gotTick = true; +	if (_seqInfo.running) processSequence(); +} + +void SkyScreen::startSequence(uint16 fileNum) { + +	_seqInfo.seqData = _skyDisk->loadFile(fileNum, NULL); +	_seqInfo.framesLeft = _seqInfo.seqData[0]; +	_seqInfo.seqDataPos = _seqInfo.seqData + 1; +	_seqInfo.delay = SEQ_DELAY; +	_seqInfo.running = true; +} + +void SkyScreen::stopSequence() { + +	_seqInfo.running = false; +	waitForTimer(); +	waitForTimer(); +	_seqInfo.framesLeft = 0; +	free(_seqInfo.seqData); +	_seqInfo.seqData = _seqInfo.seqDataPos = NULL; +} + +void SkyScreen::processSequence(void) { + +	uint32 screenPos = 0; + +	_seqInfo.delay--; +	if (_seqInfo.delay == 0) { +		_seqInfo.delay = SEQ_DELAY; + +        uint8 nrToSkip, nrToDo, cnt; +		do { +			do { +				nrToSkip = _seqInfo.seqDataPos[0]; +				_seqInfo.seqDataPos++; +				screenPos += nrToSkip; +			} while (nrToSkip == 0xFF); +			do { +				nrToDo = _seqInfo.seqDataPos[0]; +				_seqInfo.seqDataPos++; +				for (cnt = 0; cnt < nrToDo; cnt++) { +					_currentScreen[screenPos] = _seqInfo.seqDataPos[0]; +					_seqInfo.seqDataPos++; +					screenPos++; +				} +			} while (nrToDo == 0xFF); +		} while (screenPos < (GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT)); +		showScreen(_currentScreen); +		_seqInfo.framesLeft--; +	} +	if (_seqInfo.framesLeft == 0) { +		_seqInfo.running = false; +		free(_seqInfo.seqData); +		_seqInfo.seqData = _seqInfo.seqDataPos = NULL; +	} +} + +bool SkyScreen::sequenceRunning(void) { + +	return _seqInfo.running; +} diff --git a/sky/screen.h b/sky/screen.h new file mode 100644 index 0000000000..bcc742117c --- /dev/null +++ b/sky/screen.h @@ -0,0 +1,93 @@ +/* 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$ + * + */ + +#ifndef SKYSCREEN_H +#define SKYSCREEN_H + +#include "stdafx.h" +#include <string.h> +#include "common/engine.h" +#include "common/scummsys.h" +#include "sky/disk.h" +#include "sky/skydefs.h" +#include "sky/sky.h" + +#define SCROLL_JUMP		16 +#define VGA_COLOURS		256 +#define GAME_COLOURS		240 +#define SEQ_DELAY 3 + +class SkyScreen { +public: +	SkyScreen(OSystem *pSystem, SkyDisk *pDisk); +	~SkyScreen(void); +	void setPalette(uint8 *pal); +	void setPalette(uint16 fileNum); + +	void fnFadeDown(uint8 action); +	void paletteFadeUp(uint8 *pal); +	void paletteFadeUp(uint16 fileNr); + +	void showScreen(uint16 fileNum); +	void showScreen(uint8 *pScreen); +	 +	void handleTimer(void); +	void startSequence(uint16 fileNum); +	void stopSequence(void); +	bool sequenceRunning(void); +	uint32 seqFramesLeft(void) { return _seqInfo.framesLeft; }; +	uint8 *giveCurrent(void) { return _currentScreen; }; +private: +	OSystem *_system; +	SkyDisk *_skyDisk; +	static uint8 _top16Colours[16*3]; +	uint8 _palette[1024]; + +	bool volatile _gotTick; + +	void waitForTimer(void); + +	struct { +		uint32 framesLeft; +		uint32 delay; +		uint8 *seqData; +		uint8 *seqDataPos; +		bool running; +	} _seqInfo; +	void processSequence(void); + +	uint8 *_currentScreen; + +	//byte *_workScreen; +	//byte *_backScreen; +	//byte *_tempPal; +	//byte *_workPalette; +	//byte *_halfPalette; +	//byte *_scrollAddr; +	//byte *_lScreenBuf, *_lPaletteBuf; +	byte *_gameGrid; + +	void convertPalette(uint8 *inPal, uint8* outPal); +	void palette_fadedown_helper(uint32 *pal, uint num); +	void palette_fadeup_helper(uint32 *realPal, uint32 *desiredPal, int num); +}; + +#endif //SKYSCREEN_H diff --git a/sky/sky.cpp b/sky/sky.cpp index cead2b69a3..761bdcce9e 100644 --- a/sky/sky.cpp +++ b/sky/sky.cpp @@ -105,7 +105,6 @@ void SkyState::go() {  void SkyState::initialise(void) {  	//initialise_memory(); -	initTimer();  	_skySound = new SkySound(_mixer);  	_skyDisk = new SkyDisk(_gameDataPath); @@ -123,7 +122,7 @@ void SkyState::initialise(void) {  	_skyText = new SkyText(_skyDisk, _gameVersion, _language);  	_skyMouse = new SkyMouse(_skyDisk); -	initialiseScreen(); +	_skyScreen = new SkyScreen(_system, _skyDisk);  	initVirgin();  	//initMouse();  	initItemList(); @@ -132,6 +131,9 @@ void SkyState::initialise(void) {  	loadFixedItems();  	_skyGrid = new SkyGrid(_skyDisk);  	_skyLogic = new SkyLogic(_skyDisk, _skyGrid, _skyText, _skyMusic, _skyMouse, _gameVersion); +	 +	_timer = Engine::_timer; // initialize timer *after* _skyScreen has been initialized. +	_timer->installProcedure(&timerHandler, 1000000 / 50); //call 50 times per second  }  void SkyState::initItemList() { @@ -188,6 +190,16 @@ void SkyState::loadFixedItems(void) {  } +void SkyState::timerHandler(void *ptr) { + +	((SkyState*)ptr)->gotTimerTick(); +} + +void SkyState::gotTimerTick(void) { + +	_skyScreen->handleTimer(); +} +  Compact *SkyState::fetchCompact(uint32 a) {  	SkyDebug::fetchCompact(a);  	uint32 sectionNum = (a & 0xf000) >> 12; @@ -272,6 +284,7 @@ bool SkyState::isDemo(uint32 version) {  }  bool SkyState::isCDVersion(uint32 version) { +  	switch (version) {  	case 267:  		return false; @@ -32,6 +32,7 @@  #include "sky/disk.h"  #include "sky/struc.h"  #include "sky/grid.h" +#include "sky/screen.h"  #include "sky/musicbase.h"  #include "sky/adlibmusic.h"  #include "sky/gmmusic.h" @@ -41,6 +42,7 @@  class SkyLogic;  class SkyGrid;  class SkyAutoRoute; +class SkyScreen;  class SkyState : public Engine {  	void errorString(const char *buf_input, char *buf_output); @@ -49,19 +51,8 @@ protected:  	uint32 _gameVersion;  	byte _key_pressed; -	uint32 _tseqFrames; -	byte *_tseqData; -	uint32 _tseqCounter; -  	//intro related -	uint8 *_vgaData; -	uint8 *_diffData; -	uint8 *_workBase; -	uint8 *_workScreenEnd; -	uint8 *_vgaPointer; -	uint8 *_diffPointer; -	uint32 _noFrames;   //number of frames in scrolling intro -	uint32 _frameCounter; +	  	byte *_introTextSpace;  	byte *_introTextSave; @@ -73,8 +64,6 @@ protected:  	bool _mouse_pos_changed;  	uint _left_button_down; -	uint8 _palette[1024]; -  	int _numScreenUpdates;  	Timer *_timer; @@ -92,17 +81,11 @@ protected:  	SkyGrid *_skyGrid;  	SkyLogic *_skyLogic;  	SkyMouse *_skyMouse; +	SkyScreen *_skyScreen;  	SkyMusicBase *_skyMusic;  	GameDetector *_detector; // necessary for music -	byte *_workScreen; -	byte *_backScreen; -	byte *_tempPal; -	byte *_workPalette; -	byte *_halfPalette; -	byte *_scrollAddr; -	  public:  	SkyState(GameDetector *detector, OSystem *syst);  	virtual ~SkyState(); @@ -127,30 +110,21 @@ protected:  	void delay(uint amount);  	void pollMouseXY();  	void go(); -	void convertPalette(uint8 *inpal, uint8* outpal);  	//intro related  	void checkCommands(uint32 *&cmdPtr); -	void introFrame(); +	void introFrame(uint8 **diffPtr, uint8 **vgaPtr, uint8 *screenData);  	SkyText *getSkyText();  	void initialise(); -	void initTimer(); -	void initialiseScreen(); -	void initialiseGrids();  	void initItemList(); -	void setPalette(uint8 *pal); -	void fnFadeDown(uint8 action); -	void palette_fadedown_helper(uint32 *pal, uint num); -	void paletteFadeUp(uint8 *pal); -	void palette_fadeup_helper(uint32 *realPal, uint32 *desiredPal, int num); +  	void initVirgin();  	void intro();  	void doCDIntro(); -	void showScreen();  	void startTimerSequence(byte *sequence);  	static void timerHandler(void *ptr); -	void doTimerSequence(); +	void gotTimerTick();  	void loadFixedItems();  	void loadBase0(); diff --git a/sky/timer.cpp b/sky/timer.cpp deleted file mode 100644 index 50a91c279d..0000000000 --- a/sky/timer.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* 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(5, "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; - -	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--; -		 -}  | 
