mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-26 10:49:17 +00:00
only use audio when spkr output present
This commit is contained in:
parent
20ddb8a11f
commit
7e04a15670
@ -268,7 +268,7 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
}
|
||||
|
||||
function updateVideoFrame() {
|
||||
useAudio = gen.spkr !== 'undefined';
|
||||
useAudio = (audio != null);
|
||||
debugCond = self.getDebugCallback();
|
||||
var i=videoWidth-10;
|
||||
var trace=inspect_obj && inspect_sym;
|
||||
@ -448,7 +448,6 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
case 39: scope_time_x++; dirty=true; break;
|
||||
}
|
||||
});
|
||||
audio = new SampleAudio(AUDIO_FREQ);
|
||||
idata = video.getFrameData();
|
||||
timer = new AnimationTimer(frameRate, function() {
|
||||
if (!self.isRunning())
|
||||
@ -459,6 +458,7 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
else
|
||||
updateScopeFrame();
|
||||
});
|
||||
trace_buffer = new Uint32Array(0x10000);
|
||||
}
|
||||
|
||||
this.printErrorCodeContext = function(e, code) {
|
||||
@ -482,14 +482,24 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
this.printErrorCodeContext(e, output.code);
|
||||
throw e;
|
||||
}
|
||||
// compile Verilog code
|
||||
var base = new VerilatorBase();
|
||||
gen = new mod(base);
|
||||
gen.__proto__ = base;
|
||||
current_output = output;
|
||||
ports_and_signals = current_output.ports; // TODO: current_output.ports.concat(current_output.signals);
|
||||
trace_buffer = new Uint32Array(0x10000);
|
||||
ports_and_signals = current_output.ports;
|
||||
trace_index = 0;
|
||||
// power on module
|
||||
this.poweron();
|
||||
// stop/start audio
|
||||
if (audio && gen.spkr === undefined) {
|
||||
audio.stop();
|
||||
audio = null;
|
||||
} else if (!audio && gen.spkr !== undefined) {
|
||||
audio = new SampleAudio(AUDIO_FREQ);
|
||||
if (this.isRunning())
|
||||
audio.start();
|
||||
}
|
||||
}
|
||||
|
||||
this.isRunning = function() {
|
||||
@ -497,11 +507,11 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
}
|
||||
this.pause = function() {
|
||||
timer.stop();
|
||||
if (gen.spkr !== undefined) audio.stop();
|
||||
if (audio) audio.stop();
|
||||
}
|
||||
this.resume = function() {
|
||||
timer.start();
|
||||
if (gen.spkr !== undefined) audio.start();
|
||||
if (audio) audio.start();
|
||||
}
|
||||
|
||||
this.poweron = function() {
|
||||
|
@ -619,6 +619,7 @@ function setupBreakpoint() {
|
||||
function _pause() {
|
||||
if (platform.isRunning()) {
|
||||
platform.pause();
|
||||
console.log("Paused");
|
||||
}
|
||||
$("#dbg_pause").addClass("btn_stopped");
|
||||
$("#dbg_go").removeClass("btn_active");
|
||||
@ -633,6 +634,7 @@ function pause() {
|
||||
function _resume() {
|
||||
if (! platform.isRunning()) {
|
||||
platform.resume();
|
||||
console.log("Resumed");
|
||||
}
|
||||
$("#dbg_pause").removeClass("btn_stopped");
|
||||
$("#dbg_go").addClass("btn_active");
|
||||
|
Loading…
Reference in New Issue
Block a user