-
Notifications
You must be signed in to change notification settings - Fork 0
/
AY38910.js
77 lines (67 loc) · 1.87 KB
/
AY38910.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* jsMC1000 - MC-1000 emulator in JavaScript.
* Emerson Jose Silveira da Costa <emerson.costa@gmail.com>, alias "Ensjo".
* http://ensjo.net/mc-1000/jsmc1000
*/
/**
* AY38910 class.
* 2012-06-19.
*
* "AY38910" class extends the "PsgDeviceChannel" class from
* Takashi Toyoshima's T'SoundSystem -- http://code.google.com/p/tss/
* adding functionality corresponding to ports IOA and IOB of AY-3-8910,
* currently absent in "PsgDeviceChannel".
*
* "Log", "AudioLooper", "BiquadFilterChannel" and "MasterChannel"
* classes from TSS are also required.
*/
function AY38910(delegate) {
PsgDeviceChannel.call(this); // Superclass' constructor.
this.delegate = delegate;
this.ioa = 0;
this.iob = 0;
this.selectedRegister = 0;
}
AY38910.prototype = new PsgDeviceChannel();
AY38910.prototype.constructor = AY38910;
AY38910.prototype.selectRegister = function(data) {
if (data < 16) {
this.selectedRegister = data;
}
};
AY38910.prototype.getRegister = function() {
switch (this.selectedRegister) {
case 14:
return this.ioa = this.delegate.ay38910GetIoa();
break;
case 15:
return this.iob = this.delegate.ay38910GetIob();
break;
default:
return this.readRegister(this.selectedRegister); // from PsgDeviceChannel class.
}
};
AY38910.prototype.setRegister = function(data) {
switch (this.selectedRegister) {
case 14:
this.delegate.ay38910SetIoa(this.ioa = data);
break;
case 15:
this.delegate.ay38910SetIob(this.iob = data);
break;
default:
this.writeRegister(this.selectedRegister, data); // from PsgDeviceChannel class.
}
};
AY38910.prototype.getIoa = function() {
return this.ioa;
};
AY38910.prototype.setIoa = function(data) {
this.ioa = data;
};
AY38910.prototype.getIob = function() {
return this.iob;
};
AY38910.prototype.setIob = function(data) {
this.iob = data;
};