-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
40 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
pub mod background_fetcher; | ||
pub mod sprite_fetcher; | ||
mod fetching_state; | ||
mod fetcher_state_machine; | ||
mod fetcher_state_machine; | ||
|
||
pub const FIFO_SIZE:usize = 8; | ||
pub const SPRITE_WIDTH:u8 = 8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,35 @@ | ||
use std::mem::MaybeUninit; | ||
|
||
pub mod vec2; | ||
pub mod memory_registers; | ||
pub mod bit_masks; | ||
pub mod fixed_size_queue; | ||
|
||
pub const GB_FREQUENCY:u32 = 4_194_304; | ||
|
||
pub fn create_default_array<T:Default,const SIZE:usize>()->[T;SIZE]{ | ||
let mut data: [MaybeUninit<T>; SIZE] = unsafe{MaybeUninit::uninit().assume_init()}; | ||
|
||
for elem in &mut data[..]{ | ||
*elem = MaybeUninit::new(T::default()); | ||
} | ||
unsafe{ | ||
let casted_data = std::ptr::read(&data as *const [MaybeUninit<T>;SIZE] as *const [T;SIZE]); | ||
std::mem::forget(data); | ||
// std::mem::forget(data); | ||
return casted_data; | ||
} | ||
} | ||
pub fn create_array<T, F:Fn()->T,const SIZE:usize>(func:F)->[T;SIZE]{ | ||
let mut data: [MaybeUninit<T>; SIZE] = unsafe{MaybeUninit::uninit().assume_init()}; | ||
|
||
pub const GB_FREQUENCY:u32 = 4_194_304; | ||
for elem in &mut data[..]{ | ||
*elem = MaybeUninit::new(func()); | ||
} | ||
unsafe{ | ||
let casted_data = std::ptr::read(&data as *const [MaybeUninit<T>;SIZE] as *const [T;SIZE]); | ||
std::mem::forget(data); | ||
// std::mem::forget(data); | ||
return casted_data; | ||
} | ||
} |