2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @file vga.h
|
|
|
|
|
* @brief VGA
|
|
|
|
|
* @details Responsible for VGA buffer control.
|
2025-06-10 13:17:21 +00:00
|
|
|
*/
|
2025-06-29 05:13:43 +00:00
|
|
|
#ifndef VGA_H
|
|
|
|
|
#define VGA_H
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
*/
|
2025-06-08 20:18:06 +00:00
|
|
|
#define VGA_GRID_COLS 80
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
*/
|
2025-05-29 03:19:50 +00:00
|
|
|
#define VGA_GRID_ROWS 25
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
*/
|
2025-07-03 05:36:47 +00:00
|
|
|
#define DEFAULT_ATTRIBUTES 0x0F00
|
2025-07-17 11:36:45 +00:00
|
|
|
|
2025-05-29 03:19:50 +00:00
|
|
|
#include <stdint.h>
|
2025-06-08 20:18:06 +00:00
|
|
|
#include <stdarg.h>
|
2025-07-03 05:36:47 +00:00
|
|
|
#include "io.h"
|
2025-05-29 03:19:50 +00:00
|
|
|
|
2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @brief Information on the VGA buffer
|
|
|
|
|
*/
|
2025-05-29 03:19:50 +00:00
|
|
|
extern volatile uint16_t* const vga_buffer;
|
|
|
|
|
|
2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
*/
|
2025-07-03 05:36:47 +00:00
|
|
|
typedef struct vga_ctx_s {
|
2025-07-17 11:36:45 +00:00
|
|
|
int cursor_col; /**< @brief */
|
|
|
|
|
int cursor_row; /**< @brief */
|
|
|
|
|
uint16_t attributes; /**< @brief */
|
2025-07-03 05:36:47 +00:00
|
|
|
} vga_ctx_t;
|
|
|
|
|
|
2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @brief grid is top left origin. This is our cursor! Black background, White foreground
|
|
|
|
|
*/
|
|
|
|
|
extern uint16_t vga_attributes;
|
2025-05-29 03:19:50 +00:00
|
|
|
|
2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @brief
|
2025-05-29 03:19:50 +00:00
|
|
|
*/
|
2025-07-17 11:36:45 +00:00
|
|
|
extern char_writer_t* default_vga;
|
2025-05-29 03:19:50 +00:00
|
|
|
|
2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @brief Clear the VGA buffer, context optional
|
|
|
|
|
* @param ctx
|
|
|
|
|
*/
|
2025-07-03 05:36:47 +00:00
|
|
|
void vga_clear_ctx(vga_ctx_t* ctx);
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
*/
|
2025-05-29 03:19:50 +00:00
|
|
|
void vga_clear();
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Write character c to cursor. Implements IO generic ASCII output
|
|
|
|
|
* @param ctx
|
|
|
|
|
* @param c
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
2025-07-03 05:36:47 +00:00
|
|
|
int vga_out(void* ctx, char c);
|
2025-06-29 05:13:43 +00:00
|
|
|
|
2025-05-29 03:19:50 +00:00
|
|
|
|
|
|
|
|
#endif
|