Web port

From OHRRPGCE-Wiki
Jump to navigation Jump to search

This page is a collection of notes about the emscripten web port.

Status[edit]

As of 2024 we have a web port, but it has some major flaws

  • No support for permanent save games (save slots work, but are silently deleted when you close the browser tab)


Trying it[edit]

Nightly is available here: https://hamsterrepublic.com/ohrrpgce/nightly/ohrrpgce-player-web-wip.zip

It won't work from file:// urls. You need to run a local webserver to serve the files for local testing.

If you have python installed, you can run this from the same folder where the files are located:

 python3 -m http.server

And then open http://localhost:8000/ohrrpgce-game.html in your browser

RPG files[edit]

You can press ctrl+shift+L to open up a form that lets you upload rpg files.

The web port uses a fake filesystem based on the ohrrpgce-game.data file. This file is just a bunch of other files concatenated together with no separator. The filenames, offsets, and file sizes are all defined in ohrrpgce-game.js in the loadPackage() function.

For the FreeBasic code that reads, updates, and rewrites the ohrrpgce-game.data file, see the functions extract_web_data_files() and recreate_web_data_file() in distribmenu.bas

loadPackage Function[edit]

loadPackage({"files":[{"filename":"/games/collider.rpg","start":0,"end":549733},{"filename":"/games/inputtest.rpg","start":549733,"end":1085391},{"filename":"/games/turntest.rpg","start":1085391,"end":1499371}],"remote_package_size":1499371})
{
  "files": [
    {
      "filename": "/games/collider.rpg",
      "start": 0,
      "end": 549733
    },
    {
      "filename": "/games/inputtest.rpg",
      "start": 549733,
      "end": 1085391
    },
    {
      "filename": "/games/turntest.rpg",
      "start": 1085391,
      "end": 1499371
    }
  ],
  "remote_package_size": 1499371
}