diff --git a/com/isoterminal.js b/com/isoterminal.js index 51ac6be..017d9ca 100644 --- a/com/isoterminal.js +++ b/com/isoterminal.js @@ -65,6 +65,17 @@ AFRAME.registerComponent('isoterminal', { ` }, + toUint8Array: function(str) { + // Create a new Uint8Array with the same length as the input string + const uint8Array = new Uint8Array(str.length); + + // Iterate over the string and populate the Uint8Array + for (let i = 0; i < str.length; i++) { + uint8Array[i] = str.charCodeAt(i); + } + return uint8Array; + }, + runISO: function(dom){ var emulator = window.emulator = dom.emulator = new V86({ wasm_path: "com/isoterminal/v86.wasm", @@ -92,12 +103,64 @@ AFRAME.registerComponent('isoterminal', { // basefs: "com/isoterminal/v86/images/alpine-fs.json", // }, //screen_dummy: true, + //disable_jit: false, + filesystem: {}, autostart: true, }); + + emulator.bus.register("emulator-started", () => { + emulator.create_file("motd", this.toUint8Array(` + ____ _____________ _________ ___ ___ + \ \/ /\______ \/ _____// | \ + \ / | _/\_____ \/ ~ \ + / \ | | \/ \ Y / + /___/\ \ |____|_ /_______ /\___|_ / + \_/ \/ \/ \/ + + `+ "\033[0m" )) + + emulator.create_file("js", this.toUint8Array(`#!/bin/sh + cat /mnt/motd + cat > /dev/null + `)) + //emulator.serial0_send('chmod +x /mnt/js') + //emulator.serial0_send() + }); + + let line = '' + emulator.add_listener("serial0-output-byte", async (byte) => { + var chr = String.fromCharCode(byte); + if(chr < " " && chr !== "\n" && chr !== "\t" || chr > "~") + { + return; + } + + if(chr === "\n") + { + var new_line = line; + line = ""; + } + else if(chr >= " " && chr <= "~") + { + line += chr; + } + + //if(!ran_command && line.endsWith("~% ")) + //{ + // ran_command = true; + // emulator.serial0_send("chmod +x /mnt/test-i386\n"); + // emulator.serial0_send("/mnt/test-i386 > /mnt/result\n"); + // emulator.serial0_send("echo test fini''shed\n"); + //} + console.dir({line,new_line}) + + if(new_line && new_line.includes("buildroot login:")) + { + emulator.serial0_send("root\n") + emulator.serial0_send("mv /mnt/js . && chmod +x js\n") + } + }); - //setTimeout( () => { - // window.requestAnimationFrame = requestAnimationFrame - //},1000) }, events:{ diff --git a/com/isoterminal/xrsh.iso b/com/isoterminal/xrsh.iso deleted file mode 100644 index 179b9f6..0000000 Binary files a/com/isoterminal/xrsh.iso and /dev/null differ diff --git a/com/isoterminal/xrsh.iso b/com/isoterminal/xrsh.iso new file mode 120000 index 0000000..cc52e77 --- /dev/null +++ b/com/isoterminal/xrsh.iso @@ -0,0 +1 @@ +buildroot.iso \ No newline at end of file