mirror of
https://github.com/BluestormDNA/ProjectPSX.git
synced 2025-04-02 10:52:34 -04:00
OpenTK: Add drag and drop for bin and cue files for testing
This commit is contained in:
parent
19565b056d
commit
739ad037a0
3 changed files with 24 additions and 7 deletions
|
@ -1,3 +1,4 @@
|
|||
using OpenToolkit.Graphics.OpenGL;
|
||||
using OpenToolkit.Mathematics;
|
||||
using OpenToolkit.Windowing.Desktop;
|
||||
using System;
|
||||
|
@ -13,6 +14,8 @@ namespace ProjectPSX.OpenTK {
|
|||
settings.RenderFrequency = 60;
|
||||
settings.UpdateFrequency = 60;
|
||||
NativeWindowSettings nativeWindow = new NativeWindowSettings();
|
||||
nativeWindow.API = OpenToolkit.Windowing.Common.ContextAPI.OpenGL;
|
||||
nativeWindow.APIVersion = new Version(3, 2);
|
||||
nativeWindow.Size = new Vector2i(1024, 512);
|
||||
nativeWindow.Title = "ProjectPSX";
|
||||
nativeWindow.Profile = OpenToolkit.Windowing.Common.ContextProfile.Compatability;
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Optimize>true</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OpenTK" Version="4.0.0-pre9.1" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -9,15 +9,18 @@ using System;
|
|||
namespace ProjectPSX.OpenTK {
|
||||
public class Window : GameWindow, IHostWindow {
|
||||
|
||||
const int PSX_MHZ = 33868800;
|
||||
const int SYNC_CYCLES = 100;
|
||||
const int MIPS_UNDERCLOCK = 2;
|
||||
|
||||
private ProjectPSX psx;
|
||||
private int[] displayBuffer;
|
||||
private Dictionary<Key, GamepadInputsEnum> _gamepadKeyMap;
|
||||
private AudioPlayer audioPlayer = new AudioPlayer();
|
||||
private int vSyncCounter;
|
||||
private int cpuCyclesCounter;
|
||||
|
||||
public Window(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings) : base(gameWindowSettings, nativeWindowSettings) {
|
||||
psx = new ProjectPSX(this, @"C:\Users\Wapens\source\repos\ProjectPSX\ProjectPSX\bin\r4.bin");
|
||||
psx.POWER_ON();
|
||||
|
||||
_gamepadKeyMap = new Dictionary<Key, GamepadInputsEnum>() {
|
||||
{ Key.Space, GamepadInputsEnum.Space},
|
||||
|
@ -37,6 +40,16 @@ namespace ProjectPSX.OpenTK {
|
|||
{ Key.S , GamepadInputsEnum.S },
|
||||
{ Key.A , GamepadInputsEnum.A },
|
||||
};
|
||||
|
||||
FileDrop += Window_FileDrop;
|
||||
}
|
||||
|
||||
private void Window_FileDrop(FileDropEventArgs fileDrop) {
|
||||
string[] files = fileDrop.FileNames;
|
||||
string file = files[0];
|
||||
if(file.EndsWith(".bin") || file.EndsWith(".cue")) {
|
||||
psx = new ProjectPSX(this, file);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnLoad() {
|
||||
|
@ -81,7 +94,7 @@ namespace ProjectPSX.OpenTK {
|
|||
|
||||
protected override void OnUpdateFrame(FrameEventArgs args) {
|
||||
base.OnUpdateFrame(args);
|
||||
psx.RunFrame();
|
||||
psx?.RunFrame();
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyboardKeyEventArgs e) {
|
||||
|
@ -113,10 +126,6 @@ namespace ProjectPSX.OpenTK {
|
|||
return fps;
|
||||
}
|
||||
|
||||
public void SetWindowText(string newText) {
|
||||
this.Title = newText;
|
||||
}
|
||||
|
||||
public void SetDisplayMode(int horizontalRes, int verticalRes, bool is24BitDepth) {
|
||||
//throw new System.NotImplementedException();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue