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
|
<!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 2: 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="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</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>
<a name="l00022"></a><a class="code" href="display_8hcc.html#a0">00022</a> <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="smartmedia__shared_8hch.html">smartmedia_shared.hch</a>"</span>
00035 <span class="preprocessor">#include "<a class="code" href="display__shared_8hch.html">display_shared.hch</a>"</span>
00036 <span class="preprocessor">#include "<a class="code" href="display_8hch.html">display.hch</a>"</span>
00037
00038 <span class="preprocessor">#if HAVE_DEBUG</span>
00039 <span class="preprocessor"></span><span class="preprocessor"> #include "debug.hch"</span>
00040 <span class="preprocessor">#endif</span>
00041 <span class="preprocessor"></span>
00042
00043
00044 <span class="comment">/*</span>
00045 <span class="comment"> * Channel to notify others when new mousedata is available. If so</span>
00046 <span class="comment"> * Then mousedata struct is updated with shared data.</span>
00047 <span class="comment"> */</span>
<a name="l00048"></a><a class="code" href="eventhandler_8hcc.html#a0">00048</a> chan <span class="keywordtype">unsigned</span> 1 maskupdate_notification;
00049
00050
00051
<a name="l00065"></a><a class="code" href="display_8hcc.html#a2">00065</a> <span class="keywordtype">void</span> <a class="code" href="display_8hcc.html#a2">display_main</a>(<a class="code" href="structskindata__t.html">skindata_t</a> *skindata, <a class="code" href="structaudiodata__t.html">audiodata_t</a> *audiodata, <a class="code" href="structevents__t.html">events_t</a> *events, <a class="code" href="structmousedata__t.html">mousedata_t</a> *mousedata) {
00066 <span class="comment">/*</span>
00067 <span class="comment"> * Setup macro's RAM/Video handles and to coordinate pixel writing.</span>
00068 <span class="comment"> */</span>
00069 macro expr CLOCKRATE = PAL_ACTUAL_CLOCK_RATE;
00070 macro expr VIDEOOUT = PalVideoOutOptimalCT(CLOCKRATE);
00071 macro expr RAM_BANK0 = PalPL2RAMCT(0);
00072 macro expr DW = PalPL2RAMGetMaxDataWidthCT();
00073 macro expr AW = PalPL2RAMGetMaxAddressWidthCT();
00074 macro expr VISIBLEX = PalVideoOutGetVisibleX(VIDEOOUT, CLOCKRATE);
00075 macro expr TOTALX = PalVideoOutGetTotalX(VIDEOOUT, CLOCKRATE);
00076 macro expr TOTALY = PalVideoOutGetTotalY(VIDEOOUT);
00077 macro expr SCANX = PalVideoOutGetX(VIDEOOUT);
00078 macro expr SCANY = PalVideoOutGetY(VIDEOOUT);
00079
00080 <span class="keywordtype">unsigned</span> DW pixeldata;
00081 <span class="keywordtype">unsigned</span> 24 visual_graph_color;
00082 <span class="keywordtype">unsigned</span> AW address, address_offset;
00083
00084
00085
00086 <span class="comment">/*</span>
00087 <span class="comment"> * If the passed button_state tells us the button is active, then we</span>
00088 <span class="comment"> * the button is 'on' and we draw it inverted. Otherwise we draw the</span>
00089 <span class="comment"> * area of the button normally.</span>
00090 <span class="comment"> */</span>
00091 macro proc draw_button(button_state) {
00092 <span class="keywordflow">if</span> (button_state == pixeldata[31:24]) {
00093 PalVideoOutWrite(VIDEOOUT, ~<a class="code" href="display_8hch.html#a1">PIXEL</a>);
00094 } <span class="keywordflow">else</span> {
00095 PalVideoOutWrite(VIDEOOUT, <a class="code" href="display_8hch.html#a1">PIXEL</a>);
00096 }
00097 }
00098
00099 <span class="comment">/*</span>
00100 <span class="comment"> * Prime Rendering Pipeline to start where the skin starts.</span>
00101 <span class="comment"> */</span>
00102 PalPL2RAMSetReadAddress(RAM_BANK0, <a class="code" href="smartmedia__shared_8hch.html#a22">ADDRESS_SKIN_START</a>);
00103
00104 <span class="comment">/*</span>
00105 <span class="comment"> * Run the following tasks indefinatly and in parallel</span>
00106 <span class="comment"> */</span>
00107 <span class="keywordflow">while</span> (TRUE) {
00108 par {
00109 <span class="comment">/*</span>
00110 <span class="comment"> * Before starting this loop we allready set the the</span>
00111 <span class="comment"> * address. Therefor we can start reading the</span>
00112 <span class="comment"> * previously set address and prepare the next address</span>
00113 <span class="comment"> * for the next cycle.</span>
00114 <span class="comment"> */</span>
00115 PalPL2RAMRead(RAM_BANK0, &pixeldata);
00116 PalPL2RAMSetReadAddress(RAM_BANK0, address_offset +address);
00117
00118 <span class="comment">/*</span>
00119 <span class="comment"> */</span>
00120 <span class="keywordflow">switch</span> (events-><a class="code" href="structevents__t.html#o4">mode</a>) {
00121 <span class="keywordflow">case</span> <a class="code" href="eventhandler__shared_8hch.html#a2">MODE_HELP</a>:
00122 address_offset = ADDRESS_HELP_START;
00123 <span class="keywordflow">break</span>;
00124 <span class="keywordflow">case</span> <a class="code" href="eventhandler__shared_8hch.html#a3">MODE_GRAPH</a>:
00125 address_offset = ADDRESS_GRAPHMASK_START;
00126 <span class="keywordflow">break</span>;
00127 <span class="keywordflow">default</span>:
00128 address_offset = ADDRESS_SKIN_START;
00129 <span class="keywordflow">break</span>;
00130 }
00131
00132 <span class="keywordflow">if</span> (<a class="code" href="eventhandler__shared_8hch.html#a3">MODE_GRAPH</a> == events-><a class="code" href="structevents__t.html#o4">mode</a>) {
00133 par {
00134 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);
00135 PalVideoOutWrite(VIDEOOUT, 0 @ visual_graph_color);
00136 }
00137 } <span class="keywordflow">else</span> {
00138 <span class="comment">/*</span>
00139 <span class="comment"> * Determin what to draw where here. Every case has an</span>
00140 <span class="comment"> * if else statement comparing wether to draw something</span>
00141 <span class="comment"> * special or the background. Every specific drawing</span>
00142 <span class="comment"> * obviously only happens in the masked area.</span>
00143 <span class="comment"> */</span>
00144 <span class="keywordflow">switch</span> (pixeldata[31:24]) {
00145 <span class="comment">/*</span>
00146 <span class="comment"> */</span>
00147 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a1">AREA_WAVEFORM</a>:
00148 <span class="keywordflow">if</span> (SCANY == 0 @ skindata->area_waveform_bottom -(0 @ (audiodata->ifft_info.read[((SCANX -(0 @ skindata->area_waveform_left)) <-8)]))) {
00149 PalVideoOutWrite(VIDEOOUT, skindata->color_area_waveform);
00150 } <span class="keywordflow">else</span> {
00151 PalVideoOutWrite(VIDEOOUT, <a class="code" href="display_8hch.html#a1">PIXEL</a>);
00152 }
00153 <span class="keywordflow">break</span>;
00154
00155 <span class="comment">/*</span>
00156 <span class="comment"> * Volume control over the Y-axis.</span>
00157 <span class="comment"> */</span>
00158 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a2">AREA_VOLUME_YAXIS</a>:
00159 <span class="comment">/*</span>
00160 <span class="comment"> * The volume_position stores the</span>
00161 <span class="comment"> * highest point of our bar. Every</span>
00162 <span class="comment"> * pixel after this point is drawn.</span>
00163 <span class="comment"> */</span>
00164 <span class="keywordflow">if</span> (SCANY >= 0 @ events-><a class="code" href="structevents__t.html#o2">volume_position</a>) {
00165 PalVideoOutWrite(VIDEOOUT, skindata->color_area_volume);
00166 } <span class="keywordflow">else</span> {
00167 PalVideoOutWrite(VIDEOOUT, <a class="code" href="display_8hch.html#a1">PIXEL</a>);
00168 }
00169 <span class="keywordflow">break</span>;
00170
00171 <span class="comment">/*</span>
00172 <span class="comment"> * Spectrum Analyzer</span>
00173 <span class="comment"> */</span>
00174 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a3">AREA_SPECTRUM_ANALYZER</a>:
00175 <span class="comment">/*</span>
00176 <span class="comment"> * We draw every pixel that is smaller TODO</span>
00177 <span class="comment"> */</span>
00178 <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)) {
00179 PalVideoOutWrite(VIDEOOUT, <a class="code" href="display_8hch.html#a4">PIXEL_SPECTRUM</a>);
00180 } <span class="keywordflow">else</span> {
00181 PalVideoOutWrite(VIDEOOUT, <a class="code" href="display_8hch.html#a1">PIXEL</a>);
00182 }
00183 <span class="keywordflow">break</span>;
00184
00185 <span class="comment">/*</span>
00186 <span class="comment"> * Since all buttons are drawn equally, either</span>
00187 <span class="comment"> * we draw them normally or we inverse them, we</span>
00188 <span class="comment"> * can handle them almost equally.</span>
00189 <span class="comment"> */</span>
00190 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a7">BUTTON_PRESET_1</a>: <span class="comment">/* fall through */</span>
00191 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a8">BUTTON_PRESET_2</a>: <span class="comment">/* fall through */</span>
00192 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a9">BUTTON_PRESET_3</a>: <span class="comment">/* fall through */</span>
00193 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a10">BUTTON_PRESET_4</a>: <span class="comment">/* fall through */</span>
00194 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a11">BUTTON_PRESET_5</a>: <span class="comment">/* fall through */</span>
00195 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a12">BUTTON_PRESET_6</a>:
00196 <span class="comment">/*</span>
00197 <span class="comment"> * The active preset tells us what</span>
00198 <span class="comment"> * button is currently enabled. We must</span>
00199 <span class="comment"> * however not forget to add the preset</span>
00200 <span class="comment"> * button offset to possibly match it</span>
00201 <span class="comment"> * with the current mask.</span>
00202 <span class="comment"> */</span>
00203 draw_button((events-><a class="code" href="structevents__t.html#o1">active_preset</a> +<a class="code" href="display__shared_8hch.html#a7">BUTTON_PRESET_1</a>) <- 8);
00204 <span class="keywordflow">break</span>;
00205
00206 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a15">BUTTON_PRECISE</a>: <span class="comment">/* fall through */</span>
00207 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a16">BUTTON_CONCAVE_HALF</a>: <span class="comment">/* fall through */</span>
00208 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a14">BUTTON_CONVEX_HALF</a>: <span class="comment">/* fall through */</span>
00209 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a17">BUTTON_CONCAVE_FULL</a>: <span class="comment">/* fall through */</span>
00210 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a13">BUTTON_CONVEX_FULL</a>:
00211 <span class="comment">/*</span>
00212 <span class="comment"> * equalizer mode tells us what button</span>
00213 <span class="comment"> * is currently enabled. By adding the</span>
00214 <span class="comment"> * equalizer mode button offset we can</span>
00215 <span class="comment"> * safley check wether it matches our</span>
00216 <span class="comment"> * mask.</span>
00217 <span class="comment"> */</span>
00218 draw_button((0 @ events-><a class="code" href="structevents__t.html#o5">equalizer_mode</a>) +<a class="code" href="display__shared_8hch.html#a15">BUTTON_PRECISE</a>);
00219 <span class="keywordflow">break</span>;
00220
00221 <span class="keywordflow">case</span> <a class="code" href="display__shared_8hch.html#a4">BUTTON_LOG</a>:
00222 <span class="comment">/*</span>
00223 <span class="comment"> * </span>
00224 <span class="comment"> */</span>
00225 draw_button((0 @ audiodata-><a class="code" href="structaudiodata__t.html#o1">display_log</a>) +<a class="code" href="display__shared_8hch.html#a4">BUTTON_LOG</a>);
00226 <span class="keywordflow">break</span>;
00227
00228 <span class="comment">/*</span>
00229 <span class="comment"> * The default case is split up into two parts</span>
00230 <span class="comment"> * actually. This is because we have 128 bands</span>
00231 <span class="comment"> * for the equalizer and thus as many mask</span>
00232 <span class="comment"> * entries. Since we don't want 128 identical</span>
00233 <span class="comment"> * cases we check wether the equalizer mask is</span>
00234 <span class="comment"> * currently active and if so draw it. If this</span>
00235 <span class="comment"> * is not the case we simply draw the</span>
00236 <span class="comment"> * background.</span>
00237 <span class="comment"> */</span>
00238 <span class="keywordflow">default</span>:
00239 <span class="comment">/* (pixeldata[31:24] <= AREA_EQUALIZER_MAX) && */</span>
00240 <span class="keywordflow">if</span> ((<a class="code" href="display__shared_8hch.html#a20">AREA_EQUALIZER_MIN</a> <= pixeldata[31:24]) && (!events-><a class="code" href="structevents__t.html#o6">locked_display</a>)) {
00241 <span class="keywordflow">if</span> ((SCANY == 0 @ events-><a class="code" href="structevents__t.html#o0">equalizer_display</a>[(pixeldata[31:24] -AREA_EQUALIZER_MIN) <- 7]) || ((SCANY +1) == 0 @ events-><a class="code" href="structevents__t.html#o0">equalizer_display</a>[(pixeldata[31:24] -AREA_EQUALIZER_MIN) <- 7])) {
00242 PalVideoOutWrite(VIDEOOUT, skindata->color_equalizer);
00243 } <span class="keywordflow">else</span> {
00244 PalVideoOutWrite(VIDEOOUT, <a class="code" href="display_8hch.html#a1">PIXEL</a>);
00245 }
00246 } <span class="keywordflow">else</span> {
00247 PalVideoOutWrite(VIDEOOUT, <a class="code" href="display_8hch.html#a1">PIXEL</a>);
00248 }
00249 <span class="keywordflow">break</span>;
00250 }
00251 }
00252
00253 <span class="comment">/*</span>
00254 <span class="comment"> * We compare our current X and Y scan positions of the</span>
00255 <span class="comment"> * output to the x and y data of the mouse. When those</span>
00256 <span class="comment"> * are equal we set the current mask to the mask stored</span>
00257 <span class="comment"> * in memory at that location. We then know what mask</span>
00258 <span class="comment"> * is to be used for events.</span>
00259 <span class="comment"> */</span>
00260 <span class="keywordflow">if</span> (<a class="code" href="mouse__shared_8hch.html#a2">MOUSE_UPDATED</a> == mousedata-><a class="code" href="structmousedata__t.html#o3">status</a>) {
00261 <span class="keywordflow">if</span> ((SCANX == 0 @ mousedata-><a class="code" href="structmousedata__t.html#o0">x</a>) && (SCANY == 0 @ mousedata-><a class="code" href="structmousedata__t.html#o1">y</a>)) {
00262 par {
00263 events-><a class="code" href="structevents__t.html#o3">mask</a> = pixeldata[31:24];
00264 mousedata-><a class="code" href="structmousedata__t.html#o3">status</a> = MOUSE_NOT_UPDATED;
00265 <a class="code" href="display_8hcc.html#a1">maskupdate_notification</a> ! MOUSE_UPDATED;
00266 }
00267 } <span class="keywordflow">else</span> {
00268 delay;
00269 }
00270 } <span class="keywordflow">else</span> {
00271 delay;
00272 }
00273
00274 <span class="comment">/*</span>
00275 <span class="comment"> * The current position of the screen can lay in an</span>
00276 <span class="comment"> * area called the blanking area. We don't have data</span>
00277 <span class="comment"> * for this area as it is not drawn. We therefor have</span>
00278 <span class="comment"> * to determin wether we are beyond the visible area of</span>
00279 <span class="comment"> * the screen, but before the end of the total width of</span>
00280 <span class="comment"> * the screen. Our pipeline consists of 5 total stages.</span>
00281 <span class="comment"> * Therefor we have to substract 5 pixels.</span>
00282 <span class="comment"> */</span>
00283 <span class="keywordflow">if</span> ((SCANX > (VISIBLEX - 5)) && (SCANX <= (TOTALX - 5))) {
00284 <span class="comment">/*</span>
00285 <span class="comment"> * We are in the blanking area of the screen.</span>
00286 <span class="comment"> * If we are on the last line, and thus last</span>
00287 <span class="comment"> * pixel we reset our address counter.</span>
00288 <span class="comment"> */</span>
00289 <span class="keywordflow">if</span> (SCANY == (TOTALY -1)) {
00290 <span class="comment">/*</span>
00291 <span class="comment"> * Reset our draw address counter to 0.</span>
00292 <span class="comment"> */</span>
00293 address = 0;
00294 } <span class="keywordflow">else</span> {
00295 <span class="comment">/*</span>
00296 <span class="comment"> * We have reached the end of the</span>
00297 <span class="comment"> * visible line, but not the end of</span>
00298 <span class="comment"> * the screen. Therefore do nothing.</span>
00299 <span class="comment"> */</span>
00300 delay;
00301 }
00302 } <span class="keywordflow">else</span> {
00303 <span class="comment">/*</span>
00304 <span class="comment"> * Increase the memory counter for each pixel</span>
00305 <span class="comment"> * drawn thus keeping the memory location in</span>
00306 <span class="comment"> * sync with the current pixel position.</span>
00307 <span class="comment"> */</span>
00308 address++;
00309 }
00310 }
00311 }
00312 } <span class="comment">/* --- display_main() --- */</span>
00313
00314
00315
<a name="l00328"></a><a class="code" href="display_8hcc.html#a3">00328</a> <span class="keywordtype">void</span> <a class="code" href="display_8hcc.html#a3">reload_equalizer</a>(<a class="code" href="structevents__t.html">events_t</a> *events, <span class="keywordtype">unsigned</span> 4 *equalizer_levels) {
00329 <span class="keywordtype">unsigned</span> 7 equalizer_band;
00330
00331 events-><a class="code" href="structevents__t.html#o6">locked_display</a> = TRUE;
00332 delay;
00333 <span class="keywordflow">do</span> {
00334 events-><a class="code" href="structevents__t.html#o0">equalizer_display</a>[equalizer_band] = <a class="code" href="eventhandler__shared_8hch.html#a9">equalizer_table_inv</a>[equalizer_levels[equalizer_band]];
00335 equalizer_band++;
00336 } <span class="keywordflow">while</span> (equalizer_band);
00337 events-><a class="code" href="structevents__t.html#o6">locked_display</a> = FALSE;
00338 } <span class="comment">/* --- reload_equalizer() --- */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Dec 9 14:37:06 2004 for Graphic Equalizer 2 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>
|