PicoVGA  1.0-cmake
VGA/TV display on Raspberry Pico
vga.h
Go to the documentation of this file.
1 
8 #ifndef _VGA_H
9 #define _VGA_H
10 
11 // scanline type
12 #define LINE_VSYNC 0 // long vertical sync
13 #define LINE_VVSYNC 1 // short vertical + vertical sync
14 #define LINE_VHSYNC 2 // short vertical + horizontal sync
15 #define LINE_HHSYNC 3 // short horizontal + horizontal sync
16 #define LINE_HVSYNC 4 // short horizontal + vertical sync
17 #define LINE_DARK 5 // dark line
18 #define LINE_IMG 6 // progressive image 0, 1, 2,...
19 #define LINE_IMGEVEN1 7 // interlaced image even 0, 2, 4,..., 1st subframe
20 #define LINE_IMGEVEN2 8 // interlaced image even 0, 2, 4,..., 2nd subframe
21 #define LINE_IMGODD1 9 // interlaced image odd 1, 3, 5,..., 1st subframe
22 #define LINE_IMGODD2 10 // interlaced image odd 1, 3, 5,..., 2nd subframe
23 
24 extern u8 ScanlineType[MAXLINE];
25 
26 extern int DispDev; // current display device
27 extern sVmode CurVmode; // copy of current videomode table
28 //extern int LayerMode; // current layer mode (LAYERMODE_*)
29 extern volatile int ScanLine; // current scan line 1...
30 extern volatile u32 Frame; // frame counter
31 extern volatile int BufInx; // current buffer set (0..1)
32 extern volatile Bool VSync; // current scan line is vsync or dark
33 
34 // line buffers
35 extern ALIGNED u8 LineBuf1[DBUF_MAX]; // scanline 1 image data
36 extern ALIGNED u8 LineBuf2[DBUF_MAX]; // scanline 2 image data
37 extern int LineBufSize[LAYERS_MAX]; // size of data buffers
38 extern u32 LineBufHsBp[4]; // HSYNC ... back porch-1 ... IRQ command ... image command
39 extern u32 LineBufFp; // front porch+1
40 extern u32 LineBufDark[2]; // HSYNC ... dark line
41 extern u32 LineBufSync[10]; // vertical synchronization
42  // interlaced (5x half scanlines):
43  // 2x half synchronization (HSYNC pulse/2 ... line dark/2)
44  // 2x vertical synchronization (invert line dark/2 ... invert HSYNC pulse)
45  // 1x half synchronization (HSYNC pulse/2 ... line dark/2)
46  // progressive: 1x scanline with vertical synchronization (invert line dark ... invert HSYNC pulse)
47 
48 extern ALIGNED u8 LineBuf0[BLACK_MAX]; // line buffer with black color (used to clear rest of scanline)
49 
50 // control buffers
51 extern u32 CtrlBuf1[CBUF_MAX]; // control pairs: u32 count, read address (must be terminated with [0,0])
52 extern u32 CtrlBuf2[CBUF_MAX]; // control pairs: u32 count, read address (must be terminated with [0,0])
53 
54 extern int CtrlBufSize[LAYERS_MAX]; // size of control buffers
55 
56 // render font pixel mask
57 extern u32 RenderTextMask[512];
58 
59 // fill memory buffer with u32 words
60 // buf ... data buffer, must be 32-bit aligned
61 // data ... data word to store
62 // num ... number of 32-bit words (= number of bytes/4)
63 // Returns new destination address.
64 extern "C" u32* MemSet4(u32* buf, u32 data, int num);
65 
66 // blit scanline using key color
67 // dst ... destination buffer
68 // src ... source buffer
69 // w ... width
70 // key ... key color
71 extern "C" void BlitKey(u8* dst, u8* src, int w, u8 key);
72 
73 // render layers with sprites LAYERMODE_SPRITE*
74 // dbuf ... pointer to data buffer
75 // y ... coordinate of scanline
76 // scr ... pointer to layer screen structure sLayer
77 extern "C" void RenderSprite(u8* dbuf, int y, sLayer* scr);
78 
79 // render layers with fast sprites LAYERMODE_FASTSPRITE*
80 // cbuf ... pointer to control buffer
81 // y ... coordinate of scanline
82 // scr ... pointer to layer screen structure sLayer
83 // buf ... pointer to destination data buffer with transparent color
84 // Output new pointer to control buffer.
85 extern "C" u32* RenderFastSprite(u32* cbuf, int y, sLayer* scr, u8* buf);
86 
87 // render layers with transformation matrix LAYERMODE_PERSP*
88 // R0 ... dbuf pointer to data buffer
89 // R1 ... y coordinate of scanline (relative in destination image)
90 // R2 ... scr pointer to layer screen structure sLayer
91 extern "C" void RenderPersp(u8* dbuf, int y, sLayer* scr);
92 
93 // render layers double pixel with transformation matrix LAYERMODE_PERSP2*
94 // R0 ... dbuf pointer to data buffer
95 // R1 ... y coordinate of scanline (relative in destination image)
96 // R2 ... scr pointer to layer screen structure sLayer
97 extern "C" void RenderPersp2(u8* dbuf, int y, sLayer* scr);
98 
99 // render scanline
100 // cbuf ... control buffer
101 // dbuf ... data buffer (pixel data)
102 // line ... current line 0..
103 // pixnum ... total pixels (must be multiple of 4)
104 // Returns new pointer to control buffer
105 extern "C" u32* Render(u32* cbuf, u8* dbuf, int line, int pixnum);
106 
107 // initialize scanline type table
108 void ScanlineTypeInit(const sVmode* v);
109 
110 // print table if scanline types
111 void ScanlineTypePrint(const u8* scan, int lines);
112 
113 // initialize videomode (returns False on bad configuration)
114 // - All layer modes must use same layer program (LAYERMODE_BASE = overlapped layers are OFF)
115 void VgaInit(const sVmode* vmode); //, u8 layer1mode=LAYERMODE_BASE, u8 layer2mode=LAYERMODE_BASE, u8 layer3mode=LAYERMODE_BASE);
116 
129 void StartVgaCore();
130 
142 void VgaInitReq(const sVmode* vmode);
143 
145 
160 void Core1Exec(void (*fnc)());
161 
165 Bool Core1Busy();
166 
170 void Core1Wait();
171 
173 
177 void WaitVSync();
178 
179 #endif // _VGA_H
WaitVSync
void WaitVSync()
Wait for VSync scanline.
Definition: vga.cpp:1101
Core1Busy
Bool Core1Busy()
Check if core 1 is busy executing remote function.
Definition: vga.cpp:1088
StartVgaCore
void StartVgaCore()
Start the VGA processing on core1.
Definition: vga.cpp:1062
Core1Wait
void Core1Wait()
Wait for core 1 finish executing remote function.
Definition: vga.cpp:1095
sLayer
Layer screen descriptor (on change update SLAYER_* in define.h)
Definition: vga_layer.h:195
Core1Exec
void Core1Exec(void(*fnc)())
Execute remote function on second core.
Definition: vga.cpp:1080
VgaInitReq
void VgaInitReq(const sVmode *vmode)
Request to initialize VGA videomode.
Definition: vga.cpp:1071
sVmode
Videomode table - used to setup video driver.
Definition: vga_vmode.h:119