-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtypes.h
185 lines (169 loc) · 3.56 KB
/
types.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#ifndef _TYPES_H
#define _TYPES_H
#if defined(__EMSCRIPTEN__)
#include <SDL2/SDL.h>
#elif defined(_MSC_VER)
#include <SDL/SDL.h>
#else
#include <SDL2/SDL.h>
#endif
#ifdef __GNUC__ /*__GNUC__*/
typedef unsigned long long ClockCycle;
#define TSTATE_T_MID (((long long) -1LL)/2ULL)
#define TSTATE_T_LEN "Lu"
#else
typedef unsigned __int64 ClockCycle;
#define TSTATE_T_MID (((__int64) -1L)/2UL)
#define TSTATE_T_LEN "lu"
#endif
#ifndef MAX
#define MAX(A,B) ((A) > (B) ? (A) : (B))
#endif
#ifndef MIN
#define MIN(A,B) ((A) < (B) ? (A) : (B))
#endif
typedef struct _MEM_PATCH {
unsigned int addr;
unsigned char byte;
} mem_patch_t;
enum RvarTypes {
RVAR_NULL,
RVAR_TOGGLE,
RVAR_INT,
RVAR_HEX,
RVAR_STRING,
RVAR_STRING_FLIPLIST,
RVAR_VARIANT
};
typedef struct _RVAR {
char menuName[32];
char resourceName[32];
void (*callback)(void *);
void *value;
RvarTypes type;
const char *(*label)();
} rvar_t;
extern rvar_t *settings[];
/* WAV file header structure */
/* should be 1-byte aligned */
#pragma pack(1)
typedef struct _WAV_HEADER {
char riff[4];
unsigned int rLen;
char WAVEfmt[8];
unsigned int fLen; /* 0x1020 */
unsigned short wFormatTag; /* 0x0001 */
unsigned short nChannels; /* 0x0001 */
unsigned int nSamplesPerSec;
unsigned int nAvgBytesPerSec; // nSamplesPerSec*nChannels*(nBitsPerSample%8)
unsigned short nBlockAlign; /* 0x0001 */
unsigned short nBitsPerSample; /* 0x0008 */
char datastr[4];
unsigned int data_size;
} wav_header_t;
#pragma pack()
typedef void(*CallBackFunctor)(void *);
typedef void(*CallBackFunctorInt8)(void* , unsigned char);
typedef unsigned char(*CallBackReadMemory)(unsigned short);
// Simple linked list class
template<typename T>
class LinkedList {
private:
T *next;
static T *root;
static T *last;
static unsigned int count;
public:
LinkedList() {
count++;
}
~LinkedList() {
count--;
}
static T *getRoot() { return root; }
T *getNext() { return next; }
void add(T *ss) {
if (root) {
last = last->next = ss;
} else {
last = root = ss;
}
next = 0;
}
void remove(T *ss) {
T *prevNode;
T *nextNode;
T *node = root;
if (!node)
return;
prevNode = root;
do {
nextNode = node->next;
if (node == ss) {
if (node == root) {
root = nextNode;
if (!root)
last = 0;
}
if (node == last)
last = prevNode;
if (prevNode) {
prevNode->next = nextNode;
if (nextNode == last)
last = nextNode;
}
}
prevNode = node;
node = nextNode;
} while (node);
}
// void cascadeCall()
};
class Resettable : public LinkedList<Resettable> {
public:
Resettable() {
add(this);
}
~Resettable() {
remove(this);
}
void resetAll(bool hard = false) {
Resettable *rs = getRoot();
while (rs) {
rs->reset(hard);
rs->getNext();
}
}
virtual void reset(bool hard) = 0;
};
class MemoryHandler;
class Debuggable : public LinkedList<Debuggable> {
public:
Debuggable() {
add(this);
}
~Debuggable() {
remove(this);
}
Debuggable *cycleToNext(Debuggable *d) {
if (d) {
Debuggable *n = d->getNext();
if (!n)
n = getRoot();
return n;
}
else
return getRoot();
}
virtual int disassemble(int pc, char *line) = 0;
virtual void step() = 0;
virtual unsigned int getProgramCounter() = 0;
virtual MemoryHandler &getMem() = 0;
virtual unsigned int getcycle() = 0;
virtual void regDump(char *line, int rowcount) = 0;
virtual const char *getName() = 0;
};
//template<> unsigned int LinkedList<Resettable>::count = 0;
//template<> Resettable* LinkedList<Resettable>::root = 0;
//template<> Resettable* LinkedList<Resettable>::last = 0;
#endif // _TYPES_H