From 9877678730e53e9ee99241a8ab5babe35eacf28d Mon Sep 17 00:00:00 2001 From: Oliver Schinagl Date: Thu, 11 Nov 2004 10:27:31 +0000 Subject: --- Graphic_Equalizer/include/configuration.hch | 2 +- Graphic_Equalizer/include/display.hch | 2 +- Graphic_Equalizer/include/eventhandler.hch | 2 +- Graphic_Equalizer/include/mouse.hch | 2 +- Graphic_Equalizer/include/mouse_shared.hch | 1 + Graphic_Equalizer/src/display.hcc | 92 ++++++++++++++++++----------- Graphic_Equalizer/src/eventhandler.hcc | 27 +++++---- Graphic_Equalizer/src/main.hcc | 12 ++-- Graphic_Equalizer/src/mouse.hcc | 18 ++---- Graphic_Equalizer/src/smartmedia.hcc | 19 +++--- Support_Libs/debug/debug.hcc | 57 +++++++++++++----- Support_Libs/debug/debug.hch | 6 +- 12 files changed, 143 insertions(+), 97 deletions(-) diff --git a/Graphic_Equalizer/include/configuration.hch b/Graphic_Equalizer/include/configuration.hch index c02a7e2..7db28bc 100644 --- a/Graphic_Equalizer/include/configuration.hch +++ b/Graphic_Equalizer/include/configuration.hch @@ -32,7 +32,7 @@ * routines. To only load the mask and not the entire data set USE_MASK_ONLY to * 1. 0 will load all bitmaps. */ -#define HAVE_SMARTMEDIA 0 +#define HAVE_SMARTMEDIA 1 #define USE_MASK_ONLY 1 diff --git a/Graphic_Equalizer/include/display.hch b/Graphic_Equalizer/include/display.hch index f8a4d0a..4568b98 100644 --- a/Graphic_Equalizer/include/display.hch +++ b/Graphic_Equalizer/include/display.hch @@ -35,7 +35,7 @@ * informs events what the current mask is. To optain the current mask we need * the X and Y coordinates from our mousedata pointer. */ -macro proc display_main(events, mousedata, ClockRate, RAM_BANK0); +macro proc display_main(events, mousedata, CLOCKRATE, VIDEOOUT, RAM_BANK0); #else #error "ERROR file display.hch multiple times included" diff --git a/Graphic_Equalizer/include/eventhandler.hch b/Graphic_Equalizer/include/eventhandler.hch index a1dab26..b8f5ca9 100644 --- a/Graphic_Equalizer/include/eventhandler.hch +++ b/Graphic_Equalizer/include/eventhandler.hch @@ -27,7 +27,7 @@ * to store actions to be performed and a mousedata pointer so that we know on * what mousestate to respond. We never returns! */ -void eventhandler_main(events_t *events, mousedata_t *mousedata); +macro proc eventhandler_main(events, mousedata); #else #error "ERROR file eventhandler.hch multiple times included" diff --git a/Graphic_Equalizer/include/mouse.hch b/Graphic_Equalizer/include/mouse.hch index f6ae164..b602d05 100644 --- a/Graphic_Equalizer/include/mouse.hch +++ b/Graphic_Equalizer/include/mouse.hch @@ -33,7 +33,7 @@ * updates the shared memory and notifies listeners. It requires a pointer to * a mousedata_t struct to store mouse information. */ -void mouse_main(mousedata_t *mousedata); +macro proc mouse_main(mousedata); #else #error "ERROR file mousedriver.hch multiple times included" diff --git a/Graphic_Equalizer/include/mouse_shared.hch b/Graphic_Equalizer/include/mouse_shared.hch index 43887c4..05eac67 100644 --- a/Graphic_Equalizer/include/mouse_shared.hch +++ b/Graphic_Equalizer/include/mouse_shared.hch @@ -28,6 +28,7 @@ typedef struct { unsigned 10 x; unsigned 9 y; unsigned 3 state; + unsigned 1 status; } mousedata_t; diff --git a/Graphic_Equalizer/src/display.hcc b/Graphic_Equalizer/src/display.hcc index 12f440c..3260990 100644 --- a/Graphic_Equalizer/src/display.hcc +++ b/Graphic_Equalizer/src/display.hcc @@ -34,7 +34,17 @@ -/*! \fn void display_main(events_t *events, mousedata_t *mousedata, ClockRate, RAM_BANK0); +/* + * Channel to notify others when new mousedata is available. If so + * Then mousedata struct is updated with shared data. + */ +chan unsigned 1 maskupdate_notification; + + + +/*! \fn void display_main(events_t *events, + * mousedata_t *mousedata, ClockRate, RAM_BANK0); + * * \brief This routine handles all drawing of pixels. It never returns! * * \param events_t *events struct with all events. @@ -44,13 +54,12 @@ * \return Never Returns. * \retval void */ -macro proc display_main(events, mousedata, CLOCKRATE, RAM_BANK0) { +macro proc display_main(events, mousedata, CLOCKRATE, VIDEOOUT, RAM_BANK0) { /* * Setup macro's RAM/Video handles and to coordinate pixel writing. */ macro expr DW = PalPL2RAMGetMaxDataWidthCT(); macro expr AW = PalPL2RAMGetMaxAddressWidthCT(); - macro expr VIDEOOUT = PalVideoOutOptimalCT(CLOCKRATE); macro expr VISIBLEX = PalVideoOutGetVisibleX(VIDEOOUT, CLOCKRATE); macro expr TOTALX = PalVideoOutGetTotalX(VIDEOOUT, CLOCKRATE); macro expr TOTALY = PalVideoOutGetTotalY(VIDEOOUT); @@ -66,7 +75,7 @@ macro proc display_main(events, mousedata, CLOCKRATE, RAM_BANK0) { * area's on the screen. Otherwise we only use the last 24 bits, the RGB values * to draw on the screen. */ -#if USE_MASK_ONLY && HAVE_SMARTMEDIA +#if (USE_MASK_ONLY && HAVE_SMARTMEDIA) #define PIXEL (0 @ pixeldata[31:24]) #else #define PIXEL (pixeldata <- 24) @@ -82,16 +91,20 @@ macro proc display_main(events, mousedata, CLOCKRATE, RAM_BANK0) { for (;;) { par { /* - * Before starting this loop we allready set the the address. - * Therefor we can start reading the previously set address and - * prepare the next address for the next cycle. + * Before starting this loop we allready set the the + * address. Therefor we can start reading the + * previously set address and prepare the next address + * for the next cycle. */ PalPL2RAMRead(RAM_BANK0, &pixeldata); PalPL2RAMSetReadAddress(RAM_BANK0, address); -/* + + /* + * Determin what to draw where here. + */ switch (pixeldata[31:24]) { case AREA_VOLUME_YAXIS: - if (SCANY <= 0 @ events->volume_position) { + if (SCANY >= 0 @ events.volume_position) { PalVideoOutWrite(VIDEOOUT, PIXEL_VOLUME_YAXIS); } else { PalVideoOutWrite(VIDEOOUT, PIXEL); @@ -100,52 +113,63 @@ macro proc display_main(events, mousedata, CLOCKRATE, RAM_BANK0) { default: PalVideoOutWrite(VIDEOOUT, PIXEL); break; - }*/ - // PalVideoOutWrite(VIDEOOUT, pixeldata <- 24)); - print_hex_value(pixeldata <- 32); + } /* - * - if ((SCANX == 0 @ mousedata->x) && (SCANY == 0 @ mousedata->y)) { - events->mask = pixeldata[31:24]; + * We compare our current X and Y scan positions of the + * output to the x and y data of the mouse. When those + * are equal we set the current mask to the mask stored + * in memory at that location. We then know what mask + * is to be used for events. + */ + if (MOUSE_UPDATED == mousedata.status) { + if ((SCANX == 0 @ mousedata.x) && (SCANY == 0 @ mousedata.y)) { + par { + events.mask = pixeldata[31:24]; + maskupdate_notification ! MOUSE_UPDATED; + mousedata.status = MOUSE_NOT_UPDATED; + } + } else { + delay; + } } else { delay; } /* - * The current position of the screen can lay in an area called - * the blanking area. We don't have data for this area as it is - * not drawn. We therefor have to determin wether we are beyond - * the visible area of the screen, but before the end of the - * total width of the screen. - * Our pipeline consists of 4 total stages. Therefor we have to - * substract 4 pixels. + * The current position of the screen can lay in an + * area called the blanking area. We don't have data + * for this area as it is not drawn. We therefor have + * to determin wether we are beyond the visible area of + * the screen, but before the end of the total width of + * the screen. Our pipeline consists of 4 total stages. + * Therefor we have to substract 4 pixels. */ if ((SCANX > (VISIBLEX - 4)) && (SCANX <= (TOTALX - 4))) { /* - * We are in the blanking area of the screen. If we are - * on the last line, and thus last pixel we reset our - * address counter. + * We are in the blanking area of the screen. + * If we are on the last line, and thus last + * pixel we reset our address counter. */ if (SCANY == (TOTALY -1)) { /* - * The reset address is determined by the help - * bit. + * The reset address is determined by + * the help bit. */ - address = 0;//(events->help) ? ADDRESS_HELP_START : ADDRESS_SKIN_START; + address = (events.help) ? ADDRESS_HELP_START : ADDRESS_SKIN_START; } else { /* - * We should not ever get inhere. To keep - * everything consequent however, we add a - * a delay. + * We should not ever get inhere. To + * keep everything consequent however, + * we add a delay. */ delay; } } else { /* - * Increase the memory counter for each pixel drawn - * thus keeping the memory location in sync with - * the current pixel position. + * Increase the memory counter for each pixel + * drawn thus keeping the memory location in + * sync with the current pixel position. */ address++; } diff --git a/Graphic_Equalizer/src/eventhandler.hcc b/Graphic_Equalizer/src/eventhandler.hcc index b9b6b1f..b614d28 100644 --- a/Graphic_Equalizer/src/eventhandler.hcc +++ b/Graphic_Equalizer/src/eventhandler.hcc @@ -24,12 +24,17 @@ #include "pal_master.hch" /******** Application Includes ********/ +#include "configuration.hch" #include "mouse_shared.hch" #include "display_shared.hch" #include "eventhandler_shared.hch" #include "eventhandler.hch" +#if HAVE_DEBUG + #include "debug.hch" +#endif +extern chan unsigned 1 maskupdate_notification; /*! \fn void eventhandler_main(events_t *events, mousedata_t *mousedata); * \brief @@ -40,26 +45,24 @@ * \return Never Returns. * \retval void */ -void eventhandler_main(events_t *events, mousedata_t *mousedata) { - extern chan unsigned 1 mousedata_notification; - +macro proc eventhandler_main(events, mousedata) { unsigned 5 volume_left; - unsigned 1 newmousedata; + unsigned 1 newmaskupdate; for (;;) { - mousedata_notification ? newmousedata; + maskupdate_notification ? newmaskupdate; /* * First we determine what mousestate we currently have. Then * we check where we are to decide what to do. */ - switch (mousedata->state) { + switch (mousedata.state) { case MOUSE_STATE_ON_PRESS: /* * If the current mask equals the help button * we flip the help bit. */ - if (BUTTON_HELP == events->mask) { - events->help = !events->help; + if (BUTTON_HELP == events.mask) { + events.help = !events.help; } else { delay; } @@ -69,18 +72,18 @@ void eventhandler_main(events_t *events, mousedata_t *mousedata) { * If we are in the volume area we update the * volume level for both channels. */ - if (AREA_VOLUME_YAXIS) { + if (AREA_VOLUME_YAXIS == events.mask) { /* * Copy the current Y cursor position * to the events struct. This we then * later use for drawing purposes. */ - events->volume_position = 0 @ mousedata->y; + events.volume_position = 0 @ mousedata.y; /* * Look the relative y-coordinate up in * the volumecontrol lookup table. */ - volume_left = volumecontrol_table[((mousedata->y) -65) <- 6]; + volume_left = volumecontrol_table[((mousedata.y) -65) <- 6]; /* * We feel that volume gets softer the * closer it gets to the 0, and louder @@ -92,7 +95,7 @@ void eventhandler_main(events_t *events, mousedata_t *mousedata) { } else { delay; } - if ((AREA_EQUALIZER_MIN <= events->mask) && (events->mask <= AREA_EQUALIZER_MAX)) { + if ((AREA_EQUALIZER_MIN <= events.mask) && (events.mask <= AREA_EQUALIZER_MAX)) { delay; } else { delay; diff --git a/Graphic_Equalizer/src/main.hcc b/Graphic_Equalizer/src/main.hcc index d7a8600..9c18ca5 100644 --- a/Graphic_Equalizer/src/main.hcc +++ b/Graphic_Equalizer/src/main.hcc @@ -23,7 +23,6 @@ /******** System Includes *************/ #include "pal_master.hch" -#include "pal_mouse.hch" /******** Application Includes ********/ #include "configuration.hch" @@ -94,9 +93,10 @@ void main(void) { MouseRun(ClockRate); PalAudioInRun(AudioIn, ClockRate); PalAudioOutRun(AudioOut, ClockRate); + PalPL2RAMRun(RAM_BANK0, ClockRate); #if HAVE_SMARTMEDIA /* - * The smartmedia device needs the CPLD to run. + * The smartmedia device needs the CPLD to run also. */ CPLDRun(ClockRate); SmartMediaRun(ClockRate); @@ -116,7 +116,7 @@ void main(void) { * into the ram. */ #if HAVE_DEBUG - print_eol(); + print_cls(); print_string("Graphic Equalizer 2"); print_eol(); #endif @@ -152,9 +152,9 @@ void main(void) { * and display in parallel. None of these * should ever return. */ - mouse_main(&mousedata); - display_main(events, mousedata, ClockRate, RAM_BANK0); - eventhandler_main(&events, &mousedata); + mouse_main(mousedata); + display_main(events, mousedata, ClockRate, VideoOut, RAM_BANK0); + eventhandler_main(events, mousedata); audio_main(); } #if HAVE_SMARTMEDIA diff --git a/Graphic_Equalizer/src/mouse.hcc b/Graphic_Equalizer/src/mouse.hcc index 7764ed6..8db9c51 100644 --- a/Graphic_Equalizer/src/mouse.hcc +++ b/Graphic_Equalizer/src/mouse.hcc @@ -30,14 +30,6 @@ -/* - * Channel to notify others when new mousedata is available. If so - * Then mousedata struct is updated with shared data. - */ -chan unsigned 1 mousedata_notification; - - - /*! \fn void mouse_main(mousedata_t *mousedata); * \brief Main mousedriver. This function never returns! It calls the * main mousehandler and returns the States and coordinates @@ -48,7 +40,7 @@ chan unsigned 1 mousedata_notification; * \return Never Returns. * \retval void */ -void mouse_main(mousedata_t *mousedata) +macro proc mouse_main(mousedata) { unsigned 14 touch_sampler; unsigned 10 x, oldx; @@ -97,10 +89,10 @@ void mouse_main(mousedata_t *mousedata) * Set the new as previous values for the next run. */ if ((oldmousestate != mousestate) || (oldx != x) || (oldy != y)) { - mousedata->x = x; - mousedata->y = y; - mousedata->state = mousestate; - mousedata_notification ! MOUSE_UPDATED; + mousedata.x = x; + mousedata.y = y; + mousedata.state = mousestate; + mousedata.status = MOUSE_UPDATED; oldx = x; oldy = y; oldmousestate = mousestate; diff --git a/Graphic_Equalizer/src/smartmedia.hcc b/Graphic_Equalizer/src/smartmedia.hcc index 78682ba..5c547cc 100644 --- a/Graphic_Equalizer/src/smartmedia.hcc +++ b/Graphic_Equalizer/src/smartmedia.hcc @@ -77,6 +77,7 @@ macro proc smartmedia_loaddata(RAM_BANK0) { macro expr DW = PalPL2RAMGetMaxDataWidthCT(); macro expr AW = PalPL2RAMGetMaxAddressWidthCT(); + unsigned DW data; unsigned 27 smartmedia_address, smartmedia_address_mask; unsigned AW address; unsigned 8 mask, r, g, b; @@ -141,26 +142,25 @@ macro proc smartmedia_loaddata(RAM_BANK0) { RC200SmartMediaSetAddress(READ, smartmedia_address_mask); RC200SmartMediaRead(&mask, TRUE); RC200SmartMediaOperationEnd(&result); + + data = 0 @ mask @ r @ g @ b; #else - mask = 0x01; - r = 0xff; - g = 0x0f; - b = 0x00; + data = 0xff000f00; #endif /* * Now that we have gathered all pixel data, store it in ram. */ - PalPL2RAMWrite(RAM_BANK0, (unsigned DW)(0 @ mask @ r @ g @ b)); + PalPL2RAMWrite(RAM_BANK0, data); #if HAVE_DEBUG /* * Print some nice stats about data loading. */ - if (!address[12:0]) { + if (!address[11:0]) { print_cr(); - print_hex_value(0 @ address[19:13]); - print_string(" / 00000064 | data: "); - print_hex_value(0 @ mask @ r @ g @ b); + print_hex_value(0 @ (address \\ 12)); + print_string(" / 00000096 | data: "); + print_hex_value(data <- 32); } #endif @@ -169,6 +169,5 @@ macro proc smartmedia_loaddata(RAM_BANK0) { */ smartmedia_address += 3; smartmedia_address_mask++; - } } /* --- smartmedia_loaddata() --- */ diff --git a/Support_Libs/debug/debug.hcc b/Support_Libs/debug/debug.hcc index 303adde..618ca46 100644 --- a/Support_Libs/debug/debug.hcc +++ b/Support_Libs/debug/debug.hcc @@ -4,35 +4,60 @@ #include "debug.hch" -void print_hex_value(unsigned value) +void print_hex_value(unsigned 32 value) { unsigned 8 ch; unsigned 4 i; - unsigned 32 tempvalue; - - tempvalue = 0 @ value; for(i = 0;i < 8;i++) { - ch = 0 @ (tempvalue\\28); - tempvalue <<= 4; + ch = 0 @ (value\\28); + value <<= 4; ch += (ch > 9) ? 0x37 : 0x30; PalDataPortWrite(PalRS232PortCT(0), ch); } } void print_string(unsigned char *s) { - unsigned 4 i; - i = 0; - for(i = 0;'\0' != s[i];i++) - { - PalDataPortWrite(PalRS232PortCT(0), s[i]); + unsigned 10 index; + + /* + * We print all elements from the provided array until we encounter the + * '\0' character. Since standard C and Handel-C both end a string + * with the '\0' character. Since Handel-C init's var's to 0 this + * normally will never go wrong. + */ + for(index = 0; '\0' != s[index]; index++) { + PalDataPortWrite(PalRS232PortCT(0), s[index]); } - } -void print_eol(void) -{ - PalDataPortWrite(PalRS232PortCT(0), 0x0A); - PalDataPortWrite(PalRS232PortCT(0), 0x0D); + + +void print_eol(void) { + /* + * To write a clean 'return' we have to both write the newline and + * carriage return symbol. + */ + PalDataPortWrite(PalRS232PortCT(0), 0x0a); + PalDataPortWrite(PalRS232PortCT(0), 0x0d); +} + + + +void print_cr(void) { + /* + * Write the character that forces the cursor to go back to the + * beginning of the line. + */ + PalDataPortWrite(PalRS232PortCT(0), 0x0d); +} + + + +void print_cls(void) { + /* + * Write the clearscreen character to the RS232 port. + */ + PalDataPortWrite(PalRS232PortCT(0), 0x0c); } \ No newline at end of file diff --git a/Support_Libs/debug/debug.hch b/Support_Libs/debug/debug.hch index c2656f2..8777b4b 100644 --- a/Support_Libs/debug/debug.hch +++ b/Support_Libs/debug/debug.hch @@ -12,7 +12,7 @@ * Post: A hex representation of value is printed. * ****************************************************************************/ -void print_hex_value(unsigned value); +void print_hex_value(unsigned 32 value); /**************************************************************************** * @@ -30,4 +30,6 @@ void print_hex_value(unsigned value); void print_string(unsigned char *s); -void print_eol(void); \ No newline at end of file +void print_eol(void); +void print_cr(void); +void print_cls(void); \ No newline at end of file -- cgit v0.12