two_instances.html 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 V86({
  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 V86({
  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-byte", function(byte)
  54. {
  55. var char = String.fromCharCode(byte);
  56. emulator2.serial0_send(char);
  57. });
  58. emulator1.add_listener("net0-send", function(data)
  59. {
  60. emulator2.bus.send("net0-receive", data);
  61. });
  62. emulator2.add_listener("net0-send", function(data)
  63. {
  64. emulator1.bus.send("net0-receive", data);
  65. });
  66. };
  67. </script>
  68. Click on a screen to control it.<hr>
  69. <div id="screen_container1" style="float: left; margin: 10px; border: 3px solid yellow;">
  70. <div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
  71. <canvas style="display: none"></canvas>
  72. </div>
  73. <div id="screen_container2" style="float: left; margin: 10px; border: 3px solid black;">
  74. <div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
  75. <canvas style="display: none"></canvas>
  76. </div>