| 223 | } |
| 224 | |
| 225 | static void panel_buffer_pixels(void) { |
| 226 | int32_t nextRamCol = panel.nextRamCol; |
| 227 | int32_t ramCol = panel_ram_col(); |
| 228 | if (ramCol > PANEL_NUM_COLS) { |
| 229 | ramCol = PANEL_NUM_COLS; |
| 230 | } |
| 231 | /* If next RAM access column hasn't been reached, return */ |
| 232 | if (nextRamCol >= ramCol) { |
| 233 | return; |
| 234 | } |
| 235 | uint8_t redShift = panel_bgr_enabled() ? PANEL_DISP_BLUE : PANEL_DISP_RED; |
| 236 | uint8_t (*srcPixel)[3] = &panel.frame[panel.srcRow][nextRamCol >> 1]; |
| 237 | uint32_t *dstPixel = &panel.lineBuffers[panel.currLineBuffer][nextRamCol >> 1]; |
| 238 | if (panel.srcRow < 300) { |
| 239 | /* If the next read column is odd, read offsets 1, 3, 5 in the group of 6 */ |
| 240 | if (nextRamCol & 2) { |
| 241 | panel_buffer_pixel_chunk(srcPixel, dstPixel, redShift); |
| 242 | panel_buffer_pixel_chunk(srcPixel + 2, dstPixel + 2, redShift); |
| 243 | panel_buffer_pixel_chunk(srcPixel + 4, dstPixel + 4, redShift); |
| 244 | srcPixel += 5; |
| 245 | dstPixel += 5; |
| 246 | nextRamCol += 10; |
| 247 | } |
| 248 | /* Read as many full groups of 6 as possible */ |
| 249 | while (nextRamCol + 2 < ramCol) { |
| 250 | panel_buffer_pixel_chunk(srcPixel++, dstPixel++, redShift); |
| 251 | panel_buffer_pixel_chunk(srcPixel++, dstPixel++, redShift); |
| 252 | panel_buffer_pixel_chunk(srcPixel++, dstPixel++, redShift); |
| 253 | panel_buffer_pixel_chunk(srcPixel++, dstPixel++, redShift); |
| 254 | panel_buffer_pixel_chunk(srcPixel++, dstPixel++, redShift); |
| 255 | panel_buffer_pixel_chunk(srcPixel++, dstPixel++, redShift); |
| 256 | nextRamCol += 12; |
| 257 | } |
| 258 | /* The next read column is even, if we reached it then read offsets 0, 2, 4 */ |
| 259 | if (nextRamCol < ramCol) { |
| 260 | panel_buffer_pixel_chunk(srcPixel, dstPixel, redShift); |
| 261 | panel_buffer_pixel_chunk(srcPixel + 2, dstPixel + 2, redShift); |
| 262 | panel_buffer_pixel_chunk(srcPixel + 4, dstPixel + 4, redShift); |
| 263 | nextRamCol += 2; |
| 264 | } |
| 265 | } else { |
| 266 | /* Read every other clock */ |
| 267 | do { |
| 268 | panel_buffer_pixel_chunk(srcPixel++, dstPixel++, redShift); |
| 269 | nextRamCol += 2; |
| 270 | } while (nextRamCol < ramCol); |
| 271 | } |
| 272 | panel.nextRamCol = nextRamCol; |
| 273 | } |
| 274 | |
| 275 | static bool panel_start_line(uint16_t row) { |
| 276 | /* Buffer any pixels not yet buffered from the previous line */ |
no test coverage detected