Add noise to rng
This commit is contained in:
parent
9fc8654e7b
commit
88ed908faa
@ -1,5 +1,4 @@
|
|||||||
- quick drop
|
- quick drop
|
||||||
- better rng
|
|
||||||
- fix asm loader
|
- fix asm loader
|
||||||
- document everything
|
- document everything
|
||||||
- prettier pictures
|
- prettier pictures
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
use core::arch::asm;
|
use core::arch::asm;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use rand::{rngs::SmallRng, SeedableRng};
|
use rand::{rngs::SmallRng, Rng, SeedableRng};
|
||||||
use spin::Mutex;
|
use spin::Mutex;
|
||||||
|
|
||||||
use drivers::{pic::PICDriver, vga::Vga13h};
|
use drivers::{pic::PICDriver, vga::Vga13h};
|
||||||
@ -89,6 +89,16 @@ enum InputKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "x86-interrupt" fn keyboard_handler(_stack_frame: InterruptStackFrame) {
|
extern "x86-interrupt" fn keyboard_handler(_stack_frame: InterruptStackFrame) {
|
||||||
|
{
|
||||||
|
// Re-seed our rng using user input.
|
||||||
|
// This is a simple hack that makes our
|
||||||
|
// "random" tile selector less deterministic.
|
||||||
|
let mut rng = RNG.lock();
|
||||||
|
let past: u64 = rng.random();
|
||||||
|
let tcr = u64::from(*TICK_COUNTER.lock());
|
||||||
|
*rng = SmallRng::seed_from_u64(past + tcr);
|
||||||
|
}
|
||||||
|
|
||||||
'key_block: {
|
'key_block: {
|
||||||
let scancode = unsafe { inb(0x60) };
|
let scancode = unsafe { inb(0x60) };
|
||||||
let key = match scancode {
|
let key = match scancode {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user