Skip to content

Commit

Permalink
Removed Binary.vb dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
morphx666 committed Sep 23, 2017
1 parent 99ccccc commit 191548d
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 334 deletions.
4 changes: 2 additions & 2 deletions x8086NetEmu/Adapters/Disk/DiskImage.vb
Expand Up @@ -234,8 +234,8 @@ Public Class DiskImage
sector = sector And &H3F

If cylinder >= mCylinders OrElse
sector < 1 OrElse sector > mSectors OrElse
head > mHeads Then
sector < 1 OrElse sector > mSectors OrElse
head > mHeads Then
Return -1
End If

Expand Down
44 changes: 22 additions & 22 deletions x8086NetEmu/Adapters/Video/CGA/CGAConsole.vb
Expand Up @@ -10,8 +10,8 @@ Public Class CGAConsole

Private i2a As Image2Ascii
Private isRendering As Boolean
Private ratio As New Size(2, 4)
Private frameRate As Integer = 30
Private ratio As New Size(3, 4)
Private frameRate As Integer = 27

Public Sub New(cpu As x8086)
MyBase.New(cpu)
Expand All @@ -22,30 +22,29 @@ Public Class CGAConsole
Console.Clear()

i2a = New Image2Ascii() With {
.Charset = Image2Ascii.Charsets.Advanced,
.Charset = Image2Ascii.Charsets.Standard,
.ColorMode = Image2Ascii.ColorModes.Color,
.GrayScaleMode = Image2Ascii.GrayscaleModes.Accuarte,
.ScanMode = Image2Ascii.ScanModes.Accurate,
.Font = New Font("Perfect DOS VGA 437", 18)
.ScanMode = Image2Ascii.ScanModes.Fast
}

Dim tmp As New Threading.Thread(Sub()
Do
Thread.Sleep(1000 \ frameRate)

Try
If MainMode = MainModes.Graphics Then
i2a.ProcessImage(False)

For y As Integer = 0 To Console.WindowHeight - 1
For x As Integer = 0 To Console.WindowWidth - 1
ConsoleCrayon.WriteFast(i2a.Canvas(x)(y).Character, Image2Ascii.ToConsoleColor(i2a.Canvas(x)(y).Color), ConsoleColor.Black, x, y)
Next
Next
End If
Catch : End Try
Loop Until MyBase.cancelAllThreads
End Sub)
Dim tmp As New Thread(Sub()
Do
Thread.Sleep(1000 \ frameRate)

Try
If MainMode = MainModes.Graphics Then
i2a.ProcessImage(False)

For y As Integer = 0 To Console.WindowHeight - 1
For x As Integer = 0 To Console.WindowWidth - 1
ConsoleCrayon.WriteFast(i2a.Canvas(x)(y).Character, Image2Ascii.ToConsoleColor(i2a.Canvas(x)(y).Color), ConsoleColor.Black, x, y)
Next
Next
End If
Catch : End Try
Loop Until MyBase.cancelAllThreads
End Sub)
tmp.Start()
End Sub

Expand Down Expand Up @@ -79,6 +78,7 @@ Public Class CGAConsole
Case MainModes.Graphics
Console.SetWindowSize(GraphicsResolution.Width / ratio.Width, GraphicsResolution.Height / ratio.Height)
ResetI2A()
Console.SetWindowSize(i2a.CanvasSize.Width, i2a.CanvasSize.Height)
End Select
Console.SetBufferSize(Console.WindowWidth, Console.WindowHeight)
#End If
Expand Down
38 changes: 19 additions & 19 deletions x8086NetEmu/Adapters/Video/Image2Ascii.vb
Expand Up @@ -58,7 +58,7 @@
SetCharSize()
End Sub

Public Property CanvasSize As Size
Public Property CanvasSize() As Size
Get
Return mCanvasSize
End Get
Expand All @@ -70,13 +70,13 @@
End Set
End Property

