1 |
221 |
olivier.gi |
#include "demo.h"
|
2 |
|
|
#include "timerA.h"
|
3 |
|
|
#include "gfx_controller.h"
|
4 |
|
|
|
5 |
|
|
//---------------------------------------------------//
|
6 |
|
|
// 8BPP DEMO
|
7 |
|
|
//---------------------------------------------------//
|
8 |
|
|
void demo_4bpp(void) {
|
9 |
|
|
|
10 |
|
|
unsigned int lfsr;
|
11 |
|
|
unsigned int lfsr_lsb;
|
12 |
|
|
unsigned int line, column;
|
13 |
|
|
unsigned int color = 0;
|
14 |
|
|
unsigned int use_gpu = 1;
|
15 |
|
|
unsigned int wait_sel = 0;
|
16 |
|
|
unsigned int x_coord = 0;
|
17 |
|
|
unsigned int y_coord = 0;
|
18 |
|
|
unsigned int loop;
|
19 |
|
|
|
20 |
|
|
const uint16_t offset_x = 35;
|
21 |
|
|
const uint16_t offset_y = 95;
|
22 |
|
|
const uint16_t char_width = 7;
|
23 |
|
|
|
24 |
|
|
// Screen introduction
|
25 |
|
|
gpu_fill (PIX_ADDR(0, 0 ), 320, 480, 0x0000, DST_SWAP_NONE); // Background
|
26 |
|
|
|
27 |
|
|
gpu_fill (PIX_ADDR(offset_x+1*6*char_width+3*char_width, offset_y+0*char_width), 1*char_width, 7*char_width, 0x000B, DST_SWAP_NONE); // 4
|
28 |
|
|
gpu_fill (PIX_ADDR(offset_x+1*6*char_width+0*char_width, offset_y+4*char_width), 5*char_width, 1*char_width, 0x000B, DST_SWAP_NONE);
|
29 |
|
|
gpu_fill (PIX_ADDR(offset_x+1*6*char_width+2*char_width, offset_y+1*char_width), 1*char_width, 1*char_width, 0x000B, DST_SWAP_NONE);
|
30 |
|
|
gpu_fill (PIX_ADDR(offset_x+1*6*char_width+1*char_width, offset_y+2*char_width), 1*char_width, 1*char_width, 0x000B, DST_SWAP_NONE);
|
31 |
|
|
gpu_fill (PIX_ADDR(offset_x+1*6*char_width+0*char_width, offset_y+3*char_width), 1*char_width, 1*char_width, 0x000B, DST_SWAP_NONE);
|
32 |
|
|
|
33 |
|
|
gpu_fill (PIX_ADDR(offset_x+3*6*char_width+0*char_width, offset_y+0*char_width), 1*char_width, 6*char_width, 0x000B, DST_SWAP_NONE); // b
|
34 |
|
|
gpu_fill (PIX_ADDR(offset_x+3*6*char_width+1*char_width, offset_y+6*char_width), 3*char_width, 1*char_width, 0x000B, DST_SWAP_NONE);
|
35 |
|
|
gpu_fill (PIX_ADDR(offset_x+3*6*char_width+1*char_width, offset_y+4*char_width), 1*char_width, 1*char_width, 0x000B, DST_SWAP_NONE);
|
36 |
|
|
gpu_fill (PIX_ADDR(offset_x+3*6*char_width+2*char_width, offset_y+3*char_width), 2*char_width, 1*char_width, 0x000B, DST_SWAP_NONE);
|
37 |
|
|
gpu_fill (PIX_ADDR(offset_x+3*6*char_width+4*char_width, offset_y+4*char_width), 1*char_width, 2*char_width, 0x000B, DST_SWAP_NONE);
|
38 |
|
|
|
39 |
|
|
gpu_fill (PIX_ADDR(offset_x+4*6*char_width+0*char_width, offset_y+2*char_width), 1*char_width, 5*char_width, 0x000B, DST_SWAP_NONE); // p
|
40 |
|
|
gpu_fill (PIX_ADDR(offset_x+4*6*char_width+1*char_width, offset_y+2*char_width), 3*char_width, 1*char_width, 0x000B, DST_SWAP_NONE);
|
41 |
|
|
gpu_fill (PIX_ADDR(offset_x+4*6*char_width+1*char_width, offset_y+4*char_width), 3*char_width, 1*char_width, 0x000B, DST_SWAP_NONE);
|
42 |
|
|
gpu_fill (PIX_ADDR(offset_x+4*6*char_width+4*char_width, offset_y+3*char_width), 1*char_width, 1*char_width, 0x000B, DST_SWAP_NONE);
|
43 |
|
|
|
44 |
|
|
gpu_fill (PIX_ADDR(offset_x+5*6*char_width+0*char_width, offset_y+2*char_width), 1*char_width, 5*char_width, 0x000B, DST_SWAP_NONE); // p
|
45 |
|
|
gpu_fill (PIX_ADDR(offset_x+5*6*char_width+1*char_width, offset_y+2*char_width), 3*char_width, 1*char_width, 0x000B, DST_SWAP_NONE);
|
46 |
|
|
gpu_fill (PIX_ADDR(offset_x+5*6*char_width+1*char_width, offset_y+4*char_width), 3*char_width, 1*char_width, 0x000B, DST_SWAP_NONE);
|
47 |
|
|
gpu_fill (PIX_ADDR(offset_x+5*6*char_width+4*char_width, offset_y+3*char_width), 1*char_width, 1*char_width, 0x000B, DST_SWAP_NONE);
|
48 |
|
|
|
49 |
|
|
ta_wait_no_lpm(WT_500MS);
|
50 |
|
|
ta_wait_no_lpm(WT_500MS);
|
51 |
|
|
ta_wait_no_lpm(WT_500MS);
|
52 |
|
|
ta_wait_no_lpm(WT_500MS);
|
53 |
|
|
|
54 |
|
|
// Clear background
|
55 |
|
|
gpu_fill (PIX_ADDR(0, 0 ), 320, 240, 0x0000, DST_SWAP_NONE);
|
56 |
|
|
|
57 |
|
|
// Wait for on-going GPU operation to be done before moving on
|
58 |
|
|
gpu_wait_done();
|
59 |
|
|
|
60 |
|
|
// Fill the screen with all possible colors
|
61 |
|
|
color = 0x0000;
|
62 |
|
|
for( line = 0; line <4; line = line + 1 ) {
|
63 |
|
|
for( column = 0; column < 4; column = column + 1 ) {
|
64 |
|
|
|
65 |
|
|
draw_block(PIX_ADDR(x_coord, y_coord), 77, 57, color, DST_SWAP_NONE, 0);
|
66 |
|
|
if (color==15) { color= 0;}
|
67 |
|
|
else { color++; }
|
68 |
|
|
x_coord += 80;
|
69 |
|
|
}
|
70 |
|
|
y_coord += 60;
|
71 |
|
|
x_coord = 0;
|
72 |
|
|
}
|
73 |
|
|
ta_wait_no_lpm(WT_500MS);
|
74 |
|
|
ta_wait_no_lpm(WT_500MS);
|
75 |
|
|
|
76 |
|
|
// Initialize LFSR for random color generation
|
77 |
|
|
lfsr = 0xACEB;
|
78 |
|
|
|
79 |
|
|
// Loop the demo
|
80 |
|
|
loop = 0;
|
81 |
|
|
while (loop <4) {
|
82 |
|
|
|
83 |
|
|
// Select rotation & GPU use
|
84 |
|
|
switch(loop & 0x0003) {
|
85 |
|
|
case 0 : DISPLAY_CFG = DST_SWAP_CL; wait_sel = 3;
|
86 |
|
|
break;
|
87 |
|
|
case 1 : DISPLAY_CFG = DST_SWAP_CL; wait_sel = 2;
|
88 |
|
|
break;
|
89 |
|
|
case 2 : DISPLAY_CFG = DST_SWAP_CL; wait_sel = 1;
|
90 |
|
|
break;
|
91 |
|
|
default: DISPLAY_CFG = DST_SWAP_CL; wait_sel = 0;
|
92 |
|
|
break;
|
93 |
|
|
}
|
94 |
|
|
loop++;
|
95 |
|
|
move_to_next_mode = 0;
|
96 |
|
|
|
97 |
|
|
// Move the starting point of the buffer refresh
|
98 |
|
|
DISPLAY_REFR_CNT = 0;
|
99 |
|
|
while (!move_to_next_mode) {
|
100 |
|
|
|
101 |
|
|
// Fill the screen with random colors
|
102 |
|
|
x_coord = 0;
|
103 |
|
|
y_coord = 0;
|
104 |
|
|
for( line = 0; line <4; line = line + 1 ) {
|
105 |
|
|
for( column = 0; column < 4; column = column + 1 ) {
|
106 |
|
|
|
107 |
|
|
// Compute next color from LFSR
|
108 |
|
|
lfsr_lsb = lfsr & 1; /* Get LSB (i.e., the output bit). */
|
109 |
|
|
lfsr >>= 1; /* Shift register */
|
110 |
|
|
lfsr ^= (-lfsr_lsb) & 0xB400u; /* If the output bit is 1, apply toggle mask.
|
111 |
|
|
* The value has 1 at bits corresponding
|
112 |
|
|
* to taps, 0 elsewhere. */
|
113 |
|
|
color = lfsr & 0x000F;
|
114 |
|
|
|
115 |
|
|
// Draw the box
|
116 |
|
|
draw_block(PIX_ADDR(x_coord, y_coord), 77, 57, color, DST_SWAP_NONE, use_gpu);
|
117 |
|
|
x_coord += 80;
|
118 |
|
|
}
|
119 |
|
|
y_coord += 60;
|
120 |
|
|
x_coord = 0;
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
// Wait according to config
|
124 |
|
|
switch(wait_sel) {
|
125 |
|
|
case 0 : while(DISPLAY_REFR_CNT!=0); DISPLAY_REFR_CNT = 2;
|
126 |
|
|
break;
|
127 |
|
|
case 1 : while(DISPLAY_REFR_CNT!=0); DISPLAY_REFR_CNT = 4;
|
128 |
|
|
break;
|
129 |
|
|
case 2 : while(DISPLAY_REFR_CNT!=0); DISPLAY_REFR_CNT = 7;
|
130 |
|
|
break;
|
131 |
|
|
default: while(DISPLAY_REFR_CNT!=0); DISPLAY_REFR_CNT = 10;
|
132 |
|
|
break;
|
133 |
|
|
}
|
134 |
|
|
}
|
135 |
|
|
}
|
136 |
|
|
};
|