OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [altera_de0_nano_soc/] [software/] [apps/] [gfx_demo/] [demo_2bpp.c] - Blame information for rev 221

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.