From 9b4c375741a77037358e28e4f431bbc5adde94f7 Mon Sep 17 00:00:00 2001 From: hatal175 Date: Wed, 27 Sep 2023 07:45:37 +0300 Subject: [PATCH] JGadget binary OK (#1944) --- include/JSystem/JGadget/binary.h | 8 +++ libs/JSystem/JGadget/binary.cpp | 97 +++++++++++++++++--------------- 2 files changed, 61 insertions(+), 44 deletions(-) diff --git a/include/JSystem/JGadget/binary.h b/include/JSystem/JGadget/binary.h index 59a36042828..26d29d1fbfc 100644 --- a/include/JSystem/JGadget/binary.h +++ b/include/JSystem/JGadget/binary.h @@ -50,6 +50,14 @@ struct TParse_header_block { bool parse(const void* ppData_inout, u32 a2) { return parse_next(&ppData_inout, a2); } + + bool checkNext(const void** ptrLocation, u32* headerEnd, u32 idx) { + bool checkNext = false; + if (parseHeader_next(ptrLocation, headerEnd, idx)) { + checkNext = true; + } + return checkNext; + } }; template diff --git a/libs/JSystem/JGadget/binary.cpp b/libs/JSystem/JGadget/binary.cpp index 50d5fb29eb6..7e8acfd7bc3 100644 --- a/libs/JSystem/JGadget/binary.cpp +++ b/libs/JSystem/JGadget/binary.cpp @@ -6,59 +6,68 @@ #include "JSystem/JGadget/binary.h" #include "dolphin/types.h" -// -// Forward References: -// - -extern "C" void -parseVariableUInt_16_32_following__Q27JGadget6binaryFPCvPUlPUlPQ37JGadget6binary5TEBit(); -extern "C" void __dt__Q37JGadget6binary19TParse_header_blockFv(); -extern "C" void parse_next__Q37JGadget6binary19TParse_header_blockFPPCvUl(); - -// -// External References: -// - -extern "C" void __dl__FPv(); -extern "C" void _savegpr_26(); -extern "C" void _restgpr_26(); -extern "C" extern void* __vt__Q37JGadget6binary19TParse_header_block[5]; - -// -// Declarations: -// - /* 802DC864-802DC8C8 2D71A4 0064+00 0/0 2/2 0/0 .text * parseVariableUInt_16_32_following__Q27JGadget6binaryFPCvPUlPUlPQ37JGadget6binary5TEBit */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm const void* -JGadget::binary::parseVariableUInt_16_32_following(void const* param_0, u32* param_1, u32* param_2, +const void* +JGadget::binary::parseVariableUInt_16_32_following(void const* buffer, u32* param_1, u32* param_2, JGadget::binary::TEBit* param_3) { - nofralloc -#include "asm/JSystem/JGadget/binary/parseVariableUInt_16_32_following__Q27JGadget6binaryFPCvPUlPUlPQ37JGadget6binary5TEBit.s" + JGadget::binary::TEBit temp; + if (param_3 == NULL) { + param_3 = &temp; + } + u32 uVar1 = *(u16*)buffer; + const void* rv; + if ((uVar1 & 0x8000) == 0) { + param_3->value = 0x10; + *param_1 = uVar1; + *param_2 = *(u16*)((u8*)buffer + 2); + rv = (u8*)buffer + 4; + } else { + param_3->value = 0x20; + uVar1 <<= 16; + uVar1 &= 0x7fff0000; + uVar1 |= *(u16*)((u8*)buffer + 2); + *param_1 = uVar1; + *param_2 = *(u32*)((u8*)buffer + 4); + rv = (u8*)buffer + 8; + } + return rv; } -#pragma pop + /* 802DC8C8-802DC910 2D7208 0048+00 0/0 4/4 0/0 .text * __dt__Q37JGadget6binary19TParse_header_blockFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm JGadget::binary::TParse_header_block::~TParse_header_block() { - nofralloc -#include "asm/JSystem/JGadget/binary/__dt__Q37JGadget6binary19TParse_header_blockFv.s" +JGadget::binary::TParse_header_block::~TParse_header_block() { } -#pragma pop /* 802DC910-802DCA1C 2D7250 010C+00 0/0 9/9 0/0 .text * parse_next__Q37JGadget6binary19TParse_header_blockFPPCvUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm bool JGadget::binary::TParse_header_block::parse_next(void const** param_0, u32 param_1) { - nofralloc -#include "asm/JSystem/JGadget/binary/parse_next__Q37JGadget6binary19TParse_header_blockFPPCvUl.s" +bool JGadget::binary::TParse_header_block::parse_next(void const** ptrLocation, u32 idx) { + u32 headerEnd, blockEnd; + + if ((ptrLocation == NULL) || (*ptrLocation == NULL)) { + return false; + } + bool check, checkLastBlock; + checkLastBlock = check = false; + + check = checkNext(ptrLocation, &headerEnd, idx); + + checkLastBlock = check; + if (!(idx & 1) && (check == false)) { + return check; + } + + while (headerEnd > 0) { + check = false; + if (parseBlock_next(ptrLocation, &blockEnd, idx) && checkLastBlock) { + check = true; + } + checkLastBlock = check; + if (((idx & 2) == 0) && (check == false)) { + return check; + } + headerEnd--; + } + return checkLastBlock; } -#pragma pop