/[RomCheater]/trunk/RomCheater.EmuMMAPPlugin/EmuMEMMapDockControl.cs
ViewVC logotype

Diff of /trunk/RomCheater.EmuMMAPPlugin/EmuMEMMapDockControl.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.EmuMMAPPlugin/EmuMEMMapDockControl.cs	2013/06/08 19:20:04	628
+++ trunk/RomCheater.EmuMMAPPlugin/EmuMEMMapDockControl.cs	2013/06/08 21:58:23	642
@@ -12,9 +12,239 @@
 {
     public partial class EmuMEMMapDockControl : DockContent
     {
+        private List<DeviceMemoryMap> DeviceMemoryMaps = new List<DeviceMemoryMap>();
         public EmuMEMMapDockControl()
         {
             InitializeComponent();
+            CreateMaps();
         }
+        private void EmuMEMMapDockControl_Shown(object sender, EventArgs e)
+        {
+            txtDeviceMap.Clear();
+            txtDeviceMap.AppendText(string.Format("Device Memory Map(s):{0}", System.Environment.NewLine));
+            foreach (var k in DeviceMemoryMaps)
+            {
+                string devicename = k.DeviceName;
+                txtDeviceMap.AppendText(string.Format("{0}:{1}", devicename, System.Environment.NewLine));
+                var map = k.MemoryMap;
+                foreach (var mapped in map)
+                {
+                    var mapped_name = mapped.Key;
+                    var mapped_data = mapped.Value;
+                    var t = mapped_data.ToString();
+                    txtDeviceMap.AppendText(string.Format("\t{0}{1}", t, System.Environment.NewLine));
+                }
+            }
+        }
+        private void CreateMaps()
+        {
+            var map = new DeviceMemoryMap();
+
+            #region NES
+            map = CreateNESMemMap();
+            DeviceMemoryMaps.Add(map);
+            #endregion
+            #region SNES
+            map = CreateSNESMemMap();
+            DeviceMemoryMaps.Add(map);
+            #endregion
+            #region PS1
+            map = CreatePS1MemMap();
+            DeviceMemoryMaps.Add(map);
+            #endregion
+            #region PS2
+            map = CreatePS2MemMap();
+            DeviceMemoryMaps.Add(map);
+            #endregion
+            #region N64
+            map = CreateN64MemMap();
+            DeviceMemoryMaps.Add(map);
+            #endregion
+            #region NGC
+            map = CreateNGCMemMap();
+            DeviceMemoryMaps.Add(map);
+            #endregion
+            #region WII
+            map = CreateWIIMemMap();
+            DeviceMemoryMaps.Add(map);
+            #endregion
+            map = null;
+        }
+
+        #region NES
+        private DeviceMemoryMap CreateNESMemMap()
+        {
+            const string name = "NES";
+            DeviceMemoryMap map = new DeviceMemoryMap();            
+            List<IMemMap> maprange = new List<IMemMap>();
+            #region memory maps
+            maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            #endregion
+            map = new DeviceMemoryMap(name, maprange);
+            return map;
+        }
+        #endregion
+        #region SNES
+        private DeviceMemoryMap CreateSNESMemMap()
+        {
+            const string name = "SNES";
+            DeviceMemoryMap map = new DeviceMemoryMap();
+            List<IMemMap> maprange = new List<IMemMap>();
+            #region memory maps
+            maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            #endregion
+            map = new DeviceMemoryMap(name, maprange);
+            return map;
+        }
+        #endregion
+        #region PS1
+        private DeviceMemoryMap CreatePS1MemMap()
+        {
+            const string name = "PS1";
+            DeviceMemoryMap map = new DeviceMemoryMap();
+            List<IMemMap> maprange = new List<IMemMap>();
+            #region memory maps
+            maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            #endregion
+            map = new DeviceMemoryMap(name, maprange);
+            return map;
+        }
+        #endregion
+        #region PS2
+        private DeviceMemoryMap CreatePS2MemMap()
+        {
+            const string name = "PS2";
+            DeviceMemoryMap map = new DeviceMemoryMap();
+            List<IMemMap> maprange = new List<IMemMap>();
+            #region memory maps
+            //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            maprange.Add(new MemMap("EE Kernel", 0x80000000, 0x800FFFFF));
+            maprange.Add(new MemMap("EE RAM (Cached)", 0x00100000, 0x01FFFFFF));
+            maprange.Add(new MemMap("EE RAM (Uncached)", 0x20100000, 0x21FFFFFF));
+            maprange.Add(new MemMap("EE RAM (Uncached&accelerated)", 0x30100000, 0x31FFFFFF));
+            maprange.Add(new MemMap("EE Registers (uncached)", 0x10000000, 0x11FFFFFF));
+            maprange.Add(new MemMap("GS Registers (uncached)", 0x12000000, 0x13FFFFFF));
+            maprange.Add(new MemMap("Boot ROM0 (uncached)", 0x1FC00000, 0x1FFFFFFF));
+            maprange.Add(new MemMap("Boot ROM09 (cached)", 0x9FC00000, 0x9FFFFFFF));
+            maprange.Add(new MemMap("Boot ROM0b (uncached)", 0xBFC00000, 0xBFFFFFFF));
+            maprange.Add(new MemMap("Boot ROM1", 0xBE000000, 0xBE040000));
+            maprange.Add(new MemMap("Boot ROM2", 0xBE400000, 0xBE440000));
+            maprange.Add(new MemMap("IOP RAM", 0xBC000000, 0xBC1FFFFF));
+            maprange.Add(new MemMap("Scratch Pad", 0x70000000, 0x70003FFF));
+            #endregion
+            map = new DeviceMemoryMap(name, maprange);
+            return map;
+        }
+        #endregion
+        #region N64
+        private DeviceMemoryMap CreateN64MemMap()
+        {
+            const string name = "N64";
+            DeviceMemoryMap map = new DeviceMemoryMap();
+            List<IMemMap> maprange = new List<IMemMap>();
+            #region memory maps
+            maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            #endregion
+            map = new DeviceMemoryMap(name, maprange);
+            return map;
+        }
+        #endregion
+        #region NGC
+        private DeviceMemoryMap CreateNGCMemMap()
+        {
+            const string name = "NGC";
+            DeviceMemoryMap map = new DeviceMemoryMap();
+            List<IMemMap> maprange = new List<IMemMap>();
+            #region memory maps
+            maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            #endregion
+            map = new DeviceMemoryMap(name, maprange);
+            return map;
+        }
+        #endregion
+        #region WII
+        private DeviceMemoryMap CreateWIIMemMap()
+        {
+            const string name = "WII";
+            DeviceMemoryMap map = new DeviceMemoryMap();
+            List<IMemMap> maprange = new List<IMemMap>();
+            #region memory maps
+            maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            #endregion
+            map = new DeviceMemoryMap(name, maprange);
+            return map;
+        }
+        #endregion
+    }
+
+    #region Memory Map Helper Classes
+    internal interface IMemMap
+    {
+        string MapName { get; }
+        string MapStart { get; }
+        string MapEnd { get; }
+        string MapSize { get; }
+        string ToString();
+    }
+    internal interface IDeviceMemoryMap
+    {
+        string DeviceName { get; }
+        IDictionary<string, IMemMap> MemoryMap { get; }
+        string ToString();
+    }
+
+    internal class MemMap : IMemMap
+    {
+        public MemMap() : this(string.Empty, 0, 0) { }
+        public MemMap(string name)
+        {
+            this.MapName = name;
+        }
+        public MemMap(string name, ulong start, ulong end) : this(name, string.Format("0x{0}", start.ToString("X")), string.Format("0x{0}", end.ToString("X")), string.Format("0x{0}", (end - start).ToString("X"))) { }
+        public MemMap(string name, string start, string end, string size)
+            : this(name)
+        {
+            this.MapStart = start;
+            this.MapEnd = end;
+            this.MapSize = size;
+        }
+        #region IMappedMemRange Members
+        public string MapName { get; private set; }
+        public string MapStart { get; private set; }
+        public string MapEnd { get; private set; }
+        public string MapSize { get; private set; }
+        public override string ToString()
+        {
+            return string.Format("[{0}]==>[{1}-{2}] [{3}]", MapName, MapStart, MapEnd, MapSize);
+        }
+        #endregion
+    }
+
+    internal class DeviceMemoryMap : IDeviceMemoryMap
+    {
+        public DeviceMemoryMap() { this.DeviceName = string.Empty; this.MemoryMap = this.MemoryMap = new Dictionary<string, IMemMap>(); }
+        public DeviceMemoryMap(string device, List<IMemMap> memorymap)
+        {
+            this.DeviceName = device;
+            this.MemoryMap = new Dictionary<string, IMemMap>();
+
+            foreach (var map in memorymap)
+            {
+                this.MemoryMap.Add(map.MapName, map);
+            }
+
+        }
+
+        #region IDeviceMemoryMap Members
+        public string DeviceName { get; private set; }
+        public IDictionary<string, IMemMap> MemoryMap { get; private set; }
+        public override string ToString()
+        {
+            return string.Format("[{0}]==>{1} mapped memory range(s)", DeviceName, MemoryMap.Count);
+        }
+        #endregion
     }
+
+    #endregion
 }
+

 

  ViewVC Help
Powered by ViewVC 1.1.22