1
0

arch.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <!doctype html>
  2. <title>Archlinux</title>
  3. <script src="../build/libv86.js"></script>
  4. <script>
  5. "use strict";
  6. window.onload = function()
  7. {
  8. var emulator = new V86({
  9. wasm_path: "../build/v86.wasm",
  10. memory_size: 512 * 1024 * 1024,
  11. vga_memory_size: 8 * 1024 * 1024,
  12. screen_container: document.getElementById("screen_container"),
  13. bios: {
  14. url: "../bios/seabios.bin",
  15. },
  16. vga_bios: {
  17. url: "../bios/vgabios.bin",
  18. },
  19. filesystem: {
  20. baseurl: "../images/arch/",
  21. basefs: "../images/fs.json",
  22. },
  23. autostart: true,
  24. bzimage_initrd_from_filesystem: true,
  25. cmdline: [
  26. "rw",
  27. "root=host9p rootfstype=9p rootflags=trans=virtio,cache=loose",
  28. "init=/usr/bin/init-openrc",
  29. ].join(" "),
  30. });
  31. document.getElementById("save_file").onclick = async function()
  32. {
  33. const new_state = await emulator.save_state();
  34. var a = document.createElement("a");
  35. a.download = "v86state.bin";
  36. a.href = window.URL.createObjectURL(new Blob([new_state]));
  37. a.dataset.downloadurl = "application/octet-stream:" + a.download + ":" + a.href;
  38. a.click();
  39. this.blur();
  40. };
  41. document.getElementById("restore_file").onchange = function()
  42. {
  43. if(this.files.length)
  44. {
  45. var filereader = new FileReader();
  46. emulator.stop();
  47. filereader.onload = async function(e)
  48. {
  49. await emulator.restore_state(e.target.result);
  50. emulator.run();
  51. };
  52. filereader.readAsArrayBuffer(this.files[0]);
  53. this.value = "";
  54. }
  55. this.blur();
  56. };
  57. };
  58. </script>
  59. <input id="save_file" type="button" value="Save state to file">
  60. Restore from file: <input id="restore_file" type="file">
  61. <hr>
  62. <!-- A minimal structure for the ScreenAdapter defined in browser/screen.js -->
  63. <div id="screen_container">
  64. <div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
  65. <canvas style="display: none"></canvas>
  66. </div>