2019-07-14 21:45:12 -04:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "NecDspTypes.h"
|
|
|
|
#include "BaseCoprocessor.h"
|
|
|
|
|
|
|
|
class Console;
|
|
|
|
class MemoryManager;
|
2019-07-16 00:11:23 -04:00
|
|
|
class RamHandler;
|
2019-07-14 21:45:12 -04:00
|
|
|
enum class CoprocessorType;
|
|
|
|
|
|
|
|
class NecDsp final : public BaseCoprocessor
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
Console* _console = nullptr;
|
|
|
|
MemoryManager* _memoryManager = nullptr;
|
|
|
|
NecDspState _state = {};
|
2019-07-16 00:11:23 -04:00
|
|
|
unique_ptr<RamHandler> _ramHandler;
|
|
|
|
CoprocessorType _type;
|
2019-07-14 21:45:12 -04:00
|
|
|
|
2019-07-16 00:11:23 -04:00
|
|
|
double _frequency = 7600000;
|
2019-07-14 21:45:12 -04:00
|
|
|
uint32_t _opCode = 0;
|
2021-03-10 11:13:28 -05:00
|
|
|
uint8_t *_progRom = nullptr;
|
|
|
|
uint32_t *_prgCache = nullptr;
|
|
|
|
uint16_t *_dataRom = nullptr;
|
|
|
|
uint16_t *_ram = nullptr;
|
2019-07-16 00:11:23 -04:00
|
|
|
uint16_t _stack[16];
|
|
|
|
|
|
|
|
uint32_t _progSize = 0;
|
|
|
|
uint32_t _dataSize = 0;
|
|
|
|
uint32_t _ramSize = 0;
|
|
|
|
uint32_t _stackSize = 0;
|
|
|
|
|
|
|
|
uint32_t _progMask = 0;
|
|
|
|
uint32_t _dataMask = 0;
|
|
|
|
uint32_t _ramMask = 0;
|
|
|
|
uint32_t _stackMask = 0;
|
|
|
|
|
2019-07-14 21:45:12 -04:00
|
|
|
uint64_t _cycleCount = 0;
|
|
|
|
uint16_t _registerMask = 0;
|
|
|
|
bool _inRqmLoop = false;
|
|
|
|
|
2020-02-23 21:50:55 -05:00
|
|
|
void ReadOpCode();
|
|
|
|
|
2019-07-14 21:45:12 -04:00
|
|
|
void RunApuOp(uint8_t aluOperation, uint16_t source);
|
|
|
|
|
|
|
|
void UpdateDataPointer();
|
|
|
|
void ExecOp();
|
|
|
|
void ExecAndReturn();
|
|
|
|
|
|
|
|
void Jump();
|
|
|
|
void Load(uint8_t dest, uint16_t value);
|
|
|
|
uint16_t GetSourceValue(uint8_t source);
|
|
|
|
|
2021-03-10 11:13:28 -05:00
|
|
|
NecDsp(CoprocessorType type, Console* console, vector<uint8_t> &programRom, vector<uint8_t> &dataRom);
|
2019-07-14 21:45:12 -04:00
|
|
|
|
|
|
|
public:
|
2020-02-23 21:50:55 -05:00
|
|
|
virtual ~NecDsp();
|
|
|
|
|
2021-03-10 11:13:28 -05:00
|
|
|
static NecDsp* InitCoprocessor(CoprocessorType type, Console* console, vector<uint8_t> &embeddedFirmware);
|
2019-07-14 21:45:12 -04:00
|
|
|
|
2019-07-16 00:11:23 -04:00
|
|
|
void Reset() override;
|
2020-06-18 00:58:22 -04:00
|
|
|
void Run() override;
|
2019-07-16 00:11:23 -04:00
|
|
|
|
2019-08-09 16:25:59 -04:00
|
|
|
void LoadBattery() override;
|
|
|
|
void SaveBattery() override;
|
2020-02-23 21:50:55 -05:00
|
|
|
|
|
|
|
void BuildProgramCache();
|
2021-03-10 11:13:28 -05:00
|
|
|
|
2019-07-14 21:45:12 -04:00
|
|
|
uint8_t Read(uint32_t addr) override;
|
|
|
|
void Write(uint32_t addr, uint8_t value) override;
|
2021-03-10 11:13:28 -05:00
|
|
|
|
2019-07-14 21:45:12 -04:00
|
|
|
uint8_t Peek(uint32_t addr) override;
|
2021-03-10 11:13:28 -05:00
|
|
|
void PeekBlock(uint32_t addr, uint8_t * output) override;
|
2019-07-14 21:45:12 -04:00
|
|
|
AddressInfo GetAbsoluteAddress(uint32_t address) override;
|
|
|
|
|
|
|
|
uint8_t* DebugGetProgramRom();
|
|
|
|
uint8_t* DebugGetDataRom();
|
|
|
|
uint8_t* DebugGetDataRam();
|
|
|
|
uint32_t DebugGetProgramRomSize();
|
|
|
|
uint32_t DebugGetDataRomSize();
|
|
|
|
uint32_t DebugGetDataRamSize();
|
|
|
|
NecDspState GetState();
|
|
|
|
|
2021-03-10 11:13:28 -05:00
|
|
|
void Serialize(Serializer &s) override;
|
2020-10-11 13:57:01 +03:00
|
|
|
|
|
|
|
void SetReg(NecDspRegister reg, uint16_t value);
|
2021-03-10 11:13:28 -05:00
|
|
|
};
|