PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
tv.c
Go to the documentation of this file.
1 
6 #include <stdint.h>
7 #include <string.h>
8 #include <propeller.h>
9 #include "tv.h"
10 
11 static int gcog;
12 
13 #if defined(__PROPELLER_XMM__)
14 HUBDATA uint32_t pasm[496];
15 #endif
16 
17 int TV_start(TV_t* tvp)
18 {
19  extern uint32_t binary_TV_dat_start[];
20 #if defined(__PROPELLER_XMM__)
21  extern uint32_t binary_TV_dat_end[];
22  int size = (binary_TV_dat_end - binary_TV_dat_start);
23  memcpy(pasm, binary_TV_dat_start, size*4);
24  gcog = cognew(pasm, tvp) + 1;
25 #else
26  gcog = cognew(binary_TV_dat_start, tvp) + 1;
27 #endif
28  return gcog;
29 }
30 
31 #ifdef TVTEST
32 
33 #define X_TILES 10 // 44
34 #define Y_TILES 10 // 14
35 
36 #define TV_TEXT_COLORTABLE_SIZE 64 // 8*2
37 
38 HUBDATA TV_t gTV;
39 
40 HUBDATA volatile uint16_t gScreen[X_TILES * Y_TILES];
41 HUBDATA volatile uint32_t gColors[TV_TEXT_COLORTABLE_SIZE];
42 HUBDATA volatile uint8_t gpalette[TV_TEXT_COLORTABLE_SIZE] =
43 { // fgRGB bgRGB
44  0x07, 0x0a, // 0 white / dark blue
45  0x07, 0xbb, // 1 yellow / brown
46  0x9e, 0x9b, // 2 magenta / black
47  0x04, 0x07, // 3 grey / white
48  0x3d, 0x3b, // 4 cyan / dark cyan
49  0x6b, 0x6e, // 5 green / gray-green
50  0xbb, 0xce, // 6 red / pink
51  0x3e, 0x0a // 7 cyan / blue
52 };
53 
54 static void setColorPalette(volatile uint8_t* ptr)
55 {
56  int ii = 0;
57  int mm = 0;
58  int fg = 0;
59  int bg = 0;
60  for(ii = 0; ii < TV_TEXT_COLORTABLE_SIZE; ii += 2)
61  {
62  mm = ii + 1; // beta1 ICC has trouble with math in braces. use mm
63  fg = ptr[ii] << 0;
64  bg = ptr[mm] << 0;
65  gColors[ii] = (fg << 24) | (bg << 16) | (fg << 8) | bg;
66  gColors[mm] = (fg << 24) | (fg << 16) | (bg << 8) | bg;
67  }
68 }
69 
70 int main(void)
71 {
72  int dx, dy;
73 
74  gTV.enable = 1;
75  gTV.pins = TV_BASEBAND_PIN(12);
76  gTV.mode = 0; //0x12;
77  gTV.screen = (uint32_t) &gScreen[0];
78  gTV.colors = (uint32_t) &gColors[0];
79  gTV.ht = X_TILES;
80  gTV.vt = Y_TILES;
81  gTV.hx = 10; // 4 if ht=44, vt=14
82  gTV.vx = 1;
83  gTV.ho = 0;
84  gTV.vo = 0;
85  gTV.broadcast = 0;
86  gTV.auralcog = 0;
87 
88  TV_start(&gTV);
89  setColorPalette(&gpalette[0]);
90 
91  // tile screen
92  for (dx = 0; dx < gTV.ht; dx++)
93  for (dy = 0; dy < gTV.vt; dy++)
94  gScreen[dy * gTV.ht + dx] = (0x6000 >> 6) + dy + dx * gTV.vt + ((dy & 0x3F) << 10);
95 
96  return 0;
97 }
98 #endif
99 
100 /*
101 +--------------------------------------------------------------------
102 | TERMS OF USE: MIT License
103 +--------------------------------------------------------------------
104 Permission is hereby granted, free of charge, to any person obtaining
105 a copy of this software and associated documentation files
106 (the "Software"), to deal in the Software without restriction,
107 including without limitation the rights to use, copy, modify, merge,
108 publish, distribute, sublicense, and/or sell copies of the Software,
109 and to permit persons to whom the Software is furnished to do so,
110 subject to the following conditions:
111 
112 The above copyright notice and this permission notice shall be
113 included in all copies or substantial portions of the Software.
114 
115 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
116 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
117 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
118 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
119 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
120 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
121 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
122 +------------------------------------------------------------------
123 */
cognew
#define cognew(code, param)
Start a new Propeller PASM COG.
Definition: propeller.h:94
main
int main(void)
Definition: GraphicsTest.c:20
TV_start
int TV_start(TV_t *tvp)
Definition: tv.c:17
HUBDATA
#define HUBDATA
HUBDATA tells compiler to put data into HUB RAM section. This is mostly useful in XMM modes where dat...
Definition: propeller.h:32
tv.h
TV_t
volatile struct TV_struct TV_t
TV_BASEBAND_PIN
#define TV_BASEBAND_PIN(pin)
Definition: tv.h:35