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

Subversion Repositories openmsp430

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

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

powered by: WebSVN 2.1.0

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