Date: 27 Jun 1995 18:49:41 -0500 (CDT) From: jmccawle AT cs DOT uno DOT edu (Cap'n Hardgeus) Subject: keyboard interrupt in DJGPP To: djgpp AT sun DOT soe DOT clarkson DOT edu Hello again...I am having a strange problem...I have been using this keyboard interrupt for several months in inline assembly in Microsoft C. About three months ago I ported it over to DJGPP and all seemed to be OK. Then one day I needed to do some printf's. For some reason the keyboard interrupt and printf don't like each other. Sometimes it would crash, sometimes hang...All of this was in mode 13h so I didn't notice another bug until recently. If my program is in text mode, and I use the keyboard interrupt, the second I hit a key while a printf is executing( like in a loop with nothing but printfs ) the graphics mode changes to 13h!!! I took my set_video_mode function out of my code, thinking that maybe the interrupt was jumping to that function (?). But it still did the same thing. Here is the interrupt code : Beginning of code -------------------------------------- _go32_dpmi_seginfo Old_Key_Isr, New_Key_Isr, prot_isr; _go32_dpmi_registers regs; void Init_Keys( void ) { int ret; /* Install real mode handler */ _go32_dpmi_get_real_mode_interrupt_vector( KEYBOARD_INT, &Old_Key_Isr ); New_Key_Isr.pm_offset = (int)New_Key_Int; _go32_dpmi_allocate_real_mode_callback_iret( &New_Key_Isr, ®s ); _go32_dpmi_set_real_mode_interrupt_vector( KEYBOARD_INT, &New_Key_Isr ); /* Install protected mode handler */ prot_isr.pm_offset = (int)New_Key_Int; ret = _go32_dpmi_allocate_iret_wrapper( &prot_isr ); if( ret != 0 ) { printf("Could not allocate protected mode wrapper \n"); exit(0); } } void New_Key_Int( _go32_dpmi_registers *r ) { unsigned char bytey; r->d.eax = 4; /* Just doing this cuz I saw it in the dox */ bytey = inportb( KEY_BUFFER ); raw_key = bytey; /* Raw key is where I store the scan code */ bytey = inportb( KEY_CONTROL ); bytey = bytey | 0x82; outportb( KEY_CONTROL, bytey ); bytey = bytey & 0x7F; outportb( KEY_CONTROL, bytey ); bytey = 0x20; outportb( INT_CONTROL, bytey ); /* Rest of interrupt code deleted */ } --------------------------------------- End of code Sorry it's so long, but I wanted you guys to see exactly what I was and wasn't doing. One last thing. I use the make and break scan codes to keep track of multiple keypresses, which works fine for just the arrow keys. But certain key combinations cause the scan codes to either scramble or get lost...I can't tell which. Does anyone have any expertise in this area ( or can point me to a document of some sort?? ) Thanks! John R. McCawley III Cap'n Hardgeus