private static void displayMessages(eMessage i_Message)
        {
            switch (i_Message)
            {
            case eMessage.DisplayMenu:
                Console.WriteLine(@"Welcome to the garage,
Please choose what you would like to do:
1. Add a new vehicle to the garage.
2. Show a list of vehicle license plates.
3. Change a vehicle status.
4. Inflate tires to the maximum.
5. Fuel a vehicle.
6. Charge an electric vehicle.
7. Display vehicle information.
8. Exit
");
                break;

            case eMessage.InvalidInput:
                Console.WriteLine("Invalid input. Please try again");
                break;

            case eMessage.InvalidSelection:
                Console.WriteLine("Invalid selection. Please try again");
                break;
            }
        }
Пример #2
0
        private void showMessage(eMessage iPilih, string iTitle, string iMessage)
        {
            hideMessageBox();

            switch (iPilih)
            {
            case eMessage.eSuccess:
                mySuccess.Visible      = true;
                lblTitleMySuccess.Text = iTitle;
                lblMySuccess.Text      = iMessage;
                break;

            case eMessage.eWarning:
                myWarning.Visible      = true;
                lblTitleMyWarning.Text = iTitle;
                lblMyWarning.Text      = iMessage;
                break;

            case eMessage.eError:
                myError.Visible      = true;
                lblTitleMyError.Text = iTitle;
                lblMyError.Text      = iMessage;
                break;
            }
        }
Пример #3
0
        private void showMessageModal(eMessage iPilih, string iTitle, string iMessage)
        {
            switch (iPilih)
            {
            case eMessage.eSuccess:
                iTitle = "SUCCESS. " + iTitle;
                break;

            case eMessage.eWarning:
                iTitle = "WARNING!!!. " + iTitle;
                break;

            case eMessage.eError:
                iTitle = "ERROR!!!. " + iTitle;
                break;
            }

            lblMessageModal_Title.Text = iTitle;
            lblMessageModal_Body.Text  = iMessage;

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append(@"<script type='text/javascript'>");
            sb.Append("$('#messageModal').modal('show');");
            sb.Append(@"</script>");
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "messageModalScript", sb.ToString(), false);

            UpdatePanel2.Update();

            bRes = false;
        }
Пример #4
0
        private void invokeOnEndMove(ref eMessage i_OutputMessage)
        {
            EndTurnEventArgs  endUnsuccessfulTurnArgs = new EndTurnEventArgs();
            GameOverEventArgs gameOverArgs            = new GameOverEventArgs();

            if (playerCanPlay(m_ActivePlayerId))
            {
                if (i_OutputMessage == eMessage.EndTurn || i_OutputMessage == eMessage.MustJumpOverAgain)
                {
                    OnUpdateBoard();
                }
                else
                {
                    endUnsuccessfulTurnArgs.Message = i_OutputMessage;
                    OnEndUnsuccessfulTurn(endUnsuccessfulTurnArgs);
                }
            }
            else
            {
                gameOverArgs.Tie    = !playerCanPlay(opponentId);
                gameOverArgs.Winner = opponentId;
                i_OutputMessage     = eMessage.EndGame;
                OnGameOver(gameOverArgs);
            }
        }
Пример #5
0
        bool Handle_BRK(eMessage msg)
        {
            switch (msg)
            {
                default:
                    return false;

                case eMessage.eMessage_BRK_hook_exec:
                    {
                        var addr = brPipe.ReadInt32();
                        ExecHook((uint)addr);
                        break;
                    }
                case eMessage.eMessage_BRK_hook_read:
                    {
                        var addr = brPipe.ReadInt32();
                        ReadHook((uint)addr);
                        break;
                    }
                case eMessage.eMessage_BRK_hook_write:
                    {
                        var addr = brPipe.ReadInt32();
                        var value = brPipe.ReadByte();
                        WriteHook((uint)addr, value);
                        break;
                    }
                case eMessage.eMessage_BRK_hook_nmi:
                    break;
                case eMessage.eMessage_BRK_hook_irq:
                    break;
            } //switch(msg)
            return true;
        }
Пример #6
0
 public ThreadP_Message(long xMessage_ID,eMessage xMessage, delegate_Procedure procedure, object parameterasobject)
 {
     Message = xMessage;
     Message_ID = xMessage_ID;
     m_Procedure = procedure;
     m_ParameterAsObject = parameterasobject;
 }
