From 541786bc8634bc22b4ed21419b48a92b1bea4612 Mon Sep 17 00:00:00 2001 From: Steveice10 Date: Sun, 8 Jan 2017 11:23:05 -0800 Subject: [PATCH] Add new logo by PabloMK7, fade in text on CIA/3DS startup. --- Makefile | 2 +- README.md | 4 +- meta/logo_3ds.bcma.lz | Bin 0 -> 8192 bytes servefiles/servefiles.py | 2 +- source/core/screen.c | 144 +++++++++++++++++++++++++-------------- source/core/screen.h | 1 + source/main.c | 2 +- source/ui/ui.c | 24 +++++++ 8 files changed, 121 insertions(+), 58 deletions(-) create mode 100644 meta/logo_3ds.bcma.lz diff --git a/Makefile b/Makefile index d64d120..a8dce7a 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ ifeq ($(TARGET),3DS) BANNER_AUDIO := meta/audio_3ds.wav BANNER_IMAGE := meta/banner_3ds.cgfx ICON := meta/icon_3ds.png - LOGO := + LOGO := meta/logo_3ds.bcma.lz endif # Wii U CONFIGURATION # diff --git a/README.md b/README.md index 16a32cf..d64a010 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,6 @@ Requires [devkitARM](http://sourceforge.net/projects/devkitpro/files/devkitARM/) Banner: [OctopusRift](http://gbatemp.net/members/octopusrift.356526/), [Apache Thunder](https://gbatemp.net/members/apache-thunder.105648/) -SPI Protocol Information: [TuxSH](https://github.com/TuxSH/) ([TWLSaveTool](https://github.com/TuxSH/TWLSaveTool)) +Logo: [PabloMK7](http://gbatemp.net/members/pablomk7.345712/) -svchax: [aliaspider](https://github.com/aliaspider), waithax: [Mrrraou](https://github.com/Mrrraou) \ No newline at end of file +SPI Protocol Information: [TuxSH](https://github.com/TuxSH/) ([TWLSaveTool](https://github.com/TuxSH/TWLSaveTool)) diff --git a/meta/logo_3ds.bcma.lz b/meta/logo_3ds.bcma.lz new file mode 100644 index 0000000000000000000000000000000000000000..43fb7c322bf7234875fa343b943154950723ec8c GIT binary patch literal 8192 zcmeIy|5Fs_9S88wvwO#4&&Xc1Vn&;Lj#E&vxj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Z~DUx-`wX zcG>d_qW{V_M4&5E?JsjF-uXCCV>jE!@@Cz)`E?J$?uqt0w)Q)_ zKd8UtVe&t#YMh3&bgFS$+UzQ9g5Av!$v}EKqda#EoEeoUvK4h_fb$oykWoHIi5Xu^ z3_$sDw0;1#nba{4Afh`zkWD8B(!K%I^VPstzV5{R4=(cw#N|WxjlY?iZp8ioeP` ") + print("Usage: " + sys.argv[0] + " [host ip]") sys.exit(1) ip = sys.argv[1] diff --git a/source/core/screen.c b/source/core/screen.c index f0c7d31..1235dbf 100644 --- a/source/core/screen.c +++ b/source/core/screen.c @@ -12,7 +12,7 @@ #include "default_shbin.h" -GX_TRANSFER_FORMAT gpuToGxFormat[13] = { +GX_TRANSFER_FORMAT gpu_to_gx_format[13] = { GX_TRANSFER_FMT_RGBA8, GX_TRANSFER_FMT_RGB8, GX_TRANSFER_FMT_RGB5A1, @@ -28,11 +28,11 @@ GX_TRANSFER_FORMAT gpuToGxFormat[13] = { GX_TRANSFER_FMT_RGBA8 // Unsupported }; -static u32 colorConfig[NUM_COLORS] = {0xFF000000}; +static u32 color_config[NUM_COLORS] = {0xFF000000}; -static bool c3dInitialized; +static bool c3d_initialized; -static bool shaderInitialized; +static bool shader_initialized; static DVLB_s* dvlb; static shaderProgram_s program; @@ -50,7 +50,9 @@ static struct { u32 pow2Height; } textures[MAX_TEXTURES]; -static C3D_Tex* glyphSheets; +static C3D_Tex* glyph_sheets; + +static u8 base_alpha = 0xFF; static FILE* screen_open_resource(const char* path) { u32 realPathSize = strlen(path) + 17; @@ -74,7 +76,7 @@ void screen_init() { return; } - c3dInitialized = true; + c3d_initialized = true; target_top = C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8); if(target_top == NULL) { @@ -108,7 +110,7 @@ void screen_init() { return; } - shaderInitialized = true; + shader_initialized = true; Result progSetVshRes = shaderProgramSetVsh(&program, &dvlb->DVLE[0]); if(R_FAILED(progSetVshRes)) { @@ -134,8 +136,8 @@ void screen_init() { return; } - C3D_TexEnvSrc(env, C3D_Both, GPU_TEXTURE0, 0, 0); - C3D_TexEnvOp(env, C3D_Both, 0, 0, 0); + C3D_TexEnvSrc(env, C3D_Both, GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR); + C3D_TexEnvOp(env, C3D_Both, GPU_TEVOP_RGB_SRC_COLOR, GPU_TEVOP_RGB_SRC_COLOR, GPU_TEVOP_RGB_SRC_COLOR); C3D_TexEnvFunc(env, C3D_Both, GPU_REPLACE); C3D_DepthTest(true, GPU_GEQUAL, GPU_WRITE_ALL); @@ -150,14 +152,14 @@ void screen_init() { } TGLP_s* glyphInfo = fontGetGlyphInfo(); - glyphSheets = calloc(glyphInfo->nSheets, sizeof(C3D_Tex)); - if(glyphSheets == NULL) { + glyph_sheets = calloc(glyphInfo->nSheets, sizeof(C3D_Tex)); + if(glyph_sheets == NULL) { util_panic("Failed to allocate font glyph texture data."); return; } for(int i = 0; i < glyphInfo->nSheets; i++) { - C3D_Tex* tex = &glyphSheets[i]; + C3D_Tex* tex = &glyph_sheets[i]; tex->data = fontGetGlyphSheetTex(i); tex->fmt = (GPU_TEXCOLOR) glyphInfo->sheetFmt; tex->size = glyphInfo->sheetSize; @@ -190,31 +192,31 @@ void screen_init() { u32 color = strtoul(value, NULL, 16); if(strcasecmp(key, "text") == 0) { - colorConfig[COLOR_TEXT] = color; + color_config[COLOR_TEXT] = color; } else if(strcasecmp(key, "nand") == 0) { - colorConfig[COLOR_NAND] = color; + color_config[COLOR_NAND] = color; } else if(strcasecmp(key, "sd") == 0) { - colorConfig[COLOR_SD] = color; + color_config[COLOR_SD] = color; } else if(strcasecmp(key, "gamecard") == 0) { - colorConfig[COLOR_GAME_CARD] = color; + color_config[COLOR_GAME_CARD] = color; } else if(strcasecmp(key, "dstitle") == 0) { - colorConfig[COLOR_DS_TITLE] = color; + color_config[COLOR_DS_TITLE] = color; } else if(strcasecmp(key, "file") == 0) { - colorConfig[COLOR_FILE] = color; + color_config[COLOR_FILE] = color; } else if(strcasecmp(key, "directory") == 0) { - colorConfig[COLOR_DIRECTORY] = color; + color_config[COLOR_DIRECTORY] = color; } else if(strcasecmp(key, "enabled") == 0) { - colorConfig[COLOR_ENABLED] = color; + color_config[COLOR_ENABLED] = color; } else if(strcasecmp(key, "disabled") == 0) { - colorConfig[COLOR_DISABLED] = color; + color_config[COLOR_DISABLED] = color; } else if(strcasecmp(key, "installed") == 0) { - colorConfig[COLOR_INSTALLED] = color; + color_config[COLOR_INSTALLED] = color; } else if(strcasecmp(key, "notinstalled") == 0) { - colorConfig[COLOR_NOT_INSTALLED] = color; + color_config[COLOR_NOT_INSTALLED] = color; } else if(strcasecmp(key, "ticketinuse") == 0) { - colorConfig[COLOR_TICKET_IN_USE] = color; + color_config[COLOR_TICKET_IN_USE] = color; } else if(strcasecmp(key, "ticketnotinuse") == 0) { - colorConfig[COLOR_TICKET_NOT_IN_USE] = color; + color_config[COLOR_TICKET_NOT_IN_USE] = color; } } } @@ -259,14 +261,14 @@ void screen_exit() { screen_unload_texture(id); } - if(glyphSheets != NULL) { - free(glyphSheets); - glyphSheets = NULL; + if(glyph_sheets != NULL) { + free(glyph_sheets); + glyph_sheets = NULL; } - if(shaderInitialized) { + if(shader_initialized) { shaderProgramFree(&program); - shaderInitialized = false; + shader_initialized = false; } if(dvlb != NULL) { @@ -284,12 +286,16 @@ void screen_exit() { target_bottom = NULL; } - if(c3dInitialized) { + if(c3d_initialized) { C3D_Fini(); - c3dInitialized = false; + c3d_initialized = false; } } +void screen_set_base_alpha(u8 alpha) { + base_alpha = alpha; +} + static u32 screen_next_pow_2(u32 i) { i--; i |= i >> 1; @@ -358,7 +364,7 @@ void screen_load_texture(u32 id, void* data, u32 size, u32 width, u32 height, GP return; } - C3D_SafeDisplayTransfer((u32*) pow2Tex, GX_BUFFER_DIM(pow2Width, pow2Height), (u32*) textures[id].tex.data, GX_BUFFER_DIM(pow2Width, pow2Height), GX_TRANSFER_FLIP_VERT(1) | GX_TRANSFER_OUT_TILED(1) | GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT((u32) gpuToGxFormat[format]) | GX_TRANSFER_OUT_FORMAT((u32) gpuToGxFormat[format]) | GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO)); + C3D_SafeDisplayTransfer((u32*) pow2Tex, GX_BUFFER_DIM(pow2Width, pow2Height), (u32*) textures[id].tex.data, GX_BUFFER_DIM(pow2Width, pow2Height), GX_TRANSFER_FLIP_VERT(1) | GX_TRANSFER_OUT_TILED(1) | GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT((u32) gpu_to_gx_format[format]) | GX_TRANSFER_OUT_FORMAT((u32) gpu_to_gx_format[format]) | GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO)); gspWaitForPPF(); linearFree(pow2Tex); @@ -552,6 +558,32 @@ void screen_set_scissor(bool enabled, u32 x, u32 y, u32 width, u32 height) { C3D_SetScissor(enabled ? GPU_SCISSOR_NORMAL : GPU_SCISSOR_DISABLE, 240 - (y + height), x, 240 - y, x + width); } +static void screen_set_blend(u32 color, bool rgb, bool alpha) { + C3D_TexEnv* env = C3D_GetTexEnv(0); + if(env == NULL) { + util_panic("Failed to retrieve combiner settings."); + return; + } + + if(rgb) { + C3D_TexEnvSrc(env, C3D_RGB, GPU_CONSTANT, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR); + C3D_TexEnvFunc(env, C3D_RGB, GPU_REPLACE); + } else { + C3D_TexEnvSrc(env, C3D_RGB, GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR); + C3D_TexEnvFunc(env, C3D_RGB, GPU_REPLACE); + } + + if(alpha) { + C3D_TexEnvSrc(env, C3D_Alpha, GPU_TEXTURE0, GPU_CONSTANT, GPU_PRIMARY_COLOR); + C3D_TexEnvFunc(env, C3D_Alpha, GPU_MODULATE); + } else { + C3D_TexEnvSrc(env, C3D_Alpha, GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR); + C3D_TexEnvFunc(env, C3D_Alpha, GPU_REPLACE); + } + + C3D_TexEnvColor(env, color); +} + static void screen_draw_quad(float x1, float y1, float x2, float y2, float tx1, float ty1, float tx2, float ty2) { C3D_ImmDrawBegin(GPU_TRIANGLES); @@ -582,8 +614,16 @@ void screen_draw_texture(u32 id, float x, float y, float width, float height) { return; } + if(base_alpha != 0xFF) { + screen_set_blend(base_alpha << 24, false, true); + } + C3D_TexBind(0, &textures[id].tex); screen_draw_quad(x, y, x + width, y + height, 0, 0, (float) textures[id].width / (float) textures[id].pow2Width, (float) textures[id].height / (float) textures[id].pow2Height); + + if(base_alpha != 0xFF) { + screen_set_blend(0, false, false); + } } void screen_draw_texture_crop(u32 id, float x, float y, float width, float height) { @@ -592,8 +632,16 @@ void screen_draw_texture_crop(u32 id, float x, float y, float width, float heigh return; } + if(base_alpha != 0xFF) { + screen_set_blend(base_alpha << 24, false, true); + } + C3D_TexBind(0, &textures[id].tex); screen_draw_quad(x, y, x + width, y + height, 0, 0, width / (float) textures[id].pow2Width, height / (float) textures[id].pow2Height); + + if(base_alpha != 0xFF) { + screen_set_blend(0, false, false); + } } float screen_get_font_height(float scaleY) { @@ -667,18 +715,16 @@ static void screen_draw_string_internal(const char* text, float x, float y, floa return; } - C3D_TexEnv* env = C3D_GetTexEnv(0); - if(env == NULL) { - util_panic("Failed to retrieve combiner settings."); - return; + u32 blendColor = color_config[colorId]; + if(base_alpha != 0xFF) { + float alpha1 = ((blendColor >> 24) & 0xFF) / 255.0f; + float alpha2 = base_alpha / 255.0f; + float blendedAlpha = alpha1 * alpha2; + + blendColor = (((u32) (blendedAlpha * 0xFF)) << 24) | (blendColor & 0x00FFFFFF); } - C3D_TexEnvSrc(env, C3D_RGB, GPU_CONSTANT, 0, 0); - C3D_TexEnvSrc(env, C3D_Alpha, GPU_TEXTURE0, GPU_CONSTANT, 0); - C3D_TexEnvOp(env, C3D_Both, 0, 0, 0); - C3D_TexEnvFunc(env, C3D_RGB, GPU_REPLACE); - C3D_TexEnvFunc(env, C3D_Alpha, GPU_MODULATE); - C3D_TexEnvColor(env, colorConfig[colorId]); + screen_set_blend(blendColor, true, true); float stringWidth; screen_get_string_size_internal(&stringWidth, NULL, text, scaleX, scaleY, false, wrap, wrapX); @@ -727,7 +773,7 @@ static void screen_draw_string_internal(const char* text, float x, float y, floa if(data.sheetIndex != lastSheet) { lastSheet = data.sheetIndex; - C3D_TexBind(0, &glyphSheets[lastSheet]); + C3D_TexBind(0, &glyph_sheets[lastSheet]); } for(u32 i = 0; i < num; i++) { @@ -738,15 +784,7 @@ static void screen_draw_string_internal(const char* text, float x, float y, floa } } - env = C3D_GetTexEnv(0); - if(env == NULL) { - util_panic("Failed to retrieve combiner settings."); - return; - } - - C3D_TexEnvSrc(env, C3D_Both, GPU_TEXTURE0, 0, 0); - C3D_TexEnvOp(env, C3D_Both, 0, 0, 0); - C3D_TexEnvFunc(env, C3D_Both, GPU_REPLACE); + screen_set_blend(0, false, false); } void screen_draw_string(const char* text, float x, float y, float scaleX, float scaleY, u32 colorId, bool centerLines) { diff --git a/source/core/screen.h b/source/core/screen.h index 041984e..9b65bd7 100644 --- a/source/core/screen.h +++ b/source/core/screen.h @@ -60,6 +60,7 @@ void screen_init(); void screen_exit(); +void screen_set_base_alpha(u8 alpha); void screen_load_texture(u32 id, void* data, u32 size, u32 width, u32 height, GPU_TEXCOLOR format, bool linearFilter); u32 screen_load_texture_auto(void* data, u32 size, u32 width, u32 height, GPU_TEXCOLOR format, bool linearFilter); void screen_load_texture_file(u32 id, const char* path, bool linearFilter); diff --git a/source/main.c b/source/main.c index e39ff1d..2eef5a6 100644 --- a/source/main.c +++ b/source/main.c @@ -173,7 +173,7 @@ void cleanup() { } int main(int argc, const char* argv[]) { - if(argc > 0) { + if(argc > 0 && envIsHomebrew()) { util_set_3dsx_path(argv[0]); } diff --git a/source/ui/ui.c b/source/ui/ui.c index 97bb141..27132ad 100644 --- a/source/ui/ui.c +++ b/source/ui/ui.c @@ -20,10 +20,15 @@ static Handle ui_stack_mutex = 0; static u64 ui_free_space_last_update = 0; static char ui_free_space_buffer[128]; +static u64 ui_fade_begin_time = 0; +static u8 ui_fade_in_alpha = 0; + void ui_init() { if(ui_stack_mutex == 0) { svcCreateMutex(&ui_stack_mutex, false); } + + ui_fade_begin_time = osGetTime(); } void ui_exit() { @@ -140,6 +145,8 @@ static void ui_draw_top(ui_view* ui) { screen_draw_texture(TEXTURE_TOP_SCREEN_BOTTOM_BAR, topScreenBottomBarX, topScreenBottomBarY, topScreenBottomBarWidth, topScreenBottomBarHeight); screen_draw_texture(TEXTURE_TOP_SCREEN_BOTTOM_BAR_SHADOW, topScreenBottomBarX, topScreenBottomBarY - topScreenBottomBarShadowHeight, topScreenBottomBarShadowWidth, topScreenBottomBarShadowHeight); + screen_set_base_alpha(ui_fade_in_alpha); + char verText[64]; snprintf(verText, 64, "Ver. %d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO); @@ -247,6 +254,8 @@ static void ui_draw_top(ui_view* ui) { screen_get_string_size(NULL, &freeSpaceHeight, ui_free_space_buffer, 0.35f, 0.35f); screen_draw_string(ui_free_space_buffer, topScreenBottomBarX + 2, topScreenBottomBarY + (topScreenBottomBarHeight - freeSpaceHeight) / 2, 0.35f, 0.35f, COLOR_TEXT, true); + + screen_set_base_alpha(0xFF); } static void ui_draw_bottom(ui_view* ui) { @@ -273,10 +282,14 @@ static void ui_draw_bottom(ui_view* ui) { screen_select(GFX_BOTTOM); screen_draw_texture(TEXTURE_BOTTOM_SCREEN_BG, (BOTTOM_SCREEN_WIDTH - bottomScreenBgWidth) / 2, (BOTTOM_SCREEN_HEIGHT - bottomScreenBgHeight) / 2, bottomScreenBgWidth, bottomScreenBgHeight); + screen_set_base_alpha(ui_fade_in_alpha); + if(ui->drawBottom != NULL) { ui->drawBottom(ui, ui->data, 0, bottomScreenTopBarHeight, BOTTOM_SCREEN_WIDTH, BOTTOM_SCREEN_HEIGHT - bottomScreenBottomBarHeight); } + screen_set_base_alpha(0xFF); + float bottomScreenTopBarX = (BOTTOM_SCREEN_WIDTH - bottomScreenTopBarWidth) / 2; float bottomScreenTopBarY = 0; screen_draw_texture(TEXTURE_BOTTOM_SCREEN_TOP_BAR, bottomScreenTopBarX, bottomScreenTopBarY, bottomScreenTopBarWidth, bottomScreenTopBarHeight); @@ -287,6 +300,8 @@ static void ui_draw_bottom(ui_view* ui) { screen_draw_texture(TEXTURE_BOTTOM_SCREEN_BOTTOM_BAR, bottomScreenBottomBarX, bottomScreenBottomBarY, bottomScreenBottomBarWidth, bottomScreenBottomBarHeight); screen_draw_texture(TEXTURE_BOTTOM_SCREEN_BOTTOM_BAR_SHADOW, bottomScreenBottomBarX, bottomScreenBottomBarY - bottomScreenBottomBarShadowHeight, bottomScreenBottomBarShadowWidth, bottomScreenBottomBarShadowHeight); + screen_set_base_alpha(ui_fade_in_alpha); + if(ui->name != NULL) { float nameWidth; float nameHeight; @@ -300,6 +315,8 @@ static void ui_draw_bottom(ui_view* ui) { screen_get_string_size(&infoWidth, &infoHeight, ui->info, 0.5f, 0.5f); screen_draw_string(ui->info, (BOTTOM_SCREEN_WIDTH - infoWidth) / 2, BOTTOM_SCREEN_HEIGHT - (bottomScreenBottomBarHeight + infoHeight) / 2, 0.5f, 0.5f, COLOR_TEXT, true); } + + screen_set_base_alpha(0xFF); } bool ui_update() { @@ -326,6 +343,13 @@ bool ui_update() { screen_end_frame(); } + u64 time = osGetTime(); + if(!envIsHomebrew() && time - ui_fade_begin_time < 500) { + ui_fade_in_alpha = (u8) (((time - ui_fade_begin_time) / 500.0f) * 0xFF); + } else { + ui_fade_in_alpha = 0xFF; + } + return ui != NULL; }