/[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

revision 653 by william, Sun Jun 9 00:34:29 2013 UTC revision 686 by william, Mon Jun 17 09:31:52 2013 UTC
# Line 1  Line 1 
1  ´╗┐using System;  ´╗┐#region Logging Defines
2    // include this any class or method that required logging, and comment-out what is not needed
3    
4    #region Enabled logging levels
5    #define LOGGING_ENABLE_INFO
6    #define LOGGING_ENABLE_WARN
7    #define LOGGING_ENABLE_DEBUG
8    //#define LOGGING_ENABLE_VERBOSEDEBUG
9    #define LOGGING_ENABLE_ERROR
10    #define LOGGING_ENABLE_VERBOSEERROR
11    #define LOGGING_ENABLE_PROFILER
12    #endregion
13    #endregion
14    using System;
15  using System.Collections.Generic;  using System.Collections.Generic;
16  using System.ComponentModel;  using System.ComponentModel;
17  using System.Data;  using System.Data;
# Line 7  using System.Linq; Line 20  using System.Linq;
20  using System.Text;  using System.Text;
21  using System.Windows.Forms;  using System.Windows.Forms;
22  using WeifenLuo.WinFormsUI.Docking;  using WeifenLuo.WinFormsUI.Docking;
23    using RomCheater.PluginFramework.Core;
24    using RomCheater.Logging;
25    using RomCheater.Core;
26    
27  namespace RomCheater.EmuMMAPPlugin  namespace RomCheater.EmuMMAPPlugin
28  {  {
29        #region EmuMEMMapDockControl
30      public partial class EmuMEMMapDockControl : DockContent      public partial class EmuMEMMapDockControl : DockContent
31      {      {
32            private UserControlPlugin plugin;
33          private List<DeviceMemoryMap> DeviceMemoryMaps = new List<DeviceMemoryMap>();          private List<DeviceMemoryMap> DeviceMemoryMaps = new List<DeviceMemoryMap>();
34          public EmuMEMMapDockControl()          public EmuMEMMapDockControl(UserControlPlugin plugin)
35          {          {
36                this.plugin = plugin;
37                InitPluginFramework();
38              InitializeComponent();              InitializeComponent();
39              CreateMaps();              CreateMaps();
40          }          }
41            private void InitPluginFramework()
42            {
43                if (this.plugin == null) { return; }
44                this.plugin.OnSelectedProcessChanged += new BaseEventHandler<ProcessChangedEventArgs>(plugin_OnSelectedProcessChanged);
45                this.plugin.OnSelectedConfigChanged += new BaseEventHandler<ConfigChangedEventArgs>(plugin_OnSelectedConfigChanged);
46                this.plugin.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(plugin_OnPEDataUpdated);
47            }
48            void plugin_OnPEDataUpdated(PEViewerDataUpdatedEventArgs e)
49            {
50                logger.Warn.WriteLine("plugin_OnPEDataUpdated::has not been implemented!");
51            }
52            void plugin_OnSelectedConfigChanged(ConfigChangedEventArgs e)
53            {
54                logger.Warn.WriteLine("plugin_OnSelectedConfigChanged::has not been implemented!");
55            }
56            void plugin_OnSelectedProcessChanged(ProcessChangedEventArgs e)
57            {
58                logger.Warn.WriteLine("plugin_OnSelectedProcessChanged::has not been implemented!");
59            }
60          private void EmuMEMMapDockControl_Shown(object sender, EventArgs e)          private void EmuMEMMapDockControl_Shown(object sender, EventArgs e)
61          {          {
62              txtDeviceMap.Clear();              txtDeviceMap.Clear();
# Line 39  namespace RomCheater.EmuMMAPPlugin Line 78  namespace RomCheater.EmuMMAPPlugin
78          private void CreateMaps()          private void CreateMaps()
79          {          {
80              var map = new DeviceMemoryMap();              var map = new DeviceMemoryMap();
   
81              #region NES              #region NES
82              map = CreateNESMemMap();              map = CreateNESMemMap();
83              DeviceMemoryMaps.Add(map);              DeviceMemoryMaps.Add(map);
# Line 68  namespace RomCheater.EmuMMAPPlugin Line 106  namespace RomCheater.EmuMMAPPlugin
106              map = CreateWIIMemMap();              map = CreateWIIMemMap();
107              DeviceMemoryMaps.Add(map);              DeviceMemoryMaps.Add(map);
108              #endregion              #endregion
109              map = null;              map = null; // free memory
110          }          }
   
111          #region NES          #region NES
112          private DeviceMemoryMap CreateNESMemMap()          private DeviceMemoryMap CreateNESMemMap()
113          {          {
114              /* http://en.wikibooks.org/wiki/NES_Programming */              /* http://en.wikibooks.org/wiki/NES_Programming */
115              const string name = "NES";              const string name = "NES";
116              DeviceMemoryMap map = new DeviceMemoryMap();                          DeviceMemoryMap map = new DeviceMemoryMap();
117              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
118              #region memory maps              #region memory maps
119              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
# Line 90  namespace RomCheater.EmuMMAPPlugin Line 127  namespace RomCheater.EmuMMAPPlugin
127              maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror2", 0x1000, 0x17FF));              maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror2", 0x1000, 0x17FF));
128              // mirror              // mirror
129              maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror3", 0x1800, 0x1FFF));              maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror3", 0x1800, 0x1FFF));
130              
131              maprange.Add(new MemMap("IO Reg1", 0x2000, 0x2007));              maprange.Add(new MemMap("IO Reg1", 0x2000, 0x2007));
132              maprange.Add(new MemMap("IO reg1 mirror - repeated", 0x2000, 0x3FFF));              maprange.Add(new MemMap("IO reg1 mirror - repeated", 0x2000, 0x3FFF));
133              maprange.Add(new MemMap("IO Reg2", 0x4000, 0x401F));              maprange.Add(new MemMap("IO Reg2", 0x4000, 0x401F));
# Line 136  namespace RomCheater.EmuMMAPPlugin Line 173  namespace RomCheater.EmuMMAPPlugin
173              maprange.Add(new MemMap("User Memory", 0x00010000, 0x001FFFFF));              maprange.Add(new MemMap("User Memory", 0x00010000, 0x001FFFFF));
174              maprange.Add(new MemMap("Parallel Port", 0x1f000000, 0x1f00ffff));              maprange.Add(new MemMap("Parallel Port", 0x1f000000, 0x1f00ffff));
175              maprange.Add(new MemMap("Scratch Pad", 0x1f800000, 0x1f8003ff));              maprange.Add(new MemMap("Scratch Pad", 0x1f800000, 0x1f8003ff));
176              maprange.Add(new MemMap("HW Registers", 0x1f801000, 0x1f802fff));                          maprange.Add(new MemMap("HW Registers", 0x1f801000, 0x1f802fff));
177              maprange.Add(new MemMap("BIOS", 0x1FC00000, 0x1FC7FFFF));              maprange.Add(new MemMap("BIOS", 0x1FC00000, 0x1FC7FFFF));
178    
179              maprange.Add(new MemMap("Kernel & User Memory (cached)", 0x80000000, 0x801fffff));              maprange.Add(new MemMap("Kernel & User Memory (cached)", 0x80000000, 0x801fffff));
# Line 231  namespace RomCheater.EmuMMAPPlugin Line 268  namespace RomCheater.EmuMMAPPlugin
268          }          }
269          #endregion          #endregion
270      }      }
271        #endregion
272    
273      #region Memory Map Helper Classes      #region Memory Map Helper Classes
274        #region IMemMap
275      internal interface IMemMap      internal interface IMemMap
276      {      {
277          string MapName { get; }          string MapName { get; }
# Line 241  namespace RomCheater.EmuMMAPPlugin Line 280  namespace RomCheater.EmuMMAPPlugin
280          string MapSize { get; }          string MapSize { get; }
281          string ToString();          string ToString();
282      }      }
283        #endregion
284        #region IDeviceMemoryMap
285      internal interface IDeviceMemoryMap      internal interface IDeviceMemoryMap
286      {      {
287          string DeviceName { get; }          string DeviceName { get; }
288          IDictionary<string, IMemMap> MemoryMap { get; }          IDictionary<string, IMemMap> MemoryMap { get; }
289          string ToString();          string ToString();
290      }      }
291        #endregion
292        #region MemMap
293      internal class MemMap : IMemMap      internal class MemMap : IMemMap
294      {      {
295          public MemMap() : this(string.Empty, 0, 0) { }          public MemMap() : this(string.Empty, 0, 0) { }
296          public MemMap(string name)          public MemMap(string name) { this.MapName = name; }
297          {          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) { }
             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) { }  
298          public MemMap(string name, string start, string end, ulong size)          public MemMap(string name, string start, string end, ulong size)
299              : this(name)              : this(name)
300          {          {
301              this.MapStart = start;              this.MapStart = start;
302              this.MapEnd = end;              this.MapEnd = end;
   
303              ulong _size = size + 1;              ulong _size = size + 1;
304              double t = 1024.0 * 1024.0;              double t = 1024.0 * 1024.0;
305              double __size = (double)_size/t;              double __size = (double)_size / t;
306              this.MapSize = string.Format("0x{0}={1:0.000000}MB", _size.ToString("X"), __size);              this.MapSize = string.Format("0x{0}={1:0.000000}MB", _size.ToString("X"), __size);
307          }          }
308          #region IMappedMemRange Members          #region IMappedMemRange Members
# Line 272  namespace RomCheater.EmuMMAPPlugin Line 310  namespace RomCheater.EmuMMAPPlugin
310          public string MapStart { get; private set; }          public string MapStart { get; private set; }
311          public string MapEnd { get; private set; }          public string MapEnd { get; private set; }
312          public string MapSize { get; private set; }          public string MapSize { get; private set; }
313          public override string ToString()          public override string ToString() { return string.Format("[{0}]==>[{1}-{2}] [{3}]", MapName, MapStart, MapEnd, MapSize); }
         {  
             return string.Format("[{0}]==>[{1}-{2}] [{3}]", MapName, MapStart, MapEnd, MapSize);  
         }  
314          #endregion          #endregion
315      }      }
316        #endregion
317        #region DeviceMemoryMap
318      internal class DeviceMemoryMap : IDeviceMemoryMap      internal class DeviceMemoryMap : IDeviceMemoryMap
319      {      {
320          public DeviceMemoryMap() { this.DeviceName = string.Empty; this.MemoryMap = this.MemoryMap = new Dictionary<string, IMemMap>(); }          public DeviceMemoryMap() { this.DeviceName = string.Empty; this.MemoryMap = this.MemoryMap = new Dictionary<string, IMemMap>(); }
# Line 286  namespace RomCheater.EmuMMAPPlugin Line 322  namespace RomCheater.EmuMMAPPlugin
322          {          {
323              this.DeviceName = device;              this.DeviceName = device;
324              this.MemoryMap = new Dictionary<string, IMemMap>();              this.MemoryMap = new Dictionary<string, IMemMap>();
325                foreach (var map in memorymap) { this.MemoryMap.Add(map.MapName, map); }
             foreach (var map in memorymap)  
             {  
                 this.MemoryMap.Add(map.MapName, map);  
             }  
   
326          }          }
   
327          #region IDeviceMemoryMap Members          #region IDeviceMemoryMap Members
328          public string DeviceName { get; private set; }          public string DeviceName { get; private set; }
329          public IDictionary<string, IMemMap> MemoryMap { get; private set; }          public IDictionary<string, IMemMap> MemoryMap { get; private set; }
330          public override string ToString()          public override string ToString() { return string.Format("[{0}]==>{1} mapped memory range(s)", DeviceName, MemoryMap.Count); }
         {  
             return string.Format("[{0}]==>{1} mapped memory range(s)", DeviceName, MemoryMap.Count);  
         }  
331          #endregion          #endregion
332      }      }
333        #endregion
334      #endregion      #endregion
335  }  }
   

Legend:
Removed from v.653  
changed lines
  Added in v.686

  ViewVC Help
Powered by ViewVC 1.1.22