Пример #7
0
    public override void OnNotify(INotify notify)
    {
        eMessage msgType = (eMessage)notify.MsgCode;

        switch (msgType)
        {
        case eMessage.PageTransition:
        {
            string title = StringUtil.Format("<color=#{0}>{1}</color>", ColorUtility.ToHtmlStringRGBA(Color.blue), "System Message");
            Global.WidgetMgr.ShowMessageBox(title, "Exit Page", eMessageBoxType.OKAndCancel, result =>
                {
                    if (result == true)
                    {
                        Global.SceneMgr.Transition(new SceneTransition(typeof(LoginScene).ToString(), "Login", 0.5f, 0.3f, (code) =>
                        {
                            Global.SceneMgr.LogWarning(StringUtil.Format("Page Transition -> {0}", "LoginPage"));
                        }));
                    }
                    else
                    {
                        title = StringUtil.Format("<color=#{0}>{1}</color>", ColorUtility.ToHtmlStringRGBA(Color.red), "System Message");
                        string messageBoxMessage = StringUtil.Format("<color=#{0}>{1}</color> {2}", ColorUtility.ToHtmlStringRGBA(Color.red), "Error", "Exit Page");
                        Global.WidgetMgr.ShowMessageBox(title, messageBoxMessage, eMessageBoxType.OK, null, 0.4f);
                    }
                });
        }
        break;
        }

        base.OnNotify(notify);
    }
Пример #8
0
 public ThreadP2Ctrl_Message(long xMessage_ID, eMessage xMessage, ThreadP_Message.delegate_Procedure xporocedure, object oResult, string ErrorMessage)
 {
     Message_ID = xMessage_ID;
     m_Message = xMessage;
     m_Procedure = xporocedure;
     m_oResult = oResult;
     m_ErrorMessage = ErrorMessage;
 }
Пример #9
0
 void WritePipeMessage(eMessage msg)
 {
     if (!bufio)
     {
         MessageCounter++;
     }
     //Console.WriteLine("write pipe message: " + msg);
     bwPipe.Write((int)msg);
     bwPipe.Flush();
 }
Пример #10
0
        bool Handle_BRK(eMessage msg)
        {
            switch (msg)
            {
            default:
                return(false);
            }             //switch(msg)

            Message(eMessage.Resume);
            return(true);
        }
Пример #11
0
 public usrc_FVI_SLO_Message(long xMessage_ID, eMessage xMessage, string xml_data)
 {
     Message = xMessage;
     XML_Data = xml_data;
     Message_ID = xMessage_ID;
     m_errorMessage = null;
     m_messageType = MessageType.Unknown;
     m_protectedID = null;
     m_success = false;
     m_uniqueInvoiceID = null;
     m_barCodeValue = null;
     m_image_QRCode = null;
 }
Пример #12
0
        bool Handle_BRK(eMessage msg)
        {
            switch (msg)
            {
            default:
                return(false);
            }             //switch(msg)

            // TODO: do we want this ever?
#if false
            Message(eMessage.Resume);
            return(true);
#endif
        }
Пример #13
0
        bool Handle_BRK(eMessage msg)
        {
            using (_exe.EnterExit())
            {
                switch (msg)
                {
                default:
                    return(false);

                case eMessage.eMessage_BRK_hook_exec:
                    ExecHook(_comm->addr);
                    break;

                case eMessage.eMessage_BRK_hook_read:
                    ReadHook(_comm->addr);
                    break;

                case eMessage.eMessage_BRK_hook_write:
                    WriteHook(_comm->addr, (byte)_comm->value);
                    break;

                case eMessage.eMessage_BRK_hook_exec_smp:
                    ExecHook_SMP(_comm->addr);
                    break;

                case eMessage.eMessage_BRK_hook_read_smp:
                    ReadHook_SMP(_comm->addr);
                    break;

                case eMessage.eMessage_BRK_hook_write_smp:
                    WriteHook_SMP(_comm->addr, (byte)_comm->value);
                    break;

                //not supported yet
                case eMessage.eMessage_BRK_hook_nmi:
                    break;

                case eMessage.eMessage_BRK_hook_irq:
                    break;

                case eMessage.eMessage_BRK_scanlineStart:
                    scanlineStart?.Invoke(_comm->scanline);
                    break;
                }                 //switch(msg)

                _core.Message(eMessage.eMessage_Resume);
                return(true);
            }
        }
