2020-11-24 20:48:38 -05:00
|
|
|
#include "game_count.h"
|
2022-06-22 23:37:46 -04:00
|
|
|
|
2020-11-24 20:48:38 -05:00
|
|
|
#include "LinkedWordReader.h"
|
|
|
|
|
2022-06-22 23:37:46 -04:00
|
|
|
#include "decompiler/ObjectFile/ObjectFileDB.h"
|
|
|
|
|
2024-03-05 22:11:52 -05:00
|
|
|
#include "fmt/core.h"
|
2022-06-22 23:37:46 -04:00
|
|
|
|
2021-01-06 20:04:15 -05:00
|
|
|
namespace decompiler {
|
2020-11-24 20:48:38 -05:00
|
|
|
GameCountResult process_game_count(ObjectFileData& data) {
|
|
|
|
GameCountResult result;
|
|
|
|
auto& words = data.linked_data.words_by_seg.at(0);
|
|
|
|
auto reader = LinkedWordReader(&words);
|
|
|
|
auto type = reader.get_type_tag();
|
2022-02-08 19:02:47 -05:00
|
|
|
ASSERT(type == "game-count-info");
|
2020-11-24 20:48:38 -05:00
|
|
|
auto length = reader.get_word<s32>();
|
|
|
|
|
|
|
|
for (s32 i = 0; i < length; i++) {
|
|
|
|
GameCountResult::CountInfo info;
|
|
|
|
info.money_count = reader.get_word<s32>();
|
|
|
|
info.buzzer_count = reader.get_word<s32>();
|
|
|
|
result.info.push_back(info);
|
|
|
|
}
|
|
|
|
|
|
|
|
result.mystery_data[0] = reader.get_word<u32>();
|
|
|
|
result.mystery_data[1] = reader.get_word<u32>();
|
2022-02-08 19:02:47 -05:00
|
|
|
ASSERT(reader.words_left() == 0);
|
2020-11-24 20:48:38 -05:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string write_game_count(const GameCountResult& result) {
|
|
|
|
std::string str;
|
|
|
|
str +=
|
|
|
|
";; this file contains money/buzzer counts for each level.\n;; The last pair is unknown data "
|
|
|
|
"and possibly a bug that it is included\n\n";
|
|
|
|
|
|
|
|
for (auto& x : result.info) {
|
|
|
|
str += fmt::format("(:money {} :buzzer {})\n", x.money_count, x.buzzer_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
str += fmt::format("(:unknown-1 {} :unknown-2 {})\n", result.mystery_data[0],
|
|
|
|
result.mystery_data[1]);
|
|
|
|
return str;
|
2021-01-06 20:04:15 -05:00
|
|
|
}
|
|
|
|
} // namespace decompiler
|