예제 #1
0
        public void DEV9_ReadDMA8Mem(System.IO.UnmanagedMemoryStream pMem, int size)
        {
            size >>= 1;

            Log_Verb("*DEV9readDMA8Mem: size " + size.ToString("X"));
            //if (size == 0) return; //What?
            //Log_Info("rDMA");
            long ptr = pMem.Position;

            if (spd.dmaSMAP)
            {
                smap.SMAP_ReadDMA8Mem(pMem, size);
            }
            else
            {
                //ata.ATAreadDMA8Mem(pMem, size);
                spd.SPEEDreadDMA8Mem(pMem, size);
            }

            long delta = pMem.Position - ptr;

            if (delta == 0)
            {
                Log_Error("rDMA No Data Read");
            }
        }
예제 #2
0
        public static void smap_readDMA8Mem(System.IO.UnmanagedMemoryStream pMem, int size)
        {
            if ((DEV9Header.dev9Ru16((int)DEV9Header.SMAP_R_RXFIFO_CTRL) & DEV9Header.SMAP_RXFIFO_DMAEN) != 0)
            {
                int pMemAddr  = 0;
                int valueSize = 4;
                DEV9Header.dev9Wu32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR, DEV9Header.dev9Ru32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR) & 16383);
                size >>= 1;
                DEV9.DEV9_LOG(" * * SMAP DMA READ START: rd_ptr=" + DEV9Header.dev9Ru32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR).ToString() + ", wr_ptr=" + DEV9Header.dev9.rxfifo_wr_ptr.ToString());
                while (size > 0)
                {
                    //*pMem = *((u32*)(DEV9Header.dev9.rxfifo + DEV9Header.dev9Ru32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR)));
                    int    pMemIn      = BitConverter.ToInt32(DEV9Header.dev9.rxfifo, (int)DEV9Header.dev9Ru32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR));
                    byte[] pMemInBytes = BitConverter.GetBytes(pMemIn);
                    pMem.Seek(pMemAddr, System.IO.SeekOrigin.Begin);
                    pMem.Write(pMemInBytes, 0, 4);
                    //End write to pMem
                    pMemAddr += valueSize;//pMem++;
                    DEV9Header.dev9Wu32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR, (DEV9Header.dev9Ru32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR) + 4) & 16383);

                    size -= valueSize;
                }
                DEV9.DEV9_LOG(" * * SMAP DMA READ END:   rd_ptr=" + DEV9Header.dev9Ru32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR).ToString() + ", wr_ptr=" + DEV9Header.dev9.rxfifo_wr_ptr.ToString());

                DEV9Header.dev9Wu16((int)DEV9Header.SMAP_R_RXFIFO_CTRL, (UInt16)(DEV9Header.dev9Ru16((int)DEV9Header.SMAP_R_RXFIFO_CTRL) & ~DEV9Header.SMAP_RXFIFO_DMAEN));
            }
        }
예제 #3
0
        public static void smap_writeDMA8Mem(System.IO.UnmanagedMemoryStream pMem, int size)
        {
            if ((DEV9Header.dev9Ru16((int)DEV9Header.SMAP_R_TXFIFO_CTRL) & DEV9Header.SMAP_TXFIFO_DMAEN) != 0)
            {
                int pMemAddr  = 0;
                int valueSize = 4;
                DEV9Header.dev9Wu32((int)DEV9Header.SMAP_R_TXFIFO_WR_PTR, DEV9Header.dev9Ru32((int)DEV9Header.SMAP_R_TXFIFO_WR_PTR) & 16383);
                size >>= 1;
                DEV9.DEV9_LOG(" * * SMAP DMA WRITE START: wr_ptr=" + DEV9Header.dev9Ru32((int)DEV9Header.SMAP_R_TXFIFO_WR_PTR).ToString() + ", rd_ptr=" + DEV9Header.dev9.txfifo_rd_ptr.ToString());
                while (size > 0)
                {
                    pMem.Seek(pMemAddr, System.IO.SeekOrigin.Begin);
                    byte[] valueBytes = new byte[4];
                    pMem.Read(valueBytes, 0, 4);
                    int value = BitConverter.ToInt32(valueBytes, 0); //*pMem;
                    //	value=(value<<24)|(value>>24)|((value>>8)&0xFF00)|((value<<8)&0xFF0000);
                    pMemAddr += valueSize;                           //pMem++;

                    //*((u32*)(dev9.txfifo + dev9Ru32(SMAP_R_TXFIFO_WR_PTR))) = value;
                    byte[] valueBytes2 = BitConverter.GetBytes(value);
                    Utils.memcpy(ref DEV9Header.dev9.txfifo, (int)DEV9Header.dev9Ru32((int)DEV9Header.SMAP_R_TXFIFO_WR_PTR), valueBytes2, 0, 4);
                    //End
                    DEV9Header.dev9Wu32((int)DEV9Header.SMAP_R_TXFIFO_WR_PTR, (DEV9Header.dev9Ru32((int)DEV9Header.SMAP_R_TXFIFO_WR_PTR) + 4) & 16383);
                    size -= valueSize;
                }
                DEV9.DEV9_LOG(" * * SMAP DMA WRITE END:   wr_ptr=" + DEV9Header.dev9Ru32((int)DEV9Header.SMAP_R_TXFIFO_WR_PTR).ToString() + ", rd_ptr=" + DEV9Header.dev9.txfifo_rd_ptr.ToString());

                DEV9Header.dev9Wu16((int)DEV9Header.SMAP_R_TXFIFO_CTRL, (UInt16)(DEV9Header.dev9Ru16((int)DEV9Header.SMAP_R_TXFIFO_CTRL) & ~DEV9Header.SMAP_TXFIFO_DMAEN));
            }
        }
예제 #4
0
        public void DEV9_WriteDMA8Mem(System.IO.UnmanagedMemoryStream pMem, int size)
        {
            size >>= 1;

            Log_Verb("*DEV9writeDMA8Mem: size " + size.ToString("X"));
            //Log_Info("wDMA");
            long ptr = pMem.Position;

            if (spd.dmaSMAP)
            {
                smap.SMAP_WriteDMA8Mem(pMem, size);
            }
            else
            {
                //ata.ATAwriteDMA8Mem(pMem, size);
                spd.SPEEDwriteDMA8Mem(pMem, size);
            }

            long delta = pMem.Position - ptr;

            if (delta == 0)
            {
                Log_Error("wDMA No Data Written");
            }
        }
예제 #5
0
        public void SMAP_ReadDMA8Mem(System.IO.UnmanagedMemoryStream pMem, int size)
        {
            if ((dev9.Dev9Ru16((int)DEV9Header.SMAP_R_RXFIFO_CTRL) & DEV9Header.SMAP_RXFIFO_DMAEN) != 0)
            {
                int pMemAddr  = 0;
                int valueSize = 4;
                dev9.Dev9Wu32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR, dev9.Dev9Ru32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR) & 16383);
                //size >>= 1;
                Log_Verb("DMA READ START: rd_ptr=" + dev9.Dev9Ru32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR).ToString() + ", wr_ptr=" + dev9.rxFifoWrPtr.ToString());
                Log_Info("rSMAP");

                while (size > 0)
                {
                    //*pMem = *((u32*)(DEV9Header.dev9.rxfifo + DEV9Header.dev9Ru32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR)));
                    int    pMemIn      = BitConverter.ToInt32(dev9.rxFifo, (int)dev9.Dev9Ru32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR));
                    byte[] pMemInBytes = BitConverter.GetBytes(pMemIn);
                    pMem.Seek(pMemAddr, System.IO.SeekOrigin.Begin);
                    pMem.Write(pMemInBytes, 0, 4);
                    //End write to pMem
                    pMemAddr += valueSize;//pMem++;
                    dev9.Dev9Wu32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR, (dev9.Dev9Ru32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR) + 4) & 16383);

                    size -= valueSize;
                }
                Log_Verb("DMA READ END: rd_ptr=" + dev9.Dev9Ru32((int)DEV9Header.SMAP_R_RXFIFO_RD_PTR).ToString() + ", wr_ptr=" + dev9.rxFifoWrPtr.ToString());

                dev9.Dev9Wu16((int)DEV9Header.SMAP_R_RXFIFO_CTRL, (UInt16)(dev9.Dev9Ru16((int)DEV9Header.SMAP_R_RXFIFO_CTRL) & ~DEV9Header.SMAP_RXFIFO_DMAEN));
            }
        }
