2019-02-03 22:49:09 +01:00
|
|
|
/* We're using modern esm imports here */
|
2018-08-25 05:55:03 +02:00
|
|
|
import { setupState } from 'es6://app-state.js'
|
|
|
|
import { setupClickListener, setupEscListener, setupCloseListener } from 'es6://listeners.js'
|
2019-08-04 17:45:18 +02:00
|
|
|
import { toggleSetup, setupButtons } from 'es6://buttons.js'
|
2019-02-03 22:49:09 +01:00
|
|
|
import { startInfoMaybe } from 'es6://info.js'
|
2019-02-03 23:02:30 +01:00
|
|
|
import { setupIpcListeners } from 'es6://ipc.js'
|
2018-08-24 00:33:29 +02:00
|
|
|
|
2018-08-25 05:55:03 +02:00
|
|
|
setupState()
|
2018-08-23 07:03:28 +02:00
|
|
|
|
2018-08-25 05:55:03 +02:00
|
|
|
/**
|
|
|
|
* The main method executing the VM.
|
|
|
|
*/
|
|
|
|
async function main () {
|
2019-02-03 22:49:09 +01:00
|
|
|
const imageSize = await window.windows95.getDiskImageSize()
|
|
|
|
const options = {
|
|
|
|
memory_size: 128 * 1024 * 1024,
|
|
|
|
video_memory_size: 32 * 1024 * 1024,
|
2018-08-23 04:51:31 +02:00
|
|
|
screen_container: document.getElementById('emulator'),
|
|
|
|
bios: {
|
2018-08-23 07:25:17 +02:00
|
|
|
url: './bios/seabios.bin'
|
2018-08-23 04:51:31 +02:00
|
|
|
},
|
|
|
|
vga_bios: {
|
2018-08-23 07:25:17 +02:00
|
|
|
url: './bios/vgabios.bin'
|
2018-08-24 00:33:29 +02:00
|
|
|
},
|
2018-08-25 05:55:03 +02:00
|
|
|
hda: {
|
|
|
|
url: '../images/windows95.img',
|
|
|
|
async: true,
|
2019-02-03 22:49:09 +01:00
|
|
|
size: imageSize
|
2018-08-25 05:55:03 +02:00
|
|
|
},
|
2018-08-24 00:33:29 +02:00
|
|
|
fda: {
|
2018-08-25 05:55:03 +02:00
|
|
|
buffer: window.appState.floppyFile || undefined
|
2018-08-24 00:33:29 +02:00
|
|
|
},
|
|
|
|
boot_order: 0x132
|
2019-02-03 22:49:09 +01:00
|
|
|
}
|
2018-08-24 01:16:40 +02:00
|
|
|
|
2019-02-03 22:49:09 +01:00
|
|
|
console.log(`Starting emulator with options`, options)
|
2018-08-25 05:55:03 +02:00
|
|
|
|
2019-02-03 22:49:09 +01:00
|
|
|
// New v86 instance
|
|
|
|
window.emulator = new V86Starter(options)
|
2018-08-23 07:03:28 +02:00
|
|
|
|
2018-08-25 05:55:03 +02:00
|
|
|
// Restore state. We can't do this right away
|
|
|
|
// and randomly chose 500ms as the appropriate
|
|
|
|
// wait time (lol)
|
2018-08-23 07:03:28 +02:00
|
|
|
setTimeout(async () => {
|
2018-08-25 05:55:03 +02:00
|
|
|
if (!window.appState.bootFresh) {
|
|
|
|
windows95.restoreState()
|
2018-08-24 00:33:29 +02:00
|
|
|
}
|
2018-08-23 07:03:28 +02:00
|
|
|
|
2019-02-03 22:49:09 +01:00
|
|
|
startInfoMaybe()
|
2018-08-25 08:01:33 +02:00
|
|
|
|
2018-08-25 05:55:03 +02:00
|
|
|
window.appState.cursorCaptured = true
|
2018-08-23 07:03:28 +02:00
|
|
|
window.emulator.lock_mouse()
|
|
|
|
window.emulator.run()
|
|
|
|
}, 500)
|
2018-08-23 04:51:31 +02:00
|
|
|
}
|
|
|
|
|
2018-08-25 05:55:03 +02:00
|
|
|
function start () {
|
2018-08-24 00:33:29 +02:00
|
|
|
document.body.className = ''
|
2018-08-23 07:03:28 +02:00
|
|
|
|
2019-08-04 17:45:18 +02:00
|
|
|
toggleSetup(false)
|
2018-08-25 05:55:03 +02:00
|
|
|
setupClickListener()
|
|
|
|
main()
|
2018-08-23 23:59:13 +02:00
|
|
|
}
|
|
|
|
|
2019-02-04 00:23:20 +01:00
|
|
|
setupIpcListeners(start)
|
2018-08-23 07:03:28 +02:00
|
|
|
setupEscListener()
|
|
|
|
setupCloseListener()
|
2018-08-25 05:55:03 +02:00
|
|
|
setupButtons(start)
|
2019-02-04 00:23:20 +01:00
|
|
|
|
|
|
|
if (document.location.hash.includes('AUTO_START')) {
|
|
|
|
start()
|
|
|
|
}
|