Skip to content
Browse files

Minor TIA sound adjustments

  • Loading branch information...
1 parent df95801 commit ec0c478cc4179ac5125f40a0d0adfd96133ac235 @ppeccin committed May 11, 2012
Showing with 11 additions and 17 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 src/atari/tia/TIA.java
  3. +9 −16 src/atari/tia/audio/ChannelStream.java
View
1 .gitignore
@@ -1,2 +1,3 @@
bin/
saves/
+deploy/
View
2 src/atari/tia/TIA.java
@@ -783,7 +783,7 @@ public void writeByte(int address, byte b) {
case 0x05: NUSIZ1 = i; player1SetShape(i); return;
case 0x06: COLUP0 = i; observableChange(); if (!debug) player0Color = missile0Color = palette[i]; return;
case 0x07: COLUP1 = i; observableChange(); if (!debug) player1Color = missile1Color = palette[i]; return;
- case 0x08: COLUPF = i; if (debug) debugPixel(DEBUG_SPECIAL_COLOR); observableChange(); if (!debug) playfieldColor = ballColor = palette[i]; return;
+ case 0x08: COLUPF = i; observableChange(); if (!debug) playfieldColor = ballColor = palette[i]; return;
case 0x09: COLUBK = i; observableChange(); if (!debug) playfieldBackground = palette[i]; return;
case 0x0A: CTRLPF = i; playfieldAndBallSetShape(i); return;
case 0x0B: REFP0 = i; observableChange(); player0Reflected = (i & 0x08) != 0; return;
View
25 src/atari/tia/audio/ChannelStream.java
@@ -7,19 +7,19 @@
public float nextSample() {
if (--dividerCountdown <= 0) {
dividerCountdown = divider;
- currentSample = (nextSampleForControl() * 2 - 1) * volume;
+ currentSample = nextSampleForControl() == 1 ? volume : -volume;
}
return currentSample;
}
- public void setVolume(int volume) {
- this.volume = (float)Math.pow(((float)volume / MAX_VOLUME), NON_LINEAR_CONVERSION);
+ public void setVolume(int newVolume) {
+ volume = (float)Math.pow(((float)newVolume / MAX_VOLUME), NON_LINEAR_CONVERSION);
}
- public void setDivider(int divider) {
- if (this.divider == divider) return;
- this.divider = divider;
- if (dividerCountdown > divider) dividerCountdown = divider;
+ public void setDivider(int newDivider) {
+ if (divider == newDivider) return;
+ dividerCountdown = (int)(((float)dividerCountdown / divider) * newDivider);
+ divider = newDivider;
}
public void setControl(int control) {
@@ -48,10 +48,7 @@ private int nextSampleForControl() {
case 0x06: // div 31 pure tone (18 high, 13, low)
case 0x0a: // div 31 pure tone (18 high, 13, low)
return nextTone31();
- case 0x07: // 5 bit poly > div 2 (same as 5 bit poly? Peccin: NOT!)
- return nextPoly5() == 1
- ? nextTone2()
- : currentTone2();
+ case 0x07: // 5 bit poly > div 2 (same as 5 bit poly)
case 0x09: // 5 bit poly
return nextPoly5();
case 0x08: // 9 bit poly
@@ -109,10 +106,6 @@ private int nextPoly9() {
return carry;
}
- private int currentTone2() {
- return tone2;
- }
-
private int nextTone2() {
return tone2 = tone2 == 0 ? 1 : 0;
}
@@ -144,7 +137,7 @@ private int nextTone31() {
private int divider = 1; // Changes to dividers will only be reflected at the next countdown cycle
private int dividerCountdown = 1;
- private float currentSample = 0;
+ private float currentSample = 1;
private int poly4 = 0x0f;
private int poly5 = 0x1f;

0 comments on commit ec0c478

Please sign in to comment.
Something went wrong with that request. Please try again.