Re: [hatari-devel] WinUAE settings for different machine types

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On torstai 24 toukokuu 2012, Nicolas Pomarède wrote:
> Well my opinino on this is that any code or new behaviour that is
> enabled when ENABLE_WINUAE_CPU is OK with me.
> 
> But on the contrary, I think nothing should be changed in the code or in
> the cpu parameters when ENABLE_WINUAE_CPU is not defined.
> 
> STF/STE mode is considered rather stable for user ; Falcon is also
> getting more stability but it's also to be considered the "experimental"
> branch when it comes to cpu core. So, changing behaviour in that case is
> ok IMO.
> 
> Maybe hatari should have a bCompatibleCpu_winuae variable to separate
> both cpu core ?

Attached patch add bPrefetchCpu (as Laurent is already using PREFETCH
as name for it in SDL GUI).

It passed TOS booter testing with all the TOS versions.

(Some EmuTOS boots showed illegal instruction, but the boot and test
program succeeded nevertheless.)



On ST/STE mode, prefetch causes Hatari to assert on startup, and
cycle-exact causes Hatari to freeze with 100% CPU usage.  I.e.
both must be disabled for ST.  Falcon will boot regardless of
their values though.

Patch sets them suitable when:
- TOS setup causes CPU core "level" to be switched between
  000 and 030
- machine type is specified on command line

And it sets working default values for them (both values off
as that works both with ST and Falcon).

Only thing that would need major fixing now is the WinUAE
System dialog, it should do the same thing immediately when
user switches machine type in it.


When I tested it with with some ST/STE programs:
- No Cooper / 1984 bombed on startup
- SoWatt / CareBears demo selector overscan was messed up
- Starglider 1 never loaded (with monochrome)
- Nebulous & Interphase worked fine
- STE Stardust demo had wrong colors (and therefore ship
  couldn't be crashed)
- STE Dynablasters+ seems to work.

I.e. it doesn't work so great for ST/E, but at least Hatari
itself is usable and doesn't crash or freeze.


	- Eero
diff -r 5340f289e88c src/change.c
--- a/src/change.c	Wed May 23 22:48:37 2012 +0300
+++ b/src/change.c	Thu May 24 00:36:15 2012 +0300
@@ -119,13 +119,17 @@
 		return true;
 
 	/* Did change CPU prefetch mode? */
-	if (changed->System.bCompatibleCpu != current->System.bCompatibleCpu)
+	if (changed->System.bPrefetchCpu != current->System.bPrefetchCpu)
 		return true;
 
 	/* Did change CPU cycle exact? */
 	if (changed->System.bCycleExactCpu != current->System.bCycleExactCpu)
 		return true;
 
+	/* Did change FPU? */
+	if (changed->System.n_FPUType != current->System.n_FPUType)
+		return true;
+
 	/* Did change MMU? */
 	if (changed->System.bMMU != current->System.bMMU)
 		return true;
diff -r 5340f289e88c src/configuration.c
--- a/src/configuration.c	Wed May 23 22:48:37 2012 +0300
+++ b/src/configuration.c	Thu May 24 00:36:15 2012 +0300
@@ -331,6 +331,7 @@
 
 #if ENABLE_WINUAE_CPU
 	{ "bAddressSpace24", Bool_Tag, &ConfigureParams.System.bAddressSpace24 },
+	{ "bPrefetchCpu", Bool_Tag, &ConfigureParams.System.bPrefetchCpu },
 	{ "bCycleExactCpu", Bool_Tag, &ConfigureParams.System.bCycleExactCpu },
 	{ "n_FPUType", Int_Tag, &ConfigureParams.System.n_FPUType },
 	{ "bCompatibleFPU", Bool_Tag, &ConfigureParams.System.bCompatibleFPU },
@@ -523,7 +524,9 @@
 	ConfigureParams.System.bRealTimeClock = true;
 	ConfigureParams.System.bFastForward = false;
 #if ENABLE_WINUAE_CPU
+	/* use ST settings as ST is default machine type */
 	ConfigureParams.System.bAddressSpace24 = true;
+	ConfigureParams.System.bPrefetchCpu = false;
 	ConfigureParams.System.bCycleExactCpu = false;
 	ConfigureParams.System.n_FPUType = FPU_NONE;
 	ConfigureParams.System.bCompatibleFPU = false;
@@ -786,6 +789,7 @@
 
 #if ENABLE_WINUAE_CPU
 	MemorySnapShot_Store(&ConfigureParams.System.bAddressSpace24, sizeof(ConfigureParams.System.bAddressSpace24));
+	MemorySnapShot_Store(&ConfigureParams.System.bPrefetchCpu, sizeof(ConfigureParams.System.bPrefetchCpu));
 	MemorySnapShot_Store(&ConfigureParams.System.bCycleExactCpu, sizeof(ConfigureParams.System.bCycleExactCpu));
 	MemorySnapShot_Store(&ConfigureParams.System.n_FPUType, sizeof(ConfigureParams.System.n_FPUType));
 	MemorySnapShot_Store(&ConfigureParams.System.bCompatibleFPU, sizeof(ConfigureParams.System.bCompatibleFPU));
diff -r 5340f289e88c src/cpu/hatari-glue.c
--- a/src/cpu/hatari-glue.c	Wed May 23 22:48:37 2012 +0300
+++ b/src/cpu/hatari-glue.c	Thu May 24 00:36:15 2012 +0300
@@ -99,7 +99,7 @@
 		default: fprintf (stderr, "Init680x0() : Error, cpu_level unknown\n");
 	}
 	
