Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ae8ef99
Explicitly build with C23
BenHetherington Jul 7, 2025
fe7a7aa
First pass at reading discs, load banner into menu
BenHetherington May 17, 2025
b3d1dbb
Surround my temporary changes with a `#if`
BenHetherington May 22, 2025
d9dca51
Show the disc within the gameplay menu
BenHetherington May 22, 2025
35fec7f
Allow disc games to be started
BenHetherington May 30, 2025
455c0fa
Restart the BGM if game startup is interrupted
BenHetherington May 30, 2025
91f36b1
Allow switching between disc drive and FlippyDrive
BenHetherington Jun 1, 2025
ca4c073
Allow disc access to be interrupted/cancelled
BenHetherington Jun 2, 2025
686655b
Ensure banner is faded before switching device
BenHetherington Jun 2, 2025
198afa6
Move bs2tick and co. to a new file
BenHetherington Jun 14, 2025
b071a58
Move audio and drawing relocs to their own files
BenHetherington Jun 14, 2025
433c91c
Add element alpha and button description code
BenHetherington Jun 14, 2025
c15cce3
Add UI for switching between Flippy and disc drive
BenHetherington Jun 14, 2025
d1859f4
Move device selection code, minor tidy-ups
BenHetherington Jun 14, 2025
af89f0b
Only allow device changes when fully faded in
BenHetherington Jun 14, 2025
4318ed5
Make an enum for the disc drive and Flippy devices
BenHetherington Jun 15, 2025
37f7def
Add support for an automatic boot order
BenHetherington Jun 28, 2025
e5ec143
Minor tidy-ups
BenHetherington Jun 28, 2025
d01dfaf
Maintain a navigation stack for the gameplay menu
BenHetherington Jun 28, 2025
17d6fd6
Correct icon texture colours & resolve most TODOs
BenHetherington Jul 7, 2025
651a365
Add a setting to disallow disc drive access
BenHetherington Jul 21, 2025
b26799c
Always read the `allow_disc_drive` setting
BenHetherington Sep 7, 2025
b4309b4
Increase delay after entering bypass mode
BenHetherington Sep 8, 2025
044f318
Ensure `bs2init()` runs before `bs2tick()`
BenHetherington Sep 8, 2025
47a530a
Set up audio streaming for discs properly
BenHetherington Sep 20, 2025
3c0c6fa
Check for errors when reading banner
BenHetherington Sep 20, 2025
839889d
Merge branch 'custom-loader-menu' into integrate-discs-into-menu
BenHetherington Mar 1, 2026
52b9278
Merge branch 'custom-loader-menu' into integrate-discs-into-menu
trevor403 Mar 22, 2026
c720035
Merge branch 'custom-loader-menu' into integrate-discs-into-menu
BenHetherington Mar 26, 2026
8f29453
Fix types in `draw_blob_fixed` declaration
BenHetherington Jul 30, 2025
25a148d
Update the MemCard Pro game ID for discs in-menu
BenHetherington Mar 26, 2026
903640f
Add script to generate BTI textures from PNGs
BenHetherington May 29, 2026
e24a02d
Fix BTI textures, use Python gclib for conversion
BenHetherington Jun 7, 2026
870f22c
Add remaining textures to `convert.py`
BenHetherington Jun 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cubeboot/include/device.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

