From 55099ecbdd540fa4483a11f143e9852fd8af5c76 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Sat, 18 Mar 2023 21:06:06 +0100 Subject: [PATCH] trying to address #962 for Linus & MacOS --- src/common/main.cxx | 1 + src/emucore/Settings.cxx | 49 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/common/main.cxx b/src/common/main.cxx index 78bf0d027..66f081388 100644 --- a/src/common/main.cxx +++ b/src/common/main.cxx @@ -170,6 +170,7 @@ void attachConsole() AttachConsole(ATTACH_PARENT_PROCESS); FILE* fDummy; freopen_s(&fDummy, "CONOUT$", "w", stdout); + //freopen_s(&fDummy, "CONIN$", "r", stdin); // doesn't work as expected // Windows displays a new prompt immediately after starting the app. // This code tries to hide it before the new output is generated. diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 307ae6a72..125eadfd3 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -16,7 +16,6 @@ //============================================================================ #include "bspf.hxx" - #include "OSystem.hxx" #include "Version.hxx" #include "Logger.hxx" @@ -33,6 +32,16 @@ #include "DebuggerDialog.hxx" #endif +//#if defined(BSPF_WINDOWS) +//#include +//#endif + +#if defined(BSPF_UNIX) || defined(BSPF_MACOS) +#include +#include +#include +#endif + #include "Settings.hxx" #include "repository/KeyValueRepositoryNoop.hxx" @@ -481,7 +490,8 @@ void Settings::validate() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Settings::usage() { - cout << endl + stringstream buf; + buf << endl << "Stella version " << STELLA_VERSION << endl << endl << "Usage: stella [options ...] romfile" << endl @@ -807,7 +817,40 @@ void Settings::usage() << " -dev.tia.delaybkcolor <1|0> Enable extra delay cycle for background color\n" << " -dev.tia.delayplswap <1|0> Enable extra delay cycle for VDELP0/1 swap\n" << " -dev.tia.delayblswap <1|0> Enable extra delay cycle for VDELBL swap\n" - << endl << std::flush; + << endl; + +#ifdef BSPF_WINDOWS +// int height = 25; +// CONSOLE_SCREEN_BUFFER_INFO csbi; +// +// if(NULL != GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) +// height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; + cout << buf.str() << std::flush; +#endif + +#if defined(BSPF_UNIX) || defined(BSPF_MACOS) + int height = 25; + struct winsize ws; + + ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws); + + height = ws.ws_row; + + int row = 0; + while(buf.good()) + { + if(++row == height - 1) + { + row = 0; + cout << "Press \"Enter\"" << std::flush; + getchar(); + cout << endl; + } + string substr; + getline(buf, substr, '\n'); + cout << substr << endl; + } +#endif } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -