Restore video mode after an error

When using direct-DD access, the window size would not be restored,
producing complete nonsense.
This commit is contained in:
Lephenixnoir 2021-08-12 13:12:48 +02:00
parent 64452f9f74
commit 5520a6e5ee
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
5 changed files with 27 additions and 9 deletions

4
README
View File

@ -14,6 +14,7 @@ sources (GPL) and nDoom (GPLv2). See LICENSE.
UI improvements TODO:
-> Better keyboard layout (including more keys, eg. Run)
=> Edit messages accordingly ("press y"/etc)
-> Use MENU for the escape and EXE to validate in menus
WAD support TODO:
-> Unmodified 1.9 shareware WAD works all the way through?
@ -29,11 +30,12 @@ Technical support TODO:
-> Supply more VRAM memory to internal allocator
=> Merge internal heap into Z_Zone? (< 50 kB)
=> Rewrite video code to use long PRAM0 access? (138 kB)
=> Identify arrays that can go to PRAM, eg. lumpcache
=> Remove multiply-avoiding lookup tables?
-> Rate-limit the game when overclocking
-> Switches don't always show the pressed texture (?)
-> Add more SHORT() to avoid having to copy-align lumps
(note left by MPoupe in m_swap.h)
-> Quit Game menu sometimes crashes the add-in
-> Load/Save game would be very cool
-> Reenable LTO if possible
-> Built-in overclocking?

View File

@ -154,6 +154,7 @@ void I_ErrorI (const char *error, int i1,int i2,int i3,int i4)
locate_OS( 1, 5 );CGDAppendHex32("i3:",i3,8,buf);PrintLine( buf, 21 );
locate_OS( 1, 6 );CGDAppendHex32("i4:",i4,8,buf);PrintLine( buf, 21 );
GetKey( &key );
I_ReinitAfterError();
#else
I_Error (error,i1,i2,i3,i4);
#endif
@ -181,6 +182,7 @@ void I_Error (char *error, ...)
locate_OS( 1, 2 );
PrintLine( error, 21 );
GetKey( &key );
I_ReinitAfterError();
#endif //#ifdef CG_EMULATOR
//I_Quit();
}

View File

@ -130,14 +130,15 @@ static void SetWindow(int left, int top, int width, int height)
WriteLCDReg(LCD_WINDOW_BOTTOM, top + height - 1);
}
/* Whether the black background has been rendered. We could fill the screen
at initialization but it would flicker. Instead, we go the extra mile and
render the background at the same time as the first frame. This also allows
redrawing it after erros.*/
static int firstflipdone = 0;
void I_Flip (void)
{
/* Whether the black background has been rendered. We could fill the screen
at initialization but it would flicker. Instead, we go the extra mile and
render the background at the same time as the first frame. */
static int black_bg = 0;
if (!black_bg)
if (!firstflipdone)
{
SetWindow(0, 0, 396, 224);
WriteLCDReg(LCD_GRAM_X, 0);
@ -165,7 +166,7 @@ void I_Flip (void)
/* Set the future window */
SetWindow((396 - SCREENWIDTH) / 2, (224 - SCREENHEIGHT) / 2,
SCREENWIDTH, SCREENHEIGHT);
black_bg = 1;
firstflipdone = 1;
}
else
{
@ -193,6 +194,14 @@ void I_ShutdownGraphics(void)
SetWindow(6, 0, 384, 216);
}
void I_ReinitAfterError(void)
{
firstflipdone = 0;
/* Redraw status bar over help message */
extern boolean st_firsttime;
st_firsttime = true;
}
#else
void I_Flip (void)
@ -223,7 +232,10 @@ void I_InitGraphics(void)
void I_ShutdownGraphics(void)
{
}
void I_SetWindowAfterError(void)
{
}
#endif

View File

@ -51,6 +51,8 @@ void I_ReadScreen (byte* scr);
//void I_BeginRead (void);
//void I_EndRead (void);
/* CGDOOM: Restore video after error when using direct-DD access */
void I_ReinitAfterError (void);
#endif

View File

@ -267,7 +267,7 @@
static player_t* plyr;
// ST_Start() has just been called
static boolean st_firsttime;
boolean st_firsttime;
// used to execute ST_Init() only once
static int veryfirsttime = 1;