예제 #1
0
파일: Field.cs 프로젝트: Ziktur/match3
 public void OnChipStopped()
 {
     countChipsMoving--;
     if (!IsMoving())
     {
         if (IsMatch())
         {
             swapChip1 = null;
             swapChip2 = null;
             CheckMatch();
         }
         else
         {
             if (swapChip1 != null)
             {
                 SwapChips();
                 swapChip1 = null;
                 swapChip2 = null;
             }
             else
                 while (IsMatch() || !IsMatchPossible())
                     Shuffle();
         }
     }
 }
예제 #2
0
파일: Grid.cs 프로젝트: Multirez/TetrisTest
    private List<Line> lines = new List<Line>(); // The lines contain info about all blocks from bottom to top.

    #endregion Fields

    #region Methods

    /// <summary>
    /// Add the chip blocks to grid.
    /// </summary>
    /// <param name='toAdd'>
    /// The chip is will be added.
    /// </param>
    public void Add(Chip toAdd)
    {
        int lineIndex, blockIndex;
        Vector3 blockPos;
        Line tempLine;
        HashSet<Line> affectedLines=new HashSet<Line>();
        foreach(Transform blockTrans in toAdd.blocks){
            blockPos=transform.TransformPoint(blockTrans.position);
            lineIndex=Mathf.RoundToInt(blockPos.y);
            if(lineIndex>=lines.Count){
                for(int i=lineIndex-lines.Count; i>=0; i--){
                    tempLine=Instantiate(lineEtalon)as Line;
                    tempLine.transform.SetParent(transform);
                    tempLine.transform.rotation=Quaternion.identity;
                    tempLine.transform.localPosition=new Vector3(0f, lines.Count, 0f);
                    lines.Add(tempLine);
                }
            }
            tempLine=lines[lineIndex];
            affectedLines.Add(tempLine);

            blockIndex=Mathf.RoundToInt(blockPos.x);
            tempLine.blocks[blockIndex]=blockTrans;
            blockTrans.SetParent(tempLine.transform);
        }
        //remove chip
        toAdd.blocks.Clear();
        Destroy(toAdd.gameObject);
        //check lines for remove
        Line[] checkList=new Line[affectedLines.Count];
        affectedLines.CopyTo(checkList);
        RemoveFilledLines(checkList);
    }
예제 #3
0
        public IT87XX(Chip chip, ushort address, ushort gpioAddress, byte version)
        {
            this.address = address;
              this.chip = chip;
              this.version = version;
              this.addressReg = (ushort)(address + ADDRESS_REGISTER_OFFSET);
              this.dataReg = (ushort)(address + DATA_REGISTER_OFFSET);
              this.gpioAddress = gpioAddress;

              // Check vendor id
              bool valid;
              byte vendorId = ReadByte(VENDOR_ID_REGISTER, out valid);
              if (!valid || vendorId != ITE_VENDOR_ID)
            return;

              // Bit 0x10 of the configuration register should always be 1
              if ((ReadByte(CONFIGURATION_REGISTER, out valid) & 0x10) == 0)
            return;
              if (!valid)
            return;

              voltages = new float?[9];
              temperatures = new float?[3];
              fans = new float?[5];

              // IT8721F, IT8728F and IT8772E use a 12mV resultion ADC, all others 16mV
              if (chip == Chip.IT8721F || chip == Chip.IT8728F || chip == Chip.IT8771E
            || chip == Chip.IT8772E)
              {
            voltageGain = 0.012f;
              } else {
            voltageGain = 0.016f;
              }

              // older IT8721F revision do not have 16-bit fan counters
              if (chip == Chip.IT8712F && version < 8) {
            has16bitFanCounter = false;
              } else {
            has16bitFanCounter = true;
              }

              // Set the number of GPIO sets
              switch (chip) {
            case Chip.IT8712F:
            case Chip.IT8716F:
            case Chip.IT8718F:
            case Chip.IT8726F:
              gpioCount = 5;
              break;
            case Chip.IT8720F:
            case Chip.IT8721F:
              gpioCount = 8;
              break;
            case Chip.IT8728F:
            case Chip.IT8771E:
            case Chip.IT8772E:
              gpioCount = 0;
              break;
              }
        }
예제 #4
0
    // Gravity iteration
    void GravityReaction()
    {
        if (!SessionAssistant.main.CanIGravity()) return; // Work is possible only in "Gravity" mode

        chip = slotForChip.GetChip();
        if (!chip) return; // Work is possible only with the chips, otherwise nothing will move

        if (transform.position != chip.transform.position) return; // Work is possible only if the chip is physically clearly in the slot

        if (!slot [Side.Bottom] || !slot [Side.Bottom].gravity) return; // Work is possible only if there is another bottom slot

        // provided that bottom neighbor doesn't contains chip, give him our chip
        if (!slot[Side.Bottom].GetChip()) {
            slot[Side.Bottom].SetChip(chip);
            GravityReaction();
            return;
        }

        // Otherwise, we try to give it to their neighbors from the bottom-left and bottom-right side
        if (Random.value > 0.5f) { // Direction priority is random
            SlideLeft();
            SlideRight();
        } else {
            SlideRight();
            SlideLeft();
        }
    }
예제 #5
0
 void Awake()
 {
     chip = GetComponent<Chip>();
     chip.chipType = "CrossBomb";
     birth = SessionAssistant.main.eventCount;
     AudioAssistant.Shot ("CreateCrossBomb");
 }
예제 #6
0
 void Awake()
 {
     anim = GetComponent<Animation>();
     chip = GetComponent<Chip>();
     chip.chipType = "Ladybird";
     birth = SessionAssistant.main.eventCount;
     AudioAssistant.Shot("LadybirdCreate");
 }
예제 #7
0
 void Awake()
 {
     anim = GetComponent<Animation>();
     birth = SessionAssistant.main.eventCount;
     chip = GetComponent<Chip>();
     chip.chipType = "RainbowHeart";
     AudioAssistant.Shot("RainbowHeartCreate");
 }
예제 #8
0
 void Awake()
 {
     chip = GetComponent<Chip>();
     chip.chipType = "ColorBomb";
     anim = GetComponent<Animation>();
     birth = SessionAssistant.main.eventCount;
     AudioAssistant.Shot ("CreateColorBomb");
 }
    public F718XX(Chip chip, ushort address) {
      this.address = address;
      this.chip = chip;

      voltages = new float?[chip == Chip.F71858 ? 3 : 9];
      temperatures = new float?[chip == Chip.F71808E ? 2 : 3];
      fans = new float?[chip == Chip.F71882 || chip == Chip.F71858 ? 4 : 3];
      controls = new float?[0];
    }
예제 #10
0
파일: Grid.cs 프로젝트: Multirez/TetrisTest
 /// <summary>
 /// Determines whether this chip is can move down from the current position.
 /// </summary>
 /// <returns>
 /// <c>true</c> if this chip is can move down; otherwise, <c>false</c>.
 /// </returns>
 public bool IsCanMove(Chip activeChip, Vector3 direction)
 {
     Vector3 newBlockPos;
     foreach(Transform blockTrans in activeChip.blocks){
         newBlockPos=transform.TransformPoint(blockTrans.position)+direction;
         if(!gridRect.Contains(newBlockPos) ||
             !IsPositionIsFree(newBlockPos))
             return false;
     }
     return true;
 }
예제 #11
0
 public void WriteA0(Chip chip, byte val)
 {
     byte fourOp = (byte)(chip.Reg104 & chip.Opl3Active & FourMask);
     //Don't handle writes to silent fourop channels
     if (fourOp > 0x80)
         return;
     int change = (chanData ^ val) & 0xff;
     if (change != 0)
     {
         chanData ^= change;
         UpdateFrequency(chip, fourOp);
     }
 }
예제 #12
0
    private void initBoard()
    {
        board = new Chip[GameConstants.BOARD_SIZE * GameConstants.BOARD_SIZE];
        for (int ii = 0; ii < board.Length; ii++)
        {
            board[ii] = new Chip(ii, GameConstants.EMPTY);
        }

        tiles = new Texture[4];

        tiles[GameConstants.BLACK] = (Texture)Resources.Load("Black");
        tiles[GameConstants.WHITE] = (Texture)Resources.Load("White");
        tiles[GameConstants.EMPTY] = (Texture)Resources.Load("Empty");
        tiles[GameConstants.LEGAL] = (Texture)Resources.Load("Legal");
    }
예제 #13
0
        public static string GetName(Chip chip)
        {
            switch (chip) {
            case Chip.ATK0110: return "Asus ATK0110";

            case Chip.F71858: return "Fintek F71858";
            case Chip.F71862: return "Fintek F71862";
            case Chip.F71869: return "Fintek F71869";
            case Chip.F71869A: return "Fintek F71869A";
            case Chip.F71882: return "Fintek F71882";
            case Chip.F71889AD: return "Fintek F71889AD";
            case Chip.F71889ED: return "Fintek F71889ED";
            case Chip.F71889F: return "Fintek F71889F";
            case Chip.F71808E: return "Fintek F71808E";

            case Chip.IT8620E: return "ITE IT8620E";
            case Chip.IT8628E: return "ITE IT8628E";
            case Chip.IT8705F: return "ITE IT8705F";
            case Chip.IT8712F: return "ITE IT8712F";
            case Chip.IT8716F: return "ITE IT8716F";
            case Chip.IT8718F: return "ITE IT8718F";
            case Chip.IT8720F: return "ITE IT8720F";
            case Chip.IT8721F: return "ITE IT8721F";
            case Chip.IT8726F: return "ITE IT8726F";
            case Chip.IT8728F: return "ITE IT8728F";
            case Chip.IT8771E: return "ITE IT8771E";
            case Chip.IT8772E: return "ITE IT8772E";

            case Chip.NCT610X: return "Nuvoton NCT610X";

            case Chip.NCT6771F: return "Nuvoton NCT6771F";
            case Chip.NCT6776F: return "Nuvoton NCT6776F";
            case Chip.NCT6779D: return "Nuvoton NCT6779D";
            case Chip.NCT6791D: return "Nuvoton NCT6791D";

            case Chip.W83627DHG: return "Winbond W83627DHG";
            case Chip.W83627DHGP: return "Winbond W83627DHG-P";
            case Chip.W83627EHF: return "Winbond W83627EHF";
            case Chip.W83627HF: return "Winbond W83627HF";
            case Chip.W83627THF: return "Winbond W83627THF";
            case Chip.W83667HG: return "Winbond W83667HG";
            case Chip.W83667HGB: return "Winbond W83667HG-B";
            case Chip.W83687THF: return "Winbond W83687THF";

            case Chip.Unknown: return "Unkown";
            default: return "Unknown";
              }
        }
예제 #14
0
 public void UpdateRates(Chip chip)
 {
     //Mame seems to reverse this where enabling ksr actually lowers
     //the rate, but pdf manuals says otherwise?
     var newKsr = (ChanData >> Channel.ShiftKeyCode) & 0xff;
     if (!HasFlag(reg20, Mask.Ksr))
     {
         newKsr >>= 2;
     }
     if (ksr == newKsr)
         return;
     ksr = (byte)newKsr;
     UpdateAttack(chip);
     UpdateDecay(chip);
     UpdateRelease(chip);
 }
예제 #15
0
 // control function for mobile devices
 void MobileUpdate()
 {
     if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) {
         Vector2 point = controlCamera.ScreenPointToRay(Input.GetTouch(0).position).origin;
         hit = Physics2D.Raycast(point, Vector2.zero);
         if (!hit.transform) return;
         pressedChip = hit.transform.GetComponent<Chip>();
         pressPoint = Input.GetTouch(0).position;
     }
     if (Input.touchCount > 0 && pressedChip) {
         Vector2 move = Input.GetTouch(0).position - pressPoint;
         if (move.magnitude > Screen.height * 0.05f) {
             foreach (Side side in Utils.straightSides)
                 if (Vector2.Angle(move, Utils.SideOffsetX(side) * Vector2.right + Utils.SideOffsetY(side) * Vector2.up) <= 45)
                     pressedChip.Swap(side);
             pressedChip = null;
         }
     }
 }