Пример #14
0
        bool Handle_BRK(eMessage msg)
        {
            switch (msg)
            {
            case eMessage.BRK_InputState:
                comm->value = (uint)core.CB_InputState(comm->port, comm->device, comm->index, comm->id);
                break;

            default:
                return(false);
            }             //switch(msg)

            Message(eMessage.Resume);
            return(true);
        }
Пример #15
0
    //private void ShowMessageBoxWithPluginNotifyInfo(string message, eMessageBoxType boxType = eMessageBoxType.OK, System.Action<bool> completed = null)
    //{
    //    string title = StringUtil.Format("<color=#{0}>{1}</color>", ColorUtility.ToHtmlStringRGBA(Color.blue), "System Info Message");
    //    Global.WidgetMgr.ShowMessageBox(title, message, boxType, completed);
    //}

    public override void OnNotify(INotify notify)
    {
        eMessage msgType = (eMessage)notify.MsgCode;

        switch (msgType)
        {
        case eMessage.PageTransition:
        {
            Debug.LogError(msgType);
        }
        break;
        }

        base.OnNotify(notify);
    }
Пример #16
0
        public bool SendMessageToAll(eMessage type, object value = null)
        {
            if ((uint)type >= (uint)eMessage.TypeEnd)
            {
                return(false);
            }

            int count = _messageObjects[(int)type].Count;

            for (int i = 0; i < count; ++i)
            {
                _messageObjects[(int)type][i].MessageProc(type, value);
            }

            return(true);
        }
Пример #17
0
        bool Handle_BRK(eMessage msg)
        {
            switch (msg)
            {
            default:
                return(false);

            case eMessage.eMessage_BRK_hook_exec:
            {
                var addr = brPipe.ReadInt32();
                ExecHook((uint)addr);
                break;
            }

            case eMessage.eMessage_BRK_hook_read:
            {
                var addr = brPipe.ReadInt32();
                ReadHook((uint)addr);
                break;
            }

            case eMessage.eMessage_BRK_hook_write:
            {
                var addr  = brPipe.ReadInt32();
                var value = brPipe.ReadByte();
                WriteHook((uint)addr, value);
                break;
            }

            //not supported yet
            case eMessage.eMessage_BRK_hook_nmi:
                break;

            case eMessage.eMessage_BRK_hook_irq:
                break;

            case eMessage.eMessage_BRK_scanlineStart:
                int line = brPipe.ReadInt32();
                if (scanlineStart != null)
                {
                    scanlineStart(line);
                }
                SPECIAL_Resume();
                break;
            }             //switch(msg)
            return(true);
        }
Пример #18
0
        bool Handle_BRK(eMessage msg)
        {
            switch (msg)
            {
            default:
                return(false);

            case eMessage.eMessage_BRK_hook_exec:
            {
                ExecHook(comm->addr);
                break;
            }

            case eMessage.eMessage_BRK_hook_read:
            {
                ReadHook(comm->addr);
                break;
            }

            case eMessage.eMessage_BRK_hook_write:
            {
                WriteHook(comm->addr, (byte)comm->value);
                break;
            }

            //not supported yet
            case eMessage.eMessage_BRK_hook_nmi:
                break;

            case eMessage.eMessage_BRK_hook_irq:
                break;

            case eMessage.eMessage_BRK_scanlineStart:
                if (scanlineStart != null)
                {
                    scanlineStart(comm->scanline);
                }
                break;
            }             //switch(msg)

            Message(eMessage.eMessage_Resume);
            return(true);
        }
Пример #19
0
		bool Handle_BRK(eMessage msg)
		{
			switch (msg)
			{
				default:
					return false;

				case eMessage.eMessage_BRK_hook_exec:
					{
						var addr = brPipe.ReadInt32();
						ExecHook((uint)addr);
						break;
					}
				case eMessage.eMessage_BRK_hook_read:
					{
						var addr = brPipe.ReadInt32();
						ReadHook((uint)addr);
						break;
					}
				case eMessage.eMessage_BRK_hook_write:
					{
						var addr = brPipe.ReadInt32();
						var value = brPipe.ReadByte();
						WriteHook((uint)addr, value);
						break;
					}

				//not supported yet
				case eMessage.eMessage_BRK_hook_nmi:
					break;
				case eMessage.eMessage_BRK_hook_irq:
					break;

				case eMessage.eMessage_BRK_scanlineStart:
					int line = brPipe.ReadInt32();
					if (scanlineStart != null)
						scanlineStart(line);
					SPECIAL_Resume();
					break;

			} //switch(msg)
			return true;
		}
