Browse Source

s/V86Starter/V86

Fabian 7 months ago
parent
commit
080482da89

+ 1 - 1
Readme.md

@@ -153,7 +153,7 @@ See [tests/Readme.md](tests/Readme.md) for more infos.
 Using v86 for your own purposes is as easy as:
 
 ```javascript
-var emulator = new V86Starter({
+var emulator = new V86({
     screen_container: document.getElementById("screen_container"),
     bios: {
         url: "../../bios/seabios.bin",

+ 2 - 2
docs/archlinux.md

@@ -430,7 +430,7 @@ wget https://raw.githubusercontent.com/smgoller/rangehttpserver/master/RangeHTTP
 python2 RangeHTTPServer.py
 ```
 
-Now that the webserver is running, point your browser to `http://localhost:8000/examples/arch.html`. Wait for the Linux to boot. When the system is up, click 'Save state to file'. Your browser will download a `v86state.bin` file. Copy that file to `/your/v86/dir/images`. You can then edit `examples/arch.html` again and add a 'state' key to the `V86Starter` array.
+Now that the webserver is running, point your browser to `http://localhost:8000/examples/arch.html`. Wait for the Linux to boot. When the system is up, click 'Save state to file'. Your browser will download a `v86state.bin` file. Copy that file to `/your/v86/dir/images`. You can then edit `examples/arch.html` again and add a 'state' key to the `V86` array.
 
 ```sh
 initial_state: {
@@ -442,7 +442,7 @@ If you refresh `http://localhost:8000/examples/arch.html` you will see that the
 
 ### Networking
 
-The emulator can emulate a network card. For more information [look at the networking documentation](https://github.com/copy/v86/blob/master/docs/networking.md). To set up networking in the VM, add the following item to the `V86Starter` array in the `examples/arch.html` file:
+The emulator can emulate a network card. For more information [look at the networking documentation](https://github.com/copy/v86/blob/master/docs/networking.md). To set up networking in the VM, add the following item to the `V86` array in the `examples/arch.html` file:
 ```sh
 network_relay_url: "ws://localhost:8080/",
 ```

+ 1 - 1
docs/windows-xp.md

@@ -35,7 +35,7 @@ Create `winxp.htm` with this content (assuming all the files are in the same fol
 <script>
 onload = function()
 {
-    new V86Starter({
+    new V86({
         wasm_path: "v86.wasm",
         bios: { url: "seabios.bin" },
         vga_bios: { url: "vgabios.bin" },

+ 1 - 1
examples/arch.html

@@ -7,7 +7,7 @@
 
 window.onload = function()
 {
-    var emulator = new V86Starter({
+    var emulator = new V86({
         wasm_path: "../build/v86.wasm",
         memory_size: 512 * 1024 * 1024,
         vga_memory_size: 8 * 1024 * 1024,

+ 1 - 1
examples/async_load.html

@@ -13,7 +13,7 @@ window.onload = function()
     // Support of the "Range: bytes=..." header is required on the server, CORS
     // is required if the server is on a different host
 
-    var emulator = new V86Starter({
+    var emulator = new V86({
         wasm_path: "../build/v86.wasm",
         memory_size: 64 * 1024 * 1024,
         vga_memory_size: 2 * 1024 * 1024,

+ 1 - 1
examples/basic.html

@@ -7,7 +7,7 @@
 
 window.onload = function()
 {
-    var emulator = window.emulator = new V86Starter({
+    var emulator = window.emulator = new V86({
         wasm_path: "../build/v86.wasm",
         memory_size: 32 * 1024 * 1024,
         vga_memory_size: 2 * 1024 * 1024,

+ 1 - 1
examples/debian.html

@@ -7,7 +7,7 @@
 
 window.onload = function()
 {
-    var emulator = new V86Starter({
+    var emulator = new V86({
         wasm_path: "../build/v86.wasm",
         memory_size: 512 * 1024 * 1024,
         vga_memory_size: 8 * 1024 * 1024,

+ 1 - 1
examples/destroy.html

@@ -7,7 +7,7 @@
 
 window.onload = function()
 {
-    var emulator = new V86Starter({
+    var emulator = new V86({
         wasm_path: "../build/v86.wasm",
         memory_size: 32 * 1024 * 1024,
         vga_memory_size: 2 * 1024 * 1024,

+ 1 - 1
examples/lang.html

@@ -14,7 +14,7 @@ window.onload = function()
         document.getElementById("time").textContent = Math.round((Date.now() - start) / 1000);
     }, 999);
 
-    var emulator = new V86Starter({
+    var emulator = new V86({
         wasm_path: "../build/v86.wasm",
         memory_size: 512 * 1024 * 1024,
         vga_memory_size: 8 * 1024 * 1024,

+ 1 - 1
examples/lua.html

@@ -7,7 +7,7 @@
 
 window.onload = function()
 {
-    var emulator = new V86Starter({
+    var emulator = new V86({
         wasm_path: "../build/v86.wasm",
         memory_size: 32 * 1024 * 1024,
         vga_memory_size: 2 * 1024 * 1024,

+ 2 - 2
examples/nodejs.js

@@ -2,7 +2,7 @@
 "use strict";
 
 var fs = require("fs");
-var V86Starter = require("../build/libv86.js").V86Starter;
+var V86 = require("../build/libv86.js").V86;
 
 function readfile(path)
 {
@@ -18,7 +18,7 @@ process.stdin.setEncoding("utf8");
 
 console.log("Now booting, please stand by ...");
 
-var emulator = new V86Starter({
+var emulator = new V86({
     bios: { buffer: bios },
     cdrom: { buffer: linux },
     autostart: true,

+ 2 - 2
examples/nodejs_state.js

@@ -2,7 +2,7 @@
 "use strict";
 
 var fs = require("fs");
-var V86Starter = require("../build/libv86.js").V86Starter;
+var V86 = require("../build/libv86.js").V86;
 
 function readfile(path)
 {
@@ -20,7 +20,7 @@ process.stdin.setEncoding("utf8");
 
 console.log("Now booting, please stand by ...");
 
-var emulator = new V86Starter({
+var emulator = new V86({
     bios: { buffer: bios },
     cdrom: { buffer: linux },
     autostart: true,

+ 1 - 1
examples/save_restore.html

@@ -7,7 +7,7 @@
 
 window.onload = function()
 {
-    var emulator = new V86Starter({
+    var emulator = new V86({
         wasm_path: "../build/v86.wasm",
         memory_size: 32 * 1024 * 1024,
         vga_memory_size: 2 * 1024 * 1024,

+ 1 - 1
examples/serial.html

@@ -7,7 +7,7 @@
 
 window.onload = function()
 {
-    var emulator = new V86Starter({
+    var emulator = new V86({
         wasm_path: "../build/v86.wasm",
 
         // Uncomment to see what's going on

+ 2 - 2
examples/two_instances.html

@@ -10,7 +10,7 @@ window.onload = function()
     var container1 = document.getElementById("screen_container1");
     var container2 = document.getElementById("screen_container2");
 
-    var emulator1 = new V86Starter({
+    var emulator1 = new V86({
         wasm_path: "../build/v86.wasm",
         screen_container: container1,
         bios: {
@@ -25,7 +25,7 @@ window.onload = function()
         autostart: true,
     });
 
-    var emulator2 = new V86Starter({
+    var emulator2 = new V86({
         wasm_path: "../build/v86.wasm",
         screen_container: container2,
         bios: {

+ 1 - 1
examples/worker.js

@@ -1,6 +1,6 @@
 importScripts("../build/libv86.js");
 
-var emulator = new V86Starter({
+var emulator = new V86({
     wasm_path: "../build/v86.wasm",
     memory_size: 32 * 1024 * 1024,
     vga_memory_size: 2 * 1024 * 1024,

+ 2 - 2
src/browser/main.js

@@ -1391,7 +1391,7 @@
             };
         }
 
-        var emulator = new V86Starter({
+        var emulator = new V86({
             "memory_size": memory_size,
             "vga_memory_size": vga_memory_size,
 
@@ -1494,7 +1494,7 @@
 
     /**
      * @param {Object} settings
-     * @param {V86Starter} emulator
+     * @param {V86} emulator
      */
     function init_ui(settings, emulator)
     {

+ 43 - 43
src/browser/starter.js

@@ -3,7 +3,7 @@
 /**
  * Constructor for emulator instances.
  *
- * Usage: `var emulator = new V86Starter(options);`
+ * Usage: `var emulator = new V86(options);`
  *
  * Options can have the following properties (all optional, default in parenthesis):
  *
@@ -88,7 +88,7 @@
  * @param {Object} options Options to initialize the emulator with.
  * @constructor
  */
-function V86Starter(options)
+function V86(options)
 {
     //var worker = new Worker("src/browser/worker.js");
     //var adapter_bus = this.bus = WorkerBus.init(worker);
@@ -234,7 +234,7 @@ function V86Starter(options)
     this.zstd_worker_request_id = 0;
 }
 
-V86Starter.prototype.continue_init = async function(emulator, options)
+V86.prototype.continue_init = async function(emulator, options)
 {
     this.bus.register("emulator-stopped", function()
     {
@@ -613,7 +613,7 @@ V86Starter.prototype.continue_init = async function(emulator, options)
  * @param {Uint8Array} src
  * @return {ArrayBuffer}
  */
-V86Starter.prototype.zstd_decompress = function(decompressed_size, src)
+V86.prototype.zstd_decompress = function(decompressed_size, src)
 {
     const cpu = this.v86.cpu;
 
@@ -637,7 +637,7 @@ V86Starter.prototype.zstd_decompress = function(decompressed_size, src)
  * @param {Uint8Array} src
  * @return {Promise<ArrayBuffer>}
  */
-V86Starter.prototype.zstd_decompress_worker = async function(decompressed_size, src)
+V86.prototype.zstd_decompress_worker = async function(decompressed_size, src)
 {
     if(!this.zstd_worker)
     {
@@ -709,7 +709,7 @@ V86Starter.prototype.zstd_decompress_worker = async function(decompressed_size,
     });
 };
 
-V86Starter.prototype.get_bzimage_initrd_from_filesystem = function(filesystem)
+V86.prototype.get_bzimage_initrd_from_filesystem = function(filesystem)
 {
     const root = (filesystem.read_dir("/") || []).map(x => "/" + x);
     const boot = (filesystem.read_dir("/boot/") || []).map(x => "/boot/" + x);
@@ -749,7 +749,7 @@ V86Starter.prototype.get_bzimage_initrd_from_filesystem = function(filesystem)
  * asynchronous.
  * @export
  */
-V86Starter.prototype.run = async function()
+V86.prototype.run = async function()
 {
     this.bus.send("cpu-run");
 };
@@ -758,7 +758,7 @@ V86Starter.prototype.run = async function()
  * Stop emulation. Do nothing if emulator is not running. Can be asynchronous.
  * @export
  */
-V86Starter.prototype.stop = async function()
+V86.prototype.stop = async function()
 {
     if(!this.cpu_is_running)
     {
@@ -779,7 +779,7 @@ V86Starter.prototype.stop = async function()
  * @ignore
  * @export
  */
-V86Starter.prototype.destroy = async function()
+V86.prototype.destroy = async function()
 {
     await this.stop();
 
@@ -796,7 +796,7 @@ V86Starter.prototype.destroy = async function()
  * Restart (force a reboot).
  * @export
  */
-V86Starter.prototype.restart = function()
+V86.prototype.restart = function()
 {
     this.bus.send("cpu-restart");
 };
@@ -811,7 +811,7 @@ V86Starter.prototype.restart = function()
  * @param {function(*)} listener The callback function.
  * @export
  */
-V86Starter.prototype.add_listener = function(event, listener)
+V86.prototype.add_listener = function(event, listener)
 {
     this.bus.register(event, listener, this);
 };
@@ -823,7 +823,7 @@ V86Starter.prototype.add_listener = function(event, listener)
  * @param {function(*)} listener
  * @export
  */
-V86Starter.prototype.remove_listener = function(event, listener)
+V86.prototype.remove_listener = function(event, listener)
 {
     this.bus.unregister(event, listener);
 };
@@ -843,7 +843,7 @@ V86Starter.prototype.remove_listener = function(event, listener)
  * @param {ArrayBuffer} state
  * @export
  */
-V86Starter.prototype.restore_state = async function(state)
+V86.prototype.restore_state = async function(state)
 {
     dbg_assert(arguments.length === 1);
     this.v86.restore_state(state);
@@ -855,7 +855,7 @@ V86Starter.prototype.restore_state = async function(state)
  * @return {Promise<ArrayBuffer>}
  * @export
  */
-V86Starter.prototype.save_state = async function()
+V86.prototype.save_state = async function()
 {
     dbg_assert(arguments.length === 0);
     return this.v86.save_state();
@@ -901,9 +901,9 @@ V86Starter.prototype.save_state = async function()
  * @return {Object}
  * @export
  */
-V86Starter.prototype.get_statistics = function()
+V86.prototype.get_statistics = function()
 {
-    console.warn("V86Starter.prototype.get_statistics is deprecated. Use events instead.");
+    console.warn("V86.prototype.get_statistics is deprecated. Use events instead.");
 
     var stats = {
         cpu: {
@@ -950,7 +950,7 @@ V86Starter.prototype.get_statistics = function()
  * @ignore
  * @export
  */
-V86Starter.prototype.get_instruction_counter = function()
+V86.prototype.get_instruction_counter = function()
 {
     if(this.v86)
     {
@@ -967,7 +967,7 @@ V86Starter.prototype.get_instruction_counter = function()
  * @return {boolean}
  * @export
  */
-V86Starter.prototype.is_running = function()
+V86.prototype.is_running = function()
 {
     return this.cpu_is_running;
 };
@@ -977,7 +977,7 @@ V86Starter.prototype.is_running = function()
  * when physically changing the floppy disk.
  * @export
  */
-V86Starter.prototype.set_fda = async function(file)
+V86.prototype.set_fda = async function(file)
 {
     if(file.url && !file.async)
     {
@@ -1003,7 +1003,7 @@ V86Starter.prototype.set_fda = async function(file)
  * Eject the floppy drive.
  * @export
  */
-V86Starter.prototype.eject_fda = function()
+V86.prototype.eject_fda = function()
 {
     this.v86.cpu.devices.fdc.eject_fda();
 };
@@ -1016,7 +1016,7 @@ V86Starter.prototype.eject_fda = function()
  * @param {Array.<number>} codes
  * @export
  */
-V86Starter.prototype.keyboard_send_scancodes = function(codes)
+V86.prototype.keyboard_send_scancodes = function(codes)
 {
     for(var i = 0; i < codes.length; i++)
     {
@@ -1029,7 +1029,7 @@ V86Starter.prototype.keyboard_send_scancodes = function(codes)
  * @ignore
  * @export
  */
-V86Starter.prototype.keyboard_send_keys = function(codes)
+V86.prototype.keyboard_send_keys = function(codes)
 {
     for(var i = 0; i < codes.length; i++)
     {
@@ -1042,7 +1042,7 @@ V86Starter.prototype.keyboard_send_keys = function(codes)
  * @ignore
  * @export
  */
-V86Starter.prototype.keyboard_send_text = function(string)
+V86.prototype.keyboard_send_text = function(string)
 {
     for(var i = 0; i < string.length; i++)
     {
@@ -1056,7 +1056,7 @@ V86Starter.prototype.keyboard_send_text = function(string)
  * @ignore
  * @export
  */
-V86Starter.prototype.screen_make_screenshot = function()
+V86.prototype.screen_make_screenshot = function()
 {
     if(this.screen_adapter)
     {
@@ -1074,7 +1074,7 @@ V86Starter.prototype.screen_make_screenshot = function()
  * @ignore
  * @export
  */
-V86Starter.prototype.screen_set_scale = function(sx, sy)
+V86.prototype.screen_set_scale = function(sx, sy)
 {
     if(this.screen_adapter)
     {
@@ -1088,7 +1088,7 @@ V86Starter.prototype.screen_set_scale = function(sx, sy)
  * @ignore
  * @export
  */
-V86Starter.prototype.screen_go_fullscreen = function()
+V86.prototype.screen_go_fullscreen = function()
 {
     if(!this.screen_adapter)
     {
@@ -1132,7 +1132,7 @@ V86Starter.prototype.screen_go_fullscreen = function()
  * @ignore
  * @export
  */
-V86Starter.prototype.lock_mouse = function()
+V86.prototype.lock_mouse = function()
 {
     var elem = document.body;
 
@@ -1151,7 +1151,7 @@ V86Starter.prototype.lock_mouse = function()
  *
  * @param {boolean} enabled
  */
-V86Starter.prototype.mouse_set_status = function(enabled)
+V86.prototype.mouse_set_status = function(enabled)
 {
     if(this.mouse_adapter)
     {
@@ -1165,7 +1165,7 @@ V86Starter.prototype.mouse_set_status = function(enabled)
  * @param {boolean} enabled
  * @export
  */
-V86Starter.prototype.keyboard_set_status = function(enabled)
+V86.prototype.keyboard_set_status = function(enabled)
 {
     if(this.keyboard_adapter)
     {
@@ -1180,7 +1180,7 @@ V86Starter.prototype.keyboard_set_status = function(enabled)
  * @param {string} data
  * @export
  */
-V86Starter.prototype.serial0_send = function(data)
+V86.prototype.serial0_send = function(data)
 {
     for(var i = 0; i < data.length; i++)
     {
@@ -1194,7 +1194,7 @@ V86Starter.prototype.serial0_send = function(data)
  * @param {Uint8Array} data
  * @export
  */
-V86Starter.prototype.serial_send_bytes = function(serial, data)
+V86.prototype.serial_send_bytes = function(serial, data)
 {
     for(var i = 0; i < data.length; i++)
     {
@@ -1210,7 +1210,7 @@ V86Starter.prototype.serial_send_bytes = function(serial, data)
  * @param {function(Object)=} callback
  * @export
  */
-V86Starter.prototype.mount_fs = async function(path, baseurl, basefs, callback)
+V86.prototype.mount_fs = async function(path, baseurl, basefs, callback)
 {
     let file_storage = new MemoryFileStorage();
 
@@ -1263,7 +1263,7 @@ V86Starter.prototype.mount_fs = async function(path, baseurl, basefs, callback)
  * @param {Uint8Array} data
  * @export
  */
-V86Starter.prototype.create_file = async function(file, data)
+V86.prototype.create_file = async function(file, data)
 {
     dbg_assert(arguments.length === 2);
     var fs = this.fs9p;
@@ -1297,7 +1297,7 @@ V86Starter.prototype.create_file = async function(file, data)
  * @param {string} file
  * @export
  */
-V86Starter.prototype.read_file = async function(file)
+V86.prototype.read_file = async function(file)
 {
     dbg_assert(arguments.length === 1);
     var fs = this.fs9p;
@@ -1319,7 +1319,7 @@ V86Starter.prototype.read_file = async function(file)
     }
 };
 
-V86Starter.prototype.automatically = function(steps)
+V86.prototype.automatically = function(steps)
 {
     const run = (steps) =>
     {
@@ -1392,7 +1392,7 @@ V86Starter.prototype.automatically = function(steps)
  * @param {number} length
  * @returns
  */
-V86Starter.prototype.read_memory = function(offset, length)
+V86.prototype.read_memory = function(offset, length)
 {
     return this.v86.cpu.read_blob(offset, length);
 };
@@ -1403,7 +1403,7 @@ V86Starter.prototype.read_memory = function(offset, length)
  * @param {Array.<number>|Uint8Array} blob
  * @param {number} offset
  */
-V86Starter.prototype.write_memory = function(blob, offset)
+V86.prototype.write_memory = function(blob, offset)
 {
     this.v86.cpu.write_blob(blob, offset);
 };
@@ -1435,17 +1435,17 @@ FileNotFoundError.prototype = Error.prototype;
 // Closure Compiler's way of exporting
 if(typeof window !== "undefined")
 {
-    window["V86Starter"] = V86Starter;
-    window["V86"] = V86Starter;
+    window["V86Starter"] = V86;
+    window["V86"] = V86;
 }
 else if(typeof module !== "undefined" && typeof module.exports !== "undefined")
 {
-    module.exports["V86Starter"] = V86Starter;
-    module.exports["V86"] = V86Starter;
+    module.exports["V86Starter"] = V86;
+    module.exports["V86"] = V86;
 }
 else if(typeof importScripts === "function")
 {
     // web worker
-    self["V86Starter"] = V86Starter;
-    self["V86"] = V86Starter;
+    self["V86Starter"] = V86;
+    self["V86"] = V86;
 }

+ 1 - 1
tests/manual/gc.html

@@ -7,7 +7,7 @@
 
 window.onload = function()
 {
-    var emulator = new V86Starter({
+    var emulator = new V86({
         wasm_path: "../../build/v86.wasm",
         memory_size: 32 * 1024 * 1024,
         vga_memory_size: 2 * 1024 * 1024,