예제 #16
0
 // Control function for stationary platforms
 void DecktopUpdate()
 {
     if (Input.GetMouseButtonDown(0)) {
         Vector2 point = controlCamera.ScreenPointToRay(Input.mousePosition).origin;
         hit = Physics2D.Raycast(point, Vector2.zero);
         if (!hit.transform) return;
         pressedChip = hit.transform.GetComponent<Chip>();
         pressPoint = Input.mousePosition;
     }
     if (Input.GetMouseButton(0) && pressedChip != null) {
         Vector2 move = Input.mousePosition;
         move -= pressPoint;
         if (move.magnitude > Screen.height * 0.05f) {
             foreach (Side side in Utils.straightSides)
                 if (Vector2.Angle(move, Utils.SideOffsetX(side) * Vector2.right + Utils.SideOffsetY(side) * Vector2.up) <= 45)
                     pressedChip.Swap(side);
             pressedChip = null;
         }
     }
 }
예제 #17
0
    // Function immediate swapping 2 chips
    public void SwapTwoItemNow(Chip a, Chip b)
    {
        if (!a || !b) return;
        if (a == b) return;
        if (a.parentSlot.slot.GetBlock() || b.parentSlot.slot.GetBlock()) return;

        Vector3 posA = a.parentSlot.transform.position;
        Vector3 posB = b.parentSlot.transform.position;

        a.transform.position = posB;
        b.transform.position = posA;

        a.movementID = SessionAssistant.main.GetMovementID();
        b.movementID = SessionAssistant.main.GetMovementID();

        SlotForChip slotA = a.parentSlot;
        SlotForChip slotB = b.parentSlot;

        slotB.SetChip(a);
        slotA.SetChip(b);
    }
예제 #18
0
        public NCT677X(Chip chip, byte revision, ushort port)
        {
            this.chip = chip;
              this.revision = revision;
              this.port = port;

              if (!IsNuvotonVendor())
            return;

              switch (chip) {
            case LPC.Chip.NCT6771F:
              fans = new float?[4];
              // min value RPM value with 16-bit fan counter
              minFanRPM = (int)(1.35e6 / 0xFFFF);
              break;
            case LPC.Chip.NCT6776F:
              fans = new float?[5];
              // min value RPM value with 13-bit fan counter
              minFanRPM = (int)(1.35e6 / 0x1FFF);
              break;
              }
        }
예제 #19
0
파일: DosBoxOPL.cs 프로젝트: scemino/nscumm
        public void Init(int rate)
        {
            Free();

            _reg = new Reg();
            for (int i = 0; i < _chip.Length; i++)
            {
                _chip[i] = new OplChip();
            }
            _emulator = new Chip();

            InitTables();
            _emulator.Setup(rate);

            if (_type == OplType.DualOpl2)
            {
                // Setup opl3 mode in the hander
                _emulator.WriteReg(0x105, 1);
            }

            _rate = rate;
        }
예제 #20
0
 public void WriteB0(Chip chip, byte val)
 {
     byte fourOp = (byte)(chip.Reg104 & chip.Opl3Active & FourMask);
     //Don't handle writes to silent fourop channels
     if (fourOp > 0x80)
         return;
     int change = ((chanData ^ (val << 8)) & 0x1f00);
     if (change != 0)
     {
         chanData ^= change;
         UpdateFrequency(chip, fourOp);
     }
     //Check for a change in the keyon/off state
     if (0 == ((val ^ regB0) & 0x20))
         return;
     regB0 = val;
     if ((val & 0x20) != 0)
     {
         Op(0).KeyOn(0x1);
         Op(1).KeyOn(0x1);
         if ((fourOp & 0x3f) != 0)
         {
             Chip.Channels[ChannelNum + 1].Op(0).KeyOn(1);
             Chip.Channels[ChannelNum + 1].Op(1).KeyOn(1);
         }
     }
     else
     {
         Op(0).KeyOff(0x1);
         Op(1).KeyOff(0x1);
         if ((fourOp & 0x3f) != 0)
         {
             Chip.Channels[ChannelNum + 1].Op(0).KeyOff(1);
             Chip.Channels[ChannelNum + 1].Op(1).KeyOff(1);
         }
     }
 }
예제 #21
0
		public void AddChipInColumn (Chip chip, int column)
		{
			int row = NextEmptySlotInColumn (column);
			if (row >= 0)
				SetChipInColumnRow (chip, column, row);
		}
예제 #22
0
 void Awake()
 {
     chip = GetComponent<Chip>();
     chip.chipType = "SimpleChip";
 }
예제 #23
0
		void SetChipInColumnRow (Chip chip, int column, int row)
		{
			Cells [row + column * Height] = chip;
		}
예제 #24
0
        public W836XX(Chip chip, byte revision, ushort address)
        {
            this.address  = address;
            this.revision = revision;
            this.chip     = chip;

            if (!IsWinbondVendor())
            {
                return;
            }

            temperatures    = new float?[3];
            peciTemperature = new bool[3];
            switch (chip)
            {
            case Chip.W83667HG:
            case Chip.W83667HGB:
                // note temperature sensor registers that read PECI
                byte flag = ReadByte(0, TEMPERATURE_SOURCE_SELECT_REG);
                peciTemperature[0] = (flag & 0x04) != 0;
                peciTemperature[1] = (flag & 0x40) != 0;
                peciTemperature[2] = false;
                break;

            case Chip.W83627DHG:
            case Chip.W83627DHGP:
                // do not add temperature sensor registers that read PECI
                byte sel = ReadByte(0, TEMPERATURE_SOURCE_SELECT_REG);
                peciTemperature[0] = (sel & 0x07) != 0;
                peciTemperature[1] = (sel & 0x70) != 0;
                peciTemperature[2] = false;
                break;

            default:
                // no PECI support
                peciTemperature[0] = false;
                peciTemperature[1] = false;
                peciTemperature[2] = false;
                break;
            }

            switch (chip)
            {
            case Chip.W83627EHF:
                voltages        = new float?[10];
                voltageRegister = new byte[] {
                    0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x50, 0x51, 0x52
                };
                voltageBank = new byte[] { 0, 0, 0, 0, 0, 0, 0, 5, 5, 5 };
                voltageGain = 0.008f;
                fans        = new float?[5];
                break;

            case Chip.W83627DHG:
            case Chip.W83627DHGP:
            case Chip.W83667HG:
            case Chip.W83667HGB:
                voltages        = new float?[9];
                voltageRegister = new byte[] {
                    0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x50, 0x51
                };
                voltageBank = new byte[] { 0, 0, 0, 0, 0, 0, 0, 5, 5 };
                voltageGain = 0.008f;
                fans        = new float?[5];
                break;

            case Chip.W83627HF:
            case Chip.W83627THF:
            case Chip.W83687THF:
                voltages        = new float?[7];
                voltageRegister = new byte[] {
                    0x20, 0x21, 0x22, 0x23, 0x24, 0x50, 0x51
                };
                voltageBank = new byte[] { 0, 0, 0, 0, 0, 5, 5 };
                voltageGain = 0.016f;
                fans        = new float?[3];
                break;
            }
        }
예제 #25
0
        public LPCIO(Mainboard.Manufacturer mainboardManufacturer,
                     Mainboard.Model mainboardModel)
        {
            if (!WinRing0.IsAvailable)
            {
                return;
            }

            for (int i = 0; i < REGISTER_PORTS.Length; i++)
            {
                registerPort = REGISTER_PORTS[i];
                valuePort    = VALUE_PORTS[i];

                WinbondFintekEnter();

                byte logicalDeviceNumber;
                byte id       = ReadByte(CHIP_ID_REGISTER);
                byte revision = ReadByte(CHIP_REVISION_REGISTER);
                chip = Chip.Unknown;
                logicalDeviceNumber = 0;
                switch (id)
                {
                case 0x05:
                    switch (revision)
                    {
                    case 0x07:
                        chip = Chip.F71858;
                        logicalDeviceNumber = F71858_HARDWARE_MONITOR_LDN;
                        break;

                    case 0x41:
                        chip = Chip.F71882;
                        logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
                        break;
                    }
                    break;

                case 0x06:
                    switch (revision)
                    {
                    case 0x01:
                        chip = Chip.F71862;
                        logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
                        break;
                    }
                    break;

                case 0x07:
                    switch (revision)
                    {
                    case 0x23:
                        chip = Chip.F71889F;
                        logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
                        break;
                    }
                    break;

                case 0x08:
                    switch (revision)
                    {
                    case 0x14:
                        chip = Chip.F71869;
                        logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
                        break;
                    }
                    break;

                case 0x09:
                    switch (revision)
                    {
                    case 0x09:
                        chip = Chip.F71889ED;
                        logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
                        break;
                    }
                    break;

                case 0x52:
                    switch (revision)
                    {
                    case 0x17:
                    case 0x3A:
                    case 0x41:
                        chip = Chip.W83627HF;
                        logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
                        break;
                    }
                    break;

                case 0x82:
                    switch (revision)
                    {
                    case 0x83:
                        chip = Chip.W83627THF;
                        logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
                        break;
                    }
                    break;

                case 0x85:
                    switch (revision)
                    {
                    case 0x41:
                        chip = Chip.W83687THF;
                        logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
                        break;
                    }
                    break;

                case 0x88:
                    switch (revision & 0xF0)
                    {
                    case 0x50:
                    case 0x60:
                        chip = Chip.W83627EHF;
                        logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
                        break;
                    }
                    break;

                case 0xA0:
                    switch (revision & 0xF0)
                    {
                    case 0x20:
                        chip = Chip.W83627DHG;
                        logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
                        break;
                    }
                    break;

                case 0xA5:
                    switch (revision & 0xF0)
                    {
                    case 0x10:
                        chip = Chip.W83667HG;
                        logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
                        break;
                    }
                    break;

                case 0xB0:
                    switch (revision & 0xF0)
                    {
                    case 0x70:
                        chip = Chip.W83627DHGP;
                        logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
                        break;
                    }
                    break;

                case 0xB3:
                    switch (revision & 0xF0)
                    {
                    case 0x50:
                        chip = Chip.W83667HGB;
                        logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
                        break;
                    }
                    break;
                }
                if (chip == Chip.Unknown)
                {
                    if (id != 0 && id != 0xff)
                    {
                        WinbondFintekExit();

                        report.Append("Chip ID: Unknown Winbond / Fintek with ID 0x");
                        report.AppendLine(((id << 8) | revision).ToString("X"));
                        report.AppendLine();
                    }
                }
                else
                {
                    Select(logicalDeviceNumber);
                    ushort address = ReadWord(BASE_ADDRESS_REGISTER);
                    Thread.Sleep(1);
                    ushort verify = ReadWord(BASE_ADDRESS_REGISTER);

                    ushort vendorID = ReadWord(FINTEK_VENDOR_ID_REGISTER);

                    WinbondFintekExit();

                    if (address != verify)
                    {
                        report.Append("Chip ID: 0x");
                        report.AppendLine(chip.ToString("X"));
                        report.Append("Chip revision: 0x");
                        report.AppendLine(revision.ToString("X"));
                        report.AppendLine("Error: Address verification failed");
                        report.AppendLine();
                        return;
                    }

                    // some Fintek chips have address register offset 0x05 added already
                    if ((address & 0x07) == 0x05)
                    {
                        address &= 0xFFF8;
                    }

                    if (address < 0x100 || (address & 0xF007) != 0)
                    {
                        report.Append("Chip ID: 0x");
                        report.AppendLine(chip.ToString("X"));
                        report.Append("Chip revision: 0x");
                        report.AppendLine(revision.ToString("X"));
                        report.Append("Error: Invalid address 0x");
                        report.AppendLine(address.ToString("X"));
                        report.AppendLine();
                        return;
                    }

                    switch (chip)
                    {
                    case Chip.W83627DHG:
                    case Chip.W83627DHGP:
                    case Chip.W83627EHF:
                    case Chip.W83627HF:
                    case Chip.W83627THF:
                    case Chip.W83667HG:
                    case Chip.W83667HGB:
                    case Chip.W83687THF:
                        W836XX w836XX = new W836XX(chip, revision, address);
                        if (w836XX.IsAvailable)
                        {
                            hardware.Add(w836XX);
                        }
                        break;

                    case Chip.F71858:
                    case Chip.F71862:
                    case Chip.F71869:
                    case Chip.F71882:
                    case Chip.F71889ED:
                    case Chip.F71889F:
                        if (vendorID != FINTEK_VENDOR_ID)
                        {
                            report.Append("Chip ID: 0x");
                            report.AppendLine(chip.ToString("X"));
                            report.Append("Chip revision: 0x");
                            report.AppendLine(revision.ToString("X"));
                            report.Append("Error: Invalid vendor ID 0x");
                            report.AppendLine(vendorID.ToString("X"));
                            report.AppendLine();
                            return;
                        }
                        hardware.Add(new F718XX(chip, address));
                        break;

                    default: break;
                    }

                    return;
                }

                IT87Enter();

                ushort chipID = ReadWord(CHIP_ID_REGISTER);
                switch (chipID)
                {
                case 0x8712: chip = Chip.IT8712F; break;

                case 0x8716: chip = Chip.IT8716F; break;

                case 0x8718: chip = Chip.IT8718F; break;

                case 0x8720: chip = Chip.IT8720F; break;

                case 0x8726: chip = Chip.IT8726F; break;

                default: chip = Chip.Unknown; break;
                }
                if (chip == Chip.Unknown)
                {
                    if (chipID != 0 && chipID != 0xffff)
                    {
                        IT87Exit();

                        report.Append("Chip ID: Unknown ITE with ID 0x");
                        report.AppendLine(chipID.ToString("X"));
                        report.AppendLine();
                    }
                }
                else
                {
                    Select(IT87_ENVIRONMENT_CONTROLLER_LDN);
                    ushort address = ReadWord(BASE_ADDRESS_REGISTER);
                    Thread.Sleep(1);
                    ushort verify = ReadWord(BASE_ADDRESS_REGISTER);

                    IT87Exit();

                    if (address != verify || address < 0x100 || (address & 0xF007) != 0)
                    {
                        report.Append("Chip ID: 0x");
                        report.AppendLine(chip.ToString("X"));
                        report.Append("Error: Invalid address 0x");
                        report.AppendLine(address.ToString("X"));
                        report.AppendLine();
                        return;
                    }

                    IT87XX it87 = new IT87XX(chip, address, mainboardManufacturer,
                                             mainboardModel);
                    if (it87.IsAvailable)
                    {
                        hardware.Add(it87);
                    }

                    return;
                }

                SMSCEnter();

                chipID = ReadWord(CHIP_ID_REGISTER);
                switch (chipID)
                {
                default: chip = Chip.Unknown; break;
                }
                if (chip == Chip.Unknown)
                {
                    if (chipID != 0 && chipID != 0xffff)
                    {
                        SMSCExit();

                        report.Append("Chip ID: Unknown SMSC with ID 0x");
                        report.AppendLine(chipID.ToString("X"));
                        report.AppendLine();
                    }
                }
                else
                {
                    SMSCExit();

                    return;
                }
            }
        }
