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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 892 - (hide annotations) (download)
Wed Sep 17 05:56:41 2014 UTC (5 years, 5 months ago) by william
File size: 15588 byte(s)
+ alot of dang work to force an icon to be shown on the docked panels
  ** when it was as simple as setting: DockPanel.ShowDocumentIcon to true

1 william 684 #region Logging Defines
2     // include this any class or method that required logging, and comment-out what is not needed
3    
4     #region Enabled logging levels
5     #define LOGGING_ENABLE_INFO
6     #define LOGGING_ENABLE_WARN
7     #define LOGGING_ENABLE_DEBUG
8     //#define LOGGING_ENABLE_VERBOSEDEBUG
9     #define LOGGING_ENABLE_ERROR
10     #define LOGGING_ENABLE_VERBOSEERROR
11     #define LOGGING_ENABLE_PROFILER
12     #endregion
13     #endregion
14     using System;
15 william 628 using System.Collections.Generic;
16     using System.ComponentModel;
17     using System.Data;
18     using System.Drawing;
19     using System.Linq;
20     using System.Text;
21     using System.Windows.Forms;
22     using WeifenLuo.WinFormsUI.Docking;
23 william 683 using RomCheater.PluginFramework.Core;
24 william 684 using RomCheater.Logging;
25 william 889 using RomCheater.Interfaces;
26 william 628
27     namespace RomCheater.EmuMMAPPlugin
28     {
29 william 654 #region EmuMEMMapDockControl
30 william 628 public partial class EmuMEMMapDockControl : DockContent
31     {
32 william 683 private UserControlPlugin plugin;
33 william 641 private List<DeviceMemoryMap> DeviceMemoryMaps = new List<DeviceMemoryMap>();
34 william 683 public EmuMEMMapDockControl(UserControlPlugin plugin)
35 william 628 {
36 william 683 this.plugin = plugin;
37 william 684 InitPluginFramework();
38 william 628 InitializeComponent();
39 william 641 CreateMaps();
40 william 628 }
41 william 684 private void InitPluginFramework()
42     {
43     if (this.plugin == null) { return; }
44 william 686 this.plugin.OnSelectedProcessChanged += new BaseEventHandler<ProcessChangedEventArgs>(plugin_OnSelectedProcessChanged);
45     this.plugin.OnSelectedConfigChanged += new BaseEventHandler<ConfigChangedEventArgs>(plugin_OnSelectedConfigChanged);
46     this.plugin.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(plugin_OnPEDataUpdated);
47 william 689 RaisePluginFrameworkEvents();
48 william 684 }
49 william 689
50     bool EventsRaised = false;
51     private void RaisePluginFrameworkEvents()
52     {
53    
54     if (this.plugin == null) { EventsRaised = true; return; }
55     if (!EventsRaised)
56     {
57     this.plugin.RaisePluginFrameworkEvents();
58     EventsRaised = true;
59     }
60     }
61 william 686 void plugin_OnPEDataUpdated(PEViewerDataUpdatedEventArgs e)
62 william 684 {
63 william 691 //logger.Warn.WriteLine("plugin_OnPEDataUpdated::has not been implemented!");
64 william 684 }
65 william 686 void plugin_OnSelectedConfigChanged(ConfigChangedEventArgs e)
66 william 684 {
67 william 691 //logger.Warn.WriteLine("plugin_OnSelectedConfigChanged::has not been implemented!");
68 william 684 }
69 william 686 void plugin_OnSelectedProcessChanged(ProcessChangedEventArgs e)
70 william 684 {
71 william 691 //logger.Warn.WriteLine("plugin_OnSelectedProcessChanged::has not been implemented!");
72 william 684 }
73 william 641 private void EmuMEMMapDockControl_Shown(object sender, EventArgs e)
74     {
75     txtDeviceMap.Clear();
76     txtDeviceMap.AppendText(string.Format("Device Memory Map(s):{0}", System.Environment.NewLine));
77     foreach (var k in DeviceMemoryMaps)
78     {
79     string devicename = k.DeviceName;
80     txtDeviceMap.AppendText(string.Format("{0}:{1}", devicename, System.Environment.NewLine));
81     var map = k.MemoryMap;
82     foreach (var mapped in map)
83     {
84     var mapped_name = mapped.Key;
85     var mapped_data = mapped.Value;
86     var t = mapped_data.ToString();
87     txtDeviceMap.AppendText(string.Format("\t{0}{1}", t, System.Environment.NewLine));
88     }
89     }
90     }
91     private void CreateMaps()
92     {
93     var map = new DeviceMemoryMap();
94     #region NES
95     map = CreateNESMemMap();
96     DeviceMemoryMaps.Add(map);
97     #endregion
98     #region SNES
99     map = CreateSNESMemMap();
100     DeviceMemoryMaps.Add(map);
101     #endregion
102     #region PS1
103     map = CreatePS1MemMap();
104     DeviceMemoryMaps.Add(map);
105     #endregion
106     #region PS2
107     map = CreatePS2MemMap();
108     DeviceMemoryMaps.Add(map);
109     #endregion
110     #region N64
111     map = CreateN64MemMap();
112     DeviceMemoryMaps.Add(map);
113     #endregion
114     #region NGC
115     map = CreateNGCMemMap();
116     DeviceMemoryMaps.Add(map);
117     #endregion
118     #region WII
119     map = CreateWIIMemMap();
120     DeviceMemoryMaps.Add(map);
121     #endregion
122 william 654 map = null; // free memory
123 william 641 }
124     #region NES
125     private DeviceMemoryMap CreateNESMemMap()
126     {
127 william 650 /* http://en.wikibooks.org/wiki/NES_Programming */
128 william 641 const string name = "NES";
129 william 654 DeviceMemoryMap map = new DeviceMemoryMap();
130 william 641 List<IMemMap> maprange = new List<IMemMap>();
131     #region memory maps
132 william 648 //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
133     maprange.Add(new MemMap("Zero Page", 0x0000, 0x00FF));
134     maprange.Add(new MemMap("Stack", 0x0100, 0x01FF));
135     maprange.Add(new MemMap("Ram", 0x0200, 0x07FF));
136    
137     // mirror
138     maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror1", 0x0800, 0x0FFF));
139     // mirror
140     maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror2", 0x1000, 0x17FF));
141     // mirror
142     maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror3", 0x1800, 0x1FFF));
143 william 654
144 william 648 maprange.Add(new MemMap("IO Reg1", 0x2000, 0x2007));
145     maprange.Add(new MemMap("IO reg1 mirror - repeated", 0x2000, 0x3FFF));
146     maprange.Add(new MemMap("IO Reg2", 0x4000, 0x401F));
147     maprange.Add(new MemMap("Expansion ROM", 0x4020, 0x5FFF));
148     maprange.Add(new MemMap("SRAM", 0x6000, 0x7FFF));
149     maprange.Add(new MemMap("PRG-ROM", 0x8000, 0xFFFF));
150    
151     maprange.Add(new MemMap("Address of NMI Interrupt handler", 0xFFFA, 0xFFFB));
152     maprange.Add(new MemMap("Address of Power on reset handler", 0xFFFC, 0xFFFD));
153     maprange.Add(new MemMap("Address of BRK handler routine", 0xFFFE, 0xFFFF));
154 william 641 #endregion
155     map = new DeviceMemoryMap(name, maprange);
156     return map;
157     }
158     #endregion
159     #region SNES
160     private DeviceMemoryMap CreateSNESMemMap()
161     {
162 william 650 /* http://www.emulatronia.com/doctec/consolas/snes/SNESMem.txt */
163 william 641 const string name = "SNES";
164     DeviceMemoryMap map = new DeviceMemoryMap();
165     List<IMemMap> maprange = new List<IMemMap>();
166     #region memory maps
167 william 650 //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
168     maprange.Add(new MemMap("LowRAM", 0x0000, 0x1fff));
169     maprange.Add(new MemMap("HighRAM", 0x2000, 0x7fff));
170     maprange.Add(new MemMap("Expanded RAM", 0x8000, 0xffff));
171 william 641 #endregion
172     map = new DeviceMemoryMap(name, maprange);
173     return map;
174     }
175     #endregion
176     #region PS1
177     private DeviceMemoryMap CreatePS1MemMap()
178     {
179 william 650 /* http://rveach.romhack.org/PSXInfo/psx%20hardware%20info.txt */
180 william 641 const string name = "PS1";
181     DeviceMemoryMap map = new DeviceMemoryMap();
182     List<IMemMap> maprange = new List<IMemMap>();
183     #region memory maps
184 william 646 //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
185 william 644 maprange.Add(new MemMap("Kernel Memory", 0x00000000, 0x0000ffff));
186 william 645 maprange.Add(new MemMap("User Memory", 0x00010000, 0x001FFFFF));
187 william 644 maprange.Add(new MemMap("Parallel Port", 0x1f000000, 0x1f00ffff));
188     maprange.Add(new MemMap("Scratch Pad", 0x1f800000, 0x1f8003ff));
189 william 654 maprange.Add(new MemMap("HW Registers", 0x1f801000, 0x1f802fff));
190 william 650 maprange.Add(new MemMap("BIOS", 0x1FC00000, 0x1FC7FFFF));
191    
192 william 644 maprange.Add(new MemMap("Kernel & User Memory (cached)", 0x80000000, 0x801fffff));
193     maprange.Add(new MemMap("Kernel & User Memory (uncached)", 0xa0000000, 0xa01fffff));
194 william 650
195 william 646 #endregion
196     map = new DeviceMemoryMap(name, maprange);
197 william 641 return map;
198     }
199     #endregion
200     #region PS2
201     private DeviceMemoryMap CreatePS2MemMap()
202     {
203 william 650 /* http://psx-scene.com/forums/attachments/f19/17285d1280158606-ps2-memory-hardware-mapped-registers-layout-ps2-memory-hardware-mapped-registers-layout.txt */
204     /* http://psx-scene.com/forums/f19/ps2-memory-hardware-mapped-registers-layout-64760/ */
205 william 641 const string name = "PS2";
206     DeviceMemoryMap map = new DeviceMemoryMap();
207     List<IMemMap> maprange = new List<IMemMap>();
208     #region memory maps
209 william 642 //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
210     maprange.Add(new MemMap("EE Kernel", 0x80000000, 0x800FFFFF));
211     maprange.Add(new MemMap("EE RAM (Cached)", 0x00100000, 0x01FFFFFF));
212     maprange.Add(new MemMap("EE RAM (Uncached)", 0x20100000, 0x21FFFFFF));
213     maprange.Add(new MemMap("EE RAM (Uncached&accelerated)", 0x30100000, 0x31FFFFFF));
214     maprange.Add(new MemMap("EE Registers (uncached)", 0x10000000, 0x11FFFFFF));
215     maprange.Add(new MemMap("GS Registers (uncached)", 0x12000000, 0x13FFFFFF));
216     maprange.Add(new MemMap("Boot ROM0 (uncached)", 0x1FC00000, 0x1FFFFFFF));
217     maprange.Add(new MemMap("Boot ROM09 (cached)", 0x9FC00000, 0x9FFFFFFF));
218     maprange.Add(new MemMap("Boot ROM0b (uncached)", 0xBFC00000, 0xBFFFFFFF));
219     maprange.Add(new MemMap("Boot ROM1", 0xBE000000, 0xBE040000));
220     maprange.Add(new MemMap("Boot ROM2", 0xBE400000, 0xBE440000));
221     maprange.Add(new MemMap("IOP RAM", 0xBC000000, 0xBC1FFFFF));
222     maprange.Add(new MemMap("Scratch Pad", 0x70000000, 0x70003FFF));
223 william 641 #endregion
224     map = new DeviceMemoryMap(name, maprange);
225     return map;
226     }
227     #endregion
228     #region N64
229     private DeviceMemoryMap CreateN64MemMap()
230     {
231 william 651 /* http://n64.icequake.net/doc/n64intro/kantan/step1/1-4.html */
232 william 641 const string name = "N64";
233     DeviceMemoryMap map = new DeviceMemoryMap();
234     List<IMemMap> maprange = new List<IMemMap>();
235     #region memory maps
236 william 651 //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
237     maprange.Add(new MemMap("KUSEG [TLB Map]", 0x00000000, 0x7fffffff));
238     maprange.Add(new MemMap("KSEG0 [Ram cached]", 0x80000000, 0x9fffffff));
239     maprange.Add(new MemMap("KSEG1 [Ram uncached]", 0xa0000000, 0xbfffffff));
240     maprange.Add(new MemMap("KSSEG [TLB Map]", 0xc0000000, 0xdfffffff));
241     maprange.Add(new MemMap("KSEG3 [TLB Map]", 0xe0000000, 0xffffffff));
242 william 641 #endregion
243     map = new DeviceMemoryMap(name, maprange);
244     return map;
245     }
246     #endregion
247     #region NGC
248     private DeviceMemoryMap CreateNGCMemMap()
249     {
250 william 652 /* http://hitmen.c02.at/files/yagcd/yagcd/chap4.html#sec4 */
251 william 641 const string name = "NGC";
252     DeviceMemoryMap map = new DeviceMemoryMap();
253     List<IMemMap> maprange = new List<IMemMap>();
254     #region memory maps
255 william 652 //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
256     maprange.Add(new MemMap("Physical RAM", 0x00000000, 0x017fffff));
257     maprange.Add(new MemMap("Logical RAM [cached]", 0x80000000, 0x817fffff));
258     maprange.Add(new MemMap("Logical RAM [uncached]", 0xC0000000, 0xC17fffff));
259 william 641 #endregion
260     map = new DeviceMemoryMap(name, maprange);
261     return map;
262     }
263     #endregion
264     #region WII
265     private DeviceMemoryMap CreateWIIMemMap()
266     {
267 william 653 /* http://wiibrew.org/wiki/Memory_Map */
268 william 641 const string name = "WII";
269     DeviceMemoryMap map = new DeviceMemoryMap();
270     List<IMemMap> maprange = new List<IMemMap>();
271     #region memory maps
272 william 653 //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
273     maprange.Add(new MemMap("MEM1 [cached]", 0x80000000, 0x817FFFFF));
274     maprange.Add(new MemMap("MEM1 [uncached]", 0xC0000000, 0xC17FFFFF));
275     maprange.Add(new MemMap("MEM2 [cached]", 0x90000000, 0x93FFFFFF));
276     maprange.Add(new MemMap("MEM2 [uncached]", 0xD0000000, 0xD3FFFFFF));
277     maprange.Add(new MemMap("Hollywood/Starlet Registers?", 0xCD000000, 0xCD008000));
278 william 641 #endregion
279     map = new DeviceMemoryMap(name, maprange);
280     return map;
281     }
282     #endregion
283 william 628 }
284 william 654 #endregion
285 william 641
286     #region Memory Map Helper Classes
287 william 654 #region IMemMap
288 william 641 internal interface IMemMap
289     {
290     string MapName { get; }
291     string MapStart { get; }
292     string MapEnd { get; }
293     string MapSize { get; }
294     string ToString();
295     }
296 william 654 #endregion
297     #region IDeviceMemoryMap
298 william 641 internal interface IDeviceMemoryMap
299     {
300     string DeviceName { get; }
301     IDictionary<string, IMemMap> MemoryMap { get; }
302     string ToString();
303     }
304 william 654 #endregion
305     #region MemMap
306 william 641 internal class MemMap : IMemMap
307     {
308     public MemMap() : this(string.Empty, 0, 0) { }
309 william 654 public MemMap(string name) { this.MapName = name; }
310     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) { }
311 william 643 public MemMap(string name, string start, string end, ulong size)
312 william 641 : this(name)
313     {
314     this.MapStart = start;
315     this.MapEnd = end;
316 william 649 ulong _size = size + 1;
317     double t = 1024.0 * 1024.0;
318 william 654 double __size = (double)_size / t;
319 william 649 this.MapSize = string.Format("0x{0}={1:0.000000}MB", _size.ToString("X"), __size);
320 william 641 }
321     #region IMappedMemRange Members
322     public string MapName { get; private set; }
323     public string MapStart { get; private set; }
324     public string MapEnd { get; private set; }
325     public string MapSize { get; private set; }
326 william 654 public override string ToString() { return string.Format("[{0}]==>[{1}-{2}] [{3}]", MapName, MapStart, MapEnd, MapSize); }
327 william 641 #endregion
328     }
329 william 654 #endregion
330     #region DeviceMemoryMap
331 william 641 internal class DeviceMemoryMap : IDeviceMemoryMap
332     {
333     public DeviceMemoryMap() { this.DeviceName = string.Empty; this.MemoryMap = this.MemoryMap = new Dictionary<string, IMemMap>(); }
334     public DeviceMemoryMap(string device, List<IMemMap> memorymap)
335     {
336     this.DeviceName = device;
337     this.MemoryMap = new Dictionary<string, IMemMap>();
338 william 654 foreach (var map in memorymap) { this.MemoryMap.Add(map.MapName, map); }
339 william 641 }
340     #region IDeviceMemoryMap Members
341     public string DeviceName { get; private set; }
342     public IDictionary<string, IMemMap> MemoryMap { get; private set; }
343 william 654 public override string ToString() { return string.Format("[{0}]==>{1} mapped memory range(s)", DeviceName, MemoryMap.Count); }
344 william 641 #endregion
345     }
346     #endregion
347 william 654 #endregion
348 william 628 }

  ViewVC Help
Powered by ViewVC 1.1.22