Mercurial > vba-clojure
comparison clojure/com/aurellem/run/image.clj @ 515:f68d600b089c
colors now work properly.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 22 Jun 2012 21:21:48 -0500 |
parents | a00981db92da |
children | 7eac27143ab9 |
comparison
equal
deleted
inserted
replaced
514:a00981db92da | 515:f68d600b089c |
---|---|
231 (fn [[r g b]] | 231 (fn [[r g b]] |
232 (= (max r g b) b )) | 232 (= (max r g b) b )) |
233 | 233 |
234 (seq (set (vals gb-color-map))))))))) | 234 (seq (set (vals gb-color-map))))))))) |
235 ;;view (cortex.sense/view-image) | 235 ;;view (cortex.sense/view-image) |
236 target (File. user-home "proj/vba-clojure/gb-color-map-unique.png")] | 236 target |
237 (File. user-home "proj/vba-clojure/gb-color-map-unique.png")] | |
237 (dorun (for [x (range 68) y (range 69)] | 238 (dorun (for [x (range 68) y (range 69)] |
238 (let [[r g b] (get pix (+ x (* 68 y)) [0 0 0]) | 239 (let [[r g b] (get pix (+ x (* 68 y)) [0 0 0]) |
239 rgb (+ (bit-shift-left r 16) | 240 rgb (+ (bit-shift-left r 16) |
240 (bit-shift-left g 8) | 241 (bit-shift-left g 8) |
241 b)] | 242 b)] |
285 (File. user-home "/proj/vba-clojure/images/test-gb-image.png"))) | 286 (File. user-home "/proj/vba-clojure/images/test-gb-image.png"))) |
286 | 287 |
287 (def test-image-2 | 288 (def test-image-2 |
288 (ImageIO/read | 289 (ImageIO/read |
289 (File. user-home "/proj/vba-clojure/images/test-gb-image-2.png"))) | 290 (File. user-home "/proj/vba-clojure/images/test-gb-image-2.png"))) |
291 | |
292 (def test-image-color | |
293 (ImageIO/read | |
294 (File. user-home "/proj/vba-clojure/images/colors-test.png"))) | |
295 | |
290 | 296 |
291 | 297 |
292 | 298 |
293 (defn rgb->triplet [rgb] | 299 (defn rgb->triplet [rgb] |
294 (let [r (bit-shift-right (bit-and rgb 0xFF0000) 16) | 300 (let [r (bit-shift-right (bit-and rgb 0xFF0000) 16) |
599 ;; section | 605 ;; section |
600 (write-data | 606 (write-data |
601 (+ base-address (count A)) | 607 (+ base-address (count A)) |
602 character-data-address | 608 character-data-address |
603 (flatten | 609 (flatten |
604 (map gb-tile->bytes (:tiles gb-image))))] | 610 (map gb-tile->bytes (:tiles gb-image)))) |
611 (select-LCD-bank 1)] | |
605 B (flatten B) | 612 B (flatten B) |
606 | 613 |
607 | 614 |
608 C [;; [ ] write image to the screen in terms of tiles | 615 C [;; [ ] write image to the screen in terms of tiles |
609 (write-image | 616 (write-image |
610 (+ base-address (+ (count A) (count B))) | 617 (+ base-address (+ (count A) (count B))) |
611 BG-1-address | 618 BG-1-address |
612 (map first (:data gb-image)))] | 619 (map second (:data gb-image))) |
620 (select-LCD-bank 0)] | |
613 | 621 |
614 C (flatten C) | 622 C (flatten C) |
615 | 623 |
616 D [;; [ ] specifiy pallets for each character | 624 D [;; [ ] specifiy pallets for each character |
617 (select-LCD-bank 1) | 625 |
618 ;;(write-image | 626 (write-image |
619 ;; (+ base-address (+ (count A) (count B) (count C))) | 627 (+ base-address (+ (count A) (count B) (count C))) |
620 ;; BG-1-address | 628 BG-1-address |
621 ;;(map second (:data gb-image))) | 629 (map first (:data gb-image))) |
622 | 630 |
623 | 631 |
624 ;; [X] reactivate the LCD display | 632 ;; [X] reactivate the LCD display |
625 ;; we're using only BG images, located at | 633 ;; we're using only BG images, located at |
626 ;; BG-1 (0x9800), with background character data | 634 ;; BG-1 (0x9800), with background character data |
627 ;; stored starting at 0x8000 | 635 ;; stored starting at 0x8000 |