예제 #6
0
        public SwapBuffer(IntPtr ptr, int size)
        {
            _readStream  = new System.IO.UnmanagedMemoryStream((byte *)ptr.ToPointer(), size, size, System.IO.FileAccess.Read);
            _writeStream = new System.IO.UnmanagedMemoryStream((byte *)ptr.ToPointer(), size, size, System.IO.FileAccess.Write);

            _reader = new BinaryReader(new System.IO.BinaryReader(_readStream));
            _writer = new BinaryWriter(new System.IO.BinaryWriter(_writeStream));
        }
예제 #7
0
        public SoundPlayer StartMusic(System.IO.UnmanagedMemoryStream song)
        {
            SoundPlayer Music = new SoundPlayer
            {
                Stream = song
            };

            Music.PlayLooping();
            return(Music);
        }
예제 #8
0
        public override void DEV9writeDMA8Mem(System.IO.UnmanagedMemoryStream pMem, int size)
        {
            DEV9_LOG("*DEV9writeDMA8Mem: size " + size.ToString("X"));
            Console.Error.WriteLine("wDMA");

            smap.smap_writeDMA8Mem(pMem, size);
            //#ifdef ENABLE_ATA
            //    ata_writeDMA8Mem(pMem,size);
            //#endif
        }
예제 #9
0
        public static void ShutdownApplication(System.IO.UnmanagedMemoryStream audio)
        {
            System.Threading.Thread.Sleep(500);
            System.IO.Stream audioPlay = audio;
            stopsound = new System.Media.SoundPlayer(audioPlay);
            stopsound.PlaySync();

            System.Threading.Thread.Sleep(500);
            Environment.Exit(0);
            //Application.Exit();
        }
예제 #10
0
 public static byte[] Unsafe_IntPtrToByte(IntPtr source, Int32 byteLength)
 {
     unsafe
     {
         byte[] data     = new byte[byteLength];
         void * tempData = source.ToPointer();
         using (System.IO.UnmanagedMemoryStream tempUMS = new System.IO.UnmanagedMemoryStream((byte *)tempData, byteLength))
         {
             tempUMS.Read(data, 0, byteLength);
         }
         return(data);
     }
 }
예제 #11
0
        public static int GetSoundLength(System.IO.UnmanagedMemoryStream song)
        {
            StringBuilder lengthBuf = new StringBuilder(32);

            mciSendString(string.Format("open \"{0}\" type waveaudio alias wave", song), null, 0, IntPtr.Zero);
            mciSendString("status wave length", lengthBuf, lengthBuf.Capacity, IntPtr.Zero);
            mciSendString("close wave", null, 0, IntPtr.Zero);

            int length = 0;

            int.TryParse(lengthBuf.ToString(), out length);

            return(length);
        }
예제 #12
0
 public static void PlaySound(System.IO.UnmanagedMemoryStream stream, bool isLoop = false)
 {
     if (stream != null)
     {
         stream.Position    = 0;
         soundPlayer.Stream = null;
         soundPlayer.Stream = stream;
         if (isLoop)
         {
             soundPlayer.PlayLooping();
         }
         else
         {
             soundPlayer.Play();
         }
     }
 }
