[Hla-stdlib-talk] non-buffered 'stdin.getc' function
Brought to you by:
evenbit
|
From: Nathan B. <eve...@ya...> - 2008-02-15 01:59:56
|
Just coded this real quick and haven't tested it, but this is close to what a 'non-buffered' stdin.getc() function (for Windows) would look like:
unit StdInput;
#include( "../include/stdinunit.hhf" )
procedure nb_getc;
@nodisplay;
var
hStdIn :dword;
curMode :dword;
newMode :dword;
begin nb_getc;
w.GetStdHandle( STD_INPUT_HANDLE );
mov( eax, hStdIn );
w.GetConsoleMode( hStdIn, curMode );
mov( curMode, eax );
and( #$F9, al );
mov( eax, newMode );
w.SetConsoleMode( hStdIn, newMode );
w.ReadFile( hStdIn, &InputBuffer, 1, InputIndex, 0 );
w.SetConsoleMode( hStdIn, curMode );
mov( InputBuffer[ 0 ], al );
ret();
end nb_getc;
Nathan.
end StdInput;
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. |