temporarily strip out emulation code

This commit is contained in:
tildearrow 2022-03-10 14:40:45 -05:00
parent 85b9f340a9
commit 587fecd11d

View file

@ -55,86 +55,6 @@ const char* DivPlatformVERA::getEffectName(unsigned char effect) {
}
void DivPlatformVERA::acquire(short* bufL, short* bufR, size_t start, size_t len) {
// taken from the official X16 emulator's source code, (c) 2020 Frank van den Hoef
const uint8_t volume_lut_psg[64]={0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 17, 18, 19, 21, 22, 23, 25, 26, 28, 29, 31, 33, 35, 37, 39, 42, 44, 47, 50, 52, 56, 59, 63};
const uint8_t volume_lut_pcm[16]={0, 1, 2, 3, 4, 5, 6, 8, 11, 14, 18, 23, 30, 38, 49, 64};
for (size_t pos=start; pos<start+len; pos++) {
int32_t lout=0;
int32_t rout=0;
// PSG
// TODO this is a currently speculated noise generation
// as the hardware and sources for it are not out in the public
// and the official emulator just uses rand()
noiseOut=((noiseOut<<1)|(noiseState&1))&63;
noiseState=(noiseState<<1)|(((noiseState>>1)^(noiseState>>2)^(noiseState>>4)^(noiseState>>15))&1);
for (int i=0; i<16; i++) {
unsigned freq=regPool[i*4+0] | (regPool[i*4+1] << 8);
unsigned old_accum=chan[i].accum;
unsigned new_accum=old_accum+freq;
int val=0x20;
if ((old_accum^new_accum)&0x10000) chan[i].noiseval=noiseOut;
new_accum&=0x1ffff;
chan[i].accum=new_accum;
switch (regPool[i*4+3]>>6) {
case 0: val=(new_accum>>10)>(regPool[i*4+3]&(unsigned)0x3f)?0:63; break;
case 1: val=(new_accum>>11); break;
case 2: val=(new_accum&0x10000)?(~(new_accum>>10)&0x3f):((new_accum>>10)&0x3f); break;
case 3: val=chan[i].noiseval; break;
}
val=(val-0x20)*volume_lut_psg[regPool[i*4+2]&0x3f];
lout+=(regPool[i*4+2]&0x40)?val:0;
rout+=(regPool[i*4+2]&0x80)?val:0;
}
// PCM
// simple one-channel sample player, actual hardware is essentially a DAC
// with buffering
if (chan[16].pcm.sample>=0) {
chan[16].accum+=regPool[65];
if (chan[16].accum>=128) {
DivSample* s=parent->getSample(chan[16].pcm.sample);
if (s->samples>0) {
int tmp_l=0;
int tmp_r=0;
if (!isMuted[16]) {
// TODO stereo samples once DivSample has a support for it
switch (s->depth) {
case 8:
tmp_l=s->data8[chan[16].pcm.pos]*256;
tmp_r=tmp_l;
regPool[64]|=0x20; // for register viewer purposes
break;
case 16:
tmp_l=s->data16[chan[16].pcm.pos];
tmp_r=tmp_l;
regPool[64]&=~0x20;
break;
}
if (!(chan[16].pan&1)) tmp_l=0;
if (!(chan[16].pan&2)) tmp_r=0;
}
chan[16].pcm.out_l=tmp_l;
chan[16].pcm.out_r=tmp_r;
} else {
chan[16].pcm.sample=-1;
}
chan[16].accum&=0x7f;
chan[16].pcm.pos++;
if (chan[16].pcm.pos>=s->samples) {
if (s->loopStart>=0 && s->loopStart<=(int)s->samples) {
chan[16].pcm.pos=s->loopStart;
} else {
chan[16].pcm.sample=-1;
}
}
}
}
int pcmvol=volume_lut_pcm[regPool[64]&0x0f];
lout+=chan[16].pcm.out_l*pcmvol/64;
rout+=chan[16].pcm.out_r*pcmvol/64;
bufL[pos]=(short)(lout/2);
bufR[pos]=(short)(rout/2);
}
}
void DivPlatformVERA::reset() {