예제 #26
0
 void  Awake()
 {
     _chip = GetComponent <Chip>();
     birth = SessionAssistant.main.eventCount;
     AudioAssistant.Shot("CreateCrossBomb");
 }
예제 #27
0
 /// @todo document Gear.GUI.LogicProbe.PresentChip()
 ///
 public override void PresentChip()
 {
     Chip.NotifyOnPins(this);
 }
예제 #28
0
        public W836XX(Chip chip, byte revision, ushort address)
        {
            this.address  = address;
            this.revision = revision;
            this.chip     = chip;

            if (!IsWinbondVendor())
            {
                return;
            }

            temperatures    = new float?[3];
            peciTemperature = new bool[3];
            switch (chip)
            {
            case Chip.W83667HG:
            case Chip.W83667HGB:
                // note temperature sensor registers that read PECI
                byte flag = ReadByte(0, TEMPERATURE_SOURCE_SELECT_REG);
                peciTemperature[0] = (flag & 0x04) != 0;
                peciTemperature[1] = (flag & 0x40) != 0;
                peciTemperature[2] = false;
                break;

            case Chip.W83627DHG:
            case Chip.W83627DHGP:
                // note temperature sensor registers that read PECI
                byte sel = ReadByte(0, TEMPERATURE_SOURCE_SELECT_REG);
                peciTemperature[0] = (sel & 0x07) != 0;
                peciTemperature[1] = (sel & 0x70) != 0;
                peciTemperature[2] = false;
                break;

            default:
                // no PECI support
                peciTemperature[0] = false;
                peciTemperature[1] = false;
                peciTemperature[2] = false;
                break;
            }

            switch (chip)
            {
            case Chip.W83627EHF:
                voltages        = new float?[10];
                voltageRegister = new byte[] { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x50, 0x51, 0x52 };
                voltageBank     = new byte[] { 0, 0, 0, 0, 0, 0, 0, 5, 5, 5 };
                voltageGain     = 0.008f;
                fans            = new float?[5];
                fanPwmRegister  = new byte[] { 0x01, 0x03, 0x11 };                                   // Fan PWM values.
                fanPrimaryControlModeRegister   = new byte[] { 0x04, 0x04, 0x12 };                   // Primary control register.
                fanPrimaryControlValue          = new byte[] { 0b11110011, 0b11001111, 0b11111001 }; // Values to gain control of fans.
                initialFanPrimaryControlValue   = new byte[3];                                       // To store default value.
                initialFanSecondaryControlValue = new byte[3];                                       // To store default value.
                controls = new float?[3];
                break;

            case Chip.W83627DHG:
            case Chip.W83627DHGP:
                voltages        = new float?[9];
                voltageRegister = new byte[] { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x50, 0x51 };
                voltageBank     = new byte[] { 0, 0, 0, 0, 0, 0, 0, 5, 5 };
                voltageGain     = 0.008f;
                fans            = new float?[5];
                fanPwmRegister  = new byte[] { 0x01, 0x03, 0x11 };                                   // Fan PWM values
                fanPrimaryControlModeRegister   = new byte[] { 0x04, 0x04, 0x12 };                   // Primary control register
                fanPrimaryControlValue          = new byte[] { 0b11110011, 0b11001111, 0b11111001 }; // Values to gain control of fans
                initialFanPrimaryControlValue   = new byte[3];                                       // To store default value
                initialFanSecondaryControlValue = new byte[3];                                       // To store default value.
                controls = new float?[3];
                break;

            case Chip.W83667HG:
            case Chip.W83667HGB:
                voltages        = new float?[9];
                voltageRegister = new byte[] { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x50, 0x51 };
                voltageBank     = new byte[] { 0, 0, 0, 0, 0, 0, 0, 5, 5 };
                voltageGain     = 0.008f;
                fans            = new float?[5];
                fanPwmRegister  = new byte[] { 0x01, 0x03, 0x11 };                                   // Fan PWM values.
                fanPrimaryControlModeRegister   = new byte[] { 0x04, 0x04, 0x12 };                   // Primary control register.
                fanPrimaryControlValue          = new byte[] { 0b11110011, 0b11001111, 0b11111001 }; // Values to gain control of fans.
                fanSecondaryControlModeRegister = new byte[] { 0x7c, 0x7c, 0x7c };                   // Secondary control register for SmartFan4.
                fanSecondaryControlValue        = new byte[] { 0b11101111, 0b11011111, 0b10111111 }; // Values for secondary register to gain control of fans.
                fanTertiaryControlModeRegister  = new byte[] { 0x62, 0x7c, 0x62 };                   // Tertiary control register. 2nd fan doesn't have Tertiary control, same as secondary to avoid change.
                fanTertiaryControlValue         = new byte[] { 0b11101111, 0b11011111, 0b11011111 }; // Values for tertiary register to gain control of fans. 2nd fan doesn't have Tertiary control, same as secondary to avoid change.
                initialFanPrimaryControlValue   = new byte[3];                                       // To store default value.
                initialFanSecondaryControlValue = new byte[3];                                       // To store default value.
                initialFanTertiaryControlValue  = new byte[3];                                       // To store default value.
                controls = new float?[3];
                break;

            case Chip.W83627HF:
                voltages        = new float?[7];
                voltageRegister = new byte[] { 0x20, 0x21, 0x22, 0x23, 0x24, 0x50, 0x51 };
                voltageBank     = new byte[] { 0, 0, 0, 0, 0, 5, 5 };
                voltageGain     = 0.016f;
                fans            = new float?[3];
                fanPwmRegister  = new byte[] { 0x5A, 0x5B }; // Fan PWM values.
                controls        = new float?[2];
                break;

            case Chip.W83627THF:
                voltages        = new float?[7];
                voltageRegister = new byte[] { 0x20, 0x21, 0x22, 0x23, 0x24, 0x50, 0x51 };
                voltageBank     = new byte[] { 0, 0, 0, 0, 0, 5, 5 };
                voltageGain     = 0.016f;
                fans            = new float?[3];
                fanPwmRegister  = new byte[] { 0x01, 0x03, 0x11 };                                 // Fan PWM values.
                fanPrimaryControlModeRegister = new byte[] { 0x04, 0x04, 0x12 };                   // Primary control register.
                fanPrimaryControlValue        = new byte[] { 0b11110011, 0b11001111, 0b11111001 }; // Values to gain control of fans.
                initialFanPrimaryControlValue = new byte[3];                                       // To store default value.
                controls = new float?[3];
                break;

            case Chip.W83687THF:
                voltages        = new float?[7];
                voltageRegister = new byte[] { 0x20, 0x21, 0x22, 0x23, 0x24, 0x50, 0x51 };
                voltageBank     = new byte[] { 0, 0, 0, 0, 0, 5, 5 };
                voltageGain     = 0.016f;
                fans            = new float?[3];
                break;
            }
        }
예제 #29
0
        public IT87XX(Chip chip, ushort address, ushort gpioAddress, byte version)
        {
            this.address     = address;
            this.chip        = chip;
            this.version     = version;
            this.addressReg  = (ushort)(address + ADDRESS_REGISTER_OFFSET);
            this.dataReg     = (ushort)(address + DATA_REGISTER_OFFSET);
            this.gpioAddress = gpioAddress;

            // Check vendor id
            bool valid;
            byte vendorId = ReadByte(VENDOR_ID_REGISTER, out valid);

            if (!valid || vendorId != ITE_VENDOR_ID)
            {
                return;
            }

            // Bit 0x10 of the configuration register should always be 1
            byte config = ReadByte(CONFIGURATION_REGISTER, out valid);

            if ((config & 0x10) == 0 && chip != Chip.IT8665E)
            {
                return;
            }
            if (!valid)
            {
                return;
            }

            // IT8686E has more sensors
            if (chip == Chip.IT8686E)
            {
                voltages     = new float?[10];
                temperatures = new float?[5];
                fans         = new float?[5];
                fansDisabled = new bool[5];
                controls     = new float?[3];
            }
            else if (chip == Chip.IT8665E)
            {
                voltages     = new float?[10];
                temperatures = new float?[6];
                fans         = new float?[6];
                fansDisabled = new bool[6];
                controls     = new float?[3];
            }
            else if (chip == Chip.IT8688E)
            {
                voltages     = new float?[11];
                temperatures = new float?[6];
                fans         = new float?[5];
                fansDisabled = new bool[5];
                controls     = new float?[3];
            }
            else
            {
                voltages     = new float?[9];
                temperatures = new float?[3];
                fans         = new float?[chip == Chip.IT8705F ? 3 : 5];
                fansDisabled = new bool[chip == Chip.IT8705F ? 3 : 5];
                controls     = new float?[3];
            }

            // IT8620E, IT8628E, IT8721F, IT8728F, IT8772E and IT8686E use a 12mV resultion
            // ADC, all others 16mV
            if (chip == Chip.IT8620E || chip == Chip.IT8628E || chip == Chip.IT8721F ||
                chip == Chip.IT8728F || chip == Chip.IT8771E || chip == Chip.IT8772E ||
                chip == Chip.IT8686E || chip == Chip.IT8688E)
            {
                voltageGain = 0.012f;
            }
            else if (chip == Chip.IT8665E)
            {
                voltageGain = 0.0109f;
            }
            else
            {
                voltageGain = 0.016f;
            }

            // older IT8705F and IT8721F revisions do not have 16-bit fan counters
            if ((chip == Chip.IT8705F && version < 3) ||
                (chip == Chip.IT8712F && version < 8))
            {
                has16bitFanCounter = false;
            }
            else
            {
                has16bitFanCounter = true;
            }

            if (chip == Chip.IT8620E)
            {
                hasNewerAutopwm = true;
            }

            // Disable any fans that aren't set with 16-bit fan counters
            if (has16bitFanCounter)
            {
                int modes = ReadByte(FAN_TACHOMETER_16BIT_REGISTER, out valid);

                if (!valid)
                {
                    return;
                }

                if (fans.Length >= 5)
                {
                    fansDisabled[3] = (modes & (1 << 4)) == 0;
                    fansDisabled[4] = (modes & (1 << 5)) == 0;
                }
                if (fans.Length >= 6)
                {
                    fansDisabled[5] = (modes & (1 << 2)) == 0;
                }
            }

            // Set the number of GPIO sets
            switch (chip)
            {
            case Chip.IT8712F:
            case Chip.IT8716F:
            case Chip.IT8718F:
            case Chip.IT8726F:
                gpioCount = 5;
                break;

            case Chip.IT8720F:
            case Chip.IT8721F:
                gpioCount = 8;
                break;

            case Chip.IT8620E:
            case Chip.IT8628E:
            case Chip.IT8688E:
            case Chip.IT8705F:
            case Chip.IT8728F:
            case Chip.IT8771E:
            case Chip.IT8772E:
                gpioCount = 0;
                break;
            }
        }
