From 829b8852fe6b8e47c3fb58208bb746cd69c223d9 Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Tue, 27 Oct 2020 22:43:53 +0000 Subject: [PATCH] Greatly improved `func` module in `dcb::game::exe`. --- dcb/src/game/exe/func.rs | 62 +++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/dcb/src/game/exe/func.rs b/dcb/src/game/exe/func.rs index 5847e1d..cac051c 100644 --- a/dcb/src/game/exe/func.rs +++ b/dcb/src/game/exe/func.rs @@ -2,61 +2,63 @@ // Imports use crate::game::exe::Pos; -use indoc::indoc; -use std::borrow::Cow; /// A function within the executable #[derive(PartialEq, Eq, Clone, Hash, Debug)] #[derive(serde::Serialize, serde::Deserialize)] -pub struct Func { +pub struct Func, C: AsRef<[(Pos, S)]>> { /// Function signature - signature: Cow<'static, str>, + signature: S, /// Description - desc: Cow<'static, str>, + desc: S, + + /// Comments + comments: C, /// Start position start_pos: Pos, - /// End position + /// End position (non-inclusive) end_pos: Pos, } -impl Func { - /// All currently known functions - pub const FUNCTIONS: &'static [Self] = &[ +impl Func<&'static str, &'static [(Pos, &'static str)]> { + /// List of all known functions + pub const ALL: &'static [Self] = &[ Self { - signature: Cow::Borrowed("void InitHeap(int* addr, unsigned int size)"), - desc: Cow::Borrowed("Calls A(0x39)"), + signature: "void InitHeap(int* addr, unsigned int size)", + desc: "Calls A(0x39)", + comments: &[], start_pos: Pos(0x8006a734), end_pos: Pos(0x8006a744), }, Self { - signature: Cow::Borrowed("void start(void)"), - desc: Cow::Borrowed(indoc! {" - Executable start. - Zeroes out 0x80077a08..0x801ddf38. - Initializes the stack, frame and global pointer. - Calls InitHeap(0x8007f988, ???). - Calls func_1025(0x8007f98c). - Calls func_1026(string_0, string_0). - "}), + signature: "void start(void)", + desc: "Executable start", + comments: &[ + (Pos(0x80056280), "Zero out 0x80077a08 .. 0x801ddf38 word by word."), + (Pos(0x80056284), "^"), + (Pos(0x80056288), "^"), + (Pos(0x8005628c), "^"), + (Pos(0x800562f8), "InitHeap(0x8007f988, ???)"), + (Pos(0x8005630c), "func_1025(0x8007f98c)"), + (Pos(0x80056324), "func_1026(string_0, string_0)"), + ], start_pos: Pos(0x80056270), - end_pos: Pos(0x80056328), + end_pos: Pos(0x80056330), }, Self { - signature: Cow::Borrowed("void func_1025(int*)"), - desc: Cow::Borrowed(indoc! {" - At the end, calls func_446 indefinitely. - "}), + signature: "void func_1025(int*)", + desc: "", + comments: &[(Pos(0x80013ef4), "Called indefinitely?"), (Pos(0x80013efc), "^ Due to this loop")], start_pos: Pos(0x80013e4c), - end_pos: Pos(0x80013f00), + end_pos: Pos(0x80013f04), }, Self { - signature: Cow::Borrowed("int func_446(int)"), - desc: Cow::Borrowed(indoc! {" - - "}), + signature: "int func_446(int)", + desc: "", + comments: &[], start_pos: Pos(0x80069124), end_pos: Pos(0x80069150), },