summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer/src/display.hcc
blob: 12f440c0d72115f314f61ba220dae65db8ab84fd (plain)
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
/*! \file display.hcc
 *
 * \section generic Message build up information and more
 *
 * \section project Project information.
 * Project Graphic Equalizer\n
 * \author O.M. Schinagl
 * \date 20041011
 * \version 0.1
 *
 * \section copyright Copyright
 * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved
 *
 * \section history Change history
 * 20041011: O.M. Schinagl\n	Initial version
 *
 ********************************************************************/

/******** System Includes *************/
#include <stdlib.hch>

#include "pal_master.hch"

/******** Application Includes ********/
#include "configuration.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, ClockRate, RAM_BANK0);
 * \brief	This routine handles all drawing of pixels. It never returns!
 * 
 * \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
 */
macro proc display_main(events, mousedata, CLOCKRATE, 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);
	macro expr SCANX = PalVideoOutGetX(VIDEOOUT);
	macro expr SCANY = PalVideoOutGetY(VIDEOOUT);
	
	unsigned AW address;
	unsigned DW pixeldata;

/*
 * To draw something usefull when only drawing our mask, we simply draw the
 * mask itself. Thus creating a blueish image to help identify all interesting
 * 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
#define PIXEL (0 @ pixeldata[31:24])
#else
#define PIXEL (pixeldata <- 24)
#endif
	/*
	 * Prime Rendering Pipeline to start where the skin starts.
	 */
	PalPL2RAMSetReadAddress(RAM_BANK0, ADDRESS_SKIN_START);

	/*
	 * Run the following tasks indefinatly and in parallel
	 */
	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 == 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 ((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.
				 */
				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 {
				/*
				 * Increase the memory counter for each pixel drawn
				 * thus keeping the memory location in sync with
				 * the current pixel position.
				 */
				address++;
			}
		}
	}
} /* --- display_main() --- */