diff --git a/djl_con.hxx b/djl_con.hxx index ceba737..f2afc70 100644 --- a/djl_con.hxx +++ b/djl_con.hxx @@ -35,14 +35,27 @@ class ConsoleConfiguration static int throttled_kbhit() { return kbhit(); } static int portable_getch() { return getch(); } static char * portable_gets_s( char * buf, size_t bufsize ) { return gets( buf ); } - void RestoreConsole( bool clearScreen = true ) + + void RestoreConsoleInput() { if ( 0 != prev_int_23 ) { _dos_setvect( 0x23, prev_int_23 ); prev_int_23 = 0; } + } //RestoreConsoleInput + + void RestoreConsoleOutput( bool clearScreen = true ) + { + outputEstablished = false; + } //RestoreConsoleOutput + + void RestoreConsole( bool clearScreen = true ) + { + RestoreConsoleInput(); + RestoreConsoleOutput( clearScreen ); } //RestoreConsole + bool IsOutputEstablished() { return outputEstablished; } }; @@ -383,6 +396,7 @@ class ConsoleConfiguration void EstablishConsoleOutput( int16_t width = 80, int16_t height = 24 ) { + tracer.Trace( " EstablishConsoleOutput width %u height %u, outputEstablished %d\n", width, height, outputEstablished ); if ( outputEstablished ) return; @@ -470,10 +484,8 @@ class ConsoleConfiguration } } //RestoreConsoleInput - void RestoreConsole( bool clearScreen = true ) + void RestoreConsoleOutput( bool clearScreen = true ) { - RestoreConsoleInput(); - if ( outputEstablished ) { #ifndef _WIN32 @@ -502,6 +514,12 @@ class ConsoleConfiguration outputEstablished = false; } + } //RestoreConsoleOutput + + void RestoreConsole( bool clearScreen = true ) + { + RestoreConsoleInput(); + RestoreConsoleOutput( clearScreen ); } //RestoreConsole void SendClsSequence() diff --git a/djl_cycle.hxx b/djl_cycle.hxx index dc6bddc..43cf1dc 100644 --- a/djl_cycle.hxx +++ b/djl_cycle.hxx @@ -2,10 +2,19 @@ #include using namespace std; + +#ifndef WATCOM using namespace std::chrono; +#endif class CPUCycleDelay { +#ifdef WATCOM // no implementation on DOS + public: + CPUCycleDelay( uint64_t clockRate ) {} + void Reset() {} + void Delay( uint64_t cycles_total ) {} +#else private: high_resolution_clock::time_point start_execution; uint64_t clock_rate; @@ -48,4 +57,5 @@ class CPUCycleDelay } while ( true ); } } //Delay +#endif //WATCOM }; //CPUCycleDelay diff --git a/djltrace.hxx b/djltrace.hxx index 731f74e..7bc8ba7 100644 --- a/djltrace.hxx +++ b/djltrace.hxx @@ -84,6 +84,8 @@ class CDJLTrace int64_t toread = ( ( offset + bytesPerRow ) > beyond ) ? ( length % bytesPerRow ) : bytesPerRow; memcpy( buf, pData + offset, toread ); + + uint64_t extraSpace = 2; for ( int64_t o = offset; o < cap; o++ ) { @@ -93,10 +95,11 @@ class CDJLTrace { *pline++ = ':'; *pline++ = ' '; + extraSpace = 0; } } - uint64_t spaceNeeded = ( bytesPerRow - ( cap - offset ) ) * 3; + uint64_t spaceNeeded = extraSpace + ( ( bytesPerRow - ( cap - offset ) ) * 3 ); for ( uint64_t sp = 0; sp < ( 1 + spaceNeeded ); sp++ ) *pline++ = ' '; diff --git a/mr.bat b/mr.bat index e787f6c..7d51bd9 100644 --- a/mr.bat +++ b/mr.bat @@ -1,6 +1,6 @@ rem with RSS -cl /W4 /wd4706 /wd4996 /nologo ntvcm.cxx x80.cxx /DNDEBUG /DNTVCM_RSS_SUPPORT /openmp /I. /Oti2 /Ob3 /Qpar /Fa /FAsc /EHac /Zi /jumptablerdata /D_AMD64_ /link user32.lib /OPT:REF +cl /W4 /wd4706 /wd4996 /nologo ntvcm.cxx x80.cxx /DNDEBUG /DNTVCM_RSS_SUPPORT /openmp /I. /GS- /GL /Oti2 /Ob3 /Qpar /Fa /FAsc /EHac /Zi /jumptablerdata /D_AMD64_ /link user32.lib /OPT:REF rem without RSS -rem cl /W4 /wd4706 /wd4996 /nologo ntvcm.cxx x80.cxx /DNDEBUG /I. /Oti2 /Ob3 /Qpar /Fa /FAsc /EHac /Zi /jumptablerdata /D_AMD64_ /link user32.lib ntdll.lib /OPT:REF +rem cl /W4 /wd4706 /wd4996 /nologo ntvcm.cxx x80.cxx /DNDEBUG /I. /GS- /GL /Oti2 /Ob3 /Qpar /Fa /FAsc /EHac /Zi /jumptablerdata /D_AMD64_ /link user32.lib ntdll.lib /OPT:REF diff --git a/ntvcm.cxx b/ntvcm.cxx index f9d49be..1e0668f 100644 --- a/ntvcm.cxx +++ b/ntvcm.cxx @@ -43,10 +43,7 @@ #include #include #include - -#ifndef WATCOM #include -#endif // On non-Windows platforms djl_rssrdr.hxx has a dependency on: // httplib.h from https://github.com/yhirose/cpp-httplib @@ -2971,10 +2968,11 @@ int main( int argc, char * argv[] ) if ( force80x24 ) g_consoleConfig.EstablishConsoleOutput( 80, 24 ); + CPUCycleDelay delay( clockrate ); + #ifdef WATCOM uint32_t tStart = DosTimeInMS(); #else - CPUCycleDelay delay( clockrate ); high_resolution_clock::time_point tStart = high_resolution_clock::now(); #endif @@ -2986,9 +2984,7 @@ int main( int argc, char * argv[] ) if ( g_haltExecuted ) break; -#ifndef WATCOM delay.Delay( total_cycles ); -#endif } while ( true ); #ifdef WATCOM