non-guard

This commit is contained in:
2024-04-17 23:59:41 +02:00
parent da7729a00b
commit 4ad3e0ac5f
4 changed files with 38 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
use crate::{
dist_cell::read_dist_cells,
lane::EnmaLaneCell,
non_guard::EnmaNonGuardCell,
section::{read_bank_cell, EnmaBankCell, EnmaSection},
speed::EnmaSpeedCell,
windows_pe::WindowsPEFile,
@@ -67,6 +68,8 @@ pub fn read_area(file: &WindowsPEFile, address: u64) -> Result<EnmaArea, std::io
zebra_left: read_dist_cells(file, area.zebra_left_addr, area.max_dist, false)?,
zebra_right: read_dist_cells(file, area.zebra_left_addr, area.max_dist, false)?,
gaps: read_dist_cells(file, area.gaps_addr, area.max_dist, false)?,
non_guard_left: read_dist_cells(file, area.non_guard_left_addr, area.max_dist, false)?,
non_guard_right: read_dist_cells(file, area.non_guard_right_addr, area.max_dist, false)?,
speed: read_dist_cells(file, area.speed_addr, area.max_dist, true)?,
lane: read_dist_cells(file, area.lane_addr, area.max_dist, true)?,
})
@@ -87,8 +90,8 @@ pub struct EnmaArea {
pub zebra_left: Vec<EnmaZebraCell>,
pub zebra_right: Vec<EnmaZebraCell>,
pub gaps: Vec<f32>,
// TODO: Non Guard Left
// TODO: Non Guard Right
pub non_guard_left: Vec<EnmaNonGuardCell>,
pub non_guard_right: Vec<EnmaNonGuardCell>,
pub speed: Vec<EnmaSpeedCell>,
pub lane: Vec<EnmaLaneCell>,
}

View File

@@ -17,6 +17,16 @@ impl EnmaDistCell for f32 {
}
}
impl EnmaDistCell for (f32, i32) {
fn dist(&self) -> f32 {
self.0
}
fn size() -> u64 {
8
}
}
pub fn read_dist_cells<'a, T>(
file: &WindowsPEFile,
mut address: u64,

View File

@@ -2,6 +2,7 @@ pub mod area;
pub mod dist_cell;
pub mod lane;
pub mod meta;
pub mod non_guard;
pub mod section;
pub mod speed;
mod util;

View File

@@ -0,0 +1,22 @@
use binrw::BinRead;
use serde::Serialize;
use crate::dist_cell::EnmaDistCell;
#[derive(Debug, BinRead, Serialize)]
pub struct EnmaNonGuardCell {
pub dist: f32,
pub unk1: f32,
// TODO: Is this a boolean?
pub guard: i32,
}
impl EnmaDistCell for EnmaNonGuardCell {
fn dist(&self) -> f32 {
self.dist
}
fn size() -> u64 {
0xc
}
}