mirror of
https://github.com/BluestormDNA/ProjectPSX.git
synced 2025-04-02 10:52:34 -04:00
Winform GDI: Handle y ranges
This is badly handled and X still left
This commit is contained in:
parent
7e8bae99d5
commit
c0c8c66824
1 changed files with 13 additions and 15 deletions
|
@ -63,7 +63,6 @@ namespace ProjectPSX {
|
||||||
FormBorderStyle = FormBorderStyle.FixedDialog;
|
FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||||
KeyUp += new KeyEventHandler(vramViewerToggle);
|
KeyUp += new KeyEventHandler(vramViewerToggle);
|
||||||
|
|
||||||
|
|
||||||
screen.Size = _640x480;
|
screen.Size = _640x480;
|
||||||
screen.Margin = new Padding(0);
|
screen.Margin = new Padding(0);
|
||||||
screen.MouseDoubleClick += new MouseEventHandler(toggleDebug);
|
screen.MouseDoubleClick += new MouseEventHandler(toggleDebug);
|
||||||
|
@ -144,14 +143,12 @@ namespace ProjectPSX {
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Render(int[] vram) {
|
public void Render(int[] vram) {
|
||||||
//Console.WriteLine($"x1 {displayX1} x2 {displayX2} y1 {displayY1} y2 {displayY2}");
|
//Console.WriteLine($"x1 {displayX1} x2 {displayX2} y1 {displayY1} y2 {displayY2}");
|
||||||
int horizontalStart = 0;
|
|
||||||
int horizontalEnd = horizontalRes;
|
int horizontalEnd = horizontalRes;
|
||||||
int verticalStart = 0;
|
|
||||||
int verticalEnd = verticalRes;
|
int verticalEnd = verticalRes;
|
||||||
|
|
||||||
if (isVramViewer) {
|
if (isVramViewer) {
|
||||||
horizontalEnd = 1024;
|
horizontalEnd = 1024;
|
||||||
verticalStart = 0;
|
|
||||||
verticalEnd = 512;
|
verticalEnd = 512;
|
||||||
|
|
||||||
Marshal.Copy(vram, 0, display.BitmapData, 0x80000);
|
Marshal.Copy(vram, 0, display.BitmapData, 0x80000);
|
||||||
|
@ -166,17 +163,14 @@ namespace ProjectPSX {
|
||||||
using var deviceContext = new GdiDeviceContext(screen.Handle);
|
using var deviceContext = new GdiDeviceContext(screen.Handle);
|
||||||
|
|
||||||
Gdi32.StretchBlt(deviceContext, 0, 0, screen.Width, screen.Height,
|
Gdi32.StretchBlt(deviceContext, 0, 0, screen.Width, screen.Height,
|
||||||
display.DeviceContext, horizontalStart, verticalStart, horizontalEnd, verticalEnd,
|
display.DeviceContext, 0, 0, horizontalEnd, verticalEnd,
|
||||||
RasterOp.SRCCOPY);
|
RasterOp.SRCCOPY);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void blit24bpp(int[] vramBits) {
|
private void blit24bpp(int[] vramBits) {
|
||||||
int range = (240 - (displayY2 - displayY1)) / 2;
|
int yRangeOffset = (240 - (displayY2 - displayY1)) >> (verticalRes == 480 ? 0 : 1);
|
||||||
|
if (yRangeOffset < 0) yRangeOffset = 0;
|
||||||
int yRangeOffset;
|
|
||||||
if (range < 0) yRangeOffset = 0;
|
|
||||||
else yRangeOffset = range;
|
|
||||||
|
|
||||||
for (int y = yRangeOffset; y < verticalRes - yRangeOffset; y++) {
|
for (int y = yRangeOffset; y < verticalRes - yRangeOffset; y++) {
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
@ -213,11 +207,8 @@ namespace ProjectPSX {
|
||||||
private void blit16bpp(int[] vramBits) {
|
private void blit16bpp(int[] vramBits) {
|
||||||
//Console.WriteLine($"x1 {displayX1} x2 {displayX2} y1 {displayY1} y2 {displayY2}");
|
//Console.WriteLine($"x1 {displayX1} x2 {displayX2} y1 {displayY1} y2 {displayY2}");
|
||||||
//Console.WriteLine($"Display Height {display.Height} Width {display.Width}");
|
//Console.WriteLine($"Display Height {display.Height} Width {display.Width}");
|
||||||
int range = (240 - (displayY2 - displayY1)) / 2;
|
int yRangeOffset = (240 - (displayY2 - displayY1)) >> (verticalRes == 480 ? 0 : 1);
|
||||||
|
if (yRangeOffset < 0) yRangeOffset = 0;
|
||||||
int yRangeOffset;
|
|
||||||
if (range < 0) yRangeOffset = 0;
|
|
||||||
else yRangeOffset = range;
|
|
||||||
|
|
||||||
for (int y = yRangeOffset; y < verticalRes - yRangeOffset; y++) {
|
for (int y = yRangeOffset; y < verticalRes - yRangeOffset; y++) {
|
||||||
for (int x = 0; x < horizontalRes; x++) {
|
for (int x = 0; x < horizontalRes; x++) {
|
||||||
|
@ -251,6 +242,7 @@ namespace ProjectPSX {
|
||||||
this.horizontalRes = horizontalRes;
|
this.horizontalRes = horizontalRes;
|
||||||
this.verticalRes = verticalRes;
|
this.verticalRes = verticalRes;
|
||||||
|
|
||||||
|
clearDisplay();
|
||||||
//Console.WriteLine($"setDisplayMode {horizontalRes} {verticalRes} {is24BitDepth}");
|
//Console.WriteLine($"setDisplayMode {horizontalRes} {verticalRes} {is24BitDepth}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,9 +277,15 @@ namespace ProjectPSX {
|
||||||
screen.Size = _640x480;
|
screen.Size = _640x480;
|
||||||
}
|
}
|
||||||
isVramViewer = !isVramViewer;
|
isVramViewer = !isVramViewer;
|
||||||
|
clearDisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private unsafe void clearDisplay() {
|
||||||
|
Span<uint> span = new Span<uint>(display.BitmapData.ToPointer(), 0x80000);
|
||||||
|
span.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
public void Play(byte[] samples) {
|
public void Play(byte[] samples) {
|
||||||
buffer.AddSamples(samples, 0, samples.Length);
|
buffer.AddSamples(samples, 0, samples.Length);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue