Skip to content

Commit 1528411

Browse files
committed
Merge commit '5b966cfa306be958d767b16b343a6d842cdab651'
2 parents e6f3888 + 5b966cf commit 1528411

File tree

16 files changed

+547
-238
lines changed

16 files changed

+547
-238
lines changed

thirdparty/SameBoy/Core/apu.c

Lines changed: 147 additions & 102 deletions
Large diffs are not rendered by default.

thirdparty/SameBoy/Core/apu.h

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,68 +54,68 @@ typedef struct
5454
{
5555
bool global_enable;
5656
uint8_t apu_cycles;
57-
57+
5858
uint8_t samples[GB_N_CHANNELS];
5959
bool is_active[GB_N_CHANNELS];
60-
60+
6161
uint8_t div_divider; // The DIV register ticks the APU at 512Hz, but is then divided
6262
// once more to generate 128Hz and 64Hz clocks
63-
63+
6464
uint8_t lf_div; // The APU runs in 2MHz, but channels 1, 2 and 4 run in 1MHZ so we divide
6565
// need to divide the signal.
66-
66+
6767
uint8_t square_sweep_countdown; // In 128Hz
6868
uint8_t square_sweep_calculate_countdown; // In 2 MHz
6969
uint16_t new_sweep_sample_legnth;
7070
uint16_t shadow_sweep_sample_legnth;
7171
bool sweep_enabled;
7272
bool sweep_decreasing;
73-
73+
7474
struct {
7575
uint16_t pulse_length; // Reloaded from NRX1 (xorred), in 256Hz DIV ticks
7676
uint8_t current_volume; // Reloaded from NRX2
7777
uint8_t volume_countdown; // Reloaded from NRX2
7878
uint8_t current_sample_index; /* For save state compatibility,
7979
highest bit is reused (See NR14/NR24's
8080
write code)*/
81-
81+
8282
uint16_t sample_countdown; // in APU ticks (Reloaded from sample_length, xorred $7FF)
8383
uint16_t sample_length; // From NRX3, NRX4, in APU ticks
8484
bool length_enabled; // NRX4
8585

8686
} square_channels[2];
87-
87+
8888
struct {
8989
bool enable; // NR30
9090
uint16_t pulse_length; // Reloaded from NR31 (xorred), in 256Hz DIV ticks
9191
uint8_t shift; // NR32
9292
uint16_t sample_length; // NR33, NR34, in APU ticks
9393
bool length_enabled; // NR34
94-
94+
9595
uint16_t sample_countdown; // in APU ticks (Reloaded from sample_length, xorred $7FF)
9696
uint8_t current_sample_index;
9797
uint8_t current_sample; // Current sample before shifting.
98-
98+
9999
int8_t wave_form[32];
100100
bool wave_form_just_read;
101101
} wave_channel;
102-
102+
103103
struct {
104104
uint16_t pulse_length; // Reloaded from NR41 (xorred), in 256Hz DIV ticks
105105
uint8_t current_volume; // Reloaded from NR42
106106
uint8_t volume_countdown; // Reloaded from NR42
107107
uint16_t lfsr;
108108
bool narrow;
109-
109+
110110
uint16_t sample_countdown; // in APU ticks (Reloaded from sample_length)
111111
uint16_t sample_length; // From NR43, in APU ticks
112112
bool length_enabled; // NR44
113-
113+
114114
uint8_t alignment; // If (NR43 & 7) != 0, samples are aligned to 512KHz clock instead of
115115
// 1MHz. This variable keeps track of the alignment.
116-
116+
117117
} noise_channel;
118-
118+
119119
bool skip_div_event;
120120
bool current_lfsr_sample;
121121
bool previous_lfsr_sample;
@@ -130,25 +130,25 @@ typedef enum {
130130

131131
typedef struct {
132132
unsigned sample_rate;
133-
133+
134134
GB_sample_t *buffer;
135135
size_t buffer_size;
136136
size_t buffer_position;
137-
137+
138138
bool stream_started; /* detects first copy request to minimize lag */
139139
volatile bool copy_in_progress;
140140
volatile bool lock;
141-
141+
142142
double sample_cycles; // In 8 MHz units
143143
double cycles_per_sample;
144-
144+
145145
// Samples are NOT normalized to MAX_CH_AMP * 4 at this stage!
146146
unsigned cycles_since_render;
147147
unsigned last_update[GB_N_CHANNELS];
148148
GB_sample_t current_sample[GB_N_CHANNELS];
149149
GB_sample_t summed_samples[GB_N_CHANNELS];
150150
double dac_discharge[GB_N_CHANNELS];
151-
151+
152152
GB_highpass_mode_t highpass_mode;
153153
double highpass_rate;
154154
GB_double_sample_t highpass_diff;
@@ -160,6 +160,7 @@ size_t GB_apu_get_current_buffer_length(GB_gameboy_t *gb);
160160
void GB_set_highpass_filter_mode(GB_gameboy_t *gb, GB_highpass_mode_t mode);
161161

162162
#ifdef GB_INTERNAL
163+
bool GB_apu_is_DAC_enabled(GB_gameboy_t *gb, unsigned index);
163164
void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value);
164165
uint8_t GB_apu_read(GB_gameboy_t *gb, uint8_t reg);
165166
void GB_apu_div_event(GB_gameboy_t *gb);

0 commit comments

Comments
 (0)