update 0.8.3

This commit is contained in:
Rupert Hausberger 2015-03-22 19:15:45 +01:00
commit 2276cd4df8
25 changed files with 9847 additions and 9836 deletions

1
ga.js
View file

@ -10,3 +10,4 @@ _gaq.push(['_trackPageview']);
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})(); })();

View file

@ -484,3 +484,4 @@ instead of this License.
</p> </p>
</body></html> </body></html>

View file

@ -204,3 +204,4 @@ div.float_item {
div.float_clear { div.float_clear {
clear: both; clear: both;
}*/ }*/

View file

@ -373,18 +373,6 @@
<option value="2">On (best)</option> <option value="2">On (best)</option>
</select> </select>
</td> </td>
<td class="arm">Samplerate:</td>
<td>
<select id="cfg_audio_rate" size="1">
<option value="1">11025</option>
<option value="2">22050</option>
<option value="3">44100</option>
<option value="4">48000</option>
</select>
Hz
</td>
</tr>
<tr>
<td class="arm">Channels:</td> <td class="arm">Channels:</td>
<td> <td>
<select id="cfg_audio_channels" size="1"> <select id="cfg_audio_channels" size="1">
@ -608,7 +596,7 @@
<div style="height:6px"></div> <div style="height:6px"></div>
<div id="foot" class="foot" style="line-height:14px"> <div id="foot" class="foot" style="line-height:14px">
<span class="gray">2012-2015 Rupert Hausberger</span> | <span class="gray">2012-2015 Rupert Hausberger</span> |
<span class="gray">ver 0.8.2</span> | <span class="gray">ver 0.8.3</span> |
<a target="_blank" href="https://github.com/naTmeg/ScriptedAmigaEmulator">Source-code</a> | <a target="_blank" href="https://github.com/naTmeg/ScriptedAmigaEmulator">Source-code</a> |
<a target="_blank" href="readme.htm">Description</a> <a target="_blank" href="readme.htm">Description</a>
</div> </div>

View file

@ -76,7 +76,7 @@ const db = [
], ],
['9 Fingers', 'Spaceballs', '1993', ['9 Fingers', 'Spaceballs', '1993',
['9 Fingers (Disk 1).adf', ['9 Fingers (Disk 1).adf',
'9 Fingers (Disk 2).adf',false,false], [false, true], '9 Fingers (Disk 2).adf',false,false], [false, false],
[true, 16, 17, false], [], [], false [true, 16, 17, false], [], [], false
], ],
['Alpha and Omega', 'Pure Metal Coders', '1991', ['Alpha and Omega', 'Pure Metal Coders', '1991',
@ -96,10 +96,10 @@ const db = [
['Elysium.adf',false,false,false], [false, true], ['Elysium.adf',false,false,false], [false, true],
[true, 16, 17, false], [], [], false [true, 16, 17, false], [], [], false
], ],
['Ecliptica', 'TRSI', '1991', /*crash ['Ecliptica', 'TRSI', '1991',
['Ecliptica.adf',false,false,false], [false, true], ['Ecliptica.adf',false,false,false], [false, true],
[true, 16, 17, false], [], [], false [true, 16, 17, false], [], [], false
], ],*/
['Enigma', 'Phenomena', '1991', ['Enigma', 'Phenomena', '1991',
['Enigma.adf',false,false,false], [false, true], ['Enigma.adf',false,false,false], [false, true],
[true, 16, 17, false], [], [], false [true, 16, 17, false], [], [], false
@ -175,11 +175,12 @@ var dbNum = 0;
const aros_rom_file = 'aros-amiga-m68k-rom.bin'; const aros_rom_file = 'aros-amiga-m68k-rom.bin';
const aros_rom_url = 'http://'+window.location.hostname+'/db/'+aros_rom_file; const aros_rom_url = 'http://'+window.location.hostname+'/db/'+aros_rom_file;
const aros_rom_size = 0x80000; const aros_rom_size = 0x80000;
const aros_rom_crc = 0x48dfadd; //0xea48b4d1 const aros_rom_crc = 0xbe091f38; //0x48dfadd; //0xea48b4d1
const aros_ext_file = 'aros-amiga-m68k-ext.bin'; const aros_ext_file = 'aros-amiga-m68k-ext.bin';
const aros_ext_url = 'http://'+window.location.hostname+'/db/'+aros_ext_file; const aros_ext_url = 'http://'+window.location.hostname+'/db/'+aros_ext_file;
const aros_ext_size = 0x80000; const aros_ext_size = 0x80000;
const aros_ext_crc = 0xaaf211d6; //0x60871435 const aros_ext_crc = 0x3f3fdce0; //0xaaf211d6; //0x60871435
var mode = 0; var mode = 0;
var paused = false; var paused = false;
@ -599,7 +600,6 @@ function getSimpleConfig() {
if (config.audio.enabled) { if (config.audio.enabled) {
config.audio.mode = SAEV_Config_Audio_Mode_Play_Best; config.audio.mode = SAEV_Config_Audio_Mode_Play_Best;
config.audio.channels = SAEV_Config_Audio_Channels_Stereo; config.audio.channels = SAEV_Config_Audio_Channels_Stereo;
config.audio.rate = SAEV_Config_Audio_Rate_44100;
} }
/*if (info.audio == 0) { /*if (info.audio == 0) {
config.audio.enabled = false; config.audio.enabled = false;
@ -823,12 +823,6 @@ function setConfig() {
case SAEV_Config_Audio_Channels_Mono: document.getElementById('cfg_audio_channels')[0].selected = true; break; case SAEV_Config_Audio_Channels_Mono: document.getElementById('cfg_audio_channels')[0].selected = true; break;
case SAEV_Config_Audio_Channels_Stereo: document.getElementById('cfg_audio_channels')[1].selected = true; break; case SAEV_Config_Audio_Channels_Stereo: document.getElementById('cfg_audio_channels')[1].selected = true; break;
} }
switch (config.audio.rate) {
case SAEV_Config_Audio_Rate_11025: document.getElementById('cfg_audio_rate')[0].selected = true; break;
case SAEV_Config_Audio_Rate_22050: document.getElementById('cfg_audio_rate')[1].selected = true; break;
case SAEV_Config_Audio_Rate_44100: document.getElementById('cfg_audio_rate')[2].selected = true; break;
case SAEV_Config_Audio_Rate_48000: document.getElementById('cfg_audio_rate')[3].selected = true; break;
}
document.getElementById('cfg_audio_filter').checked = config.audio.filter != 0; document.getElementById('cfg_audio_filter').checked = config.audio.filter != 0;
styleDisplayTable('cfg_audio_grp', config.audio.enabled); styleDisplayTable('cfg_audio_grp', config.audio.enabled);
@ -925,8 +919,6 @@ function getConfig() {
config.audio.mode = parseInt(getSelectValue(e)); config.audio.mode = parseInt(getSelectValue(e));
e = document.getElementById('cfg_audio_channels'); e = document.getElementById('cfg_audio_channels');
config.audio.channels = parseInt(getSelectValue(e)); config.audio.channels = parseInt(getSelectValue(e));
e = document.getElementById('cfg_audio_rate');
config.audio.rate = parseInt(getSelectValue(e));
config.audio.filter = document.getElementById('cfg_audio_filter').checked ? true : false; config.audio.filter = document.getElementById('cfg_audio_filter').checked ? true : false;
} }
@ -1539,3 +1531,4 @@ function dskchgSelect() {
}); });
} }
} }

View file

@ -78,7 +78,7 @@
<ul> <ul>
<li><span class="fwb">Written and ported by</span> <li><span class="fwb">Written and ported by</span>
<ul> <ul>
<li>Rupert Hausberger &lt;<a href="mailto:rupert_hausberger@gmx.net">rupert_hausberger@gmx.net</a>&gt; (<a target="_blank" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=ZJA3YVT6EP55A">donate</a>)</li> <li>Rupert Hausberger &lt;<a href="mailto:rupert_hausberger@gmx.net">rupert_hausberger@gmx.net</a>&gt;</li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -99,7 +99,7 @@
<ul> <ul>
<li><span class="fwb">Thanks</span> <li><span class="fwb">Thanks</span>
<ul> <ul>
<li><a target="_blank" href="http://www.amigaemulator.org">Bernd Schmidt</a></li> <!--<li><a target="_blank" href="http://www.amigaemulator.org">Bernd Schmidt</a></li>-->
<li><a target="_blank" href="http://winuae.net">WinUAE team</a></li> <li><a target="_blank" href="http://winuae.net">WinUAE team</a></li>
<li><a target="_blank" href="http://aros.org">AROS team</a></li> <li><a target="_blank" href="http://aros.org">AROS team</a></li>
</ul> </ul>
@ -117,6 +117,31 @@
<ul> <ul>
<li><span class="fwb">History</span> <li><span class="fwb">History</span>
<ul> <ul>
<li><span class="fwb">0.8.3 (22.03.2015)</span>
<ul>
<li>Audio
<ul>
<li>Fixed a heavy bug i added myself around v0.6-0.7 on the seek for other bugs. Big thanks to 'Ralf Sommer'.</li>
<li>Dropped usage of the ring-buffer and wrote a new and faster queue-buffer.</li>
<li>The audio-data is now first sampled at 15.65KHz and then resampled to<br />
the rate of the soundcard. This does reduce internal CPU-usage.</li>
<li>Removed 'Audio/Samplerate' in the GUI, because it's no longer used.<br />
</ul>
</li>
<li>Events
<ul>
<li>Fixed a bug in combination with frameskip.</li>
<li>Frameskip is now disabled by default.</li>
</ul>
</li>
<li>Common
<ul>
<li>Updated AROS-ROMs to actual version SVN50213.</li>
</ul>
</li>
</ul>
</li>
<li style="list-style-type:none"><br/></li>
<li><span class="fwb">0.8.2 (10.01.2015)</span> <li><span class="fwb">0.8.2 (10.01.2015)</span>
<ul> <ul>
<li>Audio <li>Audio

View file

@ -423,3 +423,4 @@ function SAE(x) {
//return { error:SAEE_None, message:'' }; //return { error:SAEE_None, message:'' };
return 0; return 0;
} }

View file

@ -31,16 +31,6 @@ function Filter() {
var filter2_a0 = 0; var filter2_a0 = 0;
var filter_a0 = 0; var filter_a0 = 0;
function getRate(v) {
switch (v) {
case SAEV_Config_Audio_Rate_11025: return 11025;
case SAEV_Config_Audio_Rate_22050: return 22050;
case SAEV_Config_Audio_Rate_44100: return 44100;
case SAEV_Config_Audio_Rate_48000: return 48000;
default: return 44100;
}
}
function calc(sample_rate, cutoff_freq) { function calc(sample_rate, cutoff_freq) {
if (cutoff_freq >= sample_rate / 2) if (cutoff_freq >= sample_rate / 2)
return 1.0; return 1.0;
@ -50,13 +40,12 @@ function Filter() {
return 1 / (1 + 1 / omega); return 1 / (1 + 1 / omega);
} }
this.setup = function (on) { this.setup = function (on, sample_rate) {
this.on = on; this.on = on;
var rate = getRate(AMIGA.config.audio.rate); filter1_a0 = calc(sample_rate, 6200);
filter1_a0 = calc(rate, 6200); filter2_a0 = calc(sample_rate, 20000);
filter2_a0 = calc(rate, 20000); filter_a0 = calc(sample_rate, 7000);
filter_a0 = calc(rate, 7000); /*console.log(sample_rate);
/*console.log(rate);
console.log(filter1_a0); console.log(filter1_a0);
console.log(filter2_a0); console.log(filter2_a0);
console.log(filter_a0);*/ console.log(filter_a0);*/
@ -364,7 +353,7 @@ function Channel(num) {
} }
function Audi0() { function Audi0() {
const SAMPLE_BUFFER_SIZE = 8192 >> 0; const SAMPLE_BUFFER_SIZE = 8192;
this.available = 0; this.available = 0;
var channel = null; var channel = null;
@ -374,12 +363,13 @@ function Audi0() {
var scaled_sample_evtime_orig = 0; var scaled_sample_evtime_orig = 0;
var scaled_sample_evtime = 0; var scaled_sample_evtime = 0;
var amiga_sample_rate = 0;
var work_to_do = 0; var work_to_do = 0;
var prevcon = -1; var prevcon = -1;
var driver = { var driver = {
ctx: null, ctx: null,
src: null,
node: null, node: null,
paused:false paused:false
}; };
@ -389,19 +379,31 @@ function Audi0() {
left: null, left: null,
right: null right: null
}, },
pos: 0, pos: 0
rpos: 0,
rate: new MAvg(10)
}; };
var ringBuffer = { var resampleBuffer = {
size: 0, size: 0,
data: { data: {
left: null, left: null,
right: null right: null
}, },
usage:0, len: 0
readPos: 0, };
writePos: 0 var queueBuffer = {
size: 0,
data: {
left: null,
right: null
},
usage: 0
};
var outputBuffer = {
size: 0,
data: {
left: null,
right: null
},
len: 0
}; };
this.filter = new Filter(); this.filter = new Filter();
@ -424,38 +426,43 @@ function Audi0() {
/*---------------------------------*/ /*---------------------------------*/
function getRate(v) { /*this.calc_sample_evtime = function (hz, longframe, linetoggle) {
switch (v) { var lines = AMIGA.playfield.maxvpos_nom;
case SAEV_Config_Audio_Rate_11025: return 11025; var hpos = AMIGA.playfield.maxhpos_short;
case SAEV_Config_Audio_Rate_22050: return 22050;
case SAEV_Config_Audio_Rate_44100: return 44100;
case SAEV_Config_Audio_Rate_48000: return 48000;
default: return 44100;
}
}
this.calc_sample_evtime = function (hz, longframe, linetoggle) { if (Math.abs(hz-50) < 2)
var lines = 0.0; amiga_sample_rate = CHIPSET_CLOCK_PAL / 123;
var hpos; else
amiga_sample_rate = CHIPSET_CLOCK_NTSC / 124;
if (linetoggle) { if (linetoggle) {
hpos = AMIGA.playfield.maxhpos_short + 0.5; hpos += 0.5;
lines += 0.5; lines += 0.5;
} else { } else {
hpos = AMIGA.playfield.maxhpos_short + 0.0;
if (longframe < 0) if (longframe < 0)
lines += 0.5; lines += 0.5;
else if (longframe > 0) else if (longframe > 0)
lines += 1.0; lines += 1.0;
} }
lines += AMIGA.playfield.maxvpos_nom; scaled_sample_evtime_orig = hpos * lines * hz / amiga_sample_rate * CYCLE_UNIT;
scaled_sample_evtime_orig = Math.floor(hpos * lines * hz / getRate(AMIGA.config.audio.rate) / 4 * CYCLE_UNIT);
scaled_sample_evtime = scaled_sample_evtime_orig; scaled_sample_evtime = scaled_sample_evtime_orig;
/*#if 0
lines -= AMIGA.playfield.maxvpos_nom; BUG.info('Audio.calc_sample_evtime() hmax %d, vmax %d, hz %f, rate %f | scaled_sample_evtime %f', hpos, lines, hz, amiga_sample_rate, scaled_sample_evtime * CYCLE_UNIT_INV);
BUG.info('%d.%d %d.%d %.2f', maxhpos_short, linetoggle ? 5 : 0, maxvpos_nom + (lines == 1.0 ? 1 : 0), lines > 0 && lines < 1 ? 5 : 0, scaled_sample_evtime); };*/
#endif*/
BUG.info('Audio.calc_sample_evtime() scaled_sample_evtime %f (%f) | hpos %d, lines %d', scaled_sample_evtime, scaled_sample_evtime * CYCLE_UNIT_INV, hpos, lines); this.calc_sample_evtime = function (hz, longframe, linetoggle) {
if (Math.abs(hz - 50.0) <= 1.5) {
amiga_sample_rate = CHIPSET_CLOCK_PAL / 123;
scaled_sample_evtime_orig = 123 * CYCLE_UNIT;
BUG.info('Audio.calc_sample_evtime() PAL mode, rate %f, scaled_sample_evtime %f', amiga_sample_rate, scaled_sample_evtime_orig * CYCLE_UNIT_INV);
} else {
amiga_sample_rate = CHIPSET_CLOCK_NTSC / 124;
scaled_sample_evtime_orig = 124 * CYCLE_UNIT;
BUG.info('Audio.calc_sample_evtime() NTSC mode, rate %f, scaled_sample_evtime %f', amiga_sample_rate, scaled_sample_evtime_orig * CYCLE_UNIT_INV);
}
scaled_sample_evtime = scaled_sample_evtime_orig;
this.filter.setup(AMIGA.config.audio.filter, amiga_sample_rate); /* A500 lowpass-filter */
}; };
this.setup = function () { this.setup = function () {
@ -479,33 +486,37 @@ function Audi0() {
Fatal(SAEE_Audio_WebAudio_Not_Avail, null); Fatal(SAEE_Audio_WebAudio_Not_Avail, null);
} }
this.filter.setup(AMIGA.config.audio.filter); /* A500 lowpass-filter */ this.calc_sample_evtime(AMIGA.config.video.ntsc ? 60 : 50, 1, AMIGA.config.video.ntsc);
var hz = AMIGA.config.video.ntsc ? 60 : 50; sampleBuffer.size = SAMPLE_BUFFER_SIZE * 2;
this.calc_sample_evtime(hz, 1, AMIGA.config.video.ntsc);
sampleBuffer.size = SAMPLE_BUFFER_SIZE;
sampleBuffer.data.left = new Float32Array(sampleBuffer.size); sampleBuffer.data.left = new Float32Array(sampleBuffer.size);
if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo) if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo)
sampleBuffer.data.right = new Float32Array(sampleBuffer.size); sampleBuffer.data.right = new Float32Array(sampleBuffer.size);
ringBuffer.size = sampleBuffer.size + (sampleBuffer.size >> 1); resampleBuffer.size = SAMPLE_BUFFER_SIZE * 2;
ringBuffer.data.left = new Float32Array(ringBuffer.size); resampleBuffer.data.left = new Float32Array(resampleBuffer.size);
if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo) if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo)
ringBuffer.data.right = new Float32Array(ringBuffer.size); resampleBuffer.data.right = new Float32Array(resampleBuffer.size);
queueBuffer.size = SAMPLE_BUFFER_SIZE * 8;
queueBuffer.data.left = new Float32Array(queueBuffer.size);
if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo)
queueBuffer.data.right = new Float32Array(queueBuffer.size);
outputBuffer.size = SAMPLE_BUFFER_SIZE;
outputBuffer.data.left = new Float32Array(outputBuffer.size);
if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo)
outputBuffer.data.right = new Float32Array(outputBuffer.size);
if (this.available & SAEI_Audio_WebAudio) { if (this.available & SAEI_Audio_WebAudio) {
var inputs = BrowserDetect.browser == 'Safari' ? 1 : 0;
if (driver.ctx.createJavaScriptNode) if (driver.ctx.createJavaScriptNode)
driver.node = driver.ctx.createJavaScriptNode(sampleBuffer.size, inputs, AMIGA.config.audio.channels); driver.node = driver.ctx.createJavaScriptNode(SAMPLE_BUFFER_SIZE, 1, AMIGA.config.audio.channels);
else if (driver.ctx.createScriptProcessor) else if (driver.ctx.createScriptProcessor)
driver.node = driver.ctx.createScriptProcessor(sampleBuffer.size, inputs, AMIGA.config.audio.channels); driver.node = driver.ctx.createScriptProcessor(SAMPLE_BUFFER_SIZE, 1, AMIGA.config.audio.channels);
if (driver.node) { if (driver.node) {
driver.node.onaudioprocess = fillWebAudio; driver.node.onaudioprocess = audioProcess;
driver.node.connect(driver.ctx.destination); driver.node.connect(driver.ctx.destination);
BUG.info('Audio.setup() enabled WebAudio, channels %d, rate %d', AMIGA.config.audio.channels, getRate(AMIGA.config.audio.rate));
} }
} }
}; };
@ -515,6 +526,7 @@ function Audi0() {
if (this.available & SAEI_Audio_WebAudio) { if (this.available & SAEI_Audio_WebAudio) {
if (driver.node) { if (driver.node) {
driver.node.disconnect(driver.ctx.destination); driver.node.disconnect(driver.ctx.destination);
driver.node.onaudioprocess = null;
driver.node = null; driver.node = null;
} }
} }
@ -529,8 +541,10 @@ function Audi0() {
if (driver.node) { if (driver.node) {
if (pause && !driver.paused) { if (pause && !driver.paused) {
driver.node.disconnect(driver.ctx.destination); driver.node.disconnect(driver.ctx.destination);
driver.node.onaudioprocess = null;
driver.paused = true; driver.paused = true;
} else if (!pause && driver.paused) { } else if (!pause && driver.paused) {
driver.node.onaudioprocess = audioProcess;
driver.node.connect(driver.ctx.destination); driver.node.connect(driver.ctx.destination);
driver.paused = false; driver.paused = false;
} }
@ -552,12 +566,7 @@ function Audi0() {
prevcon = 0; prevcon = 0;
sampleBuffer.pos = 0; sampleBuffer.pos = 0;
sampleBuffer.rpos = 0; queueBuffer.usage = 0;
sampleBuffer.rate.clr();
ringBuffer.usage = 0;
ringBuffer.readPos = 0;
ringBuffer.writePos = 0;
this.filter.reset(); this.filter.reset();
}; };
@ -591,8 +600,7 @@ function Audi0() {
//BUG.info('Audio.deactivate()'); //BUG.info('Audio.deactivate()');
this.pauseResume(1); this.pauseResume(1);
sampleBuffer.pos = 0; sampleBuffer.pos = 0;
sampleBuffer.rpos = 0; queueBuffer.usage = 0;
sampleBuffer.rate.clr();
this.event_reset(); this.event_reset();
}; };
@ -846,8 +854,6 @@ function Audi0() {
data3 = this.filter.filter(data3, 1); data3 = this.filter.filter(data3, 1);
} }
//if (sampleBuffer.pos + 1 >= sampleBuffer.size) sampleBuffer.pos = 0;
if (sampleBuffer.pos < sampleBuffer.size) { if (sampleBuffer.pos < sampleBuffer.size) {
if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo) { if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo) {
sampleBuffer.data.left[sampleBuffer.pos] = inv32768 * data2; sampleBuffer.data.left[sampleBuffer.pos] = inv32768 * data2;
@ -914,8 +920,8 @@ function Audi0() {
sampleBuffer.pos++; sampleBuffer.pos++;
} else } else
sampleBuffer.data.left[sampleBuffer.pos++] = inv32768 * ((data2 + data3) * 0.5); sampleBuffer.data.left[sampleBuffer.pos++] = inv32768 * ((data2 + data3) * 0.5);
} else } //else
BUG.info('Audio.sample_handler_crux() audio buffer over-run!'); //BUG.info('Audio.sample_handler_crux() audio buffer over-run!');
}; };
this.sample_handler_rh = function () { this.sample_handler_rh = function () {
@ -959,115 +965,111 @@ function Audi0() {
sampleBuffer.pos++; sampleBuffer.pos++;
} else } else
sampleBuffer.data.left[sampleBuffer.pos++] = inv32768 * ((data2 + data3) * 0.5); sampleBuffer.data.left[sampleBuffer.pos++] = inv32768 * ((data2 + data3) * 0.5);
} else } //else
BUG.info('Audio.sample_handler_rh() audio buffer over-run!'); //BUG.info('Audio.sample_handler_rh() audio buffer over-run!');
}; };
/*---------------------------------*/ /*---------------------------------*/
//var avg = 0, cnt = 0; function queuePush() {
if (queueBuffer.usage + resampleBuffer.len >= queueBuffer.size)
return;
function fillRingBuffer() {
if (sampleBuffer.pos == 0) return false;
/*avg += sampleBuffer.pos;
if ((++cnt) == 7) {
var newrate = Math.floor(avg / 7);
sampleBuffer.rate = Math.floor(sampleBuffer.rate + newrate >> 1);
avg = cnt = 0;
}
if (sampleBuffer.rate == 0) {
sampleBuffer.pos = 0;
return false;
}
var rate = sampleBuffer.rate;*/
var rate = sampleBuffer.rate.set(sampleBuffer.pos);
var drop = false;
if (ringBuffer.usage + sampleBuffer.pos < ringBuffer.size) {
for (var i = 0; i < sampleBuffer.pos; i++) {
var pos = ringBuffer.writePos + i < ringBuffer.size ? ringBuffer.writePos + i : ringBuffer.writePos + i - ringBuffer.size;
if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo) { if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo) {
ringBuffer.data.left[pos] = sampleBuffer.data.left[i]; for (var i = 0; i < resampleBuffer.len; i++) {
ringBuffer.data.right[pos] = sampleBuffer.data.right[i]; queueBuffer.data.left[queueBuffer.usage + i] = resampleBuffer.data.left[i];
} else queueBuffer.data.right[queueBuffer.usage + i] = resampleBuffer.data.right[i];
ringBuffer.data.left[pos] = sampleBuffer.data.left[i];
} }
ringBuffer.writePos += sampleBuffer.pos; if (ringBuffer.writePos >= ringBuffer.size) ringBuffer.writePos -= ringBuffer.size;
ringBuffer.usage += sampleBuffer.pos;
} else { } else {
//console.log('ringBuffer overflow', ringBuffer.usage, rate, ringBuffer.size - ringBuffer.usage); for (var i = 0; i < resampleBuffer.len; i++)
queueBuffer.data.left[queueBuffer.usage + i] = resampleBuffer.data.left[i];
}
queueBuffer.usage += resampleBuffer.len;
if (queueBuffer.usage > SAMPLE_BUFFER_SIZE * 4)
queueBuffer.usage = 0;
}
function queuePop(bytes) {
if (queueBuffer.usage - bytes < 0)
bytes = queueBuffer.usage;
if (bytes <= 0) {
outputBuffer.len = 0;
return;
}
/* fill rest until full */
var rest = ringBuffer.size - ringBuffer.usage;
for (var i = 0; i < rest; i++) {
var pos = ringBuffer.writePos + i < ringBuffer.size ? ringBuffer.writePos + i : ringBuffer.writePos + i - ringBuffer.size;
if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo) { if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo) {
ringBuffer.data.left[pos] = sampleBuffer.data.left[i]; for (var i = 0; i < bytes; i++) {
ringBuffer.data.right[pos] = sampleBuffer.data.right[i]; outputBuffer.data.left[i] = queueBuffer.data.left[i];
} else outputBuffer.data.right[i] = queueBuffer.data.right[i];
ringBuffer.data.left[pos] = sampleBuffer.data.left[i];
} }
ringBuffer.writePos += rest; if (ringBuffer.writePos >= ringBuffer.size) ringBuffer.writePos -= ringBuffer.size; } else {
ringBuffer.usage += rest; for (var i = 0; i < bytes; i++)
outputBuffer.data.left[i] = queueBuffer.data.left[i];
rate = sampleBuffer.size;// + (sampleBuffer.size >> 1);
drop = true;
}
if (ringBuffer.usage - rate < 0) {
//console.log('ringBuffer underflow', ringBuffer.usage, rate);
rate += ringBuffer.usage - rate;
drop = false;
} }
outputBuffer.len = bytes;
var playBuffer = {}; queueBuffer.usage -= bytes;
playBuffer.left = new Float32Array(rate);
if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo)
playBuffer.right = new Float32Array(rate);
if (ringBuffer.usage - rate >= 0) {
for (var i = 0; i < rate; i++) {
var pos = ringBuffer.readPos + i < ringBuffer.size ? ringBuffer.readPos + i : ringBuffer.readPos + i - ringBuffer.size;
if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo) { if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo) {
playBuffer.left[i] = ringBuffer.data.left[pos]; for (var i = 0; i < queueBuffer.usage; i++) {
playBuffer.right[i] = ringBuffer.data.right[pos]; queueBuffer.data.left[i] = queueBuffer.data.left[bytes + i];
} else queueBuffer.data.right[i] = queueBuffer.data.right[bytes + i];
playBuffer.left[i] = ringBuffer.data.left[pos]; }
} else {
for (var i = 0; i < queueBuffer.usage; i++)
queueBuffer.data.left[i] = queueBuffer.data.left[bytes + i];
}
} }
ringBuffer.readPos += rate; if (ringBuffer.readPos >= ringBuffer.size) ringBuffer.readPos -= ringBuffer.size;
ringBuffer.usage -= rate;
if (drop) { function resample() {
ringBuffer.readPos += ringBuffer.usage; if (ringBuffer.readPos >= ringBuffer.size) ringBuffer.readPos -= ringBuffer.size; var step = amiga_sample_rate / driver.ctx.sampleRate;
ringBuffer.usage = 0;
resampleBuffer.len = Math.floor(sampleBuffer.pos / step);
if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo) {
for (var i = 0, j = 0.0; i < resampleBuffer.len; i++, j += step) {
resampleBuffer.data.left[i] = sampleBuffer.data.left[j >> 0];
resampleBuffer.data.right[i] = sampleBuffer.data.right[j >> 0];
} }
} else {
for (var i = 0, j = 0.0; i < resampleBuffer.len; i++, j += step)
resampleBuffer.data.left[i] = sampleBuffer.data.left[j >> 0];
} }
//console.log(sampleBuffer.pos, ringBuffer.usage, rate);
sampleBuffer.pos = 0; sampleBuffer.pos = 0;
return [playBuffer, rate];
} }
function fillWebAudio(e) { function audioProcess(e) {
var rb = fillRingBuffer(); if (sampleBuffer.pos == 0)
if (rb === false) return; return;
var playBuffer = rb[0];
var rate = rb[1];
var step = rate / sampleBuffer.size; //var _pos = sampleBuffer.pos;
resample();
queuePush();
queuePop(SAMPLE_BUFFER_SIZE);
//console.log(_pos, resampleBuffer.len, queueBuffer.usage, outputBuffer.len);
if (outputBuffer.len == 0)
return;
var step = outputBuffer.len / SAMPLE_BUFFER_SIZE;
if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo) { if (AMIGA.config.audio.channels == SAEV_Config_Audio_Channels_Stereo) {
var data1 = e.outputBuffer.getChannelData(0); var data1 = e.outputBuffer.getChannelData(0);
var data2 = e.outputBuffer.getChannelData(1); var data2 = e.outputBuffer.getChannelData(1);
for (var i = 0, j = 0.0; i < sampleBuffer.size; i++, j += step) { for (var i = 0, j = 0.0; i < SAMPLE_BUFFER_SIZE; i++, j += step) {
data1[i] = playBuffer.left[j >> 0]; data1[i] = outputBuffer.data.left[j >> 0];
data2[i] = playBuffer.right[j >> 0]; data2[i] = outputBuffer.data.right[j >> 0];
} }
} else { } else {
var data = e.outputBuffer.getChannelData(0); var data = e.outputBuffer.getChannelData(0);
for (var i = 0, j = 0.0; i < sampleBuffer.size; i++, j += step) for (var i = 0, j = 0.0; i < SAMPLE_BUFFER_SIZE; i++, j += step)
data[i] = playBuffer.left[j >> 0]; data[i] = outputBuffer.data.left[j >> 0];
} }
} }
} }

