Max OS 0.3
Loading...
Searching...
No Matches
MaxOS::drivers::video::VideoGraphicsArray Class Reference

Driver for the VGA graphics controller, handles the rendering of pixels to the screen. More...

#include <vga.h>

Inheritance diagram for MaxOS::drivers::video::VideoGraphicsArray:
MaxOS::drivers::video::VideoDriver MaxOS::drivers::Driver MaxOS::common::GraphicsContext

Public Member Functions

 VideoGraphicsArray ()
 Constructs a new Video Graphics Array (VGA) driver object, initializing the necessary I/O ports for VGA register access.
 
string vendor_name () final
 Gets the name of the vendor.
 
string device_name () final
 Gets the name of the device.
 
bool supports_mode (uint32_t width, uint32_t height, uint32_t colour_depth) final
 Checks if the specified resolution is supported.
 
- Public Member Functions inherited from MaxOS::drivers::video::VideoDriver
bool set_mode (uint32_t width, uint32_t height, uint32_t color_depth)
 Set the mode of the video driver.
 
- Public Member Functions inherited from MaxOS::drivers::Driver
virtual void activate ()
 Activate the driver.
 
virtual void deactivate ()
 Deactivate the driver.
 
virtual void initialise ()
 Initialise the driver.
 
virtual uint32_t reset ()
 Reset the driver.
 
- Public Member Functions inherited from MaxOS::common::GraphicsContext
 GraphicsContext ()
 Constructs a GraphicsContext object and initializes the color palette.
 
uint32_t colour_to_int (const Colour &)
 Converts a colour to an integer value based on the current color depth.
 
Colour int_to_colour (uint32_t)
 Converts an integer value to a colour based on the current color depth.
 
uint32_t width () const
 Gets the width of the screen.
 
uint32_t height () const
 Gets the height of the screen.
 
uint32_t color_depth () const
 Gets the current color depth (bits per pixel)
 
uint64_tframebuffer_address ()
 Gets the address of the context's framebuffer to draw on.
 
void put_pixel (uint32_t x, uint32_t y, const Colour &colour)
 Renders a pixel to the screen (automatically converts the colour to an integer)
 
void put_pixel (uint32_t x, uint32_t y, uint32_t colour)
 Renders a pixel to the screen (automatically converts the colour to an integer), will not render the pixel if it is outside the screen.
 
Colour get_pixel (uint32_t x, uint32_t y)
 Gets the colour of a pixel, or returns black if the pixel is outside the screen.
 
void invert_pixel (uint32_t x, uint32_t y)
 Inverts a pixel.
 
void draw_line (uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour &colour)
 Draws a line on the screen.
 
void draw_line (uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t colour)
 Draws a line on the screen.
 
void draw_rectangle (uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour &colour)
 Draws a rectangle on the screen.
 
void draw_rectangle (uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t colour)
 Draws a rectangle on the screen.
 
void fill_rectangle (uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour &colour)
 Draws a rectangle on the screen, filled with a colour.
 
void fill_rectangle (uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t colour)
 Draws a rectangle on the screen, filled with a colour.
 
void draw_circle (uint32_t x0, uint32_t y0, uint32_t radius, const Colour &colour)
 Draws a circle on the screen.
 
void draw_circle (uint32_t x0, uint32_t y0, uint32_t radius, uint32_t colour)
 Draws a circle on the screen.
 
void fill_circle (uint32_t x0, uint32_t y0, uint32_t radius, const Colour &colour)
 Draws a circle on the screen, filled with a colour.
 
void fill_circle (uint32_t x0, uint32_t y0, uint32_t radius, uint32_t colour)
 Draws a circle on the screen, filled with a colour.
 

Additional Inherited Members

- Protected Member Functions inherited from MaxOS::common::GraphicsContext
virtual void render_pixel (uint32_t x, uint32_t y, uint32_t colour)
 Renders a pixel to the screen based on the current color depth.
 
virtual void render_pixel_16_bit (uint32_t x, uint32_t y, uint16_t colour)
 Renders a pixel to the screen using the 16 bit color depth.
 
