YM2608-LLE, part 9

This commit is contained in:
tildearrow 2024-04-27 18:27:50 -05:00
parent 798eac373e
commit 6129d2714a

View file

@ -510,7 +510,6 @@ void DivPlatformYM2608::acquire_lle(short** buf, size_t len) {
fm_lle.input.wr=1;
fm_lle.input.a0=0;
fm_lle.input.a1=0;
//logV("preparing a delay");
delay=0;
} else {
fm_lle.input.cs=0;
@ -519,7 +518,6 @@ void DivPlatformYM2608::acquire_lle(short** buf, size_t len) {
fm_lle.input.a0=0;
fm_lle.input.a1=0;
fm_lle.input.data=0;
//logV("preparing a read");
delay=1;
}
} else if (!writes.empty()) {
@ -534,8 +532,6 @@ void DivPlatformYM2608::acquire_lle(short** buf, size_t len) {
delay=2;
//logV("VAL %.2x",w.val);
regPool[w.addr&0x1ff]=w.val;
writes.pop_front();
} else {
@ -548,8 +544,6 @@ void DivPlatformYM2608::acquire_lle(short** buf, size_t len) {
delay=2;
//logV("ADDR %.2x =",w.addr);
w.addrOrVal=true;
}
} else {
@ -558,7 +552,6 @@ void DivPlatformYM2608::acquire_lle(short** buf, size_t len) {
fm_lle.input.wr=1;
fm_lle.input.a0=0;
fm_lle.input.a1=0;
//logV("nothing to do");
}
}
@ -568,32 +561,48 @@ void DivPlatformYM2608::acquire_lle(short** buf, size_t len) {
if (canWeWrite) {
if (delay==1) {
// check busy status here
//if (!(fm_lle.o_data&0x80)) {
if (!fm_lle.busy_cnt_en[1]) {
delay=3;
} else {
//logV("AM BUSY");
delay=0;
}
}
}
if (fm_lle.o_s && !lastS) {
dacVal>>=1;
dacVal|=(fm_lle.o_opo&1)<<23;
dacVal|=(fm_lle.o_opo&1)<<14;
howLong++;
}
if (!fm_lle.o_sh1 && lastSH) {
if (dacVal&0x2000) { // positive
int e=(dacVal>>10)&7;
int m=(dacVal>>0)&1023;
dacOut[0]=m<<e;
if (e) dacOut[0]+=512<<e;
} else { // negative
int e=((dacVal>>10)&7)^7;
int m=((dacVal>>0)&1023)^1023;
dacOut[0]=-(m<<e);
if (e) dacOut[0]-=512<<e;
}
//int e=(dacVal>>10)&7;
//int m=(dacVal>>0)&1023;
dacOut[0]=dacVal>>8;//(m<<e)>>1;
//m-=512;
have0=true;
}
if (!fm_lle.o_sh2 && lastSH2) {
//int e=(dacVal>>10)&7;
//int m=(dacVal>>0)&1023;
dacOut[1]=dacVal>>8;//(m<<e)>>1;
if (dacVal&0x2000) { // positive
int e=(dacVal>>10)&7;
int m=(dacVal>>0)&1023;
dacOut[1]=(m<<e);
if (e) dacOut[1]+=512<<e;
} else { // negative
int e=((dacVal>>10)&7)^7;
int m=((dacVal>>0)&1023)^1023;
dacOut[1]=-(m<<e);
if (e) dacOut[1]-=512<<e;
}
have1=true;
}
@ -624,19 +633,8 @@ void DivPlatformYM2608::acquire_lle(short** buf, size_t len) {
}
// DAC
int accm1=dacOut[0]-0x4000;
int accm2=dacOut[1]-0x4000;
if (accm1&0x20000) {
accm1|=0xfffc0000;
}
if (accm2&0x20000) {
accm2|=0xfffc0000;
}
//logV("%.8x %.8x",dacOut[0],dacOut[1]);
//logV("%.8x %d",accm1,howLong);
int accm1=dacOut[0];
int accm2=dacOut[1];
int outL=(accm1<<1)+fm_lle.o_analog*ssgVol*42;
int outR=(accm2<<1)+fm_lle.o_analog*ssgVol*42;