示例#1
0
        /// <summary>
        /// Writes to Port C
        /// </summary>
        private void OUTPortC(int data)
        {
            // latch the data
            Regs[PORT_C] = (byte)data;

            if (DirPortCL == PortDirection.Output)
            {
                // lower Port C bits OUT
                // keyboard line update
                Keyboard.CurrentLine = Regs[PORT_C] & 0x0f;
            }

            if (DirPortCU == PortDirection.Output)
            {
                // upper Port C bits OUT
                // write to PSG using latched data
                PSG.SetFunction(data);
                PSG.PortWrite(Regs[PORT_A]);

                // cassete write data
                //not implemeted

                // cas motor control
                Tape.TapeMotor = Regs[PORT_C].Bit(4);
            }
        }
示例#2
0
        /// <summary>
        /// Writes to Port A
        /// </summary>
        private void OUTPortA(int data)
        {
            // latch the data
            Regs[PORT_A] = (byte)data;

            if (DirPortA == PortDirection.Output)
            {
                // PSG write
                PSG.PortWrite(data);
            }
        }
示例#3
0
        /// <summary>
        /// Writes to the control register
        /// </summary>
        /// <param name="data"></param>
        private void OUTControl(int data)
        {
            if (data.Bit(7))
            {
                // update configuration
                Regs[PORT_CONTROL] = (byte)data;

                // Writing to PIO Control Register (with Bit7 set), automatically resets PIO Ports A,B,C to 00h each
                Regs[PORT_A] = 0;
                Regs[PORT_B] = 0;
                Regs[PORT_C] = 0;
            }
            else
            {
                // register is used to set/reset a single bit in Port C
                bool isSet = data.Bit(0);

                // get the bit in PortC that we wish to change
                var bit = (data >> 1) & 7;

                // modify this bit
                if (isSet)
                {
                    Regs[PORT_C] = (byte)(Regs[PORT_C] | (bit * bit));
                }
                else
                {
                    Regs[PORT_C] = (byte)(Regs[PORT_C] & ~(bit * bit));
                }

                // any other ouput business
                if (DirPortCL == PortDirection.Output)
                {
                    // update keyboard line
                    Keyboard.CurrentLine = Regs[PORT_C] & 0x0f;
                }

                if (DirPortCU == PortDirection.Output)
                {
                    // write to PSG using latched data
                    PSG.SetFunction(data);
                    PSG.PortWrite(Regs[PORT_A]);

                    // cassete write data
                    //not implemeted

                    // cas motor control
                    Tape.TapeMotor = Regs[PORT_C].Bit(4);
                }
            }
        }