/[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 647 by william, Sat Jun 8 22:25:19 2013 UTC revision 654 by william, Sun Jun 9 00:40:20 2013 UTC
# Line 10  using WeifenLuo.WinFormsUI.Docking; Line 10  using WeifenLuo.WinFormsUI.Docking;
10    
11  namespace RomCheater.EmuMMAPPlugin  namespace RomCheater.EmuMMAPPlugin
12  {  {
13        #region EmuMEMMapDockControl
14      public partial class EmuMEMMapDockControl : DockContent      public partial class EmuMEMMapDockControl : DockContent
15      {      {
16          private List<DeviceMemoryMap> DeviceMemoryMaps = new List<DeviceMemoryMap>();          private List<DeviceMemoryMap> DeviceMemoryMaps = new List<DeviceMemoryMap>();
# Line 39  namespace RomCheater.EmuMMAPPlugin Line 40  namespace RomCheater.EmuMMAPPlugin
40          private void CreateMaps()          private void CreateMaps()
41          {          {
42              var map = new DeviceMemoryMap();              var map = new DeviceMemoryMap();
   
43              #region NES              #region NES
44              map = CreateNESMemMap();              map = CreateNESMemMap();
45              DeviceMemoryMaps.Add(map);              DeviceMemoryMaps.Add(map);
# Line 68  namespace RomCheater.EmuMMAPPlugin Line 68  namespace RomCheater.EmuMMAPPlugin
68              map = CreateWIIMemMap();              map = CreateWIIMemMap();
69              DeviceMemoryMaps.Add(map);              DeviceMemoryMaps.Add(map);
70              #endregion              #endregion
71              map = null;              map = null; // free memory
72          }          }
   
73          #region NES          #region NES
74          private DeviceMemoryMap CreateNESMemMap()          private DeviceMemoryMap CreateNESMemMap()
75          {          {
76                /* http://en.wikibooks.org/wiki/NES_Programming */
77              const string name = "NES";              const string name = "NES";
78              DeviceMemoryMap map = new DeviceMemoryMap();                          DeviceMemoryMap map = new DeviceMemoryMap();
79              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
80              #region memory maps              #region memory maps
81              maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
82                maprange.Add(new MemMap("Zero Page", 0x0000, 0x00FF));
83                maprange.Add(new MemMap("Stack", 0x0100, 0x01FF));
84                maprange.Add(new MemMap("Ram", 0x0200, 0x07FF));
85    
86                // mirror
87                maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror1", 0x0800, 0x0FFF));
88                // mirror
89                maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror2", 0x1000, 0x17FF));
90                // mirror
91                maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror3", 0x1800, 0x1FFF));
92    
93                maprange.Add(new MemMap("IO Reg1", 0x2000, 0x2007));
94                maprange.Add(new MemMap("IO reg1 mirror - repeated", 0x2000, 0x3FFF));
95                maprange.Add(new MemMap("IO Reg2", 0x4000, 0x401F));
96                maprange.Add(new MemMap("Expansion ROM", 0x4020, 0x5FFF));
97                maprange.Add(new MemMap("SRAM", 0x6000, 0x7FFF));
98                maprange.Add(new MemMap("PRG-ROM", 0x8000, 0xFFFF));
99    
100                maprange.Add(new MemMap("Address of NMI Interrupt handler", 0xFFFA, 0xFFFB));
101                maprange.Add(new MemMap("Address of Power on reset handler", 0xFFFC, 0xFFFD));
102                maprange.Add(new MemMap("Address of BRK handler routine", 0xFFFE, 0xFFFF));
103              #endregion              #endregion
104              map = new DeviceMemoryMap(name, maprange);              map = new DeviceMemoryMap(name, maprange);
105              return map;              return map;
# Line 87  namespace RomCheater.EmuMMAPPlugin Line 108  namespace RomCheater.EmuMMAPPlugin
108          #region SNES          #region SNES
109          private DeviceMemoryMap CreateSNESMemMap()          private DeviceMemoryMap CreateSNESMemMap()
110          {          {
111                /* http://www.emulatronia.com/doctec/consolas/snes/SNESMem.txt */
112              const string name = "SNES";              const string name = "SNES";
113              DeviceMemoryMap map = new DeviceMemoryMap();              DeviceMemoryMap map = new DeviceMemoryMap();
114              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
115              #region memory maps              #region memory maps
116              maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
117                maprange.Add(new MemMap("LowRAM", 0x0000, 0x1fff));
118                maprange.Add(new MemMap("HighRAM", 0x2000, 0x7fff));
119                maprange.Add(new MemMap("Expanded RAM", 0x8000, 0xffff));
120              #endregion              #endregion
121              map = new DeviceMemoryMap(name, maprange);              map = new DeviceMemoryMap(name, maprange);
122              return map;              return map;
# Line 100  namespace RomCheater.EmuMMAPPlugin Line 125  namespace RomCheater.EmuMMAPPlugin
125          #region PS1          #region PS1
126          private DeviceMemoryMap CreatePS1MemMap()          private DeviceMemoryMap CreatePS1MemMap()
127          {          {
128                /* http://rveach.romhack.org/PSXInfo/psx%20hardware%20info.txt */
129              const string name = "PS1";              const string name = "PS1";
130              DeviceMemoryMap map = new DeviceMemoryMap();              DeviceMemoryMap map = new DeviceMemoryMap();
131              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
# Line 110  namespace RomCheater.EmuMMAPPlugin Line 136  namespace RomCheater.EmuMMAPPlugin
136              maprange.Add(new MemMap("Parallel Port", 0x1f000000, 0x1f00ffff));              maprange.Add(new MemMap("Parallel Port", 0x1f000000, 0x1f00ffff));
137              maprange.Add(new MemMap("Scratch Pad", 0x1f800000, 0x1f8003ff));              maprange.Add(new MemMap("Scratch Pad", 0x1f800000, 0x1f8003ff));
138              maprange.Add(new MemMap("HW Registers", 0x1f801000, 0x1f802fff));              maprange.Add(new MemMap("HW Registers", 0x1f801000, 0x1f802fff));
139                maprange.Add(new MemMap("BIOS", 0x1FC00000, 0x1FC7FFFF));
140    
141              maprange.Add(new MemMap("Kernel & User Memory (cached)", 0x80000000, 0x801fffff));              maprange.Add(new MemMap("Kernel & User Memory (cached)", 0x80000000, 0x801fffff));
142              maprange.Add(new MemMap("Kernel & User Memory (uncached)", 0xa0000000, 0xa01fffff));              maprange.Add(new MemMap("Kernel & User Memory (uncached)", 0xa0000000, 0xa01fffff));
143              maprange.Add(new MemMap("BIOS", 0x1FC00000, 0x1FC7FFFF));  
144              #endregion              #endregion
145              map = new DeviceMemoryMap(name, maprange);              map = new DeviceMemoryMap(name, maprange);
146              return map;              return map;
# Line 121  namespace RomCheater.EmuMMAPPlugin Line 149  namespace RomCheater.EmuMMAPPlugin
149          #region PS2          #region PS2
150          private DeviceMemoryMap CreatePS2MemMap()          private DeviceMemoryMap CreatePS2MemMap()
151          {          {
152                /* http://psx-scene.com/forums/attachments/f19/17285d1280158606-ps2-memory-hardware-mapped-registers-layout-ps2-memory-hardware-mapped-registers-layout.txt */
153                /* http://psx-scene.com/forums/f19/ps2-memory-hardware-mapped-registers-layout-64760/ */
154              const string name = "PS2";              const string name = "PS2";
155              DeviceMemoryMap map = new DeviceMemoryMap();              DeviceMemoryMap map = new DeviceMemoryMap();
156              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
# Line 147  namespace RomCheater.EmuMMAPPlugin Line 177  namespace RomCheater.EmuMMAPPlugin
177          #region N64          #region N64
178          private DeviceMemoryMap CreateN64MemMap()          private DeviceMemoryMap CreateN64MemMap()
179          {          {
180                /* http://n64.icequake.net/doc/n64intro/kantan/step1/1-4.html */
181              const string name = "N64";              const string name = "N64";
182              DeviceMemoryMap map = new DeviceMemoryMap();              DeviceMemoryMap map = new DeviceMemoryMap();
183              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
184              #region memory maps              #region memory maps
185              maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
186                maprange.Add(new MemMap("KUSEG [TLB Map]", 0x00000000, 0x7fffffff));
187                maprange.Add(new MemMap("KSEG0 [Ram cached]", 0x80000000, 0x9fffffff));
188                maprange.Add(new MemMap("KSEG1 [Ram uncached]", 0xa0000000, 0xbfffffff));
189                maprange.Add(new MemMap("KSSEG [TLB Map]", 0xc0000000, 0xdfffffff));
190                maprange.Add(new MemMap("KSEG3 [TLB Map]", 0xe0000000, 0xffffffff));
191              #endregion              #endregion
192              map = new DeviceMemoryMap(name, maprange);              map = new DeviceMemoryMap(name, maprange);
193              return map;              return map;
# Line 160  namespace RomCheater.EmuMMAPPlugin Line 196  namespace RomCheater.EmuMMAPPlugin
196          #region NGC          #region NGC
197          private DeviceMemoryMap CreateNGCMemMap()          private DeviceMemoryMap CreateNGCMemMap()
198          {          {
199                /* http://hitmen.c02.at/files/yagcd/yagcd/chap4.html#sec4 */
200              const string name = "NGC";              const string name = "NGC";
201              DeviceMemoryMap map = new DeviceMemoryMap();              DeviceMemoryMap map = new DeviceMemoryMap();
202              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
203              #region memory maps              #region memory maps
204              maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
205                maprange.Add(new MemMap("Physical RAM", 0x00000000, 0x017fffff));
206                maprange.Add(new MemMap("Logical RAM [cached]", 0x80000000, 0x817fffff));
207                maprange.Add(new MemMap("Logical RAM [uncached]", 0xC0000000, 0xC17fffff));
208              #endregion              #endregion
209              map = new DeviceMemoryMap(name, maprange);              map = new DeviceMemoryMap(name, maprange);
210              return map;              return map;
# Line 173  namespace RomCheater.EmuMMAPPlugin Line 213  namespace RomCheater.EmuMMAPPlugin
213          #region WII          #region WII
214          private DeviceMemoryMap CreateWIIMemMap()          private DeviceMemoryMap CreateWIIMemMap()
215          {          {
216                /* http://wiibrew.org/wiki/Memory_Map */
217              const string name = "WII";              const string name = "WII";
218              DeviceMemoryMap map = new DeviceMemoryMap();              DeviceMemoryMap map = new DeviceMemoryMap();
219              List<IMemMap> maprange = new List<IMemMap>();              List<IMemMap> maprange = new List<IMemMap>();
220              #region memory maps              #region memory maps
221              maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));              //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
222                maprange.Add(new MemMap("MEM1 [cached]", 0x80000000, 0x817FFFFF));
223                maprange.Add(new MemMap("MEM1 [uncached]", 0xC0000000, 0xC17FFFFF));
224                maprange.Add(new MemMap("MEM2 [cached]", 0x90000000, 0x93FFFFFF));
225                maprange.Add(new MemMap("MEM2 [uncached]", 0xD0000000, 0xD3FFFFFF));
226                maprange.Add(new MemMap("Hollywood/Starlet Registers?", 0xCD000000, 0xCD008000));
227              #endregion              #endregion
228              map = new DeviceMemoryMap(name, maprange);              map = new DeviceMemoryMap(name, maprange);
229              return map;              return map;
230          }          }
231          #endregion          #endregion
232      }      }
233        #endregion
234    
235      #region Memory Map Helper Classes      #region Memory Map Helper Classes
236        #region IMemMap
237      internal interface IMemMap      internal interface IMemMap
238      {      {
239          string MapName { get; }          string MapName { get; }
# Line 194  namespace RomCheater.EmuMMAPPlugin Line 242  namespace RomCheater.EmuMMAPPlugin
242          string MapSize { get; }          string MapSize { get; }
243          string ToString();          string ToString();
244      }      }
245        #endregion
246        #region IDeviceMemoryMap
247      internal interface IDeviceMemoryMap      internal interface IDeviceMemoryMap
248      {      {
249          string DeviceName { get; }          string DeviceName { get; }
250          IDictionary<string, IMemMap> MemoryMap { get; }          IDictionary<string, IMemMap> MemoryMap { get; }
251          string ToString();          string ToString();
252      }      }
253        #endregion
254        #region MemMap
255      internal class MemMap : IMemMap      internal class MemMap : IMemMap
256      {      {
257          public MemMap() : this(string.Empty, 0, 0) { }          public MemMap() : this(string.Empty, 0, 0) { }
258          public MemMap(string name)          public MemMap(string name) { this.MapName = name; }
259          {          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) { }  
260          public MemMap(string name, string start, string end, ulong size)          public MemMap(string name, string start, string end, ulong size)
261              : this(name)              : this(name)
262          {          {
263              this.MapStart = start;              this.MapStart = start;
264              this.MapEnd = end;              this.MapEnd = end;
265              this.MapSize = string.Format("0x{0}={1:0.00000}MB", size.ToString("X"), ((double)size / (1024.0 * 1024.0)));              ulong _size = size + 1;
266                double t = 1024.0 * 1024.0;
267                double __size = (double)_size / t;
268                this.MapSize = string.Format("0x{0}={1:0.000000}MB", _size.ToString("X"), __size);
269          }          }
270          #region IMappedMemRange Members          #region IMappedMemRange Members
271          public string MapName { get; private set; }          public string MapName { get; private set; }
272          public string MapStart { get; private set; }          public string MapStart { get; private set; }
273          public string MapEnd { get; private set; }          public string MapEnd { get; private set; }
274          public string MapSize { get; private set; }          public string MapSize { get; private set; }
275          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);  
         }  
276          #endregion          #endregion
277      }      }
278        #endregion
279        #region DeviceMemoryMap
280      internal class DeviceMemoryMap : IDeviceMemoryMap      internal class DeviceMemoryMap : IDeviceMemoryMap
281      {      {
282          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 235  namespace RomCheater.EmuMMAPPlugin Line 284  namespace RomCheater.EmuMMAPPlugin
284          {          {
285              this.DeviceName = device;              this.DeviceName = device;
286              this.MemoryMap = new Dictionary<string, IMemMap>();              this.MemoryMap = new Dictionary<string, IMemMap>();
287                foreach (var map in memorymap) { this.MemoryMap.Add(map.MapName, map); }
             foreach (var map in memorymap)  
             {  
                 this.MemoryMap.Add(map.MapName, map);  
             }  
   
288          }          }
   
289          #region IDeviceMemoryMap Members          #region IDeviceMemoryMap Members
290          public string DeviceName { get; private set; }          public string DeviceName { get; private set; }
291          public IDictionary<string, IMemMap> MemoryMap { get; private set; }          public IDictionary<string, IMemMap> MemoryMap { get; private set; }
292          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);  
         }  
293          #endregion          #endregion
294      }      }
295        #endregion
296      #endregion      #endregion
297  }  }
   

Legend:
Removed from v.647  
changed lines
  Added in v.654

  ViewVC Help
Powered by ViewVC 1.1.22