Skip to content

Commit b387149

Browse files
committed
ensure executable runs on windows 2000
1 parent 820c963 commit b387149

1 file changed

Lines changed: 42 additions & 25 deletions

File tree

Parts/MENU.C

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -88,37 +88,54 @@ void screen_update()
8888
WriteConsoleOutput( GetStdHandle( STD_OUTPUT_HANDLE ), screen_buffer, full_screen, screen_start, &write_region );
8989
}
9090

91+
typedef BOOL (WINAPI * T_GetConsoleScreenBufferInfoEx)( _In_ HANDLE hConsoleOutput, _Inout_ PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx );
92+
typedef BOOL (WINAPI * T_SetConsoleScreenBufferInfoEx)( _In_ HANDLE hConsoleOutput, _Inout_ PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx );
93+
9194
void menu()
9295
{
9396
int y, a;
9497

9598
delay( 1 );
9699

97-
CONSOLE_SCREEN_BUFFER_INFOEX info = { 0 };
98-
info.cbSize = sizeof( CONSOLE_SCREEN_BUFFER_INFOEX );
99-
GetConsoleScreenBufferInfoEx( GetStdHandle( STD_OUTPUT_HANDLE ), &info );
100-
info.dwSize.Y = 25;
101-
info.dwMaximumWindowSize.Y = 25;
102-
int color = 0;
103-
info.ColorTable[ color++ ] = DOS_RGB( 0, 0, 0 );
104-
info.ColorTable[ color++ ] = DOS_RGB( 16, 16, 24 ); // bar
105-
info.ColorTable[ color++ ] = DOS_RGB( 13, 0, 0 );
106-
info.ColorTable[ color++ ] = DOS_RGB( 43, 0, 0 );
107-
info.ColorTable[ color++ ] = DOS_RGB( 23, 0, 0 );
108-
info.ColorTable[ color++ ] = DOS_RGB( 53, 0, 0 );
109-
info.ColorTable[ color++ ] = DOS_RGB( 33, 0, 0 ); // do not use
110-
info.ColorTable[ color++ ] = DOS_RGB( 63, 0, 0 );
111-
112-
info.ColorTable[ color++ ] = DOS_RGB( 0, 50, 63 );
113-
info.ColorTable[ color++ ] = DOS_RGB( 0, 60, 63 );
114-
info.ColorTable[ color++ ] = DOS_RGB( 25, 25, 30 );
115-
info.ColorTable[ color++ ] = DOS_RGB( 0, 30, 60 );
116-
info.ColorTable[ color++ ] = DOS_RGB( 0, 50, 60 );
117-
info.ColorTable[ color++ ] = DOS_RGB( 63, 0, 0 );
118-
info.ColorTable[ color++ ] = DOS_RGB( 63, 0, 0 );
119-
info.ColorTable[ color++ ] = DOS_RGB( 63, 0, 0 );
120-
121-
SetConsoleScreenBufferInfoEx( GetStdHandle( STD_OUTPUT_HANDLE ), &info );
100+
HMODULE hKernel32 = LoadLibraryA( "KERNEL32.DLL" );
101+
T_GetConsoleScreenBufferInfoEx _GetConsoleScreenBufferInfoEx = GetProcAddress( hKernel32, "GetConsoleScreenBufferInfoEx" );
102+
T_SetConsoleScreenBufferInfoEx _SetConsoleScreenBufferInfoEx = GetProcAddress( hKernel32, "SetConsoleScreenBufferInfoEx" );
103+
104+
if ( _GetConsoleScreenBufferInfoEx && _SetConsoleScreenBufferInfoEx )
105+
{
106+
CONSOLE_SCREEN_BUFFER_INFOEX info = { 0 };
107+
info.cbSize = sizeof( CONSOLE_SCREEN_BUFFER_INFOEX );
108+
_GetConsoleScreenBufferInfoEx( GetStdHandle( STD_OUTPUT_HANDLE ), &info );
109+
info.dwSize.Y = 25;
110+
info.dwMaximumWindowSize.Y = 25;
111+
int color = 0;
112+
info.ColorTable[ color++ ] = DOS_RGB( 0, 0, 0 );
113+
info.ColorTable[ color++ ] = DOS_RGB( 16, 16, 24 ); // bar
114+
info.ColorTable[ color++ ] = DOS_RGB( 13, 0, 0 );
115+
info.ColorTable[ color++ ] = DOS_RGB( 43, 0, 0 );
116+
info.ColorTable[ color++ ] = DOS_RGB( 23, 0, 0 );
117+
info.ColorTable[ color++ ] = DOS_RGB( 53, 0, 0 );
118+
info.ColorTable[ color++ ] = DOS_RGB( 33, 0, 0 ); // do not use
119+
info.ColorTable[ color++ ] = DOS_RGB( 63, 0, 0 );
120+
121+
info.ColorTable[ color++ ] = DOS_RGB( 0, 50, 63 );
122+
info.ColorTable[ color++ ] = DOS_RGB( 0, 60, 63 );
123+
info.ColorTable[ color++ ] = DOS_RGB( 25, 25, 30 );
124+
info.ColorTable[ color++ ] = DOS_RGB( 0, 30, 60 );
125+
info.ColorTable[ color++ ] = DOS_RGB( 0, 50, 60 );
126+
info.ColorTable[ color++ ] = DOS_RGB( 63, 0, 0 );
127+
info.ColorTable[ color++ ] = DOS_RGB( 63, 0, 0 );
128+
info.ColorTable[ color++ ] = DOS_RGB( 63, 0, 0 );
129+
130+
_SetConsoleScreenBufferInfoEx( GetStdHandle( STD_OUTPUT_HANDLE ), &info );
131+
}
132+
else
133+
{
134+
// pre-Vista
135+
COORD coords = { 80, 25 };
136+
SetConsoleScreenBufferSize( GetStdHandle( STD_OUTPUT_HANDLE ), coords );
137+
}
138+
FreeLibrary( hKernel32 );
122139

123140
SetConsoleTitleA( "Second Reality (W32)" );
124141

0 commit comments

Comments
 (0)