X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=platform%2Fcommon%2Femu.c;h=a417926dcbc3759d29b86f77ff6e9eb522554903;hb=e743be2070a13d14cae39a55b815b62b0edb6776;hp=a075abdf01620dedc36a65ce7f42c0642f77ddaf;hpb=fcdefcf62cb71969b456a6f27688adbeb5890bb9;p=picodrive.git diff --git a/platform/common/emu.c b/platform/common/emu.c index a075abd..a417926 100644 --- a/platform/common/emu.c +++ b/platform/common/emu.c @@ -10,14 +10,15 @@ #include #endif +#include "../libpicofe/posix.h" +#include "../libpicofe/input.h" +#include "../libpicofe/fonts.h" +#include "../libpicofe/lprintf.h" +#include "../libpicofe/plat.h" #include "emu.h" -#include "menu.h" -#include "fonts.h" -#include "lprintf.h" +#include "input_pico.h" +#include "menu_pico.h" #include "config.h" -#include "plat.h" -#include "input.h" -#include "posix.h" #include #include @@ -184,7 +185,7 @@ static int find_bios(int region, char **bios_file) } else { sprintf(static_buff, "no %s BIOS files found, read docs", region != 4 ? (region == 8 ? "EU" : "JAP") : "USA"); - me_update_msg(static_buff); + menu_update_msg(static_buff); return 0; } } @@ -453,11 +454,14 @@ static void shutdown_MCD(void) static void system_announce(void) { - const char *sys_name, *tv_standard; + const char *sys_name, *tv_standard, *extra = ""; int fps; if (PicoAHW & PAHW_SMS) { sys_name = "Master System"; +#ifdef NO_SMS + extra = " [no support]"; +#endif } else if (PicoAHW & PAHW_PICO) { sys_name = "Pico"; } else if (PicoAHW & PAHW_MCD) { @@ -474,7 +478,7 @@ static void system_announce(void) tv_standard = Pico.m.pal ? "PAL" : "NTSC"; fps = Pico.m.pal ? 50 : 60; - emu_status_msg("%s %s / %dFPS", tv_standard, sys_name, fps); + emu_status_msg("%s %s / %dFPS%s", tv_standard, sys_name, fps, extra); } // note: this function might mangle rom_fname @@ -494,43 +498,45 @@ int emu_reload_rom(char *rom_fname) get_ext(rom_fname, ext); - // check for movie file + // early cleanup + PicoPatchUnload(); if (movie_data) { free(movie_data); movie_data = 0; } + if (!strcmp(ext, ".gmv")) { // check for both gmv and rom int dummy; FILE *movie_file = fopen(rom_fname, "rb"); if (!movie_file) { - me_update_msg("Failed to open movie."); + menu_update_msg("Failed to open movie."); return 0; } fseek(movie_file, 0, SEEK_END); movie_size = ftell(movie_file); fseek(movie_file, 0, SEEK_SET); if (movie_size < 64+3) { - me_update_msg("Invalid GMV file."); + menu_update_msg("Invalid GMV file."); fclose(movie_file); return 0; } movie_data = malloc(movie_size); if (movie_data == NULL) { - me_update_msg("low memory."); + menu_update_msg("low memory."); fclose(movie_file); return 0; } dummy = fread(movie_data, 1, movie_size, movie_file); fclose(movie_file); if (strncmp((char *)movie_data, "Gens Movie TEST", 15) != 0) { - me_update_msg("Invalid GMV file."); + menu_update_msg("Invalid GMV file."); return 0; } dummy = try_rfn_cut(rom_fname) || try_rfn_cut(rom_fname); if (!dummy) { - me_update_msg("Could't find a ROM for movie."); + menu_update_msg("Could't find a ROM for movie."); return 0; } get_ext(rom_fname, ext); @@ -542,7 +548,7 @@ int emu_reload_rom(char *rom_fname) PicoPatchLoad(rom_fname); dummy = try_rfn_cut(rom_fname) || try_rfn_cut(rom_fname); if (!dummy) { - me_update_msg("Could't find a ROM to patch."); + menu_update_msg("Could't find a ROM to patch."); return 0; } get_ext(rom_fname, ext); @@ -550,12 +556,11 @@ int emu_reload_rom(char *rom_fname) media_type = detect_media(rom_fname); if (media_type == PM_BAD) { - me_update_msg("Not a ROM/CD img selected."); + menu_update_msg("Not a ROM/CD img selected."); return 0; } shutdown_MCD(); - PicoPatchUnload(); PicoCartUnload(); rom_loaded = 0; @@ -586,7 +591,7 @@ int emu_reload_rom(char *rom_fname) PicoAHW |= PAHW_MCD; } else { - me_update_msg("Invalid CD image"); + menu_update_msg("Invalid CD image"); return 0; } } @@ -597,7 +602,7 @@ int emu_reload_rom(char *rom_fname) rom = pm_open(used_rom_name); if (rom == NULL) { - me_update_msg("Failed to open ROM"); + menu_update_msg("Failed to open ROM"); return 0; } @@ -607,9 +612,9 @@ int emu_reload_rom(char *rom_fname) ret = PicoCartLoad(rom, &rom_data, &rom_size, (PicoAHW & PAHW_SMS) ? 1 : 0); pm_close(rom); if (ret != 0) { - if (ret == 2) me_update_msg("Out of memory"); - else if (ret == 3) me_update_msg("Read failed"); - else me_update_msg("PicoCartLoad() failed."); + if (ret == 2) menu_update_msg("Out of memory"); + else if (ret == 3) menu_update_msg("Read failed"); + else menu_update_msg("PicoCartLoad() failed."); goto fail; } @@ -625,7 +630,7 @@ int emu_reload_rom(char *rom_fname) } if (bad_rom) { - me_update_msg("Bad ROM detected."); + menu_update_msg("Bad ROM detected."); goto fail; } @@ -639,7 +644,7 @@ int emu_reload_rom(char *rom_fname) emu_make_path(static_buff, "carthw.cfg", sizeof(static_buff)); if (PicoCartInsert(rom_data, rom_size, static_buff)) { - me_update_msg("Failed to load ROM."); + menu_update_msg("Failed to load ROM."); goto fail; } @@ -649,7 +654,7 @@ int emu_reload_rom(char *rom_fname) if (ret != 0) { PicoCartUnload(); rom_data = NULL; // freed by unload - me_update_msg("Insert_CD() failed, invalid CD image?"); + menu_update_msg("Insert_CD() failed, invalid CD image?"); goto fail; } } @@ -712,7 +717,7 @@ int emu_swap_cd(const char *fname) if (cd_type != CIT_NOT_CD) ret = Insert_CD(fname, cd_type); if (ret != 0) { - me_update_msg("Load failed, invalid CD image?"); + menu_update_msg("Load failed, invalid CD image?"); return 0; } @@ -1008,7 +1013,7 @@ char *emu_get_save_fname(int load, int is_sram, int slot) return NULL; } -int emu_check_save_file(int slot) +int emu_check_save_file(int slot, int *time) { return emu_get_save_fname(1, 0, slot) ? 1 : 0; } @@ -1137,8 +1142,11 @@ static void emu_tray_close(void) void emu_32x_startup(void) { - plat_video_toggle_renderer(0, 0); + plat_video_toggle_renderer(0, 0); // HACK system_announce(); + + // force mode change event + rendstatus_old = -1; } void emu_reset_game(void) @@ -1232,7 +1240,7 @@ static void run_events_ui(unsigned int which) if (which & (PEV_STATE_LOAD|PEV_STATE_SAVE)) { int do_it = 1; - if ( emu_check_save_file(state_slot) && + if ( emu_check_save_file(state_slot, NULL) && (((which & PEV_STATE_LOAD) && (currentConfig.confirm_save & EOPT_CONFIRM_LOAD)) || ((which & PEV_STATE_SAVE) && (currentConfig.confirm_save & EOPT_CONFIRM_SAVE))) ) { @@ -1250,16 +1258,16 @@ static void run_events_ui(unsigned int which) plat_status_msg_busy_first(tmp); - in_set_blocking(1); - while (in_menu_wait_any(50) & (PBTN_MA3|PBTN_MBACK)) + in_set_config_int(0, IN_CFG_BLOCKING, 1); + while (in_menu_wait_any(NULL, 50) & (PBTN_MA3|PBTN_MBACK)) ; - while ( !((keys = in_menu_wait_any(50)) & (PBTN_MA3|PBTN_MBACK)) ) + while ( !((keys = in_menu_wait_any(NULL, 50)) & (PBTN_MA3|PBTN_MBACK)) ) ; if (keys & PBTN_MBACK) do_it = 0; - while (in_menu_wait_any(50) & (PBTN_MA3|PBTN_MBACK)) + while (in_menu_wait_any(NULL, 50) & (PBTN_MA3|PBTN_MBACK)) ; - in_set_blocking(0); + in_set_config_int(0, IN_CFG_BLOCKING, 0); } if (do_it) { plat_status_msg_busy_first((which & PEV_STATE_LOAD) ? "LOADING STATE" : "SAVING STATE"); @@ -1285,7 +1293,7 @@ static void run_events_ui(unsigned int which) } emu_status_msg("SAVE SLOT %i [%s]", state_slot, - emu_check_save_file(state_slot) ? "USED" : "FREE"); + emu_check_save_file(state_slot, NULL) ? "USED" : "FREE"); } if (which & PEV_MENU) engineState = PGS_Menu; @@ -1344,6 +1352,27 @@ static void mkdir_path(char *path_with_reserve, int pos, const char *name) lprintf("failed to create: %s\n", path_with_reserve); } +void emu_cmn_forced_frame(int no_scale, int do_emu) +{ + int po_old = PicoOpt; + + memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4); + + PicoOpt &= ~POPT_ALT_RENDERER; + PicoOpt |= POPT_ACC_SPRITES; + if (!no_scale) + PicoOpt |= POPT_EN_SOFTSCALE; + + PicoDrawSetOutFormat(PDF_RGB555, 1); + Pico.m.dirtyPal = 1; + if (do_emu) + PicoFrame(); + else + PicoFrameDrawOnly(); + + PicoOpt = po_old; +} + void emu_init(void) { char path[512]; @@ -1428,6 +1457,14 @@ void emu_loop(void) Pico.m.dirtyPal = 1; rendstatus_old = -1; + PicoLoopPrepare(); + + // prepare CD buffer + if (PicoAHW & PAHW_MCD) + PicoCDBufferInit(); + + pemu_loop_prep(); + /* number of ticks per frame */ if (Pico.m.pal) { target_fps = 50; @@ -1437,13 +1474,6 @@ void emu_loop(void) target_frametime = ms_to_ticks(1000) / 60 + 1; } - // prepare CD buffer - if (PicoAHW & PAHW_MCD) - PicoCDBufferInit(); - PicoLoopPrepare(); - - pemu_loop_prep(); - timestamp_fps = get_ticks(); reset_timing = 1;