/[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 649 by william, Sat Jun 8 22:45:25 2013 UTC revision 683 by william, Mon Jun 17 08:33:06 2013 UTC
# Line 7  using System.Linq; Line 7  using System.Linq;
7  using System.Text;  using System.Text;
8  using System.Windows.Forms;  using System.Windows.Forms;
9  using WeifenLuo.WinFormsUI.Docking;  using WeifenLuo.WinFormsUI.Docking;
10    using RomCheater.PluginFramework.Core;
11    
12  namespace RomCheater.EmuMMAPPlugin  namespace RomCheater.EmuMMAPPlugin
13  {  {
14        #region EmuMEMMapDockControl
15      public partial class EmuMEMMapDockControl : DockContent      public partial class EmuMEMMapDockControl : DockContent
16      {      {
17            private UserControlPlugin plugin;
18          private List<DeviceMemoryMap> DeviceMemoryMaps = new List<DeviceMemoryMap>();          private List<DeviceMemoryMap> DeviceMemoryMaps = new List<DeviceMemoryMap>();
19          public EmuMEMMapDockControl()          public EmuMEMMapDockControl(UserControlPlugin plugin)
20          {          {
21                this.plugin = plugin;
22              InitializeComponent();              InitializeComponent();
23              CreateMaps();              CreateMaps();
24          }          }
# Line 39  namespace RomCheater.EmuMMAPPlugin Line 43  namespace RomCheater.EmuMMAPPlugin
43          private void CreateMaps()          private void CreateMaps()
44          {          {
45              var map = new DeviceMemoryMap();              var map = new DeviceMemoryMap();
   
46              #region NES              #region NES
47              map = CreateNESMemMap();              map = CreateNESMemMap();
48              DeviceMemoryMaps.Add(map);              DeviceMemoryMaps.Add(map);
# Line 68  namespace RomCheater.EmuMMAPPlugin Line 71  namespace RomCheater.EmuMMAPPlugin
71              map = CreateWIIMemMap();              map = CreateWIIMemMap();
72              DeviceMemoryMaps.Add(map);              DeviceMemoryMaps.Add(map);
73              #endregion              #endregion
74              map = null;              map = null; // free memory
75          }          }
   
76          #region NES          #region NES
77          private DeviceMemoryMap CreateNESMemMap()          private DeviceMemoryMap CreateNESMemMap()
78          {          {
79                /* http://en.wikibooks.org/wiki/NES_Programming */
80              const string name = "NES";              const string name = "NES";
81              DeviceMemoryMap map = new DeviceMemoryMap();                          DeviceMemoryMap map = new DeviceMemoryMap();
82              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
83              #region memory maps              #region memory maps
84              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
# Line 89  namespace RomCheater.EmuMMAPPlugin Line 92  namespace RomCheater.EmuMMAPPlugin
92              maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror2", 0x1000, 0x17FF));              maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror2", 0x1000, 0x17FF));
93              // mirror              // mirror
94              maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror3", 0x1800, 0x1FFF));              maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror3", 0x1800, 0x1FFF));
95              
96              maprange.Add(new MemMap("IO Reg1", 0x2000, 0x2007));              maprange.Add(new MemMap("IO Reg1", 0x2000, 0x2007));
97              maprange.Add(new MemMap("IO reg1 mirror - repeated", 0x2000, 0x3FFF));              maprange.Add(new MemMap("IO reg1 mirror - repeated", 0x2000, 0x3FFF));
98              maprange.Add(new MemMap("IO Reg2", 0x4000, 0x401F));              maprange.Add(new MemMap("IO Reg2", 0x4000, 0x401F));
# Line 108  namespace RomCheater.EmuMMAPPlugin Line 111  namespace RomCheater.EmuMMAPPlugin
111          #region SNES          #region SNES
112          private DeviceMemoryMap CreateSNESMemMap()          private DeviceMemoryMap CreateSNESMemMap()
113          {          {
114                /* http://www.emulatronia.com/doctec/consolas/snes/SNESMem.txt */
115              const string name = "SNES";              const string name = "SNES";
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));
120                maprange.Add(new MemMap("LowRAM", 0x0000, 0x1fff));
121                maprange.Add(new MemMap("HighRAM", 0x2000, 0x7fff));
122                maprange.Add(new MemMap("Expanded RAM", 0x8000, 0xffff));
123              #endregion              #endregion
124              map = new DeviceMemoryMap(name, maprange);              map = new DeviceMemoryMap(name, maprange);
125              return map;              return map;
# Line 121  namespace RomCheater.EmuMMAPPlugin Line 128  namespace RomCheater.EmuMMAPPlugin
128          #region PS1          #region PS1
129          private DeviceMemoryMap CreatePS1MemMap()          private DeviceMemoryMap CreatePS1MemMap()
130          {          {
131                /* http://rveach.romhack.org/PSXInfo/psx%20hardware%20info.txt */
132              const string name = "PS1";              const string name = "PS1";
133              DeviceMemoryMap map = new DeviceMemoryMap();              DeviceMemoryMap map = new DeviceMemoryMap();
134              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
# Line 131  namespace RomCheater.EmuMMAPPlugin Line 139  namespace RomCheater.EmuMMAPPlugin
139              maprange.Add(new MemMap("Parallel Port", 0x1f000000, 0x1f00ffff));              maprange.Add(new MemMap("Parallel Port", 0x1f000000, 0x1f00ffff));
140              maprange.Add(new MemMap("Scratch Pad", 0x1f800000, 0x1f8003ff));              maprange.Add(new MemMap("Scratch Pad", 0x1f800000, 0x1f8003ff));
141              maprange.Add(new MemMap("HW Registers", 0x1f801000, 0x1f802fff));              maprange.Add(new MemMap("HW Registers", 0x1f801000, 0x1f802fff));
142                maprange.Add(new MemMap("BIOS", 0x1FC00000, 0x1FC7FFFF));
143    
144              maprange.Add(new MemMap("Kernel & User Memory (cached)", 0x80000000, 0x801fffff));              maprange.Add(new MemMap("Kernel & User Memory (cached)", 0x80000000, 0x801fffff));
145              maprange.Add(new MemMap("Kernel & User Memory (uncached)", 0xa0000000, 0xa01fffff));              maprange.Add(new MemMap("Kernel & User Memory (uncached)", 0xa0000000, 0xa01fffff));
146              maprange.Add(new MemMap("BIOS", 0x1FC00000, 0x1FC7FFFF));  
147              #endregion              #endregion
148              map = new DeviceMemoryMap(name, maprange);              map = new DeviceMemoryMap(name, maprange);
149              return map;              return map;
# Line 142  namespace RomCheater.EmuMMAPPlugin Line 152  namespace RomCheater.EmuMMAPPlugin
152          #region PS2          #region PS2
153          private DeviceMemoryMap CreatePS2MemMap()          private DeviceMemoryMap CreatePS2MemMap()
154          {          {
155                /* http://psx-scene.com/forums/attachments/f19/17285d1280158606-ps2-memory-hardware-mapped-registers-layout-ps2-memory-hardware-mapped-registers-layout.txt */
156                /* http://psx-scene.com/forums/f19/ps2-memory-hardware-mapped-registers-layout-64760/ */
157              const string name = "PS2";              const string name = "PS2";
158              DeviceMemoryMap map = new DeviceMemoryMap();              DeviceMemoryMap map = new DeviceMemoryMap();
159              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
# Line 168  namespace RomCheater.EmuMMAPPlugin Line 180  namespace RomCheater.EmuMMAPPlugin
180          #region N64          #region N64
181          private DeviceMemoryMap CreateN64MemMap()          private DeviceMemoryMap CreateN64MemMap()
182          {          {
183                /* http://n64.icequake.net/doc/n64intro/kantan/step1/1-4.html */
184              const string name = "N64";              const string name = "N64";
185              DeviceMemoryMap map = new DeviceMemoryMap();              DeviceMemoryMap map = new DeviceMemoryMap();
186              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
187              #region memory maps              #region memory maps
188              maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
189                maprange.Add(new MemMap("KUSEG [TLB Map]", 0x00000000, 0x7fffffff));
190                maprange.Add(new MemMap("KSEG0 [Ram cached]", 0x80000000, 0x9fffffff));
191                maprange.Add(new MemMap("KSEG1 [Ram uncached]", 0xa0000000, 0xbfffffff));
192                maprange.Add(new MemMap("KSSEG [TLB Map]", 0xc0000000, 0xdfffffff));
193                maprange.Add(new MemMap("KSEG3 [TLB Map]", 0xe0000000, 0xffffffff));
194              #endregion              #endregion
195              map = new DeviceMemoryMap(name, maprange);              map = new DeviceMemoryMap(name, maprange);
196              return map;              return map;
# Line 181  namespace RomCheater.EmuMMAPPlugin Line 199  namespace RomCheater.EmuMMAPPlugin
199          #region NGC          #region NGC
200          private DeviceMemoryMap CreateNGCMemMap()          private DeviceMemoryMap CreateNGCMemMap()
201          {          {
202                /* http://hitmen.c02.at/files/yagcd/yagcd/chap4.html#sec4 */
203              const string name = "NGC";              const string name = "NGC";
204              DeviceMemoryMap map = new DeviceMemoryMap();              DeviceMemoryMap map = new DeviceMemoryMap();
205              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
206              #region memory maps              #region memory maps
207              maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
208                maprange.Add(new MemMap("Physical RAM", 0x00000000, 0x017fffff));
209                maprange.Add(new MemMap("Logical RAM [cached]", 0x80000000, 0x817fffff));
210                maprange.Add(new MemMap("Logical RAM [uncached]", 0xC0000000, 0xC17fffff));
211              #endregion              #endregion
212              map = new DeviceMemoryMap(name, maprange);              map = new DeviceMemoryMap(name, maprange);
213              return map;              return map;
# Line 194  namespace RomCheater.EmuMMAPPlugin Line 216  namespace RomCheater.EmuMMAPPlugin
216          #region WII          #region WII
217          private DeviceMemoryMap CreateWIIMemMap()          private DeviceMemoryMap CreateWIIMemMap()
218          {          {
219                /* http://wiibrew.org/wiki/Memory_Map */
220              const string name = "WII";              const string name = "WII";
221              DeviceMemoryMap map = new DeviceMemoryMap();              DeviceMemoryMap map = new DeviceMemoryMap();
222              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
223              #region memory maps              #region memory maps
224              maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
225                maprange.Add(new MemMap("MEM1 [cached]", 0x80000000, 0x817FFFFF));
226                maprange.Add(new MemMap("MEM1 [uncached]", 0xC0000000, 0xC17FFFFF));
227                maprange.Add(new MemMap("MEM2 [cached]", 0x90000000, 0x93FFFFFF));
228                maprange.Add(new MemMap("MEM2 [uncached]", 0xD0000000, 0xD3FFFFFF));
229                maprange.Add(new MemMap("Hollywood/Starlet Registers?", 0xCD000000, 0xCD008000));
230              #endregion              #endregion
231              map = new DeviceMemoryMap(name, maprange);              map = new DeviceMemoryMap(name, maprange);
232              return map;              return map;
233          }          }
234          #endregion          #endregion
235      }      }
236        #endregion
237    
238      #region Memory Map Helper Classes      #region Memory Map Helper Classes
239        #region IMemMap
240      internal interface IMemMap      internal interface IMemMap
241      {      {
242          string MapName { get; }          string MapName { get; }
# Line 215  namespace RomCheater.EmuMMAPPlugin Line 245  namespace RomCheater.EmuMMAPPlugin
245          string MapSize { get; }          string MapSize { get; }
246          string ToString();          string ToString();
247      }      }
248        #endregion
249        #region IDeviceMemoryMap
250      internal interface IDeviceMemoryMap      internal interface IDeviceMemoryMap
251      {      {
252          string DeviceName { get; }          string DeviceName { get; }
253          IDictionary<string, IMemMap> MemoryMap { get; }          IDictionary<string, IMemMap> MemoryMap { get; }
254          string ToString();          string ToString();
255      }      }
256        #endregion
257        #region MemMap
258      internal class MemMap : IMemMap      internal class MemMap : IMemMap
259      {      {
260          public MemMap() : this(string.Empty, 0, 0) { }          public MemMap() : this(string.Empty, 0, 0) { }
261          public MemMap(string name)          public MemMap(string name) { this.MapName = name; }
262          {          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) { }  
263          public MemMap(string name, string start, string end, ulong size)          public MemMap(string name, string start, string end, ulong size)
264              : this(name)              : this(name)
265          {          {
266              this.MapStart = start;              this.MapStart = start;
267              this.MapEnd = end;              this.MapEnd = end;
   
268              ulong _size = size + 1;              ulong _size = size + 1;
269              double t = 1024.0 * 1024.0;              double t = 1024.0 * 1024.0;
270              double __size = (double)_size/t;              double __size = (double)_size / t;
271              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);
272          }          }
273          #region IMappedMemRange Members          #region IMappedMemRange Members
# Line 246  namespace RomCheater.EmuMMAPPlugin Line 275  namespace RomCheater.EmuMMAPPlugin
275          public string MapStart { get; private set; }          public string MapStart { get; private set; }
276          public string MapEnd { get; private set; }          public string MapEnd { get; private set; }
277          public string MapSize { get; private set; }          public string MapSize { get; private set; }
278          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);  
         }  
279          #endregion          #endregion
280      }      }
281        #endregion
282        #region DeviceMemoryMap
283      internal class DeviceMemoryMap : IDeviceMemoryMap      internal class DeviceMemoryMap : IDeviceMemoryMap
284      {      {
285          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 260  namespace RomCheater.EmuMMAPPlugin Line 287  namespace RomCheater.EmuMMAPPlugin
287          {          {
288              this.DeviceName = device;              this.DeviceName = device;
289              this.MemoryMap = new Dictionary<string, IMemMap>();              this.MemoryMap = new Dictionary<string, IMemMap>();
290                foreach (var map in memorymap) { this.MemoryMap.Add(map.MapName, map); }
             foreach (var map in memorymap)  
             {  
                 this.MemoryMap.Add(map.MapName, map);  
             }  
   
291          }          }
   
292          #region IDeviceMemoryMap Members          #region IDeviceMemoryMap Members
293          public string DeviceName { get; private set; }          public string DeviceName { get; private set; }
294          public IDictionary<string, IMemMap> MemoryMap { get; private set; }          public IDictionary<string, IMemMap> MemoryMap { get; private set; }
295          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);  
         }  
296          #endregion          #endregion
297      }      }
298        #endregion
299      #endregion      #endregion
300  }  }
   

Legend:
Removed from v.649  
changed lines
  Added in v.683

  ViewVC Help
Powered by ViewVC 1.1.22