all repos — mgba @ 3bf43133cb64a020a6fbfdcc5bbbcf2c4b334a4e

mGBA Game Boy Advance Emulator

Replace soundbias with a bitfield
Jeffrey Pfau jeffrey@endrift.com
Fri, 17 Oct 2014 03:26:47 -0700
commit

3bf43133cb64a020a6fbfdcc5bbbcf2c4b334a4e

parent

8c02615593484913353dd4806189357710945384

2 files changed, 7 insertions(+), 10 deletions(-)

jump to
M src/gba/gba-audio.csrc/gba/gba-audio.c

@@ -672,13 +672,13 @@ return timing;

} 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) {
M src/gba/gba-audio.hsrc/gba/gba-audio.h

@@ -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 @@ bool enable;

unsigned sampleRate; - union { - struct { - unsigned bias : 10; - unsigned : 4; - unsigned resolution : 2; - }; - uint16_t soundbias; - }; + GBARegisterSOUNDBIAS soundbias; int32_t nextEvent; int32_t eventDiff;