Skip to content

Commit

Permalink
Support latest update (Trails series)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhenjianYang committed Jan 19, 2022
1 parent cbf599a commit 5d4e469
Show file tree
Hide file tree
Showing 12 changed files with 475 additions and 66 deletions.
2 changes: 2 additions & 0 deletions solution/ed_voice/ed_voice.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<ItemGroup>
<ClCompile Include="..\..\src\ed_voice\asm\asm_sora.cpp" />
<ClCompile Include="..\..\src\ed_voice\asm\asm_tits.cpp" />
<ClCompile Include="..\..\src\ed_voice\asm\asm_titsl.cpp" />
<ClCompile Include="..\..\src\ed_voice\asm\asm_za.cpp" />
<ClCompile Include="..\..\src\ed_voice\bridge\bridge.cpp" />
<ClCompile Include="..\..\src\ed_voice\bridge\bridge_dat.cpp" />
Expand All @@ -72,6 +73,7 @@
<ClCompile Include="..\..\src\ed_voice\startup\scan_group.cpp" />
<ClCompile Include="..\..\src\ed_voice\startup\scan_group_sora.cpp" />
<ClCompile Include="..\..\src\ed_voice\startup\scan_group_tits.cpp" />
<ClCompile Include="..\..\src\ed_voice\startup\scan_group_titsl.cpp" />
<ClCompile Include="..\..\src\ed_voice\startup\scan_group_za.cpp" />
<ClCompile Include="..\..\src\ed_voice\startup\startup.cpp" />
<ClCompile Include="..\..\src\ed_voice\startup\string_patch.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions solution/ed_voice/ed_voice.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,11 @@
<ClCompile Include="..\..\src\ed_voice\player\decoder.cpp">
<Filter>src\player</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ed_voice\asm\asm_titsl.cpp">
<Filter>src\asm</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ed_voice\startup\scan_group_titsl.cpp">
<Filter>src\startup</Filter>
</ClCompile>
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions src/ed_voice/asm/asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ void textse();
void dlgse();
} // namespace asm_tits

namespace asm_titsl {
void text();
void ldat();
void dcdat();
void textse();
void dlgse();
} // namespace asm_titsl

