ixel = buffer[i];
        if (pixel != prevBuffer[i]) {
            j = i*4;
            data[j] = pixel & 0xFF;
            data[j+1] = (pixel >> 8) & 0xFF;
            data[j+2] = (pixel >> 16) & 0xFF;
            prevBuffer[i] = pixel;
        }
    }
    context.putImageData(imageData, 0, 0);
    sendScreen();
  };
}

function loadROM(url) {
  $.ajax({
    url: escape(url),
    xhr: function() {
      var xhr = $.ajaxSettings.xhr();
      xhr.overrideMimeType('text/plain; charset=x-user-defined');
     