From 501aa77d14cfbf8bbb2659165986801c59b0c196 Mon Sep 17 00:00:00 2001 From: Shaun Inman Date: Thu, 26 Jan 2023 20:39:22 -0500 Subject: [PATCH] tidy --- .../.system/rg35xx/paks/MinUI.pak/launch.sh | 1 - src/clock/main.c | 4 +- src/common/api.c | 13 +++-- src/common/defines.h | 3 +- src/minarch/main.c | 54 +++++++------------ src/minui/main.c | 4 +- 6 files changed, 33 insertions(+), 46 deletions(-) diff --git a/skeleton/.system/rg35xx/paks/MinUI.pak/launch.sh b/skeleton/.system/rg35xx/paks/MinUI.pak/launch.sh index f2734f3..6490e5a 100755 --- a/skeleton/.system/rg35xx/paks/MinUI.pak/launch.sh +++ b/skeleton/.system/rg35xx/paks/MinUI.pak/launch.sh @@ -25,7 +25,6 @@ keymon.elf & # &> /mnt/sdcard/keymon.txt & export EXEC_PATH=/tmp/minui_exec touch "$EXEC_PATH" && sync -echo ondemand > "$CPU_PATH" while [ -f "$EXEC_PATH" ]; do echo ondemand > "$CPU_PATH" diff --git a/src/clock/main.c b/src/clock/main.c index 5fe97a3..10d63cf 100644 --- a/src/clock/main.c +++ b/src/clock/main.c @@ -300,9 +300,11 @@ int main(int argc , char* argv[]) { } SDL_FreeSurface(digits); - + + QuitSettings(); GFX_quit(); + // TODO: if (seconds_selected==tm.tm_sec) refresh tm and update seconds_selected if (save_changes) { diff --git a/src/common/api.c b/src/common/api.c index f95469e..901097c 100644 --- a/src/common/api.c +++ b/src/common/api.c @@ -6,7 +6,6 @@ #include #include -#include #include #include @@ -248,9 +247,12 @@ void GFX_quit(void) { } void GFX_clear(SDL_Surface* screen) { - memset(screen->pixels, 0, gfx.buffer_size); + memset(screen->pixels, 0, gfx.buffer_size); // this buffer is offscreen when cleared } void GFX_clearAll(void) { + // TODO: one of the buffers is onscreen when cleared producing tearing + // so clear our working buffer immediately (screen->pixels) + // then set a flag and clear the other two after vsync? memset(gfx.map, 0, gfx.map_size); } @@ -442,9 +444,7 @@ void GFX_blitButton(char* hint, char*button, SDL_Surface* dst, SDL_Rect* dst_rec SDL_FreeSurface(text); } void GFX_blitMessage(char* msg, SDL_Surface* dst, SDL_Rect* dst_rect) { - if (dst_rect==NULL) { - dst_rect = &(SDL_Rect){0,0,SCREEN_WIDTH,SCREEN_HEIGHT}; - } + if (dst_rect==NULL) dst_rect = &(SDL_Rect){0,0,SCREEN_WIDTH,SCREEN_HEIGHT}; SDL_Surface* text; #define TEXT_BOX_MAX_ROWS 16 @@ -951,6 +951,7 @@ static char governor[128]; static void POW_enterSleep(void) { SetRawVolume(0); putInt(BACKLIGHT_PATH, FB_BLANK_POWERDOWN); + // save current governor (either ondemand or performance) getFile(GOVERNOR_PATH, governor, 128); trimTrailingNewlines(governor); @@ -961,8 +962,10 @@ static void POW_enterSleep(void) { static void POW_exitSleep(void) { putInt(BACKLIGHT_PATH, FB_BLANK_UNBLANK); SetVolume(GetVolume()); + // restore previous governor putFile(GOVERNOR_PATH, governor); + sync(); } static void POW_waitForWake(void) { SDL_Event event; diff --git a/src/common/defines.h b/src/common/defines.h index 4502e33..96dfcd1 100644 --- a/src/common/defines.h +++ b/src/common/defines.h @@ -74,7 +74,8 @@ // all before scale #define PILL_SIZE 30 #define BUTTON_SIZE 20 -#define BUTTON_MARGIN ((PILL_SIZE - BUTTON_SIZE) / 2) +#define BUTTON_MARGIN 5 // ((PILL_SIZE - BUTTON_SIZE) / 2) +#define BUTTON_PADDING 12 #define SETTINGS_SIZE 4 #define SETTINGS_WIDTH 80 diff --git a/src/minarch/main.c b/src/minarch/main.c index 99f0522..9dc5bd9 100644 --- a/src/minarch/main.c +++ b/src/minarch/main.c @@ -551,16 +551,16 @@ static InputOverride input_overrides[] = { static const char* core_button_names[RETRO_BUTTON_COUNT]; // core-provided static const char* device_button_names[RETRO_BUTTON_COUNT] = { - [RETRO_DEVICE_ID_JOYPAD_B] = "B", - [RETRO_DEVICE_ID_JOYPAD_Y] = "Y", - [RETRO_DEVICE_ID_JOYPAD_SELECT] = "SELECT", - [RETRO_DEVICE_ID_JOYPAD_START] = "START", [RETRO_DEVICE_ID_JOYPAD_UP] = "UP", [RETRO_DEVICE_ID_JOYPAD_DOWN] = "DOWN", [RETRO_DEVICE_ID_JOYPAD_LEFT] = "LEFT", [RETRO_DEVICE_ID_JOYPAD_RIGHT] = "RIGHT", - [RETRO_DEVICE_ID_JOYPAD_A] = "A", + [RETRO_DEVICE_ID_JOYPAD_SELECT] = "SELECT", + [RETRO_DEVICE_ID_JOYPAD_START] = "START", + [RETRO_DEVICE_ID_JOYPAD_Y] = "Y", [RETRO_DEVICE_ID_JOYPAD_X] = "X", + [RETRO_DEVICE_ID_JOYPAD_B] = "B", + [RETRO_DEVICE_ID_JOYPAD_A] = "A", [RETRO_DEVICE_ID_JOYPAD_L] = "L1", [RETRO_DEVICE_ID_JOYPAD_R] = "R1", [RETRO_DEVICE_ID_JOYPAD_L2] = "L2", @@ -671,6 +671,10 @@ static bool environment_callback(unsigned cmd, void *data) { // copied from pico } case RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS: { /* 11 */ // puts("RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS"); + // TODO: this is useless + // (some? all?) cores don't sort these in any logical way + // which explains why picoarch didn't implement this... + // TODO: move all this to an Input_init()? @@ -1648,9 +1652,7 @@ void Core_getName(char* in_name, char* out_name) { tmp[0] = '\0'; } void Core_open(const char* core_path, const char* tag_name) { - LOG_info("inside Core_open\n"); core.handle = dlopen(core_path, RTLD_LAZY); - LOG_info("after dlopen\n"); if (!core.handle) LOG_error("%s\n", dlerror()); @@ -1692,6 +1694,8 @@ void Core_open(const char* core_path, const char* tag_name) { sprintf((char*)core.version, "%s (%s)", info.library_name, info.library_version); strcpy((char*)core.tag, tag_name); + LOG_info("% %s (%s)\n", core.name, core.version, core.tag); + sprintf((char*)core.config_dir, SDCARD_PATH "/.userdata/" PLATFORM "/%s-%s", core.tag, core.name); sprintf((char*)core.saves_dir, SDCARD_PATH "/Saves/%s", core.tag); sprintf((char*)core.bios_dir, SDCARD_PATH "/Bios/%s", core.tag); @@ -1711,30 +1715,18 @@ void Core_init(void) { core.initialized = 1; } void Core_load(void) { - // LOG_info("inside Core_load\n"); - struct retro_game_info game_info; game_info.path = game.path; game_info.data = game.data; game_info.size = game.size; core.load_game(&game_info); - // LOG_info("after core.load_game\n"); SRAM_read(); - // LOG_info("after SRAM_read\n"); // NOTE: must be called after core.load_game! struct retro_system_av_info av_info = {}; core.get_system_av_info(&av_info); - // LOG_info("after core.get_system_av_info\n"); - - // double a = av_info.geometry.aspect_ratio; - // int w = av_info.geometry.base_width; - // int h = av_info.geometry.base_height; - // char r[8]; - // getRatio(a, r); - // LOG_info("after getRatio\n"); core.fps = av_info.timing.fps; core.sample_rate = av_info.timing.sample_rate; @@ -1742,12 +1734,7 @@ void Core_load(void) { if (a<=0) a = (double)av_info.geometry.base_width / av_info.geometry.base_height; core.aspect_ratio = a; - printf("aspect_ratio: %f\n", a); - - // printf("%s\n%s\n", core.tag, core.version); - // printf("%dx%d (%s)\n", w,h,r); - // printf("%f\n%f\n", core.fps, core.sample_rate); - fflush(stdout); + LOG_info("aspect_ratio: %f\n", a); } void Core_reset(void) { core.reset(); @@ -2255,10 +2242,6 @@ int main(int argc , char* argv[]) { strcpy(rom_path, argv[2]); getEmuName(rom_path, tag_name); - // LOG_info("core_path: %s\n", core_path); - // LOG_info("rom_path: %s\n", rom_path); - // LOG_info("tag_name: %s\n", tag_name); - screen = GFX_init(MODE_MENU); // doesn't even help that much with Star Fox after overclocking @@ -2267,16 +2250,15 @@ int main(int argc , char* argv[]) { MSG_init(); InitSettings(); - Core_open(core_path, tag_name); // LOG_info("after Core_open\n"); - Core_init(); // LOG_info("after Core_init\n"); - Game_open(rom_path); // LOG_info("after Game_open\n"); - Core_load(); // LOG_info("after Core_load\n"); - SND_init(core.sample_rate, core.fps); // LOG_info("after SND_init\n"); + Core_open(core_path, tag_name); + Core_init(); + Game_open(rom_path); + Core_load(); + SND_init(core.sample_rate, core.fps); Menu_init(); State_resume(); - // State_read(); LOG_info("after State_read\n"); POW_disableAutosleep(); sec_start = SDL_GetTicks(); @@ -2315,7 +2297,7 @@ int main(int argc , char* argv[]) { Core_unload(); Core_quit(); - Core_close(); // LOG_info("after Core_close\n"); + Core_close(); SDL_FreeSurface(screen); MSG_quit(); diff --git a/src/minui/main.c b/src/minui/main.c index 68ea95f..462ba06 100644 --- a/src/minui/main.c +++ b/src/minui/main.c @@ -1399,10 +1399,10 @@ int main (int argc, char *argv[]) { SDL_BlitSurface(text, &(SDL_Rect){ 0, 0, - max_width-SCALE1(12*2), + max_width-SCALE1(BUTTON_PADDING*2), text->h }, screen, &(SDL_Rect){ - SCALE1(PADDING+12), + SCALE1(PADDING+BUTTON_PADDING), SCALE1(PADDING+(j*PILL_SIZE)+4) }); SDL_FreeSurface(text);