Public ReadOnly Property DirectBitmap As DirectBitmap
Public ReadOnly Property DirectBitmap() As DirectBitmap
Get
Return mBitmap
End Get
End Property

Public Property Bitmap As Bitmap
Public Property Bitmap() As Bitmap
Get
Return mBitmap
End Get
Expand All @@ -86,13 +86,13 @@
End Set
End Property

Public ReadOnly Property Surface As Bitmap
Public ReadOnly Property Surface() As Bitmap
Get
Return mSurface
End Get
End Property

Public Property GrayScaleMode As GrayscaleModes
Public Property GrayScaleMode() As GrayscaleModes
Get
Return mGrayScaleMode
End Get
Expand All @@ -102,7 +102,7 @@
End Set
End Property

Public Property Charset As Charsets
Public Property Charset() As Charsets
Get
Return mCharset
End Get
Expand All @@ -113,7 +113,7 @@
End Set
End Property

Public Property ColorMode As ColorModes
Public Property ColorMode() As ColorModes
Get
Return mColorMode
End Get
Expand All @@ -123,7 +123,7 @@
End Set
End Property

Public Property ScanMode As ScanModes
Public Property ScanMode() As ScanModes
Get
Return mScanMode
End Get
Expand All @@ -133,13 +133,13 @@
End Set
End Property

Public ReadOnly Property CharSize As Size
Public ReadOnly Property CharSize() As Size
Get
Return mCharSize
End Get
End Property

Public Property BackColor As Color
Public Property BackColor() As Color
Get
Return mBackColor
End Get
Expand All @@ -149,7 +149,7 @@
End Set
End Property

Public Property Font As Font
Public Property Font() As Font
Get
Return mFont
End Get
Expand All @@ -160,7 +160,7 @@
End Set
End Property

Public ReadOnly Property Canvas As ASCIIChar()()
Public ReadOnly Property Canvas() As ASCIIChar()()
Get
Return mCanvas
End Get
Expand All @@ -172,7 +172,7 @@
mCharSize.Height -= 1
End Sub

Public Sub ProcessImage(Optional gurfaceGraphics As Boolean = True)
Public Sub ProcessImage(Optional surfaceGraphics As Boolean = True)
If mBitmap Is Nothing Then Exit Sub

Dim sx As Integer
Expand All @@ -185,9 +185,9 @@
mSurface = New DirectBitmap(mCanvasSize.Width * CharSize.Width, mCanvasSize.Height * CharSize.Height)
End If

If gurfaceGraphics Then
surfaceGraphics = Graphics.FromImage(mSurface)
surfaceGraphics.Clear(Me.BackColor)
If surfaceGraphics Then
Me.surfaceGraphics = Graphics.FromImage(mSurface)
Me.surfaceGraphics.Clear(Me.BackColor)
End If

Dim scanStep As Size = New Size(Math.Ceiling(mBitmap.Width / mCanvasSize.Width), Math.Ceiling(mBitmap.Height / mCanvasSize.Height))
Expand Down Expand Up @@ -251,14 +251,14 @@
mCanvas(sx)(sy) = New ASCIIChar(ColorToASCII(r, g, b), Color.FromArgb(r, g, b))
End Select

If gurfaceGraphics Then
If surfaceGraphics Then
Using sb As New SolidBrush(mCanvas(sx)(sy).Color)
surfaceGraphics.DrawString(mCanvas(sx)(sy).Character, Me.Font, sb, sx * CharSize.Width, sy * CharSize.Height)
Me.surfaceGraphics.DrawString(mCanvas(sx)(sy).Character, Me.Font, sb, sx * CharSize.Width, sy * CharSize.Height)
End Using
End If
Next
Next
If gurfaceGraphics Then surfaceGraphics.Dispose()
If surfaceGraphics Then Me.surfaceGraphics.Dispose()

lastCanvasSize = mCanvasSize

Expand Down

0 comments on commit 191548d

Please sign in to comment.