コード例 #1
1
ファイル: IRDecoder.cs プロジェクト: amoldeshpande/ModuloLib
 public IRDecoder(uint16_t[] rawData, uint16_t validLen)
 {
     _rawData = rawData;
     _rawLen = validLen;
 }
コード例 #2
0
ファイル: StackOps.cs プロジェクト: griderd/gsvm
        void PushRegister(Register_t reg)
        {
            int size = registers.SizeOf(reg);

            switch (size)
            {
            case 8:
                uint64_t value64 = registers.Read <uint64_t>(reg);
                System.Diagnostics.Debug.Assert(value64 != null);
                stack.Push(value64);
                break;

            case 4:
                uint32_t value32 = registers.Read <uint32_t>(reg);
                System.Diagnostics.Debug.Assert(value32 != null);
                stack.Push(value32);
                break;

            case 2:
                uint16_t value16 = registers.Read <uint16_t>(reg);
                System.Diagnostics.Debug.Assert(value16 != null);
                stack.Push(value16);
                break;

            case 1:
                uint8_t value8 = registers.Read <uint8_t>(reg);
                System.Diagnostics.Debug.Assert(value8 != null);
                stack.Push(value8);
                break;
            }
        }
コード例 #3
0
ファイル: MemOps.cs プロジェクト: griderd/gsvm
 /// <summary>
 /// Writes the value in reg to address in literal
 /// </summary>
 /// <param name="reg"></param>
 /// <param name="literal"></param>
 void Write(uint16_t address, Register_t value)
 {
     MoveL(Register.MAR, address);
     MoveL(Register.MLR, registers.SizeOf(value));
     MoveR(Register.MDR, value);
     WriteMemory();
 }
コード例 #4
0
ファイル: Branching.cs プロジェクト: griderd/gsvm
 void JumpGreaterEqual(uint16_t a)
 {
     if (HasFlag(CPUFlags.GreaterThan) | HasFlag(CPUFlags.Equal))
     {
         JumpL(a);
     }
 }
コード例 #5
0
ファイル: Branching.cs プロジェクト: griderd/gsvm
 void JumpGreater(uint16_t a)
 {
     if (HasFlag(CPUFlags.GreaterThan))
     {
         JumpL(a);
     }
 }
コード例 #6
0
ファイル: StackOps.cs プロジェクト: griderd/gsvm
        void PushRegister(Register_t reg)
        {
            int size = registers.SizeOf(reg);

            switch (size)
            {
            case 8:
                uint64_t value64 = registers.Read <uint64_t>(reg);
                stack.Push(value64);
                break;

            case 4:
                uint32_t value32 = registers.Read <uint32_t>(reg);
                stack.Push(value32);
                break;

            case 2:
                uint16_t value16 = registers.Read <uint16_t>(reg);
                stack.Push(value16);
                break;

            case 1:
                uint8_t value8 = registers.Read <uint8_t>(reg);
                stack.Push(value8);
                break;
            }
        }
コード例 #7
0
ファイル: Branching.cs プロジェクト: griderd/gsvm
 void JumpNotEqual(uint16_t a)
 {
     if (!HasFlag(CPUFlags.Equal))
     {
         JumpL(a);
     }
 }
コード例 #8
0
ファイル: Branching.cs プロジェクト: griderd/gsvm
 void JumpLess(uint16_t a)
 {
     if (HasFlag(CPUFlags.LessThan))
     {
         JumpL(a);
     }
 }
コード例 #9
0
ファイル: SyntaxTree.cs プロジェクト: griderd/gsvm
        bool ExpectSymbol(string operand, out uint16_t result)
        {
            result = Int.UInt16;
            if (symbols.ContainsKey(operand))
            {
                IDataType symbol = symbols[operand];
                if (symbol.Address > ushort.MaxValue)
                {
                    RaiseError("32-bit address support not available.");
                }
                else
                {
                    result = new uint16_t((ushort)symbol.Address);
                }

                return(true);
            }
            else
            {
                if ((!IsRegister(operand)) & (operand != ""))
                {
                    //unresolvedSymbols.Add(operand, opcodes.Count);
                    unresolvedSymbols.Add(new UnresolvedSymbol {
                        symbol = operand, location = opcodes.Count
                    });
                    return(true);
                }

                return(false);
            }
        }
