Compare commits
4 Commits
a26dabaa5a
...
9c09fe7cec
Author | SHA1 | Date | |
---|---|---|---|
9c09fe7cec | |||
9902506264 | |||
ab4d34ecdb | |||
c167b7a247 |
@ -1,12 +0,0 @@
|
||||
---
|
||||
BasedOnStyle: Microsoft
|
||||
CompactNamespaces: 'false'
|
||||
FixNamespaceComments: 'false'
|
||||
NamespaceIndentation: All
|
||||
AllowShortBlocksOnASingleLine: 'true'
|
||||
AllowShortCaseLabelsOnASingleLine: 'true'
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Always
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: 'true'
|
||||
PointerAlignment: Left
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,4 +2,5 @@ Luna.iso
|
||||
toolchain/
|
||||
.vscode/
|
||||
initrd/boot/
|
||||
moon/target/**
|
||||
moon/target/**
|
||||
**/Cargo.lock
|
7
moon/src/init.rs
Normal file
7
moon/src/init.rs
Normal file
@ -0,0 +1,7 @@
|
||||
use crate::bootboot::{BOOTBOOT, BOOTBOOT_MAGIC};
|
||||
use crate::util::get_bootboot;
|
||||
|
||||
pub fn check_magic() -> () {
|
||||
let boot: BOOTBOOT = get_bootboot();
|
||||
assert_eq!(boot.magic, BOOTBOOT_MAGIC[..4]);
|
||||
}
|
@ -5,9 +5,13 @@ mod video;
|
||||
mod bootboot;
|
||||
mod panic;
|
||||
mod util;
|
||||
mod init;
|
||||
|
||||
use video::Color;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn _start() -> ! {
|
||||
video::clear(0xffffffff);
|
||||
init::check_magic();
|
||||
video::clear(Color::White);
|
||||
loop {}
|
||||
}
|
||||
}
|
@ -1,27 +1,51 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use crate::bootboot::{BOOTBOOT, BOOTBOOT_FB};
|
||||
use crate::util::get_bootboot;
|
||||
|
||||
use BOOTBOOT_FB as FB;
|
||||
|
||||
pub fn put_pixel(x: u32, y: u32, color: u32) -> () {
|
||||
let boot: BOOTBOOT = get_bootboot();
|
||||
let ptr: u64 = FB + (boot.fb_scanline * y) as u64 + (x * 4) as u64;
|
||||
unsafe { *(ptr as *mut u32) = color };
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum Color {
|
||||
Black = 0x00000000,
|
||||
Blue = 0xff0000ff,
|
||||
Green = 0xff00ff00,
|
||||
Cyan = 0xff00ffff,
|
||||
Red = 0xffff0000,
|
||||
Magenta = 0xffff00ff,
|
||||
Brown = 0xff231709,
|
||||
LightGray = 0xffb9b8b5,
|
||||
DarkGray = 0xff808080,
|
||||
LightBlue = 0xff317ecc,
|
||||
LightGreen = 0xff6aab8e,
|
||||
LightCyan = 0xffe0ffff,
|
||||
LightRed = 0xffff7377,
|
||||
Pink = 0xffffc0cb,
|
||||
Yellow = 0xffffff00,
|
||||
White = 0xffffffff,
|
||||
}
|
||||
|
||||
pub fn draw_rect(x: u32, y: u32, width: u32, height: u32, color: u32) -> () {
|
||||
pub fn put_pixel(x: u32, y: u32, color: Color) -> () {
|
||||
let boot: BOOTBOOT = get_bootboot();
|
||||
let ptr: u64 = FB + (boot.fb_scanline * y) as u64 + (x * 4) as u64;
|
||||
unsafe { *(ptr as *mut u32) = color as u32 };
|
||||
}
|
||||
|
||||
pub fn draw_rect(x: u32, y: u32, width: u32, height: u32, color: Color) -> () {
|
||||
let boot: BOOTBOOT = get_bootboot();
|
||||
for i in y..(y + height)
|
||||
{
|
||||
let addr: u64 = FB + (boot.fb_scanline * i) as u64 + (x * 4) as u64;
|
||||
for ptr in (addr..(addr + (width*4) as u64)).step_by(4)
|
||||
{
|
||||
unsafe { *(ptr as *mut u32) = color };
|
||||
unsafe { *(ptr as *mut u32) = color as u32 };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear(color: u32) -> () {
|
||||
pub fn clear(color: Color) -> () {
|
||||
let boot: BOOTBOOT = get_bootboot();
|
||||
draw_rect(0, 0, boot.fb_width, boot.fb_height, color)
|
||||
}
|
Loading…
Reference in New Issue
Block a user