typedef enum {
device_disc_drive,
device_flippydrive
} device_t;
4 changes: 4 additions & 0 deletions cubeboot/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ int main(int argc, char **argv) {
// strcpy(cube_logo_ptr, settings.cube_logo);
// }

set_patch_value(symshdr, syment, symstringdata, "boot_devices", (uintptr_t)&settings.boot_devices);
set_patch_value(symshdr, syment, symstringdata, "boot_devices_count", settings.boot_devices_count);
set_patch_value(symshdr, syment, symstringdata, "is_disc_drive_allowed", settings.allow_disc_drive);

// Copy other variables
set_patch_value(symshdr, syment, symstringdata, "is_running_dolphin", is_running_dolphin);

Expand Down
101 changes: 101 additions & 0 deletions cubeboot/source/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <ctype.h>

#include "sd.h"
#include "halt.h"
Expand All @@ -28,6 +29,64 @@ char *buttons_names[] = {
"start", // START 0x1000
};

static void trim_string(const char **inout_string, u32 *inout_length) {
while (*inout_length > 0 && isspace((unsigned char)(*inout_string)[0])) {
// Trim leading whitespace
*inout_string += 1;
*inout_length -= 1;
}
while (*inout_length > 0 && isspace((unsigned char)(*inout_string)[*inout_length - 1])) {
// Trim trailing whitespace
*inout_length -= 1;
}
}

static bool get_device_from_string(const char *string, u32 length, device_t *out_device) {
trim_string(&string, &length);

if (strncmp("disc_drive", string, length) == 0) {
*out_device = device_disc_drive;
return true;
}
if (strncmp("flippydrive", string, length) == 0) {
*out_device = device_flippydrive;
return true;
}
return false;
}

static bool tokenise_string(const char **inout_string, u32 *inout_substring_length, const char *delimeters) {
bool has_found_any_delimeters = *inout_substring_length > 0;
if (has_found_any_delimeters) {
// Advance `string` to the next delimiter
*inout_string += *inout_substring_length;
*inout_substring_length = 0;
}

while (*inout_substring_length == 0) {
if ((*inout_string)[0] == '\0') {
// Reached the end of the input string
return false;
}

if (has_found_any_delimeters) {
// Advance beyond that delimiter
*inout_string += 1;
}
has_found_any_delimeters = true;

// Find the next delimiter, and therefore the length of the substring up to that delimiter
const char *delimeter_ptr = strpbrk(*inout_string, delimeters);
if (delimeter_ptr) {
*inout_substring_length = delimeter_ptr - *inout_string;
} else {
*inout_substring_length = strlen(*inout_string);
}
}

return true;
}

void load_settings() {
memset(&settings, 0, sizeof(settings));
int config_size = get_file_size("/config.ini");
Expand Down Expand Up @@ -160,6 +219,48 @@ void load_settings() {
}
}

// Boot order
settings.boot_devices_count = 0;
const char *remaining_boot_order = ini_get(conf, "cubeboot", "boot_order");
if (remaining_boot_order != NULL) {

u32 device_string_length = 0;
while (tokenise_string(&remaining_boot_order, &device_string_length, ",")) {
device_t found_device;
if (get_device_from_string(remaining_boot_order, device_string_length, &found_device)) {
bool already_in_boot_devices = false;
for (u32 i = 0; i < settings.boot_devices_count; i++) {
already_in_boot_devices |= settings.boot_devices[i] == found_device;
}

if (!already_in_boot_devices) {
settings.boot_devices[settings.boot_devices_count] = found_device;
settings.boot_devices_count += 1;
} else {
iprintf("Found duplicate boot device: %.*s\n", device_string_length, remaining_boot_order);
}
} else {
iprintf("Found unknown boot device: %.*s\n", device_string_length, remaining_boot_order);
}

if (settings.boot_devices_count >= MAX_BOOT_DEVICES) {
if (strlen(remaining_boot_order + device_string_length) > 0) {
iprintf("Reached max boot devices (%d), skipping any remaining ones in config\n", MAX_BOOT_DEVICES);
}
break;
}
}
}

// allow_disc_drive
int allow_disc_drive = 0;
if (!ini_sget(conf, "cubeboot", "allow_disc_drive", "%d", &allow_disc_drive)) {
settings.allow_disc_drive = 1;
} else {
iprintf("Found allow_disc_drive = %d\n", allow_disc_drive);
settings.allow_disc_drive = allow_disc_drive;
}

// menu grid type
settings.menu_grid_type = MENU_GRID_SQUARE_ICONS;
const char *menu_grid_type = ini_get(conf, "cubeboot", "menu_grid_type");
Expand Down
6 changes: 6 additions & 0 deletions cubeboot/source/settings.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include <gctypes.h>

#include "const.h"
#include "device.h"
#include "settings_types.h"

#define MAX_BOOT_DEVICES 8

typedef struct settings {
u32 cube_color;
char *cube_logo;
Expand All @@ -15,6 +18,9 @@ typedef struct settings {
u32 postboot_delay_ms;
char *default_program;
char *boot_buttons[MAX_BUTTONS];
device_t boot_devices[MAX_BOOT_DEVICES];
u32 boot_devices_count;
u32 allow_disc_drive;
menu_grid_type_t menu_grid_type;
} settings_t;

Expand Down
10 changes: 9 additions & 1 deletion patches/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ endif
# options for code generation
#---------------------------------------------------------------------------------

CFLAGS = -O2 -Wall -Wno-main -ffixed-r12 -ffixed-r13 -ffunction-sections -fdata-sections -Wno-unused-function -Werror-implicit-function-declaration $(MACHDEP) $(INCLUDE)
CFLAGS = -O2 -std=gnu23 -Wall -Wno-main -ffixed-r12 -ffixed-r13 -ffunction-sections -fdata-sections -Wno-unused-function -Werror-implicit-function-declaration $(MACHDEP) $(INCLUDE)
CXXFLAGS = $(CFLAGS)

LINKER_SCRIPTS :=
Expand Down Expand Up @@ -151,6 +151,14 @@ fake.o: patch.o
@echo $(notdir $<)
$(bin2o)

#---------------------------------------------------------------------------------
# This rule links in binary texture data with the .bti extension
#---------------------------------------------------------------------------------
%.bti.o %_bti.h: %.bti
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)

-include $(DEPENDS)

#---------------------------------------------------------------------------------
Expand Down
Binary file added patches/data/disc.bti

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all custom formats should also be stored in the original folder as PNG and include a convert script

Binary file not shown.
Binary file added patches/data/flippydrive.bti
Binary file not shown.
Binary file added patches/data/l_button.bti
Binary file not shown.
Binary file added patches/data/original_png/default_opening.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added patches/data/original_png/dir_tex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added patches/data/original_png/disc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added patches/data/original_png/dol_tex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added patches/data/original_png/flippydrive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added patches/data/original_png/l_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added patches/data/original_png/r_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions patches/data/original_svg/default_opening.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions patches/data/original_svg/disc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions patches/data/original_svg/flippydrive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions patches/data/original_svg/l_button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions patches/data/original_svg/r_button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added patches/data/r_button.bti
Binary file not shown.
1 change: 1 addition & 0 deletions patches/include/device.h
20 changes: 19 additions & 1 deletion patches/linker/link_ntsc10.ld
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ntsc10_Jac_PlaySe = 0x813594e0;
ntsc10_Jac_StopSoundAll = 0x81359640;
ntsc10_Jac_PlayBgm = 0x81359680;
ntsc10_PADSync = 0x81341074;
ntsc10_OSDisableInterrupts = 0x813361b0;
ntsc10___OSStopAudioSystem = 0x81333b88;
Expand Down Expand Up @@ -65,8 +66,11 @@ ntsc10_ptr_menu_blob = 0x8145d79c;
ntsc10_ptr_game_blob_a = 0x8145d88c;
ntsc10_ptr_game_blob_b = 0x8145d888;
ntsc10_game_blob_text = 0x8148dd98;
ntsc10_game_blob_insert_disc = 0x8148dda8;
ntsc10_game_blob_reading_disc = 0x8148ddc8;
ntsc10_game_blob_could_not_read_disc = 0x8148ddd8;

ntsc10_prev_menu_id = 0x8145d710;
ntsc10_next_menu_id = 0x8145d710;
ntsc10_cur_menu_id = 0x8145d70c;
ntsc10_uart_init = 0x8145dca8;

Expand Down Expand Up @@ -107,3 +111,17 @@ ntsc10_EXIImm = 0x81334d4c;
ntsc10_EXIImmEx = 0x81334fa8;

ntsc10_is_key_repeat = 0x81302ef8;

ntsc10_stock_banner_ptr = 0x80af8440;

ntsc10_get_element_alpha = 0x8130ab40;
ntsc10_update_element_alpha = 0x8130aa58;
ntsc10_banner_element_alpha = 0x8148dd88;
ntsc10_top_level_banner_element_alpha = 0x81465c3c;

ntsc10_cube_menu_rotation_vertical = 0x81465882;
ntsc10_cube_menu_alpha = 0x81465888;

ntsc10_draw_buttons = 0x813142ec;
ntsc10_setup_buttons_matrix = 0x813031c8;
ntsc10_update_button_alphas = 0x81311a98;
Loading