Re: [hatari-devel] add support for TT ram ?

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


Hi,

On sunnuntai 16 marraskuu 2014, Nicolas Pomarède wrote:
> Le 16/11/2014 11:00, Eero Tamminen a écrit :
> > On perjantai 14 marraskuu 2014, Nicolas Pomarède wrote:
> >> I see that in memory.c code is almost there to handle more ram at
> >> 0x01000000 , as provided on TT for example when using 32 bit
> >> addressing.
> >> 
> >> Only missing parts seem to be an option in the UI and some command
> >> line parameters (--tt-ramsize for example).
> >> 
> >> To use such ram, the cpu needs to use 32-bit addressing mode (--addr24
> >> false), but apart from that it should work with >= 68020.
> >> 
> >> Is there any reason why it was not enabled so far ?
> > 
> > Would it help if I would already provide patch for the options and GUI?
> > :-)
> 
> It will certainly help, but let's not commit it so soon and give false
> hope to users :)
> Still, if you have a patch, you can keep it around and apply it after I
> commit my changes for WinUAE's cpu (maybe this week)

Attached patch implements the config & option handling + GUI stuff,
hopefully it helps in testing the actual TT-ram implementation. :-)

What kind of amounts of TT-RAM there can be?  In GUI I used 4MB
step (to speed changing it), on command line the amount can be
specified in MBs.


	- Eero
diff -r 5449e91a3e3f doc/hatari.1
--- a/doc/hatari.1	Sun Nov 16 11:53:19 2014 +0200
+++ b/doc/hatari.1	Thu Nov 20 00:00:13 2014 +0200
@@ -271,7 +271,10 @@
 Load memory snap-shot <file>
 .TP 
 .B \-s, \-\-memsize <x>
-Set amount of emulated RAM, x = 1 to 14 MiB, or 0 for 512 KiB
+Set amount of emulated ST RAM, x = 1 to 14 MiB, or 0 for 512 KiB
+.TP
+.B \-s, \-\-ttram <x>
+Set amount of emulated TT RAM, x = 0 to 256 MiB
 
 .SH "ROM options"
 .TP 
diff -r 5449e91a3e3f src/change.c
--- a/src/change.c	Sun Nov 16 11:53:19 2014 +0200
+++ b/src/change.c	Thu Nov 20 00:00:13 2014 +0200
@@ -151,6 +151,8 @@
 	/* Did change size of memory? */
 	if (current->Memory.nMemorySize != changed->Memory.nMemorySize)
 		return true;
+	if (current->Memory.nTTRamSize != changed->Memory.nTTRamSize)
+		return true;
 
 	/* MIDI related IRQs start/stop needs reset */
 	if (current->Midi.bEnableMidi != changed->Midi.bEnableMidi)
