add BattleParamEntry debug functions

This commit is contained in:
Martin Michelsen
2023-03-03 23:17:08 -08:00
parent 3418afcc66
commit a35d835f31
2 changed files with 54 additions and 1 deletions
+49
View File
@@ -4,11 +4,60 @@
#include <phosg/Strings.hh>
#include "Loggers.hh"
#include "StaticGameData.hh"
using namespace std;
string BattleParamsIndex::Entry::str() const {
string a1str = format_data_string(this->unknown_a1.data(), this->unknown_a1.bytes());
return string_printf(
"BattleParamsEntry[ATP=%hu PSV=%hu EVP=%hu HP=%hu DFP=%hu ATA=%hu LCK=%hu ESP=%hu a1=%s EXP=%" PRIu32 " diff=%" PRIu32 "]",
this->atp.load(),
this->psv.load(),
this->evp.load(),
this->hp.load(),
this->dfp.load(),
this->ata.load(),
this->lck.load(),
this->esp.load(),
a1str.c_str(),
this->experience.load(),
this->difficulty.load());
}
void BattleParamsIndex::Table::print(FILE* stream) const {
auto print_entry = +[](FILE* stream, const Entry& e) {
string a1str = format_data_string(e.unknown_a1.data(), e.unknown_a1.bytes());
fprintf(stream,
"%5hu %5hu %5hu %5hu %5hu %5hu %5hu %5hu %s %5" PRIu32 " %5" PRIu32,
e.atp.load(),
e.psv.load(),
e.evp.load(),
e.hp.load(),
e.dfp.load(),
e.ata.load(),
e.lck.load(),
e.esp.load(),
a1str.c_str(),
e.experience.load(),
e.difficulty.load());
};
for (size_t diff = 0; diff < 4; diff++) {
fprintf(stream, "%c ZZ ATP PSV EVP HP DFP ATA LCK ESP A1 EXP DIFF\n",
abbreviation_for_difficulty(diff));
for (size_t z = 0; z < 0x60; z++) {
fprintf(stream, " %02zX ", z);
print_entry(stream, this->difficulty[diff][z]);
fputc('\n', stream);
}
}
}
BattleParamsIndex::BattleParamsIndex(
shared_ptr<const string> data_on_ep1,
shared_ptr<const string> data_on_ep2,
+5 -1
View File
@@ -23,13 +23,17 @@ public:
le_uint16_t ata; // accuracy
le_uint16_t lck; // luck
le_uint16_t esp; // ???
uint8_t unknown_a1[0x0C];
parray<uint8_t, 0x0C> unknown_a1;
le_uint32_t experience;
le_uint32_t difficulty;
std::string str() const;
} __attribute__((packed));
struct Table {
parray<parray<Entry, 0x60>, 4> difficulty;
void print(FILE* stream) const;
} __attribute__((packed));
BattleParamsIndex(