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
|
<!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/smartmedia.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>smartmedia.hcc</h1><a href="smartmedia_8hcc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001
00019 <span class="comment">/******** System Includes *************/</span>
00020 <span class="preprocessor">#include <stdlib.hch></span>
00021
00022 <span class="preprocessor">#include "pal_master.hch"</span>
00023
00024 <span class="comment">/******** Application Includes ********/</span>
00025 <span class="preprocessor">#include "<a class="code" href="configuration_8hch.html">configuration.hch</a>"</span>
00026 <span class="preprocessor">#include "<a class="code" href="display__shared_8hch.html">display_shared.hch</a>"</span>
00027 <span class="preprocessor">#include "<a class="code" href="smartmedia_8hch.html">smartmedia.hch</a>"</span>
00028
00029 <span class="preprocessor">#if HAVE_DEBUG</span>
00030 <span class="preprocessor"></span><span class="preprocessor"> #include "debug.hch"</span>
00031 <span class="preprocessor">#endif</span>
00032 <span class="preprocessor"></span>
00033 <span class="preprocessor">#include "<a class="code" href="audio_8hch.html">audio.hch</a>"</span>
00034 <span class="preprocessor">#include "<a class="code" href="mouse__shared_8hch.html">mouse_shared.hch</a>"</span>
00035 <span class="preprocessor">#include "<a class="code" href="eventhandler__shared_8hch.html">eventhandler_shared.hch</a>"</span>
00036 <span class="preprocessor">#include "<a class="code" href="display_8hch.html">display.hch</a>"</span> <span class="comment">/* FIXME: temporary include, needs to be moved to 'init' */</span>
00037
<a name="l00045"></a><a class="code" href="smartmedia_8hcc.html#a0">00045</a> <span class="keywordtype">unsigned</span> 1 <a class="code" href="smartmedia_8hch.html#a9">smartmedia_init</a>(<span class="keywordtype">void</span>) {
00046 <span class="keywordtype">unsigned</span> 1 retval;
00047 <span class="comment">/*</span>
00048 <span class="comment"> * Firstly we enable both the CPLD and the SmartMedia.</span>
00049 <span class="comment"> */</span>
00050 RC200CPLDEnable();
00051 RC200SmartMediaInit(&retval);
00052
00053 <span class="keywordflow">if</span> (retval) {
00054 RC200SmartMediaReset(&retval);
00055 RC200SmartMediaInit(&retval);
00056 }
00057
00058 <span class="keywordflow">return</span> retval;
00059 } <span class="comment">/* --- smartmedia_init() --- */</span>
00060
00061
00062
<a name="l00071"></a><a class="code" href="smartmedia_8hcc.html#a1">00071</a> <span class="keywordtype">void</span> <a class="code" href="smartmedia_8hcc.html#a1">smartmedia_loaddata</a>(skindata_t *skindata) {
00072 <span class="comment">/*</span>
00073 <span class="comment"> * Setup RAM Handle, and determin maximum Data and Address widths</span>
00074 <span class="comment"> */</span>
00075 macro expr RAM_BANK0 = PalPL2RAMCT(0);
00076 macro expr DW = PalPL2RAMGetMaxDataWidthCT();
00077 macro expr AW = PalPL2RAMGetMaxAddressWidthCT();
00078
00079 <span class="keywordtype">unsigned</span> DW data;
00080 <span class="keywordtype">unsigned</span> 27 smartmedia_address, smartmedia_address_mask;
00081 <span class="keywordtype">unsigned</span> AW address;
00082 <span class="keywordtype">unsigned</span> 8 mask, r, g, b;
00083 <span class="keywordtype">unsigned</span> 3 stage;
00084 <span class="keywordtype">unsigned</span> 1 result;
00085
00086 <span class="preprocessor">#if HAVE_DEBUG</span>
00087 <span class="preprocessor"></span> <span class="comment">/*</span>
00088 <span class="comment"> * Print some nice stats about data loading.</span>
00089 <span class="comment"> */</span>
00090 print_eol();
00091 print_hex_value(0);
00092 <span class="preprocessor">#endif</span>
00093 <span class="preprocessor"></span> <span class="comment">/*</span>
00094 <span class="comment"> * Before we enter our loop to fill our memory with valid data, we have</span>
00095 <span class="comment"> * to set the startup positions for the SmartMedia.</span>
00096 <span class="comment"> */</span>
00097 smartmedia_address = SMARTMEDIA_ADDRESS_SKIN_START;
00098 smartmedia_address_mask = SMARTMEDIA_ADDRESS_SKINMASK_START;
00099 stage = STAGE_LOAD_SKIN;
00100 <span class="comment">/*</span>
00101 <span class="comment"> * We start with the address of the skin, and do the loop until we have</span>
00102 <span class="comment"> * done the end of the help.</span>
00103 <span class="comment"> */</span>
00104 <span class="keywordflow">for</span> (address = ADDRESS_SKIN_START; address != (ADDRESS_PRESET_RESET_END +1); address++) {
00105 <span class="comment">/*</span>
00106 <span class="comment"> * Once we are done with the loading of our skin, we need to</span>
00107 <span class="comment"> * change the smartmedia start addresses.</span>
00108 <span class="comment"> */</span>
00109 <span class="keywordflow">if</span> (ADDRESS_HELP_START == address) {
00110 smartmedia_address = SMARTMEDIA_ADDRESS_HELP_START;
00111 smartmedia_address_mask = SMARTMEDIA_ADDRESS_HELPMASK_START;
00112 stage = STAGE_LOAD_HELP;
00113 }
00114 <span class="keywordflow">if</span> (ADDRESS_GRAPHMASK_START == address) {
00115 smartmedia_address_mask = SMARTMEDIA_ADDRESS_GRAPHMASK_START;
00116 stage = STAGE_LOAD_GRAPH;
00117 }
00118 <span class="keywordflow">if</span> (ADDRESS_PRESET_DEMO_START == address) {
00119 smartmedia_address_mask = SMARTMEDIA_ADDRESS_PRESET_DEMO_START;
00120 stage = STAGE_LOAD_PRESET;
00121 }
00122
00123 <span class="comment">/*</span>
00124 <span class="comment"> * Before reading our data from the smartmedia we set our</span>
00125 <span class="comment"> * address pointer to the address from our loop.</span>
00126 <span class="comment"> */</span>
00127 <span class="preprocessor">#if SKIP_LOAD</span>
00128 <span class="preprocessor"></span> <span class="keywordflow">if</span> (STAGE_LOAD_PRESET == stage) {
00129 PalPL2RAMSetWriteAddress(RAM_BANK0, address);
00130 } <span class="keywordflow">else</span> {
00131 PalPL2RAMSetWriteAddress(RAM_BANK0, 0);
00132 }
00133 <span class="preprocessor">#else</span>
00134 <span class="preprocessor"></span> PalPL2RAMSetWriteAddress(RAM_BANK0, address);
00135 <span class="preprocessor">#endif</span>
00136 <span class="preprocessor"></span>
00137 <span class="comment">/*</span>
00138 <span class="comment"> * SmartMedia data is read one byte per call. Because we want</span>
00139 <span class="comment"> * to store the mask + the rgb values in one variable for later</span>
00140 <span class="comment"> * useage we need to read those 4 bytes from the smartmedia</span>
00141 <span class="comment"> * before storing it as one.</span>
00142 <span class="comment"> */</span>
00143 <span class="preprocessor">#if HAVE_SMARTMEDIA</span>
00144 <span class="preprocessor"></span> <span class="comment">/*</span>
00145 <span class="comment"> * FIXME: Due to a bug in the DK2 smartmedia libraries we need</span>
00146 <span class="comment"> * stop reading after each byte with OperationEnd call. This is</span>
00147 <span class="comment"> * VERY slow and must be changed.</span>
00148 <span class="comment"> */</span>
00149 <span class="preprocessor"> #if !USE_MASK_ONLY</span>
00150 <span class="preprocessor"></span> <span class="keywordflow">if</span> ((STAGE_LOAD_SKIN == stage) || (STAGE_LOAD_HELP == stage)) {
00151 RC200SmartMediaSetAddress(READ, smartmedia_address);
00152 RC200SmartMediaRead(&r, TRUE);
00153 RC200SmartMediaOperationEnd(&result);
00154 RC200SmartMediaSetAddress(READ, (smartmedia_address +1));
00155 RC200SmartMediaRead(&g, TRUE);
00156 RC200SmartMediaOperationEnd(&result);
00157 RC200SmartMediaSetAddress(READ, (smartmedia_address +2));
00158 RC200SmartMediaRead(&b, TRUE);
00159 RC200SmartMediaOperationEnd(&result);
00160 }
00161 <span class="preprocessor"> #endif</span>
00162 <span class="preprocessor"></span> RC200SmartMediaSetAddress(READ, smartmedia_address_mask);
00163 RC200SmartMediaRead(&mask, TRUE);
00164 RC200SmartMediaOperationEnd(&result);
00165
00166 <span class="keywordflow">switch</span> (stage) {
00167 <span class="keywordflow">case</span> STAGE_LOAD_SKIN:
00168 data = 0 @ mask @ r @ g @ b;
00169 <span class="keywordflow">break</span>;
00170 <span class="keywordflow">case</span> STAGE_LOAD_HELP:
00171 data = 0 @ mask @ r @ g @ b;
00172 <span class="keywordflow">break</span>;
00173 <span class="keywordflow">case</span> STAGE_LOAD_GRAPH:
00174 data = (<span class="keywordtype">unsigned</span> DW)(0 @ mask) << 24;
00175 <span class="keywordflow">break</span>;
00176 <span class="keywordflow">case</span> STAGE_LOAD_PRESET:
00177 data = 0 @ mask;
00178 <span class="keywordflow">break</span>;
00179 }
00180
00181 <span class="preprocessor">#else</span>
00182 <span class="preprocessor"></span> <span class="keywordflow">if</span> (STAGE_LOAD_PRESET == stage) {
00183 data = (address <- 1) ? 0x000000ff : 0x00000000;
00184 } <span class="keywordflow">else</span> {
00185 data = 0x0000ff00;
00186 }
00187 <span class="preprocessor">#endif</span>
00188 <span class="preprocessor"></span> <span class="comment">/*</span>
00189 <span class="comment"> * Now that we have gathered all pixel data, store it in ram.</span>
00190 <span class="comment"> */</span>
00191 PalPL2RAMWrite(RAM_BANK0, data);
00192
00193 <span class="preprocessor">#if HAVE_DEBUG</span>
00194 <span class="preprocessor"></span> <span class="comment">/*</span>
00195 <span class="comment"> * Print some nice stats about data loading.</span>
00196 <span class="comment"> */</span>
00197 <span class="keywordflow">if</span> (!(address <- 11)) {
00198 print_cr();
00199 print_hex_value(0 @ (address \\ 12));
00200 print_string(<span class="stringliteral">" / 000000E1 | data: "</span>);
00201 print_hex_value(data <- 32);
00202 }
00203 <span class="preprocessor">#endif</span>
00204 <span class="preprocessor"></span>
00205 <span class="comment">/*</span>
00206 <span class="comment"> * Finally increase al our indexes approperiatly.</span>
00207 <span class="comment"> */</span>
00208 smartmedia_address += 3;
00209 smartmedia_address_mask++;
00210 }
00211
00212 <span class="comment">/*</span>
00213 <span class="comment"> * This block needs to probably move up into the fore loop where we</span>
00214 <span class="comment"> * calculate these settings later.</span>
00215 <span class="comment"> */</span>
00216 skindata->area_spectrum_top = 200;
00217 skindata->area_spectrum_bottom = 335;
00218 skindata->area_spectrum_left = 77;
00219 skindata->area_spectrum_right = 575;
00220 skindata->area_waveform_top = 46;
00221 skindata->area_waveform_bottom = 118;
00222 skindata->area_waveform_left = 76;
00223 skindata->area_waveform_right = 413;
00224 skindata->area_volume_top = 112;
00225 skindata->area_volume_bottom = 66;
00226 skindata->area_volume_left = 439;
00227 skindata->area_volume_right = 455;
00228 skindata->color_area_volume = PIXEL_VOLUME;
00229 skindata->color_area_waveform = PIXEL_WAVEFORM;
00230 <span class="comment">// skindata->color_area_spectrum_top = PIXEL_SPECTRUM;</span>
00231 <span class="comment">// skindata->color_area_spectrum_bottom = PIXEL_SPECTRUM;</span>
00232 skindata->color_equalizer = PIXEL_EQUALIZER;
00233 } <span class="comment">/* --- smartmedia_loaddata() --- */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Nov 29 12:04:48 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>
|