Skip to content

Commit

Permalink
Started Vbe
Browse files Browse the repository at this point in the history
  • Loading branch information
Myvar committed Jul 23, 2015
1 parent ec0fbc1 commit c22c0d6
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/Cosmos.Core/BaseIOGroups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ public class BaseIOGroups {
public readonly IOGroup.ATA ATA1 = new IOGroup.ATA(false);
public readonly IOGroup.ATA ATA2 = new IOGroup.ATA(true);
public readonly IOGroup.RTC RTC = new IOGroup.RTC();
public readonly IOGroup.VBE VBE = new IOGroup.VBE();
}
}
1 change: 1 addition & 0 deletions source/Cosmos.Core/Cosmos.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<Compile Include="IOGroup\COM.cs" />
<Compile Include="IOGroup\Network\AMDPCNetIIIOGroup.cs" />
<Compile Include="IOGroup\PCSpeaker.cs" />
<Compile Include="IOGroup\VBE.cs" />
<Compile Include="ManagedMemoryBlock.cs" />
<Compile Include="CPU.cs" />
<Compile Include="DeviceIDAttribute.cs" />
Expand Down
16 changes: 16 additions & 0 deletions source/Cosmos.Core/IOGroup/VBE.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cosmos.Core.IOGroup
{
public class VBE : IOGroup
{
public IOPort VBE_DISPI_INDEX_ENABLE = new IOPort(0x4);
public IOPort VBE_DISPI_INDEX_XRES = new IOPort(0x1);
public IOPort VBE_DISPI_INDEX_YRES = new IOPort(0x2);
public IOPort VBE_DISPI_INDEX_BPP = new IOPort(0x3);
}
}
1 change: 1 addition & 0 deletions source/Cosmos.HAL/Cosmos.HAL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<Compile Include="Drivers\PCI\Audio\PCMStream.cs" />
<Compile Include="Drivers\PCI\Network\AMDPCNetII.cs" />
<Compile Include="Drivers\PCI\Video\VMWareSVGAII.cs" />
<Compile Include="Drivers\VBEScreen.cs" />
<Compile Include="Drivers\VGAScreen.cs" />
<Compile Include="Global.cs" />
<Compile Include="Keyboard.cs" />
Expand Down
106 changes: 106 additions & 0 deletions source/Cosmos.HAL/Drivers/VBEScreen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cosmos.HAL.Drivers
{
public class VBEScreen
{
public int ScreenWidth { get; set; }
public int ScreenHeight { get; set; }
public int ScreenBpp { get; set; }

#region Internals

private Core.IOGroup.VBE IO = Core.Global.BaseIOGroups.VBE;

private void vbe_set(ushort xres, ushort yres, ushort bpp)
{
//Disable Display
IO.VBE_DISPI_INDEX_ENABLE.Word = 0x00;
//Set Display Xres
IO.VBE_DISPI_INDEX_XRES.Word = xres;
//SetDisplay Yres
IO.VBE_DISPI_INDEX_YRES.Word = yres;
//SetDisplay bpp
IO.VBE_DISPI_INDEX_BPP.Word = bpp;
//Enable Display
IO.VBE_DISPI_INDEX_ENABLE.Word = (ushort)(0x01 | 0x00);
}

#endregion



public enum ScreenSize
{
Size320x200,
Size640x400,
Size640x480,
Size800x600,
Size1024x768,
Size1280x1024

}

public enum Bpp
{
Bpp15 = 15,
Bpp16 = 16,
Bpp24 = 24,
Bpp32 = 32
}

public void SetMode(ScreenSize aSize, Bpp aBpp)
{
//Get screen size
switch (aSize)
{
case ScreenSize.Size320x200:
ScreenWidth = 320;
ScreenHeight = 200;
break;
case ScreenSize.Size640x400:
ScreenWidth = 640;
ScreenHeight = 400;
break;
case ScreenSize.Size640x480:
ScreenWidth = 640;
ScreenHeight = 480;
break;
case ScreenSize.Size800x600:
ScreenWidth = 800;
ScreenHeight = 600;
break;
case ScreenSize.Size1024x768:
ScreenWidth = 1024;
ScreenHeight = 768;
break;
case ScreenSize.Size1280x1024:
ScreenWidth = 1280;
ScreenHeight = 1024;
break;
}
//Get bpp
switch (aBpp)
{
case Bpp.Bpp15:
ScreenBpp = 15;
break;
case Bpp.Bpp16:
ScreenBpp = 16;
break;
case Bpp.Bpp24:
ScreenBpp = 24;
break;
case Bpp.Bpp32:
ScreenBpp = 32;
break;
}
vbe_set((ushort)ScreenWidth, (ushort)ScreenHeight, (ushort)ScreenBpp);

}
}
}

0 comments on commit c22c0d6

Please sign in to comment.