File: screen.h

package info (click to toggle)
memtest86%2B 7.20-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,772 kB
  • sloc: ansic: 22,575; asm: 2,497; makefile: 589; sh: 408
file content (112 lines) | stat: -rw-r--r-- 2,602 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// SPDX-License-Identifier: GPL-2.0
#ifndef SCREEN_H
#define SCREEN_H
/**
 * \file
 *
 * Provides the display interface. It provides an 80x25 VGA-compatible text
 * display.
 *
 *//*
 * Copyright (C) 2020-2024 Martin Whitaker.
 */

#include <stdint.h>

/**
 * Screen size definitions. The screen size cannot be changed.
 */
#define SCREEN_WIDTH    80
#define SCREEN_HEIGHT   25

typedef union {
    struct {
        uint8_t     ch;
        uint8_t     attr;
    };
    struct {
        uint16_t    value;
    };
} vga_char_t;

typedef vga_char_t vga_buffer_t[SCREEN_HEIGHT][SCREEN_WIDTH];

/**
 * Colours that can be used for the foreground or background.
 */
typedef enum {
    BLACK       = 0,
    BLUE        = 1,
    GREEN       = 2,
    CYAN        = 3,
    RED         = 4,
    MAUVE       = 5,
    YELLOW      = 6,
    WHITE       = 7
} screen_colour_t;

/**
 * BIOS/UEFI(GOP) agnostic framebuffer copy
 */

extern vga_buffer_t shadow_buffer;

/**
 * Modifier that can be added to any foreground colour.
 * Has no effect on background colours.
 */
#define BOLD        8

/**
 * Initialise the display interface.
 */
void screen_init(void);

/**
 * Set the foreground colour used for subsequent drawing operations.
 */
void set_foreground_colour(screen_colour_t colour);

/**
 * Set the background colour used for subsequent drawing operations.
 */
void set_background_colour(screen_colour_t colour);

/**
 * Clear the whole screen, using the current background colour.
 */
void clear_screen(void);

/**
 * Clear the specified region of the screen, using the current background
 * colour.
 */
void clear_screen_region(int start_row, int start_col, int end_row, int end_col);

/**
 * Move the contents of the specified region of the screen up one row,
 * discarding the top row, and clearing the bottom row, using the current
 * background colour.
 */
void scroll_screen_region(int start_row, int start_col, int end_row, int end_col);

/**
 * Copy the contents of the specified region of the screen into the supplied
 * buffer.
 */
void save_screen_region(int start_row, int start_col, int end_row, int end_col, uint16_t buffer[]);

/**
 * Restore the specified region of the screen from the supplied buffer.
 * This restores both text and colours.
 */
void restore_screen_region(int start_row, int start_col, int end_row, int end_col, const uint16_t buffer[]);

/**
 * Write the supplied character to the specified screen location, using the
 * current foreground colour. Has no effect if the location is outside the
 * screen.
 */
void print_char(int row, int col, char ch);

#endif // SCREEN_H