/[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/09 00:26:42	651
+++ trunk/RomCheater.EmuMMAPPlugin/EmuMEMMapDockControl.cs	2013/06/17 09:31:52	686
@@ -1,4 +1,17 @@
-´╗┐using System;
+´╗┐#region Logging Defines
+// include this any class or method that required logging, and comment-out what is not needed
+
+#region Enabled logging levels
+#define LOGGING_ENABLE_INFO
+#define LOGGING_ENABLE_WARN
+#define LOGGING_ENABLE_DEBUG
+//#define LOGGING_ENABLE_VERBOSEDEBUG
+#define LOGGING_ENABLE_ERROR
+#define LOGGING_ENABLE_VERBOSEERROR
+#define LOGGING_ENABLE_PROFILER
+#endregion
+#endregion
+using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
@@ -7,17 +20,43 @@
 using System.Text;
 using System.Windows.Forms;
 using WeifenLuo.WinFormsUI.Docking;
+using RomCheater.PluginFramework.Core;
+using RomCheater.Logging;
+using RomCheater.Core;
 
 namespace RomCheater.EmuMMAPPlugin
 {
+    #region EmuMEMMapDockControl
     public partial class EmuMEMMapDockControl : DockContent
     {
+        private UserControlPlugin plugin;
         private List<DeviceMemoryMap> DeviceMemoryMaps = new List<DeviceMemoryMap>();
-        public EmuMEMMapDockControl()
+        public EmuMEMMapDockControl(UserControlPlugin plugin)
         {
+            this.plugin = plugin;
+            InitPluginFramework();
             InitializeComponent();
             CreateMaps();
         }
+        private void InitPluginFramework()
+        {
+            if (this.plugin == null) { return; }
+            this.plugin.OnSelectedProcessChanged += new BaseEventHandler<ProcessChangedEventArgs>(plugin_OnSelectedProcessChanged);
+            this.plugin.OnSelectedConfigChanged += new BaseEventHandler<ConfigChangedEventArgs>(plugin_OnSelectedConfigChanged);
+            this.plugin.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(plugin_OnPEDataUpdated);
+        }
+        void plugin_OnPEDataUpdated(PEViewerDataUpdatedEventArgs e)
+        {
+            logger.Warn.WriteLine("plugin_OnPEDataUpdated::has not been implemented!");
+        }
+        void plugin_OnSelectedConfigChanged(ConfigChangedEventArgs e)
+        {
+            logger.Warn.WriteLine("plugin_OnSelectedConfigChanged::has not been implemented!");
+        }
+        void plugin_OnSelectedProcessChanged(ProcessChangedEventArgs e)
+        {
+            logger.Warn.WriteLine("plugin_OnSelectedProcessChanged::has not been implemented!");
+        }
         private void EmuMEMMapDockControl_Shown(object sender, EventArgs e)
         {
             txtDeviceMap.Clear();
@@ -39,7 +78,6 @@
         private void CreateMaps()
         {
             var map = new DeviceMemoryMap();
-
             #region NES
             map = CreateNESMemMap();
             DeviceMemoryMaps.Add(map);
@@ -68,15 +106,14 @@
             map = CreateWIIMemMap();
             DeviceMemoryMaps.Add(map);
             #endregion
-            map = null;
+            map = null; // free memory
         }
-
         #region NES
         private DeviceMemoryMap CreateNESMemMap()
         {
             /* http://en.wikibooks.org/wiki/NES_Programming */
             const string name = "NES";
-            DeviceMemoryMap map = new DeviceMemoryMap();            
+            DeviceMemoryMap map = new DeviceMemoryMap();
             List<IMemMap> maprange = new List<IMemMap>();
             #region memory maps
             //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
@@ -90,7 +127,7 @@
             maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror2", 0x1000, 0x17FF));
             // mirror
             maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror3", 0x1800, 0x1FFF));
-          
+
             maprange.Add(new MemMap("IO Reg1", 0x2000, 0x2007));
             maprange.Add(new MemMap("IO reg1 mirror - repeated", 0x2000, 0x3FFF));
             maprange.Add(new MemMap("IO Reg2", 0x4000, 0x401F));
@@ -136,7 +173,7 @@
             maprange.Add(new MemMap("User Memory", 0x00010000, 0x001FFFFF));
             maprange.Add(new MemMap("Parallel Port", 0x1f000000, 0x1f00ffff));
             maprange.Add(new MemMap("Scratch Pad", 0x1f800000, 0x1f8003ff));
-            maprange.Add(new MemMap("HW Registers", 0x1f801000, 0x1f802fff));            
+            maprange.Add(new MemMap("HW Registers", 0x1f801000, 0x1f802fff));
             maprange.Add(new MemMap("BIOS", 0x1FC00000, 0x1FC7FFFF));
 
             maprange.Add(new MemMap("Kernel & User Memory (cached)", 0x80000000, 0x801fffff));
@@ -197,11 +234,15 @@
         #region NGC
         private DeviceMemoryMap CreateNGCMemMap()
         {
+            /* http://hitmen.c02.at/files/yagcd/yagcd/chap4.html#sec4 */
             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));
+            //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            maprange.Add(new MemMap("Physical RAM", 0x00000000, 0x017fffff));
+            maprange.Add(new MemMap("Logical RAM [cached]", 0x80000000, 0x817fffff));
+            maprange.Add(new MemMap("Logical RAM [uncached]", 0xC0000000, 0xC17fffff));
             #endregion
             map = new DeviceMemoryMap(name, maprange);
             return map;
@@ -210,19 +251,27 @@
         #region WII
         private DeviceMemoryMap CreateWIIMemMap()
         {
+            /* http://wiibrew.org/wiki/Memory_Map */
             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));
+            //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            maprange.Add(new MemMap("MEM1 [cached]", 0x80000000, 0x817FFFFF));
+            maprange.Add(new MemMap("MEM1 [uncached]", 0xC0000000, 0xC17FFFFF));
+            maprange.Add(new MemMap("MEM2 [cached]", 0x90000000, 0x93FFFFFF));
+            maprange.Add(new MemMap("MEM2 [uncached]", 0xD0000000, 0xD3FFFFFF));
+            maprange.Add(new MemMap("Hollywood/Starlet Registers?", 0xCD000000, 0xCD008000));
             #endregion
             map = new DeviceMemoryMap(name, maprange);
             return map;
         }
         #endregion
     }
+    #endregion
 
     #region Memory Map Helper Classes
+    #region IMemMap
     internal interface IMemMap
     {
         string MapName { get; }
@@ -231,30 +280,29 @@
         string MapSize { get; }
         string ToString();
     }
+    #endregion
+    #region IDeviceMemoryMap
     internal interface IDeviceMemoryMap
     {
         string DeviceName { get; }
         IDictionary<string, IMemMap> MemoryMap { get; }
         string ToString();
     }
-
+    #endregion
+    #region MemMap
     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")), end-start) { }
+        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")), end - start) { }
         public MemMap(string name, string start, string end, ulong size)
             : this(name)
         {
             this.MapStart = start;
             this.MapEnd = end;
-
             ulong _size = size + 1;
             double t = 1024.0 * 1024.0;
-            double __size = (double)_size/t;
+            double __size = (double)_size / t;
             this.MapSize = string.Format("0x{0}={1:0.000000}MB", _size.ToString("X"), __size);
         }
         #region IMappedMemRange Members
@@ -262,13 +310,11 @@
         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);
-        }
+        public override string ToString() { return string.Format("[{0}]==>[{1}-{2}] [{3}]", MapName, MapStart, MapEnd, MapSize); }
         #endregion
     }
-
+    #endregion
+    #region DeviceMemoryMap
     internal class DeviceMemoryMap : IDeviceMemoryMap
     {
         public DeviceMemoryMap() { this.DeviceName = string.Empty; this.MemoryMap = this.MemoryMap = new Dictionary<string, IMemMap>(); }
@@ -276,24 +322,14 @@
         {
             this.DeviceName = device;
             this.MemoryMap = new Dictionary<string, IMemMap>();
-
-            foreach (var map in memorymap)
-            {
-                this.MemoryMap.Add(map.MapName, map);
-            }
-
+            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);
-        }
+        public override string ToString() { return string.Format("[{0}]==>{1} mapped memory range(s)", DeviceName, MemoryMap.Count); }
         #endregion
     }
-
+    #endregion
     #endregion
 }
-

 

  ViewVC Help
Powered by ViewVC 1.1.22