From 4bd771f97f4d0f746505cbe4e96745727dc65675 Mon Sep 17 00:00:00 2001 From: David Alvarez Date: Wed, 27 May 2026 09:38:26 +0200 Subject: [PATCH] fix: add jsdos.json to bundle for proper js-dos v8 config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The missing piece — dos.zone's bundle has .jsdos/jsdos.json which tells js-dos v8 how to configure the emulator (autoexec command, autolock=true, etc.). Without it, js-dos may apply different defaults that don't match our dosbox.conf. Also simplified dosbox.conf to just the essential sections and removed mapperfile=mapper-jsdos.map (not bundled). Keeps usescancodes=true, autolock=true, SB16 audio. --- .../java/com/dostalgia/UploadResource.java | 86 +++++-------------- 1 file changed, 21 insertions(+), 65 deletions(-) diff --git a/src/main/java/com/dostalgia/UploadResource.java b/src/main/java/com/dostalgia/UploadResource.java index 18408dc..faee721 100644 --- a/src/main/java/com/dostalgia/UploadResource.java +++ b/src/main/java/com/dostalgia/UploadResource.java @@ -91,6 +91,7 @@ public class UploadResource { String relExe = Path.of(mainExe).getFileName().toString(); String conf = buildDosboxConf(relExe); Files.writeString(jsdos.resolve("dosbox.conf"), conf); + Files.write(jsdos.resolve("jsdos.json"), buildJsdosJson(relExe)); bundleFile = ".jsdos/dosbox.conf"; } else { // Create .jsdos bundle (flat in games dir) @@ -218,6 +219,7 @@ public class UploadResource { String relExe = Path.of(mainExe).getFileName().toString(); String conf = buildDosboxConf(relExe); Files.writeString(jsdos.resolve("dosbox.conf"), conf); + Files.write(jsdos.resolve("jsdos.json"), buildJsdosJson(relExe)); // ZIP it up try (var zos = new java.util.zip.ZipOutputStream(Files.newOutputStream(bundlePath))) { @@ -240,95 +242,49 @@ public class UploadResource { // ─── File Utilities ────────────────────────────────────────── /** - * Build a complete dosbox.conf with all sections needed for proper - * keyboard and hardware emulation in js-dos v8. + * Build a minimal dosbox.conf with the critical settings for js-dos v8. + * The key setting is usescancodes=true — without it DOSBox doesn't + * translate physical key presses into game input. */ + private byte[] buildJsdosJson(String relExe) { + String json = "{" + + "\"autoexec\":{" + + "\"options\":{\"script\":{\"value\":\"" + escapeJson(relExe) + "\"}}" + + "}," + + "\"output\":{" + + "\"options\":{\"autolock\":{\"value\":true}}}" + + "}"; + return json.getBytes(java.nio.charset.StandardCharsets.UTF_8); + } + + private String escapeJson(String s) { + return s.replace("\\", "\\\\").replace("\"", "\\\""); + } + private String buildDosboxConf(String relExe) { return "[sdl]\n" + "autolock=true\n" - + "fullscreen=false\n" - + "fulldouble=false\n" - + "fullresolution=original\n" - + "windowresolution=original\n" - + "output=surface\n" - + "sensitivity=100\n" - + "waitonerror=true\n" - + "priority=higher,normal\n" - + "mapperfile=mapper-jsdos.map\n" + "usescancodes=true\n" - + "\n" - + "[dosbox]\n" - + "machine=svga_s3\n" - + "memsize=16\n" + + "output=surface\n" + "\n" + "[cpu]\n" + "core=auto\n" - + "cputype=auto\n" + "cycles=auto\n" + "\n" + "[mixer]\n" + "nosound=false\n" + "rate=44100\n" - + "blocksize=1024\n" - + "prebuffer=20\n" - + "\n" - + "[render]\n" - + "frameskip=0\n" - + "aspect=false\n" - + "scaler=none\n" - + "\n" - + "[midi]\n" - + "mpu401=intelligent\n" - + "mididevice=default\n" - + "midiconfig=\n" + "\n" + "[sblaster]\n" + "sbtype=sb16\n" - + "sbbase=220\n" + "irq=7\n" + "dma=1\n" + "hdma=5\n" - + "sbmixer=true\n" - + "oplmode=auto\n" - + "oplemu=default\n" - + "oplrate=44100\n" - + "\n" - + "[gus]\n" - + "gus=false\n" - + "gusrate=44100\n" - + "gusbase=240\n" - + "gusirq=5\n" - + "gusdma=3\n" - + "ultradir=C:\\ULTRASND\n" - + "\n" - + "[speaker]\n" - + "pcspeaker=true\n" - + "pcrate=44100\n" - + "tandy=auto\n" - + "tandyrate=44100\n" - + "disney=true\n" - + "\n" - + "[joystick]\n" - + "joysticktype=auto\n" - + "timed=true\n" - + "autofire=false\n" - + "swap34=false\n" - + "buttonwrap=false\n" - + "\n" - + "[serial]\n" - + "serial1=dummy\n" - + "serial2=dummy\n" - + "serial3=disabled\n" - + "serial4=disabled\n" + "\n" + "[dos]\n" + "xms=true\n" + "ems=true\n" + "umb=true\n" - + "keyboardlayout=auto\n" - + "\n" - + "[ipx]\n" - + "ipx=true\n" + "\n" + "[autoexec]\n" + "@echo off\n"