jak3: subtitle3, vag-player (#3758)

This commit is contained in:
Hat Kid
2024-11-12 02:45:16 +01:00
committed by GitHub
parent b55a918902
commit af5cb9b1cb
48 changed files with 12292 additions and 126 deletions
+1 -1
View File
@@ -375,7 +375,7 @@ void InitMachine_PCPort() {
make_function_symbol_from_c("pc-discord-rpc-update", (void*)kmachine_extras::update_discord_rpc);
// debugging tools
// make_function_symbol_from_c("alloc-vagdir-names", (void*)alloc_vagdir_names);
make_function_symbol_from_c("alloc-vagdir-names", (void*)kmachine_extras::alloc_vagdir_names);
// external RPCs
/*
+42
View File
@@ -12,9 +12,11 @@
#include "game/kernel/common/Symbol4.h"
#include "game/kernel/common/kmachine.h"
#include "game/kernel/common/kscheme.h"
#include "game/overlord/jak3/iso_cd.h"
namespace jak3 {
namespace kmachine_extras {
using namespace jak3;
void update_discord_rpc(u32 discord_info) {
if (gDiscordRpcEnabled) {
@@ -175,6 +177,46 @@ void pc_set_active_levels(u32 lev_list) {
Gfx::GetCurrentRenderer()->set_active_levels(levels);
}
static std::string unpack_vag_name_jak3(u64 compressed) {
const char* char_map = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-";
u32 chars = compressed & 0x1fffff;
std::array<char, 9> buf{};
buf.fill(0);
for (int i = 0; i < 8; i++) {
if (i == 4) {
chars = (compressed >> 21) & 0x1fffff;
}
buf[7 - i] = char_map[chars % 38];
chars /= 38;
}
return {buf.data()};
}
u32 alloc_vagdir_names(u32 heap_sym) {
auto alloced_heap = (Ptr<u64>)alloc_heap_memory(heap_sym, g_VagDir.num_entries * 8 + 8);
if (alloced_heap.offset) {
*alloced_heap = g_VagDir.num_entries;
// use entry -1 to get the amount
alloced_heap = alloced_heap + 8;
for (size_t i = 0; i < g_VagDir.num_entries; ++i) {
char vagname_temp[9];
u64 packed = *(u64*)g_VagDir.entries[i].words;
auto name = unpack_vag_name_jak3(packed).data();
memcpy(vagname_temp, name, 8);
for (int j = 0; j < 8; ++j) {
vagname_temp[j] = tolower(vagname_temp[j]);
}
vagname_temp[8] = 0;
u64 vagname_val;
memcpy(&vagname_val, vagname_temp, 8);
*(alloced_heap + i * 8) = vagname_val;
}
return alloced_heap.offset;
}
return s7.offset;
}
inline u64 bool_to_symbol(const bool val) {
return val ? static_cast<u64>(s7.offset) + true_symbol_offset(g_game_version) : s7.offset;
}
+1
View File
@@ -60,6 +60,7 @@ Ptr<Type> intern_type_from_c(int a, int b, const char* name, u64 methods);
u64 alloc_heap_object(u32 heap, u32 type, u32 size, u32 pp);
int InitHeapAndSymbol();
u64 call_method_of_type_arg2(u32 arg, Ptr<Type> type, u32 method_id, u32 a1, u32 a2);
u64 alloc_heap_memory(u32 heap, u32 size);
template <typename T>
Ptr<Ptr<String>> sym_to_string_ptr(Ptr<Symbol4<T>> in) {
return Ptr<Ptr<String>>(SymbolString.offset + in.offset - s7.offset);