js-dos 8.xx Help

DOSBox Direct

DOS Direct is an emulation backend based on DOSBox, you can create it with the following command:

const ci = await emulators.dosboxDirect(bundle);

Direct version is universal, it can work in Node.js environment. But it has a strong disadvantage: it's working on the main browser thread. So it can easily the app froze a browser for some amount of time, and not be very responsive.

Accessing file system

In direct mode you can easily access emscripten module:

const ci = await emulators.dosboxDirect(bundle); ci.transport.module // <-- emscripten module

Emscripten module provide lowlevel api to change file system:

const ci = await emulators.dosboxDirect(bundle); ci.transport.module.FS // <-- emscripten FS api

You can also rescan DOS devices:

const ci = await emulators.dosboxDirect(bundle); ci.transport.module._rescanFilesystem();

Accessing memory

In direct mode you can dump whole memory of dos:

const ci = await emulators.dosboxDirect(bundle); ci.transport.module._dumpMemory(copyDosMemory); ci.transport.module.memoryContents // <-- now you can access contents using this var

If you need to copy the entire memory, pass true as argument. The memoryContents contains the following:

{ "memBase": ..., "ip": ..., "flags": ..., "registers": { "ax": ..., "cx": ..., "dx": ..., "sp": ..., "bp": ..., "si": ..., "di": ... }, "segments_values": { "es": ..., "cs": ..., "ss": ..., "ds": ..., "fs": ..., "gs": ... }, "segments_physical": { "es": ..., "cs": ..., "ss": ..., "ds": ..., "fs": ..., "gs": ... }, "numPages": ..., "memoryCopy": ... }

Pausing execution

In direct mode, you can pause the Dosbox execution loop without pausing the emscripten loop. This lets you pause and inspect the current memory, for instance.

const ci = await emulators.dosboxDirect(bundle); ci.transport.module._pauseExecution(true);

The _pauseExecution function takes as its argument whether it should be paused or should resume. To resume once you have completed:

ci.transport.module._pauseExecution(false);
Last modified: 21 июня 2024