57 config.getChildDataAsInt(
"sampleram", 512),
59 , ymf278LoadTime(getCurrentTime())
60 , ymf278BusyTime(getCurrentTime())
82 alreadyReadID =
false;
84 ymf278BusyTime = time;
85 ymf278LoadTime = time;
91 if ((port & 0xFF) < 0xC0) {
93 switch (port & 0x01) {
102 if ((3 <= opl4latch) && (opl4latch <= 6)) {
111 ymf278BusyTime = time + MEM_READ_DELAY;
113 result = ymf278->readReg(opl4latch);
120 switch (port & 0x03) {
123 result = ymf262->readStatus() |
124 readYMF278Status(time);
125 if (!alreadyReadID && getNew2()) {
134 alreadyReadID =
true;
140 result = ymf262->readReg(opl3latch);
152 if ((port & 0xFF) < 0xC0) {
154 switch (port & 0x01) {
159 result = ymf278->peekReg(opl4latch);
166 switch (port & 0x03) {
169 result = ymf262->peekStatus() |
170 readYMF278Status(time);
171 if (!alreadyReadID && getNew2()) {
177 result = ymf262->peekReg(opl3latch);
188 if ((port & 0xFF) < 0xC0) {
191 switch (port & 0x01) {
193 ymf278BusyTime = time + WAVE_REG_SELECT_DELAY;
197 if ((0x08 <= opl4latch) && (opl4latch <= 0x1F)) {
198 ymf278LoadTime = time + LOAD_DELAY;
200 if ((3 <= opl4latch) && (opl4latch <= 6)) {
205 ymf278BusyTime = time + MEM_WRITE_DELAY;
210 ymf278BusyTime = time + WAVE_REG_WRITE_DELAY;
212 ymf278->writeReg(opl4latch, value, time);
224 switch (port & 0x03) {
227 ymf278BusyTime = time + FM_REG_SELECT_DELAY;
230 opl3latch = value | 0x100;
231 ymf278BusyTime = time + FM_REG_SELECT_DELAY;
235 ymf278BusyTime = time + FM_REG_WRITE_DELAY;
236 ymf262->writeReg(opl3latch, value, time);
244 bool MSXMoonSound::getNew2()
const
246 return (ymf262->peekReg(0x105) & 0x02) != 0;
252 if (time < ymf278BusyTime) result |= 0x01;
253 if (time < ymf278LoadTime) result |= 0x02;
260 template<
typename Archive>
263 ar.template serializeBase<MSXDevice>(*this);
264 ar.serialize(
"ymf262", *ymf262);
265 ar.serialize(
"ymf278", *ymf278);
266 ar.serialize(
"opl3latch", opl3latch);
267 ar.serialize(
"opl4latch", opl4latch);
268 if (ar.versionAtLeast(version, 2)) {
269 ar.serialize(
"alreadyReadID", alreadyReadID);
271 assert(ar.isLoader());
272 alreadyReadID =
true;
275 if (ar.versionAtLeast(version, 3)) {
276 ar.serialize(
"loadTime", ymf278LoadTime);
277 ar.serialize(
"busyTime", ymf278BusyTime);
279 assert(ar.isLoader());