Getting emulator errors
P粉447495069
2023-09-01 20:53:31
<p>I've been trying to reverse engineer a GBA emulator (https://gba.44670.org/) that I found online and using an HTML extractor to try to replicate it. I wanted it to work offline, so I downloaded all the scripts to my computer and ran them there. However, after this, the "Select File" button no longer appears, replaced by the "Loading, please wait..." text line. Digging deeper into the code I found that it has something to do with WASM. The code is as follows: </p>
<pre class="brush:php;toolbar:false;"><div id="wasm-loading">
Loading, please wait...
</div>
<div id="select-rom" hidden>
<input type="file" id="romFile" onchange="onFileSelected()" hidden /></p>
<button onclick="$id('romFile').click()" id="btn-choose">Choose File...</button>
</div></pre>
<p>Other references to WASM in the code are in the .js file app.js: </p>
<pre class="brush:php;toolbar:false;">function wasmReady() {
romBuffer = Module._emuGetSymbol(1)
var ptr = Module._emuGetSymbol(2)
wasmSaveBuf = Module.HEAPU8.subarray(ptr, ptr wasmSaveBufLen)
ptr = Module._emuGetSymbol(3)
imgFrameBuffer = new Uint8ClampedArray(Module.HEAPU8.buffer).subarray(ptr, ptr 240 * 160 * 4)
idata = new ImageData(imgFrameBuffer, 240, 160)
isWasmReady = true
document.getElementById('wasm-loading').hidden = true
document.getElementById('select-rom').hidden = false
}</pre>
<p>I expected that once I downloaded the script it would work like normal. I mean, it still has access to the scripts it needs, right? I've tried hiding the text by changing the true/false statements in <code>document.getElementById('select-rom').hidden = false</code> and vice versa, but nothing seems to work. Any ideas? Thanks in advance. </p>
<p>(BTW, I'm looking for the file path in vscode.dev. It looks like this: <code><script src="/Scripts/44gba.js"></script> < ;script src="/Scripts /app.js"></script> <script src="/Scripts/localforage.js"></script> <script src=/Scripts/pako.min .js></script></code>
)</p>
To use a script to keep an application local, remember two things:
That is, copy the same HTML you get in the response (https://gba.44670.org/ ), which will preserve the file structure. This is what I get (
index.html
):Then you can see the script path where you will create the file:
Additionally, you will need to download the WASM file (651KB compressed, 7.7MB uncompressed). You can download the tarball here (you can find it in the "Network" tab of the dev tools): https://gba.44670.org/build/44gba.wasm
Finally, download all necessary files (you can also download icons and images if you want, but they are not required):
You will get a structure like this:
Now, it would be great if you could deactivate CORS from your browser. But if not, you have to serve it from a local HTTP server. One option is to install the NPM package: https://www.npmjs.com/package/http-server, run
npm install --global http-server
. After that, just navigate to the project directory in the terminal and start the server:You will see the correct screen and load the ROM, then you are done.
Edit: Solving local CORS issues with a simple Hack
Since I know you are now using ChromeOS and technically don't know how to use Node, NPM and HTTP-Server to handle it, I made some modifications for you and put the WASM binary content directly Enter build/44gba.js and return the binary content on the function readBinary to bypass the CORS issue. You can launch index.html directly. Here is the link to the new
build/44gba.js
file, just replace its contents with the following file: https://sendeyo.com/en/b02f94b524 You're all good . The following are the changes: