diff --git a/Readme.md b/Readme.md index 0184d7cd07..041ddc8a8b 100644 --- a/Readme.md +++ b/Readme.md @@ -13,11 +13,11 @@ Demos API examples - -- [Basic](docs/samples/basic.html) -- [Programatically using the serial terminal](docs/samples/serial.html) -- [A LUA interpreter](docs/samples/lua.html) -- [Two instances in one window](docs/samples/two_instances.html) -- [Saving and restoring emulator state](docs/samples/save_restore.html) +- [Basic](examples/basic.html) +- [Programatically using the serial terminal](examples/serial.html) +- [A LUA interpreter](examples/lua.html) +- [Two instances in one window](examples/two_instances.html) +- [Saving and restoring emulator state](examples/save_restore.html) Using v86 for your own purposes is as easy as: @@ -79,7 +79,7 @@ How to build, run and embed? locally, make sure to serve it from a local webserver. You can use `make run` to serve the files using Python's SimpleHTTPServer. - If you want only want to embed v86 on website you can use libv86.js. For - usage, check out the [API](docs/api.md) and [examples](docs/samples/). + usage, check out the [API](docs/api.md) and [examples](examples/). - A couple of disk images are provided for testing. You can check them out using `wget -P images/ http://copy.sh/v86/images/{linux.iso,linux3.iso,kolibri.img,windows101.img,os8.dsk,freedos722.img,openbsd.img}`. @@ -88,7 +88,7 @@ How to build, run and embed? ```bash # grab the main repo -git clone https://github.com/copy/v86.git +git clone https://github.com/copy/v86.git cd v86 diff --git a/docs/api.md b/docs/api.md index abe93382c8..65c0419a0f 100644 --- a/docs/api.md +++ b/docs/api.md @@ -52,10 +52,10 @@ Options can have the following properties (all optional, default in parenthesis) - `serial_container HTMLTextAreaElement` (No serial terminal) - A textarea that will receive and send data to the emulated serial terminal. Alternatively the serial terminal can also be accessed programatically, - see [serial.html](samples/serial.html). + see [serial.html](../examples/serial.html). - `screen_container HTMLElement` (No screen) - An HTMLElement. This should - have a certain structure, see [basic.html](samples/basic.html). + have a certain structure, see [basic.html](../examples/basic.html). *** @@ -267,6 +267,6 @@ initialized. 1. **`string`** file 2. **`function(Object, Uint8Array)`** callback - + diff --git a/docs/build.js b/docs/build.js index 3b608b60e5..3af6248cc8 100755 --- a/docs/build.js +++ b/docs/build.js @@ -3,7 +3,7 @@ var markdox = require("markdox"); var options = { - output: __dirname + "/api.md", + output: __dirname + "/api.md", template: __dirname + "/template.md.ejs" }; @@ -12,5 +12,5 @@ var files = [ ]; markdox.process(files, options, function() { - console.log("Ok."); + console.log("Ok. %s written.", options.output); }); diff --git a/examples/arch.html b/examples/arch.html new file mode 100644 index 0000000000..f3dc492c8d --- /dev/null +++ b/examples/arch.html @@ -0,0 +1,82 @@ + +Archlinux + + + + + +Restore from file: +
+ + +
+
+ +
diff --git a/docs/samples/async_load.html b/examples/async_load.html similarity index 100% rename from docs/samples/async_load.html rename to examples/async_load.html diff --git a/docs/samples/basic.html b/examples/basic.html similarity index 100% rename from docs/samples/basic.html rename to examples/basic.html diff --git a/examples/lang.html b/examples/lang.html new file mode 100644 index 0000000000..7664779981 --- /dev/null +++ b/examples/lang.html @@ -0,0 +1,90 @@ + +Basic Emulator + + + + +
 
+ + +
+
+ +
+ +
+ +

diff --git a/examples/lang2.html b/examples/lang2.html
new file mode 100644
index 0000000000..5134bcf43a
--- /dev/null
+++ b/examples/lang2.html
@@ -0,0 +1,104 @@
+
+Interpreter 2
+
+
+
+
+
0s -- 
+
+ +
+
+
+
+ + +
+
+ +
+ diff --git a/docs/samples/lua.html b/examples/lua.html similarity index 100% rename from docs/samples/lua.html rename to examples/lua.html diff --git a/docs/samples/nodejs.js b/examples/nodejs.js similarity index 87% rename from docs/samples/nodejs.js rename to examples/nodejs.js index aa4fe40796..7632e47b3a 100755 --- a/docs/samples/nodejs.js +++ b/examples/nodejs.js @@ -14,6 +14,10 @@ console.log("Use F2 to save the state and F3 to restore."); var bios = readfile(__dirname + "/../../bios/seabios.bin"); var linux = readfile(__dirname + "/../../images/linux.iso"); +process.stdin.setRawMode(true); +process.stdin.resume(); +process.stdin.setEncoding("utf8"); + var emulator = new V86Starter({ bios: { buffer: bios }, cdrom: { buffer: linux }, @@ -22,15 +26,20 @@ var emulator = new V86Starter({ emulator.add_listener("serial0-output-char", function(chr) { + if(!booted) + { + var now = Date.now(); + console.log("Took %dms to boot", now - boot_start); + booted = true; + } + process.stdout.write(chr); }); console.log("Now booting, please stand by ..."); -process.stdin.setRawMode(true); -process.stdin.resume(); -process.stdin.setEncoding("utf8"); - +var boot_start = Date.now(); +var booted = false; var state; process.stdin.on("data", function(c) diff --git a/docs/samples/save_restore.html b/examples/save_restore.html similarity index 100% rename from docs/samples/save_restore.html rename to examples/save_restore.html diff --git a/docs/samples/serial.html b/examples/serial.html similarity index 100% rename from docs/samples/serial.html rename to examples/serial.html diff --git a/docs/samples/two_instances.html b/examples/two_instances.html similarity index 100% rename from docs/samples/two_instances.html rename to examples/two_instances.html diff --git a/examples/worker.html b/examples/worker.html new file mode 100644 index 0000000000..79eecd1cee --- /dev/null +++ b/examples/worker.html @@ -0,0 +1,28 @@ + +Worker + + + +s +
+ + diff --git a/examples/worker.js b/examples/worker.js new file mode 100644 index 0000000000..bc164b14a5 --- /dev/null +++ b/examples/worker.js @@ -0,0 +1,25 @@ +importScripts("../../build/libv86.js"); + +var worker = this; + +var emulator = new V86Starter({ + memory_size: 32 * 1024 * 1024, + vga_memory_size: 2 * 1024 * 1024, + bios: { + url: "../../bios/seabios.bin", + }, + vga_bios: { + url: "../../bios/vgabios.bin", + }, + cdrom: { + url: "../../images/linux.iso", + }, + autostart: true, +}); + + +emulator.add_listener("serial0-output-char", function(chr) +{ + worker.postMessage(chr); +}); + diff --git a/src/browser/starter.js b/src/browser/starter.js index 7a55f3e748..d04ccd4198 100644 --- a/src/browser/starter.js +++ b/src/browser/starter.js @@ -36,10 +36,10 @@ * - `serial_container HTMLTextAreaElement` (No serial terminal) - A textarea * that will receive and send data to the emulated serial terminal. * Alternatively the serial terminal can also be accessed programatically, - * see [serial.html](samples/serial.html). + * see [serial.html](../examples/serial.html). * * - `screen_container HTMLElement` (No screen) - An HTMLElement. This should - * have a certain structure, see [basic.html](samples/basic.html). + * have a certain structure, see [basic.html](../examples/basic.html). * * *** *