two_instances.html 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <!doctype html>
  2. <title>Two emulators</title>
  3. <script src="../build/libv86.js"></script>
  4. <script>
  5. "use strict";
  6. window.onload = function()
  7. {
  8. var container1 = document.getElementById("screen_container1");
  9. var container2 = document.getElementById("screen_container2");
  10. var emulator1 = new V86Starter({
  11. wasm_path: "../build/v86.wasm",
  12. screen_container: container1,
  13. bios: {
  14. url: "../bios/seabios.bin",
  15. },
  16. vga_bios: {
  17. url: "../bios/vgabios.bin",
  18. },
  19. cdrom: {
  20. url: "../images/linux.iso",
  21. },
  22. autostart: true,
  23. });
  24. var emulator2 = new V86Starter({
  25. wasm_path: "../build/v86.wasm",
  26. screen_container: container2,
  27. bios: {
  28. url: "../bios/seabios.bin",
  29. },
  30. vga_bios: {
  31. url: "../bios/vgabios.bin",
  32. },
  33. cdrom: {
  34. url: "../images/linux.iso",
  35. },
  36. autostart: true,
  37. });
  38. emulator2.keyboard_set_status(false);
  39. container1.addEventListener("mousedown", function(e)
  40. {
  41. container1.style.borderColor = "yellow";
  42. container2.style.borderColor = "black";
  43. emulator1.keyboard_set_status(true);
  44. emulator2.keyboard_set_status(false);
  45. }, false);
  46. container2.addEventListener("mousedown", function(e)
  47. {
  48. container1.style.borderColor = "black";
  49. container2.style.borderColor = "yellow";
  50. emulator1.keyboard_set_status(false);
  51. emulator2.keyboard_set_status(true);
  52. }, false);
  53. emulator1.add_listener("serial0-output-char", function(char)
  54. {
  55. emulator2.serial0_send(char);
  56. });
  57. };
  58. </script>
  59. Click on a screen to control it.<hr>
  60. <div id="screen_container1" style="float: left; margin: 10px; border: 3px solid yellow;">
  61. <div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
  62. <canvas style="display: none"></canvas>
  63. </div>
  64. <div id="screen_container2" style="float: left; margin: 10px; border: 3px solid black;">
  65. <div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
  66. <canvas style="display: none"></canvas>
  67. </div>