Merge branch 'master' of https://github.com/tildearrow/furnace into k053260

This commit is contained in:
cam900 2023-05-02 13:46:56 +09:00
commit 523e08ed5c
35 changed files with 677 additions and 193 deletions

View file

@ -687,6 +687,7 @@ void DivPlatformAY8910::muteChannel(int ch, bool mute) {
void DivPlatformAY8910::forceIns() {
for (int i=0; i<3; i++) {
chan[i].insChanged=true;
chan[i].freqChanged=true;
}
immWrite(0x0b,ayEnvPeriod);
immWrite(0x0c,ayEnvPeriod>>8);

View file

@ -1558,7 +1558,7 @@ DivMacroInt* DivPlatformOPL::getChanMacroInt(int ch) {
}
DivDispatchOscBuffer* DivPlatformOPL::getOscBuffer(int ch) {
if (oplType==759) {
if (oplType==759 || chipType==8950) {
if (ch>=totalChans+1) return NULL;
} else {
if (ch>=totalChans) return NULL;

View file

@ -29,6 +29,7 @@ const char* regCheatSheetPV1000[]={
"CH1_Pitch", "00",
"CH2_Pitch", "01",
"CH3_Pitch", "02",
"Control", "03",
NULL
};
@ -38,11 +39,10 @@ const char** DivPlatformPV1000::getRegisterSheet() {
void DivPlatformPV1000::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
short samp;
samp=d65010g031_sound_tick(&d65010g031,1);
short samp=d65010g031_sound_tick(&d65010g031,1);
buf[0][h]=samp;
for (int i=0; i<3; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(d65010g031.square[i].out<<12);
oscBuf[i]->data[oscBuf[i]->needle++]=(d65010g031.out[i]);
}
}
}
@ -73,17 +73,17 @@ void DivPlatformPV1000::tick(bool sysTick) {
}
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
chan[i].freq=0x3f-parent->calcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,true,0,chan[i].pitch2,chipClock,CHIP_DIVIDER);
if (chan[i].freq<1) chan[i].freq=1;
if (chan[i].freq<0) chan[i].freq=0;
if (chan[i].freq>62) chan[i].freq=62;
if (isMuted[i]) chan[i].keyOn=false;
if (chan[i].keyOn) {
rWrite(i,(isMuted[i] || (chan[i].outVol<=0)) ? 0 : chan[i].freq);
rWrite(i,(isMuted[i] || (chan[i].outVol<=0)) ? 0x3f : chan[i].freq);
chan[i].keyOn=false;
} else if (chan[i].freqChanged && chan[i].active && !isMuted[i]) {
rWrite(i,(isMuted[i] || (chan[i].outVol<=0)) ? 0 : chan[i].freq);
rWrite(i,(isMuted[i] || (chan[i].outVol<=0)) ? 0x3f : chan[i].freq);
}
if (chan[i].keyOff) {
rWrite(i,0);
rWrite(i,0x3f);
chan[i].keyOff=false;
}
chan[i].freqChanged=false;
@ -137,6 +137,13 @@ int DivPlatformPV1000::dispatch(DivCommand c) {
chan[c.chan].pitch=c.value;
chan[c.chan].freqChanged=true;
break;
case DIV_CMD_STD_NOISE_MODE: // ring modulation
if (c.value&1) {
rWrite(3,3);
} else {
rWrite(3,2);
}
break;
case DIV_CMD_NOTE_PORTA: {
int destFreq=NOTE_PERIODIC(c.value2);
bool return2=false;
@ -224,16 +231,21 @@ unsigned char* DivPlatformPV1000::getRegisterPool() {
}
int DivPlatformPV1000::getRegisterPoolSize() {
return 3;
return 4;
}
void DivPlatformPV1000::reset() {
memset(regPool,0,3);
memset(regPool,0,4);
for (int i=0; i<3; i++) {
chan[i]=Channel();
chan[i].std.setEngine(parent);
}
d65010g031_reset(&d65010g031);
// mute
rWrite(0,0x3f);
rWrite(1,0x3f);
rWrite(2,0x3f);
rWrite(3,2);
}
int DivPlatformPV1000::getOutputCount() {

View file

@ -33,7 +33,7 @@ class DivPlatformPV1000: public DivDispatch {
DivDispatchOscBuffer* oscBuf[3];
bool isMuted[3];
unsigned char regPool[3];
unsigned char regPool[4];
d65010g031_t d65010g031;
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);

View file

@ -151,8 +151,8 @@ void DivPlatformRF5C68::tick(bool sysTick) {
if (s->isLoopable()) {
loop=start+s->loopStart;
}
start=MIN(start,getSampleMemCapacity()-31);
loop=MIN(loop,getSampleMemCapacity()-31);
start=MIN(start,getSampleMemCapacity()-32);
loop=MIN(loop,getSampleMemCapacity()-32);
rWrite(8,keyoff); // force keyoff first
chWrite(i,6,start>>8);
chWrite(i,4,loop&0xff);
@ -425,7 +425,7 @@ void DivPlatformRF5C68::renderSamples(int sysID) {
}
int length=s->getLoopEndPosition(DIV_SAMPLE_DEPTH_8BIT);
int actualLength=MIN((int)(getSampleMemCapacity()-memPos)-31,length);
int actualLength=MIN((int)(getSampleMemCapacity()-memPos)-32,length);
if (actualLength>0) {
sampleOffRFC[i]=memPos;
for (int j=0; j<actualLength; j++) {
@ -435,8 +435,8 @@ void DivPlatformRF5C68::renderSamples(int sysID) {
sampleMem[memPos++]=(val>0)?(val|0x80):(0-val);
}
// write end of sample marker
memset(&sampleMem[memPos],0xff,31);
memPos+=31;
memset(&sampleMem[memPos],0xff,32);
memPos+=32;
}
if (actualLength<length) {
logW("out of RF5C68 PCM memory for sample %d!",i);

View file

@ -67,7 +67,7 @@ int d65010g031_square_tick(struct d65010g031_square_t *square, const int cycle)
{
if (square->period > 0)
{
int period = d65010g031_max(1, (0x3f - square->period));
const int period = square->period;
square->counter += cycle;
while (square->counter >= period)
{
@ -82,9 +82,9 @@ int d65010g031_square_tick(struct d65010g031_square_t *square, const int cycle)
// this is the bit I altered
// THIS IS **NOT** THE ORIGINAL SOFTWARE! I am plainly marking it as such!
const int d65Volumes[3]={
3840,
5120,
8192
3840, // -6dB
5120, // -3dB
8192 // 0dB
};
int d65010g031_sound_tick(struct d65010g031_t *d65010g031, const int cycle)
@ -92,7 +92,29 @@ int d65010g031_sound_tick(struct d65010g031_t *d65010g031, const int cycle)
int out = 0;
for (int i = 0; i < 3; i++)
{
out += d65010g031_square_tick(&d65010g031->square[i], cycle)?d65Volumes[i]:-d65Volumes[i];
d65010g031->out[i] = 0;
}
if (d65010g031->ctrl & 2)
{
if (d65010g031->ctrl & 1) // ring modulation
{
int sout[3] = {
d65010g031_square_tick(&d65010g031->square[0], cycle),
d65010g031_square_tick(&d65010g031->square[1], cycle),
d65010g031_square_tick(&d65010g031->square[2], cycle),
};
d65010g031->out[0] = (sout[0] ^ sout[1]) ? d65Volumes[0] : -d65Volumes[0];
d65010g031->out[1] = (sout[1] ^ sout[2]) ? d65Volumes[1] : -d65Volumes[1];
d65010g031->out[2] = (sout[2] ? d65Volumes[2] : -d65Volumes[2]);
}
else
{
for (int i = 0; i < 3; i++)
{
d65010g031->out[i] = d65010g031_square_tick(&d65010g031->square[i], cycle)?d65Volumes[i]:-d65Volumes[i];
}
}
out = d65010g031->out[0] + d65010g031->out[1] + d65010g031->out[2];
}
return out;
}
@ -105,12 +127,25 @@ void d65010g031_reset(struct d65010g031_t *d65010g031)
d65010g031->square[i].counter = 0;
d65010g031->square[i].out = 0;
}
d65010g031->ctrl = 0;
}
void d65010g031_write(struct d65010g031_t *d65010g031, const unsigned char a, const unsigned char d)
{
if (a < 3)
switch (a)
{
d65010g031->square[a].period = d & 0x3f;
case 3:
d65010g031->ctrl = d;
break;
default:
{
const unsigned char per = (unsigned char)(~d) & 0x3f;
if ((per == 0) && (d65010g031->square[a].period != 0))
{
d65010g031->square[a].out ^= 1;
}
d65010g031->square[a].period = per;
break;
}
}
}

View file

@ -54,6 +54,8 @@ struct d65010g031_square_t
struct d65010g031_t
{
struct d65010g031_square_t square[3];
signed short out[3];
unsigned char ctrl;
};
int d65010g031_square_tick(struct d65010g031_square_t *square, const int cycle);

View file

@ -222,7 +222,8 @@ void DivPlatformX1_010::acquire(short** buf, size_t len) {
if (stereo) buf[1][h]=tempR;
for (int i=0; i<16; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(x1_010.voice_out(i,0)+x1_010.voice_out(i,1))>>1;
int vo=(x1_010.voice_out(i,0)+x1_010.voice_out(i,1))<<3;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(vo,-32768,32767);
}
}
}