コード例 #1
0
ファイル: TestMain.cpp プロジェクト: robotology-legacy/yarp1
void parOut() 
{
	int locresult;

	unsigned char cat = 0;

	if (chip_sel_A) cat += 1;
	if (chip_sel_B) cat += 2;
	if (board_sel_A) cat += 4;
	if (board_sel_B) cat += 8;
	if (board_enable) cat += 64;

	_outp( PPORT, cat );
  
	cat=0;

	if (clk == 0)  
		cat += 1;
	if (d_in == 0)  
		cat += 2;
	_outp( PPORT+2, cat );


	locresult=_inp(PPORT + 1);
	d_out=0;
	if(locresult & 8)
		d_out = 1;


// delay to avoid going over 400k clk rate
//usleep(1);  // may be needed for computers over 266 MHZ, adjust delay as necessary

}
コード例 #2
0
ファイル: outwnd.cpp プロジェクト: lubomyr/freespace2
void mono_init()
{
	int i;

	OSVERSIONINFO ver;
	
	ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&ver);
	if ( ver.dwPlatformId == VER_PLATFORM_WIN32_NT )	{
		mono_found = 0;
		return;
	}

	_outp( 0x3b4, 0x0f );
	_outp( 0x3b4+1, 0x55 );

	if ( _inp( 0x3b4+1 ) == 0x55 )	{
		mono_found = 1;
		_outp( 0x3b4+1, 0 );
	} else {
		mono_found = 0;
		return;
	}


	for (i=0; i<80*25; i++ )	{
		mono_ram[i*2+0] = ' ';
		mono_ram[i*2+1] = 0x07;
	}
	mono_flush();
	mono_x = mono_y = 0;
}
コード例 #3
0
ファイル: parallel.c プロジェクト: takashiyamanoue/SolarCats
unsigned ftAnalog (unsigned short port, int nTrigger) {
  unsigned result = 0;
#ifdef _WIN32
  unsigned short status = port+1;
  int enabled = ftDisable && _disable();
#endif
#ifdef SC12
  unsigned short status = port;
#endif
  int data = (nTrigger ? triggerX : triggerY)|clock;
  if (ftLoadOut) data |= loadOut;

  trace(64, ("analog %03x", port));
  trace(128, (" >%02x", data));
  _outp(port, data); idle(ftIdle);
  data = triggerX|triggerY|clock;
  if (ftLoadOut) data |= loadOut;
  trace(128, (" >%02x", data));
  _outp(port, data);
  while (_inp(status) & busy) ++ result, idle(ftScale);
  trace(64, (" %u\n", result));
#ifdef _WIN32
  if (enabled) _enable();
#endif
  return result;
}
コード例 #4
0
ファイル: tstio.c プロジェクト: alcap-org/AlcapDAQ
/*********************************************************************
  Set PC's speaker frequency in Hz.  The speaker is controlled by an
Intel 8253/8254 timer at I/O port addresses 0x40-0x43.
*********************************************************************/
void setfreq(int hz)
{
	hz = 1193180 / hz;						// clocked at 1.19MHz
	_outp(0x43, 0xb6);						// timer 2, square wave
	_outp(0x42, hz);
	_outp(0x42, hz >> 8);
}
コード例 #5
0
ファイル: tstio.c プロジェクト: alcap-org/AlcapDAQ
/*********************************************************************
  Pass a note, in half steps relative to 400 Hz.  The 12 step scale
is an exponential thing.  The speaker control is at port 0x61.
Setting the lowest two bits enables timer 2 of the 8253/8254 timer
and turns on the speaker.
*********************************************************************/
void playnote(NOTE note)
{
	_outp(0x61, _inp(0x61) | 0x03);			// start speaker going
	setfreq((int)(400 * pow(2, note.pitch / 12.0)));
	Sleep(note.duration);
	_outp(0x61, _inp(0x61) & ~0x03);		// stop that racket!
}
コード例 #6
0
ファイル: vga_text.c プロジェクト: samueldotj/AceOS
/*! Moves the cursor the specified position
	Uses VGA registers.
*/
void VgaMoveCursor(UINT16 Offset)
{
    _outp(VGA_CRT_ADDRESS, VGA_CRT_CURSOR_H_LOCATION);
    _outp(VGA_CRT_DATA, Offset>>8);
    _outp(VGA_CRT_ADDRESS, VGA_CRT_CURSOR_L_LOCATION);
    _outp(VGA_CRT_DATA, (Offset<<8)>>8);
}
コード例 #7
0
ファイル: parallel.c プロジェクト: takashiyamanoue/SolarCats
void ftOutput (unsigned short port, unsigned char byte) {
#ifdef _WIN32
  int enabled = ftDisable && _disable();
#endif
  int data;
  int bit = 8;

  trace(1, ("output %03x", port));
  while (bit-- > 0) {
    data = triggerX|triggerY;
    if (byte & (1<<bit)) data |= dataOut;
    trace(2, (" >%02x", data));
    _outp(port, data); idle(ftIdle);
    data |= clock;
    trace(4, (" >%02x", data));
    _outp(port, data); idle(ftIdle);
  }
  data = triggerX|triggerY|loadOut|clock;
  trace(2, (" >%02x", data));
  _outp(port, data);
  trace(1, (" %02x\n", byte));
#ifdef _WIN32
  if (enabled) _enable();
#endif
}
コード例 #8
0
ファイル: hwctrl.c プロジェクト: BackupTheBerlios/rundfunker
static int check_comport ()
{
	_outp(COM_LCR, 0x0C);
	if((BYTE)_inp(COM_LCR) != 0x0C) return (-1);
	_outp(COM_LCR, 0x03);
	if((BYTE)_inp(COM_LCR) != 0x03) return (-1);
	return (0);
}
コード例 #9
0
ファイル: ioapic.c プロジェクト: samueldotj/AceOS
/*! Sends EOI to PIC*/
void SendEndOfInterruptTo8259(int int_no)
{
	/*! if the interrupt was generated by slave send EOI to it*/
	if ( int_no >= 8 )
		_outp(PIC_SLAVE_IO_PORT_A, 0x20);
	
	/*for all interrrupts(master/slave) send EOI to master*/
	_outp(PIC_MASTER_IO_PORT_A, 0x20);
}
コード例 #10
0
ファイル: hwctrl.c プロジェクト: BackupTheBerlios/rundfunker
static int check_lptport ()
{
	_outp(LPT_CTL, 0);
	_outp(LPT_DAT, 0x08);
	if((BYTE)_inp(LPT_DAT) != 0x08) return (-1);
	_outp(LPT_DAT, 0x40);
	if((BYTE)_inp(LPT_DAT) != 0x40) return (-1);
	return (0);
}
コード例 #11
0
KESTATUS STDCALL KeTimerSetSpeed(UINT32 hz)
{
    UINT32 Divisor;

    Divisor = 1193180 / hz;

    if(!Divisor) Divisor++;

    _outp(TIMER_CONTROL_PORT, SYSTEM_TIMER_SETUP);
    _outp(TIMER_DATA_PORT, Divisor & 0xFF);
    _outp(TIMER_DATA_PORT, Divisor >> 8);
    return STATUS_SUCCESS;
}
コード例 #12
0
ファイル: mtxvga.c プロジェクト: Gaikokujin/WinNT4
void OCFont(byte *d)
{
   _outp(VGA_SEQ_ADDR, d[0] );
   _outp(VGA_SEQ_DATA, d[1] );
   _outp(VGA_SEQ_ADDR, d[2] );
   _outp(VGA_SEQ_DATA, d[3] );
   _outp(VGA_GRAPHIC_ADDR, d[4] );
   _outp(VGA_GRAPHIC_DATA, d[5] );
   _outp(VGA_GRAPHIC_ADDR, d[6] );
   _outp(VGA_GRAPHIC_DATA, d[7] );
   _outp(VGA_GRAPHIC_ADDR, d[8] );
   _outp(VGA_GRAPHIC_DATA, d[9] );
}
コード例 #13
0
ファイル: fmsynth.c プロジェクト: cdrr/MAME_hack
static void WriteOPLRegister(BYTE opl_register, BYTE value)
{
#if defined(_M_IX86)
   int i;

   _outp(0x388, opl_register);
   for (i = 0; i < 6; i++)
      _inp(0x388);

   _outp(0x389, value);

   for (i = 0; i < 35; i++)
      _inp(0x388);
#endif
}
コード例 #14
0
ファイル: TextFile1.cpp プロジェクト: sskoruppa/Glove_Code
int main(int argc, char* argv[])
{
short data;

if(argc<2)
{
printf("Usage\n\n");
printf("partest1.exe ,,\n\n\n");
return 0;
}

if(!strcmp(argv[1],"read"))
{
data = _inp(atoi(argv[2])); 
printf("Data read from parallel port is  ");
printf("%d\n\n\n\n",data);
}

if(!strcmp(argv[1],"write"))
{
_outp(atoi(argv[2]),atoi(argv[3])); 
printf("Data written to parallel port is  ");
printf("%s\n\n\n\n\n",argv[3]);
}
return 0;
}
コード例 #15
0
ファイル: ppt.c プロジェクト: philsmd/sharpfin
// Just put the port into standard parallel mode
void ConfigureParallelPort(void) {
    // Configure the parallel port in standard mode
#if !defined(_WIN32) || defined(__CYGWIN__)
#if defined(LINUX_PPDEV) && ! defined(__CYGWIN__)
        int j;
	int ppt; 
        int k=GetPrinterIndex(base_address);
        if (k<0) {
            fprintf(stderr,"Error: Printer port index not found");
            exit(1);
        }
	char linux_device[512];
        sprintf(linux_device,"/dev/parport%d",k);
        ppt = open(linux_device, O_WRONLY);
        if (ppt < 0) {
                fprintf(stderr, "can't open %s\n",linux_device);
                exit(1);
        }

        j = ioctl(ppt, PPCLAIM);
        if (j < 0) {
                fprintf(stderr, "can't claim device\n");
                close(ppt);
                exit(1);
        }
	int i;
	i = PARPORT_MODE_COMPAT;
	i = ioctl(ppt, PPSETMODE, &i);
	if (i < 0) {
		fprintf(stderr, "can't set compatible mode\n");
		close(ppt);
		exit(1);
	}
	i = IEEE1284_MODE_COMPAT;
	i = ioctl(ppt, PPNEGOT, &i);
	if (i < 0) {
		fprintf(stderr, "can't set compatible 1284 mode\n");
		close(ppt);
		exit(1);
	}
	validPpt=ppt;
#else
        // PPCLAIM, PPSETMODE    , PPNEGOT
        // *      , PARPOR COMPAT, IEEE1284 COMPAT
        if (ioperm(base_address,3,1)) {
   	    printf("Sorry, you were not able to gain access to the ports\n");
   	    printf("You must be root to run this program\n");
   	    exit(1);
   	}

#if defined(__CYGWIN__)
	outb( ECR_STANDARD | ECR_DISnERRORINT | ECR_DISDMA | ECR_DISSVCINT, (U16)(base_address + ECP_ECR_OFFSET) );
#else
	outb( (U16)(base_address + ECP_ECR_OFFSET),  ECR_STANDARD | ECR_DISnERRORINT | ECR_DISDMA | ECR_DISSVCINT );
#endif // CYGWIN OR NOT
#endif
#else
	_outp( (ECR_STANDARD | ECR_DISnERRORINT | ECR_DISDMA | ECR_DISSVCINT), (U16)(base_address + ECP_ECR_OFFSET) );
#endif
}
コード例 #16
0
void _stdcall Out32(short PortAddress, short data)
{

	switch(sysver)
	{
	case 1:
			_outp( PortAddress,data);
	break;

	case 2:
			unsigned int error;
			DWORD BytesReturned;        
			BYTE Buffer[3];
			unsigned short * pBuffer;
			pBuffer = (unsigned short *)&Buffer[0];
			*pBuffer = LOWORD(PortAddress);
			Buffer[2] = LOBYTE(data);

			error = DeviceIoControl(hdriver,
                            IOCTL_WRITE_PORT_UCHAR,
                            &Buffer,
                            3,
                            NULL,
                            0,
                            &BytesReturned,
							NULL);
	break;
	}

	
}
コード例 #17
0
ファイル: ports.c プロジェクト: 13572293130/hackrf
/* if in debugging mode, then just set the variables */
void setPort(short p,short val)
{
#ifdef WIN95PP
    /* Old Win95 example that is similar to a GPIO register implementation.
       The old Win95 example maps individual bits of the 
       8-bit register (out_word) to the JTAG signals: TCK, TMS, TDI. 
       */

    /* Initialize static out_word register bits just once */
    if (once == 0) {
        out_word.bits.one = 1;
        out_word.bits.zero = 0;
        once = 1;
    }

    /* Update the local out_word copy of the JTAG signal to the new value. */
    if (p==TMS)
        out_word.bits.tms = (unsigned char) val;
    if (p==TDI)
        out_word.bits.tdi = (unsigned char) val;
    if (p==TCK) {
        out_word.bits.tck = (unsigned char) val;
        (void) _outp( (unsigned short) (base_port + 0), out_word.value );
        /* To save HW write cycles, this example only writes the local copy
           of the JTAG signal values to the HW register when TCK changes. */
    }
#endif
    /* Printing code for the xapp058_example.exe.  You must set the specified
       JTAG signal (p) to the new value (v).  See the above, old Win95 code
       as an implementation example. */
/*
    if (p==TMS)
        g_iTMS = val;
    if (p==TDI)
        g_iTDI = val;
    if (p==TCK) {
        g_iTCK = val;
        printf( "TCK = %d;  TMS = %d;  TDI = %d\n", g_iTCK, g_iTMS, g_iTDI );
    }
*/
	if (p==TMS) {
		if (val)
			gpio_set(PORT_CPLD_TMS, PIN_CPLD_TMS);
		else
			gpio_clear(PORT_CPLD_TMS, PIN_CPLD_TMS);
	} if (p==TDI) {
		if (val)
			gpio_set(PORT_CPLD_TDI, PIN_CPLD_TDI);
		else
			gpio_clear(PORT_CPLD_TDI, PIN_CPLD_TDI);
	} if (p==TCK) {
		if (val)
			gpio_set(PORT_CPLD_TCK, PIN_CPLD_TCK);
		else
			gpio_clear(PORT_CPLD_TCK, PIN_CPLD_TCK);
	}

	/* conservative delay */
	delay_jtag(20000);
}
コード例 #18
0
ファイル: main.cpp プロジェクト: Vort/VortOS
// ----------------------------------------------------------------------------
void InitPIT()
{
	dword Period = 1193180 / 20; // 20 Hz

	_outp(0x43, 0x36);
	_outp(0x40, (Period >> 0) & 0xFF);
	_outp(0x40, (Period >> 8) & 0xFF);
}
コード例 #19
0
ファイル: ppt.cpp プロジェクト: mayubin/mygjtag
int GetValidPpt(void)
{
	// search for valid parallel port
	_outp(LPT1, 0x55);
	if((int)_inp(LPT1) == 0x55)
	    return LPT1;
	
	_outp(LPT2, 0x55);
	if((int)_inp(LPT2) == 0x55)
	    return LPT2;
	
	_outp(LPT3, 0x55);
	if((int)_inp(LPT3) == 0x55)
	    return LPT3;
	
	return 0;	
}
コード例 #20
0
ファイル: hwctrl.c プロジェクト: iruka-/ATMEL_AVR
void close_ifport ()
{
	BYTE spicmd[2] = {FLAG, SPI_DISABLE};


	switch (PortType) {
		case TY_COMM :
			_outp(COM_MCR, 0);
			_outp(COM_LCR, 3);
			break;

		case TY_VCOM :
			break;

		case TY_BRIDGE :
			send_bridge(spicmd, 2);
			read_bridge(spicmd, 1);
			break;

		case TY_AVRSP :
			_outp(LPT_DAT, 0);
			break;

		case TY_STK200 :
			_outp(LPT_DAT, BS_DIS);
			break;

		case TY_XILINX :
			_outp(LPT_DAT, BX_DIS1|BX_DIS2);
			break;

		case TY_LATTICE :
			_outp(LPT_DAT, BL_DIS);
			break;

		case TY_ALTERA :
			_outp(LPT_CTL, 0);
			break;
#if AVRSPX
		case TY_USBASP :	//@@@ by t.k
			usbasp_close();
			break;

		case TY_HIDASP :	//@@@ by k-k
			hidasp_close();
			break;

		case TY_RSCR :	//@@@ by t.k
			if (hComm != INVALID_HANDLE_VALUE)
				rscr_close();
			break;
#endif

	}

	if(hComm != INVALID_HANDLE_VALUE)
		CloseHandle(hComm);

	PortType = 0;
}
コード例 #21
0
ファイル: ioapic.c プロジェクト: samueldotj/AceOS
/*! Initializes the Programmable Interrupt Controller 8259
	\param start_vector - The interrupt vector number where the IRQ should raised
	\reference http://www.cs.sun.ac.za/~lraitt/doc_8259.html
*/
void InitPic(BYTE start_vector)
{
	/*! Initialize the master PIC by sending Initialization Command Words 1 to 4*/
	_outp(PIC_MASTER_IO_PORT_A, 0x11);				/* ICW1 - Set expect ICW4 bit*/
	_outp(PIC_MASTER_IO_PORT_B, start_vector);		/* ICW2 - Set the interrupt vector number*/
	_outp(PIC_MASTER_IO_PORT_B, 0x4);				/* ICW3 - Set where the slave is connected*/
	_outp(PIC_MASTER_IO_PORT_B, 0x1);				/* ICW4 - Set operating mode is 8086 and not MCS-80/85*/
	
	_outp(PIC_MASTER_IO_PORT_B, 0x4);				/* Mask cascade interrupt*/
	
	/*! Initialize the slave PIC by sending Initialization Command Words 1-4*/
	_outp(PIC_SLAVE_IO_PORT_A, 0x11);				/* ICW1 - Set expect ICW4 bit*/
	_outp(PIC_SLAVE_IO_PORT_B, start_vector+8);		/* ICW2 - Set the interrupt vector number*/
	_outp(PIC_SLAVE_IO_PORT_B, 0x2);				/* ICW3 - Set where the slave is connected*/
	_outp(PIC_SLAVE_IO_PORT_B, 0x1);				/* ICW4 - Set operating mode is 8086 and not MCS-80/85*/
}
コード例 #22
0
ファイル: ParallelPort.cpp プロジェクト: imdmmp/kpgweigher
BOOL CParallelPort::GetECPPort(unsigned short nBaseAddress)
{
    //If the ECP is idle and the FIFO empty,
    //in the ECP's Ecp (at base address+402h),
    //bit 1 (Fifo full)=0, and bit 0 (Fifo empty)=1.
    //The first test is to see if these bits differ from the
    //corresponding bits in the control port (at base address+2).
    //If so a further test is to write 34h to the Ecr,
    //then read it back. Bit 1 is read/write and bit 0 is read-only.
    //If the value read is 35h, the port is an ECP.
    BOOL bSuccess = FALSE;

    unsigned short nEcrAddress = (unsigned short)(nBaseAddress+0x402);
    int nEcrData = _inp(nEcrAddress);

    //Read bits 0 and 1 and control port bit 1
    int nEcrBit0 = nEcrData & 0x1;
    int nEcrBit1 = (nEcrData & 0x2) >> 1;
    int nControlBit1 = (ReadControl(nBaseAddress) & 0x2) >> 1;

    if (nEcrBit0 == 1 && nEcrBit1 == 0)
    {
        //Compare control bit 1 to ECR bit 1
        //Toggle the control bit if necessary
        //to be sure the two registers are different.
        if (nControlBit1 == 0)
        {
            WriteControl(nBaseAddress, 0xF);
            nControlBit1 = (ReadControl(nBaseAddress) & 0x2) >> 1;
        }

        if (nEcrBit1 != nControlBit1)
        {
            int nOriginalEcrData = nEcrData;
            _outp(nEcrAddress, 0x34);
            if (_inp(nEcrAddress) == 0x35)
                bSuccess = TRUE;

            //Restore the ECR to its original value
            _outp(nEcrAddress, nOriginalEcrData);
        }
    }
コード例 #23
0
ファイル: IoLibMsc.c プロジェクト: etiago/vbox
/**
  Writes an 8-bit I/O port.

  Writes the 8-bit I/O port specified by Port with the value specified by Value
  and returns Value. This function must guarantee that all I/O read and write
  operations are serialized.

  If 8-bit I/O port operations are not supported, then ASSERT().

  @param  Port  The I/O port to write.
  @param  Value The value to write to the I/O port.

  @return The value written to the I/O port.

**/
UINT8
EFIAPI
IoWrite8 (
  IN      UINTN                     Port,
  IN      UINT8                     Value
  )
{
  _ReadWriteBarrier ();
  (UINT8)_outp ((UINT16)Port, Value);
  _ReadWriteBarrier ();
  return Value;
}
コード例 #24
0
ファイル: setdiv.c プロジェクト: lu8aja/HeavyMetal
int main(int argc, char **argv) {
    int port_addr;
    int divisor;

    if (argc == 3) {

	unsigned char old_lcr_val;
	short msl;
	short msh;
	short lcr;

	sscanf(argv[1],"%d",&port_addr);
	sscanf(argv[2],"%d",&divisor);

	printf("Setting divisor of uart at port 0x%x to %d\n",port_addr,divisor);

	msl = port_addr + 0;
	msh = port_addr + 1;
	lcr = port_addr + 3;

	if ((port_addr == 0) || (divisor == 0)) {
	    printf("Error: Invalid arguments\n");
	    usage();
	    return -1;
	}

	// Save control register settings
	old_lcr_val = _inp(lcr);

	// Set UART to recieve new divisor
	_outp(lcr,(old_lcr_val | 0x80));

	// Set new divisor a byte at a time
	_outp(msl,divisor & 0xff);
	_outp(msh,divisor >> 8);

	// Restore UART
	_outp(lcr,old_lcr_val);

    } else {
コード例 #25
0
static void ShutdownMPU
   (
   void
   )

   {
   volatile DWORD dwCount;

   for (dwCount=0; dwCount<0x2000; dwCount++) ;
   dwCount = 0x2000;
   while (dwCount && _inp(MPUPort(1)) & 0x40) --dwCount;
   _outp(MPUPort(1), MPU_RESET_CMD);
   for (dwCount=0; dwCount<0x2000; dwCount++) ;
   _inp(MPUPort(0));

   for (dwCount=0; dwCount<0x2000; dwCount++) ;
   dwCount = 0x2000;
   while (dwCount && _inp(MPUPort(1)) & 0x40) --dwCount;
   _outp(MPUPort(1), MPU_RESET_CMD);
   for (dwCount=0; dwCount<0x2000; dwCount++) ;
   _inp(MPUPort(0));
   }
コード例 #26
0
ファイル: fmsynth.c プロジェクト: cdrr/MAME_hack
static void FMSynth_opl_control(int chip, int reg)
{
#if defined(_M_IX86)
    if (enabled)
    {
        if (chip >= MAX_OPLCHIP)
            return;

        tenmicrosec();
        _outp((unsigned short)(0x388 + chip * 2), reg);
    }
#endif
}
コード例 #27
0
ファイル: ppt.c プロジェクト: philsmd/sharpfin
void OutputPpt(U8 value) {
#if !defined(_WIN32) || defined(__CYGWIN__)
#if defined(LINUX_PPDEV) && ! defined(__CYGWIN__)
    int i = value;
    ioctl(validPpt, PPWDATA, &i);
#elif defined(__CYGWIN__)
    outb( value, base_address );
#else
    outb( base_address, value );
#endif
#else
    _outp( value & 0xff, base_address );
#endif
}
コード例 #28
0
ファイル: Locals.c プロジェクト: astrohr/dagor_tca
////////////////////////////////////////////
// Windows95
// delay_us: CPU and clock independent delay
////////////////////////////////////////////
void delay_us (USHORT us)
{
	BYTE lo, hi;
	long summ,c,d,e,max;
	__int64 Delay;


	if ( InitTimeOut (TimDLY) )								// Use high speed timer for clock/cpu independent delay
	{									
		Delay = (__int64)(us) * TIM_1us;							// Number of clock ticks for given delay
		do {
		} while ( !TimeOut (TimDLY, Delay) );
	}
	else													// Use access of isa keyboard hardware for clock/cpu independent delay
	{
		DLLInfo = DLLInfo | DLLInfo_NoDelayTimer;					// High speed timer not used for delay!

		max=us*2380L/1000L;
		summ=0L;
		_outp(67,0);					
		lo=_inp(64); 					// Read low  byte
		hi=_inp(64); 					// Read high byte
		d=(hi<<8)+lo;					// Start time
		while(summ<max)
		{
			_outp(67,0);
			lo=_inp(64);  				// Read low  byte
			hi=_inp(64);  				// Read high byte
			c=(hi<<8)+lo; 				// Current time
			e=d-c;						// Elapsed time
			if(e<0L) e=e+65535L;		// If negative correct overflow
			summ=summ+e;	
			d=c;
		}
	}
}
コード例 #29
0
ファイル: fmsynth.c プロジェクト: cdrr/MAME_hack
static void FMSynth_opl_write(int chip, int data)
{
#if defined(_M_IX86)
    if (enabled)
    {
        if (chip >= MAX_OPLCHIP)
            return;

        tenmicrosec();
        _outp((unsigned short)(0x389 + chip * 2), data);

        if (chip >= num_used_opl)
            num_used_opl = chip + 1;
    }
#endif
}
コード例 #30
-1
ファイル: parallel.c プロジェクト: takashiyamanoue/SolarCats
unsigned char ftDigital (unsigned short port) {
  unsigned char result = 0;
#ifdef _WIN32
  unsigned short status = port+1;
  int enabled = ftDisable && _disable();
#endif
#ifdef SC12
  unsigned short status = port;
#endif
  int bit = 8;
  int data = triggerX|triggerY|loadIn;
  if (ftLoadOut) data |= loadOut;
  
  trace(8, ("digital %03x", port));
  trace(32, (" >%02x", data));
  _outp(port, data); idle(ftIdle);
  data |= clock;
  trace(32, (" >%02x", data));
  _outp(port, data);
  while (bit-- > 0) {
    idle(ftIdle);
    result |= ((_inp(status) & busy) != 0) << bit;
    trace(16, (" <%02x", result));
    data = triggerX|triggerY;
    if (ftLoadOut) data |= loadOut;
    trace(32, (" >%02x", data));
    _outp(port, data); idle(ftIdle);
    data |= clock;
    trace(32, (" >%02x", data));
    _outp(port, data);
  }
  trace(8, (" %02x\n", result));
#ifdef _WIN32
  if (enabled) _enable();
#endif
  return result;
}