mirror of
https://github.com/thornAvery/kep-hack.git
synced 2026-02-07 08:05:23 +13:00
updated disassembly program to support a custom stop address
hg-commit-id: a2bee0bdb345
This commit is contained in:
parent
7b5159fb06
commit
a297c105b5
3 changed files with 53 additions and 5 deletions
|
|
@ -7,31 +7,59 @@ using namespace std;
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
string arg1; // Offset
|
||||
string arg2; // File
|
||||
const unsigned char parameters = 2;
|
||||
const unsigned char self = 1;
|
||||
const unsigned char _max_argc = parameters + self;
|
||||
|
||||
if(argc >= 3)
|
||||
string arg1; // Offset
|
||||
string arg2; // File or "--" (if "--" then the file is assumed)
|
||||
|
||||
string paramStopAddr;
|
||||
|
||||
if(argc >= _max_argc)
|
||||
{
|
||||
arg1 = argv[1];
|
||||
arg2 = argv[2];
|
||||
}
|
||||
else if(argc == 2)
|
||||
else if(argc == (_max_argc - 1))
|
||||
{
|
||||
arg1 = argv[1];
|
||||
arg2 = "../baserom.gbc";
|
||||
}
|
||||
|
||||
// Process any parameters
|
||||
if(argc > _max_argc)
|
||||
{
|
||||
for(int i = _max_argc; i < argc; i++)
|
||||
{
|
||||
string tmpArgv = argv[i];
|
||||
if(tmpArgv.substr(0, 7) == "--stop=") paramStopAddr = tmpArgv.substr(7);
|
||||
}
|
||||
}
|
||||
|
||||
if(arg1 == "") Console::Ask("What offset in the file in hex (0x----): ", arg1);
|
||||
if(arg2 == "") Console::Ask("What file: ", arg2);
|
||||
|
||||
// Weird way of converting arg1 to an unsigned integer
|
||||
Parser p(arg2);
|
||||
|
||||
stringstream arg1Conv;
|
||||
unsigned int arg1ConvNum;
|
||||
arg1Conv << arg1;
|
||||
arg1Conv << hex;
|
||||
arg1Conv >> arg1ConvNum;
|
||||
|
||||
Parser p(arg2);
|
||||
if(paramStopAddr != "")
|
||||
{
|
||||
stringstream paramStopAddrConv;
|
||||
unsigned int paramStopAddrNum = 0;
|
||||
paramStopAddrConv.str("");
|
||||
paramStopAddrConv << paramStopAddr;
|
||||
paramStopAddrConv << hex;
|
||||
paramStopAddrConv >> paramStopAddrNum;
|
||||
p.SetStopAddress(paramStopAddrNum);
|
||||
}
|
||||
|
||||
p.Parse(arg1ConvNum);
|
||||
Console::PrintLn(p.GetParsedAsm().c_str());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue