diff --git a/XulumenuUpdator/NitroFS/1_20 b/XulumenuUpdator/NitroFS/1_30 similarity index 100% rename from XulumenuUpdator/NitroFS/1_20 rename to XulumenuUpdator/NitroFS/1_30 diff --git a/XulumenuUpdator/NitroFS/xulumenu.bin b/XulumenuUpdator/NitroFS/xulumenu.bin index b22a2c1..e58a8ca 100644 Binary files a/XulumenuUpdator/NitroFS/xulumenu.bin and b/XulumenuUpdator/NitroFS/xulumenu.bin differ diff --git a/XulumenuUpdator/NitroFS_Bootleg/1_2_BOOTLEG b/XulumenuUpdator/NitroFS_Bootleg/1_3_BOOTLEG similarity index 100% rename from XulumenuUpdator/NitroFS_Bootleg/1_2_BOOTLEG rename to XulumenuUpdator/NitroFS_Bootleg/1_3_BOOTLEG diff --git a/XulumenuUpdator/NitroFS_Bootleg/xulumenu.bin b/XulumenuUpdator/NitroFS_Bootleg/xulumenu.bin index b22a2c1..e58a8ca 100644 Binary files a/XulumenuUpdator/NitroFS_Bootleg/xulumenu.bin and b/XulumenuUpdator/NitroFS_Bootleg/xulumenu.bin differ diff --git a/XulumenuUpdator/Pack Bootleg SRL.cmd b/XulumenuUpdator/Pack Bootleg SRL.cmd index 9737b3e..feb1453 100644 --- a/XulumenuUpdator/Pack Bootleg SRL.cmd +++ b/XulumenuUpdator/Pack Bootleg SRL.cmd @@ -1,3 +1,5 @@ @Echo off ndstool -c autorun1_bootleg.nds -9 arm9_bootleg.bin -7 arm7.bin -t banner_bootleg.bin -h header.bin -d NitroFS_Bootleg +ndstool -c autorun2_bootleg.nds -9 arm9_bootleg.bin -7 arm7.bin -t banner_bootleg.bin -h header.bin -d NitroFS_Bootleg +ndstool -c autorun3_bootleg.nds -9 arm9_bootleg.bin -7 arm7.bin -t banner_bootleg.bin -h header.bin -d NitroFS_Bootleg pause \ No newline at end of file diff --git a/XulumenuUpdator/Pack SRL.cmd b/XulumenuUpdator/Pack SRL.cmd index a87d991..c71866b 100644 --- a/XulumenuUpdator/Pack SRL.cmd +++ b/XulumenuUpdator/Pack SRL.cmd @@ -1,3 +1,5 @@ @Echo off ndstool -c autorun1.nds -9 arm9.bin -7 arm7.bin -t banner.bin -h header.bin -d NitroFS +ndstool -c autorun2.nds -9 arm9.bin -7 arm7.bin -t banner.bin -h header.bin -d NitroFS +ndstool -c autorun3.nds -9 arm9.bin -7 arm7.bin -t banner.bin -h header.bin -d NitroFS pause \ No newline at end of file diff --git a/XulumenuUpdator/arm9.bin b/XulumenuUpdator/arm9.bin index d480397..cc08b8f 100644 Binary files a/XulumenuUpdator/arm9.bin and b/XulumenuUpdator/arm9.bin differ diff --git a/XulumenuUpdator/arm9_bootleg.bin b/XulumenuUpdator/arm9_bootleg.bin index 16611ab..604e686 100644 Binary files a/XulumenuUpdator/arm9_bootleg.bin and b/XulumenuUpdator/arm9_bootleg.bin differ diff --git a/XulumenuUpdator/banner.bin b/XulumenuUpdator/banner.bin index abcc093..4575e2d 100644 Binary files a/XulumenuUpdator/banner.bin and b/XulumenuUpdator/banner.bin differ diff --git a/XulumenuUpdator/banner_bootleg.bin b/XulumenuUpdator/banner_bootleg.bin index be17983..8529455 100644 Binary files a/XulumenuUpdator/banner_bootleg.bin and b/XulumenuUpdator/banner_bootleg.bin differ diff --git a/arm9/binaries/nriousb.srl b/arm9/binaries/nriousb.srl index f07ec55..aa88f72 100644 Binary files a/arm9/binaries/nriousb.srl and b/arm9/binaries/nriousb.srl differ diff --git a/arm9/binaries/stage2.srl b/arm9/binaries/stage2.srl index 5a52dd1..3bb2ab9 100644 Binary files a/arm9/binaries/stage2.srl and b/arm9/binaries/stage2.srl differ diff --git a/arm9/binaries/udisk.srl b/arm9/binaries/udisk.srl index c94faa2..c48f17f 100644 Binary files a/arm9/binaries/udisk.srl and b/arm9/binaries/udisk.srl differ diff --git a/arm9/source/binaries.h b/arm9/source/binaries.h deleted file mode 100644 index 56034e6..0000000 --- a/arm9/source/binaries.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef BINARIES_H -#define BINARIES_H - -#ifdef __cplusplus -extern "C" { -#endif - -extern void udiskData(); -extern void udiskData_end(); -extern void stage2Data(); -extern void stage2Data_end(); -extern void nriousbData(); -extern void nriousbData_end(); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/arm9/source/binaries.s b/arm9/source/binaries.s index 206681b..7a52e19 100644 --- a/arm9/source/binaries.s +++ b/arm9/source/binaries.s @@ -1,16 +1,15 @@ .arm - .global udiskData, udiskData_end, stage2Data, stage2Data_end, nriousbData, nriousbData_end + .global udiskData, stage2Data, nriousbData +.align 16 udiskData: .incbin "../binaries/udisk.srl" -udiskData_end: +.align 16 stage2Data: .incbin "../binaries/stage2.srl" -stage2Data_end: +.align 16 nriousbData: .incbin "../binaries/nriousb.srl" -nriousbData_end: - diff --git a/arm9/source/lzss.c b/arm9/source/lzss.c new file mode 100644 index 0000000..44fa783 --- /dev/null +++ b/arm9/source/lzss.c @@ -0,0 +1,32 @@ +#include "lzss.h" + +#include + +#define __itcm __attribute__((section(".itcm"))) + +void __itcm +LZ77_Decompress(u8* source, u8* destination){ + u32 leng = (source[1] | (source[2] << 8) | (source[3] << 16)); + int Offs = 4; + int dstoffs = 0; + while (true) { + u8 header = source[Offs++]; + for (int i = 0; i < 8; i++) { + if ((header & 0x80) == 0) destination[dstoffs++] = source[Offs++]; + else + { + u8 a = source[Offs++]; + u8 b = source[Offs++]; + int offs = (((a & 0xF) << 8) | b) + 1; + int length = (a >> 4) + 3; + for (int j = 0; j < length; j++) { + destination[dstoffs] = destination[dstoffs - offs]; + dstoffs++; + } + } + if (dstoffs >= (int)leng) return; + header <<= 1; + } + } +} + diff --git a/arm9/source/lzss.h b/arm9/source/lzss.h new file mode 100644 index 0000000..303cc42 --- /dev/null +++ b/arm9/source/lzss.h @@ -0,0 +1,15 @@ +#ifndef LZ77_DECOMPRESS_H +#define LZ77_DECOMPRESS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif +void LZ77_Decompress(u8* source, u8* destination); + +#ifdef __cplusplus +} +#endif +#endif /* DECOMPRESS_H */ + diff --git a/arm9/source/nds_loader_arm9.c b/arm9/source/nds_loader_arm9.c index 622806e..8d17d79 100644 --- a/arm9/source/nds_loader_arm9.c +++ b/arm9/source/nds_loader_arm9.c @@ -29,7 +29,7 @@ #include "load_bin.h" #include "udiskloader_bin.h" -#include "binaries.h" +#include "lzss.h" #include "tonccpy.h" #ifndef _NO_BOOTSTUB_ @@ -39,7 +39,7 @@ #include "nds_loader_arm9.h" -#define TMP_DATA 0x02200000 +#define TMP_DATA 0x02300000 #define LCDC_BANK_D (u16*)0x06860000 #define STORED_FILE_CLUSTER (*(((u32*)LCDC_BANK_D) + 1)) @@ -223,13 +223,30 @@ static bool dldiPatchLoader (data_t *binData, u32 binSize, bool clearBSS) { return true; } + + +#define nriousbData_size 0x1D6B8 +#define stage2Data_size 0x14600 +#define udiskData_size 0x91810 + +#define nriousbData_lz_size 0x13CE9 +#define stage2Data_lz_size 0xBD06 +#define udiskData_lz_size 0x69BA6 + + +ALIGN(16) extern unsigned char nriousbData[nriousbData_lz_size]; +ALIGN(16) extern unsigned char stage2Data[stage2Data_lz_size]; +ALIGN(16) extern unsigned char udiskData[udiskData_lz_size]; + +ALIGN(16) volatile u8* buffer; + int runSRLbinary(int srlType) { - switch (srlType) { + /*switch (srlType) { case 1: tonccpy((void*)TMP_DATA, (void*)stage2Data, (stage2Data_end - stage2Data)); break; case 2: tonccpy((void*)TMP_DATA, (void*)nriousbData, (nriousbData_end - nriousbData)); break; default: tonccpy((void*)TMP_DATA, (void*)udiskData, (udiskData_end - udiskData)); break; - } + }*/ /*switch (srlType) { case 1: decompress((u8*)stage2Data, (u8*)TMP_DATA, LZ77Vram); break; @@ -237,6 +254,24 @@ int runSRLbinary(int srlType) { default: decompress((u8*)udiskData, (u8*)TMP_DATA, LZ77Vram); break; }*/ + switch (srlType) { + case 1: { + buffer = malloc(stage2Data_size); + LZ77_Decompress((u8*)stage2Data, (u8*)buffer); + tonccpy((void*)TMP_DATA, (void*)buffer, stage2Data_size); + } break; + case 2: { + buffer = malloc(nriousbData_size); + LZ77_Decompress((u8*)nriousbData, (u8*)buffer); + tonccpy((void*)TMP_DATA, (void*)buffer, nriousbData_size); + } break; + default: { + buffer = malloc(udiskData_size); + LZ77_Decompress((u8*)udiskData, (u8*)buffer); + tonccpy((void*)TMP_DATA, (void*)buffer, udiskData_size); + } break; + } + // Start Bootloader irqDisable(IRQ_ALL); // Direct CPU access to VRAM bank D diff --git a/arm9/source/nrio_detect.c b/arm9/source/nrio_detect.itcm.c similarity index 100% rename from arm9/source/nrio_detect.c rename to arm9/source/nrio_detect.itcm.c diff --git a/arm9/source/tonccpy.c b/arm9/source/tonccpy.itcm.c similarity index 100% rename from arm9/source/tonccpy.c rename to arm9/source/tonccpy.itcm.c diff --git a/udiskloader/source/main.arm7.c b/udiskloader/source/main.arm7.c index 8f31d18..d048db7 100644 --- a/udiskloader/source/main.arm7.c +++ b/udiskloader/source/main.arm7.c @@ -47,7 +47,7 @@ #include "tonccpy.h" -#define TMP_DATA 0x02200000 +#define TMP_DATA 0x02300000 extern void arm7_clearmem (void* loc, size_t len); extern void arm7_reset (void);