*code beautification*

formatted the code to make it easier to read.  no functional changes at all.

i didn't put anything from the libwiigui folder or banner folder in the beautifier.

my automated .bat seems to have done a good job.  the only places i see it fucked up was on (GXColor){blablabla}.  it treated the brackets in the color like all the other brackets and put the color on a new line and indented it.  i think i fixed most of them.  not sure if it messed up anywhere else.  also not sure about how it handled different linebreaks.  it looks fine on windows.  if it looks messed up on linux, it can be reverted.

the code still compiles and runs fine.
This commit is contained in:
giantpune 2009-07-30 05:41:12 +00:00
parent 024bdee994
commit 30535c6f5d
120 changed files with 19786 additions and 20999 deletions

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<pd><ViewState><e p="gui\source\mload" x="false"></e><e p="gui\source\settings" x="false"></e><e p="gui\source\images" x="false"></e><e p="gui\source\prompts" x="true"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="true"></e><e p="gui\source\network" x="false"></e><e p="gui\source\unzip" x="false"></e><e p="gui\source\usbloader" x="false"></e><e p="gui\source\xml" x="false"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\ramdisc" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\wad" x="true"></e><e p="gui" x="true"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="true"></e><e p="gui\source" x="true"></e><e p="gui\source\libwbfs" x="false"></e><e p="gui\source\libwiigui" x="false"></e><e p="gui\source\patches" x="false"></e></ViewState></pd>
<pd><ViewState><e p="gui\source\mload" x="false"></e><e p="gui\source\settings" x="false"></e><e p="gui\source\images" x="false"></e><e p="gui\source\prompts" x="true"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="false"></e><e p="gui\source\network" x="false"></e><e p="gui\source\unzip" x="false"></e><e p="gui\source\usbloader" x="false"></e><e p="gui\source\xml" x="false"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\ramdisc" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\wad" x="true"></e><e p="gui" x="true"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="false"></e><e p="gui\source" x="true"></e><e p="gui\source\libwbfs" x="false"></e><e p="gui\source\libwiigui" x="false"></e><e p="gui\source\patches" x="false"></e></ViewState></pd>

View File

@ -95,14 +95,14 @@ wchar_t* FreeTypeGX::charToWideChar(char* strChar) {
// UTF-8
int bt;
bt = mbstowcs(strWChar, strChar, strlen(strChar));
if(bt > 0) {
if (bt > 0) {
strWChar[bt] = (wchar_t)'\0';
return strWChar;
}
char *tempSrc = strChar;
wchar_t *tempDest = strWChar;
while((*tempDest++ = *tempSrc++));
while ((*tempDest++ = *tempSrc++));
return strWChar;
}
@ -153,8 +153,8 @@ void FreeTypeGX::setCompatibilityMode(uint32_t compatibilityMode) {
* in setCompatibilityMode.
*/
void FreeTypeGX::setDefaultMode() {
if(this->compatibilityMode) {
switch(this->compatibilityMode & 0x00FF) {
if (this->compatibilityMode) {
switch (this->compatibilityMode & 0x00FF) {
case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE:
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
break;
@ -174,7 +174,7 @@ void FreeTypeGX::setDefaultMode() {
break;
}
switch(this->compatibilityMode & 0xFF00) {
switch (this->compatibilityMode & 0xFF00) {
case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE:
GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);
break;
@ -209,8 +209,7 @@ uint16_t FreeTypeGX::loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long buffe
this->ftPointSize = pointSize;
struct stat st;
if(fontPath && (stat(fontPath, &st)==0))
{
if (fontPath && (stat(fontPath, &st)==0)) {
FILE *fontfile = fopen(fontPath, "rb");
if (fontfile) {
FT_Long ftFace_fromFile_Size;
@ -229,7 +228,7 @@ uint16_t FreeTypeGX::loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long buffe
if (ftFace_fromFile == NULL)
FT_New_Memory_Face(this->ftLibrary, (FT_Byte *)fontBuffer, bufferSize, 0, &this->ftFace);
if(this->ftPointSize > 0)
if (this->ftPointSize > 0)
FT_Set_Pixel_Sizes(this->ftFace, 0, this->ftPointSize);
this->ftSlot = this->ftFace->glyph;
@ -253,13 +252,11 @@ uint16_t FreeTypeGX::loadFont(const char* fontPath, const uint8_t* fontBuffer, F
void FreeTypeGX::unloadFont() {
clearGlyphData();
if(this->ftFace)
{
if (this->ftFace) {
FT_Done_Face(this->ftFace);
this->ftFace = NULL;
}
if(this->ftFace_fromFile)
{
if (this->ftFace_fromFile) {
free(this->ftFace_fromFile);
this->ftFace_fromFile = NULL;
}
@ -269,15 +266,14 @@ void FreeTypeGX::unloadFont() {
*
* This routine clears all members of the font map structure and frees all allocated memory back to the system.
*/
void FreeTypeGX::clearGlyphData()
{
if(this->fontData.size() == 0)
void FreeTypeGX::clearGlyphData() {
if (this->fontData.size() == 0)
return;
GX_DrawDone();
GX_Flush();
for( std::map<wchar_t, ftgxCharData>::iterator i = this->fontData.begin(); i != this->fontData.end(); i++) {
for ( std::map<wchar_t, ftgxCharData>::iterator i = this->fontData.begin(); i != this->fontData.end(); i++) {
free(i->second.glyphDataTexture);
}
@ -302,7 +298,7 @@ void FreeTypeGX::changeSize(FT_UInt vPointSize, FT_UInt hPointSize/*=0*/) {
uint16_t FreeTypeGX::adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat) {
uint16_t alignment;
switch(textureFormat) {
switch (textureFormat) {
case GX_TF_I4: /* 8x8 Tiles - 4-bit Intensity */
case GX_TF_I8: /* 8x4 Tiles - 8-bit Intensity */
case GX_TF_IA4: /* 8x4 Tiles - 4-bit Intensity, , 4-bit Alpha */
@ -333,7 +329,7 @@ uint16_t FreeTypeGX::adjustTextureWidth(uint16_t textureWidth, uint8_t textureFo
uint16_t FreeTypeGX::adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat) {
uint16_t alignment;
switch(textureFormat) {
switch (textureFormat) {
case GX_TF_I4: /* 8x8 Tiles - 4-bit Intensity */
alignment = 8;
break;
@ -369,13 +365,13 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode) {
if (!FT_Load_Glyph(this->ftFace, gIndex, FT_LOAD_DEFAULT )) {
FT_Render_Glyph( this->ftSlot, FT_RENDER_MODE_NORMAL );
if(this->ftSlot->format == FT_GLYPH_FORMAT_BITMAP) {
if (this->ftSlot->format == FT_GLYPH_FORMAT_BITMAP) {
FT_Bitmap *glyphBitmap = &this->ftSlot->bitmap;
textureWidth = adjustTextureWidth(glyphBitmap->width, this->textureFormat);
textureHeight = adjustTextureHeight(glyphBitmap->rows, this->textureFormat);
this->fontData[charCode] = (ftgxCharData){
this->fontData[charCode] = (ftgxCharData) {
this->ftSlot->bitmap_left,
this->ftSlot->advance.x >> 6,
gIndex,
@ -407,7 +403,7 @@ uint16_t FreeTypeGX::cacheGlyphDataComplete() {
FT_ULong charCode = FT_Get_First_Char( this->ftFace, &gIndex );
while ( gIndex != 0 ) {
if(this->cacheGlyphData(charCode) != NULL) {
if (this->cacheGlyphData(charCode) != NULL) {
i++;
}
@ -438,7 +434,7 @@ void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) {
}
}
switch(this->textureFormat) {
switch (this->textureFormat) {
case GX_TF_I4:
charData->glyphDataTexture = Metaphrasis::convertBufferToI4(glyphData, charData->textureWidth, charData->textureHeight);
break;
@ -476,8 +472,7 @@ void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) {
*/
int16_t FreeTypeGX::getStyleOffsetWidth(uint16_t width, uint16_t format) {
switch(format & FTGX_JUSTIFY_MASK)
{
switch (format & FTGX_JUSTIFY_MASK) {
case FTGX_JUSTIFY_LEFT:
return 0;
@ -500,10 +495,8 @@ int16_t FreeTypeGX::getStyleOffsetWidth(uint16_t width, uint16_t format) {
* @param offset Current pixel offset data of the string.
* @param format Positional format of the string.
*/
int16_t FreeTypeGX::getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format)
{
switch(format & FTGX_ALIGN_MASK)
{
int16_t FreeTypeGX::getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format) {
switch (format & FTGX_ALIGN_MASK) {
case FTGX_ALIGN_TOP:
return offset->ascender;
@ -551,26 +544,25 @@ uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color
FT_Vector pairDelta;
ftgxDataOffset offset;
if(textStyle & FTGX_JUSTIFY_MASK) {
if (textStyle & FTGX_JUSTIFY_MASK) {
x_offset = this->getStyleOffsetWidth(this->getWidth(text), textStyle);
}
if(textStyle & FTGX_ALIGN_MASK) {
if (textStyle & FTGX_ALIGN_MASK) {
y_offset = this->getStyleOffsetHeight(this->getOffset(text, &offset), textStyle);
}
for (uint16_t i = 0; i < strLength; i++) {
ftgxCharData* glyphData = NULL;
if( this->fontData.find(text[i]) != this->fontData.end() ) {
if ( this->fontData.find(text[i]) != this->fontData.end() ) {
glyphData = &this->fontData[text[i]];
}
else {
} else {
glyphData = this->cacheGlyphData(text[i]);
}
if(glyphData != NULL) {
if (glyphData != NULL) {
if(this->ftKerningEnabled && i) {
if (this->ftKerningEnabled && i) {
FT_Get_Kerning( this->ftFace, this->fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta );
x_pos += pairDelta.x >> 6;
}
@ -583,7 +575,7 @@ uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color
}
}
if(textStyle & FTGX_STYLE_MASK) {
if (textStyle & FTGX_STYLE_MASK) {
this->drawTextFeature(x + x_offset, y + y_offset, this->getWidth(text), this->getOffset(text, &offset), textStyle, color);
}
@ -601,8 +593,8 @@ void FreeTypeGX::drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataO
uint16_t featureHeight = this->ftPointSize >> 4 > 0 ? this->ftPointSize >> 4 : 1;
if (format & FTGX_STYLE_UNDERLINE ) {
switch(format & FTGX_ALIGN_MASK) {
/*
switch (format & FTGX_ALIGN_MASK) {
/*
case FTGX_ALIGN_TOP:
this->copyFeatureToFramebuffer(width, featureHeight, x, y + offsetData->max + 1, color);
break;
@ -612,7 +604,7 @@ void FreeTypeGX::drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataO
case FTGX_ALIGN_BOTTOM:
this->copyFeatureToFramebuffer(width, featureHeight, x, y - offsetData->min, color);
break;
*/
*/
default:
this->copyFeatureToFramebuffer(width, featureHeight, x, y + 1, color);
break;
@ -620,8 +612,8 @@ void FreeTypeGX::drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataO
}
if (format & FTGX_STYLE_STRIKE ) {
switch(format & FTGX_ALIGN_MASK) {
/*
switch (format & FTGX_ALIGN_MASK) {
/*
case FTGX_ALIGN_TOP:
this->copyFeatureToFramebuffer(width, featureHeight, x, y + ((offsetData->max - offsetData->min + 1) >> 1), color);
break;
@ -631,7 +623,7 @@ void FreeTypeGX::drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataO
case FTGX_ALIGN_BOTTOM:
this->copyFeatureToFramebuffer(width, featureHeight, x, y - ((offsetData->max + offsetData->min) >> 1), color);
break;
*/
*/
default:
// this->copyFeatureToFramebuffer(width, featureHeight, x, y - ((offsetData->max - offsetData->min) >> 1), color);
this->copyFeatureToFramebuffer(width, featureHeight, x, y - ((offsetData->max) >> 1), color);
@ -657,15 +649,14 @@ uint16_t FreeTypeGX::getWidth(wchar_t *text) {
for (uint16_t i = 0; i < strLength; i++) {
ftgxCharData* glyphData = NULL;
if( this->fontData.find(text[i]) != this->fontData.end() ) {
if ( this->fontData.find(text[i]) != this->fontData.end() ) {
glyphData = &this->fontData[text[i]];
}
else {
} else {
glyphData = this->cacheGlyphData(text[i]);
}
if(glyphData != NULL) {
if(this->ftKerningEnabled && (i > 0)) {
if (glyphData != NULL) {
if (this->ftKerningEnabled && (i > 0)) {
FT_Get_Kerning( this->ftFace, this->fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta );
strWidth += pairDelta.x >> 6;
}
@ -726,14 +717,13 @@ ftgxDataOffset* FreeTypeGX::getOffset(wchar_t *text, ftgxDataOffset* offset) {
for (uint16_t i = 0; i < strLength; i++) {
ftgxCharData* glyphData = NULL;
if( this->fontData.find(text[i]) != this->fontData.end() ) {
if ( this->fontData.find(text[i]) != this->fontData.end() ) {
glyphData = &this->fontData[text[i]];
}
else {
} else {
glyphData = this->cacheGlyphData(text[i]);
}
if(glyphData != NULL) {
if (glyphData != NULL) {
strMax = glyphData->renderOffsetMax > strMax ? glyphData->renderOffsetMax : strMax;
strMin = glyphData->renderOffsetMin < strMin ? glyphData->renderOffsetMin : strMin;
}

View File

@ -203,7 +203,10 @@ typedef struct ftgxDataOffset_ ftgxDataOffset;
#define FTGX_COMPATIBILITY_GRRLIB FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE
#define FTGX_COMPATIBILITY_LIBWIISPRITE FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_DIRECT
const GXColor ftgxWhite = (GXColor){0xff, 0xff, 0xff, 0xff}; /**< Constant color value used only to sanitize Doxygen documentation. */
const GXColor ftgxWhite = (GXColor) {
0xff, 0xff, 0xff, 0xff
}
; /**< Constant color value used only to sanitize Doxygen documentation. */
/*! \class FreeTypeGX
* \brief Wrapper class for the libFreeType library with GX rendering.
@ -216,7 +219,7 @@ const GXColor ftgxWhite = (GXColor){0xff, 0xff, 0xff, 0xff}; /**< Constant color
*/
class FreeTypeGX {
private:
private:
FT_Library ftLibrary; /**< FreeType FT_Library instance. */
FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */
FT_Byte *ftFace_fromFile;
@ -247,7 +250,7 @@ class FreeTypeGX {
void copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 texHeight, int16_t screenX, int16_t screenY, GXColor color);
void copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, int16_t screenX, int16_t screenY, GXColor color);
public:
public:
FreeTypeGX(uint8_t textureFormat = GX_TF_RGBA8, uint8_t vertexIndex = GX_VTXFMT1);
~FreeTypeGX();

View File

@ -54,9 +54,9 @@ uint32_t* Metaphrasis::convertBufferToI4(uint32_t* rgbaBuffer, uint16_t bufferWi
uint32_t *src = (uint32_t *)rgbaBuffer;
uint8_t *dst = (uint8_t *)dataBufferI4;
for(uint16_t y = 0; y < bufferHeight; y += 8) {
for(uint16_t x = 0; x < bufferWidth; x += 8) {
for(uint16_t rows = 0; rows < 8; rows++) {
for (uint16_t y = 0; y < bufferHeight; y += 8) {
for (uint16_t x = 0; x < bufferWidth; x += 8) {
for (uint16_t rows = 0; rows < 8; rows++) {
*dst++ = (src[((y + rows) * bufferWidth) + (x + 0)] & 0xf0) | ((src[((y + rows) * bufferWidth) + (x + 1)] & 0xf0) >> 4);
*dst++ = (src[((y + rows) * bufferWidth) + (x + 2)] & 0xf0) | ((src[((y + rows) * bufferWidth) + (x + 3)] & 0xf0) >> 4);
*dst++ = (src[((y + rows) * bufferWidth) + (x + 4)] & 0xf0) | ((src[((y + rows) * bufferWidth) + (x + 5)] & 0xf0) >> 4);
@ -88,9 +88,9 @@ uint32_t* Metaphrasis::convertBufferToI8(uint32_t* rgbaBuffer, uint16_t bufferWi
uint32_t *src = (uint32_t *)rgbaBuffer;
uint8_t *dst = (uint8_t *)dataBufferI8;
for(uint16_t y = 0; y < bufferHeight; y += 4) {
for(uint16_t x = 0; x < bufferWidth; x += 8) {
for(uint16_t rows = 0; rows < 4; rows++) {
for (uint16_t y = 0; y < bufferHeight; y += 4) {
for (uint16_t x = 0; x < bufferWidth; x += 8) {
for (uint16_t rows = 0; rows < 4; rows++) {
*dst++ = src[((y + rows) * bufferWidth) + (x + 0)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 1)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 2)] & 0xff;
@ -144,9 +144,9 @@ uint32_t* Metaphrasis::convertBufferToIA4(uint32_t* rgbaBuffer, uint16_t bufferW
uint32_t *src = (uint32_t *)rgbaBuffer;
uint8_t *dst = (uint8_t *)dataBufferIA4;
for(uint16_t y = 0; y < bufferHeight; y += 4) {
for(uint16_t x = 0; x < bufferWidth; x += 8) {
for(uint16_t rows = 0; rows < 4; rows++) {
for (uint16_t y = 0; y < bufferHeight; y += 4) {
for (uint16_t x = 0; x < bufferWidth; x += 8) {
for (uint16_t rows = 0; rows < 4; rows++) {
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 0)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 1)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 2)]);
@ -200,9 +200,9 @@ uint32_t* Metaphrasis::convertBufferToIA8(uint32_t* rgbaBuffer, uint16_t bufferW
uint32_t *src = (uint32_t *)rgbaBuffer;
uint16_t *dst = (uint16_t *)dataBufferIA8;
for(uint16_t y = 0; y < bufferHeight; y += 4) {
for(uint16_t x = 0; x < bufferWidth; x += 4) {
for(uint16_t rows = 0; rows < 4; rows++) {
for (uint16_t y = 0; y < bufferHeight; y += 4) {
for (uint16_t x = 0; x < bufferWidth; x += 4) {
for (uint16_t rows = 0; rows < 4; rows++) {
*dst++ = Metaphrasis::convertRGBAToIA8(src[((y + rows) * bufferWidth) + (x + 0)]);
*dst++ = Metaphrasis::convertRGBAToIA8(src[((y + rows) * bufferWidth) + (x + 1)]);
*dst++ = Metaphrasis::convertRGBAToIA8(src[((y + rows) * bufferWidth) + (x + 2)]);
@ -234,8 +234,8 @@ uint32_t* Metaphrasis::convertBufferToRGBA8(uint32_t* rgbaBuffer, uint16_t buffe
uint8_t *src = (uint8_t *)rgbaBuffer;
uint8_t *dst = (uint8_t *)dataBufferRGBA8;
for(uint16_t block = 0; block < bufferHeight; block += 4) {
for(uint16_t i = 0; i < bufferWidth; i += 4) {
for (uint16_t block = 0; block < bufferHeight; block += 4) {
for (uint16_t i = 0; i < bufferWidth; i += 4) {
for (uint16_t c = 0; c < 4; c++) {
for (uint16_t ar = 0; ar < 4; ar++) {
*dst++ = src[(((i + ar) + ((block + c) * bufferWidth)) * 4) + 3];
@ -294,9 +294,9 @@ uint32_t* Metaphrasis::convertBufferToRGB565(uint32_t* rgbaBuffer, uint16_t buff
uint32_t *src = (uint32_t *)rgbaBuffer;
uint16_t *dst = (uint16_t *)dataBufferRGB565;
for(uint16_t y = 0; y < bufferHeight; y += 4) {
for(uint16_t x = 0; x < bufferWidth; x += 4) {
for(uint16_t rows = 0; rows < 4; rows++) {
for (uint16_t y = 0; y < bufferHeight; y += 4) {
for (uint16_t x = 0; x < bufferWidth; x += 4) {
for (uint16_t rows = 0; rows < 4; rows++) {
*dst++ = Metaphrasis::convertRGBAToRGB565(src[((y + rows) * bufferWidth) + (x + 0)]);
*dst++ = Metaphrasis::convertRGBAToRGB565(src[((y + rows) * bufferWidth) + (x + 1)]);
*dst++ = Metaphrasis::convertRGBAToRGB565(src[((y + rows) * bufferWidth) + (x + 2)]);
@ -335,8 +335,7 @@ uint16_t Metaphrasis::convertRGBAToRGB5A3(uint32_t rgba) {
color = (r << 10) | (g << 5) | b;
color |= 0x8000;
}
else {
} else {
r = r >> 4;
g = g >> 4;
b = b >> 4;
@ -367,9 +366,9 @@ uint32_t* Metaphrasis::convertBufferToRGB5A3(uint32_t* rgbaBuffer, uint16_t buff
uint32_t *src = (uint32_t *)rgbaBuffer;
uint16_t *dst = (uint16_t *)dataBufferRGB5A3;
for(uint16_t y = 0; y < bufferHeight; y += 4) {
for(uint16_t x = 0; x < bufferWidth; x += 4) {
for(uint16_t rows = 0; rows < 4; rows++) {
for (uint16_t y = 0; y < bufferHeight; y += 4) {
for (uint16_t x = 0; x < bufferWidth; x += 4) {
for (uint16_t rows = 0; rows < 4; rows++) {
*dst++ = Metaphrasis::convertRGBAToRGB5A3(src[((y + rows) * bufferWidth) + (x + 0)]);
*dst++ = Metaphrasis::convertRGBAToRGB5A3(src[((y + rows) * bufferWidth) + (x + 1)]);
*dst++ = Metaphrasis::convertRGBAToRGB5A3(src[((y + rows) * bufferWidth) + (x + 2)]);

View File

@ -94,7 +94,7 @@
* and Wii platforms.
*/
class Metaphrasis {
public:
public:
Metaphrasis();
virtual ~Metaphrasis();

View File

@ -15,8 +15,7 @@
*
* Initializes the Wii's audio subsystem
***************************************************************************/
void InitAudio()
{
void InitAudio() {
AUDIO_Init(NULL);
ASND_Init();
ASND_Pause(0);
@ -28,8 +27,7 @@ void InitAudio()
* Shuts down audio subsystem. Useful to avoid unpleasant sounds if a
* crash occurs during shutdown.
***************************************************************************/
void ShutdownAudio()
{
void ShutdownAudio() {
ASND_Pause(1);
ASND_End();
}

View File

@ -32,36 +32,34 @@ static GuiImageData * cover[BUFFERSIZE];
static GuiImage * coverImg[BUFFERSIZE];
static GuiImage * NoCover[BUFFERSIZE];
GuiImage * ImageBuffer(int imagenumber)
{
if((BUFFERSIZE-1 > imagenumber) && direction >= 0) {
GuiImage * ImageBuffer(int imagenumber) {
if ((BUFFERSIZE-1 > imagenumber) && direction >= 0) {
return coverImg[imagenumber];
}
if((0 < imagenumber) && direction < 0) {
if ((0 < imagenumber) && direction < 0) {
return coverImg[imagenumber];
}
if(loading == BUFFERSIZE) {
if (loading == BUFFERSIZE) {
return coverImg[imagenumber];
}
return NoCover[imagenumber];
}
void LoadImages()
{
if(!changed || BufferHalt)
void LoadImages() {
if (!changed || BufferHalt)
return;
char ID[4];
char IDfull[7];
char imgPath[200];
for(u32 i = offset; (int) i < offset+BUFFERSIZE; i++) {
for (u32 i = offset; (int) i < offset+BUFFERSIZE; i++) {
struct discHdr *header;
if(i > gameCnt-1)
if (i > gameCnt-1)
header = &gameList[i-gameCnt];
else
header = &gameList[i];
@ -73,13 +71,13 @@ void LoadImages()
snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, IDfull); //Load full id image
//firsttime loading images into memory
if(firstime) {
if (firstime) {
if(coverImg[loading]) {
if (coverImg[loading]) {
delete coverImg[loading];
coverImg[loading] = NULL;
}
if(cover[loading]) {
if (cover[loading]) {
delete cover[loading];
cover[loading] = NULL;
}
@ -101,17 +99,17 @@ void LoadImages()
} else {
if(direction >= 0) {
if (direction >= 0) {
if(loading < BUFFERSIZE-1) {
if (loading < BUFFERSIZE-1) {
if(coverImg[loading]) {
if (coverImg[loading]) {
delete coverImg[loading];
coverImg[loading] = NULL;
}
if(loading == 0) {
if(cover[loading]) {
if (loading == 0) {
if (cover[loading]) {
delete cover[loading];
cover[loading] = NULL;
}
@ -138,23 +136,23 @@ void LoadImages()
cover[loading] = new GuiImageData(imgPath, nocover_png);
}
}
if(coverImg[loading]) {
if (coverImg[loading]) {
delete coverImg[loading];
coverImg[loading] = NULL;
}
coverImg[loading] = new GuiImage(cover[loading]);
}
} else if(direction < 0) {
} else if (direction < 0) {
if(BUFFERSIZE-loading-1 > 0) {
if (BUFFERSIZE-loading-1 > 0) {
if(coverImg[BUFFERSIZE-loading-1]) {
if (coverImg[BUFFERSIZE-loading-1]) {
delete coverImg[BUFFERSIZE-loading-1];
coverImg[BUFFERSIZE-loading-1] = NULL;
}
if(BUFFERSIZE-loading-1 == BUFFERSIZE-1) {
if(cover[BUFFERSIZE-loading-1]) {
if (BUFFERSIZE-loading-1 == BUFFERSIZE-1) {
if (cover[BUFFERSIZE-loading-1]) {
delete cover[BUFFERSIZE-loading-1];
cover[BUFFERSIZE-loading-1] = NULL;
}
@ -187,7 +185,7 @@ void LoadImages()
cover[0] = new GuiImageData(imgPath, nocover_png);
}
}
if(coverImg[0]) {
if (coverImg[0]) {
delete coverImg[0];
coverImg[0] = NULL;
}
@ -203,9 +201,8 @@ void LoadImages()
firstime = false;
}
void NewOffset(int off, int d)
{
if(offset == off || loading < BUFFERSIZE)
void NewOffset(int off, int d) {
if (offset == off || loading < BUFFERSIZE)
return;
direction = d;
@ -219,8 +216,7 @@ void NewOffset(int off, int d)
/****************************************************************************
* HaltBuffer
***************************************************************************/
void HaltBufferThread()
{
void HaltBufferThread() {
BufferHalt = true;
firstime = true;
changed = true;
@ -229,10 +225,10 @@ void HaltBufferThread()
direction = 0;
// wait for thread to finish
while(!LWP_ThreadIsSuspended(bufferthread))
while (!LWP_ThreadIsSuspended(bufferthread))
usleep(100);
for(int i = 0; i < BUFFERSIZE; i++) {
for (int i = 0; i < BUFFERSIZE; i++) {
delete cover[i];
cover[i] = NULL;
delete coverImg[i];
@ -245,8 +241,7 @@ void HaltBufferThread()
/****************************************************************************
* ResumeBufferThread
***************************************************************************/
void ResumeBufferThread(int offset)
{
void ResumeBufferThread(int offset) {
BufferHalt = false;
firstime = true;
changed = true;
@ -254,8 +249,8 @@ void ResumeBufferThread(int offset)
offset = offset;
direction = 0;
for(u8 i = 0; i < BUFFERSIZE; i++) {
if(NoCover[i] != NULL) {
for (u8 i = 0; i < BUFFERSIZE; i++) {
if (NoCover[i] != NULL) {
delete NoCover[i];
NoCover[i] = NULL;
}
@ -268,11 +263,9 @@ void ResumeBufferThread(int offset)
/*********************************************************************************
* Bufferthread
*********************************************************************************/
static void * bufferinitcallback(void *arg)
{
while(1)
{
if(BufferHalt)
static void * bufferinitcallback(void *arg) {
while (1) {
if (BufferHalt)
LWP_SuspendThread(bufferthread);
LoadImages();
@ -283,16 +276,14 @@ static void * bufferinitcallback(void *arg)
/****************************************************************************
* InitBufferThread with priority 50
***************************************************************************/
void InitBufferThread()
{
void InitBufferThread() {
LWP_CreateThread(&bufferthread, bufferinitcallback, NULL, NULL, 0, 50);
}
/****************************************************************************
* ShutdownThread
***************************************************************************/
void ShutdownBufferThread()
{
void ShutdownBufferThread() {
LWP_JoinThread (bufferthread, NULL);
bufferthread = LWP_THREAD_NULL;
}

View File

@ -22,8 +22,7 @@ extern GuiWindow * mainWindow;
/****************************************************************************
* CheatMenu
***************************************************************************/
int CheatMenu(const char * gameID)
{
int CheatMenu(const char * gameID) {
int choice = 0;
bool exit = false;
int ret = 1;
@ -44,14 +43,14 @@ int CheatMenu(const char * gameID)
GuiImage settingsbackground(&settingsbg);
GuiText backBtnTxt(tr("Back") , 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText backBtnTxt(tr("Back") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage backBtnImg(&btnOutline);
GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -140, 400, &trigA, &btnSoundOver, &btnClick,1);
backBtn.SetLabel(&backBtnTxt);
backBtn.SetTrigger(&trigB);
GuiText createBtnTxt(tr("Create") , 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText createBtnTxt(tr("Create") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
createBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage createBtnImg(&btnOutline);
GuiButton createBtn(&createBtnImg,&createBtnImg, 2, 3, 160, 400, &trigA, &btnSoundOver, &btnClick,1);
@ -67,11 +66,12 @@ int CheatMenu(const char * gameID)
//char tmp[10];
switch(check)
{
case -1: WindowPrompt(tr("Error"),tr("Cheatfile is blank"),tr("OK"));
switch (check) {
case -1:
WindowPrompt(tr("Error"),tr("Cheatfile is blank"),tr("OK"));
break;
case 0: download = WindowPrompt(tr("Error"),tr("No Cheatfile found"),tr("OK"),tr("Download Now"));
case 0:
download = WindowPrompt(tr("Error"),tr("No Cheatfile found"),tr("OK"),tr("Download Now"));
//snprintf(tmp, sizeof(tmp), "%i",download);
//WindowPrompt(0,tmp,tr("OK"),tr("Download Now"));
@ -86,13 +86,12 @@ int CheatMenu(const char * gameID)
chtBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
chtBrowser.SetClickable(true);
GuiText titleTxt(c.getGameName().c_str(), 28, (GXColor){0, 0, 0, 255});
GuiText titleTxt(c.getGameName().c_str(), 28, (GXColor) {0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetMaxWidth(350, GuiText::SCROLL);
titleTxt.SetPosition(12,40);
for(int i = 0; i <= cntcheats; i++)
{
for (int i = 0; i <= cntcheats; i++) {
cheatslst.SetValue(i, "%s",c.getCheatName(i).c_str());
cheatslst.SetName(i, "OFF");
}
@ -109,36 +108,27 @@ int CheatMenu(const char * gameID)
mainWindow->Append(&w);
ResumeGui();
while(!exit)
{
while (!exit) {
VIDEO_WaitVSync ();
ret = chtBrowser.GetClickedOption();
if (ret != -1)
{
if (ret != -1) {
const char *strCheck = cheatslst.GetName(ret);
if (strncmp(strCheck,"ON",2) == 0)
{
if (strncmp(strCheck,"ON",2) == 0) {
cheatslst.SetName(ret,"%s","OFF");
}
else if (strncmp(strCheck,"OFF",3) == 0)
{
} else if (strncmp(strCheck,"OFF",3) == 0) {
cheatslst.SetName(ret,"%s","ON");
}
}
if(createBtn.GetState() == STATE_CLICKED)
{
if (createBtn.GetState() == STATE_CLICKED) {
createBtn.ResetState();
if (cntcheats > 0)
{
if (cntcheats > 0) {
int selectednrs[30];
int x = 0;
for(int i = 0; i <= cntcheats; i++)
{
for (int i = 0; i <= cntcheats; i++) {
const char *strCheck = cheatslst.GetName(i);
if (strncmp(strCheck,"ON",2) == 0)
{
if (strncmp(strCheck,"ON",2) == 0) {
selectednrs[x] = i;
x++;
}
@ -154,8 +144,7 @@ int CheatMenu(const char * gameID)
}
if(backBtn.GetState() == STATE_CLICKED)
{
if (backBtn.GetState() == STATE_CLICKED) {
backBtn.ResetState();
exit = true;
break;

View File

@ -4,68 +4,50 @@
#define OUTOFRANGE "Error:Range"
GCTCheats::GCTCheats(void)
{
GCTCheats::GCTCheats(void) {
iCntCheats = 0;
}
GCTCheats::~GCTCheats(void)
{
GCTCheats::~GCTCheats(void) {
}
int GCTCheats::getCnt()
{
int GCTCheats::getCnt() {
return iCntCheats;
}
string GCTCheats::getGameName(void)
{
string GCTCheats::getGameName(void) {
return sGameTitle;
}
string GCTCheats::getGameID(void)
{
string GCTCheats::getGameID(void) {
return sGameID;
}
string GCTCheats::getCheat(int nr)
{
if (nr <= (iCntCheats-1))
{
string GCTCheats::getCheat(int nr) {
if (nr <= (iCntCheats-1)) {
return sCheats[nr];
}
else
{
} else {
return OUTOFRANGE;//"Error: CheatNr out of range";
}
}
string GCTCheats::getCheatName(int nr)
{
if (nr <= (iCntCheats-1))
{
string GCTCheats::getCheatName(int nr) {
if (nr <= (iCntCheats-1)) {
return sCheatName[nr];
}
else
{
} else {
return "Error: CheatNr out of range";
}
}
string GCTCheats::getCheatComment(int nr)
{
if (nr <= (iCntCheats-1))
{
string GCTCheats::getCheatComment(int nr) {
if (nr <= (iCntCheats-1)) {
return sCheatComment[nr];
}
else
{
} else {
return "Error: CheatNr out of range";
}
}
int GCTCheats::createGCT(int nr,const char * filename)
{
int GCTCheats::createGCT(int nr,const char * filename) {
ofstream filestr;
filestr.open(filename);
@ -83,8 +65,7 @@ int GCTCheats::createGCT(int nr,const char * filename)
long int li;
int len = buf.size();
while (x < len)
{
while (x < len) {
string temp = buf.substr(x,2);
li = strtol(temp.c_str(),NULL,16);
temp = li;
@ -97,8 +78,7 @@ int GCTCheats::createGCT(int nr,const char * filename)
return 1;
}
int GCTCheats::createGCT(const char * chtbuffer,const char * filename)
{
int GCTCheats::createGCT(const char * chtbuffer,const char * filename) {
ofstream filestr;
filestr.open(filename);
@ -116,8 +96,7 @@ int GCTCheats::createGCT(const char * chtbuffer,const char * filename)
long int li;
int len = buf.size();
while (x < len)
{
while (x < len) {
string temp = buf.substr(x,2);
li = strtol(temp.c_str(),NULL,16);
temp = li;
@ -129,11 +108,10 @@ int GCTCheats::createGCT(const char * chtbuffer,const char * filename)
filestr.close();
return 1;
return 1;
}
int GCTCheats::createGCT(int nr[],int cnt,const char * filename)
{
int GCTCheats::createGCT(int nr[],int cnt,const char * filename) {
ofstream filestr;
filestr.open(filename);
@ -148,16 +126,14 @@ int GCTCheats::createGCT(int nr[],int cnt,const char * filename)
filestr.write(header,sizeof(header));
int c = 0;
while (c != cnt)
{
while (c != cnt) {
int actnr = nr[c];
string buf = getCheat(actnr);
long int li;
int len = buf.size();
int x = 0;
while (x < len)
{
while (x < len) {
string temp = buf.substr(x,2);
li = strtol(temp.c_str(),NULL,16);
temp = li;
@ -167,13 +143,12 @@ int GCTCheats::createGCT(int nr[],int cnt,const char * filename)
c++;
}
filestr.write(footer,sizeof(footer));
filestr.close();
return 1;
filestr.write(footer,sizeof(footer));
filestr.close();
return 1;
}
int GCTCheats::openTxtfile(const char * filename)
{
int GCTCheats::openTxtfile(const char * filename) {
ifstream filestr;
int i = 0;
string str;
@ -191,49 +166,43 @@ int GCTCheats::openTxtfile(const char * filename)
getline(filestr,sGameTitle);
filestr.ignore();
while(!filestr.eof())
{
while (!filestr.eof()) {
getline(filestr,sCheatName[i]);
string cheatdata;
bool emptyline = false;
bool isComment = false;
do
{
do {
getline(filestr,str,'\n');
//cheatdata.append(str);
if (str == "")
{
if (str == "") {
emptyline = true;
break;
}
if (str.size() <= 16 || str.size() > 17 )
{
if (str.size() <= 16 || str.size() > 17 ) {
isComment = true;
printf ("%i",str.size());
}
if (!isComment)
{
if (!isComment) {
cheatdata.append(str);
size_t found=cheatdata.find(' ');
cheatdata.replace(found,1,"");
} else
{
} else {
sCheatComment[i] = str;
}
if (filestr.eof()) break;
} while(!emptyline);
} while (!emptyline);
sCheats[i] = cheatdata;
i++;
}
iCntCheats = i;
filestr.close();
return 1;
}
iCntCheats = i;
filestr.close();
return 1;
}
@ -287,16 +256,14 @@ filestr.close();
return 1;
}*/
struct GCTCheats::chtentries GCTCheats::getCheatList(void)
{
struct GCTCheats::chtentries GCTCheats::getCheatList(void) {
struct GCTCheats::chtentries cheatlist;
int i = 0;
cheatlist.sGameID = sGameID;
cheatlist.sGameTitle = sGameTitle;
while (i < iCntCheats)
{
while (i < iCntCheats) {
cheatlist.sCheatName[i] = sCheatName[i];
cheatlist.sCheats[i] = sCheats[i];
i++;
@ -304,8 +271,7 @@ struct GCTCheats::chtentries GCTCheats::getCheatList(void)
return cheatlist;
}
struct GCTCheats::chtentries GCTCheats::getCheatList(const char * filename)
{
struct GCTCheats::chtentries GCTCheats::getCheatList(const char * filename) {
openTxtfile(filename);
struct GCTCheats::chtentries cheatlist;
int i = 0;
@ -313,8 +279,7 @@ struct GCTCheats::chtentries GCTCheats::getCheatList(const char * filename)
cheatlist.sGameTitle = sGameTitle;
cheatlist.iCntCheats = iCntCheats;
while (i < iCntCheats)
{
while (i < iCntCheats) {
cheatlist.sCheatName[i] = sCheatName[i];
cheatlist.sCheats[i] = sCheats[i];
i++;
@ -322,8 +287,7 @@ struct GCTCheats::chtentries GCTCheats::getCheatList(const char * filename)
return cheatlist;
}
int GCTCheats::download_txtcheat(int id)
{
int GCTCheats::download_txtcheat(int id) {
//ToDo
return 1;
return 1;
}

View File

@ -14,8 +14,7 @@
using namespace std;
struct chtentrie
{
struct chtentrie {
string sGameID;
string sGameTitle;
string sCheatName[MAXCHEATS];
@ -25,8 +24,7 @@ struct chtentrie
};
//!Handles Ocarina TXT Cheatfiles
class GCTCheats
{
class GCTCheats {
private:
chtentrie ccc;
string sGameID;
@ -38,14 +36,13 @@ private:
public:
struct chtentries
{
struct chtentries {
string sGameID;
string sGameTitle;
string sCheatName[MAXCHEATS];
string sCheats[MAXCHEATS];
int iCntCheats;
};
};
//!Constructor
GCTCheats(void);

View File

@ -12,8 +12,7 @@
#define CACHE 8
#define SECTORS 64
int USBDevice_Init()
{
int USBDevice_Init() {
//closing all open Files write back the cache and then shutdown em!
fatUnmount("USB:/");
//right now mounts first FAT-partition
@ -27,26 +26,22 @@ int USBDevice_Init()
return -1;
}
void USBDevice_deInit()
{
void USBDevice_deInit() {
//closing all open Files write back the cache and then shutdown em!
fatUnmount("USB:/");
}
int isSdInserted()
{
int isSdInserted() {
return __io_wiisd.isInserted();
}
int isInserted(const char *path)
{
if(!strncmp(path, "USB:", 4))
int isInserted(const char *path) {
if (!strncmp(path, "USB:", 4))
return 1;
return __io_wiisd.isInserted();
}
int SDCard_Init()
{
int SDCard_Init() {
//closing all open Files write back the cache and then shutdown em!
fatUnmount("SD:/");
//right now mounts first FAT-partition
@ -55,8 +50,7 @@ int SDCard_Init()
return -1;
}
void SDCard_deInit()
{
void SDCard_deInit() {
//closing all open Files write back the cache and then shutdown em!
fatUnmount("SD:/");
}

View File

@ -2,16 +2,15 @@
#define _FATMOUNTER_H_
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
int USBDevice_Init();
void USBDevice_deInit();
int isSdInserted();
int isInserted(const char *path);
int SDCard_Init();
void SDCard_deInit();
int USBDevice_Init();
void USBDevice_deInit();
int isSdInserted();
int isInserted(const char *path);
int SDCard_Init();
void SDCard_deInit();
#ifdef __cplusplus
}

View File

@ -17,7 +17,7 @@ int AllocHomebrewMemory(u32 filesize) {
innetbuffer = malloc(filesize);
if(!innetbuffer)
if (!innetbuffer)
return -1;
return 1;
@ -35,15 +35,14 @@ void CopyHomebrewMemory(u32 read, u8 *temp, u32 len) {
}
int BootHomebrew(char * path)
{
int BootHomebrew(char * path) {
void *buffer = NULL;
u32 filesize = 0;
entrypoint entry;
u32 cpu_isr;
FILE * file = fopen(path, "rb");
if(!file) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
if (!file) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
fseek (file, 0, SEEK_END);
filesize = ftell(file);
@ -51,8 +50,7 @@ int BootHomebrew(char * path)
buffer = malloc(filesize);
if(fread (buffer, 1, filesize, file) != filesize)
{
if (fread (buffer, 1, filesize, file) != filesize) {
fclose (file);
free(buffer);
SDCard_deInit();
@ -81,7 +79,7 @@ int BootHomebrew(char * path)
free(buffer);
if(!entry) {
if (!entry) {
SDCard_deInit();
USBDevice_deInit();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
@ -103,12 +101,11 @@ int BootHomebrew(char * path)
return 0;
}
int BootHomebrewFromMem()
{
int BootHomebrewFromMem() {
entrypoint entry;
u32 cpu_isr;
if(!innetbuffer) {
if (!innetbuffer) {
SDCard_deInit();
USBDevice_deInit();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
@ -124,7 +121,7 @@ int BootHomebrewFromMem()
free(innetbuffer);
if(!entry) {
if (!entry) {
SDCard_deInit();
USBDevice_deInit();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);

View File

@ -2,15 +2,14 @@
#define _BOOTHOMEBREW_H_
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
int BootHomebrew(char * path);
int BootHomebrewFromMem();
void CopyHomebrewMemory(u32 read, u8 *temp, u32 len);
int AllocHomebrewMemory(u32 filesize);
void FreeHomebrewBuffer();
int BootHomebrew(char * path);
int BootHomebrewFromMem();
void CopyHomebrewMemory(u32 read, u8 *temp, u32 len);
int AllocHomebrewMemory(u32 filesize);
void FreeHomebrewBuffer();
#ifdef __cplusplus
}

View File

@ -47,9 +47,8 @@ u8 boothomebrew = 0;
/****************************************************************************
* roundup Function
***************************************************************************/
int roundup(float number)
{
if(number == (int) number)
int roundup(float number) {
if (number == (int) number)
return (int) number;
else
return (int) (number+1);
@ -58,8 +57,7 @@ int roundup(float number)
/****************************************************************************
* MenuHomebrewBrowse
***************************************************************************/
int MenuHomebrewBrowse()
{
int MenuHomebrewBrowse() {
int menu = MENU_NONE;
int choice = 0;
@ -67,7 +65,7 @@ int MenuHomebrewBrowse()
u32 filecount = HomebrewFiles.GetFilecount();
if(!filecount) {
if (!filecount) {
WindowPrompt(tr("No .dol or .elf files found."),0, tr("OK"));
return MENU_DISCLIST;
}
@ -78,7 +76,7 @@ int MenuHomebrewBrowse()
RIGHT
};
if(IsNetworkInit())
if (IsNetworkInit())
ResumeNetworkWait();
int slidedirection = FADE;
@ -133,23 +131,23 @@ int MenuHomebrewBrowse()
GuiTrigger trigPlus;
trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);
GuiText titleTxt(tr("Homebrew Launcher"), 28, (GXColor){0, 0, 0, 255});
GuiText titleTxt(tr("Homebrew Launcher"), 28, (GXColor) {0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(0,40);
GuiImageData *IconData[4];
GuiImage *IconImg[4];
for(int i = 0; i < 4; i++) {
for (int i = 0; i < 4; i++) {
IconData[i] = NULL;
IconImg[i] = NULL;
}
/*** Buttons ***/
GuiText backBtnTxt(tr("Back") , 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText backBtnTxt(tr("Back") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage backBtnImg(&btnOutline);
if (Settings.wsprompt == yes){
if (Settings.wsprompt == yes) {
backBtnTxt.SetWidescreen(CFG.widescreen);
backBtnImg.SetWidescreen(CFG.widescreen);
}
@ -189,15 +187,15 @@ int MenuHomebrewBrowse()
GuiImage MainButton1Img(&MainButtonImgData);
GuiImage MainButton1ImgOver(&MainButtonImgOverData);
GuiText MainButton1Txt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
GuiText MainButton1Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton1Txt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::DOTTED);
MainButton1Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton1Txt.SetPosition(148, -12);
GuiText MainButton1DescTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
GuiText MainButton1DescTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton1DescTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::DOTTED);
MainButton1DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton1DescTxt.SetPosition(148, 15);
GuiText MainButton1DescOverTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
GuiText MainButton1DescOverTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
MainButton1DescOverTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::SCROLL);
MainButton1DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton1DescOverTxt.SetPosition(148, 15);
@ -216,15 +214,15 @@ int MenuHomebrewBrowse()
GuiImage MainButton2Img(&MainButtonImgData);
GuiImage MainButton2ImgOver(&MainButtonImgOverData);
GuiText MainButton2Txt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
GuiText MainButton2Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255 });
MainButton2Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton2Txt.SetPosition(148, -12);
MainButton2Txt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton2DescTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
GuiText MainButton2DescTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
MainButton2DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton2DescTxt.SetPosition(148, 15);
MainButton2DescTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton2DescOverTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
GuiText MainButton2DescOverTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton2DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton2DescOverTxt.SetPosition(148, 15);
MainButton2DescOverTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::SCROLL);
@ -243,15 +241,15 @@ int MenuHomebrewBrowse()
GuiImage MainButton3Img(&MainButtonImgData);
GuiImage MainButton3ImgOver(&MainButtonImgOverData);
GuiText MainButton3Txt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
GuiText MainButton3Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton3Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton3Txt.SetPosition(148, -12);
MainButton3Txt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton3DescTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
GuiText MainButton3DescTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
MainButton3DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton3DescTxt.SetPosition(148, 15);
MainButton3DescTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton3DescOverTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
GuiText MainButton3DescOverTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255 });
MainButton3DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton3DescOverTxt.SetPosition(148, 15);
MainButton3DescOverTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::SCROLL);
@ -270,15 +268,15 @@ int MenuHomebrewBrowse()
GuiImage MainButton4Img(&MainButtonImgData);
GuiImage MainButton4ImgOver(&MainButtonImgOverData);
GuiText MainButton4Txt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
GuiText MainButton4Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255} );
MainButton4Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton4Txt.SetPosition(148, -12);
MainButton4Txt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton4DescTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
GuiText MainButton4DescTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton4DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton4DescTxt.SetPosition(148, 15);
MainButton4DescTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton4DescOverTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
GuiText MainButton4DescOverTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
MainButton4DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton4DescOverTxt.SetPosition(148, 15);
MainButton4DescOverTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::SCROLL);
@ -296,7 +294,7 @@ int MenuHomebrewBrowse()
MainButton4.SetTrigger(&trigA);
GuiImage wifiImg(&wifiImgData);
if (Settings.wsprompt == yes){
if (Settings.wsprompt == yes) {
wifiImg.SetWidescreen(CFG.widescreen);
}
GuiButton wifiBtn(wifiImg.GetWidth(), wifiImg.GetHeight());
@ -332,8 +330,7 @@ int MenuHomebrewBrowse()
const int pages = roundup(filecount/4.0f);
bool wifi_btn_loaded=false;
while (menu == MENU_NONE) //set pageToDisplay to 0 to quit
{
while (menu == MENU_NONE) { //set pageToDisplay to 0 to quit
VIDEO_WaitVSync ();
menu = MENU_NONE;
@ -346,14 +343,13 @@ int MenuHomebrewBrowse()
MainButton3.StopEffect();
MainButton4.StopEffect();
if(slidedirection == RIGHT) {
if (slidedirection == RIGHT) {
MainButton1.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35);
MainButton2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35);
MainButton3.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35);
MainButton4.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35);
while (MainButton1.GetEffect()>0) usleep(50);
}
else if(slidedirection == LEFT) {
} else if (slidedirection == LEFT) {
MainButton1.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35);
MainButton2.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35);
MainButton3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35);
@ -366,20 +362,20 @@ int MenuHomebrewBrowse()
mainWindow->RemoveAll();
/** Set new icons **/
for(int i = 0; i < 4; i++) {
if(IconData[i] != NULL) {
for (int i = 0; i < 4; i++) {
if (IconData[i] != NULL) {
delete IconData[i];
IconData[i] = NULL;
}
if(IconImg[i] != NULL) {
if (IconImg[i] != NULL) {
delete IconImg[i];
IconImg[i] = NULL;
}
if(fileoffset+i < (int) filecount) {
if (fileoffset+i < (int) filecount) {
char iconpath[200];
snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+i));
IconData[i] = new GuiImageData(iconpath, 0);
if(IconData[i]->GetImage()) {
if (IconData[i]->GetImage()) {
IconImg[i] = new GuiImage(IconData[i]);
IconImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
IconImg[i]->SetPosition(12, 0);
@ -388,19 +384,19 @@ int MenuHomebrewBrowse()
}
}
if(IconImg[0] != 0)
if (IconImg[0] != 0)
MainButton1.SetIcon(IconImg[0]);
else
MainButton1.SetIcon(NULL);
if(IconImg[1] != 0)
if (IconImg[1] != 0)
MainButton2.SetIcon(IconImg[1]);
else
MainButton2.SetIcon(NULL);
if(IconImg[2] != 0)
if (IconImg[2] != 0)
MainButton3.SetIcon(IconImg[2]);
else
MainButton3.SetIcon(NULL);
if(IconImg[3] != 0)
if (IconImg[3] != 0)
MainButton4.SetIcon(IconImg[3]);
else
MainButton4.SetIcon(NULL);
@ -416,14 +412,14 @@ int MenuHomebrewBrowse()
w.Append(&GoRightBtn);
w.Append(&GoLeftBtn);
if(pageToDisplay == pages) {
if (pageToDisplay == pages) {
int buttonsleft = filecount-(pages-1)*4;
char * shortpath = NULL;
char temp[200];
if(buttonsleft > 0) {
if (buttonsleft > 0) {
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset));
if(XMLInfo[0].LoadHomebrewXMLData(temp) > 0) {
if (XMLInfo[0].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetName());
MainButton1Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetShortDescription());
@ -441,9 +437,9 @@ int MenuHomebrewBrowse()
}
w.Append(&MainButton1);
}
if(buttonsleft > 1) {
if (buttonsleft > 1) {
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1));
if(XMLInfo[1].LoadHomebrewXMLData(temp) > 0){
if (XMLInfo[1].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetName());
MainButton2Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetShortDescription());
@ -461,9 +457,9 @@ int MenuHomebrewBrowse()
}
w.Append(&MainButton2);
}
if(buttonsleft > 2) {
if (buttonsleft > 2) {
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2));
if(XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
if (XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
MainButton3Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
@ -481,9 +477,9 @@ int MenuHomebrewBrowse()
}
w.Append(&MainButton3);
}
if(buttonsleft > 3) {
if (buttonsleft > 3) {
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3));
if(XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
if (XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
MainButton4Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
@ -506,7 +502,7 @@ int MenuHomebrewBrowse()
char *shortpath = NULL;
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset));
if(XMLInfo[0].LoadHomebrewXMLData(temp) > 0) {
if (XMLInfo[0].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetName());
MainButton1Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetShortDescription());
@ -526,7 +522,7 @@ int MenuHomebrewBrowse()
w.Append(&MainButton1);
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1));
if(XMLInfo[1].LoadHomebrewXMLData(temp) > 0){
if (XMLInfo[1].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetName());
MainButton2Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetShortDescription());
@ -546,7 +542,7 @@ int MenuHomebrewBrowse()
w.Append(&MainButton2);
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2));
if(XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
if (XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
MainButton3Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
@ -565,7 +561,7 @@ int MenuHomebrewBrowse()
w.Append(&MainButton3);
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3));
if(XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
if (XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
MainButton4Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
@ -595,19 +591,17 @@ int MenuHomebrewBrowse()
MainButton3.SetEffectGrow();
MainButton4.SetEffectGrow();
if(slidedirection == FADE) {
if (slidedirection == FADE) {
MainButton1.SetEffect(EFFECT_FADE, 20);
MainButton2.SetEffect(EFFECT_FADE, 20);
MainButton3.SetEffect(EFFECT_FADE, 20);
MainButton4.SetEffect(EFFECT_FADE, 20);
}
else if(slidedirection == LEFT) {
} else if (slidedirection == LEFT) {
MainButton1.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35);
MainButton2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35);
MainButton3.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35);
MainButton4.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35);
}
else if(slidedirection == RIGHT) {
} else if (slidedirection == RIGHT) {
MainButton1.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35);
MainButton2.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35);
MainButton3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35);
@ -618,13 +612,12 @@ int MenuHomebrewBrowse()
ResumeGui();
while(MainButton1.GetEffect() > 0) usleep(50);
while (MainButton1.GetEffect() > 0) usleep(50);
while(!changed)
{
while (!changed) {
VIDEO_WaitVSync ();
if(MainButton1.GetState() == STATE_CLICKED) {
if (MainButton1.GetState() == STATE_CLICKED) {
char temp[200];
char iconpath[200];
char metapath[200];
@ -644,15 +637,14 @@ int MenuHomebrewBrowse()
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset));
int choice = HBCWindowPrompt(XMLInfo[0].GetName(), XMLInfo[0].GetCoder(), XMLInfo[0].GetVersion(), XMLInfo[0].GetReleasedate(), XMLInfo[0].GetLongDescription(), iconpath, filesize);
if(choice == 1) {
if (choice == 1) {
boothomebrew = 1;
menu = MENU_EXIT;
snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s", HomebrewFiles.GetFilepath(fileoffset), HomebrewFiles.GetFilename(fileoffset));
break;
}
MainButton1.ResetState();
}
else if(MainButton2.GetState() == STATE_CLICKED) {
} else if (MainButton2.GetState() == STATE_CLICKED) {
char temp[200];
char iconpath[200];
char metapath[200];
@ -672,15 +664,14 @@ int MenuHomebrewBrowse()
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1));
int choice = HBCWindowPrompt(XMLInfo[1].GetName(), XMLInfo[1].GetCoder(), XMLInfo[1].GetVersion(), XMLInfo[1].GetReleasedate(), XMLInfo[1].GetLongDescription(), iconpath, filesize);
if(choice == 1) {
if (choice == 1) {
boothomebrew = 1;
menu = MENU_EXIT;
snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s", HomebrewFiles.GetFilepath(fileoffset+1), HomebrewFiles.GetFilename(fileoffset+1));
break;
}
MainButton2.ResetState();
}
else if(MainButton3.GetState() == STATE_CLICKED) {
} else if (MainButton3.GetState() == STATE_CLICKED) {
char temp[200];
char iconpath[200];
char metapath[200];
@ -700,15 +691,14 @@ int MenuHomebrewBrowse()
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));
int choice = HBCWindowPrompt(XMLInfo[2].GetName(), XMLInfo[2].GetCoder(), XMLInfo[2].GetVersion(), XMLInfo[2].GetReleasedate(), XMLInfo[2].GetLongDescription(), iconpath, filesize);
if(choice == 1) {
if (choice == 1) {
boothomebrew = 1;
menu = MENU_EXIT;
snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s", HomebrewFiles.GetFilepath(fileoffset+2), HomebrewFiles.GetFilename(fileoffset+2));
break;
}
MainButton3.ResetState();
}
else if(MainButton4.GetState() == STATE_CLICKED) {
} else if (MainButton4.GetState() == STATE_CLICKED) {
char temp[200];
char iconpath[200];
char metapath[200];
@ -728,7 +718,7 @@ int MenuHomebrewBrowse()
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3));
int choice = HBCWindowPrompt(XMLInfo[3].GetName(), XMLInfo[3].GetCoder(), XMLInfo[3].GetVersion(), XMLInfo[3].GetReleasedate(), XMLInfo[3].GetLongDescription(), iconpath, filesize);
if(choice == 1) {
if (choice == 1) {
boothomebrew = 1;
menu = MENU_EXIT;
snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s", HomebrewFiles.GetFilepath(fileoffset+3), HomebrewFiles.GetFilename(fileoffset+3));
@ -737,49 +727,48 @@ int MenuHomebrewBrowse()
MainButton4.ResetState();
}
else if(shutdown == 1)
else if (shutdown == 1)
Sys_Shutdown();
else if(reset == 1)
else if (reset == 1)
Sys_Reboot();
else if(backBtn.GetState() == STATE_CLICKED) {
else if (backBtn.GetState() == STATE_CLICKED) {
menu = MENU_DISCLIST;
changed = true;
}
else if(GoLeftBtn.GetState() == STATE_CLICKED) {
else if (GoLeftBtn.GetState() == STATE_CLICKED) {
pageToDisplay--;
/** Change direction of the flying buttons **/
if(pageToDisplay < 1)
if (pageToDisplay < 1)
pageToDisplay = pages;
slidedirection = LEFT;
changed = true;
GoLeftBtn.ResetState();
}
else if(GoRightBtn.GetState() == STATE_CLICKED) {
else if (GoRightBtn.GetState() == STATE_CLICKED) {
pageToDisplay++;
/** Change direction of the flying buttons **/
if(pageToDisplay > pages)
if (pageToDisplay > pages)
pageToDisplay = 1;
slidedirection = RIGHT;
changed = true;
GoRightBtn.ResetState();
}
else if(wifiBtn.GetState() == STATE_CLICKED) {
else if (wifiBtn.GetState() == STATE_CLICKED) {
ResumeNetworkWait();
wifiBtn.ResetState();
}
else if(homo.GetState() == STATE_CLICKED) {
else if (homo.GetState() == STATE_CLICKED) {
cfg_save_global();
s32 thetimeofbg = bgMusic->GetPlayTime();
bgMusic->Stop();
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0);
if(!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path))
{
if (!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) {
bgMusic->Play();
} else {
bgMusic->PlayOggFile(Settings.ogg_path);
@ -787,7 +776,7 @@ int MenuHomebrewBrowse()
bgMusic->SetPlayTime(thetimeofbg);
SetVolumeOgg(255*(Settings.volume/100.0));
if(choice == 3) {
if (choice == 3) {
Sys_LoadMenu(); // Back to System Menu
} else if (choice == 2) {
Sys_BackToLoader();
@ -796,11 +785,11 @@ int MenuHomebrewBrowse()
}
}
else if(infilesize > 0) {
else if (infilesize > 0) {
char filesizetxt[50];
char temp[50];
if(infilesize < MBSIZE)
if (infilesize < MBSIZE)
snprintf(filesizetxt, sizeof(filesizetxt), tr("Incoming file %0.2fKB"), infilesize/KBSIZE);
else
snprintf(filesizetxt, sizeof(filesizetxt), tr("Incoming file %0.2fMB"), infilesize/MBSIZE);
@ -809,11 +798,11 @@ int MenuHomebrewBrowse()
int choice = WindowPrompt(filesizetxt, temp, tr("OK"), tr("Cancel"));
if(choice == 1) {
if (choice == 1) {
int res = AllocHomebrewMemory(infilesize);
if(res < 0) {
if (res < 0) {
CloseConnection();
WindowPrompt(tr("Not enough free memory"), 0, tr("OK"));
} else {
@ -822,23 +811,23 @@ int MenuHomebrewBrowse()
int len = NETWORKBLOCKSIZE;
temp = (u8*) malloc(len);
while(read < infilesize) {
while (read < infilesize) {
ShowProgress(tr("Receiving file from:"), GetNetworkIP(), NULL, read, infilesize, true);
if(infilesize - read < (u32) len)
if (infilesize - read < (u32) len)
len = infilesize-read;
else
len = NETWORKBLOCKSIZE;
int result = network_read(temp, len);
if(result < 0) {
if (result < 0) {
WindowPrompt(tr("Error while transfering data."), 0, tr("OK"));
FreeHomebrewBuffer();
break;
}
if(!result)
if (!result)
break;
CopyHomebrewMemory(read, temp, len);
@ -849,12 +838,10 @@ int MenuHomebrewBrowse()
free(temp);
ProgressStop();
if(read != infilesize) {
if (read != infilesize) {
WindowPrompt(tr("Error:"), tr("No data could be read."), tr("OK"));
FreeHomebrewBuffer();
}
else
{
} else {
//determine what type of file we just got
unsigned char filename[31];
char tmptxt[31];
@ -862,8 +849,7 @@ int MenuHomebrewBrowse()
net_read(connection, &filename, 30);
sprintf(tmptxt,"%s",filename);
//if we got a wad
if(strstr(tmptxt,".wad") || strstr(tmptxt,".WAD"))
{
if (strstr(tmptxt,".wad") || strstr(tmptxt,".WAD")) {
//make a window come up and say that we are saving this file
//because stupid people were clicking buttons while it was saving and tearing stuff up
@ -874,13 +860,14 @@ int MenuHomebrewBrowse()
snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path);
GuiImageData dialogBox(imgPath, dialogue_box_png);
GuiImage dialogBoxImg(&dialogBox);
if (Settings.wsprompt == yes){
dialogBoxImg.SetWidescreen(CFG.widescreen);}
GuiText msgTxt(tr("Saving"), 20, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
if (Settings.wsprompt == yes) {
dialogBoxImg.SetWidescreen(CFG.widescreen);
}
GuiText msgTxt(tr("Saving"), 20, (GXColor) { THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255 });
msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
msgTxt.SetPosition(0,100);
sprintf(tmptxt,"%s/wad/%s",bootDevice,filename);
GuiText msg2Txt(tmptxt, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText msg2Txt(tmptxt, 26, (GXColor) { THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
msg2Txt.SetPosition(0,130);
promptWindow.Append(&dialogBoxImg);
@ -917,8 +904,7 @@ int MenuHomebrewBrowse()
lSize = ftell (file);
rewind (file);
if(lSize==infilesize)
{
if (lSize==infilesize) {
int pick = WindowPrompt(tr(" Wad Saved as:"), tmptxt, tr("Install"),tr("Uninstall"),tr("Cancel"));
//install or uninstall it
if (pick==1)Wad_Install(file);
@ -932,9 +918,8 @@ int MenuHomebrewBrowse()
remove(tmptxt);
}
else if(strstr(tmptxt,".dol") || strstr(tmptxt,".DOL") ||
strstr(tmptxt,".elf") || strstr(tmptxt,".ELF")){
} else if (strstr(tmptxt,".dol") || strstr(tmptxt,".DOL") ||
strstr(tmptxt,".elf") || strstr(tmptxt,".ELF")) {
boothomebrew = 2;
menu = MENU_EXIT;
CloseConnection();
@ -947,7 +932,7 @@ int MenuHomebrewBrowse()
ResumeNetworkWait();
}
else if(channelBtn.GetState() == STATE_CLICKED) {
else if (channelBtn.GetState() == STATE_CLICKED) {
w.SetState(STATE_DISABLED);
//10001 are the channels that are installed as channels, not including shop channel/mii channel etc
u32 num = 0x00010001;
@ -959,9 +944,8 @@ int MenuHomebrewBrowse()
}
if(IsNetworkInit()) {
if(!wifi_btn_loaded)
{
if (IsNetworkInit()) {
if (!wifi_btn_loaded) {
wifiBtn.SetAlpha(255);
titleTT = new GuiTooltip(GetNetworkIP());
@ -974,16 +958,16 @@ int MenuHomebrewBrowse()
}
w.SetEffect(EFFECT_FADE, -20);
while(w.GetEffect()>0) usleep(50);
while (w.GetEffect()>0) usleep(50);
HaltGui();
for(int i = 0; i < 4; i++) {
if(IconData[i] != NULL) {
for (int i = 0; i < 4; i++) {
if (IconData[i] != NULL) {
delete IconData[i];
IconData[i] = NULL;
}
if(IconImg[i] != NULL) {
if (IconImg[i] != NULL) {
delete IconImg[i];
IconImg[i] = NULL;
}
@ -992,7 +976,7 @@ int MenuHomebrewBrowse()
delete titleTT;
titleTT = NULL;
if(IsNetworkInit())
if (IsNetworkInit())
HaltNetworkThread();
mainWindow->RemoveAll();

View File

@ -9,12 +9,11 @@
#include "HomebrewFiles.h"
HomebrewFiles::HomebrewFiles(const char * path)
{
HomebrewFiles::HomebrewFiles(const char * path) {
filecount = 0;
FileInfo = (FileInfos *) malloc(sizeof(FileInfos));
if(!FileInfo) {
if (!FileInfo) {
return;
}
@ -24,45 +23,42 @@ HomebrewFiles::HomebrewFiles(const char * path)
this->SortList();
}
HomebrewFiles::~HomebrewFiles()
{
if(FileInfo) {
HomebrewFiles::~HomebrewFiles() {
if (FileInfo) {
free(FileInfo);
FileInfo = NULL;
}
}
bool HomebrewFiles::LoadPath(const char * folderpath)
{
bool HomebrewFiles::LoadPath(const char * folderpath) {
struct stat st;
DIR_ITER *dir = NULL;
char filename[1024];
dir = diropen(folderpath);
if(dir == NULL) {
if (dir == NULL) {
return false;
}
while (dirnext(dir,filename,&st) == 0)
{
if((st.st_mode & S_IFDIR) != 0) {
if(strcmp(filename,".") != 0 && strcmp(filename,"..") != 0) {
while (dirnext(dir,filename,&st) == 0) {
if ((st.st_mode & S_IFDIR) != 0) {
if (strcmp(filename,".") != 0 && strcmp(filename,"..") != 0) {
char currentname[200];
snprintf(currentname, sizeof(currentname), "%s%s/", folderpath, filename);
this->LoadPath(currentname);
}
} else {
char temp[5];
for(int i = 0; i < 5; i++) {
for (int i = 0; i < 5; i++) {
temp[i] = filename[strlen(filename)-4+i];
}
if((strncasecmp(temp, ".dol", 4) == 0 || strncasecmp(temp, ".elf", 4) == 0)
if ((strncasecmp(temp, ".dol", 4) == 0 || strncasecmp(temp, ".elf", 4) == 0)
&& filecount < MAXHOMEBREWS && filename[0]!='.') {
FileInfo = (FileInfos *) realloc(FileInfo, (filecount+1)*sizeof(FileInfos));
if(!FileInfo) {
if (!FileInfo) {
free(FileInfo);
FileInfo = NULL;
filecount = 0;
@ -84,43 +80,37 @@ bool HomebrewFiles::LoadPath(const char * folderpath)
return true;
}
char * HomebrewFiles::GetFilename(int ind)
{
if(ind > filecount)
char * HomebrewFiles::GetFilename(int ind) {
if (ind > filecount)
return NULL;
else
return FileInfo[ind].FileName;
}
char * HomebrewFiles::GetFilepath(int ind)
{
if(ind > filecount)
char * HomebrewFiles::GetFilepath(int ind) {
if (ind > filecount)
return NULL;
else
return FileInfo[ind].FilePath;
}
unsigned int HomebrewFiles::GetFilesize(int ind)
{
if(ind > filecount || !filecount || !FileInfo)
unsigned int HomebrewFiles::GetFilesize(int ind) {
if (ind > filecount || !filecount || !FileInfo)
return NULL;
else
return FileInfo[ind].FileSize;
}
int HomebrewFiles::GetFilecount()
{
int HomebrewFiles::GetFilecount() {
return filecount;
}
static int ListCompare(const void *a, const void *b)
{
static int ListCompare(const void *a, const void *b) {
FileInfos *ab = (FileInfos*) a;
FileInfos *bb = (FileInfos*) b;
return stricmp((char *) ab->FilePath, (char *) bb->FilePath);
}
void HomebrewFiles::SortList()
{
void HomebrewFiles::SortList() {
qsort(FileInfo, filecount, sizeof(FileInfos), ListCompare);
}

View File

@ -13,9 +13,8 @@ typedef struct {
unsigned int FileSize;
} FileInfos;
class HomebrewFiles
{
public:
class HomebrewFiles {
public:
//!Constructor
//!\param path Path where to check for homebrew files
HomebrewFiles(const char * path);
@ -37,7 +36,7 @@ class HomebrewFiles
int GetFilecount();
//! Sort list by filepath
void SortList();
protected:
protected:
int filecount;
FileInfos *FileInfo;
};

View File

@ -9,8 +9,7 @@
#include "HomebrewXML.h"
HomebrewXML::HomebrewXML()
{
HomebrewXML::HomebrewXML() {
strcpy(name,"");
strcpy(coder,"");
strcpy(version,"");
@ -19,12 +18,10 @@ HomebrewXML::HomebrewXML()
strcpy(longdescription,"");
}
HomebrewXML::~HomebrewXML()
{
HomebrewXML::~HomebrewXML() {
}
int HomebrewXML::LoadHomebrewXMLData(const char* filename)
{
int HomebrewXML::LoadHomebrewXMLData(const char* filename) {
mxml_node_t *nodedataHB = NULL;
mxml_node_t *nodetreeHB = NULL;
char tmp1[40];

View File

@ -5,9 +5,8 @@
#ifndef ___HOMEBREWXML_H_
#define ___HOMEBREWXML_H_
class HomebrewXML
{
public:
class HomebrewXML {
public:
//!Constructor
//!\param path Path for the xml file
HomebrewXML();
@ -16,20 +15,34 @@ class HomebrewXML
//!\param filename Filepath of the XML file
int LoadHomebrewXMLData(const char* filename);
//! Get name
char * GetName() { return name; }
char * GetName() {
return name;
}
//! Get coder
char * GetCoder() { return coder; }
char * GetCoder() {
return coder;
}
//! Get version
char * GetVersion() { return version; }
char * GetVersion() {
return version;
}
//! Get releasedate
char * GetReleasedate() { return releasedate; }
char * GetReleasedate() {
return releasedate;
}
//! Get shortdescription
char * GetShortDescription() { return shortdescription; }
char * GetShortDescription() {
return shortdescription;
}
//! Get longdescription
char * GetLongDescription() { return longdescription; }
char * GetLongDescription() {
return longdescription;
}
//! Set Name
void SetName(char * path) { strncpy(name, path, sizeof(name)); }
protected:
void SetName(char * path) {
strncpy(name, path, sizeof(name));
}
protected:
char name[50];
char coder[100];
char version[30];

View File

@ -33,7 +33,7 @@ u32 load_dol(void *dolstart, struct __argv *argv) {
memmove ((void *) dolfile->text_start[i],dolstart+dolfile->text_pos[i],dolfile->text_size[i]);
}
for(i = 0; i < 11; i++) {
for (i = 0; i < 11; i++) {
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) continue;
VIDEO_WaitVSync();
memmove ((void *) dolfile->data_start[i],dolstart+dolfile->data_pos[i],dolfile->data_size[i]);

View File

@ -2,14 +2,13 @@
#define _DOLLOADER_H_
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
extern void __exception_closeall();
typedef void (*entrypoint) (void);
extern void __exception_closeall();
typedef void (*entrypoint) (void);
u32 load_dol(void *dolstart, struct __argv *argv);
u32 load_dol(void *dolstart, struct __argv *argv);
#ifdef __cplusplus

View File

@ -105,7 +105,7 @@ typedef u16 Elf32_Half; /* Unsigned medium integer */
(ehdr).e_ident[EI_MAG3] == ELFMAG3)
/* ELF Header */
typedef struct elfhdr{
typedef struct elfhdr {
unsigned char e_ident[EI_NIDENT]; /* ELF Identification */
Elf32_Half e_type; /* object file type */
Elf32_Half e_machine; /* machine */
@ -151,7 +151,7 @@ typedef struct elfhdr{
#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */
#if 0
#define EM_SPARC64 11 /* RESERVED - was SPARC v9
64-bit unoffical */
64-bit unoffical */
#endif
/* RESERVED 11-14 for future use */
#define EM_PARISC 15 /* HPPA */
@ -328,7 +328,7 @@ typedef struct {
#define SHF_TLS 0x400 /* Thread local storage */
#define SHF_MASKOS 0x0ff00000 /* OS specific */
#define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */
/* specific section attributes */
/* specific section attributes */
/* Section Group Flags */
#define GRP_COMDAT 0x1 /* COMDAT group */
@ -385,15 +385,13 @@ typedef struct elf32_sym {
/* Relocation entry with implicit addend */
typedef struct
{
typedef struct {
Elf32_Addr r_offset; /* offset of relocation */
Elf32_Word r_info; /* symbol table index and type */
} Elf32_Rel;
/* Relocation entry with explicit addend */
typedef struct
{
typedef struct {
Elf32_Addr r_offset; /* offset of relocation */
Elf32_Word r_info; /* symbol table index and type */
Elf32_Sword r_addend;
@ -437,13 +435,11 @@ typedef struct {
#define PF_R 0x4 /* Readable */
#define PF_MASKOS 0x0ff00000 /* OS specific segment flags */
#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */
/* specific segment flags */
/* specific segment flags */
/* Dynamic structure */
typedef struct
{
typedef struct {
Elf32_Sword d_tag; /* controls meaning of d_val */
union
{
union {
Elf32_Word d_val; /* Multiple meanings - see d_tag */
Elf32_Addr d_ptr; /* program virtual address */
} d_un;
@ -468,7 +464,7 @@ extern Elf32_Dyn _DYNAMIC[];
#define DT_FINI 13 /* address of termination function */
#define DT_SONAME 14 /* string table offset of shared obj */
#define DT_RPATH 15 /* string table offset of library
search path */
search path */
#define DT_SYMBOLIC 16 /* start sym search in shared obj. */
#define DT_REL 17 /* address of rel. tbl. w addends */
#define DT_RELSZ 18 /* size of DT_REL relocation table */
@ -516,7 +512,7 @@ unsigned long elf_hash(const unsigned char *name);
/* Cygnus local bits below */
#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/
#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib
flag */
flag */
/* PowerPC relocations defined by the ABIs */
#define R_PPC_NONE 0

View File

@ -26,8 +26,7 @@
* First looks at the ELF header magic field, the makes sure that it is
* executable and makes sure that it is for a PowerPC.
* ====================================================================== */
s32 valid_elf_image (void *addr)
{
s32 valid_elf_image (void *addr) {
Elf32_Ehdr *ehdr; /* Elf header structure pointer */
ehdr = (Elf32_Ehdr *) addr;
@ -49,8 +48,7 @@ s32 valid_elf_image (void *addr)
* A very simple elf loader, assumes the image is valid, returns the
* entry point address.
* ====================================================================== */
u32 load_elf_image (void *addr)
{
u32 load_elf_image (void *addr) {
Elf32_Ehdr *ehdr;
Elf32_Shdr *shdr;
u8 *strtab = 0;

View File

@ -4,12 +4,11 @@
#include <wiiuse/wpad.h>
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
s32 valid_elf_image (void *addr);
u32 load_elf_image (void *addr);
s32 valid_elf_image (void *addr);
u32 load_elf_image (void *addr);
#ifdef __cplusplus
}

View File

@ -28,10 +28,8 @@ static int rumbleCount[4] = {0,0,0,0};
* ShutoffRumble
***************************************************************************/
void ShutoffRumble()
{
for(int i=0;i<4;i++)
{
void ShutoffRumble() {
for (int i=0;i<4;i++) {
WPAD_Rumble(i, 0);
rumbleCount[i] = 0;
}
@ -41,21 +39,15 @@ void ShutoffRumble()
* DoRumble
***************************************************************************/
void DoRumble(int i)
{
if(rumbleRequest[i] && rumbleCount[i] < 3)
{
void DoRumble(int i) {
if (rumbleRequest[i] && rumbleCount[i] < 3) {
WPAD_Rumble(i, 1); // rumble on
rumbleCount[i]++;
}
else if(rumbleRequest[i])
{
} else if (rumbleRequest[i]) {
rumbleCount[i] = 20;
rumbleRequest[i] = 0;
}
else
{
if(rumbleCount[i])
} else {
if (rumbleCount[i])
rumbleCount[i]--;
WPAD_Rumble(i, 0); // rumble off
}
@ -67,31 +59,25 @@ void DoRumble(int i)
* Get X/Y value from Wii Joystick (classic, nunchuk) input
***************************************************************************/
s8 WPAD_Stick(u8 chan, u8 right, int axis)
{
s8 WPAD_Stick(u8 chan, u8 right, int axis) {
float mag = 0.0;
float ang = 0.0;
WPADData *data = WPAD_Data(chan);
switch (data->exp.type)
{
switch (data->exp.type) {
case WPAD_EXP_NUNCHUK:
case WPAD_EXP_GUITARHERO3:
if (right == 0)
{
if (right == 0) {
mag = data->exp.nunchuk.js.mag;
ang = data->exp.nunchuk.js.ang;
}
break;
case WPAD_EXP_CLASSIC:
if (right == 0)
{
if (right == 0) {
mag = data->exp.classic.ljs.mag;
ang = data->exp.classic.ljs.ang;
}
else
{
} else {
mag = data->exp.classic.rjs.mag;
ang = data->exp.classic.rjs.ang;
}
@ -106,7 +92,7 @@ s8 WPAD_Stick(u8 chan, u8 right, int axis)
else if (mag < -1.0) mag = -1.0;
double val;
if(axis == 0) // x-axis
if (axis == 0) // x-axis
val = mag * sin((PI * ang)/180.0f);
else // y-axis
val = mag * cos((PI * ang)/180.0f);

View File

@ -13,22 +13,20 @@
#include "network/networkops.h"
#include "network/http.h"
int updateLanguageFiles()
{
int updateLanguageFiles() {
char languageFiles[20][MAXLANGUAGEFILES];
//get all the files in the language path
int countfiles = GetAllDirFiles(Settings.languagefiles_path);
//give up now if we didn't find any
if(countfiles==0)return -2;
if (countfiles==0)return -2;
//now from the files we got, get only the .lang files
for (int cnt = 0; cnt < countfiles; cnt++) {
char filename[64];
strncpy(filename, GetFileName(cnt),63);
if (strcasestr(filename,".lang"))
{
if (strcasestr(filename,".lang")) {
strcpy(languageFiles[cnt],filename);
}
}
@ -36,10 +34,9 @@ int updateLanguageFiles()
//we assume that the network will already be init by another function
// ( that has gui eletents in it because this one doesn't)
int done =0,j=0;
if(IsNetworkInit()) {
if (IsNetworkInit()) {
//build the URL, save path, and download each file and save it
while (j<countfiles)
{
while (j<countfiles) {
char savepath[150];
char codeurl[200];
snprintf(codeurl, sizeof(codeurl), "http://usbloader-gui.googlecode.com/svn/trunk/Languages/%s",languageFiles[j]);
@ -47,7 +44,7 @@ int updateLanguageFiles()
struct block file = downloadfile(codeurl);
if(file.data != NULL){
if (file.data != NULL) {
FILE * pfile;
pfile = fopen(savepath, "wb");
fwrite(file.data,1,file.size,pfile);

View File

@ -4,8 +4,7 @@
#include <gctypes.h>
#include "gettext.h"
typedef struct _MSG
{
typedef struct _MSG {
u32 id;
char* msgstr;
struct _MSG *next;
@ -19,20 +18,17 @@ static MSG *baseMSG=0;
[see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
1986, 1987 Bell Telephone Laboratories, Inc.] */
static inline u32
hash_string (const char *str_param)
{
hash_string (const char *str_param) {
u32 hval, g;
const char *str = str_param;
/* Compute the hash value for the given string. */
hval = 0;
while (*str != '\0')
{
while (*str != '\0') {
hval <<= 4;
hval += (u8) *str++;
g = hval & ((u32) 0xf << (HASHWORDBITS - 4));
if (g != 0)
{
if (g != 0) {
hval ^= g >> (HASHWORDBITS - 8);
hval ^= g;
}
@ -42,25 +38,22 @@ hash_string (const char *str_param)
/* Expand some escape sequences found in the argument string. */
static char *
expand_escape (const char *str)
{
expand_escape (const char *str) {
char *retval, *rp;
const char *cp = str;
retval = (char *) malloc (strlen (str)+1);
if(retval==NULL) return NULL;
if (retval==NULL) return NULL;
rp = retval;
while (cp[0] != '\0' && cp[0] != '\\')
*rp++ = *cp++;
if(cp[0] == '\0')
if (cp[0] == '\0')
goto terminate;
do
{
do {
/* Here cp[0] == '\\'. */
switch (*++cp)
{
switch (*++cp) {
case '\"': /* " */
*rp++ = '\"';
++cp;
@ -97,18 +90,21 @@ expand_escape (const char *str)
*rp = '\\';
++cp;
break;
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7': {
int ch = *cp++ - '0';
if (*cp >= '0' && *cp <= '7')
{
if (*cp >= '0' && *cp <= '7') {
ch *= 8;
ch += *cp++ - '0';
if (*cp >= '0' && *cp <= '7')
{
if (*cp >= '0' && *cp <= '7') {
ch *= 8;
ch += *cp++ - '0';
}
@ -123,8 +119,7 @@ expand_escape (const char *str)
while (cp[0] != '\0' && cp[0] != '\\')
*rp++ = *cp++;
}
while (cp[0] != '\0');
} while (cp[0] != '\0');
/* Terminate string. */
terminate:
@ -132,34 +127,28 @@ terminate:
return retval;
}
static MSG *findMSG(u32 id)
{
static MSG *findMSG(u32 id) {
MSG *msg;
for(msg=baseMSG; msg; msg=msg->next)
{
if(msg->id == id)
for (msg=baseMSG; msg; msg=msg->next) {
if (msg->id == id)
return msg;
}
return NULL;
}
static MSG *setMSG(const char *msgid, const char *msgstr)
{
static MSG *setMSG(const char *msgid, const char *msgstr) {
u32 id = hash_string(msgid);
MSG *msg = findMSG(id);
if(!msg)
{
if (!msg) {
msg = (MSG *)malloc(sizeof(MSG));
msg->id = id;
msg->msgstr = NULL;
msg->next = baseMSG;
baseMSG = msg;
}
if(msg)
{
if(msgstr)
{
if(msg->msgstr) free(msg->msgstr);
if (msg) {
if (msgstr) {
if (msg->msgstr) free(msg->msgstr);
//msg->msgstr = strdup(msgstr);
msg->msgstr = expand_escape(msgstr);
}
@ -167,10 +156,8 @@ static MSG *setMSG(const char *msgid, const char *msgstr)
}
return NULL;
}
void gettextCleanUp(void)
{
while(baseMSG)
{
void gettextCleanUp(void) {
while (baseMSG) {
MSG *nextMsg =baseMSG->next;
free(baseMSG->msgstr);
free(baseMSG);
@ -179,45 +166,41 @@ void gettextCleanUp(void)
}
bool gettextLoadLanguage(const char* langFile)
{
bool gettextLoadLanguage(const char* langFile) {
FILE *f;
char line[200];
char *lastID=NULL;
gettextCleanUp();
f = fopen(langFile, "r");
if(!f)
if (!f)
return false;
while (fgets(line, sizeof(line), f))
{
while (fgets(line, sizeof(line), f)) {
// lines starting with # are comments
if (line[0] == '#')
continue;
else if (strncmp(line, "msgid \"", 7) == 0)
{
else if (strncmp(line, "msgid \"", 7) == 0) {
char *msgid, *end;
if(lastID) { free(lastID); lastID=NULL;}
if (lastID) {
free(lastID);
lastID=NULL;
}
msgid = &line[7];
end = strrchr(msgid, '"');
if(end && end-msgid>1)
{
if (end && end-msgid>1) {
*end = 0;
lastID = strdup(msgid);
}
}
else if (strncmp(line, "msgstr \"", 8) == 0)
{
} else if (strncmp(line, "msgstr \"", 8) == 0) {
char *msgstr, *end;
if(lastID == NULL)
if (lastID == NULL)
continue;
msgstr = &line[8];
end = strrchr(msgstr, '"');
if(end && end-msgstr>1)
{
if (end && end-msgstr>1) {
*end = 0;
setMSG(lastID, msgstr);
}
@ -230,10 +213,9 @@ bool gettextLoadLanguage(const char* langFile)
fclose(f);
return true;
}
const char *gettext(const char *msgid)
{
const char *gettext(const char *msgid) {
MSG *msg = findMSG(hash_string(msgid));
if(msg && msg->msgstr) return msg->msgstr;
if (msg && msg->msgstr) return msg->msgstr;
return msgid;
}

View File

@ -2,18 +2,17 @@
#define _GETTEXT_H_
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
bool gettextLoadLanguage(const char* langFile);
void gettextCleanUp(void);
/*
bool gettextLoadLanguage(const char* langFile);
void gettextCleanUp(void);
/*
* input msg = a text in ASCII
* output = the translated msg in utf-8
*/
const char *gettext(const char *msg);
*/
const char *gettext(const char *msg);
#define tr(s) gettext(s)
#define trNOOP(s) (s)

View File

@ -13,19 +13,16 @@
static char alldirfiles[300][70];
char filenames[80];
bool findfile(const char * filename, const char * path)
{
DIR *dir;
struct dirent *file;
bool findfile(const char * filename, const char * path) {
DIR *dir;
struct dirent *file;
dir = opendir(path);
dir = opendir(path);
char temp[11];
while ((file = readdir(dir)))
{
char temp[11];
while ((file = readdir(dir))) {
snprintf(temp,sizeof(temp),"%s",file->d_name);
if (!strncmpi(temp,filename,11))
{
if (!strncmpi(temp,filename,11)) {
closedir(dir);
return true;
}
@ -44,7 +41,7 @@ bool subfoldercreate(char * fullpath) {
snprintf(dirnoslash, strlen(fullpath), "%s", fullpath);
if(stat(fullpath, &st) != 0) {
if (stat(fullpath, &st) != 0) {
pch = strrchr(dirnoslash, '/');
cnt = pch-dirnoslash;
snprintf(dircheck, cnt+2, "%s", dirnoslash);
@ -55,22 +52,19 @@ bool subfoldercreate(char * fullpath) {
return false;
}
return true;
return true;
}
char * GetFileName(int i)
{
char * GetFileName(int i) {
return alldirfiles[i];
}
s32 filenamescmp(const void *a, const void *b)
{
s32 filenamescmp(const void *a, const void *b) {
/* Compare strings */
return stricmp((char *)a, (char *)b);
}
int GetAllDirFiles(char * filespath)
{
int GetAllDirFiles(char * filespath) {
int countfiles = 0;
struct stat st;
@ -79,10 +73,8 @@ int GetAllDirFiles(char * filespath)
if (dir == NULL) //If empty
return 0;
while (dirnext(dir,filenames,&st) == 0)
{
if ((st.st_mode & S_IFDIR) == 0)
{
while (dirnext(dir,filenames,&st) == 0) {
if ((st.st_mode & S_IFDIR) == 0) {
// st.st_mode & S_IFDIR indicates a directory
snprintf(alldirfiles[countfiles], 70, "%s", filenames);
countfiles++;
@ -93,15 +85,14 @@ int GetAllDirFiles(char * filespath)
return countfiles;
}
bool checkfile(char * path)
{
bool checkfile(char * path) {
FILE * f;
f = fopen(path,"r");
if(f) {
if (f) {
fclose(f);
return true;
}
return false;
return false;
}

View File

@ -2,15 +2,14 @@
#define _LISTFILES_H_
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
bool findfile(const char * filename, const char * path);
char * GetFileName(int i);
int GetAllDirFiles(char * filespath);
bool subfoldercreate(char * fullpath);
bool checkfile(char * path);
bool findfile(const char * filename, const char * path);
char * GetFileName(int i);
int GetAllDirFiles(char * filespath);
bool subfoldercreate(char * fullpath);
bool checkfile(char * path);
#ifdef __cplusplus
}

View File

@ -43,24 +43,20 @@ FreeTypeGX *fontSystem=0;
FreeTypeGX *fontClock=0;
int
main(int argc, char *argv[])
{
main(int argc, char *argv[]) {
s32 ret2;
bool bootDevice_found=false;
if(argc >= 1)
{
if(!strncasecmp(argv[0], "usb:/", 5))
{
if (argc >= 1) {
if (!strncasecmp(argv[0], "usb:/", 5)) {
strcpy(bootDevice, "USB:");
bootDevice_found = true;
}
else if(!strncasecmp(argv[0], "sd:/", 4))
} else if (!strncasecmp(argv[0], "sd:/", 4))
bootDevice_found = true;
}
ret2 = IOS_ReloadIOS(249);
if(ret2 < 0) {
if (ret2 < 0) {
ret2 = IOS_ReloadIOS(222);
load_ehc_module();
}
@ -68,11 +64,10 @@ main(int argc, char *argv[])
SDCard_Init(); // mount SD for loading cfg's
USBDevice_Init(); // and mount USB:/
if(!bootDevice_found)
{
if (!bootDevice_found) {
//try USB
//left in all the dol and elf files in this check in case this is the first time running the app and they dont have the config
if(checkfile((char*) "USB:/config/GXglobal.cfg") || (checkfile((char*) "USB:/apps/usbloader_gx/boot.elf"))
if (checkfile((char*) "USB:/config/GXglobal.cfg") || (checkfile((char*) "USB:/apps/usbloader_gx/boot.elf"))
|| checkfile((char*) "USB:/apps/usbloadergx/boot.dol") || (checkfile((char*) "USB:/apps/usbloadergx/boot.elf"))
|| checkfile((char*) "USB:/apps/usbloader_gx/boot.dol"))
strcpy(bootDevice, "USB:");
@ -82,7 +77,7 @@ main(int argc, char *argv[])
CFG_Load();
/* Load Custom IOS */
if(Settings.cios == ios222 && IOS_GetVersion() != 222) {
if (Settings.cios == ios222 && IOS_GetVersion() != 222) {
SDCard_deInit();// unmount SD for reloading IOS
USBDevice_deInit();// unmount USB for reloading IOS
ret2 = IOS_ReloadIOS(222);
@ -93,11 +88,11 @@ main(int argc, char *argv[])
}
SDCard_Init(); // now mount SD:/
USBDevice_Init(); // and mount USB:/
} else if(Settings.cios == ios249 && IOS_GetVersion() != 249) {
} else if (Settings.cios == ios249 && IOS_GetVersion() != 249) {
SDCard_deInit();// unmount SD for reloading IOS
USBDevice_deInit();// unmount USB for reloading IOS
ret2 = IOS_ReloadIOS(249);
if(ret2 < 0) {
if (ret2 < 0) {
Settings.cios = ios222;
ret2 = IOS_ReloadIOS(222);
load_ehc_module();

File diff suppressed because it is too large Load Diff

View File

@ -18,8 +18,7 @@ void ExitGUIThreads(void);
int MainMenu (int menuitem);
enum
{
enum {
MENU_EXIT = -1,
MENU_NONE,
MENU_SETTINGS,

View File

@ -28,63 +28,59 @@ static s32 mload_fd = -1;
// to init/test if the device is running
int mload_init()
{
int n;
int mload_init() {
int n;
if(mload_fd>=0) return 0;
if (mload_fd>=0) return 0;
for(n=0;n<10;n++) // try 2.5 seconds
{
for (n=0;n<10;n++) { // try 2.5 seconds
mload_fd=IOS_Open(mload_fs, 0);
if(mload_fd>=0) break;
if (mload_fd>=0) break;
usleep(250*1000);
}
return mload_fd;
return mload_fd;
}
/*--------------------------------------------------------------------------------------------------------------*/
// to close the device (remember call it when rebooting the IOS!)
int mload_close()
{
int ret;
int mload_close() {
int ret;
if(mload_fd<0) return -1;
if (mload_fd<0) return -1;
ret=IOS_Close(mload_fd);
mload_fd=-1;
return ret;
return ret;
}
/*--------------------------------------------------------------------------------------------------------------*/
// to get the thread id of mload
int mload_get_thread_id()
{
int ret;
s32 hid = -1;
int mload_get_thread_id() {
int ret;
s32 hid = -1;
if(mload_init()<0) return -1;
if (mload_init()<0) return -1;
hid = iosCreateHeap(0x800);
if(hid<0) return hid;
if (hid<0) return hid;
ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_MLOAD_THREAD_ID, ":");
iosDestroyHeap(hid);
return ret;
return ret;
}
@ -92,24 +88,23 @@ return ret;
// get the base and the size of the memory readable/writable to load modules
int mload_get_load_base(u32 *starlet_base, int *size)
{
int ret;
s32 hid = -1;
int mload_get_load_base(u32 *starlet_base, int *size) {
int ret;
s32 hid = -1;
if(mload_init()<0) return -1;
if (mload_init()<0) return -1;
hid = iosCreateHeap(0x800);
if(hid<0) return hid;
if (hid<0) return hid;
ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_GET_LOAD_BASE, ":ii",starlet_base, size);
iosDestroyHeap(hid);
return ret;
return ret;
}
@ -118,38 +113,43 @@ return ret;
// load and run a module from starlet (it need to allocate MEM2 to send the elf file)
// the module must be a elf made with stripios
int mload_module(void *addr, int len)
{
int ret;
void *buf=NULL;
s32 hid = -1;
int mload_module(void *addr, int len) {
int ret;
void *buf=NULL;
s32 hid = -1;
if(mload_init()<0) return -1;
if (mload_init()<0) return -1;
hid = iosCreateHeap(len+0x800);
if(hid<0) return hid;
if (hid<0) return hid;
buf= iosAlloc(hid, len);
if(!buf) {ret= -1;goto out;}
if (!buf) {
ret= -1;
goto out;
}
memcpy(buf, addr,len);
ret = IOS_IoctlvFormat(hid, mload_fd, MLOAD_LOAD_MODULE, ":d", buf, len);
if(ret<0) goto out;
if (ret<0) goto out;
ret=IOS_IoctlvFormat(hid, mload_fd, MLOAD_RUN_MODULE, ":");
if(ret<0) {ret= -666;goto out;}
if (ret<0) {
ret= -666;
goto out;
}
out:
iosDestroyHeap(hid);
return ret;
return ret;
}
@ -158,41 +158,36 @@ return ret;
// load a module from the PPC
// the module must be a elf made with stripios
int mload_elf(void *my_elf, data_elf *data_elf)
{
int n,m;
int p;
u8 *adr;
u32 elf=(u32) my_elf;
int mload_elf(void *my_elf, data_elf *data_elf) {
int n,m;
int p;
u8 *adr;
u32 elf=(u32) my_elf;
if(elf & 3) return -1; // aligned to 4 please!
if (elf & 3) return -1; // aligned to 4 please!
elfheader *head=(void *) elf;
elfphentry *entries;
elfheader *head=(void *) elf;
elfphentry *entries;
if(head->ident0!=0x7F454C46) return -1;
if(head->ident1!=0x01020161) return -1;
if(head->ident2!=0x01000000) return -1;
if (head->ident0!=0x7F454C46) return -1;
if (head->ident1!=0x01020161) return -1;
if (head->ident2!=0x01000000) return -1;
p=head->phoff;
p=head->phoff;
data_elf->start=(void *) head->entry;
data_elf->start=(void *) head->entry;
for(n=0; n<head->phnum; n++)
{
for (n=0; n<head->phnum; n++) {
entries=(void *) (elf+p);
p+=sizeof(elfphentry);
if(entries->type == 4)
{
if (entries->type == 4) {
adr=(void *) (elf + entries->offset);
if(getbe32(0)!=0) return -2; // bad info (sure)
if (getbe32(0)!=0) return -2; // bad info (sure)
for(m=4; m < entries->memsz; m+=8)
{
switch(getbe32(m))
{
for (m=4; m < entries->memsz; m+=8) {
switch (getbe32(m)) {
case 0x9:
data_elf->start= (void *) getbe32(m+4);
break;
@ -210,67 +205,63 @@ for(n=0; n<head->phnum; n++)
}
}
else
if(entries->type == 1 && entries->memsz != 0 && entries->vaddr!=0)
{
} else
if (entries->type == 1 && entries->memsz != 0 && entries->vaddr!=0) {
if(mload_memset((void *) entries->vaddr, 0, entries->memsz)<0) return -1;
if(mload_seek(entries->vaddr, SEEK_SET)<0) return -1;
if(mload_write((void *) (elf + entries->offset), entries->filesz)<0) return -1;
if (mload_memset((void *) entries->vaddr, 0, entries->memsz)<0) return -1;
if (mload_seek(entries->vaddr, SEEK_SET)<0) return -1;
if (mload_write((void *) (elf + entries->offset), entries->filesz)<0) return -1;
}
}
return 0;
return 0;
}
/*--------------------------------------------------------------------------------------------------------------*/
// run one thread (you can use to load modules or binary files)
int mload_run_thread(void *starlet_addr, void *starlet_top_stack, int stack_size, int priority)
{
int ret;
s32 hid = -1;
int mload_run_thread(void *starlet_addr, void *starlet_top_stack, int stack_size, int priority) {
int ret;
s32 hid = -1;
if(mload_init()<0) return -1;
if (mload_init()<0) return -1;
hid = iosCreateHeap(0x800);
if(hid<0) return hid;
if (hid<0) return hid;
ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_RUN_THREAD, "iiii:", starlet_addr,starlet_top_stack, stack_size, priority);
iosDestroyHeap(hid);
return ret;
return ret;
}
/*--------------------------------------------------------------------------------------------------------------*/
// stops one starlet thread
int mload_stop_thread(int id)
{
int ret;
s32 hid = -1;
int mload_stop_thread(int id) {
int ret;
s32 hid = -1;
if(mload_init()<0) return -1;
if (mload_init()<0) return -1;
hid = iosCreateHeap(0x800);
if(hid<0) return hid;
if (hid<0) return hid;
ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_STOP_THREAD, "i:", id);
iosDestroyHeap(hid);
return ret;
return ret;
}
@ -278,33 +269,31 @@ return ret;
// continue one stopped starlet thread
int mload_continue_thread(int id)
{
int ret;
s32 hid = -1;
int mload_continue_thread(int id) {
int ret;
s32 hid = -1;
if(mload_init()<0) return -1;
if (mload_init()<0) return -1;
hid = iosCreateHeap(0x800);
if(hid<0) return hid;
if (hid<0) return hid;
ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_CONTINUE_THREAD, "i:", id);
iosDestroyHeap(hid);
return ret;
return ret;
}
/*--------------------------------------------------------------------------------------------------------------*/
// fix starlet address to read/write (uses SEEK_SET, etc as mode)
int mload_seek(int offset, int mode)
{
if(mload_init()<0) return -1;
int mload_seek(int offset, int mode) {
if (mload_init()<0) return -1;
return IOS_Seek(mload_fd, offset, mode);
}
@ -312,9 +301,8 @@ int mload_seek(int offset, int mode)
// read bytes from starlet (it update the offset)
int mload_read(void* buf, u32 size)
{
if(mload_init()<0) return -1;
int mload_read(void* buf, u32 size) {
if (mload_init()<0) return -1;
return IOS_Read(mload_fd, buf, size);
}
@ -322,9 +310,8 @@ int mload_read(void* buf, u32 size)
// write bytes from starlet (it update the offset)
int mload_write(const void * buf, u32 size)
{
if(mload_init()<0) return -1;
int mload_write(const void * buf, u32 size) {
if (mload_init()<0) return -1;
return IOS_Write(mload_fd, buf, size);
}
@ -332,76 +319,72 @@ int mload_write(const void * buf, u32 size)
// fill a block (similar to memset)
int mload_memset(void *starlet_addr, int set, int len)
{
int ret;
s32 hid = -1;
int mload_memset(void *starlet_addr, int set, int len) {
int ret;
s32 hid = -1;
if(mload_init()<0) return -1;
if (mload_init()<0) return -1;
hid = iosCreateHeap(0x800);
if(hid<0) return hid;
if (hid<0) return hid;
ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_MEMSET, "iii:", starlet_addr, set, len);
iosDestroyHeap(hid);
return ret;
return ret;
}
/*--------------------------------------------------------------------------------------------------------------*/
// get the ehci datas ( ehcmodule.elf uses this address)
void * mload_get_ehci_data()
{
int ret;
s32 hid = -1;
void * mload_get_ehci_data() {
int ret;
s32 hid = -1;
if(mload_init()<0) return NULL;
if (mload_init()<0) return NULL;
hid = iosCreateHeap(0x800);
if(hid<0) return NULL;
if (hid<0) return NULL;
ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_GET_EHCI_DATA, ":");
if(ret<0) return NULL;
if (ret<0) return NULL;
iosDestroyHeap(hid);
return (void *) ret;
return (void *) ret;
}
/*--------------------------------------------------------------------------------------------------------------*/
// set the dev/es ioctlv in routine
int mload_set_ES_ioctlv_vector(void *starlet_addr)
{
int ret;
s32 hid = -1;
int mload_set_ES_ioctlv_vector(void *starlet_addr) {
int ret;
s32 hid = -1;
if(mload_init()<0) return -1;
if (mload_init()<0) return -1;
hid = iosCreateHeap(0x800);
if(hid<0) return hid;
if (hid<0) return hid;
ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_SET_ES_IOCTLV, "i:", starlet_addr);
iosDestroyHeap(hid);
return ret;
return ret;
}
static u32 ios_36[16] ATTRIBUTE_ALIGN(32)=
{
static u32 ios_36[16] ATTRIBUTE_ALIGN(32)= {
0, // DI_EmulateCmd
0,
0x2022DDAC, // dvd_read_controlling_data
@ -414,8 +397,7 @@ static u32 ios_36[16] ATTRIBUTE_ALIGN(32)=
0x20203934+1, // ios_printf (thumb)
};
static u32 ios_38[16] ATTRIBUTE_ALIGN(32)=
{
static u32 ios_38[16] ATTRIBUTE_ALIGN(32)= {
0, // DI_EmulateCmd
0,
0x2022cdac, // dvd_read_controlling_data
@ -433,7 +415,7 @@ int load_ehc_module() {
int is_ios=0;
if(mload_module(ehcmodule, size_ehcmodule)<0) return -1;
if (mload_module(ehcmodule, size_ehcmodule)<0) return -1;
usleep(350*1000);
@ -441,17 +423,13 @@ int load_ehc_module() {
mload_seek(0x20207c84, SEEK_SET);
mload_read(patch_datas, 4);
if(patch_datas[0]==0x6e657665)
{
if (patch_datas[0]==0x6e657665) {
is_ios=38;
}
else
{
} else {
is_ios=36;
}
if(is_ios==36)
{
if (is_ios==36) {
// IOS 36
memcpy(ios_36, dip_plugin, 4); // copy the entry_point
memcpy(dip_plugin, ios_36, 4*10); // copy the adresses from the array
@ -464,8 +442,7 @@ int load_ehc_module() {
mload_write(ios_36, 4);
}
if(is_ios==38)
{
if (is_ios==38) {
// IOS 38
memcpy(ios_38, dip_plugin, 4); // copy the entry_point
@ -483,7 +460,7 @@ int load_ehc_module() {
mload_close();
return 0;
return 0;
}
int patch_cios_data() {

View File

@ -50,8 +50,7 @@ extern "C" {
#define getbe32(x) ((adr[x]<<24) | (adr[x+1]<<16) | (adr[x+2]<<8) | (adr[x+3]))
typedef struct
{
typedef struct {
u32 ident0;
u32 ident1;
u32 ident2;
@ -68,10 +67,9 @@ typedef struct
u16 shentsize;
u16 shnum;
u16 shtrndx;
} elfheader;
} elfheader;
typedef struct
{
typedef struct {
u32 type;
u32 offset;
u32 vaddr;
@ -80,115 +78,114 @@ typedef struct
u32 memsz;
u32 flags;
u32 align;
} elfphentry;
} elfphentry;
typedef struct
{
typedef struct {
void *start;
int prio;
void *stack;
int size_stack;
} data_elf;
} data_elf;
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// to init/test if the device is running
int mload_init();
int mload_init();
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// to close the device (remember call it when rebooting the IOS!)
int mload_close();
int mload_close();
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// to get the thread id of mload
int mload_get_thread_id();
int mload_get_thread_id();
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// get the base and the size of the memory readable/writable to load modules
int mload_get_load_base(u32 *starlet_base, int *size);
int mload_get_load_base(u32 *starlet_base, int *size);
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// load and run a module from starlet (it need to allocate MEM2 to send the elf file)
// the module must be a elf made with stripios
int mload_module(void *addr, int len);
int mload_module(void *addr, int len);
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// load a module from the PPC
// the module must be a elf made with stripios
int mload_elf(void *my_elf, data_elf *data_elf);
int mload_elf(void *my_elf, data_elf *data_elf);
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// run one thread (you can use to load modules or binary files)
int mload_run_thread(void *starlet_addr, void *starlet_top_stack, int stack_size, int priority);
int mload_run_thread(void *starlet_addr, void *starlet_top_stack, int stack_size, int priority);
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// stops one starlet thread
int mload_stop_thread(int id);
int mload_stop_thread(int id);
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// continue one stopped starlet thread
int mload_continue_thread(int id);
int mload_continue_thread(int id);
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// fix starlet address to read/write (uses SEEK_SET, etc as mode)
int mload_seek(int offset, int mode);
int mload_seek(int offset, int mode);
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// read bytes from starlet (it update the offset)
int mload_read(void* buf, u32 size);
int mload_read(void* buf, u32 size);
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// write bytes from starlet (it update the offset)
int mload_write(const void * buf, u32 size);
int mload_write(const void * buf, u32 size);
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// fill a block (similar to memset)
int mload_memset(void *starlet_addr, int set, int len);
int mload_memset(void *starlet_addr, int set, int len);
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// get the ehci datas ( ehcmodule.elf uses this address)
void * mload_get_ehci_data();
void * mload_get_ehci_data();
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
// set the dev/es ioctlv in routine
int mload_set_ES_ioctlv_vector(void *starlet_addr);
int mload_set_ES_ioctlv_vector(void *starlet_addr);
/*--------------------------------------------------------------------------------------------------------------*/
int load_ehc_module();
int patch_cios_data();
/*--------------------------------------------------------------------------------------------------------------*/
int load_ehc_module();
int patch_cios_data();
#ifdef __cplusplus
}
}
#endif

View File

@ -11,19 +11,18 @@
#include "URL_List.h"
URL_List::URL_List(const char * url)
{
URL_List::URL_List(const char * url) {
Links = NULL;
urlcount = 0;
if(!IsNetworkInit()) {
if (!IsNetworkInit()) {
urlcount = -1;
return;
}
struct block file = downloadfile(url);
if(!file.data || !file.size) {
if (!file.data || !file.size) {
urlcount = -2;
return;
}
@ -32,7 +31,7 @@ URL_List::URL_List(const char * url)
char temp[1024];
Links = (Link_Info *) malloc(sizeof(Link_Info));
if(!Links) {
if (!Links) {
free(file.data);
urlcount = -3;
return;
@ -40,14 +39,14 @@ URL_List::URL_List(const char * url)
memset(&Links[urlcount], 0, sizeof(Link_Info));
while(cnt < file.size) {
while (cnt < file.size) {
if(file.data[cnt] == '"' && file.data[cnt-1] == '=' && file.data[cnt-2] == 'f'
if (file.data[cnt] == '"' && file.data[cnt-1] == '=' && file.data[cnt-2] == 'f'
&& file.data[cnt-3] == 'e' && file.data[cnt-4] == 'r' && file.data[cnt-5] == 'h') {
u32 cnt2 = 0;
cnt++;
while(file.data[cnt] != '"' && cnt2 < 1024) {
while (file.data[cnt] != '"' && cnt2 < 1024) {
temp[cnt2] = file.data[cnt];
cnt2++;
cnt++;
@ -56,8 +55,8 @@ URL_List::URL_List(const char * url)
Links = (Link_Info *) realloc(Links, (urlcount+1)*sizeof(Link_Info));
if(!Links) {
for(int i = 0; i == urlcount; i++) {
if (!Links) {
for (int i = 0; i == urlcount; i++) {
delete Links[i].URL;
Links[i].URL = NULL;
}
@ -72,8 +71,8 @@ URL_List::URL_List(const char * url)
Links[urlcount].URL = new char[cnt2+1];
if(!Links[urlcount].URL) {
for(int i = 0; i == urlcount; i++) {
if (!Links[urlcount].URL) {
for (int i = 0; i == urlcount; i++) {
delete Links[i].URL;
Links[i].URL = NULL;
}
@ -86,7 +85,7 @@ URL_List::URL_List(const char * url)
snprintf(Links[urlcount].URL, cnt2+1, "%s", temp);
if(strncmp(Links[urlcount].URL, "http://", strlen("http://")) != 0)
if (strncmp(Links[urlcount].URL, "http://", strlen("http://")) != 0)
Links[urlcount].direct = false;
else
Links[urlcount].direct = true;
@ -99,40 +98,35 @@ URL_List::URL_List(const char * url)
free(file.data);
}
URL_List::~URL_List()
{
for(int i = 0; i == urlcount; i++) {
URL_List::~URL_List() {
for (int i = 0; i == urlcount; i++) {
delete Links[i].URL;
Links[i].URL = NULL;
}
if(Links != NULL) {
if (Links != NULL) {
free(Links);
Links = NULL;
}
}
char * URL_List::GetURL(int ind)
{
if(ind > urlcount || ind < 0 || !Links || urlcount <= 0)
char * URL_List::GetURL(int ind) {
if (ind > urlcount || ind < 0 || !Links || urlcount <= 0)
return NULL;
else
return Links[ind].URL;
}
int URL_List::GetURLCount()
{
int URL_List::GetURLCount() {
return urlcount;
}
static int ListCompare(const void *a, const void *b)
{
static int ListCompare(const void *a, const void *b) {
Link_Info *ab = (Link_Info*) a;
Link_Info *bb = (Link_Info*) b;
return stricmp((char *) ab->URL, (char *) bb->URL);
}
void URL_List::SortList()
{
void URL_List::SortList() {
qsort(Links, urlcount, sizeof(Link_Info), ListCompare);
}

View File

@ -14,9 +14,8 @@ typedef struct {
bool direct;
} Link_Info;
class URL_List
{
public:
class URL_List {
public:
//!Constructor
//!\param url from where to get the list of links
URL_List(const char *url);
@ -31,7 +30,7 @@ class URL_List
int GetURLCount();
//! Sort list
void SortList();
protected:
protected:
int urlcount;
Link_Info *Links;
};

View File

@ -8,14 +8,13 @@
* @param char* The domain name to resolve
* @return u32 The ipaddress represented by four bytes inside an u32 (in network order)
*/
u32 getipbyname(char *domain)
{
u32 getipbyname(char *domain) {
//Care should be taken when using net_gethostbyname,
//it returns a static buffer which makes it not threadsafe
//TODO: implement some locking mechanism to make below code atomic
struct hostent *host = net_gethostbyname(domain);
if(host == NULL) {
if (host == NULL) {
return 0;
}
@ -44,21 +43,18 @@ static int dnsentrycount = 0;
* Performs the same function as getipbyname(),
* except that it will prevent extremely expensive net_gethostbyname() calls by caching the result
*/
u32 getipbynamecached(char *domain)
{
u32 getipbynamecached(char *domain) {
//Search if this domainname is already cached
struct dnsentry *node = firstdnsentry;
struct dnsentry *previousnode = NULL;
while(node != NULL)
{
if(strcmp(node->domain, domain) == 0)
{
while (node != NULL) {
if (strcmp(node->domain, domain) == 0) {
//DNS node found in the cache, move it to the front of the list
if(previousnode != NULL)
if (previousnode != NULL)
previousnode->nextnode = node->nextnode;
if(node != firstdnsentry)
if (node != firstdnsentry)
node->nextnode = firstdnsentry;
firstdnsentry = node;
@ -72,14 +68,13 @@ u32 getipbynamecached(char *domain)
//No cache of this domain could be found, create a cache node and add it to the front of the cache
struct dnsentry *newnode = malloc(sizeof(struct dnsentry));
if(newnode == NULL) {
if (newnode == NULL) {
return ip;
}
newnode->ip = ip;
newnode->domain = malloc(strlen(domain)+1);
if(newnode->domain == NULL)
{
if (newnode->domain == NULL) {
free(newnode);
return ip;
}
@ -90,24 +85,20 @@ u32 getipbynamecached(char *domain)
dnsentrycount++;
//If the cache grows too big delete the last (and probably least important) node of the list
if(dnsentrycount > MAX_DNS_CACHE_ENTRIES)
{
if (dnsentrycount > MAX_DNS_CACHE_ENTRIES) {
struct dnsentry *node = firstdnsentry;
struct dnsentry *previousnode = NULL;
//Fetch the last two elements of the list
while(node->nextnode != NULL)
{
while (node->nextnode != NULL) {
previousnode = node;
node = node->nextnode;
}
if(node == NULL)
{
if (node == NULL) {
printf("Configuration error, MAX_DNS_ENTRIES reached while the list is empty\n");
exit(1);
} else if(previousnode == NULL)
{
} else if (previousnode == NULL) {
firstdnsentry = NULL;
} else {
previousnode->nextnode = NULL;

View File

@ -9,12 +9,11 @@
#include <unistd.h> //usleep
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
u32 getipbyname(char *domain);
u32 getipbynamecached(char *domain);
u32 getipbyname(char *domain);
u32 getipbynamecached(char *domain);
#ifdef __cplusplus
}

View File

@ -67,37 +67,33 @@ static s32 server_connect(u32 ipaddress, u32 socket_port) {
* @param s32 connection The connection identifier to suck the response out of
* @return block A 'block' struct (see http.h) in which the buffer is located
*/
struct block read_message(s32 connection)
{
struct block read_message(s32 connection) {
//Create a block of memory to put in the response
struct block buffer;
buffer.data = malloc(HTTP_BUFFER_SIZE);
buffer.size = HTTP_BUFFER_SIZE;
if(buffer.data == NULL) {
if (buffer.data == NULL) {
return emptyblock;
}
//The offset variable always points to the first byte of memory that is free in the buffer
u32 offset = 0;
while(1)
{
while (1) {
//Fill the buffer with a new batch of bytes from the connection,
//starting from where we left of in the buffer till the end of the buffer
s32 bytes_read = net_read(connection, buffer.data + offset, buffer.size - offset);
//Anything below 0 is an error in the connection
if(bytes_read < 0)
{
if (bytes_read < 0) {
//printf("Connection error from net_read() Errorcode: %i\n", bytes_read);
return emptyblock;
}
//No more bytes were read into the buffer,
//we assume this means the HTTP response is done
if(bytes_read == 0)
{
if (bytes_read == 0) {
break;
}
@ -105,13 +101,11 @@ struct block read_message(s32 connection)
//Check if we have enough buffer left over,
//if not expand it with an additional HTTP_BUFFER_GROWTH worth of bytes
if(offset >= buffer.size)
{
if (offset >= buffer.size) {
buffer.size += HTTP_BUFFER_GROWTH;
buffer.data = realloc(buffer.data, buffer.size);
if(buffer.data == NULL)
{
if (buffer.data == NULL) {
return emptyblock;
}
}
@ -130,11 +124,9 @@ struct block read_message(s32 connection)
* Downloads the contents of a URL to memory
* This method is not threadsafe (because networking is not threadsafe on the Wii)
*/
struct block downloadfile(const char *url)
{
struct block downloadfile(const char *url) {
//Check if the url starts with "http://", if not it is not considered a valid url
if(strncmp(url, "http://", strlen("http://")) != 0)
{
if (strncmp(url, "http://", strlen("http://")) != 0) {
//printf("URL '%s' doesn't start with 'http://'\n", url);
return emptyblock;
}
@ -143,8 +135,7 @@ struct block downloadfile(const char *url)
char *path = strchr(url + strlen("http://"), '/');
//At the very least the url has to end with '/', ending with just a domain is invalid
if(path == NULL)
{
if (path == NULL) {
//printf("URL '%s' has no PATH part\n", url);
return emptyblock;
}
@ -152,8 +143,7 @@ struct block downloadfile(const char *url)
//Extract the domain part out of the url
int domainlength = path - url - strlen("http://");
if(domainlength == 0)
{
if (domainlength == 0) {
//printf("No domain part in URL '%s'\n", url);
return emptyblock;
}
@ -165,8 +155,7 @@ struct block downloadfile(const char *url)
//Parsing of the URL is done, start making an actual connection
u32 ipaddress = getipbynamecached(domain);
if(ipaddress == 0)
{
if (ipaddress == 0) {
//printf("\ndomain %s could not be resolved", domain);
return emptyblock;
}
@ -174,7 +163,7 @@ struct block downloadfile(const char *url)
s32 connection = server_connect(ipaddress, 80);
if(connection < 0) {
if (connection < 0) {
//printf("Error establishing connection");
return emptyblock;
}
@ -193,21 +182,18 @@ struct block downloadfile(const char *url)
unsigned char *filestart = NULL;
u32 filesize = 0;
int i;
for(i = 3; i < response.size; i++)
{
if(response.data[i] == '\n' &&
for (i = 3; i < response.size; i++) {
if (response.data[i] == '\n' &&
response.data[i-1] == '\r' &&
response.data[i-2] == '\n' &&
response.data[i-3] == '\r')
{
response.data[i-3] == '\r') {
filestart = response.data + i + 1;
filesize = response.size - i - 1;
break;
}
}
if(filestart == NULL)
{
if (filestart == NULL) {
//printf("HTTP Response was without a file\n");
free(response.data);
return emptyblock;
@ -218,8 +204,7 @@ struct block downloadfile(const char *url)
file.data = malloc(filesize);
file.size = filesize;
if(file.data == NULL)
{
if (file.data == NULL) {
//printf("No more memory to copy file from HTTP response\n");
free(response.data);
return emptyblock;
@ -236,7 +221,7 @@ struct block downloadfile(const char *url)
s32 GetConnection(char * domain) {
u32 ipaddress = getipbynamecached(domain);
if(ipaddress == 0) {
if (ipaddress == 0) {
return -1;
}
s32 connection = server_connect(ipaddress, 80);

View File

@ -7,25 +7,23 @@
#include <string.h>
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
#include "dns.h"
/**
/**
* A simple structure to keep track of the size of a malloc()ated block of memory
*/
struct block
{
struct block {
u32 size;
unsigned char *data;
};
};
extern const struct block emptyblock;
extern const struct block emptyblock;
struct block downloadfile(const char *url);
s32 GetConnection(char * domain);
struct block downloadfile(const char *url);
s32 GetConnection(char * domain);
#ifdef __cplusplus
}

View File

@ -40,13 +40,13 @@ static bool networkHalt = true;
***************************************************************************/
void Initialize_Network(void) {
if(networkinitialized) return;
if (networkinitialized) return;
s32 result;
result = if_config(IP, NULL, NULL, true);
if(result < 0) {
if (result < 0) {
networkinitialized = false;
return;
} else {
@ -58,33 +58,30 @@ void Initialize_Network(void) {
/****************************************************************************
* Check if network was initialised
***************************************************************************/
bool IsNetworkInit(void)
{
bool IsNetworkInit(void) {
return networkinitialized;
}
/****************************************************************************
* Get network IP
***************************************************************************/
char * GetNetworkIP(void)
{
char * GetNetworkIP(void) {
return IP;
}
/****************************************************************************
* Get network IP
***************************************************************************/
bool ShutdownWC24()
{
bool ShutdownWC24() {
bool onlinefix = IsNetworkInit();
if(onlinefix) {
if (onlinefix) {
s32 kd_fd, ret;
STACK_ALIGN(u8, kd_buf, 0x20, 32);
kd_fd = IOS_Open("/dev/net/kd/request", 0);
if (kd_fd >= 0) {
ret = IOS_Ioctl(kd_fd, 7, NULL, 0, kd_buf, 0x20);
if(ret >= 0)
if (ret >= 0)
onlinefix = false; // fixed no IOS reload needed
IOS_Close(kd_fd);
}
@ -92,8 +89,7 @@ bool ShutdownWC24()
return onlinefix;
}
s32 network_request(const char * request)
{
s32 network_request(const char * request) {
char buf[1024];
char *ptr = NULL;
@ -125,8 +121,7 @@ s32 network_request(const char * request)
return size;
}
s32 network_read(u8 *buf, u32 len)
{
s32 network_read(u8 *buf, u32 len) {
u32 read = 0;
s32 ret = -1;
@ -154,8 +149,7 @@ s32 network_read(u8 *buf, u32 len)
s32 download_request(const char * url) {
//Check if the url starts with "http://", if not it is not considered a valid url
if(strncmp(url, "http://", strlen("http://")) != 0)
{
if (strncmp(url, "http://", strlen("http://")) != 0) {
return -1;
}
@ -163,16 +157,14 @@ s32 download_request(const char * url) {
char *path = strchr(url + strlen("http://"), '/');
//At the very least the url has to end with '/', ending with just a domain is invalid
if(path == NULL)
{
if (path == NULL) {
return -1;
}
//Extract the domain part out of the url
int domainlength = path - url - strlen("http://");
if(domainlength == 0)
{
if (domainlength == 0) {
return -1;
}
@ -181,7 +173,7 @@ s32 download_request(const char * url) {
domain[domainlength] = '\0';
connection = GetConnection(domain);
if(connection < 0) {
if (connection < 0) {
return -1;
}
@ -198,7 +190,7 @@ void CloseConnection() {
net_close(connection);
if(waitforanswer) {
if (waitforanswer) {
net_close(socket);
waitforanswer = false;
}
@ -209,7 +201,7 @@ void CloseConnection() {
***************************************************************************/
int NetworkWait() {
if(!checkincomming)
if (!checkincomming)
return -3;
struct sockaddr_in sin;
@ -219,8 +211,7 @@ int NetworkWait() {
//Open socket
socket = net_socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
if (socket == INVALID_SOCKET)
{
if (socket == INVALID_SOCKET) {
return socket;
}
@ -228,22 +219,19 @@ int NetworkWait() {
sin.sin_port = htons(PORT);
sin.sin_addr.s_addr = htonl(INADDR_ANY);
if (net_bind(socket, (struct sockaddr*)&sin, sizeof(sin)) < 0)
{
if (net_bind(socket, (struct sockaddr*)&sin, sizeof(sin)) < 0) {
net_close(socket);
return -1;
}
if (net_listen(socket, 3) < 0)
{
if (net_listen(socket, 3) < 0) {
net_close(socket);
return -1;
}
connection = net_accept(socket, (struct sockaddr*)&client_address, &addrlen);
if (connection < 0)
{
if (connection < 0) {
net_close(connection);
net_close(socket);
return -4;
@ -265,31 +253,30 @@ int NetworkWait() {
/****************************************************************************
* Update check
***************************************************************************/
int CheckUpdate()
{
if(!networkinitialized)
int CheckUpdate() {
if (!networkinitialized)
return -1;
int revnumber = 0;
int currentrev = atoi(GetRev());
#ifdef NOTFULLCHANNEL
#ifdef NOTFULLCHANNEL
struct block file = downloadfile("http://www.techjawa.com/usbloadergx/rev.txt");
#else
#else
struct block file = downloadfile("http://www.techjawa.com/usbloadergx/wadrev.txt");
#endif
#endif
char revtxt[10];
u8 i;
if(file.data != NULL) {
for(i=0; i<9 || i < file.size; i++)
if (file.data != NULL) {
for (i=0; i<9 || i < file.size; i++)
revtxt[i] = file.data[i];
revtxt[i] = 0;
revnumber = atoi(revtxt);
free(file.data);
}
if(revnumber > currentrev)
if (revnumber > currentrev)
//if(revnumber > 1)//for testing updates
return revnumber;
else
@ -299,24 +286,22 @@ int CheckUpdate()
/****************************************************************************
* HaltNetwork
***************************************************************************/
void HaltNetworkThread()
{
void HaltNetworkThread() {
networkHalt = true;
checkincomming = false;
if(waitforanswer)
if (waitforanswer)
CloseConnection();
// wait for thread to finish
while(!LWP_ThreadIsSuspended(networkthread))
while (!LWP_ThreadIsSuspended(networkthread))
usleep(100);
}
/****************************************************************************
* ResumeNetworkThread
***************************************************************************/
void ResumeNetworkThread()
{
void ResumeNetworkThread() {
networkHalt = false;
LWP_ResumeThread(networkthread);
}
@ -324,8 +309,7 @@ void ResumeNetworkThread()
/****************************************************************************
* Resume NetworkWait
***************************************************************************/
void ResumeNetworkWait()
{
void ResumeNetworkWait() {
networkHalt = true;
checkincomming = true;
waitforanswer = true;
@ -337,18 +321,17 @@ void ResumeNetworkWait()
/*********************************************************************************
* Networkthread for background network initialize and update check with idle prio
*********************************************************************************/
static void * networkinitcallback(void *arg)
{
while(1) {
static void * networkinitcallback(void *arg) {
while (1) {
if(!checkincomming && networkHalt)
if (!checkincomming && networkHalt)
LWP_SuspendThread(networkthread);
Initialize_Network();
if(networkinitialized == true && updatechecked == false) {
if (networkinitialized == true && updatechecked == false) {
if(CheckUpdate() > 0)
if (CheckUpdate() > 0)
updateavailable = true;
//suspend thread
@ -357,7 +340,7 @@ static void * networkinitcallback(void *arg)
checkincomming = false;
}
if(checkincomming)
if (checkincomming)
NetworkWait();
}
return NULL;
@ -366,16 +349,14 @@ static void * networkinitcallback(void *arg)
/****************************************************************************
* InitNetworkThread with priority 0 (idle)
***************************************************************************/
void InitNetworkThread()
{
void InitNetworkThread() {
LWP_CreateThread (&networkthread, networkinitcallback, NULL, NULL, 0, 0);
}
/****************************************************************************
* ShutdownThread
***************************************************************************/
void ShutdownNetworkThread()
{
void ShutdownNetworkThread() {
LWP_JoinThread (networkthread, NULL);
networkthread = LWP_THREAD_NULL;
}

View File

@ -36,8 +36,7 @@
#define READ_SAMPLES 4096 // samples that it must read before to send
#define MAX_PCMOUT 4096 // minimum size to read ogg samples
typedef struct
{
typedef struct {
OggVorbis_File vf;
vorbis_info *vi;
int current_section;
@ -68,10 +67,8 @@ static lwpq_t oggplayer_queue = LWP_THREAD_NULL;
static lwp_t h_oggplayer = LWP_THREAD_NULL;
static int ogg_thread_running = 0;
static void ogg_add_callback(int voice)
{
if (!ogg_thread_running)
{
static void ogg_add_callback(int voice) {
if (!ogg_thread_running) {
ASND_StopVoice(0);
return;
}
@ -79,30 +76,24 @@ static void ogg_add_callback(int voice)
if (private_ogg.flag & 128)
return; // Ogg is paused
if (private_ogg.pcm_indx >= READ_SAMPLES)
{
if (private_ogg.pcm_indx >= READ_SAMPLES) {
if (ASND_AddVoice(0,
(void *) private_ogg.pcmout[private_ogg.pcmout_pos],
private_ogg.pcm_indx << 1) == 0)
{
private_ogg.pcm_indx << 1) == 0) {
private_ogg.pcmout_pos ^= 1;
private_ogg.pcm_indx = 0;
private_ogg.flag = 0;
LWP_ThreadSignal(oggplayer_queue);
}
}
else
{
if (private_ogg.flag & 64)
{
} else {
if (private_ogg.flag & 64) {
private_ogg.flag &= ~64;
LWP_ThreadSignal(oggplayer_queue);
}
}
}
static void * ogg_player_thread(private_data_ogg * priv)
{
static void * ogg_player_thread(private_data_ogg * priv) {
int first_time = 1;
long ret;
@ -122,25 +113,20 @@ static void * ogg_player_thread(private_data_ogg * priv)
ogg_thread_running = 1;
while (!priv[0].eof && ogg_thread_running)
{
while (!priv[0].eof && ogg_thread_running) {
if (priv[0].flag)
LWP_ThreadSleep(oggplayer_queue); // wait only when i have samples to send
if (priv[0].flag == 0) // wait to all samples are sended
{
if (priv[0].flag == 0) { // wait to all samples are sended
if (ASND_TestPointer(0, priv[0].pcmout[priv[0].pcmout_pos])
&& ASND_StatusVoice(0) != SND_UNUSED)
{
&& ASND_StatusVoice(0) != SND_UNUSED) {
priv[0].flag |= 64;
continue;
}
if (priv[0].pcm_indx < READ_SAMPLES)
{
if (priv[0].pcm_indx < READ_SAMPLES) {
priv[0].flag = 3;
if (priv[0].seek_time >= 0)
{
if (priv[0].seek_time >= 0) {
ov_time_seek(&priv[0].vf, priv[0].seek_time);
priv[0].seek_time = -1;
}
@ -151,45 +137,35 @@ static void * ogg_player_thread(private_data_ogg * priv)
(void *) &priv[0].pcmout[priv[0].pcmout_pos][priv[0].pcm_indx],
MAX_PCMOUT,/*0,2,1,*/&priv[0].current_section);
priv[0].flag &= 192;
if (ret == 0)
{
if (ret == 0) {
/* EOF */
if (priv[0].mode & 1)
ov_time_seek(&priv[0].vf, 0); // repeat
else
priv[0].eof = 1; // stops
//
}
else if (ret < 0)
{
} else if (ret < 0) {
/* error in the stream. Not a problem, just reporting it in
case we (the app) cares. In this case, we don't. */
if (ret != OV_HOLE)
{
if (ret != OV_HOLE) {
if (priv[0].mode & 1)
ov_time_seek(&priv[0].vf, 0); // repeat
else
priv[0].eof = 1; // stops
}
}
else
{
} else {
/* we don't bother dealing with sample rate changes, etc, but
you'll have to*/
priv[0].pcm_indx += ret >> 1; //get 16 bits samples
}
}
else
} else
priv[0].flag = 1;
}
if (priv[0].flag == 1)
{
if (ASND_StatusVoice(0) == SND_UNUSED || first_time)
{
if (priv[0].flag == 1) {
if (ASND_StatusVoice(0) == SND_UNUSED || first_time) {
first_time = 0;
if (priv[0].vi->channels == 2)
{
if (priv[0].vi->channels == 2) {
ASND_SetVoice(0, VOICE_STEREO_16BIT, priv[0].vi->rate, 0,
(void *) priv[0].pcmout[priv[0].pcmout_pos],
priv[0].pcm_indx << 1, priv[0].volume,
@ -197,9 +173,7 @@ static void * ogg_player_thread(private_data_ogg * priv)
priv[0].pcmout_pos ^= 1;
priv[0].pcm_indx = 0;
priv[0].flag = 0;
}
else
{
} else {
ASND_SetVoice(0, VOICE_MONO_16BIT, priv[0].vi->rate, 0,
(void *) priv[0].pcmout[priv[0].pcmout_pos],
priv[0].pcm_indx << 1, priv[0].volume,
@ -220,27 +194,23 @@ static void * ogg_player_thread(private_data_ogg * priv)
return 0;
}
void StopOgg()
{
void StopOgg() {
ASND_StopVoice(0);
ogg_thread_running = 0;
if(h_oggplayer != LWP_THREAD_NULL)
{
if(oggplayer_queue != LWP_TQUEUE_NULL)
if (h_oggplayer != LWP_THREAD_NULL) {
if (oggplayer_queue != LWP_TQUEUE_NULL)
LWP_ThreadSignal(oggplayer_queue);
LWP_JoinThread(h_oggplayer, NULL);
h_oggplayer = LWP_THREAD_NULL;
}
if(oggplayer_queue != LWP_TQUEUE_NULL)
{
if (oggplayer_queue != LWP_TQUEUE_NULL) {
LWP_CloseQueue(oggplayer_queue);
oggplayer_queue = LWP_TQUEUE_NULL;
}
}
int PlayOgg(int fd, int time_pos, int mode)
{
int PlayOgg(int fd, int time_pos, int mode) {
StopOgg();
private_ogg.fd = fd;
@ -253,13 +223,11 @@ int PlayOgg(int fd, int time_pos, int mode)
if (time_pos > 0)
private_ogg.seek_time = time_pos;
if (fd < 0)
{
if (fd < 0) {
private_ogg.fd = -1;
return -1;
}
if (ov_open((void *) &private_ogg.fd, &private_ogg.vf, NULL, 0) < 0)
{
if (ov_open((void *) &private_ogg.fd, &private_ogg.vf, NULL, 0) < 0) {
mem_close(private_ogg.fd); // mem_close() can too close files from devices
private_ogg.fd = -1;
ogg_thread_running = 0;
@ -267,8 +235,7 @@ int PlayOgg(int fd, int time_pos, int mode)
}
if (LWP_CreateThread(&h_oggplayer, (void *) ogg_player_thread,
&private_ogg, oggplayer_stack, STACKSIZE, 80) == -1)
{
&private_ogg, oggplayer_stack, STACKSIZE, 80) == -1) {
ogg_thread_running = 0;
ov_clear(&private_ogg.vf);
private_ogg.fd = -1;
@ -289,7 +256,7 @@ int PlayOggFromFile(char * path, int loop) {
pFile = fopen (path, "rb");
//Check that pFile exist
if (pFile==NULL){
if (pFile==NULL) {
return -1;
}
@ -300,11 +267,17 @@ int PlayOggFromFile(char * path, int loop) {
// allocate memory to contain the whole file:
bufferogg = (char*) malloc (sizeof(char)*filesize);
if (bufferogg == NULL) {fputs (" Memory error",stderr); exit (2);}
if (bufferogg == NULL) {
fputs (" Memory error",stderr);
exit (2);
}
// copy the file into the buffer:
resultogg = fread (bufferogg,1,filesize,pFile);
if (resultogg != filesize) {fputs (" Reading error",stderr); exit (3);}
if (resultogg != filesize) {
fputs (" Reading error",stderr);
exit (3);
}
fclose (pFile);
@ -315,20 +288,14 @@ int PlayOggFromFile(char * path, int loop) {
}
void PauseOgg(int pause)
{
if (pause)
{
void PauseOgg(int pause) {
if (pause) {
private_ogg.flag |= 128;
}
else
{
if (private_ogg.flag & 128)
{
} else {
if (private_ogg.flag & 128) {
private_ogg.flag |= 64;
private_ogg.flag &= ~128;
if (ogg_thread_running > 0)
{
if (ogg_thread_running > 0) {
LWP_ThreadSignal(oggplayer_queue);
}
}
@ -336,8 +303,7 @@ void PauseOgg(int pause)
}
}
int StatusOgg()
{
int StatusOgg() {
if (ogg_thread_running == 0)
return -1; // Error
else if (private_ogg.eof)
@ -348,14 +314,12 @@ int StatusOgg()
return 1; // running
}
void SetVolumeOgg(int volume)
{
void SetVolumeOgg(int volume) {
private_ogg.volume = volume;
ASND_ChangeVolumeVoice(0, volume, volume);
}
s32 GetTimeOgg()
{
s32 GetTimeOgg() {
int ret;
if (ogg_thread_running == 0 || private_ogg.fd < 0)
return 0;
@ -366,8 +330,7 @@ s32 GetTimeOgg()
return ret;
}
void SetTimeOgg(s32 time_pos)
{
void SetTimeOgg(s32 time_pos) {
if (time_pos >= 0)
private_ogg.seek_time = time_pos;
}

View File

@ -32,8 +32,7 @@
#include "tremor/ivorbisfile.h"
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
#define OGG_ONE_TIME 0
@ -44,11 +43,11 @@ extern "C"
#define OGG_STATUS_PAUSED 2
#define OGG_STATUS_EOF 255
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Player OGG functions */
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Player OGG functions */
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* int PlayOgg(int fd, int time_pos, int mode);
/* int PlayOgg(int fd, int time_pos, int mode);
Play an Ogg file. This file can be loaded from memory (mem_open(void *ogg, int size_ogg)) or from device with open("device:file.ogg",O_RDONLY,0);
@ -66,17 +65,17 @@ extern "C"
*/
int PlayOgg(int fd, int time_pos, int mode);
int PlayOgg(int fd, int time_pos, int mode);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* int PlayOgg(char * path, int loop);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* int PlayOgg(char * path, int loop);
Just give the function the full device+path to OGG to play it
loop = 1 for Loop and 0 for one time playing
*/
int PlayOggFromFile(char * path, int loop);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
*/
int PlayOggFromFile(char * path, int loop);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* void StopOgg();
/* void StopOgg();
Stop an Ogg file.
@ -87,11 +86,11 @@ int PlayOggFromFile(char * path, int loop);
*/
void StopOgg();
void StopOgg();
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* void PauseOgg(int pause);
/* void PauseOgg(int pause);
Pause an Ogg file.
@ -101,11 +100,11 @@ void StopOgg();
*/
void PauseOgg(int pause);
void PauseOgg(int pause);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* int StatusOgg();
/* int StatusOgg();
Return the Ogg status
@ -119,11 +118,11 @@ void PauseOgg(int pause);
*/
int StatusOgg();
int StatusOgg();
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* void SetVolumeOgg(int volume);
/* void SetVolumeOgg(int volume);
Set the Ogg playing volume.
NOTE: it change the volume of voice 0 (used for the Ogg player)
@ -134,11 +133,11 @@ int StatusOgg();
*/
void SetVolumeOgg(int volume);
void SetVolumeOgg(int volume);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* s32 GetTimeOgg();
/* s32 GetTimeOgg();
Return the Ogg time from the starts of the file
@ -149,11 +148,11 @@ void SetVolumeOgg(int volume);
*/
s32 GetTimeOgg();
s32 GetTimeOgg();
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* void SetTimeOgg(s32 time_pos);
/* void SetTimeOgg(s32 time_pos);
Set the time position
@ -165,9 +164,9 @@ s32 GetTimeOgg();
*/
void SetTimeOgg(s32 time_pos);
void SetTimeOgg(s32 time_pos);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
#ifdef __cplusplus
}

View File

@ -64,13 +64,11 @@
#define _SHIFTR(v, s, w) \
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
struct dicommand
{
struct dicommand {
u32 diReg[8];
};
struct dicontext
{
struct dicontext {
lwp_node node;
dvdcallbacklow cb;
struct dicommand *cmd;
@ -93,43 +91,38 @@ static char __di_fs[] ATTRIBUTE_ALIGN(32) = "/dev/di";
extern u32 __IPC_ClntInit();
static __inline__ lwp_node* __lwp_queue_head(lwp_queue *queue)
{
static __inline__ lwp_node* __lwp_queue_head(lwp_queue *queue) {
return (lwp_node*)queue;
}
static __inline__ lwp_node* __lwp_queue_tail(lwp_queue *queue)
{
static __inline__ lwp_node* __lwp_queue_tail(lwp_queue *queue) {
return (lwp_node*)&queue->perm_null;
}
static __inline__ void __lwp_queue_init_empty(lwp_queue *queue)
{
static __inline__ void __lwp_queue_init_empty(lwp_queue *queue) {
queue->first = __lwp_queue_tail(queue);
queue->perm_null = NULL;
queue->last = __lwp_queue_head(queue);
}
static struct dicontext* __dvd_getcontext(dvdcallbacklow cb)
{
static struct dicontext* __dvd_getcontext(dvdcallbacklow cb) {
struct dicontext *ctx;
ctx = (struct dicontext*)__lwp_queue_get(&__di_contextq);
if(ctx!=NULL) ctx->cb = cb;
if (ctx!=NULL) ctx->cb = cb;
return ctx;
}
static s32 __dvd_iostransactionCB(s32 result,void *usrdata)
{
static s32 __dvd_iostransactionCB(s32 result,void *usrdata) {
struct dicontext *ctx = (struct dicontext*)usrdata;
__dvd_reqinprogress = 0;
if(ctx->cb!=NULL) {
if (ctx->cb!=NULL) {
__dvd_cbinprogress = 1;
if(result!=0) __dvd_readlength = 0;
if (result!=0) __dvd_readlength = 0;
ctx->cb(result);
__dvd_cbinprogress = 0;
}
@ -138,14 +131,13 @@ static s32 __dvd_iostransactionCB(s32 result,void *usrdata)
return 0;
}
static s32 __dvd_ioscoverregisterCB(s32 result,void *usrdata)
{
static s32 __dvd_ioscoverregisterCB(s32 result,void *usrdata) {
struct dicontext *ctx = (struct dicontext*)usrdata;
__dvd_reqinprogress = 0;
__di_regvalcache[1] = __di_regbuffer[0];
if(ctx->cb!=NULL) {
if (ctx->cb!=NULL) {
__dvd_cbinprogress = 1;
ctx->cb(result);
__dvd_cbinprogress = 0;
@ -155,13 +147,12 @@ static s32 __dvd_ioscoverregisterCB(s32 result,void *usrdata)
return 0;
}
static s32 __dvd_ioscovercloseCB(s32 result,void *usrdata)
{
static s32 __dvd_ioscovercloseCB(s32 result,void *usrdata) {
struct dicontext *ctx = (struct dicontext*)usrdata;
__dvd_reqinprogress = 0;
if(ctx->cb!=NULL) {
if (ctx->cb!=NULL) {
__dvd_cbinprogress = 1;
ctx->cb(result);
__dvd_cbinprogress = 0;
@ -171,20 +162,19 @@ static s32 __dvd_ioscovercloseCB(s32 result,void *usrdata)
return 0;
}
s32 bwDVD_LowInit()
{
s32 bwDVD_LowInit() {
s32 i,ret = 0;
u32 ipclo,ipchi;
lwp_queue inactives;
struct dicontext *ctx;
if(__dvd_lowinitcalled==0) {
if (__dvd_lowinitcalled==0) {
ret = __IPC_ClntInit();
if(ret<0) return ret;
if (ret<0) return ret;
ipclo = (((u32)IPC_GetBufferLo()+0x1f)&~0x1f);
ipchi = (u32)IPC_GetBufferHi();
if(ipchi>=(ipclo+(sizeof(struct dicommand)*DI_CMDCTX_CNT))) {
if (ipchi>=(ipclo+(sizeof(struct dicommand)*DI_CMDCTX_CNT))) {
__di_commands = (struct dicommand*)ipclo;
IPC_SetBufferLo((void*)(ipclo+(sizeof(struct dicommand)*DI_CMDCTX_CNT)));
@ -193,7 +183,7 @@ s32 bwDVD_LowInit()
i = 0;
__lwp_queue_init_empty(&__di_contextq);
__lwp_queue_initialize(&inactives,__di_contexts,DI_CMDCTX_CNT,sizeof(struct dicontext));
while((ctx=(struct dicontext*)__lwp_queue_get(&inactives))!=NULL) {
while ((ctx=(struct dicontext*)__lwp_queue_get(&inactives))!=NULL) {
ctx->cmd = &__di_commands[i];
ctx->cb = NULL;
__lwp_queue_append(&__di_contextq,&ctx->node);
@ -203,7 +193,7 @@ s32 bwDVD_LowInit()
}
ret = IOS_Open(__di_fs,0);
if(ret<0) return ret;
if (ret<0) return ret;
__dvd_fd = ret;
// __dvd_lowinitcalled = 1;
@ -213,8 +203,7 @@ s32 bwDVD_LowInit()
return 0;
}
s32 bwDVD_LowInquiry(dvddrvinfo *info,dvdcallbacklow cb)
{
s32 bwDVD_LowInquiry(dvddrvinfo *info,dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
@ -222,7 +211,7 @@ s32 bwDVD_LowInquiry(dvddrvinfo *info,dvdcallbacklow cb)
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_INQUIRY<<24);
@ -231,8 +220,7 @@ s32 bwDVD_LowInquiry(dvddrvinfo *info,dvdcallbacklow cb)
return ret;
}
s32 bwDVD_LowReadID(dvddiskid *diskID,dvdcallbacklow cb)
{
s32 bwDVD_LowReadID(dvddiskid *diskID,dvdcallbacklow cb) {
s32 ret = 0;
struct dicontext *ctx;
struct dicommand *cmd;
@ -242,7 +230,7 @@ s32 bwDVD_LowReadID(dvddiskid *diskID,dvdcallbacklow cb)
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_READID<<24);
@ -253,19 +241,18 @@ s32 bwDVD_LowReadID(dvddiskid *diskID,dvdcallbacklow cb)
}
s32 bwDVD_LowRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb)
{
s32 bwDVD_LowRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
if(buf==NULL || ((u32)buf%32)!=0) return -1;
if (buf==NULL || ((u32)buf%32)!=0) return -1;
__dvd_reqinprogress = 1;
__dvd_readlength = len;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_READ<<24);
@ -277,8 +264,7 @@ s32 bwDVD_LowRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb)
}
// never got this function working, probably removed from wii
s32 bwDVD_LowReadVideo(void *buf,u32 len,u32 offset,dvdcallbacklow cb)
{
s32 bwDVD_LowReadVideo(void *buf,u32 len,u32 offset,dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
@ -287,7 +273,7 @@ s32 bwDVD_LowReadVideo(void *buf,u32 len,u32 offset,dvdcallbacklow cb)
__dvd_readlength = len;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_READ_DVDVIDEO<<24);
@ -300,8 +286,7 @@ s32 bwDVD_LowReadVideo(void *buf,u32 len,u32 offset,dvdcallbacklow cb)
s32 bwDVD_LowStopLaser(dvdcallbacklow cb)
{
s32 bwDVD_LowStopLaser(dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
@ -309,7 +294,7 @@ s32 bwDVD_LowStopLaser(dvdcallbacklow cb)
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_STOPLASER<<24);
@ -319,8 +304,7 @@ s32 bwDVD_LowStopLaser(dvdcallbacklow cb)
}
// never got this function working, probably removed from wii
s32 bwDVD_EnableVideo(dvdcallbacklow cb)
{
s32 bwDVD_EnableVideo(dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
@ -328,7 +312,7 @@ s32 bwDVD_EnableVideo(dvdcallbacklow cb)
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_ENABLE_DVD<<24);
@ -337,8 +321,7 @@ s32 bwDVD_EnableVideo(dvdcallbacklow cb)
return ret;
}
s32 bwDVD_LowSeek(u32 offset,dvdcallbacklow cb)
{
s32 bwDVD_LowSeek(u32 offset,dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
@ -346,7 +329,7 @@ s32 bwDVD_LowSeek(u32 offset,dvdcallbacklow cb)
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_SEEK<<24);
@ -356,8 +339,7 @@ s32 bwDVD_LowSeek(u32 offset,dvdcallbacklow cb)
return ret;
}
s32 bwDVD_LowOffset(u64 offset,dvdcallbacklow cb)
{
s32 bwDVD_LowOffset(u64 offset,dvdcallbacklow cb) {
s32 ret;
u32 *off = (u32*)(void*)(&offset);
struct dicontext *ctx;
@ -366,20 +348,19 @@ s32 bwDVD_LowOffset(u64 offset,dvdcallbacklow cb)
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_OFFSET<<24);
cmd->diReg[1] = 0;
if(off[0]) cmd->diReg[1] = 1;
if (off[0]) cmd->diReg[1] = 1;
cmd->diReg[2] = off[1];
ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_OFFSET,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx);
return ret;
}
s32 bwDVD_LowPrepareCoverRegister(dvdcallbacklow cb)
{
s32 bwDVD_LowPrepareCoverRegister(dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
@ -387,7 +368,7 @@ s32 bwDVD_LowPrepareCoverRegister(dvdcallbacklow cb)
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_COVER<<24);
@ -396,20 +377,19 @@ s32 bwDVD_LowPrepareCoverRegister(dvdcallbacklow cb)
return ret;
}
s32 bwDVD_LowOpenPartition(u32 offset,void *eticket,u32 certin_len,void *certificate_in,void *certificate_out,dvdcallbacklow cb)
{
s32 bwDVD_LowOpenPartition(u32 offset,void *eticket,u32 certin_len,void *certificate_in,void *certificate_out,dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
if(eticket!=NULL && ((u32)eticket%32)!=0) return -1;
if(certificate_in!=NULL && ((u32)certificate_in%32)!=0) return -1;
if(certificate_out!=NULL && ((u32)certificate_out%32)!=0) return -1;
if (eticket!=NULL && ((u32)eticket%32)!=0) return -1;
if (certificate_in!=NULL && ((u32)certificate_in%32)!=0) return -1;
if (certificate_out!=NULL && ((u32)certificate_out%32)!=0) return -1;
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_OPENPART<<24);
@ -419,11 +399,11 @@ s32 bwDVD_LowOpenPartition(u32 offset,void *eticket,u32 certin_len,void *certifi
__di_iovector[0].len = sizeof(struct dicommand);
__di_iovector[1].data = eticket;
if(eticket==NULL) __di_iovector[1].len = 0;
if (eticket==NULL) __di_iovector[1].len = 0;
else __di_iovector[1].len = 676;
__di_iovector[2].data = certificate_in;
if(certificate_in==NULL) __di_iovector[2].len = 0;
if (certificate_in==NULL) __di_iovector[2].len = 0;
else __di_iovector[2].len = certin_len;
__di_iovector[3].data = certificate_out;
@ -435,8 +415,7 @@ s32 bwDVD_LowOpenPartition(u32 offset,void *eticket,u32 certin_len,void *certifi
return ret;
}
s32 bwDVD_LowClosePartition(dvdcallbacklow cb)
{
s32 bwDVD_LowClosePartition(dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
@ -444,7 +423,7 @@ s32 bwDVD_LowClosePartition(dvdcallbacklow cb)
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_CLOSEPART<<24);
@ -453,8 +432,7 @@ s32 bwDVD_LowClosePartition(dvdcallbacklow cb)
return ret;
}
s32 bwDVD_LowUnencryptedRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb)
{
s32 bwDVD_LowUnencryptedRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
@ -463,7 +441,7 @@ s32 bwDVD_LowUnencryptedRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb)
__dvd_readlength = len;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_UNENCREAD<<24);
@ -474,8 +452,7 @@ s32 bwDVD_LowUnencryptedRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb)
return ret;
}
s32 bwDVD_LowWaitCoverClose(dvdcallbacklow cb)
{
s32 bwDVD_LowWaitCoverClose(dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
@ -483,7 +460,7 @@ s32 bwDVD_LowWaitCoverClose(dvdcallbacklow cb)
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_WAITCVRCLOSE<<24);
@ -492,16 +469,15 @@ s32 bwDVD_LowWaitCoverClose(dvdcallbacklow cb)
return ret;
}
s32 bwDVD_LowResetNotify()
{
s32 bwDVD_LowResetNotify() {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
if(__dvd_cbinprogress==1) return -1;
if (__dvd_cbinprogress==1) return -1;
ctx = __dvd_getcontext(NULL);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_RESETNOTIFY<<24);
@ -510,8 +486,7 @@ s32 bwDVD_LowResetNotify()
return ret;
}
s32 bwDVD_LowReset(dvdcallbacklow cb)
{
s32 bwDVD_LowReset(dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
@ -520,7 +495,7 @@ s32 bwDVD_LowReset(dvdcallbacklow cb)
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_RESET<<24);
@ -531,8 +506,7 @@ s32 bwDVD_LowReset(dvdcallbacklow cb)
return ret;
}
s32 bwDVD_LowStopMotor(u8 stop1,u8 stop2,dvdcallbacklow cb)
{
s32 bwDVD_LowStopMotor(u8 stop1,u8 stop2,dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
@ -540,7 +514,7 @@ s32 bwDVD_LowStopMotor(u8 stop1,u8 stop2,dvdcallbacklow cb)
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_STOPMOTOR<<24);
@ -552,8 +526,7 @@ s32 bwDVD_LowStopMotor(u8 stop1,u8 stop2,dvdcallbacklow cb)
}
s32 bwDVD_LowRequestError(dvdcallbacklow cb)
{
s32 bwDVD_LowRequestError(dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
@ -561,7 +534,7 @@ s32 bwDVD_LowRequestError(dvdcallbacklow cb)
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_REQERROR<<24);
@ -571,8 +544,7 @@ s32 bwDVD_LowRequestError(dvdcallbacklow cb)
}
s32 bwDVD_SetDecryption(s32 mode, dvdcallbacklow cb)
{
s32 bwDVD_SetDecryption(s32 mode, dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
@ -580,7 +552,7 @@ s32 bwDVD_SetDecryption(s32 mode, dvdcallbacklow cb)
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_SETCRYPTMODE<<24);
@ -591,8 +563,7 @@ s32 bwDVD_SetDecryption(s32 mode, dvdcallbacklow cb)
}
s32 bwDVD_SetOffset(u32 offset, dvdcallbacklow cb)
{
s32 bwDVD_SetOffset(u32 offset, dvdcallbacklow cb) {
s32 ret;
struct dicontext *ctx;
struct dicommand *cmd;
@ -600,7 +571,7 @@ s32 bwDVD_SetOffset(u32 offset, dvdcallbacklow cb)
__dvd_reqinprogress = 1;
ctx = __dvd_getcontext(cb);
if(ctx==NULL) return IPC_ENOMEM;
if (ctx==NULL) return IPC_ENOMEM;
cmd = ctx->cmd;
cmd->diReg[0] = (IOCTL_DI_SETOFFBASE<<24);

View File

@ -27,27 +27,27 @@
#include <ogc/dvd.h>
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif /* __cplusplus */
typedef void (*dvdcallbacklow)(s32 result);
typedef void (*dvdcallbacklow)(s32 result);
s32 bwDVD_LowInit();
s32 bwDVD_LowInquiry(dvddrvinfo *info,dvdcallbacklow cb);
s32 bwDVD_LowReadID(dvddiskid *diskID,dvdcallbacklow cb);
s32 bwDVD_LowClosePartition(dvdcallbacklow cb);
s32 bwDVD_LowOpenPartition(u32 offset,void *eticket,u32 certin_len,void *certificate_in,void *certificate_out,dvdcallbacklow cb);
s32 bwDVD_LowUnencryptedRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb);
s32 bwDVD_LowReset(dvdcallbacklow cb);
s32 bwDVD_LowWaitCoverClose(dvdcallbacklow cb);
s32 bwDVD_LowRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb);
s32 bwDVD_EnableVideo(dvdcallbacklow cb);
s32 bwDVD_LowReadVideo(void *buf,u32 len,u32 offset,dvdcallbacklow cb);
s32 bwDVD_SetDecryption(s32 mode, dvdcallbacklow cb);
s32 bwDVD_SetOffset(u32 offset, dvdcallbacklow cb);
s32 bwDVD_LowInit();
s32 bwDVD_LowInquiry(dvddrvinfo *info,dvdcallbacklow cb);
s32 bwDVD_LowReadID(dvddiskid *diskID,dvdcallbacklow cb);
s32 bwDVD_LowClosePartition(dvdcallbacklow cb);
s32 bwDVD_LowOpenPartition(u32 offset,void *eticket,u32 certin_len,void *certificate_in,void *certificate_out,dvdcallbacklow cb);
s32 bwDVD_LowUnencryptedRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb);
s32 bwDVD_LowReset(dvdcallbacklow cb);
s32 bwDVD_LowWaitCoverClose(dvdcallbacklow cb);
s32 bwDVD_LowRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb);
s32 bwDVD_EnableVideo(dvdcallbacklow cb);
s32 bwDVD_LowReadVideo(void *buf,u32 len,u32 offset,dvdcallbacklow cb);
s32 bwDVD_SetDecryption(s32 mode, dvdcallbacklow cb);
s32 bwDVD_SetOffset(u32 offset, dvdcallbacklow cb);
#ifdef __cplusplus
}
}
#endif /* __cplusplus */
#endif

View File

@ -37,8 +37,7 @@
extern struct SSettings Settings;
u32 do_sd_code(char *filename)
{
u32 do_sd_code(char *filename) {
FILE *fp;
u8 *filebuff;
u32 filesize;
@ -67,7 +66,7 @@ u32 do_sd_code(char *filename)
fseek(fp, 0, SEEK_SET);
filebuff = (u8*) malloc (filesize);
if(filebuff == 0){
if (filebuff == 0) {
fclose(fp);
sleep(2);
USBDevice_deInit();
@ -76,7 +75,7 @@ u32 do_sd_code(char *filename)
}
ret = fread(filebuff, 1, filesize, fp);
if(ret != filesize){
if (ret != filesize) {
free(filebuff);
fclose(fp);
USBDevice_deInit();

View File

@ -23,12 +23,11 @@
#define __FST_H__
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
//u32 do_fst(u32 fstlocation);
u32 do_sd_code(char *filename);
u32 do_sd_code(char *filename);
#ifdef __cplusplus
}

View File

@ -146,23 +146,20 @@ static const u32 wpadlibogc[5] = {
0x90A402E0,0x806502E4,0x908502E4,0x2C030000,0x906402E4
};
void dogamehooks(void *addr, u32 len)
{
void dogamehooks(void *addr, u32 len) {
void *addr_start = addr;
void *addr_end = addr+len;
while(addr_start < addr_end)
{
while (addr_start < addr_end) {
switch(hooktype)
{
switch (hooktype) {
case 0:
break;
case 1:
if(memcmp(addr_start, viwiihooks, sizeof(viwiihooks))==0){
if (memcmp(addr_start, viwiihooks, sizeof(viwiihooks))==0) {
// printf("\n\n\n");
// printf("found at address %x\n", addr_start);
// sleep(2);
@ -172,7 +169,7 @@ void dogamehooks(void *addr, u32 len)
}
break;
/*
/*
case 2:
if(memcmp(addr_start, kpadhooks, sizeof(kpadhooks))==0){
patchhook((u32)addr_start, len);
@ -197,16 +194,16 @@ void dogamehooks(void *addr, u32 len)
patchhook3((u32)addr_start, len);
}
break;
*/
*/
case 2:
if(memcmp(addr_start, viwiihooks, sizeof(viwiihooks))==0){
if (memcmp(addr_start, viwiihooks, sizeof(viwiihooks))==0) {
patchhook2((u32)addr_start, len);
}
break;
/*
/*
case 6:
// jap region free
if(memcmp(addr_start, regionfreehooks, sizeof(regionfreehooks))==0){
@ -268,14 +265,14 @@ void dogamehooks(void *addr, u32 len)
movedvdhooks((u32)addr_start, len);
}
break;
*/
*/
// multidol
case 3:
if(memcmp(addr_start, multidolpatch1, sizeof(multidolpatch1))==0){
if (memcmp(addr_start, multidolpatch1, sizeof(multidolpatch1))==0) {
multidolpatchone((u32)addr_start, len);
}
if(memcmp(addr_start, multidolpatch2, sizeof(multidolpatch2))==0){
if (memcmp(addr_start, multidolpatch2, sizeof(multidolpatch2))==0) {
multidolpatchtwo((u32)addr_start, len);
}
break;
@ -285,15 +282,13 @@ void dogamehooks(void *addr, u32 len)
}
// Not used yet, for patching DOL once loaded into memory and befor execution
void patchdol(void *addr, u32 len)
{
void patchdol(void *addr, u32 len) {
void *addr_start = addr;
void *addr_end = addr+len;
while(addr_start < addr_end)
{
if(memcmp(addr_start, wpadlibogc, sizeof(wpadlibogc))==0) {
while (addr_start < addr_end) {
if (memcmp(addr_start, wpadlibogc, sizeof(wpadlibogc))==0) {
// printf("\n\n\n");
// printf("found at address %x\n", addr_start);
// sleep(10);
@ -305,17 +300,15 @@ void patchdol(void *addr, u32 len)
}
}
void langpatcher(void *addr, u32 len)
{
void langpatcher(void *addr, u32 len) {
void *addr_start = addr;
void *addr_end = addr+len;
while(addr_start < addr_end)
{
while (addr_start < addr_end) {
if(memcmp(addr_start, langpatch, sizeof(langpatch))==0) {
if(configbytes[0] != 0xCD){
if (memcmp(addr_start, langpatch, sizeof(langpatch))==0) {
if (configbytes[0] != 0xCD) {
langvipatch((u32)addr_start, len, configbytes[0]);
}
}
@ -323,16 +316,14 @@ void langpatcher(void *addr, u32 len)
}
}
void patchdebug(void *addr, u32 len)
{
void patchdebug(void *addr, u32 len) {
void *addr_start = addr;
void *addr_end = addr+len;
while(addr_start < addr_end)
{
while (addr_start < addr_end) {
if(memcmp(addr_start, fwritepatch, sizeof(fwritepatch))==0) {
if (memcmp(addr_start, fwritepatch, sizeof(fwritepatch))==0) {
memcpy(addr_start,fwrite_patch_bin,fwrite_patch_bin_len);
// apply patch
@ -341,15 +332,13 @@ void patchdebug(void *addr, u32 len)
}
}
void vidolpatcher(void *addr, u32 len)
{
void vidolpatcher(void *addr, u32 len) {
void *addr_start = addr;
void *addr_end = addr+len;
while(addr_start < addr_end)
{
if(memcmp(addr_start, vipatchcode, sizeof(vipatchcode))==0) {
while (addr_start < addr_end) {
if (memcmp(addr_start, vipatchcode, sizeof(vipatchcode))==0) {
vipatch((u32)addr_start, len);
}
addr_start += 4;

View File

@ -22,20 +22,19 @@
#ifndef __PATCHCODE_H__
#define __PATCHCODE_H__
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
// Globals
u32 hooktype;
int patched;
u8 configbytes[2];
u32 regionfree;
u32 hooktype;
int patched;
u8 configbytes[2];
u32 regionfree;
// Function prototypes
void dogamehooks(void *addr, u32 len);
void langpatcher(void *addr, u32 len);
void vidolpatcher(void *addr, u32 len);
void patchdebug(void *addr, u32 len);
void dogamehooks(void *addr, u32 len);
void langpatcher(void *addr, u32 len);
void vidolpatcher(void *addr, u32 len);
void patchdebug(void *addr, u32 len);

View File

@ -1,43 +1,43 @@
# (c) Nuke www.usbgecko.com. Licensed under GPL V2
# (c) Nuke www.usbgecko.com. Licensed under GPL V2
.text
#include "ppc.h"
.globl patchhook # r3 address
patchhook:
mtctr r4
lis r6, 0x4E80
ori r6, r6, 0x0020 # blr
mtctr r4
lis r6, 0x4E80
ori r6, r6, 0x0020 # blr
findblr:
lwz r5, 0(r3)
cmpw r6, r5
beq writebranch
addi r3, r3, 4 # next word
bdnz findblr # loop length
b exit # stop unhooked game hanging
lwz r5, 0(r3)
cmpw r6, r5
beq writebranch
addi r3, r3, 4 # next word
bdnz findblr # loop length
b exit # stop unhooked game hanging
writebranch:
lis r4, 0x8000 # 800018A0 hook location (source)
ori r4, r4, 0x18A8
subf r4, r3, r4 # subtract r3 from r4 and place in r4
lis r5, 0x3FF
ori r5, r5, 0xFFFF # 0x3FFFFFF
and r4, r4, r5
lis r5, 0x4800 # 0x48000000
or r4, r4, r5
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
lis r4, 0x8000 # 800018A0 hook location (source)
ori r4, r4, 0x18A8
subf r4, r3, r4 # subtract r3 from r4 and place in r4
lis r5, 0x3FF
ori r5, r5, 0xFFFF # 0x3FFFFFF
and r4, r4, r5
lis r5, 0x4800 # 0x48000000
or r4, r4, r5
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exit:
blr # return
blr # return
.globl patchhook2 # r3 address
patchhook2:
.globl patchhook2 # r3 address
patchhook2:
mtctr r4
lis r6, 0x4E80
ori r6, r6, 0x0020 # blr
findblr2:
findblr2:
lwz r5, 0(r3)
cmpw r6, r5
beq writebranch2
@ -45,7 +45,7 @@ findblr2:
bdnz findblr2 # loop length
b exit2 # stop unhooked game hanging
writebranch2:
writebranch2:
lis r4, 0x8000 # 81700000 our temp patcher
ori r4, r4, 0x18a8
subf r4, r3, r4 # subtract r3 from r4 and place in r4
@ -57,15 +57,15 @@ writebranch2:
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exit2:
exit2:
blr # return
.globl patchhook3 # r3 address
patchhook3:
.globl patchhook3 # r3 address
patchhook3:
mtctr r4
lis r6, 0x4BFF
ori r6, r6, 0xE955 # blr
findbne:
findbne:
lwz r5, 0(r3)
cmpw r6, r5
beq writebl
@ -73,21 +73,21 @@ findbne:
bdnz findbne # loop length
b exit3 # stop unhooked game hanging
writebl:
writebl:
lis r4, 0x4BFF # 81700000 our temp patcher
ori r4, r4, 0xEA91
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exit3:
exit3:
blr # return
.globl patchhook4 # r3 address
patchhook4:
.globl patchhook4 # r3 address
patchhook4:
mtctr r4
lis r6, 0x4082
ori r6, r6, 0x001C # blr
findregion:
findregion:
lwz r5, 0(r3)
cmpw r6, r5
beq writebr
@ -95,21 +95,21 @@ findregion:
bdnz findregion # loop length
b exit4 # stop unhooked game hanging
writebr:
writebr:
lis r4, 0x4800
ori r4, r4, 0x001C
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exit4:
exit4:
blr # return
.globl multidolpatchone # r3 address
multidolpatchone:
.globl multidolpatchone # r3 address
multidolpatchone:
mtctr r4
lis r6, 0x3800
ori r6, r6, 0x0001 # (li r0,1)
findmulti:
findmulti:
lwz r5, 0(r3)
cmpw r6, r5
beq writemulti
@ -117,7 +117,7 @@ findmulti:
bdnz findmulti # loop length
b exit5 # stop unhooked game hanging
writemulti:
writemulti:
lis r4, 0x8170 # 81700000
ori r4, r4, 0x0020
subf r18, r3, r4 # subf r18,(source),(dest)
@ -131,15 +131,15 @@ writemulti:
sync
icbi r0, r3
isync
exit5:
exit5:
blr # return
.globl multidolpatchtwo # r3 address
multidolpatchtwo:
.globl multidolpatchtwo # r3 address
multidolpatchtwo:
mtctr r4
lis r6, 0x3F60
ori r6, r6, 0x8000 # (lis r27,-32768)
findmulti2:
findmulti2:
lwz r5, 0(r3)
cmpw r6, r5
beq writemulti2
@ -147,7 +147,7 @@ findmulti2:
bdnz findmulti2 # loop length
b exit6 # stop unhooked game hanging
writemulti2:
writemulti2:
lis r4, 0x8170 # 81700020
ori r4, r4, 0x0000
subf r18, r3, r4 # subf r18,(source),(dest)
@ -161,15 +161,15 @@ writemulti2:
sync
icbi r0, r3
isync
exit6:
exit6:
blr # return
.globl langvipatch # r3 address, r4 len, r5 lang byte
langvipatch:
.globl langvipatch # r3 address, r4 len, r5 lang byte
langvipatch:
mtctr r4
lis r6, 0x8861
ori r6, r6, 0x0008 # lbz r3, 8(sp)
findlang:
findlang:
lwz r7, 0(r3)
cmpw r6, r7
beq patchlang
@ -177,23 +177,23 @@ findlang:
bdnz findlang # loop length
b exitlang # stop unhooked game hanging
patchlang:
patchlang:
lis r4, 0x3860 # 0x38600001 li %r3, 1 # eng
add r4, r4, r5
gofinal:
gofinal:
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exitlang:
exitlang:
blr # return
.globl vipatch # r3 address
vipatch:
.globl vipatch # r3 address
vipatch:
mtctr r4
lis r6, 0x5400
ori r6, r6, 0xFFFE
findvi:
findvi:
lwz r5, 0(r3)
cmpw r6, r5
beq patchvi
@ -201,7 +201,7 @@ findvi:
bdnz findvi # loop length
b exitvi # stop unhooked game hanging
patchvi:
patchvi:
lis r4, 0x8000
ori r4, r4, 0x0003
lbz r5, 0(r4)
@ -210,26 +210,26 @@ patchvi:
cmpwi r5, 0x4A
beq patchjap2 # JAP
b exitvi
patchjap2:
patchjap2:
lis r4, 0x3800
ori r4, r4, 0x0001
b gofinal2
patchusa:
patchusa:
lis r4, 0x3800
ori r4, r4, 0x0000
gofinal2:
gofinal2:
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exitvi:
exitvi:
blr # return
.globl regionfreejap # r3 address
regionfreejap:
.globl regionfreejap # r3 address
regionfreejap:
mtctr r4
lis r6, 0x2C1B
ori r6, r6, 0x0000 # blr
findjap:
findjap:
lwz r5, 0(r3)
cmpw r6, r5
beq writenop
@ -237,22 +237,22 @@ findjap:
bdnz findjap # loop length
b exitjap # stop unhooked game hanging
writenop:
writenop:
addi r3, r3, 4 # next word
lis r4, 0x6000 # nop
ori r4, r4, 0x0000
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exitjap:
exitjap:
blr # return
.globl regionfreeusa # r3 address
regionfreeusa:
.globl regionfreeusa # r3 address
regionfreeusa:
mtctr r4
lis r6, 0x281B
ori r6, r6, 0x0001 # blr
findusa:
findusa:
lwz r5, 0(r3)
cmpw r6, r5
beq writenop1
@ -260,22 +260,22 @@ findusa:
bdnz findusa # loop length
b exitusa # stop unhooked game hanging
writenop1:
writenop1:
addi r3, r3, 4 # next word
lis r4, 0x6000 # nop
ori r4, r4, 0x0000
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exitusa:
exitusa:
blr # return
.globl regionfreepal # r3 address
regionfreepal:
.globl regionfreepal # r3 address
regionfreepal:
mtctr r4
lis r6, 0x281B
ori r6, r6, 0x0002 # blr
findpal:
findpal:
lwz r5, 0(r3)
cmpw r6, r5
beq writenop2
@ -283,7 +283,7 @@ findpal:
bdnz findpal # loop length
b exitpal # stop unhooked game hanging
writenop2:
writenop2:
addi r3, r3, 4 # next word
lis r4, 0x6000 # nop
ori r4, r4, 0x0000
@ -293,7 +293,7 @@ writenop2:
lis r6, 0x4082
ori r6, r6, 0x001C # bne loc_81377A2C
findextra: #this is just the bne to b patch
findextra: #this is just the bne to b patch
lwz r5, 0(r3)
cmpw r6, r5
beq writeb
@ -301,22 +301,22 @@ findextra: #this is just the bne to b patch
bdnz findextra # loop length
b exitpal # stop unhooked game hanging
writeb:
writeb:
addi r3, r3, 4 # next word
lis r4, 0x4800
ori r4, r4, 0x001c # b loc_81377A2C
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exitpal:
exitpal:
blr # return
.globl removehealthcheck # r3 address
removehealthcheck:
.globl removehealthcheck # r3 address
removehealthcheck:
mtctr r4
lis r6, 0x4182
ori r6, r6, 0x004C # blr
findhe:
findhe:
lwz r5, 0(r3)
cmpw r6, r5
beq writebhe
@ -324,23 +324,23 @@ findhe:
bdnz findhe # loop length
b exithe # stop unhooked game hanging
writebhe:
writebhe:
lis r4, 0x6000
ori r4, r4, 0x0000
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exithe:
exithe:
blr # return
.globl patchupdatecheck # r3 address
patchupdatecheck:
.globl patchupdatecheck # r3 address
patchupdatecheck:
mtctr r4
lis r6, 0x4082
ori r6, r6, 0x0020 # blr
finduc:
finduc:
lwz r5, 0(r3)
cmpw r6, r5
beq writenopuc
@ -348,24 +348,24 @@ finduc:
bdnz finduc # loop length
b exituc # stop unhooked game hanging
writenopuc:
writenopuc:
lis r4, 0x6000
ori r4, r4, 0x0000
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exituc:
exituc:
blr # return
.globl copyflagcheck1 # r3 address
copyflagcheck1:
.globl copyflagcheck1 # r3 address
copyflagcheck1:
mtctr r4
lis r6, 0x5400
ori r6, r6, 0x07FF
findncf1:
findncf1:
lwz r5, 0(r3)
cmpw r6, r5
beq writencf1
@ -373,21 +373,21 @@ findncf1:
bdnz findncf1 # loop length
b exitncf1 # stop unhooked game hanging
writencf1:
writencf1:
lis r4, 0x7C00
ori r4, r4, 0x0000
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exitncf1:
exitncf1:
blr # return
.globl copyflagcheck2 # r3 address
copyflagcheck2:
.globl copyflagcheck2 # r3 address
copyflagcheck2:
mtctr r4
lis r6, 0x5400
ori r6, r6, 0x07FF
findncf2:
findncf2:
lwz r5, 0(r3)
cmpw r6, r5
beq writencf2
@ -395,37 +395,37 @@ findncf2:
bdnz findncf2 # loop length
b exitncf2 # stop unhooked game hanging
writencf2:
writencf2:
lis r4, 0x7C00
ori r4, r4, 0x0000
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exitncf2:
exitncf2:
blr # return
.globl copyflagcheck3 # r3 address
copyflagcheck3:
findncf3:
.globl copyflagcheck3 # r3 address
copyflagcheck3:
findncf3:
addi r3, r3, 20 # go back one dword (4 bytes)
lwz r5, 0(r3)
writencf3:
writencf3:
lis r4, 0x3860
ori r4, r4, 0x0001 # li r3,1
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exitncf3:
exitncf3:
blr # return
.globl copyflagcheck4 # r3 address
copyflagcheck4:
.globl copyflagcheck4 # r3 address
copyflagcheck4:
mtctr r4
lis r6, 0x3BE0
ori r6, r6, 0x0001 # li r31,1
findncf4:
findncf4:
lwz r5, 0(r3)
cmpw r6, r5
beq writencf4
@ -433,21 +433,21 @@ findncf4:
bdnz findncf4 # loop length
b exitncf4 # stop unhooked game hanging
writencf4:
writencf4:
lis r4, 0x3BE0
ori r4, r4, 0x0000 # change this to 3BE00000 (li r31,0)
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exitncf4:
exitncf4:
blr # return
.globl copyflagcheck5 # r3 address
copyflagcheck5:
.globl copyflagcheck5 # r3 address
copyflagcheck5:
mtctr r4
lis r6, 0x4182
ori r6, r6, 0x0024 # beq loc_8134AA60
findncf5:
findncf5:
lwz r5, 0(r3)
cmpw r6, r5
beq writencf5
@ -455,8 +455,8 @@ findncf5:
bdnz findncf5 # loop length
b exitncf5 # stop unhooked game hanging
writencf5:
#addi r3, r3, 8 # skip 2
writencf5:
#addi r3, r3, 8 # skip 2
lis r4, 0x801D
ori r4, r4, 0x0024 # change to 801D0024 (lwz r0,36(r29))
@ -487,22 +487,22 @@ writencf5:
stw r4, 0(r3)
dcbf r0, r3
icbi r0, r3
exitncf5:
exitncf5:
blr # return
.globl movedvdhooks # r3 address
movedvdhooks:
.globl movedvdhooks # r3 address
movedvdhooks:
lis r6, 0x4182
ori r6, r6, 0x0120 # beq loc_813A7938
findmd1:
findmd1:
addi r3, r3, 4 # next word
lwz r5, 0(r3)
writemd1:
writemd1:
lis r4, 0x6000
ori r4, r4, 0x0000 # nop
stw r4, 0(r3) # result in r3
dcbf r0, r3 # data cache block flush
icbi r0, r3
exitmd1:
exitmd1:
blr # return

View File

@ -29,22 +29,21 @@ extern u8 reset;
/********************************************************************************
*Game specific settings
*********************************************************************************/
int DiscBrowse(struct discHdr * header)
{
int DiscBrowse(struct discHdr * header) {
bool exit = false;
int ret, choice;
u64 offset;
ret = Disc_SetUSB(header->id);
if(ret < 0) {
if (ret < 0) {
WindowPrompt(tr("ERROR:"), tr("Could not set USB."), tr("OK"));
return ret;
}
ret = Disc_Open();
if(ret < 0) {
if (ret < 0) {
WindowPrompt(tr("ERROR:"), tr("Could not open disc."), tr("OK"));
return ret;
}
@ -65,8 +64,7 @@ int DiscBrowse(struct discHdr * header)
int *buffer = (int*)memalign(32, 0x20);
if (buffer == NULL)
{
if (buffer == NULL) {
WindowPrompt(tr("ERROR:"), tr("Not enough free memory."), tr("OK"));
return -1;
}
@ -80,8 +78,7 @@ int DiscBrowse(struct discHdr * header)
void *fstbuffer = memalign(32, buffer[2]*4);
FST_ENTRY *fst = (FST_ENTRY *)fstbuffer;
if (fst == NULL)
{
if (fst == NULL) {
WindowPrompt(tr("ERROR:"), tr("Not enough free memory."), tr("OK"));
free(buffer);
return -1;
@ -115,8 +112,7 @@ int DiscBrowse(struct discHdr * header)
if (fstfiles(fst, i)[len-4] =='.' &&
fstfiles(fst, i)[len-3] =='d' &&
fstfiles(fst, i)[len-2] =='o' &&
fstfiles(fst, i)[len-1] =='l')
{
fstfiles(fst, i)[len-1] =='l') {
options3.SetName(i, "%i", i);
options3.SetValue(i, fstfiles(fst, i));
//options3.SetName(i, fstfiles(fst, i));
@ -125,7 +121,7 @@ int DiscBrowse(struct discHdr * header)
}
}
if(dolfilecount <= 0) {
if (dolfilecount <= 0) {
WindowPrompt(tr("ERROR"), tr("No dol file found on disc."), tr("OK"));
free(fstbuffer);
return -1;
@ -148,7 +144,7 @@ int DiscBrowse(struct discHdr * header)
GuiTrigger trigB;
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
GuiText titleTxt(get_title(header), 28, (GXColor){0, 0, 0, 255});
GuiText titleTxt(get_title(header), 28, (GXColor) {0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(12,40);
titleTxt.SetMaxWidth(356, GuiText::SCROLL);
@ -159,10 +155,10 @@ int DiscBrowse(struct discHdr * header)
settingsbackgroundbtn.SetPosition(0, 0);
settingsbackgroundbtn.SetImage(&settingsbackground);
GuiText cancelBtnTxt(tr("Back"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText cancelBtnTxt(tr("Back"), 22, (GXColor) { THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage cancelBtnImg(&btnOutline);
if (Settings.wsprompt == yes){
if (Settings.wsprompt == yes) {
cancelBtnTxt.SetWidescreen(CFG.widescreen);
cancelBtnImg.SetWidescreen(CFG.widescreen);
}
@ -172,7 +168,7 @@ int DiscBrowse(struct discHdr * header)
cancelBtn.SetTrigger(&trigB);
u8 scrollbaron = 0;
if(dolfilecount > 9)
if (dolfilecount > 9)
scrollbaron = 1;
GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, CFG.theme_path, "bg_options_gamesettings.png", bg_options_settings_png, dolfilecount>9?1:0, 200);
@ -190,22 +186,21 @@ int DiscBrowse(struct discHdr * header)
ResumeGui();
while(!exit)
{
while (!exit) {
VIDEO_WaitVSync();
if(shutdown == 1)
if (shutdown == 1)
Sys_Shutdown();
if(reset == 1)
if (reset == 1)
Sys_Reboot();
ret = optionBrowser3.GetClickedOption();
if(ret > 0) {
if (ret > 0) {
char temp[100];
strncpy(temp, fstfiles(fst, ret), sizeof(temp));
choice = WindowPrompt(temp, tr("Load this dol as alternate dol?"), tr("OK"), tr("Cancel"));
if(choice) {
if (choice) {
//ret = offsetselect[ret];
snprintf(alternatedname, sizeof(alternatedname), "%s", temp);
exit = true;
@ -213,8 +208,7 @@ int DiscBrowse(struct discHdr * header)
}
}
if (cancelBtn.GetState() == STATE_CLICKED)
{
if (cancelBtn.GetState() == STATE_CLICKED) {
exit = true;
ret = 696969;
//break;
@ -232,8 +226,7 @@ int DiscBrowse(struct discHdr * header)
}
int autoSelectDol(const char *id)
{
int autoSelectDol(const char *id) {
//still not done//
//////////ID6/////////////////
if (strcmp(id,"RF8E69") == 0) return 439;//from isostar
@ -292,7 +285,7 @@ int autoSelectDol(const char *id)
/*
/*
Tiger Woods10 R9OP69 1991
Virtual Tennis 2009 RVUP8P 16426
@ -300,7 +293,7 @@ int autoSelectDol(const char *id)
Madden NFL07 RMDP69 39
Boogie RBOP69 657
Pangya! Golf with Sryle RPYP9B 12490
Grand Slam R5TP69 1493
Grand Slam R5TP69 1493
Madden NFL08 RNFP69 1079
rboe69 = boogie ntsc = (675)
@ -321,7 +314,7 @@ Grand Slam R5TP69 1493
Mortal Kombat RKMP5D 290
House of Dead 2+3 RHDP8P 149
Metroid Prime 1 and/or 2? listed on the alt dol list but not on lustar's site
*/
*/
//if (strcmp(id,"") == 0) return ; //blank line for more dols

View File

@ -49,12 +49,12 @@ extern void HaltGui();
***************************************************************************/
static void GameInstallProgress() {
if(gameinstalltotal <= 0)
if (gameinstalltotal <= 0)
return;
GetProgressValue(&gameinstalldone, &gameinstalltotal);
if(gameinstalldone > gameinstalltotal)
if (gameinstalldone > gameinstalltotal)
gameinstalldone = gameinstalltotal;
static u32 expected = 300;
@ -66,7 +66,7 @@ static void GameInstallProgress() {
elapsed = time(0) - start;
//Calculate speed in MB/s
if(elapsed > 0)
if (elapsed > 0)
speed = KBSIZE * gamesize * gameinstalldone/(gameinstalltotal*elapsed);
if (gameinstalldone != gameinstalltotal) {
@ -113,8 +113,7 @@ void SetupGameInstallProgress(char * title, char * game) {
* progress bar showing % completion, or a throbber that only shows that an
* action is in progress.
***************************************************************************/
static void ProgressWindow(const char *title, const char *msg1, const char *msg2)
{
static void ProgressWindow(const char *title, const char *msg1, const char *msg2) {
GuiWindow promptWindow(472,320);
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
@ -129,7 +128,7 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiImage dialogBoxImg(&dialogBox);
if (Settings.wsprompt == yes){
if (Settings.wsprompt == yes) {
dialogBoxImg.SetWidescreen(CFG.widescreen);
}
@ -137,8 +136,9 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
GuiImageData progressbarOutline(imgPath, progressbar_outline_png);
GuiImage progressbarOutlineImg(&progressbarOutline);
if (Settings.wsprompt == yes){
progressbarOutlineImg.SetWidescreen(CFG.widescreen);}
if (Settings.wsprompt == yes) {
progressbarOutlineImg.SetWidescreen(CFG.widescreen);
}
progressbarOutlineImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
progressbarOutlineImg.SetPosition(25, 40);
@ -155,44 +155,44 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
progressbarImg.SetPosition(25, 40);
GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText titleTxt(title, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(0,60);
GuiText msg1Txt(msg1, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText msg1Txt(msg1, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255} );
msg1Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
if(msg2)
if (msg2)
msg1Txt.SetPosition(0,120);
else
msg1Txt.SetPosition(0,100);
msg1Txt.SetMaxWidth(430, GuiText::DOTTED);
GuiText msg2Txt(msg2, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText msg2Txt(msg2, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255} );
msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
msg2Txt.SetPosition(0,125);
msg2Txt.SetMaxWidth(430, GuiText::DOTTED);
GuiText prsTxt("%", 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText prsTxt("%", 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
prsTxt.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
prsTxt.SetPosition(-188,40);
GuiText timeTxt(NULL, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText timeTxt(NULL, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
timeTxt.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
timeTxt.SetPosition(280,-50);
GuiText sizeTxt(NULL, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText sizeTxt(NULL, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
sizeTxt.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
sizeTxt.SetPosition(50, -50);
GuiText speedTxt(NULL, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText speedTxt(NULL, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
speedTxt.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
speedTxt.SetPosition(50, -74);
GuiText prTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText prTxt(NULL, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
prTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
prTxt.SetPosition(200, 40);
if ((Settings.wsprompt == yes) && (CFG.widescreen)){/////////////adjust for widescreen
if ((Settings.wsprompt == yes) && (CFG.widescreen)) {/////////////adjust for widescreen
progressbarOutlineImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
progressbarOutlineImg.SetPosition(0, 40);
progressbarEmptyImg.SetPosition(80,40);
@ -210,7 +210,7 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
}
usleep(400000); // wait to see if progress flag changes soon
if(!showProgress)
if (!showProgress)
return;
promptWindow.Append(&dialogBoxImg);
@ -219,15 +219,15 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
promptWindow.Append(&progressbarOutlineImg);
promptWindow.Append(&prTxt);
promptWindow.Append(&prsTxt);
if(title)
if (title)
promptWindow.Append(&titleTxt);
if(msg1)
if (msg1)
promptWindow.Append(&msg1Txt);
if(msg2)
if (msg2)
promptWindow.Append(&msg2Txt);
if(showTime)
if (showTime)
promptWindow.Append(&timeTxt);
if(showSize){
if (showSize) {
promptWindow.Append(&sizeTxt);
promptWindow.Append(&speedTxt);
}
@ -239,12 +239,11 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
mainWindow->ChangeFocus(&promptWindow);
ResumeGui();
while(promptWindow.GetEffect() > 0) usleep(100);
while (promptWindow.GetEffect() > 0) usleep(100);
int tmp;
while(showProgress)
{
while (showProgress) {
VIDEO_WaitVSync ();
usleep(20000);
@ -252,27 +251,27 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
GameInstallProgress();
tmp = static_cast<int>(progressbarImg.GetWidth()*progressDone);
if(CFG.widescreen && Settings.wsprompt == yes)
if (CFG.widescreen && Settings.wsprompt == yes)
progressbarImg.SetSkew(0,0,static_cast<int>(progressbarImg.GetWidth()*progressDone*0.8)-progressbarImg.GetWidth(),0,static_cast<int>(progressbarImg.GetWidth()*progressDone*0.8)-progressbarImg.GetWidth(),0,0,0);
else
progressbarImg.SetSkew(0,0,static_cast<int>(progressbarImg.GetWidth()*progressDone)-progressbarImg.GetWidth(),0,static_cast<int>(progressbarImg.GetWidth()*progressDone)-progressbarImg.GetWidth(),0,0,0);
prTxt.SetTextf("%.2f", progressDone);
if(showSize){
if (showSize) {
sizeTxt.SetText(progressSizeLeft);
speedTxt.SetText(progressSpeed);
}
if(showTime)
if (showTime)
timeTxt.SetText(progressTime);
if(msg2)
if (msg2)
msg2Txt.SetText(dyn_message);
}
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while(promptWindow.GetEffect() > 0) usleep(100);
while (promptWindow.GetEffect() > 0) usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
@ -284,11 +283,9 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
* ProgressThread
***************************************************************************/
static void * ProgressThread (void *arg)
{
while(1)
{
if(!showProgress)
static void * ProgressThread (void *arg) {
while (1) {
if (!showProgress)
LWP_SuspendThread (progressthread);
ProgressWindow(progressTitle, progressMsg1, progressMsg2);
@ -300,13 +297,12 @@ static void * ProgressThread (void *arg)
/****************************************************************************
* ProgressStop
***************************************************************************/
void ProgressStop()
{
void ProgressStop() {
showProgress = 0;
gameinstalltotal = -1;
// wait for thread to finish
while(!LWP_ThreadIsSuspended(progressthread))
while (!LWP_ThreadIsSuspended(progressthread))
usleep(100);
}
@ -316,25 +312,24 @@ void ProgressStop()
* Callbackfunction for updating the progress values
* Use this function as standard callback
***************************************************************************/
void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done, f32 total, bool swSize, bool swTime)
{
if(total <= 0)
void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done, f32 total, bool swSize, bool swTime) {
if (total <= 0)
return;
else if(done > total)
else if (done > total)
done = total;
showSize = swSize;
showTime = swTime;
if(title)
if (title)
strncpy(progressTitle, title, sizeof(progressTitle));
if(msg1)
if (msg1)
strncpy(progressMsg1, msg1, sizeof(progressMsg1));
if(dynmsg2)
if (dynmsg2)
dyn_message = dynmsg2;
if(swTime == true) {
if (swTime == true) {
static u32 expected;
u32 elapsed, h, m, s, speed = 0;
@ -348,7 +343,7 @@ void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done,
elapsed = time(0) - start;
//Calculate speed in KB/s
if(elapsed > 0)
if (elapsed > 0)
speed = done/(elapsed*KBSIZE);
if (done != total) {
@ -368,10 +363,10 @@ void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done,
snprintf(progressTime, sizeof(progressTime), "%s %d:%02d:%02d",tr("Time left:"),h,m,s);
}
if(swSize == true) {
if(total < MBSIZE)
if (swSize == true) {
if (total < MBSIZE)
snprintf(progressSizeLeft, sizeof(progressSizeLeft), "%0.2fKB/%0.2fKB", done * done/total / KBSIZE, total/KBSIZE);
else if(total > MBSIZE && total < GBSIZE)
else if (total > MBSIZE && total < GBSIZE)
snprintf(progressSizeLeft, sizeof(progressSizeLeft), "%0.2fMB/%0.2fMB", done * done/total / MBSIZE, total/MBSIZE);
else
snprintf(progressSizeLeft, sizeof(progressSizeLeft), "%0.2fGB/%0.2fGB", done * done/total / GBSIZE, total/GBSIZE);

File diff suppressed because it is too large Load Diff

View File

@ -32,8 +32,7 @@ extern u8 reset;
* TitleBrowser- opens a browser with a list of installed Titles
* relies on code from any title deleter.
*********************************************************************************/
int TitleBrowser(u32 type)
{
int TitleBrowser(u32 type) {
u32 num_titles;
u32 titles[100] ATTRIBUTE_ALIGN(32);
@ -52,28 +51,28 @@ int TitleBrowser(u32 type)
// Get count of titles of our requested type
ret = getTitles_TypeCount(type, &num_titles);
if (ret < 0){
if (ret < 0) {
//printf("\tError! Can't get count of titles! (ret = %d)\n", ret);
//exit(1);
}
// Get titles of our requested type
ret = getTitles_Type(type, titles, num_titles);
if (ret < 0){
if (ret < 0) {
//printf("\tError! Can't get list of titles! (ret = %d)\n", ret);
//exit(1);
}
// Get count of system titles
ret = getTitles_TypeCount(0x00010002, &num_sys_titles);
if (ret < 0){
if (ret < 0) {
//printf("\tError! Can't get count of titles! (ret = %d)\n", ret);
//exit(1);
}
// Get system titles
ret = getTitles_Type(0x00010002, sys_titles, num_sys_titles);
if (ret < 0){
if (ret < 0) {
//printf("\tError! Can't get list of titles! (ret = %d)\n", ret);
//exit(1);
}
@ -89,7 +88,7 @@ int TitleBrowser(u32 type)
//first add the good stuff
while (i < num_titles){
while (i < num_titles) {
//start from the beginning of the file each loop
if (f)rewind(f);
//char name[50];
@ -105,15 +104,14 @@ int TitleBrowser(u32 type)
snprintf(tmp,50,tmp," ");
//snprintf(name[i],sizeof(name[i]),"Unknown Title");
if(f)
{
if (f) {
while (fgets(line, sizeof(line), f)) {
if (line[0]== text[0]&&
line[1]== text[1]&&
line[2]== text[2])
{ int j=0;
line[2]== text[2]) {
int j=0;
found=1;
for(j=0;(line[j+4]!='\0' || j<51);j++)
for (j=0;(line[j+4]!='\0' || j<51);j++)
tmp[j]=line[j+4];
snprintf(name[i],sizeof(name[i]),"%s",tmp);
@ -121,17 +119,15 @@ int TitleBrowser(u32 type)
}
}
}
if(!found)
{
if (!found) {
if (getName00(name[i], TITLE_ID(type, titles[i]),CONF_GetLanguage()*2)>=0)
found=2;
if(!found)
{
if (!found) {
if (getNameBN(name[i], TITLE_ID(type, titles[i]))>=0)
found=3;
if(!found)
if (!found)
snprintf(name[i],sizeof(name[i]),"Unknown Title (%08x)",titles[i]);
}
}
@ -145,7 +141,7 @@ int TitleBrowser(u32 type)
}
// now add the crappy system titles
while (i < num_titles+num_sys_titles){
while (i < num_titles+num_sys_titles) {
//start from the beginning of the file each loop
if (f)rewind(f);
//char name[50];
@ -160,15 +156,14 @@ int TitleBrowser(u32 type)
char tmp[50];
snprintf(tmp,50,tmp," ");
//snprintf(name[i],sizeof(name[i]),"Unknown Title");
if(f)
{
if (f) {
while (fgets(line, sizeof(line), f)) {
if (line[0]== text[0]&&
line[1]== text[1]&&
line[2]== text[2])
{ int j=0;
line[2]== text[2]) {
int j=0;
found=1;
for(j=0;(line[j+4]!='\0' || j<51);j++)
for (j=0;(line[j+4]!='\0' || j<51);j++)
tmp[j]=line[j+4];
snprintf(name[i],sizeof(name[i]),"%s",tmp);
@ -176,17 +171,15 @@ int TitleBrowser(u32 type)
}
}
}
if(!found)
{
if (!found) {
if (getName00(name[i], TITLE_ID(0x00010002, sys_titles[i-num_titles]))>=0)
found=2;
if(!found)
{
if (!found) {
if (getNameBN(name[i], TITLE_ID(0x00010002, sys_titles[i-num_titles]))>=0)
found=3;
if(!found)
if (!found)
snprintf(name[i],sizeof(name[i]),"Unknown Title (%08x)",sys_titles[i-num_titles]);
}
}
@ -198,8 +191,8 @@ int TitleBrowser(u32 type)
//move on to the next title
i++;
}
if(i == num_titles+num_sys_titles)
{ options3.SetName(i, " ");
if (i == num_titles+num_sys_titles) {
options3.SetName(i, " ");
options3.SetValue(i, "%s",tr("Wii Settings"));
}
//we have all the titles we need so close the database and stop poking around in the wii
@ -227,7 +220,7 @@ int TitleBrowser(u32 type)
GuiTrigger trigB;
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
GuiText titleTxt(tr("Title Launcher"), 28, (GXColor){0, 0, 0, 255});
GuiText titleTxt(tr("Title Launcher"), 28, (GXColor) {0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(12,40);
titleTxt.SetMaxWidth(356, GuiText::SCROLL);
@ -238,10 +231,10 @@ int TitleBrowser(u32 type)
settingsbackgroundbtn.SetPosition(0, 0);
settingsbackgroundbtn.SetImage(&settingsbackground);
GuiText cancelBtnTxt(tr("Back"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText cancelBtnTxt(tr("Back"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage cancelBtnImg(&btnOutline);
if (Settings.wsprompt == yes){
if (Settings.wsprompt == yes) {
cancelBtnTxt.SetWidescreen(CFG.widescreen);
cancelBtnImg.SetWidescreen(CFG.widescreen);
}
@ -251,7 +244,7 @@ int TitleBrowser(u32 type)
cancelBtn.SetTrigger(&trigB);
u8 scrollbaron = 0;
if(num_titles > 9)
if (num_titles > 9)
scrollbaron = 1;
GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, CFG.theme_path, "bg_options_gamesettings.png", bg_options_settings_png, num_titles+num_sys_titles>9?1:0, 200);
@ -271,26 +264,24 @@ int TitleBrowser(u32 type)
int tmp=num_titles+num_sys_titles;
ResumeGui();
numtitle=num_titles;
while(!exit)
{
while (!exit) {
VIDEO_WaitVSync();
if(shutdown == 1)
if (shutdown == 1)
Sys_Shutdown();
if(reset == 1)
if (reset == 1)
Sys_Reboot();
ret = optionBrowser3.GetClickedOption();
if(ret > -1) {//if a click happened
if (ret > -1) {//if a click happened
//char name[50];
char text[15];
if (f)rewind(f);
//strcpy(name,"");//make sure name is empty
if (ret<numtitle)
{
if (ret<numtitle) {
//set the title's name, number, ID to text
sprintf(text, "%s", titleText(type, titles[ret]));
@ -298,7 +289,7 @@ int TitleBrowser(u32 type)
//prompt to boot selected title
snprintf(temp, sizeof(temp), "%s : %s",text,name[ret]);
int choice = WindowPrompt(tr("Boot?"), temp, tr("OK"), tr("Cancel"));
if(choice) {//if they say yes
if (choice) {//if they say yes
//stop all this stuff before starting the channel
@ -312,18 +303,14 @@ int TitleBrowser(u32 type)
//this really shouldn't be needed because the title will be booted
exit = true;
break;
}
else{
} else {
//if they said no to booting the title
ret = -1;
optionBrowser3.ResetState();
}
}
else//if they clicked a system title
{
if(ret == tmp)
{
} else { //if they clicked a system title
if (ret == tmp) {
CloseXMLDatabase();
ExitGUIThreads();
ShutdownAudio();
@ -331,9 +318,7 @@ int TitleBrowser(u32 type)
WII_Initialize();
WII_ReturnToSettings();
}
else
{
} else {
//set the title's name, number, ID to text
sprintf(text, "%s", titleText(0x00010002, sys_titles[ret-num_titles]));
@ -341,7 +326,7 @@ int TitleBrowser(u32 type)
//prompt to boot selected title
snprintf(temp, sizeof(temp), "%s : %s May not boot correctly if your System Menu is not up to date.",text,name[ret]);
int choice = WindowPrompt(tr("Boot?"), temp, tr("OK"), tr("Cancel"));
if(choice) {//if they say yes
if (choice) {//if they say yes
//stop all this stuff before starting the channel
@ -355,8 +340,7 @@ int TitleBrowser(u32 type)
//this really shouldn't be needed because the title will be booted
exit = true;
break;
}
else{
} else {
//if they said no to booting the title
ret = -1;
optionBrowser3.ResetState();
@ -365,8 +349,7 @@ int TitleBrowser(u32 type)
}
}
if (cancelBtn.GetState() == STATE_CLICKED)
{
if (cancelBtn.GetState() == STATE_CLICKED) {
//break the loop and end the function
exit = true;
ret = -10;

View File

@ -42,15 +42,13 @@ BROWSERENTRY * browserList = NULL; // list of files/folders in browser
* ResetBrowser()
* Clears the file browser memory, and allocates one initial entry
***************************************************************************/
void ResetBrowser()
{
void ResetBrowser() {
browser.numEntries = 0;
browser.selIndex = 0;
browser.pageIndex = 0;
// Clear any existing values
if(browserList != NULL)
{
if (browserList != NULL) {
free(browserList);
browserList = NULL;
}
@ -63,25 +61,21 @@ void ResetBrowser()
* UpdateDirName()
* Update curent directory name for file browser
***************************************************************************/
int UpdateDirName()
{
int UpdateDirName() {
int size=0;
char * test;
char temp[1024];
/* current directory doesn't change */
if (strcmp(browserList[browser.selIndex].filename,".") == 0)
{
if (strcmp(browserList[browser.selIndex].filename,".") == 0) {
return 0;
}
/* go up to parent directory */
else if (strcmp(browserList[browser.selIndex].filename,"..") == 0)
{
else if (strcmp(browserList[browser.selIndex].filename,"..") == 0) {
/* determine last subdirectory namelength */
sprintf(temp,"%s",browser.dir);
test = strtok(temp,"/");
while (test != NULL)
{
while (test != NULL) {
size = strlen(test);
test = strtok(NULL,"/");
}
@ -93,17 +87,13 @@ int UpdateDirName()
return 1;
}
/* Open a directory */
else
{
else {
/* test new directory namelength */
if ((strlen(browser.dir)+1+strlen(browserList[browser.selIndex].filename)) < MAXPATHLEN)
{
if ((strlen(browser.dir)+1+strlen(browserList[browser.selIndex].filename)) < MAXPATHLEN) {
/* update current directory name */
sprintf(browser.dir, "%s/%s",browser.dir, browserList[browser.selIndex].filename);
return 1;
}
else
{
} else {
return -1;
}
}
@ -118,20 +108,26 @@ int UpdateDirName()
* <dirs>
* <files>
***************************************************************************/
int FileSortCallback(const void *f1, const void *f2)
{
int FileSortCallback(const void *f1, const void *f2) {
/* Special case for implicit directories */
if(((BROWSERENTRY *)f1)->filename[0] == '.' || ((BROWSERENTRY *)f2)->filename[0] == '.')
{
if(strcmp(((BROWSERENTRY *)f1)->filename, ".") == 0) { return -1; }
if(strcmp(((BROWSERENTRY *)f2)->filename, ".") == 0) { return 1; }
if(strcmp(((BROWSERENTRY *)f1)->filename, "..") == 0) { return -1; }
if(strcmp(((BROWSERENTRY *)f2)->filename, "..") == 0) { return 1; }
if (((BROWSERENTRY *)f1)->filename[0] == '.' || ((BROWSERENTRY *)f2)->filename[0] == '.') {
if (strcmp(((BROWSERENTRY *)f1)->filename, ".") == 0) {
return -1;
}
if (strcmp(((BROWSERENTRY *)f2)->filename, ".") == 0) {
return 1;
}
if (strcmp(((BROWSERENTRY *)f1)->filename, "..") == 0) {
return -1;
}
if (strcmp(((BROWSERENTRY *)f2)->filename, "..") == 0) {
return 1;
}
}
/* If one is a file and one is a directory the directory is first. */
if(((BROWSERENTRY *)f1)->isdir && !(((BROWSERENTRY *)f2)->isdir)) return -1;
if(!(((BROWSERENTRY *)f1)->isdir) && ((BROWSERENTRY *)f2)->isdir) return 1;
if (((BROWSERENTRY *)f1)->isdir && !(((BROWSERENTRY *)f2)->isdir)) return -1;
if (!(((BROWSERENTRY *)f1)->isdir) && ((BROWSERENTRY *)f2)->isdir) return 1;
return stricmp(((BROWSERENTRY *)f1)->filename, ((BROWSERENTRY *)f2)->filename);
}
@ -140,8 +136,7 @@ int FileSortCallback(const void *f1, const void *f2)
* Browse subdirectories
**************************************************************************/
int
ParseDirectory()
{
ParseDirectory() {
DIR_ITER *dir = NULL;
char fulldir[MAXPATHLEN];
char filename[MAXPATHLEN];
@ -155,12 +150,10 @@ ParseDirectory()
dir = diropen(fulldir);
// if we can't open the dir, try opening the root dir
if (dir == NULL)
{
if (dir == NULL) {
sprintf(browser.dir,"/");
dir = diropen(browser.rootdir);
if (dir == NULL)
{
if (dir == NULL) {
return -1;
}
}
@ -168,32 +161,24 @@ ParseDirectory()
// index files/folders
int entryNum = 0;
while(dirnext(dir,filename,&filestat) == 0)
{
if(strcmp(filename,".") != 0)
{
while (dirnext(dir,filename,&filestat) == 0) {
if (strcmp(filename,".") != 0) {
BROWSERENTRY * newBrowserList = (BROWSERENTRY *)realloc(browserList, (entryNum+1) * sizeof(BROWSERENTRY));
if(!newBrowserList) // failed to allocate required memory
{
if (!newBrowserList) { // failed to allocate required memory
ResetBrowser();
entryNum = -1;
break;
}
else
{
} else {
browserList = newBrowserList;
}
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
strncpy(browserList[entryNum].filename, filename, MAXJOLIET);
if(strcmp(filename,"..") == 0)
{
if (strcmp(filename,"..") == 0) {
sprintf(browserList[entryNum].displayname, "..");
}
else
{
} else {
strcpy(browserList[entryNum].displayname, filename); // crop name for display
}
@ -219,9 +204,8 @@ ParseDirectory()
*
* Update current directory and set new entry list if directory has changed
***************************************************************************/
int BrowserChangeFolder()
{
if(!UpdateDirName())
int BrowserChangeFolder() {
if (!UpdateDirName())
return -1;
ParseDirectory();
@ -233,11 +217,9 @@ int BrowserChangeFolder()
* BrowseDevice
* Displays a list of files on the selected device
***************************************************************************/
int BrowseDevice(int device)
{
int BrowseDevice(int device) {
sprintf(browser.dir, "/");
switch(device)
{
switch (device) {
case SD:
sprintf(browser.rootdir, "SD:");
break;
@ -254,8 +236,7 @@ int BrowseDevice(int device)
* MenuBrowseDevice
***************************************************************************/
int BrowseDevice(char * var, int force)
{
int BrowseDevice(char * var, int force) {
int result=-1;
int i;
@ -263,25 +244,20 @@ int BrowseDevice(char * var, int force)
int curDivice = -1;
int forced =force;
if(forced>-1){
if(BrowseDevice(forced) > 0)
{
if (forced>-1) {
if (BrowseDevice(forced) > 0) {
curDivice = forced;
goto main;
}
}
else if((!strcasecmp(bootDevice, "USB:"))&&(BrowseDevice(USB) > 0))
{
else if ((!strcasecmp(bootDevice, "USB:"))&&(BrowseDevice(USB) > 0)) {
curDivice = USB;
goto main;
}
else if((!strcasecmp(bootDevice, "SD:"))&&(BrowseDevice(SD) > 0))
{
} else if ((!strcasecmp(bootDevice, "SD:"))&&(BrowseDevice(SD) > 0)) {
curDivice = SD;
goto main;
}
else {
} else {
WindowPrompt(tr("Error"),0,tr("Ok"));
return -1;
}
@ -289,11 +265,11 @@ int BrowseDevice(char * var, int force)
main:
int menu = MENU_NONE;
/*
/*
GuiText titleTxt("Browse Files", 28, (GXColor){0, 0, 0, 230});
titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
titleTxt.SetPosition(70,20);
*/
*/
GuiTrigger trigA;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiTrigger trigB;
@ -312,12 +288,13 @@ main:
folderBtn.SetEffectGrow();
GuiImageData btnOutline(button_dialogue_box_png);
GuiText ExitBtnTxt("Cancel", 24, (GXColor){0, 0, 0, 255});
GuiText ExitBtnTxt("Cancel", 24, (GXColor) {0, 0, 0, 255});
GuiImage ExitBtnImg(&btnOutline);
if (Settings.wsprompt == yes){
if (Settings.wsprompt == yes) {
ExitBtnTxt.SetWidescreen(CFG.widescreen);
ExitBtnImg.SetWidescreen(CFG.widescreen);
}GuiButton ExitBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
}
GuiButton ExitBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
ExitBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
ExitBtn.SetPosition(-55, -35);
ExitBtn.SetLabel(&ExitBtnTxt);
@ -326,12 +303,13 @@ main:
ExitBtn.SetTrigger(&trigB);
ExitBtn.SetEffectGrow();
GuiText usbBtnTxt((curDivice==SD?"USB":"SD"), 24, (GXColor){0, 0, 0, 255});
GuiText usbBtnTxt((curDivice==SD?"USB":"SD"), 24, (GXColor) {0, 0, 0, 255});
GuiImage usbBtnImg(&btnOutline);
if (Settings.wsprompt == yes){
if (Settings.wsprompt == yes) {
usbBtnTxt.SetWidescreen(CFG.widescreen);
usbBtnImg.SetWidescreen(CFG.widescreen);
}GuiButton usbBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
}
GuiButton usbBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
usbBtn.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
usbBtn.SetPosition(0, -35);
usbBtn.SetLabel(&usbBtnTxt);
@ -339,9 +317,9 @@ main:
usbBtn.SetTrigger(&trigA);
usbBtn.SetEffectGrow();
GuiText okBtnTxt(tr("Ok"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText okBtnTxt(tr("Ok"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiImage okBtnImg(&btnOutline);
if (Settings.wsprompt == yes){
if (Settings.wsprompt == yes) {
okBtnTxt.SetWidescreen(CFG.widescreen);
okBtnImg.SetWidescreen(CFG.widescreen);
}
@ -354,7 +332,7 @@ main:
GuiImageData Address(addressbar_textbox_png);
snprintf(currentdir, sizeof(currentdir), "%s%s", browser.rootdir, browser.dir);
GuiText AdressText(currentdir, 20, (GXColor) {0, 0, 0, 255});
GuiText AdressText(currentdir, 20, (GXColor) { 0, 0, 0, 255});
AdressText.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
AdressText.SetPosition(20, 0);
AdressText.SetMaxWidth(Address.GetWidth()-40, GuiText::SCROLL);
@ -381,33 +359,27 @@ main:
mainWindow->Append(&w);
ResumeGui();
while(menu == MENU_NONE)
{
while (menu == MENU_NONE) {
VIDEO_WaitVSync();
if(shutdown == 1)
if (shutdown == 1)
Sys_Shutdown();
if(reset == 1)
if (reset == 1)
Sys_Reboot();
for(i=0; i<PAGESIZE; i++)
{
if(fileBrowser.fileList[i]->GetState() == STATE_CLICKED)
{
for (i=0; i<PAGESIZE; i++) {
if (fileBrowser.fileList[i]->GetState() == STATE_CLICKED) {
fileBrowser.fileList[i]->ResetState();
// check corresponding browser entry
if(browserList[browser.selIndex].isdir)
{
if(BrowserChangeFolder())
{
if (browserList[browser.selIndex].isdir) {
if (BrowserChangeFolder()) {
fileBrowser.ResetState();
fileBrowser.fileList[0]->SetState(STATE_SELECTED);
fileBrowser.TriggerUpdate();
sprintf(var,"%s", browser.rootdir);
int len=strlen(browser.rootdir);
for (unsigned int i=len;i<strlen(browser.rootdir)+strlen(browser.dir);i++)
{
for (unsigned int i=len;i<strlen(browser.rootdir)+strlen(browser.dir);i++) {
var[i]=browser.dir[i-(len-1)];
}
AdressText.SetTextf("%s", var);
@ -422,26 +394,20 @@ main:
}
}
if(ExitBtn.GetState() == STATE_CLICKED)
{
if (ExitBtn.GetState() == STATE_CLICKED) {
snprintf(var,sizeof(currentdir),"%s", currentdir);
break;
}
if(okBtn.GetState() == STATE_CLICKED)
{
if (okBtn.GetState() == STATE_CLICKED) {
result = 1;
break;
}
else if(usbBtn.GetState() == STATE_CLICKED)
{
} else if (usbBtn.GetState() == STATE_CLICKED) {
HaltGui();
mainWindow->Remove(&w);
ResumeGui();
result = BrowseDevice(var, (curDivice==SD?USB:SD));
break;
}
else if(folderBtn.GetState() == STATE_CLICKED)
{
} else if (folderBtn.GetState() == STATE_CLICKED) {
HaltGui();
mainWindow->Remove(&w);
ResumeGui();
@ -449,15 +415,14 @@ main:
sprintf(newfolder,"%s/",var);
int result = OnScreenKeyboard(newfolder,100,0);
if ( result == 1 )
{
if ( result == 1 ) {
int len = (strlen(newfolder)-1);
if(newfolder[len] !='/')
if (newfolder[len] !='/')
strncat (newfolder, "/", 1);
struct stat st;
if(stat(newfolder, &st) != 0) {
if(subfoldercreate(newfolder) != 1) {
if (stat(newfolder, &st) != 0) {
if (subfoldercreate(newfolder) != 1) {
WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK"));
}
}

View File

@ -24,8 +24,7 @@ enum {
USB
};
typedef struct
{
typedef struct {
char dir[MAXPATHLEN]; // directory path of browserList
char rootdir[10]; // directory path of browserList
int numEntries; // # of entries in browserList
@ -33,8 +32,7 @@ typedef struct
int pageIndex; // starting index of browserList page display
} BROWSERINFO;
typedef struct
{
typedef struct {
u64 offset; // DVD offset
u64 length; // file length in 64 bytes for sizes higher than 4GB
char isdir; // 0 - file, 1 - directory

View File

@ -38,15 +38,14 @@ extern void HaltGui();
/****************************************************************************
* gameinfo
***************************************************************************/
int showGameInfo(char *ID)
{
int showGameInfo(char *ID) {
HaltGui();//put this first to try to get rid of the code dump caused by loading this window at the same time as loading images from the SD card
mainWindow->SetState(STATE_DISABLED);
ResumeGui();
//load the xml shit
bool databaseopened = true;
//OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, false, true); // open file, do not load titles, keep in memory
if(databaseopened) {
if (databaseopened) {
LoadGameInfoFromXML(ID, Settings.db_language);
//CloseXMLDatabase();
@ -197,8 +196,7 @@ int showGameInfo(char *ID)
char linebuf2[100] = "";
// enable icons for required accessories
for (int i=1;i<=XML_ELEMMAX;i++)
{
for (int i=1;i<=XML_ELEMMAX;i++) {
if (strcmp(gameinfo.accessoriesReq[i],"classiccontroller")==0)
classiccontroller=1;
if (strcmp(gameinfo.accessoriesReq[i],"nunchuk")==0)
@ -253,8 +251,7 @@ int showGameInfo(char *ID)
else dancepadImgData = new GuiImageData(dancepad_png);
// look for optional accessories
for (int i=1;i<=XML_ELEMMAX;i++)
{
for (int i=1;i<=XML_ELEMMAX;i++) {
if (strcmp(gameinfo.accessories[i],"classiccontroller")==0)
classiccontroller=1;
if (strcmp(gameinfo.accessories[i],"nunchuk")==0)
@ -316,10 +313,10 @@ int showGameInfo(char *ID)
// # of players
if (strcmp(gameinfo.players,"") != 0) {
playersImgData = new GuiImageData(Wiimote1_png);
if (atoi(gameinfo.players)>1){
if (atoi(gameinfo.players)>1) {
playersImgData= new GuiImageData(Wiimote2_png);
}
if (atoi(gameinfo.players)>2){
if (atoi(gameinfo.players)>2) {
playersImgData= new GuiImageData(Wiimote4_png);
}
@ -332,7 +329,7 @@ int showGameInfo(char *ID)
}
//draw the input types for this game
if (motionplus==1){
if (motionplus==1) {
motionplusImg = new GuiImage(motionplusImgData);
motionplusImg->SetWidescreen(CFG.widescreen);
motionplusImg->SetPosition(intputX , inputY);
@ -340,7 +337,7 @@ int showGameInfo(char *ID)
gameinfoWindow.Append(motionplusImg);
intputX += (CFG.widescreen ? motionplusImg->GetWidth() * .8 : motionplusImg->GetWidth())+5;
}
if (nunchuk==1){
if (nunchuk==1) {
nunchukImg = new GuiImage(nunchukImgData);
nunchukImg->SetWidescreen(CFG.widescreen);
nunchukImg->SetPosition(intputX , inputY);
@ -348,7 +345,7 @@ int showGameInfo(char *ID)
gameinfoWindow.Append(nunchukImg);
intputX += (CFG.widescreen ? nunchukImg->GetWidth() * .8 : nunchukImg->GetWidth())+5;
}
if (classiccontroller==1){
if (classiccontroller==1) {
classiccontrollerImg = new GuiImage(classiccontrollerImgData);
classiccontrollerImg->SetWidescreen(CFG.widescreen);
classiccontrollerImg->SetPosition(intputX , inputY);
@ -356,7 +353,7 @@ int showGameInfo(char *ID)
gameinfoWindow.Append(classiccontrollerImg);
intputX += (CFG.widescreen ? classiccontrollerImg->GetWidth() * .8 : classiccontrollerImg->GetWidth())+5;
}
if (gamecube==1){
if (gamecube==1) {
gcImg = new GuiImage(gamecubeImgData);
gcImg->SetWidescreen(CFG.widescreen);
gcImg->SetPosition(intputX , inputY);
@ -364,7 +361,7 @@ int showGameInfo(char *ID)
gameinfoWindow.Append(gcImg);
intputX += (CFG.widescreen ? gcImg->GetWidth() * .8 : gcImg->GetWidth())+5;
}
if (wheel==1){
if (wheel==1) {
wheelImg = new GuiImage(wheelImgData);
wheelImg->SetWidescreen(CFG.widescreen);
wheelImg->SetPosition(intputX , inputY);
@ -372,7 +369,7 @@ int showGameInfo(char *ID)
gameinfoWindow.Append(wheelImg);
intputX += (CFG.widescreen ? wheelImg->GetWidth() * .8 : wheelImg->GetWidth())+5;
}
if (guitar==1){
if (guitar==1) {
guitarImg = new GuiImage(guitarImgData);
guitarImg->SetWidescreen(CFG.widescreen);
guitarImg->SetPosition(intputX , inputY);
@ -380,7 +377,7 @@ int showGameInfo(char *ID)
gameinfoWindow.Append(guitarImg);
intputX += (CFG.widescreen ? guitarImg->GetWidth() * .8 : guitarImg->GetWidth())+5;
}
if (drums==1){
if (drums==1) {
drumsImg = new GuiImage(drumsImgData);
drumsImg->SetWidescreen(CFG.widescreen);
drumsImg->SetPosition(intputX , inputY);
@ -388,7 +385,7 @@ int showGameInfo(char *ID)
gameinfoWindow.Append(drumsImg);
intputX += (CFG.widescreen ? drumsImg->GetWidth() * .8 : drumsImg->GetWidth())+5;
}
if (microphone==1){
if (microphone==1) {
microphoneImg = new GuiImage(microphoneImgData);
microphoneImg->SetWidescreen(CFG.widescreen);
microphoneImg->SetPosition(intputX , inputY);
@ -396,7 +393,7 @@ int showGameInfo(char *ID)
gameinfoWindow.Append(microphoneImg);
intputX += (CFG.widescreen ? microphoneImg->GetWidth() * .8 : microphoneImg->GetWidth())+5;
}
if (dancepad==1){
if (dancepad==1) {
dancepadImg = new GuiImage(dancepadImgData);
dancepadImg->SetWidescreen(CFG.widescreen);
dancepadImg->SetPosition(intputX , inputY);
@ -404,7 +401,7 @@ int showGameInfo(char *ID)
gameinfoWindow.Append(dancepadImg);
intputX += (CFG.widescreen ? dancepadImg->GetWidth() * .8 : dancepadImg->GetWidth())+5;
}
if (balanceboard==1){
if (balanceboard==1) {
balanceboardImg = new GuiImage(balanceboardImgData);
balanceboardImg->SetWidescreen(CFG.widescreen);
balanceboardImg->SetPosition(intputX , inputY);
@ -414,14 +411,17 @@ int showGameInfo(char *ID)
}
// # online players
if ((strcmp(gameinfo.wifiplayers,"") != 0) && (strcmp(gameinfo.wifiplayers,"0") != 0)){
if ((strcmp(gameinfo.wifiplayers,"") != 0) && (strcmp(gameinfo.wifiplayers,"0") != 0)) {
wifiplayersImgData = new GuiImageData(wifi1_png);
if (atoi(gameinfo.wifiplayers)>1){
wifiplayersImgData= new GuiImageData(wifi2_png);}
if (atoi(gameinfo.wifiplayers)>2){
wifiplayersImgData= new GuiImageData(wifi4_png);}
if (atoi(gameinfo.wifiplayers)>4){
wifiplayersImgData= new GuiImageData(wifi8_png);}
if (atoi(gameinfo.wifiplayers)>1) {
wifiplayersImgData= new GuiImageData(wifi2_png);
}
if (atoi(gameinfo.wifiplayers)>2) {
wifiplayersImgData= new GuiImageData(wifi4_png);
}
if (atoi(gameinfo.wifiplayers)>4) {
wifiplayersImgData= new GuiImageData(wifi8_png);
}
/*if (atoi(gameinfo.wifiplayers)>8){ uncomment this when we actually have these images and it is needed
wifiplayersImgData= new GuiImageData(wifi12_png);}
if (atoi(gameinfo.wifiplayers)>12){
@ -437,7 +437,7 @@ int showGameInfo(char *ID)
}
// ratings
if (strcmp(gameinfo.ratingtype,"") !=0){
if (strcmp(gameinfo.ratingtype,"") !=0) {
if (strcmp(gameinfo.ratingtype,"ESRB")==0) {
if (strcmp(gameinfo.ratingvalueESRB,"EC")==0)
ratingImgData = new GuiImageData(esrb_ec_png);
@ -451,7 +451,9 @@ int showGameInfo(char *ID)
ratingImgData = new GuiImageData(esrb_m_png);
else if (strcmp(gameinfo.ratingvalueESRB,"AO")==0)
ratingImgData = new GuiImageData(esrb_ao_png);
else {ratingImgData = new GuiImageData(norating_png);}
else {
ratingImgData = new GuiImageData(norating_png);
}
} //there are 2 values here cause some countries are stupid and
else if (strcmp(gameinfo.ratingtype,"PEGI")==0) {//can't use the same as everybody else
if ((strcmp(gameinfo.ratingvaluePEGI,"3")==0)||(strcmp(gameinfo.ratingvaluePEGI,"4")==0))
@ -464,9 +466,10 @@ int showGameInfo(char *ID)
ratingImgData = new GuiImageData(pegi_16_png);
else if (strcmp(gameinfo.ratingvaluePEGI,"18")==0)
ratingImgData = new GuiImageData(pegi_18_png);
else {ratingImgData = new GuiImageData(norating_png);}
else {
ratingImgData = new GuiImageData(norating_png);
}
else if (strcmp(gameinfo.ratingtype,"CERO")==0) {
} else if (strcmp(gameinfo.ratingtype,"CERO")==0) {
if (strcmp(gameinfo.ratingvalueCERO,"A")==0)
ratingImgData = new GuiImageData(cero_a_png);
else if (strcmp(gameinfo.ratingvalueCERO,"B")==0)
@ -477,10 +480,14 @@ int showGameInfo(char *ID)
ratingImgData = new GuiImageData(cero_d_png);
else if (strcmp(gameinfo.ratingvalueCERO,"Z")==0)
ratingImgData = new GuiImageData(cero_z_png);
else {ratingImgData = new GuiImageData(norating_png);}
else {
ratingImgData = new GuiImageData(norating_png);
}
}
else {ratingImgData = new GuiImageData(norating_png);}
else {
ratingImgData = new GuiImageData(norating_png);
}
ratingImg = new GuiImage(ratingImgData);
ratingImg->SetWidescreen(CFG.widescreen);
ratingImg->SetPosition(-25 , inputY);
@ -494,8 +501,9 @@ int showGameInfo(char *ID)
char meminfotxt[200];
strlcpy(meminfotxt,MemInfo(),sizeof(meminfotxt));
snprintf(linebuf, sizeof(linebuf), "%s",meminfotxt);
memTxt = new GuiText(linebuf, 18, (GXColor){0,0,0, 255});
memTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); memTxt->SetPosition(0,0);
memTxt = new GuiText(linebuf, 18, (GXColor) {0,0,0, 255});
memTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
memTxt->SetPosition(0,0);
gameinfoWindow.Append(memTxt);
}
@ -503,20 +511,21 @@ int showGameInfo(char *ID)
int titlefontsize=25;
if (strcmp(gameinfo.title,"") != 0) {
snprintf(linebuf, sizeof(linebuf), "%s",gameinfo.title);
titleTxt = new GuiText(linebuf, titlefontsize, (GXColor){0,0,0, 255});
titleTxt = new GuiText(linebuf, titlefontsize, (GXColor) {0,0,0, 255});
titleTxt->SetMaxWidth(350, GuiText::SCROLL);
//while (titleTxt->GetWidth()>250) { titleTxt->SetFontSize(titlefontsize-=2); }
titleTxt->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt->SetPosition(txtXOffset,12+titley);
titleTxt->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt->SetPosition(txtXOffset,12+titley);
gameinfoWindow.Append(titleTxt);
}
//date
snprintf(linebuf2, sizeof(linebuf2), " ");
if (strcmp(gameinfo.day,"") != 0)
{snprintf(linebuf2, sizeof(linebuf2), "%s ", gameinfo.day);}
if (strcmp(gameinfo.month,"") != 0){
switch (atoi(gameinfo.month))
{
if (strcmp(gameinfo.day,"") != 0) {
snprintf(linebuf2, sizeof(linebuf2), "%s ", gameinfo.day);
}
if (strcmp(gameinfo.month,"") != 0) {
switch (atoi(gameinfo.month)) {
case 1:
snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Jan"));
break;
@ -555,62 +564,74 @@ int showGameInfo(char *ID)
break;
}
}
if (strcmp(gameinfo.year,"") != 0){
if (strcmp(gameinfo.year,"") != 0) {
snprintf(linebuf, sizeof(linebuf), "%s : %s%s", tr("Released"), linebuf2, gameinfo.year);
releasedTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255});
releasedTxt = new GuiText(linebuf, 16, (GXColor) {0,0,0, 255});
if (releasedTxt->GetWidth()>300) newline=2;
releasedTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); releasedTxt->SetPosition(-17,12+indexy); indexy+=(20 * newline);newline=1;
releasedTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
releasedTxt->SetPosition(-17,12+indexy);
indexy+=(20 * newline);
newline=1;
gameinfoWindow.Append(releasedTxt);
}
//publisher
if (strcmp(gameinfo.publisher,"") != 0){
if (strcmp(gameinfo.publisher,"") != 0) {
snprintf(linebuf, sizeof(linebuf), "%s %s", tr("Published by"), gameinfo.publisher);
publisherTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255});
publisherTxt = new GuiText(linebuf, 16, (GXColor) {0,0,0, 255});
if (publisherTxt->GetWidth()>250) newline=2;
publisherTxt->SetMaxWidth(250,GuiText::WRAP);
publisherTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); publisherTxt->SetPosition(-17,12+indexy); indexy+=(20 * newline);newline=1;
publisherTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
publisherTxt->SetPosition(-17,12+indexy);
indexy+=(20 * newline);
newline=1;
gameinfoWindow.Append(publisherTxt);
}
//developer
if (strcmp(gameinfo.developer,"") != 0 && strcasecmp(gameinfo.developer,gameinfo.publisher) != 0) {
snprintf(linebuf, sizeof(linebuf), "%s %s", tr("Developed by"), gameinfo.developer);
developerTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255});
developerTxt = new GuiText(linebuf, 16, (GXColor) {0,0,0, 255});
if (developerTxt->GetWidth()>250) newline=2;
developerTxt->SetMaxWidth(250,GuiText::WRAP);
developerTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); developerTxt->SetPosition(-17,12+indexy); indexy+=(20 * newline);newline=1;
developerTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
developerTxt->SetPosition(-17,12+indexy);
indexy+=(20 * newline);
newline=1;
gameinfoWindow.Append(developerTxt);
}
//genre
int genreY = marginY;
genreTxt = new GuiText * [gameinfo.genreCnt + 1];
for (int i=1;i<=gameinfo.genreCnt;i++)
{
for (int i=1;i<=gameinfo.genreCnt;i++) {
snprintf(linebuf, sizeof(linebuf), "%s", gameinfo.genresplit[i]);
genreTxt[i] = new GuiText(linebuf, 16, (GXColor){0,0,0, 255});
genreTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); genreTxt[i]->SetPosition(205,12+genreY); genreY+=20;
genreTxt[i] = new GuiText(linebuf, 16, (GXColor) {0,0,0, 255});
genreTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
genreTxt[i]->SetPosition(205,12+genreY);
genreY+=20;
gameinfoWindow.Append(genreTxt[i]);
}
//online
wifiTxt = new GuiText * [gameinfo.wifiCnt + 1];
for (int i=gameinfo.wifiCnt;i>=1;i--)
{
for (int i=gameinfo.wifiCnt;i>=1;i--) {
if (strcmp(gameinfo.wififeatures[i],"Nintendods") == 0) {
snprintf(linebuf, sizeof(linebuf), "Nintendo DS");
} else {
snprintf(linebuf, sizeof(linebuf), "%s",gameinfo.wififeatures[i]);
}
wifiTxt[i] = new GuiText(linebuf, 16, (GXColor){0,0,0, 255});
wifiTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); wifiTxt[i]->SetPosition(215,200+wifiY); wifiY-=20;
wifiTxt[i] = new GuiText(linebuf, 16, (GXColor) {0,0,0, 255});
wifiTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
wifiTxt[i]->SetPosition(215,200+wifiY);
wifiY-=20;
gameinfoWindow.Append(wifiTxt[i]);
}
if (strcmp(gameinfo.wififeatures[1],"") != 0){
if (strcmp(gameinfo.wififeatures[1],"") != 0) {
snprintf(linebuf, sizeof(linebuf), "%s:",tr("WiFi Features"));
wifiTxt[0] = new GuiText(linebuf, 16, (GXColor){0,0,0, 255});
wifiTxt[0]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); wifiTxt[0]->SetPosition(205,200+wifiY);
wifiTxt[0] = new GuiText(linebuf, 16, (GXColor) {0,0,0, 255});
wifiTxt[0]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
wifiTxt[0]->SetPosition(205,200+wifiY);
gameinfoWindow.Append(wifiTxt[0]);
}
@ -618,9 +639,10 @@ int showGameInfo(char *ID)
int pagesize=12;
if (strcmp(gameinfo.synopsis,"") != 0) {
snprintf(linebuf, sizeof(linebuf), "%s", gameinfo.synopsis);
synopsisTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255});
synopsisTxt = new GuiText(linebuf, 16, (GXColor) {0,0,0, 255});
synopsisTxt->SetMaxWidth(350,GuiText::WRAP);
synopsisTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); synopsisTxt->SetPosition(0,0);
synopsisTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
synopsisTxt->SetPosition(0,0);
synopsisTxt->SetNumLines(pagesize);
//synopsisTxt->SetFirstLine(12);
@ -657,12 +679,14 @@ int showGameInfo(char *ID)
//don't bother us txt
snprintf(linebuf, sizeof(linebuf), tr("Don't bother the USB Loader GX Team about errors in this file."));
betaTxt = new GuiText(linebuf, 14, (GXColor){0,0,0, 255});
betaTxt->SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); betaTxt->SetPosition(-17,-20);
betaTxt = new GuiText(linebuf, 14, (GXColor) {0,0,0, 255});
betaTxt->SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
betaTxt->SetPosition(-17,-20);
gameinfoWindow.Append(betaTxt);
snprintf(linebuf, sizeof(linebuf), tr("If you don't have WiFi, press 1 to get an URL to get your WiiTDB.zip"));
beta1Txt = new GuiText(linebuf, 14, (GXColor){0,0,0, 255});
beta1Txt->SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); beta1Txt->SetPosition(-17,-10);
beta1Txt = new GuiText(linebuf, 14, (GXColor) {0,0,0, 255});
beta1Txt->SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
beta1Txt->SetPosition(-17,-10);
gameinfoWindow.Append(beta1Txt);
gameinfoWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 100);
@ -672,25 +696,21 @@ int showGameInfo(char *ID)
mainWindow->ChangeFocus(&gameinfoWindow);
ResumeGui();
while(choice == -1)
{
while (choice == -1) {
VIDEO_WaitVSync();
if(shutdown == 1)
{
if (shutdown == 1) {
wiilight(0);
Sys_Shutdown();
}
else if(reset == 1)
} else if (reset == 1)
Sys_Reboot();
else if ((backBtn.GetState()==STATE_CLICKED)||(backBtn.GetState()==STATE_HELD)){
if(page==1)
{choice=1;
else if ((backBtn.GetState()==STATE_CLICKED)||(backBtn.GetState()==STATE_HELD)) {
if (page==1) {
choice=1;
synopsisTxt = NULL;
break;}
else if (page==2)
{
break;
} else if (page==2) {
HaltGui();
gameinfoWindow2.SetVisible(false);
gameinfoWindow.SetVisible(true);
@ -698,11 +718,10 @@ int showGameInfo(char *ID)
ResumeGui();
page=1;
}
}
else if (((nextBtn.GetState()==STATE_CLICKED)||(nextBtn.GetState()==STATE_HELD))&&
(strcmp(gameinfo.synopsis,"") != 0)){
} else if (((nextBtn.GetState()==STATE_CLICKED)||(nextBtn.GetState()==STATE_HELD))&&
(strcmp(gameinfo.synopsis,"") != 0)) {
if (page==1){
if (page==1) {
nextBtn.ResetState();
HaltGui();
gameinfoWindow.SetVisible(false);
@ -716,8 +735,7 @@ int showGameInfo(char *ID)
mainWindow->Append(&gameinfoWindow2);
ResumeGui();
page=2;
}
else {
} else {
nextBtn.ResetState();
HaltGui();
//backBtn.SetClickable(true);
@ -732,20 +750,16 @@ int showGameInfo(char *ID)
}
nextBtn.ResetState();
}
else if ((upBtn.GetState()==STATE_CLICKED||upBtn.GetState()==STATE_HELD) && page==2)
{
} else if ((upBtn.GetState()==STATE_CLICKED||upBtn.GetState()==STATE_HELD) && page==2) {
//int l=synopsisTxt->GetFirstLine()-1;
if (synopsisTxt->GetFirstLine()>1)
synopsisTxt->SetFirstLine(synopsisTxt->GetFirstLine()-1);
usleep(60000);
if (!((ButtonsHold() & WPAD_BUTTON_UP)||(ButtonsHold() & PAD_BUTTON_UP)))
upBtn.ResetState();
}
else if ((dnBtn.GetState()==STATE_CLICKED||dnBtn.GetState()==STATE_HELD) && page==2
} else if ((dnBtn.GetState()==STATE_CLICKED||dnBtn.GetState()==STATE_HELD) && page==2
&&synopsisTxt->GetTotalLines()>pagesize
&&synopsisTxt->GetFirstLine()-1<synopsisTxt->GetTotalLines()-pagesize)
{
&&synopsisTxt->GetFirstLine()-1<synopsisTxt->GetTotalLines()-pagesize) {
int l=0;
//if(synopsisTxt->GetTotalLines()>pagesize)
l=synopsisTxt->GetFirstLine()+1;
@ -757,15 +771,12 @@ int showGameInfo(char *ID)
usleep(60000);
if (!((ButtonsHold() & WPAD_BUTTON_DOWN)||(ButtonsHold() & PAD_BUTTON_DOWN)))
dnBtn.ResetState();
}
else if (homeBtn.GetState()==STATE_CLICKED)
{
if(page==1)
{choice=2;
} else if (homeBtn.GetState()==STATE_CLICKED) {
if (page==1) {
choice=2;
synopsisTxt = NULL;
break;}
else if (page==2)
{
break;
} else if (page==2) {
HaltGui();
gameinfoWindow2.SetVisible(false);
gameinfoWindow.SetVisible(true);
@ -776,11 +787,8 @@ int showGameInfo(char *ID)
ResumeGui();
page=1;
}
}
else if (urlBtn.GetState()==STATE_CLICKED)
{
if (save_XML_URL())
{
} else if (urlBtn.GetState()==STATE_CLICKED) {
if (save_XML_URL()) {
snprintf(linebuf, sizeof(linebuf), tr("Your URL has been saved in %sWiiTDB_URL.txt."), Settings.update_path);
betaTxt->SetText(linebuf);
gameinfoWindow.Append(betaTxt);
@ -790,9 +798,9 @@ int showGameInfo(char *ID)
}
}
}
if (page==1){
if (page==1) {
gameinfoWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 100);
while(gameinfoWindow.GetEffect() > 0) usleep(50);
while (gameinfoWindow.GetEffect() > 0) usleep(50);
HaltGui();
mainWindow->Remove(&gameinfoWindow);
mainWindow->SetState(STATE_DEFAULT);
@ -845,22 +853,20 @@ int showGameInfo(char *ID)
delete betaTxt;
delete beta1Txt;
delete memTxt;
if (gameinfo.genreCnt>0){
for(int i=1;i<=gameinfo.genreCnt;i++)
{
if (gameinfo.genreCnt>0) {
for (int i=1;i<=gameinfo.genreCnt;i++) {
delete genreTxt[i];
}
}
if (gameinfo.wifiCnt>0){
for(int i=0;i<=gameinfo.wifiCnt;i++)
{
if (gameinfo.wifiCnt>0) {
for (int i=0;i<=gameinfo.wifiCnt;i++) {
delete wifiTxt[i];
}
}
ResumeGui();
} else {
gameinfoWindow2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 100);
while(gameinfoWindow2.GetEffect() > 0) usleep(50);
while (gameinfoWindow2.GetEffect() > 0) usleep(50);
HaltGui();
mainWindow->Remove(&gameinfoWindow2);
mainWindow->SetState(STATE_DEFAULT);
@ -874,12 +880,11 @@ int showGameInfo(char *ID)
}
}
bool save_XML_URL()// save xml url as as txt file for people without wifi
{
bool save_XML_URL() { // save xml url as as txt file for people without wifi
char tmp[200];
sprintf(tmp, "%s", Settings.update_path);
struct stat st;
if(stat(tmp, &st) != 0) {
if (stat(tmp, &st) != 0) {
mkdir(tmp, 0777);
}
FILE *f;

View File

@ -1,20 +1,17 @@
#include <string.h>
#include "ramdisc.h"
static inline u16 u8array_to_u16 (const u8* item, int offset)
{
static inline u16 u8array_to_u16 (const u8* item, int offset) {
return ( item[offset] | (item[offset + 1] << 8));
}
static inline u32 u8array_to_u32 (const u8* item, int offset)
{
static inline u32 u8array_to_u32 (const u8* item, int offset) {
return ( item[offset] | (item[offset + 1] << 8) | (item[offset + 2] << 16) | (item[offset + 3] << 24) );
}
static inline void u16_to_u8array (u8* item, int offset, u16 value)
{
item[offset] = (u8) value; item[offset + 1] = (u8)(value >> 8);
static inline void u16_to_u8array (u8* item, int offset, u16 value) {
item[offset] = (u8) value;
item[offset + 1] = (u8)(value >> 8);
}
static inline void u32_to_u8array (u8* item, int offset, u32 value)
{
static inline void u32_to_u8array (u8* item, int offset, u32 value) {
item[offset] = (u8) value;
item[offset + 1] = (u8)(value >> 8);
item[offset + 2] = (u8)(value >> 16);
@ -22,17 +19,17 @@ static inline void u32_to_u8array (u8* item, int offset, u32 value)
}
class padding
{
class padding {
public:
padding(u32 Start, u32 NumSectors)
{
padding(u32 Start, u32 NumSectors) {
start = Start;
end = Start + NumSectors;
data = new u8[NumSectors*512];
next = 0;
}
~padding() { delete [] data;}
~padding() {
delete [] data;
}
u32 start;
u32 end;
@ -44,26 +41,24 @@ static u32 __ramdisk_sectorsOfPadding;
static padding *__ramdisk_data_start;
static padding *__ramdisk_data_end;
static bool __ramdisk_IsInserted(void)
{
static bool __ramdisk_IsInserted(void) {
return __ramdisk_data_start!=NULL;
}
//forward decleration
static bool __ramdisk_WriteSectors(size_t Sector, size_t numSectors, u8 *Buffer);
bool initRAMDisc(u32 Size, u32 Padding)
{
if(__ramdisk_data_start) return true; // is init
bool initRAMDisc(u32 Size, u32 Padding) {
if (__ramdisk_data_start) return true; // is init
if(Size > 16*1024*1024) Size = 16*1024*1024; // maximum 16 MB
if(Size < 16*1024) Size = 16*1024; // minimum 16 MB
if(Padding > Size) Padding = Size; // Padding maximum =Disksize
if(Padding < 4*1024) Padding = 4*1024; // Padding minimum 4kB
if (Size > 16*1024*1024) Size = 16*1024*1024; // maximum 16 MB
if (Size < 16*1024) Size = 16*1024; // minimum 16 MB
if (Padding > Size) Padding = Size; // Padding maximum =Disksize
if (Padding < 4*1024) Padding = 4*1024; // Padding minimum 4kB
__ramdisk_sectorsOfPadding = Padding/512;
__ramdisk_data_start = __ramdisk_data_end = new padding(0, __ramdisk_sectorsOfPadding);
if(!__ramdisk_data_start) return false;
if (!__ramdisk_data_start) return false;
// FAT12 Formatieren
u8 sector[512] = {0, };
@ -82,12 +77,12 @@ bool initRAMDisc(u32 Size, u32 Padding)
sector[0x038] = 'T';
sector[0x1fe] = 0x55;
sector[0x1ff] = 0xaa;
if(!__ramdisk_WriteSectors(0, 1, sector))
if (!__ramdisk_WriteSectors(0, 1, sector))
goto error;
memset(sector, 0, 512);
// clear FAT & rootDir
for(int i=1; i<= sectors_per_fat+3/*sectors_per_rootDir*/; i++)
if(!__ramdisk_WriteSectors(1, 1, sector))
for (int i=1; i<= sectors_per_fat+3/*sectors_per_rootDir*/; i++)
if (!__ramdisk_WriteSectors(1, 1, sector))
goto error;
return true;
error:
@ -97,30 +92,24 @@ error:
}
void exitRAMDisc()
{
while(__ramdisk_data_start)
{
void exitRAMDisc() {
while (__ramdisk_data_start) {
padding *tmp = __ramdisk_data_start;
__ramdisk_data_start = __ramdisk_data_start->next;
delete tmp;
}
}
static u8 *__ramdisk_findSector(size_t Sector, size_t *Sectors)
{
if(__ramdisk_data_start==NULL) return NULL;
for(padding *tmp = __ramdisk_data_start; tmp; tmp=tmp->next)
{
if(tmp->start <= Sector && tmp->end >= Sector)
{
if(Sectors) *Sectors = 1+tmp->end-Sector;
static u8 *__ramdisk_findSector(size_t Sector, size_t *Sectors) {
if (__ramdisk_data_start==NULL) return NULL;
for (padding *tmp = __ramdisk_data_start; tmp; tmp=tmp->next) {
if (tmp->start <= Sector && tmp->end >= Sector) {
if (Sectors) *Sectors = 1+tmp->end-Sector;
return &(tmp->data[(Sector-tmp->start)*512]);
}
}
// not found -> add padding
__ramdisk_data_end->next = new padding((Sector/__ramdisk_sectorsOfPadding)*__ramdisk_sectorsOfPadding, __ramdisk_sectorsOfPadding);
if(__ramdisk_data_end->next)
{
if (__ramdisk_data_end->next) {
__ramdisk_data_end = __ramdisk_data_end->next;
return &( __ramdisk_data_end->data[(Sector-__ramdisk_data_end->start)*512]);
}
@ -128,58 +117,45 @@ static u8 *__ramdisk_findSector(size_t Sector, size_t *Sectors)
}
static bool __ImplizitInit = false;
static bool __ramdisk_Startup(void)
{
if(!__ramdisk_IsInserted())
{
static bool __ramdisk_Startup(void) {
if (!__ramdisk_IsInserted()) {
// Std=8MB/64kB Padding
return (__ImplizitInit = initRAMDisc(8*1024*1024, 64 * 1024));
}
return true;
}
static bool __ramdisk_ReadSectors(size_t Sector, size_t numSectors, u8 *Buffer)
{
static bool __ramdisk_ReadSectors(size_t Sector, size_t numSectors, u8 *Buffer) {
size_t num_sectors;
while(numSectors)
{
if(u8 *buff = __ramdisk_findSector(Sector,&num_sectors))
{
if(num_sectors > numSectors) num_sectors = numSectors;
while (numSectors) {
if (u8 *buff = __ramdisk_findSector(Sector,&num_sectors)) {
if (num_sectors > numSectors) num_sectors = numSectors;
memcpy(Buffer, buff, num_sectors * 512);
numSectors -= num_sectors;
Buffer+= num_sectors;
}
else
} else
return false;
}
return true;
}
static bool __ramdisk_WriteSectors(size_t Sector, size_t numSectors, u8 *Buffer)
{
static bool __ramdisk_WriteSectors(size_t Sector, size_t numSectors, u8 *Buffer) {
size_t num_sectors;
while(numSectors)
{
if(u8 *buff = __ramdisk_findSector(Sector,&num_sectors))
{
if(num_sectors > numSectors) num_sectors = numSectors;
while (numSectors) {
if (u8 *buff = __ramdisk_findSector(Sector,&num_sectors)) {
if (num_sectors > numSectors) num_sectors = numSectors;
memcpy(buff, Buffer, num_sectors * 512);
numSectors -= num_sectors;
Buffer+= num_sectors;
}
else
} else
return false;
}
return true;
}
static bool __ramdisk_ClearStatus(void)
{
static bool __ramdisk_ClearStatus(void) {
return true;
}
static bool __ramdisk_Shutdown(void)
{
if(__ImplizitInit)
{
static bool __ramdisk_Shutdown(void) {
if (__ImplizitInit) {
__ImplizitInit = false;
exitRAMDisc();
}

File diff suppressed because it is too large Load Diff

View File

@ -30,8 +30,7 @@ extern void HaltGui();
/****************************************************************************
* MenuOGG
***************************************************************************/
bool MenuOGG()
{
bool MenuOGG() {
int cnt = 0;
int ret = 0, choice = 0;
int scrollon, nothingchanged = 0;
@ -60,13 +59,13 @@ bool MenuOGG()
char shortpath[35];
int countoggs = GetAllDirFiles(Settings.oggload_path);
if(!strcmp("", Settings.oggload_path)) {
if (!strcmp("", Settings.oggload_path)) {
sprintf(shortpath, "%s", tr("Standard"));
} else {
sprintf(shortpath, "%s", Settings.oggload_path);
}
GuiText titleTxt(shortpath, 24, (GXColor){0, 0, 0, 255});
GuiText titleTxt(shortpath, 24, (GXColor) {0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
titleTxt.SetPosition(0,0);
GuiButton pathBtn(300, 50);
@ -82,10 +81,10 @@ bool MenuOGG()
oggmenubackground.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
oggmenubackground.SetPosition(0, 0);
GuiText backBtnTxt(tr("Back") , 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText backBtnTxt(tr("Back") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage backBtnImg(&btnOutline);
if (Settings.wsprompt == yes){
if (Settings.wsprompt == yes) {
backBtnTxt.SetWidescreen(CFG.widescreen);
backBtnImg.SetWidescreen(CFG.widescreen);
}
@ -100,10 +99,10 @@ bool MenuOGG()
backBtn.SetTrigger(&trigB);
backBtn.SetEffectGrow();
GuiText defaultBtnTxt(tr("Default") , 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText defaultBtnTxt(tr("Default") , 22, (GXColor) { THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
defaultBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage defaultBtnImg(&btnOutline);
if (Settings.wsprompt == yes){
if (Settings.wsprompt == yes) {
defaultBtnTxt.SetWidescreen(CFG.widescreen);
defaultBtnImg.SetWidescreen(CFG.widescreen);
}
@ -124,7 +123,7 @@ bool MenuOGG()
options2.SetName(cnt,"%i.", cnt+1);
}
if(cnt < 9) {
if (cnt < 9) {
scrollon = 0;
} else {
scrollon = 1;
@ -177,19 +176,18 @@ bool MenuOGG()
w.SetEffect(EFFECT_FADE, 20);
ResumeGui();
while(w.GetEffect()>0) usleep(50);
while (w.GetEffect()>0) usleep(50);
while(!returnhere)
{
while (!returnhere) {
if(shutdown == 1)
if (shutdown == 1)
Sys_Shutdown();
if(reset == 1)
if (reset == 1)
Sys_Reboot();
if (backBtn.GetState() == STATE_CLICKED) {
if(nothingchanged == 1 && countoggs > 0) {
if(!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) {
if (nothingchanged == 1 && countoggs > 0) {
if (!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) {
bgMusic->Play();
} else {
bgMusic->PlayOggFile(Settings.ogg_path);
@ -229,13 +227,13 @@ bool MenuOGG()
w.Append(&defaultBtn);
if ( result == 1 ) {
int len = (strlen(entered)-1);
if(entered[len] !='/')
if (entered[len] !='/')
strncat (entered, "/", 1);
strncpy(Settings.oggload_path, entered, sizeof(Settings.oggload_path));
WindowPrompt(tr("Backgroundmusic Path changed."),0,tr("OK"));
// if(isSdInserted()) {
if(isInserted(bootDevice)) {
if(!strcmp("", Settings.oggload_path)) {
if (isInserted(bootDevice)) {
if (!strcmp("", Settings.oggload_path)) {
sprintf(Settings.ogg_path, "notset");
bgMusic->Play();
}
@ -246,7 +244,7 @@ bool MenuOGG()
WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK"));
}
}
if(countoggs > 0) {
if (countoggs > 0) {
optionBrowser4.SetFocus(1);
}
pathBtn.ResetState();
@ -254,13 +252,13 @@ bool MenuOGG()
ret = optionBrowser4.GetClickedOption();
if(ret>=0) {
if (ret>=0) {
choice = WindowPrompt(tr("Set as backgroundmusic?"),GetFileName(ret),tr("Yes"),tr("No"));
if(choice == 1) {
if (choice == 1) {
StopOgg();
snprintf(fullpath,150,"%s%s",Settings.oggload_path,GetFileName(ret));
choice = bgMusic->PlayOggFile(fullpath);
if(choice < 0) {
if (choice < 0) {
WindowPrompt(tr("Not supported format!"), tr("Loading standard music."), tr("OK"));
sprintf(Settings.ogg_path, "notset");
bgMusic->Play();
@ -276,13 +274,13 @@ bool MenuOGG()
}
if (playBtn.GetState() == STATE_CLICKED && countoggs > 0) {
if(countoggs > 0) {
if (countoggs > 0) {
ret = optionBrowser4.GetSelectedOption();
snprintf(fullpath, 150,"%s%s", Settings.oggload_path,GetFileName(ret));
choice = bgMusic->PlayOggFile(fullpath);
if(choice < 0) {
if (choice < 0) {
WindowPrompt(tr("Not supported format!"), tr("Loading standard music."), tr("OK"));
if(!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) {
if (!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) {
bgMusic->Play();
} else {
bgMusic->PlayOggFile(Settings.ogg_path);
@ -295,8 +293,8 @@ bool MenuOGG()
playBtn.ResetState();
}
if(stopBtn.GetState() == STATE_CLICKED) {
if(countoggs > 0) {
if (stopBtn.GetState() == STATE_CLICKED) {
if (countoggs > 0) {
StopOgg();
nothingchanged = 1;
optionBrowser4.SetFocus(1);
@ -306,7 +304,7 @@ bool MenuOGG()
}
w.SetEffect(EFFECT_FADE, -20);
while(w.GetEffect()>0) usleep(50);
while (w.GetEffect()>0) usleep(50);
HaltGui();
mainWindow->Remove(&w);
@ -318,8 +316,7 @@ bool MenuOGG()
/****************************************************************************
* MenuLanguageSelect
***************************************************************************/
int MenuLanguageSelect()
{
int MenuLanguageSelect() {
int cnt = 0;
int ret = 0, choice = 0;
int scrollon;
@ -343,13 +340,13 @@ int MenuLanguageSelect()
char fullpath[100];
int countfiles = GetAllDirFiles(Settings.languagefiles_path);
if(!strcmp("", Settings.languagefiles_path)) {
if (!strcmp("", Settings.languagefiles_path)) {
sprintf(fullpath, "%s", tr("Standard"));
} else {
sprintf(fullpath, "%s", Settings.languagefiles_path);
}
GuiText titleTxt(fullpath, 24, (GXColor){0, 0, 0, 255});
GuiText titleTxt(fullpath, 24, (GXColor) {0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
titleTxt.SetPosition(0,0);
GuiButton pathBtn(300, 50);
@ -365,10 +362,10 @@ int MenuLanguageSelect()
oggmenubackground.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
oggmenubackground.SetPosition(0, 0);
GuiText backBtnTxt(tr("Back") , 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText backBtnTxt(tr("Back") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage backBtnImg(&btnOutline);
if (Settings.wsprompt == yes){
if (Settings.wsprompt == yes) {
backBtnTxt.SetWidescreen(CFG.widescreen);
backBtnImg.SetWidescreen(CFG.widescreen);
}
@ -383,7 +380,7 @@ int MenuLanguageSelect()
backBtn.SetTrigger(&trigB);
backBtn.SetEffectGrow();
GuiText defaultBtnTxt(tr("Default") , 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText defaultBtnTxt(tr("Default") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
defaultBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage defaultBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
@ -400,7 +397,7 @@ int MenuLanguageSelect()
defaultBtn.SetTrigger(&trigA);
defaultBtn.SetEffectGrow();
GuiText updateBtnTxt(tr("Update Files") , 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiText updateBtnTxt(tr("Update Files") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
updateBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage updateBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
@ -423,13 +420,13 @@ int MenuLanguageSelect()
char filename[64];
strncpy(filename, GetFileName(cnt),63);
char *dot = strchr(filename, '.');
if(dot) *dot='\0';
if (dot) *dot='\0';
options2.SetName(cnt, "%s", filename);
options2.SetValue(cnt, NULL);
}
if(cnt < 9) {
if (cnt < 9) {
scrollon = 0;
} else {
scrollon = 1;
@ -452,14 +449,13 @@ int MenuLanguageSelect()
w.SetEffect(EFFECT_FADE, 20);
ResumeGui();
while(w.GetEffect()>0) usleep(50);
while (w.GetEffect()>0) usleep(50);
while(!returnhere)
{
while (!returnhere) {
if(shutdown == 1)
if (shutdown == 1)
Sys_Shutdown();
else if(reset == 1)
else if (reset == 1)
Sys_Reboot();
else if (backBtn.GetState() == STATE_CLICKED) {
@ -487,11 +483,11 @@ int MenuLanguageSelect()
if (choice == 1) {
bool network = true;
if(!IsNetworkInit()) {
if (!IsNetworkInit()) {
network = NetworkInitPrompt();
}
if(network) {
if (network) {
const char URL[60] = "http://usbloader-gui.googlecode.com/svn/trunk/Languages/";
char fullURL[300];
FILE *pfile;
@ -499,17 +495,17 @@ int MenuLanguageSelect()
URL_List LinkList(URL);
int listsize = LinkList.GetURLCount();
for(int i = 0; i < listsize; i++) {
for (int i = 0; i < listsize; i++) {
ShowProgress(tr("Updating Language Files:"), 0, LinkList.GetURL(i), i, listsize-1);
if(strcasecmp(".lang", strrchr(LinkList.GetURL(i), '.')) == 0) {
if (strcasecmp(".lang", strrchr(LinkList.GetURL(i), '.')) == 0) {
snprintf(fullURL, sizeof(fullURL), "%s%s", URL, LinkList.GetURL(i));
struct block file = downloadfile(fullURL);
if(file.data && file.size) {
if (file.data && file.size) {
char filepath[300];
snprintf(filepath, sizeof(filepath), "%s%s", Settings.languagefiles_path, LinkList.GetURL(i));
@ -545,12 +541,12 @@ int MenuLanguageSelect()
w.Append(&defaultBtn);
if ( result == 1 ) {
int len = (strlen(entered)-1);
if(entered[len] !='/')
if (entered[len] !='/')
strncat (entered, "/", 1);
strncpy(Settings.languagefiles_path, entered, sizeof(Settings.languagefiles_path));
WindowPrompt(tr("Languagepath changed."),0,tr("OK"));
// if(isSdInserted()) {
if(isInserted(bootDevice)) {
if (isInserted(bootDevice)) {
cfg_save_global();
returnhere = 1;
break;
@ -558,7 +554,7 @@ int MenuLanguageSelect()
WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK"));
}
}
if(countfiles > 0) {
if (countfiles > 0) {
optionBrowser4.SetFocus(1);
}
pathBtn.ResetState();
@ -566,14 +562,14 @@ int MenuLanguageSelect()
ret = optionBrowser4.GetClickedOption();
if(ret>=0) {
if (ret>=0) {
choice = WindowPrompt(tr("Do you want to change language?"), 0, tr("Yes"), tr("Cancel"));
if(choice == 1) {
if (choice == 1) {
// if(isSdInserted()) {
if(isInserted(bootDevice)) {
if (isInserted(bootDevice)) {
snprintf(Settings.language_path, sizeof(Settings.language_path), "%s%s", Settings.languagefiles_path, GetFileName(ret));
cfg_save_global();
if(!checkfile(Settings.language_path)) {
if (!checkfile(Settings.language_path)) {
sprintf(Settings.language_path, tr("not set"));
WindowPrompt(tr("File not found."),tr("Loading standard language."),tr("OK"));
}
@ -592,7 +588,7 @@ int MenuLanguageSelect()
}
w.SetEffect(EFFECT_FADE, -20);
while(w.GetEffect()>0) usleep(50);
while (w.GetEffect()>0) usleep(50);
HaltGui();
mainWindow->Remove(&w);

View File

@ -42,14 +42,12 @@ char alternatedname[40];
#define TITLE_MAX 200
struct ID_Title
{
struct ID_Title {
u8 id[5];
char title[TITLE_MAX];
};
struct ID_Control
{
struct ID_Control {
u8 id[5];
u8 block;
};
@ -72,14 +70,12 @@ struct Game_NUM cfg_game_num[MAX_SAVED_GAME_NUM];
static char *cfg_name, *cfg_val;
struct TextMap
{
struct TextMap {
char *name;
int id;
};
struct TextMap map_video[] =
{
struct TextMap map_video[] = {
{ "system", CFG_VIDEO_SYS },
{ "game", CFG_VIDEO_GAME },
{ "patch", CFG_VIDEO_PATCH },
@ -89,8 +85,7 @@ struct TextMap map_video[] =
{ NULL, -1 }
};
struct TextMap map_language[] =
{
struct TextMap map_language[] = {
{ "console", CFG_LANG_CONSOLE },
{ "japanese", CFG_LANG_JAPANESE },
{ "english", CFG_LANG_ENGLISH },
@ -106,8 +101,7 @@ struct TextMap map_language[] =
};
struct TextMap map_alignment[] =
{
struct TextMap map_alignment[] = {
{ "left", CFG_ALIGN_LEFT },
{ "right", CFG_ALIGN_RIGHT },
{ "center", CFG_ALIGN_CENTRE },
@ -116,15 +110,13 @@ struct TextMap map_alignment[] =
{ "middle", CFG_ALIGN_MIDDLE },
{ NULL, -1 }
};
char* strcopy(char *dest, char *src, int size)
{
char* strcopy(char *dest, char *src, int size) {
strncpy(dest,src,size);
dest[size-1] = 0;
return dest;
}
int map_get_id(struct TextMap *map, char *name)
{
int map_get_id(struct TextMap *map, char *name) {
int i;
for (i=0; map[i].name != NULL; i++) {
if (strcmp(name, map[i].name) == 0) return map[i].id;
@ -132,8 +124,7 @@ int map_get_id(struct TextMap *map, char *name)
return -1;
}
char* map_get_name(struct TextMap *map, short id)
{
char* map_get_name(struct TextMap *map, short id) {
int i;
for (i=0; map[i].name != NULL; i++) {
if (id == map[i].id) return map[i].name;
@ -141,8 +132,7 @@ char* map_get_name(struct TextMap *map, short id)
return NULL;
}
bool map_auto(char *name, char *name2, char *val, struct TextMap *map, short *var)
{
bool map_auto(char *name, char *name2, char *val, struct TextMap *map, short *var) {
if (strcmp(name, name2) != 0) return false;
int id = map_get_id(map, val);
if (id == -1) {
@ -154,36 +144,30 @@ bool map_auto(char *name, char *name2, char *val, struct TextMap *map, short *va
return true;
}
bool cfg_map_auto(char *name, struct TextMap *map, short *var)
{
bool cfg_map_auto(char *name, struct TextMap *map, short *var) {
return map_auto(name, cfg_name, cfg_val, map, var);
}
bool cfg_map(char *name, char *val, short *var, short id)
{
if (strcmp(name, cfg_name)==0 && strcmpi(val, cfg_val)==0)
{
bool cfg_map(char *name, char *val, short *var, short id) {
if (strcmp(name, cfg_name)==0 && strcmpi(val, cfg_val)==0) {
*var = id;
return true;
}
return false;
}
bool cfg_bool(char *name, short *var)
{
bool cfg_bool(char *name, short *var) {
return (cfg_map(name, "0", var, 0) || cfg_map(name, "1", var, 1));
}
void cfg_int(char *name, short *var, int count)
{
void cfg_int(char *name, short *var, int count) {
char tmp[5];
short i;
if (count > 10) //avoid overflow
return;
for (i = 0; i < count; i++)
{
for (i = 0; i < count; i++) {
sprintf(tmp, "%d", i);
cfg_map(name, tmp, var, i);
}
@ -193,23 +177,19 @@ void cfg_int(char *name, short *var, int count)
//static char bg_path[100];
void CFG_Default(int widescreen) // -1 = non forced Mode
{
if(widescreen == -1)
void CFG_Default(int widescreen) { // -1 = non forced Mode
if (widescreen == -1)
CFG.widescreen = CONF_GetAspectRatio();
else
CFG.widescreen = widescreen;
if (CFG.widescreen) {
snprintf(CFG.theme_path, sizeof(CFG.theme_path), "%s/wtheme/", bootDevice);
}
else
{
} else {
snprintf(CFG.theme_path, sizeof(CFG.theme_path), "%s/theme/", bootDevice);
}
if (widescreen == -1)
{
if (widescreen == -1) {
snprintf(Settings.covers_path, sizeof(Settings.covers_path), "%s/images/", bootDevice); //default image path
snprintf(Settings.disc_path, sizeof(Settings.disc_path), "%s/images/disc/", bootDevice);
snprintf(Settings.titlestxt_path, sizeof(Settings.titlestxt_path), "%s/config/", bootDevice);//default path for disc images
@ -314,8 +294,7 @@ void CFG_Default(int widescreen) // -1 = non forced Mode
}
}
void Global_Default(void)
{
void Global_Default(void) {
Settings.video = discdefault;
Settings.vpatch = off;
Settings.language = ConsoleLangDefault;
@ -323,8 +302,7 @@ void Global_Default(void)
Settings.hddinfo = hr12;
Settings.sinfo = ((THEME.showID) ? GameID : Neither);
Settings.rumble = RumbleOn;
if (THEME.showRegion)
{
if (THEME.showRegion) {
Settings.sinfo = ((Settings.sinfo == GameID) ? Both : GameRegion);
}
Settings.volume = 80;
@ -350,8 +328,7 @@ void Global_Default(void)
}
char *cfg_get_title(u8 *id)
{
char *cfg_get_title(u8 *id) {
int i;
for (i=0; i<num_title; i++) {
if (memcmp(id, cfg_title[i].id, 4) == 0) {
@ -361,15 +338,13 @@ char *cfg_get_title(u8 *id)
return NULL;
}
char *get_title(struct discHdr *header)
{
char *get_title(struct discHdr *header) {
char *title = cfg_get_title(header->id);
if (title) return title;
return header->title;
}
void title_set(char *id, char *title)
{
void title_set(char *id, char *title) {
char *idt = cfg_get_title((u8*)id);
if (idt) {
// replace
@ -389,8 +364,7 @@ void title_set(char *id, char *title)
}
}
u8 cfg_get_block(u8 *id)
{
u8 cfg_get_block(u8 *id) {
int i;
for (i=0; i<num_control; i++) {
if (memcmp(id, cfg_control[i].id, 4) == 0) {
@ -400,18 +374,19 @@ u8 cfg_get_block(u8 *id)
return 0;
}
u8 get_block(struct discHdr *header)
{
u8 get_block(struct discHdr *header) {
return cfg_get_block(header->id);
}
// trim leading and trailing whitespace
// copy at max n or at max size-1
char* trim_n_copy(char *dest, char *src, int n, int size)
{
char* trim_n_copy(char *dest, char *src, int n, int size) {
int len;
// trim leading white space
while (isspace(*src)) { src++; n--; }
while (isspace(*src)) {
src++;
n--;
}
len = strlen(src);
if (len > n) len = n;
// trim trailing white space
@ -423,8 +398,7 @@ char* trim_n_copy(char *dest, char *src, int n, int size)
return dest;
}
char* trimcopy(char *dest, char *src, int size)
{
char* trimcopy(char *dest, char *src, int size) {
int len;
while (*src == ' ') src++;
len = strlen(src);
@ -436,8 +410,7 @@ char* trimcopy(char *dest, char *src, int size)
return dest;
}
void widescreen_set(char *name, char *val)
{
void widescreen_set(char *name, char *val) {
cfg_name = name;
cfg_val = val;
@ -448,8 +421,7 @@ void widescreen_set(char *name, char *val)
void path_set(char *name, char *val)
{
void path_set(char *name, char *val) {
cfg_name = name;
cfg_val = val;
@ -521,12 +493,11 @@ void path_set(char *name, char *val)
void theme_set(char *name, char *val)
{
void theme_set(char *name, char *val) {
cfg_name = name;
cfg_val = val;
if(strcmp(cfg_name, "gamelist_coords") == 0) {
if (strcmp(cfg_name, "gamelist_coords") == 0) {
int x,y,w,h;
if (sscanf(val, "%d,%d,%d,%d", &x, &y, &w, &h) == 4) {
THEME.selection_x = x - (x % 4);
@ -536,7 +507,7 @@ void theme_set(char *name, char *val)
}
}
if(strcmp(cfg_name, "gamegrid_coords") == 0) {
if (strcmp(cfg_name, "gamegrid_coords") == 0) {
int x,y,w,h;
if (sscanf(val, "%d,%d,%d,%d", &x, &y, &w, &h) == 4) {
THEME.gamegrid_x = x - (x % 4);
@ -546,7 +517,7 @@ void theme_set(char *name, char *val)
}
}
if(strcmp(cfg_name, "gamecarousel_coords") == 0) {
if (strcmp(cfg_name, "gamecarousel_coords") == 0) {
int x,y,w,h;
if (sscanf(val, "%d,%d,%d,%d", &x, &y, &w, &h) == 4) {
THEME.gamecarousel_x = x - (x % 4);
@ -796,22 +767,21 @@ void theme_set(char *name, char *val)
if (sscanf(val, "%hd", &x) == 1) {
THEME.batteryUnused = x;
}
}
else if (strcmp(cfg_name, "tooltipAlpha") == 0) {
} else if (strcmp(cfg_name, "tooltipAlpha") == 0) {
short x;
if (sscanf(val, "%hd", &x) == 1) {
THEME.tooltipAlpha = x;
}
}
/*
/*
else if (strcmp(cfg_name, "maxcharacters") == 0) {
short x;
if (sscanf(val, "%hd", &x) == 1) {
THEME.maxcharacters = x;
}
}
*/
*/
@ -841,8 +811,7 @@ void theme_set(char *name, char *val)
}*/
}
void global_cfg_set(char *name, char *val)
{
void global_cfg_set(char *name, char *val) {
cfg_name = name;
cfg_val = val;
@ -852,8 +821,7 @@ void global_cfg_set(char *name, char *val)
Settings.video = i;
}
return;
}
else if (strcmp(name, "vpatch") == 0) {
} else if (strcmp(name, "vpatch") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.vpatch =i;
@ -867,173 +835,148 @@ void global_cfg_set(char *name, char *val)
Settings.language = i;
}
return;
}
else if (strcmp(name, "ocarina") == 0) {
} else if (strcmp(name, "ocarina") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.ocarina = i;
}
return;
}
else if (strcmp(name, "sort") == 0) {
} else if (strcmp(name, "sort") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.sort = i;
}
return;
}
else if (strcmp(name, "fave") == 0) {
} else if (strcmp(name, "fave") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.fave = i;
}
return;
}
else if (strcmp(name, "keyset") == 0) {
} else if (strcmp(name, "keyset") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.keyset = i;
}
return;
}
else if (strcmp(name, "hddinfo") == 0) {
} else if (strcmp(name, "hddinfo") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.hddinfo = i;
}
return;
}
else if (strcmp(name, "sinfo") == 0) {
} else if (strcmp(name, "sinfo") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.sinfo = i;
}
return;
}
else if (strcmp(name, "rumble") == 0) {
} else if (strcmp(name, "rumble") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.rumble = i;
}
return;
}
else if (strcmp(name, "volume") == 0) {
} else if (strcmp(name, "volume") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.volume = i;
}
return;
}
else if (strcmp(name, "sfxvolume") == 0) {
} else if (strcmp(name, "sfxvolume") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.sfxvolume = i;
}
return;
}
else if (strcmp(name, "tooltips") == 0) {
} else if (strcmp(name, "tooltips") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.tooltips = i;
}
return;
}
else if (strcmp(name, "password") == 0) {
} else if (strcmp(name, "password") == 0) {
strcopy(Settings.unlockCode, val, sizeof(Settings.unlockCode));
return;
}
else if (strcmp(name, "parentalcontrol") == 0) {
} else if (strcmp(name, "parentalcontrol") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.parentalcontrol = i;
}
return;
}
else if (strcmp(name, "cios") == 0) {
} else if (strcmp(name, "cios") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.cios = i;
}
return;
}
else if (strcmp(name, "gridRows") == 0) {
} else if (strcmp(name, "gridRows") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.gridRows = i;
}
return;
}
else if (strcmp(name, "xflip") == 0) {
} else if (strcmp(name, "xflip") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.xflip = i;
}
return;
}
else if (strcmp(name, "qboot") == 0) {
} else if (strcmp(name, "qboot") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.qboot = i;
}
return;
}
else if (strcmp(name, "wsprompt") == 0) {
} else if (strcmp(name, "wsprompt") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.wsprompt = i;
}
return;
}
else if (strcmp(name, "wiilight") == 0) {
} else if (strcmp(name, "wiilight") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.wiilight = i;
}
return;
}
else if (strcmp(name, "autonetwork") == 0) {
} else if (strcmp(name, "autonetwork") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.autonetwork = i;
}
return;
}
else if (strcmp(name, "patchcountrystrings") == 0) {
} else if (strcmp(name, "patchcountrystrings") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.patchcountrystrings = i;
}
return;
}
else if (strcmp(name, "error002") == 0) {
} else if (strcmp(name, "error002") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.error002 = i;
}
return;
}
else if (strcmp(name, "titlesOverride") == 0) {
} else if (strcmp(name, "titlesOverride") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.titlesOverride = i;
}
return;
}
else if (strcmp(name, "db_JPtoEN") == 0) {
} else if (strcmp(name, "db_JPtoEN") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.db_JPtoEN = i;
}
return;
}
else if (strcmp(name, "gameDisplay") == 0) {
} else if (strcmp(name, "gameDisplay") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.gameDisplay = i;
}
return;
}
else if (strcmp(name, "screensaver") == 0) {
} else if (strcmp(name, "screensaver") == 0) {
int i;
if (sscanf(val, "%d", &i) == 1) {
Settings.screensaver = i;
@ -1047,16 +990,14 @@ void global_cfg_set(char *name, char *val)
}
// split line to part1 delimiter part2
bool trimsplit(char *line, char *part1, char *part2, char delim, int size)
{
bool trimsplit(char *line, char *part1, char *part2, char delim, int size) {
char *eq = strchr(line, delim);
if (!eq) return false;
trim_n_copy(part1, line, eq-line, size);
trimcopy(part2, eq+1, size);
return true;
}
void cfg_parseline(char *line, void (*set_func)(char*, char*))
{
void cfg_parseline(char *line, void (*set_func)(char*, char*)) {
// split name = value
char tmp[200], name[200], val[200];
strcopy(tmp, line, sizeof(tmp));
@ -1069,8 +1010,7 @@ void cfg_parseline(char *line, void (*set_func)(char*, char*))
set_func(name, val);
}
void cfg_parsetitleline(char *line, void (*set_func)(char*, char*, u8))
{
void cfg_parsetitleline(char *line, void (*set_func)(char*, char*, u8)) {
// split name = value
char tmp[200], name[200], val[200];
int block = 0;
@ -1085,20 +1025,17 @@ void cfg_parsetitleline(char *line, void (*set_func)(char*, char*, u8))
if (!blockpos)
trimcopy(val, eq+1, sizeof(val));
else
{
else {
*blockpos = 0;
trimcopy(val, eq+1, sizeof(val));
if (sscanf(blockpos+1, "%d", &block) != 1)
{
if (sscanf(blockpos+1, "%d", &block) != 1) {
block = 0;
}
}
set_func(name, val, block);
}
bool cfg_parsefile(char *fname, void (*set_func)(char*, char*))
{
bool cfg_parsefile(char *fname, void (*set_func)(char*, char*)) {
FILE *f;
char line[200];
@ -1117,8 +1054,7 @@ bool cfg_parsefile(char *fname, void (*set_func)(char*, char*))
return true;
}
bool cfg_parsetitlefile(char *fname, void (*set_func)(char*, char*, u8))
{
bool cfg_parsetitlefile(char *fname, void (*set_func)(char*, char*, u8)) {
FILE *f;
char line[200];
@ -1161,8 +1097,7 @@ void cfg_parsearg(int argc, char **argv)
// return existing or new
struct Game_CFG* cfg_get_game(u8 *id)
{
struct Game_CFG* cfg_get_game(u8 *id) {
struct Game_CFG *game = CFG_get_game_opt(id);
if (game) return game;
if (num_saved_games >= MAX_SAVED_GAMES) return NULL;
@ -1172,8 +1107,7 @@ struct Game_CFG* cfg_get_game(u8 *id)
}
// current options to game
void cfg_set_game_opt(struct Game_CFG *game, u8 *id)
{
void cfg_set_game_opt(struct Game_CFG *game, u8 *id) {
strncpy((char*)game->id, (char*)id, 6);
game->id[6] = 0;
game->video = videoChoice;
@ -1190,8 +1124,7 @@ void cfg_set_game_opt(struct Game_CFG *game, u8 *id)
strcpy(game->alternatedolname, alternatedname);
}
struct Game_NUM* cfg_get_game_num(u8 *id)
{
struct Game_NUM* cfg_get_game_num(u8 *id) {
struct Game_NUM *game = CFG_get_game_num(id);
if (game) return game;
if (num_saved_game_num >= MAX_SAVED_GAME_NUM) return NULL;
@ -1201,8 +1134,7 @@ struct Game_NUM* cfg_get_game_num(u8 *id)
}
// current options to game
void cfg_set_game_num(struct Game_NUM *game, u8 *id)
{
void cfg_set_game_num(struct Game_NUM *game, u8 *id) {
strncpy((char*)game->id, (char*)id, 6);
game->id[6] = 0;
game->favorite = favoritevar;
@ -1210,12 +1142,11 @@ void cfg_set_game_num(struct Game_NUM *game, u8 *id)
}
bool cfg_save_global()// save global settings
{
bool cfg_save_global() { // save global settings
char GXGlobal_cfg[26];
sprintf(GXGlobal_cfg, "%s/config", bootDevice);
struct stat st;
if(stat(GXGlobal_cfg, &st) != 0) {
if (stat(GXGlobal_cfg, &st) != 0) {
mkdir(GXGlobal_cfg, 0777);
}
FILE *f;
@ -1254,7 +1185,7 @@ bool cfg_save_global()// save global settings
fprintf(f, "wsprompt = %d\n", Settings.wsprompt);
fprintf(f, "parentalcontrol = %d\n ", Settings.parentalcontrol);
fprintf(f, "cover_path = %s\n ", Settings.covers_path);
if(CFG.widescreen) {
if (CFG.widescreen) {
fprintf(f, "wtheme_path = %s\n ", CFG.theme_path);
} else {
fprintf(f, "theme_path = %s\n ", CFG.theme_path);
@ -1265,7 +1196,7 @@ bool cfg_save_global()// save global settings
fprintf(f, "oggload_path = %s\n ", Settings.oggload_path);
fprintf(f, "TxtCheatcodespath = %s\n ", Settings.TxtCheatcodespath);
fprintf(f, "titlestxt_path = %s\n ", Settings.titlestxt_path);
if(!strcmp("", Settings.unlockCode)) {
if (!strcmp("", Settings.unlockCode)) {
fprintf(f, "godmode = %d\n ", Settings.godmode);
} else {
fprintf(f, "godmode = %d\n ", 0);
@ -1289,8 +1220,7 @@ bool cfg_save_global()// save global settings
return true;
}
void game_set(char *name, char *val)
{
void game_set(char *name, char *val) {
// sample line:
// game:RTNP41 = video:game; language:english; ocarina:0;
// game:RYWP01 = video:patch; language:console; ocarina:1;
@ -1309,14 +1239,14 @@ void game_set(char *name, char *val)
char opt[200], *p, *np;
p = val;
while(p) {
while (p) {
np = strchr(p, ';');
if (np) trim_n_copy(opt, p, np-p, sizeof(opt));
else trimcopy(opt, p, sizeof(opt));
//printf("GAME(%s) (%s)\n", id, opt); sleep(1);
// parse opt 'language:english'
char opt_name[200], opt_val[200];
if (trimsplit(opt, opt_name, opt_val, ':', sizeof(opt_name))){
if (trimsplit(opt, opt_name, opt_val, ':', sizeof(opt_name))) {
//printf("GAME(%s) (%s=%s)\n", id, opt_name, opt_val); sleep(1);
short opt_v, opt_l, opt_c;
if (map_auto("video", opt_name, opt_val, map_video, &opt_v)) {
@ -1375,9 +1305,9 @@ void game_set(char *name, char *val)
if (strcmp("alternatedolname", opt_name) == 0) {
char temp3[40];
int i = 0;
while(i < 40) {
while (i < 40) {
if(opt_val[i] == ';')
if (opt_val[i] == ';')
break;
temp3[i] = opt_val[i];
@ -1388,12 +1318,12 @@ void game_set(char *name, char *val)
}
}
// next opt
if (np) p = np + 1; else p = NULL;
if (np) p = np + 1;
else p = NULL;
}
}
void parental_set(char *name, char *val)
{
void parental_set(char *name, char *val) {
// sample line:
// game:RTNP41 = video:game; language:english; ocarina:0;
// game:RYWP01 = video:patch; language:console; ocarina:1;
@ -1408,14 +1338,14 @@ void parental_set(char *name, char *val)
char opt[200], *p, *np;
p = val;
while(p) {
while (p) {
np = strchr(p, ';');
if (np) trim_n_copy(opt, p, np-p, sizeof(opt));
else trimcopy(opt, p, sizeof(opt));
//printf("GAME(%s) (%s)\n", id, opt); sleep(1);
// parse opt 'language:english'
char opt_name[200], opt_val[200];
if (trimsplit(opt, opt_name, opt_val, ':', sizeof(opt_name))){
if (trimsplit(opt, opt_name, opt_val, ':', sizeof(opt_name))) {
//printf("GAME(%s) (%s=%s)\n", id, opt_name, opt_val); sleep(1);
short opt_c;
@ -1437,12 +1367,12 @@ void parental_set(char *name, char *val)
}
// next opt
if (np) p = np + 1; else p = NULL;
if (np) p = np + 1;
else p = NULL;
}
}
void game_set_num(char *name, char *val)
{
void game_set_num(char *name, char *val) {
u8 id[8];
struct Game_NUM *game;
if (strncmp(name, "game:", 5) != 0) return;
@ -1457,13 +1387,13 @@ void game_set_num(char *name, char *val)
char opt[200], *p, *np;
p = val;
while(p) {
while (p) {
np = strchr(p, ';');
if (np) trim_n_copy(opt, p, np-p, sizeof(opt));
else trimcopy(opt, p, sizeof(opt));
char opt_name[200], opt_val[200];
if (trimsplit(opt, opt_name, opt_val, ':', sizeof(opt_name))){
if (trimsplit(opt, opt_name, opt_val, ':', sizeof(opt_name))) {
short opt_c;
if (strcmp("favorite", opt_name) == 0) {
@ -1478,26 +1408,24 @@ void game_set_num(char *name, char *val)
}
}
if (np) p = np + 1; else p = NULL;
if (np) p = np + 1;
else p = NULL;
}
}
bool cfg_load_games()
{
bool cfg_load_games() {
char GXGameSettings_cfg[32];
sprintf(GXGameSettings_cfg, "%s/config/GXGameSettings.cfg", bootDevice);
return cfg_parsefile(GXGameSettings_cfg, &game_set);
}
bool cfg_load_game_num()
{
bool cfg_load_game_num() {
char GXGameFavorites_cfg[32];
sprintf(GXGameFavorites_cfg, "%s/config/GXGameFavorites.cfg", bootDevice);
return cfg_parsefile(GXGameFavorites_cfg, &game_set_num);
}
bool cfg_save_games()
{
bool cfg_save_games() {
FILE *f;
int i;
char GXGameSettings_cfg[50];
@ -1542,8 +1470,7 @@ bool cfg_save_games()
return true;
}
bool cfg_save_game_num()
{
bool cfg_save_game_num() {
FILE *f;
int i;
char GXGameFavorites_cfg[32];
@ -1575,8 +1502,7 @@ bool cfg_save_game_num()
return true;
}
bool CFG_reset_all_playcounters()
{
bool CFG_reset_all_playcounters() {
FILE *f;
int i;
char GXGameFavorites_cfg[32];
@ -1608,8 +1534,7 @@ bool CFG_reset_all_playcounters()
return true;
}
bool cfg_load_global()
{
bool cfg_load_global() {
char GXGlobal_cfg[26];
sprintf(GXGlobal_cfg, "%s/config/GXGlobal.cfg", bootDevice);
//Default values defined by dev team
@ -1625,8 +1550,7 @@ bool cfg_load_global()
Settings.gameDisplay = list;
Settings.sinfo = ((THEME.showID) ? GameID : Neither);
Settings.rumble = RumbleOn;
if (THEME.showRegion)
{
if (THEME.showRegion) {
Settings.sinfo = ((Settings.sinfo == GameID) ? Both : GameRegion);
}
Settings.volume = 80;
@ -1642,8 +1566,7 @@ bool cfg_load_global()
struct Game_CFG* CFG_get_game_opt(u8 *id)
{
struct Game_CFG* CFG_get_game_opt(u8 *id) {
int i;
for (i=0; i<num_saved_games; i++) {
if (memcmp(id, cfg_game[i].id, 6) == 0) {
@ -1654,8 +1577,7 @@ struct Game_CFG* CFG_get_game_opt(u8 *id)
}
struct Game_NUM* CFG_get_game_num(u8 *id)
{
struct Game_NUM* CFG_get_game_num(u8 *id) {
int i;
for (i=0; i<num_saved_game_num; i++) {
if (memcmp(id, cfg_game_num[i].id, 6) == 0) {
@ -1665,24 +1587,21 @@ struct Game_NUM* CFG_get_game_num(u8 *id)
return NULL;
}
bool CFG_save_game_opt(u8 *id)
{
bool CFG_save_game_opt(u8 *id) {
struct Game_CFG *game = cfg_get_game(id);
if (!game) return false;
cfg_set_game_opt(game, id);
return cfg_save_games();
}
bool CFG_save_game_num(u8 *id)
{
bool CFG_save_game_num(u8 *id) {
struct Game_NUM *game = cfg_get_game_num(id);
if (!game) return false;
cfg_set_game_num(game, id);
return cfg_save_game_num();
}
bool CFG_forget_game_opt(u8 *id)
{
bool CFG_forget_game_opt(u8 *id) {
struct Game_CFG *game = CFG_get_game_opt(id);
int i;
if (!game) return true;
@ -1695,8 +1614,7 @@ bool CFG_forget_game_opt(u8 *id)
return cfg_save_games();
}
bool CFG_forget_game_num(u8 *id)
{
bool CFG_forget_game_num(u8 *id) {
struct Game_NUM *game = CFG_get_game_num(id);
int i;
if (!game) return true;
@ -1710,8 +1628,7 @@ bool CFG_forget_game_num(u8 *id)
}
void CFG_Load(void)
{
void CFG_Load(void) {
char pathname[200];
// bool ret = false;
@ -1753,17 +1670,14 @@ void CFG_Load(void)
// cfg_parsearg(argc, argv);
}
void CFG_LoadGlobal(void)
{
void CFG_LoadGlobal(void) {
char GXGlobal_cfg[26];
sprintf(GXGlobal_cfg, "%s/config/GXGlobal.cfg", bootDevice);
cfg_parsefile(GXGlobal_cfg, &global_cfg_set);
}
void CFG_Cleanup(void)
{
if (cfg_title)
{
void CFG_Cleanup(void) {
if (cfg_title) {
free(cfg_title);
cfg_title = NULL;
}

View File

@ -4,8 +4,7 @@
#include <gctypes.h>
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
#include "usbloader/disc.h"
@ -42,18 +41,16 @@ extern "C"
#define CFG_ALIGN_BOTTOM 4
#define CFG_ALIGN_MIDDLE 5
extern char bootDevice[10];
extern char bootDevice[10];
//extern char *cfg_path;
struct CFG
{
struct CFG {
short widescreen;
char theme_path[100];
};
};
struct THEME
{
struct THEME {
int selection_x;
int selection_y;
int selection_w;
@ -142,36 +139,35 @@ struct THEME
short gameText_g;
short gameText_b;
short pagesize;
};
};
extern struct CFG CFG;
extern struct THEME THEME;
extern u8 ocarinaChoice;
extern u16 playcnt;
extern u8 videoChoice;
extern u8 languageChoice;
extern u8 viChoice;
extern u8 iosChoice;
extern u8 parentalcontrolChoice;
extern u8 fix002;
extern u8 reloadblock;
extern u8 countrystrings;
extern u8 alternatedol;
extern u32 alternatedoloffset;
extern u8 xflip;
extern u8 qboot;
extern u8 sort;
extern u8 fave;
extern u8 wsprompt;
extern u8 keyset;
extern u8 gameDisplay;
extern u16 playcount;
extern u8 favoritevar;
extern char alternatedname[40];
extern struct CFG CFG;
extern struct THEME THEME;
extern u8 ocarinaChoice;
extern u16 playcnt;
extern u8 videoChoice;
extern u8 languageChoice;
extern u8 viChoice;
extern u8 iosChoice;
extern u8 parentalcontrolChoice;
extern u8 fix002;
extern u8 reloadblock;
extern u8 countrystrings;
extern u8 alternatedol;
extern u32 alternatedoloffset;
extern u8 xflip;
extern u8 qboot;
extern u8 sort;
extern u8 fave;
extern u8 wsprompt;
extern u8 keyset;
extern u8 gameDisplay;
extern u16 playcount;
extern u8 favoritevar;
extern char alternatedname[40];
struct Game_CFG
{
struct Game_CFG {
u8 id[8];
u8 video;
u8 language;
@ -185,28 +181,27 @@ struct Game_CFG
u32 alternatedolstart;
u8 patchcountrystrings;
char alternatedolname[40];
};
struct Game_NUM
{
};
struct Game_NUM {
u8 id[8];
u8 favorite;
u16 count;
};
};
void CFG_Default(int widescreen); // -1 = non forced mode
void CFG_Load(void);
void lang_defualt();
struct Game_CFG* CFG_get_game_opt(u8 *id);
struct Game_NUM* CFG_get_game_num(u8 *id);
bool CFG_save_game_opt(u8 *id);
bool CFG_save_game_num(u8 *id);
bool CFG_reset_all_playcounters();
bool CFG_forget_game_opt(u8 *id);
bool CFG_forget_game_num(u8 *id);
void CFG_Default(int widescreen); // -1 = non forced mode
void CFG_Load(void);
void lang_defualt();
struct Game_CFG* CFG_get_game_opt(u8 *id);
struct Game_NUM* CFG_get_game_num(u8 *id);
bool CFG_save_game_opt(u8 *id);
bool CFG_save_game_num(u8 *id);
bool CFG_reset_all_playcounters();
bool CFG_forget_game_opt(u8 *id);
bool CFG_forget_game_num(u8 *id);
enum {
enum {
ConsoleLangDefault=0,
jap,
eng,
@ -219,9 +214,9 @@ enum {
tchin,
kor,
settings_language_max // always the last entry
};
};
enum {
enum {
systemdefault=0,
discdefault,
patch,
@ -229,62 +224,62 @@ enum {
pal60,
ntsc,
settings_video_max // always the last entry
};
};
enum {
enum {
off=0,
on,
settings_off_on_max // always the last entry
};
enum {
};
enum {
anti=2,
};
};
enum {
enum {
GameID,
GameRegion,
Both,
Neither,
settings_sinfo_max // always the last entry
};
};
enum {
enum {
i249=0,
i222,
i223
};
};
enum {
enum {
ios249=0,
ios222,
settings_cios_max // always the last entry
};
};
enum {
enum {
hr12=0,
hr24,
Off,
settings_clock_max // always the last entry
};
enum {
};
enum {
all=0,
pcount,
};
};
enum {
enum {
RumbleOff=0,
RumbleOn,
settings_rumble_max // always the last entry
};
};
enum {
enum {
TooltipsOff=0,
TooltipsOn,
settings_tooltips_max // always the last entry
};
};
enum {
enum {
min3=1,
min5,
min10,
@ -292,36 +287,36 @@ enum {
min30,
min60,
settings_screensaver_max // always the last entry
};
};
enum {
enum {
no=0,
yes,
sysmenu,
wtf,
disk3d,
settings_xflip_max // always the last entry
};
enum {
};
enum {
us=0,
qwerty,
dvorak,
euro,
azerty,
settings_keyset_max // always the last entry
};
enum {
};
enum {
list,
grid,
carousel,
settings_display_max
};
enum {
};
enum {
scrollDefault,
scrollMarquee,
settings_scrolleffect_max // always the last entry
};
struct SSettings {
};
struct SSettings {
u8 video;
u8 language;
u8 ocarina;
@ -369,17 +364,17 @@ struct SSettings {
u8 db_JPtoEN;
u8 gridRows;
u8 autonetwork;
};
};
void CFG_LoadGlobal(void);
bool cfg_save_global(void);
void CFG_LoadGlobal(void);
bool cfg_save_global(void);
bool OpenXMLDatabase(char* xmlfilepath, char* argdblang, bool argJPtoEN, bool openfile, bool loadtitles, bool freemem);
bool OpenXMLDatabase(char* xmlfilepath, char* argdblang, bool argJPtoEN, bool openfile, bool loadtitles, bool freemem);
char *get_title(struct discHdr *header);
u8 get_block(struct discHdr *header);
char *get_title(struct discHdr *header);
u8 get_block(struct discHdr *header);
void CFG_Cleanup(void);
void CFG_Cleanup(void);
#ifdef __cplusplus
}

View File

@ -1,4 +1,4 @@
#define SVN_REV "673M"
#define SVN_REV "674M"
const char *GetRev()
{

View File

@ -2,11 +2,10 @@
#define SVNREV_H
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
const char *GetRev();
const char *GetRev();
#ifdef __cplusplus
}

View File

@ -18,7 +18,7 @@
static vu32 *_wiilight_reg = (u32*)0xCD0000C0;
void wiilight(int enable) { // Toggle wiilight (thanks Bool for wiilight source)
u32 val = (*_wiilight_reg&~0x20);
if(enable && Settings.wiilight) val |= 0x20;
if (enable && Settings.wiilight) val |= 0x20;
*_wiilight_reg=val;
}
@ -26,20 +26,17 @@ void wiilight(int enable) { // Toggle wiilight (thanks Bool for wiil
u8 shutdown = 0;
u8 reset = 0;
void __Sys_ResetCallback(void)
{
void __Sys_ResetCallback(void) {
/* Reboot console */
reset = 1;
}
void __Sys_PowerCallback(void)
{
void __Sys_PowerCallback(void) {
/* Poweroff console */
shutdown = 1;
}
void Sys_Init(void)
{
void Sys_Init(void) {
/* Initialize video subsytem */
//VIDEO_Init();
@ -48,8 +45,7 @@ void Sys_Init(void)
SYS_SetPowerCallback(__Sys_PowerCallback);
}
static void _ExitApp()
{
static void _ExitApp() {
ExitGUIThreads();
StopGX();
ShutdownAudio();
@ -60,15 +56,13 @@ static void _ExitApp()
mload_close();
}
void Sys_Reboot(void)
{
void Sys_Reboot(void) {
/* Restart console */
_ExitApp();
STM_RebootSystem();
}
int Sys_IosReload(int IOS)
{
int Sys_IosReload(int IOS) {
s32 ret = -1;
//shutdown SD and USB before IOS Reload in DiscWait
@ -83,19 +77,19 @@ int Sys_IosReload(int IOS)
USBStorage_Deinit();
if(IOS == 249 || IOS == 222 || IOS == 223) {
for(int i = 0; i < 10; i++) {
if (IOS == 249 || IOS == 222 || IOS == 223) {
for (int i = 0; i < 10; i++) {
ret = IOS_ReloadIOS(IOS);
if(ret < 0) return ret;
if(IOS == 222 || IOS == 223) load_ehc_module();
if (ret < 0) return ret;
if (IOS == 222 || IOS == 223) load_ehc_module();
ret = WBFS_Init(WBFS_DEVICE_USB);
if(!(ret < 0)) break;
if (!(ret < 0)) break;
sleep(1);
USBStorage_Deinit();
}
if(ret>=0) {
if (ret>=0) {
ret = Disc_Init();
if(ret>=0) {
if (ret>=0) {
ret = WBFS_Open();
}
} else Sys_BackToLoader();
@ -116,20 +110,19 @@ int Sys_IosReload(int IOS)
#define ShutdownToIdle 1
#define ShutdownToStandby 2
static void _Sys_Shutdown(int SHUTDOWN_MODE)
{
static void _Sys_Shutdown(int SHUTDOWN_MODE) {
_ExitApp();
WPAD_Flush(0);
WPAD_Disconnect(0);
WPAD_Shutdown();
/* Poweroff console */
if((CONF_GetShutdownMode() == CONF_SHUTDOWN_IDLE && SHUTDOWN_MODE != ShutdownToStandby) || SHUTDOWN_MODE == ShutdownToIdle) {
if ((CONF_GetShutdownMode() == CONF_SHUTDOWN_IDLE && SHUTDOWN_MODE != ShutdownToStandby) || SHUTDOWN_MODE == ShutdownToIdle) {
s32 ret;
/* Set LED mode */
ret = CONF_GetIdleLedMode();
if(ret >= 0 && ret <= 2)
if (ret >= 0 && ret <= 2)
STM_SetLedMode(ret);
/* Shutdown to idle */
@ -139,30 +132,24 @@ static void _Sys_Shutdown(int SHUTDOWN_MODE)
STM_ShutdownToStandby();
}
}
void Sys_Shutdown(void)
{
void Sys_Shutdown(void) {
_Sys_Shutdown(ShutdownToDefault);
}
void Sys_ShutdownToIdel(void)
{
void Sys_ShutdownToIdel(void) {
_Sys_Shutdown(ShutdownToIdle);
}
void Sys_ShutdownToStandby(void)
{
void Sys_ShutdownToStandby(void) {
_Sys_Shutdown(ShutdownToStandby);
}
void Sys_LoadMenu(void)
{
void Sys_LoadMenu(void) {
_ExitApp();
/* Return to the Wii system menu */
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
void Sys_BackToLoader(void)
{
if (*((u32*) 0x80001800))
{
void Sys_BackToLoader(void) {
if (*((u32*) 0x80001800)) {
_ExitApp();
exit(0);
}

View File

@ -32,8 +32,7 @@
/***********************************************************************
* Return the next byte in the pseudo-random sequence
*/
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
{
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) {
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */
@ -45,8 +44,7 @@ static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
/***********************************************************************
* Update the encryption keys with the next byte of plain text
*/
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
{
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) {
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
@ -62,8 +60,7 @@ static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int
* Initialize the encryption keys and the random header according to
* the given password.
*/
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
{
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) {
*(pkeys+0) = 305419896L;
*(pkeys+1) = 591751049L;
*(pkeys+2) = 878082192L;
@ -82,18 +79,18 @@ static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned lon
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
#define RAND_HEAD_LEN 12
/* "last resort" source for second part of crypt seed pattern */
/* "last resort" source for second part of crypt seed pattern */
# ifndef ZCR_SEED2
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
# endif
static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
const char *passwd; /* password string */
unsigned char *buf; /* where to write header */
int bufSize;
unsigned long* pkeys;
const unsigned long* pcrc_32_tab;
unsigned long crcForCrypting;
const char *passwd; /* password string */
unsigned char *buf; /* where to write header */
int bufSize;
unsigned long* pkeys;
const unsigned long* pcrc_32_tab;
unsigned long crcForCrypting;
{
int n; /* index in random header */
int t; /* temporary */
@ -108,20 +105,17 @@ static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
* output of rand() to get less predictability, since rand() is
* often poorly implemented.
*/
if (++calls == 1)
{
if (++calls == 1) {
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
}
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
for (n = 0; n < RAND_HEAD_LEN-2; n++) {
c = (rand() >> 7) & 0xff;
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
}
/* Encrypt random header (last two bytes is high word of crc) */
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
for (n = 0; n < RAND_HEAD_LEN-2; n++) {
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
}
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);

View File

@ -66,9 +66,9 @@ int ZCALLBACK ferror_file_func OF((
voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
voidpf opaque;
const char* filename;
int mode;
voidpf opaque;
const char* filename;
int mode;
{
FILE* file = NULL;
const char* mode_fopen = NULL;
@ -88,10 +88,10 @@ voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
voidpf opaque;
voidpf stream;
void* buf;
uLong size;
voidpf opaque;
voidpf stream;
void* buf;
uLong size;
{
uLong ret;
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
@ -100,10 +100,10 @@ uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
voidpf opaque;
voidpf stream;
const void* buf;
uLong size;
voidpf opaque;
voidpf stream;
const void* buf;
uLong size;
{
uLong ret;
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
@ -111,8 +111,8 @@ uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
}
long ZCALLBACK ftell_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
voidpf opaque;
voidpf stream;
{
long ret;
ret = ftell((FILE *)stream);
@ -120,15 +120,14 @@ long ZCALLBACK ftell_file_func (opaque, stream)
}
long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
voidpf opaque;
voidpf stream;
uLong offset;
int origin;
voidpf opaque;
voidpf stream;
uLong offset;
int origin;
{
int fseek_origin=0;
long ret;
switch (origin)
{
switch (origin) {
case ZLIB_FILEFUNC_SEEK_CUR :
fseek_origin = SEEK_CUR;
break;
@ -138,7 +137,8 @@ long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
case ZLIB_FILEFUNC_SEEK_SET :
fseek_origin = SEEK_SET;
break;
default: return -1;
default:
return -1;
}
ret = 0;
fseek((FILE *)stream, offset, fseek_origin);
@ -146,8 +146,8 @@ long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
}
int ZCALLBACK fclose_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
voidpf opaque;
voidpf stream;
{
int ret;
ret = fclose((FILE *)stream);
@ -155,8 +155,8 @@ int ZCALLBACK fclose_file_func (opaque, stream)
}
int ZCALLBACK ferror_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
voidpf opaque;
voidpf stream;
{
int ret;
ret = ferror((FILE *)stream);
@ -164,7 +164,7 @@ int ZCALLBACK ferror_file_func (opaque, stream)
}
void fill_fopen_filefunc (pzlib_filefunc_def)
zlib_filefunc_def* pzlib_filefunc_def;
zlib_filefunc_def* pzlib_filefunc_def;
{
pzlib_filefunc_def->zopen_file = fopen_file_func;
pzlib_filefunc_def->zread_file = fread_file_func;

View File

@ -35,16 +35,15 @@
extern "C" {
#endif
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
typedef struct zlib_filefunc_def_s
{
typedef struct zlib_filefunc_def_s {
open_file_func zopen_file;
read_file_func zread_file;
write_file_func zwrite_file;
@ -53,11 +52,11 @@ typedef struct zlib_filefunc_def_s
close_file_func zclose_file;
testerror_file_func zerror_file;
voidpf opaque;
} zlib_filefunc_def;
} zlib_filefunc_def;
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))

View File

@ -21,15 +21,13 @@
#define WRITEBUFFERSIZE (8192)
#define MAXFILENAME (256)
static int mymkdir(const char* dirname)
{
static int mymkdir(const char* dirname) {
int ret=0;
ret = mkdir (dirname,0775);
return ret;
}
int makedir (char *newdir)
{
int makedir (char *newdir) {
char *buffer ;
char *p;
int len = (int)strlen(newdir);
@ -43,23 +41,20 @@ int makedir (char *newdir)
if (buffer[len-1] == '/') {
buffer[len-1] = '\0';
}
if (mymkdir(buffer) == 0)
{
if (mymkdir(buffer) == 0) {
free(buffer);
return 1;
}
p = buffer+1;
while (1)
{
while (1) {
char hold;
while(*p && *p != '\\' && *p != '/')
while (*p && *p != '\\' && *p != '/')
p++;
hold = *p;
*p = 0;
if ((mymkdir(buffer) == -1) && (errno == ENOENT))
{
if ((mymkdir(buffer) == -1) && (errno == ENOENT)) {
printf("couldn't create directory %s\n",buffer);
free(buffer);
return 0;
@ -72,8 +67,7 @@ int makedir (char *newdir)
return 1;
}
static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_path,int* popt_overwrite,const char* password)
{
static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_path,int* popt_overwrite,const char* password) {
char filename_inzip[256];
char* filename_withoutpath;
char* p;
@ -85,38 +79,31 @@ static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_pat
unz_file_info file_info;
err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
if (err!=UNZ_OK)
{
if (err!=UNZ_OK) {
printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
return err;
}
size_buf = WRITEBUFFERSIZE;
buf = (void*)malloc(size_buf);
if (buf==NULL)
{
if (buf==NULL) {
printf("Error allocating memory\n");
return UNZ_INTERNALERROR;
}
p = filename_withoutpath = filename_inzip;
while ((*p) != '\0')
{
while ((*p) != '\0') {
if (((*p)=='/') || ((*p)=='\\'))
filename_withoutpath = p+1;
p++;
}
if ((*filename_withoutpath)=='\0')
{
if ((*popt_extract_without_path)==0)
{
if ((*filename_withoutpath)=='\0') {
if ((*popt_extract_without_path)==0) {
printf("creating directory: %s\n",filename_inzip);
mymkdir(filename_inzip);
}
}
else
{
} else {
char* write_filename;
int skip=0;
@ -126,35 +113,29 @@ static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_pat
write_filename = filename_withoutpath;
err = unzOpenCurrentFilePassword(uf,password);
if (err!=UNZ_OK)
{
if (err!=UNZ_OK) {
printf("error %d with zipfile in unzOpenCurrentFilePassword\n",err);
}
if (((*popt_overwrite)==0) && (err==UNZ_OK))
{
if (((*popt_overwrite)==0) && (err==UNZ_OK)) {
char rep=0;
FILE* ftestexist;
ftestexist = fopen(write_filename,"rb");
if (ftestexist!=NULL)
{
if (ftestexist!=NULL) {
fclose(ftestexist);
do
{
do {
char answer[128];
int ret;
printf("The file %s exists. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename);
ret = scanf("%1s",answer);
if (ret != 1)
{
if (ret != 1) {
exit(EXIT_FAILURE);
}
rep = answer[0] ;
if ((rep>='a') && (rep<='z'))
rep -= 0x20;
}
while ((rep!='Y') && (rep!='N') && (rep!='A'));
} while ((rep!='Y') && (rep!='N') && (rep!='A'));
}
if (rep == 'N')
@ -164,14 +145,12 @@ static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_pat
*popt_overwrite=1;
}
if ((skip==0) && (err==UNZ_OK))
{
if ((skip==0) && (err==UNZ_OK)) {
fout=fopen(write_filename,"wb");
/* some zipfile don't contain directory alone before file */
if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
(filename_withoutpath!=(char*)filename_inzip))
{
(filename_withoutpath!=(char*)filename_inzip)) {
char c=*(filename_withoutpath-1);
*(filename_withoutpath-1)='\0';
makedir(write_filename);
@ -179,47 +158,38 @@ static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_pat
fout=fopen(write_filename,"wb");
}
if (fout==NULL)
{
if (fout==NULL) {
printf("error opening %s\n",write_filename);
}
}
if (fout!=NULL)
{
if (fout!=NULL) {
printf(" extracting: %s\n",write_filename);
do
{
do {
err = unzReadCurrentFile(uf,buf,size_buf);
if (err<0)
{
if (err<0) {
printf("error %d with zipfile in unzReadCurrentFile\n",err);
break;
}
if (err>0)
if (fwrite(buf,err,1,fout)!=1)
{
if (fwrite(buf,err,1,fout)!=1) {
printf("error in writing extracted file\n");
err=UNZ_ERRNO;
break;
}
}
while (err>0);
} while (err>0);
if (fout)
fclose(fout);
}
if (err==UNZ_OK)
{
if (err==UNZ_OK) {
err = unzCloseCurrentFile (uf);
if (err!=UNZ_OK)
{
if (err!=UNZ_OK) {
printf("error %d with zipfile in unzCloseCurrentFile\n",err);
}
}
else
} else
unzCloseCurrentFile(uf); /* don't lose the error */
}
@ -228,8 +198,7 @@ static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_pat
}
int extractZip(unzFile uf,int opt_extract_without_path,int opt_overwrite,const char* password)
{
int extractZip(unzFile uf,int opt_extract_without_path,int opt_overwrite,const char* password) {
uLong i;
unz_global_info gi;
int err;
@ -238,18 +207,15 @@ int extractZip(unzFile uf,int opt_extract_without_path,int opt_overwrite,const c
if (err!=UNZ_OK)
printf("error %d with zipfile in unzGetGlobalInfo \n",err);
for (i=0;i<gi.number_entry;i++)
{
for (i=0;i<gi.number_entry;i++) {
if (do_extract_currentfile(uf,&opt_extract_without_path,
&opt_overwrite,
password) != UNZ_OK)
break;
if ((i+1)<gi.number_entry)
{
if ((i+1)<gi.number_entry) {
err = unzGoToNextFile(uf);
if (err!=UNZ_OK)
{
if (err!=UNZ_OK) {
printf("error %d with zipfile in unzGoToNextFile\n",err);
break;
}
@ -259,10 +225,8 @@ int extractZip(unzFile uf,int opt_extract_without_path,int opt_overwrite,const c
return 0;
}
int extractZipOnefile(unzFile uf,const char* filename,int opt_extract_without_path,int opt_overwrite,const char* password)
{
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
{
int extractZipOnefile(unzFile uf,const char* filename,int opt_extract_without_path,int opt_overwrite,const char* password) {
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK) {
printf("file %s not found in the zipfile\n",filename);
return 2;
}

View File

@ -6,9 +6,9 @@
extern "C" {
#endif
int extractZip(unzFile uf,int opt_extract_without_path,int opt_overwrite,const char* password);
int extractZipOnefile(unzFile uf,const char* filename,int opt_extract_without_path,int opt_overwrite,const char* password);
int makedir(char *newdir);
int extractZip(unzFile uf,int opt_extract_without_path,int opt_overwrite,const char* password);
int extractZipOnefile(unzFile uf,const char* filename,int opt_extract_without_path,int opt_overwrite,const char* password);
int makedir(char *newdir);
#ifdef __cplusplus
}

View File

@ -28,7 +28,7 @@
} while(0)
extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered)
const char* file;
const char* file;
const char* fileOut;
const char* fileOutTmp;
uLong* nRecovered;

View File

@ -17,12 +17,12 @@ extern "C" {
#include "unzip.h"
/* Repair a ZIP file (missing central directory)
/* Repair a ZIP file (missing central directory)
file: file to recover
fileOut: output file after recovery
fileOutTmp: temporary file name used for recovery
*/
extern int ZEXPORT unzRepair(const char* file,
*/
extern int ZEXPORT unzRepair(const char* file,
const char* fileOut,
const char* fileOutTmp,
uLong* nRecovered,

View File

@ -47,7 +47,7 @@ woven in by Terry Thorsen 1/2003.
# include <stdlib.h>
#endif
#ifdef NO_ERRNO_H
extern int errno;
extern int errno;
#else
# include <errno.h>
#endif
@ -91,16 +91,14 @@ const char unz_copyright[] =
" unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
/* unz_file_info_interntal contain internal info about a file in zipfile*/
typedef struct unz_file_info_internal_s
{
typedef struct unz_file_info_internal_s {
uLong offset_curfile;/* relative offset of local header 4 bytes */
} unz_file_info_internal;
/* file_in_zip_read_info_s contain internal information about a file in zipfile,
when reading and decompress it */
typedef struct
{
typedef struct {
char *read_buffer; /* internal buffer for compressed data */
z_stream stream; /* zLib stream structure for inflate */
@ -125,8 +123,7 @@ typedef struct
/* unz_s contain internal information about the zipfile
*/
typedef struct
{
typedef struct {
zlib_filefunc_def z_filefunc;
voidpf filestream; /* io structore of the zipfile */
unz_global_info gi; /* public global information */
@ -169,19 +166,16 @@ local int unzlocal_getByte OF((
int *pi));
local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi)
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
int *pi;
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
int *pi;
{
unsigned char c;
int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
if (err==1)
{
if (err==1) {
*pi = (int)c;
return UNZ_OK;
}
else
{
} else {
if (ZERROR(*pzlib_filefunc_def,filestream))
return UNZ_ERRNO;
else
@ -199,9 +193,9 @@ local int unzlocal_getShort OF((
uLong *pX));
local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX)
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
uLong *pX;
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
uLong *pX;
{
uLong x ;
int i;
@ -227,9 +221,9 @@ local int unzlocal_getLong OF((
uLong *pX));
local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX)
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
uLong *pX;
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
uLong *pX;
{
uLong x ;
int i;
@ -260,11 +254,10 @@ local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX)
/* My own strcmpi / strcasecmp */
local int strcmpcasenosensitive_internal (fileName1,fileName2)
const char* fileName1;
const char* fileName2;
const char* fileName1;
const char* fileName2;
{
for (;;)
{
for (;;) {
char c1=*(fileName1++);
char c2=*(fileName2++);
if ((c1>='a') && (c1<='z'))
@ -304,8 +297,8 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2)
*/
extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity)
const char* fileName1;
const char* fileName2;
int iCaseSensitivity;
const char* fileName2;
int iCaseSensitivity;
{
if (iCaseSensitivity==0)
iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
@ -329,8 +322,8 @@ local uLong unzlocal_SearchCentralDir OF((
voidpf filestream));
local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream)
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
{
unsigned char* buf;
uLong uSizeFile;
@ -352,8 +345,7 @@ local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream)
return 0;
uBackRead = 4;
while (uBackRead<uMaxBack)
{
while (uBackRead<uMaxBack) {
uLong uReadSize,uReadPos ;
int i;
if (uBackRead+BUFREADCOMMENT>uMaxBack)
@ -372,8 +364,7 @@ local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream)
for (i=(int)uReadSize-3; (i--)>0;)
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
{
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) {
uPosFound = uReadPos+i;
break;
}
@ -396,7 +387,7 @@ local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream)
*/
extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def)
const char *path;
zlib_filefunc_def* pzlib_filefunc_def;
zlib_filefunc_def* pzlib_filefunc_def;
{
unz_s us;
unz_s *s;
@ -477,8 +468,7 @@ extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def)
(err==UNZ_OK))
err=UNZ_BADZIPFILE;
if (err!=UNZ_OK)
{
if (err!=UNZ_OK) {
ZCLOSE(us.z_filefunc, us.filestream);
return NULL;
}
@ -531,7 +521,7 @@ extern int ZEXPORT unzClose (file)
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
unzFile file;
unz_global_info *pglobal_info;
unz_global_info *pglobal_info;
{
unz_s* s;
if (file==NULL)
@ -546,8 +536,8 @@ extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
Translate date/time from Dos format to tm_unz (readable more easilty)
*/
local void unzlocal_DosDateToTmuDate (ulDosDate, ptm)
uLong ulDosDate;
tm_unz* ptm;
uLong ulDosDate;
tm_unz* ptm;
{
uLong uDate;
uDate = (uLong)(ulDosDate>>16);
@ -580,15 +570,15 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
szFileName, fileNameBufferSize,
extraField, extraFieldBufferSize,
szComment, commentBufferSize)
unzFile file;
unz_file_info *pfile_info;
unz_file_info_internal *pfile_info_internal;
char *szFileName;
uLong fileNameBufferSize;
void *extraField;
uLong extraFieldBufferSize;
char *szComment;
uLong commentBufferSize;
unzFile file;
unz_file_info *pfile_info;
unz_file_info_internal *pfile_info_internal;
char *szFileName;
uLong fileNameBufferSize;
void *extraField;
uLong extraFieldBufferSize;
char *szComment;
uLong commentBufferSize;
{
unz_s* s;
unz_file_info file_info;
@ -607,8 +597,7 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
/* we check the magic */
if (err==UNZ_OK)
{
if (err==UNZ_OK) {
if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
else if (uMagic!=0x02014b50)
@ -663,15 +652,12 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
err=UNZ_ERRNO;
lSeek+=file_info.size_filename;
if ((err==UNZ_OK) && (szFileName!=NULL))
{
if ((err==UNZ_OK) && (szFileName!=NULL)) {
uLong uSizeRead ;
if (file_info.size_filename<fileNameBufferSize)
{
if (file_info.size_filename<fileNameBufferSize) {
*(szFileName+file_info.size_filename)='\0';
uSizeRead = file_info.size_filename;
}
else
} else
uSizeRead = fileNameBufferSize;
if ((file_info.size_filename>0) && (fileNameBufferSize>0))
@ -681,16 +667,14 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
}
if ((err==UNZ_OK) && (extraField!=NULL))
{
if ((err==UNZ_OK) && (extraField!=NULL)) {
uLong uSizeRead ;
if (file_info.size_file_extra<extraFieldBufferSize)
uSizeRead = file_info.size_file_extra;
else
uSizeRead = extraFieldBufferSize;
if (lSeek!=0)
{
if (lSeek!=0) {
if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
lSeek=0;
else
@ -701,24 +685,19 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead)
err=UNZ_ERRNO;
lSeek += file_info.size_file_extra - uSizeRead;
}
else
} else
lSeek+=file_info.size_file_extra;
if ((err==UNZ_OK) && (szComment!=NULL))
{
if ((err==UNZ_OK) && (szComment!=NULL)) {
uLong uSizeRead ;
if (file_info.size_file_comment<commentBufferSize)
{
if (file_info.size_file_comment<commentBufferSize) {
*(szComment+file_info.size_file_comment)='\0';
uSizeRead = file_info.size_file_comment;
}
else
} else
uSizeRead = commentBufferSize;
if (lSeek!=0)
{
if (lSeek!=0) {
if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
lSeek=0;
else
@ -729,8 +708,7 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
err=UNZ_ERRNO;
lSeek+=file_info.size_file_comment - uSizeRead;
}
else
} else
lSeek+=file_info.size_file_comment;
if ((err==UNZ_OK) && (pfile_info!=NULL))
@ -755,13 +733,13 @@ extern int ZEXPORT unzGetCurrentFileInfo (file,
extraField, extraFieldBufferSize,
szComment, commentBufferSize)
unzFile file;
unz_file_info *pfile_info;
char *szFileName;
uLong fileNameBufferSize;
void *extraField;
uLong extraFieldBufferSize;
char *szComment;
uLong commentBufferSize;
unz_file_info *pfile_info;
char *szFileName;
uLong fileNameBufferSize;
void *extraField;
uLong extraFieldBufferSize;
char *szComment;
uLong commentBufferSize;
{
return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
szFileName,fileNameBufferSize,
@ -831,8 +809,8 @@ extern int ZEXPORT unzGoToNextFile (file)
*/
extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
unzFile file;
const char *szFileName;
int iCaseSensitivity;
const char *szFileName;
int iCaseSensitivity;
{
unz_s* s;
int err;
@ -864,14 +842,12 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
err = unzGoToFirstFile(file);
while (err == UNZ_OK)
{
while (err == UNZ_OK) {
char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
err = unzGetCurrentFileInfo(file,NULL,
szCurrentFileName,sizeof(szCurrentFileName)-1,
NULL,0,NULL,0);
if (err == UNZ_OK)
{
if (err == UNZ_OK) {
if (unzStringFileNameCompare(szCurrentFileName,
szFileName,iCaseSensitivity)==0)
return UNZ_OK;
@ -910,7 +886,7 @@ typedef struct unz_file_pos_s
extern int ZEXPORT unzGetFilePos(file, file_pos)
unzFile file;
unz_file_pos* file_pos;
unz_file_pos* file_pos;
{
unz_s* s;
@ -928,7 +904,7 @@ extern int ZEXPORT unzGetFilePos(file, file_pos)
extern int ZEXPORT unzGoToFilePos(file, file_pos)
unzFile file;
unz_file_pos* file_pos;
unz_file_pos* file_pos;
{
unz_s* s;
int err;
@ -965,10 +941,10 @@ extern int ZEXPORT unzGoToFilePos(file, file_pos)
local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
poffset_local_extrafield,
psize_local_extrafield)
unz_s* s;
uInt* piSizeVar;
uLong *poffset_local_extrafield;
uInt *psize_local_extrafield;
unz_s* s;
uInt* piSizeVar;
uLong *poffset_local_extrafield;
uInt *psize_local_extrafield;
{
uLong uMagic,uData,uFlags;
uLong size_filename;
@ -984,8 +960,7 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
return UNZ_ERRNO;
if (err==UNZ_OK)
{
if (err==UNZ_OK) {
if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
else if (uMagic!=0x04034b50)
@ -994,10 +969,10 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
err=UNZ_ERRNO;
/*
/*
else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
err=UNZ_BADZIPFILE;
*/
*/
if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
err=UNZ_ERRNO;
@ -1056,10 +1031,10 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
*/
extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
unzFile file;
int* method;
int* level;
int raw;
const char* password;
int* method;
int* level;
int raw;
const char* password;
{
int err=UNZ_OK;
uInt iSizeVar;
@ -1098,8 +1073,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
pfile_in_zip_read_info->pos_local_extrafield=0;
pfile_in_zip_read_info->raw=raw;
if (pfile_in_zip_read_info->read_buffer==NULL)
{
if (pfile_in_zip_read_info->read_buffer==NULL) {
TRYFREE(pfile_in_zip_read_info);
return UNZ_INTERNALERROR;
}
@ -1109,14 +1083,18 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
if (method!=NULL)
*method = (int)s->cur_file_info.compression_method;
if (level!=NULL)
{
if (level!=NULL) {
*level = 6;
switch (s->cur_file_info.flag & 0x06)
{
case 6 : *level = 1; break;
case 4 : *level = 2; break;
case 2 : *level = 9; break;
switch (s->cur_file_info.flag & 0x06) {
case 6 :
*level = 1;
break;
case 4 :
*level = 2;
break;
case 2 :
*level = 9;
break;
}
}
@ -1135,8 +1113,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
pfile_in_zip_read_info->stream.total_out = 0;
if ((s->cur_file_info.compression_method==Z_DEFLATED) &&
(!raw))
{
(!raw)) {
pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
pfile_in_zip_read_info->stream.zfree = (free_func)0;
pfile_in_zip_read_info->stream.opaque = (voidpf)0;
@ -1146,8 +1123,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
if (err == Z_OK)
pfile_in_zip_read_info->stream_initialised=1;
else
{
else {
TRYFREE(pfile_in_zip_read_info);
return err;
}
@ -1174,8 +1150,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
s->pfile_in_zip_read = pfile_in_zip_read_info;
# ifndef NOUNCRYPT
if (password != NULL)
{
if (password != NULL) {
int i;
s->pcrc_32_tab = get_crc_table();
init_keys(password,s->keys,s->pcrc_32_tab);
@ -1184,7 +1159,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
s->pfile_in_zip_read->byte_before_the_zipfile,
SEEK_SET)!=0)
return UNZ_INTERNALERROR;
if(ZREAD(s->z_filefunc, s->filestream,source, 12)<12)
if (ZREAD(s->z_filefunc, s->filestream,source, 12)<12)
return UNZ_INTERNALERROR;
for (i = 0; i<12; i++)
@ -1207,16 +1182,16 @@ extern int ZEXPORT unzOpenCurrentFile (file)
extern int ZEXPORT unzOpenCurrentFilePassword (file, password)
unzFile file;
const char* password;
const char* password;
{
return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
}
extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw)
unzFile file;
int* method;
int* level;
int raw;
int* method;
int* level;
int raw;
{
return unzOpenCurrentFile3(file, method, level, raw, NULL);
}
@ -1233,8 +1208,8 @@ extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw)
*/
extern int ZEXPORT unzReadCurrentFile (file, buf, len)
unzFile file;
voidp buf;
unsigned len;
voidp buf;
unsigned len;
{
int err=UNZ_OK;
uInt iRead = 0;
@ -1270,11 +1245,9 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
(uInt)pfile_in_zip_read_info->rest_read_compressed+
pfile_in_zip_read_info->stream.avail_in;
while (pfile_in_zip_read_info->stream.avail_out>0)
{
while (pfile_in_zip_read_info->stream.avail_out>0) {
if ((pfile_in_zip_read_info->stream.avail_in==0) &&
(pfile_in_zip_read_info->rest_read_compressed>0))
{
(pfile_in_zip_read_info->rest_read_compressed>0)) {
uInt uReadThis = UNZ_BUFSIZE;
if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
@ -1294,10 +1267,9 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
# ifndef NOUNCRYPT
if(s->encrypted)
{
if (s->encrypted) {
uInt i;
for(i=0;i<uReadThis;i++)
for (i=0;i<uReadThis;i++)
pfile_in_zip_read_info->read_buffer[i] =
zdecode(s->keys,s->pcrc_32_tab,
pfile_in_zip_read_info->read_buffer[i]);
@ -1314,8 +1286,7 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
}
if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
{
if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) {
uInt uDoCopy,i ;
if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
@ -1342,9 +1313,7 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
pfile_in_zip_read_info->stream.next_in += uDoCopy;
pfile_in_zip_read_info->stream.total_out += uDoCopy;
iRead += uDoCopy;
}
else
{
} else {
uLong uTotalOutBefore,uTotalOutAfter;
const Bytef *bufBefore;
uLong uOutThis;
@ -1447,8 +1416,8 @@ extern int ZEXPORT unzeof (file)
*/
extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
unzFile file;
voidp buf;
unsigned len;
voidp buf;
unsigned len;
{
unz_s* s;
file_in_zip_read_info_s* pfile_in_zip_read_info;
@ -1513,8 +1482,7 @@ extern int ZEXPORT unzCloseCurrentFile (file)
if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
(!pfile_in_zip_read_info->raw))
{
(!pfile_in_zip_read_info->raw)) {
if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
err=UNZ_CRCERROR;
}
@ -1541,8 +1509,8 @@ extern int ZEXPORT unzCloseCurrentFile (file)
*/
extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
unzFile file;
char *szComment;
uLong uSizeBuf;
char *szComment;
uLong uSizeBuf;
{
unz_s* s;
uLong uReadThis ;
@ -1557,8 +1525,7 @@ extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
if (ZSEEK(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
return UNZ_ERRNO;
if (uReadThis>0)
{
if (uReadThis>0) {
*szComment='\0';
if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
return UNZ_ERRNO;
@ -1588,7 +1555,7 @@ extern uLong ZEXPORT unzGetOffset (file)
extern int ZEXPORT unzSetOffset (file, pos)
unzFile file;
uLong pos;
uLong pos;
{
unz_s* s;
int err;

View File

@ -58,12 +58,14 @@ extern "C" {
#endif
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
/* like the STRICT of WIN32, we define a pointer that cannot be converted
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
typedef struct TagunzFile__ { int unused; } unzFile__;
typedef unzFile__ *unzFile;
typedef struct TagunzFile__ {
int unused;
} unzFile__;
typedef unzFile__ *unzFile;
#else
typedef voidp unzFile;
typedef voidp unzFile;
#endif
@ -76,30 +78,27 @@ typedef voidp unzFile;
#define UNZ_INTERNALERROR (-104)
#define UNZ_CRCERROR (-105)
/* tm_unz contain date/time info */
typedef struct tm_unz_s
{
/* tm_unz contain date/time info */
typedef struct tm_unz_s {
uInt tm_sec; /* seconds after the minute - [0,59] */
uInt tm_min; /* minutes after the hour - [0,59] */
uInt tm_hour; /* hours since midnight - [0,23] */
uInt tm_mday; /* day of the month - [1,31] */
uInt tm_mon; /* months since January - [0,11] */
uInt tm_year; /* years - [1980..2044] */
} tm_unz;
} tm_unz;
/* unz_global_info structure contain global data about the ZIPfile
/* unz_global_info structure contain global data about the ZIPfile
These data comes from the end of central dir */
typedef struct unz_global_info_s
{
typedef struct unz_global_info_s {
uLong number_entry; /* total number of entries in
the central dir on this disk */
uLong size_comment; /* size of the global comment of the zipfile */
} unz_global_info;
} unz_global_info;
/* unz_file_info contain information about a file in the zipfile */
typedef struct unz_file_info_s
{
/* unz_file_info contain information about a file in the zipfile */
typedef struct unz_file_info_s {
uLong version; /* version made by 2 bytes */
uLong version_needed; /* version needed to extract 2 bytes */
uLong flag; /* general purpose bit flag 2 bytes */
@ -117,23 +116,23 @@ typedef struct unz_file_info_s
uLong external_fa; /* external file attributes 4 bytes */
tm_unz tmu_date;
} unz_file_info;
} unz_file_info;
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
const char* fileName2,
int iCaseSensitivity));
/*
/*
Compare two filename (fileName1,fileName2).
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
or strcasecmp)
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
(like 1 on Unix, 2 on Windows)
*/
*/
extern unzFile ZEXPORT unzOpen OF((const char *path));
/*
extern unzFile ZEXPORT unzOpen OF((const char *path));
/*
Open a Zip file. path contain the full pathname (by example,
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
"zlib/zlib113.zip".
@ -141,89 +140,88 @@ extern unzFile ZEXPORT unzOpen OF((const char *path));
return value is NULL.
Else, the return value is a unzFile Handle, usable with other function
of this unzip package.
*/
*/
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
zlib_filefunc_def* pzlib_filefunc_def));
/*
/*
Open a Zip file, like unzOpen, but provide a set of file low level API
for read/write the zip file (see ioapi.h)
*/
*/
extern int ZEXPORT unzClose OF((unzFile file));
/*
extern int ZEXPORT unzClose OF((unzFile file));
/*
Close a ZipFile opened with unzipOpen.
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
unz_global_info *pglobal_info));
/*
/*
Write info about the ZipFile in the *pglobal_info structure.
No preparation of the structure is needed
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
char *szComment,
uLong uSizeBuf));
/*
/*
Get the global comment string of the ZipFile, in the szComment buffer.
uSizeBuf is the size of the szComment buffer.
return the number of byte copied or an error code <0
*/
*/
/***************************************************************************/
/* Unzip package allow you browse the directory of the zipfile */
/***************************************************************************/
/* Unzip package allow you browse the directory of the zipfile */
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
/*
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
/*
Set the current file of the zipfile to the first file.
return UNZ_OK if there is no problem
*/
*/
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
/*
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
/*
Set the current file of the zipfile to the next file.
return UNZ_OK if there is no problem
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
*/
*/
extern int ZEXPORT unzLocateFile OF((unzFile file,
extern int ZEXPORT unzLocateFile OF((unzFile file,
const char *szFileName,
int iCaseSensitivity));
/*
/*
Try locate the file szFileName in the zipfile.
For the iCaseSensitivity signification, see unzStringFileNameCompare
return value :
UNZ_OK if the file is found. It becomes the current file.
UNZ_END_OF_LIST_OF_FILE if the file is not found
*/
*/
/* ****************************************** */
/* Ryan supplied functions */
/* unz_file_info contain information about a file in the zipfile */
typedef struct unz_file_pos_s
{
/* ****************************************** */
/* Ryan supplied functions */
/* unz_file_info contain information about a file in the zipfile */
typedef struct unz_file_pos_s {
uLong pos_in_zip_directory; /* offset in zip file directory */
uLong num_of_file; /* # of file */
} unz_file_pos;
} unz_file_pos;
extern int ZEXPORT unzGetFilePos(
extern int ZEXPORT unzGetFilePos(
unzFile file,
unz_file_pos* file_pos);
extern int ZEXPORT unzGoToFilePos(
extern int ZEXPORT unzGoToFilePos(
unzFile file,
unz_file_pos* file_pos);
/* ****************************************** */
/* ****************************************** */
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
unz_file_info *pfile_info,
char *szFileName,
uLong fileNameBufferSize,
@ -231,7 +229,7 @@ extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
uLong extraFieldBufferSize,
char *szComment,
uLong commentBufferSize));
/*
/*
Get Info about the current file
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
the current file
@ -242,65 +240,65 @@ extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
This is the Central-header version of the extra field
if szComment!=NULL, the comment string of the file will be copied in szComment
(commentBufferSize is the size of the buffer)
*/
*/
/***************************************************************************/
/* for reading the content of the current zipfile, you can open it, read data
/***************************************************************************/
/* for reading the content of the current zipfile, you can open it, read data
from it, and close it (you can close it before reading all the file)
*/
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
/*
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
/*
Open for reading data the current file in the zipfile.
If there is no error, the return value is UNZ_OK.
*/
*/
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
const char* password));
/*
/*
Open for reading data the current file in the zipfile.
password is a crypting password
If there is no error, the return value is UNZ_OK.
*/
*/
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
int* method,
int* level,
int raw));
/*
/*
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
if raw==1
*method will receive method of compression, *level will receive level of
compression
note : you can set level parameter as NULL (if you did not want known level,
but you CANNOT set method parameter as NULL
*/
*/
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
int* method,
int* level,
int raw,
const char* password));
/*
/*
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
if raw==1
*method will receive method of compression, *level will receive level of
compression
note : you can set level parameter as NULL (if you did not want known level,
but you CANNOT set method parameter as NULL
*/
*/
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
/*
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
/*
Close the file in zip opened with unzOpenCurrentFile
Return UNZ_CRCERROR if all the file was read but the CRC is not good
*/
*/
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
voidp buf,
unsigned len));
/*
/*
Read bytes from the current file (opened by unzOpenCurrentFile)
buf contain buffer where data must be copied
len the size of buf.
@ -309,22 +307,22 @@ extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
return 0 if the end of file was reached
return <0 with error code if there is an error
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
*/
*/
extern z_off_t ZEXPORT unztell OF((unzFile file));
/*
extern z_off_t ZEXPORT unztell OF((unzFile file));
/*
Give the current position in uncompressed data
*/
*/
extern int ZEXPORT unzeof OF((unzFile file));
/*
extern int ZEXPORT unzeof OF((unzFile file));
/*
return 1 if the end of file was reached, 0 elsewhere
*/
*/
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
voidp buf,
unsigned len));
/*
/*
Read extra field from the current file (opened by unzOpenCurrentFile)
This is the local-header version of the extra field (sometimes, there is
more info in the local-header version than in the central-header)
@ -335,15 +333,15 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
buf.
the return value is the number of bytes copied in buf, or (if <0)
the error code
*/
*/
/***************************************************************************/
/***************************************************************************/
/* Get the current file offset */
extern uLong ZEXPORT unzGetOffset (unzFile file);
/* Get the current file offset */
extern uLong ZEXPORT unzGetOffset (unzFile file);
/* Set the current file offset */
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
/* Set the current file offset */
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);

View File

@ -11,8 +11,7 @@
/** Alternate dolloader made by WiiPower modified by dimok **/
bool Load_Dol(void **buffer, int* dollen, char * filepath)
{
bool Load_Dol(void **buffer, int* dollen, char * filepath) {
int ret;
FILE* file;
void* dol_buffer;
@ -28,8 +27,7 @@ bool Load_Dol(void **buffer, int* dollen, char * filepath)
file = fopen(fullpath, "rb");
if(file == NULL)
{
if (file == NULL) {
fclose(file);
SDCard_deInit();
USBDevice_deInit();
@ -42,16 +40,14 @@ bool Load_Dol(void **buffer, int* dollen, char * filepath)
fseek(file, 0, SEEK_SET);
dol_buffer = malloc(filesize);
if (dol_buffer == NULL)
{
if (dol_buffer == NULL) {
fclose(file);
SDCard_deInit();
USBDevice_deInit();
return false;
}
ret = fread( dol_buffer, 1, filesize, file);
if(ret != filesize)
{
if (ret != filesize) {
free(dol_buffer);
fclose(file);
SDCard_deInit();
@ -67,18 +63,15 @@ bool Load_Dol(void **buffer, int* dollen, char * filepath)
return true;
}
bool Remove_001_Protection(void *Address, int Size)
{
bool Remove_001_Protection(void *Address, int Size) {
u8 SearchPattern[16] = { 0x40, 0x82, 0x00, 0x0C, 0x38, 0x60, 0x00, 0x01, 0x48, 0x00, 0x02, 0x44, 0x38, 0x61, 0x00, 0x18 };
u8 PatchData[16] = { 0x40, 0x82, 0x00, 0x04, 0x38, 0x60, 0x00, 0x01, 0x48, 0x00, 0x02, 0x44, 0x38, 0x61, 0x00, 0x18 };
void *Addr = Address;
void *Addr_end = Address+Size;
while(Addr <= Addr_end-sizeof(SearchPattern))
{
if(memcmp(Addr, SearchPattern, sizeof(SearchPattern))==0)
{
while (Addr <= Addr_end-sizeof(SearchPattern)) {
if (memcmp(Addr, SearchPattern, sizeof(SearchPattern))==0) {
memcpy(Addr,PatchData,sizeof(PatchData));
return true;
}
@ -115,7 +108,7 @@ u32 load_dol_image(void *dolstart) {
memmove ((void *) dolfile->text_start[i],dolstart+dolfile->text_pos[i],dolfile->text_size[i]);
}
for(i = 0; i < 11; i++) {
for (i = 0; i < 11; i++) {
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) continue;
VIDEO_WaitVSync();
memmove ((void *) dolfile->data_start[i],dolstart+dolfile->data_pos[i],dolfile->data_size[i]);
@ -133,14 +126,11 @@ u32 load_dol_image(void *dolstart) {
static int i;
static int phase;
u32 load_dol_start(void *dolstart)
{
if (dolstart)
{
u32 load_dol_start(void *dolstart) {
if (dolstart) {
dolfile = (dolheader *)dolstart;
return dolfile->entry_point;
} else
{
} else {
return 0;
}
@ -151,23 +141,17 @@ u32 load_dol_start(void *dolstart)
i = 0;
}
bool load_dol_image_modified(void **offset, u32 *pos, u32 *len)
{
if (phase == 0)
{
if (i == 7)
{
bool load_dol_image_modified(void **offset, u32 *pos, u32 *len) {
if (phase == 0) {
if (i == 7) {
phase = 1;
i = 0;
} else
{
if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100))
{
} else {
if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) {
*offset = 0;
*pos = 0;
*len = 0;
} else
{
} else {
*offset = (void *)dolfile->text_start[i];
*pos = dolfile->text_pos[i];
*len = dolfile->text_size[i];
@ -177,21 +161,17 @@ bool load_dol_image_modified(void **offset, u32 *pos, u32 *len)
}
}
if (phase == 1)
{
if (i == 11)
{
if (phase == 1) {
if (i == 11) {
phase = 2;
return false;
}
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100))
{
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) {
*offset = 0;
*pos = 0;
*len = 0;
} else
{
} else {
*offset = (void *)dolfile->data_start[i];
*pos = dolfile->data_pos[i];
*len = dolfile->data_size[i];
@ -202,15 +182,13 @@ bool load_dol_image_modified(void **offset, u32 *pos, u32 *len)
return false;
}
u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u8 vipatch)
{
u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u8 vipatch) {
int ret;
void *dol_header;
u32 entrypoint;
dol_header = memalign(32, sizeof(dolheader));
if (dol_header == NULL)
{
if (dol_header == NULL) {
return -1;
}
@ -218,8 +196,7 @@ u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u
entrypoint = load_dol_start(dol_header);
if (entrypoint == 0)
{
if (entrypoint == 0) {
free(dol_header);
return -1;
}
@ -228,10 +205,8 @@ u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u
u32 pos;
u32 len;
while (load_dol_image_modified(&offset, &pos, &len))
{
if (len != 0)
{
while (load_dol_image_modified(&offset, &pos, &len)) {
if (len != 0) {
ret = WDVD_Read(offset, len, (doloffset<<2) + pos);
DCFlushRange(offset, len);

View File

@ -2,16 +2,15 @@
#define _ALTERNATEDOL_H_
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
/* not the full path is needed here, the path where the dol is */
/* not the full path is needed here, the path where the dol is */
bool Load_Dol(void **buffer, int* dollen, char * path);
bool Remove_001_Protection(void *Address, int Size);
u32 load_dol_image(void * dolstart);
u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u8 vipatch);
bool Load_Dol(void **buffer, int* dollen, char * path);
bool Remove_001_Protection(void *Address, int Size);
u32 load_dol_image(void * dolstart);
u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u8 vipatch);
#ifdef __cplusplus
}

View File

@ -34,14 +34,12 @@ static u8 *appldr = (u8 *)0x81200000;
static u32 buffer[0x20] ATTRIBUTE_ALIGN(32);
struct SSettings Settings;
static void __noprint(const char *fmt, ...)
{
static void __noprint(const char *fmt, ...) {
}
bool compare_videomodes(GXRModeObj* mode1, GXRModeObj* mode2)
{
bool compare_videomodes(GXRModeObj* mode1, GXRModeObj* mode2) {
if (mode1->viTVMode != mode2->viTVMode || mode1->fbWidth != mode2->fbWidth || mode1->efbHeight != mode2->efbHeight || mode1->xfbHeight != mode2->xfbHeight ||
mode1->viXOrigin != mode2->viXOrigin || mode1->viYOrigin != mode2->viYOrigin || mode1->viWidth != mode2->viWidth || mode1->viHeight != mode2->viHeight ||
mode1->xfbMode != mode2->xfbMode || mode1->field_rendering != mode2->field_rendering || mode1->aa != mode2->aa || mode1->sample_pattern[0][0] != mode2->sample_pattern[0][0] ||
@ -58,18 +56,15 @@ bool compare_videomodes(GXRModeObj* mode1, GXRModeObj* mode2)
mode1->sample_pattern[9][1] != mode2->sample_pattern[9][1] || mode1->sample_pattern[10][1] != mode2->sample_pattern[10][1] ||
mode1->sample_pattern[11][1] != mode2->sample_pattern[11][1] || mode1->vfilter[0] != mode2->vfilter[0] ||
mode1->vfilter[1] != mode2->vfilter[1] || mode1->vfilter[2] != mode2->vfilter[2] || mode1->vfilter[3] != mode2->vfilter[3] || mode1->vfilter[4] != mode2->vfilter[4] ||
mode1->vfilter[5] != mode2->vfilter[5] || mode1->vfilter[6] != mode2->vfilter[6] )
{
mode1->vfilter[5] != mode2->vfilter[5] || mode1->vfilter[6] != mode2->vfilter[6] ) {
return false;
} else
{
} else {
return true;
}
}
void patch_videomode(GXRModeObj* mode1, GXRModeObj* mode2)
{
void patch_videomode(GXRModeObj* mode1, GXRModeObj* mode2) {
mode1->viTVMode = mode2->viTVMode;
mode1->fbWidth = mode2->fbWidth;
mode1->efbHeight = mode2->efbHeight;
@ -187,22 +182,19 @@ GXRModeObj* NTSC2PAL60[]={
&TVNtsc480Prog, &TVEurgb60Hz480Prog,
0,0
};
bool Search_and_patch_Video_Modes(void *Address, u32 Size, GXRModeObj* Table[])
{
bool Search_and_patch_Video_Modes(void *Address, u32 Size, GXRModeObj* Table[]) {
u8 *Addr = (u8 *)Address;
bool found = 0;
u32 i;
while(Size >= sizeof(GXRModeObj))
{
while (Size >= sizeof(GXRModeObj)) {
for(i = 0; Table[i]; i+=2)
{
for (i = 0; Table[i]; i+=2) {
if(compare_videomodes(Table[i], (GXRModeObj*)Addr))
if (compare_videomodes(Table[i], (GXRModeObj*)Addr))
{
found = 1;
@ -222,39 +214,31 @@ bool Search_and_patch_Video_Modes(void *Address, u32 Size, GXRModeObj* Table[])
}
/** Anti 002 fix for IOS 249 rev < 12 thanks to WiiPower **/
void Anti_002_fix(void *Address, int Size)
{
void Anti_002_fix(void *Address, int Size) {
u8 SearchPattern[12] = { 0x2C, 0x00, 0x00, 0x00, 0x48, 0x00, 0x02, 0x14, 0x3C, 0x60, 0x80, 0x00 };
u8 PatchData[12] = { 0x2C, 0x00, 0x00, 0x00, 0x40, 0x82, 0x02, 0x14, 0x3C, 0x60, 0x80, 0x00 };
void *Addr = Address;
void *Addr_end = Address+Size;
while(Addr <= Addr_end-sizeof(SearchPattern))
{
if(memcmp(Addr, SearchPattern, sizeof(SearchPattern))==0)
{
while (Addr <= Addr_end-sizeof(SearchPattern)) {
if (memcmp(Addr, SearchPattern, sizeof(SearchPattern))==0) {
memcpy(Addr,PatchData,sizeof(PatchData));
}
Addr += 4;
}
}
void gamepatches(void * dst, int len, u8 videoSelected, u8 patchcountrystring, u8 vipatch)
{
void gamepatches(void * dst, int len, u8 videoSelected, u8 patchcountrystring, u8 vipatch) {
GXRModeObj** table = NULL;
if (videoSelected == 5) // patch
{
switch(CONF_GetVideo())
{
switch (CONF_GetVideo()) {
case CONF_VIDEO_PAL:
if(CONF_GetEuRGB60() > 0)
{
if (CONF_GetEuRGB60() > 0) {
table = NTSC2PAL60;
}
else
{
} else {
table = NTSC2PAL;
}
break;
@ -285,17 +269,16 @@ void gamepatches(void * dst, int len, u8 videoSelected, u8 patchcountrystring, u
langpatcher(dst,len);
/*Thanks to WiiPower*/
if(patchcountrystring == 1)
if (patchcountrystring == 1)
PatchCountryStrings(dst, len);
//if(Settings.anti002fix == on)
if(fix002 == 2)
if (fix002 == 2)
Anti_002_fix(dst, len);
}
s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8 patchcountrystring, u8 error002fix, u8 alternatedol, u32 alternatedoloffset)
{
s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8 patchcountrystring, u8 error002fix, u8 alternatedol, u32 alternatedoloffset) {
app_entry appldr_entry;
app_init appldr_init;
app_main appldr_main;
@ -326,13 +309,12 @@ s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8
/* Initialize apploader */
appldr_init(__noprint);
if(error002fix!=0){
if (error002fix!=0) {
/* ERROR 002 fix (thanks to WiiPower for sharing this)*/
*(u32 *)0x80003140 = *(u32 *)0x80003188;
}
if (cheat)
{
if (cheat) {
/*HOOKS STUFF - FISHEARS*/
memset((void*)0x80001800,0,kenobiwii_size);
memcpy((void*)0x80001800,kenobiwii,kenobiwii_size);
@ -362,12 +344,12 @@ s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8
*entry = appldr_final();
/** Load alternate dol if set **/
if(alternatedol == 1) {
if (alternatedol == 1) {
void *dolbuffer;
int dollen;
bool dolloaded = Load_Dol(&dolbuffer, &dollen, Settings.dolpath);
if(dolloaded) {
if (dolloaded) {
Remove_001_Protection(dolbuffer, dollen);
DCFlushRange(dolbuffer, dollen);
@ -379,13 +361,13 @@ s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8
/* Set entry point from apploader */
*entry = (entry_point) load_dol_image(dolbuffer);
}
} else if(alternatedol == 2) {
} else if (alternatedol == 2) {
FST_ENTRY *fst = (FST_ENTRY *)*(u32 *)0x80000038;
*entry = (entry_point) Load_Dol_from_disc(fst[alternatedoloffset].fileoffset, videoSelected, patchcountrystring, vipatch);
if(*entry == 0)
if (*entry == 0)
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}

View File

@ -2,16 +2,15 @@
#define _APPLOADER_H_
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
/* Entry point */
typedef void (*entry_point)(void);
/* Entry point */
typedef void (*entry_point)(void);
/* Prototypes */
s32 Apploader_Run(entry_point *, u8, u8, u8, u8, u8, u8, u32);
void gamepatches(void * dst, int len, u8 videoSelected, u8 patchcountrystring, u8 vipatch);
/* Prototypes */
s32 Apploader_Run(entry_point *, u8, u8, u8, u8, u8, u8, u32);
void gamepatches(void * dst, int len, u8 videoSelected, u8 patchcountrystring, u8 vipatch);
#ifdef __cplusplus
}

View File

@ -22,8 +22,7 @@ static u8 *diskid = (u8 *)0x80000000;
static char gameid[8];
void __Disc_SetLowMem(void)
{
void __Disc_SetLowMem(void) {
*(vu32 *)0x80000020 = 0x0D15EA5E; // Standard Boot Code
*(vu32 *)0x80000024 = 0x00000001; // Version
@ -45,7 +44,9 @@ void __Disc_SetLowMem(void)
(strcmp(tempTxt,"R3XP6V")==0))/*&&
(IOS_GetVersion()==249)&&
((IOS_GetRevision()==10)||(IOS_GetRevision()==13)) I left out the ios check to see if works with other ios versions.*/
{*(vu32*)0x80003184 = 0x80000000;} // Game ID Address
{
*(vu32*)0x80003184 = 0x80000000; // Game ID Address
}
/* Copy disc ID */
memcpy((void *)0x80003180, (void *)0x80000000, 4);
@ -54,8 +55,7 @@ void __Disc_SetLowMem(void)
DCFlushRange((void *)0x80000000, 0x3F00);
}
void __Disc_SetVMode(u8 videoselected)
{
void __Disc_SetVMode(u8 videoselected) {
GXRModeObj *vmode = NULL;
u32 progressive, tvmode, vmode_reg = 0;
@ -83,7 +83,7 @@ void __Disc_SetVMode(u8 videoselected)
case 0:
/* Select video mode */
switch(diskid[3]) {
switch (diskid[3]) {
/* PAL */
case 'D':
case 'F':
@ -124,7 +124,7 @@ void __Disc_SetVMode(u8 videoselected)
vmode_reg = (vmode->viTVMode) >> 2;
break;
case 4:
// vmode = VIDEO_GetPreferredMode(NULL);
// vmode = VIDEO_GetPreferredMode(NULL);
break;
}
@ -146,8 +146,7 @@ void __Disc_SetVMode(u8 videoselected)
}
}
void __Disc_SetTime(void)
{
void __Disc_SetTime(void) {
/* Extern */
extern void settime(u64);
@ -155,8 +154,7 @@ void __Disc_SetTime(void)
settime(secs_to_ticks(time(NULL) - 946684800));
}
s32 __Disc_FindPartition(u64 *outbuf)
{
s32 __Disc_FindPartition(u64 *outbuf) {
u64 offset = 0, table_offset = 0;
u32 cnt, nb_partitions;
@ -181,7 +179,7 @@ s32 __Disc_FindPartition(u64 *outbuf)
u32 type = buffer[cnt * 2 + 1];
/* Game partition */
if(!type)
if (!type)
offset = buffer[cnt * 2] << 2;
}
@ -196,14 +194,12 @@ s32 __Disc_FindPartition(u64 *outbuf)
}
s32 Disc_Init(void)
{
s32 Disc_Init(void) {
/* Init DVD subsystem */
return WDVD_Init();
}
s32 Disc_Open(void)
{
s32 Disc_Open(void) {
s32 ret;
/* Reset drive */
@ -215,8 +211,7 @@ s32 Disc_Open(void)
return WDVD_ReadDiskId(diskid);
}
s32 Disc_Wait(void)
{
s32 Disc_Wait(void) {
u32 cover = 0;
s32 ret;
@ -231,20 +226,17 @@ s32 Disc_Wait(void)
return 0;
}
s32 Disc_SetUSB(u8 *id)
{
s32 Disc_SetUSB(u8 *id) {
/* Set USB mode */
return WDVD_SetUSBMode(id);
}
s32 Disc_ReadHeader(void *outbuf)
{
s32 Disc_ReadHeader(void *outbuf) {
/* Read disc header */
return WDVD_UnencryptedRead(outbuf, sizeof(struct discHdr), 0);
}
s32 Disc_IsWii(void)
{
s32 Disc_IsWii(void) {
struct discHdr *header = (struct discHdr *)buffer;
s32 ret;
@ -261,8 +253,7 @@ s32 Disc_IsWii(void)
return 0;
}
s32 Disc_BootPartition(u64 offset, u8 videoselected, u8 cheat, u8 vipatch, u8 patchcountrystring, u8 error002fix, u8 alternatedol, u32 alternatedoloffset)
{
s32 Disc_BootPartition(u64 offset, u8 videoselected, u8 cheat, u8 vipatch, u8 patchcountrystring, u8 error002fix, u8 alternatedol, u32 alternatedoloffset) {
entry_point p_entry;
s32 ret;
@ -308,8 +299,7 @@ s32 Disc_BootPartition(u64 offset, u8 videoselected, u8 cheat, u8 vipatch, u8 pa
return 0;
}
s32 Disc_WiiBoot(u8 videoselected, u8 cheat, u8 vipatch, u8 patchcountrystring, u8 error002fix, u8 alternatedol, u32 alternatedoloffset)
{
s32 Disc_WiiBoot(u8 videoselected, u8 cheat, u8 vipatch, u8 patchcountrystring, u8 error002fix, u8 alternatedol, u32 alternatedoloffset) {
u64 offset;
s32 ret;
@ -322,16 +312,14 @@ s32 Disc_WiiBoot(u8 videoselected, u8 cheat, u8 vipatch, u8 patchcountrystring,
return Disc_BootPartition(offset, videoselected, cheat, vipatch, patchcountrystring, error002fix, alternatedol, alternatedoloffset);
}
void PatchCountryStrings(void *Address, int Size)
{
void PatchCountryStrings(void *Address, int Size) {
u8 SearchPattern[4] = { 0x00, 0x00, 0x00, 0x00 };
u8 PatchData[4] = { 0x00, 0x00, 0x00, 0x00 };
u8 *Addr = (u8*)Address;
int wiiregion = CONF_GetRegion();
switch (wiiregion)
{
switch (wiiregion) {
case CONF_REGION_JP:
SearchPattern[0] = 0x00;
SearchPattern[1] = 0x4A; // J
@ -359,8 +347,7 @@ void PatchCountryStrings(void *Address, int Size)
SearchPattern[2] = 0x53; // S
}
switch (diskid[3])
{
switch (diskid[3]) {
case 'J':
PatchData[1] = 0x4A; // J
PatchData[2] = 0x50; // P
@ -381,10 +368,8 @@ void PatchCountryStrings(void *Address, int Size)
PatchData[2] = 0x53; // S
}
while (Size >= 4)
{
if (Addr[0] == SearchPattern[0] && Addr[1] == SearchPattern[1] && Addr[2] == SearchPattern[2] && Addr[3] == SearchPattern[3])
{
while (Size >= 4) {
if (Addr[0] == SearchPattern[0] && Addr[1] == SearchPattern[1] && Addr[2] == SearchPattern[2] && Addr[3] == SearchPattern[3]) {
//*Addr = PatchData[0];
Addr += 1;
*Addr = PatchData[1];
@ -394,8 +379,7 @@ void PatchCountryStrings(void *Address, int Size)
//*Addr = PatchData[3];
Addr += 1;
Size -= 4;
} else
{
} else {
Addr += 4;
Size -= 4;
}

View File

@ -2,12 +2,10 @@
#define _DISC_H_
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
/* Disc header structure */
struct discHdr
{
/* Disc header structure */
struct discHdr {
/* Game ID */
u8 id[6];
@ -36,21 +34,21 @@ struct discHdr
/* Padding */
u8 unused3[30];
} ATTRIBUTE_PACKED;
} ATTRIBUTE_PACKED;
/* Prototypes */
s32 Disc_Init(void);
s32 Disc_Open(void);
s32 Disc_Wait(void);
void __Disc_SetLowMem(void);
s32 Disc_SetUSB(u8 *);
s32 Disc_ReadHeader(void *);
s32 Disc_IsWii(void);
s32 Disc_BootPartition(u64, u8, u8, u8, u8, u8, u8, u32);
s32 Disc_WiiBoot(u8, u8, u8, u8, u8, u8, u32);
s32 __Disc_FindPartition(u64 *outbuf);
void PatchCountryStrings(void *Address, int Size);
s32 __Disc_FindPartition(u64 *outbuf);
/* Prototypes */
s32 Disc_Init(void);
s32 Disc_Open(void);
s32 Disc_Wait(void);
void __Disc_SetLowMem(void);
s32 Disc_SetUSB(u8 *);
s32 Disc_ReadHeader(void *);
s32 Disc_IsWii(void);
s32 Disc_BootPartition(u64, u8, u8, u8, u8, u8, u8, u32);
s32 Disc_WiiBoot(u8, u8, u8, u8, u8, u8, u32);
s32 __Disc_FindPartition(u64 *outbuf);
void PatchCountryStrings(void *Address, int Size);
s32 __Disc_FindPartition(u64 *outbuf);
#ifdef __cplusplus
}

View File

@ -3,44 +3,35 @@
#include "fstfile.h"
char *fstfiles(FST_ENTRY *fst, u32 index)
{
char *fstfiles(FST_ENTRY *fst, u32 index) {
u32 count = fst[0].filelen;
u32 stringoffset;
if (index < count)
{
if (index < count) {
stringoffset = *(u32 *)&(fst[index]) % (256*256*256);
return (char *)((u32)fst + count*12 + stringoffset);
} else
{
} else {
return NULL;
}
}
char *fstfilename(u32 index)
{
char *fstfilename(u32 index) {
FST_ENTRY *fst = (FST_ENTRY *)*(u32 *)0x80000038;
u32 count = fst[0].filelen;
u32 stringoffset;
if (index < count)
{
if (index < count) {
stringoffset = *(u32 *)&(fst[index]) % (256*256*256);
return (char *)(*(u32 *)0x80000038 + count*12 + stringoffset);
} else
{
} else {
return NULL;
}
}
u32 fstfileoffset(u32 index)
{
u32 fstfileoffset(u32 index) {
FST_ENTRY *fst = (FST_ENTRY *)*(u32 *)0x80000038;
u32 count = fst[0].filelen;
if (index < count)
{
if (index < count) {
return fst[index].fileoffset;
} else
{
} else {
return 0;
}
}

View File

@ -2,20 +2,19 @@
#define _FSTFILE_H_
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
typedef struct {
typedef struct {
u8 filetype;
char name_offset[3];
u32 fileoffset;
u32 filelen;
} __attribute__((packed)) FST_ENTRY;
} __attribute__((packed)) FST_ENTRY;
char *fstfiles(FST_ENTRY *fst, u32 index);
char *fstfilename(u32 index);
u32 fstfileoffset(u32 index);
char *fstfiles(FST_ENTRY *fst, u32 index);
char *fstfilename(u32 index);
u32 fstfileoffset(u32 index);
#ifdef __cplusplus
}

View File

@ -29,8 +29,7 @@ s32 __Menu_EntryCmp(const void *a, const void *b)
}
s32 __Menu_EntryCmpCount(const void *a, const void *b)
{
s32 __Menu_EntryCmpCount(const void *a, const void *b) {
s32 ret;
struct discHdr *hdr1 = (struct discHdr *)a;
@ -58,8 +57,7 @@ s32 __Menu_EntryCmpCount(const void *a, const void *b)
* Get Gamelist
***************************************************************************/
int __Menu_GetEntries(int t)
{
int __Menu_GetEntries(int t) {
struct discHdr *buffer = NULL;
struct discHdr *buffer2 = NULL;
struct discHdr *header = NULL;
@ -86,7 +84,7 @@ int __Menu_GetEntries(int t)
/* Get header list */
ret = WBFS_GetHeaders(buffer, cnt, sizeof(struct discHdr));
if (ret < 0) {
if(buffer) free(buffer);
if (buffer) free(buffer);
return ret;
}
@ -94,8 +92,7 @@ int __Menu_GetEntries(int t)
if (Settings.fave && t==0) {
u32 cnt2 = 0;
for (u32 i = 0; i < cnt; i++)
{
for (u32 i = 0; i < cnt; i++) {
header = &buffer[i];
u8 favorite = 0;
struct Game_NUM* game_num = CFG_get_game_num(header->id);
@ -104,8 +101,7 @@ int __Menu_GetEntries(int t)
}
if (favorite==1) {
buffer2 = (discHdr *) realloc(buffer2, (cnt2+1) * sizeof(struct discHdr));
if (!buffer2)
{
if (!buffer2) {
free(buffer);
return -1;
}
@ -127,13 +123,11 @@ int __Menu_GetEntries(int t)
if (Settings.parentalcontrol && !Settings.godmode && t==0) {
u32 cnt2 = 0;
for (u32 i = 0; i < cnt; i++)
{
for (u32 i = 0; i < cnt; i++) {
header = &buffer[i];
if (get_block(header) < Settings.parentalcontrol) {
buffer2 = (discHdr *) realloc(buffer2, (cnt2+1) * sizeof(struct discHdr));
if (!buffer2)
{
if (!buffer2) {
free(buffer);
return -1;
}
@ -154,8 +148,7 @@ int __Menu_GetEntries(int t)
if (Settings.sort==pcount) {
qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpCount);
}
else {
} else {
qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp);
}

View File

@ -16,8 +16,7 @@ typedef struct {
} ATTRIBUTE_PACKED partitionTable;
s32 Partition_GetEntries(partitionEntry *outbuf, u32 *outval)
{
s32 Partition_GetEntries(partitionEntry *outbuf, u32 *outval) {
static partitionTable table ATTRIBUTE_ALIGN(32);
u32 cnt, sector_size;

View File

@ -2,12 +2,11 @@
#define _PARTITION_H_
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
/* 'partition entry' structure */
typedef struct {
/* 'partition entry' structure */
typedef struct {
/* Boot indicator */
u8 boot;
@ -25,13 +24,13 @@ typedef struct {
/* Partition size */
u32 size;
} ATTRIBUTE_PACKED partitionEntry;
} ATTRIBUTE_PACKED partitionEntry;
/* Constants */
/* Constants */
#define MAX_PARTITIONS 4
/* Prototypes */
s32 Partition_GetEntries(partitionEntry *, u32 *);
/* Prototypes */
s32 Partition_GetEntries(partitionEntry *, u32 *);
#ifdef __cplusplus
}

View File

@ -20,8 +20,7 @@ static s32 hid = -1, fd = -1;
static u32 sector_size = SDHC_SECTOR_SIZE;
bool SDHC_Init(void)
{
bool SDHC_Init(void) {
s32 ret;
/* Already open */
@ -57,8 +56,7 @@ err:
return false;
}
bool SDHC_Close(void)
{
bool SDHC_Close(void) {
/* Close SDHC device */
if (fd > 0) {
IOS_Close(fd);
@ -68,8 +66,7 @@ bool SDHC_Close(void)
return true;
}
bool SDHC_IsInserted(void)
{
bool SDHC_IsInserted(void) {
s32 ret;
/* Check if SD card is inserted */
@ -78,8 +75,7 @@ bool SDHC_IsInserted(void)
return (!ret) ? true : false;
}
bool SDHC_ReadSectors(u32 sector, u32 count, void *buffer)
{
bool SDHC_ReadSectors(u32 sector, u32 count, void *buffer) {
void *buf = (void *)buffer;
u32 len = (sector_size * count);
@ -109,8 +105,7 @@ bool SDHC_ReadSectors(u32 sector, u32 count, void *buffer)
return (!ret) ? true : false;
}
bool SDHC_WriteSectors(u32 sector, u32 count, void *buffer)
{
bool SDHC_WriteSectors(u32 sector, u32 count, void *buffer) {
void *buf = (void *)buffer;
u32 len = (sector_size * count);
@ -141,8 +136,7 @@ bool SDHC_WriteSectors(u32 sector, u32 count, void *buffer)
return (!ret) ? true : false;
}
bool SDHC_ClearStatus(void)
{
bool SDHC_ClearStatus(void) {
return true;
}

View File

@ -5,15 +5,14 @@
#define SDHC_SECTOR_SIZE 0x200
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
/* Prototypes */
bool SDHC_Init(void);
bool SDHC_Close(void);
bool SDHC_ReadSectors(u32, u32, void *);
bool SDHC_WriteSectors(u32, u32, void *);
/* Prototypes */
bool SDHC_Init(void);
bool SDHC_Close(void);
bool SDHC_ReadSectors(u32, u32, void *);
bool SDHC_WriteSectors(u32, u32, void *);
#ifdef __cplusplus
}

View File

@ -51,16 +51,14 @@ static s32 hid = -1, fd = -1;
static u32 sector_size;
inline s32 __USBStorage_isMEM2Buffer(const void *buffer)
{
inline s32 __USBStorage_isMEM2Buffer(const void *buffer) {
u32 high_addr = ((u32)buffer) >> 24;
return (high_addr == 0x90) || (high_addr == 0xD0);
}
s32 USBStorage_GetCapacity(u32 *_sector_size)
{
s32 USBStorage_GetCapacity(u32 *_sector_size) {
if (fd > 0) {
s32 ret;
@ -75,8 +73,7 @@ s32 USBStorage_GetCapacity(u32 *_sector_size)
return IPC_ENOENT;
}
s32 USBStorage_Init(void)
{
s32 USBStorage_Init(void) {
s32 ret;
/* Already open */
@ -97,7 +94,7 @@ s32 USBStorage_Init(void)
/* Initialize USB storage */
ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_INIT, ":");
if(ret<0) goto err;
if (ret<0) goto err;
/* Get device capacity */
ret = USBStorage_GetCapacity(NULL);
@ -117,8 +114,7 @@ err:
}
/** Hermes **/
s32 USBStorage_Watchdog(u32 on_off)
{
s32 USBStorage_Watchdog(u32 on_off) {
if (fd >= 0) {
s32 ret;
@ -130,8 +126,7 @@ s32 USBStorage_Watchdog(u32 on_off)
return IPC_ENOENT;
}
s32 USBStorage_Umount(void)
{
s32 USBStorage_Umount(void) {
if (fd >= 0) {
s32 ret;
ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_UNMOUNT, ":");
@ -141,8 +136,7 @@ s32 USBStorage_Umount(void)
return IPC_ENOENT;
}
void USBStorage_Deinit(void)
{
void USBStorage_Deinit(void) {
/* Close USB device */
if (fd > 0) {
IOS_Close(fd);
@ -150,8 +144,7 @@ void USBStorage_Deinit(void)
}
}
s32 USBStorage_ReadSectors(u32 sector, u32 numSectors, void *buffer)
{
s32 USBStorage_ReadSectors(u32 sector, u32 numSectors, void *buffer) {
void *buf = (void *)buffer;
u32 len = (sector_size * numSectors);
@ -181,8 +174,7 @@ s32 USBStorage_ReadSectors(u32 sector, u32 numSectors, void *buffer)
return ret;
}
s32 USBStorage_WriteSectors(u32 sector, u32 numSectors, const void *buffer)
{
s32 USBStorage_WriteSectors(u32 sector, u32 numSectors, const void *buffer) {
void *buf = (void *)buffer;
u32 len = (sector_size * numSectors);
@ -217,22 +209,18 @@ s32 USBStorage_WriteSectors(u32 sector, u32 numSectors, const void *buffer)
#define DEVICE_TYPE_WII_UMS (('W'<<24)|('U'<<16)|('M'<<8)|'S')
bool umsio_Startup()
{
bool umsio_Startup() {
return USBStorage_Init() == 0;
}
bool umsio_IsInserted()
{
bool umsio_IsInserted() {
return true; // allways true
}
bool umsio_ReadSectors(sec_t sector, sec_t numSectors, u8 *buffer)
{
bool umsio_ReadSectors(sec_t sector, sec_t numSectors, u8 *buffer) {
u32 cnt = 0;
s32 ret;
/* Do reads */
while (cnt < numSectors)
{
while (cnt < numSectors) {
u32 sectors = (numSectors - cnt);
/* Read sectors is too big */
@ -251,14 +239,12 @@ bool umsio_ReadSectors(sec_t sector, sec_t numSectors, u8 *buffer)
return true;
}
bool umsio_WriteSectors(sec_t sector, sec_t numSectors, const u8* buffer)
{
bool umsio_WriteSectors(sec_t sector, sec_t numSectors, const u8* buffer) {
u32 cnt = 0;
s32 ret;
/* Do writes */
while (cnt < numSectors)
{
while (cnt < numSectors) {
u32 sectors = (numSectors - cnt);
/* Write sectors is too big */
@ -276,21 +262,18 @@ bool umsio_WriteSectors(sec_t sector, sec_t numSectors, const u8* buffer)
return true;
}
bool umsio_ClearStatus(void)
{
bool umsio_ClearStatus(void) {
return true;
}
bool umsio_Shutdown()
{
bool umsio_Shutdown() {
USBStorage_Deinit();
return true;
}
const DISC_INTERFACE __io_wiiums =
{
DEVICE_TYPE_WII_UMS,
FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_WII_USB,
(FN_MEDIUM_STARTUP)&umsio_Startup,
const DISC_INTERFACE __io_wiiums = {
DEVICE_TYPE_WII_UMS,
FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_WII_USB,
(FN_MEDIUM_STARTUP)&umsio_Startup,
(FN_MEDIUM_ISINSERTED)&umsio_IsInserted,
(FN_MEDIUM_READSECTORS)&umsio_ReadSectors,
(FN_MEDIUM_WRITESECTORS)&umsio_WriteSectors,

View File

@ -2,17 +2,16 @@
#define _USBSTORAGE_H_
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
/* Prototypes */
s32 USBStorage_GetCapacity(u32 *);
s32 USBStorage_Init(void);
void USBStorage_Deinit(void);
s32 USBStorage_Watchdog(u32 on_off);
s32 USBStorage_ReadSectors(u32, u32, void *);
s32 USBStorage_WriteSectors(u32, u32, const void *);
extern const DISC_INTERFACE __io_wiiums;
/* Prototypes */
s32 USBStorage_GetCapacity(u32 *);
s32 USBStorage_Init(void);
void USBStorage_Deinit(void);
s32 USBStorage_Watchdog(u32 on_off);
s32 USBStorage_ReadSectors(u32, u32, void *);
s32 USBStorage_WriteSectors(u32, u32, const void *);
extern const DISC_INTERFACE __io_wiiums;
#ifdef __cplusplus
}
#endif

View File

@ -2,7 +2,6 @@
#include <ogcsys.h>
u32 swap32(u32 x)
{
u32 swap32(u32 x) {
return (x >> 24) | ((x << 8) & 0x00FF0000UL) | ((x >> 8) & 0x0000FF00UL) | (x << 24);
}

View File

@ -26,25 +26,21 @@ static s32 done = -1, total = -1;
/* Variables */
static u32 nb_sectors, sector_size;
static void WBFS_Spinner(s32 x, s32 max)
{
static void WBFS_Spinner(s32 x, s32 max) {
done = x;
total = max;
}
void GetProgressValue(s32 * d, s32 * m)
{
void GetProgressValue(s32 * d, s32 * m) {
*d = done;
*m = total;
}
wbfs_t *GetHddInfo(void)
{
wbfs_t *GetHddInfo(void) {
return hdd;
}
s32 __WBFS_ReadDVD(void *fp, u32 lba, u32 len, void *iobuf)
{
s32 __WBFS_ReadDVD(void *fp, u32 lba, u32 len, void *iobuf) {
void *buffer = NULL;
u64 offset;
@ -92,8 +88,7 @@ out:
return ret;
}
s32 __WBFS_ReadUSB(void *fp, u32 lba, u32 count, void *iobuf)
{
s32 __WBFS_ReadUSB(void *fp, u32 lba, u32 count, void *iobuf) {
u32 cnt = 0;
s32 ret;
@ -118,8 +113,7 @@ s32 __WBFS_ReadUSB(void *fp, u32 lba, u32 count, void *iobuf)
return 0;
}
s32 __WBFS_WriteUSB(void *fp, u32 lba, u32 count, void *iobuf)
{
s32 __WBFS_WriteUSB(void *fp, u32 lba, u32 count, void *iobuf) {
u32 cnt = 0;
s32 ret;
@ -144,8 +138,7 @@ s32 __WBFS_WriteUSB(void *fp, u32 lba, u32 count, void *iobuf)
return 0;
}
s32 __WBFS_ReadSDHC(void *fp, u32 lba, u32 count, void *iobuf)
{
s32 __WBFS_ReadSDHC(void *fp, u32 lba, u32 count, void *iobuf) {
u32 cnt = 0;
s32 ret;
@ -170,8 +163,7 @@ s32 __WBFS_ReadSDHC(void *fp, u32 lba, u32 count, void *iobuf)
return 0;
}
s32 __WBFS_WriteSDHC(void *fp, u32 lba, u32 count, void *iobuf)
{
s32 __WBFS_WriteSDHC(void *fp, u32 lba, u32 count, void *iobuf) {
u32 cnt = 0;
s32 ret;
@ -196,8 +188,7 @@ s32 __WBFS_WriteSDHC(void *fp, u32 lba, u32 count, void *iobuf)
return 0;
}
s32 WBFS_Init(u32 device)
{
s32 WBFS_Init(u32 device) {
s32 ret;
switch (device) {
@ -213,8 +204,7 @@ s32 WBFS_Init(u32 device)
nb_sectors = USBStorage_GetCapacity(&sector_size);
if (!nb_sectors)
return -1;
}
else
} else
return ret;
break;
case WBFS_DEVICE_SDHC:
@ -229,8 +219,7 @@ s32 WBFS_Init(u32 device)
/* Device info */
nb_sectors = 0;
sector_size = SDHC_SECTOR_SIZE;
}
else
} else
return -1;
break;
}
@ -314,8 +303,7 @@ out:
}
*/
s32 WBFS_Open(void)
{
s32 WBFS_Open(void) {
/* Close hard disk */
if (hdd)
wbfs_close(hdd);
@ -338,8 +326,7 @@ s32 WBFS_Close(void)
return 0;
}
s32 WBFS_Format(u32 lba, u32 size)
{
s32 WBFS_Format(u32 lba, u32 size) {
wbfs_t *partition = NULL;
/* Reset partition */
@ -353,8 +340,7 @@ s32 WBFS_Format(u32 lba, u32 size)
return 0;
}
s32 WBFS_GetCount(u32 *count)
{
s32 WBFS_GetCount(u32 *count) {
/* No device open */
if (!hdd)
return -1;
@ -365,8 +351,7 @@ s32 WBFS_GetCount(u32 *count)
return 0;
}
s32 WBFS_GetHeaders(void *outbuf, u32 cnt, u32 len)
{
s32 WBFS_GetHeaders(void *outbuf, u32 cnt, u32 len) {
u32 idx, size;
s32 ret;
@ -386,8 +371,7 @@ s32 WBFS_GetHeaders(void *outbuf, u32 cnt, u32 len)
return 0;
}
s32 WBFS_CheckGame(u8 *discid)
{
s32 WBFS_CheckGame(u8 *discid) {
wbfs_disc_t *disc = NULL;
/* Try to open game disc */
@ -402,8 +386,7 @@ s32 WBFS_CheckGame(u8 *discid)
return 0;
}
s32 WBFS_AddGame(void)
{
s32 WBFS_AddGame(void) {
s32 ret;
/* No device open */
@ -418,8 +401,7 @@ s32 WBFS_AddGame(void)
return 0;
}
s32 WBFS_RemoveGame(u8 *discid)
{
s32 WBFS_RemoveGame(u8 *discid) {
s32 ret;
/* No device open */
@ -434,8 +416,7 @@ s32 WBFS_RemoveGame(u8 *discid)
return 0;
}
s32 WBFS_GameSize(u8 *discid, f32 *size)
{
s32 WBFS_GameSize(u8 *discid, f32 *size) {
wbfs_disc_t *disc = NULL;
u32 sectors;
@ -461,8 +442,7 @@ s32 WBFS_GameSize(u8 *discid, f32 *size)
return 0;
}
s32 WBFS_DiskSpace(f32 *used, f32 *free)
{
s32 WBFS_DiskSpace(f32 *used, f32 *free) {
f32 ssize;
u32 cnt;
@ -483,8 +463,7 @@ s32 WBFS_DiskSpace(f32 *used, f32 *free)
return 0;
}
s32 WBFS_RenameGame(u8 *discid, const void *newname)
{
s32 WBFS_RenameGame(u8 *discid, const void *newname) {
s32 ret;
/* No USB device open */
@ -497,8 +476,7 @@ s32 WBFS_RenameGame(u8 *discid, const void *newname)
return 0;
}
f32 WBFS_EstimeGameSize(void)
{
f32 WBFS_EstimeGameSize(void) {
return wbfs_estimate_disc(hdd, __WBFS_ReadDVD, NULL, ONLY_GAME_PARTITION);

View File

@ -2,41 +2,40 @@
#define _WBFS_H_
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
#include "libwbfs/libwbfs.h"
/* Device list */
enum {
/* Device list */
enum {
WBFS_DEVICE_USB = 1, /* USB device */
WBFS_DEVICE_SDHC /* SDHC device */
};
};
/* Macros */
/* Macros */
#define WBFS_MIN_DEVICE 1
#define WBFS_MAX_DEVICE 2
/* Prototypes */
void GetProgressValue(s32 * d, s32 * m);
s32 WBFS_Init(u32);
s32 WBFS_Open(void);
s32 WBFS_Close(void);
s32 WBFS_Format(u32, u32);
s32 WBFS_GetCount(u32 *);
s32 WBFS_GetHeaders(void *, u32, u32);
s32 __WBFS_ReadDVD(void *fp, u32 lba, u32 len, void *iobuf);
wbfs_t *GetHddInfo(void);
s32 WBFS_CheckGame(u8 *);
s32 WBFS_AddGame(void);
s32 WBFS_RemoveGame(u8 *);
s32 WBFS_GameSize(u8 *, f32 *);
s32 WBFS_DiskSpace(f32 *, f32 *);
s32 WBFS_RenameGame(u8 *, const void *);
f32 WBFS_EstimeGameSize(void);
/* Prototypes */
void GetProgressValue(s32 * d, s32 * m);
s32 WBFS_Init(u32);
s32 WBFS_Open(void);
s32 WBFS_Close(void);
s32 WBFS_Format(u32, u32);
s32 WBFS_GetCount(u32 *);
s32 WBFS_GetHeaders(void *, u32, u32);
s32 __WBFS_ReadDVD(void *fp, u32 lba, u32 len, void *iobuf);
wbfs_t *GetHddInfo(void);
s32 WBFS_CheckGame(u8 *);
s32 WBFS_AddGame(void);
s32 WBFS_RemoveGame(u8 *);
s32 WBFS_GameSize(u8 *, f32 *);
s32 WBFS_DiskSpace(f32 *, f32 *);
s32 WBFS_RenameGame(u8 *, const void *);
f32 WBFS_EstimeGameSize(void);
s32 __WBFS_ReadUSB(void *fp, u32 lba, u32 count, void *iobuf);
s32 __WBFS_WriteUSB(void *fp, u32 lba, u32 count, void *iobuf);
s32 __WBFS_ReadUSB(void *fp, u32 lba, u32 count, void *iobuf);
s32 __WBFS_WriteUSB(void *fp, u32 lba, u32 count, void *iobuf);
#ifdef __cplusplus

View File

@ -30,8 +30,7 @@ static u32 outbuf[8] ATTRIBUTE_ALIGN(32);
static const char di_fs[] ATTRIBUTE_ALIGN(32) = "/dev/di";
static s32 di_fd = -1;
s32 WDVD_Init(void)
{
s32 WDVD_Init(void) {
/* Open "/dev/di" */
if (di_fd < 0) {
di_fd = IOS_Open(di_fs, 0);
@ -42,8 +41,7 @@ s32 WDVD_Init(void)
return 0;
}
s32 WDVD_Close(void)
{
s32 WDVD_Close(void) {
/* Close "/dev/di" */
if (di_fd >= 0) {
IOS_Close(di_fd);
@ -53,14 +51,12 @@ s32 WDVD_Close(void)
return 0;
}
s32 WDVD_GetHandle(void)
{
s32 WDVD_GetHandle(void) {
/* Return di handle */
return di_fd;
}
s32 WDVD_Reset(void)
{
s32 WDVD_Reset(void) {
s32 ret;
memset(inbuf, 0, sizeof(inbuf));
@ -76,8 +72,7 @@ s32 WDVD_Reset(void)
return (ret == 1) ? 0 : -ret;
}
s32 WDVD_ReadDiskId(void *id)
{
s32 WDVD_ReadDiskId(void *id) {
s32 ret;
memset(inbuf, 0, sizeof(inbuf));
@ -97,8 +92,7 @@ s32 WDVD_ReadDiskId(void *id)
return -ret;
}
s32 WDVD_Seek(u64 offset)
{
s32 WDVD_Seek(u64 offset) {
s32 ret;
memset(inbuf, 0, sizeof(inbuf));
@ -108,8 +102,7 @@ s32 WDVD_Seek(u64 offset)
inbuf[1] = (u32)(offset >> 2);
ret = IOS_Ioctl(di_fd, IOCTL_DI_SEEK, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf));
if(ret!=1)
{
if (ret!=1) {
// Try old cIOS 222
/* Drive seek */
inbuf[0] = DI_SETOFFSETBASE << 24;
@ -122,8 +115,7 @@ s32 WDVD_Seek(u64 offset)
}
s32 WDVD_Offset(u64 offset)
{
s32 WDVD_Offset(u64 offset) {
u32 *off = (u32 *)((void *)&offset);
s32 ret;
@ -141,8 +133,7 @@ s32 WDVD_Offset(u64 offset)
return (ret == 1) ? 0 : -ret;
}
s32 WDVD_StopLaser(void)
{
s32 WDVD_StopLaser(void) {
s32 ret;
memset(inbuf, 0, sizeof(inbuf));
@ -157,8 +148,7 @@ s32 WDVD_StopLaser(void)
return (ret == 1) ? 0 : -ret;
}
s32 WDVD_StopMotor(void)
{
s32 WDVD_StopMotor(void) {
s32 ret;
memset(inbuf, 0, sizeof(inbuf));
@ -173,8 +163,7 @@ s32 WDVD_StopMotor(void)
return (ret == 1) ? 0 : -ret;
}
s32 WDVD_OpenPartition(u64 offset)
{
s32 WDVD_OpenPartition(u64 offset) {
u8 *vector = NULL;
u32 *buffer = NULL;
@ -213,8 +202,7 @@ s32 WDVD_OpenPartition(u64 offset)
return (ret == 1) ? 0 : -ret;
}
s32 WDVD_ClosePartition(void)
{
s32 WDVD_ClosePartition(void) {
s32 ret;
memset(inbuf, 0, sizeof(inbuf));
@ -229,8 +217,7 @@ s32 WDVD_ClosePartition(void)
return (ret == 1) ? 0 : -ret;
}
s32 WDVD_UnencryptedRead(void *buf, u32 len, u64 offset)
{
s32 WDVD_UnencryptedRead(void *buf, u32 len, u64 offset) {
s32 ret;
memset(inbuf, 0, sizeof(inbuf));
@ -247,8 +234,7 @@ s32 WDVD_UnencryptedRead(void *buf, u32 len, u64 offset)
return (ret == 1) ? 0 : -ret;
}
s32 WDVD_Read(void *buf, u32 len, u64 offset)
{
s32 WDVD_Read(void *buf, u32 len, u64 offset) {
s32 ret;
memset(inbuf, 0, sizeof(inbuf));
@ -265,8 +251,7 @@ s32 WDVD_Read(void *buf, u32 len, u64 offset)
return (ret == 1) ? 0 : -ret;
}
s32 WDVD_WaitForDisc(void)
{
s32 WDVD_WaitForDisc(void) {
s32 ret;
memset(inbuf, 0, sizeof(inbuf));
@ -281,8 +266,7 @@ s32 WDVD_WaitForDisc(void)
return (ret == 1) ? 0 : -ret;
}
s32 WDVD_GetCoverStatus(u32 *status)
{
s32 WDVD_GetCoverStatus(u32 *status) {
s32 ret;
memset(inbuf, 0, sizeof(inbuf));
@ -304,8 +288,7 @@ s32 WDVD_GetCoverStatus(u32 *status)
return -ret;
}
s32 WDVD_DisableReset(u8 val)
{
s32 WDVD_DisableReset(u8 val) {
s32 ret;
memset(inbuf, 0, sizeof(inbuf));
@ -322,8 +305,7 @@ s32 WDVD_DisableReset(u8 val)
}
/** Hermes **/
s32 WDVD_SetUSBMode(u8 *id)
{
s32 WDVD_SetUSBMode(u8 *id) {
s32 ret;
memset(inbuf, 0, sizeof(inbuf));
@ -339,7 +321,7 @@ s32 WDVD_SetUSBMode(u8 *id)
}
ret = IOS_Ioctl(di_fd, IOCTL_DI_SETUSBMODE, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf));
if(ret!=1) {
if (ret!=1) {
// Try old cIOS 222
/* Set USB mode */
inbuf[0] = DI_SETWBFSMODE << 24;

View File

@ -2,28 +2,27 @@
#define _WDVD_H_
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
/* Prototypes */
s32 WDVD_Init(void);
s32 WDVD_Close(void);
s32 WDVD_GetHandle(void);
s32 WDVD_Reset(void);
s32 WDVD_ReadDiskId(void *);
s32 WDVD_Seek(u64);
s32 WDVD_Offset(u64);
s32 WDVD_StopLaser(void);
s32 WDVD_StopMotor(void);
s32 WDVD_OpenPartition(u64);
s32 WDVD_ClosePartition(void);
s32 WDVD_UnencryptedRead(void *, u32, u64);
s32 WDVD_Read(void *, u32, u64);
s32 WDVD_WaitForDisc(void);
s32 WDVD_GetCoverStatus(u32 *);
s32 WDVD_DisableReset(u8);
s32 WDVD_SetUSBMode(u8 *);
/* Prototypes */
s32 WDVD_Init(void);
s32 WDVD_Close(void);
s32 WDVD_GetHandle(void);
s32 WDVD_Reset(void);
s32 WDVD_ReadDiskId(void *);
s32 WDVD_Seek(u64);
s32 WDVD_Offset(u64);
s32 WDVD_StopLaser(void);
s32 WDVD_StopMotor(void);
s32 WDVD_OpenPartition(u64);
s32 WDVD_ClosePartition(void);
s32 WDVD_UnencryptedRead(void *, u32, u64);
s32 WDVD_Read(void *, u32, u64);
s32 WDVD_WaitForDisc(void);
s32 WDVD_GetCoverStatus(u32 *);
s32 WDVD_DisableReset(u8);
s32 WDVD_SetUSBMode(u8 *);
#ifdef __cplusplus
}

View File

@ -35,19 +35,17 @@ u32 frameCount = 0;
* called by postRetraceCallback in InitGCVideo - scans gcpad and wpad
***************************************************************************/
static void
UpdatePadsCB ()
{
UpdatePadsCB () {
frameCount++;
#ifdef HW_RVL
#ifdef HW_RVL
WPAD_ScanPads();
#endif
#endif
PAD_ScanPads();
for(int i=3; i >= 0; i--)
{
#ifdef HW_RVL
for (int i=3; i >= 0; i--) {
#ifdef HW_RVL
memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData));
#endif
#endif
userInput[i].chan = i;
userInput[i].pad.btns_d = PAD_ButtonsDown(i);
@ -68,8 +66,7 @@ UpdatePadsCB ()
* Initialises GX and sets it up for use
***************************************************************************/
static void
StartGX ()
{
StartGX () {
GXColor background = { 0, 0, 0, 0xff };
/*** Clear out FIFO area ***/
@ -89,8 +86,7 @@ StartGX ()
* Reset the video/rendering mode for the menu
****************************************************************************/
void
ResetVideo_Menu()
{
ResetVideo_Menu() {
Mtx44 p;
f32 yscale;
u32 xfbHeight;
@ -162,14 +158,12 @@ ResetVideo_Menu()
***************************************************************************/
void
InitVideo ()
{
InitVideo () {
VIDEO_Init();
vmode = VIDEO_GetPreferredMode(NULL); // get default video mode
// widescreen fix
if(CFG.widescreen)
{
if (CFG.widescreen) {
vmode->viWidth = VI_MAX_WIDTH_PAL-12;
vmode->viXOrigin = ((VI_MAX_WIDTH_PAL - vmode->viWidth) / 2) + 2;
}
@ -210,8 +204,7 @@ InitVideo ()
*
* Stops GX (when exiting)
***************************************************************************/
void StopGX()
{
void StopGX() {
GX_AbortFrame();
GX_Flush();
@ -224,8 +217,7 @@ void StopGX()
*
* Renders everything current sent to GX, and flushes video
***************************************************************************/
void Menu_Render()
{
void Menu_Render() {
GX_DrawDone ();
whichfb ^= 1; // flip framebuffer
@ -243,9 +235,8 @@ void Menu_Render()
* Draws the specified image on screen using GX
***************************************************************************/
void Menu_DrawImg(f32 xpos, f32 ypos, f32 zpos, f32 width, f32 height, u8 data[],
f32 degrees, f32 scaleX, f32 scaleY, u8 alpha, int XX1, int YY1,int XX2, int YY2,int XX3, int YY3,int XX4, int YY4)
{
if(data == NULL)
f32 degrees, f32 scaleX, f32 scaleY, u8 alpha, int XX1, int YY1,int XX2, int YY2,int XX3, int YY3,int XX4, int YY4) {
if (data == NULL)
return;
GXTexObj texObj;
@ -262,7 +253,9 @@ void Menu_DrawImg(f32 xpos, f32 ypos, f32 zpos, f32 width, f32 height, u8 data[]
height*=.5;
guMtxIdentity (m1);
guMtxScaleApply(m1,m1,scaleX,scaleY,1.0);
guVector axis = (guVector) {0 , 0, 1 };
guVector axis = (guVector) {
0 , 0, 1
};
guMtxRotAxisDeg (m2, &axis, degrees);
// guMtxConcat(m2,m1,m);
guMtxConcat(m1,m2,m);
@ -304,8 +297,7 @@ void Menu_DrawImg(f32 xpos, f32 ypos, f32 zpos, f32 width, f32 height, u8 data[]
*
* Draws a rectangle at the specified coordinates using GX
***************************************************************************/
void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled)
{
void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled) {
u8 fmt;
long n;
int i;
@ -313,20 +305,16 @@ void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 f
f32 y2 = y+height;
guVector v[] = {{x,y,0.0f}, {x2,y,0.0f}, {x2,y2,0.0f}, {x,y2,0.0f}, {x,y,0.0f}};
if(!filled)
{
if (!filled) {
fmt = GX_LINESTRIP;
n = 5;
}
else
{
} else {
fmt = GX_TRIANGLEFAN;
n = 4;
}
GX_Begin(fmt, GX_VTXFMT0, n);
for(i=0; i<n; i++)
{
for (i=0; i<n; i++) {
GX_Position3f32(v[i].x, v[i].y, v[i].z);
GX_Color4u8(color.r, color.g, color.b, color.a);
}
@ -334,9 +322,8 @@ void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 f
}
void Menu_DrawDiskCover(f32 xpos, f32 ypos, f32 zpos, u16 width, u16 height, u16 distance,u8 data[],
f32 deg_alpha, f32 deg_beta, f32 scaleX, f32 scaleY, u8 alpha, bool shadow)
{
if(data == NULL)
f32 deg_alpha, f32 deg_beta, f32 scaleX, f32 scaleY, u8 alpha, bool shadow) {
if (data == NULL)
return;
GXTexObj texObj;
@ -362,16 +349,20 @@ void Menu_DrawDiskCover(f32 xpos, f32 ypos, f32 zpos, u16 width, u16 height, u16
guMtxIdentity (m1);
guMtxScaleApply(m1,m1,scaleX,scaleY,1.0);
guVector axis2 = (guVector) {0 , 1, 0 };
guVector axis2 = (guVector) {
0 , 1, 0
};
guMtxRotAxisDeg (m2, &axis2, deg_beta);
guVector axis = (guVector) {0 , 0, 1 };
guVector axis = (guVector) {
0 , 0, 1
};
guMtxRotAxisDeg (m3, &axis, deg_alpha);
// guMtxConcat(m2,m1,m);
guMtxConcat(m3,m4,m3); // move distance then rotate z-axis
guMtxConcat(m2,m3,m2); // rotate y-axis
guMtxConcat(m1,m2,m); // scale
if(shadow)
if (shadow)
guMtxTransApply(m,m, xpos+width+0.5+s_offset_x,ypos+height+0.5+s_offset_y,zpos-s_offset_z);
else
guMtxTransApply(m,m, xpos+width+0.5,ypos+height+0.5,zpos);
@ -381,8 +372,7 @@ void Menu_DrawDiskCover(f32 xpos, f32 ypos, f32 zpos, u16 width, u16 height, u16
guMtxConcat (GXmodelView2D, m, mv);
GX_LoadPosMtxImm (mv, GX_PNMTX0);
if(shadow)
{
if (shadow) {
GX_Begin(GX_QUADS, GX_VTXFMT0,4);
GX_Position3f32(-width, -height, 0);
GX_Color4u8(0,0,0,alpha);
@ -399,9 +389,7 @@ void Menu_DrawDiskCover(f32 xpos, f32 ypos, f32 zpos, u16 width, u16 height, u16
GX_Position3f32(-width, height, 0);
GX_Color4u8(0,0,0,alpha);
GX_TexCoord2f32(0, 1);
}
else
{
} else {
GX_Begin(GX_QUADS, GX_VTXFMT0,4);
GX_Position3f32(-width, -height, 0);
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
@ -428,8 +416,7 @@ void Menu_DrawDiskCover(f32 xpos, f32 ypos, f32 zpos, u16 width, u16 height, u16
}
void Menu_DrawTPLImg(f32 xpos, f32 ypos, f32 zpos, f32 width, f32 height, GXTexObj *texObj,
f32 degrees, f32 scaleX, f32 scaleY, u8 alpha, int XX1, int YY1,int XX2, int YY2,int XX3, int YY3,int XX4, int YY4)
{
f32 degrees, f32 scaleX, f32 scaleY, u8 alpha, int XX1, int YY1,int XX2, int YY2,int XX3, int YY3,int XX4, int YY4) {
GX_LoadTexObj(texObj, GX_TEXMAP0);
GX_InvalidateTexAll();
@ -441,7 +428,9 @@ void Menu_DrawTPLImg(f32 xpos, f32 ypos, f32 zpos, f32 width, f32 height, GXTexO
height*=.5;
guMtxIdentity (m1);
guMtxScaleApply(m1,m1,scaleX,scaleY,1.0);
guVector axis = (guVector) {0 , 0, 1 };
guVector axis = (guVector) {
0 , 0, 1
};
guMtxRotAxisDeg (m2, &axis, degrees);
guMtxConcat(m1,m2,m);

View File

@ -61,8 +61,7 @@ s32 ISFS_ReadFileToArray (const char *filepath, u8 *filearray, u32 max_size, u32
*file_size = 0;
ret = ISFS_Open(filepath, ISFS_OPEN_READ);
if (ret <= 0)
{
if (ret <= 0) {
//printf("Error! ISFS_Open (ret = %d)\n", ret);
return -1;
}
@ -70,43 +69,37 @@ s32 ISFS_ReadFileToArray (const char *filepath, u8 *filearray, u32 max_size, u32
fd = ret;
ret = ISFS_GetFileStats(fd, &filestats);
if (ret < 0)
{
if (ret < 0) {
//printf("Error! ISFS_GetFileStats (ret = %d)\n", ret);
return -1;
}
*file_size = filestats.file_length;
if (*file_size > max_size)
{
if (*file_size > max_size) {
//printf("File is too large! Size: %u Max: %u", *file_size, max_size);
return -1;
}
ret = ISFS_Read(fd, filearray, *file_size);
*file_size = ret;
if (ret < 0)
{
if (ret < 0) {
//printf("Error! ISFS_Read (ret = %d)\n", ret);
return -1;
}
else if (ret != filestats.file_length)
{
} else if (ret != filestats.file_length) {
//printf("Error! ISFS_Read Only read: %d\n", ret);
return -1;
}
ret = ISFS_Close(fd);
if (ret < 0)
{
if (ret < 0) {
//printf("Error! ISFS_Close (ret = %d)\n", ret);
return -1;
}
return 0;
}
void Make_SUID(void){
void Make_SUID(void) {
signed_blob *s_tmd, *s_tik;
tmd *p_tmd;
tik *p_tik;

View File

@ -50,7 +50,7 @@ void zero_sig(signed_blob *sig) {
void brute_tmd(tmd *p_tmd) {
u16 fill;
for(fill=0; fill<65535; fill++) {
for (fill=0; fill<65535; fill++) {
p_tmd->fill3=fill;
sha1 hash;
// debug_printf("SHA1(%p, %x, %p)\n", p_tmd, TMD_SIZE(p_tmd), hash);
@ -67,7 +67,7 @@ void brute_tmd(tmd *p_tmd) {
void brute_tik(tik *p_tik) {
u16 fill;
for(fill=0; fill<65535; fill++) {
for (fill=0; fill<65535; fill++) {
p_tik->padding=fill;
sha1 hash;
// debug_printf("SHA1(%p, %x, %p)\n", p_tmd, TMD_SIZE(p_tmd), hash);

View File

@ -21,16 +21,14 @@ void spinner(void);
// Basic I/O.
static inline u32 read32(u32 addr)
{
static inline u32 read32(u32 addr) {
u32 x;
asm volatile("lwz %0,0(%1) ; sync" : "=r"(x) : "b"(0xc0000000 | addr));
asm volatile("lwz %0,0(%1) ; sync" : "=r"(x) : "b"(0xc0000000 | addr));
return x;
}
static inline void write32(u32 addr, u32 x)
{
asm("stw %0,0(%1) ; eieio" : : "r"(x), "b"(0xc0000000 | addr));
static inline void write32(u32 addr, u32 x) {
asm("stw %0,0(%1) ; eieio" : : "r"(x), "b"(0xc0000000 | addr));
}
// USB Gecko.
@ -44,8 +42,7 @@ extern const char version[];
// Debug: blink the tray led.
static inline void blink(void)
{
static inline void blink(void) {
write32(0x0d8000c0, read32(0x0d8000c0) ^ 0x20);
}

Some files were not shown because too many files have changed in this diff Show More