floppy-insert-eject.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env node
  2. "use strict";
  3. const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
  4. const pause = require("timers/promises").setTimeout;
  5. const fs = require("fs");
  6. var V86 = require(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.js`).V86;
  7. process.on("unhandledRejection", exn => { throw exn; });
  8. const emulator = new V86({
  9. bios: { url: __dirname + "/../../bios/seabios.bin" },
  10. vga_bios: { url: __dirname + "/../../bios/vgabios.bin" },
  11. hda: { url: __dirname + "/../../images/msdos.img" },
  12. network_relay_url: "<UNUSED>",
  13. autostart: true,
  14. memory_size: 32 * 1024 * 1024,
  15. filesystem: {},
  16. log_level: 3,
  17. disable_jit: +process.env.DISABLE_JIT,
  18. });
  19. //const interval = setInterval(() => {
  20. // console.warn(emulator.screen_adapter.get_text_screen());
  21. //}, 1000);
  22. const timeout = setTimeout(() => {
  23. console.warn(emulator.screen_adapter.get_text_screen());
  24. throw new Error("Timeout");
  25. }, 60 * 1000);
  26. setTimeout(async () =>
  27. {
  28. await emulator.wait_until_vga_screen_contains("C:\\> ");
  29. console.log("Got C:\\>");
  30. await pause(1000);
  31. emulator.keyboard_send_text("dir A:\n");
  32. await emulator.wait_until_vga_screen_contains("Abort, Retry, Fail?");
  33. console.log("Got Abort, Retry, Fail?");
  34. await pause(1000);
  35. emulator.keyboard_send_text("F");
  36. emulator.set_fda({ url: __dirname + "/../../images/freedos722.img" });
  37. emulator.keyboard_send_text("dir A:\n");
  38. await emulator.wait_until_vga_screen_contains("FDOS <DIR>");
  39. console.log("Got FDOS");
  40. emulator.stop();
  41. clearTimeout(timeout);
  42. //clearInterval(interval);
  43. }, 1000);