<div dir="ltr"><div>Excellent!</div><div><br></div><div>Yes, all four files are needed, and no others. However the .data file just contains the files/directories specified by the --preload-file arg to emcc. In SConscript:<br></div><div> gameenv['CCLINKFLAGS'] += ['--preload-file', 'games']</div><div>I only added that for testing and if you comment that out then there is no .data file. The format of it is just all the input files concatenated without anything between them. If you search ohrrpgce-game.js you'll see something like:</div><div> loadPackage({"files": [{"filename": "/games/c_debug.txt", "start": 0, "end": 5823}, {"filename": "/games/inputtest.rpg", "start": 5823, "end": 541481}], "remote_package_size": 541481});</div><div></div><div>We don't need to use this generated loadPackage code, we can include our own js code into ohrrpgce-game.js which loads an external data file and puts it in the virtual filesystem. Notably an .rpg file could be used as a .data file simply by setting the correct "end", or even better we can write an .rpg parser in JS and load it more efficiently as an .rpgdir. I haven't done any work on that yet to allow distributing games for web, aside from browsing the JS code to get an understanding of the virtual filesystem.<br></div><div><br></div><div>For now I suggest just putting a test .rpg in games/ so people have something for testing, but we'll remove the "--preload-file games" once I push the rest of Blain's emscripten work which includes adding a button to the .html to let you "upload" .rpg files into the virtual FS.<br></div><div><br></div><div>> I need to run a local webserver (I guess emscripten uses some js features that aren't allowed on file:/// urls?)</div><div><br></div><div>Unfortunately all modern web browsers have this problem, you can't access one local file from another (e.g. a .css included in a .html) without running a local web server. The easiest is to run "python3 -m http.server" from the directory.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 29 Dec 2023 at 10:25, James Paige <<a href="mailto:james.robert.paige@gmail.com">james.robert.paige@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Aha! I see. I need to run a local webserver (I guess emscripten uses some js features that aren't allowed on file:/// urls?)</div><div><br></div><div>I ran a local werbserver with</div><div> docker run -it --rm -d -p 8080:80 -v ~/src/ohrrpgce:/usr/share/nginx/html --name localweb nginx</div><div><br></div><div>And now I can go to <a href="http://localhost:8080/ohrrpgce-game.html" target="_blank">http://localhost:8080/ohrrpgce-game.html</a> and see the game I put in the games directory</div><div><br></div><div><img src="cid:ii_lqppipnw1" alt="image.png" width="488" height="242"><br></div><div>So it works! Yay!</div><div><br></div><div>Question about the files, .html .js .data .wasm</div><div>Do I need them all in the nightly build? Are there any other files that I need that I haven't noticed yet?</div><div><br></div><div>I assume that ohrrpgce-game.data has the filesystem in it? What format is it in? Is there a way that people can add .rpg files to it without having the emscripten sdk?</div><div><br></div><div>I'm wondering what we should put in ./games for the nightly build. For the minimalist builds for the distrib menu to use, I assume nothing (except that isn't allowed)</div><div>Does a non-minimalist build of emscripten even make sense?<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 28, 2023 at 4:04 PM James Paige <<a href="mailto:james.robert.paige@gmail.com" target="_blank">james.robert.paige@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Nice that fix did help.</div><div><br></div><div>Now I get:<br></div><div><br></div><div>error: games does not exist<br>emcc: error: '/emsdk/upstream/emscripten/tools/file_packager ohrrpgce-game.data --from-emcc --preload games' failed (returned 1)<br></div><div><br></div><div>If I make an empty directory named "games" the first part of that err goes away, but it still says:<br></div><div><br></div><div>emcc: error: '/emsdk/upstream/emscripten/tools/file_packager ohrrpgce-game.data --from-emcc --preload games' failed (returned 1)</div><div><br></div><div>If I put a random rpg file into the games directory, then `scons target=js` runs to completion, and I can see that ohrrpgce-(game|custom).(data|html|js|wasm) although if I load it up in my browser via file:/// I just get an error "Exception thrown, see JavaScript console"</div><div><br></div><div><img src="cid:ii_lqpozuga0" alt="image.png" width="488" height="220"><br></div><div>So I am getting closer, but not quite there yet!<br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 28, 2023 at 3:30 PM Ralph Versteegen <<a href="mailto:teeemcee@gmail.com" target="_blank">teeemcee@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">This must be due to using a different emscripten version than I have installed. I haven't upgraded, but I've just pushed a commit that should fix it.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 29 Dec 2023 at 08:56, James Paige <<a href="mailto:james.robert.paige@gmail.com" target="_blank">james.robert.paige@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Those instructions were very helpful. I now have a docker container with the latest emscripten and fbc compiled from your emscripten branch. However, I get a mutex error in filelayer.cpp</div><div><br></div><div>scons: Building targets ...<br>emcc -o build/filelayer.o -c -Wall -Wno-deprecated-declarations -Wno-unused-but-set-variable -DFBCVERSION=1101 -g -fno-omit-frame-pointer -O3 -DMINIMAL_OS -fno-pie -fwrapv --std=c++0x -Wno-non-virtual-dtor filelayer.cpp<br>filelayer.cpp:39:1: error: reference to 'mutex' is ambiguous<br> 39 | mutex openfiles_mutex(true); // Non-destructing mutex<br> | ^<br>./mutex.hpp:14:7: note: candidate found by name lookup is 'mutex'<br> 14 | class mutex {<br> | ^<br>/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__mutex/mutex.h:24:87: note: candidate found by name lookup is 'std::mutex'<br> 24 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex {<br> | ^<br>filelayer.cpp:39:7: error: no matching constructor for initialization of 'mutex'<br> 39 | mutex openfiles_mutex(true); // Non-destructing mutex<br> | ^ ~~~~<br>/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__mutex/mutex.h:30:3: note: candidate constructor not viable: no known conversion from 'bool' to 'const mutex' for 1st argument<br> 30 | mutex(const mutex&) = delete;<br> | ^ ~~~~~~~~~~~~<br>/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__mutex/mutex.h:28:43: note: candidate constructor not viable: requires 0 arguments, but 1 was provided<br> 28 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR mutex() = default;<br> | ^<br>2 errors generated.<br>scons: *** [build/filelayer.o] Error 1<br>scons: building terminated because of errors.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Dec 27, 2023 at 7:54 AM Ralph Versteegen via Ohrrpgce <<a href="mailto:ohrrpgce@lists.motherhamster.org" target="_blank">ohrrpgce@lists.motherhamster.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Oh, I haven't written instructions yet. I need to do that. But quickly:</div><div><br></div><div>If you haven't already, install emscripten:</div><div>git clone <a href="https://github.com/emscripten-core/emsdk.git" target="_blank">https://github.com/emscripten-core/emsdk.git</a></div><div>cd emsdk</div><div>Install "latest" version, or to avoid surprises in nightlies it's probably better to use the same version I have, which is 3.1.42</div><div>./emsdk install 3.1.42<br>./emsdk activate 3.1.42</div><div>Put .../emsdk/upstream/emscripten in your PATH</div><div><br></div><div>Compile FB:<br></div><div>git clone <a href="https://github.com/rversteegen/fbc.git" target="_blank">https://github.com/rversteegen/fbc.git</a></div><div>cd fbc<br></div><div>checkout my 'emscripten' branch (which mostly contains bugfixes. I'll get these upstreamed sometime soonish)</div><div>make -j4 install-compiler install-includes prefix=/install/fb/here<br></div><div>make -j4 install-rtlib TARGET=asmjs-unknown-emscripten prefix=/install/fb/here</div><div>(you can run "make install-rtlib TARGET=..." additional times to compile libraries for other targets)</div><div><br></div><div>Then you can compile with "scons target=js ..." (add fbc=... or else put the newly compiled fbc in $PATH)</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 27 Dec 2023 at 07:32, James Paige via Ohrrpgce <<a href="mailto:ohrrpgce@lists.motherhamster.org" target="_blank">ohrrpgce@lists.motherhamster.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I see when I run `scons target=js` I get</div><div><br></div><div>Error: This installation of FreeBASIC doesn't support this target-arch combination;<br>/usr/local/bin/../lib/freebasic/js-asmjs/libfb.a [or libfbpic.a] is missing.</div><div><br></div><div>Where do I find freebasic/js-asmjs/libfb.a ?</div><div><br></div><div>TMC, have you written any instructions anywhere for how to compile the ohr with emscripten?</div><div><br></div><div>I'm feeling ready to tackle that nightly build :D</div><div><br></div><div>---</div><div>James</div><div><br></div></div>
_______________________________________________<br>
Ohrrpgce mailing list<br>
<a href="mailto:ohrrpgce@lists.motherhamster.org" target="_blank">ohrrpgce@lists.motherhamster.org</a><br>
<a href="http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org" rel="noreferrer" target="_blank">http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org</a><br>
</blockquote></div>
_______________________________________________<br>
Ohrrpgce mailing list<br>
<a href="mailto:ohrrpgce@lists.motherhamster.org" target="_blank">ohrrpgce@lists.motherhamster.org</a><br>
<a href="http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org" rel="noreferrer" target="_blank">http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>