diff --git a/src/main/java/jace/hardware/mockingboard/EnvelopeGenerator.java b/src/main/java/jace/hardware/mockingboard/EnvelopeGenerator.java index f4964e3..c782684 100644 --- a/src/main/java/jace/hardware/mockingboard/EnvelopeGenerator.java +++ b/src/main/java/jace/hardware/mockingboard/EnvelopeGenerator.java @@ -75,7 +75,9 @@ public class EnvelopeGenerator extends TimedGenerator { } } + int shape; public void setShape(int shape) { + this.shape = shape & 15; oddEven = false; counter = 0; cont = (shape & 8) != 0; diff --git a/src/main/java/jace/hardware/mockingboard/PSG.java b/src/main/java/jace/hardware/mockingboard/PSG.java index dc360aa..1fce84b 100644 --- a/src/main/java/jace/hardware/mockingboard/PSG.java +++ b/src/main/java/jace/hardware/mockingboard/PSG.java @@ -23,6 +23,8 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import jace.hardware.CardMockingboard; + /** * Implementation of the AY sound PSG chip. This class manages register values * and mixes the channels together (in the update method) The work of @@ -225,6 +227,32 @@ public class PSG { case PortA, PortB -> { } } + if (CardMockingboard.DEBUG) { + debugStatus(); + } + } + + String lastStatus = ""; + public void debugStatus() { + String status = String.format("b%02X: A %03X %s %01X | B %03X %s %01X | C %03X %s %01X | N %03X | E %01X %04X", + baseReg, + channels.get(0).period, + (channels.get(0).active ? "T" : "_") + (channels.get(0).noiseActive ? "N" : "_"), + channels.get(0).amplitude, + channels.get(1).period, + (channels.get(1).active ? "T" : "_") + (channels.get(1).noiseActive ? "N" : "_"), + channels.get(1).amplitude, + channels.get(2).period, + (channels.get(2).active ? "T" : "_") + (channels.get(2).noiseActive ? "N" : "_"), + channels.get(2).amplitude, + noiseGenerator.period, + envelopeGenerator.shape, + envelopeGenerator.period + ); + if (!lastStatus.equals(status)) { + System.out.println(status); + lastStatus = status; + } } public void update(AtomicInteger bufA, boolean clearA, AtomicInteger bufB, boolean clearB, AtomicInteger bufC, boolean clearC) { diff --git a/src/main/java/jace/hardware/mockingboard/TimedGenerator.java b/src/main/java/jace/hardware/mockingboard/TimedGenerator.java index 0afe6b7..1e94c71 100644 --- a/src/main/java/jace/hardware/mockingboard/TimedGenerator.java +++ b/src/main/java/jace/hardware/mockingboard/TimedGenerator.java @@ -62,6 +62,11 @@ public class TimedGenerator { protected int updateCounter() { counter += cyclesPerSample; int numStateChanges = 0; + // Skyfox and Genius use a period value of 001 for silence instead of setting volume to 0. + if (period == 1) { + counter = 0; + return 0; + } while (counter >= clocksPerPeriod) { counter -= clocksPerPeriod; numStateChanges++;