comparison clojure/com/aurellem/run/image.clj @ 491:2304906d443b

added function to pack gb-rgb bytes
author Robert McIntyre <rlm@mit.edu>
date Thu, 24 May 2012 17:33:25 -0500
parents 09b3bc0b71b5
children 716752719a78
comparison
equal deleted inserted replaced
488:09b3bc0b71b5 491:2304906d443b
86 86
87 ;; return color; 87 ;; return color;
88 ;; } 88 ;; }
89 89
90 90
91 (def intensity 91
92 [0x00 0x10 0x20 0x30 0x40 0x50 0x5e 0x6c 0x7a 0x88 0x94
93 0xa0 0xae 0xb7 0xbf 0xc6 0xce 0xd3 0xd9 0xdf 0xe3 0xe7
94 0xeb 0xef 0xf3 0xf6 0xf9 0xfb 0xfd 0xfe 0xff 0xff])
95 92
96 (def influence 93 (def image-program-target 0xB000)
97 [[16 4 4]
98 [8 16 8]
99 [0 8 16]])
100 94
101 (defn rgb->gb-rb [[r g b]] 95
102 (let [color-matrix 96 (def display-width 160)
103 (map 97 (def display-height 144)
104 (fn [color-row] 98
105 (map 99
106 (fn [color] 100
107 (bit-shift-right 101 ;{:r :g :b }
108 (* (intensity (bit-shift-right r 3)) 102
109 color) 5)))))])) 103 (def character-data 0x8000)
110 104 (def character-data-end 0x97FF)
111 105
106
107
108
109 (def BG-data-1 0x9800)
110
111 (def BG-data-2 0x9C00)
112
113 (def OAM 0xFE00)
114
115
116 (def bg-pallet-select 0xFF68)
117 (def bg-pallet-data 0xFF69)
118
119 (def obj-palette-select 0xFF6A)
120 (def obj-palette-data 0xFF6B)
121
122
123
124 (def video-bank-select-register 0xFF4F)
125
126
127
128 (defn gb-rgb->bits [r g b]
129 (assert (< 0 r 32))
130 (assert (< 0 g 32))
131 (assert (< 0 b 32))
132 [(bit-and
133 0xFF
134 (+
135 r
136 (bit-shift-left g 5)))
137
138 (+
139 (bit-shift-right g 3)
140 (bit-shift-left b 2))])
141
142
143
144
145 )
146
147 (defn display-one-color
148 "Displayes a single color onto the gameboy screen. input rgb in
149 gameboy rgb."
150 [r g b]
151
152
153
154
155
156 )