- FreeDOS: https://www.freedos.org/
- MagiDuck: https://www.indiedb.com/games/magiduck
- SCC (Small C Compiler for DOS): https://github.com/mras0/scc
- GNU chcp: https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/repositories/1.3/pkg-html/gnuchcp.html
- GNU chcp fonts: https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/repositories/1.3/pkg-html/gnufonts.html
- Fontraption: https://github.com/viler-int10h/Fontraption
- TinyASM: https://github.com/nanochess/tinyasm
- CPI files: https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/repositories/1.3/pkg-html/cpidos.html
-
-
Save SuperMaxusa/7c8329c3f9e41db5114d57046870de03 to your computer and use it in GitHub Desktop.
v86 - Plane 2 Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<script src="libv86.js"></script> | |
<script> | |
"use strict"; | |
var glyph_w = 8; // px | |
var glyph_h = 16; // px | |
function dumpPlane() { | |
const plane2 = new Blob([window.emulator.v86.cpu.devices.vga.plane2]); | |
// from examples/arch.html | |
var a = document.createElement("a"); | |
a.download = "dump.bin"; | |
a.href = window.URL.createObjectURL(plane2); | |
a.dataset.downloadurl = "application/octet-stream:" + a.download + ":" + a.href; | |
a.click(); | |
} | |
function makeTile(bitmap) { | |
const tile = new Uint8ClampedArray(glyph_w * glyph_h * 4); | |
let row = 0, px = 0; | |
while (px < tile.length) { | |
for(let bit = 7; bit >= 0; bit--) { | |
// if the current bit is not background | |
if(((bitmap[row] >> bit) & 1) === 0) { | |
tile[px] = 0; // R | |
tile[px + 1] = 0; // G | |
tile[px + 2] = 0; // B | |
// if the current bit is background | |
} else { | |
tile[px] = 255; // R | |
tile[px + 1] = 255; // G | |
tile[px + 2] = 255; // B | |
}; | |
tile[px + 3] = 255; // A | |
px += 4; | |
}; | |
row += 1; | |
}; | |
return new ImageData(tile, glyph_w, glyph_h); | |
} | |
function displayFont() { | |
const font = window.emulator.v86.cpu.devices.vga.plane2.subarray(0, 512 * 16); | |
const canvas = document.getElementById("fontcanvas"); | |
const ctx = canvas.getContext("2d", { alpha: false }); | |
const tiles = []; | |
// make tiles from VGA bitmaps | |
for(let i = 0; i < font.length; i += glyph_h) { | |
let offset = font.subarray(i, i + glyph_h); | |
tiles.push(makeTile(offset)); | |
}; | |
let x = 0, y = 0; | |
ctx.clearRect(0, 0, canvas.width, canvas.height); | |
for(const tile of tiles) { | |
if(x + glyph_w > canvas.width) { | |
// go to next row | |
x = 0; | |
y += glyph_h; | |
} | |
// draw a char tile | |
ctx.putImageData(tile, x, y); | |
x += glyph_w; | |
}; | |
} | |
window.onload = function() | |
{ | |
var emulator = window.emulator = new V86({ | |
wasm_path: "v86.wasm", | |
memory_size: 16 * 1024 * 1024, | |
vga_memory_size: 2 * 1024 * 1024, | |
screen_container: document.getElementById("screen_container"), | |
bios: { | |
url: "seabios.bin" | |
}, | |
vga_bios: { | |
url: "vgabios.bin" | |
}, | |
fda: { | |
url: "freedos13.img" | |
}, | |
autostart: true, | |
}); | |
emulator.add_listener("emulator-started", function() { | |
setInterval(displayFont, 1000) | |
}); | |
} | |
</script> | |
<div id="screen_container"> | |
<div style="white-space: pre; font: 14px monospace; line-height: 14px"></div> | |
<canvas style="display: none"></canvas> | |
</div> | |
<br /> | |
<button onclick="dumpPlane()"> Dump plane 2 to .bin file</button> | |
<br /> | |
<canvas id="fontcanvas" width="512" height="128"></canvas> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/vga.js b/src/vga.js | |
index 8e746f9..28d1122 100644 | |
--- a/src/vga.js | |
+++ b/src/vga.js | |
@@ -677,7 +677,7 @@ VGAScreen.prototype.vga_memory_write = function(addr, value) | |
{ | |
if(!(this.plane_write_bm & 0x3)) | |
{ | |
- // Ignore writes to font planes. | |
+ this.plane2[addr] = value; | |
return; | |
} | |
this.vga_memory_write_text_mode(addr, value); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment