-
-
Notifications
You must be signed in to change notification settings - Fork 270
/
Copy pathGIF.h
125 lines (101 loc) · 2.49 KB
/
GIF.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#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
{
GIF_MODE = 0x10003010,
GIF_STAT = 0x10003020
};
enum
{
GIF_STAT_M3P = 0x002,
GIF_STAT_OPH = 0x200,
GIF_STAT_APATH3 = 0xC00,
};
enum
{
REGS_START = 0x10003000,
REGS_END = 0x100030B0,
GIF_FIFO_START = 0x10006000,
GIF_FIFO_END = 0x10006FFF,
};
struct TAG
{
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*);
virtual ~CGIF() = default;
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);
uint32 GetRegister(uint32);
void SetRegister(uint32, uint32);
CGSHandler* GetGsHandler();
uint32 GetActivePath() const;
void SetPath3Masked(bool);
void LoadState(Framework::CZipArchiveReader&);
void SaveState(Framework::CZipArchiveWriter&);
private:
enum
{
FIFO_QWC = 0x10,
FIFO_SIZE = FIFO_QWC * 0x10,
};
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);
void ProcessFifoWrite(uint32, uint32);
void DrainFifo();
void DisassembleGet(uint32);
void DisassembleSet(uint32, uint32);
bool m_path3Masked = false;
uint32 m_activePath = 0;
uint32 m_MODE = 0;
uint16 m_loops = 0;
uint8 m_cmd = 0;
uint8 m_regs = 0;
uint8 m_regsTemp = 0;
uint64 m_regList = 0;
bool m_eop = false;
uint32 m_qtemp;
SIGNAL_STATE m_signalState = SIGNAL_STATE_NONE;
MASKED_PATH3_XFER_STATE m_maskedPath3XferState = MASKED_PATH3_XFER_NONE;
int32 m_path3XferActiveTicks = 0;
uint8 m_fifoBuffer[FIFO_SIZE];
uint32 m_fifoIndex = 0;
uint8* m_ram;
uint8* m_spr;
CGSHandler*& m_gs;
CDMAC& m_dmac;
CProfiler::ZoneHandle m_gifProfilerZone = 0;
};