public void Sgrom_LoadImage() { var sc = new ServiceContainer(); var cfgSvc = mr.Stub<IConfigurationService>(); var openv = mr.Stub<OperatingEnvironment>(); var diagSvc = mr.StrictMock<IDiagnosticsService>(); var arch = new M68kArchitecture(); var platform = new SegaGenesisPlatform(sc, arch); cfgSvc.Expect(c => c.GetArchitecture("m68k")).Return(arch); cfgSvc.Expect(c => c.GetEnvironment("sega-genesis")).Return(openv); openv.Expect(o => o.Load(sc, arch)).Return(platform); sc.AddService<IConfigurationService>(cfgSvc); sc.AddService<IDiagnosticsService>(diagSvc); Given_AbsoluteMemoryMap(platform); mr.ReplayAll(); var rawBytes = new byte[0x300]; var sgrom = new RomLoader(sc, "foo.bin", rawBytes); var program = sgrom.Load(Address.Ptr32(0)); var romSegment = program.SegmentMap.Segments.Values.First(); Assert.IsNotNull(romSegment.MemoryArea, "ROM image should have been loaded into first segment"); Assert.AreSame(rawBytes, romSegment.MemoryArea.Bytes, "ROM image should have been loaded into first segment"); Assert.AreEqual(rawBytes.Length, romSegment.ContentSize); var ramSegment = program.SegmentMap.Segments.Values.First(s => s.Name == ".data"); Assert.IsNotNull(ramSegment.MemoryArea, "RAM segment should have a MemoryArea"); }
private void Given_AbsoluteMemoryMap(SegaGenesisPlatform platform) { platform.MemoryMap = new MemoryMap_v1 { Segments = new MemorySegment_v1[] { new MemorySegment_v1 { Address = "0", Name= ".text", Attributes = "rx", Size = "400000", }, new MemorySegment_v1 { Address = "E00000", Name= ".data", Attributes = "rwx", Size = "200000", }, } }; }