2015-05-07 01:52:45 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Types.h"
|
|
|
|
#include "../MIPS.h"
|
|
|
|
#include "../Profiler.h"
|
|
|
|
#include "Convertible.h"
|
|
|
|
#include "zip/ZipArchiveWriter.h"
|
|
|
|
#include "zip/ZipArchiveReader.h"
|
|
|
|
|
|
|
|
class CVif;
|
|
|
|
class CGIF;
|
2017-08-20 18:03:24 -04:00
|
|
|
class CINTC;
|
2015-05-07 01:52:45 -04:00
|
|
|
|
|
|
|
class CVpu
|
|
|
|
{
|
|
|
|
public:
|
2022-07-07 16:04:00 -04:00
|
|
|
enum
|
2015-05-07 01:52:45 -04:00
|
|
|
{
|
2022-07-07 16:54:22 -04:00
|
|
|
VU_ADDR_VU1AREA_START = 0x4000, //Only on VU0
|
2022-07-07 19:49:49 -04:00
|
|
|
VU_ADDR_TOP = 0x8400, //Only on VU1
|
|
|
|
VU_ADDR_XGKICK = 0x8410, //Only on VU1
|
2022-07-07 16:04:00 -04:00
|
|
|
VU_ADDR_ITOP = 0x8420,
|
2022-07-07 16:54:22 -04:00
|
|
|
|
|
|
|
EE_ADDR_VU1AREA_START = 0x1000FB00,
|
|
|
|
EE_ADDR_VU1AREA_END = 0x1000FEFF,
|
2024-08-12 18:06:45 -04:00
|
|
|
EE_ADDR_VU_FBRST = 0x1000FFC0, //This is meant to be used by the EE through CTC2
|
|
|
|
EE_ADDR_VU_CMSAR1 = 0x1000FFC4, //This is meant to be used by the EE through CTC2
|
2015-05-07 01:52:45 -04:00
|
|
|
};
|
|
|
|
|
2024-07-31 11:44:30 -04:00
|
|
|
enum VU_STATE
|
|
|
|
{
|
|
|
|
VU_STATE_READY,
|
|
|
|
VU_STATE_RUNNING,
|
|
|
|
VU_STATE_STOPPED,
|
|
|
|
};
|
|
|
|
|
2015-05-07 01:52:45 -04:00
|
|
|
struct VPUINIT
|
|
|
|
{
|
2018-04-30 21:01:23 +01:00
|
|
|
VPUINIT(uint8* microMem, uint8* vuMem, CMIPS* context)
|
|
|
|
: microMem(microMem)
|
|
|
|
, vuMem(vuMem)
|
|
|
|
, context(context)
|
2015-05-07 01:52:45 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8* microMem;
|
|
|
|
uint8* vuMem;
|
|
|
|
CMIPS* context;
|
|
|
|
};
|
|
|
|
|
2024-07-31 11:44:30 -04:00
|
|
|
typedef Framework::CSignal<void(VU_STATE)> VuStateChangedEvent;
|
2024-07-31 11:51:44 -04:00
|
|
|
typedef Framework::CSignal<void()> VuInterruptTriggeredEvent;
|
2019-10-14 12:55:09 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
CVpu(unsigned int, const VPUINIT&, CGIF&, CINTC&, uint8*, uint8*);
|
|
|
|
virtual ~CVpu();
|
2015-05-07 01:52:45 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void Execute(int32);
|
|
|
|
void Reset();
|
|
|
|
void SaveState(Framework::CZipArchiveWriter&);
|
|
|
|
void LoadState(Framework::CZipArchiveReader&);
|
2015-05-07 01:52:45 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
CMIPS& GetContext() const;
|
|
|
|
uint8* GetMicroMemory() const;
|
2020-07-10 16:31:09 -04:00
|
|
|
uint32 GetMicroMemorySize() const;
|
2018-04-30 21:01:23 +01:00
|
|
|
uint8* GetVuMemory() const;
|
|
|
|
uint32 GetVuMemorySize() const;
|
2024-08-12 18:06:45 -04:00
|
|
|
|
2024-07-31 11:44:30 -04:00
|
|
|
inline VU_STATE GetVuState() const
|
|
|
|
{
|
|
|
|
return m_vuState;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsVuReady() const
|
|
|
|
{
|
|
|
|
return m_vuState == VU_STATE_READY;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsVuRunning() const
|
|
|
|
{
|
|
|
|
return m_vuState == VU_STATE_RUNNING;
|
|
|
|
}
|
2015-05-07 01:52:45 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
CVif& GetVif();
|
2015-05-07 01:52:45 -04:00
|
|
|
|
2024-08-12 18:06:45 -04:00
|
|
|
void SetFbrst(uint32);
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void ExecuteMicroProgram(uint32);
|
|
|
|
void InvalidateMicroProgram();
|
2019-10-18 13:04:26 -04:00
|
|
|
void InvalidateMicroProgram(uint32, uint32);
|
2015-05-07 01:52:45 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void ProcessXgKick(uint32);
|
2015-05-07 01:52:45 -04:00
|
|
|
|
|
|
|
#ifdef DEBUGGER_INCLUDED
|
2018-04-30 21:01:23 +01:00
|
|
|
void SaveMiniState();
|
|
|
|
const MIPSSTATE& GetVuMiniState() const;
|
|
|
|
uint8* GetVuMemoryMiniState() const;
|
|
|
|
uint8* GetMicroMemoryMiniState() const;
|
|
|
|
uint32 GetVuTopMiniState() const;
|
|
|
|
uint32 GetVuItopMiniState() const;
|
2015-05-07 01:52:45 -04:00
|
|
|
#endif
|
|
|
|
|
2019-10-14 12:55:09 -04:00
|
|
|
VuStateChangedEvent VuStateChanged;
|
2024-07-31 11:51:44 -04:00
|
|
|
VuInterruptTriggeredEvent VuInterruptTriggered;
|
2019-10-14 12:55:09 -04:00
|
|
|
|
2015-05-07 01:52:45 -04:00
|
|
|
protected:
|
2024-08-12 18:06:45 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
FBRST_FB = (1 << 0),
|
|
|
|
FBRST_RS = (1 << 1),
|
|
|
|
FBRST_DE = (1 << 2),
|
|
|
|
FBRST_TE = (1 << 3),
|
|
|
|
};
|
|
|
|
|
2015-05-07 01:52:45 -04:00
|
|
|
typedef std::unique_ptr<CVif> VifPtr;
|
|
|
|
|
2023-05-02 08:56:25 -04:00
|
|
|
unsigned int m_number = 0;
|
|
|
|
VifPtr m_vif;
|
2018-04-30 21:01:23 +01:00
|
|
|
uint8* m_microMem = nullptr;
|
2020-07-10 16:31:09 -04:00
|
|
|
uint32 m_microMemSize = 0;
|
2018-04-30 21:01:23 +01:00
|
|
|
uint8* m_vuMem = nullptr;
|
|
|
|
uint32 m_vuMemSize = 0;
|
|
|
|
CMIPS* m_ctx = nullptr;
|
|
|
|
CGIF& m_gif;
|
2015-05-07 01:52:45 -04:00
|
|
|
|
|
|
|
#ifdef DEBUGGER_INCLUDED
|
2018-08-30 13:25:46 -04:00
|
|
|
MIPSSTATE m_vuMiniState;
|
2018-04-30 21:01:23 +01:00
|
|
|
uint8* m_microMemMiniState;
|
|
|
|
uint8* m_vuMemMiniState;
|
|
|
|
uint32 m_topMiniState;
|
|
|
|
uint32 m_itopMiniState;
|
2015-05-07 01:52:45 -04:00
|
|
|
#endif
|
|
|
|
|
2024-07-31 11:44:30 -04:00
|
|
|
VU_STATE m_vuState = VU_STATE_READY;
|
2024-08-12 18:06:45 -04:00
|
|
|
uint32 m_fbrst = 0;
|
2015-05-07 01:52:45 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
CProfiler::ZoneHandle m_vuProfilerZone = 0;
|
2015-05-07 01:52:45 -04:00
|
|
|
};
|