K007232: acquireDirect()
This commit is contained in:
parent
804e8b7fb8
commit
85981822fa
4 changed files with 66 additions and 44 deletions
|
|
@ -54,49 +54,67 @@ inline void DivPlatformK007232::chWrite(unsigned char ch, unsigned int addr, uns
|
|||
}
|
||||
}
|
||||
|
||||
void DivPlatformK007232::acquire(short** buf, size_t len) {
|
||||
void DivPlatformK007232::acquireDirect(blip_buffer_t** bb, size_t len) {
|
||||
for (int i=0; i<2; i++) {
|
||||
oscBuf[i]->begin(len);
|
||||
}
|
||||
|
||||
for (size_t h=0; h<len; h++) {
|
||||
if ((--delay)<=0) {
|
||||
delay=MAX(0,delay);
|
||||
if (!writes.empty()) {
|
||||
QueuedWrite& w=writes.front();
|
||||
// write on-chip register
|
||||
if (w.addr<=0xd) {
|
||||
k007232.write(w.addr,w.val);
|
||||
}
|
||||
regPool[w.addr]=w.val;
|
||||
writes.pop();
|
||||
delay=w.delay;
|
||||
int advance=len-h;
|
||||
if (!writes.empty()) {
|
||||
advance=1;
|
||||
QueuedWrite& w=writes.front();
|
||||
// write on-chip register
|
||||
if (w.addr<=0xd) {
|
||||
k007232.write(w.addr,w.val);
|
||||
}
|
||||
regPool[w.addr]=w.val;
|
||||
writes.pop();
|
||||
} else {
|
||||
for (int i=0; i<2; i++) {
|
||||
if (k007232.m_voice[i].m_busy) {
|
||||
const int remain=4096-k007232.m_voice[i].m_counter;
|
||||
if (remain<advance) advance=remain;
|
||||
}
|
||||
}
|
||||
if (advance<1) advance=1;
|
||||
}
|
||||
|
||||
k007232.tick();
|
||||
k007232.tick(advance);
|
||||
|
||||
h+=advance-1;
|
||||
|
||||
if (stereo) {
|
||||
const unsigned char vol1=regPool[0x10],vol2=regPool[0x11];
|
||||
const signed int lout[2]={(k007232.output(0)*(vol1&0xf)),(k007232.output(1)*(vol2&0xf))};
|
||||
const signed int rout[2]={(k007232.output(0)*((vol1>>4)&0xf)),(k007232.output(1)*((vol2>>4)&0xf))};
|
||||
buf[0][h]=(lout[0]+lout[1])<<4;
|
||||
buf[1][h]=(rout[0]+rout[1])<<4;
|
||||
if (++oscDivider>=8) {
|
||||
oscDivider=0;
|
||||
for (int i=0; i<2; i++) {
|
||||
oscBuf[i]->putSample(h,(lout[i]+rout[i])<<3);
|
||||
}
|
||||
const int outL=(lout[0]+lout[1])<<4;
|
||||
const int outR=(rout[0]+rout[1])<<4;
|
||||
|
||||
if (outL!=lastOut[0]) {
|
||||
blip_add_delta(bb[0],h,outL-lastOut[0]);
|
||||
lastOut[0]=outL;
|
||||
}
|
||||
if (outR!=lastOut[1]) {
|
||||
blip_add_delta(bb[1],h,outR-lastOut[1]);
|
||||
lastOut[1]=outR;
|
||||
}
|
||||
|
||||
for (int i=0; i<2; i++) {
|
||||
oscBuf[i]->putSample(h,(lout[i]+rout[i])<<3);
|
||||
}
|
||||
} else {
|
||||
const unsigned char vol=regPool[0xc];
|
||||
const signed int out[2]={(k007232.output(0)*(vol&0xf)),(k007232.output(1)*((vol>>4)&0xf))};
|
||||
buf[0][h]=(out[0]+out[1])<<4;
|
||||
if (++oscDivider>=8) {
|
||||
oscDivider=0;
|
||||
for (int i=0; i<2; i++) {
|
||||
oscBuf[i]->putSample(h,out[i]<<4);
|
||||
}
|
||||
const int outFinal=(out[0]+out[1])<<4;
|
||||
|
||||
if (outFinal!=lastOut[0]) {
|
||||
blip_add_delta(bb[0],h,outFinal-lastOut[0]);
|
||||
lastOut[0]=outFinal;
|
||||
}
|
||||
|
||||
for (int i=0; i<2; i++) {
|
||||
oscBuf[i]->putSample(h,out[i]<<4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -456,7 +474,8 @@ void DivPlatformK007232::reset() {
|
|||
k007232.reset();
|
||||
lastLoop=0;
|
||||
lastVolume=0;
|
||||
delay=0;
|
||||
lastOut[0]=0;
|
||||
lastOut[1]=0;
|
||||
for (int i=0; i<2; i++) {
|
||||
chan[i]=DivPlatformK007232::Channel();
|
||||
chan[i].std.setEngine(parent);
|
||||
|
|
@ -474,6 +493,10 @@ int DivPlatformK007232::getOutputCount() {
|
|||
return stereo?2:1;
|
||||
}
|
||||
|
||||
bool DivPlatformK007232::hasAcquireDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void DivPlatformK007232::notifyInsChange(int ins) {
|
||||
for (int i=0; i<2; i++) {
|
||||
if (chan[i].ins==ins) {
|
||||
|
|
@ -601,7 +624,6 @@ int DivPlatformK007232::init(DivEngine* p, int channels, int sugRate, const DivC
|
|||
}
|
||||
sampleMem=new unsigned char[getSampleMemCapacity()];
|
||||
sampleMemLen=0;
|
||||
oscDivider=0;
|
||||
setFlags(flags);
|
||||
reset();
|
||||
|
||||
|
|
|
|||
|
|
@ -52,16 +52,15 @@ class DivPlatformK007232: public DivDispatch, public k007232_intf {
|
|||
};
|
||||
Channel chan[2];
|
||||
DivDispatchOscBuffer* oscBuf[2];
|
||||
int lastOut[2];
|
||||
bool isMuted[2];
|
||||
struct QueuedWrite {
|
||||
unsigned short addr;
|
||||
unsigned char val;
|
||||
unsigned short delay;
|
||||
QueuedWrite(): addr(0), val(0), delay(1) {}
|
||||
QueuedWrite(unsigned short a, unsigned char v, unsigned short d=1):
|
||||
QueuedWrite(): addr(0), val(0) {}
|
||||
QueuedWrite(unsigned short a, unsigned char v):
|
||||
addr(a),
|
||||
val(v),
|
||||
delay(d) {}
|
||||
val(v) {}
|
||||
};
|
||||
FixedQueue<QueuedWrite,256> writes;
|
||||
unsigned int sampleOffK007232[256];
|
||||
|
|
@ -82,7 +81,7 @@ class DivPlatformK007232: public DivDispatch, public k007232_intf {
|
|||
void chWrite(unsigned char ch, unsigned int addr, unsigned char val);
|
||||
public:
|
||||
u8 read_sample(u8 ne, u32 address);
|
||||
void acquire(short** buf, size_t len);
|
||||
void acquireDirect(blip_buffer_t** bb, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivMacroInt* getChanMacroInt(int ch);
|
||||
|
|
@ -95,6 +94,7 @@ class DivPlatformK007232: public DivDispatch, public k007232_intf {
|
|||
void tick(bool sysTick=true);
|
||||
void muteChannel(int ch, bool mute);
|
||||
int getOutputCount();
|
||||
bool hasAcquireDirect();
|
||||
void notifyInsChange(int ins);
|
||||
void notifyWaveChange(int wave);
|
||||
void notifyInsDeletion(void* ins);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue