mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-12-26 02:01:50 +01:00
libdragon update + reorganized menu init + bug fixes
This commit is contained in:
parent
2116f6e26b
commit
10a8fcab9e
1
Makefile
1
Makefile
@ -98,7 +98,6 @@ $(SPNG_OBJS): N64_CFLAGS+=-isystem $(SOURCE_DIR)/libs/miniz -DSPNG_USE_MINIZ -fc
|
||||
$(FILESYSTEM_DIR)/FiraMonoBold.font64: MKFONT_FLAGS+=-c 1 --size 16 -r 20-7F -r 80-1FF -r 2026-2026 --ellipsis 2026,1
|
||||
$(FILESYSTEM_DIR)/%.wav64: AUDIOCONV_FLAGS=--wav-compress 1
|
||||
|
||||
|
||||
$(@info $(shell mkdir -p ./$(FILESYSTEM_DIR) &> /dev/null))
|
||||
|
||||
$(FILESYSTEM_DIR)/%.font64: $(ASSETS_DIR)/%.ttf
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit e1eb9283e6feeb37a66797fa538ae7883d73227c
|
||||
Subproject commit 9dd994151ae3f3709f1f80224e6b654aac8be6b4
|
@ -36,7 +36,6 @@ static void actions_update_direction (menu_t *menu) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (fast_dir != JOYPAD_8WAY_NONE) {
|
||||
held_dir = fast_dir;
|
||||
menu->actions.go_fast = true;
|
||||
@ -114,6 +113,12 @@ static void actions_update_buttons (menu_t *menu) {
|
||||
}
|
||||
|
||||
|
||||
void actions_init (void) {
|
||||
JOYPAD_PORT_FOREACH (port) {
|
||||
joypad_set_rumble_active(port, false);
|
||||
}
|
||||
}
|
||||
|
||||
void actions_update (menu_t *menu) {
|
||||
joypad_poll();
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "menu_state.h"
|
||||
|
||||
|
||||
void actions_init (void);
|
||||
void actions_update (menu_t *menu);
|
||||
|
||||
|
||||
|
@ -98,9 +98,6 @@ static void prepare_background (component_background_t *c) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t image_center_x = (c->image->width / 2);
|
||||
uint16_t image_center_y = (c->image->height / 2);
|
||||
|
||||
// Darken the image
|
||||
rdpq_attach(c->image, NULL);
|
||||
rdpq_mode_push();
|
||||
@ -108,15 +105,13 @@ static void prepare_background (component_background_t *c) {
|
||||
rdpq_set_prim_color(BACKGROUND_OVERLAY_COLOR);
|
||||
rdpq_mode_combiner(RDPQ_COMBINER_FLAT);
|
||||
rdpq_mode_blender(RDPQ_BLENDER_MULTIPLY);
|
||||
rdpq_fill_rectangle(
|
||||
0 - (DISPLAY_CENTER_X - image_center_x),
|
||||
0 - (DISPLAY_CENTER_Y - image_center_y),
|
||||
DISPLAY_WIDTH - (DISPLAY_CENTER_X - image_center_x),
|
||||
DISPLAY_HEIGHT - (DISPLAY_CENTER_Y - image_center_y)
|
||||
);
|
||||
rdpq_fill_rectangle(0, 0, c->image->width, c->image->height);
|
||||
rdpq_mode_pop();
|
||||
rdpq_detach();
|
||||
|
||||
uint16_t image_center_x = (c->image->width / 2);
|
||||
uint16_t image_center_y = (c->image->height / 2);
|
||||
|
||||
// Prepare display list
|
||||
rspq_block_begin();
|
||||
rdpq_mode_push();
|
||||
|
102
src/menu/menu.c
102
src/menu/menu.c
@ -27,53 +27,19 @@
|
||||
#define MENU_CACHE_DIRECTORY "cache"
|
||||
#define BACKGROUND_CACHE_FILE "background.data"
|
||||
|
||||
#define FRAMERATE_DIVIDER (2)
|
||||
#define LAG_REPORT (false)
|
||||
#define INTERLACED (true)
|
||||
#define FPS_LIMIT (30.0f)
|
||||
|
||||
|
||||
static menu_t *menu;
|
||||
static tv_type_t tv_type;
|
||||
static volatile int frame_counter = 0;
|
||||
|
||||
extern tv_type_t __boot_tvtype;
|
||||
|
||||
|
||||
static void frame_counter_handler (void) {
|
||||
frame_counter += 1;
|
||||
}
|
||||
|
||||
static void frame_counter_reset (void) {
|
||||
#if LAG_REPORT
|
||||
static int accumulated = 0;
|
||||
if (frame_counter > FRAMERATE_DIVIDER) {
|
||||
accumulated += frame_counter - FRAMERATE_DIVIDER;
|
||||
debugf(
|
||||
"LAG: %d additional frame(s) displayed since last draw (accumulated: %d)\n",
|
||||
frame_counter - FRAMERATE_DIVIDER,
|
||||
accumulated
|
||||
);
|
||||
}
|
||||
#endif
|
||||
frame_counter = 0;
|
||||
}
|
||||
|
||||
static void menu_init (boot_params_t *boot_params) {
|
||||
joypad_init();
|
||||
timer_init();
|
||||
rtc_init();
|
||||
rspq_init();
|
||||
rdpq_init();
|
||||
dfs_init(DFS_DEFAULT_LOCATION);
|
||||
|
||||
sound_init_default();
|
||||
|
||||
JOYPAD_PORT_FOREACH (port) {
|
||||
joypad_set_rumble_active(port, false);
|
||||
}
|
||||
|
||||
static void menu_init (boot_params_t *boot_params) {
|
||||
menu = calloc(1, sizeof(menu_t));
|
||||
assert(menu != NULL);
|
||||
|
||||
menu->boot_params = boot_params;
|
||||
|
||||
menu->mode = MENU_MODE_NONE;
|
||||
menu->next_mode = MENU_MODE_STARTUP;
|
||||
|
||||
@ -82,6 +48,19 @@ static void menu_init (boot_params_t *boot_params) {
|
||||
menu->next_mode = MENU_MODE_FAULT;
|
||||
}
|
||||
|
||||
joypad_init();
|
||||
timer_init();
|
||||
rtc_init();
|
||||
rspq_init();
|
||||
rdpq_init();
|
||||
dfs_init(DFS_DEFAULT_LOCATION);
|
||||
|
||||
actions_init();
|
||||
sound_init_default();
|
||||
sound_init_sfx();
|
||||
|
||||
hdmi_clear_game_id();
|
||||
|
||||
path_t *path = path_init(menu->storage_prefix, MENU_DIRECTORY);
|
||||
|
||||
directory_create(path_get(path));
|
||||
@ -91,6 +70,15 @@ static void menu_init (boot_params_t *boot_params) {
|
||||
settings_load(&menu->settings);
|
||||
path_pop(path);
|
||||
|
||||
resolution_t resolution = {
|
||||
.width = 640,
|
||||
.height = 480,
|
||||
.interlaced = INTERLACED ? INTERLACE_HALF : INTERLACE_OFF,
|
||||
.pal60 = menu->settings.pal60_enabled,
|
||||
};
|
||||
display_init(resolution, DEPTH_16_BPP, 2, GAMMA_NONE, INTERLACED ? FILTERS_DISABLED : FILTERS_RESAMPLE);
|
||||
display_set_fps_limit(FPS_LIMIT);
|
||||
|
||||
path_push(path, MENU_CUSTOM_FONT_FILE);
|
||||
fonts_init(path_get(path));
|
||||
path_pop(path);
|
||||
@ -103,40 +91,20 @@ static void menu_init (boot_params_t *boot_params) {
|
||||
|
||||
path_free(path);
|
||||
|
||||
menu->boot_params = boot_params;
|
||||
sound_use_sfx(menu->settings.sound_enabled);
|
||||
|
||||
menu->browser.directory = path_init(menu->storage_prefix, menu->settings.default_directory);
|
||||
if (!directory_exists(path_get(menu->browser.directory))) {
|
||||
path_free(menu->browser.directory);
|
||||
menu->browser.directory = path_init(menu->storage_prefix, "/");
|
||||
}
|
||||
|
||||
hdmi_clear_game_id();
|
||||
|
||||
tv_type = get_tv_type();
|
||||
if ((tv_type == TV_PAL) && menu->settings.pal60_enabled) {
|
||||
// HACK: Set TV type to NTSC, so PAL console would output 60 Hz signal instead.
|
||||
__boot_tvtype = TV_NTSC;
|
||||
}
|
||||
|
||||
sound_init_sfx();
|
||||
if (menu->settings.sound_enabled) {
|
||||
sound_use_sfx(true);
|
||||
}
|
||||
|
||||
display_init(RESOLUTION_640x480, DEPTH_16_BPP, 2, GAMMA_NONE, FILTERS_DISABLED);
|
||||
|
||||
register_VI_handler(frame_counter_handler);
|
||||
}
|
||||
|
||||
static void menu_deinit (menu_t *menu) {
|
||||
unregister_VI_handler(frame_counter_handler);
|
||||
|
||||
// NOTE: Restore previous TV type so boot procedure wouldn't passthrough wrong value.
|
||||
__boot_tvtype = tv_type;
|
||||
|
||||
hdmi_send_game_id(menu->boot_params);
|
||||
|
||||
component_background_free();
|
||||
|
||||
path_free(menu->load.disk_path);
|
||||
path_free(menu->load.rom_path);
|
||||
for (int i = 0; i < menu->browser.entries; i++) {
|
||||
@ -146,9 +114,7 @@ static void menu_deinit (menu_t *menu) {
|
||||
path_free(menu->browser.directory);
|
||||
free(menu);
|
||||
|
||||
component_background_free();
|
||||
|
||||
flashcart_deinit();
|
||||
display_close();
|
||||
|
||||
sound_deinit();
|
||||
|
||||
@ -158,7 +124,7 @@ static void menu_deinit (menu_t *menu) {
|
||||
timer_close();
|
||||
joypad_close();
|
||||
|
||||
display_close();
|
||||
flashcart_deinit();
|
||||
}
|
||||
|
||||
typedef const struct {
|
||||
@ -200,11 +166,9 @@ void menu_run (boot_params_t *boot_params) {
|
||||
menu_init(boot_params);
|
||||
|
||||
while (true) {
|
||||
surface_t *display = (frame_counter >= FRAMERATE_DIVIDER) ? display_try_get() : NULL;
|
||||
surface_t *display = display_try_get();
|
||||
|
||||
if (display != NULL) {
|
||||
frame_counter_reset();
|
||||
|
||||
actions_update(menu);
|
||||
|
||||
view_t *view = menu_get_view(menu->mode);
|
||||
|
Loading…
Reference in New Issue
Block a user