mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
Switched to using waitable timers instead of Sleep(), gives more accurate time cycles, also added some small optimizations
svn path=/trunk/; revision=1629
This commit is contained in:
parent
349ae0c799
commit
3d4886b292
1 changed files with 27 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: notevil.c,v 1.4 2001/01/31 03:03:20 phreak Exp $
|
/* $Id: notevil.c,v 1.5 2001/02/18 19:31:38 phreak Exp $
|
||||||
*
|
*
|
||||||
* notevil.c
|
* notevil.c
|
||||||
*
|
*
|
||||||
|
@ -37,6 +37,7 @@ LPCTSTR app_name = _TEXT("notevil");
|
||||||
HANDLE myself;
|
HANDLE myself;
|
||||||
HANDLE ScreenBuffer;
|
HANDLE ScreenBuffer;
|
||||||
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo;
|
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo;
|
||||||
|
HANDLE WaitableTimer;
|
||||||
|
|
||||||
void
|
void
|
||||||
WriteStringAt(
|
WriteStringAt(
|
||||||
|
@ -50,8 +51,9 @@ WriteStringAt(
|
||||||
|
|
||||||
if (0 == wLen)
|
if (0 == wLen)
|
||||||
return;
|
return;
|
||||||
WriteConsoleOutputCharacter(
|
// don't bother writing text when erasing
|
||||||
ScreenBuffer,
|
if( wColor )
|
||||||
|
WriteConsoleOutputCharacter( ScreenBuffer,
|
||||||
lpString,
|
lpString,
|
||||||
wLen,
|
wLen,
|
||||||
xy,
|
xy,
|
||||||
|
@ -194,7 +196,7 @@ MainLoop(void)
|
||||||
xy,
|
xy,
|
||||||
wColor
|
wColor
|
||||||
);
|
);
|
||||||
Sleep(100);
|
WaitForSingleObject( WaitableTimer, INFINITE );
|
||||||
WriteStringAt(
|
WriteStringAt(
|
||||||
NameString,
|
NameString,
|
||||||
xy,
|
xy,
|
||||||
|
@ -210,8 +212,10 @@ main(
|
||||||
char *argv []
|
char *argv []
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
LARGE_INTEGER lint;
|
||||||
DWORD Written;
|
DWORD Written;
|
||||||
COORD Coord = { 0, 0 };
|
COORD Coord = { 0, 0 };
|
||||||
|
|
||||||
myself = GetModuleHandle(NULL);
|
myself = GetModuleHandle(NULL);
|
||||||
|
|
||||||
GetConsoleScreenBufferInfo (GetStdHandle(STD_OUTPUT_HANDLE),
|
GetConsoleScreenBufferInfo (GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
|
@ -240,6 +244,19 @@ main(
|
||||||
ScreenBufferInfo.dwSize.X * ScreenBufferInfo.dwSize.Y,
|
ScreenBufferInfo.dwSize.X * ScreenBufferInfo.dwSize.Y,
|
||||||
Coord,
|
Coord,
|
||||||
&Written );
|
&Written );
|
||||||
|
|
||||||
|
WaitableTimer = CreateWaitableTimer( NULL, FALSE, NULL );
|
||||||
|
if( WaitableTimer == INVALID_HANDLE_VALUE )
|
||||||
|
{
|
||||||
|
printf( "CreateWaitabletimer() failed\n" );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
lint.QuadPart = -2000000;
|
||||||
|
if( SetWaitableTimer( WaitableTimer, &lint, 200, NULL, NULL, FALSE ) == FALSE )
|
||||||
|
{
|
||||||
|
printf( "SetWaitableTimer() failed: %x\n", GetLastError() );
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
SetConsoleActiveScreenBuffer(ScreenBuffer);
|
SetConsoleActiveScreenBuffer(ScreenBuffer);
|
||||||
MainLoop();
|
MainLoop();
|
||||||
CloseHandle(ScreenBuffer);
|
CloseHandle(ScreenBuffer);
|
||||||
|
|
Loading…
Reference in a new issue