예제 #30
0
        public static string GetName(Chip chip)
        {
            switch (chip)
            {
            case Chip.ATK0110: return("Asus ATK0110");

            case Chip.F71858: return("Fintek F71858");

            case Chip.F71862: return("Fintek F71862");

            case Chip.F71869: return("Fintek F71869");

            case Chip.F71869A: return("Fintek F71869A");

            case Chip.F71882: return("Fintek F71882");

            case Chip.F71889AD: return("Fintek F71889AD");

            case Chip.F71889ED: return("Fintek F71889ED");

            case Chip.F71889F: return("Fintek F71889F");

            case Chip.F71808E: return("Fintek F71808E");

            case Chip.IT8705F: return("ITE IT8705F");

            case Chip.IT8712F: return("ITE IT8712F");

            case Chip.IT8716F: return("ITE IT8716F");

            case Chip.IT8718F: return("ITE IT8718F");

            case Chip.IT8720F: return("ITE IT8720F");

            case Chip.IT8721F: return("ITE IT8721F");

            case Chip.IT8726F: return("ITE IT8726F");

            case Chip.IT8728F: return("ITE IT8728F");

            case Chip.IT8771E: return("ITE IT8771E");

            case Chip.IT8772E: return("ITE IT8772E");

            case Chip.NCT6771F: return("Nuvoton NCT6771F");

            case Chip.NCT6776F: return("Nuvoton NCT6776F");

            case Chip.NCT6779D: return("Nuvoton NCT6779D");

            case Chip.NCT6791D: return("Nuvoton NCT6791D");

            case Chip.W83627DHG: return("Winbond W83627DHG");

            case Chip.W83627DHGP: return("Winbond W83627DHG-P");

            case Chip.W83627EHF: return("Winbond W83627EHF");

            case Chip.W83627HF: return("Winbond W83627HF");

            case Chip.W83627THF: return("Winbond W83627THF");

            case Chip.W83667HG: return("Winbond W83667HG");

            case Chip.W83667HGB: return("Winbond W83667HG-B");

            case Chip.W83687THF: return("Winbond W83687THF");

            case Chip.Unknown: return("Unkown");

            default: return("Unknown");
            }
        }
예제 #31
0
        private void Renderer()
        {
            this.Dispatcher.Invoke(() =>
            {
                AppCanvas.Children.Clear();
                //Draw Vertices
                foreach (Vertex <LocationVertexPair> appGraphVertex in AppGraph.Vertices)
                {
                    //Vertex
                    var tmpElement = appGraphVertex.Data.Element;
                    Canvas.SetTop(tmpElement, appGraphVertex.Data.Y - 30);
                    Canvas.SetLeft(tmpElement, appGraphVertex.Data.X - 30);
//                   AppCanvas.Children.Add(tmpElement);

                    int elementIndex = AppCanvas.Children.IndexOf(tmpElement);
                    if (elementIndex == -1)
                    {
                        AppCanvas.Children.Add(tmpElement);
                    }
                    else
                    {
                        AppCanvas.Children[elementIndex] = tmpElement;
                    }
                }

                //Draw Location Chips
                foreach (Vertex <LocationVertexPair> appGraphVertex in AppGraph.Vertices)
                {
                    //Vertex Name
                    Chip newChip                  = new Chip();
                    var tmpChipName               = appGraphVertex.Data.Location.Data;
                    newChip.Content               = tmpChipName;
                    newChip.Foreground            = Brushes.AliceBlue;
                    newChip.RenderTransformOrigin = new Point(0.5, 0.5);

                    Canvas.SetTop(newChip, appGraphVertex.Data.Y + 20);
                    Canvas.SetLeft(newChip, appGraphVertex.Data.X - 25);
                    //                    AppCanvas.Children.Add(newChip);

                    int chipIndex = AppCanvas.Children.IndexOf(newChip);
                    if (chipIndex == -1)
                    {
                        AppCanvas.Children.Add(newChip);
                    }
                    else
                    {
                        AppCanvas.Children[chipIndex] = newChip;
                    }
                }

                //Draw Line
                foreach (Vertex <LocationVertexPair> appGraphVertex in AppGraph.Vertices)
                {
                    foreach (Neighbor <LocationVertexPair> neighbor in appGraphVertex.Neighbors)
                    {
                        //MainRoad
                        Line newLine = new Line();
                        newLine.X2   = appGraphVertex.Data.X;
                        newLine.Y2   = appGraphVertex.Data.Y;

                        newLine.X1 = neighbor.Vertex.Data.X;
                        newLine.Y1 = neighbor.Vertex.Data.Y;

                        newLine.Stroke             = Brushes.Black;
                        newLine.StrokeThickness    = 30;
                        newLine.StrokeEndLineCap   = PenLineCap.Round;
                        newLine.StrokeStartLineCap = PenLineCap.Round;

                        //                        AppCanvas.Children.Add(newLine);
                        int lineIndex = AppCanvas.Children.IndexOf(newLine);
                        if (lineIndex == -1)
                        {
                            AppCanvas.Children.Add(newLine);
                        }
                        else
                        {
                            AppCanvas.Children[lineIndex] = newLine;
                        }


                        //RoadLength Chip
                        Chip newChip                  = new Chip();
                        newChip.Content               = neighbor.Weight;
                        newChip.Foreground            = Brushes.LightCyan;
                        newChip.RenderTransformOrigin = new Point(0.5, 0.5);

                        var deltaY = appGraphVertex.Data.Y - neighbor.Vertex.Data.Y;
                        var deltaX = appGraphVertex.Data.X - neighbor.Vertex.Data.X;

                        Canvas.SetTop(newChip, neighbor.Vertex.Data.Y + (0.5 * deltaY) - 40);
                        Canvas.SetLeft(newChip, neighbor.Vertex.Data.X + (0.5 * deltaX) - 40);

                        //                        AppCanvas.Children.Add(newChip);
                        int chipIndex = AppCanvas.Children.IndexOf(newChip);
                        if (chipIndex == -1)
                        {
                            AppCanvas.Children.Add(newChip);
                        }
                        else
                        {
                            AppCanvas.Children[chipIndex] = newChip;
                        }


                        //DashLine
                        newLine    = new Line();
                        newLine.X2 = appGraphVertex.Data.X;
                        newLine.Y2 = appGraphVertex.Data.Y;

                        newLine.X1 = neighbor.Vertex.Data.X;
                        newLine.Y1 = neighbor.Vertex.Data.Y;

                        newLine.Stroke          = Brushes.White;
                        newLine.StrokeThickness = 5;
                        newLine.StrokeDashArray = doubleCollection;

                        //                        AppCanvas.Children.Add(newLine);
                        int dashlineIndex = AppCanvas.Children.IndexOf(newLine);
                        if (dashlineIndex == -1)
                        {
                            AppCanvas.Children.Add(newLine);
                        }
                        else
                        {
                            AppCanvas.Children[dashlineIndex] = newLine;
                        }
                    }
                }
            });
        }
예제 #32
0
        private void OnDataSeqFrq(long SeqCounter)
        {
            //throw new NotImplementedException();
            if (mv == null)
            {
                return;
            }
            if (mv.desVGM == null)
            {
                return;
            }
            if (mv.desVGM.dat == null)
            {
                return;
            }

            if ((Audio.sm.Mode & SendMode.MML) != SendMode.MML)
            {
                if (rtMML != null)
                {
                    rtMML.OneFrameSeq();
                }
            }

            if (mv.desVGM.dat.Count == 0)
            {
                return;
            }
            eChip = Audio.GetChip(EnmChip.YM2608);
            if (eChip == null)
            {
                return;
            }


            Enq             enq = SoundManager.GetDriverDataEnqueue();
            List <outDatum> dat = mv.desVGM.ym2608[0].lstPartWork[0].pg[0].sendData;// mv.desVGM.dat;

            lock (lockObject)
            {
                while (0 < dat.Count)
                {
                    outDatum od = dat[0];
                    if (od == null)
                    {
                        dat.RemoveAt(0);
                        continue;
                    }

                    byte val = od.val;
                    byte adr;
                    byte prm;
                    switch (val)
                    {
                    case 0x52:
                        adr = dat[1].val;
                        prm = dat[2].val;
                        enq(dat[0], SeqCounter, eChip, EnmDataType.Normal, adr, prm, null);
                        dat.RemoveAt(0);
                        dat.RemoveAt(0);
                        dat.RemoveAt(0);
                        break;

                    case 0x56:
                        if (2 >= dat.Count)
                        {
                            return;
                        }
                        adr = dat[1].val;
                        prm = dat[2].val;
                        enq(dat[0], 0, eChip, EnmDataType.Force, adr, prm, null);
                        dat.RemoveAt(0);
                        dat.RemoveAt(0);
                        dat.RemoveAt(0);
                        break;

                    default:
                        dat.RemoveAt(0);
                        break;
                    }
                }
            }
        }
