Browse Source

Merge branch 'FunKey' of fk:FunKey-Project/picodrive-irixxxx into FunKey

Michel-FK 3 years ago
parent
commit
98134ed598
3 changed files with 53 additions and 10 deletions
  1. 36 7
      platform/common/emu.c
  2. 9 3
      platform/common/plat_sdl.c
  3. 8 0
      platform/linux/emu.c

+ 36 - 7
platform/common/emu.c

@@ -221,8 +221,25 @@ static const char *find_bios(int *region, const char *cd_fname)
 		if (f) break;
 	}
 
+	/** Check Bios files in <rom path>/bios */
+	if(!f){
+		for (i = 0; i < count; i++)
+		{
+			sprintf(static_buff, "%s/bios/%s", mRomPath, files[i]);
+			printf("static_buff: %s\n", static_buff);
+			strcat(static_buff, ".bin");
+			f = fopen(static_buff, "rb");
+			if (f) break;
+
+			static_buff[strlen(static_buff) - 4] = 0;
+			strcat(static_buff, ".zip");
+			f = fopen(static_buff, "rb");
+			if (f) break;
+		}
+	}
+
+	/** Check Bios files in rom path */
 	if(!f){
-		/** Check Bios files in rom path */
 		for (i = 0; i < count; i++)
 		{
 			sprintf(static_buff, "%s/%s", mRomPath, files[i]);
@@ -263,7 +280,7 @@ static const char *find_bios(int *region, const char *cd_fname)
 
 		/** Set notif for BIOS */
 	    char shell_cmd[400];
-	    sprintf(shell_cmd, "%s 0 \"    %s BIOS FILE MISSING^^Connect your FunKey S to ^your computer and copy the^BIOS file to the game folder^^The file can be called:^ - %s.bin^ - %s.bin^ - %s.bin^ - %s.bin^^For more instructions:^www.funkey-project.com^^Press any button to exit...\"",
+	    sprintf(shell_cmd, "%s 0 \"    %s BIOS FILE MISSING^^Connect your FunKey S to ^your computer and copy the^BIOS file in the folder:^    Sega Genesis/bios/^^The file can be called:^ - %s.bin^ - %s.bin^ - %s.bin^ - %s.bin^^For more instructions:^www.funkey-project.com^^Press any button to exit...\"",
 	            SHELL_CMD_NOTIF, country, bios_names[0], bios_names[1], bios_names[2], bios_names[3]);
 	    FILE *fp = popen(shell_cmd, "r");
 	    if (fp == NULL) {
@@ -685,7 +702,8 @@ void emu_prep_defconfig(void)
 	defaultConfig.Frameskip = -1; // auto
 	defaultConfig.input_dev0 = PICO_INPUT_PAD_3BTN;
 	defaultConfig.input_dev1 = PICO_INPUT_PAD_3BTN;
-	defaultConfig.volume = 99;
+	defaultConfig.volume = 50;
+	//defaultConfig.volume = 99;
 	defaultConfig.gamma = 100;
 	defaultConfig.scaling = 0;
 	defaultConfig.turbo_rate = 15;
@@ -754,7 +772,7 @@ int emu_read_config(const char *rom_fname, int no_defaults)
 
 	// some sanity checks
 	if (currentConfig.volume < 0 || currentConfig.volume > 99)
-		currentConfig.volume = 99;
+		currentConfig.volume = 50;
 
 	if (ret == 0)
 		config_slot_current = config_slot;
@@ -1681,8 +1699,6 @@ void emu_loop(void)
 
 	fpsbuff[0] = 0;
 
-	printf("%s ------------------ \n", __func__);
-
 	PicoLoopPrepare();
 
 	plat_video_loop_prepare();
@@ -1743,6 +1759,19 @@ void emu_loop(void)
 		// second changed?
 		if (timestamp_x3 - timestamp_fps_x3 >= ms_to_ticks(1000) * 3)
 		{
+#define FUNKEY_RESYNCHRONIZE_AUDIO_SECS	(5*60)
+#ifdef FUNKEY_RESYNCHRONIZE_AUDIO_SECS
+			static unsigned int last_resync = 0, cur_sec=0;
+			if(cur_sec++ - last_resync >= FUNKEY_RESYNCHRONIZE_AUDIO_SECS){
+				last_resync = cur_sec;
+
+				/** Resync here (same as quitting ans relaunching loop for now) */
+				printf("Resync sound now\n");
+				emu_sound_stop();
+				pemu_sound_start();
+			}
+#endif //FUNKEY_RESYNCHRONIZE_AUDIO_SECS
+
 #ifdef BENCHMARK
 			static int bench = 0, bench_fps = 0, bench_fps_s = 0, bfp = 0, bf[4];
 			if (++bench == 10) {
@@ -1851,7 +1880,7 @@ void emu_loop(void)
 		/* Leave some time for the bios to load before starting a quick load at boot */
 		/* (Sega CD doesn't quick load at boot otherwise) */
 		/* Should have a much cleaner implementation thant this fix */
-		if((PicoIn.AHW & PAHW_MCD) && frame_nb >= 100){
+		if((PicoIn.AHW & PAHW_MCD) && frame_nb >= 120){
 
 			/* Load slot */
 			if(load_state_slot != -1){

+ 9 - 3
platform/common/plat_sdl.c

@@ -1576,6 +1576,7 @@ void plat_video_flip(void)
 		  prev_aspect_ratio = aspect_ratio;
 		  need_screen_cleared = 0;
 		}
+    uint16_t hres_max;
 
 		switch(aspect_ratio){
 		case ASPECT_RATIOS_TYPE_STRETCHED:
@@ -1595,18 +1596,23 @@ void plat_video_flip(void)
 			}
 			break;
 		case ASPECT_RATIOS_TYPE_MANUAL:
+      hres_max= MIN(RES_HW_SCREEN_VERTICAL, game_surface->h);
 			;uint32_t h_scaled = MIN(game_surface->h*RES_HW_SCREEN_HORIZONTAL/game_surface->w,
 						 RES_HW_SCREEN_VERTICAL);
-			uint32_t h_zoomed = MIN(h_scaled + aspect_ratio_factor_percent*(RES_HW_SCREEN_VERTICAL - h_scaled)/100,
+			uint32_t h_zoomed = MIN(h_scaled + aspect_ratio_factor_percent*(hres_max - h_scaled)/100,
 						RES_HW_SCREEN_VERTICAL);
 			flip_NNOptimized_LeftRightUpDownBilinear_Optimized8(game_surface, virtual_hw_screen,
 									    MAX(game_surface->w*h_zoomed/game_surface->h, RES_HW_SCREEN_HORIZONTAL),
 									    MIN(h_zoomed, RES_HW_SCREEN_VERTICAL));
 			break;
 		case ASPECT_RATIOS_TYPE_CROPPED:
-			flip_NNOptimized_AllowOutOfScreen(game_surface, virtual_hw_screen,
+			/*flip_NNOptimized_AllowOutOfScreen(game_surface, virtual_hw_screen,
 							  MAX(game_surface->w*RES_HW_SCREEN_VERTICAL/game_surface->h, RES_HW_SCREEN_HORIZONTAL),
-							  RES_HW_SCREEN_VERTICAL);
+							  RES_HW_SCREEN_VERTICAL);*/
+        hres_max= MIN(RES_HW_SCREEN_VERTICAL, game_surface->h);
+        flip_NNOptimized_AllowOutOfScreen(game_surface, virtual_hw_screen,
+                MAX(game_surface->w*hres_max/game_surface->h, RES_HW_SCREEN_HORIZONTAL),
+                hres_max);
 			break;
 		case ASPECT_RATIOS_TYPE_SCALED:
 			flip_NNOptimized_LeftRightUpDownBilinear_Optimized8(game_surface, virtual_hw_screen,

+ 8 - 0
platform/linux/emu.c

@@ -91,6 +91,8 @@ static unsigned short *get_16bit_start(unsigned short *buf)
 
 void pemu_finalize_frame(const char *fps, const char *notice)
 {
+
+
 	if (!is_16bit_mode()) {
 		// convert the 8 bit CLUT output to 16 bit RGB
 		unsigned short *pd = (unsigned short *)g_screen_ptr +
@@ -109,6 +111,11 @@ void pemu_finalize_frame(const char *fps, const char *notice)
 		}
 	}
 
+//#define FUNKEY_AUTHORIZE_TEXT_OVERLAY
+#ifndef FUNKEY_AUTHORIZE_TEXT_OVERLAY
+	return;
+#endif //FUNKEY_AUTHORIZE_TEXT_OVERLAY
+
 	if (notice)
 		emu_osd_text16(4, g_screen_height - 8, notice);
 	if (currentConfig.EmuOpt & EOPT_SHOW_FPS)
@@ -172,6 +179,7 @@ void plat_status_msg_clear(void)
 
 void plat_status_msg_busy_next(const char *msg)
 {
+	printf("****** %s: %s\n", __func__, msg);
 	plat_status_msg_clear();
 	pemu_finalize_frame("", msg);
 	plat_video_flip();