Update v86, patch to use fs.readFile

This commit is contained in:
Felix Rieseberg
2022-04-26 12:13:03 -07:00
parent 24a1c30502
commit 7b92d33584
20 changed files with 7922 additions and 2012 deletions

4
.gitignore vendored
View File

@@ -3,5 +3,7 @@ out
src/images
.DS_Store
images
images_new
dist
!.github/images
!.github/images
*.code-workspace

View File

@@ -115,7 +115,7 @@ You'll likely be better off with an actual virtualization app, but the short ans
## Credits
99% of the work was done over at [v86](https://github.com/copy/v86/) by Copy.
99% of the work was done over at [v86](https://github.com/copy/v86/) by Copy aka Fabian Hemmer and his contributors.
## Contributing
@@ -136,6 +136,8 @@ Unpack the `images` folder into the `src` folder, creating this layout:
Once you've done so, run `npm install` and `npm start` to run your local build.
If you want to tinker with the image or make a new one, check out the [QEMU docs](./docs/qemu.md).
## Other Questions
* [MS-DOS seems to brick the screen](./HELP.md#ms-dos-seems-to-brick-the-screen)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

20
docs/qemu.md Normal file
View File

@@ -0,0 +1,20 @@
# QEMU Instructions
The image built here was made with QEMU. In this doc, I'm keeping instructions
around.
Disk image creation
```sh
qemu-img create -f qcow2 win95.qcow2 1G
```
Installation
```sh
qemu-system-i386 -netdev user,id=mynet0 -device ne2k_isa,netdev=mynet0 -hda win95.qcow2 -soundhw sb16 -m 128 -cpu pentium -device cirrus-vga,vgamem_mb=64 -fda boot_floppy.img -cdrom Win95_OSR25.iso -boot a -soundhw pcspk
```
Running
```sh
qemu-system-i386 -netdev user,id=mynet0 -device ne2k_isa,netdev=mynet0 -drive file=win95.img,format=raw,index=0,media=disk -soundhw sb16 -m 128 -cpu pentium -device cirrus-vga,vgamem_mb=16 -soundhw pcspk -cdrom Win95_OSR25.iso
```

View File

@@ -22,7 +22,7 @@
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0",
"fs-extra": "^9.0.1",
"fs-extra": "^10.1.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"tslib": "^2.3.1",
@@ -42,11 +42,10 @@
"@types/react-dom": "^17.0.0",
"electron": "18.1.0",
"less": "^3.13.0",
"node-abi": "^2.19.3",
"node-abi": "^3.15.0",
"parcel-bundler": "^1.12.5",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
"standard": "^16.0.4",
"typescript": "^4.6.3"
}
}

View File

@@ -18,10 +18,9 @@ export function getOrCreateWindow(): BrowserWindow {
},
});
mainWindow.webContents.toggleDevTools();
// mainWindow.webContents.toggleDevTools();
mainWindow.loadFile("./dist/static/index.html");
mainWindow.on("closed", () => {
mainWindow = null;
});

View File

@@ -85,7 +85,7 @@ export class EmulatorInfo extends React.Component<
}
// TypeScript think's we're using a Node.js setInterval. We're not.
this.cpuInterval = (setInterval(this.cpuCount, 500) as unknown) as number;
this.cpuInterval = setInterval(this.cpuCount, 500) as unknown as number;
// Disk
emulator.add_listener("ide-read-start", this.onIDEReadStart);

View File

@@ -272,26 +272,29 @@ export class Emulator extends React.Component<{}, EmulatorState> {
private async startEmulator() {
document.body.classList.remove("paused");
const imageSize = await getDiskImageSize();
console.log(__dirname)
const options = {
wasm_path: path.join(__dirname, "build/v86.wasm"),
memory_size: 128 * 1024 * 1024,
video_memory_size: 32 * 1024 * 1024,
vga_memory_size: 32 * 1024 * 1024,
screen_container: document.getElementById("emulator"),
bios: {
url: "../../bios/seabios.bin",
url: path.join(__dirname, "../../bios/seabios.bin"),
},
vga_bios: {
url: "../../bios/vgabios.bin",
url: path.join(__dirname, "../../bios/vgabios.bin"),
},
hda: {
url: "../../images/windows95.img",
url: CONSTANTS.IMAGE_PATH,
async: true,
size: imageSize,
size: await getDiskImageSize(),
},
fda: {
buffer: this.state.floppyFile,
},
boot_order: 0x132,
// network_relay_url: "ws://localhost:8080/"
};
console.log(`🚜 Starting emulator with options`, options);

View File

@@ -1,4 +1,4 @@
Copyright (c) 2012-2018, Fabian Hemmer
Copyright (c) 2012, The v86 contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -19,8 +19,4 @@ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

7219
src/renderer/lib/_capstone-x86.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../src/less/vendor/95css.css">
<link rel="stylesheet" href="../src/less/root.less">
<script src="../src/renderer/lib/libv86.js"></script>
<!-- libv86 -->
</head>
<body class="paused windows95">
<div id="app"></div>

View File

@@ -2,6 +2,27 @@
const Bundler = require('parcel-bundler')
const path = require('path')
const fs = require('fs-extra')
async function copyLib() {
const target = path.join(__dirname, '../dist/static')
const lib = path.join(__dirname, '../src/renderer/lib')
const index = path.join(target, 'index.html')
// Copy in lib
await fs.copy(lib, target)
// Patch so that fs.read is used
const libv86path = path.join(target, 'libv86.js')
const libv86 = fs.readFileSync(libv86path, 'utf-8')
const patchedLibv86 = libv86.replace('v86util.load_file="undefined"===typeof XMLHttpRequest', 'v86util.load_file="undefined"!==typeof XMLHttpRequest')
fs.writeFileSync(libv86path, patchedLibv86)
// Overwrite
const indexContents = fs.readFileSync(index, 'utf-8');
const replacedContents = indexContents.replace('<!-- libv86 -->', '<script src="libv86.js"></script>')
fs.writeFileSync(index, replacedContents)
}
async function compileParcel (options = {}) {
const entryFiles = [
@@ -38,8 +59,12 @@ async function compileParcel (options = {}) {
// Run the bundler, this returns the main bundle
// Use the events if you're using watch mode as this promise will only trigger once and not for every rebuild
await bundler.bundle()
await copyLib();
}
module.exports = {
compileParcel
}

981
yarn.lock

File diff suppressed because it is too large Load Diff