BOOLEAN SynthPresent(PUCHAR base, PUCHAR inbase, volatile BOOLEAN *Fired) /*++ Routine Description: Detect the presence or absence of a 3812 (adlib-compatible) synthesizer at the given i/o address by starting the timer and looking for an overflow. Can be used to detect left and right synthesizers separately. Arguments: base - base output address inbase - base input address Return Value: TRUE if a synthesizer is present at that address --*/ { #define inport(port) READ_PORT_UCHAR((PUCHAR)(port)) UCHAR t1, t2; if (Fired) { *Fired = FALSE; } // check if the chip is present SynthMidiSendFM(base, 4, 0x60); // mask T1 & T2 SynthMidiSendFM(base, 4, 0x80); // reset IRQ t1 = inport(inbase); // read status register SynthMidiSendFM(base, 2, 0xff); // set timer - 1 latch SynthMidiSendFM(base, 4, 0x21); // unmask & start T1 // this timer should go off in 80 us. It sometimes // takes more than 100us, but will always have expired within // 200 us if it is ever going to. KeStallExecutionProcessor(200); if (Fired && *Fired) { return TRUE; } t2 = inport(inbase); // read status register SynthMidiSendFM(base, 4, 0x60); SynthMidiSendFM(base, 4, 0x80); if (!((t1 & 0xE0) == 0) || !((t2 & 0xE0) == 0xC0)) { return(FALSE); } return TRUE; #undef inport }
void Get_Pal_Reg(int index, RGB_tripple *color) { outp(PAL_MASK,0xFF); outp(PAL_READ, index); color->red=inport(PAL_DATA); color->green=inport(PAL_DATA); color->blue=inport(PAL_DATA); }
static void write_font(unsigned char *buf, unsigned font_height) { unsigned char seq2, seq4, gc4, gc5, gc6; unsigned i; /* save registers set_plane() modifies GC 4 and SEQ 2, so save them as well */ outport(VGA_SEQ_INDEX, 2); seq2 = inport(VGA_SEQ_DATA); outport(VGA_SEQ_INDEX, 4); seq4 = inport(VGA_SEQ_DATA); /* turn off even-odd addressing (set flat addressing) assume: chain-4 addressing already off */ outport(VGA_SEQ_DATA, seq4 | 0x04); outport(VGA_GC_INDEX, 4); gc4 = inport(VGA_GC_DATA); outport(VGA_GC_INDEX, 5); gc5 = inport(VGA_GC_DATA); /* turn off even-odd addressing */ outport(VGA_GC_DATA, gc5 & ~0x10); outport(VGA_GC_INDEX, 6); gc6 = inport(VGA_GC_DATA); /* turn off even-odd addressing */ outport(VGA_GC_DATA, gc6 & ~0x02); /* write font to plane P4 */ set_plane(2); /* write font 0 */ for(i = 0; i < 256; i++) { //vmemwr(16384u * 0 + i * 32, buf, font_height); memcpy((char*)buf, (char*)(i*32 + 0xA0000), font_height); buf += font_height; } #if 0 /* write font 1 */ for(i = 0; i < 256; i++) { vmemwr(16384u * 1 + i * 32, buf, font_height); buf += font_height; } #endif /* restore registers */ outport(VGA_SEQ_INDEX, 2); outport(VGA_SEQ_DATA, seq2); outport(VGA_SEQ_INDEX, 4); outport(VGA_SEQ_DATA, seq4); outport(VGA_GC_INDEX, 4); outport(VGA_GC_DATA, gc4); outport(VGA_GC_INDEX, 5); outport(VGA_GC_DATA, gc5); outport(VGA_GC_INDEX, 6); outport(VGA_GC_DATA, gc6); }
void savePalette(palette_entry* p) { outport(0x3C7, 0x00); for(int i = 0; i < 256; i++) { p[i].R = inport(0x3C9); p[i].G = inport(0x3C9); p[i].B = inport(0x3C9); } }
/*..........................................................................*/ static void interrupt kbdISR() { uint8_t key = inport(0x60); /* key scan code from 8042 kbd controller */ uint8_t kcr = inport(0x61); /* get keyboard control register */ outportb(0x61, (uint8_t)(kcr | 0x80)); /* toggle acknowledge bit high */ outportb(0x61, kcr); /* toggle acknowledge bit low */ if (key == (uint8_t)129) { /* ESC key pressed? */ QActive_postISR((QActive *)&AO_Table, TERMINATE_SIG, 0); } outportb(0x20, 0x20); /* write EOI to the master PIC */ }
void write_registers(unsigned char *regs){ unsigned i; /* write MISCELLANEOUS reg */ outport(VGA_MISC_WRITE, *regs); regs++; /* write SEQUENCER regs */ for(i = 0; i < VGA_NUM_SEQ_REGS; i++) { outport(VGA_SEQ_INDEX, i); outport(VGA_SEQ_DATA, *regs); regs++; } /* unlock CRTC registers */ outport(VGA_CRTC_INDEX, 0x03); outport(VGA_CRTC_DATA, inport(VGA_CRTC_DATA) | 0x80); outport(VGA_CRTC_INDEX, 0x11); outport(VGA_CRTC_DATA, inport(VGA_CRTC_DATA) & ~0x80); /* make sure they remain unlocked */ regs[0x03] |= 0x80; regs[0x11] &= ~0x80; /* write CRTC regs */ for(i = 0; i < VGA_NUM_CRTC_REGS; i++) { outport(VGA_CRTC_INDEX, i); outport(VGA_CRTC_DATA, *regs); regs++; } /* write GRAPHICS CONTROLLER regs */ for(i = 0; i < VGA_NUM_GC_REGS; i++) { outport(VGA_GC_INDEX, i); outport(VGA_GC_DATA, *regs); regs++; } /* write ATTRIBUTE CONTROLLER regs */ for(i = 0; i < VGA_NUM_AC_REGS; i++) { (void)inport(VGA_INSTAT_READ); outport(VGA_AC_INDEX, i); outport(VGA_AC_WRITE, *regs); regs++; } /* lock 16-color palette and unblank display */ (void)inport(VGA_INSTAT_READ); outport(VGA_AC_INDEX, 0x20); /* add new palette */ VGA_map_color(0, 0xFF, 0xFF, 0xFF); }
int rtc_getHour() { outport(0x70, 0x04); //sleep(1); int year = inport(0x71); return year; }
// 1=sunday int rtc_getWeekday() { outport(0x70, 0x06); //sleep(1); int year = inport(0x71); return year; }
int rtc_getDayOfMonth() { outport(0x70, 0x07); //sleep(1); int year = inport(0x71); return year; }
int rtc_getSecond() { outport(0x70, 0x00); //sleep(1); int year = inport(0x71); return year; }
unsigned long dc_r32(unsigned char reg_no) { unsigned int result_l,result_h; unsigned long result; outport(dc_com, reg_no); uSDelay(10); result_l=inport(dc_data); result_h=inport(dc_data); result = result_h; result = result<<16; result = result+result_l; return(result); }
uint com_status(uint portid) { uint retval; retval=inport(portid+LINE_STATUS); return retval; }
void main(void) { int tarj,modo,x=320,y=240,c=1; unsigned int segment, offst; detectgraph(&tarj,&modo); initgraph(&tarj,&modo,"c:\\tc\\bgi"); setcolor(0); setfillstyle(1,c); do { t=inport(0x60); /* Leemos la entrada del teclado */ switch (t) { case 28: /* Si se ha pulsado INTRO */ if (c<15) c++; else c=1; setfillstyle(1,c); /* Cambiamos el color del c¡rculo */ break; case 72: /* Cursor arriba */ y--; break; case 75: x--; break; /* Cursor izquierda */ case 77: x++; break; /* Cursor derecha */ case 80: y++; break; /* Cursor abajo */ } fillellipse(x,y,40,40); /* dibujamos el c¡rculo */ /* Esta es una forma pr ctica de borrar la pantalla sin excesivos parpadeos */ *(char far *) MK_FP(0x40,0x1a)=*(char far *) MK_FP(0x40,0x1c); }while(t!=1); /* Mientras no se pulse ESC */ }
int rtc_getMinute() { outport(0x70, 0x02); //sleep(1); int year = inport(0x71); return year; }
void main(void) { while (1) { wert=inport(DIP_SWITCH_LOW_ADDR); outport(LED_LOW_ADDR,~wert); } }
void main() { unsigned int c; /* 16 bits */ c = inport (p); printf ("Palabra leida = %x\n",c); getch(); }
/*! * @brief profile(), id(), name(), setEndian(), isLittleEndian() メソッドのテスト * */ void test_case0() { InPortMock inport("OutPortConnectorTest1", toTypename<RTC::TimedFloat>()); RTC::PortService_var port_ref1= inport.get_port_profile()->port_ref; OutPortMock outport("OutPortConnectorTest2", toTypename<RTC::TimedFloat>()); RTC::PortService_var port_ref2= outport.get_port_profile()->port_ref; RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); portAdmin.registerPort(outport); RTC::ConnectorProfile cprof; cprof.connector_id = "id"; cprof.name = CORBA::string_dup("OutPortConnectorTest"); CORBA_SeqUtil::push_back(cprof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(cprof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(cprof.properties, NVUtil::newNV("dataport.subscription_type", "new")); cprof.ports.length(2); cprof.ports[0] = port_ref1; cprof.ports[1] = port_ref2; coil::Properties prop; NVUtil::copyToProperties(prop, cprof.properties); RTC::ConnectorInfo info(cprof.name, cprof.connector_id, CORBA_SeqUtil::refToVstring(cprof.ports), prop); OutPortConnectorMock connector(info); CPPUNIT_ASSERT_EQUAL(std::string(cprof.connector_id), std::string(connector.id())); CPPUNIT_ASSERT_EQUAL(std::string(cprof.name), std::string(connector.name())); connector.setEndian(false); CPPUNIT_ASSERT(!connector.isLittleEndian()); connector.setEndian(true); CPPUNIT_ASSERT(connector.isLittleEndian()); RTC::ConnectorInfo info2 = connector.profile(); CPPUNIT_ASSERT_EQUAL(info.name,info2.name); CPPUNIT_ASSERT_EQUAL(info.id,info2.id); CPPUNIT_ASSERT(info.ports==info2.ports); CPPUNIT_ASSERT_EQUAL(info.properties.size(), info2.properties.size()); CPPUNIT_ASSERT_EQUAL(info.properties["dataport.interface_type"], info2.properties["dataport.interface_type"]); CPPUNIT_ASSERT_EQUAL(info.properties["dataport.dataflow_type"], info2.properties["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(info.properties["dataport.subscription_type"], info2.properties["dataport.subscription_type"]); portAdmin.deletePort(inport); portAdmin.deletePort(outport); }
unsigned int dc_r16(unsigned char reg_no) { unsigned int result; outport(dc_com, reg_no); uSDelay(10); result=inport(dc_data); return(result); }
/*..........................................................................*/ static void interrupt kbdISR() { uint8_t key = inport(0x60); /* key scan code from 8042 kbd controller */ uint8_t kcr = inport(0x61); /* get keyboard control register */ dispPreemptions(KBD_ISR_PRIO); /* for testing only, NOTE01 */ QK_ISR_ENTRY(); /* inform QK-nano about entering the ISR */ outportb(0x61, (uint8_t)(kcr | 0x80)); /* toggle acknowledge bit high */ outportb(0x61, kcr); /* toggle acknowledge bit low */ if (key == (uint8_t)129) { /* ESC key pressed? */ QActive_postISR((QActive *)&AO_Table, TERMINATE_SIG, 0); } Video_printNumAt(60, 12 + 0, VIDEO_FGND_YELLOW, key);/* display the key */ BSP_busyDelay(); /* for testing, NOTE02 */ QK_ISR_EXIT(); /* inform QK-nano about exiting the ISR */ }
static void nic_get_header(snic *nic, unsigned int page, nicframe_header *header) { int iobase=nic->iobase; unsigned int f; outportg(NIC_DMA_DISABLE | NIC_PAGE0 | NIC_START, iobase); outportg(sizeof(nicframe_header), iobase + REMOTEBYTECOUNT0); outportg(0x00, iobase + REMOTEBYTECOUNT1); outportg(0x00, iobase + REMOTESTARTADDRESS0); outportg(page, iobase + REMOTESTARTADDRESS1); outportg(NIC_REM_READ | NIC_START, iobase); if(nic->wordlength==2) for(f=0;f<(sizeof(nicframe_header)>>1);f++) ((unsigned short *)header)[f]=inport(iobase+NE_DATA); else for(f=0;f<sizeof(nicframe_header);f++)
/*++ Routine Description: Detect the presence or absence of a 3812 (adlib-compatible) synthesizer at the given i/o address by starting the timer and looking for an overflow. Can be used to detect left and right synthesizers separately. Arguments: base - base output address inbase - base input address Return Value: TRUE if a synthesizer is present at that address --*/ BOOL SoundSynthPresent(PUCHAR base, PUCHAR inbase) { #define inport(port) READ_PORT_UCHAR((PUCHAR)(port)) UCHAR t1, t2; DbgPrintf3(("SoundSynthPresent() - Entry")); // check if the chip is present SoundMidiSendFM(base, 4, 0x60); // mask T1 & T2 SoundMidiSendFM(base, 4, 0x80); // reset IRQ t1 = inport(inbase); // read status register SoundMidiSendFM(base, 2, 0xff); // set timer - 1 latch SoundMidiSendFM(base, 4, 0x21); // unmask & start T1 // this timer should go off in 80 us. It sometimes // takes more than 100us, but will always have expired within // 200 us if it is ever going to. KeStallExecutionProcessor(200); t2 = inport(inbase); // read status register SoundMidiSendFM(base, 4, 0x60); SoundMidiSendFM(base, 4, 0x80); if (!((t1 & 0xE0) == 0) || !((t2 & 0xE0) == 0xC0)) { return(FALSE); } return TRUE; #undef inport }
int main (void) { unsigned int baseAddr; int fd; int count; __u16 reading; __u8 status; baseAddr = ask_for_base(0x300); fd = open_dev_file(); printf("This sample will read the values from each of the channels on the board.\n"); //enable the DACS outportb(fd, baseAddr + 0x18, 0x1); for(count = 0; count < 8; count ++) { //tell the board what channel we want to read from outportb(fd, baseAddr + 0x02, count); //poll the board until it says that it is done with the conversion do { inportb(fd, baseAddr, &status); }while ((status & 0x80) == 0); inport(fd, baseAddr, &reading); printf("Reading from channel %d: %02X\n", count, reading); } close(fd); }
void read_registers(unsigned char* regs) { unsigned i; /* read MISCELLANEOUS reg */ *regs = inport(VGA_MISC_READ); regs++; /* read SEQUENCER regs */ for(i = 0; i < VGA_NUM_SEQ_REGS; i++) { outport(VGA_SEQ_INDEX, i); *regs = inport(VGA_SEQ_DATA); regs++; } /* read CRTC regs */ for(i = 0; i < VGA_NUM_CRTC_REGS; i++) { outport(VGA_CRTC_INDEX, i); *regs = inport(VGA_CRTC_DATA); regs++; } /* read GRAPHICS CONTROLLER regs */ for(i = 0; i < VGA_NUM_GC_REGS; i++) { outport(VGA_GC_INDEX, i); *regs = inport(VGA_GC_DATA); regs++; } /* read ATTRIBUTE CONTROLLER regs */ for(i = 0; i < VGA_NUM_AC_REGS; i++) { (void)inport(VGA_INSTAT_READ); outport(VGA_AC_INDEX, i); *regs = inport(VGA_AC_READ); regs++; } /* lock 16-color palette and unblank display */ (void)inport(VGA_INSTAT_READ); outport(VGA_AC_INDEX, 0x20); }
/* <port> .inport <word> */ private int zinport(register os_ptr op) { check_type(*op, t_integer); make_int(op, inport((int)op->value.intval)); return 0; }
int main(void) { __u16 data; int chan=0; unsigned long int timeout = 655354L; __u8 checkByte; puts("Sample 5\n"); puts("This sample will read data from all channels on the A/D card using\n" "timer/counter #2 to time and start conversions."); baseAddr = ask_for_baseAddr(0x300); fd = open_dev_file(); outportb(fd, baseAddr + 0x18, 1); CtrMode(baseAddr + 12 , 0, 2);//all counters in mode 2 CtrMode(baseAddr + 12, 1, 2);//all counters in mode 2 CtrMode(baseAddr + 12, 2, 2);//all counters in mode 2 //counter zero without count, it won't increment, cause we don't need it. CtrLoad(baseAddr + 12 , 1, 0x00FF); CtrLoad(baseAddr+ 12, 2, 0x00FF); outportb(fd, baseAddr + 2, chan);//setup channel and gain (gain code 0, gain of 1) outportb(fd, baseAddr + 0, 0xE2);//allow counter to start conversions while(!kbhit()){ timeout=655354L; do { inportb(fd, baseAddr, &checkByte); checkByte &= 0x80; }while(!(checkByte) && (--timeout));//wait for start of conversion do { inportb(fd, baseAddr, &checkByte); checkByte &= 0x80; }while(checkByte && (timeout--)); //wait for end of conversion inport(fd, baseAddr + 2, &data); data &= 0x0FFF; printf("Channel: %i Data Read:%4x\n",chan,data); if (timeout==0) puts(" A/D Timeout Error"); fflush(stdout); chan++; chan%=8; outportb(fd, baseAddr+2,chan);//setup next channel if (chan == 0) { system("clear"); printf("press <enter> to exit.\n"); } } close(fd); }
BYTE Read_REG(BYTE Addr) { outportb(BaseAddress,Addr); return(inport(BaseAddress+1)); }
uint32 SVGA_ReadReg(vgavmware_handle_t *dev, uint32 index) // IN { outport(dev->iobase + SVGA_INDEX_PORT, index); return inport(dev->iobase + SVGA_VALUE_PORT); }
void Wait_Retrace(void) { while (inport(0x03DA)&0x08) {} // wait till VGA is done with retrace. while (!(inport(0x03DA)&0x08)) {} // wait for start of next retrace. }
/*COM1 0x3F8 COM2 0x2F8 COM3 0X3E8 COM4 0X2E8*/ #define BufferSize 1000 void init_port();/*PORT SETTING*/ void main() { int gd=VGA,gm=VGAHI;/*InIt Graphics Driver*/ long int HRead,BRead;/*file stream handler and number of bytes read*/ char RBuffer[BufferSize];/*read buffer*/ unsigned long int FileSize=0;/*file size*/ unsigned long int NoOfByD=0;/*number of byte done*/ unsigned long int NumBuff1000;/*number of buffers.*/ int GotFromPort;/*to store data received from port*/ unsigned long int CurPos=0;/*pointer position in file*/ unsigned int i,g; char FileName[30];/*FILE NAME*/ char FileSizeC[30];/*file size in char form*/ char NoOfBuffC[30];/* no of buffer in char form*/ char x[1];/*to convert int to num from CP.*/ int KeyInput=0,sta=1; initgraph(&gd,&gm,"\\tc\\bgi");/*init graphics*/ cleardevice(); init_port();/*Initilize the COM port for communication*/ MainWindow("COM PORT COMMUNICATION UTILITY"); Boxes(30,60,360,180,0,"SELECT"); Show(); setcolor(14); outtextxy(Left+60,Top+30,"COM PORT Communication Utility."); outtextxy(450,430,"Sameer Rajendra Dubey"); outtextxy(450,450,"T.Y.B.Sc ELECTRONICS"); outtextxy(450,440,"ROLL NUMBER : 317"); Menu(1); for(;;) { KeyInput=getch(); if(KeyInput == 27) { exit(0); } else if(KeyInput == 80)/*Down arrow key*/ { switch(sta) { case 1: { Menu(2); sta=2; break; } case 2: { Menu(3); sta=3; break; } case 3: { Menu(4); sta=4; break; } case 4: { Menu(1); sta=1; break; } } } else if(KeyInput==72)/*Uparrow key*/ { switch(sta) { case 1: { Menu(4); sta=4; break; } case 2: { Menu(1); sta=1; break; } case 3: { Menu(2); sta=2; break; } case 4: { Menu(3); sta=3; break; } } } else if(KeyInput == 13)/*enter key*/ { if(sta==4) { cleardevice(); closegraph(); exit(0); } else { break; } } } if(sta==1)/*recieve file*/ { int c,ch; gotoxy(14,10); InputBox("Recieve File"); scanf("%s",&FileName); HRead=sopen(FileName,O_RDWR|O_BINARY|O_CREAT,SH_DENYNO,S_IREAD|S_IWRITE);/*OPEN FILE*/ outtextxy(Left+10,Top+120,"This terminal is ready to recieve a file."); setcolor(14); outtextxy(Left+10,Top+140,"when done press Esc to Exit"); c=inport(PORT1+5);/*CHECK IF RECIEVE DATA*/ if(c&1) { ch=inport(PORT1); } outportb(PORT1,100);/*SEND CHARACTER 'd' TO REMOTE TERMINAL.*/ for(;;) /*start copy*/ { c=inportb(PORT1+5); if(c&1) { ch=inport(PORT1); x[0]=ch; BRead=write(HRead,x,1); outportb(PORT1,100); } if(kbhit()) { char T=getch(); if(T == 27) { close(HRead); cleardevice(); closegraph(); exit(0); } } } } else if(sta == 2) { char choice; Top=260; Left=80; for(;;)/*Do until we get a valid file name */ { gotoxy(14,10); MainWindow("COM PORT UTILITY"); InputBox("Send File."); scanf("%s",&FileName); HRead=open(FileName,O_RDONLY|O_BINARY); FileSize=filelength(HRead); if(HRead>0)/*valid file*/ { int c=0; if(FileSize>BufferSize)/*calculate the number of buffers.*/ { NumBuff1000=(FileSize/BufferSize); } else { NumBuff1000=1; } if(NumBuff1000*BufferSize<FileSize) { ++NumBuff1000; } min=0;/*assign min max values to status bar*/ max=NumBuff1000; Boxes(30,60,300,180,0,"Send File"); Show(); setcolor(15); outtextxy(Left+10,Top+30,"File Name:"); outtextxy(Left+10,Top+40,"File Size:"); outtextxy(Left+10,Top+50,"Number Of Buffer:"); setcolor(14); outtextxy(Left+150,Top+30,FileName); ltoa(FileSize,FileSizeC,10); ltoa(NumBuff1000,NoOfBuffC,10); outtextxy(Left+150,Top+50,NoOfBuffC); outtextxy(Left+150,Top+40,FileSizeC); outtextxy(Left+10,Top+80,"after making other terminal"); outtextxy(Left+10,Top+90,"Ready press any key to start."); setcolor(15); ShowBar(Left+170,200,10,150); Refresh(0); KeyInput=getch(); if(KeyInput == 27) { cleardevice(); closegraph(); exit(0); } for(i=1;i<=NumBuff1000;i++)/*all buffers send one by one */ { CurPos=tell(HRead);/*get current pos of pointer*/ BRead=read(HRead,RBuffer,BufferSize); CurPos+=BufferSize; lseek(HRead,CurPos,SEEK_SET);/*update ptr*/ CurPos=tell(HRead); g=0; ShowBar(Left+170,200,10,150); Refresh(i); do { c=inportb(PORT1+5);/*CHECK THE DATA*/ if(c&1) { GotFromPort=inport(PORT1);/*get data*/ if(GotFromPort==100)/*if we get d*/ { outportb(PORT1,RBuffer[g]);/*send char to serial port*/ NoOfByD++; g++; } } }while(g<BRead); } /*end for*/ break; }/*end if (valid file)*/ else { Boxes(80,260,450,120,4," Error !!!"); Show(); setcolor(15); outtextxy(Left+10,Top+30,"incorrect file name or file does not exist."); outtextxy(Left+10,Top+40,"press any key to reenter file name or Esc to Cancel"); outtextxy(Left+10,Top+90,"Esc-Exit"); choice=getch(); if(choice==27) { break; } } }/*end for(;;)*/ }/*end of menu if*/ else if(sta==3) { int c,ch; char UserName1[30],UserName2[30]=""; int GotName=0,GaveName=0;/*flags*/ int INBuffer[100],OUTBuffer[100];/*output BUFFERS*/ int INPtr=0,OUTPtr=0; int v=0,flag=0,sl; char s; int i; closegraph(); clrscr(); printf("%c",201); for(i=1;i<=78;i++) { printf("%c",205); } printf("%c%c",187,186); gotoxy(29,2); printf("COM PORT CHAT UTILITY"); gotoxy(80,2); printf("%c%c",186,200); for(i=1;i<=78;i++) { printf("%c",(205)); } printf("%c",(188)); i=0; printf("\nenter your name :"); scanf("%s",&UserName1); sl=strlen(UserName1); do { if(GotName && GaveName) { if(!flag) { printf("\n%s:",UserName1); flag=1; } c=inportb(PORT1+5);/*check to see if char has been recieved.*/ if(c & 1) { ch=inportb(PORT1);/*IF SO ,then get char*/ if(ch==13) { printf("\n%s:",UserName2); for(i=0;i<INPtr-1;i++) { printf("%c",(INBuffer[i])); } INPtr=0; printf("\n%s:",UserName1); }/*end of our data,as we got the name.*/ else { INBuffer[INPtr]=ch; INPtr++; } }/*&c*/ }/*G&G*/ if(kbhit()) { ch=getch();/*if key pressed,get char*/ if((ch == 13) && GaveName && GotName) { for(i=0;i<=OUTPtr;i++) { outportb(PORT1,OUTBuffer[i]); delay(1); } outportb(PORT1,13); printf("\n%s:",UserName1); OUTPtr=0; } else if(GaveName && GotName) { OUTBuffer[OUTPtr]=ch; OUTPtr++; printf("%c",ch); } } if(!GotName)/*we want the name of the user on other computer*/ { c=inportb(PORT1+5);/*check to see if char has been recieved.*/ if(c&1) { ch=inportb(PORT1);/*IF SO THE GET CHAR*/ if(ch==13) { i=0; printf("\n user on remote computer:%s",UserName2); printf("\n press Esc to Exit"); GotName=1; }/*end of our data, as we got the name*/ else { s=ch; UserName2[i]=s;/*store name*/ i++; } } }/*end of got name*/ if(!GaveName) { outportb(PORT1,UserName1[v]);/*send name char by char*/ v++; if(v == sl) { outportb(PORT1,13); GaveName=1; } } }while(ch!=27);/*Quit when Esc(ASC27) is pressed*/ } closegraph();/*end of chat part*/ }
main() { int i,ar,in,inp; /*modo grafico*/ int gdriver=DETECT,gmode,errorcode; initgraph(&gdriver,&gmode,"..\\bgi"); errorcode=graphresult(); if (errorcode!= grOk) { printf("Error grafico: %s/n",grapherrormsg(errorcode)); printf("Presione cualquier tecla:"); getch(); exit(1); } getch(); /* >>>>>>>>>>>>> INTRODUCCION <<<<<<<<<<<<<<<<*/ /* Background */ setcolor(1); for (i=240; i>=0; i--) { /*delay(50);*/ rectangle(i,i,getmaxx()-i,getmaxy()-i); } setcolor(14); rectangle(0,0,getmaxx(),getmaxy()); rectangle(1,1,getmaxx()-1,getmaxy()-1); rectangle(2,2,getmaxx()-2,getmaxy()-2); rectangle(3,3,getmaxx()-3,getmaxy()-3); rectangle(4,4,getmaxx()-4,getmaxy()-4); rectangle(5,5,getmaxx()-5,getmaxy()-5); settextstyle(SMALL_FONT,VERT_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(20,420,"UNIVERSIDAD"); outtextxy(20,270,"SANTA"); outtextxy(20,115,"VINA"); outtextxy(614,420,"UNIVERSIDAD"); outtextxy(614,270,"SANTA"); outtextxy(614,115,"VINA"); setcolor(9); rectangle(6,6,getmaxx()-6,getmaxy()-6); rectangle(7,7,getmaxx()-7,getmaxy()-7); rectangle(8,8,getmaxx()-8,getmaxy()-8); rectangle(9,9,getmaxx()-9,getmaxy()-9); rectangle(10,10,getmaxx()-10,getmaxy()-10); rectangle(11,11,getmaxx()-11,getmaxy()-11); settextstyle(SMALL_FONT,VERT_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(20,365,"TECNICA"); outtextxy(20,237,"MARIA"); outtextxy(20,91,"DEL"); outtextxy(614,365,"TECNICA"); outtextxy(614,237,"MARIA"); outtextxy(614,91,"DEL"); setcolor(4); rectangle(12,12,getmaxx()-12,getmaxy()-12); rectangle(13,13,getmaxx()-13,getmaxy()-13); rectangle(14,14,getmaxx()-14,getmaxy()-14); rectangle(15,15,getmaxx()-15,getmaxy()-15); rectangle(16,16,getmaxx()-16,getmaxy()-16); rectangle(17,17,getmaxx()-17,getmaxy()-17); settextstyle(SMALL_FONT,VERT_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(20,315,"FEDERICO"); outtextxy(20,140,"SEDE"); outtextxy(20,71,"MAR"); outtextxy(614,315,"FEDERICO"); outtextxy(614,140,"SEDE"); outtextxy(614,71,"MAR"); /*fin background */ setcolor(4); for(i=0; i<=133; i++)rectangle(50+i,50+i,580-i,190-i); /*line (col1,fila1,col2,fila2) */ setcolor(14); line(50,50,50,190); line(51,50,51,190); line(52,50,52,190); line(580,50,580,190); line(581,50,581,190); line(582,50,582,190); line(50,50,580,50); line(50,51,580,51); line(50,52,580,52); line(50,190,582,190); line(50,191,582,191); line(50,192,582,192); setcolor(14); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(312,100,"PROGRAMACION DE SISTEMAS"); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,3); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(312,160,"Proyecto Final"); setcolor(14); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(320,230,"Control de un Motor Paso a Paso"); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(320,370,"ALUMNOS:"); outtextxy(320,390,"Rodrigo Augosto Cancino"); outtextxy(320,410,"Ivan Moyano Varas"); /* >>>>>>>>>>>>>> FIN INTRODUCCION <<<<<<<<<<<<<<<<<*/ /*delay(9999); delay(9999); delay(9999); delay(9999);*/ /*delay(9999); delay(9999); delay(9999); delay(9999);*/ /*delay(9999); delay(9999);*/ delay(9000); /* >>>>>> FUNCIONAMIENTO <<<<<<<<<< */ /* Background*/ setcolor(1); for (i=0; i<=240; i++)rectangle(i,i,getmaxx()-i,getmaxy()-i); setcolor(14); rectangle(0,0,getmaxx(),getmaxy()); rectangle(1,1,getmaxx()-1,getmaxy()-1); rectangle(2,2,getmaxx()-2,getmaxy()-2); rectangle(3,3,getmaxx()-3,getmaxy()-3); rectangle(4,4,getmaxx()-4,getmaxy()-4); rectangle(5,5,getmaxx()-5,getmaxy()-5); settextstyle(SMALL_FONT,VERT_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(20,420,"UNIVERSIDAD"); outtextxy(20,270,"SANTA"); outtextxy(20,115,"VINA"); outtextxy(614,420,"UNIVERSIDAD"); outtextxy(614,270,"SANTA"); outtextxy(614,115,"VINA"); setcolor(9); rectangle(6,6,getmaxx()-6,getmaxy()-6); rectangle(7,7,getmaxx()-7,getmaxy()-7); rectangle(8,8,getmaxx()-8,getmaxy()-8); rectangle(9,9,getmaxx()-9,getmaxy()-9); rectangle(10,10,getmaxx()-10,getmaxy()-10); rectangle(11,11,getmaxx()-11,getmaxy()-11); settextstyle(SMALL_FONT,VERT_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(20,365,"TECNICA"); outtextxy(20,237,"MARIA"); outtextxy(20,91,"DEL"); outtextxy(614,365,"TECNICA"); outtextxy(614,237,"MARIA"); outtextxy(614,91,"DEL"); setcolor(4); rectangle(12,12,getmaxx()-12,getmaxy()-12); rectangle(13,13,getmaxx()-13,getmaxy()-13); rectangle(14,14,getmaxx()-14,getmaxy()-14); rectangle(15,15,getmaxx()-15,getmaxy()-15); rectangle(16,16,getmaxx()-16,getmaxy()-16); rectangle(17,17,getmaxx()-17,getmaxy()-17); settextstyle(SMALL_FONT,VERT_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(20,315,"FEDERICO"); outtextxy(20,140,"SEDE"); outtextxy(20,71,"MAR"); outtextxy(614,315,"FEDERICO"); outtextxy(614,140,"SEDE"); outtextxy(614,71,"MAR"); /*fin background */ setcolor(14); for(i=0; i<=100; i++)rectangle(50+i,80+i,580-i,182-i); setcolor(1); /*line (col1,fila1,col2,fila2) */ line(55,85,55,175); line(56,85,56,175); line(57,85,57,175); line(573,85,573,175); line(574,85,574,175); line(575,85,575,175); line(55,85,575,85); line(55,86,575,86); line(55,87,575,87); line(55,175,575,175); line(55,176,575,176); line(55,177,575,177); setcolor(1); settextjustify(CENTER_TEXT,CENTER_TEXT); settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2); outtextxy(300, 122, "DESCRIPCION DE FUNCIONAMIENTO"); outtextxy(300, 142, "DEL PROGRAMA"); setcolor(14); settextjustify(CENTER_TEXT, CENTER_TEXT); settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 2); outtextxy(300, 220, "Programa disenado para controlar"); outtextxy(300, 245, "el movimiento de un motor paso a paso"); outtextxy(300, 270, "por intermedio de un Dip - Switch"); outtextxy(300, 295, "A continuacion se daran a conocer"); outtextxy(300, 320, "las posiciones del switch para"); outtextxy(300, 345, "distintos movimientos del motor."); /* >>>>>>>>>> FIN FUNCIONAMIENTO <<<<<<<<<<<<<<<<<*/ /*delay(9999); delay(9999); delay(9999); delay(9999);*/ /*delay(9999); delay(9999); delay(9999); delay(9999);*/ /*delay(9999); delay(9999); delay(9999);*/ delay(9000); /* >>>>>>>>>>>> PROGRAMA <<<<<<<<<<<<<<<<<<<<<<*/ while(1) { /* Background*/ setcolor(1); for (i=0; i<=240; i++)rectangle(i,i,getmaxx()-i,getmaxy()-i); setcolor(14); rectangle(0,0,getmaxx(),getmaxy()); rectangle(1,1,getmaxx()-1,getmaxy()-1); rectangle(2,2,getmaxx()-2,getmaxy()-2); rectangle(3,3,getmaxx()-3,getmaxy()-3); rectangle(4,4,getmaxx()-4,getmaxy()-4); rectangle(5,5,getmaxx()-5,getmaxy()-5); settextstyle(SMALL_FONT,VERT_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(20,420,"UNIVERSIDAD"); outtextxy(20,270,"SANTA"); outtextxy(20,115,"VINA"); outtextxy(614,420,"UNIVERSIDAD"); outtextxy(614,270,"SANTA"); outtextxy(614,115,"VINA"); setcolor(9); rectangle(6,6,getmaxx()-6,getmaxy()-6); rectangle(7,7,getmaxx()-7,getmaxy()-7); rectangle(8,8,getmaxx()-8,getmaxy()-8); rectangle(9,9,getmaxx()-9,getmaxy()-9); rectangle(10,10,getmaxx()-10,getmaxy()-10); rectangle(11,11,getmaxx()-11,getmaxy()-11); settextstyle(SMALL_FONT,VERT_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(20,365,"TECNICA"); outtextxy(20,237,"MARIA"); outtextxy(20,91,"DEL"); outtextxy(614,365,"TECNICA"); outtextxy(614,237,"MARIA"); outtextxy(614,91,"DEL"); setcolor(4); rectangle(12,12,getmaxx()-12,getmaxy()-12); rectangle(13,13,getmaxx()-13,getmaxy()-13); rectangle(14,14,getmaxx()-14,getmaxy()-14); rectangle(15,15,getmaxx()-15,getmaxy()-15); rectangle(16,16,getmaxx()-16,getmaxy()-16); rectangle(17,17,getmaxx()-17,getmaxy()-17); settextstyle(SMALL_FONT,VERT_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(20,315,"FEDERICO"); outtextxy(20,140,"SEDE"); outtextxy(20,71,"MAR"); outtextxy(614,315,"FEDERICO"); outtextxy(614,140,"SEDE"); outtextxy(614,71,"MAR"); /*fin background */ setcolor(4); for(i=0; i<=100; i++)rectangle(50+i,80+i,580-i,182-i); setcolor(15); /*line (col1,fila1,col2,fila2) */ line(55,85,55,175); line(56,85,56,175); line(57,85,57,175); line(573,85,573,175); line(574,85,574,175); line(575,85,575,175); line(55,85,575,85); line(55,86,575,86); line(55,87,575,87); line(55,175,575,175); line(55,176,575,176); line(55,177,575,177); setcolor(14); settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2); settextjustify(CENTER_TEXT, CENTER_TEXT); outtextxy(315,130,"POSICIONES DEL DIP SWITCH"); settextjustify(LEFT_TEXT, CENTER_TEXT); settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 1); outtextxy(110, 240, " 0 0 El Motor esta detenido"); outtextxy(110, 260, " 0 1 El Motor avanza 36 grados y se detiene"); outtextxy(110, 280, " 1 0 El Motor avanza 18 grados y se detiene"); outtextxy(110, 300, " 1 1 El Motor retrocede 36 grados y se detiene"); in=inport(0x379); inp=in&0xff; printf("\n puerto de entrada: %x ",inp); switch(inp){ case 0x7f : outportb(0x378,0x88); outportb(0x378,0x44); outportb(0x378,0x22); outportb(0x378,0x11); break; case 0x6f : outportb(0x378,0x11); outportb(0x378,0x22); outportb(0x378,0x44); outportb(0x378,0x88); break; case 0x77 : outportb(0x378,0x88); outportb(0x378,0xcc); outportb(0x378,0x44); outportb(0x378,0x66); outportb(0x378,0x22); outportb(0x378,0x33); outportb(0x378,0x11); outportb(0x378,0x99); break; case 0x67 : outportb(0x378,0x11); outportb(0x378,0x33); outportb(0x378,0x22); outportb(0x378,0x66); outportb(0x378,0x44); outportb(0x378,0xcc); outportb(0x378,0x88); outportb(0x378,0x99); break; default : break; } /* >>>>>>>>>>>> FIN PROGRAMA <<<<<<<<<<<<<<*/ setcolor(15); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,1); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(500,450,"Otro giro (s/n)"); /*if (inp==0xff|inp==0xe7|inp==0xef|inp==0xf7)*/ ar=getch(); if (ar==110|ar==27) { clrscr(); outportb(0x378,0x00); /* Background*/ setcolor(1); for (i=0; i<=240; i++)rectangle(i,i,getmaxx()-i,getmaxy()-i); setcolor(14); rectangle(0,0,getmaxx(),getmaxy()); rectangle(1,1,getmaxx()-1,getmaxy()-1); rectangle(2,2,getmaxx()-2,getmaxy()-2); rectangle(3,3,getmaxx()-3,getmaxy()-3); rectangle(4,4,getmaxx()-4,getmaxy()-4); rectangle(5,5,getmaxx()-5,getmaxy()-5); settextstyle(SMALL_FONT,VERT_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(20,420,"UNIVERSIDAD"); outtextxy(20,270,"SANTA"); outtextxy(20,115,"VINA"); outtextxy(614,420,"UNIVERSIDAD"); outtextxy(614,270,"SANTA"); outtextxy(614,115,"VINA"); setcolor(9); rectangle(6,6,getmaxx()-6,getmaxy()-6); rectangle(7,7,getmaxx()-7,getmaxy()-7); rectangle(8,8,getmaxx()-8,getmaxy()-8); rectangle(9,9,getmaxx()-9,getmaxy()-9); rectangle(10,10,getmaxx()-10,getmaxy()-10); rectangle(11,11,getmaxx()-11,getmaxy()-11); settextstyle(SMALL_FONT,VERT_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(20,365,"TECNICA"); outtextxy(20,237,"MARIA"); outtextxy(20,91,"DEL"); outtextxy(614,365,"TECNICA"); outtextxy(614,237,"MARIA"); outtextxy(614,91,"DEL"); setcolor(4); rectangle(12,12,getmaxx()-12,getmaxy()-12); rectangle(13,13,getmaxx()-13,getmaxy()-13); rectangle(14,14,getmaxx()-14,getmaxy()-14); rectangle(15,15,getmaxx()-15,getmaxy()-15); rectangle(16,16,getmaxx()-16,getmaxy()-16); rectangle(17,17,getmaxx()-17,getmaxy()-17); settextstyle(SMALL_FONT,VERT_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(20,315,"FEDERICO"); outtextxy(20,140,"SEDE"); outtextxy(20,71,"MAR"); outtextxy(614,315,"FEDERICO"); outtextxy(614,140,"SEDE"); outtextxy(614,71,"MAR"); /*fin background */ setcolor(15); settextstyle(GOTHIC_FONT,HORIZ_DIR,2); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(300,40,"UNIVERSIDAD TECNICA FEDERICO SANTA MARIA"); outtextxy(340,60,"Sede Vina del Mar - CHILE"); settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(LEFT_TEXT,CENTER_TEXT); outtextxy(180,200,"ALUMNOS:"); outtextxy(200,220,"* Rodrigo Augosto Cancino"); outtextxy(200,240,"* Ivan Moyano Varas"); settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(LEFT_TEXT,CENTER_TEXT); outtextxy(180,280,"PROFESOR:"); outtextxy(200,300,"* Jose Estay"); settextstyle(SMALL_FONT,HORIZ_DIR,4); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(310,430,"www.ivaninternet.com"); outtextxy(310,440,"www.alumnos.utfsm.cl/~raugostc"); outtextxy(310,450,">>>>TODOS LOS DERECHOS RESERVADOS<<<<"); settextstyle(SANS_SERIF_FONT,VERT_DIR,2); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(60,270,"CARRERA DE ELECTRONICA"); outtextxy(40,270,"PROGRAMACION DE SISTEMAS"); settextstyle(SANS_SERIF_FONT,VERT_DIR,2); settextjustify(CENTER_TEXT,CENTER_TEXT); outtextxy(580,270,"CARRERA DE ELECTRONICA"); outtextxy(600,270,"PROGRAMACION DE SISTEMAS"); /*delay(9999); delay(9999); delay(60999); delay(9999);*/ /*delay(9999); delay(9999); delay(9999); delay(9999);*/ /*delay(9999); delay(9999); delay(9999); delay(9999);*/ /*delay(9999); delay(9999);*/ delay(9000); break; } } closegraph(); return(0); }