Exemplo n.º 1
0
        // a pixel can have 0%/33%/66%/100% Intensity depending on the display time the last 3 frames
        // input: 512 bytes, one pixel uses 1 bit: 0=off, 1=on
        // output: 4096 bytes, one pixel uses 1 byte: 0=off, 1=33%, 2=66%, 3=100%
        byte[] _getShadedOutputVideoFrame()
        {
            ushort OFFSET_BUFFER0 = 0;
            ushort OFFSET_BUFFER1 = dmdPageSize;
            ushort OFFSET_BUFFER2 = (ushort)(dmdPageSize * 2);

            // output is 8 times larger (1 pixel uses 1 byte)
            byte[] videoBufferShaded = Enumerable.Repeat((byte)0x00, 8 * dmdPageSize).ToArray();

            var outputOffset = 0;
            var inputOffset  = 0;

            for (var scanline = 0; scanline < DMD_WINDOW_HEIGHT; scanline++)
            {
                for (var eightPixelsOffset = 0; eightPixelsOffset < DMD_WINDOW_WIDTH_IN_BYTES; eightPixelsOffset++)
                {
                    for (var i = 0; i < 8; i++)
                    {
                        var bitMask   = Bitmagic.setMsbBit((byte)i);
                        var intensity = (byte)(((shadedVideoBufferLatched[OFFSET_BUFFER0 + inputOffset] & bitMask) > 0 ? 1 : 0) +
                                               ((shadedVideoBufferLatched[OFFSET_BUFFER1 + inputOffset] & bitMask) > 0 ? 1 : 0) +
                                               ((shadedVideoBufferLatched[OFFSET_BUFFER2 + inputOffset] & bitMask) > 0 ? 1 : 0));
                        videoBufferShaded[outputOffset++] = intensity;
                    }
                    inputOffset++;
                }
            }
            return(videoBufferShaded);
        }
Exemplo n.º 2
0
        /**
         * update Fliptronics switch
         * @param {number} value Valid input numbers range from 11..88
         * @param {boolean} optionalValue if omitted, the switch will be toggled, else set or cleared
         */
        public void setFliptronicsInput(string value, bool?optionalValue = null)
        {
            bool hasValidTypeAndLength = value.Length == 2;

            if (!hasValidTypeAndLength || value[0] != 'F')
            {
                Debug.Print("INVALID_FLIPTRONICS_INPUT_VALUE_{0}" + value);
                return;
            }
            byte column = (byte)((value[1] - '0') - 1);

            Debug.Print("setFliptronicsInput {0} {1}", value, optionalValue);

            if (optionalValue != null && optionalValue == true)
            {
                Debug.Print("SET_FLIPTRONICS_INPUT_KEY {0}", column);
                switchState[FLIPTRONICS_COLUMN] |= Bitmagic.setMsbBit(column);
            }
            else if (optionalValue != null && optionalValue == false)
            {
                Debug.Print("CLEAR_FLIPTRONICS_INPUT_KEY {0}", column);
                switchState[FLIPTRONICS_COLUMN] &= (byte)~(Bitmagic.setMsbBit(column));
            }
            else
            {
                Debug.Print("TOGGLE_FLIPTRONICS_INPUT_KEY {0}", column);
                switchState[FLIPTRONICS_COLUMN] ^= Bitmagic.setMsbBit(column);
            }
        }
Exemplo n.º 3
0
        public void setInputKey(byte keyValue, bool?optionalValue = null)
        {
            if (keyValue < 11 || keyValue > 95)
            {
                Debug.Print("INVALID INPUT_KEY {0}", keyValue);
                return;
            }

            byte normalizedKeyValue = (byte)(keyValue - 1);
            byte row    = (byte)(normalizedKeyValue / 10); //Number.parseInt(normalizedKeyValue / 10, 10);
            byte column = (byte)(normalizedKeyValue % 10); //Number.parseInt(normalizedKeyValue % 10, 10);

            if (optionalValue != null && optionalValue == true)
            {
                Debug.Print("SET_INPUT_KEY {0} {1}", row, column);
                switchState[row] |= Bitmagic.setMsbBit(column);
            }
            else if (optionalValue != null && optionalValue == false)
            {
                Debug.Print("CLEAR_INPUT_KEY {0} {1}", row, column);
                switchState[row] &= (byte)~(Bitmagic.setMsbBit(column));
            }
            else
            {
                Debug.Print("TOGGLE_INPUT_KEY {0} {1}", row, column);
                switchState[row] ^= Bitmagic.setMsbBit(column);
            }
            // There is ONE switch in all WPC games called "always closed" (always switch 24 on all WPC games).
            switchState[2] |= 0x08;
        }
Exemplo n.º 4
0
 public void setActiveColumn(byte columnBitmask)
 {
     activeColumn = Bitmagic.findMsbBit(columnBitmask);
     Debug.Print("SET ACTIVE_COLUMN {0}", activeColumn);
 }