mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-20 04:31:09 +02:00
Drop stb_image from Switch OTA launcher with a pre-baked logo asset.
This commit is contained in:
@@ -46,7 +46,8 @@ APP_VERSION ?= 0.0.0
|
||||
|
||||
# Prefer project Switch icon if present
|
||||
ICON := $(TOPDIR)/../../assets/switch/icon.jpg
|
||||
LOGO_SRC := $(TOPDIR)/../../assets/logo/logo.png
|
||||
LOGO_RGBA_SRC := $(TOPDIR)/assets/logo.rgba
|
||||
LOGO_ROMFS := $(CURDIR)/$(ROMFS)/logo.rgba
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
|
||||
@@ -148,7 +149,8 @@ bootstrap-romfs:
|
||||
|
||||
sync-romfs: bootstrap-romfs
|
||||
@mkdir -p $(CURDIR)/$(ROMFS)
|
||||
@cp -f $(LOGO_SRC) $(CURDIR)/$(ROMFS)/logo.png
|
||||
@[ -f "$(LOGO_RGBA_SRC)" ] || (echo "missing $(LOGO_RGBA_SRC) — run: python3 scripts/switch/bake_ota_logo.py" && exit 1)
|
||||
@cp -f "$(LOGO_RGBA_SRC)" "$(LOGO_ROMFS)"
|
||||
@if ! curl -sfL --time-cond $(CACERT_ROMFS) -o $(CACERT_ROMFS) $(CACERT_URL); then \
|
||||
[ -f $(CACERT_ROMFS) ] || (echo "sync-romfs: failed to fetch cacert.pem" && exit 1); \
|
||||
fi
|
||||
@@ -161,7 +163,7 @@ $(BUILD): sync-romfs
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf $(TARGET).lst build-host
|
||||
@rm -f $(CURDIR)/$(ROMFS)/logo.png
|
||||
@rm -f $(CURDIR)/$(ROMFS)/logo.rgba $(CURDIR)/$(ROMFS)/logo.png
|
||||
|
||||
host-test:
|
||||
@mkdir -p build-host
|
||||
|
||||
@@ -59,6 +59,18 @@ scripts/switch/build_ota_launcher.sh
|
||||
|
||||
Docker fallback uses the same pin as fused builds (`scripts/switch/dkp-docker.image`).
|
||||
|
||||
## OTA logo asset
|
||||
|
||||
The launcher draws a pre-scaled logo from `romfs:/logo.rgba` (no PNG decoder in
|
||||
the NRO). The baked blob lives at `assets/logo.rgba` and is copied into romfs at
|
||||
build time. After changing `assets/logo/logo.png`, regenerate:
|
||||
|
||||
```bash
|
||||
python3 scripts/switch/bake_ota_logo.py
|
||||
```
|
||||
|
||||
Requires Pillow, or on macOS uses `sips` when Pillow is not installed.
|
||||
|
||||
## Packaging
|
||||
|
||||
`scripts/switch/pack_sd_zip.sh GAME_NRO VERSION OUT_ZIP LAUNCHER_NRO` writes both
|
||||
|
||||
Binary file not shown.
@@ -12,12 +12,10 @@
|
||||
#if defined(__SWITCH__)
|
||||
#include <switch.h>
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STBI_ONLY_PNG
|
||||
#define STBI_NO_THREAD_LOCALS
|
||||
#include "../third_party/stb_image.h"
|
||||
#include "../third_party/font8x8_basic.h"
|
||||
|
||||
#define OTA_LOGO_ROMFS "romfs:/logo.rgba"
|
||||
|
||||
#define FB_W 1280
|
||||
#define FB_H 720
|
||||
|
||||
@@ -261,25 +259,47 @@ static void blit_logo(u32 *fb, u32 stride_px, int dst_x, int dst_y, int max_w) {
|
||||
|
||||
static void load_logo(void) {
|
||||
if (g_logo) return;
|
||||
/* romfs is mounted in ota_net_init() before the release check runs. */
|
||||
int w = 0, h = 0, n = 0;
|
||||
unsigned char *data = stbi_load("romfs:/logo.png", &w, &h, &n, 4);
|
||||
if (!data || w <= 0 || h <= 0) {
|
||||
if (data) stbi_image_free(data);
|
||||
FILE *fp = fopen(OTA_LOGO_ROMFS, "rb");
|
||||
if (!fp) return;
|
||||
|
||||
unsigned char header[8];
|
||||
if (fread(header, 1, sizeof(header), fp) != sizeof(header)) {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
int w = (int)(header[0] | (header[1] << 8) | (header[2] << 16) | (header[3] << 24));
|
||||
int h = (int)(header[4] | (header[5] << 8) | (header[6] << 16) | (header[7] << 24));
|
||||
if (w <= 0 || h <= 0 || w > 2048 || h > 2048) {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
size_t nbytes = (size_t)w * (size_t)h * 4u;
|
||||
unsigned char *data = (unsigned char *)malloc(nbytes);
|
||||
if (!data) {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
if (fread(data, 1, nbytes, fp) != nbytes) {
|
||||
free(data);
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
g_logo = (u32 *)malloc((size_t)w * (size_t)h * sizeof(u32));
|
||||
if (!g_logo) {
|
||||
stbi_image_free(data);
|
||||
free(data);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < w * h; i++) {
|
||||
unsigned char *p = data + i * 4;
|
||||
unsigned char *p = data + (size_t)i * 4u;
|
||||
g_logo[i] = RGBA8(p[0], p[1], p[2], p[3]);
|
||||
}
|
||||
free(data);
|
||||
g_logo_w = w;
|
||||
g_logo_h = h;
|
||||
stbi_image_free(data);
|
||||
}
|
||||
|
||||
static int ui_ensure(void) {
|
||||
|
||||
-7988
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user