Skip to content

Commit

Permalink
Add basic support for reading states
Browse files Browse the repository at this point in the history
  • Loading branch information
endrift committed Apr 3, 2013
1 parent 8cc8a3e commit ae597ba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions js/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ GameBoyAdvanceIO.prototype.loadU16 = function(offset) {
case this.SIOMULTI1:
case this.SIOMULTI2:
case this.SIOMULTI3:
return this.sio.read((offset - this.SIOMULTI0) >> 1);

case this.SIODATA8:
this.core.STUB('Unimplemented SIO register read: 0x' + offset.toString(16));
return 0;
Expand Down
23 changes: 21 additions & 2 deletions js/sio.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ GameBoyAdvanceSIO.prototype.clear = function() {
si: 0,
id: 0,
error: 0,
busy: 0
busy: 0,

states: [ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF ]
};

this.linkLayer = null;
Expand Down Expand Up @@ -107,4 +109,21 @@ GameBoyAdvanceSIO.prototype.readSIOCNT = function() {
break;
}
return value;
}
};

GameBoyAdvanceSIO.prototype.read = function(slot) {
switch (this.mode) {
case this.SIO_NORMAL_32:
this.core.STUB('32-bit transfer unsupported');
break;
case this.SIO_MULTI:
return this.multiplayer.states[slot];
case this.SIO_UART:
this.core.STUB('UART unsupported');
break;
default:
this.core.WARN('Reading from transfer register in unsupported mode');
break;
}
return 0;
};

0 comments on commit ae597ba

Please sign in to comment.