/[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 650 by william, Sun Jun 9 00:04:18 2013 UTC revision 684 by william, Mon Jun 17 08:52:54 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    
26  namespace RomCheater.EmuMMAPPlugin  namespace RomCheater.EmuMMAPPlugin
27  {  {
28        #region EmuMEMMapDockControl
29      public partial class EmuMEMMapDockControl : DockContent      public partial class EmuMEMMapDockControl : DockContent
30      {      {
31            private UserControlPlugin plugin;
32          private List<DeviceMemoryMap> DeviceMemoryMaps = new List<DeviceMemoryMap>();          private List<DeviceMemoryMap> DeviceMemoryMaps = new List<DeviceMemoryMap>();
33          public EmuMEMMapDockControl()          public EmuMEMMapDockControl(UserControlPlugin plugin)
34          {          {
35                this.plugin = plugin;
36                InitPluginFramework();
37              InitializeComponent();              InitializeComponent();
38              CreateMaps();              CreateMaps();
39          }          }
40            private void InitPluginFramework()
41            {
42                if (this.plugin == null) { return; }
43                this.plugin.OnSelectedProcessChanged += new PluginFramework.Events.BaseEventHandler<PluginFramework.Events.ProcessChangedEventArgs>(plugin_OnSelectedProcessChanged);
44                this.plugin.OnSelectedConfigChanged += new PluginFramework.Events.BaseEventHandler<PluginFramework.Events.ConfigChangedEventArgs>(plugin_OnSelectedConfigChanged);
45                this.plugin.OnPEDataUpdated += new PluginFramework.Events.BaseEventHandler<PluginFramework.Events.PEViewerDataUpdatedEventArgs>(plugin_OnPEDataUpdated);
46            }
47            void plugin_OnPEDataUpdated(PluginFramework.Events.PEViewerDataUpdatedEventArgs e)
48            {
49                logger.Warn.WriteLine("plugin_OnPEDataUpdated::has not been implemented!");
50            }
51            void plugin_OnSelectedConfigChanged(PluginFramework.Events.ConfigChangedEventArgs e)
52            {
53                logger.Warn.WriteLine("plugin_OnSelectedConfigChanged::has not been implemented!");
54            }
55            void plugin_OnSelectedProcessChanged(PluginFramework.Events.ProcessChangedEventArgs e)
56            {
57                logger.Warn.WriteLine("plugin_OnSelectedProcessChanged::has not been implemented!");
58            }
59          private void EmuMEMMapDockControl_Shown(object sender, EventArgs e)          private void EmuMEMMapDockControl_Shown(object sender, EventArgs e)
60          {          {
61              txtDeviceMap.Clear();              txtDeviceMap.Clear();
# Line 39  namespace RomCheater.EmuMMAPPlugin Line 77  namespace RomCheater.EmuMMAPPlugin
77          private void CreateMaps()          private void CreateMaps()
78          {          {
79              var map = new DeviceMemoryMap();              var map = new DeviceMemoryMap();
   
80              #region NES              #region NES
81              map = CreateNESMemMap();              map = CreateNESMemMap();
82              DeviceMemoryMaps.Add(map);              DeviceMemoryMaps.Add(map);
# Line 68  namespace RomCheater.EmuMMAPPlugin Line 105  namespace RomCheater.EmuMMAPPlugin
105              map = CreateWIIMemMap();              map = CreateWIIMemMap();
106              DeviceMemoryMaps.Add(map);              DeviceMemoryMaps.Add(map);
107              #endregion              #endregion
108              map = null;              map = null; // free memory
109          }          }
   
110          #region NES          #region NES
111          private DeviceMemoryMap CreateNESMemMap()          private DeviceMemoryMap CreateNESMemMap()
112          {          {
113              /* http://en.wikibooks.org/wiki/NES_Programming */              /* http://en.wikibooks.org/wiki/NES_Programming */
114              const string name = "NES";              const string name = "NES";
115              DeviceMemoryMap map = new DeviceMemoryMap();                          DeviceMemoryMap map = new DeviceMemoryMap();
116              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
117              #region memory maps              #region memory maps
118              //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 126  namespace RomCheater.EmuMMAPPlugin
126              maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror2", 0x1000, 0x17FF));              maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror2", 0x1000, 0x17FF));
127              // mirror              // mirror
128              maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror3", 0x1800, 0x1FFF));              maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror3", 0x1800, 0x1FFF));
129              
130              maprange.Add(new MemMap("IO Reg1", 0x2000, 0x2007));              maprange.Add(new MemMap("IO Reg1", 0x2000, 0x2007));
131              maprange.Add(new MemMap("IO reg1 mirror - repeated", 0x2000, 0x3FFF));              maprange.Add(new MemMap("IO reg1 mirror - repeated", 0x2000, 0x3FFF));
132              maprange.Add(new MemMap("IO Reg2", 0x4000, 0x401F));              maprange.Add(new MemMap("IO Reg2", 0x4000, 0x401F));
# Line 136  namespace RomCheater.EmuMMAPPlugin Line 172  namespace RomCheater.EmuMMAPPlugin
172              maprange.Add(new MemMap("User Memory", 0x00010000, 0x001FFFFF));              maprange.Add(new MemMap("User Memory", 0x00010000, 0x001FFFFF));
173              maprange.Add(new MemMap("Parallel Port", 0x1f000000, 0x1f00ffff));              maprange.Add(new MemMap("Parallel Port", 0x1f000000, 0x1f00ffff));
174              maprange.Add(new MemMap("Scratch Pad", 0x1f800000, 0x1f8003ff));              maprange.Add(new MemMap("Scratch Pad", 0x1f800000, 0x1f8003ff));
175              maprange.Add(new MemMap("HW Registers", 0x1f801000, 0x1f802fff));                          maprange.Add(new MemMap("HW Registers", 0x1f801000, 0x1f802fff));
176              maprange.Add(new MemMap("BIOS", 0x1FC00000, 0x1FC7FFFF));              maprange.Add(new MemMap("BIOS", 0x1FC00000, 0x1FC7FFFF));
177    
178              maprange.Add(new MemMap("Kernel & User Memory (cached)", 0x80000000, 0x801fffff));              maprange.Add(new MemMap("Kernel & User Memory (cached)", 0x80000000, 0x801fffff));
# Line 178  namespace RomCheater.EmuMMAPPlugin Line 214  namespace RomCheater.EmuMMAPPlugin
214          #region N64          #region N64
215          private DeviceMemoryMap CreateN64MemMap()          private DeviceMemoryMap CreateN64MemMap()
216          {          {
217                /* http://n64.icequake.net/doc/n64intro/kantan/step1/1-4.html */
218              const string name = "N64";              const string name = "N64";
219              DeviceMemoryMap map = new DeviceMemoryMap();              DeviceMemoryMap map = new DeviceMemoryMap();
220              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
221              #region memory maps              #region memory maps
222              maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
223                maprange.Add(new MemMap("KUSEG [TLB Map]", 0x00000000, 0x7fffffff));
224                maprange.Add(new MemMap("KSEG0 [Ram cached]", 0x80000000, 0x9fffffff));
225                maprange.Add(new MemMap("KSEG1 [Ram uncached]", 0xa0000000, 0xbfffffff));
226                maprange.Add(new MemMap("KSSEG [TLB Map]", 0xc0000000, 0xdfffffff));
227                maprange.Add(new MemMap("KSEG3 [TLB Map]", 0xe0000000, 0xffffffff));
228              #endregion              #endregion
229              map = new DeviceMemoryMap(name, maprange);              map = new DeviceMemoryMap(name, maprange);
230              return map;              return map;
# Line 191  namespace RomCheater.EmuMMAPPlugin Line 233  namespace RomCheater.EmuMMAPPlugin
233          #region NGC          #region NGC
234          private DeviceMemoryMap CreateNGCMemMap()          private DeviceMemoryMap CreateNGCMemMap()
235          {          {
236                /* http://hitmen.c02.at/files/yagcd/yagcd/chap4.html#sec4 */
237              const string name = "NGC";              const string name = "NGC";
238              DeviceMemoryMap map = new DeviceMemoryMap();              DeviceMemoryMap map = new DeviceMemoryMap();
239              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
240              #region memory maps              #region memory maps
241              maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
242                maprange.Add(new MemMap("Physical RAM", 0x00000000, 0x017fffff));
243                maprange.Add(new MemMap("Logical RAM [cached]", 0x80000000, 0x817fffff));
244                maprange.Add(new MemMap("Logical RAM [uncached]", 0xC0000000, 0xC17fffff));
245              #endregion              #endregion
246              map = new DeviceMemoryMap(name, maprange);              map = new DeviceMemoryMap(name, maprange);
247              return map;              return map;
# Line 204  namespace RomCheater.EmuMMAPPlugin Line 250  namespace RomCheater.EmuMMAPPlugin
250          #region WII          #region WII
251          private DeviceMemoryMap CreateWIIMemMap()          private DeviceMemoryMap CreateWIIMemMap()
252          {          {
253                /* http://wiibrew.org/wiki/Memory_Map */
254              const string name = "WII";              const string name = "WII";
255              DeviceMemoryMap map = new DeviceMemoryMap();              DeviceMemoryMap map = new DeviceMemoryMap();
256              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
257              #region memory maps              #region memory maps
258              maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
259                maprange.Add(new MemMap("MEM1 [cached]", 0x80000000, 0x817FFFFF));
260                maprange.Add(new MemMap("MEM1 [uncached]", 0xC0000000, 0xC17FFFFF));
261                maprange.Add(new MemMap("MEM2 [cached]", 0x90000000, 0x93FFFFFF));
262                maprange.Add(new MemMap("MEM2 [uncached]", 0xD0000000, 0xD3FFFFFF));
263                maprange.Add(new MemMap("Hollywood/Starlet Registers?", 0xCD000000, 0xCD008000));
264              #endregion              #endregion
265              map = new DeviceMemoryMap(name, maprange);              map = new DeviceMemoryMap(name, maprange);
266              return map;              return map;
267          }          }
268          #endregion          #endregion
269      }      }
270        #endregion
271    
272      #region Memory Map Helper Classes      #region Memory Map Helper Classes
273        #region IMemMap
274      internal interface IMemMap      internal interface IMemMap
275      {      {
276          string MapName { get; }          string MapName { get; }
# Line 225  namespace RomCheater.EmuMMAPPlugin Line 279  namespace RomCheater.EmuMMAPPlugin
279          string MapSize { get; }          string MapSize { get; }
280          string ToString();          string ToString();
281      }      }
282        #endregion
283        #region IDeviceMemoryMap
284      internal interface IDeviceMemoryMap      internal interface IDeviceMemoryMap
285      {      {
286          string DeviceName { get; }          string DeviceName { get; }
287          IDictionary<string, IMemMap> MemoryMap { get; }          IDictionary<string, IMemMap> MemoryMap { get; }
288          string ToString();          string ToString();
289      }      }
290        #endregion
291        #region MemMap
292      internal class MemMap : IMemMap      internal class MemMap : IMemMap
293      {      {
294          public MemMap() : this(string.Empty, 0, 0) { }          public MemMap() : this(string.Empty, 0, 0) { }
295          public MemMap(string name)          public MemMap(string name) { this.MapName = name; }
296          {          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) { }  
297          public MemMap(string name, string start, string end, ulong size)          public MemMap(string name, string start, string end, ulong size)
298              : this(name)              : this(name)
299          {          {
300              this.MapStart = start;              this.MapStart = start;
301              this.MapEnd = end;              this.MapEnd = end;
   
302              ulong _size = size + 1;              ulong _size = size + 1;
303              double t = 1024.0 * 1024.0;              double t = 1024.0 * 1024.0;
304              double __size = (double)_size/t;              double __size = (double)_size / t;
305              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);
306          }          }
307          #region IMappedMemRange Members          #region IMappedMemRange Members
# Line 256  namespace RomCheater.EmuMMAPPlugin Line 309  namespace RomCheater.EmuMMAPPlugin
309          public string MapStart { get; private set; }          public string MapStart { get; private set; }
310          public string MapEnd { get; private set; }          public string MapEnd { get; private set; }
311          public string MapSize { get; private set; }          public string MapSize { get; private set; }
312          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);  
         }  
313          #endregion          #endregion
314      }      }
315        #endregion
316        #region DeviceMemoryMap
317      internal class DeviceMemoryMap : IDeviceMemoryMap      internal class DeviceMemoryMap : IDeviceMemoryMap
318      {      {
319          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 270  namespace RomCheater.EmuMMAPPlugin Line 321  namespace RomCheater.EmuMMAPPlugin
321          {          {
322              this.DeviceName = device;              this.DeviceName = device;
323              this.MemoryMap = new Dictionary<string, IMemMap>();              this.MemoryMap = new Dictionary<string, IMemMap>();
324                foreach (var map in memorymap) { this.MemoryMap.Add(map.MapName, map); }
             foreach (var map in memorymap)  
             {  
                 this.MemoryMap.Add(map.MapName, map);  
             }  
   
325          }          }
   
326          #region IDeviceMemoryMap Members          #region IDeviceMemoryMap Members
327          public string DeviceName { get; private set; }          public string DeviceName { get; private set; }
328          public IDictionary<string, IMemMap> MemoryMap { get; private set; }          public IDictionary<string, IMemMap> MemoryMap { get; private set; }
329          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);  
         }  
330          #endregion          #endregion
331      }      }
332        #endregion
333      #endregion      #endregion
334  }  }
   

Legend:
Removed from v.650  
changed lines
  Added in v.684

  ViewVC Help
Powered by ViewVC 1.1.22