2015-07-14 21:50:14 -04:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "IMemoryHandler.h"
|
2015-07-25 11:59:18 -04:00
|
|
|
#include "BaseApuChannel.h"
|
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
class Console;
|
2015-07-14 21:50:14 -04:00
|
|
|
|
2016-01-24 18:51:07 -05:00
|
|
|
class DeltaModulationChannel : public BaseApuChannel
|
2015-07-14 21:50:14 -04:00
|
|
|
{
|
|
|
|
private:
|
2017-03-31 22:14:16 -04:00
|
|
|
const uint16_t _dmcPeriodLookupTableNtsc[16] = { 428, 380, 340, 320, 286, 254, 226, 214, 190, 160, 142, 128, 106, 84, 72, 54 };
|
|
|
|
const uint16_t _dmcPeriodLookupTablePal[16] = { 398, 354, 316, 298, 276, 236, 210, 198, 176, 148, 132, 118, 98, 78, 66, 50 };
|
2015-07-14 21:50:14 -04:00
|
|
|
|
|
|
|
uint16_t _sampleAddr = 0;
|
|
|
|
uint16_t _sampleLength = 0;
|
|
|
|
uint8_t _outputLevel = 0;
|
|
|
|
bool _irqEnabled = false;
|
|
|
|
bool _loopFlag = false;
|
|
|
|
|
|
|
|
uint16_t _currentAddr = 0;
|
|
|
|
uint16_t _bytesRemaining = 0;
|
|
|
|
uint8_t _readBuffer = 0;
|
|
|
|
bool _bufferEmpty = true;
|
|
|
|
|
|
|
|
uint8_t _shiftRegister = 0;
|
|
|
|
uint8_t _bitsRemaining = 0;
|
|
|
|
bool _silenceFlag = true;
|
2015-07-25 11:59:18 -04:00
|
|
|
bool _needToRun = false;
|
2019-11-10 17:35:29 -05:00
|
|
|
bool _needInit = false;
|
2015-07-14 21:50:14 -04:00
|
|
|
|
2017-07-17 19:35:16 -04:00
|
|
|
uint8_t _lastValue4011 = 0;
|
|
|
|
|
2015-07-25 11:59:18 -04:00
|
|
|
void InitSample();
|
2015-07-14 23:35:30 -04:00
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
void Clock() override;
|
2015-07-14 23:35:30 -04:00
|
|
|
|
2015-07-14 21:50:14 -04:00
|
|
|
public:
|
2018-07-01 15:21:05 -04:00
|
|
|
DeltaModulationChannel(AudioChannel channel, shared_ptr<Console> console, SoundMixer* mixer);
|
2015-07-14 21:50:14 -04:00
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
virtual void Reset(bool softReset) override;
|
|
|
|
virtual void StreamState(bool saving) override;
|
2015-07-14 21:50:14 -04:00
|
|
|
|
2015-07-25 11:59:18 -04:00
|
|
|
bool IrqPending(uint32_t cyclesToRun);
|
|
|
|
bool NeedToRun();
|
2016-12-17 23:14:47 -05:00
|
|
|
bool GetStatus() override;
|
|
|
|
void GetMemoryRanges(MemoryRanges &ranges) override;
|
|
|
|
void WriteRAM(uint16_t addr, uint8_t value) override;
|
2015-07-14 21:50:14 -04:00
|
|
|
|
2015-07-25 11:59:18 -04:00
|
|
|
void SetEnabled(bool enabled);
|
|
|
|
void StartDmcTransfer();
|
2019-11-10 17:35:29 -05:00
|
|
|
uint16_t GetDmcReadAddress();
|
|
|
|
void SetDmcReadBuffer(uint8_t value);
|
2017-08-30 18:31:27 -04:00
|
|
|
|
|
|
|
ApuDmcState GetState();
|
2015-07-14 21:50:14 -04:00
|
|
|
};
|