 (defn make-handler-sets
   "Create possible opcode set for opcode-list"
   [opcode]
+  ;; TODO: cljs lack format
   (let [code (format "%04X" opcode)
         ZNNN (format "%SNNN" (subs code 0 1))
         ZXNN (format "%SXNN" (subs code 0 1))

  "Parse the code to find how many VX, VY, NNN, NN, N
  and create argument lists."
  [opcode]
  (let [code (format "%04X" opcode)]
    {:NNN (subs code 1 4)
     :NN  (subs code 2 4)
     :N   (subs code 3 4)
     :VX  (subs code 1 2)
     :VY  (subs code 2 3)}))

(defn find-match-handler
  "Search for matching handler in handler list.

  (make-handler-sets 0xf155)  ; => #{:FXY5 :FNNN :FXYN :FX55 :F155 :FXNN}
  (make-handler-args 0xf155)  ; =>  {:NNN 155, :NN 55, :N 5, :VX 1, :VY 5}
  (find-match-handler @opcode-list 0xf155) ; => :FX55

  ;; build the opmap with :type
  (build-opmap 0xf155) ; => {:NNN 155, :NN 55, :N 5, :VX 1, :VY 5, :type :FX55}

