SegaPCM: new real emulation core

This commit is contained in:
tildearrow 2023-02-10 02:01:23 -05:00
parent 0d424c7962
commit 6036366f38
9 changed files with 144 additions and 169 deletions

View file

@ -16,6 +16,7 @@ segapcm_device::segapcm_device()
: m_bankshift(12)
, m_bankmask(0x70)
{
memset(m_muted,0,16*sizeof(bool));
}
@ -94,8 +95,13 @@ void segapcm_device::sound_stream_update(int* outputs)
v = read_byte(offset + (addr >> 8)) - 0x80;
/* apply panning and advance */
lastOut[ch][0]=v * (regs[2] & 0x7f);
lastOut[ch][1]=v * (regs[3] & 0x7f);
if (m_muted[ch]) {
lastOut[ch][0]=0;
lastOut[ch][1]=0;
} else {
lastOut[ch][0]=v * (regs[2] & 0x7f);
lastOut[ch][1]=v * (regs[3] & 0x7f);
}
outputs[0]+=lastOut[ch][0];
outputs[1]+=lastOut[ch][1];
addr = (addr + regs[7]) & 0xffffff;
@ -123,3 +129,11 @@ uint8_t segapcm_device::read(unsigned int offset)
{
return m_ram[offset & 0x07ff];
}
uint8_t* segapcm_device::get_ram() {
return m_ram;
}
void segapcm_device::mute(int ch, bool doMute) {
m_muted[ch&15]=doMute;
}

View file

@ -7,6 +7,7 @@
#ifndef MAMESOUND_SEGAPCM_H
#define MAMESOUND_SEGAPCM_H
#include <stdint.h>
#include <functional>
//**************************************************************************
@ -22,7 +23,7 @@ public:
static constexpr int BANK_MASKF = 0xf0 << 16;
static constexpr int BANK_MASKF8 = 0xf8 << 16;
short lastOut[16][2];
short lastOut[16][2];
segapcm_device();
@ -32,6 +33,8 @@ public:
void write(unsigned int offset, uint8_t data);
uint8_t read(unsigned int offset);
uint8_t* get_ram();
void mute(int ch, bool doMute);
// device-level overrides
void device_start();
@ -42,6 +45,7 @@ public:
private:
uint8_t m_ram[0x800];
uint8_t m_low[16];
bool m_muted[16];
int m_bankshift;
int m_bankmask;
std::function<unsigned char(unsigned int)> read_byte;