WritePString

This commit is contained in:
Kelvin Sherlock 2013-02-13 22:16:05 -05:00
parent db68aea8b1
commit 8bde718b83
2 changed files with 17 additions and 0 deletions

View File

@ -97,5 +97,20 @@ namespace ToolBox {
return tmp;
}
bool WritePString(uint32_t address, const std::string &s)
{
int length = s.length();
if (length > 255) return false;
if (address == 0) return false;
uint8_t *ptr = memoryPointer(address);
*ptr++ = (uint8_t)length;
for (char c : s)
{
*ptr++ = (uint8_t)c;
}
return true;
}
}

View File

@ -10,6 +10,8 @@ namespace ToolBox
std::string ReadCString(uint32_t address);
std::string ReadPString(uint32_t address);
bool WritePString(uint32_t address, const std::string &s);
}