예제 #33
0
        public NCT677X(Chip chip, byte revision, ushort port, LPCPort lpcPort)
        {
            Chip          = chip;
            this.revision = revision;
            this.port     = port;
            this.lpcPort  = lpcPort;

            if (chip == Chip.NCT610X)
            {
                VENDOR_ID_HIGH_REGISTER = 0x80FE;
                VENDOR_ID_LOW_REGISTER  = 0x00FE;

                FAN_PWM_OUT_REG      = new ushort[] { 0x04A, 0x04B, 0x04C };
                FAN_PWM_COMMAND_REG  = new ushort[] { 0x119, 0x129, 0x139 };
                FAN_CONTROL_MODE_REG = new ushort[] { 0x113, 0x123, 0x133 };

                vBatMonitorControlRegister = 0x0318;
            }
            else
            {
                VENDOR_ID_HIGH_REGISTER = 0x804F;
                VENDOR_ID_LOW_REGISTER  = 0x004F;

                FAN_PWM_OUT_REG = new ushort[]
                {
                    0x001, 0x003, 0x011, 0x013, 0x015, 0x017
                };
                FAN_PWM_COMMAND_REG = new ushort[]
                {
                    0x109, 0x209, 0x309, 0x809, 0x909, 0xA09
                };
                FAN_CONTROL_MODE_REG = new ushort[]
                {
                    0x102, 0x202, 0x302, 0x802, 0x902, 0xA02
                };

                vBatMonitorControlRegister = 0x005D;
            }

            isNuvotonVendor = IsNuvotonVendor();

            if (!isNuvotonVendor)
            {
                return;
            }

            switch (chip)
            {
            case Chip.NCT6771F:
            case Chip.NCT6776F:
                if (chip == Chip.NCT6771F)
                {
                    Fans = new float?[4];

                    // min value RPM value with 16-bit fan counter
                    minFanRPM = (int)(1.35e6 / 0xFFFF);

                    temperaturesSource = new[]
                    {
                        (byte)SourceNCT6771F.PECI_0,
                        (byte)SourceNCT6771F.CPUTIN,
                        (byte)SourceNCT6771F.AUXTIN,
                        (byte)SourceNCT6771F.SYSTIN
                    };
                }
                else
                {
                    Fans = new float?[5];

                    // min value RPM value with 13-bit fan counter
                    minFanRPM = (int)(1.35e6 / 0x1FFF);

                    temperaturesSource = new[]
                    {
                        (byte)SourceNCT6776F.PECI_0,
                        (byte)SourceNCT6776F.CPUTIN,
                        (byte)SourceNCT6776F.AUXTIN,
                        (byte)SourceNCT6776F.SYSTIN
                    };
                }
                fanRpmBaseRegister = 0x656;

                Controls = new float?[3];

                Voltages         = new float?[9];
                voltageRegisters = new ushort[]
                { 0x020, 0x021, 0x022, 0x023, 0x024, 0x025, 0x026, 0x550, 0x551 };
                voltageVBatRegister = 0x551;

                Temperatures        = new float?[4];
                temperatureRegister = new ushort[]
                { 0x027, 0x073, 0x075, 0x077, 0x150, 0x250, 0x62B, 0x62C, 0x62D };
                temperatureHalfRegister = new ushort[]
                { 0, 0x074, 0x076, 0x078, 0x151, 0x251, 0x62E, 0x62E, 0x62E };
                temperatureHalfBit = new[]
                { -1, 7, 7, 7, 7, 7, 0, 1, 2 };
                temperatureSourceRegister = new ushort[]
                { 0x621, 0x100, 0x200, 0x300, 0x622, 0x623, 0x624, 0x625, 0x626 };

                alternateTemperatureRegister = new ushort?[]
                { null, null, null, null };
                break;

            case Chip.NCT6779D:
            case Chip.NCT6791D:
                if (chip == Chip.NCT6779D)
                {
                    Fans     = new float?[5];
                    Controls = new float?[5];
                }
                else
                {
                    Fans     = new float?[6];
                    Controls = new float?[6];
                }

                fanRpmBaseRegister = 0x4C0;

                // min value RPM value with 13-bit fan counter
                minFanRPM = (int)(1.35e6 / 0x1FFF);

                Voltages         = new float?[15];
                voltageRegisters = new ushort[]
                {
                    0x480, 0x481, 0x482, 0x483, 0x484, 0x485, 0x486, 0x487, 0x488,
                    0x489, 0x48A, 0x48B, 0x48C, 0x48D, 0x48E
                };
                voltageVBatRegister = 0x488;

                Temperatures       = new float?[7];
                temperaturesSource = new[]
                {
                    (byte)SourceNCT67XXD.PECI_0,
                    (byte)SourceNCT67XXD.CPUTIN,
                    (byte)SourceNCT67XXD.SYSTIN,
                    (byte)SourceNCT67XXD.AUXTIN0,
                    (byte)SourceNCT67XXD.AUXTIN1,
                    (byte)SourceNCT67XXD.AUXTIN2,
                    (byte)SourceNCT67XXD.AUXTIN3
                };

                temperatureRegister = new ushort[]
                { 0x027, 0x073, 0x075, 0x077, 0x079, 0x07B, 0x150 };
                temperatureHalfRegister = new ushort[]
                { 0, 0x074, 0x076, 0x078, 0x07A, 0x07C, 0x151 };
                temperatureHalfBit = new[]
                { -1, 7, 7, 7, 7, 7, 7 };
                temperatureSourceRegister = new ushort[]
                { 0x621, 0x100, 0x200, 0x300, 0x800, 0x900, 0x622 };

                alternateTemperatureRegister = new ushort?[]
                { null, 0x491, 0x490, 0x492, 0x493, 0x494, 0x495 };

                break;

            case Chip.NCT610X:

                Fans     = new float?[3];
                Controls = new float?[3];

                fanRpmBaseRegister = 0x030;

                // min value RPM value with 13-bit fan counter
                minFanRPM = (int)(1.35e6 / 0x1FFF);

                Voltages         = new float?[9];
                voltageRegisters = new ushort[]
                { 0x300, 0x301, 0x302, 0x303, 0x304, 0x305, 0x307, 0x308, 0x309 };
                voltageVBatRegister = 0x308;

                Temperatures       = new float?[4];
                temperaturesSource = new[]
                {
                    (byte)SourceNCT610X.PECI_0,
                    (byte)SourceNCT610X.SYSTIN,
                    (byte)SourceNCT610X.CPUTIN,
                    (byte)SourceNCT610X.AUXTIN
                };

                temperatureRegister = new ushort[]
                { 0x027, 0x018, 0x019, 0x01A };
                temperatureHalfRegister = new ushort[]
                { 0, 0x01B, 0x11B, 0x21B };
                temperatureHalfBit = new[]
                { -1, 7, 7, 7 };
                temperatureSourceRegister = new ushort[]
                { 0x621, 0x100, 0x200, 0x300 };

                alternateTemperatureRegister = new ushort?[]
                { null, 0x018, 0x019, 0x01A };

                break;
            }
        }
