summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2004-11-10 16:11:03 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2004-11-10 16:11:03 (GMT)
commit51085a870cc074c3eeef5a6ba1b45503ce0e0f4d (patch)
tree2232a881b7a90f475da5640161f32cf900102369
parentedf01e33d5680018a8c48224b8f7134587f3fcdf (diff)
downloadTASS-51085a870cc074c3eeef5a6ba1b45503ce0e0f4d.zip
TASS-51085a870cc074c3eeef5a6ba1b45503ce0e0f4d.tar.gz
TASS-51085a870cc074c3eeef5a6ba1b45503ce0e0f4d.tar.bz2
-rw-r--r--Graphic_Equalizer/include/audio.hch18
-rw-r--r--Graphic_Equalizer/include/configuration.hch54
-rw-r--r--Graphic_Equalizer/include/display.hch2
-rw-r--r--Graphic_Equalizer/include/display_shared.hch16
-rw-r--r--Graphic_Equalizer/include/eventhandler.hch7
-rw-r--r--Graphic_Equalizer/include/eventhandler_shared.hch18
-rw-r--r--Graphic_Equalizer/include/smartmedia.hch11
-rw-r--r--Graphic_Equalizer/src/audio.hcc30
-rw-r--r--Graphic_Equalizer/src/display.hcc150
-rw-r--r--Graphic_Equalizer/src/eventhandler.hcc62
-rw-r--r--Graphic_Equalizer/src/main.hcc52
-rw-r--r--Graphic_Equalizer/src/mouse.hcc4
-rw-r--r--Graphic_Equalizer/src/smartmedia.hcc36
13 files changed, 272 insertions, 188 deletions
diff --git a/Graphic_Equalizer/include/audio.hch b/Graphic_Equalizer/include/audio.hch
index 0b11168..ff4a4fc 100644
--- a/Graphic_Equalizer/include/audio.hch
+++ b/Graphic_Equalizer/include/audio.hch
@@ -1,4 +1,4 @@
-/*! \file audiodriver.hch
+/*! \file audio.hch
*
* \section generic Audiodriver API
*
@@ -16,16 +16,14 @@
*
********************************************************************/
-#ifndef _AUDIODRIVER_HCH
-#define _AUDIODRIVER_HCH 1
+#ifndef _AUDIO_HCH
+#define _AUDIO_HCH 1
/*
* Type definition of the shared memory to be used in various processes
*/
-typedef struct {
-} audiodata_s;
@@ -41,7 +39,7 @@ typedef struct {
* Line in or Mic in aliases for audio_init.
*/
#define LINE_IN RC200AudioInLineIn
-#define MIC_IN RC200AudioInMicIn
+#define MIC_IN RC200AudioInMicrophone
@@ -62,9 +60,7 @@ typedef struct {
* passed level, input_source chooses between line in or mic in. The
* sample_rate is set to supplied rate. Defines for these are mentioned above.
*/
-void audio_init(unsigned 4 gain_level,
- unsigned 1 input_source,
- unsigned 3 sample_rate);
+macro proc audio_init(gain_level, input_source, sample_rate);
@@ -75,6 +71,6 @@ void audio_init(unsigned 4 gain_level,
void audio_main(void);
#else
-#error "ERROR file audiodriver.hch multiple times included"
-#endif /* --- _AUDIODRIVER_HCH --- */
+#error "ERROR file audio.hch multiple times included"
+#endif /* --- _AUDIO_HCH --- */
diff --git a/Graphic_Equalizer/include/configuration.hch b/Graphic_Equalizer/include/configuration.hch
index 6e9480a..c02a7e2 100644
--- a/Graphic_Equalizer/include/configuration.hch
+++ b/Graphic_Equalizer/include/configuration.hch
@@ -22,7 +22,7 @@
/*
* To print debug information on the RS232 port set this define.
*/
-#define HAVE_DEBUG 0
+#define HAVE_DEBUG 1
@@ -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_SMART_MEDIA 0
+#define HAVE_SMARTMEDIA 0
#define USE_MASK_ONLY 1
@@ -42,7 +42,7 @@
* data, or each segment is stored seperatly at its own address. If set to 1
* we'll asume one large continuous blok.
*/
-#define LARGE_DATA_BLOCK 1
+#define LARGE_DATA_BLOCK 0
@@ -53,42 +53,42 @@
*/
#define SIZE_SKIN 0x04b000
#define SIZE_HELP 0x04b000
-#define SIZE_MASK_SKIN 0x019000
-#define SIZE_MASK_HELP 0x019000
+#define SIZE_SKINMASK 0x019000
+#define SIZE_HELPMASK 0x019000
/*
* Here we setup the start and end address for the various components.
*/
-#define ADDR_SKIN_START 0x000000
-#define ADDR_SKIN_END (ADDR_SKIN_START +SIZE_SKIN)
+#define ADDRESS_SKIN_START 0x000000
+#define ADDRESS_SKIN_END (ADDRESS_SKIN_START +SIZE_SKIN)
-#define ADDR_HELP_START 0x04b001
-#define ADDR_HELP_END (ADDR_HELP_START +SIZE_HELP)
+#define ADDRESS_HELP_START 0x04b001
+#define ADDRESS_HELP_END (ADDRESS_HELP_START +SIZE_HELP)
#if LARGE_DATA_BLOCK
- #define SM_ADDR_OFFSET 0x084000
+ #define SMARTMEDIA_ADDRESS_OFFSET 0x084000
- #define SM_ADDR_SKIN_START SM_ADDR_OFFSET
- #define SM_ADDR_SKIN_END (SM_ADDR_SKIN_START +(SIZE_SKIN *3))
- #define SM_ADDR_SKIN_MASK_START (SM_ADDR_SKIN_END +1)
- #define SM_ADDR_SKIN_MASK_END (SM_ADDR_OFFSET +SIZE_MASK_SKIN)
+ #define SMARTMEDIA_ADDRESS_SKIN_START SMARTMEDIA_ADDRESS_OFFSET
+ #define SMARTMEDIA_ADDRESS_SKIN_END (SMARTMEDIA_ADDRESS_SKIN_START +(SIZE_SKIN *3))
+ #define SMARTMEDIA_ADDRESS_SKINMASK_START (SMARTMEDIA_ADDRESS_SKIN_END +1)
+ #define SMARTMEDIA_ADDRESS_SKINMASK_END (SMARTMEDIA_ADDRESS_SKINMASK_START +SIZE_SKINMASK)
- #define SM_ADDR_HELP_START (SM_ADDR_SKIN_MASK_END +1)
- #define SM_ADDR_HELP_END (SM_ADDR_HELP_START +(SIZE_HELP *3))
- #define SM_ADDR_HELP_MASK_START (SM_ADDR_HELP_END +1)
- #define SM_ADDR_HELP_MASK_END (SM_ADDR_OFFSET +SIZE_MASK_HELP)
+ #define SMARTMEDIA_ADDRESS_HELP_START (SMARTMEDIA_ADDRESS_SKINMASK_END +1)
+ #define SMARTMEDIA_ADDRESS_HELP_END (SMARTMEDIA_ADDRESS_HELP_START +(SIZE_HELP *3))
+ #define SMARTMEDIA_ADDRESS_HELPMASK_START (SMARTMEDIA_ADDRESS_HELP_END +1)
+ #define SMARTMEDIA_ADDRESS_HELPMASK_END (SMARTMEDIA_ADDRESS_HELPMASK_START +SIZE_HELPMASK)
#else
- #define SM_ADDR_SKIN_START 0x084000
- #define SM_ADDR_SKIN_MASK_START 0x168000
- #define SM_ADDR_HELP_START 0x1b4000
- #define SM_ADDR_HELP_START 0x298000
-
- #define SM_ADDR_SKIN_END (SM_ADDR_SKIN_START +(SIZE_SKIN *3))
- #define SM_ADDR_SKIN_MASK_END (SM_ADDR_SKIN_END +(SIZE_MASK_SKIN *3))
- #define SM_ADDR_HELP_END (SM_ADDR_HELP_START +(SIZE_HELP *3))
- #define SM_ADDR_HELP_MASK_END (SM_ADDR_SKIN_MASK_END +(SIZE_MASK_HELP *3))
+ #define SMARTMEDIA_ADDRESS_SKIN_START 0x084000
+ #define SMARTMEDIA_ADDRESS_SKINMASK_START 0x168000
+ #define SMARTMEDIA_ADDRESS_HELP_START 0x1b4000
+ #define SMARTMEDIA_ADDRESS_HELPMASK_START 0x298000
+
+ #define SMARTMEDIA_ADDRESS_SKIN_END (SMARTMEDIA_ADDRESS_SKIN_START +(SIZE_SKIN *3))
+ #define SMARTMEDIA_ADDRESS_SKINMASK_END (SMARTMEDIA_ADDRESS_SKINMASK_START +(SIZE_SKINMASK *3))
+ #define SMARTMEDIA_ADDRESS_HELP_END (SMARTMEDIA_ADDRESS_HELP_START +(SIZE_HELP *3))
+ #define SMARTMEDIA_ADDRESS_HELPMASK_END (SMARTMEDIA_ADDRESS_HELPMASK_END +(SIZE_HELPMASK *3))
#endif
diff --git a/Graphic_Equalizer/include/display.hch b/Graphic_Equalizer/include/display.hch
index d191149..f8a4d0a 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.
*/
-void display_main(events_t *events, mousedata_t *mousedata);
+macro proc display_main(events, mousedata, ClockRate, RAM_BANK0);
#else
#error "ERROR file display.hch multiple times included"
diff --git a/Graphic_Equalizer/include/display_shared.hch b/Graphic_Equalizer/include/display_shared.hch
index 66e8111..a3f2cb1 100644
--- a/Graphic_Equalizer/include/display_shared.hch
+++ b/Graphic_Equalizer/include/display_shared.hch
@@ -22,22 +22,6 @@
/*
- * Volume Control lookuptable.
- * TODO: This table is now hardcoded. To ensure full skinability this table
- * should be dynamically loaded.
- */
-rom unsigned 6 volumecontrol_table[46] = {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0};
-
-/*
- * Equalizer lookuptabe.
- * TODO: This table is now hardcoded. To ensure full skinability this table
- * should be dynamically loaded.
- */
-rom unsigned 4 equalizer_table[66] = {15, 15, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0};
-
-
-
-/*
* Define all area's of the display.
*/
#define AREA_WAVEFORM 0x01
diff --git a/Graphic_Equalizer/include/eventhandler.hch b/Graphic_Equalizer/include/eventhandler.hch
index 413e563..a1dab26 100644
--- a/Graphic_Equalizer/include/eventhandler.hch
+++ b/Graphic_Equalizer/include/eventhandler.hch
@@ -23,10 +23,11 @@
/*
- * This is the main eventhandler loop. It never returns! It coordinates
- * userinput and the actions requred to be taken.
+ * This is the main eventhandler loop. We require pointers to the event struct
+ * 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);
+void eventhandler_main(events_t *events, mousedata_t *mousedata);
#else
#error "ERROR file eventhandler.hch multiple times included"
diff --git a/Graphic_Equalizer/include/eventhandler_shared.hch b/Graphic_Equalizer/include/eventhandler_shared.hch
index 1ce7578..342bb0b 100644
--- a/Graphic_Equalizer/include/eventhandler_shared.hch
+++ b/Graphic_Equalizer/include/eventhandler_shared.hch
@@ -32,6 +32,24 @@ typedef struct {
unsigned 8 mask;
} events_t;
+
+
+/*
+ * Volume Control lookuptable.
+ * TODO: This table is now hardcoded. To ensure full skinability this table
+ * should be dynamically loaded.
+ */
+extern unsigned 5 volumecontrol_table[46];
+
+/*
+ * Equalizer lookuptabe.
+ * TODO: This table is now hardcoded. To ensure full skinability this table
+ * should be dynamically loaded.
+ */
+extern unsigned 4 equalizer_table[66];
+
+
+
#else
#error "ERROR file eventhandler_shared.hch multiple times included"
#endif /* --- _EVENTHANDLER_SHARED_HCH --- */
diff --git a/Graphic_Equalizer/include/smartmedia.hch b/Graphic_Equalizer/include/smartmedia.hch
index e44e435..774518f 100644
--- a/Graphic_Equalizer/include/smartmedia.hch
+++ b/Graphic_Equalizer/include/smartmedia.hch
@@ -19,6 +19,12 @@
#ifndef _SMARTMEDIA_HCH
#define _SMARTMEDIA_HCH 1
+/*
+ * SmartMedia functioncalls a bit to be set to either Read or Write. This
+ * define should make life easier identifying which one is what.
+ */
+#define READ 0
+#define WRITE 1
/*
@@ -32,13 +38,14 @@
/*
* Initializes the smartmedia device.
*/
-void smartmedia_init(void);
+unsigned 1 smartmedia_init(void);
+
/*
* This function loads the memory with data from the smartmedia card.
*/
-void smartmedia_loaddata(void);
+macro proc smartmedia_loaddata(RAM_BANK0);
#else
#error "ERROR file smartmedia.hch multiple times included"
diff --git a/Graphic_Equalizer/src/audio.hcc b/Graphic_Equalizer/src/audio.hcc
index c7d1adf..2959591 100644
--- a/Graphic_Equalizer/src/audio.hcc
+++ b/Graphic_Equalizer/src/audio.hcc
@@ -1,6 +1,6 @@
-/*! \file header_templace.hcc
+/*! \file audio.hcc
*
- * \section generic Message build up information and more
+ * \section generic Audio init and main loop
*
* \section project Project information.
* Project Graphic Equalizer\n
@@ -23,30 +23,32 @@
/******** Application Includes ********/
#include "audio.hch"
-#include "audio_shared.hch"
-/*! \fn void audio_init(unsigned 4 gain_level,
- * unsigned 1 input_source,
- * unsigned 3 sample_rate)
+/*! \fn void audio_init(gain_level,
+ * input_source,
+ * sample_rate)
*
* \brief Set some inital values to the audio hardware.
*
- * \param unsigned 4 gain_level Set the input amplifier to this
+ * \param gain_level Set the input amplifier to this
* amplification level.
- * \param unsigned 1 input_source Choose between microphone input
+ * \param input_source Choose between microphone input
* or linein input
- * \param unsigned 3 sample_rate Set the sample rate between 8000
+ * \param sample_rate Set the sample rate between 8000
* and 48000
*
* \return void
* \retval void
*
*/
-void audio_init(unsigned 4 gain_level,
- unsigned 1 input_source,
- unsigned 3 sample_rate) {
+macro proc audio_init(gain_level, input_source, sample_rate) {
+ /*
+ * Setup audio pointers.
+ */
+ macro expr AudioIn = PalAudioInCT(0);
+ macro expr AudioOut = PalAudioOutCT(0);
/*
* 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.
@@ -90,7 +92,7 @@ void audio_main(void) {
signed OW sample_left_out, sample_right_out;
for (;;) {
- PalAudioRead(AudioIn, &sample_left_in, &sample_right_in);
+ PalAudioInRead(AudioIn, &sample_left_in, &sample_right_in);
/* par {
sample_add(sample_left_in);
@@ -102,6 +104,6 @@ void audio_main(void) {
* 64 Samples have been processed, calculate.
* /
}
-*/ PalAudioWrite(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 8be1f2e..12f440c 100644
--- a/Graphic_Equalizer/src/display.hcc
+++ b/Graphic_Equalizer/src/display.hcc
@@ -23,32 +23,39 @@
/******** Application Includes ********/
#include "configuration.hch"
-#include "display.hch"
#include "eventhandler_shared.hch"
+#include "mouse_shared.hch"
+#include "display_shared.hch"
+#include "display.hch"
+
+#if HAVE_DEBUG
+ #include "debug.hch"
+#endif
-/*! \fn void display_main(events_t *events, mousedata_t *mousedata);
+/*! \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 pointer to struct with all events.
- * \param mousedata_t *mousedata pointer to struct with coordinates to
- * current X en Y.
+ * \param events_t *events struct with all events.
+ * \param mousedata_t *mousedata struct with coordinates to current
+ * X en Y.
*
* \return Never Returns.
* \retval void
*/
-void display_main(events_t *events, mousedata_t *mousedata) {
+macro proc display_main(events, mousedata, CLOCKRATE, RAM_BANK0) {
/*
* Setup macro's RAM/Video handles and to coordinate pixel writing.
*/
- macro expr RAM_BANK0 = PalPL2RAMCT(0);
- macro expr VideoOut = PalVideoOutOptimalCT(ClockRate);
- macro expr VisibleX = PalVideoOutGetVisibleX (VideoOut, ClockRate);
- macro expr TotalX = PalVideoOutGetTotalX (VideoOut, ClockRate);
- macro expr TotalY = PalVideoOutGetTotalY (VideoOut);
- macro expr X = PalVideoOutGetX (VideoOut);
- macro expr Y = PalVideoOutGetY (VideoOut);
+ 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);
+ macro expr SCANX = PalVideoOutGetX(VIDEOOUT);
+ macro expr SCANY = PalVideoOutGetY(VIDEOOUT);
unsigned AW address;
unsigned DW pixeldata;
@@ -59,7 +66,7 @@ void display_main(events_t *events, mousedata_t *mousedata) {
* 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
+#if USE_MASK_ONLY && HAVE_SMARTMEDIA
#define PIXEL (0 @ pixeldata[31:24])
#else
#define PIXEL (pixeldata <- 24)
@@ -72,69 +79,76 @@ void display_main(events_t *events, mousedata_t *mousedata) {
/*
* Run the following tasks indefinatly and in parallel
*/
- 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.
- */
- PalPL2RAMRead(RAM_BANK0, &pixeldata);
- PalPL2RAMSetReadAddress(RAM_BANK0, address);
-
- switch (pixeldata[31:24]) {
- case (AREA_VOLUME_YAXIS == pixeldata[31:24]):
- if (ScanY <= events->volume_position) {
- PalVideoOutWrite(VideoOut, PIXEL_VOLUME_YAXIS);
- } else {
- PalVideoOutWrite(VideoOut, PIXEL);
- }
- break;
- default:
- PalVideoOutWrite(VideoOut, PIXEL);
- break;
- }
+ 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.
+ */
+ PalPL2RAMRead(RAM_BANK0, &pixeldata);
+ PalPL2RAMSetReadAddress(RAM_BANK0, address);
+/*
+ switch (pixeldata[31:24]) {
+ case AREA_VOLUME_YAXIS:
+ if (SCANY <= 0 @ events->volume_position) {
+ PalVideoOutWrite(VIDEOOUT, PIXEL_VOLUME_YAXIS);
+ } else {
+ PalVideoOutWrite(VIDEOOUT, PIXEL);
+ }
+ break;
+ default:
+ PalVideoOutWrite(VIDEOOUT, PIXEL);
+ break;
+ }*/
+ // PalVideoOutWrite(VIDEOOUT, pixeldata <- 24));
+ print_hex_value(pixeldata <- 32);
- /*
- */
- if ((ScanX == mousedata->x) && (ScanY == mousedata->y)) {
- events->mask = pixeldata[31:24];
- }
+ /*
+ *
+ if ((SCANX == 0 @ mousedata->x) && (SCANY == 0 @ mousedata->y)) {
+ events->mask = pixeldata[31:24];
+ } 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.
- */
- if ((X > (VisibleX - 4)) && (X <= (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.
+ * 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 (Y == (TotalY -1)) {
+ if ((SCANX > (VISIBLEX - 4)) && (SCANX <= (TOTALX - 4))) {
/*
- * The reset address is determined by the help
- * bit. FIXME: This needs come from a struct.
+ * 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.
*/
- address = (events->help) ? ADDRESS_HELP_START : ADDRESS_SKIN_START;
+ if (SCANY == (TOTALY -1)) {
+ /*
+ * The reset address is determined by the help
+ * bit.
+ */
+ address = 0;//(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.
+ */
+ delay;
+ }
} else {
/*
- * We should not ever get inhere. To keep
- * everything consequent however, we add a
- * a delay.
+ * Increase the memory counter for each pixel drawn
+ * thus keeping the memory location in sync with
+ * the current pixel position.
*/
- delay;
+ address++;
}
- } else {
- /*
- * Increase the memory counter for each pixel drawn
- * thus keeping the memory location in sync with
- * the current pixel position.
- */
- address++;
}
+ }
} /* --- display_main() --- */
diff --git a/Graphic_Equalizer/src/eventhandler.hcc b/Graphic_Equalizer/src/eventhandler.hcc
index 9c67aef..b9b6b1f 100644
--- a/Graphic_Equalizer/src/eventhandler.hcc
+++ b/Graphic_Equalizer/src/eventhandler.hcc
@@ -24,10 +24,10 @@
#include "pal_master.hch"
/******** Application Includes ********/
-#include "eventhandler.hch"
-#include "eventhandler_shared.hch"
#include "mouse_shared.hch"
#include "display_shared.hch"
+#include "eventhandler_shared.hch"
+#include "eventhandler.hch"
@@ -47,25 +47,73 @@ void eventhandler_main(events_t *events, mousedata_t *mousedata) {
unsigned 1 newmousedata;
for (;;) {
+ mousedata_notification ? newmousedata;
/*
* First we determine what mousestate we currently have. Then
* we check where we are to decide what to do.
*/
switch (mousedata->state) {
- case MOUSE_STATE_DOWN:
+ 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;
+ } else {
+ delay;
}
break;
- case MOUSE_STATE_ON_PRESS:
+ case MOUSE_STATE_DOWN:
+ /*
+ * If we are in the volume area we update the
+ * volume level for both channels.
+ */
if (AREA_VOLUME_YAXIS) {
- events->volume_position = mousedata->y;
- volume_left = volume_table[(mousedata->y) -65];
- RC200SetVolume(!volume_left, volume_left, volume_left);
+ /*
+ * Copy the current Y cursor position
+ * to the events struct. This we then
+ * later use for drawing purposes.
+ */
+ 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];
+ /*
+ * We feel that volume gets softer the
+ * closer it gets to the 0, and louder
+ * as it approaches 0x1f. The SetVolume
+ * RC200 call does this in an unnatural
+ * reverse way. Therefor we reverse it.
+ */
+ RC200AudioOutSetVolume(!volume_left, 0x1f -volume_left, 0x1f -volume_left);
+ } else {
+ delay;
}
if ((AREA_EQUALIZER_MIN <= events->mask) && (events->mask <= AREA_EQUALIZER_MAX)) {
+ delay;
+ } else {
+ delay;
}
break;
}
}
} /* --- eventhandler_main() --- */
+
+
+
+/*
+ * Volume Control lookuptable.
+ * TODO: This table is now hardcoded. To ensure full skinability this table
+ * should be dynamically loaded.
+ */
+rom unsigned 5 volumecontrol_table[46] = {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0};
+
+/*
+ * Equalizer lookuptabe.
+ * TODO: This table is now hardcoded. To ensure full skinability this table
+ * should be dynamically loaded.
+ */
+rom unsigned 4 equalizer_table[66] = {15, 15, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0}; \ No newline at end of file
diff --git a/Graphic_Equalizer/src/main.hcc b/Graphic_Equalizer/src/main.hcc
index 6e4f7ae..d7a8600 100644
--- a/Graphic_Equalizer/src/main.hcc
+++ b/Graphic_Equalizer/src/main.hcc
@@ -16,7 +16,6 @@
*
*****************************************************************************/
-
/*
* Set the Clock rate for this domain. 25.175 Mhz is required for the Video output.
*/
@@ -28,25 +27,19 @@
/******** Application Includes ********/
#include "configuration.hch"
-#include "display.hch"
-#include "mouse.hch"
#include "mouse_shared.hch"
-#include "audio.hch"
-#include "eventhandler.hch"
+#include "mouse.hch"
#include "eventhandler_shared.hch"
+#include "eventhandler.hch"
+#include "audio.hch"
+#include "display.hch"
+#include "smartmedia.hch"
#if HAVE_DEBUG
#include "debug.hch"
#endif
-/*
- * Request Clockrate. Approximated ClockRate is compiler assigned. As the
- * ClockRate is identical throughout the entire domain, this is a global
- * expression so that all process use the correct one.
- */
-macro expr ClockRate = PAL_ACTUAL_CLOCK_RATE;
-
/*! \fn void main(void);
* \brief Main User Input/Ouput loop.
@@ -58,15 +51,17 @@ macro expr ClockRate = PAL_ACTUAL_CLOCK_RATE;
*/
void main(void) {
/*
- * Set VideoOut, Audio I/O and Ram Handles
+ * Set VideoOut, Audio I/O and Ram Handles and set clockrate.
*/
+ macro expr ClockRate = PAL_ACTUAL_CLOCK_RATE;
macro expr VideoOut = PalVideoOutOptimalCT(ClockRate);
macro expr AudioIn = PalAudioInCT(0);
- macro expr AudioOut = PalAudioOutCT(0)
+ macro expr AudioOut = PalAudioOutCT(0);
macro expr RAM_BANK0 = PalPL2RAMCT(0);
- unsigned mousedata_t mousedata;
- unsigned events_t events;
+ mousedata_t mousedata;
+ events_t events;
+ unsigned 1 result;
/*
* Check library versions and Request various hardware functionality.
@@ -85,7 +80,7 @@ void main(void) {
*/
assert (PalVideoOutGetColorWidthCT(VideoOut) == 24, 0,
"We need a 24-bit color Display.");
- assert (PalPL2RAMGetDataWidthCT(PL2RAM_BANK0) >= 32, 0,
+ assert (PalPL2RAMGetDataWidthCT(RAM_BANK0) >= 32, 0,
"We can't work with anything less then 32 bits wide ram.");
/*
@@ -99,13 +94,17 @@ void main(void) {
MouseRun(ClockRate);
PalAudioInRun(AudioIn, ClockRate);
PalAudioOutRun(AudioOut, ClockRate);
-#if HAVE_SMART_MEDIA
+#if HAVE_SMARTMEDIA
/*
* The smartmedia device needs the CPLD to run.
*/
CPLDRun(ClockRate);
SmartMediaRun(ClockRate);
#endif
+#if HAVE_DEBUG
+ RC200RS232Run(RC200RS232_115200Baud, RC200RS232ParityNone,
+ RC200RS232FlowControlNone, ClockRate);
+#endif
/*
* Parallel to our Primary tasks we run the application.
@@ -116,22 +115,29 @@ void main(void) {
* We also load the data from the SmartMedia card
* into the ram.
*/
+#if HAVE_DEBUG
+ print_eol();
+ print_string("Graphic Equalizer 2");
+ print_eol();
+#endif
display_init(ClockRate);
PalAudioInEnable(AudioIn);
PalAudioOutEnable(AudioOut);
audio_init(6, LINE_IN, SR_44100);
-#if HAVE_SMART_MEDIA
+#if HAVE_SMARTMEDIA
/*
* Once we properly setup the SmartMedia we load our
* data folowed by our main program loop.
*/
- if (!smartmedia_init()) {
+ result = smartmedia_init();
+ if (!result) {
#endif
#if HAVE_DEBUG
print_string("Loading Skin ...");
#endif
- smartmedia_loaddata();
+ smartmedia_loaddata(RAM_BANK0);
#if HAVE_DEBUG
+ print_eol();
print_string("Done Loading Skin ...");
print_eol();
print_string("Running Main Application.");
@@ -147,11 +153,11 @@ void main(void) {
* should ever return.
*/
mouse_main(&mousedata);
- display_main(&events, &mousedata);
+ display_main(events, mousedata, ClockRate, RAM_BANK0);
eventhandler_main(&events, &mousedata);
audio_main();
}
-#if HAVE_SMART_MEDIA
+#if HAVE_SMARTMEDIA
} else {
#if HAVE_DEBUG
print_string("Error Initializing SmartMedia");
diff --git a/Graphic_Equalizer/src/mouse.hcc b/Graphic_Equalizer/src/mouse.hcc
index 7e7ca26..7764ed6 100644
--- a/Graphic_Equalizer/src/mouse.hcc
+++ b/Graphic_Equalizer/src/mouse.hcc
@@ -25,8 +25,8 @@
#include "pal_mouse.hch"
/******** Application Includes ********/
-#include "mousedriver.hch"
-#include "mousedriver_shared.hch"
+#include "mouse_shared.hch"
+#include "mouse.hch"
diff --git a/Graphic_Equalizer/src/smartmedia.hcc b/Graphic_Equalizer/src/smartmedia.hcc
index 7fc647b..78682ba 100644
--- a/Graphic_Equalizer/src/smartmedia.hcc
+++ b/Graphic_Equalizer/src/smartmedia.hcc
@@ -25,6 +25,10 @@
#include "configuration.hch"
#include "smartmedia.hch"
+#if HAVE_DEBUG
+ #include "debug.hch"
+#endif
+
/*! \fn void smartmedia_init(void);
@@ -58,19 +62,18 @@ unsigned 1 smartmedia_init(void) {
-/*! \fn void smartmedia_loaddata(void);
+/*! \fn void smartmedia_loaddata(RAM_BANK0);
* \brief We load our memory with skin and help data from the smartmedia.
*
- * \param void None.
+ * \param RAM_BANK0 Handle to RAM_BANK0
*
* \return void
* \retval void
*/
-void smartmedia_loaddata(void) {
+macro proc smartmedia_loaddata(RAM_BANK0) {
/*
* Setup RAM Handle, and determin maximum Data and Address widths
*/
- macro expr RAM_BANK0 = PalPL2RAMCT(0);
macro expr DW = PalPL2RAMGetMaxDataWidthCT();
macro expr AW = PalPL2RAMGetMaxAddressWidthCT();
@@ -84,20 +87,24 @@ void smartmedia_loaddata(void) {
* Print some nice stats about data loading.
*/
print_eol();
- print_hex_value(0 @ 0);
+ print_hex_value(0);
#endif
/*
* Before we enter our loop to fill our memory with valid data, we have
* to set the startup positions for the SmartMedia.
*/
- smartmedia_address = SMARTMEDIA_ADDRES_SKIN_START;
+ smartmedia_address = SMARTMEDIA_ADDRESS_SKIN_START;
smartmedia_address_mask = SMARTMEDIA_ADDRESS_SKINMASK_START;
- for (address = ADDRESS_SKIN_START; address != (ADDRESS_HELP_END);) {
+ /*
+ * 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++) {
/*
* Once we are done with the loading of our skin, we need to
* change the smartmedia start addresses.
*/
- if (address == ADDRRESS_HELP_START) {
+ if (address == ADDRESS_HELP_START) {
smartmedia_address = SMARTMEDIA_ADDRESS_HELP_START;
smartmedia_address_mask = SMARTMEDIA_ADDRESS_HELPMASK_START;
}
@@ -137,22 +144,23 @@ void smartmedia_loaddata(void) {
#else
mask = 0x01;
r = 0xff;
- g = 0x00;
+ g = 0x0f;
b = 0x00;
#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, (unsigned DW)(0 @ mask @ r @ g @ b));
#if HAVE_DEBUG
/*
* Print some nice stats about data loading.
*/
- if (!address[8:0]) {
+ if (!address[12:0]) {
print_cr();
- print_hex_value(0 @ address);
- print_string(" / 02E4000");
+ print_hex_value(0 @ address[19:13]);
+ print_string(" / 00000064 | data: ");
+ print_hex_value(0 @ mask @ r @ g @ b);
}
#endif
@@ -161,6 +169,6 @@ void smartmedia_loaddata(void) {
*/
smartmedia_address += 3;
smartmedia_address_mask++;
- address++;
+
}
} /* --- smartmedia_loaddata() --- */