forked from Apple-2-Tools/jace
Miscellaneous changes
This commit is contained in:
parent
d03c1d9333
commit
17b8183a31
src/main/java/jace/hardware
@ -74,7 +74,7 @@ public class CardMockingboard extends Card implements Runnable {
|
|||||||
public PSG[] chips;
|
public PSG[] chips;
|
||||||
// The 6522 controllr chips (always 2)
|
// The 6522 controllr chips (always 2)
|
||||||
public R6522[] controllers;
|
public R6522[] controllers;
|
||||||
static private int ticksBeteenPlayback = 200;
|
static private int ticksBetweenPlayback = 200;
|
||||||
Lock timerSync = new ReentrantLock();
|
Lock timerSync = new ReentrantLock();
|
||||||
Condition cpuCountReached = timerSync.newCondition();
|
Condition cpuCountReached = timerSync.newCondition();
|
||||||
Condition playbackFinished = timerSync.newCondition();
|
Condition playbackFinished = timerSync.newCondition();
|
||||||
@ -189,11 +189,11 @@ public class CardMockingboard extends Card implements Runnable {
|
|||||||
timerSync.lock();
|
timerSync.lock();
|
||||||
try {
|
try {
|
||||||
ticksSinceLastPlayback++;
|
ticksSinceLastPlayback++;
|
||||||
if (ticksSinceLastPlayback >= ticksBeteenPlayback) {
|
if (ticksSinceLastPlayback >= ticksBetweenPlayback) {
|
||||||
cpuCountReached.signalAll();
|
cpuCountReached.signalAll();
|
||||||
while (isRunning() && ticksSinceLastPlayback >= ticksBeteenPlayback) {
|
while (isRunning() && ticksSinceLastPlayback >= ticksBetweenPlayback) {
|
||||||
if (!playbackFinished.await(1, TimeUnit.SECONDS)) {
|
if (!playbackFinished.await(1, TimeUnit.SECONDS)) {
|
||||||
gripe("The mockingboard playback thread has stalled. Disabling mockingboard.");
|
// gripe("The mockingboard playback thread has stalled. Disabling mockingboard.");
|
||||||
suspend();
|
suspend();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -319,7 +319,8 @@ public class CardMockingboard extends Card implements Runnable {
|
|||||||
System.out.println("Mockingboard playback started");
|
System.out.println("Mockingboard playback started");
|
||||||
int bytesPerSample = frameSize / 2;
|
int bytesPerSample = frameSize / 2;
|
||||||
buildMixerTable();
|
buildMixerTable();
|
||||||
ticksBeteenPlayback = (int) ((Motherboard.SPEED * BUFFER_LENGTH) / SAMPLE_RATE);
|
ticksBetweenPlayback = (int) ((Motherboard.SPEED * BUFFER_LENGTH) / SAMPLE_RATE);
|
||||||
|
System.out.println("Ticks between playback: "+ticksBetweenPlayback);
|
||||||
ticksSinceLastPlayback = 0;
|
ticksSinceLastPlayback = 0;
|
||||||
int zeroSamples = 0;
|
int zeroSamples = 0;
|
||||||
setRun(true);
|
setRun(true);
|
||||||
@ -329,7 +330,6 @@ public class CardMockingboard extends Card implements Runnable {
|
|||||||
Thread.currentThread().yield();
|
Thread.currentThread().yield();
|
||||||
}
|
}
|
||||||
if (isRunning()) {
|
if (isRunning()) {
|
||||||
computer.getMotherboard().requestSpeed(this);
|
|
||||||
playSound(leftBuffer, rightBuffer);
|
playSound(leftBuffer, rightBuffer);
|
||||||
int p = 0;
|
int p = 0;
|
||||||
for (int idx = 0; idx < BUFFER_LENGTH; idx++) {
|
for (int idx = 0; idx < BUFFER_LENGTH; idx++) {
|
||||||
@ -349,7 +349,7 @@ public class CardMockingboard extends Card implements Runnable {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
timerSync.lock();
|
timerSync.lock();
|
||||||
ticksSinceLastPlayback -= ticksBeteenPlayback;
|
ticksSinceLastPlayback -= ticksBetweenPlayback;
|
||||||
} finally {
|
} finally {
|
||||||
timerSync.unlock();
|
timerSync.unlock();
|
||||||
}
|
}
|
||||||
@ -379,8 +379,10 @@ public class CardMockingboard extends Card implements Runnable {
|
|||||||
try {
|
try {
|
||||||
timerSync.lock();
|
timerSync.lock();
|
||||||
playbackFinished.signalAll();
|
playbackFinished.signalAll();
|
||||||
while (isRunning() && ticksSinceLastPlayback < ticksBeteenPlayback) {
|
while (isRunning() && ticksSinceLastPlayback < ticksBetweenPlayback) {
|
||||||
|
computer.getMotherboard().requestSpeed(this);
|
||||||
cpuCountReached.await();
|
cpuCountReached.await();
|
||||||
|
computer.getMotherboard().cancelSpeedRequest(this);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
// Do nothing, probably killing playback thread on purpose
|
// Do nothing, probably killing playback thread on purpose
|
||||||
|
@ -61,7 +61,6 @@ public class SoundGenerator extends TimedGenerator {
|
|||||||
double amp = stateChanges == 0 ? 1 : 1.0 / Math.max(stateChanges-1, 1);
|
double amp = stateChanges == 0 ? 1 : 1.0 / Math.max(stateChanges-1, 1);
|
||||||
int vol = useEnvGen ? envGen.getEffectiveAmplitude() : amplitude;
|
int vol = useEnvGen ? envGen.getEffectiveAmplitude() : amplitude;
|
||||||
boolean on = noiseActive && noiseGen.isOn() || (active && inverted);
|
boolean on = noiseActive && noiseGen.isOn() || (active && inverted);
|
||||||
// return invert ? -CardMockingboard.VolTable[vol] : CardMockingboard.VolTable[vol];
|
|
||||||
return on ? (int) (CardMockingboard.VolTable[vol] * amp) : 0;
|
return on ? (int) (CardMockingboard.VolTable[vol] * amp) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user