Re: [hatari-devel] Allowing/supporting additional ST-RAM amounts?

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


Hi,

On 4/13/20 6:27 AM, Thomas Huth wrote:
Am Sat, 4 Apr 2020 00:05:27 +0300
schrieb Eero Tamminen <oak@xxxxxxxxxxxxxx>:
What else than the attached patch is needed to properly support
additional ST-RAM amount?

The GUI should be updated accordingly, too, I think.

Does the attached patch look OK?


I'm asking because the real max ST-RAM limit for TT and MegaSTE
machines is 10MB (not 8MB nor 14MB that Hatari currently allows).

If 10 MB is a valid configuration, I guess we should allow it, too...
the difference shouldn't matter on normal ST/STEs since their real
maximum was 4 MB anyway, and on Falcon we could simply fall back to 8MB
after showing a warning to the user.

I opted selecting next Falcon mem amount on
assumption that user selected memory amount so that it's enough for his/her use-case, so using
smaller one wouldn't be right.

Should something about this be mentioned in
manual page too?


	- Eero

commit 67a92f07870eac5402794695c718630d77ba74c4
Author: Eero Tamminen <oak@xxxxxxxxxxxxxx>
Date:   Wed Apr 1 15:24:56 2020 +0300

    Accept 10MB (MegaSTE/TT max) as valid ST-RAM amount
    
    Add command line and SDL GUI support for it, and correct Falcon
    memory amount to supported one, as there doesn't seem to be
    a config for 10MB.
    
    MegaSTE/TT info is from Christian Zietz:
    
    The TT has 2 MB of on-board ST-RAM and there were upgrade cards with
    2 MB and 8 MB. But you could only add one upgrade, not both. Thus, at
    maximum 10 MB ST-RAM.  And TT MCU simply never decodes addresses above
    0x9FFFFF. [1]
    
    On MegaSTE the memory above 10 MB is used for VME.
    
    [1] This has been found also in Simbo's HW experiments:
      http://www.atari-forum.com/viewtopic.php?f=27&t=19784&start=25#p218548
    
    => Even if more memory (12 or 16MB) is installed to TT, only 10MB is visible.

diff --git a/doc/release-notes.txt b/doc/release-notes.txt
index cfce3a17..7a7bb3d1 100644
--- a/doc/release-notes.txt
+++ b/doc/release-notes.txt
@@ -55,6 +55,8 @@ Emulator:
 - Show mouse grab toggle shortcut key in startup statusbar message
 - Center host mouse to Hatari window on Atari resets and resolution
   changes only when window is focused and mouse pointer is within it
+- Accept 10MB as valid ST-RAM amount (max on real MegaSTE/TT machines)
+  and correct invalid Falcon ST-RAM amounts
 - Fix: 24-bit address mode change while emulation is running
   (triggered e.g. when TT-RAM is enabled for TT)
 - Fix: when autostarting programs without pre-existing INF file,
diff --git a/src/gui-sdl/dlgMemory.c b/src/gui-sdl/dlgMemory.c
index 18825726..bfa71bb2 100644
--- a/src/gui-sdl/dlgMemory.c
+++ b/src/gui-sdl/dlgMemory.c
@@ -22,15 +22,16 @@ const char DlgMemory_fileid[] = "Hatari dlgMemory.c : " __DATE__ " " __TIME__;
 #define DLGMEM_2_5MB	8
 #define DLGMEM_4MB	9
 #define DLGMEM_8MB	10
-#define DLGMEM_14MB	11
-#define DLGMEM_TTRAM_LESS	13
-#define DLGMEM_TTRAM_TEXT	14
-#define DLGMEM_TTRAM_MORE	15
-#define DLGMEM_FILENAME	20
-#define DLGMEM_SAVE	21
-#define DLGMEM_RESTORE	22
-#define DLGMEM_AUTOSAVE	23
-#define DLGMEM_EXIT	24
+#define DLGMEM_10MB	11
+#define DLGMEM_14MB	12
+#define DLGMEM_TTRAM_LESS	14
+#define DLGMEM_TTRAM_TEXT	15
+#define DLGMEM_TTRAM_MORE	16
+#define DLGMEM_FILENAME	21
+#define DLGMEM_SAVE	22
+#define DLGMEM_RESTORE	23
+#define DLGMEM_AUTOSAVE	24
+#define DLGMEM_EXIT	25
 
 
 /* String for TT RAM size */