예제 #13
0
 public void SetLabelText(System.IO.UnmanagedMemoryStream sound)
 {
     if (this.labNumber.InvokeRequired)
     {
         SetLabelTextCallback d = new SetLabelTextCallback(SetLabelText);
         Invoke(d, new object[] { sound });
     }
     else
     {
         butPositive.Enabled = true;
         butNegative.Enabled = true;
         SoundPlayer player = new SoundPlayer();
         sound.Position = 0;
         player.Stream  = null;
         player.Stream  = sound;
         player.Play();
     }
 }
        static unsafe void ProcessTextInputEvent(Sdl2NativeWindow window, TextInputEvent ev)
        {
            var keyPress = window.KeyPress;

            if (keyPress != null)
            {
                var   length = 0;
                byte *pText  = ev.Text;
                while (*pText != 0)
                {
                    length++;
                    pText++;
                }
                using (var stream = new System.IO.UnmanagedMemoryStream(ev.Text, length))
                    using (var reader = new System.IO.StreamReader(stream, Encoding.UTF8))
                    {
                        var text = reader.ReadToEnd();
                        foreach (var c in text)
                        {
                            keyPress(window, new KeyPressEventArgs(c));
                        }
                    }
            }
        }
예제 #15
0
 public deal(System.IO.UnmanagedMemoryStream stream_)
 {
     Data   = stream_;
     offset = 0;
 }
예제 #16
0
        public async Task <object> GetNodes()
        {
            EnsureIsAdmin();
            var ls = new Dictionary <uint, NodeInfo>(); //key=ip

            //1.扫描节点
            var peerStateParser = new Google.Protobuf.MessageParser <PeerState>(() => new PeerState());

            await ScanNodes((kp, ks, vp, vs) =>
            {
                unsafe
                {
                    uint peerId     = 0;
                    byte *peerIdPtr = (byte *)&peerId;
                    byte *keyPtr    = (byte *)kp.ToPointer();
                    peerIdPtr[0]    = keyPtr[2];
                    peerIdPtr[1]    = keyPtr[1];

                    var stream    = new System.IO.UnmanagedMemoryStream((byte *)vp.ToPointer(), vs);
                    var peerState = peerStateParser.ParseFrom(stream);
                    stream.Dispose();

                    var ip        = peerState.Endpoint.Address;
                    byte *ipPtr   = (byte *)&ip;
                    var ipAddress = $"{ipPtr[3]}.{ipPtr[2]}.{ipPtr[1]}.{ipPtr[0]}";
                    var nodeInfo  = new NodeInfo
                    {
                        PeerId    = peerId.ToString("X2"),
                        IPAddress = ipAddress,
                        Port      = (ushort)peerState.Endpoint.Port
                    };
                    ls.Add(ip, nodeInfo);
                }
            });

            //2.获取MetaNodes
            var        peerConfigParser = new Google.Protobuf.MessageParser <PeerConfig>(() => new PeerConfig());
            IntPtr     configData       = NativeApi.GetPeerConfigData();
            var        configDataPtr    = NativeApi.GetStringData(configData);
            var        configDataSize   = NativeApi.GetStringSize(configData);
            PeerConfig peerConfig;

            unsafe
            {
                var stream = new System.IO.UnmanagedMemoryStream((byte *)configDataPtr.ToPointer(), (long)configDataSize);
                peerConfig = peerConfigParser.ParseFrom(stream);
                stream.Dispose();
            }
            NativeApi.FreeNativeString(configData);
            foreach (var meta in peerConfig.MetaNodes)
            {
                ls[meta.Endpoint.Address].IsMeta     = true;
                ls[meta.Endpoint.Address].RaftNodes += 1;
            }

            //3.扫描RaftGroups
            var groupParser = new Google.Protobuf.MessageParser <RaftGroupInfo>(() => new RaftGroupInfo());

            await ScanRaftGroups((kp, ks, vp, vs) =>
            {
                unsafe
                {
                    var stream    = new System.IO.UnmanagedMemoryStream((byte *)vp.ToPointer(), vs);
                    var groupInfo = groupParser.ParseFrom(stream);
                    stream.Dispose();

                    foreach (var peer in groupInfo.Nodes)
                    {
                        ls[peer.Endpoint.Address].RaftNodes += 1;
                    }
                }
            });

            return(ls.Values.ToArray());
        }
