/[RomCheater]/trunk/RomCheater.EmuMMAPPlugin/EmuMEMMapDockControl.cs
ViewVC logotype

Contents of /trunk/RomCheater.EmuMMAPPlugin/EmuMEMMapDockControl.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 643 - (show annotations) (download)
Sat Jun 8 22:06:24 2013 UTC (7 years, 5 months ago) by william
File size: 9429 byte(s)
+ calculate actual memory size in megabytes

1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 using WeifenLuo.WinFormsUI.Docking;
10
11 namespace RomCheater.EmuMMAPPlugin
12 {
13 public partial class EmuMEMMapDockControl : DockContent
14 {
15 private List<DeviceMemoryMap> DeviceMemoryMaps = new List<DeviceMemoryMap>();
16 public EmuMEMMapDockControl()
17 {
18 InitializeComponent();
19 CreateMaps();
20 }
21 private void EmuMEMMapDockControl_Shown(object sender, EventArgs e)
22 {
23 txtDeviceMap.Clear();
24 txtDeviceMap.AppendText(string.Format("Device Memory Map(s):{0}", System.Environment.NewLine));
25 foreach (var k in DeviceMemoryMaps)
26 {
27 string devicename = k.DeviceName;
28 txtDeviceMap.AppendText(string.Format("{0}:{1}", devicename, System.Environment.NewLine));
29 var map = k.MemoryMap;
30 foreach (var mapped in map)
31 {
32 var mapped_name = mapped.Key;
33 var mapped_data = mapped.Value;
34 var t = mapped_data.ToString();
35 txtDeviceMap.AppendText(string.Format("\t{0}{1}", t, System.Environment.NewLine));
36 }
37 }
38 }
39 private void CreateMaps()
40 {
41 var map = new DeviceMemoryMap();
42
43 #region NES
44 map = CreateNESMemMap();
45 DeviceMemoryMaps.Add(map);
46 #endregion
47 #region SNES
48 map = CreateSNESMemMap();
49 DeviceMemoryMaps.Add(map);
50 #endregion
51 #region PS1
52 map = CreatePS1MemMap();
53 DeviceMemoryMaps.Add(map);
54 #endregion
55 #region PS2
56 map = CreatePS2MemMap();
57 DeviceMemoryMaps.Add(map);
58 #endregion
59 #region N64
60 map = CreateN64MemMap();
61 DeviceMemoryMaps.Add(map);
62 #endregion
63 #region NGC
64 map = CreateNGCMemMap();
65 DeviceMemoryMaps.Add(map);
66 #endregion
67 #region WII
68 map = CreateWIIMemMap();
69 DeviceMemoryMaps.Add(map);
70 #endregion
71 map = null;
72 }
73
74 #region NES
75 private DeviceMemoryMap CreateNESMemMap()
76 {
77 const string name = "NES";
78 DeviceMemoryMap map = new DeviceMemoryMap();
79 List<IMemMap> maprange = new List<IMemMap>();
80 #region memory maps
81 maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
82 #endregion
83 map = new DeviceMemoryMap(name, maprange);
84 return map;
85 }
86 #endregion
87 #region SNES
88 private DeviceMemoryMap CreateSNESMemMap()
89 {
90 const string name = "SNES";
91 DeviceMemoryMap map = new DeviceMemoryMap();
92 List<IMemMap> maprange = new List<IMemMap>();
93 #region memory maps
94 maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
95 #endregion
96 map = new DeviceMemoryMap(name, maprange);
97 return map;
98 }
99 #endregion
100 #region PS1
101 private DeviceMemoryMap CreatePS1MemMap()
102 {
103 const string name = "PS1";
104 DeviceMemoryMap map = new DeviceMemoryMap();
105 List<IMemMap> maprange = new List<IMemMap>();
106 #region memory maps
107 maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
108 #endregion
109 map = new DeviceMemoryMap(name, maprange);
110 return map;
111 }
112 #endregion
113 #region PS2
114 private DeviceMemoryMap CreatePS2MemMap()
115 {
116 const string name = "PS2";
117 DeviceMemoryMap map = new DeviceMemoryMap();
118 List<IMemMap> maprange = new List<IMemMap>();
119 #region memory maps
120 //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
121 maprange.Add(new MemMap("EE Kernel", 0x80000000, 0x800FFFFF));
122 maprange.Add(new MemMap("EE RAM (Cached)", 0x00100000, 0x01FFFFFF));
123 maprange.Add(new MemMap("EE RAM (Uncached)", 0x20100000, 0x21FFFFFF));
124 maprange.Add(new MemMap("EE RAM (Uncached&accelerated)", 0x30100000, 0x31FFFFFF));
125 maprange.Add(new MemMap("EE Registers (uncached)", 0x10000000, 0x11FFFFFF));
126 maprange.Add(new MemMap("GS Registers (uncached)", 0x12000000, 0x13FFFFFF));
127 maprange.Add(new MemMap("Boot ROM0 (uncached)", 0x1FC00000, 0x1FFFFFFF));
128 maprange.Add(new MemMap("Boot ROM09 (cached)", 0x9FC00000, 0x9FFFFFFF));
129 maprange.Add(new MemMap("Boot ROM0b (uncached)", 0xBFC00000, 0xBFFFFFFF));
130 maprange.Add(new MemMap("Boot ROM1", 0xBE000000, 0xBE040000));
131 maprange.Add(new MemMap("Boot ROM2", 0xBE400000, 0xBE440000));
132 maprange.Add(new MemMap("IOP RAM", 0xBC000000, 0xBC1FFFFF));
133 maprange.Add(new MemMap("Scratch Pad", 0x70000000, 0x70003FFF));
134 #endregion
135 map = new DeviceMemoryMap(name, maprange);
136 return map;
137 }
138 #endregion
139 #region N64
140 private DeviceMemoryMap CreateN64MemMap()
141 {
142 const string name = "N64";
143 DeviceMemoryMap map = new DeviceMemoryMap();
144 List<IMemMap> maprange = new List<IMemMap>();
145 #region memory maps
146 maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
147 #endregion
148 map = new DeviceMemoryMap(name, maprange);
149 return map;
150 }
151 #endregion
152 #region NGC
153 private DeviceMemoryMap CreateNGCMemMap()
154 {
155 const string name = "NGC";
156 DeviceMemoryMap map = new DeviceMemoryMap();
157 List<IMemMap> maprange = new List<IMemMap>();
158 #region memory maps
159 maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
160 #endregion
161 map = new DeviceMemoryMap(name, maprange);
162 return map;
163 }
164 #endregion
165 #region WII
166 private DeviceMemoryMap CreateWIIMemMap()
167 {
168 const string name = "WII";
169 DeviceMemoryMap map = new DeviceMemoryMap();
170 List<IMemMap> maprange = new List<IMemMap>();
171 #region memory maps
172 maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
173 #endregion
174 map = new DeviceMemoryMap(name, maprange);
175 return map;
176 }
177 #endregion
178 }
179
180 #region Memory Map Helper Classes
181 internal interface IMemMap
182 {
183 string MapName { get; }
184 string MapStart { get; }
185 string MapEnd { get; }
186 string MapSize { get; }
187 string ToString();
188 }
189 internal interface IDeviceMemoryMap
190 {
191 string DeviceName { get; }
192 IDictionary<string, IMemMap> MemoryMap { get; }
193 string ToString();
194 }
195
196 internal class MemMap : IMemMap
197 {
198 public MemMap() : this(string.Empty, 0, 0) { }
199 public MemMap(string name)
200 {
201 this.MapName = name;
202 }
203 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) { }
204 public MemMap(string name, string start, string end, ulong size)
205 : this(name)
206 {
207 this.MapStart = start;
208 this.MapEnd = end;
209 this.MapSize = string.Format("0x{0}={1:0.00}MB", size.ToString("X"), ((double)size / (1024.0 * 1024.0)));
210 }
211 #region IMappedMemRange Members
212 public string MapName { get; private set; }
213 public string MapStart { get; private set; }
214 public string MapEnd { get; private set; }
215 public string MapSize { get; private set; }
216 public override string ToString()
217 {
218 return string.Format("[{0}]==>[{1}-{2}] [{3}]", MapName, MapStart, MapEnd, MapSize);
219 }
220 #endregion
221 }
222
223 internal class DeviceMemoryMap : IDeviceMemoryMap
224 {
225 public DeviceMemoryMap() { this.DeviceName = string.Empty; this.MemoryMap = this.MemoryMap = new Dictionary<string, IMemMap>(); }
226 public DeviceMemoryMap(string device, List<IMemMap> memorymap)
227 {
228 this.DeviceName = device;
229 this.MemoryMap = new Dictionary<string, IMemMap>();
230
231 foreach (var map in memorymap)
232 {
233 this.MemoryMap.Add(map.MapName, map);
234 }
235
236 }
237
238 #region IDeviceMemoryMap Members
239 public string DeviceName { get; private set; }
240 public IDictionary<string, IMemMap> MemoryMap { get; private set; }
241 public override string ToString()
242 {
243 return string.Format("[{0}]==>{1} mapped memory range(s)", DeviceName, MemoryMap.Count);
244 }
245 #endregion
246 }
247
248 #endregion
249 }
250

  ViewVC Help
Powered by ViewVC 1.1.22