MCPcopy Create free account
hub / github.com/NetHack/NetHack / vesa_FillRect

Function vesa_FillRect

sys/msdos/vidvesa.c:497–539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495}
496
497static void
498vesa_FillRect(unsigned left, unsigned top, unsigned width,
499 unsigned height, unsigned color)
500{
501 unsigned p_row_size = width * vesa_pixel_bytes;
502 unsigned char *p_row = (unsigned char *) alloc(p_row_size);
503 unsigned long c32 = vesa_palette[color & 0xFF];
504 unsigned long offset = top * (unsigned long)vesa_scan_line + left * vesa_pixel_bytes;
505 unsigned x, y;
506
507 switch (vesa_pixel_bytes) {
508 case 1:
509 memset(p_row, color, p_row_size);
510 break;
511
512 case 2:
513 for (x = 0; x < width; ++x) {
514 ((uint16_t *)p_row)[x] = c32;
515 }
516 break;
517
518 case 3:
519 for (x = 0; x < width; ++x) {
520 p_row[3*x + 0] = c32 & 0xFF;
521 p_row[3*x + 1] = (c32 >> 8) & 0xFF;
522 p_row[3*x + 2] = c32 >> 16 ;
523 }
524 break;
525
526 case 4:
527 for (x = 0; x < width; ++x) {
528 ((uint32_t *)p_row)[x] = c32;
529 }
530 break;
531 }
532
533 for (y = 0; y < height; ++y) {
534 vesa_WritePixelRow(offset, p_row, p_row_size);
535 offset += vesa_scan_line;
536 }
537
538 free(p_row);
539}
540
541void
542vesa_get_scr_size(void)

Callers 5

vesa_clear_screenFunction · 0.85
vesa_cl_endFunction · 0.85
vesa_cl_eosFunction · 0.85
vesa_redrawmapFunction · 0.85
positionbarFunction · 0.85

Calls 2

vesa_WritePixelRowFunction · 0.85
allocFunction · 0.50

Tested by

no test coverage detected