View file

@ -2834,3 +2834,4 @@ function Blitter() {
return [blit_interrupt, blt_info.blitzero]; return [blit_interrupt, blt_info.blitzero];
} }
} }

View file

@ -1326,3 +1326,4 @@ function CIA() {
this.store16(addr + 2, value & 0xffff); this.store16(addr + 2, value & 0xffff);
} }
} }

View file

@ -86,7 +86,6 @@ function Config() {
enabled: false, enabled: false,
mode:0, mode:0,
channels: 0, channels: 0,
rate: 0,
filter: false filter: false
}; };
this.ports = [{ this.ports = [{
@ -169,7 +168,7 @@ function Config() {
c.video.enabled = true; c.video.enabled = true;
c.video.scale = false; c.video.scale = false;
c.video.ntsc = false; c.video.ntsc = false;
c.video.framerate = 2; c.video.framerate = 1; //2
c.video.hresolution = 1 ? RES_HIRES : RES_LORES; c.video.hresolution = 1 ? RES_HIRES : RES_LORES;
c.video.vresolution = 1 ? VRES_DOUBLE : VRES_NONDOUBLE; c.video.vresolution = 1 ? VRES_DOUBLE : VRES_NONDOUBLE;
c.video.scandoubler = 0 ? true : false; c.video.scandoubler = 0 ? true : false;
@ -182,7 +181,6 @@ function Config() {
//c.audio.mode = SAEV_Config_Audio_Mode_Play_Best; //c.audio.mode = SAEV_Config_Audio_Mode_Play_Best;
c.audio.mode = SAEV_Config_Audio_Mode_Play; c.audio.mode = SAEV_Config_Audio_Mode_Play;
c.audio.channels = SAEV_Config_Audio_Channels_Stereo; c.audio.channels = SAEV_Config_Audio_Channels_Stereo;
c.audio.rate = SAEV_Config_Audio_Rate_44100;
c.audio.filter = false; c.audio.filter = false;
c.ports[0].type = SAEV_Config_Ports_Type_Mouse; c.ports[0].type = SAEV_Config_Ports_Type_Mouse;
@ -216,3 +214,4 @@ function Config() {
} }
configSetDefaults(this); configSetDefaults(this);
} }

View file

@ -99,11 +99,6 @@ const SAEV_Config_Audio_Mode_Play_Best = 2;
const SAEV_Config_Audio_Channels_Mono = 1; const SAEV_Config_Audio_Channels_Mono = 1;
const SAEV_Config_Audio_Channels_Stereo = 2; const SAEV_Config_Audio_Channels_Stereo = 2;
const SAEV_Config_Audio_Rate_11025 = 1;
const SAEV_Config_Audio_Rate_22050 = 2;
const SAEV_Config_Audio_Rate_44100 = 3;
const SAEV_Config_Audio_Rate_48000 = 4;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* input */ /* input */
@ -368,3 +363,4 @@ const MAX_WORDS_PER_LINE = 100;
const DO_SPRITES = 1; const DO_SPRITES = 1;
const FAST_COLORS = 0; const FAST_COLORS = 0;

View file

@ -601,3 +601,4 @@ function Copper() {
} }
}*/ }*/
} }

