oad = function () {
    context.clearRect(0, 0, screen.width, screen.height);
    context.drawImage(img, 0, 0);
  };
}

function startPlaying(data) {
	player = parseInt(data, 10);

  if (player == 1) {
    newGame();
		$("#message").text("You are Player 1");
  }
  if (player == 2) {
    $("#message").text("You are Player 2");
  }
}

function newGame() {
	if(player == 1) {
		clearScreen();
  	createNes();
  	loadROM("/rom");
	}
}

function stopPlaying() {
  if (nes !== null) {
    nes.stop();
    nes = null;