Пример #20
0
    public void SendeMessageToChat(string text, eMessageTYPE type)
    {
        if (eMessageList.Count >= maxeMessages)
        {
            Destroy(eMessageList[0].textObject.gameObject);
            eMessageList.Remove(eMessageList[0]);
        }
        eMessage neweMessage = new eMessage();

        neweMessage.text = text;


        GameObject newText = Instantiate(textObject, chatPanel.transform);

        neweMessage.textObject       = newText.GetComponent <Text>();
        neweMessage.textObject.color = colors[(int)type];
        neweMessage.textObject.text  = neweMessage.text;
        eMessageList.Add(neweMessage);
    }
Пример #21
0
        public bool Add(eMessage type, IMessageObject messageObject)
        {
            if ((uint)type >= (uint)eMessage.TypeEnd)
            {
                return(false);
            }

            if (_messageObjects[(int)type].Contains(messageObject) == true)
            {
                return(false);
            }

            _messageObjects[(int)type].Add(messageObject);

            if (_removeHelper.ContainsKey(messageObject) == false)
            {
                _removeHelper.Add(messageObject, new List <eMessage>());
            }

            _removeHelper[messageObject].Add(type);

            return(true);
        }
Пример #22
0
 public bool GetMessage(ref eMessage eMsg)
 {
     if (usrSearchLocalNetwork.mutexMessageBox.WaitOne())
     {
         bool bRes = false;
         if (MessageList.Count > 0)
         {
             eMsg = MessageList[0];
             MessageList.RemoveAt(0);
             bRes = true;
         }
         else
         {
             bRes = false;
         }
         usrSearchLocalNetwork.mutexMessageBox.ReleaseMutex();
         return bRes;
     }
     else
     {
         return false;
     }
 }
Пример #23
0
        bool Handle_BRK(eMessage msg)
        {
            switch (msg)
            {
            default:
                return(false);

            case eMessage.eMessage_BRK_hook_exec:
            {
                var addr = brPipe.ReadInt32();
                ExecHook((uint)addr);
                break;
            }

            case eMessage.eMessage_BRK_hook_read:
            {
                var addr = brPipe.ReadInt32();
                ReadHook((uint)addr);
                break;
            }

            case eMessage.eMessage_BRK_hook_write:
            {
                var addr  = brPipe.ReadInt32();
                var value = brPipe.ReadByte();
                WriteHook((uint)addr, value);
                break;
            }

            case eMessage.eMessage_BRK_hook_nmi:
                break;

            case eMessage.eMessage_BRK_hook_irq:
                break;
            }             //switch(msg)
            return(true);
        }
Пример #24
0
        bool Handle_SIG(eMessage msg)
        {
            //I know, ive done this two completely different ways
            //both ways are sloppy glue, anyway
            //I havent decided on the final architecture yet

            switch (msg)
            {
            case eMessage.SIG_InputState:
                comm->value = (uint)core.CB_InputState(comm->port, comm->device, comm->index, comm->id);
                break;

            case eMessage.SIG_VideoUpdate:
                core.SIG_VideoUpdate();
                break;

            case eMessage.SIG_Sample:
            {
                short *samples = (short *)comm->buf[(int)BufId.Param0];
                core.retro_audio_sample(samples[0], samples[1]);
            }
            break;

            case eMessage.SIG_SampleBatch:
            {
                void *samples = (void *)comm->buf[(int)BufId.Param0];
                core.retro_audio_sample_batch(samples, (int)comm->buf_size[(int)BufId.Param0] / 4);
            }
            break;

            default:
                return(false);
            }             //switch(msg)

            Message(eMessage.Resume);
            return(true);
        }