예제 #34
0
        public string GetReport()
        {
            var r = new StringBuilder();

            r.AppendLine("LPC " + GetType().Name);
            r.AppendLine();
            r.Append("Chip ID: 0x");
            r.AppendLine(Chip.ToString("X"));
            r.Append("Chip revision: 0x");
            r.AppendLine(revision.ToString("X", CultureInfo.InvariantCulture));
            r.Append("Base Adress: 0x");
            r.AppendLine(port.ToString("X4", CultureInfo.InvariantCulture));
            r.AppendLine();

            if (!Ring0.WaitIsaBusMutex(100))
            {
                return(r.ToString());
            }

            ushort[] addresses =
            {
                0x000,  0x010, 0x020, 0x030, 0x040, 0x050, 0x060, 0x070, 0x0F0,
                0x100,  0x110, 0x120, 0x130, 0x140, 0x150,
                0x200,  0x210, 0x220, 0x230, 0x240, 0x250, 0x260,
                0x300,  0x320, 0x330, 0x340, 0x360,
                0x400,  0x410, 0x420, 0x440, 0x450, 0x460, 0x480, 0x490, 0x4B0,
                0x4C0,  0x4F0,
                0x500,  0x550, 0x560,
                0x600,  0x610, 0x620, 0x630, 0x640, 0x650, 0x660, 0x670,
                0x700,  0x710, 0x720, 0x730,
                0x800,  0x820, 0x830, 0x840,
                0x900,  0x920, 0x930, 0x940, 0x960,
                0xA00,  0xA10, 0xA20, 0xA30, 0xA40, 0xA50, 0xA60, 0xA70,
                0xB00,  0xB10, 0xB20, 0xB30, 0xB50, 0xB60, 0xB70,
                0xC00,  0xC10, 0xC20, 0xC30, 0xC50, 0xC60, 0xC70,
                0xD00,  0xD10, 0xD20, 0xD30, 0xD50, 0xD60,
                0xE00,  0xE10, 0xE20, 0xE30,
                0xF00,  0xF10, 0xF20, 0xF30,
                0x8040, 0x80F0
            };

            r.AppendLine("Hardware Monitor Registers");
            r.AppendLine();
            r.AppendLine("        00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
            r.AppendLine();
            foreach (var address in addresses)
            {
                r.Append(" ");
                r.Append(address.ToString("X4", CultureInfo.InvariantCulture));
                r.Append("  ");
                for (ushort j = 0; j <= 0xF; j++)
                {
                    r.Append(" ");
                    r.Append(ReadByte((ushort)(address | j)).ToString(
                                 "X2", CultureInfo.InvariantCulture));
                }
                r.AppendLine();
            }
            r.AppendLine();

            Ring0.ReleaseIsaBusMutex();

            return(r.ToString());
        }
예제 #35
0
        public Nct677X(Chip chip, byte revision, ushort port, LpcPort lpcPort)
        {
            Chip      = chip;
            _revision = revision;
            _port     = port;
            _lpcPort  = lpcPort;

            if (chip == Chip.NCT610XD)
            {
                VENDOR_ID_HIGH_REGISTER = 0x80FE;
                VENDOR_ID_LOW_REGISTER  = 0x00FE;

                FAN_PWM_OUT_REG      = new ushort[] { 0x04A, 0x04B, 0x04C };
                FAN_PWM_COMMAND_REG  = new ushort[] { 0x119, 0x129, 0x139 };
                FAN_CONTROL_MODE_REG = new ushort[] { 0x113, 0x123, 0x133 };

                _vBatMonitorControlRegister = 0x0318;
            }
            else if (chip == Chip.NCT6687D)
            {
                FAN_PWM_OUT_REG      = new ushort[] { 0x160, 0x161, 0x162, 0x163, 0x164, 0x165, 0x166, 0x167 };
                FAN_PWM_COMMAND_REG  = new ushort[] { 0xA28, 0xA29, 0xA2A, 0xA2B, 0xA2C, 0xA2D, 0xA2E, 0xA2F };
                FAN_CONTROL_MODE_REG = new ushort[] { 0xA00, 0xA00, 0xA00, 0xA00, 0xA00, 0xA00, 0xA00, 0xA00 };
                FAN_PWM_REQUEST_REG  = new ushort[] { 0xA01, 0xA01, 0xA01, 0xA01, 0xA01, 0xA01, 0xA01, 0xA01 };
            }
            else
            {
                VENDOR_ID_HIGH_REGISTER = 0x804F;
                VENDOR_ID_LOW_REGISTER  = 0x004F;

                if (chip == Chip.NCT6797D || chip == Chip.NCT6798D)
                {
                    FAN_PWM_OUT_REG = new ushort[] { 0x001, 0x003, 0x011, 0x013, 0x015, 0xA09, 0xB09 }
                }
                ;
                else
                {
                    FAN_PWM_OUT_REG = new ushort[] { 0x001, 0x003, 0x011, 0x013, 0x015, 0x017, 0x029 }
                };

                FAN_PWM_COMMAND_REG  = new ushort[] { 0x109, 0x209, 0x309, 0x809, 0x909, 0xA09, 0xB09 };
                FAN_CONTROL_MODE_REG = new ushort[] { 0x102, 0x202, 0x302, 0x802, 0x902, 0xA02, 0xB02 };

                _vBatMonitorControlRegister = 0x005D;
            }

            _isNuvotonVendor = IsNuvotonVendor();

            if (!_isNuvotonVendor)
            {
                return;
            }


            switch (chip)
            {
            case Chip.NCT6771F:
            case Chip.NCT6776F:
            {
                if (chip == Chip.NCT6771F)
                {
                    Fans = new float?[4];

                    // min value RPM value with 16-bit fan counter
                    _minFanRpm = (int)(1.35e6 / 0xFFFF);

                    _temperaturesSource = new Enum[] { SourceNct6771F.PECI_0, SourceNct6771F.CPUTIN, SourceNct6771F.AUXTIN, SourceNct6771F.SYSTIN };
                }
                else
                {
                    Fans = new float?[5];

                    // min value RPM value with 13-bit fan counter
                    _minFanRpm = (int)(1.35e6 / 0x1FFF);

                    _temperaturesSource = new Enum[] { SourceNct6776F.PECI_0, SourceNct6776F.CPUTIN, SourceNct6776F.AUXTIN, SourceNct6776F.SYSTIN };
                }

                _fanRpmRegister = new ushort[5];
                for (int i = 0; i < _fanRpmRegister.Length; i++)
                {
                    _fanRpmRegister[i] = (ushort)(0x656 + (i << 1));
                }

                Controls = new float?[3];

                Voltages             = new float?[9];
                _voltageRegisters    = new ushort[] { 0x020, 0x021, 0x022, 0x023, 0x024, 0x025, 0x026, 0x550, 0x551 };
                _voltageVBatRegister = 0x551;

                Temperatures                  = new float?[4];
                _temperatureRegister          = new ushort[] { 0x027, 0x073, 0x075, 0x077, 0x150, 0x250, 0x62B, 0x62C, 0x62D };
                _temperatureHalfRegister      = new ushort[] { 0, 0x074, 0x076, 0x078, 0x151, 0x251, 0x62E, 0x62E, 0x62E };
                _temperatureHalfBit           = new[] { -1, 7, 7, 7, 7, 7, 0, 1, 2 };
                _temperatureSourceRegister    = new ushort[] { 0x621, 0x100, 0x200, 0x300, 0x622, 0x623, 0x624, 0x625, 0x626 };
                _alternateTemperatureRegister = new ushort?[] { null, null, null, null };

                break;
            }

            case Chip.NCT6779D:
            case Chip.NCT6791D:
            case Chip.NCT6792D:
            case Chip.NCT6792DA:
            case Chip.NCT6793D:
            case Chip.NCT6795D:
            case Chip.NCT6796D:
            case Chip.NCT6796DR:
            case Chip.NCT6797D:
            case Chip.NCT6798D:
            {
                switch (chip)
                {
                case Chip.NCT6779D:
                {
                    Fans     = new float?[5];
                    Controls = new float?[5];
                    break;
                }

                case Chip.NCT6797D:
                case Chip.NCT6798D:
                {
                    Fans     = new float?[7];
                    Controls = new float?[7];
                    break;
                }

                default:
                {
                    Fans     = new float?[6];
                    Controls = new float?[6];
                    break;
                }
                }

                _fanCountRegister = new ushort[] { 0x4B0, 0x4B2, 0x4B4, 0x4B6, 0x4B8, 0x4BA, 0x4CC };

                // max value for 13-bit fan counter
                _maxFanCount = 0x1FFF;

                // min value that could be transferred to 16-bit RPM registers
                _minFanCount = 0x15;

                Voltages             = new float?[15];
                _voltageRegisters    = new ushort[] { 0x480, 0x481, 0x482, 0x483, 0x484, 0x485, 0x486, 0x487, 0x488, 0x489, 0x48A, 0x48B, 0x48C, 0x48D, 0x48E };
                _voltageVBatRegister = 0x488;
                switch (chip)
                {
                case Chip.NCT6796D:
                case Chip.NCT6796DR:
                case Chip.NCT6797D:
                case Chip.NCT6798D:
                {
                    Temperatures        = new float?[24];
                    _temperaturesSource = new Enum[]
                    {
                        SourceNct67Xxd.PECI_0,
                        SourceNct67Xxd.CPUTIN,
                        SourceNct67Xxd.SYSTIN,
                        SourceNct67Xxd.AUXTIN0,
                        SourceNct67Xxd.AUXTIN1,
                        SourceNct67Xxd.AUXTIN2,
                        SourceNct67Xxd.AUXTIN3,
                        SourceNct67Xxd.AUXTIN4,
                        SourceNct67Xxd.SMBUSMASTER0,
                        SourceNct67Xxd.SMBUSMASTER1,
                        SourceNct67Xxd.PECI_1,
                        SourceNct67Xxd.PCH_CHIP_CPU_MAX_TEMP,
                        SourceNct67Xxd.PCH_CHIP_TEMP,
                        SourceNct67Xxd.PCH_CPU_TEMP,
                        SourceNct67Xxd.PCH_MCH_TEMP,
                        SourceNct67Xxd.AGENT0_DIMM0,
                        SourceNct67Xxd.AGENT0_DIMM1,
                        SourceNct67Xxd.AGENT1_DIMM0,
                        SourceNct67Xxd.AGENT1_DIMM1,
                        SourceNct67Xxd.BYTE_TEMP0,
                        SourceNct67Xxd.BYTE_TEMP1,
                        SourceNct67Xxd.PECI_0_CAL,
                        SourceNct67Xxd.PECI_1_CAL,
                        SourceNct67Xxd.VIRTUAL_TEMP
                    };

                    _temperatureRegister = new ushort[]
                    {
                        0x073, 0x075, 0x077, 0x079, 0x07B, 0x07D, 0x4A0, 0x027, 0x150, 0x670, 0x672, 0x674, 0x676, 0x678, 0x67A
                    };
                    _temperatureHalfRegister = new ushort[]
                    {
                        0x074, 0x076, 0x078, 0x07A, 0x07C, 0x07E, 0x49E, 0, 0x151, 0, 0, 0, 0, 0, 0
                    };
                    _temperatureHalfBit = new[]
                    {
                        7, 7, 7, 7, 7, 7, 6, -1, 7, -1, -1, -1, -1, -1, -1
                    };
                    _temperatureSourceRegister = new ushort[]
                    {
                        0x100, 0x200, 0x300, 0x800, 0x900, 0xA00, 0xB00, 0x621, 0x622, 0xC26, 0xC27, 0xC28, 0xC29, 0xC2A, 0xC2B
                    };
                    _alternateTemperatureRegister = new ushort?[]
                    {
                        null, 0x491, 0x490, 0x492, 0x493, 0x494, 0x495, null, null, null, null, 0x400, 0x401, 0x402, 0x404, null, null, null, null, null, null, null, null, null
                    };
                    break;
                }

                default:
                {
                    Temperatures        = new float?[7];
                    _temperaturesSource = new Enum[]
                    {
                        SourceNct67Xxd.PECI_0,
                        SourceNct67Xxd.CPUTIN,
                        SourceNct67Xxd.SYSTIN,
                        SourceNct67Xxd.AUXTIN0,
                        SourceNct67Xxd.AUXTIN1,
                        SourceNct67Xxd.AUXTIN2,
                        SourceNct67Xxd.AUXTIN3
                    };

                    _temperatureRegister          = new ushort[] { 0x027, 0x073, 0x075, 0x077, 0x079, 0x07B, 0x150 };
                    _temperatureHalfRegister      = new ushort[] { 0, 0x074, 0x076, 0x078, 0x07A, 0x07C, 0x151 };
                    _temperatureHalfBit           = new[] { -1, 7, 7, 7, 7, 7, 7 };
                    _temperatureSourceRegister    = new ushort[] { 0x621, 0x100, 0x200, 0x300, 0x800, 0x900, 0x622 };
                    _alternateTemperatureRegister = new ushort?[] { null, 0x491, 0x490, 0x492, 0x493, 0x494, 0x495 };
                    break;
                }
                }
                break;
            }

            case Chip.NCT610XD:
            {
                Fans     = new float?[3];
                Controls = new float?[3];

                _fanRpmRegister = new ushort[3];
                for (int i = 0; i < _fanRpmRegister.Length; i++)
                {
                    _fanRpmRegister[i] = (ushort)(0x030 + (i << 1));
                }

                // min value RPM value with 13-bit fan counter
                _minFanRpm = (int)(1.35e6 / 0x1FFF);

                Voltages             = new float?[9];
                _voltageRegisters    = new ushort[] { 0x300, 0x301, 0x302, 0x303, 0x304, 0x305, 0x307, 0x308, 0x309 };
                _voltageVBatRegister = 0x308;
                Temperatures         = new float?[4];
                _temperaturesSource  = new Enum[] { SourceNct610X.PECI_0, SourceNct610X.SYSTIN, SourceNct610X.CPUTIN, SourceNct610X.AUXTIN };

                _temperatureRegister          = new ushort[] { 0x027, 0x018, 0x019, 0x01A };
                _temperatureHalfRegister      = new ushort[] { 0, 0x01B, 0x11B, 0x21B };
                _temperatureHalfBit           = new[] { -1, 7, 7, 7 };
                _temperatureSourceRegister    = new ushort[] { 0x621, 0x100, 0x200, 0x300 };
                _alternateTemperatureRegister = new ushort?[] { null, 0x018, 0x019, 0x01A };

                break;
            }

            case Chip.NCT6687D:
            {
                Fans         = new float?[8];
                Controls     = new float?[8];
                Voltages     = new float?[14];
                Temperatures = new float?[7];

                // CPU
                // System
                // MOS
                // PCH
                // CPU Socket
                // PCIE_1
                // M2_1
                _temperatureRegister = new ushort[] { 0x100, 0x102, 0x104, 0x106, 0x108, 0x10A, 0x10C };

                // VIN0 +12V
                // VIN1 +5V
                // VIN2 VCore
                // VIN3 SIO
                // VIN4 DRAM
                // VIN5 CPU IO
                // VIN6 CPU SA
                // VIN7 SIO
                // 3VCC I/O +3.3
                // SIO VTT
                // SIO VREF
                // SIO VSB
                // SIO AVSB
                // SIO VBAT
                _voltageRegisters = new ushort[] { 0x120, 0x122, 0x124, 0x126, 0x128, 0x12A, 0x12C, 0x12E, 0x130, 0x13A, 0x13E, 0x136, 0x138, 0x13C };

                // CPU Fan
                // PUMP Fan
                // SYS Fan 1
                // SYS Fan 2
                // SYS Fan 3
                // SYS Fan 4
                // SYS Fan 5
                // SYS Fan 6
                _fanRpmRegister = new ushort[] { 0x140, 0x142, 0x144, 0x146, 0x148, 0x14A, 0x14C, 0x14E };

                _restoreDefaultFanControlRequired = new bool[_fanRpmRegister.Length];
                _initialFanControlMode            = new byte[_fanRpmRegister.Length];
                _initialFanPwmCommand             = new byte[_fanRpmRegister.Length];

                // initialize
                ushort initRegister = 0x180;
                byte   data         = ReadByte(initRegister);
                if ((data & 0x80) == 0)
                {
                    WriteByte(initRegister, (byte)(data | 0x80));
                }

                // enable SIO voltage
                WriteByte(0x1BB, 0x61);
                WriteByte(0x1BC, 0x62);
                WriteByte(0x1BD, 0x63);
                WriteByte(0x1BE, 0x64);
                WriteByte(0x1BF, 0x65);

                _alternateTemperatureRegister = new ushort?[] { null };

                break;
            }
            }
        }
예제 #36
0
        private bool DetectWinbondFintek(LPCPort port)
        {
            port.WinbondNuvotonFintekEnter();

            byte logicalDeviceNumber = 0;
            byte id       = port.ReadByte(CHIP_ID_REGISTER);
            byte revision = port.ReadByte(CHIP_REVISION_REGISTER);
            Chip chip     = Chip.Unknown;

            switch (id)
            {
            case 0x05:
                switch (revision)
                {
                case 0x07:
                    chip = Chip.F71858;
                    logicalDeviceNumber = F71858_HARDWARE_MONITOR_LDN;
                    break;

                case 0x41:
                    chip = Chip.F71882;
                    logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0x06:
                switch (revision)
                {
                case 0x01:
                    chip = Chip.F71862;
                    logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0x07:
                switch (revision)
                {
                case 0x23:
                    chip = Chip.F71889F;
                    logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0x08:
                switch (revision)
                {
                case 0x14:
                    chip = Chip.F71869;
                    logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0x09:
                switch (revision)
                {
                case 0x01:
                    chip = Chip.F71808E;
                    logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
                    break;

                case 0x09:
                    chip = Chip.F71889ED;
                    logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0x10:
                switch (revision)
                {
                case 0x05:
                    chip = Chip.F71889AD;
                    logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
                    break;

                case 0x07:
                    chip = Chip.F71869A;
                    logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0x52:
                switch (revision)
                {
                case 0x17:
                case 0x3A:
                case 0x41:
                    chip = Chip.W83627HF;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0x82:
                switch (revision & 0xF0)
                {
                case 0x80:
                    chip = Chip.W83627THF;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0x85:
                switch (revision)
                {
                case 0x41:
                    chip = Chip.W83687THF;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0x88:
                switch (revision & 0xF0)
                {
                case 0x50:
                case 0x60:
                    chip = Chip.W83627EHF;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0xA0:
                switch (revision & 0xF0)
                {
                case 0x20:
                    chip = Chip.W83627DHG;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0xA5:
                switch (revision & 0xF0)
                {
                case 0x10:
                    chip = Chip.W83667HG;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0xB0:
                switch (revision & 0xF0)
                {
                case 0x70:
                    chip = Chip.W83627DHGP;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0xB3:
                switch (revision & 0xF0)
                {
                case 0x50:
                    chip = Chip.W83667HGB;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0xB4:
                switch (revision & 0xF0)
                {
                case 0x70:
                    chip = Chip.NCT6771F;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0xC3:
                switch (revision & 0xF0)
                {
                case 0x30:
                    chip = Chip.NCT6776F;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0xC4:
                switch (revision & 0xF0)
                {
                case 0x50:
                    chip = Chip.NCT610X;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0xC5:
                switch (revision & 0xF0)
                {
                case 0x60:
                    chip = Chip.NCT6779D;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0xC8:
                switch (revision)
                {
                case 0x03:
                    chip = Chip.NCT6791D;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0xD4:
                switch (revision)
                {
                case 0x23:
                    chip = Chip.NCT6796D;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0xD1:
                switch (revision)
                {
                case 0x21:
                    chip = Chip.NCT6793D;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;

            case 0xD3:
                switch (revision)
                {
                case 0x52:
                    chip = Chip.NCT6795D;
                    logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
                    break;
                }
                break;
            }
            if (chip == Chip.Unknown)
            {
                if (id != 0 && id != 0xff)
                {
                    port.WinbondNuvotonFintekExit();

                    ReportUnknownChip(port, "Winbond / Nuvoton / Fintek",
                                      ((id << 8) | revision));
                }
            }
            else
            {
                port.Select(logicalDeviceNumber);
                ushort address = port.ReadWord(BASE_ADDRESS_REGISTER);
                Thread.Sleep(1);
                ushort verify = port.ReadWord(BASE_ADDRESS_REGISTER);

                ushort vendorID = port.ReadWord(FINTEK_VENDOR_ID_REGISTER);

                // disable the hardware monitor i/o space lock on NCT679*D chips
                if (address == verify && (chip == Chip.NCT6791D || chip == Chip.NCT6796D || chip == Chip.NCT6793D || chip == Chip.NCT6795D))
                {
                    port.NuvotonDisableIOSpaceLock();
                }

                port.WinbondNuvotonFintekExit();

                if (address != verify)
                {
                    report.Append("Chip ID: 0x");
                    report.AppendLine(chip.ToString("X"));
                    report.Append("Chip revision: 0x");
                    report.AppendLine(revision.ToString("X",
                                                        CultureInfo.InvariantCulture));
                    report.AppendLine("Error: Address verification failed");
                    report.AppendLine();
                    return(false);
                }

                // some Fintek chips have address register offset 0x05 added already
                if ((address & 0x07) == 0x05)
                {
                    address &= 0xFFF8;
                }

                if (address < 0x100 || (address & 0xF007) != 0)
                {
                    report.Append("Chip ID: 0x");
                    report.AppendLine(chip.ToString("X"));
                    report.Append("Chip revision: 0x");
                    report.AppendLine(revision.ToString("X",
                                                        CultureInfo.InvariantCulture));
                    report.Append("Error: Invalid address 0x");
                    report.AppendLine(address.ToString("X",
                                                       CultureInfo.InvariantCulture));
                    report.AppendLine();
                    return(false);
                }

                switch (chip)
                {
                case Chip.W83627DHG:
                case Chip.W83627DHGP:
                case Chip.W83627EHF:
                case Chip.W83627HF:
                case Chip.W83627THF:
                case Chip.W83667HG:
                case Chip.W83667HGB:
                case Chip.W83687THF:
                    superIOs.Add(new W836XX(chip, revision, address));
                    break;

                case Chip.NCT610X:
                case Chip.NCT6771F:
                case Chip.NCT6776F:
                case Chip.NCT6779D:
                case Chip.NCT6791D:
                case Chip.NCT6796D:
                case Chip.NCT6793D:
                case Chip.NCT6795D:
                    superIOs.Add(new NCT677X(chip, revision, address, port));
                    break;

                case Chip.F71858:
                case Chip.F71862:
                case Chip.F71869:
                case Chip.F71869A:
                case Chip.F71882:
                case Chip.F71889AD:
                case Chip.F71889ED:
                case Chip.F71889F:
                case Chip.F71808E:
                    if (vendorID != FINTEK_VENDOR_ID)
                    {
                        report.Append("Chip ID: 0x");
                        report.AppendLine(chip.ToString("X"));
                        report.Append("Chip revision: 0x");
                        report.AppendLine(revision.ToString("X",
                                                            CultureInfo.InvariantCulture));
                        report.Append("Error: Invalid vendor ID 0x");
                        report.AppendLine(vendorID.ToString("X",
                                                            CultureInfo.InvariantCulture));
                        report.AppendLine();
                        return(false);
                    }
                    superIOs.Add(new F718XX(chip, address));
                    break;

                default: break;
                }

                return(true);
            }

            return(false);
        }
예제 #37
0
 public void CrossMix(Chip secondary)
 {
     StartCoroutine(CrossMixRoutine(secondary));
 }
예제 #38
0
 public static void SetBorder(this Chip view, Context context, IBorderElement borderElement)
 {
     view.ChipStrokeColor = ColorStateList.ValueOf(borderElement.BorderColor.ToAndroid());
     view.ChipStrokeWidth = (int)context.ToPixels(borderElement.BorderWidth);
 }
예제 #39
0
 public void LineMix(Chip secondary)
 {
     sides = Utils.straightSides;
     chip.DestroyChip();
 }
예제 #40
0
 /// <summary>
 /// Add chip to board.
 /// </summary>
 /// <param name="chip">Chip to add.</param>
 public void AddChipToBoard(Chip chip)
 {
     Board.Chips[chip.PosY][chip.PosX] = chip;
 }
예제 #41
0
 public override void Execute()
 {
     Chip.ClearDisplay(true);
     PC += 2;
 }
예제 #42
0
 private Tuple <Chip, Chip> CreateTuple(Chip first, Chip second)
 {
     return(new Tuple <Chip, Chip>(first, second));
 }
예제 #43
0
        private void SetResult(Position[] result, Chip chip, Position position)
        {
            var index = this.chips.IndexOf(chip);

            result[index] = position;
        }
예제 #44
0
 private void CreateNextChip(Chip etalon)
 {
     if(nextChip!=null)
         Destroy(nextChip.gameObject);
     Debug.Log("Create next chip");
     nextChip=Instantiate(etalon,
         nextChipPos.position, nextChipPos.rotation) as Chip;
 }
예제 #45
0
    // меняет 2 элемента местами
    IEnumerator SwapByPlayerRoutine(Chip a, Chip b, bool onlyForMatching, bool byAI = false)
    {
        System.Action breaker = () => {
            if (a && !a.destroying)
            {
                a.busy = false;
            }
            if (b && !b.destroying)
            {
                b.busy = false;
            }
            swaping = false;
        };
        if (!isPlaying)
        {
            yield break;
        }
        if (!iteraction && !byAI)
        {
            yield break;
        }

        if (swaping)
        {
            yield break;
        }
        if (!a || !b)
        {
            yield break;
        }
        if (a.destroying || b.destroying)
        {
            yield break;
        }
        if (Chip.busyList.Count > 0)
        {
            yield break;
        }

        if (a.slot.block || b.slot.block)
        {
            yield break;
        }
        if (movesCount <= 0 || eat <= 0 || energy <= 0 || hygiene <= 0 || coffee <= 0)
        {
            yield break;
        }
        Mix mix  = mixes.Find(x => x.Compare(a.chipType, b.chipType));
        int move = 0;

        swaping = true;
        Vector3 posA     = a.slot.transform.position;
        Vector3 posB     = b.slot.transform.position;
        float   progress = 0;
        Vector3 normal   = a.slot.x == b.slot.x ? Vector3.right : Vector3.up;
        float   time     = 0;

        a.busy = true;
        b.busy = true;

        while (progress < ProjectParameters.main.swap_duration)
        {
            if (!a || !b)
            {
                breaker.Invoke();
                yield break;
            }
            time = EasingFunctions.easeInOutQuad(progress / ProjectParameters.main.swap_duration);
            a.transform.position = Vector3.Lerp(posA, posB, time) + normal * Mathf.Sin(3.14f * time) * 0.2f;
            if (mix == null)
            {
                b.transform.position = Vector3.Lerp(posB, posA, time) - normal * Mathf.Sin(3.14f * time) * 0.2f;
            }
            progress += Time.deltaTime;
            yield return(0);
        }
        a.transform.position = posB;
        if (mix == null)
        {
            b.transform.position = posA;
        }
        a.movementID = main.GetMovementID();
        b.movementID = main.GetMovementID();
        if (mix != null)
        {
            swaping = false;
            a.busy  = false;
            b.busy  = false;
            MixChips(a, b);
            yield return(new WaitForSeconds(0.3f));

            MovesFunction(1);
            swapEvent++;
            yield break;
        }

        Slot slotA = a.slot;
        Slot slotB = b.slot;

        if (!slotB || !slotB || !a || !b)
        {
            breaker.Invoke();
            yield break;
        }
        slotB.chip = a;
        slotA.chip = b;
        move++;

        int      count = 0;
        Solution solution;

        solution = MatchAnaliz(slotA);
        if (solution != null)
        {
            count += solution.count;
        }
        solution = MatchSquareAnaliz(slotA);
        if (solution != null)
        {
            count += solution.count;
        }
        solution = MatchAnaliz(slotB);
        if (solution != null)
        {
            count += solution.count;
        }
        solution = MatchSquareAnaliz(slotB);
        if (solution != null)
        {
            count += solution.count;
        }

        if (count == 0 && !onlyForMatching)
        {
            AudioAssistant.Shot("SwapFailed");
            while (progress > 0)
            {
                if (!a || !b)
                {
                    breaker.Invoke();
                    yield break;
                }
                time = EasingFunctions.easeInOutQuad(progress / ProjectParameters.main.swap_duration);
                a.transform.position = Vector3.Lerp(posA, posB, time) - normal * Mathf.Sin(3.14f * time) * 0.2f;
                b.transform.position = Vector3.Lerp(posB, posA, time) + normal * Mathf.Sin(3.14f * time) * 0.2f;
                progress            -= Time.deltaTime;
                yield return(0);
            }
            a.transform.position = posA;
            b.transform.position = posB;
            a.movementID         = GetMovementID();
            b.movementID         = GetMovementID();
            slotB.chip           = b;
            slotA.chip           = a;
            move--;
        }
        else
        {
            AudioAssistant.Shot("SwapSuccess");
            swapEvent++;
        }
        firstChipGeneration = false;
        if (!byAI)
        {
            Debug.Log("move = " + move);
            MovesFunction(move);
        }

        EventCounter();
        a.busy  = false;
        b.busy  = false;
        swaping = false;
    }
예제 #46
0
 private bool RotateChip(Chip chip, Vector3 eulerAngles)
 {
     if(grid.IsCanRotate(chip, eulerAngles)){
         chip.transform.Rotate(eulerAngles, Space.Self);
         return true;
     }
     return false;
 }
예제 #47
0
 public void SwapByPlayer(Chip a, Chip b, bool onlyForMatching, bool byAI = false)
 {
     StartCoroutine(SwapByPlayerRoutine(a, b, onlyForMatching, byAI));
 }
예제 #48
0
    public Solution MatchSquareAnaliz(Slot slot)
    {
        if (!slot.chip)
        {
            return(null);
        }
        if (!slot.chip.IsMatcheble())
        {
            return(null);
        }
        if (slot.chip.IsUniversalColor())
        {
            List <Solution> solutions = new List <Solution>();
            Solution        z;
            Chip            multicolorChip = slot.chip;
            for (int i = 0; i < 6; i++)
            {
                multicolorChip.id = i;
                z = MatchSquareAnaliz(slot);
                if (z != null)
                {
                    solutions.Add(z);
                }
            }
            multicolorChip.id = Chip.universalColorId;
            z = null;
            foreach (Solution sol in solutions)
            {
                if (z == null || z.potential < sol.potential)
                {
                    z = sol;
                }
            }
            return(z);
        }
        List <Chip> square = new List <Chip>();
        List <Chip> buffer = new List <Chip>();
        Side        sideR;
        int2        key;
        Slot        s;

        buffer.Clear();
        foreach (Side side in Utils.straightSides)
        {
            for (int r = 0; r <= 2; r++)
            {
                sideR = Utils.RotateSide(side, r);
                key   = slot.coord + Utils.SideOffset(sideR);
                if (Slot.all.ContainsKey(key))
                {
                    s = Slot.all[key];
                    if (s.chip && (s.chip.id == slot.chip.id || s.chip.IsUniversalColor()) && s.chip.IsMatcheble())
                    {
                        buffer.Add(s.chip);
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }
            if (buffer.Count == 3)
            {
                foreach (Chip chip_b in buffer)
                {
                    if (!square.Contains(chip_b))
                    {
                        square.Add(chip_b);
                    }
                }
            }
            buffer.Clear();
        }
        bool q = square.Count >= 3;

        if (q)
        {
            Solution solution = new Solution();
            solution.q     = q;
            solution.chips = new List <Chip>();
            solution.chips.Add(slot.chip);
            solution.chips.AddRange(square);
            solution.count = solution.chips.Count;
            solution.x     = slot.x;
            solution.y     = slot.y;
            solution.id    = slot.chip.id;
            foreach (Chip c in solution.chips)
            {
                solution.potential += c.GetPotencial();
            }
            return(solution);
        }
        return(null);
    }
예제 #49
0
		public Board ()
		{
			CurrentPlayer = Player.RedPlayer;
			Cells = new Chip [Width * Height];
		}
예제 #50
0
    IEnumerator CrossSimpleMixRoutine(Chip secondary)
    {
        chip.busy        = true;
        chip.destroyable = false;
        SessionAssistant.main.EventCounter();

        Transform effect = ContentAssistant.main.GetItem("SimpleCrossMixEffect").transform;

        effect.SetParent(Slot.folder);
        effect.position = transform.position;
        effect.GetComponent <Animation>().Play();
        AudioAssistant.Shot("CrossBombCrush");

        List <Side> _sides = new List <Side>(sides);

        if (!_sides.Contains(Side.Left))
        {
            Destroy(effect.FindChild("WaveLeft").gameObject);
        }
        if (!_sides.Contains(Side.Right))
        {
            Destroy(effect.FindChild("WaveRight").gameObject);
        }
        if (!_sides.Contains(Side.Top))
        {
            Destroy(effect.FindChild("WaveTop").gameObject);
        }
        if (!_sides.Contains(Side.Bottom))
        {
            Destroy(effect.FindChild("WaveBottom").gameObject);
        }

        chip.Minimize();

        yield return(new WaitForSeconds(0.1f));

        FieldAssistant.main.BlockCrush(chip.slot.coord, false);

        System.Action <int2> Wave = (int2 coord) => {
            Slot s = Slot.GetSlot(coord);
            if (s)
            {
                AnimationAssistant.main.Explode(s.transform.position, 3, 20);
            }
        };

        for (int path = 0; path < LevelProfile.maxSize; path++)
        {
            foreach (Side side in _sides)
            {
                Freez(chip.slot.coord + Utils.SideOffset(side) * path);
                Freez(chip.slot.coord + Utils.SideOffset(side) * path + Utils.SideOffset(Utils.RotateSide(side, 2)));
                Freez(chip.slot.coord + Utils.SideOffset(side) * path + Utils.SideOffset(Utils.RotateSide(side, -2)));
            }
        }

        foreach (Side side in Utils.allSides)
        {
            Crush(chip.slot.coord + Utils.SideOffset(side));
        }
        Wave(chip.slot.coord);

        yield return(new WaitForSeconds(0.05f));

        for (int path = 2; path < LevelProfile.maxSize; path++)
        {
            foreach (Side side in _sides)
            {
                Crush(chip.slot.coord + Utils.SideOffset(side) * path);
                Crush(chip.slot.coord + Utils.SideOffset(side) * path + Utils.SideOffset(Utils.RotateSide(side, 2)));
                Crush(chip.slot.coord + Utils.SideOffset(side) * path + Utils.SideOffset(Utils.RotateSide(side, -2)));
                Wave(chip.slot.coord + Utils.SideOffset(side) * path);
            }
            yield return(new WaitForSeconds(0.05f));
        }

        chip.busy = false;
        chip.HideChip(false);
    }
예제 #51
0
    /// <summary>
    /// Moves the nextChip to start position and creates new nextChip.
    /// </summary>
    private void UseNextChip()
    {
        activeChip=nextChip;
        activeChip.transform.position=startChipPos.position;
        activeChip.transform.rotation=startChipPos.rotation;
        activeChip.transform.SetParent(grid.transform);

        nextChip=null;
        CreateNextChip(chipList[Random.Range(0, chipList.Count)]);
    }
예제 #52
0
 public static void SetCornerRadius(this Chip view, Context context, ICornerElement cornerElement)
 {
     view.ChipCornerRadius = context.ToPixels(cornerElement.CornerRadius.TopLeft);
 }
예제 #53
0
 public void PushChip(Chip chip)
 {
     throw new NotImplementedException();
 }
예제 #54
0
 void SetDepth(Chip chip, float depth)
 {
     chip.transform.position = new Vector3(chip.transform.position.x, chip.transform.position.y, depth);
 }
예제 #55
0
 private bool MoveChip(Chip chip, Vector3 direction)
 {
     if(grid.IsCanMove(chip, direction)){
         chip.transform.localPosition+=direction;
         return true;
     }
     return false;
 }
예제 #56
0
 public void LoadChip(Chip chip)
 {
     chip.transform.parent = chipHolder;
     allChips.Add(chip);
 }
예제 #57
0
 private void UpdateChipPos()
 {
     float timeStep=Time.time-lastMoveTimePoint;
     float oneMoveTime=1f/moveSpeed;
     while(timeStep > oneMoveTime){
         timeStep-=oneMoveTime;
         //calc move
         if(activeChip==null){
             UseNextChip();
         }else if(!MoveChip(activeChip, Vector3.down)){
             grid.Add(activeChip);
             if(grid.IsGameOver())
                 PauseGame();
             activeChip=null;
         }
     }
     lastMoveTimePoint=Time.time-timeStep;
 }
예제 #58
0
    public Solution MatchAnaliz(Slot slot)
    {
        if (!slot.chip)
        {
            return(null);
        }
        if (!slot.chip.IsMatcheble())
        {
            return(null);
        }
        if (slot.chip.IsUniversalColor())
        {
            List <Solution> solutions = new List <Solution>();
            Solution        z;
            Chip            multicolorChip = slot.chip;
            for (int i = 0; i < 6; i++)
            {
                multicolorChip.id = i;
                z = MatchAnaliz(slot);
                if (z != null)
                {
                    solutions.Add(z);
                }
                z = MatchSquareAnaliz(slot);
                if (z != null)
                {
                    solutions.Add(z);
                }
            }
            multicolorChip.id = Chip.universalColorId;
            z = null;
            foreach (Solution sol in solutions)
            {
                if (z == null || z.potential < sol.potential)
                {
                    z = sol;
                }
            }
            return(z);
        }
        Slot s;
        Dictionary <Side, List <Chip> > sides = new Dictionary <Side, List <Chip> >();
        int  count;
        int2 key;

        foreach (Side side in Utils.straightSides)
        {
            count = 1;
            sides.Add(side, new List <Chip>());
            while (true)
            {
                key = slot.coord + Utils.SideOffset(side) * count;
                if (!Slot.all.ContainsKey(key))
                {
                    break;
                }
                s = Slot.all[key];
                if (!s.chip)
                {
                    break;
                }
                if (s.chip.id != slot.chip.id && !s.chip.IsUniversalColor())
                {
                    break;
                }
                if (!s.chip.IsMatcheble())
                {
                    break;
                }
                sides[side].Add(s.chip);
                count++;
            }
        }
        bool h = sides[Side.Right].Count + sides[Side.Left].Count >= 2;
        bool v = sides[Side.Top].Count + sides[Side.Bottom].Count >= 2;

        if (h || v)
        {
            Solution solution = new Solution();
            solution.h     = h;
            solution.v     = v;
            solution.chips = new List <Chip>();
            solution.chips.Add(slot.chip);
            if (h)
            {
                solution.chips.AddRange(sides[Side.Right]);
                solution.chips.AddRange(sides[Side.Left]);
            }
            if (v)
            {
                solution.chips.AddRange(sides[Side.Top]);
                solution.chips.AddRange(sides[Side.Bottom]);
            }
            solution.count = solution.chips.Count;
            solution.x     = slot.x;
            solution.y     = slot.y;
            solution.id    = slot.chip.id;
            foreach (Chip c in solution.chips)
            {
                solution.potential += c.GetPotencial();
            }
            return(solution);
        }
        return(null);
    }
예제 #59
0
    public void CheckCollision()
    {
        if (!ismovable)
        {
            return;
        }
        if (!getPicked())
        {
            return;
        }
        Place place1 = null;
        Place place2 = null;
        int   i = 0, len = BoardBuilder.Places.Count;

        for (i = 0; i < len; i++)
        {
            string key = "Places" + i.ToString();
            if (BoardBuilder.Places.ContainsKey(key))
            {
                if (chip.getCColllider().IsTouching(BoardBuilder.Places[key].getCollider()))
                {
                    if (place1 == null)
                    {
                        place1 = BoardBuilder.Places[key];
                    }
                    else if (place2 == null && place1.name != key)
                    {
                        place2 = BoardBuilder.Places[key];
                        break;
                    }
                }
            }
            else if (chip.getCColllider().IsTouching(BoardBuilder.homeB.getCollider()))
            {
                if (place1 == null)
                {
                    place1 = BoardBuilder.homeB;
                }
                else if (place2 == null && place1.name != BoardBuilder.homeB.name)
                {
                    place2 = BoardBuilder.homeB;
                    break;
                }
            }
            else if (chip.getCColllider().IsTouching(BoardBuilder.homeW.getCollider()))
            {
                if (place1 == null)
                {
                    place1 = BoardBuilder.homeW;
                }
                else if (place2 == null && place1.name != BoardBuilder.homeW.name)
                {
                    place2 = BoardBuilder.homeW;
                    break;
                }
            }
        }
        if (place1 == null || place2 == null)
        {
            string key1 = "Chip_White_";
            string key2 = "Chip_Black_";
            int    len1 = BoardBuilder.WhiteChip.Count;
            for (i = 0; i < len1; i++)
            {
                if (chip == null)
                {
                    break;
                }

                if (BoardBuilder.WhiteChip.ContainsKey(key1 + i.ToString()))
                {
                    Chip ch = BoardBuilder.WhiteChip[key1 + i.ToString()];
                    if (chip.getCColllider().IsTouching(ch.getCColllider()))
                    {
                        if (place1 == null)
                        {
                            place1 = BoardBuilder.WhiteChip[key1 + i.ToString()].place;
                        }
                        else if (place2 == null && place1.name != ch.place.name)
                        {
                            place2 = ch.place;
                            break;
                        }
                    }
                }
                if (BoardBuilder.BlackChip.ContainsKey(key2 + i.ToString()))
                {
                    Chip ch = BoardBuilder.BlackChip[key2 + i.ToString()];
                    if (chip.getCColllider().IsTouching(ch.getCColllider()))
                    {
                        if (place1 == null)
                        {
                            place1 = ch.place;
                        }
                        else if (place2 == null && place1.name != ch.place.name)
                        {
                            place2 = ch.place;
                            break;
                        }
                    }
                }
            }
        }
        float vec1 = 0;
        float vec2 = 0;

        if (place1 != null)
        {
            vec1 = Vector3.Distance(chip.getGameObject().transform.position, place1.getGameObject().transform.position);
        }
        if (place2 != null)
        {
            vec2 = Vector3.Distance(chip.getGameObject().transform.position, place2.getGameObject().transform.position);
        }

        if (place1 == null && place2 == null)
        {
            SetFinalPlace(null);
            return;
        }
        else if (place1 != null && place2 == null)
        {
            setColorOfColidPlace(place1);
            SetFinalPlace(place1);
            return;
        }
        else
        {
            if (vec1 < vec2)
            {
                setColorOfColidPlace(place1);
                SetFinalPlace(place1);
            }
            else
            {
                setColorOfColidPlace(place2);
                SetFinalPlace(place2);
            }
        }
    }
예제 #60
0
        private void OnDataSeqFrq(long SeqCounter)
        {
            //throw new NotImplementedException();
            if (mv == null)
            {
                return;
            }
            if (mv.desVGM == null)
            {
                return;
            }
            if (mv.desVGM.dat == null)
            {
                return;
            }

            if ((Audio.sm.Mode & SendMode.MML) != SendMode.MML)
            {
                if (rtMML != null)
                {
                    rtMML.OneFrameSeq();
                }
            }

            if (mv.desVGM.dat.Count == 0)
            {
                return;
            }
            eChip = Audio.GetChip(EnmChip.YM2612);
            if (eChip == null)
            {
                return;
            }


            Enq             enq = SoundManager.GetDriverDataEnqueue();
            List <outDatum> dat = mv.desVGM.dat;

            lock (lockObject)
            {
                int badr = 0;
                while (badr < dat.Count)
                {
                    outDatum od = dat[badr];
                    if (od == null)
                    {
                        badr++;
                        continue;
                    }

                    byte val = od.val;
                    switch (val)
                    {
                    case 0x52:
                        byte adr = dat[badr + 1].val;
                        byte prm = dat[badr + 2].val;
                        enq(dat[badr], SeqCounter, eChip, EnmDataType.Normal, adr, prm, null);
                        //enq(dat[badr], 0, eChip, EnmDataType.Normal, adr, prm, null);
                        if (adr == 0x28 && dat[badr].type == enmMMLType.Note && dat[badr].args != null && dat[badr].args.Count > 1)
                        {
                            log.Write(string.Format("noteLog: note:{0} counter:{1}", (int)dat[badr].args[1], SeqCounter));
                            if (recMode != 0)
                            {
                                if ((int)dat[badr].args[1] >= 0)
                                {
                                    NoteON(SeqCounter, (int)dat[badr].args[1]);
                                }
                                else
                                {
                                    NoteOFF(SeqCounter, (int)dat[badr].args[1]);
                                }
                            }
                        }
                        badr += 2;
                        break;
                    }
                    badr++;
                }
                dat.Clear();
            }
        }