summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer/src/display/display.hcc
blob: 2dfc669c4481a944f875ca9ae6038ec4ab5865cf (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
/*! \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 "display.hch"



/*! \fn		void display_main(RAM_BANK0, RAM_BANK1);
 * \brief	This routine handles all drawing of pixels. It never returns!
 * 
 * \param	PL2RAM RAM_BANK0	Handle to the first rambank.
 * \param	PL2RAM RAM_BANK1	Handle to the second rambank.
 * 
 * \return	Never Returns.
 * \retval	void
 */
macro void display_main(RAM_BANK0, RAM_BANK1) {
	/*
	 * Setup macro's to coordinate pixel writing.
	 */
	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);
	
	unsigned 32 pixeldata;
	unsigned AW nextaddr;
	unsigned DW pixeldata;
	unsigned 1 SwitchData, help;

	/*
	 * Prime Rendering Pipeline to start at bank 0 address 0.
	 */
	PalPL2RAMSetReadAddress(RAM_BANK0, 0);

	/*
	 * Run the following tasks indefinatly and in parallel
	 */
	par (;;) {
		/*
		 * We write only the last 24 bits of pixeldata as it also
		 * contains information about the mask.
		 */
		PalVideoOutWrite(VideoOut, pixeldata <- 24);

		/* FIXME this needs to be replaced by a global state array */
		PalSwitchRead(PalSwitchCT(0), &help);
		/*
		 * When 'help' is activated, we display data from rambank 1
		 * otherwise we draw from rambank 0.
		 */
		if (help) {
			PalPL2RAMRead(RAM_BANK1, &Data);
			PalPL2RAMSetReadAddress(RAM_BANK1, nextaddr);
		} else {
			PalPL2RAMRead(PL2RAM_BANK0, &Data);
			PalPL2RAMSetReadAddress(RAM_BANK0, nextaddr);
		}

		/*
		 * 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 5 total stages. Therefor we have to
		 * substract 5 pixels.
		 */
		if ((X > (VisibleX - 5)) && (X <= (TotalX - 5))) {
			/*
			 * 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 (Y == (TotalY -1)) {
				nextaddr = 0;
			}
		} else {
			/*
			 * Increase the memory counter for each pixel drawn
			 * thus keeping the memory location in sync with
			 * the current pixel position.
			 */
			nextaddr++;
		}
} /* --- display_main() --- */