diff --git a/src/engine/platform/k007232.cpp b/src/engine/platform/k007232.cpp index 1b8be394..3c2ad157 100644 --- a/src/engine/platform/k007232.cpp +++ b/src/engine/platform/k007232.cpp @@ -149,12 +149,19 @@ void DivPlatformK007232::tick(bool sysTick) { if (stereo) { chan[i].lvol=isMuted[i]?0:(((chan[i].outVol&0xf)*((chan[i].panning>>0)&0xf))/15); chan[i].rvol=isMuted[i]?0:(((chan[i].outVol&0xf)*((chan[i].panning>>4)&0xf))/15); - rWrite(0x10+i,(chan[i].lvol&0xf)|((chan[i].rvol&0xf)<<4)); + const unsigned char prevPan=lastPan[i]; + lastPan[i]=(chan[i].lvol&0xf)|((chan[i].rvol&0xf)<<4); + if (prevPan!=lastPan[i]) { + rWrite(0x10+i,(chan[i].lvol&0xf)|((chan[i].rvol&0xf)<<4)); + } } else { chan[i].lvol=chan[i].rvol=isMuted[i]?0:chan[i].outVol&0xf; + const unsigned char prevVolume=lastVolume; lastVolume=(lastVolume&~(0xf<<(i<<2)))|((chan[i].outVol&0xf)<<(i<<2)); - rWrite(0xc,lastVolume); + if (prevVolume!=lastVolume) { + rWrite(0xc,lastVolume); + } } chan[i].volumeChanged=false; } @@ -202,13 +209,16 @@ void DivPlatformK007232::tick(bool sysTick) { chWrite(i,4,0x1); chWrite(i,5,0); // keyon + const unsigned char prevLoop=lastLoop; if (s->isLoopable()) { loop=start+s->loopStart; lastLoop|=(1<>8)&0xf); @@ -399,10 +409,11 @@ void DivPlatformK007232::reset() { while (!writes.empty()) { writes.pop(); } - memset(regPool,0,32); + memset(regPool,0,20); k007232.reset(); lastLoop=0; - lastVolume=0xff; + lastVolume=0; + lastPan[0]=lastPan[1]=0; for (int i=0; i<2; i++) { chan[i]=DivPlatformK007232::Channel(); chan[i].std.setEngine(parent); @@ -462,7 +473,7 @@ unsigned char* DivPlatformK007232::getRegisterPool() { } int DivPlatformK007232::getRegisterPoolSize() { - return 32; + return 20; } const void* DivPlatformK007232::getSampleMem(int index) { diff --git a/src/engine/platform/k007232.h b/src/engine/platform/k007232.h index 46e68a15..2eb78837 100644 --- a/src/engine/platform/k007232.h +++ b/src/engine/platform/k007232.h @@ -80,13 +80,14 @@ class DivPlatformK007232: public DivDispatch, public k007232_intf { unsigned int sampleOffK007232[256]; bool sampleLoaded[256]; - int delay, lastLoop, lastVolume; + int delay; + unsigned char lastLoop, lastVolume, lastPan[2]; bool stereo; unsigned char* sampleMem; size_t sampleMemLen; k007232_core k007232; - unsigned char regPool[32]; + unsigned char regPool[20]; friend void putDispatchChip(void*,int); friend void putDispatchChan(void*,int,int);