1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Graphic Equalizer: C:/Project Marcel & Oliver/Graphic_Equalizer/src/display.hcc Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.9.1 -->
<div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="globals.html">Globals</a></div>
<div class="nav">
<a class="el" href="dir_000000.html">C:</a> / <a class="el" href="dir_000001.html">Project Marcel & Oliver</a> / <a class="el" href="dir_000002.html">Graphic_Equalizer</a> / <a class="el" href="dir_000004.html">src</a></div>
<h1>display.hcc</h1><a href="display_8hcc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001
00019 <span class="comment">/*</span>
00020 <span class="comment"> * Set the Clock rate for this domain. 25.175 Mhz is required for the Video output.</span>
00021 <span class="comment"> */</span>
00022 <span class="preprocessor">#define PAL_TARGET_CLOCK_RATE 25175000</span>
00023 <span class="preprocessor"></span>
00024 <span class="comment">/******** System Includes *************/</span>
00025 <span class="preprocessor">#include <stdlib.hch></span>
00026
00027 <span class="preprocessor">#include "pal_master.hch"</span>
00028
00029 <span class="comment">/******** Application Includes ********/</span>
00030 <span class="preprocessor">#include "<a class="code" href="configuration_8hch.html">configuration.hch</a>"</span>
00031 <span class="preprocessor">#include "<a class="code" href="audio_8hch.html">audio.hch</a>"</span>
00032 <span class="preprocessor">#include "<a class="code" href="eventhandler__shared_8hch.html">eventhandler_shared.hch</a>"</span>
00033 <span class="preprocessor">#include "<a class="code" href="mouse__shared_8hch.html">mouse_shared.hch</a>"</span>
00034 <span class="preprocessor">#include "<a class="code" href="display__shared_8hch.html">display_shared.hch</a>"</span>
00035 <span class="preprocessor">#include "<a class="code" href="display_8hch.html">display.hch</a>"</span>
00036
00037 <span class="preprocessor">#if HAVE_DEBUG</span>
00038 <span class="preprocessor"></span><span class="preprocessor"> #include "debug.hch"</span>
00039 <span class="preprocessor">#endif</span>
00040 <span class="preprocessor"></span>
00041
00042
00043 <span class="comment">/*</span>
00044 <span class="comment"> * Channel to notify others when new mousedata is available. If so</span>
00045 <span class="comment"> * Then mousedata struct is updated with shared data.</span>
00046 <span class="comment"> */</span>
00047 chan <span class="keywordtype">unsigned</span> 1 maskupdate_notification;
00048
00049
00050
<a name="l00064"></a><a class="code" href="display_8hcc.html#a3">00064</a> <span class="keywordtype">void</span> <a class="code" href="display_8hcc.html#a3">display_main</a>(skindata_t *skindata, audiodata_t *audiodata, events_t *events, mousedata_t *mousedata) {
00065 <span class="comment">/*</span>
00066 <span class="comment"> * Setup macro's RAM/Video handles and to coordinate pixel writing.</span>
00067 <span class="comment"> */</span>
00068 macro expr CLOCKRATE = PAL_ACTUAL_CLOCK_RATE;
00069 macro expr VIDEOOUT = PalVideoOutOptimalCT(CLOCKRATE);
00070 macro expr RAM_BANK0 = PalPL2RAMCT(0);
00071 macro expr DW = PalPL2RAMGetMaxDataWidthCT();
00072 macro expr AW = PalPL2RAMGetMaxAddressWidthCT();
00073 macro expr VISIBLEX = PalVideoOutGetVisibleX(VIDEOOUT, CLOCKRATE);
00074 macro expr TOTALX = PalVideoOutGetTotalX(VIDEOOUT, CLOCKRATE);
00075 macro expr TOTALY = PalVideoOutGetTotalY(VIDEOOUT);
00076 macro expr SCANX = PalVideoOutGetX(VIDEOOUT);
00077 macro expr SCANY = PalVideoOutGetY(VIDEOOUT);
00078
00079 <span class="keywordtype">unsigned</span> DW pixeldata;
00080 <span class="keywordtype">unsigned</span> 24 visual_graph_color;
00081 <span class="keywordtype">unsigned</span> AW address, address_offset;
00082
00083 <span class="comment">/*</span>
00084 <span class="comment"> * To draw something usefull when only drawing our mask, we simply draw the</span>
00085 <span class="comment"> * mask itself. Thus creating a blueish image to help identify all interesting</span>
00086 <span class="comment"> * area's on the screen. Otherwise we only use the last 24 bits, the RGB values</span>
00087 <span class="comment"> * to draw on the screen.</span>
00088 <span class="comment"> */</span>
00089 <span class="preprocessor">#if (USE_MASK_ONLY && HAVE_SMARTMEDIA)</span>
00090 <span class="preprocessor"></span><span class="preprocessor">#define PIXEL (0 @ pixeldata[31:24])</span>
00091 <span class="preprocessor"></span><span class="preprocessor">#else</span>
00092 <span class="preprocessor"></span><span class="preprocessor">#define PIXEL (pixeldata <- 24)</span>
00093 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00094 <span class="preprocessor"></span>
00095 <span class="comment">/*</span>
00096 <span class="comment"> * If the passed button_state tells us the button is active, then we</span>
00097 <span class="comment"> * the button is 'on' and we draw it inverted. Otherwise we draw the</span>
00098 <span class="comment"> * area of the button normally.</span>
00099 <span class="comment"> */</span>
00100 macro proc draw_button(button_state) {
00101 <span class="keywordflow">if</span> (button_state == pixeldata[31:24]) {
00102 PalVideoOutWrite(VIDEOOUT, ~PIXEL);
00103 } <span class="keywordflow">else</span> {
00104 PalVideoOutWrite(VIDEOOUT, PIXEL);
00105 }
00106 }
00107
00108 <span class="comment">/*</span>
00109 <span class="comment"> * Prime Rendering Pipeline to start where the skin starts.</span>
00110 <span class="comment"> */</span>
00111 PalPL2RAMSetReadAddress(RAM_BANK0, ADDRESS_SKIN_START);
00112
00113 <span class="comment">/*</span>
00114 <span class="comment"> * Run the following tasks indefinatly and in parallel</span>
00115 <span class="comment"> */</span>
00116 <span class="keywordflow">while</span> (TRUE) {
00117 par {
00118 <span class="comment">/*</span>
00119 <span class="comment"> * Before starting this loop we allready set the the</span>
00120 <span class="comment"> * address. Therefor we can start reading the</span>
00121 <span class="comment"> * previously set address and prepare the next address</span>
00122 <span class="comment"> * for the next cycle.</span>
00123 <span class="comment"> */</span>
00124 PalPL2RAMRead(RAM_BANK0, &pixeldata);
00125 PalPL2RAMSetReadAddress(RAM_BANK0, address_offset +address);
00126
00127 <span class="comment">/*</span>
00128 <span class="comment"> */</span>
00129 <span class="keywordflow">switch</span> (events->mode) {
00130 <span class="keywordflow">case</span> MODE_HELP:
00131 address_offset = ADDRESS_HELP_START;
00132 <span class="keywordflow">break</span>;
00133 <span class="keywordflow">case</span> MODE_GRAPH:
00134 address_offset = ADDRESS_GRAPHMASK_START;
00135 <span class="keywordflow">break</span>;
00136 <span class="keywordflow">default</span>:
00137 address_offset = ADDRESS_SKIN_START;
00138 <span class="keywordflow">break</span>;
00139 }
00140
00141 <span class="keywordflow">if</span> (MODE_GRAPH == events->mode) {
00142 par {
00143 visual_graph_color = ((<span class="keywordtype">unsigned</span> 8)(0 @ audiodata->fft_info.read[pixeldata[31:24]]) << 1) @ ((<span class="keywordtype">unsigned</span> 8)(0 @ audiodata->fft_info.read[pixeldata[31:24]]) << -1) @ ((<span class="keywordtype">unsigned</span> 8)(0 @ audiodata->fft_info.read[pixeldata[31:24]]) << 0);
00144 PalVideoOutWrite(VIDEOOUT, 0 @ visual_graph_color);
00145 }
00146 } <span class="keywordflow">else</span> {
00147 <span class="comment">/*</span>
00148 <span class="comment"> * Determin what to draw where here. Every case has an</span>
00149 <span class="comment"> * if else statement comparing wether to draw something</span>
00150 <span class="comment"> * special or the background. Every specific drawing</span>
00151 <span class="comment"> * obviously only happens in the masked area.</span>
00152 <span class="comment"> */</span>
00153 <span class="keywordflow">switch</span> (pixeldata[31:24]) {
00154 <span class="comment">/*</span>
00155 <span class="comment"> */</span>
00156 <span class="keywordflow">case</span> AREA_WAVEFORM:
00157 <span class="keywordflow">if</span> (SCANY == 0 @ skindata->area_waveform_bottom -(0 @ (audiodata->ifft_info.read[((SCANX -(0 @ skindata->area_waveform_left)) <-8)]))) {
00158 PalVideoOutWrite(VIDEOOUT, skindata->color_area_waveform);
00159 } <span class="keywordflow">else</span> {
00160 PalVideoOutWrite(VIDEOOUT, PIXEL);
00161 }
00162 <span class="keywordflow">break</span>;
00163
00164 <span class="comment">/*</span>
00165 <span class="comment"> * Volume control over the Y-axis.</span>
00166 <span class="comment"> */</span>
00167 <span class="keywordflow">case</span> AREA_VOLUME_YAXIS:
00168 <span class="comment">/*</span>
00169 <span class="comment"> * The volume_position stores the</span>
00170 <span class="comment"> * highest point of our bar. Every</span>
00171 <span class="comment"> * pixel after this point is drawn.</span>
00172 <span class="comment"> */</span>
00173 <span class="keywordflow">if</span> (SCANY >= 0 @ events->volume_position) {
00174 PalVideoOutWrite(VIDEOOUT, skindata->color_area_volume);
00175 } <span class="keywordflow">else</span> {
00176 PalVideoOutWrite(VIDEOOUT, PIXEL);
00177 }
00178 <span class="keywordflow">break</span>;
00179
00180 <span class="comment">/*</span>
00181 <span class="comment"> * Spectrum Analyzer</span>
00182 <span class="comment"> */</span>
00183 <span class="keywordflow">case</span> AREA_SPECTRUM_ANALYZER:
00184 <span class="comment">/*</span>
00185 <span class="comment"> * We draw every pixel that is smaller TODO</span>
00186 <span class="comment"> */</span>
00187 <span class="keywordflow">if</span> ((SCANY >= (0 @ skindata->area_spectrum_bottom) -(0 @ audiodata->fft_info.read[(SCANX -(0 @ skindata->area_spectrum_left))[9:2]])) && ((SCANX -(0 @ skindata->area_spectrum_left)) <- 2)) {
00188 PalVideoOutWrite(VIDEOOUT, PIXEL_SPECTRUM);
00189 } <span class="keywordflow">else</span> {
00190 PalVideoOutWrite(VIDEOOUT, PIXEL);
00191 }
00192 <span class="keywordflow">break</span>;
00193
00194 <span class="comment">/*</span>
00195 <span class="comment"> * Since all buttons are drawn equally, either</span>
00196 <span class="comment"> * we draw them normally or we inverse them, we</span>
00197 <span class="comment"> * can handle them almost equally.</span>
00198 <span class="comment"> */</span>
00199 <span class="keywordflow">case</span> BUTTON_PRESET_1: <span class="comment">/* fall through */</span>
00200 <span class="keywordflow">case</span> BUTTON_PRESET_2: <span class="comment">/* fall through */</span>
00201 <span class="keywordflow">case</span> BUTTON_PRESET_3: <span class="comment">/* fall through */</span>
00202 <span class="keywordflow">case</span> BUTTON_PRESET_4: <span class="comment">/* fall through */</span>
00203 <span class="keywordflow">case</span> BUTTON_PRESET_5: <span class="comment">/* fall through */</span>
00204 <span class="keywordflow">case</span> BUTTON_PRESET_6:
00205 <span class="comment">/*</span>
00206 <span class="comment"> * The active preset tells us what</span>
00207 <span class="comment"> * button is currently enabled. We must</span>
00208 <span class="comment"> * however not forget to add the preset</span>
00209 <span class="comment"> * button offset to possibly match it</span>
00210 <span class="comment"> * with the current mask.</span>
00211 <span class="comment"> */</span>
00212 draw_button((events->active_preset +BUTTON_PRESET_1) <- 8);
00213 <span class="keywordflow">break</span>;
00214
00215 <span class="keywordflow">case</span> BUTTON_CONVEX_FULL: <span class="comment">/* fall through */</span>
00216 <span class="keywordflow">case</span> BUTTON_CONVEX_HALF: <span class="comment">/* fall through */</span>
00217 <span class="keywordflow">case</span> BUTTON_PRECISE: <span class="comment">/* fall through */</span>
00218 <span class="keywordflow">case</span> BUTTON_CONCAVE_HALF: <span class="comment">/* fall through */</span>
00219 <span class="keywordflow">case</span> BUTTON_CONCAVE_FULL:
00220 <span class="comment">/*</span>
00221 <span class="comment"> * equalizer mode tells us what button</span>
00222 <span class="comment"> * is currently enabled. By adding the</span>
00223 <span class="comment"> * equalizer mode button offset we can</span>
00224 <span class="comment"> * safley check wether it matches our</span>
00225 <span class="comment"> * mask.</span>
00226 <span class="comment"> */</span>
00227 draw_button((0 @ events->equalizer_mode) +BUTTON_CONVEX_FULL);
00228 <span class="keywordflow">break</span>;
00229
00230 <span class="keywordflow">case</span> BUTTON_LOG:
00231 <span class="comment">/*</span>
00232 <span class="comment"> * </span>
00233 <span class="comment"> */</span>
00234 draw_button((0 @ audiodata->display_log) +BUTTON_LOG);
00235 <span class="keywordflow">break</span>;
00236
00237 <span class="comment">/*</span>
00238 <span class="comment"> * The default case is split up into two parts</span>
00239 <span class="comment"> * actually. This is because we have 128 bands</span>
00240 <span class="comment"> * for the equalizer and thus as many mask</span>
00241 <span class="comment"> * entries. Since we don't want 128 identical</span>
00242 <span class="comment"> * cases we check wether the equalizer mask is</span>
00243 <span class="comment"> * currently active and if so draw it. If this</span>
00244 <span class="comment"> * is not the case we simply draw the</span>
00245 <span class="comment"> * background.</span>
00246 <span class="comment"> */</span>
00247 <span class="keywordflow">default</span>:
00248 <span class="comment">/* (pixeldata[31:24] <= AREA_EQUALIZER_MAX) && */</span>
00249 <span class="keywordflow">if</span> (!events->locked_equalizer) {
00250 <span class="keywordflow">if</span> ((AREA_EQUALIZER_MIN <= pixeldata[31:24]) && ((SCANY -(0 @ SCANY <- 1)) == 0 @ events->equalizer_display[(pixeldata[31:24] -AREA_EQUALIZER_MIN) <- 7])) {
00251 PalVideoOutWrite(VIDEOOUT, skindata->color_equalizer);
00252 } <span class="keywordflow">else</span> {
00253 PalVideoOutWrite(VIDEOOUT, PIXEL);
00254 }
00255 } <span class="keywordflow">else</span> {
00256 PalVideoOutWrite(VIDEOOUT, PIXEL);
00257 }
00258 <span class="keywordflow">break</span>;
00259 }
00260 }
00261
00262 <span class="comment">/*</span>
00263 <span class="comment"> * We compare our current X and Y scan positions of the</span>
00264 <span class="comment"> * output to the x and y data of the mouse. When those</span>
00265 <span class="comment"> * are equal we set the current mask to the mask stored</span>
00266 <span class="comment"> * in memory at that location. We then know what mask</span>
00267 <span class="comment"> * is to be used for events.</span>
00268 <span class="comment"> */</span>
00269 <span class="keywordflow">if</span> (MOUSE_UPDATED == mousedata->status) {
00270 <span class="keywordflow">if</span> ((SCANX == 0 @ mousedata->x) && (SCANY == 0 @ mousedata->y)) {
00271 par {
00272 events->mask = pixeldata[31:24];
00273 mousedata->status = MOUSE_NOT_UPDATED;
00274 maskupdate_notification ! MOUSE_UPDATED;
00275 }
00276 } <span class="keywordflow">else</span> {
00277 delay;
00278 }
00279 } <span class="keywordflow">else</span> {
00280 delay;
00281 }
00282
00283 <span class="comment">/*</span>
00284 <span class="comment"> * The current position of the screen can lay in an</span>
00285 <span class="comment"> * area called the blanking area. We don't have data</span>
00286 <span class="comment"> * for this area as it is not drawn. We therefor have</span>
00287 <span class="comment"> * to determin wether we are beyond the visible area of</span>
00288 <span class="comment"> * the screen, but before the end of the total width of</span>
00289 <span class="comment"> * the screen. Our pipeline consists of 4 total stages.</span>
00290 <span class="comment"> * Therefor we have to substract 4 pixels.</span>
00291 <span class="comment"> */</span>
00292 <span class="keywordflow">if</span> ((SCANX > (VISIBLEX - 4)) && (SCANX <= (TOTALX - 4))) {
00293 <span class="comment">/*</span>
00294 <span class="comment"> * We are in the blanking area of the screen.</span>
00295 <span class="comment"> * If we are on the last line, and thus last</span>
00296 <span class="comment"> * pixel we reset our address counter.</span>
00297 <span class="comment"> */</span>
00298 <span class="keywordflow">if</span> (SCANY == (TOTALY -1)) {
00299 <span class="comment">/*</span>
00300 <span class="comment"> * Reset our draw address counter to 0.</span>
00301 <span class="comment"> */</span>
00302 address = 0;
00303 } <span class="keywordflow">else</span> {
00304 <span class="comment">/*</span>
00305 <span class="comment"> * We should not ever get inhere. To</span>
00306 <span class="comment"> * keep everything consequent however,</span>
00307 <span class="comment"> * we add a delay.</span>
00308 <span class="comment"> */</span>
00309 delay;
00310 }
00311 } <span class="keywordflow">else</span> {
00312 <span class="comment">/*</span>
00313 <span class="comment"> * Increase the memory counter for each pixel</span>
00314 <span class="comment"> * drawn thus keeping the memory location in</span>
00315 <span class="comment"> * sync with the current pixel position.</span>
00316 <span class="comment"> */</span>
00317 address++;
00318 }
00319 }
00320 }
00321 } <span class="comment">/* --- display_main() --- */</span>
00322
00323
00324
<a name="l00337"></a><a class="code" href="display_8hcc.html#a4">00337</a> <span class="keywordtype">void</span> <a class="code" href="display_8hcc.html#a4">reload_equalizer</a>(events_t *events, <span class="keywordtype">unsigned</span> 4 *equalizer_levels) {
00338 <span class="keywordtype">unsigned</span> 7 equalizer_band;
00339
00340 events->locked_equalizer = TRUE;
00341 delay;
00342 <span class="keywordflow">do</span> {
00343 events->equalizer_display[equalizer_band] = equalizer_table_inv[equalizer_levels[equalizer_band]];
00344 equalizer_band++;
00345 } <span class="keywordflow">while</span> (equalizer_band);
00346 events->locked_equalizer = FALSE;
00347 } <span class="comment">/* --- reload_equalizer() --- */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Nov 29 12:04:47 2004 for Graphic Equalizer by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address>
</body>
</html>
|