mirror of https://github.com/mgba-emu/mgba.git
Replace soundbias with a bitfield
This commit is contained in:
parent
8c02615593
commit
3bf43133cb
|
@ -672,13 +672,13 @@ static int32_t _updateChannel4(struct GBAAudioChannel4* ch) {
|
|||
}
|
||||
|
||||
static int _applyBias(struct GBAAudio* audio, int sample) {
|
||||
sample += audio->bias;
|
||||
sample += GBARegisterSOUNDBIASGetBias(audio->soundbias);
|
||||
if (sample >= 0x400) {
|
||||
sample = 0x3FF;
|
||||
} else if (sample < 0) {
|
||||
sample = 0;
|
||||
}
|
||||
return (sample - audio->bias) << 6;
|
||||
return (sample - GBARegisterSOUNDBIASGetBias(audio->soundbias)) << 6;
|
||||
}
|
||||
|
||||
static void _sample(struct GBAAudio* audio) {
|
||||
|
|
|
@ -157,6 +157,10 @@ DECL_BIT(GBARegisterSOUNDCNT_X, PlayingCh3, 2);
|
|||
DECL_BIT(GBARegisterSOUNDCNT_X, PlayingCh4, 3);
|
||||
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 GBA* p;
|
||||
|
||||
|
@ -200,14 +204,7 @@ struct GBAAudio {
|
|||
|
||||
unsigned sampleRate;
|
||||
|
||||
union {
|
||||
struct {
|
||||
unsigned bias : 10;
|
||||
unsigned : 4;
|
||||
unsigned resolution : 2;
|
||||
};
|
||||
uint16_t soundbias;
|
||||
};
|
||||
GBARegisterSOUNDBIAS soundbias;
|
||||
|
||||
int32_t nextEvent;
|
||||
int32_t eventDiff;
|
||||
|
|
Loading…
Reference in New Issue