Compare commits
No commits in common. "master" and "update-testing" have entirely different histories.
master
...
update-tes
24
Cargo.toml
24
Cargo.toml
|
@ -1,12 +1,17 @@
|
||||||
[package]
|
[package]
|
||||||
name = "vga"
|
name = "vga"
|
||||||
version = "0.2.7"
|
version = "0.2.6"
|
||||||
authors = ["Ryan Kennedy <rkennedy9064@gmail.com>"]
|
authors = ["Ryan Kennedy <rkennedy9064@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Support for vga specific functions, data structures, and registers."
|
description = "Support for vga specific functions, data structures, and registers."
|
||||||
documentation = "https://docs.rs/vga"
|
documentation = "https://docs.rs/vga"
|
||||||
keywords = ["vga", "no_std"]
|
keywords = [
|
||||||
categories = ["no-std"]
|
"vga",
|
||||||
|
"no_std",
|
||||||
|
]
|
||||||
|
categories = [
|
||||||
|
"no-std",
|
||||||
|
]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/rust-osdev/vga"
|
repository = "https://github.com/rust-osdev/vga"
|
||||||
|
@ -15,20 +20,11 @@ repository = "https://github.com/rust-osdev/vga"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.2.1"
|
bitflags = "1.2.1"
|
||||||
spin = "0.9"
|
|
||||||
log = "*"
|
|
||||||
|
|
||||||
conquer-once = { version = "0.3.2", default-features = false }
|
conquer-once = { version = "0.3.2", default-features = false }
|
||||||
font8x8 = { version = "0.3.1", default-features = false, features = [
|
font8x8 = { version = "0.3.1", default-features = false, features = ["unicode"] }
|
||||||
"unicode",
|
|
||||||
] }
|
|
||||||
spinning_top = { version = "0.2.4", features = ["nightly"] }
|
spinning_top = { version = "0.2.4", features = ["nightly"] }
|
||||||
x86_64 = "0.14.2"
|
x86_64 = "0.14.2"
|
||||||
|
|
||||||
[dependencies.num-traits]
|
[dependencies.num-traits]
|
||||||
version = "0.2.14"
|
version = "0.2.14"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dependencies.ab_glyph]
|
|
||||||
version = "0.2.15"
|
|
||||||
default-features = false
|
|
||||||
features = ["libm"]
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -69,6 +69,7 @@ impl TextModeColor {
|
||||||
self.0 = foreground as u8;
|
self.0 = foreground as u8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the default vga 256 color palette.
|
/// Represents the default vga 256 color palette.
|
||||||
pub const DEFAULT_PALETTE: [u8; PALETTE_SIZE] = [
|
pub const DEFAULT_PALETTE: [u8; PALETTE_SIZE] = [
|
||||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x2A, 0x0, 0x2A, 0x0, 0x0, 0x2A, 0x2A, 0x2A, 0x0, 0x0, 0x2A, 0x0,
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x2A, 0x0, 0x2A, 0x0, 0x0, 0x2A, 0x2A, 0x2A, 0x0, 0x0, 0x2A, 0x0,
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
extern crate alloc;
|
|
||||||
|
|
||||||
pub mod colors;
|
pub mod colors;
|
||||||
pub mod configurations;
|
pub mod configurations;
|
||||||
pub mod drawing;
|
pub mod drawing;
|
||||||
|
|
|
@ -5,7 +5,6 @@ use crate::{
|
||||||
registers::{PlaneMask, WriteMode},
|
registers::{PlaneMask, WriteMode},
|
||||||
vga::{VideoMode, VGA},
|
vga::{VideoMode, VGA},
|
||||||
};
|
};
|
||||||
use core::convert::From;
|
|
||||||
use font8x8::UnicodeFonts;
|
use font8x8::UnicodeFonts;
|
||||||
|
|
||||||
const WIDTH: usize = 640;
|
const WIDTH: usize = 640;
|
||||||
|
@ -123,7 +122,6 @@ impl Graphics640x480x16 {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn _set_pixel(self, x: usize, y: usize, color: Color16) {
|
fn _set_pixel(self, x: usize, y: usize, color: Color16) {
|
||||||
if x < 640 && y < 480 {
|
|
||||||
let frame_buffer = self.get_frame_buffer();
|
let frame_buffer = self.get_frame_buffer();
|
||||||
let offset = x / 8 + y * WIDTH_IN_BYTES;
|
let offset = x / 8 + y * WIDTH_IN_BYTES;
|
||||||
let pixel_mask = 0x80 >> (x & 0x07);
|
let pixel_mask = 0x80 >> (x & 0x07);
|
||||||
|
@ -136,76 +134,3 @@ impl Graphics640x480x16 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
use ab_glyph::{Font, FontRef, Glyph};
|
|
||||||
use log::trace;
|
|
||||||
use spin::Lazy;
|
|
||||||
|
|
||||||
const FONT_BASIC: Lazy<FontRef> = Lazy::new({
|
|
||||||
|| FontRef::try_from_slice(include_bytes!("../../assets/fonts/unifont-14.0.01.ttf")).unwrap()
|
|
||||||
});
|
|
||||||
|
|
||||||
const FONT_SUPPLEMENTARY: Lazy<FontRef> = Lazy::new(|| {
|
|
||||||
FontRef::try_from_slice(include_bytes!(
|
|
||||||
"../../assets/fonts/unifont_upper-14.0.01.ttf"
|
|
||||||
))
|
|
||||||
.unwrap()
|
|
||||||
});
|
|
||||||
|
|
||||||
const FONT_SCALE: f32 = 14.0;
|
|
||||||
const GLYPH_HEIGHT: f32 = 10.0;
|
|
||||||
const GLYPH_WIDTH: f32 = 8.0;
|
|
||||||
|
|
||||||
impl Graphics640x480x16 {
|
|
||||||
/// Draw a glyph on the screen at the given position
|
|
||||||
///
|
|
||||||
/// # Arguments
|
|
||||||
/// * `x` - the x position of the glyph
|
|
||||||
/// * `y` - the y position of the glyph
|
|
||||||
/// * `glyph` - the glyph to draw
|
|
||||||
/// * `color` - the color of the glyph
|
|
||||||
pub fn draw_unicode_char(&self, mut x: usize, mut y: usize, character: char, color: Color16) {
|
|
||||||
self.set_write_mode_2();
|
|
||||||
|
|
||||||
// trace!("Char {}", character);
|
|
||||||
|
|
||||||
// if character == '\n' {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
if x == 80 {
|
|
||||||
x = 0;
|
|
||||||
y += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if character != '\0' {
|
|
||||||
let real_x = x as f32 * GLYPH_WIDTH;
|
|
||||||
let real_y = (y as f32 + 1.0) * GLYPH_HEIGHT;
|
|
||||||
// trace!("REALX{}\nREALY{}", real_x, real_y);
|
|
||||||
|
|
||||||
let in_supp_plane = character as u32 > 0xffff;
|
|
||||||
|
|
||||||
let plane = match in_supp_plane {
|
|
||||||
false => FONT_BASIC,
|
|
||||||
true => FONT_SUPPLEMENTARY,
|
|
||||||
};
|
|
||||||
|
|
||||||
let q_glyph: Glyph = plane
|
|
||||||
.glyph_id(character)
|
|
||||||
.with_scale_and_position(FONT_SCALE, ab_glyph::point(real_x, real_y));
|
|
||||||
|
|
||||||
if let Some(q) = plane.outline_glyph(q_glyph) {
|
|
||||||
q.draw(|gx, gy, c| {
|
|
||||||
if c > 0.1 {
|
|
||||||
let corner = q.px_bounds().min;
|
|
||||||
self._set_pixel(
|
|
||||||
gx as usize + corner.x as usize,
|
|
||||||
gy as usize + corner.y as usize,
|
|
||||||
color,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue