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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 641 - (hide annotations) (download)
Sat Jun 8 21:50:28 2013 UTC (7 years, 5 months ago) by william
File size: 8302 byte(s)

1 william 628 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 william 641 private List<DeviceMemoryMap> DeviceMemoryMaps = new List<DeviceMemoryMap>();
16 william 628 public EmuMEMMapDockControl()
17     {
18     InitializeComponent();
19 william 641 CreateMaps();
20 william 628 }
21 william 641 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     #endregion
122     map = new DeviceMemoryMap(name, maprange);
123     return map;
124     }
125     #endregion
126     #region N64
127     private DeviceMemoryMap CreateN64MemMap()
128     {
129     const string name = "N64";
130     DeviceMemoryMap map = new DeviceMemoryMap();
131     List<IMemMap> maprange = new List<IMemMap>();
132     #region memory maps
133     maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
134     #endregion
135     map = new DeviceMemoryMap(name, maprange);
136     return map;
137     }
138     #endregion
139     #region NGC
140     private DeviceMemoryMap CreateNGCMemMap()
141     {
142     const string name = "NGC";
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 WII
153     private DeviceMemoryMap CreateWIIMemMap()
154     {
155     const string name = "WII";
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 william 628 }
166 william 641
167     #region Memory Map Helper Classes
168     internal interface IMemMap
169     {
170     string MapName { get; }
171     string MapStart { get; }
172     string MapEnd { get; }
173     string MapSize { get; }
174     string ToString();
175     }
176     internal interface IDeviceMemoryMap
177     {
178     string DeviceName { get; }
179     IDictionary<string, IMemMap> MemoryMap { get; }
180     string ToString();
181     }
182    
183     internal class MemMap : IMemMap
184     {
185     public MemMap() : this(string.Empty, 0, 0) { }
186     public MemMap(string name)
187     {
188     this.MapName = name;
189     }
190     public MemMap(string name, ulong start, ulong end) : this(name, string.Format("0x{0}", start.ToString("X")), string.Format("0x{0}", end.ToString("X")), string.Format("0x{0}", (end - start).ToString("X"))) { }
191     public MemMap(string name, string start, string end, string size)
192     : this(name)
193     {
194     this.MapStart = start;
195     this.MapEnd = end;
196     this.MapSize = size;
197     }
198     #region IMappedMemRange Members
199     public string MapName { get; private set; }
200     public string MapStart { get; private set; }
201     public string MapEnd { get; private set; }
202     public string MapSize { get; private set; }
203     public override string ToString()
204     {
205     return string.Format("[{0}]==>[{1}-{2}] [{3}]", MapName, MapStart, MapEnd, MapSize);
206     }
207     #endregion
208     }
209    
210     internal class DeviceMemoryMap : IDeviceMemoryMap
211     {
212     public DeviceMemoryMap() { this.DeviceName = string.Empty; this.MemoryMap = this.MemoryMap = new Dictionary<string, IMemMap>(); }
213     public DeviceMemoryMap(string device, List<IMemMap> memorymap)
214     {
215     this.DeviceName = device;
216     this.MemoryMap = new Dictionary<string, IMemMap>();
217    
218     foreach (var map in memorymap)
219     {
220     this.MemoryMap.Add(map.MapName, map);
221     }
222    
223     }
224    
225     #region IDeviceMemoryMap Members
226     public string DeviceName { get; private set; }
227     public IDictionary<string, IMemMap> MemoryMap { get; private set; }
228     public override string ToString()
229     {
230     return string.Format("[{0}]==>{1} mapped memory range(s)", DeviceName, MemoryMap.Count);
231     }
232     #endregion
233     }
234    
235     #endregion
236 william 628 }
237 william 641

  ViewVC Help
Powered by ViewVC 1.1.22