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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 645 - (show annotations) (download)
Sat Jun 8 22:19:03 2013 UTC (7 years, 5 months ago) by william
File size: 10033 byte(s)
PS1: fix bios mem range

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

  ViewVC Help
Powered by ViewVC 1.1.22