mirror of
https://github.com/open-goal/jak-project
synced 2026-05-23 15:02:01 -04:00
d3cc739e43
This attempts to get into master whatever work was done in this PR / it's earlier PR https://github.com/open-goal/jak-project/pull/3965 I don't want this work to be lost / floating around in massive PRs. However the changes are: - switch to ntsc_v1 instead of PAL as the development target, as we have done for all other games - remove most of the copied-from-jak2/3 changes as they need to be confirmed during the decompilation process not just assumed - avoids committing any changes to `game/kernel/common` as it was not clear to me if these were changes made in jak x's kernel that were not properly broken out into it's own functions. We don't want to accidentally introduce bugs into jak1-3's kernel code. - in other words, if the change in the kernel only happens in jak x...it should likely be specific to jak x's kernel, not common. --------- Co-authored-by: VodBox <dillon@vodbox.io> Co-authored-by: yodah <greenboyyodah@gmail.com>
57 lines
1.6 KiB
C++
57 lines
1.6 KiB
C++
#include "dir_tpages.h"
|
|
|
|
#include "decompiler/ObjectFile/ObjectFileDB.h"
|
|
|
|
#include "fmt/format.h"
|
|
|
|
namespace decompiler {
|
|
std::string DirTpageResult::to_source() const {
|
|
std::string result;
|
|
int i = 0;
|
|
for (auto len : lengths) {
|
|
result += fmt::format(" {:6s} ;; entry {}\n", fmt::format("#x{:x}", len), i);
|
|
i++;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
DirTpageResult process_dir_tpages(ObjectFileData& data) {
|
|
DirTpageResult result;
|
|
|
|
auto& words = data.linked_data.words_by_seg.at(0);
|
|
|
|
int word_idx = 0;
|
|
// first is type
|
|
ASSERT(words.at(word_idx).kind() == LinkedWord::TYPE_PTR);
|
|
ASSERT(words.at(word_idx).symbol_name() == "texture-page-dir");
|
|
word_idx++;
|
|
// next is length
|
|
ASSERT(words.at(word_idx).kind() == LinkedWord::PLAIN_DATA);
|
|
int dir_length = words.at(word_idx).data;
|
|
word_idx++;
|
|
|
|
for (int i = 0; i < dir_length; i++) {
|
|
ASSERT(words.at(word_idx).kind() == LinkedWord::PLAIN_DATA);
|
|
u32 entry = words.at(word_idx).data;
|
|
ASSERT((entry & 0xffff7000) == 0); // 7 checks for sign bit.
|
|
word_idx++;
|
|
result.lengths.push_back(entry & 0xffff);
|
|
|
|
ASSERT(words.at(word_idx).kind() == LinkedWord::SYM_PTR);
|
|
ASSERT(words.at(word_idx).symbol_name() == "#f");
|
|
word_idx++;
|
|
ASSERT(words.at(word_idx).kind() == LinkedWord::SYM_PTR);
|
|
ASSERT(words.at(word_idx).symbol_name() == "#f");
|
|
word_idx++;
|
|
}
|
|
|
|
if (data.linked_data.version != GameVersion::Jak3 &&
|
|
data.linked_data.version != GameVersion::JakX) {
|
|
word_idx = ((word_idx + 3) / 4) * 4;
|
|
}
|
|
ASSERT(word_idx == (int)words.size());
|
|
|
|
return result;
|
|
}
|
|
} // namespace decompiler
|