1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-25 18:33:11 +00:00

apple2 cassette export w/ c2t

This commit is contained in:
Steven Hugg 2018-09-25 19:46:24 -04:00
parent 780b232259
commit 22e79612ee
4 changed files with 72 additions and 1 deletions

View File

@ -63,6 +63,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#" id="item_record_video">Record Video...</a></li>
<li><a class="dropdown-item" href="#" id="item_share_file">Share Playable Link...</a></li>
<li><a class="dropdown-item" href="#" id="item_export_cassette">Make Cassette Audio...</a></li>
</ul>
</li>
<li class="dropdown dropdown-submenu">

31
lib/c2t.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -353,6 +353,39 @@ function _shareEmbedLink(e) {
return true;
}
function _downloadCassetteFile(e) {
if (current_output == null) { // TODO
alert("Please fix errors before exporting.");
return true;
}
var addr = compparams && compparams.code_start;
if (addr === undefined) {
alert("Cassette export is not supported on this platform.");
return true;
}
loadScript('lib/c2t.js', () => {
var stdout = '';
var print_fn = function(s) { stdout += s + "\n"; }
var c2t = window['c2t']({
noInitialRun:true,
print:print_fn,
printErr:print_fn
});
var FS = c2t['FS'];
var rompath = getCurrentMainFilename() + ".bin";
var audpath = getCurrentMainFilename() + ".wav";
FS.writeFile(rompath, current_output, {encoding:'binary'});
var args = ["-2bc", rompath+','+addr.toString(16), audpath];
c2t.callMain(args);
var audout = FS.readFile(audpath, {'encoding':'binary'});
if (audout) {
var blob = new Blob([audout], {type: "audio/wav"});
saveAs(blob, audpath);
alert(stdout);
}
});
}
function fixFilename(fn : string) : string {
if (platform_id.startsWith('vcs') && fn.indexOf('.') <= 0)
fn += ".a"; // legacy stuff
@ -892,6 +925,10 @@ function setupDebugControls(){
$("#item_download_zip").click(_downloadProjectZipFile);
$("#item_download_allzip").click(_downloadAllFilesZipFile);
$("#item_record_video").click(_recordVideo);
if (platform_id == 'apple2')
$("#item_export_cassette").click(_downloadCassetteFile);
else
$("#item_export_cassette").hide();
if (platform.setFrameRate && platform.getFrameRate) {
$("#dbg_slower").click(_slowerFrameRate);
$("#dbg_faster").click(_fasterFrameRate);

View File

@ -128,6 +128,7 @@ var PLATFORM_PARAMS = {
cfgfile: 'apple2-hgr.cfg',
libargs: ['apple2.lib'],
__CODE_RUN__: 16384,
code_start: 0x803,
},
'apple2-e': {
define: '__APPLE2__',
@ -1514,8 +1515,9 @@ function executeBuildSteps() {
return {errors:[{line:0, msg:e+""}]}; // TODO: catch errors already generated?
}
if (step.result) {
step.result.params = step.params;
// errors? return them
if (step.result.errors) {
if (step.result.errors && step.result.errors.length) {
applyDefaultErrorPath(step.result.errors, step.path);
return step.result;
}