2021-11-27 10:18:48 -05:00
|
|
|
#include <cstdio>
|
|
|
|
#include <emscripten/bind.h>
|
|
|
|
#include "Ps2VmJs.h"
|
2021-12-14 14:59:12 -05:00
|
|
|
#include "GSH_OpenGLJs.h"
|
2021-11-27 10:18:48 -05:00
|
|
|
|
|
|
|
CPs2VmJs* g_virtualMachine = nullptr;
|
2021-12-14 14:59:12 -05:00
|
|
|
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE g_context = 0;
|
2021-11-27 10:18:48 -05:00
|
|
|
|
|
|
|
int main(int argc, const char** argv)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void initVm()
|
|
|
|
{
|
2021-12-14 14:59:12 -05:00
|
|
|
EmscriptenWebGLContextAttributes attr;
|
|
|
|
emscripten_webgl_init_context_attributes(&attr);
|
|
|
|
attr.majorVersion = 2;
|
|
|
|
attr.minorVersion = 0;
|
|
|
|
g_context = emscripten_webgl_create_context("#outputCanvas", &attr);
|
|
|
|
assert(g_context >= 0);
|
|
|
|
|
2021-11-27 10:18:48 -05:00
|
|
|
g_virtualMachine = new CPs2VmJs();
|
|
|
|
g_virtualMachine->Initialize();
|
2021-12-14 14:59:12 -05:00
|
|
|
g_virtualMachine->CreateGSHandler(CGSH_OpenGLJs::GetFactoryFunction(g_context));
|
2021-12-02 20:10:35 -05:00
|
|
|
|
2021-11-27 10:18:48 -05:00
|
|
|
//g_virtualMachine->Reset();
|
|
|
|
printf("Reset VM\r\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadElf(std::string path)
|
|
|
|
{
|
|
|
|
printf("Loading '%s'...\r\n", path.c_str());
|
|
|
|
g_virtualMachine->m_ee->m_os->BootFromFile(path);
|
|
|
|
printf("Starting...\r\n");
|
|
|
|
g_virtualMachine->Resume();
|
|
|
|
}
|
|
|
|
|
|
|
|
EMSCRIPTEN_BINDINGS(PsfPlayer)
|
|
|
|
{
|
|
|
|
using namespace emscripten;
|
|
|
|
|
|
|
|
function("loadElf", &loadElf);
|
|
|
|
}
|