From f269d58d12bdfcf44d7d35fe1a86d783dc3079a1 Mon Sep 17 00:00:00 2001 From: LuigiBlood Date: Fri, 4 Aug 2023 19:46:14 +0200 Subject: [PATCH 1/2] define block_param_form struct & LEOc2_param & LEOC2_Syndrome --- include/libleo/internal.h | 9 +++++++++ src/libleo/leoc2ecc.c | 10 ++++++---- src/libleo/leoint.c | 1 + tools/symbol_addrs.txt | 1 + 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/libleo/internal.h b/include/libleo/internal.h index 2c81cb6a..814f69ac 100644 --- a/include/libleo/internal.h +++ b/include/libleo/internal.h @@ -15,6 +15,15 @@ typedef struct { /* 0xA */ u8 start_block; } tgt_param_form; // size = 0xC +typedef struct { + /* 0x00 */ u8* pntr; + /* 0x04 */ u8* c2buff_e; + /* 0x08 */ u8 err_pos[4]; + /* 0x0C */ u8 err_num; + /* 0x0D */ u8 bytes; + /* 0x0E */ u16 blkbytes; +} block_param_form; // size = 0x10 + typedef union { /* 0x00 */ struct { /* 0x00 */ u32 country; diff --git a/src/libleo/leoc2ecc.c b/src/libleo/leoc2ecc.c index 5aee5bb6..6939249e 100644 --- a/src/libleo/leoc2ecc.c +++ b/src/libleo/leoc2ecc.c @@ -1,17 +1,19 @@ -#include "common.h" +#include +#include "libleo/internal.h" //Tables to add here extern u8 ganlog[512]; extern u8 glog[512]; -//To be determined, should be a struct -extern u8 LEOc2_param[16]; + +extern block_param_form LEOc2_param; +extern u8 LEOC2_Syndrome[2][0xE8*4]; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunknown-pragmas" #ifdef NON_MATCHING s32 leoC2_Correction(void) { - switch (LEOc2_param[12]) { + switch (LEOc2_param.err_num) { case 1: leoC2_single_ecc(); return 0; diff --git a/src/libleo/leoint.c b/src/libleo/leoint.c index 70c52dd9..54563852 100644 --- a/src/libleo/leoint.c +++ b/src/libleo/leoint.c @@ -2,6 +2,7 @@ #include "libleo/internal.h" extern vu16 LEOrw_flags; +extern u8 LEOC2_Syndrome[2][0xE8*4]; void* read_write_track(); diff --git a/tools/symbol_addrs.txt b/tools/symbol_addrs.txt index 7f2b70b1..de4c4c5b 100644 --- a/tools/symbol_addrs.txt +++ b/tools/symbol_addrs.txt @@ -143,6 +143,7 @@ LEOdisk_type = 0x801006D8; LEO_country_code = 0x801006EC; LEOrw_flags = 0x801006D6; LEOc2_param = 0x80101080; +LEOC2_Syndrome = 0x80100940; leoC2_Correction = 0x80053710; leoC2_single_ecc = 0x8005379C; leoC2_double_ecc = 0x80053870; From 97f31ca2a7d19e7e32b8028c2c7b2763a14e7ed8 Mon Sep 17 00:00:00 2001 From: LuigiBlood Date: Sat, 5 Aug 2023 00:11:20 +0200 Subject: [PATCH 2/2] leoC2_single_ecc match --- src/libleo/leoc2ecc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libleo/leoc2ecc.c b/src/libleo/leoc2ecc.c index 6939249e..f0a3f03b 100644 --- a/src/libleo/leoc2ecc.c +++ b/src/libleo/leoc2ecc.c @@ -36,7 +36,21 @@ s32 leoC2_Correction(void) { #pragma GLOBAL_ASM("asm/nonmatchings/libleo/leoc2ecc/leoC2_Correction.s") #endif -#pragma GLOBAL_ASM("asm/nonmatchings/libleo/leoc2ecc/leoC2_single_ecc.s") +void leoC2_single_ecc(void) { + u8* pointer; + u32 byte; + u8* p_s; + + if (LEOc2_param.err_pos[0] < 0x55) { + byte = LEOc2_param.bytes; + pointer = &LEOc2_param.pntr[(LEOc2_param.err_pos[0] + 1) * byte]; + p_s = LEOc2_param.c2buff_e; + + do { + *(--pointer) ^= *(p_s -= 4); + } while(--byte != 0); + } +} #pragma GLOBAL_ASM("asm/nonmatchings/libleo/leoc2ecc/leoC2_double_ecc.s")