virtual void render_pixel_24_bit (uint32_t x, uint32_t y, uint32_t colour)
 Renders a pixel to the screen using the 24 bit color depth.
 
virtual void render_pixel_32_bit (uint32_t x, uint32_t y, uint32_t colour)
 Renders a pixel to the screen using the 32 bit color depth.
 
virtual uint32_t get_rendered_pixel (uint32_t x, uint32_t y)
 Gets the colour of a pixel on the screen, automatically uses the correct color depth.
 
virtual uint16_t get_rendered_pixel_16_bit (uint32_t x, uint32_t y)
 Gets the colour of a pixel on the screen using the 16 bit color depth.
 
virtual uint32_t get_rendered_pixel_24_bit (uint32_t x, uint32_t y)
 Gets the colour of a pixel on the screen using the 24 bit color depth.
 
virtual uint32_t get_rendered_pixel_32_bit (uint32_t x, uint32_t y)
 Gets the colour of a pixel on the screen using the 32 bit color depth.
 
- Protected Attributes inherited from MaxOS::common::GraphicsContext
bool mirror_y_axis
 Should the y axis be mirrored (0,0 is top left if false, bottom left if true)
 
uint32_t m_width { 0 }
 The width of the screen in pixels.
 
uint32_t m_height { 0 }
 The height of the screen in pixels.
 
uint32_t m_color_depth { 0 }
 The color depth of the screen in bits per pixel.
 
Colour m_colour_pallet [256]
 The colour pallet for 8 bit color depth.
 
uint64_tm_framebuffer_address { nullptr }
 The address of the framebuffer.
 

Detailed Description

Driver for the VGA graphics controller, handles the rendering of pixels to the screen.

Definition at line 28 of file vga.h.

Constructor & Destructor Documentation

◆ VideoGraphicsArray()

VideoGraphicsArray::VideoGraphicsArray ( )

Constructs a new Video Graphics Array (VGA) driver object, initializing the necessary I/O ports for VGA register access.

Definition at line 22 of file vga.cpp.

23: m_misc_port(0x3C2),
24 m_crtc_index_port(0x3D4),
25 crtc_data_port(0x3D5),
26 m_sequence_index_port(0x3C4),
27 m_sequence_data_port(0x3C5),
28 m_graphics_controller_index_port(0x3CE),
29 m_graphics_controller_data_port(0x3CF),
30 m_attribute_controller_index_port(0x3C0),
31 m_attribute_controller_read_port(0x3C1),
32 m_attribute_controller_write_port(0x3C0),
33 m_attribute_controller_reset_port(0x3DA)
34{
35}

Member Function Documentation

◆ device_name()

string VideoGraphicsArray::device_name ( )
finalvirtual

Gets the name of the device.

Returns
The name of the device.

Reimplemented from MaxOS::drivers::Driver.

Definition at line 208 of file vga.cpp.

208 {
209 return "VGA compatible graphics card";
210}

◆ supports_mode()

bool VideoGraphicsArray::supports_mode ( uint32_t  width,
uint32_t  height,
uint32_t  colour_depth 
)
finalvirtual

Checks if the specified resolution is supported.

Parameters
widthThe width of the resolution.
heightThe height of the resolution.
colour_depthThe byte depth of the resolution.
Returns
True if the specified resolution is supported, otherwise false.

Reimplemented from MaxOS::drivers::video::VideoDriver.

Definition at line 98 of file vga.cpp.

98 {
99 return width == 320 && height == 200 && colour_depth == 8;
100}
uint32_t width() const
Gets the width of the screen.
uint32_t height() const
Gets the height of the screen.

References MaxOS::common::GraphicsContext::height(), and MaxOS::common::GraphicsContext::width().

◆ vendor_name()

string VideoGraphicsArray::vendor_name ( )
finalvirtual

Gets the name of the vendor.

Returns
The name of the vendor.

Reimplemented from MaxOS::drivers::Driver.

Definition at line 197 of file vga.cpp.

197 {
198
199 // VGA was made by IBM
200 return "IBM";
201}

The documentation for this class was generated from the following files: