示例#1
0
        void OPL3LPTWrite(ushort reg, byte data)
        {
            int   i;
            short lpt_data;
            short lpt_ctrl;

            if (port == 0)
            {
                return;
            }
            lpt_data = (short)port;
            lpt_ctrl = (short)(port + 2);

            /* Select OPL3 register */
            LPT.outportb(lpt_data, (short)(reg & 0xFF));
            if (reg < 0x100)
            {
                LPT.outportb(lpt_ctrl, 13);
                LPT.outportb(lpt_ctrl, 9);
                LPT.outportb(lpt_ctrl, 13);
            }
            else
            {
                LPT.outportb(lpt_ctrl, 5);
                LPT.outportb(lpt_ctrl, 1);
                LPT.outportb(lpt_ctrl, 5);
            }

            /* Wait at least 3.3 microseconds */
            for (i = 0; i < 6; i++)
            {
                LPT.inportb(lpt_ctrl);
            }

            /* Set value */
            LPT.outportb(lpt_data, data);
            LPT.outportb(lpt_ctrl, 12);
            LPT.outportb(lpt_ctrl, 8);
            LPT.outportb(lpt_ctrl, 12);

            /* 3.3 microseconds is sufficient here as well for OPL3 */
            for (i = 0; i < 6; i++)
            {
                LPT.inportb(lpt_ctrl);
            }
        }
示例#2
0
 public byte ReadRegister(int port)
 {
     return(LPT.inportb((short)port));
 }