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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 646 - (hide annotations) (download)
Sat Jun 8 22:21:47 2013 UTC (7 years, 5 months ago) by william
File size: 10103 byte(s)
+ text size

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 william 646 //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
108 william 644 maprange.Add(new MemMap("Kernel Memory", 0x00000000, 0x0000ffff));
109 william 645 maprange.Add(new MemMap("User Memory", 0x00010000, 0x001FFFFF));
110 william 644 maprange.Add(new MemMap("Parallel Port", 0x1f000000, 0x1f00ffff));
111     maprange.Add(new MemMap("Scratch Pad", 0x1f800000, 0x1f8003ff));
112     maprange.Add(new MemMap("HW Registers", 0x1f801000, 0x1f802fff));
113     maprange.Add(new MemMap("Kernel & User Memory (cached)", 0x80000000, 0x801fffff));
114     maprange.Add(new MemMap("Kernel & User Memory (uncached)", 0xa0000000, 0xa01fffff));
115 william 645 maprange.Add(new MemMap("BIOS", 0x1FC00000, 0x1FC7FFFF));
116 william 646 #endregion
117     map = new DeviceMemoryMap(name, maprange);
118 william 641 return map;
119     }
120     #endregion
121     #region PS2
122     private DeviceMemoryMap CreatePS2MemMap()
123     {
124     const string name = "PS2";
125     DeviceMemoryMap map = new DeviceMemoryMap();
126     List<IMemMap> maprange = new List<IMemMap>();
127     #region memory maps
128 william 642 //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
129     maprange.Add(new MemMap("EE Kernel", 0x80000000, 0x800FFFFF));
130     maprange.Add(new MemMap("EE RAM (Cached)", 0x00100000, 0x01FFFFFF));
131     maprange.Add(new MemMap("EE RAM (Uncached)", 0x20100000, 0x21FFFFFF));
132     maprange.Add(new MemMap("EE RAM (Uncached&accelerated)", 0x30100000, 0x31FFFFFF));
133     maprange.Add(new MemMap("EE Registers (uncached)", 0x10000000, 0x11FFFFFF));
134     maprange.Add(new MemMap("GS Registers (uncached)", 0x12000000, 0x13FFFFFF));
135     maprange.Add(new MemMap("Boot ROM0 (uncached)", 0x1FC00000, 0x1FFFFFFF));
136     maprange.Add(new MemMap("Boot ROM09 (cached)", 0x9FC00000, 0x9FFFFFFF));
137     maprange.Add(new MemMap("Boot ROM0b (uncached)", 0xBFC00000, 0xBFFFFFFF));
138     maprange.Add(new MemMap("Boot ROM1", 0xBE000000, 0xBE040000));
139     maprange.Add(new MemMap("Boot ROM2", 0xBE400000, 0xBE440000));
140     maprange.Add(new MemMap("IOP RAM", 0xBC000000, 0xBC1FFFFF));
141     maprange.Add(new MemMap("Scratch Pad", 0x70000000, 0x70003FFF));
142 william 641 #endregion
143     map = new DeviceMemoryMap(name, maprange);
144     return map;
145     }
146     #endregion
147     #region N64
148     private DeviceMemoryMap CreateN64MemMap()
149     {
150     const string name = "N64";
151     DeviceMemoryMap map = new DeviceMemoryMap();
152     List<IMemMap> maprange = new List<IMemMap>();
153     #region memory maps
154     maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
155     #endregion
156     map = new DeviceMemoryMap(name, maprange);
157     return map;
158     }
159     #endregion
160     #region NGC
161     private DeviceMemoryMap CreateNGCMemMap()
162     {
163     const string name = "NGC";
164     DeviceMemoryMap map = new DeviceMemoryMap();
165     List<IMemMap> maprange = new List<IMemMap>();
166     #region memory maps
167     maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
168     #endregion
169     map = new DeviceMemoryMap(name, maprange);
170     return map;
171     }
172     #endregion
173     #region WII
174     private DeviceMemoryMap CreateWIIMemMap()
175     {
176     const string name = "WII";
177     DeviceMemoryMap map = new DeviceMemoryMap();
178     List<IMemMap> maprange = new List<IMemMap>();
179     #region memory maps
180     maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
181     #endregion
182     map = new DeviceMemoryMap(name, maprange);
183     return map;
184     }
185     #endregion
186 william 628 }
187 william 641
188     #region Memory Map Helper Classes
189     internal interface IMemMap
190     {
191     string MapName { get; }
192     string MapStart { get; }
193     string MapEnd { get; }
194     string MapSize { get; }
195     string ToString();
196     }
197     internal interface IDeviceMemoryMap
198     {
199     string DeviceName { get; }
200     IDictionary<string, IMemMap> MemoryMap { get; }
201     string ToString();
202     }
203    
204     internal class MemMap : IMemMap
205     {
206     public MemMap() : this(string.Empty, 0, 0) { }
207     public MemMap(string name)
208     {
209     this.MapName = name;
210     }
211 william 643 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) { }
212     public MemMap(string name, string start, string end, ulong size)
213 william 641 : this(name)
214     {
215     this.MapStart = start;
216     this.MapEnd = end;
217 william 643 this.MapSize = string.Format("0x{0}={1:0.00}MB", size.ToString("X"), ((double)size / (1024.0 * 1024.0)));
218 william 641 }
219     #region IMappedMemRange Members
220     public string MapName { get; private set; }
221     public string MapStart { get; private set; }
222     public string MapEnd { get; private set; }
223     public string MapSize { get; private set; }
224     public override string ToString()
225     {
226     return string.Format("[{0}]==>[{1}-{2}] [{3}]", MapName, MapStart, MapEnd, MapSize);
227     }
228     #endregion
229     }
230    
231     internal class DeviceMemoryMap : IDeviceMemoryMap
232     {
233     public DeviceMemoryMap() { this.DeviceName = string.Empty; this.MemoryMap = this.MemoryMap = new Dictionary<string, IMemMap>(); }
234     public DeviceMemoryMap(string device, List<IMemMap> memorymap)
235     {
236     this.DeviceName = device;
237     this.MemoryMap = new Dictionary<string, IMemMap>();
238    
239     foreach (var map in memorymap)
240     {
241     this.MemoryMap.Add(map.MapName, map);
242     }
243    
244     }
245    
246     #region IDeviceMemoryMap Members
247     public string DeviceName { get; private set; }
248     public IDictionary<string, IMemMap> MemoryMap { get; private set; }
249     public override string ToString()
250     {
251     return string.Format("[{0}]==>{1} mapped memory range(s)", DeviceName, MemoryMap.Count);
252     }
253     #endregion
254     }
255    
256     #endregion
257 william 628 }
258 william 641

  ViewVC Help
Powered by ViewVC 1.1.22