@@ -51,14 +52,15 @@ static SGOBJ memorydlg[] =
 	{ SGBOX, 0, 0, 1,1, 38,10, NULL },
 	{ SGTEXT, 0, 0, 15,2, 12,1, "Memory setup" },
 	{ SGTEXT, 0, 0, 4,4, 12,1, "ST-RAM size:" },
-	{ SGRADIOBUT, 0, 0, 18,4, 9,1, "256 KiB" },
-	{ SGRADIOBUT, 0, 0, 18,5, 9,1, "_512 KiB" },
-	{ SGRADIOBUT, 0, 0, 18,6, 7,1, "_1 MiB" },
-	{ SGRADIOBUT, 0, 0, 18,7, 7,1, "_2 MiB" },
-	{ SGRADIOBUT, 0, 0, 29,4, 7,1, "2.5 MiB" },
-	{ SGRADIOBUT, 0, 0, 29,5, 7,1, "_4 MiB" },
-	{ SGRADIOBUT, 0, 0, 29,6, 7,1, "_8 MiB" },
-	{ SGRADIOBUT, 0, 0, 29,7, 8,1, "14 _MiB" },
+	{ SGRADIOBUT, 0, 0,  7,6, 9,1, "256 _KiB" },
+	{ SGRADIOBUT, 0, 0,  7,7, 9,1, "512 Ki_B" },
+	{ SGRADIOBUT, 0, 0, 18,4, 9,1, "  _1 MiB" },
+	{ SGRADIOBUT, 0, 0, 18,5, 9,1, "  _2 MiB" },
+	{ SGRADIOBUT, 0, 0, 18,6, 9,1, "2._5 MiB" },
+	{ SGRADIOBUT, 0, 0, 18,7, 9,1, "  _4 MiB" },
+	{ SGRADIOBUT, 0, 0, 29,4, 9,1, " _8 MiB" },
+	{ SGRADIOBUT, 0, 0, 29,5, 9,1, "1_0 MiB" },
+	{ SGRADIOBUT, 0, 0, 29,6, 9,1, "14 _MiB" },
 	{ SGTEXT,     0, 0,  4,9,12,1, "TT-RAM size:" },
 	{ SGBUTTON,   0, 0, 18,9, 1,1, "\x04", SG_SHORTCUT_LEFT },
 	{ SGTEXT,     0, 0, 20,9, 3,1, sTTRamSize },
@@ -118,6 +120,9 @@ bool Dialog_MemDlg(void)
 	 case 8*1024:
 		memorydlg[DLGMEM_8MB].state |= SG_SELECTED;
 		break;
+	 case 10*1024:
+		memorydlg[DLGMEM_10MB].state |= SG_SELECTED;
+		break;
 	 default:
 		memorydlg[DLGMEM_14MB].state |= SG_SELECTED;
 		break;
@@ -194,6 +199,8 @@ bool Dialog_MemDlg(void)
 		ConfigureParams.Memory.STRamSize_KB = 4*1024;
 	else if (memorydlg[DLGMEM_8MB].state & SG_SELECTED)
 		ConfigureParams.Memory.STRamSize_KB = 8*1024;
+	else if (memorydlg[DLGMEM_10MB].state & SG_SELECTED)
+		ConfigureParams.Memory.STRamSize_KB = 10*1024;
 	else
 		ConfigureParams.Memory.STRamSize_KB = 14*1024;
 
diff --git a/src/includes/stMemory.h b/src/includes/stMemory.h
index 2f8c7f7d..ed6af330 100644
--- a/src/includes/stMemory.h
+++ b/src/includes/stMemory.h
@@ -48,6 +48,7 @@ extern bool STMemory_SafeClear(Uint32 addr, unsigned int len);
 extern bool STMemory_SafeCopy(Uint32 addr, Uint8 *src, unsigned int len, const char *name);
 extern void STMemory_MemorySnapShot_Capture(bool bSave);
 extern void STMemory_SetDefaultConfig(void);
