Skip to content

Commit

Permalink
trying to address #962 for Linus & MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
thrust26 committed Mar 18, 2023
1 parent 790bc51 commit fd7c495
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/common/main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
49 changes: 46 additions & 3 deletions src/emucore/Settings.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
//============================================================================

#include "bspf.hxx"

#include "OSystem.hxx"
#include "Version.hxx"
#include "Logger.hxx"
Expand All @@ -33,6 +32,16 @@
#include "DebuggerDialog.hxx"
#endif

//#if defined(BSPF_WINDOWS)
//#include <windows.hxx>
//#endif

#if defined(BSPF_UNIX) || defined(BSPF_MACOS)
#include <sys/ioctl.h>
#include <stdio.h>
#include <unistd.h>
#endif

#include "Settings.hxx"
#include "repository/KeyValueRepositoryNoop.hxx"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down

0 comments on commit fd7c495

Please sign in to comment.