diff clojure/com/aurellem/run/image.clj @ 514:a00981db92da

can now display black and white images (still working on color).
author Robert McIntyre <rlm@mit.edu>
date Fri, 22 Jun 2012 21:03:04 -0500
parents 3dbb863eb801
children f68d600b089c
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/run/image.clj	Fri Jun 22 18:58:47 2012 -0500
     1.2 +++ b/clojure/com/aurellem/run/image.clj	Fri Jun 22 21:03:04 2012 -0500
     1.3 @@ -284,6 +284,12 @@
     1.4    (ImageIO/read
     1.5     (File. user-home "/proj/vba-clojure/images/test-gb-image.png")))
     1.6  
     1.7 +(def test-image-2
     1.8 +  (ImageIO/read
     1.9 +   (File. user-home "/proj/vba-clojure/images/test-gb-image-2.png")))
    1.10 +
    1.11 +
    1.12 +
    1.13  (defn rgb->triplet [rgb]
    1.14    (let [r (bit-shift-right (bit-and rgb 0xFF0000) 16)
    1.15          g (bit-shift-right (bit-and rgb 0xFF00)    8)
    1.16 @@ -299,7 +305,7 @@
    1.17  
    1.18  (defn gb-tiles [^BufferedImage image]
    1.19    (for [tile (range 360)]
    1.20 -    (for [x (range 8) y (range 8)]
    1.21 +    (for [y (range 8) x (range 8)]
    1.22        (vga-rgb->gb-rgb
    1.23         (rgb->triplet
    1.24          (.getRGB image (+ x (* 8 (rem tile 20)))
    1.25 @@ -463,7 +469,7 @@
    1.26          data])))
    1.27  
    1.28  (defn write-image
    1.29 -  "Assume the image data is 160x144 pixels specified as 360 blocks."
    1.30 +  "Assume the image data is specified as 360 blocks."
    1.31    [base-address target-address image-data]
    1.32    
    1.33    (let [len (count image-data)
    1.34 @@ -511,7 +517,7 @@
    1.35              
    1.36              0x1D ;; dec E
    1.37              0x20
    1.38 -            (->signed-8-bit -18) ;; contunue writing picture
    1.39 +            (->signed-8-bit -18) ;; contunue writing image
    1.40  
    1.41              0xC3
    1.42              (reverse
    1.43 @@ -609,10 +615,10 @@
    1.44  
    1.45          D [;; [ ] specifiy pallets for each character
    1.46             (select-LCD-bank 1)
    1.47 -           (write-image
    1.48 -            (+ base-address (+ (count A) (count B) (count C)))
    1.49 -            BG-1-address
    1.50 -            (map second (:data gb-image)))
    1.51 +           ;;(write-image
    1.52 +           ;; (+ base-address (+ (count A) (count B) (count C)))
    1.53 +           ;; BG-1-address
    1.54 +           ;;(map second (:data gb-image)))
    1.55  
    1.56  
    1.57             ;; [X] reactivate the LCD display