// -------------------------------------------------
// ---------------- Framebuffer --------------------
// -------------------------------------------------

// constructor
function Framebuffer(elemId) {
    var element = document.getElementById(elemId);
    this.c = element.getContext("2d");
    // read the width and height of the canvas
    this.width = element.width;
    this.height = element.height;
    // create a new batch of pixels with the same
    // dimensions as the image:
    this.imageData = this.c.createImageData(this.width, this.height);
}

Framebuffer.prototype.SetAddr = function(addr) {
    this.buf8 = new Uint8ClampedArray(ram.mem, addr, this.imageData.data.length);
    this.Update();
};

Framebuffer.prototype.Update = function() {
    if (!this.buf8) {
        return;
    }
    // copy the image data back onto the canvas
    for (var i = 3; i < this.width * this.height * 4; i += 4) {
        this.buf8[i] = 0xFF;
    }

    this.imageData.data.set(this.buf8);
    this.c.putImageData(this.imageData, 0, 0); // at coords 0,0
    // hack, because this.Update does not work
    window.setTimeout(function() {
        fb.Update();
    }, 500); // update every half a second
};

@@ -803,55 +803,74 @@
   %7D%0A
-    // copy the image data back onto the canvas
+%09%0A%09// remove alpha channel. The buffer can then be used directly.%09
 %0A   
@@ -1074,55 +1074,8 @@
 0,0%0A
-    // hack, because this.Update does not work%0A
     
@@ -1104,24 +1104,16 @@
 tion() %7B
-%0A       
  fb.Upda
@@ -1117,20 +1117,16 @@
 pdate();
-%0A   
  %7D, 500)

correct framebuffer comments