Flesh out bgmap viewer

This commit is contained in:
2025-02-15 18:33:18 -05:00
parent 57eebb5874
commit 4601f1b52f
7 changed files with 469 additions and 177 deletions
+5 -2
View File
@@ -70,9 +70,12 @@ pub struct MemoryRef<'a> {
}
impl MemoryRef<'_> {
pub fn read(&self, index: usize) -> u8 {
self.inner[index]
pub fn read<T: bytemuck::AnyBitPattern>(&self, index: usize) -> T {
let from = index * size_of::<T>();
let to = from + size_of::<T>();
*bytemuck::from_bytes(&self.inner[from..to])
}
pub fn range<T: bytemuck::AnyBitPattern>(&self, start: usize, count: usize) -> &[T] {
let from = start * size_of::<T>();
let to = from + (count * size_of::<T>());