View file

@ -5253,3 +5253,4 @@ function CPU() {
} }
} }
} }

View file

@ -724,5 +724,5 @@ function Custom() {
this.store16(addr & 0xfffe, value >>> 16); this.store16(addr & 0xfffe, value >>> 16);
this.store16((addr + 2) & 0xfffe, value & 0xffff); this.store16((addr + 2) & 0xfffe, value & 0xffff);
} }
} }

View file

@ -1659,3 +1659,4 @@ function Disk() {
return dmal; return dmal;
} }
} }

View file

@ -138,7 +138,6 @@ function Events() {
this.calc_vsynctimebase = function (hz) { this.calc_vsynctimebase = function (hz) {
vsynctimebase = Math.floor(SYNCBASE / hz); vsynctimebase = Math.floor(SYNCBASE / hz);
//vsynctimebase >>= 1;//(AMIGA.config.video.framerate > 1 ? 1 : 0);
}; };
/*---------------------------------*/ /*---------------------------------*/
@ -632,18 +631,11 @@ function Events() {
if (vs) { if (vs) {
this.vsync_handler_pre(); this.vsync_handler_pre();
if (AMIGA.config.video.framerate > 1) { //vsyncresume = true; throw new VSync(0, 'vsync');
if (AMIGA.playfield.framecnt == AMIGA.config.video.framerate - 1) {
//vsyncresume = true;
//throw new VSync(0, 'vsync');
AMIGA.state = ST_IDLE; AMIGA.state = ST_IDLE;
} }
} else {
//vsyncresume = true;
//throw new VSync(0, 'vsync');
AMIGA.state = ST_IDLE;
}
}
this.hsync_handler_post(vs); this.hsync_handler_post(vs);
} }
} }

