summaryrefslogtreecommitdiff
path: root/src/drivers/video/video.h
blob: 8cfebb3d82c86219b7373d940b886402d36e0268 (plain)
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
#ifndef VIDEO_H
#define VIDEO_H

#include "driver.h"

#include <stdbool.h>

typedef enum {
	VIDEO_MODE_TYPE_TEXT,
	VIDEO_MODE_TYPE_GRAPHICS
} video_mode_type_t;

#define MAX_NOF_VIDEO_MODES 255

typedef struct {
	video_mode_type_t mode_type;
	int x;
	int y;
	int color_depth;
} video_mode_t;

typedef struct {
	driver_t base;
	unsigned int nof_modes;
	const video_mode_t *modes[MAX_NOF_VIDEO_MODES];
	const video_mode_t *mode;
} video_t;

typedef struct {
	int R;
	int G;
	int B;
} video_rgb_color_t;

typedef struct {
	driver_vtable_t base;
	void (*register_mode)( void *obj, const video_mode_t *mode );
	bool (*supports_mode)( void *obj, const video_mode_t mode );
	bool (*set_mode)( void *obj, const video_mode_t mode );
	bool (*switch_mode)( void *obj, const video_mode_t *mode );
	void (*set_pixel)( void *obj, const int x, const int y, const video_rgb_color_t color );
	void (*draw_rectangle)( void *obj, const int x, const int y, const int w, const int h, const video_rgb_color_t color );
	void (*clear_screen)( void *obj, const video_rgb_color_t color );
	void (*draw_char)( void *obj, const unsigned char c, const int x, const int y, const video_rgb_color_t background, const video_rgb_color_t foreground );
	void (*wait_for_retrace)( void *obj );
	void (*use_z_buffer)( void *obj, bool use );
	void (*refresh)( void *obj );
} video_vtable_t;

void video_init( video_t *video, interrupt_t *interrupt, void *context );
void video_activate( void *obj );
void video_deactivate( void *obj );
void video_deinit( void *obj );
void video_print_info( void *obj );

video_mode_t video_make_mode( const video_mode_type_t mode_type, const int x, const int y, const int color_depth );

void video_register_mode( void *obj, const video_mode_t *mode );
bool video_supports_mode( void *obj, const video_mode_t mode );
bool video_set_mode( void *obj, const video_mode_t mode );
bool video_switch_mode( void *obj, const video_mode_t *mode );

extern const video_rgb_color_t VIDEO_RGB_COLOR_BLACK;
extern const video_rgb_color_t VIDEO_RGB_COLOR_BLUE;
extern const video_rgb_color_t VIDEO_RGB_COLOR_GREEN;
extern const video_rgb_color_t VIDEO_RGB_COLOR_CYAN;
extern const video_rgb_color_t VIDEO_RGB_COLOR_RED;
extern const video_rgb_color_t VIDEO_RGB_COLOR_MAGENTA;
extern const video_rgb_color_t VIDEO_RGB_COLOR_BROWN;
extern const video_rgb_color_t VIDEO_RGB_COLOR_GRAY;
extern const video_rgb_color_t VIDEO_RGB_COLOR_WHITE;

video_rgb_color_t video_make_rgb_color( const int R, const int G, const int B );

void video_set_pixel( void *obj, const int x, const int y, const video_rgb_color_t color );
void video_draw_rectangle( void *obj, const int x, const int y, const int w, const int h, const video_rgb_color_t color );
void video_clear_screen( void *obj, const video_rgb_color_t color );
void video_draw_char( void *obj, const unsigned char c, const int x, const int y, const video_rgb_color_t background, const video_rgb_color_t foreground );
void video_wait_for_retrace( void *obj );
void video_use_z_buffer( void *obj, bool use );
void video_refresh( void *obj );

#endif // VIDEO_H