Пример #1
0
        /// <summary>
        /// Launches inputshareSP
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="desktop"></param>
        /// <param name="createConsole"></param>
        /// <param name="ipcHost"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        /// <exception cref="CreateProcessException"></exception>"
        public static Process LaunchSP(SPMode mode, WindowsDesktop desktop, bool createConsole, AnonIpcHost ipcHost, IntPtr token)
        {
            PROCESS_INFORMATION pi = new PROCESS_INFORMATION();
            STARTUPINFO         si = new STARTUPINFO();

            si.cb        = Marshal.SizeOf(si);
            si.lpDesktop = desktop.ToString();
            CreateBlankAttribs(out SECURITY_ATTRIBUTES tokenAttribs, out SECURITY_ATTRIBUTES threadAttribs);

            CreateProcessFlags flags = CreateProcessFlags.REALTIME_PRIORITY_CLASS;

            if (!createConsole)
            {
                flags |= CreateProcessFlags.CREATE_NO_WINDOW;
            }

            string cmd = " " + mode.ToString() + " " + ipcHost.WriteStringHandle + " " + ipcHost.ReadStringHandle;

            if (!CreateProcessAsUser(token, AppDomain.CurrentDomain.BaseDirectory + "\\inputsharesp.exe",
                                     cmd,
                                     ref tokenAttribs,
                                     ref threadAttribs,
                                     true,
                                     (uint)flags,
                                     IntPtr.Zero,
                                     AppDomain.CurrentDomain.BaseDirectory,
                                     ref si,
                                     out pi))
            {
                throw new CreateProcessException(new Win32Exception().Message);
            }

            return(Process.GetProcessById(pi.dwProcessId));
        }
Пример #2
0
        public void HardReset()
        {
            HardResetInternal();
            alarmSelect       = false;
            cntPos            = false;
            enableIntAlarm    = false;
            enableIntFlag     = false;
            enableIntSP       = false;
            enableIntTimer[0] = false;
            enableIntTimer[1] = false;
            intAlarm          = false;
            intFlag           = false;
            intSP             = false;
            intTimer[0]       = false;
            intTimer[1]       = false;
            sr                 = 0;
            timerDelay[0]      = 0;
            timerDelay[1]      = 0;
            timerInMode[0]     = InMode.Phase2;
            timerInMode[1]     = InMode.Phase2;
            timerOn[0]         = false;
            timerOn[1]         = false;
            timerOutMode[0]    = OutMode.Pulse;
            timerOutMode[1]    = OutMode.Pulse;
            timerPortEnable[0] = false;
            timerPortEnable[1] = false;
            timerPulse[0]      = false;
            timerPulse[1]      = false;
            timerRunMode[0]    = RunMode.Continuous;
            timerRunMode[1]    = RunMode.Continuous;
            timerSPMode        = SPMode.Input;
            tod[0]             = 0;
            tod[1]             = 0;
            tod[2]             = 0;
            tod[3]             = 0x12;
            todAlarm[0]        = 0;
            todAlarm[1]        = 0;
            todAlarm[2]        = 0;
            todAlarm[3]        = 0;
            todCounter         = todCounterLatch;
            todIn              = (chipRegion == Region.PAL);
            todPM              = false;

            pinCnt = false;
            pinPC  = true;
        }
