Instead of passing function pointers, we're passing structs with context now. The idea is the same, I/O functions require some struct with a function pointer and some generic memory that only the output device cares about. I/O just calls it. VGA has been reworked to accomodate this change, as well as default outputs being created for low-overhead use (such as interrupt handlers).
43 lines
829 B
C
43 lines
829 B
C
/* vga.h
|
|
* VGA
|
|
*
|
|
* Responsible for VGA buffer control.
|
|
*/
|
|
#ifndef VGA_H
|
|
#define VGA_H
|
|
#define VGA_GRID_COLS 80
|
|
#define VGA_GRID_ROWS 25
|
|
#define DEFAULT_ATTRIBUTES 0x0F00
|
|
#include <stdint.h>
|
|
#include <stdarg.h>
|
|
#include "io.h"
|
|
/*
|
|
* CONSTANTS AND VARIABLES
|
|
*/
|
|
|
|
//Information on the VGA buffer
|
|
extern volatile uint16_t* const vga_buffer;
|
|
|
|
typedef struct vga_ctx_s {
|
|
int cursor_col;
|
|
int cursor_row;
|
|
uint16_t attributes;
|
|
} vga_ctx_t;
|
|
|
|
//grid is top left origin. This is our cursor!
|
|
extern uint16_t vga_attributes; // Black background, White foreground
|
|
extern char_writer_t* default_vga;
|
|
|
|
/*
|
|
* Functions
|
|
*/
|
|
|
|
//Clear the VGA buffer, context optional
|
|
void vga_clear_ctx(vga_ctx_t* ctx);
|
|
void vga_clear();
|
|
//Write character c to cursor
|
|
//Implements IO generic ASCII output
|
|
int vga_out(void* ctx, char c);
|
|
|
|
|
|
#endif
|