revamped pixel output draft

This commit is contained in:
Luxferre
2022-07-29 00:12:29 +03:00
parent 61018ab06d
commit c0e7afd79d
3 changed files with 29 additions and 23 deletions
+18 -1
View File
@@ -39,8 +39,25 @@ function ESOPExtensions() {
height = 48,
vramOffset = vm.videoMemOffset,
vramSize = vm.videoMemSize,
ctx = cnv.getContext('2d', {alpha: false})
ctx = cnv.getContext('2d', {alpha: false}),
xval = null, yval = null
ctx.globalAlpha = 1
//setup pixel drawing ports
function pixelHook(port, coord, prev) {
if(port === 2) xval = coord
else if(port === 3) yval = coord
if(xval !== null && yval !== null) { //both coordinates set, update the pixel
var pxlOffset = yval * width + xval,
byteOffset = pxlOffset >>> 3,
bitOffset = 7 - pxlOffset + (byteOffset << 3),
vramvalue = vm.getram(vramOffset + byteOffset, 1)[0]
vm.setram(vramOffset + byteOffset, vramvalue | (1<<bitOffset))
xval = yval = null
}
vm.setdev(port, prev) //preserve the input value
}
vm.setWriteHook(2, pixelHook) //X
vm.setWriteHook(3, pixelHook) //Y
//setup screen renderer
function renderScreen() {
var vram = vm.getram(vramOffset, vramSize),