Menu

SDL2 and WASM

2018-11-12
2020-04-26
  • Witold Filipczyk

    Hello,
    Do you plan to add SDL2 code?

    SDL2 is supported by emscripten and compilation of fuse with it possible.
    http://tc2048.y0.pl/WASM/fuse.html (is proof)
    http://tc2048.y0.pl/WASM/fuse-emscripten.diff
    This is based on 2014-12-28-sdl2 branch.

    Here is sample recipe for compilation:

    First get and configure latest emscripten.

    Next, compile libspectrum:
    untar libspectrum-1.4.4.tar.gz
    cd libspectrum-1.4.4
    CFLAGS='-O2 -s USE_ZLIB=1' CPPFLAGS='-O2 -s USE_ZLIB=1' emconfigure ./configure --prefix=$HOME --with-fake-glib
    gcc -o make-perl make-perl.c -I.
    emmake make
    emmake make install

    Next, libxml2
    untar libxml2-2.9.8.tar.gz
    cd libxml2-2.9.8
    emconfigure ./configure --prefix=$HOME --without-python --without-threads
    emmake make
    emmake make install

    And finally fuse:
    apply fuse-emscripten.diff
    Copy ~/lib/libspectrum.so.8.8.14 to libspectrum.bc
    Copy ~/lib/libxml2.so.2.9.8 to libxml2.bc
    ./autogen.sh
    CFLAGS="-O3 -s USE_SDL=2 -s USE_LIBPNG=1 -s USE_ZLIB=1 -s TOTAL_MEMORY=536870912 -s ALLOW_MEMORY_GROWTH=1" \ CPPFLAGS="-O3 -s USE_SDL=2 -s USE_LIBPNG=1 -s USE_ZLIB=1 -s TOTAL_MEMORY=536870912 -s ALLOW_MEMORY_GROWTH=1" \ emconfigure ./configure --with-sdl --without-pthread --prefix=$HOME

    emmake make
    cp -a fuse fuse.bc

    emcc -o fuseall.bc fuse.bc libspectrum.bc libxml2.bc -O3 -s USE_SDL=2 -s USE_LIBPNG=1 -s USE_ZLIB=1 -s TOTAL_MEMORY=536870912 -s ALLOW_MEMORY_GROWTH=1

    copy to roms all required files, eg. fuse.font, .fuserc, bmp files, etc.

    emcc fuseall.bc -o fuse.html -O3 -s USE_SDL=2 -s USE_LIBPNG=1 -s USE_ZLIB=1 -s TOTAL_MEMORY=536870912 -s ALLOW_MEMORY_GROWTH=1 \ --preload-file roms@/

    Could you add SDL2 to supported versions of fuse? Branch is from end of 2014, but it is not so complicated to refresh it and emscripten compatibility out of the box would be nice feature for the end of 2018.

     
  • serdeliuk

    serdeliuk - 2020-04-26

    I have updated/created a SDL2 patch for Fuse 1.5.7 i hope is not too late :)
    https://sourceforge.net/p/fuse-emulator/patches/430/

     

Log in to post a comment.