MCPcopy Create free account
hub / github.com/CE-Programming/CEmu / panel_buffer_pixels

Function panel_buffer_pixels

core/panel.c:225–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225static 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
275static bool panel_start_line(uint16_t row) {
276 /* Buffer any pixels not yet buffered from the previous line */

Callers 4

panel_start_lineFunction · 0.85
panel_buffer_catchupFunction · 0.85
panel_write_cmdFunction · 0.85
panel_write_paramFunction · 0.85

Calls 3

panel_ram_colFunction · 0.85
panel_bgr_enabledFunction · 0.85
panel_buffer_pixel_chunkFunction · 0.85

Tested by

no test coverage detected