Mesen-SX/Core/DmaController.h

39 lines
882 B
C
Raw Normal View History

2019-02-15 00:08:50 -05:00
#pragma once
#include "stdafx.h"
#include "CpuTypes.h"
class MemoryManager;
struct DmaChannelConfig
{
bool InvertDirection;
bool Decrement;
bool FixedTransfer;
bool HdmaPointers;
uint8_t TransferMode;
uint32_t SrcAddress;
uint8_t DestAddress;
uint16_t TransferSize;
};
class DmaController
{
private:
static constexpr uint8_t _transferByteCount[8] = { 1, 2, 2, 4, 4, 2, 4 };
static constexpr uint8_t _transferOffset[8][4] = {
{ 0, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 1, 1 },
{ 0, 1, 2, 3 }, { 0, 1, 0, 1 }, { 0, 0, 0, 0 }, { 0, 0, 1, 1 }
};
2019-02-15 00:08:50 -05:00
DmaChannelConfig _channel[8] = {};
shared_ptr<MemoryManager> _memoryManager;
void RunSingleTransfer(DmaChannelConfig &channel, uint32_t &bytesLeft);
void RunDma(DmaChannelConfig &channel);
2019-02-15 00:08:50 -05:00
public:
DmaController(shared_ptr<MemoryManager> memoryManager);
void Write(uint16_t addr, uint8_t value);
};