arch.html 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 V86Starter({
  9. wasm_path: "../build/v86.wasm",
  10. memory_size: 128 * 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. hda: {
  20. url: "http://localhost/v86-images/arch3.img",
  21. async: true,
  22. size: 8 * 1024 * 1024 * 1024,
  23. },
  24. filesystem: {
  25. baseurl: "http://localhost/v86-images/arch/",
  26. basefs: "http://localhost/v86-images/fs.json",
  27. },
  28. autostart: true,
  29. });
  30. document.getElementById("save_file").onclick = function()
  31. {
  32. emulator.save_state(function(error, new_state)
  33. {
  34. if(error)
  35. {
  36. throw error;
  37. }
  38. var a = document.createElement("a");
  39. a.download = "v86state.bin";
  40. a.href = window.URL.createObjectURL(new Blob([new_state]));
  41. a.dataset.downloadurl = "application/octet-stream:" + a.download + ":" + a.href;
  42. a.click();
  43. });
  44. this.blur();
  45. };
  46. document.getElementById("restore_file").onchange = function()
  47. {
  48. if(this.files.length)
  49. {
  50. var filereader = new FileReader();
  51. emulator.stop();
  52. filereader.onload = function(e)
  53. {
  54. emulator.restore_state(e.target.result);
  55. emulator.run();
  56. };
  57. filereader.readAsArrayBuffer(this.files[0]);
  58. this.value = "";
  59. }
  60. this.blur();
  61. };
  62. };
  63. </script>
  64. <input id="save_file" type="button" value="Save state to file">
  65. Restore from file: <input id="restore_file" type="file">
  66. <hr>
  67. <!-- A minimal structure for the ScreenAdapter defined in browser/screen.js -->
  68. <div id="screen_container">
  69. <div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
  70. <canvas style="display: none"></canvas>
  71. </div>