-	currprefs.cpu_compatible = changed_prefs.cpu_compatible = ConfigureParams.System.bCompatibleCpu;
+	currprefs.cpu_compatible = changed_prefs.cpu_compatible = ConfigureParams.System.bPrefetchCpu;
 	currprefs.address_space_24 = changed_prefs.address_space_24 = ConfigureParams.System.bAddressSpace24;
 	currprefs.cpu_cycle_exact = changed_prefs.cpu_cycle_exact = ConfigureParams.System.bCycleExactCpu;
 	currprefs.fpu_model = changed_prefs.fpu_model = ConfigureParams.System.n_FPUType;
diff -r 5340f289e88c src/cpu/newcpu.c
--- a/src/cpu/newcpu.c	Wed May 23 22:48:37 2012 +0300
+++ b/src/cpu/newcpu.c	Thu May 24 00:36:15 2012 +0300
@@ -3331,7 +3331,7 @@
 }
 #endif
 
-static oldpc;
+static uaecptr oldpc;
 /* Aranym MMU 68040  */
 static void m68k_run_mmu040 (void)
 {
diff -r 5340f289e88c src/gui-sdl/dlgSystem.c
--- a/src/gui-sdl/dlgSystem.c	Wed May 23 22:48:37 2012 +0300
+++ b/src/gui-sdl/dlgSystem.c	Thu May 24 00:36:15 2012 +0300
@@ -343,7 +343,7 @@
 		systemdlg[DLGSYS_DSPON].state |= SG_SELECTED;
 
 	/* More compatible CPU, Prefetch mode */
-	if (ConfigureParams.System.bCompatibleCpu)
+	if (ConfigureParams.System.bPrefetchCpu)
 		systemdlg[DLGSYS_PREFETCH].state |= SG_SELECTED;
 	else
 		systemdlg[DLGSYS_PREFETCH].state &= ~SG_SELECTED;
@@ -442,7 +442,7 @@
 	else
 		ConfigureParams.System.nDSPType = DSP_TYPE_EMU;
 
-	ConfigureParams.System.bCompatibleCpu = (systemdlg[DLGSYS_PREFETCH].state & SG_SELECTED);
+	ConfigureParams.System.bPrefetchCpu = (systemdlg[DLGSYS_PREFETCH].state & SG_SELECTED);
 	ConfigureParams.System.bBlitter = (systemdlg[DLGSYS_BLITTER].state & SG_SELECTED);
 	ConfigureParams.System.bRealTimeClock = (systemdlg[DLGSYS_RTC].state & SG_SELECTED);
 	ConfigureParams.System.bPatchTimerD = (systemdlg[DLGSYS_TIMERD].state & SG_SELECTED);
diff -r 5340f289e88c src/includes/configuration.h
--- a/src/includes/configuration.h	Wed May 23 22:48:37 2012 +0300
+++ b/src/includes/configuration.h	Thu May 24 00:36:15 2012 +0300
@@ -283,6 +283,7 @@
 
 #if ENABLE_WINUAE_CPU
   bool bAddressSpace24;
+  bool bPrefetchCpu;
   bool bCycleExactCpu;
   FPUTYPE n_FPUType;
   bool bCompatibleFPU;            /* More compatible FPU */
diff -r 5340f289e88c src/m68000.c
--- a/src/m68000.c	Wed May 23 22:48:37 2012 +0300
+++ b/src/m68000.c	Thu May 24 00:36:15 2012 +0300
@@ -276,7 +276,6 @@
 		nCpuFreqShift = 1;
 	}
 	changed_prefs.cpu_level = ConfigureParams.System.nCpuLevel;
