Better-sounding noise generator, Halls of Doom in Ultima 5 sounds much better

This commit is contained in:
Brendan Robert 2015-08-08 04:03:13 -05:00
parent e01a3049c2
commit 72dc7b5318
2 changed files with 4 additions and 1 deletions

View File

@ -39,6 +39,7 @@ public class NoiseGenerator extends TimedGenerator {
}
public static final int bit17 = 0x010000;
public void updateRng() {
// noise = (noise >> 1) ^ ((noise & 1) ? 0x14000 : 0);
int newBit17 = (rng & 0x04) > 0 == (rng & 0x01) > 0 ? bit17 : 0;
rng = newBit17 + (rng >> 1);
}

View File

@ -207,6 +207,7 @@ public class PSG {
/* Also, note that period = 0 is the same as period = 1. This is mentioned */
/* in the YM2203 data sheets. However, this does NOT apply to the Envelope */
/* period. In that case, period = 0 is half as period = 1. */
value = value & 0x0ff;
switch (r) {
case ACoarse:
case AFine:
@ -221,7 +222,8 @@ public class PSG {
channels.get(2).setPeriod(getReg(Reg.CFine) + (getReg(Reg.CCoarse) << 8));
break;
case NoisePeriod:
noiseGenerator.setPeriod(value);
if (value == 0) value = 32;
noiseGenerator.setPeriod(value+16);
noiseGenerator.counter = 0;
break;
case Enable: