1
/* FakeNES - A free, portable, Open Source NES emulator.
3
apu_int.h: Internal declarations for the APU emulation.
5
Copyright (c) 2001-2007, FakeNES Team.
6
This is free software. See 'LICENSE' for details.
7
You must read and accept the license prior to use. */
9
#ifndef APU_INT_H_INCLUDED
10
#define APU_INT_H_INCLUDED
15
// Maximum number of channels to send to the DSP (mono = 1, stereo = 2).
16
#define APU_MIXER_MAX_CHANNELS 2
35
bool increment; // do not save
43
uint8 volume; // do not save for triangle
45
bool silence; // do not save for triangle
52
class APUWaveformChannel : public APUChannel {
54
// Length counter (all except dmc).
59
class APUSquare : public APUWaveformChannel {
61
// Envelope generator (square/noise).
66
// Sequencer (squares/triangle).
69
// Square wave generator.
73
class APUTriangle : public APUWaveformChannel {
75
// Sequencer (squares/triangle).
81
uint8 cached_linear_length;
84
class APUNoise : public APUWaveformChannel {
86
// Envelope generator (squares/noise).
94
class APUDMC : public APUChannel {
99
uint16 cached_address;
100
uint16 cached_dmalength;
115
// Mixer environment for the low pass filter.
116
typedef struct _APULPFilter {
121
// Mixer environment for the DC blocking filter.
122
typedef struct _APUDCFilter {
125
real next_filter_sample;
134
// Timestamp of the last call to process().
135
cpu_time_t clock_counter;
138
cpu_time_t prediction_timestamp;
139
cpu_time_t prediction_cycles;
141
// Frame sequencer & frame IRQs.
142
int16 sequence_counter;
144
uint8 sequence_steps;
146
bool frame_irq_occurred;
150
APUTriangle triangle;
154
// Delta value for timers.
155
cpu_time_t timer_delta; // do not save
158
struct { // do not save any of this
160
cpu_time_t delta_cycles;
161
real inputs[APU_MIXER_MAX_CHANNELS];
162
real accumulators[APU_MIXER_MAX_CHANNELS];
163
real sample_cache[APU_MIXER_MAX_CHANNELS];
164
real accumulated_samples;
167
// Filtering environments.
168
APULPFilter lpEnv[APU_MIXER_MAX_CHANNELS];
169
APUDCFilter dcEnv[APU_MIXER_MAX_CHANNELS];
174
#endif //!APU_INT_H_INCLUDED