2222
2323 // compile options
2424#define VGA_CRT_EFFECT PICO9918_SCANLINES
25- #define VGA_SCANLINE_TIME_DEBUG 0
26- #define VGA_HARDCODED_640 0
27- #define VGA_NO_MALLOC 1
28- #define VGA_COMBINE_SYNC 1
25+ #define VGA_HARDCODED_640 !PICO9918_SCART_RGBS
26+ #define VGA_COMBINE_SYNC PICO9918_SCART_RGBS
2927
28+ #define VGA_NO_MALLOC 1
3029
3130 // a number of compiile-time optimisations can occur
3231 // if it knows some of the VGA parameters
@@ -61,10 +60,16 @@ int roundflt(float x)
6160#define RGB_SM 1 // vga rgb state machine index
6261
6362#define END_OF_SCANLINE_MSG 0x40000000
64- #define END_OF_FRAME_MSG 0x80000000
63+ #define END_OF_FRAME_MSG 0x80000000
6564
65+ #if VGA_COMBINE_SYNC
66+ bi_decl (bi_1pin_with_name (SYNC_PINS_START , "C Sync" ));
67+ bi_decl (bi_1pin_with_name (SYNC_PINS_START + 1 , "C Sync" ));
68+ #else
6669bi_decl (bi_1pin_with_name (SYNC_PINS_START , "H Sync" ));
6770bi_decl (bi_1pin_with_name (SYNC_PINS_START + 1 , "V Sync" ));
71+ #endif
72+
6873bi_decl (bi_pin_mask_with_names (0xf << RGB_PINS_START , "Red (LSB - MSB)" ));
6974bi_decl (bi_pin_mask_with_names (0xf << RGB_PINS_START + 4 , "Green (LSB - MSB)" ));
7075bi_decl (bi_pin_mask_with_names (0xf << RGB_PINS_START + 8 , "Blue (LSB - MSB)" ));
@@ -77,10 +82,10 @@ uint32_t __aligned(4) syncDataPorch[4]; // vertical porch
7782uint32_t __aligned (4 ) syncDataSync [4 ]; // vertical sync
7883
7984#if VGA_NO_MALLOC
80- uint16_t __aligned (4 ) rgbDataBuffer [2 + VGA_SCANLINE_TIME_DEBUG ][640 * sizeof (uint16_t )] = { 0 }; // two scanline buffers (odd and even)
85+ uint16_t __aligned (4 ) rgbDataBuffer [2 ][640 * sizeof (uint16_t )] = { 0 }; // two scanline buffers (odd and even)
8186#else
8287#include <stdlib.h>
83- uint16_t * __aligned (4 ) rgbDataBuffer [2 + VGA_SCANLINE_TIME_DEBUG ] = { 0 }; // two scanline buffers (odd and even)
88+ uint16_t * __aligned (4 ) rgbDataBuffer [2 ] = { 0 }; // two scanline buffers (odd and even)
8489#endif
8590
8691
@@ -93,11 +98,6 @@ static uint syncDmaChanMask = 0;
9398static uint rgbDmaChanMask = 0 ;
9499static VgaInitParams vgaParams = { 0 };
95100
96- #if VGA_SCANLINE_TIME_DEBUG
97- bool hasRenderedNext = false;
98- #endif
99-
100-
101101uint32_t vgaMinimumPioClockKHz (VgaParams * params )
102102{
103103 if (params )
@@ -130,15 +130,6 @@ static bool buildSyncData()
130130 rgbDataBuffer [1 ] = malloc (VIRTUAL_PIXELS_X * sizeof (uint16_t ));
131131#endif
132132
133- #if VGA_SCANLINE_TIME_DEBUG
134- #if !VGA_NO_MALLOC
135- rgbDataBuffer [2 ] = malloc (VIRTUAL_PIXELS_X * sizeof (uint16_t ));
136- #endif
137-
138- for (int i = 0 ; i < VIRTUAL_PIXELS_X ; ++ i )
139- rgbDataBuffer [2 ][i ] = 0x0f00 ;
140- #endif
141-
142133 vgaParams .params .pioDivider = roundflt (sysClockKHz / (float )minClockKHz );
143134 vgaParams .params .pioFreqKHz = sysClockKHz / vgaParams .params .pioDivider ;
144135
@@ -361,15 +352,6 @@ static void __isr __time_critical_func(dmaIrqHandler)(void)
361352 }
362353#endif
363354
364- #if VGA_SCANLINE_TIME_DEBUG
365- // apply a few darkened values before passing to dma
366- if (pxLineRpt != 0 && hasRenderedNext )
367- {
368- currentBuffer = (uint32_t * )rgbDataBuffer [2 ];
369- }
370- #endif
371-
372-
373355 dma_channel_set_read_addr (rgbDmaChan , currentBuffer , true);
374356
375357 // need a new line every X display lines
@@ -380,9 +362,6 @@ static void __isr __time_critical_func(dmaIrqHandler)(void)
380362
381363 multicore_fifo_push_timeout_us (requestLine , 0 );
382364
383- #if VGA_SCANLINE_TIME_DEBUG
384- hasRenderedNext = false;
385- #endif
386365 if (requestLine == VIRTUAL_PIXELS_Y - 1 )
387366 {
388367 multicore_fifo_push_timeout_us (END_OF_FRAME_MSG , 0 );
@@ -449,10 +428,6 @@ void __time_critical_func(vgaLoop)()
449428 {
450429 // get the next scanline pixels
451430 vgaParams .scanlineFn (message & 0xfff , & vgaParams .params , rgbDataBuffer [message & 0x01 ]);
452- #if VGA_SCANLINE_TIME_DEBUG
453- dma_channel_set_read_addr (rgbDmaChan , rgbDataBuffer [2 ], true);
454- hasRenderedNext = true;
455- #endif
456431 }
457432 }
458433}
0 commit comments