Пример #3
0
		public void WriteRegister(int addr, byte val)
		{
			bool intReg;

			switch (addr)
			{
				case 0x0:
					portA.Latch = val;
					break;
				case 0x1:
					portB.Latch = val;
					break;
				case 0x2:
					portA.Direction = val;
					break;
				case 0x3:
					portB.Direction = val;
					break;
				case 0x4:
					timerLatch[0] &= 0xFF00;
					timerLatch[0] |= val;
					break;
				case 0x5:
					timerLatch[0] &= 0x00FF;
					timerLatch[0] |= val << 8;
					break;
				case 0x6:
					timerLatch[1] &= 0xFF00;
					timerLatch[1] |= val;
					break;
				case 0x7:
					timerLatch[1] &= 0x00FF;
					timerLatch[1] |= val << 8;
					break;
				case 0x8:
					if (alarmSelect)
						todAlarm[0] = (byte)(val & 0xF);
					else
						tod[0] = (byte)(val & 0xF);
					break;
				case 0x9:
					if (alarmSelect)
						todAlarm[1] = (byte)(val & 0x7F);
					else
						tod[1] = (byte)(val & 0x7F);
					break;
				case 0xA:
					if (alarmSelect)
						todAlarm[2] = (byte)(val & 0x7F);
					else
						tod[2] = (byte)(val & 0x7F);
					break;
				case 0xB:
					if (alarmSelect)
					{
						todAlarm[3] = (byte)(val & 0x1F);
						todAlarmPM = ((val & 0x80) != 0);
					}
					else
					{
						tod[3] = (byte)(val & 0x1F);
						todPM = ((val & 0x80) != 0);
					}
					break;
				case 0xC:
					sr = val;
					break;
				case 0xD:
					intReg = ((val & 0x80) != 0);
					if ((val & 0x01) != 0)
						enableIntTimer[0] = intReg;
					if ((val & 0x02) != 0)
						enableIntTimer[1] = intReg;
					if ((val & 0x04) != 0)
						enableIntAlarm = intReg;
					if ((val & 0x08) != 0)
						enableIntSP = intReg;
					if ((val & 0x10) != 0)
						enableIntFlag = intReg;
					break;
				case 0xE:
					if ((val & 0x01) != 0 && !timerOn[0])
						timerDelay[0] = 2;
					timerOn[0] = ((val & 0x01) != 0);
					timerPortEnable[0] = ((val & 0x02) != 0);
					timerOutMode[0] = ((val & 0x04) != 0) ? OutMode.Toggle : OutMode.Pulse;
					timerRunMode[0] = ((val & 0x08) != 0) ? RunMode.Oneshot : RunMode.Continuous;
					timerInMode[0] = ((val & 0x20) != 0) ? InMode.CNT : InMode.Phase2;
					timerSPMode = ((val & 0x40) != 0) ? SPMode.Output : SPMode.Input;
					todIn = ((val & 0x80) != 0);
					break;
				case 0xF:
					if ((val & 0x01) != 0 && !timerOn[1])
						timerDelay[1] = 2;
					timerOn[1] = ((val & 0x01) != 0);
					timerPortEnable[1] = ((val & 0x02) != 0);
					timerOutMode[1] = ((val & 0x04) != 0) ? OutMode.Toggle : OutMode.Pulse;
					timerRunMode[1] = ((val & 0x08) != 0) ? RunMode.Oneshot : RunMode.Continuous;
					switch (val & 0x60)
					{
						case 0x00: timerInMode[1] = InMode.Phase2; break;
						case 0x20: timerInMode[1] = InMode.CNT; break;
						case 0x40: timerInMode[1] = InMode.TimerAUnderflow; break;
						case 0x60: timerInMode[1] = InMode.TimerAUnderflowCNT; break;
					}
					alarmSelect = ((val & 0x80) != 0);
					break;
			}
		}
