Small minor changes that have been sitting around collecting dust

This commit is contained in:
Brendan Robert 2015-02-02 00:51:42 -06:00
parent d84396df72
commit 0f60a59df7
5 changed files with 10 additions and 7 deletions

View File

@ -86,9 +86,8 @@ public class Motherboard extends TimedDevice {
}
clockCounter = cpuPerClock;
computer.getVideo().doTick();
// Unrolled loop since this happens so often
for (Optional<Card> card : cards) {
card.ifPresent(Card::doTick);
card.ifPresent(c -> c.doTick());
}
miscDevices.stream().forEach((m) -> {
m.doTick();

View File

@ -36,6 +36,7 @@ public class EnvelopeGenerator extends TimedGenerator {
super(_clock, _sampleRate);
}
@Override
public int stepsPerCycle() {
return 8;
}
@ -104,6 +105,7 @@ public class EnvelopeGenerator extends TimedGenerator {
return amplitude;
}
@Override
public void reset() {
super.reset();
setShape(0);

View File

@ -28,6 +28,7 @@ public class NoiseGenerator extends TimedGenerator {
public NoiseGenerator(int _clock,int _sampleRate) {
super(_clock, _sampleRate);
}
@Override
public int stepsPerCycle() {
return 8;
}

View File

@ -110,7 +110,7 @@ public class PSG {
public PSG(int base, int clock, int sample_rate, String name) {
this.name = name;
baseReg = base;
channels = new ArrayList<SoundGenerator>();
channels = new ArrayList<>();
for (int i = 0; i < 3; i++) {
channels.add(new SoundGenerator(clock, sample_rate));
}
@ -155,9 +155,9 @@ public class PSG {
public void setRate(int clock, int sample_rate) {
CLOCK = clock;
SAMPLE_RATE = sample_rate;
for (SoundGenerator c : channels) {
channels.stream().forEach((c) -> {
c.setRate(clock, sample_rate);
}
});
envelopeGenerator.setRate(clock, sample_rate);
noiseGenerator.setRate(clock, sample_rate);
reset();
@ -170,9 +170,9 @@ public class PSG {
}
envelopeGenerator.reset();
noiseGenerator.reset();
for (SoundGenerator c : channels) {
channels.parallelStream().forEach((c) -> {
c.reset();
}
});
}
public void setReg(Reg r, int value) {

View File

@ -70,6 +70,7 @@ public class SoundGenerator extends TimedGenerator {
return invert ? -CardMockingboard.VolTable[vol] : CardMockingboard.VolTable[vol];
}
@Override
public void reset() {
super.reset();
amplitude = 0;