-
Notifications
You must be signed in to change notification settings - Fork 3
/
stdfunc.h
113 lines (105 loc) · 3.47 KB
/
stdfunc.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
// Standard ROM/input/DIP info functions
// A function to pick a rom, or return NULL if i is out of range
#define STD_ROM_PICK(Name) \
struct BurnRomInfo* Name##PickRom(unsigned int i) \
{ \
if (i >= sizeof(Name##RomDesc) / sizeof(Name##RomDesc[0])) { \
return NULL; \
} \
return Name##RomDesc + i; \
}
#define STDROMPICKEXT(Name, Info1, Info2) \
struct BurnRomInfo* Name##PickRom(unsigned int i) \
{ \
if (i >= 0x80) { \
i &= 0x7F; \
if (i >= sizeof(Info2##RomDesc) / sizeof(Info2##RomDesc[0])) { \
return NULL; \
} \
return Info2##RomDesc + i; \
} else { \
if (i >= sizeof(Info1##RomDesc) / sizeof(Info1##RomDesc[0])) { \
return emptyRomDesc + 0; \
} \
return Info1##RomDesc + i; \
} \
}
// Standard rom functions for returning Length, Crc, Type and one one Name
#define STD_ROM_FN(Name) \
int Name##RomInfo(struct BurnRomInfo* pri, unsigned int i) \
{ \
struct BurnRomInfo* por = Name##PickRom(i); \
if (por == NULL) { \
return 1; \
} \
if (pri) { \
pri->nLen = por->nLen; \
pri->nCrc = por->nCrc; \
pri->nType = por->nType; \
} \
return 0; \
} \
\
int Name##RomName(char** pszName, unsigned int i, int nAka) \
{ \
struct BurnRomInfo *por = Name##PickRom(i); \
if (por == NULL) { \
return 1; \
} \
if (nAka) { \
return 1; \
} \
*pszName = por->szName; \
return 0; \
}
#define STDINPUTINFO(Name) \
int Name##InputInfo(struct BurnInputInfo* pii, unsigned int i) \
{ \
if (i >= sizeof(Name##InputList) / sizeof(Name##InputList[0])) { \
return 1; \
} \
if (pii) { \
*pii = Name##InputList[i]; \
} \
return 0; \
}
#define STDINPUTINFOSPEC(Name, Info1) \
int Name##InputInfo(struct BurnInputInfo* pii, unsigned int i) \
{ \
if (i >= sizeof(Info1) / sizeof(Info1[0])) { \
return 1; \
} \
if (pii) { \
*pii = Info1[i]; \
} \
return 0; \
}
#define STDDIPINFO(Name) \
int Name##DIPInfo(struct BurnDIPInfo* pdi, unsigned int i) \
{ \
if (i >= sizeof(Name##DIPList) / sizeof(Name##DIPList[0])) { \
return 1; \
} \
if (pdi) { \
*pdi = Name##DIPList[i]; \
} \
return 0; \
}
#define STDDIPINFOEXT(Name, Info1, Info2) \
int Name##DIPInfo(struct BurnDIPInfo* pdi, unsigned int i) \
{ \
if (i >= sizeof(Info1##DIPList) / sizeof(Info1##DIPList[0])) { \
i -= sizeof(Info1##DIPList) / sizeof(Info1##DIPList[0]); \
if (i >= sizeof(Info2##DIPList) / sizeof(Info2##DIPList[0])) { \
return 1; \
} \
if (pdi) { \
*pdi = Info2##DIPList[i]; \
} \
return 0; \
} \
if (pdi) { \
*pdi = Info1##DIPList[i]; \
} \
return 0; \
}