GA20: acquireDirect optimizations, part 1
buggy, slow and glitchy output is good but chan osc is now broken from 1.5 to 0.4 seconds
This commit is contained in:
parent
2c75555fae
commit
8f54445625
|
@ -52,39 +52,23 @@ inline void DivPlatformGA20::chWrite(unsigned char ch, unsigned int addr, unsign
|
|||
}
|
||||
|
||||
void DivPlatformGA20::acquire(short** buf, size_t len) {
|
||||
if (ga20BufLen<len) {
|
||||
ga20BufLen=len;
|
||||
for (int i=0; i<4; i++) {
|
||||
delete[] ga20Buf[i];
|
||||
ga20Buf[i]=new short[ga20BufLen];
|
||||
}
|
||||
}
|
||||
thread_local short ga20Buf[4];
|
||||
|
||||
for (int i=0; i<4; 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();
|
||||
ga20.write(w.addr,w.val);
|
||||
regPool[w.addr]=w.val;
|
||||
writes.pop();
|
||||
delay=1;
|
||||
}
|
||||
}
|
||||
short *buffer[4]={
|
||||
&ga20Buf[0][h],
|
||||
&ga20Buf[1][h],
|
||||
&ga20Buf[2][h],
|
||||
&ga20Buf[3][h]
|
||||
};
|
||||
ga20.sound_stream_update(buffer,1);
|
||||
buf[0][h]=(signed int)(ga20Buf[0][h]+ga20Buf[1][h]+ga20Buf[2][h]+ga20Buf[3][h])>>2;
|
||||
ga20.sound_stream_update(ga20Buf,1);
|
||||
buf[0][h]=(signed int)(ga20Buf[0]+ga20Buf[1]+ga20Buf[2]+ga20Buf[3])>>2;
|
||||
for (int i=0; i<4; i++) {
|
||||
oscBuf[i]->putSample(h,ga20Buf[i][h]>>1);
|
||||
oscBuf[i]->putSample(h,ga20Buf[i]>>1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,43 +78,42 @@ void DivPlatformGA20::acquire(short** buf, size_t len) {
|
|||
}
|
||||
|
||||
void DivPlatformGA20::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) {
|
||||
if (ga20BufLen<len) {
|
||||
ga20BufLen=len;
|
||||
for (int i=0; i<4; i++) {
|
||||
delete[] ga20Buf[i];
|
||||
ga20Buf[i]=new short[ga20BufLen];
|
||||
}
|
||||
}
|
||||
thread_local short ga20Buf[4];
|
||||
|
||||
for (int i=0; i<4; i++) {
|
||||
oscBuf[i]->begin(len);
|
||||
}
|
||||
|
||||
for (size_t h=off; h<off+len; h++) {
|
||||
if ((--delay)<=0) {
|
||||
delay=MAX(0,delay);
|
||||
size_t advance=0;
|
||||
if (!writes.empty()) {
|
||||
QueuedWrite& w=writes.front();
|
||||
ga20.write(w.addr,w.val);
|
||||
regPool[w.addr]=w.val;
|
||||
writes.pop();
|
||||
delay=1;
|
||||
} else {
|
||||
// heuristic
|
||||
advance=off+len-h-1;
|
||||
|
||||
for (int i=0; i<4; i++) {
|
||||
if (!ga20.m_channel[i].play) continue;
|
||||
if (ga20.m_channel[i].hot) {
|
||||
advance=0;
|
||||
break;
|
||||
}
|
||||
const size_t newAdvance=ga20.m_channel[i].counter-ga20.m_channel[i].rate-1;
|
||||
if (newAdvance<advance) advance=newAdvance;
|
||||
}
|
||||
}
|
||||
short *buffer[4]={
|
||||
&ga20Buf[0][h],
|
||||
&ga20Buf[1][h],
|
||||
&ga20Buf[2][h],
|
||||
&ga20Buf[3][h]
|
||||
};
|
||||
ga20.sound_stream_update(buffer,1);
|
||||
const int out=(signed int)(ga20Buf[0][h]+ga20Buf[1][h]+ga20Buf[2][h]+ga20Buf[3][h])>>2;
|
||||
ga20.sound_stream_update(ga20Buf,advance+1);
|
||||
h+=advance;
|
||||
const int out=(signed int)(ga20Buf[0]+ga20Buf[1]+ga20Buf[2]+ga20Buf[3])>>2;
|
||||
if (out!=oldOut) {
|
||||
blip_add_delta(bb[0],h,out-oldOut);
|
||||
oldOut=out;
|
||||
}
|
||||
for (int i=0; i<4; i++) {
|
||||
oscBuf[i]->putSample(h,ga20Buf[i][h]>>1);
|
||||
oscBuf[i]->putSample(h,ga20Buf[i]>>1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -420,7 +403,6 @@ void DivPlatformGA20::reset() {
|
|||
writes.clear();
|
||||
memset(regPool,0,32);
|
||||
ga20.device_reset();
|
||||
delay=0;
|
||||
oldOut=0;
|
||||
for (int i=0; i<4; i++) {
|
||||
chan[i]=DivPlatformGA20::Channel();
|
||||
|
@ -561,7 +543,6 @@ int DivPlatformGA20::init(DivEngine* p, int channels, int sugRate, const DivConf
|
|||
}
|
||||
sampleMem=new unsigned char[getSampleMemCapacity()];
|
||||
sampleMemLen=0;
|
||||
delay=0;
|
||||
setFlags(flags);
|
||||
ga20BufLen=65536;
|
||||
for (int i=0; i<4; i++) ga20Buf[i]=new short[ga20BufLen];
|
||||
|
|
|
@ -58,7 +58,6 @@ class DivPlatformGA20: public DivDispatch, public iremga20_intf {
|
|||
unsigned int sampleOffGA20[256];
|
||||
bool sampleLoaded[256];
|
||||
|
||||
int delay;
|
||||
int oldOut;
|
||||
|
||||
short* ga20Buf[4];
|
||||
|
|
|
@ -89,9 +89,7 @@ void iremga20_device::device_reset()
|
|||
// sound_stream_update - handle a stream update
|
||||
//-------------------------------------------------
|
||||
|
||||
void iremga20_device::sound_stream_update(short** outputs, int len)
|
||||
{
|
||||
for (int i = 0; i < len; i++)
|
||||
void iremga20_device::sound_stream_update(short* outputs, int len)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
|
@ -106,7 +104,7 @@ void iremga20_device::sound_stream_update(short** outputs, int len)
|
|||
ch.hot=false;
|
||||
ch.output = ch.mute ? 0 : (ch.sample - 0x80) * (s32)ch.volume;
|
||||
}
|
||||
ch.counter--;
|
||||
ch.counter-=len;
|
||||
if (ch.counter <= ch.rate)
|
||||
{
|
||||
ch.pos++;
|
||||
|
@ -116,8 +114,7 @@ void iremga20_device::sound_stream_update(short** outputs, int len)
|
|||
}
|
||||
}
|
||||
}
|
||||
outputs[j][i] = ch.output;
|
||||
}
|
||||
outputs[j] = ch.output;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
DISCLAIMER
|
||||
- This file is modified for suitable in furnace.
|
||||
- modified by cam900
|
||||
- modified by cam900 and tildearrow
|
||||
|
||||
*********************************************************/
|
||||
#ifndef MAME_SOUND_IREMGA20_H
|
||||
|
@ -50,10 +50,9 @@ public:
|
|||
void device_reset();
|
||||
|
||||
// sound stream update overrides
|
||||
void sound_stream_update(short** outputs, int len);
|
||||
void sound_stream_update(short* outputs, int len);
|
||||
|
||||
|
||||
private:
|
||||
struct channel_def
|
||||
{
|
||||
channel_def() :
|
||||
|
|
|
@ -521,7 +521,6 @@ void putDispatchChip(void* data, int type) {
|
|||
DivPlatformGA20* ch=(DivPlatformGA20*)data;
|
||||
ImGui::Text("> GA20");
|
||||
COMMON_CHIP_DEBUG;
|
||||
ImGui::Text("- delay: %.2x",ch->delay);
|
||||
COMMON_CHIP_DEBUG_BOOL;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue