Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/vbanext/instance.h
2 views
1
#ifndef INSTANCE_H
2
#define INSTANCE_H
3
4
struct FrontEndSettings
5
{
6
int cpuSaveType; // [0auto] 1eeprom 2sram 3flash 4eeprom+sensor 5none
7
int flashSize; // [0x10000] 0x20000
8
int enableRtc; // [false] true
9
int mirroringEnable; // [false] true
10
int skipBios; // [false] true
11
12
int RTCuseRealTime;
13
int RTCyear; // 00..99
14
int RTCmonth; // 00..11
15
int RTCmday; // 01..31
16
int RTCwday; // 00..06
17
int RTChour; // 00..23
18
int RTCmin; // 00..59
19
int RTCsec; // 00..59
20
21
};
22
23
struct MemoryAreas
24
{
25
void *bios;
26
void *iwram;
27
void *ewram;
28
void *palram;
29
void *vram;
30
void *oam;
31
void *rom;
32
void *mmio;
33
void *sram;
34
uint32_t sram_size;
35
};
36
37
#define FLASH_128K_SZ 0x20000
38
39
#define EEPROM_IDLE 0
40
#define EEPROM_READADDRESS 1
41
#define EEPROM_READDATA 2
42
#define EEPROM_READDATA2 3
43
#define EEPROM_WRITEDATA 4
44
45
enum {
46
IMAGE_UNKNOWN,
47
IMAGE_GBA
48
};
49
50
#define SGCNT0_H 0x82
51
#define FIFOA_L 0xa0
52
#define FIFOA_H 0xa2
53
#define FIFOB_L 0xa4
54
#define FIFOB_H 0xa6
55
56
#define BLIP_BUFFER_ACCURACY 16
57
#define BLIP_PHASE_BITS 8
58
#define BLIP_WIDEST_IMPULSE_ 16
59
#define BLIP_BUFFER_EXTRA_ 18
60
#define BLIP_RES 256
61
#define BLIP_RES_MIN_ONE 255
62
#define BLIP_SAMPLE_BITS 30
63
#define BLIP_READER_DEFAULT_BASS 9
64
#define BLIP_DEFAULT_LENGTH 250 /* 1/4th of a second */
65
66
#define BUFS_SIZE 3
67
#define STEREO 2
68
69
#define CLK_MUL GB_APU_OVERCLOCK
70
#define CLK_MUL_MUL_2 8
71
#define CLK_MUL_MUL_4 16
72
#define CLK_MUL_MUL_6 24
73
#define CLK_MUL_MUL_8 32
74
#define CLK_MUL_MUL_15 60
75
#define CLK_MUL_MUL_32 128
76
#define DAC_BIAS 7
77
78
#define PERIOD_MASK 0x70
79
#define SHIFT_MASK 0x07
80
81
#define PERIOD2_MASK 0x1FFFF
82
83
#define BANK40_MASK 0x40
84
#define BANK_SIZE 32
85
#define BANK_SIZE_MIN_ONE 31
86
#define BANK_SIZE_DIV_TWO 16
87
88
/* 11-bit frequency in NRx3 and NRx4*/
89
#define GB_OSC_FREQUENCY() (((regs[4] & 7) << 8) + regs[3])
90
91
#define WAVE_TYPE 0x100
92
#define NOISE_TYPE 0x200
93
#define MIXED_TYPE WAVE_TYPE | NOISE_TYPE
94
#define TYPE_INDEX_MASK 0xFF
95
96
#define BITS_16 0
97
#define BITS_32 1
98
99
#define R13_IRQ 18
100
#define R14_IRQ 19
101
#define SPSR_IRQ 20
102
#define R13_USR 26
103
#define R14_USR 27
104
#define R13_SVC 28
105
#define R14_SVC 29
106
#define SPSR_SVC 30
107
#define R13_ABT 31
108
#define R14_ABT 32
109
#define SPSR_ABT 33
110
#define R13_UND 34
111
#define R14_UND 35
112
#define SPSR_UND 36
113
#define R8_FIQ 37
114
#define R9_FIQ 38
115
#define R10_FIQ 39
116
#define R11_FIQ 40
117
#define R12_FIQ 41
118
#define R13_FIQ 42
119
#define R14_FIQ 43
120
#define SPSR_FIQ 44
121
122
typedef struct {
123
uint8_t *address;
124
uint32_t mask;
125
} memoryMap;
126
127
typedef union {
128
struct {
129
#ifdef LSB_FIRST
130
uint8_t B0;
131
uint8_t B1;
132
uint8_t B2;
133
uint8_t B3;
134
#else
135
uint8_t B3;
136
uint8_t B2;
137
uint8_t B1;
138
uint8_t B0;
139
#endif
140
} B;
141
struct {
142
#ifdef LSB_FIRST
143
uint16_t W0;
144
uint16_t W1;
145
#else
146
uint16_t W1;
147
uint16_t W0;
148
#endif
149
} W;
150
#ifdef LSB_FIRST
151
uint32_t I;
152
#else
153
volatile uint32_t I;
154
#endif
155
} reg_pair;
156
157
typedef struct
158
{
159
reg_pair reg[45];
160
bool busPrefetch;
161
bool busPrefetchEnable;
162
uint32_t busPrefetchCount;
163
uint32_t armNextPC;
164
} bus_t;
165
166
typedef struct
167
{
168
uint8_t paletteRAM[0x400];
169
int layerEnable;
170
int layerEnableDelay;
171
int lcdTicks;
172
} graphics_t;
173
174
/* Begins reading from buffer. Name should be unique to the current block.*/
175
#define BLIP_READER_BEGIN( name, blip_buffer ) \
176
const int32_t * name##_reader_buf = (blip_buffer).buffer_;\
177
int32_t name##_reader_accum = (blip_buffer).reader_accum_
178
179
/* Advances to next sample*/
180
#define BLIP_READER_NEXT( name, bass ) \
181
(void) (name##_reader_accum += *name##_reader_buf++ - (name##_reader_accum >> (bass)))
182
183
/* Ends reading samples from buffer. The number of samples read must now be removed
184
using Blip_Buffer::remove_samples(). */
185
#define BLIP_READER_END( name, blip_buffer ) \
186
(void) ((blip_buffer).reader_accum_ = name##_reader_accum)
187
188
#define BLIP_READER_ADJ_( name, offset ) (name##_reader_buf += offset)
189
190
#define BLIP_READER_NEXT_IDX_( name, idx ) {\
191
name##_reader_accum -= name##_reader_accum >> BLIP_READER_DEFAULT_BASS;\
192
name##_reader_accum += name##_reader_buf [(idx)];\
193
}
194
195
#define BLIP_READER_NEXT_RAW_IDX_( name, idx ) {\
196
name##_reader_accum -= name##_reader_accum >> BLIP_READER_DEFAULT_BASS; \
197
name##_reader_accum += *(int32_t const*) ((char const*) name##_reader_buf + (idx)); \
198
}
199
200
#if defined (_M_IX86) || defined (_M_IA64) || defined (__i486__) || \
201
defined (__x86_64__) || defined (__ia64__) || defined (__i386__)
202
#define BLIP_CLAMP_( in ) in < -0x8000 || 0x7FFF < in
203
#else
204
#define BLIP_CLAMP_( in ) (int16_t) in != in
205
#endif
206
207
/* Clamp sample to int16_t range */
208
#define BLIP_CLAMP( sample, out ) { if ( BLIP_CLAMP_( (sample) ) ) (out) = ((sample) >> 24) ^ 0x7FFF; }
209
#define GB_ENV_DAC_ENABLED() (regs[2] & 0xF8) /* Non-zero if DAC is enabled*/
210
#define GB_NOISE_PERIOD2_INDEX() (regs[3] >> 4)
211
#define GB_NOISE_PERIOD2(base) (base << GB_NOISE_PERIOD2_INDEX())
212
#define GB_NOISE_LFSR_MASK() ((regs[3] & 0x08) ? ~0x4040 : ~0x4000)
213
#define GB_WAVE_DAC_ENABLED() (regs[0] & 0x80) /* Non-zero if DAC is enabled*/
214
215
#define reload_sweep_timer() \
216
sweep_delay = (regs [0] & PERIOD_MASK) >> 4; \
217
if ( !sweep_delay ) \
218
sweep_delay = 8;
219
220
221
#ifdef __LIBRETRO__
222
#define PIX_BUFFER_SCREEN_WIDTH 256
223
#else
224
#define PIX_BUFFER_SCREEN_WIDTH 240
225
#endif
226
227
#endif
228
229