2025-06-29 05:13:43 +00:00
|
|
|
/* vga.h
|
|
|
|
|
* VGA
|
2025-06-10 13:17:21 +00:00
|
|
|
*
|
2025-06-29 05:13:43 +00:00
|
|
|
* 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-06-08 20:18:06 +00:00
|
|
|
#define VGA_GRID_COLS 80
|
2025-05-29 03:19:50 +00:00
|
|
|
#define VGA_GRID_ROWS 25
|
2025-07-03 05:36:47 +00:00
|
|
|
#define DEFAULT_ATTRIBUTES 0x0F00
|
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
|
|
|
/*
|
|
|
|
|
* CONSTANTS AND VARIABLES
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//Information on the VGA buffer
|
|
|
|
|
extern volatile uint16_t* const vga_buffer;
|
|
|
|
|
|
2025-07-03 05:36:47 +00:00
|
|
|
typedef struct vga_ctx_s {
|
|
|
|
|
int cursor_col;
|
|
|
|
|
int cursor_row;
|
|
|
|
|
uint16_t attributes;
|
|
|
|
|
} vga_ctx_t;
|
|
|
|
|
|
2025-05-29 03:19:50 +00:00
|
|
|
//grid is top left origin. This is our cursor!
|
|
|
|
|
extern uint16_t vga_attributes; // Black background, White foreground
|
2025-07-03 05:36:47 +00:00
|
|
|
extern char_writer_t* default_vga;
|
2025-05-29 03:19:50 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Functions
|
|
|
|
|
*/
|
|
|
|
|
|
2025-07-03 05:36:47 +00:00
|
|
|
//Clear the VGA buffer, context optional
|
|
|
|
|
void vga_clear_ctx(vga_ctx_t* ctx);
|
2025-05-29 03:19:50 +00:00
|
|
|
void vga_clear();
|
2025-06-29 05:13:43 +00:00
|
|
|
//Write character c to cursor
|
|
|
|
|
//Implements IO generic ASCII output
|
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
|