Example #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();

                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>().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);

                var sr = _core as ICustomSaveram;
                if (sr != null)
                {
                    _serviceProvider.Register <ISaveRam>(new CustomSaverammer(sr));                    // override the default implementation
                }
                _exe.Seal();
            }
        }
Example #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();
            }
        }
Example #3
0
 protected T PreInit <T>(WaterboxOptions options)
     where T : LibWaterboxCore
 {
     options.Path ??= CoreComm.CoreFileProvider.DllPath();
     _exe = new WaterboxHost(options);
     using (_exe.EnterExit())
     {
         var ret = BizInvoker.GetInvoker <T>(_exe, _exe, CallingConventionAdapters.Waterbox);
         _core = ret;
         return(ret);
     }
 }
Example #4
0
        protected T PreInit <T>(WaterboxOptions options, IEnumerable <Delegate> allExtraDelegates = null)
            where T : LibWaterboxCore
        {
            options.Path ??= CoreComm.CoreFileProvider.DllPath();
            _exe = new WaterboxHost(options);
            var delegates = new Delegate[] { _inputCallback }.AsEnumerable();

            if (allExtraDelegates != null)
            {
                delegates = delegates.Concat(allExtraDelegates);
            }
            using (_exe.EnterExit())
            {
                var ret = BizInvoker.GetInvoker <T>(_exe, _exe, CallingConventionAdapters.MakeWaterbox(delegates, _exe));
                _core = ret;
                return(ret);
            }
        }