Added a way of forcing certain parts to be read as dw.

This commit is contained in:
2020-10-29 01:30:42 +00:00
parent 00a85397a7
commit 5e4c920f8f
3 changed files with 55 additions and 1 deletions

View File

@@ -126,6 +126,11 @@ impl Data<&'static str> {
desc: "start of the heap",
start_pos: Pos(0x801ddf38),
},
Self::Bytes {
name: "something1_data1",
desc: "???",
start_pos: Pos(0x8006f984),
},
])
}
}

View File

@@ -11,6 +11,7 @@ use maplit::hashmap;
// Imports
use crate::game::exe::Pos;
use indoc::indoc;
use std::collections::HashMap;
/// A function within the executable
@@ -97,6 +98,43 @@ impl Func<&'static str> {
start_pos: Pos(0x80056270),
end_pos: Pos(0x80056330),
},
Self {
name: "something1",
signature: "void(void)",
desc: indoc! {"
This function checks if *something1_data1 is positive, if so decreases
it by 1 and calls something2.
"},
comments: hashmap! {
Pos(0x80056348) => "If *something1_data1 == 0, skip",
Pos(0x8005634c) => "Else decrease it by 1 and save it.",
Pos(0x80056368) => "Then call call_func_arr with args (string0, string0)",
},
labels: hashmap! {
Pos(0x80056370) => "skip",
},
start_pos: Pos(0x80056330),
end_pos: Pos(0x80056388),
},
Self {
name: "call_func_arr",
signature: "fn(start: fn(), end: fn())",
desc: "",
comments: hashmap! {
Pos(0x800563a0) => "if `start >= end`, skip",
Pos(0x800563b0) => "If *start == 0, skip call",
Pos(0x800563b8) => "Else call *start",
Pos(0x800563c0) => "start++",
Pos(0x800563c8) => "If `start < end`, restart",
},
labels: hashmap! {
Pos(0x800563a8) => "loop",
Pos(0x800563c0) => "skip_call",
Pos(0x800563d0) => "exit",
},
start_pos: Pos(0x80056388),
end_pos: Pos(0x800563e4),
},
])
}
}

View File

@@ -4,6 +4,10 @@
use super::{FromRawIter, Instruction, Raw};
use crate::game::exe::Pos;
use ascii::{AsciiChar, AsciiStr, AsciiString};
use std::ops::{
Bound::{self, Excluded, Included, Unbounded},
RangeBounds,
};
use AsciiChar::Null;
/// A directive
@@ -20,6 +24,13 @@ pub enum Directive {
}
impl Directive {
/// All range of positions that should be force decoded
/// as `dw`.
pub const FORCE_DW_RANGES: &'static [(Bound<Pos>, Bound<Pos>)] = &[
(Included(Pos(0x80010000)), Excluded(Pos(0x80010008))),
(Included(Instruction::CODE_END), Unbounded),
];
/// Returns the size of this instruction
#[must_use]
pub fn size(&self) -> u32 {
@@ -56,7 +67,7 @@ impl FromRawIter for Directive {
// If we're past all the code, there are no more strings,
// so just decode a `dw`.
if raw.pos >= Instruction::CODE_END {
if Self::FORCE_DW_RANGES.iter().any(|range| range.contains(&raw.pos)) {
return Some((raw.pos, Self::Dw(raw.repr)));
}