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) {
FadeDown((float) 0.75);
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);
WaitForFade();
}
Set_mouse(0);
@ -416,21 +401,7 @@ void DisplayMsg(uint8 *text, int time) { // Chris 15May97
Free_mem(text_spr);
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_UP);
WaitForFade();
uint32 targetTime = SVM_timeGetTime() + (time * 1000);
@ -473,22 +444,7 @@ void DisplayMsg(uint8 *text, int time) { // Chris 15May97
void RemoveMsg(void) { // Chris 15May97
FadeDown((float) 0.75);
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);
WaitForFade();
EraseBackBuffer(); // for hardware 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
// happen when everythings cached into a large memory model
do {
ServiceWindows();
} while (GetFadeStatus() == RDFADE_DOWN);
WaitForFade();
// open the screen file
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
do {
ServiceWindows();
} while (GetFadeStatus() == RDFADE_DOWN);
WaitForFade();
if (GetFadeStatus() == RDFADE_BLACK)
FadeUp((float) 0.75);

View File

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

View File

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

View File

@ -312,6 +312,13 @@ uint8 GetFadeStatus(void) {
return fadeStatus;
}
void WaitForFade(void) {
while (GetFadeStatus() != RDFADE_NONE && GetFadeStatus() != RDFADE_BLACK) {
ServiceWindows();
g_system->delay_msecs(20);
}
}
void FadeServer() {
static int32 previousTime = 0;
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
do
{
ServiceWindows();
}
while(GetFadeStatus()==RDFADE_DOWN);
WaitForFade();
//-------------------------------------------------------
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];
sprintf(buf, "%sClusters\\%s", cdPath, resource_files[newCluster]);
uint8 fadeStat;
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);
WaitForFade();
if (GetFadeStatus() != RDFADE_BLACK) {
FadeDown((float) 0.75);
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);
WaitForFade();
}
EraseBackBuffer();
@ -1083,18 +1056,7 @@ void resMan::CacheNewCluster(uint32 newCluster) {
CopyScreenBuffer();
FadeUp((float) 0.75);
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_UP);
WaitForFade();
fseek(inFile, 0, SEEK_END);
uint32 size = ftell(inFile);
@ -1167,22 +1129,9 @@ void resMan::CacheNewCluster(uint32 newCluster) {
EraseSoftwareScreenBuffer(); // for software rendering
FadeDown((float) 0.75);
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);
WaitForFade();
CopyScreenBuffer();
FadeUp((float)0.75);
FadeUp((float) 0.75);
// Git rid of read-only status.
SVM_SetFileAttributes(resource_files[newCluster], FILE_ATTRIBUTE_NORMAL);