changed some stuff
This commit is contained in:
@@ -5,4 +5,5 @@ pub mod interrupts;
|
||||
pub mod memory;
|
||||
pub mod render;
|
||||
pub mod serial;
|
||||
pub mod tasks;
|
||||
pub mod tasks;
|
||||
pub mod sysinit;
|
||||
@@ -1,3 +1,4 @@
|
||||
fn init() -> Result<(), ()> {
|
||||
use crate::println;
|
||||
pub fn init() -> Result<(), ()> {
|
||||
Ok(())
|
||||
}
|
||||
@@ -6,4 +6,5 @@ pub fn init() {
|
||||
kernel::interrupts::init_idt();
|
||||
unsafe { kernel::interrupts::PICS.lock().initialize() };
|
||||
x86_64::instructions::interrupts::enable();
|
||||
kernel::sysinit::init().unwrap();
|
||||
}
|
||||
@@ -3,14 +3,16 @@ use alloc::{string::{String, ToString}, vec::Vec};
|
||||
use rand::{Rng, SeedableRng, rngs::SmallRng, RngCore};
|
||||
use spin::Mutex;
|
||||
use lazy_static::lazy_static;
|
||||
use cmos_rtc::{ReadRTC, Time};
|
||||
|
||||
lazy_static! {
|
||||
pub static ref RANDOM: Mutex<SmallRng> = Mutex::new(SmallRng::seed_from_u64(1));
|
||||
pub static ref RANDOM: Mutex<SmallRng> = Mutex::new(SmallRng::seed_from_u64({
|
||||
let mut cmos = ReadRTC::new(0x00, 0x00);
|
||||
let time: Time = cmos.read();
|
||||
time.second as u64 + time.minute as u64 + time.hour as u64 + time.day as u64 + time.month as u64 + time.year as u64
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
pub struct Random;
|
||||
|
||||
impl Random {
|
||||
@@ -28,8 +30,8 @@ impl Random {
|
||||
}
|
||||
|
||||
}
|
||||
pub fn selection<T: Clone>(ls: Vec<T>) -> T {
|
||||
pub fn selection<T: Clone>(ls: &Vec<T>) -> &T {
|
||||
let range = Random::int(0, ls.len() - 1);
|
||||
ls[range as usize].clone()
|
||||
&ls[range as usize]
|
||||
}
|
||||
}
|
||||
@@ -123,17 +123,21 @@ async fn exec() -> Result<(), Error> {
|
||||
}
|
||||
"random" => {
|
||||
use crate::std::random::Random;
|
||||
let vec = Vec::from(["a", "b", "c", "d", "e", "f"]);
|
||||
let sel = Random::selection(vec);
|
||||
println!("{}", sel);
|
||||
let vec = Vec::from(["is", "is not", "is absolutely"]);
|
||||
let vec2 = Vec::from(["simp", "gigachad", "genius", "bozo", "Non simp"]);
|
||||
let sel = *Random::selection(&vec);
|
||||
let sel2 = *Random::selection(&vec2);
|
||||
println!("panic attack {} a {}", sel, sel2);
|
||||
}
|
||||
"filesystem" => {
|
||||
use crate::std::io;
|
||||
io::mkfs();
|
||||
}
|
||||
"test_features" => {
|
||||
use crate::user::lib::libgui;
|
||||
libgui::libgui_core::test_elements();
|
||||
use crate::std::random::Random;
|
||||
println!("{}", Random::int(0, 10));
|
||||
// use crate::user::lib::libgui;
|
||||
// libgui::libgui_core::test_elements();
|
||||
}
|
||||
_ => {
|
||||
return Err(Error::UnknownCommand(
|
||||
|
||||
@@ -268,6 +268,11 @@ this is gonna be the best game ever",
|
||||
true,
|
||||
)));
|
||||
|
||||
let mut bar = IndicatorBar::new(Pos::new(7, 7), 12);
|
||||
bar.set_value(70);
|
||||
bar.set_text(String::from("ayo"));
|
||||
|
||||
containers[0].elements.push(Box::new(bar));
|
||||
render_frame(containers);
|
||||
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user