Play-/Source/ee/GIF.h

126 lines
2.5 KiB
C
Raw Permalink Normal View History

#pragma once
#include "Types.h"
#include "zip/ZipArchiveWriter.h"
#include "zip/ZipArchiveReader.h"
#include "../gs/GSHandler.h"
#include "../Profiler.h"
class CDMAC;
class CGIF
{
public:
enum REGISTER
{
2021-05-13 10:46:57 -04:00
GIF_MODE = 0x10003010,
2018-04-30 21:01:23 +01:00
GIF_STAT = 0x10003020
};
enum
{
2018-04-30 21:01:23 +01:00
GIF_STAT_M3P = 0x002,
GIF_STAT_OPH = 0x200,
2018-04-30 21:01:23 +01:00
GIF_STAT_APATH3 = 0xC00,
};
enum
{
2018-04-30 21:01:23 +01:00
REGS_START = 0x10003000,
REGS_END = 0x100030B0,
2022-07-21 09:46:19 -04:00
GIF_FIFO_START = 0x10006000,
GIF_FIFO_END = 0x10006FFF,
};
struct TAG
{
2018-04-30 21:01:23 +01:00
unsigned int loops : 15;
unsigned int eop : 1;
unsigned int reserved0 : 16;
unsigned int reserved1 : 14;
unsigned int pre : 1;
unsigned int prim : 11;
unsigned int cmd : 2;
unsigned int nreg : 4;
uint64 regs;
};
static_assert(sizeof(TAG) == 0x10, "Size of TAG must be 16 bytes.");
CGIF(CGSHandler*&, CDMAC&, uint8*, uint8*);
2018-04-30 21:01:23 +01:00
virtual ~CGIF() = default;
2018-04-30 21:01:23 +01:00
void Reset();
uint32 ReceiveDMA(uint32, uint32, uint32, bool);
uint32 ProcessSinglePacket(const uint8*, uint32, uint32, uint32, const CGsPacketMetadata&);
uint32 ProcessMultiplePackets(const uint8*, uint32, uint32, uint32, const CGsPacketMetadata&);
void CountTicks(uint32);
2018-04-30 21:01:23 +01:00
uint32 GetRegister(uint32);
void SetRegister(uint32, uint32);
2018-04-30 21:01:23 +01:00
CGSHandler* GetGsHandler();
2022-10-27 17:29:21 -04:00
uint32 GetActivePath() const;
2018-04-30 21:01:23 +01:00
void SetPath3Masked(bool);
2018-04-30 21:01:23 +01:00
void LoadState(Framework::CZipArchiveReader&);
void SaveState(Framework::CZipArchiveWriter&);
private:
2022-07-21 09:46:19 -04:00
enum
{
FIFO_QWC = 0x10,
FIFO_SIZE = FIFO_QWC * 0x10,
2022-07-21 09:46:19 -04:00
};
enum SIGNAL_STATE
{
SIGNAL_STATE_NONE,
SIGNAL_STATE_ENCOUNTERED,
SIGNAL_STATE_PENDING,
};
enum MASKED_PATH3_XFER_STATE
{
MASKED_PATH3_XFER_NONE,
MASKED_PATH3_XFER_PROCESSING,
MASKED_PATH3_XFER_DONE,
};
uint32 ProcessPacked(const uint8*, uint32, uint32);
uint32 ProcessRegList(const uint8*, uint32, uint32);
uint32 ProcessImage(const uint8*, uint32, uint32, uint32);
2018-04-30 21:01:23 +01:00
2022-07-21 09:46:19 -04:00
void ProcessFifoWrite(uint32, uint32);
void DrainFifo();
2022-07-21 09:46:19 -04:00
2018-04-30 21:01:23 +01:00
void DisassembleGet(uint32);
void DisassembleSet(uint32, uint32);
bool m_path3Masked = false;
uint32 m_activePath = 0;
2021-05-13 10:46:57 -04:00
uint32 m_MODE = 0;
2018-04-30 21:01:23 +01:00
2019-04-04 18:25:28 -04:00
uint16 m_loops = 0;
uint8 m_cmd = 0;
uint8 m_regs = 0;
uint8 m_regsTemp = 0;
uint64 m_regList = 0;
bool m_eop = false;
2018-04-30 21:01:23 +01:00
uint32 m_qtemp;
SIGNAL_STATE m_signalState = SIGNAL_STATE_NONE;
MASKED_PATH3_XFER_STATE m_maskedPath3XferState = MASKED_PATH3_XFER_NONE;
int32 m_path3XferActiveTicks = 0;
2022-07-21 09:46:19 -04:00
uint8 m_fifoBuffer[FIFO_SIZE];
uint32 m_fifoIndex = 0;
2018-04-30 21:01:23 +01:00
uint8* m_ram;
uint8* m_spr;
CGSHandler*& m_gs;
CDMAC& m_dmac;
CProfiler::ZoneHandle m_gifProfilerZone = 0;
};