diff --git a/images/battle-chess.png b/images/battle-chess.png new file mode 100644 index 0000000..eacb2a1 Binary files /dev/null and b/images/battle-chess.png differ diff --git a/index.html b/index.html index 0226e1f..c173778 100644 --- a/index.html +++ b/index.html @@ -176,6 +176,7 @@ async function setupScreenView() { const image = await screenEmu.loadImage("images/airheart-560x192.png"); + // const image = await screenEmu.loadImage("images/battle-chess.png"); const [imageCanvas, imageData] = screenEmu.screenData(image, screenEmu.C.NTSC_DETAILS); let canvas = document.getElementById("d"); diff --git a/screenEmu.js b/screenEmu.js index dcc7db1..d069d89 100644 --- a/screenEmu.js +++ b/screenEmu.js @@ -487,7 +487,7 @@ void main(void) // image: a 560x192 image, from the same domain (hence readable). // details: NTSC_DETAILS, or PAL_DETAILS // returns: a canvas - const screenData = (image, details) => { + const screenData = (image, details, dhgr=true) => { if ((image.naturalWidth != 560) || (image.naturalHeight != 192)) { throw new Error('screenData expects an image 560x192;' + ` got ${image.naturalWidth}x${image.naturalHeight}`); @@ -500,7 +500,8 @@ void main(void) canvas.height = height; context.fillStyle = 'rgba(0,0,0,1)'; context.fillRect(0, 0, width, height); - context.drawImage(image, details.topLeft80Col.x, details.topLeft80Col.y); + const topLeft = dhgr ? details.topLeft80Col : details.topLeft; + context.drawImage(image, topLeft.x, topLeft.y); const imageData = context.getImageData(0, 0, width, height); return [canvas, imageData]; };