Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moving the new audio system over to the standalone VM.

  • Loading branch information...
commit 087484f0c50b83ca702d4a975dec7d2d4443b28d 1 parent d82d644
@JohnEarnest authored
Showing with 10 additions and 8 deletions.
  1. +10 −8 tools/Standalone/src/MakoVM.java
View
18 tools/Standalone/src/MakoVM.java
@@ -9,7 +9,7 @@
public int keys = 0;
private SourceDataLine soundLine = null;
- private final byte[] abuffer = new byte[1000];
+ private final byte[] abuffer = new byte[8000];
private int apointer = 0;
public final java.util.Queue<Integer> keyQueue = new java.util.LinkedList<Integer>();
@@ -20,7 +20,7 @@ public MakoVM(int[] m) {
AudioFormat format = new AudioFormat(8000f, 8, 1, false, false);
DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
soundLine = (SourceDataLine)AudioSystem.getLine(info);
- soundLine.open(format, 32000);
+ soundLine.open(format, 670);
soundLine.start();
}
catch(IllegalArgumentException e) { System.out.println("Unable to initialize sound."); }
@@ -92,12 +92,9 @@ private int load(int addr) {
private void stor(int addr, int value) {
if (addr == CO) { System.out.print((char)value); return; }
- if (addr == AU && soundLine != null) {
- abuffer[apointer++] = (byte)value;
- apointer %= abuffer.length;
- if (apointer == 0) {
- soundLine.write(abuffer, 0, abuffer.length);
- }
+ if (addr == AU) {
+ abuffer[apointer] = (byte)value;
+ if (apointer < abuffer.length - 1) { apointer++; }
}
m[addr] = value;
}
@@ -160,5 +157,10 @@ public void sync() {
drawSprite(tile, status, px - scrollx, py - scrolly);
}
drawGrid(true, scrollx, scrolly);
+
+ if (soundLine != null && apointer > 0) {
+ soundLine.write(abuffer, 0, apointer);
+ apointer = 0;
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.