summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2021-02-17 11:19:50 +0100
committerMichael Forney <mforney@mforney.org>2021-02-17 11:19:50 +0100
commitf1d29a9d12fa6d89015735ea010ac4b02f1b80b5 (patch)
treeb64b54c08533e152b503e6cd97a042f1c07666ca
parent52b54097bf23ed4f14e82ff21b24f39827055448 (diff)
downloadplan9front-f1d29a9d12fa6d89015735ea010ac4b02f1b80b5.tar.xz
games/snes: implement DSP noise
I'm not sure if this LFSR is the same one used by the hardware or is arbitrary, but it matches the noise sequence used by all other snes emulators I looked at.
-rw-r--r--sys/src/games/snes/dsp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/src/games/snes/dsp.c b/sys/src/games/snes/dsp.c
index 13406d216..4b5c0cfd2 100644
--- a/sys/src/games/snes/dsp.c
+++ b/sys/src/games/snes/dsp.c
@@ -6,7 +6,7 @@
#include "fns.h"
u8int dsp[256], dspstate;
-u16int dspcounter, noise;
+u16int dspcounter, noise = 0x8000;
static s16int samp[2], echoin[2];
enum {
@@ -517,6 +517,8 @@ dspstep(void)
}
if(dspcounter-- == 0)
dspcounter = 0x77ff;
+ if(envyes(dsp[FLG] & 0x1f))
+ noise = (noise << 13 ^ noise << 14) & 0x8000 | noise >> 1 & ~1;
break;
case 31: voice(0, 4); voice(2, 1); break;
}