mirror of
https://github.com/thornAvery/kep-hack.git
synced 2025-09-17 02:40:50 +12:00
merge KuroiIeWa5Da/pokered
hg-commit-id: 18f5e99b6ae1
This commit is contained in:
commit
177c1dccba
|
@ -72,7 +72,7 @@ string Modulation::GenAsm()
|
|||
if(tmpRet != "") return tmpRet;
|
||||
|
||||
stringstream tmpAsmOut;
|
||||
tmpAsmOut << "mus_mod " << hex << (short)delay << ", " << (short)depth << ", " << (short)rate;
|
||||
tmpAsmOut << "mus_mod " << (short)delay << ", " << (short)depth << ", " << (short)rate;
|
||||
return tmpAsmOut.str();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ Parser::Parser()
|
|||
fileLength = 0;
|
||||
filePos = 0;
|
||||
stop = false;
|
||||
stopAddress = 0;
|
||||
}
|
||||
|
||||
Parser::Parser(std::string filename)
|
||||
|
@ -46,6 +47,16 @@ void Parser::SetFilename(std::string value)
|
|||
Read();
|
||||
}
|
||||
|
||||
unsigned int Parser::GetStopAddress()
|
||||
{
|
||||
return stopAddress;
|
||||
}
|
||||
|
||||
void Parser::SetStopAddress(unsigned int value)
|
||||
{
|
||||
stopAddress = value;
|
||||
}
|
||||
|
||||
string Parser::GetParsedAsm()
|
||||
{
|
||||
string tmpStr;
|
||||
|
@ -103,7 +114,6 @@ void Parser::ParseNext() // Parses the block immidiately following
|
|||
for(unsigned int i = filePos; (i <= fileLength) && (stop == false); i++)
|
||||
{
|
||||
// There's a way to make this block shorter but for now it does it's job
|
||||
filePos = i;
|
||||
|
||||
// Check to see if it's the correct data type and if so then use it
|
||||
if(tmpCall.IsValid(&rawBytesFixed[i])) // Should have made IsValid static
|
||||
|
@ -192,6 +202,11 @@ void Parser::ParseNext() // Parses the block immidiately following
|
|||
unkCode << "db $" << hex << uppercase << (short)rawBytesFixed[i];
|
||||
parsedString.push_back(unkCode.str());
|
||||
}
|
||||
|
||||
filePos = i;
|
||||
|
||||
// If the stop address parameter is set, break when we get there
|
||||
if( (stopAddress != 0) && (i >= stopAddress) ) break;
|
||||
}
|
||||
|
||||
// Now record the postion we left off
|
||||
|
|
|
@ -37,6 +37,9 @@ public:
|
|||
std::string GetFilename();
|
||||
void SetFilename(std::string value);
|
||||
|
||||
unsigned int GetStopAddress();
|
||||
void SetStopAddress(unsigned int value);
|
||||
|
||||
std::string GetParsedAsm();
|
||||
|
||||
// File Operations
|
||||
|
@ -56,6 +59,9 @@ private:
|
|||
unsigned int filePos;
|
||||
bool stop;
|
||||
|
||||
// Optional Settings
|
||||
unsigned int stopAddress;
|
||||
|
||||
// A lot of tmp classes
|
||||
Call tmpCall;
|
||||
Duty tmpDuty;
|
||||
|
|
|
@ -7,31 +7,61 @@ 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;
|
||||
const string defFileLoc = "../baserom.gbc";
|
||||
|
||||
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";
|
||||
arg2 = defFileLoc;
|
||||
}
|
||||
|
||||
// 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);
|
||||
if(arg2 == "--") arg2 = defFileLoc; // You can also put "--" for the default file location
|
||||
|
||||
// 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…
Reference in a new issue