Fix formatting in ParseTextDataByte and optimize message handling in ReadAllTextDataV2
This commit is contained in:
@@ -93,7 +93,7 @@ std::string ParseTextDataByte(uint8_t value) {
|
||||
// Check for dictionary.
|
||||
int dictionary = FindDictionaryEntry(value);
|
||||
if (dictionary >= 0) {
|
||||
return absl::StrFormat("[%s:%2X]", DICTIONARYTOKEN, dictionary);
|
||||
return absl::StrFormat("[%s:%02X]", DICTIONARYTOKEN, dictionary);
|
||||
}
|
||||
|
||||
return "";
|
||||
@@ -285,12 +285,14 @@ std::vector<std::string> ParseMessageData(
|
||||
parsed_message.push_back(CharEncoder.at(byte));
|
||||
} else {
|
||||
if (byte >= DICTOFF && byte < (DICTOFF + 97)) {
|
||||
if (byte > 0 && byte <= dictionary_entries.size()) {
|
||||
auto dic_entry = dictionary_entries[byte];
|
||||
parsed_message.append(dic_entry.Contents);
|
||||
} else {
|
||||
parsed_message.append(dictionary_entries[0].Contents);
|
||||
DictionaryEntry dic_entry;
|
||||
for (const auto &entry : dictionary_entries) {
|
||||
if (entry.ID == byte - DICTOFF) {
|
||||
dic_entry = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
parsed_message.append(dic_entry.Contents);
|
||||
} else {
|
||||
auto text_element = FindMatchingCommand(byte);
|
||||
if (text_element != std::nullopt) {
|
||||
|
||||
@@ -224,7 +224,6 @@ void MessageEditor::DrawDictionary() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Fix the command parsing.
|
||||
void MessageEditor::ReadAllTextDataV2() {
|
||||
// Read all text data from the ROM.
|
||||
int pos = kTextData;
|
||||
@@ -232,7 +231,6 @@ void MessageEditor::ReadAllTextDataV2() {
|
||||
|
||||
std::vector<uint8_t> raw_message;
|
||||
std::vector<uint8_t> parsed_message;
|
||||
|
||||
std::string current_raw_message;
|
||||
std::string current_parsed_message;
|
||||
|
||||
@@ -243,19 +241,6 @@ void MessageEditor::ReadAllTextDataV2() {
|
||||
list_of_texts_.push_back(
|
||||
MessageData(message_id++, pos, current_raw_message, raw_message,
|
||||
current_parsed_message, parsed_message));
|
||||
std::cout << "Message ID: " << message_id << std::endl;
|
||||
std::cout << "Raw: " << current_raw_message << std::endl;
|
||||
std::cout << "Parsed: " << current_parsed_message << std::endl;
|
||||
std::cout << "Raw Bytes: ";
|
||||
for (const auto &byte : raw_message) {
|
||||
std::cout << util::HexByte(byte) << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
std::cout << "Parsed Bytes: ";
|
||||
for (const auto &byte : parsed_message) {
|
||||
std::cout << util::HexByte(byte) << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
raw_message.clear();
|
||||
parsed_message.clear();
|
||||
current_raw_message.clear();
|
||||
|
||||
Reference in New Issue
Block a user