write_to_coord() in rust now has sensible coordinates
This commit is contained in:
40
lightshow.rs
40
lightshow.rs
@@ -9,29 +9,57 @@ extern fn eh_personality() {}
|
|||||||
#[lang = "panic_fmt"]
|
#[lang = "panic_fmt"]
|
||||||
fn panic_fmt() -> ! { loop {} }
|
fn panic_fmt() -> ! { loop {} }
|
||||||
|
|
||||||
|
#[lang = "panic"]
|
||||||
|
pub fn panic(expr_file_line: &(&'static str, &'static str, u32)) -> ! { panic_fmt() }
|
||||||
|
|
||||||
#[lang = "sized"]
|
#[lang = "sized"]
|
||||||
trait Sized {}
|
trait Sized {}
|
||||||
|
|
||||||
#[lang = "copy"]
|
#[lang = "copy"]
|
||||||
trait 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]
|
#[no_mangle]
|
||||||
pub extern fn rust_entry() {
|
pub extern fn rust_entry() {
|
||||||
|
|
||||||
//white A on black
|
//white A on black
|
||||||
let spec: u16 = 0x0f_41;
|
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) {
|
fn write_to_coord(x: u8, y: u8, x86_specifier: u16) {
|
||||||
unsafe {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user