From b51d025f1c7342bad03777a1bb74ae7d8eb9e827 Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Sun, 8 Aug 2021 20:33:21 -0400 Subject: [PATCH 1/4] port cgb fakematching fixes (thanks to revo) --- src/m4a.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/m4a.c b/src/m4a.c index 105312a40c..ef4c2a537a 100644 --- a/src/m4a.c +++ b/src/m4a.c @@ -906,7 +906,6 @@ void CgbSound(void) { s32 ch; struct CgbChannel *channels; - s32 envelopeStepTimeAndDir; s32 prevC15; struct SoundInfo *soundInfo = SOUND_INFO_PTR; vu8 *nrx0ptr; @@ -914,6 +913,7 @@ void CgbSound(void) vu8 *nrx2ptr; vu8 *nrx3ptr; vu8 *nrx4ptr; + s32 envelopeStepTimeAndDir; // Most comparision operations that cast to s8 perform 'and' by 0xFF. int mask = 0xff; @@ -1198,8 +1198,8 @@ void CgbSound(void) } else { - envelopeStepTimeAndDir &= 0xf; - *nrx2ptr = (channels->envelopeVolume << 4) + envelopeStepTimeAndDir; + unsigned int newMask = 0xF; + *nrx2ptr = (envelopeStepTimeAndDir & newMask) + (channels->envelopeVolume << 4); *nrx4ptr = channels->n4 | 0x80; if (ch == 1 && !(*nrx0ptr & 0x08)) *nrx4ptr = channels->n4 | 0x80; From 0bceaab046b677b28e188e25a90cf2a7b02067df Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Sun, 8 Aug 2021 20:34:16 -0400 Subject: [PATCH 2/4] rename variable --- src/m4a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m4a.c b/src/m4a.c index ef4c2a537a..0c68c6bddd 100644 --- a/src/m4a.c +++ b/src/m4a.c @@ -1198,7 +1198,7 @@ void CgbSound(void) } else { - unsigned int newMask = 0xF; + unsigned int envMask = 0xF; *nrx2ptr = (envelopeStepTimeAndDir & newMask) + (channels->envelopeVolume << 4); *nrx4ptr = channels->n4 | 0x80; if (ch == 1 && !(*nrx0ptr & 0x08)) From ddb3911d0df42b424840dbe12e73b011b3be46b7 Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Sun, 8 Aug 2021 20:49:29 -0400 Subject: [PATCH 3/4] oops --- src/m4a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m4a.c b/src/m4a.c index 0c68c6bddd..9877ad7401 100644 --- a/src/m4a.c +++ b/src/m4a.c @@ -1199,7 +1199,7 @@ void CgbSound(void) else { unsigned int envMask = 0xF; - *nrx2ptr = (envelopeStepTimeAndDir & newMask) + (channels->envelopeVolume << 4); + *nrx2ptr = (envelopeStepTimeAndDir & envMask) + (channels->envelopeVolume << 4); *nrx4ptr = channels->n4 | 0x80; if (ch == 1 && !(*nrx0ptr & 0x08)) *nrx4ptr = channels->n4 | 0x80; From 2e892c6961d646244b6cf0397181ba3051fffb80 Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Sun, 8 Aug 2021 22:22:50 -0400 Subject: [PATCH 4/4] unsigned int -> u32 --- src/m4a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m4a.c b/src/m4a.c index 9877ad7401..b159e3873d 100644 --- a/src/m4a.c +++ b/src/m4a.c @@ -1198,7 +1198,7 @@ void CgbSound(void) } else { - unsigned int envMask = 0xF; + u32 envMask = 0xF; *nrx2ptr = (envelopeStepTimeAndDir & envMask) + (channels->envelopeVolume << 4); *nrx4ptr = channels->n4 | 0x80; if (ch == 1 && !(*nrx0ptr & 0x08))