Index: firmware/a800/freeze.c
===================================================================
--- firmware/a800/freeze.c	(revision 349)
+++ firmware/a800/freeze.c	(revision 350)
@@ -3,7 +3,6 @@
 #include "regs.h"
 #include "memory.h"
 
-unsigned char store_portb;
 unsigned volatile char * store_mem;
 unsigned volatile char * custom_mirror;
 unsigned volatile char * atari_base;
@@ -48,7 +47,7 @@
 {
 	int i;
 	// store custom chips
-	store_portb = *atari_portb;
+	store_mem[0xd300] = *atari_portb;
 	{
 		//backup last value written to custom chip regs
 		//gtia
@@ -110,6 +109,32 @@
 		memcp8(store_mem,atari_base,0xd400,0x10);
 	}
 
-	*atari_portb = store_portb;
+	*atari_portb = store_mem[0xd300];
 }
 
+void freeze_save(struct SimpleFile * file)
+{
+	if (file_size(file)>=65536 && file_readonly(file)==0)
+	{
+		int byteswritten = 0;
+		file_write(file,(void *)store_mem,65536,&byteswritten);
+		file_write_flush();
+	}
+}
+void freeze_load(struct SimpleFile * file)
+{
+	if (file_size(file)>=65536)
+	{
+		int bytesread = 0;
+		file_read(file,(void *)store_mem,65536,&bytesread);
+	}
+}
+
+
+/*
+enum SimpleFileStatus file_read(struct SimpleFile * file, void * buffer, int bytes, int * bytesread);
+
+enum SimpleFileStatus file_write(struct SimpleFile * file, void * buffer, int bytes, int * byteswritten);
+enum SimpleFileStatus file_write_flush();
+*/
+
Index: firmware/a800/mainmenu.c
===================================================================
--- firmware/a800/mainmenu.c	(revision 349)
+++ firmware/a800/mainmenu.c	(revision 350)
@@ -182,6 +182,14 @@
 
 		debug_pos = 520;
 		debug_adjust = row==9 ? 128 : 0;
+		printf("Load memory");
+
+		debug_pos = 560;
+		debug_adjust = row==10 ? 128 : 0;
+		printf("Save memory (for debugging)");
+
+		debug_pos = 640;
+		debug_adjust = row==11 ? 128 : 0;
 		printf("Exit");
 
 		// Slow it down a bit
@@ -194,7 +202,7 @@
 
 		row+=joy.y_;
 		if (row<0) row = 0;
-		if (row>9) row = 8;
+		if (row>11) row = 11;
 		switch (row)
 		{
 		case 0:
@@ -291,6 +299,25 @@
 			}
 			break;
 		case 9:
+		case 10:
+			{
+				if (joy.fire_)
+				{
+					fil_type = fil_type_mem;
+					filter = filter_specified;
+					file_selector(files[6]);
+					if (row == 9)
+					{
+						freeze_load(files[6]);
+					}
+					else if (row == 10)
+					{
+						freeze_save(files[6]);
+					}
+				}
+			}
+			break;
+		case 11:
 			if (joy.fire_)
 			{
 				done = 1;
Index: firmware/fileselector.c
===================================================================
--- firmware/fileselector.c	(revision 349)
+++ firmware/fileselector.c	(revision 350)
@@ -27,6 +27,7 @@
 char const * fil_type_rom;
 char const * fil_type_bin;
 char const * fil_type_car;
+char const * fil_type_mem;
 int filter_specified(struct SimpleDirEntry * entry)
 {
 	if (dir_is_subdir(entry)) return 1;
Index: firmware/fileselector.h
===================================================================
--- firmware/fileselector.h	(revision 349)
+++ firmware/fileselector.h	(revision 350)
@@ -7,6 +7,7 @@
 extern char const * fil_type_rom;
 extern char const * fil_type_bin;
 extern char const * fil_type_car;
+extern char const * fil_type_mem;
 int filter_specified(struct SimpleDirEntry * entry);
 
 extern int (* filter)(struct SimpleDirEntry * entry);
Index: firmware/freeze.h
===================================================================
--- firmware/freeze.h	(revision 349)
+++ firmware/freeze.h	(revision 350)
@@ -1,5 +1,7 @@
 #pragma once
 
+#include "simplefile.h"
+
 // Allow us to take over the system
 // NB: CPU should be frozen before calling these!
 
@@ -14,3 +16,7 @@
 // Restore hardware registers
 void restore();
 
+// Store system ram to a file for debugging (base 64k only)
+void freeze_save(struct SimpleFile * file);
+void freeze_load(struct SimpleFile * file);
+
Index: firmware/main.h
===================================================================
--- firmware/main.h	(revision 349)
+++ firmware/main.h	(revision 350)
@@ -246,6 +246,7 @@
 	fil_type_rom = "ROM";
 	fil_type_bin = "BIN";
 	fil_type_car = "CAR";
+	fil_type_mem = "MEM";
 
 	int i;
 	for (i=0; i!=NUM_FILES; ++i)
