diff options
| author | 2019-06-06 19:20:15 -0400 | |
|---|---|---|
| committer | 2019-06-06 19:20:15 -0400 | |
| commit | 9db119f8a2e5a4d877f00b9efb40e4a109c95ef7 (patch) | |
| tree | 9d30248278656913599b01dd0fc70a3b0e7e7e24 /src | |
| parent | game_list: Accept *.kip as a file extension of executables (diff) | |
| download | yuzu-9db119f8a2e5a4d877f00b9efb40e4a109c95ef7.tar.gz yuzu-9db119f8a2e5a4d877f00b9efb40e4a109c95ef7.tar.xz yuzu-9db119f8a2e5a4d877f00b9efb40e4a109c95ef7.zip | |
kernel_executable: Optimize BLZ decompression
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/kernel_executable.cpp | 11 | ||||
| -rw-r--r-- | src/core/loader/kip.cpp | 12 |
2 files changed, 13 insertions, 10 deletions
diff --git a/src/core/file_sys/kernel_executable.cpp b/src/core/file_sys/kernel_executable.cpp index 45cbde4c9..371300684 100644 --- a/src/core/file_sys/kernel_executable.cpp +++ b/src/core/file_sys/kernel_executable.cpp | |||
| @@ -34,7 +34,7 @@ bool DecompressBLZ(std::vector<u8>& data) { | |||
| 34 | --index; | 34 | --index; |
| 35 | auto control = data[index + start_offset]; | 35 | auto control = data[index + start_offset]; |
| 36 | for (size_t i = 0; i < 8; ++i) { | 36 | for (size_t i = 0; i < 8; ++i) { |
| 37 | if ((control & 0x80) > 0) { | 37 | if (((control << i) & 0x80) > 0) { |
| 38 | if (index < 2) { | 38 | if (index < 2) { |
| 39 | return false; | 39 | return false; |
| 40 | } | 40 | } |
| @@ -70,9 +70,8 @@ bool DecompressBLZ(std::vector<u8>& data) { | |||
| 70 | data[out_index + start_offset] = data[index + start_offset]; | 70 | data[out_index + start_offset] = data[index + start_offset]; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | control <<= 1; | ||
| 74 | if (out_index == 0) | 73 | if (out_index == 0) |
| 75 | return true; | 74 | break; |
| 76 | } | 75 | } |
| 77 | } | 76 | } |
| 78 | 77 | ||
| @@ -132,15 +131,15 @@ std::vector<u8> KIP::GetSectionDecompressed(u8 index) const { | |||
| 132 | } | 131 | } |
| 133 | 132 | ||
| 134 | bool KIP::Is64Bit() const { | 133 | bool KIP::Is64Bit() const { |
| 135 | return header.flags & 0x8; | 134 | return (header.flags & 0x8) != 0; |
| 136 | } | 135 | } |
| 137 | 136 | ||
| 138 | bool KIP::Is39BitAddressSpace() const { | 137 | bool KIP::Is39BitAddressSpace() const { |
| 139 | return header.flags & 0x10; | 138 | return (header.flags & 0x10) != 0; |
| 140 | } | 139 | } |
| 141 | 140 | ||
| 142 | bool KIP::IsService() const { | 141 | bool KIP::IsService() const { |
| 143 | return header.flags & 0x20; | 142 | return (header.flags & 0x20) != 0; |
| 144 | } | 143 | } |
| 145 | 144 | ||
| 146 | std::vector<u32> KIP::GetKernelCapabilities() const { | 145 | std::vector<u32> KIP::GetKernelCapabilities() const { |
diff --git a/src/core/loader/kip.cpp b/src/core/loader/kip.cpp index 2efd14f04..70051c13a 100644 --- a/src/core/loader/kip.cpp +++ b/src/core/loader/kip.cpp | |||
| @@ -53,10 +53,14 @@ AppLoader::LoadResult AppLoader_KIP::Load(Kernel::Process& process) { | |||
| 53 | return {kip->GetStatus(), {}}; | 53 | return {kip->GetStatus(), {}}; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | const auto address_space = | 56 | const auto get_kip_address_space_type = [](const auto& kip) { |
| 57 | kip->Is64Bit() ? (kip->Is39BitAddressSpace() ? FileSys::ProgramAddressSpaceType::Is39Bit | 57 | return kip.Is64Bit() |
| 58 | : FileSys::ProgramAddressSpaceType::Is36Bit) | 58 | ? (kip.Is39BitAddressSpace() ? FileSys::ProgramAddressSpaceType::Is39Bit |
| 59 | : FileSys::ProgramAddressSpaceType::Is32Bit; | 59 | : FileSys::ProgramAddressSpaceType::Is36Bit) |
| 60 | : FileSys::ProgramAddressSpaceType::Is32Bit; | ||
| 61 | }; | ||
| 62 | |||
| 63 | const auto address_space = get_kip_address_space_type(*kip); | ||
| 60 | 64 | ||
| 61 | FileSys::ProgramMetadata metadata; | 65 | FileSys::ProgramMetadata metadata; |
| 62 | metadata.LoadManual(kip->Is64Bit(), address_space, kip->GetMainThreadPriority(), | 66 | metadata.LoadManual(kip->Is64Bit(), address_space, kip->GetMainThreadPriority(), |