From 2a46c247d9548c26d782d2fc6bcc6f7bf04101c2 Mon Sep 17 00:00:00 2001 From: KuroiIeWa5Da Date: Sat, 28 Jan 2012 06:56:20 -0600 Subject: Updated Music Disassembler to support a help parameter hg-commit-id: d5725126c98b --- music/pokeredmusicdisasm/main.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/music/pokeredmusicdisasm/main.cpp b/music/pokeredmusicdisasm/main.cpp index 51ba16b4..f486e28f 100644 --- a/music/pokeredmusicdisasm/main.cpp +++ b/music/pokeredmusicdisasm/main.cpp @@ -6,6 +6,36 @@ using namespace std; +void PrintUsage() +{ + Console::PrintLn("Usage: [ [ | --]]"); + Console::PrintLn("Usage: [--offset= | -o ] [--file=[ | --] | -f [ | --]] [--stop= | -s ]"); + Console::PrintLn("Usage: [-h | --help]"); + Console::PrintLn(""); + Console::PrintLn("Used without parameters will start in limited interactive mode where the program will ask you the file and offset"); + Console::PrintLn("An offset is a requirement but the file may be blank or explicitly set, whenever the file is set you may use '--' to substitute for the default file '../baserom.gbc'"); + Console::PrintLn("If parameter options are not used the ordering is important:"); + Console::PrintLn("There is an intentional glitch in the program, since long paramaters must be specified with --xxx= with or without a value, you may use the short option instead -xxx even though it's suppose to be -xxx="); + Console::PrintLn("\t* "); + Console::PrintLn("If parameter options are used the ordering does not matter, ensure the parameter option or parameter is present"); + Console::PrintLn("You may mix and match parameters and parameter options, keep in mind that bare parameters must be in a certain order"); + Console::PrintLn("If the offset parameter is missing in any way the program will prompt you for it"); + Console::PrintLn("The program will stop parsing when it encounters mus_end regardlessly"); + Console::PrintLn("Parameter types"); + Console::PrintLn("\t* - Bare parameter, they must be in a certain order"); + Console::PrintLn("\t* -xxx=xxx - Long parameter option, it can be in any order but is case sensitive, can contain no spaces, must contain the equal sign, and is read literally"); + Console::PrintLn("\t* -xxx xxx - Short parameter option, it can be in any order but is case sensitive, must contain 1 space and is read literally"); + Console::PrintLn("----"); + Console::PrintLn("Breakdown of parameters:"); + Console::PrintLn(" - A bare parameter, it must be in hexidecimal eith alone or prefixed with 0x and be the first parameter. It tells the parser where to start parsing"); + Console::PrintLn(" - A bare parameter, it must be the second parameter and tells the parser which rom file to parse"); + Console::PrintLn("-- - A special file path value meaning use the default file '../baserom.gbc'"); + Console::PrintLn("--offset, -o - the parameterized offset in hexidecimal, It tells the parser where to start parsing"); + Console::PrintLn("--file, -f - the parameterized file path, It tells the parser which rom file to parse"); + Console::PrintLn("--stop, -s - tells the parser to stop at that hexidecimal address or until it reaches mus_end."); + Console::PrintLn("help, --help, -h - prints this info and exits, if the bare parameter is used it must be the first parameter"); +} + /* Usage: pokeredmusicdisasm [ [ | --]] @@ -25,6 +55,13 @@ int main(int argc, char** argv) // Get the file path, this can be set with -f filename, --file=filename, arg #2, or missing (missing means default) // the filepath can contain the actual filename or -- to use the built-in path, if the path is not missing then it must be set (can't be blank) + // Is the user asking for help with -h, --help=, or help + if((a.SearchKeys("h") != -1) || (a.SearchKeys("help") != -1) || (a.GetArgv(1) == "help")) + { + PrintUsage(); + return 0; + } + // Does a -f or --file key exist if(a.SearchKeys("f") != -1) filePath = a.GetValue(a.SearchKeys("f"), true); else if(a.SearchKeys("file") != -1) filePath = a.GetValue(a.SearchKeys("file")); -- cgit v1.2.3