vga/README.md

43 lines
1.5 KiB
Markdown
Raw Permalink Normal View History

2020-03-16 19:21:39 -05:00
[![Build Status](https://github.com/rust-osdev/vga/workflows/Build/badge.svg)](https://github.com/rust-osdev/vga/actions?query=workflow%3ABuild) [![Docs.rs Badge](https://docs.rs/vga/badge.svg)](https://docs.rs/vga/)
2020-03-12 17:23:40 -05:00
# vga
This crate provides vga specific functions, data structures,
and access to various registers.
Memory addresses `0xA0000 -> 0xBFFFF` must be readable and writeable
this crate to work properly.
2020-03-12 17:40:53 -05:00
**Note: This crate is currently experimental and subject to change since it's in active development.**
2020-03-24 17:54:09 -05:00
## Text Mode
2020-03-12 17:40:53 -05:00
```rust
2020-03-24 16:17:13 -05:00
use vga::colors::{Color16, TextModeColor};
use vga::writers::{ScreenCharacter, TextWriter, Text80x25};
2020-03-12 17:40:53 -05:00
let text_mode = Text80x25::new();
2020-03-24 16:17:13 -05:00
let color = TextModeColor::new(Color16::Yellow, Color16::Black);
2020-03-19 10:24:22 -05:00
let screen_character = ScreenCharacter::new(b'T', color);
2020-03-12 17:40:53 -05:00
text_mode.set_mode();
text_mode.clear_screen();
text_mode.write_character(0, 0, screen_character);
2020-03-12 17:40:53 -05:00
```
2020-03-24 17:54:09 -05:00
## Graphics Mode
```rust
use vga::colors::Color16;
use vga::writers::{Graphics640x480x16, GraphicsWriter};
let mode = Graphics640x480x16::new();
mode.set_mode();
mode.clear_screen(Color16::Black);
mode.draw_line((80, 60), (80, 420), Color16::White);
mode.draw_line((80, 60), (540, 60), Color16::White);
mode.draw_line((80, 420), (540, 420), Color16::White);
mode.draw_line((540, 420), (540, 60), Color16::White);
mode.draw_line((80, 90), (540, 90), Color16::White);
for (offset, character) in "Hello World!".chars().enumerate() {
mode.draw_character(270 + offset * 8, 72, character, Color16::White)
}
```