mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-05 20:04:13 +00:00
force services into guest process and singlecore option
This commit is contained in:
@@ -86,15 +86,22 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system
|
|||||||
|
|
||||||
// BEGONE cold clones of lambdas, for I have merged you all into a SINGLE lambda instead of
|
// BEGONE cold clones of lambdas, for I have merged you all into a SINGLE lambda instead of
|
||||||
// spamming lambdas like it's some kind of lambda calculus class
|
// spamming lambdas like it's some kind of lambda calculus class
|
||||||
for (auto const& e : std::vector<std::pair<std::string_view, void (*)(Core::System&)>>{
|
std::vector<std::pair<std::string_view, void (*)(Core::System&)>> rt_services{
|
||||||
{"audio", &Audio::LoopProcess},
|
{"audio", &Audio::LoopProcess},
|
||||||
{"FS", &FileSystem::LoopProcess},
|
{"FS", &FileSystem::LoopProcess},
|
||||||
{"ldn", &LDN::LoopProcess},
|
{"ldn", &LDN::LoopProcess},
|
||||||
{"nvservices", &Nvidia::LoopProcess},
|
{"nvservices", &Nvidia::LoopProcess},
|
||||||
{"bsdsocket", &Sockets::LoopProcess},
|
{"bsdsocket", &Sockets::LoopProcess},
|
||||||
})
|
};
|
||||||
|
#if defined(__EMSCRIPTEN__) || defined(__wasi__) || defined(__OPENORBIS__)
|
||||||
|
for (auto const& e : rt_services)
|
||||||
|
kernel.RunOnGuestCoreProcess(std::string(e.first), [&system, f = e.second] { f(system); });
|
||||||
|
kernel.RunOnGuestCoreProcess("vi", [&, token] { VI::LoopProcess(system, token); });
|
||||||
|
#else
|
||||||
|
for (auto const& e : rt_services)
|
||||||
kernel.RunOnHostCoreProcess(std::string(e.first), [&system, f = e.second] { f(system); }).detach();
|
kernel.RunOnHostCoreProcess(std::string(e.first), [&system, f = e.second] { f(system); }).detach();
|
||||||
kernel.RunOnHostCoreProcess("vi", [&, token] { VI::LoopProcess(system, token); }).detach();
|
kernel.RunOnHostCoreProcess("vi", [&, token] { VI::LoopProcess(system, token); }).detach();
|
||||||
|
#endif
|
||||||
// Avoid cold clones of lambdas -- succintly
|
// Avoid cold clones of lambdas -- succintly
|
||||||
for (auto const& e : std::vector<std::pair<std::string_view, void (*)(Core::System&)>>{
|
for (auto const& e : std::vector<std::pair<std::string_view, void (*)(Core::System&)>>{
|
||||||
{"sm", &SM::LoopProcess},
|
{"sm", &SM::LoopProcess},
|
||||||
|
|||||||
+8
-12
@@ -5,8 +5,7 @@
|
|||||||
import { createServer } from 'http';
|
import { createServer } from 'http';
|
||||||
import { readFile } from 'fs';
|
import { readFile } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
console.log(`dont forget to run: "npm --global install @jdmichaud/dwarf-2-sourcemap" for better debugging!`);
|
||||||
// DO NOT RUN THIS IN ANY PRODUCTION ENVIRONMENT EVER
|
|
||||||
const server = createServer((req, res) => {
|
const server = createServer((req, res) => {
|
||||||
console.log(`get ${req.url}`);
|
console.log(`get ${req.url}`);
|
||||||
if (req.url === '/') {
|
if (req.url === '/') {
|
||||||
@@ -22,15 +21,15 @@ const server = createServer((req, res) => {
|
|||||||
<head>
|
<head>
|
||||||
<title>eden-cli</title>
|
<title>eden-cli</title>
|
||||||
</head>
|
</head>
|
||||||
<body style="margin:0;padding:0;background-color:black;font-family:Monospace,Tahoma,Arial;width:100%;height:100%;">
|
<body style="margin:0;padding:0;background-color:black;color:white;font-family:Monospace,Tahoma,Arial;">
|
||||||
<div style="display:grid;grid-template-columns:1fr 1fr;gap:2px;width:100%;height:100%;">
|
<div style="display:grid;grid-template-columns:1fr 1fr;gap:2px;width:100%;height:100vh;">
|
||||||
<canvas id="canvas" oncontextmenu="event.preventDefault()" style="width:100%;height:100%;background-color:gray;"></canvas>
|
<canvas id="canvas" oncontextmenu="event.preventDefault()" style="width:100%;height:100%;background-color:gray;"></canvas>
|
||||||
<div id="tty-stdout"></div>
|
<div id="tty-stdout"></div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
var Module = { //do not prepend var
|
var Module = { //do not prepend var
|
||||||
mainScriptUrlOrBlob: 'eden-cli.js',
|
mainScriptUrlOrBlob: 'eden-cli.js',
|
||||||
arguments: ['--null-render', '-F', '*:Trace', 'game.nro'],
|
arguments: ['--null-render', '--singlecore', '--filter', '*:Trace', 'game.nro'],
|
||||||
canvas: document.getElementById('canvas'),
|
canvas: document.getElementById('canvas'),
|
||||||
print: (e) => {
|
print: (e) => {
|
||||||
e = e.replace('[1;31m', '<span style="color:red;font-weight:bold;">');
|
e = e.replace('[1;31m', '<span style="color:red;font-weight:bold;">');
|
||||||
@@ -52,9 +51,7 @@ var Module = { //do not prepend var
|
|||||||
monitorRunDependencies: (e) => { Module.printInternal("monitor deps: " + e); },
|
monitorRunDependencies: (e) => { Module.printInternal("monitor deps: " + e); },
|
||||||
__wasm_call_ctors: () => { Module.printInternal("ctors beep"); },
|
__wasm_call_ctors: () => { Module.printInternal("ctors beep"); },
|
||||||
};
|
};
|
||||||
|
|
||||||
var gameNroFileBuffer = {};
|
var gameNroFileBuffer = {};
|
||||||
|
|
||||||
Module.printInternal(\`Atomics: \${window.Atomics}, SharedArrayBuffer: \${window.SharedArrayBuffer}\`);
|
Module.printInternal(\`Atomics: \${window.Atomics}, SharedArrayBuffer: \${window.SharedArrayBuffer}\`);
|
||||||
Module.printInternal("trying to load script (if it hangs here check console)");
|
Module.printInternal("trying to load script (if it hangs here check console)");
|
||||||
fetch('game.nro').then((resp) => {
|
fetch('game.nro').then((resp) => {
|
||||||
@@ -63,8 +60,7 @@ fetch('game.nro').then((resp) => {
|
|||||||
return resp.arrayBuffer();
|
return resp.arrayBuffer();
|
||||||
}).then((buffer) => {
|
}).then((buffer) => {
|
||||||
gameNroFileBuffer = buffer;
|
gameNroFileBuffer = buffer;
|
||||||
Module.printInternal("buffer: " + gameNroFileBuffer);
|
Module.printInternal(\`buffer: \${gameNroFileBuffer}\`);
|
||||||
|
|
||||||
// load the thingy AFTER loading the nro
|
// load the thingy AFTER loading the nro
|
||||||
Module.printInternal(\`loading from ${build_dir}/\${Module.mainScriptUrlOrBlob}\`);
|
Module.printInternal(\`loading from ${build_dir}/\${Module.mainScriptUrlOrBlob}\`);
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
@@ -95,16 +91,16 @@ fetch('game.nro').then((resp) => {
|
|||||||
'Cross-Origin-Opener-Policy': 'same-origin',
|
'Cross-Origin-Opener-Policy': 'same-origin',
|
||||||
'Cross-Origin-Embedder-Policy': 'require-corp'
|
'Cross-Origin-Embedder-Policy': 'require-corp'
|
||||||
});
|
});
|
||||||
res.end(content, 'utf-8');
|
res.end(content);
|
||||||
});
|
});
|
||||||
} else if (req.url === '/game.nro') {
|
} else if (req.url === '/game.nro') {
|
||||||
readFile(nro_file, (err, content) => {
|
readFile(nro_file, (err, content) => {
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
'Content-Type': 'application/wasm',
|
'Content-Type': 'application/octet-stream',
|
||||||
'Cross-Origin-Opener-Policy': 'same-origin',
|
'Cross-Origin-Opener-Policy': 'same-origin',
|
||||||
'Cross-Origin-Embedder-Policy': 'require-corp'
|
'Cross-Origin-Embedder-Policy': 'require-corp'
|
||||||
});
|
});
|
||||||
res.end(content, 'utf-8');
|
res.end(content);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.writeHead(404, {});
|
res.writeHead(404, {});
|
||||||
|
|||||||
Reference in New Issue
Block a user