mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-27 05:34:15 +01:00
-added missing lowmem setup for channels booted without apploader
-cleaned up channel boot
This commit is contained in:
parent
47fe516390
commit
e44ec9cda1
@ -72,7 +72,7 @@ static u8 *GetDol(u32 bootcontent, u64 title)
|
|||||||
}
|
}
|
||||||
free(data);
|
free(data);
|
||||||
data = decompressed;
|
data = decompressed;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -72,6 +72,22 @@ void Disc_SetLowMem(u32 IOS)
|
|||||||
DCFlushRange((void*)0x80000000, 0x3f00);
|
DCFlushRange((void*)0x80000000, 0x3f00);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Thanks to triiforce for that code */
|
||||||
|
void Disc_SetLowMemChan()
|
||||||
|
{
|
||||||
|
/* Setup low mem */
|
||||||
|
*Arena_H = 0x00000000; // Arena High, the appldr does this too
|
||||||
|
*BI2 = 0x817FE000; // BI2, the appldr does this too
|
||||||
|
*GameID_Address = 0x81000000; // Game id address, 0s at 0x81000000 with appldr
|
||||||
|
|
||||||
|
/* Flush low mem */
|
||||||
|
DCFlushRange((void*)0x80000000, 0x3f00);
|
||||||
|
|
||||||
|
/* Clear BI2 */
|
||||||
|
memset((void *)0x817FE000, 0, 0x2000);
|
||||||
|
DCFlushRange((void*)0x817FE000, 0x2000);
|
||||||
|
}
|
||||||
|
|
||||||
/* Thanks Tinyload */
|
/* Thanks Tinyload */
|
||||||
static struct {
|
static struct {
|
||||||
u32 offset;
|
u32 offset;
|
||||||
|
@ -11,6 +11,7 @@ s32 Disc_FindPartition(u32 *outbuf);
|
|||||||
s32 Disc_SetUSB(const u8 *id, bool frag);
|
s32 Disc_SetUSB(const u8 *id, bool frag);
|
||||||
void Disc_SetLowMemPre();
|
void Disc_SetLowMemPre();
|
||||||
void Disc_SetLowMem(u32 IOS);
|
void Disc_SetLowMem(u32 IOS);
|
||||||
|
void Disc_SetLowMemChan();
|
||||||
void Disc_SetTime();
|
void Disc_SetTime();
|
||||||
|
|
||||||
GXRModeObj *Disc_SelectVMode(u8 videoselected, u32 *rmode_reg);
|
GXRModeObj *Disc_SelectVMode(u8 videoselected, u32 *rmode_reg);
|
||||||
|
@ -1,215 +1,177 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* lz77.c
|
* lz77.c
|
||||||
*
|
*
|
||||||
* Copyright (c) 2009 The Lemon Man
|
* Copyright (c) 2009 The Lemon Man
|
||||||
* Copyright (c) 2009 Nicksasa
|
* Copyright (c) 2009 Nicksasa
|
||||||
* Copyright (c) 2009 WiiPower
|
* Copyright (c) 2009 WiiPower
|
||||||
*
|
*
|
||||||
* Distributed under the terms of the GNU General Public License (v2)
|
* Distributed under the terms of the GNU General Public License (v2)
|
||||||
* See http://www.gnu.org/licenses/gpl-2.0.txt for more info.
|
* See http://www.gnu.org/licenses/gpl-2.0.txt for more info.
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* -----------
|
* -----------
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
#include <stdio.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include "lz77.h"
|
||||||
#include <malloc.h>
|
|
||||||
|
static inline u32 packBytes(int a, int b, int c, int d)
|
||||||
#include "lz77.h"
|
{
|
||||||
#include "utils.h"
|
return (d << 24) | (c << 16) | (b << 8) | (a);
|
||||||
|
}
|
||||||
u32 packBytes(int a, int b, int c, int d)
|
|
||||||
{
|
static int __decompressLZ77_11(u8 *in, u32 inputLen, u8 **output, u32 *outputLen)
|
||||||
return (d << 24) | (c << 16) | (b << 8) | (a);
|
{
|
||||||
}
|
int x = 0;
|
||||||
|
u32 y = 0;
|
||||||
s32 __decompressLZ77_11(u8 *in, u32 inputLen, u8 **output, u32 *outputLen)
|
u32 compressedPos = 0x4;
|
||||||
{
|
u32 decompressedPos = 0;
|
||||||
int x, y;
|
u32 decompressedSize = packBytes(in[0], in[1], in[2], in[3]) >> 8;
|
||||||
|
if(decompressedSize == 0)
|
||||||
u8 *out = NULL;
|
{
|
||||||
|
decompressedSize = packBytes(in[4], in[5], in[6], in[7]);
|
||||||
u32 compressedPos = 0x4;
|
compressedPos += 0x4;
|
||||||
u32 decompressedPos = 0x0;
|
}
|
||||||
u32 decompressedSize = 0;
|
//printf("Decompressed size : %i\n", decompressedSize);
|
||||||
|
|
||||||
decompressedSize = packBytes(in[0], in[1], in[2], in[3]) >> 8;
|
u8 *out = (u8*)malloc(decompressedSize);
|
||||||
|
if(out == NULL)
|
||||||
if (!decompressedSize)
|
{
|
||||||
{
|
//printf("Out of memory\n");
|
||||||
decompressedSize = packBytes(in[4], in[5], in[6], in[7]);
|
return -1;
|
||||||
compressedPos += 0x4;
|
}
|
||||||
}
|
|
||||||
|
while(compressedPos < inputLen && decompressedPos < decompressedSize)
|
||||||
//printf("Decompressed size : %i\n", decompressedSize);
|
{
|
||||||
|
u8 byteFlag = in[compressedPos];
|
||||||
out = malloc(ALIGN32(decompressedSize));
|
compressedPos++;
|
||||||
if (out == NULL)
|
|
||||||
{
|
for(x = 7; x >= 0; x--)
|
||||||
printf("Out of memory\n");
|
{
|
||||||
return -1;
|
if((byteFlag & (1 << x)) > 0)
|
||||||
}
|
{
|
||||||
|
u8 first = in[compressedPos];
|
||||||
while (compressedPos < inputLen && decompressedPos < decompressedSize)
|
u8 second = in[compressedPos + 1];
|
||||||
{
|
|
||||||
u8 byteFlag = in[compressedPos];
|
u32 pos, copyLen;
|
||||||
compressedPos++;
|
if(first < 0x20)
|
||||||
|
{
|
||||||
for (x = 7; x >= 0; x--)
|
u8 third = in[compressedPos + 2];
|
||||||
{
|
if(first >= 0x10)
|
||||||
if ((byteFlag & (1 << x)) > 0)
|
{
|
||||||
{
|
u32 fourth = in[compressedPos + 3];
|
||||||
u8 first = in[compressedPos];
|
pos = (u32)(((third & 0xF) << 8) | fourth) + 1;
|
||||||
u8 second = in[compressedPos + 1];
|
copyLen = (u32)((second << 4) | ((first & 0xF) << 12) | (third >> 4)) + 273;
|
||||||
|
compressedPos += 4;
|
||||||
u32 pos, copyLen;
|
}
|
||||||
|
else
|
||||||
if (first < 0x20)
|
{
|
||||||
{
|
pos = (u32)(((second & 0xF) << 8) | third) + 1;
|
||||||
u8 third = in[compressedPos + 2];
|
copyLen = (u32)(((first & 0xF) << 4) | (second >> 4)) + 17;
|
||||||
|
compressedPos += 3;
|
||||||
if (first >= 0x10)
|
}
|
||||||
{
|
}
|
||||||
u32 fourth = in[compressedPos + 3];
|
else
|
||||||
|
{
|
||||||
pos = (u32)(((third & 0xF) << 8) | fourth) + 1;
|
pos = (u32)(((first & 0xF) << 8) | second) + 1;
|
||||||
copyLen = (u32)((second << 4) | ((first & 0xF) << 12) | (third >> 4)) + 273;
|
copyLen = (u32)(first >> 4) + 1;
|
||||||
|
compressedPos += 2;
|
||||||
compressedPos += 4;
|
}
|
||||||
} else
|
for(y = 0; y < copyLen; y++)
|
||||||
{
|
out[decompressedPos + y] = out[decompressedPos - pos + y];
|
||||||
pos = (u32)(((second & 0xF) << 8) | third) + 1;
|
decompressedPos += copyLen;
|
||||||
copyLen = (u32)(((first & 0xF) << 4) | (second >> 4)) + 17;
|
}
|
||||||
|
else
|
||||||
compressedPos += 3;
|
{
|
||||||
}
|
out[decompressedPos] = in[compressedPos];
|
||||||
} else
|
decompressedPos++;
|
||||||
{
|
compressedPos++;
|
||||||
pos = (u32)(((first & 0xF) << 8) | second) + 1;
|
}
|
||||||
copyLen = (u32)(first >> 4) + 1;
|
if(compressedPos >= inputLen || decompressedPos >= decompressedSize)
|
||||||
|
break;
|
||||||
compressedPos += 2;
|
}
|
||||||
}
|
}
|
||||||
|
*output = out;
|
||||||
for (y = 0; y < (int)copyLen; y++)
|
*outputLen = decompressedSize;
|
||||||
{
|
return 0;
|
||||||
out[decompressedPos + y] = out[decompressedPos - pos + y];
|
}
|
||||||
}
|
|
||||||
|
static int __decompressLZ77_10(u8 *in, u8 **output, u32 *outputLen)
|
||||||
decompressedPos += copyLen;
|
{
|
||||||
} else
|
int x = 0;
|
||||||
{
|
u32 y = 0;
|
||||||
out[decompressedPos] = in[compressedPos];
|
u32 compressedPos = 0x4;
|
||||||
|
u32 decompressedPos = 0;
|
||||||
decompressedPos++;
|
u32 decompressedSize = packBytes(in[0], in[1], in[2], in[3]) >> 8;
|
||||||
compressedPos++;
|
//printf("Decompressed size : %i\n", decompressedSize);
|
||||||
}
|
|
||||||
|
u8 *out = (u8*)malloc(decompressedSize);
|
||||||
if (compressedPos >= inputLen || decompressedPos >= decompressedSize)
|
if(out == NULL)
|
||||||
break;
|
{
|
||||||
}
|
//printf("Out of memory\n");
|
||||||
}
|
return -1;
|
||||||
*output = out;
|
}
|
||||||
*outputLen = decompressedSize;
|
|
||||||
return 0;
|
while(decompressedPos < decompressedSize)
|
||||||
}
|
{
|
||||||
|
u8 byteFlag = in[compressedPos];
|
||||||
s32 __decompressLZ77_10(u8 *in, u8 **output, u32 *outputLen)
|
compressedPos ++;
|
||||||
{
|
|
||||||
int x, y;
|
for(x = 0; x < 8; ++x)
|
||||||
|
{
|
||||||
u8 *out = NULL;
|
if(byteFlag & 0x80)
|
||||||
|
{
|
||||||
u32 compressedPos = 0;
|
u8 first = in[compressedPos];
|
||||||
u32 decompressedSize = 0x4;
|
u8 second = in[compressedPos + 1];
|
||||||
u32 decompressedPos = 0;
|
u16 pos = (u16)((((first << 8) + second) & 0xFFF) + 1);
|
||||||
|
u8 copyLen = (u8)(3 + ((first >> 4) & 0xF));
|
||||||
decompressedSize = packBytes(in[0], in[1], in[2], in[3]) >> 8;
|
for(y = 0; y < copyLen; y++)
|
||||||
|
out[decompressedPos + y] = out[decompressedPos - pos + (y % pos)];
|
||||||
//int compressionType = (packBytes(in[0], in[1], in[2], in[3]) >> 4) & 0xF;
|
compressedPos += 2;
|
||||||
|
decompressedPos += copyLen;
|
||||||
//printf("Decompressed size : %i\n", decompressedSize);
|
}
|
||||||
|
else
|
||||||
out = malloc(ALIGN32(decompressedSize));
|
{
|
||||||
if (out == NULL)
|
out[decompressedPos] = in[compressedPos];
|
||||||
{
|
compressedPos += 1;
|
||||||
printf("Out of memory\n");
|
decompressedPos += 1;
|
||||||
return -1;
|
}
|
||||||
}
|
byteFlag <<= 1;
|
||||||
|
if(decompressedPos >= decompressedSize)
|
||||||
compressedPos += 0x4;
|
break;
|
||||||
|
}
|
||||||
while (decompressedPos < decompressedSize)
|
}
|
||||||
{
|
*output = out;
|
||||||
u8 flag = *(u8*)(in + compressedPos);
|
*outputLen = decompressedSize;
|
||||||
compressedPos += 1;
|
return 0;
|
||||||
|
}
|
||||||
for (x = 0; x < 8; x++)
|
|
||||||
{
|
int isLZ77compressed(u8 *buffer)
|
||||||
if (flag & 0x80)
|
{
|
||||||
{
|
if((buffer[0] == LZ77_0x10_FLAG) || (buffer[0] == LZ77_0x11_FLAG))
|
||||||
u8 first = in[compressedPos];
|
return 1;
|
||||||
u8 second = in[compressedPos + 1];
|
return 0;
|
||||||
|
}
|
||||||
u16 pos = (u16)((((first << 8) + second) & 0xFFF) + 1);
|
|
||||||
u8 copyLen = (u8)(3 + ((first >> 4) & 0xF));
|
int decompressLZ77content(u8 *buffer, u32 length, u8 **output, u32 *outputLen)
|
||||||
|
{
|
||||||
for (y = 0; y < copyLen; y++)
|
int ret = 0;
|
||||||
{
|
switch(buffer[0])
|
||||||
out[decompressedPos + y] = out[decompressedPos - pos + (y % pos)];
|
{
|
||||||
}
|
case LZ77_0x10_FLAG:
|
||||||
|
//printf("LZ77 variant 0x10 compressed content...unpacking may take a while...\n");
|
||||||
compressedPos += 2;
|
ret = __decompressLZ77_10(buffer, output, outputLen);
|
||||||
decompressedPos += copyLen;
|
break;
|
||||||
} else
|
case LZ77_0x11_FLAG:
|
||||||
{
|
//printf("LZ77 variant 0x11 compressed content...unpacking may take a while...\n");
|
||||||
out[decompressedPos] = in[compressedPos];
|
ret = __decompressLZ77_11(buffer, length, output, outputLen);
|
||||||
compressedPos += 1;
|
break;
|
||||||
decompressedPos += 1;
|
default:
|
||||||
}
|
//printf("Not compressed ...\n");
|
||||||
|
ret = -1;
|
||||||
flag <<= 1;
|
break;
|
||||||
|
}
|
||||||
if (decompressedPos >= decompressedSize)
|
return ret;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*output = out;
|
|
||||||
*outputLen = decompressedSize;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int isLZ77compressed(u8 *buffer)
|
|
||||||
{
|
|
||||||
if ((buffer[0] == LZ77_0x10_FLAG) || (buffer[0] == LZ77_0x11_FLAG))
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int decompressLZ77content(u8 *buffer, u32 length, u8 **output, u32 *outputLen)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
switch (buffer[0])
|
|
||||||
{
|
|
||||||
case LZ77_0x10_FLAG:
|
|
||||||
//printf("LZ77 variant 0x10 compressed content...unpacking may take a while...\n");
|
|
||||||
ret = __decompressLZ77_10(buffer, output, outputLen);
|
|
||||||
break;
|
|
||||||
case LZ77_0x11_FLAG:
|
|
||||||
//printf("LZ77 variant 0x11 compressed content...unpacking may take a while...\n");
|
|
||||||
ret = __decompressLZ77_11(buffer, length, output, outputLen);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//printf("Not compressed ...\n");
|
|
||||||
ret = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* lz77.h
|
* lz77.h
|
||||||
*
|
*
|
||||||
* Copyright (c) 2009 The Lemon Man
|
* Copyright (c) 2009 The Lemon Man
|
||||||
* Copyright (c) 2009 Nicksasa
|
* Copyright (c) 2009 Nicksasa
|
||||||
* Copyright (c) 2009 WiiPower
|
* Copyright (c) 2009 WiiPower
|
||||||
*
|
*
|
||||||
* Distributed under the terms of the GNU General Public License (v2)
|
* Distributed under the terms of the GNU General Public License (v2)
|
||||||
* See http://www.gnu.org/licenses/gpl-2.0.txt for more info.
|
* See http://www.gnu.org/licenses/gpl-2.0.txt for more info.
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* -----------
|
* -----------
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#ifndef _LZ77_MODULE
|
#ifndef _LZ77_MODULE
|
||||||
#define _LZ77_MODULE
|
#define _LZ77_MODULE
|
||||||
|
|
||||||
#define LZ77_0x10_FLAG 0x10
|
#define LZ77_0x10_FLAG 0x10
|
||||||
#define LZ77_0x11_FLAG 0x11
|
#define LZ77_0x11_FLAG 0x11
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
int isLZ77compressed(u8 *buffer);
|
int isLZ77compressed(u8 *buffer);
|
||||||
int decompressLZ77content(u8 *buffer, u32 length, u8 **output, u32 *outputLen);
|
int decompressLZ77content(u8 *buffer, u32 length, u8 **output, u32 *outputLen);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -121,6 +121,8 @@ int main()
|
|||||||
|
|
||||||
/* Setup Low Memory */
|
/* Setup Low Memory */
|
||||||
Disc_SetLowMem(GameIOS);
|
Disc_SetLowMem(GameIOS);
|
||||||
|
if(normalCFG.BootType == TYPE_CHANNEL && AppEntrypoint != 0x3400)
|
||||||
|
Disc_SetLowMemChan(); /* Real DOL without appldr */
|
||||||
|
|
||||||
/* Set time */
|
/* Set time */
|
||||||
Disc_SetTime();
|
Disc_SetTime();
|
||||||
@ -136,10 +138,10 @@ int main()
|
|||||||
/* Originally from tueidj - taken from NeoGamma (thx) */
|
/* Originally from tueidj - taken from NeoGamma (thx) */
|
||||||
*(vu32*)0xCC003024 = 1;
|
*(vu32*)0xCC003024 = 1;
|
||||||
|
|
||||||
if(AppEntrypoint == 0x3400)
|
if(AppEntrypoint == 0x3400)
|
||||||
{
|
{
|
||||||
if(hooktype)
|
if(hooktype)
|
||||||
{
|
{
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"lis %r3, returnpoint@h\n"
|
"lis %r3, returnpoint@h\n"
|
||||||
"ori %r3, %r3, returnpoint@l\n"
|
"ori %r3, %r3, returnpoint@l\n"
|
||||||
@ -160,24 +162,24 @@ int main()
|
|||||||
"mtsrr0 %r4\n"
|
"mtsrr0 %r4\n"
|
||||||
"rfi\n"
|
"rfi\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"isync\n"
|
"isync\n"
|
||||||
"lis %r3, AppEntrypoint@h\n"
|
"lis %r3, AppEntrypoint@h\n"
|
||||||
"ori %r3, %r3, AppEntrypoint@l\n"
|
"ori %r3, %r3, AppEntrypoint@l\n"
|
||||||
"lwz %r3, 0(%r3)\n"
|
"lwz %r3, 0(%r3)\n"
|
||||||
"mtsrr0 %r3\n"
|
"mtsrr0 %r3\n"
|
||||||
"mfmsr %r3\n"
|
"mfmsr %r3\n"
|
||||||
"li %r4, 0x30\n"
|
"li %r4, 0x30\n"
|
||||||
"andc %r3, %r3, %r4\n"
|
"andc %r3, %r3, %r4\n"
|
||||||
"mtsrr1 %r3\n"
|
"mtsrr1 %r3\n"
|
||||||
"rfi\n"
|
"rfi\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(hooktype)
|
else if(hooktype)
|
||||||
{
|
{
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"lis %r3, AppEntrypoint@h\n"
|
"lis %r3, AppEntrypoint@h\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user