two_instances.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. screen_container: container1,
  12. bios: {
  13. url: "../bios/seabios.bin",
  14. },
  15. vga_bios: {
  16. url: "../bios/vgabios.bin",
  17. },
  18. cdrom: {
  19. url: "../images/linux.iso",
  20. },
  21. autostart: true,
  22. });
  23. var emulator2 = new V86Starter({
  24. screen_container: container2,
  25. bios: {
  26. url: "../bios/seabios.bin",
  27. },
  28. vga_bios: {
  29. url: "../bios/vgabios.bin",
  30. },
  31. cdrom: {
  32. url: "../images/linux.iso",
  33. },
  34. autostart: true,
  35. });
  36. emulator2.keyboard_set_status(false);
  37. container1.addEventListener("mousedown", function(e)
  38. {
  39. container1.style.borderColor = "yellow";
  40. container2.style.borderColor = "black";
  41. emulator1.keyboard_set_status(true);
  42. emulator2.keyboard_set_status(false);
  43. }, false);
  44. container2.addEventListener("mousedown", function(e)
  45. {
  46. container1.style.borderColor = "black";
  47. container2.style.borderColor = "yellow";
  48. emulator1.keyboard_set_status(false);
  49. emulator2.keyboard_set_status(true);
  50. }, false);
  51. emulator1.add_listener("serial0-output-char", function(char)
  52. {
  53. emulator2.serial0_send(char);
  54. });
  55. };
  56. </script>
  57. Click on a screen to control it.<hr>
  58. <div id="screen_container1" style="float: left; margin: 10px; border: 3px solid yellow;">
  59. <div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
  60. <canvas style="display: none"></canvas>
  61. </div>
  62. <div id="screen_container2" style="float: left; margin: 10px; border: 3px solid black;">
  63. <div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
  64. <canvas style="display: none"></canvas>
  65. </div>