From 8178a13f7117e4d0cc188fc325b7e95b19bc15a6 Mon Sep 17 00:00:00 2001 From: mysticbbs Date: Thu, 1 Mar 2012 18:18:45 -0500 Subject: [PATCH] Initial import for OS2 tomfoolery --- mdl/m_input_crt.pas | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 mdl/m_input_crt.pas diff --git a/mdl/m_input_crt.pas b/mdl/m_input_crt.pas new file mode 100644 index 0000000..aac6866 --- /dev/null +++ b/mdl/m_input_crt.pas @@ -0,0 +1,71 @@ +{$I M_OPS.PAS} + +Unit m_Input_CRT; + +// This is a generic implementation of the Input class which relies on the +// FPC CRT unit. This is not really suitable to use but it can sometimes +// be useful when beginning to port an MDL application to a new operating +// system. The CRT based I/O implementions not only rely on a usable CRT +// implementation for that platform, but also are very inefficient. They +// should NOT be used. + +Interface + +Type + TInputCRT = Class + + Constructor Create; + Destructor Destroy; Override; + + Function ProcessQueue : Boolean; + Function KeyWait (MS: LongInt) : Boolean; + Function KeyPressed : Boolean; + Function ReadKey : Char; + End; + +Implementation + +Uses + CRT; + +Constructor TInputCRT.Create; +Begin + Inherited Create; +End; + +Destructor TInputCRT.Destroy; +Begin + Inherited Destroy; +End; + +Function TInputCRT.ProcessQueue : Boolean; +Begin + Result := CRT.KeyPressed; +End; + +Function TInputCRT.KeyWait (MS: LongInt) : Boolean; +Var + WaitTimer : LongInt = 0; +Begin + Result := CRT.KeyPressed; + + While Not Result And (WaitTimer < MS) Do Begin + CRT.Delay (20); + + Inc (WaitTimer, 20); + + Result := KeyPressed; + End; +End; + +Function TInputCRT.ReadKey : Char; +Begin + Result := CRT.ReadKey; +End; + +Function TInputCRT.KeyPressed : Boolean; +Begin + Result := CRT.KeyPressed; +End; + +End.