Пример #25
0
        public bool MessageProc(eMessage type, object value)
        {
            switch (type)
            {
            case eMessage.SearchButtonClick:
            {
                OnSearchButtonClick((string)value);
                return(true);
            }

            case eMessage.SearchProgramViewAppend:
            {
                OnSearchProgramViewAppend();
                return(true);
            }

            case eMessage.SearchProgramViewPrepend:
            {
                OnSearchProgramViewPrepend();
                return(true);
            }

            case eMessage.SearchProgramItemClick:
            {
                OnSearchProgramItemClick((string)value);
                return(true);
            }

            case eMessage.ProgramViewBackButtonClick:
            {
                OnProgramViewBackButtonClick();
                return(true);
            }
            }

            return(false);
        }
Пример #26
0
        internal void Set(long message_ID, eMessage xeMessage, string xml_returned, string errorMessage, MessageType messageType, string protectedID, bool success, string uniqueInvoiceID, string barCodeValue, Image img_QRCode)
        {
            Message = xeMessage;
            XML_Data = xml_returned;
            Message_ID = message_ID;

            m_errorMessage = errorMessage;
            m_messageType = messageType;
            m_protectedID = protectedID;
            m_success = success;
            m_uniqueInvoiceID = uniqueInvoiceID;
            m_barCodeValue = barCodeValue;
            if (img_QRCode !=null)
            {
                m_image_QRCode = (Image)img_QRCode.Clone();
            }
            else
            {
                m_image_QRCode = null;
            }
        }
Пример #27
0
        bool Handle_SIG(eMessage msg)
        {
            switch (msg)
            {
            default:
                return(false);

            case eMessage.eMessage_SIG_video_refresh:
            {
                int width  = comm->width;
                int height = comm->height;
                if (video_refresh != null)
                {
                    video_refresh((int *)comm->ptr, width, height);
                }
                break;
            }

            case eMessage.eMessage_SIG_input_poll:
                break;

            case eMessage.eMessage_SIG_input_state:
            {
                int port   = comm->port;
                int device = comm->device;
                int index  = comm->index;
                int id     = (int)comm->id;
                if (input_state != null)
                {
                    comm->value = (uint)input_state(port, device, index, id);
                }
                break;
            }

            case eMessage.eMessage_SIG_input_notify:
            {
                if (input_notify != null)
                {
                    input_notify(comm->index);
                }
                break;
            }

            case eMessage.eMessage_SIG_audio_flush:
            {
                uint nsamples = comm->size;

                if (audio_sample != null)
                {
                    ushort *audiobuffer = ((ushort *)comm->ptr);
                    for (uint i = 0; i < nsamples;)
                    {
                        ushort left  = audiobuffer[i++];
                        ushort right = audiobuffer[i++];
                        audio_sample(left, right);
                    }
                }

                break;
            }

            case eMessage.eMessage_SIG_path_request:
            {
                int    slot = comm->slot;
                string hint = comm->GetAscii();
                string ret  = hint;
                if (pathRequest != null)
                {
                    hint = pathRequest(slot, hint);
                }
                SetAscii(hint);
                break;
            }

            case eMessage.eMessage_SIG_trace_callback:
            {
                if (traceCallback != null)
                {
                    traceCallback(comm->GetAscii());
                }
                break;
            }

            case eMessage.eMessage_SIG_allocSharedMemory:
            {
                var name = comm->GetAscii();
                var size = comm->size;

                if (SharedMemoryBlocks.ContainsKey(name))
                {
                    throw new InvalidOperationException("Re-defined a shared memory block. Check bsnes init/shutdown code. Block name: " + name);
                }

                //try reusing existing block; dispose it if it exists and if the size doesnt match
                SharedMemoryBlock smb = null;
                if (DeallocatedMemoryBlocks.ContainsKey(name))
                {
                    smb = DeallocatedMemoryBlocks[name];
                    DeallocatedMemoryBlocks.Remove(name);
                    if (smb.Size != size)
                    {
                        smb.Dispose();
                        smb = null;
                    }
                }

                //allocate a new block if we have to
                if (smb == null)
                {
                    smb           = new SharedMemoryBlock();
                    smb.Name      = name;
                    smb.Size      = (int)size;
                    smb.BlockName = InstanceName + smb.Name;
                    smb.Allocate();
                }

                comm->ptr = smb.Ptr;
                SharedMemoryBlocks[smb.Name] = smb;
                CopyString(smb.BlockName);
                break;
            }

            case eMessage.eMessage_SIG_freeSharedMemory:
            {
                foreach (var block in SharedMemoryBlocks.Values)
                {
                    if (block.Ptr == comm->ptr)
                    {
                        DeallocatedMemoryBlocks[block.Name] = block;
                        SharedMemoryBlocks.Remove(block.Name);
                        break;
                    }
                }
                break;
            }
            }             //switch(msg)

            Message(eMessage.eMessage_Resume);
            return(true);
        }
