summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2014-09-06 20:06:14 +0200
committerbunnei <bunneidev@gmail.com>2014-09-06 20:06:14 +0200
commit272a201d129ff10fdf0189b4c84aae5801640b28 (patch)
tree8667a3bb9e56f610bef0aaa0c6a9202192954a64
parentMerge pull request #88 from archshift/remove-atomic (diff)
parentncch: Remove C-style struct typedefs (diff)
downloadyuzu-272a201d129ff10fdf0189b4c84aae5801640b28.tar
yuzu-272a201d129ff10fdf0189b4c84aae5801640b28.tar.gz
yuzu-272a201d129ff10fdf0189b4c84aae5801640b28.tar.bz2
yuzu-272a201d129ff10fdf0189b4c84aae5801640b28.tar.lz
yuzu-272a201d129ff10fdf0189b4c84aae5801640b28.tar.xz
yuzu-272a201d129ff10fdf0189b4c84aae5801640b28.tar.zst
yuzu-272a201d129ff10fdf0189b4c84aae5801640b28.zip
-rw-r--r--src/core/loader/ncch.cpp12
-rw-r--r--src/core/loader/ncch.h8
2 files changed, 9 insertions, 11 deletions
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index ba27eb75a..9af59e419 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -40,19 +40,17 @@ u32 LZSS_GetDecompressedSize(u8* buffer, u32 size) {
bool LZSS_Decompress(u8* compressed, u32 compressed_size, u8* decompressed, u32 decompressed_size) {
u8* footer = compressed + compressed_size - 8;
u32 buffer_top_and_bottom = *(u32*)footer;
- u32 i, j;
u32 out = decompressed_size;
u32 index = compressed_size - ((buffer_top_and_bottom >> 24) & 0xFF);
- u8 control;
u32 stop_index = compressed_size - (buffer_top_and_bottom & 0xFFFFFF);
memset(decompressed, 0, decompressed_size);
memcpy(decompressed, compressed, compressed_size);
while(index > stop_index) {
- control = compressed[--index];
+ u8 control = compressed[--index];
- for(i = 0; i < 8; i++) {
+ for(u32 i = 0; i < 8; i++) {
if(index <= stop_index)
break;
if(index <= 0)
@@ -76,13 +74,13 @@ bool LZSS_Decompress(u8* compressed, u32 compressed_size, u8* decompressed, u32
if(out < segment_size) {
return false;
}
- for(j = 0; j < segment_size; j++) {
- u8 data;
+ for(u32 j = 0; j < segment_size; j++) {
// Check if compression is out of bounds
if(out + segment_offset >= decompressed_size) {
return false;
}
- data = decompressed[out + segment_offset];
+
+ u8 data = decompressed[out + segment_offset];
decompressed[--out] = data;
}
} else {
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h
index 29b59aa11..f40a258b7 100644
--- a/src/core/loader/ncch.h
+++ b/src/core/loader/ncch.h
@@ -46,17 +46,17 @@ struct NCCH_Header {
////////////////////////////////////////////////////////////////////////////////////////////////////
// ExeFS (executable file system) headers
-typedef struct {
+struct ExeFs_SectionHeader {
char name[8];
u32 offset;
u32 size;
-} ExeFs_SectionHeader;
+};
-typedef struct {
+struct ExeFs_Header {
ExeFs_SectionHeader section[8];
u8 reserved[0x80];
u8 hashes[8][0x20];
-} ExeFs_Header;
+};
////////////////////////////////////////////////////////////////////////////////////////////////////
// ExHeader (executable file system header) headers