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

Subversion Repositories openmsp430

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

powered by: WebSVN 2.1.0

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