Add progress display for C64 transfer to editor

This commit is contained in:
John Lorentzson 2025-07-29 11:36:12 +02:00
parent b0434c4938
commit 5a7cf8f7c4
2 changed files with 17 additions and 4 deletions

View file

@ -756,6 +756,10 @@ Additionally ensures correct line numbers on the way, as a bonus."
(defparameter *refresh-asm-functions-p* #+swank t #-swank nil
"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 ()
(when *refresh-asm-functions-p*
(usc:usc-init))
@ -783,7 +787,12 @@ Additionally ensures correct line numbers on the way, as a bonus."
:if-exists :supersede)
(dolist (byte bytes)
(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)))))

View file

@ -223,7 +223,7 @@
(defparameter *c64-tty* "/dev/ttyACM0")
(defun %send-data-to-c64 (data)
(defun %send-data-to-c64 (data progress-callback)
(declare (type vector data))
(with-open-file (stream *c64-tty*
:direction :io
@ -236,6 +236,7 @@
(write-byte (ldb (byte 8 0) length) stream)
(write-byte (ldb (byte 8 8) length) stream)
(force-output stream)
(funcall progress-callback index length)
(loop :while (< index length)
:for amount := (min 16 (- (length data) index))
:do (format t "~D " amount)
@ -246,9 +247,10 @@
:across (subseq data index (incf index amount))
:do (write-byte byte stream))
(force-output stream)
(funcall progress-callback index length)
(format t "~D~%" index)))))
(defun send-data-to-c64 (data)
(defun send-data-to-c64 (data &optional progress-callback)
(declare (type vector data))
(handler-bind
((file-error
@ -258,7 +260,9 @@
(warn "Failed to open C64 transfer TTY.")
(abort c)))))
(restart-case
(%send-data-to-c64 data)
(%send-data-to-c64 data (or progress-callback
(lambda (progress total)
(declare (ignore progress total)))))
(abort ()))))
(defun compile-and-send-to-c64 (string)