コード例 #10
0
ファイル: config.cs プロジェクト: indigoman/minimosd-extra
        public void setEepromScrFlags(uint16_t val)
        {
            const int pan_pos = 0;                                                             // position of flags

            eeprom[osd.screen_number * OSD.OffsetBITpanel + pan_pos]     = (byte)(val & 0xFF); // x
            eeprom[osd.screen_number * OSD.OffsetBITpanel + pan_pos + 1] = (byte)(val >> 8);   // y
        }
コード例 #11
0
ファイル: MemOps.cs プロジェクト: griderd/gsvm
 /// <summary>
 /// Reads the value stored in memory at address into reg.
 /// </summary>
 /// <param name="reg"></param>
 /// <param name="literal"></param>
 void Read(Register_t reg, uint16_t literal)
 {
     MoveL(Register.MLR, registers.SizeOf(reg));
     MoveL(Register.MAR, literal);
     ReadMemory();
     MoveR(reg, Register.MDR);
 }
コード例 #12
0
ファイル: ArrayOperations.cs プロジェクト: griderd/gsvm
 /// <summary>
 /// Set Array. Sets up the array registers for reading or writing to
 /// </summary>
 /// <param name="baseAddress">Address of the array</param>
 /// <param name="elementSize">Size of the elements in bytes</param>
 void sall(uint16_t baseAddress, uint16_t elementSize)
 {
     registers.Write <uint16_t>(Register.ABP, baseAddress);
     registers.Write <uint16_t>(Register.AEI, 0);
     registers.Write <uint16_t>(Register.AEL, elementSize);
     registers.Write <uint16_t>(Register.AEP, baseAddress);
 }
コード例 #13
0
ファイル: Branching.cs プロジェクト: griderd/gsvm
 void JumpLessEqual(uint16_t a)
 {
     if (HasFlag(CPUFlags.LessThan) | HasFlag(CPUFlags.Equal))
     {
         JumpL(a);
     }
 }
コード例 #14
0
ファイル: ArrayOperations.cs プロジェクト: griderd/gsvm
 void sail(uint16_t index)
 {
     registers.Write <uint16_t>(Register.AEI, index);
     registers.Write <uint16_t>(Register.AEP, index);
     Multiply(Register.AEP, Register.AEL);
     Add(Register.AEP, Register.ABP);
 }
コード例 #15
0
ファイル: MemOps.cs プロジェクト: griderd/gsvm
 void Write(Register_t address, uint16_t value)
 {
     MoveR(Register.MAR, address);
     MoveL(Register.MLR, 2);
     MoveL(Register.MDR, value);
     WriteMemory();
 }
コード例 #16
0
    public RGBColor getNextPixel()
    {
        RGBColor pixel = _pixels[_offset];

        _offset = (ushort)((_offset + 1) % _numPixels);

        return(pixel);
    }
コード例 #17
0
ファイル: SyntaxTree.cs プロジェクト: griderd/gsvm
        bool ExpectLiteral(string operand, out uint16_t result)
        {
            ushort literal;
            bool   isLiteral = ushort.TryParse(operand, out literal);

            result = literal;
            return(isLiteral);
        }
コード例 #18
0
        private void chkAlt_CheckedChanged(object sender, EventArgs e)
        {
            string item = osd.currentlyselected;

            if (fReenter)
            {
                return;
            }

            for (int a = 0; a < panelItems.Length; a++)
            {
                if (panelItems[a] != null && panelItems[a].name == item)
                {
                    if (panelItems[a].Altf >= 0)
                    {
                        panelItems[a].Altf = chkAlt.Checked ? 1 : 0;
                    }
                    if (panelItems[a].Alt2 >= 0)
                    {
                        panelItems[a].Alt2 = chkAlt2.Checked ? 1 : 0;
                    }
                    if (panelItems[a].Alt3 >= 0)
                    {
                        panelItems[a].Alt3 = chkAlt3.Checked ? 1 : 0;
                    }
                    if (panelItems[a].Alt4 >= 0)
                    {
                        panelItems[a].Alt4 = chkAlt4.Checked ? 1 : 0;
                    }
                    if (panelItems[a].Alt5_mask != 0)
                    {
                        panelItems[a].Alt5 = chkAlt5.Checked? 1 : 0;
                        if (panelItems[a].Alt5 != 0)
                        {
                            screen_flags |= (uint16_t)(panelItems[a].Alt5_mask);
                        }
                        else
                        {
                            screen_flags &= (uint16_t)(~panelItems[a].Alt5_mask);
                        }
                    }
                    if (panelItems[a].Alt6_mask != 0)
                    {
                        panelItems[a].Alt6 = chkAlt6.Checked ? 1 : 0;
                        if (panelItems[a].Alt6 != 0)
                        {
                            screen_flags |= (uint16_t)(panelItems[a].Alt6_mask);
                        }
                        else
                        {
                            screen_flags &= (uint16_t)(~panelItems[a].Alt6_mask);
                        }
                    }
                }
            }

            osd.Draw(number);
        }
