Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/attic/PsxHawk.API/api.cpp
2 views
1
/*
2
this c++/cli file implements the bridge between PsxHawk.Core and managed code.
3
currently this is a miserable little pile of hacks.
4
*/
5
6
#using <mscorlib.dll>
7
#using <System.dll>
8
#include <vcclr.h>
9
#include <msclr/marshal.h>
10
#include <msclr/marshal_cppstd.h>
11
#include <string>
12
13
#include "psx.h"
14
#include "loader.h"
15
16
using namespace msclr::interop;
17
18
public ref class PsxApi
19
{
20
public:
21
PSX *psx;
22
23
//this endeavours to fix some issues with routing stdio between .net and the CRT
24
static void StdioFixes()
25
{
26
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
27
DWORD fileType = GetFileType(handle);
28
bool shouldReopen = fileType == FILE_TYPE_CHAR;
29
if(shouldReopen)
30
freopen("CONOUT$", "w", stdout);
31
32
handle = GetStdHandle(STD_ERROR_HANDLE);
33
fileType = GetFileType(handle);
34
shouldReopen = fileType == FILE_TYPE_CHAR;
35
if(shouldReopen)
36
freopen("CONOUT$", "w", stderr);
37
}
38
39
PsxApi()
40
{
41
StdioFixes();
42
43
//initialize the psx instance
44
psx = new PSX();
45
psx->poweron(PSX::eConsoleType_DTL);
46
Load_BIOS(*psx, "B:\\svn\\bizhawk4\\BizHawk.MultiClient\\output\\SCPH5500.bin"); //JP bios (apparently thats what region our test programs are, or what mednafen ends up using)
47
//Load_BIOS(psx, "scph5501.bin");
48
psx->reset();
49
}
50
51
void Load_EXE(System::String^ str)
52
{
53
::Load_EXE(*psx, marshal_as<std::wstring>(str).c_str());
54
}
55
56
void RunForever()
57
{
58
psx->RunForever();
59
}
60
};
61
62