Ejemplo n.º 1
0
        public static async Task Aggregator(
            FPGA.OutputSignal <byte> outRow,
            FPGA.OutputSignal <byte> outCol,
            FPGA.OutputSignal <byte> outOffset,
            FPGA.OutputSignal <bool> tick,
            FPGA.OutputSignal <bool> setColor
            )
        {
            Sequential handler = () =>
            {
                for (byte row = 0; row < 8; row++)
                {
                    for (byte col = 0; col < 8; col++)
                    {
                        tick = true;
                        byte offset = 0;
                        Lookups.RowColToOffset(row, col, ref offset);

                        FPGA.Config.Link(row, outRow);
                        FPGA.Config.Link(col, outCol);
                        FPGA.Config.Link(offset, outOffset);

                        if (row == col || (7 - row) == col)
                        {
                            setColor = true;
                        }
                    }
                }
            };

            FPGA.Config.OnStartup(handler);
        }
Ejemplo n.º 2
0
        public static void PlaceNextPiece(eCellType[] fieldMatrix, int randomValue)
        {
            byte indexOfEmptyCell = (byte)(randomValue & 63);
            bool foundSpot        = false;

            do
            {
                for (byte row = 0; row < 8; row++)
                {
                    for (byte col = 0; col < 8; col++)
                    {
                        byte offset = 0;
                        Lookups.RowColToOffset(row, col, ref offset);
                        eCellType cellType;
                        cellType = fieldMatrix[offset];

                        if (cellType == eCellType.None)
                        {
                            foundSpot = true;
                            if (indexOfEmptyCell == 0)
                            {
                                fieldMatrix[offset] = eCellType.NextPart;
                                return;
                            }
                            else
                            {
                                indexOfEmptyCell--;
                            }
                        }
                    }
                }
            }while (foundSpot);

            throw new GameCompletedException();
        }
Ejemplo n.º 3
0
        public static void Reset(eCellType[] fieldMatrix)
        {
            for (byte row = 0; row < 8; row++)
            {
                for (byte col = 0; col < 8; col++)
                {
                    byte offset = 0;
                    Lookups.RowColToOffset(row, col, ref offset);

                    fieldMatrix[offset] = 0;
                }
            }
        }
Ejemplo n.º 4
0
        public static void DrawCross(eCellType[] fieldMatrix, eCellType color)
        {
            for (byte row = 0; row < 8; row++)
            {
                for (byte col = 0; col < 8; col++)
                {
                    byte offset = 0;
                    Lookups.RowColToOffset(row, col, ref offset);

                    eCellType value = eCellType.None;

                    if (row == col || (7 - row) == col)
                    {
                        value = color;
                    }

                    fieldMatrix[offset] = value;
                }
            }
        }