diff clojure/com/aurellem/run/image.clj @ 505:f992a0a0480d

fix compilation problem.
author Robert McIntyre <rlm@mit.edu>
date Wed, 20 Jun 2012 13:59:21 -0500
parents 81e43f0350db
children 130ba9f49db5
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/run/image.clj	Mon Jun 18 18:56:49 2012 -0500
     1.2 +++ b/clojure/com/aurellem/run/image.clj	Wed Jun 20 13:59:21 2012 -0500
     1.3 @@ -126,23 +126,6 @@
     1.4  (defn display-one-color
     1.5    "Displayes a single color onto the gameboy screen. input rgb in
     1.6     gameboy rgb."
     1.7 -<<<<<<< local
     1.8 -  [[r g b]]
     1.9 -  ;; construct a kernel that displays a single color
    1.10 -  (let
    1.11 -      [palettes (repeat 8 [r g b])
    1.12 -       kernel-address 0xC000
    1.13 -       kernel
    1.14 -       [0xF3 ;; disable interrupts
    1.15 -        (clear-music-registers)
    1.16 -        (frame-metronome)
    1.17 -        (set-palettes obj-palette-select obj-palette-data palettes)
    1.18 -        (set-palettes bg-palette-select bg-palette-data palettes)
    1.19 -        (infinite-loop)]]
    1.20 -    (-> (set-memory-range (second (music-base))
    1.21 -                          kernel-address (flatten kernel))
    1.22 -        (PC! kernel-address))))
    1.23 -=======
    1.24    ([state [r g b]]
    1.25       ;; construct a kernel that displays a single color
    1.26       (let
    1.27 @@ -161,16 +144,16 @@
    1.28    ([[r g b]]
    1.29       (display-one-color @current-state [r g b])))
    1.30  
    1.31 -(require 'cortex.sense)
    1.32 +;;(require 'cortex.sense)
    1.33  (import java.awt.image.BufferedImage)
    1.34  
    1.35 -(defn show-screenshot []
    1.36 -  (let [im (BufferedImage. 160 144 BufferedImage/TYPE_INT_RGB)
    1.37 -        pix (vec (pixels))
    1.38 -        view (cortex.sense/view-image)]
    1.39 -    (dorun (for [x (range 160) y (range 144)]
    1.40 -             (.setRGB im x y (pix (+ x (* 160 y))))))
    1.41 -    (view im)))
    1.42 +;; (defn show-screenshot []
    1.43 +;;   (let [im (BufferedImage. 160 144 BufferedImage/TYPE_INT_RGB)
    1.44 +;;         pix (vec (pixels))
    1.45 +;;         view (cortex.sense/view-image)]
    1.46 +;;     (dorun (for [x (range 160) y (range 144)]
    1.47 +;;              (.setRGB im x y (pix (+ x (* 160 y))))))
    1.48 +;;     (view im)))
    1.49  
    1.50  (defn gb-rgb->vga-rgb [[r g b]]
    1.51    (let [vga-rgb  
    1.52 @@ -245,15 +228,15 @@
    1.53                          (= (max r g b) b ))
    1.54                       
    1.55                        (seq (set (vals gb-color-map)))))))))
    1.56 -        view (cortex.sense/view-image)
    1.57 +        ;;view (cortex.sense/view-image)
    1.58          target (File. user-home "proj/vba-clojure/gb-color-map-unique.png")]
    1.59      (dorun (for [x (range 68) y (range 69)]
    1.60               (let [[r g b] (get pix (+ x (* 68 y)) [0 0 0])
    1.61                     rgb (+ (bit-shift-left r 16)
    1.62                            (bit-shift-left g 8)
    1.63                            b)]
    1.64 -             (.setRGB im x y rgb))))
    1.65 -    (view im)
    1.66 +               (.setRGB im x y rgb))))
    1.67 +    ;;(view im)
    1.68      (doto
    1.69          (.next (ImageIO/getImageWritersByFormatName "png"))
    1.70        (.setOutput (FileImageOutputStream. target))
    1.71 @@ -269,7 +252,7 @@
    1.72             (vec
    1.73              (for [b (range 32) g (range 32)]
    1.74                (gb-color-map [r g b])))))
    1.75 -        view (cortex.sense/view-image)
    1.76 +        ;;view (cortex.sense/view-image)
    1.77          target (File. user-home "proj/vba-clojure/gb-color-map.png")]
    1.78  
    1.79      (dorun
    1.80 @@ -285,7 +268,7 @@
    1.81                       (+ 3 (* 35 (rem s-index 6)) x)
    1.82                       (+ 3 (* 35 (int (/ s-index 6))) y)
    1.83                       rgb))))))
    1.84 -    (view im)
    1.85 +    ;;(view im)
    1.86      (doto
    1.87          (.next (ImageIO/getImageWritersByFormatName "png"))
    1.88        (.setOutput (FileImageOutputStream. target))
    1.89 @@ -343,24 +326,38 @@
    1.90  
    1.91  (defn absorb-combine-4 [objs]
    1.92  
    1.93 -  
    1.94 -
    1.95    )
    1.96  
    1.97  (defn palettes [^BufferedImage image]
    1.98    (let [palettes (map tile->palette (gb-tiles image))
    1.99          unique-palettes (absorb-contract (set palettes))]
   1.100      unique-palettes))
   1.101 -    
   1.102 -    
   1.103 -        
   1.104 -    
   1.105 -    
   1.106 -    
   1.107 +
   1.108 +(defn wait-until-v-blank
   1.109 +  "Modified version of frame-metronome. waits untill LY == 144,
   1.110 +   indicating start of v-blank period."
   1.111 +  []
   1.112 +  (let [timing-loop
   1.113 +        [0x01 ; \
   1.114 +         0x44 ;  | load 0xFF44 into BC
   1.115 +         0xFF ; /  
   1.116 +         0x0A] ;; (BC) -> A, now A = LY (vertical line coord)
   1.117 +        continue-if-144
   1.118 +        [0xFE
   1.119 +         144  ;; compare LY (in A) with 144
   1.120 +         0x20 ;; jump back to beginning if LY != 144 (not-v-blank)
   1.121 +         (->signed-8-bit
   1.122 +          (+ -4 (- (count timing-loop))))]]
   1.123 +    (concat timing-loop continue-if-144)))
   1.124  
   1.125  
   1.126  (defn display-image-kernel [^BufferedImage image]
   1.127 - 
   1.128 +  ;; assume image tile data is stored at 0xA000
   1.129 +  ;;   "      "   palette date is at     0xB000
   1.130 +  
   1.131  
   1.132  
   1.133 -  )
   1.134 \ No newline at end of file
   1.135 +  )
   1.136 +
   1.137 +
   1.138 +