/* Unload the TSR */ static int far _cdecl unload(void) { /* device driver can't be unloaded */ if (tsr_sys) return 0; if ( (int_10 == getvect(0x10)) #ifdef __RUN__ && (int_21 == getvect(0x21)) && (int_8 == getvect(0x8)) #endif && (int_2f == getvect(0x2f))) { tsr_done_0(); setvect(0x10, int_10_old); #ifdef __RUN__ setvect(0x21, int_21_old); setvect(0x8, int_8_old); #endif setvect(0x2f, int_2f_old); tsr_done_1(); return 1; } return 0; }
main() { randomize(); fill_maze_with_wall(); build_maze(1, 1, RIGHT_BOUND, BOTTOM_BOUND); search_target_xy(&tx, &ty); memset(mark, 0, sizeof(mark)); show_maze(0, 0, RIGHT_BOUND+1, BOTTOM_BOUND+1); save_sth_under_target(); draw_target(); bioskey(0); init_bug(1, 1, 0); old_8h = getvect(8); old_9h = getvect(9); setvect(8, int_8h); setvect(9, int_9h); while(!stop) { if(move_bug(bug[0].x, bug[0].y, tx, ty) == 1) /* target has been reached */ { bug_cry(); break; } } setvect(8, old_8h); setvect(9, old_9h); bioskey(0); }
/* Load old interrupt value */ static void int_init(void) { int_2f_old = getvect(0x2f); int_10_old = getvect(0x10); #ifdef __RUN__ int_21_old = getvect(0x21); int_8_old = getvect(0x8); #endif }
/*..........................................................................*/ void QF_onStartup(void) { /* save the origingal DOS vectors ... */ l_dosTmrISR = getvect(TMR_VECTOR); l_dosKbdISR = getvect(KBD_VECTOR); QF_INT_LOCK(); setvect(TMR_VECTOR, &tmrISR); setvect(KBD_VECTOR, &kbdISR); QF_INT_UNLOCK(); }
void init_com(int device, int baud, int param) { char mask; int lcreg, divll, divlh, mctrl, intena, sioena; getptr2 = combfr2; /* initialize buffer pointers */ putptr2 = combfr2; getptr1 = combfr1; putptr1 = combfr1; commerr2 = 0; /* clear error flag */ commerr1 = 0; if (device == 2) { oldvect2 = getvect(INUM2); /* get old vector routine address */ setvect(INUM2, &comintr2); /* install interrupt vector */ lcreg = LCREG2; divll = DIVLL2; divlh = DIVLH2; mctrl = MCTRL2; intena = INTENA2; sioena = SIOENA2; outportb(lcreg, param | DLAB); /* set params & div latch access */ outportb(divll, baud); outportb(divlh, 0); outportb(lcreg, param); /* clear div latch access */ outportb(mctrl, MDTR | MRTS | MOUT2); /* enable dtr, rts, and interrupts */ outportb(intena, RCVENA); /* enable receive interrupts */ mask = inportb(INTMSK); /* tell 8259 about it */ outportb(INTMSK, mask & sioena); } else if (device == 1) { oldvect1 = getvect(INUM1); /* get old vector routine address */ setvect(INUM1, &comintr1); /* install interrupt vector */ lcreg = LCREG1; divll = DIVLL1; divlh = DIVLH1; mctrl = MCTRL1; intena = INTENA1; sioena = SIOENA1; outportb(lcreg, param | DLAB); /* set params & div latch access */ outportb(divll, baud); outportb(divlh, 0); outportb(lcreg, param); /* clear div latch access */ outportb(mctrl, MDTR | MRTS | MOUT2); /* enable dtr, rts, and interrupts */ outportb(intena, RCVENA); /* enable receive interrupts */ mask = inportb(INTMSK); /* tell 8259 about it */ outportb(INTMSK, mask & sioena); } }
void init_timer(){ slow_tick = 1; fast_tick = 1; tick_counter = 0; oldtimer = getvect(8); init_handler(&state); asm cli // speed up clock // 1193180 / 298295 = 4 (298295kHz, 3,3523861 us, 3 ticks 10,057158us) // its 16384 times faster than standard 18.2Hz clock asm { mov bx, FREQ_DIVI mov al, 00110100b out 43h, al mov al, bl out 40h, al mov al, bh out 40h, al } setvect(8, new_timer); asm sti }
void Init (void) { int i,j,k,n; double angulo; n=0; for (j=0; j<maxy; j++) for (i=0; i<maxx; i++) Tab[i][j]=0; for (j=maxy/3; j<2*maxy/3; j++) for (i=0; i<maxx/tam; i++) { for (k=0; k<tam; k++) Tab[i*tam+k][j]=1000+n; n++; } for (i=0; i<maxbol; i++) bol[i].player=0; bol[0].lx=bol[0].x=maxx/2; bol[0].ly=bol[0].y=maxy-2; bol[0].player=1; bol[1].lx=bol[1].x=maxx/2; bol[1].ly=bol[1].y=1; bol[1].player=2; angulo=pi/2; /* (double) random (1000)/999.0*pi; */ InitBres (&bol[0],cos (angulo),-sin (angulo)); angulo=3*pi/4; InitBres (&bol[1],cos (angulo),sin (angulo)); _setcursortype (_NOCURSOR); rk1=lk1=rk2=lk2=ek=0; p1x=(maxx-rtam)/2; lostone=0; old9handler=getvect (9); setvect (9,new9handler); }
/* 设置新的时钟中断处理过程 */ void SetTimer(void interrupt (*IntProc)()) { oldhandler=getvect(TIMER); disable(); /* 设置新的时钟中断处理过程时,禁止所有中断 */ setvect(TIMER,IntProc); enable(); /* 开启中断 */ }
/* Install our functions to handle communications */ void GSerial::SetVects(void interrupt(*New_Int)(...)) { disable(); OldVects = getvect(InterruptNo[m_unPortNo-1]); setvect(InterruptNo[m_unPortNo-1], New_Int); enable(); }
void GetMicroRetard( void ) { DWORD Counter = 0; DWORD wMcSec = 1; DWORD wCount = 0; OldInt8 = getvect( 0x08 ); setvect( 0x08, Int8Handler ); Flag = 0xFF; Count = 1; // 55 milisegundos while( Flag ); Count = 1; // 55 milisegundos // Bucle que vamos a calibrar while( Counter < wMcSec ) { ++wCount; if( Flag ) Counter = wMcSec; } setvect( 0x08, OldInt8 ); }
int main() { int i; /* Initialization Part */ DosInit(); TcbInitAll(); /*TODO*/ BufInitAll(); /* Get access to the entry address of clock intrrupt */ old_int8 = getvect(8); clrscr(); tcbs[0].state = RUNNING; current = 0; /* current thread */ ThreadCreate(sndThdName,(codeptr)Sender,STACK_SIZE); ThreadCreate(recvThdName,(codeptr)Receiver,STACK_SIZE); setvect(8, new_int8); my_swtch(); TcbState(); while(!ThreadFinished()); TcbState(); setvect(8, old_int8); /* Recover old clock interrupt */ ThreadDestory(0); return 0; }
void int_save_int_vect( void ) { #if 0 // Do nothing if interrupt use not enabled now. // Do nothing if our interrupt handler is installed now. if ( ! ata->int_use_intr_flag ) return; if ( int_got_it_now ) return; // Disable interrupts. // Save the interrupt vector. disable(); int_org_int_vect = getvect( int_int_vector ); // install our interrupt handler setvect( int_int_vector, int_handler ); // Our interrupt handler is installed now. int_got_it_now = 1; // Reset the interrupt flag. #endif //int_intr_cntr = 0; ata->int_intr_flag = 0; // Enable interrupts. //enable(); }
void Nucleus::Inic_Timer(){ #ifndef BCC_BLOCK_IGNORE void interrupt (*oldRoutine)(...) = getvect(0x08); setvect(0x08, Timer); setvect(0x60, oldRoutine); #endif }
void registerSIGINTHandler(void) { register char *s; int len; if (oldSIGINThandler == NULL) { s = catgets (cat, SET_SIGINT, MSG_SIGINTABORT, MSG_SIGINTABORT_STR); if ((msgabort = (char *)malloc((strlen(s)+1)*sizeof(char))) != NULL) strcpy(msgabort, s); s = catgets (cat, SET_SIGINT, MSG_SIGINTVERIFYABORT, MSG_SIGINTVERIFYABORT_STR); if ((msgverifyabort = (char *)malloc((strlen(s)+1)*sizeof(char))) != NULL) strcpy(msgverifyabort, s); /* ( boxborder space strlen(msgverifyabort) space boxborder ) * (char + attribute) */ len = strlen(msgverifyabort); saveblock = (char *)malloc((len+5)*5*2*sizeof(char)); leftx = 40 - (len+5)/2; rightx = 40 + (len+5)/2; topy = 10; bottomy = 14; #ifndef PORTABLE oldSIGINThandler = getvect(0x23); setvect(0x23, ourSIGINThandler); #else oldSIGINThandler = signal(SIGINT, ourSIGINThandler); #endif } }
void main() { clrscr(); old=getvect(INT_NUM); disable(); setvect(INT_NUM,int_func); enable(); float a; clrscr(); cout << "enter number:\n"; cin >> a; asm finit asm fld a int flags=894; // 11_0111_1110 asm fldcw flags asm fsqrt asm fstp a cout << "sqrt: " << a; getch(); setvect(INT_NUM,old); }
void main(void) { unsigned int segment, offst; disable(); /* Deshabilita las interrupciones */ vieja1c=getvect(0x1c); setvect(0x1c,otra1c); enable(); /* Habilita las interrupciones hardware */ asm{ mov ah,34h /* Detectamos la inactividad del DOS */ int 21h /* Retornar 0 si el DOS se encuentra */ mov segment,es /* inactivo y 1 si est activo */ mov offst,bx } tiempo=(char far *) MK_FP(0x0040,0x006c); keep(0,1000); /* Finaliza y permanece residente ( 1000 es el tama¤o */ /* del archivo .EXE creado.Siempre es mejor poner un poco */ /* m s... ) El tama¤o no se expresa en bytes.Divide el */ /* tama¤o entre 16 y eso es lo que tendr s que poner en la */ /* funci¢n keep(). */ }
//............................................................................ void QF::run(void) { // install uC/OS-II context switch vector l_dosSpareISR = getvect(uCOS); setvect(uCOS, (void interrupt (*)(...))&OSCtxSw); // NOTE the QF::onStartup() callback must be invoked from the task level OSStart(); // start uC/OS-II multitasking }
/* * ----- Function: keyboard_setup() ----- */ static void keyboard_setup(void interrupt (*key_isr)(void)) { // Save the default keyboard interrupt vector. default_keyboard_isr = getvect(KEYBOARD_VECT_NUM); // Set the interrupt vector. setvect(KEYBOARD_VECT_NUM, key_isr); }
void main(void) { oldhandler = getvect (0x1c); displayclock(); setvect (0x1c, clockproc); keep (0, (_SS + (_SP/16) - _psp)); }
void install_new_key_handler(void) { keybuf = farmalloc(KEY_WAS_PRESSED * 2); clear_key_buffer(); old_int09_handler = getvect(9); setvect(9, new_int09_handler); new_key_handler_installed = TRUE; }
//--------------------------------------------------------------------------- void tkernel::start() { cur = (TProcess *)ReadyList->at(0); ReadyList->remove(cur); oldhandler = getvect(INTR); disable(); setvect(INTR,handler); swt(mainp->ts,cur->ts); enable(); }//tkernel::start
main() { void interrupt(*oldTimer)(); oldTimer=getvect(0X1c); setvect(0X1c,beNoisy); playtune(song); DoSomething(); setvect(0X1c,oldTimer); nosound(); }
void Timer__init (void) { if (!timer_installed) { /* std_timer = (void interrupt(*)())getvect (0x1C); */ std_timer = getvect (0x1C); setvect (0x1C, timer_handler); elapsed = 0; timer_installed = 1; atexit (Timer_Close); } } /*Timer__init*/
void InstallKeyboard (void) { int i; for (i=0; i<128; i++) Keyboard[i]=0; KeyboardInstalled=1; atexit (RemoveKeyboard); OldKeyboardHandler=getvect (0x09); setvect (0x09,NewKeyboardHandler); }
//------------------------------------------------------------------------------ void init_input(void) { bios_keyboard_handler = getvect(keyboard_interrupt); setvect(keyboard_interrupt, keyboard_handler); for (int i = 0; i < NUM_KEYS; i++) { key_down[i] = 0; } }
void _fast install_24(void) { if (installed) return; installed=TRUE; old_24h=(_intcast)getvect(INT_CRITERR); setvect(INT_CRITERR, (_veccast)newint24h); }
int main(void) { oldhandler = getvect(28); setvect(28, handler); keep(0, (_SS + (_SP/16) - _psp)); return 0; }
void init_ack(){ asm cli send_port(LPT_CONTROL, 16); old_ack7 = getvect(0x0f); setvect(0x0f, ack_int_7); asm sti }
int com_open(int *eflag_p, int baud_rate) { int baud_rate_div; int mask; if(eflag_p == NULL) { return INVALID_E_FLAG; } if(baud_rate <= 0) { return INVALID_BRD; } if(DCB->flag == OPEN) { return ALREADY_OPEN; } //initialize all the DCB fields DCB->flag = OPEN; DCB->event_flag = eflag_p; DCB->status = IDLE; DCB->ring_buffer_in = 0; DCB->ring_buffer_out = 0; DCB->ring_buffer_count = 0; oldfunc = getvect(COM1_INT_ID); setvect(COM1_INT_ID, &handler); baud_rate_div = 115200 / (long) baud_rate; //change BRD reg outportb(COM1_LC, 0x80); //set the baud_rate_div outportb(COM1_BRD_LSB, baud_rate_div & 0xFF); outportb(COM1_BRD_MSB, (baud_rate_div >> 8) & 0xFF); //cant change BRD outportb(COM1_LC, 0x03); //Enable PIC Mask disable(); mask = inportb(PIC_MASK); mask &= ~0x10; outportb(PIC_MASK, mask); enable(); //Enable COM1 interrupts outportb(COM1_MC, 0x08); //Set Data Available Interrupt bit in the interrupt enable register outportb(COM1_INT_EN, 0x01); return 0; }
int com_open(int comport, long speed, int data_bit, unsigned char parity, unsigned char stop_bit) { int x; disable(); if (modem_open) com_close(); modem_port=comport; switch(modem_port) { case 1:modem_base=0x3F8; modem_irq=4; modem_vect=0x0C; break; case 2:modem_base=0x2F8; modem_irq=3; modem_vect=0x0B; break; case 3:modem_base=0x3E8; modem_irq=4; modem_vect=0x0B; break; case 4:modem_base=0x2E8; modem_irq=3; modem_vect=0x0C; break; case 5:break; default:modem_base=0x3F8; modem_irq=4; modem_vect=0x0C; break; } outp(modem_base+1,0x00); if (inp(modem_base+1)!=0) { enable(); return(0); } /* Set up the Interrupt Info */ old_modem_ier=inp(modem_base+1); outp(modem_base+1,0x01); old_modem_isr=(void (INTERRUPT FAR *)(void))getvect(modem_vect); setvect(modem_vect,modem_isr); if (modem_rts_cts) { outp(modem_base+4,0x0B); } else { outp(modem_base+4,0x09); } old_modem_imr=inp(I8088_IMR); outp(I8088_IMR,old_modem_imr & ((1 << modem_irq) ^ 0x00FF)); for (x=1; x<=5; x++) inp(modem_base+x); modem_open=1; modem_buffer_count=0; modem_buffer_head=0; modem_buffer_tail=0; com_speed(speed); com_data_bits((unsigned char)data_bit); com_parity(parity); com_stop_bits(stop_bit); enable(); return(1); }