Main Page | Data Structures | Directories | File List | Data Fields | Globals

smartmedia.hcc

Go to the documentation of this file.
00001 
00019 /******** System Includes *************/
00020 #include <stdlib.hch>
00021 
00022 #include "pal_master.hch"
00023 
00024 /******** Application Includes ********/
00025 #include "configuration.hch"
00026 #include "display_shared.hch"
00027 #include "smartmedia_shared.hch"
00028 #include "smartmedia.hch"
00029 
00030 #if HAVE_DEBUG
00031         #include "debug.hch"
00032 #endif
00033 
00034 #include "audio.hch"
00035 #include "mouse_shared.hch"
00036 #include "eventhandler_shared.hch"
00037 #include "display.hch" /* FIXME: temporary include, needs to be moved to 'init' */
00038 
00046 unsigned 1 smartmedia_init(void) {
00047         unsigned 1 retval;
00048         /*
00049          * Firstly we enable both the CPLD and the SmartMedia.
00050          */
00051         RC200CPLDEnable();
00052         RC200SmartMediaInit(&retval);
00053 
00054         if (retval) {
00055                 RC200SmartMediaReset(&retval);
00056                 RC200SmartMediaInit(&retval);
00057         }
00058         
00059         return retval;  
00060 } /* --- smartmedia_init() --- */
00061 
00062 
00063 
00072 void smartmedia_loaddata(skindata_t *skindata) {
00073         /*
00074          * Setup RAM Handle, and determin maximum Data and Address widths
00075          */
00076         macro expr RAM_BANK0 = PalPL2RAMCT(0);
00077         macro expr DW = PalPL2RAMGetMaxDataWidthCT();
00078         macro expr AW = PalPL2RAMGetMaxAddressWidthCT();
00079 
00080         unsigned DW data;
00081         unsigned 27 smartmedia_address, smartmedia_address_mask;
00082         unsigned AW address;
00083         unsigned 8 mask, r, g, b;
00084         unsigned 3 stage;
00085         unsigned 1 result;
00086 
00087         extern ram unsigned 8 presets_default_values[768];
00088 
00089 #if HAVE_DEBUG
00090         /*
00091          * Print some nice stats about data loading.
00092          */
00093         print_eol();
00094         print_hex_value(0);
00095 #endif
00096         /*
00097          * Before we enter our loop to fill our memory with valid data, we have
00098          * to set the startup positions for the SmartMedia.
00099          */
00100         smartmedia_address = SMARTMEDIA_ADDRESS_SKIN_START;
00101         smartmedia_address_mask = SMARTMEDIA_ADDRESS_SKINMASK_START;
00102         stage = STAGE_LOAD_SKIN;
00103         /*
00104          * We start with the address of the skin, and do the loop until we have
00105          * done the end of the help.
00106          */
00107         for (address = ADDRESS_SKIN_START; address != (ADDRESS_PRESET_RESET_END +1); address++) {
00108                 /*
00109                  * Once we are done with the loading of our skin, we need to
00110                  * change the smartmedia start addresses.
00111                  */
00112                 switch (address) {
00113                         case ADDRESS_HELP_START:
00114                                 smartmedia_address = SMARTMEDIA_ADDRESS_HELP_START;
00115                                 smartmedia_address_mask = SMARTMEDIA_ADDRESS_HELPMASK_START;
00116                                 stage = STAGE_LOAD_HELP;
00117                                 break;
00118                         case ADDRESS_GRAPHMASK_START:
00119                                 smartmedia_address_mask = SMARTMEDIA_ADDRESS_GRAPHMASK_START;
00120                                 stage = STAGE_LOAD_GRAPH;
00121                                 break;
00122                         case ADDRESS_PRESET_DEMO_START:
00123                                 smartmedia_address_mask = SMARTMEDIA_ADDRESS_PRESET_DEMO_START;
00124                                 stage = STAGE_LOAD_PRESET;
00125                                 break;
00126                         case ADDRESS_PRESET_RESET_START:
00127                                 smartmedia_address_mask = SMARTMEDIA_ADDRESS_PRESET_RESET_START;
00128                                 stage = STAGE_LOAD_PRESET;
00129                                 break;
00130                         default:
00131                                 break;
00132                 }
00133 
00134                 /*
00135                  * Before reading our data from the smartmedia we set our
00136                  * address pointer to the address from our loop.
00137                  */
00138 #if HAVE_SMARTMEDIA
00139                 PalPL2RAMSetWriteAddress(RAM_BANK0, address);
00140 #else
00141                 PalPL2RAMSetWriteAddress(RAM_BANK0, 0);
00142 #endif
00143 
00144                 /*
00145                  * SmartMedia data is read one byte per call. Because we want
00146                  * to store the mask + the rgb values in one variable for later
00147                  * useage we need to read those 4 bytes from the smartmedia
00148                  * before storing it as one.
00149                  */
00150 #if HAVE_SMARTMEDIA
00151                 /*
00152                  * FIXME: Due to a bug in the DK2 smartmedia libraries we need
00153                  * stop reading after each byte with OperationEnd call. This is
00154                  * VERY slow and must be changed.
00155                  */
00156                 if ((STAGE_LOAD_SKIN == stage) || (STAGE_LOAD_HELP == stage)) {
00157                         RC200SmartMediaSetAddress(READ, smartmedia_address);
00158                         RC200SmartMediaRead(&r, TRUE);
00159                         RC200SmartMediaOperationEnd(&result);
00160                         RC200SmartMediaSetAddress(READ, (smartmedia_address +1));
00161                         RC200SmartMediaRead(&g, TRUE);
00162                         RC200SmartMediaOperationEnd(&result);
00163                         RC200SmartMediaSetAddress(READ, (smartmedia_address +2));
00164                         RC200SmartMediaRead(&b, TRUE);
00165                         RC200SmartMediaOperationEnd(&result);
00166                 }
00167                 RC200SmartMediaSetAddress(READ, smartmedia_address_mask);
00168                 RC200SmartMediaRead(&mask, TRUE);
00169                 RC200SmartMediaOperationEnd(&result);
00170 
00171                 switch (stage) {
00172                         case STAGE_LOAD_SKIN:
00173                                 data = 0 @ mask @ r @ g @ b;
00174                                 break;
00175                         case STAGE_LOAD_HELP:
00176                                 data = 0 @ mask @ r @ g @ b;
00177                                 break;
00178                         case STAGE_LOAD_GRAPH:
00179                                 data = (unsigned DW)(0 @ mask) << 24;
00180                                 break;
00181                         case STAGE_LOAD_PRESET:
00182                                 presets_default_values[(address -ADDRESS_PRESET_DEMO_START) <- 10] = mask;
00183                 }
00184                 
00185 #else
00186                 data = 0x0000ff00;
00187 #endif
00188                 /*
00189                  * Now that we have gathered all pixel data, store it in ram.
00190                  */
00191                 PalPL2RAMWrite(RAM_BANK0, data);
00192 
00193 #if HAVE_DEBUG
00194                 /*
00195                  * Print some nice stats about data loading.
00196                  */
00197                 if (!(address <- 10)) {
00198                         print_cr();
00199                         print_hex_value(0 @ (address \\ 11));
00200                         print_string(" / 000001C2 | data: ");
00201                         print_hex_value(data <- 32);
00202                 }
00203 #endif
00204 
00205                 /*
00206                  * Finally increase al our indexes approperiatly.
00207                  */
00208                 smartmedia_address += 3;
00209                 smartmedia_address_mask++;
00210         }
00211 
00212         /*
00213          * This block needs to probably move up into the fore loop where we
00214          * calculate these settings later.
00215          */
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 //      skindata->color_area_spectrum_top = PIXEL_SPECTRUM;
00231 //      skindata->color_area_spectrum_bottom = PIXEL_SPECTRUM;
00232         skindata->color_equalizer = PIXEL_EQUALIZER;
00233 } /* --- smartmedia_loaddata() --- */

Generated on Thu Dec 9 14:37:07 2004 for Graphic Equalizer 2 by  doxygen 1.3.9.1