diff -r 5449e91a3e3f src/configuration.c
--- a/src/configuration.c	Sun Nov 16 11:53:19 2014 +0200
+++ b/src/configuration.c	Thu Nov 20 00:00:13 2014 +0200
@@ -260,6 +260,7 @@
 static const struct Config_Tag configs_Memory[] =
 {
 	{ "nMemorySize", Int_Tag, &ConfigureParams.Memory.nMemorySize },
+	{ "nTTRamSize", Int_Tag, &ConfigureParams.Memory.nTTRamSize },
 	{ "bAutoSave", Bool_Tag, &ConfigureParams.Memory.bAutoSave },
 	{ "szMemoryCaptureFileName", String_Tag, ConfigureParams.Memory.szMemoryCaptureFileName },
 	{ "szAutoSaveFileName", String_Tag, ConfigureParams.Memory.szAutoSaveFileName },
@@ -525,6 +526,7 @@
 
 	/* Set defaults for Memory */
 	ConfigureParams.Memory.nMemorySize = 1;     /* 1 MiB */
+	ConfigureParams.Memory.nTTRamSize = 0;     /* disabled */
 	ConfigureParams.Memory.bAutoSave = false;
 	sprintf(ConfigureParams.Memory.szMemoryCaptureFileName, "%s%chatari.sav",
 	        psHomeDir, PATHSEP);
@@ -871,6 +873,7 @@
 	MemorySnapShot_Store(ConfigureParams.Rom.szCartridgeImageFileName, sizeof(ConfigureParams.Rom.szCartridgeImageFileName));
 
 	MemorySnapShot_Store(&ConfigureParams.Memory.nMemorySize, sizeof(ConfigureParams.Memory.nMemorySize));
+	MemorySnapShot_Store(&ConfigureParams.Memory.nMemorySize, sizeof(ConfigureParams.Memory.nTTRamSize));
 
 	MemorySnapShot_Store(&ConfigureParams.DiskImage.szDiskFileName[0], sizeof(ConfigureParams.DiskImage.szDiskFileName[0]));
 	MemorySnapShot_Store(&ConfigureParams.DiskImage.szDiskZipPath[0], sizeof(ConfigureParams.DiskImage.szDiskZipPath[0]));
diff -r 5449e91a3e3f src/gui-sdl/dlgMemory.c
--- a/src/gui-sdl/dlgMemory.c	Sun Nov 16 11:53:19 2014 +0200
+++ b/src/gui-sdl/dlgMemory.c	Thu Nov 20 00:00:13 2014 +0200
@@ -12,6 +12,7 @@
 #include "memorySnapShot.h"
 #include "file.h"
 #include "screen.h"
+#include "vdi.h"
 
 
 #define DLGMEM_512KB    4
@@ -20,22 +21,32 @@
 #define DLGMEM_4MB      7
 #define DLGMEM_8MB      8
 #define DLGMEM_14MB     9
-#define DLGMEM_FILENAME 13
-#define DLGMEM_SAVE     14
-#define DLGMEM_RESTORE  15
-#define DLGMEM_AUTOSAVE 16
-#define DLGMEM_EXIT     17
+#define DLGMEM_TTRAM_LESS    11
+#define DLGMEM_TTRAM_TEXT    12
+#define DLGMEM_TTRAM_MORE    13
+#define DLGMEM_FILENAME 17
+#define DLGMEM_SAVE     18
+#define DLGMEM_RESTORE  19
+#define DLGMEM_AUTOSAVE 20
+#define DLGMEM_EXIT     21
 
 
+/* String for TT RAM size */
+static char sTTRamSize[4];
+
+#define TTRAM_STEP	4
+#define TTRAM_MIN	0
+#define TTRAM_MAX	256
+
 static char dlgSnapShotName[36+1];
 
 
 /* The memory dialog: */
 static SGOBJ memorydlg[] =
 {
-	{ SGBOX, 0, 0, 0,0, 40,22, NULL },
+	{ SGBOX, 0, 0, 0,0, 40,24, NULL },
 
-	{ SGBOX, 0, 0, 1,1, 38,7, NULL },
+	{ SGBOX, 0, 0, 1,1, 38,9, 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, "_512 KiB" },
@@ -44,16 +55,20 @@
 	{ SGRADIOBUT, 0, 0, 29,4, 7,1, "_4 MiB" },
 	{ SGRADIOBUT, 0, 0, 29,5, 7,1, "_8 MiB" },
 	{ SGRADIOBUT, 0, 0, 29,6, 8,1, "14 _MiB" },
+	{ SGTEXT,     0, 0,  4,8,12,1, "TT-RAM size:" },
+	{ SGBUTTON,   0, 0, 18,8, 1,1, "\x04", SG_SHORTCUT_LEFT },
+	{ SGTEXT,     0, 0, 20,8, 3,1, sTTRamSize },
+	{ SGBUTTON,   0, 0, 24,8, 1,1, "\x03", SG_SHORTCUT_RIGHT },
 
-	{ SGBOX, 0, 0, 1,9, 38,10, NULL },
-	{ SGTEXT, 0, 0, 12,10, 17,1, "Memory state save" },
-	{ SGTEXT, 0, 0, 2,12, 20,1, "Snap-shot file name:" },
-	{ SGTEXT, 0, 0, 2,13, 36,1, dlgSnapShotName },
-	{ SGBUTTON,   0, 0,  8,15, 10,1, "_Save" },
-	{ SGBUTTON,   0, 0, 22,15, 10,1, "_Restore" },
-	{ SGCHECKBOX, 0, 0,  2,17, 34,1, "_Load/save state at start-up/exit" },
+	{ SGBOX,      0, 0,  1,11, 38,10, NULL },
+	{ SGTEXT,     0, 0, 12,12, 17,1, "Memory state save" },
+	{ SGTEXT,     0, 0,  2,14, 20,1, "Snap-shot file name:" },
+	{ SGTEXT,     0, 0,  2,15, 36,1, dlgSnapShotName },
+	{ SGBUTTON,   0, 0,  8,17, 10,1, "_Save" },
+	{ SGBUTTON,   0, 0, 22,17, 10,1, "_Restore" },
+	{ SGCHECKBOX, 0, 0,  2,19, 34,1, "_Load/save state at start-up/exit" },
 
-	{ SGBUTTON, SG_DEFAULT, 0, 10,20, 20,1, "Back to main menu" },
+	{ SGBUTTON, SG_DEFAULT, 0, 10,22, 20,1, "Back to main menu" },
 	{ -1, 0, 0, 0,0, 0,0, NULL }
 };
 
@@ -96,6 +111,7 @@
 		memorydlg[DLGMEM_14MB].state |= SG_SELECTED;
 		break;
 	}
+	sprintf(sTTRamSize, "%3i", ConfigureParams.Memory.nTTRamSize);
 
 	File_ShrinkName(dlgSnapShotName, ConfigureParams.Memory.szMemoryCaptureFileName, memorydlg[DLGMEM_FILENAME].w);
 
