Ejemplo n.º 1
0
        protected void PostInit()
        {
            using (_exe.EnterExit())
            {
                var areas = new LibWaterboxCore.MemoryArea[256];
                _core.GetMemoryAreas(areas);
                _memoryAreas = areas.Where(a => a.Data != IntPtr.Zero && a.Size != 0)
                               .ToArray();
                _saveramAreas = _memoryAreas.Where(a => (a.Flags & LibWaterboxCore.MemoryDomainFlags.Saverammable) != 0)
                                .ToArray();
                _saveramSize = (int)_saveramAreas.Sum(a => a.Size);

                var memoryDomains = _memoryAreas.Select(a => new LibWaterboxCore.WaterboxMemoryDomain(a, _exe));
                var primaryIndex  = _memoryAreas
                                    .Select((a, i) => new { a, i })
                                    .Single(a => (a.a.Flags & LibWaterboxCore.MemoryDomainFlags.Primary) != 0).i;
                var mdl = new MemoryDomainList(memoryDomains.Cast <MemoryDomain>().ToList());
                mdl.MainMemory = mdl[primaryIndex];
                _serviceProvider.Register <IMemoryDomains>(mdl);

                var sr = _core as ICustomSaveram;
                if (sr != null)
                {
                    _serviceProvider.Register <ISaveRam>(new CustomSaverammer(sr));                    // override the default implementation
                }
                _exe.Seal();
            }
        }
Ejemplo n.º 2
0
        protected void PostInit()
        {
            using (_exe.EnterExit())
            {
                var areas = new LibWaterboxCore.MemoryArea[256];
                _core.GetMemoryAreas(areas);
                _memoryAreas = areas.Where(a => a.Data != IntPtr.Zero && a.Size != 0)
                               .ToArray();

                var memoryDomains = _memoryAreas.Select(a => WaterboxMemoryDomain.Create(a, _exe)).ToList();
                var primaryDomain = memoryDomains
                                    .Where(md => md.Definition.Flags.HasFlag(LibWaterboxCore.MemoryDomainFlags.Primary))
                                    .Single();

                var mdl = new MemoryDomainList(
                    memoryDomains.Cast <MemoryDomain>()
                    .Concat(new[] { _exe.GetPagesDomain() })
                    .ToList()
                    );
                mdl.MainMemory = primaryDomain;
                _serviceProvider.Register <IMemoryDomains>(mdl);

                _saveramAreas = memoryDomains
                                .Where(md => md.Definition.Flags.HasFlag(LibWaterboxCore.MemoryDomainFlags.Saverammable))
                                .ToArray();
                _saveramSize = (int)_saveramAreas.Sum(a => a.Size);

                _exe.Seal();
            }
        }