mirror of
https://github.com/badvision/jace.git
synced 2024-11-30 23:49:52 +00:00
Better handling of zero period values, still silencing if period <= 1 though
This commit is contained in:
parent
14b0cfd967
commit
dfc2cbae4e
@ -162,10 +162,10 @@ public class CardMockingboard extends Card {
|
|||||||
if (e.getType().isRead()) {
|
if (e.getType().isRead()) {
|
||||||
int val = controller.readRegister(register & 0x0f);
|
int val = controller.readRegister(register & 0x0f);
|
||||||
e.setNewValue(val);
|
e.setNewValue(val);
|
||||||
if (DEBUG) System.out.println("Chip " + chip + " Read "+Integer.toHexString(register & 0x0f)+" == "+val);
|
// if (DEBUG) System.out.println("Chip " + chip + " Read "+Integer.toHexString(register & 0x0f)+" == "+val);
|
||||||
} else {
|
} else {
|
||||||
controller.writeRegister(register & 0x0f, e.getNewValue());
|
controller.writeRegister(register & 0x0f, e.getNewValue());
|
||||||
if (DEBUG) System.out.println("Chip " + chip + " Write "+Integer.toHexString(register & 0x0f)+" == "+e.getNewValue());
|
// if (DEBUG) System.out.println("Chip " + chip + " Write "+Integer.toHexString(register & 0x0f)+" == "+e.getNewValue());
|
||||||
}
|
}
|
||||||
// Any firmware access will reset the idle counter and wake up the card, this allows the timers to start running again
|
// Any firmware access will reset the idle counter and wake up the card, this allows the timers to start running again
|
||||||
// Games such as "Skyfox" use the timer to detect if the card is present.
|
// Games such as "Skyfox" use the timer to detect if the card is present.
|
||||||
|
@ -51,7 +51,7 @@ public class TimedGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setPeriod(int _period) {
|
public void setPeriod(int _period) {
|
||||||
period = _period > 0 ? _period : 1;
|
period = _period;
|
||||||
clocksPerPeriod = (period * stepsPerCycle());
|
clocksPerPeriod = (period * stepsPerCycle());
|
||||||
// set counter back... necessary?
|
// set counter back... necessary?
|
||||||
// while (clocksPerPeriod > period) {
|
// while (clocksPerPeriod > period) {
|
||||||
@ -60,13 +60,12 @@ public class TimedGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected int updateCounter() {
|
protected int updateCounter() {
|
||||||
counter += cyclesPerSample;
|
// Period == 0 means the generator is off
|
||||||
int numStateChanges = 0;
|
if (period <= 1 || clocksPerPeriod <= 1) {
|
||||||
// Skyfox and Genius use a period value of 001 for silence instead of setting volume to 0.
|
|
||||||
if (period == 1) {
|
|
||||||
counter = 0;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
counter += cyclesPerSample;
|
||||||
|
int numStateChanges = 0;
|
||||||
while (counter >= clocksPerPeriod) {
|
while (counter >= clocksPerPeriod) {
|
||||||
counter -= clocksPerPeriod;
|
counter -= clocksPerPeriod;
|
||||||
numStateChanges++;
|
numStateChanges++;
|
||||||
@ -76,6 +75,6 @@ public class TimedGenerator {
|
|||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
counter = 0;
|
counter = 0;
|
||||||
period = 1;
|
period = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user