+extern int  STMemory_CorrectSTRamSize(void);
 extern bool STMemory_CheckAreaType ( Uint32 addr , int size , int mem_type );
 extern bool STMemory_CheckRegionBusError ( Uint32 addr );
 extern void *STMemory_STAddrToPointer ( Uint32 addr );
diff --git a/src/stMemory.c b/src/stMemory.c
index 96a3539b..2c96aebb 100644
--- a/src/stMemory.c
+++ b/src/stMemory.c
@@ -451,6 +451,49 @@ void STMemory_SetDefaultConfig(void)
 	STMemory_WriteLong(0x4c2, ConnectedDriveMask);
 }
 
+/**
+ * Called after machine type is fixed, to correct ST-RAM amount to machine
+ * specific value, when machine doesn't support all values accepted by Hatari.
+ *
+ * Returns resulting STRamEnd value.
+ */
+int STMemory_CorrectSTRamSize(void)
+{
+	int STRamSize_KB = ConfigureParams.Memory.STRamSize_KB;
+
+	if (Config_IsMachineFalcon())
+	{
+		/* These values need to match ones used in STMemory_SetDefaultConfig()
+		 * above.
+		 *
+		 * Check ranges which might have non-supported memory values:
+		 *   10MB, 6MB & 2.5MB
+		 */
+		if (STRamSize_KB > 8*1024 && STRamSize_KB < 14*1024)
+			STRamSize_KB = 14*1024;
+		else if (STRamSize_KB > 4*1024 && STRamSize_KB < 8*1024)
+			STRamSize_KB = 8*1024;
+		else if (STRamSize_KB > 2*1024 && STRamSize_KB < 4*1024)
+			STRamSize_KB = 4*1024;
+
+		if (STRamSize_KB != ConfigureParams.Memory.STRamSize_KB)
+		{
+			Log_Printf(LOG_WARN, "unsupported Falcon ST-RAM amount %d, changing to %d KB\n",
+				   ConfigureParams.Memory.STRamSize_KB, STRamSize_KB);
+			ConfigureParams.Memory.STRamSize_KB = STRamSize_KB;
+		}
+	}
+	else if (Config_IsMachineMegaSTE() || Config_IsMachineTT())
+	{
+		if (STRamSize_KB > 10*1024)
+		{
+			Log_Printf(LOG_INFO, "maximum MegaSTE/TT ST-RAM amount is 10MB, not %dMB\n",
+				   STRamSize_KB/1024);
+		}
+	}
+	return STRamSize_KB * 1024;
+}
+
 
 /**
  * Check that the region of 'size' starting at 'addr' is entirely inside
@@ -799,7 +842,7 @@ int	STMemory_RAM_Validate_Size_KB ( int TotalMem )
 	/* New format where ST RAM size is in KB */
 	if (  ( TotalMem ==  128 ) || ( TotalMem ==  256 ) || ( TotalMem ==  512 ) || ( TotalMem ==  640 )
 		|| ( TotalMem == 1024 ) || ( TotalMem == 2048 ) || ( TotalMem == 2176 ) || ( TotalMem == 2560 )
-		|| ( TotalMem == 4096 )	|| ( TotalMem == 8*1024 ) || ( TotalMem == 14*1024 ) )
+		|| ( TotalMem == 4096 ) || ( TotalMem == 8*1024 ) || ( TotalMem == 10*1024 ) || ( TotalMem == 14*1024 ) )
 		return TotalMem;
 
 	return -1;
diff --git a/src/tos.c b/src/tos.c
index 65036d6b..9a11f3d9 100644
--- a/src/tos.c
+++ b/src/tos.c
@@ -1128,6 +1128,12 @@ int TOS_InitImage(void)
 			return -1;
 	}
 
+	/* After TOS is loaded, and machine configuration adapted
+	 * accordingly, correct memory amount to valid machine
+	 * specific value
+	 */
+	STRamEnd = STMemory_CorrectSTRamSize();
+
 	/* (Re-)Initialize the memory banks: */
 	memory_uninit();
 	memory_init(STRamEnd, ConfigureParams.Memory.TTRamSize_KB*1024, TosAddress);


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