Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libleo #61

Merged
merged 2 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions include/libleo/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 21 additions & 5 deletions src/libleo/leoc2ecc.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#include "common.h"
#include <ultra64.h>
#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;
Expand All @@ -34,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")

Expand Down
1 change: 1 addition & 0 deletions src/libleo/leoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "libleo/internal.h"

extern vu16 LEOrw_flags;
extern u8 LEOC2_Syndrome[2][0xE8*4];

void* read_write_track();

Expand Down
1 change: 1 addition & 0 deletions tools/symbol_addrs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down