Skip to content

Commit cce82cd

Browse files
committed
Minimized Console flickering and improved performance
1 parent 2fdb8e2 commit cce82cd

File tree

8 files changed

+73
-58
lines changed

8 files changed

+73
-58
lines changed

GenOpCodes/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("2019.3.2.597")>
35-
<Assembly: AssemblyFileVersion("2019.3.2.597")>
34+
<Assembly: AssemblyVersion("2019.3.2.610")>
35+
<Assembly: AssemblyFileVersion("2019.3.2.610")>

RunTests/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("2019.3.2.924")>
35-
<Assembly: AssemblyFileVersion("2019.3.2.924")>
34+
<Assembly: AssemblyVersion("2019.3.2.938")>
35+
<Assembly: AssemblyFileVersion("2019.3.2.938")>

x8086NetEmu/Adapters/Video/CGA/CGAAdapter.vb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,6 @@ Public MustInherit Class CGAAdapter
419419
Case Else : mPixelsPerByte = 4
420420
End Select
421421

422-
X8086.Notify("Set Video Mode: {0}", X8086.NotificationReasons.Info, mVideoMode)
423-
424422
OnPaletteRegisterChanged()
425423

426424
AutoSize()

x8086NetEmu/Helpers/Hooks/INT13.vb

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ Partial Public Class X8086
1616

1717
Select Case mRegisters.AH
1818
Case &H0 ' Reset drive
19-
X8086.Notify("Drive {0} Reset", NotificationReasons.Info, mRegisters.DL)
19+
X8086.Notify("Drive {0:000} Reset", NotificationReasons.Info, mRegisters.DL)
2020
ret = If(dskImg Is Nothing, &HAA, 0)
2121

2222
Case &H1 ' Get last operation status
23-
X8086.Notify("Drive {0} Get Last Operation Status", NotificationReasons.Info, mRegisters.DL)
23+
X8086.Notify("Drive {0:000} Get Last Operation Status", NotificationReasons.Info, mRegisters.DL)
2424
mRegisters.AH = lastAH(mRegisters.DL)
2525
mFlags.CF = lastCF(mRegisters.DL)
2626
ret = 0
@@ -41,13 +41,13 @@ Partial Public Class X8086
4141
Exit Select
4242
End If
4343

