From 7d99e8162fb6d7fbe99118d4641a9d79e0333699 Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Mon, 1 Jun 2026 11:10:31 +0100 Subject: [PATCH] Small usage simplification with bus mapper --- EightBit/Bus.cs | 2 +- EightBit/MemoryMapping.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/EightBit/Bus.cs b/EightBit/Bus.cs index b78da80..fee5307 100644 --- a/EightBit/Bus.cs +++ b/EightBit/Bus.cs @@ -66,7 +66,7 @@ namespace EightBit protected ref byte Reference(ushort absolute) { var mapped = this.Mapping(absolute); - var offset = (ushort)mapped.Offset(absolute); + var offset = mapped.Offset(absolute); if (mapped.Access != AccessLevel.ReadOnly) { return ref mapped.Memory.Reference(offset); diff --git a/EightBit/MemoryMapping.cs b/EightBit/MemoryMapping.cs index 0a92995..92931d6 100644 --- a/EightBit/MemoryMapping.cs +++ b/EightBit/MemoryMapping.cs @@ -25,7 +25,7 @@ namespace EightBit { } - private readonly int[] _offsets = new int[ushort.MaxValue + 1]; + private readonly ushort[] _offsets = new ushort[ushort.MaxValue + 1]; private readonly Memory _memory; private readonly ushort _begin; private readonly ushort _mask; @@ -39,8 +39,8 @@ namespace EightBit public AccessLevel Access => this._access; - private int CalculateOffset(ushort absolute) => (absolute - this.Begin) & this.Mask; + private ushort CalculateOffset(ushort absolute) => (ushort)((absolute - this.Begin) & this.Mask); - public int Offset(ushort absolute) => this._offsets[absolute]; + public ushort Offset(ushort absolute) => this._offsets[absolute]; } }