diff --git a/gui.pnproj b/gui.pnproj index 16b13d12..9f98d919 100644 --- a/gui.pnproj +++ b/gui.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/gui.pnps b/gui.pnps index be6e1712..91ed5adf 100644 --- a/gui.pnps +++ b/gui.pnps @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/source/FreeTypeGX.cpp b/source/FreeTypeGX.cpp index 396fa1c7..d4f774cb 100644 --- a/source/FreeTypeGX.cpp +++ b/source/FreeTypeGX.cpp @@ -23,26 +23,26 @@ #include #include "FreeTypeGX.h" #include "settings/cfg.h" - -#include "main.h" + +#include "main.h" /*! \struct ftgxCharData_ * * Font face character glyph relevant data structure. */ typedef struct ftgxCharData_ { - int16_t renderOffsetX; /**< Texture X axis bearing offset. */ - uint16_t glyphAdvanceX; /**< Character glyph X coordinate advance in pixels. */ - uint16_t glyphIndex; /**< Charachter glyph index in the font face. */ + int16_t renderOffsetX; /**< Texture X axis bearing offset. */ + uint16_t glyphAdvanceX; /**< Character glyph X coordinate advance in pixels. */ + uint16_t glyphIndex; /**< Charachter glyph index in the font face. */ - uint16_t textureWidth; /**< Texture width in pixels/bytes. */ - uint16_t textureHeight; /**< Texture glyph height in pixels/bytes. */ + uint16_t textureWidth; /**< Texture width in pixels/bytes. */ + uint16_t textureHeight; /**< Texture glyph height in pixels/bytes. */ - int16_t renderOffsetY; /**< Texture Y axis bearing offset. */ - int16_t renderOffsetMax; /**< Texture Y axis bearing maximum value. */ - int16_t renderOffsetMin; /**< Texture Y axis bearing minimum value. */ + int16_t renderOffsetY; /**< Texture Y axis bearing offset. */ + int16_t renderOffsetMax; /**< Texture Y axis bearing maximum value. */ + int16_t renderOffsetMin; /**< Texture Y axis bearing minimum value. */ - uint32_t* glyphDataTexture; /**< Glyph texture bitmap data buffer. */ + uint32_t* glyphDataTexture; /**< Glyph texture bitmap data buffer. */ } ftgxCharData; /*! \struct ftgxDataOffset_ @@ -50,10 +50,10 @@ typedef struct ftgxCharData_ { * Offset structure which hold both a maximum and minimum value. */ typedef struct ftgxDataOffset_ { - int16_t ascender; /**< Maximum data offset. */ - int16_t descender; /**< Minimum data offset. */ - int16_t max; /**< Maximum data offset. */ - int16_t min; /**< Minimum data offset. */ + int16_t ascender; /**< Maximum data offset. */ + int16_t descender; /**< Minimum data offset. */ + int16_t max; /**< Maximum data offset. */ + int16_t min; /**< Minimum data offset. */ } ftgxDataOffset; @@ -64,19 +64,19 @@ typedef struct ftgxDataOffset_ { * @param vertexIndex Optional vertex format index (GX_VTXFMT*) of the glyph textures as defined by the libogc gx.h header file. If not specified default value is GX_VTXFMT1. */ FreeTypeGX::FreeTypeGX(uint8_t textureFormat, uint8_t vertexIndex) : ftFace(NULL), ftFace_fromFile(NULL) { - FT_Init_FreeType(&this->ftLibrary); + FT_Init_FreeType(&this->ftLibrary); - this->textureFormat = textureFormat; - this->setVertexFormat(vertexIndex); - this->setCompatibilityMode(FTGX_COMPATIBILITY_NONE); + this->textureFormat = textureFormat; + this->setVertexFormat(vertexIndex); + this->setCompatibilityMode(FTGX_COMPATIBILITY_NONE); } /** * Default destructor for the FreeTypeGX class. */ FreeTypeGX::~FreeTypeGX() { - this->unloadFont(); - FT_Done_FreeType(this->ftLibrary); + this->unloadFont(); + FT_Done_FreeType(this->ftLibrary); } /** @@ -89,22 +89,22 @@ FreeTypeGX::~FreeTypeGX() { * @return Wide character representation of supplied character string. */ wchar_t* FreeTypeGX::charToWideChar(char* strChar) { - wchar_t *strWChar; - strWChar = new wchar_t[strlen(strChar) + 1]; + wchar_t *strWChar; + strWChar = new wchar_t[strlen(strChar) + 1]; - // UTF-8 - int bt; - bt = mbstowcs(strWChar, strChar, strlen(strChar)); - if(bt > 0) { - strWChar[bt] = (wchar_t)'\0'; - return strWChar; - } + // UTF-8 + int bt; + bt = mbstowcs(strWChar, strChar, strlen(strChar)); + if (bt > 0) { + strWChar[bt] = (wchar_t)'\0'; + return strWChar; + } - char *tempSrc = strChar; - wchar_t *tempDest = strWChar; - while((*tempDest++ = *tempSrc++)); + char *tempSrc = strChar; + wchar_t *tempDest = strWChar; + while ((*tempDest++ = *tempSrc++)); - return strWChar; + return strWChar; } /** @@ -112,7 +112,7 @@ wchar_t* FreeTypeGX::charToWideChar(char* strChar) { * \overload */ wchar_t* FreeTypeGX::charToWideChar(const char* strChar) { - return FreeTypeGX::charToWideChar((char*) strChar); + return FreeTypeGX::charToWideChar((char*) strChar); } /** @@ -125,11 +125,11 @@ wchar_t* FreeTypeGX::charToWideChar(const char* strChar) { * @param vertexIndex Vertex format index (GX_VTXFMT*) of the glyph textures as defined by the libogc gx.h header file. */ void FreeTypeGX::setVertexFormat(uint8_t vertexIndex) { - this->vertexIndex = vertexIndex; + this->vertexIndex = vertexIndex; - GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_POS, GX_POS_XY, GX_S16, 0); - GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); - GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); + GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_POS, GX_POS_XY, GX_S16, 0); + GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); + GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); } /** @@ -143,7 +143,7 @@ void FreeTypeGX::setVertexFormat(uint8_t vertexIndex) { * @param compatibilityMode Compatibility descritor (FTGX_COMPATIBILITY_*) as defined in FreeTypeGX.h */ void FreeTypeGX::setCompatibilityMode(uint32_t compatibilityMode) { - this->compatibilityMode = compatibilityMode; + this->compatibilityMode = compatibilityMode; } /** @@ -153,44 +153,44 @@ void FreeTypeGX::setCompatibilityMode(uint32_t compatibilityMode) { * in setCompatibilityMode. */ void FreeTypeGX::setDefaultMode() { - if(this->compatibilityMode) { - switch(this->compatibilityMode & 0x00FF) { - case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE: - GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE); - break; - case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_DECAL: - GX_SetTevOp(GX_TEVSTAGE0, GX_DECAL); - break; - case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_BLEND: - GX_SetTevOp(GX_TEVSTAGE0, GX_BLEND); - break; - case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_REPLACE: - GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE); - break; - case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR: - GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); - break; - default: - break; - } + if (this->compatibilityMode) { + switch (this->compatibilityMode & 0x00FF) { + case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE: + GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE); + break; + case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_DECAL: + GX_SetTevOp(GX_TEVSTAGE0, GX_DECAL); + break; + case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_BLEND: + GX_SetTevOp(GX_TEVSTAGE0, GX_BLEND); + break; + case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_REPLACE: + GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE); + break; + case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR: + GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); + break; + default: + break; + } - switch(this->compatibilityMode & 0xFF00) { - case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE: - GX_SetVtxDesc(GX_VA_TEX0, GX_NONE); - break; - case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_DIRECT: - GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); - break; - case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX8: - GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX8); - break; - case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX16: - GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX16); - break; - default: - break; - } - } + switch (this->compatibilityMode & 0xFF00) { + case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE: + GX_SetVtxDesc(GX_VA_TEX0, GX_NONE); + break; + case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_DIRECT: + GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); + break; + case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX8: + GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX8); + break; + case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX16: + GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX16); + break; + default: + break; + } + } } /** @@ -205,41 +205,40 @@ void FreeTypeGX::setDefaultMode() { * @param cacheAll Optional flag to specify if all font characters should be cached when the class object is created. If specified as false the characters only become cached the first time they are used. If not specified default value is false. */ uint16_t FreeTypeGX::loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) { - this->unloadFont(); - this->ftPointSize = pointSize; - struct stat st; + this->unloadFont(); + this->ftPointSize = pointSize; + struct stat st; - if(fontPath && (stat(fontPath, &st)==0)) - { - FILE *fontfile = fopen(fontPath, "rb"); - if (fontfile) { - FT_Long ftFace_fromFile_Size; - - fseek(fontfile, 0, SEEK_END); - ftFace_fromFile_Size = ftell(fontfile); - fseek(fontfile, 0, SEEK_SET); - ftFace_fromFile = (uint8_t*)malloc(ftFace_fromFile_Size); - if (ftFace_fromFile != NULL) { - fread(ftFace_fromFile, 1, ftFace_fromFile_Size, fontfile); - FT_New_Memory_Face(this->ftLibrary, ftFace_fromFile, ftFace_fromFile_Size, 0, &this->ftFace); - } - fclose(fontfile); - } - } - if (ftFace_fromFile == NULL) - FT_New_Memory_Face(this->ftLibrary, (FT_Byte *)fontBuffer, bufferSize, 0, &this->ftFace); + if (fontPath && (stat(fontPath, &st)==0)) { + FILE *fontfile = fopen(fontPath, "rb"); + if (fontfile) { + FT_Long ftFace_fromFile_Size; - if(this->ftPointSize > 0) - FT_Set_Pixel_Sizes(this->ftFace, 0, this->ftPointSize); + fseek(fontfile, 0, SEEK_END); + ftFace_fromFile_Size = ftell(fontfile); + fseek(fontfile, 0, SEEK_SET); + ftFace_fromFile = (uint8_t*)malloc(ftFace_fromFile_Size); + if (ftFace_fromFile != NULL) { + fread(ftFace_fromFile, 1, ftFace_fromFile_Size, fontfile); + FT_New_Memory_Face(this->ftLibrary, ftFace_fromFile, ftFace_fromFile_Size, 0, &this->ftFace); + } + fclose(fontfile); + } + } + if (ftFace_fromFile == NULL) + FT_New_Memory_Face(this->ftLibrary, (FT_Byte *)fontBuffer, bufferSize, 0, &this->ftFace); - this->ftSlot = this->ftFace->glyph; - this->ftKerningEnabled = FT_HAS_KERNING(this->ftFace); + if (this->ftPointSize > 0) + FT_Set_Pixel_Sizes(this->ftFace, 0, this->ftPointSize); - if (cacheAll) { - return this->cacheGlyphDataComplete(); - } + this->ftSlot = this->ftFace->glyph; + this->ftKerningEnabled = FT_HAS_KERNING(this->ftFace); - return 0; + if (cacheAll) { + return this->cacheGlyphDataComplete(); + } + + return 0; } /** @@ -247,47 +246,44 @@ uint16_t FreeTypeGX::loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long buffe * \overload */ uint16_t FreeTypeGX::loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) { - return this->loadFont((char*)fontPath, (uint8_t *)fontBuffer, bufferSize, pointSize, cacheAll); + return this->loadFont((char*)fontPath, (uint8_t *)fontBuffer, bufferSize, pointSize, cacheAll); } void FreeTypeGX::unloadFont() { - clearGlyphData(); - - if(this->ftFace) - { - FT_Done_Face(this->ftFace); - this->ftFace = NULL; - } - if(this->ftFace_fromFile) - { - free(this->ftFace_fromFile); - this->ftFace_fromFile = NULL; - } + clearGlyphData(); + + if (this->ftFace) { + FT_Done_Face(this->ftFace); + this->ftFace = NULL; + } + if (this->ftFace_fromFile) { + free(this->ftFace_fromFile); + this->ftFace_fromFile = NULL; + } } /** * Clears all loaded font glyph data. * * 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) - return; +void FreeTypeGX::clearGlyphData() { + if (this->fontData.size() == 0) + return; - GX_DrawDone(); - GX_Flush(); + GX_DrawDone(); + GX_Flush(); - for( std::map::iterator i = this->fontData.begin(); i != this->fontData.end(); i++) { - free(i->second.glyphDataTexture); - } + for ( std::map::iterator i = this->fontData.begin(); i != this->fontData.end(); i++) { + free(i->second.glyphDataTexture); + } - this->fontData.clear(); + this->fontData.clear(); } void FreeTypeGX::changeSize(FT_UInt vPointSize, FT_UInt hPointSize/*=0*/) { - this->clearGlyphData(); - this->ftPointSize = vPointSize; - FT_Set_Pixel_Sizes(this->ftFace, hPointSize, this->ftPointSize); + this->clearGlyphData(); + this->ftPointSize = vPointSize; + FT_Set_Pixel_Sizes(this->ftFace, hPointSize, this->ftPointSize); } /** @@ -300,24 +296,24 @@ void FreeTypeGX::changeSize(FT_UInt vPointSize, FT_UInt hPointSize/*=0*/) { * @return The correctly adjusted texture width. */ uint16_t FreeTypeGX::adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat) { - uint16_t alignment; + uint16_t alignment; - 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 */ - alignment = 8; - break; + 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 */ + alignment = 8; + break; - case GX_TF_IA8: /* 4x4 Tiles - 8-bit Intensity, 8-bit Alpha */ - case GX_TF_RGB565: /* 4x4 Tiles - RGB565 Format */ - case GX_TF_RGB5A3: /* 4x4 Tiles - RGB5A3 Format */ - case GX_TF_RGBA8: /* 4x4 Tiles - RGBA8 Dual Cache Line Format */ - default: - alignment = 4; - break; - } - return textureWidth % alignment == 0 ? textureWidth : alignment + textureWidth - (textureWidth % alignment); + case GX_TF_IA8: /* 4x4 Tiles - 8-bit Intensity, 8-bit Alpha */ + case GX_TF_RGB565: /* 4x4 Tiles - RGB565 Format */ + case GX_TF_RGB5A3: /* 4x4 Tiles - RGB5A3 Format */ + case GX_TF_RGBA8: /* 4x4 Tiles - RGBA8 Dual Cache Line Format */ + default: + alignment = 4; + break; + } + return textureWidth % alignment == 0 ? textureWidth : alignment + textureWidth - (textureWidth % alignment); } @@ -331,24 +327,24 @@ uint16_t FreeTypeGX::adjustTextureWidth(uint16_t textureWidth, uint8_t textureFo * @return The correctly adjusted texture height. */ uint16_t FreeTypeGX::adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat) { - uint16_t alignment; + uint16_t alignment; - switch(textureFormat) { - case GX_TF_I4: /* 8x8 Tiles - 4-bit Intensity */ - alignment = 8; - break; + switch (textureFormat) { + case GX_TF_I4: /* 8x8 Tiles - 4-bit Intensity */ + alignment = 8; + break; - case GX_TF_I8: /* 8x4 Tiles - 8-bit Intensity */ - case GX_TF_IA4: /* 8x4 Tiles - 4-bit Intensity, , 4-bit Alpha */ - case GX_TF_IA8: /* 4x4 Tiles - 8-bit Intensity, 8-bit Alpha */ - case GX_TF_RGB565: /* 4x4 Tiles - RGB565 Format */ - case GX_TF_RGB5A3: /* 4x4 Tiles - RGB5A3 Format */ - case GX_TF_RGBA8: /* 4x4 Tiles - RGBA8 Dual Cache Line Format */ - default: - alignment = 4; - break; - } - return textureHeight % alignment == 0 ? textureHeight : alignment + textureHeight - (textureHeight % alignment); + case GX_TF_I8: /* 8x4 Tiles - 8-bit Intensity */ + case GX_TF_IA4: /* 8x4 Tiles - 4-bit Intensity, , 4-bit Alpha */ + case GX_TF_IA8: /* 4x4 Tiles - 8-bit Intensity, 8-bit Alpha */ + case GX_TF_RGB565: /* 4x4 Tiles - RGB565 Format */ + case GX_TF_RGB5A3: /* 4x4 Tiles - RGB5A3 Format */ + case GX_TF_RGBA8: /* 4x4 Tiles - RGBA8 Dual Cache Line Format */ + default: + alignment = 4; + break; + } + return textureHeight % alignment == 0 ? textureHeight : alignment + textureHeight - (textureHeight % alignment); } @@ -362,37 +358,37 @@ uint16_t FreeTypeGX::adjustTextureHeight(uint16_t textureHeight, uint8_t texture * @return A pointer to the allocated font structure. */ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode) { - FT_UInt gIndex; - uint16_t textureWidth = 0, textureHeight = 0; + FT_UInt gIndex; + uint16_t textureWidth = 0, textureHeight = 0; - gIndex = FT_Get_Char_Index( this->ftFace, charCode ); - if (!FT_Load_Glyph(this->ftFace, gIndex, FT_LOAD_DEFAULT )) { - FT_Render_Glyph( this->ftSlot, FT_RENDER_MODE_NORMAL ); + gIndex = FT_Get_Char_Index( this->ftFace, 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) { - FT_Bitmap *glyphBitmap = &this->ftSlot->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); + textureWidth = adjustTextureWidth(glyphBitmap->width, this->textureFormat); + textureHeight = adjustTextureHeight(glyphBitmap->rows, this->textureFormat); - this->fontData[charCode] = (ftgxCharData){ - this->ftSlot->bitmap_left, - this->ftSlot->advance.x >> 6, - gIndex, - textureWidth, - textureHeight, - this->ftSlot->bitmap_top, - this->ftSlot->bitmap_top, - glyphBitmap->rows - this->ftSlot->bitmap_top, - NULL - }; - this->loadGlyphData(glyphBitmap, &this->fontData[charCode]); + this->fontData[charCode] = (ftgxCharData) { + this->ftSlot->bitmap_left, + this->ftSlot->advance.x >> 6, + gIndex, + textureWidth, + textureHeight, + this->ftSlot->bitmap_top, + this->ftSlot->bitmap_top, + glyphBitmap->rows - this->ftSlot->bitmap_top, + NULL + }; + this->loadGlyphData(glyphBitmap, &this->fontData[charCode]); - return &this->fontData[charCode]; - } - } + return &this->fontData[charCode]; + } + } - return NULL; + return NULL; } /** @@ -402,19 +398,19 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode) { * Each bitmap and relevant information is loaded into its own quickly addressible structure within an instance-specific map. */ uint16_t FreeTypeGX::cacheGlyphDataComplete() { - uint16_t i = 0; - FT_UInt gIndex; - FT_ULong charCode = FT_Get_First_Char( this->ftFace, &gIndex ); - while ( gIndex != 0 ) { + uint16_t i = 0; + FT_UInt gIndex; + FT_ULong charCode = FT_Get_First_Char( this->ftFace, &gIndex ); + while ( gIndex != 0 ) { - if(this->cacheGlyphData(charCode) != NULL) { - i++; - } + if (this->cacheGlyphData(charCode) != NULL) { + i++; + } - charCode = FT_Get_Next_Char( this->ftFace, charCode, &gIndex ); - } + charCode = FT_Get_Next_Char( this->ftFace, charCode, &gIndex ); + } - return i; + return i; } /** @@ -428,42 +424,42 @@ uint16_t FreeTypeGX::cacheGlyphDataComplete() { */ void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) { - uint32_t *glyphData = (uint32_t *)memalign(32, charData->textureWidth * charData->textureHeight * 4); - memset(glyphData, 0x00, charData->textureWidth * charData->textureHeight * 4); + uint32_t *glyphData = (uint32_t *)memalign(32, charData->textureWidth * charData->textureHeight * 4); + memset(glyphData, 0x00, charData->textureWidth * charData->textureHeight * 4); - for (uint16_t imagePosY = 0; imagePosY < bmp->rows; imagePosY++) { - for (uint16_t imagePosX = 0; imagePosX < bmp->width; imagePosX++) { - uint32_t pixel = (uint32_t) bmp->buffer[imagePosY * bmp->width + imagePosX]; - glyphData[imagePosY * charData->textureWidth + imagePosX] = 0x00000000 | (pixel << 24) | (pixel << 16) | (pixel << 8) | pixel; - } - } + for (uint16_t imagePosY = 0; imagePosY < bmp->rows; imagePosY++) { + for (uint16_t imagePosX = 0; imagePosX < bmp->width; imagePosX++) { + uint32_t pixel = (uint32_t) bmp->buffer[imagePosY * bmp->width + imagePosX]; + glyphData[imagePosY * charData->textureWidth + imagePosX] = 0x00000000 | (pixel << 24) | (pixel << 16) | (pixel << 8) | pixel; + } + } - switch(this->textureFormat) { - case GX_TF_I4: - charData->glyphDataTexture = Metaphrasis::convertBufferToI4(glyphData, charData->textureWidth, charData->textureHeight); - break; - case GX_TF_I8: - charData->glyphDataTexture = Metaphrasis::convertBufferToI8(glyphData, charData->textureWidth, charData->textureHeight); - break; - case GX_TF_IA4: - charData->glyphDataTexture = Metaphrasis::convertBufferToIA4(glyphData, charData->textureWidth, charData->textureHeight); - break; - case GX_TF_IA8: - charData->glyphDataTexture = Metaphrasis::convertBufferToIA8(glyphData, charData->textureWidth, charData->textureHeight); - break; - case GX_TF_RGB565: - charData->glyphDataTexture = Metaphrasis::convertBufferToRGB565(glyphData, charData->textureWidth, charData->textureHeight); - break; - case GX_TF_RGB5A3: - charData->glyphDataTexture = Metaphrasis::convertBufferToRGB5A3(glyphData, charData->textureWidth, charData->textureHeight); - break; - case GX_TF_RGBA8: - default: - charData->glyphDataTexture = Metaphrasis::convertBufferToRGBA8(glyphData, charData->textureWidth, charData->textureHeight); - break; - } + switch (this->textureFormat) { + case GX_TF_I4: + charData->glyphDataTexture = Metaphrasis::convertBufferToI4(glyphData, charData->textureWidth, charData->textureHeight); + break; + case GX_TF_I8: + charData->glyphDataTexture = Metaphrasis::convertBufferToI8(glyphData, charData->textureWidth, charData->textureHeight); + break; + case GX_TF_IA4: + charData->glyphDataTexture = Metaphrasis::convertBufferToIA4(glyphData, charData->textureWidth, charData->textureHeight); + break; + case GX_TF_IA8: + charData->glyphDataTexture = Metaphrasis::convertBufferToIA8(glyphData, charData->textureWidth, charData->textureHeight); + break; + case GX_TF_RGB565: + charData->glyphDataTexture = Metaphrasis::convertBufferToRGB565(glyphData, charData->textureWidth, charData->textureHeight); + break; + case GX_TF_RGB5A3: + charData->glyphDataTexture = Metaphrasis::convertBufferToRGB5A3(glyphData, charData->textureWidth, charData->textureHeight); + break; + case GX_TF_RGBA8: + default: + charData->glyphDataTexture = Metaphrasis::convertBufferToRGBA8(glyphData, charData->textureWidth, charData->textureHeight); + break; + } - free(glyphData); + free(glyphData); } /** @@ -476,20 +472,19 @@ void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) { */ int16_t FreeTypeGX::getStyleOffsetWidth(uint16_t width, uint16_t format) { - switch(format & FTGX_JUSTIFY_MASK) - { - case FTGX_JUSTIFY_LEFT: - return 0; + switch (format & FTGX_JUSTIFY_MASK) { + case FTGX_JUSTIFY_LEFT: + return 0; - default: - case FTGX_JUSTIFY_CENTER: - return -(width >> 1); + default: + case FTGX_JUSTIFY_CENTER: + return -(width >> 1); - case FTGX_JUSTIFY_RIGHT: - return -width; - } + case FTGX_JUSTIFY_RIGHT: + return -width; + } - return 0; + return 0; } /** @@ -500,34 +495,32 @@ 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) - { - case FTGX_ALIGN_TOP: - return offset->ascender; +int16_t FreeTypeGX::getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format) { + switch (format & FTGX_ALIGN_MASK) { + case FTGX_ALIGN_TOP: + return offset->ascender; - default: - case FTGX_ALIGN_MIDDLE: - return (offset->ascender + offset->descender + 1) >> 1; + default: + case FTGX_ALIGN_MIDDLE: + return (offset->ascender + offset->descender + 1) >> 1; - case FTGX_ALIGN_BOTTOM: - return offset->descender; + case FTGX_ALIGN_BOTTOM: + return offset->descender; - case FTGX_ALIGN_BASELINE: - return 0; + case FTGX_ALIGN_BASELINE: + return 0; - case FTGX_ALIGN_GLYPH_TOP: - return offset->max; + case FTGX_ALIGN_GLYPH_TOP: + return offset->max; - case FTGX_ALIGN_GLYPH_MIDDLE: - return (offset->max + offset->min + 1) >> 1; + case FTGX_ALIGN_GLYPH_MIDDLE: + return (offset->max + offset->min + 1) >> 1; - case FTGX_ALIGN_GLYPH_BOTTOM: - return offset->min; - } + case FTGX_ALIGN_GLYPH_BOTTOM: + return offset->min; + } - return 0; + return 0; } /** @@ -544,100 +537,99 @@ int16_t FreeTypeGX::getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format * @return The number of characters printed. */ uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color, uint16_t textStyle) { - uint16_t strLength = wcslen(text); - uint16_t x_pos = x, printed = 0; - uint16_t x_offset = 0, y_offset = 0; - GXTexObj glyphTexture; - FT_Vector pairDelta; - ftgxDataOffset offset; + uint16_t strLength = wcslen(text); + uint16_t x_pos = x, printed = 0; + uint16_t x_offset = 0, y_offset = 0; + GXTexObj glyphTexture; + FT_Vector pairDelta; + ftgxDataOffset offset; - if(textStyle & FTGX_JUSTIFY_MASK) { - x_offset = this->getStyleOffsetWidth(this->getWidth(text), textStyle); - } - if(textStyle & FTGX_ALIGN_MASK) { - y_offset = this->getStyleOffsetHeight(this->getOffset(text, &offset), textStyle); - } + if (textStyle & FTGX_JUSTIFY_MASK) { + x_offset = this->getStyleOffsetWidth(this->getWidth(text), textStyle); + } + if (textStyle & FTGX_ALIGN_MASK) { + y_offset = this->getStyleOffsetHeight(this->getOffset(text, &offset), textStyle); + } - for (uint16_t i = 0; i < strLength; i++) { + for (uint16_t i = 0; i < strLength; i++) { - ftgxCharData* glyphData = NULL; - if( this->fontData.find(text[i]) != this->fontData.end() ) { - glyphData = &this->fontData[text[i]]; - } - else { - glyphData = this->cacheGlyphData(text[i]); - } + ftgxCharData* glyphData = NULL; + if ( this->fontData.find(text[i]) != this->fontData.end() ) { + glyphData = &this->fontData[text[i]]; + } else { + glyphData = this->cacheGlyphData(text[i]); + } - if(glyphData != NULL) { + if (glyphData != NULL) { - 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; - } + 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; + } - GX_InitTexObj(&glyphTexture, glyphData->glyphDataTexture, glyphData->textureWidth, glyphData->textureHeight, this->textureFormat, GX_CLAMP, GX_CLAMP, GX_FALSE); - this->copyTextureToFramebuffer(&glyphTexture, glyphData->textureWidth, glyphData->textureHeight, x_pos + glyphData->renderOffsetX + x_offset, y - glyphData->renderOffsetY + y_offset, color); + GX_InitTexObj(&glyphTexture, glyphData->glyphDataTexture, glyphData->textureWidth, glyphData->textureHeight, this->textureFormat, GX_CLAMP, GX_CLAMP, GX_FALSE); + this->copyTextureToFramebuffer(&glyphTexture, glyphData->textureWidth, glyphData->textureHeight, x_pos + glyphData->renderOffsetX + x_offset, y - glyphData->renderOffsetY + y_offset, color); - x_pos += glyphData->glyphAdvanceX; - printed++; - } - } + x_pos += glyphData->glyphAdvanceX; + printed++; + } + } - if(textStyle & FTGX_STYLE_MASK) { - this->drawTextFeature(x + x_offset, y + y_offset, this->getWidth(text), this->getOffset(text, &offset), textStyle, color); - } + if (textStyle & FTGX_STYLE_MASK) { + this->drawTextFeature(x + x_offset, y + y_offset, this->getWidth(text), this->getOffset(text, &offset), textStyle, color); + } - return printed; + return printed; } /** * \overload */ uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t const *text, GXColor color, uint16_t textStyle) { - return this->drawText(x, y, (wchar_t *)text, color, textStyle); + return this->drawText(x, y, (wchar_t *)text, color, textStyle); } void FreeTypeGX::drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataOffset *offsetData, uint16_t format, GXColor color) { - uint16_t featureHeight = this->ftPointSize >> 4 > 0 ? this->ftPointSize >> 4 : 1; + uint16_t featureHeight = this->ftPointSize >> 4 > 0 ? this->ftPointSize >> 4 : 1; - if (format & FTGX_STYLE_UNDERLINE ) { - switch(format & FTGX_ALIGN_MASK) { -/* - case FTGX_ALIGN_TOP: - this->copyFeatureToFramebuffer(width, featureHeight, x, y + offsetData->max + 1, color); - break; - case FTGX_ALIGN_MIDDLE: - this->copyFeatureToFramebuffer(width, featureHeight, x, y + ((offsetData->max - offsetData->min + 1) >> 1), color); - break; - case FTGX_ALIGN_BOTTOM: - this->copyFeatureToFramebuffer(width, featureHeight, x, y - offsetData->min, color); - break; -*/ - default: - this->copyFeatureToFramebuffer(width, featureHeight, x, y + 1, color); - break; - } - } + if (format & FTGX_STYLE_UNDERLINE ) { + switch (format & FTGX_ALIGN_MASK) { + /* + case FTGX_ALIGN_TOP: + this->copyFeatureToFramebuffer(width, featureHeight, x, y + offsetData->max + 1, color); + break; + case FTGX_ALIGN_MIDDLE: + this->copyFeatureToFramebuffer(width, featureHeight, x, y + ((offsetData->max - offsetData->min + 1) >> 1), color); + break; + case FTGX_ALIGN_BOTTOM: + this->copyFeatureToFramebuffer(width, featureHeight, x, y - offsetData->min, color); + break; + */ + default: + this->copyFeatureToFramebuffer(width, featureHeight, x, y + 1, color); + break; + } + } - if (format & FTGX_STYLE_STRIKE ) { - switch(format & FTGX_ALIGN_MASK) { -/* - case FTGX_ALIGN_TOP: - this->copyFeatureToFramebuffer(width, featureHeight, x, y + ((offsetData->max - offsetData->min + 1) >> 1), color); - break; - case FTGX_ALIGN_MIDDLE: - this->copyFeatureToFramebuffer(width, featureHeight, x, y, color); - break; - case FTGX_ALIGN_BOTTOM: - this->copyFeatureToFramebuffer(width, featureHeight, x, y - ((offsetData->max + offsetData->min) >> 1), color); - break; -*/ - default: + if (format & FTGX_STYLE_STRIKE ) { + switch (format & FTGX_ALIGN_MASK) { + /* + case FTGX_ALIGN_TOP: + this->copyFeatureToFramebuffer(width, featureHeight, x, y + ((offsetData->max - offsetData->min + 1) >> 1), color); + break; + case FTGX_ALIGN_MIDDLE: + this->copyFeatureToFramebuffer(width, featureHeight, x, y, color); + break; + 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); - break; - } - } + this->copyFeatureToFramebuffer(width, featureHeight, x, y - ((offsetData->max) >> 1), color); + break; + } + } } /** @@ -650,31 +642,30 @@ void FreeTypeGX::drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataO * @return The width of the text string in pixels. */ uint16_t FreeTypeGX::getWidth(wchar_t *text) { - uint16_t strLength = wcslen(text); - uint16_t strWidth = 0; - FT_Vector pairDelta; + uint16_t strLength = wcslen(text); + uint16_t strWidth = 0; + FT_Vector pairDelta; - for (uint16_t i = 0; i < strLength; i++) { + for (uint16_t i = 0; i < strLength; i++) { - ftgxCharData* glyphData = NULL; - if( this->fontData.find(text[i]) != this->fontData.end() ) { - glyphData = &this->fontData[text[i]]; - } - else { - glyphData = this->cacheGlyphData(text[i]); - } + ftgxCharData* glyphData = NULL; + if ( this->fontData.find(text[i]) != this->fontData.end() ) { + glyphData = &this->fontData[text[i]]; + } else { + glyphData = this->cacheGlyphData(text[i]); + } - 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; - } + 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; + } - strWidth += glyphData->glyphAdvanceX; - } - } + strWidth += glyphData->glyphAdvanceX; + } + } - return strWidth; + return strWidth; } /** @@ -682,7 +673,7 @@ uint16_t FreeTypeGX::getWidth(wchar_t *text) { * \overload */ uint16_t FreeTypeGX::getWidth(wchar_t const *text) { - return this->getWidth((wchar_t *)text); + return this->getWidth((wchar_t *)text); } /** @@ -695,10 +686,10 @@ uint16_t FreeTypeGX::getWidth(wchar_t const *text) { * @return The height of the text string in pixels. */ uint16_t FreeTypeGX::getHeight(wchar_t *text) { - ftgxDataOffset offset; - this->getOffset(text, &offset); + ftgxDataOffset offset; + this->getOffset(text, &offset); - return offset.max - offset.min; + return offset.max - offset.min; } /** @@ -706,7 +697,7 @@ uint16_t FreeTypeGX::getHeight(wchar_t *text) { * \overload */ uint16_t FreeTypeGX::getHeight(wchar_t const *text) { - return this->getHeight((wchar_t *)text); + return this->getHeight((wchar_t *)text); } /** @@ -720,29 +711,28 @@ uint16_t FreeTypeGX::getHeight(wchar_t const *text) { * */ ftgxDataOffset* FreeTypeGX::getOffset(wchar_t *text, ftgxDataOffset* offset) { - uint16_t strLength = wcslen(text); - int16_t strMax = 0, strMin = 9999; + uint16_t strLength = wcslen(text); + int16_t strMax = 0, strMin = 9999; - for (uint16_t i = 0; i < strLength; i++) { + for (uint16_t i = 0; i < strLength; i++) { - ftgxCharData* glyphData = NULL; - if( this->fontData.find(text[i]) != this->fontData.end() ) { - glyphData = &this->fontData[text[i]]; - } - else { - glyphData = this->cacheGlyphData(text[i]); - } + ftgxCharData* glyphData = NULL; + if ( this->fontData.find(text[i]) != this->fontData.end() ) { + glyphData = &this->fontData[text[i]]; + } else { + glyphData = this->cacheGlyphData(text[i]); + } - if(glyphData != NULL) { - strMax = glyphData->renderOffsetMax > strMax ? glyphData->renderOffsetMax : strMax; - strMin = glyphData->renderOffsetMin < strMin ? glyphData->renderOffsetMin : strMin; - } - } - offset->ascender = this->ftFace->size->metrics.ascender>>6; - offset->descender = this->ftFace->size->metrics.descender>>6; - offset->max = strMax; - offset->min = strMin; - return offset; + if (glyphData != NULL) { + strMax = glyphData->renderOffsetMax > strMax ? glyphData->renderOffsetMax : strMax; + strMin = glyphData->renderOffsetMin < strMin ? glyphData->renderOffsetMin : strMin; + } + } + offset->ascender = this->ftFace->size->metrics.ascender>>6; + offset->descender = this->ftFace->size->metrics.descender>>6; + offset->max = strMax; + offset->min = strMin; + return offset; } /** @@ -750,7 +740,7 @@ ftgxDataOffset* FreeTypeGX::getOffset(wchar_t *text, ftgxDataOffset* offset) { * \overload */ ftgxDataOffset* FreeTypeGX::getOffset(wchar_t const *text, ftgxDataOffset* offset) { - return this->getOffset(text, offset); + return this->getOffset(text, offset); } /** @@ -767,31 +757,31 @@ ftgxDataOffset* FreeTypeGX::getOffset(wchar_t const *text, ftgxDataOffset* offse */ void FreeTypeGX::copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 texHeight, int16_t screenX, int16_t screenY, GXColor color) { - GX_LoadTexObj(texObj, GX_TEXMAP0); - GX_InvalidateTexAll(); + GX_LoadTexObj(texObj, GX_TEXMAP0); + GX_InvalidateTexAll(); - GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); - GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT); + GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); + GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT); - GX_Begin(GX_QUADS, this->vertexIndex, 4); - GX_Position2s16(screenX, screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); - GX_TexCoord2f32(0.0f, 0.0f); + GX_Begin(GX_QUADS, this->vertexIndex, 4); + GX_Position2s16(screenX, screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); + GX_TexCoord2f32(0.0f, 0.0f); - GX_Position2s16(texWidth + screenX, screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); - GX_TexCoord2f32(1.0f, 0.0f); + GX_Position2s16(texWidth + screenX, screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); + GX_TexCoord2f32(1.0f, 0.0f); - GX_Position2s16(texWidth + screenX, texHeight + screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); - GX_TexCoord2f32(1.0f, 1.0f); + GX_Position2s16(texWidth + screenX, texHeight + screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); + GX_TexCoord2f32(1.0f, 1.0f); - GX_Position2s16(screenX, texHeight + screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); - GX_TexCoord2f32(0.0f, 1.0f); - GX_End(); + GX_Position2s16(screenX, texHeight + screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); + GX_TexCoord2f32(0.0f, 1.0f); + GX_End(); - this->setDefaultMode(); + this->setDefaultMode(); } /** @@ -807,22 +797,22 @@ void FreeTypeGX::copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 te */ void FreeTypeGX::copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, int16_t screenX, int16_t screenY, GXColor color) { - GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR); - GX_SetVtxDesc (GX_VA_TEX0, GX_NONE); + GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR); + GX_SetVtxDesc (GX_VA_TEX0, GX_NONE); - GX_Begin(GX_QUADS, this->vertexIndex, 4); - GX_Position2s16(screenX, screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); + GX_Begin(GX_QUADS, this->vertexIndex, 4); + GX_Position2s16(screenX, screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); - GX_Position2s16(featureWidth + screenX, screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); + GX_Position2s16(featureWidth + screenX, screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); - GX_Position2s16(featureWidth + screenX, featureHeight + screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); + GX_Position2s16(featureWidth + screenX, featureHeight + screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); - GX_Position2s16(screenX, featureHeight + screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); - GX_End(); + GX_Position2s16(screenX, featureHeight + screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); + GX_End(); - this->setDefaultMode(); + this->setDefaultMode(); } diff --git a/source/FreeTypeGX.h b/source/FreeTypeGX.h index 95d99dad..5d235837 100644 --- a/source/FreeTypeGX.h +++ b/source/FreeTypeGX.h @@ -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,59 +219,59 @@ const GXColor ftgxWhite = (GXColor){0xff, 0xff, 0xff, 0xff}; /**< Constant color */ class FreeTypeGX { - private: - FT_Library ftLibrary; /**< FreeType FT_Library instance. */ - FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */ - FT_Byte *ftFace_fromFile; - FT_GlyphSlot ftSlot; /**< FreeType reusable FT_GlyphSlot glyph container object. */ - FT_UInt ftPointSize; /**< Requested size of the rendered font. */ - bool ftKerningEnabled; /**< Flag indicating the availability of font kerning data. */ +private: + FT_Library ftLibrary; /**< FreeType FT_Library instance. */ + FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */ + FT_Byte *ftFace_fromFile; + FT_GlyphSlot ftSlot; /**< FreeType reusable FT_GlyphSlot glyph container object. */ + FT_UInt ftPointSize; /**< Requested size of the rendered font. */ + bool ftKerningEnabled; /**< Flag indicating the availability of font kerning data. */ - uint8_t textureFormat; /**< Defined texture format of the target EFB. */ - uint8_t vertexIndex; /**< Vertex format descriptor index. */ - uint32_t compatibilityMode; /**< Compatibility mode for default tev operations and vertex descriptors. */ - std::map fontData; /**< Map which holds the glyph data structures for the corresponding characters. */ + uint8_t textureFormat; /**< Defined texture format of the target EFB. */ + uint8_t vertexIndex; /**< Vertex format descriptor index. */ + uint32_t compatibilityMode; /**< Compatibility mode for default tev operations and vertex descriptors. */ + std::map fontData; /**< Map which holds the glyph data structures for the corresponding characters. */ - static uint16_t adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat); - static uint16_t adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat); + static uint16_t adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat); + static uint16_t adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat); - static int16_t getStyleOffsetWidth(uint16_t width, uint16_t format); - static int16_t getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format); + static int16_t getStyleOffsetWidth(uint16_t width, uint16_t format); + static int16_t getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format); - void unloadFont(); - void clearGlyphData(); - ftgxCharData *cacheGlyphData(wchar_t charCode); - uint16_t cacheGlyphDataComplete(); - void loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData); + void unloadFont(); + void clearGlyphData(); + ftgxCharData *cacheGlyphData(wchar_t charCode); + uint16_t cacheGlyphDataComplete(); + void loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData); - void setDefaultMode(); + void setDefaultMode(); - void drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataOffset *offsetData, uint16_t format, GXColor color); - 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); + void drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataOffset *offsetData, uint16_t format, GXColor color); + 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: - FreeTypeGX(uint8_t textureFormat = GX_TF_RGBA8, uint8_t vertexIndex = GX_VTXFMT1); - ~FreeTypeGX(); +public: + FreeTypeGX(uint8_t textureFormat = GX_TF_RGBA8, uint8_t vertexIndex = GX_VTXFMT1); + ~FreeTypeGX(); - static wchar_t* charToWideChar(char* p); - static wchar_t* charToWideChar(const char* p); - void setVertexFormat(uint8_t vertexIndex); - void setCompatibilityMode(uint32_t compatibilityMode); + static wchar_t* charToWideChar(char* p); + static wchar_t* charToWideChar(const char* p); + void setVertexFormat(uint8_t vertexIndex); + void setCompatibilityMode(uint32_t compatibilityMode); - uint16_t loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false); - uint16_t loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false); - void changeSize(FT_UInt vPointSize, FT_UInt hPointSize=0); + uint16_t loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false); + uint16_t loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false); + void changeSize(FT_UInt vPointSize, FT_UInt hPointSize=0); - uint16_t drawText(int16_t x, int16_t y, wchar_t *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL); - uint16_t drawText(int16_t x, int16_t y, wchar_t const *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL); + uint16_t drawText(int16_t x, int16_t y, wchar_t *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL); + uint16_t drawText(int16_t x, int16_t y, wchar_t const *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL); - uint16_t getWidth(wchar_t *text); - uint16_t getWidth(wchar_t const *text); - uint16_t getHeight(wchar_t *text); - uint16_t getHeight(wchar_t const *text); - ftgxDataOffset* getOffset(wchar_t *text, ftgxDataOffset* offset); - ftgxDataOffset* getOffset(wchar_t const *text, ftgxDataOffset* offset); + uint16_t getWidth(wchar_t *text); + uint16_t getWidth(wchar_t const *text); + uint16_t getHeight(wchar_t *text); + uint16_t getHeight(wchar_t const *text); + ftgxDataOffset* getOffset(wchar_t *text, ftgxDataOffset* offset); + ftgxDataOffset* getOffset(wchar_t const *text, ftgxDataOffset* offset); }; #endif /* FREETYPEGX_H_ */ diff --git a/source/Metaphrasis.cpp b/source/Metaphrasis.cpp index cc83cfcc..47656c9c 100644 --- a/source/Metaphrasis.cpp +++ b/source/Metaphrasis.cpp @@ -1,20 +1,20 @@ -/* +/* * Metaphrasis is a static conversion class for transforming RGBA image * buffers into verious GX texture formats for Wii homebrew development. * Copyright (C) 2008 Armin Tamzarian - * + * * This file is part of Metaphrasis. - * + * * Metaphrasis is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * Metaphrasis is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with Metaphrasis. If not, see . */ @@ -37,9 +37,9 @@ Metaphrasis::~Metaphrasis() { /** * Convert the specified RGBA data buffer into the I4 texture format - * + * * This routine converts the RGBA data buffer into the I4 texture format and returns a pointer to the converted buffer. - * + * * @param rgbaBuffer Buffer containing the temporarily rendered RGBA data. * @param bufferWidth Pixel width of the data buffer. * @param bufferHeight Pixel height of the data buffer. @@ -47,33 +47,33 @@ Metaphrasis::~Metaphrasis() { */ uint32_t* Metaphrasis::convertBufferToI4(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) { - uint32_t bufferSize = bufferWidth * bufferHeight >> 1; - uint32_t* dataBufferI4 = (uint32_t *)memalign(32, bufferSize); - memset(dataBufferI4, 0x00, bufferSize); + uint32_t bufferSize = bufferWidth * bufferHeight >> 1; + uint32_t* dataBufferI4 = (uint32_t *)memalign(32, bufferSize); + memset(dataBufferI4, 0x00, bufferSize); - uint32_t *src = (uint32_t *)rgbaBuffer; - uint8_t *dst = (uint8_t *)dataBufferI4; + 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++) { - *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); - *dst++ = (src[((y + rows) * bufferWidth) + (x + 5)] & 0xf0) | ((src[((y + rows) * bufferWidth) + (x + 7)] & 0xf0) >> 4); - } - } - } - DCFlushRange(dataBufferI4, bufferSize); + 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); + *dst++ = (src[((y + rows) * bufferWidth) + (x + 5)] & 0xf0) | ((src[((y + rows) * bufferWidth) + (x + 7)] & 0xf0) >> 4); + } + } + } + DCFlushRange(dataBufferI4, bufferSize); - return dataBufferI4; + return dataBufferI4; } /** * Convert the specified RGBA data buffer into the I8 texture format - * + * * This routine converts the RGBA data buffer into the I8 texture format and returns a pointer to the converted buffer. - * + * * @param rgbaBuffer Buffer containing the temporarily rendered RGBA data. * @param bufferWidth Pixel width of the data buffer. * @param bufferHeight Pixel height of the data buffer. @@ -81,55 +81,55 @@ uint32_t* Metaphrasis::convertBufferToI4(uint32_t* rgbaBuffer, uint16_t bufferWi */ uint32_t* Metaphrasis::convertBufferToI8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) { - uint32_t bufferSize = bufferWidth * bufferHeight; - uint32_t* dataBufferI8 = (uint32_t *)memalign(32, bufferSize); - memset(dataBufferI8, 0x00, bufferSize); + uint32_t bufferSize = bufferWidth * bufferHeight; + uint32_t* dataBufferI8 = (uint32_t *)memalign(32, bufferSize); + memset(dataBufferI8, 0x00, bufferSize); - uint32_t *src = (uint32_t *)rgbaBuffer; - uint8_t *dst = (uint8_t *)dataBufferI8; + 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++) { - *dst++ = src[((y + rows) * bufferWidth) + (x + 0)] & 0xff; - *dst++ = src[((y + rows) * bufferWidth) + (x + 1)] & 0xff; - *dst++ = src[((y + rows) * bufferWidth) + (x + 2)] & 0xff; - *dst++ = src[((y + rows) * bufferWidth) + (x + 3)] & 0xff; - *dst++ = src[((y + rows) * bufferWidth) + (x + 4)] & 0xff; - *dst++ = src[((y + rows) * bufferWidth) + (x + 5)] & 0xff; - *dst++ = src[((y + rows) * bufferWidth) + (x + 6)] & 0xff; - *dst++ = src[((y + rows) * bufferWidth) + (x + 7)] & 0xff; - } - } - } - DCFlushRange(dataBufferI8, bufferSize); + 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; + *dst++ = src[((y + rows) * bufferWidth) + (x + 3)] & 0xff; + *dst++ = src[((y + rows) * bufferWidth) + (x + 4)] & 0xff; + *dst++ = src[((y + rows) * bufferWidth) + (x + 5)] & 0xff; + *dst++ = src[((y + rows) * bufferWidth) + (x + 6)] & 0xff; + *dst++ = src[((y + rows) * bufferWidth) + (x + 7)] & 0xff; + } + } + } + DCFlushRange(dataBufferI8, bufferSize); - return dataBufferI8; + return dataBufferI8; } /** * Downsample the specified RGBA value data buffer to an IA4 value. - * + * * This routine downsamples the given RGBA data value into the IA4 texture data format. - * + * * @param rgba A 32-bit RGBA value to convert to the IA4 format. * @return The IA4 value of the given RGBA value. */ uint8_t Metaphrasis::convertRGBAToIA4(uint32_t rgba) { - uint8_t i, a; - - i = (rgba >> 8) & 0xf0; - a = (rgba ) & 0xff; + uint8_t i, a; - return i | (a >> 4); + i = (rgba >> 8) & 0xf0; + a = (rgba ) & 0xff; + + return i | (a >> 4); } /** * Convert the specified RGBA data buffer into the IA4 texture format - * + * * This routine converts the RGBA data buffer into the IA4 texture format and returns a pointer to the converted buffer. - * + * * @param rgbaBuffer Buffer containing the temporarily rendered RGBA data. * @param bufferWidth Pixel width of the data buffer. * @param bufferHeight Pixel height of the data buffer. @@ -137,55 +137,55 @@ uint8_t Metaphrasis::convertRGBAToIA4(uint32_t rgba) { */ uint32_t* Metaphrasis::convertBufferToIA4(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) { - uint32_t bufferSize = bufferWidth * bufferHeight; - uint32_t* dataBufferIA4 = (uint32_t *)memalign(32, bufferSize); - memset(dataBufferIA4, 0x00, bufferSize); + uint32_t bufferSize = bufferWidth * bufferHeight; + uint32_t* dataBufferIA4 = (uint32_t *)memalign(32, bufferSize); + memset(dataBufferIA4, 0x00, bufferSize); - uint32_t *src = (uint32_t *)rgbaBuffer; - uint8_t *dst = (uint8_t *)dataBufferIA4; + 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++) { - *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)]); - *dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 3)]); - *dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 4)]); - *dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 5)]); - *dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 6)]); - *dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 7)]); - } - } - } - DCFlushRange(dataBufferIA4, bufferSize); + 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)]); + *dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 3)]); + *dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 4)]); + *dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 5)]); + *dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 6)]); + *dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 7)]); + } + } + } + DCFlushRange(dataBufferIA4, bufferSize); - return dataBufferIA4; + return dataBufferIA4; } /** * Downsample the specified RGBA value data buffer to an IA8 value. - * + * * This routine downsamples the given RGBA data value into the IA8 texture data format. - * + * * @param rgba A 32-bit RGBA value to convert to the IA8 format. * @return The IA8 value of the given RGBA value. */ uint16_t Metaphrasis::convertRGBAToIA8(uint32_t rgba) { - uint8_t i, a; - - i = (rgba >> 8) & 0xff; - a = (rgba ) & 0xff; + uint8_t i, a; - return (i << 8) | a; + i = (rgba >> 8) & 0xff; + a = (rgba ) & 0xff; + + return (i << 8) | a; } /** * Convert the specified RGBA data buffer into the IA8 texture format - * + * * This routine converts the RGBA data buffer into the IA8 texture format and returns a pointer to the converted buffer. - * + * * @param rgbaBuffer Buffer containing the temporarily rendered RGBA data. * @param bufferWidth Pixel width of the data buffer. * @param bufferHeight Pixel height of the data buffer. @@ -193,33 +193,33 @@ uint16_t Metaphrasis::convertRGBAToIA8(uint32_t rgba) { */ uint32_t* Metaphrasis::convertBufferToIA8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) { - uint32_t bufferSize = (bufferWidth * bufferHeight) << 1; - uint32_t* dataBufferIA8 = (uint32_t *)memalign(32, bufferSize); - memset(dataBufferIA8, 0x00, bufferSize); + uint32_t bufferSize = (bufferWidth * bufferHeight) << 1; + uint32_t* dataBufferIA8 = (uint32_t *)memalign(32, bufferSize); + memset(dataBufferIA8, 0x00, bufferSize); - uint32_t *src = (uint32_t *)rgbaBuffer; - uint16_t *dst = (uint16_t *)dataBufferIA8; + 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++) { - *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)]); - *dst++ = Metaphrasis::convertRGBAToIA8(src[((y + rows) * bufferWidth) + (x + 3)]); - } - } - } - DCFlushRange(dataBufferIA8, bufferSize); + 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)]); + *dst++ = Metaphrasis::convertRGBAToIA8(src[((y + rows) * bufferWidth) + (x + 3)]); + } + } + } + DCFlushRange(dataBufferIA8, bufferSize); - return dataBufferIA8; + return dataBufferIA8; } /** * Convert the specified RGBA data buffer into the RGBA8 texture format - * + * * This routine converts the RGBA data buffer into the RGBA8 texture format and returns a pointer to the converted buffer. - * + * * @param rgbaBuffer Buffer containing the temporarily rendered RGBA data. * @param bufferWidth Pixel width of the data buffer. * @param bufferHeight Pixel height of the data buffer. @@ -227,59 +227,59 @@ uint32_t* Metaphrasis::convertBufferToIA8(uint32_t* rgbaBuffer, uint16_t bufferW */ uint32_t* Metaphrasis::convertBufferToRGBA8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) { - uint32_t bufferSize = (bufferWidth * bufferHeight) << 2; - uint32_t* dataBufferRGBA8 = (uint32_t *)memalign(32, bufferSize); - memset(dataBufferRGBA8, 0x00, bufferSize); + uint32_t bufferSize = (bufferWidth * bufferHeight) << 2; + uint32_t* dataBufferRGBA8 = (uint32_t *)memalign(32, bufferSize); + memset(dataBufferRGBA8, 0x00, bufferSize); - uint8_t *src = (uint8_t *)rgbaBuffer; - uint8_t *dst = (uint8_t *)dataBufferRGBA8; + 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 c = 0; c < 4; c++) { - for (uint16_t ar = 0; ar < 4; ar++) { - *dst++ = src[(((i + ar) + ((block + c) * bufferWidth)) * 4) + 3]; - *dst++ = src[((i + ar) + ((block + c) * bufferWidth)) * 4]; - } - } - for (uint16_t c = 0; c < 4; c++) { - for (uint16_t gb = 0; gb < 4; gb++) { - *dst++ = src[(((i + gb) + ((block + c) * bufferWidth)) * 4) + 1]; - *dst++ = src[(((i + gb) + ((block + c) * bufferWidth)) * 4) + 2]; - } - } - } - } - DCFlushRange(dataBufferRGBA8, bufferSize); + 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]; + *dst++ = src[((i + ar) + ((block + c) * bufferWidth)) * 4]; + } + } + for (uint16_t c = 0; c < 4; c++) { + for (uint16_t gb = 0; gb < 4; gb++) { + *dst++ = src[(((i + gb) + ((block + c) * bufferWidth)) * 4) + 1]; + *dst++ = src[(((i + gb) + ((block + c) * bufferWidth)) * 4) + 2]; + } + } + } + } + DCFlushRange(dataBufferRGBA8, bufferSize); - return dataBufferRGBA8; + return dataBufferRGBA8; } /** * Downsample the specified RGBA value data buffer to an RGB565 value. - * + * * This routine downsamples the given RGBA data value into the RGB565 texture data format. * Attribution for this routine is given fully to NoNameNo of GRRLIB Wii library. - * + * * @param rgba A 32-bit RGBA value to convert to the RGB565 format. * @return The RGB565 value of the given RGBA value. */ uint16_t Metaphrasis::convertRGBAToRGB565(uint32_t rgba) { - uint8_t r, g, b; - - r = (((rgba >> 24) & 0xff) * 31) / 255; - g = (((rgba >> 16) & 0xff) * 63) / 255; - b = (((rgba >> 8) & 0xff) * 31) / 255; + uint8_t r, g, b; - return (((r << 6) | g ) << 5 ) | b; + r = (((rgba >> 24) & 0xff) * 31) / 255; + g = (((rgba >> 16) & 0xff) * 63) / 255; + b = (((rgba >> 8) & 0xff) * 31) / 255; + + return (((r << 6) | g ) << 5 ) | b; } /** * Convert the specified RGBA data buffer into the RGB565 texture format - * + * * This routine converts the RGBA data buffer into the RGB565 texture format and returns a pointer to the converted buffer. - * + * * @param rgbaBuffer Buffer containing the temporarily rendered RGBA data. * @param bufferWidth Pixel width of the data buffer. * @param bufferHeight Pixel height of the data buffer. @@ -287,72 +287,71 @@ uint16_t Metaphrasis::convertRGBAToRGB565(uint32_t rgba) { */ uint32_t* Metaphrasis::convertBufferToRGB565(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) { - uint32_t bufferSize = (bufferWidth * bufferHeight) << 1; - uint32_t* dataBufferRGB565 = (uint32_t *)memalign(32, bufferSize); - memset(dataBufferRGB565, 0x00, bufferSize); + uint32_t bufferSize = (bufferWidth * bufferHeight) << 1; + uint32_t* dataBufferRGB565 = (uint32_t *)memalign(32, bufferSize); + memset(dataBufferRGB565, 0x00, bufferSize); - uint32_t *src = (uint32_t *)rgbaBuffer; - uint16_t *dst = (uint16_t *)dataBufferRGB565; + 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++) { - *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)]); - *dst++ = Metaphrasis::convertRGBAToRGB565(src[((y + rows) * bufferWidth) + (x + 3)]); - } - } - } - DCFlushRange(dataBufferRGB565, bufferSize); + 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)]); + *dst++ = Metaphrasis::convertRGBAToRGB565(src[((y + rows) * bufferWidth) + (x + 3)]); + } + } + } + DCFlushRange(dataBufferRGB565, bufferSize); - return dataBufferRGB565; + return dataBufferRGB565; } /** * Downsample the specified RGBA value data buffer to an RGB5A3 value. - * + * * This routine downsamples the given RGBA data value into the RGB5A3 texture data format. * Attribution for this routine is given fully to WiiGator via the TehSkeen forum. - * + * * @param rgba A 32-bit RGBA value to convert to the RGB5A3 format. * @return The RGB5A3 value of the given RGBA value. */ uint16_t Metaphrasis::convertRGBAToRGB5A3(uint32_t rgba) { - uint32_t r, g, b, a; - uint16_t color; + uint32_t r, g, b, a; + uint16_t color; - r = (rgba >> 24) & 0xff; - g = (rgba >> 16) & 0xff; - b = (rgba >> 8) & 0xff; - a = (rgba ) & 0xff; + r = (rgba >> 24) & 0xff; + g = (rgba >> 16) & 0xff; + b = (rgba >> 8) & 0xff; + a = (rgba ) & 0xff; - if (a > 0xe0) { - r = r >> 3; - g = g >> 3; - b = b >> 3; - - color = (r << 10) | (g << 5) | b; - color |= 0x8000; - } - else { - r = r >> 4; - g = g >> 4; - b = b >> 4; - a = a >> 5; - - color = (a << 12) | (r << 8) | (g << 4) | b; - } + if (a > 0xe0) { + r = r >> 3; + g = g >> 3; + b = b >> 3; - return color; + color = (r << 10) | (g << 5) | b; + color |= 0x8000; + } else { + r = r >> 4; + g = g >> 4; + b = b >> 4; + a = a >> 5; + + color = (a << 12) | (r << 8) | (g << 4) | b; + } + + return color; } - + /** * Convert the specified RGBA data buffer into the RGB5A3 texture format - * + * * This routine converts the RGBA data buffer into the RGB5A3 texture format and returns a pointer to the converted buffer. - * + * * @param rgbaBuffer Buffer containing the temporarily rendered RGBA data. * @param bufferWidth Pixel width of the data buffer. * @param bufferHeight Pixel height of the data buffer. @@ -360,24 +359,24 @@ uint16_t Metaphrasis::convertRGBAToRGB5A3(uint32_t rgba) { */ uint32_t* Metaphrasis::convertBufferToRGB5A3(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) { - uint32_t bufferSize = (bufferWidth * bufferHeight) << 1; - uint32_t* dataBufferRGB5A3 = (uint32_t *)memalign(32, bufferSize); - memset(dataBufferRGB5A3, 0x00, bufferSize); + uint32_t bufferSize = (bufferWidth * bufferHeight) << 1; + uint32_t* dataBufferRGB5A3 = (uint32_t *)memalign(32, bufferSize); + memset(dataBufferRGB5A3, 0x00, bufferSize); - uint32_t *src = (uint32_t *)rgbaBuffer; - uint16_t *dst = (uint16_t *)dataBufferRGB5A3; + 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++) { - *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)]); - *dst++ = Metaphrasis::convertRGBAToRGB5A3(src[((y + rows) * bufferWidth) + (x + 3)]); - } - } - } - DCFlushRange(dataBufferRGB5A3, bufferSize); + 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)]); + *dst++ = Metaphrasis::convertRGBAToRGB5A3(src[((y + rows) * bufferWidth) + (x + 3)]); + } + } + } + DCFlushRange(dataBufferRGB5A3, bufferSize); - return dataBufferRGB5A3; + return dataBufferRGB5A3; } diff --git a/source/Metaphrasis.h b/source/Metaphrasis.h index 4ca88713..a0d49558 100644 --- a/source/Metaphrasis.h +++ b/source/Metaphrasis.h @@ -1,20 +1,20 @@ -/* +/* * Metaphrasis is a static conversion class for transforming RGBA image * buffers into verious GX texture formats for Wii homebrew development. * Copyright (C) 2008 Armin Tamzarian - * + * * This file is part of Metaphrasis. - * + * * Metaphrasis is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * Metaphrasis is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with Metaphrasis. If not, see . */ @@ -22,40 +22,40 @@ /** \mainpage Metaphrasis * * \section sec_intro Introduction - * + * * Metaphrasis is a static conversion class for transforming RGBA image buffers into verious GX texture formats for Wii homebrew development. *
- * Metaphrasis is written in C++ and makes use of a community standard and newly developed algorithms for conversion of 32-bit RGBA data buffers into various GX texture formats common to both the Gamecube and Wii platforms. + * Metaphrasis is written in C++ and makes use of a community standard and newly developed algorithms for conversion of 32-bit RGBA data buffers into various GX texture formats common to both the Gamecube and Wii platforms. *

- * This library was developed in-full by Armin Tamzarian with the support of developers in \#wiibrew on EFnet, Chaosteil of libwiisprite, and DrTwox of GRRLIB. - * + * This library was developed in-full by Armin Tamzarian with the support of developers in \#wiibrew on EFnet, Chaosteil of libwiisprite, and DrTwox of GRRLIB. + * * \section sec_installation_source Installation (Source Code) - * + * * -# Extract the Metaphrasis archive. * -# Copy the contents of the src directory into your project's development path. * -# Include the Metaphrasis header file in your code using syntax such as the following: * \code * #include "Metaphrasis.h" * \endcode - * + * * \section sec_installation_library Installation (Library) - * + * * -# Extract the Metaphrasis archive. * -# Copy the contents of the lib directory into your devKitPro/libogc directory. * -# Include the Metaphrasis header file in your code using syntax such as the following: * \code * #include "Metaphrasis.h" * \endcode - * + * * \section sec_usage Usage - * + * * -# Create a buffer full of 32-bit RGBA values noting both the pixel height and width of the buffer. * -# Call one of the many conversion routines from within your code. (Note: All methods within the Metaphrasis class are static and thus no class instance need be allocated) * \code * uint32_t* rgba8Buffer = Metaphrasis::convertBufferToRGBA8(rgbaBuffer, bufferWidth, bufferHeight); * \endcode * -# Free your temporary RGBA value buffer if you no longer need said values. - * + * * Currently supported conversion routines are as follows: * \li convertBufferToI4 * \li convertBufferToI8 @@ -64,13 +64,13 @@ * \li convertBufferToRGBA8 * \li convertBufferToRGB565 * \li convertBufferToRGB5A3 - * + * * \section sec_license License - * + * * Metaphrasis is distributed under the GNU Lesser General Public License. - * + * * \section sec_contact Contact - * + * * If you have any suggestions, questions, or comments regarding this library feel free to e-mail me at tamzarian1989 [at] gmail [dawt] com. */ @@ -87,29 +87,29 @@ * Wii homebrew development. * \author Armin Tamzarian * \version 0.1.0 - * + * * Metaphrasis is a static conversion class for transforming RGBA image buffers into verious GX texture formats for * Wii homebrew development. Metaphrasis is written in C++ and makes use of a community standard and newly developed * algorithms for conversion of 32-bit RGBA data buffers into various GX texture formats common to both the Gamecube * and Wii platforms. */ class Metaphrasis { - public: - Metaphrasis(); - virtual ~Metaphrasis(); +public: + Metaphrasis(); + virtual ~Metaphrasis(); - static uint32_t* convertBufferToI4(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight); - static uint32_t* convertBufferToI8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight); - static uint32_t* convertBufferToIA4(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight); - static uint32_t* convertBufferToIA8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight); - static uint32_t* convertBufferToRGBA8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight); - static uint32_t* convertBufferToRGB565(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight); - static uint32_t* convertBufferToRGB5A3(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight); - - static uint8_t convertRGBAToIA4(uint32_t rgba); - static uint16_t convertRGBAToIA8(uint32_t rgba); - static uint16_t convertRGBAToRGB565(uint32_t rgba); - static uint16_t convertRGBAToRGB5A3(uint32_t rgba); + static uint32_t* convertBufferToI4(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight); + static uint32_t* convertBufferToI8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight); + static uint32_t* convertBufferToIA4(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight); + static uint32_t* convertBufferToIA8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight); + static uint32_t* convertBufferToRGBA8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight); + static uint32_t* convertBufferToRGB565(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight); + static uint32_t* convertBufferToRGB5A3(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight); + + static uint8_t convertRGBAToIA4(uint32_t rgba); + static uint16_t convertRGBAToIA8(uint32_t rgba); + static uint16_t convertRGBAToRGB565(uint32_t rgba); + static uint16_t convertRGBAToRGB5A3(uint32_t rgba); }; diff --git a/source/audio.cpp b/source/audio.cpp index 8d0b8854..b8e301ad 100644 --- a/source/audio.cpp +++ b/source/audio.cpp @@ -15,11 +15,10 @@ * * Initializes the Wii's audio subsystem ***************************************************************************/ -void InitAudio() -{ - AUDIO_Init(NULL); - ASND_Init(); - ASND_Pause(0); +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() -{ - ASND_Pause(1); - ASND_End(); +void ShutdownAudio() { + ASND_Pause(1); + ASND_End(); } diff --git a/source/buffer.cpp b/source/buffer.cpp index abfd7caa..cdc1b8fc 100644 --- a/source/buffer.cpp +++ b/source/buffer.cpp @@ -32,59 +32,57 @@ 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 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) - header = &gameList[i-gameCnt]; - else - header = &gameList[i]; + struct discHdr *header; + if (i > gameCnt-1) + header = &gameList[i-gameCnt]; + else + header = &gameList[i]; - snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); - snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); + snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, IDfull); //Load full id image + snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, IDfull); //Load full id image - //firsttime loading images into memory - if(firstime) { + //firsttime loading images into memory + if (firstime) { - if(coverImg[loading]) { - delete coverImg[loading]; - coverImg[loading] = NULL; - } - if(cover[loading]) { - delete cover[loading]; - cover[loading] = NULL; - } + if (coverImg[loading]) { + delete coverImg[loading]; + coverImg[loading] = NULL; + } + if (cover[loading]) { + delete cover[loading]; + cover[loading] = NULL; + } - cover[loading] = new GuiImageData(imgPath,0); + cover[loading] = new GuiImageData(imgPath,0); if (!cover[loading]->GetImage()) { delete cover[loading]; cover[loading] = NULL; @@ -97,105 +95,105 @@ void LoadImages() cover[loading] = new GuiImageData(imgPath, nocover_png); } } - coverImg[loading] = new GuiImage(cover[loading]); + coverImg[loading] = new GuiImage(cover[loading]); - } else { + } else { - if(direction >= 0) { + if (direction >= 0) { - if(loading < BUFFERSIZE-1) { + if (loading < BUFFERSIZE-1) { - if(coverImg[loading]) { - delete coverImg[loading]; - coverImg[loading] = NULL; - } - - if(loading == 0) { - if(cover[loading]) { - delete cover[loading]; - cover[loading] = NULL; + if (coverImg[loading]) { + delete coverImg[loading]; + coverImg[loading] = NULL; } - cover[loading] = new GuiImageData(NULL, 0); - cover[loading] = cover[loading+1]; + + if (loading == 0) { + if (cover[loading]) { + delete cover[loading]; + cover[loading] = NULL; + } + cover[loading] = new GuiImageData(NULL, 0); + cover[loading] = cover[loading+1]; + } else { + cover[loading] = cover[loading+1]; + } + + coverImg[loading] = new GuiImage(cover[loading]); + } else { - cover[loading] = cover[loading+1]; - } - coverImg[loading] = new GuiImage(cover[loading]); - - } else { - - cover[loading] = new GuiImageData(imgPath,0); - if (!cover[loading]->GetImage()) { - delete cover[loading]; - cover[loading] = NULL; - snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID); //Load short id image - cover[loading] = new GuiImageData(imgPath, 0); + cover[loading] = new GuiImageData(imgPath,0); if (!cover[loading]->GetImage()) { delete cover[loading]; cover[loading] = NULL; - snprintf(imgPath, sizeof(imgPath), "%snoimage.png", Settings.covers_path); //Load no image - cover[loading] = new GuiImageData(imgPath, nocover_png); + snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID); //Load short id image + cover[loading] = new GuiImageData(imgPath, 0); + if (!cover[loading]->GetImage()) { + delete cover[loading]; + cover[loading] = NULL; + snprintf(imgPath, sizeof(imgPath), "%snoimage.png", Settings.covers_path); //Load no image + cover[loading] = new GuiImageData(imgPath, nocover_png); + } } - } - if(coverImg[loading]) { - delete coverImg[loading]; - coverImg[loading] = NULL; - } - coverImg[loading] = new GuiImage(cover[loading]); - } - } else if(direction < 0) { - - if(BUFFERSIZE-loading-1 > 0) { - - 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]) { - delete cover[BUFFERSIZE-loading-1]; - cover[BUFFERSIZE-loading-1] = NULL; + if (coverImg[loading]) { + delete coverImg[loading]; + coverImg[loading] = NULL; } - cover[BUFFERSIZE-loading-1] = new GuiImageData(NULL, 0); - cover[BUFFERSIZE-loading-1] = cover[BUFFERSIZE-loading-1-1]; + coverImg[loading] = new GuiImage(cover[loading]); + } + } else if (direction < 0) { + + if (BUFFERSIZE-loading-1 > 0) { + + 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]) { + delete cover[BUFFERSIZE-loading-1]; + cover[BUFFERSIZE-loading-1] = NULL; + } + cover[BUFFERSIZE-loading-1] = new GuiImageData(NULL, 0); + cover[BUFFERSIZE-loading-1] = cover[BUFFERSIZE-loading-1-1]; + } else { + cover[BUFFERSIZE-loading-1] = cover[BUFFERSIZE-loading-1-1]; + coverImg[BUFFERSIZE-loading-1] = new GuiImage(cover[BUFFERSIZE-loading-1]); + } + } else { - cover[BUFFERSIZE-loading-1] = cover[BUFFERSIZE-loading-1-1]; - coverImg[BUFFERSIZE-loading-1] = new GuiImage(cover[BUFFERSIZE-loading-1]); - } - } else { + header = &gameList[offset]; - header = &gameList[offset]; + snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); + snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); - snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, IDfull); //Load full id image - snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, IDfull); //Load full id image - - cover[0] = new GuiImageData(imgPath,0); - if (!cover[0]->GetImage()) { - delete cover[0]; - cover[0] = NULL; - snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID); //Load short id image - cover[0] = new GuiImageData(imgPath, 0); + cover[0] = new GuiImageData(imgPath,0); if (!cover[0]->GetImage()) { delete cover[0]; cover[0] = NULL; - snprintf(imgPath, sizeof(imgPath), "%snoimage.png", Settings.covers_path); //Load no image - cover[0] = new GuiImageData(imgPath, nocover_png); + snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID); //Load short id image + cover[0] = new GuiImageData(imgPath, 0); + if (!cover[0]->GetImage()) { + delete cover[0]; + cover[0] = NULL; + snprintf(imgPath, sizeof(imgPath), "%snoimage.png", Settings.covers_path); //Load no image + cover[0] = new GuiImageData(imgPath, nocover_png); + } } + if (coverImg[0]) { + delete coverImg[0]; + coverImg[0] = NULL; + } + coverImg[0] = new GuiImage(cover[0]); } - if(coverImg[0]) { - delete coverImg[0]; - coverImg[0] = NULL; - } - coverImg[0] = new GuiImage(cover[0]); } } - } - loading++; + loading++; } loading = BUFFERSIZE; @@ -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; @@ -228,11 +224,11 @@ void HaltBufferThread() offset = 0; direction = 0; - // wait for thread to finish - while(!LWP_ThreadIsSuspended(bufferthread)) - usleep(100); + // wait for thread to finish + 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,54 +241,49 @@ void HaltBufferThread() /**************************************************************************** * ResumeBufferThread ***************************************************************************/ -void ResumeBufferThread(int offset) -{ - BufferHalt = false; +void ResumeBufferThread(int offset) { + BufferHalt = false; firstime = true; changed = true; loading = 0; 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; } NoCover[i] = new GuiImage(&NoCoverData); } - LWP_ResumeThread(bufferthread); + LWP_ResumeThread(bufferthread); } /********************************************************************************* * Bufferthread *********************************************************************************/ -static void * bufferinitcallback(void *arg) -{ - while(1) - { - if(BufferHalt) +static void * bufferinitcallback(void *arg) { + while (1) { + if (BufferHalt) LWP_SuspendThread(bufferthread); LoadImages(); } - return NULL; + return NULL; } /**************************************************************************** * InitBufferThread with priority 50 ***************************************************************************/ -void InitBufferThread() -{ - LWP_CreateThread(&bufferthread, bufferinitcallback, NULL, NULL, 0, 50); +void InitBufferThread() { + LWP_CreateThread(&bufferthread, bufferinitcallback, NULL, NULL, 0, 50); } /**************************************************************************** * ShutdownThread ***************************************************************************/ -void ShutdownBufferThread() -{ - LWP_JoinThread (bufferthread, NULL); - bufferthread = LWP_THREAD_NULL; +void ShutdownBufferThread() { + LWP_JoinThread (bufferthread, NULL); + bufferthread = LWP_THREAD_NULL; } diff --git a/source/cheats/cheatmenu.cpp b/source/cheats/cheatmenu.cpp index bb7b63f5..3c24548b 100644 --- a/source/cheats/cheatmenu.cpp +++ b/source/cheats/cheatmenu.cpp @@ -22,151 +22,140 @@ extern GuiWindow * mainWindow; /**************************************************************************** * CheatMenu ***************************************************************************/ -int CheatMenu(const char * gameID) -{ - int choice = 0; - bool exit = false; - int ret = 1; +int CheatMenu(const char * gameID) { + int choice = 0; + bool exit = false; + int ret = 1; - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); - GuiImageData settingsbg(imgPath, settings_background_png); + char imgPath[100]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); + GuiImageData settingsbg(imgPath, settings_background_png); - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiTrigger trigB; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); - GuiImage settingsbackground(&settingsbg); + GuiImage settingsbackground(&settingsbg); - 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 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}); - createBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); - GuiImage createBtnImg(&btnOutline); - GuiButton createBtn(&createBtnImg,&createBtnImg, 2, 3, 160, 400, &trigA, &btnSoundOver, &btnClick,1); - createBtn.SetLabel(&createBtnTxt); + 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); + createBtn.SetLabel(&createBtnTxt); - char txtfilename[55]; - snprintf(txtfilename,sizeof(txtfilename),"%s%s.txt",Settings.TxtCheatcodespath,gameID); - - GCTCheats c; - int check = c.openTxtfile(txtfilename); - - int download =0; - //char tmp[10]; - - - 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")); - //snprintf(tmp, sizeof(tmp), "%i",download); - - //WindowPrompt(0,tmp,tr("OK"),tr("Download Now")); - if (download==0) - download = CodeDownload(gameID); - break; - case 1: - int cntcheats = c.getCnt(); - customOptionList cheatslst(cntcheats); - GuiCustomOptionBrowser chtBrowser(400, 280, &cheatslst, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 1, 90); - chtBrowser.SetPosition(0, 90); - chtBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - chtBrowser.SetClickable(true); + char txtfilename[55]; + snprintf(txtfilename,sizeof(txtfilename),"%s%s.txt",Settings.TxtCheatcodespath,gameID); - 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); + GCTCheats c; + int check = c.openTxtfile(txtfilename); - for(int i = 0; i <= cntcheats; i++) - { - cheatslst.SetValue(i, "%s",c.getCheatName(i).c_str()); - cheatslst.SetName(i, "OFF"); - } + int download =0; + //char tmp[10]; - HaltGui(); - GuiWindow w(screenwidth, screenheight); - w.Append(&settingsbackground); - w.Append(&titleTxt); - w.Append(&backBtn); - w.Append(&createBtn); - w.Append(&chtBrowser); - mainWindow->SetState(STATE_DISABLED); - mainWindow->ChangeFocus(&w); - mainWindow->Append(&w); - ResumeGui(); - while(!exit) - { - VIDEO_WaitVSync (); + 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")); + //snprintf(tmp, sizeof(tmp), "%i",download); - ret = chtBrowser.GetClickedOption(); - if (ret != -1) - { - const char *strCheck = cheatslst.GetName(ret); - if (strncmp(strCheck,"ON",2) == 0) - { - cheatslst.SetName(ret,"%s","OFF"); - } - else if (strncmp(strCheck,"OFF",3) == 0) - { - cheatslst.SetName(ret,"%s","ON"); - } + //WindowPrompt(0,tmp,tr("OK"),tr("Download Now")); + if (download==0) + download = CodeDownload(gameID); + break; + case 1: + int cntcheats = c.getCnt(); + customOptionList cheatslst(cntcheats); + GuiCustomOptionBrowser chtBrowser(400, 280, &cheatslst, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 1, 90); + chtBrowser.SetPosition(0, 90); + chtBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + chtBrowser.SetClickable(true); + + 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++) { + cheatslst.SetValue(i, "%s",c.getCheatName(i).c_str()); + cheatslst.SetName(i, "OFF"); } - if(createBtn.GetState() == STATE_CLICKED) - { - createBtn.ResetState(); - if (cntcheats > 0) - { - int selectednrs[30]; - int x = 0; - for(int i = 0; i <= cntcheats; i++) - { - const char *strCheck = cheatslst.GetName(i); - if (strncmp(strCheck,"ON",2) == 0) - { - selectednrs[x] = i; - x++; + HaltGui(); + GuiWindow w(screenwidth, screenheight); + w.Append(&settingsbackground); + w.Append(&titleTxt); + w.Append(&backBtn); + w.Append(&createBtn); + w.Append(&chtBrowser); + mainWindow->SetState(STATE_DISABLED); + mainWindow->ChangeFocus(&w); + mainWindow->Append(&w); + ResumeGui(); + + while (!exit) { + VIDEO_WaitVSync (); + + ret = chtBrowser.GetClickedOption(); + if (ret != -1) { + const char *strCheck = cheatslst.GetName(ret); + if (strncmp(strCheck,"ON",2) == 0) { + cheatslst.SetName(ret,"%s","OFF"); + } else if (strncmp(strCheck,"OFF",3) == 0) { + cheatslst.SetName(ret,"%s","ON"); } } - string chtpath = Settings.Cheatcodespath; - string gctfname = chtpath + c.getGameID() + ".gct"; - c.createGCT(selectednrs,x,gctfname.c_str()); - WindowPrompt(tr("GCT File created"),NULL,tr("OK")); - exit = true; - break; - } else WindowPrompt(tr("Error"),tr("Could not create GCT file"),tr("OK")); + if (createBtn.GetState() == STATE_CLICKED) { + createBtn.ResetState(); + if (cntcheats > 0) { + int selectednrs[30]; + int x = 0; + for (int i = 0; i <= cntcheats; i++) { + const char *strCheck = cheatslst.GetName(i); + if (strncmp(strCheck,"ON",2) == 0) { + selectednrs[x] = i; + x++; + } + } + string chtpath = Settings.Cheatcodespath; + string gctfname = chtpath + c.getGameID() + ".gct"; + c.createGCT(selectednrs,x,gctfname.c_str()); + WindowPrompt(tr("GCT File created"),NULL,tr("OK")); + exit = true; + break; + } else WindowPrompt(tr("Error"),tr("Could not create GCT file"),tr("OK")); + + } + + if (backBtn.GetState() == STATE_CLICKED) { + backBtn.ResetState(); + exit = true; + break; + } } + HaltGui(); + mainWindow->SetState(STATE_DEFAULT); + mainWindow->Remove(&w); + ResumeGui(); - if(backBtn.GetState() == STATE_CLICKED) - { - backBtn.ResetState(); - exit = true; - break; - } - } - HaltGui(); - mainWindow->SetState(STATE_DEFAULT); - mainWindow->Remove(&w); - ResumeGui(); - - break; + break; } return choice; diff --git a/source/cheats/gct.cpp b/source/cheats/gct.cpp index 28e80fbb..e2186fda 100644 --- a/source/cheats/gct.cpp +++ b/source/cheats/gct.cpp @@ -4,236 +4,205 @@ #define OUTOFRANGE "Error:Range" -GCTCheats::GCTCheats(void) -{ - iCntCheats = 0; +GCTCheats::GCTCheats(void) { + iCntCheats = 0; } -GCTCheats::~GCTCheats(void) -{ +GCTCheats::~GCTCheats(void) { } -int GCTCheats::getCnt() -{ - return iCntCheats; +int GCTCheats::getCnt() { + return iCntCheats; } -string GCTCheats::getGameName(void) -{ - return sGameTitle; +string GCTCheats::getGameName(void) { + return sGameTitle; } -string GCTCheats::getGameID(void) -{ - return sGameID; +string GCTCheats::getGameID(void) { + return sGameID; } -string GCTCheats::getCheat(int nr) -{ - if (nr <= (iCntCheats-1)) - { - return sCheats[nr]; - } - else - { - return OUTOFRANGE;//"Error: CheatNr out of range"; - } +string GCTCheats::getCheat(int nr) { + if (nr <= (iCntCheats-1)) { + return sCheats[nr]; + } else { + return OUTOFRANGE;//"Error: CheatNr out of range"; + } } -string GCTCheats::getCheatName(int nr) -{ - if (nr <= (iCntCheats-1)) - { - return sCheatName[nr]; - } - else - { - return "Error: CheatNr out of range"; - } +string GCTCheats::getCheatName(int nr) { + if (nr <= (iCntCheats-1)) { + return sCheatName[nr]; + } else { + return "Error: CheatNr out of range"; + } } -string GCTCheats::getCheatComment(int nr) -{ - if (nr <= (iCntCheats-1)) - { - return sCheatComment[nr]; - } - else - { - return "Error: CheatNr out of range"; - } +string GCTCheats::getCheatComment(int nr) { + if (nr <= (iCntCheats-1)) { + return sCheatComment[nr]; + } else { + return "Error: CheatNr out of range"; + } } -int GCTCheats::createGCT(int nr,const char * filename) -{ - ofstream filestr; - filestr.open(filename); +int GCTCheats::createGCT(int nr,const char * filename) { + ofstream filestr; + filestr.open(filename); - if (filestr.fail()) - return 0; + if (filestr.fail()) + return 0; - //Reversed Header and Footer - char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde}; - char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + //Reversed Header and Footer + char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde}; + char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - string buf = getCheat(nr); - filestr.write(header,sizeof(header)); + string buf = getCheat(nr); + filestr.write(header,sizeof(header)); - int x = 0; - long int li; - int len = buf.size(); + int x = 0; + long int li; + int len = buf.size(); - while (x < len) - { - string temp = buf.substr(x,2); - li = strtol(temp.c_str(),NULL,16); - temp = li; - filestr.write(temp.c_str(),1); - x +=2; - } - filestr.write(footer,sizeof(footer)); + while (x < len) { + string temp = buf.substr(x,2); + li = strtol(temp.c_str(),NULL,16); + temp = li; + filestr.write(temp.c_str(),1); + x +=2; + } + filestr.write(footer,sizeof(footer)); - filestr.close(); - return 1; + filestr.close(); + return 1; } -int GCTCheats::createGCT(const char * chtbuffer,const char * filename) -{ - ofstream filestr; - filestr.open(filename); +int GCTCheats::createGCT(const char * chtbuffer,const char * filename) { + ofstream filestr; + filestr.open(filename); - if (filestr.fail()) - return 0; + if (filestr.fail()) + return 0; - //Reversed Header and Footer - char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde}; - char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + //Reversed Header and Footer + char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde}; + char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - string buf = chtbuffer; - filestr.write(header,sizeof(header)); + string buf = chtbuffer; + filestr.write(header,sizeof(header)); - int x = 0; - long int li; - int len = buf.size(); + int x = 0; + long int li; + int len = buf.size(); - while (x < len) - { - string temp = buf.substr(x,2); - li = strtol(temp.c_str(),NULL,16); - temp = li; - filestr.write(temp.c_str(),1); - x +=2; - } + while (x < len) { + string temp = buf.substr(x,2); + li = strtol(temp.c_str(),NULL,16); + temp = li; + filestr.write(temp.c_str(),1); + x +=2; + } - filestr.write(footer,sizeof(footer)); + filestr.write(footer,sizeof(footer)); - filestr.close(); + 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); + ofstream filestr; + filestr.open(filename); - if (filestr.fail()) - return 0; + if (filestr.fail()) + return 0; - //Reversed Header and Footer - char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde}; - char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + //Reversed Header and Footer + char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde}; + char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - filestr.write(header,sizeof(header)); + filestr.write(header,sizeof(header)); - int c = 0; - while (c != cnt) - { - int actnr = nr[c]; - string buf = getCheat(actnr); - long int li; - int len = buf.size(); - int x = 0; + int c = 0; + while (c != cnt) { + int actnr = nr[c]; + string buf = getCheat(actnr); + long int li; + int len = buf.size(); + int x = 0; - while (x < len) - { - string temp = buf.substr(x,2); - li = strtol(temp.c_str(),NULL,16); - temp = li; - filestr.write(temp.c_str(),1); - x +=2; - } - c++; - } + while (x < len) { + string temp = buf.substr(x,2); + li = strtol(temp.c_str(),NULL,16); + temp = li; + filestr.write(temp.c_str(),1); + x +=2; + } + 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) -{ - ifstream filestr; - int i = 0; - string str; - filestr.open(filename); +int GCTCheats::openTxtfile(const char * filename) { + ifstream filestr; + int i = 0; + string str; + filestr.open(filename); - if (filestr.fail()) - return 0; + if (filestr.fail()) + return 0; - filestr.seekg(0,ios_base::end); - int size = filestr.tellg(); - if (size <= 0) return -1; - filestr.seekg(0,ios_base::beg); + filestr.seekg(0,ios_base::end); + int size = filestr.tellg(); + if (size <= 0) return -1; + filestr.seekg(0,ios_base::beg); - getline(filestr,sGameID); - getline(filestr,sGameTitle); - filestr.ignore(); + getline(filestr,sGameID); + getline(filestr,sGameTitle); + filestr.ignore(); - while(!filestr.eof()) - { + while (!filestr.eof()) { getline(filestr,sCheatName[i]); string cheatdata; bool emptyline = false; - bool isComment = false; + bool isComment = false; - do - { - getline(filestr,str,'\n'); - //cheatdata.append(str); + do { + getline(filestr,str,'\n'); + //cheatdata.append(str); - if (str == "") - { - emptyline = true; - break; - } + if (str == "") { + emptyline = true; + break; + } - if (str.size() <= 16 || str.size() > 17 ) - { - isComment = true; - printf ("%i",str.size()); - } + if (str.size() <= 16 || str.size() > 17 ) { + isComment = true; + printf ("%i",str.size()); + } - if (!isComment) - { - cheatdata.append(str); - size_t found=cheatdata.find(' '); - cheatdata.replace(found,1,""); - } else - { - sCheatComment[i] = str; - } + if (!isComment) { + cheatdata.append(str); + size_t found=cheatdata.find(' '); + cheatdata.replace(found,1,""); + } else { + sCheatComment[i] = str; + } - if (filestr.eof()) break; - } while(!emptyline); + if (filestr.eof()) break; + } while (!emptyline); - sCheats[i] = cheatdata; - i++; -} -iCntCheats = i; -filestr.close(); -return 1; + sCheats[i] = cheatdata; + i++; + } + iCntCheats = i; + filestr.close(); + return 1; } @@ -287,43 +256,38 @@ 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; + struct GCTCheats::chtentries cheatlist; + int i = 0; + cheatlist.sGameID = sGameID; + cheatlist.sGameTitle = sGameTitle; - while (i < iCntCheats) - { - cheatlist.sCheatName[i] = sCheatName[i]; - cheatlist.sCheats[i] = sCheats[i]; - i++; - } - return cheatlist; + while (i < iCntCheats) { + cheatlist.sCheatName[i] = sCheatName[i]; + cheatlist.sCheats[i] = sCheats[i]; + i++; + } + return cheatlist; } -struct GCTCheats::chtentries GCTCheats::getCheatList(const char * filename) -{ - openTxtfile(filename); - struct GCTCheats::chtentries cheatlist; - int i = 0; - cheatlist.sGameID = sGameID; - cheatlist.sGameTitle = sGameTitle; - cheatlist.iCntCheats = iCntCheats; +struct GCTCheats::chtentries GCTCheats::getCheatList(const char * filename) { + openTxtfile(filename); + struct GCTCheats::chtentries cheatlist; + int i = 0; + cheatlist.sGameID = sGameID; + cheatlist.sGameTitle = sGameTitle; + cheatlist.iCntCheats = iCntCheats; - while (i < iCntCheats) - { - cheatlist.sCheatName[i] = sCheatName[i]; - cheatlist.sCheats[i] = sCheats[i]; - i++; - } - return cheatlist; + while (i < iCntCheats) { + cheatlist.sCheatName[i] = sCheatName[i]; + cheatlist.sCheats[i] = sCheats[i]; + i++; + } + return cheatlist; } -int GCTCheats::download_txtcheat(int id) -{ +int GCTCheats::download_txtcheat(int id) { //ToDo -return 1; + return 1; } diff --git a/source/cheats/gct.h b/source/cheats/gct.h index c19fc6f0..6b2b2087 100644 --- a/source/cheats/gct.h +++ b/source/cheats/gct.h @@ -14,93 +14,90 @@ using namespace std; -struct chtentrie -{ - string sGameID; - string sGameTitle; - string sCheatName[MAXCHEATS]; - string sCheats[MAXCHEATS]; - string sCheatComment[MAXCHEATS]; - int iCntCheats; +struct chtentrie { + string sGameID; + string sGameTitle; + string sCheatName[MAXCHEATS]; + string sCheats[MAXCHEATS]; + string sCheatComment[MAXCHEATS]; + int iCntCheats; }; //!Handles Ocarina TXT Cheatfiles -class GCTCheats -{ +class GCTCheats { private: - chtentrie ccc; - string sGameID; - string sGameTitle; - string sCheatName[MAXCHEATS]; - string sCheats[MAXCHEATS]; - string sCheatComment[MAXCHEATS]; - int iCntCheats; + chtentrie ccc; + string sGameID; + string sGameTitle; + string sCheatName[MAXCHEATS]; + string sCheats[MAXCHEATS]; + string sCheatComment[MAXCHEATS]; + int iCntCheats; public: -struct chtentries -{ - string sGameID; - string sGameTitle; - string sCheatName[MAXCHEATS]; - string sCheats[MAXCHEATS]; - int iCntCheats; -}; + struct chtentries { + string sGameID; + string sGameTitle; + string sCheatName[MAXCHEATS]; + string sCheats[MAXCHEATS]; + int iCntCheats; + }; - //!Constructor - GCTCheats(void); - //!Destructor - ~GCTCheats(void); - //!Open txt file with cheats - //!\param filename name of TXT file - //!\return error code - int openTxtfile(const char * filename); - //!Creates GCT file for one cheat - //!\param nr selected Cheat Numbers - //!\param filename name of GCT file - //!\return error code - int createGCT(int nr,const char * filename); - //!Creates GCT file from a buffer - //!\param chtbuffer buffer that holds the cheat data - //!\param filename name of GCT file - //!\return error code - int createGCT(const char * chtbuffer,const char * filename); - //!Creates GCT file - //!\param nr[] array of selected Cheat Numbers - //!\param cnt size of array - //!\param filename name of GCT file - //!\return error code - int createGCT(int nr[],int cnt,const char * filename); - //!Gets Count cheats - //!\return Count cheats - int getCnt(); - //!Gets Game Name - //!\return Game Name - string getGameName(void); - //!Gets GameID - //!\return GameID - string getGameID(void); - //!Gets cheat data - //!\return cheat data - string getCheat(int nr); - //!Gets Cheat Name - //!\return Cheat Name - string getCheatName(int nr); - //!Gets Cheat Comment - //!\return Cheat Comment - string getCheatComment(int nr); - //!Gets Cheat List - //!\return struct chtentrie - //struct chtentrie getCheatList2(void); - //!Gets Cheat List - //!\return struct chtentries - struct chtentries getCheatList(void); - //!Gets Cheat List from file - //!\param filename name of TXT file - //!\return struct chtentries - struct chtentries getCheatList(const char * filename); + //!Constructor + GCTCheats(void); + //!Destructor + ~GCTCheats(void); + //!Open txt file with cheats + //!\param filename name of TXT file + //!\return error code + int openTxtfile(const char * filename); + //!Creates GCT file for one cheat + //!\param nr selected Cheat Numbers + //!\param filename name of GCT file + //!\return error code + int createGCT(int nr,const char * filename); + //!Creates GCT file from a buffer + //!\param chtbuffer buffer that holds the cheat data + //!\param filename name of GCT file + //!\return error code + int createGCT(const char * chtbuffer,const char * filename); + //!Creates GCT file + //!\param nr[] array of selected Cheat Numbers + //!\param cnt size of array + //!\param filename name of GCT file + //!\return error code + int createGCT(int nr[],int cnt,const char * filename); + //!Gets Count cheats + //!\return Count cheats + int getCnt(); + //!Gets Game Name + //!\return Game Name + string getGameName(void); + //!Gets GameID + //!\return GameID + string getGameID(void); + //!Gets cheat data + //!\return cheat data + string getCheat(int nr); + //!Gets Cheat Name + //!\return Cheat Name + string getCheatName(int nr); + //!Gets Cheat Comment + //!\return Cheat Comment + string getCheatComment(int nr); + //!Gets Cheat List + //!\return struct chtentrie + //struct chtentrie getCheatList2(void); + //!Gets Cheat List + //!\return struct chtentries + struct chtentries getCheatList(void); + //!Gets Cheat List from file + //!\param filename name of TXT file + //!\return struct chtentries + struct chtentries getCheatList(const char * filename); - int download_txtcheat(int id); + int download_txtcheat(int id); }; #endif /* _GCT_H */ diff --git a/source/fatmounter.c b/source/fatmounter.c index 4c8788e5..d098d027 100644 --- a/source/fatmounter.c +++ b/source/fatmounter.c @@ -12,51 +12,45 @@ #define CACHE 8 #define SECTORS 64 -int USBDevice_Init() -{ - //closing all open Files write back the cache and then shutdown em! - fatUnmount("USB:/"); - //right now mounts first FAT-partition - if (fatMount("USB", &__io_wiiums, 0, CACHE, SECTORS)) { - //try first mount with cIOS - return 1; +int USBDevice_Init() { + //closing all open Files write back the cache and then shutdown em! + fatUnmount("USB:/"); + //right now mounts first FAT-partition + if (fatMount("USB", &__io_wiiums, 0, CACHE, SECTORS)) { + //try first mount with cIOS + return 1; } else if (fatMount("USB", &__io_usbstorage, 0, CACHE, SECTORS)) { - //try now mount with libogc - return 1; - } - return -1; + //try now mount with libogc + return 1; + } + return -1; } -void USBDevice_deInit() -{ - //closing all open Files write back the cache and then shutdown em! - fatUnmount("USB:/"); +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)) - return 1; +int isInserted(const char *path) { + if (!strncmp(path, "USB:", 4)) + return 1; return __io_wiisd.isInserted(); } -int SDCard_Init() -{ - //closing all open Files write back the cache and then shutdown em! - fatUnmount("SD:/"); - //right now mounts first FAT-partition - if (fatMount("SD", &__io_wiisd, 0, CACHE, SECTORS)) - return 1; - return -1; +int SDCard_Init() { + //closing all open Files write back the cache and then shutdown em! + fatUnmount("SD:/"); + //right now mounts first FAT-partition + if (fatMount("SD", &__io_wiisd, 0, CACHE, SECTORS)) + return 1; + return -1; } -void SDCard_deInit() -{ - //closing all open Files write back the cache and then shutdown em! - fatUnmount("SD:/"); +void SDCard_deInit() { + //closing all open Files write back the cache and then shutdown em! + fatUnmount("SD:/"); } diff --git a/source/fatmounter.h b/source/fatmounter.h index 90154b6d..6a7370e8 100644 --- a/source/fatmounter.h +++ b/source/fatmounter.h @@ -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 } diff --git a/source/homebrewboot/BootHomebrew.c b/source/homebrewboot/BootHomebrew.c index db791fa3..ff6fcbb3 100644 --- a/source/homebrewboot/BootHomebrew.c +++ b/source/homebrewboot/BootHomebrew.c @@ -17,7 +17,7 @@ int AllocHomebrewMemory(u32 filesize) { innetbuffer = malloc(filesize); - if(!innetbuffer) + if (!innetbuffer) return -1; return 1; @@ -35,53 +35,51 @@ void CopyHomebrewMemory(u32 read, u8 *temp, u32 len) { } -int BootHomebrew(char * path) -{ - void *buffer = NULL; - u32 filesize = 0; - entrypoint entry; +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); - rewind(file); + filesize = ftell(file); + rewind(file); - buffer = malloc(filesize); + buffer = malloc(filesize); - if(fread (buffer, 1, filesize, file) != filesize) - { + if (fread (buffer, 1, filesize, file) != filesize) { fclose (file); free(buffer); SDCard_deInit(); USBDevice_deInit(); - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); - } - fclose (file); + SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); + } + fclose (file); - struct __argv args; - bzero(&args, sizeof(args)); - args.argvMagic = ARGV_MAGIC; - args.length = strlen(path) + 2; - args.commandLine = (char*)malloc(args.length); - if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); - strcpy(args.commandLine, path); - args.commandLine[args.length - 1] = '\0'; - args.argc = 1; - args.argv = &args.commandLine; - args.endARGV = args.argv + 1; + struct __argv args; + bzero(&args, sizeof(args)); + args.argvMagic = ARGV_MAGIC; + args.length = strlen(path) + 2; + args.commandLine = (char*)malloc(args.length); + if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); + strcpy(args.commandLine, path); + args.commandLine[args.length - 1] = '\0'; + args.argc = 1; + args.argv = &args.commandLine; + args.endARGV = args.argv + 1; - int ret = valid_elf_image(buffer); - if (ret == 1) - entry = (entrypoint) load_elf_image(buffer); - else - entry = (entrypoint) load_dol(buffer, &args); + int ret = valid_elf_image(buffer); + if (ret == 1) + entry = (entrypoint) load_elf_image(buffer); + else + entry = (entrypoint) load_dol(buffer, &args); free(buffer); - if(!entry) { + if (!entry) { SDCard_deInit(); USBDevice_deInit(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); @@ -95,36 +93,35 @@ int BootHomebrew(char * path) WPAD_Shutdown(); SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); - _CPU_ISR_Disable (cpu_isr); - __exception_closeall(); - entry(); - _CPU_ISR_Restore (cpu_isr); + _CPU_ISR_Disable (cpu_isr); + __exception_closeall(); + entry(); + _CPU_ISR_Restore (cpu_isr); - return 0; + return 0; } -int BootHomebrewFromMem() -{ - entrypoint entry; +int BootHomebrewFromMem() { + entrypoint entry; u32 cpu_isr; - if(!innetbuffer) { + if (!innetbuffer) { SDCard_deInit(); USBDevice_deInit(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } - struct __argv args; + struct __argv args; - int ret = valid_elf_image(innetbuffer); - if (ret == 1) - entry = (entrypoint) load_elf_image(innetbuffer); - else - entry = (entrypoint) load_dol(innetbuffer, &args); + int ret = valid_elf_image(innetbuffer); + if (ret == 1) + entry = (entrypoint) load_elf_image(innetbuffer); + else + entry = (entrypoint) load_dol(innetbuffer, &args); free(innetbuffer); - if(!entry) { + if (!entry) { SDCard_deInit(); USBDevice_deInit(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); @@ -138,10 +135,10 @@ int BootHomebrewFromMem() WPAD_Shutdown(); SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); - _CPU_ISR_Disable (cpu_isr); - __exception_closeall(); - entry(); - _CPU_ISR_Restore (cpu_isr); + _CPU_ISR_Disable (cpu_isr); + __exception_closeall(); + entry(); + _CPU_ISR_Restore (cpu_isr); - return 0; + return 0; } diff --git a/source/homebrewboot/BootHomebrew.h b/source/homebrewboot/BootHomebrew.h index f41beaf6..2b1d18bd 100644 --- a/source/homebrewboot/BootHomebrew.h +++ b/source/homebrewboot/BootHomebrew.h @@ -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 } diff --git a/source/homebrewboot/HomebrewBrowse.cpp b/source/homebrewboot/HomebrewBrowse.cpp index eac07d99..ef7b13b0 100644 --- a/source/homebrewboot/HomebrewBrowse.cpp +++ b/source/homebrewboot/HomebrewBrowse.cpp @@ -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,287 +57,285 @@ int roundup(float number) /**************************************************************************** * MenuHomebrewBrowse ***************************************************************************/ -int MenuHomebrewBrowse() -{ - int menu = MENU_NONE; - int choice = 0; +int MenuHomebrewBrowse() { + int menu = MENU_NONE; + int choice = 0; - HomebrewFiles HomebrewFiles(Settings.homebrewapps_path); + HomebrewFiles HomebrewFiles(Settings.homebrewapps_path); - u32 filecount = HomebrewFiles.GetFilecount(); + u32 filecount = HomebrewFiles.GetFilecount(); - if(!filecount) { + if (!filecount) { WindowPrompt(tr("No .dol or .elf files found."),0, tr("OK")); return MENU_DISCLIST; - } + } - enum { + enum { FADE, LEFT, RIGHT }; - if(IsNetworkInit()) + if (IsNetworkInit()) ResumeNetworkWait(); - int slidedirection = FADE; + int slidedirection = FADE; /*** Sound Variables ***/ - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); GuiSound btnClick1(button_click_pcm, button_click_pcm_size, SOUND_PCM, Settings.sfxvolume); /*** Image Variables ***/ - char imgPath[150]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); + char imgPath[150]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); - GuiImageData bgData(imgPath, settings_background_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); + GuiImageData bgData(imgPath, settings_background_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_title.png", CFG.theme_path); - GuiImageData MainButtonImgData(imgPath, settings_title_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_title.png", CFG.theme_path); + GuiImageData MainButtonImgData(imgPath, settings_title_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_title_over.png", CFG.theme_path); - GuiImageData MainButtonImgOverData(imgPath, settings_title_over_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_title_over.png", CFG.theme_path); + GuiImageData MainButtonImgOverData(imgPath, settings_title_over_png); snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path); - GuiImageData arrow_left(imgPath, startgame_arrow_left_png); + GuiImageData arrow_left(imgPath, startgame_arrow_left_png); - snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path); - GuiImageData arrow_right(imgPath, startgame_arrow_right_png); + snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path); + GuiImageData arrow_right(imgPath, startgame_arrow_right_png); - snprintf(imgPath, sizeof(imgPath), "%sWifi_btn.png", CFG.theme_path); - GuiImageData wifiImgData(imgPath, Wifi_btn_png); - - snprintf(imgPath, sizeof(imgPath), "%sChannel_btn.png", CFG.theme_path); - GuiImageData channelImgData(imgPath, Channel_btn_png); + snprintf(imgPath, sizeof(imgPath), "%sWifi_btn.png", CFG.theme_path); + GuiImageData wifiImgData(imgPath, Wifi_btn_png); + + snprintf(imgPath, sizeof(imgPath), "%sChannel_btn.png", CFG.theme_path); + GuiImageData channelImgData(imgPath, Channel_btn_png); GuiImage background(&bgData); /*** Trigger Variables ***/ GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); - GuiTrigger trigB; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); GuiTrigger trigL; - trigL.SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT); - GuiTrigger trigR; - trigR.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT); + trigL.SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT); + GuiTrigger trigR; + trigR.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT); GuiTrigger trigMinus; - trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0); - GuiTrigger trigPlus; - trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0); + trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0); + GuiTrigger trigPlus; + trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0); - GuiText titleTxt(tr("Homebrew Launcher"), 28, (GXColor){0, 0, 0, 255}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - titleTxt.SetPosition(0,40); + 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}); - backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); - GuiImage backBtnImg(&btnOutline); - if (Settings.wsprompt == yes){ + 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) { backBtnTxt.SetWidescreen(CFG.widescreen); backBtnImg.SetWidescreen(CFG.widescreen); - } - GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, &btnClick,1); - backBtn.SetLabel(&backBtnTxt); - backBtn.SetTrigger(&trigB); + } + GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, &btnClick,1); + backBtn.SetLabel(&backBtnTxt); + backBtn.SetTrigger(&trigB); - GuiButton homo(1,1); - homo.SetTrigger(&trigHome); + GuiButton homo(1,1); + homo.SetTrigger(&trigHome); - GuiImage GoLeftImg(&arrow_left); - GuiButton GoLeftBtn(GoLeftImg.GetWidth(), GoLeftImg.GetHeight()); - GoLeftBtn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - GoLeftBtn.SetPosition(25, -25); - GoLeftBtn.SetImage(&GoLeftImg); - GoLeftBtn.SetSoundOver(&btnSoundOver); - GoLeftBtn.SetSoundClick(&btnClick); - GoLeftBtn.SetEffectGrow(); - GoLeftBtn.SetTrigger(&trigA); - GoLeftBtn.SetTrigger(&trigL); - GoLeftBtn.SetTrigger(&trigMinus); + GuiImage GoLeftImg(&arrow_left); + GuiButton GoLeftBtn(GoLeftImg.GetWidth(), GoLeftImg.GetHeight()); + GoLeftBtn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + GoLeftBtn.SetPosition(25, -25); + GoLeftBtn.SetImage(&GoLeftImg); + GoLeftBtn.SetSoundOver(&btnSoundOver); + GoLeftBtn.SetSoundClick(&btnClick); + GoLeftBtn.SetEffectGrow(); + GoLeftBtn.SetTrigger(&trigA); + GoLeftBtn.SetTrigger(&trigL); + GoLeftBtn.SetTrigger(&trigMinus); - GuiImage GoRightImg(&arrow_right); - GuiButton GoRightBtn(GoRightImg.GetWidth(), GoRightImg.GetHeight()); - GoRightBtn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); - GoRightBtn.SetPosition(-25, -25); - GoRightBtn.SetImage(&GoRightImg); - GoRightBtn.SetSoundOver(&btnSoundOver); - GoRightBtn.SetSoundClick(&btnClick); - GoRightBtn.SetEffectGrow(); - GoRightBtn.SetTrigger(&trigA); - GoRightBtn.SetTrigger(&trigR); - GoRightBtn.SetTrigger(&trigPlus); + GuiImage GoRightImg(&arrow_right); + GuiButton GoRightBtn(GoRightImg.GetWidth(), GoRightImg.GetHeight()); + GoRightBtn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); + GoRightBtn.SetPosition(-25, -25); + GoRightBtn.SetImage(&GoRightImg); + GoRightBtn.SetSoundOver(&btnSoundOver); + GoRightBtn.SetSoundClick(&btnClick); + GoRightBtn.SetEffectGrow(); + GoRightBtn.SetTrigger(&trigA); + GoRightBtn.SetTrigger(&trigR); + GoRightBtn.SetTrigger(&trigPlus); char MainButtonText[50]; snprintf(MainButtonText, sizeof(MainButtonText), "%s", " "); GuiImage MainButton1Img(&MainButtonImgData); GuiImage MainButton1ImgOver(&MainButtonImgOverData); - 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}); - 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}); - MainButton1DescOverTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::SCROLL); - MainButton1DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - MainButton1DescOverTxt.SetPosition(148, 15); + 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}); + 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}); + MainButton1DescOverTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::SCROLL); + MainButton1DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + MainButton1DescOverTxt.SetPosition(148, 15); GuiButton MainButton1(MainButton1Img.GetWidth(), MainButton1Img.GetHeight()); MainButton1.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - MainButton1.SetPosition(0, 90); - MainButton1.SetImage(&MainButton1Img); - MainButton1.SetImageOver(&MainButton1ImgOver); - MainButton1.SetLabel(&MainButton1Txt); - MainButton1.SetLabel(&MainButton1DescTxt,1); - MainButton1.SetLabelOver(&MainButton1DescOverTxt,1); - MainButton1.SetSoundOver(&btnSoundOver); - MainButton1.SetSoundClick(&btnClick1); - MainButton1.SetEffectGrow(); - MainButton1.SetTrigger(&trigA); + MainButton1.SetPosition(0, 90); + MainButton1.SetImage(&MainButton1Img); + MainButton1.SetImageOver(&MainButton1ImgOver); + MainButton1.SetLabel(&MainButton1Txt); + MainButton1.SetLabel(&MainButton1DescTxt,1); + MainButton1.SetLabelOver(&MainButton1DescOverTxt,1); + MainButton1.SetSoundOver(&btnSoundOver); + MainButton1.SetSoundClick(&btnClick1); + MainButton1.SetEffectGrow(); + MainButton1.SetTrigger(&trigA); GuiImage MainButton2Img(&MainButtonImgData); GuiImage MainButton2ImgOver(&MainButtonImgOverData); - 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}); - 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}); - MainButton2DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - MainButton2DescOverTxt.SetPosition(148, 15); - MainButton2DescOverTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::SCROLL); + 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}); + 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}); + MainButton2DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + MainButton2DescOverTxt.SetPosition(148, 15); + MainButton2DescOverTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::SCROLL); GuiButton MainButton2(MainButton2Img.GetWidth(), MainButton2Img.GetHeight()); MainButton2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - MainButton2.SetPosition(0, 160); - MainButton2.SetImage(&MainButton2Img); - MainButton2.SetImageOver(&MainButton2ImgOver); - MainButton2.SetLabel(&MainButton2Txt); - MainButton2.SetLabel(&MainButton2DescTxt,1); - MainButton2.SetLabelOver(&MainButton2DescOverTxt,1); - MainButton2.SetSoundOver(&btnSoundOver); - MainButton2.SetSoundClick(&btnClick1); - MainButton2.SetEffectGrow(); - MainButton2.SetTrigger(&trigA); + MainButton2.SetPosition(0, 160); + MainButton2.SetImage(&MainButton2Img); + MainButton2.SetImageOver(&MainButton2ImgOver); + MainButton2.SetLabel(&MainButton2Txt); + MainButton2.SetLabel(&MainButton2DescTxt,1); + MainButton2.SetLabelOver(&MainButton2DescOverTxt,1); + MainButton2.SetSoundOver(&btnSoundOver); + MainButton2.SetSoundClick(&btnClick1); + MainButton2.SetEffectGrow(); + MainButton2.SetTrigger(&trigA); GuiImage MainButton3Img(&MainButtonImgData); GuiImage MainButton3ImgOver(&MainButtonImgOverData); - 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}); - 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}); - MainButton3DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - MainButton3DescOverTxt.SetPosition(148, 15); - MainButton3DescOverTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::SCROLL); + 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}); + 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 }); + MainButton3DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + MainButton3DescOverTxt.SetPosition(148, 15); + MainButton3DescOverTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::SCROLL); GuiButton MainButton3(MainButton3Img.GetWidth(), MainButton3Img.GetHeight()); MainButton3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - MainButton3.SetPosition(0, 230); - MainButton3.SetImage(&MainButton3Img); - MainButton3.SetImageOver(&MainButton3ImgOver); - MainButton3.SetLabel(&MainButton3Txt); - MainButton3.SetLabel(&MainButton3DescTxt,1); - MainButton3.SetLabelOver(&MainButton3DescOverTxt,1); - MainButton3.SetSoundOver(&btnSoundOver); - MainButton3.SetSoundClick(&btnClick1); - MainButton3.SetEffectGrow(); - MainButton3.SetTrigger(&trigA); + MainButton3.SetPosition(0, 230); + MainButton3.SetImage(&MainButton3Img); + MainButton3.SetImageOver(&MainButton3ImgOver); + MainButton3.SetLabel(&MainButton3Txt); + MainButton3.SetLabel(&MainButton3DescTxt,1); + MainButton3.SetLabelOver(&MainButton3DescOverTxt,1); + MainButton3.SetSoundOver(&btnSoundOver); + MainButton3.SetSoundClick(&btnClick1); + MainButton3.SetEffectGrow(); + MainButton3.SetTrigger(&trigA); GuiImage MainButton4Img(&MainButtonImgData); GuiImage MainButton4ImgOver(&MainButtonImgOverData); - 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}); - 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}); - MainButton4DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - MainButton4DescOverTxt.SetPosition(148, 15); - MainButton4DescOverTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::SCROLL); + 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}); + 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}); + MainButton4DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + MainButton4DescOverTxt.SetPosition(148, 15); + MainButton4DescOverTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::SCROLL); GuiButton MainButton4(MainButton4Img.GetWidth(), MainButton4Img.GetHeight()); MainButton4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - MainButton4.SetPosition(0, 300); - MainButton4.SetImage(&MainButton4Img); - MainButton4.SetImageOver(&MainButton4ImgOver); - MainButton4.SetLabel(&MainButton4Txt); - MainButton4.SetLabel(&MainButton4DescTxt,1); - MainButton4.SetLabelOver(&MainButton4DescOverTxt,1); - MainButton4.SetSoundOver(&btnSoundOver); - MainButton4.SetSoundClick(&btnClick1); - MainButton4.SetEffectGrow(); - MainButton4.SetTrigger(&trigA); + MainButton4.SetPosition(0, 300); + MainButton4.SetImage(&MainButton4Img); + MainButton4.SetImageOver(&MainButton4ImgOver); + MainButton4.SetLabel(&MainButton4Txt); + MainButton4.SetLabel(&MainButton4DescTxt,1); + MainButton4.SetLabelOver(&MainButton4DescOverTxt,1); + MainButton4.SetSoundOver(&btnSoundOver); + MainButton4.SetSoundClick(&btnClick1); + MainButton4.SetEffectGrow(); + MainButton4.SetTrigger(&trigA); - GuiImage wifiImg(&wifiImgData); - if (Settings.wsprompt == yes){ + GuiImage wifiImg(&wifiImgData); + if (Settings.wsprompt == yes) { wifiImg.SetWidescreen(CFG.widescreen); - } - GuiButton wifiBtn(wifiImg.GetWidth(), wifiImg.GetHeight()); - wifiBtn.SetImage(&wifiImg); - wifiBtn.SetPosition(500, 400); - wifiBtn.SetSoundOver(&btnSoundOver); - wifiBtn.SetSoundClick(&btnClick1); - wifiBtn.SetEffectGrow(); - wifiBtn.SetAlpha(80); - wifiBtn.SetTrigger(&trigA); - - GuiImage channelBtnImg(&channelImgData); - channelBtnImg.SetWidescreen(CFG.widescreen); - GuiButton channelBtn(channelBtnImg.GetWidth(), channelBtnImg.GetHeight()); - channelBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - channelBtn.SetPosition(440, 400); - channelBtn.SetImage(&channelBtnImg); - channelBtn.SetSoundOver(&btnSoundOver); - channelBtn.SetSoundClick(&btnClick); - channelBtn.SetEffectGrow(); - channelBtn.SetTrigger(&trigA); - - GuiTooltip * titleTT = NULL; + } + GuiButton wifiBtn(wifiImg.GetWidth(), wifiImg.GetHeight()); + wifiBtn.SetImage(&wifiImg); + wifiBtn.SetPosition(500, 400); + wifiBtn.SetSoundOver(&btnSoundOver); + wifiBtn.SetSoundClick(&btnClick1); + wifiBtn.SetEffectGrow(); + wifiBtn.SetAlpha(80); + wifiBtn.SetTrigger(&trigA); + + GuiImage channelBtnImg(&channelImgData); + channelBtnImg.SetWidescreen(CFG.widescreen); + GuiButton channelBtn(channelBtnImg.GetWidth(), channelBtnImg.GetHeight()); + channelBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + channelBtn.SetPosition(440, 400); + channelBtn.SetImage(&channelBtnImg); + channelBtn.SetSoundOver(&btnSoundOver); + channelBtn.SetSoundClick(&btnClick); + channelBtn.SetEffectGrow(); + channelBtn.SetTrigger(&trigA); + + GuiTooltip * titleTT = NULL; - GuiWindow w(screenwidth, screenheight); + GuiWindow w(screenwidth, screenheight); - /*** XML Variables ***/ + /*** XML Variables ***/ HomebrewXML XMLInfo[4]; - int pageToDisplay = 1; - const int pages = roundup(filecount/4.0f); - bool wifi_btn_loaded=false; + int pageToDisplay = 1; + const int pages = roundup(filecount/4.0f); + bool wifi_btn_loaded=false; - while (menu == MENU_NONE) //set pageToDisplay to 0 to quit - { - VIDEO_WaitVSync (); + while (menu == MENU_NONE) { //set pageToDisplay to 0 to quit + VIDEO_WaitVSync (); - menu = MENU_NONE; - bool changed = false; - int fileoffset = pageToDisplay*4-4; + menu = MENU_NONE; + bool changed = false; + int fileoffset = pageToDisplay*4-4; /** Standard procedure made in all pages **/ MainButton1.StopEffect(); @@ -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,89 +412,89 @@ 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) { - snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset)); - 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()); - MainButton1DescTxt.SetText(MainButtonText); - MainButton1DescOverTxt.SetText(MainButtonText); - } else { - snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset)); - shortpath = strrchr(temp, '/'); - snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset)); - XMLInfo[0].SetName(MainButtonText); - MainButton1Txt.SetText(MainButtonText); - snprintf(MainButtonText, sizeof(MainButtonText), " "); - MainButton1DescTxt.SetText(MainButtonText); - MainButton1DescOverTxt.SetText(MainButtonText); - } + if (buttonsleft > 0) { + snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset)); + 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()); + MainButton1DescTxt.SetText(MainButtonText); + MainButton1DescOverTxt.SetText(MainButtonText); + } else { + snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset)); + shortpath = strrchr(temp, '/'); + snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset)); + XMLInfo[0].SetName(MainButtonText); + MainButton1Txt.SetText(MainButtonText); + snprintf(MainButtonText, sizeof(MainButtonText), " "); + MainButton1DescTxt.SetText(MainButtonText); + MainButton1DescOverTxt.SetText(MainButtonText); + } w.Append(&MainButton1); } - if(buttonsleft > 1) { - snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1)); - 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()); - MainButton2DescTxt.SetText(MainButtonText); - MainButton2DescOverTxt.SetText(MainButtonText); - } else { - snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1)); - shortpath = strrchr(temp, '/'); - snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1)); - XMLInfo[1].SetName(MainButtonText); - MainButton2Txt.SetText(MainButtonText); - snprintf(MainButtonText, sizeof(MainButtonText), " "); - MainButton2DescTxt.SetText(MainButtonText); - MainButton2DescOverTxt.SetText(MainButtonText); - } + if (buttonsleft > 1) { + snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1)); + 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()); + MainButton2DescTxt.SetText(MainButtonText); + MainButton2DescOverTxt.SetText(MainButtonText); + } else { + snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1)); + shortpath = strrchr(temp, '/'); + snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1)); + XMLInfo[1].SetName(MainButtonText); + MainButton2Txt.SetText(MainButtonText); + snprintf(MainButtonText, sizeof(MainButtonText), " "); + MainButton2DescTxt.SetText(MainButtonText); + MainButton2DescOverTxt.SetText(MainButtonText); + } w.Append(&MainButton2); } - if(buttonsleft > 2) { - snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2)); - 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()); - MainButton3DescTxt.SetText(MainButtonText); - MainButton3DescOverTxt.SetText(MainButtonText); - } else { - snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2)); - shortpath = strrchr(temp, '/'); - snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2)); - XMLInfo[2].SetName(MainButtonText); - MainButton3Txt.SetText(MainButtonText); - snprintf(MainButtonText, sizeof(MainButtonText), " "); - MainButton3DescTxt.SetText(MainButtonText); - MainButton3DescOverTxt.SetText(MainButtonText); - } + if (buttonsleft > 2) { + snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2)); + 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()); + MainButton3DescTxt.SetText(MainButtonText); + MainButton3DescOverTxt.SetText(MainButtonText); + } else { + snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2)); + shortpath = strrchr(temp, '/'); + snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2)); + XMLInfo[2].SetName(MainButtonText); + MainButton3Txt.SetText(MainButtonText); + snprintf(MainButtonText, sizeof(MainButtonText), " "); + MainButton3DescTxt.SetText(MainButtonText); + MainButton3DescOverTxt.SetText(MainButtonText); + } 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) { - snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName()); - MainButton4Txt.SetText(MainButtonText); - snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription()); - MainButton4DescTxt.SetText(MainButtonText); - MainButton4DescOverTxt.SetText(MainButtonText); - } else { - snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3)); - shortpath = strrchr(temp, '/'); - snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3)); - XMLInfo[3].SetName(MainButtonText); - MainButton4Txt.SetText(MainButtonText); - snprintf(MainButtonText, sizeof(MainButtonText), " "); - MainButton4DescTxt.SetText(MainButtonText); - MainButton4DescOverTxt.SetText(MainButtonText); - } + 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()); + MainButton4DescTxt.SetText(MainButtonText); + MainButton4DescOverTxt.SetText(MainButtonText); + } else { + snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3)); + shortpath = strrchr(temp, '/'); + snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3)); + XMLInfo[3].SetName(MainButtonText); + MainButton4Txt.SetText(MainButtonText); + snprintf(MainButtonText, sizeof(MainButtonText), " "); + MainButton4DescTxt.SetText(MainButtonText); + MainButton4DescOverTxt.SetText(MainButtonText); + } w.Append(&MainButton4); } } else { @@ -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,22 +612,21 @@ int MenuHomebrewBrowse() ResumeGui(); - while(MainButton1.GetEffect() > 0) usleep(50); + while (MainButton1.GetEffect() > 0) usleep(50); - while(!changed) - { - VIDEO_WaitVSync (); + while (!changed) { + VIDEO_WaitVSync (); - if(MainButton1.GetState() == STATE_CLICKED) { - char temp[200]; + if (MainButton1.GetState() == STATE_CLICKED) { + char temp[200]; char iconpath[200]; char metapath[200]; char * shortpath = NULL; - //write iconpath - snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset)); + //write iconpath + snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset)); - //write iconpath + //write iconpath snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset)); //get filesize @@ -644,142 +637,138 @@ 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) { - boothomebrew = 1; - menu = MENU_EXIT; + 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]; char * shortpath = NULL; - //write iconpath - snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1)); + //write iconpath + snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1)); - //write iconpath - snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+1)); + //write iconpath + snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+1)); - //get filesize + //get filesize u64 filesize = HomebrewFiles.GetFilesize(fileoffset+1); - //write short filename + //write short filename snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1)); shortpath = strrchr(temp, '/'); 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) { + int choice = HBCWindowPrompt(XMLInfo[1].GetName(), XMLInfo[1].GetCoder(), XMLInfo[1].GetVersion(), XMLInfo[1].GetReleasedate(), XMLInfo[1].GetLongDescription(), iconpath, filesize); + if (choice == 1) { boothomebrew = 1; - menu = MENU_EXIT; + 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]; char * shortpath = NULL; - //write iconpath - snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2)); + //write iconpath + snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2)); - //write iconpath - snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+2)); + //write iconpath + snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+2)); - //get filesize - u64 filesize = HomebrewFiles.GetFilesize(fileoffset+2); - //write short filename - snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2)); + //get filesize + u64 filesize = HomebrewFiles.GetFilesize(fileoffset+2); + //write short filename + snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2)); shortpath = strrchr(temp, '/'); 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) { + int choice = HBCWindowPrompt(XMLInfo[2].GetName(), XMLInfo[2].GetCoder(), XMLInfo[2].GetVersion(), XMLInfo[2].GetReleasedate(), XMLInfo[2].GetLongDescription(), iconpath, filesize); + if (choice == 1) { boothomebrew = 1; - menu = MENU_EXIT; + 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]; char * shortpath = NULL; - //write iconpath - snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3)); + //write iconpath + snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3)); - //write iconpath - snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+3)); + //write iconpath + snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+3)); - //get filesize + //get filesize u64 filesize = HomebrewFiles.GetFilesize(fileoffset+3); - //write short filename + //write short filename snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3)); shortpath = strrchr(temp, '/'); 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) { + int choice = HBCWindowPrompt(XMLInfo[3].GetName(), XMLInfo[3].GetCoder(), XMLInfo[3].GetVersion(), XMLInfo[3].GetReleasedate(), XMLInfo[3].GetLongDescription(), iconpath, filesize); + if (choice == 1) { boothomebrew = 1; - menu = MENU_EXIT; + menu = MENU_EXIT; snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s", HomebrewFiles.GetFilepath(fileoffset+3), HomebrewFiles.GetFilename(fileoffset+3)); break; - } + } 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); @@ -848,157 +837,152 @@ int MenuHomebrewBrowse() } free(temp); ProgressStop(); - - if(read != infilesize) { + + if (read != infilesize) { WindowPrompt(tr("Error:"), tr("No data could be read."), tr("OK")); FreeHomebrewBuffer(); - } - else - { - //determine what type of file we just got - unsigned char filename[31]; - char tmptxt[31]; - - net_read(connection, &filename, 30); - sprintf(tmptxt,"%s",filename); - //if we got a 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 - GuiWindow promptWindow(472,320); - promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - promptWindow.SetPosition(0, -10); - //char imgPath[100]; - 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}); - 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}); - msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - msg2Txt.SetPosition(0,130); - promptWindow.Append(&dialogBoxImg); - promptWindow.Append(&msgTxt); - promptWindow.Append(&msg2Txt); - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&promptWindow); - mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); + } else { + //determine what type of file we just got + unsigned char filename[31]; + char tmptxt[31]; - - - //what do we want to do with the wad - //save that biatch to the wad folder - - FILE * file = fopen(tmptxt, "w"); - fwrite (innetbuffer , 1 , infilesize , file ); - fclose (file); - - HaltGui(); - mainWindow->Remove(&promptWindow); - mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); - //get it out of the memory - FreeHomebrewBuffer(); - - //check and make sure the wad we just saved is the correct size - u32 lSize; - file = fopen(tmptxt, "rb"); - - // obtain file size: - fseek (file , 0 , SEEK_END); - lSize = ftell (file); - - rewind (file); - 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); - if (pick==2)Wad_Uninstall(file); - } - //close that beast, we're done with it - fclose (file); - - //do we want to keep the file in the wad folder - if (WindowPrompt(tr("Delete ?"), tmptxt, tr("Delete"),tr("Keep"))!=0) - remove(tmptxt); - - - } - else if(strstr(tmptxt,".dol") || strstr(tmptxt,".DOL") || - strstr(tmptxt,".elf") || strstr(tmptxt,".ELF")){ - boothomebrew = 2; - menu = MENU_EXIT; - CloseConnection(); - break; - } - } + net_read(connection, &filename, 30); + sprintf(tmptxt,"%s",filename); + //if we got a 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 + GuiWindow promptWindow(472,320); + promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + promptWindow.SetPosition(0, -10); + //char imgPath[100]; + 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 }); + 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}); + msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + msg2Txt.SetPosition(0,130); + promptWindow.Append(&dialogBoxImg); + promptWindow.Append(&msgTxt); + promptWindow.Append(&msg2Txt); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); + + + + //what do we want to do with the wad + //save that biatch to the wad folder + + FILE * file = fopen(tmptxt, "w"); + fwrite (innetbuffer , 1 , infilesize , file ); + fclose (file); + + HaltGui(); + mainWindow->Remove(&promptWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); + //get it out of the memory + FreeHomebrewBuffer(); + + //check and make sure the wad we just saved is the correct size + u32 lSize; + file = fopen(tmptxt, "rb"); + + // obtain file size: + fseek (file , 0 , SEEK_END); + lSize = ftell (file); + + rewind (file); + 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); + if (pick==2)Wad_Uninstall(file); + } + //close that beast, we're done with it + fclose (file); + + //do we want to keep the file in the wad folder + if (WindowPrompt(tr("Delete ?"), tmptxt, tr("Delete"),tr("Keep"))!=0) + remove(tmptxt); + + + } else if (strstr(tmptxt,".dol") || strstr(tmptxt,".DOL") || + strstr(tmptxt,".elf") || strstr(tmptxt,".ELF")) { + boothomebrew = 2; + menu = MENU_EXIT; + CloseConnection(); + break; + } + } } } CloseConnection(); ResumeNetworkWait(); } - - 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; - TitleBrowser(num); - //if they didn't boot a channel reset this window - w.SetState(STATE_DEFAULT); - channelBtn.ResetState(); - - - } - - if(IsNetworkInit()) { - if(!wifi_btn_loaded) - { - wifiBtn.SetAlpha(255); - - titleTT = new GuiTooltip(GetNetworkIP()); - titleTT->SetAlpha(THEME.tooltipAlpha); - wifiBtn.SetToolTip(titleTT,0,-50,0,5); - wifi_btn_loaded=true; - } + + 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; + TitleBrowser(num); + //if they didn't boot a channel reset this window + w.SetState(STATE_DEFAULT); + channelBtn.ResetState(); + + + } + + if (IsNetworkInit()) { + if (!wifi_btn_loaded) { + wifiBtn.SetAlpha(255); + + titleTT = new GuiTooltip(GetNetworkIP()); + titleTT->SetAlpha(THEME.tooltipAlpha); + wifiBtn.SetToolTip(titleTT,0,-50,0,5); + wifi_btn_loaded=true; + } } } - } + } - w.SetEffect(EFFECT_FADE, -20); - while(w.GetEffect()>0) usleep(50); + w.SetEffect(EFFECT_FADE, -20); + while (w.GetEffect()>0) usleep(50); - HaltGui(); + 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; } } - - delete titleTT; - titleTT = NULL; - if(IsNetworkInit()) + delete titleTT; + titleTT = NULL; + + if (IsNetworkInit()) HaltNetworkThread(); - mainWindow->RemoveAll(); - mainWindow->Append(bgImg); + mainWindow->RemoveAll(); + mainWindow->Append(bgImg); - ResumeGui(); + ResumeGui(); - return menu; + return menu; } diff --git a/source/homebrewboot/HomebrewFiles.cpp b/source/homebrewboot/HomebrewFiles.cpp index a3ff0551..70cd33c2 100644 --- a/source/homebrewboot/HomebrewFiles.cpp +++ b/source/homebrewboot/HomebrewFiles.cpp @@ -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; @@ -78,49 +74,43 @@ bool HomebrewFiles::LoadPath(const char * folderpath) filecount++; } } - } - dirclose(dir); + } + dirclose(dir); 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); + return stricmp((char *) ab->FilePath, (char *) bb->FilePath); } -void HomebrewFiles::SortList() -{ +void HomebrewFiles::SortList() { qsort(FileInfo, filecount, sizeof(FileInfos), ListCompare); } diff --git a/source/homebrewboot/HomebrewFiles.h b/source/homebrewboot/HomebrewFiles.h index 4fd0082d..ecdb9936 100644 --- a/source/homebrewboot/HomebrewFiles.h +++ b/source/homebrewboot/HomebrewFiles.h @@ -13,33 +13,32 @@ typedef struct { unsigned int FileSize; } FileInfos; -class HomebrewFiles -{ - public: - //!Constructor - //!\param path Path where to check for homebrew files - HomebrewFiles(const char * path); - //!Destructor - ~HomebrewFiles(); - //! Load the dol/elf list of a path - //!\param path Path where to check for homebrew files - bool LoadPath(const char * path); - //! Get the a filename of the list - //!\param list index - char * GetFilename(int index); - //! Get the a filepath of the list - //!\param list index - char * GetFilepath(int index); - //! Get the a filesize of the list - //!\param list index - unsigned int GetFilesize(int index); - //! Get the filecount of the whole list - int GetFilecount(); - //! Sort list by filepath - void SortList(); - protected: - int filecount; - FileInfos *FileInfo; +class HomebrewFiles { +public: + //!Constructor + //!\param path Path where to check for homebrew files + HomebrewFiles(const char * path); + //!Destructor + ~HomebrewFiles(); + //! Load the dol/elf list of a path + //!\param path Path where to check for homebrew files + bool LoadPath(const char * path); + //! Get the a filename of the list + //!\param list index + char * GetFilename(int index); + //! Get the a filepath of the list + //!\param list index + char * GetFilepath(int index); + //! Get the a filesize of the list + //!\param list index + unsigned int GetFilesize(int index); + //! Get the filecount of the whole list + int GetFilecount(); + //! Sort list by filepath + void SortList(); +protected: + int filecount; + FileInfos *FileInfo; }; #endif diff --git a/source/homebrewboot/HomebrewXML.cpp b/source/homebrewboot/HomebrewXML.cpp index 528a748b..29c58724 100644 --- a/source/homebrewboot/HomebrewXML.cpp +++ b/source/homebrewboot/HomebrewXML.cpp @@ -9,8 +9,7 @@ #include "HomebrewXML.h" -HomebrewXML::HomebrewXML() -{ +HomebrewXML::HomebrewXML() { strcpy(name,""); strcpy(coder,""); strcpy(version,""); @@ -19,15 +18,13 @@ HomebrewXML::HomebrewXML() strcpy(longdescription,""); } -HomebrewXML::~HomebrewXML() -{ +HomebrewXML::~HomebrewXML() { } -int HomebrewXML::LoadHomebrewXMLData(const char* filename) -{ - mxml_node_t *nodedataHB = NULL; - mxml_node_t *nodetreeHB = NULL; - char tmp1[40]; +int HomebrewXML::LoadHomebrewXMLData(const char* filename) { + mxml_node_t *nodedataHB = NULL; + mxml_node_t *nodetreeHB = NULL; + char tmp1[40]; /* Load XML file */ FILE *filexml; @@ -39,14 +36,14 @@ int HomebrewXML::LoadHomebrewXMLData(const char* filename) nodetreeHB = mxmlLoadFile(NULL, filexml, MXML_NO_CALLBACK); fclose(filexml); - if (nodetreeHB == NULL) { - return -2; + if (nodetreeHB == NULL) { + return -2; } nodedataHB = mxmlFindElement(nodetreeHB, nodetreeHB, "app", NULL, NULL, MXML_DESCEND); - if (nodedataHB == NULL) { - return -5; - } + if (nodedataHB == NULL) { + return -5; + } GetTextFromNode(nodedataHB, nodedataHB, (char*) "name", NULL, NULL, MXML_DESCEND, name,sizeof(name)); GetTextFromNode(nodedataHB, nodedataHB, (char*) "coder", NULL, NULL, MXML_DESCEND, coder,sizeof(coder)); @@ -63,8 +60,8 @@ int HomebrewXML::LoadHomebrewXMLData(const char* filename) snprintf(releasedate, sizeof(releasedate), "%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[0],tmp1[1],tmp1[2],tmp1[3]); else snprintf(releasedate, sizeof(releasedate), "%s", tmp1); - free(nodedataHB); - free(nodetreeHB); + free(nodedataHB); + free(nodetreeHB); - return 1; + return 1; } diff --git a/source/homebrewboot/HomebrewXML.h b/source/homebrewboot/HomebrewXML.h index 8830db40..cb7d6266 100644 --- a/source/homebrewboot/HomebrewXML.h +++ b/source/homebrewboot/HomebrewXML.h @@ -5,37 +5,50 @@ #ifndef ___HOMEBREWXML_H_ #define ___HOMEBREWXML_H_ -class HomebrewXML -{ - public: - //!Constructor - //!\param path Path for the xml file - HomebrewXML(); - //!Destructor - ~HomebrewXML(); - //!\param filename Filepath of the XML file - int LoadHomebrewXMLData(const char* filename); - //! Get name - char * GetName() { return name; } - //! Get coder - char * GetCoder() { return coder; } - //! Get version - char * GetVersion() { return version; } - //! Get releasedate - char * GetReleasedate() { return releasedate; } - //! Get shortdescription - char * GetShortDescription() { return shortdescription; } - //! Get longdescription - char * GetLongDescription() { return longdescription; } - //! Set Name - void SetName(char * path) { strncpy(name, path, sizeof(name)); } - protected: - char name[50]; - char coder[100]; - char version[30]; - char releasedate[30]; - char shortdescription[150]; - char longdescription[500]; +class HomebrewXML { +public: + //!Constructor + //!\param path Path for the xml file + HomebrewXML(); + //!Destructor + ~HomebrewXML(); + //!\param filename Filepath of the XML file + int LoadHomebrewXMLData(const char* filename); + //! Get name + char * GetName() { + return name; + } + //! Get coder + char * GetCoder() { + return coder; + } + //! Get version + char * GetVersion() { + return version; + } + //! Get releasedate + char * GetReleasedate() { + return releasedate; + } + //! Get shortdescription + char * GetShortDescription() { + return shortdescription; + } + //! Get longdescription + char * GetLongDescription() { + return longdescription; + } + //! Set Name + void SetName(char * path) { + strncpy(name, path, sizeof(name)); + } +protected: + char name[50]; + char coder[100]; + char version[30]; + char releasedate[30]; + char shortdescription[150]; + char longdescription[500]; }; #endif diff --git a/source/homebrewboot/dolloader.c b/source/homebrewboot/dolloader.c index 06ae54b1..e19aa111 100644 --- a/source/homebrewboot/dolloader.c +++ b/source/homebrewboot/dolloader.c @@ -9,47 +9,47 @@ #include "dolloader.h" typedef struct _dolheader { - u32 text_pos[7]; - u32 data_pos[11]; - u32 text_start[7]; - u32 data_start[11]; - u32 text_size[7]; - u32 data_size[11]; - u32 bss_start; - u32 bss_size; - u32 entry_point; + u32 text_pos[7]; + u32 data_pos[11]; + u32 text_start[7]; + u32 data_start[11]; + u32 text_size[7]; + u32 data_size[11]; + u32 bss_start; + u32 bss_size; + u32 entry_point; } dolheader; u32 load_dol(void *dolstart, struct __argv *argv) { - u32 i; - dolheader *dolfile; + u32 i; + dolheader *dolfile; - if (dolstart) { - dolfile = (dolheader *) dolstart; - for (i = 0; i < 7; i++) { - if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) continue; - VIDEO_WaitVSync(); - ICInvalidateRange ((void *) dolfile->text_start[i],dolfile->text_size[i]); - memmove ((void *) dolfile->text_start[i],dolstart+dolfile->text_pos[i],dolfile->text_size[i]); - } + if (dolstart) { + dolfile = (dolheader *) dolstart; + for (i = 0; i < 7; i++) { + if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) continue; + VIDEO_WaitVSync(); + ICInvalidateRange ((void *) dolfile->text_start[i],dolfile->text_size[i]); + memmove ((void *) dolfile->text_start[i],dolstart+dolfile->text_pos[i],dolfile->text_size[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]); - DCFlushRangeNoSync ((void *) dolfile->data_start[i],dolfile->data_size[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]); + DCFlushRangeNoSync ((void *) dolfile->data_start[i],dolfile->data_size[i]); + } - memset ((void *) dolfile->bss_start, 0, dolfile->bss_size); - DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size); + memset ((void *) dolfile->bss_start, 0, dolfile->bss_size); + DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size); - if (argv && argv->argvMagic == ARGV_MAGIC) { - void *new_argv = (void *)(dolfile->entry_point + 8); - memmove(new_argv, argv, sizeof(*argv)); - DCFlushRange(new_argv, sizeof(*argv)); - } + if (argv && argv->argvMagic == ARGV_MAGIC) { + void *new_argv = (void *)(dolfile->entry_point + 8); + memmove(new_argv, argv, sizeof(*argv)); + DCFlushRange(new_argv, sizeof(*argv)); + } - return dolfile->entry_point; - } - return 0; + return dolfile->entry_point; + } + return 0; } diff --git a/source/homebrewboot/dolloader.h b/source/homebrewboot/dolloader.h index 4764c457..fdba42cb 100644 --- a/source/homebrewboot/dolloader.h +++ b/source/homebrewboot/dolloader.h @@ -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 diff --git a/source/homebrewboot/elf_abi.h b/source/homebrewboot/elf_abi.h index c9e705ef..994912ca 100644 --- a/source/homebrewboot/elf_abi.h +++ b/source/homebrewboot/elf_abi.h @@ -105,21 +105,21 @@ typedef u16 Elf32_Half; /* Unsigned medium integer */ (ehdr).e_ident[EI_MAG3] == ELFMAG3) /* ELF Header */ -typedef struct elfhdr{ - unsigned char e_ident[EI_NIDENT]; /* ELF Identification */ - Elf32_Half e_type; /* object file type */ - Elf32_Half e_machine; /* machine */ - Elf32_Word e_version; /* object file version */ - Elf32_Addr e_entry; /* virtual entry point */ - Elf32_Off e_phoff; /* program header table offset */ - Elf32_Off e_shoff; /* section header table offset */ - Elf32_Word e_flags; /* processor-specific flags */ - Elf32_Half e_ehsize; /* ELF header size */ - Elf32_Half e_phentsize; /* program header entry size */ - Elf32_Half e_phnum; /* number of program header entries */ - Elf32_Half e_shentsize; /* section header entry size */ - Elf32_Half e_shnum; /* number of section header entries */ - Elf32_Half e_shstrndx; /* section header table's "section +typedef struct elfhdr { + unsigned char e_ident[EI_NIDENT]; /* ELF Identification */ + Elf32_Half e_type; /* object file type */ + Elf32_Half e_machine; /* machine */ + Elf32_Word e_version; /* object file version */ + Elf32_Addr e_entry; /* virtual entry point */ + Elf32_Off e_phoff; /* program header table offset */ + Elf32_Off e_shoff; /* section header table offset */ + Elf32_Word e_flags; /* processor-specific flags */ + Elf32_Half e_ehsize; /* ELF header size */ + Elf32_Half e_phentsize; /* program header entry size */ + Elf32_Half e_phnum; /* number of program header entries */ + Elf32_Half e_shentsize; /* section header entry size */ + Elf32_Half e_shnum; /* number of section header entries */ + Elf32_Half e_shstrndx; /* section header table's "section header string table" entry offset */ } Elf32_Ehdr; @@ -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 */ @@ -227,17 +227,17 @@ typedef struct elfhdr{ /* Section Header */ typedef struct { - Elf32_Word sh_name; /* name - index into section header + Elf32_Word sh_name; /* name - index into section header string table section */ - Elf32_Word sh_type; /* type */ - Elf32_Word sh_flags; /* flags */ - Elf32_Addr sh_addr; /* address */ - Elf32_Off sh_offset; /* file offset */ - Elf32_Word sh_size; /* section size */ - Elf32_Word sh_link; /* section header table index link */ - Elf32_Word sh_info; /* extra information */ - Elf32_Word sh_addralign; /* address alignment */ - Elf32_Word sh_entsize; /* section entry size */ + Elf32_Word sh_type; /* type */ + Elf32_Word sh_flags; /* flags */ + Elf32_Addr sh_addr; /* address */ + Elf32_Off sh_offset; /* file offset */ + Elf32_Word sh_size; /* section size */ + Elf32_Word sh_link; /* section header table index link */ + Elf32_Word sh_info; /* extra information */ + Elf32_Word sh_addralign; /* address alignment */ + Elf32_Word sh_entsize; /* section entry size */ } Elf32_Shdr; /* Special Section Indexes */ @@ -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 */ @@ -337,12 +337,12 @@ typedef struct { /* Symbol Table Entry */ typedef struct elf32_sym { - Elf32_Word st_name; /* name - index into string table */ - Elf32_Addr st_value; /* symbol value */ - Elf32_Word st_size; /* symbol size */ - unsigned char st_info; /* type and binding */ - unsigned char st_other; /* 0 - no defined meaning */ - Elf32_Half st_shndx; /* section header index */ + Elf32_Word st_name; /* name - index into string table */ + Elf32_Addr st_value; /* symbol value */ + Elf32_Word st_size; /* symbol size */ + unsigned char st_info; /* type and binding */ + unsigned char st_other; /* 0 - no defined meaning */ + Elf32_Half st_shndx; /* section header index */ } Elf32_Sym; /* Symbol table index */ @@ -385,18 +385,16 @@ typedef struct elf32_sym { /* Relocation entry with implicit addend */ -typedef struct -{ - Elf32_Addr r_offset; /* offset of relocation */ - Elf32_Word r_info; /* symbol table index and type */ +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 -{ - Elf32_Addr r_offset; /* offset of relocation */ - Elf32_Word r_info; /* symbol table index and type */ - Elf32_Sword r_addend; +typedef struct { + Elf32_Addr r_offset; /* offset of relocation */ + Elf32_Word r_info; /* symbol table index and type */ + Elf32_Sword r_addend; } Elf32_Rela; /* Extract relocation info - r_info */ @@ -406,14 +404,14 @@ typedef struct /* Program Header */ typedef struct { - Elf32_Word p_type; /* segment type */ - Elf32_Off p_offset; /* segment offset */ - Elf32_Addr p_vaddr; /* virtual address of segment */ - Elf32_Addr p_paddr; /* physical address - ignored? */ - Elf32_Word p_filesz; /* number of bytes in file for seg. */ - Elf32_Word p_memsz; /* number of bytes in mem. for seg. */ - Elf32_Word p_flags; /* flags */ - Elf32_Word p_align; /* memory alignment */ + Elf32_Word p_type; /* segment type */ + Elf32_Off p_offset; /* segment offset */ + Elf32_Addr p_vaddr; /* virtual address of segment */ + Elf32_Addr p_paddr; /* physical address - ignored? */ + Elf32_Word p_filesz; /* number of bytes in file for seg. */ + Elf32_Word p_memsz; /* number of bytes in mem. for seg. */ + Elf32_Word p_flags; /* flags */ + Elf32_Word p_align; /* memory alignment */ } Elf32_Phdr; /* Segment types - p_type */ @@ -437,16 +435,14 @@ 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 -{ - Elf32_Sword d_tag; /* controls meaning of d_val */ - union - { - Elf32_Word d_val; /* Multiple meanings - see d_tag */ - Elf32_Addr d_ptr; /* program virtual address */ - } d_un; +typedef struct { + Elf32_Sword d_tag; /* controls meaning of d_val */ + union { + Elf32_Word d_val; /* Multiple meanings - see d_tag */ + Elf32_Addr d_ptr; /* program virtual address */ + } d_un; } Elf32_Dyn; extern Elf32_Dyn _DYNAMIC[]; @@ -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 diff --git a/source/homebrewboot/elfloader.c b/source/homebrewboot/elfloader.c index 651a1eef..d9fcdbb8 100644 --- a/source/homebrewboot/elfloader.c +++ b/source/homebrewboot/elfloader.c @@ -26,22 +26,21 @@ * 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) -{ - Elf32_Ehdr *ehdr; /* Elf header structure pointer */ +s32 valid_elf_image (void *addr) { + Elf32_Ehdr *ehdr; /* Elf header structure pointer */ - ehdr = (Elf32_Ehdr *) addr; + ehdr = (Elf32_Ehdr *) addr; - if (!IS_ELF (*ehdr)) - return 0; + if (!IS_ELF (*ehdr)) + return 0; - if (ehdr->e_type != ET_EXEC) - return -1; + if (ehdr->e_type != ET_EXEC) + return -1; - if (ehdr->e_machine != EM_PPC) - return -1; + if (ehdr->e_machine != EM_PPC) + return -1; - return 1; + return 1; } @@ -49,55 +48,54 @@ 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) -{ - Elf32_Ehdr *ehdr; - Elf32_Shdr *shdr; - u8 *strtab = 0; - u8 *image; - int i; +u32 load_elf_image (void *addr) { + Elf32_Ehdr *ehdr; + Elf32_Shdr *shdr; + u8 *strtab = 0; + u8 *image; + int i; - ehdr = (Elf32_Ehdr *) addr; - /* Find the section header string table for output info */ + ehdr = (Elf32_Ehdr *) addr; + /* Find the section header string table for output info */ + shdr = (Elf32_Shdr *) (addr + ehdr->e_shoff + + (ehdr->e_shstrndx * sizeof (Elf32_Shdr))); + + if (shdr->sh_type == SHT_STRTAB) + strtab = (u8 *) (addr + shdr->sh_offset); + + /* Load each appropriate section */ + for (i = 0; i < ehdr->e_shnum; ++i) { shdr = (Elf32_Shdr *) (addr + ehdr->e_shoff + - (ehdr->e_shstrndx * sizeof (Elf32_Shdr))); + (i * sizeof (Elf32_Shdr))); - if (shdr->sh_type == SHT_STRTAB) - strtab = (u8 *) (addr + shdr->sh_offset); - - /* Load each appropriate section */ - for (i = 0; i < ehdr->e_shnum; ++i) { - shdr = (Elf32_Shdr *) (addr + ehdr->e_shoff + - (i * sizeof (Elf32_Shdr))); - - if (!(shdr->sh_flags & SHF_ALLOC) - || shdr->sh_addr == 0 || shdr->sh_size == 0) { - continue; - } - - shdr->sh_addr &= 0x3FFFFFFF; - shdr->sh_addr |= 0x80000000; - - if (strtab) { - /*printf ("%sing section %s @ 0x%08x (0x%08x bytes)\n", - (shdr->sh_type == SHT_NOBITS) ? - "clear" : "load", - &strtab[shdr->sh_name], - (u32) shdr->sh_addr, - (u32) shdr->sh_size);*/ - } - - if (shdr->sh_type == SHT_NOBITS) { - memset ((void *) shdr->sh_addr, 0, shdr->sh_size); - } else { - image = (u8 *) addr + shdr->sh_offset; - memcpy ((void *) shdr->sh_addr, - (const void *) image, - shdr->sh_size); - } - DCFlushRangeNoSync ((void *) shdr->sh_addr, shdr->sh_size); + if (!(shdr->sh_flags & SHF_ALLOC) + || shdr->sh_addr == 0 || shdr->sh_size == 0) { + continue; } - return (ehdr->e_entry & 0x3FFFFFFF) | 0x80000000; + shdr->sh_addr &= 0x3FFFFFFF; + shdr->sh_addr |= 0x80000000; + + if (strtab) { + /*printf ("%sing section %s @ 0x%08x (0x%08x bytes)\n", + (shdr->sh_type == SHT_NOBITS) ? + "clear" : "load", + &strtab[shdr->sh_name], + (u32) shdr->sh_addr, + (u32) shdr->sh_size);*/ + } + + if (shdr->sh_type == SHT_NOBITS) { + memset ((void *) shdr->sh_addr, 0, shdr->sh_size); + } else { + image = (u8 *) addr + shdr->sh_offset; + memcpy ((void *) shdr->sh_addr, + (const void *) image, + shdr->sh_size); + } + DCFlushRangeNoSync ((void *) shdr->sh_addr, shdr->sh_size); + } + + return (ehdr->e_entry & 0x3FFFFFFF) | 0x80000000; } diff --git a/source/homebrewboot/elfloader.h b/source/homebrewboot/elfloader.h index d378fe45..3bd5799d 100644 --- a/source/homebrewboot/elfloader.h +++ b/source/homebrewboot/elfloader.h @@ -4,12 +4,11 @@ #include #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 } diff --git a/source/input.cpp b/source/input.cpp index a4ef1460..c22cc514 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -28,88 +28,74 @@ static int rumbleCount[4] = {0,0,0,0}; * ShutoffRumble ***************************************************************************/ -void ShutoffRumble() -{ - for(int i=0;i<4;i++) - { - WPAD_Rumble(i, 0); - rumbleCount[i] = 0; - } +void ShutoffRumble() { + for (int i=0;i<4;i++) { + WPAD_Rumble(i, 0); + rumbleCount[i] = 0; + } } /**************************************************************************** * DoRumble ***************************************************************************/ -void DoRumble(int i) -{ - if(rumbleRequest[i] && rumbleCount[i] < 3) - { - WPAD_Rumble(i, 1); // rumble on - rumbleCount[i]++; - } - else if(rumbleRequest[i]) - { - rumbleCount[i] = 20; - rumbleRequest[i] = 0; - } - else - { - if(rumbleCount[i]) - rumbleCount[i]--; - WPAD_Rumble(i, 0); // rumble off - } +void DoRumble(int i) { + if (rumbleRequest[i] && rumbleCount[i] < 3) { + WPAD_Rumble(i, 1); // rumble on + rumbleCount[i]++; + } else if (rumbleRequest[i]) { + rumbleCount[i] = 20; + rumbleRequest[i] = 0; + } else { + if (rumbleCount[i]) + rumbleCount[i]--; + WPAD_Rumble(i, 0); // rumble off + } } /**************************************************************************** * WPAD_Stick * - * Get X/Y value from Wii Joystick (classic, nunchuk) input + * Get X/Y value from Wii Joystick (classic, nunchuk) input ***************************************************************************/ -s8 WPAD_Stick(u8 chan, u8 right, int axis) -{ - float mag = 0.0; - float ang = 0.0; - WPADData *data = WPAD_Data(chan); +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) - { - case WPAD_EXP_NUNCHUK: - case WPAD_EXP_GUITARHERO3: - if (right == 0) - { - mag = data->exp.nunchuk.js.mag; - ang = data->exp.nunchuk.js.ang; - } - break; + switch (data->exp.type) { + case WPAD_EXP_NUNCHUK: + case WPAD_EXP_GUITARHERO3: + if (right == 0) { + mag = data->exp.nunchuk.js.mag; + ang = data->exp.nunchuk.js.ang; + } + break; - case WPAD_EXP_CLASSIC: - if (right == 0) - { - mag = data->exp.classic.ljs.mag; - ang = data->exp.classic.ljs.ang; - } - else - { - mag = data->exp.classic.rjs.mag; - ang = data->exp.classic.rjs.ang; - } - break; + case WPAD_EXP_CLASSIC: + if (right == 0) { + mag = data->exp.classic.ljs.mag; + ang = data->exp.classic.ljs.ang; + } else { + mag = data->exp.classic.rjs.mag; + ang = data->exp.classic.rjs.ang; + } + break; - default: - break; - } + default: + break; + } - /* calculate x/y value (angle need to be converted into radian) */ - if (mag > 1.0) mag = 1.0; - else if (mag < -1.0) mag = -1.0; - double val; + /* calculate x/y value (angle need to be converted into radian) */ + if (mag > 1.0) mag = 1.0; + else if (mag < -1.0) mag = -1.0; + double val; - if(axis == 0) // x-axis - val = mag * sin((PI * ang)/180.0f); - else // y-axis - val = mag * cos((PI * ang)/180.0f); + if (axis == 0) // x-axis + val = mag * sin((PI * ang)/180.0f); + else // y-axis + val = mag * cos((PI * ang)/180.0f); - return (s8)(val * 128.0f); + return (s8)(val * 128.0f); } diff --git a/source/language/UpdateLanguage.cpp b/source/language/UpdateLanguage.cpp index b80029ed..8f322836 100644 --- a/source/language/UpdateLanguage.cpp +++ b/source/language/UpdateLanguage.cpp @@ -13,57 +13,54 @@ #include "network/networkops.h" #include "network/http.h" -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; - - //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")) - { - strcpy(languageFiles[cnt],filename); - } - } - - //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()) { - //build the URL, save path, and download each file and save it - while (j #include "gettext.h" -typedef struct _MSG -{ - u32 id; - char* msgstr; - struct _MSG *next; +typedef struct _MSG { + u32 id; + char* msgstr; + struct _MSG *next; } MSG; static MSG *baseMSG=0; @@ -19,222 +18,205 @@ 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) -{ - u32 hval, g; - const char *str = 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') - { - hval <<= 4; - hval += (u8) *str++; - g = hval & ((u32) 0xf << (HASHWORDBITS - 4)); - if (g != 0) - { - hval ^= g >> (HASHWORDBITS - 8); - hval ^= g; - } + /* Compute the hash value for the given string. */ + hval = 0; + while (*str != '\0') { + hval <<= 4; + hval += (u8) *str++; + g = hval & ((u32) 0xf << (HASHWORDBITS - 4)); + if (g != 0) { + hval ^= g >> (HASHWORDBITS - 8); + hval ^= g; + } } - return hval; + return hval; } /* Expand some escape sequences found in the argument string. */ static char * -expand_escape (const char *str) -{ - char *retval, *rp; - const char *cp = str; +expand_escape (const char *str) { + char *retval, *rp; + const char *cp = str; - retval = (char *) malloc (strlen (str)+1); - if(retval==NULL) return NULL; - rp = retval; + retval = (char *) malloc (strlen (str)+1); + if (retval==NULL) return NULL; + rp = retval; - while (cp[0] != '\0' && cp[0] != '\\') - *rp++ = *cp++; - if(cp[0] == '\0') - goto terminate; - do - { - - /* Here cp[0] == '\\'. */ - switch (*++cp) - { - case '\"': /* " */ - *rp++ = '\"'; - ++cp; - break; - case 'a': /* alert */ - *rp++ = '\a'; - ++cp; - break; - case 'b': /* backspace */ - *rp++ = '\b'; - ++cp; - break; - case 'f': /* form feed */ - *rp++ = '\f'; - ++cp; - break; - case 'n': /* new line */ - *rp++ = '\n'; - ++cp; - break; - case 'r': /* carriage return */ - *rp++ = '\r'; - ++cp; - break; - case 't': /* horizontal tab */ - *rp++ = '\t'; - ++cp; - break; - case 'v': /* vertical tab */ - *rp++ = '\v'; - ++cp; - break; - case '\\': - *rp = '\\'; - ++cp; - break; - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - { - int ch = *cp++ - '0'; + while (cp[0] != '\0' && cp[0] != '\\') + *rp++ = *cp++; + if (cp[0] == '\0') + goto terminate; + do { - if (*cp >= '0' && *cp <= '7') - { - ch *= 8; - ch += *cp++ - '0'; + /* Here cp[0] == '\\'. */ + switch (*++cp) { + case '\"': /* " */ + *rp++ = '\"'; + ++cp; + break; + case 'a': /* alert */ + *rp++ = '\a'; + ++cp; + break; + case 'b': /* backspace */ + *rp++ = '\b'; + ++cp; + break; + case 'f': /* form feed */ + *rp++ = '\f'; + ++cp; + break; + case 'n': /* new line */ + *rp++ = '\n'; + ++cp; + break; + case 'r': /* carriage return */ + *rp++ = '\r'; + ++cp; + break; + case 't': /* horizontal tab */ + *rp++ = '\t'; + ++cp; + break; + case 'v': /* vertical tab */ + *rp++ = '\v'; + ++cp; + break; + case '\\': + *rp = '\\'; + ++cp; + break; + 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') - { - ch *= 8; - ch += *cp++ - '0'; - } - } - *rp = ch; - } - break; - default: - *rp = '\\'; - break; - } + if (*cp >= '0' && *cp <= '7') { + ch *= 8; + ch += *cp++ - '0'; - while (cp[0] != '\0' && cp[0] != '\\') - *rp++ = *cp++; - } - while (cp[0] != '\0'); + if (*cp >= '0' && *cp <= '7') { + ch *= 8; + ch += *cp++ - '0'; + } + } + *rp = ch; + } + break; + default: + *rp = '\\'; + break; + } - /* Terminate string. */ + while (cp[0] != '\0' && cp[0] != '\\') + *rp++ = *cp++; + } while (cp[0] != '\0'); + + /* Terminate string. */ terminate: - *rp = '\0'; - return retval; + *rp = '\0'; + return retval; } -static MSG *findMSG(u32 id) -{ - MSG *msg; - for(msg=baseMSG; msg; msg=msg->next) - { - if(msg->id == id) - return msg; - } - return NULL; +static MSG *findMSG(u32 id) { + MSG *msg; + for (msg=baseMSG; msg; msg=msg->next) { + if (msg->id == id) + return msg; + } + return NULL; } -static MSG *setMSG(const char *msgid, const char *msgstr) -{ - u32 id = hash_string(msgid); - MSG *msg = findMSG(id); - 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); - //msg->msgstr = strdup(msgstr); - msg->msgstr = expand_escape(msgstr); - } - return msg; - } - return NULL; +static MSG *setMSG(const char *msgid, const char *msgstr) { + u32 id = hash_string(msgid); + MSG *msg = findMSG(id); + 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); + //msg->msgstr = strdup(msgstr); + msg->msgstr = expand_escape(msgstr); + } + return msg; + } + return NULL; } -void gettextCleanUp(void) -{ - while(baseMSG) - { - MSG *nextMsg =baseMSG->next; - free(baseMSG->msgstr); - free(baseMSG); - baseMSG = nextMsg; - } +void gettextCleanUp(void) { + while (baseMSG) { + MSG *nextMsg =baseMSG->next; + free(baseMSG->msgstr); + free(baseMSG); + baseMSG = nextMsg; + } } -bool gettextLoadLanguage(const char* langFile) -{ - FILE *f; - char line[200]; - char *lastID=NULL; - - gettextCleanUp(); - f = fopen(langFile, "r"); - if(!f) - return false; +bool gettextLoadLanguage(const char* langFile) { + FILE *f; + char line[200]; + char *lastID=NULL; - while (fgets(line, sizeof(line), f)) - { - // lines starting with # are comments - if (line[0] == '#') - continue; - else if (strncmp(line, "msgid \"", 7) == 0) - { - char *msgid, *end; - if(lastID) { free(lastID); lastID=NULL;} - msgid = &line[7]; - end = strrchr(msgid, '"'); - if(end && end-msgid>1) - { - *end = 0; - lastID = strdup(msgid); - } - } - else if (strncmp(line, "msgstr \"", 8) == 0) - { - char *msgstr, *end; - - if(lastID == NULL) - continue; - - msgstr = &line[8]; - end = strrchr(msgstr, '"'); - if(end && end-msgstr>1) - { - *end = 0; - setMSG(lastID, msgstr); - } - free(lastID); - lastID=NULL; - } - - } + gettextCleanUp(); + f = fopen(langFile, "r"); + if (!f) + return false; - fclose(f); - return true; + while (fgets(line, sizeof(line), f)) { + // lines starting with # are comments + if (line[0] == '#') + continue; + else if (strncmp(line, "msgid \"", 7) == 0) { + char *msgid, *end; + if (lastID) { + free(lastID); + lastID=NULL; + } + msgid = &line[7]; + end = strrchr(msgid, '"'); + if (end && end-msgid>1) { + *end = 0; + lastID = strdup(msgid); + } + } else if (strncmp(line, "msgstr \"", 8) == 0) { + char *msgstr, *end; + + if (lastID == NULL) + continue; + + msgstr = &line[8]; + end = strrchr(msgstr, '"'); + if (end && end-msgstr>1) { + *end = 0; + setMSG(lastID, msgstr); + } + free(lastID); + lastID=NULL; + } + + } + + fclose(f); + return true; } -const char *gettext(const char *msgid) -{ - MSG *msg = findMSG(hash_string(msgid)); - if(msg && msg->msgstr) return msg->msgstr; - return msgid; +const char *gettext(const char *msgid) { + MSG *msg = findMSG(hash_string(msgid)); + if (msg && msg->msgstr) return msg->msgstr; + return msgid; } diff --git a/source/language/gettext.h b/source/language/gettext.h index 1a660c82..1e7ad500 100644 --- a/source/language/gettext.h +++ b/source/language/gettext.h @@ -2,18 +2,17 @@ #define _GETTEXT_H_ #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif -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); + 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); #define tr(s) gettext(s) #define trNOOP(s) (s) diff --git a/source/listfiles.c b/source/listfiles.c index aa124836..68e8acae 100644 --- a/source/listfiles.c +++ b/source/listfiles.c @@ -13,95 +13,86 @@ 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))) -{ - snprintf(temp,sizeof(temp),"%s",file->d_name); - if (!strncmpi(temp,filename,11)) - { - closedir(dir); - return true; - } - } - closedir(dir); - return false; + char temp[11]; + while ((file = readdir(dir))) { + snprintf(temp,sizeof(temp),"%s",file->d_name); + if (!strncmpi(temp,filename,11)) { + closedir(dir); + return true; + } + } + closedir(dir); + return false; } bool subfoldercreate(char * fullpath) { - //check forsubfolders - char dircheck[300]; - char dirnoslash[300]; - char * pch = NULL; - u32 cnt = 0; - struct stat st; + //check forsubfolders + char dircheck[300]; + char dirnoslash[300]; + char * pch = NULL; + u32 cnt = 0; + struct stat st; - snprintf(dirnoslash, strlen(fullpath), "%s", 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); subfoldercreate(dircheck); - }; + }; - if (mkdir(dirnoslash, 0777) == -1) { + if (mkdir(dirnoslash, 0777) == -1) { 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) -{ - /* Compare strings */ - return stricmp((char *)a, (char *)b); +s32 filenamescmp(const void *a, const void *b) { + /* Compare strings */ + return stricmp((char *)a, (char *)b); } -int GetAllDirFiles(char * filespath) -{ - int countfiles = 0; +int GetAllDirFiles(char * filespath) { + int countfiles = 0; - struct stat st; - DIR_ITER* dir; - dir = diropen (filespath); + struct stat st; + DIR_ITER* dir; + dir = diropen (filespath); - if (dir == NULL) //If empty - return 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++; - } - } - dirclose(dir); - qsort(alldirfiles, countfiles, sizeof(char[70]), filenamescmp); - return countfiles; + if (dir == NULL) //If empty + return 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++; + } + } + dirclose(dir); + qsort(alldirfiles, countfiles, sizeof(char[70]), filenamescmp); + return countfiles; } -bool checkfile(char * path) -{ +bool checkfile(char * path) { FILE * f; f = fopen(path,"r"); - if(f) { - fclose(f); - return true; + if (f) { + fclose(f); + return true; } -return false; + return false; } diff --git a/source/listfiles.h b/source/listfiles.h index ea41ee86..baadef66 100644 --- a/source/listfiles.h +++ b/source/listfiles.h @@ -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 } diff --git a/source/main.cpp b/source/main.cpp index 17d12908..b8cbfd1a 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -16,7 +16,7 @@ #include #include -#include "usbloader/wbfs.h" +#include "usbloader/wbfs.h" #include "settings/cfg.h" #include "language/gettext.h" #include "mload/mload.h" @@ -43,46 +43,41 @@ FreeTypeGX *fontSystem=0; FreeTypeGX *fontClock=0; int -main(int argc, char *argv[]) -{ - s32 ret2; +main(int argc, char *argv[]) { + s32 ret2; - bool bootDevice_found=false; - if(argc >= 1) - { - if(!strncasecmp(argv[0], "usb:/", 5)) - { - strcpy(bootDevice, "USB:"); - bootDevice_found = true; - } - else if(!strncasecmp(argv[0], "sd:/", 4)) - bootDevice_found = true; - } + bool bootDevice_found=false; + if (argc >= 1) { + if (!strncasecmp(argv[0], "usb:/", 5)) { + strcpy(bootDevice, "USB:"); + bootDevice_found = true; + } else if (!strncasecmp(argv[0], "sd:/", 4)) + bootDevice_found = true; + } ret2 = IOS_ReloadIOS(249); - if(ret2 < 0) { - ret2 = IOS_ReloadIOS(222); - load_ehc_module(); - } + if (ret2 < 0) { + ret2 = IOS_ReloadIOS(222); + load_ehc_module(); + } - SDCard_Init(); // mount SD for loading cfg's - USBDevice_Init(); // and mount USB:/ + SDCard_Init(); // mount SD for loading cfg's + USBDevice_Init(); // and mount USB:/ - 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")) - || 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:"); - } + 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")) + || 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:"); + } - gettextCleanUp(); - CFG_Load(); + gettextCleanUp(); + 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,51 +88,51 @@ 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) { + ret2 = IOS_ReloadIOS(249); + if (ret2 < 0) { Settings.cios = ios222; ret2 = IOS_ReloadIOS(222); load_ehc_module(); - } + } SDCard_Init(); // now mount SD:/ USBDevice_Init(); // and mount USB:/ - } + } - if (ret2 < 0) { - printf("ERROR: cIOS could not be loaded!"); - sleep(5); - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); - } + if (ret2 < 0) { + printf("ERROR: cIOS could not be loaded!"); + sleep(5); + SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); + } - Sys_Init(); + Sys_Init(); - /** PAD_Init has to be before InitVideo don't move that **/ + /** PAD_Init has to be before InitVideo don't move that **/ PAD_Init(); // initialize PAD/WPAD - Wpad_Init(); + Wpad_Init(); - InitVideo(); // Initialise video - InitAudio(); // Initialize audio + InitVideo(); // Initialise video + InitAudio(); // Initialize audio - WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); - WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); + WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); + WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); - // load main font from file, or default to built-in font - fontSystem = new FreeTypeGX(); - char *fontPath = NULL; - asprintf(&fontPath, "%sfont.ttf", CFG.theme_path); - fontSystem->loadFont(fontPath, font_ttf, font_ttf_size, 0); - fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); - free(fontPath); + // load main font from file, or default to built-in font + fontSystem = new FreeTypeGX(); + char *fontPath = NULL; + asprintf(&fontPath, "%sfont.ttf", CFG.theme_path); + fontSystem->loadFont(fontPath, font_ttf, font_ttf_size, 0); + fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); + free(fontPath); - fontClock = new FreeTypeGX(); - fontClock->loadFont(NULL, clock_ttf, clock_ttf_size, 0); - fontClock->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); + fontClock = new FreeTypeGX(); + fontClock->loadFont(NULL, clock_ttf, clock_ttf_size, 0); + fontClock->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); - InitGUIThreads(); - MainMenu(MENU_CHECK); - return 0; + InitGUIThreads(); + MainMenu(MENU_CHECK); + return 0; } diff --git a/source/menu.cpp b/source/menu.cpp index e2c863f8..ddea99c9 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -47,7 +47,7 @@ #include "wad/title.h" #include "usbloader/wdvd.h" - + #define MAX_CHARACTERS 38 @@ -92,10 +92,9 @@ extern bool updateavailable; * GUI setup. ***************************************************************************/ void -ResumeGui() -{ - guiHalt = false; - LWP_ResumeThread (guithread); +ResumeGui() { + guiHalt = false; + LWP_ResumeThread (guithread); } /**************************************************************************** @@ -107,13 +106,12 @@ ResumeGui() * an element that is being changed. ***************************************************************************/ void -HaltGui() -{ - guiHalt = true; +HaltGui() { + guiHalt = true; - // wait for thread to finish - while(!LWP_ThreadIsSuspended(guithread)) - usleep(50); + // wait for thread to finish + while (!LWP_ThreadIsSuspended(guithread)) + usleep(50); } /**************************************************************************** @@ -121,80 +119,71 @@ HaltGui() * * Primary thread to allow GUI to respond to state changes, and draws GUI ***************************************************************************/ -static void * UpdateGUI (void *arg) -{ - while(1) - { - if(guiHalt) - { - LWP_SuspendThread(guithread); - } - else - { - if(!ExitRequested) { - mainWindow->Draw(); - if (Settings.tooltips == TooltipsOn && THEME.showToolTip != 0 && mainWindow->GetState() != STATE_DISABLED) - mainWindow->DrawTooltip(); +static void * UpdateGUI (void *arg) { + while (1) { + if (guiHalt) { + LWP_SuspendThread(guithread); + } else { + if (!ExitRequested) { + mainWindow->Draw(); + if (Settings.tooltips == TooltipsOn && THEME.showToolTip != 0 && mainWindow->GetState() != STATE_DISABLED) + mainWindow->DrawTooltip(); - #ifdef HW_RVL - for(int i=3; i >= 0; i--) // so that player 1's cursor appears on top! - { - if(userInput[i].wpad.ir.valid) - Menu_DrawImg(userInput[i].wpad.ir.x-48, userInput[i].wpad.ir.y-48, 200.0, - 96, 96, pointer[i]->GetImage(), userInput[i].wpad.ir.angle, CFG.widescreen? 0.8 : 1, 1, 255,0,0,0,0,0,0,0,0); - if(Settings.rumble == RumbleOn) - { - DoRumble(i); - } - } - #endif +#ifdef HW_RVL + for (int i=3; i >= 0; i--) { // so that player 1's cursor appears on top! + if (userInput[i].wpad.ir.valid) + Menu_DrawImg(userInput[i].wpad.ir.x-48, userInput[i].wpad.ir.y-48, 200.0, + 96, 96, pointer[i]->GetImage(), userInput[i].wpad.ir.angle, CFG.widescreen? 0.8 : 1, 1, 255,0,0,0,0,0,0,0,0); + if (Settings.rumble == RumbleOn) { + DoRumble(i); + } + } +#endif - Menu_Render(); + Menu_Render(); - for(int i=0; i < 4; i++) - mainWindow->Update(&userInput[i]); + for (int i=0; i < 4; i++) + mainWindow->Update(&userInput[i]); - } else { - for(int a = 5; a < 255; a += 10) - { - mainWindow->Draw(); - Menu_DrawRectangle(0,0,screenwidth,screenheight,(GXColor){0, 0, 0, a},1); - Menu_Render(); - } - mainWindow->RemoveAll(); - ShutoffRumble(); - return 0; - } - } + } else { + for (int a = 5; a < 255; a += 10) { + mainWindow->Draw(); + Menu_DrawRectangle(0,0,screenwidth,screenheight,(GXColor) {0, 0, 0, a},1); + Menu_Render(); + } + mainWindow->RemoveAll(); + ShutoffRumble(); + return 0; + } + } - switch (Settings.screensaver) - { - case 1: - WPad_SetIdleTime(180); - break; - case 2: - WPad_SetIdleTime(300); - break; - case 3: - WPad_SetIdleTime(600); - break; - case 4: - WPad_SetIdleTime(1200); - break; - case 5: - WPad_SetIdleTime(1800); - break; - case 6: - WPad_SetIdleTime(3600); - break; + switch (Settings.screensaver) { + case 1: + WPad_SetIdleTime(180); + break; + case 2: + WPad_SetIdleTime(300); + break; + case 3: + WPad_SetIdleTime(600); + break; + case 4: + WPad_SetIdleTime(1200); + break; + case 5: + WPad_SetIdleTime(1800); + break; + case 6: + WPad_SetIdleTime(3600); + break; - } + } - } - return NULL; + } + return NULL; } /**************************************************************************** @@ -202,69 +191,64 @@ static void * UpdateGUI (void *arg) * * Startup GUI threads ***************************************************************************/ -void InitGUIThreads() -{ - LWP_CreateThread(&guithread, UpdateGUI, NULL, NULL, 0, 75); - InitProgressThread(); - InitBufferThread(); - InitNetworkThread(); +void InitGUIThreads() { + LWP_CreateThread(&guithread, UpdateGUI, NULL, NULL, 0, 75); + InitProgressThread(); + InitBufferThread(); + InitNetworkThread(); - if(Settings.autonetwork) + if (Settings.autonetwork) ResumeNetworkThread(); } -void ExitGUIThreads() -{ - ExitRequested = 1; - LWP_JoinThread(guithread, NULL); - guithread = LWP_THREAD_NULL; +void ExitGUIThreads() { + ExitRequested = 1; + LWP_JoinThread(guithread, NULL); + guithread = LWP_THREAD_NULL; } -void rockout(int f = 0) -{ +void rockout(int f = 0) { - HaltGui(); - int num=(f==2?-1:gameSelected); - - char imgPath[100]; - #ifdef HW_RVL - if(!(strcasestr(get_title(&gameList[num]),"guitar")|| - strcasestr(get_title(&gameList[num]),"band")|| - strcasestr(get_title(&gameList[num]),"rock")|| - f==1)){ - for(int i = 0; i < 4; i++) - delete pointer[i]; - snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); - pointer[0] = new GuiImageData(imgPath, player1_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path); - pointer[1] = new GuiImageData(imgPath, player2_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer3_point.png", CFG.theme_path); - pointer[2] = new GuiImageData(imgPath, player3_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); - pointer[3] = new GuiImageData(imgPath, player4_point_png); - } - else{ + HaltGui(); + int num=(f==2?-1:gameSelected); - for(int i = 0; i < 4; i++) - delete pointer[i]; - snprintf(imgPath, sizeof(imgPath), "%srplayer1_point.png", CFG.theme_path); - pointer[0] = new GuiImageData(imgPath, rplayer1_point_png); - snprintf(imgPath, sizeof(imgPath), "%srplayer2_point.png", CFG.theme_path); - pointer[1] = new GuiImageData(imgPath, rplayer2_point_png); - snprintf(imgPath, sizeof(imgPath), "%srplayer3_point.png", CFG.theme_path); - pointer[2] = new GuiImageData(imgPath, rplayer3_point_png); - snprintf(imgPath, sizeof(imgPath), "%srplayer4_point.png", CFG.theme_path); - pointer[3] = new GuiImageData(imgPath, rplayer4_point_png); - } - #endif - ResumeGui(); + char imgPath[100]; +#ifdef HW_RVL + if (!(strcasestr(get_title(&gameList[num]),"guitar")|| + strcasestr(get_title(&gameList[num]),"band")|| + strcasestr(get_title(&gameList[num]),"rock")|| + f==1)) { + for (int i = 0; i < 4; i++) + delete pointer[i]; + snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); + pointer[0] = new GuiImageData(imgPath, player1_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path); + pointer[1] = new GuiImageData(imgPath, player2_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer3_point.png", CFG.theme_path); + pointer[2] = new GuiImageData(imgPath, player3_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); + pointer[3] = new GuiImageData(imgPath, player4_point_png); + } else { + + for (int i = 0; i < 4; i++) + delete pointer[i]; + snprintf(imgPath, sizeof(imgPath), "%srplayer1_point.png", CFG.theme_path); + pointer[0] = new GuiImageData(imgPath, rplayer1_point_png); + snprintf(imgPath, sizeof(imgPath), "%srplayer2_point.png", CFG.theme_path); + pointer[1] = new GuiImageData(imgPath, rplayer2_point_png); + snprintf(imgPath, sizeof(imgPath), "%srplayer3_point.png", CFG.theme_path); + pointer[2] = new GuiImageData(imgPath, rplayer3_point_png); + snprintf(imgPath, sizeof(imgPath), "%srplayer4_point.png", CFG.theme_path); + pointer[3] = new GuiImageData(imgPath, rplayer4_point_png); + } +#endif + ResumeGui(); } /**************************************************************************** * MenuDiscList ***************************************************************************/ -int MenuDiscList() -{ +int MenuDiscList() { int startat = 0; int offset = 0; @@ -272,1153 +256,1094 @@ int MenuDiscList() int datagB =0; int dataed = -1; int cosa=0,sina=0; - int selectImg1 = 0; - char ID[4]; + int selectImg1 = 0; + char ID[4]; char IDfull[7]; - u32 covert = 0; - char imgPath[100]; + u32 covert = 0; + char imgPath[100]; WDVD_GetCoverStatus(&covert); - u32 covertOld=covert; + u32 covertOld=covert; - //i put this here to take care of the disappearing cursors - //at least untill we know why they go away - #ifdef HW_RVL - for(int i = 0; i < 4; i++) - delete pointer[i]; - snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); - pointer[0] = new GuiImageData(imgPath, player1_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path); - pointer[1] = new GuiImageData(imgPath, player2_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer3_point.png", CFG.theme_path); - pointer[2] = new GuiImageData(imgPath, player3_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); - pointer[3] = new GuiImageData(imgPath, player4_point_png); - #endif + //SCREENSAVER + //WPad_SetIdleTime(300); //needs the time in seconds + int check = 0; //to skip the first cycle when wiimote isn't completely connected + datagB=0; + int menu = MENU_NONE, dataef=0; + __Menu_GetEntries(); - //SCREENSAVER - //WPad_SetIdleTime(300); //needs the time in seconds - int check = 0; //to skip the first cycle when wiimote isn't completely connected + f32 freespace, used, size = 0.0; + u32 nolist; + char text[MAX_CHARACTERS + 4]; + int choice = 0, selectedold = 100; + s32 ret; - datagB=0; - int menu = MENU_NONE, dataef=0; - __Menu_GetEntries(); + //CLOCK + struct tm * timeinfo; + char theTime[80]=""; + time_t lastrawtime=0; - f32 freespace, used, size = 0.0; - u32 nolist; - char text[MAX_CHARACTERS + 4]; - int choice = 0, selectedold = 100; - s32 ret; + WBFS_DiskSpace(&used, &freespace); - //CLOCK - struct tm * timeinfo; - char theTime[80]=""; - time_t lastrawtime=0; - - WBFS_DiskSpace(&used, &freespace); - - if (!gameCnt) { //if there is no list of games to display - nolist = 1; - } - - - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - - snprintf(imgPath, sizeof(imgPath), "%sbutton_install.png", CFG.theme_path); - GuiImageData btnInstall(imgPath, button_install_png); - snprintf(imgPath, sizeof(imgPath), "%sbutton_install_over.png", CFG.theme_path); - GuiImageData btnInstallOver(imgPath, button_install_over_png); - - snprintf(imgPath, sizeof(imgPath), "%ssettings_button.png", CFG.theme_path); - GuiImageData btnSettings(imgPath, settings_button_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_button_over.png", CFG.theme_path); - GuiImageData btnSettingsOver(imgPath, settings_button_over_png); - GuiImageData dataID(&data1); - - snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff.png", CFG.theme_path); - GuiImageData btnpwroff(imgPath, wiimote_poweroff_png); - snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff_over.png", CFG.theme_path); - GuiImageData btnpwroffOver(imgPath, wiimote_poweroff_over_png); - snprintf(imgPath, sizeof(imgPath), "%smenu_button.png", CFG.theme_path); - GuiImageData btnhome(imgPath, menu_button_png); - snprintf(imgPath, sizeof(imgPath), "%smenu_button_over.png", CFG.theme_path); - GuiImageData btnhomeOver(imgPath, menu_button_over_png); - snprintf(imgPath, sizeof(imgPath), "%sSDcard_over.png", CFG.theme_path); - GuiImageData btnsdcardOver(imgPath, sdcard_over_png); - snprintf(imgPath, sizeof(imgPath), "%sSDcard.png", CFG.theme_path); - GuiImageData btnsdcard(imgPath, sdcard_png); - - - snprintf(imgPath, sizeof(imgPath), "%sbattery.png", CFG.theme_path); - GuiImageData battery(imgPath, battery_png); - snprintf(imgPath, sizeof(imgPath), "%sbattery_red.png", CFG.theme_path); - GuiImageData batteryRed(imgPath, battery_red_png); - snprintf(imgPath, sizeof(imgPath), "%sbattery_bar.png", CFG.theme_path); - GuiImageData batteryBar(imgPath, battery_bar_png); - - snprintf(imgPath, sizeof(imgPath), "%sfavIcon.png", CFG.theme_path); - GuiImageData imgfavIcon(imgPath, favIcon_png); - snprintf(imgPath, sizeof(imgPath), "%sfavIcon_gray.png", CFG.theme_path); - GuiImageData imgfavIcon_gray(imgPath, favIcon_gray_png); - snprintf(imgPath, sizeof(imgPath), "%sabcIcon.png", CFG.theme_path); - GuiImageData imgabcIcon(imgPath, abcIcon_png); - snprintf(imgPath, sizeof(imgPath), "%sabcIcon_gray.png", CFG.theme_path); - GuiImageData imgabcIcon_gray(imgPath, abcIcon_gray_png); - snprintf(imgPath, sizeof(imgPath), "%splayCountIcon.png", CFG.theme_path); - GuiImageData imgplayCountIcon(imgPath, playCountIcon_png); - snprintf(imgPath, sizeof(imgPath), "%splayCountIcon_gray.png", CFG.theme_path); - GuiImageData imgplayCountIcon_gray(imgPath, playCountIcon_gray_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeGrid.png", CFG.theme_path); - GuiImageData imgarrangeGrid(imgPath, arrangeGrid_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeGrid_gray.png", CFG.theme_path); - GuiImageData imgarrangeGrid_gray(imgPath, arrangeGrid_gray_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeList.png", CFG.theme_path); - GuiImageData imgarrangeList(imgPath, arrangeList_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeList_gray.png", CFG.theme_path); - GuiImageData imgarrangeList_gray(imgPath, arrangeList_gray_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeCarousel.png", CFG.theme_path); - GuiImageData imgarrangeCarousel(imgPath, arrangeCarousel_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeCarousel_gray.png", CFG.theme_path); - GuiImageData imgarrangeCarousel_gray(imgPath, arrangeCarousel_gray_png); - snprintf(imgPath, sizeof(imgPath), "%sbrowser.png", CFG.theme_path); - GuiImageData homebrewImgData(imgPath, browser_png); - snprintf(imgPath, sizeof(imgPath), "%sbrowser_over.png", CFG.theme_path); - GuiImageData homebrewImgDataOver(imgPath, browser_over_png); - - - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); - GuiTrigger trig2; - trig2.SetButtonOnlyTrigger(-1, WPAD_BUTTON_2 | WPAD_CLASSIC_BUTTON_X, 0); - GuiTrigger trig1; - trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1 | WPAD_CLASSIC_BUTTON_Y, 0); - - - char spaceinfo[30]; - sprintf(spaceinfo,"%.2fGB %s %.2fGB %s",freespace,tr("of"),(freespace+used),tr("free")); - GuiText usedSpaceTxt(spaceinfo, 18, (GXColor){THEME.info_r, THEME.info_g, THEME.info_b, 255}); - usedSpaceTxt.SetAlignment(THEME.hddInfoAlign, ALIGN_TOP); - usedSpaceTxt.SetPosition(THEME.hddInfo_x, THEME.hddInfo_y); - - char GamesCnt[15]; - sprintf(GamesCnt,"%s: %i",tr("Games"), gameCnt); - GuiText gamecntTxt(GamesCnt, 18, (GXColor){THEME.info_r, THEME.info_g, THEME.info_b, 255}); - gamecntTxt.SetAlignment(THEME.gameCntAlign, ALIGN_TOP); - gamecntTxt.SetPosition(THEME.gameCnt_x,THEME.gameCnt_y); - - GuiTooltip installBtnTT(tr("Install a game")); - if (Settings.wsprompt == yes) - installBtnTT.SetWidescreen(CFG.widescreen); - installBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage installBtnImg(&btnInstall); - GuiImage installBtnImgOver(&btnInstallOver); - installBtnImg.SetWidescreen(CFG.widescreen); - installBtnImgOver.SetWidescreen(CFG.widescreen); - - GuiButton installBtn(&installBtnImg, &installBtnImgOver, ALIGN_LEFT, ALIGN_TOP, THEME.install_x, THEME.install_y, &trigA, &btnSoundOver, &btnClick, 1, &installBtnTT,24,-30, 0,5); - - - GuiTooltip settingsBtnTT(tr("Settings")); - if (Settings.wsprompt == yes) - settingsBtnTT.SetWidescreen(CFG.widescreen); - settingsBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage settingsBtnImg(&btnSettings); - settingsBtnImg.SetWidescreen(CFG.widescreen); - GuiImage settingsBtnImgOver(&btnSettingsOver); - settingsBtnImgOver.SetWidescreen(CFG.widescreen); - GuiButton settingsBtn(&settingsBtnImg,&settingsBtnImgOver, 0, 3, THEME.setting_x, THEME.setting_y, &trigA, &btnSoundOver, &btnClick,1,&settingsBtnTT,65,-30,0,5); - - GuiTooltip homeBtnTT(tr("Back to HBC or Wii Menu")); - if (Settings.wsprompt == yes) - homeBtnTT.SetWidescreen(CFG.widescreen); - settingsBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage homeBtnImg(&btnhome); - homeBtnImg.SetWidescreen(CFG.widescreen); - GuiImage homeBtnImgOver(&btnhomeOver); - homeBtnImgOver.SetWidescreen(CFG.widescreen); - GuiButton homeBtn(&homeBtnImg,&homeBtnImgOver, 0, 3, THEME.home_x, THEME.home_y, &trigA, &btnSoundOver, &btnClick,1,&homeBtnTT,15,-30,1,5); - homeBtn.RemoveSoundClick(); - homeBtn.SetTrigger(&trigHome); - - GuiTooltip poweroffBtnTT(tr("Power off the Wii")); - if (Settings.wsprompt == yes) - poweroffBtnTT.SetWidescreen(CFG.widescreen); - poweroffBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage poweroffBtnImg(&btnpwroff); - GuiImage poweroffBtnImgOver(&btnpwroffOver); - poweroffBtnImg.SetWidescreen(CFG.widescreen); - poweroffBtnImgOver.SetWidescreen(CFG.widescreen); - GuiButton poweroffBtn(&poweroffBtnImg,&poweroffBtnImgOver, 0, 3, THEME.power_x, THEME.power_y, &trigA, &btnSoundOver, &btnClick,1,&poweroffBtnTT,-10,-30,1,5); - - - GuiTooltip sdcardBtnTT(tr("Reload SD")); - if (Settings.wsprompt == yes) - sdcardBtnTT.SetWidescreen(CFG.widescreen); - sdcardBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage sdcardImg(&btnsdcard); - GuiImage sdcardImgOver(&btnsdcardOver); - sdcardImg.SetWidescreen(CFG.widescreen); - sdcardImgOver.SetWidescreen(CFG.widescreen); - GuiButton sdcardBtn(&sdcardImg,&sdcardImgOver, 0, 3, THEME.sdcard_x, THEME.sdcard_y, &trigA, &btnSoundOver, &btnClick,1,&sdcardBtnTT,15,-30,0,5); - - GuiButton gameInfo(0,0); - gameInfo.SetTrigger(&trig2); - gameInfo.SetSoundClick(&btnClick); - - - GuiImage wiiBtnImg(&dataID); - wiiBtnImg.SetWidescreen(CFG.widescreen); - GuiButton wiiBtn(&wiiBtnImg,&wiiBtnImg, 0, 4, 0, -10, &trigA, &btnSoundOver, &btnClick,0); - - GuiTooltip favoriteBtnTT(tr("Display favorites")); - if (Settings.wsprompt == yes) - favoriteBtnTT.SetWidescreen(CFG.widescreen); - favoriteBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage favoriteBtnImg(&imgfavIcon); - GuiImage favoriteBtnImg_g(&imgfavIcon_gray); - favoriteBtnImg.SetWidescreen(CFG.widescreen); - favoriteBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton favoriteBtn(&favoriteBtnImg_g,&favoriteBtnImg_g, 2, 3, THEME.favorite_x, THEME.favorite_y, &trigA, &btnSoundOver, &btnClick,1, &favoriteBtnTT, -15, 52, 0, 3); - favoriteBtn.SetAlpha(180); - - GuiTooltip abcBtnTT(tr("Sort alphabetically")); - if (Settings.wsprompt == yes) - abcBtnTT.SetWidescreen(CFG.widescreen); - abcBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage abcBtnImg(&imgabcIcon); - abcBtnImg.SetWidescreen(CFG.widescreen); - GuiImage abcBtnImg_g(&imgabcIcon_gray); - abcBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton abcBtn(&abcBtnImg_g,&abcBtnImg_g, 2, 3, THEME.abc_x, THEME.abc_y, &trigA, &btnSoundOver, &btnClick,1,&abcBtnTT, -15, 52, 0, 3); - abcBtn.SetAlpha(180); - - GuiTooltip countBtnTT(tr("Sort order by most played")); - if (Settings.wsprompt == yes) - countBtnTT.SetWidescreen(CFG.widescreen); - countBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage countBtnImg(&imgplayCountIcon); - countBtnImg.SetWidescreen(CFG.widescreen); - GuiImage countBtnImg_g(&imgplayCountIcon_gray); - countBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton countBtn(&countBtnImg_g,&countBtnImg_g, 2, 3, THEME.count_x, THEME.count_y, &trigA, &btnSoundOver, &btnClick,1, &countBtnTT, -15, 52, 0, 3); - countBtn.SetAlpha(180); - - GuiTooltip listBtnTT(tr("Display as a list")); - if (Settings.wsprompt == yes) - listBtnTT.SetWidescreen(CFG.widescreen); - listBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage listBtnImg(&imgarrangeList); - listBtnImg.SetWidescreen(CFG.widescreen); - GuiImage listBtnImg_g(&imgarrangeList_gray); - listBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton listBtn(&listBtnImg_g,&listBtnImg_g, 2, 3, THEME.list_x, THEME.list_y, &trigA, &btnSoundOver, &btnClick,1, &listBtnTT, 15, 52, 1, 3); - listBtn.SetAlpha(180); - - GuiTooltip gridBtnTT(tr("Display as a grid")); - if (Settings.wsprompt == yes) - gridBtnTT.SetWidescreen(CFG.widescreen); - gridBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage gridBtnImg(&imgarrangeGrid); - gridBtnImg.SetWidescreen(CFG.widescreen); - GuiImage gridBtnImg_g(&imgarrangeGrid_gray); - gridBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton gridBtn(&gridBtnImg_g,&gridBtnImg_g, 2, 3, THEME.grid_x, THEME.grid_y, &trigA, &btnSoundOver, &btnClick,1, &gridBtnTT, 15, 52, 1, 3); - gridBtn.SetAlpha(180); - - GuiTooltip carouselBtnTT(tr("Display as a carousel")); - if (Settings.wsprompt == yes) - carouselBtnTT.SetWidescreen(CFG.widescreen); - carouselBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage carouselBtnImg(&imgarrangeCarousel); - carouselBtnImg.SetWidescreen(CFG.widescreen); - GuiImage carouselBtnImg_g(&imgarrangeCarousel_gray); - carouselBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton carouselBtn(&carouselBtnImg_g,&carouselBtnImg_g, 2, 3, THEME.carousel_x, THEME.carousel_y, &trigA, &btnSoundOver, &btnClick,1, &carouselBtnTT, 15, 52, 1, 3); - carouselBtn.SetAlpha(180); - - GuiTooltip homebrewBtnTT(tr("Homebrew Launcher")); - if (Settings.wsprompt == yes) - homebrewBtnTT.SetWidescreen(CFG.widescreen); - homebrewBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage homebrewImg(&homebrewImgData); - GuiImage homebrewImgOver(&homebrewImgDataOver); - homebrewImg.SetWidescreen(CFG.widescreen); - homebrewImgOver.SetWidescreen(CFG.widescreen); - GuiButton homebrewBtn(&homebrewImg,&homebrewImgOver, 0, 3, THEME.homebrew_x, THEME.homebrew_y, &trigA, &btnSoundOver, &btnClick,1,&homebrewBtnTT,15,-30,1,5); - - if (Settings.fave) - { - favoriteBtn.SetImage(&favoriteBtnImg); - favoriteBtn.SetImageOver(&favoriteBtnImg); - favoriteBtn.SetAlpha(255); - } - if (Settings.sort==all) - { - abcBtn.SetImage(&abcBtnImg); - abcBtn.SetImageOver(&abcBtnImg); - abcBtn.SetAlpha(255); - } - else if (Settings.sort==pcount) - { - countBtn.SetImage(&countBtnImg); - countBtn.SetImageOver(&countBtnImg); - countBtn.SetAlpha(255); - } - if (Settings.gameDisplay==list) - { - listBtn.SetImage(&listBtnImg); - listBtn.SetImageOver(&listBtnImg); - listBtn.SetAlpha(255); - } - else if (Settings.gameDisplay==grid) - { - gridBtn.SetImage(&gridBtnImg); - gridBtn.SetImageOver(&gridBtnImg); - gridBtn.SetAlpha(255); - } - else if (Settings.gameDisplay==carousel) - { - carouselBtn.SetImage(&carouselBtnImg); - carouselBtn.SetImageOver(&carouselBtnImg); - carouselBtn.SetAlpha(255); - } - if (Settings.gameDisplay==list) - { - if(CFG.widescreen) - { - favoriteBtn.SetPosition(THEME.favorite_x, THEME.favorite_y); - abcBtn.SetPosition(THEME.abc_x, THEME.abc_y); - countBtn.SetPosition(THEME.count_x, THEME.count_y); - listBtn.SetPosition(THEME.list_x, THEME.list_y); - gridBtn.SetPosition(THEME.grid_x, THEME.grid_y); - carouselBtn.SetPosition(THEME.carousel_x, THEME.carousel_y); - } - else - { - favoriteBtn.SetPosition(THEME.favorite_x-20, THEME.favorite_y); - abcBtn.SetPosition(THEME.abc_x-12, THEME.abc_y); - countBtn.SetPosition(THEME.count_x-4, THEME.count_y); - listBtn.SetPosition(THEME.list_x+4, THEME.list_y); - gridBtn.SetPosition(THEME.grid_x+12, THEME.grid_y); - carouselBtn.SetPosition(THEME.carousel_x+20, THEME.carousel_y); - } - } - else - { - if(CFG.widescreen) - { - favoriteBtn.SetPosition(THEME.favorite_x-THEME.sortBarOffset, THEME.favorite_y); - abcBtn.SetPosition(THEME.abc_x-THEME.sortBarOffset, THEME.abc_y); - countBtn.SetPosition(THEME.count_x-THEME.sortBarOffset, THEME.count_y); - listBtn.SetPosition(THEME.list_x-THEME.sortBarOffset, THEME.list_y); - gridBtn.SetPosition(THEME.grid_x-THEME.sortBarOffset, THEME.grid_y); - carouselBtn.SetPosition(THEME.carousel_x-THEME.sortBarOffset, THEME.carousel_y); - } - else - { - favoriteBtn.SetPosition(THEME.favorite_x-20-THEME.sortBarOffset, THEME.favorite_y); - abcBtn.SetPosition(THEME.abc_x-12-THEME.sortBarOffset, THEME.abc_y); - countBtn.SetPosition(THEME.count_x-4-THEME.sortBarOffset, THEME.count_y); - listBtn.SetPosition(THEME.list_x+4-THEME.sortBarOffset, THEME.list_y); - gridBtn.SetPosition(THEME.grid_x+12-THEME.sortBarOffset, THEME.grid_y); - carouselBtn.SetPosition(THEME.carousel_x+20-THEME.sortBarOffset, THEME.carousel_y); - } - } - - - //Downloading Covers - GuiTooltip DownloadBtnTT(tr("Click to Download Covers")); - if (Settings.wsprompt == yes) - DownloadBtnTT.SetWidescreen(CFG.widescreen); - DownloadBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiButton DownloadBtn(0,0); - DownloadBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - DownloadBtn.SetPosition(THEME.cover_x,THEME.cover_y); - - if (Settings.godmode == 1) - {//only make the button have trigger & tooltip if in godmode - DownloadBtn.SetSoundOver(&btnSoundOver); - DownloadBtn.SetTrigger(&trigA); - DownloadBtn.SetTrigger(&trig1); - DownloadBtn.SetToolTip(&DownloadBtnTT,205,-30); + if (!gameCnt) { //if there is no list of games to display + nolist = 1; } - else - DownloadBtn.SetRumble(false); + + + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + + snprintf(imgPath, sizeof(imgPath), "%sbutton_install.png", CFG.theme_path); + GuiImageData btnInstall(imgPath, button_install_png); + snprintf(imgPath, sizeof(imgPath), "%sbutton_install_over.png", CFG.theme_path); + GuiImageData btnInstallOver(imgPath, button_install_over_png); + + snprintf(imgPath, sizeof(imgPath), "%ssettings_button.png", CFG.theme_path); + GuiImageData btnSettings(imgPath, settings_button_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_button_over.png", CFG.theme_path); + GuiImageData btnSettingsOver(imgPath, settings_button_over_png); + GuiImageData dataID(&data1); + + snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff.png", CFG.theme_path); + GuiImageData btnpwroff(imgPath, wiimote_poweroff_png); + snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff_over.png", CFG.theme_path); + GuiImageData btnpwroffOver(imgPath, wiimote_poweroff_over_png); + snprintf(imgPath, sizeof(imgPath), "%smenu_button.png", CFG.theme_path); + GuiImageData btnhome(imgPath, menu_button_png); + snprintf(imgPath, sizeof(imgPath), "%smenu_button_over.png", CFG.theme_path); + GuiImageData btnhomeOver(imgPath, menu_button_over_png); + snprintf(imgPath, sizeof(imgPath), "%sSDcard_over.png", CFG.theme_path); + GuiImageData btnsdcardOver(imgPath, sdcard_over_png); + snprintf(imgPath, sizeof(imgPath), "%sSDcard.png", CFG.theme_path); + GuiImageData btnsdcard(imgPath, sdcard_png); + + + snprintf(imgPath, sizeof(imgPath), "%sbattery.png", CFG.theme_path); + GuiImageData battery(imgPath, battery_png); + snprintf(imgPath, sizeof(imgPath), "%sbattery_red.png", CFG.theme_path); + GuiImageData batteryRed(imgPath, battery_red_png); + snprintf(imgPath, sizeof(imgPath), "%sbattery_bar.png", CFG.theme_path); + GuiImageData batteryBar(imgPath, battery_bar_png); + + snprintf(imgPath, sizeof(imgPath), "%sfavIcon.png", CFG.theme_path); + GuiImageData imgfavIcon(imgPath, favIcon_png); + snprintf(imgPath, sizeof(imgPath), "%sfavIcon_gray.png", CFG.theme_path); + GuiImageData imgfavIcon_gray(imgPath, favIcon_gray_png); + snprintf(imgPath, sizeof(imgPath), "%sabcIcon.png", CFG.theme_path); + GuiImageData imgabcIcon(imgPath, abcIcon_png); + snprintf(imgPath, sizeof(imgPath), "%sabcIcon_gray.png", CFG.theme_path); + GuiImageData imgabcIcon_gray(imgPath, abcIcon_gray_png); + snprintf(imgPath, sizeof(imgPath), "%splayCountIcon.png", CFG.theme_path); + GuiImageData imgplayCountIcon(imgPath, playCountIcon_png); + snprintf(imgPath, sizeof(imgPath), "%splayCountIcon_gray.png", CFG.theme_path); + GuiImageData imgplayCountIcon_gray(imgPath, playCountIcon_gray_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeGrid.png", CFG.theme_path); + GuiImageData imgarrangeGrid(imgPath, arrangeGrid_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeGrid_gray.png", CFG.theme_path); + GuiImageData imgarrangeGrid_gray(imgPath, arrangeGrid_gray_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeList.png", CFG.theme_path); + GuiImageData imgarrangeList(imgPath, arrangeList_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeList_gray.png", CFG.theme_path); + GuiImageData imgarrangeList_gray(imgPath, arrangeList_gray_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeCarousel.png", CFG.theme_path); + GuiImageData imgarrangeCarousel(imgPath, arrangeCarousel_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeCarousel_gray.png", CFG.theme_path); + GuiImageData imgarrangeCarousel_gray(imgPath, arrangeCarousel_gray_png); + snprintf(imgPath, sizeof(imgPath), "%sbrowser.png", CFG.theme_path); + GuiImageData homebrewImgData(imgPath, browser_png); + snprintf(imgPath, sizeof(imgPath), "%sbrowser_over.png", CFG.theme_path); + GuiImageData homebrewImgDataOver(imgPath, browser_over_png); + + + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigHome; + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); + GuiTrigger trig2; + trig2.SetButtonOnlyTrigger(-1, WPAD_BUTTON_2 | WPAD_CLASSIC_BUTTON_X, 0); + GuiTrigger trig1; + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1 | WPAD_CLASSIC_BUTTON_Y, 0); + + + char spaceinfo[30]; + sprintf(spaceinfo,"%.2fGB %s %.2fGB %s",freespace,tr("of"),(freespace+used),tr("free")); + GuiText usedSpaceTxt(spaceinfo, 18, (GXColor) {THEME.info_r, THEME.info_g, THEME.info_b, 255}); + usedSpaceTxt.SetAlignment(THEME.hddInfoAlign, ALIGN_TOP); + usedSpaceTxt.SetPosition(THEME.hddInfo_x, THEME.hddInfo_y); + + char GamesCnt[15]; + sprintf(GamesCnt,"%s: %i",tr("Games"), gameCnt); + GuiText gamecntTxt(GamesCnt, 18, (GXColor) {THEME.info_r, THEME.info_g, THEME.info_b, 255}); + gamecntTxt.SetAlignment(THEME.gameCntAlign, ALIGN_TOP); + gamecntTxt.SetPosition(THEME.gameCnt_x,THEME.gameCnt_y); + + GuiTooltip installBtnTT(tr("Install a game")); + if (Settings.wsprompt == yes) + installBtnTT.SetWidescreen(CFG.widescreen); + installBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage installBtnImg(&btnInstall); + GuiImage installBtnImgOver(&btnInstallOver); + installBtnImg.SetWidescreen(CFG.widescreen); + installBtnImgOver.SetWidescreen(CFG.widescreen); + + GuiButton installBtn(&installBtnImg, &installBtnImgOver, ALIGN_LEFT, ALIGN_TOP, THEME.install_x, THEME.install_y, &trigA, &btnSoundOver, &btnClick, 1, &installBtnTT,24,-30, 0,5); + + + GuiTooltip settingsBtnTT(tr("Settings")); + if (Settings.wsprompt == yes) + settingsBtnTT.SetWidescreen(CFG.widescreen); + settingsBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage settingsBtnImg(&btnSettings); + settingsBtnImg.SetWidescreen(CFG.widescreen); + GuiImage settingsBtnImgOver(&btnSettingsOver); + settingsBtnImgOver.SetWidescreen(CFG.widescreen); + GuiButton settingsBtn(&settingsBtnImg,&settingsBtnImgOver, 0, 3, THEME.setting_x, THEME.setting_y, &trigA, &btnSoundOver, &btnClick,1,&settingsBtnTT,65,-30,0,5); + + GuiTooltip homeBtnTT(tr("Back to HBC or Wii Menu")); + if (Settings.wsprompt == yes) + homeBtnTT.SetWidescreen(CFG.widescreen); + settingsBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage homeBtnImg(&btnhome); + homeBtnImg.SetWidescreen(CFG.widescreen); + GuiImage homeBtnImgOver(&btnhomeOver); + homeBtnImgOver.SetWidescreen(CFG.widescreen); + GuiButton homeBtn(&homeBtnImg,&homeBtnImgOver, 0, 3, THEME.home_x, THEME.home_y, &trigA, &btnSoundOver, &btnClick,1,&homeBtnTT,15,-30,1,5); + homeBtn.RemoveSoundClick(); + homeBtn.SetTrigger(&trigHome); + + GuiTooltip poweroffBtnTT(tr("Power off the Wii")); + if (Settings.wsprompt == yes) + poweroffBtnTT.SetWidescreen(CFG.widescreen); + poweroffBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage poweroffBtnImg(&btnpwroff); + GuiImage poweroffBtnImgOver(&btnpwroffOver); + poweroffBtnImg.SetWidescreen(CFG.widescreen); + poweroffBtnImgOver.SetWidescreen(CFG.widescreen); + GuiButton poweroffBtn(&poweroffBtnImg,&poweroffBtnImgOver, 0, 3, THEME.power_x, THEME.power_y, &trigA, &btnSoundOver, &btnClick,1,&poweroffBtnTT,-10,-30,1,5); + + + GuiTooltip sdcardBtnTT(tr("Reload SD")); + if (Settings.wsprompt == yes) + sdcardBtnTT.SetWidescreen(CFG.widescreen); + sdcardBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage sdcardImg(&btnsdcard); + GuiImage sdcardImgOver(&btnsdcardOver); + sdcardImg.SetWidescreen(CFG.widescreen); + sdcardImgOver.SetWidescreen(CFG.widescreen); + GuiButton sdcardBtn(&sdcardImg,&sdcardImgOver, 0, 3, THEME.sdcard_x, THEME.sdcard_y, &trigA, &btnSoundOver, &btnClick,1,&sdcardBtnTT,15,-30,0,5); + + GuiButton gameInfo(0,0); + gameInfo.SetTrigger(&trig2); + gameInfo.SetSoundClick(&btnClick); + + + GuiImage wiiBtnImg(&dataID); + wiiBtnImg.SetWidescreen(CFG.widescreen); + GuiButton wiiBtn(&wiiBtnImg,&wiiBtnImg, 0, 4, 0, -10, &trigA, &btnSoundOver, &btnClick,0); + + GuiTooltip favoriteBtnTT(tr("Display favorites")); + if (Settings.wsprompt == yes) + favoriteBtnTT.SetWidescreen(CFG.widescreen); + favoriteBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage favoriteBtnImg(&imgfavIcon); + GuiImage favoriteBtnImg_g(&imgfavIcon_gray); + favoriteBtnImg.SetWidescreen(CFG.widescreen); + favoriteBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton favoriteBtn(&favoriteBtnImg_g,&favoriteBtnImg_g, 2, 3, THEME.favorite_x, THEME.favorite_y, &trigA, &btnSoundOver, &btnClick,1, &favoriteBtnTT, -15, 52, 0, 3); + favoriteBtn.SetAlpha(180); + + GuiTooltip abcBtnTT(tr("Sort alphabetically")); + if (Settings.wsprompt == yes) + abcBtnTT.SetWidescreen(CFG.widescreen); + abcBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage abcBtnImg(&imgabcIcon); + abcBtnImg.SetWidescreen(CFG.widescreen); + GuiImage abcBtnImg_g(&imgabcIcon_gray); + abcBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton abcBtn(&abcBtnImg_g,&abcBtnImg_g, 2, 3, THEME.abc_x, THEME.abc_y, &trigA, &btnSoundOver, &btnClick,1,&abcBtnTT, -15, 52, 0, 3); + abcBtn.SetAlpha(180); + + GuiTooltip countBtnTT(tr("Sort order by most played")); + if (Settings.wsprompt == yes) + countBtnTT.SetWidescreen(CFG.widescreen); + countBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage countBtnImg(&imgplayCountIcon); + countBtnImg.SetWidescreen(CFG.widescreen); + GuiImage countBtnImg_g(&imgplayCountIcon_gray); + countBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton countBtn(&countBtnImg_g,&countBtnImg_g, 2, 3, THEME.count_x, THEME.count_y, &trigA, &btnSoundOver, &btnClick,1, &countBtnTT, -15, 52, 0, 3); + countBtn.SetAlpha(180); + + GuiTooltip listBtnTT(tr("Display as a list")); + if (Settings.wsprompt == yes) + listBtnTT.SetWidescreen(CFG.widescreen); + listBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage listBtnImg(&imgarrangeList); + listBtnImg.SetWidescreen(CFG.widescreen); + GuiImage listBtnImg_g(&imgarrangeList_gray); + listBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton listBtn(&listBtnImg_g,&listBtnImg_g, 2, 3, THEME.list_x, THEME.list_y, &trigA, &btnSoundOver, &btnClick,1, &listBtnTT, 15, 52, 1, 3); + listBtn.SetAlpha(180); + + GuiTooltip gridBtnTT(tr("Display as a grid")); + if (Settings.wsprompt == yes) + gridBtnTT.SetWidescreen(CFG.widescreen); + gridBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage gridBtnImg(&imgarrangeGrid); + gridBtnImg.SetWidescreen(CFG.widescreen); + GuiImage gridBtnImg_g(&imgarrangeGrid_gray); + gridBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton gridBtn(&gridBtnImg_g,&gridBtnImg_g, 2, 3, THEME.grid_x, THEME.grid_y, &trigA, &btnSoundOver, &btnClick,1, &gridBtnTT, 15, 52, 1, 3); + gridBtn.SetAlpha(180); + + GuiTooltip carouselBtnTT(tr("Display as a carousel")); + if (Settings.wsprompt == yes) + carouselBtnTT.SetWidescreen(CFG.widescreen); + carouselBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage carouselBtnImg(&imgarrangeCarousel); + carouselBtnImg.SetWidescreen(CFG.widescreen); + GuiImage carouselBtnImg_g(&imgarrangeCarousel_gray); + carouselBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton carouselBtn(&carouselBtnImg_g,&carouselBtnImg_g, 2, 3, THEME.carousel_x, THEME.carousel_y, &trigA, &btnSoundOver, &btnClick,1, &carouselBtnTT, 15, 52, 1, 3); + carouselBtn.SetAlpha(180); + + GuiTooltip homebrewBtnTT(tr("Homebrew Launcher")); + if (Settings.wsprompt == yes) + homebrewBtnTT.SetWidescreen(CFG.widescreen); + homebrewBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage homebrewImg(&homebrewImgData); + GuiImage homebrewImgOver(&homebrewImgDataOver); + homebrewImg.SetWidescreen(CFG.widescreen); + homebrewImgOver.SetWidescreen(CFG.widescreen); + GuiButton homebrewBtn(&homebrewImg,&homebrewImgOver, 0, 3, THEME.homebrew_x, THEME.homebrew_y, &trigA, &btnSoundOver, &btnClick,1,&homebrewBtnTT,15,-30,1,5); + + if (Settings.fave) { + favoriteBtn.SetImage(&favoriteBtnImg); + favoriteBtn.SetImageOver(&favoriteBtnImg); + favoriteBtn.SetAlpha(255); + } + if (Settings.sort==all) { + abcBtn.SetImage(&abcBtnImg); + abcBtn.SetImageOver(&abcBtnImg); + abcBtn.SetAlpha(255); + } else if (Settings.sort==pcount) { + countBtn.SetImage(&countBtnImg); + countBtn.SetImageOver(&countBtnImg); + countBtn.SetAlpha(255); + } + if (Settings.gameDisplay==list) { + listBtn.SetImage(&listBtnImg); + listBtn.SetImageOver(&listBtnImg); + listBtn.SetAlpha(255); + } else if (Settings.gameDisplay==grid) { + gridBtn.SetImage(&gridBtnImg); + gridBtn.SetImageOver(&gridBtnImg); + gridBtn.SetAlpha(255); + } else if (Settings.gameDisplay==carousel) { + carouselBtn.SetImage(&carouselBtnImg); + carouselBtn.SetImageOver(&carouselBtnImg); + carouselBtn.SetAlpha(255); + } + if (Settings.gameDisplay==list) { + if (CFG.widescreen) { + favoriteBtn.SetPosition(THEME.favorite_x, THEME.favorite_y); + abcBtn.SetPosition(THEME.abc_x, THEME.abc_y); + countBtn.SetPosition(THEME.count_x, THEME.count_y); + listBtn.SetPosition(THEME.list_x, THEME.list_y); + gridBtn.SetPosition(THEME.grid_x, THEME.grid_y); + carouselBtn.SetPosition(THEME.carousel_x, THEME.carousel_y); + } else { + favoriteBtn.SetPosition(THEME.favorite_x-20, THEME.favorite_y); + abcBtn.SetPosition(THEME.abc_x-12, THEME.abc_y); + countBtn.SetPosition(THEME.count_x-4, THEME.count_y); + listBtn.SetPosition(THEME.list_x+4, THEME.list_y); + gridBtn.SetPosition(THEME.grid_x+12, THEME.grid_y); + carouselBtn.SetPosition(THEME.carousel_x+20, THEME.carousel_y); + } + } else { + if (CFG.widescreen) { + favoriteBtn.SetPosition(THEME.favorite_x-THEME.sortBarOffset, THEME.favorite_y); + abcBtn.SetPosition(THEME.abc_x-THEME.sortBarOffset, THEME.abc_y); + countBtn.SetPosition(THEME.count_x-THEME.sortBarOffset, THEME.count_y); + listBtn.SetPosition(THEME.list_x-THEME.sortBarOffset, THEME.list_y); + gridBtn.SetPosition(THEME.grid_x-THEME.sortBarOffset, THEME.grid_y); + carouselBtn.SetPosition(THEME.carousel_x-THEME.sortBarOffset, THEME.carousel_y); + } else { + favoriteBtn.SetPosition(THEME.favorite_x-20-THEME.sortBarOffset, THEME.favorite_y); + abcBtn.SetPosition(THEME.abc_x-12-THEME.sortBarOffset, THEME.abc_y); + countBtn.SetPosition(THEME.count_x-4-THEME.sortBarOffset, THEME.count_y); + listBtn.SetPosition(THEME.list_x+4-THEME.sortBarOffset, THEME.list_y); + gridBtn.SetPosition(THEME.grid_x+12-THEME.sortBarOffset, THEME.grid_y); + carouselBtn.SetPosition(THEME.carousel_x+20-THEME.sortBarOffset, THEME.carousel_y); + } + } + + + //Downloading Covers + GuiTooltip DownloadBtnTT(tr("Click to Download Covers")); + if (Settings.wsprompt == yes) + DownloadBtnTT.SetWidescreen(CFG.widescreen); + DownloadBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiButton DownloadBtn(0,0); + DownloadBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + DownloadBtn.SetPosition(THEME.cover_x,THEME.cover_y); + + if (Settings.godmode == 1) {//only make the button have trigger & tooltip if in godmode + DownloadBtn.SetSoundOver(&btnSoundOver); + DownloadBtn.SetTrigger(&trigA); + DownloadBtn.SetTrigger(&trig1); + DownloadBtn.SetToolTip(&DownloadBtnTT,205,-30); + } else + DownloadBtn.SetRumble(false); GuiGameBrowser * gameBrowser = NULL; GuiGameGrid * gameGrid = NULL; GuiGameCarousel * gameCarousel = NULL; if (Settings.gameDisplay==list) { - gameBrowser = new GuiGameBrowser(THEME.selection_w, THEME.selection_h, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); + gameBrowser = new GuiGameBrowser(THEME.selection_w, THEME.selection_h, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); gameBrowser->SetPosition(THEME.selection_x, THEME.selection_y); gameBrowser->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); - } - else if (Settings.gameDisplay==grid) { + } else if (Settings.gameDisplay==grid) { gameGrid = new GuiGameGrid(THEME.gamegrid_w,THEME.gamegrid_h, gameList, gameCnt, CFG.theme_path, bg_options_png, 0, 0); gameGrid->SetPosition(THEME.gamegrid_x,THEME.gamegrid_y); gameGrid->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); - } - else if (Settings.gameDisplay==carousel) { + } else if (Settings.gameDisplay==carousel) { //GuiGameCarousel gameCarousel(THEME.gamecarousel_w, THEME.gamecarousel_h, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); gameCarousel = new GuiGameCarousel(640, 400, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); gameCarousel->SetPosition(THEME.gamecarousel_x,THEME.gamecarousel_y); gameCarousel->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); } - GuiText clockTimeBack("88:88", 40, (GXColor){THEME.clock_r, THEME.clock_g, THEME.clock_b, 40}); - clockTimeBack.SetAlignment(THEME.clockAlign, ALIGN_TOP); - clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y); - clockTimeBack.SetFont(fontClock); - GuiText clockTime(theTime, 40, (GXColor){THEME.clock_r, THEME.clock_g, THEME.clock_b, 240}); - clockTime.SetAlignment(THEME.clockAlign, ALIGN_TOP); - clockTime.SetPosition(THEME.clock_x, THEME.clock_y); - clockTime.SetFont(fontClock); + GuiText clockTimeBack("88:88", 40, (GXColor) {THEME.clock_r, THEME.clock_g, THEME.clock_b, 40}); + clockTimeBack.SetAlignment(THEME.clockAlign, ALIGN_TOP); + clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y); + clockTimeBack.SetFont(fontClock); + GuiText clockTime(theTime, 40, (GXColor) {THEME.clock_r, THEME.clock_g, THEME.clock_b, 240}); + clockTime.SetAlignment(THEME.clockAlign, ALIGN_TOP); + clockTime.SetPosition(THEME.clock_x, THEME.clock_y); + clockTime.SetFont(fontClock); - HaltGui(); - GuiWindow w(screenwidth, screenheight); + HaltGui(); + GuiWindow w(screenwidth, screenheight); - if(THEME.showHDD == -1 || THEME.showHDD == 1) //force show hdd info - { - w.Append(&usedSpaceTxt); - } - if(THEME.showGameCnt == -1 || THEME.showGameCnt == 1) //force show game cnt info - { - w.Append(&gamecntTxt); - } - w.Append(&sdcardBtn); - w.Append(&poweroffBtn); - w.Append(&gameInfo); - if (Settings.godmode) - w.Append(&installBtn); - w.Append(&homeBtn); - w.Append(&settingsBtn); - w.Append(&DownloadBtn); - w.Append(&favoriteBtn); - w.Append(&abcBtn); - w.Append(&countBtn); - w.Append(&listBtn); - w.Append(&gridBtn); - w.Append(&carouselBtn); - if (Settings.godmode == 1) - w.Append(&homebrewBtn); + if (THEME.showHDD == -1 || THEME.showHDD == 1) { //force show hdd info + w.Append(&usedSpaceTxt); + } + if (THEME.showGameCnt == -1 || THEME.showGameCnt == 1) { //force show game cnt info + w.Append(&gamecntTxt); + } + w.Append(&sdcardBtn); + w.Append(&poweroffBtn); + w.Append(&gameInfo); + if (Settings.godmode) + w.Append(&installBtn); + w.Append(&homeBtn); + w.Append(&settingsBtn); + w.Append(&DownloadBtn); + w.Append(&favoriteBtn); + w.Append(&abcBtn); + w.Append(&countBtn); + w.Append(&listBtn); + w.Append(&gridBtn); + w.Append(&carouselBtn); + if (Settings.godmode == 1) + w.Append(&homebrewBtn); - if((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) - { - w.Append(&clockTimeBack); - w.Append(&clockTime); + if ((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) { + w.Append(&clockTimeBack); + w.Append(&clockTime); + } + + if (Settings.gameDisplay==list) { + mainWindow->Append(gameBrowser); + } + if (Settings.gameDisplay==grid) { + mainWindow->Append(gameGrid); + } + if (Settings.gameDisplay==carousel) { + mainWindow->Append(gameCarousel); + } + mainWindow->Append(&w); + + ResumeGui(); + + + + + + while (menu == MENU_NONE) { + + if (idiotFlag==1) { + char idiotBuffer[200]; + snprintf(idiotBuffer, sizeof(idiotBuffer), "%s (%s). %s",tr("You have attempted to load a bad image"), + idiotChar,tr("Most likely it has dimensions that are not evenly divisible by 4.")); + + int deleteImg = WindowPrompt(0,idiotBuffer,tr("Ok"),tr("Delete")); + if (deleteImg==0) { + snprintf(idiotBuffer, sizeof(idiotBuffer), "%s %s.",tr("You are about to delete "), idiotChar); + deleteImg = WindowPrompt(tr("Confirm"),idiotBuffer,tr("Delete"),tr("Cancel")); + if (deleteImg==1) { + remove(idiotChar); + } + } + idiotFlag=-1; } - if (Settings.gameDisplay==list){mainWindow->Append(gameBrowser);} - if (Settings.gameDisplay==grid){mainWindow->Append(gameGrid);} - if (Settings.gameDisplay==carousel){mainWindow->Append(gameCarousel);} - mainWindow->Append(&w); + WDVD_GetCoverStatus(&covert);//for detecting if i disc has been inserted - ResumeGui(); + // if the idiot is showing favoorites and don't have any + if (Settings.fave && !gameCnt) { + WindowPrompt(tr("No Favorites"),tr("You are choosing to display favorites and you do not have any selected."),tr("Back")); + Settings.fave=!Settings.fave; + if (isInserted(bootDevice)) { + cfg_save_global(); + } + __Menu_GetEntries(); + menu = MENU_DISCLIST; + break; + } + //CLOCK + time_t rawtime = time(0); //this fixes code dump caused by the clock + if (((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) && rawtime != lastrawtime) { + lastrawtime = rawtime; + timeinfo = localtime (&rawtime); + if (dataed < 1) { + if (Settings.hddinfo == hr12) { + if (rawtime & 1) + strftime(theTime, sizeof(theTime), "%I:%M", timeinfo); + else + strftime(theTime, sizeof(theTime), "%I %M", timeinfo); + } + if (Settings.hddinfo == hr24) { + if (rawtime & 1) + strftime(theTime, sizeof(theTime), "%H:%M", timeinfo); + else + strftime(theTime, sizeof(theTime), "%H %M", timeinfo); + } + clockTime.SetText(theTime); + } else if (dataed > 0) { - - - while(menu == MENU_NONE) - { - - if (idiotFlag==1){ - char idiotBuffer[200]; - snprintf(idiotBuffer, sizeof(idiotBuffer), "%s (%s). %s",tr("You have attempted to load a bad image"), - idiotChar,tr("Most likely it has dimensions that are not evenly divisible by 4.")); - - int deleteImg = WindowPrompt(0,idiotBuffer,tr("Ok"),tr("Delete")); - if(deleteImg==0) - { - snprintf(idiotBuffer, sizeof(idiotBuffer), "%s %s.",tr("You are about to delete "), idiotChar); - deleteImg = WindowPrompt(tr("Confirm"),idiotBuffer,tr("Delete"),tr("Cancel")); - if(deleteImg==1) - { - remove(idiotChar); - } - } - idiotFlag=-1;} - - WDVD_GetCoverStatus(&covert);//for detecting if i disc has been inserted - - // if the idiot is showing favoorites and don't have any - if (Settings.fave && !gameCnt){ - WindowPrompt(tr("No Favorites"),tr("You are choosing to display favorites and you do not have any selected."),tr("Back")); - Settings.fave=!Settings.fave; - if(isInserted(bootDevice)) { - cfg_save_global(); - } - __Menu_GetEntries(); - menu = MENU_DISCLIST; - break; - } - - //CLOCK - time_t rawtime = time(0); //this fixes code dump caused by the clock - if (((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) && rawtime != lastrawtime) { - lastrawtime = rawtime; - timeinfo = localtime (&rawtime); - if (dataed < 1){ - if(Settings.hddinfo == hr12){ - if(rawtime & 1) - strftime(theTime, sizeof(theTime), "%I:%M", timeinfo); - else - strftime(theTime, sizeof(theTime), "%I %M", timeinfo); - } - if(Settings.hddinfo == hr24){ - if(rawtime & 1) - strftime(theTime, sizeof(theTime), "%H:%M", timeinfo); - else - strftime(theTime, sizeof(theTime), "%H %M", timeinfo); - } - clockTime.SetText(theTime); - - } - else if (dataed > 0){ - - clockTime.SetTextf("%i", (dataed-1)); - } + clockTime.SetTextf("%i", (dataed-1)); + } } if ((datagB<1)&&(Settings.cios==1)&&(Settings.video == ntsc)&&(Settings.hddinfo == hr12)&&(Settings.qboot==1)&&(Settings.wsprompt==0)&&(Settings.language==ger)&&(Settings.tooltips==0)){dataed=1;dataef=1;}if (dataef==1){if (cosa>7){cosa=1;}datag++;if (sina==3){wiiBtn.SetAlignment(ALIGN_LEFT,ALIGN_BOTTOM);wiiBtnImg.SetAngle(0);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),((datag*2)-130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==2){wiiBtn.SetAlignment(ALIGN_RIGHT,ALIGN_TOP);wiiBtnImg.SetAngle(270);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((-2*(datag)+130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((2*(datag)-120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==1){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(180);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(2*(datag)-120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==0){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(90);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((2*(datag)-130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((-2*(datag)+120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}} - // respond to button presses - if(shutdown == 1) - { - Sys_Shutdown(); - } - if(reset == 1) - Sys_Reboot(); - - if(updateavailable == true) { - HaltGui(); - GuiWindow ww(640,480); - w.SetState(STATE_DISABLED); - mainWindow->Append(&ww); - ResumeGui(); - ProgressUpdateWindow(); - updateavailable = false; - mainWindow->Remove(&ww); - w.SetState(STATE_DEFAULT); - menu = MENU_DISCLIST; - } - - if(poweroffBtn.GetState() == STATE_CLICKED) - { - - - choice = WindowPrompt(tr("How to Shutdown?"),0,tr("Full Shutdown"), tr("Shutdown to Idle"), tr("Cancel")); - if(choice == 2) - { - Sys_ShutdownToIdel(); - } else if(choice == 1) { - Sys_ShutdownToStandby(); - } else { - poweroffBtn.ResetState(); - if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} - else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} - else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} - } - - } - else if(homeBtn.GetState() == STATE_CLICKED) - { - 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)) { - bgMusic->Play(); - } else { - bgMusic->PlayOggFile(Settings.ogg_path); - } - bgMusic->SetPlayTime(thetimeofbg); - SetVolumeOgg(255*(Settings.volume/100.0)); - - if(choice == 3) - { - Sys_LoadMenu(); // Back to System Menu - } - else if (choice == 2) - { - Sys_BackToLoader(); - } else { - homeBtn.ResetState(); - if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} - else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} - else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} - } - + // respond to button presses + if (shutdown == 1) { + Sys_Shutdown(); } - else if(wiiBtn.GetState() == STATE_CLICKED) - { dataed++; - wiiBtn.ResetState(); - if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} - else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} - else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} + if (reset == 1) + Sys_Reboot(); + + if (updateavailable == true) { + HaltGui(); + GuiWindow ww(640,480); + w.SetState(STATE_DISABLED); + mainWindow->Append(&ww); + ResumeGui(); + ProgressUpdateWindow(); + updateavailable = false; + mainWindow->Remove(&ww); + w.SetState(STATE_DEFAULT); + menu = MENU_DISCLIST; + } + + if (poweroffBtn.GetState() == STATE_CLICKED) { + + + choice = WindowPrompt(tr("How to Shutdown?"),0,tr("Full Shutdown"), tr("Shutdown to Idle"), tr("Cancel")); + if (choice == 2) { + Sys_ShutdownToIdel(); + } else if (choice == 1) { + Sys_ShutdownToStandby(); + } else { + poweroffBtn.ResetState(); + if (Settings.gameDisplay==list) { + gameBrowser->SetFocus(1); + } else if (Settings.gameDisplay==grid) { + gameGrid->SetFocus(1); + } else if (Settings.gameDisplay==carousel) { + gameCarousel->SetFocus(1); } - else if((installBtn.GetState() == STATE_CLICKED)||((covert & 0x2)&&(covert!=covertOld))) - { - choice = WindowPrompt(tr("Install a game"),0,tr("Yes"),tr("No")); - if (choice == 1) - { - menu = MENU_INSTALL; - break; - } - else - { - installBtn.ResetState(); - if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} - else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} - else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} - } + } + + } else if (homeBtn.GetState() == STATE_CLICKED) { + 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)) { + bgMusic->Play(); + } else { + bgMusic->PlayOggFile(Settings.ogg_path); + } + bgMusic->SetPlayTime(thetimeofbg); + SetVolumeOgg(255*(Settings.volume/100.0)); + + if (choice == 3) { + Sys_LoadMenu(); // Back to System Menu + } else if (choice == 2) { + Sys_BackToLoader(); + } else { + homeBtn.ResetState(); + if (Settings.gameDisplay==list) { + gameBrowser->SetFocus(1); + } else if (Settings.gameDisplay==grid) { + gameGrid->SetFocus(1); + } else if (Settings.gameDisplay==carousel) { + gameCarousel->SetFocus(1); } + } - - - - else if(sdcardBtn.GetState() == STATE_CLICKED){ - SDCard_deInit(); - SDCard_Init(); - if (Settings.gameDisplay==list){ - startat = gameBrowser->GetSelectedOption(); - offset = gameBrowser->GetOffset();} - else if (Settings.gameDisplay==grid){ - startat = gameGrid->GetSelectedOption(); - offset = gameGrid->GetOffset();} - else if (Settings.gameDisplay==carousel){ - startat = gameCarousel->GetSelectedOption(); - offset = gameCarousel->GetOffset();} - //if(isSdInserted()) { - if(isInserted(bootDevice)) { - CFG_Load(); - } - sdcardBtn.ResetState(); - menu = MENU_DISCLIST; - break; + } else if (wiiBtn.GetState() == STATE_CLICKED) { + dataed++; + wiiBtn.ResetState(); + if (Settings.gameDisplay==list) { + gameBrowser->SetFocus(1); + } else if (Settings.gameDisplay==grid) { + gameGrid->SetFocus(1); + } else if (Settings.gameDisplay==carousel) { + gameCarousel->SetFocus(1); + } + } else if ((installBtn.GetState() == STATE_CLICKED)||((covert & 0x2)&&(covert!=covertOld))) { + choice = WindowPrompt(tr("Install a game"),0,tr("Yes"),tr("No")); + if (choice == 1) { + menu = MENU_INSTALL; + break; + } else { + installBtn.ResetState(); + if (Settings.gameDisplay==list) { + gameBrowser->SetFocus(1); + } else if (Settings.gameDisplay==grid) { + gameGrid->SetFocus(1); + } else if (Settings.gameDisplay==carousel) { + gameCarousel->SetFocus(1); } + } + } - else if(DownloadBtn.GetState() == STATE_CLICKED) - { - //if(isSdInserted()) { - if(isInserted(bootDevice)) { - choice = WindowPrompt(tr("Cover Download"), 0, tr("Normal Covers"), tr("3D Covers"), tr("Disc Images"), tr("Back")); // ask for download choice - if (choice != 0) + + + else if (sdcardBtn.GetState() == STATE_CLICKED) { + SDCard_deInit(); + SDCard_Init(); + if (Settings.gameDisplay==list) { + startat = gameBrowser->GetSelectedOption(); + offset = gameBrowser->GetOffset(); + } else if (Settings.gameDisplay==grid) { + startat = gameGrid->GetSelectedOption(); + offset = gameGrid->GetOffset(); + } else if (Settings.gameDisplay==carousel) { + startat = gameCarousel->GetSelectedOption(); + offset = gameCarousel->GetOffset(); + } + //if(isSdInserted()) { + if (isInserted(bootDevice)) { + CFG_Load(); + } + sdcardBtn.ResetState(); + menu = MENU_DISCLIST; + break; + } + + else if (DownloadBtn.GetState() == STATE_CLICKED) { + //if(isSdInserted()) { + if (isInserted(bootDevice)) { + choice = WindowPrompt(tr("Cover Download"), 0, tr("Normal Covers"), tr("3D Covers"), tr("Disc Images"), tr("Back")); // ask for download choice + + if (choice != 0) { + int choice2 = choice; + + SearchMissingImages(choice2); + + if (IsNetworkInit() == false) { + WindowPrompt(tr("Network init error"), 0, tr("OK")); + + } else { + + if (GetMissingFiles() != NULL && cntMissFiles > 0) + { - int choice2 = choice; - - SearchMissingImages(choice2); - - if(IsNetworkInit() == false) - { - WindowPrompt(tr("Network init error"), 0, tr("OK")); + char tempCnt[40]; + sprintf(tempCnt,"%i %s",cntMissFiles,tr("Missing files")); + if (choice!=3)choice = WindowPrompt(tr("Download Boxart image?"),tempCnt,tr("Yes"),tr("No")); + else if (choice==3)choice = WindowPrompt(tr("Download Discart image?"),tempCnt,tr("Yes"),tr("No")); + if (choice == 1) { + ret = ProgressDownloadWindow(choice2); + if (ret == 0) { + WindowPrompt(tr("Download finished"),0,tr("OK")); } else { - - if (GetMissingFiles() != NULL && cntMissFiles > 0) - - { - char tempCnt[40]; - - sprintf(tempCnt,"%i %s",cntMissFiles,tr("Missing files")); - if (choice!=3)choice = WindowPrompt(tr("Download Boxart image?"),tempCnt,tr("Yes"),tr("No")); - else if (choice==3)choice = WindowPrompt(tr("Download Discart image?"),tempCnt,tr("Yes"),tr("No")); - if (choice == 1) - { - ret = ProgressDownloadWindow(choice2); - if (ret == 0) { - WindowPrompt(tr("Download finished"),0,tr("OK")); - } else { - sprintf(tempCnt,"%i %s",ret,tr("files not found on the server!")); - WindowPrompt(tr("Download finished"),tempCnt,tr("OK")); - } - } - } - else - { - WindowPrompt(tr("No file missing!"),0,tr("OK")); - } - } + sprintf(tempCnt,"%i %s",ret,tr("files not found on the server!")); + WindowPrompt(tr("Download finished"),tempCnt,tr("OK")); } - } else { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to download images."), tr("OK")); - }menu = MENU_DISCLIST; - DownloadBtn.ResetState(); - if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} - else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} - else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} - }//end download - - else if(settingsBtn.GetState() == STATE_CLICKED) - { if (Settings.gameDisplay==list){ - startat = gameBrowser->GetSelectedOption(); - offset = gameBrowser->GetOffset();} - else if (Settings.gameDisplay==grid){ - startat = gameGrid->GetSelectedOption(); - offset = gameGrid->GetOffset();} - else if (Settings.gameDisplay==carousel){ - startat = gameCarousel->GetSelectedOption(); - offset = gameCarousel->GetOffset();} - menu = MENU_SETTINGS; - break; - - } - - else if(favoriteBtn.GetState() == STATE_CLICKED) - { - Settings.fave=!Settings.fave; - //if(isSdInserted()) { - if(isInserted(bootDevice)) { - cfg_save_global(); - } - __Menu_GetEntries(); - menu = MENU_DISCLIST; - break; - - } - - else if(abcBtn.GetState() == STATE_CLICKED) - { - if(Settings.sort != all) { - Settings.sort=all; - //if(isSdInserted()) { - if(isInserted(bootDevice)) { - cfg_save_global(); - } - __Menu_GetEntries(); - - menu = MENU_DISCLIST; - break; - } - abcBtn.ResetState(); - } - - else if(countBtn.GetState() == STATE_CLICKED) - { - if(Settings.sort != pcount) { - Settings.sort=pcount; - //if(isSdInserted()) { - if(isInserted(bootDevice)) { - cfg_save_global(); - } - __Menu_GetEntries(); - - menu = MENU_DISCLIST; - break; - } - countBtn.ResetState(); - - } - - else if(listBtn.GetState() == STATE_CLICKED) { - if (Settings.gameDisplay!=list){ - Settings.gameDisplay=list; - menu = MENU_DISCLIST; - if(isInserted(bootDevice)) { - cfg_save_global(); - } - listBtn.ResetState(); - break; - } else { - listBtn.ResetState(); - } - } - - - else if (gridBtn.GetState() == STATE_CLICKED) { - if (Settings.gameDisplay!=grid){ - - Settings.gameDisplay=grid; - menu = MENU_DISCLIST; - if(isInserted(bootDevice)) { - cfg_save_global(); - } - gridBtn.ResetState(); - break; - } else { - gridBtn.ResetState(); - } - } - - else if (carouselBtn.GetState() == STATE_CLICKED) { - if (Settings.gameDisplay!=carousel) { - Settings.gameDisplay=carousel; - menu = MENU_DISCLIST; - if(isInserted(bootDevice)) { - cfg_save_global(); } - carouselBtn.ResetState(); - break; - } else { - carouselBtn.ResetState(); + } else { + WindowPrompt(tr("No file missing!"),0,tr("OK")); + } } } - else if (homebrewBtn.GetState() == STATE_CLICKED) { - menu = MENU_HOMEBREWBROWSE; - break; + } else { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to download images."), tr("OK")); + } + menu = MENU_DISCLIST; + DownloadBtn.ResetState(); + if (Settings.gameDisplay==list) { + gameBrowser->SetFocus(1); + } else if (Settings.gameDisplay==grid) { + gameGrid->SetFocus(1); + } else if (Settings.gameDisplay==carousel) { + gameCarousel->SetFocus(1); + } + }//end download + + else if (settingsBtn.GetState() == STATE_CLICKED) { + if (Settings.gameDisplay==list) { + startat = gameBrowser->GetSelectedOption(); + offset = gameBrowser->GetOffset(); + } else if (Settings.gameDisplay==grid) { + startat = gameGrid->GetSelectedOption(); + offset = gameGrid->GetOffset(); + } else if (Settings.gameDisplay==carousel) { + startat = gameCarousel->GetSelectedOption(); + offset = gameCarousel->GetOffset(); + } + menu = MENU_SETTINGS; + break; + + } + + else if (favoriteBtn.GetState() == STATE_CLICKED) { + Settings.fave=!Settings.fave; + //if(isSdInserted()) { + if (isInserted(bootDevice)) { + cfg_save_global(); + } + __Menu_GetEntries(); + menu = MENU_DISCLIST; + break; + + } + + else if (abcBtn.GetState() == STATE_CLICKED) { + if (Settings.sort != all) { + Settings.sort=all; + //if(isSdInserted()) { + if (isInserted(bootDevice)) { + cfg_save_global(); } - else if (gameInfo.GetState() == STATE_CLICKED) { - gameSelected = selectImg1; - rockout(); - struct discHdr *header = &gameList[selectImg1]; + __Menu_GetEntries(); + + menu = MENU_DISCLIST; + break; + } + abcBtn.ResetState(); + } + + else if (countBtn.GetState() == STATE_CLICKED) { + if (Settings.sort != pcount) { + Settings.sort=pcount; + //if(isSdInserted()) { + if (isInserted(bootDevice)) { + cfg_save_global(); + } + __Menu_GetEntries(); + + menu = MENU_DISCLIST; + break; + } + countBtn.ResetState(); + + } + + else if (listBtn.GetState() == STATE_CLICKED) { + if (Settings.gameDisplay!=list) { + Settings.gameDisplay=list; + menu = MENU_DISCLIST; + if (isInserted(bootDevice)) { + cfg_save_global(); + } + listBtn.ResetState(); + break; + } else { + listBtn.ResetState(); + } + } + + + else if (gridBtn.GetState() == STATE_CLICKED) { + if (Settings.gameDisplay!=grid) { + + Settings.gameDisplay=grid; + menu = MENU_DISCLIST; + if (isInserted(bootDevice)) { + cfg_save_global(); + } + gridBtn.ResetState(); + break; + } else { + gridBtn.ResetState(); + } + } + + else if (carouselBtn.GetState() == STATE_CLICKED) { + if (Settings.gameDisplay!=carousel) { + Settings.gameDisplay=carousel; + menu = MENU_DISCLIST; + if (isInserted(bootDevice)) { + cfg_save_global(); + } + carouselBtn.ResetState(); + break; + } else { + carouselBtn.ResetState(); + } + } else if (homebrewBtn.GetState() == STATE_CLICKED) { + menu = MENU_HOMEBREWBROWSE; + break; + } else if (gameInfo.GetState() == STATE_CLICKED) { + gameSelected = selectImg1; + rockout(); + struct discHdr *header = &gameList[selectImg1]; + snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + choice = showGameInfo(IDfull); + gameInfo.ResetState(); + rockout(2); + if (choice==2) + homeBtn.SetState(STATE_CLICKED); + } + + if (Settings.gameDisplay==grid) { + int selectimg; + DownloadBtn.SetSize(0,0); + selectimg = gameGrid->GetSelectedOption(); + gameSelected = gameGrid->GetClickedOption(); + selectImg1=selectimg; + } + + if (Settings.gameDisplay==carousel) { + int selectimg; + DownloadBtn.SetSize(0,0); + selectimg = gameCarousel->GetSelectedOption(); + gameSelected = gameCarousel->GetClickedOption(); + selectImg1=selectimg; + } + if (Settings.gameDisplay==list) { + //Get selected game under cursor + int selectimg; + DownloadBtn.SetSize(160,224); + + selectimg = gameBrowser->GetSelectedOption(); + gameSelected = gameBrowser->GetClickedOption(); + selectImg1=selectimg; + + if (gameSelected > 0) //if click occured + selectimg = gameSelected; + + if ((selectimg >= 0) && (selectimg < (s32) gameCnt)) { + if (selectimg != selectedold) { + selectedold = selectimg;//update displayed cover, game ID, and region if the selected game changes + struct discHdr *header = &gameList[selectimg]; + snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - choice = showGameInfo(IDfull); - gameInfo.ResetState(); - rockout(2); - if (choice==2) - homeBtn.SetState(STATE_CLICKED); + w.Remove(&DownloadBtn); + + if (GameIDTxt) { + w.Remove(GameIDTxt); + delete GameIDTxt; + GameIDTxt = NULL; + } + if (GameRegionTxt) { + w.Remove(GameRegionTxt); + delete GameRegionTxt; + GameRegionTxt = NULL; + } + + switch (header->id[3]) { + case 'E': + sprintf(gameregion,"NTSC U"); + break; + + case 'J': + sprintf(gameregion,"NTSC J"); + break; + + case 'K': + sprintf(gameregion,"NTSC K"); + break; + + + case 'P': + case 'D': + case 'F': + case 'X': + case 'S': + case 'Y': + sprintf(gameregion," PAL "); + break; + } + + //load game cover + if (cover) { + delete cover; + cover = NULL; + } + + snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, IDfull); + cover = new GuiImageData(imgPath,0); //load short id + if (!cover->GetImage()) { //if could not load the short id image + delete cover; + snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID); + cover = new GuiImageData(imgPath, 0); //load full id image + if (!cover->GetImage()) { + delete cover; + snprintf(imgPath, sizeof(imgPath), "%snoimage.png", CFG.theme_path); + cover = new GuiImageData(imgPath, nocover_png); //load no image + } + } + + if (coverImg) { + delete coverImg; + coverImg = NULL; + } + coverImg = new GuiImage(cover); + coverImg->SetWidescreen(CFG.widescreen); + + DownloadBtn.SetImage(coverImg);// put the new image on the download button + w.Append(&DownloadBtn); + + if ((Settings.sinfo == GameID) || (Settings.sinfo == Both)) { + GameIDTxt = new GuiText(IDfull, 22, (GXColor) {THEME.info_r, THEME.info_g, THEME.info_b, 255}); + GameIDTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + GameIDTxt->SetPosition(THEME.id_x,THEME.id_y); + GameIDTxt->SetEffect(EFFECT_FADE, 20); + w.Append(GameIDTxt); + } + + if ((Settings.sinfo == GameRegion) || (Settings.sinfo == Both)) { + GameRegionTxt = new GuiText(gameregion, 22, (GXColor) {THEME.info_r, THEME.info_g, THEME.info_b, 255}); + GameRegionTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + GameRegionTxt->SetPosition(THEME.region_x, THEME.region_y); + GameRegionTxt->SetEffect(EFFECT_FADE, 20); + w.Append(GameRegionTxt); + } + } + } + } + + if ((gameSelected >= 0) && (gameSelected < (s32)gameCnt)) { + rockout(); + struct discHdr *header = &gameList[gameSelected]; + WBFS_GameSize(header->id, &size); + if (strlen(get_title(header)) < (MAX_CHARACTERS + 3)) { + sprintf(text, "%s", get_title(header)); + } else { + strncpy(text, get_title(header), MAX_CHARACTERS); + text[MAX_CHARACTERS] = '\0'; + strncat(text, "...", 3); + } + + //check if alt Dol and gct file is present + FILE *exeFile = NULL; + char nipple[100]; + header = &gameList[gameSelected]; //reset header + snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); + if (game_cfg) { + ocarinaChoice = game_cfg->ocarina; + alternatedol = game_cfg->loadalternatedol; + } else { + alternatedol = off; + ocarinaChoice = Settings.ocarina; + } + + + if (Settings.qboot == yes) { //quickboot game + if (alternatedol == on) { + /* Open dol File and check exist */ + sprintf(nipple, "%s%s.dol",Settings.dolpath,IDfull); + exeFile = fopen (nipple ,"rb"); + if (exeFile==NULL) { + sprintf(nipple, "%s %s",nipple,tr("does not exist!")); + WindowPrompt(tr("Error"),nipple,tr("OK")); + + menu = MENU_CHECK; + wiilight(0); + break; + } + } + if (ocarinaChoice != off) { + /* Open gct File and check exist */ + sprintf(nipple, "%s%s.gct",Settings.Cheatcodespath,IDfull); + exeFile = fopen (nipple ,"rb"); + + if (exeFile==NULL) { + sprintf(nipple, "%s %s",nipple,tr("does not exist! Loading game without cheats.")); + WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); + } else { + fseek (exeFile, 0, SEEK_END); + long size=ftell (exeFile); + rewind (exeFile); + if (size>2056) { + sprintf(nipple, "%s %s",nipple,tr("contains over 255 lines of code. It will produce unexpected results.")); + WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); + } + } + + } + SDCard_deInit(); + wiilight(0); + if (isInserted(bootDevice)) { + //////////save game play count//////////////// + struct Game_NUM* game_num = CFG_get_game_num(header->id); + + if (game_num) { + favoritevar = game_num->favorite; + playcount = game_num->count; + } else { + favoritevar = 0; + playcount = 0; + } + playcount += 1; + + CFG_save_game_num(header->id); } - if (Settings.gameDisplay==grid){ - int selectimg; - DownloadBtn.SetSize(0,0); - selectimg = gameGrid->GetSelectedOption(); - gameSelected = gameGrid->GetClickedOption(); - selectImg1=selectimg; - } + menu = MENU_EXIT; + break; - if (Settings.gameDisplay==carousel){ - int selectimg; - DownloadBtn.SetSize(0,0); - selectimg = gameCarousel->GetSelectedOption(); - gameSelected = gameCarousel->GetClickedOption(); - selectImg1=selectimg; - } - if (Settings.gameDisplay==list) { - //Get selected game under cursor - int selectimg;//, promptnumber; - DownloadBtn.SetSize(160,224); + } + bool returnHere = true;// prompt to start game + while (returnHere) { + returnHere = false; + if (Settings.wiilight != 2) wiilight(1); + choice = GameWindowPrompt(); + // header = &gameList[gameSelected]; //reset header - selectimg = gameBrowser->GetSelectedOption(); - gameSelected = gameBrowser->GetClickedOption(); - selectImg1=selectimg; + if (choice == 1) { + if (alternatedol == on) { + /* Open dol File and check exist */ + sprintf(nipple, "%s%s.dol",Settings.dolpath,IDfull); + exeFile = fopen (nipple ,"rb"); + if (exeFile==NULL) { + sprintf(nipple, "%s %s",nipple,tr("does not exist! You Messed something up, Idiot.")); + WindowPrompt(tr("Error"),nipple,tr("OK")); - if (gameSelected > 0) //if click occured - selectimg = gameSelected; - - if ((selectimg >= 0) && (selectimg < (s32) gameCnt)) - { - if (selectimg != selectedold) - { - selectedold = selectimg;//update displayed cover, game ID, and region if the selected game changes - struct discHdr *header = &gameList[selectimg]; - snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); - snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - w.Remove(&DownloadBtn); - - if (GameIDTxt) - { - w.Remove(GameIDTxt); - delete GameIDTxt; - GameIDTxt = NULL; - } - if(GameRegionTxt) - { - w.Remove(GameRegionTxt); - delete GameRegionTxt; - GameRegionTxt = NULL; - } - - switch(header->id[3]) - { - case 'E': - sprintf(gameregion,"NTSC U"); - break; - - case 'J': - sprintf(gameregion,"NTSC J"); - break; - - case 'K': - sprintf(gameregion,"NTSC K"); - break; - - - case 'P': - case 'D': - case 'F': - case 'X': - case 'S': - case 'Y': - sprintf(gameregion," PAL "); - break; - } - - //load game cover - if (cover) - { - delete cover; - cover = NULL; - } - - snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, IDfull); - cover = new GuiImageData(imgPath,0); //load short id - if (!cover->GetImage()) //if could not load the short id image - { - delete cover; - snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID); - cover = new GuiImageData(imgPath, 0); //load full id image - if (!cover->GetImage()) - { - delete cover; - snprintf(imgPath, sizeof(imgPath), "%snoimage.png", CFG.theme_path); - cover = new GuiImageData(imgPath, nocover_png); //load no image - } - } - - if (coverImg) - { - delete coverImg; - coverImg = NULL; - } - coverImg = new GuiImage(cover); - coverImg->SetWidescreen(CFG.widescreen); - - DownloadBtn.SetImage(coverImg);// put the new image on the download button - w.Append(&DownloadBtn); - - if ((Settings.sinfo == GameID) || (Settings.sinfo == Both)){ - GameIDTxt = new GuiText(IDfull, 22, (GXColor){THEME.info_r, THEME.info_g, THEME.info_b, 255}); - GameIDTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); - GameIDTxt->SetPosition(THEME.id_x,THEME.id_y); - GameIDTxt->SetEffect(EFFECT_FADE, 20); - w.Append(GameIDTxt); - } - - if ((Settings.sinfo == GameRegion) || (Settings.sinfo == Both)){ - GameRegionTxt = new GuiText(gameregion, 22, (GXColor){THEME.info_r, THEME.info_g, THEME.info_b, 255}); - GameRegionTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); - GameRegionTxt->SetPosition(THEME.region_x, THEME.region_y); - GameRegionTxt->SetEffect(EFFECT_FADE, 20); - w.Append(GameRegionTxt); - } - } - } - } - - if ((gameSelected >= 0) && (gameSelected < (s32)gameCnt)) - { - rockout(); - struct discHdr *header = &gameList[gameSelected]; - WBFS_GameSize(header->id, &size); - if (strlen(get_title(header)) < (MAX_CHARACTERS + 3)) { - sprintf(text, "%s", get_title(header)); - } - else { - strncpy(text, get_title(header), MAX_CHARACTERS); - text[MAX_CHARACTERS] = '\0'; - strncat(text, "...", 3); - } - - //check if alt Dol and gct file is present - FILE *exeFile = NULL; - char nipple[100]; - header = &gameList[gameSelected]; //reset header - snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); - if (game_cfg) { - ocarinaChoice = game_cfg->ocarina; - alternatedol = game_cfg->loadalternatedol; - } else { - alternatedol = off; - ocarinaChoice = Settings.ocarina; - } - - - if (Settings.qboot == yes)//quickboot game - { if (alternatedol == on){ - /* Open dol File and check exist */ - sprintf(nipple, "%s%s.dol",Settings.dolpath,IDfull); - exeFile = fopen (nipple ,"rb"); - if (exeFile==NULL) - { - sprintf(nipple, "%s %s",nipple,tr("does not exist!")); - WindowPrompt(tr("Error"),nipple,tr("OK")); - - menu = MENU_CHECK; - wiilight(0); - break; - } - } - if (ocarinaChoice != off){ - /* Open gct File and check exist */ - sprintf(nipple, "%s%s.gct",Settings.Cheatcodespath,IDfull); - exeFile = fopen (nipple ,"rb"); - - if (exeFile==NULL) - { - sprintf(nipple, "%s %s",nipple,tr("does not exist! Loading game without cheats.")); - WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); - } - else - { - fseek (exeFile, 0, SEEK_END); - long size=ftell (exeFile); - rewind (exeFile); - if (size>2056){ - sprintf(nipple, "%s %s",nipple,tr("contains over 255 lines of code. It will produce unexpected results.")); - WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); - } - } - - } - SDCard_deInit(); - wiilight(0); - if(isInserted(bootDevice)) { - //////////save game play count//////////////// - struct Game_NUM* game_num = CFG_get_game_num(header->id); - - if (game_num) { - favoritevar = game_num->favorite; - playcount = game_num->count; - } else { - favoritevar = 0; - playcount = 0; - } - playcount += 1; - - CFG_save_game_num(header->id); - } - - menu = MENU_EXIT; + menu = MENU_CHECK; + wiilight(0); break; - } - bool returnHere = true;// prompt to start game - while (returnHere) - { - returnHere = false; - if(Settings.wiilight != 2) wiilight(1); - choice = GameWindowPrompt(); - // header = &gameList[gameSelected]; //reset header - - if(choice == 1) - { - if (alternatedol == on){ - /* Open dol File and check exist */ - sprintf(nipple, "%s%s.dol",Settings.dolpath,IDfull); - exeFile = fopen (nipple ,"rb"); - if (exeFile==NULL) - { - sprintf(nipple, "%s %s",nipple,tr("does not exist! You Messed something up, Idiot.")); - WindowPrompt(tr("Error"),nipple,tr("OK")); - - menu = MENU_CHECK; - wiilight(0); - break; - } - } - if (ocarinaChoice != off){ - /* Open gct File and check exist */ - sprintf(nipple, "%s%s.gct",Settings.Cheatcodespath,IDfull); - exeFile = fopen (nipple ,"rb"); - if (exeFile==NULL) - { - sprintf(nipple, "%s %s",nipple,tr("does not exist! Loading game without cheats.")); - WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); - } - else - { - fseek (exeFile, 0, SEEK_END); - long size=ftell (exeFile); - rewind (exeFile); - fclose(exeFile); - if (size>2056){ - sprintf(nipple, "%s %s",nipple,tr("contains over 255 lines of code. It will produce unexpected results.")); - WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); - } - } - - } - SDCard_deInit(); - wiilight(0); - returnHere = false; - menu = MENU_EXIT; - - - } - else if (choice == 2) - { - wiilight(0); - HaltGui(); - if (Settings.gameDisplay==list) mainWindow->Remove(gameBrowser); - else if (Settings.gameDisplay==grid) mainWindow->Remove(gameGrid); - else if (Settings.gameDisplay==carousel) mainWindow->Remove(gameCarousel); - mainWindow->Remove(&w); - ResumeGui(); - - //re-evaluate header now in case they changed games while on the game prompt - header = &gameList[gameSelected]; - int settret = GameSettings(header); - menu = MENU_DISCLIST; // refresh titles (needed if the language setting has changed) - HaltGui(); - if (Settings.gameDisplay==list) mainWindow->Append(gameBrowser); - else if (Settings.gameDisplay==grid) mainWindow->Append(gameGrid); - else if (Settings.gameDisplay==carousel) mainWindow->Append(gameCarousel); - mainWindow->Append(&w); - ResumeGui(); - if (settret == 1) //if deleted - { - menu = MENU_DISCLIST; - break; - } - returnHere = true; - rockout(2); - } - - else if (choice == 3) //WBFS renaming - { - wiilight(0); - //enter new game title - char entered[60]; - snprintf(entered, sizeof(entered), "%s", get_title(header)); - entered[59] = '\0'; - int result = OnScreenKeyboard(entered, 60,0); - if (result == 1) { - WBFS_RenameGame(header->id, entered); - __Menu_GetEntries(); - menu = MENU_DISCLIST; - } - } - else if(choice == 0) { - rockout(2); - if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} - else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} - else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} - } - - + } + if (ocarinaChoice != off) { + /* Open gct File and check exist */ + sprintf(nipple, "%s%s.gct",Settings.Cheatcodespath,IDfull); + exeFile = fopen (nipple ,"rb"); + if (exeFile==NULL) { + sprintf(nipple, "%s %s",nipple,tr("does not exist! Loading game without cheats.")); + WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); + } else { + fseek (exeFile, 0, SEEK_END); + long size=ftell (exeFile); + rewind (exeFile); + fclose(exeFile); + if (size>2056) { + sprintf(nipple, "%s %s",nipple,tr("contains over 255 lines of code. It will produce unexpected results.")); + WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); + } } + + } + SDCard_deInit(); + wiilight(0); + returnHere = false; + menu = MENU_EXIT; + + + } else if (choice == 2) { + wiilight(0); + HaltGui(); + if (Settings.gameDisplay==list) mainWindow->Remove(gameBrowser); + else if (Settings.gameDisplay==grid) mainWindow->Remove(gameGrid); + else if (Settings.gameDisplay==carousel) mainWindow->Remove(gameCarousel); + mainWindow->Remove(&w); + ResumeGui(); + + //re-evaluate header now in case they changed games while on the game prompt + header = &gameList[gameSelected]; + int settret = GameSettings(header); + menu = MENU_DISCLIST; // refresh titles (needed if the language setting has changed) + HaltGui(); + if (Settings.gameDisplay==list) mainWindow->Append(gameBrowser); + else if (Settings.gameDisplay==grid) mainWindow->Append(gameGrid); + else if (Settings.gameDisplay==carousel) mainWindow->Append(gameCarousel); + mainWindow->Append(&w); + ResumeGui(); + if (settret == 1) { //if deleted + menu = MENU_DISCLIST; + break; + } + returnHere = true; + rockout(2); } - // to skip the first call of windowScreensaver at startup when wiimote is not connected - if(IsWpadConnected()){check = 1;} - // screensaver is called when wiimote shuts down, depending on the wiimotet idletime - if(!IsWpadConnected() && check !=0 && Settings.screensaver!=0) - { check++; - int screensaverIsOn=0; - if(check==11500) //to allow time for the wii to turn off and not show the screensaver - {screensaverIsOn=WindowScreensaver();} - if (screensaverIsOn==1)check=0; - } - covertOld=covert; - } + else if (choice == 3) { //WBFS renaming + wiilight(0); + //enter new game title + char entered[60]; + snprintf(entered, sizeof(entered), "%s", get_title(header)); + entered[59] = '\0'; + int result = OnScreenKeyboard(entered, 60,0); + if (result == 1) { + WBFS_RenameGame(header->id, entered); + __Menu_GetEntries(); + menu = MENU_DISCLIST; + } + } else if (choice == 0) { + rockout(2); + if (Settings.gameDisplay==list) { + gameBrowser->SetFocus(1); + } else if (Settings.gameDisplay==grid) { + gameGrid->SetFocus(1); + } else if (Settings.gameDisplay==carousel) { + gameCarousel->SetFocus(1); + } + } - HaltGui(); - mainWindow->RemoveAll(); - mainWindow->Append(bgImg); - delete gameBrowser; - gameBrowser = NULL; - delete gameGrid; - gameGrid = NULL; - delete gameCarousel; - gameCarousel = NULL; - ResumeGui(); - return menu; + + } + } + // to skip the first call of windowScreensaver at startup when wiimote is not connected + if (IsWpadConnected()) { + check = 1; + } + + // screensaver is called when wiimote shuts down, depending on the wiimotet idletime + if (!IsWpadConnected() && check !=0 && Settings.screensaver!=0) { + check++; + int screensaverIsOn=0; + if (check==11500) { //to allow time for the wii to turn off and not show the screensaver + screensaverIsOn=WindowScreensaver(); + } + if (screensaverIsOn==1)check=0; + } + covertOld=covert; + } + + HaltGui(); + mainWindow->RemoveAll(); + mainWindow->Append(bgImg); + delete gameBrowser; + gameBrowser = NULL; + delete gameGrid; + gameGrid = NULL; + delete gameCarousel; + gameCarousel = NULL; + ResumeGui(); + return menu; } @@ -1426,164 +1351,160 @@ int MenuDiscList() * MenuInstall ***************************************************************************/ -static int MenuInstall() -{ - int menu = MENU_NONE; +static int MenuInstall() { + int menu = MENU_NONE; static struct discHdr headerdisc ATTRIBUTE_ALIGN(32); Disc_SetUSB(NULL); int ret, choice = 0; - char name[200]; + char name[200]; - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbattery.png", CFG.theme_path); - GuiImageData battery(imgPath, battery_png); - snprintf(imgPath, sizeof(imgPath), "%sbattery_red.png", CFG.theme_path); - GuiImageData batteryRed(imgPath, battery_red_png); - snprintf(imgPath, sizeof(imgPath), "%sbattery_bar.png", CFG.theme_path); - GuiImageData batteryBar(imgPath, battery_bar_png); + snprintf(imgPath, sizeof(imgPath), "%sbattery.png", CFG.theme_path); + GuiImageData battery(imgPath, battery_png); + snprintf(imgPath, sizeof(imgPath), "%sbattery_red.png", CFG.theme_path); + GuiImageData batteryRed(imgPath, battery_red_png); + snprintf(imgPath, sizeof(imgPath), "%sbattery_bar.png", CFG.theme_path); + GuiImageData batteryBar(imgPath, battery_bar_png); HaltGui(); - GuiWindow w(screenwidth, screenheight); + GuiWindow w(screenwidth, screenheight); mainWindow->Append(&w); - ResumeGui(); + ResumeGui(); - while(menu == MENU_NONE) - { - VIDEO_WaitVSync (); + while (menu == MENU_NONE) { + VIDEO_WaitVSync (); - ret = DiscWait(tr("Insert Disk"),tr("Waiting..."),tr("Cancel"),0,0); - if (ret < 0) { - WindowPrompt (tr("Error reading Disc"),0,tr("Back")); - menu = MENU_DISCLIST; - break; - } - ret = Disc_Open(); - if (ret < 0) { - WindowPrompt (tr("Could not open Disc"),0,tr("Back")); - menu = MENU_DISCLIST; - break; - } + ret = DiscWait(tr("Insert Disk"),tr("Waiting..."),tr("Cancel"),0,0); + if (ret < 0) { + WindowPrompt (tr("Error reading Disc"),0,tr("Back")); + menu = MENU_DISCLIST; + break; + } + ret = Disc_Open(); + if (ret < 0) { + WindowPrompt (tr("Could not open Disc"),0,tr("Back")); + menu = MENU_DISCLIST; + break; + } - ret = Disc_IsWii(); - if (ret < 0) { - choice = WindowPrompt (tr("Not a Wii Disc"),tr("Insert a Wii Disc!"),tr("OK"),tr("Back")); + ret = Disc_IsWii(); + if (ret < 0) { + choice = WindowPrompt (tr("Not a Wii Disc"),tr("Insert a Wii Disc!"),tr("OK"),tr("Back")); - if (choice == 1) { - menu = MENU_INSTALL; - break; - } else - menu = MENU_DISCLIST; - break; - } + if (choice == 1) { + menu = MENU_INSTALL; + break; + } else + menu = MENU_DISCLIST; + break; + } - Disc_ReadHeader(&headerdisc); - snprintf(name, sizeof(name), "%s", headerdisc.title); + Disc_ReadHeader(&headerdisc); + snprintf(name, sizeof(name), "%s", headerdisc.title); - ret = WBFS_CheckGame(headerdisc.id); - if (ret) { - WindowPrompt (tr("Game is already installed:"),name,tr("Back")); - menu = MENU_DISCLIST; - break; - } + ret = WBFS_CheckGame(headerdisc.id); + if (ret) { + WindowPrompt (tr("Game is already installed:"),name,tr("Back")); + menu = MENU_DISCLIST; + break; + } - f32 freespace, used; + f32 freespace, used; - WBFS_DiskSpace(&used, &freespace); - gamesize = WBFS_EstimeGameSize()/GBSIZE; + WBFS_DiskSpace(&used, &freespace); + gamesize = WBFS_EstimeGameSize()/GBSIZE; - char gametxt[50]; + char gametxt[50]; - sprintf(gametxt, "%s : %.2fGB", name, gamesize); + sprintf(gametxt, "%s : %.2fGB", name, gamesize); wiilight(1); - choice = WindowPrompt(tr("Continue to install game?"),gametxt,tr("OK"),tr("Cancel")); + choice = WindowPrompt(tr("Continue to install game?"),gametxt,tr("OK"),tr("Cancel")); - if(choice == 1) { + if (choice == 1) { - sprintf(gametxt, "%s", tr("Installing game:")); + sprintf(gametxt, "%s", tr("Installing game:")); - if (gamesize > freespace) { - char errortxt[50]; - sprintf(errortxt, "%s: %.2fGB, %s: %.2fGB",tr("Game Size"), gamesize, tr("Free Space"), freespace); - WindowPrompt(tr("Not enough free space!"),errortxt,tr("OK")); - menu = MENU_DISCLIST; - break; - } - else { - USBStorage_Watchdog(0); - SetupGameInstallProgress(gametxt, name); - ret = WBFS_AddGame(); - ProgressStop(); - USBStorage_Watchdog(1); + if (gamesize > freespace) { + char errortxt[50]; + sprintf(errortxt, "%s: %.2fGB, %s: %.2fGB",tr("Game Size"), gamesize, tr("Free Space"), freespace); + WindowPrompt(tr("Not enough free space!"),errortxt,tr("OK")); + menu = MENU_DISCLIST; + break; + } else { + USBStorage_Watchdog(0); + SetupGameInstallProgress(gametxt, name); + ret = WBFS_AddGame(); + ProgressStop(); + USBStorage_Watchdog(1); + wiilight(0); + if (ret != 0) { + WindowPrompt(tr("Install Error!"),0,tr("Back")); + menu = MENU_DISCLIST; + break; + } else { + __Menu_GetEntries(); //get the entries again + WindowPrompt (tr("Successfully installed:"),name,tr("OK")); + menu = MENU_DISCLIST; + break; + } + } + } else { + menu = MENU_DISCLIST; + break; + } + + if (shutdown == 1) { wiilight(0); - if (ret != 0) { - WindowPrompt(tr("Install Error!"),0,tr("Back")); - menu = MENU_DISCLIST; - break; - } else { - __Menu_GetEntries(); //get the entries again - WindowPrompt (tr("Successfully installed:"),name,tr("OK")); - menu = MENU_DISCLIST; - break; - } - } - } else { - menu = MENU_DISCLIST; - break; - } - - if (shutdown == 1) { - wiilight(0); - Sys_Shutdown(); - } - if(reset == 1) { - wiilight(0); - Sys_Reboot(); - } - } + Sys_Shutdown(); + } + if (reset == 1) { + wiilight(0); + Sys_Reboot(); + } + } //Turn off the WiiLight wiilight(0); - HaltGui(); + HaltGui(); - mainWindow->Remove(&w); - ResumeGui(); - return menu; + mainWindow->Remove(&w); + ResumeGui(); + return menu; } /**************************************************************************** * MenuFormat ***************************************************************************/ -static int MenuFormat() -{ - USBDevice_deInit(); - int menu = MENU_NONE; - char imgPath[100]; +static int MenuFormat() { + USBDevice_deInit(); + int menu = MENU_NONE; + char imgPath[100]; - OptionList options; + OptionList options; partitionEntry partitions[MAX_PARTITIONS]; - u32 cnt, sector_size, selected = 2000; - int choice, ret; - char text[ISFS_MAXPATH]; + u32 cnt, sector_size, selected = 2000; + int choice, ret; + char text[ISFS_MAXPATH]; - s32 ret2; + s32 ret2; ret2 = Partition_GetEntries(partitions, §or_size); - //create the partitionlist + //create the partitionlist for (cnt = 0; cnt < MAX_PARTITIONS; cnt++) { - partitionEntry *entry = &partitions[cnt]; + partitionEntry *entry = &partitions[cnt]; - /* Calculate size in gigabytes */ - f32 size = entry->size * (sector_size / GBSIZE); + /* Calculate size in gigabytes */ + f32 size = entry->size * (sector_size / GBSIZE); if (size) { sprintf(options.name[cnt], "%s %d:",tr("Partition"), cnt+1); @@ -1596,71 +1517,66 @@ static int MenuFormat() options.length = cnt; - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff.png", CFG.theme_path); - GuiImageData btnpwroff(imgPath, wiimote_poweroff_png); - snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff_over.png", CFG.theme_path); - GuiImageData btnpwroffOver(imgPath, wiimote_poweroff_over_png); - snprintf(imgPath, sizeof(imgPath), "%smenu_button.png", CFG.theme_path); - GuiImageData btnhome(imgPath, menu_button_png); - snprintf(imgPath, sizeof(imgPath), "%smenu_button_over.png", CFG.theme_path); - GuiImageData btnhomeOver(imgPath, menu_button_over_png); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff.png", CFG.theme_path); + GuiImageData btnpwroff(imgPath, wiimote_poweroff_png); + snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff_over.png", CFG.theme_path); + GuiImageData btnpwroffOver(imgPath, wiimote_poweroff_over_png); + snprintf(imgPath, sizeof(imgPath), "%smenu_button.png", CFG.theme_path); + GuiImageData btnhome(imgPath, menu_button_png); + snprintf(imgPath, sizeof(imgPath), "%smenu_button_over.png", CFG.theme_path); + GuiImageData btnhomeOver(imgPath, menu_button_over_png); GuiImageData battery(battery_png); - GuiImageData batteryRed(battery_red_png); - GuiImageData batteryBar(battery_bar_png); + GuiImageData batteryRed(battery_red_png); + GuiImageData batteryBar(battery_bar_png); GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigHome; + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); GuiImage poweroffBtnImg(&btnpwroff); - GuiImage poweroffBtnImgOver(&btnpwroffOver); - poweroffBtnImg.SetWidescreen(CFG.widescreen); - poweroffBtnImgOver.SetWidescreen(CFG.widescreen); - GuiButton poweroffBtn(&poweroffBtnImg,&poweroffBtnImgOver, 0, 3, THEME.power_x, THEME.power_y, &trigA, &btnSoundOver, &btnClick,1); - GuiImage exitBtnImg(&btnhome); - GuiImage exitBtnImgOver(&btnhomeOver); - exitBtnImg.SetWidescreen(CFG.widescreen); - exitBtnImgOver.SetWidescreen(CFG.widescreen); - GuiButton exitBtn(&exitBtnImg,&exitBtnImgOver, 0, 3, 0,-10, &trigA, &btnSoundOver, &btnClick,1); - exitBtn.SetTrigger(&trigHome); + GuiImage poweroffBtnImgOver(&btnpwroffOver); + poweroffBtnImg.SetWidescreen(CFG.widescreen); + poweroffBtnImgOver.SetWidescreen(CFG.widescreen); + GuiButton poweroffBtn(&poweroffBtnImg,&poweroffBtnImgOver, 0, 3, THEME.power_x, THEME.power_y, &trigA, &btnSoundOver, &btnClick,1); + GuiImage exitBtnImg(&btnhome); + GuiImage exitBtnImgOver(&btnhomeOver); + exitBtnImg.SetWidescreen(CFG.widescreen); + exitBtnImgOver.SetWidescreen(CFG.widescreen); + GuiButton exitBtn(&exitBtnImg,&exitBtnImgOver, 0, 3, 0,-10, &trigA, &btnSoundOver, &btnClick,1); + exitBtn.SetTrigger(&trigHome); - GuiOptionBrowser optionBrowser(THEME.selection_w, THEME.selection_h, &options, CFG.theme_path, bg_options_png, 1, 0); - optionBrowser.SetPosition(THEME.selection_x, THEME.selection_y); - optionBrowser.SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); + GuiOptionBrowser optionBrowser(THEME.selection_w, THEME.selection_h, &options, CFG.theme_path, bg_options_png, 1, 0); + optionBrowser.SetPosition(THEME.selection_x, THEME.selection_y); + optionBrowser.SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); optionBrowser.SetCol2Position(200); HaltGui(); - GuiWindow w(screenwidth, screenheight); + GuiWindow w(screenwidth, screenheight); w.Append(&poweroffBtn); - w.Append(&exitBtn); + w.Append(&exitBtn); mainWindow->Append(&w); mainWindow->Append(&optionBrowser); - ResumeGui(); + ResumeGui(); - while(menu == MENU_NONE) - { - VIDEO_WaitVSync (); + while (menu == MENU_NONE) { + VIDEO_WaitVSync (); - selected = optionBrowser.GetClickedOption(); + selected = optionBrowser.GetClickedOption(); - for (cnt = 0; cnt < MAX_PARTITIONS; cnt++) { - if ((cnt == selected)&&((Settings.godmode == 1)|| - (!strcmp("", Settings.unlockCode)))){ - partitionEntry *entry = &partitions[selected]; - if (entry->size) { - sprintf(text, "%s %d : %.2fGB",tr("Partition"), selected+1, entry->size * (sector_size / GBSIZE)); - choice = WindowPrompt( - tr("Do you want to format:"), - text, - tr("Yes"), - tr("No")); - if(choice == 1) { - ret = FormatingPartition(tr("Formatting, please wait..."), entry); + for (cnt = 0; cnt < MAX_PARTITIONS; cnt++) { + if ((cnt == selected)&&((Settings.godmode == 1)|| + (!strcmp("", Settings.unlockCode)))) { + partitionEntry *entry = &partitions[selected]; + if (entry->size) { + sprintf(text, "%s %d : %.2fGB",tr("Partition"), selected+1, entry->size * (sector_size / GBSIZE)); + choice = WindowPrompt( tr("Do you want to format:"), text,tr("Yes"),tr("No")); + if (choice == 1) { + ret = FormatingPartition(tr("Formatting, please wait..."), entry); if (ret < 0) { WindowPrompt(tr("Error !"),tr("Failed formating"),tr("Return")); menu = MENU_SETTINGS; @@ -1672,460 +1588,437 @@ static int MenuFormat() menu = MENU_DISCLIST; } } + } + } else if ( (cnt == selected)&&(Settings.godmode == 0) ) { + mainWindow->Remove(&optionBrowser); + char entered[20] = ""; + int result = OnScreenKeyboard(entered, 20,0); + mainWindow->Append(&optionBrowser); + if ( result == 1 ) { + if (!strcmp(entered, Settings.unlockCode)) { //if password correct + if (Settings.godmode == 0) { + WindowPrompt(tr("Correct Password"),tr("All the features of USB Loader GX are unlocked."),tr("OK")); + Settings.godmode = 1; + } + } else { + WindowPrompt(tr("Wrong Password"),tr("USB Loader GX is protected"),tr("OK")); } } - else if ( (cnt == selected)&&(Settings.godmode == 0) ) { - mainWindow->Remove(&optionBrowser); - char entered[20] = ""; - int result = OnScreenKeyboard(entered, 20,0); - mainWindow->Append(&optionBrowser); - if ( result == 1 ) { - if (!strcmp(entered, Settings.unlockCode)) //if password correct - { - if (Settings.godmode == 0) { - WindowPrompt(tr("Correct Password"),tr("All the features of USB Loader GX are unlocked."),tr("OK")); - Settings.godmode = 1; - } - } else { - WindowPrompt(tr("Wrong Password"),tr("USB Loader GX is protected"),tr("OK")); - } - } - } } - if (shutdown == 1) - Sys_Shutdown(); - if(reset == 1) - Sys_Reboot(); + } + if (shutdown == 1) + Sys_Shutdown(); + if (reset == 1) + Sys_Reboot(); - if(poweroffBtn.GetState() == STATE_CLICKED) - { - choice = WindowPrompt (tr("Shutdown System"),tr("Are you sure?"),tr("Yes"),tr("No")); - if(choice == 1) - { - Sys_Shutdown(); - } + if (poweroffBtn.GetState() == STATE_CLICKED) { + choice = WindowPrompt (tr("Shutdown System"),tr("Are you sure?"),tr("Yes"),tr("No")); + if (choice == 1) { + Sys_Shutdown(); + } - } else if(exitBtn.GetState() == STATE_CLICKED) - { - choice = WindowPrompt (tr("Return to Wii Menu"),tr("Are you sure?"),tr("Yes"),tr("No")); - if(choice == 1) - { - Sys_LoadMenu(); - } - } - } + } else if (exitBtn.GetState() == STATE_CLICKED) { + choice = WindowPrompt (tr("Return to Wii Menu"),tr("Are you sure?"),tr("Yes"),tr("No")); + if (choice == 1) { + Sys_LoadMenu(); + } + } + } - HaltGui(); + HaltGui(); - mainWindow->Remove(&optionBrowser); - mainWindow->Remove(&w); - ResumeGui(); - USBDevice_Init(); - return menu; + mainWindow->Remove(&optionBrowser); + mainWindow->Remove(&w); + ResumeGui(); + USBDevice_Init(); + return menu; } /**************************************************************************** * MenuCheck ***************************************************************************/ -static int MenuCheck() -{ - int menu = MENU_NONE; - int i = 0; - int choice; - s32 ret2, wbfsinit; - OptionList options; - options.length = i; - partitionEntry partitions[MAX_PARTITIONS]; +static int MenuCheck() { + int menu = MENU_NONE; + int i = 0; + int choice; + s32 ret2, wbfsinit; + OptionList options; + options.length = i; + partitionEntry partitions[MAX_PARTITIONS]; - VIDEO_WaitVSync (); - OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride==1?true:false, true); + VIDEO_WaitVSync (); + OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride==1?true:false, true); - wbfsinit = WBFS_Init(WBFS_DEVICE_USB); - if (wbfsinit < 0) - { - ret2 = WindowPrompt(tr("No USB Device found."), - tr("Do you want to retry for 30 secs?"), - "cIOS249", "cIOS222", - tr("Back to Wii Menu")); - SDCard_deInit(); - USBDevice_deInit(); - WPAD_Flush(0); - WPAD_Disconnect(0); - WPAD_Shutdown(); - if(ret2 == 1) { - Settings.cios = ios249; - } else if(ret2 == 2) { - Settings.cios = ios222; - } else { - Sys_LoadMenu(); - } - ret2 = DiscWait(tr("No USB Device"), tr("Waiting for USB Device"), 0, 0, 1); - //reinitialize SD and USB - Wpad_Init(); - WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); - WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); - if (ret2 < 0) { - WindowPrompt (tr("Error !"),tr("USB Device not found"), tr("OK")); - Sys_LoadMenu(); - } - } - - ret2 = Disc_Init(); - if (ret2 < 0) { - WindowPrompt (tr("Error !"),tr("Could not initialize DIP module!"),tr("OK")); + wbfsinit = WBFS_Init(WBFS_DEVICE_USB); + if (wbfsinit < 0) { + ret2 = WindowPrompt(tr("No USB Device found."), tr("Do you want to retry for 30 secs?"), "cIOS249", "cIOS222", tr("Back to Wii Menu")); + SDCard_deInit(); + USBDevice_deInit(); + WPAD_Flush(0); + WPAD_Disconnect(0); + WPAD_Shutdown(); + if (ret2 == 1) { + Settings.cios = ios249; + } else if (ret2 == 2) { + Settings.cios = ios222; + } else { Sys_LoadMenu(); } - - ret2 = WBFS_Open(); + ret2 = DiscWait(tr("No USB Device"), tr("Waiting for USB Device"), 0, 0, 1); + //reinitialize SD and USB + Wpad_Init(); + WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); + WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); if (ret2 < 0) { - choice = WindowPrompt(tr("No WBFS partition found"), - tr("You need to format a partition"), - tr("Format"), - tr("Return")); - if(choice == 0) - { - Sys_LoadMenu(); - } else { - /* Get partition entries */ - u32 sector_size; - ret2 = Partition_GetEntries(partitions, §or_size); - if (ret2 < 0) { - WindowPrompt (tr("No partitions found"),0, tr("Restart")); - Sys_LoadMenu(); - } - menu = MENU_FORMAT; - } + WindowPrompt (tr("Error !"),tr("USB Device not found"), tr("OK")); + Sys_LoadMenu(); } + } - if(shutdown == 1) - Sys_Shutdown(); - if(reset == 1) - Sys_Reboot(); + ret2 = Disc_Init(); + if (ret2 < 0) { + WindowPrompt (tr("Error !"),tr("Could not initialize DIP module!"),tr("OK")); + Sys_LoadMenu(); + } - if(wbfsinit < 0) { - sleep(1); + ret2 = WBFS_Open(); + if (ret2 < 0) { + choice = WindowPrompt(tr("No WBFS partition found"),tr("You need to format a partition"), tr("Format"),tr("Return")); + if (choice == 0) { + Sys_LoadMenu(); + } else { + /* Get partition entries */ + u32 sector_size; + ret2 = Partition_GetEntries(partitions, §or_size); + if (ret2 < 0) { + WindowPrompt (tr("No partitions found"),0, tr("Restart")); + Sys_LoadMenu(); + } + menu = MENU_FORMAT; } + } - //Spieleliste laden - __Menu_GetEntries(0); + if (shutdown == 1) + Sys_Shutdown(); + if (reset == 1) + Sys_Reboot(); - if(menu == MENU_NONE) - menu = MENU_DISCLIST; + if (wbfsinit < 0) { + sleep(1); + } - //for HDDs with issues - if(wbfsinit < 0) { - sleep(1); - USBDevice_Init(); - SDCard_Init(); - } + //Spieleliste laden + __Menu_GetEntries(0); - return menu; + if (menu == MENU_NONE) + menu = MENU_DISCLIST; + + //for HDDs with issues + if (wbfsinit < 0) { + sleep(1); + USBDevice_Init(); + SDCard_Init(); + } + + return menu; } /**************************************************************************** * MainMenu ***************************************************************************/ -int MainMenu(int menu) -{ +int MainMenu(int menu) { - currentMenu = menu; - char imgPath[100]; + currentMenu = menu; + char imgPath[100]; - #ifdef HW_RVL - snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); - pointer[0] = new GuiImageData(imgPath, player1_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path); - pointer[1] = new GuiImageData(imgPath, player2_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer3_point.png", CFG.theme_path); - pointer[2] = new GuiImageData(imgPath, player3_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); - pointer[3] = new GuiImageData(imgPath, player4_point_png); - #endif +#ifdef HW_RVL + snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); + pointer[0] = new GuiImageData(imgPath, player1_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path); + pointer[1] = new GuiImageData(imgPath, player2_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer3_point.png", CFG.theme_path); + pointer[2] = new GuiImageData(imgPath, player3_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); + pointer[3] = new GuiImageData(imgPath, player4_point_png); +#endif - mainWindow = new GuiWindow(screenwidth, screenheight); + mainWindow = new GuiWindow(screenwidth, screenheight); - if (CFG.widescreen) - snprintf(imgPath, sizeof(imgPath), "%swbackground.png", CFG.theme_path); - else - snprintf(imgPath, sizeof(imgPath), "%sbackground.png", CFG.theme_path); + if (CFG.widescreen) + snprintf(imgPath, sizeof(imgPath), "%swbackground.png", CFG.theme_path); + else + snprintf(imgPath, sizeof(imgPath), "%sbackground.png", CFG.theme_path); - background = new GuiImageData(imgPath, CFG.widescreen? wbackground_png : background_png); + background = new GuiImageData(imgPath, CFG.widescreen? wbackground_png : background_png); bgImg = new GuiImage(background); - mainWindow->Append(bgImg); + mainWindow->Append(bgImg); - ResumeGui(); + ResumeGui(); bgMusic = new GuiSound(bg_music_ogg, bg_music_ogg_size, SOUND_OGG, Settings.volume); bgMusic->SetVolume(Settings.volume); - bgMusic->SetLoop(1); //loop music + bgMusic->SetLoop(1); //loop music // startup music - 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); } - while(currentMenu != MENU_EXIT) - { - SetVolumeOgg(255*(Settings.volume/100.0)); + while (currentMenu != MENU_EXIT) { + SetVolumeOgg(255*(Settings.volume/100.0)); - switch (currentMenu) - { - case MENU_CHECK: - currentMenu = MenuCheck(); - break; - case MENU_FORMAT: - currentMenu = MenuFormat(); - break; - case MENU_INSTALL: - currentMenu = MenuInstall(); - break; - case MENU_SETTINGS: - currentMenu = MenuSettings(); - break; - case MENU_HOMEBREWBROWSE: - currentMenu = MenuHomebrewBrowse(); - break; - case MENU_DISCLIST: - currentMenu = MenuDiscList(); - break; - default: // unrecognized menu - currentMenu = MenuCheck(); - break; - } - } + switch (currentMenu) { + case MENU_CHECK: + currentMenu = MenuCheck(); + break; + case MENU_FORMAT: + currentMenu = MenuFormat(); + break; + case MENU_INSTALL: + currentMenu = MenuInstall(); + break; + case MENU_SETTINGS: + currentMenu = MenuSettings(); + break; + case MENU_HOMEBREWBROWSE: + currentMenu = MenuHomebrewBrowse(); + break; + case MENU_DISCLIST: + currentMenu = MenuDiscList(); + break; + default: // unrecognized menu + currentMenu = MenuCheck(); + break; + } + } - CloseXMLDatabase(); - ExitGUIThreads(); + CloseXMLDatabase(); + ExitGUIThreads(); bgMusic->Stop(); - delete bgMusic; - delete background; - delete bgImg; - delete mainWindow; - for(int i = 0; i < 4; i++) - delete pointer[i]; + delete bgMusic; + delete background; + delete bgImg; + delete mainWindow; + for (int i = 0; i < 4; i++) + delete pointer[i]; delete GameRegionTxt; delete GameIDTxt; - delete cover; - delete coverImg; + delete cover; + delete coverImg; - ShutdownAudio(); - StopGX(); + ShutdownAudio(); + StopGX(); - if(boothomebrew == 1) { + if (boothomebrew == 1) { BootHomebrew(Settings.selected_homebrew); - } else if(boothomebrew == 2) { + } else if (boothomebrew == 2) { BootHomebrewFromMem(); } else { - int ret = 0; - struct discHdr *header = &gameList[gameSelected]; + int ret = 0; + struct discHdr *header = &gameList[gameSelected]; - struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); + struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); - if (game_cfg) { - videoChoice = game_cfg->video; - languageChoice = game_cfg->language; - ocarinaChoice = game_cfg->ocarina; - viChoice = game_cfg->vipatch; - fix002 = game_cfg->errorfix002; - iosChoice = game_cfg->ios; - countrystrings = game_cfg->patchcountrystrings; - alternatedol = game_cfg->loadalternatedol; - alternatedoloffset = game_cfg->alternatedolstart; - reloadblock = game_cfg->iosreloadblock; - } else { - videoChoice = Settings.video; - languageChoice = Settings.language; - ocarinaChoice = Settings.ocarina; - viChoice = Settings.vpatch; - if(Settings.cios == ios222) { - iosChoice = i222; - } else { - iosChoice = i249; - } - fix002 = Settings.error002; - countrystrings = Settings.patchcountrystrings; - alternatedol = off; - alternatedoloffset = 0; - reloadblock = off; - } - int ios2; - switch(iosChoice) { - case i249: - ios2 = 249; - break; + if (game_cfg) { + videoChoice = game_cfg->video; + languageChoice = game_cfg->language; + ocarinaChoice = game_cfg->ocarina; + viChoice = game_cfg->vipatch; + fix002 = game_cfg->errorfix002; + iosChoice = game_cfg->ios; + countrystrings = game_cfg->patchcountrystrings; + alternatedol = game_cfg->loadalternatedol; + alternatedoloffset = game_cfg->alternatedolstart; + reloadblock = game_cfg->iosreloadblock; + } else { + videoChoice = Settings.video; + languageChoice = Settings.language; + ocarinaChoice = Settings.ocarina; + viChoice = Settings.vpatch; + if (Settings.cios == ios222) { + iosChoice = i222; + } else { + iosChoice = i249; + } + fix002 = Settings.error002; + countrystrings = Settings.patchcountrystrings; + alternatedol = off; + alternatedoloffset = 0; + reloadblock = off; + } + int ios2; + switch (iosChoice) { + case i249: + ios2 = 249; + break; - case i222: - ios2 = 222; - break; + case i222: + ios2 = 222; + break; - case i223: - ios2 = 223; - break; + case i223: + ios2 = 223; + break; - default: - ios2 = 249; - break; - } + default: + ios2 = 249; + break; + } - bool onlinefix = ShutdownWC24(); - if(IOS_GetVersion() != ios2 || onlinefix == true) { - ret = Sys_IosReload(ios2); - if(ret < 0) { - Sys_IosReload(249); - } - } - ret = Disc_SetUSB(header->id); - if(ret < 0) Sys_BackToLoader(); - ret = Disc_Open(); - if(ret < 0) Sys_BackToLoader(); + bool onlinefix = ShutdownWC24(); + if (IOS_GetVersion() != ios2 || onlinefix == true) { + ret = Sys_IosReload(ios2); + if (ret < 0) { + Sys_IosReload(249); + } + } + ret = Disc_SetUSB(header->id); + if (ret < 0) Sys_BackToLoader(); + ret = Disc_Open(); + if (ret < 0) Sys_BackToLoader(); - SDCard_deInit(); - USBDevice_deInit(); + SDCard_deInit(); + USBDevice_deInit(); - if(reloadblock == on && (IOS_GetVersion() == 222 || IOS_GetVersion() == 223)) { - patch_cios_data(); - mload_close(); - } + if (reloadblock == on && (IOS_GetVersion() == 222 || IOS_GetVersion() == 223)) { + patch_cios_data(); + mload_close(); + } - u8 errorfixer002 = 0; - switch(fix002) - { + u8 errorfixer002 = 0; + switch (fix002) { case on: errorfixer002 = 1; break; case off: errorfixer002 = 0; - break; - case anti: - errorfixer002 = 2; break; - } + case anti: + errorfixer002 = 2; + break; + } - switch(languageChoice) - { - case ConsoleLangDefault: - configbytes[0] = 0xCD; - break; + switch (languageChoice) { + case ConsoleLangDefault: + configbytes[0] = 0xCD; + break; - case jap: - configbytes[0] = 0x00; - break; + case jap: + configbytes[0] = 0x00; + break; - case eng: - configbytes[0] = 0x01; - break; + case eng: + configbytes[0] = 0x01; + break; - case ger: - configbytes[0] = 0x02; - break; + case ger: + configbytes[0] = 0x02; + break; - case fren: - configbytes[0] = 0x03; - break; + case fren: + configbytes[0] = 0x03; + break; - case esp: - configbytes[0] = 0x04; - break; + case esp: + configbytes[0] = 0x04; + break; - case it: - configbytes[0] = 0x05; - break; + case it: + configbytes[0] = 0x05; + break; - case dut: - configbytes[0] = 0x06; - break; + case dut: + configbytes[0] = 0x06; + break; - case schin: - configbytes[0] = 0x07; - break; + case schin: + configbytes[0] = 0x07; + break; - case tchin: - configbytes[0] = 0x08; - break; + case tchin: + configbytes[0] = 0x08; + break; - case kor: - configbytes[0] = 0x09; - break; - //wenn nicht genau klar ist welches - default: - configbytes[0] = 0xCD; - break; - } + case kor: + configbytes[0] = 0x09; + break; + //wenn nicht genau klar ist welches + default: + configbytes[0] = 0xCD; + break; + } - u8 videoselected = 0; + u8 videoselected = 0; - switch(videoChoice) - { - case discdefault: - videoselected = 0; - break; + switch (videoChoice) { + case discdefault: + videoselected = 0; + break; - case pal50: - videoselected = 1; - break; + case pal50: + videoselected = 1; + break; - case pal60: - videoselected = 2; - break; + case pal60: + videoselected = 2; + break; - case ntsc: - videoselected = 3; - break; + case ntsc: + videoselected = 3; + break; - case systemdefault: - videoselected = 4; - break; + case systemdefault: + videoselected = 4; + break; - case patch: - videoselected = 5; - break; + case patch: + videoselected = 5; + break; - default: - videoselected = 0; - break; - } + default: + videoselected = 0; + break; + } - u32 cheat = 0; - switch(ocarinaChoice) - { - case on: - cheat = 1; - break; + u32 cheat = 0; + switch (ocarinaChoice) { + case on: + cheat = 1; + break; - case off: - cheat = 0; - break; + case off: + cheat = 0; + break; - default: - cheat = 1; - break; - } + default: + cheat = 1; + break; + } - u8 vipatch = 0; - switch(viChoice) - { - case on: - vipatch = 1; - break; + u8 vipatch = 0; + switch (viChoice) { + case on: + vipatch = 1; + break; - case off: - vipatch = 0; - break; + case off: + vipatch = 0; + break; - default: - vipatch = 0; - break; - } + default: + vipatch = 0; + break; + } - ret = Disc_WiiBoot(videoselected, cheat, vipatch, countrystrings, errorfixer002, alternatedol, alternatedoloffset); - if (ret < 0) { - Sys_LoadMenu(); - } + ret = Disc_WiiBoot(videoselected, cheat, vipatch, countrystrings, errorfixer002, alternatedol, alternatedoloffset); + if (ret < 0) { + Sys_LoadMenu(); + } } return 0; diff --git a/source/menu.h b/source/menu.h index 5cad172a..0819c0bf 100644 --- a/source/menu.h +++ b/source/menu.h @@ -10,26 +10,25 @@ #define _MENU_H_ #include -#include "settings/cfg.h" +#include "settings/cfg.h" #include "main.h" void InitGUIThreads(void); -void ExitGUIThreads(void); - -int MainMenu (int menuitem); +void ExitGUIThreads(void); -enum -{ - MENU_EXIT = -1, - MENU_NONE, - MENU_SETTINGS, - MENU_DISCLIST, - MENU_FORMAT, - MENU_INSTALL, - MENU_CHECK, - MENU_GAME_SETTINGS, - MENU_HOMEBREWBROWSE, - BOOTHOMEBREW +int MainMenu (int menuitem); + +enum { + MENU_EXIT = -1, + MENU_NONE, + MENU_SETTINGS, + MENU_DISCLIST, + MENU_FORMAT, + MENU_INSTALL, + MENU_CHECK, + MENU_GAME_SETTINGS, + MENU_HOMEBREWBROWSE, + BOOTHOMEBREW }; #endif diff --git a/source/mload/dip_plugin.c b/source/mload/dip_plugin.c index 0c37593d..a32995b4 100644 --- a/source/mload/dip_plugin.c +++ b/source/mload/dip_plugin.c @@ -1,140 +1,140 @@ #define size_dip_plugin 3700 unsigned char dip_plugin[3700] __attribute__((aligned (32)))={ - 19, 119, 230, 81, 18, 52, 0, 1, 32, 34, 205, 172, 32, 32, 13, 57, 32, 32, 8, 197, 32, 32, 8, 153, 32, 32, 91, 129, 32, - 32, 0, 73, 32, 32, 40, 117, 32, 32, 54, 93, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 19, 119, 235, 77, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 71, 120, 234, 0, 2, 143, 70, 192, 71, - 120, 234, 0, 2, 159, 70, 192, 71, 120, 234, 0, 2, 175, 70, 192, 71, 120, 234, 0, 2, 167, 70, 192, 71, 120, 234, 0, 2, - 141, 70, 192, 71, 120, 234, 0, 2, 127, 70, 192, 71, 120, 234, 0, 2, 165, 70, 192, 71, 120, 234, 0, 2, 161, 70, 192, - 71, 120, 234, 0, 2, 167, 70, 192, 71, 120, 234, 0, 2, 167, 181, 0, 75, 7, 176, 137, 147, 0, 70, 104, 35, 0, 33, 0, 34, - 0, 147, 1, 147, 2, 240, 0, 253, 93, 176, 9, 188, 2, 71, 8, 70, 192, 227, 0, 0, 0, 181, 16, 28, 3, 34, 32, 28, 12, 72, - 13, 28, 25, 247, 255, 255, 206, 33, 32, 72, 11, 247, 255, 255, 198, 73, 10, 34, 1, 104, 11, 66, 19, 209, 253, 34, 32, - 28, 32, 73, 6, 247, 255, 255, 192, 28, 32, 33, 32, 247, 255, 255, 184, 75, 4, 104, 24, 188, 16, 188, 2, 71, 8, 70, 192, - 13, 0, 96, 0, 13, 0, 96, 28, 13, 0, 96, 32, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 10, 203, 70, 154, 75, - 20, 176, 137, 37, 0, 28, 7, 28, 14, 70, 145, 70, 108, 70, 155, 70, 168, 70, 91, 96, 35, 70, 67, 96, 99, 96, 163, 70, - 83, 96, 227, 28, 56, 70, 75, 28, 49, 97, 35, 247, 255, 255, 158, 70, 104, 28, 57, 28, 50, 240, 0, 253, 14, 53, 1, 40, - 0, 209, 8, 176, 9, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 45, 15, 217, 223, 231, 243, - 208, 0, 0, 0, 181, 112, 176, 136, 75, 8, 28, 6, 28, 13, 70, 108, 147, 0, 96, 97, 146, 2, 247, 255, 255, 125, 28, 49, - 28, 42, 70, 104, 240, 0, 252, 237, 176, 8, 188, 112, 188, 2, 71, 8, 168, 0, 0, 0, 181, 240, 70, 95, 70, 86, 70, 77, - 70, 68, 180, 240, 176, 143, 144, 4, 145, 3, 146, 2, 41, 0, 209, 0, 224, 126, 10, 82, 70, 145, 35, 128, 34, 0, 1, 27, - 70, 147, 34, 255, 147, 1, 3, 210, 171, 6, 146, 0, 70, 152, 224, 7, 154, 3, 68, 179, 69, 90, 217, 62, 154, 5, 24, 179, - 10, 219, 68, 153, 154, 3, 70, 91, 26, 214, 70, 74, 2, 83, 154, 2, 66, 154, 216, 87, 35, 0, 147, 5, 36, 0, 159, 4, 34, - 128, 68, 95, 28, 56, 28, 49, 1, 18, 240, 0, 248, 103, 44, 0, 209, 47, 40, 0, 208, 45, 155, 0, 28, 6, 66, 152, 217, 1, - 38, 255, 3, 246, 10, 242, 70, 146, 36, 0, 75, 43, 70, 66, 96, 19, 35, 0, 96, 83, 96, 147, 70, 83, 96, 211, 70, 75, 97, - 19, 28, 56, 28, 49, 247, 255, 255, 34, 70, 64, 28, 57, 28, 50, 240, 0, 252, 146, 52, 1, 28, 5, 40, 0, 208, 192, 44, - 15, 217, 230, 45, 0, 208, 188, 176, 15, 28, 40, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, - 154, 5, 25, 147, 154, 1, 66, 147, 217, 1, 155, 5, 26, 214, 32, 128, 1, 0, 33, 32, 247, 255, 254, 247, 28, 4, 40, 0, - 208, 18, 33, 128, 1, 9, 70, 74, 247, 255, 255, 59, 28, 5, 40, 0, 208, 15, 28, 32, 247, 255, 254, 213, 231, 216, 26, - 211, 0, 155, 28, 28, 147, 5, 30, 99, 65, 156, 231, 163, 37, 1, 66, 109, 231, 208, 37, 0, 231, 206, 154, 5, 28, 56, 24, - 161, 28, 50, 247, 255, 254, 210, 28, 56, 28, 49, 247, 255, 254, 202, 231, 228, 70, 192, 208, 0, 0, 0, 181, 48, 28, 13, - 28, 20, 6, 195, 209, 18, 75, 15, 66, 152, 217, 19, 33, 0, 75, 14, 24, 194, 75, 14, 66, 154, 216, 1, 75, 13, 26, 25, - 66, 161, 211, 5, 28, 8, 66, 169, 216, 10, 30, 99, 67, 152, 224, 0, 32, 0, 188, 48, 188, 2, 71, 8, 35, 192, 4, 91, 26, - 25, 231, 232, 28, 40, 30, 99, 67, 152, 231, 244, 1, 127, 255, 255, 240, 0, 0, 0, 3, 97, 127, 255, 19, 97, 128, 0, 181, - 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 70, 137, 176, 129, 73, 51, 34, 4, 28, 7, 240, 0, 250, 235, 40, 0, 209, - 3, 35, 128, 0, 91, 69, 153, 208, 13, 75, 47, 70, 154, 120, 27, 43, 0, 209, 81, 176, 1, 188, 60, 70, 144, 70, 153, 70, - 162, 70, 171, 188, 240, 188, 1, 71, 0, 74, 40, 35, 10, 70, 146, 112, 19, 38, 243, 75, 38, 74, 39, 37, 0, 70, 152, 70, - 147, 224, 2, 53, 1, 66, 181, 210, 19, 25, 124, 28, 32, 70, 65, 34, 13, 240, 0, 250, 195, 40, 0, 209, 244, 70, 89, 34, - 13, 28, 32, 247, 255, 254, 98, 53, 1, 28, 32, 33, 13, 247, 255, 254, 89, 66, 181, 211, 235, 34, 12, 66, 82, 68, 74, - 70, 144, 42, 0, 208, 27, 75, 23, 37, 0, 78, 23, 70, 153, 224, 2, 53, 1, 69, 69, 210, 19, 25, 124, 28, 32, 28, 49, 34, - 12, 240, 0, 250, 161, 40, 0, 209, 244, 70, 73, 34, 12, 28, 32, 247, 255, 254, 64, 53, 1, 28, 32, 33, 12, 247, 255, 254, - 55, 69, 69, 211, 235, 70, 82, 120, 19, 59, 1, 112, 19, 231, 173, 70, 78, 62, 13, 46, 0, 209, 183, 231, 211, 70, 192, - 19, 119, 235, 176, 19, 119, 238, 128, 19, 119, 235, 217, 19, 119, 235, 204, 19, 119, 235, 180, 19, 119, 235, 192, 181, - 48, 28, 4, 72, 15, 28, 13, 104, 131, 104, 193, 176, 129, 24, 91, 24, 154, 105, 3, 43, 0, 209, 15, 104, 67, 43, 0, 209, - 7, 28, 32, 28, 41, 247, 255, 254, 147, 176, 1, 188, 48, 188, 2, 71, 8, 28, 32, 28, 41, 247, 255, 254, 161, 231, 246, - 28, 32, 28, 41, 240, 0, 250, 118, 231, 241, 70, 192, 19, 119, 238, 132, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, - 240, 176, 129, 28, 4, 70, 139, 72, 48, 33, 1, 70, 145, 247, 255, 253, 248, 70, 130, 40, 0, 219, 74, 120, 35, 43, 0, - 208, 80, 77, 43, 34, 0, 84, 171, 52, 1, 120, 35, 50, 1, 43, 0, 209, 249, 28, 87, 35, 10, 70, 72, 84, 171, 40, 0, 221, - 45, 35, 15, 38, 0, 70, 152, 224, 24, 28, 122, 28, 81, 28, 59, 28, 79, 32, 48, 84, 232, 70, 88, 93, 131, 70, 64, 64, - 3, 51, 48, 84, 171, 43, 57, 217, 1, 51, 7, 84, 171, 70, 67, 64, 51, 43, 15, 208, 16, 35, 32, 54, 1, 84, 107, 69, 177, - 221, 16, 47, 252, 221, 228, 28, 58, 28, 41, 70, 80, 247, 255, 253, 200, 39, 3, 35, 0, 34, 1, 33, 2, 231, 222, 35, 10, - 54, 1, 84, 107, 69, 177, 220, 238, 28, 32, 28, 57, 247, 255, 253, 166, 70, 80, 28, 41, 28, 58, 247, 255, 253, 181, 70, - 80, 247, 255, 253, 154, 176, 1, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 1, 71, 0, 34, 0, 39, 1, - 77, 2, 231, 179, 70, 192, 19, 119, 235, 232, 19, 119, 239, 32, 181, 240, 70, 71, 180, 128, 79, 33, 28, 4, 104, 59, 70, - 152, 43, 0, 209, 17, 35, 1, 96, 59, 33, 32, 247, 255, 253, 142, 104, 227, 43, 8, 208, 12, 28, 32, 240, 0, 250, 241, - 70, 67, 96, 59, 188, 4, 70, 144, 188, 240, 188, 2, 71, 8, 240, 0, 250, 232, 231, 247, 28, 33, 72, 20, 49, 12, 34, 4, - 247, 255, 255, 110, 34, 32, 28, 33, 72, 17, 247, 255, 255, 105, 105, 163, 104, 24, 104, 89, 247, 255, 253, 110, 105, - 163, 36, 197, 104, 27, 1, 164, 28, 32, 33, 8, 104, 93, 104, 30, 247, 255, 253, 100, 75, 9, 4, 45, 64, 30, 67, 53, 28, - 32, 96, 37, 33, 8, 247, 255, 253, 75, 70, 67, 96, 59, 32, 0, 231, 208, 70, 192, 19, 119, 238, 172, 19, 119, 235, 248, - 19, 119, 236, 4, 0, 0, 255, 255, 181, 16, 73, 21, 28, 4, 104, 139, 104, 202, 24, 154, 105, 11, 43, 0, 209, 18, 104, - 75, 43, 0, 209, 11, 33, 32, 247, 255, 253, 183, 40, 0, 219, 3, 105, 162, 75, 13, 66, 154, 208, 10, 188, 16, 188, 2, - 71, 8, 33, 32, 247, 255, 253, 193, 231, 242, 33, 32, 240, 0, 249, 151, 231, 238, 75, 7, 104, 27, 104, 26, 35, 1, 112, - 19, 120, 83, 43, 0, 209, 236, 247, 255, 253, 12, 231, 233, 70, 192, 19, 119, 238, 132, 93, 28, 158, 163, 19, 119, 224, - 8, 181, 240, 70, 87, 70, 70, 180, 192, 28, 4, 120, 0, 176, 129, 28, 14, 28, 23, 40, 224, 208, 24, 77, 133, 35, 0, 98, - 43, 28, 3, 59, 112, 43, 143, 217, 13, 28, 32, 28, 49, 28, 58, 240, 0, 250, 122, 28, 4, 176, 1, 28, 32, 188, 12, 70, - 144, 70, 154, 188, 240, 188, 2, 71, 8, 74, 123, 0, 155, 88, 211, 70, 159, 77, 120, 106, 43, 43, 0, 209, 2, 105, 43, - 43, 0, 208, 230, 28, 48, 33, 0, 28, 58, 240, 0, 248, 240, 106, 43, 224, 143, 104, 107, 43, 0, 209, 2, 105, 43, 43, 0, - 208, 217, 36, 0, 231, 221, 35, 1, 34, 37, 84, 171, 104, 43, 43, 0, 208, 0, 224, 173, 28, 32, 28, 58, 240, 0, 250, 76, - 28, 4, 34, 0, 35, 37, 84, 234, 44, 0, 209, 204, 224, 46, 104, 235, 104, 169, 70, 154, 105, 43, 70, 136, 43, 0, 209, - 0, 224, 176, 32, 0, 34, 0, 70, 67, 70, 81, 67, 11, 209, 2, 42, 0, 209, 0, 224, 176, 28, 3, 30, 90, 65, 147, 96, 107, - 28, 48, 28, 57, 247, 255, 255, 105, 28, 4, 231, 176, 105, 43, 43, 0, 208, 167, 35, 2, 224, 85, 104, 97, 104, 162, 40, - 208, 209, 0, 224, 144, 28, 48, 247, 255, 254, 122, 28, 4, 40, 0, 209, 160, 35, 37, 92, 235, 43, 0, 209, 156, 28, 48, - 28, 57, 247, 255, 253, 243, 231, 151, 35, 36, 92, 234, 42, 0, 209, 179, 105, 41, 84, 234, 35, 37, 96, 42, 96, 106, 96, - 170, 96, 234, 98, 42, 84, 234, 70, 136, 41, 0, 209, 0, 231, 128, 105, 108, 247, 255, 252, 148, 70, 64, 28, 41, 28, 34, - 56, 1, 49, 24, 240, 0, 249, 19, 28, 4, 231, 122, 104, 107, 43, 0, 208, 93, 75, 60, 36, 160, 98, 43, 2, 36, 231, 114, - 104, 107, 43, 0, 209, 3, 105, 43, 43, 0, 209, 0, 231, 101, 104, 99, 104, 162, 7, 155, 67, 19, 74, 53, 36, 0, 64, 19, - 96, 235, 231, 98, 104, 99, 72, 51, 64, 24, 247, 255, 252, 128, 28, 4, 231, 91, 104, 98, 35, 36, 84, 234, 36, 0, 231, - 86, 105, 43, 96, 51, 28, 48, 28, 57, 247, 255, 252, 69, 36, 0, 231, 78, 104, 99, 97, 43, 43, 0, 209, 40, 105, 99, 36, - 0, 97, 107, 231, 70, 104, 43, 231, 238, 104, 99, 36, 0, 96, 43, 231, 64, 104, 171, 231, 232, 104, 99, 36, 0, 96, 171, - 231, 58, 104, 107, 43, 0, 209, 3, 105, 43, 43, 0, 209, 0, 231, 45, 28, 48, 33, 0, 28, 58, 240, 0, 248, 55, 28, 48, 28, - 57, 247, 255, 252, 31, 36, 0, 231, 40, 104, 97, 104, 162, 28, 48, 247, 255, 253, 250, 28, 4, 231, 79, 28, 40, 28, 33, - 49, 8, 34, 6, 48, 24, 247, 255, 252, 19, 231, 206, 105, 43, 43, 0, 209, 158, 231, 15, 2, 201, 2, 82, 231, 107, 28, 58, - 28, 32, 28, 49, 240, 0, 249, 135, 28, 2, 30, 83, 65, 154, 231, 71, 105, 43, 43, 0, 208, 0, 231, 74, 96, 106, 36, 0, - 231, 2, 70, 192, 19, 119, 238, 132, 19, 119, 236, 12, 0, 5, 49, 0, 255, 255, 128, 0, 127, 255, 255, 255, 181, 240, 70, - 87, 70, 78, 70, 69, 180, 224, 70, 128, 28, 14, 70, 148, 42, 0, 208, 51, 33, 3, 28, 2, 64, 10, 35, 4, 26, 155, 28, 24, - 64, 8, 69, 96, 216, 49, 40, 0, 208, 49, 36, 0, 70, 67, 85, 30, 52, 1, 66, 160, 216, 250, 69, 132, 208, 32, 70, 99, 26, - 27, 8, 159, 70, 153, 0, 187, 70, 154, 43, 0, 208, 17, 4, 51, 6, 50, 2, 49, 67, 26, 67, 10, 28, 21, 70, 67, 67, 53, 24, - 26, 33, 0, 0, 139, 49, 1, 80, 213, 66, 185, 211, 250, 68, 84, 69, 209, 208, 6, 70, 67, 25, 24, 52, 1, 112, 6, 48, 1, - 69, 164, 216, 250, 188, 28, 70, 144, 70, 153, 70, 162, 188, 240, 188, 1, 71, 0, 70, 96, 231, 203, 36, 0, 231, 211, 70, - 192, 181, 48, 28, 5, 28, 12, 28, 16, 42, 0, 208, 12, 120, 42, 120, 11, 66, 154, 209, 12, 33, 0, 224, 3, 92, 106, 92, - 99, 66, 154, 209, 6, 49, 1, 66, 136, 216, 248, 32, 0, 188, 48, 188, 2, 71, 8, 32, 1, 66, 64, 231, 249, 181, 112, 76, - 17, 28, 6, 104, 32, 176, 130, 28, 13, 98, 2, 97, 6, 100, 1, 97, 65, 33, 68, 247, 255, 251, 123, 28, 48, 28, 41, 247, - 255, 251, 119, 75, 10, 34, 2, 104, 24, 104, 35, 73, 9, 147, 0, 35, 1, 247, 255, 251, 134, 28, 41, 28, 4, 28, 48, 247, - 255, 251, 121, 176, 2, 28, 32, 188, 112, 188, 2, 71, 8, 19, 119, 238, 176, 19, 119, 238, 180, 87, 70, 83, 2, 181, 240, - 176, 133, 28, 4, 28, 15, 146, 3, 40, 1, 217, 5, 32, 1, 66, 64, 176, 5, 188, 240, 188, 2, 71, 8, 77, 38, 104, 43, 43, - 0, 208, 65, 78, 37, 104, 48, 40, 0, 219, 1, 247, 255, 251, 67, 75, 35, 0, 162, 88, 208, 33, 1, 247, 255, 251, 77, 96, - 48, 40, 0, 219, 232, 104, 40, 28, 57, 34, 6, 48, 32, 247, 255, 251, 60, 104, 40, 169, 3, 34, 4, 48, 64, 247, 255, 251, - 54, 104, 42, 36, 4, 28, 19, 51, 32, 96, 19, 104, 42, 35, 6, 96, 83, 104, 42, 33, 68, 28, 19, 51, 64, 96, 147, 104, 43, - 96, 220, 104, 40, 247, 255, 251, 32, 104, 43, 104, 48, 34, 2, 147, 0, 73, 14, 35, 0, 247, 255, 251, 48, 104, 42, 28, - 19, 51, 32, 96, 19, 104, 43, 96, 92, 104, 42, 28, 19, 51, 64, 96, 147, 104, 43, 96, 220, 231, 181, 75, 7, 78, 3, 96, - 43, 35, 1, 66, 91, 96, 51, 231, 188, 19, 119, 238, 176, 19, 119, 238, 180, 19, 119, 238, 108, 87, 70, 83, 1, 19, 119, - 238, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 233, 45, 64, 128, 229, 159, 112, 248, 229, 151, 112, 0, 235, 0, 0, 45, - 232, 189, 64, 128, 225, 47, 255, 30, 233, 45, 64, 128, 229, 159, 112, 228, 229, 151, 112, 0, 235, 0, 0, 39, 232, 189, - 64, 128, 225, 47, 255, 30, 233, 45, 64, 128, 229, 159, 112, 208, 229, 151, 112, 0, 235, 0, 0, 33, 232, 189, 64, 128, - 225, 47, 255, 30, 233, 45, 64, 128, 229, 159, 112, 188, 229, 151, 112, 0, 235, 0, 0, 27, 232, 189, 64, 128, 225, 47, - 255, 30, 233, 45, 64, 128, 229, 159, 112, 168, 229, 151, 112, 0, 235, 0, 0, 21, 232, 189, 64, 128, 225, 47, 255, 30, - 233, 45, 64, 128, 229, 159, 112, 148, 229, 151, 112, 0, 235, 0, 0, 15, 232, 189, 64, 128, 225, 47, 255, 30, 230, 0, - 8, 16, 225, 47, 255, 30, 230, 0, 7, 240, 225, 47, 255, 30, 230, 0, 3, 144, 225, 47, 255, 30, 230, 0, 3, 176, 225, 47, - 255, 30, 230, 0, 3, 208, 225, 47, 255, 30, 230, 0, 3, 240, 225, 47, 255, 30, 230, 0, 4, 80, 225, 47, 255, 30, 225, 47, - 255, 23, 180, 124, 181, 0, 247, 255, 252, 254, 188, 2, 188, 124, 71, 8, 181, 112, 176, 136, 104, 133, 28, 1, 75, 14, - 71, 24, 70, 192, 70, 114, 28, 1, 32, 4, 223, 171, 71, 16, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 75, 8, - 104, 27, 71, 24, 19, 119, 224, 16, 19, 119, 224, 20, 19, 119, 224, 24, 19, 119, 224, 28, 19, 119, 224, 32, 19, 119, - 224, 36, 32, 16, 0, 213, 19, 119, 224, 12, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 0, 0, 1, 0, 44, 0, - 0, 0, 72, 0, 2, 20, 60, 96, 128, 0, 44, 0, 0, 0, 64, 130, 2, 20, 60, 96, 128, 0, 4, 56, 96, 0, 1, 72, 0, 2, 68, 56, - 97, 0, 24, 12, 56, 96, 0, 1, 72, 0, 2, 68, 56, 97, 0, 24, 0, 0, 47, 100, 101, 118, 47, 102, 97, 116, 47, 108, 111, 103, - 0, 0, 0, 0, 69, 83, 95, 105, 111, 99, 116, 108, 118, 0, 0, 0, 100, 117, 109, 112, 0, 0, 0, 0, 19, 119, 230, 232, 19, - 119, 230, 196, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, - 230, 116, 19, 119, 230, 116, 19, 119, 230, 186, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, - 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, - 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 231, 30, 19, 119, 230, 116, 19, - 119, 231, 80, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 231, 40, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, - 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, - 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, - 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, - 119, 230, 116, 19, 119, 231, 138, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 231, 40, 19, 119, - 230, 116, 19, 119, 230, 116, 19, 119, 230, 180, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, - 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, - 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, - 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, - 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, - 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, - 19, 119, 230, 116, 19, 119, 231, 40, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, - 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 231, 154, 19, 119, 230, 116, 19, 119, - 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 154, 19, 119, 230, - 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 232, 10, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, - 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, - 119, 230, 116, 19, 119, 230, 116, 19, 119, 232, 2, 19, 119, 231, 254, 19, 119, 231, 246, 19, 119, 231, 242, 19, 119, - 231, 226, 19, 119, 231, 210, 19, 119, 231, 200, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, - 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 231, 186, 47, 100, 101, 118, - 47, 117, 115, 98, 47, 101, 104, 99, 0, 0, 0, 0, 47, 100, 101, 118, 47, 115, 100, 105, 111, 47, 115, 100, 104, 99, 0, - 0, 19, 119, 238, 76, 19, 119, 238, 92 + 19, 119, 230, 81, 18, 52, 0, 1, 32, 34, 205, 172, 32, 32, 13, 57, 32, 32, 8, 197, 32, 32, 8, 153, 32, 32, 91, 129, 32, + 32, 0, 73, 32, 32, 40, 117, 32, 32, 54, 93, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 19, 119, 235, 77, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 71, 120, 234, 0, 2, 143, 70, 192, 71, + 120, 234, 0, 2, 159, 70, 192, 71, 120, 234, 0, 2, 175, 70, 192, 71, 120, 234, 0, 2, 167, 70, 192, 71, 120, 234, 0, 2, + 141, 70, 192, 71, 120, 234, 0, 2, 127, 70, 192, 71, 120, 234, 0, 2, 165, 70, 192, 71, 120, 234, 0, 2, 161, 70, 192, + 71, 120, 234, 0, 2, 167, 70, 192, 71, 120, 234, 0, 2, 167, 181, 0, 75, 7, 176, 137, 147, 0, 70, 104, 35, 0, 33, 0, 34, + 0, 147, 1, 147, 2, 240, 0, 253, 93, 176, 9, 188, 2, 71, 8, 70, 192, 227, 0, 0, 0, 181, 16, 28, 3, 34, 32, 28, 12, 72, + 13, 28, 25, 247, 255, 255, 206, 33, 32, 72, 11, 247, 255, 255, 198, 73, 10, 34, 1, 104, 11, 66, 19, 209, 253, 34, 32, + 28, 32, 73, 6, 247, 255, 255, 192, 28, 32, 33, 32, 247, 255, 255, 184, 75, 4, 104, 24, 188, 16, 188, 2, 71, 8, 70, 192, + 13, 0, 96, 0, 13, 0, 96, 28, 13, 0, 96, 32, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 10, 203, 70, 154, 75, + 20, 176, 137, 37, 0, 28, 7, 28, 14, 70, 145, 70, 108, 70, 155, 70, 168, 70, 91, 96, 35, 70, 67, 96, 99, 96, 163, 70, + 83, 96, 227, 28, 56, 70, 75, 28, 49, 97, 35, 247, 255, 255, 158, 70, 104, 28, 57, 28, 50, 240, 0, 253, 14, 53, 1, 40, + 0, 209, 8, 176, 9, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 45, 15, 217, 223, 231, 243, + 208, 0, 0, 0, 181, 112, 176, 136, 75, 8, 28, 6, 28, 13, 70, 108, 147, 0, 96, 97, 146, 2, 247, 255, 255, 125, 28, 49, + 28, 42, 70, 104, 240, 0, 252, 237, 176, 8, 188, 112, 188, 2, 71, 8, 168, 0, 0, 0, 181, 240, 70, 95, 70, 86, 70, 77, + 70, 68, 180, 240, 176, 143, 144, 4, 145, 3, 146, 2, 41, 0, 209, 0, 224, 126, 10, 82, 70, 145, 35, 128, 34, 0, 1, 27, + 70, 147, 34, 255, 147, 1, 3, 210, 171, 6, 146, 0, 70, 152, 224, 7, 154, 3, 68, 179, 69, 90, 217, 62, 154, 5, 24, 179, + 10, 219, 68, 153, 154, 3, 70, 91, 26, 214, 70, 74, 2, 83, 154, 2, 66, 154, 216, 87, 35, 0, 147, 5, 36, 0, 159, 4, 34, + 128, 68, 95, 28, 56, 28, 49, 1, 18, 240, 0, 248, 103, 44, 0, 209, 47, 40, 0, 208, 45, 155, 0, 28, 6, 66, 152, 217, 1, + 38, 255, 3, 246, 10, 242, 70, 146, 36, 0, 75, 43, 70, 66, 96, 19, 35, 0, 96, 83, 96, 147, 70, 83, 96, 211, 70, 75, 97, + 19, 28, 56, 28, 49, 247, 255, 255, 34, 70, 64, 28, 57, 28, 50, 240, 0, 252, 146, 52, 1, 28, 5, 40, 0, 208, 192, 44, + 15, 217, 230, 45, 0, 208, 188, 176, 15, 28, 40, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, + 154, 5, 25, 147, 154, 1, 66, 147, 217, 1, 155, 5, 26, 214, 32, 128, 1, 0, 33, 32, 247, 255, 254, 247, 28, 4, 40, 0, + 208, 18, 33, 128, 1, 9, 70, 74, 247, 255, 255, 59, 28, 5, 40, 0, 208, 15, 28, 32, 247, 255, 254, 213, 231, 216, 26, + 211, 0, 155, 28, 28, 147, 5, 30, 99, 65, 156, 231, 163, 37, 1, 66, 109, 231, 208, 37, 0, 231, 206, 154, 5, 28, 56, 24, + 161, 28, 50, 247, 255, 254, 210, 28, 56, 28, 49, 247, 255, 254, 202, 231, 228, 70, 192, 208, 0, 0, 0, 181, 48, 28, 13, + 28, 20, 6, 195, 209, 18, 75, 15, 66, 152, 217, 19, 33, 0, 75, 14, 24, 194, 75, 14, 66, 154, 216, 1, 75, 13, 26, 25, + 66, 161, 211, 5, 28, 8, 66, 169, 216, 10, 30, 99, 67, 152, 224, 0, 32, 0, 188, 48, 188, 2, 71, 8, 35, 192, 4, 91, 26, + 25, 231, 232, 28, 40, 30, 99, 67, 152, 231, 244, 1, 127, 255, 255, 240, 0, 0, 0, 3, 97, 127, 255, 19, 97, 128, 0, 181, + 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 70, 137, 176, 129, 73, 51, 34, 4, 28, 7, 240, 0, 250, 235, 40, 0, 209, + 3, 35, 128, 0, 91, 69, 153, 208, 13, 75, 47, 70, 154, 120, 27, 43, 0, 209, 81, 176, 1, 188, 60, 70, 144, 70, 153, 70, + 162, 70, 171, 188, 240, 188, 1, 71, 0, 74, 40, 35, 10, 70, 146, 112, 19, 38, 243, 75, 38, 74, 39, 37, 0, 70, 152, 70, + 147, 224, 2, 53, 1, 66, 181, 210, 19, 25, 124, 28, 32, 70, 65, 34, 13, 240, 0, 250, 195, 40, 0, 209, 244, 70, 89, 34, + 13, 28, 32, 247, 255, 254, 98, 53, 1, 28, 32, 33, 13, 247, 255, 254, 89, 66, 181, 211, 235, 34, 12, 66, 82, 68, 74, + 70, 144, 42, 0, 208, 27, 75, 23, 37, 0, 78, 23, 70, 153, 224, 2, 53, 1, 69, 69, 210, 19, 25, 124, 28, 32, 28, 49, 34, + 12, 240, 0, 250, 161, 40, 0, 209, 244, 70, 73, 34, 12, 28, 32, 247, 255, 254, 64, 53, 1, 28, 32, 33, 12, 247, 255, 254, + 55, 69, 69, 211, 235, 70, 82, 120, 19, 59, 1, 112, 19, 231, 173, 70, 78, 62, 13, 46, 0, 209, 183, 231, 211, 70, 192, + 19, 119, 235, 176, 19, 119, 238, 128, 19, 119, 235, 217, 19, 119, 235, 204, 19, 119, 235, 180, 19, 119, 235, 192, 181, + 48, 28, 4, 72, 15, 28, 13, 104, 131, 104, 193, 176, 129, 24, 91, 24, 154, 105, 3, 43, 0, 209, 15, 104, 67, 43, 0, 209, + 7, 28, 32, 28, 41, 247, 255, 254, 147, 176, 1, 188, 48, 188, 2, 71, 8, 28, 32, 28, 41, 247, 255, 254, 161, 231, 246, + 28, 32, 28, 41, 240, 0, 250, 118, 231, 241, 70, 192, 19, 119, 238, 132, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, + 240, 176, 129, 28, 4, 70, 139, 72, 48, 33, 1, 70, 145, 247, 255, 253, 248, 70, 130, 40, 0, 219, 74, 120, 35, 43, 0, + 208, 80, 77, 43, 34, 0, 84, 171, 52, 1, 120, 35, 50, 1, 43, 0, 209, 249, 28, 87, 35, 10, 70, 72, 84, 171, 40, 0, 221, + 45, 35, 15, 38, 0, 70, 152, 224, 24, 28, 122, 28, 81, 28, 59, 28, 79, 32, 48, 84, 232, 70, 88, 93, 131, 70, 64, 64, + 3, 51, 48, 84, 171, 43, 57, 217, 1, 51, 7, 84, 171, 70, 67, 64, 51, 43, 15, 208, 16, 35, 32, 54, 1, 84, 107, 69, 177, + 221, 16, 47, 252, 221, 228, 28, 58, 28, 41, 70, 80, 247, 255, 253, 200, 39, 3, 35, 0, 34, 1, 33, 2, 231, 222, 35, 10, + 54, 1, 84, 107, 69, 177, 220, 238, 28, 32, 28, 57, 247, 255, 253, 166, 70, 80, 28, 41, 28, 58, 247, 255, 253, 181, 70, + 80, 247, 255, 253, 154, 176, 1, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 1, 71, 0, 34, 0, 39, 1, + 77, 2, 231, 179, 70, 192, 19, 119, 235, 232, 19, 119, 239, 32, 181, 240, 70, 71, 180, 128, 79, 33, 28, 4, 104, 59, 70, + 152, 43, 0, 209, 17, 35, 1, 96, 59, 33, 32, 247, 255, 253, 142, 104, 227, 43, 8, 208, 12, 28, 32, 240, 0, 250, 241, + 70, 67, 96, 59, 188, 4, 70, 144, 188, 240, 188, 2, 71, 8, 240, 0, 250, 232, 231, 247, 28, 33, 72, 20, 49, 12, 34, 4, + 247, 255, 255, 110, 34, 32, 28, 33, 72, 17, 247, 255, 255, 105, 105, 163, 104, 24, 104, 89, 247, 255, 253, 110, 105, + 163, 36, 197, 104, 27, 1, 164, 28, 32, 33, 8, 104, 93, 104, 30, 247, 255, 253, 100, 75, 9, 4, 45, 64, 30, 67, 53, 28, + 32, 96, 37, 33, 8, 247, 255, 253, 75, 70, 67, 96, 59, 32, 0, 231, 208, 70, 192, 19, 119, 238, 172, 19, 119, 235, 248, + 19, 119, 236, 4, 0, 0, 255, 255, 181, 16, 73, 21, 28, 4, 104, 139, 104, 202, 24, 154, 105, 11, 43, 0, 209, 18, 104, + 75, 43, 0, 209, 11, 33, 32, 247, 255, 253, 183, 40, 0, 219, 3, 105, 162, 75, 13, 66, 154, 208, 10, 188, 16, 188, 2, + 71, 8, 33, 32, 247, 255, 253, 193, 231, 242, 33, 32, 240, 0, 249, 151, 231, 238, 75, 7, 104, 27, 104, 26, 35, 1, 112, + 19, 120, 83, 43, 0, 209, 236, 247, 255, 253, 12, 231, 233, 70, 192, 19, 119, 238, 132, 93, 28, 158, 163, 19, 119, 224, + 8, 181, 240, 70, 87, 70, 70, 180, 192, 28, 4, 120, 0, 176, 129, 28, 14, 28, 23, 40, 224, 208, 24, 77, 133, 35, 0, 98, + 43, 28, 3, 59, 112, 43, 143, 217, 13, 28, 32, 28, 49, 28, 58, 240, 0, 250, 122, 28, 4, 176, 1, 28, 32, 188, 12, 70, + 144, 70, 154, 188, 240, 188, 2, 71, 8, 74, 123, 0, 155, 88, 211, 70, 159, 77, 120, 106, 43, 43, 0, 209, 2, 105, 43, + 43, 0, 208, 230, 28, 48, 33, 0, 28, 58, 240, 0, 248, 240, 106, 43, 224, 143, 104, 107, 43, 0, 209, 2, 105, 43, 43, 0, + 208, 217, 36, 0, 231, 221, 35, 1, 34, 37, 84, 171, 104, 43, 43, 0, 208, 0, 224, 173, 28, 32, 28, 58, 240, 0, 250, 76, + 28, 4, 34, 0, 35, 37, 84, 234, 44, 0, 209, 204, 224, 46, 104, 235, 104, 169, 70, 154, 105, 43, 70, 136, 43, 0, 209, + 0, 224, 176, 32, 0, 34, 0, 70, 67, 70, 81, 67, 11, 209, 2, 42, 0, 209, 0, 224, 176, 28, 3, 30, 90, 65, 147, 96, 107, + 28, 48, 28, 57, 247, 255, 255, 105, 28, 4, 231, 176, 105, 43, 43, 0, 208, 167, 35, 2, 224, 85, 104, 97, 104, 162, 40, + 208, 209, 0, 224, 144, 28, 48, 247, 255, 254, 122, 28, 4, 40, 0, 209, 160, 35, 37, 92, 235, 43, 0, 209, 156, 28, 48, + 28, 57, 247, 255, 253, 243, 231, 151, 35, 36, 92, 234, 42, 0, 209, 179, 105, 41, 84, 234, 35, 37, 96, 42, 96, 106, 96, + 170, 96, 234, 98, 42, 84, 234, 70, 136, 41, 0, 209, 0, 231, 128, 105, 108, 247, 255, 252, 148, 70, 64, 28, 41, 28, 34, + 56, 1, 49, 24, 240, 0, 249, 19, 28, 4, 231, 122, 104, 107, 43, 0, 208, 93, 75, 60, 36, 160, 98, 43, 2, 36, 231, 114, + 104, 107, 43, 0, 209, 3, 105, 43, 43, 0, 209, 0, 231, 101, 104, 99, 104, 162, 7, 155, 67, 19, 74, 53, 36, 0, 64, 19, + 96, 235, 231, 98, 104, 99, 72, 51, 64, 24, 247, 255, 252, 128, 28, 4, 231, 91, 104, 98, 35, 36, 84, 234, 36, 0, 231, + 86, 105, 43, 96, 51, 28, 48, 28, 57, 247, 255, 252, 69, 36, 0, 231, 78, 104, 99, 97, 43, 43, 0, 209, 40, 105, 99, 36, + 0, 97, 107, 231, 70, 104, 43, 231, 238, 104, 99, 36, 0, 96, 43, 231, 64, 104, 171, 231, 232, 104, 99, 36, 0, 96, 171, + 231, 58, 104, 107, 43, 0, 209, 3, 105, 43, 43, 0, 209, 0, 231, 45, 28, 48, 33, 0, 28, 58, 240, 0, 248, 55, 28, 48, 28, + 57, 247, 255, 252, 31, 36, 0, 231, 40, 104, 97, 104, 162, 28, 48, 247, 255, 253, 250, 28, 4, 231, 79, 28, 40, 28, 33, + 49, 8, 34, 6, 48, 24, 247, 255, 252, 19, 231, 206, 105, 43, 43, 0, 209, 158, 231, 15, 2, 201, 2, 82, 231, 107, 28, 58, + 28, 32, 28, 49, 240, 0, 249, 135, 28, 2, 30, 83, 65, 154, 231, 71, 105, 43, 43, 0, 208, 0, 231, 74, 96, 106, 36, 0, + 231, 2, 70, 192, 19, 119, 238, 132, 19, 119, 236, 12, 0, 5, 49, 0, 255, 255, 128, 0, 127, 255, 255, 255, 181, 240, 70, + 87, 70, 78, 70, 69, 180, 224, 70, 128, 28, 14, 70, 148, 42, 0, 208, 51, 33, 3, 28, 2, 64, 10, 35, 4, 26, 155, 28, 24, + 64, 8, 69, 96, 216, 49, 40, 0, 208, 49, 36, 0, 70, 67, 85, 30, 52, 1, 66, 160, 216, 250, 69, 132, 208, 32, 70, 99, 26, + 27, 8, 159, 70, 153, 0, 187, 70, 154, 43, 0, 208, 17, 4, 51, 6, 50, 2, 49, 67, 26, 67, 10, 28, 21, 70, 67, 67, 53, 24, + 26, 33, 0, 0, 139, 49, 1, 80, 213, 66, 185, 211, 250, 68, 84, 69, 209, 208, 6, 70, 67, 25, 24, 52, 1, 112, 6, 48, 1, + 69, 164, 216, 250, 188, 28, 70, 144, 70, 153, 70, 162, 188, 240, 188, 1, 71, 0, 70, 96, 231, 203, 36, 0, 231, 211, 70, + 192, 181, 48, 28, 5, 28, 12, 28, 16, 42, 0, 208, 12, 120, 42, 120, 11, 66, 154, 209, 12, 33, 0, 224, 3, 92, 106, 92, + 99, 66, 154, 209, 6, 49, 1, 66, 136, 216, 248, 32, 0, 188, 48, 188, 2, 71, 8, 32, 1, 66, 64, 231, 249, 181, 112, 76, + 17, 28, 6, 104, 32, 176, 130, 28, 13, 98, 2, 97, 6, 100, 1, 97, 65, 33, 68, 247, 255, 251, 123, 28, 48, 28, 41, 247, + 255, 251, 119, 75, 10, 34, 2, 104, 24, 104, 35, 73, 9, 147, 0, 35, 1, 247, 255, 251, 134, 28, 41, 28, 4, 28, 48, 247, + 255, 251, 121, 176, 2, 28, 32, 188, 112, 188, 2, 71, 8, 19, 119, 238, 176, 19, 119, 238, 180, 87, 70, 83, 2, 181, 240, + 176, 133, 28, 4, 28, 15, 146, 3, 40, 1, 217, 5, 32, 1, 66, 64, 176, 5, 188, 240, 188, 2, 71, 8, 77, 38, 104, 43, 43, + 0, 208, 65, 78, 37, 104, 48, 40, 0, 219, 1, 247, 255, 251, 67, 75, 35, 0, 162, 88, 208, 33, 1, 247, 255, 251, 77, 96, + 48, 40, 0, 219, 232, 104, 40, 28, 57, 34, 6, 48, 32, 247, 255, 251, 60, 104, 40, 169, 3, 34, 4, 48, 64, 247, 255, 251, + 54, 104, 42, 36, 4, 28, 19, 51, 32, 96, 19, 104, 42, 35, 6, 96, 83, 104, 42, 33, 68, 28, 19, 51, 64, 96, 147, 104, 43, + 96, 220, 104, 40, 247, 255, 251, 32, 104, 43, 104, 48, 34, 2, 147, 0, 73, 14, 35, 0, 247, 255, 251, 48, 104, 42, 28, + 19, 51, 32, 96, 19, 104, 43, 96, 92, 104, 42, 28, 19, 51, 64, 96, 147, 104, 43, 96, 220, 231, 181, 75, 7, 78, 3, 96, + 43, 35, 1, 66, 91, 96, 51, 231, 188, 19, 119, 238, 176, 19, 119, 238, 180, 19, 119, 238, 108, 87, 70, 83, 1, 19, 119, + 238, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 233, 45, 64, 128, 229, 159, 112, 248, 229, 151, 112, 0, 235, 0, 0, 45, + 232, 189, 64, 128, 225, 47, 255, 30, 233, 45, 64, 128, 229, 159, 112, 228, 229, 151, 112, 0, 235, 0, 0, 39, 232, 189, + 64, 128, 225, 47, 255, 30, 233, 45, 64, 128, 229, 159, 112, 208, 229, 151, 112, 0, 235, 0, 0, 33, 232, 189, 64, 128, + 225, 47, 255, 30, 233, 45, 64, 128, 229, 159, 112, 188, 229, 151, 112, 0, 235, 0, 0, 27, 232, 189, 64, 128, 225, 47, + 255, 30, 233, 45, 64, 128, 229, 159, 112, 168, 229, 151, 112, 0, 235, 0, 0, 21, 232, 189, 64, 128, 225, 47, 255, 30, + 233, 45, 64, 128, 229, 159, 112, 148, 229, 151, 112, 0, 235, 0, 0, 15, 232, 189, 64, 128, 225, 47, 255, 30, 230, 0, + 8, 16, 225, 47, 255, 30, 230, 0, 7, 240, 225, 47, 255, 30, 230, 0, 3, 144, 225, 47, 255, 30, 230, 0, 3, 176, 225, 47, + 255, 30, 230, 0, 3, 208, 225, 47, 255, 30, 230, 0, 3, 240, 225, 47, 255, 30, 230, 0, 4, 80, 225, 47, 255, 30, 225, 47, + 255, 23, 180, 124, 181, 0, 247, 255, 252, 254, 188, 2, 188, 124, 71, 8, 181, 112, 176, 136, 104, 133, 28, 1, 75, 14, + 71, 24, 70, 192, 70, 114, 28, 1, 32, 4, 223, 171, 71, 16, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 75, 8, + 104, 27, 71, 24, 19, 119, 224, 16, 19, 119, 224, 20, 19, 119, 224, 24, 19, 119, 224, 28, 19, 119, 224, 32, 19, 119, + 224, 36, 32, 16, 0, 213, 19, 119, 224, 12, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 0, 0, 1, 0, 44, 0, + 0, 0, 72, 0, 2, 20, 60, 96, 128, 0, 44, 0, 0, 0, 64, 130, 2, 20, 60, 96, 128, 0, 4, 56, 96, 0, 1, 72, 0, 2, 68, 56, + 97, 0, 24, 12, 56, 96, 0, 1, 72, 0, 2, 68, 56, 97, 0, 24, 0, 0, 47, 100, 101, 118, 47, 102, 97, 116, 47, 108, 111, 103, + 0, 0, 0, 0, 69, 83, 95, 105, 111, 99, 116, 108, 118, 0, 0, 0, 100, 117, 109, 112, 0, 0, 0, 0, 19, 119, 230, 232, 19, + 119, 230, 196, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, + 230, 116, 19, 119, 230, 116, 19, 119, 230, 186, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, + 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, + 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 231, 30, 19, 119, 230, 116, 19, + 119, 231, 80, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 231, 40, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, + 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, + 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, + 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, + 119, 230, 116, 19, 119, 231, 138, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 231, 40, 19, 119, + 230, 116, 19, 119, 230, 116, 19, 119, 230, 180, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, + 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, + 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, + 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, + 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, + 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, + 19, 119, 230, 116, 19, 119, 231, 40, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, + 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 231, 154, 19, 119, 230, 116, 19, 119, + 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 154, 19, 119, 230, + 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 232, 10, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, + 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, + 119, 230, 116, 19, 119, 230, 116, 19, 119, 232, 2, 19, 119, 231, 254, 19, 119, 231, 246, 19, 119, 231, 242, 19, 119, + 231, 226, 19, 119, 231, 210, 19, 119, 231, 200, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, + 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 230, 116, 19, 119, 231, 186, 47, 100, 101, 118, + 47, 117, 115, 98, 47, 101, 104, 99, 0, 0, 0, 0, 47, 100, 101, 118, 47, 115, 100, 105, 111, 47, 115, 100, 104, 99, 0, + 0, 19, 119, 238, 76, 19, 119, 238, 92 }; diff --git a/source/mload/ehcmodule.c b/source/mload/ehcmodule.c index a5a8dfe1..14671bd5 100644 --- a/source/mload/ehcmodule.c +++ b/source/mload/ehcmodule.c @@ -1,661 +1,661 @@ #define size_ehcmodule 18412 unsigned char ehcmodule[18412] __attribute__((aligned (32)))={ - 127, 69, 76, 70, 1, 2, 1, 97, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 40, 0, 0, 0, 1, 19, 112, 0, 0, 0, 0, 0, 52, 0, 0, 0, - 0, 0, 0, 6, 6, 0, 52, 0, 32, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, - 0, 0, 0, 160, 0, 240, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 212, 0, 0, 0, 160, 0, 0, 0, 160, 0, 0, 0, 52, 0, 0, 0, - 52, 0, 240, 0, 0, 0, 0, 0, 4, 0, 0, 0, 1, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 212, 0, 0, 0, 212, 0, 240, 0, - 0, 0, 0, 64, 0, 0, 0, 0, 1, 0, 0, 1, 8, 19, 112, 0, 0, 19, 112, 0, 0, 0, 0, 69, 156, 0, 0, 69, 156, 0, 0, 0, 5, 0, 0, - 0, 4, 0, 0, 0, 1, 0, 0, 70, 164, 19, 112, 128, 0, 19, 112, 128, 0, 0, 0, 1, 72, 0, 2, 11, 56, 0, 0, 0, 6, 0, 0, 0, 4, - 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 6, 0, 0, 0, 11, 0, 0, 0, 4, 0, 0, 0, 9, 19, 112, 0, 0, 0, 0, 0, 125, 0, 0, 0, 72, - 0, 0, 0, 126, 0, 0, 64, 0, 0, 0, 0, 127, 19, 114, 139, 56, 227, 160, 0, 0, 227, 160, 16, 0, 229, 159, 48, 0, 225, 47, - 255, 19, 19, 112, 8, 13, 225, 160, 0, 0, 225, 160, 0, 0, 225, 160, 0, 0, 70, 192, 71, 120, 234, 0, 16, 74, 70, 192, - 71, 120, 234, 0, 16, 118, 70, 192, 71, 120, 234, 0, 16, 94, 70, 192, 71, 120, 234, 0, 16, 78, 70, 192, 71, 120, 234, - 0, 16, 106, 70, 192, 71, 120, 234, 0, 16, 58, 70, 192, 71, 120, 234, 0, 16, 38, 70, 192, 71, 120, 234, 0, 16, 78, 70, - 192, 71, 120, 234, 0, 16, 62, 70, 192, 71, 120, 234, 0, 16, 100, 70, 192, 71, 120, 234, 0, 16, 62, 70, 192, 71, 120, - 234, 0, 16, 66, 70, 192, 71, 120, 234, 0, 16, 62, 70, 192, 71, 120, 234, 0, 16, 28, 70, 192, 71, 120, 234, 0, 16, 38, - 70, 192, 71, 120, 234, 0, 16, 34, 70, 192, 71, 120, 234, 0, 16, 26, 181, 240, 28, 15, 120, 1, 28, 6, 28, 10, 58, 48, - 6, 19, 14, 27, 36, 0, 28, 69, 43, 9, 216, 11, 1, 35, 28, 28, 67, 20, 28, 40, 120, 1, 28, 69, 28, 10, 58, 48, 6, 19, - 14, 27, 43, 9, 217, 243, 28, 11, 59, 97, 6, 27, 14, 27, 43, 5, 216, 6, 1, 34, 28, 11, 59, 87, 28, 20, 67, 28, 28, 40, - 231, 234, 28, 11, 59, 65, 6, 27, 14, 27, 43, 5, 217, 6, 28, 115, 66, 157, 208, 10, 96, 60, 188, 240, 188, 2, 71, 8, - 1, 34, 28, 11, 59, 55, 28, 20, 67, 28, 28, 40, 231, 214, 32, 0, 231, 243, 70, 192, 181, 240, 70, 71, 180, 128, 28, 13, - 28, 6, 240, 4, 250, 7, 70, 128, 70, 65, 28, 48, 247, 255, 255, 120, 45, 0, 208, 33, 28, 40, 240, 4, 249, 253, 28, 7, - 28, 57, 28, 40, 247, 255, 255, 110, 72, 13, 33, 1, 247, 255, 255, 150, 28, 4, 40, 0, 219, 13, 28, 49, 70, 66, 247, 255, - 255, 123, 45, 0, 208, 4, 28, 32, 28, 41, 28, 58, 247, 255, 255, 116, 28, 32, 247, 255, 255, 129, 188, 4, 70, 144, 188, - 240, 188, 1, 71, 0, 39, 0, 231, 227, 19, 112, 128, 36, 181, 0, 75, 4, 176, 129, 28, 1, 104, 24, 247, 255, 255, 109, - 176, 1, 188, 1, 71, 0, 19, 112, 128, 24, 181, 0, 75, 9, 28, 1, 176, 129, 104, 24, 247, 255, 255, 89, 40, 0, 208, 2, - 176, 1, 188, 2, 71, 8, 72, 4, 33, 0, 247, 255, 255, 176, 32, 100, 240, 0, 251, 131, 231, 251, 19, 112, 128, 24, 19, - 112, 128, 52, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 149, 72, 198, 33, 0, 247, 255, 255, 157, 75, - 197, 33, 64, 104, 24, 247, 255, 255, 56, 33, 16, 247, 255, 255, 45, 70, 129, 72, 193, 70, 73, 144, 6, 247, 255, 255, - 27, 72, 192, 70, 74, 75, 192, 28, 1, 247, 255, 255, 69, 75, 191, 76, 191, 70, 130, 72, 191, 34, 0, 146, 13, 146, 14, - 146, 15, 146, 16, 146, 17, 147, 5, 148, 4, 144, 11, 74, 187, 75, 188, 76, 188, 72, 189, 146, 10, 147, 9, 148, 8, 144, - 7, 34, 0, 169, 19, 70, 72, 247, 255, 255, 47, 70, 80, 247, 255, 255, 0, 156, 19, 74, 183, 66, 148, 208, 243, 75, 173, - 66, 156, 209, 0, 224, 230, 120, 35, 120, 98, 6, 27, 4, 18, 67, 26, 120, 163, 2, 27, 67, 19, 120, 226, 67, 26, 42, 2, - 209, 0, 224, 198, 42, 2, 216, 17, 42, 1, 209, 0, 224, 154, 39, 1, 66, 127, 38, 1, 154, 5, 104, 19, 43, 0, 208, 0, 224, - 141, 46, 0, 208, 211, 152, 19, 28, 57, 247, 255, 254, 212, 231, 206, 42, 6, 209, 0, 224, 172, 42, 7, 209, 235, 126, - 35, 126, 98, 6, 27, 4, 18, 67, 26, 126, 163, 2, 27, 67, 19, 126, 226, 67, 26, 70, 147, 124, 35, 124, 98, 6, 27, 4, 18, - 67, 26, 124, 163, 2, 27, 67, 19, 124, 226, 67, 26, 146, 12, 125, 35, 125, 98, 6, 27, 4, 18, 67, 26, 125, 163, 2, 27, - 67, 19, 125, 226, 28, 21, 67, 29, 123, 35, 43, 0, 208, 0, 224, 196, 154, 15, 42, 0, 208, 0, 224, 192, 122, 35, 122, - 98, 6, 27, 4, 18, 67, 26, 122, 163, 122, 224, 2, 27, 67, 19, 67, 24, 240, 0, 251, 73, 28, 6, 155, 12, 70, 88, 25, 91, - 70, 152, 0, 217, 70, 68, 247, 255, 254, 164, 44, 0, 221, 9, 70, 92, 37, 0, 104, 32, 104, 97, 53, 1, 247, 255, 254, 155, - 52, 8, 69, 168, 220, 247, 153, 19, 72, 124, 123, 11, 123, 74, 6, 27, 4, 18, 67, 26, 123, 139, 2, 27, 67, 19, 123, 202, - 67, 26, 66, 130, 209, 0, 225, 172, 66, 130, 217, 0, 224, 157, 42, 6, 217, 0, 224, 187, 42, 5, 211, 0, 225, 41, 42, 1, - 209, 0, 225, 207, 42, 0, 209, 0, 225, 117, 42, 2, 209, 0, 225, 32, 39, 1, 38, 1, 154, 12, 69, 66, 219, 0, 231, 125, - 0, 211, 70, 88, 24, 196, 28, 21, 104, 32, 104, 97, 53, 1, 247, 255, 254, 72, 52, 8, 69, 168, 220, 247, 154, 5, 104, - 19, 43, 0, 209, 0, 231, 113, 70, 80, 73, 86, 247, 255, 254, 112, 231, 108, 123, 35, 123, 98, 6, 27, 4, 18, 67, 26, 123, - 163, 153, 6, 2, 27, 67, 19, 123, 226, 28, 21, 67, 29, 28, 40, 240, 4, 248, 136, 40, 0, 209, 90, 125, 35, 125, 98, 6, - 27, 4, 18, 67, 26, 125, 163, 2, 27, 67, 19, 125, 226, 156, 16, 28, 23, 67, 31, 44, 0, 209, 0, 224, 217, 32, 1, 144, - 16, 38, 1, 231, 67, 39, 1, 38, 1, 231, 64, 122, 35, 122, 98, 6, 27, 4, 18, 67, 26, 122, 163, 2, 27, 67, 19, 122, 226, - 156, 15, 28, 16, 67, 24, 66, 132, 209, 47, 32, 0, 144, 15, 39, 0, 38, 1, 231, 45, 156, 14, 44, 0, 209, 0, 231, 4, 152, - 5, 104, 3, 43, 0, 209, 0, 230, 255, 168, 18, 240, 0, 251, 37, 154, 18, 75, 59, 28, 4, 66, 154, 221, 0, 230, 246, 154, - 4, 33, 1, 152, 13, 240, 2, 254, 14, 73, 43, 70, 80, 247, 255, 254, 26, 32, 128, 4, 64, 153, 18, 240, 3, 255, 33, 154, - 13, 24, 18, 146, 13, 66, 148, 219, 0, 230, 226, 35, 0, 147, 13, 230, 223, 38, 0, 231, 73, 240, 0, 250, 144, 240, 0, - 250, 134, 39, 0, 38, 1, 230, 251, 155, 15, 43, 0, 208, 83, 39, 6, 66, 127, 38, 1, 230, 244, 75, 38, 66, 154, 209, 0, - 224, 136, 66, 154, 217, 0, 224, 141, 59, 3, 66, 154, 209, 0, 224, 198, 66, 154, 210, 0, 225, 37, 51, 1, 66, 154, 209, - 0, 225, 21, 51, 1, 66, 154, 208, 0, 231, 90, 70, 92, 104, 35, 105, 34, 104, 24, 104, 163, 38, 1, 104, 25, 240, 1, 253, - 159, 28, 7, 231, 81, 42, 12, 209, 0, 224, 184, 42, 12, 210, 0, 231, 73, 28, 19, 59, 26, 43, 1, 217, 0, 231, 68, 39, - 1, 38, 0, 231, 67, 70, 192, 19, 112, 128, 76, 19, 112, 128, 24, 19, 112, 128, 92, 0, 152, 150, 128, 0, 0, 6, 102, 19, - 112, 128, 12, 19, 112, 129, 128, 19, 112, 128, 108, 19, 112, 128, 124, 19, 112, 129, 72, 19, 112, 128, 136, 19, 112, - 128, 148, 0, 0, 5, 85, 85, 77, 83, 1, 0, 0, 7, 255, 85, 77, 83, 6, 28, 40, 153, 11, 34, 13, 240, 3, 255, 7, 40, 0, 209, - 164, 125, 35, 125, 98, 6, 27, 4, 18, 67, 26, 28, 47, 125, 163, 55, 13, 28, 57, 2, 27, 67, 19, 125, 226, 120, 12, 28, - 22, 28, 34, 58, 48, 67, 30, 6, 19, 14, 27, 37, 0, 28, 72, 43, 9, 216, 11, 1, 43, 28, 29, 67, 21, 28, 1, 120, 12, 28, - 72, 28, 34, 58, 48, 6, 19, 14, 27, 43, 9, 217, 243, 28, 35, 59, 97, 6, 27, 14, 27, 43, 5, 216, 40, 1, 42, 28, 35, 59, - 87, 28, 21, 67, 29, 28, 1, 231, 234, 240, 1, 249, 209, 34, 1, 146, 16, 38, 1, 230, 103, 152, 9, 104, 3, 66, 90, 65, - 83, 96, 3, 39, 0, 38, 1, 230, 221, 76, 143, 66, 162, 208, 51, 66, 162, 217, 0, 224, 180, 75, 141, 66, 154, 208, 0, 230, - 209, 156, 5, 35, 0, 96, 35, 240, 0, 251, 92, 32, 0, 144, 14, 39, 0, 38, 1, 230, 201, 28, 35, 59, 65, 6, 27, 14, 27, - 43, 5, 216, 0, 224, 152, 28, 123, 66, 152, 209, 0, 231, 71, 41, 0, 209, 0, 231, 68, 44, 47, 208, 0, 231, 65, 169, 18, - 247, 255, 253, 75, 40, 0, 209, 0, 231, 59, 120, 3, 43, 0, 208, 0, 231, 55, 28, 50, 153, 18, 28, 40, 240, 0, 249, 127, - 38, 1, 28, 7, 230, 40, 70, 90, 104, 19, 156, 5, 104, 27, 96, 35, 230, 158, 70, 92, 104, 35, 105, 34, 104, 24, 104, 163, - 38, 1, 104, 25, 240, 2, 253, 17, 28, 7, 230, 149, 46, 0, 209, 0, 224, 198, 39, 6, 66, 127, 38, 1, 230, 142, 46, 0, 208, - 249, 70, 88, 105, 3, 70, 90, 136, 24, 105, 147, 136, 28, 106, 19, 136, 29, 104, 19, 120, 25, 104, 147, 120, 26, 2, 3, - 10, 0, 67, 3, 2, 32, 10, 36, 67, 32, 4, 0, 12, 0, 144, 0, 2, 40, 10, 45, 67, 40, 4, 0, 12, 0, 144, 1, 70, 92, 107, 32, - 4, 27, 144, 2, 12, 27, 28, 48, 240, 0, 255, 99, 38, 1, 28, 7, 230, 102, 240, 2, 251, 6, 28, 7, 40, 0, 219, 116, 154, - 5, 153, 19, 32, 1, 96, 16, 122, 11, 122, 74, 6, 27, 4, 18, 67, 26, 122, 139, 152, 10, 2, 27, 67, 19, 122, 202, 67, 26, - 146, 15, 33, 0, 247, 255, 253, 32, 35, 1, 147, 14, 38, 1, 230, 74, 70, 88, 104, 3, 70, 90, 104, 24, 104, 147, 105, 18, - 104, 25, 240, 2, 251, 133, 38, 1, 28, 7, 230, 62, 70, 90, 104, 16, 240, 0, 249, 192, 38, 1, 28, 7, 230, 55, 46, 0, 208, - 162, 70, 88, 104, 3, 120, 25, 104, 131, 136, 26, 105, 3, 28, 48, 240, 0, 255, 18, 38, 1, 28, 7, 230, 41, 1, 42, 28, - 35, 59, 55, 28, 21, 67, 29, 28, 1, 231, 33, 75, 51, 66, 154, 208, 21, 51, 1, 66, 154, 208, 0, 230, 25, 156, 17, 44, - 0, 208, 63, 70, 80, 247, 255, 252, 123, 70, 88, 104, 3, 105, 2, 104, 25, 104, 131, 152, 17, 104, 27, 240, 2, 254, 112, - 39, 0, 38, 1, 230, 9, 122, 11, 122, 74, 6, 27, 4, 18, 67, 26, 122, 139, 70, 88, 2, 27, 67, 19, 122, 202, 28, 20, 67, - 28, 35, 0, 147, 18, 104, 195, 43, 4, 208, 38, 70, 90, 104, 16, 153, 18, 240, 2, 254, 17, 144, 17, 40, 0, 208, 27, 39, - 0, 148, 15, 152, 8, 231, 154, 153, 19, 152, 7, 122, 11, 122, 74, 6, 27, 4, 18, 67, 26, 122, 139, 38, 1, 2, 27, 67, 19, - 122, 202, 33, 0, 67, 26, 146, 15, 247, 255, 252, 173, 35, 0, 147, 14, 229, 216, 39, 1, 66, 127, 38, 1, 229, 212, 39, - 1, 66, 127, 231, 225, 104, 129, 34, 4, 168, 18, 240, 3, 253, 226, 231, 210, 70, 90, 104, 19, 70, 92, 120, 24, 104, 147, - 105, 18, 120, 25, 105, 163, 240, 0, 248, 247, 38, 1, 28, 7, 229, 190, 85, 77, 83, 128, 85, 77, 83, 16, 87, 70, 83, 1, - 181, 0, 33, 128, 176, 129, 2, 73, 72, 18, 247, 255, 252, 3, 75, 18, 33, 64, 96, 24, 247, 255, 252, 30, 33, 16, 247, - 255, 252, 19, 75, 15, 33, 250, 28, 2, 96, 24, 0, 137, 75, 13, 72, 14, 247, 255, 252, 46, 75, 13, 96, 24, 247, 255, 252, - 2, 240, 0, 249, 64, 40, 0, 219, 5, 247, 255, 252, 192, 32, 0, 176, 1, 188, 2, 71, 8, 32, 1, 66, 64, 231, 249, 70, 192, - 19, 113, 73, 128, 19, 112, 128, 24, 19, 112, 128, 16, 0, 0, 6, 102, 0, 15, 66, 64, 19, 112, 128, 20, 181, 240, 77, 17, - 176, 131, 28, 4, 73, 16, 34, 0, 104, 40, 247, 255, 251, 255, 79, 15, 28, 33, 104, 56, 247, 255, 251, 254, 76, 11, 174, - 1, 104, 40, 28, 49, 34, 0, 247, 255, 251, 255, 155, 1, 66, 163, 209, 247, 28, 49, 104, 40, 34, 0, 247, 255, 251, 247, - 104, 56, 247, 255, 251, 200, 176, 3, 188, 240, 188, 1, 71, 0, 19, 112, 128, 16, 0, 0, 5, 85, 19, 112, 128, 20, 181, - 240, 77, 19, 28, 4, 176, 131, 73, 18, 34, 0, 104, 40, 247, 255, 251, 213, 1, 97, 27, 9, 79, 16, 0, 137, 25, 9, 104, - 56, 0, 201, 247, 255, 251, 208, 76, 11, 174, 1, 104, 40, 28, 49, 34, 0, 247, 255, 251, 209, 155, 1, 66, 163, 209, 247, - 28, 49, 104, 40, 34, 0, 247, 255, 251, 201, 104, 56, 247, 255, 251, 154, 176, 3, 188, 240, 188, 1, 71, 0, 19, 112, 128, - 16, 0, 0, 5, 85, 19, 112, 128, 20, 181, 240, 75, 24, 28, 5, 104, 31, 35, 84, 92, 252, 70, 140, 28, 22, 44, 0, 208, 32, - 28, 57, 49, 96, 32, 0, 224, 3, 48, 1, 49, 40, 66, 132, 221, 24, 105, 139, 43, 0, 209, 248, 136, 10, 2, 19, 10, 18, 67, - 19, 4, 27, 12, 27, 66, 171, 209, 240, 136, 74, 2, 19, 10, 18, 67, 19, 4, 27, 12, 27, 69, 99, 209, 232, 0, 131, 24, 27, - 0, 219, 24, 251, 103, 158, 224, 1, 38, 6, 66, 118, 28, 48, 188, 240, 188, 2, 71, 8, 70, 192, 19, 112, 128, 28, 181, - 0, 40, 0, 208, 1, 35, 0, 98, 3, 32, 0, 188, 2, 71, 8, 181, 112, 75, 16, 28, 6, 104, 28, 35, 84, 92, 229, 45, 0, 208, - 18, 111, 163, 66, 179, 208, 19, 28, 33, 49, 160, 34, 0, 224, 8, 0, 147, 24, 155, 0, 219, 51, 88, 24, 224, 104, 11, 49, - 40, 66, 179, 208, 3, 50, 1, 66, 170, 219, 243, 32, 0, 188, 112, 188, 2, 71, 8, 28, 32, 48, 88, 231, 249, 19, 112, 128, - 28, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 70, 147, 74, 35, 28, 31, 104, 20, 35, 84, 92, 227, 70, 128, - 70, 148, 43, 0, 208, 59, 40, 0, 208, 57, 37, 0, 35, 84, 38, 0, 70, 169, 70, 154, 224, 1, 69, 69, 218, 36, 0, 179, 25, - 155, 0, 219, 24, 228, 111, 35, 43, 0, 208, 22, 0, 232, 28, 3, 70, 74, 51, 2, 82, 58, 52, 96, 83, 218, 136, 34, 28, 1, - 4, 18, 10, 19, 14, 18, 67, 19, 49, 4, 83, 203, 136, 99, 24, 56, 4, 27, 10, 26, 14, 27, 67, 26, 128, 194, 53, 1, 70, - 99, 104, 28, 70, 82, 92, 163, 54, 1, 66, 179, 220, 216, 6, 43, 14, 24, 70, 91, 112, 24, 32, 0, 188, 60, 70, 144, 70, - 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 32, 0, 231, 242, 19, 112, 128, 28, 181, 0, 75, 12, 28, 1, 120, 27, 43, - 1, 208, 2, 32, 0, 188, 2, 71, 8, 40, 0, 208, 11, 74, 8, 72, 8, 120, 19, 51, 4, 0, 155, 88, 195, 96, 11, 120, 19, 51, - 20, 0, 155, 88, 192, 231, 239, 72, 3, 74, 1, 231, 247, 19, 112, 129, 85, 19, 112, 129, 84, 19, 114, 73, 152, 181, 48, - 76, 18, 75, 18, 176, 131, 96, 35, 240, 2, 252, 95, 40, 0, 218, 5, 32, 1, 66, 64, 176, 3, 188, 48, 188, 2, 71, 8, 72, - 13, 33, 1, 247, 255, 250, 201, 28, 5, 40, 0, 219, 242, 35, 0, 73, 10, 34, 0, 147, 0, 247, 255, 250, 152, 96, 32, 28, - 40, 247, 255, 250, 184, 104, 33, 34, 1, 35, 84, 84, 202, 32, 0, 231, 228, 19, 112, 128, 28, 19, 114, 74, 60, 19, 112, - 128, 160, 77, 76, 68, 160, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 124, 130, 124, 199, 125, 6, 6, 19, 70, - 148, 125, 68, 4, 58, 67, 26, 2, 51, 67, 19, 28, 33, 176, 129, 70, 128, 67, 25, 208, 121, 124, 67, 70, 154, 43, 0, 208, - 114, 34, 0, 70, 147, 70, 145, 70, 75, 24, 205, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, - 42, 28, 16, 67, 24, 208, 82, 121, 43, 43, 0, 208, 58, 39, 0, 38, 0, 224, 10, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, - 122, 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 25, 132, 123, 163, 123, 226, 6, 27, 4, 18, 67, 26, 124, 35, 2, 27, - 67, 19, 124, 98, 28, 16, 67, 24, 208, 1, 240, 2, 251, 154, 122, 99, 122, 162, 6, 27, 4, 18, 67, 26, 122, 227, 2, 27, - 67, 19, 123, 34, 28, 16, 67, 24, 208, 1, 240, 2, 251, 140, 121, 43, 55, 1, 54, 18, 66, 187, 220, 210, 122, 107, 122, - 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 240, 2, 251, 122, 70, 66, 124, 82, 70, - 67, 70, 146, 70, 66, 124, 155, 124, 215, 70, 156, 4, 58, 6, 27, 67, 26, 70, 67, 125, 30, 2, 51, 67, 19, 70, 66, 125, - 84, 28, 33, 67, 25, 35, 1, 34, 13, 68, 155, 68, 145, 69, 218, 221, 8, 70, 98, 6, 19, 4, 58, 67, 26, 2, 51, 67, 19, 28, - 33, 67, 25, 231, 143, 28, 8, 240, 2, 251, 85, 176, 1, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 1, - 71, 0, 181, 48, 75, 15, 176, 129, 104, 25, 108, 10, 28, 19, 51, 8, 0, 155, 88, 92, 50, 1, 100, 10, 28, 32, 240, 2, 251, - 60, 33, 0, 28, 5, 34, 96, 28, 32, 240, 3, 251, 218, 35, 64, 96, 163, 35, 128, 4, 91, 176, 1, 99, 101, 28, 32, 96, 35, - 96, 99, 188, 48, 188, 2, 71, 8, 19, 112, 128, 28, 181, 48, 77, 16, 176, 129, 104, 43, 43, 0, 209, 3, 176, 1, 188, 48, - 188, 1, 71, 0, 76, 12, 35, 160, 88, 224, 40, 0, 208, 1, 240, 2, 251, 25, 34, 164, 33, 0, 28, 32, 240, 3, 251, 182, 72, - 7, 33, 0, 247, 255, 250, 42, 74, 6, 35, 0, 112, 19, 74, 6, 96, 43, 96, 19, 231, 228, 70, 192, 19, 112, 129, 80, 19, - 114, 73, 152, 19, 112, 128, 172, 19, 112, 129, 85, 19, 112, 129, 76, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, - 240, 74, 204, 176, 137, 146, 3, 104, 17, 70, 129, 108, 10, 28, 19, 51, 8, 0, 155, 88, 91, 50, 1, 100, 10, 28, 24, 70, - 152, 240, 2, 250, 230, 34, 96, 28, 4, 33, 0, 70, 64, 240, 3, 251, 132, 70, 67, 99, 92, 70, 66, 35, 64, 96, 147, 35, - 128, 4, 91, 96, 19, 96, 83, 70, 75, 99, 211, 70, 74, 35, 0, 97, 83, 105, 19, 147, 4, 126, 82, 70, 75, 146, 6, 126, 24, - 40, 0, 209, 0, 224, 176, 34, 128, 35, 192, 70, 70, 70, 147, 0, 91, 70, 74, 104, 215, 154, 6, 42, 0, 208, 0, 70, 155, - 70, 75, 105, 218, 75, 176, 37, 255, 64, 19, 147, 5, 34, 255, 59, 1, 147, 2, 2, 19, 34, 128, 1, 82, 70, 154, 4, 45, 146, - 1, 155, 4, 14, 58, 70, 156, 6, 59, 67, 26, 70, 83, 64, 59, 2, 27, 67, 26, 28, 59, 64, 43, 10, 27, 67, 26, 96, 242, 34, - 0, 98, 50, 75, 163, 154, 1, 64, 59, 26, 208, 155, 4, 66, 131, 211, 0, 224, 213, 34, 0, 28, 28, 146, 4, 70, 91, 4, 34, - 67, 26, 6, 19, 14, 17, 67, 25, 70, 83, 64, 19, 2, 27, 64, 42, 67, 25, 10, 18, 67, 17, 70, 98, 96, 177, 100, 50, 155, - 6, 43, 0, 208, 4, 154, 3, 104, 19, 105, 219, 105, 91, 96, 115, 154, 2, 25, 19, 154, 5, 66, 19, 209, 1, 75, 144, 68, - 155, 154, 4, 42, 0, 221, 0, 224, 230, 39, 128, 4, 127, 150, 7, 70, 74, 96, 119, 105, 19, 43, 0, 208, 65, 126, 19, 70, - 154, 43, 0, 209, 61, 154, 3, 35, 128, 104, 17, 0, 91, 70, 93, 108, 10, 64, 93, 75, 131, 67, 29, 28, 19, 51, 8, 0, 155, - 88, 94, 50, 1, 100, 10, 28, 48, 240, 2, 250, 83, 33, 0, 28, 4, 34, 96, 28, 48, 240, 3, 250, 241, 70, 75, 99, 243, 14, - 34, 6, 35, 32, 255, 67, 26, 2, 0, 28, 35, 33, 255, 4, 9, 64, 3, 99, 116, 96, 55, 2, 27, 96, 119, 64, 12, 67, 26, 10, - 36, 155, 7, 67, 34, 96, 26, 70, 82, 99, 158, 96, 242, 6, 43, 98, 50, 14, 42, 67, 26, 28, 43, 64, 3, 2, 27, 64, 13, 67, - 26, 10, 45, 67, 42, 70, 83, 96, 178, 100, 51, 104, 179, 34, 128, 4, 18, 67, 19, 176, 9, 70, 64, 96, 179, 188, 60, 70, - 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 70, 75, 104, 89, 37, 255, 6, 11, 14, 10, 67, 26, 2, 45, 28, - 11, 64, 43, 2, 27, 36, 255, 67, 26, 4, 36, 28, 11, 64, 35, 10, 27, 67, 26, 70, 67, 96, 218, 98, 24, 75, 85, 28, 10, - 64, 26, 35, 128, 1, 91, 26, 155, 43, 8, 216, 0, 224, 132, 75, 83, 70, 66, 96, 147, 35, 8, 100, 19, 155, 3, 104, 25, - 108, 10, 28, 19, 51, 8, 0, 155, 88, 94, 50, 1, 100, 10, 28, 48, 240, 2, 249, 234, 34, 96, 28, 4, 33, 0, 28, 48, 240, - 3, 250, 136, 35, 64, 96, 179, 35, 128, 4, 91, 70, 74, 96, 51, 96, 115, 99, 242, 6, 35, 14, 34, 67, 26, 35, 255, 2, 27, - 64, 35, 2, 27, 67, 26, 35, 255, 4, 27, 99, 116, 64, 28, 10, 36, 67, 34, 70, 67, 96, 26, 99, 158, 154, 4, 42, 0, 209, - 2, 75, 58, 70, 155, 231, 0, 74, 58, 75, 56, 70, 147, 230, 252, 28, 4, 66, 163, 217, 92, 35, 128, 1, 91, 24, 250, 75, - 54, 28, 17, 34, 1, 64, 25, 28, 48, 70, 148, 6, 11, 14, 10, 67, 26, 70, 83, 64, 11, 2, 27, 67, 26, 28, 11, 64, 43, 10, - 27, 67, 26, 35, 0, 97, 2, 98, 67, 34, 128, 1, 82, 155, 4, 24, 164, 24, 137, 66, 163, 216, 5, 28, 28, 155, 4, 70, 164, - 27, 27, 147, 4, 231, 5, 34, 1, 68, 148, 70, 99, 48, 4, 43, 4, 221, 222, 28, 32, 153, 5, 240, 3, 249, 186, 154, 4, 26, - 100, 27, 18, 70, 164, 146, 4, 230, 245, 68, 103, 247, 255, 254, 61, 107, 66, 70, 75, 14, 17, 99, 195, 6, 19, 67, 25, - 70, 83, 64, 19, 2, 27, 64, 42, 67, 25, 10, 18, 67, 17, 96, 49, 99, 176, 28, 6, 230, 198, 43, 8, 209, 0, 231, 119, 34, - 128, 1, 82, 75, 17, 24, 137, 64, 25, 28, 10, 28, 11, 64, 42, 64, 35, 10, 27, 2, 18, 67, 26, 14, 9, 70, 67, 67, 10, 97, - 26, 98, 88, 231, 101, 154, 4, 66, 162, 209, 201, 231, 189, 70, 192, 19, 112, 128, 28, 0, 0, 7, 255, 0, 0, 15, 255, 128, - 0, 0, 0, 128, 2, 8, 0, 128, 0, 1, 128, 128, 0, 0, 128, 255, 255, 240, 0, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, - 240, 176, 133, 144, 3, 145, 2, 126, 11, 43, 0, 209, 0, 226, 33, 154, 2, 105, 17, 41, 0, 208, 8, 126, 83, 43, 0, 209, - 0, 226, 19, 104, 144, 240, 2, 249, 130, 155, 2, 96, 216, 72, 227, 34, 0, 104, 3, 70, 129, 105, 219, 70, 154, 195, 4, - 51, 4, 70, 81, 96, 74, 195, 4, 195, 4, 195, 4, 195, 4, 195, 4, 195, 4, 195, 4, 195, 4, 195, 4, 96, 26, 152, 2, 247, - 255, 254, 31, 70, 82, 100, 144, 155, 2, 158, 3, 126, 25, 105, 220, 34, 128, 105, 179, 1, 146, 67, 26, 35, 15, 64, 11, - 28, 5, 2, 27, 28, 16, 67, 24, 41, 0, 208, 0, 225, 205, 75, 207, 28, 1, 67, 25, 6, 11, 14, 10, 36, 255, 2, 36, 67, 26, - 28, 11, 64, 35, 2, 27, 32, 255, 4, 0, 67, 26, 28, 11, 64, 3, 10, 27, 70, 81, 67, 26, 96, 74, 108, 74, 35, 64, 96, 139, - 28, 17, 28, 19, 64, 3, 64, 33, 10, 27, 2, 9, 67, 25, 14, 19, 67, 25, 35, 224, 64, 26, 35, 2, 67, 26, 6, 18, 67, 17, - 70, 82, 96, 17, 107, 106, 70, 86, 6, 19, 14, 17, 67, 25, 28, 19, 64, 35, 2, 27, 64, 2, 67, 25, 10, 18, 67, 17, 70, 83, - 97, 25, 35, 128, 4, 91, 97, 115, 152, 2, 126, 2, 42, 0, 208, 0, 225, 125, 70, 81, 105, 138, 75, 176, 70, 78, 64, 19, - 70, 82, 97, 147, 104, 51, 70, 80, 105, 155, 108, 89, 35, 255, 2, 27, 28, 10, 64, 26, 35, 255, 4, 27, 64, 11, 10, 27, - 2, 18, 67, 26, 14, 11, 67, 26, 35, 224, 64, 25, 35, 2, 67, 25, 6, 9, 67, 10, 96, 2, 33, 96, 240, 2, 248, 231, 70, 81, - 108, 140, 44, 0, 208, 6, 28, 32, 33, 96, 240, 2, 248, 223, 107, 164, 44, 0, 209, 248, 70, 78, 104, 51, 70, 82, 108, - 81, 105, 152, 35, 255, 2, 27, 28, 10, 64, 26, 35, 255, 4, 27, 64, 11, 10, 27, 2, 18, 67, 26, 14, 11, 67, 26, 35, 224, - 64, 25, 35, 2, 67, 25, 6, 9, 67, 10, 96, 2, 104, 51, 33, 96, 105, 152, 240, 2, 248, 191, 104, 51, 152, 3, 104, 154, - 75, 140, 33, 2, 104, 28, 105, 195, 29, 23, 51, 16, 0, 155, 24, 211, 51, 4, 70, 152, 70, 139, 32, 100, 247, 255, 251, - 56, 70, 73, 104, 14, 70, 67, 104, 26, 104, 179, 104, 56, 29, 29, 104, 91, 33, 55, 64, 25, 75, 129, 64, 26, 42, 1, 208, - 0, 225, 84, 70, 91, 66, 25, 208, 0, 225, 93, 7, 195, 213, 0, 225, 99, 60, 100, 44, 0, 220, 227, 96, 41, 70, 73, 104, - 11, 104, 155, 104, 27, 75, 120, 96, 26, 34, 1, 66, 83, 70, 155, 70, 78, 104, 51, 33, 96, 105, 155, 108, 88, 240, 2, - 248, 108, 70, 81, 108, 72, 33, 96, 240, 2, 248, 103, 70, 82, 108, 148, 44, 0, 208, 6, 107, 96, 33, 96, 240, 2, 248, - 95, 107, 164, 44, 0, 209, 248, 70, 78, 104, 51, 105, 152, 35, 255, 108, 65, 2, 27, 28, 10, 64, 26, 35, 255, 4, 27, 64, - 11, 10, 27, 2, 18, 67, 26, 14, 11, 67, 26, 35, 224, 64, 25, 35, 2, 67, 25, 6, 9, 67, 10, 96, 2, 104, 51, 33, 96, 105, - 152, 240, 2, 248, 88, 104, 51, 33, 96, 105, 155, 108, 88, 240, 2, 248, 58, 152, 2, 126, 2, 42, 0, 208, 23, 153, 3, 35, - 15, 106, 72, 28, 17, 64, 25, 6, 19, 43, 0, 218, 0, 224, 248, 34, 1, 28, 19, 64, 139, 28, 4, 70, 86, 67, 156, 105, 179, - 9, 219, 28, 24, 64, 16, 28, 3, 64, 139, 152, 3, 67, 35, 98, 67, 70, 89, 41, 0, 209, 53, 70, 74, 104, 19, 158, 3, 104, - 154, 105, 155, 28, 23, 108, 91, 55, 24, 70, 154, 105, 243, 36, 0, 51, 16, 0, 155, 24, 211, 51, 4, 70, 152, 32, 100, - 247, 255, 250, 170, 70, 73, 104, 14, 70, 64, 104, 179, 104, 2, 29, 29, 104, 56, 104, 91, 33, 55, 64, 25, 75, 58, 64, - 26, 42, 1, 208, 0, 224, 228, 35, 2, 66, 25, 208, 0, 224, 234, 69, 130, 209, 0, 224, 240, 52, 1, 44, 200, 209, 227, 96, - 41, 70, 78, 104, 51, 104, 155, 104, 27, 75, 49, 96, 26, 32, 1, 66, 65, 70, 139, 70, 74, 104, 19, 105, 219, 108, 156, - 44, 0, 208, 59, 35, 255, 72, 44, 39, 255, 4, 27, 38, 3, 33, 64, 37, 0, 2, 63, 147, 1, 70, 176, 70, 132, 70, 138, 104, - 162, 70, 70, 6, 19, 14, 17, 67, 25, 28, 19, 64, 59, 2, 27, 67, 25, 155, 1, 28, 8, 64, 26, 10, 18, 67, 16, 10, 3, 64, - 51, 43, 2, 208, 8, 107, 225, 108, 34, 105, 75, 70, 102, 24, 210, 12, 3, 64, 51, 26, 210, 97, 74, 108, 35, 43, 0, 209, - 3, 35, 255, 64, 3, 43, 64, 208, 4, 70, 81, 66, 8, 208, 1, 37, 1, 66, 109, 107, 164, 44, 0, 209, 213, 45, 0, 208, 3, - 107, 226, 35, 1, 66, 91, 97, 83, 70, 75, 104, 26, 35, 0, 100, 19, 158, 2, 105, 49, 41, 0, 208, 6, 126, 115, 43, 0, 208, - 65, 104, 240, 240, 1, 255, 165, 158, 2, 126, 51, 43, 0, 208, 66, 224, 13, 19, 112, 128, 28, 64, 64, 64, 0, 1, 0, 0, - 128, 19, 112, 128, 32, 0, 0, 32, 1, 19, 112, 129, 76, 0, 0, 127, 255, 70, 88, 40, 0, 209, 2, 153, 2, 105, 73, 70, 139, - 176, 5, 70, 88, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 155, 3, 106, 88, 6, 19, 43, 0, - 219, 54, 33, 0, 35, 15, 64, 19, 24, 203, 64, 216, 7, 198, 213, 41, 70, 80, 105, 130, 35, 128, 67, 26, 97, 130, 230, - 113, 75, 50, 28, 34, 64, 26, 35, 128, 4, 18, 5, 219, 67, 26, 28, 17, 67, 1, 230, 42, 154, 2, 104, 208, 240, 1, 255, - 90, 158, 2, 126, 51, 43, 0, 209, 203, 104, 112, 33, 8, 240, 1, 255, 90, 231, 198, 158, 2, 104, 176, 240, 1, 255, 101, - 96, 240, 229, 234, 104, 8, 33, 8, 240, 1, 255, 103, 153, 2, 96, 72, 229, 214, 70, 81, 105, 138, 35, 128, 67, 154, 97, - 138, 230, 71, 33, 16, 231, 199, 49, 16, 231, 4, 74, 28, 35, 1, 96, 19, 104, 179, 70, 78, 96, 89, 104, 51, 32, 1, 104, - 155, 66, 65, 104, 27, 70, 139, 230, 177, 96, 41, 70, 78, 104, 51, 32, 2, 104, 155, 66, 65, 104, 27, 70, 139, 230, 168, - 96, 41, 70, 78, 104, 51, 32, 0, 104, 155, 70, 131, 104, 27, 230, 160, 74, 13, 35, 1, 96, 19, 104, 179, 70, 78, 96, 89, - 104, 51, 104, 155, 104, 27, 231, 33, 96, 41, 70, 78, 104, 51, 32, 2, 104, 155, 66, 65, 104, 27, 70, 139, 231, 27, 96, - 41, 70, 74, 104, 19, 104, 155, 104, 27, 231, 21, 70, 192, 0, 0, 7, 255, 19, 112, 129, 76, 181, 48, 176, 137, 70, 109, - 118, 41, 9, 201, 118, 105, 33, 128, 0, 137, 145, 7, 36, 0, 70, 105, 148, 0, 146, 4, 147, 2, 247, 255, 253, 116, 176, - 9, 188, 48, 188, 2, 71, 8, 181, 240, 70, 71, 180, 128, 176, 136, 70, 128, 70, 104, 48, 58, 136, 5, 48, 4, 136, 6, 72, - 40, 4, 45, 104, 4, 32, 248, 88, 32, 4, 54, 112, 66, 2, 26, 10, 27, 67, 26, 4, 18, 12, 19, 112, 195, 10, 43, 14, 45, - 67, 43, 14, 18, 4, 27, 112, 130, 12, 55, 12, 26, 14, 27, 113, 3, 14, 54, 2, 59, 67, 51, 4, 27, 113, 66, 14, 26, 12, - 27, 112, 1, 113, 195, 70, 108, 35, 0, 9, 201, 113, 130, 118, 35, 118, 97, 35, 64, 144, 0, 147, 7, 152, 16, 75, 20, 151, - 4, 66, 152, 216, 12, 96, 160, 70, 105, 70, 64, 247, 255, 253, 51, 28, 5, 176, 8, 28, 40, 188, 4, 70, 144, 188, 240, - 188, 2, 71, 8, 28, 56, 240, 1, 254, 130, 28, 58, 153, 16, 144, 2, 240, 2, 254, 207, 70, 105, 70, 64, 247, 255, 253, - 31, 153, 2, 28, 5, 28, 58, 152, 16, 240, 2, 254, 197, 152, 2, 240, 1, 254, 100, 231, 226, 70, 192, 19, 112, 128, 28, - 19, 136, 0, 0, 181, 0, 176, 133, 42, 0, 209, 4, 32, 3, 66, 64, 176, 5, 188, 2, 71, 8, 28, 19, 34, 0, 145, 0, 146, 1, - 146, 2, 33, 1, 34, 11, 247, 255, 255, 142, 231, 242, 70, 192, 181, 0, 176, 133, 34, 0, 146, 0, 146, 1, 146, 2, 28, 11, - 34, 9, 33, 0, 247, 255, 255, 129, 176, 5, 188, 2, 71, 8, 181, 16, 176, 132, 28, 20, 70, 106, 50, 27, 120, 18, 2, 36, - 67, 28, 35, 0, 147, 0, 146, 1, 145, 2, 34, 6, 33, 128, 28, 35, 247, 255, 255, 109, 176, 4, 188, 16, 188, 2, 71, 8, 70, - 192, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 137, 144, 6, 72, 160, 155, 6, 104, 1, 51, 16, 145, 7, - 104, 138, 0, 155, 24, 213, 154, 6, 70, 128, 152, 6, 0, 146, 104, 105, 24, 19, 146, 5, 154, 7, 0, 219, 24, 211, 34, 0, - 103, 26, 75, 151, 64, 25, 70, 155, 41, 1, 208, 0, 224, 227, 75, 149, 32, 100, 96, 107, 247, 255, 248, 239, 75, 148, - 32, 100, 96, 107, 247, 255, 248, 234, 75, 146, 32, 100, 96, 107, 247, 255, 248, 187, 70, 64, 104, 4, 104, 106, 104, - 163, 104, 105, 29, 31, 104, 91, 32, 55, 70, 129, 64, 24, 70, 91, 64, 26, 42, 1, 208, 0, 224, 203, 34, 2, 70, 146, 66, - 16, 208, 0, 224, 184, 38, 128, 0, 118, 66, 49, 209, 0, 224, 205, 32, 100, 247, 255, 248, 159, 70, 67, 104, 28, 104, - 106, 104, 163, 104, 105, 29, 31, 104, 91, 70, 72, 64, 24, 70, 91, 64, 26, 42, 1, 208, 0, 224, 176, 70, 82, 66, 16, 208, - 0, 224, 158, 66, 49, 209, 0, 224, 181, 32, 100, 247, 255, 248, 135, 70, 67, 104, 28, 104, 106, 104, 163, 104, 105, 29, - 31, 104, 91, 70, 72, 64, 24, 70, 91, 64, 26, 42, 1, 208, 0, 224, 152, 70, 82, 66, 16, 208, 0, 224, 134, 66, 49, 209, - 0, 224, 157, 32, 100, 247, 255, 248, 111, 70, 67, 104, 28, 104, 106, 104, 163, 104, 105, 29, 31, 104, 91, 32, 55, 70, - 131, 64, 24, 75, 98, 64, 26, 70, 153, 42, 1, 208, 0, 224, 126, 34, 2, 66, 16, 209, 109, 38, 128, 0, 118, 66, 49, 209, - 0, 224, 130, 32, 100, 247, 255, 248, 84, 70, 67, 104, 28, 104, 106, 104, 163, 104, 105, 29, 31, 104, 91, 70, 88, 64, - 24, 70, 75, 64, 26, 42, 1, 209, 102, 70, 82, 66, 16, 209, 85, 66, 49, 208, 109, 32, 100, 247, 255, 248, 63, 70, 67, - 104, 28, 104, 106, 104, 163, 104, 105, 29, 31, 104, 91, 70, 88, 64, 24, 70, 75, 64, 26, 42, 1, 209, 81, 70, 82, 66, - 16, 209, 64, 66, 49, 208, 88, 32, 100, 247, 255, 248, 42, 70, 67, 104, 28, 104, 106, 104, 163, 104, 105, 29, 31, 104, - 91, 70, 88, 64, 24, 70, 75, 64, 26, 42, 1, 209, 60, 34, 2, 66, 16, 209, 43, 38, 128, 0, 118, 66, 49, 208, 65, 32, 100, - 247, 255, 248, 19, 70, 67, 104, 28, 104, 105, 104, 163, 104, 109, 104, 90, 29, 31, 28, 16, 35, 55, 64, 24, 70, 75, 64, - 25, 41, 1, 209, 36, 70, 82, 66, 16, 209, 19, 66, 53, 208, 43, 96, 56, 70, 64, 104, 3, 32, 1, 104, 155, 66, 64, 104, - 27, 75, 48, 96, 25, 176, 9, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 96, 56, 70, 64, 104, - 3, 32, 2, 104, 155, 66, 64, 104, 27, 231, 238, 35, 128, 1, 155, 32, 1, 96, 107, 66, 64, 231, 232, 74, 35, 35, 1, 96, - 19, 104, 163, 96, 88, 70, 64, 104, 3, 32, 1, 104, 155, 66, 64, 104, 27, 231, 220, 153, 5, 154, 6, 37, 0, 24, 139, 0, - 219, 153, 7, 70, 66, 96, 56, 70, 154, 51, 88, 24, 204, 104, 19, 32, 100, 104, 155, 104, 27, 247, 254, 255, 237, 35, - 22, 147, 1, 35, 128, 28, 32, 33, 128, 34, 6, 0, 91, 149, 0, 148, 2, 247, 255, 254, 52, 40, 0, 219, 190, 158, 6, 28, - 32, 54, 1, 4, 51, 12, 27, 33, 0, 34, 5, 149, 0, 149, 1, 149, 2, 247, 255, 254, 38, 40, 0, 219, 176, 155, 7, 68, 83, - 103, 221, 103, 30, 231, 171, 70, 192, 19, 112, 128, 28, 0, 0, 32, 1, 0, 0, 24, 3, 0, 0, 25, 3, 0, 0, 16, 1, 19, 112, - 129, 76, 181, 112, 77, 12, 35, 84, 104, 42, 92, 211, 43, 0, 208, 14, 36, 0, 38, 84, 0, 163, 25, 27, 0, 219, 24, 211, - 103, 92, 28, 32, 247, 255, 254, 153, 104, 42, 52, 1, 93, 147, 66, 163, 220, 242, 32, 0, 188, 112, 188, 2, 71, 8, 19, - 112, 128, 28, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 75, 81, 39, 0, 34, 144, 176, 133, 28, 4, 70, 146, - 70, 185, 70, 155, 224, 98, 70, 82, 88, 162, 32, 1, 70, 144, 240, 1, 252, 171, 28, 6, 40, 0, 208, 83, 70, 75, 147, 0, - 35, 1, 147, 1, 144, 2, 33, 128, 70, 64, 34, 8, 35, 0, 247, 255, 253, 211, 40, 0, 219, 108, 120, 50, 28, 48, 70, 144, - 240, 1, 252, 138, 120, 35, 69, 67, 208, 11, 70, 82, 88, 160, 70, 74, 146, 0, 146, 1, 146, 2, 33, 0, 34, 9, 247, 255, - 253, 191, 40, 0, 219, 50, 104, 163, 43, 0, 209, 89, 70, 83, 88, 224, 136, 227, 70, 74, 147, 0, 146, 1, 146, 2, 33, 33, - 34, 255, 35, 0, 247, 255, 253, 174, 28, 5, 40, 0, 219, 67, 32, 10, 247, 254, 255, 86, 70, 83, 88, 224, 123, 35, 70, - 74, 147, 0, 146, 1, 146, 2, 33, 2, 34, 1, 35, 0, 247, 255, 253, 156, 28, 5, 40, 0, 219, 14, 70, 83, 88, 224, 123, 99, - 70, 74, 147, 0, 146, 1, 146, 2, 33, 2, 34, 1, 35, 0, 247, 255, 253, 141, 28, 5, 40, 0, 218, 24, 47, 20, 208, 22, 32, - 100, 247, 254, 255, 51, 55, 1, 47, 0, 208, 199, 70, 82, 88, 163, 105, 216, 247, 255, 254, 21, 28, 5, 32, 10, 247, 254, - 255, 39, 28, 107, 208, 5, 45, 0, 218, 141, 69, 93, 208, 139, 47, 20, 209, 232, 176, 5, 28, 40, 188, 60, 70, 144, 70, - 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 69, 88, 209, 218, 231, 184, 28, 48, 240, 1, 252, 31, 231, 213, 6, 27, - 70, 82, 14, 27, 88, 160, 104, 98, 43, 0, 208, 206, 6, 18, 14, 18, 146, 0, 70, 74, 146, 1, 146, 2, 33, 1, 34, 11, 247, - 255, 253, 79, 40, 0, 218, 146, 231, 193, 255, 255, 228, 164, 181, 0, 176, 129, 33, 0, 247, 255, 255, 79, 176, 1, 188, - 2, 71, 8, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 143, 28, 30, 70, 107, 51, 103, 120, 27, 145, 2, 147, - 1, 70, 107, 51, 107, 120, 27, 33, 128, 147, 0, 155, 1, 37, 0, 59, 1, 6, 27, 28, 7, 70, 146, 14, 27, 32, 11, 0, 138, - 147, 4, 70, 131, 149, 5, 149, 3, 70, 145, 45, 0, 209, 54, 70, 91, 59, 1, 6, 27, 152, 0, 14, 27, 70, 155, 40, 0, 208, - 61, 153, 4, 41, 15, 217, 79, 37, 3, 66, 109, 70, 88, 6, 4, 152, 5, 34, 1, 70, 128, 44, 0, 221, 1, 42, 0, 209, 26, 44, - 0, 220, 0, 225, 211, 28, 169, 208, 1, 42, 0, 209, 49, 155, 27, 43, 0, 208, 1, 70, 64, 112, 24, 153, 28, 41, 0, 208, - 1, 154, 3, 96, 10, 176, 15, 28, 40, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 28, 107, 208, - 35, 70, 64, 144, 5, 45, 0, 208, 200, 70, 88, 6, 4, 22, 35, 15, 217, 34, 9, 37, 0, 66, 154, 65, 105, 28, 56, 247, 255, - 254, 232, 28, 5, 40, 0, 219, 201, 231, 185, 153, 4, 41, 15, 216, 0, 224, 177, 37, 3, 66, 109, 70, 90, 6, 20, 231, 191, - 28, 56, 33, 0, 247, 255, 254, 215, 28, 130, 209, 199, 28, 5, 231, 197, 74, 209, 35, 1, 96, 19, 231, 203, 34, 160, 88, - 184, 70, 144, 40, 0, 208, 170, 33, 0, 34, 31, 240, 2, 252, 28, 70, 67, 88, 250, 75, 202, 70, 64, 96, 19, 35, 152, 88, - 250, 36, 255, 6, 19, 14, 17, 88, 61, 67, 25, 2, 36, 28, 19, 32, 255, 4, 0, 64, 35, 2, 27, 64, 2, 67, 25, 10, 18, 67, - 17, 96, 105, 70, 66, 88, 185, 6, 51, 14, 50, 67, 26, 28, 51, 64, 35, 2, 27, 67, 26, 28, 51, 64, 3, 10, 27, 67, 26, 96, - 138, 70, 69, 89, 123, 32, 0, 115, 24, 70, 105, 34, 11, 89, 123, 92, 81, 115, 89, 35, 156, 92, 251, 43, 0, 209, 0, 224, - 236, 89, 122, 35, 12, 115, 147, 36, 160, 89, 56, 153, 24, 154, 1, 48, 15, 240, 2, 251, 155, 33, 144, 88, 120, 89, 59, - 123, 121, 34, 31, 247, 255, 252, 100, 28, 5, 40, 31, 208, 0, 225, 18, 46, 0, 209, 0, 224, 234, 4, 51, 12, 27, 172, 6, - 70, 152, 123, 123, 37, 144, 89, 120, 118, 35, 9, 219, 33, 0, 118, 99, 70, 74, 70, 67, 70, 85, 96, 33, 96, 165, 97, 226, - 97, 35, 28, 33, 247, 255, 249, 204, 28, 5, 28, 104, 209, 0, 224, 206, 45, 0, 218, 0, 224, 193, 66, 181, 208, 0, 224, - 189, 68, 178, 28, 51, 70, 180, 45, 0, 218, 0, 225, 16, 38, 0, 34, 160, 70, 144, 88, 184, 33, 255, 34, 13, 240, 2, 251, - 164, 123, 59, 70, 69, 33, 144, 89, 122, 88, 120, 118, 35, 9, 219, 37, 0, 118, 99, 70, 73, 35, 13, 96, 37, 97, 225, 97, - 35, 96, 162, 28, 33, 247, 255, 249, 162, 28, 5, 40, 0, 218, 0, 231, 89, 40, 13, 209, 0, 224, 166, 155, 5, 77, 131, 70, - 152, 70, 91, 34, 1, 6, 28, 231, 21, 34, 160, 88, 184, 70, 144, 40, 0, 209, 0, 231, 71, 33, 0, 34, 31, 240, 2, 251, 122, - 70, 67, 88, 250, 75, 121, 70, 64, 96, 19, 35, 152, 88, 250, 36, 255, 6, 19, 14, 17, 88, 61, 67, 25, 2, 36, 28, 19, 32, - 255, 4, 0, 64, 35, 2, 27, 64, 2, 67, 25, 10, 18, 67, 17, 96, 105, 70, 66, 88, 185, 6, 51, 14, 50, 67, 26, 28, 51, 64, - 35, 2, 27, 67, 26, 28, 51, 64, 3, 10, 27, 67, 26, 96, 138, 70, 67, 88, 250, 35, 128, 66, 91, 115, 19, 70, 69, 70, 104, - 33, 11, 89, 123, 92, 8, 115, 88, 35, 156, 92, 251, 43, 0, 208, 65, 89, 122, 35, 12, 115, 147, 36, 160, 89, 56, 153, - 24, 154, 1, 37, 144, 48, 15, 240, 2, 250, 247, 89, 120, 123, 121, 89, 59, 34, 31, 247, 255, 251, 193, 28, 5, 40, 31, - 209, 68, 46, 0, 208, 73, 172, 6, 224, 4, 37, 1, 28, 30, 66, 109, 46, 0, 208, 27, 123, 59, 33, 144, 88, 120, 118, 35, - 9, 219, 118, 99, 70, 75, 97, 227, 4, 51, 34, 0, 12, 27, 70, 85, 96, 165, 96, 34, 97, 35, 28, 33, 247, 255, 249, 39, - 28, 5, 40, 0, 219, 232, 26, 51, 68, 130, 66, 174, 209, 225, 28, 30, 46, 0, 209, 227, 45, 0, 219, 0, 231, 94, 152, 5, - 70, 89, 15, 234, 70, 128, 6, 12, 230, 149, 155, 1, 70, 65, 88, 122, 43, 6, 216, 55, 35, 6, 115, 147, 231, 184, 157, - 1, 70, 67, 88, 250, 45, 6, 216, 50, 35, 6, 115, 147, 231, 13, 77, 57, 46, 0, 208, 0, 231, 34, 28, 43, 70, 172, 231, - 61, 40, 0, 218, 0, 230, 118, 77, 53, 70, 89, 6, 12, 230, 116, 172, 6, 231, 56, 70, 69, 89, 123, 36, 255, 104, 26, 104, - 152, 104, 93, 123, 27, 14, 17, 70, 152, 6, 19, 67, 25, 70, 132, 28, 19, 2, 36, 32, 255, 64, 35, 4, 0, 2, 27, 64, 2, - 67, 25, 10, 18, 75, 41, 67, 17, 66, 153, 208, 16, 153, 5, 77, 39, 70, 136, 231, 62, 35, 16, 115, 147, 231, 128, 35, - 16, 115, 147, 230, 218, 40, 0, 218, 0, 230, 137, 70, 91, 77, 31, 6, 28, 230, 72, 6, 43, 14, 42, 67, 26, 28, 43, 64, - 35, 2, 27, 67, 26, 28, 43, 64, 3, 10, 27, 28, 17, 67, 25, 70, 99, 14, 26, 6, 27, 67, 26, 70, 99, 64, 35, 2, 27, 67, - 26, 70, 99, 64, 3, 10, 27, 67, 26, 146, 3, 34, 152, 88, 187, 66, 153, 208, 18, 77, 18, 231, 18, 15, 218, 155, 5, 70, - 88, 70, 101, 70, 152, 38, 0, 6, 4, 230, 36, 42, 0, 209, 0, 230, 40, 74, 4, 35, 1, 37, 1, 96, 19, 66, 109, 230, 48, 28, - 75, 80, 187, 37, 0, 230, 34, 19, 112, 129, 76, 85, 83, 66, 67, 255, 255, 216, 237, 255, 255, 216, 233, 255, 255, 216, - 238, 83, 66, 83, 85, 255, 255, 216, 236, 255, 255, 216, 235, 181, 240, 70, 87, 70, 78, 70, 69, 180, 224, 176, 140, 70, - 129, 32, 18, 70, 136, 240, 1, 249, 213, 70, 109, 34, 47, 68, 106, 38, 0, 53, 31, 28, 7, 70, 146, 112, 22, 28, 40, 33, - 0, 34, 16, 240, 2, 250, 94, 47, 0, 208, 32, 35, 1, 112, 46, 147, 1, 147, 2, 70, 83, 147, 3, 70, 72, 70, 65, 34, 0, 35, - 0, 149, 0, 150, 4, 247, 255, 253, 172, 28, 4, 40, 0, 219, 3, 70, 82, 120, 19, 43, 0, 209, 14, 28, 56, 240, 1, 249, 162, - 176, 12, 28, 32, 188, 28, 70, 144, 70, 153, 70, 162, 188, 240, 188, 2, 71, 8, 36, 4, 66, 100, 231, 243, 35, 3, 70, 66, - 112, 43, 1, 83, 112, 107, 33, 0, 35, 18, 34, 18, 28, 56, 113, 43, 113, 110, 240, 2, 250, 43, 35, 6, 147, 1, 70, 72, - 70, 65, 28, 58, 35, 18, 149, 0, 150, 2, 150, 3, 150, 4, 247, 255, 253, 125, 28, 4, 40, 0, 219, 212, 120, 187, 34, 15, - 64, 19, 70, 82, 112, 19, 59, 2, 6, 27, 14, 27, 43, 2, 216, 202, 76, 0, 231, 200, 255, 255, 216, 239, 181, 240, 70, 95, - 70, 86, 70, 77, 70, 68, 180, 240, 176, 149, 144, 11, 72, 91, 145, 10, 144, 8, 120, 3, 146, 9, 43, 1, 208, 9, 32, 0, - 176, 21, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 4, 11, 12, 27, 147, 15, 74, 82, 75, 83, - 33, 0, 145, 14, 146, 7, 70, 153, 152, 7, 70, 74, 120, 0, 28, 7, 55, 4, 0, 187, 144, 12, 88, 209, 152, 15, 28, 11, 67, - 67, 32, 128, 2, 0, 66, 131, 216, 111, 153, 15, 70, 139, 28, 10, 42, 0, 208, 216, 152, 12, 153, 9, 7, 67, 14, 27, 70, - 108, 0, 191, 157, 11, 147, 13, 28, 22, 70, 138, 52, 69, 151, 6, 28, 55, 69, 94, 217, 0, 70, 95, 4, 58, 12, 19, 32, 79, - 70, 152, 68, 104, 35, 0, 112, 3, 32, 40, 35, 55, 112, 32, 68, 107, 120, 27, 33, 0, 112, 99, 14, 43, 112, 163, 12, 43, - 112, 227, 14, 18, 10, 43, 70, 64, 113, 161, 114, 97, 113, 35, 113, 101, 113, 226, 114, 32, 70, 73, 123, 139, 154, 12, - 66, 147, 217, 168, 155, 6, 72, 46, 88, 26, 42, 0, 208, 163, 32, 79, 33, 10, 68, 104, 70, 67, 67, 83, 34, 0, 145, 1, - 146, 2, 144, 3, 146, 4, 72, 39, 153, 12, 70, 82, 148, 0, 247, 255, 252, 241, 40, 0, 221, 40, 33, 79, 68, 105, 120, 11, - 43, 0, 208, 0, 231, 139, 70, 65, 26, 115, 4, 27, 153, 6, 12, 30, 70, 75, 88, 90, 46, 0, 208, 4, 28, 19, 67, 123, 25, - 237, 68, 154, 231, 176, 40, 0, 218, 0, 231, 122, 155, 11, 152, 10, 154, 14, 24, 27, 147, 11, 35, 128, 50, 1, 0, 155, - 146, 14, 66, 154, 209, 130, 32, 1, 231, 110, 240, 2, 248, 97, 154, 15, 70, 131, 231, 141, 40, 0, 218, 218, 28, 130, - 209, 230, 154, 8, 35, 0, 112, 19, 70, 73, 35, 160, 88, 200, 40, 0, 208, 1, 240, 1, 248, 184, 33, 0, 34, 164, 70, 72, - 240, 2, 249, 85, 72, 6, 33, 0, 247, 253, 255, 201, 32, 0, 231, 80, 70, 192, 19, 112, 129, 85, 19, 112, 129, 84, 19, - 114, 73, 152, 19, 112, 128, 172, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 141, 144, 5, 32, 22, 70, 137, - 240, 1, 248, 164, 28, 4, 144, 11, 40, 0, 209, 0, 226, 13, 35, 0, 147, 0, 35, 18, 147, 1, 35, 128, 144, 2, 33, 128, 152, - 5, 34, 6, 0, 91, 247, 255, 249, 201, 144, 6, 40, 0, 219, 0, 224, 142, 152, 11, 240, 1, 248, 128, 70, 74, 70, 73, 124, - 137, 124, 215, 6, 11, 4, 58, 67, 26, 70, 75, 70, 140, 125, 30, 70, 73, 125, 76, 2, 51, 67, 19, 28, 33, 67, 25, 209, - 0, 225, 222, 70, 74, 124, 82, 70, 144, 42, 0, 209, 0, 225, 230, 35, 0, 70, 155, 70, 154, 70, 82, 24, 141, 122, 107, - 122, 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 208, 82, 121, 43, 43, 0, 208, 58, - 39, 0, 38, 0, 224, 10, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 25, - 132, 123, 163, 123, 226, 6, 27, 4, 18, 67, 26, 124, 35, 2, 27, 67, 19, 124, 98, 28, 16, 67, 24, 208, 1, 240, 1, 248, - 55, 122, 99, 122, 162, 6, 27, 4, 18, 67, 26, 122, 227, 2, 27, 67, 19, 123, 34, 28, 16, 67, 24, 208, 1, 240, 1, 248, - 41, 121, 43, 55, 1, 54, 18, 66, 159, 219, 210, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, - 42, 28, 16, 67, 24, 240, 1, 248, 23, 70, 74, 70, 75, 70, 73, 124, 137, 124, 91, 124, 215, 70, 152, 4, 58, 6, 11, 67, - 26, 70, 75, 70, 140, 125, 30, 70, 73, 125, 76, 2, 51, 67, 19, 28, 33, 67, 25, 34, 1, 35, 13, 68, 147, 68, 154, 69, 195, - 219, 0, 225, 123, 70, 97, 6, 11, 4, 58, 67, 26, 2, 51, 67, 19, 28, 33, 67, 25, 231, 142, 28, 33, 34, 18, 70, 72, 240, - 2, 248, 77, 28, 32, 240, 0, 255, 236, 70, 73, 120, 138, 120, 203, 2, 18, 67, 19, 4, 27, 10, 26, 14, 27, 67, 26, 4, 18, - 12, 19, 14, 18, 112, 138, 122, 10, 112, 203, 122, 75, 2, 18, 67, 19, 4, 27, 10, 26, 14, 27, 67, 26, 4, 18, 12, 19, 14, - 18, 114, 10, 122, 138, 114, 75, 122, 203, 2, 18, 67, 19, 4, 27, 10, 26, 14, 27, 67, 26, 4, 18, 12, 19, 14, 18, 114, - 138, 123, 10, 114, 203, 123, 75, 2, 18, 67, 19, 4, 27, 10, 26, 14, 27, 67, 26, 4, 18, 12, 19, 115, 75, 124, 75, 14, - 18, 0, 88, 24, 192, 0, 128, 115, 10, 24, 192, 240, 0, 255, 188, 70, 74, 14, 3, 116, 147, 12, 3, 116, 211, 10, 3, 117, - 19, 117, 80, 40, 0, 209, 0, 225, 47, 124, 83, 33, 0, 0, 90, 24, 210, 0, 146, 24, 210, 240, 2, 248, 63, 70, 73, 124, - 75, 43, 0, 209, 0, 225, 59, 34, 0, 146, 7, 146, 10, 32, 9, 240, 0, 255, 158, 28, 4, 40, 0, 209, 0, 225, 8, 153, 7, 34, - 2, 6, 11, 14, 29, 35, 9, 28, 33, 147, 0, 152, 5, 28, 43, 247, 255, 249, 71, 70, 75, 124, 154, 124, 219, 70, 73, 6, 18, - 4, 27, 67, 19, 125, 10, 2, 18, 67, 26, 125, 75, 28, 33, 67, 19, 154, 10, 24, 210, 70, 146, 28, 16, 34, 9, 240, 1, 255, - 205, 28, 32, 240, 0, 255, 108, 70, 83, 120, 154, 120, 219, 2, 18, 67, 19, 4, 27, 10, 26, 14, 27, 67, 26, 4, 18, 12, - 20, 70, 81, 14, 18, 112, 138, 112, 204, 28, 32, 240, 0, 255, 102, 144, 11, 40, 0, 209, 0, 224, 208, 70, 82, 120, 211, - 152, 5, 147, 0, 153, 11, 34, 2, 28, 43, 247, 255, 249, 17, 144, 6, 40, 0, 218, 0, 230, 197, 70, 83, 120, 29, 121, 27, - 0, 216, 24, 192, 0, 64, 240, 0, 255, 77, 70, 81, 14, 3, 114, 75, 12, 3, 114, 139, 10, 3, 114, 203, 115, 8, 40, 0, 209, - 0, 224, 192, 121, 11, 33, 0, 0, 218, 24, 210, 0, 82, 240, 1, 255, 209, 70, 82, 121, 19, 43, 0, 209, 0, 224, 138, 155, - 11, 33, 0, 25, 91, 27, 100, 70, 152, 70, 163, 145, 8, 145, 9, 70, 83, 122, 90, 122, 155, 70, 81, 6, 18, 4, 27, 67, 19, - 122, 202, 2, 18, 67, 26, 123, 11, 70, 65, 67, 19, 154, 9, 24, 157, 28, 40, 34, 9, 240, 1, 255, 109, 121, 43, 120, 44, - 0, 216, 26, 192, 240, 0, 255, 21, 14, 3, 115, 171, 12, 3, 115, 235, 10, 3, 116, 43, 116, 104, 40, 0, 209, 0, 224, 137, - 70, 91, 27, 27, 70, 155, 121, 43, 33, 0, 0, 218, 26, 210, 240, 1, 255, 152, 70, 89, 68, 160, 41, 0, 209, 0, 224, 120, - 70, 66, 120, 83, 59, 4, 6, 27, 14, 27, 43, 1, 216, 0, 224, 112, 70, 64, 70, 90, 224, 5, 120, 67, 59, 4, 6, 27, 14, 27, - 43, 1, 217, 98, 120, 3, 26, 210, 24, 192, 42, 0, 209, 244, 70, 65, 26, 68, 6, 35, 14, 27, 115, 107, 44, 0, 209, 98, - 121, 43, 43, 0, 208, 37, 39, 0, 38, 0, 123, 171, 123, 234, 6, 27, 4, 18, 67, 26, 124, 43, 124, 108, 2, 27, 67, 19, 67, - 28, 25, 164, 70, 65, 34, 7, 28, 32, 240, 1, 255, 29, 120, 35, 121, 34, 68, 152, 121, 99, 2, 18, 67, 19, 4, 27, 10, 26, - 14, 27, 67, 26, 4, 18, 12, 19, 14, 18, 113, 34, 113, 99, 121, 43, 55, 1, 54, 7, 66, 187, 216, 219, 155, 8, 153, 9, 51, - 1, 49, 18, 147, 8, 145, 9, 70, 82, 121, 19, 153, 8, 66, 139, 217, 0, 231, 124, 152, 11, 240, 0, 254, 156, 154, 7, 155, - 10, 50, 1, 51, 13, 146, 7, 147, 10, 70, 73, 124, 75, 66, 147, 217, 0, 230, 251, 34, 0, 146, 6, 152, 6, 176, 13, 188, - 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 34, 4, 66, 82, 146, 6, 230, 0, 28, 8, 240, 0, 254, - 126, 231, 237, 70, 67, 26, 196, 6, 35, 14, 27, 231, 160, 35, 0, 115, 107, 231, 160, 35, 4, 66, 91, 147, 6, 229, 237, - 28, 32, 240, 0, 254, 122, 14, 3, 114, 107, 12, 3, 114, 171, 10, 3, 114, 235, 115, 40, 40, 0, 208, 239, 70, 65, 28, 34, - 240, 1, 254, 191, 70, 90, 27, 18, 68, 160, 70, 147, 231, 135, 28, 32, 240, 0, 254, 89, 35, 0, 147, 6, 231, 198, 181, - 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 141, 70, 130, 32, 1, 28, 12, 240, 0, 254, 86, 144, 5, 40, 0, 209, - 0, 225, 239, 33, 0, 34, 164, 70, 80, 240, 1, 254, 227, 70, 81, 35, 1, 34, 152, 80, 139, 35, 144, 80, 204, 70, 105, 28, - 32, 49, 26, 247, 255, 253, 146, 28, 4, 40, 0, 218, 0, 225, 194, 75, 178, 104, 27, 43, 0, 208, 0, 224, 211, 72, 177, - 70, 105, 49, 26, 34, 22, 240, 1, 254, 133, 33, 43, 68, 105, 120, 15, 47, 0, 209, 0, 226, 30, 70, 108, 141, 163, 141, - 226, 33, 0, 4, 27, 28, 20, 67, 28, 70, 139, 70, 137, 38, 0, 70, 74, 24, 165, 121, 41, 41, 0, 208, 68, 35, 0, 70, 152, - 39, 0, 122, 106, 122, 171, 6, 18, 4, 27, 67, 19, 122, 234, 2, 18, 67, 26, 123, 43, 67, 19, 25, 220, 121, 99, 43, 8, - 209, 0, 224, 189, 123, 163, 123, 226, 6, 27, 4, 18, 67, 26, 124, 35, 2, 27, 67, 19, 124, 98, 28, 16, 67, 24, 208, 1, - 240, 0, 253, 242, 122, 99, 122, 162, 6, 27, 4, 18, 67, 26, 122, 227, 115, 166, 2, 27, 67, 19, 123, 34, 115, 230, 28, - 16, 116, 38, 116, 102, 67, 24, 208, 1, 240, 0, 253, 224, 114, 102, 114, 166, 114, 230, 115, 38, 121, 41, 36, 1, 68, - 160, 55, 18, 69, 65, 216, 198, 70, 106, 141, 147, 33, 43, 141, 210, 68, 105, 4, 27, 28, 20, 120, 15, 67, 28, 35, 1, - 33, 13, 68, 155, 68, 137, 69, 95, 216, 175, 44, 0, 209, 0, 225, 83, 47, 0, 209, 0, 225, 77, 34, 0, 70, 145, 70, 144, - 70, 67, 24, 229, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 208, 72, - 121, 43, 43, 0, 208, 58, 39, 0, 38, 0, 224, 10, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, - 42, 28, 16, 67, 24, 25, 132, 123, 163, 123, 226, 6, 27, 4, 18, 67, 26, 124, 35, 2, 27, 67, 19, 124, 98, 28, 16, 67, - 24, 208, 1, 240, 0, 253, 144, 122, 99, 122, 162, 6, 27, 4, 18, 67, 26, 122, 227, 2, 27, 67, 19, 123, 34, 28, 16, 67, - 24, 208, 1, 240, 0, 253, 130, 121, 43, 55, 1, 54, 18, 66, 159, 219, 210, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, - 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 240, 0, 253, 112, 70, 105, 36, 43, 141, 139, 141, 202, 68, 108, 120, 39, - 4, 27, 28, 20, 67, 28, 34, 1, 35, 13, 68, 145, 68, 152, 69, 185, 219, 0, 224, 236, 70, 108, 141, 163, 141, 226, 4, 27, - 28, 20, 67, 28, 231, 154, 33, 0, 72, 70, 224, 3, 49, 1, 41, 18, 209, 0, 231, 37, 36, 26, 68, 108, 92, 66, 92, 99, 66, - 154, 208, 245, 152, 5, 240, 0, 253, 73, 70, 104, 48, 26, 36, 1, 247, 254, 249, 96, 66, 100, 224, 225, 121, 162, 42, - 6, 208, 4, 42, 2, 208, 2, 42, 5, 208, 0, 231, 57, 121, 227, 43, 80, 208, 0, 231, 53, 121, 35, 43, 1, 216, 0, 231, 86, - 42, 6, 208, 3, 35, 1, 70, 81, 34, 156, 84, 139, 70, 81, 115, 78, 115, 14, 121, 34, 70, 148, 42, 0, 209, 0, 231, 71, - 32, 0, 33, 0, 224, 3, 48, 1, 49, 7, 69, 132, 217, 26, 123, 162, 123, 227, 6, 18, 4, 27, 67, 19, 124, 34, 2, 18, 67, - 26, 124, 99, 67, 19, 24, 90, 120, 211, 43, 2, 209, 237, 120, 146, 6, 19, 43, 0, 218, 0, 224, 145, 70, 83, 115, 90, 121, - 34, 48, 1, 70, 148, 49, 7, 69, 132, 216, 228, 70, 81, 123, 11, 43, 0, 209, 0, 231, 32, 70, 82, 123, 83, 43, 0, 209, - 0, 231, 27, 121, 107, 70, 81, 112, 11, 120, 163, 70, 106, 96, 75, 120, 227, 96, 139, 141, 147, 141, 210, 4, 27, 28, - 17, 67, 25, 209, 0, 224, 152, 35, 43, 68, 107, 120, 28, 44, 0, 209, 0, 224, 143, 34, 0, 70, 145, 70, 144, 70, 67, 24, - 205, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 208, 76, 121, 43, 43, - 0, 208, 62, 39, 0, 38, 0, 224, 14, 19, 112, 129, 80, 19, 114, 73, 128, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, - 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 25, 132, 123, 163, 123, 226, 6, 27, 4, 18, 67, 26, 124, 35, 2, 27, 67, - 19, 124, 98, 28, 16, 67, 24, 208, 1, 240, 0, 252, 174, 122, 99, 122, 162, 6, 27, 4, 18, 67, 26, 122, 227, 2, 27, 67, - 19, 123, 34, 28, 16, 67, 24, 208, 1, 240, 0, 252, 160, 121, 43, 55, 1, 54, 18, 66, 159, 219, 210, 122, 107, 122, 170, - 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 240, 0, 252, 142, 70, 106, 141, 147, 33, 43, - 141, 210, 68, 105, 120, 12, 4, 27, 28, 17, 67, 25, 35, 1, 34, 13, 68, 153, 68, 144, 69, 161, 218, 43, 70, 105, 141, - 139, 141, 202, 4, 27, 28, 17, 67, 25, 231, 151, 70, 83, 115, 26, 121, 34, 70, 148, 231, 81, 28, 32, 240, 0, 252, 112, - 76, 59, 152, 5, 240, 0, 252, 108, 35, 160, 70, 81, 88, 200, 40, 0, 208, 1, 240, 0, 252, 101, 70, 80, 33, 0, 34, 164, - 240, 1, 253, 2, 176, 13, 28, 32, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 36, 4, 66, 100, - 231, 242, 28, 8, 240, 0, 252, 80, 70, 82, 38, 144, 32, 1, 89, 148, 240, 0, 252, 86, 28, 5, 40, 0, 208, 61, 35, 0, 147, - 0, 35, 1, 147, 1, 144, 2, 33, 128, 28, 32, 34, 8, 35, 0, 247, 254, 253, 126, 40, 0, 219, 50, 28, 40, 120, 44, 240, 0, - 252, 54, 70, 83, 120, 25, 66, 161, 208, 5, 70, 84, 89, 160, 247, 254, 253, 228, 40, 0, 219, 34, 70, 81, 104, 138, 42, - 0, 208, 8, 35, 144, 6, 18, 88, 200, 14, 18, 121, 201, 247, 254, 253, 195, 40, 0, 219, 21, 70, 80, 247, 255, 248, 20, - 28, 4, 40, 0, 219, 169, 35, 16, 70, 82, 115, 147, 72, 15, 240, 0, 252, 31, 70, 84, 35, 160, 80, 224, 40, 0, 208, 18, - 152, 5, 240, 0, 252, 11, 36, 0, 231, 168, 76, 10, 231, 151, 28, 40, 240, 0, 252, 4, 76, 7, 231, 146, 70, 106, 141, 147, - 141, 210, 4, 27, 28, 20, 67, 28, 230, 51, 36, 4, 66, 100, 231, 136, 255, 255, 216, 240, 0, 0, 128, 16, 255, 255, 216, - 231, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 73, 98, 176, 141, 144, 6, 70, 136, 28, 8, 153, 6, 247, 255, - 253, 142, 40, 0, 218, 0, 224, 165, 70, 67, 123, 154, 146, 7, 42, 0, 209, 0, 224, 140, 73, 91, 35, 38, 38, 0, 68, 107, - 70, 139, 70, 154, 70, 177, 224, 6, 155, 7, 54, 1, 66, 158, 219, 0, 224, 127, 70, 65, 123, 138, 6, 51, 14, 29, 66, 149, - 210, 244, 73, 82, 70, 90, 96, 17, 72, 79, 28, 41, 247, 255, 249, 237, 28, 4, 40, 0, 219, 90, 75, 77, 70, 89, 96, 11, - 7, 107, 70, 82, 14, 31, 35, 18, 70, 73, 112, 19, 35, 36, 112, 87, 112, 145, 112, 209, 113, 19, 113, 81, 32, 36, 240, - 0, 251, 184, 28, 4, 40, 0, 208, 16, 70, 74, 70, 81, 35, 6, 145, 0, 147, 1, 146, 2, 146, 3, 146, 4, 72, 61, 28, 41, 28, - 34, 35, 36, 247, 254, 255, 155, 28, 32, 240, 0, 251, 152, 70, 81, 35, 37, 112, 79, 112, 11, 32, 8, 240, 0, 251, 157, - 28, 7, 40, 0, 208, 186, 35, 2, 70, 82, 147, 1, 70, 75, 146, 0, 147, 2, 147, 3, 147, 4, 72, 47, 28, 41, 28, 58, 35, 8, - 247, 254, 255, 128, 28, 4, 40, 0, 219, 22, 172, 11, 28, 32, 28, 57, 34, 4, 240, 1, 251, 213, 28, 43, 154, 11, 73, 39, - 51, 20, 0, 155, 80, 90, 28, 32, 29, 57, 34, 4, 240, 1, 251, 202, 29, 43, 154, 11, 73, 33, 0, 155, 80, 90, 36, 0, 28, - 56, 240, 0, 251, 99, 28, 162, 208, 48, 44, 0, 219, 139, 153, 6, 74, 30, 137, 11, 32, 0, 128, 19, 137, 75, 74, 29, 128, - 19, 74, 29, 35, 1, 112, 19, 75, 28, 70, 90, 112, 29, 75, 23, 96, 19, 224, 20, 75, 24, 34, 0, 112, 26, 35, 160, 70, 66, - 88, 208, 40, 0, 208, 1, 240, 0, 251, 68, 33, 0, 70, 64, 34, 164, 240, 1, 251, 225, 72, 19, 33, 0, 247, 253, 250, 85, - 32, 3, 66, 64, 176, 13, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 75, 9, 34, 0, 112, 26, - 70, 65, 35, 160, 88, 200, 40, 0, 209, 225, 231, 226, 70, 192, 19, 114, 73, 152, 19, 112, 128, 32, 0, 15, 66, 64, 19, - 112, 129, 86, 19, 112, 129, 88, 19, 112, 129, 85, 19, 112, 129, 84, 19, 112, 128, 172, 181, 240, 70, 95, 70, 86, 70, - 77, 70, 68, 180, 240, 74, 73, 176, 129, 104, 19, 70, 146, 43, 0, 208, 9, 32, 0, 176, 1, 188, 60, 70, 144, 70, 153, 70, - 162, 70, 171, 188, 240, 188, 2, 71, 8, 75, 66, 104, 29, 70, 153, 35, 84, 92, 235, 43, 0, 208, 121, 38, 0, 224, 53, 32, - 250, 0, 128, 247, 253, 253, 227, 70, 64, 247, 255, 254, 254, 40, 0, 208, 103, 25, 187, 0, 219, 24, 235, 70, 74, 111, - 92, 104, 19, 28, 32, 104, 155, 70, 155, 247, 254, 252, 189, 48, 1, 208, 68, 32, 250, 0, 128, 247, 253, 253, 205, 70, - 64, 247, 255, 254, 232, 40, 0, 208, 81, 25, 187, 0, 219, 24, 235, 111, 92, 70, 74, 104, 19, 28, 32, 104, 157, 247, 254, - 252, 168, 48, 1, 208, 58, 32, 250, 0, 128, 247, 253, 253, 184, 70, 75, 104, 29, 34, 84, 92, 171, 54, 1, 66, 179, 221, - 65, 0, 183, 25, 187, 0, 219, 28, 26, 24, 236, 50, 88, 111, 35, 25, 82, 70, 144, 43, 0, 208, 237, 28, 16, 247, 255, 254, - 193, 40, 0, 208, 42, 70, 74, 104, 19, 111, 100, 104, 155, 28, 32, 70, 155, 247, 254, 252, 131, 48, 1, 209, 175, 32, - 250, 0, 64, 247, 253, 253, 147, 28, 35, 51, 16, 0, 155, 74, 19, 68, 91, 96, 90, 231, 164, 32, 250, 0, 64, 247, 253, - 253, 136, 28, 35, 51, 16, 0, 155, 74, 14, 68, 91, 96, 90, 231, 175, 32, 250, 0, 64, 247, 253, 253, 125, 28, 35, 51, - 16, 0, 155, 74, 8, 24, 235, 96, 90, 231, 185, 35, 1, 70, 82, 96, 19, 74, 6, 35, 0, 96, 19, 231, 116, 32, 1, 66, 64, - 231, 114, 19, 112, 129, 80, 19, 112, 128, 28, 0, 0, 16, 1, 19, 112, 129, 76, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, - 180, 240, 75, 142, 176, 151, 120, 27, 144, 11, 146, 10, 43, 1, 208, 9, 32, 0, 176, 23, 188, 60, 70, 144, 70, 153, 70, - 162, 70, 171, 188, 240, 188, 2, 71, 8, 4, 11, 33, 0, 70, 138, 74, 133, 73, 134, 12, 27, 147, 14, 146, 9, 35, 0, 145, - 8, 224, 137, 74, 131, 35, 144, 88, 208, 70, 147, 40, 0, 209, 0, 224, 208, 75, 129, 105, 196, 104, 27, 28, 32, 104, 157, - 247, 254, 252, 30, 28, 67, 209, 0, 224, 188, 40, 0, 208, 0, 224, 195, 35, 160, 70, 89, 88, 200, 40, 0, 208, 1, 240, - 0, 250, 55, 35, 160, 70, 90, 33, 0, 80, 209, 35, 144, 88, 208, 247, 255, 254, 61, 40, 0, 208, 0, 224, 177, 155, 9, 34, - 0, 96, 26, 32, 100, 247, 253, 253, 22, 75, 111, 153, 8, 96, 11, 75, 111, 70, 89, 120, 27, 154, 14, 28, 30, 54, 4, 147, - 12, 0, 179, 88, 203, 32, 128, 70, 153, 70, 75, 67, 83, 2, 0, 146, 15, 66, 131, 217, 4, 70, 73, 240, 1, 249, 167, 154, - 14, 144, 15, 42, 0, 209, 0, 224, 181, 155, 10, 153, 12, 147, 13, 7, 75, 14, 27, 70, 108, 0, 182, 157, 11, 147, 16, 28, - 23, 52, 77, 150, 7, 154, 15, 28, 62, 66, 151, 217, 0, 28, 22, 4, 50, 12, 19, 33, 87, 70, 152, 68, 105, 35, 0, 112, 11, - 33, 42, 35, 67, 112, 33, 68, 107, 120, 27, 14, 18, 112, 99, 14, 43, 112, 163, 12, 43, 112, 227, 33, 0, 113, 226, 10, - 43, 70, 66, 113, 161, 114, 97, 113, 35, 113, 101, 114, 34, 70, 89, 123, 139, 154, 12, 66, 147, 216, 38, 33, 3, 66, 74, - 70, 146, 75, 71, 153, 8, 96, 11, 154, 9, 104, 19, 43, 0, 209, 2, 70, 83, 43, 0, 218, 117, 155, 17, 51, 1, 43, 15, 220, - 99, 147, 17, 43, 12, 221, 1, 34, 12, 146, 17, 153, 9, 104, 11, 43, 0, 208, 0, 231, 107, 70, 82, 50, 2, 208, 70, 75, - 58, 154, 8, 96, 19, 70, 83, 51, 2, 208, 222, 73, 53, 70, 139, 231, 142, 70, 75, 43, 0, 208, 213, 70, 65, 34, 10, 70, - 75, 67, 75, 146, 1, 33, 1, 34, 87, 145, 2, 68, 106, 33, 0, 146, 3, 145, 4, 72, 44, 153, 12, 154, 13, 148, 0, 247, 254, - 253, 157, 70, 130, 40, 0, 221, 63, 34, 87, 68, 106, 120, 19, 43, 0, 209, 55, 70, 65, 26, 123, 4, 27, 12, 31, 155, 7, - 70, 90, 88, 210, 70, 145, 47, 0, 208, 180, 70, 75, 67, 115, 153, 13, 25, 173, 24, 201, 145, 13, 231, 133, 32, 250, 0, - 64, 247, 253, 252, 112, 28, 35, 51, 16, 0, 155, 74, 29, 24, 235, 96, 90, 32, 100, 247, 253, 252, 103, 70, 82, 50, 2, - 209, 184, 155, 17, 43, 0, 221, 181, 73, 19, 28, 8, 70, 139, 33, 1, 247, 254, 252, 183, 70, 130, 40, 0, 219, 172, 75, - 16, 154, 8, 96, 19, 231, 64, 70, 81, 15, 203, 34, 1, 64, 83, 6, 27, 14, 24, 230, 246, 75, 14, 70, 154, 231, 131, 70, - 83, 43, 0, 218, 193, 231, 127, 32, 1, 230, 237, 34, 1, 66, 83, 70, 154, 231, 121, 19, 112, 129, 85, 19, 112, 129, 76, - 19, 112, 128, 32, 19, 114, 73, 152, 19, 112, 128, 28, 0, 15, 66, 64, 19, 112, 129, 84, 0, 0, 16, 1, 255, 255, 216, 234, - 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 75, 144, 176, 151, 120, 27, 144, 12, 146, 11, 43, 1, 208, 9, 32, - 0, 176, 23, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 74, 137, 4, 11, 33, 0, 70, 136, 146, - 10, 73, 135, 74, 136, 12, 27, 147, 14, 145, 8, 35, 0, 146, 7, 224, 141, 154, 8, 35, 144, 88, 208, 40, 0, 209, 0, 224, - 187, 75, 130, 105, 196, 104, 27, 28, 32, 104, 157, 247, 254, 250, 231, 28, 67, 209, 0, 224, 167, 40, 0, 208, 0, 224, - 174, 153, 8, 35, 160, 88, 200, 40, 0, 208, 2, 240, 0, 249, 0, 153, 8, 35, 160, 34, 0, 80, 202, 35, 144, 88, 200, 247, - 255, 253, 6, 40, 0, 208, 0, 224, 156, 154, 10, 96, 16, 32, 100, 247, 253, 251, 224, 35, 0, 70, 152, 153, 10, 104, 11, - 43, 0, 209, 89, 75, 110, 154, 7, 70, 65, 96, 19, 49, 2, 208, 116, 75, 108, 73, 104, 120, 27, 154, 14, 28, 30, 54, 4, - 147, 13, 0, 179, 88, 203, 32, 128, 70, 153, 70, 75, 67, 83, 2, 0, 146, 15, 66, 131, 217, 4, 70, 73, 240, 1, 248, 104, - 154, 14, 144, 15, 42, 0, 209, 0, 224, 167, 155, 11, 153, 13, 70, 155, 7, 75, 14, 27, 70, 108, 0, 182, 157, 12, 147, - 16, 28, 23, 52, 77, 150, 9, 154, 15, 28, 62, 66, 151, 217, 0, 28, 22, 4, 50, 12, 19, 33, 87, 70, 154, 68, 105, 35, 0, - 112, 11, 33, 40, 35, 67, 112, 33, 68, 107, 120, 27, 33, 0, 112, 99, 14, 43, 112, 163, 14, 18, 12, 43, 112, 227, 113, - 161, 113, 226, 114, 97, 10, 43, 70, 82, 73, 71, 113, 35, 113, 101, 114, 34, 123, 139, 154, 13, 66, 147, 216, 69, 35, - 3, 66, 89, 70, 136, 75, 69, 153, 7, 96, 11, 154, 10, 104, 19, 43, 0, 208, 115, 155, 17, 51, 1, 43, 15, 220, 34, 147, - 17, 43, 12, 221, 1, 35, 12, 147, 17, 153, 10, 104, 11, 43, 0, 208, 0, 231, 103, 70, 65, 49, 2, 209, 144, 154, 17, 42, - 0, 221, 141, 72, 52, 33, 1, 247, 254, 251, 196, 70, 128, 40, 0, 219, 1, 75, 54, 70, 152, 32, 10, 247, 253, 251, 96, - 231, 128, 154, 7, 96, 19, 155, 17, 51, 1, 43, 15, 221, 220, 70, 65, 15, 203, 34, 1, 64, 83, 6, 27, 14, 24, 231, 49, - 32, 250, 0, 64, 247, 253, 251, 78, 28, 35, 51, 16, 0, 155, 74, 42, 24, 235, 96, 90, 32, 100, 247, 253, 251, 69, 231, - 209, 70, 75, 43, 0, 208, 182, 34, 10, 70, 81, 146, 1, 34, 87, 70, 75, 67, 75, 68, 106, 33, 0, 145, 2, 146, 3, 145, 4, - 72, 25, 153, 13, 70, 90, 148, 0, 247, 254, 252, 64, 70, 128, 40, 0, 221, 7, 33, 87, 68, 105, 120, 11, 43, 0, 208, 5, - 74, 25, 70, 144, 231, 157, 70, 66, 42, 0, 219, 154, 70, 81, 26, 123, 4, 27, 12, 31, 74, 13, 155, 9, 88, 210, 70, 145, - 47, 0, 208, 144, 70, 75, 67, 115, 25, 173, 68, 155, 231, 99, 75, 11, 153, 7, 34, 1, 96, 11, 66, 83, 70, 152, 231, 139, - 70, 67, 43, 0, 219, 136, 32, 1, 230, 230, 70, 192, 19, 112, 129, 85, 19, 112, 129, 76, 19, 114, 73, 152, 19, 112, 128, - 32, 19, 112, 128, 28, 0, 15, 66, 64, 19, 112, 129, 84, 255, 255, 253, 102, 0, 0, 16, 1, 255, 255, 216, 234, 71, 112, - 70, 192, 181, 0, 75, 4, 176, 129, 28, 1, 104, 24, 247, 252, 254, 187, 176, 1, 188, 1, 71, 0, 19, 112, 129, 92, 181, - 0, 75, 9, 28, 1, 176, 129, 104, 24, 247, 252, 254, 167, 40, 0, 208, 2, 176, 1, 188, 2, 71, 8, 72, 4, 33, 0, 247, 252, - 254, 254, 32, 100, 247, 253, 250, 209, 231, 251, 19, 112, 129, 92, 19, 112, 128, 192, 181, 0, 176, 129, 247, 252, 254, - 150, 176, 1, 188, 1, 71, 0, 70, 192, 181, 0, 176, 129, 247, 252, 254, 142, 176, 1, 188, 1, 71, 0, 70, 192, 181, 0, 176, - 129, 247, 252, 254, 134, 176, 1, 188, 1, 71, 0, 70, 192, 181, 16, 28, 4, 247, 252, 254, 94, 28, 32, 188, 16, 188, 2, - 71, 8, 181, 16, 28, 4, 247, 252, 254, 86, 28, 32, 188, 16, 188, 2, 71, 8, 181, 16, 28, 4, 247, 252, 254, 78, 28, 32, - 188, 16, 188, 2, 71, 8, 181, 0, 33, 192, 176, 129, 72, 5, 2, 9, 247, 252, 254, 63, 75, 4, 176, 1, 96, 24, 32, 0, 188, - 2, 71, 8, 70, 192, 19, 112, 137, 128, 19, 112, 129, 92, 181, 112, 176, 132, 28, 13, 28, 6, 247, 255, 252, 126, 76, 14, - 28, 32, 247, 253, 251, 94, 75, 13, 28, 2, 96, 24, 40, 0, 209, 4, 32, 0, 176, 4, 188, 112, 188, 2, 71, 8, 104, 35, 72, - 9, 146, 0, 33, 0, 34, 0, 149, 1, 146, 2, 240, 0, 250, 227, 40, 0, 208, 239, 28, 49, 240, 0, 249, 32, 231, 236, 70, 192, - 19, 112, 129, 100, 19, 112, 129, 96, 19, 112, 52, 13, 181, 48, 28, 20, 28, 8, 176, 129, 28, 17, 28, 26, 28, 29, 247, - 255, 254, 41, 40, 0, 209, 4, 32, 1, 176, 1, 188, 48, 188, 2, 71, 8, 75, 4, 28, 40, 104, 27, 28, 25, 67, 97, 247, 252, - 254, 23, 32, 0, 231, 242, 70, 192, 19, 112, 129, 100, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 133, - 144, 1, 104, 6, 28, 21, 106, 112, 70, 152, 28, 10, 30, 131, 64, 218, 4, 19, 12, 27, 147, 2, 122, 50, 26, 128, 144, 3, - 106, 51, 104, 116, 59, 1, 64, 211, 70, 155, 58, 2, 28, 11, 64, 211, 70, 95, 64, 31, 155, 1, 8, 162, 104, 88, 155, 2, - 58, 1, 51, 128, 0, 91, 90, 195, 70, 153, 64, 17, 208, 0, 224, 114, 70, 170, 69, 160, 211, 53, 122, 49, 70, 69, 64, 205, - 106, 50, 25, 235, 66, 147, 216, 60, 70, 74, 42, 0, 208, 61, 154, 3, 106, 241, 70, 75, 64, 147, 24, 121, 24, 201, 107, - 52, 107, 176, 28, 42, 70, 83, 240, 0, 248, 183, 28, 4, 40, 0, 209, 32, 122, 51, 28, 42, 64, 154, 28, 19, 70, 66, 26, - 210, 25, 127, 70, 144, 68, 154, 69, 187, 210, 14, 42, 0, 208, 12, 155, 2, 39, 0, 51, 1, 4, 27, 12, 27, 147, 2, 155, - 1, 104, 90, 155, 2, 51, 128, 0, 91, 90, 211, 70, 153, 104, 116, 69, 160, 210, 201, 70, 66, 42, 0, 209, 31, 36, 0, 176, - 5, 28, 32, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 27, 213, 70, 74, 42, 0, 209, 193, 28, - 42, 64, 138, 70, 80, 33, 0, 240, 0, 255, 122, 122, 51, 28, 42, 64, 154, 28, 19, 70, 66, 26, 210, 70, 144, 68, 154, 25, - 127, 104, 116, 231, 164, 70, 75, 43, 0, 208, 55, 154, 3, 106, 241, 64, 147, 24, 121, 24, 201, 107, 52, 107, 176, 108, - 243, 34, 1, 240, 0, 248, 102, 28, 4, 40, 0, 209, 207, 108, 241, 70, 80, 70, 66, 240, 0, 255, 21, 231, 201, 0, 137, 70, - 138, 43, 0, 208, 71, 154, 3, 106, 241, 64, 147, 24, 121, 24, 201, 107, 52, 107, 176, 108, 243, 34, 1, 240, 0, 248, 78, - 28, 4, 40, 0, 209, 183, 104, 115, 70, 82, 26, 156, 69, 160, 210, 19, 108, 241, 28, 40, 68, 81, 70, 66, 240, 0, 254, - 247, 68, 69, 35, 0, 70, 170, 55, 1, 70, 152, 104, 116, 231, 105, 70, 80, 33, 0, 70, 66, 240, 0, 255, 47, 36, 0, 231, - 158, 108, 241, 28, 40, 68, 81, 28, 34, 240, 0, 254, 227, 70, 67, 27, 27, 25, 45, 55, 1, 70, 152, 70, 170, 69, 95, 216, - 0, 231, 136, 43, 0, 209, 0, 231, 133, 155, 2, 39, 0, 51, 1, 4, 27, 12, 27, 147, 2, 155, 1, 104, 116, 104, 90, 155, 2, - 51, 128, 0, 91, 90, 211, 70, 153, 231, 65, 26, 100, 69, 68, 217, 0, 70, 68, 28, 40, 28, 34, 33, 0, 240, 0, 255, 3, 70, - 67, 27, 27, 25, 45, 70, 152, 70, 170, 55, 1, 104, 116, 231, 48, 71, 32, 181, 240, 70, 87, 70, 70, 180, 192, 35, 72, - 90, 194, 122, 3, 176, 129, 65, 26, 70, 144, 143, 130, 28, 6, 70, 138, 42, 0, 208, 32, 37, 0, 39, 0, 224, 3, 53, 1, 68, - 71, 66, 170, 217, 25, 104, 51, 25, 91, 123, 27, 43, 0, 208, 246, 106, 241, 34, 1, 49, 1, 24, 121, 107, 176, 108, 243, - 107, 52, 240, 0, 248, 72, 108, 241, 70, 80, 34, 6, 240, 0, 254, 97, 40, 0, 208, 14, 143, 178, 53, 1, 68, 71, 66, 170, - 216, 229, 34, 0, 70, 146, 176, 1, 70, 80, 188, 12, 70, 144, 70, 154, 188, 240, 188, 2, 71, 8, 32, 12, 247, 252, 253, - 117, 70, 130, 40, 0, 208, 33, 70, 82, 96, 22, 96, 149, 35, 72, 90, 240, 247, 252, 253, 107, 70, 82, 28, 3, 96, 80, 40, - 0, 208, 11, 106, 241, 107, 176, 49, 1, 25, 201, 107, 52, 70, 66, 240, 0, 248, 24, 109, 51, 51, 1, 101, 51, 231, 217, - 72, 7, 73, 8, 247, 252, 253, 22, 70, 80, 247, 252, 253, 71, 35, 0, 70, 154, 231, 207, 72, 2, 73, 3, 247, 252, 253, 12, - 231, 202, 70, 192, 19, 112, 128, 224, 19, 112, 128, 236, 71, 32, 70, 192, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, - 180, 240, 176, 129, 70, 139, 153, 10, 70, 130, 32, 84, 70, 145, 28, 31, 70, 136, 247, 252, 253, 52, 28, 5, 47, 0, 209, - 85, 32, 128, 0, 128, 247, 252, 253, 45, 35, 128, 2, 27, 97, 43, 70, 66, 35, 15, 117, 43, 23, 211, 12, 91, 68, 67, 19, - 219, 67, 123, 97, 171, 75, 137, 96, 40, 97, 235, 155, 11, 28, 6, 98, 235, 153, 12, 41, 0, 208, 62, 33, 0, 28, 58, 240, - 0, 254, 92, 35, 87, 112, 51, 35, 66, 112, 115, 35, 70, 112, 179, 35, 83, 28, 60, 112, 243, 47, 0, 209, 0, 224, 232, - 35, 0, 51, 1, 6, 27, 8, 100, 14, 27, 44, 0, 209, 249, 59, 1, 6, 27, 14, 27, 70, 66, 114, 51, 14, 19, 113, 51, 12, 19, - 113, 115, 10, 19, 113, 179, 113, 242, 105, 170, 75, 115, 66, 154, 216, 0, 224, 215, 75, 114, 66, 154, 216, 0, 224, 213, - 75, 113, 66, 154, 216, 0, 224, 211, 75, 112, 66, 154, 216, 0, 224, 209, 75, 111, 66, 154, 216, 0, 224, 207, 34, 11, - 125, 43, 24, 211, 114, 115, 224, 7, 28, 56, 231, 169, 70, 72, 153, 11, 34, 1, 28, 51, 240, 0, 248, 221, 120, 51, 120, - 114, 6, 27, 4, 18, 67, 26, 120, 179, 2, 27, 67, 19, 120, 242, 67, 26, 75, 99, 66, 154, 208, 0, 224, 167, 75, 98, 104, - 27, 66, 92, 65, 92, 44, 0, 208, 24, 47, 0, 208, 0, 224, 116, 44, 0, 208, 19, 70, 65, 41, 0, 208, 16, 121, 50, 121, 115, - 6, 18, 4, 27, 67, 19, 121, 178, 2, 18, 67, 26, 121, 243, 67, 19, 69, 67, 208, 4, 72, 86, 73, 86, 247, 252, 252, 103, - 224, 112, 122, 51, 36, 1, 28, 39, 64, 159, 96, 111, 122, 51, 105, 41, 114, 43, 121, 51, 121, 114, 6, 27, 4, 18, 67, - 26, 121, 179, 121, 240, 2, 27, 67, 19, 67, 24, 96, 232, 240, 0, 252, 207, 28, 57, 67, 65, 97, 169, 122, 114, 125, 43, - 64, 148, 98, 106, 26, 210, 105, 235, 64, 209, 64, 211, 4, 27, 12, 27, 4, 58, 133, 107, 12, 18, 51, 128, 133, 41, 0, - 91, 30, 81, 24, 201, 66, 82, 64, 17, 35, 72, 82, 233, 70, 91, 99, 107, 141, 43, 70, 82, 99, 42, 8, 219, 122, 42, 98, - 44, 26, 228, 70, 73, 64, 212, 99, 169, 100, 44, 153, 12, 41, 0, 209, 58, 100, 105, 35, 72, 90, 233, 108, 40, 65, 17, - 56, 1, 240, 0, 252, 158, 104, 106, 4, 0, 28, 19, 12, 0, 59, 12, 135, 168, 66, 152, 217, 0, 135, 171, 28, 16, 247, 252, - 252, 84, 35, 0, 100, 232, 101, 43, 176, 1, 28, 40, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, - 8, 122, 51, 28, 58, 70, 156, 33, 0, 28, 75, 6, 27, 8, 82, 28, 8, 14, 25, 42, 0, 209, 248, 69, 96, 209, 0, 231, 124, - 72, 29, 73, 30, 247, 252, 251, 245, 28, 40, 247, 252, 252, 38, 28, 48, 247, 252, 252, 35, 37, 0, 231, 219, 30, 120, - 24, 192, 66, 123, 64, 24, 247, 252, 252, 39, 141, 42, 100, 104, 8, 210, 33, 255, 240, 0, 253, 105, 122, 42, 231, 183, - 35, 255, 231, 30, 72, 15, 73, 17, 247, 252, 251, 217, 231, 226, 34, 6, 231, 54, 34, 7, 231, 52, 34, 8, 231, 50, 34, - 9, 231, 48, 34, 10, 231, 46, 0, 4, 96, 144, 0, 63, 255, 255, 0, 127, 255, 255, 0, 255, 255, 255, 1, 255, 255, 255, 3, - 255, 255, 255, 87, 66, 70, 83, 19, 112, 129, 104, 19, 112, 128, 224, 19, 112, 129, 44, 19, 112, 129, 12, 19, 112, 129, - 0, 71, 80, 70, 192, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 177, 144, 14, 28, 24, 145, 13, 146, 12, - 147, 11, 247, 252, 251, 230, 28, 5, 33, 0, 152, 12, 34, 1, 28, 43, 156, 14, 240, 0, 251, 94, 40, 0, 208, 0, 226, 173, - 38, 223, 172, 32, 0, 118, 25, 169, 28, 32, 34, 64, 240, 0, 252, 215, 32, 1, 66, 64, 33, 0, 145, 17, 144, 16, 35, 227, - 120, 42, 0, 91, 24, 235, 120, 110, 120, 232, 70, 163, 70, 148, 120, 172, 73, 217, 147, 10, 34, 228, 75, 216, 0, 82, - 24, 105, 24, 170, 24, 235, 145, 9, 146, 8, 147, 7, 33, 235, 74, 213, 35, 236, 0, 73, 0, 91, 24, 105, 24, 170, 24, 235, - 145, 6, 146, 5, 147, 4, 70, 90, 122, 82, 70, 89, 122, 9, 70, 91, 70, 144, 70, 98, 70, 137, 122, 159, 122, 217, 6, 19, - 4, 50, 67, 26, 2, 35, 70, 138, 67, 19, 73, 201, 67, 3, 66, 139, 209, 0, 226, 159, 70, 91, 121, 25, 41, 0, 209, 0, 226, - 97, 70, 68, 4, 58, 2, 35, 67, 19, 70, 78, 70, 80, 67, 51, 6, 2, 67, 19, 70, 152, 41, 15, 208, 0, 226, 104, 28, 25, 152, - 12, 34, 1, 28, 43, 156, 14, 240, 0, 251, 1, 40, 0, 208, 0, 226, 80, 158, 7, 152, 9, 120, 50, 120, 3, 153, 10, 2, 27, - 6, 18, 67, 26, 156, 8, 120, 11, 152, 6, 67, 26, 120, 0, 120, 35, 153, 5, 144, 18, 4, 27, 67, 26, 120, 9, 70, 70, 75, - 175, 24, 183, 154, 4, 145, 19, 24, 235, 120, 18, 147, 15, 120, 28, 70, 146, 152, 12, 28, 57, 34, 1, 28, 43, 158, 14, - 70, 161, 240, 0, 250, 218, 40, 0, 208, 0, 226, 40, 120, 40, 120, 110, 120, 172, 6, 3, 4, 50, 67, 26, 70, 132, 2, 35, - 120, 232, 67, 19, 73, 159, 67, 3, 66, 139, 209, 0, 226, 91, 153, 19, 70, 82, 4, 19, 2, 10, 67, 19, 154, 18, 70, 73, - 67, 19, 6, 10, 28, 25, 67, 17, 209, 0, 226, 6, 70, 66, 24, 140, 152, 12, 28, 33, 34, 1, 28, 43, 158, 14, 240, 0, 250, - 178, 40, 0, 208, 0, 226, 0, 152, 9, 153, 8, 120, 2, 120, 11, 158, 10, 4, 27, 2, 18, 67, 26, 152, 7, 120, 51, 153, 6, - 67, 26, 120, 3, 120, 9, 6, 27, 67, 26, 24, 167, 155, 4, 154, 5, 156, 15, 145, 20, 120, 18, 120, 27, 120, 36, 70, 145, - 70, 154, 148, 21, 152, 12, 28, 57, 34, 1, 28, 43, 158, 14, 240, 0, 250, 141, 40, 0, 208, 0, 225, 219, 120, 40, 120, - 110, 120, 172, 6, 3, 4, 50, 67, 26, 70, 132, 2, 35, 120, 232, 67, 19, 73, 121, 67, 3, 66, 139, 209, 0, 226, 26, 70, - 82, 70, 73, 4, 19, 2, 10, 67, 19, 154, 20, 153, 21, 67, 19, 6, 10, 28, 25, 67, 17, 209, 0, 225, 185, 70, 66, 24, 140, - 152, 12, 28, 33, 34, 1, 28, 43, 158, 14, 240, 0, 250, 101, 40, 0, 208, 0, 225, 179, 152, 9, 153, 8, 120, 2, 120, 11, - 158, 10, 4, 27, 2, 18, 67, 26, 152, 7, 120, 51, 153, 6, 67, 26, 120, 3, 120, 9, 6, 27, 67, 26, 24, 167, 155, 4, 154, - 5, 156, 15, 145, 22, 120, 18, 120, 27, 120, 36, 70, 145, 70, 154, 148, 23, 152, 12, 28, 57, 34, 1, 28, 43, 158, 14, - 240, 0, 250, 64, 40, 0, 208, 0, 225, 142, 120, 40, 120, 110, 120, 172, 6, 3, 4, 50, 67, 26, 70, 132, 2, 35, 120, 232, - 67, 19, 73, 82, 67, 3, 66, 139, 209, 0, 225, 217, 70, 82, 70, 73, 4, 19, 2, 10, 67, 19, 154, 22, 153, 23, 67, 19, 6, - 10, 28, 25, 67, 17, 209, 0, 225, 108, 70, 66, 24, 140, 152, 12, 28, 33, 34, 1, 28, 43, 158, 14, 240, 0, 250, 24, 40, - 0, 208, 0, 225, 102, 152, 9, 153, 8, 120, 2, 120, 11, 158, 10, 4, 27, 2, 18, 67, 26, 152, 7, 120, 51, 153, 6, 67, 26, - 120, 3, 120, 9, 6, 27, 67, 26, 24, 167, 155, 4, 154, 5, 156, 15, 145, 24, 120, 18, 120, 27, 120, 36, 70, 145, 70, 154, - 148, 25, 152, 12, 28, 57, 34, 1, 28, 43, 158, 14, 240, 0, 249, 243, 40, 0, 208, 0, 225, 65, 120, 40, 120, 110, 120, - 172, 6, 3, 4, 50, 67, 26, 70, 132, 2, 35, 120, 232, 67, 19, 73, 44, 67, 3, 66, 139, 209, 0, 225, 152, 70, 82, 70, 73, - 4, 19, 2, 10, 67, 19, 154, 24, 153, 25, 67, 19, 6, 10, 28, 25, 67, 17, 209, 0, 225, 31, 70, 66, 24, 140, 152, 12, 28, - 33, 34, 1, 28, 43, 158, 14, 240, 0, 249, 203, 40, 0, 208, 0, 225, 25, 152, 9, 153, 8, 120, 2, 120, 11, 158, 10, 4, 27, - 2, 18, 67, 26, 152, 7, 120, 51, 153, 6, 67, 26, 120, 3, 120, 9, 6, 27, 67, 26, 24, 167, 155, 4, 154, 5, 156, 15, 145, - 26, 120, 18, 120, 27, 120, 36, 70, 145, 70, 154, 148, 27, 152, 12, 28, 57, 34, 1, 28, 43, 158, 14, 240, 0, 249, 166, - 40, 0, 208, 0, 224, 244, 120, 40, 120, 110, 120, 172, 6, 3, 4, 50, 67, 26, 70, 132, 2, 35, 120, 232, 67, 19, 73, 5, - 67, 3, 66, 139, 209, 0, 225, 27, 224, 9, 0, 0, 1, 199, 0, 0, 1, 201, 0, 0, 1, 215, 87, 66, 70, 83, 0, 0, 1, 217, 70, - 82, 70, 73, 4, 19, 2, 10, 67, 19, 154, 26, 153, 27, 67, 19, 6, 10, 28, 25, 67, 17, 209, 0, 224, 199, 70, 66, 24, 140, - 152, 12, 28, 33, 34, 1, 28, 43, 158, 14, 240, 0, 249, 115, 40, 0, 208, 0, 224, 193, 152, 9, 153, 8, 120, 2, 120, 11, - 158, 10, 4, 27, 2, 18, 67, 26, 152, 7, 120, 51, 153, 6, 67, 26, 120, 3, 120, 9, 6, 27, 67, 26, 24, 167, 155, 4, 154, - 5, 156, 15, 145, 28, 120, 18, 120, 27, 120, 36, 70, 145, 70, 154, 148, 29, 152, 12, 28, 57, 34, 1, 28, 43, 158, 14, - 240, 0, 249, 78, 40, 0, 208, 0, 224, 156, 120, 40, 120, 110, 120, 172, 6, 3, 4, 50, 67, 26, 70, 132, 2, 35, 120, 232, - 67, 19, 73, 158, 67, 3, 66, 139, 209, 0, 224, 255, 70, 82, 70, 73, 4, 19, 2, 10, 67, 19, 154, 28, 153, 29, 67, 19, 6, - 10, 28, 25, 67, 17, 208, 123, 70, 66, 24, 140, 152, 12, 28, 33, 34, 1, 28, 43, 158, 14, 240, 0, 249, 39, 40, 0, 209, - 118, 152, 9, 153, 8, 120, 2, 120, 11, 158, 10, 4, 27, 2, 18, 67, 26, 152, 7, 120, 51, 153, 6, 67, 26, 120, 3, 120, 9, - 6, 27, 67, 26, 24, 167, 155, 4, 154, 5, 156, 15, 145, 30, 120, 18, 120, 27, 120, 36, 70, 145, 70, 154, 148, 31, 152, - 12, 28, 57, 34, 1, 28, 43, 158, 14, 240, 0, 249, 3, 40, 0, 209, 82, 120, 40, 120, 110, 120, 172, 6, 3, 4, 50, 67, 26, - 70, 132, 2, 35, 120, 232, 67, 19, 73, 121, 67, 3, 66, 139, 209, 0, 224, 193, 70, 82, 70, 73, 4, 19, 2, 10, 67, 19, 154, - 30, 153, 31, 67, 19, 6, 10, 28, 25, 67, 17, 208, 49, 70, 66, 24, 84, 152, 12, 28, 33, 34, 1, 28, 43, 158, 14, 240, 0, - 248, 221, 40, 0, 209, 44, 152, 9, 153, 8, 120, 2, 120, 11, 158, 10, 4, 27, 2, 18, 67, 26, 152, 7, 120, 51, 67, 26, 120, - 3, 152, 12, 6, 27, 67, 26, 24, 167, 28, 57, 34, 1, 28, 43, 156, 14, 240, 0, 248, 196, 40, 0, 209, 20, 120, 46, 120, - 172, 6, 51, 70, 180, 120, 110, 120, 232, 4, 50, 67, 26, 2, 35, 67, 19, 73, 90, 67, 3, 66, 139, 209, 0, 224, 143, 171, - 44, 69, 155, 208, 2, 33, 16, 68, 139, 229, 125, 28, 40, 247, 252, 249, 30, 36, 0, 176, 49, 28, 32, 188, 60, 70, 144, - 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 28, 25, 152, 12, 34, 1, 28, 43, 156, 14, 240, 0, 248, 152, 28, 1, - 40, 0, 209, 231, 120, 46, 120, 172, 6, 51, 70, 180, 120, 110, 120, 232, 4, 50, 67, 26, 2, 35, 67, 19, 74, 68, 67, 3, - 66, 147, 209, 211, 155, 17, 154, 59, 66, 147, 208, 124, 153, 16, 69, 136, 208, 204, 154, 17, 70, 67, 50, 1, 146, 17, - 147, 16, 231, 198, 70, 90, 121, 17, 229, 97, 154, 59, 155, 17, 66, 154, 208, 92, 153, 16, 66, 185, 209, 0, 230, 230, - 51, 1, 147, 17, 151, 16, 230, 226, 154, 59, 155, 17, 66, 154, 208, 80, 153, 16, 66, 185, 209, 0, 229, 155, 51, 1, 147, - 17, 151, 16, 229, 151, 154, 59, 155, 17, 66, 154, 208, 68, 153, 16, 66, 185, 209, 0, 229, 220, 51, 1, 147, 17, 151, - 16, 229, 216, 154, 59, 155, 17, 66, 154, 208, 56, 153, 16, 66, 185, 209, 0, 230, 29, 51, 1, 147, 17, 151, 16, 230, 25, - 154, 59, 155, 17, 66, 154, 208, 44, 153, 16, 66, 185, 209, 0, 230, 94, 51, 1, 147, 17, 151, 16, 230, 90, 154, 59, 155, - 17, 66, 154, 208, 32, 153, 16, 66, 185, 209, 0, 230, 247, 51, 1, 147, 17, 151, 16, 230, 243, 154, 59, 155, 17, 66, 154, - 208, 20, 153, 16, 66, 185, 209, 0, 231, 53, 51, 1, 147, 17, 151, 16, 231, 49, 154, 59, 155, 17, 66, 154, 208, 8, 153, - 16, 66, 143, 209, 0, 231, 103, 154, 17, 151, 16, 50, 1, 146, 17, 231, 98, 35, 0, 147, 0, 151, 1, 156, 60, 152, 14, 153, - 13, 154, 12, 155, 11, 148, 2, 247, 255, 251, 71, 28, 4, 28, 40, 247, 252, 248, 123, 231, 92, 70, 67, 145, 0, 147, 1, - 231, 238, 87, 66, 70, 83, 71, 32, 71, 48, 230, 0, 0, 16, 225, 47, 255, 30, 230, 0, 0, 48, 225, 47, 255, 30, 230, 0, - 0, 80, 225, 47, 255, 30, 230, 0, 0, 112, 225, 47, 255, 30, 230, 0, 0, 144, 225, 47, 255, 30, 230, 0, 0, 176, 225, 47, - 255, 30, 230, 0, 0, 208, 225, 47, 255, 30, 230, 0, 0, 240, 225, 47, 255, 30, 230, 0, 1, 16, 225, 47, 255, 30, 230, 0, - 1, 48, 225, 47, 255, 30, 230, 0, 1, 80, 225, 47, 255, 30, 230, 0, 1, 112, 225, 47, 255, 30, 230, 0, 1, 144, 225, 47, - 255, 30, 230, 0, 1, 176, 225, 47, 255, 30, 230, 0, 1, 208, 225, 47, 255, 30, 230, 0, 1, 240, 225, 47, 255, 30, 230, - 0, 2, 16, 225, 47, 255, 30, 230, 0, 2, 48, 225, 47, 255, 30, 230, 0, 2, 80, 225, 47, 255, 30, 230, 0, 2, 112, 225, 47, - 255, 30, 230, 0, 2, 144, 225, 47, 255, 30, 230, 0, 2, 176, 225, 47, 255, 30, 230, 0, 2, 208, 225, 47, 255, 30, 230, - 0, 2, 240, 225, 47, 255, 30, 230, 0, 3, 16, 225, 47, 255, 30, 230, 0, 3, 48, 225, 47, 255, 30, 230, 0, 3, 80, 225, 47, - 255, 30, 230, 0, 3, 112, 225, 47, 255, 30, 230, 0, 3, 144, 225, 47, 255, 30, 230, 0, 3, 176, 225, 47, 255, 30, 230, - 0, 3, 208, 225, 47, 255, 30, 230, 0, 3, 240, 225, 47, 255, 30, 230, 0, 4, 16, 225, 47, 255, 30, 230, 0, 4, 48, 225, - 47, 255, 30, 230, 0, 4, 80, 225, 47, 255, 30, 230, 0, 4, 112, 225, 47, 255, 30, 230, 0, 4, 144, 225, 47, 255, 30, 230, - 0, 4, 176, 225, 47, 255, 30, 230, 0, 4, 208, 225, 47, 255, 30, 230, 0, 4, 240, 225, 47, 255, 30, 230, 0, 5, 16, 225, - 47, 255, 30, 230, 0, 5, 48, 225, 47, 255, 30, 230, 0, 5, 80, 225, 47, 255, 30, 230, 0, 6, 144, 225, 47, 255, 30, 230, - 0, 7, 240, 225, 47, 255, 30, 230, 0, 8, 16, 225, 47, 255, 30, 230, 0, 10, 16, 225, 47, 255, 30, 41, 0, 208, 52, 35, - 1, 34, 0, 180, 16, 66, 136, 211, 44, 36, 1, 7, 36, 66, 161, 210, 4, 66, 129, 210, 2, 1, 9, 1, 27, 231, 248, 0, 228, - 66, 161, 210, 4, 66, 129, 210, 2, 0, 73, 0, 91, 231, 248, 66, 136, 211, 1, 26, 64, 67, 26, 8, 76, 66, 160, 211, 2, 27, - 0, 8, 92, 67, 34, 8, 140, 66, 160, 211, 2, 27, 0, 8, 156, 67, 34, 8, 204, 66, 160, 211, 2, 27, 0, 8, 220, 67, 34, 40, - 0, 208, 3, 9, 27, 208, 1, 9, 9, 231, 227, 28, 16, 188, 16, 71, 112, 181, 2, 240, 0, 248, 94, 32, 0, 188, 6, 71, 16, - 70, 192, 181, 3, 247, 255, 255, 191, 188, 14, 67, 66, 26, 137, 71, 24, 70, 192, 41, 0, 208, 65, 180, 16, 28, 4, 64, - 76, 70, 164, 35, 1, 34, 0, 41, 0, 213, 0, 66, 73, 40, 0, 213, 0, 66, 64, 66, 136, 211, 44, 36, 1, 7, 36, 66, 161, 210, - 4, 66, 129, 210, 2, 1, 9, 1, 27, 231, 248, 0, 228, 66, 161, 210, 4, 66, 129, 210, 2, 0, 73, 0, 91, 231, 248, 66, 136, - 211, 1, 26, 64, 67, 26, 8, 76, 66, 160, 211, 2, 27, 0, 8, 92, 67, 34, 8, 140, 66, 160, 211, 2, 27, 0, 8, 156, 67, 34, - 8, 204, 66, 160, 211, 2, 27, 0, 8, 220, 67, 34, 40, 0, 208, 3, 9, 27, 208, 1, 9, 9, 231, 227, 28, 16, 70, 100, 44, 0, - 213, 0, 66, 64, 188, 16, 71, 112, 181, 2, 240, 0, 248, 11, 32, 0, 188, 6, 71, 16, 181, 3, 247, 255, 255, 179, 188, 14, - 67, 66, 26, 137, 71, 24, 70, 192, 71, 112, 70, 192, 181, 112, 28, 14, 28, 21, 28, 4, 42, 3, 217, 32, 28, 51, 67, 3, - 7, 154, 208, 18, 120, 35, 120, 8, 66, 131, 209, 27, 30, 106, 224, 6, 52, 1, 49, 1, 120, 35, 120, 8, 58, 1, 66, 131, - 209, 18, 42, 0, 209, 246, 32, 0, 188, 112, 188, 2, 71, 8, 104, 2, 104, 11, 66, 154, 209, 4, 61, 4, 48, 4, 49, 4, 45, - 3, 216, 246, 28, 4, 45, 0, 209, 224, 231, 238, 26, 24, 231, 237, 181, 240, 28, 7, 28, 14, 28, 4, 28, 21, 28, 8, 28, - 17, 42, 15, 217, 3, 28, 51, 67, 59, 7, 154, 208, 11, 41, 0, 208, 5, 34, 0, 92, 131, 84, 163, 50, 1, 66, 138, 209, 250, - 28, 56, 188, 240, 188, 2, 71, 8, 28, 58, 28, 49, 28, 40, 104, 11, 96, 19, 104, 75, 96, 83, 104, 139, 96, 147, 104, 203, - 56, 16, 96, 211, 49, 16, 50, 16, 40, 15, 216, 242, 28, 43, 59, 16, 9, 26, 1, 17, 50, 1, 1, 18, 26, 89, 24, 176, 24, - 188, 41, 3, 217, 216, 34, 0, 88, 131, 80, 163, 50, 4, 26, 139, 43, 3, 216, 249, 31, 11, 8, 154, 0, 145, 50, 1, 0, 146, - 26, 89, 24, 128, 24, 164, 231, 200, 181, 240, 28, 7, 70, 140, 28, 16, 28, 57, 7, 186, 208, 14, 40, 0, 208, 73, 70, 98, - 6, 19, 56, 1, 14, 27, 34, 3, 224, 2, 40, 0, 208, 65, 56, 1, 112, 11, 49, 1, 66, 17, 209, 248, 28, 5, 28, 10, 40, 3, - 217, 46, 35, 255, 70, 98, 64, 26, 2, 19, 67, 19, 4, 26, 28, 20, 28, 14, 67, 28, 40, 15, 217, 18, 28, 2, 28, 11, 58, - 16, 96, 28, 96, 92, 96, 156, 96, 220, 51, 16, 42, 15, 216, 247, 28, 3, 59, 16, 28, 29, 9, 27, 51, 1, 34, 15, 1, 27, - 64, 21, 24, 206, 45, 3, 217, 13, 34, 0, 80, 180, 50, 4, 26, 171, 43, 3, 216, 250, 31, 43, 28, 29, 8, 155, 51, 1, 34, - 3, 0, 155, 64, 21, 24, 246, 28, 50, 45, 0, 208, 7, 70, 97, 6, 11, 14, 25, 35, 0, 84, 209, 51, 1, 66, 157, 209, 251, - 28, 56, 188, 240, 188, 2, 71, 8, 70, 192, 181, 48, 28, 11, 67, 3, 7, 154, 209, 28, 104, 2, 104, 11, 66, 154, 209, 24, - 76, 16, 25, 19, 67, 147, 74, 15, 66, 19, 209, 11, 28, 20, 48, 4, 49, 4, 104, 2, 104, 11, 66, 154, 209, 11, 77, 9, 25, - 83, 67, 147, 66, 35, 208, 244, 32, 0, 224, 9, 120, 10, 66, 154, 209, 5, 48, 1, 49, 1, 120, 3, 43, 0, 209, 247, 120, - 10, 26, 152, 188, 48, 188, 2, 71, 8, 254, 254, 254, 255, 128, 128, 128, 128, 181, 48, 28, 4, 7, 129, 208, 10, 120, 3, - 43, 0, 208, 33, 34, 3, 224, 2, 120, 3, 43, 0, 208, 24, 48, 1, 66, 16, 209, 249, 104, 2, 77, 13, 25, 83, 67, 147, 74, - 13, 66, 19, 209, 11, 28, 17, 48, 4, 104, 2, 77, 9, 25, 83, 67, 147, 66, 11, 208, 248, 120, 3, 43, 0, 208, 3, 48, 1, - 120, 3, 43, 0, 209, 251, 27, 0, 188, 48, 188, 2, 71, 8, 32, 0, 231, 250, 70, 192, 254, 254, 254, 255, 128, 128, 128, - 128, 73, 79, 83, 32, 109, 111, 100, 117, 108, 101, 0, 0, 0, 0, 0, 1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 19, 114, 74, 60, 0, 15, 66, 64, 47, 100, 101, 118, 47, 102, 97, 116, 47, 108, 111, 103, 0, 0, 0, 0, 87, 66, - 70, 83, 32, 110, 111, 116, 32, 101, 110, 111, 117, 103, 104, 32, 109, 101, 109, 111, 114, 121, 33, 0, 101, 104, 99, - 32, 108, 111, 111, 112, 32, 101, 110, 116, 114, 121, 0, 0, 47, 100, 101, 118, 47, 117, 115, 98, 47, 101, 104, 99, 0, - 0, 0, 0, 47, 100, 101, 118, 47, 117, 115, 98, 47, 101, 104, 99, 47, 0, 0, 0, 85, 77, 83, 32, 73, 110, 105, 116, 0, 0, - 0, 0, 87, 66, 70, 83, 32, 79, 112, 101, 110, 40, 41, 0, 85, 77, 83, 32, 102, 97, 105, 108, 0, 0, 0, 0, 47, 100, 101, - 118, 47, 109, 108, 111, 97, 100, 0, 0, 85, 83, 66, 83, 116, 111, 114, 97, 103, 101, 95, 67, 108, 111, 115, 101, 40, - 41, 0, 0, 85, 83, 66, 32, 65, 108, 108, 111, 99, 58, 32, 110, 111, 116, 32, 101, 110, 111, 117, 103, 104, 32, 109, 101, - 109, 111, 114, 121, 33, 0, 0, 0, 119, 98, 102, 115, 32, 101, 114, 114, 111, 114, 0, 0, 97, 108, 108, 111, 99, 97, 116, - 105, 110, 103, 32, 109, 101, 109, 111, 114, 121, 0, 0, 0, 98, 97, 100, 32, 109, 97, 103, 105, 99, 0, 0, 0, 104, 100, - 32, 115, 101, 99, 116, 111, 114, 32, 115, 105, 122, 101, 32, 100, 111, 101, 115, 110, 39, 116, 32, 109, 97, 116, 99, - 104, 0, 0, 0, 0, 104, 100, 32, 110, 117, 109, 32, 115, 101, 99, 116, 111, 114, 32, 100, 111, 101, 115, 110, 39, 116, - 32, 109, 97, 116, 99, 104, 0 + 127, 69, 76, 70, 1, 2, 1, 97, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 40, 0, 0, 0, 1, 19, 112, 0, 0, 0, 0, 0, 52, 0, 0, 0, + 0, 0, 0, 6, 6, 0, 52, 0, 32, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, + 0, 0, 0, 160, 0, 240, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 212, 0, 0, 0, 160, 0, 0, 0, 160, 0, 0, 0, 52, 0, 0, 0, + 52, 0, 240, 0, 0, 0, 0, 0, 4, 0, 0, 0, 1, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 212, 0, 0, 0, 212, 0, 240, 0, + 0, 0, 0, 64, 0, 0, 0, 0, 1, 0, 0, 1, 8, 19, 112, 0, 0, 19, 112, 0, 0, 0, 0, 69, 156, 0, 0, 69, 156, 0, 0, 0, 5, 0, 0, + 0, 4, 0, 0, 0, 1, 0, 0, 70, 164, 19, 112, 128, 0, 19, 112, 128, 0, 0, 0, 1, 72, 0, 2, 11, 56, 0, 0, 0, 6, 0, 0, 0, 4, + 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 6, 0, 0, 0, 11, 0, 0, 0, 4, 0, 0, 0, 9, 19, 112, 0, 0, 0, 0, 0, 125, 0, 0, 0, 72, + 0, 0, 0, 126, 0, 0, 64, 0, 0, 0, 0, 127, 19, 114, 139, 56, 227, 160, 0, 0, 227, 160, 16, 0, 229, 159, 48, 0, 225, 47, + 255, 19, 19, 112, 8, 13, 225, 160, 0, 0, 225, 160, 0, 0, 225, 160, 0, 0, 70, 192, 71, 120, 234, 0, 16, 74, 70, 192, + 71, 120, 234, 0, 16, 118, 70, 192, 71, 120, 234, 0, 16, 94, 70, 192, 71, 120, 234, 0, 16, 78, 70, 192, 71, 120, 234, + 0, 16, 106, 70, 192, 71, 120, 234, 0, 16, 58, 70, 192, 71, 120, 234, 0, 16, 38, 70, 192, 71, 120, 234, 0, 16, 78, 70, + 192, 71, 120, 234, 0, 16, 62, 70, 192, 71, 120, 234, 0, 16, 100, 70, 192, 71, 120, 234, 0, 16, 62, 70, 192, 71, 120, + 234, 0, 16, 66, 70, 192, 71, 120, 234, 0, 16, 62, 70, 192, 71, 120, 234, 0, 16, 28, 70, 192, 71, 120, 234, 0, 16, 38, + 70, 192, 71, 120, 234, 0, 16, 34, 70, 192, 71, 120, 234, 0, 16, 26, 181, 240, 28, 15, 120, 1, 28, 6, 28, 10, 58, 48, + 6, 19, 14, 27, 36, 0, 28, 69, 43, 9, 216, 11, 1, 35, 28, 28, 67, 20, 28, 40, 120, 1, 28, 69, 28, 10, 58, 48, 6, 19, + 14, 27, 43, 9, 217, 243, 28, 11, 59, 97, 6, 27, 14, 27, 43, 5, 216, 6, 1, 34, 28, 11, 59, 87, 28, 20, 67, 28, 28, 40, + 231, 234, 28, 11, 59, 65, 6, 27, 14, 27, 43, 5, 217, 6, 28, 115, 66, 157, 208, 10, 96, 60, 188, 240, 188, 2, 71, 8, + 1, 34, 28, 11, 59, 55, 28, 20, 67, 28, 28, 40, 231, 214, 32, 0, 231, 243, 70, 192, 181, 240, 70, 71, 180, 128, 28, 13, + 28, 6, 240, 4, 250, 7, 70, 128, 70, 65, 28, 48, 247, 255, 255, 120, 45, 0, 208, 33, 28, 40, 240, 4, 249, 253, 28, 7, + 28, 57, 28, 40, 247, 255, 255, 110, 72, 13, 33, 1, 247, 255, 255, 150, 28, 4, 40, 0, 219, 13, 28, 49, 70, 66, 247, 255, + 255, 123, 45, 0, 208, 4, 28, 32, 28, 41, 28, 58, 247, 255, 255, 116, 28, 32, 247, 255, 255, 129, 188, 4, 70, 144, 188, + 240, 188, 1, 71, 0, 39, 0, 231, 227, 19, 112, 128, 36, 181, 0, 75, 4, 176, 129, 28, 1, 104, 24, 247, 255, 255, 109, + 176, 1, 188, 1, 71, 0, 19, 112, 128, 24, 181, 0, 75, 9, 28, 1, 176, 129, 104, 24, 247, 255, 255, 89, 40, 0, 208, 2, + 176, 1, 188, 2, 71, 8, 72, 4, 33, 0, 247, 255, 255, 176, 32, 100, 240, 0, 251, 131, 231, 251, 19, 112, 128, 24, 19, + 112, 128, 52, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 149, 72, 198, 33, 0, 247, 255, 255, 157, 75, + 197, 33, 64, 104, 24, 247, 255, 255, 56, 33, 16, 247, 255, 255, 45, 70, 129, 72, 193, 70, 73, 144, 6, 247, 255, 255, + 27, 72, 192, 70, 74, 75, 192, 28, 1, 247, 255, 255, 69, 75, 191, 76, 191, 70, 130, 72, 191, 34, 0, 146, 13, 146, 14, + 146, 15, 146, 16, 146, 17, 147, 5, 148, 4, 144, 11, 74, 187, 75, 188, 76, 188, 72, 189, 146, 10, 147, 9, 148, 8, 144, + 7, 34, 0, 169, 19, 70, 72, 247, 255, 255, 47, 70, 80, 247, 255, 255, 0, 156, 19, 74, 183, 66, 148, 208, 243, 75, 173, + 66, 156, 209, 0, 224, 230, 120, 35, 120, 98, 6, 27, 4, 18, 67, 26, 120, 163, 2, 27, 67, 19, 120, 226, 67, 26, 42, 2, + 209, 0, 224, 198, 42, 2, 216, 17, 42, 1, 209, 0, 224, 154, 39, 1, 66, 127, 38, 1, 154, 5, 104, 19, 43, 0, 208, 0, 224, + 141, 46, 0, 208, 211, 152, 19, 28, 57, 247, 255, 254, 212, 231, 206, 42, 6, 209, 0, 224, 172, 42, 7, 209, 235, 126, + 35, 126, 98, 6, 27, 4, 18, 67, 26, 126, 163, 2, 27, 67, 19, 126, 226, 67, 26, 70, 147, 124, 35, 124, 98, 6, 27, 4, 18, + 67, 26, 124, 163, 2, 27, 67, 19, 124, 226, 67, 26, 146, 12, 125, 35, 125, 98, 6, 27, 4, 18, 67, 26, 125, 163, 2, 27, + 67, 19, 125, 226, 28, 21, 67, 29, 123, 35, 43, 0, 208, 0, 224, 196, 154, 15, 42, 0, 208, 0, 224, 192, 122, 35, 122, + 98, 6, 27, 4, 18, 67, 26, 122, 163, 122, 224, 2, 27, 67, 19, 67, 24, 240, 0, 251, 73, 28, 6, 155, 12, 70, 88, 25, 91, + 70, 152, 0, 217, 70, 68, 247, 255, 254, 164, 44, 0, 221, 9, 70, 92, 37, 0, 104, 32, 104, 97, 53, 1, 247, 255, 254, 155, + 52, 8, 69, 168, 220, 247, 153, 19, 72, 124, 123, 11, 123, 74, 6, 27, 4, 18, 67, 26, 123, 139, 2, 27, 67, 19, 123, 202, + 67, 26, 66, 130, 209, 0, 225, 172, 66, 130, 217, 0, 224, 157, 42, 6, 217, 0, 224, 187, 42, 5, 211, 0, 225, 41, 42, 1, + 209, 0, 225, 207, 42, 0, 209, 0, 225, 117, 42, 2, 209, 0, 225, 32, 39, 1, 38, 1, 154, 12, 69, 66, 219, 0, 231, 125, + 0, 211, 70, 88, 24, 196, 28, 21, 104, 32, 104, 97, 53, 1, 247, 255, 254, 72, 52, 8, 69, 168, 220, 247, 154, 5, 104, + 19, 43, 0, 209, 0, 231, 113, 70, 80, 73, 86, 247, 255, 254, 112, 231, 108, 123, 35, 123, 98, 6, 27, 4, 18, 67, 26, 123, + 163, 153, 6, 2, 27, 67, 19, 123, 226, 28, 21, 67, 29, 28, 40, 240, 4, 248, 136, 40, 0, 209, 90, 125, 35, 125, 98, 6, + 27, 4, 18, 67, 26, 125, 163, 2, 27, 67, 19, 125, 226, 156, 16, 28, 23, 67, 31, 44, 0, 209, 0, 224, 217, 32, 1, 144, + 16, 38, 1, 231, 67, 39, 1, 38, 1, 231, 64, 122, 35, 122, 98, 6, 27, 4, 18, 67, 26, 122, 163, 2, 27, 67, 19, 122, 226, + 156, 15, 28, 16, 67, 24, 66, 132, 209, 47, 32, 0, 144, 15, 39, 0, 38, 1, 231, 45, 156, 14, 44, 0, 209, 0, 231, 4, 152, + 5, 104, 3, 43, 0, 209, 0, 230, 255, 168, 18, 240, 0, 251, 37, 154, 18, 75, 59, 28, 4, 66, 154, 221, 0, 230, 246, 154, + 4, 33, 1, 152, 13, 240, 2, 254, 14, 73, 43, 70, 80, 247, 255, 254, 26, 32, 128, 4, 64, 153, 18, 240, 3, 255, 33, 154, + 13, 24, 18, 146, 13, 66, 148, 219, 0, 230, 226, 35, 0, 147, 13, 230, 223, 38, 0, 231, 73, 240, 0, 250, 144, 240, 0, + 250, 134, 39, 0, 38, 1, 230, 251, 155, 15, 43, 0, 208, 83, 39, 6, 66, 127, 38, 1, 230, 244, 75, 38, 66, 154, 209, 0, + 224, 136, 66, 154, 217, 0, 224, 141, 59, 3, 66, 154, 209, 0, 224, 198, 66, 154, 210, 0, 225, 37, 51, 1, 66, 154, 209, + 0, 225, 21, 51, 1, 66, 154, 208, 0, 231, 90, 70, 92, 104, 35, 105, 34, 104, 24, 104, 163, 38, 1, 104, 25, 240, 1, 253, + 159, 28, 7, 231, 81, 42, 12, 209, 0, 224, 184, 42, 12, 210, 0, 231, 73, 28, 19, 59, 26, 43, 1, 217, 0, 231, 68, 39, + 1, 38, 0, 231, 67, 70, 192, 19, 112, 128, 76, 19, 112, 128, 24, 19, 112, 128, 92, 0, 152, 150, 128, 0, 0, 6, 102, 19, + 112, 128, 12, 19, 112, 129, 128, 19, 112, 128, 108, 19, 112, 128, 124, 19, 112, 129, 72, 19, 112, 128, 136, 19, 112, + 128, 148, 0, 0, 5, 85, 85, 77, 83, 1, 0, 0, 7, 255, 85, 77, 83, 6, 28, 40, 153, 11, 34, 13, 240, 3, 255, 7, 40, 0, 209, + 164, 125, 35, 125, 98, 6, 27, 4, 18, 67, 26, 28, 47, 125, 163, 55, 13, 28, 57, 2, 27, 67, 19, 125, 226, 120, 12, 28, + 22, 28, 34, 58, 48, 67, 30, 6, 19, 14, 27, 37, 0, 28, 72, 43, 9, 216, 11, 1, 43, 28, 29, 67, 21, 28, 1, 120, 12, 28, + 72, 28, 34, 58, 48, 6, 19, 14, 27, 43, 9, 217, 243, 28, 35, 59, 97, 6, 27, 14, 27, 43, 5, 216, 40, 1, 42, 28, 35, 59, + 87, 28, 21, 67, 29, 28, 1, 231, 234, 240, 1, 249, 209, 34, 1, 146, 16, 38, 1, 230, 103, 152, 9, 104, 3, 66, 90, 65, + 83, 96, 3, 39, 0, 38, 1, 230, 221, 76, 143, 66, 162, 208, 51, 66, 162, 217, 0, 224, 180, 75, 141, 66, 154, 208, 0, 230, + 209, 156, 5, 35, 0, 96, 35, 240, 0, 251, 92, 32, 0, 144, 14, 39, 0, 38, 1, 230, 201, 28, 35, 59, 65, 6, 27, 14, 27, + 43, 5, 216, 0, 224, 152, 28, 123, 66, 152, 209, 0, 231, 71, 41, 0, 209, 0, 231, 68, 44, 47, 208, 0, 231, 65, 169, 18, + 247, 255, 253, 75, 40, 0, 209, 0, 231, 59, 120, 3, 43, 0, 208, 0, 231, 55, 28, 50, 153, 18, 28, 40, 240, 0, 249, 127, + 38, 1, 28, 7, 230, 40, 70, 90, 104, 19, 156, 5, 104, 27, 96, 35, 230, 158, 70, 92, 104, 35, 105, 34, 104, 24, 104, 163, + 38, 1, 104, 25, 240, 2, 253, 17, 28, 7, 230, 149, 46, 0, 209, 0, 224, 198, 39, 6, 66, 127, 38, 1, 230, 142, 46, 0, 208, + 249, 70, 88, 105, 3, 70, 90, 136, 24, 105, 147, 136, 28, 106, 19, 136, 29, 104, 19, 120, 25, 104, 147, 120, 26, 2, 3, + 10, 0, 67, 3, 2, 32, 10, 36, 67, 32, 4, 0, 12, 0, 144, 0, 2, 40, 10, 45, 67, 40, 4, 0, 12, 0, 144, 1, 70, 92, 107, 32, + 4, 27, 144, 2, 12, 27, 28, 48, 240, 0, 255, 99, 38, 1, 28, 7, 230, 102, 240, 2, 251, 6, 28, 7, 40, 0, 219, 116, 154, + 5, 153, 19, 32, 1, 96, 16, 122, 11, 122, 74, 6, 27, 4, 18, 67, 26, 122, 139, 152, 10, 2, 27, 67, 19, 122, 202, 67, 26, + 146, 15, 33, 0, 247, 255, 253, 32, 35, 1, 147, 14, 38, 1, 230, 74, 70, 88, 104, 3, 70, 90, 104, 24, 104, 147, 105, 18, + 104, 25, 240, 2, 251, 133, 38, 1, 28, 7, 230, 62, 70, 90, 104, 16, 240, 0, 249, 192, 38, 1, 28, 7, 230, 55, 46, 0, 208, + 162, 70, 88, 104, 3, 120, 25, 104, 131, 136, 26, 105, 3, 28, 48, 240, 0, 255, 18, 38, 1, 28, 7, 230, 41, 1, 42, 28, + 35, 59, 55, 28, 21, 67, 29, 28, 1, 231, 33, 75, 51, 66, 154, 208, 21, 51, 1, 66, 154, 208, 0, 230, 25, 156, 17, 44, + 0, 208, 63, 70, 80, 247, 255, 252, 123, 70, 88, 104, 3, 105, 2, 104, 25, 104, 131, 152, 17, 104, 27, 240, 2, 254, 112, + 39, 0, 38, 1, 230, 9, 122, 11, 122, 74, 6, 27, 4, 18, 67, 26, 122, 139, 70, 88, 2, 27, 67, 19, 122, 202, 28, 20, 67, + 28, 35, 0, 147, 18, 104, 195, 43, 4, 208, 38, 70, 90, 104, 16, 153, 18, 240, 2, 254, 17, 144, 17, 40, 0, 208, 27, 39, + 0, 148, 15, 152, 8, 231, 154, 153, 19, 152, 7, 122, 11, 122, 74, 6, 27, 4, 18, 67, 26, 122, 139, 38, 1, 2, 27, 67, 19, + 122, 202, 33, 0, 67, 26, 146, 15, 247, 255, 252, 173, 35, 0, 147, 14, 229, 216, 39, 1, 66, 127, 38, 1, 229, 212, 39, + 1, 66, 127, 231, 225, 104, 129, 34, 4, 168, 18, 240, 3, 253, 226, 231, 210, 70, 90, 104, 19, 70, 92, 120, 24, 104, 147, + 105, 18, 120, 25, 105, 163, 240, 0, 248, 247, 38, 1, 28, 7, 229, 190, 85, 77, 83, 128, 85, 77, 83, 16, 87, 70, 83, 1, + 181, 0, 33, 128, 176, 129, 2, 73, 72, 18, 247, 255, 252, 3, 75, 18, 33, 64, 96, 24, 247, 255, 252, 30, 33, 16, 247, + 255, 252, 19, 75, 15, 33, 250, 28, 2, 96, 24, 0, 137, 75, 13, 72, 14, 247, 255, 252, 46, 75, 13, 96, 24, 247, 255, 252, + 2, 240, 0, 249, 64, 40, 0, 219, 5, 247, 255, 252, 192, 32, 0, 176, 1, 188, 2, 71, 8, 32, 1, 66, 64, 231, 249, 70, 192, + 19, 113, 73, 128, 19, 112, 128, 24, 19, 112, 128, 16, 0, 0, 6, 102, 0, 15, 66, 64, 19, 112, 128, 20, 181, 240, 77, 17, + 176, 131, 28, 4, 73, 16, 34, 0, 104, 40, 247, 255, 251, 255, 79, 15, 28, 33, 104, 56, 247, 255, 251, 254, 76, 11, 174, + 1, 104, 40, 28, 49, 34, 0, 247, 255, 251, 255, 155, 1, 66, 163, 209, 247, 28, 49, 104, 40, 34, 0, 247, 255, 251, 247, + 104, 56, 247, 255, 251, 200, 176, 3, 188, 240, 188, 1, 71, 0, 19, 112, 128, 16, 0, 0, 5, 85, 19, 112, 128, 20, 181, + 240, 77, 19, 28, 4, 176, 131, 73, 18, 34, 0, 104, 40, 247, 255, 251, 213, 1, 97, 27, 9, 79, 16, 0, 137, 25, 9, 104, + 56, 0, 201, 247, 255, 251, 208, 76, 11, 174, 1, 104, 40, 28, 49, 34, 0, 247, 255, 251, 209, 155, 1, 66, 163, 209, 247, + 28, 49, 104, 40, 34, 0, 247, 255, 251, 201, 104, 56, 247, 255, 251, 154, 176, 3, 188, 240, 188, 1, 71, 0, 19, 112, 128, + 16, 0, 0, 5, 85, 19, 112, 128, 20, 181, 240, 75, 24, 28, 5, 104, 31, 35, 84, 92, 252, 70, 140, 28, 22, 44, 0, 208, 32, + 28, 57, 49, 96, 32, 0, 224, 3, 48, 1, 49, 40, 66, 132, 221, 24, 105, 139, 43, 0, 209, 248, 136, 10, 2, 19, 10, 18, 67, + 19, 4, 27, 12, 27, 66, 171, 209, 240, 136, 74, 2, 19, 10, 18, 67, 19, 4, 27, 12, 27, 69, 99, 209, 232, 0, 131, 24, 27, + 0, 219, 24, 251, 103, 158, 224, 1, 38, 6, 66, 118, 28, 48, 188, 240, 188, 2, 71, 8, 70, 192, 19, 112, 128, 28, 181, + 0, 40, 0, 208, 1, 35, 0, 98, 3, 32, 0, 188, 2, 71, 8, 181, 112, 75, 16, 28, 6, 104, 28, 35, 84, 92, 229, 45, 0, 208, + 18, 111, 163, 66, 179, 208, 19, 28, 33, 49, 160, 34, 0, 224, 8, 0, 147, 24, 155, 0, 219, 51, 88, 24, 224, 104, 11, 49, + 40, 66, 179, 208, 3, 50, 1, 66, 170, 219, 243, 32, 0, 188, 112, 188, 2, 71, 8, 28, 32, 48, 88, 231, 249, 19, 112, 128, + 28, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 70, 147, 74, 35, 28, 31, 104, 20, 35, 84, 92, 227, 70, 128, + 70, 148, 43, 0, 208, 59, 40, 0, 208, 57, 37, 0, 35, 84, 38, 0, 70, 169, 70, 154, 224, 1, 69, 69, 218, 36, 0, 179, 25, + 155, 0, 219, 24, 228, 111, 35, 43, 0, 208, 22, 0, 232, 28, 3, 70, 74, 51, 2, 82, 58, 52, 96, 83, 218, 136, 34, 28, 1, + 4, 18, 10, 19, 14, 18, 67, 19, 49, 4, 83, 203, 136, 99, 24, 56, 4, 27, 10, 26, 14, 27, 67, 26, 128, 194, 53, 1, 70, + 99, 104, 28, 70, 82, 92, 163, 54, 1, 66, 179, 220, 216, 6, 43, 14, 24, 70, 91, 112, 24, 32, 0, 188, 60, 70, 144, 70, + 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 32, 0, 231, 242, 19, 112, 128, 28, 181, 0, 75, 12, 28, 1, 120, 27, 43, + 1, 208, 2, 32, 0, 188, 2, 71, 8, 40, 0, 208, 11, 74, 8, 72, 8, 120, 19, 51, 4, 0, 155, 88, 195, 96, 11, 120, 19, 51, + 20, 0, 155, 88, 192, 231, 239, 72, 3, 74, 1, 231, 247, 19, 112, 129, 85, 19, 112, 129, 84, 19, 114, 73, 152, 181, 48, + 76, 18, 75, 18, 176, 131, 96, 35, 240, 2, 252, 95, 40, 0, 218, 5, 32, 1, 66, 64, 176, 3, 188, 48, 188, 2, 71, 8, 72, + 13, 33, 1, 247, 255, 250, 201, 28, 5, 40, 0, 219, 242, 35, 0, 73, 10, 34, 0, 147, 0, 247, 255, 250, 152, 96, 32, 28, + 40, 247, 255, 250, 184, 104, 33, 34, 1, 35, 84, 84, 202, 32, 0, 231, 228, 19, 112, 128, 28, 19, 114, 74, 60, 19, 112, + 128, 160, 77, 76, 68, 160, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 124, 130, 124, 199, 125, 6, 6, 19, 70, + 148, 125, 68, 4, 58, 67, 26, 2, 51, 67, 19, 28, 33, 176, 129, 70, 128, 67, 25, 208, 121, 124, 67, 70, 154, 43, 0, 208, + 114, 34, 0, 70, 147, 70, 145, 70, 75, 24, 205, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, + 42, 28, 16, 67, 24, 208, 82, 121, 43, 43, 0, 208, 58, 39, 0, 38, 0, 224, 10, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, + 122, 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 25, 132, 123, 163, 123, 226, 6, 27, 4, 18, 67, 26, 124, 35, 2, 27, + 67, 19, 124, 98, 28, 16, 67, 24, 208, 1, 240, 2, 251, 154, 122, 99, 122, 162, 6, 27, 4, 18, 67, 26, 122, 227, 2, 27, + 67, 19, 123, 34, 28, 16, 67, 24, 208, 1, 240, 2, 251, 140, 121, 43, 55, 1, 54, 18, 66, 187, 220, 210, 122, 107, 122, + 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 240, 2, 251, 122, 70, 66, 124, 82, 70, + 67, 70, 146, 70, 66, 124, 155, 124, 215, 70, 156, 4, 58, 6, 27, 67, 26, 70, 67, 125, 30, 2, 51, 67, 19, 70, 66, 125, + 84, 28, 33, 67, 25, 35, 1, 34, 13, 68, 155, 68, 145, 69, 218, 221, 8, 70, 98, 6, 19, 4, 58, 67, 26, 2, 51, 67, 19, 28, + 33, 67, 25, 231, 143, 28, 8, 240, 2, 251, 85, 176, 1, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 1, + 71, 0, 181, 48, 75, 15, 176, 129, 104, 25, 108, 10, 28, 19, 51, 8, 0, 155, 88, 92, 50, 1, 100, 10, 28, 32, 240, 2, 251, + 60, 33, 0, 28, 5, 34, 96, 28, 32, 240, 3, 251, 218, 35, 64, 96, 163, 35, 128, 4, 91, 176, 1, 99, 101, 28, 32, 96, 35, + 96, 99, 188, 48, 188, 2, 71, 8, 19, 112, 128, 28, 181, 48, 77, 16, 176, 129, 104, 43, 43, 0, 209, 3, 176, 1, 188, 48, + 188, 1, 71, 0, 76, 12, 35, 160, 88, 224, 40, 0, 208, 1, 240, 2, 251, 25, 34, 164, 33, 0, 28, 32, 240, 3, 251, 182, 72, + 7, 33, 0, 247, 255, 250, 42, 74, 6, 35, 0, 112, 19, 74, 6, 96, 43, 96, 19, 231, 228, 70, 192, 19, 112, 129, 80, 19, + 114, 73, 152, 19, 112, 128, 172, 19, 112, 129, 85, 19, 112, 129, 76, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, + 240, 74, 204, 176, 137, 146, 3, 104, 17, 70, 129, 108, 10, 28, 19, 51, 8, 0, 155, 88, 91, 50, 1, 100, 10, 28, 24, 70, + 152, 240, 2, 250, 230, 34, 96, 28, 4, 33, 0, 70, 64, 240, 3, 251, 132, 70, 67, 99, 92, 70, 66, 35, 64, 96, 147, 35, + 128, 4, 91, 96, 19, 96, 83, 70, 75, 99, 211, 70, 74, 35, 0, 97, 83, 105, 19, 147, 4, 126, 82, 70, 75, 146, 6, 126, 24, + 40, 0, 209, 0, 224, 176, 34, 128, 35, 192, 70, 70, 70, 147, 0, 91, 70, 74, 104, 215, 154, 6, 42, 0, 208, 0, 70, 155, + 70, 75, 105, 218, 75, 176, 37, 255, 64, 19, 147, 5, 34, 255, 59, 1, 147, 2, 2, 19, 34, 128, 1, 82, 70, 154, 4, 45, 146, + 1, 155, 4, 14, 58, 70, 156, 6, 59, 67, 26, 70, 83, 64, 59, 2, 27, 67, 26, 28, 59, 64, 43, 10, 27, 67, 26, 96, 242, 34, + 0, 98, 50, 75, 163, 154, 1, 64, 59, 26, 208, 155, 4, 66, 131, 211, 0, 224, 213, 34, 0, 28, 28, 146, 4, 70, 91, 4, 34, + 67, 26, 6, 19, 14, 17, 67, 25, 70, 83, 64, 19, 2, 27, 64, 42, 67, 25, 10, 18, 67, 17, 70, 98, 96, 177, 100, 50, 155, + 6, 43, 0, 208, 4, 154, 3, 104, 19, 105, 219, 105, 91, 96, 115, 154, 2, 25, 19, 154, 5, 66, 19, 209, 1, 75, 144, 68, + 155, 154, 4, 42, 0, 221, 0, 224, 230, 39, 128, 4, 127, 150, 7, 70, 74, 96, 119, 105, 19, 43, 0, 208, 65, 126, 19, 70, + 154, 43, 0, 209, 61, 154, 3, 35, 128, 104, 17, 0, 91, 70, 93, 108, 10, 64, 93, 75, 131, 67, 29, 28, 19, 51, 8, 0, 155, + 88, 94, 50, 1, 100, 10, 28, 48, 240, 2, 250, 83, 33, 0, 28, 4, 34, 96, 28, 48, 240, 3, 250, 241, 70, 75, 99, 243, 14, + 34, 6, 35, 32, 255, 67, 26, 2, 0, 28, 35, 33, 255, 4, 9, 64, 3, 99, 116, 96, 55, 2, 27, 96, 119, 64, 12, 67, 26, 10, + 36, 155, 7, 67, 34, 96, 26, 70, 82, 99, 158, 96, 242, 6, 43, 98, 50, 14, 42, 67, 26, 28, 43, 64, 3, 2, 27, 64, 13, 67, + 26, 10, 45, 67, 42, 70, 83, 96, 178, 100, 51, 104, 179, 34, 128, 4, 18, 67, 19, 176, 9, 70, 64, 96, 179, 188, 60, 70, + 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 70, 75, 104, 89, 37, 255, 6, 11, 14, 10, 67, 26, 2, 45, 28, + 11, 64, 43, 2, 27, 36, 255, 67, 26, 4, 36, 28, 11, 64, 35, 10, 27, 67, 26, 70, 67, 96, 218, 98, 24, 75, 85, 28, 10, + 64, 26, 35, 128, 1, 91, 26, 155, 43, 8, 216, 0, 224, 132, 75, 83, 70, 66, 96, 147, 35, 8, 100, 19, 155, 3, 104, 25, + 108, 10, 28, 19, 51, 8, 0, 155, 88, 94, 50, 1, 100, 10, 28, 48, 240, 2, 249, 234, 34, 96, 28, 4, 33, 0, 28, 48, 240, + 3, 250, 136, 35, 64, 96, 179, 35, 128, 4, 91, 70, 74, 96, 51, 96, 115, 99, 242, 6, 35, 14, 34, 67, 26, 35, 255, 2, 27, + 64, 35, 2, 27, 67, 26, 35, 255, 4, 27, 99, 116, 64, 28, 10, 36, 67, 34, 70, 67, 96, 26, 99, 158, 154, 4, 42, 0, 209, + 2, 75, 58, 70, 155, 231, 0, 74, 58, 75, 56, 70, 147, 230, 252, 28, 4, 66, 163, 217, 92, 35, 128, 1, 91, 24, 250, 75, + 54, 28, 17, 34, 1, 64, 25, 28, 48, 70, 148, 6, 11, 14, 10, 67, 26, 70, 83, 64, 11, 2, 27, 67, 26, 28, 11, 64, 43, 10, + 27, 67, 26, 35, 0, 97, 2, 98, 67, 34, 128, 1, 82, 155, 4, 24, 164, 24, 137, 66, 163, 216, 5, 28, 28, 155, 4, 70, 164, + 27, 27, 147, 4, 231, 5, 34, 1, 68, 148, 70, 99, 48, 4, 43, 4, 221, 222, 28, 32, 153, 5, 240, 3, 249, 186, 154, 4, 26, + 100, 27, 18, 70, 164, 146, 4, 230, 245, 68, 103, 247, 255, 254, 61, 107, 66, 70, 75, 14, 17, 99, 195, 6, 19, 67, 25, + 70, 83, 64, 19, 2, 27, 64, 42, 67, 25, 10, 18, 67, 17, 96, 49, 99, 176, 28, 6, 230, 198, 43, 8, 209, 0, 231, 119, 34, + 128, 1, 82, 75, 17, 24, 137, 64, 25, 28, 10, 28, 11, 64, 42, 64, 35, 10, 27, 2, 18, 67, 26, 14, 9, 70, 67, 67, 10, 97, + 26, 98, 88, 231, 101, 154, 4, 66, 162, 209, 201, 231, 189, 70, 192, 19, 112, 128, 28, 0, 0, 7, 255, 0, 0, 15, 255, 128, + 0, 0, 0, 128, 2, 8, 0, 128, 0, 1, 128, 128, 0, 0, 128, 255, 255, 240, 0, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, + 240, 176, 133, 144, 3, 145, 2, 126, 11, 43, 0, 209, 0, 226, 33, 154, 2, 105, 17, 41, 0, 208, 8, 126, 83, 43, 0, 209, + 0, 226, 19, 104, 144, 240, 2, 249, 130, 155, 2, 96, 216, 72, 227, 34, 0, 104, 3, 70, 129, 105, 219, 70, 154, 195, 4, + 51, 4, 70, 81, 96, 74, 195, 4, 195, 4, 195, 4, 195, 4, 195, 4, 195, 4, 195, 4, 195, 4, 195, 4, 96, 26, 152, 2, 247, + 255, 254, 31, 70, 82, 100, 144, 155, 2, 158, 3, 126, 25, 105, 220, 34, 128, 105, 179, 1, 146, 67, 26, 35, 15, 64, 11, + 28, 5, 2, 27, 28, 16, 67, 24, 41, 0, 208, 0, 225, 205, 75, 207, 28, 1, 67, 25, 6, 11, 14, 10, 36, 255, 2, 36, 67, 26, + 28, 11, 64, 35, 2, 27, 32, 255, 4, 0, 67, 26, 28, 11, 64, 3, 10, 27, 70, 81, 67, 26, 96, 74, 108, 74, 35, 64, 96, 139, + 28, 17, 28, 19, 64, 3, 64, 33, 10, 27, 2, 9, 67, 25, 14, 19, 67, 25, 35, 224, 64, 26, 35, 2, 67, 26, 6, 18, 67, 17, + 70, 82, 96, 17, 107, 106, 70, 86, 6, 19, 14, 17, 67, 25, 28, 19, 64, 35, 2, 27, 64, 2, 67, 25, 10, 18, 67, 17, 70, 83, + 97, 25, 35, 128, 4, 91, 97, 115, 152, 2, 126, 2, 42, 0, 208, 0, 225, 125, 70, 81, 105, 138, 75, 176, 70, 78, 64, 19, + 70, 82, 97, 147, 104, 51, 70, 80, 105, 155, 108, 89, 35, 255, 2, 27, 28, 10, 64, 26, 35, 255, 4, 27, 64, 11, 10, 27, + 2, 18, 67, 26, 14, 11, 67, 26, 35, 224, 64, 25, 35, 2, 67, 25, 6, 9, 67, 10, 96, 2, 33, 96, 240, 2, 248, 231, 70, 81, + 108, 140, 44, 0, 208, 6, 28, 32, 33, 96, 240, 2, 248, 223, 107, 164, 44, 0, 209, 248, 70, 78, 104, 51, 70, 82, 108, + 81, 105, 152, 35, 255, 2, 27, 28, 10, 64, 26, 35, 255, 4, 27, 64, 11, 10, 27, 2, 18, 67, 26, 14, 11, 67, 26, 35, 224, + 64, 25, 35, 2, 67, 25, 6, 9, 67, 10, 96, 2, 104, 51, 33, 96, 105, 152, 240, 2, 248, 191, 104, 51, 152, 3, 104, 154, + 75, 140, 33, 2, 104, 28, 105, 195, 29, 23, 51, 16, 0, 155, 24, 211, 51, 4, 70, 152, 70, 139, 32, 100, 247, 255, 251, + 56, 70, 73, 104, 14, 70, 67, 104, 26, 104, 179, 104, 56, 29, 29, 104, 91, 33, 55, 64, 25, 75, 129, 64, 26, 42, 1, 208, + 0, 225, 84, 70, 91, 66, 25, 208, 0, 225, 93, 7, 195, 213, 0, 225, 99, 60, 100, 44, 0, 220, 227, 96, 41, 70, 73, 104, + 11, 104, 155, 104, 27, 75, 120, 96, 26, 34, 1, 66, 83, 70, 155, 70, 78, 104, 51, 33, 96, 105, 155, 108, 88, 240, 2, + 248, 108, 70, 81, 108, 72, 33, 96, 240, 2, 248, 103, 70, 82, 108, 148, 44, 0, 208, 6, 107, 96, 33, 96, 240, 2, 248, + 95, 107, 164, 44, 0, 209, 248, 70, 78, 104, 51, 105, 152, 35, 255, 108, 65, 2, 27, 28, 10, 64, 26, 35, 255, 4, 27, 64, + 11, 10, 27, 2, 18, 67, 26, 14, 11, 67, 26, 35, 224, 64, 25, 35, 2, 67, 25, 6, 9, 67, 10, 96, 2, 104, 51, 33, 96, 105, + 152, 240, 2, 248, 88, 104, 51, 33, 96, 105, 155, 108, 88, 240, 2, 248, 58, 152, 2, 126, 2, 42, 0, 208, 23, 153, 3, 35, + 15, 106, 72, 28, 17, 64, 25, 6, 19, 43, 0, 218, 0, 224, 248, 34, 1, 28, 19, 64, 139, 28, 4, 70, 86, 67, 156, 105, 179, + 9, 219, 28, 24, 64, 16, 28, 3, 64, 139, 152, 3, 67, 35, 98, 67, 70, 89, 41, 0, 209, 53, 70, 74, 104, 19, 158, 3, 104, + 154, 105, 155, 28, 23, 108, 91, 55, 24, 70, 154, 105, 243, 36, 0, 51, 16, 0, 155, 24, 211, 51, 4, 70, 152, 32, 100, + 247, 255, 250, 170, 70, 73, 104, 14, 70, 64, 104, 179, 104, 2, 29, 29, 104, 56, 104, 91, 33, 55, 64, 25, 75, 58, 64, + 26, 42, 1, 208, 0, 224, 228, 35, 2, 66, 25, 208, 0, 224, 234, 69, 130, 209, 0, 224, 240, 52, 1, 44, 200, 209, 227, 96, + 41, 70, 78, 104, 51, 104, 155, 104, 27, 75, 49, 96, 26, 32, 1, 66, 65, 70, 139, 70, 74, 104, 19, 105, 219, 108, 156, + 44, 0, 208, 59, 35, 255, 72, 44, 39, 255, 4, 27, 38, 3, 33, 64, 37, 0, 2, 63, 147, 1, 70, 176, 70, 132, 70, 138, 104, + 162, 70, 70, 6, 19, 14, 17, 67, 25, 28, 19, 64, 59, 2, 27, 67, 25, 155, 1, 28, 8, 64, 26, 10, 18, 67, 16, 10, 3, 64, + 51, 43, 2, 208, 8, 107, 225, 108, 34, 105, 75, 70, 102, 24, 210, 12, 3, 64, 51, 26, 210, 97, 74, 108, 35, 43, 0, 209, + 3, 35, 255, 64, 3, 43, 64, 208, 4, 70, 81, 66, 8, 208, 1, 37, 1, 66, 109, 107, 164, 44, 0, 209, 213, 45, 0, 208, 3, + 107, 226, 35, 1, 66, 91, 97, 83, 70, 75, 104, 26, 35, 0, 100, 19, 158, 2, 105, 49, 41, 0, 208, 6, 126, 115, 43, 0, 208, + 65, 104, 240, 240, 1, 255, 165, 158, 2, 126, 51, 43, 0, 208, 66, 224, 13, 19, 112, 128, 28, 64, 64, 64, 0, 1, 0, 0, + 128, 19, 112, 128, 32, 0, 0, 32, 1, 19, 112, 129, 76, 0, 0, 127, 255, 70, 88, 40, 0, 209, 2, 153, 2, 105, 73, 70, 139, + 176, 5, 70, 88, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 155, 3, 106, 88, 6, 19, 43, 0, + 219, 54, 33, 0, 35, 15, 64, 19, 24, 203, 64, 216, 7, 198, 213, 41, 70, 80, 105, 130, 35, 128, 67, 26, 97, 130, 230, + 113, 75, 50, 28, 34, 64, 26, 35, 128, 4, 18, 5, 219, 67, 26, 28, 17, 67, 1, 230, 42, 154, 2, 104, 208, 240, 1, 255, + 90, 158, 2, 126, 51, 43, 0, 209, 203, 104, 112, 33, 8, 240, 1, 255, 90, 231, 198, 158, 2, 104, 176, 240, 1, 255, 101, + 96, 240, 229, 234, 104, 8, 33, 8, 240, 1, 255, 103, 153, 2, 96, 72, 229, 214, 70, 81, 105, 138, 35, 128, 67, 154, 97, + 138, 230, 71, 33, 16, 231, 199, 49, 16, 231, 4, 74, 28, 35, 1, 96, 19, 104, 179, 70, 78, 96, 89, 104, 51, 32, 1, 104, + 155, 66, 65, 104, 27, 70, 139, 230, 177, 96, 41, 70, 78, 104, 51, 32, 2, 104, 155, 66, 65, 104, 27, 70, 139, 230, 168, + 96, 41, 70, 78, 104, 51, 32, 0, 104, 155, 70, 131, 104, 27, 230, 160, 74, 13, 35, 1, 96, 19, 104, 179, 70, 78, 96, 89, + 104, 51, 104, 155, 104, 27, 231, 33, 96, 41, 70, 78, 104, 51, 32, 2, 104, 155, 66, 65, 104, 27, 70, 139, 231, 27, 96, + 41, 70, 74, 104, 19, 104, 155, 104, 27, 231, 21, 70, 192, 0, 0, 7, 255, 19, 112, 129, 76, 181, 48, 176, 137, 70, 109, + 118, 41, 9, 201, 118, 105, 33, 128, 0, 137, 145, 7, 36, 0, 70, 105, 148, 0, 146, 4, 147, 2, 247, 255, 253, 116, 176, + 9, 188, 48, 188, 2, 71, 8, 181, 240, 70, 71, 180, 128, 176, 136, 70, 128, 70, 104, 48, 58, 136, 5, 48, 4, 136, 6, 72, + 40, 4, 45, 104, 4, 32, 248, 88, 32, 4, 54, 112, 66, 2, 26, 10, 27, 67, 26, 4, 18, 12, 19, 112, 195, 10, 43, 14, 45, + 67, 43, 14, 18, 4, 27, 112, 130, 12, 55, 12, 26, 14, 27, 113, 3, 14, 54, 2, 59, 67, 51, 4, 27, 113, 66, 14, 26, 12, + 27, 112, 1, 113, 195, 70, 108, 35, 0, 9, 201, 113, 130, 118, 35, 118, 97, 35, 64, 144, 0, 147, 7, 152, 16, 75, 20, 151, + 4, 66, 152, 216, 12, 96, 160, 70, 105, 70, 64, 247, 255, 253, 51, 28, 5, 176, 8, 28, 40, 188, 4, 70, 144, 188, 240, + 188, 2, 71, 8, 28, 56, 240, 1, 254, 130, 28, 58, 153, 16, 144, 2, 240, 2, 254, 207, 70, 105, 70, 64, 247, 255, 253, + 31, 153, 2, 28, 5, 28, 58, 152, 16, 240, 2, 254, 197, 152, 2, 240, 1, 254, 100, 231, 226, 70, 192, 19, 112, 128, 28, + 19, 136, 0, 0, 181, 0, 176, 133, 42, 0, 209, 4, 32, 3, 66, 64, 176, 5, 188, 2, 71, 8, 28, 19, 34, 0, 145, 0, 146, 1, + 146, 2, 33, 1, 34, 11, 247, 255, 255, 142, 231, 242, 70, 192, 181, 0, 176, 133, 34, 0, 146, 0, 146, 1, 146, 2, 28, 11, + 34, 9, 33, 0, 247, 255, 255, 129, 176, 5, 188, 2, 71, 8, 181, 16, 176, 132, 28, 20, 70, 106, 50, 27, 120, 18, 2, 36, + 67, 28, 35, 0, 147, 0, 146, 1, 145, 2, 34, 6, 33, 128, 28, 35, 247, 255, 255, 109, 176, 4, 188, 16, 188, 2, 71, 8, 70, + 192, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 137, 144, 6, 72, 160, 155, 6, 104, 1, 51, 16, 145, 7, + 104, 138, 0, 155, 24, 213, 154, 6, 70, 128, 152, 6, 0, 146, 104, 105, 24, 19, 146, 5, 154, 7, 0, 219, 24, 211, 34, 0, + 103, 26, 75, 151, 64, 25, 70, 155, 41, 1, 208, 0, 224, 227, 75, 149, 32, 100, 96, 107, 247, 255, 248, 239, 75, 148, + 32, 100, 96, 107, 247, 255, 248, 234, 75, 146, 32, 100, 96, 107, 247, 255, 248, 187, 70, 64, 104, 4, 104, 106, 104, + 163, 104, 105, 29, 31, 104, 91, 32, 55, 70, 129, 64, 24, 70, 91, 64, 26, 42, 1, 208, 0, 224, 203, 34, 2, 70, 146, 66, + 16, 208, 0, 224, 184, 38, 128, 0, 118, 66, 49, 209, 0, 224, 205, 32, 100, 247, 255, 248, 159, 70, 67, 104, 28, 104, + 106, 104, 163, 104, 105, 29, 31, 104, 91, 70, 72, 64, 24, 70, 91, 64, 26, 42, 1, 208, 0, 224, 176, 70, 82, 66, 16, 208, + 0, 224, 158, 66, 49, 209, 0, 224, 181, 32, 100, 247, 255, 248, 135, 70, 67, 104, 28, 104, 106, 104, 163, 104, 105, 29, + 31, 104, 91, 70, 72, 64, 24, 70, 91, 64, 26, 42, 1, 208, 0, 224, 152, 70, 82, 66, 16, 208, 0, 224, 134, 66, 49, 209, + 0, 224, 157, 32, 100, 247, 255, 248, 111, 70, 67, 104, 28, 104, 106, 104, 163, 104, 105, 29, 31, 104, 91, 32, 55, 70, + 131, 64, 24, 75, 98, 64, 26, 70, 153, 42, 1, 208, 0, 224, 126, 34, 2, 66, 16, 209, 109, 38, 128, 0, 118, 66, 49, 209, + 0, 224, 130, 32, 100, 247, 255, 248, 84, 70, 67, 104, 28, 104, 106, 104, 163, 104, 105, 29, 31, 104, 91, 70, 88, 64, + 24, 70, 75, 64, 26, 42, 1, 209, 102, 70, 82, 66, 16, 209, 85, 66, 49, 208, 109, 32, 100, 247, 255, 248, 63, 70, 67, + 104, 28, 104, 106, 104, 163, 104, 105, 29, 31, 104, 91, 70, 88, 64, 24, 70, 75, 64, 26, 42, 1, 209, 81, 70, 82, 66, + 16, 209, 64, 66, 49, 208, 88, 32, 100, 247, 255, 248, 42, 70, 67, 104, 28, 104, 106, 104, 163, 104, 105, 29, 31, 104, + 91, 70, 88, 64, 24, 70, 75, 64, 26, 42, 1, 209, 60, 34, 2, 66, 16, 209, 43, 38, 128, 0, 118, 66, 49, 208, 65, 32, 100, + 247, 255, 248, 19, 70, 67, 104, 28, 104, 105, 104, 163, 104, 109, 104, 90, 29, 31, 28, 16, 35, 55, 64, 24, 70, 75, 64, + 25, 41, 1, 209, 36, 70, 82, 66, 16, 209, 19, 66, 53, 208, 43, 96, 56, 70, 64, 104, 3, 32, 1, 104, 155, 66, 64, 104, + 27, 75, 48, 96, 25, 176, 9, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 96, 56, 70, 64, 104, + 3, 32, 2, 104, 155, 66, 64, 104, 27, 231, 238, 35, 128, 1, 155, 32, 1, 96, 107, 66, 64, 231, 232, 74, 35, 35, 1, 96, + 19, 104, 163, 96, 88, 70, 64, 104, 3, 32, 1, 104, 155, 66, 64, 104, 27, 231, 220, 153, 5, 154, 6, 37, 0, 24, 139, 0, + 219, 153, 7, 70, 66, 96, 56, 70, 154, 51, 88, 24, 204, 104, 19, 32, 100, 104, 155, 104, 27, 247, 254, 255, 237, 35, + 22, 147, 1, 35, 128, 28, 32, 33, 128, 34, 6, 0, 91, 149, 0, 148, 2, 247, 255, 254, 52, 40, 0, 219, 190, 158, 6, 28, + 32, 54, 1, 4, 51, 12, 27, 33, 0, 34, 5, 149, 0, 149, 1, 149, 2, 247, 255, 254, 38, 40, 0, 219, 176, 155, 7, 68, 83, + 103, 221, 103, 30, 231, 171, 70, 192, 19, 112, 128, 28, 0, 0, 32, 1, 0, 0, 24, 3, 0, 0, 25, 3, 0, 0, 16, 1, 19, 112, + 129, 76, 181, 112, 77, 12, 35, 84, 104, 42, 92, 211, 43, 0, 208, 14, 36, 0, 38, 84, 0, 163, 25, 27, 0, 219, 24, 211, + 103, 92, 28, 32, 247, 255, 254, 153, 104, 42, 52, 1, 93, 147, 66, 163, 220, 242, 32, 0, 188, 112, 188, 2, 71, 8, 19, + 112, 128, 28, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 75, 81, 39, 0, 34, 144, 176, 133, 28, 4, 70, 146, + 70, 185, 70, 155, 224, 98, 70, 82, 88, 162, 32, 1, 70, 144, 240, 1, 252, 171, 28, 6, 40, 0, 208, 83, 70, 75, 147, 0, + 35, 1, 147, 1, 144, 2, 33, 128, 70, 64, 34, 8, 35, 0, 247, 255, 253, 211, 40, 0, 219, 108, 120, 50, 28, 48, 70, 144, + 240, 1, 252, 138, 120, 35, 69, 67, 208, 11, 70, 82, 88, 160, 70, 74, 146, 0, 146, 1, 146, 2, 33, 0, 34, 9, 247, 255, + 253, 191, 40, 0, 219, 50, 104, 163, 43, 0, 209, 89, 70, 83, 88, 224, 136, 227, 70, 74, 147, 0, 146, 1, 146, 2, 33, 33, + 34, 255, 35, 0, 247, 255, 253, 174, 28, 5, 40, 0, 219, 67, 32, 10, 247, 254, 255, 86, 70, 83, 88, 224, 123, 35, 70, + 74, 147, 0, 146, 1, 146, 2, 33, 2, 34, 1, 35, 0, 247, 255, 253, 156, 28, 5, 40, 0, 219, 14, 70, 83, 88, 224, 123, 99, + 70, 74, 147, 0, 146, 1, 146, 2, 33, 2, 34, 1, 35, 0, 247, 255, 253, 141, 28, 5, 40, 0, 218, 24, 47, 20, 208, 22, 32, + 100, 247, 254, 255, 51, 55, 1, 47, 0, 208, 199, 70, 82, 88, 163, 105, 216, 247, 255, 254, 21, 28, 5, 32, 10, 247, 254, + 255, 39, 28, 107, 208, 5, 45, 0, 218, 141, 69, 93, 208, 139, 47, 20, 209, 232, 176, 5, 28, 40, 188, 60, 70, 144, 70, + 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 69, 88, 209, 218, 231, 184, 28, 48, 240, 1, 252, 31, 231, 213, 6, 27, + 70, 82, 14, 27, 88, 160, 104, 98, 43, 0, 208, 206, 6, 18, 14, 18, 146, 0, 70, 74, 146, 1, 146, 2, 33, 1, 34, 11, 247, + 255, 253, 79, 40, 0, 218, 146, 231, 193, 255, 255, 228, 164, 181, 0, 176, 129, 33, 0, 247, 255, 255, 79, 176, 1, 188, + 2, 71, 8, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 143, 28, 30, 70, 107, 51, 103, 120, 27, 145, 2, 147, + 1, 70, 107, 51, 107, 120, 27, 33, 128, 147, 0, 155, 1, 37, 0, 59, 1, 6, 27, 28, 7, 70, 146, 14, 27, 32, 11, 0, 138, + 147, 4, 70, 131, 149, 5, 149, 3, 70, 145, 45, 0, 209, 54, 70, 91, 59, 1, 6, 27, 152, 0, 14, 27, 70, 155, 40, 0, 208, + 61, 153, 4, 41, 15, 217, 79, 37, 3, 66, 109, 70, 88, 6, 4, 152, 5, 34, 1, 70, 128, 44, 0, 221, 1, 42, 0, 209, 26, 44, + 0, 220, 0, 225, 211, 28, 169, 208, 1, 42, 0, 209, 49, 155, 27, 43, 0, 208, 1, 70, 64, 112, 24, 153, 28, 41, 0, 208, + 1, 154, 3, 96, 10, 176, 15, 28, 40, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 28, 107, 208, + 35, 70, 64, 144, 5, 45, 0, 208, 200, 70, 88, 6, 4, 22, 35, 15, 217, 34, 9, 37, 0, 66, 154, 65, 105, 28, 56, 247, 255, + 254, 232, 28, 5, 40, 0, 219, 201, 231, 185, 153, 4, 41, 15, 216, 0, 224, 177, 37, 3, 66, 109, 70, 90, 6, 20, 231, 191, + 28, 56, 33, 0, 247, 255, 254, 215, 28, 130, 209, 199, 28, 5, 231, 197, 74, 209, 35, 1, 96, 19, 231, 203, 34, 160, 88, + 184, 70, 144, 40, 0, 208, 170, 33, 0, 34, 31, 240, 2, 252, 28, 70, 67, 88, 250, 75, 202, 70, 64, 96, 19, 35, 152, 88, + 250, 36, 255, 6, 19, 14, 17, 88, 61, 67, 25, 2, 36, 28, 19, 32, 255, 4, 0, 64, 35, 2, 27, 64, 2, 67, 25, 10, 18, 67, + 17, 96, 105, 70, 66, 88, 185, 6, 51, 14, 50, 67, 26, 28, 51, 64, 35, 2, 27, 67, 26, 28, 51, 64, 3, 10, 27, 67, 26, 96, + 138, 70, 69, 89, 123, 32, 0, 115, 24, 70, 105, 34, 11, 89, 123, 92, 81, 115, 89, 35, 156, 92, 251, 43, 0, 209, 0, 224, + 236, 89, 122, 35, 12, 115, 147, 36, 160, 89, 56, 153, 24, 154, 1, 48, 15, 240, 2, 251, 155, 33, 144, 88, 120, 89, 59, + 123, 121, 34, 31, 247, 255, 252, 100, 28, 5, 40, 31, 208, 0, 225, 18, 46, 0, 209, 0, 224, 234, 4, 51, 12, 27, 172, 6, + 70, 152, 123, 123, 37, 144, 89, 120, 118, 35, 9, 219, 33, 0, 118, 99, 70, 74, 70, 67, 70, 85, 96, 33, 96, 165, 97, 226, + 97, 35, 28, 33, 247, 255, 249, 204, 28, 5, 28, 104, 209, 0, 224, 206, 45, 0, 218, 0, 224, 193, 66, 181, 208, 0, 224, + 189, 68, 178, 28, 51, 70, 180, 45, 0, 218, 0, 225, 16, 38, 0, 34, 160, 70, 144, 88, 184, 33, 255, 34, 13, 240, 2, 251, + 164, 123, 59, 70, 69, 33, 144, 89, 122, 88, 120, 118, 35, 9, 219, 37, 0, 118, 99, 70, 73, 35, 13, 96, 37, 97, 225, 97, + 35, 96, 162, 28, 33, 247, 255, 249, 162, 28, 5, 40, 0, 218, 0, 231, 89, 40, 13, 209, 0, 224, 166, 155, 5, 77, 131, 70, + 152, 70, 91, 34, 1, 6, 28, 231, 21, 34, 160, 88, 184, 70, 144, 40, 0, 209, 0, 231, 71, 33, 0, 34, 31, 240, 2, 251, 122, + 70, 67, 88, 250, 75, 121, 70, 64, 96, 19, 35, 152, 88, 250, 36, 255, 6, 19, 14, 17, 88, 61, 67, 25, 2, 36, 28, 19, 32, + 255, 4, 0, 64, 35, 2, 27, 64, 2, 67, 25, 10, 18, 67, 17, 96, 105, 70, 66, 88, 185, 6, 51, 14, 50, 67, 26, 28, 51, 64, + 35, 2, 27, 67, 26, 28, 51, 64, 3, 10, 27, 67, 26, 96, 138, 70, 67, 88, 250, 35, 128, 66, 91, 115, 19, 70, 69, 70, 104, + 33, 11, 89, 123, 92, 8, 115, 88, 35, 156, 92, 251, 43, 0, 208, 65, 89, 122, 35, 12, 115, 147, 36, 160, 89, 56, 153, + 24, 154, 1, 37, 144, 48, 15, 240, 2, 250, 247, 89, 120, 123, 121, 89, 59, 34, 31, 247, 255, 251, 193, 28, 5, 40, 31, + 209, 68, 46, 0, 208, 73, 172, 6, 224, 4, 37, 1, 28, 30, 66, 109, 46, 0, 208, 27, 123, 59, 33, 144, 88, 120, 118, 35, + 9, 219, 118, 99, 70, 75, 97, 227, 4, 51, 34, 0, 12, 27, 70, 85, 96, 165, 96, 34, 97, 35, 28, 33, 247, 255, 249, 39, + 28, 5, 40, 0, 219, 232, 26, 51, 68, 130, 66, 174, 209, 225, 28, 30, 46, 0, 209, 227, 45, 0, 219, 0, 231, 94, 152, 5, + 70, 89, 15, 234, 70, 128, 6, 12, 230, 149, 155, 1, 70, 65, 88, 122, 43, 6, 216, 55, 35, 6, 115, 147, 231, 184, 157, + 1, 70, 67, 88, 250, 45, 6, 216, 50, 35, 6, 115, 147, 231, 13, 77, 57, 46, 0, 208, 0, 231, 34, 28, 43, 70, 172, 231, + 61, 40, 0, 218, 0, 230, 118, 77, 53, 70, 89, 6, 12, 230, 116, 172, 6, 231, 56, 70, 69, 89, 123, 36, 255, 104, 26, 104, + 152, 104, 93, 123, 27, 14, 17, 70, 152, 6, 19, 67, 25, 70, 132, 28, 19, 2, 36, 32, 255, 64, 35, 4, 0, 2, 27, 64, 2, + 67, 25, 10, 18, 75, 41, 67, 17, 66, 153, 208, 16, 153, 5, 77, 39, 70, 136, 231, 62, 35, 16, 115, 147, 231, 128, 35, + 16, 115, 147, 230, 218, 40, 0, 218, 0, 230, 137, 70, 91, 77, 31, 6, 28, 230, 72, 6, 43, 14, 42, 67, 26, 28, 43, 64, + 35, 2, 27, 67, 26, 28, 43, 64, 3, 10, 27, 28, 17, 67, 25, 70, 99, 14, 26, 6, 27, 67, 26, 70, 99, 64, 35, 2, 27, 67, + 26, 70, 99, 64, 3, 10, 27, 67, 26, 146, 3, 34, 152, 88, 187, 66, 153, 208, 18, 77, 18, 231, 18, 15, 218, 155, 5, 70, + 88, 70, 101, 70, 152, 38, 0, 6, 4, 230, 36, 42, 0, 209, 0, 230, 40, 74, 4, 35, 1, 37, 1, 96, 19, 66, 109, 230, 48, 28, + 75, 80, 187, 37, 0, 230, 34, 19, 112, 129, 76, 85, 83, 66, 67, 255, 255, 216, 237, 255, 255, 216, 233, 255, 255, 216, + 238, 83, 66, 83, 85, 255, 255, 216, 236, 255, 255, 216, 235, 181, 240, 70, 87, 70, 78, 70, 69, 180, 224, 176, 140, 70, + 129, 32, 18, 70, 136, 240, 1, 249, 213, 70, 109, 34, 47, 68, 106, 38, 0, 53, 31, 28, 7, 70, 146, 112, 22, 28, 40, 33, + 0, 34, 16, 240, 2, 250, 94, 47, 0, 208, 32, 35, 1, 112, 46, 147, 1, 147, 2, 70, 83, 147, 3, 70, 72, 70, 65, 34, 0, 35, + 0, 149, 0, 150, 4, 247, 255, 253, 172, 28, 4, 40, 0, 219, 3, 70, 82, 120, 19, 43, 0, 209, 14, 28, 56, 240, 1, 249, 162, + 176, 12, 28, 32, 188, 28, 70, 144, 70, 153, 70, 162, 188, 240, 188, 2, 71, 8, 36, 4, 66, 100, 231, 243, 35, 3, 70, 66, + 112, 43, 1, 83, 112, 107, 33, 0, 35, 18, 34, 18, 28, 56, 113, 43, 113, 110, 240, 2, 250, 43, 35, 6, 147, 1, 70, 72, + 70, 65, 28, 58, 35, 18, 149, 0, 150, 2, 150, 3, 150, 4, 247, 255, 253, 125, 28, 4, 40, 0, 219, 212, 120, 187, 34, 15, + 64, 19, 70, 82, 112, 19, 59, 2, 6, 27, 14, 27, 43, 2, 216, 202, 76, 0, 231, 200, 255, 255, 216, 239, 181, 240, 70, 95, + 70, 86, 70, 77, 70, 68, 180, 240, 176, 149, 144, 11, 72, 91, 145, 10, 144, 8, 120, 3, 146, 9, 43, 1, 208, 9, 32, 0, + 176, 21, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 4, 11, 12, 27, 147, 15, 74, 82, 75, 83, + 33, 0, 145, 14, 146, 7, 70, 153, 152, 7, 70, 74, 120, 0, 28, 7, 55, 4, 0, 187, 144, 12, 88, 209, 152, 15, 28, 11, 67, + 67, 32, 128, 2, 0, 66, 131, 216, 111, 153, 15, 70, 139, 28, 10, 42, 0, 208, 216, 152, 12, 153, 9, 7, 67, 14, 27, 70, + 108, 0, 191, 157, 11, 147, 13, 28, 22, 70, 138, 52, 69, 151, 6, 28, 55, 69, 94, 217, 0, 70, 95, 4, 58, 12, 19, 32, 79, + 70, 152, 68, 104, 35, 0, 112, 3, 32, 40, 35, 55, 112, 32, 68, 107, 120, 27, 33, 0, 112, 99, 14, 43, 112, 163, 12, 43, + 112, 227, 14, 18, 10, 43, 70, 64, 113, 161, 114, 97, 113, 35, 113, 101, 113, 226, 114, 32, 70, 73, 123, 139, 154, 12, + 66, 147, 217, 168, 155, 6, 72, 46, 88, 26, 42, 0, 208, 163, 32, 79, 33, 10, 68, 104, 70, 67, 67, 83, 34, 0, 145, 1, + 146, 2, 144, 3, 146, 4, 72, 39, 153, 12, 70, 82, 148, 0, 247, 255, 252, 241, 40, 0, 221, 40, 33, 79, 68, 105, 120, 11, + 43, 0, 208, 0, 231, 139, 70, 65, 26, 115, 4, 27, 153, 6, 12, 30, 70, 75, 88, 90, 46, 0, 208, 4, 28, 19, 67, 123, 25, + 237, 68, 154, 231, 176, 40, 0, 218, 0, 231, 122, 155, 11, 152, 10, 154, 14, 24, 27, 147, 11, 35, 128, 50, 1, 0, 155, + 146, 14, 66, 154, 209, 130, 32, 1, 231, 110, 240, 2, 248, 97, 154, 15, 70, 131, 231, 141, 40, 0, 218, 218, 28, 130, + 209, 230, 154, 8, 35, 0, 112, 19, 70, 73, 35, 160, 88, 200, 40, 0, 208, 1, 240, 1, 248, 184, 33, 0, 34, 164, 70, 72, + 240, 2, 249, 85, 72, 6, 33, 0, 247, 253, 255, 201, 32, 0, 231, 80, 70, 192, 19, 112, 129, 85, 19, 112, 129, 84, 19, + 114, 73, 152, 19, 112, 128, 172, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 141, 144, 5, 32, 22, 70, 137, + 240, 1, 248, 164, 28, 4, 144, 11, 40, 0, 209, 0, 226, 13, 35, 0, 147, 0, 35, 18, 147, 1, 35, 128, 144, 2, 33, 128, 152, + 5, 34, 6, 0, 91, 247, 255, 249, 201, 144, 6, 40, 0, 219, 0, 224, 142, 152, 11, 240, 1, 248, 128, 70, 74, 70, 73, 124, + 137, 124, 215, 6, 11, 4, 58, 67, 26, 70, 75, 70, 140, 125, 30, 70, 73, 125, 76, 2, 51, 67, 19, 28, 33, 67, 25, 209, + 0, 225, 222, 70, 74, 124, 82, 70, 144, 42, 0, 209, 0, 225, 230, 35, 0, 70, 155, 70, 154, 70, 82, 24, 141, 122, 107, + 122, 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 208, 82, 121, 43, 43, 0, 208, 58, + 39, 0, 38, 0, 224, 10, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 25, + 132, 123, 163, 123, 226, 6, 27, 4, 18, 67, 26, 124, 35, 2, 27, 67, 19, 124, 98, 28, 16, 67, 24, 208, 1, 240, 1, 248, + 55, 122, 99, 122, 162, 6, 27, 4, 18, 67, 26, 122, 227, 2, 27, 67, 19, 123, 34, 28, 16, 67, 24, 208, 1, 240, 1, 248, + 41, 121, 43, 55, 1, 54, 18, 66, 159, 219, 210, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, + 42, 28, 16, 67, 24, 240, 1, 248, 23, 70, 74, 70, 75, 70, 73, 124, 137, 124, 91, 124, 215, 70, 152, 4, 58, 6, 11, 67, + 26, 70, 75, 70, 140, 125, 30, 70, 73, 125, 76, 2, 51, 67, 19, 28, 33, 67, 25, 34, 1, 35, 13, 68, 147, 68, 154, 69, 195, + 219, 0, 225, 123, 70, 97, 6, 11, 4, 58, 67, 26, 2, 51, 67, 19, 28, 33, 67, 25, 231, 142, 28, 33, 34, 18, 70, 72, 240, + 2, 248, 77, 28, 32, 240, 0, 255, 236, 70, 73, 120, 138, 120, 203, 2, 18, 67, 19, 4, 27, 10, 26, 14, 27, 67, 26, 4, 18, + 12, 19, 14, 18, 112, 138, 122, 10, 112, 203, 122, 75, 2, 18, 67, 19, 4, 27, 10, 26, 14, 27, 67, 26, 4, 18, 12, 19, 14, + 18, 114, 10, 122, 138, 114, 75, 122, 203, 2, 18, 67, 19, 4, 27, 10, 26, 14, 27, 67, 26, 4, 18, 12, 19, 14, 18, 114, + 138, 123, 10, 114, 203, 123, 75, 2, 18, 67, 19, 4, 27, 10, 26, 14, 27, 67, 26, 4, 18, 12, 19, 115, 75, 124, 75, 14, + 18, 0, 88, 24, 192, 0, 128, 115, 10, 24, 192, 240, 0, 255, 188, 70, 74, 14, 3, 116, 147, 12, 3, 116, 211, 10, 3, 117, + 19, 117, 80, 40, 0, 209, 0, 225, 47, 124, 83, 33, 0, 0, 90, 24, 210, 0, 146, 24, 210, 240, 2, 248, 63, 70, 73, 124, + 75, 43, 0, 209, 0, 225, 59, 34, 0, 146, 7, 146, 10, 32, 9, 240, 0, 255, 158, 28, 4, 40, 0, 209, 0, 225, 8, 153, 7, 34, + 2, 6, 11, 14, 29, 35, 9, 28, 33, 147, 0, 152, 5, 28, 43, 247, 255, 249, 71, 70, 75, 124, 154, 124, 219, 70, 73, 6, 18, + 4, 27, 67, 19, 125, 10, 2, 18, 67, 26, 125, 75, 28, 33, 67, 19, 154, 10, 24, 210, 70, 146, 28, 16, 34, 9, 240, 1, 255, + 205, 28, 32, 240, 0, 255, 108, 70, 83, 120, 154, 120, 219, 2, 18, 67, 19, 4, 27, 10, 26, 14, 27, 67, 26, 4, 18, 12, + 20, 70, 81, 14, 18, 112, 138, 112, 204, 28, 32, 240, 0, 255, 102, 144, 11, 40, 0, 209, 0, 224, 208, 70, 82, 120, 211, + 152, 5, 147, 0, 153, 11, 34, 2, 28, 43, 247, 255, 249, 17, 144, 6, 40, 0, 218, 0, 230, 197, 70, 83, 120, 29, 121, 27, + 0, 216, 24, 192, 0, 64, 240, 0, 255, 77, 70, 81, 14, 3, 114, 75, 12, 3, 114, 139, 10, 3, 114, 203, 115, 8, 40, 0, 209, + 0, 224, 192, 121, 11, 33, 0, 0, 218, 24, 210, 0, 82, 240, 1, 255, 209, 70, 82, 121, 19, 43, 0, 209, 0, 224, 138, 155, + 11, 33, 0, 25, 91, 27, 100, 70, 152, 70, 163, 145, 8, 145, 9, 70, 83, 122, 90, 122, 155, 70, 81, 6, 18, 4, 27, 67, 19, + 122, 202, 2, 18, 67, 26, 123, 11, 70, 65, 67, 19, 154, 9, 24, 157, 28, 40, 34, 9, 240, 1, 255, 109, 121, 43, 120, 44, + 0, 216, 26, 192, 240, 0, 255, 21, 14, 3, 115, 171, 12, 3, 115, 235, 10, 3, 116, 43, 116, 104, 40, 0, 209, 0, 224, 137, + 70, 91, 27, 27, 70, 155, 121, 43, 33, 0, 0, 218, 26, 210, 240, 1, 255, 152, 70, 89, 68, 160, 41, 0, 209, 0, 224, 120, + 70, 66, 120, 83, 59, 4, 6, 27, 14, 27, 43, 1, 216, 0, 224, 112, 70, 64, 70, 90, 224, 5, 120, 67, 59, 4, 6, 27, 14, 27, + 43, 1, 217, 98, 120, 3, 26, 210, 24, 192, 42, 0, 209, 244, 70, 65, 26, 68, 6, 35, 14, 27, 115, 107, 44, 0, 209, 98, + 121, 43, 43, 0, 208, 37, 39, 0, 38, 0, 123, 171, 123, 234, 6, 27, 4, 18, 67, 26, 124, 43, 124, 108, 2, 27, 67, 19, 67, + 28, 25, 164, 70, 65, 34, 7, 28, 32, 240, 1, 255, 29, 120, 35, 121, 34, 68, 152, 121, 99, 2, 18, 67, 19, 4, 27, 10, 26, + 14, 27, 67, 26, 4, 18, 12, 19, 14, 18, 113, 34, 113, 99, 121, 43, 55, 1, 54, 7, 66, 187, 216, 219, 155, 8, 153, 9, 51, + 1, 49, 18, 147, 8, 145, 9, 70, 82, 121, 19, 153, 8, 66, 139, 217, 0, 231, 124, 152, 11, 240, 0, 254, 156, 154, 7, 155, + 10, 50, 1, 51, 13, 146, 7, 147, 10, 70, 73, 124, 75, 66, 147, 217, 0, 230, 251, 34, 0, 146, 6, 152, 6, 176, 13, 188, + 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 34, 4, 66, 82, 146, 6, 230, 0, 28, 8, 240, 0, 254, + 126, 231, 237, 70, 67, 26, 196, 6, 35, 14, 27, 231, 160, 35, 0, 115, 107, 231, 160, 35, 4, 66, 91, 147, 6, 229, 237, + 28, 32, 240, 0, 254, 122, 14, 3, 114, 107, 12, 3, 114, 171, 10, 3, 114, 235, 115, 40, 40, 0, 208, 239, 70, 65, 28, 34, + 240, 1, 254, 191, 70, 90, 27, 18, 68, 160, 70, 147, 231, 135, 28, 32, 240, 0, 254, 89, 35, 0, 147, 6, 231, 198, 181, + 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 141, 70, 130, 32, 1, 28, 12, 240, 0, 254, 86, 144, 5, 40, 0, 209, + 0, 225, 239, 33, 0, 34, 164, 70, 80, 240, 1, 254, 227, 70, 81, 35, 1, 34, 152, 80, 139, 35, 144, 80, 204, 70, 105, 28, + 32, 49, 26, 247, 255, 253, 146, 28, 4, 40, 0, 218, 0, 225, 194, 75, 178, 104, 27, 43, 0, 208, 0, 224, 211, 72, 177, + 70, 105, 49, 26, 34, 22, 240, 1, 254, 133, 33, 43, 68, 105, 120, 15, 47, 0, 209, 0, 226, 30, 70, 108, 141, 163, 141, + 226, 33, 0, 4, 27, 28, 20, 67, 28, 70, 139, 70, 137, 38, 0, 70, 74, 24, 165, 121, 41, 41, 0, 208, 68, 35, 0, 70, 152, + 39, 0, 122, 106, 122, 171, 6, 18, 4, 27, 67, 19, 122, 234, 2, 18, 67, 26, 123, 43, 67, 19, 25, 220, 121, 99, 43, 8, + 209, 0, 224, 189, 123, 163, 123, 226, 6, 27, 4, 18, 67, 26, 124, 35, 2, 27, 67, 19, 124, 98, 28, 16, 67, 24, 208, 1, + 240, 0, 253, 242, 122, 99, 122, 162, 6, 27, 4, 18, 67, 26, 122, 227, 115, 166, 2, 27, 67, 19, 123, 34, 115, 230, 28, + 16, 116, 38, 116, 102, 67, 24, 208, 1, 240, 0, 253, 224, 114, 102, 114, 166, 114, 230, 115, 38, 121, 41, 36, 1, 68, + 160, 55, 18, 69, 65, 216, 198, 70, 106, 141, 147, 33, 43, 141, 210, 68, 105, 4, 27, 28, 20, 120, 15, 67, 28, 35, 1, + 33, 13, 68, 155, 68, 137, 69, 95, 216, 175, 44, 0, 209, 0, 225, 83, 47, 0, 209, 0, 225, 77, 34, 0, 70, 145, 70, 144, + 70, 67, 24, 229, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 208, 72, + 121, 43, 43, 0, 208, 58, 39, 0, 38, 0, 224, 10, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, + 42, 28, 16, 67, 24, 25, 132, 123, 163, 123, 226, 6, 27, 4, 18, 67, 26, 124, 35, 2, 27, 67, 19, 124, 98, 28, 16, 67, + 24, 208, 1, 240, 0, 253, 144, 122, 99, 122, 162, 6, 27, 4, 18, 67, 26, 122, 227, 2, 27, 67, 19, 123, 34, 28, 16, 67, + 24, 208, 1, 240, 0, 253, 130, 121, 43, 55, 1, 54, 18, 66, 159, 219, 210, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, + 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 240, 0, 253, 112, 70, 105, 36, 43, 141, 139, 141, 202, 68, 108, 120, 39, + 4, 27, 28, 20, 67, 28, 34, 1, 35, 13, 68, 145, 68, 152, 69, 185, 219, 0, 224, 236, 70, 108, 141, 163, 141, 226, 4, 27, + 28, 20, 67, 28, 231, 154, 33, 0, 72, 70, 224, 3, 49, 1, 41, 18, 209, 0, 231, 37, 36, 26, 68, 108, 92, 66, 92, 99, 66, + 154, 208, 245, 152, 5, 240, 0, 253, 73, 70, 104, 48, 26, 36, 1, 247, 254, 249, 96, 66, 100, 224, 225, 121, 162, 42, + 6, 208, 4, 42, 2, 208, 2, 42, 5, 208, 0, 231, 57, 121, 227, 43, 80, 208, 0, 231, 53, 121, 35, 43, 1, 216, 0, 231, 86, + 42, 6, 208, 3, 35, 1, 70, 81, 34, 156, 84, 139, 70, 81, 115, 78, 115, 14, 121, 34, 70, 148, 42, 0, 209, 0, 231, 71, + 32, 0, 33, 0, 224, 3, 48, 1, 49, 7, 69, 132, 217, 26, 123, 162, 123, 227, 6, 18, 4, 27, 67, 19, 124, 34, 2, 18, 67, + 26, 124, 99, 67, 19, 24, 90, 120, 211, 43, 2, 209, 237, 120, 146, 6, 19, 43, 0, 218, 0, 224, 145, 70, 83, 115, 90, 121, + 34, 48, 1, 70, 148, 49, 7, 69, 132, 216, 228, 70, 81, 123, 11, 43, 0, 209, 0, 231, 32, 70, 82, 123, 83, 43, 0, 209, + 0, 231, 27, 121, 107, 70, 81, 112, 11, 120, 163, 70, 106, 96, 75, 120, 227, 96, 139, 141, 147, 141, 210, 4, 27, 28, + 17, 67, 25, 209, 0, 224, 152, 35, 43, 68, 107, 120, 28, 44, 0, 209, 0, 224, 143, 34, 0, 70, 145, 70, 144, 70, 67, 24, + 205, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 208, 76, 121, 43, 43, + 0, 208, 62, 39, 0, 38, 0, 224, 14, 19, 112, 129, 80, 19, 114, 73, 128, 122, 107, 122, 170, 6, 27, 4, 18, 67, 26, 122, + 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 25, 132, 123, 163, 123, 226, 6, 27, 4, 18, 67, 26, 124, 35, 2, 27, 67, + 19, 124, 98, 28, 16, 67, 24, 208, 1, 240, 0, 252, 174, 122, 99, 122, 162, 6, 27, 4, 18, 67, 26, 122, 227, 2, 27, 67, + 19, 123, 34, 28, 16, 67, 24, 208, 1, 240, 0, 252, 160, 121, 43, 55, 1, 54, 18, 66, 159, 219, 210, 122, 107, 122, 170, + 6, 27, 4, 18, 67, 26, 122, 235, 2, 27, 67, 19, 123, 42, 28, 16, 67, 24, 240, 0, 252, 142, 70, 106, 141, 147, 33, 43, + 141, 210, 68, 105, 120, 12, 4, 27, 28, 17, 67, 25, 35, 1, 34, 13, 68, 153, 68, 144, 69, 161, 218, 43, 70, 105, 141, + 139, 141, 202, 4, 27, 28, 17, 67, 25, 231, 151, 70, 83, 115, 26, 121, 34, 70, 148, 231, 81, 28, 32, 240, 0, 252, 112, + 76, 59, 152, 5, 240, 0, 252, 108, 35, 160, 70, 81, 88, 200, 40, 0, 208, 1, 240, 0, 252, 101, 70, 80, 33, 0, 34, 164, + 240, 1, 253, 2, 176, 13, 28, 32, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 36, 4, 66, 100, + 231, 242, 28, 8, 240, 0, 252, 80, 70, 82, 38, 144, 32, 1, 89, 148, 240, 0, 252, 86, 28, 5, 40, 0, 208, 61, 35, 0, 147, + 0, 35, 1, 147, 1, 144, 2, 33, 128, 28, 32, 34, 8, 35, 0, 247, 254, 253, 126, 40, 0, 219, 50, 28, 40, 120, 44, 240, 0, + 252, 54, 70, 83, 120, 25, 66, 161, 208, 5, 70, 84, 89, 160, 247, 254, 253, 228, 40, 0, 219, 34, 70, 81, 104, 138, 42, + 0, 208, 8, 35, 144, 6, 18, 88, 200, 14, 18, 121, 201, 247, 254, 253, 195, 40, 0, 219, 21, 70, 80, 247, 255, 248, 20, + 28, 4, 40, 0, 219, 169, 35, 16, 70, 82, 115, 147, 72, 15, 240, 0, 252, 31, 70, 84, 35, 160, 80, 224, 40, 0, 208, 18, + 152, 5, 240, 0, 252, 11, 36, 0, 231, 168, 76, 10, 231, 151, 28, 40, 240, 0, 252, 4, 76, 7, 231, 146, 70, 106, 141, 147, + 141, 210, 4, 27, 28, 20, 67, 28, 230, 51, 36, 4, 66, 100, 231, 136, 255, 255, 216, 240, 0, 0, 128, 16, 255, 255, 216, + 231, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 73, 98, 176, 141, 144, 6, 70, 136, 28, 8, 153, 6, 247, 255, + 253, 142, 40, 0, 218, 0, 224, 165, 70, 67, 123, 154, 146, 7, 42, 0, 209, 0, 224, 140, 73, 91, 35, 38, 38, 0, 68, 107, + 70, 139, 70, 154, 70, 177, 224, 6, 155, 7, 54, 1, 66, 158, 219, 0, 224, 127, 70, 65, 123, 138, 6, 51, 14, 29, 66, 149, + 210, 244, 73, 82, 70, 90, 96, 17, 72, 79, 28, 41, 247, 255, 249, 237, 28, 4, 40, 0, 219, 90, 75, 77, 70, 89, 96, 11, + 7, 107, 70, 82, 14, 31, 35, 18, 70, 73, 112, 19, 35, 36, 112, 87, 112, 145, 112, 209, 113, 19, 113, 81, 32, 36, 240, + 0, 251, 184, 28, 4, 40, 0, 208, 16, 70, 74, 70, 81, 35, 6, 145, 0, 147, 1, 146, 2, 146, 3, 146, 4, 72, 61, 28, 41, 28, + 34, 35, 36, 247, 254, 255, 155, 28, 32, 240, 0, 251, 152, 70, 81, 35, 37, 112, 79, 112, 11, 32, 8, 240, 0, 251, 157, + 28, 7, 40, 0, 208, 186, 35, 2, 70, 82, 147, 1, 70, 75, 146, 0, 147, 2, 147, 3, 147, 4, 72, 47, 28, 41, 28, 58, 35, 8, + 247, 254, 255, 128, 28, 4, 40, 0, 219, 22, 172, 11, 28, 32, 28, 57, 34, 4, 240, 1, 251, 213, 28, 43, 154, 11, 73, 39, + 51, 20, 0, 155, 80, 90, 28, 32, 29, 57, 34, 4, 240, 1, 251, 202, 29, 43, 154, 11, 73, 33, 0, 155, 80, 90, 36, 0, 28, + 56, 240, 0, 251, 99, 28, 162, 208, 48, 44, 0, 219, 139, 153, 6, 74, 30, 137, 11, 32, 0, 128, 19, 137, 75, 74, 29, 128, + 19, 74, 29, 35, 1, 112, 19, 75, 28, 70, 90, 112, 29, 75, 23, 96, 19, 224, 20, 75, 24, 34, 0, 112, 26, 35, 160, 70, 66, + 88, 208, 40, 0, 208, 1, 240, 0, 251, 68, 33, 0, 70, 64, 34, 164, 240, 1, 251, 225, 72, 19, 33, 0, 247, 253, 250, 85, + 32, 3, 66, 64, 176, 13, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 75, 9, 34, 0, 112, 26, + 70, 65, 35, 160, 88, 200, 40, 0, 209, 225, 231, 226, 70, 192, 19, 114, 73, 152, 19, 112, 128, 32, 0, 15, 66, 64, 19, + 112, 129, 86, 19, 112, 129, 88, 19, 112, 129, 85, 19, 112, 129, 84, 19, 112, 128, 172, 181, 240, 70, 95, 70, 86, 70, + 77, 70, 68, 180, 240, 74, 73, 176, 129, 104, 19, 70, 146, 43, 0, 208, 9, 32, 0, 176, 1, 188, 60, 70, 144, 70, 153, 70, + 162, 70, 171, 188, 240, 188, 2, 71, 8, 75, 66, 104, 29, 70, 153, 35, 84, 92, 235, 43, 0, 208, 121, 38, 0, 224, 53, 32, + 250, 0, 128, 247, 253, 253, 227, 70, 64, 247, 255, 254, 254, 40, 0, 208, 103, 25, 187, 0, 219, 24, 235, 70, 74, 111, + 92, 104, 19, 28, 32, 104, 155, 70, 155, 247, 254, 252, 189, 48, 1, 208, 68, 32, 250, 0, 128, 247, 253, 253, 205, 70, + 64, 247, 255, 254, 232, 40, 0, 208, 81, 25, 187, 0, 219, 24, 235, 111, 92, 70, 74, 104, 19, 28, 32, 104, 157, 247, 254, + 252, 168, 48, 1, 208, 58, 32, 250, 0, 128, 247, 253, 253, 184, 70, 75, 104, 29, 34, 84, 92, 171, 54, 1, 66, 179, 221, + 65, 0, 183, 25, 187, 0, 219, 28, 26, 24, 236, 50, 88, 111, 35, 25, 82, 70, 144, 43, 0, 208, 237, 28, 16, 247, 255, 254, + 193, 40, 0, 208, 42, 70, 74, 104, 19, 111, 100, 104, 155, 28, 32, 70, 155, 247, 254, 252, 131, 48, 1, 209, 175, 32, + 250, 0, 64, 247, 253, 253, 147, 28, 35, 51, 16, 0, 155, 74, 19, 68, 91, 96, 90, 231, 164, 32, 250, 0, 64, 247, 253, + 253, 136, 28, 35, 51, 16, 0, 155, 74, 14, 68, 91, 96, 90, 231, 175, 32, 250, 0, 64, 247, 253, 253, 125, 28, 35, 51, + 16, 0, 155, 74, 8, 24, 235, 96, 90, 231, 185, 35, 1, 70, 82, 96, 19, 74, 6, 35, 0, 96, 19, 231, 116, 32, 1, 66, 64, + 231, 114, 19, 112, 129, 80, 19, 112, 128, 28, 0, 0, 16, 1, 19, 112, 129, 76, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, + 180, 240, 75, 142, 176, 151, 120, 27, 144, 11, 146, 10, 43, 1, 208, 9, 32, 0, 176, 23, 188, 60, 70, 144, 70, 153, 70, + 162, 70, 171, 188, 240, 188, 2, 71, 8, 4, 11, 33, 0, 70, 138, 74, 133, 73, 134, 12, 27, 147, 14, 146, 9, 35, 0, 145, + 8, 224, 137, 74, 131, 35, 144, 88, 208, 70, 147, 40, 0, 209, 0, 224, 208, 75, 129, 105, 196, 104, 27, 28, 32, 104, 157, + 247, 254, 252, 30, 28, 67, 209, 0, 224, 188, 40, 0, 208, 0, 224, 195, 35, 160, 70, 89, 88, 200, 40, 0, 208, 1, 240, + 0, 250, 55, 35, 160, 70, 90, 33, 0, 80, 209, 35, 144, 88, 208, 247, 255, 254, 61, 40, 0, 208, 0, 224, 177, 155, 9, 34, + 0, 96, 26, 32, 100, 247, 253, 253, 22, 75, 111, 153, 8, 96, 11, 75, 111, 70, 89, 120, 27, 154, 14, 28, 30, 54, 4, 147, + 12, 0, 179, 88, 203, 32, 128, 70, 153, 70, 75, 67, 83, 2, 0, 146, 15, 66, 131, 217, 4, 70, 73, 240, 1, 249, 167, 154, + 14, 144, 15, 42, 0, 209, 0, 224, 181, 155, 10, 153, 12, 147, 13, 7, 75, 14, 27, 70, 108, 0, 182, 157, 11, 147, 16, 28, + 23, 52, 77, 150, 7, 154, 15, 28, 62, 66, 151, 217, 0, 28, 22, 4, 50, 12, 19, 33, 87, 70, 152, 68, 105, 35, 0, 112, 11, + 33, 42, 35, 67, 112, 33, 68, 107, 120, 27, 14, 18, 112, 99, 14, 43, 112, 163, 12, 43, 112, 227, 33, 0, 113, 226, 10, + 43, 70, 66, 113, 161, 114, 97, 113, 35, 113, 101, 114, 34, 70, 89, 123, 139, 154, 12, 66, 147, 216, 38, 33, 3, 66, 74, + 70, 146, 75, 71, 153, 8, 96, 11, 154, 9, 104, 19, 43, 0, 209, 2, 70, 83, 43, 0, 218, 117, 155, 17, 51, 1, 43, 15, 220, + 99, 147, 17, 43, 12, 221, 1, 34, 12, 146, 17, 153, 9, 104, 11, 43, 0, 208, 0, 231, 107, 70, 82, 50, 2, 208, 70, 75, + 58, 154, 8, 96, 19, 70, 83, 51, 2, 208, 222, 73, 53, 70, 139, 231, 142, 70, 75, 43, 0, 208, 213, 70, 65, 34, 10, 70, + 75, 67, 75, 146, 1, 33, 1, 34, 87, 145, 2, 68, 106, 33, 0, 146, 3, 145, 4, 72, 44, 153, 12, 154, 13, 148, 0, 247, 254, + 253, 157, 70, 130, 40, 0, 221, 63, 34, 87, 68, 106, 120, 19, 43, 0, 209, 55, 70, 65, 26, 123, 4, 27, 12, 31, 155, 7, + 70, 90, 88, 210, 70, 145, 47, 0, 208, 180, 70, 75, 67, 115, 153, 13, 25, 173, 24, 201, 145, 13, 231, 133, 32, 250, 0, + 64, 247, 253, 252, 112, 28, 35, 51, 16, 0, 155, 74, 29, 24, 235, 96, 90, 32, 100, 247, 253, 252, 103, 70, 82, 50, 2, + 209, 184, 155, 17, 43, 0, 221, 181, 73, 19, 28, 8, 70, 139, 33, 1, 247, 254, 252, 183, 70, 130, 40, 0, 219, 172, 75, + 16, 154, 8, 96, 19, 231, 64, 70, 81, 15, 203, 34, 1, 64, 83, 6, 27, 14, 24, 230, 246, 75, 14, 70, 154, 231, 131, 70, + 83, 43, 0, 218, 193, 231, 127, 32, 1, 230, 237, 34, 1, 66, 83, 70, 154, 231, 121, 19, 112, 129, 85, 19, 112, 129, 76, + 19, 112, 128, 32, 19, 114, 73, 152, 19, 112, 128, 28, 0, 15, 66, 64, 19, 112, 129, 84, 0, 0, 16, 1, 255, 255, 216, 234, + 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 75, 144, 176, 151, 120, 27, 144, 12, 146, 11, 43, 1, 208, 9, 32, + 0, 176, 23, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 74, 137, 4, 11, 33, 0, 70, 136, 146, + 10, 73, 135, 74, 136, 12, 27, 147, 14, 145, 8, 35, 0, 146, 7, 224, 141, 154, 8, 35, 144, 88, 208, 40, 0, 209, 0, 224, + 187, 75, 130, 105, 196, 104, 27, 28, 32, 104, 157, 247, 254, 250, 231, 28, 67, 209, 0, 224, 167, 40, 0, 208, 0, 224, + 174, 153, 8, 35, 160, 88, 200, 40, 0, 208, 2, 240, 0, 249, 0, 153, 8, 35, 160, 34, 0, 80, 202, 35, 144, 88, 200, 247, + 255, 253, 6, 40, 0, 208, 0, 224, 156, 154, 10, 96, 16, 32, 100, 247, 253, 251, 224, 35, 0, 70, 152, 153, 10, 104, 11, + 43, 0, 209, 89, 75, 110, 154, 7, 70, 65, 96, 19, 49, 2, 208, 116, 75, 108, 73, 104, 120, 27, 154, 14, 28, 30, 54, 4, + 147, 13, 0, 179, 88, 203, 32, 128, 70, 153, 70, 75, 67, 83, 2, 0, 146, 15, 66, 131, 217, 4, 70, 73, 240, 1, 248, 104, + 154, 14, 144, 15, 42, 0, 209, 0, 224, 167, 155, 11, 153, 13, 70, 155, 7, 75, 14, 27, 70, 108, 0, 182, 157, 12, 147, + 16, 28, 23, 52, 77, 150, 9, 154, 15, 28, 62, 66, 151, 217, 0, 28, 22, 4, 50, 12, 19, 33, 87, 70, 154, 68, 105, 35, 0, + 112, 11, 33, 40, 35, 67, 112, 33, 68, 107, 120, 27, 33, 0, 112, 99, 14, 43, 112, 163, 14, 18, 12, 43, 112, 227, 113, + 161, 113, 226, 114, 97, 10, 43, 70, 82, 73, 71, 113, 35, 113, 101, 114, 34, 123, 139, 154, 13, 66, 147, 216, 69, 35, + 3, 66, 89, 70, 136, 75, 69, 153, 7, 96, 11, 154, 10, 104, 19, 43, 0, 208, 115, 155, 17, 51, 1, 43, 15, 220, 34, 147, + 17, 43, 12, 221, 1, 35, 12, 147, 17, 153, 10, 104, 11, 43, 0, 208, 0, 231, 103, 70, 65, 49, 2, 209, 144, 154, 17, 42, + 0, 221, 141, 72, 52, 33, 1, 247, 254, 251, 196, 70, 128, 40, 0, 219, 1, 75, 54, 70, 152, 32, 10, 247, 253, 251, 96, + 231, 128, 154, 7, 96, 19, 155, 17, 51, 1, 43, 15, 221, 220, 70, 65, 15, 203, 34, 1, 64, 83, 6, 27, 14, 24, 231, 49, + 32, 250, 0, 64, 247, 253, 251, 78, 28, 35, 51, 16, 0, 155, 74, 42, 24, 235, 96, 90, 32, 100, 247, 253, 251, 69, 231, + 209, 70, 75, 43, 0, 208, 182, 34, 10, 70, 81, 146, 1, 34, 87, 70, 75, 67, 75, 68, 106, 33, 0, 145, 2, 146, 3, 145, 4, + 72, 25, 153, 13, 70, 90, 148, 0, 247, 254, 252, 64, 70, 128, 40, 0, 221, 7, 33, 87, 68, 105, 120, 11, 43, 0, 208, 5, + 74, 25, 70, 144, 231, 157, 70, 66, 42, 0, 219, 154, 70, 81, 26, 123, 4, 27, 12, 31, 74, 13, 155, 9, 88, 210, 70, 145, + 47, 0, 208, 144, 70, 75, 67, 115, 25, 173, 68, 155, 231, 99, 75, 11, 153, 7, 34, 1, 96, 11, 66, 83, 70, 152, 231, 139, + 70, 67, 43, 0, 219, 136, 32, 1, 230, 230, 70, 192, 19, 112, 129, 85, 19, 112, 129, 76, 19, 114, 73, 152, 19, 112, 128, + 32, 19, 112, 128, 28, 0, 15, 66, 64, 19, 112, 129, 84, 255, 255, 253, 102, 0, 0, 16, 1, 255, 255, 216, 234, 71, 112, + 70, 192, 181, 0, 75, 4, 176, 129, 28, 1, 104, 24, 247, 252, 254, 187, 176, 1, 188, 1, 71, 0, 19, 112, 129, 92, 181, + 0, 75, 9, 28, 1, 176, 129, 104, 24, 247, 252, 254, 167, 40, 0, 208, 2, 176, 1, 188, 2, 71, 8, 72, 4, 33, 0, 247, 252, + 254, 254, 32, 100, 247, 253, 250, 209, 231, 251, 19, 112, 129, 92, 19, 112, 128, 192, 181, 0, 176, 129, 247, 252, 254, + 150, 176, 1, 188, 1, 71, 0, 70, 192, 181, 0, 176, 129, 247, 252, 254, 142, 176, 1, 188, 1, 71, 0, 70, 192, 181, 0, 176, + 129, 247, 252, 254, 134, 176, 1, 188, 1, 71, 0, 70, 192, 181, 16, 28, 4, 247, 252, 254, 94, 28, 32, 188, 16, 188, 2, + 71, 8, 181, 16, 28, 4, 247, 252, 254, 86, 28, 32, 188, 16, 188, 2, 71, 8, 181, 16, 28, 4, 247, 252, 254, 78, 28, 32, + 188, 16, 188, 2, 71, 8, 181, 0, 33, 192, 176, 129, 72, 5, 2, 9, 247, 252, 254, 63, 75, 4, 176, 1, 96, 24, 32, 0, 188, + 2, 71, 8, 70, 192, 19, 112, 137, 128, 19, 112, 129, 92, 181, 112, 176, 132, 28, 13, 28, 6, 247, 255, 252, 126, 76, 14, + 28, 32, 247, 253, 251, 94, 75, 13, 28, 2, 96, 24, 40, 0, 209, 4, 32, 0, 176, 4, 188, 112, 188, 2, 71, 8, 104, 35, 72, + 9, 146, 0, 33, 0, 34, 0, 149, 1, 146, 2, 240, 0, 250, 227, 40, 0, 208, 239, 28, 49, 240, 0, 249, 32, 231, 236, 70, 192, + 19, 112, 129, 100, 19, 112, 129, 96, 19, 112, 52, 13, 181, 48, 28, 20, 28, 8, 176, 129, 28, 17, 28, 26, 28, 29, 247, + 255, 254, 41, 40, 0, 209, 4, 32, 1, 176, 1, 188, 48, 188, 2, 71, 8, 75, 4, 28, 40, 104, 27, 28, 25, 67, 97, 247, 252, + 254, 23, 32, 0, 231, 242, 70, 192, 19, 112, 129, 100, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 133, + 144, 1, 104, 6, 28, 21, 106, 112, 70, 152, 28, 10, 30, 131, 64, 218, 4, 19, 12, 27, 147, 2, 122, 50, 26, 128, 144, 3, + 106, 51, 104, 116, 59, 1, 64, 211, 70, 155, 58, 2, 28, 11, 64, 211, 70, 95, 64, 31, 155, 1, 8, 162, 104, 88, 155, 2, + 58, 1, 51, 128, 0, 91, 90, 195, 70, 153, 64, 17, 208, 0, 224, 114, 70, 170, 69, 160, 211, 53, 122, 49, 70, 69, 64, 205, + 106, 50, 25, 235, 66, 147, 216, 60, 70, 74, 42, 0, 208, 61, 154, 3, 106, 241, 70, 75, 64, 147, 24, 121, 24, 201, 107, + 52, 107, 176, 28, 42, 70, 83, 240, 0, 248, 183, 28, 4, 40, 0, 209, 32, 122, 51, 28, 42, 64, 154, 28, 19, 70, 66, 26, + 210, 25, 127, 70, 144, 68, 154, 69, 187, 210, 14, 42, 0, 208, 12, 155, 2, 39, 0, 51, 1, 4, 27, 12, 27, 147, 2, 155, + 1, 104, 90, 155, 2, 51, 128, 0, 91, 90, 211, 70, 153, 104, 116, 69, 160, 210, 201, 70, 66, 42, 0, 209, 31, 36, 0, 176, + 5, 28, 32, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 27, 213, 70, 74, 42, 0, 209, 193, 28, + 42, 64, 138, 70, 80, 33, 0, 240, 0, 255, 122, 122, 51, 28, 42, 64, 154, 28, 19, 70, 66, 26, 210, 70, 144, 68, 154, 25, + 127, 104, 116, 231, 164, 70, 75, 43, 0, 208, 55, 154, 3, 106, 241, 64, 147, 24, 121, 24, 201, 107, 52, 107, 176, 108, + 243, 34, 1, 240, 0, 248, 102, 28, 4, 40, 0, 209, 207, 108, 241, 70, 80, 70, 66, 240, 0, 255, 21, 231, 201, 0, 137, 70, + 138, 43, 0, 208, 71, 154, 3, 106, 241, 64, 147, 24, 121, 24, 201, 107, 52, 107, 176, 108, 243, 34, 1, 240, 0, 248, 78, + 28, 4, 40, 0, 209, 183, 104, 115, 70, 82, 26, 156, 69, 160, 210, 19, 108, 241, 28, 40, 68, 81, 70, 66, 240, 0, 254, + 247, 68, 69, 35, 0, 70, 170, 55, 1, 70, 152, 104, 116, 231, 105, 70, 80, 33, 0, 70, 66, 240, 0, 255, 47, 36, 0, 231, + 158, 108, 241, 28, 40, 68, 81, 28, 34, 240, 0, 254, 227, 70, 67, 27, 27, 25, 45, 55, 1, 70, 152, 70, 170, 69, 95, 216, + 0, 231, 136, 43, 0, 209, 0, 231, 133, 155, 2, 39, 0, 51, 1, 4, 27, 12, 27, 147, 2, 155, 1, 104, 116, 104, 90, 155, 2, + 51, 128, 0, 91, 90, 211, 70, 153, 231, 65, 26, 100, 69, 68, 217, 0, 70, 68, 28, 40, 28, 34, 33, 0, 240, 0, 255, 3, 70, + 67, 27, 27, 25, 45, 70, 152, 70, 170, 55, 1, 104, 116, 231, 48, 71, 32, 181, 240, 70, 87, 70, 70, 180, 192, 35, 72, + 90, 194, 122, 3, 176, 129, 65, 26, 70, 144, 143, 130, 28, 6, 70, 138, 42, 0, 208, 32, 37, 0, 39, 0, 224, 3, 53, 1, 68, + 71, 66, 170, 217, 25, 104, 51, 25, 91, 123, 27, 43, 0, 208, 246, 106, 241, 34, 1, 49, 1, 24, 121, 107, 176, 108, 243, + 107, 52, 240, 0, 248, 72, 108, 241, 70, 80, 34, 6, 240, 0, 254, 97, 40, 0, 208, 14, 143, 178, 53, 1, 68, 71, 66, 170, + 216, 229, 34, 0, 70, 146, 176, 1, 70, 80, 188, 12, 70, 144, 70, 154, 188, 240, 188, 2, 71, 8, 32, 12, 247, 252, 253, + 117, 70, 130, 40, 0, 208, 33, 70, 82, 96, 22, 96, 149, 35, 72, 90, 240, 247, 252, 253, 107, 70, 82, 28, 3, 96, 80, 40, + 0, 208, 11, 106, 241, 107, 176, 49, 1, 25, 201, 107, 52, 70, 66, 240, 0, 248, 24, 109, 51, 51, 1, 101, 51, 231, 217, + 72, 7, 73, 8, 247, 252, 253, 22, 70, 80, 247, 252, 253, 71, 35, 0, 70, 154, 231, 207, 72, 2, 73, 3, 247, 252, 253, 12, + 231, 202, 70, 192, 19, 112, 128, 224, 19, 112, 128, 236, 71, 32, 70, 192, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, + 180, 240, 176, 129, 70, 139, 153, 10, 70, 130, 32, 84, 70, 145, 28, 31, 70, 136, 247, 252, 253, 52, 28, 5, 47, 0, 209, + 85, 32, 128, 0, 128, 247, 252, 253, 45, 35, 128, 2, 27, 97, 43, 70, 66, 35, 15, 117, 43, 23, 211, 12, 91, 68, 67, 19, + 219, 67, 123, 97, 171, 75, 137, 96, 40, 97, 235, 155, 11, 28, 6, 98, 235, 153, 12, 41, 0, 208, 62, 33, 0, 28, 58, 240, + 0, 254, 92, 35, 87, 112, 51, 35, 66, 112, 115, 35, 70, 112, 179, 35, 83, 28, 60, 112, 243, 47, 0, 209, 0, 224, 232, + 35, 0, 51, 1, 6, 27, 8, 100, 14, 27, 44, 0, 209, 249, 59, 1, 6, 27, 14, 27, 70, 66, 114, 51, 14, 19, 113, 51, 12, 19, + 113, 115, 10, 19, 113, 179, 113, 242, 105, 170, 75, 115, 66, 154, 216, 0, 224, 215, 75, 114, 66, 154, 216, 0, 224, 213, + 75, 113, 66, 154, 216, 0, 224, 211, 75, 112, 66, 154, 216, 0, 224, 209, 75, 111, 66, 154, 216, 0, 224, 207, 34, 11, + 125, 43, 24, 211, 114, 115, 224, 7, 28, 56, 231, 169, 70, 72, 153, 11, 34, 1, 28, 51, 240, 0, 248, 221, 120, 51, 120, + 114, 6, 27, 4, 18, 67, 26, 120, 179, 2, 27, 67, 19, 120, 242, 67, 26, 75, 99, 66, 154, 208, 0, 224, 167, 75, 98, 104, + 27, 66, 92, 65, 92, 44, 0, 208, 24, 47, 0, 208, 0, 224, 116, 44, 0, 208, 19, 70, 65, 41, 0, 208, 16, 121, 50, 121, 115, + 6, 18, 4, 27, 67, 19, 121, 178, 2, 18, 67, 26, 121, 243, 67, 19, 69, 67, 208, 4, 72, 86, 73, 86, 247, 252, 252, 103, + 224, 112, 122, 51, 36, 1, 28, 39, 64, 159, 96, 111, 122, 51, 105, 41, 114, 43, 121, 51, 121, 114, 6, 27, 4, 18, 67, + 26, 121, 179, 121, 240, 2, 27, 67, 19, 67, 24, 96, 232, 240, 0, 252, 207, 28, 57, 67, 65, 97, 169, 122, 114, 125, 43, + 64, 148, 98, 106, 26, 210, 105, 235, 64, 209, 64, 211, 4, 27, 12, 27, 4, 58, 133, 107, 12, 18, 51, 128, 133, 41, 0, + 91, 30, 81, 24, 201, 66, 82, 64, 17, 35, 72, 82, 233, 70, 91, 99, 107, 141, 43, 70, 82, 99, 42, 8, 219, 122, 42, 98, + 44, 26, 228, 70, 73, 64, 212, 99, 169, 100, 44, 153, 12, 41, 0, 209, 58, 100, 105, 35, 72, 90, 233, 108, 40, 65, 17, + 56, 1, 240, 0, 252, 158, 104, 106, 4, 0, 28, 19, 12, 0, 59, 12, 135, 168, 66, 152, 217, 0, 135, 171, 28, 16, 247, 252, + 252, 84, 35, 0, 100, 232, 101, 43, 176, 1, 28, 40, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, + 8, 122, 51, 28, 58, 70, 156, 33, 0, 28, 75, 6, 27, 8, 82, 28, 8, 14, 25, 42, 0, 209, 248, 69, 96, 209, 0, 231, 124, + 72, 29, 73, 30, 247, 252, 251, 245, 28, 40, 247, 252, 252, 38, 28, 48, 247, 252, 252, 35, 37, 0, 231, 219, 30, 120, + 24, 192, 66, 123, 64, 24, 247, 252, 252, 39, 141, 42, 100, 104, 8, 210, 33, 255, 240, 0, 253, 105, 122, 42, 231, 183, + 35, 255, 231, 30, 72, 15, 73, 17, 247, 252, 251, 217, 231, 226, 34, 6, 231, 54, 34, 7, 231, 52, 34, 8, 231, 50, 34, + 9, 231, 48, 34, 10, 231, 46, 0, 4, 96, 144, 0, 63, 255, 255, 0, 127, 255, 255, 0, 255, 255, 255, 1, 255, 255, 255, 3, + 255, 255, 255, 87, 66, 70, 83, 19, 112, 129, 104, 19, 112, 128, 224, 19, 112, 129, 44, 19, 112, 129, 12, 19, 112, 129, + 0, 71, 80, 70, 192, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 177, 144, 14, 28, 24, 145, 13, 146, 12, + 147, 11, 247, 252, 251, 230, 28, 5, 33, 0, 152, 12, 34, 1, 28, 43, 156, 14, 240, 0, 251, 94, 40, 0, 208, 0, 226, 173, + 38, 223, 172, 32, 0, 118, 25, 169, 28, 32, 34, 64, 240, 0, 252, 215, 32, 1, 66, 64, 33, 0, 145, 17, 144, 16, 35, 227, + 120, 42, 0, 91, 24, 235, 120, 110, 120, 232, 70, 163, 70, 148, 120, 172, 73, 217, 147, 10, 34, 228, 75, 216, 0, 82, + 24, 105, 24, 170, 24, 235, 145, 9, 146, 8, 147, 7, 33, 235, 74, 213, 35, 236, 0, 73, 0, 91, 24, 105, 24, 170, 24, 235, + 145, 6, 146, 5, 147, 4, 70, 90, 122, 82, 70, 89, 122, 9, 70, 91, 70, 144, 70, 98, 70, 137, 122, 159, 122, 217, 6, 19, + 4, 50, 67, 26, 2, 35, 70, 138, 67, 19, 73, 201, 67, 3, 66, 139, 209, 0, 226, 159, 70, 91, 121, 25, 41, 0, 209, 0, 226, + 97, 70, 68, 4, 58, 2, 35, 67, 19, 70, 78, 70, 80, 67, 51, 6, 2, 67, 19, 70, 152, 41, 15, 208, 0, 226, 104, 28, 25, 152, + 12, 34, 1, 28, 43, 156, 14, 240, 0, 251, 1, 40, 0, 208, 0, 226, 80, 158, 7, 152, 9, 120, 50, 120, 3, 153, 10, 2, 27, + 6, 18, 67, 26, 156, 8, 120, 11, 152, 6, 67, 26, 120, 0, 120, 35, 153, 5, 144, 18, 4, 27, 67, 26, 120, 9, 70, 70, 75, + 175, 24, 183, 154, 4, 145, 19, 24, 235, 120, 18, 147, 15, 120, 28, 70, 146, 152, 12, 28, 57, 34, 1, 28, 43, 158, 14, + 70, 161, 240, 0, 250, 218, 40, 0, 208, 0, 226, 40, 120, 40, 120, 110, 120, 172, 6, 3, 4, 50, 67, 26, 70, 132, 2, 35, + 120, 232, 67, 19, 73, 159, 67, 3, 66, 139, 209, 0, 226, 91, 153, 19, 70, 82, 4, 19, 2, 10, 67, 19, 154, 18, 70, 73, + 67, 19, 6, 10, 28, 25, 67, 17, 209, 0, 226, 6, 70, 66, 24, 140, 152, 12, 28, 33, 34, 1, 28, 43, 158, 14, 240, 0, 250, + 178, 40, 0, 208, 0, 226, 0, 152, 9, 153, 8, 120, 2, 120, 11, 158, 10, 4, 27, 2, 18, 67, 26, 152, 7, 120, 51, 153, 6, + 67, 26, 120, 3, 120, 9, 6, 27, 67, 26, 24, 167, 155, 4, 154, 5, 156, 15, 145, 20, 120, 18, 120, 27, 120, 36, 70, 145, + 70, 154, 148, 21, 152, 12, 28, 57, 34, 1, 28, 43, 158, 14, 240, 0, 250, 141, 40, 0, 208, 0, 225, 219, 120, 40, 120, + 110, 120, 172, 6, 3, 4, 50, 67, 26, 70, 132, 2, 35, 120, 232, 67, 19, 73, 121, 67, 3, 66, 139, 209, 0, 226, 26, 70, + 82, 70, 73, 4, 19, 2, 10, 67, 19, 154, 20, 153, 21, 67, 19, 6, 10, 28, 25, 67, 17, 209, 0, 225, 185, 70, 66, 24, 140, + 152, 12, 28, 33, 34, 1, 28, 43, 158, 14, 240, 0, 250, 101, 40, 0, 208, 0, 225, 179, 152, 9, 153, 8, 120, 2, 120, 11, + 158, 10, 4, 27, 2, 18, 67, 26, 152, 7, 120, 51, 153, 6, 67, 26, 120, 3, 120, 9, 6, 27, 67, 26, 24, 167, 155, 4, 154, + 5, 156, 15, 145, 22, 120, 18, 120, 27, 120, 36, 70, 145, 70, 154, 148, 23, 152, 12, 28, 57, 34, 1, 28, 43, 158, 14, + 240, 0, 250, 64, 40, 0, 208, 0, 225, 142, 120, 40, 120, 110, 120, 172, 6, 3, 4, 50, 67, 26, 70, 132, 2, 35, 120, 232, + 67, 19, 73, 82, 67, 3, 66, 139, 209, 0, 225, 217, 70, 82, 70, 73, 4, 19, 2, 10, 67, 19, 154, 22, 153, 23, 67, 19, 6, + 10, 28, 25, 67, 17, 209, 0, 225, 108, 70, 66, 24, 140, 152, 12, 28, 33, 34, 1, 28, 43, 158, 14, 240, 0, 250, 24, 40, + 0, 208, 0, 225, 102, 152, 9, 153, 8, 120, 2, 120, 11, 158, 10, 4, 27, 2, 18, 67, 26, 152, 7, 120, 51, 153, 6, 67, 26, + 120, 3, 120, 9, 6, 27, 67, 26, 24, 167, 155, 4, 154, 5, 156, 15, 145, 24, 120, 18, 120, 27, 120, 36, 70, 145, 70, 154, + 148, 25, 152, 12, 28, 57, 34, 1, 28, 43, 158, 14, 240, 0, 249, 243, 40, 0, 208, 0, 225, 65, 120, 40, 120, 110, 120, + 172, 6, 3, 4, 50, 67, 26, 70, 132, 2, 35, 120, 232, 67, 19, 73, 44, 67, 3, 66, 139, 209, 0, 225, 152, 70, 82, 70, 73, + 4, 19, 2, 10, 67, 19, 154, 24, 153, 25, 67, 19, 6, 10, 28, 25, 67, 17, 209, 0, 225, 31, 70, 66, 24, 140, 152, 12, 28, + 33, 34, 1, 28, 43, 158, 14, 240, 0, 249, 203, 40, 0, 208, 0, 225, 25, 152, 9, 153, 8, 120, 2, 120, 11, 158, 10, 4, 27, + 2, 18, 67, 26, 152, 7, 120, 51, 153, 6, 67, 26, 120, 3, 120, 9, 6, 27, 67, 26, 24, 167, 155, 4, 154, 5, 156, 15, 145, + 26, 120, 18, 120, 27, 120, 36, 70, 145, 70, 154, 148, 27, 152, 12, 28, 57, 34, 1, 28, 43, 158, 14, 240, 0, 249, 166, + 40, 0, 208, 0, 224, 244, 120, 40, 120, 110, 120, 172, 6, 3, 4, 50, 67, 26, 70, 132, 2, 35, 120, 232, 67, 19, 73, 5, + 67, 3, 66, 139, 209, 0, 225, 27, 224, 9, 0, 0, 1, 199, 0, 0, 1, 201, 0, 0, 1, 215, 87, 66, 70, 83, 0, 0, 1, 217, 70, + 82, 70, 73, 4, 19, 2, 10, 67, 19, 154, 26, 153, 27, 67, 19, 6, 10, 28, 25, 67, 17, 209, 0, 224, 199, 70, 66, 24, 140, + 152, 12, 28, 33, 34, 1, 28, 43, 158, 14, 240, 0, 249, 115, 40, 0, 208, 0, 224, 193, 152, 9, 153, 8, 120, 2, 120, 11, + 158, 10, 4, 27, 2, 18, 67, 26, 152, 7, 120, 51, 153, 6, 67, 26, 120, 3, 120, 9, 6, 27, 67, 26, 24, 167, 155, 4, 154, + 5, 156, 15, 145, 28, 120, 18, 120, 27, 120, 36, 70, 145, 70, 154, 148, 29, 152, 12, 28, 57, 34, 1, 28, 43, 158, 14, + 240, 0, 249, 78, 40, 0, 208, 0, 224, 156, 120, 40, 120, 110, 120, 172, 6, 3, 4, 50, 67, 26, 70, 132, 2, 35, 120, 232, + 67, 19, 73, 158, 67, 3, 66, 139, 209, 0, 224, 255, 70, 82, 70, 73, 4, 19, 2, 10, 67, 19, 154, 28, 153, 29, 67, 19, 6, + 10, 28, 25, 67, 17, 208, 123, 70, 66, 24, 140, 152, 12, 28, 33, 34, 1, 28, 43, 158, 14, 240, 0, 249, 39, 40, 0, 209, + 118, 152, 9, 153, 8, 120, 2, 120, 11, 158, 10, 4, 27, 2, 18, 67, 26, 152, 7, 120, 51, 153, 6, 67, 26, 120, 3, 120, 9, + 6, 27, 67, 26, 24, 167, 155, 4, 154, 5, 156, 15, 145, 30, 120, 18, 120, 27, 120, 36, 70, 145, 70, 154, 148, 31, 152, + 12, 28, 57, 34, 1, 28, 43, 158, 14, 240, 0, 249, 3, 40, 0, 209, 82, 120, 40, 120, 110, 120, 172, 6, 3, 4, 50, 67, 26, + 70, 132, 2, 35, 120, 232, 67, 19, 73, 121, 67, 3, 66, 139, 209, 0, 224, 193, 70, 82, 70, 73, 4, 19, 2, 10, 67, 19, 154, + 30, 153, 31, 67, 19, 6, 10, 28, 25, 67, 17, 208, 49, 70, 66, 24, 84, 152, 12, 28, 33, 34, 1, 28, 43, 158, 14, 240, 0, + 248, 221, 40, 0, 209, 44, 152, 9, 153, 8, 120, 2, 120, 11, 158, 10, 4, 27, 2, 18, 67, 26, 152, 7, 120, 51, 67, 26, 120, + 3, 152, 12, 6, 27, 67, 26, 24, 167, 28, 57, 34, 1, 28, 43, 156, 14, 240, 0, 248, 196, 40, 0, 209, 20, 120, 46, 120, + 172, 6, 51, 70, 180, 120, 110, 120, 232, 4, 50, 67, 26, 2, 35, 67, 19, 73, 90, 67, 3, 66, 139, 209, 0, 224, 143, 171, + 44, 69, 155, 208, 2, 33, 16, 68, 139, 229, 125, 28, 40, 247, 252, 249, 30, 36, 0, 176, 49, 28, 32, 188, 60, 70, 144, + 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 28, 25, 152, 12, 34, 1, 28, 43, 156, 14, 240, 0, 248, 152, 28, 1, + 40, 0, 209, 231, 120, 46, 120, 172, 6, 51, 70, 180, 120, 110, 120, 232, 4, 50, 67, 26, 2, 35, 67, 19, 74, 68, 67, 3, + 66, 147, 209, 211, 155, 17, 154, 59, 66, 147, 208, 124, 153, 16, 69, 136, 208, 204, 154, 17, 70, 67, 50, 1, 146, 17, + 147, 16, 231, 198, 70, 90, 121, 17, 229, 97, 154, 59, 155, 17, 66, 154, 208, 92, 153, 16, 66, 185, 209, 0, 230, 230, + 51, 1, 147, 17, 151, 16, 230, 226, 154, 59, 155, 17, 66, 154, 208, 80, 153, 16, 66, 185, 209, 0, 229, 155, 51, 1, 147, + 17, 151, 16, 229, 151, 154, 59, 155, 17, 66, 154, 208, 68, 153, 16, 66, 185, 209, 0, 229, 220, 51, 1, 147, 17, 151, + 16, 229, 216, 154, 59, 155, 17, 66, 154, 208, 56, 153, 16, 66, 185, 209, 0, 230, 29, 51, 1, 147, 17, 151, 16, 230, 25, + 154, 59, 155, 17, 66, 154, 208, 44, 153, 16, 66, 185, 209, 0, 230, 94, 51, 1, 147, 17, 151, 16, 230, 90, 154, 59, 155, + 17, 66, 154, 208, 32, 153, 16, 66, 185, 209, 0, 230, 247, 51, 1, 147, 17, 151, 16, 230, 243, 154, 59, 155, 17, 66, 154, + 208, 20, 153, 16, 66, 185, 209, 0, 231, 53, 51, 1, 147, 17, 151, 16, 231, 49, 154, 59, 155, 17, 66, 154, 208, 8, 153, + 16, 66, 143, 209, 0, 231, 103, 154, 17, 151, 16, 50, 1, 146, 17, 231, 98, 35, 0, 147, 0, 151, 1, 156, 60, 152, 14, 153, + 13, 154, 12, 155, 11, 148, 2, 247, 255, 251, 71, 28, 4, 28, 40, 247, 252, 248, 123, 231, 92, 70, 67, 145, 0, 147, 1, + 231, 238, 87, 66, 70, 83, 71, 32, 71, 48, 230, 0, 0, 16, 225, 47, 255, 30, 230, 0, 0, 48, 225, 47, 255, 30, 230, 0, + 0, 80, 225, 47, 255, 30, 230, 0, 0, 112, 225, 47, 255, 30, 230, 0, 0, 144, 225, 47, 255, 30, 230, 0, 0, 176, 225, 47, + 255, 30, 230, 0, 0, 208, 225, 47, 255, 30, 230, 0, 0, 240, 225, 47, 255, 30, 230, 0, 1, 16, 225, 47, 255, 30, 230, 0, + 1, 48, 225, 47, 255, 30, 230, 0, 1, 80, 225, 47, 255, 30, 230, 0, 1, 112, 225, 47, 255, 30, 230, 0, 1, 144, 225, 47, + 255, 30, 230, 0, 1, 176, 225, 47, 255, 30, 230, 0, 1, 208, 225, 47, 255, 30, 230, 0, 1, 240, 225, 47, 255, 30, 230, + 0, 2, 16, 225, 47, 255, 30, 230, 0, 2, 48, 225, 47, 255, 30, 230, 0, 2, 80, 225, 47, 255, 30, 230, 0, 2, 112, 225, 47, + 255, 30, 230, 0, 2, 144, 225, 47, 255, 30, 230, 0, 2, 176, 225, 47, 255, 30, 230, 0, 2, 208, 225, 47, 255, 30, 230, + 0, 2, 240, 225, 47, 255, 30, 230, 0, 3, 16, 225, 47, 255, 30, 230, 0, 3, 48, 225, 47, 255, 30, 230, 0, 3, 80, 225, 47, + 255, 30, 230, 0, 3, 112, 225, 47, 255, 30, 230, 0, 3, 144, 225, 47, 255, 30, 230, 0, 3, 176, 225, 47, 255, 30, 230, + 0, 3, 208, 225, 47, 255, 30, 230, 0, 3, 240, 225, 47, 255, 30, 230, 0, 4, 16, 225, 47, 255, 30, 230, 0, 4, 48, 225, + 47, 255, 30, 230, 0, 4, 80, 225, 47, 255, 30, 230, 0, 4, 112, 225, 47, 255, 30, 230, 0, 4, 144, 225, 47, 255, 30, 230, + 0, 4, 176, 225, 47, 255, 30, 230, 0, 4, 208, 225, 47, 255, 30, 230, 0, 4, 240, 225, 47, 255, 30, 230, 0, 5, 16, 225, + 47, 255, 30, 230, 0, 5, 48, 225, 47, 255, 30, 230, 0, 5, 80, 225, 47, 255, 30, 230, 0, 6, 144, 225, 47, 255, 30, 230, + 0, 7, 240, 225, 47, 255, 30, 230, 0, 8, 16, 225, 47, 255, 30, 230, 0, 10, 16, 225, 47, 255, 30, 41, 0, 208, 52, 35, + 1, 34, 0, 180, 16, 66, 136, 211, 44, 36, 1, 7, 36, 66, 161, 210, 4, 66, 129, 210, 2, 1, 9, 1, 27, 231, 248, 0, 228, + 66, 161, 210, 4, 66, 129, 210, 2, 0, 73, 0, 91, 231, 248, 66, 136, 211, 1, 26, 64, 67, 26, 8, 76, 66, 160, 211, 2, 27, + 0, 8, 92, 67, 34, 8, 140, 66, 160, 211, 2, 27, 0, 8, 156, 67, 34, 8, 204, 66, 160, 211, 2, 27, 0, 8, 220, 67, 34, 40, + 0, 208, 3, 9, 27, 208, 1, 9, 9, 231, 227, 28, 16, 188, 16, 71, 112, 181, 2, 240, 0, 248, 94, 32, 0, 188, 6, 71, 16, + 70, 192, 181, 3, 247, 255, 255, 191, 188, 14, 67, 66, 26, 137, 71, 24, 70, 192, 41, 0, 208, 65, 180, 16, 28, 4, 64, + 76, 70, 164, 35, 1, 34, 0, 41, 0, 213, 0, 66, 73, 40, 0, 213, 0, 66, 64, 66, 136, 211, 44, 36, 1, 7, 36, 66, 161, 210, + 4, 66, 129, 210, 2, 1, 9, 1, 27, 231, 248, 0, 228, 66, 161, 210, 4, 66, 129, 210, 2, 0, 73, 0, 91, 231, 248, 66, 136, + 211, 1, 26, 64, 67, 26, 8, 76, 66, 160, 211, 2, 27, 0, 8, 92, 67, 34, 8, 140, 66, 160, 211, 2, 27, 0, 8, 156, 67, 34, + 8, 204, 66, 160, 211, 2, 27, 0, 8, 220, 67, 34, 40, 0, 208, 3, 9, 27, 208, 1, 9, 9, 231, 227, 28, 16, 70, 100, 44, 0, + 213, 0, 66, 64, 188, 16, 71, 112, 181, 2, 240, 0, 248, 11, 32, 0, 188, 6, 71, 16, 181, 3, 247, 255, 255, 179, 188, 14, + 67, 66, 26, 137, 71, 24, 70, 192, 71, 112, 70, 192, 181, 112, 28, 14, 28, 21, 28, 4, 42, 3, 217, 32, 28, 51, 67, 3, + 7, 154, 208, 18, 120, 35, 120, 8, 66, 131, 209, 27, 30, 106, 224, 6, 52, 1, 49, 1, 120, 35, 120, 8, 58, 1, 66, 131, + 209, 18, 42, 0, 209, 246, 32, 0, 188, 112, 188, 2, 71, 8, 104, 2, 104, 11, 66, 154, 209, 4, 61, 4, 48, 4, 49, 4, 45, + 3, 216, 246, 28, 4, 45, 0, 209, 224, 231, 238, 26, 24, 231, 237, 181, 240, 28, 7, 28, 14, 28, 4, 28, 21, 28, 8, 28, + 17, 42, 15, 217, 3, 28, 51, 67, 59, 7, 154, 208, 11, 41, 0, 208, 5, 34, 0, 92, 131, 84, 163, 50, 1, 66, 138, 209, 250, + 28, 56, 188, 240, 188, 2, 71, 8, 28, 58, 28, 49, 28, 40, 104, 11, 96, 19, 104, 75, 96, 83, 104, 139, 96, 147, 104, 203, + 56, 16, 96, 211, 49, 16, 50, 16, 40, 15, 216, 242, 28, 43, 59, 16, 9, 26, 1, 17, 50, 1, 1, 18, 26, 89, 24, 176, 24, + 188, 41, 3, 217, 216, 34, 0, 88, 131, 80, 163, 50, 4, 26, 139, 43, 3, 216, 249, 31, 11, 8, 154, 0, 145, 50, 1, 0, 146, + 26, 89, 24, 128, 24, 164, 231, 200, 181, 240, 28, 7, 70, 140, 28, 16, 28, 57, 7, 186, 208, 14, 40, 0, 208, 73, 70, 98, + 6, 19, 56, 1, 14, 27, 34, 3, 224, 2, 40, 0, 208, 65, 56, 1, 112, 11, 49, 1, 66, 17, 209, 248, 28, 5, 28, 10, 40, 3, + 217, 46, 35, 255, 70, 98, 64, 26, 2, 19, 67, 19, 4, 26, 28, 20, 28, 14, 67, 28, 40, 15, 217, 18, 28, 2, 28, 11, 58, + 16, 96, 28, 96, 92, 96, 156, 96, 220, 51, 16, 42, 15, 216, 247, 28, 3, 59, 16, 28, 29, 9, 27, 51, 1, 34, 15, 1, 27, + 64, 21, 24, 206, 45, 3, 217, 13, 34, 0, 80, 180, 50, 4, 26, 171, 43, 3, 216, 250, 31, 43, 28, 29, 8, 155, 51, 1, 34, + 3, 0, 155, 64, 21, 24, 246, 28, 50, 45, 0, 208, 7, 70, 97, 6, 11, 14, 25, 35, 0, 84, 209, 51, 1, 66, 157, 209, 251, + 28, 56, 188, 240, 188, 2, 71, 8, 70, 192, 181, 48, 28, 11, 67, 3, 7, 154, 209, 28, 104, 2, 104, 11, 66, 154, 209, 24, + 76, 16, 25, 19, 67, 147, 74, 15, 66, 19, 209, 11, 28, 20, 48, 4, 49, 4, 104, 2, 104, 11, 66, 154, 209, 11, 77, 9, 25, + 83, 67, 147, 66, 35, 208, 244, 32, 0, 224, 9, 120, 10, 66, 154, 209, 5, 48, 1, 49, 1, 120, 3, 43, 0, 209, 247, 120, + 10, 26, 152, 188, 48, 188, 2, 71, 8, 254, 254, 254, 255, 128, 128, 128, 128, 181, 48, 28, 4, 7, 129, 208, 10, 120, 3, + 43, 0, 208, 33, 34, 3, 224, 2, 120, 3, 43, 0, 208, 24, 48, 1, 66, 16, 209, 249, 104, 2, 77, 13, 25, 83, 67, 147, 74, + 13, 66, 19, 209, 11, 28, 17, 48, 4, 104, 2, 77, 9, 25, 83, 67, 147, 66, 11, 208, 248, 120, 3, 43, 0, 208, 3, 48, 1, + 120, 3, 43, 0, 209, 251, 27, 0, 188, 48, 188, 2, 71, 8, 32, 0, 231, 250, 70, 192, 254, 254, 254, 255, 128, 128, 128, + 128, 73, 79, 83, 32, 109, 111, 100, 117, 108, 101, 0, 0, 0, 0, 0, 1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 19, 114, 74, 60, 0, 15, 66, 64, 47, 100, 101, 118, 47, 102, 97, 116, 47, 108, 111, 103, 0, 0, 0, 0, 87, 66, + 70, 83, 32, 110, 111, 116, 32, 101, 110, 111, 117, 103, 104, 32, 109, 101, 109, 111, 114, 121, 33, 0, 101, 104, 99, + 32, 108, 111, 111, 112, 32, 101, 110, 116, 114, 121, 0, 0, 47, 100, 101, 118, 47, 117, 115, 98, 47, 101, 104, 99, 0, + 0, 0, 0, 47, 100, 101, 118, 47, 117, 115, 98, 47, 101, 104, 99, 47, 0, 0, 0, 85, 77, 83, 32, 73, 110, 105, 116, 0, 0, + 0, 0, 87, 66, 70, 83, 32, 79, 112, 101, 110, 40, 41, 0, 85, 77, 83, 32, 102, 97, 105, 108, 0, 0, 0, 0, 47, 100, 101, + 118, 47, 109, 108, 111, 97, 100, 0, 0, 85, 83, 66, 83, 116, 111, 114, 97, 103, 101, 95, 67, 108, 111, 115, 101, 40, + 41, 0, 0, 85, 83, 66, 32, 65, 108, 108, 111, 99, 58, 32, 110, 111, 116, 32, 101, 110, 111, 117, 103, 104, 32, 109, 101, + 109, 111, 114, 121, 33, 0, 0, 0, 119, 98, 102, 115, 32, 101, 114, 114, 111, 114, 0, 0, 97, 108, 108, 111, 99, 97, 116, + 105, 110, 103, 32, 109, 101, 109, 111, 114, 121, 0, 0, 0, 98, 97, 100, 32, 109, 97, 103, 105, 99, 0, 0, 0, 104, 100, + 32, 115, 101, 99, 116, 111, 114, 32, 115, 105, 122, 101, 32, 100, 111, 101, 115, 110, 39, 116, 32, 109, 97, 116, 99, + 104, 0, 0, 0, 0, 104, 100, 32, 110, 117, 109, 32, 115, 101, 99, 116, 111, 114, 32, 100, 111, 101, 115, 110, 39, 116, + 32, 109, 97, 116, 99, 104, 0 }; diff --git a/source/mload/mload.c b/source/mload/mload.c index e8122302..46837cd0 100644 --- a/source/mload/mload.c +++ b/source/mload/mload.c @@ -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 - { - mload_fd=IOS_Open(mload_fs, 0); + 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); - } + 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); + ret=IOS_Close(mload_fd); - mload_fd=-1; + 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); + hid = iosCreateHeap(0x800); - if(hid<0) return hid; + if (hid<0) return hid; - ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_MLOAD_THREAD_ID, ":"); + ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_MLOAD_THREAD_ID, ":"); - iosDestroyHeap(hid); + 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); + 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); + ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_GET_LOAD_BASE, ":ii",starlet_base, size); - iosDestroyHeap(hid); + 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); + hid = iosCreateHeap(len+0x800); - if(hid<0) return hid; + if (hid<0) return hid; - buf= iosAlloc(hid, len); + buf= iosAlloc(hid, len); - if(!buf) {ret= -1;goto out;} + if (!buf) { + ret= -1; + goto out; + } - memcpy(buf, addr,len); + memcpy(buf, addr,len); - ret = IOS_IoctlvFormat(hid, mload_fd, MLOAD_LOAD_MODULE, ":d", buf, 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, ":"); + 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); + iosDestroyHeap(hid); -return ret; + return ret; } @@ -158,119 +158,110 @@ 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; nphnum; n++) - { - entries=(void *) (elf+p); - p+=sizeof(elfphentry); + for (n=0; nphnum; n++) { + entries=(void *) (elf+p); + p+=sizeof(elfphentry); - if(entries->type == 4) - { - adr=(void *) (elf + entries->offset); + 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)) - { - case 0x9: - data_elf->start= (void *) getbe32(m+4); - break; - case 0x7D: - data_elf->prio= getbe32(m+4); - break; - case 0x7E: - data_elf->size_stack= getbe32(m+4); - break; - case 0x7F: - data_elf->stack= (void *) (getbe32(m+4)); - break; + for (m=4; m < entries->memsz; m+=8) { + switch (getbe32(m)) { + case 0x9: + data_elf->start= (void *) getbe32(m+4); + break; + case 0x7D: + data_elf->prio= getbe32(m+4); + break; + case 0x7E: + data_elf->size_stack= getbe32(m+4); + break; + case 0x7F: + data_elf->stack= (void *) (getbe32(m+4)); + break; - } + } - } + } - } - 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); + 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); + ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_RUN_THREAD, "iiii:", starlet_addr,starlet_top_stack, stack_size, priority); - iosDestroyHeap(hid); + 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); + hid = iosCreateHeap(0x800); - if(hid<0) return hid; + if (hid<0) return hid; - ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_STOP_THREAD, "i:", id); + ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_STOP_THREAD, "i:", id); - iosDestroyHeap(hid); + iosDestroyHeap(hid); -return ret; + return ret; } @@ -278,154 +269,145 @@ 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); + hid = iosCreateHeap(0x800); - if(hid<0) return hid; + if (hid<0) return hid; - ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_CONTINUE_THREAD, "i:", id); + ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_CONTINUE_THREAD, "i:", id); - iosDestroyHeap(hid); + 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; - return IOS_Seek(mload_fd, offset, mode); +int mload_seek(int offset, int mode) { + if (mload_init()<0) return -1; + return IOS_Seek(mload_fd, offset, mode); } /*--------------------------------------------------------------------------------------------------------------*/ // read bytes from starlet (it update the offset) -int mload_read(void* buf, u32 size) -{ - if(mload_init()<0) return -1; - return IOS_Read(mload_fd, buf, size); +int mload_read(void* buf, u32 size) { + if (mload_init()<0) return -1; + return IOS_Read(mload_fd, buf, size); } /*--------------------------------------------------------------------------------------------------------------*/ // write bytes from starlet (it update the offset) -int mload_write(const void * buf, u32 size) -{ - if(mload_init()<0) return -1; - return IOS_Write(mload_fd, buf, size); +int mload_write(const void * buf, u32 size) { + if (mload_init()<0) return -1; + return IOS_Write(mload_fd, buf, 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); + 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); + ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_MEMSET, "iii:", starlet_addr, set, len); - iosDestroyHeap(hid); + 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); + 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; + ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_GET_EHCI_DATA, ":"); + if (ret<0) return NULL; - iosDestroyHeap(hid); + 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); + 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); + ret= IOS_IoctlvFormat(hid, mload_fd, MLOAD_SET_ES_IOCTLV, "i:", starlet_addr); - iosDestroyHeap(hid); + iosDestroyHeap(hid); -return ret; + return ret; } -static u32 ios_36[16] ATTRIBUTE_ALIGN(32)= -{ - 0, // DI_EmulateCmd - 0, - 0x2022DDAC, // dvd_read_controlling_data - 0x20201010+1, // handle_di_cmd_reentry (thumb) - 0x20200b9c+1, // ios_shared_alloc_aligned (thumb) - 0x20200b70+1, // ios_shared_free (thumb) - 0x20205dc0+1, // ios_memcpy (thumb) - 0x20200048+1, // ios_fatal_di_error (thumb) - 0x20202b4c+1, // ios_doReadHashEncryptedState (thumb) - 0x20203934+1, // ios_printf (thumb) +static u32 ios_36[16] ATTRIBUTE_ALIGN(32)= { + 0, // DI_EmulateCmd + 0, + 0x2022DDAC, // dvd_read_controlling_data + 0x20201010+1, // handle_di_cmd_reentry (thumb) + 0x20200b9c+1, // ios_shared_alloc_aligned (thumb) + 0x20200b70+1, // ios_shared_free (thumb) + 0x20205dc0+1, // ios_memcpy (thumb) + 0x20200048+1, // ios_fatal_di_error (thumb) + 0x20202b4c+1, // ios_doReadHashEncryptedState (thumb) + 0x20203934+1, // ios_printf (thumb) }; -static u32 ios_38[16] ATTRIBUTE_ALIGN(32)= -{ - 0, // DI_EmulateCmd - 0, - 0x2022cdac, // dvd_read_controlling_data - 0x20200d38+1, // handle_di_cmd_reentry (thumb) - 0x202008c4+1, // ios_shared_alloc_aligned (thumb) - 0x20200898+1, // ios_shared_free (thumb) - 0x20205b80+1, // ios_memcpy (thumb) - 0x20200048+1, // ios_fatal_di_error (thumb) - 0x20202874+1, // ios_doReadHashEncryptedState (thumb) - 0x2020365c+1, // ios_printf (thumb) +static u32 ios_38[16] ATTRIBUTE_ALIGN(32)= { + 0, // DI_EmulateCmd + 0, + 0x2022cdac, // dvd_read_controlling_data + 0x20200d38+1, // handle_di_cmd_reentry (thumb) + 0x202008c4+1, // ios_shared_alloc_aligned (thumb) + 0x20200898+1, // ios_shared_free (thumb) + 0x20205b80+1, // ios_memcpy (thumb) + 0x20200048+1, // ios_fatal_di_error (thumb) + 0x20202874+1, // ios_doReadHashEncryptedState (thumb) + 0x2020365c+1, // ios_printf (thumb) }; @@ -433,62 +415,57 @@ int load_ehc_module() { int is_ios=0; - if(mload_module(ehcmodule, size_ehcmodule)<0) return -1; - usleep(350*1000); + if (mload_module(ehcmodule, size_ehcmodule)<0) return -1; + usleep(350*1000); - // Test for IOS + // Test for IOS - mload_seek(0x20207c84, SEEK_SET); - mload_read(patch_datas, 4); - if(patch_datas[0]==0x6e657665) - { - is_ios=38; - } - else - { - is_ios=36; - } + mload_seek(0x20207c84, SEEK_SET); + mload_read(patch_datas, 4); + if (patch_datas[0]==0x6e657665) { + is_ios=38; + } else { + 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 + 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 - mload_seek(0x1377E000, SEEK_SET); // copy dip_plugin in the starlet - mload_write(dip_plugin,size_dip_plugin); + mload_seek(0x1377E000, SEEK_SET); // copy dip_plugin in the starlet + mload_write(dip_plugin,size_dip_plugin); - // enables DIP plugin - mload_seek(0x20209040, SEEK_SET); - mload_write(ios_36, 4); + // enables DIP plugin + mload_seek(0x20209040, SEEK_SET); + mload_write(ios_36, 4); - } - if(is_ios==38) - { - // IOS 38 + } + if (is_ios==38) { + // IOS 38 - memcpy(ios_38, dip_plugin, 4); // copy the entry_point - memcpy(dip_plugin, ios_38, 4*10); // copy the adresses from the array + memcpy(ios_38, dip_plugin, 4); // copy the entry_point + memcpy(dip_plugin, ios_38, 4*10); // copy the adresses from the array - mload_seek(0x1377E000, SEEK_SET); // copy dip_plugin in the starlet - mload_write(dip_plugin,size_dip_plugin); + mload_seek(0x1377E000, SEEK_SET); // copy dip_plugin in the starlet + mload_write(dip_plugin,size_dip_plugin); - // enables DIP plugin - mload_seek(0x20208030, SEEK_SET); - mload_write(ios_38, 4); + // enables DIP plugin + mload_seek(0x20208030, SEEK_SET); + mload_write(ios_38, 4); - } + } - mload_close(); + mload_close(); -return 0; + return 0; } int patch_cios_data() { patch_datas[0]=*((u32 *) (dip_plugin+16*4)); - mload_set_ES_ioctlv_vector((void *) patch_datas[0]); - return 1; + mload_set_ES_ioctlv_vector((void *) patch_datas[0]); + return 1; } diff --git a/source/mload/mload.h b/source/mload/mload.h index ae2a0f53..e1f8b90f 100644 --- a/source/mload/mload.h +++ b/source/mload/mload.h @@ -50,12 +50,11 @@ 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; - u32 ident3; + u32 ident1; + u32 ident2; + u32 ident3; u32 machinetype; u32 version; u32 entry; @@ -68,127 +67,125 @@ typedef struct u16 shentsize; u16 shnum; u16 shtrndx; -} elfheader; + } elfheader; -typedef struct -{ - u32 type; - u32 offset; - u32 vaddr; - u32 paddr; - u32 filesz; - u32 memsz; - u32 flags; - u32 align; -} elfphentry; + typedef struct { + u32 type; + u32 offset; + u32 vaddr; + u32 paddr; + u32 filesz; + u32 memsz; + u32 flags; + u32 align; + } elfphentry; -typedef struct -{ - void *start; - int prio; - void *stack; - int size_stack; -} data_elf; + typedef struct { + void *start; + int prio; + void *stack; + int size_stack; + } 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 diff --git a/source/network/URL_List.cpp b/source/network/URL_List.cpp index 8e37437d..76ffec8e 100644 --- a/source/network/URL_List.cpp +++ b/source/network/URL_List.cpp @@ -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' - && file.data[cnt-3] == 'e' && file.data[cnt-4] == 'r' && file.data[cnt-5] == 'h') { + 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); + return stricmp((char *) ab->URL, (char *) bb->URL); } -void URL_List::SortList() -{ +void URL_List::SortList() { qsort(Links, urlcount, sizeof(Link_Info), ListCompare); } diff --git a/source/network/URL_List.h b/source/network/URL_List.h index 7024df8a..9e47b0b7 100644 --- a/source/network/URL_List.h +++ b/source/network/URL_List.h @@ -14,26 +14,25 @@ typedef struct { bool direct; } Link_Info; -class URL_List -{ - public: - //!Constructor - //!\param url from where to get the list of links - URL_List(const char *url); - //!Destructor - ~URL_List(); - //! Get the a filepath of the list - //!\param list index - char * GetURL(int index); - //! Is it a direct URL or just a file or path under the main url - bool IsDirectURL(int index); - //! Get the number of links counted - int GetURLCount(); - //! Sort list - void SortList(); - protected: - int urlcount; - Link_Info *Links; +class URL_List { +public: + //!Constructor + //!\param url from where to get the list of links + URL_List(const char *url); + //!Destructor + ~URL_List(); + //! Get the a filepath of the list + //!\param list index + char * GetURL(int index); + //! Is it a direct URL or just a file or path under the main url + bool IsDirectURL(int index); + //! Get the number of links counted + int GetURLCount(); + //! Sort list + void SortList(); +protected: + int urlcount; + Link_Info *Links; }; #endif diff --git a/source/network/dns.c b/source/network/dns.c index 91fc1dea..07d15288 100644 --- a/source/network/dns.c +++ b/source/network/dns.c @@ -8,19 +8,18 @@ * @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) -{ - //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) { - return 0; - } - - u32 *ip = (u32*)host->h_addr_list[0]; - return *ip; +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) { + return 0; + } + + u32 *ip = (u32*)host->h_addr_list[0]; + return *ip; } @@ -32,9 +31,9 @@ u32 getipbyname(char *domain) //The last resolved domain name will always be at the front //This will allow heavily used domainnames to always stay cached struct dnsentry { - char *domain; - u32 ip; - struct dnsentry *nextnode; + char *domain; + u32 ip; + struct dnsentry *nextnode; } ; static struct dnsentry *firstdnsentry = NULL; @@ -44,79 +43,71 @@ 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) -{ - //Search if this domainname is already cached - struct dnsentry *node = firstdnsentry; - struct dnsentry *previousnode = NULL; - - 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) - previousnode->nextnode = node->nextnode; - - if(node != firstdnsentry) - node->nextnode = firstdnsentry; - firstdnsentry = node; - - return node->ip; - } - //Go to the next element in the list - previousnode = node; - node = node->nextnode; - } - u32 ip = getipbyname(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) { - return ip; - } - - newnode->ip = ip; - newnode->domain = malloc(strlen(domain)+1); - if(newnode->domain == NULL) - { - free(newnode); - return ip; - } - strcpy(newnode->domain, domain); - - newnode->nextnode = firstdnsentry; - firstdnsentry = newnode; - dnsentrycount++; +u32 getipbynamecached(char *domain) { + //Search if this domainname is already cached + struct dnsentry *node = firstdnsentry; + struct dnsentry *previousnode = NULL; - //If the cache grows too big delete the last (and probably least important) node of the list - 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) - { - previousnode = node; - node = node->nextnode; - } - - if(node == NULL) - { - printf("Configuration error, MAX_DNS_ENTRIES reached while the list is empty\n"); - exit(1); - } else if(previousnode == NULL) - { - firstdnsentry = NULL; - } else { - previousnode->nextnode = NULL; - } - - free(node->domain); - free(node); - dnsentrycount--; - } + 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) + previousnode->nextnode = node->nextnode; - return newnode->ip; + if (node != firstdnsentry) + node->nextnode = firstdnsentry; + firstdnsentry = node; + + return node->ip; + } + //Go to the next element in the list + previousnode = node; + node = node->nextnode; + } + u32 ip = getipbyname(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) { + return ip; + } + + newnode->ip = ip; + newnode->domain = malloc(strlen(domain)+1); + if (newnode->domain == NULL) { + free(newnode); + return ip; + } + strcpy(newnode->domain, domain); + + newnode->nextnode = firstdnsentry; + firstdnsentry = newnode; + dnsentrycount++; + + //If the cache grows too big delete the last (and probably least important) node of the list + 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) { + previousnode = node; + node = node->nextnode; + } + + if (node == NULL) { + printf("Configuration error, MAX_DNS_ENTRIES reached while the list is empty\n"); + exit(1); + } else if (previousnode == NULL) { + firstdnsentry = NULL; + } else { + previousnode->nextnode = NULL; + } + + free(node->domain); + free(node); + dnsentrycount--; + } + + return newnode->ip; } diff --git a/source/network/dns.h b/source/network/dns.h index 28617246..b9313a0e 100644 --- a/source/network/dns.h +++ b/source/network/dns.h @@ -9,12 +9,11 @@ #include //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 } diff --git a/source/network/http.c b/source/network/http.c index 864e6a71..29d84e78 100644 --- a/source/network/http.c +++ b/source/network/http.c @@ -11,19 +11,19 @@ const struct block emptyblock = {0, NULL}; // Write our message to the server static s32 send_message(s32 server, char *msg) { - s32 bytes_transferred = 0; + s32 bytes_transferred = 0; s32 remaining = strlen(msg); while (remaining) { if ((bytes_transferred = net_write(server, msg, remaining > NET_BUFFER_SIZE ? NET_BUFFER_SIZE : remaining)) > 0) { remaining -= bytes_transferred; - usleep (20 * 1000); + usleep (20 * 1000); } else if (bytes_transferred < 0) { return bytes_transferred; } else { return -ENODATA; } } - return 0; + return 0; } /** @@ -34,22 +34,22 @@ static s32 send_message(s32 server, char *msg) { * @return s32 The connection to the server (negative number if connection could not be established) */ static s32 server_connect(u32 ipaddress, u32 socket_port) { - //Initialize socket - s32 connection = net_socket(AF_INET, SOCK_STREAM, IPPROTO_IP); + //Initialize socket + s32 connection = net_socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if (connection < 0) return connection; - struct sockaddr_in connect_addr; - memset(&connect_addr, 0, sizeof(connect_addr)); - connect_addr.sin_family = AF_INET; - connect_addr.sin_port = socket_port; - connect_addr.sin_addr.s_addr= ipaddress; + struct sockaddr_in connect_addr; + memset(&connect_addr, 0, sizeof(connect_addr)); + connect_addr.sin_family = AF_INET; + connect_addr.sin_port = socket_port; + connect_addr.sin_addr.s_addr= ipaddress; - //Attemt to open the socket - if (net_connect(connection, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) == -1) { - net_close(connection); - return -1; - } - return connection; + //Attemt to open the socket + if (net_connect(connection, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) == -1) { + net_close(connection); + return -1; + } + return connection; } //The amount of memory in bytes reserved initially to store the HTTP response in @@ -67,179 +67,164 @@ 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) -{ - //Create a block of memory to put in the response - struct block buffer; - buffer.data = malloc(HTTP_BUFFER_SIZE); - buffer.size = HTTP_BUFFER_SIZE; +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) { - return emptyblock; - } + 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; + //The offset variable always points to the first byte of memory that is free in the buffer + u32 offset = 0; - 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); + 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) - { - //printf("Connection error from net_read() Errorcode: %i\n", bytes_read); - return emptyblock; - } + //Anything below 0 is an error in the connection + 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) - { - break; - } + //No more bytes were read into the buffer, + //we assume this means the HTTP response is done + if (bytes_read == 0) { + break; + } - offset += bytes_read; + offset += bytes_read; - //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) - { - buffer.size += HTTP_BUFFER_GROWTH; - buffer.data = realloc(buffer.data, buffer.size); + //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) { + buffer.size += HTTP_BUFFER_GROWTH; + buffer.data = realloc(buffer.data, buffer.size); - if(buffer.data == NULL) - { - return emptyblock; - } - } - } + if (buffer.data == NULL) { + return emptyblock; + } + } + } - //At the end of above loop offset should be precisely the amount of bytes that were read from the connection - buffer.size = offset; + //At the end of above loop offset should be precisely the amount of bytes that were read from the connection + buffer.size = offset; - //Shrink the size of the buffer so the data fits exactly in it - realloc(buffer.data, buffer.size); + //Shrink the size of the buffer so the data fits exactly in it + realloc(buffer.data, buffer.size); - return buffer; + return buffer; } /** * 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) -{ - //Check if the url starts with "http://", if not it is not considered a valid url - if(strncmp(url, "http://", strlen("http://")) != 0) - { - //printf("URL '%s' doesn't start with 'http://'\n", url); - return emptyblock; - } +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) { + //printf("URL '%s' doesn't start with 'http://'\n", url); + return emptyblock; + } - //Locate the path part of the url by searching for '/' past "http://" - char *path = strchr(url + strlen("http://"), '/'); + //Locate the path part of the url by searching for '/' past "http://" + 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) - { - //printf("URL '%s' has no PATH part\n", url); - return emptyblock; - } + //At the very least the url has to end with '/', ending with just a domain is invalid + if (path == NULL) { + //printf("URL '%s' has no PATH part\n", url); + return emptyblock; + } - //Extract the domain part out of the url - int domainlength = path - url - strlen("http://"); + //Extract the domain part out of the url + int domainlength = path - url - strlen("http://"); - if(domainlength == 0) - { - //printf("No domain part in URL '%s'\n", url); - return emptyblock; - } + if (domainlength == 0) { + //printf("No domain part in URL '%s'\n", url); + return emptyblock; + } - char domain[domainlength + 1]; - strncpy(domain, url + strlen("http://"), domainlength); - domain[domainlength] = '\0'; + char domain[domainlength + 1]; + strncpy(domain, url + strlen("http://"), domainlength); + domain[domainlength] = '\0'; - //Parsing of the URL is done, start making an actual connection - u32 ipaddress = getipbynamecached(domain); + //Parsing of the URL is done, start making an actual connection + u32 ipaddress = getipbynamecached(domain); - if(ipaddress == 0) - { - //printf("\ndomain %s could not be resolved", domain); - return emptyblock; - } + if (ipaddress == 0) { + //printf("\ndomain %s could not be resolved", domain); + return emptyblock; + } - s32 connection = server_connect(ipaddress, 80); + s32 connection = server_connect(ipaddress, 80); - if(connection < 0) { - //printf("Error establishing connection"); - return emptyblock; - } + if (connection < 0) { + //printf("Error establishing connection"); + return emptyblock; + } - //Form a nice request header to send to the webserver - char* headerformat = "GET %s HTTP/1.0\r\nHost: %s\r\nUser-Agent: WiiEarthh 1.0\r\n\r\n";; - char header[strlen(headerformat) + strlen(domain) + strlen(path)]; - sprintf(header, headerformat, path, domain); + //Form a nice request header to send to the webserver + char* headerformat = "GET %s HTTP/1.0\r\nHost: %s\r\nUser-Agent: WiiEarthh 1.0\r\n\r\n";; + char header[strlen(headerformat) + strlen(domain) + strlen(path)]; + sprintf(header, headerformat, path, domain); - //Do the request and get the response - send_message(connection, header); - struct block response = read_message(connection); - net_close(connection); + //Do the request and get the response + send_message(connection, header); + struct block response = read_message(connection); + net_close(connection); - //Search for the 4-character sequence \r\n\r\n in the response which signals the start of the http payload (file) - unsigned char *filestart = NULL; - u32 filesize = 0; - int i; - 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') - { - filestart = response.data + i + 1; - filesize = response.size - i - 1; - break; - } - } + //Search for the 4-character sequence \r\n\r\n in the response which signals the start of the http payload (file) + unsigned char *filestart = NULL; + u32 filesize = 0; + int i; + 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') { + filestart = response.data + i + 1; + filesize = response.size - i - 1; + break; + } + } - if(filestart == NULL) - { - //printf("HTTP Response was without a file\n"); - free(response.data); - return emptyblock; - } + if (filestart == NULL) { + //printf("HTTP Response was without a file\n"); + free(response.data); + return emptyblock; + } - //Copy the file part of the response into a new memoryblock to return - struct block file; - file.data = malloc(filesize); - file.size = filesize; + //Copy the file part of the response into a new memoryblock to return + struct block file; + file.data = malloc(filesize); + file.size = filesize; - if(file.data == NULL) - { - //printf("No more memory to copy file from HTTP response\n"); - free(response.data); - return emptyblock; - } + if (file.data == NULL) { + //printf("No more memory to copy file from HTTP response\n"); + free(response.data); + return emptyblock; + } - memcpy(file.data, filestart, filesize); + memcpy(file.data, filestart, filesize); - //Dispose of the original response - free(response.data); + //Dispose of the original response + free(response.data); + + return file; +} + +s32 GetConnection(char * domain) { + + u32 ipaddress = getipbynamecached(domain); + if (ipaddress == 0) { + return -1; + } + s32 connection = server_connect(ipaddress, 80); + return connection; - return file; -} - -s32 GetConnection(char * domain) { - - u32 ipaddress = getipbynamecached(domain); - if(ipaddress == 0) { - return -1; - } - s32 connection = server_connect(ipaddress, 80); - return connection; - } diff --git a/source/network/http.h b/source/network/http.h index 0bcf90a2..6031e7ec 100644 --- a/source/network/http.h +++ b/source/network/http.h @@ -7,25 +7,23 @@ #include #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 -{ - u32 size; - unsigned char *data; -}; + /** + * A simple structure to keep track of the size of a malloc()ated block of memory + */ + 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 } diff --git a/source/network/networkops.cpp b/source/network/networkops.cpp index 497986d7..d1c12f82 100644 --- a/source/network/networkops.cpp +++ b/source/network/networkops.cpp @@ -40,112 +40,107 @@ static bool networkHalt = true; ***************************************************************************/ void Initialize_Network(void) { - if(networkinitialized) return; + if (networkinitialized) return; - s32 result; + s32 result; result = if_config(IP, NULL, NULL, true); - if(result < 0) { + if (result < 0) { networkinitialized = false; - return; - } else { + return; + } else { networkinitialized = true; return; - } + } } /**************************************************************************** * 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) { - s32 kd_fd, ret; - STACK_ALIGN(u8, kd_buf, 0x20, 32); + 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) - onlinefix = false; // fixed no IOS reload needed - IOS_Close(kd_fd); - } - } - return onlinefix; + 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) + onlinefix = false; // fixed no IOS reload needed + IOS_Close(kd_fd); + } + } + return onlinefix; } -s32 network_request(const char * request) -{ - char buf[1024]; - char *ptr = NULL; +s32 network_request(const char * request) { + char buf[1024]; + char *ptr = NULL; - u32 cnt, size; - s32 ret; + u32 cnt, size; + s32 ret; - /* Send request */ - ret = net_send(connection, request, strlen(request), 0); - if (ret < 0) - return ret; + /* Send request */ + ret = net_send(connection, request, strlen(request), 0); + if (ret < 0) + return ret; - /* Clear buffer */ - memset(buf, 0, sizeof(buf)); + /* Clear buffer */ + memset(buf, 0, sizeof(buf)); - /* Read HTTP header */ - for (cnt = 0; !strstr(buf, "\r\n\r\n"); cnt++) - if (net_recv(connection, buf + cnt, 1, 0) <= 0) - return -1; + /* Read HTTP header */ + for (cnt = 0; !strstr(buf, "\r\n\r\n"); cnt++) + if (net_recv(connection, buf + cnt, 1, 0) <= 0) + return -1; - /* HTTP request OK? */ - if (!strstr(buf, "HTTP/1.1 200 OK")) - return -1; - /* Retrieve content size */ - ptr = strstr(buf, "Content-Length:"); - if (!ptr) - return -1; + /* HTTP request OK? */ + if (!strstr(buf, "HTTP/1.1 200 OK")) + return -1; + /* Retrieve content size */ + ptr = strstr(buf, "Content-Length:"); + if (!ptr) + return -1; - sscanf(ptr, "Content-Length: %u", &size); - return size; + sscanf(ptr, "Content-Length: %u", &size); + return size; } -s32 network_read(u8 *buf, u32 len) -{ - u32 read = 0; - s32 ret = -1; +s32 network_read(u8 *buf, u32 len) { + u32 read = 0; + s32 ret = -1; - /* Data to be read */ - while (read < len) { - /* Read network data */ - ret = net_read(connection, buf + read, len - read); - if (ret < 0) - return ret; + /* Data to be read */ + while (read < len) { + /* Read network data */ + ret = net_read(connection, buf + read, len - read); + if (ret < 0) + return ret; - /* Read finished */ - if (!ret) - break; + /* Read finished */ + if (!ret) + break; - /* Increment read variable */ - read += ret; - } + /* Increment read variable */ + read += ret; + } - return read; + return read; } /**************************************************************************** @@ -154,42 +149,39 @@ 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) - { - return -1; - } + if (strncmp(url, "http://", strlen("http://")) != 0) { + return -1; + } - //Locate the path part of the url by searching for '/' past "http://" - char *path = strchr(url + strlen("http://"), '/'); + //Locate the path part of the url by searching for '/' past "http://" + 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) - { - return -1; - } + //At the very least the url has to end with '/', ending with just a domain is invalid + if (path == NULL) { + return -1; + } - //Extract the domain part out of the url - int domainlength = path - url - strlen("http://"); + //Extract the domain part out of the url + int domainlength = path - url - strlen("http://"); - if(domainlength == 0) - { - return -1; - } + if (domainlength == 0) { + return -1; + } - char domain[domainlength + 1]; - strncpy(domain, url + strlen("http://"), domainlength); - domain[domainlength] = '\0'; + char domain[domainlength + 1]; + strncpy(domain, url + strlen("http://"), domainlength); + domain[domainlength] = '\0'; - connection = GetConnection(domain); - if(connection < 0) { + connection = GetConnection(domain); + if (connection < 0) { return -1; } //Form a nice request header to send to the webserver - char header[strlen(path)+strlen(domain)+100]; - sprintf(header, "GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n", path, domain); + char header[strlen(path)+strlen(domain)+100]; + sprintf(header, "GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n", path, domain); - s32 filesize = network_request(header); + s32 filesize = network_request(header); return filesize; } @@ -198,7 +190,7 @@ void CloseConnection() { net_close(connection); - if(waitforanswer) { + if (waitforanswer) { net_close(socket); waitforanswer = false; } @@ -209,46 +201,42 @@ void CloseConnection() { ***************************************************************************/ int NetworkWait() { - if(!checkincomming) + if (!checkincomming) return -3; - struct sockaddr_in sin; - struct sockaddr_in client_address; - socklen_t addrlen = sizeof(client_address); + struct sockaddr_in sin; + struct sockaddr_in client_address; + socklen_t addrlen = sizeof(client_address); - //Open socket - socket = net_socket(AF_INET, SOCK_STREAM, IPPROTO_IP); + //Open socket + socket = net_socket(AF_INET, SOCK_STREAM, IPPROTO_IP); - if (socket == INVALID_SOCKET) - { - return socket; - } + if (socket == INVALID_SOCKET) { + return socket; + } - sin.sin_family = AF_INET; - sin.sin_port = htons(PORT); - sin.sin_addr.s_addr = htonl(INADDR_ANY); + sin.sin_family = AF_INET; + sin.sin_port = htons(PORT); + sin.sin_addr.s_addr = htonl(INADDR_ANY); - if (net_bind(socket, (struct sockaddr*)&sin, sizeof(sin)) < 0) - { - net_close(socket); - return -1; - } + if (net_bind(socket, (struct sockaddr*)&sin, sizeof(sin)) < 0) { + net_close(socket); + return -1; + } - if (net_listen(socket, 3) < 0) - { - net_close(socket); - return -1; - } + if (net_listen(socket, 3) < 0) { + net_close(socket); + return -1; + } connection = net_accept(socket, (struct sockaddr*)&client_address, &addrlen); - if (connection < 0) - { - net_close(connection); - net_close(socket); - return -4; + if (connection < 0) { + net_close(connection); + net_close(socket); + return -4; - } else { + } else { unsigned char haxx[9]; //skip haxx @@ -257,40 +245,39 @@ int NetworkWait() { waitforanswer = true; checkincomming = false; networkHalt = true; - } + } - return 1; + return 1; } /**************************************************************************** * Update check ***************************************************************************/ -int CheckUpdate() -{ - if(!networkinitialized) +int CheckUpdate() { + if (!networkinitialized) return -1; int revnumber = 0; int currentrev = atoi(GetRev()); - #ifdef NOTFULLCHANNEL - struct block file = downloadfile("http://www.techjawa.com/usbloadergx/rev.txt"); - #else - struct block file = downloadfile("http://www.techjawa.com/usbloadergx/wadrev.txt"); - #endif +#ifdef NOTFULLCHANNEL + struct block file = downloadfile("http://www.techjawa.com/usbloadergx/rev.txt"); +#else + struct block file = downloadfile("http://www.techjawa.com/usbloadergx/wadrev.txt"); +#endif char revtxt[10]; - u8 i; - if(file.data != NULL) { - for(i=0; i<9 || i < file.size; i++) - revtxt[i] = file.data[i]; + u8 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 > 1)//for testing updates + if (revnumber > currentrev) + //if(revnumber > 1)//for testing updates return revnumber; else return -1; @@ -299,56 +286,52 @@ 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)) - usleep(100); + // wait for thread to finish + while (!LWP_ThreadIsSuspended(networkthread)) + usleep(100); } /**************************************************************************** * ResumeNetworkThread ***************************************************************************/ -void ResumeNetworkThread() -{ - networkHalt = false; - LWP_ResumeThread(networkthread); +void ResumeNetworkThread() { + networkHalt = false; + LWP_ResumeThread(networkthread); } /**************************************************************************** * Resume NetworkWait ***************************************************************************/ -void ResumeNetworkWait() -{ - networkHalt = true; - checkincomming = true; - waitforanswer = true; - infilesize = 0; - connection = -1; - LWP_ResumeThread(networkthread); +void ResumeNetworkWait() { + networkHalt = true; + checkincomming = true; + waitforanswer = true; + infilesize = 0; + connection = -1; + LWP_ResumeThread(networkthread); } /********************************************************************************* * 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,25 +340,23 @@ static void * networkinitcallback(void *arg) checkincomming = false; } - if(checkincomming) + if (checkincomming) NetworkWait(); } - return NULL; + return NULL; } /**************************************************************************** * InitNetworkThread with priority 0 (idle) ***************************************************************************/ -void InitNetworkThread() -{ - LWP_CreateThread (&networkthread, networkinitcallback, NULL, NULL, 0, 0); +void InitNetworkThread() { + LWP_CreateThread (&networkthread, networkinitcallback, NULL, NULL, 0, 0); } /**************************************************************************** * ShutdownThread ***************************************************************************/ -void ShutdownNetworkThread() -{ - LWP_JoinThread (networkthread, NULL); - networkthread = LWP_THREAD_NULL; +void ShutdownNetworkThread() { + LWP_JoinThread (networkthread, NULL); + networkthread = LWP_THREAD_NULL; } diff --git a/source/oggplayer.c b/source/oggplayer.c index adf8ca18..92cd426f 100644 --- a/source/oggplayer.c +++ b/source/oggplayer.c @@ -36,24 +36,23 @@ #define READ_SAMPLES 4096 // samples that it must read before to send #define MAX_PCMOUT 4096 // minimum size to read ogg samples -typedef struct -{ - OggVorbis_File vf; - vorbis_info *vi; - int current_section; +typedef struct { + OggVorbis_File vf; + vorbis_info *vi; + int current_section; - // OGG file operation - int fd; - int mode; - int eof; - int flag; - int volume; - int seek_time; + // OGG file operation + int fd; + int mode; + int eof; + int flag; + int volume; + int seek_time; - /* OGG buffer control */ - short pcmout[2][READ_SAMPLES + MAX_PCMOUT * 2]; /* take 4k out of the data segment, not the stack */ - int pcmout_pos; - int pcm_indx; + /* OGG buffer control */ + short pcmout[2][READ_SAMPLES + MAX_PCMOUT * 2]; /* take 4k out of the data segment, not the stack */ + int pcmout_pos; + int pcm_indx; } private_data_ogg; @@ -68,213 +67,181 @@ 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) - { - ASND_StopVoice(0); - return; - } +static void ogg_add_callback(int voice) { + if (!ogg_thread_running) { + ASND_StopVoice(0); + return; + } - if (private_ogg.flag & 128) - return; // Ogg is paused + if (private_ogg.flag & 128) + return; // Ogg is paused - 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.pcmout_pos ^= 1; - private_ogg.pcm_indx = 0; - private_ogg.flag = 0; - LWP_ThreadSignal(oggplayer_queue); - } - } - else - { - if (private_ogg.flag & 64) - { - private_ogg.flag &= ~64; - LWP_ThreadSignal(oggplayer_queue); - } - } + 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.pcmout_pos ^= 1; + private_ogg.pcm_indx = 0; + private_ogg.flag = 0; + LWP_ThreadSignal(oggplayer_queue); + } + } else { + if (private_ogg.flag & 64) { + private_ogg.flag &= ~64; + LWP_ThreadSignal(oggplayer_queue); + } + } } -static void * ogg_player_thread(private_data_ogg * priv) -{ - int first_time = 1; - long ret; +static void * ogg_player_thread(private_data_ogg * priv) { + int first_time = 1; + long ret; - ogg_thread_running = 0; - //init - LWP_InitQueue(&oggplayer_queue); + ogg_thread_running = 0; + //init + LWP_InitQueue(&oggplayer_queue); - priv[0].vi = ov_info(&priv[0].vf, -1); + priv[0].vi = ov_info(&priv[0].vf, -1); - ASND_Pause(0); + ASND_Pause(0); - priv[0].pcm_indx = 0; - priv[0].pcmout_pos = 0; - priv[0].eof = 0; - priv[0].flag = 0; - priv[0].current_section = 0; + priv[0].pcm_indx = 0; + priv[0].pcmout_pos = 0; + priv[0].eof = 0; + priv[0].flag = 0; + priv[0].current_section = 0; - ogg_thread_running = 1; + ogg_thread_running = 1; - while (!priv[0].eof && ogg_thread_running) - { - if (priv[0].flag) - LWP_ThreadSleep(oggplayer_queue); // wait only when i have samples to send + 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 (ASND_TestPointer(0, priv[0].pcmout[priv[0].pcmout_pos]) - && ASND_StatusVoice(0) != SND_UNUSED) - { - priv[0].flag |= 64; - continue; - } - if (priv[0].pcm_indx < READ_SAMPLES) - { - priv[0].flag = 3; + 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) { + priv[0].flag |= 64; + continue; + } + if (priv[0].pcm_indx < READ_SAMPLES) { + priv[0].flag = 3; - if (priv[0].seek_time >= 0) - { - ov_time_seek(&priv[0].vf, priv[0].seek_time); - priv[0].seek_time = -1; - } + if (priv[0].seek_time >= 0) { + ov_time_seek(&priv[0].vf, priv[0].seek_time); + priv[0].seek_time = -1; + } - ret - = ov_read( - &priv[0].vf, - (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) - { - /* EOF */ - if (priv[0].mode & 1) - ov_time_seek(&priv[0].vf, 0); // repeat - else - priv[0].eof = 1; // stops - // - } - 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 (priv[0].mode & 1) - ov_time_seek(&priv[0].vf, 0); // repeat - else - priv[0].eof = 1; // stops - } - } - 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 - priv[0].flag = 1; - } + ret + = ov_read( + &priv[0].vf, + (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) { + /* EOF */ + if (priv[0].mode & 1) + ov_time_seek(&priv[0].vf, 0); // repeat + else + priv[0].eof = 1; // stops + // + } 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 (priv[0].mode & 1) + ov_time_seek(&priv[0].vf, 0); // repeat + else + priv[0].eof = 1; // stops + } + } 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 + priv[0].flag = 1; + } - if (priv[0].flag == 1) - { - if (ASND_StatusVoice(0) == SND_UNUSED || first_time) - { - first_time = 0; - 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, - priv[0].volume, ogg_add_callback); - priv[0].pcmout_pos ^= 1; - priv[0].pcm_indx = 0; - priv[0].flag = 0; - } - 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, - priv[0].volume, ogg_add_callback); - priv[0].pcmout_pos ^= 1; - priv[0].pcm_indx = 0; - priv[0].flag = 0; - } - } - } - usleep(100); - } - ov_clear(&priv[0].vf); - priv[0].fd = -1; - priv[0].pcm_indx = 0; - ogg_thread_running = 0; + if (priv[0].flag == 1) { + if (ASND_StatusVoice(0) == SND_UNUSED || first_time) { + first_time = 0; + 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, + priv[0].volume, ogg_add_callback); + priv[0].pcmout_pos ^= 1; + priv[0].pcm_indx = 0; + priv[0].flag = 0; + } 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, + priv[0].volume, ogg_add_callback); + priv[0].pcmout_pos ^= 1; + priv[0].pcm_indx = 0; + priv[0].flag = 0; + } + } + } + usleep(100); + } + ov_clear(&priv[0].vf); + priv[0].fd = -1; + priv[0].pcm_indx = 0; + ogg_thread_running = 0; - return 0; + return 0; } -void StopOgg() -{ - ASND_StopVoice(0); - ogg_thread_running = 0; +void StopOgg() { + ASND_StopVoice(0); + ogg_thread_running = 0; - 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) - { - LWP_CloseQueue(oggplayer_queue); - 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) { + LWP_CloseQueue(oggplayer_queue); + oggplayer_queue = LWP_TQUEUE_NULL; + } } -int PlayOgg(int fd, int time_pos, int mode) -{ - StopOgg(); +int PlayOgg(int fd, int time_pos, int mode) { + StopOgg(); - private_ogg.fd = fd; - private_ogg.mode = mode; - private_ogg.eof = 0; - private_ogg.volume = 127; - private_ogg.flag = 0; - private_ogg.seek_time = -1; + private_ogg.fd = fd; + private_ogg.mode = mode; + private_ogg.eof = 0; + private_ogg.volume = 127; + private_ogg.flag = 0; + private_ogg.seek_time = -1; - if (time_pos > 0) - private_ogg.seek_time = time_pos; + if (time_pos > 0) + private_ogg.seek_time = time_pos; - if (fd < 0) - { - private_ogg.fd = -1; - return -1; - } - 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; - return -1; - } + if (fd < 0) { + private_ogg.fd = -1; + return -1; + } + 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; + return -1; + } - if (LWP_CreateThread(&h_oggplayer, (void *) ogg_player_thread, - &private_ogg, oggplayer_stack, STACKSIZE, 80) == -1) - { - ogg_thread_running = 0; - ov_clear(&private_ogg.vf); - private_ogg.fd = -1; - return -1; - } - return 0; + if (LWP_CreateThread(&h_oggplayer, (void *) ogg_player_thread, + &private_ogg, oggplayer_stack, STACKSIZE, 80) == -1) { + ogg_thread_running = 0; + ov_clear(&private_ogg.vf); + private_ogg.fd = -1; + return -1; + } + return 0; } @@ -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,74 +267,70 @@ 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); + fclose (pFile); if (loop) - return PlayOgg(mem_open((char *)bufferogg, filesize), 0, OGG_INFINITE_TIME); + return PlayOgg(mem_open((char *)bufferogg, filesize), 0, OGG_INFINITE_TIME); else - return PlayOgg(mem_open((char *)bufferogg, filesize), 0, OGG_ONE_TIME); + return PlayOgg(mem_open((char *)bufferogg, filesize), 0, OGG_ONE_TIME); } -void PauseOgg(int pause) -{ - if (pause) - { - private_ogg.flag |= 128; - } - else - { - if (private_ogg.flag & 128) - { - private_ogg.flag |= 64; - private_ogg.flag &= ~128; - if (ogg_thread_running > 0) - { - LWP_ThreadSignal(oggplayer_queue); - } - } +void PauseOgg(int pause) { + if (pause) { + private_ogg.flag |= 128; + } else { + if (private_ogg.flag & 128) { + private_ogg.flag |= 64; + private_ogg.flag &= ~128; + if (ogg_thread_running > 0) { + LWP_ThreadSignal(oggplayer_queue); + } + } - } + } } -int StatusOgg() -{ - if (ogg_thread_running == 0) - return -1; // Error - else if (private_ogg.eof) - return 255; // EOF - else if (private_ogg.flag & 128) - return 2; // paused - else - return 1; // running +int StatusOgg() { + if (ogg_thread_running == 0) + return -1; // Error + else if (private_ogg.eof) + return 255; // EOF + else if (private_ogg.flag & 128) + return 2; // paused + else + return 1; // running } -void SetVolumeOgg(int volume) -{ - private_ogg.volume = volume; - ASND_ChangeVolumeVoice(0, volume, volume); +void SetVolumeOgg(int volume) { + private_ogg.volume = volume; + ASND_ChangeVolumeVoice(0, volume, volume); } -s32 GetTimeOgg() -{ - int ret; - if (ogg_thread_running == 0 || private_ogg.fd < 0) - return 0; - ret = ((s32) ov_time_tell(&private_ogg.vf)); - if (ret < 0) - ret = 0; +s32 GetTimeOgg() { + int ret; + if (ogg_thread_running == 0 || private_ogg.fd < 0) + return 0; + ret = ((s32) ov_time_tell(&private_ogg.vf)); + if (ret < 0) + ret = 0; - return ret; + return ret; } -void SetTimeOgg(s32 time_pos) -{ - if (time_pos >= 0) - private_ogg.seek_time = time_pos; +void SetTimeOgg(s32 time_pos) { + if (time_pos >= 0) + private_ogg.seek_time = time_pos; } diff --git a/source/oggplayer.h b/source/oggplayer.h index 7478263f..dff5ef3a 100644 --- a/source/oggplayer.h +++ b/source/oggplayer.h @@ -32,8 +32,7 @@ #include "tremor/ivorbisfile.h" #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif #define OGG_ONE_TIME 0 @@ -44,130 +43,130 @@ 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); + 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); - NOTE: The file is closed by the player when you call PlayOgg(), StopOgg() or if it fail. + NOTE: The file is closed by the player when you call PlayOgg(), StopOgg() or if it fail. - -- Params --- + -- Params --- - fd: file descriptor from open() or mem_open() + fd: file descriptor from open() or mem_open() - time_pos: initial time position in the file (in milliseconds). For example, use 30000 to advance 30 seconds + time_pos: initial time position in the file (in milliseconds). For example, use 30000 to advance 30 seconds - mode: Use OGG_ONE_TIME or OGG_INFINITE_TIME. When you use OGG_ONE_TIME the sound stops and StatusOgg() return OGG_STATUS_EOF + mode: Use OGG_ONE_TIME or OGG_INFINITE_TIME. When you use OGG_ONE_TIME the sound stops and StatusOgg() return OGG_STATUS_EOF - return: 0- Ok, -1 Error + return: 0- Ok, -1 Error - */ + */ -int PlayOgg(int fd, int time_pos, int mode); + int PlayOgg(int fd, int time_pos, int mode); -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ -/* 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 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); + /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ -/* void StopOgg(); + /* void StopOgg(); - Stop an Ogg file. + Stop an Ogg file. - NOTE: The file is closed and the player thread is released + NOTE: The file is closed and the player thread is released - -- Params --- + -- Params --- - */ + */ -void StopOgg(); + void StopOgg(); -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ -/* void PauseOgg(int pause); + /* void PauseOgg(int pause); - Pause an Ogg file. + Pause an Ogg file. - -- Params --- + -- Params --- - pause: 0 -> continue, 1-> pause + pause: 0 -> continue, 1-> pause - */ + */ -void PauseOgg(int pause); + void PauseOgg(int pause); -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ -/* int StatusOgg(); + /* int StatusOgg(); - Return the Ogg status + Return the Ogg status - -- Params --- + -- Params --- - return: OGG_STATUS_RUNNING - OGG_STATUS_ERR -> not initialized? - OGG_STATUS_PAUSED - OGG_STATUS_EOF -> player stopped by End Of File + return: OGG_STATUS_RUNNING + OGG_STATUS_ERR -> not initialized? + OGG_STATUS_PAUSED + OGG_STATUS_EOF -> player stopped by End Of File - */ + */ -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) + Set the Ogg playing volume. + NOTE: it change the volume of voice 0 (used for the Ogg player) - -- Params --- + -- Params --- - volume: 0 to 255 (max) + volume: 0 to 255 (max) - */ + */ -void SetVolumeOgg(int volume); + void SetVolumeOgg(int volume); -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ -/* s32 GetTimeOgg(); + /* s32 GetTimeOgg(); - Return the Ogg time from the starts of the file + Return the Ogg time from the starts of the file - -- Params --- + -- Params --- - return: 0 -> Ok or error condition (you must ignore this value) - >0 -> time in milliseconds from the starts + return: 0 -> Ok or error condition (you must ignore this value) + >0 -> time in milliseconds from the starts - */ + */ -s32 GetTimeOgg(); + s32 GetTimeOgg(); -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ -/* void SetTimeOgg(s32 time_pos); + /* void SetTimeOgg(s32 time_pos); - Set the time position + Set the time position - NOTE: The file is closed by the player when you call PlayOgg(), StopOgg() or if it fail. + NOTE: The file is closed by the player when you call PlayOgg(), StopOgg() or if it fail. - -- Params --- + -- Params --- - time_pos: time position in the file (in milliseconds). For example, use 30000 to advance 30 seconds + time_pos: time position in the file (in milliseconds). For example, use 30000 to advance 30 seconds - */ + */ -void SetTimeOgg(s32 time_pos); + void SetTimeOgg(s32 time_pos); -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ #ifdef __cplusplus } diff --git a/source/patches/dvd_broadway.c b/source/patches/dvd_broadway.c index 16e6a9e9..ee7d2aa9 100644 --- a/source/patches/dvd_broadway.c +++ b/source/patches/dvd_broadway.c @@ -26,15 +26,15 @@ #include #include #include -#include - +#include + #include "dvd_broadway.h" - + #define DI_CMDCTX_CNT 4 - + #define DVD_DISKIDSIZE 0x20 #define DVD_DRVINFSIZE 0x20 - + #define IOCTL_DI_INQUIRY 0x12 #define IOCTL_DI_READID 0x70 #define IOCTL_DI_READ 0x71 @@ -58,24 +58,22 @@ #define IOCTL_DI_GETCRYPTMODE 0xF3 #define IOCTL_DI_SETDVDROMMODE 0xF4 #define IOCTL_DI_GETDVDROMMODE 0xF5 - + #define _SHIFTL(v, s, w) \ ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s))) #define _SHIFTR(v, s, w) \ ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1))) - -struct dicommand -{ - u32 diReg[8]; + +struct dicommand { + u32 diReg[8]; }; - -struct dicontext -{ - lwp_node node; - dvdcallbacklow cb; - struct dicommand *cmd; + +struct dicontext { + lwp_node node; + dvdcallbacklow cb; + struct dicommand *cmd; }; - + static s32 __dvd_fd = -1; static u32 __dvd_spinupval = 1; static lwp_queue __di_contextq; @@ -90,523 +88,496 @@ static u32 __di_regvalcache[0x08] ATTRIBUTE_ALIGN(32); static u32 __di_lastticketerror[0x08] ATTRIBUTE_ALIGN(32); static ioctlv __di_iovector[0x08] ATTRIBUTE_ALIGN(32); static char __di_fs[] ATTRIBUTE_ALIGN(32) = "/dev/di"; - + extern u32 __IPC_ClntInit(); - -static __inline__ lwp_node* __lwp_queue_head(lwp_queue *queue) -{ - return (lwp_node*)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) -{ - return (lwp_node*)&queue->perm_null; + +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) -{ - queue->first = __lwp_queue_tail(queue); - queue->perm_null = NULL; - queue->last = __lwp_queue_head(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) -{ - struct dicontext *ctx; - - ctx = (struct dicontext*)__lwp_queue_get(&__di_contextq); - if(ctx!=NULL) ctx->cb = cb; - - return ctx; + +static struct dicontext* __dvd_getcontext(dvdcallbacklow cb) { + struct dicontext *ctx; + + ctx = (struct dicontext*)__lwp_queue_get(&__di_contextq); + if (ctx!=NULL) ctx->cb = cb; + + return ctx; } - -static s32 __dvd_iostransactionCB(s32 result,void *usrdata) -{ - struct dicontext *ctx = (struct dicontext*)usrdata; - - __dvd_reqinprogress = 0; - - if(ctx->cb!=NULL) { - __dvd_cbinprogress = 1; - if(result!=0) __dvd_readlength = 0; - ctx->cb(result); - __dvd_cbinprogress = 0; - } - __lwp_queue_append(&__di_contextq,&ctx->node); - - return 0; + +static s32 __dvd_iostransactionCB(s32 result,void *usrdata) { + struct dicontext *ctx = (struct dicontext*)usrdata; + + __dvd_reqinprogress = 0; + + if (ctx->cb!=NULL) { + __dvd_cbinprogress = 1; + if (result!=0) __dvd_readlength = 0; + ctx->cb(result); + __dvd_cbinprogress = 0; + } + __lwp_queue_append(&__di_contextq,&ctx->node); + + return 0; } - -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) { - __dvd_cbinprogress = 1; - ctx->cb(result); - __dvd_cbinprogress = 0; - } - __lwp_queue_append(&__di_contextq,&ctx->node); - - return 0; + +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) { + __dvd_cbinprogress = 1; + ctx->cb(result); + __dvd_cbinprogress = 0; + } + __lwp_queue_append(&__di_contextq,&ctx->node); + + return 0; } - -static s32 __dvd_ioscovercloseCB(s32 result,void *usrdata) -{ - struct dicontext *ctx = (struct dicontext*)usrdata; - - __dvd_reqinprogress = 0; - - if(ctx->cb!=NULL) { - __dvd_cbinprogress = 1; - ctx->cb(result); - __dvd_cbinprogress = 0; - } - __lwp_queue_append(&__di_contextq,&ctx->node); - - return 0; + +static s32 __dvd_ioscovercloseCB(s32 result,void *usrdata) { + struct dicontext *ctx = (struct dicontext*)usrdata; + + __dvd_reqinprogress = 0; + + if (ctx->cb!=NULL) { + __dvd_cbinprogress = 1; + ctx->cb(result); + __dvd_cbinprogress = 0; + } + __lwp_queue_append(&__di_contextq,&ctx->node); + + return 0; } - -s32 bwDVD_LowInit() -{ - s32 i,ret = 0; - u32 ipclo,ipchi; - lwp_queue inactives; - struct dicontext *ctx; - - if(__dvd_lowinitcalled==0) { - ret = __IPC_ClntInit(); - if(ret<0) return ret; - - ipclo = (((u32)IPC_GetBufferLo()+0x1f)&~0x1f); - ipchi = (u32)IPC_GetBufferHi(); - if(ipchi>=(ipclo+(sizeof(struct dicommand)*DI_CMDCTX_CNT))) { - __di_commands = (struct dicommand*)ipclo; - IPC_SetBufferLo((void*)(ipclo+(sizeof(struct dicommand)*DI_CMDCTX_CNT))); - - memset(__di_commands,0,(sizeof(struct dicommand)*DI_CMDCTX_CNT)); - - 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) { - ctx->cmd = &__di_commands[i]; - ctx->cb = NULL; - __lwp_queue_append(&__di_contextq,&ctx->node); - - i++; - } - } - - ret = IOS_Open(__di_fs,0); - if(ret<0) return ret; - - __dvd_fd = ret; + +s32 bwDVD_LowInit() { + s32 i,ret = 0; + u32 ipclo,ipchi; + lwp_queue inactives; + struct dicontext *ctx; + + if (__dvd_lowinitcalled==0) { + ret = __IPC_ClntInit(); + if (ret<0) return ret; + + ipclo = (((u32)IPC_GetBufferLo()+0x1f)&~0x1f); + ipchi = (u32)IPC_GetBufferHi(); + if (ipchi>=(ipclo+(sizeof(struct dicommand)*DI_CMDCTX_CNT))) { + __di_commands = (struct dicommand*)ipclo; + IPC_SetBufferLo((void*)(ipclo+(sizeof(struct dicommand)*DI_CMDCTX_CNT))); + + memset(__di_commands,0,(sizeof(struct dicommand)*DI_CMDCTX_CNT)); + + 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) { + ctx->cmd = &__di_commands[i]; + ctx->cb = NULL; + __lwp_queue_append(&__di_contextq,&ctx->node); + + i++; + } + } + + ret = IOS_Open(__di_fs,0); + if (ret<0) return ret; + + __dvd_fd = ret; // __dvd_lowinitcalled = 1; - - // printf("DVD_LowInit(%d)\n",ret); - } - return 0; + + // printf("DVD_LowInit(%d)\n",ret); + } + return 0; } - -s32 bwDVD_LowInquiry(dvddrvinfo *info,dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_INQUIRY<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_INQUIRY,cmd->diReg,sizeof(struct dicommand),info,DVD_DRVINFSIZE,__dvd_iostransactionCB,ctx); - - return ret; + +s32 bwDVD_LowInquiry(dvddrvinfo *info,dvdcallbacklow cb) { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_INQUIRY<<24); + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_INQUIRY,cmd->diReg,sizeof(struct dicommand),info,DVD_DRVINFSIZE,__dvd_iostransactionCB,ctx); + + return ret; } - -s32 bwDVD_LowReadID(dvddiskid *diskID,dvdcallbacklow cb) -{ - s32 ret = 0; - struct dicontext *ctx; - struct dicommand *cmd; - + +s32 bwDVD_LowReadID(dvddiskid *diskID,dvdcallbacklow cb) { + s32 ret = 0; + struct dicontext *ctx; + struct dicommand *cmd; + // printf("DVD_LowReadID()\n"); - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_READID<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_READID,cmd->diReg,sizeof(struct dicommand),diskID,DVD_DISKIDSIZE,__dvd_iostransactionCB,ctx); - + + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_READID<<24); + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_READID,cmd->diReg,sizeof(struct dicommand),diskID,DVD_DISKIDSIZE,__dvd_iostransactionCB,ctx); + // printf("DVD_LowReadID(%d)\n",ret); - return ret; + return ret; } - -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; - - __dvd_reqinprogress = 1; - __dvd_readlength = len; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_READ<<24); - cmd->diReg[1] = len; - cmd->diReg[2] = offset; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_READ,cmd->diReg,sizeof(struct dicommand),buf,len,__dvd_iostransactionCB,ctx); - - return ret; + +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; + + __dvd_reqinprogress = 1; + __dvd_readlength = len; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_READ<<24); + cmd->diReg[1] = len; + cmd->diReg[2] = offset; + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_READ,cmd->diReg,sizeof(struct dicommand),buf,len,__dvd_iostransactionCB,ctx); + + return ret; } // never got this function working, probably removed from wii -s32 bwDVD_LowReadVideo(void *buf,u32 len,u32 offset,dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - __dvd_readlength = len; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_READ_DVDVIDEO<<24); - cmd->diReg[1] = len; - cmd->diReg[2] = offset; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_READ_DVDVIDEO,cmd->diReg,sizeof(struct dicommand),buf,len,__dvd_iostransactionCB,ctx); - - return ret; +s32 bwDVD_LowReadVideo(void *buf,u32 len,u32 offset,dvdcallbacklow cb) { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + + __dvd_reqinprogress = 1; + __dvd_readlength = len; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_READ_DVDVIDEO<<24); + cmd->diReg[1] = len; + cmd->diReg[2] = offset; + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_READ_DVDVIDEO,cmd->diReg,sizeof(struct dicommand),buf,len,__dvd_iostransactionCB,ctx); + + return ret; } - -s32 bwDVD_LowStopLaser(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_STOPLASER<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_STOPLASER,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; + +s32 bwDVD_LowStopLaser(dvdcallbacklow cb) { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_STOPLASER<<24); + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_STOPLASER,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); + + return ret; } // never got this function working, probably removed from wii -s32 bwDVD_EnableVideo(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_ENABLE_DVD<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_ENABLE_DVD,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; +s32 bwDVD_EnableVideo(dvdcallbacklow cb) { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_ENABLE_DVD<<24); + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_ENABLE_DVD,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); + + return ret; } - -s32 bwDVD_LowSeek(u32 offset,dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_SEEK<<24); - cmd->diReg[1] = offset; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_SEEK,cmd->diReg,sizeof(struct dicommand),NULL,0,__dvd_iostransactionCB,ctx); - - return ret; + +s32 bwDVD_LowSeek(u32 offset,dvdcallbacklow cb) { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_SEEK<<24); + cmd->diReg[1] = offset; + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_SEEK,cmd->diReg,sizeof(struct dicommand),NULL,0,__dvd_iostransactionCB,ctx); + + return ret; } - -s32 bwDVD_LowOffset(u64 offset,dvdcallbacklow cb) -{ - s32 ret; - u32 *off = (u32*)(void*)(&offset); - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - 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; - 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_LowOffset(u64 offset,dvdcallbacklow cb) { + s32 ret; + u32 *off = (u32*)(void*)(&offset); + struct dicontext *ctx; + struct dicommand *cmd; + + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + 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; + 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 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_COVER<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_COVER,cmd->diReg,sizeof(struct dicommand),__di_regbuffer,0x20,__dvd_ioscoverregisterCB,ctx); - - return ret; + +s32 bwDVD_LowPrepareCoverRegister(dvdcallbacklow cb) { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_COVER<<24); + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_COVER,cmd->diReg,sizeof(struct dicommand),__di_regbuffer,0x20,__dvd_ioscoverregisterCB,ctx); + + return ret; } - -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; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_OPENPART<<24); - cmd->diReg[1] = offset; - - __di_iovector[0].data = cmd; - __di_iovector[0].len = sizeof(struct dicommand); - - __di_iovector[1].data = eticket; - 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; - else __di_iovector[2].len = certin_len; - - __di_iovector[3].data = certificate_out; - __di_iovector[3].len = 18916; - __di_iovector[4].data = __di_lastticketerror; - __di_iovector[4].len = 0x20; - ret = IOS_IoctlvAsync(__dvd_fd,IOCTL_DI_OPENPART,3,2,__di_iovector,__dvd_iostransactionCB,ctx); - - return ret; + +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; + + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_OPENPART<<24); + cmd->diReg[1] = offset; + + __di_iovector[0].data = cmd; + __di_iovector[0].len = sizeof(struct dicommand); + + __di_iovector[1].data = eticket; + 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; + else __di_iovector[2].len = certin_len; + + __di_iovector[3].data = certificate_out; + __di_iovector[3].len = 18916; + __di_iovector[4].data = __di_lastticketerror; + __di_iovector[4].len = 0x20; + ret = IOS_IoctlvAsync(__dvd_fd,IOCTL_DI_OPENPART,3,2,__di_iovector,__dvd_iostransactionCB,ctx); + + return ret; } - -s32 bwDVD_LowClosePartition(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_CLOSEPART<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_CLOSEPART,cmd->diReg,sizeof(struct dicommand),NULL,0,__dvd_iostransactionCB,ctx); - - return ret; + +s32 bwDVD_LowClosePartition(dvdcallbacklow cb) { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_CLOSEPART<<24); + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_CLOSEPART,cmd->diReg,sizeof(struct dicommand),NULL,0,__dvd_iostransactionCB,ctx); + + return ret; } - -s32 bwDVD_LowUnencryptedRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - __dvd_readlength = len; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_UNENCREAD<<24); - cmd->diReg[1] = len; - cmd->diReg[2] = offset; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_UNENCREAD,cmd->diReg,sizeof(struct dicommand),buf,len,__dvd_iostransactionCB,ctx); - - return ret; + +s32 bwDVD_LowUnencryptedRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb) { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + + __dvd_reqinprogress = 1; + __dvd_readlength = len; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_UNENCREAD<<24); + cmd->diReg[1] = len; + cmd->diReg[2] = offset; + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_UNENCREAD,cmd->diReg,sizeof(struct dicommand),buf,len,__dvd_iostransactionCB,ctx); + + return ret; } - -s32 bwDVD_LowWaitCoverClose(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_WAITCVRCLOSE<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_WAITCVRCLOSE,cmd->diReg,sizeof(struct dicommand),NULL,0,__dvd_ioscovercloseCB,ctx); - - return ret; + +s32 bwDVD_LowWaitCoverClose(dvdcallbacklow cb) { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_WAITCVRCLOSE<<24); + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_WAITCVRCLOSE,cmd->diReg,sizeof(struct dicommand),NULL,0,__dvd_ioscovercloseCB,ctx); + + return ret; } - -s32 bwDVD_LowResetNotify() -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - if(__dvd_cbinprogress==1) return -1; - - ctx = __dvd_getcontext(NULL); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_RESETNOTIFY<<24); - ret = IOS_Ioctl(__dvd_fd,IOCTL_DI_RESETNOTIFY,cmd->diReg,sizeof(struct dicommand),NULL,0); - - return ret; + +s32 bwDVD_LowResetNotify() { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + + if (__dvd_cbinprogress==1) return -1; + + ctx = __dvd_getcontext(NULL); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_RESETNOTIFY<<24); + ret = IOS_Ioctl(__dvd_fd,IOCTL_DI_RESETNOTIFY,cmd->diReg,sizeof(struct dicommand),NULL,0); + + return ret; } - -s32 bwDVD_LowReset(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - + +s32 bwDVD_LowReset(dvdcallbacklow cb) { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + // printf("DVD_LowReset()\n"); - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_RESET<<24); - cmd->diReg[1] = __dvd_spinupval; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_RESET,cmd->diReg,sizeof(struct dicommand),NULL,0,__dvd_iostransactionCB,ctx); - + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_RESET<<24); + cmd->diReg[1] = __dvd_spinupval; + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_RESET,cmd->diReg,sizeof(struct dicommand),NULL,0,__dvd_iostransactionCB,ctx); + // printf("DVD_LowReset(%d)\n",ret); - return ret; + return ret; } - -s32 bwDVD_LowStopMotor(u8 stop1,u8 stop2,dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_STOPMOTOR<<24); - cmd->diReg[1] = (stop1<<24); - cmd->diReg[2] = (stop2<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_STOPMOTOR,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; - + +s32 bwDVD_LowStopMotor(u8 stop1,u8 stop2,dvdcallbacklow cb) { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_STOPMOTOR<<24); + cmd->diReg[1] = (stop1<<24); + cmd->diReg[2] = (stop2<<24); + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_STOPMOTOR,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); + + return ret; + } - -s32 bwDVD_LowRequestError(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_REQERROR<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_REQERROR,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; + +s32 bwDVD_LowRequestError(dvdcallbacklow cb) { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_REQERROR<<24); + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_REQERROR,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); + + return ret; } -s32 bwDVD_SetDecryption(s32 mode, dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_SETCRYPTMODE<<24); - cmd->diReg[1] = mode; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_SETCRYPTMODE,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; - +s32 bwDVD_SetDecryption(s32 mode, dvdcallbacklow cb) { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_SETCRYPTMODE<<24); + cmd->diReg[1] = mode; + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_SETCRYPTMODE,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); + + return ret; + } -s32 bwDVD_SetOffset(u32 offset, dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_SETOFFBASE<<24); - cmd->diReg[1] = offset; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_SETOFFBASE,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; - +s32 bwDVD_SetOffset(u32 offset, dvdcallbacklow cb) { + s32 ret; + struct dicontext *ctx; + struct dicommand *cmd; + + __dvd_reqinprogress = 1; + + ctx = __dvd_getcontext(cb); + if (ctx==NULL) return IPC_ENOMEM; + + cmd = ctx->cmd; + cmd->diReg[0] = (IOCTL_DI_SETOFFBASE<<24); + cmd->diReg[1] = offset; + ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_SETOFFBASE,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); + + return ret; + } diff --git a/source/patches/dvd_broadway.h b/source/patches/dvd_broadway.h index c0ca133b..b2c63e4a 100644 --- a/source/patches/dvd_broadway.h +++ b/source/patches/dvd_broadway.h @@ -21,33 +21,33 @@ #ifndef __DVD_BROADWAY_H__ #define __DVD_BROADWAY_H__ - + #include #include #include - -#ifdef __cplusplus - extern "C" { -#endif /* __cplusplus */ - -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); #ifdef __cplusplus - } +extern "C" { #endif /* __cplusplus */ - + + 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); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + #endif diff --git a/source/patches/fst.c b/source/patches/fst.c index 4fd76839..cfea0d0f 100644 --- a/source/patches/fst.c +++ b/source/patches/fst.c @@ -37,63 +37,62 @@ extern struct SSettings Settings; -u32 do_sd_code(char *filename) -{ - FILE *fp; - u8 *filebuff; - u32 filesize; - u32 ret; - char filepath[150]; +u32 do_sd_code(char *filename) { + FILE *fp; + u8 *filebuff; + u32 filesize; + u32 ret; + char filepath[150]; SDCard_Init(); - USBDevice_Init(); + USBDevice_Init(); - sprintf(filepath, "%s%s", Settings.Cheatcodespath, filename); - filepath[strlen(Settings.Cheatcodespath)+6] = 0x2E; - filepath[strlen(Settings.Cheatcodespath)+7] = 0x67; - filepath[strlen(Settings.Cheatcodespath)+8] = 0x63; - filepath[strlen(Settings.Cheatcodespath)+9] = 0x74; - filepath[strlen(Settings.Cheatcodespath)+10] = 0; + sprintf(filepath, "%s%s", Settings.Cheatcodespath, filename); + filepath[strlen(Settings.Cheatcodespath)+6] = 0x2E; + filepath[strlen(Settings.Cheatcodespath)+7] = 0x67; + filepath[strlen(Settings.Cheatcodespath)+8] = 0x63; + filepath[strlen(Settings.Cheatcodespath)+9] = 0x74; + filepath[strlen(Settings.Cheatcodespath)+10] = 0; - fp = fopen(filepath, "rb"); - if (!fp) { + fp = fopen(filepath, "rb"); + if (!fp) { USBDevice_deInit(); SDCard_deInit(); - return 0; - } + return 0; + } - fseek(fp, 0, SEEK_END); - filesize = ftell(fp); - fseek(fp, 0, SEEK_SET); + fseek(fp, 0, SEEK_END); + filesize = ftell(fp); + fseek(fp, 0, SEEK_SET); - filebuff = (u8*) malloc (filesize); - if(filebuff == 0){ - fclose(fp); - sleep(2); + filebuff = (u8*) malloc (filesize); + if (filebuff == 0) { + fclose(fp); + sleep(2); USBDevice_deInit(); SDCard_deInit(); - return 0; - } + return 0; + } - ret = fread(filebuff, 1, filesize, fp); - if(ret != filesize){ - free(filebuff); - fclose(fp); + ret = fread(filebuff, 1, filesize, fp); + if (ret != filesize) { + free(filebuff); + fclose(fp); USBDevice_deInit(); SDCard_deInit(); - return 0; - } + return 0; + } memcpy((void*)0x800027E8,filebuff,filesize); *(vu8*)0x80001807 = 0x01; - free(filebuff); - fclose(fp); + free(filebuff); + fclose(fp); - USBDevice_deInit(); + USBDevice_deInit(); SDCard_deInit(); - return 1; + return 1; } diff --git a/source/patches/fst.h b/source/patches/fst.h index ccd855e0..66252053 100644 --- a/source/patches/fst.h +++ b/source/patches/fst.h @@ -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 } diff --git a/source/patches/fwrite_patch.h b/source/patches/fwrite_patch.h index 54fedcc4..bd47ce44 100644 --- a/source/patches/fwrite_patch.h +++ b/source/patches/fwrite_patch.h @@ -1,15 +1,15 @@ unsigned char fwrite_patch_bin[] = { - 0x7c, 0x84, 0x29, 0xd6, 0x39, 0x40, 0x00, 0x00, 0x94, 0x21, 0xff, 0xf0, - 0x93, 0xe1, 0x00, 0x0c, 0x7f, 0x8a, 0x20, 0x00, 0x40, 0x9c, 0x00, 0x64, - 0x3d, 0x00, 0xcd, 0x00, 0x3d, 0x60, 0xcd, 0x00, 0x3d, 0x20, 0xcd, 0x00, - 0x61, 0x08, 0x68, 0x14, 0x61, 0x6b, 0x68, 0x24, 0x61, 0x29, 0x68, 0x20, - 0x39, 0x80, 0x00, 0xd0, 0x38, 0xc0, 0x00, 0x19, 0x38, 0xe0, 0x00, 0x00, - 0x91, 0x88, 0x00, 0x00, 0x7c, 0x03, 0x50, 0xae, 0x54, 0x00, 0xa0, 0x16, - 0x64, 0x00, 0xb0, 0x00, 0x90, 0x0b, 0x00, 0x00, 0x90, 0xc9, 0x00, 0x00, - 0x80, 0x09, 0x00, 0x00, 0x70, 0x1f, 0x00, 0x01, 0x40, 0x82, 0xff, 0xf8, - 0x80, 0x0b, 0x00, 0x00, 0x90, 0xe8, 0x00, 0x00, 0x54, 0x00, 0x37, 0xfe, - 0x7d, 0x4a, 0x02, 0x14, 0x7f, 0x8a, 0x20, 0x00, 0x41, 0x9c, 0xff, 0xc8, - 0x7c, 0xa3, 0x2b, 0x78, 0x83, 0xe1, 0x00, 0x0c, 0x38, 0x21, 0x00, 0x10, - 0x4e, 0x80, 0x00, 0x20 + 0x7c, 0x84, 0x29, 0xd6, 0x39, 0x40, 0x00, 0x00, 0x94, 0x21, 0xff, 0xf0, + 0x93, 0xe1, 0x00, 0x0c, 0x7f, 0x8a, 0x20, 0x00, 0x40, 0x9c, 0x00, 0x64, + 0x3d, 0x00, 0xcd, 0x00, 0x3d, 0x60, 0xcd, 0x00, 0x3d, 0x20, 0xcd, 0x00, + 0x61, 0x08, 0x68, 0x14, 0x61, 0x6b, 0x68, 0x24, 0x61, 0x29, 0x68, 0x20, + 0x39, 0x80, 0x00, 0xd0, 0x38, 0xc0, 0x00, 0x19, 0x38, 0xe0, 0x00, 0x00, + 0x91, 0x88, 0x00, 0x00, 0x7c, 0x03, 0x50, 0xae, 0x54, 0x00, 0xa0, 0x16, + 0x64, 0x00, 0xb0, 0x00, 0x90, 0x0b, 0x00, 0x00, 0x90, 0xc9, 0x00, 0x00, + 0x80, 0x09, 0x00, 0x00, 0x70, 0x1f, 0x00, 0x01, 0x40, 0x82, 0xff, 0xf8, + 0x80, 0x0b, 0x00, 0x00, 0x90, 0xe8, 0x00, 0x00, 0x54, 0x00, 0x37, 0xfe, + 0x7d, 0x4a, 0x02, 0x14, 0x7f, 0x8a, 0x20, 0x00, 0x41, 0x9c, 0xff, 0xc8, + 0x7c, 0xa3, 0x2b, 0x78, 0x83, 0xe1, 0x00, 0x0c, 0x38, 0x21, 0x00, 0x10, + 0x4e, 0x80, 0x00, 0x20 }; unsigned int fwrite_patch_bin_len = 136; diff --git a/source/patches/kenobiwii.h b/source/patches/kenobiwii.h index bc3d0ed1..0bf9557c 100644 --- a/source/patches/kenobiwii.h +++ b/source/patches/kenobiwii.h @@ -4,261 +4,261 @@ Visit http://www.devkitpro.org */ const unsigned char kenobiwii[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x26, 0xa0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x94, 0x21, 0xff, 0x58, 0x90, 0x01, 0x00, 0x08, - 0x7c, 0x08, 0x02, 0xa6, 0x90, 0x01, 0x00, 0xac, 0x7c, 0x00, 0x00, 0x26, 0x90, 0x01, 0x00, 0x0c, - 0x7c, 0x09, 0x02, 0xa6, 0x90, 0x01, 0x00, 0x10, 0x7c, 0x01, 0x02, 0xa6, 0x90, 0x01, 0x00, 0x14, - 0xbc, 0x61, 0x00, 0x18, 0x7f, 0x20, 0x00, 0xa6, 0x63, 0x3a, 0x20, 0x00, 0x73, 0x5a, 0xf9, 0xff, - 0x7f, 0x40, 0x01, 0x24, 0xd8, 0x41, 0x00, 0x98, 0xd8, 0x61, 0x00, 0xa0, 0x3f, 0xe0, 0x80, 0x00, - 0x3e, 0x80, 0xcc, 0x00, 0xa3, 0x94, 0x40, 0x10, 0x63, 0x95, 0x00, 0xff, 0xb2, 0xb4, 0x40, 0x10, - 0x48, 0x00, 0x06, 0xb1, 0x3a, 0xa0, 0x00, 0x00, 0x3a, 0xc0, 0x00, 0x19, 0x3a, 0xe0, 0x00, 0xd0, - 0x3f, 0x00, 0xcd, 0x00, 0x63, 0xf2, 0x26, 0xa0, 0x80, 0x01, 0x00, 0xac, 0x90, 0x12, 0x00, 0x04, - 0x92, 0xb8, 0x64, 0x3c, 0x48, 0x00, 0x04, 0x85, 0x41, 0x82, 0x05, 0xfc, 0x2c, 0x1d, 0x00, 0x04, - 0x40, 0x80, 0x00, 0x10, 0x2c, 0x1d, 0x00, 0x01, 0x41, 0x80, 0x05, 0xec, 0x48, 0x00, 0x03, 0xa8, - 0x41, 0x82, 0x05, 0x48, 0x2c, 0x1d, 0x00, 0x06, 0x41, 0x82, 0x00, 0x8c, 0x2c, 0x1d, 0x00, 0x07, - 0x41, 0x82, 0x03, 0x8c, 0x2c, 0x1d, 0x00, 0x08, 0x41, 0x82, 0x05, 0xd8, 0x2c, 0x1d, 0x00, 0x09, - 0x41, 0x82, 0x00, 0xa0, 0x2c, 0x1d, 0x00, 0x10, 0x41, 0x82, 0x00, 0x98, 0x2c, 0x1d, 0x00, 0x2f, - 0x41, 0x82, 0x00, 0x70, 0x2c, 0x1d, 0x00, 0x30, 0x41, 0x82, 0x00, 0x78, 0x2c, 0x1d, 0x00, 0x38, - 0x41, 0x82, 0x05, 0x80, 0x2c, 0x1d, 0x00, 0x40, 0x41, 0x82, 0x03, 0x9c, 0x2c, 0x1d, 0x00, 0x41, - 0x41, 0x82, 0x03, 0xb0, 0x2c, 0x1d, 0x00, 0x44, 0x41, 0x82, 0x00, 0x68, 0x2c, 0x1d, 0x00, 0x50, - 0x41, 0x82, 0x00, 0x20, 0x2c, 0x1d, 0x00, 0x60, 0x41, 0x82, 0x00, 0x24, 0x2c, 0x1d, 0x00, 0x89, - 0x41, 0x82, 0x00, 0x50, 0x2c, 0x1d, 0x00, 0x99, 0x41, 0x82, 0x05, 0x64, 0x48, 0x00, 0x05, 0x68, - 0x80, 0x72, 0x00, 0x00, 0x48, 0x00, 0x04, 0x81, 0x48, 0x00, 0x05, 0x5c, 0x48, 0x00, 0x05, 0xe5, - 0x48, 0x00, 0x05, 0x54, 0x38, 0x80, 0x00, 0x01, 0x90, 0x92, 0x00, 0x00, 0x48, 0x00, 0x05, 0x48, - 0x48, 0x00, 0x04, 0x61, 0x3a, 0x00, 0x00, 0xa0, 0x63, 0xec, 0x26, 0xc4, 0x48, 0x00, 0x03, 0x6c, - 0x38, 0x60, 0x01, 0x20, 0x63, 0xec, 0x26, 0xc4, 0x48, 0x00, 0x04, 0x21, 0x48, 0x00, 0x05, 0x28, - 0x2f, 0x1d, 0x00, 0x10, 0x2e, 0x9d, 0x00, 0x44, 0x63, 0xe4, 0x1a, 0xb4, 0x3c, 0x60, 0x80, 0x00, - 0x60, 0x63, 0x03, 0x00, 0x48, 0x00, 0x05, 0x65, 0x38, 0x63, 0x0a, 0x00, 0x48, 0x00, 0x05, 0x5d, - 0x38, 0x63, 0x06, 0x00, 0x48, 0x00, 0x05, 0x55, 0x63, 0xec, 0x26, 0xb4, 0x92, 0xac, 0x00, 0x00, - 0x92, 0xac, 0x00, 0x04, 0x92, 0xac, 0x00, 0x08, 0x63, 0xe4, 0x26, 0xc4, 0x81, 0x24, 0x00, 0x18, - 0x80, 0x72, 0x00, 0x00, 0x2c, 0x03, 0x00, 0x02, 0x40, 0x82, 0x00, 0x0c, 0x41, 0x96, 0x00, 0x0c, - 0x48, 0x00, 0x00, 0x20, 0x38, 0x60, 0x00, 0x00, 0x90, 0x6c, 0x00, 0x0c, 0x40, 0x82, 0x00, 0x14, - 0x40, 0x96, 0x00, 0x10, 0x61, 0x29, 0x04, 0x00, 0x91, 0x24, 0x00, 0x18, 0x48, 0x00, 0x02, 0x70, - 0x55, 0x29, 0x05, 0xa8, 0x91, 0x24, 0x00, 0x18, 0x41, 0x96, 0x04, 0xac, 0x41, 0x9a, 0x00, 0x08, - 0x39, 0x8c, 0x00, 0x04, 0x38, 0x60, 0x00, 0x04, 0x48, 0x00, 0x03, 0x61, 0x40, 0x99, 0x00, 0x10, - 0x39, 0x8c, 0x00, 0x04, 0x38, 0x60, 0x00, 0x04, 0x48, 0x00, 0x03, 0x51, 0x63, 0xe4, 0x26, 0xb4, - 0x80, 0x64, 0x00, 0x00, 0x80, 0x84, 0x00, 0x04, 0x7c, 0x72, 0xfb, 0xa6, 0x7c, 0x95, 0xfb, 0xa6, - 0x48, 0x00, 0x04, 0x74, 0x7c, 0x32, 0x43, 0xa6, 0x7c, 0x3a, 0x02, 0xa6, 0x7c, 0x73, 0x43, 0xa6, - 0x7c, 0x7b, 0x02, 0xa6, 0x54, 0x63, 0x05, 0xa8, 0x90, 0x60, 0x26, 0xdc, 0x54, 0x63, 0x06, 0x20, - 0x60, 0x63, 0x20, 0x00, 0x54, 0x63, 0x04, 0x5e, 0x7c, 0x7b, 0x03, 0xa6, 0x3c, 0x60, 0x80, 0x00, - 0x60, 0x63, 0x1a, 0xf4, 0x7c, 0x7a, 0x03, 0xa6, 0x4c, 0x00, 0x01, 0x2c, 0x7c, 0x00, 0x04, 0xac, - 0x4c, 0x00, 0x00, 0x64, 0x3c, 0x60, 0x80, 0x00, 0x60, 0x63, 0x26, 0xc4, 0x90, 0x23, 0x00, 0x14, - 0x7c, 0x61, 0x1b, 0x78, 0x7c, 0x73, 0x42, 0xa6, 0xbc, 0x41, 0x00, 0x24, 0x7c, 0x24, 0x0b, 0x78, - 0x7c, 0x32, 0x42, 0xa6, 0x90, 0x04, 0x00, 0x1c, 0x90, 0x24, 0x00, 0x20, 0x7c, 0x68, 0x02, 0xa6, - 0x90, 0x64, 0x00, 0x9c, 0x7c, 0x60, 0x00, 0x26, 0x90, 0x64, 0x00, 0x00, 0x7c, 0x61, 0x02, 0xa6, - 0x90, 0x64, 0x00, 0x04, 0x7c, 0x69, 0x02, 0xa6, 0x90, 0x64, 0x00, 0x08, 0x7c, 0x72, 0x02, 0xa6, - 0x90, 0x64, 0x00, 0x0c, 0x7c, 0x73, 0x02, 0xa6, 0x90, 0x64, 0x00, 0x10, 0x39, 0x20, 0x00, 0x00, - 0x7d, 0x32, 0xfb, 0xa6, 0x7d, 0x35, 0xfb, 0xa6, 0xd0, 0x04, 0x00, 0xa0, 0xd0, 0x24, 0x00, 0xa4, - 0xd0, 0x44, 0x00, 0xa8, 0xd0, 0x64, 0x00, 0xac, 0xd0, 0x84, 0x00, 0xb0, 0xd0, 0xa4, 0x00, 0xb4, - 0xd0, 0xc4, 0x00, 0xb8, 0xd0, 0xe4, 0x00, 0xbc, 0xd1, 0x04, 0x00, 0xc0, 0xd1, 0x24, 0x00, 0xc4, - 0xd1, 0x44, 0x00, 0xc8, 0xd1, 0x64, 0x00, 0xcc, 0xd1, 0x84, 0x00, 0xd0, 0xd1, 0xa4, 0x00, 0xd4, - 0xd1, 0xc4, 0x00, 0xd8, 0xd1, 0xe4, 0x00, 0xdc, 0xd2, 0x04, 0x00, 0xe0, 0xd2, 0x24, 0x00, 0xe4, - 0xd2, 0x44, 0x00, 0xe8, 0xd2, 0x64, 0x00, 0xec, 0xd2, 0x84, 0x00, 0xf0, 0xd2, 0xa4, 0x00, 0xf4, - 0xd2, 0xc4, 0x00, 0xf8, 0xd2, 0xe4, 0x00, 0xfc, 0xd3, 0x04, 0x01, 0x00, 0xd3, 0x24, 0x01, 0x04, - 0xd3, 0x44, 0x01, 0x08, 0xd3, 0x64, 0x01, 0x0c, 0xd3, 0x84, 0x01, 0x10, 0xd3, 0xa4, 0x01, 0x14, - 0xd3, 0xc4, 0x01, 0x18, 0xd3, 0xe4, 0x01, 0x1c, 0x3f, 0xe0, 0x80, 0x00, 0x63, 0xe5, 0x26, 0xb4, - 0x82, 0x05, 0x00, 0x00, 0x82, 0x25, 0x00, 0x04, 0x82, 0x65, 0x00, 0x0c, 0x2c, 0x13, 0x00, 0x00, - 0x41, 0x82, 0x00, 0x74, 0x2c, 0x13, 0x00, 0x02, 0x40, 0x82, 0x00, 0x18, 0x81, 0x24, 0x00, 0x14, - 0x39, 0x33, 0x00, 0x03, 0x91, 0x25, 0x00, 0x00, 0x91, 0x25, 0x00, 0x0c, 0x48, 0x00, 0x00, 0x6c, - 0x7c, 0x10, 0x98, 0x00, 0x41, 0x82, 0x00, 0x38, 0x7c, 0x11, 0x98, 0x00, 0x41, 0x82, 0x00, 0x30, - 0x7d, 0x30, 0x8a, 0x14, 0x91, 0x25, 0x00, 0x0c, 0x82, 0x05, 0x00, 0x08, 0x2c, 0x10, 0x00, 0x00, - 0x41, 0x82, 0x00, 0x48, 0x80, 0x64, 0x00, 0x10, 0x7c, 0x10, 0x18, 0x00, 0x40, 0x82, 0x00, 0x10, - 0x3a, 0x00, 0x00, 0x00, 0x92, 0x05, 0x00, 0x08, 0x48, 0x00, 0x00, 0x30, 0x3a, 0x20, 0x00, 0x00, - 0x92, 0x25, 0x00, 0x0c, 0x81, 0x24, 0x00, 0x18, 0x61, 0x29, 0x04, 0x00, 0x91, 0x24, 0x00, 0x18, - 0x48, 0x00, 0x00, 0x30, 0x7e, 0x12, 0xfb, 0xa6, 0x7e, 0x35, 0xfb, 0xa6, 0x39, 0x20, 0x00, 0x01, - 0x91, 0x25, 0x00, 0x0c, 0x48, 0x00, 0x00, 0x1c, 0x38, 0xa0, 0x00, 0x02, 0x63, 0xe4, 0x26, 0xa0, - 0x90, 0xa4, 0x00, 0x00, 0x38, 0x60, 0x00, 0x11, 0x48, 0x00, 0x01, 0xbd, 0x4b, 0xff, 0xfc, 0x1d, - 0x7c, 0x20, 0x00, 0xa6, 0x54, 0x21, 0x07, 0xfa, 0x54, 0x21, 0x04, 0x5e, 0x7c, 0x20, 0x01, 0x24, - 0x63, 0xe1, 0x26, 0xc4, 0x80, 0x61, 0x00, 0x00, 0x7c, 0x6f, 0xf1, 0x20, 0x80, 0x61, 0x00, 0x14, - 0x7c, 0x7a, 0x03, 0xa6, 0x80, 0x61, 0x00, 0x18, 0x7c, 0x7b, 0x03, 0xa6, 0x80, 0x61, 0x00, 0x9c, - 0x7c, 0x68, 0x03, 0xa6, 0xb8, 0x41, 0x00, 0x24, 0x80, 0x01, 0x00, 0x1c, 0x80, 0x21, 0x00, 0x20, - 0x4c, 0x00, 0x01, 0x2c, 0x7c, 0x00, 0x04, 0xac, 0x4c, 0x00, 0x00, 0x64, 0x92, 0xb2, 0x00, 0x00, - 0x48, 0x00, 0x02, 0x50, 0x2e, 0x9d, 0x00, 0x02, 0x38, 0x60, 0x00, 0x08, 0x63, 0xec, 0x26, 0xa8, - 0x48, 0x00, 0x00, 0xf9, 0x80, 0xac, 0x00, 0x00, 0x80, 0x6c, 0x00, 0x04, 0x98, 0x65, 0x00, 0x00, - 0x41, 0x94, 0x00, 0x10, 0xb0, 0x65, 0x00, 0x00, 0x41, 0x96, 0x00, 0x08, 0x90, 0x65, 0x00, 0x00, - 0x7c, 0x00, 0x28, 0xac, 0x7c, 0x00, 0x04, 0xac, 0x7c, 0x00, 0x2f, 0xac, 0x4c, 0x00, 0x01, 0x2c, - 0x48, 0x00, 0x02, 0x04, 0x48, 0x00, 0x01, 0x1d, 0x38, 0x60, 0x00, 0x04, 0x63, 0xec, 0x26, 0xa8, - 0x48, 0x00, 0x00, 0xb9, 0x82, 0x0c, 0x00, 0x00, 0x63, 0xec, 0x27, 0xe8, 0x48, 0x00, 0x00, 0x1c, - 0x48, 0x00, 0x01, 0x01, 0x38, 0x60, 0x00, 0x08, 0x63, 0xec, 0x26, 0xa8, 0x48, 0x00, 0x00, 0x9d, - 0x82, 0x0c, 0x00, 0x04, 0x81, 0x8c, 0x00, 0x00, 0x63, 0xfb, 0x26, 0xb0, 0x3a, 0x20, 0x0f, 0x80, - 0x48, 0x00, 0x02, 0x3d, 0x41, 0x82, 0x00, 0x20, 0x7e, 0x23, 0x8b, 0x78, 0x48, 0x00, 0x00, 0x7d, - 0x48, 0x00, 0x00, 0xd1, 0x41, 0x82, 0xff, 0xfc, 0x7d, 0x8c, 0x72, 0x14, 0x35, 0x6b, 0xff, 0xff, - 0x41, 0x81, 0xff, 0xe8, 0x80, 0x7b, 0x00, 0x00, 0x2c, 0x03, 0x00, 0x00, 0x41, 0x82, 0x00, 0x08, - 0x48, 0x00, 0x00, 0x59, 0x7c, 0x00, 0x60, 0xac, 0x7c, 0x00, 0x04, 0xac, 0x7c, 0x00, 0x67, 0xac, - 0x4c, 0x00, 0x01, 0x2c, 0x48, 0x00, 0x01, 0x80, 0x7f, 0xc8, 0x02, 0xa6, 0x3c, 0x60, 0xa0, 0x00, - 0x48, 0x00, 0x00, 0x15, 0x76, 0x03, 0x08, 0x00, 0x56, 0x1d, 0x86, 0x3e, 0x7f, 0xc8, 0x03, 0xa6, - 0x4e, 0x80, 0x00, 0x20, 0x92, 0xf8, 0x68, 0x14, 0x90, 0x78, 0x68, 0x24, 0x92, 0xd8, 0x68, 0x20, - 0x80, 0xb8, 0x68, 0x20, 0x70, 0xa5, 0x00, 0x01, 0x40, 0x82, 0xff, 0xf8, 0x82, 0x18, 0x68, 0x24, - 0x90, 0xb8, 0x68, 0x14, 0x4e, 0x80, 0x00, 0x20, 0x7d, 0x48, 0x02, 0xa6, 0x7c, 0x69, 0x03, 0xa6, - 0x39, 0xc0, 0x00, 0x00, 0x48, 0x00, 0x00, 0x79, 0x48, 0x00, 0x00, 0x75, 0x4b, 0xff, 0xff, 0xad, - 0x41, 0x82, 0xff, 0xf4, 0x7f, 0xae, 0x61, 0xae, 0x39, 0xce, 0x00, 0x01, 0x42, 0x00, 0xff, 0xe8, - 0x7d, 0x48, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x20, 0x7d, 0x48, 0x02, 0xa6, 0x7c, 0x69, 0x03, 0xa6, - 0x39, 0xc0, 0x00, 0x00, 0x7c, 0x6c, 0x70, 0xae, 0x48, 0x00, 0x00, 0x1d, 0x41, 0x82, 0xff, 0xf8, - 0x39, 0xce, 0x00, 0x01, 0x42, 0x00, 0xff, 0xf0, 0x7d, 0x48, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x20, - 0x38, 0x60, 0x00, 0xaa, 0x7f, 0xc8, 0x02, 0xa6, 0x54, 0x63, 0xa0, 0x16, 0x64, 0x63, 0xb0, 0x00, - 0x3a, 0xc0, 0x00, 0x19, 0x3a, 0xe0, 0x00, 0xd0, 0x3f, 0x00, 0xcd, 0x00, 0x4b, 0xff, 0xff, 0x69, - 0x56, 0x03, 0x37, 0xff, 0x7f, 0xc8, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x20, 0x7f, 0xc8, 0x02, 0xa6, - 0x3c, 0x60, 0xd0, 0x00, 0x4b, 0xff, 0xff, 0x51, 0x56, 0x03, 0x37, 0xff, 0x41, 0x82, 0xff, 0xf4, - 0x7f, 0xc8, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x20, 0x4b, 0xff, 0xff, 0xb9, 0x38, 0x60, 0x00, 0x08, - 0x63, 0xec, 0x26, 0xa8, 0x4b, 0xff, 0xff, 0x55, 0x80, 0xac, 0x00, 0x04, 0x81, 0x8c, 0x00, 0x00, - 0x63, 0xfb, 0x26, 0xb0, 0x62, 0xb1, 0xf8, 0x00, 0x7e, 0x0c, 0x28, 0x50, 0x48, 0x00, 0x00, 0xf1, - 0x41, 0x81, 0x00, 0x10, 0x82, 0x3b, 0x00, 0x00, 0x2c, 0x11, 0x00, 0x00, 0x41, 0x82, 0x00, 0x68, - 0x7e, 0x23, 0x8b, 0x78, 0x4b, 0xff, 0xff, 0x55, 0x4b, 0xff, 0xff, 0xa5, 0x4b, 0xff, 0xff, 0xa1, - 0x4b, 0xff, 0xfe, 0xd9, 0x41, 0x82, 0xff, 0xf4, 0x2c, 0x1d, 0x00, 0xcc, 0x41, 0x82, 0x00, 0x48, - 0x2c, 0x1d, 0x00, 0xbb, 0x41, 0x82, 0xff, 0xdc, 0x2c, 0x1d, 0x00, 0xaa, 0x40, 0x82, 0xff, 0xdc, - 0x7d, 0x8c, 0x72, 0x14, 0x35, 0x6b, 0xff, 0xff, 0x41, 0x80, 0x00, 0x2c, 0x4b, 0xff, 0xff, 0xb4, - 0x7e, 0xb5, 0xfb, 0xa6, 0x7e, 0xb2, 0xfb, 0xa6, 0x63, 0xe4, 0x26, 0xc4, 0x81, 0x24, 0x00, 0x18, - 0x55, 0x29, 0x05, 0xa8, 0x91, 0x24, 0x00, 0x18, 0x48, 0x00, 0x00, 0x0c, 0x38, 0x60, 0x00, 0x80, - 0x4b, 0xff, 0xff, 0x25, 0x80, 0x92, 0x00, 0x00, 0x2c, 0x04, 0x00, 0x00, 0x40, 0x82, 0xf9, 0xf8, - 0xb3, 0x94, 0x40, 0x10, 0xc8, 0x41, 0x00, 0x98, 0xc8, 0x61, 0x00, 0xa0, 0x7f, 0x20, 0x00, 0xa6, - 0x80, 0x01, 0x00, 0xac, 0x7c, 0x08, 0x03, 0xa6, 0x80, 0x01, 0x00, 0x0c, 0x7c, 0x0f, 0xf1, 0x20, - 0x80, 0x01, 0x00, 0x10, 0x7c, 0x09, 0x03, 0xa6, 0x80, 0x01, 0x00, 0x14, 0x7c, 0x01, 0x03, 0xa6, - 0xb8, 0x61, 0x00, 0x18, 0x80, 0x01, 0x00, 0x08, 0x38, 0x21, 0x00, 0xa8, 0x4c, 0x00, 0x01, 0x2c, - 0x7c, 0x00, 0x04, 0xac, 0x4e, 0x80, 0x00, 0x20, 0x7e, 0x23, 0x20, 0x50, 0x3c, 0xa0, 0x48, 0x00, - 0x52, 0x25, 0x01, 0xba, 0x90, 0xa3, 0x00, 0x00, 0x7c, 0x00, 0x18, 0xac, 0x7c, 0x00, 0x04, 0xac, - 0x7c, 0x00, 0x1f, 0xac, 0x4c, 0x00, 0x01, 0x2c, 0x4e, 0x80, 0x00, 0x20, 0x7d, 0x70, 0x8b, 0xd7, - 0x7d, 0x4b, 0x89, 0xd6, 0x7d, 0x4a, 0x80, 0x50, 0x91, 0x5b, 0x00, 0x00, 0x4e, 0x80, 0x00, 0x20, - 0x7f, 0xa8, 0x02, 0xa6, 0x63, 0xef, 0x27, 0xe8, 0x63, 0xe7, 0x18, 0x08, 0x3c, 0xc0, 0x80, 0x00, - 0x7c, 0xd0, 0x33, 0x78, 0x39, 0x00, 0x00, 0x00, 0x3c, 0x60, 0x00, 0xd0, 0x60, 0x63, 0xc0, 0xde, - 0x80, 0x8f, 0x00, 0x00, 0x7c, 0x03, 0x20, 0x00, 0x40, 0x82, 0x00, 0x18, 0x80, 0x8f, 0x00, 0x04, - 0x7c, 0x03, 0x20, 0x00, 0x40, 0x82, 0x00, 0x0c, 0x39, 0xef, 0x00, 0x08, 0x48, 0x00, 0x00, 0x0c, - 0x7f, 0xa8, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x20, 0x80, 0x6f, 0x00, 0x00, 0x80, 0x8f, 0x00, 0x04, - 0x39, 0xef, 0x00, 0x08, 0x71, 0x09, 0x00, 0x01, 0x2f, 0x89, 0x00, 0x00, 0x39, 0x20, 0x00, 0x00, - 0x54, 0x6a, 0x1f, 0x7e, 0x54, 0x65, 0x3f, 0x7e, 0x74, 0x6b, 0x10, 0x00, 0x54, 0x63, 0x01, 0xfe, - 0x40, 0x82, 0x00, 0x0c, 0x54, 0xcc, 0x00, 0x0c, 0x48, 0x00, 0x00, 0x08, 0x7e, 0x0c, 0x83, 0x78, - 0x2e, 0x05, 0x00, 0x00, 0x2c, 0x0a, 0x00, 0x01, 0x41, 0xa0, 0x00, 0x2c, 0x41, 0xa2, 0x00, 0xe4, - 0x2c, 0x0a, 0x00, 0x03, 0x41, 0xa0, 0x01, 0xb0, 0x41, 0x82, 0x02, 0x54, 0x2c, 0x0a, 0x00, 0x05, - 0x41, 0x80, 0x02, 0xdc, 0x41, 0xa2, 0x04, 0xe8, 0x2c, 0x0a, 0x00, 0x07, 0x41, 0xa0, 0x05, 0x14, - 0x48, 0x00, 0x05, 0xf8, 0x7d, 0x8c, 0x1a, 0x14, 0x2c, 0x05, 0x00, 0x03, 0x41, 0x82, 0x00, 0x48, - 0x41, 0x81, 0x00, 0x60, 0x40, 0xbe, 0xff, 0x84, 0x2e, 0x05, 0x00, 0x01, 0x41, 0x91, 0x00, 0x2c, - 0x54, 0x8a, 0x84, 0x3e, 0x41, 0x92, 0x00, 0x10, 0x7c, 0x89, 0x61, 0xae, 0x39, 0x29, 0x00, 0x01, - 0x48, 0x00, 0x00, 0x0c, 0x7c, 0x89, 0x63, 0x2e, 0x39, 0x29, 0x00, 0x02, 0x35, 0x4a, 0xff, 0xff, - 0x40, 0xa0, 0xff, 0xe4, 0x4b, 0xff, 0xff, 0x54, 0x55, 0x8c, 0x00, 0x3a, 0x90, 0x8c, 0x00, 0x00, - 0x4b, 0xff, 0xff, 0x48, 0x7c, 0x89, 0x23, 0x78, 0x40, 0x9e, 0x04, 0xd0, 0x35, 0x29, 0xff, 0xff, - 0x41, 0x80, 0x04, 0xc8, 0x7c, 0xa9, 0x78, 0xae, 0x7c, 0xa9, 0x61, 0xae, 0x4b, 0xff, 0xff, 0xf0, - 0x39, 0xef, 0x00, 0x08, 0x40, 0xbe, 0xff, 0x24, 0x80, 0xaf, 0xff, 0xf8, 0x81, 0x6f, 0xff, 0xfc, - 0x54, 0xb1, 0x04, 0x3e, 0x54, 0xaa, 0x85, 0x3e, 0x54, 0xa5, 0x27, 0x3e, 0x2e, 0x85, 0x00, 0x01, - 0x41, 0x96, 0x00, 0x10, 0x41, 0xb5, 0x00, 0x14, 0x7c, 0x89, 0x61, 0xae, 0x48, 0x00, 0x00, 0x10, - 0x7c, 0x89, 0x63, 0x2e, 0x48, 0x00, 0x00, 0x08, 0x7c, 0x89, 0x61, 0x2e, 0x7c, 0x84, 0x5a, 0x14, - 0x7d, 0x29, 0x8a, 0x14, 0x35, 0x4a, 0xff, 0xff, 0x40, 0x80, 0xff, 0xd4, 0x4b, 0xff, 0xfe, 0xdc, - 0x54, 0x69, 0x07, 0xff, 0x41, 0x82, 0x00, 0x10, 0x55, 0x08, 0xf8, 0x7e, 0x71, 0x09, 0x00, 0x01, - 0x2f, 0x89, 0x00, 0x00, 0x2e, 0x85, 0x00, 0x04, 0x2d, 0x8a, 0x00, 0x05, 0x7d, 0x13, 0x43, 0x78, - 0x52, 0x68, 0x08, 0x3c, 0x40, 0x9e, 0x00, 0x78, 0x41, 0x8d, 0x04, 0xbc, 0x7d, 0x8c, 0x1a, 0x14, - 0x41, 0x8c, 0x00, 0x0c, 0x41, 0x94, 0x00, 0x30, 0x48, 0x00, 0x00, 0x1c, 0x40, 0x94, 0x00, 0x10, - 0x55, 0x8c, 0x00, 0x3a, 0x81, 0x6c, 0x00, 0x00, 0x48, 0x00, 0x00, 0x1c, 0x55, 0x8c, 0x00, 0x3c, - 0xa1, 0x6c, 0x00, 0x00, 0x7c, 0x89, 0x20, 0xf8, 0x55, 0x29, 0x84, 0x3e, 0x7d, 0x6b, 0x48, 0x38, - 0x54, 0x84, 0x04, 0x3e, 0x7f, 0x0b, 0x20, 0x40, 0x70, 0xa9, 0x00, 0x03, 0x41, 0x82, 0x00, 0x18, - 0x2c, 0x09, 0x00, 0x02, 0x41, 0x82, 0x00, 0x18, 0x41, 0x81, 0x00, 0x1c, 0x40, 0x9a, 0x00, 0x20, - 0x48, 0x00, 0x00, 0x18, 0x41, 0x9a, 0x00, 0x18, 0x48, 0x00, 0x00, 0x10, 0x41, 0x99, 0x00, 0x10, - 0x48, 0x00, 0x00, 0x08, 0x41, 0x98, 0x00, 0x08, 0x61, 0x08, 0x00, 0x01, 0x40, 0x8e, 0xfe, 0x3c, - 0x41, 0x94, 0xfe, 0x38, 0x81, 0x6f, 0xff, 0xf8, 0x40, 0x9e, 0x00, 0x20, 0x70, 0x6c, 0x00, 0x08, - 0x41, 0x82, 0x00, 0x0c, 0x71, 0x0c, 0x00, 0x01, 0x41, 0x82, 0x00, 0x10, 0x39, 0x8b, 0x00, 0x10, - 0x51, 0x8b, 0x03, 0x36, 0x48, 0x00, 0x00, 0x08, 0x55, 0x6b, 0x07, 0x16, 0x91, 0x6f, 0xff, 0xf8, - 0x4b, 0xff, 0xfe, 0x08, 0x40, 0xbe, 0xfe, 0x04, 0x54, 0x69, 0x16, 0xba, 0x54, 0x6e, 0x87, 0xfe, - 0x2d, 0x8e, 0x00, 0x00, 0x2e, 0x05, 0x00, 0x04, 0x70, 0xae, 0x00, 0x03, 0x2e, 0x8e, 0x00, 0x02, - 0x41, 0x94, 0x00, 0x14, 0x41, 0x96, 0x00, 0x50, 0x7c, 0x64, 0x07, 0x34, 0x7c, 0x84, 0x7a, 0x14, - 0x48, 0x00, 0x00, 0x68, 0x54, 0x65, 0xa7, 0xff, 0x41, 0x82, 0x00, 0x0c, 0x7d, 0x27, 0x48, 0x2e, - 0x7c, 0x84, 0x4a, 0x14, 0x41, 0x8e, 0x00, 0x08, 0x7c, 0x8c, 0x22, 0x14, 0x2e, 0x8e, 0x00, 0x01, - 0x41, 0x96, 0x00, 0x08, 0x80, 0x84, 0x00, 0x00, 0x54, 0x63, 0x67, 0xff, 0x41, 0x82, 0x00, 0x3c, - 0x40, 0x90, 0x00, 0x0c, 0x7c, 0x84, 0x32, 0x14, 0x48, 0x00, 0x00, 0x30, 0x7c, 0x84, 0x82, 0x14, - 0x48, 0x00, 0x00, 0x28, 0x54, 0x65, 0xa7, 0xff, 0x41, 0x82, 0x00, 0x0c, 0x7d, 0x27, 0x48, 0x2e, - 0x7c, 0x84, 0x4a, 0x14, 0x40, 0x90, 0x00, 0x0c, 0x7c, 0xcc, 0x21, 0x2e, 0x4b, 0xff, 0xfd, 0x7c, - 0x7e, 0x0c, 0x21, 0x2e, 0x4b, 0xff, 0xfd, 0x74, 0x40, 0x90, 0x00, 0x0c, 0x7c, 0x86, 0x23, 0x78, - 0x4b, 0xff, 0xfd, 0x68, 0x7c, 0x90, 0x23, 0x78, 0x4b, 0xff, 0xfd, 0x60, 0x54, 0x89, 0x1e, 0x78, - 0x39, 0x29, 0x00, 0x40, 0x2c, 0x05, 0x00, 0x02, 0x41, 0x80, 0x00, 0x4c, 0x54, 0x6b, 0x67, 0xbf, - 0x2c, 0x0b, 0x00, 0x01, 0x41, 0x80, 0x00, 0x14, 0x41, 0x82, 0x00, 0x08, 0x48, 0x00, 0x00, 0x10, - 0x41, 0xbe, 0xfd, 0x38, 0x48, 0x00, 0x00, 0x08, 0x40, 0xbe, 0xfd, 0x30, 0x2c, 0x05, 0x00, 0x03, - 0x41, 0x81, 0x00, 0x10, 0x41, 0xa2, 0x00, 0x10, 0x7d, 0xe7, 0x48, 0x2e, 0x4b, 0xff, 0xfd, 0x1c, - 0x7d, 0xe7, 0x49, 0x2e, 0x7c, 0x64, 0x07, 0x34, 0x54, 0x84, 0x1a, 0x78, 0x7d, 0xef, 0x22, 0x14, - 0x4b, 0xff, 0xfd, 0x08, 0x40, 0xbe, 0xfd, 0x04, 0x7c, 0xa7, 0x4a, 0x14, 0x40, 0x92, 0x00, 0x14, - 0x54, 0x64, 0x04, 0x3e, 0x91, 0xe5, 0x00, 0x00, 0x90, 0x85, 0x00, 0x04, 0x4b, 0xff, 0xfc, 0xec, - 0x81, 0x25, 0x00, 0x04, 0x2c, 0x09, 0x00, 0x00, 0x41, 0xa2, 0xfc, 0xe0, 0x39, 0x29, 0xff, 0xff, - 0x91, 0x25, 0x00, 0x04, 0x81, 0xe5, 0x00, 0x00, 0x4b, 0xff, 0xfc, 0xd0, 0x40, 0xbe, 0xfc, 0xcc, - 0x54, 0x6b, 0x16, 0xba, 0x7f, 0x47, 0x5a, 0x14, 0x81, 0x3a, 0x00, 0x00, 0x54, 0x6e, 0x67, 0xbe, - 0x41, 0x92, 0x00, 0x84, 0x2e, 0x05, 0x00, 0x05, 0x40, 0x90, 0x01, 0x74, 0x2e, 0x05, 0x00, 0x03, - 0x40, 0x90, 0x00, 0x90, 0x2e, 0x05, 0x00, 0x01, 0x54, 0x65, 0x87, 0xff, 0x41, 0x82, 0x00, 0x08, - 0x7c, 0x8c, 0x22, 0x14, 0x2f, 0x0e, 0x00, 0x01, 0x40, 0x92, 0x00, 0x24, 0x41, 0xb9, 0x00, 0x18, - 0x41, 0x9a, 0x00, 0x0c, 0x88, 0x84, 0x00, 0x00, 0x48, 0x00, 0x00, 0xf8, 0xa0, 0x84, 0x00, 0x00, - 0x48, 0x00, 0x00, 0xf0, 0x80, 0x84, 0x00, 0x00, 0x48, 0x00, 0x00, 0xe8, 0x54, 0x73, 0xe5, 0x3e, - 0x41, 0xb9, 0x00, 0x20, 0x41, 0x9a, 0x00, 0x10, 0x99, 0x24, 0x00, 0x00, 0x38, 0x84, 0x00, 0x01, - 0x48, 0x00, 0x00, 0x18, 0xb1, 0x24, 0x00, 0x00, 0x38, 0x84, 0x00, 0x02, 0x48, 0x00, 0x00, 0x0c, - 0x91, 0x24, 0x00, 0x00, 0x38, 0x84, 0x00, 0x04, 0x36, 0x73, 0xff, 0xff, 0x40, 0x80, 0xff, 0xd4, - 0x4b, 0xff, 0xfc, 0x38, 0x54, 0x65, 0x87, 0xff, 0x41, 0x82, 0x00, 0x08, 0x7c, 0x84, 0x62, 0x14, - 0x71, 0xc5, 0x00, 0x01, 0x41, 0x82, 0x00, 0x9c, 0x7c, 0x84, 0x4a, 0x14, 0x48, 0x00, 0x00, 0x94, - 0x54, 0x6a, 0x87, 0xbe, 0x54, 0x8e, 0x16, 0xba, 0x7e, 0x67, 0x72, 0x14, 0x40, 0x92, 0x00, 0x08, - 0x3a, 0x6f, 0xff, 0xfc, 0x80, 0x9a, 0x00, 0x00, 0x81, 0x33, 0x00, 0x00, 0x71, 0x4b, 0x00, 0x01, - 0x41, 0x82, 0x00, 0x08, 0x7c, 0x9a, 0x23, 0x78, 0x71, 0x4b, 0x00, 0x02, 0x41, 0x82, 0x00, 0x10, - 0x7d, 0x33, 0x4b, 0x78, 0x40, 0xb2, 0x00, 0x08, 0x7e, 0x6c, 0x9a, 0x14, 0x54, 0x65, 0x67, 0x3f, - 0x2c, 0x05, 0x00, 0x09, 0x40, 0x80, 0x00, 0x54, 0x48, 0x00, 0x00, 0x79, 0x7c, 0x89, 0x22, 0x14, - 0x48, 0x00, 0x00, 0x40, 0x7c, 0x89, 0x21, 0xd6, 0x48, 0x00, 0x00, 0x38, 0x7d, 0x24, 0x23, 0x78, - 0x48, 0x00, 0x00, 0x30, 0x7d, 0x24, 0x20, 0x38, 0x48, 0x00, 0x00, 0x28, 0x7d, 0x24, 0x22, 0x78, - 0x48, 0x00, 0x00, 0x20, 0x7d, 0x24, 0x20, 0x30, 0x48, 0x00, 0x00, 0x18, 0x7d, 0x24, 0x24, 0x30, - 0x48, 0x00, 0x00, 0x10, 0x5d, 0x24, 0x20, 0x3e, 0x48, 0x00, 0x00, 0x08, 0x7d, 0x24, 0x26, 0x30, - 0x90, 0x9a, 0x00, 0x00, 0x4b, 0xff, 0xfb, 0x84, 0x2c, 0x05, 0x00, 0x0a, 0x41, 0x81, 0xfb, 0x7c, - 0xc0, 0x5a, 0x00, 0x00, 0xc0, 0x73, 0x00, 0x00, 0x41, 0x82, 0x00, 0x0c, 0xec, 0x43, 0x10, 0x2a, - 0x48, 0x00, 0x00, 0x08, 0xec, 0x43, 0x00, 0xb2, 0xd0, 0x5a, 0x00, 0x00, 0x4b, 0xff, 0xfb, 0x5c, - 0x7d, 0x48, 0x02, 0xa6, 0x54, 0xa5, 0x1e, 0x78, 0x7d, 0x4a, 0x2a, 0x14, 0x80, 0x9a, 0x00, 0x00, - 0x81, 0x33, 0x00, 0x00, 0x7d, 0x48, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x20, 0x40, 0xbe, 0xfb, 0x3c, - 0x54, 0x69, 0xc0, 0x3e, 0x7d, 0x8e, 0x63, 0x78, 0x48, 0x00, 0x00, 0x35, 0x41, 0x92, 0x00, 0x0c, - 0x7e, 0x31, 0x22, 0x14, 0x48, 0x00, 0x00, 0x08, 0x7d, 0x29, 0x22, 0x14, 0x54, 0x64, 0xc4, 0x3f, - 0x38, 0xa0, 0x00, 0x00, 0x41, 0x82, 0xfb, 0x14, 0x7d, 0x45, 0x88, 0xae, 0x7d, 0x45, 0x49, 0xae, - 0x38, 0xa5, 0x00, 0x01, 0x7c, 0x05, 0x20, 0x00, 0x4b, 0xff, 0xff, 0xec, 0x2e, 0x8a, 0x00, 0x04, - 0x55, 0x31, 0x36, 0xba, 0x2c, 0x11, 0x00, 0x3c, 0x7e, 0x27, 0x88, 0x2e, 0x40, 0x82, 0x00, 0x08, - 0x7d, 0xd1, 0x73, 0x78, 0x41, 0x96, 0x00, 0x08, 0xa2, 0x31, 0x00, 0x00, 0x55, 0x29, 0x56, 0xba, - 0x2c, 0x09, 0x00, 0x3c, 0x7d, 0x27, 0x48, 0x2e, 0x40, 0x82, 0x00, 0x08, 0x7d, 0xc9, 0x73, 0x78, - 0x41, 0x96, 0x00, 0x08, 0xa1, 0x29, 0x00, 0x00, 0x4e, 0x80, 0x00, 0x20, 0x2c, 0x05, 0x00, 0x04, - 0x40, 0x80, 0x00, 0x28, 0x7c, 0x89, 0x23, 0x78, 0x7d, 0xc3, 0x62, 0x14, 0x55, 0xce, 0x00, 0x3c, - 0x4b, 0xff, 0xff, 0xad, 0x7c, 0x84, 0x20, 0xf8, 0x54, 0x84, 0x04, 0x3e, 0x7d, 0x2b, 0x20, 0x38, - 0x7e, 0x24, 0x20, 0x38, 0x4b, 0xff, 0xfb, 0xbc, 0x54, 0x6b, 0xe4, 0x3e, 0x4b, 0xff, 0xfb, 0xb4, - 0x7c, 0x9a, 0x23, 0x78, 0x54, 0x84, 0x18, 0x38, 0x40, 0x92, 0x00, 0x20, 0x40, 0x9e, 0x00, 0x0c, - 0x7d, 0xe8, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x21, 0x7d, 0xe4, 0x7a, 0x14, 0x39, 0xef, 0x00, 0x07, - 0x55, 0xef, 0x00, 0x38, 0x4b, 0xff, 0xfa, 0x64, 0x2e, 0x05, 0x00, 0x03, 0x41, 0x91, 0x00, 0x5c, - 0x3c, 0xa0, 0x48, 0x00, 0x7d, 0x83, 0x62, 0x14, 0x55, 0x8c, 0x00, 0x3a, 0x40, 0x92, 0x00, 0x20, - 0x40, 0xbe, 0xfa, 0x48, 0x57, 0x44, 0x00, 0x3a, 0x7c, 0x8c, 0x20, 0x50, 0x50, 0x85, 0x01, 0xba, - 0x50, 0x65, 0x07, 0xfe, 0x90, 0xac, 0x00, 0x00, 0x4b, 0xff, 0xfa, 0x30, 0x40, 0xbe, 0xff, 0xbc, - 0x7d, 0x2c, 0x78, 0x50, 0x51, 0x25, 0x01, 0xba, 0x90, 0xac, 0x00, 0x00, 0x39, 0x8c, 0x00, 0x04, - 0x7d, 0x6f, 0x22, 0x14, 0x39, 0x6b, 0xff, 0xfc, 0x7d, 0x2b, 0x60, 0x50, 0x51, 0x25, 0x01, 0xba, - 0x90, 0xab, 0x00, 0x00, 0x4b, 0xff, 0xff, 0x94, 0x2e, 0x05, 0x00, 0x06, 0x41, 0x92, 0x00, 0x28, - 0x4b, 0xff, 0xfb, 0x20, 0x55, 0x8c, 0x84, 0x3e, 0x57, 0x44, 0x84, 0x3e, 0x57, 0x5a, 0x04, 0x3e, - 0x7c, 0x0c, 0x20, 0x00, 0x41, 0x80, 0xfb, 0xa4, 0x7c, 0x0c, 0xd0, 0x00, 0x40, 0x80, 0xfb, 0x9c, - 0x4b, 0xff, 0xf9, 0xd8, 0x57, 0x45, 0xff, 0xfe, 0x68, 0xa5, 0x00, 0x01, 0x71, 0x03, 0x00, 0x01, - 0x7c, 0x05, 0x18, 0x00, 0x41, 0x82, 0x00, 0x1c, 0x51, 0x1a, 0x0f, 0xbc, 0x6b, 0x5a, 0x00, 0x02, - 0x57, 0x45, 0xff, 0xff, 0x41, 0x82, 0x00, 0x08, 0x6b, 0x5a, 0x00, 0x01, 0x93, 0x4f, 0xff, 0xfc, - 0x53, 0x48, 0x07, 0xfe, 0x4b, 0xff, 0xf9, 0xa4, 0x2c, 0x0b, 0x00, 0x00, 0x40, 0x82, 0xf9, 0x94, - 0x40, 0x92, 0x00, 0x0c, 0x39, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x14, 0x54, 0x69, 0x06, 0xff, - 0x40, 0x82, 0x00, 0x08, 0x40, 0x9e, 0x00, 0x10, 0x54, 0x65, 0x67, 0xfe, 0x7d, 0x08, 0x4c, 0x30, - 0x7d, 0x08, 0x2a, 0x78, 0x54, 0x85, 0x00, 0x1f, 0x41, 0x82, 0x00, 0x08, 0x7c, 0xa6, 0x2b, 0x78, - 0x54, 0x85, 0x80, 0x1f, 0x41, 0x82, 0x00, 0x08, 0x7c, 0xb0, 0x2b, 0x78, 0x4b, 0xff, 0xf9, 0x5c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x26, 0xa0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x94, 0x21, 0xff, 0x58, 0x90, 0x01, 0x00, 0x08, + 0x7c, 0x08, 0x02, 0xa6, 0x90, 0x01, 0x00, 0xac, 0x7c, 0x00, 0x00, 0x26, 0x90, 0x01, 0x00, 0x0c, + 0x7c, 0x09, 0x02, 0xa6, 0x90, 0x01, 0x00, 0x10, 0x7c, 0x01, 0x02, 0xa6, 0x90, 0x01, 0x00, 0x14, + 0xbc, 0x61, 0x00, 0x18, 0x7f, 0x20, 0x00, 0xa6, 0x63, 0x3a, 0x20, 0x00, 0x73, 0x5a, 0xf9, 0xff, + 0x7f, 0x40, 0x01, 0x24, 0xd8, 0x41, 0x00, 0x98, 0xd8, 0x61, 0x00, 0xa0, 0x3f, 0xe0, 0x80, 0x00, + 0x3e, 0x80, 0xcc, 0x00, 0xa3, 0x94, 0x40, 0x10, 0x63, 0x95, 0x00, 0xff, 0xb2, 0xb4, 0x40, 0x10, + 0x48, 0x00, 0x06, 0xb1, 0x3a, 0xa0, 0x00, 0x00, 0x3a, 0xc0, 0x00, 0x19, 0x3a, 0xe0, 0x00, 0xd0, + 0x3f, 0x00, 0xcd, 0x00, 0x63, 0xf2, 0x26, 0xa0, 0x80, 0x01, 0x00, 0xac, 0x90, 0x12, 0x00, 0x04, + 0x92, 0xb8, 0x64, 0x3c, 0x48, 0x00, 0x04, 0x85, 0x41, 0x82, 0x05, 0xfc, 0x2c, 0x1d, 0x00, 0x04, + 0x40, 0x80, 0x00, 0x10, 0x2c, 0x1d, 0x00, 0x01, 0x41, 0x80, 0x05, 0xec, 0x48, 0x00, 0x03, 0xa8, + 0x41, 0x82, 0x05, 0x48, 0x2c, 0x1d, 0x00, 0x06, 0x41, 0x82, 0x00, 0x8c, 0x2c, 0x1d, 0x00, 0x07, + 0x41, 0x82, 0x03, 0x8c, 0x2c, 0x1d, 0x00, 0x08, 0x41, 0x82, 0x05, 0xd8, 0x2c, 0x1d, 0x00, 0x09, + 0x41, 0x82, 0x00, 0xa0, 0x2c, 0x1d, 0x00, 0x10, 0x41, 0x82, 0x00, 0x98, 0x2c, 0x1d, 0x00, 0x2f, + 0x41, 0x82, 0x00, 0x70, 0x2c, 0x1d, 0x00, 0x30, 0x41, 0x82, 0x00, 0x78, 0x2c, 0x1d, 0x00, 0x38, + 0x41, 0x82, 0x05, 0x80, 0x2c, 0x1d, 0x00, 0x40, 0x41, 0x82, 0x03, 0x9c, 0x2c, 0x1d, 0x00, 0x41, + 0x41, 0x82, 0x03, 0xb0, 0x2c, 0x1d, 0x00, 0x44, 0x41, 0x82, 0x00, 0x68, 0x2c, 0x1d, 0x00, 0x50, + 0x41, 0x82, 0x00, 0x20, 0x2c, 0x1d, 0x00, 0x60, 0x41, 0x82, 0x00, 0x24, 0x2c, 0x1d, 0x00, 0x89, + 0x41, 0x82, 0x00, 0x50, 0x2c, 0x1d, 0x00, 0x99, 0x41, 0x82, 0x05, 0x64, 0x48, 0x00, 0x05, 0x68, + 0x80, 0x72, 0x00, 0x00, 0x48, 0x00, 0x04, 0x81, 0x48, 0x00, 0x05, 0x5c, 0x48, 0x00, 0x05, 0xe5, + 0x48, 0x00, 0x05, 0x54, 0x38, 0x80, 0x00, 0x01, 0x90, 0x92, 0x00, 0x00, 0x48, 0x00, 0x05, 0x48, + 0x48, 0x00, 0x04, 0x61, 0x3a, 0x00, 0x00, 0xa0, 0x63, 0xec, 0x26, 0xc4, 0x48, 0x00, 0x03, 0x6c, + 0x38, 0x60, 0x01, 0x20, 0x63, 0xec, 0x26, 0xc4, 0x48, 0x00, 0x04, 0x21, 0x48, 0x00, 0x05, 0x28, + 0x2f, 0x1d, 0x00, 0x10, 0x2e, 0x9d, 0x00, 0x44, 0x63, 0xe4, 0x1a, 0xb4, 0x3c, 0x60, 0x80, 0x00, + 0x60, 0x63, 0x03, 0x00, 0x48, 0x00, 0x05, 0x65, 0x38, 0x63, 0x0a, 0x00, 0x48, 0x00, 0x05, 0x5d, + 0x38, 0x63, 0x06, 0x00, 0x48, 0x00, 0x05, 0x55, 0x63, 0xec, 0x26, 0xb4, 0x92, 0xac, 0x00, 0x00, + 0x92, 0xac, 0x00, 0x04, 0x92, 0xac, 0x00, 0x08, 0x63, 0xe4, 0x26, 0xc4, 0x81, 0x24, 0x00, 0x18, + 0x80, 0x72, 0x00, 0x00, 0x2c, 0x03, 0x00, 0x02, 0x40, 0x82, 0x00, 0x0c, 0x41, 0x96, 0x00, 0x0c, + 0x48, 0x00, 0x00, 0x20, 0x38, 0x60, 0x00, 0x00, 0x90, 0x6c, 0x00, 0x0c, 0x40, 0x82, 0x00, 0x14, + 0x40, 0x96, 0x00, 0x10, 0x61, 0x29, 0x04, 0x00, 0x91, 0x24, 0x00, 0x18, 0x48, 0x00, 0x02, 0x70, + 0x55, 0x29, 0x05, 0xa8, 0x91, 0x24, 0x00, 0x18, 0x41, 0x96, 0x04, 0xac, 0x41, 0x9a, 0x00, 0x08, + 0x39, 0x8c, 0x00, 0x04, 0x38, 0x60, 0x00, 0x04, 0x48, 0x00, 0x03, 0x61, 0x40, 0x99, 0x00, 0x10, + 0x39, 0x8c, 0x00, 0x04, 0x38, 0x60, 0x00, 0x04, 0x48, 0x00, 0x03, 0x51, 0x63, 0xe4, 0x26, 0xb4, + 0x80, 0x64, 0x00, 0x00, 0x80, 0x84, 0x00, 0x04, 0x7c, 0x72, 0xfb, 0xa6, 0x7c, 0x95, 0xfb, 0xa6, + 0x48, 0x00, 0x04, 0x74, 0x7c, 0x32, 0x43, 0xa6, 0x7c, 0x3a, 0x02, 0xa6, 0x7c, 0x73, 0x43, 0xa6, + 0x7c, 0x7b, 0x02, 0xa6, 0x54, 0x63, 0x05, 0xa8, 0x90, 0x60, 0x26, 0xdc, 0x54, 0x63, 0x06, 0x20, + 0x60, 0x63, 0x20, 0x00, 0x54, 0x63, 0x04, 0x5e, 0x7c, 0x7b, 0x03, 0xa6, 0x3c, 0x60, 0x80, 0x00, + 0x60, 0x63, 0x1a, 0xf4, 0x7c, 0x7a, 0x03, 0xa6, 0x4c, 0x00, 0x01, 0x2c, 0x7c, 0x00, 0x04, 0xac, + 0x4c, 0x00, 0x00, 0x64, 0x3c, 0x60, 0x80, 0x00, 0x60, 0x63, 0x26, 0xc4, 0x90, 0x23, 0x00, 0x14, + 0x7c, 0x61, 0x1b, 0x78, 0x7c, 0x73, 0x42, 0xa6, 0xbc, 0x41, 0x00, 0x24, 0x7c, 0x24, 0x0b, 0x78, + 0x7c, 0x32, 0x42, 0xa6, 0x90, 0x04, 0x00, 0x1c, 0x90, 0x24, 0x00, 0x20, 0x7c, 0x68, 0x02, 0xa6, + 0x90, 0x64, 0x00, 0x9c, 0x7c, 0x60, 0x00, 0x26, 0x90, 0x64, 0x00, 0x00, 0x7c, 0x61, 0x02, 0xa6, + 0x90, 0x64, 0x00, 0x04, 0x7c, 0x69, 0x02, 0xa6, 0x90, 0x64, 0x00, 0x08, 0x7c, 0x72, 0x02, 0xa6, + 0x90, 0x64, 0x00, 0x0c, 0x7c, 0x73, 0x02, 0xa6, 0x90, 0x64, 0x00, 0x10, 0x39, 0x20, 0x00, 0x00, + 0x7d, 0x32, 0xfb, 0xa6, 0x7d, 0x35, 0xfb, 0xa6, 0xd0, 0x04, 0x00, 0xa0, 0xd0, 0x24, 0x00, 0xa4, + 0xd0, 0x44, 0x00, 0xa8, 0xd0, 0x64, 0x00, 0xac, 0xd0, 0x84, 0x00, 0xb0, 0xd0, 0xa4, 0x00, 0xb4, + 0xd0, 0xc4, 0x00, 0xb8, 0xd0, 0xe4, 0x00, 0xbc, 0xd1, 0x04, 0x00, 0xc0, 0xd1, 0x24, 0x00, 0xc4, + 0xd1, 0x44, 0x00, 0xc8, 0xd1, 0x64, 0x00, 0xcc, 0xd1, 0x84, 0x00, 0xd0, 0xd1, 0xa4, 0x00, 0xd4, + 0xd1, 0xc4, 0x00, 0xd8, 0xd1, 0xe4, 0x00, 0xdc, 0xd2, 0x04, 0x00, 0xe0, 0xd2, 0x24, 0x00, 0xe4, + 0xd2, 0x44, 0x00, 0xe8, 0xd2, 0x64, 0x00, 0xec, 0xd2, 0x84, 0x00, 0xf0, 0xd2, 0xa4, 0x00, 0xf4, + 0xd2, 0xc4, 0x00, 0xf8, 0xd2, 0xe4, 0x00, 0xfc, 0xd3, 0x04, 0x01, 0x00, 0xd3, 0x24, 0x01, 0x04, + 0xd3, 0x44, 0x01, 0x08, 0xd3, 0x64, 0x01, 0x0c, 0xd3, 0x84, 0x01, 0x10, 0xd3, 0xa4, 0x01, 0x14, + 0xd3, 0xc4, 0x01, 0x18, 0xd3, 0xe4, 0x01, 0x1c, 0x3f, 0xe0, 0x80, 0x00, 0x63, 0xe5, 0x26, 0xb4, + 0x82, 0x05, 0x00, 0x00, 0x82, 0x25, 0x00, 0x04, 0x82, 0x65, 0x00, 0x0c, 0x2c, 0x13, 0x00, 0x00, + 0x41, 0x82, 0x00, 0x74, 0x2c, 0x13, 0x00, 0x02, 0x40, 0x82, 0x00, 0x18, 0x81, 0x24, 0x00, 0x14, + 0x39, 0x33, 0x00, 0x03, 0x91, 0x25, 0x00, 0x00, 0x91, 0x25, 0x00, 0x0c, 0x48, 0x00, 0x00, 0x6c, + 0x7c, 0x10, 0x98, 0x00, 0x41, 0x82, 0x00, 0x38, 0x7c, 0x11, 0x98, 0x00, 0x41, 0x82, 0x00, 0x30, + 0x7d, 0x30, 0x8a, 0x14, 0x91, 0x25, 0x00, 0x0c, 0x82, 0x05, 0x00, 0x08, 0x2c, 0x10, 0x00, 0x00, + 0x41, 0x82, 0x00, 0x48, 0x80, 0x64, 0x00, 0x10, 0x7c, 0x10, 0x18, 0x00, 0x40, 0x82, 0x00, 0x10, + 0x3a, 0x00, 0x00, 0x00, 0x92, 0x05, 0x00, 0x08, 0x48, 0x00, 0x00, 0x30, 0x3a, 0x20, 0x00, 0x00, + 0x92, 0x25, 0x00, 0x0c, 0x81, 0x24, 0x00, 0x18, 0x61, 0x29, 0x04, 0x00, 0x91, 0x24, 0x00, 0x18, + 0x48, 0x00, 0x00, 0x30, 0x7e, 0x12, 0xfb, 0xa6, 0x7e, 0x35, 0xfb, 0xa6, 0x39, 0x20, 0x00, 0x01, + 0x91, 0x25, 0x00, 0x0c, 0x48, 0x00, 0x00, 0x1c, 0x38, 0xa0, 0x00, 0x02, 0x63, 0xe4, 0x26, 0xa0, + 0x90, 0xa4, 0x00, 0x00, 0x38, 0x60, 0x00, 0x11, 0x48, 0x00, 0x01, 0xbd, 0x4b, 0xff, 0xfc, 0x1d, + 0x7c, 0x20, 0x00, 0xa6, 0x54, 0x21, 0x07, 0xfa, 0x54, 0x21, 0x04, 0x5e, 0x7c, 0x20, 0x01, 0x24, + 0x63, 0xe1, 0x26, 0xc4, 0x80, 0x61, 0x00, 0x00, 0x7c, 0x6f, 0xf1, 0x20, 0x80, 0x61, 0x00, 0x14, + 0x7c, 0x7a, 0x03, 0xa6, 0x80, 0x61, 0x00, 0x18, 0x7c, 0x7b, 0x03, 0xa6, 0x80, 0x61, 0x00, 0x9c, + 0x7c, 0x68, 0x03, 0xa6, 0xb8, 0x41, 0x00, 0x24, 0x80, 0x01, 0x00, 0x1c, 0x80, 0x21, 0x00, 0x20, + 0x4c, 0x00, 0x01, 0x2c, 0x7c, 0x00, 0x04, 0xac, 0x4c, 0x00, 0x00, 0x64, 0x92, 0xb2, 0x00, 0x00, + 0x48, 0x00, 0x02, 0x50, 0x2e, 0x9d, 0x00, 0x02, 0x38, 0x60, 0x00, 0x08, 0x63, 0xec, 0x26, 0xa8, + 0x48, 0x00, 0x00, 0xf9, 0x80, 0xac, 0x00, 0x00, 0x80, 0x6c, 0x00, 0x04, 0x98, 0x65, 0x00, 0x00, + 0x41, 0x94, 0x00, 0x10, 0xb0, 0x65, 0x00, 0x00, 0x41, 0x96, 0x00, 0x08, 0x90, 0x65, 0x00, 0x00, + 0x7c, 0x00, 0x28, 0xac, 0x7c, 0x00, 0x04, 0xac, 0x7c, 0x00, 0x2f, 0xac, 0x4c, 0x00, 0x01, 0x2c, + 0x48, 0x00, 0x02, 0x04, 0x48, 0x00, 0x01, 0x1d, 0x38, 0x60, 0x00, 0x04, 0x63, 0xec, 0x26, 0xa8, + 0x48, 0x00, 0x00, 0xb9, 0x82, 0x0c, 0x00, 0x00, 0x63, 0xec, 0x27, 0xe8, 0x48, 0x00, 0x00, 0x1c, + 0x48, 0x00, 0x01, 0x01, 0x38, 0x60, 0x00, 0x08, 0x63, 0xec, 0x26, 0xa8, 0x48, 0x00, 0x00, 0x9d, + 0x82, 0x0c, 0x00, 0x04, 0x81, 0x8c, 0x00, 0x00, 0x63, 0xfb, 0x26, 0xb0, 0x3a, 0x20, 0x0f, 0x80, + 0x48, 0x00, 0x02, 0x3d, 0x41, 0x82, 0x00, 0x20, 0x7e, 0x23, 0x8b, 0x78, 0x48, 0x00, 0x00, 0x7d, + 0x48, 0x00, 0x00, 0xd1, 0x41, 0x82, 0xff, 0xfc, 0x7d, 0x8c, 0x72, 0x14, 0x35, 0x6b, 0xff, 0xff, + 0x41, 0x81, 0xff, 0xe8, 0x80, 0x7b, 0x00, 0x00, 0x2c, 0x03, 0x00, 0x00, 0x41, 0x82, 0x00, 0x08, + 0x48, 0x00, 0x00, 0x59, 0x7c, 0x00, 0x60, 0xac, 0x7c, 0x00, 0x04, 0xac, 0x7c, 0x00, 0x67, 0xac, + 0x4c, 0x00, 0x01, 0x2c, 0x48, 0x00, 0x01, 0x80, 0x7f, 0xc8, 0x02, 0xa6, 0x3c, 0x60, 0xa0, 0x00, + 0x48, 0x00, 0x00, 0x15, 0x76, 0x03, 0x08, 0x00, 0x56, 0x1d, 0x86, 0x3e, 0x7f, 0xc8, 0x03, 0xa6, + 0x4e, 0x80, 0x00, 0x20, 0x92, 0xf8, 0x68, 0x14, 0x90, 0x78, 0x68, 0x24, 0x92, 0xd8, 0x68, 0x20, + 0x80, 0xb8, 0x68, 0x20, 0x70, 0xa5, 0x00, 0x01, 0x40, 0x82, 0xff, 0xf8, 0x82, 0x18, 0x68, 0x24, + 0x90, 0xb8, 0x68, 0x14, 0x4e, 0x80, 0x00, 0x20, 0x7d, 0x48, 0x02, 0xa6, 0x7c, 0x69, 0x03, 0xa6, + 0x39, 0xc0, 0x00, 0x00, 0x48, 0x00, 0x00, 0x79, 0x48, 0x00, 0x00, 0x75, 0x4b, 0xff, 0xff, 0xad, + 0x41, 0x82, 0xff, 0xf4, 0x7f, 0xae, 0x61, 0xae, 0x39, 0xce, 0x00, 0x01, 0x42, 0x00, 0xff, 0xe8, + 0x7d, 0x48, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x20, 0x7d, 0x48, 0x02, 0xa6, 0x7c, 0x69, 0x03, 0xa6, + 0x39, 0xc0, 0x00, 0x00, 0x7c, 0x6c, 0x70, 0xae, 0x48, 0x00, 0x00, 0x1d, 0x41, 0x82, 0xff, 0xf8, + 0x39, 0xce, 0x00, 0x01, 0x42, 0x00, 0xff, 0xf0, 0x7d, 0x48, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x20, + 0x38, 0x60, 0x00, 0xaa, 0x7f, 0xc8, 0x02, 0xa6, 0x54, 0x63, 0xa0, 0x16, 0x64, 0x63, 0xb0, 0x00, + 0x3a, 0xc0, 0x00, 0x19, 0x3a, 0xe0, 0x00, 0xd0, 0x3f, 0x00, 0xcd, 0x00, 0x4b, 0xff, 0xff, 0x69, + 0x56, 0x03, 0x37, 0xff, 0x7f, 0xc8, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x20, 0x7f, 0xc8, 0x02, 0xa6, + 0x3c, 0x60, 0xd0, 0x00, 0x4b, 0xff, 0xff, 0x51, 0x56, 0x03, 0x37, 0xff, 0x41, 0x82, 0xff, 0xf4, + 0x7f, 0xc8, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x20, 0x4b, 0xff, 0xff, 0xb9, 0x38, 0x60, 0x00, 0x08, + 0x63, 0xec, 0x26, 0xa8, 0x4b, 0xff, 0xff, 0x55, 0x80, 0xac, 0x00, 0x04, 0x81, 0x8c, 0x00, 0x00, + 0x63, 0xfb, 0x26, 0xb0, 0x62, 0xb1, 0xf8, 0x00, 0x7e, 0x0c, 0x28, 0x50, 0x48, 0x00, 0x00, 0xf1, + 0x41, 0x81, 0x00, 0x10, 0x82, 0x3b, 0x00, 0x00, 0x2c, 0x11, 0x00, 0x00, 0x41, 0x82, 0x00, 0x68, + 0x7e, 0x23, 0x8b, 0x78, 0x4b, 0xff, 0xff, 0x55, 0x4b, 0xff, 0xff, 0xa5, 0x4b, 0xff, 0xff, 0xa1, + 0x4b, 0xff, 0xfe, 0xd9, 0x41, 0x82, 0xff, 0xf4, 0x2c, 0x1d, 0x00, 0xcc, 0x41, 0x82, 0x00, 0x48, + 0x2c, 0x1d, 0x00, 0xbb, 0x41, 0x82, 0xff, 0xdc, 0x2c, 0x1d, 0x00, 0xaa, 0x40, 0x82, 0xff, 0xdc, + 0x7d, 0x8c, 0x72, 0x14, 0x35, 0x6b, 0xff, 0xff, 0x41, 0x80, 0x00, 0x2c, 0x4b, 0xff, 0xff, 0xb4, + 0x7e, 0xb5, 0xfb, 0xa6, 0x7e, 0xb2, 0xfb, 0xa6, 0x63, 0xe4, 0x26, 0xc4, 0x81, 0x24, 0x00, 0x18, + 0x55, 0x29, 0x05, 0xa8, 0x91, 0x24, 0x00, 0x18, 0x48, 0x00, 0x00, 0x0c, 0x38, 0x60, 0x00, 0x80, + 0x4b, 0xff, 0xff, 0x25, 0x80, 0x92, 0x00, 0x00, 0x2c, 0x04, 0x00, 0x00, 0x40, 0x82, 0xf9, 0xf8, + 0xb3, 0x94, 0x40, 0x10, 0xc8, 0x41, 0x00, 0x98, 0xc8, 0x61, 0x00, 0xa0, 0x7f, 0x20, 0x00, 0xa6, + 0x80, 0x01, 0x00, 0xac, 0x7c, 0x08, 0x03, 0xa6, 0x80, 0x01, 0x00, 0x0c, 0x7c, 0x0f, 0xf1, 0x20, + 0x80, 0x01, 0x00, 0x10, 0x7c, 0x09, 0x03, 0xa6, 0x80, 0x01, 0x00, 0x14, 0x7c, 0x01, 0x03, 0xa6, + 0xb8, 0x61, 0x00, 0x18, 0x80, 0x01, 0x00, 0x08, 0x38, 0x21, 0x00, 0xa8, 0x4c, 0x00, 0x01, 0x2c, + 0x7c, 0x00, 0x04, 0xac, 0x4e, 0x80, 0x00, 0x20, 0x7e, 0x23, 0x20, 0x50, 0x3c, 0xa0, 0x48, 0x00, + 0x52, 0x25, 0x01, 0xba, 0x90, 0xa3, 0x00, 0x00, 0x7c, 0x00, 0x18, 0xac, 0x7c, 0x00, 0x04, 0xac, + 0x7c, 0x00, 0x1f, 0xac, 0x4c, 0x00, 0x01, 0x2c, 0x4e, 0x80, 0x00, 0x20, 0x7d, 0x70, 0x8b, 0xd7, + 0x7d, 0x4b, 0x89, 0xd6, 0x7d, 0x4a, 0x80, 0x50, 0x91, 0x5b, 0x00, 0x00, 0x4e, 0x80, 0x00, 0x20, + 0x7f, 0xa8, 0x02, 0xa6, 0x63, 0xef, 0x27, 0xe8, 0x63, 0xe7, 0x18, 0x08, 0x3c, 0xc0, 0x80, 0x00, + 0x7c, 0xd0, 0x33, 0x78, 0x39, 0x00, 0x00, 0x00, 0x3c, 0x60, 0x00, 0xd0, 0x60, 0x63, 0xc0, 0xde, + 0x80, 0x8f, 0x00, 0x00, 0x7c, 0x03, 0x20, 0x00, 0x40, 0x82, 0x00, 0x18, 0x80, 0x8f, 0x00, 0x04, + 0x7c, 0x03, 0x20, 0x00, 0x40, 0x82, 0x00, 0x0c, 0x39, 0xef, 0x00, 0x08, 0x48, 0x00, 0x00, 0x0c, + 0x7f, 0xa8, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x20, 0x80, 0x6f, 0x00, 0x00, 0x80, 0x8f, 0x00, 0x04, + 0x39, 0xef, 0x00, 0x08, 0x71, 0x09, 0x00, 0x01, 0x2f, 0x89, 0x00, 0x00, 0x39, 0x20, 0x00, 0x00, + 0x54, 0x6a, 0x1f, 0x7e, 0x54, 0x65, 0x3f, 0x7e, 0x74, 0x6b, 0x10, 0x00, 0x54, 0x63, 0x01, 0xfe, + 0x40, 0x82, 0x00, 0x0c, 0x54, 0xcc, 0x00, 0x0c, 0x48, 0x00, 0x00, 0x08, 0x7e, 0x0c, 0x83, 0x78, + 0x2e, 0x05, 0x00, 0x00, 0x2c, 0x0a, 0x00, 0x01, 0x41, 0xa0, 0x00, 0x2c, 0x41, 0xa2, 0x00, 0xe4, + 0x2c, 0x0a, 0x00, 0x03, 0x41, 0xa0, 0x01, 0xb0, 0x41, 0x82, 0x02, 0x54, 0x2c, 0x0a, 0x00, 0x05, + 0x41, 0x80, 0x02, 0xdc, 0x41, 0xa2, 0x04, 0xe8, 0x2c, 0x0a, 0x00, 0x07, 0x41, 0xa0, 0x05, 0x14, + 0x48, 0x00, 0x05, 0xf8, 0x7d, 0x8c, 0x1a, 0x14, 0x2c, 0x05, 0x00, 0x03, 0x41, 0x82, 0x00, 0x48, + 0x41, 0x81, 0x00, 0x60, 0x40, 0xbe, 0xff, 0x84, 0x2e, 0x05, 0x00, 0x01, 0x41, 0x91, 0x00, 0x2c, + 0x54, 0x8a, 0x84, 0x3e, 0x41, 0x92, 0x00, 0x10, 0x7c, 0x89, 0x61, 0xae, 0x39, 0x29, 0x00, 0x01, + 0x48, 0x00, 0x00, 0x0c, 0x7c, 0x89, 0x63, 0x2e, 0x39, 0x29, 0x00, 0x02, 0x35, 0x4a, 0xff, 0xff, + 0x40, 0xa0, 0xff, 0xe4, 0x4b, 0xff, 0xff, 0x54, 0x55, 0x8c, 0x00, 0x3a, 0x90, 0x8c, 0x00, 0x00, + 0x4b, 0xff, 0xff, 0x48, 0x7c, 0x89, 0x23, 0x78, 0x40, 0x9e, 0x04, 0xd0, 0x35, 0x29, 0xff, 0xff, + 0x41, 0x80, 0x04, 0xc8, 0x7c, 0xa9, 0x78, 0xae, 0x7c, 0xa9, 0x61, 0xae, 0x4b, 0xff, 0xff, 0xf0, + 0x39, 0xef, 0x00, 0x08, 0x40, 0xbe, 0xff, 0x24, 0x80, 0xaf, 0xff, 0xf8, 0x81, 0x6f, 0xff, 0xfc, + 0x54, 0xb1, 0x04, 0x3e, 0x54, 0xaa, 0x85, 0x3e, 0x54, 0xa5, 0x27, 0x3e, 0x2e, 0x85, 0x00, 0x01, + 0x41, 0x96, 0x00, 0x10, 0x41, 0xb5, 0x00, 0x14, 0x7c, 0x89, 0x61, 0xae, 0x48, 0x00, 0x00, 0x10, + 0x7c, 0x89, 0x63, 0x2e, 0x48, 0x00, 0x00, 0x08, 0x7c, 0x89, 0x61, 0x2e, 0x7c, 0x84, 0x5a, 0x14, + 0x7d, 0x29, 0x8a, 0x14, 0x35, 0x4a, 0xff, 0xff, 0x40, 0x80, 0xff, 0xd4, 0x4b, 0xff, 0xfe, 0xdc, + 0x54, 0x69, 0x07, 0xff, 0x41, 0x82, 0x00, 0x10, 0x55, 0x08, 0xf8, 0x7e, 0x71, 0x09, 0x00, 0x01, + 0x2f, 0x89, 0x00, 0x00, 0x2e, 0x85, 0x00, 0x04, 0x2d, 0x8a, 0x00, 0x05, 0x7d, 0x13, 0x43, 0x78, + 0x52, 0x68, 0x08, 0x3c, 0x40, 0x9e, 0x00, 0x78, 0x41, 0x8d, 0x04, 0xbc, 0x7d, 0x8c, 0x1a, 0x14, + 0x41, 0x8c, 0x00, 0x0c, 0x41, 0x94, 0x00, 0x30, 0x48, 0x00, 0x00, 0x1c, 0x40, 0x94, 0x00, 0x10, + 0x55, 0x8c, 0x00, 0x3a, 0x81, 0x6c, 0x00, 0x00, 0x48, 0x00, 0x00, 0x1c, 0x55, 0x8c, 0x00, 0x3c, + 0xa1, 0x6c, 0x00, 0x00, 0x7c, 0x89, 0x20, 0xf8, 0x55, 0x29, 0x84, 0x3e, 0x7d, 0x6b, 0x48, 0x38, + 0x54, 0x84, 0x04, 0x3e, 0x7f, 0x0b, 0x20, 0x40, 0x70, 0xa9, 0x00, 0x03, 0x41, 0x82, 0x00, 0x18, + 0x2c, 0x09, 0x00, 0x02, 0x41, 0x82, 0x00, 0x18, 0x41, 0x81, 0x00, 0x1c, 0x40, 0x9a, 0x00, 0x20, + 0x48, 0x00, 0x00, 0x18, 0x41, 0x9a, 0x00, 0x18, 0x48, 0x00, 0x00, 0x10, 0x41, 0x99, 0x00, 0x10, + 0x48, 0x00, 0x00, 0x08, 0x41, 0x98, 0x00, 0x08, 0x61, 0x08, 0x00, 0x01, 0x40, 0x8e, 0xfe, 0x3c, + 0x41, 0x94, 0xfe, 0x38, 0x81, 0x6f, 0xff, 0xf8, 0x40, 0x9e, 0x00, 0x20, 0x70, 0x6c, 0x00, 0x08, + 0x41, 0x82, 0x00, 0x0c, 0x71, 0x0c, 0x00, 0x01, 0x41, 0x82, 0x00, 0x10, 0x39, 0x8b, 0x00, 0x10, + 0x51, 0x8b, 0x03, 0x36, 0x48, 0x00, 0x00, 0x08, 0x55, 0x6b, 0x07, 0x16, 0x91, 0x6f, 0xff, 0xf8, + 0x4b, 0xff, 0xfe, 0x08, 0x40, 0xbe, 0xfe, 0x04, 0x54, 0x69, 0x16, 0xba, 0x54, 0x6e, 0x87, 0xfe, + 0x2d, 0x8e, 0x00, 0x00, 0x2e, 0x05, 0x00, 0x04, 0x70, 0xae, 0x00, 0x03, 0x2e, 0x8e, 0x00, 0x02, + 0x41, 0x94, 0x00, 0x14, 0x41, 0x96, 0x00, 0x50, 0x7c, 0x64, 0x07, 0x34, 0x7c, 0x84, 0x7a, 0x14, + 0x48, 0x00, 0x00, 0x68, 0x54, 0x65, 0xa7, 0xff, 0x41, 0x82, 0x00, 0x0c, 0x7d, 0x27, 0x48, 0x2e, + 0x7c, 0x84, 0x4a, 0x14, 0x41, 0x8e, 0x00, 0x08, 0x7c, 0x8c, 0x22, 0x14, 0x2e, 0x8e, 0x00, 0x01, + 0x41, 0x96, 0x00, 0x08, 0x80, 0x84, 0x00, 0x00, 0x54, 0x63, 0x67, 0xff, 0x41, 0x82, 0x00, 0x3c, + 0x40, 0x90, 0x00, 0x0c, 0x7c, 0x84, 0x32, 0x14, 0x48, 0x00, 0x00, 0x30, 0x7c, 0x84, 0x82, 0x14, + 0x48, 0x00, 0x00, 0x28, 0x54, 0x65, 0xa7, 0xff, 0x41, 0x82, 0x00, 0x0c, 0x7d, 0x27, 0x48, 0x2e, + 0x7c, 0x84, 0x4a, 0x14, 0x40, 0x90, 0x00, 0x0c, 0x7c, 0xcc, 0x21, 0x2e, 0x4b, 0xff, 0xfd, 0x7c, + 0x7e, 0x0c, 0x21, 0x2e, 0x4b, 0xff, 0xfd, 0x74, 0x40, 0x90, 0x00, 0x0c, 0x7c, 0x86, 0x23, 0x78, + 0x4b, 0xff, 0xfd, 0x68, 0x7c, 0x90, 0x23, 0x78, 0x4b, 0xff, 0xfd, 0x60, 0x54, 0x89, 0x1e, 0x78, + 0x39, 0x29, 0x00, 0x40, 0x2c, 0x05, 0x00, 0x02, 0x41, 0x80, 0x00, 0x4c, 0x54, 0x6b, 0x67, 0xbf, + 0x2c, 0x0b, 0x00, 0x01, 0x41, 0x80, 0x00, 0x14, 0x41, 0x82, 0x00, 0x08, 0x48, 0x00, 0x00, 0x10, + 0x41, 0xbe, 0xfd, 0x38, 0x48, 0x00, 0x00, 0x08, 0x40, 0xbe, 0xfd, 0x30, 0x2c, 0x05, 0x00, 0x03, + 0x41, 0x81, 0x00, 0x10, 0x41, 0xa2, 0x00, 0x10, 0x7d, 0xe7, 0x48, 0x2e, 0x4b, 0xff, 0xfd, 0x1c, + 0x7d, 0xe7, 0x49, 0x2e, 0x7c, 0x64, 0x07, 0x34, 0x54, 0x84, 0x1a, 0x78, 0x7d, 0xef, 0x22, 0x14, + 0x4b, 0xff, 0xfd, 0x08, 0x40, 0xbe, 0xfd, 0x04, 0x7c, 0xa7, 0x4a, 0x14, 0x40, 0x92, 0x00, 0x14, + 0x54, 0x64, 0x04, 0x3e, 0x91, 0xe5, 0x00, 0x00, 0x90, 0x85, 0x00, 0x04, 0x4b, 0xff, 0xfc, 0xec, + 0x81, 0x25, 0x00, 0x04, 0x2c, 0x09, 0x00, 0x00, 0x41, 0xa2, 0xfc, 0xe0, 0x39, 0x29, 0xff, 0xff, + 0x91, 0x25, 0x00, 0x04, 0x81, 0xe5, 0x00, 0x00, 0x4b, 0xff, 0xfc, 0xd0, 0x40, 0xbe, 0xfc, 0xcc, + 0x54, 0x6b, 0x16, 0xba, 0x7f, 0x47, 0x5a, 0x14, 0x81, 0x3a, 0x00, 0x00, 0x54, 0x6e, 0x67, 0xbe, + 0x41, 0x92, 0x00, 0x84, 0x2e, 0x05, 0x00, 0x05, 0x40, 0x90, 0x01, 0x74, 0x2e, 0x05, 0x00, 0x03, + 0x40, 0x90, 0x00, 0x90, 0x2e, 0x05, 0x00, 0x01, 0x54, 0x65, 0x87, 0xff, 0x41, 0x82, 0x00, 0x08, + 0x7c, 0x8c, 0x22, 0x14, 0x2f, 0x0e, 0x00, 0x01, 0x40, 0x92, 0x00, 0x24, 0x41, 0xb9, 0x00, 0x18, + 0x41, 0x9a, 0x00, 0x0c, 0x88, 0x84, 0x00, 0x00, 0x48, 0x00, 0x00, 0xf8, 0xa0, 0x84, 0x00, 0x00, + 0x48, 0x00, 0x00, 0xf0, 0x80, 0x84, 0x00, 0x00, 0x48, 0x00, 0x00, 0xe8, 0x54, 0x73, 0xe5, 0x3e, + 0x41, 0xb9, 0x00, 0x20, 0x41, 0x9a, 0x00, 0x10, 0x99, 0x24, 0x00, 0x00, 0x38, 0x84, 0x00, 0x01, + 0x48, 0x00, 0x00, 0x18, 0xb1, 0x24, 0x00, 0x00, 0x38, 0x84, 0x00, 0x02, 0x48, 0x00, 0x00, 0x0c, + 0x91, 0x24, 0x00, 0x00, 0x38, 0x84, 0x00, 0x04, 0x36, 0x73, 0xff, 0xff, 0x40, 0x80, 0xff, 0xd4, + 0x4b, 0xff, 0xfc, 0x38, 0x54, 0x65, 0x87, 0xff, 0x41, 0x82, 0x00, 0x08, 0x7c, 0x84, 0x62, 0x14, + 0x71, 0xc5, 0x00, 0x01, 0x41, 0x82, 0x00, 0x9c, 0x7c, 0x84, 0x4a, 0x14, 0x48, 0x00, 0x00, 0x94, + 0x54, 0x6a, 0x87, 0xbe, 0x54, 0x8e, 0x16, 0xba, 0x7e, 0x67, 0x72, 0x14, 0x40, 0x92, 0x00, 0x08, + 0x3a, 0x6f, 0xff, 0xfc, 0x80, 0x9a, 0x00, 0x00, 0x81, 0x33, 0x00, 0x00, 0x71, 0x4b, 0x00, 0x01, + 0x41, 0x82, 0x00, 0x08, 0x7c, 0x9a, 0x23, 0x78, 0x71, 0x4b, 0x00, 0x02, 0x41, 0x82, 0x00, 0x10, + 0x7d, 0x33, 0x4b, 0x78, 0x40, 0xb2, 0x00, 0x08, 0x7e, 0x6c, 0x9a, 0x14, 0x54, 0x65, 0x67, 0x3f, + 0x2c, 0x05, 0x00, 0x09, 0x40, 0x80, 0x00, 0x54, 0x48, 0x00, 0x00, 0x79, 0x7c, 0x89, 0x22, 0x14, + 0x48, 0x00, 0x00, 0x40, 0x7c, 0x89, 0x21, 0xd6, 0x48, 0x00, 0x00, 0x38, 0x7d, 0x24, 0x23, 0x78, + 0x48, 0x00, 0x00, 0x30, 0x7d, 0x24, 0x20, 0x38, 0x48, 0x00, 0x00, 0x28, 0x7d, 0x24, 0x22, 0x78, + 0x48, 0x00, 0x00, 0x20, 0x7d, 0x24, 0x20, 0x30, 0x48, 0x00, 0x00, 0x18, 0x7d, 0x24, 0x24, 0x30, + 0x48, 0x00, 0x00, 0x10, 0x5d, 0x24, 0x20, 0x3e, 0x48, 0x00, 0x00, 0x08, 0x7d, 0x24, 0x26, 0x30, + 0x90, 0x9a, 0x00, 0x00, 0x4b, 0xff, 0xfb, 0x84, 0x2c, 0x05, 0x00, 0x0a, 0x41, 0x81, 0xfb, 0x7c, + 0xc0, 0x5a, 0x00, 0x00, 0xc0, 0x73, 0x00, 0x00, 0x41, 0x82, 0x00, 0x0c, 0xec, 0x43, 0x10, 0x2a, + 0x48, 0x00, 0x00, 0x08, 0xec, 0x43, 0x00, 0xb2, 0xd0, 0x5a, 0x00, 0x00, 0x4b, 0xff, 0xfb, 0x5c, + 0x7d, 0x48, 0x02, 0xa6, 0x54, 0xa5, 0x1e, 0x78, 0x7d, 0x4a, 0x2a, 0x14, 0x80, 0x9a, 0x00, 0x00, + 0x81, 0x33, 0x00, 0x00, 0x7d, 0x48, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x20, 0x40, 0xbe, 0xfb, 0x3c, + 0x54, 0x69, 0xc0, 0x3e, 0x7d, 0x8e, 0x63, 0x78, 0x48, 0x00, 0x00, 0x35, 0x41, 0x92, 0x00, 0x0c, + 0x7e, 0x31, 0x22, 0x14, 0x48, 0x00, 0x00, 0x08, 0x7d, 0x29, 0x22, 0x14, 0x54, 0x64, 0xc4, 0x3f, + 0x38, 0xa0, 0x00, 0x00, 0x41, 0x82, 0xfb, 0x14, 0x7d, 0x45, 0x88, 0xae, 0x7d, 0x45, 0x49, 0xae, + 0x38, 0xa5, 0x00, 0x01, 0x7c, 0x05, 0x20, 0x00, 0x4b, 0xff, 0xff, 0xec, 0x2e, 0x8a, 0x00, 0x04, + 0x55, 0x31, 0x36, 0xba, 0x2c, 0x11, 0x00, 0x3c, 0x7e, 0x27, 0x88, 0x2e, 0x40, 0x82, 0x00, 0x08, + 0x7d, 0xd1, 0x73, 0x78, 0x41, 0x96, 0x00, 0x08, 0xa2, 0x31, 0x00, 0x00, 0x55, 0x29, 0x56, 0xba, + 0x2c, 0x09, 0x00, 0x3c, 0x7d, 0x27, 0x48, 0x2e, 0x40, 0x82, 0x00, 0x08, 0x7d, 0xc9, 0x73, 0x78, + 0x41, 0x96, 0x00, 0x08, 0xa1, 0x29, 0x00, 0x00, 0x4e, 0x80, 0x00, 0x20, 0x2c, 0x05, 0x00, 0x04, + 0x40, 0x80, 0x00, 0x28, 0x7c, 0x89, 0x23, 0x78, 0x7d, 0xc3, 0x62, 0x14, 0x55, 0xce, 0x00, 0x3c, + 0x4b, 0xff, 0xff, 0xad, 0x7c, 0x84, 0x20, 0xf8, 0x54, 0x84, 0x04, 0x3e, 0x7d, 0x2b, 0x20, 0x38, + 0x7e, 0x24, 0x20, 0x38, 0x4b, 0xff, 0xfb, 0xbc, 0x54, 0x6b, 0xe4, 0x3e, 0x4b, 0xff, 0xfb, 0xb4, + 0x7c, 0x9a, 0x23, 0x78, 0x54, 0x84, 0x18, 0x38, 0x40, 0x92, 0x00, 0x20, 0x40, 0x9e, 0x00, 0x0c, + 0x7d, 0xe8, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x21, 0x7d, 0xe4, 0x7a, 0x14, 0x39, 0xef, 0x00, 0x07, + 0x55, 0xef, 0x00, 0x38, 0x4b, 0xff, 0xfa, 0x64, 0x2e, 0x05, 0x00, 0x03, 0x41, 0x91, 0x00, 0x5c, + 0x3c, 0xa0, 0x48, 0x00, 0x7d, 0x83, 0x62, 0x14, 0x55, 0x8c, 0x00, 0x3a, 0x40, 0x92, 0x00, 0x20, + 0x40, 0xbe, 0xfa, 0x48, 0x57, 0x44, 0x00, 0x3a, 0x7c, 0x8c, 0x20, 0x50, 0x50, 0x85, 0x01, 0xba, + 0x50, 0x65, 0x07, 0xfe, 0x90, 0xac, 0x00, 0x00, 0x4b, 0xff, 0xfa, 0x30, 0x40, 0xbe, 0xff, 0xbc, + 0x7d, 0x2c, 0x78, 0x50, 0x51, 0x25, 0x01, 0xba, 0x90, 0xac, 0x00, 0x00, 0x39, 0x8c, 0x00, 0x04, + 0x7d, 0x6f, 0x22, 0x14, 0x39, 0x6b, 0xff, 0xfc, 0x7d, 0x2b, 0x60, 0x50, 0x51, 0x25, 0x01, 0xba, + 0x90, 0xab, 0x00, 0x00, 0x4b, 0xff, 0xff, 0x94, 0x2e, 0x05, 0x00, 0x06, 0x41, 0x92, 0x00, 0x28, + 0x4b, 0xff, 0xfb, 0x20, 0x55, 0x8c, 0x84, 0x3e, 0x57, 0x44, 0x84, 0x3e, 0x57, 0x5a, 0x04, 0x3e, + 0x7c, 0x0c, 0x20, 0x00, 0x41, 0x80, 0xfb, 0xa4, 0x7c, 0x0c, 0xd0, 0x00, 0x40, 0x80, 0xfb, 0x9c, + 0x4b, 0xff, 0xf9, 0xd8, 0x57, 0x45, 0xff, 0xfe, 0x68, 0xa5, 0x00, 0x01, 0x71, 0x03, 0x00, 0x01, + 0x7c, 0x05, 0x18, 0x00, 0x41, 0x82, 0x00, 0x1c, 0x51, 0x1a, 0x0f, 0xbc, 0x6b, 0x5a, 0x00, 0x02, + 0x57, 0x45, 0xff, 0xff, 0x41, 0x82, 0x00, 0x08, 0x6b, 0x5a, 0x00, 0x01, 0x93, 0x4f, 0xff, 0xfc, + 0x53, 0x48, 0x07, 0xfe, 0x4b, 0xff, 0xf9, 0xa4, 0x2c, 0x0b, 0x00, 0x00, 0x40, 0x82, 0xf9, 0x94, + 0x40, 0x92, 0x00, 0x0c, 0x39, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x14, 0x54, 0x69, 0x06, 0xff, + 0x40, 0x82, 0x00, 0x08, 0x40, 0x9e, 0x00, 0x10, 0x54, 0x65, 0x67, 0xfe, 0x7d, 0x08, 0x4c, 0x30, + 0x7d, 0x08, 0x2a, 0x78, 0x54, 0x85, 0x00, 0x1f, 0x41, 0x82, 0x00, 0x08, 0x7c, 0xa6, 0x2b, 0x78, + 0x54, 0x85, 0x80, 0x1f, 0x41, 0x82, 0x00, 0x08, 0x7c, 0xb0, 0x2b, 0x78, 0x4b, 0xff, 0xf9, 0x5c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; const int kenobiwii_size = sizeof(kenobiwii); diff --git a/source/patches/patchcode.c b/source/patches/patchcode.c index 9382e7a0..d9dc178b 100644 --- a/source/patches/patchcode.c +++ b/source/patches/patchcode.c @@ -58,35 +58,35 @@ extern void vipatch(u32 address, u32 len); extern u32 regionfreeselect; static const u32 viwiihooks[4] = { - 0x7CE33B78,0x38870034,0x38A70038,0x38C7004C + 0x7CE33B78,0x38870034,0x38A70038,0x38C7004C }; static const u32 multidolpatch1[2] = { - 0x3C03FFB4,0x28004F43 -}; + 0x3C03FFB4,0x28004F43 +}; static const u32 healthcheckhook[2] = { - 0x41810010,0x881D007D -}; + 0x41810010,0x881D007D +}; static const u32 updatecheckhook[3] = { - 0x80650050,0x80850054,0xA0A50058 + 0x80650050,0x80850054,0xA0A50058 }; static const u32 multidolpatch2[2] = { - 0x3F608000, 0x807B0018 + 0x3F608000, 0x807B0018 }; static const u32 recoveryhooks[3] = { - 0xA00100AC,0x5400073E,0x2C00000F + 0xA00100AC,0x5400073E,0x2C00000F }; static const u32 nocopyflag1[3] = { - 0x540007FF, 0x4182001C, 0x80630068 + 0x540007FF, 0x4182001C, 0x80630068 }; static const u32 nocopyflag2[3] = { - 0x540007FF, 0x41820024, 0x387E12E2 + 0x540007FF, 0x41820024, 0x387E12E2 }; // this one is for the GH3 and VC saves @@ -95,265 +95,254 @@ static const u32 nocopyflag2[3] = { //}; static const u32 nocopyflag3[5] = { - 0x2C030000, 0x41820200,0x48000058,0x38610100 + 0x2C030000, 0x41820200,0x48000058,0x38610100 }; // this removes the display warning for no copy VC and GH3 saves static const u32 nocopyflag4[4] = { - 0x80010008, 0x2C000000, 0x4182000C, 0x3BE00001 + 0x80010008, 0x2C000000, 0x4182000C, 0x3BE00001 }; static const u32 nocopyflag5[3] = { - 0x801D0024,0x540007FF,0x41820024 + 0x801D0024,0x540007FF,0x41820024 }; static const u32 movedvdpatch[3] = { - 0x2C040000, 0x41820120, 0x3C608109 + 0x2C040000, 0x41820120, 0x3C608109 }; - + static const u32 regionfreehooks[5] = { - 0x7C600774, 0x2C000001, 0x41820030,0x40800010,0x2C000000 + 0x7C600774, 0x2C000001, 0x41820030,0x40800010,0x2C000000 }; static const u32 fwritepatch[8] = { - 0x9421FFD0,0x7C0802A6,0x90010034,0xBF210014,0x7C9B2378,0x7CDC3378,0x7C7A1B78,0x7CB92B78 // bushing fwrite + 0x9421FFD0,0x7C0802A6,0x90010034,0xBF210014,0x7C9B2378,0x7CDC3378,0x7C7A1B78,0x7CB92B78 // bushing fwrite }; static const u32 kpadhooks[4] = { - 0x9A3F005E,0x38AE0080,0x389FFFFC,0x7E0903A6 + 0x9A3F005E,0x38AE0080,0x389FFFFC,0x7E0903A6 }; static const u32 kpadoldhooks[6] = { - 0x801D0060, 0x901E0060, 0x801D0064, 0x901E0064, 0x801D0068, 0x901E0068 + 0x801D0060, 0x901E0060, 0x801D0064, 0x901E0064, 0x801D0068, 0x901E0068 }; static const u32 joypadhooks[4] = { - 0x3AB50001, 0x3A73000C, 0x2C150004, 0x3B18000C + 0x3AB50001, 0x3A73000C, 0x2C150004, 0x3B18000C }; static const u32 langpatch[3] = { - 0x7C600775, 0x40820010, 0x38000000 + 0x7C600775, 0x40820010, 0x38000000 }; static const u32 vipatchcode[3] = { - 0x4182000C,0x4180001C,0x48000018 + 0x4182000C,0x4180001C,0x48000018 }; static const u32 wpadlibogc[5] = { // 0x38A00140, 0x7C095878, 0x7D600078, 0x901F0010,0x913F0014 // 0x7FA00124, 0x8001001C, 0x83810008, 0x83A1000C,0x7C0803A6 - 0x90A402E0,0x806502E4,0x908502E4,0x2C030000,0x906402E4 + 0x90A402E0,0x806502E4,0x908502E4,0x2C030000,0x906402E4 }; -void dogamehooks(void *addr, u32 len) -{ - void *addr_start = addr; - void *addr_end = addr+len; +void dogamehooks(void *addr, u32 len) { + void *addr_start = addr; + void *addr_end = addr+len; - while(addr_start < addr_end) - { - - switch(hooktype) - { - - case 0: - - break; - - case 1: - if(memcmp(addr_start, viwiihooks, sizeof(viwiihooks))==0){ - // printf("\n\n\n"); - // printf("found at address %x\n", addr_start); - // sleep(2); - patchhook((u32)addr_start, len); - patched = 1; - hooktype = 1; - } - break; + while (addr_start < addr_end) { -/* - case 2: - if(memcmp(addr_start, kpadhooks, sizeof(kpadhooks))==0){ - patchhook((u32)addr_start, len); - patched = 1; - } + switch (hooktype) { - if(memcmp(addr_start, kpadoldhooks, sizeof(kpadoldhooks))==0){ - patchhook((u32)addr_start, len); - patched = 1; - } - break; - - case 3: - if(memcmp(addr_start, joypadhooks, sizeof(joypadhooks))==0){ - patchhook((u32)addr_start, len); - patched = 1; - } - break; + case 0: - case 4: - if(memcmp(addr_start, recoveryhooks, sizeof(recoveryhooks))==0){ - patchhook3((u32)addr_start, len); - } - break; -*/ - case 2: + break; - if(memcmp(addr_start, viwiihooks, sizeof(viwiihooks))==0){ - patchhook2((u32)addr_start, len); - } - - break; + case 1: + if (memcmp(addr_start, viwiihooks, sizeof(viwiihooks))==0) { + // printf("\n\n\n"); + // printf("found at address %x\n", addr_start); + // sleep(2); + patchhook((u32)addr_start, len); + patched = 1; + hooktype = 1; + } + break; -/* - case 6: - // jap region free - if(memcmp(addr_start, regionfreehooks, sizeof(regionfreehooks))==0){ - regionfreejap((u32)addr_start, len); - } + /* + case 2: + if(memcmp(addr_start, kpadhooks, sizeof(kpadhooks))==0){ + patchhook((u32)addr_start, len); + patched = 1; + } - // usa region free - if(memcmp(addr_start, regionfreehooks, sizeof(regionfreehooks))==0){ - regionfreeusa((u32)addr_start, len); - } + if(memcmp(addr_start, kpadoldhooks, sizeof(kpadoldhooks))==0){ + patchhook((u32)addr_start, len); + patched = 1; + } + break; - // pal region free - if(memcmp(addr_start, regionfreehooks, sizeof(regionfreehooks))==0){ - regionfreepal((u32)addr_start, len); - } + case 3: + if(memcmp(addr_start, joypadhooks, sizeof(joypadhooks))==0){ + patchhook((u32)addr_start, len); + patched = 1; + } + break; - // skip disc update - if(memcmp(addr_start, updatecheckhook, sizeof(updatecheckhook))==0){ - patchupdatecheck((u32)addr_start, len); - } - break; + case 4: + if(memcmp(addr_start, recoveryhooks, sizeof(recoveryhooks))==0){ + patchhook3((u32)addr_start, len); + } + break; + */ + case 2: + + 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){ + regionfreejap((u32)addr_start, len); + } + + // usa region free + if(memcmp(addr_start, regionfreehooks, sizeof(regionfreehooks))==0){ + regionfreeusa((u32)addr_start, len); + } + + // pal region free + if(memcmp(addr_start, regionfreehooks, sizeof(regionfreehooks))==0){ + regionfreepal((u32)addr_start, len); + } + + // skip disc update + if(memcmp(addr_start, updatecheckhook, sizeof(updatecheckhook))==0){ + patchupdatecheck((u32)addr_start, len); + } + break; - case 7: - if(memcmp(addr_start, healthcheckhook, sizeof(healthcheckhook))==0){ - removehealthcheck((u32)addr_start, len); - } - break; + case 7: + if(memcmp(addr_start, healthcheckhook, sizeof(healthcheckhook))==0){ + removehealthcheck((u32)addr_start, len); + } + break; - // no copy flags - case 8: - // Remove the actual flag so can copy back - if(memcmp(addr_start, nocopyflag5, sizeof(nocopyflag5))==0){ - copyflagcheck5((u32)addr_start, len); - } - - - if(memcmp(addr_start, nocopyflag1, sizeof(nocopyflag1))==0){ - copyflagcheck1((u32)addr_start, len); - } + // no copy flags + case 8: + // Remove the actual flag so can copy back + if(memcmp(addr_start, nocopyflag5, sizeof(nocopyflag5))==0){ + copyflagcheck5((u32)addr_start, len); + } - if(memcmp(addr_start, nocopyflag2, sizeof(nocopyflag2))==0){ - copyflagcheck2((u32)addr_start, len); - } - - // no VC and GH3 save - if(memcmp(addr_start, nocopyflag3, sizeof(nocopyflag2))==0){ - copyflagcheck3((u32)addr_start, len); - } - // no VC and GH3 save display remove - if(memcmp(addr_start, nocopyflag4, sizeof(nocopyflag4))==0){ - copyflagcheck4((u32)addr_start, len); - } - - break; - case 9: - if(memcmp(addr_start, movedvdpatch, sizeof(movedvdpatch))==0){ - movedvdhooks((u32)addr_start, len); - } - break; -*/ - // multidol - case 3: + if(memcmp(addr_start, nocopyflag1, sizeof(nocopyflag1))==0){ + copyflagcheck1((u32)addr_start, len); + } - if(memcmp(addr_start, multidolpatch1, sizeof(multidolpatch1))==0){ - multidolpatchone((u32)addr_start, len); - } - if(memcmp(addr_start, multidolpatch2, sizeof(multidolpatch2))==0){ - multidolpatchtwo((u32)addr_start, len); - } - break; - } - addr_start += 4; + if(memcmp(addr_start, nocopyflag2, sizeof(nocopyflag2))==0){ + copyflagcheck2((u32)addr_start, len); + } + + // no VC and GH3 save + if(memcmp(addr_start, nocopyflag3, sizeof(nocopyflag2))==0){ + copyflagcheck3((u32)addr_start, len); + } + // no VC and GH3 save display remove + if(memcmp(addr_start, nocopyflag4, sizeof(nocopyflag4))==0){ + copyflagcheck4((u32)addr_start, len); + } + + break; + + case 9: + if(memcmp(addr_start, movedvdpatch, sizeof(movedvdpatch))==0){ + movedvdhooks((u32)addr_start, len); + } + break; + */ + // multidol + case 3: + + if (memcmp(addr_start, multidolpatch1, sizeof(multidolpatch1))==0) { + multidolpatchone((u32)addr_start, len); + } + if (memcmp(addr_start, multidolpatch2, sizeof(multidolpatch2))==0) { + multidolpatchtwo((u32)addr_start, len); + } + break; } + addr_start += 4; + } } // Not used yet, for patching DOL once loaded into memory and befor execution -void patchdol(void *addr, u32 len) -{ - - void *addr_start = addr; - void *addr_end = addr+len; +void patchdol(void *addr, u32 len) { - 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); - // patchhookdol((u32)addr_start, len); - patched = 1; - break; - } - addr_start += 4; - } + void *addr_start = addr; + void *addr_end = addr+len; + + 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); + // patchhookdol((u32)addr_start, len); + patched = 1; + break; + } + addr_start += 4; + } } -void langpatcher(void *addr, u32 len) -{ - - void *addr_start = addr; - void *addr_end = addr+len; +void langpatcher(void *addr, u32 len) { - while(addr_start < addr_end) - { - - if(memcmp(addr_start, langpatch, sizeof(langpatch))==0) { - if(configbytes[0] != 0xCD){ - langvipatch((u32)addr_start, len, configbytes[0]); - } - } - addr_start += 4; - } + void *addr_start = addr; + void *addr_end = addr+len; + + while (addr_start < addr_end) { + + if (memcmp(addr_start, langpatch, sizeof(langpatch))==0) { + if (configbytes[0] != 0xCD) { + langvipatch((u32)addr_start, len, configbytes[0]); + } + } + addr_start += 4; + } } -void patchdebug(void *addr, u32 len) -{ - - void *addr_start = addr; - void *addr_end = addr+len; +void patchdebug(void *addr, u32 len) { - while(addr_start < addr_end) - { - - if(memcmp(addr_start, fwritepatch, sizeof(fwritepatch))==0) { + void *addr_start = addr; + void *addr_end = addr+len; - memcpy(addr_start,fwrite_patch_bin,fwrite_patch_bin_len); - // apply patch - } - addr_start += 4; - } + while (addr_start < addr_end) { + + if (memcmp(addr_start, fwritepatch, sizeof(fwritepatch))==0) { + + memcpy(addr_start,fwrite_patch_bin,fwrite_patch_bin_len); + // apply patch + } + addr_start += 4; + } } -void vidolpatcher(void *addr, u32 len) -{ - - void *addr_start = addr; - void *addr_end = addr+len; +void vidolpatcher(void *addr, u32 len) { - while(addr_start < addr_end) - { - if(memcmp(addr_start, vipatchcode, sizeof(vipatchcode))==0) { - vipatch((u32)addr_start, len); - } - addr_start += 4; - } + void *addr_start = addr; + void *addr_end = addr+len; + + while (addr_start < addr_end) { + if (memcmp(addr_start, vipatchcode, sizeof(vipatchcode))==0) { + vipatch((u32)addr_start, len); + } + addr_start += 4; + } } diff --git a/source/patches/patchcode.h b/source/patches/patchcode.h index 381fcaa9..688b6279 100644 --- a/source/patches/patchcode.h +++ b/source/patches/patchcode.h @@ -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); diff --git a/source/patches/patchhook.S b/source/patches/patchhook.S index bddd9b7c..231ad527 100644 --- a/source/patches/patchhook.S +++ b/source/patches/patchhook.S @@ -1,508 +1,508 @@ - # (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: - mtctr r4 - lis r6, 0x4E80 - ori r6, r6, 0x0020 # blr -findblr2: - lwz r5, 0(r3) - cmpw r6, r5 - beq writebranch2 - addi r3, r3, 4 # next word - bdnz findblr2 # loop length - b exit2 # stop unhooked game hanging + .globl patchhook2 # r3 address + patchhook2: + mtctr r4 + lis r6, 0x4E80 + ori r6, r6, 0x0020 # blr + findblr2: + lwz r5, 0(r3) + cmpw r6, r5 + beq writebranch2 + addi r3, r3, 4 # next word + bdnz findblr2 # loop length + b exit2 # stop unhooked game hanging -writebranch2: - lis r4, 0x8000 # 81700000 our temp patcher - 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 -exit2: - blr # return + writebranch2: + lis r4, 0x8000 # 81700000 our temp patcher + 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 + exit2: + blr # return -.globl patchhook3 # r3 address -patchhook3: - mtctr r4 - lis r6, 0x4BFF - ori r6, r6, 0xE955 # blr -findbne: - lwz r5, 0(r3) - cmpw r6, r5 - beq writebl - addi r3, r3, 4 # next word - bdnz findbne # loop length - b exit3 # stop unhooked game hanging + .globl patchhook3 # r3 address + patchhook3: + mtctr r4 + lis r6, 0x4BFF + ori r6, r6, 0xE955 # blr + findbne: + lwz r5, 0(r3) + cmpw r6, r5 + beq writebl + addi r3, r3, 4 # next word + bdnz findbne # loop length + b exit3 # stop unhooked game hanging -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: - blr # return + 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: + blr # return -.globl patchhook4 # r3 address -patchhook4: - mtctr r4 - lis r6, 0x4082 - ori r6, r6, 0x001C # blr -findregion: - lwz r5, 0(r3) - cmpw r6, r5 - beq writebr - addi r3, r3, 4 # next word - bdnz findregion # loop length - b exit4 # stop unhooked game hanging + .globl patchhook4 # r3 address + patchhook4: + mtctr r4 + lis r6, 0x4082 + ori r6, r6, 0x001C # blr + findregion: + lwz r5, 0(r3) + cmpw r6, r5 + beq writebr + addi r3, r3, 4 # next word + bdnz findregion # loop length + b exit4 # stop unhooked game hanging -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: - blr # return + 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: + blr # return -.globl multidolpatchone # r3 address -multidolpatchone: - mtctr r4 - lis r6, 0x3800 - ori r6, r6, 0x0001 # (li r0,1) -findmulti: - lwz r5, 0(r3) - cmpw r6, r5 - beq writemulti - subi r3, r3, 4 # go back - bdnz findmulti # loop length - b exit5 # stop unhooked game hanging + .globl multidolpatchone # r3 address + multidolpatchone: + mtctr r4 + lis r6, 0x3800 + ori r6, r6, 0x0001 # (li r0,1) + findmulti: + lwz r5, 0(r3) + cmpw r6, r5 + beq writemulti + subi r3, r3, 4 # go back + bdnz findmulti # loop length + b exit5 # stop unhooked game hanging -writemulti: - lis r4, 0x8170 # 81700000 - ori r4, r4, 0x0020 - subf r18, r3, r4 # subf r18,(source),(dest) - lis r6, 0x4800 - ori r6,r6,1 - rlwimi r6,r18,0,6,29 - stw r6,0(r3) - stw r6,0(r19) - stw r3,4(r19) - dcbf r0, r3 - sync - icbi r0, r3 - isync -exit5: - blr # return + writemulti: + lis r4, 0x8170 # 81700000 + ori r4, r4, 0x0020 + subf r18, r3, r4 # subf r18,(source),(dest) + lis r6, 0x4800 + ori r6,r6,1 + rlwimi r6,r18,0,6,29 + stw r6,0(r3) + stw r6,0(r19) + stw r3,4(r19) + dcbf r0, r3 + sync + icbi r0, r3 + isync + exit5: + blr # return -.globl multidolpatchtwo # r3 address -multidolpatchtwo: - mtctr r4 - lis r6, 0x3F60 - ori r6, r6, 0x8000 # (lis r27,-32768) -findmulti2: - lwz r5, 0(r3) - cmpw r6, r5 - beq writemulti2 - addi r3, r3, 4 # go forward - bdnz findmulti2 # loop length - b exit6 # stop unhooked game hanging + .globl multidolpatchtwo # r3 address + multidolpatchtwo: + mtctr r4 + lis r6, 0x3F60 + ori r6, r6, 0x8000 # (lis r27,-32768) + findmulti2: + lwz r5, 0(r3) + cmpw r6, r5 + beq writemulti2 + addi r3, r3, 4 # go forward + bdnz findmulti2 # loop length + b exit6 # stop unhooked game hanging -writemulti2: - lis r4, 0x8170 # 81700020 - ori r4, r4, 0x0000 - subf r18, r3, r4 # subf r18,(source),(dest) - lis r6, 0x4800 - ori r6,r6,1 - rlwimi r6,r18,0,6,29 - stw r6,0(r3) - stw r6,0(r19) - stw r3,4(r19) - dcbf r0, r3 - sync - icbi r0, r3 - isync -exit6: - blr # return + writemulti2: + lis r4, 0x8170 # 81700020 + ori r4, r4, 0x0000 + subf r18, r3, r4 # subf r18,(source),(dest) + lis r6, 0x4800 + ori r6,r6,1 + rlwimi r6,r18,0,6,29 + stw r6,0(r3) + stw r6,0(r19) + stw r3,4(r19) + dcbf r0, r3 + sync + icbi r0, r3 + isync + exit6: + blr # return -.globl langvipatch # r3 address, r4 len, r5 lang byte -langvipatch: - mtctr r4 - lis r6, 0x8861 - ori r6, r6, 0x0008 # lbz r3, 8(sp) -findlang: - lwz r7, 0(r3) - cmpw r6, r7 - beq patchlang - addi r3, r3, 4 # next word - bdnz findlang # loop length - b exitlang # stop unhooked game hanging + .globl langvipatch # r3 address, r4 len, r5 lang byte + langvipatch: + mtctr r4 + lis r6, 0x8861 + ori r6, r6, 0x0008 # lbz r3, 8(sp) + findlang: + lwz r7, 0(r3) + cmpw r6, r7 + beq patchlang + addi r3, r3, 4 # next word + bdnz findlang # loop length + b exitlang # stop unhooked game hanging -patchlang: - - lis r4, 0x3860 # 0x38600001 li %r3, 1 # eng - add r4, r4, r5 -gofinal: - stw r4, 0(r3) # result in r3 - dcbf r0, r3 # data cache block flush - icbi r0, r3 -exitlang: - blr # return + patchlang: -.globl vipatch # r3 address -vipatch: - mtctr r4 - lis r6, 0x5400 - ori r6, r6, 0xFFFE -findvi: - lwz r5, 0(r3) - cmpw r6, r5 - beq patchvi - addi r3, r3, 4 # next word - bdnz findvi # loop length - b exitvi # stop unhooked game hanging + lis r4, 0x3860 # 0x38600001 li %r3, 1 # eng + add r4, r4, r5 + gofinal: + stw r4, 0(r3) # result in r3 + dcbf r0, r3 # data cache block flush + icbi r0, r3 + exitlang: + blr # return -patchvi: - lis r4, 0x8000 - ori r4, r4, 0x0003 - lbz r5, 0(r4) - cmpwi r5, 0x45 # USA - beq patchusa - cmpwi r5, 0x4A - beq patchjap2 # JAP - b exitvi -patchjap2: - lis r4, 0x3800 - ori r4, r4, 0x0001 - b gofinal2 -patchusa: - lis r4, 0x3800 - ori r4, r4, 0x0000 -gofinal2: - stw r4, 0(r3) # result in r3 - dcbf r0, r3 # data cache block flush - icbi r0, r3 -exitvi: - blr # return + .globl vipatch # r3 address + vipatch: + mtctr r4 + lis r6, 0x5400 + ori r6, r6, 0xFFFE + findvi: + lwz r5, 0(r3) + cmpw r6, r5 + beq patchvi + addi r3, r3, 4 # next word + bdnz findvi # loop length + b exitvi # stop unhooked game hanging -.globl regionfreejap # r3 address -regionfreejap: - mtctr r4 - lis r6, 0x2C1B - ori r6, r6, 0x0000 # blr -findjap: - lwz r5, 0(r3) - cmpw r6, r5 - beq writenop - addi r3, r3, 4 # next word - bdnz findjap # loop length - b exitjap # stop unhooked game hanging + patchvi: + lis r4, 0x8000 + ori r4, r4, 0x0003 + lbz r5, 0(r4) + cmpwi r5, 0x45 # USA + beq patchusa + cmpwi r5, 0x4A + beq patchjap2 # JAP + b exitvi + patchjap2: + lis r4, 0x3800 + ori r4, r4, 0x0001 + b gofinal2 + patchusa: + lis r4, 0x3800 + ori r4, r4, 0x0000 + gofinal2: + stw r4, 0(r3) # result in r3 + dcbf r0, r3 # data cache block flush + icbi r0, r3 + exitvi: + blr # return -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: - blr # return + .globl regionfreejap # r3 address + regionfreejap: + mtctr r4 + lis r6, 0x2C1B + ori r6, r6, 0x0000 # blr + findjap: + lwz r5, 0(r3) + cmpw r6, r5 + beq writenop + addi r3, r3, 4 # next word + bdnz findjap # loop length + b exitjap # stop unhooked game hanging -.globl regionfreeusa # r3 address -regionfreeusa: - mtctr r4 - lis r6, 0x281B - ori r6, r6, 0x0001 # blr -findusa: - lwz r5, 0(r3) - cmpw r6, r5 - beq writenop1 - addi r3, r3, 4 # next word - bdnz findusa # loop length - b exitusa # stop unhooked game hanging + 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: + blr # return -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: - blr # return + .globl regionfreeusa # r3 address + regionfreeusa: + mtctr r4 + lis r6, 0x281B + ori r6, r6, 0x0001 # blr + findusa: + lwz r5, 0(r3) + cmpw r6, r5 + beq writenop1 + addi r3, r3, 4 # next word + bdnz findusa # loop length + b exitusa # stop unhooked game hanging -.globl regionfreepal # r3 address -regionfreepal: - mtctr r4 - lis r6, 0x281B - ori r6, r6, 0x0002 # blr -findpal: - lwz r5, 0(r3) - cmpw r6, r5 - beq writenop2 - addi r3, r3, 4 # next word - bdnz findpal # loop length - b exitpal # stop unhooked game hanging + 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: + blr # return -writenop2: - 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 + .globl regionfreepal # r3 address + regionfreepal: + mtctr r4 + lis r6, 0x281B + ori r6, r6, 0x0002 # blr + findpal: + lwz r5, 0(r3) + cmpw r6, r5 + beq writenop2 + addi r3, r3, 4 # next word + bdnz findpal # loop length + b exitpal # stop unhooked game hanging - lis r6, 0x4082 - ori r6, r6, 0x001C # bne loc_81377A2C -findextra: #this is just the bne to b patch - lwz r5, 0(r3) - cmpw r6, r5 - beq writeb - addi r3, r3, 4 # next word - bdnz findextra # loop length - b exitpal # stop unhooked game hanging + writenop2: + 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 -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: - blr # return + lis r6, 0x4082 + ori r6, r6, 0x001C # bne loc_81377A2C + findextra: #this is just the bne to b patch + lwz r5, 0(r3) + cmpw r6, r5 + beq writeb + addi r3, r3, 4 # next word + bdnz findextra # loop length + b exitpal # stop unhooked game hanging -.globl removehealthcheck # r3 address -removehealthcheck: - mtctr r4 - lis r6, 0x4182 - ori r6, r6, 0x004C # blr -findhe: - lwz r5, 0(r3) - cmpw r6, r5 - beq writebhe - addi r3, r3, 4 # next word - bdnz findhe # loop length - b exithe # stop unhooked game hanging + 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: + blr # return -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: - blr # return + .globl removehealthcheck # r3 address + removehealthcheck: + mtctr r4 + lis r6, 0x4182 + ori r6, r6, 0x004C # blr + findhe: + lwz r5, 0(r3) + cmpw r6, r5 + beq writebhe + addi r3, r3, 4 # next word + bdnz findhe # loop length + b exithe # stop unhooked game hanging - + 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: + blr # return -.globl patchupdatecheck # r3 address -patchupdatecheck: - mtctr r4 - lis r6, 0x4082 - ori r6, r6, 0x0020 # blr -finduc: - lwz r5, 0(r3) - cmpw r6, r5 - beq writenopuc - addi r3, r3, 4 # next word - bdnz finduc # loop length - b exituc # stop unhooked game hanging -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: - blr # return + + .globl patchupdatecheck # r3 address + patchupdatecheck: + mtctr r4 + lis r6, 0x4082 + ori r6, r6, 0x0020 # blr + finduc: + lwz r5, 0(r3) + cmpw r6, r5 + beq writenopuc + addi r3, r3, 4 # next word + bdnz finduc # loop length + b exituc # stop unhooked game hanging + + 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: + blr # return -.globl copyflagcheck1 # r3 address -copyflagcheck1: - mtctr r4 - lis r6, 0x5400 - ori r6, r6, 0x07FF -findncf1: - lwz r5, 0(r3) - cmpw r6, r5 - beq writencf1 - subi r3, r3, 4 # next word - bdnz findncf1 # loop length - b exitncf1 # stop unhooked game hanging + .globl copyflagcheck1 # r3 address + copyflagcheck1: + mtctr r4 + lis r6, 0x5400 + ori r6, r6, 0x07FF + findncf1: + lwz r5, 0(r3) + cmpw r6, r5 + beq writencf1 + subi r3, r3, 4 # next word + bdnz findncf1 # loop length + b exitncf1 # stop unhooked game hanging -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: - blr # return + 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: + blr # return -.globl copyflagcheck2 # r3 address -copyflagcheck2: - mtctr r4 - lis r6, 0x5400 - ori r6, r6, 0x07FF -findncf2: - lwz r5, 0(r3) - cmpw r6, r5 - beq writencf2 - subi r3, r3, 4 # next word - bdnz findncf2 # loop length - b exitncf2 # stop unhooked game hanging + .globl copyflagcheck2 # r3 address + copyflagcheck2: + mtctr r4 + lis r6, 0x5400 + ori r6, r6, 0x07FF + findncf2: + lwz r5, 0(r3) + cmpw r6, r5 + beq writencf2 + subi r3, r3, 4 # next word + bdnz findncf2 # loop length + b exitncf2 # stop unhooked game hanging -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: - blr # return + 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: + blr # return -.globl copyflagcheck3 # r3 address -copyflagcheck3: -findncf3: - addi r3, r3, 20 # go back one dword (4 bytes) - lwz r5, 0(r3) -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: - blr # return + .globl copyflagcheck3 # r3 address + copyflagcheck3: + findncf3: + addi r3, r3, 20 # go back one dword (4 bytes) + lwz r5, 0(r3) + 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: + blr # return -.globl copyflagcheck4 # r3 address -copyflagcheck4: - mtctr r4 - lis r6, 0x3BE0 - ori r6, r6, 0x0001 # li r31,1 -findncf4: - lwz r5, 0(r3) - cmpw r6, r5 - beq writencf4 - addi r3, r3, 4 # next word - bdnz findncf4 # loop length - b exitncf4 # stop unhooked game hanging + .globl copyflagcheck4 # r3 address + copyflagcheck4: + mtctr r4 + lis r6, 0x3BE0 + ori r6, r6, 0x0001 # li r31,1 + findncf4: + lwz r5, 0(r3) + cmpw r6, r5 + beq writencf4 + addi r3, r3, 4 # next word + bdnz findncf4 # loop length + b exitncf4 # stop unhooked game hanging -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: - blr # return + 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: + blr # return -.globl copyflagcheck5 # r3 address -copyflagcheck5: - mtctr r4 - lis r6, 0x4182 - ori r6, r6, 0x0024 # beq loc_8134AA60 -findncf5: - lwz r5, 0(r3) - cmpw r6, r5 - beq writencf5 - addi r3, r3, 4 # next word - bdnz findncf5 # loop length - b exitncf5 # stop unhooked game hanging + .globl copyflagcheck5 # r3 address + copyflagcheck5: + mtctr r4 + lis r6, 0x4182 + ori r6, r6, 0x0024 # beq loc_8134AA60 + findncf5: + lwz r5, 0(r3) + cmpw r6, r5 + beq writencf5 + addi r3, r3, 4 # next word + bdnz findncf5 # loop length + b exitncf5 # stop unhooked game hanging -writencf5: - #addi r3, r3, 8 # skip 2 - - lis r4, 0x801D - ori r4, r4, 0x0024 # change to 801D0024 (lwz r0,36(r29)) - stw r4, 0(r3) - dcbf r0, r3 - icbi r0, r3 - - addi r3, r3, 4 # next word + writencf5: +#addi r3, r3, 8 # skip 2 - lis r4, 0x5400 - ori r4, r4, 0x003C # change to 5400003C (rlwinm r0,r0,0,0,30) - stw r4, 0(r3) - dcbf r0, r3 - icbi r0, r3 + lis r4, 0x801D + ori r4, r4, 0x0024 # change to 801D0024 (lwz r0,36(r29)) + stw r4, 0(r3) + dcbf r0, r3 + icbi r0, r3 - addi r3, r3, 4 # next word + addi r3, r3, 4 # next word - lis r4, 0x901D - ori r4, r4, 0x0024 # change to 901D0024 (stw r0,36(r29)) - stw r4, 0(r3) - dcbf r0, r3 - icbi r0, r3 + lis r4, 0x5400 + ori r4, r4, 0x003C # change to 5400003C (rlwinm r0,r0,0,0,30) + stw r4, 0(r3) + dcbf r0, r3 + icbi r0, r3 - addi r3, r3, 4 # next word + addi r3, r3, 4 # next word - lis r4, 0x4800 - ori r4, r4, 0x0018 # change to 48000018 (b 0x8134aa60) - stw r4, 0(r3) - dcbf r0, r3 - icbi r0, r3 -exitncf5: - blr # return + lis r4, 0x901D + ori r4, r4, 0x0024 # change to 901D0024 (stw r0,36(r29)) + stw r4, 0(r3) + dcbf r0, r3 + icbi r0, r3 -.globl movedvdhooks # r3 address -movedvdhooks: - lis r6, 0x4182 - ori r6, r6, 0x0120 # beq loc_813A7938 -findmd1: - addi r3, r3, 4 # next word - lwz r5, 0(r3) -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: - blr # return + addi r3, r3, 4 # next word + + lis r4, 0x4800 + ori r4, r4, 0x0018 # change to 48000018 (b 0x8134aa60) + stw r4, 0(r3) + dcbf r0, r3 + icbi r0, r3 + exitncf5: + blr # return + + .globl movedvdhooks # r3 address + movedvdhooks: + lis r6, 0x4182 + ori r6, r6, 0x0120 # beq loc_813A7938 + findmd1: + addi r3, r3, 4 # next word + lwz r5, 0(r3) + 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: + blr # return diff --git a/source/prompts/DiscBrowser.cpp b/source/prompts/DiscBrowser.cpp index 2387ae81..afd33d87 100644 --- a/source/prompts/DiscBrowser.cpp +++ b/source/prompts/DiscBrowser.cpp @@ -29,302 +29,295 @@ extern u8 reset; /******************************************************************************** *Game specific settings *********************************************************************************/ -int DiscBrowse(struct discHdr * header) -{ - bool exit = false; - int ret, choice; - u64 offset; +int DiscBrowse(struct discHdr * header) { + bool exit = false; + int ret, choice; + u64 offset; - - ret = Disc_SetUSB(header->id); - if(ret < 0) { - WindowPrompt(tr("ERROR:"), tr("Could not set USB."), tr("OK")); - return ret; - } - - ret = Disc_Open(); - if(ret < 0) { - WindowPrompt(tr("ERROR:"), tr("Could not open disc."), tr("OK")); - return ret; - } - - - - ret = __Disc_FindPartition(&offset); - if (ret < 0) { - WindowPrompt(tr("ERROR:"), tr("Could not find a WBFS partition."), tr("OK")); - return ret; - } - - ret = WDVD_OpenPartition(offset); + ret = Disc_SetUSB(header->id); if (ret < 0) { - WindowPrompt(tr("ERROR:"), tr("Could not open WBFS partition"), tr("OK")); - return ret; + WindowPrompt(tr("ERROR:"), tr("Could not set USB."), tr("OK")); + return ret; } - + + + ret = Disc_Open(); + if (ret < 0) { + WindowPrompt(tr("ERROR:"), tr("Could not open disc."), tr("OK")); + return ret; + } + + + + ret = __Disc_FindPartition(&offset); + if (ret < 0) { + WindowPrompt(tr("ERROR:"), tr("Could not find a WBFS partition."), tr("OK")); + return ret; + } + + ret = WDVD_OpenPartition(offset); + if (ret < 0) { + WindowPrompt(tr("ERROR:"), tr("Could not open WBFS partition"), tr("OK")); + return ret; + } + int *buffer = (int*)memalign(32, 0x20); - - if (buffer == NULL) - { - WindowPrompt(tr("ERROR:"), tr("Not enough free memory."), tr("OK")); - return -1; - } - - ret = WDVD_Read(buffer, 0x20, 0x420); - if (ret < 0) { - WindowPrompt(tr("ERROR:"), tr("Could not read the disc."), tr("OK")); - return ret; - } - - void *fstbuffer = memalign(32, buffer[2]*4); - FST_ENTRY *fst = (FST_ENTRY *)fstbuffer; - if (fst == NULL) - { - WindowPrompt(tr("ERROR:"), tr("Not enough free memory."), tr("OK")); - free(buffer); - return -1; - } - - ret = WDVD_Read(fstbuffer, buffer[2]*4, buffer[1]*4); + if (buffer == NULL) { + WindowPrompt(tr("ERROR:"), tr("Not enough free memory."), tr("OK")); + return -1; + } - if (ret < 0) { - WindowPrompt(tr("ERROR:"), tr("Could not read the disc."), tr("OK")); - free(buffer); - free(fstbuffer); - return ret; - } - - free(buffer); - - WDVD_Reset(); - //Disc_SetUSB(NULL); - WDVD_ClosePartition(); - - u32 discfilecount = fst[0].filelen; - u32 dolfilecount = 0; - //int offsetselect[20]; - - customOptionList options3(discfilecount); - - for (u32 i = 0; i < discfilecount; i++) { - - //don't add files that aren't .dol to the list - int len = (strlen(fstfiles(fst, i))); - if (fstfiles(fst, i)[len-4] =='.' && - fstfiles(fst, i)[len-3] =='d' && - fstfiles(fst, i)[len-2] =='o' && - fstfiles(fst, i)[len-1] =='l') - { - options3.SetName(i, "%i", i); - options3.SetValue(i, fstfiles(fst, i)); - //options3.SetName(i, fstfiles(fst, i)); - - dolfilecount++; - } - } - - if(dolfilecount <= 0) { + ret = WDVD_Read(buffer, 0x20, 0x420); + if (ret < 0) { + WindowPrompt(tr("ERROR:"), tr("Could not read the disc."), tr("OK")); + return ret; + } + + void *fstbuffer = memalign(32, buffer[2]*4); + FST_ENTRY *fst = (FST_ENTRY *)fstbuffer; + + if (fst == NULL) { + WindowPrompt(tr("ERROR:"), tr("Not enough free memory."), tr("OK")); + free(buffer); + return -1; + } + + ret = WDVD_Read(fstbuffer, buffer[2]*4, buffer[1]*4); + + if (ret < 0) { + WindowPrompt(tr("ERROR:"), tr("Could not read the disc."), tr("OK")); + free(buffer); + free(fstbuffer); + return ret; + } + + free(buffer); + + WDVD_Reset(); + //Disc_SetUSB(NULL); + WDVD_ClosePartition(); + + u32 discfilecount = fst[0].filelen; + u32 dolfilecount = 0; + //int offsetselect[20]; + + customOptionList options3(discfilecount); + + for (u32 i = 0; i < discfilecount; i++) { + + //don't add files that aren't .dol to the list + int len = (strlen(fstfiles(fst, i))); + if (fstfiles(fst, i)[len-4] =='.' && + fstfiles(fst, i)[len-3] =='d' && + fstfiles(fst, i)[len-2] =='o' && + fstfiles(fst, i)[len-1] =='l') { + options3.SetName(i, "%i", i); + options3.SetValue(i, fstfiles(fst, i)); + //options3.SetName(i, fstfiles(fst, i)); + + dolfilecount++; + } + } + + if (dolfilecount <= 0) { WindowPrompt(tr("ERROR"), tr("No dol file found on disc."), tr("OK")); free(fstbuffer); return -1; } - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[100]; + char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sgamesettings_background.png", CFG.theme_path); - GuiImageData settingsbg(imgPath, settings_background_png); + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sgamesettings_background.png", CFG.theme_path); + GuiImageData settingsbg(imgPath, settings_background_png); GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); - GuiTrigger trigB; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); + 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}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - titleTxt.SetPosition(12,40); - titleTxt.SetMaxWidth(356, GuiText::SCROLL); + 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); GuiImage settingsbackground(&settingsbg); - GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight()); - settingsbackgroundbtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - settingsbackgroundbtn.SetPosition(0, 0); - settingsbackgroundbtn.SetImage(&settingsbackground); + GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight()); + settingsbackgroundbtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + settingsbackgroundbtn.SetPosition(0, 0); + settingsbackgroundbtn.SetImage(&settingsbackground); - 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){ + 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) { cancelBtnTxt.SetWidescreen(CFG.widescreen); cancelBtnImg.SetWidescreen(CFG.widescreen); } - GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, &btnClick,1); - cancelBtn.SetScale(0.9); - cancelBtn.SetLabel(&cancelBtnTxt); - cancelBtn.SetTrigger(&trigB); + GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, &btnClick,1); + cancelBtn.SetScale(0.9); + cancelBtn.SetLabel(&cancelBtnTxt); + cancelBtn.SetTrigger(&trigB); - u8 scrollbaron = 0; - if(dolfilecount > 9) + u8 scrollbaron = 0; + 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); - optionBrowser3.SetPosition(0, 90); - optionBrowser3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - - HaltGui(); - GuiWindow w(screenwidth, screenheight); - w.Append(&settingsbackgroundbtn); + GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, CFG.theme_path, "bg_options_gamesettings.png", bg_options_settings_png, dolfilecount>9?1:0, 200); + optionBrowser3.SetPosition(0, 90); + optionBrowser3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + + HaltGui(); + GuiWindow w(screenwidth, screenheight); + w.Append(&settingsbackgroundbtn); w.Append(&titleTxt); - w.Append(&cancelBtn); + w.Append(&cancelBtn); w.Append(&optionBrowser3); - mainWindow->Append(&w); + mainWindow->Append(&w); - ResumeGui(); - - while(!exit) - { - VIDEO_WaitVSync(); + ResumeGui(); - if(shutdown == 1) - Sys_Shutdown(); - if(reset == 1) - Sys_Reboot(); + while (!exit) { + VIDEO_WaitVSync(); - ret = optionBrowser3.GetClickedOption(); + if (shutdown == 1) + Sys_Shutdown(); + if (reset == 1) + Sys_Reboot(); - if(ret > 0) { - char temp[100]; - strncpy(temp, fstfiles(fst, ret), sizeof(temp)); + ret = optionBrowser3.GetClickedOption(); + + 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; break; } - } + } - if (cancelBtn.GetState() == STATE_CLICKED) - { - exit = true; - ret = 696969; - //break; - } - } + if (cancelBtn.GetState() == STATE_CLICKED) { + exit = true; + ret = 696969; + //break; + } + } - HaltGui(); - mainWindow->Remove(&w); - ResumeGui(); + HaltGui(); + mainWindow->Remove(&w); + ResumeGui(); //free not needed list buffer anymore - free(fstbuffer); + free(fstbuffer); - return ret; + return ret; } -int autoSelectDol(const char *id) -{ - //still not done// - //////////ID6///////////////// - if (strcmp(id,"RF8E69") == 0) return 439;//from isostar - if (strcmp(id,"RF8P69") == 0) return 463;//from isostar - if (strcmp(id,"RF8X69") == 0) return 464;//from isostar - - if (strcmp(id,"RZTP01") == 0) return 952;//from isostar - if (strcmp(id,"RZTE01") == 0) return 674;//from starstremr - - if (strcmp(id,"RMZX69") == 0) return 492;//from isostar - if (strcmp(id,"RMZP69") == 0) return 492;//from isostar - if (strcmp(id,"RMZE69") == 0) return 492;//starstremr - - if (strcmp(id,"REDP41") == 0) return 1957;//from isostar - if (strcmp(id,"REDE41") == 0) return 1957;//starstremr - - if (strcmp(id,"RSXP69") == 0) return 337;//from isostar - if (strcmp(id,"RSXE69") == 0) return 337;//starstremr - - if (strcmp(id,"RNBX69") == 0) return 964;//from isostar - - if (strcmp(id,"RNFP69") == 0) return 1079;//from isostar - - if (strcmp(id,"RMLP7U") == 0) return 56;//from isostar - - if (strcmp(id,"RKMP5D") == 0) return 290;//from isostar - if (strcmp(id,"RKME5D") == 0) return 290;//starstremr - - if (strcmp(id,"R5TP69") == 0) return 1493;//from isostar - if (strcmp(id,"R5TE69") == 0) return 1493;//starstremr - - if (strcmp(id,"R9OP69") == 0) return 1991;//from isostar - if (strcmp(id,"R9OE69") == 0) return 1973;//starstremr - - if (strcmp(id,"RVUP8P") == 0) return 16426;//from isostar - if (strcmp(id,"RVUE8P") == 0) return 16405;//from isostar - - if (strcmp(id,"RJ8P64") == 0) return 8;//from isostar - - if (strcmp(id,"RHDP8P") == 0) return 149;//from isostar - if (strcmp(id,"RHDE8P") == 0) return 149;//starstremr - - if (strcmp(id,"RJ8P64") == 0) return 8;//from isostar - if (strcmp(id,"RJ8E64") == 0) return 8;//starstremr - - if (strcmp(id,"RHDP8P") == 0) return 149;//from isostar - - if (strcmp(id,"RMDP69") == 0) return 39;//from isostar +int autoSelectDol(const char *id) { + //still not done// + //////////ID6///////////////// + if (strcmp(id,"RF8E69") == 0) return 439;//from isostar + if (strcmp(id,"RF8P69") == 0) return 463;//from isostar + if (strcmp(id,"RF8X69") == 0) return 464;//from isostar - if (strcmp(id,"RBOP69") == 0) return 657;//from isostar - if (strcmp(id,"RBOE69") == 0) return 675;//starstremr + if (strcmp(id,"RZTP01") == 0) return 952;//from isostar + if (strcmp(id,"RZTE01") == 0) return 674;//from starstremr - if (strcmp(id,"RPYP9B") == 0) return 12490;//from isostar - - if (strcmp(id,"RM2X69") == 0)return 601;//dj_skual + if (strcmp(id,"RMZX69") == 0) return 492;//from isostar + if (strcmp(id,"RMZP69") == 0) return 492;//from isostar + if (strcmp(id,"RMZE69") == 0) return 492;//starstremr + + if (strcmp(id,"REDP41") == 0) return 1957;//from isostar + if (strcmp(id,"REDE41") == 0) return 1957;//starstremr + + if (strcmp(id,"RSXP69") == 0) return 337;//from isostar + if (strcmp(id,"RSXE69") == 0) return 337;//starstremr + + if (strcmp(id,"RNBX69") == 0) return 964;//from isostar + + if (strcmp(id,"RNFP69") == 0) return 1079;//from isostar + + if (strcmp(id,"RMLP7U") == 0) return 56;//from isostar + + if (strcmp(id,"RKMP5D") == 0) return 290;//from isostar + if (strcmp(id,"RKME5D") == 0) return 290;//starstremr + + if (strcmp(id,"R5TP69") == 0) return 1493;//from isostar + if (strcmp(id,"R5TE69") == 0) return 1493;//starstremr + + if (strcmp(id,"R9OP69") == 0) return 1991;//from isostar + if (strcmp(id,"R9OE69") == 0) return 1973;//starstremr + + if (strcmp(id,"RVUP8P") == 0) return 16426;//from isostar + if (strcmp(id,"RVUE8P") == 0) return 16405;//from isostar + + if (strcmp(id,"RJ8P64") == 0) return 8;//from isostar + + if (strcmp(id,"RHDP8P") == 0) return 149;//from isostar + if (strcmp(id,"RHDE8P") == 0) return 149;//starstremr + + if (strcmp(id,"RJ8P64") == 0) return 8;//from isostar + if (strcmp(id,"RJ8E64") == 0) return 8;//starstremr + + if (strcmp(id,"RHDP8P") == 0) return 149;//from isostar + + if (strcmp(id,"RMDP69") == 0) return 39;//from isostar + + if (strcmp(id,"RBOP69") == 0) return 657;//from isostar + if (strcmp(id,"RBOE69") == 0) return 675;//starstremr + + if (strcmp(id,"RPYP9B") == 0) return 12490;//from isostar + + if (strcmp(id,"RM2X69") == 0)return 601;//dj_skual - -/* - Tiger Woods10 R9OP69 1991 - Virtual Tennis 2009 RVUP8P 16426 - Fate of Atlantis"Indianer Jones" RJ8P64 8 - Madden NFL07 RMDP69 39 - Boogie RBOP69 657 - Pangya! Golf with Sryle RPYP9B 12490 -Grand Slam R5TP69 1493 - Madden NFL08 RNFP69 1079 + /* - rboe69 = boogie ntsc = (675) - - 601 rm2x69 - - RZTE01 = WSR = 674 + Tiger Woods10 R9OP69 1991 + Virtual Tennis 2009 RVUP8P 16426 + Fate of Atlantis"Indianer Jones" RJ8P64 8 + Madden NFL07 RMDP69 39 + Boogie RBOP69 657 + Pangya! Golf with Sryle RPYP9B 12490 + Grand Slam R5TP69 1493 + Madden NFL08 RNFP69 1079 - Fifa08 RF8P69 463 - Fifa08 RF8X69 464 - Wii Sports Resort RZTP01 952 - Medal of Honor Heroes RMZX69 492 - Medal of Honor Heroes RMZP69 492 - Redsteel REDP41 1957 - SSX RSXP69 337 - NBA08 RNBX69 964 - Metal Slug Anthology RMLP7U 56 - 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 -*/ + rboe69 = boogie ntsc = (675) - //if (strcmp(id,"") == 0) return ; //blank line for more dols - - return -1; + 601 rm2x69 + + RZTE01 = WSR = 674 + + Fifa08 RF8P69 463 + Fifa08 RF8X69 464 + Wii Sports Resort RZTP01 952 + Medal of Honor Heroes RMZX69 492 + Medal of Honor Heroes RMZP69 492 + Redsteel REDP41 1957 + SSX RSXP69 337 + NBA08 RNBX69 964 + Metal Slug Anthology RMLP7U 56 + 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 + + return -1; } diff --git a/source/prompts/ProgressWindow.cpp b/source/prompts/ProgressWindow.cpp index 2de25076..45821ddd 100644 --- a/source/prompts/ProgressWindow.cpp +++ b/source/prompts/ProgressWindow.cpp @@ -49,13 +49,13 @@ extern void HaltGui(); ***************************************************************************/ static void GameInstallProgress() { - if(gameinstalltotal <= 0) - return; + if (gameinstalltotal <= 0) + return; GetProgressValue(&gameinstalldone, &gameinstalltotal); - if(gameinstalldone > gameinstalltotal) - 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) { @@ -100,8 +100,8 @@ void SetupGameInstallProgress(char * title, char * game) { strncpy(progressMsg1, game, sizeof(progressMsg1)); gameinstalltotal = 1; showProgress = 1; - showSize = true; - showTime = true; + showSize = true; + showTime = true; LWP_ResumeThread(progressthread); start = time(0); } @@ -113,201 +113,197 @@ 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) -{ - GuiWindow promptWindow(472,320); - promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - promptWindow.SetPosition(0, -10); +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); - char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); - GuiImageData dialogBox(imgPath, dialogue_box_png); + char imgPath[100]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); + GuiImageData dialogBox(imgPath, dialogue_box_png); - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiImage dialogBoxImg(&dialogBox); - if (Settings.wsprompt == yes){ + GuiImage dialogBoxImg(&dialogBox); + if (Settings.wsprompt == yes) { dialogBoxImg.SetWidescreen(CFG.widescreen); } - snprintf(imgPath, sizeof(imgPath), "%sprogressbar_outline.png", CFG.theme_path); - GuiImageData progressbarOutline(imgPath, progressbar_outline_png); + snprintf(imgPath, sizeof(imgPath), "%sprogressbar_outline.png", CFG.theme_path); + GuiImageData progressbarOutline(imgPath, progressbar_outline_png); - GuiImage progressbarOutlineImg(&progressbarOutline); - if (Settings.wsprompt == yes){ - progressbarOutlineImg.SetWidescreen(CFG.widescreen);} - progressbarOutlineImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - progressbarOutlineImg.SetPosition(25, 40); + GuiImage progressbarOutlineImg(&progressbarOutline); + if (Settings.wsprompt == yes) { + progressbarOutlineImg.SetWidescreen(CFG.widescreen); + } + progressbarOutlineImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + progressbarOutlineImg.SetPosition(25, 40); - snprintf(imgPath, sizeof(imgPath), "%sprogressbar_empty.png", CFG.theme_path); - GuiImageData progressbarEmpty(imgPath, progressbar_empty_png); - GuiImage progressbarEmptyImg(&progressbarEmpty); - progressbarEmptyImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - progressbarEmptyImg.SetPosition(25, 40); - progressbarEmptyImg.SetTile(100); + snprintf(imgPath, sizeof(imgPath), "%sprogressbar_empty.png", CFG.theme_path); + GuiImageData progressbarEmpty(imgPath, progressbar_empty_png); + GuiImage progressbarEmptyImg(&progressbarEmpty); + progressbarEmptyImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + progressbarEmptyImg.SetPosition(25, 40); + progressbarEmptyImg.SetTile(100); - snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path); - GuiImageData progressbar(imgPath, progressbar_png); + snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path); + GuiImageData progressbar(imgPath, progressbar_png); GuiImage progressbarImg(&progressbar); - progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - progressbarImg.SetPosition(25, 40); + 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}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - titleTxt.SetPosition(0,60); + 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}); - msg1Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - if(msg2) + GuiText msg1Txt(msg1, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255} ); + msg1Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + if (msg2) msg1Txt.SetPosition(0,120); else msg1Txt.SetPosition(0,100); - msg1Txt.SetMaxWidth(430, GuiText::DOTTED); + msg1Txt.SetMaxWidth(430, GuiText::DOTTED); - 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 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}); - prsTxt.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); - prsTxt.SetPosition(-188,40); + 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); + 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); + 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); + speedTxt.SetPosition(50, -74); - 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); + 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 - progressbarOutlineImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - progressbarOutlineImg.SetPosition(0, 40); - progressbarEmptyImg.SetPosition(80,40); - progressbarEmptyImg.SetTile(78); - progressbarImg.SetPosition(80, 40); + if ((Settings.wsprompt == yes) && (CFG.widescreen)) {/////////////adjust for widescreen + progressbarOutlineImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + progressbarOutlineImg.SetPosition(0, 40); + progressbarEmptyImg.SetPosition(80,40); + progressbarEmptyImg.SetTile(78); + progressbarImg.SetPosition(80, 40); msg1Txt.SetMaxWidth(380, GuiText::DOTTED); msg2Txt.SetMaxWidth(380, GuiText::DOTTED); - timeTxt.SetPosition(250,-50); - timeTxt.SetFontSize(20); - speedTxt.SetPosition(90,-74); - speedTxt.SetFontSize(20); - sizeTxt.SetPosition(90, -50); - sizeTxt.SetFontSize(20); - } + timeTxt.SetPosition(250,-50); + timeTxt.SetFontSize(20); + speedTxt.SetPosition(90,-74); + speedTxt.SetFontSize(20); + sizeTxt.SetPosition(90, -50); + sizeTxt.SetFontSize(20); + } usleep(400000); // wait to see if progress flag changes soon - if(!showProgress) - return; + if (!showProgress) + return; - promptWindow.Append(&dialogBoxImg); + promptWindow.Append(&dialogBoxImg); promptWindow.Append(&progressbarEmptyImg); promptWindow.Append(&progressbarImg); promptWindow.Append(&progressbarOutlineImg); promptWindow.Append(&prTxt); - promptWindow.Append(&prsTxt); - if(title) - promptWindow.Append(&titleTxt); - if(msg1) - promptWindow.Append(&msg1Txt); - if(msg2) - promptWindow.Append(&msg2Txt); - if(showTime) + promptWindow.Append(&prsTxt); + if (title) + promptWindow.Append(&titleTxt); + if (msg1) + promptWindow.Append(&msg1Txt); + if (msg2) + promptWindow.Append(&msg2Txt); + if (showTime) promptWindow.Append(&timeTxt); - if(showSize){ + if (showSize) { promptWindow.Append(&sizeTxt); promptWindow.Append(&speedTxt); } - HaltGui(); - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&promptWindow); - mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); + HaltGui(); + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); - while(promptWindow.GetEffect() > 0) usleep(100); + while (promptWindow.GetEffect() > 0) usleep(100); - int tmp; - while(showProgress) - { + int tmp; + while (showProgress) { VIDEO_WaitVSync (); - usleep(20000); + usleep(20000); GameInstallProgress(); - tmp = static_cast(progressbarImg.GetWidth()*progressDone); + tmp = static_cast(progressbarImg.GetWidth()*progressDone); - if(CFG.widescreen && Settings.wsprompt == yes) + if (CFG.widescreen && Settings.wsprompt == yes) progressbarImg.SetSkew(0,0,static_cast(progressbarImg.GetWidth()*progressDone*0.8)-progressbarImg.GetWidth(),0,static_cast(progressbarImg.GetWidth()*progressDone*0.8)-progressbarImg.GetWidth(),0,0,0); else progressbarImg.SetSkew(0,0,static_cast(progressbarImg.GetWidth()*progressDone)-progressbarImg.GetWidth(),0,static_cast(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); + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + while (promptWindow.GetEffect() > 0) usleep(100); - HaltGui(); - mainWindow->Remove(&promptWindow); - mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); + HaltGui(); + mainWindow->Remove(&promptWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); } /**************************************************************************** * ProgressThread ***************************************************************************/ -static void * ProgressThread (void *arg) -{ - while(1) - { - if(!showProgress) - LWP_SuspendThread (progressthread); +static void * ProgressThread (void *arg) { + while (1) { + if (!showProgress) + LWP_SuspendThread (progressthread); - ProgressWindow(progressTitle, progressMsg1, progressMsg2); - usleep(100); - } - return NULL; + ProgressWindow(progressTitle, progressMsg1, progressMsg2); + usleep(100); + } + return NULL; } /**************************************************************************** * ProgressStop ***************************************************************************/ -void ProgressStop() -{ - showProgress = 0; - gameinstalltotal = -1; +void ProgressStop() { + showProgress = 0; + gameinstalltotal = -1; - // wait for thread to finish - while(!LWP_ThreadIsSuspended(progressthread)) - usleep(100); + // wait for thread to finish + 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) - return; +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) - 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,19 +363,19 @@ 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); } - showProgress = 1; - progressDone = 100.0*done/total; + showProgress = 1; + progressDone = 100.0*done/total; - LWP_ResumeThread(progressthread); + LWP_ResumeThread(progressthread); } /**************************************************************************** @@ -389,7 +384,7 @@ void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done, * Startup Progressthread in idle prio ***************************************************************************/ void InitProgressThread() { - LWP_CreateThread(&progressthread, ProgressThread, NULL, NULL, 0, 0); + LWP_CreateThread(&progressthread, ProgressThread, NULL, NULL, 0, 0); } /**************************************************************************** @@ -398,6 +393,6 @@ void InitProgressThread() { * Shutdown Progressthread ***************************************************************************/ void ExitProgressThread() { - LWP_JoinThread(progressthread, NULL); - progressthread = LWP_THREAD_NULL; + LWP_JoinThread(progressthread, NULL); + progressthread = LWP_THREAD_NULL; } diff --git a/source/prompts/ProgressWindow.h b/source/prompts/ProgressWindow.h index e345615c..f4484af9 100644 --- a/source/prompts/ProgressWindow.h +++ b/source/prompts/ProgressWindow.h @@ -16,7 +16,7 @@ void InitProgressThread(); void ExitProgressThread(); void SetupGameInstallProgress(char * titl, char * game); void ShowProgress (const char *title, const char *msg1, char *dynmsg2, - f32 done, f32 total, bool swSize = false, bool swTime = false); + f32 done, f32 total, bool swSize = false, bool swTime = false); void ProgressStop(); #endif diff --git a/source/prompts/PromptWindows.cpp b/source/prompts/PromptWindows.cpp index b3bfdd40..d1afa895 100644 --- a/source/prompts/PromptWindows.cpp +++ b/source/prompts/PromptWindows.cpp @@ -61,279 +61,302 @@ extern void HaltGui(); * Opens an on-screen keyboard window, with the data entered being stored * into the specified variable. ***************************************************************************/ -int OnScreenKeyboard(char * var, u32 maxlen, int min) -{ - int save = -1; - int keyset = 0; - if (Settings.keyset == us) keyset = 0; - else if (Settings.keyset == dvorak) keyset = 1; - else if (Settings.keyset == euro) keyset = 2; - else if (Settings.keyset == azerty) keyset = 3; - else if (Settings.keyset == qwerty) keyset = 4; +int OnScreenKeyboard(char * var, u32 maxlen, int min) { + int save = -1; + int keyset = 0; + if (Settings.keyset == us) keyset = 0; + else if (Settings.keyset == dvorak) keyset = 1; + else if (Settings.keyset == euro) keyset = 2; + else if (Settings.keyset == azerty) keyset = 3; + else if (Settings.keyset == qwerty) keyset = 4; - GuiKeyboard keyboard(var, maxlen, min, keyset); + GuiKeyboard keyboard(var, maxlen, min, keyset); - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[50]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); + char imgPath[50]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiTrigger trigB; - trigB.SetSimpleTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigB; + trigB.SetSimpleTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); - GuiText okBtnTxt(tr("OK"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage okBtnImg(&btnOutline); - if (Settings.wsprompt == yes){ - okBtnTxt.SetWidescreen(CFG.widescreen); - okBtnImg.SetWidescreen(CFG.widescreen); - } - GuiButton okBtn(&okBtnImg,&okBtnImg, 0, 4, 5, 15, &trigA, &btnSoundOver, &btnClick,1); - okBtn.SetLabel(&okBtnTxt); - GuiText cancelBtnTxt(tr("Cancel"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage cancelBtnImg(&btnOutline); - if (Settings.wsprompt == yes){ - cancelBtnTxt.SetWidescreen(CFG.widescreen); - cancelBtnImg.SetWidescreen(CFG.widescreen); - } - GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 1, 4, -5, 15, &trigA, &btnSoundOver, &btnClick,1); - cancelBtn.SetLabel(&cancelBtnTxt); - cancelBtn.SetTrigger(&trigB); + GuiText okBtnTxt(tr("OK"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage okBtnImg(&btnOutline); + if (Settings.wsprompt == yes) { + okBtnTxt.SetWidescreen(CFG.widescreen); + okBtnImg.SetWidescreen(CFG.widescreen); + } + GuiButton okBtn(&okBtnImg,&okBtnImg, 0, 4, 5, 15, &trigA, &btnSoundOver, &btnClick,1); + okBtn.SetLabel(&okBtnTxt); + GuiText cancelBtnTxt(tr("Cancel"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage cancelBtnImg(&btnOutline); + if (Settings.wsprompt == yes) { + cancelBtnTxt.SetWidescreen(CFG.widescreen); + cancelBtnImg.SetWidescreen(CFG.widescreen); + } + GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 1, 4, -5, 15, &trigA, &btnSoundOver, &btnClick,1); + cancelBtn.SetLabel(&cancelBtnTxt); + cancelBtn.SetTrigger(&trigB); - keyboard.Append(&okBtn); - keyboard.Append(&cancelBtn); + keyboard.Append(&okBtn); + keyboard.Append(&cancelBtn); - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&keyboard); - mainWindow->ChangeFocus(&keyboard); - ResumeGui(); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&keyboard); + mainWindow->ChangeFocus(&keyboard); + ResumeGui(); - while(save == -1) - { - VIDEO_WaitVSync(); + while (save == -1) { + VIDEO_WaitVSync(); - if(okBtn.GetState() == STATE_CLICKED) - save = 1; - else if(cancelBtn.GetState() == STATE_CLICKED) - save = 0; - } + if (okBtn.GetState() == STATE_CLICKED) + save = 1; + else if (cancelBtn.GetState() == STATE_CLICKED) + save = 0; + } - if(save) - { - snprintf(var, maxlen, "%s", keyboard.kbtextstr); - } + if (save) { + snprintf(var, maxlen, "%s", keyboard.kbtextstr); + } - HaltGui(); - mainWindow->Remove(&keyboard); - mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); - return save; + HaltGui(); + mainWindow->Remove(&keyboard); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); + return save; } /**************************************************************************** * WindowCredits * Display credits ***************************************************************************/ -void WindowCredits() -{ - int angle = 0; - GuiSound * creditsMusic = NULL; +void WindowCredits() { + int angle = 0; + GuiSound * creditsMusic = NULL; s32 thetimeofbg = bgMusic->GetPlayTime(); - StopOgg(); + StopOgg(); - creditsMusic = new GuiSound(credits_music_ogg, credits_music_ogg_size, SOUND_OGG, 55); - creditsMusic->SetVolume(60); - creditsMusic->SetLoop(1); - creditsMusic->Play(); + creditsMusic = new GuiSound(credits_music_ogg, credits_music_ogg_size, SOUND_OGG, 55); + creditsMusic->SetVolume(60); + creditsMusic->SetLoop(1); + creditsMusic->Play(); - bool exit = false; - int i = 0; - int y = 20; + bool exit = false; + int i = 0; + int y = 20; - GuiWindow creditsWindow(screenwidth,screenheight); - GuiWindow creditsWindowBox(580,448); - creditsWindowBox.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + GuiWindow creditsWindow(screenwidth,screenheight); + GuiWindow creditsWindowBox(580,448); + creditsWindowBox.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - GuiImageData creditsBox(credits_bg_png); - GuiImage creditsBoxImg(&creditsBox); - creditsBoxImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - creditsWindowBox.Append(&creditsBoxImg); + GuiImageData creditsBox(credits_bg_png); + GuiImage creditsBoxImg(&creditsBox); + creditsBoxImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + creditsWindowBox.Append(&creditsBoxImg); - GuiImageData star(little_star_png); - GuiImage starImg(&star); - starImg.SetWidescreen(CFG.widescreen); //added - starImg.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - starImg.SetPosition(505,350); + GuiImageData star(little_star_png); + GuiImage starImg(&star); + starImg.SetWidescreen(CFG.widescreen); //added + starImg.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + starImg.SetPosition(505,350); - int numEntries = 19; - GuiText * txt[numEntries]; + int numEntries = 19; + GuiText * txt[numEntries]; - txt[i] = new GuiText(tr("Credits"), 26, (GXColor){255, 255, 255, 255}); - txt[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); txt[i]->SetPosition(0,12); i++; + txt[i] = new GuiText(tr("Credits"), 26, (GXColor) {255, 255, 255, 255}); + txt[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + txt[i]->SetPosition(0,12); + i++; - #ifdef NOTFULLCHANNEL - char SvnRev[30]; - snprintf(SvnRev,sizeof(SvnRev), "Rev%s IOS%u (Rev %u)", GetRev(), IOS_GetVersion(), IOS_GetRevision()); - #else - char svnTmp[4];//did this to hide the M after the rev# that is made by altering it - //to be ready to be in a full channel - snprintf(svnTmp,sizeof(svnTmp), "%s", GetRev()); - char SvnRev[30]; - snprintf(SvnRev,sizeof(SvnRev), "Rev%sc IOS%u (Rev %u)", svnTmp, IOS_GetVersion(), IOS_GetRevision()); - #endif +#ifdef NOTFULLCHANNEL + char SvnRev[30]; + snprintf(SvnRev,sizeof(SvnRev), "Rev%s IOS%u (Rev %u)", GetRev(), IOS_GetVersion(), IOS_GetRevision()); +#else + char svnTmp[4];//did this to hide the M after the rev# that is made by altering it + //to be ready to be in a full channel + snprintf(svnTmp,sizeof(svnTmp), "%s", GetRev()); + char SvnRev[30]; + snprintf(SvnRev,sizeof(SvnRev), "Rev%sc IOS%u (Rev %u)", svnTmp, IOS_GetVersion(), IOS_GetRevision()); +#endif - txt[i] = new GuiText(SvnRev, 16, (GXColor){255, 255, 255, 255}); - txt[i]->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); txt[i]->SetPosition(0,y); i++; y+=34; + txt[i] = new GuiText(SvnRev, 16, (GXColor) { 255, 255, 255, 255}); + txt[i]->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); + txt[i]->SetPosition(0,y); + i++; + y+=34; - txt[i] = new GuiText("USB Loader GX", 24, (GXColor){255, 255, 255, 255}); - txt[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); txt[i]->SetPosition(0,y); i++; y+=26; + txt[i] = new GuiText("USB Loader GX", 24, (GXColor) {255, 255, 255, 255}); + txt[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + txt[i]->SetPosition(0,y); + i++; + y+=26; - txt[i] = new GuiText(": http://code.google.com/p/usbloader-gui/", 20, (GXColor){255, 255, 255, 255}); - txt[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); txt[i]->SetPosition(50,y); i++; //y+=28; + txt[i] = new GuiText(": http://code.google.com/p/usbloader-gui/", 20, (GXColor) {255, 255, 255, 255}); + txt[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + txt[i]->SetPosition(50,y); + i++; //y+=28; - txt[i] = new GuiText(tr("Official Site"), 20, (GXColor){255, 255, 255, 255}); - txt[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); txt[i]->SetPosition(-180,y); i++; y+=28; + txt[i] = new GuiText(tr("Official Site"), 20, (GXColor) {255, 255, 255, 255}); + txt[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + txt[i]->SetPosition(-180,y); + i++; + y+=28; - GuiText::SetPresets(22, (GXColor){255, 255, 255, 255}, 0, GuiText::WRAP, - FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP, ALIGN_LEFT, ALIGN_TOP); + GuiText::SetPresets(22, (GXColor) {255, 255, 255, 255}, 0, GuiText::WRAP,FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP, ALIGN_LEFT, ALIGN_TOP); - txt[i] = new GuiText(tr("Coding:")); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(70,y); - i++; + txt[i] = new GuiText(tr("Coding:")); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(70,y); + i++; - txt[i] = new GuiText("dimok / nIxx"); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(220,y); - i++; - y+=24; + txt[i] = new GuiText("dimok / nIxx"); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(220,y); + i++; + y+=24; - txt[i] = new GuiText("giantpune / ardi"); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(220,y); - i++; - y+=24; + txt[i] = new GuiText("giantpune / ardi"); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(220,y); + i++; + y+=24; char text[100]; sprintf(text, "hungyip84 / DrayX7 %s", tr("(both retired)")); - txt[i] = new GuiText(text); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(220,y); - i++; - y+=24; + txt[i] = new GuiText(text); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(220,y); + i++; + y+=24; - txt[i] = new GuiText("lustar"); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(220,y); - i++; - y+=34; + txt[i] = new GuiText("lustar"); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(220,y); + i++; + y+=34; - txt[i] = new GuiText(tr("Design:")); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(70,y); - i++; + txt[i] = new GuiText(tr("Design:")); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(70,y); + i++; - txt[i] = new GuiText("cyrex / NeoRame"); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(220,y); - i++; - y+=20; + txt[i] = new GuiText("cyrex / NeoRame"); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(220,y); + i++; + y+=20; - txt[i] = new GuiText(" "); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(220,y); - i++; - y+=22; + txt[i] = new GuiText(" "); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(220,y); + i++; + y+=22; - txt[i] = new GuiText(tr("Big thanks to:")); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(70,y); - i++; + txt[i] = new GuiText(tr("Big thanks to:")); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(70,y); + i++; - sprintf(text, "lustar %s", tr("for WiiTDB and hosting covers / disc images")); - txt[i] = new GuiText(text); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(220,y); - i++; - y+=24; + sprintf(text, "lustar %s", tr("for WiiTDB and hosting covers / disc images")); + txt[i] = new GuiText(text); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(220,y); + i++; + y+=24; sprintf(text, "CorneliousJD %s", tr("for hosting the update files")); - txt[i] = new GuiText(text); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(220,y); - i++; - y+=30; + txt[i] = new GuiText(text); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(220,y); + i++; + y+=30; - txt[i] = new GuiText(tr("Special thanks to:")); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(70,y); - i++; - y+=24; + txt[i] = new GuiText(tr("Special thanks to:")); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(70,y); + i++; + y+=24; sprintf(text, "Waninkoko, Kwiirk & Hermes %s", tr("for the USB Loader source")); - txt[i] = new GuiText(text); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(100,y); - i++; - y+=22; + txt[i] = new GuiText(text); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(100,y); + i++; + y+=22; sprintf(text, "Tantric %s LibWiiGui", tr("for his awesome tool")); - txt[i] = new GuiText(text); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(100,y); - i++; - y+=22; + txt[i] = new GuiText(text); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(100,y); + i++; + y+=22; sprintf(text, "Fishears/Nuke %s Ocarina", tr("for")); - txt[i] = new GuiText(text); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(100,y); - i++; - y+=22; + txt[i] = new GuiText(text); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(100,y); + i++; + y+=22; sprintf(text, "WiiPower %s", tr("for diverse patches")); - txt[i] = new GuiText(text); - txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(100,y); - i++; - y+=22; + txt[i] = new GuiText(text); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(100,y); + i++; + y+=22; - for(i=0; i < numEntries; i++) - creditsWindowBox.Append(txt[i]); + for (i=0; i < numEntries; i++) + creditsWindowBox.Append(txt[i]); - creditsWindow.Append(&creditsWindowBox); - creditsWindow.Append(&starImg); + creditsWindow.Append(&creditsWindowBox); + creditsWindow.Append(&starImg); creditsWindow.SetEffect(EFFECT_FADE, 30); - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&creditsWindow); - ResumeGui(); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&creditsWindow); + ResumeGui(); - while(!exit) - { - angle++; - if(angle > 360) - angle = 0; + while (!exit) { + angle++; + if (angle > 360) + angle = 0; usleep(12000); - starImg.SetAngle(angle); - if(ButtonsPressed() != 0) - exit = true; + starImg.SetAngle(angle); + if (ButtonsPressed() != 0) + exit = true; - } + } - creditsMusic->Stop(); + creditsMusic->Stop(); - delete creditsMusic; + delete creditsMusic; creditsWindow.SetEffect(EFFECT_FADE, -30); - while(creditsWindow.GetEffect() > 0) usleep(50); - HaltGui(); - mainWindow->Remove(&creditsWindow); - mainWindow->SetState(STATE_DEFAULT); - for(i=0; i < numEntries; i++) { - delete txt[i]; - txt[i] = NULL; - } - ResumeGui(); + while (creditsWindow.GetEffect() > 0) usleep(50); + HaltGui(); + mainWindow->Remove(&creditsWindow); + mainWindow->SetState(STATE_DEFAULT); + for (i=0; i < numEntries; i++) { + delete txt[i]; + txt[i] = NULL; + } + ResumeGui(); - 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); @@ -346,56 +369,52 @@ void WindowCredits() * WindowScreensaver * Display screensaver ***************************************************************************/ -int WindowScreensaver() -{ - int i = 0; - bool exit = false; - //char imgPath[100];//uncomment for themable screensaver +int WindowScreensaver() { + int i = 0; + bool exit = false; + //char imgPath[100];//uncomment for themable screensaver - /* initialize random seed: */ - srand ( time(NULL) ); + /* initialize random seed: */ + srand ( time(NULL) ); - //snprintf(imgPath, sizeof(imgPath), "%sscreensaver.png", CFG.theme_path);//uncomment for themable screensaver + //snprintf(imgPath, sizeof(imgPath), "%sscreensaver.png", CFG.theme_path);//uncomment for themable screensaver //GuiImageData GXlogo(imgPath, gxlogo_png);//uncomment for themable screensaver - GuiImageData GXlogo(gxlogo_png);//comment for themable screensaver - GuiImage GXlogoImg(&GXlogo); - GXlogoImg.SetPosition(172,152); - GXlogoImg.SetAlignment(ALIGN_LEFT,ALIGN_TOP); + GuiImageData GXlogo(gxlogo_png);//comment for themable screensaver + GuiImage GXlogoImg(&GXlogo); + GXlogoImg.SetPosition(172,152); + GXlogoImg.SetAlignment(ALIGN_LEFT,ALIGN_TOP); - GuiImage BackgroundImg(640,480,(GXColor){0, 0, 0, 255}); - BackgroundImg.SetPosition(0,0); - BackgroundImg.SetAlignment(ALIGN_LEFT,ALIGN_TOP); + GuiImage BackgroundImg(640,480,(GXColor) {0, 0, 0, 255}); + BackgroundImg.SetPosition(0,0); + BackgroundImg.SetAlignment(ALIGN_LEFT,ALIGN_TOP); - GuiWindow screensaverWindow(screenwidth,screenheight); - screensaverWindow.Append(&BackgroundImg); - screensaverWindow.Append(&GXlogoImg); + GuiWindow screensaverWindow(screenwidth,screenheight); + screensaverWindow.Append(&BackgroundImg); + screensaverWindow.Append(&GXlogoImg); - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&screensaverWindow); - ResumeGui(); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&screensaverWindow); + ResumeGui(); - while(!exit) - { - i++; - if(IsWpadConnected()) - { - exit = true; - } - /* Set position only every 400000th loop */ - if((i % 8000000) == 0) - { - /* Set random position */ - GXlogoImg.SetPosition((rand() % 345), (rand() % 305)); - } + while (!exit) { + i++; + if (IsWpadConnected()) { + exit = true; + } + /* Set position only every 400000th loop */ + if ((i % 8000000) == 0) { + /* Set random position */ + GXlogoImg.SetPosition((rand() % 345), (rand() % 305)); + } - } + } - HaltGui(); - mainWindow->Remove(&screensaverWindow); - mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); - return 1; + HaltGui(); + mainWindow->Remove(&screensaverWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); + return 1; } /**************************************************************************** @@ -410,92 +429,90 @@ int WindowScreensaver() ***************************************************************************/ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, - const char *btn2Label, const char *btn3Label, - const char *btn4Label, int wait) -{ - int choice = -1; - int count = wait; + const char *btn2Label, const char *btn3Label, + const char *btn4Label, int wait) { + int choice = -1; + int count = wait; - GuiWindow promptWindow(472,320); - promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - promptWindow.SetPosition(0, -10); + GuiWindow promptWindow(472,320); + promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + promptWindow.SetPosition(0, -10); - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[50]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); - GuiImageData dialogBox(imgPath, dialogue_box_png); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + char imgPath[50]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); + GuiImageData dialogBox(imgPath, dialogue_box_png); - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiTrigger trigB; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); - GuiImage dialogBoxImg(&dialogBox); - if (Settings.wsprompt == yes){ - dialogBoxImg.SetWidescreen(CFG.widescreen); - } + GuiImage dialogBoxImg(&dialogBox); + if (Settings.wsprompt == yes) { + dialogBoxImg.SetWidescreen(CFG.widescreen); + } - GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - titleTxt.SetPosition(0,55); - GuiText msgTxt(msg, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - msgTxt.SetPosition(0,-40); - msgTxt.SetMaxWidth(430); + GuiText titleTxt(title, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + titleTxt.SetPosition(0,55); + GuiText msgTxt(msg, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + msgTxt.SetPosition(0,-40); + msgTxt.SetMaxWidth(430); - GuiText btn1Txt(btn1Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn1Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn1Txt.SetWidescreen(CFG.widescreen); - btn1Img.SetWidescreen(CFG.widescreen); - } + GuiText btn1Txt(btn1Label, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn1Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn1Txt.SetWidescreen(CFG.widescreen); + btn1Img.SetWidescreen(CFG.widescreen); + } - GuiButton btn1(&btn1Img, &btn1Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1); - btn1.SetLabel(&btn1Txt); - btn1.SetState(STATE_SELECTED); + GuiButton btn1(&btn1Img, &btn1Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1); + btn1.SetLabel(&btn1Txt); + btn1.SetState(STATE_SELECTED); - GuiText btn2Txt(btn2Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn2Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn2Txt.SetWidescreen(CFG.widescreen); - btn2Img.SetWidescreen(CFG.widescreen); - } - GuiButton btn2(&btn2Img, &btn2Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1); - btn2.SetLabel(&btn2Txt); - if(!btn3Label && !btn4Label) - btn2.SetTrigger(&trigB); + GuiText btn2Txt(btn2Label, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn2Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn2Txt.SetWidescreen(CFG.widescreen); + btn2Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn2(&btn2Img, &btn2Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1); + btn2.SetLabel(&btn2Txt); + if (!btn3Label && !btn4Label) + btn2.SetTrigger(&trigB); - GuiText btn3Txt(btn3Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn3Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn3Txt.SetWidescreen(CFG.widescreen); - btn3Img.SetWidescreen(CFG.widescreen); - } - GuiButton btn3(&btn3Img, &btn3Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1); - btn3.SetLabel(&btn3Txt); - if(!btn4Label) - btn3.SetTrigger(&trigB); + GuiText btn3Txt(btn3Label, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn3Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn3Txt.SetWidescreen(CFG.widescreen); + btn3Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn3(&btn3Img, &btn3Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1); + btn3.SetLabel(&btn3Txt); + if (!btn4Label) + btn3.SetTrigger(&trigB); - GuiText btn4Txt(btn4Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn4Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn4Txt.SetWidescreen(CFG.widescreen); - btn4Img.SetWidescreen(CFG.widescreen); - } - GuiButton btn4(&btn4Img, &btn4Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1); - btn4.SetLabel(&btn4Txt); - if(btn4Label) - btn4.SetTrigger(&trigB); + GuiText btn4Txt(btn4Label, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn4Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn4Txt.SetWidescreen(CFG.widescreen); + btn4Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn4(&btn4Img, &btn4Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1); + btn4.SetLabel(&btn4Txt); + if (btn4Label) + btn4.SetTrigger(&trigB); - if ((Settings.wsprompt == yes) && (CFG.widescreen)){/////////////adjust buttons for widescreen - msgTxt.SetMaxWidth(330); + if ((Settings.wsprompt == yes) && (CFG.widescreen)) {/////////////adjust buttons for widescreen + msgTxt.SetMaxWidth(330); - if(btn2Label && !btn3Label && !btn4Label) - { + if (btn2Label && !btn3Label && !btn4Label) { btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); btn1.SetPosition(70, -80); btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); @@ -504,7 +521,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, btn3.SetPosition(-70, -55); btn4.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); btn4.SetPosition(70, -55); - } else if(btn2Label && btn3Label && !btn4Label) { + } else if (btn2Label && btn3Label && !btn4Label) { btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); btn1.SetPosition(70, -120); btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); @@ -513,7 +530,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, btn3.SetPosition(0, -55); btn4.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); btn4.SetPosition(70, -55); - } else if(btn2Label && btn3Label && btn4Label) { + } else if (btn2Label && btn3Label && btn4Label) { btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); btn1.SetPosition(70, -120); btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); @@ -522,7 +539,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, btn3.SetPosition(70, -55); btn4.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); btn4.SetPosition(-70, -55); - } else if(!btn2Label && btn3Label && btn4Label) { + } else if (!btn2Label && btn3Label && btn4Label) { btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); btn1.SetPosition(0, -120); btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); @@ -541,9 +558,9 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, btn4.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); btn4.SetPosition(70, -55); } - } else { + } else { - if(btn2Label && !btn3Label && !btn4Label) { + if (btn2Label && !btn3Label && !btn4Label) { btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); btn1.SetPosition(40, -45); btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); @@ -552,7 +569,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, btn3.SetPosition(50, -65); btn4.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); btn4.SetPosition(-50, -65); - } else if(btn2Label && btn3Label && !btn4Label) { + } else if (btn2Label && btn3Label && !btn4Label) { btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); btn1.SetPosition(50, -120); btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); @@ -561,8 +578,8 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, btn3.SetPosition(0, -65); btn4.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); btn4.SetPosition(-50, -65); - } else if(btn2Label && btn3Label && btn4Label) { - btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); + } else if (btn2Label && btn3Label && btn4Label) { + btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); btn1.SetPosition(50, -120); btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); btn2.SetPosition(-50, -120); @@ -570,8 +587,8 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, btn3.SetPosition(50, -65); btn4.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); btn4.SetPosition(-50, -65); - } else if(!btn2Label && btn3Label && btn4Label) { - btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); + } else if (!btn2Label && btn3Label && btn4Label) { + btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); btn1.SetPosition(0, -120); btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); btn2.SetPosition(-50, -120); @@ -579,8 +596,8 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, btn3.SetPosition(50, -65); btn4.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); btn4.SetPosition(-50, -65); - } else { - btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); + } else { + btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); btn1.SetPosition(0, -45); btn2.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); btn2.SetPosition(50, -120); @@ -588,69 +605,64 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, btn3.SetPosition(50, -65); btn4.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); btn4.SetPosition(-50, -65); - } + } - } + } - promptWindow.Append(&dialogBoxImg); - promptWindow.Append(&titleTxt); - promptWindow.Append(&msgTxt); + promptWindow.Append(&dialogBoxImg); + promptWindow.Append(&titleTxt); + promptWindow.Append(&msgTxt); - if(btn1Label) - promptWindow.Append(&btn1); - if(btn2Label) - promptWindow.Append(&btn2); - if(btn3Label) - promptWindow.Append(&btn3); - if(btn4Label) - promptWindow.Append(&btn4); + if (btn1Label) + promptWindow.Append(&btn1); + if (btn2Label) + promptWindow.Append(&btn2); + if (btn3Label) + promptWindow.Append(&btn3); + if (btn4Label) + promptWindow.Append(&btn4); - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&promptWindow); - mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); - while(choice == -1) - { - VIDEO_WaitVSync(); - if(shutdown == 1) - { - wiilight(0); - Sys_Shutdown(); - } - if(reset == 1) - Sys_Reboot(); - if(btn1.GetState() == STATE_CLICKED) { - choice = 1; - } - else if(btn2.GetState() == STATE_CLICKED) { - if(!btn3Label) - choice = 0; - else - choice = 2; - } - else if(btn3.GetState() == STATE_CLICKED) { - if(!btn4Label) - choice = 0; - else - choice = 3; - } - else if(btn4.GetState() == STATE_CLICKED) { - choice = 0; - } - if (count>0)count--; - if (count==0) choice = 1; - } + while (choice == -1) { + VIDEO_WaitVSync(); + if (shutdown == 1) { + wiilight(0); + Sys_Shutdown(); + } + if (reset == 1) + Sys_Reboot(); + if (btn1.GetState() == STATE_CLICKED) { + choice = 1; + } else if (btn2.GetState() == STATE_CLICKED) { + if (!btn3Label) + choice = 0; + else + choice = 2; + } else if (btn3.GetState() == STATE_CLICKED) { + if (!btn4Label) + choice = 0; + else + choice = 3; + } else if (btn4.GetState() == STATE_CLICKED) { + choice = 0; + } + if (count>0)count--; + if (count==0) choice = 1; + } - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - while(promptWindow.GetEffect() > 0) usleep(50); - HaltGui(); - mainWindow->Remove(&promptWindow); - mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); - return choice; + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + while (promptWindow.GetEffect() > 0) usleep(50); + HaltGui(); + mainWindow->Remove(&promptWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); + return choice; } /**************************************************************************** @@ -665,88 +677,86 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, ***************************************************************************/ int WindowExitPrompt(const char *title, const char *msg, const char *btn1Label, - const char *btn2Label, const char *btn3Label, - const char *btn4Label) -{ + const char *btn2Label, const char *btn3Label, + const char *btn4Label) { GuiSound * homein = NULL; homein = new GuiSound(menuin_ogg, menuin_ogg_size, SOUND_OGG, Settings.sfxvolume); homein->SetVolume(Settings.sfxvolume); - homein->SetLoop(0); - homein->Play(); + homein->SetLoop(0); + homein->Play(); - GuiSound * homeout = NULL; + GuiSound * homeout = NULL; homeout = new GuiSound(menuout_ogg, menuout_ogg_size, SOUND_OGG, Settings.sfxvolume); homeout->SetVolume(Settings.sfxvolume); - homeout->SetLoop(0); + homeout->SetLoop(0); int choice = -1; - char imgPath[100]; - u8 HBC=0; - GuiWindow promptWindow(640,480); - promptWindow.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - promptWindow.SetPosition(0, 0); - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + char imgPath[100]; + u8 HBC=0; + GuiWindow promptWindow(640,480); + promptWindow.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + promptWindow.SetPosition(0, 0); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiImageData top(exit_top_png); - GuiImageData topOver(exit_top_over_png); - GuiImageData bottom(exit_bottom_png); - GuiImageData bottomOver(exit_bottom_over_png); - GuiImageData button(exit_button_png); - GuiImageData wiimote(wiimote_png); - GuiImageData close(closebutton_png); + GuiImageData top(exit_top_png); + GuiImageData topOver(exit_top_over_png); + GuiImageData bottom(exit_bottom_png); + GuiImageData bottomOver(exit_bottom_over_png); + GuiImageData button(exit_button_png); + GuiImageData wiimote(wiimote_png); + GuiImageData close(closebutton_png); - snprintf(imgPath, sizeof(imgPath), "%sbattery_white.png", CFG.theme_path); - GuiImageData battery(imgPath, battery_white_png); - snprintf(imgPath, sizeof(imgPath), "%sbattery_red.png", CFG.theme_path); - GuiImageData batteryRed(imgPath, battery_red_png); - snprintf(imgPath, sizeof(imgPath), "%sbattery_bar_white.png", CFG.theme_path); - GuiImageData batteryBar(imgPath, battery_bar_white_png); + snprintf(imgPath, sizeof(imgPath), "%sbattery_white.png", CFG.theme_path); + GuiImageData battery(imgPath, battery_white_png); + snprintf(imgPath, sizeof(imgPath), "%sbattery_red.png", CFG.theme_path); + GuiImageData batteryRed(imgPath, battery_red_png); + snprintf(imgPath, sizeof(imgPath), "%sbattery_bar_white.png", CFG.theme_path); + GuiImageData batteryBar(imgPath, battery_bar_white_png); - #ifdef HW_RVL - int i = 0, ret = 0, level; - char txt[3]; - GuiText * batteryTxt[4]; - GuiImage * batteryImg[4]; - GuiImage * batteryBarImg[4]; - GuiButton * batteryBtn[4]; +#ifdef HW_RVL + int i = 0, ret = 0, level; + char txt[3]; + GuiText * batteryTxt[4]; + GuiImage * batteryImg[4]; + GuiImage * batteryBarImg[4]; + GuiButton * batteryBtn[4]; - for(i=0; i < 4; i++) - { + for (i=0; i < 4; i++) { - if(i == 0) - sprintf(txt, "P%d", i+1); - else - sprintf(txt, "P%d", i+1); + if (i == 0) + sprintf(txt, "P%d", i+1); + else + sprintf(txt, "P%d", i+1); - batteryTxt[i] = new GuiText(txt, 22, (GXColor){255,255,255, 255}); - batteryTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - batteryImg[i] = new GuiImage(&battery); - batteryImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - batteryImg[i]->SetPosition(36, 0); - batteryImg[i]->SetTile(0); - batteryBarImg[i] = new GuiImage(&batteryBar); - batteryBarImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - batteryBarImg[i]->SetPosition(33, 0); + batteryTxt[i] = new GuiText(txt, 22, (GXColor) {255,255,255, 255}); + batteryTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + batteryImg[i] = new GuiImage(&battery); + batteryImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + batteryImg[i]->SetPosition(36, 0); + batteryImg[i]->SetTile(0); + batteryBarImg[i] = new GuiImage(&batteryBar); + batteryBarImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + batteryBarImg[i]->SetPosition(33, 0); - batteryBtn[i] = new GuiButton(40, 20); - batteryBtn[i]->SetLabel(batteryTxt[i]); - batteryBtn[i]->SetImage(batteryBarImg[i]); - batteryBtn[i]->SetIcon(batteryImg[i]); - batteryBtn[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - batteryBtn[i]->SetRumble(false); - batteryBtn[i]->SetAlpha(70); - batteryBtn[i]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 50); - } + batteryBtn[i] = new GuiButton(40, 20); + batteryBtn[i]->SetLabel(batteryTxt[i]); + batteryBtn[i]->SetImage(batteryBarImg[i]); + batteryBtn[i]->SetIcon(batteryImg[i]); + batteryBtn[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + batteryBtn[i]->SetRumble(false); + batteryBtn[i]->SetAlpha(70); + batteryBtn[i]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 50); + } - batteryBtn[0]->SetPosition(180,150); - batteryBtn[1]->SetPosition(284, 150); - batteryBtn[2]->SetPosition(388, 150); - batteryBtn[3]->SetPosition(494, 150); + batteryBtn[0]->SetPosition(180,150); + batteryBtn[1]->SetPosition(284, 150); + batteryBtn[2]->SetPosition(388, 150); + batteryBtn[3]->SetPosition(494, 150); char * sig = (char *)0x80001804; - if( + if ( sig[0] == 'S' && sig[1] == 'T' && sig[2] == 'U' && @@ -756,218 +766,208 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label, sig[6] == 'X' && sig[7] == 'X') HBC=1; // Exit to HBC - #endif +#endif GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiTrigger trigB; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); - GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + GuiTrigger trigHome; + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); - GuiText titleTxt(tr("HOME Menu"), 36, (GXColor){255, 255, 255, 255}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - titleTxt.SetPosition(-180,40); - titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + GuiText titleTxt(tr("HOME Menu"), 36, (GXColor) {255, 255, 255, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + titleTxt.SetPosition(-180,40); + titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); - GuiText closeTxt(tr("Close"), 28, (GXColor){0, 0, 0, 255}); - closeTxt.SetPosition(10,3); - GuiImage closeImg(&close); - if (Settings.wsprompt == yes){ - closeTxt.SetWidescreen(CFG.widescreen); - closeImg.SetWidescreen(CFG.widescreen); - } - GuiButton closeBtn(close.GetWidth(), close.GetHeight()); - closeBtn.SetImage(&closeImg); - closeBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - closeBtn.SetPosition(190,30); - closeBtn.SetLabel(&closeTxt); - closeBtn.SetRumble(false); - closeBtn.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + GuiText closeTxt(tr("Close"), 28, (GXColor) {0, 0, 0, 255}); + closeTxt.SetPosition(10,3); + GuiImage closeImg(&close); + if (Settings.wsprompt == yes) { + closeTxt.SetWidescreen(CFG.widescreen); + closeImg.SetWidescreen(CFG.widescreen); + } + GuiButton closeBtn(close.GetWidth(), close.GetHeight()); + closeBtn.SetImage(&closeImg); + closeBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + closeBtn.SetPosition(190,30); + closeBtn.SetLabel(&closeTxt); + closeBtn.SetRumble(false); + closeBtn.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); - GuiImage btn1Img(&top); - GuiImage btn1OverImg(&topOver); - GuiButton btn1(&btn1Img,&btn1OverImg, 0, 3, 0, 0, &trigA, &btnSoundOver, &btnClick,0); - btn1.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + GuiImage btn1Img(&top); + GuiImage btn1OverImg(&topOver); + GuiButton btn1(&btn1Img,&btn1OverImg, 0, 3, 0, 0, &trigA, &btnSoundOver, &btnClick,0); + btn1.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); - GuiText btn2Txt((HBC!=1?"Homebrew Channel":btn1Label), 28, (GXColor){0, 0, 0, 255}); - GuiImage btn2Img(&button); - if (Settings.wsprompt == yes){ - btn2Txt.SetWidescreen(CFG.widescreen); - btn2Img.SetWidescreen(CFG.widescreen); - } - GuiButton btn2(&btn2Img,&btn2Img, 2, 5, -150, 0, &trigA, &btnSoundOver, &btnClick,1); - btn2.SetLabel(&btn2Txt); - btn2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 50); - btn2.SetRumble(false); - if (HBC==1){btn2.SetPosition(-150, 0);} + GuiText btn2Txt((HBC!=1?"Homebrew Channel":btn1Label), 28, (GXColor) {0, 0, 0, 255}); + GuiImage btn2Img(&button); + if (Settings.wsprompt == yes) { + btn2Txt.SetWidescreen(CFG.widescreen); + btn2Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn2(&btn2Img,&btn2Img, 2, 5, -150, 0, &trigA, &btnSoundOver, &btnClick,1); + btn2.SetLabel(&btn2Txt); + btn2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 50); + btn2.SetRumble(false); + if (HBC==1) { + btn2.SetPosition(-150, 0); + } - GuiText btn3Txt(btn2Label, 28, (GXColor){0, 0, 0, 255}); - GuiImage btn3Img(&button); - if (Settings.wsprompt == yes){ - btn3Txt.SetWidescreen(CFG.widescreen); - btn3Img.SetWidescreen(CFG.widescreen); - } - GuiButton btn3(&btn3Img,&btn3Img, 2, 5, 150, 0, &trigA, &btnSoundOver, &btnClick,1); - btn3.SetLabel(&btn3Txt); - btn3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 50); - btn3.SetRumble(false); - btn3.SetPosition(150, 0); + GuiText btn3Txt(btn2Label, 28, (GXColor) {0, 0, 0, 255}); + GuiImage btn3Img(&button); + if (Settings.wsprompt == yes) { + btn3Txt.SetWidescreen(CFG.widescreen); + btn3Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn3(&btn3Img,&btn3Img, 2, 5, 150, 0, &trigA, &btnSoundOver, &btnClick,1); + btn3.SetLabel(&btn3Txt); + btn3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 50); + btn3.SetRumble(false); + btn3.SetPosition(150, 0); - GuiImage btn4Img(&bottom); - GuiImage btn4OverImg(&bottomOver); - GuiButton btn4(&btn4Img,&btn4OverImg, 0, 4, 0, 0, &trigA, &btnSoundOver, &btnClick,0); - btn4.SetTrigger(&trigB); - btn4.SetTrigger(&trigHome); - btn4.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 50); + GuiImage btn4Img(&bottom); + GuiImage btn4OverImg(&bottomOver); + GuiButton btn4(&btn4Img,&btn4OverImg, 0, 4, 0, 0, &trigA, &btnSoundOver, &btnClick,0); + btn4.SetTrigger(&trigB); + btn4.SetTrigger(&trigHome); + btn4.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 50); - GuiImage wiimoteImg(&wiimote); - if (Settings.wsprompt == yes){wiimoteImg.SetWidescreen(CFG.widescreen);} - wiimoteImg.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); - wiimoteImg.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 50); - wiimoteImg.SetPosition(50,210); + GuiImage wiimoteImg(&wiimote); + if (Settings.wsprompt == yes) { + wiimoteImg.SetWidescreen(CFG.widescreen); + } + wiimoteImg.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); + wiimoteImg.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 50); + wiimoteImg.SetPosition(50,210); - promptWindow.Append(&btn2); + promptWindow.Append(&btn2); promptWindow.Append(&btn3); promptWindow.Append(&btn4); promptWindow.Append(&btn1); - promptWindow.Append(&closeBtn); - promptWindow.Append(&titleTxt); - promptWindow.Append(&wiimoteImg); + promptWindow.Append(&closeBtn); + promptWindow.Append(&titleTxt); + promptWindow.Append(&wiimoteImg); - #ifdef HW_RVL - promptWindow.Append(batteryBtn[0]); +#ifdef HW_RVL + promptWindow.Append(batteryBtn[0]); promptWindow.Append(batteryBtn[1]); promptWindow.Append(batteryBtn[2]); promptWindow.Append(batteryBtn[3]); - #endif +#endif - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&promptWindow); - mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); - while(choice == -1) - { - VIDEO_WaitVSync(); + while (choice == -1) { + VIDEO_WaitVSync(); - #ifdef HW_RVL - for(i=0; i < 4; i++) - { - if(WPAD_Probe(i, NULL) == WPAD_ERR_NONE) // controller connected - { - level = (userInput[i].wpad.battery_level / 100.0) * 4; - if(level > 4) level = 4; - batteryImg[i]->SetTile(level); +#ifdef HW_RVL + for (i=0; i < 4; i++) { + if (WPAD_Probe(i, NULL) == WPAD_ERR_NONE) { // controller connected + level = (userInput[i].wpad.battery_level / 100.0) * 4; + if (level > 4) level = 4; + batteryImg[i]->SetTile(level); - if(level == 0) - batteryBarImg[i]->SetImage(&batteryRed); - else - batteryBarImg[i]->SetImage(&batteryBar); + if (level == 0) + batteryBarImg[i]->SetImage(&batteryRed); + else + batteryBarImg[i]->SetImage(&batteryBar); - batteryBtn[i]->SetAlpha(255); - } - else // controller not connected - { - batteryImg[i]->SetTile(0); - batteryImg[i]->SetImage(&battery); - batteryBtn[i]->SetAlpha(70); - } - } - #endif + batteryBtn[i]->SetAlpha(255); + } else { // controller not connected + batteryImg[i]->SetTile(0); + batteryImg[i]->SetImage(&battery); + batteryBtn[i]->SetAlpha(70); + } + } +#endif - if(shutdown == 1) - { - wiilight(0); - Sys_Shutdown(); - } - if(reset == 1) - Sys_Reboot(); - if(btn1.GetState() == STATE_CLICKED) { - choice = 1; - btn1.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - closeBtn.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - btn4.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); + if (shutdown == 1) { + wiilight(0); + Sys_Shutdown(); + } + if (reset == 1) + Sys_Reboot(); + if (btn1.GetState() == STATE_CLICKED) { + choice = 1; + btn1.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + closeBtn.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + btn4.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); btn2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50); btn3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); - titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - wiimoteImg.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); - #ifdef HW_RVL - for (int i = 0; i < 4; i++) - batteryBtn[i]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); - #endif - } - else if(btn4.GetState() == STATE_SELECTED) - { - wiimoteImg.SetPosition(50,165); - } - else if(btn2.GetState() == STATE_CLICKED) { + titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + wiimoteImg.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); +#ifdef HW_RVL + for (int i = 0; i < 4; i++) + batteryBtn[i]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); +#endif + } else if (btn4.GetState() == STATE_SELECTED) { + wiimoteImg.SetPosition(50,165); + } else if (btn2.GetState() == STATE_CLICKED) { ret = WindowPrompt(tr("Are you sure?"), 0, tr("Yes"), tr("No")); - if (ret == 1) { - if (HBC!=1) - { - CloseXMLDatabase(); - ExitGUIThreads(); - ShutdownAudio(); - StopGX(); - WII_Initialize(); - WII_LaunchTitle(TITLE_ID(0x00010001,0x48415858)); - } - choice = 2; - } - HaltGui(); + if (ret == 1) { + if (HBC!=1) { + CloseXMLDatabase(); + ExitGUIThreads(); + ShutdownAudio(); + StopGX(); + WII_Initialize(); + WII_LaunchTitle(TITLE_ID(0x00010001,0x48415858)); + } + choice = 2; + } + HaltGui(); mainWindow->SetState(STATE_DISABLED); - promptWindow.SetState(STATE_DEFAULT); + promptWindow.SetState(STATE_DEFAULT); mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); - btn2.ResetState(); - } - else if(btn3.GetState() == STATE_CLICKED) { - ret = WindowPrompt(tr("Are you sure?"), 0, tr("Yes"), tr("No")); - if (ret == 1) { - choice = 3; - } - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - promptWindow.SetState(STATE_DEFAULT); - mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); - btn3.ResetState(); - } - else if(btn4.GetState() == STATE_CLICKED) { - btn1.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - closeBtn.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - btn4.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); - btn2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50); + ResumeGui(); + btn2.ResetState(); + } else if (btn3.GetState() == STATE_CLICKED) { + ret = WindowPrompt(tr("Are you sure?"), 0, tr("Yes"), tr("No")); + if (ret == 1) { + choice = 3; + } + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + promptWindow.SetState(STATE_DEFAULT); + mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); + btn3.ResetState(); + } else if (btn4.GetState() == STATE_CLICKED) { + btn1.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + closeBtn.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + btn4.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); + btn2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50); btn3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); - titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - wiimoteImg.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); - #ifdef HW_RVL - for (int i = 0; i < 4; i++) - batteryBtn[i]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); - #endif - choice = 0; - } - else if(btn4.GetState() != STATE_SELECTED) - { - wiimoteImg.SetPosition(50,210); - } - } + titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + wiimoteImg.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); +#ifdef HW_RVL + for (int i = 0; i < 4; i++) + batteryBtn[i]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); +#endif + choice = 0; + } else if (btn4.GetState() != STATE_SELECTED) { + wiimoteImg.SetPosition(50,210); + } + } homeout->Play(); - while(btn1.GetEffect() > 0) usleep(50); - while(promptWindow.GetEffect() > 0) usleep(50); - HaltGui(); - homein->Stop(); - delete homein; - mainWindow->Remove(&promptWindow); - mainWindow->SetState(STATE_DEFAULT); - while(homeout->IsPlaying() > 0) usleep(50); + while (btn1.GetEffect() > 0) usleep(50); + while (promptWindow.GetEffect() > 0) usleep(50); + HaltGui(); + homein->Stop(); + delete homein; + mainWindow->Remove(&promptWindow); + mainWindow->SetState(STATE_DEFAULT); + while (homeout->IsPlaying() > 0) usleep(50); homeout->Stop(); - delete homeout; - ResumeGui(); - return choice; + delete homeout; + ResumeGui(); + return choice; } /**************************************************************************** @@ -976,622 +976,595 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label, * Displays a prompt window to user, with information, an error message, or * presenting a user with a choice ***************************************************************************/ -int GameWindowPrompt() -{ - int choice = -1, angle = 0; - f32 size = 0.0; - char ID[5]; - char IDFull[7]; +int GameWindowPrompt() { + int choice = -1, angle = 0; + f32 size = 0.0; + char ID[5]; + char IDFull[7]; - GuiWindow promptWindow(472,320); - promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - promptWindow.SetPosition(0, -10); - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiWindow promptWindow(472,320); + promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + promptWindow.SetPosition(0, -10); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); + char imgPath[100]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sfavorite.png", CFG.theme_path); - GuiImageData imgFavorite(imgPath, favorite_png); - snprintf(imgPath, sizeof(imgPath), "%snot_favorite.png", CFG.theme_path); - GuiImageData imgNotFavorite(imgPath, not_favorite_png); + snprintf(imgPath, sizeof(imgPath), "%sfavorite.png", CFG.theme_path); + GuiImageData imgFavorite(imgPath, favorite_png); + snprintf(imgPath, sizeof(imgPath), "%snot_favorite.png", CFG.theme_path); + GuiImageData imgNotFavorite(imgPath, not_favorite_png); - snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path); - GuiImageData imgLeft(imgPath, startgame_arrow_left_png); - snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path); - GuiImageData imgRight(imgPath, startgame_arrow_right_png); + snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path); + GuiImageData imgLeft(imgPath, startgame_arrow_left_png); + snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path); + GuiImageData imgRight(imgPath, startgame_arrow_right_png); - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiTrigger trigB; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); - GuiTrigger trigL; - trigL.SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT); - GuiTrigger trigR; - trigR.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT); + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + GuiTrigger trigL; + trigL.SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT); + GuiTrigger trigR; + trigR.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT); GuiTrigger trigPlus; - trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0); - GuiTrigger trigMinus; - trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0); + trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0); + GuiTrigger trigMinus; + trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0); - if (CFG.widescreen) - snprintf(imgPath, sizeof(imgPath), "%swdialogue_box_startgame.png", CFG.theme_path); - else - snprintf(imgPath, sizeof(imgPath), "%sdialogue_box_startgame.png", CFG.theme_path); + if (CFG.widescreen) + snprintf(imgPath, sizeof(imgPath), "%swdialogue_box_startgame.png", CFG.theme_path); + else + snprintf(imgPath, sizeof(imgPath), "%sdialogue_box_startgame.png", CFG.theme_path); - GuiImageData dialogBox(imgPath, CFG.widescreen ? wdialogue_box_startgame_png : dialogue_box_startgame_png); - GuiImage dialogBoxImg(&dialogBox); + GuiImageData dialogBox(imgPath, CFG.widescreen ? wdialogue_box_startgame_png : dialogue_box_startgame_png); + GuiImage dialogBoxImg(&dialogBox); - GuiTooltip nameBtnTT(tr("Rename Game on WBFS")); - if (Settings.wsprompt == yes) - nameBtnTT.SetWidescreen(CFG.widescreen); - GuiText nameTxt("", 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - if (Settings.wsprompt == yes) - nameTxt.SetWidescreen(CFG.widescreen); - nameTxt.SetMaxWidth(350, GuiText::SCROLL); - GuiButton nameBtn(120,50); - nameBtn.SetLabel(&nameTxt); + GuiTooltip nameBtnTT(tr("Rename Game on WBFS")); + if (Settings.wsprompt == yes) + nameBtnTT.SetWidescreen(CFG.widescreen); + GuiText nameTxt("", 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + if (Settings.wsprompt == yes) + nameTxt.SetWidescreen(CFG.widescreen); + nameTxt.SetMaxWidth(350, GuiText::SCROLL); + GuiButton nameBtn(120,50); + nameBtn.SetLabel(&nameTxt); // nameBtn.SetLabelOver(&nameTxt); - nameBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - nameBtn.SetPosition(0,-122); - nameBtn.SetSoundOver(&btnSoundOver); - nameBtn.SetSoundClick(&btnClick); - nameBtn.SetToolTip(&nameBtnTT,24,-30, ALIGN_LEFT); + nameBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + nameBtn.SetPosition(0,-122); + nameBtn.SetSoundOver(&btnSoundOver); + nameBtn.SetSoundClick(&btnClick); + nameBtn.SetToolTip(&nameBtnTT,24,-30, ALIGN_LEFT); - if (Settings.godmode == 1){ - nameBtn.SetTrigger(&trigA); - nameBtn.SetEffectGrow(); - } + if (Settings.godmode == 1) { + nameBtn.SetTrigger(&trigA); + nameBtn.SetEffectGrow(); + } - GuiText sizeTxt(NULL, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //TODO: get the size here - sizeTxt.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); - sizeTxt.SetPosition(-60,70); + GuiText sizeTxt(NULL, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //TODO: get the size here + sizeTxt.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); + sizeTxt.SetPosition(-60,70); // GuiImage diskImg; - GuiDiskCover diskImg; - diskImg.SetWidescreen(CFG.widescreen); - diskImg.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - diskImg.SetAngle(angle); - GuiDiskCover diskImg2; - diskImg2.SetWidescreen(CFG.widescreen); - diskImg2.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - diskImg2.SetPosition(0, -20); - diskImg2.SetAngle(angle); - diskImg2.SetBeta(180); + GuiDiskCover diskImg; + diskImg.SetWidescreen(CFG.widescreen); + diskImg.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + diskImg.SetAngle(angle); + GuiDiskCover diskImg2; + diskImg2.SetWidescreen(CFG.widescreen); + diskImg2.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + diskImg2.SetPosition(0, -20); + diskImg2.SetAngle(angle); + diskImg2.SetBeta(180); - GuiText playcntTxt(NULL, 18, (GXColor){THEME.info_r, THEME.info_g, THEME.info_b, 255}); - playcntTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - playcntTxt.SetPosition(-115,45); + GuiText playcntTxt(NULL, 18, (GXColor) {THEME.info_r, THEME.info_g, THEME.info_b, 255}); + playcntTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + playcntTxt.SetPosition(-115,45); - GuiButton btn1(160, 160); - btn1.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - btn1.SetPosition(0, -20); - btn1.SetImage(&diskImg); + GuiButton btn1(160, 160); + btn1.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + btn1.SetPosition(0, -20); + btn1.SetImage(&diskImg); - btn1.SetSoundOver(&btnSoundOver); - btn1.SetSoundClick(&btnClick); - btn1.SetTrigger(&trigA); - btn1.SetState(STATE_SELECTED); + btn1.SetSoundOver(&btnSoundOver); + btn1.SetSoundClick(&btnClick); + btn1.SetTrigger(&trigA); + btn1.SetState(STATE_SELECTED); - GuiText btn2Txt(tr("Back"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn2Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn2Txt.SetWidescreen(CFG.widescreen); - btn2Img.SetWidescreen(CFG.widescreen); - } - GuiButton btn2(&btn2Img,&btn2Img, 1, 5, 0, 0, &trigA, &btnSoundOver, &btnClick,1); - if (Settings.godmode == 1) - { - btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); - btn2.SetPosition(-50, -40); - } - else - { - btn2.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); - btn2.SetPosition(0, -40); - } + GuiText btn2Txt(tr("Back"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn2Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn2Txt.SetWidescreen(CFG.widescreen); + btn2Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn2(&btn2Img,&btn2Img, 1, 5, 0, 0, &trigA, &btnSoundOver, &btnClick,1); + if (Settings.godmode == 1) { + btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); + btn2.SetPosition(-50, -40); + } else { + btn2.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); + btn2.SetPosition(0, -40); + } - btn2.SetLabel(&btn2Txt); - btn2.SetTrigger(&trigB); + btn2.SetLabel(&btn2Txt); + btn2.SetTrigger(&trigB); - GuiText btn3Txt(tr("Settings"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn3Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn3Txt.SetWidescreen(CFG.widescreen); - btn3Img.SetWidescreen(CFG.widescreen);} - GuiButton btn3(&btn3Img,&btn3Img, 0, 4, 50, -40, &trigA, &btnSoundOver, &btnClick,1); - btn3.SetLabel(&btn3Txt); + GuiText btn3Txt(tr("Settings"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn3Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn3Txt.SetWidescreen(CFG.widescreen); + btn3Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn3(&btn3Img,&btn3Img, 0, 4, 50, -40, &trigA, &btnSoundOver, &btnClick,1); + btn3.SetLabel(&btn3Txt); - GuiImage btnFavoriteImg; - btnFavoriteImg.SetWidescreen(CFG.widescreen); - //GuiButton btnFavorite(&btnFavoriteImg,&btnFavoriteImg, 2, 5, -125, -60, &trigA, &btnSoundOver, &btnClick,1); - GuiButton btnFavorite(imgFavorite.GetWidth(), imgFavorite.GetHeight()); - btnFavorite.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - btnFavorite.SetPosition(-125, -60); - btnFavorite.SetImage(&btnFavoriteImg); - btnFavorite.SetSoundOver(&btnSoundOver); - btnFavorite.SetSoundClick(&btnClick); - btnFavorite.SetTrigger(&trigA); - btnFavorite.SetEffectGrow(); + GuiImage btnFavoriteImg; + btnFavoriteImg.SetWidescreen(CFG.widescreen); + //GuiButton btnFavorite(&btnFavoriteImg,&btnFavoriteImg, 2, 5, -125, -60, &trigA, &btnSoundOver, &btnClick,1); + GuiButton btnFavorite(imgFavorite.GetWidth(), imgFavorite.GetHeight()); + btnFavorite.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + btnFavorite.SetPosition(-125, -60); + btnFavorite.SetImage(&btnFavoriteImg); + btnFavorite.SetSoundOver(&btnSoundOver); + btnFavorite.SetSoundClick(&btnClick); + btnFavorite.SetTrigger(&trigA); + btnFavorite.SetEffectGrow(); - GuiImage btnLeftImg(&imgLeft); - if (Settings.wsprompt == yes) - { - btnLeftImg.SetWidescreen(CFG.widescreen); - } - GuiButton btnLeft(&btnLeftImg,&btnLeftImg, 0, 5, 20, 0, &trigA, &btnSoundOver, &btnClick,1); - btnLeft.SetTrigger(&trigL); - btnLeft.SetTrigger(&trigMinus); + GuiImage btnLeftImg(&imgLeft); + if (Settings.wsprompt == yes) { + btnLeftImg.SetWidescreen(CFG.widescreen); + } + GuiButton btnLeft(&btnLeftImg,&btnLeftImg, 0, 5, 20, 0, &trigA, &btnSoundOver, &btnClick,1); + btnLeft.SetTrigger(&trigL); + btnLeft.SetTrigger(&trigMinus); - GuiImage btnRightImg(&imgRight); - if (Settings.wsprompt == yes) - { - btnRightImg.SetWidescreen(CFG.widescreen); - } - GuiButton btnRight(&btnRightImg,&btnRightImg, 1, 5, -20, 0, &trigA, &btnSoundOver, &btnClick,1); - btnRight.SetTrigger(&trigR); - btnRight.SetTrigger(&trigPlus); + GuiImage btnRightImg(&imgRight); + if (Settings.wsprompt == yes) { + btnRightImg.SetWidescreen(CFG.widescreen); + } + GuiButton btnRight(&btnRightImg,&btnRightImg, 1, 5, -20, 0, &trigA, &btnSoundOver, &btnClick,1); + btnRight.SetTrigger(&trigR); + btnRight.SetTrigger(&trigPlus); - promptWindow.Append(&dialogBoxImg); - promptWindow.Append(&nameBtn); - promptWindow.Append(&sizeTxt); - promptWindow.Append(&playcntTxt); - promptWindow.Append(&btn2); - promptWindow.Append(&btnLeft); - promptWindow.Append(&btnRight); - promptWindow.Append(&btnFavorite); + promptWindow.Append(&dialogBoxImg); + promptWindow.Append(&nameBtn); + promptWindow.Append(&sizeTxt); + promptWindow.Append(&playcntTxt); + promptWindow.Append(&btn2); + promptWindow.Append(&btnLeft); + promptWindow.Append(&btnRight); + promptWindow.Append(&btnFavorite); - //check if unlocked - if (Settings.godmode == 1) - { - promptWindow.Append(&btn3); - } + //check if unlocked + if (Settings.godmode == 1) { + promptWindow.Append(&btn3); + } - promptWindow.Append(&diskImg2); - promptWindow.Append(&btn1); + promptWindow.Append(&diskImg2); + promptWindow.Append(&btn1); - short changed = -1; - GuiImageData * diskCover = NULL; - GuiImageData * diskCover2 = NULL; + short changed = -1; + GuiImageData * diskCover = NULL; + GuiImageData * diskCover2 = NULL; - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); - while (changed) - { - if (changed == 1){ - promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 50); - } - else if (changed == 2){ - promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 50); - } - else if (changed == 3 || changed == 4) - { - if(diskCover2) - delete diskCover2; - diskCover2 = NULL; - if(diskCover) - diskCover2 = diskCover; - diskCover = NULL; - } + while (changed) { + if (changed == 1) { + promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 50); + } else if (changed == 2) { + promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 50); + } else if (changed == 3 || changed == 4) { + if (diskCover2) + delete diskCover2; + diskCover2 = NULL; + if (diskCover) + diskCover2 = diskCover; + diskCover = NULL; + } - //load disc image based or what game is seleted - struct discHdr * header = &gameList[gameSelected]; + //load disc image based or what game is seleted + struct discHdr * header = &gameList[gameSelected]; - snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); - snprintf (IDFull,sizeof(IDFull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); + snprintf (IDFull,sizeof(IDFull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - if (diskCover) - delete diskCover; + if (diskCover) + delete diskCover; - snprintf(imgPath,sizeof(imgPath),"%s%s.png", Settings.disc_path, IDFull); //changed to current full id - diskCover = new GuiImageData(imgPath,0); + snprintf(imgPath,sizeof(imgPath),"%s%s.png", Settings.disc_path, IDFull); //changed to current full id + diskCover = new GuiImageData(imgPath,0); - if (!diskCover->GetImage()) - { - delete diskCover; - snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.disc_path, ID); //changed to current id - diskCover = new GuiImageData(imgPath, 0); + if (!diskCover->GetImage()) { + delete diskCover; + snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.disc_path, ID); //changed to current id + diskCover = new GuiImageData(imgPath, 0); - if (!diskCover->GetImage()) - { snprintf (ID,sizeof(ID),"%c%c%c%c", header->id[0], header->id[1], header->id[2], header->id[3]); + if (!diskCover->GetImage()) { + snprintf (ID,sizeof(ID),"%c%c%c%c", header->id[0], header->id[1], header->id[2], header->id[3]); - delete diskCover; - snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.disc_path, ID); //changed to current id - diskCover = new GuiImageData(imgPath, 0); - if (!diskCover->GetImage()) - { - delete diskCover; - snprintf(imgPath, sizeof(imgPath), "%snodisc.png", CFG.theme_path); //changed to nodisc.png - diskCover = new GuiImageData(imgPath,nodisc_png); - } - } - } + delete diskCover; + snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.disc_path, ID); //changed to current id + diskCover = new GuiImageData(imgPath, 0); + if (!diskCover->GetImage()) { + delete diskCover; + snprintf(imgPath, sizeof(imgPath), "%snodisc.png", CFG.theme_path); //changed to nodisc.png + diskCover = new GuiImageData(imgPath,nodisc_png); + } + } + } - if (changed == 3){ - diskImg.SetImage(diskCover2); - diskImg.SetBeta(0); - diskImg.SetBetaRotateEffect(-90, 15); - diskImg2.SetImage(diskCover); - diskImg2.SetAngle(diskImg.GetAngle()); - diskImg2.SetBeta(180); - diskImg2.SetBetaRotateEffect(-90, 15); - sizeTxt.SetEffect(EFFECT_FADE, -17); - nameTxt.SetEffect(EFFECT_FADE, -17); - ResumeGui(); - while(nameTxt.GetEffect() > 0 || diskImg.GetBetaRotateEffect()) usleep(50); - HaltGui(); - diskImg.SetImage(diskCover); - diskImg.SetBeta(90); - diskImg.SetBetaRotateEffect(-90, 15); - diskImg2.SetImage(diskCover2); - diskImg2.SetBeta(270); - diskImg2.SetBetaRotateEffect(-90, 15); - sizeTxt.SetEffect(EFFECT_FADE, 17); - nameTxt.SetEffect(EFFECT_FADE, 17); - } - else if (changed == 4){ - diskImg.SetImage(diskCover2); - diskImg.SetBeta(0); - diskImg.SetBetaRotateEffect(90, 15); - diskImg2.SetImage(diskCover); - diskImg2.SetAngle(diskImg.GetAngle()); - diskImg2.SetBeta(180); - diskImg2.SetBetaRotateEffect(90, 15); - sizeTxt.SetEffect(EFFECT_FADE, -17); - nameTxt.SetEffect(EFFECT_FADE, -17); - ResumeGui(); - while(nameTxt.GetEffect() > 0 || diskImg.GetBetaRotateEffect()) usleep(50); - HaltGui(); - diskImg.SetImage(diskCover); - diskImg.SetBeta(270); - diskImg.SetBetaRotateEffect(90, 15); - diskImg2.SetImage(diskCover2); - diskImg2.SetBeta(90); - diskImg2.SetBetaRotateEffect(90, 15); - sizeTxt.SetEffect(EFFECT_FADE, 17); - nameTxt.SetEffect(EFFECT_FADE, 17); - } - else - diskImg.SetImage(diskCover); + if (changed == 3) { + diskImg.SetImage(diskCover2); + diskImg.SetBeta(0); + diskImg.SetBetaRotateEffect(-90, 15); + diskImg2.SetImage(diskCover); + diskImg2.SetAngle(diskImg.GetAngle()); + diskImg2.SetBeta(180); + diskImg2.SetBetaRotateEffect(-90, 15); + sizeTxt.SetEffect(EFFECT_FADE, -17); + nameTxt.SetEffect(EFFECT_FADE, -17); + ResumeGui(); + while (nameTxt.GetEffect() > 0 || diskImg.GetBetaRotateEffect()) usleep(50); + HaltGui(); + diskImg.SetImage(diskCover); + diskImg.SetBeta(90); + diskImg.SetBetaRotateEffect(-90, 15); + diskImg2.SetImage(diskCover2); + diskImg2.SetBeta(270); + diskImg2.SetBetaRotateEffect(-90, 15); + sizeTxt.SetEffect(EFFECT_FADE, 17); + nameTxt.SetEffect(EFFECT_FADE, 17); + } else if (changed == 4) { + diskImg.SetImage(diskCover2); + diskImg.SetBeta(0); + diskImg.SetBetaRotateEffect(90, 15); + diskImg2.SetImage(diskCover); + diskImg2.SetAngle(diskImg.GetAngle()); + diskImg2.SetBeta(180); + diskImg2.SetBetaRotateEffect(90, 15); + sizeTxt.SetEffect(EFFECT_FADE, -17); + nameTxt.SetEffect(EFFECT_FADE, -17); + ResumeGui(); + while (nameTxt.GetEffect() > 0 || diskImg.GetBetaRotateEffect()) usleep(50); + HaltGui(); + diskImg.SetImage(diskCover); + diskImg.SetBeta(270); + diskImg.SetBetaRotateEffect(90, 15); + diskImg2.SetImage(diskCover2); + diskImg2.SetBeta(90); + diskImg2.SetBetaRotateEffect(90, 15); + sizeTxt.SetEffect(EFFECT_FADE, 17); + nameTxt.SetEffect(EFFECT_FADE, 17); + } else + diskImg.SetImage(diskCover); - WBFS_GameSize(header->id, &size); - sizeTxt.SetTextf("%.2fGB", size); //set size text; - nameTxt.SetText(get_title(header)); + WBFS_GameSize(header->id, &size); + sizeTxt.SetTextf("%.2fGB", size); //set size text; + nameTxt.SetText(get_title(header)); - struct Game_NUM* game_num = CFG_get_game_num(header->id); - if (game_num) { - playcount = game_num->count; - favoritevar = game_num->favorite; - } else { - playcount = 0; - favoritevar = 0; - } - playcntTxt.SetTextf("%s: %i",tr("Play Count"), playcount); - btnFavoriteImg.SetImage(favoritevar ? &imgFavorite : &imgNotFavorite); + struct Game_NUM* game_num = CFG_get_game_num(header->id); + if (game_num) { + playcount = game_num->count; + favoritevar = game_num->favorite; + } else { + playcount = 0; + favoritevar = 0; + } + playcntTxt.SetTextf("%s: %i",tr("Play Count"), playcount); + btnFavoriteImg.SetImage(favoritevar ? &imgFavorite : &imgNotFavorite); - nameTxt.SetPosition(0, 1); + nameTxt.SetPosition(0, 1); - if(changed != 3 && changed != 4) // changed==3 or changed==4 --> only Resume the GUI - { - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&promptWindow); - mainWindow->ChangeFocus(&promptWindow); - } - ResumeGui(); + if (changed != 3 && changed != 4) { // changed==3 or changed==4 --> only Resume the GUI + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); + } + ResumeGui(); - changed = 0; - while(choice == -1) - { - diskImg.SetSpin(btn1.GetState() == STATE_SELECTED); - diskImg2.SetSpin(btn1.GetState() == STATE_SELECTED); - if(shutdown == 1) //for power button - { - wiilight(0); - Sys_Shutdown(); - } - if(reset == 1) //for reset button - Sys_Reboot(); + changed = 0; + while (choice == -1) { + diskImg.SetSpin(btn1.GetState() == STATE_SELECTED); + diskImg2.SetSpin(btn1.GetState() == STATE_SELECTED); + if (shutdown == 1) { //for power button + wiilight(0); + Sys_Shutdown(); + } + if (reset == 1) //for reset button + Sys_Reboot(); - if(btn1.GetState() == STATE_CLICKED) { - //playcounter - struct Game_NUM* game_num = CFG_get_game_num(header->id); - if (game_num) { - favoritevar = game_num->favorite; - playcount = game_num->count; + if (btn1.GetState() == STATE_CLICKED) { + //playcounter + struct Game_NUM* game_num = CFG_get_game_num(header->id); + if (game_num) { + favoritevar = game_num->favorite; + playcount = game_num->count; } else { favoritevar = 0; playcount = 0; } - playcount += 1; - if(isInserted(bootDevice)) { - CFG_save_game_num(header->id); - } - - choice = 1; - //SDCard_deInit();// moved this into menu.cpp after checking for gct file and alt dol - } - - else if(btn2.GetState() == STATE_CLICKED) { //back - choice = 0; - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - mainWindow->SetState(STATE_DEFAULT); - wiilight(0); - } - - else if(btn3.GetState() == STATE_CLICKED) { //settings - choice = 2; - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - } - - else if(nameBtn.GetState() == STATE_CLICKED) { //rename - choice = 3; - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - } - - else if(btnFavorite.GetState() == STATE_CLICKED){//switch favorite - //if(isSdInserted()) { - if(isInserted(bootDevice)) { - struct Game_NUM * game_num = CFG_get_game_num(header->id); - if (game_num) { - playcount = game_num->count; - favoritevar = game_num->favorite; - } else { - playcount = 0; - favoritevar = 0; - } - favoritevar = (favoritevar + 1) % 2; + playcount += 1; + if (isInserted(bootDevice)) { CFG_save_game_num(header->id); - btnFavoriteImg.SetImage(favoritevar ? &imgFavorite : &imgNotFavorite); - } - btnFavorite.ResetState(); - } + } - // this next part is long because nobody could agree on what the left/right buttons should do - else if((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == no)){//next game - promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); - changed = 1; - btnClick.Play(); - gameSelected = (gameSelected + 1) % gameCnt; - btnRight.ResetState(); - break; - } + choice = 1; + //SDCard_deInit();// moved this into menu.cpp after checking for gct file and alt dol + } - else if((btnLeft.GetState() == STATE_CLICKED) && (Settings.xflip == no)){//previous game - promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50); - changed = 2; - btnClick.Play(); - gameSelected = (gameSelected - 1 + gameCnt) % gameCnt; - btnLeft.ResetState(); - break; - } + else if (btn2.GetState() == STATE_CLICKED) { //back + choice = 0; + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + mainWindow->SetState(STATE_DEFAULT); + wiilight(0); + } - else if((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == yes)){//previous game - promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50); - changed = 2; - btnClick.Play(); - gameSelected = (gameSelected - 1 + gameCnt) % gameCnt; - btnRight.ResetState(); - break; - } + else if (btn3.GetState() == STATE_CLICKED) { //settings + choice = 2; + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + } - else if((btnLeft.GetState() == STATE_CLICKED) && (Settings.xflip == yes)){//netx game - promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); - changed = 1; - btnClick.Play(); - gameSelected = (gameSelected + 1) % gameCnt; - btnLeft.ResetState(); - break; - } + else if (nameBtn.GetState() == STATE_CLICKED) { //rename + choice = 3; + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + } - else if((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == sysmenu)){//previous game - promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50); - changed = 2; - btnClick.Play(); - gameSelected = (gameSelected + 1) % gameCnt; - btnRight.ResetState(); - break; - } + else if (btnFavorite.GetState() == STATE_CLICKED) {//switch favorite + //if(isSdInserted()) { + if (isInserted(bootDevice)) { + struct Game_NUM * game_num = CFG_get_game_num(header->id); + if (game_num) { + playcount = game_num->count; + favoritevar = game_num->favorite; + } else { + playcount = 0; + favoritevar = 0; + } + favoritevar = (favoritevar + 1) % 2; + CFG_save_game_num(header->id); + btnFavoriteImg.SetImage(favoritevar ? &imgFavorite : &imgNotFavorite); + } + btnFavorite.ResetState(); + } - else if((btnLeft.GetState() == STATE_CLICKED) && (Settings.xflip == sysmenu)){//netx game - promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); - changed = 1; - btnClick.Play(); - gameSelected = (gameSelected - 1 + gameCnt) % gameCnt; - btnLeft.ResetState(); - break; - } + // this next part is long because nobody could agree on what the left/right buttons should do + else if ((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == no)) {//next game + promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); + changed = 1; + btnClick.Play(); + gameSelected = (gameSelected + 1) % gameCnt; + btnRight.ResetState(); + break; + } - else if((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == wtf)){//previous game - promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); - changed = 1; - btnClick.Play(); - gameSelected = (gameSelected - 1 + gameCnt) % gameCnt; - btnRight.ResetState(); - break; - } + else if ((btnLeft.GetState() == STATE_CLICKED) && (Settings.xflip == no)) {//previous game + promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50); + changed = 2; + btnClick.Play(); + gameSelected = (gameSelected - 1 + gameCnt) % gameCnt; + btnLeft.ResetState(); + break; + } - else if((btnLeft.GetState() == STATE_CLICKED) && (Settings.xflip == wtf)){//netx game - promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50); - changed = 2; - btnClick.Play(); - gameSelected = (gameSelected + 1) % gameCnt; - btnLeft.ResetState(); - break; - } + else if ((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == yes)) {//previous game + promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50); + changed = 2; + btnClick.Play(); + gameSelected = (gameSelected - 1 + gameCnt) % gameCnt; + btnRight.ResetState(); + break; + } - else if((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == disk3d)){//next game + else if ((btnLeft.GetState() == STATE_CLICKED) && (Settings.xflip == yes)) {//netx game + promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); + changed = 1; + btnClick.Play(); + gameSelected = (gameSelected + 1) % gameCnt; + btnLeft.ResetState(); + break; + } + + else if ((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == sysmenu)) {//previous game + promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50); + changed = 2; + btnClick.Play(); + gameSelected = (gameSelected + 1) % gameCnt; + btnRight.ResetState(); + break; + } + + else if ((btnLeft.GetState() == STATE_CLICKED) && (Settings.xflip == sysmenu)) {//netx game + promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); + changed = 1; + btnClick.Play(); + gameSelected = (gameSelected - 1 + gameCnt) % gameCnt; + btnLeft.ResetState(); + break; + } + + else if ((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == wtf)) {//previous game + promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); + changed = 1; + btnClick.Play(); + gameSelected = (gameSelected - 1 + gameCnt) % gameCnt; + btnRight.ResetState(); + break; + } + + else if ((btnLeft.GetState() == STATE_CLICKED) && (Settings.xflip == wtf)) {//netx game + promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50); + changed = 2; + btnClick.Play(); + gameSelected = (gameSelected + 1) % gameCnt; + btnLeft.ResetState(); + break; + } + + else if ((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == disk3d)) {//next game // diskImg.SetBetaRotateEffect(45, 90); - changed = 3; - btnClick.Play(); - gameSelected = (gameSelected + 1) % gameCnt; - btnRight.ResetState(); - break; - } + changed = 3; + btnClick.Play(); + gameSelected = (gameSelected + 1) % gameCnt; + btnRight.ResetState(); + break; + } - else if((btnLeft.GetState() == STATE_CLICKED) && (Settings.xflip == disk3d)){//previous game + else if ((btnLeft.GetState() == STATE_CLICKED) && (Settings.xflip == disk3d)) {//previous game // diskImg.SetBetaRotateEffect(-45, 90); // promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 1/*50*/); - changed = 4; - btnClick.Play(); - gameSelected = (gameSelected - 1 + gameCnt) % gameCnt; - btnLeft.ResetState(); - break; - } - } + changed = 4; + btnClick.Play(); + gameSelected = (gameSelected - 1 + gameCnt) % gameCnt; + btnLeft.ResetState(); + break; + } + } - while(promptWindow.GetEffect() > 0) usleep(50); - HaltGui(); - if(changed != 3 && changed != 4) // changed==3 or changed==4 --> only Halt the GUI - { - mainWindow->Remove(&promptWindow); - ResumeGui(); - } - } - delete diskCover; - delete diskCover2; + while (promptWindow.GetEffect() > 0) usleep(50); + HaltGui(); + if (changed != 3 && changed != 4) { // changed==3 or changed==4 --> only Halt the GUI + mainWindow->Remove(&promptWindow); + ResumeGui(); + } + } + delete diskCover; + delete diskCover2; - return choice; + return choice; } /**************************************************************************** * DiscWait ***************************************************************************/ int -DiscWait(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, int IsDeviceWait) -{ - int i = 30, ret = 0; +DiscWait(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, int IsDeviceWait) { + int i = 30, ret = 0; u32 cover = 0; - GuiWindow promptWindow(472,320); - promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - promptWindow.SetPosition(0, -10); - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiWindow promptWindow(472,320); + promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + promptWindow.SetPosition(0, -10); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); - GuiImageData dialogBox(imgPath, dialogue_box_png); - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiTrigger trigB; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + char imgPath[100]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); + GuiImageData dialogBox(imgPath, dialogue_box_png); + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); - GuiImage dialogBoxImg(&dialogBox); - if (Settings.wsprompt == yes){ - dialogBoxImg.SetWidescreen(CFG.widescreen); - } + GuiImage dialogBoxImg(&dialogBox); + if (Settings.wsprompt == yes) { + dialogBoxImg.SetWidescreen(CFG.widescreen); + } - 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 msgTxt(msg, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - msgTxt.SetPosition(0,-40); - msgTxt.SetMaxWidth(430); + 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 msgTxt(msg, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + msgTxt.SetPosition(0,-40); + msgTxt.SetMaxWidth(430); - GuiText btn1Txt(btn1Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn1Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn1Txt.SetWidescreen(CFG.widescreen); - btn1Img.SetWidescreen(CFG.widescreen); - } - GuiButton btn1(&btn1Img,&btn1Img, 1, 5, 0, 0, &trigA, &btnSoundOver, &btnClick,1); + GuiText btn1Txt(btn1Label, 22, (GXColor) { THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn1Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn1Txt.SetWidescreen(CFG.widescreen); + btn1Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn1(&btn1Img,&btn1Img, 1, 5, 0, 0, &trigA, &btnSoundOver, &btnClick,1); - if(btn2Label) - { - btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); - btn1.SetPosition(40, -45); - } - else - { - btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); - btn1.SetPosition(0, -45); - } + if (btn2Label) { + btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); + btn1.SetPosition(40, -45); + } else { + btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); + btn1.SetPosition(0, -45); + } - btn1.SetLabel(&btn1Txt); - btn1.SetTrigger(&trigB); - btn1.SetState(STATE_SELECTED); + btn1.SetLabel(&btn1Txt); + btn1.SetTrigger(&trigB); + btn1.SetState(STATE_SELECTED); - GuiText btn2Txt(btn2Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn2Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn2Txt.SetWidescreen(CFG.widescreen); - btn2Img.SetWidescreen(CFG.widescreen); - } - GuiButton btn2(&btn2Img,&btn2Img, 1, 4, -20, -25, &trigA, &btnSoundOver, &btnClick,1); - btn2.SetLabel(&btn2Txt); + GuiText btn2Txt(btn2Label, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn2Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn2Txt.SetWidescreen(CFG.widescreen); + btn2Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn2(&btn2Img,&btn2Img, 1, 4, -20, -25, &trigA, &btnSoundOver, &btnClick,1); + btn2.SetLabel(&btn2Txt); - if ((Settings.wsprompt == yes) && (CFG.widescreen)){/////////////adjust buttons for widescreen - msgTxt.SetMaxWidth(380); - if(btn2Label) - { - btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); - btn2.SetPosition(-70, -80); - btn1.SetPosition(70, -80); - } - else - { - btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); - btn1.SetPosition(0, -80); - } - } + if ((Settings.wsprompt == yes) && (CFG.widescreen)) {/////////////adjust buttons for widescreen + msgTxt.SetMaxWidth(380); + if (btn2Label) { + btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); + btn2.SetPosition(-70, -80); + btn1.SetPosition(70, -80); + } else { + btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); + btn1.SetPosition(0, -80); + } + } - GuiText timerTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - timerTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - timerTxt.SetPosition(0,160); + GuiText timerTxt(NULL, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + timerTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + timerTxt.SetPosition(0,160); - promptWindow.Append(&dialogBoxImg); - promptWindow.Append(&titleTxt); - promptWindow.Append(&msgTxt); + promptWindow.Append(&dialogBoxImg); + promptWindow.Append(&titleTxt); + promptWindow.Append(&msgTxt); - if(btn1Label) - promptWindow.Append(&btn1); - if(btn2Label) - promptWindow.Append(&btn2); - if(IsDeviceWait) - promptWindow.Append(&timerTxt); + if (btn1Label) + promptWindow.Append(&btn1); + if (btn2Label) + promptWindow.Append(&btn2); + if (IsDeviceWait) + promptWindow.Append(&timerTxt); - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&promptWindow); - mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); - if(IsDeviceWait) { - while(i >= 0) - { + if (IsDeviceWait) { + while (i >= 0) { VIDEO_WaitVSync(); timerTxt.SetTextf("%u %s", i,tr("seconds left")); HaltGui(); - if(Settings.cios == ios222) { - ret = IOS_ReloadIOS(222); - load_ehc_module(); + if (Settings.cios == ios222) { + ret = IOS_ReloadIOS(222); + load_ehc_module(); } else { - ret = IOS_ReloadIOS(249); + ret = IOS_ReloadIOS(249); } ResumeGui(); sleep(1); ret = WBFS_Init(WBFS_DEVICE_USB); - if(ret>=0) - break; + if (ret>=0) + break; i--; } - } else { - while(!(cover & 0x2)) - { + } else { + while (!(cover & 0x2)) { VIDEO_WaitVSync(); - if(btn1.GetState() == STATE_CLICKED) { + if (btn1.GetState() == STATE_CLICKED) { btn1.ResetState(); break; } @@ -1599,300 +1572,293 @@ DiscWait(const char *title, const char *msg, const char *btn1Label, const char * if (ret < 0) break; } - } + } - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - while(promptWindow.GetEffect() > 0) usleep(50); - HaltGui(); - mainWindow->Remove(&promptWindow); - mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); - return ret; + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + while (promptWindow.GetEffect() > 0) usleep(50); + HaltGui(); + mainWindow->Remove(&promptWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); + return ret; } /**************************************************************************** * FormatingPartition ***************************************************************************/ int -FormatingPartition(const char *title, partitionEntry *entry) -{ +FormatingPartition(const char *title, partitionEntry *entry) { int ret; - GuiWindow promptWindow(472,320); - promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - promptWindow.SetPosition(0, -10); + GuiWindow promptWindow(472,320); + promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + promptWindow.SetPosition(0, -10); - char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); - GuiImageData dialogBox(imgPath, dialogue_box_png); + char imgPath[100]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); + GuiImageData dialogBox(imgPath, dialogue_box_png); - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiImage dialogBoxImg(&dialogBox); - if (Settings.wsprompt == yes){ - dialogBoxImg.SetWidescreen(CFG.widescreen); - } + GuiImage dialogBoxImg(&dialogBox); + if (Settings.wsprompt == yes) { + dialogBoxImg.SetWidescreen(CFG.widescreen); + } - 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 titleTxt(title, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + titleTxt.SetPosition(0,60); - promptWindow.Append(&dialogBoxImg); - promptWindow.Append(&titleTxt); + promptWindow.Append(&dialogBoxImg); + promptWindow.Append(&titleTxt); - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&promptWindow); - mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); - VIDEO_WaitVSync(); - ret = WBFS_Format(entry->sector, entry->size); + VIDEO_WaitVSync(); + ret = WBFS_Format(entry->sector, entry->size); - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - while(promptWindow.GetEffect() > 0) usleep(50); - HaltGui(); - mainWindow->Remove(&promptWindow); - mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); - return ret; + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + while (promptWindow.GetEffect() > 0) usleep(50); + HaltGui(); + mainWindow->Remove(&promptWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); + return ret; } /**************************************************************************** * SearchMissingImages ***************************************************************************/ -void SearchMissingImages(int choice2) -{ - //make sure that all games are added to the gamelist - __Menu_GetEntries(1); - GuiWindow promptWindow(472,320); - promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - promptWindow.SetPosition(0, -10); +void SearchMissingImages(int choice2) { + //make sure that all games are added to the gamelist + __Menu_GetEntries(1); + GuiWindow promptWindow(472,320); + promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + promptWindow.SetPosition(0, -10); GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); - GuiImageData dialogBox(imgPath, dialogue_box_png); - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + char imgPath[100]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); + GuiImageData dialogBox(imgPath, dialogue_box_png); + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiImage dialogBoxImg(&dialogBox); - if (Settings.wsprompt == yes){ - dialogBoxImg.SetWidescreen(CFG.widescreen); - } + GuiImage dialogBoxImg(&dialogBox); + if (Settings.wsprompt == yes) { + dialogBoxImg.SetWidescreen(CFG.widescreen); + } - GuiText titleTxt(tr("Initializing Network"), 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - titleTxt.SetPosition(0,60); + GuiText titleTxt(tr("Initializing Network"), 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + titleTxt.SetPosition(0,60); - char msg[20] = " "; - GuiText msgTxt(msg, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - msgTxt.SetPosition(0,-40); + char msg[20] = " "; + GuiText msgTxt(msg, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + msgTxt.SetPosition(0,-40); - GuiText btn1Txt(tr("Cancel"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn1Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn1Txt.SetWidescreen(CFG.widescreen); - btn1Img.SetWidescreen(CFG.widescreen); - } - GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -45, &trigA, &btnSoundOver, &btnClick,1); - btn1.SetLabel(&btn1Txt); - btn1.SetState(STATE_SELECTED); + GuiText btn1Txt(tr("Cancel"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn1Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn1Txt.SetWidescreen(CFG.widescreen); + btn1Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -45, &trigA, &btnSoundOver, &btnClick,1); + btn1.SetLabel(&btn1Txt); + btn1.SetState(STATE_SELECTED); - if ((Settings.wsprompt == yes) && (CFG.widescreen)){/////////////adjust buttons for widescreen - btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); - btn1.SetPosition(0, -80); - } + if ((Settings.wsprompt == yes) && (CFG.widescreen)) {/////////////adjust buttons for widescreen + btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); + btn1.SetPosition(0, -80); + } - promptWindow.Append(&dialogBoxImg); - promptWindow.Append(&titleTxt); - promptWindow.Append(&msgTxt); - promptWindow.Append(&btn1); + promptWindow.Append(&dialogBoxImg); + promptWindow.Append(&titleTxt); + promptWindow.Append(&msgTxt); + promptWindow.Append(&btn1); - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&promptWindow); - mainWindow->ChangeFocus(&promptWindow); + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); + ResumeGui(); - while (!IsNetworkInit()) { + while (!IsNetworkInit()) { VIDEO_WaitVSync(); Initialize_Network(); - if (!IsNetworkInit()) { - msgTxt.SetText(tr("Could not initialize network!")); - } + if (!IsNetworkInit()) { + msgTxt.SetText(tr("Could not initialize network!")); + } - if(btn1.GetState() == STATE_CLICKED) { - btn1.ResetState(); - break; - } + if (btn1.GetState() == STATE_CLICKED) { + btn1.ResetState(); + break; + } } if (IsNetworkInit()) { - msgTxt.SetTextf("IP: %s", GetNetworkIP()); - cntMissFiles = 0; - u32 i = 0; - char filename[11]; + msgTxt.SetTextf("IP: %s", GetNetworkIP()); + cntMissFiles = 0; + u32 i = 0; + char filename[11]; - bool found1 = false;/////add Ids of games that are missing covers to cntMissFiles - bool found2 = false; - bool found3 = false; - for (i = 0; i < gameCnt && cntMissFiles < 500; i++) - { - struct discHdr* header = &gameList[i]; - if (choice2 != 3) { + bool found1 = false;/////add Ids of games that are missing covers to cntMissFiles + bool found2 = false; + bool found3 = false; + for (i = 0; i < gameCnt && cntMissFiles < 500; i++) { + struct discHdr* header = &gameList[i]; + if (choice2 != 3) { - snprintf (filename,sizeof(filename),"%c%c%c.png", header->id[0], header->id[1], header->id[2]); - found2 = findfile(filename, Settings.covers_path); + snprintf (filename,sizeof(filename),"%c%c%c.png", header->id[0], header->id[1], header->id[2]); + found2 = findfile(filename, Settings.covers_path); - snprintf (filename,sizeof(filename),"%c%c%c%c.png", header->id[0], header->id[1], header->id[2], header->id[3]); - found3 = findfile(filename, Settings.covers_path); + snprintf (filename,sizeof(filename),"%c%c%c%c.png", header->id[0], header->id[1], header->id[2], header->id[3]); + found3 = findfile(filename, Settings.covers_path); - snprintf(filename,sizeof(filename),"%c%c%c%c%c%c.png",header->id[0], header->id[1], header->id[2], - header->id[3], header->id[4], header->id[5]); //full id - found1 = findfile(filename, Settings.covers_path); - if (!found1 && !found2 && !found3) //if could not find any image - { - snprintf(missingFiles[cntMissFiles],11,"%s",filename); - cntMissFiles++; - } - } - else if (choice2 == 3) { - snprintf (filename,sizeof(filename),"%c%c%c.png", header->id[0], header->id[1], header->id[2]); - found2 = findfile(filename, Settings.disc_path); - snprintf(filename,sizeof(filename),"%c%c%c%c%c%c.png",header->id[0], header->id[1], header->id[2], - header->id[3], header->id[4], header->id[5]); //full id - found1 = findfile(filename,Settings.disc_path); - if (!found1 && !found2) - { - snprintf(missingFiles[cntMissFiles],11,"%s",filename); - cntMissFiles++; - } - } - } - } + snprintf(filename,sizeof(filename),"%c%c%c%c%c%c.png",header->id[0], header->id[1], header->id[2], + header->id[3], header->id[4], header->id[5]); //full id + found1 = findfile(filename, Settings.covers_path); + if (!found1 && !found2 && !found3) { //if could not find any image + snprintf(missingFiles[cntMissFiles],11,"%s",filename); + cntMissFiles++; + } + } else if (choice2 == 3) { + snprintf (filename,sizeof(filename),"%c%c%c.png", header->id[0], header->id[1], header->id[2]); + found2 = findfile(filename, Settings.disc_path); + snprintf(filename,sizeof(filename),"%c%c%c%c%c%c.png",header->id[0], header->id[1], header->id[2], + header->id[3], header->id[4], header->id[5]); //full id + found1 = findfile(filename,Settings.disc_path); + if (!found1 && !found2) { + snprintf(missingFiles[cntMissFiles],11,"%s",filename); + cntMissFiles++; + } + } + } + } - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - while(promptWindow.GetEffect() > 0) usleep(50); - HaltGui(); - mainWindow->Remove(&promptWindow); - mainWindow->SetState(STATE_DEFAULT); - //change the gamelist backto how it was before this function - __Menu_GetEntries(); - ResumeGui(); + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + while (promptWindow.GetEffect() > 0) usleep(50); + HaltGui(); + mainWindow->Remove(&promptWindow); + mainWindow->SetState(STATE_DEFAULT); + //change the gamelist backto how it was before this function + __Menu_GetEntries(); + ResumeGui(); - return; + return; } /**************************************************************************** * NetworkInitPrompt ***************************************************************************/ -bool NetworkInitPrompt() -{ +bool NetworkInitPrompt() { bool success = true; - GuiWindow promptWindow(472,320); - promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - promptWindow.SetPosition(0, -10); + GuiWindow promptWindow(472,320); + promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + promptWindow.SetPosition(0, -10); GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); - GuiImageData dialogBox(imgPath, dialogue_box_png); - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + char imgPath[100]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); + GuiImageData dialogBox(imgPath, dialogue_box_png); + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiImage dialogBoxImg(&dialogBox); + GuiImage dialogBoxImg(&dialogBox); - if (Settings.wsprompt == yes){ + if (Settings.wsprompt == yes) { dialogBoxImg.SetWidescreen(CFG.widescreen); - } + } - GuiText titleTxt(tr("Initializing Network"), 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - titleTxt.SetPosition(0,60); + GuiText titleTxt(tr("Initializing Network"), 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + titleTxt.SetPosition(0,60); - char msg[20] = " "; - GuiText msgTxt(msg, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - msgTxt.SetPosition(0,-40); + char msg[20] = " "; + GuiText msgTxt(msg, 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + msgTxt.SetPosition(0,-40); - GuiText btn1Txt(tr("Cancel"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn1Img(&btnOutline); - if (Settings.wsprompt == yes){ + GuiText btn1Txt(tr("Cancel"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn1Img(&btnOutline); + if (Settings.wsprompt == yes) { btn1Txt.SetWidescreen(CFG.widescreen); btn1Img.SetWidescreen(CFG.widescreen); - } - GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -45, &trigA, &btnSoundOver, &btnClick,1); - btn1.SetLabel(&btn1Txt); - btn1.SetState(STATE_SELECTED); + } + GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -45, &trigA, &btnSoundOver, &btnClick,1); + btn1.SetLabel(&btn1Txt); + btn1.SetState(STATE_SELECTED); - if ((Settings.wsprompt == yes) && (CFG.widescreen)){/////////////adjust buttons for widescreen - btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); - btn1.SetPosition(0, -80); - } + if ((Settings.wsprompt == yes) && (CFG.widescreen)) {/////////////adjust buttons for widescreen + btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); + btn1.SetPosition(0, -80); + } - promptWindow.Append(&dialogBoxImg); - promptWindow.Append(&titleTxt); - promptWindow.Append(&msgTxt); - promptWindow.Append(&btn1); + promptWindow.Append(&dialogBoxImg); + promptWindow.Append(&titleTxt); + promptWindow.Append(&msgTxt); + promptWindow.Append(&btn1); - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&promptWindow); - mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); - while (!IsNetworkInit()) { + while (!IsNetworkInit()) { VIDEO_WaitVSync(); Initialize_Network(); - if (!IsNetworkInit()) { + if (!IsNetworkInit()) { msgTxt.SetText(tr("Could not initialize network!")); sleep(3); success = false; break; - } + } - if(btn1.GetState() == STATE_CLICKED) { - btn1.ResetState(); - success = false; - break; - } + if (btn1.GetState() == STATE_CLICKED) { + btn1.ResetState(); + success = false; + break; + } } - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - while(promptWindow.GetEffect() > 0) usleep(50); + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + while (promptWindow.GetEffect() > 0) usleep(50); - HaltGui(); - mainWindow->Remove(&promptWindow); - mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); + HaltGui(); + mainWindow->Remove(&promptWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); - return success; + return success; } /**************************************************************************** @@ -1903,394 +1869,366 @@ bool NetworkInitPrompt() * action is in progress. ***************************************************************************/ int -ProgressDownloadWindow(int choice2) -{ +ProgressDownloadWindow(int choice2) { int i = 0, cntNotFound = 0; - GuiWindow promptWindow(472,320); - promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - promptWindow.SetPosition(0, -10); + GuiWindow promptWindow(472,320); + promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + promptWindow.SetPosition(0, -10); GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); - GuiImageData dialogBox(imgPath, dialogue_box_png); - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + char imgPath[100]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); + GuiImageData dialogBox(imgPath, dialogue_box_png); + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiImage dialogBoxImg(&dialogBox); - if (Settings.wsprompt == yes){ - dialogBoxImg.SetWidescreen(CFG.widescreen);} + GuiImage dialogBoxImg(&dialogBox); + if (Settings.wsprompt == yes) { + dialogBoxImg.SetWidescreen(CFG.widescreen); + } - snprintf(imgPath, sizeof(imgPath), "%sprogressbar_outline.png", CFG.theme_path); - GuiImageData progressbarOutline(imgPath, progressbar_outline_png); - GuiImage progressbarOutlineImg(&progressbarOutline); - if (Settings.wsprompt == yes){ - progressbarOutlineImg.SetWidescreen(CFG.widescreen);} - progressbarOutlineImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - progressbarOutlineImg.SetPosition(25, 40); + snprintf(imgPath, sizeof(imgPath), "%sprogressbar_outline.png", CFG.theme_path); + GuiImageData progressbarOutline(imgPath, progressbar_outline_png); + GuiImage progressbarOutlineImg(&progressbarOutline); + if (Settings.wsprompt == yes) { + progressbarOutlineImg.SetWidescreen(CFG.widescreen); + } + progressbarOutlineImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + progressbarOutlineImg.SetPosition(25, 40); - snprintf(imgPath, sizeof(imgPath), "%sprogressbar_empty.png", CFG.theme_path); - GuiImageData progressbarEmpty(imgPath, progressbar_empty_png); - GuiImage progressbarEmptyImg(&progressbarEmpty); - progressbarEmptyImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - progressbarEmptyImg.SetPosition(25, 40); - progressbarEmptyImg.SetTile(100); + snprintf(imgPath, sizeof(imgPath), "%sprogressbar_empty.png", CFG.theme_path); + GuiImageData progressbarEmpty(imgPath, progressbar_empty_png); + GuiImage progressbarEmptyImg(&progressbarEmpty); + progressbarEmptyImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + progressbarEmptyImg.SetPosition(25, 40); + progressbarEmptyImg.SetTile(100); - snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path); - GuiImageData progressbar(imgPath, progressbar_png); - GuiImage progressbarImg(&progressbar); - progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - progressbarImg.SetPosition(25, 40); + snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path); + GuiImageData progressbar(imgPath, progressbar_png); + GuiImage progressbarImg(&progressbar); + progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + progressbarImg.SetPosition(25, 40); - GuiText titleTxt(tr("Downloading file"), 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - titleTxt.SetPosition(0,60); + GuiText titleTxt(tr("Downloading file"), 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + titleTxt.SetPosition(0,60); - GuiText msgTxt(NULL, 20, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - msgTxt.SetPosition(0,130); + GuiText msgTxt(NULL, 20, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + msgTxt.SetPosition(0,130); - GuiText msg2Txt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - msg2Txt.SetPosition(0,100); + GuiText msg2Txt(NULL, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + msg2Txt.SetPosition(0,100); - GuiText prTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - prTxt.SetPosition(0, 40); + GuiText prTxt(NULL, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + prTxt.SetPosition(0, 40); - GuiText btn1Txt(tr("Cancel"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn1Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn1Txt.SetWidescreen(CFG.widescreen); - btn1Img.SetWidescreen(CFG.widescreen);} - GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -45, &trigA, &btnSoundOver, &btnClick,1); - btn1.SetLabel(&btn1Txt); - btn1.SetState(STATE_SELECTED); + GuiText btn1Txt(tr("Cancel"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn1Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn1Txt.SetWidescreen(CFG.widescreen); + btn1Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -45, &trigA, &btnSoundOver, &btnClick,1); + btn1.SetLabel(&btn1Txt); + btn1.SetState(STATE_SELECTED); - if ((Settings.wsprompt == yes) && (CFG.widescreen)){/////////////adjust for widescreen - progressbarOutlineImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - progressbarOutlineImg.SetPosition(0, 40); - progressbarEmptyImg.SetPosition(80,40); - progressbarEmptyImg.SetTile(78); - progressbarImg.SetPosition(80, 40); - } + if ((Settings.wsprompt == yes) && (CFG.widescreen)) {/////////////adjust for widescreen + progressbarOutlineImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + progressbarOutlineImg.SetPosition(0, 40); + progressbarEmptyImg.SetPosition(80,40); + progressbarEmptyImg.SetTile(78); + progressbarImg.SetPosition(80, 40); + } - promptWindow.Append(&dialogBoxImg); - promptWindow.Append(&titleTxt); - promptWindow.Append(&msgTxt); - promptWindow.Append(&msg2Txt); + promptWindow.Append(&dialogBoxImg); + promptWindow.Append(&titleTxt); + promptWindow.Append(&msgTxt); + promptWindow.Append(&msg2Txt); promptWindow.Append(&progressbarEmptyImg); promptWindow.Append(&progressbarImg); promptWindow.Append(&progressbarOutlineImg); promptWindow.Append(&prTxt); promptWindow.Append(&btn1); - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&promptWindow); - mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); - int offset=0, tries=0; - int serverCnt3d = 1,serverCnt2d = 1,serverCntDisc = 1; + int offset=0, tries=0; + int serverCnt3d = 1,serverCnt2d = 1,serverCntDisc = 1; - char server3d[75]; - char serverDisc[75]; - char server2d[75]; + char server3d[75]; + char serverDisc[75]; + char server2d[75]; - snprintf(server3d, sizeof(server3d), "http://wiitdb.com/wiitdb/artwork/cover3D/"); - snprintf(serverDisc, sizeof(serverDisc), "http://wiitdb.com/wiitdb/artwork/disc/"); - snprintf(server2d, sizeof(server2d), "http://wiitdb.com/wiitdb/artwork/cover/"); + snprintf(server3d, sizeof(server3d), "http://wiitdb.com/wiitdb/artwork/cover3D/"); + snprintf(serverDisc, sizeof(serverDisc), "http://wiitdb.com/wiitdb/artwork/disc/"); + snprintf(server2d, sizeof(server2d), "http://wiitdb.com/wiitdb/artwork/cover/"); - //check if directory exist and if not create one + //check if directory exist and if not create one struct stat st; - if(stat(Settings.covers_path, &st) != 0) { - if(subfoldercreate(Settings.covers_path) != 1) { - WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); - cntMissFiles = 0; + if (stat(Settings.covers_path, &st) != 0) { + if (subfoldercreate(Settings.covers_path) != 1) { + WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); + cntMissFiles = 0; } } - if(stat(Settings.disc_path,&st) != 0) { - if(subfoldercreate(Settings.disc_path) != 1) { - WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); - cntMissFiles = 0; + if (stat(Settings.disc_path,&st) != 0) { + if (subfoldercreate(Settings.disc_path) != 1) { + WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); + cntMissFiles = 0; } } - // get Wii's language setting - char sysLanguage[3]; - GetLanguageToLangCode(sysLanguage); + // get Wii's language setting + char sysLanguage[3]; + GetLanguageToLangCode(sysLanguage); - //int server = 1; - while (i < cntMissFiles) - { - tries=0; - prTxt.SetTextf("%i%%", 100*i/cntMissFiles); + //int server = 1; + while (i < cntMissFiles) { + tries=0; + prTxt.SetTextf("%i%%", 100*i/cntMissFiles); - if ((Settings.wsprompt == yes) && (CFG.widescreen)) - { - //adjust for widescreen - progressbarImg.SetPosition(80,40); - progressbarImg.SetTile(80*i/cntMissFiles); - } - else - { - progressbarImg.SetTile(100*i/cntMissFiles); - } + if ((Settings.wsprompt == yes) && (CFG.widescreen)) { + //adjust for widescreen + progressbarImg.SetPosition(80,40); + progressbarImg.SetTile(80*i/cntMissFiles); + } else { + progressbarImg.SetTile(100*i/cntMissFiles); + } - if (cntMissFiles - i>1)msgTxt.SetTextf("%i %s", cntMissFiles - i, tr("files left")); - else msgTxt.SetTextf("%i %s", cntMissFiles - i, tr("file left")); - msg2Txt.SetTextf("%s", missingFiles[i]); + if (cntMissFiles - i>1)msgTxt.SetTextf("%i %s", cntMissFiles - i, tr("files left")); + else msgTxt.SetTextf("%i %s", cntMissFiles - i, tr("file left")); + msg2Txt.SetTextf("%s", missingFiles[i]); - //download boxart image - char imgPath[100]; - char URLFile[100]; - char tmp[75]; - sprintf(tmp,tr("Not Found")); - struct block file = downloadfile(URLFile); - if (choice2 == 2) - { - while(triesRemove(&promptWindow); - mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); + HaltGui(); + mainWindow->Remove(&promptWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); - if (cntNotFound != 0) { - return cntNotFound; - } else { + if (cntNotFound != 0) { + return cntNotFound; + } else { return 0; - } + } } /**************************************************************************** @@ -2300,133 +2238,135 @@ ProgressDownloadWindow(int choice2) * progress bar showing % completion, or a throbber that only shows that an * action is in progress. ***************************************************************************/ - #define BLOCKSIZE 1024 - /*bool unzipArchive(char * zipfilepath, char * unzipfolderpath) +#define BLOCKSIZE 1024 +/*bool unzipArchive(char * zipfilepath, char * unzipfolderpath) { - unzFile uf = unzOpen(zipfilepath); - if (uf==NULL) - { - // printf("Cannot open %s, aborting\n",zipfilepath); - return false; - } - //printf("%s opened\n",zipfilepath); - if(chdir(unzipfolderpath)) // can't access dir - { - makedir(unzipfolderpath); // attempt to make dir - if(chdir(unzipfolderpath)) // still can't access dir - { - //printf("Error changing into %s, aborting\n", unzipfolderpath); - return false; - } - } - extractZip(uf,0,1,0); - unzCloseCurrentFile(uf); - return true + unzFile uf = unzOpen(zipfilepath); + if (uf==NULL) + { + // printf("Cannot open %s, aborting\n",zipfilepath); + return false; + } + //printf("%s opened\n",zipfilepath); + if(chdir(unzipfolderpath)) // can't access dir + { + makedir(unzipfolderpath); // attempt to make dir + if(chdir(unzipfolderpath)) // still can't access dir + { + //printf("Error changing into %s, aborting\n", unzipfolderpath); + return false; + } + } + extractZip(uf,0,1,0); + unzCloseCurrentFile(uf); + return true } */ - #ifdef NOTFULLCHANNEL +#ifdef NOTFULLCHANNEL -int ProgressUpdateWindow() -{ +int ProgressUpdateWindow() { int ret = 0, failed = 0; - GuiWindow promptWindow(472,320); - promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - promptWindow.SetPosition(0, -10); + GuiWindow promptWindow(472,320); + promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + promptWindow.SetPosition(0, -10); GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); - GuiImageData dialogBox(imgPath, dialogue_box_png); - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + char imgPath[100]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); + GuiImageData dialogBox(imgPath, dialogue_box_png); + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiImage dialogBoxImg(&dialogBox); - if (Settings.wsprompt == yes){ - dialogBoxImg.SetWidescreen(CFG.widescreen);} + GuiImage dialogBoxImg(&dialogBox); + if (Settings.wsprompt == yes) { + dialogBoxImg.SetWidescreen(CFG.widescreen); + } - snprintf(imgPath, sizeof(imgPath), "%sprogressbar_outline.png", CFG.theme_path); - GuiImageData progressbarOutline(imgPath, progressbar_outline_png); - GuiImage progressbarOutlineImg(&progressbarOutline); - if (Settings.wsprompt == yes){ - progressbarOutlineImg.SetWidescreen(CFG.widescreen);} - progressbarOutlineImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - progressbarOutlineImg.SetPosition(25, 7); + snprintf(imgPath, sizeof(imgPath), "%sprogressbar_outline.png", CFG.theme_path); + GuiImageData progressbarOutline(imgPath, progressbar_outline_png); + GuiImage progressbarOutlineImg(&progressbarOutline); + if (Settings.wsprompt == yes) { + progressbarOutlineImg.SetWidescreen(CFG.widescreen); + } + progressbarOutlineImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + progressbarOutlineImg.SetPosition(25, 7); - snprintf(imgPath, sizeof(imgPath), "%sprogressbar_empty.png", CFG.theme_path); - GuiImageData progressbarEmpty(imgPath, progressbar_empty_png); - GuiImage progressbarEmptyImg(&progressbarEmpty); - progressbarEmptyImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - progressbarEmptyImg.SetPosition(25, 7); - progressbarEmptyImg.SetTile(100); + snprintf(imgPath, sizeof(imgPath), "%sprogressbar_empty.png", CFG.theme_path); + GuiImageData progressbarEmpty(imgPath, progressbar_empty_png); + GuiImage progressbarEmptyImg(&progressbarEmpty); + progressbarEmptyImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + progressbarEmptyImg.SetPosition(25, 7); + progressbarEmptyImg.SetTile(100); - snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path); - GuiImageData progressbar(imgPath, progressbar_png); - GuiImage progressbarImg(&progressbar); - progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - progressbarImg.SetPosition(25, 7); + snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path); + GuiImageData progressbar(imgPath, progressbar_png); + GuiImage progressbarImg(&progressbar); + progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + progressbarImg.SetPosition(25, 7); char title[50]; sprintf(title, "%s", tr("Checking for Updates")); - GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - titleTxt.SetPosition(0,50); + GuiText titleTxt(title, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + titleTxt.SetPosition(0,50); char msg[50]; sprintf(msg, "%s", tr("Initializing Network")); - GuiText msgTxt(msg, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - msgTxt.SetPosition(0,140); - char msg2[50] = " "; - GuiText msg2Txt(msg2, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - msg2Txt.SetPosition(0, 50); + GuiText msgTxt(msg, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + msgTxt.SetPosition(0,140); + char msg2[50] = " "; + GuiText msg2Txt(msg2, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + msg2Txt.SetPosition(0, 50); - GuiText prTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - prTxt.SetPosition(0, 7); + GuiText prTxt(NULL, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + prTxt.SetPosition(0, 7); - GuiText btn1Txt(tr("Cancel"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn1Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn1Txt.SetWidescreen(CFG.widescreen); - btn1Img.SetWidescreen(CFG.widescreen);} - GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -40, &trigA, &btnSoundOver, &btnClick,1); - btn1.SetLabel(&btn1Txt); - btn1.SetState(STATE_SELECTED); + GuiText btn1Txt(tr("Cancel"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn1Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn1Txt.SetWidescreen(CFG.widescreen); + btn1Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -40, &trigA, &btnSoundOver, &btnClick,1); + btn1.SetLabel(&btn1Txt); + btn1.SetState(STATE_SELECTED); - if ((Settings.wsprompt == yes) && (CFG.widescreen)){/////////////adjust for widescreen - progressbarOutlineImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - progressbarOutlineImg.SetPosition(0, 7); - progressbarEmptyImg.SetPosition(80,7); - progressbarEmptyImg.SetTile(78); - progressbarImg.SetPosition(80, 7); - } + if ((Settings.wsprompt == yes) && (CFG.widescreen)) {/////////////adjust for widescreen + progressbarOutlineImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + progressbarOutlineImg.SetPosition(0, 7); + progressbarEmptyImg.SetPosition(80,7); + progressbarEmptyImg.SetTile(78); + progressbarImg.SetPosition(80, 7); + } - promptWindow.Append(&dialogBoxImg); - promptWindow.Append(&titleTxt); - promptWindow.Append(&msgTxt); - promptWindow.Append(&msg2Txt); + promptWindow.Append(&dialogBoxImg); + promptWindow.Append(&titleTxt); + promptWindow.Append(&msgTxt); + promptWindow.Append(&msg2Txt); promptWindow.Append(&btn1); promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&promptWindow); - mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); struct stat st; - if(stat(Settings.update_path, &st) != 0) { - if(subfoldercreate(Settings.update_path) != 1) { - WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); - ret = -1; - failed = -1; + if (stat(Settings.update_path, &st) != 0) { + if (subfoldercreate(Settings.update_path) != 1) { + WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); + ret = -1; + failed = -1; } } @@ -2435,175 +2375,175 @@ int ProgressUpdateWindow() snprintf(dolpath, sizeof(dolpath), "%sbootnew.dol", Settings.update_path); snprintf(dolpathsuccess, sizeof(dolpathsuccess), "%sboot.dol", Settings.update_path); - while (!IsNetworkInit()) { + while (!IsNetworkInit()) { VIDEO_WaitVSync(); Initialize_Network(); - if (IsNetworkInit()) { - msgTxt.SetText(GetNetworkIP()); - } else { - msgTxt.SetText(tr("Could not initialize network!")); - } - - if(btn1.GetState() == STATE_CLICKED) { - ret = -1; - failed = -1; - btn1.ResetState(); - break; - } - } - - // get Wii's language setting - char sysLanguage[3]; - GetLanguageToLangCode(sysLanguage); - - //make the URL to get XML based on our games - char XMLurl[2040]; - char filename[10]; - __Menu_GetEntries(1); - snprintf(XMLurl,sizeof(XMLurl),"http://wiitdb.com/wiitdb.zip?LANG=%s?ID=",sysLanguage); - unsigned int i; - for (i = 0; i < gameCnt ; i++) { - struct discHdr* header = &gameList[i]; - if (i<500) { - snprintf(filename,sizeof(filename),"%c%c%c", header->id[1], header->id[2], header->id[3]); - strncat(XMLurl, filename,3 ); - if ((i!=gameCnt-1)&&(i<500)) - strncat(XMLurl, ",",1); - } - } - __Menu_GetEntries(); - if(IsNetworkInit() && ret >= 0) { - - int newrev = CheckUpdate(); - if(newrev > 0) { - - sprintf(msg, "Rev%i %s.", newrev, tr("available")); - int choice = WindowPrompt(msg, tr("How do you want to update?"), tr("Update DOL"), tr("Update All"), tr("Cancel")); - mainWindow->SetState(STATE_DISABLED); - promptWindow.SetState(STATE_DEFAULT); - mainWindow->ChangeFocus(&promptWindow); - if(choice == 1 || choice == 2) { - titleTxt.SetTextf("%s USB Loader GX", tr("Updating")); - msgTxt.SetPosition(0,100); - promptWindow.Append(&progressbarEmptyImg); - promptWindow.Append(&progressbarImg); - promptWindow.Append(&progressbarOutlineImg); - promptWindow.Append(&prTxt); - msgTxt.SetTextf("%s Rev%i", tr("Update to"), newrev); - s32 filesize = download_request("http://www.techjawa.com/usbloadergx/boot.dol"); - if(filesize > 0) { - FILE * pfile; - pfile = fopen(dolpath, "wb"); - u8 * blockbuffer = new unsigned char[BLOCKSIZE]; - for (s32 i = 0; i < filesize; i += BLOCKSIZE) { - usleep(100); - prTxt.SetTextf("%i%%", (100*i/filesize)+1); - if ((Settings.wsprompt == yes) && (CFG.widescreen)) { - progressbarImg.SetTile(80*i/filesize); - } else { - progressbarImg.SetTile(100*i/filesize); - } - msg2Txt.SetTextf("%iKB/%iKB", i/1024, filesize/1024); - - if(btn1.GetState() == STATE_CLICKED) { - fclose(pfile); - remove(dolpath); - failed = -1; - btn1.ResetState(); - break; - } - - u32 blksize; - blksize = (u32)(filesize - i); - if (blksize > BLOCKSIZE) - blksize = BLOCKSIZE; - - ret = network_read(blockbuffer, blksize); - if (ret != (s32) blksize) { - failed = -1; - ret = -1; - fclose(pfile); - remove(dolpath); - break; - } - fwrite(blockbuffer,1,blksize, pfile); - } - fclose(pfile); - delete blockbuffer; - if(!failed) { - //remove old - if(checkfile(dolpathsuccess)){ - remove(dolpathsuccess); - } - //rename new to old - rename(dolpath, dolpathsuccess); - - if(choice == 2) { - //get the icon.png and the meta.xml - char xmliconpath[150]; - struct block file = downloadfile("http://www.techjawa.com/usbloadergx/meta.file"); - if(file.data != NULL){ - sprintf(xmliconpath, "%smeta.xml", Settings.update_path); - pfile = fopen(xmliconpath, "wb"); - fwrite(file.data,1,file.size,pfile); - fclose(pfile); - free(file.data); - } - file = downloadfile("http://www.techjawa.com/usbloadergx/icon.png"); - if(file.data != NULL){ - sprintf(xmliconpath, "%sicon.png", Settings.update_path); - pfile = fopen(xmliconpath, "wb"); - fwrite(file.data,1,file.size,pfile); - fclose(pfile); - free(file.data); - } - msgTxt.SetTextf("%s", tr("Updating WiiTDB.zip")); - file = downloadfile(XMLurl); - if(file.data != NULL){ - sprintf(xmliconpath, "%swiitdb.zip", Settings.titlestxt_path); - pfile = fopen(xmliconpath, "wb"); - fwrite(file.data,1,file.size,pfile); - fclose(pfile); - free(file.data); - } - msgTxt.SetTextf("%s", tr("Updating Language Files:")); - updateLanguageFiles(); - } - } - }else { - failed = -1; - } + if (IsNetworkInit()) { + msgTxt.SetText(GetNetworkIP()); } else { - ret = -1; + msgTxt.SetText(tr("Could not initialize network!")); } - } else { - WindowPrompt(tr("No new updates."), 0, tr("OK")); - ret = -1; + if (btn1.GetState() == STATE_CLICKED) { + ret = -1; + failed = -1; + btn1.ResetState(); + break; + } } + // get Wii's language setting + char sysLanguage[3]; + GetLanguageToLangCode(sysLanguage); + + //make the URL to get XML based on our games + char XMLurl[2040]; + char filename[10]; + __Menu_GetEntries(1); + snprintf(XMLurl,sizeof(XMLurl),"http://wiitdb.com/wiitdb.zip?LANG=%s?ID=",sysLanguage); + unsigned int i; + for (i = 0; i < gameCnt ; i++) { + struct discHdr* header = &gameList[i]; + if (i<500) { + snprintf(filename,sizeof(filename),"%c%c%c", header->id[1], header->id[2], header->id[3]); + strncat(XMLurl, filename,3 ); + if ((i!=gameCnt-1)&&(i<500)) + strncat(XMLurl, ",",1); + } + } + __Menu_GetEntries(); + if (IsNetworkInit() && ret >= 0) { + + int newrev = CheckUpdate(); + if (newrev > 0) { + + sprintf(msg, "Rev%i %s.", newrev, tr("available")); + int choice = WindowPrompt(msg, tr("How do you want to update?"), tr("Update DOL"), tr("Update All"), tr("Cancel")); + mainWindow->SetState(STATE_DISABLED); + promptWindow.SetState(STATE_DEFAULT); + mainWindow->ChangeFocus(&promptWindow); + if (choice == 1 || choice == 2) { + titleTxt.SetTextf("%s USB Loader GX", tr("Updating")); + msgTxt.SetPosition(0,100); + promptWindow.Append(&progressbarEmptyImg); + promptWindow.Append(&progressbarImg); + promptWindow.Append(&progressbarOutlineImg); + promptWindow.Append(&prTxt); + msgTxt.SetTextf("%s Rev%i", tr("Update to"), newrev); + s32 filesize = download_request("http://www.techjawa.com/usbloadergx/boot.dol"); + if (filesize > 0) { + FILE * pfile; + pfile = fopen(dolpath, "wb"); + u8 * blockbuffer = new unsigned char[BLOCKSIZE]; + for (s32 i = 0; i < filesize; i += BLOCKSIZE) { + usleep(100); + prTxt.SetTextf("%i%%", (100*i/filesize)+1); + if ((Settings.wsprompt == yes) && (CFG.widescreen)) { + progressbarImg.SetTile(80*i/filesize); + } else { + progressbarImg.SetTile(100*i/filesize); + } + msg2Txt.SetTextf("%iKB/%iKB", i/1024, filesize/1024); + + if (btn1.GetState() == STATE_CLICKED) { + fclose(pfile); + remove(dolpath); + failed = -1; + btn1.ResetState(); + break; + } + + u32 blksize; + blksize = (u32)(filesize - i); + if (blksize > BLOCKSIZE) + blksize = BLOCKSIZE; + + ret = network_read(blockbuffer, blksize); + if (ret != (s32) blksize) { + failed = -1; + ret = -1; + fclose(pfile); + remove(dolpath); + break; + } + fwrite(blockbuffer,1,blksize, pfile); + } + fclose(pfile); + delete blockbuffer; + if (!failed) { + //remove old + if (checkfile(dolpathsuccess)) { + remove(dolpathsuccess); + } + //rename new to old + rename(dolpath, dolpathsuccess); + + if (choice == 2) { + //get the icon.png and the meta.xml + char xmliconpath[150]; + struct block file = downloadfile("http://www.techjawa.com/usbloadergx/meta.file"); + if (file.data != NULL) { + sprintf(xmliconpath, "%smeta.xml", Settings.update_path); + pfile = fopen(xmliconpath, "wb"); + fwrite(file.data,1,file.size,pfile); + fclose(pfile); + free(file.data); + } + file = downloadfile("http://www.techjawa.com/usbloadergx/icon.png"); + if (file.data != NULL) { + sprintf(xmliconpath, "%sicon.png", Settings.update_path); + pfile = fopen(xmliconpath, "wb"); + fwrite(file.data,1,file.size,pfile); + fclose(pfile); + free(file.data); + } + msgTxt.SetTextf("%s", tr("Updating WiiTDB.zip")); + file = downloadfile(XMLurl); + if (file.data != NULL) { + sprintf(xmliconpath, "%swiitdb.zip", Settings.titlestxt_path); + pfile = fopen(xmliconpath, "wb"); + fwrite(file.data,1,file.size,pfile); + fclose(pfile); + free(file.data); + } + msgTxt.SetTextf("%s", tr("Updating Language Files:")); + updateLanguageFiles(); + } + } + } else { + failed = -1; + } + } else { + ret = -1; + } + + } else { + WindowPrompt(tr("No new updates."), 0, tr("OK")); + ret = -1; + } + } CloseConnection(); - if(!failed && ret >= 0) { + if (!failed && ret >= 0) { WindowPrompt(tr("Successfully Updated") , tr("Restarting..."), tr("OK")); Sys_BackToLoader(); } promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - while(promptWindow.GetEffect() > 0) usleep(50); + while (promptWindow.GetEffect() > 0) usleep(50); - HaltGui(); - mainWindow->Remove(&promptWindow); - mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); + HaltGui(); + mainWindow->Remove(&promptWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); - if(failed != 0) - return failed; + if (failed != 0) + return failed; return 1; } @@ -2611,454 +2551,452 @@ int ProgressUpdateWindow() #else ///////////////////this is only used if the dol is being compiled for a full channel -int ProgressUpdateWindow() -{ +int ProgressUpdateWindow() { int ret = 0, failed = 0; - GuiWindow promptWindow(472,320); - promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - promptWindow.SetPosition(0, -10); + GuiWindow promptWindow(472,320); + promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + promptWindow.SetPosition(0, -10); GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); - GuiImageData dialogBox(imgPath, dialogue_box_png); - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + char imgPath[100]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); + GuiImageData dialogBox(imgPath, dialogue_box_png); + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiImage dialogBoxImg(&dialogBox); - if (Settings.wsprompt == yes){ - dialogBoxImg.SetWidescreen(CFG.widescreen);} + GuiImage dialogBoxImg(&dialogBox); + if (Settings.wsprompt == yes) { + dialogBoxImg.SetWidescreen(CFG.widescreen); + } - snprintf(imgPath, sizeof(imgPath), "%sprogressbar_outline.png", CFG.theme_path); - GuiImageData progressbarOutline(imgPath, progressbar_outline_png); - GuiImage progressbarOutlineImg(&progressbarOutline); - if (Settings.wsprompt == yes){ - progressbarOutlineImg.SetWidescreen(CFG.widescreen);} - progressbarOutlineImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - progressbarOutlineImg.SetPosition(25, 7); + snprintf(imgPath, sizeof(imgPath), "%sprogressbar_outline.png", CFG.theme_path); + GuiImageData progressbarOutline(imgPath, progressbar_outline_png); + GuiImage progressbarOutlineImg(&progressbarOutline); + if (Settings.wsprompt == yes) { + progressbarOutlineImg.SetWidescreen(CFG.widescreen); + } + progressbarOutlineImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + progressbarOutlineImg.SetPosition(25, 7); - snprintf(imgPath, sizeof(imgPath), "%sprogressbar_empty.png", CFG.theme_path); - GuiImageData progressbarEmpty(imgPath, progressbar_empty_png); - GuiImage progressbarEmptyImg(&progressbarEmpty); - progressbarEmptyImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - progressbarEmptyImg.SetPosition(25, 7); - progressbarEmptyImg.SetTile(100); + snprintf(imgPath, sizeof(imgPath), "%sprogressbar_empty.png", CFG.theme_path); + GuiImageData progressbarEmpty(imgPath, progressbar_empty_png); + GuiImage progressbarEmptyImg(&progressbarEmpty); + progressbarEmptyImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + progressbarEmptyImg.SetPosition(25, 7); + progressbarEmptyImg.SetTile(100); - snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path); - GuiImageData progressbar(imgPath, progressbar_png); - GuiImage progressbarImg(&progressbar); - progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - progressbarImg.SetPosition(25, 7); + snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path); + GuiImageData progressbar(imgPath, progressbar_png); + GuiImage progressbarImg(&progressbar); + progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + progressbarImg.SetPosition(25, 7); char title[50]; sprintf(title, "%s", tr("Checking for Updates")); - GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - titleTxt.SetPosition(0,50); + GuiText titleTxt(title, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + titleTxt.SetPosition(0,50); char msg[50]; sprintf(msg, "%s", tr("Initializing Network")); - GuiText msgTxt(msg, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - msgTxt.SetPosition(0,140); - char msg2[50] = " "; - GuiText msg2Txt(msg2, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - msg2Txt.SetPosition(0, 50); + GuiText msgTxt(msg, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + msgTxt.SetPosition(0,140); + char msg2[50] = " "; + GuiText msg2Txt(msg2, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + msg2Txt.SetPosition(0, 50); - GuiText prTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - prTxt.SetPosition(0, 7); + GuiText prTxt(NULL, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + prTxt.SetPosition(0, 7); - GuiText btn1Txt(tr("Cancel"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn1Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn1Txt.SetWidescreen(CFG.widescreen); - btn1Img.SetWidescreen(CFG.widescreen);} - GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -40, &trigA, &btnSoundOver, &btnClick,1); - btn1.SetLabel(&btn1Txt); - btn1.SetState(STATE_SELECTED); + GuiText btn1Txt(tr("Cancel"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn1Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn1Txt.SetWidescreen(CFG.widescreen); + btn1Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -40, &trigA, &btnSoundOver, &btnClick,1); + btn1.SetLabel(&btn1Txt); + btn1.SetState(STATE_SELECTED); - if ((Settings.wsprompt == yes) && (CFG.widescreen)){/////////////adjust for widescreen - progressbarOutlineImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - progressbarOutlineImg.SetPosition(0, 7); - progressbarEmptyImg.SetPosition(80,7); - progressbarEmptyImg.SetTile(78); - progressbarImg.SetPosition(80, 7); - } + if ((Settings.wsprompt == yes) && (CFG.widescreen)) {/////////////adjust for widescreen + progressbarOutlineImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + progressbarOutlineImg.SetPosition(0, 7); + progressbarEmptyImg.SetPosition(80,7); + progressbarEmptyImg.SetTile(78); + progressbarImg.SetPosition(80, 7); + } - promptWindow.Append(&dialogBoxImg); - promptWindow.Append(&titleTxt); - promptWindow.Append(&msgTxt); - promptWindow.Append(&msg2Txt); + promptWindow.Append(&dialogBoxImg); + promptWindow.Append(&titleTxt); + promptWindow.Append(&msgTxt); + promptWindow.Append(&msg2Txt); promptWindow.Append(&btn1); promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&promptWindow); - mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); struct stat st; - if(stat(Settings.update_path, &st) != 0) { - if(subfoldercreate(Settings.covers_path) != 1) { - WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); - ret = -1; - failed = -1; + if (stat(Settings.update_path, &st) != 0) { + if (subfoldercreate(Settings.covers_path) != 1) { + WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); + ret = -1; + failed = -1; } } - if(stat(Settings.titlestxt_path, &st) != 0) { - if(subfoldercreate(Settings.titlestxt_path) != 1) { - WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); - ret = -1; - failed = -1; + if (stat(Settings.titlestxt_path, &st) != 0) { + if (subfoldercreate(Settings.titlestxt_path) != 1) { + WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); + ret = -1; + failed = -1; } } - // get Wii's language setting - char sysLanguage[3]; - GetLanguageToLangCode(sysLanguage); + // get Wii's language setting + char sysLanguage[3]; + GetLanguageToLangCode(sysLanguage); - //make the URL to get XML based on our games - char XMLurl[2040]; - char filename[10]; - __Menu_GetEntries(1); - snprintf(XMLurl,sizeof(XMLurl),"http://wiitdb.com/wiitdb.zip?LANG=%s?ID=",sysLanguage); - unsigned int i; - for (i = 0; i < gameCnt ; i++) { - struct discHdr* header = &gameList[i]; - if (i<500) { - snprintf(filename,sizeof(filename),"%c%c%c", header->id[1], header->id[2], header->id[3]); - strncat(XMLurl, filename,3 ); - if ((i!=gameCnt-1)&&(i<500)) - strncat(XMLurl, ",",1); - } - } - __Menu_GetEntries(); + //make the URL to get XML based on our games + char XMLurl[2040]; + char filename[10]; + __Menu_GetEntries(1); + snprintf(XMLurl,sizeof(XMLurl),"http://wiitdb.com/wiitdb.zip?LANG=%s?ID=",sysLanguage); + unsigned int i; + for (i = 0; i < gameCnt ; i++) { + struct discHdr* header = &gameList[i]; + if (i<500) { + snprintf(filename,sizeof(filename),"%c%c%c", header->id[1], header->id[2], header->id[3]); + strncat(XMLurl, filename,3 ); + if ((i!=gameCnt-1)&&(i<500)) + strncat(XMLurl, ",",1); + } + } + __Menu_GetEntries(); char dolpath[150]; // char dolpathsuccess[150];//use coverspath as a folder for the update wad so we dont make a new folder and have to delete it snprintf(dolpath, sizeof(dolpath), "%sULNR.wad", Settings.covers_path); //snprintf(dolpathsuccess, sizeof(dolpathsuccess), "%sUNEO.wad", Settings.covers_path); - Initialize_Network(); - while (!IsNetworkInit()) { + Initialize_Network(); + while (!IsNetworkInit()) { VIDEO_WaitVSync(); Initialize_Network(); - if (IsNetworkInit()) { - msgTxt.SetText(GetNetworkIP()); - } else { - msgTxt.SetText(tr("Could not initialize network!")); - } - - if(btn1.GetState() == STATE_CLICKED) { - ret = -1; - failed = -1; - btn1.ResetState(); - break; - } - } - - if(IsNetworkInit() && ret >= 0) { - - int newrev = CheckUpdate(); - - if(newrev > 0) { - FILE * pfile; - sprintf(msg, "Rev%i %s.", newrev, tr("available")); - int choice = WindowPrompt(msg, 0, tr("Update"),tr("Cancel")); - if(choice == 1) { - titleTxt.SetTextf("%s USB Loader GX", tr("Updating")); - msgTxt.SetPosition(0,100); - msgTxt.SetTextf("%s", tr("Updating WiiTDB.zip"));//download the wad but it is saved as a genaric file. - - struct block file = downloadfile(XMLurl); - char xmliconpath[100]; - if(file.data != NULL){ - sprintf(xmliconpath, "%swiitdb.zip", Settings.titlestxt_path); - pfile = fopen(xmliconpath, "wb"); - fwrite(file.data,1,file.size,pfile); - fclose(pfile); - free(file.data); - } - msgTxt.SetTextf("%s", tr("Updating Language Files:")); - updateLanguageFiles(); - promptWindow.Append(&progressbarEmptyImg); - promptWindow.Append(&progressbarImg); - promptWindow.Append(&progressbarOutlineImg); - promptWindow.Append(&prTxt); - msgTxt.SetTextf("%s Rev%i wad.", tr("Downloading"), newrev); - s32 filesize = download_request("http://www.techjawa.com/usbloadergx/ULNR.file");//for some reason it didn't download completely when saved as a wad. - if(filesize > 0) { - - pfile = fopen(dolpath, "wb");//here we save the txt as a wad - u8 * blockbuffer = new unsigned char[BLOCKSIZE]; - for (s32 i = 0; i < filesize; i += BLOCKSIZE) { - usleep(100); - prTxt.SetTextf("%i%%", (100*i/filesize)+1); - if ((Settings.wsprompt == yes) && (CFG.widescreen)) { - progressbarImg.SetTile(80*i/filesize); - } else { - progressbarImg.SetTile(100*i/filesize); - } - msg2Txt.SetTextf("%iKB/%iKB", i/1024, filesize/1024); - - if(btn1.GetState() == STATE_CLICKED) { - fclose(pfile); - remove(dolpath); - failed = -1; - btn1.ResetState(); - break; - } - - u32 blksize; - blksize = (u32)(filesize - i); - if (blksize > BLOCKSIZE) - blksize = BLOCKSIZE; - - ret = network_read(blockbuffer, blksize); - if (ret != (s32) blksize) { - failed = -1; - ret = -1; - fclose(pfile); - remove(dolpath); - break; - } - fwrite(blockbuffer,1,blksize, pfile); - } - fclose(pfile); - delete blockbuffer; - if(!failed) { - } - }else { - failed = -1; - } + if (IsNetworkInit()) { + msgTxt.SetText(GetNetworkIP()); } else { - ret = -1; + msgTxt.SetText(tr("Could not initialize network!")); } - } else { - WindowPrompt(tr("No new updates."), 0, tr("OK")); - ret = -1; + if (btn1.GetState() == STATE_CLICKED) { + ret = -1; + failed = -1; + btn1.ResetState(); + break; + } } + if (IsNetworkInit() && ret >= 0) { + + int newrev = CheckUpdate(); + + if (newrev > 0) { + FILE * pfile; + sprintf(msg, "Rev%i %s.", newrev, tr("available")); + int choice = WindowPrompt(msg, 0, tr("Update"),tr("Cancel")); + if (choice == 1) { + titleTxt.SetTextf("%s USB Loader GX", tr("Updating")); + msgTxt.SetPosition(0,100); + msgTxt.SetTextf("%s", tr("Updating WiiTDB.zip"));//download the wad but it is saved as a genaric file. + + struct block file = downloadfile(XMLurl); + char xmliconpath[100]; + if (file.data != NULL) { + sprintf(xmliconpath, "%swiitdb.zip", Settings.titlestxt_path); + pfile = fopen(xmliconpath, "wb"); + fwrite(file.data,1,file.size,pfile); + fclose(pfile); + free(file.data); + } + msgTxt.SetTextf("%s", tr("Updating Language Files:")); + updateLanguageFiles(); + promptWindow.Append(&progressbarEmptyImg); + promptWindow.Append(&progressbarImg); + promptWindow.Append(&progressbarOutlineImg); + promptWindow.Append(&prTxt); + msgTxt.SetTextf("%s Rev%i wad.", tr("Downloading"), newrev); + s32 filesize = download_request("http://www.techjawa.com/usbloadergx/ULNR.file");//for some reason it didn't download completely when saved as a wad. + if (filesize > 0) { + + pfile = fopen(dolpath, "wb");//here we save the txt as a wad + u8 * blockbuffer = new unsigned char[BLOCKSIZE]; + for (s32 i = 0; i < filesize; i += BLOCKSIZE) { + usleep(100); + prTxt.SetTextf("%i%%", (100*i/filesize)+1); + if ((Settings.wsprompt == yes) && (CFG.widescreen)) { + progressbarImg.SetTile(80*i/filesize); + } else { + progressbarImg.SetTile(100*i/filesize); + } + msg2Txt.SetTextf("%iKB/%iKB", i/1024, filesize/1024); + + if (btn1.GetState() == STATE_CLICKED) { + fclose(pfile); + remove(dolpath); + failed = -1; + btn1.ResetState(); + break; + } + + u32 blksize; + blksize = (u32)(filesize - i); + if (blksize > BLOCKSIZE) + blksize = BLOCKSIZE; + + ret = network_read(blockbuffer, blksize); + if (ret != (s32) blksize) { + failed = -1; + ret = -1; + fclose(pfile); + remove(dolpath); + break; + } + fwrite(blockbuffer,1,blksize, pfile); + } + fclose(pfile); + delete blockbuffer; + if (!failed) { + } + } else { + failed = -1; + } + } else { + ret = -1; + } + + } else { + WindowPrompt(tr("No new updates."), 0, tr("OK")); + ret = -1; + } + } promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - while(promptWindow.GetEffect() > 0) usleep(50); + while (promptWindow.GetEffect() > 0) usleep(50); - HaltGui(); - mainWindow->Remove(&promptWindow); - //mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); + HaltGui(); + mainWindow->Remove(&promptWindow); + //mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); CloseConnection(); - sleep(1);//sleep 1 because it froze without this for some reason + sleep(1);//sleep 1 because it froze without this for some reason - if(!failed && ret >= 0) { + if (!failed && ret >= 0) { - FILE *wadFile = NULL; - s32 error = 1; - int diarhea = 0; - char nipple[100]; - wadFile = fopen (dolpath ,"rb"); - if (wadFile==NULL)//we can't open the file wad we just downloaded - {sprintf(nipple, tr("Unable to open the wad that was just downloaded (%s)."),dolpath); - WindowPrompt(tr("Error !"), nipple, tr("Ok")); - failed = -1; - } - else{ - //sprintf(nipple, tr("The update wad has been saved as %s. Now let's try to install it."),dolpath); - //WindowPrompt(0,nipple, tr("Ok")); - error = Wad_Install(wadFile); - fclose(wadFile); - if (error==0){ - diarhea = remove(dolpath); - if (diarhea) - WindowPrompt(tr("Success"),tr("The wad file was installed. But It could not be deleted from the SD card."),tr("Ok")); - }else{ - sprintf(nipple, tr("The wad installation failed with error %ld"),error); - WindowPrompt(tr("Error"),nipple,tr("Ok")); - } - } + FILE *wadFile = NULL; + s32 error = 1; + int diarhea = 0; + char nipple[100]; + wadFile = fopen (dolpath ,"rb"); + if (wadFile==NULL) { //we can't open the file wad we just downloaded + sprintf(nipple, tr("Unable to open the wad that was just downloaded (%s)."),dolpath); + WindowPrompt(tr("Error !"), nipple, tr("Ok")); + failed = -1; + } else { + //sprintf(nipple, tr("The update wad has been saved as %s. Now let's try to install it."),dolpath); + //WindowPrompt(0,nipple, tr("Ok")); + error = Wad_Install(wadFile); + fclose(wadFile); + if (error==0) { + diarhea = remove(dolpath); + if (diarhea) + WindowPrompt(tr("Success"),tr("The wad file was installed. But It could not be deleted from the SD card."),tr("Ok")); + } else { + sprintf(nipple, tr("The wad installation failed with error %ld"),error); + WindowPrompt(tr("Error"),nipple,tr("Ok")); + } + } - if (error) - WindowPrompt(tr("ERROR") , tr("An Error accured"), tr("OK")); - else - WindowPrompt(tr("Successfully Updated") , tr("Restarting..."), 0,0,0,0,150); + if (error) + WindowPrompt(tr("ERROR") , tr("An Error accured"), tr("OK")); + else + WindowPrompt(tr("Successfully Updated") , tr("Restarting..."), 0,0,0,0,150); CloseXMLDatabase(); - ExitGUIThreads(); - ShutdownAudio(); - StopGX(); - WII_Initialize(); - WII_LaunchTitle(TITLE_ID(0x00010001,0x554c4e52)); + ExitGUIThreads(); + ShutdownAudio(); + StopGX(); + WII_Initialize(); + WII_LaunchTitle(TITLE_ID(0x00010001,0x554c4e52)); } - // promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - //while(promptWindow.GetEffect() > 0) usleep(50); + // promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + //while(promptWindow.GetEffect() > 0) usleep(50); - HaltGui(); - //mainWindow->Remove(&promptWindow); - mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); + HaltGui(); + //mainWindow->Remove(&promptWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); - if(failed != 0) - return failed; + if (failed != 0) + return failed; return 1; } #endif -int CodeDownload(const char *id) -{ +int CodeDownload(const char *id) { int ret = 0; - GuiWindow promptWindow(472,320); - promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - promptWindow.SetPosition(0, -10); + GuiWindow promptWindow(472,320); + promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + promptWindow.SetPosition(0, -10); - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); - GuiImageData dialogBox(imgPath, dialogue_box_png); - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + char imgPath[100]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); + GuiImageData dialogBox(imgPath, dialogue_box_png); + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiImage dialogBoxImg(&dialogBox); - if (Settings.wsprompt == yes){ - dialogBoxImg.SetWidescreen(CFG.widescreen);} + GuiImage dialogBoxImg(&dialogBox); + if (Settings.wsprompt == yes) { + dialogBoxImg.SetWidescreen(CFG.widescreen); + } char title[50]; - sprintf(title, "%s", tr("Code Download")); - GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - titleTxt.SetPosition(0,50); + sprintf(title, "%s", tr("Code Download")); + GuiText titleTxt(title, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + titleTxt.SetPosition(0,50); char msg[50]; sprintf(msg, "%s", tr("Initializing Network")); - GuiText msgTxt(msg, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - msgTxt.SetPosition(0,140); - char msg2[50] = " "; - GuiText msg2Txt(msg2, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - msg2Txt.SetPosition(0, 50); + GuiText msgTxt(msg, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + msgTxt.SetPosition(0,140); + char msg2[50] = " "; + GuiText msg2Txt(msg2, 26, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + msg2Txt.SetPosition(0, 50); - GuiText btn1Txt(tr("Cancel"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn1Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn1Txt.SetWidescreen(CFG.widescreen); - btn1Img.SetWidescreen(CFG.widescreen);} - GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -40, &trigA, &btnSoundOver, &btnClick,1); - btn1.SetLabel(&btn1Txt); - btn1.SetState(STATE_SELECTED); + GuiText btn1Txt(tr("Cancel"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn1Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn1Txt.SetWidescreen(CFG.widescreen); + btn1Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -40, &trigA, &btnSoundOver, &btnClick,1); + btn1.SetLabel(&btn1Txt); + btn1.SetState(STATE_SELECTED); - promptWindow.Append(&dialogBoxImg); - promptWindow.Append(&titleTxt); - promptWindow.Append(&msgTxt); - promptWindow.Append(&msg2Txt); - promptWindow.Append(&btn1); + promptWindow.Append(&dialogBoxImg); + promptWindow.Append(&titleTxt); + promptWindow.Append(&msgTxt); + promptWindow.Append(&msg2Txt); + promptWindow.Append(&btn1); - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&promptWindow); - mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); struct stat st; - if(stat(Settings.TxtCheatcodespath, &st) != 0) { - if(subfoldercreate(Settings.TxtCheatcodespath) != 1) { - WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); - ret = -1; - goto exit; + if (stat(Settings.TxtCheatcodespath, &st) != 0) { + if (subfoldercreate(Settings.TxtCheatcodespath) != 1) { + WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); + ret = -1; + goto exit; } } - while (!IsNetworkInit()) { + while (!IsNetworkInit()) { VIDEO_WaitVSync(); Initialize_Network(); - if (IsNetworkInit()) { - msgTxt.SetText(GetNetworkIP()); - } else { - msgTxt.SetText(tr("Could not initialize network!")); - } - if(btn1.GetState() == STATE_CLICKED) { - ret = -1; - btn1.ResetState(); - goto exit; - } - } - - if(IsNetworkInit() && ret >= 0) { - - char txtpath[150]; - snprintf(txtpath, sizeof(txtpath), "%s%s.txt", Settings.TxtCheatcodespath,id); - - char codeurl[150]; - snprintf(codeurl, sizeof(codeurl), "http://usbgecko.com/codes/codes/R/%s.txt",id); - - struct block file = downloadfile(codeurl); - - if (file.size == 333) - { - strcat(codeurl, tr(" is not on the server.")); - - WindowPrompt(tr("Error"),codeurl,tr("Ok")); - ret =-1; - goto exit; - } - - if(file.data != NULL){ - FILE * pfile; - pfile = fopen(txtpath, "wb"); - fwrite(file.data,1,file.size,pfile); - fclose(pfile); - free(file.data); - ret = 1; - strcat(txtpath, tr(" has been Saved. The text has not been verified. Some of the code may not work right with each other. If you experience trouble, open the text in a real text editor for more information.")); - - WindowPrompt(0,txtpath,tr("Ok")); + if (IsNetworkInit()) { + msgTxt.SetText(GetNetworkIP()); + } else { + msgTxt.SetText(tr("Could not initialize network!")); + } + if (btn1.GetState() == STATE_CLICKED) { + ret = -1; + btn1.ResetState(); + goto exit; + } } - else - { - strcat(codeurl, tr(" could not be downloaded.")); - WindowPrompt(tr("Error"),codeurl,tr("Ok")); - ret =-1; - } + if (IsNetworkInit() && ret >= 0) { - CloseConnection(); - } + char txtpath[150]; + snprintf(txtpath, sizeof(txtpath), "%s%s.txt", Settings.TxtCheatcodespath,id); + + char codeurl[150]; + snprintf(codeurl, sizeof(codeurl), "http://usbgecko.com/codes/codes/R/%s.txt",id); + + struct block file = downloadfile(codeurl); + + if (file.size == 333) { + strcat(codeurl, tr(" is not on the server.")); + + WindowPrompt(tr("Error"),codeurl,tr("Ok")); + ret =-1; + goto exit; + } + + if (file.data != NULL) { + FILE * pfile; + pfile = fopen(txtpath, "wb"); + fwrite(file.data,1,file.size,pfile); + fclose(pfile); + free(file.data); + ret = 1; + strcat(txtpath, tr(" has been Saved. The text has not been verified. Some of the code may not work right with each other. If you experience trouble, open the text in a real text editor for more information.")); + + WindowPrompt(0,txtpath,tr("Ok")); + } else { + strcat(codeurl, tr(" could not be downloaded.")); + + WindowPrompt(tr("Error"),codeurl,tr("Ok")); + ret =-1; + } + + CloseConnection(); + } exit: - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - while(promptWindow.GetEffect() > 0) usleep(50); + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + while (promptWindow.GetEffect() > 0) usleep(50); - HaltGui(); - mainWindow->Remove(&promptWindow); - mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); + HaltGui(); + mainWindow->Remove(&promptWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); return ret; } -char * GetMissingFiles() -{ +char * GetMissingFiles() { return (char *) missingFiles; } @@ -3067,43 +3005,43 @@ char * GetMissingFiles() /* get the language setting from the Wii settings and return a language code */ void GetLanguageToLangCode(char *langcode) { - switch(CONF_GetLanguage()){ - case CONF_LANG_JAPANESE: - sprintf(langcode, "JA"); - break; - case CONF_LANG_ENGLISH: - sprintf(langcode, "EN"); - break; - case CONF_LANG_GERMAN: - sprintf(langcode, "DE"); - break; - case CONF_LANG_FRENCH: - sprintf(langcode, "FR"); - break; - case CONF_LANG_SPANISH: - sprintf(langcode, "ES"); - break; - case CONF_LANG_ITALIAN: - sprintf(langcode, "IT"); - break; - case CONF_LANG_DUTCH: - sprintf(langcode, "NL"); - break; - /* - case CONF_LANG_PORTUGUESE: - sprintf(langcode, "PO"); - break; - */ - case CONF_LANG_SIMP_CHINESE: - sprintf(langcode, "EN"); // default to EN for chinese - break; - case CONF_LANG_TRAD_CHINESE: - sprintf(langcode, "EN"); // default to EN for chinese - break; - case CONF_LANG_KOREAN: - sprintf(langcode, "KO"); - break; - } + switch (CONF_GetLanguage()) { + case CONF_LANG_JAPANESE: + sprintf(langcode, "JA"); + break; + case CONF_LANG_ENGLISH: + sprintf(langcode, "EN"); + break; + case CONF_LANG_GERMAN: + sprintf(langcode, "DE"); + break; + case CONF_LANG_FRENCH: + sprintf(langcode, "FR"); + break; + case CONF_LANG_SPANISH: + sprintf(langcode, "ES"); + break; + case CONF_LANG_ITALIAN: + sprintf(langcode, "IT"); + break; + case CONF_LANG_DUTCH: + sprintf(langcode, "NL"); + break; + /* + case CONF_LANG_PORTUGUESE: + sprintf(langcode, "PO"); + break; + */ + case CONF_LANG_SIMP_CHINESE: + sprintf(langcode, "EN"); // default to EN for chinese + break; + case CONF_LANG_TRAD_CHINESE: + sprintf(langcode, "EN"); // default to EN for chinese + break; + case CONF_LANG_KOREAN: + sprintf(langcode, "KO"); + break; + } } /**************************************************************************** @@ -3123,254 +3061,243 @@ void GetLanguageToLangCode(char *langcode) { int HBCWindowPrompt(const char *name, const char *coder, const char *version, - const char *release_date, const char *long_description, const char *iconPath, u64 filesize) -{ - int choice = -1; + const char *release_date, const char *long_description, const char *iconPath, u64 filesize) { + int choice = -1; - GuiWindow promptWindow(472,320); - promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - promptWindow.SetPosition(0, 6); + GuiWindow promptWindow(472,320); + promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + promptWindow.SetPosition(0, 6); - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiTrigger trigB; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); - GuiTrigger trigU; - trigU.SetButtonOnlyTrigger(-1, WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP, PAD_BUTTON_UP); - GuiTrigger trigD; - trigD.SetButtonOnlyTrigger(-1, WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN, PAD_BUTTON_DOWN); + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + GuiTrigger trigU; + trigU.SetButtonOnlyTrigger(-1, WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP, PAD_BUTTON_UP); + GuiTrigger trigD; + trigD.SetButtonOnlyTrigger(-1, WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN, PAD_BUTTON_DOWN); - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[50]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); - GuiImageData dialogBox(imgPath, dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sbg_options.png", CFG.theme_path); - GuiImageData whiteBox(imgPath, bg_options_png); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + char imgPath[50]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path); + GuiImageData dialogBox(imgPath, dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sbg_options.png", CFG.theme_path); + GuiImageData whiteBox(imgPath, bg_options_png); - snprintf(imgPath, sizeof(imgPath), "%sscrollbar.png", CFG.theme_path); - GuiImageData scrollbar(imgPath, scrollbar_png); - GuiImage scrollbarImg(&scrollbar); - scrollbarImg.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); - scrollbarImg.SetPosition(-40, 114); - scrollbarImg.SetSkew(0,0,0,0,0,-120,0,-120); + snprintf(imgPath, sizeof(imgPath), "%sscrollbar.png", CFG.theme_path); + GuiImageData scrollbar(imgPath, scrollbar_png); + GuiImage scrollbarImg(&scrollbar); + scrollbarImg.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); + scrollbarImg.SetPosition(-40, 114); + scrollbarImg.SetSkew(0,0,0,0,0,-120,0,-120); - snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowdown.png", CFG.theme_path); - GuiImageData arrowDown(imgPath, scrollbar_arrowdown_png); - GuiImage arrowDownImg(&arrowDown); - arrowDownImg.SetScale(.8); + snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowdown.png", CFG.theme_path); + GuiImageData arrowDown(imgPath, scrollbar_arrowdown_png); + GuiImage arrowDownImg(&arrowDown); + arrowDownImg.SetScale(.8); - snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowup.png", CFG.theme_path); - GuiImageData arrowUp(imgPath, scrollbar_arrowup_png); - GuiImage arrowUpImg (&arrowUp); - arrowUpImg.SetScale(.8); + snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowup.png", CFG.theme_path); + GuiImageData arrowUp(imgPath, scrollbar_arrowup_png); + GuiImage arrowUpImg (&arrowUp); + arrowUpImg.SetScale(.8); - GuiButton arrowUpBtn(arrowUpImg.GetWidth(), arrowUpImg.GetHeight()); - arrowUpBtn.SetImage(&arrowUpImg); - arrowUpBtn.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); - arrowUpBtn.SetPosition(-25,91); - arrowUpBtn.SetTrigger(&trigA); - arrowUpBtn.SetTrigger(&trigU); - arrowUpBtn.SetEffectOnOver(EFFECT_SCALE, 50, 130); - arrowUpBtn.SetSoundClick(&btnClick); + GuiButton arrowUpBtn(arrowUpImg.GetWidth(), arrowUpImg.GetHeight()); + arrowUpBtn.SetImage(&arrowUpImg); + arrowUpBtn.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); + arrowUpBtn.SetPosition(-25,91); + arrowUpBtn.SetTrigger(&trigA); + arrowUpBtn.SetTrigger(&trigU); + arrowUpBtn.SetEffectOnOver(EFFECT_SCALE, 50, 130); + arrowUpBtn.SetSoundClick(&btnClick); - GuiButton arrowDownBtn(arrowDownImg.GetWidth(), arrowDownImg.GetHeight()); - arrowDownBtn.SetImage(&arrowDownImg); - arrowDownBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); - arrowDownBtn.SetPosition(-25,-27); - arrowDownBtn.SetTrigger(&trigA); - arrowDownBtn.SetTrigger(&trigD); - arrowDownBtn.SetEffectOnOver(EFFECT_SCALE, 50, 130); - arrowDownBtn.SetSoundClick(&btnClick); + GuiButton arrowDownBtn(arrowDownImg.GetWidth(), arrowDownImg.GetHeight()); + arrowDownBtn.SetImage(&arrowDownImg); + arrowDownBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); + arrowDownBtn.SetPosition(-25,-27); + arrowDownBtn.SetTrigger(&trigA); + arrowDownBtn.SetTrigger(&trigD); + arrowDownBtn.SetEffectOnOver(EFFECT_SCALE, 50, 130); + arrowDownBtn.SetSoundClick(&btnClick); - GuiImageData *iconData =NULL; - GuiImage *iconImg =NULL; - snprintf(imgPath, sizeof(imgPath), "%s", iconPath); + GuiImageData *iconData =NULL; + GuiImage *iconImg =NULL; + snprintf(imgPath, sizeof(imgPath), "%s", iconPath); - bool iconExist = checkfile(imgPath); - if (iconExist){ - iconData = new GuiImageData (iconPath, dialogue_box_png); - iconImg = new GuiImage (iconData); - iconImg->SetAlignment(ALIGN_LEFT, ALIGN_TOP); - iconImg->SetPosition(45,10); - } + bool iconExist = checkfile(imgPath); + if (iconExist) { + iconData = new GuiImageData (iconPath, dialogue_box_png); + iconImg = new GuiImage (iconData); + iconImg->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + iconImg->SetPosition(45,10); + } - GuiImage dialogBoxImg(&dialogBox); - dialogBoxImg.SetSkew(0,-80,0,-80,0,50,0,50); + GuiImage dialogBoxImg(&dialogBox); + dialogBoxImg.SetSkew(0,-80,0,-80,0,50,0,50); - GuiImage whiteBoxImg(&whiteBox); - whiteBoxImg.SetPosition(0,110); - whiteBoxImg.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - whiteBoxImg.SetSkew(0,0,0,0,0,-120,0,-120); - /*if (Settings.wsprompt == yes){ - dialogBoxImg.SetWidescreen(CFG.widescreen); - }*/ + GuiImage whiteBoxImg(&whiteBox); + whiteBoxImg.SetPosition(0,110); + whiteBoxImg.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + whiteBoxImg.SetSkew(0,0,0,0,0,-120,0,-120); + /*if (Settings.wsprompt == yes){ + dialogBoxImg.SetWidescreen(CFG.widescreen); + }*/ - char tmp[510]; + char tmp[510]; - GuiText nameTxt(name,30 , (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - nameTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - nameTxt.SetPosition(0,-15); - nameTxt.SetMaxWidth(430, GuiText::SCROLL); + GuiText nameTxt(name,30 , (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + nameTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + nameTxt.SetPosition(0,-15); + nameTxt.SetMaxWidth(430, GuiText::SCROLL); - if (strcmp(coder,"")) - snprintf(tmp, sizeof(tmp), tr("Coded by: %s"),coder); - GuiText coderTxt(tmp, 16, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - coderTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - coderTxt.SetPosition(180,30); - coderTxt.SetMaxWidth(280); + if (strcmp(coder,"")) + snprintf(tmp, sizeof(tmp), tr("Coded by: %s"),coder); + GuiText coderTxt(tmp, 16, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255} ); + coderTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + coderTxt.SetPosition(180,30); + coderTxt.SetMaxWidth(280); - if (strcmp(version,"")) - snprintf(tmp, sizeof(tmp), tr("Version: %s"),version); - GuiText versionTxt(tmp,16 , (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - versionTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - versionTxt.SetPosition(40,65); - versionTxt.SetMaxWidth(430); + if (strcmp(version,"")) + snprintf(tmp, sizeof(tmp), tr("Version: %s"),version); + GuiText versionTxt(tmp,16 , (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + versionTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + versionTxt.SetPosition(40,65); + versionTxt.SetMaxWidth(430); - //if (release_date) - //snprintf(tmp, sizeof(tmp), tr("Released: %s"),release_date); - GuiText release_dateTxt(release_date,16 , (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - release_dateTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - release_dateTxt.SetPosition(40,85); - release_dateTxt.SetMaxWidth(430); + //if (release_date) + //snprintf(tmp, sizeof(tmp), tr("Released: %s"),release_date); + GuiText release_dateTxt(release_date,16 , (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + release_dateTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + release_dateTxt.SetPosition(40,85); + release_dateTxt.SetMaxWidth(430); - int pagesize = 6; - GuiText long_descriptionTxt(long_description, 20, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - long_descriptionTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - long_descriptionTxt.SetPosition(46,117); - long_descriptionTxt.SetMaxWidth(360); - long_descriptionTxt.SetNumLines(pagesize); + int pagesize = 6; + GuiText long_descriptionTxt(long_description, 20, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + long_descriptionTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + long_descriptionTxt.SetPosition(46,117); + long_descriptionTxt.SetMaxWidth(360); + long_descriptionTxt.SetNumLines(pagesize); - //convert filesize from u64 to char and put unit of measurement after it - char temp2[7]; - char filesizeCH[15]; - f32 sizeAdjusted; - if(filesize<=1024.0) - { - sizeAdjusted = filesize; - snprintf(temp2, sizeof(temp2), "%.2f",sizeAdjusted); - snprintf(filesizeCH, sizeof(filesizeCH), "%s B",temp2); + //convert filesize from u64 to char and put unit of measurement after it + char temp2[7]; + char filesizeCH[15]; + f32 sizeAdjusted; + if (filesize<=1024.0) { + sizeAdjusted = filesize; + snprintf(temp2, sizeof(temp2), "%.2f",sizeAdjusted); + snprintf(filesizeCH, sizeof(filesizeCH), "%s B",temp2); - } - if(filesize>1024.0) - { - sizeAdjusted = filesize/1024.0; - snprintf(temp2, sizeof(temp2), "%.2f",sizeAdjusted); - snprintf(filesizeCH, sizeof(filesizeCH), "%s KB",temp2); + } + if (filesize>1024.0) { + sizeAdjusted = filesize/1024.0; + snprintf(temp2, sizeof(temp2), "%.2f",sizeAdjusted); + snprintf(filesizeCH, sizeof(filesizeCH), "%s KB",temp2); - } - if(filesize>1048576.0) - { - sizeAdjusted = filesize/1048576.0; - snprintf(temp2, sizeof(temp2), "%.2f",sizeAdjusted); - snprintf(filesizeCH, sizeof(filesizeCH), "%s MB",temp2); + } + if (filesize>1048576.0) { + sizeAdjusted = filesize/1048576.0; + snprintf(temp2, sizeof(temp2), "%.2f",sizeAdjusted); + snprintf(filesizeCH, sizeof(filesizeCH), "%s MB",temp2); - } - GuiText filesizeTxt(filesizeCH, 16, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - filesizeTxt.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); - filesizeTxt.SetPosition(-40,12); + } + GuiText filesizeTxt(filesizeCH, 16, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + filesizeTxt.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); + filesizeTxt.SetPosition(-40,12); - GuiText btn1Txt(tr("Load"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn1Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn1Txt.SetWidescreen(CFG.widescreen); - btn1Img.SetWidescreen(CFG.widescreen); - } + GuiText btn1Txt(tr("Load"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn1Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn1Txt.SetWidescreen(CFG.widescreen); + btn1Img.SetWidescreen(CFG.widescreen); + } - GuiButton btn1(&btn1Img, &btn1Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1); - btn1.SetLabel(&btn1Txt); - btn1.SetState(STATE_SELECTED); + GuiButton btn1(&btn1Img, &btn1Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1); + btn1.SetLabel(&btn1Txt); + btn1.SetState(STATE_SELECTED); - GuiText btn2Txt(tr("Back"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage btn2Img(&btnOutline); - if (Settings.wsprompt == yes){ - btn2Txt.SetWidescreen(CFG.widescreen); - btn2Img.SetWidescreen(CFG.widescreen); - } - GuiButton btn2(&btn2Img, &btn2Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1); - btn2.SetLabel(&btn2Txt); - btn2.SetTrigger(&trigB); + GuiText btn2Txt(tr("Back"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn2Img(&btnOutline); + if (Settings.wsprompt == yes) { + btn2Txt.SetWidescreen(CFG.widescreen); + btn2Img.SetWidescreen(CFG.widescreen); + } + GuiButton btn2(&btn2Img, &btn2Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1); + btn2.SetLabel(&btn2Txt); + btn2.SetTrigger(&trigB); - btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); - btn1.SetPosition(40, 2); - btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); - btn2.SetPosition(-40, 2); + btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); + btn1.SetPosition(40, 2); + btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); + btn2.SetPosition(-40, 2); - promptWindow.Append(&dialogBoxImg); - if (strcmp(long_description,""))promptWindow.Append(&whiteBoxImg); - if (strcmp(long_description,""))promptWindow.Append(&scrollbarImg); - if (strcmp(long_description,""))promptWindow.Append(&arrowDownBtn); - if (strcmp(long_description,""))promptWindow.Append(&arrowUpBtn); + promptWindow.Append(&dialogBoxImg); + if (strcmp(long_description,""))promptWindow.Append(&whiteBoxImg); + if (strcmp(long_description,""))promptWindow.Append(&scrollbarImg); + if (strcmp(long_description,""))promptWindow.Append(&arrowDownBtn); + if (strcmp(long_description,""))promptWindow.Append(&arrowUpBtn); - if (strcmp(name,""))promptWindow.Append(&nameTxt); - if (strcmp(version,""))promptWindow.Append(&versionTxt); - if (strcmp(coder,""))promptWindow.Append(&coderTxt); - if (strcmp(release_date,""))promptWindow.Append(&release_dateTxt); - if (strcmp(long_description,""))promptWindow.Append(&long_descriptionTxt); - promptWindow.Append(&filesizeTxt); - if (iconExist)promptWindow.Append(iconImg); - promptWindow.Append(&btn1); - promptWindow.Append(&btn2); + if (strcmp(name,""))promptWindow.Append(&nameTxt); + if (strcmp(version,""))promptWindow.Append(&versionTxt); + if (strcmp(coder,""))promptWindow.Append(&coderTxt); + if (strcmp(release_date,""))promptWindow.Append(&release_dateTxt); + if (strcmp(long_description,""))promptWindow.Append(&long_descriptionTxt); + promptWindow.Append(&filesizeTxt); + if (iconExist)promptWindow.Append(iconImg); + promptWindow.Append(&btn1); + promptWindow.Append(&btn2); - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); - HaltGui(); - mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&promptWindow); - mainWindow->ChangeFocus(&promptWindow); - ResumeGui(); + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); - while(choice == -1) - { - VIDEO_WaitVSync(); - if(shutdown == 1) - { - wiilight(0); - Sys_Shutdown(); - } - if(reset == 1) - Sys_Reboot(); - if(btn1.GetState() == STATE_CLICKED) { - choice = 1; - } - else if(btn2.GetState() == STATE_CLICKED) { - choice = 0; - } - else if ((arrowUpBtn.GetState()==STATE_CLICKED||arrowUpBtn.GetState()==STATE_HELD) ) - { - if (long_descriptionTxt.GetFirstLine()>1) - long_descriptionTxt.SetFirstLine(long_descriptionTxt.GetFirstLine()-1); - usleep(60000); - if (!((ButtonsHold() & WPAD_BUTTON_UP)||(ButtonsHold() & PAD_BUTTON_UP))) - arrowUpBtn.ResetState(); - } - else if ((arrowDownBtn.GetState()==STATE_CLICKED||arrowDownBtn.GetState()==STATE_HELD) - &&long_descriptionTxt.GetTotalLines()>pagesize - &&long_descriptionTxt.GetFirstLine()-11) + long_descriptionTxt.SetFirstLine(long_descriptionTxt.GetFirstLine()-1); + usleep(60000); + if (!((ButtonsHold() & WPAD_BUTTON_UP)||(ButtonsHold() & PAD_BUTTON_UP))) + arrowUpBtn.ResetState(); + } else if ((arrowDownBtn.GetState()==STATE_CLICKED||arrowDownBtn.GetState()==STATE_HELD) + &&long_descriptionTxt.GetTotalLines()>pagesize + &&long_descriptionTxt.GetFirstLine()-1 0) usleep(50); - HaltGui(); - mainWindow->Remove(&promptWindow); - mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); - return choice; + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + while (promptWindow.GetEffect() > 0) usleep(50); + HaltGui(); + mainWindow->Remove(&promptWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); + return choice; } diff --git a/source/prompts/PromptWindows.h b/source/prompts/PromptWindows.h index 16e24369..6cb525c5 100644 --- a/source/prompts/PromptWindows.h +++ b/source/prompts/PromptWindows.h @@ -12,8 +12,8 @@ #define NOTFULLCHANNEL int WindowPrompt(const char *title, const char *msg = NULL, const char *btn1Label = NULL, - const char *btn2Label = NULL, const char *btn3Label = NULL, - const char *btn4Label = NULL, int wait = -1); + const char *btn2Label = NULL, const char *btn3Label = NULL, + const char *btn4Label = NULL, int wait = -1); void WindowCredits(); int OnScreenKeyboard(char * var, u32 maxlen, int min); @@ -30,8 +30,8 @@ int WindowScreensaver(); int CodeDownload(const char *id); void GetLanguageToLangCode(char *langcode); int HBCWindowPrompt(const char *name, const char *coder, const char *version, - const char *release_date, const char *long_description, - const char *iconPath, u64 filesize); + const char *release_date, const char *long_description, + const char *iconPath, u64 filesize); #endif diff --git a/source/prompts/TitleBrowser.cpp b/source/prompts/TitleBrowser.cpp index 30ddbd57..e1488281 100644 --- a/source/prompts/TitleBrowser.cpp +++ b/source/prompts/TitleBrowser.cpp @@ -32,353 +32,336 @@ 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); - u32 num_sys_titles; - u32 sys_titles[10] ATTRIBUTE_ALIGN(32); - s32 ret = -1; - int numtitle;//to get rid of a stupid compile wrning - //open the database file - FILE *f; - char path[100]; - - ISFS_Initialize(); - - sprintf(path,"%s/config/database.txt",bootDevice); - f = fopen(path, "r"); - - // Get count of titles of our requested type - ret = getTitles_TypeCount(type, &num_titles); - 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){ - //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){ - //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){ - //printf("\tError! Can't get list of titles! (ret = %d)\n", ret); - //exit(1); - } - - - //this array will hold all the names for the titles so we only have to get them one time - char name[num_titles+num_sys_titles][50]; - - customOptionList options3(num_titles+num_sys_titles+1); - //write the titles on the option browser - u32 i = 0; - - + u32 num_titles; + u32 titles[100] ATTRIBUTE_ALIGN(32); + u32 num_sys_titles; + u32 sys_titles[10] ATTRIBUTE_ALIGN(32); + s32 ret = -1; + int numtitle;//to get rid of a stupid compile wrning + //open the database file + FILE *f; + char path[100]; - //first add the good stuff - while (i < num_titles){ - //start from the beginning of the file each loop - if (f)rewind(f); - //char name[50]; - char text[15]; - strcpy(name[i],"");//make sure name is empty - u8 found=0; - //set the title's name, number, ID to text - sprintf(text, "%s", titleText(type, titles[i])); - - //get name from database cause i dont like the ADT function - char line[200]; - char tmp[50]; - snprintf(tmp,50,tmp," "); - //snprintf(name[i],sizeof(name[i]),"Unknown Title"); + ISFS_Initialize(); - if(f) - { - while (fgets(line, sizeof(line), f)) { - if (line[0]== text[0]&& - line[1]== text[1]&& - line[2]== text[2]) - { int j=0; - found=1; - for(j=0;(line[j+4]!='\0' || j<51);j++) - - tmp[j]=line[j+4]; - snprintf(name[i],sizeof(name[i]),"%s",tmp); - //break; - } - } - } - if(!found) - { - if (getName00(name[i], TITLE_ID(type, titles[i]),CONF_GetLanguage()*2)>=0) - found=2; - - if(!found) - { - if (getNameBN(name[i], TITLE_ID(type, titles[i]))>=0) - found=3; - - if(!found) - snprintf(name[i],sizeof(name[i]),"Unknown Title (%08x)",titles[i]); - } - } - - //set the text to the option browser - options3.SetName(i, "%s",text); - options3.SetValue(i, "%s",name[i]); - //options3.SetValue(i, " (%08x) %s",titles[i],name[i]);//use this line to show the number to call to launch the channel - //move on to the next title - i++; - } - - // now add the crappy system titles - while (i < num_titles+num_sys_titles){ - //start from the beginning of the file each loop - if (f)rewind(f); - //char name[50]; - char text[15]; - strcpy(name[i],"");//make sure name is empty - u8 found=0; - //set the title's name, number, ID to text - sprintf(text, "%s", titleText(0x00010002, sys_titles[i-num_titles])); - - //get name from database cause i dont like the ADT function - char line[200]; - char tmp[50]; - snprintf(tmp,50,tmp," "); - //snprintf(name[i],sizeof(name[i]),"Unknown Title"); - if(f) - { - while (fgets(line, sizeof(line), f)) { - if (line[0]== text[0]&& - line[1]== text[1]&& - line[2]== text[2]) - { int j=0; - found=1; - for(j=0;(line[j+4]!='\0' || j<51);j++) - - tmp[j]=line[j+4]; - snprintf(name[i],sizeof(name[i]),"%s",tmp); - break; - } - } - } - if(!found) - { - if (getName00(name[i], TITLE_ID(0x00010002, sys_titles[i-num_titles]))>=0) - found=2; - - if(!found) - { - if (getNameBN(name[i], TITLE_ID(0x00010002, sys_titles[i-num_titles]))>=0) - found=3; - - if(!found) - snprintf(name[i],sizeof(name[i]),"Unknown Title (%08x)",sys_titles[i-num_titles]); - } - } - - //set the text to the option browser - options3.SetName(i, "%s",text); - options3.SetValue(i, "%s",name[i]); - //options3.SetValue(i, " (%08x) %s",titles[i],name[i]);//use this line to show the number to call to launch the channel - //move on to the next title - 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 - fclose(f); - - //get rid of our footprints in there - Uninstall_FromTitle(TITLE_ID(1, 0)); - ISFS_Deinitialize(); - bool exit = false; + sprintf(path,"%s/config/database.txt",bootDevice); + f = fopen(path, "r"); - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + // Get count of titles of our requested type + ret = getTitles_TypeCount(type, &num_titles); + if (ret < 0) { + //printf("\tError! Can't get count of titles! (ret = %d)\n", ret); + //exit(1); + } - char imgPath[100]; + // Get titles of our requested type + ret = getTitles_Type(type, titles, num_titles); + if (ret < 0) { + //printf("\tError! Can't get list of titles! (ret = %d)\n", ret); + //exit(1); + } - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sgamesettings_background.png", CFG.theme_path); - GuiImageData settingsbg(imgPath, settings_background_png); + // Get count of system titles + ret = getTitles_TypeCount(0x00010002, &num_sys_titles); + 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) { + //printf("\tError! Can't get list of titles! (ret = %d)\n", ret); + //exit(1); + } + + + //this array will hold all the names for the titles so we only have to get them one time + char name[num_titles+num_sys_titles][50]; + + customOptionList options3(num_titles+num_sys_titles+1); + //write the titles on the option browser + u32 i = 0; + + + + //first add the good stuff + while (i < num_titles) { + //start from the beginning of the file each loop + if (f)rewind(f); + //char name[50]; + char text[15]; + strcpy(name[i],"");//make sure name is empty + u8 found=0; + //set the title's name, number, ID to text + sprintf(text, "%s", titleText(type, titles[i])); + + //get name from database cause i dont like the ADT function + char line[200]; + char tmp[50]; + snprintf(tmp,50,tmp," "); + //snprintf(name[i],sizeof(name[i]),"Unknown Title"); + + if (f) { + while (fgets(line, sizeof(line), f)) { + if (line[0]== text[0]&& + line[1]== text[1]&& + line[2]== text[2]) { + int j=0; + found=1; + for (j=0;(line[j+4]!='\0' || j<51);j++) + + tmp[j]=line[j+4]; + snprintf(name[i],sizeof(name[i]),"%s",tmp); + //break; + } + } + } + if (!found) { + if (getName00(name[i], TITLE_ID(type, titles[i]),CONF_GetLanguage()*2)>=0) + found=2; + + if (!found) { + if (getNameBN(name[i], TITLE_ID(type, titles[i]))>=0) + found=3; + + if (!found) + snprintf(name[i],sizeof(name[i]),"Unknown Title (%08x)",titles[i]); + } + } + + //set the text to the option browser + options3.SetName(i, "%s",text); + options3.SetValue(i, "%s",name[i]); + //options3.SetValue(i, " (%08x) %s",titles[i],name[i]);//use this line to show the number to call to launch the channel + //move on to the next title + i++; + } + + // now add the crappy system titles + while (i < num_titles+num_sys_titles) { + //start from the beginning of the file each loop + if (f)rewind(f); + //char name[50]; + char text[15]; + strcpy(name[i],"");//make sure name is empty + u8 found=0; + //set the title's name, number, ID to text + sprintf(text, "%s", titleText(0x00010002, sys_titles[i-num_titles])); + + //get name from database cause i dont like the ADT function + char line[200]; + char tmp[50]; + snprintf(tmp,50,tmp," "); + //snprintf(name[i],sizeof(name[i]),"Unknown Title"); + if (f) { + while (fgets(line, sizeof(line), f)) { + if (line[0]== text[0]&& + line[1]== text[1]&& + line[2]== text[2]) { + int j=0; + found=1; + for (j=0;(line[j+4]!='\0' || j<51);j++) + + tmp[j]=line[j+4]; + snprintf(name[i],sizeof(name[i]),"%s",tmp); + break; + } + } + } + if (!found) { + if (getName00(name[i], TITLE_ID(0x00010002, sys_titles[i-num_titles]))>=0) + found=2; + + if (!found) { + if (getNameBN(name[i], TITLE_ID(0x00010002, sys_titles[i-num_titles]))>=0) + found=3; + + if (!found) + snprintf(name[i],sizeof(name[i]),"Unknown Title (%08x)",sys_titles[i-num_titles]); + } + } + + //set the text to the option browser + options3.SetName(i, "%s",text); + options3.SetValue(i, "%s",name[i]); + //options3.SetValue(i, " (%08x) %s",titles[i],name[i]);//use this line to show the number to call to launch the channel + //move on to the next title + 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 + fclose(f); + + //get rid of our footprints in there + Uninstall_FromTitle(TITLE_ID(1, 0)); + ISFS_Deinitialize(); + bool exit = false; + + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + + char imgPath[100]; + + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sgamesettings_background.png", CFG.theme_path); + GuiImageData settingsbg(imgPath, settings_background_png); GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); - GuiTrigger trigB; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); + 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}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - titleTxt.SetPosition(12,40); - titleTxt.SetMaxWidth(356, GuiText::SCROLL); + 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); - GuiImage settingsbackground(&settingsbg); - GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight()); - settingsbackgroundbtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - settingsbackgroundbtn.SetPosition(0, 0); - settingsbackgroundbtn.SetImage(&settingsbackground); + GuiImage settingsbackground(&settingsbg); + GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight()); + settingsbackgroundbtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + settingsbackgroundbtn.SetPosition(0, 0); + settingsbackgroundbtn.SetImage(&settingsbackground); - 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){ + 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) { cancelBtnTxt.SetWidescreen(CFG.widescreen); cancelBtnImg.SetWidescreen(CFG.widescreen); } - GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, &btnClick,1); - cancelBtn.SetScale(0.9); - cancelBtn.SetLabel(&cancelBtnTxt); - cancelBtn.SetTrigger(&trigB); + GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, &btnClick,1); + cancelBtn.SetScale(0.9); + cancelBtn.SetLabel(&cancelBtnTxt); + cancelBtn.SetTrigger(&trigB); - u8 scrollbaron = 0; - if(num_titles > 9) + u8 scrollbaron = 0; + 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); - optionBrowser3.SetPosition(0, 90); - optionBrowser3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - - HaltGui(); - GuiWindow w(screenwidth, screenheight); - w.Append(&settingsbackgroundbtn); + 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); + optionBrowser3.SetPosition(0, 90); + optionBrowser3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + + HaltGui(); + GuiWindow w(screenwidth, screenheight); + w.Append(&settingsbackgroundbtn); w.Append(&titleTxt); - w.Append(&cancelBtn); + w.Append(&cancelBtn); w.Append(&optionBrowser3); - mainWindow->Append(&w); + mainWindow->Append(&w); - int tmp=num_titles+num_sys_titles; - ResumeGui(); - numtitle=num_titles; - while(!exit) - { - VIDEO_WaitVSync(); + int tmp=num_titles+num_sys_titles; + ResumeGui(); + numtitle=num_titles; + while (!exit) { + VIDEO_WaitVSync(); - if(shutdown == 1) - Sys_Shutdown(); - if(reset == 1) - Sys_Reboot(); + if (shutdown == 1) + Sys_Shutdown(); + if (reset == 1) + Sys_Reboot(); - ret = optionBrowser3.GetClickedOption(); + ret = optionBrowser3.GetClickedOption(); - 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 -1) {//if a click happened + + //char name[50]; + char text[15]; + if (f)rewind(f); + //strcpy(name,"");//make sure name is empty + + if (retRemove(&w); - ResumeGui(); - - return ret; + if (cancelBtn.GetState() == STATE_CLICKED) { + //break the loop and end the function + exit = true; + ret = -10; + } + } + + fclose(f); + HaltGui(); + mainWindow->Remove(&w); + ResumeGui(); + + return ret; } diff --git a/source/prompts/TitleBrowser.h b/source/prompts/TitleBrowser.h index b6f12793..b436f626 100644 --- a/source/prompts/TitleBrowser.h +++ b/source/prompts/TitleBrowser.h @@ -8,7 +8,7 @@ #ifndef _TITLEBROWSER_H_ #define _TITLEBROWSER_H_ -///opens a window with a custom option browser in it populated with +///opens a window with a custom option browser in it populated with //! type is the type of chnnel to put in the list int TitleBrowser(u32 type); diff --git a/source/prompts/filebrowser.cpp b/source/prompts/filebrowser.cpp index ebb0fd06..8d8feb41 100644 --- a/source/prompts/filebrowser.cpp +++ b/source/prompts/filebrowser.cpp @@ -42,71 +42,61 @@ BROWSERENTRY * browserList = NULL; // list of files/folders in browser * ResetBrowser() * Clears the file browser memory, and allocates one initial entry ***************************************************************************/ -void ResetBrowser() -{ - browser.numEntries = 0; - browser.selIndex = 0; - browser.pageIndex = 0; +void ResetBrowser() { + browser.numEntries = 0; + browser.selIndex = 0; + browser.pageIndex = 0; - // Clear any existing values - if(browserList != NULL) - { - free(browserList); - browserList = NULL; - } - // set aside space for 1 entry - browserList = (BROWSERENTRY *)malloc(sizeof(BROWSERENTRY)); - memset(browserList, 0, sizeof(BROWSERENTRY)); + // Clear any existing values + if (browserList != NULL) { + free(browserList); + browserList = NULL; + } + // set aside space for 1 entry + browserList = (BROWSERENTRY *)malloc(sizeof(BROWSERENTRY)); + memset(browserList, 0, sizeof(BROWSERENTRY)); } /**************************************************************************** * UpdateDirName() * Update curent directory name for file browser ***************************************************************************/ -int UpdateDirName() -{ - int size=0; - char * test; - char temp[1024]; +int UpdateDirName() { + int size=0; + char * test; + char temp[1024]; - /* current directory doesn't change */ - if (strcmp(browserList[browser.selIndex].filename,".") == 0) - { - return 0; - } - /* go up to parent directory */ - else if (strcmp(browserList[browser.selIndex].filename,"..") == 0) - { - /* determine last subdirectory namelength */ - sprintf(temp,"%s",browser.dir); - test = strtok(temp,"/"); - while (test != NULL) - { - size = strlen(test); - test = strtok(NULL,"/"); - } + /* current directory doesn't change */ + if (strcmp(browserList[browser.selIndex].filename,".") == 0) { + return 0; + } + /* go up to parent directory */ + else if (strcmp(browserList[browser.selIndex].filename,"..") == 0) { + /* determine last subdirectory namelength */ + sprintf(temp,"%s",browser.dir); + test = strtok(temp,"/"); + while (test != NULL) { + size = strlen(test); + test = strtok(NULL,"/"); + } - /* remove last subdirectory name */ - size = strlen(browser.dir) - size - 1; - browser.dir[size] = 0; + /* remove last subdirectory name */ + size = strlen(browser.dir) - size - 1; + browser.dir[size] = 0; - return 1; - } - /* Open a directory */ - else - { - /* test new directory namelength */ - 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 - { - return -1; - } - } + return 1; + } + /* Open a directory */ + else { + /* test new directory namelength */ + 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 { + return -1; + } + } } /**************************************************************************** @@ -118,100 +108,95 @@ int UpdateDirName() * * ***************************************************************************/ -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; } - } +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 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 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; - return stricmp(((BROWSERENTRY *)f1)->filename, ((BROWSERENTRY *)f2)->filename); + return stricmp(((BROWSERENTRY *)f1)->filename, ((BROWSERENTRY *)f2)->filename); } /*************************************************************************** * Browse subdirectories **************************************************************************/ int -ParseDirectory() -{ - DIR_ITER *dir = NULL; - char fulldir[MAXPATHLEN]; - char filename[MAXPATHLEN]; - struct stat filestat; +ParseDirectory() { + DIR_ITER *dir = NULL; + char fulldir[MAXPATHLEN]; + char filename[MAXPATHLEN]; + struct stat filestat; - // reset browser - ResetBrowser(); + // reset browser + ResetBrowser(); - // open the directory - sprintf(fulldir, "%s%s", browser.rootdir, browser.dir); // add currentDevice to path - dir = diropen(fulldir); + // open the directory + sprintf(fulldir, "%s%s", browser.rootdir, browser.dir); // add currentDevice to path + dir = diropen(fulldir); - // if we can't open the dir, try opening the root dir - if (dir == NULL) - { - sprintf(browser.dir,"/"); - dir = diropen(browser.rootdir); - if (dir == NULL) - { - return -1; - } - } + // if we can't open the dir, try opening the root dir + if (dir == NULL) { + sprintf(browser.dir,"/"); + dir = diropen(browser.rootdir); + if (dir == NULL) { + return -1; + } + } - // index files/folders - int entryNum = 0; + // index files/folders + int entryNum = 0; - while(dirnext(dir,filename,&filestat) == 0) - { - if(strcmp(filename,".") != 0) - { - BROWSERENTRY * newBrowserList = (BROWSERENTRY *)realloc(browserList, (entryNum+1) * sizeof(BROWSERENTRY)); + 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 - { - ResetBrowser(); - entryNum = -1; - break; - } - else - { - browserList = newBrowserList; - } - memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry + if (!newBrowserList) { // failed to allocate required memory + ResetBrowser(); + entryNum = -1; + break; + } else { + browserList = newBrowserList; + } + memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry - strncpy(browserList[entryNum].filename, filename, MAXJOLIET); + strncpy(browserList[entryNum].filename, filename, MAXJOLIET); - if(strcmp(filename,"..") == 0) - { - sprintf(browserList[entryNum].displayname, ".."); - } - else - { - strcpy(browserList[entryNum].displayname, filename); // crop name for display - } + if (strcmp(filename,"..") == 0) { + sprintf(browserList[entryNum].displayname, ".."); + } else { + strcpy(browserList[entryNum].displayname, filename); // crop name for display + } - browserList[entryNum].length = filestat.st_size; - browserList[entryNum].isdir = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir + browserList[entryNum].length = filestat.st_size; + browserList[entryNum].isdir = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir - entryNum++; - } - } + entryNum++; + } + } - // close directory - dirclose(dir); + // close directory + dirclose(dir); - // Sort the file list - qsort(browserList, entryNum, sizeof(BROWSERENTRY), FileSortCallback); + // Sort the file list + qsort(browserList, entryNum, sizeof(BROWSERENTRY), FileSortCallback); - browser.numEntries = entryNum; - return entryNum; + browser.numEntries = entryNum; + return entryNum; } /**************************************************************************** @@ -219,260 +204,240 @@ ParseDirectory() * * Update current directory and set new entry list if directory has changed ***************************************************************************/ -int BrowserChangeFolder() -{ - if(!UpdateDirName()) - return -1; +int BrowserChangeFolder() { + if (!UpdateDirName()) + return -1; - ParseDirectory(); + ParseDirectory(); - return browser.numEntries; + return browser.numEntries; } /**************************************************************************** * BrowseDevice * Displays a list of files on the selected device ***************************************************************************/ -int BrowseDevice(int device) -{ - sprintf(browser.dir, "/"); - switch(device) - { - case SD: - sprintf(browser.rootdir, "SD:"); - break; - case USB: - sprintf(browser.rootdir, "USB:"); - break; - } - ParseDirectory(); // Parse root directory - return browser.numEntries; +int BrowseDevice(int device) { + sprintf(browser.dir, "/"); + switch (device) { + case SD: + sprintf(browser.rootdir, "SD:"); + break; + case USB: + sprintf(browser.rootdir, "USB:"); + break; + } + ParseDirectory(); // Parse root directory + return browser.numEntries; } /**************************************************************************** * MenuBrowseDevice - ***************************************************************************/ - -int BrowseDevice(char * var, int force) -{ + ***************************************************************************/ - int result=-1; - int i; - char currentdir[90]; - int curDivice = -1; - int forced =force; - - if(forced>-1){ - if(BrowseDevice(forced) > 0) - { - curDivice = forced; - goto main; - } - } +int BrowseDevice(char * var, int force) { - else if((!strcasecmp(bootDevice, "USB:"))&&(BrowseDevice(USB) > 0)) - { - curDivice = USB; - goto main; - } - else if((!strcasecmp(bootDevice, "SD:"))&&(BrowseDevice(SD) > 0)) - { - curDivice = SD; - goto main; - } - else { - WindowPrompt(tr("Error"),0,tr("Ok")); - return -1; - } + int result=-1; + int i; + char currentdir[90]; + int curDivice = -1; + int forced =force; + + if (forced>-1) { + if (BrowseDevice(forced) > 0) { + curDivice = forced; + goto main; + } + } + + else if ((!strcasecmp(bootDevice, "USB:"))&&(BrowseDevice(USB) > 0)) { + curDivice = USB; + goto main; + } else if ((!strcasecmp(bootDevice, "SD:"))&&(BrowseDevice(SD) > 0)) { + curDivice = SD; + goto main; + } else { + WindowPrompt(tr("Error"),0,tr("Ok")); + return -1; + } 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; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); - - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + int menu = MENU_NONE; - GuiImageData folderImgData(folder_png); - GuiImage folderImg(&folderImgData); - GuiButton folderBtn(folderImg.GetWidth(), folderImg.GetHeight()); - folderBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - folderBtn.SetPosition(-210, -145); - folderBtn.SetImage(&folderImg); - folderBtn.SetTrigger(&trigA); - folderBtn.SetEffectGrow(); + /* + 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; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); - GuiImageData btnOutline(button_dialogue_box_png); - GuiText ExitBtnTxt("Cancel", 24, (GXColor){0, 0, 0, 255}); - GuiImage ExitBtnImg(&btnOutline); - if (Settings.wsprompt == yes){ - ExitBtnTxt.SetWidescreen(CFG.widescreen); - ExitBtnImg.SetWidescreen(CFG.widescreen); - }GuiButton ExitBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); - ExitBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); - ExitBtn.SetPosition(-55, -35); - ExitBtn.SetLabel(&ExitBtnTxt); - ExitBtn.SetImage(&ExitBtnImg); - ExitBtn.SetTrigger(&trigA); - ExitBtn.SetTrigger(&trigB); - ExitBtn.SetEffectGrow(); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiText usbBtnTxt((curDivice==SD?"USB":"SD"), 24, (GXColor){0, 0, 0, 255}); - GuiImage usbBtnImg(&btnOutline); - if (Settings.wsprompt == yes){ - usbBtnTxt.SetWidescreen(CFG.widescreen); - usbBtnImg.SetWidescreen(CFG.widescreen); - }GuiButton usbBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); - usbBtn.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); - usbBtn.SetPosition(0, -35); - usbBtn.SetLabel(&usbBtnTxt); - usbBtn.SetImage(&usbBtnImg); - usbBtn.SetTrigger(&trigA); - usbBtn.SetEffectGrow(); + GuiImageData folderImgData(folder_png); + GuiImage folderImg(&folderImgData); + GuiButton folderBtn(folderImg.GetWidth(), folderImg.GetHeight()); + folderBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + folderBtn.SetPosition(-210, -145); + folderBtn.SetImage(&folderImg); + folderBtn.SetTrigger(&trigA); + folderBtn.SetEffectGrow(); - GuiText okBtnTxt(tr("Ok"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - GuiImage okBtnImg(&btnOutline); - if (Settings.wsprompt == yes){ - okBtnTxt.SetWidescreen(CFG.widescreen); - okBtnImg.SetWidescreen(CFG.widescreen); - } - GuiButton okBtn(&okBtnImg,&okBtnImg, 0, 4, 45, -35, &trigA, &btnSoundOver, &btnClick,1); - okBtn.SetLabel(&okBtnTxt); - - GuiFileBrowser fileBrowser(396, 248); - fileBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - fileBrowser.SetPosition(0, 120); - - GuiImageData Address(addressbar_textbox_png); - snprintf(currentdir, sizeof(currentdir), "%s%s", browser.rootdir, browser.dir); - 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); - GuiImage AdressbarImg(&Address); - GuiButton Adressbar(Address.GetWidth(), Address.GetHeight()); - Adressbar.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - Adressbar.SetPosition(0, fileBrowser.GetTop()-45); - Adressbar.SetImage(&AdressbarImg); - Adressbar.SetLabel(&AdressText); - - //save var in case they cancel and return it to them - snprintf(currentdir, sizeof(currentdir), "%s", var); - sprintf(var,"%s", browser.rootdir); - - HaltGui(); - GuiWindow w(screenwidth, screenheight); - w.Append(&ExitBtn); + GuiImageData btnOutline(button_dialogue_box_png); + GuiText ExitBtnTxt("Cancel", 24, (GXColor) {0, 0, 0, 255}); + GuiImage ExitBtnImg(&btnOutline); + if (Settings.wsprompt == yes) { + ExitBtnTxt.SetWidescreen(CFG.widescreen); + ExitBtnImg.SetWidescreen(CFG.widescreen); + } + GuiButton ExitBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); + ExitBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); + ExitBtn.SetPosition(-55, -35); + ExitBtn.SetLabel(&ExitBtnTxt); + ExitBtn.SetImage(&ExitBtnImg); + ExitBtn.SetTrigger(&trigA); + ExitBtn.SetTrigger(&trigB); + ExitBtn.SetEffectGrow(); + + GuiText usbBtnTxt((curDivice==SD?"USB":"SD"), 24, (GXColor) {0, 0, 0, 255}); + GuiImage usbBtnImg(&btnOutline); + if (Settings.wsprompt == yes) { + usbBtnTxt.SetWidescreen(CFG.widescreen); + usbBtnImg.SetWidescreen(CFG.widescreen); + } + GuiButton usbBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); + usbBtn.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); + usbBtn.SetPosition(0, -35); + usbBtn.SetLabel(&usbBtnTxt); + usbBtn.SetImage(&usbBtnImg); + usbBtn.SetTrigger(&trigA); + usbBtn.SetEffectGrow(); + + GuiText okBtnTxt(tr("Ok"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage okBtnImg(&btnOutline); + if (Settings.wsprompt == yes) { + okBtnTxt.SetWidescreen(CFG.widescreen); + okBtnImg.SetWidescreen(CFG.widescreen); + } + GuiButton okBtn(&okBtnImg,&okBtnImg, 0, 4, 45, -35, &trigA, &btnSoundOver, &btnClick,1); + okBtn.SetLabel(&okBtnTxt); + + GuiFileBrowser fileBrowser(396, 248); + fileBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + fileBrowser.SetPosition(0, 120); + + GuiImageData Address(addressbar_textbox_png); + snprintf(currentdir, sizeof(currentdir), "%s%s", browser.rootdir, browser.dir); + 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); + GuiImage AdressbarImg(&Address); + GuiButton Adressbar(Address.GetWidth(), Address.GetHeight()); + Adressbar.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + Adressbar.SetPosition(0, fileBrowser.GetTop()-45); + Adressbar.SetImage(&AdressbarImg); + Adressbar.SetLabel(&AdressText); + + //save var in case they cancel and return it to them + snprintf(currentdir, sizeof(currentdir), "%s", var); + sprintf(var,"%s", browser.rootdir); + + HaltGui(); + GuiWindow w(screenwidth, screenheight); + w.Append(&ExitBtn); // w.Append(&titleTxt); - w.Append(&fileBrowser); - w.Append(&Adressbar); - w.Append(&okBtn); - w.Append(&folderBtn); - w.Append(&usbBtn); - mainWindow->Append(&w); - ResumeGui(); + w.Append(&fileBrowser); + w.Append(&Adressbar); + w.Append(&okBtn); + w.Append(&folderBtn); + w.Append(&usbBtn); + mainWindow->Append(&w); + ResumeGui(); - while(menu == MENU_NONE) - { - VIDEO_WaitVSync(); + 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; iGetState() == STATE_CLICKED) - { - fileBrowser.fileList[i]->ResetState(); - // check corresponding browser entry - if(browserList[browser.selIndex].isdir) - { - if(BrowserChangeFolder()) - { - fileBrowser.ResetState(); - fileBrowser.fileList[0]->SetState(STATE_SELECTED); - fileBrowser.TriggerUpdate(); + for (i=0; iGetState() == STATE_CLICKED) { + fileBrowser.fileList[i]->ResetState(); + // check corresponding browser entry + 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;iSetState(STATE_DISABLED); - mainWindow->SetState(STATE_DEFAULT); - } - } - } - - if(ExitBtn.GetState() == STATE_CLICKED) - { - snprintf(var,sizeof(currentdir),"%s", currentdir); - break; - } - if(okBtn.GetState() == STATE_CLICKED) - { - result = 1; - break; - } - 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) - { - HaltGui(); - mainWindow->Remove(&w); - ResumeGui(); - char newfolder[100]; - sprintf(newfolder,"%s/",var); - - int result = OnScreenKeyboard(newfolder,100,0); - if ( result == 1 ) - { - int len = (strlen(newfolder)-1); - if(newfolder[len] !='/') - strncat (newfolder, "/", 1); - - struct stat st; - if(stat(newfolder, &st) != 0) { - if(subfoldercreate(newfolder) != 1) { - WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); - } - } + int len=strlen(browser.rootdir); + for (unsigned int i=len;iSetState(STATE_DISABLED); + mainWindow->SetState(STATE_DEFAULT); + } } - result = BrowseDevice(var, (curDivice==SD?SD:USB)); - break; - } - - } - HaltGui(); - mainWindow->Remove(&w); - ResumeGui(); + } - //} + if (ExitBtn.GetState() == STATE_CLICKED) { + snprintf(var,sizeof(currentdir),"%s", currentdir); + break; + } + if (okBtn.GetState() == STATE_CLICKED) { + result = 1; + break; + } 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) { + HaltGui(); + mainWindow->Remove(&w); + ResumeGui(); + char newfolder[100]; + sprintf(newfolder,"%s/",var); - return result; + int result = OnScreenKeyboard(newfolder,100,0); + if ( result == 1 ) { + int len = (strlen(newfolder)-1); + if (newfolder[len] !='/') + strncat (newfolder, "/", 1); + + struct stat st; + if (stat(newfolder, &st) != 0) { + if (subfoldercreate(newfolder) != 1) { + WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); + } + } + } + result = BrowseDevice(var, (curDivice==SD?SD:USB)); + break; + } + + } + HaltGui(); + mainWindow->Remove(&w); + ResumeGui(); + + //} + + return result; } diff --git a/source/prompts/filebrowser.h b/source/prompts/filebrowser.h index 6036fb1e..07d1c565 100644 --- a/source/prompts/filebrowser.h +++ b/source/prompts/filebrowser.h @@ -1,7 +1,7 @@ /**************************************************************************** * libwiigui Template * Tantric 2009 - * + * * modified by dimok * * filebrowser.h @@ -16,38 +16,36 @@ #include #define MAXJOLIET 255 -#define MAXDISPLAY MAXPATHLEN - - -enum { - SD, - USB -}; +#define MAXDISPLAY MAXPATHLEN -typedef struct -{ - char dir[MAXPATHLEN]; // directory path of browserList - char rootdir[10]; // directory path of browserList - int numEntries; // # of entries in browserList - int selIndex; // currently selected index of browserList - int pageIndex; // starting index of browserList page display + +enum { + SD, + USB +}; + +typedef struct { + char dir[MAXPATHLEN]; // directory path of browserList + char rootdir[10]; // directory path of browserList + int numEntries; // # of entries in browserList + int selIndex; // currently selected index of browserList + int pageIndex; // starting index of browserList page display } BROWSERINFO; -typedef struct -{ - u64 offset; // DVD offset - u64 length; // file length in 64 bytes for sizes higher than 4GB - char isdir; // 0 - file, 1 - directory - char filename[MAXJOLIET + 1]; // full filename - char displayname[MAXDISPLAY + 1]; // name for browser display -} BROWSERENTRY; +typedef struct { + u64 offset; // DVD offset + u64 length; // file length in 64 bytes for sizes higher than 4GB + char isdir; // 0 - file, 1 - directory + char filename[MAXJOLIET + 1]; // full filename + char displayname[MAXDISPLAY + 1]; // name for browser display +} BROWSERENTRY; extern BROWSERINFO browser; extern BROWSERENTRY * browserList; int UpdateDirName(); int FileSortCallback(const void *f1, const void *f2); -void ResetBrowser(); +void ResetBrowser(); int ParseDirectory(); int BrowserChangeFolder(); int BrowseDevice(int device); diff --git a/source/prompts/gameinfo.cpp b/source/prompts/gameinfo.cpp index 5b5ae9f2..81be03fb 100644 --- a/source/prompts/gameinfo.cpp +++ b/source/prompts/gameinfo.cpp @@ -38,891 +38,896 @@ extern void HaltGui(); /**************************************************************************** * gameinfo ***************************************************************************/ -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(); +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) { + 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) { - LoadGameInfoFromXML(ID, Settings.db_language); - //CloseXMLDatabase(); + LoadGameInfoFromXML(ID, Settings.db_language); + //CloseXMLDatabase(); - bool showmeminfo = false; - - int choice=-1; - int titley=10; - int marginY=titley+40; - int indexy = marginY; - int wifiY=0; - int intputX=200, inputY=-30, txtXOffset=90; - u8 nunchuk=0, - classiccontroller=0, - balanceboard=0, - dancepad=0, - guitar=0, - gamecube=0, - wheel=0, - motionplus=0, - drums=0, - microphone=0; - int newline=1; - u8 page=1; - - GuiImageData * playersImgData = NULL; - GuiImage * playersImg = NULL; + bool showmeminfo = false; - GuiImageData * wifiplayersImgData = NULL; - GuiImage * wifiplayersImg = NULL; - GuiImage * ratingImg = NULL; + int choice=-1; + int titley=10; + int marginY=titley+40; + int indexy = marginY; + int wifiY=0; + int intputX=200, inputY=-30, txtXOffset=90; + u8 nunchuk=0, + classiccontroller=0, + balanceboard=0, + dancepad=0, + guitar=0, + gamecube=0, + wheel=0, + motionplus=0, + drums=0, + microphone=0; + int newline=1; + u8 page=1; - GuiImage * classiccontrollerImg = NULL; - GuiImage * nunchukImg = NULL; - GuiImage * guitarImg = NULL; - GuiImage * drumsImg = NULL; - GuiImage * dancepadImg = NULL; - GuiImage * motionplusImg = NULL; - GuiImage * wheelImg = NULL; - GuiImage * balanceboardImg = NULL; - GuiImage * microphoneImg = NULL; - GuiImage * gcImg = NULL; - GuiImage * dialogBoxImg1 = NULL; - GuiImage * dialogBoxImg2 = NULL; - GuiImage * dialogBoxImg3 = NULL; - GuiImage * dialogBoxImg4 = NULL; - GuiImage * dialogBoxImg11 = NULL; - GuiImage * dialogBoxImg22 = NULL; - GuiImage * dialogBoxImg33 = NULL; - GuiImage * dialogBoxImg44 = NULL; - GuiImage * coverImg = NULL; - GuiImage * coverImg2 = NULL; + GuiImageData * playersImgData = NULL; + GuiImage * playersImg = NULL; - GuiImageData * classiccontrollerImgData = NULL; - GuiImageData * nunchukImgData = NULL; - GuiImageData * guitarImgData = NULL; - GuiImageData * drumsImgData = NULL; - GuiImageData * motionplusImgData = NULL; - GuiImageData * wheelImgData = NULL; - GuiImageData * balanceboardImgData = NULL; - GuiImageData * dancepadImgData = NULL; - GuiImageData * microphoneImgData = NULL; - GuiImageData * gamecubeImgData = NULL; - GuiImageData * ratingImgData = NULL; - GuiImageData * cover = NULL; + GuiImageData * wifiplayersImgData = NULL; + GuiImage * wifiplayersImg = NULL; + GuiImage * ratingImg = NULL; - GuiText * releasedTxt = NULL; - GuiText * publisherTxt = NULL; - GuiText * developerTxt = NULL; - GuiText * titleTxt = NULL; - GuiText * synopsisTxt = NULL; - GuiText ** genreTxt = NULL; - GuiText ** wifiTxt = NULL; - GuiText * betaTxt = NULL; - GuiText * beta1Txt = NULL; - GuiText * memTxt = NULL; + GuiImage * classiccontrollerImg = NULL; + GuiImage * nunchukImg = NULL; + GuiImage * guitarImg = NULL; + GuiImage * drumsImg = NULL; + GuiImage * dancepadImg = NULL; + GuiImage * motionplusImg = NULL; + GuiImage * wheelImg = NULL; + GuiImage * balanceboardImg = NULL; + GuiImage * microphoneImg = NULL; + GuiImage * gcImg = NULL; + GuiImage * dialogBoxImg1 = NULL; + GuiImage * dialogBoxImg2 = NULL; + GuiImage * dialogBoxImg3 = NULL; + GuiImage * dialogBoxImg4 = NULL; + GuiImage * dialogBoxImg11 = NULL; + GuiImage * dialogBoxImg22 = NULL; + GuiImage * dialogBoxImg33 = NULL; + GuiImage * dialogBoxImg44 = NULL; + GuiImage * coverImg = NULL; + GuiImage * coverImg2 = NULL; - GuiWindow gameinfoWindow(600,308); - gameinfoWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - gameinfoWindow.SetPosition(0, -50); + GuiImageData * classiccontrollerImgData = NULL; + GuiImageData * nunchukImgData = NULL; + GuiImageData * guitarImgData = NULL; + GuiImageData * drumsImgData = NULL; + GuiImageData * motionplusImgData = NULL; + GuiImageData * wheelImgData = NULL; + GuiImageData * balanceboardImgData = NULL; + GuiImageData * dancepadImgData = NULL; + GuiImageData * microphoneImgData = NULL; + GuiImageData * gamecubeImgData = NULL; + GuiImageData * ratingImgData = NULL; + GuiImageData * cover = NULL; - GuiWindow gameinfoWindow2(600,308); - gameinfoWindow2.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - gameinfoWindow2.SetPosition(0, -50); + GuiText * releasedTxt = NULL; + GuiText * publisherTxt = NULL; + GuiText * developerTxt = NULL; + GuiText * titleTxt = NULL; + GuiText * synopsisTxt = NULL; + GuiText ** genreTxt = NULL; + GuiText ** wifiTxt = NULL; + GuiText * betaTxt = NULL; + GuiText * beta1Txt = NULL; + GuiText * memTxt = NULL; - GuiWindow txtWindow(350,270); - txtWindow.SetAlignment(ALIGN_CENTRE, ALIGN_RIGHT); - txtWindow.SetPosition(95, 55); + GuiWindow gameinfoWindow(600,308); + gameinfoWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + gameinfoWindow.SetPosition(0, -50); - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[50]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%sgameinfo1_png.png", CFG.theme_path); - GuiImageData dialogBox1(imgPath, gameinfo1_png); - snprintf(imgPath, sizeof(imgPath), "%sgameinfo1a_png.png", CFG.theme_path); - GuiImageData dialogBox2(imgPath, gameinfo1a_png); - snprintf(imgPath, sizeof(imgPath), "%sgameinfo2_png.png", CFG.theme_path); - GuiImageData dialogBox3(imgPath, gameinfo2_png); - snprintf(imgPath, sizeof(imgPath), "%sgameinfo2a_png.png", CFG.theme_path); - GuiImageData dialogBox4(imgPath, gameinfo2a_png); + GuiWindow gameinfoWindow2(600,308); + gameinfoWindow2.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + gameinfoWindow2.SetPosition(0, -50); - GuiTrigger trig1; - trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1 | WPAD_CLASSIC_BUTTON_X, 0); - GuiTrigger trigA; - trigA.SetButtonOnlyTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiTrigger trigB; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); - GuiTrigger trigU; - trigU.SetButtonOnlyTrigger(-1, WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP, PAD_BUTTON_UP); - GuiTrigger trigD; - trigD.SetButtonOnlyTrigger(-1, WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN, PAD_BUTTON_DOWN); - GuiTrigger trigH; - trigH.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); - - //buttons for changing between synopsis and other info - GuiButton backBtn(0,0); - backBtn.SetPosition(-20,-20); - backBtn.SetTrigger(&trigB); - gameinfoWindow.Append(&backBtn); + GuiWindow txtWindow(350,270); + txtWindow.SetAlignment(ALIGN_CENTRE, ALIGN_RIGHT); + txtWindow.SetPosition(95, 55); - GuiButton nextBtn(0,0); - nextBtn.SetPosition(20,20); - nextBtn.SetTrigger(&trigA); - gameinfoWindow.Append(&nextBtn); - - //buttons for scrolling the synopsis - GuiButton upBtn(0,0); - upBtn.SetPosition(0,0); - upBtn.SetTrigger(&trigU); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + char imgPath[50]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sgameinfo1_png.png", CFG.theme_path); + GuiImageData dialogBox1(imgPath, gameinfo1_png); + snprintf(imgPath, sizeof(imgPath), "%sgameinfo1a_png.png", CFG.theme_path); + GuiImageData dialogBox2(imgPath, gameinfo1a_png); + snprintf(imgPath, sizeof(imgPath), "%sgameinfo2_png.png", CFG.theme_path); + GuiImageData dialogBox3(imgPath, gameinfo2_png); + snprintf(imgPath, sizeof(imgPath), "%sgameinfo2a_png.png", CFG.theme_path); + GuiImageData dialogBox4(imgPath, gameinfo2a_png); - GuiButton dnBtn(0,0); - dnBtn.SetPosition(0,0); - dnBtn.SetTrigger(&trigD); + GuiTrigger trig1; + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1 | WPAD_CLASSIC_BUTTON_X, 0); + GuiTrigger trigA; + trigA.SetButtonOnlyTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + GuiTrigger trigU; + trigU.SetButtonOnlyTrigger(-1, WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP, PAD_BUTTON_UP); + GuiTrigger trigD; + trigD.SetButtonOnlyTrigger(-1, WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN, PAD_BUTTON_DOWN); + GuiTrigger trigH; + trigH.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); - GuiButton homeBtn(0,0); - homeBtn.SetPosition(0,0); - homeBtn.SetTrigger(&trigH); + //buttons for changing between synopsis and other info + GuiButton backBtn(0,0); + backBtn.SetPosition(-20,-20); + backBtn.SetTrigger(&trigB); + gameinfoWindow.Append(&backBtn); - // button to save the url for the zip file for poor people without wifi - GuiButton urlBtn(0,0); - urlBtn.SetPosition(0,0); - urlBtn.SetTrigger(&trig1); - gameinfoWindow.Append(&urlBtn); + GuiButton nextBtn(0,0); + nextBtn.SetPosition(20,20); + nextBtn.SetTrigger(&trigA); + gameinfoWindow.Append(&nextBtn); - char linebuf[3000] = ""; - char linebuf2[100] = ""; + //buttons for scrolling the synopsis + GuiButton upBtn(0,0); + upBtn.SetPosition(0,0); + upBtn.SetTrigger(&trigU); - // enable icons for required accessories - for (int i=1;i<=XML_ELEMMAX;i++) - { - if (strcmp(gameinfo.accessoriesReq[i],"classiccontroller")==0) - classiccontroller=1; - if (strcmp(gameinfo.accessoriesReq[i],"nunchuk")==0) - nunchuk=1; - if (strcmp(gameinfo.accessoriesReq[i],"guitar")==0) - guitar=1; - if (strcmp(gameinfo.accessoriesReq[i],"drums")==0) - drums=1; - if (strcmp(gameinfo.accessoriesReq[i],"dancepad")==0) - dancepad=1; - if (strcmp(gameinfo.accessoriesReq[i],"motionplus")==0) - motionplus=1; - if (strcmp(gameinfo.accessoriesReq[i],"wheel")==0) - wheel=1; - if (strcmp(gameinfo.accessoriesReq[i],"balanceboard")==0) - balanceboard=1; - if (strcmp(gameinfo.accessoriesReq[i],"microphone")==0) - microphone=1; - if (strcmp(gameinfo.accessoriesReq[i],"gamecube")==0) - gamecube=1; - } - - // switch icons - if (nunchuk) nunchukImgData = new GuiImageData(nunchukR_png); - else nunchukImgData = new GuiImageData(nunchuk_png); - - if (classiccontroller) classiccontrollerImgData = new GuiImageData(classiccontrollerR_png); - else classiccontrollerImgData = new GuiImageData(classiccontroller_png); - - if (guitar) guitarImgData = new GuiImageData(guitarR_png); - else guitarImgData = new GuiImageData(guitar_png); - - if (gamecube) gamecubeImgData = new GuiImageData(gcncontrollerR_png); - else gamecubeImgData = new GuiImageData(gcncontroller_png); - - if (wheel) wheelImgData = new GuiImageData(wheelR_png); - else wheelImgData = new GuiImageData(wheel_png); - - if (motionplus) motionplusImgData = new GuiImageData(motionplusR_png); - else motionplusImgData = new GuiImageData(motionplus_png); - - if (drums) drumsImgData = new GuiImageData(drumsR_png); - else drumsImgData = new GuiImageData(drums_png); - - if (microphone) microphoneImgData = new GuiImageData(microphoneR_png); - else microphoneImgData = new GuiImageData(microphone_png); - - if (balanceboard) balanceboardImgData = new GuiImageData(balanceboardR_png); - else balanceboardImgData = new GuiImageData(balanceboard_png); - - if (dancepad) dancepadImgData = new GuiImageData(dancepadR_png); - else dancepadImgData = new GuiImageData(dancepad_png); + GuiButton dnBtn(0,0); + dnBtn.SetPosition(0,0); + dnBtn.SetTrigger(&trigD); - // look for optional accessories - for (int i=1;i<=XML_ELEMMAX;i++) - { - if (strcmp(gameinfo.accessories[i],"classiccontroller")==0) - classiccontroller=1; - if (strcmp(gameinfo.accessories[i],"nunchuk")==0) - nunchuk=1; - if (strcmp(gameinfo.accessories[i],"guitar")==0) - guitar=1; - if (strcmp(gameinfo.accessories[i],"drums")==0) - drums=1; - if (strcmp(gameinfo.accessories[i],"dancepad")==0) - dancepad=1; - if (strcmp(gameinfo.accessories[i],"motionplus")==0) - motionplus=1; - if (strcmp(gameinfo.accessories[i],"wheel")==0) - wheel=1; - if (strcmp(gameinfo.accessories[i],"balanceboard")==0) - balanceboard=1; - if (strcmp(gameinfo.accessories[i],"microphone")==0) - microphone=1; - if (strcmp(gameinfo.accessories[i],"gamecube")==0) - gamecube=1; - } + GuiButton homeBtn(0,0); + homeBtn.SetPosition(0,0); + homeBtn.SetTrigger(&trigH); - dialogBoxImg1 = new GuiImage(&dialogBox1); - dialogBoxImg1->SetAlignment(0,3); - dialogBoxImg1->SetPosition(-9,0); + // button to save the url for the zip file for poor people without wifi + GuiButton urlBtn(0,0); + urlBtn.SetPosition(0,0); + urlBtn.SetTrigger(&trig1); + gameinfoWindow.Append(&urlBtn); - dialogBoxImg2 = new GuiImage(&dialogBox2); - dialogBoxImg2->SetAlignment(0,3); - dialogBoxImg2->SetPosition(145,0); + char linebuf[3000] = ""; + char linebuf2[100] = ""; - dialogBoxImg3 = new GuiImage(&dialogBox3); - dialogBoxImg3->SetAlignment(0,3); - dialogBoxImg3->SetPosition(301,0); + // enable icons for required accessories + for (int i=1;i<=XML_ELEMMAX;i++) { + if (strcmp(gameinfo.accessoriesReq[i],"classiccontroller")==0) + classiccontroller=1; + if (strcmp(gameinfo.accessoriesReq[i],"nunchuk")==0) + nunchuk=1; + if (strcmp(gameinfo.accessoriesReq[i],"guitar")==0) + guitar=1; + if (strcmp(gameinfo.accessoriesReq[i],"drums")==0) + drums=1; + if (strcmp(gameinfo.accessoriesReq[i],"dancepad")==0) + dancepad=1; + if (strcmp(gameinfo.accessoriesReq[i],"motionplus")==0) + motionplus=1; + if (strcmp(gameinfo.accessoriesReq[i],"wheel")==0) + wheel=1; + if (strcmp(gameinfo.accessoriesReq[i],"balanceboard")==0) + balanceboard=1; + if (strcmp(gameinfo.accessoriesReq[i],"microphone")==0) + microphone=1; + if (strcmp(gameinfo.accessoriesReq[i],"gamecube")==0) + gamecube=1; + } - dialogBoxImg4 = new GuiImage(&dialogBox4); - dialogBoxImg4->SetAlignment(0,3); - dialogBoxImg4->SetPosition(457,0); + // switch icons + if (nunchuk) nunchukImgData = new GuiImageData(nunchukR_png); + else nunchukImgData = new GuiImageData(nunchuk_png); - gameinfoWindow.Append(dialogBoxImg1); - gameinfoWindow.Append(dialogBoxImg2); - gameinfoWindow.Append(dialogBoxImg3); - gameinfoWindow.Append(dialogBoxImg4); + if (classiccontroller) classiccontrollerImgData = new GuiImageData(classiccontrollerR_png); + else classiccontrollerImgData = new GuiImageData(classiccontroller_png); - snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID); - cover = new GuiImageData(imgPath, 0); //load full id image - if (!cover->GetImage()) { - delete cover; - snprintf(imgPath, sizeof(imgPath), "%snoimage.png", Settings.covers_path); - cover = new GuiImageData(imgPath, nocover_png); //load no image - } - delete coverImg; - coverImg = NULL; + if (guitar) guitarImgData = new GuiImageData(guitarR_png); + else guitarImgData = new GuiImageData(guitar_png); - coverImg = new GuiImage(cover); - coverImg->SetWidescreen(CFG.widescreen); - coverImg->SetPosition(15,30); - gameinfoWindow.Append(coverImg); + if (gamecube) gamecubeImgData = new GuiImageData(gcncontrollerR_png); + else gamecubeImgData = new GuiImageData(gcncontroller_png); - // # of players - if (strcmp(gameinfo.players,"") != 0) { - playersImgData = new GuiImageData(Wiimote1_png); - if (atoi(gameinfo.players)>1){ - playersImgData= new GuiImageData(Wiimote2_png); - } - if (atoi(gameinfo.players)>2){ - playersImgData= new GuiImageData(Wiimote4_png); - } + if (wheel) wheelImgData = new GuiImageData(wheelR_png); + else wheelImgData = new GuiImageData(wheel_png); - playersImg = new GuiImage(playersImgData); - playersImg->SetWidescreen(CFG.widescreen); - playersImg->SetPosition(intputX , inputY); - playersImg->SetAlignment(0,4); - gameinfoWindow.Append(playersImg); - intputX += (CFG.widescreen ? playersImg->GetWidth() * .8 : playersImg->GetWidth())+5; - } + if (motionplus) motionplusImgData = new GuiImageData(motionplusR_png); + else motionplusImgData = new GuiImageData(motionplus_png); - //draw the input types for this game - if (motionplus==1){ - motionplusImg = new GuiImage(motionplusImgData); - motionplusImg->SetWidescreen(CFG.widescreen); - motionplusImg->SetPosition(intputX , inputY); - motionplusImg->SetAlignment(0,4); - gameinfoWindow.Append(motionplusImg); - intputX += (CFG.widescreen ? motionplusImg->GetWidth() * .8 : motionplusImg->GetWidth())+5; - } - if (nunchuk==1){ - nunchukImg = new GuiImage(nunchukImgData); - nunchukImg->SetWidescreen(CFG.widescreen); - nunchukImg->SetPosition(intputX , inputY); - nunchukImg->SetAlignment(0,4); - gameinfoWindow.Append(nunchukImg); - intputX += (CFG.widescreen ? nunchukImg->GetWidth() * .8 : nunchukImg->GetWidth())+5; - } - if (classiccontroller==1){ - classiccontrollerImg = new GuiImage(classiccontrollerImgData); - classiccontrollerImg->SetWidescreen(CFG.widescreen); - classiccontrollerImg->SetPosition(intputX , inputY); - classiccontrollerImg->SetAlignment(0,4); - gameinfoWindow.Append(classiccontrollerImg); - intputX += (CFG.widescreen ? classiccontrollerImg->GetWidth() * .8 : classiccontrollerImg->GetWidth())+5; - } - if (gamecube==1){ - gcImg = new GuiImage(gamecubeImgData); - gcImg->SetWidescreen(CFG.widescreen); - gcImg->SetPosition(intputX , inputY); - gcImg->SetAlignment(0,4); - gameinfoWindow.Append(gcImg); - intputX += (CFG.widescreen ? gcImg->GetWidth() * .8 : gcImg->GetWidth())+5; - } - if (wheel==1){ - wheelImg = new GuiImage(wheelImgData); - wheelImg->SetWidescreen(CFG.widescreen); - wheelImg->SetPosition(intputX , inputY); - wheelImg->SetAlignment(0,4); - gameinfoWindow.Append(wheelImg); - intputX += (CFG.widescreen ? wheelImg->GetWidth() * .8 : wheelImg->GetWidth())+5; - } - if (guitar==1){ - guitarImg = new GuiImage(guitarImgData); - guitarImg->SetWidescreen(CFG.widescreen); - guitarImg->SetPosition(intputX , inputY); - guitarImg->SetAlignment(0,4); - gameinfoWindow.Append(guitarImg); - intputX += (CFG.widescreen ? guitarImg->GetWidth() * .8 : guitarImg->GetWidth())+5; - } - if (drums==1){ - drumsImg = new GuiImage(drumsImgData); - drumsImg->SetWidescreen(CFG.widescreen); - drumsImg->SetPosition(intputX , inputY); - drumsImg->SetAlignment(0,4); - gameinfoWindow.Append(drumsImg); - intputX += (CFG.widescreen ? drumsImg->GetWidth() * .8 : drumsImg->GetWidth())+5; - } - if (microphone==1){ - microphoneImg = new GuiImage(microphoneImgData); - microphoneImg->SetWidescreen(CFG.widescreen); - microphoneImg->SetPosition(intputX , inputY); - microphoneImg->SetAlignment(0,4); - gameinfoWindow.Append(microphoneImg); - intputX += (CFG.widescreen ? microphoneImg->GetWidth() * .8 : microphoneImg->GetWidth())+5; - } - if (dancepad==1){ - dancepadImg = new GuiImage(dancepadImgData); - dancepadImg->SetWidescreen(CFG.widescreen); - dancepadImg->SetPosition(intputX , inputY); - dancepadImg->SetAlignment(0,4); - gameinfoWindow.Append(dancepadImg); - intputX += (CFG.widescreen ? dancepadImg->GetWidth() * .8 : dancepadImg->GetWidth())+5; - } - if (balanceboard==1){ - balanceboardImg = new GuiImage(balanceboardImgData); - balanceboardImg->SetWidescreen(CFG.widescreen); - balanceboardImg->SetPosition(intputX , inputY); - balanceboardImg->SetAlignment(0,4); - gameinfoWindow.Append(balanceboardImg); - intputX += (CFG.widescreen ? balanceboardImg->GetWidth() * .8 : balanceboardImg->GetWidth())+5; - } + if (drums) drumsImgData = new GuiImageData(drumsR_png); + else drumsImgData = new GuiImageData(drums_png); - // # online players - 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)>8){ uncomment this when we actually have these images and it is needed - wifiplayersImgData= new GuiImageData(wifi12_png);} - if (atoi(gameinfo.wifiplayers)>12){ - wifiplayersImgData= new GuiImageData(wifi16_png);} - if (atoi(gameinfo.wifiplayers)>16){ - wifiplayersImgData= new GuiImageData(wifi32_png);}*/ - wifiplayersImg = new GuiImage(wifiplayersImgData); - wifiplayersImg->SetWidescreen(CFG.widescreen); - wifiplayersImg->SetPosition(intputX , inputY); - wifiplayersImg->SetAlignment(0,4); - gameinfoWindow.Append(wifiplayersImg); - intputX += (CFG.widescreen ? wifiplayersImg->GetWidth() * .8 : wifiplayersImg->GetWidth())+5; - } + if (microphone) microphoneImgData = new GuiImageData(microphoneR_png); + else microphoneImgData = new GuiImageData(microphone_png); - // ratings - if (strcmp(gameinfo.ratingtype,"") !=0){ - if (strcmp(gameinfo.ratingtype,"ESRB")==0) { - if (strcmp(gameinfo.ratingvalueESRB,"EC")==0) - ratingImgData = new GuiImageData(esrb_ec_png); - else if (strcmp(gameinfo.ratingvalueESRB,"E")==0) - ratingImgData = new GuiImageData(esrb_e_png); - else if (strcmp(gameinfo.ratingvalueESRB,"E10+")==0) - ratingImgData = new GuiImageData(esrb_eten_png); - else if (strcmp(gameinfo.ratingvalueESRB,"T")==0) - ratingImgData = new GuiImageData(esrb_t_png); - else if (strcmp(gameinfo.ratingvalueESRB,"M")==0) - 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);} - } //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)) - ratingImgData = new GuiImageData(pegi_3_png); - else if ((strcmp(gameinfo.ratingvaluePEGI,"7")==0)||(strcmp(gameinfo.ratingvaluePEGI,"7")==0)) - ratingImgData = new GuiImageData(pegi_7_png); - else if (strcmp(gameinfo.ratingvaluePEGI,"12")==0) - ratingImgData = new GuiImageData(pegi_12_png); - else if ((strcmp(gameinfo.ratingvaluePEGI,"16")==0)||(strcmp(gameinfo.ratingvaluePEGI,"15")==0)) - 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 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) - ratingImgData = new GuiImageData(cero_b_png); - else if (strcmp(gameinfo.ratingvalueCERO,"C")==0) - ratingImgData = new GuiImageData(cero_c_png); - else if (strcmp(gameinfo.ratingvalueCERO,"D")==0) - 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);} - } + if (balanceboard) balanceboardImgData = new GuiImageData(balanceboardR_png); + else balanceboardImgData = new GuiImageData(balanceboard_png); - else {ratingImgData = new GuiImageData(norating_png);} - ratingImg = new GuiImage(ratingImgData); - ratingImg->SetWidescreen(CFG.widescreen); - ratingImg->SetPosition(-25 , inputY); - ratingImg->SetAlignment(1,4); - gameinfoWindow.Append(ratingImg); - intputX += (CFG.widescreen ? ratingImg->GetWidth() * .8 : ratingImg->GetWidth())+5; - } + if (dancepad) dancepadImgData = new GuiImageData(dancepadR_png); + else dancepadImgData = new GuiImageData(dancepad_png); - // memory info - if (showmeminfo) { - 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); - gameinfoWindow.Append(memTxt); - } - - // title - 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->SetMaxWidth(350, GuiText::SCROLL); - //while (titleTxt->GetWidth()>250) { titleTxt->SetFontSize(titlefontsize-=2); } - 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)) - { - case 1: - snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Jan")); - break; - case 2: - snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Feb")); - break; - case 3: - snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Mar")); - break; - case 4: - snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Apr")); - break; - case 5: - snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("May")); - break; - case 6: - snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("June")); - break; - case 7: - snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("July")); - break; - case 8: - snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Aug")); - break; - case 9: - snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Sept")); - break; - case 10: - snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Oct")); - break; - case 11: - snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Nov")); - break; - case 12: - snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Dec")); - break; - } - } - 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}); - if (releasedTxt->GetWidth()>300) newline=2; - releasedTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); releasedTxt->SetPosition(-17,12+indexy); indexy+=(20 * newline);newline=1; - gameinfoWindow.Append(releasedTxt); - } + // look for optional accessories + for (int i=1;i<=XML_ELEMMAX;i++) { + if (strcmp(gameinfo.accessories[i],"classiccontroller")==0) + classiccontroller=1; + if (strcmp(gameinfo.accessories[i],"nunchuk")==0) + nunchuk=1; + if (strcmp(gameinfo.accessories[i],"guitar")==0) + guitar=1; + if (strcmp(gameinfo.accessories[i],"drums")==0) + drums=1; + if (strcmp(gameinfo.accessories[i],"dancepad")==0) + dancepad=1; + if (strcmp(gameinfo.accessories[i],"motionplus")==0) + motionplus=1; + if (strcmp(gameinfo.accessories[i],"wheel")==0) + wheel=1; + if (strcmp(gameinfo.accessories[i],"balanceboard")==0) + balanceboard=1; + if (strcmp(gameinfo.accessories[i],"microphone")==0) + microphone=1; + if (strcmp(gameinfo.accessories[i],"gamecube")==0) + gamecube=1; + } - //publisher - 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}); - 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; - 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}); - 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; - gameinfoWindow.Append(developerTxt); - } + dialogBoxImg1 = new GuiImage(&dialogBox1); + dialogBoxImg1->SetAlignment(0,3); + dialogBoxImg1->SetPosition(-9,0); - //genre - int genreY = marginY; - genreTxt = new GuiText * [gameinfo.genreCnt + 1]; - 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; - gameinfoWindow.Append(genreTxt[i]); - } - - //online - wifiTxt = new GuiText * [gameinfo.wifiCnt + 1]; - 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; - gameinfoWindow.Append(wifiTxt[i]); - } - 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); - gameinfoWindow.Append(wifiTxt[0]); - } - - //synopsis - 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->SetMaxWidth(350,GuiText::WRAP); - synopsisTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); synopsisTxt->SetPosition(0,0); - synopsisTxt->SetNumLines(pagesize); - //synopsisTxt->SetFirstLine(12); - - dialogBoxImg11 = new GuiImage(&dialogBox1); - dialogBoxImg11->SetAlignment(0,3); - dialogBoxImg11->SetPosition(-9,0); + dialogBoxImg2 = new GuiImage(&dialogBox2); + dialogBoxImg2->SetAlignment(0,3); + dialogBoxImg2->SetPosition(145,0); - dialogBoxImg22 = new GuiImage(&dialogBox2); - dialogBoxImg22->SetAlignment(0,3); - dialogBoxImg22->SetPosition(145,0); + dialogBoxImg3 = new GuiImage(&dialogBox3); + dialogBoxImg3->SetAlignment(0,3); + dialogBoxImg3->SetPosition(301,0); - dialogBoxImg33 = new GuiImage(&dialogBox3); - dialogBoxImg33->SetAlignment(0,3); - dialogBoxImg33->SetPosition(301,0); + dialogBoxImg4 = new GuiImage(&dialogBox4); + dialogBoxImg4->SetAlignment(0,3); + dialogBoxImg4->SetPosition(457,0); - dialogBoxImg44 = new GuiImage(&dialogBox4); - dialogBoxImg44->SetAlignment(0,3); - dialogBoxImg44->SetPosition(457,0); + gameinfoWindow.Append(dialogBoxImg1); + gameinfoWindow.Append(dialogBoxImg2); + gameinfoWindow.Append(dialogBoxImg3); + gameinfoWindow.Append(dialogBoxImg4); - gameinfoWindow2.Append(dialogBoxImg11); - gameinfoWindow2.Append(dialogBoxImg22); - gameinfoWindow2.Append(dialogBoxImg33); - gameinfoWindow2.Append(dialogBoxImg44); + snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID); + cover = new GuiImageData(imgPath, 0); //load full id image + if (!cover->GetImage()) { + delete cover; + snprintf(imgPath, sizeof(imgPath), "%snoimage.png", Settings.covers_path); + cover = new GuiImageData(imgPath, nocover_png); //load no image + } + delete coverImg; + coverImg = NULL; - txtWindow.Append(synopsisTxt); - txtWindow.Append(&upBtn); - txtWindow.Append(&dnBtn); - coverImg2 = new GuiImage(cover); - coverImg2->SetWidescreen(CFG.widescreen); - coverImg2->SetPosition(15,30); - gameinfoWindow2.Append(coverImg2); - gameinfoWindow2.Append(&txtWindow); - } - - //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); - 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); - gameinfoWindow.Append(beta1Txt); - - gameinfoWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 100); - HaltGui(); - //mainWindow->SetState(STATE_DISABLED); - mainWindow->Append(&gameinfoWindow); - mainWindow->ChangeFocus(&gameinfoWindow); - ResumeGui(); - - while(choice == -1) - { - - VIDEO_WaitVSync(); - if(shutdown == 1) - { - wiilight(0); - Sys_Shutdown(); - } - else if(reset == 1) - Sys_Reboot(); + coverImg = new GuiImage(cover); + coverImg->SetWidescreen(CFG.widescreen); + coverImg->SetPosition(15,30); + gameinfoWindow.Append(coverImg); - else if ((backBtn.GetState()==STATE_CLICKED)||(backBtn.GetState()==STATE_HELD)){ - if(page==1) - {choice=1; - synopsisTxt = NULL; - break;} - else if (page==2) - { - HaltGui(); - gameinfoWindow2.SetVisible(false); - gameinfoWindow.SetVisible(true); - mainWindow->Remove(&gameinfoWindow2); - ResumeGui(); - page=1; - } - } - else if (((nextBtn.GetState()==STATE_CLICKED)||(nextBtn.GetState()==STATE_HELD))&& - (strcmp(gameinfo.synopsis,"") != 0)){ + // # of players + if (strcmp(gameinfo.players,"") != 0) { + playersImgData = new GuiImageData(Wiimote1_png); + if (atoi(gameinfo.players)>1) { + playersImgData= new GuiImageData(Wiimote2_png); + } + if (atoi(gameinfo.players)>2) { + playersImgData= new GuiImageData(Wiimote4_png); + } - if (page==1){ - nextBtn.ResetState(); - HaltGui(); - gameinfoWindow.SetVisible(false); - gameinfoWindow2.SetVisible(true); - coverImg->SetPosition(15,30); + playersImg = new GuiImage(playersImgData); + playersImg->SetWidescreen(CFG.widescreen); + playersImg->SetPosition(intputX , inputY); + playersImg->SetAlignment(0,4); + gameinfoWindow.Append(playersImg); + intputX += (CFG.widescreen ? playersImg->GetWidth() * .8 : playersImg->GetWidth())+5; + } - //backBtn.SetClickable(false); - gameinfoWindow2.Append(&nextBtn); - gameinfoWindow2.Append(&backBtn); - gameinfoWindow2.Append(&homeBtn); - mainWindow->Append(&gameinfoWindow2); - ResumeGui(); - page=2; - } - else { - nextBtn.ResetState(); - HaltGui(); - //backBtn.SetClickable(true); - gameinfoWindow2.SetVisible(false); - gameinfoWindow.SetVisible(true); - gameinfoWindow.Append(&backBtn); - gameinfoWindow.Append(&nextBtn); - gameinfoWindow.Append(&homeBtn); - mainWindow->Remove(&gameinfoWindow2); - ResumeGui(); - page=1; - } - nextBtn.ResetState(); - - } - 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 - &&synopsisTxt->GetTotalLines()>pagesize - &&synopsisTxt->GetFirstLine()-1GetTotalLines()-pagesize) - { - int l=0; - //if(synopsisTxt->GetTotalLines()>pagesize) - l=synopsisTxt->GetFirstLine()+1; - - //if (l>(synopsisTxt->GetTotalLines()+1)-pagesize) - //l=(synopsisTxt->GetTotalLines()+1)-pagesize; - - synopsisTxt->SetFirstLine(l); - usleep(60000); - if (!((ButtonsHold() & WPAD_BUTTON_DOWN)||(ButtonsHold() & PAD_BUTTON_DOWN))) - dnBtn.ResetState(); - } - else if (homeBtn.GetState()==STATE_CLICKED) - { - if(page==1) - {choice=2; - synopsisTxt = NULL; - break;} - else if (page==2) - { - HaltGui(); - gameinfoWindow2.SetVisible(false); - gameinfoWindow.SetVisible(true); - //gameinfoWindow.Append(&backBtn); - //gameinfoWindow.Append(&nextBtn); - //gameinfoWindow.Append(&homeBtn); - mainWindow->Remove(&gameinfoWindow2); - ResumeGui(); - page=1; - } - } - 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); - snprintf(linebuf, sizeof(linebuf), tr("Paste it into your browser to get your WiiTDB.zip.")); - beta1Txt->SetText(linebuf); - gameinfoWindow.Append(beta1Txt); - } - } - } - if (page==1){ - gameinfoWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 100); - while(gameinfoWindow.GetEffect() > 0) usleep(50); - HaltGui(); - mainWindow->Remove(&gameinfoWindow); - mainWindow->SetState(STATE_DEFAULT); + //draw the input types for this game + if (motionplus==1) { + motionplusImg = new GuiImage(motionplusImgData); + motionplusImg->SetWidescreen(CFG.widescreen); + motionplusImg->SetPosition(intputX , inputY); + motionplusImg->SetAlignment(0,4); + gameinfoWindow.Append(motionplusImg); + intputX += (CFG.widescreen ? motionplusImg->GetWidth() * .8 : motionplusImg->GetWidth())+5; + } + if (nunchuk==1) { + nunchukImg = new GuiImage(nunchukImgData); + nunchukImg->SetWidescreen(CFG.widescreen); + nunchukImg->SetPosition(intputX , inputY); + nunchukImg->SetAlignment(0,4); + gameinfoWindow.Append(nunchukImg); + intputX += (CFG.widescreen ? nunchukImg->GetWidth() * .8 : nunchukImg->GetWidth())+5; + } + if (classiccontroller==1) { + classiccontrollerImg = new GuiImage(classiccontrollerImgData); + classiccontrollerImg->SetWidescreen(CFG.widescreen); + classiccontrollerImg->SetPosition(intputX , inputY); + classiccontrollerImg->SetAlignment(0,4); + gameinfoWindow.Append(classiccontrollerImg); + intputX += (CFG.widescreen ? classiccontrollerImg->GetWidth() * .8 : classiccontrollerImg->GetWidth())+5; + } + if (gamecube==1) { + gcImg = new GuiImage(gamecubeImgData); + gcImg->SetWidescreen(CFG.widescreen); + gcImg->SetPosition(intputX , inputY); + gcImg->SetAlignment(0,4); + gameinfoWindow.Append(gcImg); + intputX += (CFG.widescreen ? gcImg->GetWidth() * .8 : gcImg->GetWidth())+5; + } + if (wheel==1) { + wheelImg = new GuiImage(wheelImgData); + wheelImg->SetWidescreen(CFG.widescreen); + wheelImg->SetPosition(intputX , inputY); + wheelImg->SetAlignment(0,4); + gameinfoWindow.Append(wheelImg); + intputX += (CFG.widescreen ? wheelImg->GetWidth() * .8 : wheelImg->GetWidth())+5; + } + if (guitar==1) { + guitarImg = new GuiImage(guitarImgData); + guitarImg->SetWidescreen(CFG.widescreen); + guitarImg->SetPosition(intputX , inputY); + guitarImg->SetAlignment(0,4); + gameinfoWindow.Append(guitarImg); + intputX += (CFG.widescreen ? guitarImg->GetWidth() * .8 : guitarImg->GetWidth())+5; + } + if (drums==1) { + drumsImg = new GuiImage(drumsImgData); + drumsImg->SetWidescreen(CFG.widescreen); + drumsImg->SetPosition(intputX , inputY); + drumsImg->SetAlignment(0,4); + gameinfoWindow.Append(drumsImg); + intputX += (CFG.widescreen ? drumsImg->GetWidth() * .8 : drumsImg->GetWidth())+5; + } + if (microphone==1) { + microphoneImg = new GuiImage(microphoneImgData); + microphoneImg->SetWidescreen(CFG.widescreen); + microphoneImg->SetPosition(intputX , inputY); + microphoneImg->SetAlignment(0,4); + gameinfoWindow.Append(microphoneImg); + intputX += (CFG.widescreen ? microphoneImg->GetWidth() * .8 : microphoneImg->GetWidth())+5; + } + if (dancepad==1) { + dancepadImg = new GuiImage(dancepadImgData); + dancepadImg->SetWidescreen(CFG.widescreen); + dancepadImg->SetPosition(intputX , inputY); + dancepadImg->SetAlignment(0,4); + gameinfoWindow.Append(dancepadImg); + intputX += (CFG.widescreen ? dancepadImg->GetWidth() * .8 : dancepadImg->GetWidth())+5; + } + if (balanceboard==1) { + balanceboardImg = new GuiImage(balanceboardImgData); + balanceboardImg->SetWidescreen(CFG.widescreen); + balanceboardImg->SetPosition(intputX , inputY); + balanceboardImg->SetAlignment(0,4); + gameinfoWindow.Append(balanceboardImg); + intputX += (CFG.widescreen ? balanceboardImg->GetWidth() * .8 : balanceboardImg->GetWidth())+5; + } - delete playersImgData; - delete playersImg; + // # online players + 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)>8){ uncomment this when we actually have these images and it is needed + wifiplayersImgData= new GuiImageData(wifi12_png);} + if (atoi(gameinfo.wifiplayers)>12){ + wifiplayersImgData= new GuiImageData(wifi16_png);} + if (atoi(gameinfo.wifiplayers)>16){ + wifiplayersImgData= new GuiImageData(wifi32_png);}*/ + wifiplayersImg = new GuiImage(wifiplayersImgData); + wifiplayersImg->SetWidescreen(CFG.widescreen); + wifiplayersImg->SetPosition(intputX , inputY); + wifiplayersImg->SetAlignment(0,4); + gameinfoWindow.Append(wifiplayersImg); + intputX += (CFG.widescreen ? wifiplayersImg->GetWidth() * .8 : wifiplayersImg->GetWidth())+5; + } - delete wifiplayersImgData; - delete wifiplayersImg; - delete ratingImg; + // ratings + if (strcmp(gameinfo.ratingtype,"") !=0) { + if (strcmp(gameinfo.ratingtype,"ESRB")==0) { + if (strcmp(gameinfo.ratingvalueESRB,"EC")==0) + ratingImgData = new GuiImageData(esrb_ec_png); + else if (strcmp(gameinfo.ratingvalueESRB,"E")==0) + ratingImgData = new GuiImageData(esrb_e_png); + else if (strcmp(gameinfo.ratingvalueESRB,"E10+")==0) + ratingImgData = new GuiImageData(esrb_eten_png); + else if (strcmp(gameinfo.ratingvalueESRB,"T")==0) + ratingImgData = new GuiImageData(esrb_t_png); + else if (strcmp(gameinfo.ratingvalueESRB,"M")==0) + 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); + } + } //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)) + ratingImgData = new GuiImageData(pegi_3_png); + else if ((strcmp(gameinfo.ratingvaluePEGI,"7")==0)||(strcmp(gameinfo.ratingvaluePEGI,"7")==0)) + ratingImgData = new GuiImageData(pegi_7_png); + else if (strcmp(gameinfo.ratingvaluePEGI,"12")==0) + ratingImgData = new GuiImageData(pegi_12_png); + else if ((strcmp(gameinfo.ratingvaluePEGI,"16")==0)||(strcmp(gameinfo.ratingvaluePEGI,"15")==0)) + 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 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) + ratingImgData = new GuiImageData(cero_b_png); + else if (strcmp(gameinfo.ratingvalueCERO,"C")==0) + ratingImgData = new GuiImageData(cero_c_png); + else if (strcmp(gameinfo.ratingvalueCERO,"D")==0) + 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); + } + } - delete classiccontrollerImg; - delete nunchukImg; - delete guitarImg; - delete drumsImg; - delete dancepadImg; - delete motionplusImg; - delete wheelImg; - delete balanceboardImg; - delete microphoneImg; - delete gcImg; - delete dialogBoxImg1; - delete dialogBoxImg2; - delete dialogBoxImg3; - delete dialogBoxImg4; - delete dialogBoxImg11; - delete dialogBoxImg22; - delete dialogBoxImg33; - delete dialogBoxImg44; - delete coverImg; - delete coverImg2; + else { + ratingImgData = new GuiImageData(norating_png); + } + ratingImg = new GuiImage(ratingImgData); + ratingImg->SetWidescreen(CFG.widescreen); + ratingImg->SetPosition(-25 , inputY); + ratingImg->SetAlignment(1,4); + gameinfoWindow.Append(ratingImg); + intputX += (CFG.widescreen ? ratingImg->GetWidth() * .8 : ratingImg->GetWidth())+5; + } - delete classiccontrollerImgData; - delete nunchukImgData; - delete guitarImgData; - delete drumsImgData; - delete motionplusImgData; - delete wheelImgData; - delete balanceboardImgData; - delete dancepadImgData; - delete microphoneImgData; - delete gamecubeImgData; - delete ratingImgData; - delete cover; - delete releasedTxt; - delete publisherTxt; - delete developerTxt; - delete titleTxt; - delete synopsisTxt; - delete betaTxt; - delete beta1Txt; - delete memTxt; - 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++) - { - delete wifiTxt[i]; - } - } - ResumeGui(); - } else { - gameinfoWindow2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 100); - while(gameinfoWindow2.GetEffect() > 0) usleep(50); - HaltGui(); - mainWindow->Remove(&gameinfoWindow2); - mainWindow->SetState(STATE_DEFAULT); - ResumeGui(); - } - return choice; + // memory info + if (showmeminfo) { + 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); + gameinfoWindow.Append(memTxt); + } - /* File not found */ + // title + 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->SetMaxWidth(350, GuiText::SCROLL); + //while (titleTxt->GetWidth()>250) { titleTxt->SetFontSize(titlefontsize-=2); } + 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)) { + case 1: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Jan")); + break; + case 2: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Feb")); + break; + case 3: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Mar")); + break; + case 4: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Apr")); + break; + case 5: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("May")); + break; + case 6: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("June")); + break; + case 7: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("July")); + break; + case 8: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Aug")); + break; + case 9: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Sept")); + break; + case 10: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Oct")); + break; + case 11: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Nov")); + break; + case 12: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr("Dec")); + break; + } + } + 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}); + if (releasedTxt->GetWidth()>300) newline=2; + 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) { + snprintf(linebuf, sizeof(linebuf), "%s %s", tr("Published by"), gameinfo.publisher); + 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; + 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}); + 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; + gameinfoWindow.Append(developerTxt); + } + + //genre + int genreY = marginY; + genreTxt = new GuiText * [gameinfo.genreCnt + 1]; + 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; + gameinfoWindow.Append(genreTxt[i]); + } + + //online + wifiTxt = new GuiText * [gameinfo.wifiCnt + 1]; + 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; + gameinfoWindow.Append(wifiTxt[i]); + } + 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); + gameinfoWindow.Append(wifiTxt[0]); + } + + //synopsis + 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->SetMaxWidth(350,GuiText::WRAP); + synopsisTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + synopsisTxt->SetPosition(0,0); + synopsisTxt->SetNumLines(pagesize); + //synopsisTxt->SetFirstLine(12); + + dialogBoxImg11 = new GuiImage(&dialogBox1); + dialogBoxImg11->SetAlignment(0,3); + dialogBoxImg11->SetPosition(-9,0); + + dialogBoxImg22 = new GuiImage(&dialogBox2); + dialogBoxImg22->SetAlignment(0,3); + dialogBoxImg22->SetPosition(145,0); + + dialogBoxImg33 = new GuiImage(&dialogBox3); + dialogBoxImg33->SetAlignment(0,3); + dialogBoxImg33->SetPosition(301,0); + + dialogBoxImg44 = new GuiImage(&dialogBox4); + dialogBoxImg44->SetAlignment(0,3); + dialogBoxImg44->SetPosition(457,0); + + gameinfoWindow2.Append(dialogBoxImg11); + gameinfoWindow2.Append(dialogBoxImg22); + gameinfoWindow2.Append(dialogBoxImg33); + gameinfoWindow2.Append(dialogBoxImg44); + + txtWindow.Append(synopsisTxt); + txtWindow.Append(&upBtn); + txtWindow.Append(&dnBtn); + coverImg2 = new GuiImage(cover); + coverImg2->SetWidescreen(CFG.widescreen); + coverImg2->SetPosition(15,30); + gameinfoWindow2.Append(coverImg2); + gameinfoWindow2.Append(&txtWindow); + } + + //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); + 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); + gameinfoWindow.Append(beta1Txt); + + gameinfoWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 100); + HaltGui(); + //mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&gameinfoWindow); + mainWindow->ChangeFocus(&gameinfoWindow); + ResumeGui(); + + while (choice == -1) { + + VIDEO_WaitVSync(); + if (shutdown == 1) { + wiilight(0); + Sys_Shutdown(); + } else if (reset == 1) + Sys_Reboot(); + + else if ((backBtn.GetState()==STATE_CLICKED)||(backBtn.GetState()==STATE_HELD)) { + if (page==1) { + choice=1; + synopsisTxt = NULL; + break; + } else if (page==2) { + HaltGui(); + gameinfoWindow2.SetVisible(false); + gameinfoWindow.SetVisible(true); + mainWindow->Remove(&gameinfoWindow2); + ResumeGui(); + page=1; + } + } else if (((nextBtn.GetState()==STATE_CLICKED)||(nextBtn.GetState()==STATE_HELD))&& + (strcmp(gameinfo.synopsis,"") != 0)) { + + if (page==1) { + nextBtn.ResetState(); + HaltGui(); + gameinfoWindow.SetVisible(false); + gameinfoWindow2.SetVisible(true); + coverImg->SetPosition(15,30); + + //backBtn.SetClickable(false); + gameinfoWindow2.Append(&nextBtn); + gameinfoWindow2.Append(&backBtn); + gameinfoWindow2.Append(&homeBtn); + mainWindow->Append(&gameinfoWindow2); + ResumeGui(); + page=2; + } else { + nextBtn.ResetState(); + HaltGui(); + //backBtn.SetClickable(true); + gameinfoWindow2.SetVisible(false); + gameinfoWindow.SetVisible(true); + gameinfoWindow.Append(&backBtn); + gameinfoWindow.Append(&nextBtn); + gameinfoWindow.Append(&homeBtn); + mainWindow->Remove(&gameinfoWindow2); + ResumeGui(); + page=1; + } + nextBtn.ResetState(); + + } 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 + &&synopsisTxt->GetTotalLines()>pagesize + &&synopsisTxt->GetFirstLine()-1GetTotalLines()-pagesize) { + int l=0; + //if(synopsisTxt->GetTotalLines()>pagesize) + l=synopsisTxt->GetFirstLine()+1; + + //if (l>(synopsisTxt->GetTotalLines()+1)-pagesize) + //l=(synopsisTxt->GetTotalLines()+1)-pagesize; + + synopsisTxt->SetFirstLine(l); + usleep(60000); + if (!((ButtonsHold() & WPAD_BUTTON_DOWN)||(ButtonsHold() & PAD_BUTTON_DOWN))) + dnBtn.ResetState(); + } else if (homeBtn.GetState()==STATE_CLICKED) { + if (page==1) { + choice=2; + synopsisTxt = NULL; + break; + } else if (page==2) { + HaltGui(); + gameinfoWindow2.SetVisible(false); + gameinfoWindow.SetVisible(true); + //gameinfoWindow.Append(&backBtn); + //gameinfoWindow.Append(&nextBtn); + //gameinfoWindow.Append(&homeBtn); + mainWindow->Remove(&gameinfoWindow2); + ResumeGui(); + page=1; + } + } 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); + snprintf(linebuf, sizeof(linebuf), tr("Paste it into your browser to get your WiiTDB.zip.")); + beta1Txt->SetText(linebuf); + gameinfoWindow.Append(beta1Txt); + } + } + } + if (page==1) { + gameinfoWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 100); + while (gameinfoWindow.GetEffect() > 0) usleep(50); + HaltGui(); + mainWindow->Remove(&gameinfoWindow); + mainWindow->SetState(STATE_DEFAULT); + + delete playersImgData; + delete playersImg; + + delete wifiplayersImgData; + delete wifiplayersImg; + delete ratingImg; + + delete classiccontrollerImg; + delete nunchukImg; + delete guitarImg; + delete drumsImg; + delete dancepadImg; + delete motionplusImg; + delete wheelImg; + delete balanceboardImg; + delete microphoneImg; + delete gcImg; + delete dialogBoxImg1; + delete dialogBoxImg2; + delete dialogBoxImg3; + delete dialogBoxImg4; + delete dialogBoxImg11; + delete dialogBoxImg22; + delete dialogBoxImg33; + delete dialogBoxImg44; + delete coverImg; + delete coverImg2; + + delete classiccontrollerImgData; + delete nunchukImgData; + delete guitarImgData; + delete drumsImgData; + delete motionplusImgData; + delete wheelImgData; + delete balanceboardImgData; + delete dancepadImgData; + delete microphoneImgData; + delete gamecubeImgData; + delete ratingImgData; + delete cover; + delete releasedTxt; + delete publisherTxt; + delete developerTxt; + delete titleTxt; + delete synopsisTxt; + delete betaTxt; + delete beta1Txt; + delete memTxt; + 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++) { + delete wifiTxt[i]; + } + } + ResumeGui(); + } else { + gameinfoWindow2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 100); + while (gameinfoWindow2.GetEffect() > 0) usleep(50); + HaltGui(); + mainWindow->Remove(&gameinfoWindow2); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); + } + return choice; + + /* File not found */ } else { return -1; } } -bool save_XML_URL()// save xml url as as txt file for people without wifi -{ - char tmp[200]; - sprintf(tmp, "%s", Settings.update_path); +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; - sprintf(tmp, "%sWiiTDB_URL.txt", Settings.update_path); - f = fopen(tmp, "w"); - if (!f) { - sleep(1); - return false; - } - //make sure that all games are added to the gamelist - __Menu_GetEntries(1); - - char XMLurl[2040]; - char filename[10]; - // get Wii's language setting - char sysLanguage[3]; - GetLanguageToLangCode(sysLanguage); + sprintf(tmp, "%sWiiTDB_URL.txt", Settings.update_path); + f = fopen(tmp, "w"); + if (!f) { + sleep(1); + return false; + } + //make sure that all games are added to the gamelist + __Menu_GetEntries(1); - snprintf(XMLurl,sizeof(XMLurl),"http://wiitdb.com/wiitdb.zip?LANG=%s?ID=",sysLanguage); - unsigned int i; - for (i = 0; i < gameCnt ; i++) { - struct discHdr* header = &gameList[i]; - if (i<500) { - snprintf(filename,sizeof(filename),"%c%c%c", header->id[1], header->id[2], header->id[3]); - strncat(XMLurl, filename,3 ); - if ((i!=gameCnt-1)&&(i<500)) - strncat(XMLurl, ",",1); - } - } - - fprintf(f, "# USB Loader Has Saved this file\n"); - fprintf(f, "# This url was created based on your list of games and language settings\n"); - fclose(f); - /* Closing and reopening because of a write issue we are having right now */ - f = fopen(tmp, "w"); - fprintf(f, "# USB Loader Has Saved this file\n"); - fprintf(f, "# This url was created based on your list of games and language settings.\n"); - fprintf(f, "# If copy and paste this URL into your web browser and you should get a zip file that will work for you.\n"); - fprintf(f, "%s\n\n\n ", XMLurl); - - fclose(f); - - __Menu_GetEntries(); - return true; + char XMLurl[2040]; + char filename[10]; + // get Wii's language setting + char sysLanguage[3]; + GetLanguageToLangCode(sysLanguage); + + snprintf(XMLurl,sizeof(XMLurl),"http://wiitdb.com/wiitdb.zip?LANG=%s?ID=",sysLanguage); + unsigned int i; + for (i = 0; i < gameCnt ; i++) { + struct discHdr* header = &gameList[i]; + if (i<500) { + snprintf(filename,sizeof(filename),"%c%c%c", header->id[1], header->id[2], header->id[3]); + strncat(XMLurl, filename,3 ); + if ((i!=gameCnt-1)&&(i<500)) + strncat(XMLurl, ",",1); + } + } + + fprintf(f, "# USB Loader Has Saved this file\n"); + fprintf(f, "# This url was created based on your list of games and language settings\n"); + fclose(f); + /* Closing and reopening because of a write issue we are having right now */ + f = fopen(tmp, "w"); + fprintf(f, "# USB Loader Has Saved this file\n"); + fprintf(f, "# This url was created based on your list of games and language settings.\n"); + fprintf(f, "# If copy and paste this URL into your web browser and you should get a zip file that will work for you.\n"); + fprintf(f, "%s\n\n\n ", XMLurl); + + fclose(f); + + __Menu_GetEntries(); + return true; } diff --git a/source/ramdisc/ramdisc.cpp b/source/ramdisc/ramdisc.cpp index 40f7d0c6..37db6cb3 100644 --- a/source/ramdisc/ramdisc.cpp +++ b/source/ramdisc/ramdisc.cpp @@ -1,198 +1,174 @@ #include #include "ramdisc.h" -static inline u16 u8array_to_u16 (const u8* item, int offset) -{ - return ( item[offset] | (item[offset + 1] << 8)); +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) -{ - return ( item[offset] | (item[offset + 1] << 8) | (item[offset + 2] << 16) | (item[offset + 3] << 24) ); +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) { + item[offset] = (u8) value; + item[offset + 1] = (u8)(value >> 8); + item[offset + 2] = (u8)(value >> 16); + item[offset + 3] = (u8)(value >> 24); } -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); - item[offset + 3] = (u8)(value >> 24); -} -class padding -{ +class padding { public: - padding(u32 Start, u32 NumSectors) - { - start = Start; - end = Start + NumSectors; - data = new u8[NumSectors*512]; - next = 0; - } - ~padding() { delete [] data;} + padding(u32 Start, u32 NumSectors) { + start = Start; + end = Start + NumSectors; + data = new u8[NumSectors*512]; + next = 0; + } + ~padding() { + delete [] data; + } - u32 start; - u32 end; - u8 *data; - padding *next; + u32 start; + u32 end; + u8 *data; + padding *next; }; static u32 __ramdisk_sectorsOfPadding; static padding *__ramdisk_data_start; static padding *__ramdisk_data_end; -static bool __ramdisk_IsInserted(void) -{ - return __ramdisk_data_start!=NULL; +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 - - __ramdisk_sectorsOfPadding = Padding/512; + 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_data_start = __ramdisk_data_end = new padding(0, __ramdisk_sectorsOfPadding); - if(!__ramdisk_data_start) return false; + __ramdisk_sectorsOfPadding = Padding/512; - // FAT12 Formatieren - u8 sector[512] = {0, }; - sector[0x00d] = 2; /*BPB_sectorsPerCluster*/ - sector[0x00e] = 1; /*BPB_reservedSectors*/ - sector[0x010] = 1; /*BPB_numFATs*/ - u16_to_u8array (sector, 0x011, 48); /*BPB_rootEntries*/ - int num_sectors = Size/512; - u16_to_u8array (sector, 0x013, num_sectors); /*BPB_numSectorsSmall*/ - int num_clusters = (num_sectors-1-3) /2; - int sectors_per_fat = (num_clusters * 3 + 1023) /1024; - u16_to_u8array (sector, 0x016, sectors_per_fat); /*BPB_sectorsPerFAT*/ - //u32_to_u8array (sector, 0x020, Size/512); /*BPB_numSectors*/ - sector[0x036] = 'F'; - sector[0x037] = 'A'; - sector[0x038] = 'T'; - sector[0x1fe] = 0x55; - sector[0x1ff] = 0xaa; - 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)) - goto error; - return true; + __ramdisk_data_start = __ramdisk_data_end = new padding(0, __ramdisk_sectorsOfPadding); + if (!__ramdisk_data_start) return false; + + // FAT12 Formatieren + u8 sector[512] = {0, }; + sector[0x00d] = 2; /*BPB_sectorsPerCluster*/ + sector[0x00e] = 1; /*BPB_reservedSectors*/ + sector[0x010] = 1; /*BPB_numFATs*/ + u16_to_u8array (sector, 0x011, 48); /*BPB_rootEntries*/ + int num_sectors = Size/512; + u16_to_u8array (sector, 0x013, num_sectors); /*BPB_numSectorsSmall*/ + int num_clusters = (num_sectors-1-3) /2; + int sectors_per_fat = (num_clusters * 3 + 1023) /1024; + u16_to_u8array (sector, 0x016, sectors_per_fat); /*BPB_sectorsPerFAT*/ + //u32_to_u8array (sector, 0x020, Size/512); /*BPB_numSectors*/ + sector[0x036] = 'F'; + sector[0x037] = 'A'; + sector[0x038] = 'T'; + sector[0x1fe] = 0x55; + sector[0x1ff] = 0xaa; + 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)) + goto error; + return true; error: - delete __ramdisk_data_start; - __ramdisk_data_start = 0; - return false; + delete __ramdisk_data_start; + __ramdisk_data_start = 0; + return false; } -void exitRAMDisc() -{ - while(__ramdisk_data_start) - { - padding *tmp = __ramdisk_data_start; - __ramdisk_data_start = __ramdisk_data_start->next; - delete tmp; - } +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; - 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) - { - __ramdisk_data_end = __ramdisk_data_end->next; - return &( __ramdisk_data_end->data[(Sector-__ramdisk_data_end->start)*512]); - } - return 0; +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) { + __ramdisk_data_end = __ramdisk_data_end->next; + return &( __ramdisk_data_end->data[(Sector-__ramdisk_data_end->start)*512]); + } + return 0; } static bool __ImplizitInit = false; -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_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) -{ - size_t num_sectors; - 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 - return false; - } - return true; +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; + memcpy(Buffer, buff, num_sectors * 512); + numSectors -= num_sectors; + Buffer+= num_sectors; + } else + return false; + } + return true; } -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; - memcpy(buff, Buffer, num_sectors * 512); - numSectors -= num_sectors; - Buffer+= num_sectors; - } - else - return false; - } - return true; +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; + memcpy(buff, Buffer, num_sectors * 512); + numSectors -= num_sectors; + Buffer+= num_sectors; + } else + return false; + } + return true; } -static bool __ramdisk_ClearStatus(void) -{ - return true; +static bool __ramdisk_ClearStatus(void) { + return true; } -static bool __ramdisk_Shutdown(void) -{ - if(__ImplizitInit) - { - __ImplizitInit = false; - exitRAMDisc(); - } - return true; +static bool __ramdisk_Shutdown(void) { + if (__ImplizitInit) { + __ImplizitInit = false; + exitRAMDisc(); + } + return true; } const DISC_INTERFACE __io_ramdisk = { - DEVICE_TYPE_RAM_DISK, - FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | 0x1000, - (FN_MEDIUM_STARTUP)&__ramdisk_Startup, - (FN_MEDIUM_ISINSERTED)&__ramdisk_IsInserted, - (FN_MEDIUM_READSECTORS)&__ramdisk_ReadSectors, - (FN_MEDIUM_WRITESECTORS)&__ramdisk_WriteSectors, - (FN_MEDIUM_CLEARSTATUS)&__ramdisk_ClearStatus, - (FN_MEDIUM_SHUTDOWN)&__ramdisk_Shutdown -}; + DEVICE_TYPE_RAM_DISK, + FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | 0x1000, + (FN_MEDIUM_STARTUP)&__ramdisk_Startup, + (FN_MEDIUM_ISINSERTED)&__ramdisk_IsInserted, + (FN_MEDIUM_READSECTORS)&__ramdisk_ReadSectors, + (FN_MEDIUM_WRITESECTORS)&__ramdisk_WriteSectors, + (FN_MEDIUM_CLEARSTATUS)&__ramdisk_ClearStatus, + (FN_MEDIUM_SHUTDOWN)&__ramdisk_Shutdown +}; diff --git a/source/settings/Settings.cpp b/source/settings/Settings.cpp index ccd56437..d16210bd 100644 --- a/source/settings/Settings.cpp +++ b/source/settings/Settings.cpp @@ -35,244 +35,240 @@ extern u8 reset; /**************************************************************************** * MenuSettings ***************************************************************************/ -int MenuSettings() -{ - int menu = MENU_NONE; - int ret; - int choice = 0; - bool exit = false; +int MenuSettings() { + int menu = MENU_NONE; + int ret; + int choice = 0; + bool exit = false; - // backup game language setting - int opt_lang = 0; - opt_lang = Settings.language; + // backup game language setting + int opt_lang = 0; + opt_lang = Settings.language; - enum { - FADE, - LEFT, - RIGHT + enum { + FADE, + LEFT, + RIGHT }; - int slidedirection = FADE; + int slidedirection = FADE; - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); GuiSound btnClick1(button_click_pcm, button_click_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[100]; + char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); - GuiImageData settingsbg(imgPath, settings_background_png); + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); + GuiImageData settingsbg(imgPath, settings_background_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_title.png", CFG.theme_path); - GuiImageData MainButtonImgData(imgPath, settings_title_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_title.png", CFG.theme_path); + GuiImageData MainButtonImgData(imgPath, settings_title_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_title_over.png", CFG.theme_path); - GuiImageData MainButtonImgOverData(imgPath, settings_title_over_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_title_over.png", CFG.theme_path); + GuiImageData MainButtonImgOverData(imgPath, settings_title_over_png); - snprintf(imgPath, sizeof(imgPath), "%spageindicator.png", CFG.theme_path); - GuiImageData PageindicatorImgData(imgPath, pageindicator_png); + snprintf(imgPath, sizeof(imgPath), "%spageindicator.png", CFG.theme_path); + GuiImageData PageindicatorImgData(imgPath, pageindicator_png); snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path); - GuiImageData arrow_left(imgPath, startgame_arrow_left_png); + GuiImageData arrow_left(imgPath, startgame_arrow_left_png); - snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path); - GuiImageData arrow_right(imgPath, startgame_arrow_right_png); + snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path); + GuiImageData arrow_right(imgPath, startgame_arrow_right_png); snprintf(imgPath, sizeof(imgPath), "%scredits_button.png", CFG.theme_path); - GuiImageData creditsImgData(imgPath, credits_button_png); + GuiImageData creditsImgData(imgPath, credits_button_png); snprintf(imgPath, sizeof(imgPath), "%scredits_button_over.png", CFG.theme_path); - GuiImageData creditsOver(imgPath, credits_button_over_png); + GuiImageData creditsOver(imgPath, credits_button_over_png); - GuiImage creditsImg(&creditsImgData); - GuiImage creditsImgOver(&creditsOver); + GuiImage creditsImg(&creditsImgData); + GuiImage creditsImgOver(&creditsOver); GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); - GuiTrigger trigB; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); GuiTrigger trigL; - trigL.SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT); - GuiTrigger trigR; - trigR.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT); + trigL.SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT); + GuiTrigger trigR; + trigR.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT); GuiTrigger trigMinus; - trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0); - GuiTrigger trigPlus; - trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0); + trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0); + GuiTrigger trigPlus; + trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0); - GuiText titleTxt(tr("Settings"), 28, (GXColor){0, 0, 0, 255}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - titleTxt.SetPosition(0,40); + GuiText titleTxt(tr("Settings"), 28, (GXColor) {0, 0, 0, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + titleTxt.SetPosition(0,40); GuiImage settingsbackground(&settingsbg); - 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){ - backBtnTxt.SetWidescreen(CFG.widescreen); - backBtnImg.SetWidescreen(CFG.widescreen); - } - GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, &btnClick,1); - backBtn.SetLabel(&backBtnTxt); - backBtn.SetTrigger(&trigB); + 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) { + backBtnTxt.SetWidescreen(CFG.widescreen); + backBtnImg.SetWidescreen(CFG.widescreen); + } + GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, &btnClick,1); + backBtn.SetLabel(&backBtnTxt); + backBtn.SetTrigger(&trigB); - GuiButton homo(1,1); - homo.SetTrigger(&trigHome); + GuiButton homo(1,1); + homo.SetTrigger(&trigHome); - GuiImage PageindicatorImg1(&PageindicatorImgData); - GuiText PageindicatorTxt1("1", 22, (GXColor){0, 0, 0, 255}); - GuiButton PageIndicatorBtn1(PageindicatorImg1.GetWidth(), PageindicatorImg1.GetHeight()); - PageIndicatorBtn1.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - PageIndicatorBtn1.SetPosition(200, 400); - PageIndicatorBtn1.SetImage(&PageindicatorImg1); - PageIndicatorBtn1.SetLabel(&PageindicatorTxt1); - PageIndicatorBtn1.SetSoundOver(&btnSoundOver); - PageIndicatorBtn1.SetSoundClick(&btnClick1); - PageIndicatorBtn1.SetTrigger(&trigA); - PageIndicatorBtn1.SetEffectGrow(); + GuiImage PageindicatorImg1(&PageindicatorImgData); + GuiText PageindicatorTxt1("1", 22, (GXColor) { 0, 0, 0, 255}); + GuiButton PageIndicatorBtn1(PageindicatorImg1.GetWidth(), PageindicatorImg1.GetHeight()); + PageIndicatorBtn1.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + PageIndicatorBtn1.SetPosition(200, 400); + PageIndicatorBtn1.SetImage(&PageindicatorImg1); + PageIndicatorBtn1.SetLabel(&PageindicatorTxt1); + PageIndicatorBtn1.SetSoundOver(&btnSoundOver); + PageIndicatorBtn1.SetSoundClick(&btnClick1); + PageIndicatorBtn1.SetTrigger(&trigA); + PageIndicatorBtn1.SetEffectGrow(); - GuiImage PageindicatorImg2(&PageindicatorImgData); - GuiText PageindicatorTxt2("2", 22, (GXColor){0, 0, 0, 255}); - GuiButton PageIndicatorBtn2(PageindicatorImg2.GetWidth(), PageindicatorImg2.GetHeight()); - PageIndicatorBtn2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - PageIndicatorBtn2.SetPosition(235, 400); - PageIndicatorBtn2.SetImage(&PageindicatorImg2); - PageIndicatorBtn2.SetLabel(&PageindicatorTxt2); - PageIndicatorBtn2.SetSoundOver(&btnSoundOver); - PageIndicatorBtn2.SetSoundClick(&btnClick1); - PageIndicatorBtn2.SetTrigger(&trigA); - PageIndicatorBtn2.SetEffectGrow(); + GuiImage PageindicatorImg2(&PageindicatorImgData); + GuiText PageindicatorTxt2("2", 22, (GXColor) {0, 0, 0, 255}); + GuiButton PageIndicatorBtn2(PageindicatorImg2.GetWidth(), PageindicatorImg2.GetHeight()); + PageIndicatorBtn2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + PageIndicatorBtn2.SetPosition(235, 400); + PageIndicatorBtn2.SetImage(&PageindicatorImg2); + PageIndicatorBtn2.SetLabel(&PageindicatorTxt2); + PageIndicatorBtn2.SetSoundOver(&btnSoundOver); + PageIndicatorBtn2.SetSoundClick(&btnClick1); + PageIndicatorBtn2.SetTrigger(&trigA); + PageIndicatorBtn2.SetEffectGrow(); - GuiImage GoLeftImg(&arrow_left); - GuiButton GoLeftBtn(GoLeftImg.GetWidth(), GoLeftImg.GetHeight()); - GoLeftBtn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - GoLeftBtn.SetPosition(25, -25); - GoLeftBtn.SetImage(&GoLeftImg); - GoLeftBtn.SetSoundOver(&btnSoundOver); - GoLeftBtn.SetSoundClick(&btnClick); - GoLeftBtn.SetEffectGrow(); - GoLeftBtn.SetTrigger(&trigA); - GoLeftBtn.SetTrigger(&trigL); - GoLeftBtn.SetTrigger(&trigMinus); + GuiImage GoLeftImg(&arrow_left); + GuiButton GoLeftBtn(GoLeftImg.GetWidth(), GoLeftImg.GetHeight()); + GoLeftBtn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + GoLeftBtn.SetPosition(25, -25); + GoLeftBtn.SetImage(&GoLeftImg); + GoLeftBtn.SetSoundOver(&btnSoundOver); + GoLeftBtn.SetSoundClick(&btnClick); + GoLeftBtn.SetEffectGrow(); + GoLeftBtn.SetTrigger(&trigA); + GoLeftBtn.SetTrigger(&trigL); + GoLeftBtn.SetTrigger(&trigMinus); - GuiImage GoRightImg(&arrow_right); - GuiButton GoRightBtn(GoRightImg.GetWidth(), GoRightImg.GetHeight()); - GoRightBtn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); - GoRightBtn.SetPosition(-25, -25); - GoRightBtn.SetImage(&GoRightImg); - GoRightBtn.SetSoundOver(&btnSoundOver); - GoRightBtn.SetSoundClick(&btnClick); - GoRightBtn.SetEffectGrow(); - GoRightBtn.SetTrigger(&trigA); - GoRightBtn.SetTrigger(&trigR); - GoRightBtn.SetTrigger(&trigPlus); + GuiImage GoRightImg(&arrow_right); + GuiButton GoRightBtn(GoRightImg.GetWidth(), GoRightImg.GetHeight()); + GoRightBtn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); + GoRightBtn.SetPosition(-25, -25); + GoRightBtn.SetImage(&GoRightImg); + GoRightBtn.SetSoundOver(&btnSoundOver); + GoRightBtn.SetSoundClick(&btnClick); + GoRightBtn.SetEffectGrow(); + GoRightBtn.SetTrigger(&trigA); + GoRightBtn.SetTrigger(&trigR); + GoRightBtn.SetTrigger(&trigPlus); char MainButtonText[50]; snprintf(MainButtonText, sizeof(MainButtonText), "%s", " "); GuiImage MainButton1Img(&MainButtonImgData); GuiImage MainButton1ImgOver(&MainButtonImgOverData); - GuiText MainButton1Txt(MainButtonText, 22, (GXColor){0, 0, 0, 255}); - MainButton1Txt.SetMaxWidth(MainButton1Img.GetWidth()); + GuiText MainButton1Txt(MainButtonText, 22, (GXColor) {0, 0, 0, 255}); + MainButton1Txt.SetMaxWidth(MainButton1Img.GetWidth()); GuiButton MainButton1(MainButton1Img.GetWidth(), MainButton1Img.GetHeight()); MainButton1.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - MainButton1.SetPosition(0, 90); - MainButton1.SetImage(&MainButton1Img); - MainButton1.SetImageOver(&MainButton1ImgOver); - MainButton1.SetLabel(&MainButton1Txt); - MainButton1.SetSoundOver(&btnSoundOver); - MainButton1.SetSoundClick(&btnClick1); - MainButton1.SetEffectGrow(); - MainButton1.SetTrigger(&trigA); + MainButton1.SetPosition(0, 90); + MainButton1.SetImage(&MainButton1Img); + MainButton1.SetImageOver(&MainButton1ImgOver); + MainButton1.SetLabel(&MainButton1Txt); + MainButton1.SetSoundOver(&btnSoundOver); + MainButton1.SetSoundClick(&btnClick1); + MainButton1.SetEffectGrow(); + MainButton1.SetTrigger(&trigA); GuiImage MainButton2Img(&MainButtonImgData); GuiImage MainButton2ImgOver(&MainButtonImgOverData); - GuiText MainButton2Txt(MainButtonText, 22, (GXColor){0, 0, 0, 255}); - MainButton2Txt.SetMaxWidth(MainButton2Img.GetWidth()); + GuiText MainButton2Txt(MainButtonText, 22, (GXColor) {0, 0, 0, 255 }); + MainButton2Txt.SetMaxWidth(MainButton2Img.GetWidth()); GuiButton MainButton2(MainButton2Img.GetWidth(), MainButton2Img.GetHeight()); MainButton2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - MainButton2.SetPosition(0, 160); - MainButton2.SetImage(&MainButton2Img); - MainButton2.SetImageOver(&MainButton2ImgOver); - MainButton2.SetLabel(&MainButton2Txt); - MainButton2.SetSoundOver(&btnSoundOver); - MainButton2.SetSoundClick(&btnClick1); - MainButton2.SetEffectGrow(); - MainButton2.SetTrigger(&trigA); + MainButton2.SetPosition(0, 160); + MainButton2.SetImage(&MainButton2Img); + MainButton2.SetImageOver(&MainButton2ImgOver); + MainButton2.SetLabel(&MainButton2Txt); + MainButton2.SetSoundOver(&btnSoundOver); + MainButton2.SetSoundClick(&btnClick1); + MainButton2.SetEffectGrow(); + MainButton2.SetTrigger(&trigA); GuiImage MainButton3Img(&MainButtonImgData); GuiImage MainButton3ImgOver(&MainButtonImgOverData); - GuiText MainButton3Txt(MainButtonText, 22, (GXColor){0, 0, 0, 255}); - MainButton3Txt.SetMaxWidth(MainButton3Img.GetWidth()); + GuiText MainButton3Txt(MainButtonText, 22, (GXColor) {0, 0, 0, 255}); + MainButton3Txt.SetMaxWidth(MainButton3Img.GetWidth()); GuiButton MainButton3(MainButton3Img.GetWidth(), MainButton3Img.GetHeight()); MainButton3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - MainButton3.SetPosition(0, 230); - MainButton3.SetImage(&MainButton3Img); - MainButton3.SetImageOver(&MainButton3ImgOver); - MainButton3.SetLabel(&MainButton3Txt); - MainButton3.SetSoundOver(&btnSoundOver); - MainButton3.SetSoundClick(&btnClick1); - MainButton3.SetEffectGrow(); - MainButton3.SetTrigger(&trigA); + MainButton3.SetPosition(0, 230); + MainButton3.SetImage(&MainButton3Img); + MainButton3.SetImageOver(&MainButton3ImgOver); + MainButton3.SetLabel(&MainButton3Txt); + MainButton3.SetSoundOver(&btnSoundOver); + MainButton3.SetSoundClick(&btnClick1); + MainButton3.SetEffectGrow(); + MainButton3.SetTrigger(&trigA); GuiImage MainButton4Img(&MainButtonImgData); GuiImage MainButton4ImgOver(&MainButtonImgOverData); - GuiText MainButton4Txt(MainButtonText, 22, (GXColor){0, 0, 0, 255}); - MainButton4Txt.SetMaxWidth(MainButton4Img.GetWidth()); + GuiText MainButton4Txt(MainButtonText, 22, (GXColor) {0, 0, 0, 255}); + MainButton4Txt.SetMaxWidth(MainButton4Img.GetWidth()); GuiButton MainButton4(MainButton4Img.GetWidth(), MainButton4Img.GetHeight()); MainButton4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - MainButton4.SetPosition(0, 300); - MainButton4.SetImage(&MainButton4Img); - MainButton4.SetImageOver(&MainButton4ImgOver); - MainButton4.SetLabel(&MainButton4Txt); - MainButton4.SetSoundOver(&btnSoundOver); - MainButton4.SetSoundClick(&btnClick1); - MainButton4.SetEffectGrow(); - MainButton4.SetTrigger(&trigA); + MainButton4.SetPosition(0, 300); + MainButton4.SetImage(&MainButton4Img); + MainButton4.SetImageOver(&MainButton4ImgOver); + MainButton4.SetLabel(&MainButton4Txt); + MainButton4.SetSoundOver(&btnSoundOver); + MainButton4.SetSoundClick(&btnClick1); + MainButton4.SetEffectGrow(); + MainButton4.SetTrigger(&trigA); - customOptionList options2(MAXOPTIONS); - GuiCustomOptionBrowser optionBrowser2(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 0, 150); - optionBrowser2.SetPosition(0, 90); - optionBrowser2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + customOptionList options2(MAXOPTIONS); + GuiCustomOptionBrowser optionBrowser2(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 0, 150); + optionBrowser2.SetPosition(0, 90); + optionBrowser2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - GuiWindow w(screenwidth, screenheight); + GuiWindow w(screenwidth, screenheight); - int pageToDisplay = 1; - while ( pageToDisplay > 0) //set pageToDisplay to 0 to quit - { - VIDEO_WaitVSync (); + int pageToDisplay = 1; + while ( pageToDisplay > 0) { //set pageToDisplay to 0 to quit + VIDEO_WaitVSync (); - menu = MENU_NONE; + menu = MENU_NONE; - if ( pageToDisplay == 1) - { - /** Standard procedure made in all pages **/ - MainButton1.StopEffect(); - MainButton2.StopEffect(); - MainButton3.StopEffect(); - MainButton4.StopEffect(); + if ( pageToDisplay == 1) { + /** Standard procedure made in all pages **/ + MainButton1.StopEffect(); + MainButton2.StopEffect(); + MainButton3.StopEffect(); + MainButton4.StopEffect(); - 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) { - 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); - MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35); - while (MainButton1.GetEffect()>0) usleep(50); + 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) { + 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); + MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35); + while (MainButton1.GetEffect()>0) usleep(50); } - HaltGui(); + HaltGui(); snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr("GUI Settings")); MainButton1Txt.SetText(MainButtonText); @@ -283,95 +279,90 @@ int MenuSettings() snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr("Sound")); MainButton4Txt.SetText(MainButtonText); - mainWindow->RemoveAll(); - mainWindow->Append(&w); - w.RemoveAll(); + mainWindow->RemoveAll(); + mainWindow->Append(&w); + w.RemoveAll(); w.Append(&settingsbackground); w.Append(&PageIndicatorBtn1); w.Append(&PageIndicatorBtn2); - w.Append(&titleTxt); - w.Append(&backBtn); - w.Append(&homo); - w.Append(&GoRightBtn); - w.Append(&GoLeftBtn); - w.Append(&MainButton1); - w.Append(&MainButton2); - w.Append(&MainButton3); - w.Append(&MainButton4); + w.Append(&titleTxt); + w.Append(&backBtn); + w.Append(&homo); + w.Append(&GoRightBtn); + w.Append(&GoLeftBtn); + w.Append(&MainButton1); + w.Append(&MainButton2); + w.Append(&MainButton3); + w.Append(&MainButton4); - PageIndicatorBtn1.SetAlpha(255); - PageIndicatorBtn2.SetAlpha(50); + PageIndicatorBtn1.SetAlpha(255); + PageIndicatorBtn2.SetAlpha(50); - /** Creditsbutton change **/ - MainButton4.SetImage(&MainButton4Img); - MainButton4.SetImageOver(&MainButton4ImgOver); + /** Creditsbutton change **/ + MainButton4.SetImage(&MainButton4Img); + MainButton4.SetImageOver(&MainButton4ImgOver); - /** Disable ability to click through MainButtons */ - optionBrowser2.SetClickable(false); - /** Default no scrollbar and reset position **/ - optionBrowser2.SetScrollbar(0); - optionBrowser2.SetOffset(0); + /** Disable ability to click through MainButtons */ + optionBrowser2.SetClickable(false); + /** Default no scrollbar and reset position **/ + optionBrowser2.SetScrollbar(0); + optionBrowser2.SetOffset(0); - MainButton1.StopEffect(); - MainButton2.StopEffect(); - MainButton3.StopEffect(); - MainButton4.StopEffect(); + MainButton1.StopEffect(); + MainButton2.StopEffect(); + MainButton3.StopEffect(); + MainButton4.StopEffect(); - MainButton1.SetEffectGrow(); - MainButton2.SetEffectGrow(); - MainButton3.SetEffectGrow(); - MainButton4.SetEffectGrow(); + MainButton1.SetEffectGrow(); + MainButton2.SetEffectGrow(); + MainButton3.SetEffectGrow(); + MainButton4.SetEffectGrow(); - 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) { - 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) { - 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); - MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35); + 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) { + 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) { + 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); + MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35); } - mainWindow->Append(&w); + mainWindow->Append(&w); - ResumeGui(); + ResumeGui(); - while(MainButton1.GetEffect() > 0) usleep(50); + while (MainButton1.GetEffect() > 0) usleep(50); - } - else if ( pageToDisplay == 2 ) - { - /** Standard procedure made in all pages **/ - MainButton1.StopEffect(); - MainButton2.StopEffect(); - MainButton3.StopEffect(); - MainButton4.StopEffect(); + } else if ( pageToDisplay == 2 ) { + /** Standard procedure made in all pages **/ + MainButton1.StopEffect(); + MainButton2.StopEffect(); + MainButton3.StopEffect(); + MainButton4.StopEffect(); - 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) { - 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); - MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35); - while (MainButton1.GetEffect()>0) usleep(50); + 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) { + 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); + MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35); + while (MainButton1.GetEffect()>0) usleep(50); } - HaltGui(); + HaltGui(); snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr("Custom Paths")); MainButton1Txt.SetText(MainButtonText); @@ -382,84 +373,80 @@ int MenuSettings() snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr("Credits")); MainButton4Txt.SetText(MainButtonText); - mainWindow->RemoveAll(); - mainWindow->Append(&w); - w.RemoveAll(); + mainWindow->RemoveAll(); + mainWindow->Append(&w); + w.RemoveAll(); w.Append(&settingsbackground); w.Append(&PageIndicatorBtn1); w.Append(&PageIndicatorBtn2); - w.Append(&titleTxt); - w.Append(&backBtn); - w.Append(&homo); - w.Append(&GoRightBtn); - w.Append(&GoLeftBtn); - w.Append(&MainButton1); - w.Append(&MainButton2); - w.Append(&MainButton3); - w.Append(&MainButton4); + w.Append(&titleTxt); + w.Append(&backBtn); + w.Append(&homo); + w.Append(&GoRightBtn); + w.Append(&GoLeftBtn); + w.Append(&MainButton1); + w.Append(&MainButton2); + w.Append(&MainButton3); + w.Append(&MainButton4); - PageIndicatorBtn1.SetAlpha(50); - PageIndicatorBtn2.SetAlpha(255); + PageIndicatorBtn1.SetAlpha(50); + PageIndicatorBtn2.SetAlpha(255); - /** Creditsbutton change **/ - MainButton4.SetImage(&creditsImg); - MainButton4.SetImageOver(&creditsImgOver); + /** Creditsbutton change **/ + MainButton4.SetImage(&creditsImg); + MainButton4.SetImageOver(&creditsImgOver); - /** Disable ability to click through MainButtons */ - optionBrowser2.SetClickable(false); - /** Default no scrollbar and reset position **/ - optionBrowser2.SetScrollbar(0); - optionBrowser2.SetOffset(0); + /** Disable ability to click through MainButtons */ + optionBrowser2.SetClickable(false); + /** Default no scrollbar and reset position **/ + optionBrowser2.SetScrollbar(0); + optionBrowser2.SetOffset(0); - MainButton1.StopEffect(); - MainButton2.StopEffect(); - MainButton3.StopEffect(); - MainButton4.StopEffect(); + MainButton1.StopEffect(); + MainButton2.StopEffect(); + MainButton3.StopEffect(); + MainButton4.StopEffect(); - MainButton1.SetEffectGrow(); - MainButton2.SetEffectGrow(); - MainButton3.SetEffectGrow(); - MainButton4.SetEffectGrow(); + MainButton1.SetEffectGrow(); + MainButton2.SetEffectGrow(); + MainButton3.SetEffectGrow(); + MainButton4.SetEffectGrow(); - 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) { - 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) { - 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); - MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35); + 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) { + 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) { + 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); + MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35); } - mainWindow->Append(&w); + mainWindow->Append(&w); - ResumeGui(); + ResumeGui(); - while(MainButton1.GetEffect() > 0) usleep(50); + while (MainButton1.GetEffect() > 0) usleep(50); - } + } - while(menu == MENU_NONE) - { - VIDEO_WaitVSync (); + while (menu == MENU_NONE) { + VIDEO_WaitVSync (); - if ( pageToDisplay == 1 ) - { - if(MainButton1.GetState() == STATE_CLICKED) { + if ( pageToDisplay == 1 ) { + if (MainButton1.GetState() == STATE_CLICKED) { MainButton1.SetEffect(EFFECT_FADE, -20); MainButton2.SetEffect(EFFECT_FADE, -20); MainButton3.SetEffect(EFFECT_FADE, -20); MainButton4.SetEffect(EFFECT_FADE, -20); - while(MainButton1.GetEffect() > 0) usleep(50); + while (MainButton1.GetEffect() > 0) usleep(50); HaltGui(); w.Remove(&PageIndicatorBtn1); w.Remove(&PageIndicatorBtn2); @@ -471,7 +458,7 @@ int MenuSettings() w.Remove(&MainButton4); titleTxt.SetText(tr("GUI Settings")); exit = false; - for(int i = 0; i <= MAXOPTIONS; i++) options2.SetName(i, NULL); + for (int i = 0; i <= MAXOPTIONS; i++) options2.SetName(i, NULL); options2.SetName(0, "%s",tr("App Language")); options2.SetName(1, "%s",tr("Display")); options2.SetName(2, "%s",tr("Clock")); @@ -484,7 +471,7 @@ int MenuSettings() options2.SetName(9, "%s",tr("AutoInit Network")); options2.SetName(10, "%s",tr("Titles from XML")); options2.SetName(11, "%s",tr("Screensaver")); - for(int i = 0; i <= MAXOPTIONS; i++) options2.SetValue(i, NULL); + for (int i = 0; i <= MAXOPTIONS; i++) options2.SetValue(i, NULL); optionBrowser2.SetScrollbar(1); w.Append(&optionBrowser2); optionBrowser2.SetClickable(true); @@ -492,21 +479,20 @@ int MenuSettings() VIDEO_WaitVSync (); optionBrowser2.SetEffect(EFFECT_FADE, 20); - while(optionBrowser2.GetEffect() > 0) usleep(50); + while (optionBrowser2.GetEffect() > 0) usleep(50); int returnhere = 1; char * languagefile; languagefile = strrchr(Settings.language_path, '/')+1; - while(!exit) - { + while (!exit) { VIDEO_WaitVSync (); returnhere = 1; - if(Settings.sinfo >= settings_sinfo_max) + if (Settings.sinfo >= settings_sinfo_max) Settings.sinfo = 0; - if(Settings.hddinfo >= settings_clock_max) + if (Settings.hddinfo >= settings_clock_max) Settings.hddinfo = 0; //CLOCK if (Settings.tooltips >= settings_tooltips_max) Settings.tooltips = 0; @@ -518,13 +504,13 @@ int MenuSettings() Settings.keyset = 0; if ( Settings.wiilight > 2 ) Settings.wiilight = 0; - if(Settings.rumble >= settings_rumble_max) + if (Settings.rumble >= settings_rumble_max) Settings.rumble = 0; //RUMBLE - if(Settings.screensaver >= settings_screensaver_max) + if (Settings.screensaver >= settings_screensaver_max) Settings.screensaver = 0; //RUMBLE - if(Settings.titlesOverride >= 2) - Settings.titlesOverride = 0; - if(!strcmp("notset", Settings.language_path)) + if (Settings.titlesOverride >= 2) + Settings.titlesOverride = 0; + if (!strcmp("notset", Settings.language_path)) options2.SetValue(0, "%s", tr("Default")); else options2.SetValue(0, "%s", languagefile); @@ -569,49 +555,45 @@ int MenuSettings() if (Settings.titlesOverride == 0) options2.SetValue(10,"%s",tr("OFF")); else if (Settings.titlesOverride == 1) options2.SetValue(10,"%s",tr("ON")); - if (Settings.screensaver == 0) options2.SetValue(11,"%s",tr("OFF")); + if (Settings.screensaver == 0) options2.SetValue(11,"%s",tr("OFF")); else if (Settings.screensaver == 1) options2.SetValue(11,tr("3 min")); - else if (Settings.screensaver == 2) options2.SetValue(11,tr("5 min")); - else if (Settings.screensaver == 3) options2.SetValue(11,tr("10 min")); - else if (Settings.screensaver == 4) options2.SetValue(11,tr("20 min")); - else if (Settings.screensaver == 5) options2.SetValue(11,tr("30 min")); - else if (Settings.screensaver == 6) options2.SetValue(11,tr("1 hour")); + else if (Settings.screensaver == 2) options2.SetValue(11,tr("5 min")); + else if (Settings.screensaver == 3) options2.SetValue(11,tr("10 min")); + else if (Settings.screensaver == 4) options2.SetValue(11,tr("20 min")); + else if (Settings.screensaver == 5) options2.SetValue(11,tr("30 min")); + else if (Settings.screensaver == 6) options2.SetValue(11,tr("1 hour")); - if(backBtn.GetState() == STATE_CLICKED) - { + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); exit = true; - break; + break; } - if(shutdown == 1) + if (shutdown == 1) Sys_Shutdown(); - else if(reset == 1) + else if (reset == 1) Sys_Reboot(); - else if(menu == MENU_DISCLIST) { + else if (menu == MENU_DISCLIST) { w.Remove(&optionBrowser2); w.Remove(&backBtn); WindowCredits(); w.Append(&optionBrowser2); w.Append(&backBtn); - } - else if(homo.GetState() == STATE_CLICKED) - { + } else if (homo.GetState() == STATE_CLICKED) { cfg_save_global(); optionBrowser2.SetState(STATE_DISABLED); 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); } 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(); @@ -623,92 +605,90 @@ int MenuSettings() ret = optionBrowser2.GetClickedOption(); - switch (ret) - { - case 0: - //if(isSdInserted()) { - if(isInserted(bootDevice)) { - if ( Settings.godmode == 1) - { + switch (ret) { + case 0: + //if(isSdInserted()) { + if (isInserted(bootDevice)) { + if ( Settings.godmode == 1) { w.SetEffect(EFFECT_FADE, -20); - while(w.GetEffect()>0) usleep(50); + while (w.GetEffect()>0) usleep(50); mainWindow->Remove(&w); - while(returnhere == 1) - returnhere = MenuLanguageSelect(); - if(returnhere == 2) { + while (returnhere == 1) + returnhere = MenuLanguageSelect(); + if (returnhere == 2) { menu = MENU_SETTINGS; pageToDisplay = 0; exit = true; mainWindow->Append(&w); break; } else { - HaltGui(); - mainWindow->Append(&w); - w.SetEffect(EFFECT_FADE, 20); - ResumeGui(); - while(w.GetEffect()>0) usleep(50); + HaltGui(); + mainWindow->Append(&w); + w.SetEffect(EFFECT_FADE, 20); + ResumeGui(); + while (w.GetEffect()>0) usleep(50); } } else { WindowPrompt(tr("Language change:"),tr("Console should be unlocked to modify it."),tr("OK")); } - } else { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to use this option."), tr("OK")); - } - break; - case 1: - Settings.sinfo++; - break; - case 2: - Settings.hddinfo++; - break; - case 3: - Settings.tooltips++; - break; - case 4: - Settings.xflip++; - break; - case 5: - Settings.wsprompt++; - break; - case 6: - Settings.keyset++; - break; - case 7: - Settings.wiilight++; - break; - case 8: - Settings.rumble++; - break; - case 9: - Settings.autonetwork++; - if(Settings.autonetwork > 1) - Settings.autonetwork = 0; - break; - case 10: - Settings.titlesOverride++; - break; - case 11: - Settings.screensaver++; - break; + } else { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to use this option."), tr("OK")); + } + break; + case 1: + Settings.sinfo++; + break; + case 2: + Settings.hddinfo++; + break; + case 3: + Settings.tooltips++; + break; + case 4: + Settings.xflip++; + break; + case 5: + Settings.wsprompt++; + break; + case 6: + Settings.keyset++; + break; + case 7: + Settings.wiilight++; + break; + case 8: + Settings.rumble++; + break; + case 9: + Settings.autonetwork++; + if (Settings.autonetwork > 1) + Settings.autonetwork = 0; + break; + case 10: + Settings.titlesOverride++; + break; + case 11: + Settings.screensaver++; + break; - } + } } optionBrowser2.SetEffect(EFFECT_FADE, -20); - while(optionBrowser2.GetEffect() > 0) usleep(50); + while (optionBrowser2.GetEffect() > 0) usleep(50); titleTxt.SetText(tr("Settings")); slidedirection = FADE; - if(returnhere != 2) - pageToDisplay = 1; + if (returnhere != 2) + pageToDisplay = 1; MainButton1.ResetState(); break; } - if(MainButton2.GetState() == STATE_CLICKED) { + if (MainButton2.GetState() == STATE_CLICKED) { MainButton1.SetEffect(EFFECT_FADE, -20); MainButton2.SetEffect(EFFECT_FADE, -20); MainButton3.SetEffect(EFFECT_FADE, -20); MainButton4.SetEffect(EFFECT_FADE, -20); - while(MainButton2.GetEffect() > 0) usleep(50); + while (MainButton2.GetEffect() > 0) usleep(50); HaltGui(); w.Remove(&PageIndicatorBtn1); w.Remove(&PageIndicatorBtn2); @@ -720,7 +700,7 @@ int MenuSettings() w.Remove(&MainButton4); titleTxt.SetText(tr("Game Load")); exit = false; - for(int i = 0; i <= MAXOPTIONS; i++) options2.SetName(i, NULL); + for (int i = 0; i <= MAXOPTIONS; i++) options2.SetName(i, NULL); options2.SetName(0, "%s",tr("Video Mode")); options2.SetName(1, "%s",tr("VIDTV Patch")); options2.SetName(2, "%s",tr("Game Language")); @@ -729,25 +709,24 @@ int MenuSettings() options2.SetName(5,"%s", tr("Boot/Standard")); options2.SetName(6, "%s",tr("Quick Boot")); options2.SetName(7, "%s",tr("Error 002 fix")); - for(int i = 0; i <= MAXOPTIONS; i++) options2.SetValue(i, NULL); + for (int i = 0; i <= MAXOPTIONS; i++) options2.SetValue(i, NULL); w.Append(&optionBrowser2); optionBrowser2.SetClickable(true); ResumeGui(); VIDEO_WaitVSync (); optionBrowser2.SetEffect(EFFECT_FADE, 20); - while(optionBrowser2.GetEffect() > 0) usleep(50); + while (optionBrowser2.GetEffect() > 0) usleep(50); - while(!exit) - { + while (!exit) { VIDEO_WaitVSync (); - if(Settings.video >= settings_video_max) + if (Settings.video >= settings_video_max) Settings.video = 0; - if(Settings.vpatch >= settings_off_on_max) + if (Settings.vpatch >= settings_off_on_max) Settings.vpatch = 0; if ( Settings.patchcountrystrings > 1) Settings.patchcountrystrings = 0; - if(Settings.ocarina >= settings_off_on_max) + if (Settings.ocarina >= settings_off_on_max) Settings.ocarina = 0; if ( Settings.qboot > 1 ) Settings.qboot = 0; @@ -755,7 +734,7 @@ int MenuSettings() Settings.cios = 0; if ( Settings.language >= settings_language_max) Settings.language = 0; - if(Settings.error002 >= settings_off_on_max+1) + if (Settings.error002 >= settings_off_on_max+1) Settings.error002 = 0; if (Settings.video == discdefault) options2.SetValue(0,"%s",tr("Disc Default")); @@ -786,7 +765,7 @@ int MenuSettings() if (Settings.ocarina == on) options2.SetValue(4,"%s",tr("ON")); else if (Settings.ocarina == off) options2.SetValue(4,"%s",tr("OFF")); - if (Settings.godmode != 1) options2.SetValue(5, "********"); + if (Settings.godmode != 1) options2.SetValue(5, "********"); else if (Settings.cios == ios249) options2.SetValue(5,"cIOS 249"); else if (Settings.cios == ios222) options2.SetValue(5,"cIOS 222"); @@ -795,36 +774,33 @@ int MenuSettings() if (Settings.error002 == no) options2.SetValue(7,"%s",tr("No")); else if (Settings.error002 == yes) options2.SetValue(7,"%s",tr("Yes")); - else if (Settings.error002 == anti) options2.SetValue(7,"%s",tr("Anti")); + else if (Settings.error002 == anti) options2.SetValue(7,"%s",tr("Anti")); - if(backBtn.GetState() == STATE_CLICKED) - { + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); exit = true; break; } - if(shutdown == 1) + if (shutdown == 1) Sys_Shutdown(); - else if(reset == 1) + else if (reset == 1) Sys_Reboot(); - else if(homo.GetState() == STATE_CLICKED) - { + else if (homo.GetState() == STATE_CLICKED) { cfg_save_global(); optionBrowser2.SetState(STATE_DISABLED); 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); } 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(); @@ -836,38 +812,37 @@ int MenuSettings() ret = optionBrowser2.GetClickedOption(); - switch (ret) - { - case 0: - Settings.video++; - break; - case 1: - Settings.vpatch++; - break; - case 2: - Settings.language++; - break; - case 3: - Settings.patchcountrystrings++; - break; - case 4: - Settings.ocarina++; - break; - case 5: - if(Settings.godmode) + switch (ret) { + case 0: + Settings.video++; + break; + case 1: + Settings.vpatch++; + break; + case 2: + Settings.language++; + break; + case 3: + Settings.patchcountrystrings++; + break; + case 4: + Settings.ocarina++; + break; + case 5: + if (Settings.godmode) Settings.cios++; - break; - case 6: - Settings.qboot++; - break; - case 7: - Settings.error002++; - break; + break; + case 6: + Settings.qboot++; + break; + case 7: + Settings.error002++; + break; } } optionBrowser2.SetEffect(EFFECT_FADE, -20); - while(optionBrowser2.GetEffect() > 0) usleep(50); + while (optionBrowser2.GetEffect() > 0) usleep(50); titleTxt.SetText(tr("Settings")); slidedirection = FADE; pageToDisplay = 1; @@ -875,12 +850,12 @@ int MenuSettings() break; } - if(MainButton3.GetState() == STATE_CLICKED) { + if (MainButton3.GetState() == STATE_CLICKED) { MainButton1.SetEffect(EFFECT_FADE, -20); MainButton2.SetEffect(EFFECT_FADE, -20); MainButton3.SetEffect(EFFECT_FADE, -20); MainButton4.SetEffect(EFFECT_FADE, -20); - while(MainButton3.GetEffect() > 0) usleep(50); + while (MainButton3.GetEffect() > 0) usleep(50); HaltGui(); w.Remove(&PageIndicatorBtn1); w.Remove(&PageIndicatorBtn2); @@ -892,68 +867,64 @@ int MenuSettings() w.Remove(&MainButton4); titleTxt.SetText(tr("Parental Control")); exit = false; - for(int i = 0; i <= MAXOPTIONS; i++) options2.SetName(i, NULL); + for (int i = 0; i <= MAXOPTIONS; i++) options2.SetName(i, NULL); options2.SetName(0, "%s",tr("Console")); options2.SetName(1, "%s",tr("Password")); options2.SetName(2, "%s",tr("Controllevel")); - for(int i = 0; i <= MAXOPTIONS; i++) options2.SetValue(i, NULL); + for (int i = 0; i <= MAXOPTIONS; i++) options2.SetValue(i, NULL); w.Append(&optionBrowser2); optionBrowser2.SetClickable(true); ResumeGui(); VIDEO_WaitVSync (); optionBrowser2.SetEffect(EFFECT_FADE, 20); - while(optionBrowser2.GetEffect() > 0) usleep(50); + while (optionBrowser2.GetEffect() > 0) usleep(50); - while(!exit) - { + while (!exit) { VIDEO_WaitVSync (); if (Settings.parentalcontrol > 4 ) Settings.parentalcontrol = 0; - if( Settings.godmode == 1 ) options2.SetValue(0, tr("Unlocked")); - else if( Settings.godmode == 0 ) options2.SetValue(0, tr("Locked")); + if ( Settings.godmode == 1 ) options2.SetValue(0, tr("Unlocked")); + else if ( Settings.godmode == 0 ) options2.SetValue(0, tr("Locked")); if ( Settings.godmode != 1) options2.SetValue(1, "********"); else if (!strcmp("", Settings.unlockCode)) options2.SetValue(1, "%s",tr("not set")); else options2.SetValue(1, Settings.unlockCode); if (Settings.godmode != 1) options2.SetValue(2, "********"); - else if(Settings.parentalcontrol == 0) options2.SetValue(2, tr("OFF")); - else if(Settings.parentalcontrol == 1) options2.SetValue(2, tr("1 (Child 7+)")); - else if(Settings.parentalcontrol == 2) options2.SetValue(2, tr("2 (Teen 12+)")); - else if(Settings.parentalcontrol == 3) options2.SetValue(2, tr("3 (Mature 16+)")); - else if(Settings.parentalcontrol == 4) options2.SetValue(2, tr("4 (Adults Only 18+)")); + else if (Settings.parentalcontrol == 0) options2.SetValue(2, tr("OFF")); + else if (Settings.parentalcontrol == 1) options2.SetValue(2, tr("1 (Child 7+)")); + else if (Settings.parentalcontrol == 2) options2.SetValue(2, tr("2 (Teen 12+)")); + else if (Settings.parentalcontrol == 3) options2.SetValue(2, tr("3 (Mature 16+)")); + else if (Settings.parentalcontrol == 4) options2.SetValue(2, tr("4 (Adults Only 18+)")); - if(backBtn.GetState() == STATE_CLICKED) - { + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); exit = true; break; } - if(shutdown == 1) + if (shutdown == 1) Sys_Shutdown(); - else if(reset == 1) + else if (reset == 1) Sys_Reboot(); - else if(homo.GetState() == STATE_CLICKED) - { + else if (homo.GetState() == STATE_CLICKED) { cfg_save_global(); optionBrowser2.SetState(STATE_DISABLED); 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); } 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(); @@ -965,71 +936,66 @@ int MenuSettings() ret = optionBrowser2.GetClickedOption(); - switch (ret) - { - case 0: - if (!strcmp("", Settings.unlockCode)) - { - Settings.godmode = !Settings.godmode; - break; - } - else if ( Settings.godmode == 0 ) { - //password check to unlock Install,Delete and Format - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - char entered[20] = ""; - int result = OnScreenKeyboard(entered, 20,0); - w.Append(&optionBrowser2); - w.Append(&backBtn); - if ( result == 1 ) { - if (!strcmp(entered, Settings.unlockCode)) //if password correct - { - if (Settings.godmode == 0) { - WindowPrompt(tr("Correct Password"),tr("All the features of USB Loader GX are unlocked."),tr("OK")); - Settings.godmode = 1; - //__Menu_GetEntries(); - menu = MENU_DISCLIST; - } - } else { - WindowPrompt(tr("Wrong Password"),tr("USB Loader GX is protected"),tr("OK")); + switch (ret) { + case 0: + if (!strcmp("", Settings.unlockCode)) { + Settings.godmode = !Settings.godmode; + break; + } else if ( Settings.godmode == 0 ) { + //password check to unlock Install,Delete and Format + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[20] = ""; + int result = OnScreenKeyboard(entered, 20,0); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) { + if (!strcmp(entered, Settings.unlockCode)) { //if password correct + if (Settings.godmode == 0) { + WindowPrompt(tr("Correct Password"),tr("All the features of USB Loader GX are unlocked."),tr("OK")); + Settings.godmode = 1; + //__Menu_GetEntries(); + menu = MENU_DISCLIST; } - } - } else { - int choice = WindowPrompt (tr("Lock Console"),tr("Are you sure?"),tr("Yes"),tr("No")); - if(choice == 1) { - WindowPrompt(tr("Console Locked"),tr("USB Loader GX is protected"),tr("OK")); - Settings.godmode = 0; - //__Menu_GetEntries(); - menu = MENU_DISCLIST; + } else { + WindowPrompt(tr("Wrong Password"),tr("USB Loader GX is protected"),tr("OK")); } } - break; - case 1:// Modify Password - if ( Settings.godmode == 1) - { - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - char entered[20] = ""; - strncpy(entered, Settings.unlockCode, sizeof(entered)); - int result = OnScreenKeyboard(entered, 20,0); - w.Append(&optionBrowser2); - w.Append(&backBtn); - if ( result == 1 ) { - strncpy(Settings.unlockCode, entered, sizeof(Settings.unlockCode)); - WindowPrompt(tr("Password Changed"),tr("Password has been changed"),tr("OK")); - } - } else { - WindowPrompt(tr("Password Changed"),tr("Console should be unlocked to modify it."),tr("OK")); + } else { + int choice = WindowPrompt (tr("Lock Console"),tr("Are you sure?"),tr("Yes"),tr("No")); + if (choice == 1) { + WindowPrompt(tr("Console Locked"),tr("USB Loader GX is protected"),tr("OK")); + Settings.godmode = 0; + //__Menu_GetEntries(); + menu = MENU_DISCLIST; } - break; - case 2: - if(Settings.godmode) + } + break; + case 1:// Modify Password + if ( Settings.godmode == 1) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[20] = ""; + strncpy(entered, Settings.unlockCode, sizeof(entered)); + int result = OnScreenKeyboard(entered, 20,0); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) { + strncpy(Settings.unlockCode, entered, sizeof(Settings.unlockCode)); + WindowPrompt(tr("Password Changed"),tr("Password has been changed"),tr("OK")); + } + } else { + WindowPrompt(tr("Password Changed"),tr("Console should be unlocked to modify it."),tr("OK")); + } + break; + case 2: + if (Settings.godmode) Settings.parentalcontrol++; - break; + break; } } optionBrowser2.SetEffect(EFFECT_FADE, -20); - while(optionBrowser2.GetEffect() > 0) usleep(50); + while (optionBrowser2.GetEffect() > 0) usleep(50); titleTxt.SetText(tr("Settings")); slidedirection = FADE; pageToDisplay = 1; @@ -1037,12 +1003,12 @@ int MenuSettings() break; } - if(MainButton4.GetState() == STATE_CLICKED) { + if (MainButton4.GetState() == STATE_CLICKED) { MainButton1.SetEffect(EFFECT_FADE, -20); MainButton2.SetEffect(EFFECT_FADE, -20); MainButton3.SetEffect(EFFECT_FADE, -20); MainButton4.SetEffect(EFFECT_FADE, -20); - while(MainButton4.GetEffect() > 0) usleep(50); + while (MainButton4.GetEffect() > 0) usleep(50); HaltGui(); w.Remove(&PageIndicatorBtn1); w.Remove(&PageIndicatorBtn2); @@ -1054,72 +1020,68 @@ int MenuSettings() w.Remove(&MainButton4); titleTxt.SetText(tr("Sound")); exit = false; - for(int i = 0; i <= MAXOPTIONS; i++) options2.SetName(i, NULL); + for (int i = 0; i <= MAXOPTIONS; i++) options2.SetName(i, NULL); options2.SetName(0, "%s",tr("Backgroundmusic")); options2.SetName(1, "%s",tr("Music Volume")); options2.SetName(2, "%s",tr("SFX Volume")); - for(int i = 0; i <= MAXOPTIONS; i++) options2.SetValue(i, NULL); + for (int i = 0; i <= MAXOPTIONS; i++) options2.SetValue(i, NULL); w.Append(&optionBrowser2); optionBrowser2.SetClickable(true); ResumeGui(); VIDEO_WaitVSync (); optionBrowser2.SetEffect(EFFECT_FADE, 20); - while(optionBrowser2.GetEffect() > 0) usleep(50); + while (optionBrowser2.GetEffect() > 0) usleep(50); char * oggfile; - while(!exit) - { + while (!exit) { VIDEO_WaitVSync (); bool returnhere = true; - if(!strcmp("notset", Settings.ogg_path)) + if (!strcmp("notset", Settings.ogg_path)) options2.SetValue(0, "%s", tr("Standard")); else { oggfile = strrchr(Settings.ogg_path, '/')+1; options2.SetValue(0, "%s", oggfile); } - if(Settings.volume > 0) - options2.SetValue(1,"%i", Settings.volume); + if (Settings.volume > 0) + options2.SetValue(1,"%i", Settings.volume); else - options2.SetValue(1,"%s", tr("OFF")); - if(Settings.sfxvolume > 0) - options2.SetValue(2,"%i", Settings.sfxvolume); + options2.SetValue(1,"%s", tr("OFF")); + if (Settings.sfxvolume > 0) + options2.SetValue(2,"%i", Settings.sfxvolume); else - options2.SetValue(2,"%s", tr("OFF")); + options2.SetValue(2,"%s", tr("OFF")); - if(backBtn.GetState() == STATE_CLICKED) - { + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); exit = true; break; } - if(shutdown == 1) + if (shutdown == 1) Sys_Shutdown(); - else if(reset == 1) + else if (reset == 1) Sys_Reboot(); - else if(homo.GetState() == STATE_CLICKED) - { + else if (homo.GetState() == STATE_CLICKED) { cfg_save_global(); optionBrowser2.SetState(STATE_DISABLED); 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); } 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(); @@ -1131,60 +1093,56 @@ int MenuSettings() ret = optionBrowser2.GetClickedOption(); - switch (ret) - { - case 0: - //if(isSdInserted()) - if(isInserted(bootDevice)) - { - w.SetEffect(EFFECT_FADE, -20); - while(w.GetEffect()>0) usleep(50); - mainWindow->Remove(&w); - while(returnhere) - returnhere = MenuOGG(); - HaltGui(); - mainWindow->Append(&w); - w.SetEffect(EFFECT_FADE, 20); - ResumeGui(); - while(w.GetEffect()>0) usleep(50); - } - else - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to use this option."), tr("OK")); - break; - case 1: - Settings.volume += 10; - if(Settings.volume > 100) - Settings.volume = 0; - SetVolumeOgg(255*(Settings.volume/100.0)); - break; - case 2: - Settings.sfxvolume += 10; - if(Settings.sfxvolume > 100) - Settings.sfxvolume = 0; - btnSoundOver.SetVolume(Settings.sfxvolume); - btnClick.SetVolume(Settings.sfxvolume); - btnClick1.SetVolume(Settings.sfxvolume); - break; + switch (ret) { + case 0: + //if(isSdInserted()) + if (isInserted(bootDevice)) { + w.SetEffect(EFFECT_FADE, -20); + while (w.GetEffect()>0) usleep(50); + mainWindow->Remove(&w); + while (returnhere) + returnhere = MenuOGG(); + HaltGui(); + mainWindow->Append(&w); + w.SetEffect(EFFECT_FADE, 20); + ResumeGui(); + while (w.GetEffect()>0) usleep(50); + } else + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to use this option."), tr("OK")); + break; + case 1: + Settings.volume += 10; + if (Settings.volume > 100) + Settings.volume = 0; + SetVolumeOgg(255*(Settings.volume/100.0)); + break; + case 2: + Settings.sfxvolume += 10; + if (Settings.sfxvolume > 100) + Settings.sfxvolume = 0; + btnSoundOver.SetVolume(Settings.sfxvolume); + btnClick.SetVolume(Settings.sfxvolume); + btnClick1.SetVolume(Settings.sfxvolume); + break; } } optionBrowser2.SetEffect(EFFECT_FADE, -20); - while(optionBrowser2.GetEffect() > 0) usleep(50); + while (optionBrowser2.GetEffect() > 0) usleep(50); titleTxt.SetText(tr("Settings")); slidedirection = FADE; pageToDisplay = 1; MainButton4.ResetState(); break; } - } + } - if ( pageToDisplay == 2) - { - if(MainButton1.GetState() == STATE_CLICKED) { + if ( pageToDisplay == 2) { + if (MainButton1.GetState() == STATE_CLICKED) { MainButton1.SetEffect(EFFECT_FADE, -20); MainButton2.SetEffect(EFFECT_FADE, -20); MainButton3.SetEffect(EFFECT_FADE, -20); MainButton4.SetEffect(EFFECT_FADE, -20); - while(MainButton1.GetEffect() > 0) usleep(50); + while (MainButton1.GetEffect() > 0) usleep(50); HaltGui(); w.Remove(&PageIndicatorBtn1); w.Remove(&PageIndicatorBtn2); @@ -1196,106 +1154,99 @@ int MenuSettings() w.Remove(&MainButton4); titleTxt.SetText(tr("Custom Paths")); exit = false; - for(int i = 0; i <= MAXOPTIONS; i++) options2.SetName(i, NULL); - if(Settings.godmode) - options2.SetName(0, "%s", tr("Cover Path")); + for (int i = 0; i <= MAXOPTIONS; i++) options2.SetName(i, NULL); + if (Settings.godmode) + options2.SetName(0, "%s", tr("Cover Path")); options2.SetName(1, "%s", tr("Discimage Path")); options2.SetName(2, "%s", tr("ThemePath")); options2.SetName(3, "%s", tr("XMLPath")); options2.SetName(4, "%s", tr("Updatepath")); options2.SetName(5, "%s", tr("Cheatcodes Path")); - options2.SetName(6, "%s", tr("TXTCheatcodes Path")); + options2.SetName(6, "%s", tr("TXTCheatcodes Path")); options2.SetName(7, "%s", tr("Dol Path")); options2.SetName(8, "%s", tr("Homebrew Apps Path")); - for(int i = 0; i <= MAXOPTIONS; i++) options2.SetValue(i, NULL); + for (int i = 0; i <= MAXOPTIONS; i++) options2.SetValue(i, NULL); w.Append(&optionBrowser2); optionBrowser2.SetClickable(true); ResumeGui(); VIDEO_WaitVSync (); optionBrowser2.SetEffect(EFFECT_FADE, 20); - while(optionBrowser2.GetEffect() > 0) usleep(50); + while (optionBrowser2.GetEffect() > 0) usleep(50); - if(Settings.godmode) { + if (Settings.godmode) { - while(!exit) - { - VIDEO_WaitVSync (); + while (!exit) { + VIDEO_WaitVSync (); - options2.SetValue(0, "%s", Settings.covers_path); - options2.SetValue(1, "%s", Settings.disc_path); - options2.SetValue(2, "%s", CFG.theme_path); - options2.SetValue(3, "%s", Settings.titlestxt_path); - options2.SetValue(4, "%s", Settings.update_path); - options2.SetValue(5, "%s", Settings.Cheatcodespath); - options2.SetValue(6, "%s", Settings.TxtCheatcodespath); - options2.SetValue(7, "%s", Settings.dolpath); - options2.SetValue(8, "%s", Settings.homebrewapps_path); + options2.SetValue(0, "%s", Settings.covers_path); + options2.SetValue(1, "%s", Settings.disc_path); + options2.SetValue(2, "%s", CFG.theme_path); + options2.SetValue(3, "%s", Settings.titlestxt_path); + options2.SetValue(4, "%s", Settings.update_path); + options2.SetValue(5, "%s", Settings.Cheatcodespath); + options2.SetValue(6, "%s", Settings.TxtCheatcodespath); + options2.SetValue(7, "%s", Settings.dolpath); + options2.SetValue(8, "%s", Settings.homebrewapps_path); - if(backBtn.GetState() == STATE_CLICKED) - { - backBtn.ResetState(); - exit = true; - break; - } - - if(shutdown == 1) - Sys_Shutdown(); - else if(reset == 1) - Sys_Reboot(); - - else if(homo.GetState() == STATE_CLICKED) - { - cfg_save_global(); - optionBrowser2.SetState(STATE_DISABLED); - 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)) - { - bgMusic->Play(); - } else { - bgMusic->PlayOggFile(Settings.ogg_path); + if (backBtn.GetState() == STATE_CLICKED) { + backBtn.ResetState(); + exit = true; + break; } - bgMusic->SetPlayTime(thetimeofbg); - SetVolumeOgg(255*(Settings.volume/100.0)); - if(choice == 3) { - Sys_LoadMenu(); // Back to System Menu - } else if (choice == 2) { - Sys_BackToLoader(); - } else { - homo.ResetState(); + + if (shutdown == 1) + Sys_Shutdown(); + else if (reset == 1) + Sys_Reboot(); + + else if (homo.GetState() == STATE_CLICKED) { + cfg_save_global(); + optionBrowser2.SetState(STATE_DISABLED); + 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)) { + bgMusic->Play(); + } else { + bgMusic->PlayOggFile(Settings.ogg_path); + } + bgMusic->SetPlayTime(thetimeofbg); + SetVolumeOgg(255*(Settings.volume/100.0)); + if (choice == 3) { + Sys_LoadMenu(); // Back to System Menu + } else if (choice == 2) { + Sys_BackToLoader(); + } else { + homo.ResetState(); + } + optionBrowser2.SetState(STATE_DEFAULT); } - optionBrowser2.SetState(STATE_DEFAULT); - } - ret = optionBrowser2.GetClickedOption(); + ret = optionBrowser2.GetClickedOption(); - switch (ret) - { + switch (ret) { case 0: - if ( Settings.godmode == 1) - { + if ( Settings.godmode == 1) { w.Remove(&optionBrowser2); w.Remove(&backBtn); char entered[43] = ""; strncpy(entered, Settings.covers_path, sizeof(entered)); titleTxt.SetText(tr("Cover Path")); - int result = BrowseDevice(entered); + int result = BrowseDevice(entered); //int result = OnScreenKeyboard(entered,43,0); titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); + w.Append(&optionBrowser2); w.Append(&backBtn); - if ( result == 1 ) - { + if ( result == 1 ) { int len = (strlen(entered)-1); - if(entered[len] !='/') - strncat (entered, "/", 1); + if (entered[len] !='/') + strncat (entered, "/", 1); strncpy(Settings.covers_path, entered, sizeof(Settings.covers_path)); WindowPrompt(tr("Coverpath Changed"),0,tr("OK")); // if(!isSdInserted()) { - if(!isInserted(bootDevice)) { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); + if (!isInserted(bootDevice)) { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); } } } else { @@ -1303,27 +1254,25 @@ int MenuSettings() } break; case 1: - if ( Settings.godmode == 1) - { + if ( Settings.godmode == 1) { w.Remove(&optionBrowser2); w.Remove(&backBtn); char entered[43] = ""; strncpy(entered, Settings.disc_path, sizeof(entered)); titleTxt.SetText(tr("Discimage Path")); - int result = BrowseDevice(entered); + int result = BrowseDevice(entered); //int result = OnScreenKeyboard(entered, 43,0); titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); + w.Append(&optionBrowser2); w.Append(&backBtn); - if ( result == 1 ) - { + if ( result == 1 ) { int len = (strlen(entered)-1); - if(entered[len] !='/') - strncat (entered, "/", 1); + if (entered[len] !='/') + strncat (entered, "/", 1); strncpy(Settings.disc_path, entered, sizeof(Settings.disc_path)); WindowPrompt(tr("Discpath Changed"),0,tr("OK")); // if(!isSdInserted()) { - if(!isInserted(bootDevice)) { + if (!isInserted(bootDevice)) { WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); } } @@ -1332,26 +1281,24 @@ int MenuSettings() } break; case 2: - if ( Settings.godmode == 1) - { + if ( Settings.godmode == 1) { w.Remove(&optionBrowser2); w.Remove(&backBtn); char entered[43] = ""; titleTxt.SetText(tr("ThemePath")); - strncpy(entered, CFG.theme_path, sizeof(entered)); + strncpy(entered, CFG.theme_path, sizeof(entered)); int result = BrowseDevice(entered); //int result = OnScreenKeyboard(entered, 43,0); HaltGui(); w.RemoveAll(); - if ( result == 1 ) - { + if ( result == 1 ) { int len = (strlen(entered)-1); - if(entered[len] !='/') - strncat (entered, "/", 1); + if (entered[len] !='/') + strncat (entered, "/", 1); strncpy(CFG.theme_path, entered, sizeof(CFG.theme_path)); WindowPrompt(tr("Themepath Changed"),0,tr("OK")); // if(!isSdInserted()) { - if(!isInserted(bootDevice)) { + if (!isInserted(bootDevice)) { WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); } else { cfg_save_global(); @@ -1360,7 +1307,7 @@ int MenuSettings() CFG_Load(); CFG_LoadGlobal(); menu = MENU_SETTINGS; - #ifdef HW_RVL +#ifdef HW_RVL snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); pointer[0] = new GuiImageData(imgPath, player1_point_png); snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path); @@ -1369,11 +1316,11 @@ int MenuSettings() pointer[2] = new GuiImageData(imgPath, player3_point_png); snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); pointer[3] = new GuiImageData(imgPath, player4_point_png); - #endif +#endif if (CFG.widescreen) - snprintf(imgPath, sizeof(imgPath), "%swbackground.png", CFG.theme_path); - else - snprintf(imgPath, sizeof(imgPath), "%sbackground.png", CFG.theme_path); + snprintf(imgPath, sizeof(imgPath), "%swbackground.png", CFG.theme_path); + else + snprintf(imgPath, sizeof(imgPath), "%sbackground.png", CFG.theme_path); background = new GuiImageData(imgPath, CFG.widescreen? wbackground_png : background_png); @@ -1384,7 +1331,7 @@ int MenuSettings() w.Append(&settingsbackground); w.Append(&titleTxt); titleTxt.SetText(tr("Custom Paths")); - w.Append(&backBtn); + w.Append(&backBtn); w.Append(&optionBrowser2); ResumeGui(); } else { @@ -1392,137 +1339,122 @@ int MenuSettings() } break; case 3: - if ( Settings.godmode == 1) - { + if ( Settings.godmode == 1) { w.Remove(&optionBrowser2); w.Remove(&backBtn); char entered[43] = ""; titleTxt.SetText(tr("XMLPath")); - strncpy(entered, Settings.titlestxt_path, sizeof(entered)); + strncpy(entered, Settings.titlestxt_path, sizeof(entered)); int result = BrowseDevice(entered); //int result = OnScreenKeyboard(entered,43,0); w.Append(&optionBrowser2); titleTxt.SetText(tr("Custom Paths")); - w.Append(&backBtn); - if ( result == 1 ) - { + w.Append(&backBtn); + if ( result == 1 ) { int len = (strlen(entered)-1); - if(entered[len] !='/') - strncat (entered, "/", 1); + if (entered[len] !='/') + strncat (entered, "/", 1); strncpy(Settings.titlestxt_path, entered, sizeof(Settings.titlestxt_path)); WindowPrompt(tr("XMLPath changed."),0,tr("OK")); // if(isSdInserted()) { - if(isInserted(bootDevice)) { + if (isInserted(bootDevice)) { cfg_save_global(); CFG_Load(); } else { WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); } } - } - else - { + } else { WindowPrompt(tr("XMLPath change"),tr("Console should be unlocked to modify it."),tr("OK")); } break; case 4: - if ( Settings.godmode == 1) - { + if ( Settings.godmode == 1) { w.Remove(&optionBrowser2); w.Remove(&backBtn); char entered[43] = ""; strncpy(entered, Settings.update_path, sizeof(entered)); titleTxt.SetText(tr("Updatepath")); - int result = BrowseDevice(entered); + int result = BrowseDevice(entered); //int result = OnScreenKeyboard(entered,43,0); titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); + w.Append(&optionBrowser2); w.Append(&backBtn); - if ( result == 1 ) - { + if ( result == 1 ) { int len = (strlen(entered)-1); - if(entered[len] !='/') - strncat (entered, "/", 1); + if (entered[len] !='/') + strncat (entered, "/", 1); strncpy(Settings.update_path, entered, sizeof(Settings.update_path)); WindowPrompt(tr("Updatepath changed."),0,tr("OK")); } - } - else + } else WindowPrompt(0,tr("Console should be unlocked to modify it."),tr("OK")); break; case 5: - if ( Settings.godmode == 1) - { + if ( Settings.godmode == 1) { w.Remove(&optionBrowser2); w.Remove(&backBtn); char entered[43] = ""; strncpy(entered, Settings.Cheatcodespath, sizeof(entered)); titleTxt.SetText(tr("Cheatcodes Path")); - int result = BrowseDevice(entered); + int result = BrowseDevice(entered); //int result = OnScreenKeyboard(entered,43,0); titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); + w.Append(&optionBrowser2); w.Append(&backBtn); - if ( result == 1 ) - { + if ( result == 1 ) { int len = (strlen(entered)-1); - if(entered[len] !='/') - strncat (entered, "/", 1); + if (entered[len] !='/') + strncat (entered, "/", 1); strncpy(Settings.Cheatcodespath, entered, sizeof(Settings.Cheatcodespath)); WindowPrompt(tr("Cheatcodes Path changed"),0,tr("OK")); } - } - else + } else WindowPrompt(0,tr("Console should be unlocked to modify it."),tr("OK")); break; - case 6: - if ( Settings.godmode == 1) - { + case 6: + if ( Settings.godmode == 1) { w.Remove(&optionBrowser2); w.Remove(&backBtn); char entered[43] = ""; strncpy(entered, Settings.TxtCheatcodespath, sizeof(entered)); titleTxt.SetText(tr("TXTCheatcodes Path")); - int result = BrowseDevice(entered); + int result = BrowseDevice(entered); //int result = OnScreenKeyboard(entered,43,0); titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); + w.Append(&optionBrowser2); w.Append(&backBtn); - if ( result == 1 ) - { + if ( result == 1 ) { int len = (strlen(entered)-1); - if(entered[len] !='/') - strncat (entered, "/", 1); + if (entered[len] !='/') + strncat (entered, "/", 1); strncpy(Settings.TxtCheatcodespath, entered, sizeof(Settings.TxtCheatcodespath)); WindowPrompt(tr("TXTCheatcodes Path changed"),0,tr("OK")); } - } - else + } else WindowPrompt(0,tr("Console should be unlocked to modify it."),tr("OK")); break; - case 7: - if ( Settings.godmode == 1) - { + case 7: + if ( Settings.godmode == 1) { w.Remove(&optionBrowser2); w.Remove(&backBtn); char entered[43] = ""; strncpy(entered, Settings.dolpath, sizeof(entered)); titleTxt.SetText(tr("Dol Path")); - int result = BrowseDevice(entered); + int result = BrowseDevice(entered); //int result = OnScreenKeyboard(entered,43,0); titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); + w.Append(&optionBrowser2); w.Append(&backBtn); - if ( result == 1 ) - { + if ( result == 1 ) { int len = (strlen(entered)-1); - if(entered[len] !='/') - strncat (entered, "/", 1); + if (entered[len] !='/') + strncat (entered, "/", 1); strncpy(Settings.dolpath, entered, sizeof(Settings.dolpath)); WindowPrompt(tr("Dolpath Changed"),0,tr("OK")); // if(!isSdInserted()) { - if(!isInserted(bootDevice)) { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); + if (!isInserted(bootDevice)) { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); } } } else { @@ -1530,28 +1462,26 @@ int MenuSettings() } break; case 8: - if ( Settings.godmode == 1) - { + if ( Settings.godmode == 1) { w.Remove(&optionBrowser2); w.Remove(&backBtn); char entered[43] = ""; strncpy(entered, Settings.homebrewapps_path, sizeof(entered)); titleTxt.SetText(tr("Homebrew Apps Path")); - int result = BrowseDevice(entered); + int result = BrowseDevice(entered); //int result = OnScreenKeyboard(entered,43,0); titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); + w.Append(&optionBrowser2); w.Append(&backBtn); - if ( result == 1 ) - { + if ( result == 1 ) { int len = (strlen(entered)-1); - if(entered[len] !='/') - strncat (entered, "/", 1); + if (entered[len] !='/') + strncat (entered, "/", 1); strncpy(Settings.homebrewapps_path, entered, sizeof(Settings.homebrewapps_path)); WindowPrompt(tr("Homebrew Appspath changed"),0,tr("OK")); // if(!isSdInserted()) { - if(!isInserted(bootDevice)) { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); + if (!isInserted(bootDevice)) { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); } } } else { @@ -1559,14 +1489,14 @@ int MenuSettings() } break; + } } - } - /** If not godmode don't let him inside **/ + /** If not godmode don't let him inside **/ } else { WindowPrompt(tr("Console Locked"), tr("Unlock console to use this option."), tr("OK")); } optionBrowser2.SetEffect(EFFECT_FADE, -20); - while(optionBrowser2.GetEffect() > 0) usleep(50); + while (optionBrowser2.GetEffect() > 0) usleep(50); titleTxt.SetText(tr("Settings")); slidedirection = FADE; pageToDisplay = 2; @@ -1574,12 +1504,12 @@ int MenuSettings() break; } - if(MainButton2.GetState() == STATE_CLICKED) { + if (MainButton2.GetState() == STATE_CLICKED) { MainButton1.SetEffect(EFFECT_FADE, -20); MainButton2.SetEffect(EFFECT_FADE, -20); MainButton3.SetEffect(EFFECT_FADE, -20); MainButton4.SetEffect(EFFECT_FADE, -20); - while(MainButton2.GetEffect() > 0) usleep(50); + while (MainButton2.GetEffect() > 0) usleep(50); w.Remove(&PageIndicatorBtn1); w.Remove(&PageIndicatorBtn2); w.Remove(&GoRightBtn); @@ -1589,15 +1519,15 @@ int MenuSettings() w.Remove(&MainButton3); w.Remove(&MainButton4); // if(isSdInserted() && Settings.godmode) { - if(isInserted(bootDevice) && Settings.godmode) { - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - int ret = ProgressUpdateWindow(); - if(ret < 0) { - WindowPrompt(tr("Update failed"),0,tr("OK")); - } - w.Append(&optionBrowser2); - w.Append(&backBtn); + if (isInserted(bootDevice) && Settings.godmode) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + int ret = ProgressUpdateWindow(); + if (ret < 0) { + WindowPrompt(tr("Update failed"),0,tr("OK")); + } + w.Append(&optionBrowser2); + w.Append(&backBtn); } else { WindowPrompt(tr("Console Locked"), tr("Unlock console to use this option."), tr("OK")); } @@ -1607,12 +1537,12 @@ int MenuSettings() break; } - if(MainButton3.GetState() == STATE_CLICKED) { + if (MainButton3.GetState() == STATE_CLICKED) { MainButton1.SetEffect(EFFECT_FADE, -20); MainButton2.SetEffect(EFFECT_FADE, -20); MainButton3.SetEffect(EFFECT_FADE, -20); MainButton4.SetEffect(EFFECT_FADE, -20); - while(MainButton3.GetEffect() > 0) usleep(50); + while (MainButton3.GetEffect() > 0) usleep(50); w.Remove(&PageIndicatorBtn1); w.Remove(&PageIndicatorBtn2); w.Remove(&GoRightBtn); @@ -1623,22 +1553,21 @@ int MenuSettings() w.Remove(&MainButton4); w.Remove(&backBtn); w.Remove(&optionBrowser2); - if(Settings.godmode) { - int choice = WindowPrompt(tr("Are you sure?"), 0, tr("Yes"), tr("Cancel")); - if(choice == 1) { + if (Settings.godmode) { + int choice = WindowPrompt(tr("Are you sure?"), 0, tr("Yes"), tr("Cancel")); + if (choice == 1) { // if(isSdInserted()) - if(isInserted(bootDevice)) - { - char GXGlobal_cfg[26]; - sprintf(GXGlobal_cfg, "%s/config/GXGlobal.cfg", bootDevice); - remove(GXGlobal_cfg); - } - gettextCleanUp(); - //lang_default(); - CFG_Load(); - menu = MENU_SETTINGS; - pageToDisplay = 0; - } + if (isInserted(bootDevice)) { + char GXGlobal_cfg[26]; + sprintf(GXGlobal_cfg, "%s/config/GXGlobal.cfg", bootDevice); + remove(GXGlobal_cfg); + } + gettextCleanUp(); + //lang_default(); + CFG_Load(); + menu = MENU_SETTINGS; + pageToDisplay = 0; + } } else { WindowPrompt(tr("Console Locked"), tr("Unlock console to use this option."), tr("OK")); } @@ -1650,12 +1579,12 @@ int MenuSettings() break; } - if(MainButton4.GetState() == STATE_CLICKED) { + if (MainButton4.GetState() == STATE_CLICKED) { MainButton1.SetEffect(EFFECT_FADE, -20); MainButton2.SetEffect(EFFECT_FADE, -20); MainButton3.SetEffect(EFFECT_FADE, -20); MainButton4.SetEffect(EFFECT_FADE, -20); - while(MainButton4.GetEffect() > 0) usleep(50); + while (MainButton4.GetEffect() > 0) usleep(50); w.Remove(&PageIndicatorBtn1); w.Remove(&PageIndicatorBtn2); w.Remove(&GoRightBtn); @@ -1670,916 +1599,871 @@ int MenuSettings() MainButton4.ResetState(); break; } - } + } - if(shutdown == 1) - Sys_Shutdown(); - if(reset == 1) - Sys_Reboot(); + if (shutdown == 1) + Sys_Shutdown(); + if (reset == 1) + Sys_Reboot(); - if(backBtn.GetState() == STATE_CLICKED) - { - //Add the procedure call to save the global configuration + if (backBtn.GetState() == STATE_CLICKED) { + //Add the procedure call to save the global configuration // if(isSdInserted()) { - if(isInserted(bootDevice)) { - cfg_save_global(); - } - menu = MENU_DISCLIST; - pageToDisplay = 0; - break; - } + if (isInserted(bootDevice)) { + cfg_save_global(); + } + menu = MENU_DISCLIST; + pageToDisplay = 0; + break; + } - if(GoLeftBtn.GetState() == STATE_CLICKED) - { + if (GoLeftBtn.GetState() == STATE_CLICKED) { pageToDisplay--; /** Change direction of the flying buttons **/ - if(pageToDisplay < 1) - pageToDisplay = 2; + if (pageToDisplay < 1) + pageToDisplay = 2; slidedirection = LEFT; GoLeftBtn.ResetState(); break; - } + } - if(GoRightBtn.GetState() == STATE_CLICKED) - { + if (GoRightBtn.GetState() == STATE_CLICKED) { pageToDisplay++; /** Change direction of the flying buttons **/ - if(pageToDisplay > 2) - pageToDisplay = 1; + if (pageToDisplay > 2) + pageToDisplay = 1; slidedirection = RIGHT; GoRightBtn.ResetState(); break; - } + } - if(PageIndicatorBtn1.GetState() == STATE_CLICKED) - { - if(pageToDisplay == 2) { - slidedirection = LEFT; - pageToDisplay = 1; - PageIndicatorBtn1.ResetState(); - break; + if (PageIndicatorBtn1.GetState() == STATE_CLICKED) { + if (pageToDisplay == 2) { + slidedirection = LEFT; + pageToDisplay = 1; + PageIndicatorBtn1.ResetState(); + break; } PageIndicatorBtn1.ResetState(); - } - else if(PageIndicatorBtn2.GetState() == STATE_CLICKED) - { - if(pageToDisplay == 1) { - slidedirection = RIGHT; - pageToDisplay = 2; - PageIndicatorBtn2.ResetState(); - break; + } else if (PageIndicatorBtn2.GetState() == STATE_CLICKED) { + if (pageToDisplay == 1) { + slidedirection = RIGHT; + pageToDisplay = 2; + PageIndicatorBtn2.ResetState(); + break; } else - PageIndicatorBtn2.ResetState(); - } + PageIndicatorBtn2.ResetState(); + } - if(homo.GetState() == STATE_CLICKED) - { - cfg_save_global(); - optionBrowser2.SetState(STATE_DISABLED); - 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)) - { - bgMusic->Play(); - } else { - bgMusic->PlayOggFile(Settings.ogg_path); - } - bgMusic->SetPlayTime(thetimeofbg); - SetVolumeOgg(255*(Settings.volume/100.0)); + if (homo.GetState() == STATE_CLICKED) { + cfg_save_global(); + optionBrowser2.SetState(STATE_DISABLED); + 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)) { + bgMusic->Play(); + } else { + bgMusic->PlayOggFile(Settings.ogg_path); + } + bgMusic->SetPlayTime(thetimeofbg); + SetVolumeOgg(255*(Settings.volume/100.0)); - if(choice == 3) - { - Sys_LoadMenu(); // Back to System Menu - } else if (choice == 2) { - Sys_BackToLoader(); - } else { - homo.ResetState(); - } + if (choice == 3) { + Sys_LoadMenu(); // Back to System Menu + } else if (choice == 2) { + Sys_BackToLoader(); + } else { + homo.ResetState(); + } optionBrowser2.SetState(STATE_DEFAULT); - } - } - } + } + } + } - w.SetEffect(EFFECT_FADE, -20); - while(w.GetEffect()>0) usleep(50); + w.SetEffect(EFFECT_FADE, -20); + while (w.GetEffect()>0) usleep(50); - // if language has changed, reload titles - int opt_langnew = 0; - opt_langnew = Settings.language; - if (Settings.titlesOverride==1 && opt_lang != opt_langnew) { - OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, true, false); // open file, reload titles, do not keep in memory - menu = MENU_DISCLIST; - } + // if language has changed, reload titles + int opt_langnew = 0; + opt_langnew = Settings.language; + if (Settings.titlesOverride==1 && opt_lang != opt_langnew) { + OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, true, false); // open file, reload titles, do not keep in memory + menu = MENU_DISCLIST; + } - HaltGui(); + HaltGui(); - mainWindow->RemoveAll(); - mainWindow->Append(bgImg); + mainWindow->RemoveAll(); + mainWindow->Append(bgImg); - ResumeGui(); - return menu; + ResumeGui(); + return menu; } /******************************************************************************** *Game specific settings *********************************************************************************/ -int GameSettings(struct discHdr * header) -{ - int menu = MENU_NONE; - int ret; - int choice = 0; - bool exit = false; - - int retVal = 0; +int GameSettings(struct discHdr * header) { + int menu = MENU_NONE; + int ret; + int choice = 0; + bool exit = false; - + int retVal = 0; - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + + + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); GuiSound btnClick1(button_click_pcm, button_click_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[100]; + char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); - GuiImageData settingsbg(imgPath, settings_background_png); + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); + GuiImageData settingsbg(imgPath, settings_background_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_title.png", CFG.theme_path); - GuiImageData MainButtonImgData(imgPath, settings_title_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_title.png", CFG.theme_path); + GuiImageData MainButtonImgData(imgPath, settings_title_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_title_over.png", CFG.theme_path); - GuiImageData MainButtonImgOverData(imgPath, settings_title_over_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_title_over.png", CFG.theme_path); + GuiImageData MainButtonImgOverData(imgPath, settings_title_over_png); GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); - GuiTrigger trigB; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); - char gameName[31]; + char gameName[31]; - if (strlen(get_title(header)) < (27 + 3)) { - sprintf(gameName, "%s", get_title(header)); - } - else { - strncpy(gameName, get_title(header), 27); - gameName[27] = '\0'; - strncat(gameName, "...", 3); - } - - + if (strlen(get_title(header)) < (27 + 3)) { + sprintf(gameName, "%s", get_title(header)); + } else { + strncpy(gameName, get_title(header), 27); + gameName[27] = '\0'; + strncat(gameName, "...", 3); + } - 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); + + + 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); GuiImage settingsbackground(&settingsbg); - 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){ - backBtnTxt.SetWidescreen(CFG.widescreen); - backBtnImg.SetWidescreen(CFG.widescreen); - } - GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, &btnClick,1); - backBtn.SetLabel(&backBtnTxt); - backBtn.SetTrigger(&trigB); + 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) { + backBtnTxt.SetWidescreen(CFG.widescreen); + backBtnImg.SetWidescreen(CFG.widescreen); + } + GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, &btnClick,1); + backBtn.SetLabel(&backBtnTxt); + backBtn.SetTrigger(&trigB); + + GuiButton homo(1,1); + homo.SetTrigger(&trigHome); + + GuiText saveBtnTxt(tr("Save"), 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + saveBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); + GuiImage saveBtnImg(&btnOutline); + if (Settings.wsprompt == yes) { + saveBtnTxt.SetWidescreen(CFG.widescreen); + saveBtnImg.SetWidescreen(CFG.widescreen); + } + GuiButton saveBtn(&saveBtnImg,&saveBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, &btnClick,1); + saveBtn.SetLabel(&saveBtnTxt); - GuiButton homo(1,1); - homo.SetTrigger(&trigHome); - - GuiText saveBtnTxt(tr("Save"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); - saveBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); - GuiImage saveBtnImg(&btnOutline); - if (Settings.wsprompt == yes){ - saveBtnTxt.SetWidescreen(CFG.widescreen); - saveBtnImg.SetWidescreen(CFG.widescreen);} - GuiButton saveBtn(&saveBtnImg,&saveBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, &btnClick,1); - saveBtn.SetLabel(&saveBtnTxt); - char MainButtonText[50]; snprintf(MainButtonText, sizeof(MainButtonText), "%s", " "); GuiImage MainButton1Img(&MainButtonImgData); GuiImage MainButton1ImgOver(&MainButtonImgOverData); - GuiText MainButton1Txt(MainButtonText, 22, (GXColor){0, 0, 0, 255}); - MainButton1Txt.SetMaxWidth(MainButton1Img.GetWidth()); + GuiText MainButton1Txt(MainButtonText, 22, (GXColor) {0, 0, 0, 255}); + MainButton1Txt.SetMaxWidth(MainButton1Img.GetWidth()); GuiButton MainButton1(MainButton1Img.GetWidth(), MainButton1Img.GetHeight()); MainButton1.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - MainButton1.SetPosition(0, 90); - MainButton1.SetImage(&MainButton1Img); - MainButton1.SetImageOver(&MainButton1ImgOver); - MainButton1.SetLabel(&MainButton1Txt); - MainButton1.SetSoundOver(&btnSoundOver); - MainButton1.SetSoundClick(&btnClick1); - MainButton1.SetEffectGrow(); - MainButton1.SetTrigger(&trigA); + MainButton1.SetPosition(0, 90); + MainButton1.SetImage(&MainButton1Img); + MainButton1.SetImageOver(&MainButton1ImgOver); + MainButton1.SetLabel(&MainButton1Txt); + MainButton1.SetSoundOver(&btnSoundOver); + MainButton1.SetSoundClick(&btnClick1); + MainButton1.SetEffectGrow(); + MainButton1.SetTrigger(&trigA); GuiImage MainButton2Img(&MainButtonImgData); GuiImage MainButton2ImgOver(&MainButtonImgOverData); - GuiText MainButton2Txt(MainButtonText, 22, (GXColor){0, 0, 0, 255}); - MainButton2Txt.SetMaxWidth(MainButton2Img.GetWidth()); + GuiText MainButton2Txt(MainButtonText, 22, (GXColor) {0, 0, 0, 255}); + MainButton2Txt.SetMaxWidth(MainButton2Img.GetWidth()); GuiButton MainButton2(MainButton2Img.GetWidth(), MainButton2Img.GetHeight()); MainButton2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - MainButton2.SetPosition(0, 160); - MainButton2.SetImage(&MainButton2Img); - MainButton2.SetImageOver(&MainButton2ImgOver); - MainButton2.SetLabel(&MainButton2Txt); - MainButton2.SetSoundOver(&btnSoundOver); - MainButton2.SetSoundClick(&btnClick1); - MainButton2.SetEffectGrow(); - MainButton2.SetTrigger(&trigA); + MainButton2.SetPosition(0, 160); + MainButton2.SetImage(&MainButton2Img); + MainButton2.SetImageOver(&MainButton2ImgOver); + MainButton2.SetLabel(&MainButton2Txt); + MainButton2.SetSoundOver(&btnSoundOver); + MainButton2.SetSoundClick(&btnClick1); + MainButton2.SetEffectGrow(); + MainButton2.SetTrigger(&trigA); GuiImage MainButton3Img(&MainButtonImgData); GuiImage MainButton3ImgOver(&MainButtonImgOverData); - GuiText MainButton3Txt(MainButtonText, 22, (GXColor){0, 0, 0, 255}); - MainButton3Txt.SetMaxWidth(MainButton3Img.GetWidth()); + GuiText MainButton3Txt(MainButtonText, 22, (GXColor) {0, 0, 0, 255}); + MainButton3Txt.SetMaxWidth(MainButton3Img.GetWidth()); GuiButton MainButton3(MainButton3Img.GetWidth(), MainButton3Img.GetHeight()); MainButton3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - MainButton3.SetPosition(0, 230); - MainButton3.SetImage(&MainButton3Img); - MainButton3.SetImageOver(&MainButton3ImgOver); - MainButton3.SetLabel(&MainButton3Txt); - MainButton3.SetSoundOver(&btnSoundOver); - MainButton3.SetSoundClick(&btnClick1); - MainButton3.SetEffectGrow(); - MainButton3.SetTrigger(&trigA); + MainButton3.SetPosition(0, 230); + MainButton3.SetImage(&MainButton3Img); + MainButton3.SetImageOver(&MainButton3ImgOver); + MainButton3.SetLabel(&MainButton3Txt); + MainButton3.SetSoundOver(&btnSoundOver); + MainButton3.SetSoundClick(&btnClick1); + MainButton3.SetEffectGrow(); + MainButton3.SetTrigger(&trigA); GuiImage MainButton4Img(&MainButtonImgData); GuiImage MainButton4ImgOver(&MainButtonImgOverData); - GuiText MainButton4Txt(MainButtonText, 22, (GXColor){0, 0, 0, 255}); - MainButton4Txt.SetMaxWidth(MainButton4Img.GetWidth()); + GuiText MainButton4Txt(MainButtonText, 22, (GXColor) {0, 0, 0, 255}); + MainButton4Txt.SetMaxWidth(MainButton4Img.GetWidth()); GuiButton MainButton4(MainButton4Img.GetWidth(), MainButton4Img.GetHeight()); MainButton4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - MainButton4.SetPosition(0, 300); - MainButton4.SetImage(&MainButton4Img); - MainButton4.SetImageOver(&MainButton4ImgOver); - MainButton4.SetLabel(&MainButton4Txt); - MainButton4.SetSoundOver(&btnSoundOver); - MainButton4.SetSoundClick(&btnClick1); - MainButton4.SetEffectGrow(); - MainButton4.SetTrigger(&trigA); + MainButton4.SetPosition(0, 300); + MainButton4.SetImage(&MainButton4Img); + MainButton4.SetImageOver(&MainButton4ImgOver); + MainButton4.SetLabel(&MainButton4Txt); + MainButton4.SetSoundOver(&btnSoundOver); + MainButton4.SetSoundClick(&btnClick1); + MainButton4.SetEffectGrow(); + MainButton4.SetTrigger(&trigA); - customOptionList options2(MAXOPTIONS-1); - GuiCustomOptionBrowser optionBrowser2(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 0, 150); - optionBrowser2.SetPosition(0, 90); - optionBrowser2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + customOptionList options2(MAXOPTIONS-1); + GuiCustomOptionBrowser optionBrowser2(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 0, 150); + optionBrowser2.SetPosition(0, 90); + optionBrowser2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - GuiWindow w(screenwidth, screenheight); - int opt_lang = languageChoice; // backup language setting - struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); + GuiWindow w(screenwidth, screenheight); + int opt_lang = languageChoice; // backup language setting + struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); - int pageToDisplay = 1; - while ( pageToDisplay > 0) //set pageToDisplay to 0 to quit - { - VIDEO_WaitVSync (); + int pageToDisplay = 1; + while ( pageToDisplay > 0) { //set pageToDisplay to 0 to quit + VIDEO_WaitVSync (); - menu = MENU_NONE; + menu = MENU_NONE; - /** Standard procedure made in all pages **/ - MainButton1.StopEffect(); - MainButton2.StopEffect(); - MainButton3.StopEffect(); - MainButton4.StopEffect(); + /** Standard procedure made in all pages **/ + MainButton1.StopEffect(); + MainButton2.StopEffect(); + MainButton3.StopEffect(); + MainButton4.StopEffect(); - HaltGui(); + HaltGui(); - snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr("Game Load")); - MainButton1Txt.SetText(MainButtonText); - snprintf(MainButtonText, sizeof(MainButtonText), "Ocarina"); - MainButton2Txt.SetText(MainButtonText); - snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr("Uninstall Menu")); - MainButton3Txt.SetText(MainButtonText); - snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr("Default Gamesettings")); - MainButton4Txt.SetText(MainButtonText); + snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr("Game Load")); + MainButton1Txt.SetText(MainButtonText); + snprintf(MainButtonText, sizeof(MainButtonText), "Ocarina"); + MainButton2Txt.SetText(MainButtonText); + snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr("Uninstall Menu")); + MainButton3Txt.SetText(MainButtonText); + snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr("Default Gamesettings")); + MainButton4Txt.SetText(MainButtonText); - mainWindow->RemoveAll(); - mainWindow->Append(&w); - w.RemoveAll(); - w.Append(&settingsbackground); - w.Append(&titleTxt); - w.Append(&backBtn); - w.Append(&homo); - //w.Append(&saveBtn); - w.Append(&MainButton1); - w.Append(&MainButton2); - w.Append(&MainButton3); - w.Append(&MainButton4); + mainWindow->RemoveAll(); + mainWindow->Append(&w); + w.RemoveAll(); + w.Append(&settingsbackground); + w.Append(&titleTxt); + w.Append(&backBtn); + w.Append(&homo); + //w.Append(&saveBtn); + w.Append(&MainButton1); + w.Append(&MainButton2); + w.Append(&MainButton3); + w.Append(&MainButton4); - /** Disable ability to click through MainButtons */ - optionBrowser2.SetClickable(false); - /** Default no scrollbar and reset position **/ - optionBrowser2.SetScrollbar(0); - optionBrowser2.SetOffset(0); + /** Disable ability to click through MainButtons */ + optionBrowser2.SetClickable(false); + /** Default no scrollbar and reset position **/ + optionBrowser2.SetScrollbar(0); + optionBrowser2.SetOffset(0); - MainButton1.StopEffect(); - MainButton2.StopEffect(); - MainButton3.StopEffect(); - MainButton4.StopEffect(); + MainButton1.StopEffect(); + MainButton2.StopEffect(); + MainButton3.StopEffect(); + MainButton4.StopEffect(); - MainButton1.SetEffectGrow(); - MainButton2.SetEffectGrow(); - MainButton3.SetEffectGrow(); - MainButton4.SetEffectGrow(); + MainButton1.SetEffectGrow(); + MainButton2.SetEffectGrow(); + MainButton3.SetEffectGrow(); + MainButton4.SetEffectGrow(); - - MainButton1.SetEffect(EFFECT_FADE, 20); - MainButton2.SetEffect(EFFECT_FADE, 20); - MainButton3.SetEffect(EFFECT_FADE, 20); - MainButton4.SetEffect(EFFECT_FADE, 20); - - mainWindow->Append(&w); - - - if (game_cfg)//if there are saved settings for this game use them - { - videoChoice = game_cfg->video; - languageChoice = game_cfg->language; - ocarinaChoice = game_cfg->ocarina; - viChoice = game_cfg->vipatch; - iosChoice = game_cfg->ios; - parentalcontrolChoice = game_cfg->parentalcontrol; - fix002 = game_cfg->errorfix002; - countrystrings = game_cfg->patchcountrystrings; - alternatedol = game_cfg->loadalternatedol; - alternatedoloffset = game_cfg->alternatedolstart; - reloadblock = game_cfg->iosreloadblock; - strncpy(alternatedname, game_cfg->alternatedolname, sizeof(alternatedname)); - } - else - { - videoChoice = Settings.video; - languageChoice = Settings.language; - ocarinaChoice = Settings.ocarina; - viChoice = Settings.vpatch; - if(Settings.cios == ios222) { - iosChoice = i222; - } else { - iosChoice = i249; - } - parentalcontrolChoice = 0; - fix002 = Settings.error002; - countrystrings = Settings.patchcountrystrings; - alternatedol = off; - alternatedoloffset = 0; - reloadblock = off; - sprintf(alternatedname, " "); - } + MainButton1.SetEffect(EFFECT_FADE, 20); + MainButton2.SetEffect(EFFECT_FADE, 20); + MainButton3.SetEffect(EFFECT_FADE, 20); + MainButton4.SetEffect(EFFECT_FADE, 20); + + mainWindow->Append(&w); - ResumeGui(); + if (game_cfg) { //if there are saved settings for this game use them + videoChoice = game_cfg->video; + languageChoice = game_cfg->language; + ocarinaChoice = game_cfg->ocarina; + viChoice = game_cfg->vipatch; + iosChoice = game_cfg->ios; + parentalcontrolChoice = game_cfg->parentalcontrol; + fix002 = game_cfg->errorfix002; + countrystrings = game_cfg->patchcountrystrings; + alternatedol = game_cfg->loadalternatedol; + alternatedoloffset = game_cfg->alternatedolstart; + reloadblock = game_cfg->iosreloadblock; + strncpy(alternatedname, game_cfg->alternatedolname, sizeof(alternatedname)); + } else { + videoChoice = Settings.video; + languageChoice = Settings.language; + ocarinaChoice = Settings.ocarina; + viChoice = Settings.vpatch; + if (Settings.cios == ios222) { + iosChoice = i222; + } else { + iosChoice = i249; + } + parentalcontrolChoice = 0; + fix002 = Settings.error002; + countrystrings = Settings.patchcountrystrings; + alternatedol = off; + alternatedoloffset = 0; + reloadblock = off; + sprintf(alternatedname, " "); + } - while(MainButton1.GetEffect() > 0) usleep(50); - - while(menu == MENU_NONE) - { - VIDEO_WaitVSync (); + ResumeGui(); - if(MainButton1.GetState() == STATE_CLICKED) { - w.Append(&saveBtn); - MainButton1.SetEffect(EFFECT_FADE, -20); - MainButton2.SetEffect(EFFECT_FADE, -20); - MainButton3.SetEffect(EFFECT_FADE, -20); - MainButton4.SetEffect(EFFECT_FADE, -20); - while(MainButton1.GetEffect() > 0) usleep(50); - HaltGui(); - w.Remove(&MainButton1); - w.Remove(&MainButton2); - w.Remove(&MainButton3); - w.Remove(&MainButton4); - exit = false; - for(int i = 0; i <= MAXOPTIONS-1; i++) options2.SetName(i, NULL); - options2.SetName(0, "%s",tr("Video Mode")); - options2.SetName(1, "%s",tr("VIDTV Patch")); - options2.SetName(2,"%s", tr("Game Language")); - options2.SetName(3, "Ocarina"); - options2.SetName(4, "IOS"); - options2.SetName(5,"%s", tr("Parental control")); - options2.SetName(6,"%s", tr("Error 002 fix")); - options2.SetName(7,"%s", tr("Patch Country Strings")); - options2.SetName(8,"%s", tr("Alternate DOL")); - options2.SetName(9,"%s", tr("DOL from disc")); - options2.SetName(10,"%s", tr("Block IOS Reload")); - for(int i = 0; i <= MAXOPTIONS-1; i++) options2.SetValue(i, NULL); - optionBrowser2.SetScrollbar(1); - w.Append(&optionBrowser2); - //w.Append(&saveBtn); - optionBrowser2.SetClickable(true); - ResumeGui(); + while (MainButton1.GetEffect() > 0) usleep(50); + + + while (menu == MENU_NONE) { + VIDEO_WaitVSync (); + + if (MainButton1.GetState() == STATE_CLICKED) { + w.Append(&saveBtn); + MainButton1.SetEffect(EFFECT_FADE, -20); + MainButton2.SetEffect(EFFECT_FADE, -20); + MainButton3.SetEffect(EFFECT_FADE, -20); + MainButton4.SetEffect(EFFECT_FADE, -20); + while (MainButton1.GetEffect() > 0) usleep(50); + HaltGui(); + w.Remove(&MainButton1); + w.Remove(&MainButton2); + w.Remove(&MainButton3); + w.Remove(&MainButton4); + exit = false; + for (int i = 0; i <= MAXOPTIONS-1; i++) options2.SetName(i, NULL); + options2.SetName(0, "%s",tr("Video Mode")); + options2.SetName(1, "%s",tr("VIDTV Patch")); + options2.SetName(2,"%s", tr("Game Language")); + options2.SetName(3, "Ocarina"); + options2.SetName(4, "IOS"); + options2.SetName(5,"%s", tr("Parental control")); + options2.SetName(6,"%s", tr("Error 002 fix")); + options2.SetName(7,"%s", tr("Patch Country Strings")); + options2.SetName(8,"%s", tr("Alternate DOL")); + options2.SetName(9,"%s", tr("DOL from disc")); + options2.SetName(10,"%s", tr("Block IOS Reload")); + for (int i = 0; i <= MAXOPTIONS-1; i++) options2.SetValue(i, NULL); + optionBrowser2.SetScrollbar(1); + w.Append(&optionBrowser2); + //w.Append(&saveBtn); + optionBrowser2.SetClickable(true); + ResumeGui(); + + VIDEO_WaitVSync (); + optionBrowser2.SetEffect(EFFECT_FADE, 20); + while (optionBrowser2.GetEffect() > 0) usleep(50); + + int returnhere = 1; + char * languagefile; + languagefile = strrchr(Settings.language_path, '/')+1; + + while (!exit) { VIDEO_WaitVSync (); - optionBrowser2.SetEffect(EFFECT_FADE, 20); - while(optionBrowser2.GetEffect() > 0) usleep(50); - int returnhere = 1; - char * languagefile; - languagefile = strrchr(Settings.language_path, '/')+1; + returnhere = 1; - while(!exit) - { - VIDEO_WaitVSync (); + if (videoChoice >= 6) + videoChoice = 0; + if (viChoice >= 2) + viChoice = 0; + if (languageChoice >= 11) + languageChoice = 0; + if ( ocarinaChoice >= 2) + ocarinaChoice = 0; + if ( Settings.wsprompt > 1 ) + Settings.wsprompt = 0; + if ( iosChoice >= 3) + iosChoice = 0; + if ( Settings.wiilight > 2 ) + Settings.wiilight = 0; + if (parentalcontrolChoice >= 5) + parentalcontrolChoice = 0; + if (fix002 >= 3) + fix002 = 0; //RUMBLE + if (countrystrings >= 2) + countrystrings = 0; + if (alternatedol >= 3) + alternatedol = 0; + if (reloadblock >= 2) + reloadblock = 0; - returnhere = 1; + if (videoChoice == discdefault) options2.SetValue(0,"%s",tr("Disc Default")); + else if (videoChoice == systemdefault) options2.SetValue(0,"%s",tr("System Default")); + else if (videoChoice == patch) options2.SetValue(0,"%s",tr("AutoPatch")); + else if (videoChoice == pal50) options2.SetValue(0,"%s PAL50",tr("Force")); + else if (videoChoice == pal60) options2.SetValue(0,"%s PAL60",tr("Force")); + else if (videoChoice == ntsc) options2.SetValue(0,"%s NTSC",tr("Force")); - if(videoChoice >= 6) - videoChoice = 0; - if(viChoice >= 2) - viChoice = 0; - if (languageChoice >= 11) - languageChoice = 0; - if ( ocarinaChoice >= 2) - ocarinaChoice = 0; - if ( Settings.wsprompt > 1 ) - Settings.wsprompt = 0; - if ( iosChoice >= 3) - iosChoice = 0; - if ( Settings.wiilight > 2 ) - Settings.wiilight = 0; - if(parentalcontrolChoice >= 5) - parentalcontrolChoice = 0; - if(fix002 >= 3) - fix002 = 0; //RUMBLE - if(countrystrings >= 2) - countrystrings = 0; - if(alternatedol >= 3) - alternatedol = 0; - if(reloadblock >= 2) - reloadblock = 0; - - if (videoChoice == discdefault) options2.SetValue(0,"%s",tr("Disc Default")); - else if (videoChoice == systemdefault) options2.SetValue(0,"%s",tr("System Default")); - else if (videoChoice == patch) options2.SetValue(0,"%s",tr("AutoPatch")); - else if (videoChoice == pal50) options2.SetValue(0,"%s PAL50",tr("Force")); - else if (videoChoice == pal60) options2.SetValue(0,"%s PAL60",tr("Force")); - else if (videoChoice == ntsc) options2.SetValue(0,"%s NTSC",tr("Force")); + if (viChoice == on) options2.SetValue(1,"%s",tr("ON")); + else if (viChoice == off) options2.SetValue(1,"%s",tr("OFF")); - if (viChoice == on) options2.SetValue(1,"%s",tr("ON")); - else if (viChoice == off) options2.SetValue(1,"%s",tr("OFF")); + if (languageChoice == ConsoleLangDefault) options2.SetValue(2,"%s",tr("Console Default")); + else if (languageChoice == jap) options2.SetValue(2,"%s",tr("Japanese")); + else if (languageChoice == ger) options2.SetValue(2,"%s",tr("German")); + else if (languageChoice == eng) options2.SetValue(2,"%s",tr("English")); + else if (languageChoice == fren) options2.SetValue(2,"%s",tr("French")); + else if (languageChoice == esp) options2.SetValue(2,"%s",tr("Spanish")); + else if (languageChoice == it) options2.SetValue(2,"%s",tr("Italian")); + else if (languageChoice == dut) options2.SetValue(2,"%s",tr("Dutch")); + else if (languageChoice == schin) options2.SetValue(2,"%s",tr("SChinese")); + else if (languageChoice == tchin) options2.SetValue(2,"%s",tr("TChinese")); + else if (languageChoice == kor) options2.SetValue(2,"%s",tr("Korean")); - if (languageChoice == ConsoleLangDefault) options2.SetValue(2,"%s",tr("Console Default")); - else if (languageChoice == jap) options2.SetValue(2,"%s",tr("Japanese")); - else if (languageChoice == ger) options2.SetValue(2,"%s",tr("German")); - else if (languageChoice == eng) options2.SetValue(2,"%s",tr("English")); - else if (languageChoice == fren) options2.SetValue(2,"%s",tr("French")); - else if (languageChoice == esp) options2.SetValue(2,"%s",tr("Spanish")); - else if (languageChoice == it) options2.SetValue(2,"%s",tr("Italian")); - else if (languageChoice == dut) options2.SetValue(2,"%s",tr("Dutch")); - else if (languageChoice == schin) options2.SetValue(2,"%s",tr("SChinese")); - else if (languageChoice == tchin) options2.SetValue(2,"%s",tr("TChinese")); - else if (languageChoice == kor) options2.SetValue(2,"%s",tr("Korean")); + if (ocarinaChoice == on) options2.SetValue(3,"%s",tr("ON")); + else if (ocarinaChoice == off) options2.SetValue(3,"%s",tr("OFF")); - if (ocarinaChoice == on) options2.SetValue(3,"%s",tr("ON")); - else if (ocarinaChoice == off) options2.SetValue(3,"%s",tr("OFF")); + if (iosChoice == i249) options2.SetValue(4,"249"); + else if (iosChoice == i222) options2.SetValue(4,"222"); + else if (iosChoice == i223) options2.SetValue(4,"223"); - if (iosChoice == i249) options2.SetValue(4,"249"); - else if (iosChoice == i222) options2.SetValue(4,"222"); - else if (iosChoice == i223) options2.SetValue(4,"223"); + if (parentalcontrolChoice == 0) options2.SetValue(5, tr("0 (Everyone)")); + else if (parentalcontrolChoice == 1) options2.SetValue(5, tr("1 (Child 7+)")); + else if (parentalcontrolChoice == 2) options2.SetValue(5, tr("2 (Teen 12+)")); + else if (parentalcontrolChoice == 3) options2.SetValue(5, tr("3 (Mature 16+)")); + else if (parentalcontrolChoice == 4) options2.SetValue(5, tr("4 (Adults Only 18+)")); - if (parentalcontrolChoice == 0) options2.SetValue(5, tr("0 (Everyone)")); - else if (parentalcontrolChoice == 1) options2.SetValue(5, tr("1 (Child 7+)")); - else if (parentalcontrolChoice == 2) options2.SetValue(5, tr("2 (Teen 12+)")); - else if (parentalcontrolChoice == 3) options2.SetValue(5, tr("3 (Mature 16+)")); - else if (parentalcontrolChoice == 4) options2.SetValue(5, tr("4 (Adults Only 18+)")); + if (fix002 == on) options2.SetValue(6,tr("ON")); + else if (fix002 == off) options2.SetValue(6,tr("OFF")); + else if (fix002 == anti) options2.SetValue(6,tr("Anti")); - if (fix002 == on) options2.SetValue(6,tr("ON")); - else if (fix002 == off) options2.SetValue(6,tr("OFF")); - else if (fix002 == anti) options2.SetValue(6,tr("Anti")); + if (countrystrings == on) options2.SetValue(7,tr("ON")); + else if (countrystrings == off) options2.SetValue(7,tr("OFF")); - if (countrystrings == on) options2.SetValue(7,tr("ON")); - else if (countrystrings == off) options2.SetValue(7,tr("OFF")); + if (alternatedol == on) options2.SetValue(8,tr("DOL from SD")); + if (alternatedol == 2) options2.SetValue(8,tr("DOL from disc")); + else if (alternatedol == off) options2.SetValue(8,tr("OFF")); - if (alternatedol == on) options2.SetValue(8,tr("DOL from SD")); - if (alternatedol == 2) options2.SetValue(8,tr("DOL from disc")); - else if (alternatedol == off) options2.SetValue(8,tr("OFF")); + if (alternatedol == on) options2.SetValue(9,tr("SD selected")); + else if (alternatedol == off) options2.SetValue(9,tr("OFF")); + else options2.SetValue(9, alternatedname); - if (alternatedol == on) options2.SetValue(9,tr("SD selected")); - else if (alternatedol == off) options2.SetValue(9,tr("OFF")); - else options2.SetValue(9, alternatedname); + if (reloadblock == on) options2.SetValue(10,tr("ON")); + else if (reloadblock == off) options2.SetValue(10,tr("OFF")); - if (reloadblock == on) options2.SetValue(10,tr("ON")); - else if (reloadblock == off) options2.SetValue(10,tr("OFF")); - - if(backBtn.GetState() == STATE_CLICKED) - { - backBtn.ResetState(); - exit = true; - break; - } - - if(shutdown == 1) - Sys_Shutdown(); - else if(reset == 1) - Sys_Reboot(); - - else if(menu == MENU_DISCLIST) { - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - WindowCredits(); - w.Append(&optionBrowser2); - w.Append(&backBtn); - } - else if(homo.GetState() == STATE_CLICKED) - { - cfg_save_global(); - optionBrowser2.SetState(STATE_DISABLED); - 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)) - { - bgMusic->Play(); - } else { - bgMusic->PlayOggFile(Settings.ogg_path); - } - bgMusic->SetPlayTime(thetimeofbg); - SetVolumeOgg(255*(Settings.volume/100.0)); - if(choice == 3) { - Sys_LoadMenu(); // Back to System Menu - } else if (choice == 2) { - Sys_BackToLoader(); - } else { - homo.ResetState(); - } - optionBrowser2.SetState(STATE_DEFAULT); - } - - ret = optionBrowser2.GetClickedOption(); - - switch (ret) - { - case 0: - videoChoice = (videoChoice + 1) % CFG_VIDEO_COUNT; - break; - case 1: - viChoice = (viChoice + 1) % 2; - break; - case 2: - languageChoice = (languageChoice + 1) % CFG_LANG_COUNT; - break; - case 3: - ocarinaChoice = (ocarinaChoice + 1) % 2; - break; - case 4: - iosChoice = (iosChoice + 1) % 3; - break; - case 5: - parentalcontrolChoice = (parentalcontrolChoice + 1) % 5; - break; - case 6: - fix002 = (fix002+1) % 3; - break; - case 7: - countrystrings = (countrystrings+1) % 2; - break; - case 8: - alternatedol = (alternatedol+1) % 3; - break; - case 9: - if(alternatedol == 2) { - char filename[10]; - snprintf(filename,sizeof(filename),"%c%c%c%c%c%c",header->id[0], header->id[1], header->id[2], - header->id[3],header->id[4], header->id[5]); - int dolchoice =0; - //check to see if we already know the offset of the correct dol - int autodol = autoSelectDol(filename); - - //if we do know that offset ask if they want to use it - if (autodol>0){ - dolchoice = WindowPrompt(0,tr("Do you want to use the alt dol that is known to be correct?"),tr("Yes"),tr("Pick from a list")); - if (dolchoice==1) - { - alternatedoloffset = autodol; - snprintf(alternatedname, sizeof(alternatedname), "%s <%i>", tr("AUTO"),autodol); - } - else {//they want to search for the correct dol themselves - int res = DiscBrowse(header); - if((res >= 0)&&(res !=696969))//if res==6969696 they pressed the back button - alternatedoloffset = res; - } - } - else { - int res = DiscBrowse(header); - if((res >= 0)&&(res !=696969)) - alternatedoloffset = res; - char tmp[170]; - snprintf(tmp,sizeof(tmp),tr("It seems that you have some information that will we helpfull to us. Please pass this information along to the DEV team. %s - %i") ,filename,alternatedoloffset); - WindowPrompt(0,tmp,tr("Ok")); - } - - - - } - break; - case 10: - reloadblock = (reloadblock+1) % 2; - break; - - } - - if(saveBtn.GetState() == STATE_CLICKED) - { - - if(isInserted(bootDevice)) { - if (CFG_save_game_opt(header->id)) - { - // if language has changed, reload titles - int opt_langnew = 0; - game_cfg = CFG_get_game_opt(header->id); - if (game_cfg) opt_langnew = game_cfg->language; - if (Settings.titlesOverride==1 && opt_lang != opt_langnew) - OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, true, false); // open file, reload titles, do not keep in memory - // titles are refreshed in menu.cpp as soon as this function returns - WindowPrompt(tr("Successfully Saved"), 0, tr("OK")); - } - else - { - WindowPrompt(tr("Save Failed"), 0, tr("OK")); - } - } else { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); - } - - saveBtn.ResetState(); - optionBrowser2.SetFocus(1); - } - } - - optionBrowser2.SetEffect(EFFECT_FADE, -20); - while(optionBrowser2.GetEffect() > 0) usleep(50); - MainButton1.ResetState(); - break; - w.Remove(&saveBtn); - } - - if(MainButton2.GetState() == STATE_CLICKED) { - char ID[7]; - snprintf (ID,sizeof(ID),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - CheatMenu(ID); - MainButton2.ResetState(); - break; - } - - if(MainButton3.GetState() == STATE_CLICKED) { - MainButton1.SetEffect(EFFECT_FADE, -20); - MainButton2.SetEffect(EFFECT_FADE, -20); - MainButton3.SetEffect(EFFECT_FADE, -20); - MainButton4.SetEffect(EFFECT_FADE, -20); - while(MainButton3.GetEffect() > 0) usleep(50); - HaltGui(); - w.Remove(&MainButton1); - w.Remove(&MainButton2); - w.Remove(&MainButton3); - w.Remove(&MainButton4); - //titleTxt.SetText(tr("Parental Control")); - exit = false; - - for(int i = 0; i <= MAXOPTIONS-1; i++) options2.SetName(i, NULL); - options2.SetName(0,"%s", tr("Uninstall Game")); - options2.SetName(1,"%s", tr("Reset Playcounter")); - options2.SetName(2,"%s", tr("Delete Boxart")); - options2.SetName(3,"%s", tr("Delete Discart")); - options2.SetName(4,"%s", tr("Delete CheatTxt")); - for(int i = 0; i <= MAXOPTIONS-1; i++) options2.SetValue(i, NULL); - w.Append(&optionBrowser2); - optionBrowser2.SetClickable(true); - ResumeGui(); - - VIDEO_WaitVSync (); - optionBrowser2.SetEffect(EFFECT_FADE, 20); - while(optionBrowser2.GetEffect() > 0) usleep(50); - - while(!exit) - { - VIDEO_WaitVSync (); - - if(backBtn.GetState() == STATE_CLICKED) - { - backBtn.ResetState(); - exit = true; - break; - } - - if(shutdown == 1) - Sys_Shutdown(); - else if(reset == 1) - Sys_Reboot(); - - else if(homo.GetState() == STATE_CLICKED) - { - cfg_save_global(); - optionBrowser2.SetState(STATE_DISABLED); - 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)) - { - bgMusic->Play(); - } else { - bgMusic->PlayOggFile(Settings.ogg_path); - } - bgMusic->SetPlayTime(thetimeofbg); - SetVolumeOgg(255*(Settings.volume/100.0)); - if(choice == 3) { - Sys_LoadMenu(); // Back to System Menu - } else if (choice == 2) { - Sys_BackToLoader(); - } else { - homo.ResetState(); - } - optionBrowser2.SetState(STATE_DEFAULT); - } - - ret = optionBrowser2.GetClickedOption(); - - int choice1; - char tmp[200]; - switch (ret) - { - case 0: - choice1 = WindowPrompt(tr("Do you really want to delete:"),gameName,tr("Yes"),tr("Cancel")); - if (choice1 == 1) - { - CFG_forget_game_opt(header->id); - CFG_forget_game_num(header->id); - ret = WBFS_RemoveGame(header->id); - if (ret < 0) - { - WindowPrompt( - tr("Can't delete:"), - gameName, - tr("OK")); - } - else { - WindowPrompt(tr("Successfully deleted:"),gameName,tr("OK")); - retVal = 1; - } - } - else if (choice1 == 0) - { - optionBrowser2.SetFocus(1); - } - break; - case 1: - int result; - result = WindowPrompt(tr("Are you sure?"),0,tr("Yes"),tr("Cancel")); - if(result == 1) { - if(isInserted(bootDevice)) { - struct Game_NUM* game_num = CFG_get_game_num(header->id); - if (game_num) { - favoritevar = game_num->favorite; - playcount = game_num->count; - } else { - favoritevar = 0; - playcount = 0; - } - playcount = 0; - CFG_save_game_num(header->id); - } - } - break; - case 2: - - snprintf(tmp,sizeof(tmp),"%s%c%c%c%c%c%c.png", Settings.covers_path, header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - - choice1 = WindowPrompt(tr("Delete"),tmp,tr("Yes"),tr("No")); - if(choice1==1) - { - if(checkfile(tmp)) - remove(tmp); - } - break; - case 3: - - snprintf(tmp,sizeof(tmp),"%s%c%c%c%c%c%c.png", Settings.disc_path, header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - - choice1 = WindowPrompt(tr("Delete"),tmp,tr("Yes"),tr("No")); - if(choice1==1) - { - if(checkfile(tmp)) - remove(tmp); - } - break; - case 4: - - snprintf(tmp,sizeof(tmp),"%s%c%c%c%c%c%c.txt", Settings.TxtCheatcodespath, header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - - choice1 = WindowPrompt(tr("Delete"),tmp,tr("Yes"),tr("No")); - if(choice1==1) - { - if(checkfile(tmp)) - remove(tmp); - } - break; - - } + if (backBtn.GetState() == STATE_CLICKED) { + backBtn.ResetState(); + exit = true; + break; + } + + if (shutdown == 1) + Sys_Shutdown(); + else if (reset == 1) + Sys_Reboot(); + + else if (menu == MENU_DISCLIST) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + WindowCredits(); + w.Append(&optionBrowser2); + w.Append(&backBtn); + } else if (homo.GetState() == STATE_CLICKED) { + cfg_save_global(); + optionBrowser2.SetState(STATE_DISABLED); + 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)) { + bgMusic->Play(); + } else { + bgMusic->PlayOggFile(Settings.ogg_path); + } + bgMusic->SetPlayTime(thetimeofbg); + SetVolumeOgg(255*(Settings.volume/100.0)); + if (choice == 3) { + Sys_LoadMenu(); // Back to System Menu + } else if (choice == 2) { + Sys_BackToLoader(); + } else { + homo.ResetState(); + } + optionBrowser2.SetState(STATE_DEFAULT); + } + + ret = optionBrowser2.GetClickedOption(); + + switch (ret) { + case 0: + videoChoice = (videoChoice + 1) % CFG_VIDEO_COUNT; + break; + case 1: + viChoice = (viChoice + 1) % 2; + break; + case 2: + languageChoice = (languageChoice + 1) % CFG_LANG_COUNT; + break; + case 3: + ocarinaChoice = (ocarinaChoice + 1) % 2; + break; + case 4: + iosChoice = (iosChoice + 1) % 3; + break; + case 5: + parentalcontrolChoice = (parentalcontrolChoice + 1) % 5; + break; + case 6: + fix002 = (fix002+1) % 3; + break; + case 7: + countrystrings = (countrystrings+1) % 2; + break; + case 8: + alternatedol = (alternatedol+1) % 3; + break; + case 9: + if (alternatedol == 2) { + char filename[10]; + snprintf(filename,sizeof(filename),"%c%c%c%c%c%c",header->id[0], header->id[1], header->id[2], + header->id[3],header->id[4], header->id[5]); + int dolchoice =0; + //check to see if we already know the offset of the correct dol + int autodol = autoSelectDol(filename); + + //if we do know that offset ask if they want to use it + if (autodol>0) { + dolchoice = WindowPrompt(0,tr("Do you want to use the alt dol that is known to be correct?"),tr("Yes"),tr("Pick from a list")); + if (dolchoice==1) { + alternatedoloffset = autodol; + snprintf(alternatedname, sizeof(alternatedname), "%s <%i>", tr("AUTO"),autodol); + } else {//they want to search for the correct dol themselves + int res = DiscBrowse(header); + if ((res >= 0)&&(res !=696969))//if res==6969696 they pressed the back button + alternatedoloffset = res; + } + } else { + int res = DiscBrowse(header); + if ((res >= 0)&&(res !=696969)) + alternatedoloffset = res; + char tmp[170]; + snprintf(tmp,sizeof(tmp),tr("It seems that you have some information that will we helpfull to us. Please pass this information along to the DEV team. %s - %i") ,filename,alternatedoloffset); + WindowPrompt(0,tmp,tr("Ok")); + } + + + + } + break; + case 10: + reloadblock = (reloadblock+1) % 2; + break; + + } + + if (saveBtn.GetState() == STATE_CLICKED) { + + if (isInserted(bootDevice)) { + if (CFG_save_game_opt(header->id)) { + // if language has changed, reload titles + int opt_langnew = 0; + game_cfg = CFG_get_game_opt(header->id); + if (game_cfg) opt_langnew = game_cfg->language; + if (Settings.titlesOverride==1 && opt_lang != opt_langnew) + OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, true, false); // open file, reload titles, do not keep in memory + // titles are refreshed in menu.cpp as soon as this function returns + WindowPrompt(tr("Successfully Saved"), 0, tr("OK")); + } else { + WindowPrompt(tr("Save Failed"), 0, tr("OK")); + } + } else { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); + } + + saveBtn.ResetState(); + optionBrowser2.SetFocus(1); } - optionBrowser2.SetEffect(EFFECT_FADE, -20); - while(optionBrowser2.GetEffect() > 0) usleep(50); - pageToDisplay = 1; - MainButton3.ResetState(); - break; } - if(MainButton4.GetState() == STATE_CLICKED) { + optionBrowser2.SetEffect(EFFECT_FADE, -20); + while (optionBrowser2.GetEffect() > 0) usleep(50); + MainButton1.ResetState(); + break; + w.Remove(&saveBtn); + } - int choice1 = WindowPrompt(tr("Are you sure?"),0,tr("Yes"),tr("Cancel")); - if(choice1 == 1) { - videoChoice = Settings.video; - viChoice = Settings.vpatch; - languageChoice = Settings.language; - ocarinaChoice = Settings.ocarina; - fix002 = Settings.error002; - countrystrings = Settings.patchcountrystrings; - alternatedol = off; - alternatedoloffset = 0; - reloadblock = off; - if(Settings.cios == ios222) { - iosChoice = i222; - } else { - iosChoice = i249; - } - parentalcontrolChoice = 0; - sprintf(alternatedname, " "); - CFG_forget_game_opt(header->id); - // if default language is different than language from main settings, reload titles - int opt_langnew = 0; - opt_langnew = Settings.language; - if (Settings.titlesOverride==1 && opt_lang != opt_langnew) - OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, true, false); // open file, reload titles, do not keep in memory - // titles are refreshed in menu.cpp as soon as this function returns - } - - pageToDisplay = 1; - MainButton4.ResetState(); - break; + if (MainButton2.GetState() == STATE_CLICKED) { + char ID[7]; + snprintf (ID,sizeof(ID),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + CheatMenu(ID); + MainButton2.ResetState(); + break; + } + + if (MainButton3.GetState() == STATE_CLICKED) { + MainButton1.SetEffect(EFFECT_FADE, -20); + MainButton2.SetEffect(EFFECT_FADE, -20); + MainButton3.SetEffect(EFFECT_FADE, -20); + MainButton4.SetEffect(EFFECT_FADE, -20); + while (MainButton3.GetEffect() > 0) usleep(50); + HaltGui(); + w.Remove(&MainButton1); + w.Remove(&MainButton2); + w.Remove(&MainButton3); + w.Remove(&MainButton4); + //titleTxt.SetText(tr("Parental Control")); + exit = false; + + for (int i = 0; i <= MAXOPTIONS-1; i++) options2.SetName(i, NULL); + options2.SetName(0,"%s", tr("Uninstall Game")); + options2.SetName(1,"%s", tr("Reset Playcounter")); + options2.SetName(2,"%s", tr("Delete Boxart")); + options2.SetName(3,"%s", tr("Delete Discart")); + options2.SetName(4,"%s", tr("Delete CheatTxt")); + for (int i = 0; i <= MAXOPTIONS-1; i++) options2.SetValue(i, NULL); + w.Append(&optionBrowser2); + optionBrowser2.SetClickable(true); + ResumeGui(); + + VIDEO_WaitVSync (); + optionBrowser2.SetEffect(EFFECT_FADE, 20); + while (optionBrowser2.GetEffect() > 0) usleep(50); + + while (!exit) { + VIDEO_WaitVSync (); + + if (backBtn.GetState() == STATE_CLICKED) { + backBtn.ResetState(); + exit = true; + break; + } + + if (shutdown == 1) + Sys_Shutdown(); + else if (reset == 1) + Sys_Reboot(); + + else if (homo.GetState() == STATE_CLICKED) { + cfg_save_global(); + optionBrowser2.SetState(STATE_DISABLED); + 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)) { + bgMusic->Play(); + } else { + bgMusic->PlayOggFile(Settings.ogg_path); + } + bgMusic->SetPlayTime(thetimeofbg); + SetVolumeOgg(255*(Settings.volume/100.0)); + if (choice == 3) { + Sys_LoadMenu(); // Back to System Menu + } else if (choice == 2) { + Sys_BackToLoader(); + } else { + homo.ResetState(); + } + optionBrowser2.SetState(STATE_DEFAULT); + } + + ret = optionBrowser2.GetClickedOption(); + + int choice1; + char tmp[200]; + switch (ret) { + case 0: + choice1 = WindowPrompt(tr("Do you really want to delete:"),gameName,tr("Yes"),tr("Cancel")); + if (choice1 == 1) { + CFG_forget_game_opt(header->id); + CFG_forget_game_num(header->id); + ret = WBFS_RemoveGame(header->id); + if (ret < 0) { + WindowPrompt( + tr("Can't delete:"), + gameName, + tr("OK")); + } else { + WindowPrompt(tr("Successfully deleted:"),gameName,tr("OK")); + retVal = 1; + } + } else if (choice1 == 0) { + optionBrowser2.SetFocus(1); + } + break; + case 1: + int result; + result = WindowPrompt(tr("Are you sure?"),0,tr("Yes"),tr("Cancel")); + if (result == 1) { + if (isInserted(bootDevice)) { + struct Game_NUM* game_num = CFG_get_game_num(header->id); + if (game_num) { + favoritevar = game_num->favorite; + playcount = game_num->count; + } else { + favoritevar = 0; + playcount = 0; + } + playcount = 0; + CFG_save_game_num(header->id); + } + } + break; + case 2: + + snprintf(tmp,sizeof(tmp),"%s%c%c%c%c%c%c.png", Settings.covers_path, header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + + choice1 = WindowPrompt(tr("Delete"),tmp,tr("Yes"),tr("No")); + if (choice1==1) { + if (checkfile(tmp)) + remove(tmp); + } + break; + case 3: + + snprintf(tmp,sizeof(tmp),"%s%c%c%c%c%c%c.png", Settings.disc_path, header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + + choice1 = WindowPrompt(tr("Delete"),tmp,tr("Yes"),tr("No")); + if (choice1==1) { + if (checkfile(tmp)) + remove(tmp); + } + break; + case 4: + + snprintf(tmp,sizeof(tmp),"%s%c%c%c%c%c%c.txt", Settings.TxtCheatcodespath, header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + + choice1 = WindowPrompt(tr("Delete"),tmp,tr("Yes"),tr("No")); + if (choice1==1) { + if (checkfile(tmp)) + remove(tmp); + } + break; + + } } - + optionBrowser2.SetEffect(EFFECT_FADE, -20); + while (optionBrowser2.GetEffect() > 0) usleep(50); + pageToDisplay = 1; + MainButton3.ResetState(); + break; + } - if(shutdown == 1) - Sys_Shutdown(); - if(reset == 1) - Sys_Reboot(); + if (MainButton4.GetState() == STATE_CLICKED) { - if(backBtn.GetState() == STATE_CLICKED) - { - menu = MENU_DISCLIST; - pageToDisplay = 0; - break; - } + int choice1 = WindowPrompt(tr("Are you sure?"),0,tr("Yes"),tr("Cancel")); + if (choice1 == 1) { + videoChoice = Settings.video; + viChoice = Settings.vpatch; + languageChoice = Settings.language; + ocarinaChoice = Settings.ocarina; + fix002 = Settings.error002; + countrystrings = Settings.patchcountrystrings; + alternatedol = off; + alternatedoloffset = 0; + reloadblock = off; + if (Settings.cios == ios222) { + iosChoice = i222; + } else { + iosChoice = i249; + } + parentalcontrolChoice = 0; + sprintf(alternatedname, " "); + CFG_forget_game_opt(header->id); + // if default language is different than language from main settings, reload titles + int opt_langnew = 0; + opt_langnew = Settings.language; + if (Settings.titlesOverride==1 && opt_lang != opt_langnew) + OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, true, false); // open file, reload titles, do not keep in memory + // titles are refreshed in menu.cpp as soon as this function returns + } - if(homo.GetState() == STATE_CLICKED) - { - cfg_save_global(); - optionBrowser2.SetState(STATE_DISABLED); - 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)) - { - bgMusic->Play(); - } else { - bgMusic->PlayOggFile(Settings.ogg_path); - } - bgMusic->SetPlayTime(thetimeofbg); - SetVolumeOgg(255*(Settings.volume/100.0)); + pageToDisplay = 1; + MainButton4.ResetState(); + break; + } - if(choice == 3) - { - Sys_LoadMenu(); // Back to System Menu - } else if (choice == 2) { - Sys_BackToLoader(); - } else { - homo.ResetState(); - } + + if (shutdown == 1) + Sys_Shutdown(); + if (reset == 1) + Sys_Reboot(); + + if (backBtn.GetState() == STATE_CLICKED) { + menu = MENU_DISCLIST; + pageToDisplay = 0; + break; + } + + if (homo.GetState() == STATE_CLICKED) { + cfg_save_global(); + optionBrowser2.SetState(STATE_DISABLED); + 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)) { + bgMusic->Play(); + } else { + bgMusic->PlayOggFile(Settings.ogg_path); + } + bgMusic->SetPlayTime(thetimeofbg); + SetVolumeOgg(255*(Settings.volume/100.0)); + + if (choice == 3) { + Sys_LoadMenu(); // Back to System Menu + } else if (choice == 2) { + Sys_BackToLoader(); + } else { + homo.ResetState(); + } optionBrowser2.SetState(STATE_DEFAULT); - } - } - } - w.SetEffect(EFFECT_FADE, -20); - while(w.GetEffect()>0) usleep(50); + } + } + } + w.SetEffect(EFFECT_FADE, -20); + while (w.GetEffect()>0) usleep(50); - HaltGui(); + HaltGui(); - mainWindow->RemoveAll(); - mainWindow->Append(bgImg); + mainWindow->RemoveAll(); + mainWindow->Append(bgImg); - ResumeGui(); - return retVal; + ResumeGui(); + return retVal; } diff --git a/source/settings/SettingsPrompts.cpp b/source/settings/SettingsPrompts.cpp index 2d320f04..6d7bf720 100644 --- a/source/settings/SettingsPrompts.cpp +++ b/source/settings/SettingsPrompts.cpp @@ -30,92 +30,91 @@ extern void HaltGui(); /**************************************************************************** * MenuOGG ***************************************************************************/ -bool MenuOGG() -{ +bool MenuOGG() { int cnt = 0; int ret = 0, choice = 0; int scrollon, nothingchanged = 0; bool returnhere = false; - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[100]; + char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); - GuiImageData settingsbg(imgPath, settings_background_png); + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); + GuiImageData settingsbg(imgPath, settings_background_png); GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiTrigger trigB; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); GuiTrigger trigMinus; - trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0); - GuiTrigger trigPlus; - trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0); + trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0); + GuiTrigger trigPlus; + trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0); char fullpath[150]; char shortpath[35]; - int countoggs = GetAllDirFiles(Settings.oggload_path); + 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); - } + } else { + sprintf(shortpath, "%s", Settings.oggload_path); + } - GuiText titleTxt(shortpath, 24, (GXColor){0, 0, 0, 255}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - titleTxt.SetPosition(0,0); - GuiButton pathBtn(300, 50); - pathBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - pathBtn.SetPosition(0,28); - pathBtn.SetLabel(&titleTxt); - pathBtn.SetSoundOver(&btnSoundOver); - pathBtn.SetSoundClick(&btnClick); - pathBtn.SetTrigger(&trigA); - pathBtn.SetEffectGrow(); + GuiText titleTxt(shortpath, 24, (GXColor) {0, 0, 0, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + titleTxt.SetPosition(0,0); + GuiButton pathBtn(300, 50); + pathBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + pathBtn.SetPosition(0,28); + pathBtn.SetLabel(&titleTxt); + pathBtn.SetSoundOver(&btnSoundOver); + pathBtn.SetSoundClick(&btnClick); + pathBtn.SetTrigger(&trigA); + pathBtn.SetEffectGrow(); GuiImage oggmenubackground(&settingsbg); - oggmenubackground.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - oggmenubackground.SetPosition(0, 0); + 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}); - backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); - GuiImage backBtnImg(&btnOutline); - if (Settings.wsprompt == yes){ - backBtnTxt.SetWidescreen(CFG.widescreen); - backBtnImg.SetWidescreen(CFG.widescreen); - } - GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); - backBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - backBtn.SetPosition(-180, 400); - backBtn.SetLabel(&backBtnTxt); - backBtn.SetImage(&backBtnImg); - backBtn.SetSoundOver(&btnSoundOver); - backBtn.SetSoundClick(&btnClick); - backBtn.SetTrigger(&trigA); - backBtn.SetTrigger(&trigB); - backBtn.SetEffectGrow(); + 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) { + backBtnTxt.SetWidescreen(CFG.widescreen); + backBtnImg.SetWidescreen(CFG.widescreen); + } + GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); + backBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + backBtn.SetPosition(-180, 400); + backBtn.SetLabel(&backBtnTxt); + backBtn.SetImage(&backBtnImg); + backBtn.SetSoundOver(&btnSoundOver); + backBtn.SetSoundClick(&btnClick); + backBtn.SetTrigger(&trigA); + backBtn.SetTrigger(&trigB); + backBtn.SetEffectGrow(); - 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){ - defaultBtnTxt.SetWidescreen(CFG.widescreen); - defaultBtnImg.SetWidescreen(CFG.widescreen); - } - GuiButton defaultBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); - defaultBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - defaultBtn.SetPosition(180, 400); - defaultBtn.SetLabel(&defaultBtnTxt); - defaultBtn.SetImage(&defaultBtnImg); - defaultBtn.SetSoundOver(&btnSoundOver); - defaultBtn.SetSoundClick(&btnClick); - defaultBtn.SetTrigger(&trigA); - defaultBtn.SetEffectGrow(); + 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) { + defaultBtnTxt.SetWidescreen(CFG.widescreen); + defaultBtnImg.SetWidescreen(CFG.widescreen); + } + GuiButton defaultBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); + defaultBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + defaultBtn.SetPosition(180, 400); + defaultBtn.SetLabel(&defaultBtnTxt); + defaultBtn.SetImage(&defaultBtnImg); + defaultBtn.SetSoundOver(&btnSoundOver); + defaultBtn.SetSoundClick(&btnClick); + defaultBtn.SetTrigger(&trigA); + defaultBtn.SetEffectGrow(); customOptionList options2(countoggs); @@ -124,100 +123,99 @@ bool MenuOGG() options2.SetName(cnt,"%i.", cnt+1); } - if(cnt < 9) { - scrollon = 0; + if (cnt < 9) { + scrollon = 0; } else { - scrollon = 1; + scrollon = 1; } - GuiCustomOptionBrowser optionBrowser4(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, scrollon, 10); - optionBrowser4.SetPosition(0, 90); - optionBrowser4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + GuiCustomOptionBrowser optionBrowser4(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, scrollon, 10); + optionBrowser4.SetPosition(0, 90); + optionBrowser4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - snprintf(imgPath, sizeof(imgPath), "%smp3_stop.png", CFG.theme_path); - GuiImageData stop(imgPath, mp3_stop_png); - snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path); - GuiImageData play(imgPath, startgame_arrow_right_png); + snprintf(imgPath, sizeof(imgPath), "%smp3_stop.png", CFG.theme_path); + GuiImageData stop(imgPath, mp3_stop_png); + snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path); + GuiImageData play(imgPath, startgame_arrow_right_png); - GuiImage playBtnImg(&play); - playBtnImg.SetWidescreen(CFG.widescreen); - GuiButton playBtn(play.GetWidth(), play.GetHeight()); - playBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - playBtn.SetPosition(50, 400); - playBtn.SetImage(&playBtnImg); - playBtn.SetSoundOver(&btnSoundOver); - playBtn.SetSoundClick(&btnClick); - playBtn.SetTrigger(&trigA); - playBtn.SetTrigger(&trigPlus); - playBtn.SetEffectGrow(); + GuiImage playBtnImg(&play); + playBtnImg.SetWidescreen(CFG.widescreen); + GuiButton playBtn(play.GetWidth(), play.GetHeight()); + playBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + playBtn.SetPosition(50, 400); + playBtn.SetImage(&playBtnImg); + playBtn.SetSoundOver(&btnSoundOver); + playBtn.SetSoundClick(&btnClick); + playBtn.SetTrigger(&trigA); + playBtn.SetTrigger(&trigPlus); + playBtn.SetEffectGrow(); - GuiImage stopBtnImg(&stop); - stopBtnImg.SetWidescreen(CFG.widescreen); - GuiButton stopBtn(stop.GetWidth(), stop.GetHeight()); - stopBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - stopBtn.SetPosition(-15, 400); - stopBtn.SetImage(&stopBtnImg); - stopBtn.SetSoundOver(&btnSoundOver); - stopBtn.SetSoundClick(&btnClick); - stopBtn.SetTrigger(&trigA); - stopBtn.SetTrigger(&trigMinus); - stopBtn.SetEffectGrow(); + GuiImage stopBtnImg(&stop); + stopBtnImg.SetWidescreen(CFG.widescreen); + GuiButton stopBtn(stop.GetWidth(), stop.GetHeight()); + stopBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + stopBtn.SetPosition(-15, 400); + stopBtn.SetImage(&stopBtnImg); + stopBtn.SetSoundOver(&btnSoundOver); + stopBtn.SetSoundClick(&btnClick); + stopBtn.SetTrigger(&trigA); + stopBtn.SetTrigger(&trigMinus); + stopBtn.SetEffectGrow(); HaltGui(); - GuiWindow w(screenwidth, screenheight); - w.Append(&oggmenubackground); - w.Append(&pathBtn); + GuiWindow w(screenwidth, screenheight); + w.Append(&oggmenubackground); + w.Append(&pathBtn); w.Append(&backBtn); w.Append(&playBtn); - w.Append(&stopBtn); - w.Append(&defaultBtn); + w.Append(&stopBtn); + w.Append(&defaultBtn); w.Append(&optionBrowser4); mainWindow->Append(&w); - w.SetEffect(EFFECT_FADE, 20); - ResumeGui(); + 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) - Sys_Shutdown(); - if(reset == 1) - Sys_Reboot(); + if (shutdown == 1) + Sys_Shutdown(); + 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)) { - bgMusic->Play(); - } else { - bgMusic->PlayOggFile(Settings.ogg_path); - } + if (backBtn.GetState() == STATE_CLICKED) { + if (nothingchanged == 1 && countoggs > 0) { + if (!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) { + bgMusic->Play(); + } else { + bgMusic->PlayOggFile(Settings.ogg_path); + } } backBtn.ResetState(); - break; - } + break; + } - if (defaultBtn.GetState() == STATE_CLICKED) { + if (defaultBtn.GetState() == STATE_CLICKED) { choice = WindowPrompt(tr("Loading standard music."),0,tr("OK"), tr("Cancel")); if (choice == 1) { - sprintf(Settings.ogg_path, "notset"); - bgMusic->Play(); - SetVolumeOgg(255*(Settings.volume/100.0)); - cfg_save_global(); + sprintf(Settings.ogg_path, "notset"); + bgMusic->Play(); + SetVolumeOgg(255*(Settings.volume/100.0)); + cfg_save_global(); } defaultBtn.ResetState(); - optionBrowser4.SetFocus(1); - } + optionBrowser4.SetFocus(1); + } - if (pathBtn.GetState() == STATE_CLICKED) { + if (pathBtn.GetState() == STATE_CLICKED) { w.Remove(&optionBrowser4); w.Remove(&backBtn); w.Remove(&pathBtn); w.Remove(&playBtn); w.Remove(&stopBtn); - w.Remove(&defaultBtn); + w.Remove(&defaultBtn); char entered[43] = ""; strncpy(entered, Settings.oggload_path, sizeof(entered)); int result = OnScreenKeyboard(entered,43,0); @@ -226,18 +224,18 @@ bool MenuOGG() w.Append(&backBtn); w.Append(&playBtn); w.Append(&stopBtn); - w.Append(&defaultBtn); + w.Append(&defaultBtn); if ( result == 1 ) { int len = (strlen(entered)-1); - if(entered[len] !='/') - strncat (entered, "/", 1); + 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)) { - sprintf(Settings.ogg_path, "notset"); - bgMusic->Play(); + if (isInserted(bootDevice)) { + if (!strcmp("", Settings.oggload_path)) { + sprintf(Settings.ogg_path, "notset"); + bgMusic->Play(); } cfg_save_global(); returnhere = true; @@ -246,71 +244,71 @@ bool MenuOGG() WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); } } - if(countoggs > 0) { - optionBrowser4.SetFocus(1); - } - pathBtn.ResetState(); - } - - ret = optionBrowser4.GetClickedOption(); - - if(ret>=0) { - choice = WindowPrompt(tr("Set as backgroundmusic?"),GetFileName(ret),tr("Yes"),tr("No")); - if(choice == 1) { - StopOgg(); - snprintf(fullpath,150,"%s%s",Settings.oggload_path,GetFileName(ret)); - choice = bgMusic->PlayOggFile(fullpath); - if(choice < 0) { - WindowPrompt(tr("Not supported format!"), tr("Loading standard music."), tr("OK")); - sprintf(Settings.ogg_path, "notset"); - bgMusic->Play(); - SetVolumeOgg(255*(Settings.volume/100.0)); - } else { - snprintf(Settings.ogg_path, sizeof(Settings.ogg_path), "%s", fullpath); - cfg_save_global(); - SetVolumeOgg(255*(Settings.volume/100.0)); - nothingchanged = 0; - } - } - optionBrowser4.SetFocus(1); - } - - if (playBtn.GetState() == STATE_CLICKED && 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) { - WindowPrompt(tr("Not supported format!"), tr("Loading standard music."), tr("OK")); - if(!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) { - bgMusic->Play(); - } else { - bgMusic->PlayOggFile(Settings.ogg_path); + if (countoggs > 0) { + optionBrowser4.SetFocus(1); } + pathBtn.ResetState(); + } + + ret = optionBrowser4.GetClickedOption(); + + if (ret>=0) { + choice = WindowPrompt(tr("Set as backgroundmusic?"),GetFileName(ret),tr("Yes"),tr("No")); + if (choice == 1) { + StopOgg(); + snprintf(fullpath,150,"%s%s",Settings.oggload_path,GetFileName(ret)); + choice = bgMusic->PlayOggFile(fullpath); + if (choice < 0) { + WindowPrompt(tr("Not supported format!"), tr("Loading standard music."), tr("OK")); + sprintf(Settings.ogg_path, "notset"); + bgMusic->Play(); + SetVolumeOgg(255*(Settings.volume/100.0)); + } else { + snprintf(Settings.ogg_path, sizeof(Settings.ogg_path), "%s", fullpath); + cfg_save_global(); + SetVolumeOgg(255*(Settings.volume/100.0)); + nothingchanged = 0; + } } - SetVolumeOgg(255*(Settings.volume/100.0)); - nothingchanged = 1; optionBrowser4.SetFocus(1); - } - playBtn.ResetState(); + } + + if (playBtn.GetState() == STATE_CLICKED && 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) { + WindowPrompt(tr("Not supported format!"), tr("Loading standard music."), tr("OK")); + if (!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) { + bgMusic->Play(); + } else { + bgMusic->PlayOggFile(Settings.ogg_path); + } + } + SetVolumeOgg(255*(Settings.volume/100.0)); + nothingchanged = 1; + optionBrowser4.SetFocus(1); + } + playBtn.ResetState(); + } + + if (stopBtn.GetState() == STATE_CLICKED) { + if (countoggs > 0) { + StopOgg(); + nothingchanged = 1; + optionBrowser4.SetFocus(1); + } + stopBtn.ResetState(); + } } - if(stopBtn.GetState() == STATE_CLICKED) { - if(countoggs > 0) { - StopOgg(); - nothingchanged = 1; - optionBrowser4.SetFocus(1); - } - stopBtn.ResetState(); - } - } + w.SetEffect(EFFECT_FADE, -20); + while (w.GetEffect()>0) usleep(50); - w.SetEffect(EFFECT_FADE, -20); - while(w.GetEffect()>0) usleep(50); - - HaltGui(); - mainWindow->Remove(&w); - ResumeGui(); + HaltGui(); + mainWindow->Remove(&w); + ResumeGui(); return returnhere; } @@ -318,180 +316,178 @@ bool MenuOGG() /**************************************************************************** * MenuLanguageSelect ***************************************************************************/ -int MenuLanguageSelect() -{ +int MenuLanguageSelect() { int cnt = 0; int ret = 0, choice = 0; int scrollon; int returnhere = 0; - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); - GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); - char imgPath[100]; + char imgPath[100]; - snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); - GuiImageData btnOutline(imgPath, button_dialogue_box_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); - GuiImageData settingsbg(imgPath, settings_background_png); + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); + GuiImageData settingsbg(imgPath, settings_background_png); GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiTrigger trigB; - trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); char fullpath[100]; - int countfiles = GetAllDirFiles(Settings.languagefiles_path); + 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); - } + } else { + sprintf(fullpath, "%s", Settings.languagefiles_path); + } - GuiText titleTxt(fullpath, 24, (GXColor){0, 0, 0, 255}); - titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - titleTxt.SetPosition(0,0); - GuiButton pathBtn(300, 50); - pathBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - pathBtn.SetPosition(0,28); - pathBtn.SetLabel(&titleTxt); - pathBtn.SetSoundOver(&btnSoundOver); - pathBtn.SetSoundClick(&btnClick); - pathBtn.SetTrigger(&trigA); - pathBtn.SetEffectGrow(); + GuiText titleTxt(fullpath, 24, (GXColor) {0, 0, 0, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + titleTxt.SetPosition(0,0); + GuiButton pathBtn(300, 50); + pathBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + pathBtn.SetPosition(0,28); + pathBtn.SetLabel(&titleTxt); + pathBtn.SetSoundOver(&btnSoundOver); + pathBtn.SetSoundClick(&btnClick); + pathBtn.SetTrigger(&trigA); + pathBtn.SetEffectGrow(); GuiImage oggmenubackground(&settingsbg); - oggmenubackground.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - oggmenubackground.SetPosition(0, 0); + 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}); - backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); - GuiImage backBtnImg(&btnOutline); - if (Settings.wsprompt == yes){ - backBtnTxt.SetWidescreen(CFG.widescreen); - backBtnImg.SetWidescreen(CFG.widescreen); - } - GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); - backBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - backBtn.SetPosition(-190, 400); - backBtn.SetLabel(&backBtnTxt); - backBtn.SetImage(&backBtnImg); - backBtn.SetSoundOver(&btnSoundOver); - backBtn.SetSoundClick(&btnClick); - backBtn.SetTrigger(&trigA); - backBtn.SetTrigger(&trigB); - backBtn.SetEffectGrow(); + 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) { + backBtnTxt.SetWidescreen(CFG.widescreen); + backBtnImg.SetWidescreen(CFG.widescreen); + } + GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); + backBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + backBtn.SetPosition(-190, 400); + backBtn.SetLabel(&backBtnTxt); + backBtn.SetImage(&backBtnImg); + backBtn.SetSoundOver(&btnSoundOver); + backBtn.SetSoundClick(&btnClick); + backBtn.SetTrigger(&trigA); + backBtn.SetTrigger(&trigB); + backBtn.SetEffectGrow(); - 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) { - defaultBtnTxt.SetWidescreen(CFG.widescreen); - defaultBtnImg.SetWidescreen(CFG.widescreen); - } - GuiButton defaultBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); - defaultBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - defaultBtn.SetPosition(190, 400); - defaultBtn.SetLabel(&defaultBtnTxt); - defaultBtn.SetImage(&defaultBtnImg); - defaultBtn.SetSoundOver(&btnSoundOver); - defaultBtn.SetSoundClick(&btnClick); - defaultBtn.SetTrigger(&trigA); - defaultBtn.SetEffectGrow(); + 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) { + defaultBtnTxt.SetWidescreen(CFG.widescreen); + defaultBtnImg.SetWidescreen(CFG.widescreen); + } + GuiButton defaultBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); + defaultBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + defaultBtn.SetPosition(190, 400); + defaultBtn.SetLabel(&defaultBtnTxt); + defaultBtn.SetImage(&defaultBtnImg); + defaultBtn.SetSoundOver(&btnSoundOver); + defaultBtn.SetSoundClick(&btnClick); + defaultBtn.SetTrigger(&trigA); + defaultBtn.SetEffectGrow(); - 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) { + 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) { updateBtnTxt.SetWidescreen(CFG.widescreen); updateBtnImg.SetWidescreen(CFG.widescreen); - } - GuiButton updateBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); - updateBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - updateBtn.SetPosition(0, 400); - updateBtn.SetLabel(&updateBtnTxt); - updateBtn.SetImage(&updateBtnImg); - updateBtn.SetSoundOver(&btnSoundOver); - updateBtn.SetSoundClick(&btnClick); - updateBtn.SetTrigger(&trigA); - updateBtn.SetEffectGrow(); + } + GuiButton updateBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); + updateBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + updateBtn.SetPosition(0, 400); + updateBtn.SetLabel(&updateBtnTxt); + updateBtn.SetImage(&updateBtnImg); + updateBtn.SetSoundOver(&btnSoundOver); + updateBtn.SetSoundClick(&btnClick); + updateBtn.SetTrigger(&trigA); + updateBtn.SetEffectGrow(); customOptionList options2(countfiles); for (cnt = 0; cnt < countfiles; cnt++) { - char filename[64]; - strncpy(filename, GetFileName(cnt),63); - char *dot = strchr(filename, '.'); - if(dot) *dot='\0'; + char filename[64]; + strncpy(filename, GetFileName(cnt),63); + char *dot = strchr(filename, '.'); + if (dot) *dot='\0'; options2.SetName(cnt, "%s", filename); options2.SetValue(cnt, NULL); } - if(cnt < 9) { - scrollon = 0; + if (cnt < 9) { + scrollon = 0; } else { - scrollon = 1; + scrollon = 1; } - GuiCustomOptionBrowser optionBrowser4(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, scrollon, 10); - optionBrowser4.SetPosition(0, 90); - optionBrowser4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + GuiCustomOptionBrowser optionBrowser4(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, scrollon, 10); + optionBrowser4.SetPosition(0, 90); + optionBrowser4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); HaltGui(); - GuiWindow w(screenwidth, screenheight); - w.Append(&oggmenubackground); - w.Append(&pathBtn); + GuiWindow w(screenwidth, screenheight); + w.Append(&oggmenubackground); + w.Append(&pathBtn); w.Append(&backBtn); - w.Append(&defaultBtn); - w.Append(&updateBtn); + w.Append(&defaultBtn); + w.Append(&updateBtn); w.Append(&optionBrowser4); mainWindow->Append(&w); - w.SetEffect(EFFECT_FADE, 20); - ResumeGui(); + 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) - Sys_Shutdown(); - else if(reset == 1) - Sys_Reboot(); + if (shutdown == 1) + Sys_Shutdown(); + else if (reset == 1) + Sys_Reboot(); - else if (backBtn.GetState() == STATE_CLICKED) { + else if (backBtn.GetState() == STATE_CLICKED) { - backBtn.ResetState(); - break; - } + backBtn.ResetState(); + break; + } - else if (defaultBtn.GetState() == STATE_CLICKED) { + else if (defaultBtn.GetState() == STATE_CLICKED) { choice = WindowPrompt(tr("Loading standard language."),0,tr("OK"), tr("Cancel")); if (choice == 1) { - sprintf(Settings.language_path, "notset"); - cfg_save_global(); - gettextCleanUp(); - //lang_default(); - CFG_Load(); - returnhere = 2; + sprintf(Settings.language_path, "notset"); + cfg_save_global(); + gettextCleanUp(); + //lang_default(); + CFG_Load(); + returnhere = 2; } defaultBtn.ResetState(); - optionBrowser4.SetFocus(1); - } + optionBrowser4.SetFocus(1); + } - else if (updateBtn.GetState() == STATE_CLICKED) { + else if (updateBtn.GetState() == STATE_CLICKED) { choice = WindowPrompt(tr("Update all Language Files"),tr("Do you wish to update/download all language files?"),tr("OK"), tr("Cancel")); 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)); @@ -528,29 +524,29 @@ int MenuLanguageSelect() } } updateBtn.ResetState(); - optionBrowser4.SetFocus(1); - } + optionBrowser4.SetFocus(1); + } - else if (pathBtn.GetState() == STATE_CLICKED) { + else if (pathBtn.GetState() == STATE_CLICKED) { w.Remove(&optionBrowser4); w.Remove(&backBtn); w.Remove(&pathBtn); - w.Remove(&defaultBtn); + w.Remove(&defaultBtn); char entered[43] = ""; strncpy(entered, Settings.languagefiles_path, sizeof(entered)); int result = OnScreenKeyboard(entered,43,0); w.Append(&optionBrowser4); w.Append(&pathBtn); w.Append(&backBtn); - w.Append(&defaultBtn); + w.Append(&defaultBtn); if ( result == 1 ) { int len = (strlen(entered)-1); - if(entered[len] !='/') - strncat (entered, "/", 1); + 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,45 +554,45 @@ 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(); + } + + ret = optionBrowser4.GetClickedOption(); + + if (ret>=0) { + choice = WindowPrompt(tr("Do you want to change language?"), 0, tr("Yes"), tr("Cancel")); + if (choice == 1) { +// if(isSdInserted()) { + 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)) { + sprintf(Settings.language_path, tr("not set")); + WindowPrompt(tr("File not found."),tr("Loading standard language."),tr("OK")); + } + gettextCleanUp(); + //lang_default(); + CFG_Load(); + returnhere = 2; + break; + } else { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK"), 0,0,0,-1); + } + } optionBrowser4.SetFocus(1); } - pathBtn.ResetState(); + } - ret = optionBrowser4.GetClickedOption(); + w.SetEffect(EFFECT_FADE, -20); + while (w.GetEffect()>0) usleep(50); - if(ret>=0) { - choice = WindowPrompt(tr("Do you want to change language?"), 0, tr("Yes"), tr("Cancel")); - if(choice == 1) { -// if(isSdInserted()) { - 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)) { - sprintf(Settings.language_path, tr("not set")); - WindowPrompt(tr("File not found."),tr("Loading standard language."),tr("OK")); - } - gettextCleanUp(); - //lang_default(); - CFG_Load(); - returnhere = 2; - break; - } else { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK"), 0,0,0,-1); - } - } - optionBrowser4.SetFocus(1); - } - - } - - w.SetEffect(EFFECT_FADE, -20); - while(w.GetEffect()>0) usleep(50); - - HaltGui(); - mainWindow->Remove(&w); - ResumeGui(); + HaltGui(); + mainWindow->Remove(&w); + ResumeGui(); return returnhere; } diff --git a/source/settings/cfg.c b/source/settings/cfg.c index 40189247..71ef066b 100644 --- a/source/settings/cfg.c +++ b/source/settings/cfg.c @@ -42,16 +42,14 @@ char alternatedname[40]; #define TITLE_MAX 200 -struct ID_Title -{ - u8 id[5]; - char title[TITLE_MAX]; +struct ID_Title { + u8 id[5]; + char title[TITLE_MAX]; }; -struct ID_Control -{ - u8 id[5]; - u8 block; +struct ID_Control { + u8 id[5]; + u8 block; }; // renamed titles int num_title = 0; //number of titles @@ -72,1070 +70,1008 @@ struct Game_NUM cfg_game_num[MAX_SAVED_GAME_NUM]; static char *cfg_name, *cfg_val; -struct TextMap -{ - char *name; - int id; +struct TextMap { + char *name; + int id; }; -struct TextMap map_video[] = -{ - { "system", CFG_VIDEO_SYS }, - { "game", CFG_VIDEO_GAME }, - { "patch", CFG_VIDEO_PATCH }, - { "pal50", CFG_VIDEO_PAL50 }, - { "pal60", CFG_VIDEO_PAL60 }, - { "ntsc", CFG_VIDEO_NTSC }, - { NULL, -1 } +struct TextMap map_video[] = { + { "system", CFG_VIDEO_SYS }, + { "game", CFG_VIDEO_GAME }, + { "patch", CFG_VIDEO_PATCH }, + { "pal50", CFG_VIDEO_PAL50 }, + { "pal60", CFG_VIDEO_PAL60 }, + { "ntsc", CFG_VIDEO_NTSC }, + { NULL, -1 } }; -struct TextMap map_language[] = -{ - { "console", CFG_LANG_CONSOLE }, - { "japanese", CFG_LANG_JAPANESE }, - { "english", CFG_LANG_ENGLISH }, - { "german", CFG_LANG_GERMAN }, - { "french", CFG_LANG_FRENCH }, - { "spanish", CFG_LANG_SPANISH }, - { "italian", CFG_LANG_ITALIAN }, - { "dutch", CFG_LANG_DUTCH }, - { "s.chinese", CFG_LANG_S_CHINESE }, - { "t.chinese", CFG_LANG_T_CHINESE }, - { "korean", CFG_LANG_KOREAN }, - { NULL, -1 } +struct TextMap map_language[] = { + { "console", CFG_LANG_CONSOLE }, + { "japanese", CFG_LANG_JAPANESE }, + { "english", CFG_LANG_ENGLISH }, + { "german", CFG_LANG_GERMAN }, + { "french", CFG_LANG_FRENCH }, + { "spanish", CFG_LANG_SPANISH }, + { "italian", CFG_LANG_ITALIAN }, + { "dutch", CFG_LANG_DUTCH }, + { "s.chinese", CFG_LANG_S_CHINESE }, + { "t.chinese", CFG_LANG_T_CHINESE }, + { "korean", CFG_LANG_KOREAN }, + { NULL, -1 } }; -struct TextMap map_alignment[] = -{ - { "left", CFG_ALIGN_LEFT }, - { "right", CFG_ALIGN_RIGHT }, - { "center", CFG_ALIGN_CENTRE }, - { "top", CFG_ALIGN_TOP }, - { "bottom", CFG_ALIGN_BOTTOM }, - { "middle", CFG_ALIGN_MIDDLE }, - { NULL, -1 } +struct TextMap map_alignment[] = { + { "left", CFG_ALIGN_LEFT }, + { "right", CFG_ALIGN_RIGHT }, + { "center", CFG_ALIGN_CENTRE }, + { "top", CFG_ALIGN_TOP }, + { "bottom", CFG_ALIGN_BOTTOM }, + { "middle", CFG_ALIGN_MIDDLE }, + { NULL, -1 } }; -char* strcopy(char *dest, char *src, int size) -{ - strncpy(dest,src,size); - dest[size-1] = 0; - return dest; +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 i; - for (i=0; map[i].name != NULL; i++) { - if (strcmp(name, map[i].name) == 0) return map[i].id; - } - return -1; +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; + } + return -1; } -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; - } - return NULL; +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; + } + return NULL; } -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) { - //printf("MAP FAIL: %s=%s : %d\n", name, val, id); sleep(1); - return false; - } - *var = id; - //printf("MAP AUTO: %s=%s : %d\n", name, val, id); sleep(1); - return true; +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) { + //printf("MAP FAIL: %s=%s : %d\n", name, val, id); sleep(1); + return false; + } + *var = id; + //printf("MAP AUTO: %s=%s : %d\n", name, val, id); sleep(1); + return true; } -bool cfg_map_auto(char *name, struct TextMap *map, short *var) -{ - return map_auto(name, cfg_name, cfg_val, map, 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) - { - *var = id; - return true; - } - return false; +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) -{ - return (cfg_map(name, "0", var, 0) || cfg_map(name, "1", var, 1)); +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) -{ - char tmp[5]; - short i; +void cfg_int(char *name, short *var, int count) { + char tmp[5]; + short i; - if (count > 10) //avoid overflow - return; + if (count > 10) //avoid overflow + return; - for (i = 0; i < count; i++) - { - sprintf(tmp, "%d", i); - cfg_map(name, tmp, var, i); - } + for (i = 0; i < count; i++) { + sprintf(tmp, "%d", i); + cfg_map(name, tmp, var, i); + } } /* Mapping */ //static char bg_path[100]; -void CFG_Default(int widescreen) // -1 = non forced Mode -{ - if(widescreen == -1) - CFG.widescreen = CONF_GetAspectRatio(); - else - CFG.widescreen = widescreen; +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 - { - snprintf(CFG.theme_path, sizeof(CFG.theme_path), "%s/theme/", bootDevice); - } + if (CFG.widescreen) { + snprintf(CFG.theme_path, sizeof(CFG.theme_path), "%s/wtheme/", bootDevice); + } else { + snprintf(CFG.theme_path, sizeof(CFG.theme_path), "%s/theme/", bootDevice); + } - 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 - char * empty = ""; - snprintf(Settings.unlockCode, sizeof(Settings.unlockCode), empty); // default password - snprintf(Settings.language_path, sizeof(Settings.language_path), "notset"); - snprintf(Settings.languagefiles_path, sizeof(Settings.languagefiles_path), "%s/config/language/", bootDevice); - snprintf(Settings.oggload_path, sizeof(Settings.oggload_path), "%s/config/backgroundmusic/", bootDevice); - snprintf(Settings.update_path, sizeof(Settings.update_path), "%s/apps/usbloader_gx/", bootDevice); - snprintf(Settings.homebrewapps_path, sizeof(Settings.homebrewapps_path), "%s/apps/", bootDevice); - snprintf(Settings.Cheatcodespath, sizeof(Settings.Cheatcodespath), "%s/codes/", bootDevice); - snprintf(Settings.TxtCheatcodespath, sizeof(Settings.TxtCheatcodespath), "%s/txtcodes/", bootDevice); - snprintf(Settings.dolpath, sizeof(Settings.dolpath), "%s/", bootDevice); - sprintf(Settings.ogg_path, "notset"); + 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 + char * empty = ""; + snprintf(Settings.unlockCode, sizeof(Settings.unlockCode), empty); // default password + snprintf(Settings.language_path, sizeof(Settings.language_path), "notset"); + snprintf(Settings.languagefiles_path, sizeof(Settings.languagefiles_path), "%s/config/language/", bootDevice); + snprintf(Settings.oggload_path, sizeof(Settings.oggload_path), "%s/config/backgroundmusic/", bootDevice); + snprintf(Settings.update_path, sizeof(Settings.update_path), "%s/apps/usbloader_gx/", bootDevice); + snprintf(Settings.homebrewapps_path, sizeof(Settings.homebrewapps_path), "%s/apps/", bootDevice); + snprintf(Settings.Cheatcodespath, sizeof(Settings.Cheatcodespath), "%s/codes/", bootDevice); + snprintf(Settings.TxtCheatcodespath, sizeof(Settings.TxtCheatcodespath), "%s/txtcodes/", bootDevice); + snprintf(Settings.dolpath, sizeof(Settings.dolpath), "%s/", bootDevice); + sprintf(Settings.ogg_path, "notset"); - //all alignments are left top here - THEME.selection_x = 200; - THEME.selection_y = 49;//40; - THEME.selection_w = 396; - THEME.selection_h = 280; - THEME.batteryUnused = 70; - THEME.gamegrid_w = 640; - THEME.gamegrid_h = 400; - THEME.gamegrid_x = 0; - THEME.gamegrid_y = 20; - THEME.gamecarousel_w = 640; - THEME.gamecarousel_h = 400; - THEME.gamecarousel_x = 0; - THEME.gamecarousel_y = -20; - THEME.clock_r = 138; - THEME.clock_g = 138; - THEME.clock_b = 138; - THEME.settingsTxt_r = 0; - THEME.settingsTxt_g = 0; - THEME.settingsTxt_b = 0; - THEME.cover_x = 26; - THEME.cover_y = 58; - THEME.homebrew_x = 425; - THEME.homebrew_y = 400; - THEME.showID = 1; - // THEME.maxcharacters = 36; - THEME.id_x = 68; - THEME.id_y = 305; - THEME.region_x = 68; - THEME.region_y = 30; - THEME.power_x = 576; - THEME.tooltipAlpha = 255; - THEME.power_y = 355; - THEME.home_x = 485;//215; - THEME.home_y = 367; - THEME.setting_x = 60;//-210 - THEME.setting_y = 367; - THEME.showHDD = 1; //default - THEME.showGameCnt = 1; //default - THEME.showToolTip = 1; //1 means use settings, 0 means force turn off - THEME.install_x = 16;//-280 - THEME.install_y = 355; - THEME.showBattery = 1; - THEME.showRegion = 1; - THEME.hddInfo_x = 0; - THEME.hddInfo_y = 410; - THEME.hddInfoAlign = CFG_ALIGN_CENTRE; - THEME.gameCnt_x = 0; - THEME.gameCnt_y = 430; - THEME.gameCntAlign = CFG_ALIGN_CENTRE; - THEME.battery1_x = 245; - THEME.battery1_y = 400; - THEME.battery2_x = 335; - THEME.battery2_y = 400; - THEME.battery3_x = 245; - THEME.battery3_y = 425; - THEME.battery4_x = 335; - THEME.battery4_y = 425; - THEME.info_r = 55; - THEME.info_g = 190; - THEME.info_b = 237; - THEME.prompttxt_r = 0; - THEME.prompttxt_g = 0; - THEME.prompttxt_b = 0; - THEME.clock_x = 0; - THEME.clock_y = 335;//330; - THEME.clockAlign = CFG_ALIGN_CENTRE; - THEME.sdcard_x = 150; - THEME.sdcard_y = 390; - THEME.gameText_r = 0; - THEME.gameText_g = 0; - THEME.gameText_b = 0; - THEME.pagesize = 9; - THEME.favorite_x = 4; - THEME.favorite_y = 13; - THEME.abc_x = 36; - THEME.abc_y = 13; - THEME.list_x = 100; - THEME.list_y = 13; - THEME.grid_x = 132; - THEME.grid_y = 13; - THEME.carousel_x = 164; - THEME.carousel_y = 13; - THEME.count_x = 68; - THEME.count_y = 13; - THEME.sortBarOffset = 100; - } + //all alignments are left top here + THEME.selection_x = 200; + THEME.selection_y = 49;//40; + THEME.selection_w = 396; + THEME.selection_h = 280; + THEME.batteryUnused = 70; + THEME.gamegrid_w = 640; + THEME.gamegrid_h = 400; + THEME.gamegrid_x = 0; + THEME.gamegrid_y = 20; + THEME.gamecarousel_w = 640; + THEME.gamecarousel_h = 400; + THEME.gamecarousel_x = 0; + THEME.gamecarousel_y = -20; + THEME.clock_r = 138; + THEME.clock_g = 138; + THEME.clock_b = 138; + THEME.settingsTxt_r = 0; + THEME.settingsTxt_g = 0; + THEME.settingsTxt_b = 0; + THEME.cover_x = 26; + THEME.cover_y = 58; + THEME.homebrew_x = 425; + THEME.homebrew_y = 400; + THEME.showID = 1; + // THEME.maxcharacters = 36; + THEME.id_x = 68; + THEME.id_y = 305; + THEME.region_x = 68; + THEME.region_y = 30; + THEME.power_x = 576; + THEME.tooltipAlpha = 255; + THEME.power_y = 355; + THEME.home_x = 485;//215; + THEME.home_y = 367; + THEME.setting_x = 60;//-210 + THEME.setting_y = 367; + THEME.showHDD = 1; //default + THEME.showGameCnt = 1; //default + THEME.showToolTip = 1; //1 means use settings, 0 means force turn off + THEME.install_x = 16;//-280 + THEME.install_y = 355; + THEME.showBattery = 1; + THEME.showRegion = 1; + THEME.hddInfo_x = 0; + THEME.hddInfo_y = 410; + THEME.hddInfoAlign = CFG_ALIGN_CENTRE; + THEME.gameCnt_x = 0; + THEME.gameCnt_y = 430; + THEME.gameCntAlign = CFG_ALIGN_CENTRE; + THEME.battery1_x = 245; + THEME.battery1_y = 400; + THEME.battery2_x = 335; + THEME.battery2_y = 400; + THEME.battery3_x = 245; + THEME.battery3_y = 425; + THEME.battery4_x = 335; + THEME.battery4_y = 425; + THEME.info_r = 55; + THEME.info_g = 190; + THEME.info_b = 237; + THEME.prompttxt_r = 0; + THEME.prompttxt_g = 0; + THEME.prompttxt_b = 0; + THEME.clock_x = 0; + THEME.clock_y = 335;//330; + THEME.clockAlign = CFG_ALIGN_CENTRE; + THEME.sdcard_x = 150; + THEME.sdcard_y = 390; + THEME.gameText_r = 0; + THEME.gameText_g = 0; + THEME.gameText_b = 0; + THEME.pagesize = 9; + THEME.favorite_x = 4; + THEME.favorite_y = 13; + THEME.abc_x = 36; + THEME.abc_y = 13; + THEME.list_x = 100; + THEME.list_y = 13; + THEME.grid_x = 132; + THEME.grid_y = 13; + THEME.carousel_x = 164; + THEME.carousel_y = 13; + THEME.count_x = 68; + THEME.count_y = 13; + THEME.sortBarOffset = 100; + } } -void Global_Default(void) -{ - Settings.video = discdefault; - Settings.vpatch = off; - Settings.language = ConsoleLangDefault; - Settings.ocarina = off; - Settings.hddinfo = hr12; - Settings.sinfo = ((THEME.showID) ? GameID : Neither); - Settings.rumble = RumbleOn; - if (THEME.showRegion) - { - Settings.sinfo = ((Settings.sinfo == GameID) ? Both : GameRegion); - } - Settings.volume = 80; - Settings.sfxvolume = 80; - Settings.tooltips = TooltipsOn; - char * empty = ""; - snprintf(Settings.unlockCode, sizeof(Settings.unlockCode), empty); - Settings.godmode = 1; - Settings.parentalcontrol = 0; - Settings.cios = ios249; - Settings.xflip = no; - Settings.qboot = no; - Settings.wiilight = 1; - Settings.autonetwork = 0; - Settings.patchcountrystrings = 0; - Settings.gridRows = 3; - Settings.error002 = 0; - Settings.titlesOverride = 0; - snprintf(Settings.db_url, sizeof(Settings.db_url), empty); - snprintf(Settings.db_language, sizeof(Settings.db_language), empty); - Settings.db_JPtoEN = 0; - Settings.screensaver = 3; +void Global_Default(void) { + Settings.video = discdefault; + Settings.vpatch = off; + Settings.language = ConsoleLangDefault; + Settings.ocarina = off; + Settings.hddinfo = hr12; + Settings.sinfo = ((THEME.showID) ? GameID : Neither); + Settings.rumble = RumbleOn; + if (THEME.showRegion) { + Settings.sinfo = ((Settings.sinfo == GameID) ? Both : GameRegion); + } + Settings.volume = 80; + Settings.sfxvolume = 80; + Settings.tooltips = TooltipsOn; + char * empty = ""; + snprintf(Settings.unlockCode, sizeof(Settings.unlockCode), empty); + Settings.godmode = 1; + Settings.parentalcontrol = 0; + Settings.cios = ios249; + Settings.xflip = no; + Settings.qboot = no; + Settings.wiilight = 1; + Settings.autonetwork = 0; + Settings.patchcountrystrings = 0; + Settings.gridRows = 3; + Settings.error002 = 0; + Settings.titlesOverride = 0; + snprintf(Settings.db_url, sizeof(Settings.db_url), empty); + snprintf(Settings.db_language, sizeof(Settings.db_language), empty); + Settings.db_JPtoEN = 0; + Settings.screensaver = 3; } -char *cfg_get_title(u8 *id) -{ - int i; - for (i=0; iid); - if (title) return title; - return header->title; +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) -{ - char *idt = cfg_get_title((u8*)id); - if (idt) { - // replace - strcopy(idt, title, TITLE_MAX); - } else { - cfg_title = realloc(cfg_title, (num_title+1) * sizeof(struct ID_Title)); - if (!cfg_title) { - // error - num_title = 0; - return; - } - // add - memcpy(cfg_title[num_title].id, id, 4); - cfg_title[num_title].id[4] = 0; - strcopy(cfg_title[num_title].title, title, TITLE_MAX); - num_title++; - } +void title_set(char *id, char *title) { + char *idt = cfg_get_title((u8*)id); + if (idt) { + // replace + strcopy(idt, title, TITLE_MAX); + } else { + cfg_title = realloc(cfg_title, (num_title+1) * sizeof(struct ID_Title)); + if (!cfg_title) { + // error + num_title = 0; + return; + } + // add + memcpy(cfg_title[num_title].id, id, 4); + cfg_title[num_title].id[4] = 0; + strcopy(cfg_title[num_title].title, title, TITLE_MAX); + num_title++; + } } -u8 cfg_get_block(u8 *id) -{ - int i; - for (i=0; iid); +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) -{ - int len; - // trim leading white space - while (isspace(*src)) { src++; n--; } - len = strlen(src); - if (len > n) len = n; - // trim trailing white space - while (len > 0 && isspace(src[len-1])) len--; - if (len >= size) len = size-1; - strncpy(dest, src, len); - dest[len] = 0; - //printf("trim_copy: '%s' %d\n", dest, len); //sleep(1); - return dest; +char* trim_n_copy(char *dest, char *src, int n, int size) { + int len; + // trim leading white space + while (isspace(*src)) { + src++; + n--; + } + len = strlen(src); + if (len > n) len = n; + // trim trailing white space + while (len > 0 && isspace(src[len-1])) len--; + if (len >= size) len = size-1; + strncpy(dest, src, len); + dest[len] = 0; + //printf("trim_copy: '%s' %d\n", dest, len); //sleep(1); + return dest; } -char* trimcopy(char *dest, char *src, int size) -{ - int len; - while (*src == ' ') src++; - len = strlen(src); - // trim trailing " \r\n" - while (len > 0 && strchr(" \r\n", src[len-1])) len--; - if (len >= size) len = size-1; - strncpy(dest, src, len); - dest[len] = 0; - return dest; +char* trimcopy(char *dest, char *src, int size) { + int len; + while (*src == ' ') src++; + len = strlen(src); + // trim trailing " \r\n" + while (len > 0 && strchr(" \r\n", src[len-1])) len--; + if (len >= size) len = size-1; + strncpy(dest, src, len); + dest[len] = 0; + return dest; } -void widescreen_set(char *name, char *val) -{ - cfg_name = name; - cfg_val = val; +void widescreen_set(char *name, char *val) { + cfg_name = name; + cfg_val = val; - short widescreen; - if (cfg_bool("widescreen", &widescreen) && CFG.widescreen != widescreen) - CFG_Default(widescreen); //reset default when forced an other Screenmode + short widescreen; + if (cfg_bool("widescreen", &widescreen) && CFG.widescreen != widescreen) + CFG_Default(widescreen); //reset default when forced an other Screenmode } -void path_set(char *name, char *val) -{ - cfg_name = name; - cfg_val = val; +void path_set(char *name, char *val) { + cfg_name = name; + cfg_val = val; - // if these are defined in txt file, use them. otherwise use defaults + // if these are defined in txt file, use them. otherwise use defaults - if (!CFG.widescreen &&(strcmp(name, "theme_path") == 0)) {// if in 4:3 - strcopy(CFG.theme_path, val, sizeof(CFG.theme_path)); - return; - } + if (!CFG.widescreen &&(strcmp(name, "theme_path") == 0)) {// if in 4:3 + strcopy(CFG.theme_path, val, sizeof(CFG.theme_path)); + return; + } - if (CFG.widescreen && strcmp(name, "wtheme_path") == 0) { // if in 16:9 - strcopy(CFG.theme_path, val, sizeof(CFG.theme_path)); - return; - } + if (CFG.widescreen && strcmp(name, "wtheme_path") == 0) { // if in 16:9 + strcopy(CFG.theme_path, val, sizeof(CFG.theme_path)); + return; + } - if (strcmp(name, "cover_path") == 0) { - strcopy(Settings.covers_path, val, sizeof(Settings.covers_path)); - return; - } + if (strcmp(name, "cover_path") == 0) { + strcopy(Settings.covers_path, val, sizeof(Settings.covers_path)); + return; + } - if (strcmp(name, "disc_path") == 0) { - strcopy(Settings.disc_path, val, sizeof(Settings.disc_path)); - return; - } + if (strcmp(name, "disc_path") == 0) { + strcopy(Settings.disc_path, val, sizeof(Settings.disc_path)); + return; + } if (strcmp(name, "titlestxt_path") == 0) { - strcopy(Settings.titlestxt_path, val, sizeof(Settings.titlestxt_path)); - return; - } - if (strcmp(name, "language_path") == 0) { - strcopy(Settings.language_path, val, sizeof(Settings.language_path)); - return; - } - if (strcmp(name, "languagefiles_path") == 0) { - strcopy(Settings.languagefiles_path, val, sizeof(Settings.languagefiles_path)); - return; - } - if (strcmp(name, "update_path") == 0) { - strcopy(Settings.update_path, val, sizeof(Settings.update_path)); - return; - } - if (strcmp(name, "homebrewapps_path") == 0) { - strcopy(Settings.homebrewapps_path, val, sizeof(Settings.homebrewapps_path)); - return; - } - if (strcmp(name, "Cheatcodespath") == 0) { - strcopy(Settings.Cheatcodespath, val, sizeof(Settings.Cheatcodespath)); - return; - } - if (strcmp(name, "TxtCheatcodespath") == 0) { - strcopy(Settings.TxtCheatcodespath, val, sizeof(Settings.TxtCheatcodespath)); - return; - } - if (strcmp(name, "oggload_path") == 0) { - strcopy(Settings.oggload_path, val, sizeof(Settings.oggload_path)); - return; - } + strcopy(Settings.titlestxt_path, val, sizeof(Settings.titlestxt_path)); + return; + } + if (strcmp(name, "language_path") == 0) { + strcopy(Settings.language_path, val, sizeof(Settings.language_path)); + return; + } + if (strcmp(name, "languagefiles_path") == 0) { + strcopy(Settings.languagefiles_path, val, sizeof(Settings.languagefiles_path)); + return; + } + if (strcmp(name, "update_path") == 0) { + strcopy(Settings.update_path, val, sizeof(Settings.update_path)); + return; + } + if (strcmp(name, "homebrewapps_path") == 0) { + strcopy(Settings.homebrewapps_path, val, sizeof(Settings.homebrewapps_path)); + return; + } + if (strcmp(name, "Cheatcodespath") == 0) { + strcopy(Settings.Cheatcodespath, val, sizeof(Settings.Cheatcodespath)); + return; + } + if (strcmp(name, "TxtCheatcodespath") == 0) { + strcopy(Settings.TxtCheatcodespath, val, sizeof(Settings.TxtCheatcodespath)); + return; + } + if (strcmp(name, "oggload_path") == 0) { + strcopy(Settings.oggload_path, val, sizeof(Settings.oggload_path)); + return; + } if (strcmp(name, "dolpath") == 0) { - strcopy(Settings.dolpath, val, sizeof(Settings.dolpath)); - return; - } + strcopy(Settings.dolpath, val, sizeof(Settings.dolpath)); + return; + } if (strcmp(name, "ogg_path") == 0) { - strcopy(Settings.ogg_path, val, sizeof(Settings.ogg_path)); - return; - } + strcopy(Settings.ogg_path, val, sizeof(Settings.ogg_path)); + return; + } - return; + return; } -void theme_set(char *name, char *val) -{ - cfg_name = name; - cfg_val = val; +void theme_set(char *name, char *val) { + cfg_name = name; + cfg_val = val; - 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); - THEME.selection_y = y; - THEME.selection_w = w; - THEME.selection_h = h; - } - } + 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); + THEME.selection_y = y; + THEME.selection_w = w; + THEME.selection_h = h; + } + } - 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); - THEME.gamegrid_y = y; - THEME.gamegrid_w = w; - THEME.gamegrid_h = h; - } - } + 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); + THEME.gamegrid_y = y; + THEME.gamegrid_w = w; + THEME.gamegrid_h = h; + } + } - 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); - THEME.gamecarousel_y = y; - THEME.gamecarousel_w = w; - THEME.gamecarousel_h = h; - } - } + 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); + THEME.gamecarousel_y = y; + THEME.gamecarousel_w = w; + THEME.gamecarousel_h = h; + } + } - else if (strcmp(cfg_name, "covers_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.cover_x = x - (x % 4); - THEME.cover_y = y; - } - } + else if (strcmp(cfg_name, "covers_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.cover_x = x - (x % 4); + THEME.cover_y = y; + } + } - else if (strcmp(cfg_name, "id_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.id_x = x - (x % 4); - THEME.id_y = y; - } - } + else if (strcmp(cfg_name, "id_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.id_x = x - (x % 4); + THEME.id_y = y; + } + } - else if (strcmp(cfg_name, "hddinfo_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.hddInfo_x = x - (x % 4); - THEME.hddInfo_y = y; - } - } + else if (strcmp(cfg_name, "hddinfo_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.hddInfo_x = x - (x % 4); + THEME.hddInfo_y = y; + } + } - else if (strcmp(cfg_name, "gamecount_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.gameCnt_x = x - (x % 4); - THEME.gameCnt_y = y; - } - } + else if (strcmp(cfg_name, "gamecount_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.gameCnt_x = x - (x % 4); + THEME.gameCnt_y = y; + } + } - else if (strcmp(cfg_name, "region_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.region_x = x - (x % 4); - THEME.region_y = y; - } - } + else if (strcmp(cfg_name, "region_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.region_x = x - (x % 4); + THEME.region_y = y; + } + } - else if (strcmp(cfg_name, "homebrew_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.homebrew_x = x - (x % 4); - THEME.homebrew_y = y; - } - } + else if (strcmp(cfg_name, "homebrew_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.homebrew_x = x - (x % 4); + THEME.homebrew_y = y; + } + } - else if (strcmp(cfg_name, "power_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.power_x = x - (x % 4); - THEME.power_y = y; - } - } + else if (strcmp(cfg_name, "power_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.power_x = x - (x % 4); + THEME.power_y = y; + } + } - else if (strcmp(cfg_name, "home_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.home_x = x - (x % 4); - THEME.home_y = y; - } - } + else if (strcmp(cfg_name, "home_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.home_x = x - (x % 4); + THEME.home_y = y; + } + } - else if (strcmp(cfg_name, "setting_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.setting_x = x - (x % 4); - THEME.setting_y = y; - } - } + else if (strcmp(cfg_name, "setting_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.setting_x = x - (x % 4); + THEME.setting_y = y; + } + } - else if (strcmp(cfg_name, "install_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.install_x = x - (x % 4); - THEME.install_y = y; - } - } + else if (strcmp(cfg_name, "install_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.install_x = x - (x % 4); + THEME.install_y = y; + } + } - else if (strcmp(cfg_name, "battery1_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.battery1_x = x - (x % 4); - THEME.battery1_y = y; - } - } + else if (strcmp(cfg_name, "battery1_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.battery1_x = x - (x % 4); + THEME.battery1_y = y; + } + } - else if (strcmp(cfg_name, "battery2_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.battery2_x = x - (x % 4); - THEME.battery2_y = y; - } - } + else if (strcmp(cfg_name, "battery2_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.battery2_x = x - (x % 4); + THEME.battery2_y = y; + } + } - else if (strcmp(cfg_name, "battery3_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.battery3_x = x - (x % 4); - THEME.battery3_y = y; - } - } + else if (strcmp(cfg_name, "battery3_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.battery3_x = x - (x % 4); + THEME.battery3_y = y; + } + } - else if (strcmp(cfg_name, "battery4_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.battery4_x = x - (x % 4); - THEME.battery4_y = y; - } - } + else if (strcmp(cfg_name, "battery4_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.battery4_x = x - (x % 4); + THEME.battery4_y = y; + } + } - else if (strcmp(cfg_name, "clock_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.clock_x = x - (x % 4); - THEME.clock_y = y; - } - } + else if (strcmp(cfg_name, "clock_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.clock_x = x - (x % 4); + THEME.clock_y = y; + } + } - else if (strcmp(cfg_name, "sdcard_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.sdcard_x = x - (x % 4); - THEME.sdcard_y = y; - } - } + else if (strcmp(cfg_name, "sdcard_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.sdcard_x = x - (x % 4); + THEME.sdcard_y = y; + } + } - else if (strcmp(cfg_name, "favorite_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.favorite_x = x - (x % 4); - THEME.favorite_y = y; - } - } + else if (strcmp(cfg_name, "favorite_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.favorite_x = x - (x % 4); + THEME.favorite_y = y; + } + } - else if (strcmp(cfg_name, "abc_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.abc_x = x - (x % 4); - THEME.abc_y = y; - } - } + else if (strcmp(cfg_name, "abc_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.abc_x = x - (x % 4); + THEME.abc_y = y; + } + } - else if (strcmp(cfg_name, "count_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.count_x = x - (x % 4); - THEME.count_y = y; - } - } + else if (strcmp(cfg_name, "count_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.count_x = x - (x % 4); + THEME.count_y = y; + } + } - else if (strcmp(cfg_name, "carousel_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.carousel_x = x - (x % 4); - THEME.carousel_y = y; - } - } + else if (strcmp(cfg_name, "carousel_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.carousel_x = x - (x % 4); + THEME.carousel_y = y; + } + } - else if (strcmp(cfg_name, "grid_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.grid_x = x - (x % 4); - THEME.grid_y = y; - } - } + else if (strcmp(cfg_name, "grid_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.grid_x = x - (x % 4); + THEME.grid_y = y; + } + } - else if (strcmp(cfg_name, "list_coords") == 0) { - short x,y; - if (sscanf(val, "%hd,%hd", &x, &y) == 2) { - THEME.list_x = x - (x % 4); - THEME.list_y = y; - } - } + else if (strcmp(cfg_name, "list_coords") == 0) { + short x,y; + if (sscanf(val, "%hd,%hd", &x, &y) == 2) { + THEME.list_x = x - (x % 4); + THEME.list_y = y; + } + } - else if (strcmp(cfg_name, "sortBarOffset") == 0) { - short x; - if (sscanf(val, "%hd", &x) == 1) { - THEME.sortBarOffset = x; - } - } + else if (strcmp(cfg_name, "sortBarOffset") == 0) { + short x; + if (sscanf(val, "%hd", &x) == 1) { + THEME.sortBarOffset = x; + } + } - else if (strcmp(cfg_name, "info_color") == 0) { - short x,y,z; - if (sscanf(val, "%hd,%hd, %hd", &x, &y, &z) == 3) { - THEME.info_r = x; - THEME.info_g = y; - THEME.info_b = z; - } - } + else if (strcmp(cfg_name, "info_color") == 0) { + short x,y,z; + if (sscanf(val, "%hd,%hd, %hd", &x, &y, &z) == 3) { + THEME.info_r = x; + THEME.info_g = y; + THEME.info_b = z; + } + } - else if (strcmp(cfg_name, "gametext_color") == 0) { - short x,y,z; - if (sscanf(val, "%hd,%hd, %hd", &x, &y, &z) == 3) { - THEME.gameText_r = x; - THEME.gameText_g = y; - THEME.gameText_b = z; - } - } + else if (strcmp(cfg_name, "gametext_color") == 0) { + short x,y,z; + if (sscanf(val, "%hd,%hd, %hd", &x, &y, &z) == 3) { + THEME.gameText_r = x; + THEME.gameText_g = y; + THEME.gameText_b = z; + } + } - else if (strcmp(cfg_name, "prompttext_color") == 0) { - short x,y,z; - if (sscanf(val, "%hd,%hd, %hd", &x, &y, &z) == 3) { - THEME.prompttxt_r = x; - THEME.prompttxt_g = y; - THEME.prompttxt_b = z; - } - } + else if (strcmp(cfg_name, "prompttext_color") == 0) { + short x,y,z; + if (sscanf(val, "%hd,%hd, %hd", &x, &y, &z) == 3) { + THEME.prompttxt_r = x; + THEME.prompttxt_g = y; + THEME.prompttxt_b = z; + } + } - else if (strcmp(cfg_name, "clock_color") == 0) { - short x,y,z; - if (sscanf(val, "%hd,%hd, %hd", &x, &y, &z) == 3) { - THEME.clock_r = x; - THEME.clock_g = y; - THEME.clock_b = z; - } - } + else if (strcmp(cfg_name, "clock_color") == 0) { + short x,y,z; + if (sscanf(val, "%hd,%hd, %hd", &x, &y, &z) == 3) { + THEME.clock_r = x; + THEME.clock_g = y; + THEME.clock_b = z; + } + } - else if (strcmp(cfg_name, "settingstext_color") == 0) { - short x,y,z; - if (sscanf(val, "%hd,%hd, %hd", &x, &y, &z) == 3) { - THEME.settingsTxt_r = x; - THEME.settingsTxt_g = y; - THEME.settingsTxt_b = z; - } - } + else if (strcmp(cfg_name, "settingstext_color") == 0) { + short x,y,z; + if (sscanf(val, "%hd,%hd, %hd", &x, &y, &z) == 3) { + THEME.settingsTxt_r = x; + THEME.settingsTxt_g = y; + THEME.settingsTxt_b = z; + } + } - else if (strcmp(cfg_name, "pagesize") == 0) { - short x; - if (sscanf(val, "%hd", &x) == 1) { - THEME.pagesize = x; - } - } + else if (strcmp(cfg_name, "pagesize") == 0) { + short x; + if (sscanf(val, "%hd", &x) == 1) { + THEME.pagesize = x; + } + } - else if (strcmp(cfg_name, "batteryUnused") == 0) { - short x; - if (sscanf(val, "%hd", &x) == 1) { - THEME.batteryUnused = x; - } - } - else if (strcmp(cfg_name, "tooltipAlpha") == 0) { - short x; - if (sscanf(val, "%hd", &x) == 1) { - THEME.tooltipAlpha = x; - } - } + else if (strcmp(cfg_name, "batteryUnused") == 0) { + short x; + if (sscanf(val, "%hd", &x) == 1) { + THEME.batteryUnused = x; + } + } 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; - } - } -*/ + /* + else if (strcmp(cfg_name, "maxcharacters") == 0) { + short x; + if (sscanf(val, "%hd", &x) == 1) { + THEME.maxcharacters = x; + } + } + */ - cfg_bool("show_id", &THEME.showID); - cfg_bool("show_tooltip", &THEME.showToolTip); - cfg_bool("show_hddinfo", &THEME.showHDD); - cfg_bool("show_gamecount", &THEME.showGameCnt); - cfg_bool("show_region", &THEME.showRegion); - cfg_bool("show_battery", &THEME.showBattery); - cfg_map_auto("hddinfo_align", map_alignment, &THEME.hddInfoAlign); - cfg_map_auto("gamecount_align", map_alignment, &THEME.gameCntAlign); - cfg_map_auto("clock_align", map_alignment, &THEME.clockAlign); + cfg_bool("show_id", &THEME.showID); + cfg_bool("show_tooltip", &THEME.showToolTip); + cfg_bool("show_hddinfo", &THEME.showHDD); + cfg_bool("show_gamecount", &THEME.showGameCnt); + cfg_bool("show_region", &THEME.showRegion); + cfg_bool("show_battery", &THEME.showBattery); + cfg_map_auto("hddinfo_align", map_alignment, &THEME.hddInfoAlign); + cfg_map_auto("gamecount_align", map_alignment, &THEME.gameCntAlign); + cfg_map_auto("clock_align", map_alignment, &THEME.clockAlign); - /* - else if (strcmp(cfg_name, "entry_lines") == 0) { - int x; - if (sscanf(val, "%d", &x) == 1) { - ENTRIES_PER_PAGE = x; - } - } + /* + else if (strcmp(cfg_name, "entry_lines") == 0) { + int x; + if (sscanf(val, "%d", &x) == 1) { + ENTRIES_PER_PAGE = x; + } + } - else if (strcmp(cfg_name, "max_characters") == 0) { - int x; - if (sscanf(val, "%d", &x) == 1) { - MAX_CHARACTERS = x; - } - }*/ + else if (strcmp(cfg_name, "max_characters") == 0) { + int x; + if (sscanf(val, "%d", &x) == 1) { + MAX_CHARACTERS = x; + } + }*/ } -void global_cfg_set(char *name, char *val) -{ - cfg_name = name; - cfg_val = val; +void global_cfg_set(char *name, char *val) { + cfg_name = name; + cfg_val = val; - if (strcmp(name, "video") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { - Settings.video = i; - } - return; - } - else if (strcmp(name, "vpatch") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { - Settings.vpatch =i; - } - return; - } + if (strcmp(name, "video") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.video = i; + } + return; + } else if (strcmp(name, "vpatch") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.vpatch =i; + } + return; + } - else if (strcmp(name, "language") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { - Settings.language = i; - } - return; - } - else if (strcmp(name, "ocarina") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { - Settings.ocarina = i; - } - return; - } - else if (strcmp(name, "sort") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { - Settings.sort = i; - } - return; - } - else if (strcmp(name, "fave") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { - Settings.fave = i; - } - return; - } - else if (strcmp(name, "keyset") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { - Settings.keyset = i; - } - return; - } - else if (strcmp(name, "hddinfo") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { - Settings.hddinfo = i; - } - return; - } - else if (strcmp(name, "sinfo") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { - Settings.sinfo = i; - } - return; - } - else if (strcmp(name, "rumble") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { - Settings.rumble = i; - } - return; - } - else if (strcmp(name, "volume") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { - Settings.volume = i; - } - return; - } - else if (strcmp(name, "sfxvolume") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { - Settings.sfxvolume = i; - } - return; - } - else if (strcmp(name, "tooltips") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { - Settings.tooltips = i; - } - return; - } - else if (strcmp(name, "password") == 0) { - strcopy(Settings.unlockCode, val, sizeof(Settings.unlockCode)); - return; - } - else if (strcmp(name, "parentalcontrol") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { - Settings.parentalcontrol = i; - } - return; - } - else if (strcmp(name, "cios") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { + else if (strcmp(name, "language") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.language = i; + } + return; + } else if (strcmp(name, "ocarina") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.ocarina = i; + } + return; + } else if (strcmp(name, "sort") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.sort = i; + } + return; + } else if (strcmp(name, "fave") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.fave = i; + } + return; + } else if (strcmp(name, "keyset") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.keyset = i; + } + return; + } else if (strcmp(name, "hddinfo") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.hddinfo = i; + } + return; + } else if (strcmp(name, "sinfo") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.sinfo = i; + } + return; + } else if (strcmp(name, "rumble") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.rumble = i; + } + return; + } else if (strcmp(name, "volume") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.volume = i; + } + return; + } else if (strcmp(name, "sfxvolume") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.sfxvolume = i; + } + return; + } else if (strcmp(name, "tooltips") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.tooltips = i; + } + return; + } else if (strcmp(name, "password") == 0) { + strcopy(Settings.unlockCode, val, sizeof(Settings.unlockCode)); + return; + } else if (strcmp(name, "parentalcontrol") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.parentalcontrol = i; + } + return; + } else if (strcmp(name, "cios") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { Settings.cios = i; - } - return; - } - else if (strcmp(name, "gridRows") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { + } + return; + } else if (strcmp(name, "gridRows") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { Settings.gridRows = i; - } - return; - } - else if (strcmp(name, "xflip") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { + } + return; + } else if (strcmp(name, "xflip") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { Settings.xflip = i; - } - return; - } - else if (strcmp(name, "qboot") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { + } + return; + } else if (strcmp(name, "qboot") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { Settings.qboot = i; - } - return; - } - else if (strcmp(name, "wsprompt") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { + } + return; + } else if (strcmp(name, "wsprompt") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { Settings.wsprompt = i; - } - return; - } - else if (strcmp(name, "wiilight") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { + } + return; + } else if (strcmp(name, "wiilight") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { Settings.wiilight = i; - } - return; - } - else if (strcmp(name, "autonetwork") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { + } + return; + } else if (strcmp(name, "autonetwork") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { Settings.autonetwork = i; - } - return; - } - else if (strcmp(name, "patchcountrystrings") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { + } + return; + } else if (strcmp(name, "patchcountrystrings") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { Settings.patchcountrystrings = i; - } - return; - } - else if (strcmp(name, "error002") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { + } + return; + } else if (strcmp(name, "error002") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { Settings.error002 = i; - } - return; - } - else if (strcmp(name, "titlesOverride") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { + } + return; + } 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) { - int i; - if (sscanf(val, "%d", &i) == 1) { + } + return; + } 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) { - int i; - if (sscanf(val, "%d", &i) == 1) { + } + return; + } else if (strcmp(name, "gameDisplay") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { Settings.gameDisplay = i; - } - return; - } - else if (strcmp(name, "screensaver") == 0) { - int i; - if (sscanf(val, "%d", &i) == 1) { + } + return; + } else if (strcmp(name, "screensaver") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { Settings.screensaver = i; - } - return; - } + } + return; + } - cfg_bool("godmode", &Settings.godmode); + cfg_bool("godmode", &Settings.godmode); - return; + return; } // split line to part1 delimiter part2 -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; +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*)) -{ - // split name = value - char tmp[200], name[200], val[200]; - strcopy(tmp, line, sizeof(tmp)); - char *eq = strchr(tmp, '='); - if (!eq) return; - *eq = 0; - trimcopy(name, tmp, sizeof(name)); - trimcopy(val, eq+1, sizeof(val)); - //printf("CFG: %s = %s\n", name, val); - set_func(name, val); +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)); + char *eq = strchr(tmp, '='); + if (!eq) return; + *eq = 0; + trimcopy(name, tmp, sizeof(name)); + trimcopy(val, eq+1, sizeof(val)); + //printf("CFG: %s = %s\n", name, val); + set_func(name, val); } -void cfg_parsetitleline(char *line, void (*set_func)(char*, char*, u8)) -{ - // split name = value - char tmp[200], name[200], val[200]; - int block = 0; - strcopy(tmp, line, sizeof(tmp)); - char *eq = strchr(tmp, '='); - if (!eq) return; - *eq = 0; - trimcopy(name, tmp, sizeof(name)); +void cfg_parsetitleline(char *line, void (*set_func)(char*, char*, u8)) { + // split name = value + char tmp[200], name[200], val[200]; + int block = 0; + strcopy(tmp, line, sizeof(tmp)); + char *eq = strchr(tmp, '='); + if (!eq) return; + *eq = 0; + trimcopy(name, tmp, sizeof(name)); - char *blockpos = strrchr(eq+1, '='); + char *blockpos = strrchr(eq+1, '='); - if (!blockpos) - trimcopy(val, eq+1, sizeof(val)); + if (!blockpos) + trimcopy(val, eq+1, sizeof(val)); - else - { - *blockpos = 0; - trimcopy(val, eq+1, sizeof(val)); - if (sscanf(blockpos+1, "%d", &block) != 1) - { - block = 0; - } - } - set_func(name, val, block); + else { + *blockpos = 0; + trimcopy(val, eq+1, sizeof(val)); + if (sscanf(blockpos+1, "%d", &block) != 1) { + block = 0; + } + } + set_func(name, val, block); } -bool cfg_parsefile(char *fname, void (*set_func)(char*, char*)) -{ - FILE *f; - char line[200]; +bool cfg_parsefile(char *fname, void (*set_func)(char*, char*)) { + FILE *f; + char line[200]; - //printf("opening(%s)\n", fname); - f = fopen(fname, "r"); - if (!f) { - //printf("error opening(%s)\n", fname); - return false; - } - while (fgets(line, sizeof(line), f)) { - // lines starting with # are comments - if (line[0] == '#') continue; - cfg_parseline(line, set_func); - } - fclose(f); - return true; + //printf("opening(%s)\n", fname); + f = fopen(fname, "r"); + if (!f) { + //printf("error opening(%s)\n", fname); + return false; + } + while (fgets(line, sizeof(line), f)) { + // lines starting with # are comments + if (line[0] == '#') continue; + cfg_parseline(line, set_func); + } + fclose(f); + return true; } -bool cfg_parsetitlefile(char *fname, void (*set_func)(char*, char*, u8)) -{ - FILE *f; - char line[200]; +bool cfg_parsetitlefile(char *fname, void (*set_func)(char*, char*, u8)) { + FILE *f; + char line[200]; - //printf("opening(%s)\n", fname); - f = fopen(fname, "r"); - if (!f) { - //printf("error opening(%s)\n", fname); - return false; - } + //printf("opening(%s)\n", fname); + f = fopen(fname, "r"); + if (!f) { + //printf("error opening(%s)\n", fname); + return false; + } - while (fgets(line, sizeof(line), f)) { - // lines starting with # are comments - if (line[0] == '#') continue; - cfg_parsetitleline(line, set_func); - } - fclose(f); - return true; + while (fgets(line, sizeof(line), f)) { + // lines starting with # are comments + if (line[0] == '#') continue; + cfg_parsetitleline(line, set_func); + } + fclose(f); + return true; } /* @@ -1161,610 +1097,588 @@ void cfg_parsearg(int argc, char **argv) // return existing or new -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; - game = &cfg_game[num_saved_games]; - num_saved_games++; - return game; +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; + game = &cfg_game[num_saved_games]; + num_saved_games++; + return game; } // current options to game -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; - game->language = languageChoice; - game->ocarina = ocarinaChoice; - game->vipatch = viChoice; - game->ios = iosChoice; - game->parentalcontrol = parentalcontrolChoice; - game->errorfix002 = fix002; - game->iosreloadblock = reloadblock; - game->patchcountrystrings = countrystrings; - game->loadalternatedol = alternatedol; - game->alternatedolstart = alternatedoloffset; - strcpy(game->alternatedolname, alternatedname); +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; + game->language = languageChoice; + game->ocarina = ocarinaChoice; + game->vipatch = viChoice; + game->ios = iosChoice; + game->parentalcontrol = parentalcontrolChoice; + game->errorfix002 = fix002; + game->iosreloadblock = reloadblock; + game->patchcountrystrings = countrystrings; + game->loadalternatedol = alternatedol; + game->alternatedolstart = alternatedoloffset; + strcpy(game->alternatedolname, alternatedname); } -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; - game = &cfg_game_num[num_saved_game_num]; - num_saved_game_num++; - return game; +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; + game = &cfg_game_num[num_saved_game_num]; + num_saved_game_num++; + return game; } // current options to game -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; - game->count = playcount; +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; + game->count = playcount; } -bool cfg_save_global()// save global settings -{ - char GXGlobal_cfg[26]; - sprintf(GXGlobal_cfg, "%s/config", bootDevice); +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; - sprintf(GXGlobal_cfg, "%s/config/GXGlobal.cfg", bootDevice); - f = fopen(GXGlobal_cfg, "w"); - if (!f) { - printf("Error saving %s\n", GXGlobal_cfg); - sleep(1); - return false; - } - fprintf(f, "# USB Loader global settings file\n"); - fprintf(f, "# Note: This file is automatically generated\n"); - fclose(f); - /* Closing and reopening because of a write issue we are having right now */ - f = fopen(GXGlobal_cfg, "w"); - fprintf(f, "# USB Loader global settings file\n"); - fprintf(f, "# Note: This file is automatically generated\n"); - fprintf(f, "video = %d\n ", Settings.video); - fprintf(f, "vpatch = %d\n ", Settings.vpatch); - fprintf(f, "language = %d\n ", Settings.language); - fprintf(f, "ocarina = %d\n ", Settings.ocarina); - fprintf(f, "hddinfo = %d\n ", Settings.hddinfo); - fprintf(f, "sinfo = %d\n ", Settings.sinfo); - fprintf(f, "rumble = %d\n ", Settings.rumble); - fprintf(f, "volume = %d\n ", Settings.volume); - fprintf(f, "sfxvolume = %d\n ", Settings.sfxvolume); - fprintf(f, "tooltips = %d\n ", Settings.tooltips); - fprintf(f, "password = %s\n ", Settings.unlockCode); - fprintf(f, "sort = %d\n ", Settings.sort); - fprintf(f, "fave = %d\n ", Settings.fave); - fprintf(f, "cios = %d\n ", Settings.cios); - fprintf(f, "keyset = %d\n ", Settings.keyset); - fprintf(f, "xflip = %d\n ", Settings.xflip); - fprintf(f, "gridRows = %d\n ", Settings.gridRows); - fprintf(f, "qboot = %d\n ", Settings.qboot); - 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) { - fprintf(f, "wtheme_path = %s\n ", CFG.theme_path); - } else { - fprintf(f, "theme_path = %s\n ", CFG.theme_path); - } - fprintf(f, "disc_path = %s\n ", Settings.disc_path); - fprintf(f, "language_path = %s\n ", Settings.language_path); - fprintf(f, "languagefiles_path = %s\n ", Settings.languagefiles_path); - 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)) { - fprintf(f, "godmode = %d\n ", Settings.godmode); - } else { - fprintf(f, "godmode = %d\n ", 0); - } - fprintf(f, "dolpath = %s\n ", Settings.dolpath); - fprintf(f, "ogg_path = %s\n ", Settings.ogg_path); - fprintf(f, "wiilight = %d\n ", Settings.wiilight); - fprintf(f, "gameDisplay = %d\n ", Settings.gameDisplay); - fprintf(f, "update_path = %s\n ", Settings.update_path); - fprintf(f, "homebrewapps_path = %s\n ", Settings.homebrewapps_path); - fprintf(f, "Cheatcodespath = %s\n ", Settings.Cheatcodespath); - fprintf(f, "titlesOverride = %d\n ", Settings.titlesOverride); - //fprintf(f, "db_url = %s\n ", Settings.db_url); - //fprintf(f, "db_JPtoEN = %d\n ", Settings.db_JPtoEN); - //fprintf(f, "db_language = %d\n ", Settings.language); - fprintf(f, "patchcountrystrings = %d\n ", Settings.patchcountrystrings); - fprintf(f, "screensaver = %d\n ", Settings.screensaver); - fprintf(f, "error002 = %d\n ", Settings.error002); - fprintf(f, "autonetwork = %d\n ", Settings.autonetwork); - fclose(f); - return true; + sprintf(GXGlobal_cfg, "%s/config/GXGlobal.cfg", bootDevice); + f = fopen(GXGlobal_cfg, "w"); + if (!f) { + printf("Error saving %s\n", GXGlobal_cfg); + sleep(1); + return false; + } + fprintf(f, "# USB Loader global settings file\n"); + fprintf(f, "# Note: This file is automatically generated\n"); + fclose(f); + /* Closing and reopening because of a write issue we are having right now */ + f = fopen(GXGlobal_cfg, "w"); + fprintf(f, "# USB Loader global settings file\n"); + fprintf(f, "# Note: This file is automatically generated\n"); + fprintf(f, "video = %d\n ", Settings.video); + fprintf(f, "vpatch = %d\n ", Settings.vpatch); + fprintf(f, "language = %d\n ", Settings.language); + fprintf(f, "ocarina = %d\n ", Settings.ocarina); + fprintf(f, "hddinfo = %d\n ", Settings.hddinfo); + fprintf(f, "sinfo = %d\n ", Settings.sinfo); + fprintf(f, "rumble = %d\n ", Settings.rumble); + fprintf(f, "volume = %d\n ", Settings.volume); + fprintf(f, "sfxvolume = %d\n ", Settings.sfxvolume); + fprintf(f, "tooltips = %d\n ", Settings.tooltips); + fprintf(f, "password = %s\n ", Settings.unlockCode); + fprintf(f, "sort = %d\n ", Settings.sort); + fprintf(f, "fave = %d\n ", Settings.fave); + fprintf(f, "cios = %d\n ", Settings.cios); + fprintf(f, "keyset = %d\n ", Settings.keyset); + fprintf(f, "xflip = %d\n ", Settings.xflip); + fprintf(f, "gridRows = %d\n ", Settings.gridRows); + fprintf(f, "qboot = %d\n ", Settings.qboot); + 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) { + fprintf(f, "wtheme_path = %s\n ", CFG.theme_path); + } else { + fprintf(f, "theme_path = %s\n ", CFG.theme_path); + } + fprintf(f, "disc_path = %s\n ", Settings.disc_path); + fprintf(f, "language_path = %s\n ", Settings.language_path); + fprintf(f, "languagefiles_path = %s\n ", Settings.languagefiles_path); + 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)) { + fprintf(f, "godmode = %d\n ", Settings.godmode); + } else { + fprintf(f, "godmode = %d\n ", 0); + } + fprintf(f, "dolpath = %s\n ", Settings.dolpath); + fprintf(f, "ogg_path = %s\n ", Settings.ogg_path); + fprintf(f, "wiilight = %d\n ", Settings.wiilight); + fprintf(f, "gameDisplay = %d\n ", Settings.gameDisplay); + fprintf(f, "update_path = %s\n ", Settings.update_path); + fprintf(f, "homebrewapps_path = %s\n ", Settings.homebrewapps_path); + fprintf(f, "Cheatcodespath = %s\n ", Settings.Cheatcodespath); + fprintf(f, "titlesOverride = %d\n ", Settings.titlesOverride); + //fprintf(f, "db_url = %s\n ", Settings.db_url); + //fprintf(f, "db_JPtoEN = %d\n ", Settings.db_JPtoEN); + //fprintf(f, "db_language = %d\n ", Settings.language); + fprintf(f, "patchcountrystrings = %d\n ", Settings.patchcountrystrings); + fprintf(f, "screensaver = %d\n ", Settings.screensaver); + fprintf(f, "error002 = %d\n ", Settings.error002); + fprintf(f, "autonetwork = %d\n ", Settings.autonetwork); + fclose(f); + return true; } -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; - //printf("GAME: '%s=%s'\n", name, val); - u8 id[8]; - struct Game_CFG *game; - if (strncmp(name, "game:", 5) != 0) return; - trimcopy((char*)id, name+5, sizeof(id)); - game = cfg_get_game(id); - // set id and current options as default - cfg_set_game_opt(game, id); - //printf("GAME(%s) '%s'\n", id, val); sleep(1); +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; + //printf("GAME: '%s=%s'\n", name, val); + u8 id[8]; + struct Game_CFG *game; + if (strncmp(name, "game:", 5) != 0) return; + trimcopy((char*)id, name+5, sizeof(id)); + game = cfg_get_game(id); + // set id and current options as default + cfg_set_game_opt(game, id); + //printf("GAME(%s) '%s'\n", id, val); sleep(1); - // parse val - // first split options by ; - char opt[200], *p, *np; - p = val; + // parse val + // first split options by ; + char opt[200], *p, *np; + p = val; - 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))){ - //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)) { - // valid option, assign - game->video = opt_v; - } - if (map_auto("language", opt_name, opt_val, map_language, &opt_l)) { - // valid option, assign - game->language = opt_l; - } - if (strcmp("ocarina", opt_name) == 0) { - if (sscanf(opt_val, "%hd", &opt_c) == 1) { - game->ocarina = opt_c; - } - } - if (strcmp("vipatch", opt_name) == 0) { - if (sscanf(opt_val, "%hd", &opt_c) == 1) { - game->vipatch = opt_c; - } - } - if (strcmp("ios", opt_name) == 0) { - if (sscanf(opt_val, "%hd", &opt_c) == 1) { - game->ios = opt_c; - } - } - if (strcmp("pctrl", opt_name) == 0) { - if (sscanf(opt_val, "%hd", &opt_c) == 1) { - game->parentalcontrol = opt_c; - } - } - if (strcmp("errorfix002", opt_name) == 0) { - if (sscanf(opt_val, "%hd", &opt_c) == 1) { - game->errorfix002 = opt_c; - } - } - if (strcmp("iosreloadblock", opt_name) == 0) { - if (sscanf(opt_val, "%hd", &opt_c) == 1) { - game->iosreloadblock = opt_c; - } - } - if (strcmp("patchcountrystrings", opt_name) == 0) { - if (sscanf(opt_val, "%hd", &opt_c) == 1) { - game->patchcountrystrings = opt_c; - } - } - if (strcmp("loadalternatedol", opt_name) == 0) { - if (sscanf(opt_val, "%hd", &opt_c) == 1) { - game->loadalternatedol = opt_c; - } - } - if (strcmp("alternatedolstart", opt_name) == 0) { - if (sscanf(opt_val, "%hd", &opt_c) == 1) { - game->alternatedolstart = opt_c; - } - } - if (strcmp("alternatedolname", opt_name) == 0) { - char temp3[40]; - int i = 0; - while(i < 40) { + 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))) { + //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)) { + // valid option, assign + game->video = opt_v; + } + if (map_auto("language", opt_name, opt_val, map_language, &opt_l)) { + // valid option, assign + game->language = opt_l; + } + if (strcmp("ocarina", opt_name) == 0) { + if (sscanf(opt_val, "%hd", &opt_c) == 1) { + game->ocarina = opt_c; + } + } + if (strcmp("vipatch", opt_name) == 0) { + if (sscanf(opt_val, "%hd", &opt_c) == 1) { + game->vipatch = opt_c; + } + } + if (strcmp("ios", opt_name) == 0) { + if (sscanf(opt_val, "%hd", &opt_c) == 1) { + game->ios = opt_c; + } + } + if (strcmp("pctrl", opt_name) == 0) { + if (sscanf(opt_val, "%hd", &opt_c) == 1) { + game->parentalcontrol = opt_c; + } + } + if (strcmp("errorfix002", opt_name) == 0) { + if (sscanf(opt_val, "%hd", &opt_c) == 1) { + game->errorfix002 = opt_c; + } + } + if (strcmp("iosreloadblock", opt_name) == 0) { + if (sscanf(opt_val, "%hd", &opt_c) == 1) { + game->iosreloadblock = opt_c; + } + } + if (strcmp("patchcountrystrings", opt_name) == 0) { + if (sscanf(opt_val, "%hd", &opt_c) == 1) { + game->patchcountrystrings = opt_c; + } + } + if (strcmp("loadalternatedol", opt_name) == 0) { + if (sscanf(opt_val, "%hd", &opt_c) == 1) { + game->loadalternatedol = opt_c; + } + } + if (strcmp("alternatedolstart", opt_name) == 0) { + if (sscanf(opt_val, "%hd", &opt_c) == 1) { + game->alternatedolstart = opt_c; + } + } + if (strcmp("alternatedolname", opt_name) == 0) { + char temp3[40]; + int i = 0; + while (i < 40) { - if(opt_val[i] == ';') + if (opt_val[i] == ';') break; temp3[i] = opt_val[i]; i++; - } - temp3[i] = '\0'; - strncpy(game->alternatedolname, temp3, 39); - } - } - // next opt - if (np) p = np + 1; else p = NULL; - } + } + temp3[i] = '\0'; + strncpy(game->alternatedolname, temp3, 39); + } + } + // next opt + if (np) p = np + 1; + else p = NULL; + } } -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; - //printf("GAME: '%s=%s'\n", name, val); - u8 id[8]; +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; + //printf("GAME: '%s=%s'\n", name, val); + u8 id[8]; - if (strncmp(name, "game:", 5) != 0) return; - trimcopy((char*)id, name+5, sizeof(id)); + if (strncmp(name, "game:", 5) != 0) return; + trimcopy((char*)id, name+5, sizeof(id)); - // parse val - // first split options by ; - char opt[200], *p, *np; - p = val; + // parse val + // first split options by ; + char opt[200], *p, *np; + p = val; - 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))){ - //printf("GAME(%s) (%s=%s)\n", id, opt_name, opt_val); sleep(1); - short opt_c; + 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))) { + //printf("GAME(%s) (%s=%s)\n", id, opt_name, opt_val); sleep(1); + short opt_c; - if (strcmp("pctrl", opt_name) == 0) { - if (sscanf(opt_val, "%hd", &opt_c) == 1) { - cfg_control = realloc(cfg_control, (num_control+1) * sizeof(struct ID_Control)); - if (!cfg_control) { - // error - num_control = 0; - return; - } - // add - memcpy(cfg_control[num_control].id, id, 4); - cfg_control[num_control].id[4] = 0; - cfg_control[num_control].block = opt_c; - num_control++; - } - } + if (strcmp("pctrl", opt_name) == 0) { + if (sscanf(opt_val, "%hd", &opt_c) == 1) { + cfg_control = realloc(cfg_control, (num_control+1) * sizeof(struct ID_Control)); + if (!cfg_control) { + // error + num_control = 0; + return; + } + // add + memcpy(cfg_control[num_control].id, id, 4); + cfg_control[num_control].id[4] = 0; + cfg_control[num_control].block = opt_c; + num_control++; + } + } - } - // next opt - if (np) p = np + 1; else p = NULL; - } + } + // next opt + if (np) p = np + 1; + else p = NULL; + } } -void game_set_num(char *name, char *val) -{ - u8 id[8]; - struct Game_NUM *game; - if (strncmp(name, "game:", 5) != 0) return; - trimcopy((char*)id, name+5, sizeof(id)); - game = cfg_get_game_num(id); +void game_set_num(char *name, char *val) { + u8 id[8]; + struct Game_NUM *game; + if (strncmp(name, "game:", 5) != 0) return; + trimcopy((char*)id, name+5, sizeof(id)); + game = cfg_get_game_num(id); - cfg_set_game_num(game, id); + cfg_set_game_num(game, id); - // parse val - // first split options by ; - char opt[200], *p, *np; - p = val; + // parse val + // first split options by ; + char opt[200], *p, *np; + p = val; - while(p) { - np = strchr(p, ';'); - if (np) trim_n_copy(opt, p, np-p, sizeof(opt)); - else trimcopy(opt, p, sizeof(opt)); + 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))){ + char opt_name[200], opt_val[200]; + if (trimsplit(opt, opt_name, opt_val, ':', sizeof(opt_name))) { - short opt_c; - if (strcmp("favorite", opt_name) == 0) { - if (sscanf(opt_val, "%hd", &opt_c) == 1) { - game->favorite = opt_c; - } - } - if (strcmp("count", opt_name) == 0) { - if (sscanf(opt_val, "%hd", &opt_c) == 1) { - game->count = opt_c; - } - } - } + short opt_c; + if (strcmp("favorite", opt_name) == 0) { + if (sscanf(opt_val, "%hd", &opt_c) == 1) { + game->favorite = opt_c; + } + } + if (strcmp("count", opt_name) == 0) { + if (sscanf(opt_val, "%hd", &opt_c) == 1) { + game->count = opt_c; + } + } + } - if (np) p = np + 1; else p = NULL; - } + if (np) p = np + 1; + else p = NULL; + } } -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_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() -{ - char GXGameFavorites_cfg[32]; - sprintf(GXGameFavorites_cfg, "%s/config/GXGameFavorites.cfg", bootDevice); - return cfg_parsefile(GXGameFavorites_cfg, &game_set_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() -{ - FILE *f; - int i; - char GXGameSettings_cfg[50]; - sprintf(GXGameSettings_cfg, "%s/config", bootDevice); - mkdir(GXGameSettings_cfg, 0777); +bool cfg_save_games() { + FILE *f; + int i; + char GXGameSettings_cfg[50]; + sprintf(GXGameSettings_cfg, "%s/config", bootDevice); + mkdir(GXGameSettings_cfg, 0777); - sprintf(GXGameSettings_cfg, "%s/config/GXGameSettings.cfg", bootDevice); - f = fopen(GXGameSettings_cfg, "w"); - if (!f) { - printf("Error saving %s\n", "GXGameSettings.cfg"); - sleep(1); - return false; - } - fprintf(f, "# USB Loader settings file\n"); - fprintf(f, "# note: this file is automatically generated\n"); - fclose(f); - /* Closing and reopening because of a write issue we are having right now */ + sprintf(GXGameSettings_cfg, "%s/config/GXGameSettings.cfg", bootDevice); + f = fopen(GXGameSettings_cfg, "w"); + if (!f) { + printf("Error saving %s\n", "GXGameSettings.cfg"); + sleep(1); + return false; + } + fprintf(f, "# USB Loader settings file\n"); + fprintf(f, "# note: this file is automatically generated\n"); + fclose(f); + /* Closing and reopening because of a write issue we are having right now */ f = fopen(GXGameSettings_cfg, "w"); fprintf(f, "# USB Loader settings file\n"); - fprintf(f, "# note: this file is automatically generated\n"); - fprintf(f, "# Num Games: %d\n", num_saved_games); - for (i=0; i #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif #include "usbloader/disc.h" @@ -42,344 +41,340 @@ 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 -{ - short widescreen; - char theme_path[100]; -}; + struct CFG { + short widescreen; + char theme_path[100]; + }; -struct THEME -{ - int selection_x; - int selection_y; - int selection_w; - int selection_h; - int gamegrid_x; - int gamegrid_y; - int gamegrid_w; - int gamegrid_h; - int tooltipAlpha; - int gamecarousel_x; - int gamecarousel_y; - int gamecarousel_w; - int gamecarousel_h; - short cover_x; - short cover_y; - short showID; + struct THEME { + int selection_x; + int selection_y; + int selection_w; + int selection_h; + int gamegrid_x; + int gamegrid_y; + int gamegrid_w; + int gamegrid_h; + int tooltipAlpha; + int gamecarousel_x; + int gamecarousel_y; + int gamecarousel_w; + int gamecarousel_h; + short cover_x; + short cover_y; + short showID; // short maxcharacters; - short batteryUnused; - short homebrew_x; - short homebrew_y; - short id_x; - short id_y; - short region_x; - short region_y; - short power_x; - short power_y; - short home_x; - short home_y; - short battery1_x; - short battery2_x; - short battery3_x; - short battery4_x; - short battery1_y; - short battery2_y; - short battery3_y; - short battery4_y; - short favorite_x; - short favorite_y; - short abc_x; - short abc_y; - short list_x; - short list_y; - short grid_x; - short grid_y; - short carousel_x; - short carousel_y; - short count_x; - short count_y; - short sortBarOffset; + short batteryUnused; + short homebrew_x; + short homebrew_y; + short id_x; + short id_y; + short region_x; + short region_y; + short power_x; + short power_y; + short home_x; + short home_y; + short battery1_x; + short battery2_x; + short battery3_x; + short battery4_x; + short battery1_y; + short battery2_y; + short battery3_y; + short battery4_y; + short favorite_x; + short favorite_y; + short abc_x; + short abc_y; + short list_x; + short list_y; + short grid_x; + short grid_y; + short carousel_x; + short carousel_y; + short count_x; + short count_y; + short sortBarOffset; // short showPower; // short showHome; - short setting_x; - short setting_y; - short install_x; - short install_y; - short showHDD; - short hddInfoAlign; - short hddInfo_x; - short hddInfo_y; - short showGameCnt; - short gameCntAlign; - short gameCnt_x; - short gameCnt_y; - short showRegion; - short showBattery; - short showToolTip; - //color - short info_r; - short info_g; - short info_b; - short prompttxt_r; - short prompttxt_g; - short prompttxt_b; - short settingsTxt_r; - short settingsTxt_g; - short settingsTxt_b; - short clock_r; - short clock_g; - short clock_b; - short clock_x; - short clock_y; - short clockAlign; - short sdcard_x; - short sdcard_y; - short gameText_r; - short gameText_g; - short gameText_b; - short pagesize; -}; + short setting_x; + short setting_y; + short install_x; + short install_y; + short showHDD; + short hddInfoAlign; + short hddInfo_x; + short hddInfo_y; + short showGameCnt; + short gameCntAlign; + short gameCnt_x; + short gameCnt_y; + short showRegion; + short showBattery; + short showToolTip; + //color + short info_r; + short info_g; + short info_b; + short prompttxt_r; + short prompttxt_g; + short prompttxt_b; + short settingsTxt_r; + short settingsTxt_g; + short settingsTxt_b; + short clock_r; + short clock_g; + short clock_b; + short clock_x; + short clock_y; + short clockAlign; + short sdcard_x; + short sdcard_y; + short gameText_r; + 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 -{ - u8 id[8]; - u8 video; - u8 language; - u8 ocarina; - u8 vipatch; - u8 ios; - u8 parentalcontrol; - u8 errorfix002; - u8 iosreloadblock; - u8 loadalternatedol; - u32 alternatedolstart; - u8 patchcountrystrings; - char alternatedolname[40]; -}; -struct Game_NUM -{ - u8 id[8]; - u8 favorite; - u16 count; -}; + struct Game_CFG { + u8 id[8]; + u8 video; + u8 language; + u8 ocarina; + u8 vipatch; + u8 ios; + u8 parentalcontrol; + u8 errorfix002; + u8 iosreloadblock; + u8 loadalternatedol; + u32 alternatedolstart; + u8 patchcountrystrings; + char alternatedolname[40]; + }; + 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 { - ConsoleLangDefault=0, - jap, - eng, - ger, - fren, - esp, - it, - dut, - schin, - tchin, - kor, - settings_language_max // always the last entry -}; + enum { + ConsoleLangDefault=0, + jap, + eng, + ger, + fren, + esp, + it, + dut, + schin, + tchin, + kor, + settings_language_max // always the last entry + }; -enum { - systemdefault=0, - discdefault, - patch, - pal50, - pal60, - ntsc, - settings_video_max // always the last entry -}; + enum { + systemdefault=0, + discdefault, + patch, + pal50, + pal60, + ntsc, + settings_video_max // always the last entry + }; -enum { - off=0, - on, - settings_off_on_max // always the last entry -}; -enum { - anti=2, -}; + enum { + off=0, + on, + settings_off_on_max // always the last entry + }; + enum { + anti=2, + }; -enum { - GameID, - GameRegion, - Both, - Neither, - settings_sinfo_max // always the last entry -}; + enum { + GameID, + GameRegion, + Both, + Neither, + settings_sinfo_max // always the last entry + }; -enum { - i249=0, - i222, - i223 -}; + enum { + i249=0, + i222, + i223 + }; -enum { - ios249=0, - ios222, - settings_cios_max // always the last entry -}; + enum { + ios249=0, + ios222, + settings_cios_max // always the last entry + }; -enum { - hr12=0, - hr24, - Off, - settings_clock_max // always the last entry -}; -enum { - all=0, - pcount, -}; + enum { + hr12=0, + hr24, + Off, + settings_clock_max // always the last entry + }; + enum { + all=0, + pcount, + }; -enum { - RumbleOff=0, - RumbleOn, - settings_rumble_max // always the last entry -}; + enum { + RumbleOff=0, + RumbleOn, + settings_rumble_max // always the last entry + }; -enum { - TooltipsOff=0, - TooltipsOn, - settings_tooltips_max // always the last entry -}; + enum { + TooltipsOff=0, + TooltipsOn, + settings_tooltips_max // always the last entry + }; -enum { - min3=1, - min5, - min10, - min20, - min30, - min60, - settings_screensaver_max // always the last entry -}; + enum { + min3=1, + min5, + min10, + min20, + min30, + min60, + settings_screensaver_max // always the last entry + }; -enum { - no=0, - yes, - sysmenu, - wtf, - disk3d, - settings_xflip_max // always the last entry -}; -enum { - us=0, - qwerty, - dvorak, - euro, - azerty, - settings_keyset_max // always the last entry -}; -enum { - list, - grid, - carousel, - settings_display_max -}; -enum { - scrollDefault, - scrollMarquee, - settings_scrolleffect_max // always the last entry -}; -struct SSettings { - u8 video; - u8 language; - u8 ocarina; - u8 vpatch; - int ios; - u8 sinfo; - u8 hddinfo; - u8 rumble; - u8 xflip; - int volume; - int sfxvolume; - u8 tooltips; - char unlockCode[20]; - u8 parentalcontrol; - u8 cios; - u8 qboot; - u8 wsprompt; - u8 keyset; - u8 sort; - u8 fave; - u8 wiilight; - u8 gameDisplay; - u8 patchcountrystrings; - u8 screensaver; - short godmode; - char covers_path[100]; - char theme_path[100]; - char wtheme_path[100]; - char disc_path[100]; - char titlestxt_path[100]; - char language_path[100]; - char languagefiles_path[100]; - char oggload_path[100]; - char ogg_path[150]; - char dolpath[150]; - char update_path[150]; - char homebrewapps_path[150]; - char selected_homebrew[200]; - char Cheatcodespath[100]; - char TxtCheatcodespath[100]; - short error002; - u8 titlesOverride; // db_titles - char db_url[200]; - char db_language[100]; - u8 db_JPtoEN; - u8 gridRows; - u8 autonetwork; -}; + enum { + no=0, + yes, + sysmenu, + wtf, + disk3d, + settings_xflip_max // always the last entry + }; + enum { + us=0, + qwerty, + dvorak, + euro, + azerty, + settings_keyset_max // always the last entry + }; + enum { + list, + grid, + carousel, + settings_display_max + }; + enum { + scrollDefault, + scrollMarquee, + settings_scrolleffect_max // always the last entry + }; + struct SSettings { + u8 video; + u8 language; + u8 ocarina; + u8 vpatch; + int ios; + u8 sinfo; + u8 hddinfo; + u8 rumble; + u8 xflip; + int volume; + int sfxvolume; + u8 tooltips; + char unlockCode[20]; + u8 parentalcontrol; + u8 cios; + u8 qboot; + u8 wsprompt; + u8 keyset; + u8 sort; + u8 fave; + u8 wiilight; + u8 gameDisplay; + u8 patchcountrystrings; + u8 screensaver; + short godmode; + char covers_path[100]; + char theme_path[100]; + char wtheme_path[100]; + char disc_path[100]; + char titlestxt_path[100]; + char language_path[100]; + char languagefiles_path[100]; + char oggload_path[100]; + char ogg_path[150]; + char dolpath[150]; + char update_path[150]; + char homebrewapps_path[150]; + char selected_homebrew[200]; + char Cheatcodespath[100]; + char TxtCheatcodespath[100]; + short error002; + u8 titlesOverride; // db_titles + char db_url[200]; + char db_language[100]; + 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 } diff --git a/source/svnrev.c b/source/svnrev.c index f514d4a0..cb47cc53 100644 --- a/source/svnrev.c +++ b/source/svnrev.c @@ -1,4 +1,4 @@ -#define SVN_REV "673M" +#define SVN_REV "674M" const char *GetRev() { diff --git a/source/svnrev.h b/source/svnrev.h index fa0b6a17..3d6cebe7 100644 --- a/source/svnrev.h +++ b/source/svnrev.h @@ -2,14 +2,13 @@ #define SVNREV_H #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif -const char *GetRev(); + const char *GetRev(); #ifdef __cplusplus } #endif - -#endif /* SVNREV_H */ + +#endif /* SVNREV_H */ diff --git a/source/sys.cpp b/source/sys.cpp index 6bf8197f..20a51062 100644 --- a/source/sys.cpp +++ b/source/sys.cpp @@ -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,52 +26,46 @@ void wiilight(int enable) { // Toggle wiilight (thanks Bool for wiil u8 shutdown = 0; u8 reset = 0; -void __Sys_ResetCallback(void) -{ - /* Reboot console */ - reset = 1; +void __Sys_ResetCallback(void) { + /* Reboot console */ + reset = 1; } -void __Sys_PowerCallback(void) -{ - /* Poweroff console */ - shutdown = 1; +void __Sys_PowerCallback(void) { + /* Poweroff console */ + shutdown = 1; } -void Sys_Init(void) -{ - /* Initialize video subsytem */ - //VIDEO_Init(); +void Sys_Init(void) { + /* Initialize video subsytem */ + //VIDEO_Init(); - /* Set RESET/POWER button callback */ - SYS_SetResetCallback(__Sys_ResetCallback); - SYS_SetPowerCallback(__Sys_PowerCallback); + /* Set RESET/POWER button callback */ + SYS_SetResetCallback(__Sys_ResetCallback); + SYS_SetPowerCallback(__Sys_PowerCallback); } -static void _ExitApp() -{ - ExitGUIThreads(); - StopGX(); - ShutdownAudio(); +static void _ExitApp() { + ExitGUIThreads(); + StopGX(); + ShutdownAudio(); SDCard_deInit(); - USBDevice_deInit(); + USBDevice_deInit(); mload_set_ES_ioctlv_vector(NULL); - mload_close(); + mload_close(); } -void Sys_Reboot(void) -{ - /* Restart console */ - _ExitApp(); - STM_RebootSystem(); +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 + //shutdown SD and USB before IOS Reload in DiscWait SDCard_deInit(); USBDevice_deInit(); @@ -83,29 +77,29 @@ 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) { + ret = Disc_Init(); + if (ret>=0) { + ret = WBFS_Open(); + } + } else Sys_BackToLoader(); } - if(ret>=0) { - ret = Disc_Init(); - if(ret>=0) { - ret = WBFS_Open(); - } - } else Sys_BackToLoader(); - } PAD_Init(); Wpad_Init(); WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); - //reinitialize SD and USB + //reinitialize SD and USB SDCard_Init(); USBDevice_Init(); @@ -116,56 +110,49 @@ int Sys_IosReload(int IOS) #define ShutdownToIdle 1 #define ShutdownToStandby 2 -static void _Sys_Shutdown(int SHUTDOWN_MODE) -{ - _ExitApp(); - WPAD_Flush(0); - WPAD_Disconnect(0); - WPAD_Shutdown(); +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) { - s32 ret; + /* Poweroff console */ + 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) - STM_SetLedMode(ret); + /* Set LED mode */ + ret = CONF_GetIdleLedMode(); + if (ret >= 0 && ret <= 2) + STM_SetLedMode(ret); - /* Shutdown to idle */ - STM_ShutdownToIdle(); - } else { - /* Shutdown to standby */ - STM_ShutdownToStandby(); - } + /* Shutdown to idle */ + STM_ShutdownToIdle(); + } else { + /* Shutdown to standby */ + STM_ShutdownToStandby(); + } } -void Sys_Shutdown(void) -{ - _Sys_Shutdown(ShutdownToDefault); +void Sys_Shutdown(void) { + _Sys_Shutdown(ShutdownToDefault); } -void Sys_ShutdownToIdel(void) -{ - _Sys_Shutdown(ShutdownToIdle); +void Sys_ShutdownToIdel(void) { + _Sys_Shutdown(ShutdownToIdle); } -void Sys_ShutdownToStandby(void) -{ - _Sys_Shutdown(ShutdownToStandby); +void Sys_ShutdownToStandby(void) { + _Sys_Shutdown(ShutdownToStandby); } -void Sys_LoadMenu(void) -{ - _ExitApp(); - /* Return to the Wii system menu */ - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); +void Sys_LoadMenu(void) { + _ExitApp(); + /* Return to the Wii system menu */ + SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } -void Sys_BackToLoader(void) -{ - if (*((u32*) 0x80001800)) - { - _ExitApp(); - exit(0); - } - // Channel Version - Sys_LoadMenu(); +void Sys_BackToLoader(void) { + if (*((u32*) 0x80001800)) { + _ExitApp(); + exit(0); + } + // Channel Version + Sys_LoadMenu(); } diff --git a/source/unzip/crypt.h b/source/unzip/crypt.h index f14a628b..4c6f4429 100644 --- a/source/unzip/crypt.h +++ b/source/unzip/crypt.h @@ -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,14 +44,13 @@ 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; { - register int keyshift = (int)((*(pkeys+1)) >> 24); - (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); + register int keyshift = (int)((*(pkeys+1)) >> 24); + (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); } return c; } @@ -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 */ @@ -102,26 +99,23 @@ static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) static unsigned calls = 0; /* ensure different random header each time */ if (bufSize> 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); diff --git a/source/unzip/ioapi.c b/source/unzip/ioapi.c index 7f20c182..c9e6b051 100644 --- a/source/unzip/ioapi.c +++ b/source/unzip/ioapi.c @@ -30,56 +30,56 @@ #endif voidpf ZCALLBACK fopen_file_func OF(( - voidpf opaque, - const char* filename, - int mode)); + voidpf opaque, + const char* filename, + int mode)); uLong ZCALLBACK fread_file_func OF(( - voidpf opaque, - voidpf stream, - void* buf, - uLong size)); + voidpf opaque, + voidpf stream, + void* buf, + uLong size)); uLong ZCALLBACK fwrite_file_func OF(( - voidpf opaque, - voidpf stream, - const void* buf, - uLong size)); + voidpf opaque, + voidpf stream, + const void* buf, + uLong size)); long ZCALLBACK ftell_file_func OF(( - voidpf opaque, - voidpf stream)); + voidpf opaque, + voidpf stream)); long ZCALLBACK fseek_file_func OF(( - voidpf opaque, - voidpf stream, - uLong offset, - int origin)); + voidpf opaque, + voidpf stream, + uLong offset, + int origin)); int ZCALLBACK fclose_file_func OF(( - voidpf opaque, - voidpf stream)); + voidpf opaque, + voidpf stream)); int ZCALLBACK ferror_file_func OF(( - voidpf opaque, - voidpf stream)); + voidpf opaque, + voidpf stream)); 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; if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) mode_fopen = "rb"; else - if (mode & ZLIB_FILEFUNC_MODE_EXISTING) - mode_fopen = "r+b"; - else - if (mode & ZLIB_FILEFUNC_MODE_CREATE) - mode_fopen = "wb"; + if (mode & ZLIB_FILEFUNC_MODE_EXISTING) + mode_fopen = "r+b"; + else + if (mode & ZLIB_FILEFUNC_MODE_CREATE) + mode_fopen = "wb"; if ((filename!=NULL) && (mode_fopen != NULL)) file = fopen(filename, mode_fopen); @@ -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; diff --git a/source/unzip/ioapi.h b/source/unzip/ioapi.h index e73a3b2b..c09ca70e 100644 --- a/source/unzip/ioapi.h +++ b/source/unzip/ioapi.h @@ -35,29 +35,28 @@ 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 -{ - open_file_func zopen_file; - read_file_func zread_file; - write_file_func zwrite_file; - tell_file_func ztell_file; - seek_file_func zseek_file; - close_file_func zclose_file; - testerror_file_func zerror_file; - voidpf opaque; -} zlib_filefunc_def; + typedef struct zlib_filefunc_def_s { + open_file_func zopen_file; + read_file_func zread_file; + write_file_func zwrite_file; + tell_file_func ztell_file; + seek_file_func zseek_file; + close_file_func zclose_file; + testerror_file_func zerror_file; + voidpf opaque; + } 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)) diff --git a/source/unzip/miniunz.c b/source/unzip/miniunz.c index 0874e4de..bab52f6e 100644 --- a/source/unzip/miniunz.c +++ b/source/unzip/miniunz.c @@ -21,59 +21,53 @@ #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) -{ - char *buffer ; - char *p; - int len = (int)strlen(newdir); +int makedir (char *newdir) { + char *buffer ; + char *p; + int len = (int)strlen(newdir); - if (len <= 0) - return 0; + if (len <= 0) + return 0; - buffer = (char*)malloc(len+1); - strcpy(buffer,newdir); + buffer = (char*)malloc(len+1); + strcpy(buffer,newdir); - if (buffer[len-1] == '/') { - buffer[len-1] = '\0'; - } - if (mymkdir(buffer) == 0) - { - free(buffer); - return 1; + if (buffer[len-1] == '/') { + buffer[len-1] = '\0'; + } + if (mymkdir(buffer) == 0) { + free(buffer); + return 1; } - p = buffer+1; - while (1) - { - char hold; + p = buffer+1; + while (1) { + char hold; - while(*p && *p != '\\' && *p != '/') - p++; - hold = *p; - *p = 0; - if ((mymkdir(buffer) == -1) && (errno == ENOENT)) - { - printf("couldn't create directory %s\n",buffer); - free(buffer); - return 0; + while (*p && *p != '\\' && *p != '/') + p++; + hold = *p; + *p = 0; + if ((mymkdir(buffer) == -1) && (errno == ENOENT)) { + printf("couldn't create directory %s\n",buffer); + free(buffer); + return 0; } - if (hold == 0) - break; - *p++ = hold; + if (hold == 0) + break; + *p++ = hold; } - free(buffer); - return 1; + free(buffer); + 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) - { - exit(EXIT_FAILURE); + 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); + 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 0) { - if (fread(filename, 1, fnsize, fpZip) == fnsize) { - if (fwrite(filename, 1, fnsize, fpOut) == fnsize) { - offset += fnsize; - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_STREAM_ERROR; - break; - } + /* File entry */ + if (READ_32(header) == 0x04034b50) { + unsigned int version = READ_16(header + 4); + unsigned int gpflag = READ_16(header + 6); + unsigned int method = READ_16(header + 8); + unsigned int filetime = READ_16(header + 10); + unsigned int filedate = READ_16(header + 12); + unsigned int crc = READ_32(header + 14); /* crc */ + unsigned int cpsize = READ_32(header + 18); /* compressed size */ + unsigned int uncpsize = READ_32(header + 22); /* uncompressed sz */ + unsigned int fnsize = READ_16(header + 26); /* file name length */ + unsigned int extsize = READ_16(header + 28); /* extra field length */ + filename[0] = extra[0] = '\0'; - /* Extra field */ - if (extsize > 0) { - if (fread(extra, 1, extsize, fpZip) == extsize) { - if (fwrite(extra, 1, extsize, fpOut) == extsize) { - offset += extsize; - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_ERRNO; - break; - } - } - - /* Data */ - { - int dataSize = cpsize; - if (dataSize == 0) { - dataSize = uncpsize; - } - if (dataSize > 0) { - char* data = malloc(dataSize); - if (data != NULL) { - if ((int)fread(data, 1, dataSize, fpZip) == dataSize) { - if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) { - offset += dataSize; - totalBytes += dataSize; + /* Header */ + if (fwrite(header, 1, 30, fpOut) == 30) { + offset += 30; } else { - err = Z_ERRNO; + err = Z_ERRNO; + break; } - } else { - err = Z_ERRNO; - } - free(data); - if (err != Z_OK) { - break; - } + + /* Filename */ + if (fnsize > 0) { + if (fread(filename, 1, fnsize, fpZip) == fnsize) { + if (fwrite(filename, 1, fnsize, fpOut) == fnsize) { + offset += fnsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_STREAM_ERROR; + break; + } + + /* Extra field */ + if (extsize > 0) { + if (fread(extra, 1, extsize, fpZip) == extsize) { + if (fwrite(extra, 1, extsize, fpOut) == extsize) { + offset += extsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_ERRNO; + break; + } + } + + /* Data */ + { + int dataSize = cpsize; + if (dataSize == 0) { + dataSize = uncpsize; + } + if (dataSize > 0) { + char* data = malloc(dataSize); + if (data != NULL) { + if ((int)fread(data, 1, dataSize, fpZip) == dataSize) { + if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) { + offset += dataSize; + totalBytes += dataSize; + } else { + err = Z_ERRNO; + } + } else { + err = Z_ERRNO; + } + free(data); + if (err != Z_OK) { + break; + } + } else { + err = Z_MEM_ERROR; + break; + } + } + } + + /* Central directory entry */ + { + char header[46]; + char* comment = ""; + int comsize = (int) strlen(comment); + WRITE_32(header, 0x02014b50); + WRITE_16(header + 4, version); + WRITE_16(header + 6, version); + WRITE_16(header + 8, gpflag); + WRITE_16(header + 10, method); + WRITE_16(header + 12, filetime); + WRITE_16(header + 14, filedate); + WRITE_32(header + 16, crc); + WRITE_32(header + 20, cpsize); + WRITE_32(header + 24, uncpsize); + WRITE_16(header + 28, fnsize); + WRITE_16(header + 30, extsize); + WRITE_16(header + 32, comsize); + WRITE_16(header + 34, 0); /* disk # */ + WRITE_16(header + 36, 0); /* int attrb */ + WRITE_32(header + 38, 0); /* ext attrb */ + WRITE_32(header + 42, currentOffset); + /* Header */ + if (fwrite(header, 1, 46, fpOutCD) == 46) { + offsetCD += 46; + + /* Filename */ + if (fnsize > 0) { + if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) { + offsetCD += fnsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_STREAM_ERROR; + break; + } + + /* Extra field */ + if (extsize > 0) { + if (fwrite(extra, 1, extsize, fpOutCD) == extsize) { + offsetCD += extsize; + } else { + err = Z_ERRNO; + break; + } + } + + /* Comment field */ + if (comsize > 0) { + if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) { + offsetCD += comsize; + } else { + err = Z_ERRNO; + break; + } + } + + + } else { + err = Z_ERRNO; + break; + } + } + + /* Success */ + entries++; + } else { - err = Z_MEM_ERROR; - break; + break; } - } } - - /* Central directory entry */ + + /* Final central directory */ { - char header[46]; - char* comment = ""; - int comsize = (int) strlen(comment); - WRITE_32(header, 0x02014b50); - WRITE_16(header + 4, version); - WRITE_16(header + 6, version); - WRITE_16(header + 8, gpflag); - WRITE_16(header + 10, method); - WRITE_16(header + 12, filetime); - WRITE_16(header + 14, filedate); - WRITE_32(header + 16, crc); - WRITE_32(header + 20, cpsize); - WRITE_32(header + 24, uncpsize); - WRITE_16(header + 28, fnsize); - WRITE_16(header + 30, extsize); - WRITE_16(header + 32, comsize); - WRITE_16(header + 34, 0); /* disk # */ - WRITE_16(header + 36, 0); /* int attrb */ - WRITE_32(header + 38, 0); /* ext attrb */ - WRITE_32(header + 42, currentOffset); - /* Header */ - if (fwrite(header, 1, 46, fpOutCD) == 46) { - offsetCD += 46; - - /* Filename */ - if (fnsize > 0) { - if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) { - offsetCD += fnsize; - } else { - err = Z_ERRNO; - break; - } + int entriesZip = entries; + char header[22]; + char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools"; + int comsize = (int) strlen(comment); + if (entriesZip > 0xffff) { + entriesZip = 0xffff; + } + WRITE_32(header, 0x06054b50); + WRITE_16(header + 4, 0); /* disk # */ + WRITE_16(header + 6, 0); /* disk # */ + WRITE_16(header + 8, entriesZip); /* hack */ + WRITE_16(header + 10, entriesZip); /* hack */ + WRITE_32(header + 12, offsetCD); /* size of CD */ + WRITE_32(header + 16, offset); /* offset to CD */ + WRITE_16(header + 20, comsize); /* comment */ + + /* Header */ + if (fwrite(header, 1, 22, fpOutCD) == 22) { + + /* Comment field */ + if (comsize > 0) { + if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) { + err = Z_ERRNO; + } + } + } else { - err = Z_STREAM_ERROR; - break; - } - - /* Extra field */ - if (extsize > 0) { - if (fwrite(extra, 1, extsize, fpOutCD) == extsize) { - offsetCD += extsize; - } else { err = Z_ERRNO; - break; - } } - - /* Comment field */ - if (comsize > 0) { - if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) { - offsetCD += comsize; - } else { - err = Z_ERRNO; - break; - } - } - - - } else { - err = Z_ERRNO; - break; - } } - /* Success */ - entries++; - - } else { - break; - } - } - - /* Final central directory */ - { - int entriesZip = entries; - char header[22]; - char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools"; - int comsize = (int) strlen(comment); - if (entriesZip > 0xffff) { - entriesZip = 0xffff; - } - WRITE_32(header, 0x06054b50); - WRITE_16(header + 4, 0); /* disk # */ - WRITE_16(header + 6, 0); /* disk # */ - WRITE_16(header + 8, entriesZip); /* hack */ - WRITE_16(header + 10, entriesZip); /* hack */ - WRITE_32(header + 12, offsetCD); /* size of CD */ - WRITE_32(header + 16, offset); /* offset to CD */ - WRITE_16(header + 20, comsize); /* comment */ - - /* Header */ - if (fwrite(header, 1, 22, fpOutCD) == 22) { - - /* Comment field */ - if (comsize > 0) { - if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) { - err = Z_ERRNO; - } - } - - } else { - err = Z_ERRNO; - } - } - - /* Final merge (file + central directory) */ - fclose(fpOutCD); - if (err == Z_OK) { - fpOutCD = fopen(fileOutTmp, "rb"); - if (fpOutCD != NULL) { - int nRead; - char buffer[8192]; - while ( (nRead = (int)fread(buffer, 1, sizeof(buffer), fpOutCD)) > 0) { - if ((int)fwrite(buffer, 1, nRead, fpOut) != nRead) { - err = Z_ERRNO; - break; - } - } + /* Final merge (file + central directory) */ fclose(fpOutCD); - } + if (err == Z_OK) { + fpOutCD = fopen(fileOutTmp, "rb"); + if (fpOutCD != NULL) { + int nRead; + char buffer[8192]; + while ( (nRead = (int)fread(buffer, 1, sizeof(buffer), fpOutCD)) > 0) { + if ((int)fwrite(buffer, 1, nRead, fpOut) != nRead) { + err = Z_ERRNO; + break; + } + } + fclose(fpOutCD); + } + } + + /* Close */ + fclose(fpZip); + fclose(fpOut); + + /* Wipe temporary file */ + (void)remove(fileOutTmp); + + /* Number of recovered entries */ + if (err == Z_OK) { + if (nRecovered != NULL) { + *nRecovered = entries; + } + if (bytesRecovered != NULL) { + *bytesRecovered = totalBytes; + } + } + } else { + err = Z_STREAM_ERROR; } - - /* Close */ - fclose(fpZip); - fclose(fpOut); - - /* Wipe temporary file */ - (void)remove(fileOutTmp); - - /* Number of recovered entries */ - if (err == Z_OK) { - if (nRecovered != NULL) { - *nRecovered = entries; - } - if (bytesRecovered != NULL) { - *bytesRecovered = totalBytes; - } - } - } else { - err = Z_STREAM_ERROR; - } - return err; + return err; } diff --git a/source/unzip/mztools.h b/source/unzip/mztools.h index 82d1597a..461ee558 100644 --- a/source/unzip/mztools.h +++ b/source/unzip/mztools.h @@ -17,15 +17,15 @@ extern "C" { #include "unzip.h" -/* 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, - const char* fileOut, - const char* fileOutTmp, - uLong* nRecovered, - uLong* bytesRecovered); + /* 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, + const char* fileOut, + const char* fileOutTmp, + uLong* nRecovered, + uLong* bytesRecovered); #endif diff --git a/source/unzip/unzip.c b/source/unzip/unzip.c index c24ff76f..8edf98a9 100644 --- a/source/unzip/unzip.c +++ b/source/unzip/unzip.c @@ -47,7 +47,7 @@ woven in by Terry Thorsen 1/2003. # include #endif #ifdef NO_ERRNO_H - extern int errno; +extern int errno; #else # include #endif @@ -88,19 +88,17 @@ woven in by Terry Thorsen 1/2003. const char unz_copyright[] = - " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; + " 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 */ @@ -164,24 +161,21 @@ typedef struct local int unzlocal_getByte OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - int *pi)); + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + 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 @@ -194,14 +188,14 @@ local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi) Reads a long in LSB order from the given gz_stream. Sets */ local int unzlocal_getShort OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX)); + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + 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; @@ -222,14 +216,14 @@ local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX) } local int unzlocal_getLong OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX)); + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + 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; @@ -325,12 +318,12 @@ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivit the global comment) */ local uLong unzlocal_SearchCentralDir OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream)); + const zlib_filefunc_def* pzlib_filefunc_def, + 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 (uBackReaduMaxBack) @@ -363,7 +355,7 @@ local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream) uReadPos = uSizeFile-uBackRead ; uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); + (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) break; @@ -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; @@ -421,9 +412,9 @@ extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def) us.z_filefunc = *pzlib_filefunc_def; us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque, - path, - ZLIB_FILEFUNC_MODE_READ | - ZLIB_FILEFUNC_MODE_EXISTING); + path, + ZLIB_FILEFUNC_MODE_READ | + ZLIB_FILEFUNC_MODE_EXISTING); if (us.filestream==NULL) return NULL; @@ -432,7 +423,7 @@ extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def) err=UNZ_ERRNO; if (ZSEEK(us.z_filefunc, us.filestream, - central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) + central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) err=UNZ_ERRNO; /* the signature, already checked */ @@ -456,8 +447,8 @@ extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def) err=UNZ_ERRNO; if ((number_entry_CD!=us.gi.number_entry) || - (number_disk_with_CD!=0) || - (number_disk!=0)) + (number_disk_with_CD!=0) || + (number_disk!=0)) err=UNZ_BADZIPFILE; /* size of the central directory */ @@ -474,17 +465,16 @@ extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def) err=UNZ_ERRNO; if ((central_pos>16); @@ -564,31 +554,31 @@ local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) Get Info about the current file in the zipfile, with internal only info */ local int unzlocal_GetCurrentFileInfoInternal OF((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_file_info *pfile_info, + unz_file_info_internal + *pfile_info_internal, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); local int unzlocal_GetCurrentFileInfoInternal (file, - pfile_info, - pfile_info_internal, - 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; + pfile_info, + pfile_info_internal, + 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; { unz_s* s; unz_file_info file_info; @@ -607,13 +597,12 @@ 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) err=UNZ_BADZIPFILE; - } + } if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) err=UNZ_ERRNO; @@ -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_filename0) && (fileNameBufferSize>0)) @@ -681,56 +667,48 @@ local int unzlocal_GetCurrentFileInfoInternal (file, } - if ((err==UNZ_OK) && (extraField!=NULL)) - { + if ((err==UNZ_OK) && (extraField!=NULL)) { uLong uSizeRead ; if (file_info.size_file_extraz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; - } - + } + if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) 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_commentz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; - } - + } + if ((file_info.size_file_comment>0) && (commentBufferSize>0)) 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)) @@ -750,23 +728,23 @@ local int unzlocal_GetCurrentFileInfoInternal (file, return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetCurrentFileInfo (file, - pfile_info, - szFileName, fileNameBufferSize, - extraField, extraFieldBufferSize, - szComment, commentBufferSize) + pfile_info, + szFileName, fileNameBufferSize, + 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, - extraField,extraFieldBufferSize, - szComment,commentBufferSize); + szFileName,fileNameBufferSize, + extraField,extraFieldBufferSize, + szComment,commentBufferSize); } /* @@ -784,8 +762,8 @@ extern int ZEXPORT unzGoToFirstFile (file) s->pos_in_central_dir=s->offset_central_dir; s->num_file=0; err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); return err; } @@ -807,15 +785,15 @@ extern int ZEXPORT unzGoToNextFile (file) if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */ - if (s->num_file+1==s->gi.number_entry) - return UNZ_END_OF_LIST_OF_FILE; + if (s->num_file+1==s->gi.number_entry) + return UNZ_END_OF_LIST_OF_FILE; s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + - s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; s->num_file++; err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); return err; } @@ -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,16 +842,14 @@ 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) + szFileName,iCaseSensitivity)==0) return UNZ_OK; err = unzGoToNextFile(file); } @@ -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; @@ -943,8 +919,8 @@ extern int ZEXPORT unzGoToFilePos(file, file_pos) /* set the current file */ err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); /* return results */ s->current_file_ok = (err == UNZ_OK); return err; @@ -963,12 +939,12 @@ extern int ZEXPORT unzGoToFilePos(file, file_pos) (filename and size of extra field data) */ 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; + poffset_local_extrafield, + psize_local_extrafield) +unz_s* s; +uInt* piSizeVar; +uLong *poffset_local_extrafield; +uInt *psize_local_extrafield; { uLong uMagic,uData,uFlags; uLong size_filename; @@ -980,24 +956,23 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, *psize_local_extrafield = 0; if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + - s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) + s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) 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) err=UNZ_BADZIPFILE; - } + } 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; -*/ + /* + 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; @@ -1007,7 +982,7 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, err=UNZ_BADZIPFILE; if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && - (s->cur_file_info.compression_method!=Z_DEFLATED)) + (s->cur_file_info.compression_method!=Z_DEFLATED)) err=UNZ_BADZIPFILE; if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ @@ -1016,19 +991,19 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && - ((uFlags & 8)==0)) + ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && - ((uFlags & 8)==0)) + ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && - ((uFlags & 8)==0)) + ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; @@ -1042,7 +1017,7 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) err=UNZ_ERRNO; *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + - SIZEZIPLOCALHEADER + size_filename; + SIZEZIPLOCALHEADER + size_filename; *psize_local_extrafield = (uInt)size_extra_field; *piSizeVar += (uInt)size_extra_field; @@ -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; @@ -1084,11 +1059,11 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) unzCloseCurrentFile(file); if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, - &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) + &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) return UNZ_BADZIPFILE; pfile_in_zip_read_info = (file_in_zip_read_info_s*) - ALLOC(sizeof(file_in_zip_read_info_s)); + ALLOC(sizeof(file_in_zip_read_info_s)); if (pfile_in_zip_read_info==NULL) return UNZ_INTERNALERROR; @@ -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,25 +1083,29 @@ 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; } } if ((s->cur_file_info.compression_method!=0) && - (s->cur_file_info.compression_method!=Z_DEFLATED)) + (s->cur_file_info.compression_method!=Z_DEFLATED)) err=UNZ_BADZIPFILE; pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; pfile_in_zip_read_info->crc32=0; pfile_in_zip_read_info->compression_method = - s->cur_file_info.compression_method; + s->cur_file_info.compression_method; pfile_in_zip_read_info->filestream=s->filestream; pfile_in_zip_read_info->z_filefunc=s->z_filefunc; pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; @@ -1135,22 +1113,20 @@ 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)) - { - 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; - pfile_in_zip_read_info->stream.next_in = (voidpf)0; - pfile_in_zip_read_info->stream.avail_in = 0; + (!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; + pfile_in_zip_read_info->stream.next_in = (voidpf)0; + pfile_in_zip_read_info->stream.avail_in = 0; - err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); - if (err == Z_OK) - pfile_in_zip_read_info->stream_initialised=1; - else - { - TRYFREE(pfile_in_zip_read_info); - return err; - } + err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); + if (err == Z_OK) + pfile_in_zip_read_info->stream_initialised=1; + else { + TRYFREE(pfile_in_zip_read_info); + return err; + } /* windowBits is passed < 0 to tell that there is no zlib header. * Note that in this case inflate *requires* an extra "dummy" byte * after the compressed stream in order to complete decompression and @@ -1160,31 +1136,30 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) */ } pfile_in_zip_read_info->rest_read_compressed = - s->cur_file_info.compressed_size ; + s->cur_file_info.compressed_size ; pfile_in_zip_read_info->rest_read_uncompressed = - s->cur_file_info.uncompressed_size ; + s->cur_file_info.uncompressed_size ; pfile_in_zip_read_info->pos_in_zipfile = - s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + - iSizeVar; + s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + + iSizeVar; pfile_in_zip_read_info->stream.avail_in = (uInt)0; 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); if (ZSEEK(s->z_filefunc, s->filestream, s->pfile_in_zip_read->pos_in_zipfile + - s->pfile_in_zip_read->byte_before_the_zipfile, + 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; @@ -1259,22 +1234,20 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) pfile_in_zip_read_info->stream.avail_out = (uInt)len; if ((len>pfile_in_zip_read_info->rest_read_uncompressed) && - (!(pfile_in_zip_read_info->raw))) + (!(pfile_in_zip_read_info->raw))) pfile_in_zip_read_info->stream.avail_out = (uInt)pfile_in_zip_read_info->rest_read_uncompressed; if ((len>pfile_in_zip_read_info->rest_read_compressed+ - pfile_in_zip_read_info->stream.avail_in) && - (pfile_in_zip_read_info->raw)) + pfile_in_zip_read_info->stream.avail_in) && + (pfile_in_zip_read_info->raw)) pfile_in_zip_read_info->stream.avail_out = (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_compressedrest_read_compressed; @@ -1283,8 +1256,8 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) if (ZSEEK(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, pfile_in_zip_read_info->pos_in_zipfile + - pfile_in_zip_read_info->byte_before_the_zipfile, - ZLIB_FILEFUNC_SEEK_SET)!=0) + pfile_in_zip_read_info->byte_before_the_zipfile, + ZLIB_FILEFUNC_SEEK_SET)!=0) return UNZ_ERRNO; if (ZREAD(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, @@ -1294,13 +1267,12 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) # ifndef NOUNCRYPT - if(s->encrypted) - { + if (s->encrypted) { uInt i; - for(i=0;iread_buffer[i] = - zdecode(s->keys,s->pcrc_32_tab, - pfile_in_zip_read_info->read_buffer[i]); + for (i=0;iread_buffer[i] = + zdecode(s->keys,s->pcrc_32_tab, + pfile_in_zip_read_info->read_buffer[i]); } # endif @@ -1314,27 +1286,26 @@ 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) && - (pfile_in_zip_read_info->rest_read_compressed == 0)) + (pfile_in_zip_read_info->rest_read_compressed == 0)) return (iRead==0) ? UNZ_EOF : iRead; if (pfile_in_zip_read_info->stream.avail_out < - pfile_in_zip_read_info->stream.avail_in) + pfile_in_zip_read_info->stream.avail_in) uDoCopy = pfile_in_zip_read_info->stream.avail_out ; else uDoCopy = pfile_in_zip_read_info->stream.avail_in ; for (i=0;istream.next_out+i) = - *(pfile_in_zip_read_info->stream.next_in+i); + *(pfile_in_zip_read_info->stream.next_in+i); pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, - pfile_in_zip_read_info->stream.next_out, - uDoCopy); + pfile_in_zip_read_info->stream.next_out, + uDoCopy); pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; pfile_in_zip_read_info->stream.avail_in -= uDoCopy; pfile_in_zip_read_info->stream.avail_out -= uDoCopy; @@ -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; @@ -1362,14 +1331,14 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) err=inflate(&pfile_in_zip_read_info->stream,flush); if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL)) - err = Z_DATA_ERROR; + err = Z_DATA_ERROR; uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; uOutThis = uTotalOutAfter-uTotalOutBefore; pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, - (uInt)(uOutThis)); + (uInt)(uOutThis)); pfile_in_zip_read_info->rest_read_uncompressed -= 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; @@ -1464,7 +1433,7 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) return UNZ_PARAMERROR; size_to_read = (pfile_in_zip_read_info->size_local_extrafield - - pfile_in_zip_read_info->pos_local_extrafield); + pfile_in_zip_read_info->pos_local_extrafield); if (buf==NULL) return (int)size_to_read; @@ -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,11 +1525,10 @@ 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) - { - *szComment='\0'; - if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis) - return UNZ_ERRNO; + if (uReadThis>0) { + *szComment='\0'; + if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis) + return UNZ_ERRNO; } if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) @@ -1576,19 +1543,19 @@ extern uLong ZEXPORT unzGetOffset (file) unz_s* s; if (file==NULL) - return UNZ_PARAMERROR; + return UNZ_PARAMERROR; s=(unz_s*)file; if (!s->current_file_ok) - return 0; + return 0; if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff) - if (s->num_file==s->gi.number_entry) - return 0; + if (s->num_file==s->gi.number_entry) + return 0; return s->pos_in_central_dir; } extern int ZEXPORT unzSetOffset (file, pos) - unzFile file; - uLong pos; + unzFile file; +uLong pos; { unz_s* s; int err; @@ -1600,8 +1567,8 @@ extern int ZEXPORT unzSetOffset (file, pos) s->pos_in_central_dir = pos; s->num_file = s->gi.number_entry; /* hack */ err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); return err; } diff --git a/source/unzip/unzip.h b/source/unzip/unzip.h index c3206a05..b7237efa 100644 --- a/source/unzip/unzip.h +++ b/source/unzip/unzip.h @@ -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 - from (void*) without cast */ -typedef struct TagunzFile__ { int unused; } unzFile__; -typedef unzFile__ *unzFile; + /* 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; #else -typedef voidp unzFile; + typedef voidp unzFile; #endif @@ -76,274 +78,270 @@ typedef voidp unzFile; #define UNZ_INTERNALERROR (-104) #define UNZ_CRCERROR (-105) -/* 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 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; -/* 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 -{ - uLong number_entry; /* total number of entries in + /* 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 { + 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; + uLong size_comment; /* size of the global comment of the zipfile */ + } unz_global_info; -/* 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 */ - uLong compression_method; /* compression method 2 bytes */ - uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ - uLong crc; /* crc-32 4 bytes */ - uLong compressed_size; /* compressed size 4 bytes */ - uLong uncompressed_size; /* uncompressed size 4 bytes */ - uLong size_filename; /* filename length 2 bytes */ - uLong size_file_extra; /* extra field length 2 bytes */ - uLong size_file_comment; /* file comment length 2 bytes */ + /* 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 */ + uLong compression_method; /* compression method 2 bytes */ + uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ + uLong crc; /* crc-32 4 bytes */ + uLong compressed_size; /* compressed size 4 bytes */ + uLong uncompressed_size; /* uncompressed size 4 bytes */ + uLong size_filename; /* filename length 2 bytes */ + uLong size_file_extra; /* extra field length 2 bytes */ + uLong size_file_comment; /* file comment length 2 bytes */ - uLong disk_num_start; /* disk number start 2 bytes */ - uLong internal_fa; /* internal file attributes 2 bytes */ - uLong external_fa; /* external file attributes 4 bytes */ + uLong disk_num_start; /* disk number start 2 bytes */ + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ - tm_unz tmu_date; -} unz_file_info; + tm_unz tmu_date; + } unz_file_info; -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 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)); -/* - 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". - If the zipfile cannot be opened (file don't exist or in not valid), the - return value is NULL. - Else, the return value is a unzFile Handle, usable with other function - of this unzip package. -*/ + 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". + If the zipfile cannot be opened (file don't exist or in not valid), the + 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, - 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 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)); -/* - 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 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, - 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 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, - 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 -*/ + 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)); -/* - Set the current file of the zipfile to the first file. - return UNZ_OK if there is no problem -*/ + 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)); -/* - 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 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, - const char *szFileName, - int iCaseSensitivity)); -/* - Try locate the file szFileName in the zipfile. - For the iCaseSensitivity signification, see unzStringFileNameCompare + 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 -*/ + 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 -{ - uLong pos_in_zip_directory; /* offset in zip file directory */ - uLong num_of_file; /* # of file */ -} unz_file_pos; + /* ****************************************** */ + /* 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; -extern int ZEXPORT unzGetFilePos( - unzFile file, - unz_file_pos* file_pos); + extern int ZEXPORT unzGetFilePos( + unzFile file, + unz_file_pos* file_pos); -extern int ZEXPORT unzGoToFilePos( - unzFile file, - unz_file_pos* file_pos); + extern int ZEXPORT unzGoToFilePos( + unzFile file, + unz_file_pos* file_pos); -/* ****************************************** */ + /* ****************************************** */ -extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, - unz_file_info *pfile_info, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - 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 - if szFileName!=NULL, the filemane string will be copied in szFileName - (fileNameBufferSize is the size of the buffer) - if extraField!=NULL, the extra field information will be copied in extraField - (extraFieldBufferSize is the size of the buffer). - 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) -*/ + extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, + unz_file_info *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + 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 + if szFileName!=NULL, the filemane string will be copied in szFileName + (fileNameBufferSize is the size of the buffer) + if extraField!=NULL, the extra field information will be copied in extraField + (extraFieldBufferSize is the size of the buffer). + 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 - from it, and close it (you can close it before reading all the file) - */ + /***************************************************************************/ + /* 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)); -/* - Open for reading data the current file in the zipfile. - If there is no error, the return value is UNZ_OK. -*/ + 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, - 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 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, - 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 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, - 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 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)); -/* - 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 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, - 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. + 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. - return the number of byte copied if somes bytes are copied - 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) -*/ + return the number of byte copied if somes bytes are copied + 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)); -/* - Give the current position in uncompressed data -*/ + extern z_off_t ZEXPORT unztell OF((unzFile file)); + /* + Give the current position in uncompressed data + */ -extern int ZEXPORT unzeof OF((unzFile file)); -/* - return 1 if the end of file was reached, 0 elsewhere -*/ + 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, - 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) + 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) - if buf==NULL, it return the size of the local extra field + if buf==NULL, it return the size of the local extra field - if buf!=NULL, len is the size of the buffer, the extra header is copied in - buf. - the return value is the number of bytes copied in buf, or (if <0) - the error code -*/ + if buf!=NULL, len is the size of the buffer, the extra header is copied in + 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); diff --git a/source/usbloader/alternatedol.c b/source/usbloader/alternatedol.c index c74dd0a6..d593a3fa 100644 --- a/source/usbloader/alternatedol.c +++ b/source/usbloader/alternatedol.c @@ -11,92 +11,85 @@ /** Alternate dolloader made by WiiPower modified by dimok **/ -bool Load_Dol(void **buffer, int* dollen, char * filepath) -{ - int ret; - FILE* file; - void* dol_buffer; +bool Load_Dol(void **buffer, int* dollen, char * filepath) { + int ret; + FILE* file; + void* dol_buffer; - char fullpath[200]; - char gameidbuffer6[7]; - memset(gameidbuffer6, 0, 7); - memcpy(gameidbuffer6, (char*)0x80000000, 6); - snprintf(fullpath, 200, "%s%s.dol", filepath, gameidbuffer6); + char fullpath[200]; + char gameidbuffer6[7]; + memset(gameidbuffer6, 0, 7); + memcpy(gameidbuffer6, (char*)0x80000000, 6); + snprintf(fullpath, 200, "%s%s.dol", filepath, gameidbuffer6); SDCard_Init(); USBDevice_Init(); - file = fopen(fullpath, "rb"); + file = fopen(fullpath, "rb"); - if(file == NULL) - { - fclose(file); - SDCard_deInit(); - USBDevice_deInit(); - return false; - } + if (file == NULL) { + fclose(file); + SDCard_deInit(); + USBDevice_deInit(); + return false; + } - int filesize; - fseek(file, 0, SEEK_END); - filesize = ftell(file); - fseek(file, 0, SEEK_SET); + int filesize; + fseek(file, 0, SEEK_END); + filesize = ftell(file); + fseek(file, 0, SEEK_SET); - dol_buffer = malloc(filesize); - if (dol_buffer == NULL) - { - fclose(file); - SDCard_deInit(); - USBDevice_deInit(); - return false; - } - ret = fread( dol_buffer, 1, filesize, file); - if(ret != filesize) - { - free(dol_buffer); - fclose(file); - SDCard_deInit(); - USBDevice_deInit(); - return false; - } - fclose(file); + dol_buffer = malloc(filesize); + if (dol_buffer == NULL) { + fclose(file); + SDCard_deInit(); + USBDevice_deInit(); + return false; + } + ret = fread( dol_buffer, 1, filesize, file); + if (ret != filesize) { + free(dol_buffer); + fclose(file); + SDCard_deInit(); + USBDevice_deInit(); + return false; + } + fclose(file); - SDCard_deInit(); + SDCard_deInit(); USBDevice_deInit(); - *buffer = dol_buffer; - *dollen = filesize; - return true; + *buffer = dol_buffer; + *dollen = filesize; + return true; } -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 }; +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; + void *Addr = Address; + void *Addr_end = Address+Size; - while(Addr <= Addr_end-sizeof(SearchPattern)) - { - if(memcmp(Addr, SearchPattern, sizeof(SearchPattern))==0) - { - memcpy(Addr,PatchData,sizeof(PatchData)); - return true; - } - Addr += 4; - } - return false; + while (Addr <= Addr_end-sizeof(SearchPattern)) { + if (memcmp(Addr, SearchPattern, sizeof(SearchPattern))==0) { + memcpy(Addr,PatchData,sizeof(PatchData)); + return true; + } + Addr += 4; + } + return false; } typedef struct _dolheader { - u32 text_pos[7]; - u32 data_pos[11]; - u32 text_start[7]; - u32 data_start[11]; - u32 text_size[7]; - u32 data_size[11]; - u32 bss_start; - u32 bss_size; - u32 entry_point; + u32 text_pos[7]; + u32 data_pos[11]; + u32 text_start[7]; + u32 data_start[11]; + u32 text_size[7]; + u32 data_size[11]; + u32 bss_start; + u32 bss_size; + u32 entry_point; } dolheader; static dolheader *dolfile; @@ -104,147 +97,129 @@ static dolheader *dolfile; u32 load_dol_image(void *dolstart) { - u32 i; + u32 i; - if (dolstart) { - dolfile = (dolheader *) dolstart; - for (i = 0; i < 7; i++) { - if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) continue; - VIDEO_WaitVSync(); - ICInvalidateRange ((void *) dolfile->text_start[i],dolfile->text_size[i]); - memmove ((void *) dolfile->text_start[i],dolstart+dolfile->text_pos[i],dolfile->text_size[i]); - } + if (dolstart) { + dolfile = (dolheader *) dolstart; + for (i = 0; i < 7; i++) { + if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) continue; + VIDEO_WaitVSync(); + ICInvalidateRange ((void *) dolfile->text_start[i],dolfile->text_size[i]); + memmove ((void *) dolfile->text_start[i],dolstart+dolfile->text_pos[i],dolfile->text_size[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]); - DCFlushRangeNoSync ((void *) dolfile->data_start[i],dolfile->data_size[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]); + DCFlushRangeNoSync ((void *) dolfile->data_start[i],dolfile->data_size[i]); + } /* - memset ((void *) dolfile->bss_start, 0, dolfile->bss_size); - DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size); + memset ((void *) dolfile->bss_start, 0, dolfile->bss_size); + DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size); */ - return dolfile->entry_point; - } - return 0; + return dolfile->entry_point; + } + return 0; } static int i; static int phase; -u32 load_dol_start(void *dolstart) -{ - if (dolstart) - { - dolfile = (dolheader *)dolstart; +u32 load_dol_start(void *dolstart) { + if (dolstart) { + dolfile = (dolheader *)dolstart; return dolfile->entry_point; - } else - { - return 0; - } + } else { + return 0; + } memset((void *)dolfile->bss_start, 0, dolfile->bss_size); DCFlushRange((void *)dolfile->bss_start, dolfile->bss_size); - phase = 0; - i = 0; + phase = 0; + i = 0; } -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)) - { - *offset = 0; - *pos = 0; - *len = 0; - } else - { - *offset = (void *)dolfile->text_start[i]; - *pos = dolfile->text_pos[i]; - *len = dolfile->text_size[i]; - } - i++; - return true; - } - } +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)) { + *offset = 0; + *pos = 0; + *len = 0; + } else { + *offset = (void *)dolfile->text_start[i]; + *pos = dolfile->text_pos[i]; + *len = dolfile->text_size[i]; + } + i++; + return true; + } + } - if (phase == 1) - { - if (i == 11) - { - phase = 2; - return false; - } + if (phase == 1) { + if (i == 11) { + phase = 2; + return false; + } - if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) - { - *offset = 0; - *pos = 0; - *len = 0; - } else - { - *offset = (void *)dolfile->data_start[i]; - *pos = dolfile->data_pos[i]; - *len = dolfile->data_size[i]; - } - i++; - return true; - } - return false; + if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) { + *offset = 0; + *pos = 0; + *len = 0; + } else { + *offset = (void *)dolfile->data_start[i]; + *pos = dolfile->data_pos[i]; + *len = dolfile->data_size[i]; + } + i++; + return true; + } + return false; } -u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u8 vipatch) -{ - int ret; - void *dol_header; - u32 entrypoint; +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) - { - return -1; - } + dol_header = memalign(32, sizeof(dolheader)); + if (dol_header == NULL) { + return -1; + } - ret = WDVD_Read(dol_header, sizeof(dolheader), (doloffset<<2)); + ret = WDVD_Read(dol_header, sizeof(dolheader), (doloffset<<2)); - entrypoint = load_dol_start(dol_header); + entrypoint = load_dol_start(dol_header); - if (entrypoint == 0) - { - free(dol_header); - return -1; - } + if (entrypoint == 0) { + free(dol_header); + return -1; + } - void *offset; - u32 pos; - u32 len; + void *offset; + u32 pos; + u32 len; - while (load_dol_image_modified(&offset, &pos, &len)) - { - if (len != 0) - { - ret = WDVD_Read(offset, len, (doloffset<<2) + pos); + while (load_dol_image_modified(&offset, &pos, &len)) { + if (len != 0) { + ret = WDVD_Read(offset, len, (doloffset<<2) + pos); DCFlushRange(offset, len); - gamepatches(offset, len, videoSelected, patchcountrystring, vipatch); + gamepatches(offset, len, videoSelected, patchcountrystring, vipatch); DCFlushRange(offset, len); - Remove_001_Protection(offset, len); - } - } + Remove_001_Protection(offset, len); + } + } - free(dol_header); + free(dol_header); - return entrypoint; + return entrypoint; } diff --git a/source/usbloader/alternatedol.h b/source/usbloader/alternatedol.h index 4fe84e00..b5e3f463 100644 --- a/source/usbloader/alternatedol.h +++ b/source/usbloader/alternatedol.h @@ -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 } diff --git a/source/usbloader/apploader.c b/source/usbloader/apploader.c index b2cd36fb..0f250461 100644 --- a/source/usbloader/apploader.c +++ b/source/usbloader/apploader.c @@ -1,10 +1,10 @@ -#include +#include #include -#include +#include #include "patches/patchcode.h" #include "patches/kenobiwii.h" /*FISHEARS*/ -#include "apploader.h" +#include "apploader.h" #include "wdvd.h" #include "wpad.h" #include "disc.h" @@ -15,14 +15,14 @@ /*KENOBI! - FISHEARS*/ extern const unsigned char kenobiwii[]; extern const int kenobiwii_size; -/*KENOBI! - FISHEARS*/ - -/* Apploader function pointers */ -typedef int (*app_main)(void **dst, int *size, int *offset); -typedef void (*app_init)(void (*report)(const char *fmt, ...)); -typedef void *(*app_final)(); -typedef void (*app_entry)(void (**init)(void (*report)(const char *fmt, ...)), int (**main)(), void *(**final)()); - +/*KENOBI! - FISHEARS*/ + +/* Apploader function pointers */ +typedef int (*app_main)(void **dst, int *size, int *offset); +typedef void (*app_init)(void (*report)(const char *fmt, ...)); +typedef void *(*app_final)(); +typedef void (*app_entry)(void (**init)(void (*report)(const char *fmt, ...)), int (**main)(), void *(**final)()); + /* Apploader pointers */ static u8 *appldr = (u8 *)0x81200000; @@ -34,340 +34,322 @@ 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) -{ - 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] || - mode1->sample_pattern[1][0] != mode2->sample_pattern[1][0] || mode1->sample_pattern[2][0] != mode2->sample_pattern[2][0] || - mode1->sample_pattern[3][0] != mode2->sample_pattern[3][0] || mode1->sample_pattern[4][0] != mode2->sample_pattern[4][0] || - mode1->sample_pattern[5][0] != mode2->sample_pattern[5][0] || mode1->sample_pattern[6][0] != mode2->sample_pattern[6][0] || - mode1->sample_pattern[7][0] != mode2->sample_pattern[7][0] || mode1->sample_pattern[8][0] != mode2->sample_pattern[8][0] || - mode1->sample_pattern[9][0] != mode2->sample_pattern[9][0] || mode1->sample_pattern[10][0] != mode2->sample_pattern[10][0] || - mode1->sample_pattern[11][0] != mode2->sample_pattern[11][0] || mode1->sample_pattern[0][1] != mode2->sample_pattern[0][1] || - mode1->sample_pattern[1][1] != mode2->sample_pattern[1][1] || mode1->sample_pattern[2][1] != mode2->sample_pattern[2][1] || - mode1->sample_pattern[3][1] != mode2->sample_pattern[3][1] || mode1->sample_pattern[4][1] != mode2->sample_pattern[4][1] || - mode1->sample_pattern[5][1] != mode2->sample_pattern[5][1] || mode1->sample_pattern[6][1] != mode2->sample_pattern[6][1] || - mode1->sample_pattern[7][1] != mode2->sample_pattern[7][1] || mode1->sample_pattern[8][1] != mode2->sample_pattern[8][1] || - 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] ) - { - return false; - } else - { - return true; - } + + + +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] || + mode1->sample_pattern[1][0] != mode2->sample_pattern[1][0] || mode1->sample_pattern[2][0] != mode2->sample_pattern[2][0] || + mode1->sample_pattern[3][0] != mode2->sample_pattern[3][0] || mode1->sample_pattern[4][0] != mode2->sample_pattern[4][0] || + mode1->sample_pattern[5][0] != mode2->sample_pattern[5][0] || mode1->sample_pattern[6][0] != mode2->sample_pattern[6][0] || + mode1->sample_pattern[7][0] != mode2->sample_pattern[7][0] || mode1->sample_pattern[8][0] != mode2->sample_pattern[8][0] || + mode1->sample_pattern[9][0] != mode2->sample_pattern[9][0] || mode1->sample_pattern[10][0] != mode2->sample_pattern[10][0] || + mode1->sample_pattern[11][0] != mode2->sample_pattern[11][0] || mode1->sample_pattern[0][1] != mode2->sample_pattern[0][1] || + mode1->sample_pattern[1][1] != mode2->sample_pattern[1][1] || mode1->sample_pattern[2][1] != mode2->sample_pattern[2][1] || + mode1->sample_pattern[3][1] != mode2->sample_pattern[3][1] || mode1->sample_pattern[4][1] != mode2->sample_pattern[4][1] || + mode1->sample_pattern[5][1] != mode2->sample_pattern[5][1] || mode1->sample_pattern[6][1] != mode2->sample_pattern[6][1] || + mode1->sample_pattern[7][1] != mode2->sample_pattern[7][1] || mode1->sample_pattern[8][1] != mode2->sample_pattern[8][1] || + 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] ) { + return false; + } else { + return true; + } } -void patch_videomode(GXRModeObj* mode1, GXRModeObj* mode2) -{ - 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]; - mode1->sample_pattern[1][0] = mode2->sample_pattern[1][0]; - mode1->sample_pattern[2][0] = mode2->sample_pattern[2][0]; - mode1->sample_pattern[3][0] = mode2->sample_pattern[3][0]; - mode1->sample_pattern[4][0] = mode2->sample_pattern[4][0]; - mode1->sample_pattern[5][0] = mode2->sample_pattern[5][0]; - mode1->sample_pattern[6][0] = mode2->sample_pattern[6][0]; - mode1->sample_pattern[7][0] = mode2->sample_pattern[7][0]; - mode1->sample_pattern[8][0] = mode2->sample_pattern[8][0]; - mode1->sample_pattern[9][0] = mode2->sample_pattern[9][0]; - mode1->sample_pattern[10][0] = mode2->sample_pattern[10][0]; - mode1->sample_pattern[11][0] = mode2->sample_pattern[11][0]; - mode1->sample_pattern[0][1] = mode2->sample_pattern[0][1]; - mode1->sample_pattern[1][1] = mode2->sample_pattern[1][1]; - mode1->sample_pattern[2][1] = mode2->sample_pattern[2][1]; - mode1->sample_pattern[3][1] = mode2->sample_pattern[3][1]; - mode1->sample_pattern[4][1] = mode2->sample_pattern[4][1]; - mode1->sample_pattern[5][1] = mode2->sample_pattern[5][1]; - mode1->sample_pattern[6][1] = mode2->sample_pattern[6][1]; - mode1->sample_pattern[7][1] = mode2->sample_pattern[7][1]; - mode1->sample_pattern[8][1] = mode2->sample_pattern[8][1]; - 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]; +void patch_videomode(GXRModeObj* mode1, GXRModeObj* mode2) { + 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]; + mode1->sample_pattern[1][0] = mode2->sample_pattern[1][0]; + mode1->sample_pattern[2][0] = mode2->sample_pattern[2][0]; + mode1->sample_pattern[3][0] = mode2->sample_pattern[3][0]; + mode1->sample_pattern[4][0] = mode2->sample_pattern[4][0]; + mode1->sample_pattern[5][0] = mode2->sample_pattern[5][0]; + mode1->sample_pattern[6][0] = mode2->sample_pattern[6][0]; + mode1->sample_pattern[7][0] = mode2->sample_pattern[7][0]; + mode1->sample_pattern[8][0] = mode2->sample_pattern[8][0]; + mode1->sample_pattern[9][0] = mode2->sample_pattern[9][0]; + mode1->sample_pattern[10][0] = mode2->sample_pattern[10][0]; + mode1->sample_pattern[11][0] = mode2->sample_pattern[11][0]; + mode1->sample_pattern[0][1] = mode2->sample_pattern[0][1]; + mode1->sample_pattern[1][1] = mode2->sample_pattern[1][1]; + mode1->sample_pattern[2][1] = mode2->sample_pattern[2][1]; + mode1->sample_pattern[3][1] = mode2->sample_pattern[3][1]; + mode1->sample_pattern[4][1] = mode2->sample_pattern[4][1]; + mode1->sample_pattern[5][1] = mode2->sample_pattern[5][1]; + mode1->sample_pattern[6][1] = mode2->sample_pattern[6][1]; + mode1->sample_pattern[7][1] = mode2->sample_pattern[7][1]; + mode1->sample_pattern[8][1] = mode2->sample_pattern[8][1]; + 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]; } GXRModeObj* vmodes[] = { - &TVNtsc240Ds, - &TVNtsc240DsAa, - &TVNtsc240Int, - &TVNtsc240IntAa, - &TVNtsc480IntDf, - &TVNtsc480IntAa, - &TVNtsc480Prog, - &TVMpal480IntDf, - &TVPal264Ds, - &TVPal264DsAa, - &TVPal264Int, - &TVPal264IntAa, - &TVPal524IntAa, - &TVPal528Int, - &TVPal528IntDf, - &TVPal574IntDfScale, - &TVEurgb60Hz240Ds, - &TVEurgb60Hz240DsAa, - &TVEurgb60Hz240Int, - &TVEurgb60Hz240IntAa, - &TVEurgb60Hz480Int, - &TVEurgb60Hz480IntDf, - &TVEurgb60Hz480IntAa, - &TVEurgb60Hz480Prog, - &TVEurgb60Hz480ProgSoft, - &TVEurgb60Hz480ProgAa + &TVNtsc240Ds, + &TVNtsc240DsAa, + &TVNtsc240Int, + &TVNtsc240IntAa, + &TVNtsc480IntDf, + &TVNtsc480IntAa, + &TVNtsc480Prog, + &TVMpal480IntDf, + &TVPal264Ds, + &TVPal264DsAa, + &TVPal264Int, + &TVPal264IntAa, + &TVPal524IntAa, + &TVPal528Int, + &TVPal528IntDf, + &TVPal574IntDfScale, + &TVEurgb60Hz240Ds, + &TVEurgb60Hz240DsAa, + &TVEurgb60Hz240Int, + &TVEurgb60Hz240IntAa, + &TVEurgb60Hz480Int, + &TVEurgb60Hz480IntDf, + &TVEurgb60Hz480IntAa, + &TVEurgb60Hz480Prog, + &TVEurgb60Hz480ProgSoft, + &TVEurgb60Hz480ProgAa }; GXRModeObj* PAL2NTSC[]={ - &TVMpal480IntDf, &TVNtsc480IntDf, - &TVPal264Ds, &TVNtsc240Ds, - &TVPal264DsAa, &TVNtsc240DsAa, - &TVPal264Int, &TVNtsc240Int, - &TVPal264IntAa, &TVNtsc240IntAa, - &TVPal524IntAa, &TVNtsc480IntAa, - &TVPal528Int, &TVNtsc480IntAa, - &TVPal528IntDf, &TVNtsc480IntDf, - &TVPal574IntDfScale, &TVNtsc480IntDf, - &TVEurgb60Hz240Ds, &TVNtsc240Ds, - &TVEurgb60Hz240DsAa, &TVNtsc240DsAa, - &TVEurgb60Hz240Int, &TVNtsc240Int, - &TVEurgb60Hz240IntAa, &TVNtsc240IntAa, - &TVEurgb60Hz480Int, &TVNtsc480IntAa, - &TVEurgb60Hz480IntDf, &TVNtsc480IntDf, - &TVEurgb60Hz480IntAa, &TVNtsc480IntAa, - &TVEurgb60Hz480Prog, &TVNtsc480Prog, - &TVEurgb60Hz480ProgSoft,&TVNtsc480Prog, - &TVEurgb60Hz480ProgAa, &TVNtsc480Prog, - 0,0 + &TVMpal480IntDf, &TVNtsc480IntDf, + &TVPal264Ds, &TVNtsc240Ds, + &TVPal264DsAa, &TVNtsc240DsAa, + &TVPal264Int, &TVNtsc240Int, + &TVPal264IntAa, &TVNtsc240IntAa, + &TVPal524IntAa, &TVNtsc480IntAa, + &TVPal528Int, &TVNtsc480IntAa, + &TVPal528IntDf, &TVNtsc480IntDf, + &TVPal574IntDfScale, &TVNtsc480IntDf, + &TVEurgb60Hz240Ds, &TVNtsc240Ds, + &TVEurgb60Hz240DsAa, &TVNtsc240DsAa, + &TVEurgb60Hz240Int, &TVNtsc240Int, + &TVEurgb60Hz240IntAa, &TVNtsc240IntAa, + &TVEurgb60Hz480Int, &TVNtsc480IntAa, + &TVEurgb60Hz480IntDf, &TVNtsc480IntDf, + &TVEurgb60Hz480IntAa, &TVNtsc480IntAa, + &TVEurgb60Hz480Prog, &TVNtsc480Prog, + &TVEurgb60Hz480ProgSoft,&TVNtsc480Prog, + &TVEurgb60Hz480ProgAa, &TVNtsc480Prog, + 0,0 }; GXRModeObj* NTSC2PAL[]={ - &TVNtsc240Ds, &TVPal264Ds, - &TVNtsc240DsAa, &TVPal264DsAa, - &TVNtsc240Int, &TVPal264Int, - &TVNtsc240IntAa, &TVPal264IntAa, - &TVNtsc480IntDf, &TVPal528IntDf, - &TVNtsc480IntAa, &TVPal524IntAa, - &TVNtsc480Prog, &TVPal528IntDf, - 0,0 + &TVNtsc240Ds, &TVPal264Ds, + &TVNtsc240DsAa, &TVPal264DsAa, + &TVNtsc240Int, &TVPal264Int, + &TVNtsc240IntAa, &TVPal264IntAa, + &TVNtsc480IntDf, &TVPal528IntDf, + &TVNtsc480IntAa, &TVPal524IntAa, + &TVNtsc480Prog, &TVPal528IntDf, + 0,0 }; GXRModeObj* NTSC2PAL60[]={ - &TVNtsc240Ds, &TVEurgb60Hz240Ds, - &TVNtsc240DsAa, &TVEurgb60Hz240DsAa, - &TVNtsc240Int, &TVEurgb60Hz240Int, - &TVNtsc240IntAa, &TVEurgb60Hz240IntAa, - &TVNtsc480IntDf, &TVEurgb60Hz480IntDf, - &TVNtsc480IntAa, &TVEurgb60Hz480IntAa, - &TVNtsc480Prog, &TVEurgb60Hz480Prog, - 0,0 + &TVNtsc240Ds, &TVEurgb60Hz240Ds, + &TVNtsc240DsAa, &TVEurgb60Hz240DsAa, + &TVNtsc240Int, &TVEurgb60Hz240Int, + &TVNtsc240IntAa, &TVEurgb60Hz240IntAa, + &TVNtsc480IntDf, &TVEurgb60Hz480IntDf, + &TVNtsc480IntAa, &TVEurgb60Hz480IntAa, + &TVNtsc480Prog, &TVEurgb60Hz480Prog, + 0,0 }; -bool Search_and_patch_Video_Modes(void *Address, u32 Size, GXRModeObj* Table[]) -{ - u8 *Addr = (u8 *)Address; - bool found = 0; - u32 i; +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; - patch_videomode((GXRModeObj*)Addr, Table[i+1]); - Addr += (sizeof(GXRModeObj)-4); - Size -= (sizeof(GXRModeObj)-4); - break; - } - } + { + found = 1; + patch_videomode((GXRModeObj*)Addr, Table[i+1]); + Addr += (sizeof(GXRModeObj)-4); + Size -= (sizeof(GXRModeObj)-4); + break; + } + } - Addr += 4; - Size -= 4; - } + Addr += 4; + Size -= 4; + } - return found; + return found; } /** Anti 002 fix for IOS 249 rev < 12 thanks to WiiPower **/ -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 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; + void *Addr = Address; + void *Addr_end = Address+Size; - while(Addr <= Addr_end-sizeof(SearchPattern)) - { - if(memcmp(Addr, SearchPattern, sizeof(SearchPattern))==0) - { - memcpy(Addr,PatchData,sizeof(PatchData)); - } - Addr += 4; - } + 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()) - { - case CONF_VIDEO_PAL: - if(CONF_GetEuRGB60() > 0) - { - table = NTSC2PAL60; - } - else - { - table = NTSC2PAL; - } - break; - - case CONF_VIDEO_MPAL: - - - - table = NTSC2PAL; - break; - - - default: - table = PAL2NTSC; - break; - } - Search_and_patch_Video_Modes(dst, len, table); - } - - /*GAME HOOK - FISHEARS*/ - dogamehooks(dst,len); - - if (vipatch) - vidolpatcher(dst,len); - - - /*LANGUAGE PATCH - FISHEARS*/ - langpatcher(dst,len); - - /*Thanks to WiiPower*/ - if(patchcountrystring == 1) - PatchCountryStrings(dst, len); - - //if(Settings.anti002fix == on) - 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) -{ - app_entry appldr_entry; - app_init appldr_init; - app_main appldr_main; - app_final appldr_final; - - u32 appldr_len; - s32 ret; - - /* Read apploader header */ - ret = WDVD_Read(buffer, 0x20, APPLDR_OFFSET); - if (ret < 0) - return ret; - - /* Calculate apploader length */ - appldr_len = buffer[5] + buffer[6]; - - /* Read apploader code */ - ret = WDVD_Read(appldr, appldr_len, APPLDR_OFFSET + 0x20); - if (ret < 0) - return ret; - - /* Set apploader entry function */ - appldr_entry = (app_entry)buffer[4]; - - /* Call apploader entry */ - appldr_entry(&appldr_init, &appldr_main, &appldr_final); - - /* Initialize apploader */ - appldr_init(__noprint); - - if(error002fix!=0){ - /* ERROR 002 fix (thanks to WiiPower for sharing this)*/ - *(u32 *)0x80003140 = *(u32 *)0x80003188; - } - - if (cheat) { - /*HOOKS STUFF - FISHEARS*/ - memset((void*)0x80001800,0,kenobiwii_size); - memcpy((void*)0x80001800,kenobiwii,kenobiwii_size); - DCFlushRange((void*)0x80001800,kenobiwii_size); - hooktype = 1; - memcpy((void*)0x80001800, (char*)0x80000000, 6); // For WiiRD - /*HOOKS STUFF - FISHEARS*/ - } - - for (;;) { - void *dst = NULL; - int len = 0, offset = 0; - - /* Run apploader main function */ - ret = appldr_main(&dst, &len, &offset); - if (!ret) - break; - - /* Read data from DVD */ - WDVD_Read(dst, len, (u64)(offset << 2)); + switch (CONF_GetVideo()) { + case CONF_VIDEO_PAL: + if (CONF_GetEuRGB60() > 0) { + table = NTSC2PAL60; + } else { + table = NTSC2PAL; + } + break; + + case CONF_VIDEO_MPAL: + + + + table = NTSC2PAL; + break; + + + default: + table = PAL2NTSC; + break; + } + Search_and_patch_Video_Modes(dst, len, table); + } + + /*GAME HOOK - FISHEARS*/ + dogamehooks(dst,len); + + if (vipatch) + vidolpatcher(dst,len); + + + /*LANGUAGE PATCH - FISHEARS*/ + langpatcher(dst,len); + + /*Thanks to WiiPower*/ + if (patchcountrystring == 1) + PatchCountryStrings(dst, len); + + //if(Settings.anti002fix == on) + 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) { + app_entry appldr_entry; + app_init appldr_init; + app_main appldr_main; + app_final appldr_final; + + u32 appldr_len; + s32 ret; + + /* Read apploader header */ + ret = WDVD_Read(buffer, 0x20, APPLDR_OFFSET); + if (ret < 0) + return ret; + + /* Calculate apploader length */ + appldr_len = buffer[5] + buffer[6]; + + /* Read apploader code */ + ret = WDVD_Read(appldr, appldr_len, APPLDR_OFFSET + 0x20); + if (ret < 0) + return ret; + + /* Set apploader entry function */ + appldr_entry = (app_entry)buffer[4]; + + /* Call apploader entry */ + appldr_entry(&appldr_init, &appldr_main, &appldr_final); + + /* Initialize apploader */ + appldr_init(__noprint); + + if (error002fix!=0) { + /* ERROR 002 fix (thanks to WiiPower for sharing this)*/ + *(u32 *)0x80003140 = *(u32 *)0x80003188; + } + + if (cheat) { + /*HOOKS STUFF - FISHEARS*/ + memset((void*)0x80001800,0,kenobiwii_size); + memcpy((void*)0x80001800,kenobiwii,kenobiwii_size); + DCFlushRange((void*)0x80001800,kenobiwii_size); + hooktype = 1; + memcpy((void*)0x80001800, (char*)0x80000000, 6); // For WiiRD + /*HOOKS STUFF - FISHEARS*/ + } + + for (;;) { + void *dst = NULL; + int len = 0, offset = 0; + + /* Run apploader main function */ + ret = appldr_main(&dst, &len, &offset); + if (!ret) + break; + + /* Read data from DVD */ + WDVD_Read(dst, len, (u64)(offset << 2)); gamepatches(dst, len, videoSelected, patchcountrystring, vipatch); - DCFlushRange(dst, len); - } + DCFlushRange(dst, len); + } *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); @@ -375,19 +357,19 @@ s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8 gamepatches(dolbuffer, dollen, videoSelected, patchcountrystring, vipatch); DCFlushRange(dolbuffer, dollen); - - /* Set entry point from apploader */ + + /* 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); - } - - return 0; + } + + return 0; } diff --git a/source/usbloader/apploader.h b/source/usbloader/apploader.h index 7a6c44f7..77b45338 100644 --- a/source/usbloader/apploader.h +++ b/source/usbloader/apploader.h @@ -1,17 +1,16 @@ -#ifndef _APPLOADER_H_ +#ifndef _APPLOADER_H_ #define _APPLOADER_H_ #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif - -/* 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); + + /* 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); #ifdef __cplusplus } diff --git a/source/usbloader/disc.c b/source/usbloader/disc.c index ff384624..b56cb0c3 100644 --- a/source/usbloader/disc.c +++ b/source/usbloader/disc.c @@ -2,15 +2,15 @@ #include #include #include -#include -#include - +#include +#include + #include "patches/fst.h" #include "apploader.h" #include "disc.h" #include "video.h" -#include "wdvd.h" -#include "alternatedol.h" +#include "wdvd.h" +#include "alternatedol.h" /* Constants */ #define PTABLE_OFFSET 0x40000 @@ -18,386 +18,370 @@ /* Disc pointers */ static u32 *buffer = (u32 *)0x93000000; -static u8 *diskid = (u8 *)0x80000000; +static u8 *diskid = (u8 *)0x80000000; static char gameid[8]; -void __Disc_SetLowMem(void) -{ - *(vu32 *)0x80000020 = 0x0D15EA5E; // Standard Boot Code +void __Disc_SetLowMem(void) { + *(vu32 *)0x80000020 = 0x0D15EA5E; // Standard Boot Code *(vu32 *)0x80000024 = 0x00000001; // Version - *(vu32 *)0x80000030 = 0x00000000; // Arena Low - *(vu32 *)0x800000F4 = 0x817E5480; // BI2 - *(vu32 *)0x800000F8 = 0x0E7BE2C0; // Console Bus Speed - *(vu32 *)0x800000FC = 0x2B73A840; // Console CPU Speed - - /* Setup low memory */ - *(vu32 *)0x80000060 = 0x38A00040; - *(vu32 *)0x800000E4 = 0x80431A80; - *(vu32 *)0x800000EC = 0x81800000; // Dev Debugger Monitor Address + *(vu32 *)0x80000030 = 0x00000000; // Arena Low + *(vu32 *)0x800000F4 = 0x817E5480; // BI2 + *(vu32 *)0x800000F8 = 0x0E7BE2C0; // Console Bus Speed + *(vu32 *)0x800000FC = 0x2B73A840; // Console CPU Speed + + /* Setup low memory */ + *(vu32 *)0x80000060 = 0x38A00040; + *(vu32 *)0x800000E4 = 0x80431A80; + *(vu32 *)0x800000EC = 0x81800000; // Dev Debugger Monitor Address *(vu32 *)0x800000F0 = 0x01800000; // Simulated Memory Size - //If the game is sam & max: season 1 put this shit in - char tempTxt[10]; - snprintf (tempTxt,sizeof(tempTxt),"%c%c%c%c%c%c", gameid[0], gameid[1], gameid[2], gameid[3], gameid[4], gameid[5]); + //If the game is sam & max: season 1 put this shit in + char tempTxt[10]; + snprintf (tempTxt,sizeof(tempTxt),"%c%c%c%c%c%c", gameid[0], gameid[1], gameid[2], gameid[3], gameid[4], gameid[5]); if ((strcmp(tempTxt,"R3XE6U")==0)|| - (strcmp(tempTxt,"R3XP6V")==0))/*&& + (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 + ((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 + } - /* Copy disc ID */ - memcpy((void *)0x80003180, (void *)0x80000000, 4); + /* Copy disc ID */ + memcpy((void *)0x80003180, (void *)0x80000000, 4); - /* Flush cache */ - DCFlushRange((void *)0x80000000, 0x3F00); + /* Flush cache */ + DCFlushRange((void *)0x80000000, 0x3F00); } -void __Disc_SetVMode(u8 videoselected) -{ - GXRModeObj *vmode = NULL; +void __Disc_SetVMode(u8 videoselected) { + GXRModeObj *vmode = NULL; - u32 progressive, tvmode, vmode_reg = 0; + u32 progressive, tvmode, vmode_reg = 0; - /* Get video mode configuration */ - progressive = (CONF_GetProgressiveScan() > 0) && VIDEO_HaveComponentCable(); - tvmode = CONF_GetVideo(); + /* Get video mode configuration */ + progressive = (CONF_GetProgressiveScan() > 0) && VIDEO_HaveComponentCable(); + tvmode = CONF_GetVideo(); - /* Select video mode register */ - switch (tvmode) { - case CONF_VIDEO_PAL: - vmode_reg = (CONF_GetEuRGB60() > 0) ? 5 : 1; - break; + /* Select video mode register */ + switch (tvmode) { + case CONF_VIDEO_PAL: + vmode_reg = (CONF_GetEuRGB60() > 0) ? 5 : 1; + break; - case CONF_VIDEO_MPAL: - vmode_reg = 4; - break; + case CONF_VIDEO_MPAL: + vmode_reg = 4; + break; - case CONF_VIDEO_NTSC: - vmode_reg = 0; - break; - } - - switch (videoselected) { - case 0: - - /* Select video mode */ - switch(diskid[3]) { - /* PAL */ - case 'D': - case 'F': - case 'P': - case 'X': - case 'Y': - if (tvmode != CONF_VIDEO_PAL) { - vmode_reg = 5; - vmode = (progressive) ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf; - } - - break; - - /* NTSC or unknown */ - case 'E': - case 'J': - if (tvmode != CONF_VIDEO_NTSC) { - vmode_reg = 0; - vmode = (progressive) ? &TVNtsc480Prog : &TVNtsc480IntDf; - } - - break; - } - break; - - case 1: - vmode = &TVPal528IntDf; - vmode_reg = (vmode->viTVMode) >> 2; - break; - case 2: - progressive = (CONF_GetProgressiveScan() > 0) && VIDEO_HaveComponentCable(); - vmode = (progressive) ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf; - vmode_reg = (vmode->viTVMode) >> 2; - break; - case 3: - progressive = (CONF_GetProgressiveScan() > 0) && VIDEO_HaveComponentCable(); - vmode = (progressive) ? &TVNtsc480Prog : &TVNtsc480IntDf; - vmode_reg = (vmode->viTVMode) >> 2; - break; - case 4: - // vmode = VIDEO_GetPreferredMode(NULL); + case CONF_VIDEO_NTSC: + vmode_reg = 0; break; } - /* Set video mode register */ - *(vu32 *)0x800000CC = vmode_reg; + switch (videoselected) { + case 0: - /* Set video mode */ - if (vmode) { + /* Select video mode */ + switch (diskid[3]) { + /* PAL */ + case 'D': + case 'F': + case 'P': + case 'X': + case 'Y': + if (tvmode != CONF_VIDEO_PAL) { + vmode_reg = 5; + vmode = (progressive) ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf; + } - VIDEO_Configure(vmode); + break; - /* Setup video */ - VIDEO_SetBlack(FALSE); - VIDEO_Flush(); - VIDEO_WaitVSync(); + /* NTSC or unknown */ + case 'E': + case 'J': + if (tvmode != CONF_VIDEO_NTSC) { + vmode_reg = 0; + vmode = (progressive) ? &TVNtsc480Prog : &TVNtsc480IntDf; + } - if (vmode->viTVMode & VI_NON_INTERLACE) - VIDEO_WaitVSync(); - } + break; + } + break; + + case 1: + vmode = &TVPal528IntDf; + vmode_reg = (vmode->viTVMode) >> 2; + break; + case 2: + progressive = (CONF_GetProgressiveScan() > 0) && VIDEO_HaveComponentCable(); + vmode = (progressive) ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf; + vmode_reg = (vmode->viTVMode) >> 2; + break; + case 3: + progressive = (CONF_GetProgressiveScan() > 0) && VIDEO_HaveComponentCable(); + vmode = (progressive) ? &TVNtsc480Prog : &TVNtsc480IntDf; + vmode_reg = (vmode->viTVMode) >> 2; + break; + case 4: +// vmode = VIDEO_GetPreferredMode(NULL); + break; + } + + /* Set video mode register */ + *(vu32 *)0x800000CC = vmode_reg; + + /* Set video mode */ + if (vmode) { + + VIDEO_Configure(vmode); + + /* Setup video */ + VIDEO_SetBlack(FALSE); + VIDEO_Flush(); + VIDEO_WaitVSync(); + + if (vmode->viTVMode & VI_NON_INTERLACE) + VIDEO_WaitVSync(); + } } -void __Disc_SetTime(void) -{ - /* Extern */ - extern void settime(u64); +void __Disc_SetTime(void) { + /* Extern */ + extern void settime(u64); - /* Set proper time */ - settime(secs_to_ticks(time(NULL) - 946684800)); + /* Set proper time */ + settime(secs_to_ticks(time(NULL) - 946684800)); } -s32 __Disc_FindPartition(u64 *outbuf) -{ - u64 offset = 0, table_offset = 0; +s32 __Disc_FindPartition(u64 *outbuf) { + u64 offset = 0, table_offset = 0; - u32 cnt, nb_partitions; - s32 ret; + u32 cnt, nb_partitions; + s32 ret; - /* Read partition info */ - ret = WDVD_UnencryptedRead(buffer, 0x20, PTABLE_OFFSET); - if (ret < 0) - return ret; + /* Read partition info */ + ret = WDVD_UnencryptedRead(buffer, 0x20, PTABLE_OFFSET); + if (ret < 0) + return ret; - /* Get data */ - nb_partitions = buffer[0]; - table_offset = buffer[1] << 2; + /* Get data */ + nb_partitions = buffer[0]; + table_offset = buffer[1] << 2; - /* Read partition table */ - ret = WDVD_UnencryptedRead(buffer, 0x20, table_offset); - if (ret < 0) - return ret; + /* Read partition table */ + ret = WDVD_UnencryptedRead(buffer, 0x20, table_offset); + if (ret < 0) + return ret; - /* Find game partition */ - for (cnt = 0; cnt < nb_partitions; cnt++) { - u32 type = buffer[cnt * 2 + 1]; + /* Find game partition */ + for (cnt = 0; cnt < nb_partitions; cnt++) { + u32 type = buffer[cnt * 2 + 1]; - /* Game partition */ - if(!type) - offset = buffer[cnt * 2] << 2; - } + /* Game partition */ + if (!type) + offset = buffer[cnt * 2] << 2; + } - /* No game partition found */ - if (!offset) - return -1; + /* No game partition found */ + if (!offset) + return -1; - /* Set output buffer */ - *outbuf = offset; + /* Set output buffer */ + *outbuf = offset; - return 0; + return 0; } -s32 Disc_Init(void) -{ - /* Init DVD subsystem */ - return WDVD_Init(); +s32 Disc_Init(void) { + /* Init DVD subsystem */ + return WDVD_Init(); } -s32 Disc_Open(void) -{ - s32 ret; +s32 Disc_Open(void) { + s32 ret; - /* Reset drive */ - ret = WDVD_Reset(); - if (ret < 0) - return ret; + /* Reset drive */ + ret = WDVD_Reset(); + if (ret < 0) + return ret; - /* Read disc ID */ - return WDVD_ReadDiskId(diskid); + /* Read disc ID */ + return WDVD_ReadDiskId(diskid); } -s32 Disc_Wait(void) -{ - u32 cover = 0; - s32 ret; +s32 Disc_Wait(void) { + u32 cover = 0; + s32 ret; - /* Wait for disc */ - while (!(cover & 0x2)) { - /* Get cover status */ - ret = WDVD_GetCoverStatus(&cover); - if (ret < 0) - return ret; - } + /* Wait for disc */ + while (!(cover & 0x2)) { + /* Get cover status */ + ret = WDVD_GetCoverStatus(&cover); + if (ret < 0) + return ret; + } - return 0; + return 0; } -s32 Disc_SetUSB(u8 *id) -{ - /* Set USB mode */ - return WDVD_SetUSBMode(id); +s32 Disc_SetUSB(u8 *id) { + /* Set USB mode */ + return WDVD_SetUSBMode(id); } -s32 Disc_ReadHeader(void *outbuf) -{ - /* Read disc header */ - return WDVD_UnencryptedRead(outbuf, sizeof(struct discHdr), 0); +s32 Disc_ReadHeader(void *outbuf) { + /* Read disc header */ + return WDVD_UnencryptedRead(outbuf, sizeof(struct discHdr), 0); } -s32 Disc_IsWii(void) -{ - struct discHdr *header = (struct discHdr *)buffer; +s32 Disc_IsWii(void) { + struct discHdr *header = (struct discHdr *)buffer; - s32 ret; + s32 ret; - /* Read disc header */ - ret = Disc_ReadHeader(header); - if (ret < 0) - return ret; + /* Read disc header */ + ret = Disc_ReadHeader(header); + if (ret < 0) + return ret; - /* Check magic word */ - if (header->magic != WII_MAGIC) - return -1; + /* Check magic word */ + if (header->magic != WII_MAGIC) + return -1; - return 0; + return 0; } -s32 Disc_BootPartition(u64 offset, u8 videoselected, u8 cheat, u8 vipatch, u8 patchcountrystring, u8 error002fix, u8 alternatedol, u32 alternatedoloffset) -{ - entry_point p_entry; +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; + s32 ret; - /* Open specified partition */ - ret = WDVD_OpenPartition(offset); - if (ret < 0) - return ret; + /* Open specified partition */ + ret = WDVD_OpenPartition(offset); + if (ret < 0) + return ret; - /* Run apploader */ - ret = Apploader_Run(&p_entry, cheat, videoselected, vipatch, patchcountrystring, error002fix, alternatedol, alternatedoloffset); - if (ret < 0) - return ret; + /* Run apploader */ + ret = Apploader_Run(&p_entry, cheat, videoselected, vipatch, patchcountrystring, error002fix, alternatedol, alternatedoloffset); + if (ret < 0) + return ret; - /* Setup low memory */ - __Disc_SetLowMem(); + /* Setup low memory */ + __Disc_SetLowMem(); - /* Set an appropiate video mode */ - __Disc_SetVMode(videoselected); + /* Set an appropiate video mode */ + __Disc_SetVMode(videoselected); - /* Set time */ - __Disc_SetTime(); - - if (cheat == 1) { - /* OCARINA STUFF - FISHEARS*/ - memset(gameid, 0, 8); - memcpy(gameid, (char*)0x80000000, 6); - do_sd_code(gameid); - /* OCARINA STUFF - FISHEARS*/ - } + /* Set time */ + __Disc_SetTime(); - /* Disconnect Wiimote */ - WPAD_Flush(0); - WPAD_Disconnect(0); - WPAD_Shutdown(); + if (cheat == 1) { + /* OCARINA STUFF - FISHEARS*/ + memset(gameid, 0, 8); + memcpy(gameid, (char*)0x80000000, 6); + do_sd_code(gameid); + /* OCARINA STUFF - FISHEARS*/ + } - /* Shutdown IOS subsystems */ - SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); + /* Disconnect Wiimote */ + WPAD_Flush(0); + WPAD_Disconnect(0); + WPAD_Shutdown(); - /* Jump to entry point */ - p_entry(); + /* Shutdown IOS subsystems */ + SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); - return 0; + /* Jump to entry point */ + p_entry(); + + return 0; } -s32 Disc_WiiBoot(u8 videoselected, u8 cheat, u8 vipatch, u8 patchcountrystring, u8 error002fix, u8 alternatedol, u32 alternatedoloffset) -{ - u64 offset; - s32 ret; +s32 Disc_WiiBoot(u8 videoselected, u8 cheat, u8 vipatch, u8 patchcountrystring, u8 error002fix, u8 alternatedol, u32 alternatedoloffset) { + u64 offset; + s32 ret; - /* Find game partition offset */ - ret = __Disc_FindPartition(&offset); - if (ret < 0) - return ret; + /* Find game partition offset */ + ret = __Disc_FindPartition(&offset); + if (ret < 0) + return ret; - /* Boot partition */ - return Disc_BootPartition(offset, videoselected, cheat, vipatch, patchcountrystring, error002fix, alternatedol, alternatedoloffset); + /* Boot partition */ + return Disc_BootPartition(offset, videoselected, cheat, vipatch, patchcountrystring, error002fix, alternatedol, alternatedoloffset); +} + +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) { + case CONF_REGION_JP: + SearchPattern[0] = 0x00; + SearchPattern[1] = 0x4A; // J + SearchPattern[2] = 0x50; // P + break; + case CONF_REGION_EU: + SearchPattern[0] = 0x02; + SearchPattern[1] = 0x45; // E + SearchPattern[2] = 0x55; // U + break; + case CONF_REGION_KR: + SearchPattern[0] = 0x04; + SearchPattern[1] = 0x4B; // K + SearchPattern[2] = 0x52; // R + break; + case CONF_REGION_CN: + SearchPattern[0] = 0x05; + SearchPattern[1] = 0x43; // C + SearchPattern[2] = 0x4E; // N + break; + case CONF_REGION_US: + default: + SearchPattern[0] = 0x01; + SearchPattern[1] = 0x55; // U + SearchPattern[2] = 0x53; // S + } + + switch (diskid[3]) { + case 'J': + PatchData[1] = 0x4A; // J + PatchData[2] = 0x50; // P + break; + + case 'D': + case 'F': + case 'P': + case 'X': + case 'Y': + PatchData[1] = 0x45; // E + PatchData[2] = 0x55; // U + break; + + case 'E': + default: + PatchData[1] = 0x55; // U + PatchData[2] = 0x53; // S + } + + 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]; + Addr += 1; + *Addr = PatchData[2]; + Addr += 1; + //*Addr = PatchData[3]; + Addr += 1; + Size -= 4; + } else { + Addr += 4; + Size -= 4; + } + } } - -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) - { - case CONF_REGION_JP: - SearchPattern[0] = 0x00; - SearchPattern[1] = 0x4A; // J - SearchPattern[2] = 0x50; // P - break; - case CONF_REGION_EU: - SearchPattern[0] = 0x02; - SearchPattern[1] = 0x45; // E - SearchPattern[2] = 0x55; // U - break; - case CONF_REGION_KR: - SearchPattern[0] = 0x04; - SearchPattern[1] = 0x4B; // K - SearchPattern[2] = 0x52; // R - break; - case CONF_REGION_CN: - SearchPattern[0] = 0x05; - SearchPattern[1] = 0x43; // C - SearchPattern[2] = 0x4E; // N - break; - case CONF_REGION_US: - default: - SearchPattern[0] = 0x01; - SearchPattern[1] = 0x55; // U - SearchPattern[2] = 0x53; // S - } - - switch (diskid[3]) - { - case 'J': - PatchData[1] = 0x4A; // J - PatchData[2] = 0x50; // P - break; - - case 'D': - case 'F': - case 'P': - case 'X': - case 'Y': - PatchData[1] = 0x45; // E - PatchData[2] = 0x55; // U - break; - - case 'E': - default: - PatchData[1] = 0x55; // U - PatchData[2] = 0x53; // S - } - - 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]; - Addr += 1; - *Addr = PatchData[2]; - Addr += 1; - //*Addr = PatchData[3]; - Addr += 1; - Size -= 4; - } else - { - Addr += 4; - Size -= 4; - } - } -} diff --git a/source/usbloader/disc.h b/source/usbloader/disc.h index 5a052fce..ee1f8aed 100644 --- a/source/usbloader/disc.h +++ b/source/usbloader/disc.h @@ -1,59 +1,57 @@ -#ifndef _DISC_H_ +#ifndef _DISC_H_ #define _DISC_H_ #ifdef __cplusplus -extern "C" -{ +extern "C" { +#endif + /* Disc header structure */ + struct discHdr { + /* Game ID */ + u8 id[6]; + + /* Game version */ + u16 version; + + /* Audio streaming */ + u8 streaming; + u8 bufsize; + + /* Padding */ + u8 unused1[14]; + + /* Magic word */ + u32 magic; + + /* Padding */ + u8 unused2[4]; + + /* Game title */ + char title[64]; + + /* Encryption/Hashing */ + u8 encryption; + u8 h3_verify; + + /* Padding */ + u8 unused3[30]; + } 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); + +#ifdef __cplusplus +} #endif -/* Disc header structure */ -struct discHdr -{ - /* Game ID */ - u8 id[6]; - /* Game version */ - u16 version; - - /* Audio streaming */ - u8 streaming; - u8 bufsize; - - /* Padding */ - u8 unused1[14]; - - /* Magic word */ - u32 magic; - - /* Padding */ - u8 unused2[4]; - - /* Game title */ - char title[64]; - - /* Encryption/Hashing */ - u8 encryption; - u8 h3_verify; - - /* Padding */ - u8 unused3[30]; -} 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); - -#ifdef __cplusplus -} -#endif - -#endif +#endif diff --git a/source/usbloader/fstfile.c b/source/usbloader/fstfile.c index dda9a493..6e5ffc31 100644 --- a/source/usbloader/fstfile.c +++ b/source/usbloader/fstfile.c @@ -3,44 +3,35 @@ #include "fstfile.h" -char *fstfiles(FST_ENTRY *fst, u32 index) -{ - u32 count = fst[0].filelen; - u32 stringoffset; - if (index < count) - { - stringoffset = *(u32 *)&(fst[index]) % (256*256*256); - return (char *)((u32)fst + count*12 + stringoffset); - } else - { - return NULL; - } +char *fstfiles(FST_ENTRY *fst, u32 index) { + u32 count = fst[0].filelen; + u32 stringoffset; + if (index < count) { + stringoffset = *(u32 *)&(fst[index]) % (256*256*256); + return (char *)((u32)fst + count*12 + stringoffset); + } else { + return NULL; + } } -char *fstfilename(u32 index) -{ - FST_ENTRY *fst = (FST_ENTRY *)*(u32 *)0x80000038; - u32 count = fst[0].filelen; - u32 stringoffset; - if (index < count) - { - stringoffset = *(u32 *)&(fst[index]) % (256*256*256); - return (char *)(*(u32 *)0x80000038 + count*12 + stringoffset); - } else - { - return NULL; - } +char *fstfilename(u32 index) { + FST_ENTRY *fst = (FST_ENTRY *)*(u32 *)0x80000038; + u32 count = fst[0].filelen; + u32 stringoffset; + if (index < count) { + stringoffset = *(u32 *)&(fst[index]) % (256*256*256); + return (char *)(*(u32 *)0x80000038 + count*12 + stringoffset); + } else { + return NULL; + } } -u32 fstfileoffset(u32 index) -{ - FST_ENTRY *fst = (FST_ENTRY *)*(u32 *)0x80000038; - u32 count = fst[0].filelen; - if (index < count) - { - return fst[index].fileoffset; - } else - { - return 0; - } +u32 fstfileoffset(u32 index) { + FST_ENTRY *fst = (FST_ENTRY *)*(u32 *)0x80000038; + u32 count = fst[0].filelen; + if (index < count) { + return fst[index].fileoffset; + } else { + return 0; + } } diff --git a/source/usbloader/fstfile.h b/source/usbloader/fstfile.h index 0079dc6a..11e0ee18 100644 --- a/source/usbloader/fstfile.h +++ b/source/usbloader/fstfile.h @@ -2,20 +2,19 @@ #define _FSTFILE_H_ #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif -typedef struct { - u8 filetype; - char name_offset[3]; - u32 fileoffset; - u32 filelen; -} __attribute__((packed)) FST_ENTRY; + typedef struct { + u8 filetype; + char name_offset[3]; + u32 fileoffset; + u32 filelen; + } __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 } diff --git a/source/usbloader/getentries.cpp b/source/usbloader/getentries.cpp index 4cd4dcf4..bdcd48cd 100644 --- a/source/usbloader/getentries.cpp +++ b/source/usbloader/getentries.cpp @@ -17,159 +17,152 @@ s32 __Menu_EntryCmp(const void *a, const void *b) { - struct discHdr *hdr1 = (struct discHdr *)a; + struct discHdr *hdr1 = (struct discHdr *)a; - struct discHdr *hdr2 = (struct discHdr *)b; + struct discHdr *hdr2 = (struct discHdr *)b; - /* Compare strings */ + /* Compare strings */ - return stricmp(get_title(hdr1), get_title(hdr2)); + return stricmp(get_title(hdr1), get_title(hdr2)); } -s32 __Menu_EntryCmpCount(const void *a, const void *b) -{ - s32 ret; +s32 __Menu_EntryCmpCount(const void *a, const void *b) { + s32 ret; - struct discHdr *hdr1 = (struct discHdr *)a; + struct discHdr *hdr1 = (struct discHdr *)a; - struct discHdr *hdr2 = (struct discHdr *)b; + struct discHdr *hdr2 = (struct discHdr *)b; - /* Compare Play Count */ - u16 count1 = 0; - u16 count2 = 0; - struct Game_NUM* game_num1 = CFG_get_game_num(hdr1->id); - struct Game_NUM* game_num2 = CFG_get_game_num(hdr2->id); + /* Compare Play Count */ + u16 count1 = 0; + u16 count2 = 0; + struct Game_NUM* game_num1 = CFG_get_game_num(hdr1->id); + struct Game_NUM* game_num2 = CFG_get_game_num(hdr2->id); - if (game_num1) count1 = game_num1->count; - if (game_num2) count2 = game_num2->count; + if (game_num1) count1 = game_num1->count; + if (game_num2) count2 = game_num2->count; - ret = (s32) (count2-count1); - if (ret == 0) return stricmp(get_title(hdr1), get_title(hdr2)); + ret = (s32) (count2-count1); + if (ret == 0) return stricmp(get_title(hdr1), get_title(hdr2)); - return ret; + return ret; } /**************************************************************************** * Get Gamelist ***************************************************************************/ -int __Menu_GetEntries(int t) -{ - struct discHdr *buffer = NULL; - struct discHdr *buffer2 = NULL; - struct discHdr *header = NULL; +int __Menu_GetEntries(int t) { + struct discHdr *buffer = NULL; + struct discHdr *buffer2 = NULL; + struct discHdr *header = NULL; - u32 cnt, len; - s32 ret; + u32 cnt, len; + s32 ret; - /* Get list length */ - ret = WBFS_GetCount(&cnt); - if (ret < 0) - return ret; + /* Get list length */ + ret = WBFS_GetCount(&cnt); + if (ret < 0) + return ret; - /* Buffer length */ - len = sizeof(struct discHdr) * cnt; + /* Buffer length */ + len = sizeof(struct discHdr) * cnt; - /* Allocate memory */ - buffer = (struct discHdr *)memalign(32, len); - if (!buffer) - return -1; + /* Allocate memory */ + buffer = (struct discHdr *)memalign(32, len); + if (!buffer) + return -1; - /* Clear buffer */ - memset(buffer, 0, len); + /* Clear buffer */ + memset(buffer, 0, len); - /* Get header list */ - ret = WBFS_GetHeaders(buffer, cnt, sizeof(struct discHdr)); - if (ret < 0) { - if(buffer) free(buffer); - return ret; - } + /* Get header list */ + ret = WBFS_GetHeaders(buffer, cnt, sizeof(struct discHdr)); + if (ret < 0) { + if (buffer) free(buffer); + return ret; + } - /* Filters */ - if (Settings.fave && t==0) { - u32 cnt2 = 0; + /* Filters */ + if (Settings.fave && t==0) { + u32 cnt2 = 0; - for (u32 i = 0; i < cnt; i++) - { - header = &buffer[i]; - u8 favorite = 0; - struct Game_NUM* game_num = CFG_get_game_num(header->id); - if (game_num) { - favorite = game_num->favorite; - } - if (favorite==1) { - buffer2 = (discHdr *) realloc(buffer2, (cnt2+1) * sizeof(struct discHdr)); - if (!buffer2) - { - free(buffer); - return -1; - } + for (u32 i = 0; i < cnt; i++) { + header = &buffer[i]; + u8 favorite = 0; + struct Game_NUM* game_num = CFG_get_game_num(header->id); + if (game_num) { + favorite = game_num->favorite; + } + if (favorite==1) { + buffer2 = (discHdr *) realloc(buffer2, (cnt2+1) * sizeof(struct discHdr)); + if (!buffer2) { + free(buffer); + return -1; + } - memcpy((buffer2 + cnt2), (buffer + i), sizeof(struct discHdr)); - cnt2++; - } - } - if (buffer2) { - free(buffer); - buffer = buffer2; - buffer2 = NULL; - } else { - memset(buffer, 0, len); - } - cnt = cnt2; - } + memcpy((buffer2 + cnt2), (buffer + i), sizeof(struct discHdr)); + cnt2++; + } + } + if (buffer2) { + free(buffer); + buffer = buffer2; + buffer2 = NULL; + } else { + memset(buffer, 0, len); + } + cnt = cnt2; + } - if (Settings.parentalcontrol && !Settings.godmode && t==0) { - u32 cnt2 = 0; + if (Settings.parentalcontrol && !Settings.godmode && t==0) { + u32 cnt2 = 0; - 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) - { - free(buffer); - return -1; - } + 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) { + free(buffer); + return -1; + } - memcpy((buffer2 + cnt2), (buffer + i), sizeof(struct discHdr)); - cnt2++; - } - } - if (buffer2) { - free(buffer); - buffer = buffer2; - buffer2 = NULL; - } else { - memset(buffer, 0, len); - } - cnt = cnt2; - } + memcpy((buffer2 + cnt2), (buffer + i), sizeof(struct discHdr)); + cnt2++; + } + } + if (buffer2) { + free(buffer); + buffer = buffer2; + buffer2 = NULL; + } else { + memset(buffer, 0, len); + } + cnt = cnt2; + } - if (Settings.sort==pcount) { - qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpCount); - } - else { - qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp); - } + if (Settings.sort==pcount) { + qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpCount); + } else { + qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp); + } - /* Free memory */ - if (gameList) - free(gameList); + /* Free memory */ + if (gameList) + free(gameList); - /* Set values */ - gameList = buffer; - buffer = NULL; - gameCnt = cnt; + /* Set values */ + gameList = buffer; + buffer = NULL; + gameCnt = cnt; - /* Reset variables */ - gameSelected = gameStart = 0; + /* Reset variables */ + gameSelected = gameStart = 0; - return 0; + return 0; } diff --git a/source/usbloader/getentries.h b/source/usbloader/getentries.h index 4f7b8a92..36909fdd 100644 --- a/source/usbloader/getentries.h +++ b/source/usbloader/getentries.h @@ -9,9 +9,9 @@ #define _GETENTRIES_H_ //! param t -//! make this 1 if you want the function to ignore the rules +//! make this 1 if you want the function to ignore the rules //! (settings and parental control) when making the game list. -//! +//! int __Menu_GetEntries(int t=0); #endif diff --git a/source/usbloader/partition.c b/source/usbloader/partition.c index 32dc5711..99bb1db1 100644 --- a/source/usbloader/partition.c +++ b/source/usbloader/partition.c @@ -8,44 +8,43 @@ /* 'partition table' structure */ typedef struct { - /* Zero bytes */ - u8 padding[446]; + /* Zero bytes */ + u8 padding[446]; - /* Partition table entries */ - partitionEntry entries[MAX_PARTITIONS]; + /* Partition table entries */ + partitionEntry entries[MAX_PARTITIONS]; } ATTRIBUTE_PACKED partitionTable; -s32 Partition_GetEntries(partitionEntry *outbuf, u32 *outval) -{ - static partitionTable table ATTRIBUTE_ALIGN(32); +s32 Partition_GetEntries(partitionEntry *outbuf, u32 *outval) { + static partitionTable table ATTRIBUTE_ALIGN(32); - u32 cnt, sector_size; - s32 ret; + u32 cnt, sector_size; + s32 ret; - /* Get sector size */ - ret = USBStorage_GetCapacity(§or_size); - if (ret < 0) - return ret; + /* Get sector size */ + ret = USBStorage_GetCapacity(§or_size); + if (ret < 0) + return ret; - /* Read partition table */ - ret = USBStorage_ReadSectors(0, 1, &table); - if (ret < 0) - return ret; + /* Read partition table */ + ret = USBStorage_ReadSectors(0, 1, &table); + if (ret < 0) + return ret; - /* Swap endianess */ - for (cnt = 0; cnt < 4; cnt++) { - partitionEntry *entry = &table.entries[cnt]; + /* Swap endianess */ + for (cnt = 0; cnt < 4; cnt++) { + partitionEntry *entry = &table.entries[cnt]; - entry->sector = swap32(entry->sector); - entry->size = swap32(entry->size); - } + entry->sector = swap32(entry->sector); + entry->size = swap32(entry->size); + } - /* Set partition entries */ - memcpy(outbuf, table.entries, sizeof(table.entries)); + /* Set partition entries */ + memcpy(outbuf, table.entries, sizeof(table.entries)); - /* Set sector size */ - *outval = sector_size; + /* Set sector size */ + *outval = sector_size; - return 0; + return 0; } diff --git a/source/usbloader/partition.h b/source/usbloader/partition.h index cc8807de..f7716419 100644 --- a/source/usbloader/partition.h +++ b/source/usbloader/partition.h @@ -1,40 +1,39 @@ -#ifndef _PARTITION_H_ +#ifndef _PARTITION_H_ #define _PARTITION_H_ #ifdef __cplusplus -extern "C" -{ -#endif - -/* 'partition entry' structure */ -typedef struct { - /* Boot indicator */ - u8 boot; - - /* Starting CHS */ - u8 start[3]; - - /* Partition type */ - u8 type; - - /* Ending CHS */ - u8 end[3]; - - /* Partition sector */ - u32 sector; - - /* Partition size */ - u32 size; -} ATTRIBUTE_PACKED partitionEntry; - -/* Constants */ -#define MAX_PARTITIONS 4 - -/* Prototypes */ -s32 Partition_GetEntries(partitionEntry *, u32 *); - -#ifdef __cplusplus -} +extern "C" { #endif + /* 'partition entry' structure */ + typedef struct { + /* Boot indicator */ + u8 boot; + + /* Starting CHS */ + u8 start[3]; + + /* Partition type */ + u8 type; + + /* Ending CHS */ + u8 end[3]; + + /* Partition sector */ + u32 sector; + + /* Partition size */ + u32 size; + } ATTRIBUTE_PACKED partitionEntry; + + /* Constants */ +#define MAX_PARTITIONS 4 + + /* Prototypes */ + s32 Partition_GetEntries(partitionEntry *, u32 *); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/source/usbloader/sdhc.c b/source/usbloader/sdhc.c index 9fc27701..a4fd4c45 100644 --- a/source/usbloader/sdhc.c +++ b/source/usbloader/sdhc.c @@ -20,140 +20,134 @@ static s32 hid = -1, fd = -1; static u32 sector_size = SDHC_SECTOR_SIZE; -bool SDHC_Init(void) -{ - s32 ret; - - /* Already open */ - if (fd > 0) - return true; +bool SDHC_Init(void) { + s32 ret; - /* Create heap */ - if (hid < 0) { - hid = iosCreateHeap(SDHC_HEAPSIZE); - if (hid < 0) - goto err; - } + /* Already open */ + if (fd > 0) + return true; - /* Open SDHC device */ - fd = IOS_Open(fs, 0); - if (fd < 0) - goto err; + /* Create heap */ + if (hid < 0) { + hid = iosCreateHeap(SDHC_HEAPSIZE); + if (hid < 0) + goto err; + } - /* Initialize SDHC */ - ret = IOS_IoctlvFormat(hid, fd, IOCTL_SDHC_INIT, ":"); - if (ret) - goto err; + /* Open SDHC device */ + fd = IOS_Open(fs, 0); + if (fd < 0) + goto err; - return true; + /* Initialize SDHC */ + ret = IOS_IoctlvFormat(hid, fd, IOCTL_SDHC_INIT, ":"); + if (ret) + goto err; + + return true; err: - /* Close SDHC device */ - if (fd > 0) { - IOS_Close(fd); - fd = -1; - } + /* Close SDHC device */ + if (fd > 0) { + IOS_Close(fd); + fd = -1; + } - return false; + return false; } -bool SDHC_Close(void) -{ - /* Close SDHC device */ - if (fd > 0) { - IOS_Close(fd); - fd = -1; - } +bool SDHC_Close(void) { + /* Close SDHC device */ + if (fd > 0) { + IOS_Close(fd); + fd = -1; + } - return true; + return true; } -bool SDHC_IsInserted(void) -{ - s32 ret; +bool SDHC_IsInserted(void) { + s32 ret; - /* Check if SD card is inserted */ - ret = IOS_IoctlvFormat(hid, fd, IOCTL_SDHC_ISINSERTED, ":"); + /* Check if SD card is inserted */ + ret = IOS_IoctlvFormat(hid, fd, IOCTL_SDHC_ISINSERTED, ":"); - return (!ret) ? true : false; + return (!ret) ? true : false; } -bool SDHC_ReadSectors(u32 sector, u32 count, void *buffer) -{ - void *buf = (void *)buffer; - u32 len = (sector_size * count); +bool SDHC_ReadSectors(u32 sector, u32 count, void *buffer) { + void *buf = (void *)buffer; + u32 len = (sector_size * count); - s32 ret; + s32 ret; - /* Device not opened */ - if (fd < 0) - return false; + /* Device not opened */ + if (fd < 0) + return false; - /* Buffer not aligned */ - if ((u32)buffer & 0x1F) { - /* Allocate memory */ - buf = iosAlloc(hid, len); - if (!buf) - return false; - } + /* Buffer not aligned */ + if ((u32)buffer & 0x1F) { + /* Allocate memory */ + buf = iosAlloc(hid, len); + if (!buf) + return false; + } - /* Read data */ - ret = IOS_IoctlvFormat(hid, fd, IOCTL_SDHC_READ, "ii:d", sector, count, buf, len); + /* Read data */ + ret = IOS_IoctlvFormat(hid, fd, IOCTL_SDHC_READ, "ii:d", sector, count, buf, len); - /* Copy data */ - if (buf != buffer) { - memcpy(buffer, buf, len); - iosFree(hid, buf); - } + /* Copy data */ + if (buf != buffer) { + memcpy(buffer, buf, len); + iosFree(hid, buf); + } - return (!ret) ? true : false; + return (!ret) ? true : false; } -bool SDHC_WriteSectors(u32 sector, u32 count, void *buffer) -{ - void *buf = (void *)buffer; - u32 len = (sector_size * count); +bool SDHC_WriteSectors(u32 sector, u32 count, void *buffer) { + void *buf = (void *)buffer; + u32 len = (sector_size * count); - s32 ret; + s32 ret; - /* Device not opened */ - if (fd < 0) - return false; + /* Device not opened */ + if (fd < 0) + return false; - /* Buffer not aligned */ - if ((u32)buffer & 0x1F) { - /* Allocate memory */ - buf = iosAlloc(hid, len); - if (!buf) - return false; + /* Buffer not aligned */ + if ((u32)buffer & 0x1F) { + /* Allocate memory */ + buf = iosAlloc(hid, len); + if (!buf) + return false; - /* Copy data */ - memcpy(buf, buffer, len); - } + /* Copy data */ + memcpy(buf, buffer, len); + } - /* Read data */ - ret = IOS_IoctlvFormat(hid, fd, IOCTL_SDHC_WRITE, "ii:d", sector, count, buf, len); + /* Read data */ + ret = IOS_IoctlvFormat(hid, fd, IOCTL_SDHC_WRITE, "ii:d", sector, count, buf, len); - /* Free memory */ - if (buf != buffer) - iosFree(hid, buf); + /* Free memory */ + if (buf != buffer) + iosFree(hid, buf); - return (!ret) ? true : false; + return (!ret) ? true : false; } -bool SDHC_ClearStatus(void) -{ - return true; +bool SDHC_ClearStatus(void) { + return true; } const DISC_INTERFACE __io_sdhc = { - DEVICE_TYPE_WII_SD, - FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_WII_SD, - (FN_MEDIUM_STARTUP)&SDHC_Init, - (FN_MEDIUM_ISINSERTED)&SDHC_IsInserted, - (FN_MEDIUM_READSECTORS)&SDHC_ReadSectors, - (FN_MEDIUM_WRITESECTORS)&SDHC_WriteSectors, - (FN_MEDIUM_CLEARSTATUS)&SDHC_ClearStatus, - (FN_MEDIUM_SHUTDOWN)&SDHC_Close + DEVICE_TYPE_WII_SD, + FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_WII_SD, + (FN_MEDIUM_STARTUP)&SDHC_Init, + (FN_MEDIUM_ISINSERTED)&SDHC_IsInserted, + (FN_MEDIUM_READSECTORS)&SDHC_ReadSectors, + (FN_MEDIUM_WRITESECTORS)&SDHC_WriteSectors, + (FN_MEDIUM_CLEARSTATUS)&SDHC_ClearStatus, + (FN_MEDIUM_SHUTDOWN)&SDHC_Close }; diff --git a/source/usbloader/sdhc.h b/source/usbloader/sdhc.h index 9f6f3c56..ceec4e7d 100644 --- a/source/usbloader/sdhc.h +++ b/source/usbloader/sdhc.h @@ -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 } diff --git a/source/usbloader/usbstorage.c b/source/usbloader/usbstorage.c index 97c6a032..4cd94106 100644 --- a/source/usbloader/usbstorage.c +++ b/source/usbloader/usbstorage.c @@ -38,8 +38,8 @@ distribution. #define USB_IOCTL_UMS_READ_SECTORS (UMS_BASE+0x3) #define USB_IOCTL_UMS_WRITE_SECTORS (UMS_BASE+0x4) #define USB_IOCTL_UMS_READ_STRESS (UMS_BASE+0x5) -#define USB_IOCTL_UMS_SET_VERBOSE (UMS_BASE+0x6) -#define USB_IOCTL_UMS_UNMOUNT (UMS_BASE+0x10) +#define USB_IOCTL_UMS_SET_VERBOSE (UMS_BASE+0x6) +#define USB_IOCTL_UMS_UNMOUNT (UMS_BASE+0x10) #define USB_IOCTL_UMS_WATCHDOG (UMS_BASE+0x80) #define UMS_HEAPSIZE 0x10000 @@ -51,249 +51,232 @@ static s32 hid = -1, fd = -1; static u32 sector_size; -inline s32 __USBStorage_isMEM2Buffer(const void *buffer) -{ - u32 high_addr = ((u32)buffer) >> 24; +inline s32 __USBStorage_isMEM2Buffer(const void *buffer) { + u32 high_addr = ((u32)buffer) >> 24; - return (high_addr == 0x90) || (high_addr == 0xD0); + return (high_addr == 0x90) || (high_addr == 0xD0); } -s32 USBStorage_GetCapacity(u32 *_sector_size) -{ - if (fd > 0) { - s32 ret; +s32 USBStorage_GetCapacity(u32 *_sector_size) { + if (fd > 0) { + s32 ret; - ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_GET_CAPACITY, ":i", §or_size); + ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_GET_CAPACITY, ":i", §or_size); - if (ret && _sector_size) - *_sector_size = sector_size; + if (ret && _sector_size) + *_sector_size = sector_size; - return ret; - } + return ret; + } - return IPC_ENOENT; + return IPC_ENOENT; } -s32 USBStorage_Init(void) -{ - s32 ret; +s32 USBStorage_Init(void) { + s32 ret; - /* Already open */ - if (fd > 0) - return 0; + /* Already open */ + if (fd > 0) + return 0; - /* Create heap */ - if (hid < 0) { - hid = iosCreateHeap(UMS_HEAPSIZE); - if (hid < 0) - return IPC_ENOMEM; - } + /* Create heap */ + if (hid < 0) { + hid = iosCreateHeap(UMS_HEAPSIZE); + if (hid < 0) + return IPC_ENOMEM; + } - /* Open USB device */ - fd = IOS_Open(fs, 0); - if (fd < 0) - return fd; + /* Open USB device */ + fd = IOS_Open(fs, 0); + if (fd < 0) + return fd; - /* Initialize USB storage */ - ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_INIT, ":"); - if(ret<0) goto err; + /* Initialize USB storage */ + ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_INIT, ":"); + if (ret<0) goto err; - /* Get device capacity */ - ret = USBStorage_GetCapacity(NULL); - if (!ret) - goto err; + /* Get device capacity */ + ret = USBStorage_GetCapacity(NULL); + if (!ret) + goto err; - return 0; + return 0; err: - /* Close USB device */ - if (fd > 0) { - IOS_Close(fd); - fd = -1; - } + /* Close USB device */ + if (fd > 0) { + IOS_Close(fd); + fd = -1; + } - return -1; -} - -/** Hermes **/ -s32 USBStorage_Watchdog(u32 on_off) -{ - if (fd >= 0) { - s32 ret; - - ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_WATCHDOG, "i:", on_off); - - return ret; - } - - return IPC_ENOENT; -} - -s32 USBStorage_Umount(void) -{ - if (fd >= 0) { - s32 ret; - ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_UNMOUNT, ":"); - return ret; - } - - return IPC_ENOENT; -} - -void USBStorage_Deinit(void) -{ - /* Close USB device */ - if (fd > 0) { - IOS_Close(fd); - fd = -1; - } -} - -s32 USBStorage_ReadSectors(u32 sector, u32 numSectors, void *buffer) -{ - void *buf = (void *)buffer; - u32 len = (sector_size * numSectors); - - s32 ret; - - /* Device not opened */ - if (fd < 0) - return fd; - - /* MEM1 buffer */ - if (!__USBStorage_isMEM2Buffer(buffer)) { - /* Allocate memory */ - buf = iosAlloc(hid, len); - if (!buf) - return IPC_ENOMEM; - } - - /* Read data */ - ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_READ_SECTORS, "ii:d", sector, numSectors, buf, len); - - /* Copy data */ - if (buf != buffer) { - memcpy(buffer, buf, len); - iosFree(hid, buf); - } - - return ret; + return -1; } -s32 USBStorage_WriteSectors(u32 sector, u32 numSectors, const void *buffer) -{ - void *buf = (void *)buffer; - u32 len = (sector_size * numSectors); +/** Hermes **/ +s32 USBStorage_Watchdog(u32 on_off) { + if (fd >= 0) { + s32 ret; - s32 ret; + ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_WATCHDOG, "i:", on_off); - /* Device not opened */ - if (fd < 0) - return fd; + return ret; + } - /* MEM1 buffer */ - if (!__USBStorage_isMEM2Buffer(buffer)) { - /* Allocate memory */ - buf = iosAlloc(hid, len); - if (!buf) - return IPC_ENOMEM; + return IPC_ENOENT; +} - /* Copy data */ - memcpy(buf, buffer, len); - } +s32 USBStorage_Umount(void) { + if (fd >= 0) { + s32 ret; + ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_UNMOUNT, ":"); + return ret; + } - /* Write data */ - ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_WRITE_SECTORS, "ii:d", sector, numSectors, buf, len); + return IPC_ENOENT; +} - /* Free memory */ - if (buf != buffer) - iosFree(hid, buf); +void USBStorage_Deinit(void) { + /* Close USB device */ + if (fd > 0) { + IOS_Close(fd); + fd = -1; + } +} - return ret; +s32 USBStorage_ReadSectors(u32 sector, u32 numSectors, void *buffer) { + void *buf = (void *)buffer; + u32 len = (sector_size * numSectors); + + s32 ret; + + /* Device not opened */ + if (fd < 0) + return fd; + + /* MEM1 buffer */ + if (!__USBStorage_isMEM2Buffer(buffer)) { + /* Allocate memory */ + buf = iosAlloc(hid, len); + if (!buf) + return IPC_ENOMEM; + } + + /* Read data */ + ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_READ_SECTORS, "ii:d", sector, numSectors, buf, len); + + /* Copy data */ + if (buf != buffer) { + memcpy(buffer, buf, len); + iosFree(hid, buf); + } + + return ret; +} + +s32 USBStorage_WriteSectors(u32 sector, u32 numSectors, const void *buffer) { + void *buf = (void *)buffer; + u32 len = (sector_size * numSectors); + + s32 ret; + + /* Device not opened */ + if (fd < 0) + return fd; + + /* MEM1 buffer */ + if (!__USBStorage_isMEM2Buffer(buffer)) { + /* Allocate memory */ + buf = iosAlloc(hid, len); + if (!buf) + return IPC_ENOMEM; + + /* Copy data */ + memcpy(buf, buffer, len); + } + + /* Write data */ + ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_WRITE_SECTORS, "ii:d", sector, numSectors, buf, len); + + /* Free memory */ + if (buf != buffer) + iosFree(hid, buf); + + return ret; } #define DEVICE_TYPE_WII_UMS (('W'<<24)|('U'<<16)|('M'<<8)|'S') -bool umsio_Startup() -{ - return USBStorage_Init() == 0; +bool umsio_Startup() { + return USBStorage_Init() == 0; } -bool umsio_IsInserted() -{ - return true; // allways true +bool umsio_IsInserted() { + return true; // allways true } -bool umsio_ReadSectors(sec_t sector, sec_t numSectors, u8 *buffer) -{ - u32 cnt = 0; - s32 ret; - /* Do reads */ - while (cnt < numSectors) - { - u32 sectors = (numSectors - cnt); +bool umsio_ReadSectors(sec_t sector, sec_t numSectors, u8 *buffer) { + u32 cnt = 0; + s32 ret; + /* Do reads */ + while (cnt < numSectors) { + u32 sectors = (numSectors - cnt); - /* Read sectors is too big */ - if (sectors > 32) - sectors = 32; + /* Read sectors is too big */ + if (sectors > 32) + sectors = 32; - /* USB read */ - ret = USBStorage_ReadSectors(sector + cnt, sectors, &buffer[cnt*512]); - if (ret < 0) - return false; + /* USB read */ + ret = USBStorage_ReadSectors(sector + cnt, sectors, &buffer[cnt*512]); + if (ret < 0) + return false; - /* Increment counter */ - cnt += sectors; - } + /* Increment counter */ + cnt += sectors; + } - return true; + return true; } -bool umsio_WriteSectors(sec_t sector, sec_t numSectors, const u8* buffer) -{ - u32 cnt = 0; - s32 ret; +bool umsio_WriteSectors(sec_t sector, sec_t numSectors, const u8* buffer) { + u32 cnt = 0; + s32 ret; - /* Do writes */ - while (cnt < numSectors) - { - u32 sectors = (numSectors - cnt); + /* Do writes */ + while (cnt < numSectors) { + u32 sectors = (numSectors - cnt); - /* Write sectors is too big */ - if (sectors > 32) - sectors = 32; + /* Write sectors is too big */ + if (sectors > 32) + sectors = 32; - /* USB write */ - ret = USBStorage_WriteSectors(sector + cnt, sectors, &buffer[cnt * 512]); - if (ret < 0) - return false; + /* USB write */ + ret = USBStorage_WriteSectors(sector + cnt, sectors, &buffer[cnt * 512]); + if (ret < 0) + return false; - /* Increment counter */ - cnt += sectors; - } + /* Increment counter */ + cnt += sectors; + } - return true; + return true; } -bool umsio_ClearStatus(void) -{ - return true; +bool umsio_ClearStatus(void) { + return true; } -bool umsio_Shutdown() -{ - USBStorage_Deinit(); - return true; +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, - (FN_MEDIUM_ISINSERTED)&umsio_IsInserted, - (FN_MEDIUM_READSECTORS)&umsio_ReadSectors, - (FN_MEDIUM_WRITESECTORS)&umsio_WriteSectors, - (FN_MEDIUM_CLEARSTATUS)&umsio_ClearStatus, - (FN_MEDIUM_SHUTDOWN)&umsio_Shutdown +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, + (FN_MEDIUM_CLEARSTATUS)&umsio_ClearStatus, + (FN_MEDIUM_SHUTDOWN)&umsio_Shutdown }; diff --git a/source/usbloader/usbstorage.h b/source/usbloader/usbstorage.h index 939e1b05..6326be91 100644 --- a/source/usbloader/usbstorage.h +++ b/source/usbloader/usbstorage.h @@ -1,20 +1,19 @@ -#ifndef _USBSTORAGE_H_ +#ifndef _USBSTORAGE_H_ #define _USBSTORAGE_H_ #ifdef __cplusplus -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; -#ifdef __cplusplus -} +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; +#ifdef __cplusplus +} +#endif #endif diff --git a/source/usbloader/utils.c b/source/usbloader/utils.c index a29f37e3..5e28c2f2 100644 --- a/source/usbloader/utils.c +++ b/source/usbloader/utils.c @@ -2,7 +2,6 @@ #include -u32 swap32(u32 x) -{ - return (x >> 24) | ((x << 8) & 0x00FF0000UL) | ((x >> 8) & 0x0000FF00UL) | (x << 24); +u32 swap32(u32 x) { + return (x >> 24) | ((x << 8) & 0x00FF0000UL) | ((x >> 8) & 0x0000FF00UL) | (x << 24); } diff --git a/source/usbloader/wbfs.c b/source/usbloader/wbfs.c index 622010d8..673992d0 100644 --- a/source/usbloader/wbfs.c +++ b/source/usbloader/wbfs.c @@ -9,8 +9,8 @@ #include "utils.h" #include "video.h" #include "wdvd.h" -#include "wbfs.h" - +#include "wbfs.h" + #include "libwbfs/libwbfs.h" /* Constants */ @@ -26,216 +26,205 @@ static s32 done = -1, total = -1; /* Variables */ static u32 nb_sectors, sector_size; -static void WBFS_Spinner(s32 x, s32 max) -{ - done = x; - total = max; -} - -void GetProgressValue(s32 * d, s32 * m) -{ - *d = done; - *m = total; -} - -wbfs_t *GetHddInfo(void) -{ - return hdd; +static void WBFS_Spinner(s32 x, s32 max) { + done = x; + total = max; } -s32 __WBFS_ReadDVD(void *fp, u32 lba, u32 len, void *iobuf) -{ - void *buffer = NULL; +void GetProgressValue(s32 * d, s32 * m) { + *d = done; + *m = total; +} - u64 offset; - u32 mod, size; - s32 ret; +wbfs_t *GetHddInfo(void) { + return hdd; +} - /* Calculate offset */ - offset = ((u64)lba) << 2; +s32 __WBFS_ReadDVD(void *fp, u32 lba, u32 len, void *iobuf) { + void *buffer = NULL; - /* Calcualte sizes */ - mod = len % 32; - size = len - mod; + u64 offset; + u32 mod, size; + s32 ret; - /* Read aligned data */ - if (size) { - ret = WDVD_UnencryptedRead(iobuf, size, offset); - if (ret < 0) - goto out; - } + /* Calculate offset */ + offset = ((u64)lba) << 2; - /* Read non-aligned data */ - if (mod) { - /* Allocate memory */ - buffer = memalign(32, 0x20); - if (!buffer) - return -1; + /* Calcualte sizes */ + mod = len % 32; + size = len - mod; - /* Read data */ - ret = WDVD_UnencryptedRead(buffer, 0x20, offset + size); - if (ret < 0) - goto out; + /* Read aligned data */ + if (size) { + ret = WDVD_UnencryptedRead(iobuf, size, offset); + if (ret < 0) + goto out; + } - /* Copy data */ - memcpy(iobuf + size, buffer, mod); - } + /* Read non-aligned data */ + if (mod) { + /* Allocate memory */ + buffer = memalign(32, 0x20); + if (!buffer) + return -1; - /* Success */ - ret = 0; + /* Read data */ + ret = WDVD_UnencryptedRead(buffer, 0x20, offset + size); + if (ret < 0) + goto out; + + /* Copy data */ + memcpy(iobuf + size, buffer, mod); + } + + /* Success */ + ret = 0; out: - /* Free memory */ - if (buffer) - free(buffer); + /* Free memory */ + if (buffer) + free(buffer); - return ret; + return ret; } -s32 __WBFS_ReadUSB(void *fp, u32 lba, u32 count, void *iobuf) -{ - u32 cnt = 0; - s32 ret; +s32 __WBFS_ReadUSB(void *fp, u32 lba, u32 count, void *iobuf) { + u32 cnt = 0; + s32 ret; - /* Do reads */ - while (cnt < count) { - void *ptr = ((u8 *)iobuf) + (cnt * sector_size); - u32 sectors = (count - cnt); + /* Do reads */ + while (cnt < count) { + void *ptr = ((u8 *)iobuf) + (cnt * sector_size); + u32 sectors = (count - cnt); - /* Read sectors is too big */ - if (sectors > MAX_NB_SECTORS) - sectors = MAX_NB_SECTORS; + /* Read sectors is too big */ + if (sectors > MAX_NB_SECTORS) + sectors = MAX_NB_SECTORS; - /* USB read */ - ret = USBStorage_ReadSectors(lba + cnt, sectors, ptr); - if (ret < 0) - return ret; + /* USB read */ + ret = USBStorage_ReadSectors(lba + cnt, sectors, ptr); + if (ret < 0) + return ret; - /* Increment counter */ - cnt += sectors; - } + /* Increment counter */ + cnt += sectors; + } - return 0; + return 0; } -s32 __WBFS_WriteUSB(void *fp, u32 lba, u32 count, void *iobuf) -{ - u32 cnt = 0; - s32 ret; +s32 __WBFS_WriteUSB(void *fp, u32 lba, u32 count, void *iobuf) { + u32 cnt = 0; + s32 ret; - /* Do writes */ - while (cnt < count) { - void *ptr = ((u8 *)iobuf) + (cnt * sector_size); - u32 sectors = (count - cnt); + /* Do writes */ + while (cnt < count) { + void *ptr = ((u8 *)iobuf) + (cnt * sector_size); + u32 sectors = (count - cnt); - /* Write sectors is too big */ - if (sectors > MAX_NB_SECTORS) - sectors = MAX_NB_SECTORS; + /* Write sectors is too big */ + if (sectors > MAX_NB_SECTORS) + sectors = MAX_NB_SECTORS; - /* USB write */ - ret = USBStorage_WriteSectors(lba + cnt, sectors, ptr); - if (ret < 0) - return ret; + /* USB write */ + ret = USBStorage_WriteSectors(lba + cnt, sectors, ptr); + if (ret < 0) + return ret; - /* Increment counter */ - cnt += sectors; - } + /* Increment counter */ + cnt += sectors; + } - return 0; + return 0; } -s32 __WBFS_ReadSDHC(void *fp, u32 lba, u32 count, void *iobuf) -{ - u32 cnt = 0; - s32 ret; +s32 __WBFS_ReadSDHC(void *fp, u32 lba, u32 count, void *iobuf) { + u32 cnt = 0; + s32 ret; - /* Do reads */ - while (cnt < count) { - void *ptr = ((u8 *)iobuf) + (cnt * sector_size); - u32 sectors = (count - cnt); + /* Do reads */ + while (cnt < count) { + void *ptr = ((u8 *)iobuf) + (cnt * sector_size); + u32 sectors = (count - cnt); - /* Read sectors is too big */ - if (sectors > MAX_NB_SECTORS) - sectors = MAX_NB_SECTORS; + /* Read sectors is too big */ + if (sectors > MAX_NB_SECTORS) + sectors = MAX_NB_SECTORS; - /* SDHC read */ - ret = SDHC_ReadSectors(lba + cnt, sectors, ptr); - if (!ret) - return -1; + /* SDHC read */ + ret = SDHC_ReadSectors(lba + cnt, sectors, ptr); + if (!ret) + return -1; - /* Increment counter */ - cnt += sectors; - } + /* Increment counter */ + cnt += sectors; + } - return 0; + return 0; } -s32 __WBFS_WriteSDHC(void *fp, u32 lba, u32 count, void *iobuf) -{ - u32 cnt = 0; - s32 ret; +s32 __WBFS_WriteSDHC(void *fp, u32 lba, u32 count, void *iobuf) { + u32 cnt = 0; + s32 ret; - /* Do writes */ - while (cnt < count) { - void *ptr = ((u8 *)iobuf) + (cnt * sector_size); - u32 sectors = (count - cnt); + /* Do writes */ + while (cnt < count) { + void *ptr = ((u8 *)iobuf) + (cnt * sector_size); + u32 sectors = (count - cnt); - /* Write sectors is too big */ - if (sectors > MAX_NB_SECTORS) - sectors = MAX_NB_SECTORS; + /* Write sectors is too big */ + if (sectors > MAX_NB_SECTORS) + sectors = MAX_NB_SECTORS; - /* SDHC write */ - ret = SDHC_WriteSectors(lba + cnt, sectors, ptr); - if (!ret) - return -1; + /* SDHC write */ + ret = SDHC_WriteSectors(lba + cnt, sectors, ptr); + if (!ret) + return -1; - /* Increment counter */ - cnt += sectors; - } + /* Increment counter */ + cnt += sectors; + } - return 0; + return 0; } -s32 WBFS_Init(u32 device) -{ - s32 ret; +s32 WBFS_Init(u32 device) { + s32 ret; - switch (device) { - case WBFS_DEVICE_USB: - /* Initialize USB storage */ - ret = USBStorage_Init(); - if (ret >= 0) { - /* Setup callbacks */ - readCallback = __WBFS_ReadUSB; - writeCallback = __WBFS_WriteUSB; - /* Device info */ - /* Get USB capacity */ - nb_sectors = USBStorage_GetCapacity(§or_size); - if (!nb_sectors) - return -1; - } - else - return ret; - break; - case WBFS_DEVICE_SDHC: - /* Initialize SDHC */ - ret = SDHC_Init(); + switch (device) { + case WBFS_DEVICE_USB: + /* Initialize USB storage */ + ret = USBStorage_Init(); + if (ret >= 0) { + /* Setup callbacks */ + readCallback = __WBFS_ReadUSB; + writeCallback = __WBFS_WriteUSB; + /* Device info */ + /* Get USB capacity */ + nb_sectors = USBStorage_GetCapacity(§or_size); + if (!nb_sectors) + return -1; + } else + return ret; + break; + case WBFS_DEVICE_SDHC: + /* Initialize SDHC */ + ret = SDHC_Init(); - if (ret) { - /* Setup callbacks */ - readCallback = __WBFS_ReadSDHC; - writeCallback = __WBFS_WriteSDHC; + if (ret) { + /* Setup callbacks */ + readCallback = __WBFS_ReadSDHC; + writeCallback = __WBFS_WriteSDHC; - /* Device info */ - nb_sectors = 0; - sector_size = SDHC_SECTOR_SIZE; - } - else - return -1; - break; - } + /* Device info */ + nb_sectors = 0; + sector_size = SDHC_SECTOR_SIZE; + } else + return -1; + break; + } - return 0; + return 0; } //s32 WBFS_Init(void) //{ @@ -314,192 +303,181 @@ out: } */ -s32 WBFS_Open(void) -{ - /* Close hard disk */ - if (hdd) - wbfs_close(hdd); +s32 WBFS_Open(void) { + /* Close hard disk */ + if (hdd) + wbfs_close(hdd); - /* Open hard disk */ - hdd = wbfs_open_hd(readCallback, writeCallback, NULL, sector_size, nb_sectors, 0); - if (!hdd) - return -1; + /* Open hard disk */ + hdd = wbfs_open_hd(readCallback, writeCallback, NULL, sector_size, nb_sectors, 0); + if (!hdd) + return -1; - return 0; -} - -s32 WBFS_Close(void) - -{ - /* Close hard disk */ - if (hdd) - wbfs_close(hdd); - - return 0; + return 0; } -s32 WBFS_Format(u32 lba, u32 size) +s32 WBFS_Close(void) + { - wbfs_t *partition = NULL; + /* Close hard disk */ + if (hdd) + wbfs_close(hdd); - /* Reset partition */ - partition = wbfs_open_partition(readCallback, writeCallback, NULL, sector_size, size, lba, 1); - if (!partition) - return -1; - - /* Free memory */ - wbfs_close(partition); - - return 0; + return 0; } -s32 WBFS_GetCount(u32 *count) -{ - /* No device open */ - if (!hdd) - return -1; +s32 WBFS_Format(u32 lba, u32 size) { + wbfs_t *partition = NULL; - /* Get list length */ - *count = wbfs_count_discs(hdd); + /* Reset partition */ + partition = wbfs_open_partition(readCallback, writeCallback, NULL, sector_size, size, lba, 1); + if (!partition) + return -1; - return 0; + /* Free memory */ + wbfs_close(partition); + + return 0; } -s32 WBFS_GetHeaders(void *outbuf, u32 cnt, u32 len) -{ - u32 idx, size; - s32 ret; +s32 WBFS_GetCount(u32 *count) { + /* No device open */ + if (!hdd) + return -1; - /* No device open */ - if (!hdd) - return -1; + /* Get list length */ + *count = wbfs_count_discs(hdd); - for (idx = 0; idx < cnt; idx++) { - u8 *ptr = ((u8 *)outbuf) + (idx * len); - - /* Get header */ - ret = wbfs_get_disc_info(hdd, idx, ptr, len, &size); - if (ret < 0) - return ret; - } - - return 0; + return 0; } -s32 WBFS_CheckGame(u8 *discid) -{ - wbfs_disc_t *disc = NULL; +s32 WBFS_GetHeaders(void *outbuf, u32 cnt, u32 len) { + u32 idx, size; + s32 ret; - /* Try to open game disc */ - disc = wbfs_open_disc(hdd, discid); - if (disc) { - /* Close disc */ - wbfs_close_disc(disc); + /* No device open */ + if (!hdd) + return -1; - return 1; - } + for (idx = 0; idx < cnt; idx++) { + u8 *ptr = ((u8 *)outbuf) + (idx * len); - return 0; + /* Get header */ + ret = wbfs_get_disc_info(hdd, idx, ptr, len, &size); + if (ret < 0) + return ret; + } + + return 0; } -s32 WBFS_AddGame(void) -{ - s32 ret; +s32 WBFS_CheckGame(u8 *discid) { + wbfs_disc_t *disc = NULL; - /* No device open */ - if (!hdd) - return -1; + /* Try to open game disc */ + disc = wbfs_open_disc(hdd, discid); + if (disc) { + /* Close disc */ + wbfs_close_disc(disc); - /* Add game to device */ - ret = wbfs_add_disc(hdd, __WBFS_ReadDVD, NULL, WBFS_Spinner, ONLY_GAME_PARTITION, 0); - if (ret < 0) - return ret; + return 1; + } - return 0; + return 0; } -s32 WBFS_RemoveGame(u8 *discid) -{ - s32 ret; +s32 WBFS_AddGame(void) { + s32 ret; - /* No device open */ - if (!hdd) - return -1; + /* No device open */ + if (!hdd) + return -1; - /* Remove game from USB device */ - ret = wbfs_rm_disc(hdd, discid); - if (ret < 0) - return ret; + /* Add game to device */ + ret = wbfs_add_disc(hdd, __WBFS_ReadDVD, NULL, WBFS_Spinner, ONLY_GAME_PARTITION, 0); + if (ret < 0) + return ret; - return 0; + return 0; } -s32 WBFS_GameSize(u8 *discid, f32 *size) -{ - wbfs_disc_t *disc = NULL; +s32 WBFS_RemoveGame(u8 *discid) { + s32 ret; - u32 sectors; + /* No device open */ + if (!hdd) + return -1; - /* No device open */ - if (!hdd) - return -1; + /* Remove game from USB device */ + ret = wbfs_rm_disc(hdd, discid); + if (ret < 0) + return ret; - /* Open disc */ - disc = wbfs_open_disc(hdd, discid); - if (!disc) - return -2; - - /* Get game size in sectors */ - sectors = wbfs_sector_used(hdd, disc->header); - - /* Close disc */ - wbfs_close_disc(disc); - - /* Copy value */ - *size = (hdd->wbfs_sec_sz / GB_SIZE) * sectors; - - return 0; + return 0; } -s32 WBFS_DiskSpace(f32 *used, f32 *free) -{ - f32 ssize; - u32 cnt; +s32 WBFS_GameSize(u8 *discid, f32 *size) { + wbfs_disc_t *disc = NULL; - /* No device open */ - if (!hdd) - return -1; + u32 sectors; - /* Count used blocks */ - cnt = wbfs_count_usedblocks(hdd); + /* No device open */ + if (!hdd) + return -1; - /* Sector size in GB */ - ssize = hdd->wbfs_sec_sz / GB_SIZE; + /* Open disc */ + disc = wbfs_open_disc(hdd, discid); + if (!disc) + return -2; - /* Copy values */ - *free = ssize * cnt; - *used = ssize * (hdd->n_wbfs_sec - cnt); + /* Get game size in sectors */ + sectors = wbfs_sector_used(hdd, disc->header); - return 0; + /* Close disc */ + wbfs_close_disc(disc); + + /* Copy value */ + *size = (hdd->wbfs_sec_sz / GB_SIZE) * sectors; + + return 0; } -s32 WBFS_RenameGame(u8 *discid, const void *newname) -{ - s32 ret; +s32 WBFS_DiskSpace(f32 *used, f32 *free) { + f32 ssize; + u32 cnt; - /* No USB device open */ - if (!hdd) - return -1; - ret = wbfs_ren_disc(hdd, discid,(u8*)newname); - if (ret < 0) - return ret; + /* No device open */ + if (!hdd) + return -1; + + /* Count used blocks */ + cnt = wbfs_count_usedblocks(hdd); + + /* Sector size in GB */ + ssize = hdd->wbfs_sec_sz / GB_SIZE; + + /* Copy values */ + *free = ssize * cnt; + *used = ssize * (hdd->n_wbfs_sec - cnt); + + return 0; +} + +s32 WBFS_RenameGame(u8 *discid, const void *newname) { + s32 ret; + + /* No USB device open */ + if (!hdd) + return -1; + ret = wbfs_ren_disc(hdd, discid,(u8*)newname); + if (ret < 0) + return ret; + + return 0; +} + +f32 WBFS_EstimeGameSize(void) { - return 0; -} - -f32 WBFS_EstimeGameSize(void) -{ - return wbfs_estimate_disc(hdd, __WBFS_ReadDVD, NULL, ONLY_GAME_PARTITION); - -} + +} diff --git a/source/usbloader/wbfs.h b/source/usbloader/wbfs.h index 8cd9f09b..a942de11 100644 --- a/source/usbloader/wbfs.h +++ b/source/usbloader/wbfs.h @@ -1,46 +1,45 @@ -#ifndef _WBFS_H_ +#ifndef _WBFS_H_ #define _WBFS_H_ #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif -#include "libwbfs/libwbfs.h" -/* Device list */ -enum { - WBFS_DEVICE_USB = 1, /* USB device */ - WBFS_DEVICE_SDHC /* SDHC device */ -}; +#include "libwbfs/libwbfs.h" + /* 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); -s32 __WBFS_ReadUSB(void *fp, u32 lba, u32 count, void *iobuf); -s32 __WBFS_WriteUSB(void *fp, u32 lba, u32 count, void *iobuf); + /* 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); + - #ifdef __cplusplus } #endif -#endif +#endif diff --git a/source/usbloader/wdvd.c b/source/usbloader/wdvd.c index cbb3b3ef..ed27def5 100644 --- a/source/usbloader/wdvd.c +++ b/source/usbloader/wdvd.c @@ -18,10 +18,10 @@ #define IOCTL_DI_STOPMOTOR 0xE3 #define IOCTL_DI_SETUSBMODE 0xF4 #define IOCTL_DI_DISABLERESET 0xF6 - -/** Hermes IOS222 **/ -#define DI_SETWBFSMODE 0xfe -#define DI_SETOFFSETBASE 0xf1 + +/** Hermes IOS222 **/ +#define DI_SETWBFSMODE 0xfe +#define DI_SETOFFSETBASE 0xf1 /* Variables */ static u32 inbuf[8] ATTRIBUTE_ALIGN(32); @@ -30,324 +30,306 @@ 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) -{ - /* Open "/dev/di" */ - if (di_fd < 0) { - di_fd = IOS_Open(di_fs, 0); - if (di_fd < 0) - return di_fd; - } +s32 WDVD_Init(void) { + /* Open "/dev/di" */ + if (di_fd < 0) { + di_fd = IOS_Open(di_fs, 0); + if (di_fd < 0) + return di_fd; + } - return 0; + return 0; } -s32 WDVD_Close(void) -{ - /* Close "/dev/di" */ - if (di_fd >= 0) { - IOS_Close(di_fd); - di_fd = -1; - } +s32 WDVD_Close(void) { + /* Close "/dev/di" */ + if (di_fd >= 0) { + IOS_Close(di_fd); + di_fd = -1; + } - return 0; + return 0; } -s32 WDVD_GetHandle(void) -{ - /* Return di handle */ - return di_fd; +s32 WDVD_GetHandle(void) { + /* Return di handle */ + return di_fd; } -s32 WDVD_Reset(void) -{ - s32 ret; +s32 WDVD_Reset(void) { + s32 ret; - memset(inbuf, 0, sizeof(inbuf)); + memset(inbuf, 0, sizeof(inbuf)); - /* Reset drive */ - inbuf[0] = IOCTL_DI_RESET << 24; - inbuf[1] = 1; + /* Reset drive */ + inbuf[0] = IOCTL_DI_RESET << 24; + inbuf[1] = 1; - ret = IOS_Ioctl(di_fd, IOCTL_DI_RESET, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); - if (ret < 0) - return ret; + ret = IOS_Ioctl(di_fd, IOCTL_DI_RESET, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); + if (ret < 0) + return ret; - return (ret == 1) ? 0 : -ret; + return (ret == 1) ? 0 : -ret; } -s32 WDVD_ReadDiskId(void *id) -{ - s32 ret; +s32 WDVD_ReadDiskId(void *id) { + s32 ret; - memset(inbuf, 0, sizeof(inbuf)); + memset(inbuf, 0, sizeof(inbuf)); - /* Read disc ID */ - inbuf[0] = IOCTL_DI_READID << 24; + /* Read disc ID */ + inbuf[0] = IOCTL_DI_READID << 24; - ret = IOS_Ioctl(di_fd, IOCTL_DI_READID, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); - if (ret < 0) - return ret; + ret = IOS_Ioctl(di_fd, IOCTL_DI_READID, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); + if (ret < 0) + return ret; - if (ret == 1) { - memcpy(id, outbuf, sizeof(dvddiskid)); - return 0; - } + if (ret == 1) { + memcpy(id, outbuf, sizeof(dvddiskid)); + return 0; + } - return -ret; + return -ret; } -s32 WDVD_Seek(u64 offset) -{ - s32 ret; +s32 WDVD_Seek(u64 offset) { + s32 ret; - memset(inbuf, 0, sizeof(inbuf)); + memset(inbuf, 0, sizeof(inbuf)); - /* Drive seek */ - inbuf[0] = IOCTL_DI_SEEK << 24; - inbuf[1] = (u32)(offset >> 2); + /* Drive seek */ + inbuf[0] = IOCTL_DI_SEEK << 24; + inbuf[1] = (u32)(offset >> 2); - ret = IOS_Ioctl(di_fd, IOCTL_DI_SEEK, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); - if(ret!=1) - { - // Try old cIOS 222 - /* Drive seek */ - inbuf[0] = DI_SETOFFSETBASE << 24; - ret = IOS_Ioctl(di_fd, DI_SETOFFSETBASE, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); - } - if (ret < 0) - return ret; + ret = IOS_Ioctl(di_fd, IOCTL_DI_SEEK, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); + if (ret!=1) { + // Try old cIOS 222 + /* Drive seek */ + inbuf[0] = DI_SETOFFSETBASE << 24; + ret = IOS_Ioctl(di_fd, DI_SETOFFSETBASE, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); + } + if (ret < 0) + return ret; - return (ret == 1) ? 0 : -ret; + return (ret == 1) ? 0 : -ret; } -s32 WDVD_Offset(u64 offset) -{ - u32 *off = (u32 *)((void *)&offset); - s32 ret; +s32 WDVD_Offset(u64 offset) { + u32 *off = (u32 *)((void *)&offset); + s32 ret; - memset(inbuf, 0, sizeof(inbuf)); + memset(inbuf, 0, sizeof(inbuf)); - /* Set offset */ - inbuf[0] = IOCTL_DI_OFFSET << 24; - inbuf[1] = (off[0]) ? 1: 0; - inbuf[2] = (off[1] >> 2); + /* Set offset */ + inbuf[0] = IOCTL_DI_OFFSET << 24; + inbuf[1] = (off[0]) ? 1: 0; + inbuf[2] = (off[1] >> 2); - ret = IOS_Ioctl(di_fd, IOCTL_DI_OFFSET, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); - if (ret < 0) - return ret; + ret = IOS_Ioctl(di_fd, IOCTL_DI_OFFSET, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); + if (ret < 0) + return ret; - return (ret == 1) ? 0 : -ret; + return (ret == 1) ? 0 : -ret; } -s32 WDVD_StopLaser(void) -{ - s32 ret; +s32 WDVD_StopLaser(void) { + s32 ret; - memset(inbuf, 0, sizeof(inbuf)); + memset(inbuf, 0, sizeof(inbuf)); - /* Stop laser */ - inbuf[0] = IOCTL_DI_STOPLASER << 24; + /* Stop laser */ + inbuf[0] = IOCTL_DI_STOPLASER << 24; - ret = IOS_Ioctl(di_fd, IOCTL_DI_STOPLASER, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); - if (ret < 0) - return ret; + ret = IOS_Ioctl(di_fd, IOCTL_DI_STOPLASER, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); + if (ret < 0) + return ret; - return (ret == 1) ? 0 : -ret; + return (ret == 1) ? 0 : -ret; } -s32 WDVD_StopMotor(void) -{ - s32 ret; +s32 WDVD_StopMotor(void) { + s32 ret; - memset(inbuf, 0, sizeof(inbuf)); + memset(inbuf, 0, sizeof(inbuf)); - /* Stop motor */ - inbuf[0] = IOCTL_DI_STOPMOTOR << 24; + /* Stop motor */ + inbuf[0] = IOCTL_DI_STOPMOTOR << 24; - ret = IOS_Ioctl(di_fd, IOCTL_DI_STOPMOTOR, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); - if (ret < 0) - return ret; + ret = IOS_Ioctl(di_fd, IOCTL_DI_STOPMOTOR, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); + if (ret < 0) + return ret; - return (ret == 1) ? 0 : -ret; -} - -s32 WDVD_OpenPartition(u64 offset) -{ - u8 *vector = NULL; - - u32 *buffer = NULL; - s32 ret; - - /* Allocate memory */ - buffer = (u32 *)memalign(32, 0x5000); - if (!buffer) - return -1; - - /* Set vector pointer */ - vector = (u8 *)buffer; - - memset(buffer, 0, 0x5000); - - /* Open partition */ - buffer[0] = (u32)(buffer + 0x10); - buffer[1] = 0x20; - buffer[3] = 0x024A; - buffer[6] = (u32)(buffer + 0x380); - buffer[7] = 0x49E4; - buffer[8] = (u32)(buffer + 0x360); - buffer[9] = 0x20; - - buffer[(0x40 >> 2)] = IOCTL_DI_OPENPART << 24; - buffer[(0x40 >> 2) + 1] = offset >> 2; - - ret = IOS_Ioctlv(di_fd, IOCTL_DI_OPENPART, 3, 2, (ioctlv *)vector); - - /* Free memory */ - free(buffer); - - if (ret < 0) - return ret; - - return (ret == 1) ? 0 : -ret; + return (ret == 1) ? 0 : -ret; } -s32 WDVD_ClosePartition(void) -{ - s32 ret; +s32 WDVD_OpenPartition(u64 offset) { + u8 *vector = NULL; - memset(inbuf, 0, sizeof(inbuf)); + u32 *buffer = NULL; + s32 ret; - /* Close partition */ - inbuf[0] = IOCTL_DI_CLOSEPART << 24; + /* Allocate memory */ + buffer = (u32 *)memalign(32, 0x5000); + if (!buffer) + return -1; - ret = IOS_Ioctl(di_fd, IOCTL_DI_CLOSEPART, inbuf, sizeof(inbuf), NULL, 0); - if (ret < 0) - return ret; + /* Set vector pointer */ + vector = (u8 *)buffer; - return (ret == 1) ? 0 : -ret; + memset(buffer, 0, 0x5000); + + /* Open partition */ + buffer[0] = (u32)(buffer + 0x10); + buffer[1] = 0x20; + buffer[3] = 0x024A; + buffer[6] = (u32)(buffer + 0x380); + buffer[7] = 0x49E4; + buffer[8] = (u32)(buffer + 0x360); + buffer[9] = 0x20; + + buffer[(0x40 >> 2)] = IOCTL_DI_OPENPART << 24; + buffer[(0x40 >> 2) + 1] = offset >> 2; + + ret = IOS_Ioctlv(di_fd, IOCTL_DI_OPENPART, 3, 2, (ioctlv *)vector); + + /* Free memory */ + free(buffer); + + if (ret < 0) + return ret; + + return (ret == 1) ? 0 : -ret; } -s32 WDVD_UnencryptedRead(void *buf, u32 len, u64 offset) -{ - s32 ret; +s32 WDVD_ClosePartition(void) { + s32 ret; - memset(inbuf, 0, sizeof(inbuf)); + memset(inbuf, 0, sizeof(inbuf)); - /* Unencrypted read */ - inbuf[0] = IOCTL_DI_UNENCREAD << 24; - inbuf[1] = len; - inbuf[2] = (u32)(offset >> 2); + /* Close partition */ + inbuf[0] = IOCTL_DI_CLOSEPART << 24; - ret = IOS_Ioctl(di_fd, IOCTL_DI_UNENCREAD, inbuf, sizeof(inbuf), buf, len); - if (ret < 0) - return ret; + ret = IOS_Ioctl(di_fd, IOCTL_DI_CLOSEPART, inbuf, sizeof(inbuf), NULL, 0); + if (ret < 0) + return ret; - return (ret == 1) ? 0 : -ret; + return (ret == 1) ? 0 : -ret; } -s32 WDVD_Read(void *buf, u32 len, u64 offset) -{ - s32 ret; +s32 WDVD_UnencryptedRead(void *buf, u32 len, u64 offset) { + s32 ret; - memset(inbuf, 0, sizeof(inbuf)); + memset(inbuf, 0, sizeof(inbuf)); - /* Disc read */ - inbuf[0] = IOCTL_DI_READ << 24; - inbuf[1] = len; - inbuf[2] = (u32)(offset >> 2); + /* Unencrypted read */ + inbuf[0] = IOCTL_DI_UNENCREAD << 24; + inbuf[1] = len; + inbuf[2] = (u32)(offset >> 2); - ret = IOS_Ioctl(di_fd, IOCTL_DI_READ, inbuf, sizeof(inbuf), buf, len); - if (ret < 0) - return ret; + ret = IOS_Ioctl(di_fd, IOCTL_DI_UNENCREAD, inbuf, sizeof(inbuf), buf, len); + if (ret < 0) + return ret; - return (ret == 1) ? 0 : -ret; + return (ret == 1) ? 0 : -ret; } -s32 WDVD_WaitForDisc(void) -{ - s32 ret; +s32 WDVD_Read(void *buf, u32 len, u64 offset) { + s32 ret; - memset(inbuf, 0, sizeof(inbuf)); + memset(inbuf, 0, sizeof(inbuf)); - /* Wait for disc */ - inbuf[0] = IOCTL_DI_WAITCVRCLOSE << 24; + /* Disc read */ + inbuf[0] = IOCTL_DI_READ << 24; + inbuf[1] = len; + inbuf[2] = (u32)(offset >> 2); - ret = IOS_Ioctl(di_fd, IOCTL_DI_WAITCVRCLOSE, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); - if (ret < 0) - return ret; + ret = IOS_Ioctl(di_fd, IOCTL_DI_READ, inbuf, sizeof(inbuf), buf, len); + if (ret < 0) + return ret; - return (ret == 1) ? 0 : -ret; + return (ret == 1) ? 0 : -ret; } -s32 WDVD_GetCoverStatus(u32 *status) -{ - s32 ret; +s32 WDVD_WaitForDisc(void) { + s32 ret; - memset(inbuf, 0, sizeof(inbuf)); + memset(inbuf, 0, sizeof(inbuf)); - /* Get cover status */ - inbuf[0] = IOCTL_DI_GETCOVER << 24; + /* Wait for disc */ + inbuf[0] = IOCTL_DI_WAITCVRCLOSE << 24; - ret = IOS_Ioctl(di_fd, IOCTL_DI_GETCOVER, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); - if (ret < 0) - return ret; + ret = IOS_Ioctl(di_fd, IOCTL_DI_WAITCVRCLOSE, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); + if (ret < 0) + return ret; - if (ret == 1) { - /* Copy cover status */ - memcpy(status, outbuf, sizeof(u32)); - - return 0; - } - - return -ret; + return (ret == 1) ? 0 : -ret; } -s32 WDVD_DisableReset(u8 val) -{ - s32 ret; +s32 WDVD_GetCoverStatus(u32 *status) { + s32 ret; - memset(inbuf, 0, sizeof(inbuf)); + memset(inbuf, 0, sizeof(inbuf)); - /* Disable/Enable reset */ - inbuf[0] = IOCTL_DI_DISABLERESET << 24; - inbuf[1] = val; + /* Get cover status */ + inbuf[0] = IOCTL_DI_GETCOVER << 24; - ret = IOS_Ioctl(di_fd, IOCTL_DI_DISABLERESET, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); - if (ret < 0) - return ret; + ret = IOS_Ioctl(di_fd, IOCTL_DI_GETCOVER, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); + if (ret < 0) + return ret; - return (ret == 1) ? 0 : -ret; + if (ret == 1) { + /* Copy cover status */ + memcpy(status, outbuf, sizeof(u32)); + + return 0; + } + + return -ret; } - + +s32 WDVD_DisableReset(u8 val) { + s32 ret; + + memset(inbuf, 0, sizeof(inbuf)); + + /* Disable/Enable reset */ + inbuf[0] = IOCTL_DI_DISABLERESET << 24; + inbuf[1] = val; + + ret = IOS_Ioctl(di_fd, IOCTL_DI_DISABLERESET, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); + if (ret < 0) + return ret; + + return (ret == 1) ? 0 : -ret; +} + /** Hermes **/ -s32 WDVD_SetUSBMode(u8 *id) -{ - s32 ret; - - memset(inbuf, 0, sizeof(inbuf)); - - /* Set USB mode */ - inbuf[0] = IOCTL_DI_SETUSBMODE << 24; - inbuf[1] = (id) ? 1 : 0; - - - /* Copy ID */ - if (id) { - memcpy(&inbuf[2], id, 6); - } - - ret = IOS_Ioctl(di_fd, IOCTL_DI_SETUSBMODE, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); - if(ret!=1) { - // Try old cIOS 222 - /* Set USB mode */ - inbuf[0] = DI_SETWBFSMODE << 24; - ret = IOS_Ioctl(di_fd, DI_SETWBFSMODE, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); - } - - if (ret < 0) - return ret; - - return (ret == 1) ? 0 : -ret; -} +s32 WDVD_SetUSBMode(u8 *id) { + s32 ret; + + memset(inbuf, 0, sizeof(inbuf)); + + /* Set USB mode */ + inbuf[0] = IOCTL_DI_SETUSBMODE << 24; + inbuf[1] = (id) ? 1 : 0; + + + /* Copy ID */ + if (id) { + memcpy(&inbuf[2], id, 6); + } + + ret = IOS_Ioctl(di_fd, IOCTL_DI_SETUSBMODE, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); + if (ret!=1) { + // Try old cIOS 222 + /* Set USB mode */ + inbuf[0] = DI_SETWBFSMODE << 24; + ret = IOS_Ioctl(di_fd, DI_SETWBFSMODE, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); + } + + if (ret < 0) + return ret; + + return (ret == 1) ? 0 : -ret; +} diff --git a/source/usbloader/wdvd.h b/source/usbloader/wdvd.h index 3d2bd710..13a3040c 100644 --- a/source/usbloader/wdvd.h +++ b/source/usbloader/wdvd.h @@ -1,33 +1,32 @@ -#ifndef _WDVD_H_ +#ifndef _WDVD_H_ #define _WDVD_H_ #ifdef __cplusplus -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 *); - -#ifdef __cplusplus -} +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 *); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/source/video.cpp b/source/video.cpp index 3e98de3f..4f549012 100644 --- a/source/video.cpp +++ b/source/video.cpp @@ -35,31 +35,29 @@ u32 frameCount = 0; * called by postRetraceCallback in InitGCVideo - scans gcpad and wpad ***************************************************************************/ static void -UpdatePadsCB () -{ - frameCount++; - #ifdef HW_RVL - WPAD_ScanPads(); - #endif - PAD_ScanPads(); +UpdatePadsCB () { + frameCount++; +#ifdef HW_RVL + WPAD_ScanPads(); +#endif + PAD_ScanPads(); - for(int i=3; i >= 0; i--) - { - #ifdef HW_RVL - memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData)); - #endif + for (int i=3; i >= 0; i--) { +#ifdef HW_RVL + memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData)); +#endif - userInput[i].chan = i; - userInput[i].pad.btns_d = PAD_ButtonsDown(i); - userInput[i].pad.btns_u = PAD_ButtonsUp(i); - userInput[i].pad.btns_h = PAD_ButtonsHeld(i); - userInput[i].pad.stickX = PAD_StickX(i); - userInput[i].pad.stickY = PAD_StickY(i); - userInput[i].pad.substickX = PAD_SubStickX(i); - userInput[i].pad.substickY = PAD_SubStickY(i); - userInput[i].pad.triggerL = PAD_TriggerL(i); - userInput[i].pad.triggerR = PAD_TriggerR(i); - } + userInput[i].chan = i; + userInput[i].pad.btns_d = PAD_ButtonsDown(i); + userInput[i].pad.btns_u = PAD_ButtonsUp(i); + userInput[i].pad.btns_h = PAD_ButtonsHeld(i); + userInput[i].pad.stickX = PAD_StickX(i); + userInput[i].pad.stickY = PAD_StickY(i); + userInput[i].pad.substickX = PAD_SubStickX(i); + userInput[i].pad.substickY = PAD_SubStickY(i); + userInput[i].pad.triggerL = PAD_TriggerL(i); + userInput[i].pad.triggerR = PAD_TriggerR(i); + } } /**************************************************************************** @@ -68,19 +66,18 @@ UpdatePadsCB () * Initialises GX and sets it up for use ***************************************************************************/ static void -StartGX () -{ - GXColor background = { 0, 0, 0, 0xff }; +StartGX () { + GXColor background = { 0, 0, 0, 0xff }; - /*** Clear out FIFO area ***/ - memset (&gp_fifo, 0, DEFAULT_FIFO_SIZE); + /*** Clear out FIFO area ***/ + memset (&gp_fifo, 0, DEFAULT_FIFO_SIZE); - /*** Initialise GX ***/ - GX_Init (&gp_fifo, DEFAULT_FIFO_SIZE); - GX_SetCopyClear (background, 0x00ffffff); + /*** Initialise GX ***/ + GX_Init (&gp_fifo, DEFAULT_FIFO_SIZE); + GX_SetCopyClear (background, 0x00ffffff); - GX_SetDispCopyGamma (GX_GM_1_0); - GX_SetCullMode (GX_CULL_NONE); + GX_SetDispCopyGamma (GX_GM_1_0); + GX_SetCullMode (GX_CULL_NONE); } /**************************************************************************** @@ -89,69 +86,68 @@ StartGX () * Reset the video/rendering mode for the menu ****************************************************************************/ void -ResetVideo_Menu() -{ - Mtx44 p; - f32 yscale; - u32 xfbHeight; +ResetVideo_Menu() { + Mtx44 p; + f32 yscale; + u32 xfbHeight; - VIDEO_Configure (vmode); - VIDEO_Flush(); - VIDEO_WaitVSync(); - if (vmode->viTVMode & VI_NON_INTERLACE) - VIDEO_WaitVSync(); - else - while (VIDEO_GetNextField()) - VIDEO_WaitVSync(); + VIDEO_Configure (vmode); + VIDEO_Flush(); + VIDEO_WaitVSync(); + if (vmode->viTVMode & VI_NON_INTERLACE) + VIDEO_WaitVSync(); + else + while (VIDEO_GetNextField()) + VIDEO_WaitVSync(); - // clears the bg to color and clears the z buffer - GXColor background = {0, 0, 0, 255}; - GX_SetCopyClear (background, 0x00ffffff); + // clears the bg to color and clears the z buffer + GXColor background = {0, 0, 0, 255}; + GX_SetCopyClear (background, 0x00ffffff); - yscale = GX_GetYScaleFactor(vmode->efbHeight,vmode->xfbHeight); - xfbHeight = GX_SetDispCopyYScale(yscale); - GX_SetScissor(0,0,vmode->fbWidth,vmode->efbHeight); - GX_SetDispCopySrc(0,0,vmode->fbWidth,vmode->efbHeight); - GX_SetDispCopyDst(vmode->fbWidth,xfbHeight); - GX_SetCopyFilter(vmode->aa,vmode->sample_pattern,GX_TRUE,vmode->vfilter); - GX_SetFieldMode(vmode->field_rendering,((vmode->viHeight==2*vmode->xfbHeight)?GX_ENABLE:GX_DISABLE)); + yscale = GX_GetYScaleFactor(vmode->efbHeight,vmode->xfbHeight); + xfbHeight = GX_SetDispCopyYScale(yscale); + GX_SetScissor(0,0,vmode->fbWidth,vmode->efbHeight); + GX_SetDispCopySrc(0,0,vmode->fbWidth,vmode->efbHeight); + GX_SetDispCopyDst(vmode->fbWidth,xfbHeight); + GX_SetCopyFilter(vmode->aa,vmode->sample_pattern,GX_TRUE,vmode->vfilter); + GX_SetFieldMode(vmode->field_rendering,((vmode->viHeight==2*vmode->xfbHeight)?GX_ENABLE:GX_DISABLE)); - if (vmode->aa) - GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR); - else - GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); + if (vmode->aa) + GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR); + else + GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); - // setup the vertex descriptor - // tells the flipper to expect direct data - GX_ClearVtxDesc(); - GX_InvVtxCache (); - GX_InvalidateTexAll(); + // setup the vertex descriptor + // tells the flipper to expect direct data + GX_ClearVtxDesc(); + GX_InvVtxCache (); + GX_InvalidateTexAll(); - GX_SetVtxDesc(GX_VA_TEX0, GX_NONE); - GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); - GX_SetVtxDesc (GX_VA_CLR0, GX_DIRECT); + GX_SetVtxDesc(GX_VA_TEX0, GX_NONE); + GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); + GX_SetVtxDesc (GX_VA_CLR0, GX_DIRECT); - GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); - GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); - GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); - GX_SetZMode (GX_FALSE, GX_LEQUAL, GX_TRUE); + GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); + GX_SetZMode (GX_FALSE, GX_LEQUAL, GX_TRUE); - GX_SetNumChans(1); - GX_SetNumTexGens(1); - GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR); - GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); - GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); + GX_SetNumChans(1); + GX_SetNumTexGens(1); + GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR); + GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); + GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); - guMtxIdentity(GXmodelView2D); - guMtxTransApply (GXmodelView2D, GXmodelView2D, 0.0F, 0.0F, -200.0F); - GX_LoadPosMtxImm(GXmodelView2D,GX_PNMTX0); + guMtxIdentity(GXmodelView2D); + guMtxTransApply (GXmodelView2D, GXmodelView2D, 0.0F, 0.0F, -200.0F); + GX_LoadPosMtxImm(GXmodelView2D,GX_PNMTX0); - guOrtho(p,0,479,0,639,0,300); - GX_LoadProjectionMtx(p, GX_ORTHOGRAPHIC); + guOrtho(p,0,479,0,639,0,300); + GX_LoadProjectionMtx(p, GX_ORTHOGRAPHIC); - GX_SetViewport(0,0,vmode->fbWidth,vmode->efbHeight,0,1); - GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); - GX_SetAlphaUpdate(GX_TRUE); + GX_SetViewport(0,0,vmode->fbWidth,vmode->efbHeight,0,1); + GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GX_SetAlphaUpdate(GX_TRUE); } /**************************************************************************** @@ -162,47 +158,45 @@ ResetVideo_Menu() ***************************************************************************/ void -InitVideo () -{ - VIDEO_Init(); - vmode = VIDEO_GetPreferredMode(NULL); // get default video mode +InitVideo () { + VIDEO_Init(); + vmode = VIDEO_GetPreferredMode(NULL); // get default video mode - // widescreen fix - if(CFG.widescreen) - { - vmode->viWidth = VI_MAX_WIDTH_PAL-12; - vmode->viXOrigin = ((VI_MAX_WIDTH_PAL - vmode->viWidth) / 2) + 2; - } + // widescreen fix + if (CFG.widescreen) { + vmode->viWidth = VI_MAX_WIDTH_PAL-12; + vmode->viXOrigin = ((VI_MAX_WIDTH_PAL - vmode->viWidth) / 2) + 2; + } - VIDEO_Configure (vmode); + VIDEO_Configure (vmode); - screenheight = 480; - screenwidth = vmode->fbWidth; + screenheight = 480; + screenwidth = vmode->fbWidth; - // Allocate the video buffers - xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); - xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); + // Allocate the video buffers + xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); + xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); - // A console is always useful while debugging - console_init (xfb[0], 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2); + // A console is always useful while debugging + console_init (xfb[0], 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2); - // Clear framebuffers etc. - VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK); - VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK); - VIDEO_SetNextFramebuffer (xfb[0]); + // Clear framebuffers etc. + VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK); + VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK); + VIDEO_SetNextFramebuffer (xfb[0]); - // video callback - VIDEO_SetPostRetraceCallback ((VIRetraceCallback)UpdatePadsCB); + // video callback + VIDEO_SetPostRetraceCallback ((VIRetraceCallback)UpdatePadsCB); - VIDEO_SetBlack (FALSE); - VIDEO_Flush (); - VIDEO_WaitVSync (); - if (vmode->viTVMode & VI_NON_INTERLACE) - VIDEO_WaitVSync (); + VIDEO_SetBlack (FALSE); + VIDEO_Flush (); + VIDEO_WaitVSync (); + if (vmode->viTVMode & VI_NON_INTERLACE) + VIDEO_WaitVSync (); - StartGX(); - ResetVideo_Menu(); - // Finally, the video is up and ready for use :) + StartGX(); + ResetVideo_Menu(); + // Finally, the video is up and ready for use :) } /**************************************************************************** @@ -210,13 +204,12 @@ InitVideo () * * Stops GX (when exiting) ***************************************************************************/ -void StopGX() -{ - GX_AbortFrame(); - GX_Flush(); +void StopGX() { + GX_AbortFrame(); + GX_Flush(); - VIDEO_SetBlack(TRUE); - VIDEO_Flush(); + VIDEO_SetBlack(TRUE); + VIDEO_Flush(); } /**************************************************************************** @@ -224,17 +217,16 @@ void StopGX() * * Renders everything current sent to GX, and flushes video ***************************************************************************/ -void Menu_Render() -{ - GX_DrawDone (); +void Menu_Render() { + GX_DrawDone (); - whichfb ^= 1; // flip framebuffer - GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); - GX_SetColorUpdate(GX_TRUE); - GX_CopyDisp(xfb[whichfb],GX_TRUE); - VIDEO_SetNextFramebuffer(xfb[whichfb]); - VIDEO_Flush(); - VIDEO_WaitVSync(); + whichfb ^= 1; // flip framebuffer + GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); + GX_SetColorUpdate(GX_TRUE); + GX_CopyDisp(xfb[whichfb],GX_TRUE); + VIDEO_SetNextFramebuffer(xfb[whichfb]); + VIDEO_Flush(); + VIDEO_WaitVSync(); } /**************************************************************************** @@ -243,59 +235,60 @@ 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) - return; + 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; + GXTexObj texObj; - GX_InitTexObj(&texObj, data, width,height, GX_TF_RGBA8,GX_CLAMP, GX_CLAMP,GX_FALSE); - GX_LoadTexObj(&texObj, GX_TEXMAP0); - GX_InvalidateTexAll(); + GX_InitTexObj(&texObj, data, width,height, GX_TF_RGBA8,GX_CLAMP, GX_CLAMP,GX_FALSE); + GX_LoadTexObj(&texObj, GX_TEXMAP0); + GX_InvalidateTexAll(); - GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); - GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT); + GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); + GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT); - Mtx m,m1,m2, mv; - width *=.5; - height*=.5; - guMtxIdentity (m1); - guMtxScaleApply(m1,m1,scaleX,scaleY,1.0); - guVector axis = (guVector) {0 , 0, 1 }; - guMtxRotAxisDeg (m2, &axis, degrees); + Mtx m,m1,m2, mv; + width *=.5; + height*=.5; + guMtxIdentity (m1); + guMtxScaleApply(m1,m1,scaleX,scaleY,1.0); + guVector axis = (guVector) { + 0 , 0, 1 + }; + guMtxRotAxisDeg (m2, &axis, degrees); // guMtxConcat(m2,m1,m); - guMtxConcat(m1,m2,m); + guMtxConcat(m1,m2,m); - guMtxTransApply(m,m, xpos+width+0.5,ypos+height+0.5,zpos); - guMtxConcat (GXmodelView2D, m, mv); - GX_LoadPosMtxImm (mv, GX_PNMTX0); + guMtxTransApply(m,m, xpos+width+0.5,ypos+height+0.5,zpos); + guMtxConcat (GXmodelView2D, m, mv); + GX_LoadPosMtxImm (mv, GX_PNMTX0); // - GX_Begin(GX_QUADS, GX_VTXFMT0,4); - GX_Position3f32(-width+XX1 , -height+YY1, 0); - GX_Color4u8(0xFF,0xFF,0xFF,alpha); - GX_TexCoord2f32(0, 0); + GX_Begin(GX_QUADS, GX_VTXFMT0,4); + GX_Position3f32(-width+XX1 , -height+YY1, 0); + GX_Color4u8(0xFF,0xFF,0xFF,alpha); + GX_TexCoord2f32(0, 0); - GX_Position3f32(width+XX2, -height+YY2, 0); - GX_Color4u8(0xFF,0xFF,0xFF,alpha); - GX_TexCoord2f32(1, 0); + GX_Position3f32(width+XX2, -height+YY2, 0); + GX_Color4u8(0xFF,0xFF,0xFF,alpha); + GX_TexCoord2f32(1, 0); - GX_Position3f32(width+XX3, height+YY3, 0); - GX_Color4u8(0xFF,0xFF,0xFF,alpha); - GX_TexCoord2f32(1, 1); + GX_Position3f32(width+XX3, height+YY3, 0); + GX_Color4u8(0xFF,0xFF,0xFF,alpha); + GX_TexCoord2f32(1, 1); - GX_Position3f32(-width+XX4, height+YY4, 0); - GX_Color4u8(0xFF,0xFF,0xFF,alpha); - GX_TexCoord2f32(0, 1); + GX_Position3f32(-width+XX4, height+YY4, 0); + GX_Color4u8(0xFF,0xFF,0xFF,alpha); + GX_TexCoord2f32(0, 1); // - GX_End(); - GX_LoadPosMtxImm (GXmodelView2D, GX_PNMTX0); + GX_End(); + GX_LoadPosMtxImm (GXmodelView2D, GX_PNMTX0); - GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR); - GX_SetVtxDesc (GX_VA_TEX0, GX_NONE); + GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR); + GX_SetVtxDesc (GX_VA_TEX0, GX_NONE); } @@ -304,171 +297,167 @@ 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) -{ - u8 fmt; - long n; - int i; - f32 x2 = x+width; - 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}}; +void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled) { + u8 fmt; + long n; + int i; + f32 x2 = x+width; + 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) - { - fmt = GX_LINESTRIP; - n = 5; - } - else - { - fmt = GX_TRIANGLEFAN; - n = 4; - } + if (!filled) { + fmt = GX_LINESTRIP; + n = 5; + } else { + fmt = GX_TRIANGLEFAN; + n = 4; + } - GX_Begin(fmt, GX_VTXFMT0, n); - for(i=0; i @@ -56,155 +56,148 @@ int su_id_filled = 0; /* Reads a file from ISFS to an array in memory */ s32 ISFS_ReadFileToArray (const char *filepath, u8 *filearray, u32 max_size, u32 *file_size) { - s32 ret, fd; - static fstats filestats ATTRIBUTE_ALIGN(32); - - *file_size = 0; - ret = ISFS_Open(filepath, ISFS_OPEN_READ); - if (ret <= 0) - { - //printf("Error! ISFS_Open (ret = %d)\n", ret); - return -1; - } - - fd = ret; - - ret = ISFS_GetFileStats(fd, &filestats); - if (ret < 0) - { - //printf("Error! ISFS_GetFileStats (ret = %d)\n", ret); - return -1; - } - - *file_size = filestats.file_length; - - 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) - { - //printf("Error! ISFS_Read (ret = %d)\n", ret); - return -1; - } - else if (ret != filestats.file_length) - { - //printf("Error! ISFS_Read Only read: %d\n", ret); - return -1; - } - - ret = ISFS_Close(fd); - if (ret < 0) - { - //printf("Error! ISFS_Close (ret = %d)\n", ret); - return -1; - } - return 0; + s32 ret, fd; + static fstats filestats ATTRIBUTE_ALIGN(32); + + *file_size = 0; + ret = ISFS_Open(filepath, ISFS_OPEN_READ); + if (ret <= 0) { + //printf("Error! ISFS_Open (ret = %d)\n", ret); + return -1; + } + + fd = ret; + + ret = ISFS_GetFileStats(fd, &filestats); + if (ret < 0) { + //printf("Error! ISFS_GetFileStats (ret = %d)\n", ret); + return -1; + } + + *file_size = filestats.file_length; + + 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) { + //printf("Error! ISFS_Read (ret = %d)\n", ret); + return -1; + } else if (ret != filestats.file_length) { + //printf("Error! ISFS_Read Only read: %d\n", ret); + return -1; + } + + ret = ISFS_Close(fd); + if (ret < 0) { + //printf("Error! ISFS_Close (ret = %d)\n", ret); + return -1; + } + return 0; } -void Make_SUID(void){ - signed_blob *s_tmd, *s_tik; - tmd *p_tmd; - tik *p_tik; - - memset(su_tmd, 0, sizeof su_tmd); - memset(su_tik, 0, sizeof su_tik); - s_tmd = (signed_blob*)&su_tmd[0]; - s_tik = (signed_blob*)&su_tik[0]; - *s_tmd = *s_tik = 0x10001; - p_tmd = (tmd*)SIGNATURE_PAYLOAD(s_tmd); - p_tik = (tik*)SIGNATURE_PAYLOAD(s_tik); - - - strcpy(p_tmd->issuer, "Root-CA00000001-CP00000004"); - p_tmd->title_id = TITLE_ID(1,2); - - p_tmd->num_contents = 1; - - forge_tmd(s_tmd); - - strcpy(p_tik->issuer, "Root-CA00000001-XS00000003"); - p_tik->ticketid = 0x000038A45236EE5FLL; - p_tik->titleid = TITLE_ID(1,2); - - memset(p_tik->cidx_mask, 0xFF, 0x20); - forge_tik(s_tik); - - su_id_filled = 1; - +void Make_SUID(void) { + signed_blob *s_tmd, *s_tik; + tmd *p_tmd; + tik *p_tik; + + memset(su_tmd, 0, sizeof su_tmd); + memset(su_tik, 0, sizeof su_tik); + s_tmd = (signed_blob*)&su_tmd[0]; + s_tik = (signed_blob*)&su_tik[0]; + *s_tmd = *s_tik = 0x10001; + p_tmd = (tmd*)SIGNATURE_PAYLOAD(s_tmd); + p_tik = (tik*)SIGNATURE_PAYLOAD(s_tik); + + + strcpy(p_tmd->issuer, "Root-CA00000001-CP00000004"); + p_tmd->title_id = TITLE_ID(1,2); + + p_tmd->num_contents = 1; + + forge_tmd(s_tmd); + + strcpy(p_tik->issuer, "Root-CA00000001-XS00000003"); + p_tik->ticketid = 0x000038A45236EE5FLL; + p_tik->titleid = TITLE_ID(1,2); + + memset(p_tik->cidx_mask, 0xFF, 0x20); + forge_tik(s_tik); + + su_id_filled = 1; + } s32 Identify(const u8 *certs, u32 certs_size, const u8 *idtmd, u32 idtmd_size, const u8 *idticket, u32 idticket_size) { - s32 ret; - u32 keyid = 0; - ret = ES_Identify((signed_blob*)certs, certs_size, (signed_blob*)idtmd, idtmd_size, (signed_blob*)idticket, idticket_size, &keyid); - /*if (ret < 0){ - switch(ret){ - case ES_EINVAL: - printf("Error! ES_Identify (ret = %d;) Data invalid!\n", ret); - break; - case ES_EALIGN: - printf("Error! ES_Identify (ret = %d;) Data not aligned!\n", ret); - break; - case ES_ENOTINIT: - printf("Error! ES_Identify (ret = %d;) ES not initialized!\n", ret); - break; - case ES_ENOMEM: - printf("Error! ES_Identify (ret = %d;) No memory!\n", ret); - break; - default: - printf("Error! ES_Identify (ret = %d)\n", ret); - break; - } - } - else - printf("OK!\n");*/ - return ret; + s32 ret; + u32 keyid = 0; + ret = ES_Identify((signed_blob*)certs, certs_size, (signed_blob*)idtmd, idtmd_size, (signed_blob*)idticket, idticket_size, &keyid); + /*if (ret < 0){ + switch(ret){ + case ES_EINVAL: + printf("Error! ES_Identify (ret = %d;) Data invalid!\n", ret); + break; + case ES_EALIGN: + printf("Error! ES_Identify (ret = %d;) Data not aligned!\n", ret); + break; + case ES_ENOTINIT: + printf("Error! ES_Identify (ret = %d;) ES not initialized!\n", ret); + break; + case ES_ENOMEM: + printf("Error! ES_Identify (ret = %d;) No memory!\n", ret); + break; + default: + printf("Error! ES_Identify (ret = %d)\n", ret); + break; + } + } + else + printf("OK!\n");*/ + return ret; } s32 Identify_SU(void) { - if (!su_id_filled) - Make_SUID(); - - //printf("\nIdentifying as SU..."); - //fflush(stdout); - return Identify(certs_dat, certs_dat_size, su_tmd, sizeof su_tmd, su_tik, sizeof su_tik); + if (!su_id_filled) + Make_SUID(); + + //printf("\nIdentifying as SU..."); + //fflush(stdout); + return Identify(certs_dat, certs_dat_size, su_tmd, sizeof su_tmd, su_tik, sizeof su_tik); } s32 Identify_SysMenu(void) { - s32 ret; - u32 sysmenu_tmd_size, sysmenu_ticket_size; - //static u8 certs[0xA00] ATTRIBUTE_ALIGN(32); - static u8 sysmenu_tmd[MAX_SIGNED_TMD_SIZE] ATTRIBUTE_ALIGN(32); - static u8 sysmenu_ticket[STD_SIGNED_TIK_SIZE] ATTRIBUTE_ALIGN(32); - - /*printf("\nPulling Certs..."); - ret = ISFS_ReadFileToArray ("/sys/certs.sys", certs, 0xA00, &certs_size); - if (ret < 0) { - printf("\tReading Certs failed!\n"); - return -1; - }*/ - - //printf("\nPulling Sysmenu TMD..."); - ret = ISFS_ReadFileToArray ("/title/00000001/00000002/content/title.tmd", sysmenu_tmd, MAX_SIGNED_TMD_SIZE, &sysmenu_tmd_size); - if (ret < 0) { - //printf("\tReading TMD failed!\n"); - return -1; - } - - //printf("\nPulling Sysmenu Ticket..."); - ret = ISFS_ReadFileToArray ("/ticket/00000001/00000002.tik", sysmenu_ticket, STD_SIGNED_TIK_SIZE, &sysmenu_ticket_size); - if (ret < 0) { - //printf("\tReading TMD failed!\n"); - return -1; - } - - //printf("\nIdentifying as SysMenu..."); - //fflush(stdout); - return Identify(certs_dat, certs_dat_size, sysmenu_tmd, sysmenu_tmd_size, sysmenu_ticket, sysmenu_ticket_size); + s32 ret; + u32 sysmenu_tmd_size, sysmenu_ticket_size; + //static u8 certs[0xA00] ATTRIBUTE_ALIGN(32); + static u8 sysmenu_tmd[MAX_SIGNED_TMD_SIZE] ATTRIBUTE_ALIGN(32); + static u8 sysmenu_ticket[STD_SIGNED_TIK_SIZE] ATTRIBUTE_ALIGN(32); + + /*printf("\nPulling Certs..."); + ret = ISFS_ReadFileToArray ("/sys/certs.sys", certs, 0xA00, &certs_size); + if (ret < 0) { + printf("\tReading Certs failed!\n"); + return -1; + }*/ + + //printf("\nPulling Sysmenu TMD..."); + ret = ISFS_ReadFileToArray ("/title/00000001/00000002/content/title.tmd", sysmenu_tmd, MAX_SIGNED_TMD_SIZE, &sysmenu_tmd_size); + if (ret < 0) { + //printf("\tReading TMD failed!\n"); + return -1; + } + + //printf("\nPulling Sysmenu Ticket..."); + ret = ISFS_ReadFileToArray ("/ticket/00000001/00000002.tik", sysmenu_ticket, STD_SIGNED_TIK_SIZE, &sysmenu_ticket_size); + if (ret < 0) { + //printf("\tReading TMD failed!\n"); + return -1; + } + + //printf("\nIdentifying as SysMenu..."); + //fflush(stdout); + return Identify(certs_dat, certs_dat_size, sysmenu_tmd, sysmenu_tmd_size, sysmenu_ticket, sysmenu_ticket_size); } diff --git a/source/wad/id.h b/source/wad/id.h index 067c3d08..a33174f9 100644 --- a/source/wad/id.h +++ b/source/wad/id.h @@ -1,29 +1,29 @@ /*------------------------------------------------------------- - + id.h -- ES Identification code - + Copyright (C) 2008 tona Unless other credit specified - + This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. - + Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - + 1.The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. - + 2.Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - + 3.This notice may not be removed or altered from any source distribution. - + -------------------------------------------------------------*/ #ifndef _ID_H_ diff --git a/source/wad/patchmii_core.c b/source/wad/patchmii_core.c index 02356956..81ac9137 100644 --- a/source/wad/patchmii_core.c +++ b/source/wad/patchmii_core.c @@ -44,51 +44,51 @@ static u8 tikbuf[STD_SIGNED_TIK_SIZE] ATTRIBUTE_ALIGN(0x20); void zero_sig(signed_blob *sig) { - u8 *sig_ptr = (u8 *)sig; - memset(sig_ptr + 4, 0, SIGNATURE_SIZE(sig)-4); + u8 *sig_ptr = (u8 *)sig; + memset(sig_ptr + 4, 0, SIGNATURE_SIZE(sig)-4); } void brute_tmd(tmd *p_tmd) { - u16 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); - SHA1((u8 *)p_tmd, TMD_SIZE(p_tmd), hash);; - - if (hash[0]==0) { - // debug_printf("setting fill3 to %04hx\n", fill); - return; + u16 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); + SHA1((u8 *)p_tmd, TMD_SIZE(p_tmd), hash);; + + if (hash[0]==0) { + // debug_printf("setting fill3 to %04hx\n", fill); + return; + } } - } - printf("Unable to fix tmd :(\n"); - exit(4); + printf("Unable to fix tmd :(\n"); + exit(4); } void brute_tik(tik *p_tik) { - u16 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); - SHA1((u8 *)p_tik, sizeof(tik), hash); - - if (hash[0]==0) return; - } - printf("Unable to fix tik :(\n"); - exit(5); + u16 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); + SHA1((u8 *)p_tik, sizeof(tik), hash); + + if (hash[0]==0) return; + } + printf("Unable to fix tik :(\n"); + exit(5); } - + void forge_tmd(signed_blob *s_tmd) { // debug_printf("forging tmd sig"); - zero_sig(s_tmd); - brute_tmd(SIGNATURE_PAYLOAD(s_tmd)); + zero_sig(s_tmd); + brute_tmd(SIGNATURE_PAYLOAD(s_tmd)); } void forge_tik(signed_blob *s_tik) { // debug_printf("forging tik sig"); - zero_sig(s_tik); - brute_tik(SIGNATURE_PAYLOAD(s_tik)); + zero_sig(s_tik); + brute_tik(SIGNATURE_PAYLOAD(s_tik)); } diff --git a/source/wad/patchmii_core.h b/source/wad/patchmii_core.h index 47488af5..7f45618e 100644 --- a/source/wad/patchmii_core.h +++ b/source/wad/patchmii_core.h @@ -21,16 +21,14 @@ void spinner(void); // Basic I/O. -static inline u32 read32(u32 addr) -{ - u32 x; - asm volatile("lwz %0,0(%1) ; sync" : "=r"(x) : "b"(0xc0000000 | addr)); - return x; +static inline u32 read32(u32 addr) { + u32 x; +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,9 +42,8 @@ extern const char version[]; // Debug: blink the tray led. -static inline void blink(void) -{ - write32(0x0d8000c0, read32(0x0d8000c0) ^ 0x20); +static inline void blink(void) { + write32(0x0d8000c0, read32(0x0d8000c0) ^ 0x20); } void debug_printf(const char *fmt, ...); diff --git a/source/wad/sha1.c b/source/wad/sha1.c index 83a533a7..86b5c46a 100644 --- a/source/wad/sha1.c +++ b/source/wad/sha1.c @@ -42,16 +42,15 @@ A million repetitions of "a" /* Hash a single 512-bit block. This is the core of the algorithm. */ -void SHA1Transform(unsigned long state[5], unsigned char buffer[64]) -{ -unsigned long a, b, c, d, e; -typedef union { - unsigned char c[64]; - unsigned long l[16]; -} CHAR64LONG16; -CHAR64LONG16* block; +void SHA1Transform(unsigned long state[5], unsigned char buffer[64]) { + unsigned long a, b, c, d, e; + typedef union { + unsigned char c[64]; + unsigned long l[16]; + } CHAR64LONG16; + CHAR64LONG16* block; #ifdef SHA1HANDSOFF -static unsigned char workspace[64]; + static unsigned char workspace[64]; block = (CHAR64LONG16*)workspace; memcpy(block, buffer, 64); #else @@ -64,26 +63,86 @@ static unsigned char workspace[64]; d = state[3]; e = state[4]; /* 4 rounds of 20 operations each. Loop unrolled. */ - R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); - R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); - R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); - R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); - R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); - R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); - R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); - R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); - R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); - R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); - R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); - R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); - R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); - R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); - R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); - R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); - R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); - R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); - R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); - R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); + R0(a,b,c,d,e, 0); + R0(e,a,b,c,d, 1); + R0(d,e,a,b,c, 2); + R0(c,d,e,a,b, 3); + R0(b,c,d,e,a, 4); + R0(a,b,c,d,e, 5); + R0(e,a,b,c,d, 6); + R0(d,e,a,b,c, 7); + R0(c,d,e,a,b, 8); + R0(b,c,d,e,a, 9); + R0(a,b,c,d,e,10); + R0(e,a,b,c,d,11); + R0(d,e,a,b,c,12); + R0(c,d,e,a,b,13); + R0(b,c,d,e,a,14); + R0(a,b,c,d,e,15); + R1(e,a,b,c,d,16); + R1(d,e,a,b,c,17); + R1(c,d,e,a,b,18); + R1(b,c,d,e,a,19); + R2(a,b,c,d,e,20); + R2(e,a,b,c,d,21); + R2(d,e,a,b,c,22); + R2(c,d,e,a,b,23); + R2(b,c,d,e,a,24); + R2(a,b,c,d,e,25); + R2(e,a,b,c,d,26); + R2(d,e,a,b,c,27); + R2(c,d,e,a,b,28); + R2(b,c,d,e,a,29); + R2(a,b,c,d,e,30); + R2(e,a,b,c,d,31); + R2(d,e,a,b,c,32); + R2(c,d,e,a,b,33); + R2(b,c,d,e,a,34); + R2(a,b,c,d,e,35); + R2(e,a,b,c,d,36); + R2(d,e,a,b,c,37); + R2(c,d,e,a,b,38); + R2(b,c,d,e,a,39); + R3(a,b,c,d,e,40); + R3(e,a,b,c,d,41); + R3(d,e,a,b,c,42); + R3(c,d,e,a,b,43); + R3(b,c,d,e,a,44); + R3(a,b,c,d,e,45); + R3(e,a,b,c,d,46); + R3(d,e,a,b,c,47); + R3(c,d,e,a,b,48); + R3(b,c,d,e,a,49); + R3(a,b,c,d,e,50); + R3(e,a,b,c,d,51); + R3(d,e,a,b,c,52); + R3(c,d,e,a,b,53); + R3(b,c,d,e,a,54); + R3(a,b,c,d,e,55); + R3(e,a,b,c,d,56); + R3(d,e,a,b,c,57); + R3(c,d,e,a,b,58); + R3(b,c,d,e,a,59); + R4(a,b,c,d,e,60); + R4(e,a,b,c,d,61); + R4(d,e,a,b,c,62); + R4(c,d,e,a,b,63); + R4(b,c,d,e,a,64); + R4(a,b,c,d,e,65); + R4(e,a,b,c,d,66); + R4(d,e,a,b,c,67); + R4(c,d,e,a,b,68); + R4(b,c,d,e,a,69); + R4(a,b,c,d,e,70); + R4(e,a,b,c,d,71); + R4(d,e,a,b,c,72); + R4(c,d,e,a,b,73); + R4(b,c,d,e,a,74); + R4(a,b,c,d,e,75); + R4(e,a,b,c,d,76); + R4(d,e,a,b,c,77); + R4(c,d,e,a,b,78); + R4(b,c,d,e,a,79); /* Add the working vars back into context.state[] */ state[0] += a; state[1] += b; @@ -97,8 +156,7 @@ static unsigned char workspace[64]; /* SHA1Init - Initialize new context */ -void SHA1Init(SHA1_CTX* context) -{ +void SHA1Init(SHA1_CTX* context) { /* SHA1 initialization constants */ context->state[0] = 0x67452301; context->state[1] = 0xEFCDAB89; @@ -111,9 +169,8 @@ void SHA1Init(SHA1_CTX* context) /* Run your data through this. */ -void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len) -{ -unsigned int i, j; +void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len) { + unsigned int i, j; j = (context->count[0] >> 3) & 63; if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++; @@ -125,22 +182,20 @@ unsigned int i, j; SHA1Transform(context->state, &data[i]); } j = 0; - } - else i = 0; + } else i = 0; memcpy(&context->buffer[j], &data[i], len - i); } /* Add padding and return the message digest. */ -void SHA1Final(unsigned char digest[20], SHA1_CTX* context) -{ -unsigned long i, j; -unsigned char finalcount[8]; +void SHA1Final(unsigned char digest[20], SHA1_CTX* context) { + unsigned long i, j; + unsigned char finalcount[8]; for (i = 0; i < 8; i++) { finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)] - >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ + >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ } SHA1Update(context, (unsigned char *)"\200", 1); while ((context->count[0] & 504) != 448) { @@ -149,7 +204,7 @@ unsigned char finalcount[8]; SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */ for (i = 0; i < 20; i++) { digest[i] = (unsigned char) - ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); + ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); } /* Wipe variables */ i = j = 0; @@ -163,10 +218,10 @@ unsigned char finalcount[8]; } void SHA1(unsigned char *ptr, unsigned int size, unsigned char *outbuf) { - SHA1_CTX ctx; - - SHA1Init(&ctx); - SHA1Update(&ctx, ptr, size); - SHA1Final(outbuf, &ctx); + SHA1_CTX ctx; + + SHA1Init(&ctx); + SHA1Update(&ctx, ptr, size); + SHA1Final(outbuf, &ctx); } diff --git a/source/wad/title.c b/source/wad/title.c index 0fdfa9e9..8db49eb6 100644 --- a/source/wad/title.c +++ b/source/wad/title.c @@ -13,596 +13,584 @@ #define MAX_TITLES 256 -s32 Title_GetList(u64 **outbuf, u32 *outlen) -{ - u64 *titles = NULL; +s32 Title_GetList(u64 **outbuf, u32 *outlen) { + u64 *titles = NULL; - u32 len, nb_titles; - s32 ret; + u32 len, nb_titles; + s32 ret; - /* Get number of titles */ - ret = ES_GetNumTitles(&nb_titles); - if (ret < 0) - return ret; + /* Get number of titles */ + ret = ES_GetNumTitles(&nb_titles); + if (ret < 0) + return ret; - /* Calculate buffer lenght */ - len = round_up(sizeof(u64) * nb_titles, 32); + /* Calculate buffer lenght */ + len = round_up(sizeof(u64) * nb_titles, 32); - /* Allocate memory */ - titles = memalign(32, len); - if (!titles) - return -1; + /* Allocate memory */ + titles = memalign(32, len); + if (!titles) + return -1; - /* Get titles */ - ret = ES_GetTitles(titles, nb_titles); - if (ret < 0) - goto err; + /* Get titles */ + ret = ES_GetTitles(titles, nb_titles); + if (ret < 0) + goto err; - /* Set values */ - *outbuf = titles; - *outlen = nb_titles; + /* Set values */ + *outbuf = titles; + *outlen = nb_titles; - return 0; + return 0; err: - /* Free memory */ - if (titles) - free(titles); + /* Free memory */ + if (titles) + free(titles); - return ret; + return ret; } -s32 Title_GetTicketViews(u64 tid, tikview **outbuf, u32 *outlen) -{ - tikview *views = NULL; +s32 Title_GetTicketViews(u64 tid, tikview **outbuf, u32 *outlen) { + tikview *views = NULL; - u32 nb_views; - s32 ret; + u32 nb_views; + s32 ret; - /* Get number of ticket views */ - ret = ES_GetNumTicketViews(tid, &nb_views); - if (ret < 0) - return ret; + /* Get number of ticket views */ + ret = ES_GetNumTicketViews(tid, &nb_views); + if (ret < 0) + return ret; - /* Allocate memory */ - views = (tikview *)memalign(32, sizeof(tikview) * nb_views); - if (!views) - return -1; + /* Allocate memory */ + views = (tikview *)memalign(32, sizeof(tikview) * nb_views); + if (!views) + return -1; - /* Get ticket views */ - ret = ES_GetTicketViews(tid, views, nb_views); - if (ret < 0) - goto err; + /* Get ticket views */ + ret = ES_GetTicketViews(tid, views, nb_views); + if (ret < 0) + goto err; - /* Set values */ - *outbuf = views; - *outlen = nb_views; + /* Set values */ + *outbuf = views; + *outlen = nb_views; - return 0; + return 0; err: - /* Free memory */ - if (views) - free(views); + /* Free memory */ + if (views) + free(views); - return ret; + return ret; } -s32 Title_GetTMD(u64 tid, signed_blob **outbuf, u32 *outlen) -{ - void *p_tmd = NULL; +s32 Title_GetTMD(u64 tid, signed_blob **outbuf, u32 *outlen) { + void *p_tmd = NULL; - u32 len; - s32 ret; + u32 len; + s32 ret; - /* Get TMD size */ - ret = ES_GetStoredTMDSize(tid, &len); - if (ret < 0) - return ret; + /* Get TMD size */ + ret = ES_GetStoredTMDSize(tid, &len); + if (ret < 0) + return ret; - /* Allocate memory */ - p_tmd = memalign(32, round_up(len, 32)); - if (!p_tmd) - return -1; + /* Allocate memory */ + p_tmd = memalign(32, round_up(len, 32)); + if (!p_tmd) + return -1; - /* Read TMD */ - ret = ES_GetStoredTMD(tid, p_tmd, len); - if (ret < 0) - goto err; + /* Read TMD */ + ret = ES_GetStoredTMD(tid, p_tmd, len); + if (ret < 0) + goto err; - /* Set values */ - *outbuf = p_tmd; - *outlen = len; + /* Set values */ + *outbuf = p_tmd; + *outlen = len; - return 0; + return 0; err: - /* Free memory */ - if (p_tmd) - free(p_tmd); + /* Free memory */ + if (p_tmd) + free(p_tmd); - return ret; + return ret; } -s32 Title_GetVersion(u64 tid, u16 *outbuf) -{ - signed_blob *p_tmd = NULL; - tmd *tmd_data = NULL; +s32 Title_GetVersion(u64 tid, u16 *outbuf) { + signed_blob *p_tmd = NULL; + tmd *tmd_data = NULL; - u32 len; - s32 ret; + u32 len; + s32 ret; - /* Get title TMD */ - ret = Title_GetTMD(tid, &p_tmd, &len); - if (ret < 0) - return ret; + /* Get title TMD */ + ret = Title_GetTMD(tid, &p_tmd, &len); + if (ret < 0) + return ret; - /* Retrieve TMD info */ - tmd_data = (tmd *)SIGNATURE_PAYLOAD(p_tmd); + /* Retrieve TMD info */ + tmd_data = (tmd *)SIGNATURE_PAYLOAD(p_tmd); - /* Set values */ - *outbuf = tmd_data->title_version; + /* Set values */ + *outbuf = tmd_data->title_version; - /* Free memory */ - free(p_tmd); + /* Free memory */ + free(p_tmd); - return 0; + return 0; } -s32 Title_GetSysVersion(u64 tid, u64 *outbuf) -{ - signed_blob *p_tmd = NULL; - tmd *tmd_data = NULL; +s32 Title_GetSysVersion(u64 tid, u64 *outbuf) { + signed_blob *p_tmd = NULL; + tmd *tmd_data = NULL; - u32 len; - s32 ret; + u32 len; + s32 ret; - /* Get title TMD */ - ret = Title_GetTMD(tid, &p_tmd, &len); - if (ret < 0) - return ret; + /* Get title TMD */ + ret = Title_GetTMD(tid, &p_tmd, &len); + if (ret < 0) + return ret; - /* Retrieve TMD info */ - tmd_data = (tmd *)SIGNATURE_PAYLOAD(p_tmd); + /* Retrieve TMD info */ + tmd_data = (tmd *)SIGNATURE_PAYLOAD(p_tmd); - /* Set values */ - *outbuf = tmd_data->sys_version; + /* Set values */ + *outbuf = tmd_data->sys_version; - /* Free memory */ - free(p_tmd); + /* Free memory */ + free(p_tmd); - return 0; + return 0; } -s32 Title_GetSize(u64 tid, u32 *outbuf) -{ - signed_blob *p_tmd = NULL; - tmd *tmd_data = NULL; +s32 Title_GetSize(u64 tid, u32 *outbuf) { + signed_blob *p_tmd = NULL; + tmd *tmd_data = NULL; - u32 cnt, len, size = 0; - s32 ret; + u32 cnt, len, size = 0; + s32 ret; - /* Get title TMD */ - ret = Title_GetTMD(tid, &p_tmd, &len); - if (ret < 0) - return ret; + /* Get title TMD */ + ret = Title_GetTMD(tid, &p_tmd, &len); + if (ret < 0) + return ret; - /* Retrieve TMD info */ - tmd_data = (tmd *)SIGNATURE_PAYLOAD(p_tmd); + /* Retrieve TMD info */ + tmd_data = (tmd *)SIGNATURE_PAYLOAD(p_tmd); - /* Calculate title size */ - for (cnt = 0; cnt < tmd_data->num_contents; cnt++) { - tmd_content *content = &tmd_data->contents[cnt]; + /* Calculate title size */ + for (cnt = 0; cnt < tmd_data->num_contents; cnt++) { + tmd_content *content = &tmd_data->contents[cnt]; - /* Add content size */ - size += content->size; - } + /* Add content size */ + size += content->size; + } - /* Set values */ - *outbuf = size; + /* Set values */ + *outbuf = size; - /* Free memory */ - free(p_tmd); + /* Free memory */ + free(p_tmd); - return 0; + return 0; } -s32 Title_GetIOSVersions(u8 **outbuf, u32 *outlen) -{ - u8 *buffer = NULL; - u64 *list = NULL; +s32 Title_GetIOSVersions(u8 **outbuf, u32 *outlen) { + u8 *buffer = NULL; + u64 *list = NULL; - u32 count, cnt, idx; - s32 ret; + u32 count, cnt, idx; + s32 ret; - /* Get title list */ - ret = Title_GetList(&list, &count); - if (ret < 0) - return ret; + /* Get title list */ + ret = Title_GetList(&list, &count); + if (ret < 0) + return ret; - /* Count IOS */ - for (cnt = idx = 0; idx < count; idx++) { - u32 tidh = (list[idx] >> 32); - u32 tidl = (list[idx] & 0xFFFFFFFF); + /* Count IOS */ + for (cnt = idx = 0; idx < count; idx++) { + u32 tidh = (list[idx] >> 32); + u32 tidl = (list[idx] & 0xFFFFFFFF); - /* Title is IOS */ - if ((tidh == 0x1) && (tidl >= 3) && (tidl <= 255)) - cnt++; - } + /* Title is IOS */ + if ((tidh == 0x1) && (tidl >= 3) && (tidl <= 255)) + cnt++; + } - /* Allocate memory */ - buffer = (u8 *)memalign(32, cnt); - if (!buffer) { - ret = -1; - goto out; - } + /* Allocate memory */ + buffer = (u8 *)memalign(32, cnt); + if (!buffer) { + ret = -1; + goto out; + } - /* Copy IOS */ - for (cnt = idx = 0; idx < count; idx++) { - u32 tidh = (list[idx] >> 32); - u32 tidl = (list[idx] & 0xFFFFFFFF); + /* Copy IOS */ + for (cnt = idx = 0; idx < count; idx++) { + u32 tidh = (list[idx] >> 32); + u32 tidl = (list[idx] & 0xFFFFFFFF); - /* Title is IOS */ - if ((tidh == 0x1) && (tidl >= 3) && (tidl <= 255)) - buffer[cnt++] = (u8)(tidl & 0xFF); - } + /* Title is IOS */ + if ((tidh == 0x1) && (tidl >= 3) && (tidl <= 255)) + buffer[cnt++] = (u8)(tidl & 0xFF); + } - /* Set values */ - *outbuf = buffer; - *outlen = cnt; + /* Set values */ + *outbuf = buffer; + *outlen = cnt; - goto out; + goto out; out: - /* Free memory */ - if (list) - free(list); + /* Free memory */ + if (list) + free(list); - return ret; + return ret; } -s32 Uninstall_RemoveTicket(u64 tid) -{ - static tikview viewdata[0x10] ATTRIBUTE_ALIGN(32); +s32 Uninstall_RemoveTicket(u64 tid) { + static tikview viewdata[0x10] ATTRIBUTE_ALIGN(32); - u32 cnt, views; - s32 ret; + u32 cnt, views; + s32 ret; -/* Get number of ticket views */ - ret = ES_GetNumTicketViews(tid, &views); - if (ret < 0) { + /* Get number of ticket views */ + ret = ES_GetNumTicketViews(tid, &views); + if (ret < 0) { - return ret; - } + return ret; + } - if (!views) { - //printf(" No tickets found!\n"); - return 1; - } else if (views > 16) { - //printf(" Too many ticket views! (views = %d)\n", views); - return -1; - } - - /* Get ticket views */ - ret = ES_GetTicketViews(tid, viewdata, views); - if (ret < 0) { - //printf(" \n\tError! ES_GetTicketViews (ret = %d)\n", ret); - return ret; - } + if (!views) { + //printf(" No tickets found!\n"); + return 1; + } else if (views > 16) { + //printf(" Too many ticket views! (views = %d)\n", views); + return -1; + } - /* Remove tickets */ - for (cnt = 0; cnt < views; cnt++) { - ret = ES_DeleteTicket(&viewdata[cnt]); - if (ret < 0) { - //printf(" Error! (view = %d, ret = %d)\n", cnt, ret); - return ret; - } - } - //printf(" OK!\n"); + /* Get ticket views */ + ret = ES_GetTicketViews(tid, viewdata, views); + if (ret < 0) { + //printf(" \n\tError! ES_GetTicketViews (ret = %d)\n", ret); + return ret; + } - return ret; + /* Remove tickets */ + for (cnt = 0; cnt < views; cnt++) { + ret = ES_DeleteTicket(&viewdata[cnt]); + if (ret < 0) { + //printf(" Error! (view = %d, ret = %d)\n", cnt, ret); + return ret; + } + } + //printf(" OK!\n"); + + return ret; } -s32 Uninstall_DeleteTitle(u32 title_u, u32 title_l) -{ - s32 ret; - char filepath[256]; - sprintf(filepath, "/title/%08x/%08x", title_u, title_l); - - /* Remove title */ - ret = ISFS_Delete(filepath); - return ret; +s32 Uninstall_DeleteTitle(u32 title_u, u32 title_l) { + s32 ret; + char filepath[256]; + sprintf(filepath, "/title/%08x/%08x", title_u, title_l); + + /* Remove title */ + ret = ISFS_Delete(filepath); + return ret; } -s32 Uninstall_DeleteTicket(u32 title_u, u32 title_l) -{ - s32 ret; +s32 Uninstall_DeleteTicket(u32 title_u, u32 title_l) { + s32 ret; - char filepath[256]; - sprintf(filepath, "/ticket/%08x/%08x.tik", title_u, title_l); - - /* Delete ticket */ - ret = ISFS_Delete(filepath); + char filepath[256]; + sprintf(filepath, "/ticket/%08x/%08x.tik", title_u, title_l); - return ret; + /* Delete ticket */ + ret = ISFS_Delete(filepath); + + return ret; } //carefull when using this function -//it will force remove stuff even if something fails -s32 Uninstall_FromTitle(const u64 tid) -{ - s32 contents_ret, tik_ret, title_ret, ret; - u32 id = tid & 0xFFFFFFFF, kind = tid >> 32; - contents_ret = tik_ret = title_ret = ret = 0; - - if (kind == 1) - { - // Delete title and ticket at FS level. - tik_ret = Uninstall_DeleteTicket(kind, id); - title_ret = Uninstall_DeleteTitle(kind, id); - contents_ret = title_ret; - } - else - { - // Remove title (contents and ticket) - tik_ret = Uninstall_RemoveTicket(tid); - contents_ret = ES_DeleteTitleContent(tid); - title_ret = ES_DeleteTitle(tid); - - - // Attempt forced uninstall if something fails - if (tik_ret < 0 || contents_ret < 0 || title_ret < 0){ - tik_ret = Uninstall_DeleteTicket(kind, id); - title_ret = Uninstall_DeleteTitle(kind, id); - contents_ret = title_ret; - - } - } - if (tik_ret < 0 && contents_ret < 0 && title_ret < 0) - ret = -1; - else if (tik_ret < 0 || contents_ret < 0 || title_ret < 0) - ret = 1; - else - ret = 0; - - return ret; +//it will force remove stuff even if something fails +s32 Uninstall_FromTitle(const u64 tid) { + s32 contents_ret, tik_ret, title_ret, ret; + u32 id = tid & 0xFFFFFFFF, kind = tid >> 32; + contents_ret = tik_ret = title_ret = ret = 0; + + if (kind == 1) { + // Delete title and ticket at FS level. + tik_ret = Uninstall_DeleteTicket(kind, id); + title_ret = Uninstall_DeleteTitle(kind, id); + contents_ret = title_ret; + } else { + // Remove title (contents and ticket) + tik_ret = Uninstall_RemoveTicket(tid); + contents_ret = ES_DeleteTitleContent(tid); + title_ret = ES_DeleteTitle(tid); + + + // Attempt forced uninstall if something fails + if (tik_ret < 0 || contents_ret < 0 || title_ret < 0) { + tik_ret = Uninstall_DeleteTicket(kind, id); + title_ret = Uninstall_DeleteTitle(kind, id); + contents_ret = title_ret; + + } + } + if (tik_ret < 0 && contents_ret < 0 && title_ret < 0) + ret = -1; + else if (tik_ret < 0 || contents_ret < 0 || title_ret < 0) + ret = 1; + else + ret = 0; + + return ret; } /*------------------------------------------------------------- taken from anytitledeleter name.c -- functions for determining the name of a title - + Copyright (C) 2009 MrClick - + -------------------------------------------------------------*/ -s32 __convertWiiString(char *str, u8 *data, u32 cnt){ - u32 i = 0; - for(; i < cnt; data += 2){ - u16 *chr = (u16*)data; - if (*chr == 0) - break; - // ignores all but ASCII characters - else if (*chr >= 0x20 && *chr <= 0x7E) - str[i] = *chr; - else - str[i] = '.'; - i++; - } - str[i] = 0; - - return 0; +s32 __convertWiiString(char *str, u8 *data, u32 cnt) { + u32 i = 0; + for (; i < cnt; data += 2) { + u16 *chr = (u16*)data; + if (*chr == 0) + break; + // ignores all but ASCII characters + else if (*chr >= 0x20 && *chr <= 0x7E) + str[i] = *chr; + else + str[i] = '.'; + i++; + } + str[i] = 0; + + return 0; } -s32 getNameBN(char* name, u64 id){ - // Terminate the name string just in case the function exits prematurely - name[0] = 0; +s32 getNameBN(char* name, u64 id) { + // Terminate the name string just in case the function exits prematurely + name[0] = 0; - // Create a string containing the absolute filename - char file[256] __attribute__ ((aligned (32))); - sprintf(file, "/title/%08x/%08x/data/banner.bin", (u32)(id >> 32), (u32)id); - - // Bring the Wii into the title's userspace - if (ES_SetUID(id) < 0){ - // Should that fail repeat after setting permissions to system menu mode - Identify_SysMenu(); - if (ES_SetUID(id) < 0) - return -1; - } - - // Try to open file - s32 fh = ISFS_Open(file, ISFS_OPEN_READ); - - // If a title does not have a banner.bin bail out - if (fh == -106) - return -2; - - // If it fails try to open again after identifying as SU - if (fh == -102){ - Identify_SU(); - fh = ISFS_Open(file, ISFS_OPEN_READ); - } - // If the file won't open - else if (fh < 0) - return fh; + // Create a string containing the absolute filename + char file[256] __attribute__ ((aligned (32))); + sprintf(file, "/title/%08x/%08x/data/banner.bin", (u32)(id >> 32), (u32)id); - // Seek to 0x20 where the name is stored - ISFS_Seek(fh, 0x20, 0); + // Bring the Wii into the title's userspace + if (ES_SetUID(id) < 0) { + // Should that fail repeat after setting permissions to system menu mode + Identify_SysMenu(); + if (ES_SetUID(id) < 0) + return -1; + } - // Read a chunk of 256 bytes from the banner.bin - u8 *data = memalign(32, 0x100); - if (ISFS_Read(fh, data, 0x100) < 0){ - ISFS_Close(fh); - free(data); - return -3; - } - - - // Prepare the strings that will contain the name of the title - char name1[0x41] __attribute__ ((aligned (32))); - char name2[0x41] __attribute__ ((aligned (32))); - name1[0x40] = 0; - name2[0x40] = 0; + // Try to open file + s32 fh = ISFS_Open(file, ISFS_OPEN_READ); - __convertWiiString(name1, data + 0x00, 0x40); - __convertWiiString(name2, data + 0x40, 0x40); - free(data); - - // Assemble name - sprintf(name, "%s", name1); - if (strlen(name2) > 1) - sprintf(name, "%s (%s)", name, name2); + // If a title does not have a banner.bin bail out + if (fh == -106) + return -2; - // Close the banner.bin - ISFS_Close(fh); + // If it fails try to open again after identifying as SU + if (fh == -102) { + Identify_SU(); + fh = ISFS_Open(file, ISFS_OPEN_READ); + } + // If the file won't open + else if (fh < 0) + return fh; - // Job well done - return 1; + // Seek to 0x20 where the name is stored + ISFS_Seek(fh, 0x20, 0); + + // Read a chunk of 256 bytes from the banner.bin + u8 *data = memalign(32, 0x100); + if (ISFS_Read(fh, data, 0x100) < 0) { + ISFS_Close(fh); + free(data); + return -3; + } + + + // Prepare the strings that will contain the name of the title + char name1[0x41] __attribute__ ((aligned (32))); + char name2[0x41] __attribute__ ((aligned (32))); + name1[0x40] = 0; + name2[0x40] = 0; + + __convertWiiString(name1, data + 0x00, 0x40); + __convertWiiString(name2, data + 0x40, 0x40); + free(data); + + // Assemble name + sprintf(name, "%s", name1); + if (strlen(name2) > 1) + sprintf(name, "%s (%s)", name, name2); + + // Close the banner.bin + ISFS_Close(fh); + + // Job well done + return 1; } -s32 getName00(char* name, u64 id, int lang){ -/* -languages -0jap -2eng -4german -6french -8spanish -10italian -12dutch -*/ - // Create a string containing the absolute filename - char file[256] __attribute__ ((aligned (32))); - sprintf(file, "/title/%08x/%08x/content/00000000.app", (u32)(id >> 32), (u32)id); - Identify_SU(); - s32 fh = ISFS_Open(file, ISFS_OPEN_READ); - - - - // If the title does not have 00000000.app bail out - if (fh == -106) - return fh; - - // In case there is some problem with the permission - if (fh == -102){ - // Identify as super user - Identify_SU(); - fh = ISFS_Open(file, ISFS_OPEN_READ); - } - else if (fh < 0) - return fh; - - // Jump to start of the name entries - ISFS_Seek(fh, 0x9C, 0); +s32 getName00(char* name, u64 id, int lang) { + /* + languages + 0jap + 2eng + 4german + 6french + 8spanish + 10italian + 12dutch + */ + // Create a string containing the absolute filename + char file[256] __attribute__ ((aligned (32))); + sprintf(file, "/title/%08x/%08x/content/00000000.app", (u32)(id >> 32), (u32)id); + Identify_SU(); + s32 fh = ISFS_Open(file, ISFS_OPEN_READ); - // Read a chunk of 0x22 * 0x2B bytes from 00000000.app - u8 *data = memalign(32, 2048); - s32 r = ISFS_Read(fh, data, 0x22 * 0x2B); - //printf("%s %d\n", file, r);wait_anyKey(); - if (r < 0){ - ISFS_Close(fh); - free(data); - return -4; - } - // Take the entries apart - char str[0x22][0x2B]; - u8 i = 0; - // Convert the entries to ASCII strings - for(; i < 0x22; i++) - __convertWiiString(str[i], data + (i * 0x2A), 0x2A); - - // Clean up - ISFS_Close(fh); - free(data); - - // Assemble name - if(strlen(str[lang]) > 1){ - sprintf(name, "%s", str[lang]); - if (strlen(str[lang+1]) > 1) - sprintf(name, "%s (%s)", name, str[lang+1]); - } - else{ - sprintf(name, "%s", str[2]); - if (strlen(str[3]) > 1) - sprintf(name, "%s (%s)", name, str[3]); - } - // Job well done - return 2; + + // If the title does not have 00000000.app bail out + if (fh == -106) + return fh; + + // In case there is some problem with the permission + if (fh == -102) { + // Identify as super user + Identify_SU(); + fh = ISFS_Open(file, ISFS_OPEN_READ); + } else if (fh < 0) + return fh; + + // Jump to start of the name entries + ISFS_Seek(fh, 0x9C, 0); + + // Read a chunk of 0x22 * 0x2B bytes from 00000000.app + u8 *data = memalign(32, 2048); + s32 r = ISFS_Read(fh, data, 0x22 * 0x2B); + //printf("%s %d\n", file, r);wait_anyKey(); + if (r < 0) { + ISFS_Close(fh); + free(data); + return -4; + } + + // Take the entries apart + char str[0x22][0x2B]; + u8 i = 0; + // Convert the entries to ASCII strings + for (; i < 0x22; i++) + __convertWiiString(str[i], data + (i * 0x2A), 0x2A); + + // Clean up + ISFS_Close(fh); + free(data); + + // Assemble name + if (strlen(str[lang]) > 1) { + sprintf(name, "%s", str[lang]); + if (strlen(str[lang+1]) > 1) + sprintf(name, "%s (%s)", name, str[lang+1]); + } else { + sprintf(name, "%s", str[2]); + if (strlen(str[3]) > 1) + sprintf(name, "%s (%s)", name, str[3]); + } + // Job well done + return 2; } -s32 printContent(u64 tid){ - char dir[256] __attribute__ ((aligned (32))); - sprintf(dir, "/title/%08x/%08x/content", (u32)(tid >> 32), (u32)tid); +s32 printContent(u64 tid) { + char dir[256] __attribute__ ((aligned (32))); + sprintf(dir, "/title/%08x/%08x/content", (u32)(tid >> 32), (u32)tid); - u32 num = 64; - - static char list[8000] __attribute__((aligned(32))); + u32 num = 64; - ISFS_ReadDir(dir, list, &num); - - char *ptr = list; - u8 br = 0; - for (; strlen(ptr) > 0; ptr += strlen(ptr) + 1){ - printf(" %-12.12s", ptr); - br++; if (br == 4) { br = 0; printf("\n"); } - } - if (br != 0) - printf("\n"); - - return num; + static char list[8000] __attribute__((aligned(32))); + + ISFS_ReadDir(dir, list, &num); + + char *ptr = list; + u8 br = 0; + for (; strlen(ptr) > 0; ptr += strlen(ptr) + 1) { + printf(" %-12.12s", ptr); + br++; + if (br == 4) { + br = 0; + printf("\n"); + } + } + if (br != 0) + printf("\n"); + + return num; } -char *titleText(u32 kind, u32 title){ - static char text[10]; - - if (kind == 1){ - // If we're dealing with System Titles, use custom names - switch (title){ - case 1: - strcpy(text, "BOOT2"); - break; - case 2: - strcpy(text, "SYSMENU"); - break; - case 0x100: - strcpy(text, "BC"); - break; - case 0x101: - strcpy(text, "MIOS"); - break; - default: - sprintf(text, "IOS%u", title); - break; - } - } else { - // Otherwise, just convert the title to ASCII - int i =32, j = 0; - do { - u8 temp; - i -= 8; - temp = (title >> i) & 0x000000FF; - if (temp < 32 || temp > 126) - text[j] = '.'; - else - text[j] = temp; - j++; - } while (i > 0); - text[4] = 0; - } - return text; +char *titleText(u32 kind, u32 title) { + static char text[10]; + + if (kind == 1) { + // If we're dealing with System Titles, use custom names + switch (title) { + case 1: + strcpy(text, "BOOT2"); + break; + case 2: + strcpy(text, "SYSMENU"); + break; + case 0x100: + strcpy(text, "BC"); + break; + case 0x101: + strcpy(text, "MIOS"); + break; + default: + sprintf(text, "IOS%u", title); + break; + } + } else { + // Otherwise, just convert the title to ASCII + int i =32, j = 0; + do { + u8 temp; + i -= 8; + temp = (title >> i) & 0x000000FF; + if (temp < 32 || temp > 126) + text[j] = '.'; + else + text[j] = temp; + j++; + } while (i > 0); + text[4] = 0; + } + return text; } /*------------------------------------------------------------- from any title deleter titles.c -- functions for grabbing all titles of a certain type - + Copyright (C) 2008 tona -------------------------------------------------------------*/ @@ -611,67 +599,67 @@ u32 __num_titles; static u64 __title_list[MAX_TITLES] ATTRIBUTE_ALIGN(32); s32 __getTitles() { - s32 ret; - ret = ES_GetNumTitles(&__num_titles); - if (ret <0) - return ret; - if (__num_titles > MAX_TITLES) - return -1; - ret = ES_GetTitles(__title_list, __num_titles); - if (ret <0) - return ret; - __titles_init = 1; - return 0; + s32 ret; + ret = ES_GetNumTitles(&__num_titles); + if (ret <0) + return ret; + if (__num_titles > MAX_TITLES) + return -1; + ret = ES_GetTitles(__title_list, __num_titles); + if (ret <0) + return ret; + __titles_init = 1; + return 0; } s32 getTitles_TypeCount(u32 type, u32 *count) { - s32 ret = 0; - u32 type_count; - if (!__titles_init) - ret = __getTitles(); - if (ret <0) - return ret; - int i; - type_count = 0; - for (i=0; i < __num_titles; i++) { - u32 upper, lower; - upper = __title_list[i] >> 32; - lower = __title_list[i] & 0xFFFFFFFF; - if((upper == type)&& - ((lower !=0x48414741)&&//this filters out haga,haaa, hafa. dupe factory channels that don't load - (lower !=0x48414141)&&//since we dont care about apps that dont load for what we are doing - (lower !=0x48414641))) - type_count++; - } - *count = type_count; - return ret; + s32 ret = 0; + u32 type_count; + if (!__titles_init) + ret = __getTitles(); + if (ret <0) + return ret; + int i; + type_count = 0; + for (i=0; i < __num_titles; i++) { + u32 upper, lower; + upper = __title_list[i] >> 32; + lower = __title_list[i] & 0xFFFFFFFF; + if ((upper == type)&& + ((lower !=0x48414741)&&//this filters out haga,haaa, hafa. dupe factory channels that don't load + (lower !=0x48414141)&&//since we dont care about apps that dont load for what we are doing + (lower !=0x48414641))) + type_count++; + } + *count = type_count; + return ret; } - + s32 getTitles_Type(u32 type, u32 *titles, u32 count) { - s32 ret = 0; - u32 type_count; - if (!__titles_init) - ret = __getTitles(); - if (ret <0) - return ret; - int i; - type_count = 0; - for (i=0; type_count < count && i < __num_titles; i++) { - u32 upper, lower; - upper = __title_list[i] >> 32; - lower = __title_list[i] & 0xFFFFFFFF; - if((upper == type)&& - ((lower !=0x48414741)&& - (lower !=0x48414141)&& - (lower !=0x48414641))) { - titles[type_count]=lower; - type_count++; - } - } - if (type_count < count) - return -2; - __titles_init = 0; - return 0; + s32 ret = 0; + u32 type_count; + if (!__titles_init) + ret = __getTitles(); + if (ret <0) + return ret; + int i; + type_count = 0; + for (i=0; type_count < count && i < __num_titles; i++) { + u32 upper, lower; + upper = __title_list[i] >> 32; + lower = __title_list[i] & 0xFFFFFFFF; + if ((upper == type)&& + ((lower !=0x48414741)&& + (lower !=0x48414141)&& + (lower !=0x48414641))) { + titles[type_count]=lower; + type_count++; + } + } + if (type_count < count) + return -2; + __titles_init = 0; + return 0; } diff --git a/source/wad/title.h b/source/wad/title.h index 3eb76a4b..03a48198 100644 --- a/source/wad/title.h +++ b/source/wad/title.h @@ -1,7 +1,7 @@ /*------------------------------------------------------------- from any title deleter and wad manager 1.4 -title.h -- - +title.h -- + Copyright (C) 2008 tona and/or waninkoko -------------------------------------------------------------*/ #include @@ -21,49 +21,48 @@ Copyright (C) 2008 tona and/or waninkoko #define MAX_TITLES 100 #ifndef _TITLE_H_ -#define _TITLE_H_ +#define _TITLE_H_ -#ifdef __cplusplus -extern "C" -{ +#ifdef __cplusplus +extern "C" { #endif -/* Constants */ + /* Constants */ #define BLOCK_SIZE 1024 -/* Prototypes */ -s32 Title_GetList(u64 **, u32 *); -s32 Title_GetTicketViews(u64, tikview **, u32 *); -s32 Title_GetTMD(u64, signed_blob **, u32 *); -s32 Title_GetVersion(u64, u16 *); -s32 Title_GetSysVersion(u64, u64 *); -s32 Title_GetSize(u64, u32 *); -s32 Title_GetIOSVersions(u8 **, u32 *); + /* Prototypes */ + s32 Title_GetList(u64 **, u32 *); + s32 Title_GetTicketViews(u64, tikview **, u32 *); + s32 Title_GetTMD(u64, signed_blob **, u32 *); + s32 Title_GetVersion(u64, u16 *); + s32 Title_GetSysVersion(u64, u64 *); + s32 Title_GetSize(u64, u32 *); + s32 Title_GetIOSVersions(u8 **, u32 *); // Get the name of a title from its banner.bin in NAND -s32 getNameBN(char *name, u64 id); + s32 getNameBN(char *name, u64 id); // Get the name of a title from its 00000000.app in NAND -s32 getName00(char *name, u64 id, int lang = 2); + s32 getName00(char *name, u64 id, int lang = 2); // Get string representation of lower title id -char *titleText(u32 kind, u32 title); + char *titleText(u32 kind, u32 title); // Converts a 16 bit Wii string to a printable 8 bit string -s32 __convertWiiString(char *str, u8 *data, u32 cnt); + s32 __convertWiiString(char *str, u8 *data, u32 cnt); // Get the number of titles on the Wii of a given type -s32 getTitles_TypeCount(u32 type, u32 *count); + s32 getTitles_TypeCount(u32 type, u32 *count); // Get the list of titles of this type -s32 getTitles_Type(u32 type, u32 *titles, u32 count); + s32 getTitles_Type(u32 type, u32 *titles, u32 count); //returns a name for a title -char *__getTitleName(u64 titleid, int language); + char *__getTitleName(u64 titleid, int language); -s32 Uninstall_FromTitle(const u64 tid); - -#ifdef __cplusplus -} -#endif - -#endif + s32 Uninstall_FromTitle(const u64 tid); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/source/wad/utils.h b/source/wad/utils.h index 46a29463..d4208bd8 100644 --- a/source/wad/utils.h +++ b/source/wad/utils.h @@ -1,23 +1,22 @@ -#ifndef _UTILS_H_ +#ifndef _UTILS_H_ #define _UTILS_H_ #ifdef __cplusplus -extern "C" -{ -#endif -/* Constants */ +extern "C" { +#endif + /* Constants */ #define KB_SIZE 1024.0 #define MB_SIZE 1048576.0 #define GB_SIZE 1073741824.0 -/* Macros */ + /* Macros */ #define round_up(x,n) (-(-(x) & -(n))) -/* Prototypes */ -u32 swap32(u32); - -#ifdef __cplusplus -} -#endif - + /* Prototypes */ + u32 swap32(u32); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/source/wad/wad.cpp b/source/wad/wad.cpp index 80e8f277..66bd6895 100644 --- a/source/wad/wad.cpp +++ b/source/wad/wad.cpp @@ -117,164 +117,6 @@ out: return ret; } - -/*s32 Wad_Install(FILE *fp) -{ - wadHeader *header = NULL; - signed_blob *p_certs = NULL, *p_crl = NULL, *p_tik = NULL, *p_tmd = NULL; - - tmd *tmd_data = NULL; - - u32 cnt, offset = 0; - s32 ret = 666; - - //WindowPrompt("Here we go...","don't turn off your Wii",0,0,0,0,200); - // WAD header - //ret = __Wad_ReadAlloc(fp, (void *)header, offset, sizeof(wadHeader)); - ret = __Wad_ReadAlloc(fp, (void **)&header, offset, sizeof(wadHeader)); - - if (ret < 0) - goto err; - else - offset += round_up(header->header_len, 64); - - // WAD certificates - //ret = __Wad_ReadAlloc(fp, (void *)&p_certs, offset, header->certs_len); - ret = __Wad_ReadAlloc(fp, (void **)&p_certs, offset, header->certs_len); - if (ret < 0) - goto err; - else - offset += round_up(header->certs_len, 64); - - // WAD crl - - if (header->crl_len) { - //ret = __Wad_ReadAlloc(fp, (void *)&p_crl, offset, header->crl_len); - ret = __Wad_ReadAlloc(fp, (void **)&p_crl, offset, header->crl_len); - if (ret < 0) - goto err; - else - offset += round_up(header->crl_len, 64); - } - - // WAD ticket - //ret = __Wad_ReadAlloc(fp, (void *)&p_tik, offset, header->tik_len); - ret = __Wad_ReadAlloc(fp, (void **)&p_tik, offset, header->tik_len); - if (ret < 0) - goto err; - else - offset += round_up(header->tik_len, 64); - - // WAD TMD - //ret = __Wad_ReadAlloc(fp, (void *)&p_tmd, offset, header->tmd_len); - ret = __Wad_ReadAlloc(fp, (void **)&p_tmd, offset, header->tmd_len); - if (ret < 0) - goto err; - else - offset += round_up(header->tmd_len, 64); - - //WindowPrompt("Installing ticket...",0,0,0,0,0,200); - - // Install ticket - ret = ES_AddTicket(p_tik, header->tik_len, p_certs, header->certs_len, p_crl, header->crl_len); - if (ret < 0) - goto err; - - //WindowPrompt(">> Installing title...",0,0,0,0,0,200); - - // Install title - ret = ES_AddTitleStart(p_tmd, header->tmd_len, p_certs, header->certs_len, p_crl, header->crl_len); - if (ret < 0) - goto err; - - // Get TMD info - tmd_data = (tmd *)SIGNATURE_PAYLOAD(p_tmd); - - // Install contents - for (cnt = 0; cnt < tmd_data->num_contents; cnt++) { - tmd_content *content = &tmd_data->contents[cnt]; - - u32 idx = 0, len; - s32 cfd; - - //printf("\r\t\t>> Installing content #%02d...", content->cid); - - // Encrypted content size - len = round_up(content->size, 64); - - // Install content - cfd = ES_AddContentStart(tmd_data->title_id, content->cid); - if (cfd < 0) { - ret = cfd; - goto err; - } - - // Install content data - while (idx < len) { - u32 size; - - // Data length - size = (len - idx); - if (size > BLOCK_SIZE) - size = BLOCK_SIZE; - - // Read data - ret = __Wad_ReadFile(fp, &wadBuffer, offset, size); - if (ret < 0) - goto err; - - // Install data - ret = ES_AddContentData(cfd, wadBuffer, size); - if (ret < 0) - goto err; - - // Increase variables - idx += size; - offset += size; - } - - // Finish content installation - ret = ES_AddContentFinish(cfd); - if (ret < 0) - goto err; - } - - //WindowPrompt(">> Finishing installation...",0,0,0,0,0,200); - - // Finish title install - ret = ES_AddTitleFinish(); - if (ret >= 0) { -// printf(" OK!\n"); - goto out; - } - -err: - //char titties[100]; - //snprintf(titties, sizeof(titties), "%d", ret); - //printf(" ERROR! (ret = %d)\n", ret); - //WindowPrompt("ERROR!",titties,"Back",0,0); - // Cancel install - ES_AddTitleCancel(); - return ret; - -out: - // Free memory - if (header) - free(header); - if (p_certs) - free(p_certs); - if (p_crl) - free(p_crl); - if (p_tik) - free(p_tik); - if (p_tmd) - free(p_tmd); - - //WindowPrompt(tr("Success"),"The wad file was installed","Ok"); - return ret; -}*/ - - s32 Wad_Install(FILE *fp) { //////start the gui shit @@ -575,11 +417,8 @@ out: free(p_tmd); goto exit; - //WindowPrompt(tr("Success"),"The wad file was installed","Ok"); exit: - //promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - //while(promptWindow.GetEffect() > 0) usleep(50); msg5Txt.SetText(tr("Finishing installation... Ok!")); promptWindow.Append(&btn1); while(btn1.GetState() != STATE_CLICKED){ @@ -598,7 +437,6 @@ exit: s32 Wad_Uninstall(FILE *fp) { //////start the gui shit - //////start the gui shit GuiWindow promptWindow(472,320); promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); promptWindow.SetPosition(0, -10); @@ -778,11 +616,8 @@ out: goto exit; - //WindowPrompt(tr("Success"),"The wad file was installed","Ok"); exit: - //promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - //while(promptWindow.GetEffect() > 0) usleep(50); msg5Txt.SetText(tr("Done!")); promptWindow.Append(&btn1); while(btn1.GetState() != STATE_CLICKED){ diff --git a/source/wpad.c b/source/wpad.c index 82cb5416..2801eae4 100644 --- a/source/wpad.c +++ b/source/wpad.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include "sys.h" @@ -8,82 +8,76 @@ /* Constants */ #define MAX_WIIMOTES 4 -extern u8 shutdown; +extern u8 shutdown; -void __Wpad_PowerCallback(s32 chan) -{ - /* Poweroff console */ - shutdown = 1; +void __Wpad_PowerCallback(s32 chan) { + /* Poweroff console */ + shutdown = 1; } -void WPad_SetIdleTime(u32 seconds) -{ - /*Set idle time for wiimote*/ - WPAD_SetIdleTimeout(seconds); -} - -s32 Wpad_Init(void) -{ - s32 ret; - - /* Initialize Wiimote subsystem */ - ret = WPAD_Init(); - if (ret < 0) - return ret; - - /* Set POWER button callback */ - WPAD_SetPowerButtonCallback(__Wpad_PowerCallback); - - return ret; +void WPad_SetIdleTime(u32 seconds) { + /*Set idle time for wiimote*/ + WPAD_SetIdleTimeout(seconds); } -void Wpad_Disconnect(void) -{ - u32 cnt; +s32 Wpad_Init(void) { + s32 ret; - /* Disconnect Wiimotes */ - for (cnt = 0; cnt < MAX_WIIMOTES; cnt++) - WPAD_Disconnect(cnt); + /* Initialize Wiimote subsystem */ + ret = WPAD_Init(); + if (ret < 0) + return ret; - /* Shutdown Wiimote subsystem */ - WPAD_Shutdown(); -} - -bool IsWpadConnected() -{ - int i = 0; - u32 test = 0; - int notconnected = 0; - #ifdef HW_RVL - for(i = 0; i < 4; i++) { - if(WPAD_Probe(i, &test) == WPAD_ERR_NO_CONTROLLER) { - notconnected++; - } + /* Set POWER button callback */ + WPAD_SetPowerButtonCallback(__Wpad_PowerCallback); + + return ret; +} + +void Wpad_Disconnect(void) { + u32 cnt; + + /* Disconnect Wiimotes */ + for (cnt = 0; cnt < MAX_WIIMOTES; cnt++) + WPAD_Disconnect(cnt); + + /* Shutdown Wiimote subsystem */ + WPAD_Shutdown(); +} + +bool IsWpadConnected() { + int i = 0; + u32 test = 0; + int notconnected = 0; +#ifdef HW_RVL + for (i = 0; i < 4; i++) { + if (WPAD_Probe(i, &test) == WPAD_ERR_NO_CONTROLLER) { + notconnected++; + } + } +#endif + if (notconnected < 4) + return true; + else + return false; +} + +u32 ButtonsHold(void) { + + int i; + u32 buttons = 0; + +#ifdef HW_RVL + WPAD_ScanPads(); +#endif + PAD_ScanPads(); + + for (i=3; i >= 0; i--) { + buttons |= PAD_ButtonsHeld(i); +#ifdef HW_RVL + buttons |= WPAD_ButtonsHeld(i); +#endif } - #endif - if(notconnected < 4) - return true; - else - return false; -} - -u32 ButtonsHold(void) { - - int i; - u32 buttons = 0; - - #ifdef HW_RVL - WPAD_ScanPads(); - #endif - PAD_ScanPads(); - - for(i=3; i >= 0; i--) - { - buttons |= PAD_ButtonsHeld(i); - #ifdef HW_RVL - buttons |= WPAD_ButtonsHeld(i); - #endif - } return buttons; } @@ -92,42 +86,41 @@ u32 ButtonsPressed(void) { int i; u32 buttons = 0; - #ifdef HW_RVL +#ifdef HW_RVL WPAD_ScanPads(); - #endif +#endif PAD_ScanPads(); - for(i=3; i >= 0; i--) - { - buttons |= PAD_ButtonsDown(i); - #ifdef HW_RVL - buttons |= WPAD_ButtonsDown(i); - #endif - } + for (i=3; i >= 0; i--) { + buttons |= PAD_ButtonsDown(i); +#ifdef HW_RVL + buttons |= WPAD_ButtonsDown(i); +#endif + } return buttons; -/* Don't remove this commented out code it might be useful for checking which buttons were pressed/hold + /* Don't remove this commented out code it might be useful for checking which buttons were pressed/hold - if(buttons & (PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT | PAD_BUTTON_DOWN | PAD_BUTTON_UP - | PAD_BUTTON_A | PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_Y | PAD_BUTTON_MENU - | PAD_BUTTON_START | WPAD_BUTTON_2 | WPAD_BUTTON_1 - | WPAD_BUTTON_B | WPAD_BUTTON_A | WPAD_BUTTON_MINUS - | WPAD_BUTTON_HOME | WPAD_BUTTON_LEFT | WPAD_BUTTON_RIGHT - | WPAD_BUTTON_DOWN | WPAD_BUTTON_UP | WPAD_BUTTON_PLUS - | WPAD_NUNCHUK_BUTTON_Z | WPAD_NUNCHUK_BUTTON_C - | WPAD_CLASSIC_BUTTON_UP | WPAD_CLASSIC_BUTTON_LEFT - | WPAD_CLASSIC_BUTTON_ZR | WPAD_CLASSIC_BUTTON_X - | WPAD_CLASSIC_BUTTON_A | WPAD_CLASSIC_BUTTON_Y - | WPAD_CLASSIC_BUTTON_B | WPAD_CLASSIC_BUTTON_ZL - | WPAD_CLASSIC_BUTTON_FULL_R | WPAD_CLASSIC_BUTTON_PLUS - | WPAD_CLASSIC_BUTTON_HOME | WPAD_CLASSIC_BUTTON_MINUS - | WPAD_CLASSIC_BUTTON_FULL_L | WPAD_CLASSIC_BUTTON_DOWN - | WPAD_CLASSIC_BUTTON_RIGHT | WPAD_GUITAR_HERO_3_BUTTON_STRUM_UP - | WPAD_GUITAR_HERO_3_BUTTON_YELLOW | WPAD_GUITAR_HERO_3_BUTTON_GREEN - | WPAD_GUITAR_HERO_3_BUTTON_BLUE | WPAD_GUITAR_HERO_3_BUTTON_RED - | WPAD_GUITAR_HERO_3_BUTTON_ORANGE | WPAD_GUITAR_HERO_3_BUTTON_PLUS - | WPAD_GUITAR_HERO_3_BUTTON_MINUS | WPAD_GUITAR_HERO_3_BUTTON_STRUM_DOWN) - ) -*/ + if(buttons & (PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT | PAD_BUTTON_DOWN | PAD_BUTTON_UP + | PAD_BUTTON_A | PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_Y | PAD_BUTTON_MENU + | PAD_BUTTON_START | WPAD_BUTTON_2 | WPAD_BUTTON_1 + | WPAD_BUTTON_B | WPAD_BUTTON_A | WPAD_BUTTON_MINUS + | WPAD_BUTTON_HOME | WPAD_BUTTON_LEFT | WPAD_BUTTON_RIGHT + | WPAD_BUTTON_DOWN | WPAD_BUTTON_UP | WPAD_BUTTON_PLUS + | WPAD_NUNCHUK_BUTTON_Z | WPAD_NUNCHUK_BUTTON_C + | WPAD_CLASSIC_BUTTON_UP | WPAD_CLASSIC_BUTTON_LEFT + | WPAD_CLASSIC_BUTTON_ZR | WPAD_CLASSIC_BUTTON_X + | WPAD_CLASSIC_BUTTON_A | WPAD_CLASSIC_BUTTON_Y + | WPAD_CLASSIC_BUTTON_B | WPAD_CLASSIC_BUTTON_ZL + | WPAD_CLASSIC_BUTTON_FULL_R | WPAD_CLASSIC_BUTTON_PLUS + | WPAD_CLASSIC_BUTTON_HOME | WPAD_CLASSIC_BUTTON_MINUS + | WPAD_CLASSIC_BUTTON_FULL_L | WPAD_CLASSIC_BUTTON_DOWN + | WPAD_CLASSIC_BUTTON_RIGHT | WPAD_GUITAR_HERO_3_BUTTON_STRUM_UP + | WPAD_GUITAR_HERO_3_BUTTON_YELLOW | WPAD_GUITAR_HERO_3_BUTTON_GREEN + | WPAD_GUITAR_HERO_3_BUTTON_BLUE | WPAD_GUITAR_HERO_3_BUTTON_RED + | WPAD_GUITAR_HERO_3_BUTTON_ORANGE | WPAD_GUITAR_HERO_3_BUTTON_PLUS + | WPAD_GUITAR_HERO_3_BUTTON_MINUS | WPAD_GUITAR_HERO_3_BUTTON_STRUM_DOWN) + ) + */ -} +} diff --git a/source/wpad.h b/source/wpad.h index 5669a2a1..c054d83a 100644 --- a/source/wpad.h +++ b/source/wpad.h @@ -2,22 +2,21 @@ #define _WPAD_H_ #include - -#ifdef __cplusplus -extern "C" -{ + +#ifdef __cplusplus +extern "C" { #endif -/* Prototypes */ -s32 Wpad_Init(void); -void Wpad_Disconnect(void); -u32 ButtonsPressed(void); -u32 ButtonsHold(void); -bool IsWpadConnected(); -void WPad_SetIdleTime(u32 seconds); - + /* Prototypes */ + s32 Wpad_Init(void); + void Wpad_Disconnect(void); + u32 ButtonsPressed(void); + u32 ButtonsHold(void); + bool IsWpadConnected(); + void WPad_SetIdleTime(u32 seconds); + #ifdef __cplusplus } #endif -#endif +#endif diff --git a/source/xml/xml.c b/source/xml/xml.c index da6cb8dc..3ba965bc 100644 --- a/source/xml/xml.c +++ b/source/xml/xml.c @@ -23,31 +23,31 @@ extern struct SSettings Settings; // for loader GX struct gameXMLinfo gameinfo; struct gameXMLinfo gameinfo_reset; -static char langlist[11][22] = -{{"Console Default"}, -{"Japanese"}, -{"English"}, -{"German"}, -{"French"}, -{"Spanish"}, -{"Italian"}, -{"Dutch"}, -{"S. Chinese"}, -{"T. Chinese"}, -{"Korean"}}; +static char langlist[11][22] = {{"Console Default"}, + {"Japanese"}, + {"English"}, + {"German"}, + {"French"}, + {"Spanish"}, + {"Italian"}, + {"Dutch"}, + {"S. Chinese"}, + {"T. Chinese"}, + {"Korean"} +}; -static char langcodes[11][3] = -{{""}, -{"JA"}, -{"EN"}, -{"DE"}, -{"FR"}, -{"ES"}, -{"IT"}, -{"NL"}, -{"ZH"}, -{"ZH"}, -{"KO"}}; +static char langcodes[11][3] = {{""}, + {"JA"}, + {"EN"}, + {"DE"}, + {"FR"}, + {"ES"}, + {"IT"}, + {"NL"}, + {"ZH"}, + {"ZH"}, + {"KO"} +}; static char element_text[5000]; static mxml_node_t *nodetree=NULL; @@ -63,212 +63,207 @@ bool xml_loaded = false; /* load renamed titles from proper names and game info XML, needs to be after cfg_load_games */ -bool OpenXMLDatabase(char* xmlfilepath, char* argdblang, bool argJPtoEN, bool openfile, bool loadtitles, bool keepopen) -{ - if (!xml_loaded) { - bool opensuccess = false; - char pathname[200]; - snprintf(pathname, sizeof(pathname), "%s", xmlfilepath); - if (xmlfilepath[strlen(xmlfilepath) - 1] != '/') snprintf(pathname, sizeof(pathname), "%s/",pathname); - snprintf(pathname, sizeof(pathname), "%s%s", pathname, xmlcfg_filename); - if (openfile) opensuccess = OpenXMLFile(pathname); - if (!opensuccess) { - snprintf(pathname, sizeof(pathname), "%swiitdb.zip", pathname); - if (openfile) opensuccess = OpenXMLFile(pathname); - } - if (!opensuccess) { - CloseXMLDatabase(); - return false; - } - if (loadtitles) LoadTitlesFromXML(argdblang, argJPtoEN); - if (!keepopen) CloseXMLDatabase(); - } - return true; +bool OpenXMLDatabase(char* xmlfilepath, char* argdblang, bool argJPtoEN, bool openfile, bool loadtitles, bool keepopen) { + if (!xml_loaded) { + bool opensuccess = false; + char pathname[200]; + snprintf(pathname, sizeof(pathname), "%s", xmlfilepath); + if (xmlfilepath[strlen(xmlfilepath) - 1] != '/') snprintf(pathname, sizeof(pathname), "%s/",pathname); + snprintf(pathname, sizeof(pathname), "%s%s", pathname, xmlcfg_filename); + if (openfile) opensuccess = OpenXMLFile(pathname); + if (!opensuccess) { + snprintf(pathname, sizeof(pathname), "%swiitdb.zip", pathname); + if (openfile) opensuccess = OpenXMLFile(pathname); + } + if (!opensuccess) { + CloseXMLDatabase(); + return false; + } + if (loadtitles) LoadTitlesFromXML(argdblang, argJPtoEN); + if (!keepopen) CloseXMLDatabase(); + } + return true; } -void CloseXMLDatabase() -{ +void CloseXMLDatabase() { /* free memory */ - if (xml_loaded) { - mxmlDelete(nodedata); - mxmlDelete(nodetree); - xml_loaded = false; - } + if (xml_loaded) { + mxmlDelete(nodedata); + mxmlDelete(nodetree); + xml_loaded = false; + } } void GetTextFromNode(mxml_node_t *currentnode, mxml_node_t *topnode, char *nodename, - char *attributename, char *value, int descend, char *dest, int destsize) -{ - *element_text = 0; + char *attributename, char *value, int descend, char *dest, int destsize) { + *element_text = 0; nodefound = mxmlFindElement(currentnode, topnode, nodename, attributename, value, descend); - if (nodefound != NULL) { - if (attributename != NULL) { - strlcpy(dest,mxmlElementGetAttr(nodefound, attributename),destsize); - } else { - get_text(nodefound, element_text, sizeof(element_text)); - strlcpy(dest,element_text,destsize); - } - } else { - strcpy(dest,""); - } + if (nodefound != NULL) { + if (attributename != NULL) { + strlcpy(dest,mxmlElementGetAttr(nodefound, attributename),destsize); + } else { + get_text(nodefound, element_text, sizeof(element_text)); + strlcpy(dest,element_text,destsize); + } + } else { + strcpy(dest,""); + } } -bool OpenXMLFile(char *filename) -{ - //if (xmldebug) dbg_time1(); +bool OpenXMLFile(char *filename) { + //if (xmldebug) dbg_time1(); - if (xml_loaded) - return false; + if (xml_loaded) + return false; - gameinfo = gameinfo_reset; - nodedata=NULL; - nodetree=NULL; - nodeid=NULL; - nodeidtmp=NULL; - nodefound=NULL; + gameinfo = gameinfo_reset; + nodedata=NULL; + nodetree=NULL; + nodeid=NULL; + nodeidtmp=NULL; + nodefound=NULL; - char* strresult = strstr(filename,".zip"); + char* strresult = strstr(filename,".zip"); if (strresult == NULL) { - /* Load XML file */ - FILE *filexml; - filexml = fopen(filename, "rb"); - if (!filexml) - return false; + /* Load XML file */ + FILE *filexml; + filexml = fopen(filename, "rb"); + if (!filexml) + return false; - nodetree = mxmlLoadFile(NULL, filexml, MXML_NO_CALLBACK); - fclose(filexml); + nodetree = mxmlLoadFile(NULL, filexml, MXML_NO_CALLBACK); + fclose(filexml); - } else { - /* load zipped XML file */ - unzFile unzfile = unzOpen(filename); - if (unzfile == NULL) - return false; - unzOpenCurrentFile(unzfile); + } else { + /* load zipped XML file */ + unzFile unzfile = unzOpen(filename); + if (unzfile == NULL) + return false; + unzOpenCurrentFile(unzfile); - unz_file_info zipfileinfo; - unzGetCurrentFileInfo(unzfile, &zipfileinfo, NULL, 0, NULL, 0, NULL, 0); - int zipfilebuffersize = zipfileinfo.uncompressed_size; - if (zipfilebuffersize >= xmlmaxsize) { - unzCloseCurrentFile(unzfile); - unzClose(unzfile); - return false; - } - - char * zipfilebuffer = malloc(zipfilebuffersize); - memset(zipfilebuffer, 0, zipfilebuffersize); - if (zipfilebuffer == NULL) { - unzCloseCurrentFile(unzfile); - unzClose(unzfile); - return false; - } + unz_file_info zipfileinfo; + unzGetCurrentFileInfo(unzfile, &zipfileinfo, NULL, 0, NULL, 0, NULL, 0); + int zipfilebuffersize = zipfileinfo.uncompressed_size; + if (zipfilebuffersize >= xmlmaxsize) { + unzCloseCurrentFile(unzfile); + unzClose(unzfile); + return false; + } - unzReadCurrentFile(unzfile, zipfilebuffer, zipfilebuffersize); - unzCloseCurrentFile(unzfile); - unzClose(unzfile); + char * zipfilebuffer = malloc(zipfilebuffersize); + memset(zipfilebuffer, 0, zipfilebuffersize); + if (zipfilebuffer == NULL) { + unzCloseCurrentFile(unzfile); + unzClose(unzfile); + return false; + } - nodetree = mxmlLoadString(NULL, zipfilebuffer, MXML_NO_CALLBACK); - free(zipfilebuffer); - } + unzReadCurrentFile(unzfile, zipfilebuffer, zipfilebuffersize); + unzCloseCurrentFile(unzfile); + unzClose(unzfile); - if (nodetree == NULL) - return false; + nodetree = mxmlLoadString(NULL, zipfilebuffer, MXML_NO_CALLBACK); + free(zipfilebuffer); + } + + if (nodetree == NULL) + return false; nodedata = mxmlFindElement(nodetree, nodetree, "datafile", NULL, NULL, MXML_DESCEND); - if (nodedata == NULL) { - return false; - } else { - //if (xmldebug) xmlloadtime = dbg_time2(NULL); - xml_loaded = true; - return true; - } + if (nodedata == NULL) { + return false; + } else { + //if (xmldebug) xmlloadtime = dbg_time2(NULL); + xml_loaded = true; + return true; + } } -char *GetLangSettingFromGame(char *gameid) -{ - int langcode; - struct Game_CFG *game_cfg = NULL; - game_cfg = CFG_get_game_opt((u8*)gameid); - if (game_cfg) { - langcode = game_cfg->language; - } else { - //langcode = CFG.language; // for Configurable Loader - langcode = Settings.language; // for Loader GX - } - char *langtxt = langlist[langcode]; - return langtxt; +char *GetLangSettingFromGame(char *gameid) { + int langcode; + struct Game_CFG *game_cfg = NULL; + game_cfg = CFG_get_game_opt((u8*)gameid); + if (game_cfg) { + langcode = game_cfg->language; + } else { + //langcode = CFG.language; // for Configurable Loader + langcode = Settings.language; // for Loader GX + } + char *langtxt = langlist[langcode]; + return langtxt; } /* convert language text into ISO 639 two-letter language code */ -char *ConvertLangTextToCode(char *languagetxt) -{ - int i; - for (i=0;i<=10;i++) - { - if (!strcasecmp(languagetxt,langlist[i])) // case insensitive comparison - return langcodes[i]; - } - return ""; +char *ConvertLangTextToCode(char *languagetxt) { + int i; + for (i=0;i<=10;i++) { + if (!strcasecmp(languagetxt,langlist[i])) // case insensitive comparison + return langcodes[i]; + } + return ""; } -char ConvertRatingToIndex(char *ratingtext) -{ - int type = -1; - if (!strcmp(ratingtext,"CERO")) { type = 0; } - if (!strcmp(ratingtext,"ESRB")) { type = 1; } - if (!strcmp(ratingtext,"PEGI")) { type = 2; } - return type; +char ConvertRatingToIndex(char *ratingtext) { + int type = -1; + if (!strcmp(ratingtext,"CERO")) { + type = 0; + } + if (!strcmp(ratingtext,"ESRB")) { + type = 1; + } + if (!strcmp(ratingtext,"PEGI")) { + type = 2; + } + return type; } -void ConvertRating(char *ratingvalue, char *fromrating, char *torating, char *destvalue, int destsize) -{ - if(!strcmp(fromrating,torating)) { - strlcpy(destvalue,ratingvalue,destsize); - return; - } +void ConvertRating(char *ratingvalue, char *fromrating, char *torating, char *destvalue, int destsize) { + if (!strcmp(fromrating,torating)) { + strlcpy(destvalue,ratingvalue,destsize); + return; + } - strcpy(destvalue,""); - int type = -1; - int desttype = -1; + strcpy(destvalue,""); + int type = -1; + int desttype = -1; - type = ConvertRatingToIndex(fromrating); - desttype = ConvertRatingToIndex(torating); - if (type == -1 || desttype == -1) - return; + type = ConvertRatingToIndex(fromrating); + desttype = ConvertRatingToIndex(torating); + if (type == -1 || desttype == -1) + return; - /* rating conversion table */ - /* the list is ordered to pick the most likely value first: */ - /* EC and AO are less likely to be used so they are moved down to only be picked up when converting ESRB to PEGI or CERO */ - /* the conversion can never be perfect because ratings can differ between regions for the same game */ - char ratingtable[12][3][4] = - { - {{"A"},{"E"},{"3"}}, - {{"A"},{"E"},{"4"}}, - {{"A"},{"E"},{"6"}}, - {{"A"},{"E"},{"7"}}, - {{"A"},{"EC"},{"3"}}, - {{"A"},{"E10+"},{"7"}}, - {{"B"},{"T"},{"12"}}, - {{"D"},{"M"},{"18"}}, - {{"D"},{"M"},{"16"}}, - {{"C"},{"T"},{"16"}}, - {{"C"},{"T"},{"15"}}, - {{"Z"},{"AO"},{"18"}}, - }; + /* rating conversion table */ + /* the list is ordered to pick the most likely value first: */ + /* EC and AO are less likely to be used so they are moved down to only be picked up when converting ESRB to PEGI or CERO */ + /* the conversion can never be perfect because ratings can differ between regions for the same game */ + char ratingtable[12][3][4] = { + {{"A"},{"E"},{"3"}}, + {{"A"},{"E"},{"4"}}, + {{"A"},{"E"},{"6"}}, + {{"A"},{"E"},{"7"}}, + {{"A"},{"EC"},{"3"}}, + {{"A"},{"E10+"},{"7"}}, + {{"B"},{"T"},{"12"}}, + {{"D"},{"M"},{"18"}}, + {{"D"},{"M"},{"16"}}, + {{"C"},{"T"},{"16"}}, + {{"C"},{"T"},{"15"}}, + {{"Z"},{"AO"},{"18"}}, + }; - int i; - for (i=0;i<=11;i++) - { - if (!strcmp(ratingtable[i][type],ratingvalue)) { - strlcpy(destvalue,ratingtable[i][desttype],destsize); - return; - } - } + int i; + for (i=0;i<=11;i++) { + if (!strcmp(ratingtable[i][type],ratingvalue)) { + strlcpy(destvalue,ratingtable[i][desttype],destsize); + return; + } + } } @@ -276,100 +271,97 @@ void LoadTitlesFromXML(char *langtxt, bool forcejptoen) /* langtxt: set to "English","French","German", to force language for all titles, or "" to load title depending on each game's setting */ /* forcejptoen: set to true to load English title instead of Japanese title when game is set to Japanese */ { - if (nodedata == NULL) - return; + if (nodedata == NULL) + return; - bool forcelang = false; - if (strcmp(langtxt,"")) - forcelang = true; + bool forcelang = false; + if (strcmp(langtxt,"")) + forcelang = true; - char langcode[10] = ""; - if (forcelang) - strcpy(langcode,ConvertLangTextToCode(langtxt)); /* convert language text into ISO 639 two-letter language code */ + char langcode[10] = ""; + if (forcelang) + strcpy(langcode,ConvertLangTextToCode(langtxt)); /* convert language text into ISO 639 two-letter language code */ - /* create index of elements */ + /* create index of elements */ nodeindex = mxmlIndexNew(nodedata,"id", NULL); nodeid = mxmlIndexReset(nodeindex); *element_text = 0; - char id_text[10]; - char title_text[200] = ""; - char title_text_EN[200] = ""; + char id_text[10]; + char title_text[200] = ""; + char title_text_EN[200] = ""; - /* search index of id elements, load all id/titles text */ - while (nodeid != NULL) - { + /* search index of id elements, load all id/titles text */ + while (nodeid != NULL) { nodeid = mxmlIndexFind(nodeindex,"id", NULL); - if (nodeid != NULL) { - strcpy(title_text,""); - strcpy(title_text_EN,""); + if (nodeid != NULL) { + strcpy(title_text,""); + strcpy(title_text_EN,""); - get_text(nodeid, element_text, sizeof(element_text)); - snprintf(id_text, 7, "%s",element_text); + get_text(nodeid, element_text, sizeof(element_text)); + snprintf(id_text, 7, "%s",element_text); - // if language is not forced, use game language setting from config - if (!forcelang) { - langtxt = GetLangSettingFromGame(id_text); - strcpy(langcode,ConvertLangTextToCode(langtxt)); - } + // if language is not forced, use game language setting from config + if (!forcelang) { + langtxt = GetLangSettingFromGame(id_text); + strcpy(langcode,ConvertLangTextToCode(langtxt)); + } - /* if enabled, force English title for all games set to Japanese */ - if (forcejptoen && (!strcmp(langcode,"JA"))) - strcpy(langcode,"EN"); + /* if enabled, force English title for all games set to Japanese */ + if (forcejptoen && (!strcmp(langcode,"JA"))) + strcpy(langcode,"EN"); - /* load title from nodes */ - nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", "EN", MXML_NO_DESCEND); - if (nodefound != NULL) { - GetTextFromNode(nodefound, nodedata, "title", NULL, NULL, MXML_DESCEND, title_text_EN,sizeof(title_text_EN)); - } - nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", langcode, MXML_NO_DESCEND); - if (nodefound != NULL) { - GetTextFromNode(nodefound, nodedata, "title", NULL, NULL, MXML_DESCEND, title_text,sizeof(title_text)); - } + /* load title from nodes */ + nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", "EN", MXML_NO_DESCEND); + if (nodefound != NULL) { + GetTextFromNode(nodefound, nodedata, "title", NULL, NULL, MXML_DESCEND, title_text_EN,sizeof(title_text_EN)); + } + nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", langcode, MXML_NO_DESCEND); + if (nodefound != NULL) { + GetTextFromNode(nodefound, nodedata, "title", NULL, NULL, MXML_DESCEND, title_text,sizeof(title_text)); + } - /* fall back to English title if prefered language was not found */ - if (!strcmp(title_text,"")) { - strcpy(title_text,title_text_EN); - } + /* fall back to English title if prefered language was not found */ + if (!strcmp(title_text,"")) { + strcpy(title_text,title_text_EN); + } - snprintf(id_text, 7, "%s",id_text); - title_set(id_text, title_text); - } + snprintf(id_text, 7, "%s",id_text); + title_set(id_text, title_text); + } } - // free memory - mxmlIndexDelete(nodeindex); + // free memory + mxmlIndexDelete(nodeindex); //if (xmldebug) xmlloadtime = dbg_time2(NULL); } -void GetPublisherFromGameid(char *idtxt, char *dest, int destsize) -{ - /* guess publisher from company list using last two characters from game id */ - nodeindextmp = mxmlIndexNew(nodedata,"company", NULL); - nodeidtmp = mxmlIndexReset(nodeindextmp); +void GetPublisherFromGameid(char *idtxt, char *dest, int destsize) { + /* guess publisher from company list using last two characters from game id */ + nodeindextmp = mxmlIndexNew(nodedata,"company", NULL); + nodeidtmp = mxmlIndexReset(nodeindextmp); *element_text=0; - char publishercode[3]; - sprintf(publishercode,"%c%c", idtxt[4],idtxt[5]); + char publishercode[3]; + sprintf(publishercode,"%c%c", idtxt[4],idtxt[5]); - while (strcmp(element_text,publishercode) != 0) - { - nodeidtmp = mxmlIndexFind(nodeindextmp,"company", NULL); - if (nodeidtmp != NULL) { - strlcpy(element_text,mxmlElementGetAttr(nodeidtmp, "code"),sizeof(element_text)); - } else { - break; - } + while (strcmp(element_text,publishercode) != 0) { + nodeidtmp = mxmlIndexFind(nodeindextmp,"company", NULL); + if (nodeidtmp != NULL) { + strlcpy(element_text,mxmlElementGetAttr(nodeidtmp, "code"),sizeof(element_text)); + } else { + break; + } + } + if (!strcmp(element_text,publishercode)) { + strlcpy(dest,mxmlElementGetAttr(nodeidtmp, "name"),destsize); + } else { + strcpy(dest,""); } - if (!strcmp(element_text,publishercode)) { - strlcpy(dest,mxmlElementGetAttr(nodeidtmp, "name"),destsize); - } else { - strcpy(dest,""); - } - // free memory - mxmlIndexDelete(nodeindextmp); + // free memory + mxmlIndexDelete(nodeindextmp); } @@ -378,381 +370,366 @@ bool LoadGameInfoFromXML(char* gameid, char* langtxt) /* gameid: full game id */ /* langtxt: "English","French","German" */ { - bool exist=false; - if (!xml_loaded || nodedata == NULL) - return exist; + bool exist=false; + if (!xml_loaded || nodedata == NULL) + return exist; - // load game info using forced language, or game individual setting, or main language setting - char langcode[100] = ""; - if (!strcmp(langtxt,"")) - langtxt = GetLangSettingFromGame(gameid); - strcpy(langcode,ConvertLangTextToCode(langtxt)); + // load game info using forced language, or game individual setting, or main language setting + char langcode[100] = ""; + if (!strcmp(langtxt,"")) + langtxt = GetLangSettingFromGame(gameid); + strcpy(langcode,ConvertLangTextToCode(langtxt)); - /* reset all game info */ - gameinfo = gameinfo_reset; + /* reset all game info */ + gameinfo = gameinfo_reset; /* index all IDs */ nodeindex = mxmlIndexNew(nodedata,"id", NULL); nodeid = mxmlIndexReset(nodeindex); - *element_text = 0; - /* search for game matching gameid */ - while (1) - { + *element_text = 0; + /* search for game matching gameid */ + while (1) { nodeid = mxmlIndexFind(nodeindex,"id", NULL); - if (nodeid != NULL) { - get_text(nodeid, element_text, sizeof(element_text)); - if (!strcmp(element_text,gameid)) { - break; - } - } else { - break; - } + if (nodeid != NULL) { + get_text(nodeid, element_text, sizeof(element_text)); + if (!strcmp(element_text,gameid)) { + break; + } + } else { + break; + } } if (!strcmp(element_text,gameid)) { - /* text from elements */ - strlcpy(gameinfo.id,element_text,sizeof(gameinfo.id)); - GetTextFromNode(nodeid, nodedata, "region", NULL, NULL, MXML_NO_DESCEND, gameinfo.region,sizeof(gameinfo.region)); - GetTextFromNode(nodeid, nodedata, "version", NULL, NULL, MXML_NO_DESCEND, gameinfo.version,sizeof(gameinfo.version)); - GetTextFromNode(nodeid, nodedata, "genre", NULL, NULL, MXML_NO_DESCEND, gameinfo.genre,sizeof(gameinfo.genre)); - GetTextFromNode(nodeid, nodedata, "developer", NULL, NULL, MXML_NO_DESCEND, gameinfo.developer,sizeof(gameinfo.developer)); - GetTextFromNode(nodeid, nodedata, "publisher", NULL, NULL, MXML_NO_DESCEND, gameinfo.publisher,sizeof(gameinfo.publisher)); - GetPublisherFromGameid(gameid,gameinfo.publisherfromid,sizeof(gameinfo.publisherfromid)); + /* text from elements */ + strlcpy(gameinfo.id,element_text,sizeof(gameinfo.id)); + GetTextFromNode(nodeid, nodedata, "region", NULL, NULL, MXML_NO_DESCEND, gameinfo.region,sizeof(gameinfo.region)); + GetTextFromNode(nodeid, nodedata, "version", NULL, NULL, MXML_NO_DESCEND, gameinfo.version,sizeof(gameinfo.version)); + GetTextFromNode(nodeid, nodedata, "genre", NULL, NULL, MXML_NO_DESCEND, gameinfo.genre,sizeof(gameinfo.genre)); + GetTextFromNode(nodeid, nodedata, "developer", NULL, NULL, MXML_NO_DESCEND, gameinfo.developer,sizeof(gameinfo.developer)); + GetTextFromNode(nodeid, nodedata, "publisher", NULL, NULL, MXML_NO_DESCEND, gameinfo.publisher,sizeof(gameinfo.publisher)); + GetPublisherFromGameid(gameid,gameinfo.publisherfromid,sizeof(gameinfo.publisherfromid)); - /* text from attributes */ - GetTextFromNode(nodeid, nodedata, "date", "year", NULL, MXML_NO_DESCEND, gameinfo.year,sizeof(gameinfo.year)); - GetTextFromNode(nodeid, nodedata, "date", "month", NULL,MXML_NO_DESCEND, gameinfo.month,sizeof(gameinfo.month)); - GetTextFromNode(nodeid, nodedata, "date", "day", NULL, MXML_NO_DESCEND, gameinfo.day,sizeof(gameinfo.day)); - GetTextFromNode(nodeid, nodedata, "rating", "type", NULL, MXML_NO_DESCEND, gameinfo.ratingtype,sizeof(gameinfo.ratingtype)); - GetTextFromNode(nodeid, nodedata, "rating", "value", NULL, MXML_NO_DESCEND, gameinfo.ratingvalue,sizeof(gameinfo.ratingvalue)); - GetTextFromNode(nodeid, nodedata, "rom", "crc", NULL, MXML_NO_DESCEND, gameinfo.iso_crc,sizeof(gameinfo.iso_crc)); - GetTextFromNode(nodeid, nodedata, "rom", "md5", NULL, MXML_NO_DESCEND, gameinfo.iso_md5,sizeof(gameinfo.iso_md5)); - GetTextFromNode(nodeid, nodedata, "rom", "sha1", NULL, MXML_NO_DESCEND, gameinfo.iso_sha1,sizeof(gameinfo.iso_sha1)); + /* text from attributes */ + GetTextFromNode(nodeid, nodedata, "date", "year", NULL, MXML_NO_DESCEND, gameinfo.year,sizeof(gameinfo.year)); + GetTextFromNode(nodeid, nodedata, "date", "month", NULL,MXML_NO_DESCEND, gameinfo.month,sizeof(gameinfo.month)); + GetTextFromNode(nodeid, nodedata, "date", "day", NULL, MXML_NO_DESCEND, gameinfo.day,sizeof(gameinfo.day)); + GetTextFromNode(nodeid, nodedata, "rating", "type", NULL, MXML_NO_DESCEND, gameinfo.ratingtype,sizeof(gameinfo.ratingtype)); + GetTextFromNode(nodeid, nodedata, "rating", "value", NULL, MXML_NO_DESCEND, gameinfo.ratingvalue,sizeof(gameinfo.ratingvalue)); + GetTextFromNode(nodeid, nodedata, "rom", "crc", NULL, MXML_NO_DESCEND, gameinfo.iso_crc,sizeof(gameinfo.iso_crc)); + GetTextFromNode(nodeid, nodedata, "rom", "md5", NULL, MXML_NO_DESCEND, gameinfo.iso_md5,sizeof(gameinfo.iso_md5)); + GetTextFromNode(nodeid, nodedata, "rom", "sha1", NULL, MXML_NO_DESCEND, gameinfo.iso_sha1,sizeof(gameinfo.iso_sha1)); - /* text from child elements */ - nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", "EN", MXML_NO_DESCEND); - if (nodefound != NULL) { - GetTextFromNode(nodefound, nodedata, "title", NULL, NULL, MXML_DESCEND, gameinfo.title_EN,sizeof(gameinfo.title_EN)); - GetTextFromNode(nodefound, nodedata, "synopsis", NULL, NULL, MXML_DESCEND, gameinfo.synopsis_EN,sizeof(gameinfo.synopsis_EN)); - } - nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", langcode, MXML_NO_DESCEND); - if (nodefound != NULL) { - GetTextFromNode(nodefound, nodedata, "title", NULL, NULL, MXML_DESCEND, gameinfo.title,sizeof(gameinfo.title)); - GetTextFromNode(nodefound, nodedata, "synopsis", NULL, NULL, MXML_DESCEND, gameinfo.synopsis,sizeof(gameinfo.synopsis)); - } - // fall back to English title and synopsis if prefered language was not found - if (!strcmp(gameinfo.title,"")) { - strlcpy(gameinfo.title,gameinfo.title_EN,sizeof(gameinfo.title)); - } - if (!strcmp(gameinfo.synopsis,"")) { - strlcpy(gameinfo.synopsis,gameinfo.synopsis_EN,sizeof(gameinfo.synopsis)); - } + /* text from child elements */ + nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", "EN", MXML_NO_DESCEND); + if (nodefound != NULL) { + GetTextFromNode(nodefound, nodedata, "title", NULL, NULL, MXML_DESCEND, gameinfo.title_EN,sizeof(gameinfo.title_EN)); + GetTextFromNode(nodefound, nodedata, "synopsis", NULL, NULL, MXML_DESCEND, gameinfo.synopsis_EN,sizeof(gameinfo.synopsis_EN)); + } + nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", langcode, MXML_NO_DESCEND); + if (nodefound != NULL) { + GetTextFromNode(nodefound, nodedata, "title", NULL, NULL, MXML_DESCEND, gameinfo.title,sizeof(gameinfo.title)); + GetTextFromNode(nodefound, nodedata, "synopsis", NULL, NULL, MXML_DESCEND, gameinfo.synopsis,sizeof(gameinfo.synopsis)); + } + // fall back to English title and synopsis if prefered language was not found + if (!strcmp(gameinfo.title,"")) { + strlcpy(gameinfo.title,gameinfo.title_EN,sizeof(gameinfo.title)); + } + if (!strcmp(gameinfo.synopsis,"")) { + strlcpy(gameinfo.synopsis,gameinfo.synopsis_EN,sizeof(gameinfo.synopsis)); + } - /* list locale lang attributes */ - nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", NULL, MXML_NO_DESCEND); - if (nodefound != NULL) { - int incr = 0; - while (nodefound != NULL) - { - ++incr; - strlcpy(gameinfo.locales[incr],mxmlElementGetAttr(nodefound, "lang"),sizeof(gameinfo.locales[incr])); - nodefound = mxmlWalkNext(nodefound, nodedata, MXML_NO_DESCEND); - if (nodefound != NULL) { - nodefound = mxmlFindElement(nodefound, nodedata, "locale", "lang", NULL, MXML_NO_DESCEND); - } - } - } + /* list locale lang attributes */ + nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", NULL, MXML_NO_DESCEND); + if (nodefound != NULL) { + int incr = 0; + while (nodefound != NULL) { + ++incr; + strlcpy(gameinfo.locales[incr],mxmlElementGetAttr(nodefound, "lang"),sizeof(gameinfo.locales[incr])); + nodefound = mxmlWalkNext(nodefound, nodedata, MXML_NO_DESCEND); + if (nodefound != NULL) { + nodefound = mxmlFindElement(nodefound, nodedata, "locale", "lang", NULL, MXML_NO_DESCEND); + } + } + } - /* unbounded child elements */ - GetTextFromNode(nodeid, nodedata, "wi-fi", "players", NULL, MXML_NO_DESCEND, gameinfo.wifiplayers,sizeof(gameinfo.wifiplayers)); - nodefound = mxmlFindElement(nodeid, nodedata, "wi-fi", NULL, NULL, MXML_NO_DESCEND); - if (nodefound != NULL) { - gameinfo.wifiCnt = 0; - nodeindextmp = mxmlIndexNew(nodefound,"feature", NULL); - nodeidtmp = mxmlIndexReset(nodeindextmp); - while (nodeidtmp != NULL) - { - nodeidtmp = mxmlIndexFind(nodeindextmp,"feature", NULL); - if (nodeidtmp != NULL) { - ++gameinfo.wifiCnt; - GetTextFromNode(nodeidtmp, nodedata, "feature", NULL, NULL, MXML_DESCEND, gameinfo.wififeatures[gameinfo.wifiCnt], - sizeof(gameinfo.wififeatures[gameinfo.wifiCnt])); - gameinfo.wififeatures[gameinfo.wifiCnt][0] = toupper(gameinfo.wififeatures[gameinfo.wifiCnt][0]); - if (gameinfo.wifiCnt == XML_ELEMMAX) - break; - } - } - mxmlIndexDelete(nodeindextmp); // placed after each mxmlIndexNew to prevent memory leak - } + /* unbounded child elements */ + GetTextFromNode(nodeid, nodedata, "wi-fi", "players", NULL, MXML_NO_DESCEND, gameinfo.wifiplayers,sizeof(gameinfo.wifiplayers)); + nodefound = mxmlFindElement(nodeid, nodedata, "wi-fi", NULL, NULL, MXML_NO_DESCEND); + if (nodefound != NULL) { + gameinfo.wifiCnt = 0; + nodeindextmp = mxmlIndexNew(nodefound,"feature", NULL); + nodeidtmp = mxmlIndexReset(nodeindextmp); + while (nodeidtmp != NULL) { + nodeidtmp = mxmlIndexFind(nodeindextmp,"feature", NULL); + if (nodeidtmp != NULL) { + ++gameinfo.wifiCnt; + GetTextFromNode(nodeidtmp, nodedata, "feature", NULL, NULL, MXML_DESCEND, gameinfo.wififeatures[gameinfo.wifiCnt], + sizeof(gameinfo.wififeatures[gameinfo.wifiCnt])); + gameinfo.wififeatures[gameinfo.wifiCnt][0] = toupper(gameinfo.wififeatures[gameinfo.wifiCnt][0]); + if (gameinfo.wifiCnt == XML_ELEMMAX) + break; + } + } + mxmlIndexDelete(nodeindextmp); // placed after each mxmlIndexNew to prevent memory leak + } - nodefound = mxmlFindElement(nodeid, nodedata, "rating", NULL, NULL, MXML_NO_DESCEND); - if (nodefound != NULL) { - gameinfo.descriptorCnt=0; - nodeindextmp = mxmlIndexNew(nodefound,"descriptor", NULL); - nodeidtmp = mxmlIndexReset(nodeindextmp); - while (nodeidtmp != NULL) - { - nodeidtmp = mxmlIndexFind(nodeindextmp,"descriptor", NULL); - if (nodeidtmp != NULL) { - ++gameinfo.descriptorCnt; - GetTextFromNode(nodeidtmp, nodedata, "descriptor", NULL, NULL, MXML_DESCEND, - gameinfo.ratingdescriptors[gameinfo.descriptorCnt], sizeof(gameinfo.ratingdescriptors[gameinfo.descriptorCnt])); - if (gameinfo.descriptorCnt == XML_ELEMMAX) - break; - } - } - mxmlIndexDelete(nodeindextmp); - } + nodefound = mxmlFindElement(nodeid, nodedata, "rating", NULL, NULL, MXML_NO_DESCEND); + if (nodefound != NULL) { + gameinfo.descriptorCnt=0; + nodeindextmp = mxmlIndexNew(nodefound,"descriptor", NULL); + nodeidtmp = mxmlIndexReset(nodeindextmp); + while (nodeidtmp != NULL) { + nodeidtmp = mxmlIndexFind(nodeindextmp,"descriptor", NULL); + if (nodeidtmp != NULL) { + ++gameinfo.descriptorCnt; + GetTextFromNode(nodeidtmp, nodedata, "descriptor", NULL, NULL, MXML_DESCEND, + gameinfo.ratingdescriptors[gameinfo.descriptorCnt], sizeof(gameinfo.ratingdescriptors[gameinfo.descriptorCnt])); + if (gameinfo.descriptorCnt == XML_ELEMMAX) + break; + } + } + mxmlIndexDelete(nodeindextmp); + } - GetTextFromNode(nodeid, nodedata, "input", "players", NULL, MXML_NO_DESCEND, gameinfo.players,sizeof(gameinfo.players)); - nodefound = mxmlFindElement(nodeid, nodedata, "input", NULL, NULL, MXML_NO_DESCEND); - if (nodefound != NULL) { - gameinfo.accessoryCnt=0; - gameinfo.accessoryReqCnt=0; - nodeindextmp = mxmlIndexNew(nodefound,"control", NULL); - nodeidtmp = mxmlIndexReset(nodeindextmp); - while (nodeidtmp != NULL) - { - nodeidtmp = mxmlIndexFind(nodeindextmp,"control", NULL); - if (nodeidtmp != NULL) { - if (!strcmp(mxmlElementGetAttr(nodeidtmp, "required"),"true") && gameinfo.accessoryReqCnt < XML_ELEMMAX) { - ++gameinfo.accessoryReqCnt; - strlcpy(gameinfo.accessoriesReq[gameinfo.accessoryReqCnt],mxmlElementGetAttr(nodeidtmp, "type"), - sizeof(gameinfo.accessoriesReq[gameinfo.accessoryReqCnt])); - } else if (gameinfo.accessoryCnt < XML_ELEMMAX) { - ++gameinfo.accessoryCnt; - strlcpy(gameinfo.accessories[gameinfo.accessoryCnt],mxmlElementGetAttr(nodeidtmp, "type"), - sizeof(gameinfo.accessories[gameinfo.accessoryCnt])); - } - } - } - mxmlIndexDelete(nodeindextmp); - } + GetTextFromNode(nodeid, nodedata, "input", "players", NULL, MXML_NO_DESCEND, gameinfo.players,sizeof(gameinfo.players)); + nodefound = mxmlFindElement(nodeid, nodedata, "input", NULL, NULL, MXML_NO_DESCEND); + if (nodefound != NULL) { + gameinfo.accessoryCnt=0; + gameinfo.accessoryReqCnt=0; + nodeindextmp = mxmlIndexNew(nodefound,"control", NULL); + nodeidtmp = mxmlIndexReset(nodeindextmp); + while (nodeidtmp != NULL) { + nodeidtmp = mxmlIndexFind(nodeindextmp,"control", NULL); + if (nodeidtmp != NULL) { + if (!strcmp(mxmlElementGetAttr(nodeidtmp, "required"),"true") && gameinfo.accessoryReqCnt < XML_ELEMMAX) { + ++gameinfo.accessoryReqCnt; + strlcpy(gameinfo.accessoriesReq[gameinfo.accessoryReqCnt],mxmlElementGetAttr(nodeidtmp, "type"), + sizeof(gameinfo.accessoriesReq[gameinfo.accessoryReqCnt])); + } else if (gameinfo.accessoryCnt < XML_ELEMMAX) { + ++gameinfo.accessoryCnt; + strlcpy(gameinfo.accessories[gameinfo.accessoryCnt],mxmlElementGetAttr(nodeidtmp, "type"), + sizeof(gameinfo.accessories[gameinfo.accessoryCnt])); + } + } + } + mxmlIndexDelete(nodeindextmp); + } - /* convert rating value */ - ConvertRating(gameinfo.ratingvalue, gameinfo.ratingtype, "CERO",gameinfo.ratingvalueCERO,sizeof(gameinfo.ratingvalueCERO)); - ConvertRating(gameinfo.ratingvalue, gameinfo.ratingtype, "ESRB",gameinfo.ratingvalueESRB,sizeof(gameinfo.ratingvalueESRB)); - ConvertRating(gameinfo.ratingvalue, gameinfo.ratingtype, "PEGI",gameinfo.ratingvaluePEGI,sizeof(gameinfo.ratingvaluePEGI)); + /* convert rating value */ + ConvertRating(gameinfo.ratingvalue, gameinfo.ratingtype, "CERO",gameinfo.ratingvalueCERO,sizeof(gameinfo.ratingvalueCERO)); + ConvertRating(gameinfo.ratingvalue, gameinfo.ratingtype, "ESRB",gameinfo.ratingvalueESRB,sizeof(gameinfo.ratingvalueESRB)); + ConvertRating(gameinfo.ratingvalue, gameinfo.ratingtype, "PEGI",gameinfo.ratingvaluePEGI,sizeof(gameinfo.ratingvaluePEGI)); - /* provide genre as an array: gameinfo.genresplit */ - if (strcmp(gameinfo.genre,"") != 0){ - gameinfo.genreCnt=0; - const char *delimgenre = ",;"; - char genretxt[200]; - strlcpy(genretxt,gameinfo.genre,sizeof(genretxt)); - char *splitresult; - splitresult = strtok(genretxt, delimgenre); - if (splitresult != NULL) { - ++gameinfo.genreCnt; - trimcopy(splitresult,splitresult,strlen(splitresult)+1); - strlcpy(gameinfo.genresplit[gameinfo.genreCnt],splitresult,sizeof(gameinfo.genresplit[gameinfo.genreCnt])); - gameinfo.genresplit[gameinfo.genreCnt][0] = toupper(gameinfo.genresplit[gameinfo.genreCnt][0]); - while (splitresult != NULL) - { - splitresult = strtok(NULL, delimgenre); - if (splitresult != NULL && strcmp(splitresult,"")!=0) { - ++gameinfo.genreCnt; - trimcopy(splitresult,splitresult,strlen(splitresult)+1); - strlcpy(gameinfo.genresplit[gameinfo.genreCnt],splitresult,sizeof(gameinfo.genresplit[gameinfo.genreCnt])); - gameinfo.genresplit[gameinfo.genreCnt][0] = toupper(gameinfo.genresplit[gameinfo.genreCnt][0]); - if (gameinfo.genreCnt == XML_ELEMMAX) - break; - } - } - } + /* provide genre as an array: gameinfo.genresplit */ + if (strcmp(gameinfo.genre,"") != 0) { + gameinfo.genreCnt=0; + const char *delimgenre = ",;"; + char genretxt[200]; + strlcpy(genretxt,gameinfo.genre,sizeof(genretxt)); + char *splitresult; + splitresult = strtok(genretxt, delimgenre); + if (splitresult != NULL) { + ++gameinfo.genreCnt; + trimcopy(splitresult,splitresult,strlen(splitresult)+1); + strlcpy(gameinfo.genresplit[gameinfo.genreCnt],splitresult,sizeof(gameinfo.genresplit[gameinfo.genreCnt])); + gameinfo.genresplit[gameinfo.genreCnt][0] = toupper(gameinfo.genresplit[gameinfo.genreCnt][0]); + while (splitresult != NULL) { + splitresult = strtok(NULL, delimgenre); + if (splitresult != NULL && strcmp(splitresult,"")!=0) { + ++gameinfo.genreCnt; + trimcopy(splitresult,splitresult,strlen(splitresult)+1); + strlcpy(gameinfo.genresplit[gameinfo.genreCnt],splitresult,sizeof(gameinfo.genresplit[gameinfo.genreCnt])); + gameinfo.genresplit[gameinfo.genreCnt][0] = toupper(gameinfo.genresplit[gameinfo.genreCnt][0]); + if (gameinfo.genreCnt == XML_ELEMMAX) + break; + } + } + } - } + } - exist=true; + exist=true; } else { - /*game not found */ - exist=false; - } + /*game not found */ + exist=false; + } - // if game was not found or info is missing - // guess publisher from game id in case it is missing - if (!strcmp(gameinfo.publisher,"")) { - GetPublisherFromGameid(gameid,gameinfo.publisherfromid,sizeof(gameinfo.publisherfromid)); - strlcpy(gameinfo.publisher,gameinfo.publisherfromid,sizeof(gameinfo.publisher)); - } + // if game was not found or info is missing + // guess publisher from game id in case it is missing + if (!strcmp(gameinfo.publisher,"")) { + GetPublisherFromGameid(gameid,gameinfo.publisherfromid,sizeof(gameinfo.publisherfromid)); + strlcpy(gameinfo.publisher,gameinfo.publisherfromid,sizeof(gameinfo.publisher)); + } - // if missing, get region from game ID - if (!strcmp(gameinfo.region,"")) { - if (gameid[3] == 'E') strlcpy(gameinfo.region,"NTSC-U",sizeof(gameinfo.region)); - if (gameid[3] == 'J') strlcpy(gameinfo.region,"NTSC-J",sizeof(gameinfo.region)); - if (gameid[3] == 'K') strlcpy(gameinfo.region,"NTSC-K",sizeof(gameinfo.region)); - if (gameid[3] == 'P') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); - if (gameid[3] == 'X') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); - if (gameid[3] == 'Y') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); - if (gameid[3] == 'D') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); - if (gameid[3] == 'F') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); - if (gameid[3] == 'S') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); - if (gameid[3] == 'I') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); - if (gameid[3] == 'H') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); - } + // if missing, get region from game ID + if (!strcmp(gameinfo.region,"")) { + if (gameid[3] == 'E') strlcpy(gameinfo.region,"NTSC-U",sizeof(gameinfo.region)); + if (gameid[3] == 'J') strlcpy(gameinfo.region,"NTSC-J",sizeof(gameinfo.region)); + if (gameid[3] == 'K') strlcpy(gameinfo.region,"NTSC-K",sizeof(gameinfo.region)); + if (gameid[3] == 'P') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); + if (gameid[3] == 'X') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); + if (gameid[3] == 'Y') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); + if (gameid[3] == 'D') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); + if (gameid[3] == 'F') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); + if (gameid[3] == 'S') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); + if (gameid[3] == 'I') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); + if (gameid[3] == 'H') strlcpy(gameinfo.region,"PAL",sizeof(gameinfo.region)); + } - // free memory - mxmlIndexDelete(nodeindex); + // free memory + mxmlIndexDelete(nodeindex); - return exist; + return exist; } -void PrintGameInfo(bool showfullinfo) -{ - if (showfullinfo) { +void PrintGameInfo(bool showfullinfo) { + if (showfullinfo) { - //Con_Clear(); + //Con_Clear(); - //printf("id: %s version: %s region: %s",gameinfo.id, gameinfo.version, gameinfo.region); - //printf("title: %s\n",gameinfo.title); - int i; - printf("languages:"); - for (i=1;strcmp(gameinfo.locales[i],"") != 0;i++) - { - printf(" %s",gameinfo.locales[i]); - } - printf("\n"); - //printf("developer: %s\n",gameinfo.developer); - //printf("publisher: %s\n",gameinfo.publisher); - //printf("publisher from ID: %s\n",gameinfo.publisherfromid); - printf("year:%s month:%s day:%s\n",gameinfo.year,gameinfo.month,gameinfo.day); - printf("genre: %s\n",gameinfo.genre); - //printf("rating: %s %s (CERO: %s ESRB: %s PEGI: %s)\n",gameinfo.ratingtype, gameinfo.ratingvalue, + //printf("id: %s version: %s region: %s",gameinfo.id, gameinfo.version, gameinfo.region); + //printf("title: %s\n",gameinfo.title); + int i; + printf("languages:"); + for (i=1;strcmp(gameinfo.locales[i],"") != 0;i++) { + printf(" %s",gameinfo.locales[i]); + } + printf("\n"); + //printf("developer: %s\n",gameinfo.developer); + //printf("publisher: %s\n",gameinfo.publisher); + //printf("publisher from ID: %s\n",gameinfo.publisherfromid); + printf("year:%s month:%s day:%s\n",gameinfo.year,gameinfo.month,gameinfo.day); + printf("genre: %s\n",gameinfo.genre); + //printf("rating: %s %s (CERO: %s ESRB: %s PEGI: %s)\n",gameinfo.ratingtype, gameinfo.ratingvalue, // gameinfo.ratingvalueCERO,gameinfo.ratingvalueESRB,gameinfo.ratingvaluePEGI); - printf("content descriptors:"); - for (i=1;strcmp(gameinfo.wififeatures[i],"") != 0;i++) - { - printf(" %s",gameinfo.ratingdescriptors[i]); - } - printf("\n"); - printf("players: %s online: %s\n",gameinfo.players,gameinfo.wifiplayers); - printf("online features:"); - for (i=1;strcmp(gameinfo.wififeatures[i],"") != 0;i++) - { - printf(" %s",gameinfo.wififeatures[i]); - } - printf("\n"); - printf("required accessories:"); - for (i=1;strcmp(gameinfo.accessoriesReq[i],"") != 0;i++) - { - printf(" %s",gameinfo.accessoriesReq[i]); - } - printf("\n"); - printf("accessories:"); - for (i=1;strcmp(gameinfo.accessories[i],"") != 0;i++) - { - printf(" %s",gameinfo.accessories[i]); - } - printf("\n"); - //printf("iso_crc: %s iso_md5: %s\n",gameinfo.iso_crc,gameinfo.iso_md5); - //printf("iso_sha1: %s\n",gameinfo.iso_sha1); - //printf("synopsis: %s\n",gameinfo.synopsis); + printf("content descriptors:"); + for (i=1;strcmp(gameinfo.wififeatures[i],"") != 0;i++) { + printf(" %s",gameinfo.ratingdescriptors[i]); + } + printf("\n"); + printf("players: %s online: %s\n",gameinfo.players,gameinfo.wifiplayers); + printf("online features:"); + for (i=1;strcmp(gameinfo.wififeatures[i],"") != 0;i++) { + printf(" %s",gameinfo.wififeatures[i]); + } + printf("\n"); + printf("required accessories:"); + for (i=1;strcmp(gameinfo.accessoriesReq[i],"") != 0;i++) { + printf(" %s",gameinfo.accessoriesReq[i]); + } + printf("\n"); + printf("accessories:"); + for (i=1;strcmp(gameinfo.accessories[i],"") != 0;i++) { + printf(" %s",gameinfo.accessories[i]); + } + printf("\n"); + //printf("iso_crc: %s iso_md5: %s\n",gameinfo.iso_crc,gameinfo.iso_md5); + //printf("iso_sha1: %s\n",gameinfo.iso_sha1); + //printf("synopsis: %s\n",gameinfo.synopsis); - } else { + } else { - char linebuf[1000] = ""; + char linebuf[1000] = ""; - if (xmldebug) { - //char xmltime[100]; - //sprintf(xmltime,"%d",xmlloadtime); - //printf("xml load time: %s\n",xmltime); + if (xmldebug) { + //char xmltime[100]; + //sprintf(xmltime,"%d",xmlloadtime); + //printf("xml load time: %s\n",xmltime); /* - printf("xml forcelang: %s\n",CFG.db_lang); - printf("xml url: %s\n",CFG.db_url); - printf("xml file: %s\n",CFG.db_filename); - char xmljptoen[100]; - sprintf(xmljptoen,"%d",CFG.db_JPtoEN); - printf("xml JPtoEN: %s\n",xmljptoen); - */ - printf(MemInfo()); // guidebug - } + printf("xml forcelang: %s\n",CFG.db_lang); + printf("xml url: %s\n",CFG.db_url); + printf("xml file: %s\n",CFG.db_filename); + char xmljptoen[100]; + sprintf(xmljptoen,"%d",CFG.db_JPtoEN); + printf("xml JPtoEN: %s\n",xmljptoen); + */ + printf(MemInfo()); // guidebug + } - //printf("%s: ",gameidfull); - //printf("%s\n",gameinfo.title); - if (strcmp(gameinfo.year,"") != 0) - snprintf(linebuf, sizeof(linebuf), "%s ", gameinfo.year); - if (strcmp(gameinfo.publisher,"") != 0) - snprintf(linebuf, sizeof(linebuf), "%s%s", linebuf, gameinfo.publisher); - if (strcmp(gameinfo.developer,"") != 0 && strcmp(gameinfo.developer,gameinfo.publisher) != 0) - snprintf(linebuf, sizeof(linebuf), "%s / %s", linebuf, gameinfo.developer); - if (strlen(linebuf) >= 100) { - char buffer[200] = ""; - strncpy(buffer, linebuf, 100); - strncat(buffer, "...", 3); - snprintf(linebuf, sizeof(linebuf), "%s", buffer); - } - printf("%s\n",linebuf); - strcpy(linebuf,""); + //printf("%s: ",gameidfull); + //printf("%s\n",gameinfo.title); + if (strcmp(gameinfo.year,"") != 0) + snprintf(linebuf, sizeof(linebuf), "%s ", gameinfo.year); + if (strcmp(gameinfo.publisher,"") != 0) + snprintf(linebuf, sizeof(linebuf), "%s%s", linebuf, gameinfo.publisher); + if (strcmp(gameinfo.developer,"") != 0 && strcmp(gameinfo.developer,gameinfo.publisher) != 0) + snprintf(linebuf, sizeof(linebuf), "%s / %s", linebuf, gameinfo.developer); + if (strlen(linebuf) >= 100) { + char buffer[200] = ""; + strncpy(buffer, linebuf, 100); + strncat(buffer, "...", 3); + snprintf(linebuf, sizeof(linebuf), "%s", buffer); + } + printf("%s\n",linebuf); + strcpy(linebuf,""); - if (strcmp(gameinfo.ratingvalue,"") != 0) { - snprintf(linebuf, sizeof(linebuf), "rated %s", gameinfo.ratingvalue); - if (!strcmp(gameinfo.ratingtype,"PEGI")) - snprintf(linebuf, sizeof(linebuf), "%s+ ", linebuf); - snprintf(linebuf, sizeof(linebuf), "%s ", linebuf); - } - if (strcmp(gameinfo.players,"") != 0) { - snprintf(linebuf, sizeof(linebuf), "%sfor %s player", linebuf, gameinfo.players); - if (atoi(gameinfo.players) > 1) - snprintf(linebuf, sizeof(linebuf), "%ss", linebuf); - if (atoi(gameinfo.wifiplayers) > 1) - snprintf(linebuf, sizeof(linebuf), "%s (%s online)", linebuf, gameinfo.wifiplayers); - } - printf("%s\n",linebuf); - strcpy(linebuf,""); - } + if (strcmp(gameinfo.ratingvalue,"") != 0) { + snprintf(linebuf, sizeof(linebuf), "rated %s", gameinfo.ratingvalue); + if (!strcmp(gameinfo.ratingtype,"PEGI")) + snprintf(linebuf, sizeof(linebuf), "%s+ ", linebuf); + snprintf(linebuf, sizeof(linebuf), "%s ", linebuf); + } + if (strcmp(gameinfo.players,"") != 0) { + snprintf(linebuf, sizeof(linebuf), "%sfor %s player", linebuf, gameinfo.players); + if (atoi(gameinfo.players) > 1) + snprintf(linebuf, sizeof(linebuf), "%ss", linebuf); + if (atoi(gameinfo.wifiplayers) > 1) + snprintf(linebuf, sizeof(linebuf), "%s (%s online)", linebuf, gameinfo.wifiplayers); + } + printf("%s\n",linebuf); + strcpy(linebuf,""); + } } -char *MemInfo() -{ - char linebuf[300] = ""; - char memtotal[20]; - char memused[20]; - char memnotinuse[20]; - char memcanbefreed[20]; - struct mallinfo mymallinfo = mallinfo(); - sprintf(memtotal,"%d",mymallinfo.arena/1024); - sprintf(memused,"%d",mymallinfo.uordblks/1024); - sprintf(memnotinuse,"%d",mymallinfo.fordblks/1024); - sprintf(memcanbefreed,"%d",mymallinfo.keepcost/1024); - snprintf(linebuf,sizeof(linebuf),"all:%sKB used:%sKB notused:%sKB canfree:%sKB", memtotal, memused, memnotinuse, memcanbefreed); - char *minfo[300]; - *minfo = linebuf; - return *minfo; +char *MemInfo() { + char linebuf[300] = ""; + char memtotal[20]; + char memused[20]; + char memnotinuse[20]; + char memcanbefreed[20]; + struct mallinfo mymallinfo = mallinfo(); + sprintf(memtotal,"%d",mymallinfo.arena/1024); + sprintf(memused,"%d",mymallinfo.uordblks/1024); + sprintf(memnotinuse,"%d",mymallinfo.fordblks/1024); + sprintf(memcanbefreed,"%d",mymallinfo.keepcost/1024); + snprintf(linebuf,sizeof(linebuf),"all:%sKB used:%sKB notused:%sKB canfree:%sKB", memtotal, memused, memnotinuse, memcanbefreed); + char *minfo[300]; + *minfo = linebuf; + return *minfo; } /*-------------------------------------------------------------------------------------*/ /* get_text() - Get the text for a node, taken from mini-mxml example mxmldoc.c */ -static char * get_text(mxml_node_t *node, char *buffer, int buflen) /* O - Text in node, I - Node to get, I - Buffer, I - Size of buffer */ -{ - char *ptr, *end; /* Pointer into buffer, End of buffer */ - int len; /* Length of node */ - mxml_node_t *current; /* Current node */ - ptr = buffer; - end = buffer + buflen - 1; - for (current = node->child; current && ptr < end; current = current->next) - { - if (current->type == MXML_TEXT) { - if (current->value.text.whitespace) - *ptr++ = ' '; - len = (int)strlen(current->value.text.string); - if (len > (int)(end - ptr)) - len = (int)(end - ptr); - memcpy(ptr, current->value.text.string, len); - ptr += len; - } else if (current->type == MXML_OPAQUE) { - len = (int)strlen(current->value.opaque); - if (len > (int)(end - ptr)) - len = (int)(end - ptr); - memcpy(ptr, current->value.opaque, len); - ptr += len; +static char * get_text(mxml_node_t *node, char *buffer, int buflen) { /* O - Text in node, I - Node to get, I - Buffer, I - Size of buffer */ + char *ptr, *end; /* Pointer into buffer, End of buffer */ + int len; /* Length of node */ + mxml_node_t *current; /* Current node */ + ptr = buffer; + end = buffer + buflen - 1; + for (current = node->child; current && ptr < end; current = current->next) { + if (current->type == MXML_TEXT) { + if (current->value.text.whitespace) + *ptr++ = ' '; + len = (int)strlen(current->value.text.string); + if (len > (int)(end - ptr)) + len = (int)(end - ptr); + memcpy(ptr, current->value.text.string, len); + ptr += len; + } else if (current->type == MXML_OPAQUE) { + len = (int)strlen(current->value.opaque); + if (len > (int)(end - ptr)) + len = (int)(end - ptr); + memcpy(ptr, current->value.opaque, len); + ptr += len; + } } - } - *ptr = '\0'; - return (buffer); + *ptr = '\0'; + return (buffer); } diff --git a/source/xml/xml.h b/source/xml/xml.h index 3c9a1896..bcf6b4f5 100644 --- a/source/xml/xml.h +++ b/source/xml/xml.h @@ -6,69 +6,67 @@ #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif // open database, close database, load info for a game -bool OpenXMLDatabase(char* xmlfilepath, char* argdblang, bool argJPtoEN, bool openfile, bool loadtitles, bool keepopen); -void CloseXMLDatabase(); -bool LoadGameInfoFromXML(char* gameid, char* langcode); + bool OpenXMLDatabase(char* xmlfilepath, char* argdblang, bool argJPtoEN, bool openfile, bool loadtitles, bool keepopen); + void CloseXMLDatabase(); + bool LoadGameInfoFromXML(char* gameid, char* langcode); #define XML_ELEMMAX 15 -struct gameXMLinfo -{ - char id[7]; - char version[50]; - char region[7]; - char title[200]; - char synopsis[3000]; - char title_EN[200]; - char synopsis_EN[3000]; - char locales[XML_ELEMMAX+1][3]; - int localeCnt; - char developer[75]; - char publisher[75]; - char publisherfromid[75]; - char year[5]; - char month[3]; - char day[3]; - char genre[75]; - char genresplit[XML_ELEMMAX+1][20]; - int genreCnt; - char ratingtype[5]; - char ratingvalue[5]; - char ratingdescriptors[XML_ELEMMAX+1][40]; - int descriptorCnt; - char ratingvalueCERO[5]; - char ratingvalueESRB[5]; - char ratingvaluePEGI[5]; - char wifiplayers[4]; - char wififeatures[XML_ELEMMAX+1][20]; - int wifiCnt; - char players[4]; - char accessories[XML_ELEMMAX+1][20]; - int accessoryCnt; - char accessoriesReq[XML_ELEMMAX+1][20]; - int accessoryReqCnt; - char iso_crc[9]; - char iso_md5[33]; - char iso_sha1[41]; -} ; + struct gameXMLinfo { + char id[7]; + char version[50]; + char region[7]; + char title[200]; + char synopsis[3000]; + char title_EN[200]; + char synopsis_EN[3000]; + char locales[XML_ELEMMAX+1][3]; + int localeCnt; + char developer[75]; + char publisher[75]; + char publisherfromid[75]; + char year[5]; + char month[3]; + char day[3]; + char genre[75]; + char genresplit[XML_ELEMMAX+1][20]; + int genreCnt; + char ratingtype[5]; + char ratingvalue[5]; + char ratingdescriptors[XML_ELEMMAX+1][40]; + int descriptorCnt; + char ratingvalueCERO[5]; + char ratingvalueESRB[5]; + char ratingvaluePEGI[5]; + char wifiplayers[4]; + char wififeatures[XML_ELEMMAX+1][20]; + int wifiCnt; + char players[4]; + char accessories[XML_ELEMMAX+1][20]; + int accessoryCnt; + char accessoriesReq[XML_ELEMMAX+1][20]; + int accessoryReqCnt; + char iso_crc[9]; + char iso_md5[33]; + char iso_sha1[41]; + } ; -bool OpenXMLFile(char* filename); -void LoadTitlesFromXML(char *langcode, bool forcejptoen); -void GetPublisherFromGameid(char *idtxt, char *dest, int destsize); -char *ConvertLangTextToCode(char *langtext); -void ConvertRating(char *ratingvalue, char *fromrating, char *torating, char *destvalue, int destsize); -void PrintGameInfo(bool showfullinfo); -char *MemInfo(); -void GetTextFromNode(mxml_node_t *currentnode, mxml_node_t *topnode, char *nodename, - char *attributename, char *value, int descend, char *dest, int destsize); + bool OpenXMLFile(char* filename); + void LoadTitlesFromXML(char *langcode, bool forcejptoen); + void GetPublisherFromGameid(char *idtxt, char *dest, int destsize); + char *ConvertLangTextToCode(char *langtext); + void ConvertRating(char *ratingvalue, char *fromrating, char *torating, char *destvalue, int destsize); + void PrintGameInfo(bool showfullinfo); + char *MemInfo(); + void GetTextFromNode(mxml_node_t *currentnode, mxml_node_t *topnode, char *nodename, + char *attributename, char *value, int descend, char *dest, int destsize); -void title_set(char *id, char *title); -char* trimcopy(char *dest, char *src, int size); + void title_set(char *id, char *title); + char* trimcopy(char *dest, char *src, int size); #ifdef __cplusplus }