Skip to content

Commit

Permalink
renamings for read from/write to vm (exclamation point)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly committed Jan 19, 2017
1 parent 0dd2e7e commit c2ec3b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/clojure/ifas2/beautify.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(fn [url vm-map] url))

(defmethod beautify-story-sequence :default [url vm-map]
[(read-text-from-vm vm-map)])
[(read-text-from-vm! vm-map)])

(defn- standard-beautify-out
"Replaces a bunch of weird special characters often occuring within stories with something more suitable for voice interfaces (often empty)."
Expand Down
2 changes: 1 addition & 1 deletion src/main/clojure/ifas2/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
vm-map (create-zax-vm story-file url dump64)]

(when next-command
(write-text-to-vm vm-map (beautify-in url next-command)))
(write-text-to-vm! vm-map (beautify-in url next-command)))

(let [raw-texts (beautify-story-sequence url vm-map)
raw-text (str/join "\n" raw-texts)
Expand Down
14 changes: 7 additions & 7 deletions src/main/clojure/ifas2/zax.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
(com.zaxsoft.zmachine ZCPU)
(java.io File)))

(defn destroy-zax-vm
(defn destroy-zax-vm!
"Destroys the given interpreter."
[vm-map]
(zax-quit (:cpu vm-map)))

(defn read-text-from-vm
(defn read-text-from-vm!
"Given an interpreter, reads available text from it."
([vm-map] (->> vm-map :zax-ui .getStoryTextStream (read-text-from-vm []) (apply str)))
([vm-map] (->> vm-map :zax-ui .getStoryTextStream (read-text-from-vm! []) (apply str)))
([acc chan]
(let [[txt port] (alts!! [(timeout 100) chan])]
(if txt
(read-text-from-vm (conj acc txt) chan)
(read-text-from-vm! (conj acc txt) chan)
acc))))

(defn write-text-to-vm
(defn write-text-to-vm!
"Given an interpreter, writes the specified text to it"
[vm-map text]
(thread
Expand All @@ -42,8 +42,8 @@
cpu (ZCPU. zax-ui)]
(.initialize cpu story-file-path)
(.start cpu)
(when dump64
(read-text-from-vm {:zax-ui zax-ui}) ; discard initial output
(when dump64 ;;TODO: do we need to pause here to allow some time for the story to load?
(read-text-from-vm! {:zax-ui zax-ui}) ; discard initial output
(zop-restore cpu
zax-ui
(.getAbsolutePath (base64-as-file dump64))))
Expand Down

0 comments on commit c2ec3b8

Please sign in to comment.