コード例 #1
0
 public MessageHub(IUserService userService, IMemoryAccess memory, IMessenger messenger, IGameService gameService)
 {
     _userService  = userService;
     _memoryAccess = memory;
     _messenger    = messenger;
     _gameService  = gameService;
 }
コード例 #2
0
        public unsafe Tree([NotNull] Allocator alloc, [NotNull] IMemoryAccess mem)
        {
            _alloc = alloc;
            _mem   = mem;

            NodeSize = NODE_HEAD_SIZE + sizeof(TElement);

            // Make the root node
            var res = _alloc.Alloc(NodeSize);

            if (!res.Success)
            {
                Valid = false;
                return;
            }

            // Set initial values
            Root = res.Value;
            var rootHead = new TreeNodeHead
            {
                FirstChildPtr  = -1,
                NextSiblingPtr = -1,
                ParentPtr      = -1
            };

            _mem.WriteC <TreeNodeHead, TElement>(Root, rootHead, default);

            Valid = true;
        }
コード例 #3
0
        /// <summary>
        /// Start a new allocator.
        /// This tracks memory usage, but does not do any physical work
        /// </summary>
        /// <param name="start">Start of space (bytes) available to the allocator. Some will be reserved for arena tracking</param>
        /// <param name="limit">Maximum memory before an out-of-memory condition is flagged (bytes)</param>
        /// <param name="memory">Access to real or simulated memory</param>
        public Allocator(long start, long limit, [NotNull] IMemoryAccess memory)
        {
            _limit  = limit;
            _memory = memory;

            // with 64KB arenas (ushort) and 1GB of RAM, we get 16384 arenas.
            // recording only heads and refs would take 64KB of management space
            // recording heads, refs and back-step (an optimisation for very short-lived items) would use 96KB of management space.
            // This seems pretty reasonable.
            _arenaCount   = (int)((_limit - _start) / ArenaSize);
            _currentArena = 0;

            // Allow space for arena tables, store adjusted base
            var sizeOfTables = sizeof(ushort) * _arenaCount;

            _headsPtr     = start;
            _refCountsPtr = start + sizeOfTables;

            _start = start + (sizeOfTables * 2);

            // zero-out the tables
            var zptr = _headsPtr;

            while (zptr < _start)
            {
                _memory.Write <ushort>(zptr, 0);
                zptr += sizeof(ushort);
            }
        }
コード例 #4
0
        public static ushort PeekWord(this IMemoryAccess <ushort, byte> memory, ushort address)
        {
            ushort value = memory.Peek(address++);

            value += (ushort)(memory.Peek(address) << 8);
            return(value);
        }
コード例 #5
0
        public MemoryManagementUnit(IMemoryAccess <ushort, byte> rom, IMemoryAccess <ushort, byte> ram, IMemoryAccess <ushort, byte> mikey, IMemoryAccess <ushort, byte> suzy)
        {
            this.Ram   = ram;
            this.Rom   = rom;
            this.Suzy  = suzy;
            this.Mikey = mikey;

            MAPCTL = new MemoryMapControl();
        }
コード例 #6
0
        public SystemService(ICpuAccess cpuAccess, IMemoryAccess memoryAccess, IGpuAccess gpuAccess)
        {
            ArgumentMust.NotBeNull(() => cpuAccess);
            ArgumentMust.NotBeNull(() => memoryAccess);
            ArgumentMust.NotBeNull(() => gpuAccess);

            _cpuAccess    = cpuAccess;
            _memoryAccess = memoryAccess;
            _gpuAccess    = gpuAccess;
        }
コード例 #7
0
ファイル: Vector.cs プロジェクト: i-e-b/SArA
        /// <summary>
        /// A variable length array of variable elements.
        /// Create a new vector base in the first free section
        /// </summary>
        public Vector([NotNull] Allocator alloc, [NotNull] IMemoryAccess mem)
        {
            _alloc = alloc;
            _mem   = mem;

            unsafe
            {
                ElementByteSize = sizeof(TElement);
            }

            // Work out how many elements can fit in an arena
            ChunkHeaderSize = PTR_SIZE;
            var spaceForElements = Allocator.ArenaSize - ChunkHeaderSize; // need pointer space

            ElemsPerChunk = (int)(spaceForElements / ElementByteSize);

            if (ElemsPerChunk <= 1)
            {
                IsValid = false;
                return;
            }

            if (ElemsPerChunk > TARGET_ELEMS_PER_CHUNK)
            {
                ElemsPerChunk = TARGET_ELEMS_PER_CHUNK; // no need to go crazy with small items.
            }
            ChunkBytes = (ushort)(ChunkHeaderSize + (ElemsPerChunk * ElementByteSize));



            // Make a table, which can store a few chunks, and can have a next-chunk-table pointer
            // Each chunk can hold a few elements.
            _skipEntries    = -1;
            _skipTable      = -1;
            _endChunkPtr    = -1;
            _baseChunkTable = -1;
            var res = NewChunk();

            if (!res.Success)
            {
                IsValid = false;
                return;
            }
            _baseChunkTable = res.Value;
            _elementCount   = 0;
            RebuildSkipTable();

            // All done
            IsValid = true;
        }
コード例 #8
0
 public GeoAreaFinder(IMemoryAccess memoryAccess)
 {
     _memoryAccess = memoryAccess;
 }
コード例 #9
0
 /// <summary>
 /// Create a new hash map
 /// </summary>
 /// <param name="size">Initial size</param>
 /// <param name="alloc">Memory allocator</param>
 /// <param name="mem">Memory access</param>
 public TaggedHashMap(uint size, Allocator alloc, IMemoryAccess mem)
 {
     _alloc = alloc;
     _mem   = mem;
     Resize((uint)NextPow2(size), false);
 }
コード例 #10
0
 public Messenger(IMemoryAccess cache, ISender sender, IUserNameValidator nameValidator)
 {
     _cache         = cache;
     _sender        = sender;
     _nameValidator = nameValidator;
 }
コード例 #11
0
 public GameController(IMemoryAccess memory, IGameService gameService)
 {
     _memoryAccess = memory;
     _gameService  = gameService;
 }
コード例 #12
0
 public Cmos65SC02(IMemoryAccess <ushort, byte> memory, Clock clock)
     : base(memory, clock)
 {
 }
コード例 #13
0
 public GameService(IMemoryAccess memoryAccess, IMessenger messenger, IUserNameValidator nameValidator)
 {
     _memoryAccess  = memoryAccess;
     _messenger     = messenger;
     _nameValidator = nameValidator;
 }
コード例 #14
0
 public PageMemoryManager(IMemoryAccess MemoryAccess, int PageSize)
 {
     _memoryAccess = MemoryAccess;
     _pageSize = PageSize;
     _buffer = new byte[_pageSize];
 }
コード例 #15
0
 public Nmos6502(IMemoryAccess <ushort, byte> memory, Clock clock)
 {
     SystemClock = clock;
     Memory      = memory;
 }
コード例 #16
0
 public Sender(IMemoryAccess cache, IUserService userService)
 {
     _cache       = cache;
     _userService = userService;
 }