public T CpuReadBE <T>(int addr) where T : struct { switch (Type.GetTypeCode(typeof(T))) { case TypeCode.Byte: case TypeCode.SByte: return((T)(object)Libgambatte.gambatte_cpuread(Handle, (ushort)(addr))); case TypeCode.Int16: case TypeCode.UInt16: return((T)(object)(ushort)((Libgambatte.gambatte_cpuread(Handle, (ushort)(addr)) << 8) | (Libgambatte.gambatte_cpuread(Handle, (ushort)(addr + 1))))); case TypeCode.Int32: case TypeCode.UInt32: return((T)(object)(uint)((Libgambatte.gambatte_cpuread(Handle, (ushort)(addr)) << 24) | (Libgambatte.gambatte_cpuread(Handle, (ushort)(addr + 1)) << 16) | (Libgambatte.gambatte_cpuread(Handle, (ushort)(addr + 2)) << 8) | (Libgambatte.gambatte_cpuread(Handle, (ushort)(addr + 3))))); case TypeCode.Int64: case TypeCode.UInt64: return((T)(object)(ulong)((Libgambatte.gambatte_cpuread(Handle, (ushort)(addr)) << 56) | (Libgambatte.gambatte_cpuread(Handle, (ushort)(addr + 1)) << 48) | (Libgambatte.gambatte_cpuread(Handle, (ushort)(addr + 2)) << 40) | (Libgambatte.gambatte_cpuread(Handle, (ushort)(addr + 3)) << 32) | (Libgambatte.gambatte_cpuread(Handle, (ushort)(addr + 4)) << 24) | (Libgambatte.gambatte_cpuread(Handle, (ushort)(addr + 5)) << 16) | (Libgambatte.gambatte_cpuread(Handle, (ushort)(addr + 6)) << 8) | (Libgambatte.gambatte_cpuread(Handle, (ushort)(addr + 7))))); default: return(default); } }
// Reads one byte of data from the CPU bus. public byte CpuRead(int addr) { return(Libgambatte.gambatte_cpuread(Handle, (ushort)addr)); }