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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.EmuMMAPPlugin/EmuMEMMapDockControl.cs	2013/06/08 22:15:48	644
+++ trunk/RomCheater.EmuMMAPPlugin/EmuMEMMapDockControl.cs	2013/06/09 00:40:20	654
@@ -10,6 +10,7 @@
 
 namespace RomCheater.EmuMMAPPlugin
 {
+    #region EmuMEMMapDockControl
     public partial class EmuMEMMapDockControl : DockContent
     {
         private List<DeviceMemoryMap> DeviceMemoryMaps = new List<DeviceMemoryMap>();
@@ -39,7 +40,6 @@
         private void CreateMaps()
         {
             var map = new DeviceMemoryMap();
-
             #region NES
             map = CreateNESMemMap();
             DeviceMemoryMaps.Add(map);
@@ -68,17 +68,38 @@
             map = CreateWIIMemMap();
             DeviceMemoryMaps.Add(map);
             #endregion
-            map = null;
+            map = null; // free memory
         }
-
         #region NES
         private DeviceMemoryMap CreateNESMemMap()
         {
+            /* http://en.wikibooks.org/wiki/NES_Programming */
             const string name = "NES";
-            DeviceMemoryMap map = new DeviceMemoryMap();            
+            DeviceMemoryMap map = new DeviceMemoryMap();
             List<IMemMap> maprange = new List<IMemMap>();
             #region memory maps
-            maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            maprange.Add(new MemMap("Zero Page", 0x0000, 0x00FF));
+            maprange.Add(new MemMap("Stack", 0x0100, 0x01FF));
+            maprange.Add(new MemMap("Ram", 0x0200, 0x07FF));
+
+            // mirror
+            maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror1", 0x0800, 0x0FFF));
+            // mirror
+            maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror2", 0x1000, 0x17FF));
+            // mirror
+            maprange.Add(new MemMap("ZeroPage/Stack/Ram Mirror3", 0x1800, 0x1FFF));
+
+            maprange.Add(new MemMap("IO Reg1", 0x2000, 0x2007));
+            maprange.Add(new MemMap("IO reg1 mirror - repeated", 0x2000, 0x3FFF));
+            maprange.Add(new MemMap("IO Reg2", 0x4000, 0x401F));
+            maprange.Add(new MemMap("Expansion ROM", 0x4020, 0x5FFF));
+            maprange.Add(new MemMap("SRAM", 0x6000, 0x7FFF));
+            maprange.Add(new MemMap("PRG-ROM", 0x8000, 0xFFFF));
+
+            maprange.Add(new MemMap("Address of NMI Interrupt handler", 0xFFFA, 0xFFFB));
+            maprange.Add(new MemMap("Address of Power on reset handler", 0xFFFC, 0xFFFD));
+            maprange.Add(new MemMap("Address of BRK handler routine", 0xFFFE, 0xFFFF));
             #endregion
             map = new DeviceMemoryMap(name, maprange);
             return map;
@@ -87,11 +108,15 @@
         #region SNES
         private DeviceMemoryMap CreateSNESMemMap()
         {
+            /* http://www.emulatronia.com/doctec/consolas/snes/SNESMem.txt */
             const string name = "SNES";
             DeviceMemoryMap map = new DeviceMemoryMap();
             List<IMemMap> maprange = new List<IMemMap>();
             #region memory maps
-            maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            maprange.Add(new MemMap("LowRAM", 0x0000, 0x1fff));
+            maprange.Add(new MemMap("HighRAM", 0x2000, 0x7fff));
+            maprange.Add(new MemMap("Expanded RAM", 0x8000, 0xffff));
             #endregion
             map = new DeviceMemoryMap(name, maprange);
             return map;
@@ -100,26 +125,32 @@
         #region PS1
         private DeviceMemoryMap CreatePS1MemMap()
         {
+            /* http://rveach.romhack.org/PSXInfo/psx%20hardware%20info.txt */
             const string name = "PS1";
             DeviceMemoryMap map = new DeviceMemoryMap();
             List<IMemMap> maprange = new List<IMemMap>();
             #region memory maps
-            maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
-            #endregion
+            //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));            
             maprange.Add(new MemMap("Kernel Memory", 0x00000000, 0x0000ffff));
-            maprange.Add(new MemMap("User Memory", 0x00010000, 0x001fffff));
+            maprange.Add(new MemMap("User Memory", 0x00010000, 0x001FFFFF));
             maprange.Add(new MemMap("Parallel Port", 0x1f000000, 0x1f00ffff));
             maprange.Add(new MemMap("Scratch Pad", 0x1f800000, 0x1f8003ff));
             maprange.Add(new MemMap("HW Registers", 0x1f801000, 0x1f802fff));
+            maprange.Add(new MemMap("BIOS", 0x1FC00000, 0x1FC7FFFF));
+
             maprange.Add(new MemMap("Kernel & User Memory (cached)", 0x80000000, 0x801fffff));
             maprange.Add(new MemMap("Kernel & User Memory (uncached)", 0xa0000000, 0xa01fffff));
-            maprange.Add(new MemMap("BIOS", 0xbfc00000, 0xbfc7ffff));
+
+            #endregion
+            map = new DeviceMemoryMap(name, maprange);
             return map;
         }
         #endregion
         #region PS2
         private DeviceMemoryMap CreatePS2MemMap()
         {
+            /* http://psx-scene.com/forums/attachments/f19/17285d1280158606-ps2-memory-hardware-mapped-registers-layout-ps2-memory-hardware-mapped-registers-layout.txt */
+            /* http://psx-scene.com/forums/f19/ps2-memory-hardware-mapped-registers-layout-64760/ */
             const string name = "PS2";
             DeviceMemoryMap map = new DeviceMemoryMap();
             List<IMemMap> maprange = new List<IMemMap>();
@@ -146,11 +177,17 @@
         #region N64
         private DeviceMemoryMap CreateN64MemMap()
         {
+            /* http://n64.icequake.net/doc/n64intro/kantan/step1/1-4.html */
             const string name = "N64";
             DeviceMemoryMap map = new DeviceMemoryMap();
             List<IMemMap> maprange = new List<IMemMap>();
             #region memory maps
-            maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            maprange.Add(new MemMap("KUSEG [TLB Map]", 0x00000000, 0x7fffffff));
+            maprange.Add(new MemMap("KSEG0 [Ram cached]", 0x80000000, 0x9fffffff));
+            maprange.Add(new MemMap("KSEG1 [Ram uncached]", 0xa0000000, 0xbfffffff));
+            maprange.Add(new MemMap("KSSEG [TLB Map]", 0xc0000000, 0xdfffffff));
+            maprange.Add(new MemMap("KSEG3 [TLB Map]", 0xe0000000, 0xffffffff));
             #endregion
             map = new DeviceMemoryMap(name, maprange);
             return map;
@@ -159,11 +196,15 @@
         #region NGC
         private DeviceMemoryMap CreateNGCMemMap()
         {
+            /* http://hitmen.c02.at/files/yagcd/yagcd/chap4.html#sec4 */
             const string name = "NGC";
             DeviceMemoryMap map = new DeviceMemoryMap();
             List<IMemMap> maprange = new List<IMemMap>();
             #region memory maps
-            maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            maprange.Add(new MemMap("Physical RAM", 0x00000000, 0x017fffff));
+            maprange.Add(new MemMap("Logical RAM [cached]", 0x80000000, 0x817fffff));
+            maprange.Add(new MemMap("Logical RAM [uncached]", 0xC0000000, 0xC17fffff));
             #endregion
             map = new DeviceMemoryMap(name, maprange);
             return map;
@@ -172,19 +213,27 @@
         #region WII
         private DeviceMemoryMap CreateWIIMemMap()
         {
+            /* http://wiibrew.org/wiki/Memory_Map */
             const string name = "WII";
             DeviceMemoryMap map = new DeviceMemoryMap();
             List<IMemMap> maprange = new List<IMemMap>();
             #region memory maps
-            maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            //maprange.Add(new MemMap(string.Format("{0}_test", name), 0, 0));
+            maprange.Add(new MemMap("MEM1 [cached]", 0x80000000, 0x817FFFFF));
+            maprange.Add(new MemMap("MEM1 [uncached]", 0xC0000000, 0xC17FFFFF));
+            maprange.Add(new MemMap("MEM2 [cached]", 0x90000000, 0x93FFFFFF));
+            maprange.Add(new MemMap("MEM2 [uncached]", 0xD0000000, 0xD3FFFFFF));
+            maprange.Add(new MemMap("Hollywood/Starlet Registers?", 0xCD000000, 0xCD008000));
             #endregion
             map = new DeviceMemoryMap(name, maprange);
             return map;
         }
         #endregion
     }
+    #endregion
 
     #region Memory Map Helper Classes
+    #region IMemMap
     internal interface IMemMap
     {
         string MapName { get; }
@@ -193,40 +242,41 @@
         string MapSize { get; }
         string ToString();
     }
+    #endregion
+    #region IDeviceMemoryMap
     internal interface IDeviceMemoryMap
     {
         string DeviceName { get; }
         IDictionary<string, IMemMap> MemoryMap { get; }
         string ToString();
     }
-
+    #endregion
+    #region MemMap
     internal class MemMap : IMemMap
     {
         public MemMap() : this(string.Empty, 0, 0) { }
-        public MemMap(string name)
-        {
-            this.MapName = name;
-        }
-        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) { }
+        public MemMap(string name) { this.MapName = name; }
+        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) { }
         public MemMap(string name, string start, string end, ulong size)
             : this(name)
         {
             this.MapStart = start;
             this.MapEnd = end;
-            this.MapSize = string.Format("0x{0}={1:0.00}MB", size.ToString("X"), ((double)size / (1024.0 * 1024.0)));
+            ulong _size = size + 1;
+            double t = 1024.0 * 1024.0;
+            double __size = (double)_size / t;
+            this.MapSize = string.Format("0x{0}={1:0.000000}MB", _size.ToString("X"), __size);
         }
         #region IMappedMemRange Members
         public string MapName { get; private set; }
         public string MapStart { get; private set; }
         public string MapEnd { get; private set; }
         public string MapSize { get; private set; }
-        public override string ToString()
-        {
-            return string.Format("[{0}]==>[{1}-{2}] [{3}]", MapName, MapStart, MapEnd, MapSize);
-        }
+        public override string ToString() { return string.Format("[{0}]==>[{1}-{2}] [{3}]", MapName, MapStart, MapEnd, MapSize); }
         #endregion
     }
-
+    #endregion
+    #region DeviceMemoryMap
     internal class DeviceMemoryMap : IDeviceMemoryMap
     {
         public DeviceMemoryMap() { this.DeviceName = string.Empty; this.MemoryMap = this.MemoryMap = new Dictionary<string, IMemMap>(); }
@@ -234,24 +284,14 @@
         {
             this.DeviceName = device;
             this.MemoryMap = new Dictionary<string, IMemMap>();
-
-            foreach (var map in memorymap)
-            {
-                this.MemoryMap.Add(map.MapName, map);
-            }
-
+            foreach (var map in memorymap) { this.MemoryMap.Add(map.MapName, map); }
         }
-
         #region IDeviceMemoryMap Members
         public string DeviceName { get; private set; }
         public IDictionary<string, IMemMap> MemoryMap { get; private set; }
-        public override string ToString()
-        {
-            return string.Format("[{0}]==>{1} mapped memory range(s)", DeviceName, MemoryMap.Count);
-        }
+        public override string ToString() { return string.Format("[{0}]==>{1} mapped memory range(s)", DeviceName, MemoryMap.Count); }
         #endregion
     }
-
+    #endregion
     #endregion
 }
-

 

  ViewVC Help
Powered by ViewVC 1.1.22