Browse Source

Tidy up: spacing, quotes, and line length.

- Space before ? in ternary operators
- Double quotes ' -> "
- Line length of 100
Ernest Wong 6 years ago
parent
commit
a185fd13bc
3 changed files with 12 additions and 29 deletions
  1. 1 1
      src/browser/speaker.js
  2. 2 8
      src/pit.js
  3. 9 20
      src/sb16.js

+ 1 - 1
src/browser/speaker.js

@@ -29,7 +29,7 @@ function SpeakerAdapter(bus)
     this.beep_gain.connect(this.audio_context.destination);
 
     this.beep_oscillator = this.audio_context.createOscillator();
-    this.beep_oscillator.type = 'square';
+    this.beep_oscillator.type = "square";
     this.beep_oscillator.frequency.value = 440;
     this.beep_oscillator.connect(this.beep_gain);
     this.beep_oscillator.start();

+ 2 - 8
src/pit.js

@@ -235,10 +235,7 @@ PIT.prototype.counter_write = function(i, value)
         this.counter_next_low[i] ^= 1;
     }
 
-    this.bus.send("pcspeaker-update", [
-        this.counter_mode[2],
-        this.counter_reload[2]
-    ]);
+    this.bus.send("pcspeaker-update", [this.counter_mode[2], this.counter_reload[2]]);
 };
 
 PIT.prototype.port43_write = function(reg_byte)
@@ -315,8 +312,5 @@ PIT.prototype.port43_write = function(reg_byte)
     this.counter_mode[i] = mode;
     this.counter_read_mode[i] = read_mode;
 
-    this.bus.send("pcspeaker-update", [
-        this.counter_mode[2],
-        this.counter_reload[2]
-    ]);
+    this.bus.send("pcspeaker-update", [this.counter_mode[2], this.counter_reload[2]]);
 };

+ 9 - 20
src/sb16.js

@@ -896,10 +896,7 @@ register_dsp_command([0x40], 1, function()
 // Set digitized sound input sampling rate.
 register_dsp_command([0x41, 0x42], 2, function()
 {
-    this.sampling_rate_change(
-        (this.write_buffer.shift() << 8)
-        | this.write_buffer.shift()
-    );
+    this.sampling_rate_change((this.write_buffer.shift() << 8) | this.write_buffer.shift());
 });
 
 // Set DSP block transfer size.
@@ -1437,14 +1434,12 @@ SB16.prototype.sampling_rate_change = function(rate)
 
 SB16.prototype.get_channel_count = function()
 {
-    return this.dsp_stereo? 2 : 1;
+    return this.dsp_stereo ? 2 : 1;
 };
 
 SB16.prototype.dma_transfer_size_set = function()
 {
-    this.dma_sample_count = 1 +
-        (this.write_buffer.shift() << 0) +
-        (this.write_buffer.shift() << 8);
+    this.dma_sample_count = 1 + (this.write_buffer.shift() << 0) + (this.write_buffer.shift() << 8);
 };
 
 SB16.prototype.dma_transfer_start = function()
@@ -1532,22 +1527,18 @@ SB16.prototype.dma_transfer_next = function()
 
 SB16.prototype.dma_to_dac = function(sample_count)
 {
-    var amplitude = this.dsp_16bit? 32767.5 : 127.5;
-    var offset = this.dsp_signed? 0 : -1;
-    var repeats = (this.dsp_stereo? 1 : 2) * this.dac_rate_ratio;
+    var amplitude = this.dsp_16bit ? 32767.5 : 127.5;
+    var offset = this.dsp_signed ? 0 : -1;
+    var repeats = (this.dsp_stereo ? 1 : 2) * this.dac_rate_ratio;
 
     var buffer;
     if(this.dsp_16bit)
     {
-        buffer = this.dsp_signed ?
-            this.dma_buffer_int16 :
-            this.dma_buffer_uint16;
+        buffer = this.dsp_signed ? this.dma_buffer_int16 : this.dma_buffer_uint16;
     }
     else
     {
-        buffer = this.dsp_signed ?
-            this.dma_buffer_int8 :
-            this.dma_buffer_uint8;
+        buffer = this.dsp_signed ? this.dma_buffer_int8 : this.dma_buffer_uint8;
     }
 
     var channel = 0;
@@ -1614,7 +1605,5 @@ function audio_normalize(value, amplitude, offset)
 
 function audio_clip(value, low, high)
 {
-    return (value < low) * low +
-        (value > high) * high +
-        (low <= value && value <= high) * value;
+    return (value < low) * low + (value > high) * high + (low <= value && value <= high) * value;
 }