View file

@ -174,3 +174,4 @@ function Expansion() {
} }
} }
} }

View file

@ -896,3 +896,4 @@ function Input() {
//BUG.info('Input.JOYTEST() $%04x', v); //BUG.info('Input.JOYTEST() $%04x', v);
} }
} }

View file

@ -652,3 +652,4 @@ function Memory() {
this.chip.data[i] = this.rom.data[i]; this.chip.data[i] = this.rom.data[i];
}*/ }*/
} }

View file

@ -251,7 +251,7 @@ function Playfield() {
var last_max_ypos = 0; var last_max_ypos = 0;
var extra_y_adjust = 0; var extra_y_adjust = 0;
var center_reset = true; var center_reset = true;
this.framecnt = 0; var framecnt = 0;
var last_redraw_point = 0; var last_redraw_point = 0;
var lores_shift = 0; var lores_shift = 0;
@ -675,7 +675,7 @@ function Playfield() {
} }
this.nodraw = function () { this.nodraw = function () {
return this.framecnt != 0; return framecnt != 0;
}; };
this.doflickerfix = function () { this.doflickerfix = function () {
@ -4069,7 +4069,6 @@ function Playfield() {
equ_vblank_toggle = false; equ_vblank_toggle = false;
} }
// long/short field refresh rate adjustment // long/short field refresh rate adjustment
//this.vblank_hz >>= (AMIGA.config.video.framerate > 1 ? 1 : 0);
this.vblank_hz = this.vblank_hz * (this.maxvpos * 2 + 1) / ((this.maxvpos + this.lof_current) * 2); this.vblank_hz = this.vblank_hz * (this.maxvpos * 2 + 1) / ((this.maxvpos + this.lof_current) * 2);
this.maxvpos_nom = this.maxvpos; this.maxvpos_nom = this.maxvpos;
@ -4896,8 +4895,8 @@ function Playfield() {
}; };
this.count_frame = function () { this.count_frame = function () {
if (++this.framecnt >= AMIGA.config.video.framerate) if (++framecnt >= AMIGA.config.video.framerate)
this.framecnt = 0; framecnt = 0;
}; };
this.vsync_handle_redraw = function () { //(long_frame, lof_changed, bplcon0p, bplcon3p) this.vsync_handle_redraw = function () { //(long_frame, lof_changed, bplcon0p, bplcon3p)
@ -4905,7 +4904,7 @@ function Playfield() {
if (this.lof_changed || this.lof_store || interlace_seen <= 0 || doublescan < 0 || last_redraw_point >= 2) { if (this.lof_changed || this.lof_store || interlace_seen <= 0 || doublescan < 0 || last_redraw_point >= 2) {
last_redraw_point = 0; last_redraw_point = 0;
if (this.framecnt == 0) if (framecnt == 0)
this.finish_drawing_frame(); this.finish_drawing_frame();
/*#if 0 /*#if 0
if (interlace_seen > 0) if (interlace_seen > 0)
@ -4918,7 +4917,7 @@ function Playfield() {
#endif*/ #endif*/
this.count_frame(); this.count_frame();
if (this.framecnt == 0) if (framecnt == 0)
this.init_drawing_frame(); this.init_drawing_frame();
} }
}; };
@ -5198,7 +5197,7 @@ function Playfield() {
}; };
this.hsync_record_line_state = function (lineno, how, changed) { this.hsync_record_line_state = function (lineno, how, changed) {
if (this.framecnt != 0) if (framecnt != 0)
return; return;
//changed += ((frame_redraw_necessary ? 1 : 0) + ((lineno >= lightpen_y1 && lineno <= lightpen_y2) ? 1 : 0)); //changed += ((frame_redraw_necessary ? 1 : 0) + ((lineno >= lightpen_y1 && lineno <= lightpen_y2) ? 1 : 0));
@ -6319,3 +6318,4 @@ function Playfield() {
#endif*/ #endif*/
} }
} }

View file

@ -232,3 +232,4 @@ function RTC() {
this.store16(addr + 2, value & 0xffff); this.store16(addr + 2, value & 0xffff);
} }
} }

View file

@ -79,3 +79,4 @@ function Serial()
return serdat; return serdat;
} }
} }

View file

@ -475,3 +475,4 @@ function Debug() {
}*/ }*/

View file

@ -296,3 +296,4 @@ function Vide0() {
ctx.drawArrays(ctx.TRIANGLES, 0, 6); ctx.drawArrays(ctx.TRIANGLES, 0, 6);
} }
} }