git: 9front

Download patch

ref: 340c6f84ee6574a81534518b670e8e7251935c2d
parent: 85e593d4dd9252c29afd82d0925e578af51877da
author: Michael Forney <mforney@mforney.org>
date: Wed Feb 17 06:19:50 EST 2021

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.

--- 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 @@
 		}
 		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;
 	}
--