Skip to content

Commit

Permalink
🐛VBE Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymekk44 committed Sep 25, 2024
1 parent 8177e34 commit 014e99e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions source/Cosmos.System2/Graphics/VBECanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ public override void DrawArray(int[] aColors, int aX, int aY, int aWidth, int aH
{
for (int i = 0; i < aHeight; i++)
{
if (i >= mode.Height)
{
return;
}
int destinationIndex = (aY + i) * (int)mode.Width + aX;
driver.CopyVRAM(destinationIndex, aColors, i * aWidth, aWidth);
}
Expand All @@ -294,6 +298,10 @@ public override void DrawArray(int[] aColors, int aX, int aY, int aWidth, int aH
{
for (int i = 0; i < aHeight; i++)
{
if (i >= mode.Height)
{
return;
}
int destinationIndex = (aY + i) * (int)mode.Width + aX;
driver.CopyVRAM(destinationIndex, aColors, i * aWidth + startIndex, aWidth);
}
Expand Down Expand Up @@ -458,15 +466,16 @@ public override Bitmap GetImage(int x, int y, int width, int height)
int endX = Math.Min(x + width, (int)Mode.Width);
int endY = Math.Min(y + height, (int)Mode.Height);

int offsetX = Math.Max(0, -x);
int offsetY = Math.Max(0, -y);
int offsetX = Math.Max(0, -x);
int offsetY = Math.Max(0, -y);

int[] rawData = new int[width * height];
int[] rawData = new int[width * height];

for (int posy = startY; posy < endY; posy++)
{
int srcOffset = posy * (int)Mode.Width + startX;
int destOffset = (posy - startY) * width;
int destOffset = (posy - startY + offsetY) * width + offsetX;

driver.GetVRAM(srcOffset, rawData, destOffset, endX - startX);
}

Expand Down

0 comments on commit 014e99e

Please sign in to comment.