Add basic unfinished C64 upload function to USC
This commit is contained in:
parent
d22bd4ee49
commit
57a47e6ba3
1 changed files with 29 additions and 0 deletions
|
@ -220,3 +220,32 @@
|
||||||
:do (write-byte byte stream)))
|
:do (write-byte byte stream)))
|
||||||
(format t "Finished, wrote compiled program to \"~A\".~%"
|
(format t "Finished, wrote compiled program to \"~A\".~%"
|
||||||
output-filepath))))
|
output-filepath))))
|
||||||
|
|
||||||
|
(defun send-data-to-c64 (data)
|
||||||
|
(with-open-file (stream "/dev/ttyACM0"
|
||||||
|
:direction :io
|
||||||
|
:element-type '(unsigned-byte 8)
|
||||||
|
:if-exists :overwrite)
|
||||||
|
(sleep 2.5)
|
||||||
|
(let ((index 0)
|
||||||
|
(length (length data)))
|
||||||
|
(write-byte (ldb (byte 8 0) length) stream)
|
||||||
|
(write-byte (ldb (byte 8 8) length) stream)
|
||||||
|
(force-output stream)
|
||||||
|
(loop :while (< index length)
|
||||||
|
:for amount := (min 16 (- (length data) index))
|
||||||
|
:do (format t "~D " amount)
|
||||||
|
(read-byte stream)
|
||||||
|
(write-byte amount stream)
|
||||||
|
(format t "~D " index)
|
||||||
|
(loop :for byte
|
||||||
|
:across (subseq data index (incf index amount))
|
||||||
|
:do (write-byte byte stream))
|
||||||
|
(force-output stream)
|
||||||
|
(format t "~D~%" index)))))
|
||||||
|
|
||||||
|
(defun compile-and-send-to-c64 (string)
|
||||||
|
(let ((bytes (compile-string-to-bytes string :print-ir-p t)))
|
||||||
|
(handler-case
|
||||||
|
(send-data-to-c64 (coerce bytes 'vector))
|
||||||
|
(error (c) (abort c)))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue