Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Sending the PPU now works.

  • Loading branch information...
commit a99b49d514946c5dfc249618fbefee809cb5702b 1 parent ab43a75
@daicoden daicoden authored
View
4 public/js/joynes.js
@@ -6,8 +6,8 @@ joynes = {
return this;
},
- Slave : function(socket) {
- this.initialize(socket);
+ Slave : function(nes, socket) {
+ this.initialize(nes, socket);
return this;
}
};
View
6 public/js/joynes/master.js
@@ -9,6 +9,7 @@ joynes.Master.prototype = {
this.nes.ui.romSelect.unbind('change');
this.nes.ui.romSelect.bind('change', function(){
self.loadRom(self.nes.ui.romSelect.val());
+ self.socket.send(JSON.stringify(self.nes.ui.prevBuffer));
});
this.socket.on("message", function(evt){
@@ -17,16 +18,17 @@ joynes.Master.prototype = {
if(data.key) { self.nes.keyboard.setKey(data.key, data.value) }
if(data.ok) {
self.calculateFrameRate();
- self.socket.send(self.nes.ui.prevBuffer);
+ self.socket.send(JSON.stringify(self.nes.ui.prevBuffer));
}
- }
+ });
},
setFrameRate: function(rate){
this.nes.setFramerate(rate);
},
calculateFrameRate: function() {
var now = Date.now();
+ var self = this;
if(!self.lastSendTime) { self.lastSendTime = now; }
else {
var frameRate = 1/(now - self.lastSendTime) * 1000;
View
7 public/js/joynes/slave.js
@@ -5,11 +5,12 @@ joynes.Slave.prototype = {
this.socket = socket;
this.socket.on("connection", function(evt){
self.socket.send(JSON.stringify({ok: 1}));
- }
+ });
+
this.socket.on("message", function(evt){
- self.nes.ui.writeFrame(evt.data)
+ self.nes.ui.writeFrame(JSON.parse(evt));
self.socket.send(JSON.stringify({ok: 1}));
- };
+ });
/* TODO: we should only preventDefault for non-controller keys. */
$(document).
View
5 views/index.ejs
@@ -20,8 +20,9 @@
var message = JSON.parse(evt);
if (message.initialize) {
switch (message.initialize) {
- case 'm': joynesClient = new joynes.Master(emulator, socket);
- case 's': joynesClient = new joynes.Slave(emulator, socket);
+ case 'm': joynesClient = new joynes.Master(emulator, socket); break;
+ case 's': joynesClient = new joynes.Slave(emulator, socket); break;
+ default: alert("something's wrong");
}
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.