Replace soundbias with a bitfield

This commit is contained in:
Jeffrey Pfau 2014-10-17 03:26:47 -07:00
parent 8c02615593
commit 3bf43133cb
2 changed files with 7 additions and 10 deletions

View File

@ -672,13 +672,13 @@ static int32_t _updateChannel4(struct GBAAudioChannel4* ch) {
} }
static int _applyBias(struct GBAAudio* audio, int sample) { static int _applyBias(struct GBAAudio* audio, int sample) {
sample += audio->bias; sample += GBARegisterSOUNDBIASGetBias(audio->soundbias);
if (sample >= 0x400) { if (sample >= 0x400) {
sample = 0x3FF; sample = 0x3FF;
} else if (sample < 0) { } else if (sample < 0) {
sample = 0; sample = 0;
} }
return (sample - audio->bias) << 6; return (sample - GBARegisterSOUNDBIASGetBias(audio->soundbias)) << 6;
} }
static void _sample(struct GBAAudio* audio) { static void _sample(struct GBAAudio* audio) {

View File

@ -157,6 +157,10 @@ DECL_BIT(GBARegisterSOUNDCNT_X, PlayingCh3, 2);
DECL_BIT(GBARegisterSOUNDCNT_X, PlayingCh4, 3); DECL_BIT(GBARegisterSOUNDCNT_X, PlayingCh4, 3);
DECL_BIT(GBARegisterSOUNDCNT_X, Enable, 7); DECL_BIT(GBARegisterSOUNDCNT_X, Enable, 7);
DECL_BITFIELD(GBARegisterSOUNDBIAS, uint16_t);
DECL_BITS(GBARegisterSOUNDBIAS, Bias, 0, 10);
DECL_BITS(GBARegisterSOUNDBIAS, Resolution, 14, 2);
struct GBAAudio { struct GBAAudio {
struct GBA* p; struct GBA* p;
@ -200,14 +204,7 @@ struct GBAAudio {
unsigned sampleRate; unsigned sampleRate;
union { GBARegisterSOUNDBIAS soundbias;
struct {
unsigned bias : 10;
unsigned : 4;
unsigned resolution : 2;
};
uint16_t soundbias;
};
int32_t nextEvent; int32_t nextEvent;
int32_t eventDiff; int32_t eventDiff;