YM2608-LLE, part 7

thanks nukeykt for the memory code!
also ADPCM is very, very loud...
This commit is contained in:
tildearrow 2024-04-27 02:23:46 -05:00
parent 7a55ff48fe
commit f12e7cf7b0
2 changed files with 28 additions and 14 deletions

View file

@ -532,13 +532,6 @@ void DivPlatformYM2608::acquire_lle(short** buf, size_t len) {
fm_lle.input.a0=1;
fm_lle.input.data=w.val;
// TEMPORARY: until we can determine whether volumes are actually inverted in hardware
if (w.addr==0x11) {
fm_lle.input.data=w.val^0x3f;
} else if (w.addr>=0x18 && w.addr<=0x1d) {
fm_lle.input.data=w.val^0x1f;
}
delay=2;
//logV("VAL %.2x",w.val);
@ -607,9 +600,23 @@ void DivPlatformYM2608::acquire_lle(short** buf, size_t len) {
if (have0 && have1) break;
// ADPCM data bus
if (fm_lle.o_dm!=0) {
//logV("%x",fm_lle.o_dm);
// thanks nukeykt
const int newAddr=(fm_lle.o_dm&255)|(fm_lle.o_a8<<8);
if (cas && !fm_lle.o_cas) {
adMemAddr&=~0x3fe00;
adMemAddr|=newAddr<<9;
}
if (ras && !fm_lle.o_ras) {
adMemAddr&=~0x1ff;
adMemAddr|=newAddr;
}
if (fm_lle.o_romcs==0) {
fm_lle.input.dm=adpcmBMem[adMemAddr&0x3ffff];
fm_lle.input.dt0=fm_lle.input.dm&1;
}
cas=fm_lle.o_cas;
ras=fm_lle.o_ras;
}
if (howLong!=48) {
@ -920,7 +927,7 @@ void DivPlatformYM2608::tick(bool sysTick) {
if (chan[15].pan!=(chan[15].std.panL.val&3)) {
chan[15].pan=chan[15].std.panL.val&3;
if (!isMuted[15]) {
immWrite(0x101,(isMuted[15]?0:(chan[15].pan<<6))|2);
immWrite(0x101,(isMuted[15]?0:(chan[15].pan<<6))|1);
hardResetElapsed++;
}
}
@ -1087,7 +1094,7 @@ int DivPlatformYM2608::dispatch(DivCommand c) {
int end=sampleOffB[chan[c.chan].sample]+s->lengthB-1;
immWrite(0x104,(end>>5)&0xff);
immWrite(0x105,(end>>13)&0xff);
immWrite(0x101,(isMuted[c.chan]?0:(chan[c.chan].pan<<6))|2);
immWrite(0x101,(isMuted[c.chan]?0:(chan[c.chan].pan<<6))|1);
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].note=c.value;
chan[c.chan].baseFreq=NOTE_ADPCMB(chan[c.chan].note);
@ -1119,7 +1126,7 @@ int DivPlatformYM2608::dispatch(DivCommand c) {
int end=sampleOffB[chan[c.chan].sample]+s->lengthB-1;
immWrite(0x104,(end>>5)&0xff);
immWrite(0x105,(end>>13)&0xff);
immWrite(0x101,(isMuted[c.chan]?0:(chan[c.chan].pan<<6))|2);
immWrite(0x101,(isMuted[c.chan]?0:(chan[c.chan].pan<<6))|1);
int freq=(65536.0*(double)s->rate)/((double)chipClock/144.0);
immWrite(0x109,freq&0xff);
immWrite(0x10a,(freq>>8)&0xff);
@ -1249,7 +1256,7 @@ int DivPlatformYM2608::dispatch(DivCommand c) {
chan[c.chan].pan=(c.value2>0)|((c.value>0)<<1);
}
if (c.chan>14) {
immWrite(0x101,(isMuted[c.chan]?0:(chan[c.chan].pan<<6))|2);
immWrite(0x101,(isMuted[c.chan]?0:(chan[c.chan].pan<<6))|1);
break;
}
if (c.chan>8) {
@ -1539,7 +1546,7 @@ int DivPlatformYM2608::dispatch(DivCommand c) {
void DivPlatformYM2608::muteChannel(int ch, bool mute) {
isMuted[ch]=mute;
if (ch>14) { // ADPCM-B
immWrite(0x101,(isMuted[ch]?0:(chan[ch].pan<<6))|2);
immWrite(0x101,(isMuted[ch]?0:(chan[ch].pan<<6))|1);
}
if (ch>8) { // ADPCM-A
immWrite(0x18+(ch-9),isMuted[ch]?0:((chan[ch].pan<<6)|chan[ch].outVol));
@ -1717,6 +1724,10 @@ void DivPlatformYM2608::reset() {
lastSH=false;
lastSH2=false;
lastS=false;
cas=0;
ras=0;
adReadCount=0;
adMemAddr=0;
}
lastBusy=60;

View file

@ -60,6 +60,9 @@ class DivPlatformYM2608: public DivPlatformOPN {
bool lastSH;
bool lastSH2;
bool lastS;
unsigned char cas, ras;
unsigned short adMemAddr;
int adReadCount;
unsigned char* adpcmBMem;
size_t adpcmBMemLen;