fixed some bugs

This commit is contained in:
AArt1256 2024-08-09 11:34:02 +03:00
parent 5532965925
commit fc6e22cb83

View file

@ -52,10 +52,9 @@ const char* regCheatSheetSupervision[]={
NULL NULL
}; };
unsigned char freqLo[2];
unsigned char freqHi[2];
unsigned char noiseReg[3]; unsigned char noiseReg[3];
unsigned char kon[3]; unsigned char kon[3];
unsigned char initWrite[4];
const char** DivPlatformSupervision::getRegisterSheet() { const char** DivPlatformSupervision::getRegisterSheet() {
return regCheatSheetSupervision; return regCheatSheetSupervision;
@ -69,6 +68,11 @@ unsigned char otherFlags = 0;
void DivPlatformSupervision::acquire(short** buf, size_t len) { void DivPlatformSupervision::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) { for (size_t h=0; h<len; h++) {
int mask_bits=0;
for (int i=0; i<4; i++)
mask_bits |= isMuted[i]?0:8>>i;
supervision_set_mute_mask(mask_bits);
while (!writes.empty()) { while (!writes.empty()) {
QueuedWrite w=writes.front(); QueuedWrite w=writes.front();
supervision_memorymap_registers_write(w.addr|0x2000,w.val); supervision_memorymap_registers_write(w.addr|0x2000,w.val);
@ -142,12 +146,11 @@ void DivPlatformSupervision::tick(bool sysTick) {
chan[i].freq=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<<1,CHIP_DIVIDER); chan[i].freq=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<<1,CHIP_DIVIDER);
if (chan[i].freq<1) chan[i].freq=1; if (chan[i].freq<1) chan[i].freq=1;
if (chan[i].freq>2047) chan[i].freq=2047; if (chan[i].freq>2047) chan[i].freq=2047;
if (freqLo[i] != (chan[i].freq&0xff)) if (chan[i].freqChanged || initWrite[i]) {
rWrite(0x10|(i<<2),chan[i].freq&0xff); rWrite(0x10|(i<<2),chan[i].freq&0xff);
freqLo[i] = chan[i].freq&0xff; rWrite(0x11|(i<<2),(chan[i].freq>>8)&0x7);
if (freqHi[i] != ((chan[i].freq>>8)&0xff)) }
rWrite(0x11|(i<<2),(chan[i].freq>>8)&0xff); initWrite[i]=0;
freqHi[i] = (chan[i].freq>>8)&0xff;
} else if (i == 3) { } else if (i == 3) {
int ntPos=chan[i].baseFreq; int ntPos=chan[i].baseFreq;
if (NEW_ARP_STRAT) { if (NEW_ARP_STRAT) {
@ -182,6 +185,18 @@ void DivPlatformSupervision::tick(bool sysTick) {
} }
} }
} }
if (chan[i].keyOff && i==2) {
if (chan[i].pcm) {
int ntPos=chan[i].sampleNote;
ntPos+=chan[i].pitch2;
chan[i].freq=3-(ntPos&3);
int sNum=chan[i].sample;
DivSample* sample=parent->getSample(sNum);
if (sample!=NULL && sNum>=0 && sNum<parent->song.sampleLen) {
rWrite(0x1C,0x00);
}
}
}
if (chan[i].keyOn) kon[i]=1; if (chan[i].keyOn) kon[i]=1;
if (chan[i].keyOff) kon[i]=0; if (chan[i].keyOff) kon[i]=0;
if (chan[i].keyOn) chan[i].keyOn=false; if (chan[i].keyOn) chan[i].keyOn=false;
@ -346,10 +361,6 @@ int DivPlatformSupervision::dispatch(DivCommand c) {
void DivPlatformSupervision::muteChannel(int ch, bool mute) { void DivPlatformSupervision::muteChannel(int ch, bool mute) {
isMuted[ch]=mute; isMuted[ch]=mute;
int mask_bits = 0;
for (int i=0; i<4; i++)
mask_bits |= isMuted[i]?0:8>>i;
supervision_set_mute_mask(mask_bits);
} }
void DivPlatformSupervision::forceIns() { void DivPlatformSupervision::forceIns() {
@ -395,8 +406,7 @@ void DivPlatformSupervision::reset() {
memset(tempR,0,32*sizeof(int)); memset(tempR,0,32*sizeof(int));
memset(noiseReg,0,3*sizeof(unsigned char)); memset(noiseReg,0,3*sizeof(unsigned char));
memset(kon,0,3*sizeof(unsigned char)); memset(kon,0,3*sizeof(unsigned char));
memset(freqLo,0,sizeof(unsigned char)); memset(initWrite,1,sizeof(unsigned char));
memset(freqHi,0,sizeof(unsigned char));
} }
int DivPlatformSupervision::getOutputCount() { int DivPlatformSupervision::getOutputCount() {