public static bool Init() { try { uint nResult = 0; try { nResult = LPT.IsInpOutDriverOpen(); return(true); } catch (BadImageFormatException) { nResult = LPT.IsInpOutDriverOpen_x64(); if (nResult != 0) { IsLPTX64 = true; } else { return(false); } } } catch (DllNotFoundException ex) { return(false); } return(false); }
public bool Init(int rate) { bool result = LPT.Init(); Reset(); return(result); }
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); } }
void OPL2LPTWrite(ushort reg, byte data) { short lpt_data; short lpt_ctrl; if (port == 0) { return; } lpt_data = (short)port; lpt_ctrl = (short)(port + 2); /* Select OPL2 register */ LPT.outportb(lpt_data, (short)reg); LPT.outportb(lpt_ctrl, 13); LPT.outportb(lpt_ctrl, 9); LPT.outportb(lpt_ctrl, 13); /* Wait at least 3.3 microseconds */ //for (i = 0; i < 6; i++) //for (i = 0; i < 1; 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); /* Wait at least 23 microseconds */ //for (i = 0; i < 35; i++) //for (i = 0; i < 1; i++) //{ // LPT.inportb(lpt_ctrl); //} }
public byte ReadRegister(int port) { return(LPT.inportb((short)port)); }