namespace asm_sora {
void text();
void ldat();
Expand Down
34 changes: 19 additions & 15 deletions src/ed_voice/asm/asm_tits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ __declspec(naked) void asm_tits::text() {
jmp common

fc:
push ebx
push esi

common:
call bridge::Play
Expand All @@ -28,8 +28,12 @@ __declspec(naked) void asm_tits::text() {

__declspec(naked) void asm_tits::ldat() {
__asm {
call bridge::LoadDat
push edx
push ecx
call bridge::LoadDatF
test eax, eax
pop ecx
pop edx
je short next
ret

Expand All @@ -40,12 +44,14 @@ __declspec(naked) void asm_tits::ldat() {

__declspec(naked) void asm_tits::dcdat() {
__asm {
push edi
push ebx
pushad
push edx
push ecx
push 0
call bridge::DecompressDat
add esp, 12
test eax, eax
popad
je short next
ret

Expand All @@ -69,22 +75,20 @@ __declspec(naked) void asm_tits::textse() {

__declspec(naked) void asm_tits::dlgse() {
__asm {
pushad
call bridge::Stop
popad

cmp dword ptr[global.sigs.no_dlgse], 0
je short next
je short jump
mov dword ptr[global.sigs.no_dlgse], 0
cmp dword ptr[global.config.disable_dialog_se], 0
je short next
je short jump

pushad
call bridge::Stop
popad
jmp dword ptr[global.addrs.dlgse_jmp]
ret

next :
pushad
call bridge::Stop
popad
jmp dword ptr[global.addrs.dlgse_next]
jump :
jmp dword ptr[global.addrs.dlgse_jmp]
}
}

90 changes: 90 additions & 0 deletions src/ed_voice/asm/asm_titsl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#include "asm/asm.h"
#include "bridge/bridge.h"
#include "global/global.h"

__declspec(naked) void asm_titsl::text() {
__asm {
jne short next
pushad

cmp dword ptr[global.info.game], GameTitsFC
je short fc
push edi
jmp common

fc:
push ebx

common:
call bridge::Play

popad
jmp dword ptr[global.addrs.text_next]

next :
jmp dword ptr[global.addrs.text_jmp]
}
}

__declspec(naked) void asm_titsl::ldat() {
__asm {
call bridge::LoadDat
test eax, eax
je short next
ret

next :
jmp dword ptr[global.addrs.ldat_next];
}
}

__declspec(naked) void asm_titsl::dcdat() {
__asm {
push edi
push ebx
push 0
call bridge::DecompressDat
add esp, 12
test eax, eax
je short next
ret

next :
jmp dword ptr[global.addrs.dcdat_next]
}
}

__declspec(naked) void asm_titsl::textse() {
__asm {
cmp dword ptr[global.sigs.no_textse], 0
je short next
cmp dword ptr[global.config.disable_text_se], 0
je short next
jmp dword ptr[global.addrs.textse_jmp]

next :
jmp dword ptr[global.addrs.textse_next]
}
}

__declspec(naked) void asm_titsl::dlgse() {
__asm {
cmp dword ptr[global.sigs.no_dlgse], 0
je short next
mov dword ptr[global.sigs.no_dlgse], 0
cmp dword ptr[global.config.disable_dialog_se], 0
je short next

pushad
call bridge::Stop
popad
jmp dword ptr[global.addrs.dlgse_jmp]

next :
pushad
call bridge::Stop
popad
jmp dword ptr[global.addrs.dlgse_next]
}
}

1 change: 1 addition & 0 deletions src/ed_voice/bridge/bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ int __stdcall Play(void* b);
int __cdecl Stop();

int __cdecl LoadDat(void*, void* buff, int idx, unsigned offset, unsigned size);
int __cdecl LoadDatF(void* buff, int idx, void*, unsigned offset, unsigned size);
int __cdecl LoadDat2(void*, void* buff, int idx);
int __cdecl DecompressDat(void*, void** uncompressed, void** compressed);

Expand Down
4 changes: 4 additions & 0 deletions src/ed_voice/bridge/bridge_dat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ inline const char* GetDir(int idx) {

} // namespace

int __cdecl bridge::LoadDatF(void* buff, int idx, void*, unsigned offset, unsigned size) {
return bridge::LoadDat(nullptr, buff, idx, offset, size);
}

int __cdecl bridge::LoadDat(void*, void* buff, int idx, unsigned offset, unsigned size) {
const char* dir = GetDir(idx);
if (!dir) {
Expand Down
23 changes: 7 additions & 16 deletions src/ed_voice/startup/scan_group_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class ScanGroupCommon : public ScanGroup {
strings_.push_back(std::make_unique<char[]>(kCodeBackupBlockSize));
code_bak_ = (byte*)strings_.back().get();
code_bak_remian = kCodeBackupBlockSize;
utils::MemProtection proction_bak;
utils::ChangeMemProtection(code_bak_, kCodeBackupBlockSize, utils::kMemProtectionRWE, &proction_bak);
}

bool InSection(const char* sec_name, byte* begin, std::size_t length) const {
Expand All @@ -83,7 +85,11 @@ class ScanGroupCommon : public ScanGroup {
return false;
}
const auto& sec = it->second;
return begin >= sec.start && begin + length <= sec.end;
if (length > sec.size) {
return false;
}
return (unsigned long long)begin >= (unsigned long long)sec.start
&& (unsigned long long)begin <= (unsigned long long)sec.end - length;
}

byte* GetCodeBackupBlock(std::size_t length) {
Expand Down Expand Up @@ -228,21 +234,6 @@ class ScanGroupCommon : public ScanGroup {
ScanGroupCommon& operator=(const ScanGroupCommon&) = delete;
}; // ScanGroupCommon

class PieceCommon : public ScanGroupCommon::BasicPiece {
public:
PieceCommon(std::string_view pattern, ScanGroupCommon::PatternType pattern_type,
ScanGroupCommon* group)
: ScanGroupCommon::BasicPiece(pattern, pattern_type), Group{ group } {
}

bool InSection(byte* p, std::size_t len) {

}

protected:
ScanGroupCommon* const Group;
};

} // namespace startup

#define DEFINE_GROUP_BEGIN(GroupName_) \
Expand Down
Loading

0 comments on commit 5d4e469

Please sign in to comment.