summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer/src
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2004-11-11 16:13:58 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2004-11-11 16:13:58 (GMT)
commit27405f4f8c65baabb28ce427912851be10207781 (patch)
tree3a090403142563d916a8cbb5ef8a3c4113a5b6ae /Graphic_Equalizer/src
parent9877678730e53e9ee99241a8ab5babe35eacf28d (diff)
downloadTASS-27405f4f8c65baabb28ce427912851be10207781.zip
TASS-27405f4f8c65baabb28ce427912851be10207781.tar.gz
TASS-27405f4f8c65baabb28ce427912851be10207781.tar.bz2
Added fft files
fixed some issues, included equalizer.
Diffstat (limited to 'Graphic_Equalizer/src')
-rw-r--r--Graphic_Equalizer/src/audio.hcc34
-rw-r--r--Graphic_Equalizer/src/display.hcc10
-rw-r--r--Graphic_Equalizer/src/eventhandler.hcc27
-rw-r--r--Graphic_Equalizer/src/fft.hcc454
-rw-r--r--Graphic_Equalizer/src/main.hcc7
-rw-r--r--Graphic_Equalizer/src/mouse.hcc37
-rw-r--r--Graphic_Equalizer/src/smartmedia.hcc9
7 files changed, 535 insertions, 43 deletions
diff --git a/Graphic_Equalizer/src/audio.hcc b/Graphic_Equalizer/src/audio.hcc
index 2959591..b38805b 100644
--- a/Graphic_Equalizer/src/audio.hcc
+++ b/Graphic_Equalizer/src/audio.hcc
@@ -26,9 +26,8 @@
-/*! \fn void audio_init(gain_level,
- * input_source,
- * sample_rate)
+/*! \fn void audio_init(gain_level, input_source,
+ * sample_rate, AUDIOIN, AUDIOOUT)
*
* \brief Set some inital values to the audio hardware.
*
@@ -43,12 +42,7 @@
* \retval void
*
*/
-macro proc audio_init(gain_level, input_source, sample_rate) {
- /*
- * Setup audio pointers.
- */
- macro expr AudioIn = PalAudioInCT(0);
- macro expr AudioOut = PalAudioOutCT(0);
+macro proc audio_init(gain_level, input_source, sample_rate, AUDIOIN, AUDIOOUT) {
/*
* We simply call the appropiate handlers and pass values along. We
* Don't set the mute on input gain. We have volume control to do this.
@@ -57,31 +51,27 @@ macro proc audio_init(gain_level, input_source, sample_rate) {
*/
RC200AudioInSetGain(FALSE, gain_level, gain_level);
RC200AudioInSetInput(input_source);
- PalAudioInSetSampleRate(AudioIn, sample_rate);
- PalAudioOutSetSampleRate(AudioOut, sample_rate);
+ PalAudioInSetSampleRate(AUDIOIN, sample_rate);
+ PalAudioOutSetSampleRate(AUDIOOUT, sample_rate);
} /* --- audio_init() --- */
-/*! \fn void audio_main(void);
+/*! \fn void audio_main(AUDIOIN, AUDIOOUT);
+ *
* \brief Main audiodriver. This function never returns! It calls the
* audiohandlers and stores samples into a global array. Once 64
* Samples are collected it raises a signal AUDIO_READY to let
* other processes know it's ready. We use quadruple buffering for
* audio input and double buffering for audio output.
*
- * \param void
+ * \param AUDIOIN Audio Input Handler
+ * \param AUDIOOUT Audio Output Handler
*
* \return Never Returns.
* \retval void
*/
-void audio_main(void) {
- /*
- * Setup audio pointers.
- */
- macro expr AudioIn = PalAudioInCT(0);
- macro expr AudioOut = PalAudioOutCT(0);
-
+macro proc audio_main(AUDIOIN, AUDIOOUT) {
/*
* Determin the data width for the current platform.
*/
@@ -92,7 +82,7 @@ void audio_main(void) {
signed OW sample_left_out, sample_right_out;
for (;;) {
- PalAudioInRead(AudioIn, &sample_left_in, &sample_right_in);
+ PalAudioInRead(AUDIOIN, &sample_left_in, &sample_right_in);
/* par {
sample_add(sample_left_in);
@@ -104,6 +94,6 @@ void audio_main(void) {
* 64 Samples have been processed, calculate.
* /
}
-*/ PalAudioOutWrite(AudioOut, (signed OW)(sample_left_in @ 0), (signed OW)(sample_right_in @ 0));
+*/ PalAudioOutWrite(AUDIOOUT, (signed OW)(sample_left_in @ 0), (signed OW)(sample_right_in @ 0));
}
} /* --- audio_main() --- */
diff --git a/Graphic_Equalizer/src/display.hcc b/Graphic_Equalizer/src/display.hcc
index 3260990..79cf4b2 100644
--- a/Graphic_Equalizer/src/display.hcc
+++ b/Graphic_Equalizer/src/display.hcc
@@ -42,7 +42,7 @@ chan unsigned 1 maskupdate_notification;
-/*! \fn void display_main(events_t *events,
+/*! \fn void display_main(equalizer_levels_t *equalizer_levels, events_t *events,
* mousedata_t *mousedata, ClockRate, RAM_BANK0);
*
* \brief This routine handles all drawing of pixels. It never returns!
@@ -111,7 +111,11 @@ macro proc display_main(events, mousedata, CLOCKRATE, VIDEOOUT, RAM_BANK0) {
}
break;
default:
- PalVideoOutWrite(VIDEOOUT, PIXEL);
+ if ((AREA_EQUALIZER_MIN <= pixeldata[31:24]) && (pixeldata[31:24] <= AREA_EQUALIZER_MAX) && ((SCANY -382) == 0 @ events.equalizer_position[(pixeldata[31:24] -0x80) <- 7])) {
+ PalVideoOutWrite(VIDEOOUT, PIXEL_EQUALIZER);
+ } else {
+ PalVideoOutWrite(VIDEOOUT, PIXEL);
+ }
break;
}
@@ -126,8 +130,8 @@ macro proc display_main(events, mousedata, CLOCKRATE, VIDEOOUT, RAM_BANK0) {
if ((SCANX == 0 @ mousedata.x) && (SCANY == 0 @ mousedata.y)) {
par {
events.mask = pixeldata[31:24];
- maskupdate_notification ! MOUSE_UPDATED;
mousedata.status = MOUSE_NOT_UPDATED;
+ maskupdate_notification ! MOUSE_UPDATED;
}
} else {
delay;
diff --git a/Graphic_Equalizer/src/eventhandler.hcc b/Graphic_Equalizer/src/eventhandler.hcc
index b614d28..f0583aa 100644
--- a/Graphic_Equalizer/src/eventhandler.hcc
+++ b/Graphic_Equalizer/src/eventhandler.hcc
@@ -36,7 +36,7 @@
extern chan unsigned 1 maskupdate_notification;
-/*! \fn void eventhandler_main(events_t *events, mousedata_t *mousedata);
+/*! \fn void eventhandler_main(equalizer_levels_t *equalizer_levels, events_t *events, mousedata_t *mousedata);
* \brief
*
* \param events_t *events pointer to struct with all events.
@@ -45,12 +45,15 @@ extern chan unsigned 1 maskupdate_notification;
* \return Never Returns.
* \retval void
*/
-macro proc eventhandler_main(events, mousedata) {
+macro proc eventhandler_main(equalizer_levels, events, mousedata) {
unsigned 5 volume_left;
unsigned 1 newmaskupdate;
for (;;) {
maskupdate_notification ? newmaskupdate;
+ print_string("Mask: ");print_hex_value(0 @ events.mask);print_eol();
+ print_string("state: ");print_hex_value(0 @ mousedata.state);print_eol();
+
/*
* First we determine what mousestate we currently have. Then
* we check where we are to decide what to do.
@@ -96,7 +99,25 @@ macro proc eventhandler_main(events, mousedata) {
delay;
}
if ((AREA_EQUALIZER_MIN <= events.mask) && (events.mask <= AREA_EQUALIZER_MAX)) {
- delay;
+ print_string("Ypos for eq: ");print_hex_value(0 @ mousedata.y);print_eol();
+ /*
+ * Copy the current Y position into a
+ * store for the current equalizer bar.
+ */
+ events.equalizer_position[(events.mask -0x80) <- 7] = mousedata.y;
+ /*
+ * We look our current possition up in
+ * the lookup table. We determin our
+ * position via the current Y position
+ * (minus an offset of course). We
+ * store the result in the array of
+ * equalizer levels. The index we get
+ * from the current mask.
+ *
+ * TODO: lock equalizer store with a
+ * semaphore!
+ */
+ equalizer_levels.write[0 @ (events.mask -0x80) <- 7] = equalizer_table[((mousedata.y) -382) <- 7];
} else {
delay;
}
diff --git a/Graphic_Equalizer/src/fft.hcc b/Graphic_Equalizer/src/fft.hcc
new file mode 100644
index 0000000..7c3fa94
--- /dev/null
+++ b/Graphic_Equalizer/src/fft.hcc
@@ -0,0 +1,454 @@
+#include <pal_master.hch>
+#include <stdlib.hch>
+#include "weights256.hch"
+#include "config.hch"
+#include "debug.hch"
+#include "xilinxmult.hch"
+
+#define PERFORM_FFT_CALCULATION 1
+#define USE_UNSIGNED_AUDIO 0
+#define PRINT_DEBUG 0
+/* Define two multi-port RAMs for FFT calculation; one for real and one for imaginary values
+ * Extra block RAM settings are defined to make sure read and write actions can be performed
+ * within one clock-cycle.
+ * Left out extra settings on new board the clock changes TODO !!!!
+ */
+#if HARDWARE_MULTIPLY
+mpram
+{
+ ram signed 18 rwrite[256];
+ rom signed 18 read[256];
+} real with {block = "BlockRAM"/*, westart=2.5, welength=1, rclkpos={1.5}, wclkpos={3}, clkpulselen=0.5*/};
+
+mpram
+{
+ ram signed 18 rwrite[256];
+ rom signed 18 read[256];
+} imaginary with {block = "BlockRAM"/*, westart=2.5, welength=1, rclkpos={1.5}, wclkpos={3}, clkpulselen=0.5*/};
+#else
+mpram
+{
+ ram signed 24 rwrite[256];
+ rom signed 24 read[256];
+} real with {block = "BlockRAM"/*, westart=2.5, welength=1, rclkpos={1.5}, wclkpos={3}, clkpulselen=0.5*/};
+
+mpram
+{
+ ram signed 24 rwrite[256];
+ rom signed 24 read[256];
+} imaginary with {block = "BlockRAM"/*, westart=2.5, welength=1, rclkpos={1.5}, wclkpos={3}, clkpulselen=0.5*/};
+#endif
+// multiplication factors for equalizer function
+ram signed 7 eq_settings[16] = {0,2,4,7,10,13,16,19,22,26,30,35,41,48,55,63};
+
+
+/****************************************************************
+* Function: multiply *
+* *
+* Arguments *
+* x,y signed variables *
+* *
+* Description *
+* Just a multiplier. But by doing this in a function the *
+* FPGA space needed is reduced. *
+* *
+* Return Values *
+* The result after multiplication *
+****************************************************************/
+macro proc multiply(result, op_a, op_b)
+{
+#if HARDWARE_MULTIPLY
+ xilinxmult(result, op_a, adjs(op_b,18));
+#else
+ macro expr mul_width = (width(op_a) + width(op_b));
+ result = adjs(op_a, mul_width) * adjs(op_b, mul_width);
+#endif
+/* signed result;
+
+ fixed_mul(result,x,y);
+ return result;*/
+}
+/*macro proc multiply(result, x,y)
+{
+#if HARDWARE_MULTIPLY
+ xilinxmult(result, adjs(x,18), adjs(y,18));
+#else
+ result = ((adjs(x,36))*(adjs(y,36)));
+#endif
+
+}
+*/
+
+
+
+/*******************************************************************
+* Function: calculate_fft *
+* *
+* Arguments *
+* select_inverse Boolean that indicates FFT or iFFT calculation *
+* *
+* Description *
+* This routine performs the Fast Fourier Transform for *
+* calculation of the frequency spectrum *
+* *
+*******************************************************************/
+void calculate_fft(unsigned 1 select_inverse)
+{
+ unsigned 4 level;
+ unsigned 8 point1,point2,j,f,k;
+ unsigned 9 e,i;
+ signed 16 weight1,weight2;
+#if HARDWARE_MULTIPLY
+ signed 18 p,q,r,t;
+#else
+ signed 24 p,q,r,t;
+#endif
+ signed a,b;
+
+ macro expr rescale (x) = (x[35] @ x[30:14]);
+
+ for(level=1;level<=NUMBER_OF_COLUMNS;level++) // count all the columns
+ {
+ e=1<<(NUMBER_OF_COLUMNS-level+1); // number of points in each block in this column
+ f=(e>>1)<-8; // number of butterflies in each block in this column
+
+ for(j=1;j<=f;j++) // count all the butterflies in each block
+ {
+ par
+ {
+ // Weight factors for real (the same for FFT and iFFT)
+ weight1 = weight_re[((j-1)<<(level-1))<-7];
+
+
+ // Weight factors for imaginary (opposite for FFT and iFFT)
+ weight2 = (!select_inverse) ? (weight_im[((j-1)<<(level-1))<-7]) : -(weight_im[((j-1)<<(level-1))<-7]);
+
+ /* ORIGINAL CODE BELOW, MODIFIED BECAUSE OF MISMATCHING OUTPUT WITH BORLAND TESTAPP
+ weight2 = (!select_inverse) ? -(weight_im[((j-1)<<(level-1))<-7]) : weight_im[((j-1)<<(level-1))<-7];
+ */
+
+
+
+ for(i=0@j;i<=NUMBER_OF_POINTS;i+=e) // count all the blocks in this column
+ { // Butterfly calculation
+ par
+ {
+ point1 = ((i<-8)-1);
+ point2 = (((i<-8)+f)-1);
+ }
+
+ par
+ {
+ p = (real.read[point1] >> 1) + (real.rwrite[point2] >> 1);
+ q = (imaginary.read[point1] >> 1) + (imaginary.rwrite[point2] >> 1);
+ }
+
+ par
+ {
+ r = (real.read[point1] >> 1) - (real.rwrite[point2] >> 1);
+ t = (imaginary.read[point1] >> 1) - (imaginary.rwrite[point2] >> 1);
+ }
+
+ multiply(a,r,weight1);
+ multiply(b,t,weight2);
+
+ par
+ {
+ real.rwrite[point2] = (rescale(a-b));
+ imaginary.rwrite[point1] = q;
+ }
+
+ multiply(a,t,weight1);
+ multiply(b,r,weight2);
+
+ par
+ {
+ real.rwrite[point1] = p;
+ imaginary.rwrite[point2] = (rescale(a+b));
+ }
+
+ }
+ }
+ }
+ }
+
+ j=1;
+ for(i=1;i<NUMBER_OF_POINTS;i++)
+ {
+ if(i<(0@j))
+ {
+ par
+ {
+ point1=j-1;
+ point2=(i-1)<-8;
+ }
+ /*
+ COPYING ARRAY VALUES FROM ONE PLACE TO ANOTHER IN THE ARRAT MUST BE DONE IN
+ 2 STEPS. FIRSTLY THE VALUES ARE COPIED TO SEPARATE VARIABLES AFTER THAT THEY
+ ARE COPIED BACK TO THEIR NEW POSITION IN THE ARRAY. THIS MUST BE DONE TO
+ PREVENT TIMING ISSUES FROM OCCURING.
+ */
+ par
+ {
+ p = real.read[point1];
+ q = imaginary.read[point1];
+ }
+ par
+ {
+ r = real.read[point2];
+ t = imaginary.read[point2];
+ }
+ par
+ {
+ real.rwrite[point1] = r;
+ imaginary.rwrite[point1] = t;
+ }
+ par
+ {
+ real.rwrite[point2] = p;
+ imaginary.rwrite[point2] = q;
+ }
+ }
+
+ k = NUMBER_OF_POINTS>>1;
+
+
+ while(k<j)
+ {
+ j = j-k;
+ k = k>>1;
+ }
+
+ j+=k;
+ }
+
+}
+
+/********************************************************************/
+#if HARDWARE_MULTIPLY
+void perform_fft(signed 18 *pcm_audio)
+#else
+void perform_fft(signed 16 *pcm_audio)
+#endif
+{
+ unsigned 8 k;
+
+
+#if HARDWARE_MULTIPLY
+ signed 18 sample;
+ k=0;
+ sample = adjs(pcm_audio[k],18);
+#else
+ signed 24 sample;
+ k=0;
+ sample = adjs(pcm_audio[k],24);
+#endif
+
+ //initialize variables for the copying pipeline
+
+
+ // copy audio data to real-array before starting FFT calculation
+ // and set imaginary values to zero
+ do
+ {
+ //Copying the array values has been pipelined to prevent parallel access to the
+ //pcm_audio array. This copying procedure must be finished before another
+ //sample is read from the audio input. The time available for this loop is
+ //determined by the sampling rate of 44,1 Khz
+ par
+ {
+ //COPYING NEEDS TO BE DONE IN 2 STEPS, BECAUSE THE VALUE THAT NEEDS TO WRITTEN
+ //TO THE REAL-RAM NEEDS TO BE AVAILABLE ON THE START OFF THE CLOCKCYCLE.
+#if HARDWARE_MULTIPLY
+ sample = adjs(pcm_audio[k+1],18);
+#else
+ sample = adjs(pcm_audio[k+1],24);
+#endif
+ real.rwrite[k] = sample;
+ imaginary.rwrite[k] = 0;
+ k++;
+ }
+ } while (k);
+
+
+
+#if PERFORM_FFT_CALCULATION
+ calculate_fft(0);
+#endif
+
+
+}
+
+/********************************************************************/
+#if HARDWARE_MULTIPLY
+void perform_ifft(signed 18 *modified_audio/*, unsigned 6 *ifft_info*/)
+#else
+void perform_ifft(signed 16 *modified_audio/*, unsigned 6 *ifft_info*/)
+#endif
+{
+ unsigned 6 k;
+#if HARDWARE_MULTIPLY
+ signed 18 p;
+#else
+ signed 24 p;
+#endif
+#if PERFORM_FFT_CALCULATION
+ calculate_fft(1);
+#endif
+
+ k=0;
+//initialize variables for the copying pipeline
+#if PERFORM_FFT_CALCULATION
+ #if HARDWARE_MULTIPLY
+ p = (real.read[(0@k)+95] << NUMBER_OF_COLUMNS);
+ #else
+ p = (real.read[(0@k)+95] >> NUMBER_OF_COLUMNS);
+ #endif
+#else
+ p = (real.read[(0@k)+95]);
+#endif
+
+ do
+ {
+ //Copying the array values has been pipelined to prevent parallel access to the
+ //pcm_audio array. This copying procedure must be finished before another
+ //sample is read from the audio input. The time available for this loop is
+ //determined by the sampling rate of 44,1 Khz
+ par
+ {
+#if PERFORM_FFT_CALCULATION
+ #if HARDWARE_MULTIPLY
+ p = (real.read[(0@k)+95] << NUMBER_OF_COLUMNS);
+ #else
+ p = (real.read[(0@k)+95] >> NUMBER_OF_COLUMNS);
+ #endif
+#else
+ p = (real.read[(0@k)+95]);
+#endif
+#if HARDWARE_MULTIPLY
+ modified_audio[k] = p ;
+#else
+ modified_audio[k] = (p<-16);
+#endif
+ //ifft_info[k] = (unsigned)(p[15:10]);
+ k++;
+ }
+ } while(k);
+}
+
+/********************************************************************/
+void equalize_audio(unsigned 4 *eq_level, unsigned 7 *fft_info)
+{
+#if 1
+#if HARDWARE_MULTIPLY
+ signed 18 p,q;
+#else
+ signed 24 p,q;
+#endif
+ signed 16 a;
+ unsigned 8 i, mirror_i, bit, m, n;
+ unsigned 7 old_value;
+ unsigned 9 tmp;
+
+ //macro expr equalize_bar = multiply(q,a)[29:6];
+
+ macro proc equalize_bar(result)
+ {
+ signed result;
+ multiply(result, q,a);
+#if HARDWARE_MULTIPLY
+ result = result[29:12];
+#else
+ result = result[29:6];
+#endif
+ }
+#if HARDWARE_MULTIPLY
+ p = real.read[0] - 10;
+#else
+ p = real.read[0] - DC_COMPONENT; // remove DC component for calculations
+#endif
+ real.rwrite[0] = p;
+// imaginary.rwrite[0] = 0; // remove DC component
+
+
+ for(i=0;i<=NUMBER_OF_FREQUENCIES;i++)
+ {
+ // set multiplication factor (0..64) for current frequency bar
+ a = adjs(eq_settings[eq_level[i<-7]],16);
+
+ // multiply frequency with this factor and divide by 64 (drop 6 LSB's)
+ q = real.read[i];
+ equalize_bar(p);
+ real.rwrite[i] = p;
+
+ q = imaginary.read[i];
+ equalize_bar(p);
+ imaginary.rwrite[i] = p;
+
+ // the upper part(128..255) of the spectrum is mirrored to the lower part;
+ // these values need to be adjusted too
+ if ((i<-7)!=0) // if not in DC component bar
+ {
+ mirror_i = (NUMBER_OF_POINTS-1)-i+1;
+ q = real.read[mirror_i];
+ equalize_bar(p);
+ real.rwrite[mirror_i] = p;
+
+ q = imaginary.read[mirror_i];
+ equalize_bar(p);
+ imaginary.rwrite[mirror_i] = p;
+ }
+ }
+
+ //write data to fft_info for display purposes
+ for(i=0;i<NUMBER_OF_FREQUENCIES;i++)
+ {
+ p = real.read[i];
+ q = imaginary.read[i];
+#if HARDWARE_MULTIPLY
+ if (p[17] == 1) p = -p; else delay;
+ if (q[17] == 1) q = -q; else delay;
+#else
+ if (p[17] == 1) p = -p; else delay;
+ if (q[17] == 1) q = -q; else delay;
+#endif
+ p = (p<q) ? q : p; // This is done to get the best visual frequency result
+
+ if (display_log)
+ {
+
+ bit=126;
+#if HARDWARE_MULTIPLY
+ while ((p[15] == 0) && (bit != 0))
+#else
+ while ((p[15] == 0) && (bit != 0))
+#endif
+ par
+ {
+ p = p<<1;
+ bit = bit - 18;
+ }
+ old_value = fft_info[i<-7];
+ tmp = ((0@old_value) + (0@bit))>>1;
+ fft_info[i<-7] = (old_value <= (tmp<-7)) ? (tmp<-7) : old_value-1;
+ }
+ else
+ {
+ old_value = fft_info[i<-7];
+#if HARDWARE_MULTIPLY
+ fft_info[i<-7] = (old_value<=(unsigned)(p[15:9])) ? (unsigned)(p[15:9]) : old_value-1;
+#else
+ fft_info[i<-7] = (old_value<=(unsigned)(p[21:15])) ? (unsigned)(p[21:15]) : old_value-1;
+#endif
+ }
+ }
+
+ // add DC component again before inverse FFT calculation is performed
+#if HARDWARE_MULTIPLY
+ p = real.read[0] +10;// + DC_COMPONENT;
+#else
+ p = real.read[0] + DC_COMPONENT;
+#endif
+ real.rwrite[0] = p;
+#endif
+}
diff --git a/Graphic_Equalizer/src/main.hcc b/Graphic_Equalizer/src/main.hcc
index 9c18ca5..60eb71b 100644
--- a/Graphic_Equalizer/src/main.hcc
+++ b/Graphic_Equalizer/src/main.hcc
@@ -60,6 +60,7 @@ void main(void) {
mousedata_t mousedata;
events_t events;
+ mpram equalizer_levels_t equalizer_levels;
unsigned 1 result;
/*
@@ -123,7 +124,7 @@ void main(void) {
display_init(ClockRate);
PalAudioInEnable(AudioIn);
PalAudioOutEnable(AudioOut);
- audio_init(6, LINE_IN, SR_44100);
+ audio_init(6, LINE_IN, SR_44100, AudioIn, AudioOut);
#if HAVE_SMARTMEDIA
/*
* Once we properly setup the SmartMedia we load our
@@ -154,8 +155,8 @@ void main(void) {
*/
mouse_main(mousedata);
display_main(events, mousedata, ClockRate, VideoOut, RAM_BANK0);
- eventhandler_main(events, mousedata);
- audio_main();
+ eventhandler_main(equalizer_levels, events, mousedata);
+ audio_main(AudioIn, AudioOut);
}
#if HAVE_SMARTMEDIA
} else {
diff --git a/Graphic_Equalizer/src/mouse.hcc b/Graphic_Equalizer/src/mouse.hcc
index 8db9c51..4d28097 100644
--- a/Graphic_Equalizer/src/mouse.hcc
+++ b/Graphic_Equalizer/src/mouse.hcc
@@ -25,9 +25,14 @@
#include "pal_mouse.hch"
/******** Application Includes ********/
+#include "configuration.hch"
#include "mouse_shared.hch"
#include "mouse.hch"
+#if HAVE_DEBUG
+ #include "debug.hch"
+#endif
+
/*! \fn void mouse_main(mousedata_t *mousedata);
@@ -54,7 +59,7 @@ macro proc mouse_main(mousedata)
* using newer libs this might be overkill, e.g. smaller values may due
* or sampling all together will be redundant.
*/
- for(touch_sampler = 1;;touch_sampler++) {
+ for(touch_sampler = 1;; touch_sampler++) {
if (!touch_sampler) {
/*
* We are here ready to set mouse states. We compare
@@ -83,19 +88,31 @@ macro proc mouse_main(mousedata)
touched = FALSE;
/*
+ * In the rare occurance that we receive values
+ * beyond our range, we set them to some sane
+ * values here.
+ */
+ x = (x > 639) ? 0 : x;
+ y = (y > 479) ? 0 : y;
+
+ /*
* Compare Previous States and Coordinates to determine
* wether they have changed. If so, Copy them into
* shared memory, notify the listening processes and
- * Set the new as previous values for the next run.
+ * Set the new as previous values for the next run. We
+ * can only do this when the display has handled all
+ * changes.
*/
- if ((oldmousestate != mousestate) || (oldx != x) || (oldy != y)) {
- mousedata.x = x;
- mousedata.y = y;
- mousedata.state = mousestate;
- mousedata.status = MOUSE_UPDATED;
- oldx = x;
- oldy = y;
- oldmousestate = mousestate;
+ if (((oldmousestate != mousestate) || (oldx != x) || (oldy != y)) && (MOUSE_NOT_UPDATED == mousedata.status)) {
+ //par {
+ oldx = x;
+ oldy = y;
+ oldmousestate = mousestate;
+ mousedata.x = x;
+ mousedata.y = y;
+ mousedata.state = mousestate;
+ mousedata.status = MOUSE_UPDATED;
+ //}
}
}
diff --git a/Graphic_Equalizer/src/smartmedia.hcc b/Graphic_Equalizer/src/smartmedia.hcc
index 5c547cc..86d6f44 100644
--- a/Graphic_Equalizer/src/smartmedia.hcc
+++ b/Graphic_Equalizer/src/smartmedia.hcc
@@ -100,7 +100,7 @@ macro proc smartmedia_loaddata(RAM_BANK0) {
* We start with the address of the skin, and do the loop until we have
* done the end of the help.
*/
- for (address = ADDRESS_SKIN_START; address != (ADDRESS_HELP_END +1); address++) {
+ for (address = ADDRESS_SKIN_START; address != (ADDRESS_SKIN_END +1); address++) {
/*
* Once we are done with the loading of our skin, we need to
* change the smartmedia start addresses.
@@ -114,7 +114,12 @@ macro proc smartmedia_loaddata(RAM_BANK0) {
* Before reading our data from the smartmedia we set our
* address pointer to the address from our loop.
*/
+#if SKIP_LOAD
+ PalPL2RAMSetWriteAddress(RAM_BANK0, 0);
+#else
+/* Warning: Make sure the proper images are loaded into ram before calling! */
PalPL2RAMSetWriteAddress(RAM_BANK0, address);
+#endif
/*
* SmartMedia data is read one byte per call. Because we want
@@ -145,7 +150,7 @@ macro proc smartmedia_loaddata(RAM_BANK0) {
data = 0 @ mask @ r @ g @ b;
#else
- data = 0xff000f00;
+ data = 0x0000ff00;
#endif
/*
* Now that we have gathered all pixel data, store it in ram.