-	changed_prefs.cpu_compatible = ConfigureParams.System.bCompatibleCpu;
 
 #if ENABLE_WINUAE_CPU
 	switch (changed_prefs.cpu_level) {
@@ -294,6 +293,10 @@
 	changed_prefs.fpu_model = ConfigureParams.System.n_FPUType;
 	changed_prefs.fpu_strict = ConfigureParams.System.bCompatibleFPU;
 	changed_prefs.mmu_model = ConfigureParams.System.bMMU;
+
+	changed_prefs.cpu_compatible = ConfigureParams.System.bPrefetchCpu;
+#else
+	changed_prefs.cpu_compatible = ConfigureParams.System.bCompatibleCpu;
 #endif
 	if (table68k)
 		check_prefs_changed_cpu();
diff -r 5340f289e88c src/options.c
--- a/src/options.c	Wed May 23 22:48:37 2012 +0300
+++ b/src/options.c	Thu May 24 00:36:15 2012 +0300
@@ -114,7 +114,8 @@
 	OPT_CPUCLOCK,
 	OPT_COMPATIBLE,
 #if ENABLE_WINUAE_CPU
-	OPT_CPU_CYCLE_EXACT,	/* WinUAE CPU/FPU/bus options */
+	OPT_CPU_PREFETCH,	/* WinUAE CPU/FPU/bus options */
+	OPT_CPU_CYCLE_EXACT,
 	OPT_CPU_ADDR24,
 	OPT_FPU_TYPE,
 	OPT_FPU_COMPATIBLE,
@@ -312,8 +313,10 @@
 
 #if ENABLE_WINUAE_CPU
 	{ OPT_HEADER, NULL, NULL, NULL, "WinUAE CPU/FPU/bus" },
+	{ OPT_CPU_PREFETCH, NULL, "--cpu-prefetch",
+	  "<bool>", "Better/more accurate (030) CPU prefetch" },
 	{ OPT_CPU_CYCLE_EXACT, NULL, "--cpu-exact",
-	  "<bool>", "Use cycle exact CPU emulation" },
+	  "<bool>", "Use (030) cycle exact CPU emulation" },
 	{ OPT_CPU_ADDR24, NULL, "--addr24",
 	  "<bool>", "Use 24-bit instead of 32-bit addressing mode" },
 	{ OPT_FPU_TYPE, NULL, "--fpu-type",
@@ -1368,6 +1371,11 @@
 			bLoadAutoSave = false;
 			break;
 
+		case OPT_CPU_PREFETCH:
+			ok = Opt_Bool(argv[++i], OPT_CPU_PREFETCH, &ConfigureParams.System.bPrefetchCpu);
+			bLoadAutoSave = false;
+			break;
+
 		case OPT_CPU_CYCLE_EXACT:
 			ok = Opt_Bool(argv[++i], OPT_CPU_CYCLE_EXACT, &ConfigureParams.System.bCycleExactCpu);
 			bLoadAutoSave = false;
@@ -1432,7 +1440,7 @@
 			else if (strcasecmp(argv[i], "falcon") == 0)
 			{
 #if ENABLE_DSP_EMU
-		ConfigureParams.System.nDSPType = DSP_TYPE_EMU;
+				ConfigureParams.System.nDSPType = DSP_TYPE_EMU;
 #endif
 				ConfigureParams.System.nMachineType = MACHINE_FALCON;
 				ConfigureParams.System.nCpuLevel = 3;
@@ -1442,6 +1450,22 @@
 			{
 				return Opt_ShowError(OPT_MACHINE, argv[i], "Unknown machine type");
 			}
+#if ENABLE_WINUAE_CPU
+			ConfigureParams.System.bMMU = false;	/* does this affect also other than 040 CPUs? */
+			ConfigureParams.System.bAddressSpace24 = true;
+			if (ConfigureParams.System.nCpuLevel > 0) {
+				/* TT / Falcon selected above */
+				ConfigureParams.System.bPrefetchCpu = true;
+				ConfigureParams.System.bCycleExactCpu = true;
+				ConfigureParams.System.bCompatibleFPU = true;
+				ConfigureParams.System.n_FPUType = FPU_68882;
+			} else {
+				/* WinUAE cycles are configured for Falcon/030, so disable this for ST/STE */
+				ConfigureParams.System.bPrefetchCpu = false;
+				ConfigureParams.System.bCycleExactCpu = false;
+				ConfigureParams.System.n_FPUType = FPU_NONE;	/* TODO: or leave it as-is? */
+			}
+#endif
 			bLoadAutoSave = false;
 			break;
 
diff -r 5340f289e88c src/tos.c
--- a/src/tos.c	Wed May 23 22:48:37 2012 +0300
+++ b/src/tos.c	Thu May 24 00:36:15 2012 +0300
@@ -437,6 +437,9 @@
  */
 static void TOS_CheckSysConfig(void)
 {
+#if ENABLE_WINUAE_CPU
+	int oldCpuLevel = ConfigureParams.System.nCpuLevel;
+#endif
 	if ((TosVersion == 0x0106 || TosVersion == 0x0162) && ConfigureParams.System.nMachineType != MACHINE_STE)
 	{
 		Log_AlertDlg(LOG_ERROR, "TOS versions 1.06 and 1.62 are for Atari STE only.\n"
@@ -511,6 +514,26 @@
 		ConfigureParams.System.nCpuLevel = 2;
 		M68000_CheckCpuSettings();
 	}
+#if ENABLE_WINUAE_CPU
+	/* TOS version triggered machine type change? */
+	if (ConfigureParams.System.nCpuLevel != oldCpuLevel &&
+	    ConfigureParams.System.nCpuLevel != 2)
+	{
+		ConfigureParams.System.bMMU = false;		/* TODO: does this affect also other than 040 CPUs? */
+		ConfigureParams.System.bAddressSpace24 = true;
+		if (ConfigureParams.System.nCpuLevel > 0) {
+			/* TT / Falcon selected above */
+			ConfigureParams.System.bPrefetchCpu = true;
+			ConfigureParams.System.bCycleExactCpu = true;
+			ConfigureParams.System.n_FPUType = FPU_68882;
+		} else {
+			/* WinUAE cycles are configured for Falcon/030, so disable this for ST/STE */
+			ConfigureParams.System.bPrefetchCpu = false;
+			ConfigureParams.System.bCycleExactCpu = false;
+			ConfigureParams.System.n_FPUType = FPU_NONE;	/* TODO: or leave it as-is? */
+		}
+	}
+#endif
 	if (TosVersion < 0x0104 && ConfigureParams.HardDisk.bUseHardDiskDirectories)
 	{
 		Log_AlertDlg(LOG_ERROR, "Please use at least TOS v1.04 for the HD directory emulation "


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/