Patch matching BB battle param tables with raw HP diffs
This commit is contained in:
+18
-13
@@ -847,7 +847,6 @@ static std::shared_ptr<AsyncPromise<C_ExecuteCodeResult_B3>> send_brutal_peeps_h
|
|||||||
constexpr uint32_t scan_start = 0x16760000;
|
constexpr uint32_t scan_start = 0x16760000;
|
||||||
constexpr uint32_t scan_end = 0x16A90000;
|
constexpr uint32_t scan_end = 0x16A90000;
|
||||||
constexpr uint32_t signature_size = 64;
|
constexpr uint32_t signature_size = 64;
|
||||||
constexpr uint32_t hp_patch_bytes = 0x60 * 2;
|
|
||||||
|
|
||||||
if (bp_entry->size < signature_size) {
|
if (bp_entry->size < signature_size) {
|
||||||
c->log.warning_f("Skipping Brutal Peeps HP client patch: BattleParamEntry_on.dat too small for signature");
|
c->log.warning_f("Skipping Brutal Peeps HP client patch: BattleParamEntry_on.dat too small for signature");
|
||||||
@@ -865,21 +864,27 @@ static std::shared_ptr<AsyncPromise<C_ExecuteCodeResult_B3>> send_brutal_peeps_h
|
|||||||
append_u32l(suffix, scan_start);
|
append_u32l(suffix, scan_start);
|
||||||
append_u32l(suffix, scan_end);
|
append_u32l(suffix, scan_end);
|
||||||
append_u32l(suffix, signature_size);
|
append_u32l(suffix, signature_size);
|
||||||
append_u32l(suffix, hp_patch_bytes);
|
append_u32l(suffix, 0); // patched below after diff generation
|
||||||
suffix.append(vanilla_data, signature_size);
|
suffix.append(vanilla_data, signature_size);
|
||||||
|
|
||||||
for (size_t z = 0; z < 0x60; z++) {
|
uint32_t patch_entry_count = 0;
|
||||||
const auto& hp = table->stats[ultimate_index][z].char_stats.hp;
|
for (uint32_t offset = 0; offset < target_data.size(); offset++) {
|
||||||
uint32_t hp_offset = reinterpret_cast<const char*>(&hp) - target_data.data();
|
uint8_t old_byte = static_cast<uint8_t>(vanilla_data[offset]);
|
||||||
const uint8_t* hp_bytes = reinterpret_cast<const uint8_t*>(&hp);
|
uint8_t new_byte = static_cast<uint8_t>(target_data[offset]);
|
||||||
|
if (old_byte == new_byte) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
append_u32l(suffix, hp_offset);
|
append_u32l(suffix, offset);
|
||||||
suffix.push_back(static_cast<char>(hp_bytes[0]));
|
suffix.push_back(static_cast<char>(new_byte));
|
||||||
|
patch_entry_count++;
|
||||||
append_u32l(suffix, hp_offset + 1);
|
|
||||||
suffix.push_back(static_cast<char>(hp_bytes[1]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suffix[12] = static_cast<char>(patch_entry_count & 0xFF);
|
||||||
|
suffix[13] = static_cast<char>((patch_entry_count >> 8) & 0xFF);
|
||||||
|
suffix[14] = static_cast<char>((patch_entry_count >> 16) & 0xFF);
|
||||||
|
suffix[15] = static_cast<char>((patch_entry_count >> 24) & 0xFF);
|
||||||
|
|
||||||
auto fn = s->client_functions->get("PsoPeepsBrutalPeepsHP", c->specific_version);
|
auto fn = s->client_functions->get("PsoPeepsBrutalPeepsHP", c->specific_version);
|
||||||
|
|
||||||
auto promise = std::make_shared<AsyncPromise<C_ExecuteCodeResult_B3>>();
|
auto promise = std::make_shared<AsyncPromise<C_ExecuteCodeResult_B3>>();
|
||||||
@@ -895,8 +900,8 @@ static std::shared_ptr<AsyncPromise<C_ExecuteCodeResult_B3>> send_brutal_peeps_h
|
|||||||
|
|
||||||
c->enabled_flags |= fn->client_flag;
|
c->enabled_flags |= fn->client_flag;
|
||||||
|
|
||||||
c->log.info_f("Brutal Peeps HP client patch sent: tier={} mult={:g} patch_bytes={} scan={:08X}-{:08X}",
|
c->log.info_f("Brutal Peeps HP client patch sent: tier={} mult={:g} patch_entries={} scan={:08X}-{:08X}",
|
||||||
tier, mult, hp_patch_bytes, scan_start, scan_end);
|
tier, mult, patch_entry_count, scan_start, scan_end);
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
|
|
||||||
|
|||||||
@@ -14,23 +14,24 @@ start:
|
|||||||
push esi
|
push esi
|
||||||
push edi
|
push edi
|
||||||
push ebp
|
push ebp
|
||||||
|
push 0 # [esp] = last matched table base / 0
|
||||||
|
|
||||||
jmp get_data_ptr
|
jmp get_data_ptr
|
||||||
|
|
||||||
get_data_ptr_ret:
|
get_data_ptr_ret:
|
||||||
pop ebx # ebx = suffix payload
|
pop ebx # ebx = suffix payload
|
||||||
|
|
||||||
mov esi, [ebx] # scan_start
|
mov esi, [ebx] # scan_start
|
||||||
mov edx, [ebx + 4] # scan_end
|
|
||||||
mov ecx, [ebx + 8] # signature_size
|
|
||||||
sub edx, ecx # scan limit = end - sig_size
|
|
||||||
lea edi, [ebx + 16] # signature ptr
|
|
||||||
|
|
||||||
scan_again:
|
scan_again:
|
||||||
|
mov edx, [ebx + 4] # scan_end
|
||||||
|
mov ecx, [ebx + 8] # signature_size
|
||||||
|
sub edx, ecx # scan limit = end - sig_size
|
||||||
cmp esi, edx
|
cmp esi, edx
|
||||||
ja not_found
|
ja return
|
||||||
|
|
||||||
xor ebp, ebp
|
xor ebp, ebp
|
||||||
|
lea edi, [ebx + 16] # signature ptr
|
||||||
|
|
||||||
compare_again:
|
compare_again:
|
||||||
cmp ebp, ecx
|
cmp ebp, ecx
|
||||||
@@ -48,32 +49,32 @@ next_candidate:
|
|||||||
jmp scan_again
|
jmp scan_again
|
||||||
|
|
||||||
found_table:
|
found_table:
|
||||||
# esi = BattleParamEntry_on.dat base
|
# esi = one matching BattleParam table base
|
||||||
mov ecx, [ebx + 12] # patch entry count
|
mov [esp], esi # remember last match for return_value
|
||||||
mov edi, [ebx + 8] # signature_size
|
|
||||||
add edi, ebx
|
mov ecx, [ebx + 12] # patch entry count
|
||||||
add edi, 16 # patch entries after header+signature
|
mov edi, [ebx + 8] # signature_size
|
||||||
|
lea edi, [ebx + edi + 16] # patch entries after header+signature
|
||||||
|
|
||||||
patch_again:
|
patch_again:
|
||||||
test ecx, ecx
|
test ecx, ecx
|
||||||
jz done
|
jz after_patch
|
||||||
|
|
||||||
mov edx, [edi] # offset from table base
|
mov edx, [edi] # offset from table base
|
||||||
mov al, [edi + 4] # byte value
|
mov al, [edi + 4] # byte value
|
||||||
mov [esi + edx], al
|
mov [esi + edx], al
|
||||||
|
|
||||||
add edi, 5
|
add edi, 5
|
||||||
dec ecx
|
dec ecx
|
||||||
jmp patch_again
|
jmp patch_again
|
||||||
|
|
||||||
done:
|
after_patch:
|
||||||
mov eax, esi # return found table base
|
inc esi # continue scanning after this match
|
||||||
jmp return
|
jmp scan_again
|
||||||
|
|
||||||
not_found:
|
|
||||||
xor eax, eax
|
|
||||||
|
|
||||||
return:
|
return:
|
||||||
|
mov eax, [esp] # 0 if none found, else last matched base
|
||||||
|
add esp, 4
|
||||||
pop ebp
|
pop ebp
|
||||||
pop edi
|
pop edi
|
||||||
pop esi
|
pop esi
|
||||||
|
|||||||
Reference in New Issue
Block a user