- added new command line option '-noconsole' to disable the console window
on Windows. Added early command line check for this option to call the console creation for sdl and wx only if required. NOTE: The console is still needed for the config interface 'textconfig', the console debugger and log output to stdout/stderr.
This commit is contained in:
parent
c52d97cb7f
commit
2b4d9a26dc
@ -250,7 +250,8 @@ void print_tree(bx_param_c *node, int level)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int bxmain (void) {
|
int bxmain(void)
|
||||||
|
{
|
||||||
#ifdef HAVE_LOCALE_H
|
#ifdef HAVE_LOCALE_H
|
||||||
// Initialize locale (for isprint() and other functions)
|
// Initialize locale (for isprint() and other functions)
|
||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
@ -261,8 +262,8 @@ int bxmain (void) {
|
|||||||
if (setjmp (context) == 0) {
|
if (setjmp (context) == 0) {
|
||||||
SIM->set_quit_context (&context);
|
SIM->set_quit_context (&context);
|
||||||
BX_INSTR_INIT_ENV();
|
BX_INSTR_INIT_ENV();
|
||||||
if (bx_init_main(bx_startup_flags.argc, bx_startup_flags.argv) < 0)
|
if (bx_init_main(bx_startup_flags.argc, bx_startup_flags.argv) < 0) {
|
||||||
{ BX_INSTR_EXIT_ENV();
|
BX_INSTR_EXIT_ENV();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// read a param to decide which config interface to start.
|
// read a param to decide which config interface to start.
|
||||||
@ -414,6 +415,7 @@ int RedirectIOToConsole()
|
|||||||
long lStdHandle;
|
long lStdHandle;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
// allocate a console for this app
|
// allocate a console for this app
|
||||||
|
FreeConsole();
|
||||||
if (!AllocConsole()) {
|
if (!AllocConsole()) {
|
||||||
MessageBox(NULL, "Failed to create text console", "Error", MB_ICONERROR);
|
MessageBox(NULL, "Failed to create text console", "Error", MB_ICONERROR);
|
||||||
return 0;
|
return 0;
|
||||||
@ -453,13 +455,25 @@ int WINAPI WinMain(
|
|||||||
bx_startup_flags.hPrevInstance = hPrevInstance;
|
bx_startup_flags.hPrevInstance = hPrevInstance;
|
||||||
bx_startup_flags.m_lpCmdLine = m_lpCmdLine;
|
bx_startup_flags.m_lpCmdLine = m_lpCmdLine;
|
||||||
bx_startup_flags.nCmdShow = nCmdShow;
|
bx_startup_flags.nCmdShow = nCmdShow;
|
||||||
if (!RedirectIOToConsole()) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
SetConsoleTitle("Bochs for Windows (wxWidgets port) - Console");
|
|
||||||
int max_argv = 20;
|
int max_argv = 20;
|
||||||
bx_startup_flags.argv = (char**) malloc (max_argv * sizeof (char*));
|
bx_startup_flags.argv = (char**) malloc (max_argv * sizeof (char*));
|
||||||
split_string_into_argv(m_lpCmdLine, &bx_startup_flags.argc, bx_startup_flags.argv, max_argv);
|
split_string_into_argv(m_lpCmdLine, &bx_startup_flags.argc, bx_startup_flags.argv, max_argv);
|
||||||
|
int arg = 1;
|
||||||
|
bx_bool bx_noconsole = 0;
|
||||||
|
while (arg < bx_startup_flags.argc) {
|
||||||
|
if (!strcmp("-noconsole", bx_startup_flags.argv[arg])) {
|
||||||
|
bx_noconsole = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
arg++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bx_noconsole) {
|
||||||
|
if (!RedirectIOToConsole()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
SetConsoleTitle("Bochs for Windows (wxWidgets port) - Console");
|
||||||
|
}
|
||||||
return bxmain();
|
return bxmain();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -471,14 +485,28 @@ int CDECL main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
bx_startup_flags.argc = argc;
|
bx_startup_flags.argc = argc;
|
||||||
bx_startup_flags.argv = argv;
|
bx_startup_flags.argv = argv;
|
||||||
#if BX_WITH_SDL && defined(WIN32)
|
#ifdef WIN32
|
||||||
// if SDL/win32, try to create a console window.
|
int arg = 1;
|
||||||
if (!RedirectIOToConsole()) {
|
bx_bool bx_noconsole = 0;
|
||||||
return 1;
|
while (arg < argc) {
|
||||||
|
if (!strcmp("-noconsole", argv[arg])) {
|
||||||
|
bx_noconsole = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
arg++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bx_noconsole) {
|
||||||
|
FreeConsole();
|
||||||
|
} else {
|
||||||
|
#if BX_WITH_SDL
|
||||||
|
// if SDL/win32, try to create a console window.
|
||||||
|
if (!RedirectIOToConsole()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(WIN32)
|
SetConsoleTitle("Bochs for Windows - Console");
|
||||||
SetConsoleTitle("Bochs for Windows - Console");
|
}
|
||||||
#endif
|
#endif
|
||||||
return bxmain();
|
return bxmain();
|
||||||
}
|
}
|
||||||
@ -497,6 +525,9 @@ void print_usage(void)
|
|||||||
#if BX_DEBUGGER
|
#if BX_DEBUGGER
|
||||||
" -rc filename execute debugger commands stored in file\n"
|
" -rc filename execute debugger commands stored in file\n"
|
||||||
" -dbglog filename specify Bochs internal debugger log file name\n"
|
" -dbglog filename specify Bochs internal debugger log file name\n"
|
||||||
|
#endif
|
||||||
|
#ifdef WIN32
|
||||||
|
" -noconsole disable console window\n"
|
||||||
#endif
|
#endif
|
||||||
" --help display this help and exit\n"
|
" --help display this help and exit\n"
|
||||||
#if BX_CPU_LEVEL > 4
|
#if BX_CPU_LEVEL > 4
|
||||||
@ -597,6 +628,11 @@ int bx_init_main(int argc, char *argv[])
|
|||||||
SIM->get_param_string(BXPN_RESTORE_PATH)->set(argv[arg]);
|
SIM->get_param_string(BXPN_RESTORE_PATH)->set(argv[arg]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef WIN32
|
||||||
|
else if (!strcmp("-noconsole", argv[arg])) {
|
||||||
|
// already handled in main() / WinMain()
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if BX_WITH_CARBON
|
#if BX_WITH_CARBON
|
||||||
else if (!strncmp("-psn", argv[arg], 4)) {
|
else if (!strncmp("-psn", argv[arg], 4)) {
|
||||||
// "-psn" is passed if we are launched by double-clicking
|
// "-psn" is passed if we are launched by double-clicking
|
||||||
|
Loading…
x
Reference in New Issue
Block a user