44-
X8086.Notify("Drive {0} Read H{1:00} T{2:000} S{3:000} x {4:000} {5:000000} -> {6:X4}:{7:X4}", NotificationReasons.Info,
44+
X8086.Notify("Drive {0:000} Read H{1:00} T{2:000} S{3:000} x {4:000} {5:X6} -> {6:X4}:{7:X4}", NotificationReasons.Info,
4545
mRegisters.DL,
4646
mRegisters.DH,
4747
mRegisters.CH,
4848
mRegisters.CL,
4949
mRegisters.AL,
50-
offset.ToString("X5"),
50+
offset,
5151
mRegisters.ES,
5252
mRegisters.BX)
5353

@@ -87,13 +87,13 @@ Partial Public Class X8086
8787
Exit Select
8888
End If
8989

90-
X8086.Notify("Drive {0} Write H{1:00} T{2:000} S{3:000} x {4:000} {5:000000} <- {6:X4}:{7:X4}", NotificationReasons.Info,
90+
X8086.Notify("Drive {0:000} Write H{1:00} T{2:000} S{3:000} x {4:000} {5:X6} <- {6:X4}:{7:X4}", NotificationReasons.Info,
9191
mRegisters.DL,
9292
mRegisters.DH,
9393
mRegisters.CH,
9494
mRegisters.CL,
9595
mRegisters.AL,
96-
offset.ToString("X5"),
96+
offset,
9797
mRegisters.ES,
9898
mRegisters.BX)
9999

@@ -127,13 +127,13 @@ Partial Public Class X8086
127127
Exit Select
128128
End If
129129

130-
X8086.Notify("Drive {0} Verify Sectors H{1:00} T{2:000} S{3:000} ? {4:000} {5:000000} ? {6:X4}:{7:X4}", NotificationReasons.Info,
130+
X8086.Notify("Drive {0:000} Verify Sectors H{1:00} T{2:000} S{3:000} ? {4:000} {5:X6} ? {6:X4}:{7:X4}", NotificationReasons.Info,
131131
mRegisters.DL,
132132
mRegisters.DH,
133133
mRegisters.CH,
134134
mRegisters.CL,
135135
mRegisters.AL,
136-
offset.ToString("X5"),
136+
offset,
137137
mRegisters.ES,
138138
mRegisters.BX)
139139

@@ -156,13 +156,13 @@ Partial Public Class X8086
156156
Exit Select
157157
End If
158158

159-
X8086.Notify("Drive {0} Format Track H{1:00} T{2:000} S{3:000} ? {4:000} {5:000000} = {6:X4}:{7:X4}", NotificationReasons.Info,
159+
X8086.Notify("Drive {0:000} Format Track H{1:00} T{2:000} S{3:000} ? {4:000} {5:X6} = {6:X4}:{7:X4}", NotificationReasons.Info,
160160
mRegisters.DL,
161161
mRegisters.DH,
162162
mRegisters.CH,
163163
mRegisters.CL,
164164
mRegisters.AL,
165-
offset.ToString("X5"),
165+
offset,
166166
mRegisters.ES,
167167
mRegisters.BX)
168168
ret = 0
@@ -174,7 +174,7 @@ Partial Public Class X8086
174174
Exit Select
175175
End If
176176

177-
X8086.Notify("Drive {0} Format Track (SBSF) H{1:00} T{2:000} S{3:000} ? {4:000}", NotificationReasons.Info,
177+
X8086.Notify("Drive {0:000} Format Track (SBSF) H{1:00} T{2:000} S{3:000} ? {4:000}", NotificationReasons.Info,
178178
mRegisters.DL,
179179
mRegisters.DH,
180180
mRegisters.CH,
@@ -189,7 +189,7 @@ Partial Public Class X8086
189189
Exit Select
190190
End If
191191

192-
X8086.Notify("Drive {0} Format Drive H{1:00} T{2:000} S{3:000}", NotificationReasons.Info,
192+
X8086.Notify("Drive {0:000} Format Drive H{1:00} T{2:000} S{3:000}", NotificationReasons.Info,
193193
mRegisters.DL,
194194
mRegisters.DH,
195195
mRegisters.CH,
@@ -220,7 +220,7 @@ Partial Public Class X8086
220220
mRegisters.DL = DiskImage.HardDiskCount
221221
End If
222222

223-
X8086.Notify("Drive {0} Get Parameters", NotificationReasons.Info, mRegisters.DL)
223+
X8086.Notify("Drive {0:000} Get Parameters", NotificationReasons.Info, mRegisters.DL)
224224
ret = 0
225225
End If
226226

@@ -230,7 +230,7 @@ Partial Public Class X8086
230230
ret = &HAA ' fixed disk drive not ready
231231
Exit Select
232232
End If
233-
X8086.Notify("Drive {0} Init Drive Pair Characteristic", NotificationReasons.Info, mRegisters.DL)
233+
X8086.Notify("Drive {0:000} Init Drive Pair Characteristic", NotificationReasons.Info, mRegisters.DL)
234234
ret = 0
235235

236236
' The following are meant to keep diagnostic tools happy ;)
@@ -251,13 +251,13 @@ Partial Public Class X8086
251251
Exit Select
252252
End If
253253

254-
X8086.Notify("Drive {0} Read Long H{1:00} T{2:000} S{3:000} x {4:000} {5:000000} -> {6:X4}:{7:X4}", NotificationReasons.Info,
254+
X8086.Notify("Drive {0:000} Read Long H{1:00} T{2:000} S{3:000} x {4:000} {5:X6} -> {6:X4}:{7:X4}", NotificationReasons.Info,
255255
mRegisters.DL,
256256
mRegisters.DH,
257257
mRegisters.CH,
258258
mRegisters.CL,
259259
mRegisters.AL,
260-
offset.ToString("X5"),
260+
offset,
261261
mRegisters.ES,
262262
mRegisters.BX)
263263

@@ -282,19 +282,19 @@ Partial Public Class X8086
282282
AL = bufSize \ dskImg.SectorSize
283283

284284
Case &HC ' Seek to Cylinder
285-
X8086.Notify("Drive {0} Seek to Cylinder ", NotificationReasons.Info, mRegisters.DL)
285+
X8086.Notify("Drive {0:000} Seek to Cylinder ", NotificationReasons.Info, mRegisters.DL)
286286
ret = 0
287287

288288
Case &HD ' Alternate Disk Reset
289-
X8086.Notify("Drive {0} Alternate Disk Reset", NotificationReasons.Info, mRegisters.DL)
289+
X8086.Notify("Drive {0:000} Alternate Disk Reset", NotificationReasons.Info, mRegisters.DL)
290290
ret = 0
291291

292292
Case &H14 ' Controller Internal Diagnostic
293-
X8086.Notify("Drive {0} Controller Internal Diagnostic", NotificationReasons.Info, mRegisters.DL)
293+
X8086.Notify("Drive {0:000} Controller Internal Diagnostic", NotificationReasons.Info, mRegisters.DL)
294294
ret = 0
295295

296296
Case &H11 ' Recalibrate
297-
X8086.Notify("Drive {0} Recalibrate", NotificationReasons.Info, mRegisters.DL)
297+
X8086.Notify("Drive {0:000} Recalibrate", NotificationReasons.Info, mRegisters.DL)
298298
ret = 0
299299

300300
Case &H15 ' Read DASD Type
@@ -311,18 +311,18 @@ Partial Public Class X8086
311311
mRegisters.DX = dskImg.Sectors And &HFF
312312
ret = &H12C
313313
End If
314-
X8086.Notify("Drive {0} Read DASD Type", NotificationReasons.Info, mRegisters.DL)
314+
X8086.Notify("Drive {0:000} Read DASD Type", NotificationReasons.Info, mRegisters.DL)
315315

316316
Case &H12 ' Controller RAM Diagnostic
317-
X8086.Notify("Drive {0} Controller RAM Diagnostic", NotificationReasons.Info, mRegisters.DL)
317+
X8086.Notify("Drive {0:000} Controller RAM Diagnostic", NotificationReasons.Info, mRegisters.DL)
318318
ret = 0
319319

320320
Case &H13 ' Drive Diagnostic
321-
X8086.Notify("Drive {0} Drive Diagnostic", NotificationReasons.Info, mRegisters.DL)
321+
X8086.Notify("Drive {0:000} Drive Diagnostic", NotificationReasons.Info, mRegisters.DL)
322322
ret = 0
323323

324324
Case &H41 ' Check Extensions Support
325-
X8086.Notify("Drive {0} Extensions Check", NotificationReasons.Info, mRegisters.DL)
325+
X8086.Notify("Drive {0:000} Extensions Check", NotificationReasons.Info, mRegisters.DL)
326326
If mRegisters.BX = &H55AA Then
327327
mFlags.CF = 0
328328
mRegisters.AH = &H1
@@ -355,10 +355,10 @@ Partial Public Class X8086
355355
Exit Select
356356
End If
357357

358-
X8086.Notify("Drive {0} Read {4:000} {5:000000} -> {6:X4}:{7:X4}", NotificationReasons.Info,
358+
X8086.Notify("Drive {0:000} Read {4:000} {5:X6} -> {6:X4}:{7:X4}", NotificationReasons.Info,
359359
mRegisters.DL,
360360
bufSize,
361-
offset.ToString("X5"),
361+
offset,
362362
seg,
363363
off)
364364

@@ -398,10 +398,10 @@ Partial Public Class X8086
398398
Exit Select
399399
End If
400400

401-
X8086.Notify("Drive {0} Write {4:000} {5:000000} <- {6:X4}:{7:X4}", NotificationReasons.Info,
401+
X8086.Notify("Drive {0:000} Write {4:000} {5:X6} <- {6:X4}:{7:X4}", NotificationReasons.Info,
402402
mRegisters.DL,
403403
bufSize,
404-
offset.ToString("X5"),
404+
offset,
405405
seg,
406406
off)
407407

@@ -431,12 +431,12 @@ Partial Public Class X8086
431431
ret = &HAA
432432
Else
433433
Throw New NotImplementedException("Extended get Drive Parameters is not Implemented")
434-
X8086.Notify("Drive {0} Get Parameters", NotificationReasons.Info, mRegisters.DL)
434+
X8086.Notify("Drive {0:000} Get Parameters", NotificationReasons.Info, mRegisters.DL)
435435
ret = 0
436436
End If
437437

438438
Case Else
439-
X8086.Notify("Drive {0} Unknown Request {1}", NotificationReasons.Err,
439+
X8086.Notify("Drive {0:000} Unknown Request {1}", NotificationReasons.Err,
440440
mRegisters.DL,
441441
((mRegisters.AX And &HFF00) >> 8).ToString("X2"))
442442
ret = &H1

x8086NetEmu/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("2019.3.2.6992")>
35-
<Assembly: AssemblyFileVersion("2019.3.2.6985")>
34+
<Assembly: AssemblyVersion("2019.3.2.7006")>
35+
<Assembly: AssemblyFileVersion("2019.3.2.6999")>

x8086NetEmuConsole/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("2019.3.2.986")>
35-
<Assembly: AssemblyFileVersion("2019.3.2.981")>
34+
<Assembly: AssemblyVersion("2019.3.2.1000")>
35+
<Assembly: AssemblyFileVersion("2019.3.2.995")>

x8086NetEmuWinForms/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("2019.3.2.6674")>
35-
<Assembly: AssemblyFileVersion("2019.3.2.6672")>
34+
<Assembly: AssemblyVersion("2019.3.2.6692")>
35+
<Assembly: AssemblyFileVersion("2019.3.2.6690")>

x8086NetEmuWinForms/Tools/FormConsole.vb

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22
Imports System.Threading
33

44
Public Class FormConsole
5+
#If Win32 Then
6+
<Runtime.InteropServices.DllImport("user32.dll")>
7+
Public Shared Function LockWindowUpdate(hWndLock As IntPtr) As Boolean
8+
End Function
9+
#End If
10+
511
Private mEmulator As X8086
612

713
Private rtfTextStd As String = "{\rtf1\ansi {\colortbl;" +
8-
"\red000\green192\blue000;" +
9-
"\red192\green192\blue000;" +
10-
"\red192\green000\blue192;" +
11-
"\red255\green000\blue000;" +
12-
"\red255\green000\blue000;" +
13-
"\red080\green020\blue240;" +
14-
"}%\par}"
14+
"\red000\green192\blue000;" +
15+
"\red192\green192\blue000;" +
16+
"\red192\green000\blue192;" +
17+
"\red255\green000\blue000;" +
18+
"\red255\green000\blue000;" +
19+
"\red080\green080\blue255;" +
20+
"}%\par}"
1521
Private rtfText As String = ""
16-
22+
Private updateIsScheduled As Boolean
1723
Private refreshTimer As New Timer(New TimerCallback(AddressOf UpdateRtf), Nothing, Timeout.Infinite, Timeout.Infinite)
1824

1925
Private Sub FormConsole_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
@@ -54,19 +60,30 @@ Public Class FormConsole
5460
rtfText += String.Format(message.Replace("{", "\b {").Replace("}", "}\b0 ") + " \par ", arg)
5561

5662
Try
57-
refreshTimer.Change(30, Timeout.Infinite)
63+
If Not updateIsScheduled Then
64+
refreshTimer.Change(250, Timeout.Infinite)
65+
updateIsScheduled = True
66+
End If
5867
Catch
5968
End Try
6069
End Sub
6170

6271
Private Sub UpdateRtf()
63-
Me.Invoke(Sub()
64-
SyncLock Me
65-
RichTextBoxConsole.Rtf = rtfTextStd.Replace("%", rtfText)
66-
RichTextBoxConsole.SelectionStart = RichTextBoxConsole.TextLength
67-
RichTextBoxConsole.ScrollToCaret()
68-
End SyncLock
69-
End Sub)
72+
Me.BeginInvoke(Sub()
73+
SyncLock Me
74+
#If Win32 Then
75+
LockWindowUpdate(RichTextBoxConsole.Handle)
76+
#End If
77+
RichTextBoxConsole.Rtf = rtfTextStd.Replace("%", rtfText)
78+
RichTextBoxConsole.SelectionStart = RichTextBoxConsole.TextLength
79+
RichTextBoxConsole.ScrollToCaret()
80+
#If Win32 Then
81+
LockWindowUpdate(0)
82+
#End If
83+
84+
updateIsScheduled = False
85+
End SyncLock
86+
End Sub)
7087
End Sub
7188

7289
Private ReadOnly Property MillTime As String

0 commit comments

Comments
 (0)