write_to_coord() in rust now has sensible coordinates

This commit is contained in:
greg
2015-10-22 23:40:18 -07:00
parent 3e6c6d17d7
commit c5fcd73499

View File

@@ -9,29 +9,57 @@ extern fn eh_personality() {}
#[lang = "panic_fmt"]
fn panic_fmt() -> ! { loop {} }
#[lang = "panic"]
pub fn panic(expr_file_line: &(&'static str, &'static str, u32)) -> ! { panic_fmt() }
#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}
#[lang = "add"]
pub trait Add<RHS=Self> {
type Output;
fn add(self, rhs: RHS) -> Self::Output;
}
/* this can be bogus, apparently? */
impl Add for usize {
type Output = usize;
fn add(self, _rhs: usize) -> usize { 1 }
}
#[lang = "mul"]
pub trait Mul<RHS = Self> {
type Output;
fn mul(self, rhs: RHS) -> Self::Output;
}
impl Mul for usize {
type Output = usize;
fn mul(self, rhs: usize) -> usize { 1 }
}
#[no_mangle]
pub extern fn rust_entry() {
//white A on black
let spec: u16 = 0x0f_41;
write_to_coord(0, 0, spec);
loop {
}
write_to_coord(1, 2, spec);
loop { }
}
//const VRAM_OFFSET = 0xb8000;
const X86_COLS: usize = 80;
const X86_ROWS: usize = 25;
const VRAM_OFFSET: usize = 0xb8000;
fn write_to_coord(x: u8, y: u8, x86_specifier: u16) {
unsafe {
*(0xb8000 as *mut u16) = x86_specifier;
let offset = VRAM_OFFSET + (X86_COLS*2*(y as usize)) + (x as usize)*2;
*(offset as *mut u16) = x86_specifier;
}
}