Added a WaitForFade() function, to replace numerous while-loops scattered

througout the code.

svn-id: r10127
This commit is contained in:
Torbjörn Andersson 2003-09-09 12:14:08 +00:00
parent 29607a17ef
commit bb5f479a8c
6 changed files with 25 additions and 119 deletions

View file

@ -349,22 +349,7 @@ void DisplayMsg(uint8 *text, int time) { // Chris 15May97
if (GetFadeStatus() != RDFADE_BLACK) { if (GetFadeStatus() != RDFADE_BLACK) {
FadeDown((float) 0.75); FadeDown((float) 0.75);
WaitForFade();
do {
//--------------------------------------------------
// Service windows
while (!gotTheFocus)
if (ServiceWindows() == RDERR_APPCLOSED)
break;
// if we pressed Ctrl-Q
if (ServiceWindows() == RDERR_APPCLOSED) {
Close_game(); //close engine systems down
CloseAppWindow();
exit(0); //quit the game
}
//--------------------------------------------------
} while (GetFadeStatus() == RDFADE_DOWN);
} }
Set_mouse(0); Set_mouse(0);
@ -416,21 +401,7 @@ void DisplayMsg(uint8 *text, int time) { // Chris 15May97
Free_mem(text_spr); Free_mem(text_spr);
do { WaitForFade();
//--------------------------------------------------
// Service windows
while (!gotTheFocus)
if (ServiceWindows() == RDERR_APPCLOSED)
break;
// if we pressed Ctrl-Q
if (ServiceWindows() == RDERR_APPCLOSED) {
Close_game(); //close engine systems down
CloseAppWindow();
exit(0); //quit the game
}
//--------------------------------------------------
} while (GetFadeStatus() == RDFADE_UP);
uint32 targetTime = SVM_timeGetTime() + (time * 1000); uint32 targetTime = SVM_timeGetTime() + (time * 1000);
@ -473,22 +444,7 @@ void DisplayMsg(uint8 *text, int time) { // Chris 15May97
void RemoveMsg(void) { // Chris 15May97 void RemoveMsg(void) { // Chris 15May97
FadeDown((float) 0.75); FadeDown((float) 0.75);
do { WaitForFade();
//--------------------------------------------------
// Service windows
while (!gotTheFocus)
if (ServiceWindows() == RDERR_APPCLOSED)
break;
// if we pressed Ctrl-Q
if (ServiceWindows() == RDERR_APPCLOSED)
{
Close_game(); //close engine systems down
CloseAppWindow();
exit(0); //quit the game
}
//--------------------------------------------------
} while (GetFadeStatus() == RDFADE_DOWN);
EraseBackBuffer(); // for hardware rendering EraseBackBuffer(); // for hardware rendering
EraseSoftwareScreenBuffer(); // for software rendering EraseSoftwareScreenBuffer(); // for software rendering
@ -1054,10 +1010,7 @@ void Start_new_palette(void) { //Tony25Sept96
// if the screen is still fading down then wait for black - could // if the screen is still fading down then wait for black - could
// happen when everythings cached into a large memory model // happen when everythings cached into a large memory model
WaitForFade();
do {
ServiceWindows();
} while (GetFadeStatus() == RDFADE_DOWN);
// open the screen file // open the screen file
screenFile = res_man.Res_open(this_screen.background_layer_id); screenFile = res_man.Res_open(this_screen.background_layer_id);
@ -1111,9 +1064,7 @@ int32 FN_fade_down(int32 *params) { //Tony5Dec96
} }
int32 FN_fade_up(int32 *params) { //Chris 15May97 int32 FN_fade_up(int32 *params) { //Chris 15May97
do { WaitForFade();
ServiceWindows();
} while (GetFadeStatus() == RDFADE_DOWN);
if (GetFadeStatus() == RDFADE_BLACK) if (GetFadeStatus() == RDFADE_BLACK)
FadeUp((float) 0.75); FadeUp((float) 0.75);

View file

@ -102,13 +102,14 @@ void ExitWithReport(const char *format,...) // (6dec96 JEL)
vsprintf(buf, format, arg_ptr); vsprintf(buf, format, arg_ptr);
Zdebug("%s",buf); // send output to 'debug.txt' as well, just for the record Zdebug("%s",buf); // send output to 'debug.txt' as well, just for the record
while (GetFadeStatus()) // wait for fade to finish before calling RestoreDisplay() // wait for fade to finish before calling RestoreDisplay()
ServiceWindows(); WaitForFade();
ReportFatalError((const uint8 *)buf); // display message box ReportFatalError((const uint8 *)buf); // display message box
CloseAppWindow(); CloseAppWindow();
while (ServiceWindows() != RDERR_APPCLOSED); // This looks like a bad idea, since our ServiceWindows() never
// returns RDERR_APPCLOSED.
// while (ServiceWindows() != RDERR_APPCLOSED);
exit(0); exit(0);
} }

View file

@ -1421,6 +1421,7 @@ extern int32 FadeUp(float time);
extern int32 FadeDown(float time); extern int32 FadeDown(float time);
extern uint8 GetFadeStatus(void); extern uint8 GetFadeStatus(void);
extern int32 DimPalette(void); extern int32 DimPalette(void);
extern void WaitForFade(void);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -312,6 +312,13 @@ uint8 GetFadeStatus(void) {
return fadeStatus; return fadeStatus;
} }
void WaitForFade(void) {
while (GetFadeStatus() != RDFADE_NONE && GetFadeStatus() != RDFADE_BLACK) {
ServiceWindows();
g_system->delay_msecs(20);
}
}
void FadeServer() { void FadeServer() {
static int32 previousTime = 0; static int32 previousTime = 0;
const byte *newPalette = (const byte *) fadePalette; const byte *newPalette = (const byte *) fadePalette;

View file

@ -92,11 +92,8 @@ int32 FN_init_background(int32 *params) //Tony11Sept96
//------------------------------------------------------- //-------------------------------------------------------
// if the screen is still fading down then wait for black // if the screen is still fading down then wait for black
do WaitForFade();
{
ServiceWindows();
}
while(GetFadeStatus()==RDFADE_DOWN);
//------------------------------------------------------- //-------------------------------------------------------
if (this_screen.mask_flag) // if last screen was using a shading mask (see below) (James 08apr97) if (this_screen.mask_flag) // if last screen was using a shading mask (see below) (James 08apr97)

View file

@ -955,38 +955,11 @@ void resMan::CacheNewCluster(uint32 newCluster) {
char buf[1024]; char buf[1024];
sprintf(buf, "%sClusters\\%s", cdPath, resource_files[newCluster]); sprintf(buf, "%sClusters\\%s", cdPath, resource_files[newCluster]);
uint8 fadeStat; WaitForFade();
do {
fadeStat = GetFadeStatus();
//--------------------------------------------------
// Service windows
// if we pressed Ctrl-Q
if (ServiceWindows() == RDERR_APPCLOSED) {
Close_game(); //close engine systems down
CloseAppWindow();
exit(0); //quit the game
}
//--------------------------------------------------
} while (fadeStat == RDFADE_UP || fadeStat == RDFADE_DOWN);
if (GetFadeStatus() != RDFADE_BLACK) { if (GetFadeStatus() != RDFADE_BLACK) {
FadeDown((float) 0.75); FadeDown((float) 0.75);
WaitForFade();
do {
//--------------------------------------------------
// Service windows
// if we pressed Ctrl-Q
if (ServiceWindows() == RDERR_APPCLOSED) {
Close_game(); //close engine systems down
CloseAppWindow();
exit(0); //quit the game
}
//--------------------------------------------------
} while (GetFadeStatus() != RDFADE_BLACK);
} }
EraseBackBuffer(); EraseBackBuffer();
@ -1083,18 +1056,7 @@ void resMan::CacheNewCluster(uint32 newCluster) {
CopyScreenBuffer(); CopyScreenBuffer();
FadeUp((float) 0.75); FadeUp((float) 0.75);
do { WaitForFade();
//--------------------------------------------------
// Service windows
// if we pressed Ctrl-Q
if (ServiceWindows() == RDERR_APPCLOSED) {
Close_game(); //close engine systems down
CloseAppWindow();
exit(0); //quit the game
}
//--------------------------------------------------
} while (GetFadeStatus() == RDFADE_UP);
fseek(inFile, 0, SEEK_END); fseek(inFile, 0, SEEK_END);
uint32 size = ftell(inFile); uint32 size = ftell(inFile);
@ -1167,22 +1129,9 @@ void resMan::CacheNewCluster(uint32 newCluster) {
EraseSoftwareScreenBuffer(); // for software rendering EraseSoftwareScreenBuffer(); // for software rendering
FadeDown((float) 0.75); FadeDown((float) 0.75);
WaitForFade();
do {
//--------------------------------------------------
// Service windows
// if we pressed Ctrl-Q
if (ServiceWindows() == RDERR_APPCLOSED) {
Close_game(); //close engine systems down
CloseAppWindow();
exit(0); //quit the game
}
//--------------------------------------------------
} while (GetFadeStatus() == RDFADE_DOWN);
CopyScreenBuffer(); CopyScreenBuffer();
FadeUp((float)0.75); FadeUp((float) 0.75);
// Git rid of read-only status. // Git rid of read-only status.
SVM_SetFileAttributes(resource_files[newCluster], FILE_ATTRIBUTE_NORMAL); SVM_SetFileAttributes(resource_files[newCluster], FILE_ATTRIBUTE_NORMAL);