mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-19 07:30:55 +00:00
apple2 cassette export w/ c2t
This commit is contained in:
parent
780b232259
commit
22e79612ee
@ -63,6 +63,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
|||||||
<ul class="dropdown-menu">
|
<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_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_share_file">Share Playable Link...</a></li>
|
||||||
|
<li><a class="dropdown-item" href="#" id="item_export_cassette">Make Cassette Audio...</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li class="dropdown dropdown-submenu">
|
<li class="dropdown dropdown-submenu">
|
||||||
|
31
lib/c2t.js
Normal file
31
lib/c2t.js
Normal file
File diff suppressed because one or more lines are too long
37
src/ui.ts
37
src/ui.ts
@ -353,6 +353,39 @@ function _shareEmbedLink(e) {
|
|||||||
return true;
|
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 {
|
function fixFilename(fn : string) : string {
|
||||||
if (platform_id.startsWith('vcs') && fn.indexOf('.') <= 0)
|
if (platform_id.startsWith('vcs') && fn.indexOf('.') <= 0)
|
||||||
fn += ".a"; // legacy stuff
|
fn += ".a"; // legacy stuff
|
||||||
@ -892,6 +925,10 @@ function setupDebugControls(){
|
|||||||
$("#item_download_zip").click(_downloadProjectZipFile);
|
$("#item_download_zip").click(_downloadProjectZipFile);
|
||||||
$("#item_download_allzip").click(_downloadAllFilesZipFile);
|
$("#item_download_allzip").click(_downloadAllFilesZipFile);
|
||||||
$("#item_record_video").click(_recordVideo);
|
$("#item_record_video").click(_recordVideo);
|
||||||
|
if (platform_id == 'apple2')
|
||||||
|
$("#item_export_cassette").click(_downloadCassetteFile);
|
||||||
|
else
|
||||||
|
$("#item_export_cassette").hide();
|
||||||
if (platform.setFrameRate && platform.getFrameRate) {
|
if (platform.setFrameRate && platform.getFrameRate) {
|
||||||
$("#dbg_slower").click(_slowerFrameRate);
|
$("#dbg_slower").click(_slowerFrameRate);
|
||||||
$("#dbg_faster").click(_fasterFrameRate);
|
$("#dbg_faster").click(_fasterFrameRate);
|
||||||
|
@ -128,6 +128,7 @@ var PLATFORM_PARAMS = {
|
|||||||
cfgfile: 'apple2-hgr.cfg',
|
cfgfile: 'apple2-hgr.cfg',
|
||||||
libargs: ['apple2.lib'],
|
libargs: ['apple2.lib'],
|
||||||
__CODE_RUN__: 16384,
|
__CODE_RUN__: 16384,
|
||||||
|
code_start: 0x803,
|
||||||
},
|
},
|
||||||
'apple2-e': {
|
'apple2-e': {
|
||||||
define: '__APPLE2__',
|
define: '__APPLE2__',
|
||||||
@ -1514,8 +1515,9 @@ function executeBuildSteps() {
|
|||||||
return {errors:[{line:0, msg:e+""}]}; // TODO: catch errors already generated?
|
return {errors:[{line:0, msg:e+""}]}; // TODO: catch errors already generated?
|
||||||
}
|
}
|
||||||
if (step.result) {
|
if (step.result) {
|
||||||
|
step.result.params = step.params;
|
||||||
// errors? return them
|
// errors? return them
|
||||||
if (step.result.errors) {
|
if (step.result.errors && step.result.errors.length) {
|
||||||
applyDefaultErrorPath(step.result.errors, step.path);
|
applyDefaultErrorPath(step.result.errors, step.path);
|
||||||
return step.result;
|
return step.result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user