diff clojure/com/aurellem/gb_driver.clj @ 101:37711ff4a7bc

filled out functions for the rest of the registers.
author Robert McIntyre <rlm@mit.edu>
date Mon, 12 Mar 2012 12:41:55 -0500
parents 2090bcb78f44
children d2e00ea31508
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb_driver.clj	Mon Mar 12 12:37:04 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb_driver.clj	Mon Mar 12 12:41:55 2012 -0500
     1.3 @@ -179,15 +179,7 @@
     1.4  (def write-registers!
     1.5    (write-cpu-data Gb/NUM_REGISTERS #(Gb/writeRegisters %)))
     1.6  
     1.7 -;; (defn write-memory! [new-memory]
     1.8 -;;   (let [store (int-array new-memory)]
     1.9 -;;     (assert (= Gb/GB_MEMORY) (count new-memory))
    1.10 -;;     (Gb/writeMemory new-memory)))
    1.11 -    
    1.12 -
    1.13 -;; TODO add register names
    1.14 -
    1.15 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    1.16 +;;;;;  Registers  ;;;;;;;;;;;;;;;;;;;;;;;;;;;
    1.17  
    1.18  (defmacro gen-get-set-register [name index]
    1.19    (let [name-bang (symbol (str name "!"))]
    1.20 @@ -210,9 +202,8 @@
    1.21                (update-state)))
    1.22           ([new-register#]
    1.23              (~name-bang @current-state new-register#))))))
    1.24 -  
    1.25  
    1.26 -
    1.27 +;; 16 bit registers
    1.28  (gen-get-set-register PC 0)
    1.29  (gen-get-set-register SP 1)
    1.30  (gen-get-set-register AF 2)
    1.31 @@ -221,8 +212,28 @@
    1.32  (gen-get-set-register HL 5)
    1.33  (gen-get-set-register IFF 6)
    1.34  
    1.35 -
    1.36 -
    1.37 +;; 8 bit registers
    1.38 +(gen-get-set-register DIV 7)
    1.39 +(gen-get-set-register TIMA 8)
    1.40 +(gen-get-set-register TMA 9)
    1.41 +(gen-get-set-register IF 11)
    1.42 +(gen-get-set-register LCDC 12)
    1.43 +(gen-get-set-register STAT 13)
    1.44 +(gen-get-set-register SCY 14)
    1.45 +(gen-get-set-register SCX 15)
    1.46 +(gen-get-set-register LY 16)
    1.47 +(gen-get-set-register DMA 18)
    1.48 +(gen-get-set-register WY 19)
    1.49 +(gen-get-set-register WX 20)
    1.50 +(gen-get-set-register VBK 21)
    1.51 +(gen-get-set-register HDMA1 22)
    1.52 +(gen-get-set-register HDMA2 23)
    1.53 +(gen-get-set-register HDMA3 24)
    1.54 +(gen-get-set-register HDMA4 25)
    1.55 +(gen-get-set-register HDMA5 26)
    1.56 +(gen-get-set-register SVBK 27)
    1.57 +(gen-get-set-register IE 28)
    1.58 +                            
    1.59  ;;;;;;;;;;;;;;;
    1.60  
    1.61  (defmacro defn-memo