@@ -83,6 +83,8 @@ bool audioRepeats; // should this stream repeat?
8383
8484JsSysTime videoFrameTime ;
8585JsSysTime videoNextFrameTime ;
86+ static uint16_t blitRowA [480 ];
87+ static uint16_t blitRowB [480 ];
8688bool debugInfo = false;
8789int startX = 0 ;
8890int startY = 0 ;
@@ -2025,6 +2027,8 @@ void jswrap_pb_blitScreen(JsVar *image, JsVar *options) {
20252027 yoffset += 320 ; // to avoid negative values
20262028 lcdFSMC_blitStart (gfx , 0 ,y1 , 480 ,y2 + 1 - y1 );
20272029 for (int y = y1 ;y <=y2 ;y ++ ) {
2030+ uint16_t * rowBuf = (y & 1 ) ? blitRowB : blitRowA ; // double buffer selection
2031+
20282032 // work out row pointers
20292033 row1 = & imgPtr [((y + yoffset - ydiff )%320 )* 120 ]; // 480 pixels, 2bpp = 120 bytes per row
20302034 row2 = & imgPtr [((y + yoffset )%320 )* 120 ]; // 480 pixels, 2bpp = 120 bytes per row
@@ -2033,19 +2037,20 @@ void jswrap_pb_blitScreen(JsVar *image, JsVar *options) {
20332037
20342038 uint32_t pixels = 0 ;
20352039 uint8_t pixelUp , pixelDn ;
2040+ int p = 0 ; // index into DMA row buffer
2041+ #define BLITPIXEL \
2042+ filterResult32 = (pixels&mulx1) + ((pixels&mulx2)<<1); /* Apply 8x 2bit filter */ \
2043+ filterResult32 = (filterResult32 & 0x0F0F0F0F ) + ((filterResult32 >>4 )& 0x0F0F0F0F ) ; /* Merge each nibble, now we have 8 bits to play with */ \
2044+ filterResult32 = filterResult32 + (filterResult32 >>8 ); \
2045+ filterResult32 = (filterResult32 + (filterResult32 >>16 )) & 255 ; \
2046+ filterResult32 = ((((pixelUp + pixelDn )<<1 ) + filterResult32 )* 3 )>>3 ; /* blur upper and lower lines */ \
2047+ if (filterResult32 > 15 ) filterResult32 = 15 ; \
2048+ rowBuf [p ++ ] = palette [filterResult32 ];
20362049 for (int x = 0 ;x < 120 ;x ++ ) {
20372050 uint8_t p4up = * (row1 ++ );
20382051 uint8_t p4 = * (row2 ++ );
20392052 uint8_t p4dn = * (row3 ++ );
20402053 uint32_t filterResult32 ;
2041- #define BLITPIXEL \
2042- filterResult32 = (pixels&mulx1) + ((pixels&mulx2)<<1); /* Apply 8x 2bit filter */ \
2043- filterResult32 = (filterResult32 & 0x0F0F0F0F ) + ((filterResult32 >>4 )& 0x0F0F0F0F ) ; /* Merge each nibble, now we have 8 bits to play with */ \
2044- filterResult32 = filterResult32 + (filterResult32 >>8 ); \
2045- filterResult32 = (filterResult32 + (filterResult32 >>16 )) & 255 ; \
2046- filterResult32 = ((((pixelUp + pixelDn )<<1 ) + filterResult32 )* 3 )>>3 ; /* blur upper and lower lines */ \
2047- if (filterResult32 > 15 ) filterResult32 = 15 ; \
2048- lcdFSMC_blitPixel (palette [filterResult32 ]);
20492054 pixelUp = (p4up >>5 );
20502055 pixelDn = (p4dn >>5 );
20512056 pixels = (pixels <<4 ) | (p4 >>6 );
@@ -2064,7 +2069,10 @@ void jswrap_pb_blitScreen(JsVar *image, JsVar *options) {
20642069 BLITPIXEL
20652070 #undef BLITPIXEL
20662071 }
2072+ if (y != y1 ) lcdFSMC_dmaWait ();
2073+ lcdFSMC_dmaStart (rowBuf , 480 );
20672074 }
2075+ lcdFSMC_dmaWait ();
20682076 lcdFSMC_blitEnd ();
20692077 _jswrap_graphics_freeImageInfo (& img );
20702078}
0 commit comments