Пример #28
0
 public UIEventNotify(eMessage subMessage, string data) : base(subMessage)
 {
     Data = data;
 }
Пример #29
0
 public UIEventNotify(eMessage subMessage) : this(subMessage, string.Empty)
 {
 }
Пример #30
0
		void WritePipeMessage(eMessage msg)
		{
			if(!bufio) MessageCounter++;
			//Console.WriteLine("write pipe message: " + msg);
			bwPipe.Write((int)msg);
			bwPipe.Flush();
		}
Пример #31
0
 public SpawnerNotify(eMessage message) : base(message)
 {
 }
Пример #32
0
        bool Handle_SIG(eMessage msg)
        {
            switch (msg)
            {
            default:
                return(false);

            case eMessage.eMessage_SIG_video_refresh:
            {
                int width  = brPipe.ReadInt32();
                int height = brPipe.ReadInt32();
                bwPipe.Write(0);                                 //offset in mapped memory buffer
                bwPipe.Flush();
                brPipe.ReadBoolean();                            //dummy synchronization
                if (video_refresh != null)
                {
                    video_refresh((int *)mmvaPtr, width, height);
                }
                break;
            }

            case eMessage.eMessage_SIG_input_poll:
                break;

            case eMessage.eMessage_SIG_input_state:
            {
                int    port   = brPipe.ReadInt32();
                int    device = brPipe.ReadInt32();
                int    index  = brPipe.ReadInt32();
                int    id     = brPipe.ReadInt32();
                ushort ret    = 0;
                if (input_state != null)
                {
                    ret = input_state(port, device, index, id);
                }
                bwPipe.Write(ret);
                bwPipe.Flush();
                break;
            }

            case eMessage.eMessage_SIG_input_notify:
            {
                int index = brPipe.ReadInt32();
                if (input_notify != null)
                {
                    input_notify(index);
                }
                break;
            }

            case eMessage.eMessage_SIG_audio_flush:
            {
                int nsamples = brPipe.ReadInt32();
                bwPipe.Write(0);                                 //location to store audio buffer in
                bwPipe.Flush();
                brPipe.ReadInt32();                              //dummy synchronization

                if (audio_sample != null)
                {
                    ushort *audiobuffer = ((ushort *)mmvaPtr);
                    for (int i = 0; i < nsamples;)
                    {
                        ushort left  = audiobuffer[i++];
                        ushort right = audiobuffer[i++];
                        audio_sample(left, right);
                    }
                }

                bwPipe.Write(0);                                 //dummy synchronization
                bwPipe.Flush();
                brPipe.ReadInt32();                              //dummy synchronization
                break;
            }

            case eMessage.eMessage_SIG_path_request:
            {
                int    slot = brPipe.ReadInt32();
                string hint = ReadPipeString();
                string ret  = hint;
                if (pathRequest != null)
                {
                    hint = pathRequest(slot, hint);
                }
                WritePipeString(hint);
                break;
            }

            case eMessage.eMessage_SIG_trace_callback:
            {
                var trace = ReadPipeString();
                if (traceCallback != null)
                {
                    traceCallback(trace);
                }
                break;
            }

            case eMessage.eMessage_SIG_allocSharedMemory:
            {
                var name = ReadPipeString();
                var size = brPipe.ReadInt32();

                if (SharedMemoryBlocks.ContainsKey(name))
                {
                    throw new InvalidOperationException("Re-defined a shared memory block. Check bsnes init/shutdown code. Block name: " + name);
                }

                //try reusing existing block; dispose it if it exists and if the size doesnt match
                SharedMemoryBlock smb = null;
                if (DeallocatedMemoryBlocks.ContainsKey(name))
                {
                    smb = DeallocatedMemoryBlocks[name];
                    DeallocatedMemoryBlocks.Remove(name);
                    if (smb.Size != size)
                    {
                        smb.Dispose();
                        smb = null;
                    }
                }

                //allocate a new block if we have to
                if (smb == null)
                {
                    smb           = new SharedMemoryBlock();
                    smb.Name      = name;
                    smb.Size      = size;
                    smb.BlockName = InstanceName + smb.Name;
                    smb.Allocate();
                }

                SharedMemoryBlocks[smb.Name] = smb;
                WritePipeString(smb.BlockName);
                break;
            }

            case eMessage.eMessage_SIG_freeSharedMemory:
            {
                string name = ReadPipeString();
                var    smb  = SharedMemoryBlocks[name];
                DeallocatedMemoryBlocks[name] = smb;
                SharedMemoryBlocks.Remove(name);
                break;
            }
            }             //switch(msg)

            return(true);
        }
