SegaPCM: implement getSamplePos()

This commit is contained in:
tildearrow 2023-03-19 16:49:31 -05:00
parent 62b9b98300
commit 591cd633d7
4 changed files with 27 additions and 1 deletions

View file

@ -382,6 +382,17 @@ DivMacroInt* DivPlatformSegaPCM::getChanMacroInt(int ch) {
return &chan[ch].std;
}
DivSamplePos DivPlatformSegaPCM::getSamplePos(int ch) {
if (ch>=16) return DivSamplePos();
if (chan[ch].pcm.sample<0 || chan[ch].pcm.sample>=parent->song.sampleLen) return DivSamplePos();
if (!pcm.is_playing(ch)) return DivSamplePos();
return DivSamplePos(
chan[ch].pcm.sample,
pcm.get_addr(ch)-sampleOffSegaPCM[chan[ch].pcm.sample],
122*(chan[ch].pcm.freq+1)
);
}
DivDispatchOscBuffer* DivPlatformSegaPCM::getOscBuffer(int ch) {
return oscBuf[ch];
}

View file

@ -87,6 +87,7 @@ class DivPlatformSegaPCM: public DivDispatch {
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
DivSamplePos getSamplePos(int ch);
DivDispatchOscBuffer* getOscBuffer(int chan);
unsigned char* getRegisterPool();
int getRegisterPoolSize();

View file

@ -134,6 +134,18 @@ uint8_t* segapcm_device::get_ram() {
return m_ram;
}
unsigned int segapcm_device::get_addr(int ch) {
uint8_t *regs = &m_ram[8*ch];
int offset = (regs[0x86] & m_bankmask) << m_bankshift;
uint32_t addr = (regs[0x85] << 8) | (regs[0x84]) | offset;
return addr;
}
bool segapcm_device::is_playing(int ch) {
uint8_t *regs = &m_ram[8*ch];
return !(regs[0x86]&1);
}
void segapcm_device::mute(int ch, bool doMute) {
m_muted[ch&15]=doMute;
}
}

View file

@ -34,6 +34,8 @@ public:
void write(unsigned int offset, uint8_t data);
uint8_t read(unsigned int offset);
uint8_t* get_ram();
unsigned int get_addr(int ch);
bool is_playing(int ch);
void mute(int ch, bool doMute);
// device-level overrides