@@ -111,6 +127,17 @@
 
 		switch (but)
 		{
+		 case DLGMEM_TTRAM_LESS:
+			ConfigureParams.Memory.nTTRamSize = VDI_Limit(ConfigureParams.Memory.nTTRamSize - TTRAM_STEP,
+								      TTRAM_STEP, TTRAM_MIN, TTRAM_MAX);
+			sprintf(sTTRamSize, "%3i", ConfigureParams.Memory.nTTRamSize);
+			break;
+		 case DLGMEM_TTRAM_MORE:
+			ConfigureParams.Memory.nTTRamSize = VDI_Limit(ConfigureParams.Memory.nTTRamSize + TTRAM_STEP,
+								      TTRAM_STEP, TTRAM_MIN, TTRAM_MAX);
+			sprintf(sTTRamSize, "%3i", ConfigureParams.Memory.nTTRamSize);
+			break;
+
 		 case DLGMEM_SAVE:              /* Save memory snap-shot */
 			if (SDLGui_FileConfSelect("Save memory snapshot:", dlgSnapShotName,
 			                          ConfigureParams.Memory.szMemoryCaptureFileName,
diff -r 5449e91a3e3f src/includes/configuration.h
--- a/src/includes/configuration.h	Sun Nov 16 11:53:19 2014 +0200
+++ b/src/includes/configuration.h	Thu Nov 20 00:00:13 2014 +0200
@@ -118,6 +118,7 @@
 typedef struct
 {
   int nMemorySize;
+  int nTTRamSize;
   bool bAutoSave;
   char szMemoryCaptureFileName[FILENAME_MAX];
   char szAutoSaveFileName[FILENAME_MAX];
diff -r 5449e91a3e3f src/options.c
--- a/src/options.c	Sun Nov 16 11:53:19 2014 +0200
+++ b/src/options.c	Thu Nov 20 00:00:13 2014 +0200
@@ -118,6 +118,7 @@
 	OPT_IDEMASTERHDIMAGE,
 	OPT_IDESLAVEHDIMAGE,
 	OPT_MEMSIZE,		/* memory options */
+	OPT_TT_RAM,
 	OPT_MEMSTATE,
 	OPT_TOS,		/* ROM options */
 	OPT_PATCHTOS,
@@ -327,6 +328,8 @@
 	{ OPT_HEADER, NULL, NULL, NULL, "Memory" },
 	{ OPT_MEMSIZE,   "-s", "--memsize",
 	  "<x>", "ST RAM size (x = size in MiB from 0 to 14, 0 = 512KiB)" },
+	{ OPT_TT_RAM,   NULL, "--ttram",
+	  "<x>", "TT RAM size (x = size in MiB from 0 to 256)" },
 	{ OPT_MEMSTATE,   NULL, "--memstate",
 	  "<file>", "Load memory snap-shot <file>" },
 
@@ -1422,6 +1425,16 @@
 			bLoadAutoSave = false;
 			break;
 
+		case OPT_TT_RAM:
+			memsize = atoi(argv[++i]);
+			if (memsize < 0 || memsize > 256)
+			{
+				return Opt_ShowError(OPT_TT_RAM, argv[i], "Invalid memory size");
+			}
+			ConfigureParams.Memory.nTTRamSize = memsize;
+			bLoadAutoSave = false;
+			break;
+
 		case OPT_TOS:
 			i += 1;
 			ok = Opt_StrCpy(OPT_TOS, true, ConfigureParams.Rom.szTosImageFileName,
diff -r 5449e91a3e3f src/statusbar.c
--- a/src/statusbar.c	Sun Nov 16 11:53:19 2014 +0200
+++ b/src/statusbar.c	Thu Nov 20 00:00:13 2014 +0200
@@ -428,18 +428,19 @@
 		*end++ = '0' + ConfigureParams.System.nCpuFreq / 10;
 	}
 	*end++ = '0' + ConfigureParams.System.nCpuFreq % 10;
-	end = Statusbar_AddString(end, "MHz/");
+	end = Statusbar_AddString(end, "MHz");
 
 	/* CPU type */
 	if(ConfigureParams.System.nCpuLevel > 0) {
+		*end++ = '/';
 		*end++ = '0';
 		*end++ = '0' + ConfigureParams.System.nCpuLevel % 10;
 		*end++ = '0';
-		*end++ = '/';
 	}
 
 	/* additional WinUAE CPU/FPU info */
 #if ENABLE_WINUAE_CPU
+	*end++ = '/';
 	switch (ConfigureParams.System.n_FPUType) {
 	case FPU_68881:
 		end = Statusbar_AddString(end, "68881");
@@ -453,13 +454,13 @@
 	default:
 		*end++ = '-';
 	}
-	*end++ = '/';
 	if (ConfigureParams.System.bMMU) {
-		end = Statusbar_AddString(end, "MMU/");
+		end = Statusbar_AddString(end, "/MMU");
 	}
 #endif
 
 	/* amount of memory */
+	*end++ = ' ';
 	if (ConfigureParams.Memory.nMemorySize > 9) {
 		*end++ = '1';
 		*end++ = '0' + ConfigureParams.Memory.nMemorySize % 10;
@@ -470,6 +471,9 @@
 			end = Statusbar_AddString(end, "0.5");
 		}
 	}
+	if (ConfigureParams.Memory.nTTRamSize) {
+		end += sprintf(end, "/%i", ConfigureParams.Memory.nTTRamSize);
+	}
 	end = Statusbar_AddString(end, "MB ");
 
 	/* machine type */


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