Ypsilon.Emulation.Processor.YCPU.WriteMemInt16 C# (CSharp) Method

WriteMemInt16() public method

public WriteMemInt16 ( ushort address, ushort value, SegmentIndex segment ) : void
address ushort
value ushort
segment SegmentIndex
return void
        public void WriteMemInt16(ushort address, ushort value, SegmentIndex segment)
        {
            Segment s = GetSegment(segment);
            if (s == null)
                throw new Exception("Unknown segment referenced in DebugReadMemory");
            if ((address & 0x0001) == 0x0001) {
                // This read is not 16-bit aligned. Two memory accesses needed.
                Cycles += 2;
                s[address] = (byte)(value & 0x00ff);
                s[(ushort)(address + 1)] = (byte)(value >> 8);
            }
            else {
                // This read is 16-bit aligned. Only one memory access is needed.
                Cycles += 1;
                s[address] = (byte)(value & 0x00ff);
                s[(ushort)(address + 1)] = (byte)(value >> 8);
            }
        }