Пример #4
0
		public void HardReset()
		{
			HardResetInternal();
			alarmSelect = false;
			cntPos = false;
			enableIntAlarm = false;
			enableIntFlag = false;
			enableIntSP = false;
			enableIntTimer[0] = false;
			enableIntTimer[1] = false;
			intAlarm = false;
			intFlag = false;
			intSP = false;
			intTimer[0] = false;
			intTimer[1] = false;
			sr = 0;
			timerDelay[0] = 0;
			timerDelay[1] = 0;
			timerInMode[0] = InMode.Phase2;
			timerInMode[1] = InMode.Phase2;
			timerOn[0] = false;
			timerOn[1] = false;
			timerOutMode[0] = OutMode.Pulse;
			timerOutMode[1] = OutMode.Pulse;
			timerPortEnable[0] = false;
			timerPortEnable[1] = false;
			timerPulse[0] = false;
			timerPulse[1] = false;
			timerRunMode[0] = RunMode.Continuous;
			timerRunMode[1] = RunMode.Continuous;
			timerSPMode = SPMode.Input;
			tod[0] = 0;
			tod[1] = 0;
			tod[2] = 0;
			tod[3] = 0x12;
			todAlarm[0] = 0;
			todAlarm[1] = 0;
			todAlarm[2] = 0;
			todAlarm[3] = 0;
			todCounter = 0;
			todIn = false;
			todPM = false;

			pinCnt = false;
			pinPC = true;
		}
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            RefreshUI_All();
        }
        switch (ts)
        {
        case TurnStage.start:
            nextStageTimer -= 5 * Time.deltaTime;
            break;

        case TurnStage.prepare:
            nextStageTimer -= 2 * Time.deltaTime;
            break;

        case TurnStage.play:
            break;

        case TurnStage.curse:
            break;

        case TurnStage.wrath:
            break;

        case TurnStage.discard:
            nextStageTimer -= 5 * Time.deltaTime;
            break;

        case TurnStage.draw:
            nextStageTimer -= 5 * Time.deltaTime;
            break;

        case TurnStage.end:
            nextStageTimer -= 5 * Time.deltaTime;
            break;

        default:
            break;
        }
        if (ts != TurnStage.play)
        {
            if (nextStageTimer > 0)
            {
                nextStageTimer -= Time.deltaTime;
            }
            else
            {
                SwitchStage();
            }
            uiStageTimer.fillAmount = (nextStageTimer / stageWaitTime);
        }
        if (sp == SPMode.exile)
        {
            if (exileHand > 0)
            {
                if (hand.GetCount() <= 0)
                {
                    exileHand = 0;
                    sp        = SPMode.none;
                }
            }
        }
        if (sp == SPMode.discard)
        {
            if (discardHand > 0 && hand.GetCount() <= 0)
            {
                discardHand = 0;
                sp          = SPMode.none;
            }
        }
    }
Пример #6
0
    public void OnCardClicked(string pileTag, int index)
    {
        switch (ts)
        {
        case TurnStage.start:
            break;

        case TurnStage.prepare:
            break;

        case TurnStage.play:
            if (sp == SPMode.exile)
            {
                if (pileTag == "BattleField" && exileField > 0)
                {
                    Card clickedCard = battleField.GetCard(index);
                    bool avaliable   = clickedCard.canExile();
                    if (avaliable)
                    {
                        clickedCard.OnExile();
                        battleField.DrawCard(index);
                        exileField--;
                    }
                }
                else if (pileTag == "Hand" && exileHand > 0)
                {
                    Card clickedCard = hand.GetCard(index);
                    bool avaliable   = clickedCard.canExile();
                    if (avaliable)
                    {
                        hand.ExileCard(index);
                        exileHand--;
                    }
                }
                if (exileHand <= 0 && exileField <= 0)
                {
                    sp = SPMode.none;
                }
            }
            else if (sp == SPMode.discard)
            {
                if (pileTag == "Hand" && discardHand > 0)
                {
                    Card clickedCard = hand.GetCard(index);
                    hand.DiscardCard(index);
                    discardHand--;
                }
                if (discardHand <= 0)
                {
                    sp = SPMode.none;
                }
            }
            else
            {
                if (pileTag == "BattleField")
                {
                    Card clickedCard = battleField.GetCard(index);
                    bool avaliable   = clickedCard.RequirementsCheck();
                    if (avaliable)
                    {
                        clickedCard.OnGetNormally();
                        battleField.DrawCard(index);
                        switch (clickedCard.getCostType())
                        {
                        case CostType.gold:
                            gold -= clickedCard.getCost();
                            break;

                        case CostType.attack:
                            attack -= clickedCard.getCost();
                            break;

                        default:
                            break;
                        }
                    }
                }
                else if (pileTag == "Hand")
                {
                    hand.PlayCard(index);
                }
            }
            break;

        case TurnStage.curse:
            break;

        case TurnStage.wrath:
            break;

        case TurnStage.discard:
            break;

        case TurnStage.draw:
            break;

        case TurnStage.end:
            break;

        default:
            break;
        }
    }
Пример #7
0
 public void StartDiscard(int numHand)
 {
     sp          = SPMode.discard;
     discardHand = numHand;
 }
Пример #8
0
 public void StartExile(int numBattleField, int numHand)
 {
     sp         = SPMode.exile;
     exileField = numBattleField;
     exileHand  = numHand;
 }
Пример #9
0
 public StoredProc(SPMode mode, String name)
     : this(mode)
 {
     ParameterName = name;
 }
Пример #10
0
 public StoredProc(SPMode mode)
 {
     Mode = mode;
 }