예제 #17
0
파일: DEV9.cs 프로젝트: TheLastRar/CLR-DEV9
 public static unsafe void DEV9writeDMA8Mem(byte* memPointer, int size)
 {
     try
     {
         System.IO.UnmanagedMemoryStream pMem = new System.IO.UnmanagedMemoryStream(memPointer, size, size, System.IO.FileAccess.Read);
         dev9.DEV9_WriteDMA8Mem(pMem, size);
     }
     catch (Exception e)
     {
         CLR_PSE_PluginLog.MsgBoxError(e);
         throw;
     }
 }
예제 #18
0
 public void setAlarmFile(System.IO.UnmanagedMemoryStream file)
 {
     alarmFile = file;
 }
예제 #19
0
 public ORDERBOOK(System.IO.UnmanagedMemoryStream stream_, int offset_)
 {
     Data   = stream_;
     offset = offset_;
 }
예제 #20
0
 public position(System.IO.UnmanagedMemoryStream stream_)
 {
     Data   = stream_;
     offset = 0;
 }
예제 #21
0
 public multileg_orders_log(System.IO.UnmanagedMemoryStream stream_)
 {
     Data = stream_;
 }
예제 #22
0
 static unsafe void ProcessTextInputEvent(Sdl2NativeWindow window, TextInputEvent ev)
 {
     var keyPress = window.KeyPress;
     if (keyPress != null)
     {
         var length = 0;
         byte* pText = ev.Text;
         while (*pText != 0)
         {
             length++;
             pText++;
         }
         using (var stream = new System.IO.UnmanagedMemoryStream(ev.Text, length))
         using (var reader = new System.IO.StreamReader(stream, Encoding.UTF8))
         {
             var text = reader.ReadToEnd();
             foreach (var c in text)
             {
                 keyPress(window, new KeyPressEventArgs(c));
             }
         }
     }
 }
예제 #23
0
 public orders_aggr(System.IO.UnmanagedMemoryStream stream_, int offset_)
 {
     Data   = stream_;
     offset = offset_;
 }
예제 #24
0
 public deal(System.IO.UnmanagedMemoryStream stream_, int offset_)
 {
     Data   = stream_;
     offset = offset_;
 }
예제 #25
0
 public void SetSounds(System.IO.UnmanagedMemoryStream pEntry, System.IO.UnmanagedMemoryStream pClick)
 {
     this.enterSound = pEntry;
     this.clickSound = pClick;
 }
예제 #26
0
 public SECURITIES(System.IO.UnmanagedMemoryStream stream_, int offset_)
 {
     Data   = stream_;
     offset = offset_;
 }
예제 #27
0
 public sys_events(System.IO.UnmanagedMemoryStream stream_)
 {
     Data = stream_;
 }
예제 #28
0
 public ALL_TRADES(System.IO.UnmanagedMemoryStream stream_, int offset_)
 {
     Data   = stream_;
     offset = offset_;
 }
예제 #29
0
 public heartbeat(System.IO.UnmanagedMemoryStream stream_)
 {
     Data = stream_;
 }
예제 #30
0
        public void playSimpleSound(System.IO.UnmanagedMemoryStream s)
        {
            simpleSound = new SoundPlayer(s);

            simpleSound.Play();
        }
예제 #31
0
 public void playInLoop(System.IO.UnmanagedMemoryStream s)
 {
     simpleSound = new SoundPlayer(s);
     simpleSound.PlayLooping();
 }
예제 #32
0
 public Alarm(System.IO.UnmanagedMemoryStream file)
 {
     setAlarmFile(file);
     open();
 }