Пример #33
0
        bool Handle_SIG(eMessage msg)
        {
            using (_exe.EnterExit())
            {
                switch (msg)
                {
                default:
                    return(false);

                case eMessage.eMessage_SIG_video_refresh:
                {
                    int width  = _comm->width;
                    int height = _comm->height;
                    video_refresh?.Invoke((int *)_comm->ptr, width, height);
                    break;
                }

                case eMessage.eMessage_SIG_input_poll:
                    break;

                case eMessage.eMessage_SIG_input_state:
                {
                    int port   = _comm->port;
                    int device = _comm->device;
                    int index  = _comm->index;
                    int id     = (int)_comm->id;
                    if (input_state != null)
                    {
                        _comm->value = (uint)input_state(port, device, index, id);
                    }
                    break;
                }

                case eMessage.eMessage_SIG_input_notify:
                {
                    input_notify?.Invoke(_comm->index);
                    break;
                }

                case eMessage.eMessage_SIG_audio_flush:
                {
                    uint nsamples = _comm->size;

                    if (audio_sample != null)
                    {
                        ushort *audiobuffer = ((ushort *)_comm->ptr);
                        for (uint i = 0; i < nsamples;)
                        {
                            ushort left  = audiobuffer[i++];
                            ushort right = audiobuffer[i++];
                            audio_sample(left, right);
                        }
                    }

                    break;
                }

                case eMessage.eMessage_SIG_path_request:
                {
                    int    slot = _comm->slot;
                    string hint = _comm->GetAscii();
                    string ret  = hint;
                    if (pathRequest != null)
                    {
                        hint = pathRequest(slot, hint);
                    }
                    CopyAscii(0, hint);
                    break;
                }

                case eMessage.eMessage_SIG_trace_callback:
                {
                    traceCallback?.Invoke(_comm->value, _comm->GetAscii());
                    break;
                }

                case eMessage.eMessage_SIG_allocSharedMemory:
                {
                    // NB: shared memory blocks are allocated on the unmanaged side
                    var name = _comm->GetAscii();
                    var size = _comm->size;
                    var ptr  = _comm->ptr;

                    if (_sharedMemoryBlocks.ContainsKey(name))
                    {
                        throw new InvalidOperationException("Re-defined a shared memory block. Check bsnes init/shutdown code. Block name: " + name);
                    }

                    _sharedMemoryBlocks.Add(name, (IntPtr)ptr);
                    break;
                }

                case eMessage.eMessage_SIG_freeSharedMemory:
                    throw new InvalidOperationException("Unexpected call:  SIG_freeSharedMemory");
                }                 //switch(msg)

                _core.Message(eMessage.eMessage_Resume);
                return(true);
            }
        }