Пример #11
0
        public void WriteRegister(int addr, byte val)
        {
            bool intReg;

            switch (addr)
            {
            case 0x0:
                portA.Latch = val;
                break;

            case 0x1:
                portB.Latch = val;
                break;

            case 0x2:
                portA.Direction = val;
                break;

            case 0x3:
                portB.Direction = val;
                break;

            case 0x4:
                timerLatch[0] &= 0xFF00;
                timerLatch[0] |= val;
                break;

            case 0x5:
                timerLatch[0] &= 0x00FF;
                timerLatch[0] |= val << 8;
                break;

            case 0x6:
                timerLatch[1] &= 0xFF00;
                timerLatch[1] |= val;
                break;

            case 0x7:
                timerLatch[1] &= 0x00FF;
                timerLatch[1] |= val << 8;
                break;

            case 0x8:
                if (alarmSelect)
                {
                    todAlarm[0] = (byte)(val & 0xF);
                }
                else
                {
                    tod[0] = (byte)(val & 0xF);
                }
                break;

            case 0x9:
                if (alarmSelect)
                {
                    todAlarm[1] = (byte)(val & 0x7F);
                }
                else
                {
                    tod[1] = (byte)(val & 0x7F);
                }
                break;

            case 0xA:
                if (alarmSelect)
                {
                    todAlarm[2] = (byte)(val & 0x7F);
                }
                else
                {
                    tod[2] = (byte)(val & 0x7F);
                }
                break;

            case 0xB:
                if (alarmSelect)
                {
                    todAlarm[3] = (byte)(val & 0x1F);
                    todAlarmPM  = ((val & 0x80) != 0);
                }
                else
                {
                    tod[3] = (byte)(val & 0x1F);
                    todPM  = ((val & 0x80) != 0);
                }
                break;

            case 0xC:
                sr = val;
                break;

            case 0xD:
                intReg = ((val & 0x80) != 0);
                if ((val & 0x01) != 0)
                {
                    enableIntTimer[0] = intReg;
                }
                if ((val & 0x02) != 0)
                {
                    enableIntTimer[1] = intReg;
                }
                if ((val & 0x04) != 0)
                {
                    enableIntAlarm = intReg;
                }
                if ((val & 0x08) != 0)
                {
                    enableIntSP = intReg;
                }
                if ((val & 0x10) != 0)
                {
                    enableIntFlag = intReg;
                }
                break;

            case 0xE:
                if ((val & 0x01) != 0 && !timerOn[0])
                {
                    timerDelay[0] = 2;
                }
                timerOn[0]         = ((val & 0x01) != 0);
                timerPortEnable[0] = ((val & 0x02) != 0);
                timerOutMode[0]    = ((val & 0x04) != 0) ? OutMode.Toggle : OutMode.Pulse;
                timerRunMode[0]    = ((val & 0x08) != 0) ? RunMode.Oneshot : RunMode.Continuous;
                timerInMode[0]     = ((val & 0x20) != 0) ? InMode.CNT : InMode.Phase2;
                timerSPMode        = ((val & 0x40) != 0) ? SPMode.Output : SPMode.Input;
                todIn = ((val & 0x80) != 0);
                break;

            case 0xF:
                if ((val & 0x01) != 0 && !timerOn[1])
                {
                    timerDelay[1] = 2;
                }
                timerOn[1]         = ((val & 0x01) != 0);
                timerPortEnable[1] = ((val & 0x02) != 0);
                timerOutMode[1]    = ((val & 0x04) != 0) ? OutMode.Toggle : OutMode.Pulse;
                timerRunMode[1]    = ((val & 0x08) != 0) ? RunMode.Oneshot : RunMode.Continuous;
                switch (val & 0x60)
                {
                case 0x00: timerInMode[1] = InMode.Phase2; break;

                case 0x20: timerInMode[1] = InMode.CNT; break;

                case 0x40: timerInMode[1] = InMode.TimerAUnderflow; break;

                case 0x60: timerInMode[1] = InMode.TimerAUnderflowCNT; break;
                }
                alarmSelect = ((val & 0x80) != 0);
                break;
            }
        }
Пример #12
0
 internal ProcMapping(String clrProperty, SPMode mode)
 {
     // Initially points to the name of the clrProperty (convention is used)
     Map = new KeyMapping(clrProperty, clrProperty);
     Mode = mode;
 }