diff --git a/src/debugger/dap_frontend.cpp b/src/debugger/dap_frontend.cpp index 7bdb5a0..c6d3bb5 100644 --- a/src/debugger/dap_frontend.cpp +++ b/src/debugger/dap_frontend.cpp @@ -10,6 +10,10 @@ #include "nact.h" #include "ags.h" #include "debugger/debugger.h" +#ifdef _WIN32 +#include +#include +#endif using Json = nlohmann::json; namespace debugger { @@ -58,6 +62,10 @@ int read_command_thread(void*) { class DapFrontend : public Frontend { public: DapFrontend(Debugger* backend, const DebugInfo& symbols) : Frontend(backend, symbols) { +#ifdef _WIN32 + _setmode(_fileno(stdin), _O_BINARY); + _setmode(_fileno(stdout), _O_BINARY); +#endif SDL_CreateThread(read_command_thread, "Debugger", NULL); } diff --git a/src/win/nact_win.cpp b/src/win/nact_win.cpp index 3f479f9..51bfb5b 100644 --- a/src/win/nact_win.cpp +++ b/src/win/nact_win.cpp @@ -41,13 +41,13 @@ void init_menu(bool mouse_move_enabled, const Config& config) void init_console(int sys_ver) { -#if defined(_DEBUG_CONSOLE) AllocConsole(); freopen("CONOUT$", "w", stdout); - char title[] = "SYSTEM1 NACT Tracer"; + freopen("CONOUT$", "w", stderr); + freopen("CONIN$", "r", stdin); + char title[] = "SYSTEM1 Debug Console"; title[6] = '0' + sys_ver; SetConsoleTitle(title); -#endif } void save_screenshot(AGS* ags) @@ -138,7 +138,10 @@ void NACT::text_dialog() void NACT::platform_initialize() { init_menu(mouse_move_enabled, config); - init_console(game_id.sys_ver); +#ifndef _DEBUG_CONSOLE + if (config.debugger_mode == DebuggerMode::CLI) +#endif + init_console(game_id.sys_ver); SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); }