diff --git a/apple2js.html b/apple2js.html index 40b5794..2a365c2 100644 --- a/apple2js.html +++ b/apple2js.html @@ -348,6 +348,7 @@
diff --git a/apple2jse.html b/apple2jse.html index 1f44f56..76765d2 100644 --- a/apple2jse.html +++ b/apple2jse.html @@ -353,6 +353,7 @@ diff --git a/js/ui/apple2.js b/js/ui/apple2.js index b67f92b..3991c54 100644 --- a/js/ui/apple2.js +++ b/js/ui/apple2.js @@ -766,6 +766,13 @@ export function openOptions() { } export function openPrinterModal() { + let mimeType = 'application/octet-stream'; + let data = _printer.getRawOutput(); + let a = document.querySelector('#raw_printer_output'); + + let blob = new Blob([data], { 'type': mimeType}); + a.href = window.URL.createObjectURL(blob); + a.download = 'raw_printer_output.bin'; MicroModal.show('printer-modal'); } diff --git a/js/ui/printer.js b/js/ui/printer.js index e372c85..44957ee 100644 --- a/js/ui/printer.js +++ b/js/ui/printer.js @@ -27,6 +27,8 @@ export default function Printer(el) { var paper = document.querySelector(el); var _lineBuffer = ''; var _line; + var _rawLen = 0; + var _raw = new Uint8Array(1024); function newLine() { _line = document.createElement('div'); @@ -56,16 +58,29 @@ export default function Printer(el) { _lineBuffer += c; } _line.innerText = _lineBuffer; + _raw[_rawLen] = val; + _rawLen++; + if (_rawLen > _raw.length) { + let newRaw = new Uint8Array(_raw.length * 2); + newRaw.set(_raw); + _raw = newRaw; + } }, clear: function() { _lineBuffer = ''; paper.innerHTML = ""; newLine(); + _raw = new Uint8Array(1024); + _rawLen = 0; }, hasPrintout: function() { return paper.text.length; + }, + + getRawOutput: function() { + return _raw.slice(0, _rawLen); } }; }