Merge pull request #412 from grauw/ay8930-vgm

AY8930: Fix VGM output.
This commit is contained in:
tildearrow 2022-05-03 01:53:41 -05:00 committed by GitHub
commit 3d541682e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 11 deletions

View file

@ -25,7 +25,7 @@
#include <math.h> #include <math.h>
#define rWrite(a,v) if (!skipRegisterWrites) {pendingWrites[a]=v;} #define rWrite(a,v) if (!skipRegisterWrites) {pendingWrites[a]=v;}
#define immWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } #define immWrite2(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} }
#define CHIP_DIVIDER 8 #define CHIP_DIVIDER 8
@ -61,6 +61,18 @@ const char* regCheatSheetAY8930[]={
NULL NULL
}; };
void DivPlatformAY8930::immWrite(unsigned char a, unsigned char v) {
if ((int)bank!=(a>>4)) {
bank=a>>4;
immWrite2(0x0d, 0xa0|(bank<<4)|ayEnvMode[0]);
}
if (a==0x0d) {
immWrite2(0x0d,0xa0|(bank<<4)|(v&15));
} else {
immWrite2(a&15,v);
}
}
const char** DivPlatformAY8930::getRegisterSheet() { const char** DivPlatformAY8930::getRegisterSheet() {
return regCheatSheetAY8930; return regCheatSheetAY8930;
} }
@ -123,18 +135,13 @@ void DivPlatformAY8930::acquire(short* bufL, short* bufR, size_t start, size_t l
} }
while (!writes.empty()) { while (!writes.empty()) {
QueuedWrite w=writes.front(); QueuedWrite w=writes.front();
if ((int)bank!=(w.addr>>4)) { ay->address_w(w.addr);
bank=w.addr>>4; ay->data_w(w.val);
ay->address_w(0x0d); if (w.addr!=0x0d && (regPool[0x0d]&0xf0)==0xb0) {
ay->data_w(0xa0|(bank<<4)|ayEnvMode[0]); regPool[(w.addr&0x0f)|0x10]=w.val;
}
ay->address_w(w.addr&15);
if (w.addr==0x0d) {
ay->data_w(0xa0|(bank<<4)|(w.val&15));
} else { } else {
ay->data_w(w.val); regPool[w.addr&0x0f]=w.val;
} }
regPool[w.addr&0x1f]=w.val;
writes.pop(); writes.pop();
} }
ay->sound_stream_update(ayBuf,len); ay->sound_stream_update(ayBuf,len);

View file

@ -73,6 +73,7 @@ class DivPlatformAY8930: public DivDispatch {
size_t ayBufLen; size_t ayBufLen;
void updateOutSel(bool immediate=false); void updateOutSel(bool immediate=false);
void immWrite(unsigned char a, unsigned char v);
friend void putDispatchChan(void*,int,int); friend void putDispatchChan(void*,int,int);