コード例 #19
0
    public RGBColor getNextColor()
    {
        _steps--;
        _red   = (uint16_t)(_red + _redDelta);
        _green = (uint16_t)(_green + _greenDelta);
        _blue  = (uint16_t)(_blue + _blueDelta);

        return(new RGBColor((uint8_t)(_red >> 8), (uint8_t)(_green >> 8), (uint8_t)(_blue >> 8)));
    }
コード例 #20
0
        void Compare(Register_t a, uint16_t b)
        {
            byte[] opA = registers.Read(a);
            byte[] opB = b.ToBinary();

            alu.Compare(opA, opB);

            ALUCopyCompareFlags();
        }
コード例 #21
0
ファイル: Animator.cs プロジェクト: ericgu/AnimationDesigner
 public void setOffset(uint16_t offsetMin, uint16_t offsetMax, uint16_t offsetCount, uint16_t offsetIncrement)
 {
     _offsetIncrement = offsetIncrement;
     _offsetMax       = offsetMax;
     _offsetMin       = offsetMin;
     _offsetCount     = offsetCount;
     _offset          = _offsetMin;
     _offsetWait      = 0;
 }
コード例 #22
0
 public AnimateLinear(uint16_t offsetMin, uint16_t offsetMax, uint16_t offsetCount, uint16_t offsetIncrement)
 {
     _offsetIncrement = offsetIncrement;
     _offsetMax       = offsetMax;
     _offsetMin       = offsetMin;
     _offsetCount     = offsetCount;
     _offset          = _offsetMin;
     _offsetWait      = 0;
 }
コード例 #23
0
        void ALUOperation(Register_t a, uint16_t b, ALU.ALUOperation op)
        {
            byte[] opA = registers.Read(a);
            byte[] opB = b.ToBinary();
            bool   overflow;

            byte[] result = op(opA, opB, out overflow);
            registers.Write(a, result);
            ALUCopyFlags();
        }
コード例 #24
0
        public Opcode(Opcodes opcode, OpcodeFlags flags, uint16_t opA, uint16_t opB)
        {
            this.opcode = opcode;

            operandA   = opA;
            operandB   = opB;
            this.flags = flags;

            ptr = new SmartPointer(0, 8);
        }
コード例 #25
0
        public void FromBinary(byte[] value)
        {
            if (value.Length != 8)
            {
                throw new IndexOutOfRangeException();
            }

            opcode   = (Opcodes)BitConverter.ToUInt16(value, 0);
            flags    = (OpcodeFlags)BitConverter.ToUInt16(value, 2);
            operandA = new uint16_t(BitConverter.ToUInt16(value, 4));
            operandB = new uint16_t(BitConverter.ToUInt16(value, 6));
        }
コード例 #26
0
ファイル: Mapper.cs プロジェクト: ericgu/AnimationDesigner
        public void renderAndShow(Chunk chunk)
        {
            var numPixels = _strip.numPixels();

            for (uint16_t i = 0; i < numPixels; i++)
            {
                RGBColor color = chunk.getNextPixel();

                _strip.setPixelColor(i, color.red, color.green, color.blue);
            }

            _strip.show();
        }
コード例 #27
0
    public PixelAnimator(RGBColor currentColor, RGBColor targetColor, int steps)
    {
        _steps       = steps;
        _targetColor = targetColor;

        _red   = (uint16_t)(currentColor.red << 8);
        _green = (uint16_t)(currentColor.green << 8);
        _blue  = (uint16_t)(currentColor.blue << 8);

        _redDelta   = (uint16_t)(((targetColor.red - currentColor.red) << 8) / steps);
        _greenDelta = (uint16_t)(((targetColor.green - currentColor.green) << 8) / steps);
        _blueDelta  = (uint16_t)(((targetColor.blue - currentColor.blue) << 8) / steps);
    }
コード例 #28
0
        /* **************************************************************** */
        // Panel  : panWPDir
        // Needs  : X, Y locations
        // Output : 2 symbols that are combined as one arrow, shows direction to next waypoint
        // Size   : 1 x 2  (rows x chars)
        // Staus  : not ready

        public int panWPDir(int first_col, int first_line)
        {
            osd.setPanel(first_col, first_line);
            osd.openPanel();

            long     waypoint_distance        = 1620;
            uint16_t waypoint_eta_sec         = 103;
            uint16_t osd_waypointactive_index = 5;

            osd.printf("%c%c%c%4.0f%c|%02i%c%02i%c%2i", 0x13, 0x14, 0x19, (float)waypoint_distance, unit_length, (osd_waypointactive_index + 1), 0x1A, ((int)(waypoint_eta_sec / 60)) % 60, 0x3A, waypoint_eta_sec % 60);

            osd.closePanel();
            return(0);
        }
コード例 #29
0
ファイル: config.cs プロジェクト: JJRnumrous/ardu
        public int writeEEPROM(uint16_t start, uint16_t length)
        {
            ArduinoSTK sp  = osd.OpenArduino();
            int        err = 0;

            if (sp != null && sp.connectAP())
            {
                try {
                    bool spupload_flag = false;

                    for (int i = 0; i < 10; i++)   //try to upload two times if it fail
                    {
                        spupload_flag = sp.upload(eeprom.data, start, length, start);
                        if (!spupload_flag)
                        {
                            if (sp.keepalive())
                            {
                                Console.WriteLine("keepalive successful (iter " + i + ")");
                            }
                            else
                            {
                                Console.WriteLine("keepalive fail (iter " + i + ")");
                            }
                        }
                        else
                        {
                            break;
                        }

                        if (!spupload_flag)
                        {
                            err = 1;
                        }
                    }
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    err = -1;
                }
            }
            else
            {
                MessageBox.Show("Failed to talk to bootloader");
                err = -1;
            }

            sp.Close();

            return(err);
        }
コード例 #30
0
ファイル: SyntaxTree.cs プロジェクト: griderd/gsvm
        bool ExpectRegister(string operand, out uint16_t result)
        {
            result = Int.UInt16;

            if (IsRegister(operand))
            {
                Register register;
                bool     isRegister = Enum.TryParse <Register>(operand.ToUpper(), out register);
                result = new uint16_t((ushort)register);
                return(isRegister);
            }
            else
            {
                return(false);
            }
        }
コード例 #31
0
        protected void WriteMemory()
        {
            if (Parent == null)
            {
                throw new Exception("Not connected to VM. Parent is null.");
            }
            if (Northbridge == null)
            {
                throw new Exception("Not connected to northbridge.");
            }

            uint16_t address = registers.Read <uint16_t>(Register.MAR);
            uint16_t length  = registers.Read <uint16_t>(Register.MLR);

            byte[] value = new byte[0];

            switch (length.Value)
            {
            case 8:
                value = registers.Read(Register.MDR);
                break;

            case 4:
                value = registers.Read(Register.MDR32);
                break;

            case 2:
                value = registers.Read(Register.MDR16);
                break;

            case 1:
                value = registers.Read(Register.MDR8);
                break;
            }

            try
            {
                Northbridge.WriteMemory(address, value, (uint)value.Length);
            }
            catch (MemoryAccessException)
            {
                // Raise interrupt
                SetFlag(CPUFlags.MemoryError);
            }
        }
コード例 #32
0
ファイル: IRDecoder.cs プロジェクト: amoldeshpande/ModuloLib
 bool match(uint16_t measured, int16_t desired_us)
 {
     return (measured >= (short)IREncoding.TICKS_LOW(desired_us) && measured <= (short)IREncoding.TICKS_HIGH(desired_us));
 }
コード例 #33
0
ファイル: IRDecoder.cs プロジェクト: amoldeshpande/ModuloLib
 bool matchSpace(uint16_t measured, uint16_t desired_us)
 {
     return match(measured, (short)(desired_us - IREncoding.MARK_EXCESS));
 }