Define to chose between Old and New VRC7 emu
This commit is contained in:
parent
6c5454638f
commit
5203ff1217
2 changed files with 85 additions and 2 deletions
|
@ -266,7 +266,15 @@ int16_t SoundMixer::GetOutputVolume(bool forRightChannel)
|
|||
GetChannelOutput(AudioChannel::Namco163, forRightChannel) * 20 +
|
||||
GetChannelOutput(AudioChannel::Sunsoft5B, forRightChannel) * 15 +
|
||||
GetChannelOutput(AudioChannel::VRC6, forRightChannel) * 75 +
|
||||
#ifndef VRC7_USE_OLD_EMU
|
||||
#define VRC7_USE_NUKED
|
||||
#endif
|
||||
|
||||
#ifdef VRC7_USE_NUKED
|
||||
GetChannelOutput(AudioChannel::VRC7, forRightChannel) * 12 +
|
||||
#else
|
||||
GetChannelOutput(AudioChannel::VRC7, forRightChannel) +
|
||||
#endif
|
||||
GetChannelOutput(AudioChannel::EPSG_L, forRightChannel) * 15 +
|
||||
GetChannelOutput(AudioChannel::EPSG_R, forRightChannel) * 15
|
||||
);
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
#include <array>
|
||||
#include "opll.h"
|
||||
|
||||
|
||||
#ifndef VRC7_USE_OLD_EMU
|
||||
#define VRC7_USE_NUKED
|
||||
#endif
|
||||
|
||||
#ifdef VRC7_USE_NUKED
|
||||
class Vrc7Audio : public BaseExpansionAudio
|
||||
{
|
||||
private:
|
||||
|
@ -88,7 +94,7 @@ protected:
|
|||
while (_clock >= cycleCount)
|
||||
{
|
||||
|
||||
_currentOutput = 0;
|
||||
_currentOutput = 0;
|
||||
|
||||
|
||||
for (uint8_t cycle = 0; cycle < cycleCount; cycle++)
|
||||
|
@ -140,4 +146,73 @@ public:
|
|||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
#else
|
||||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include "BaseExpansionAudio.h"
|
||||
#include "Console.h"
|
||||
#include "OpllEmulator.h"
|
||||
|
||||
class Vrc7Audio : public BaseExpansionAudio
|
||||
{
|
||||
private:
|
||||
unique_ptr<Vrc7Opll::OpllEmulator> _opllEmulator;
|
||||
uint8_t _currentReg;
|
||||
int16_t _previousOutput;
|
||||
double _clockTimer;
|
||||
bool _muted;
|
||||
|
||||
protected:
|
||||
void ClockAudio() override
|
||||
{
|
||||
if (_clockTimer == 0) {
|
||||
_clockTimer = ((double)_console->GetCpu()->GetClockRate(_console->GetModel())) / 49716;
|
||||
}
|
||||
|
||||
_clockTimer--;
|
||||
if (_clockTimer <= 0) {
|
||||
int16_t output = _opllEmulator->GetOutput();
|
||||
_console->GetApu()->AddExpansionAudioDelta(AudioChannel::VRC7, _muted ? 0 : (output - _previousOutput));
|
||||
_previousOutput = output;
|
||||
_clockTimer = ((double)_console->GetCpu()->GetClockRate(_console->GetModel())) / 49716;
|
||||
}
|
||||
}
|
||||
|
||||
void StreamState(bool saving) override
|
||||
{
|
||||
BaseExpansionAudio::StreamState(saving);
|
||||
|
||||
SnapshotInfo opllEmulator{ _opllEmulator.get() };
|
||||
Stream(opllEmulator, _currentReg, _previousOutput, _clockTimer, _muted);
|
||||
}
|
||||
|
||||
public:
|
||||
Vrc7Audio(shared_ptr<Console> console) : BaseExpansionAudio(console)
|
||||
{
|
||||
_previousOutput = 0;
|
||||
_currentReg = 0;
|
||||
_muted = false;
|
||||
_clockTimer = 0;
|
||||
_opllEmulator.reset(new Vrc7Opll::OpllEmulator());
|
||||
}
|
||||
|
||||
void SetMuteAudio(bool muted)
|
||||
{
|
||||
_muted = muted;
|
||||
}
|
||||
|
||||
void WriteRegister(uint16_t addr, uint8_t value)
|
||||
{
|
||||
switch (addr & 0xF030) {
|
||||
case 0x9010:
|
||||
_currentReg = value;
|
||||
break;
|
||||
case 0x9030:
|
||||
_opllEmulator->WriteReg(_currentReg, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue