mirror of https://github.com/mgba-emu/mgba.git
Rename GBAAudioWave to GBAAudioEnvelope, add fields for internal state
This commit is contained in:
parent
7393351e27
commit
d99bf7fdff
|
@ -25,6 +25,8 @@ void GBAAudioInit(struct GBAAudio* audio) {
|
|||
audio->eventDiff = 0;
|
||||
audio->nextSample = 0;
|
||||
audio->sampleRate = 0x8000;
|
||||
audio->soundcntLo = 0;
|
||||
audio->soundcntHi = 0;
|
||||
audio->sampleInterval = GBA_ARM7TDMI_FREQUENCY / audio->sampleRate;
|
||||
|
||||
CircleBufferInit(&audio->left, GBA_AUDIO_SAMPLES * sizeof(int32_t));
|
||||
|
@ -107,7 +109,7 @@ void GBAAudioWriteSOUND1CNT_LO(struct GBAAudio* audio, uint16_t value) {
|
|||
}
|
||||
|
||||
void GBAAudioWriteSOUND1CNT_HI(struct GBAAudio* audio, uint16_t value) {
|
||||
audio->ch1.wave.packed = value;
|
||||
audio->ch1.envelope.packed = value;
|
||||
}
|
||||
|
||||
void GBAAudioWriteSOUND1CNT_X(struct GBAAudio* audio, uint16_t value) {
|
||||
|
@ -115,7 +117,7 @@ void GBAAudioWriteSOUND1CNT_X(struct GBAAudio* audio, uint16_t value) {
|
|||
}
|
||||
|
||||
void GBAAudioWriteSOUND2CNT_LO(struct GBAAudio* audio, uint16_t value) {
|
||||
audio->ch2.wave.packed = value;
|
||||
audio->ch2.envelope.packed = value;
|
||||
}
|
||||
|
||||
void GBAAudioWriteSOUND2CNT_HI(struct GBAAudio* audio, uint16_t value) {
|
||||
|
@ -135,7 +137,7 @@ void GBAAudioWriteSOUND3CNT_X(struct GBAAudio* audio, uint16_t value) {
|
|||
}
|
||||
|
||||
void GBAAudioWriteSOUND4CNT_LO(struct GBAAudio* audio, uint16_t value) {
|
||||
audio->ch4.wave.packed = value;
|
||||
audio->ch4.envelope.packed = value;
|
||||
}
|
||||
|
||||
void GBAAudioWriteSOUND4CNT_HI(struct GBAAudio* audio, uint16_t value) {
|
||||
|
|
|
@ -10,7 +10,8 @@ struct GBADMA;
|
|||
|
||||
const unsigned GBA_AUDIO_SAMPLES;
|
||||
|
||||
union GBAAudioWave {
|
||||
struct GBAAudioEnvelope {
|
||||
union {
|
||||
struct {
|
||||
unsigned length : 6;
|
||||
unsigned duty : 2;
|
||||
|
@ -20,6 +21,9 @@ union GBAAudioWave {
|
|||
};
|
||||
uint16_t packed;
|
||||
};
|
||||
int currentVolume;
|
||||
int32_t nextStep;
|
||||
};
|
||||
|
||||
union GBAAudioSquareControl {
|
||||
struct {
|
||||
|
@ -42,12 +46,12 @@ struct GBAAudioChannel1 {
|
|||
uint16_t packed;
|
||||
} sweep;
|
||||
|
||||
union GBAAudioWave wave;
|
||||
struct GBAAudioEnvelope envelope;
|
||||
union GBAAudioSquareControl control;
|
||||
};
|
||||
|
||||
struct GBAAudioChannel2 {
|
||||
union GBAAudioWave wave;
|
||||
struct GBAAudioEnvelope envelope;
|
||||
union GBAAudioSquareControl control;
|
||||
};
|
||||
|
||||
|
@ -86,7 +90,7 @@ struct GBAAudioChannel3 {
|
|||
};
|
||||
|
||||
struct GBAAudioChannel4 {
|
||||
union GBAAudioWave wave;
|
||||
struct GBAAudioEnvelope envelope;
|
||||
union {
|
||||
struct {
|
||||
unsigned ratio : 3;
|
||||
|
|
Loading…
Reference in New Issue