Пример #34
0
		bool Handle_SIG(eMessage msg)
		{
			switch (msg)
			{
				default:
					return false;
				case eMessage.eMessage_SIG_video_refresh:
					{
						int width = brPipe.ReadInt32();
						int height = brPipe.ReadInt32();
						bwPipe.Write(0); //offset in mapped memory buffer
						bwPipe.Flush();
						brPipe.ReadBoolean(); //dummy synchronization
						if (video_refresh != null)
						{
							video_refresh((int*)mmvaPtr, width, height);
						}
						break;
					}
				case eMessage.eMessage_SIG_input_poll:
					break;
				case eMessage.eMessage_SIG_input_state:
					{
						int port = brPipe.ReadInt32();
						int device = brPipe.ReadInt32();
						int index = brPipe.ReadInt32();
						int id = brPipe.ReadInt32();
						ushort ret = 0;
						if (input_state != null)
							ret = input_state(port, device, index, id);
						bwPipe.Write(ret);
						bwPipe.Flush();
						break;
					}
				case eMessage.eMessage_SIG_input_notify:
					{
						int index = brPipe.ReadInt32();
						if (input_notify != null)
							input_notify(index);
						break;
					}
				case eMessage.eMessage_SIG_audio_flush:
					{
						int nsamples = brPipe.ReadInt32();
						bwPipe.Write(0); //location to store audio buffer in
						bwPipe.Flush();
						brPipe.ReadInt32(); //dummy synchronization

						if (audio_sample != null)
						{
							ushort* audiobuffer = ((ushort*)mmvaPtr);
							for (int i = 0; i < nsamples; )
							{
								ushort left = audiobuffer[i++];
								ushort right = audiobuffer[i++];
								audio_sample(left, right);
							}
						}

						bwPipe.Write(0); //dummy synchronization
						bwPipe.Flush();
						brPipe.ReadInt32();  //dummy synchronization
						break;
					}
				case eMessage.eMessage_SIG_scanlineStart:
					{
						int line = brPipe.ReadInt32();
						if (scanlineStart != null)
							scanlineStart(line);

						//we have to notify the unmanaged process that we're done peeking thruogh its memory and whatnot so it can proceed with emulation
						//HUM??????????? BRK_COMPLETE???? SCANLINE CB NEEDS RE-EVALUATING
						WritePipeMessage(eMessage.eMessage_BRK_Complete);
						break;
					}
				case eMessage.eMessage_SIG_path_request:
					{
						int slot = brPipe.ReadInt32();
						string hint = ReadPipeString();
						string ret = hint;
						if (pathRequest != null)
							hint = pathRequest(slot, hint);
						WritePipeString(hint);
						break;
					}
				case eMessage.eMessage_SIG_trace_callback:
					{
						var trace = ReadPipeString();
						if (traceCallback != null)
							traceCallback(trace);
						break;
					}
				case eMessage.eMessage_SIG_allocSharedMemory:
					{
						var name = ReadPipeString();
						var size = brPipe.ReadInt32();

						if (SharedMemoryBlocks.ContainsKey(name))
						{
							throw new InvalidOperationException("Re-defined a shared memory block. Check bsnes init/shutdown code. Block name: " + name);
						}

						//try reusing existing block; dispose it if it exists and if the size doesnt match
						SharedMemoryBlock smb = null;
						if (DeallocatedMemoryBlocks.ContainsKey(name))
						{
							smb = DeallocatedMemoryBlocks[name];
							DeallocatedMemoryBlocks.Remove(name);
							if (smb.Size != size)
							{
								smb.Dispose();
								smb = null;
							}
						}

						//allocate a new block if we have to
						if (smb == null)
						{
							smb = new SharedMemoryBlock();
							smb.Name = name;
							smb.Size = size;
							smb.BlockName = InstanceName + smb.Name;
							smb.Allocate();
						}

						SharedMemoryBlocks[smb.Name] = smb;
						WritePipeString(smb.BlockName);
						break;
					}
				case eMessage.eMessage_SIG_freeSharedMemory:
					{
						string name = ReadPipeString();
						var smb = SharedMemoryBlocks[name];
						DeallocatedMemoryBlocks[name] = smb;
						SharedMemoryBlocks.Remove(name);
						break;
					}
			} //switch(msg)
			
			return true;
		}
Пример #35
0
 public void Set(long xMessage_ID,eMessage xMessage, delegate_Procedure procedure, object parameterasobject)
 {
     Message_ID = xMessage_ID;
     Message = xMessage;
     Procedure = procedure;
     m_ParameterAsObject = parameterasobject;
 }
Пример #36
0
 public Thread_FVI_Message(long xMessage_ID,eMessage xMessage, string xml_data)
 {
     Message = xMessage;
     XML_Data = xml_data;
     Message_ID = xMessage_ID;
 }
Пример #37
0
 public void Set(long xMessage_ID,eMessage xMessage, string xml_data)
 {
     Message_ID = xMessage_ID;
     Message = xMessage;
     XML_Data = xml_data;
 }
Пример #38
0
 public EventNotify(eMessage message)
 {
     m_message = message;
 }