Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/base/base.hpp
2 views
1
#ifndef BASE_HPP
2
#define BASE_HPP
3
4
const char Version[] = "087";
5
6
#include <nall/platform.hpp>
7
#include <nall/algorithm.hpp>
8
#include <nall/any.hpp>
9
#include <nall/array.hpp>
10
#include <nall/dl.hpp>
11
#include <nall/dsp.hpp>
12
#include <nall/endian.hpp>
13
#include <nall/file.hpp>
14
#include <nall/function.hpp>
15
#include <nall/moduloarray.hpp>
16
#include <nall/priorityqueue.hpp>
17
#include <nall/property.hpp>
18
#include <nall/random.hpp>
19
#include <nall/serializer.hpp>
20
#include <nall/stdint.hpp>
21
#include <nall/string.hpp>
22
#include <nall/utility.hpp>
23
#include <nall/varint.hpp>
24
#include <nall/vector.hpp>
25
using namespace nall;
26
27
//debugging function hook:
28
//no overhead (and no debugger invocation) if not compiled with -DDEBUGGER
29
//wraps testing of function to allow invocation without a defined callback
30
template<typename T> struct hook;
31
template<typename R, typename... P> struct hook<R (P...)> {
32
function<R (P...)> callback;
33
34
R operator()(P... p) const {
35
#if defined(DEBUGGER) || defined(HOOKS)
36
if(callback) return callback(std::forward<P>(p)...);
37
#endif
38
return R();
39
}
40
41
hook() {}
42
hook(const hook &hook) { callback = hook.callback; }
43
hook(void *function) { callback = function; }
44
hook(R (*function)(P...)) { callback = function; }
45
template<typename C> hook(R (C::*function)(P...), C *object) { callback = { function, object }; }
46
template<typename C> hook(R (C::*function)(P...) const, C *object) { callback = { function, object }; }
47
template<typename L> hook(const L& function) { callback = function; }
48
49
hook& operator=(const hook& hook) { callback = hook.callback; return *this; }
50
};
51
52
#if defined(DEBUGGER)
53
#define privileged public
54
#else
55
#define privileged private
56
#endif
57
58
enum eCDLog_AddrType
59
{
60
eCDLog_AddrType_CARTROM, eCDLog_AddrType_CARTRAM, eCDLog_AddrType_WRAM, eCDLog_AddrType_APURAM,
61
eCDLog_AddrType_NUM
62
};
63
64
enum eCDLog_Flags
65
{
66
eCDLog_Flags_None = 0x00,
67
eCDLog_Flags_ExecFirst = 0x01,
68
eCDLog_Flags_ExecOperand = 0x02,
69
eCDLog_Flags_CPUData = 0x04,
70
eCDLog_Flags_DMAData = 0x08, //not supported yet
71
eCDLog_Flags_BRR = 0x80
72
};
73
74
struct CDLInfo
75
{
76
eCDLog_Flags currFlags;
77
uint8_t* blocks[eCDLog_AddrType_NUM]; //[0]==nullptr -> disabled
78
uint32_t blockSizes[eCDLog_AddrType_NUM];
79
void set(eCDLog_AddrType addrType, uint32_t addr)
80
{
81
if(!blocks[0]) return;
82
if(addr >= blockSizes[addrType])
83
return;
84
blocks[addrType][addr] |= currFlags;
85
}
86
};
87
88
extern CDLInfo cdlInfo;
89
inline bool wantCDL() { return cdlInfo.blocks[0] != nullptr; }
90
91
typedef int1_t int1;
92
typedef int2_t int2;
93
typedef int3_t int3;
94
typedef int4_t int4;
95
typedef int5_t int5;
96
typedef int6_t int6;
97
typedef int7_t int7;
98
typedef int8_t int8;
99
typedef int9_t int9;
100
typedef int10_t int10;
101
typedef int11_t int11;
102
typedef int12_t int12;
103
typedef int13_t int13;
104
typedef int14_t int14;
105
typedef int15_t int15;
106
typedef int16_t int16;
107
typedef int17_t int17;
108
typedef int18_t int18;
109
typedef int19_t int19;
110
typedef int20_t int20;
111
typedef int21_t int21;
112
typedef int22_t int22;
113
typedef int23_t int23;
114
typedef int24_t int24;
115
typedef int25_t int25;
116
typedef int26_t int26;
117
typedef int27_t int27;
118
typedef int28_t int28;
119
typedef int29_t int29;
120
typedef int30_t int30;
121
typedef int31_t int31;
122
typedef int32_t int32;
123
typedef int64_t int64;
124
125
typedef uint1_t uint1;
126
typedef uint2_t uint2;
127
typedef uint3_t uint3;
128
typedef uint4_t uint4;
129
typedef uint5_t uint5;
130
typedef uint6_t uint6;
131
typedef uint7_t uint7;
132
typedef uint8_t uint8;
133
typedef uint9_t uint9;
134
typedef uint10_t uint10;
135
typedef uint11_t uint11;
136
typedef uint12_t uint12;
137
typedef uint13_t uint13;
138
typedef uint14_t uint14;
139
typedef uint15_t uint15;
140
typedef uint16_t uint16;
141
typedef uint17_t uint17;
142
typedef uint18_t uint18;
143
typedef uint19_t uint19;
144
typedef uint20_t uint20;
145
typedef uint21_t uint21;
146
typedef uint22_t uint22;
147
typedef uint23_t uint23;
148
typedef uint24_t uint24;
149
typedef uint25_t uint25;
150
typedef uint26_t uint26;
151
typedef uint27_t uint27;
152
typedef uint28_t uint28;
153
typedef uint29_t uint29;
154
typedef uint30_t uint30;
155
typedef uint31_t uint31;
156
typedef uint32_t uint32;
157
typedef uint_t<33> uint33;
158
typedef uint64_t uint64;
159
160
typedef varuint_t varuint;
161
162
#endif
163
164