From cd4983db0b2d331cd26ae95189465da114364a4e Mon Sep 17 00:00:00 2001 From: mysticbbs Date: Mon, 6 May 2013 20:07:28 -0400 Subject: [PATCH] Updates --- mdl/m_bits.pas | 2 +- mdl/m_input_windows.pas | 8 ++++---- mdl/m_io_base.pas | 8 ++++++++ mdl/m_io_sockets.pas | 8 +++++--- mdl/m_output_windows.pas | 32 ++++++++++++++++---------------- 5 files changed, 34 insertions(+), 24 deletions(-) diff --git a/mdl/m_bits.pas b/mdl/m_bits.pas index 654ef82..67d6129 100644 --- a/mdl/m_bits.pas +++ b/mdl/m_bits.pas @@ -11,7 +11,7 @@ Procedure BitSet (B: Byte; Size: Byte; Var Temp; IsOn: Boolean); Implementation Const - Bit : Array[1..32] of LongInt = ( + Bit : Array[1..32] of Cardinal = ( $00000001, $00000002, $00000004, $00000008, $00000010, $00000020, diff --git a/mdl/m_input_windows.pas b/mdl/m_input_windows.pas index b18fd6c..6e183f5 100644 --- a/mdl/m_input_windows.pas +++ b/mdl/m_input_windows.pas @@ -1,7 +1,7 @@ -{$I M_OPS.PAS} {$R-} - Unit m_Input_Windows; +{$I M_OPS.PAS} + Interface Uses @@ -21,7 +21,7 @@ Type Procedure AddBuffer (Ch: Char); Function RemapScanCode (ScanCode: Word; CtrlKeyState: dWord; Keycode: Word) : Byte; Function ProcessQueue : Boolean; - Function KeyWait (MS: LongInt) : Boolean; + Function KeyWait (MS: Cardinal) : Boolean; Function KeyPressed : Boolean; Function ReadKey : Char; End; @@ -168,7 +168,7 @@ Begin Until NumRead = 0; End; -Function TInputWindows.KeyWait (MS: LongInt) : Boolean; +Function TInputWindows.KeyWait (MS: Cardinal) : Boolean; Begin If BufPos <> BufSize Then Begin Result := True; diff --git a/mdl/m_io_base.pas b/mdl/m_io_base.pas index 1bc03d6..08ae2b8 100644 --- a/mdl/m_io_base.pas +++ b/mdl/m_io_base.pas @@ -85,6 +85,7 @@ End; Function TIOBase.WriteBuf (Var Buf; Len: LongInt) : LongInt; Begin + Result := 0; End; Procedure TIOBase.BufFlush; @@ -101,30 +102,37 @@ End; Function TIOBase.ReadChar : Char; Begin + Result := #0; End; Function TIOBase.PeekChar (Num: Byte) : Char; Begin + Result := #0; End; Function TIOBase.ReadBuf (Var Buf; Len: LongInt) : LongInt; Begin + Result := 0; End; Function TIOBase.ReadLine (Var Str: String) : LongInt; Begin + Result := 0; End; Function TIOBase.WriteStr (Str: String) : LongInt; Begin + Result := 0; End; Function TIOBase.WriteLine (Str: String) : LongInt; Begin + Result := 0; End; Function TIOBase.WaitForData (TimeOut: LongInt) : LongInt; Begin + Result := 0; End; End. diff --git a/mdl/m_io_sockets.pas b/mdl/m_io_sockets.pas index f6e123e..cc2cb5c 100644 --- a/mdl/m_io_sockets.pas +++ b/mdl/m_io_sockets.pas @@ -65,7 +65,7 @@ Type Function WaitForData (TimeOut: LongInt) : LongInt; Override; Function Connect (Address: String; Port: Word) : Boolean; Function ResolveAddress (Host: String) : LongInt; - Procedure WaitInit (Port: Word); + Procedure WaitInit (NetInterface: String; Port: Word); Function WaitConnection : TIOSocket; Function PeekChar (Num: Byte) : Char; Override; @@ -564,7 +564,7 @@ Begin Result := fpConnect(FSocketHandle, @Sin, SizeOf(Sin)) = 0; End; -Procedure TIOSocket.WaitInit (Port: Word); +Procedure TIOSocket.WaitInit (NetInterface: String; Port: Word); Var SIN : TINetSockAddr; Opt : LongInt; @@ -576,10 +576,12 @@ Begin fpSetSockOpt (FSocketHandle, SOL_SOCKET, SO_REUSEADDR, @Opt, SizeOf(Opt)); SIN.sin_family := PF_INET; - SIN.sin_addr.s_addr := 0; +// SIN.sin_addr.s_addr := 0; + SIN.sin_addr := StrToNetAddr(NetInterface); SIN.sin_port := htons(Port); {$IFDEF TNDEBUG} + TNLOG('Attempting to bind to interface ' + NetInterface + ' (' + strI2S(SIN.sin_addr.s_addr) + ')'); TNLOG('WaitInit Bind'); If fpBind(FSocketHandle, @SIN, SizeOf(SIN)) <> 0 Then TNLOG('WaitInit Bind Failed') diff --git a/mdl/m_output_windows.pas b/mdl/m_output_windows.pas index 54529ac..90b1c4a 100644 --- a/mdl/m_output_windows.pas +++ b/mdl/m_output_windows.pas @@ -170,38 +170,38 @@ End; Procedure TOutputWindows.ClearEOL; Var - Count : Byte; - Res : LongInt; + Count : Byte; + BufSize : TCoord; + BufCoord : TCoord; + Region : TSmallRect; Begin Count := Window.Right - Cursor.X + 1; FillDWord (Buffer[Cursor.Y + 1][Cursor.X + 1], Count, (Word(TextAttr) SHL 16) OR Word($0020)); If Active Then Begin - FillConsoleOutputCharacter (ConOut, ' ', Count, Cursor, @Res); - FillConsoleOutputAttribute (ConOut, TextAttr, Count, Cursor, @Res); + BufSize.X := Count - 1; + BufSize.Y := 1; + BufCoord.X := 0; + BufCoord.Y := 0; + Region.Left := Cursor.X; + Region.Top := Cursor.Y; + Region.Right := Cursor.X + Count - 1; + Region.Bottom := Cursor.Y; + + WriteConsoleOutput(ConOut, @Buffer[Cursor.Y + 1][Cursor.X + 1], BufSize, BufCoord, Region); End; End; (* Procedure TOutputWindows.ClearEOL; Var - Buf : Array[1..80] of TCharInfo; Count : Byte; Res : LongInt; Begin - If Window.Right = Cursor.X Then Exit; + Count := Window.Right - Cursor.X + 1; - Count := 0; - - While Count <= Window.Right - Cursor.X Do Begin - Inc (Count); - - Buf[Count].Attributes := TextAttr; - Buf[Count].UnicodeChar := ' '; - End; - - Move(Buf[1], Buffer[Cursor.Y + 1][Cursor.X + 1], SizeOf(TCharInfo) * Count); + FillDWord (Buffer[Cursor.Y + 1][Cursor.X + 1], Count, (Word(TextAttr) SHL 16) OR Word($0020)); If Active Then Begin FillConsoleOutputCharacter (ConOut, ' ', Count, Cursor, @Res);