Skip to content

Commit

Permalink
Update emulator.js
Browse files Browse the repository at this point in the history
  • Loading branch information
zHoeshin authored Dec 26, 2023
1 parent ce92378 commit c61b19c
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions emulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ class Screen{
this.canvas.drawImage(this.img, imgX, imgY, this.img.width / 16, this.img.height / 16, x*charwidth, y*charheight, charwidth, charheight)
}else{
let rawdata = new Array()
let c = 4*(imgX + imgY*this.img.width)
let cond = (this.img.width**2 / 16 + this.img.height)*4
for(let i = 0; i < cond; i+=4){
rawdata.push(this.imgdata[c + i] & clr[0])
rawdata.push(this.imgdata[c + 1 + i] & clr[1])
rawdata.push(this.imgdata[c + 2 + i] & clr[2])
rawdata.push(this.imgdata[c + 3 + i] & clr[3])
for(let i = 0; i < this.img.width / 16; i++){
for(let j = 0; j < this.img.height / 16; j++){
let c = 4*(imgX + imgY*this.img.width) + (j + i*this.img.width)*4
rawdata.push(this.imgdata[c] & clr[0])
rawdata.push(this.imgdata[c + 1] & clr[1])
rawdata.push(this.imgdata[c + 2] & clr[2])
rawdata.push(this.imgdata[c + 3] & clr[3])
}
}
console.log(c, cond, rawdata);
let imgdatanew = new ImageData(new Uint8ClampedArray(rawdata), this.img.width / 16, this.img.height / 16)
this.tctx.putImageData(imgdatanew, 0, 0)

Expand Down Expand Up @@ -179,13 +179,14 @@ class Screen{
this.canvas.drawImage(this.img, imgX, imgY, this.img.width / 16, this.img.height / 16, x*charwidth, y*charheight, charwidth, charheight)
}else{
let rawdata = new Array()
let c = 4*(imgX + imgY*this.img.width)
let cond = (this.img.width**2 / 16 + this.img.height)*4
for(let i = 0; i < cond; i+=4){
rawdata.push(this.imgdata[c + i] & clr[0])
rawdata.push(this.imgdata[c + 1 + i] & clr[1])
rawdata.push(this.imgdata[c + 2 + i] & clr[2])
rawdata.push(this.imgdata[c + 3 + i] & clr[3])
for(let i = 0; i < this.img.width / 16; i++){
for(let j = 0; j < this.img.height / 16; j++){
let c = 4*(imgX + imgY*this.img.width) + (j + i*this.img.width)*4
rawdata.push(this.imgdata[c] & clr[0])
rawdata.push(this.imgdata[c + 1] & clr[1])
rawdata.push(this.imgdata[c + 2] & clr[2])
rawdata.push(this.imgdata[c + 3] & clr[3])
}
}
let imgdatanew = new ImageData(new Uint8ClampedArray(rawdata), this.img.width / 16, this.img.height / 16)
this.tctx.putImageData(imgdatanew, 0, 0)
Expand Down

0 comments on commit c61b19c

Please sign in to comment.