Issue #24: Mute prevents any sound mixer from being created; error in sound init fixed; fixed incorrect assumption in CPU addition test

This commit is contained in:
Brendan Robert 2016-02-14 22:59:40 -06:00
parent 4a371ceec3
commit 609ad08bfd
3 changed files with 15 additions and 1 deletions

View File

@ -61,6 +61,9 @@ public class SoundMixer extends Device {
*/ */
@ConfigurableField(name = "Playback Rate", shortName = "freq") @ConfigurableField(name = "Playback Rate", shortName = "freq")
public static int RATE = 48000; public static int RATE = 48000;
@ConfigurableField(name = "Mute", shortName = "mute")
public static boolean MUTE = false;
/** /**
* Sound format used for playback * Sound format used for playback
*/ */
@ -104,7 +107,9 @@ public class SoundMixer extends Device {
@Override @Override
public synchronized void reconfigure() { public synchronized void reconfigure() {
if (isConfigDifferent()) { if (MUTE) {
detach();
} else if (isConfigDifferent()) {
detach(); detach();
try { try {
initMixer(); initMixer();

View File

@ -286,6 +286,10 @@ public class Utility {
isHeadless = headless; isHeadless = headless;
} }
public static boolean isHeadlessMode() {
return isHeadless;
}
public static Optional<Image> loadIcon(String filename) { public static Optional<Image> loadIcon(String filename) {
if (isHeadless) { if (isHeadless) {
return Optional.empty(); return Optional.empty();

View File

@ -20,6 +20,7 @@ import jace.apple2e.Apple2e;
import jace.apple2e.MOS65C02; import jace.apple2e.MOS65C02;
import jace.core.Computer; import jace.core.Computer;
import jace.core.RAM; import jace.core.RAM;
import jace.core.SoundMixer;
import jace.core.Utility; import jace.core.Utility;
import jace.ide.HeadlessProgram; import jace.ide.HeadlessProgram;
import jace.ide.Program; import jace.ide.Program;
@ -45,10 +46,12 @@ public class Basic6502FuncationalityTest {
@BeforeClass @BeforeClass
public static void setupClass() { public static void setupClass() {
Utility.setHeadlessMode(true); Utility.setHeadlessMode(true);
SoundMixer.MUTE = true;
computer = new Apple2e(); computer = new Apple2e();
cpu = (MOS65C02) computer.getCpu(); cpu = (MOS65C02) computer.getCpu();
ram = computer.getMemory(); ram = computer.getMemory();
Emulator.computer = (Apple2e) computer; Emulator.computer = (Apple2e) computer;
computer.pause();
} }
@AfterClass @AfterClass
@ -57,6 +60,7 @@ public class Basic6502FuncationalityTest {
@Before @Before
public void setup() { public void setup() {
cpu.suspend();
for (int i = 0; i < 1024; i++) { for (int i = 0; i < 1024; i++) {
ram.write(i, (byte) 0, false, false); ram.write(i, (byte) 0, false, false);
} }
@ -74,6 +78,7 @@ public class Basic6502FuncationalityTest {
public void testAdditionNonDecimal() { public void testAdditionNonDecimal() {
cpu.A = 0; cpu.A = 0;
cpu.D = false; cpu.D = false;
cpu.C = 0;
assemble(" adc #1"); assemble(" adc #1");
assertEquals("Nothing should change yet", 0, cpu.A); assertEquals("Nothing should change yet", 0, cpu.A);
cpu.tick(); cpu.tick();