Exemplo n.º 1
0
 public void CpuWriteBE<T>(int addr, T data) where T : struct {
     switch(Type.GetTypeCode(typeof(T))) {
         case TypeCode.Byte:
         case TypeCode.SByte:
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr), (byte) (object) data);
             break;
         case TypeCode.Int16:
         case TypeCode.UInt16:
             ushort u16 = (ushort) (object) data;
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr), (byte) (u16 >> 8));
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr + 1), (byte) (u16 & 0xff));
             break;
         case TypeCode.Int32:
         case TypeCode.UInt32:
             uint u32 = (uint) (object) data;
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr), (byte) (u32 >> 24));
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr + 1), (byte) (u32 >> 16));
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr + 2), (byte) (u32 >> 8));
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr + 3), (byte) (u32 & 0xff));
             break;
         case TypeCode.Int64:
         case TypeCode.UInt64:
             ulong u64 = (ulong) (object) data;
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr), (byte) (u64 >> 56));
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr + 1), (byte) (u64 >> 48));
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr + 2), (byte) (u64 >> 40));
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr + 3), (byte) (u64 >> 32));
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr + 4), (byte) (u64 >> 24));
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr + 5), (byte) (u64 >> 16));
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr + 6), (byte) (u64 >> 8));
             Libgambatte.gambatte_cpuwrite(Handle, (ushort) (addr + 7), (byte) (u64 & 0xff));
             break;
     }
 }
Exemplo n.º 2
0
 // Writes one byte of data to the CPU bus.
 public void CpuWrite(int addr, byte data)
 {
     Libgambatte.gambatte_cpuwrite(Handle, (ushort)addr, data);
 }