Add progress display for C64 transfer to editor
This commit is contained in:
parent
b0434c4938
commit
5a7cf8f7c4
2 changed files with 17 additions and 4 deletions
|
@ -756,6 +756,10 @@ Additionally ensures correct line numbers on the way, as a bonus."
|
||||||
(defparameter *refresh-asm-functions-p* #+swank t #-swank nil
|
(defparameter *refresh-asm-functions-p* #+swank t #-swank nil
|
||||||
"If non-NIL, reload asm function addresses from listing before every compile.")
|
"If non-NIL, reload asm function addresses from listing before every compile.")
|
||||||
|
|
||||||
|
(defun draw-transfer-progress (progress total)
|
||||||
|
(move-cursor 1 0)
|
||||||
|
(format *eio* "Uploading, ~D/~D~%" progress total))
|
||||||
|
|
||||||
(defun com-compile-buffer ()
|
(defun com-compile-buffer ()
|
||||||
(when *refresh-asm-functions-p*
|
(when *refresh-asm-functions-p*
|
||||||
(usc:usc-init))
|
(usc:usc-init))
|
||||||
|
@ -783,7 +787,12 @@ Additionally ensures correct line numbers on the way, as a bonus."
|
||||||
:if-exists :supersede)
|
:if-exists :supersede)
|
||||||
(dolist (byte bytes)
|
(dolist (byte bytes)
|
||||||
(write-byte byte output)))
|
(write-byte byte output)))
|
||||||
(usc::send-data-to-c64 (coerce bytes 'vector))))))
|
(clear-screen)
|
||||||
|
(usc::send-data-to-c64 (coerce bytes 'vector)
|
||||||
|
'draw-transfer-progress)
|
||||||
|
(clear-screen)
|
||||||
|
(redisplay-view (current-view *editor*))
|
||||||
|
(redisplay-status-line :completely-p t)))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@
|
||||||
|
|
||||||
(defparameter *c64-tty* "/dev/ttyACM0")
|
(defparameter *c64-tty* "/dev/ttyACM0")
|
||||||
|
|
||||||
(defun %send-data-to-c64 (data)
|
(defun %send-data-to-c64 (data progress-callback)
|
||||||
(declare (type vector data))
|
(declare (type vector data))
|
||||||
(with-open-file (stream *c64-tty*
|
(with-open-file (stream *c64-tty*
|
||||||
:direction :io
|
:direction :io
|
||||||
|
@ -236,6 +236,7 @@
|
||||||
(write-byte (ldb (byte 8 0) length) stream)
|
(write-byte (ldb (byte 8 0) length) stream)
|
||||||
(write-byte (ldb (byte 8 8) length) stream)
|
(write-byte (ldb (byte 8 8) length) stream)
|
||||||
(force-output stream)
|
(force-output stream)
|
||||||
|
(funcall progress-callback index length)
|
||||||
(loop :while (< index length)
|
(loop :while (< index length)
|
||||||
:for amount := (min 16 (- (length data) index))
|
:for amount := (min 16 (- (length data) index))
|
||||||
:do (format t "~D " amount)
|
:do (format t "~D " amount)
|
||||||
|
@ -246,9 +247,10 @@
|
||||||
:across (subseq data index (incf index amount))
|
:across (subseq data index (incf index amount))
|
||||||
:do (write-byte byte stream))
|
:do (write-byte byte stream))
|
||||||
(force-output stream)
|
(force-output stream)
|
||||||
|
(funcall progress-callback index length)
|
||||||
(format t "~D~%" index)))))
|
(format t "~D~%" index)))))
|
||||||
|
|
||||||
(defun send-data-to-c64 (data)
|
(defun send-data-to-c64 (data &optional progress-callback)
|
||||||
(declare (type vector data))
|
(declare (type vector data))
|
||||||
(handler-bind
|
(handler-bind
|
||||||
((file-error
|
((file-error
|
||||||
|
@ -258,7 +260,9 @@
|
||||||
(warn "Failed to open C64 transfer TTY.")
|
(warn "Failed to open C64 transfer TTY.")
|
||||||
(abort c)))))
|
(abort c)))))
|
||||||
(restart-case
|
(restart-case
|
||||||
(%send-data-to-c64 data)
|
(%send-data-to-c64 data (or progress-callback
|
||||||
|
(lambda (progress total)
|
||||||
|
(declare (ignore progress total)))))
|
||||||
(abort ()))))
|
(abort ()))))
|
||||||
|
|
||||||
(defun compile-and-send-to-c64 (string)
|
(defun compile-and-send-to-c64 (string)
|
||||||
|
|
Loading…
Add table
Reference in a new issue