Resurrection of my old DOS Program

Install emscripten

 git clone https://github.com/emscripten-core/emsdk.git
 cd emsdk
 git pull
 ./emsdk install latest
 ./emsdk activate latest
 source ./emsdk_env.sh

Due to some browser such as Chrome and Safari will mute the sound when start. We can fixed the problem by go to emsdk directory, modify “./fastcomp/emscripten/src/shell.html” as shown below:-

        Module.setStatus('Exception thrown, see JavaScript console');
        spinnerElement.style.display = 'none';
        Module.setStatus = function(text) {
          if (text) Module.printErr('[post-exception status] ' + text);
        };
      };
    </script>
    <!-- REF: https://developers.google.com/web/updates/2018/11/web-audio-autoplay -->
    <script type='text/javascript'>
        function resumeAudio() {
          if (typeof Module === 'undefined'
              || typeof Module.SDL2 == 'undefined'
              || typeof Module.SDL2.audioContext == 'undefined')
              return;
          if (Module.SDL2.audioContext.state == 'suspended') {
              Module.SDL2.audioContext.resume();
          }
          if (Module.SDL2.audioContext.state == 'running') {
              document.getElementById('canvas').removeEventListener('click', resumeAudio);
              document.removeEventListener('keydown', resumeAudio);
          }
        }
      document.getElementById('canvas').addEventListener('click', resumeAudio);
      document.addEventListener('keydown', resumeAudio);
    </script>

    {{{ SCRIPT }}}
  </body>
</html>

Check out em-dosbox

git clone https://github.com/dreamlayers/em-dosbox.git
cd em-dosbox

Add “-s FORCE_FILESYSTEM=1” to src/Makefile.am since we also required filesystem support.

EXTRA_DIST = winres.rc dosbox.ico

if EMSCRIPTEN_BUILD
dosbox_LDFLAGS=-s TOTAL_MEMORY=134217728 -s ALLOW_MEMORY_GROWTH=0 -s FORCE_FILESYSTEM=1
CLEANFILES=dosbox.js dosbox.html.mem dosbox.js.orig.js dosbox.js.tmp.js

Configure and build em-dosbox.

cd ~/emsdk
source ./emsdk_env.sh
cd ~/em-dosbox
emconfigure ./configure
make

Put all DOS files inside a directory under em-dosbox/src, in this case “praditww” and start creating dosbox application.

cd ~/em-dosbox/src
./packager.py pradit praditww PRADITWW.EXE

This will create files that will be use to run dosbox with browser ie:- pradit.html and pradit.data. To test it, issue the following command “python -m SimpleHTTPServer” and access this URL “http://localhost:8000/pradit.html”.