delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/17/11:15:20

Xref: news2.mv.net comp.os.msdos.djgpp:6082
From: Arash <ei39594 AT ios DOT chalmers DOT se>
Newsgroups: comp.os.msdos.djgpp
Subject: r-mode handler just crashes!
Date: 17 Jul 1996 14:24:59 GMT
Organization: Chalmers University of Technology
Lines: 60
Message-ID: <4sit3r$8eu@nyheter.chalmers.se>
NNTP-Posting-Host: sv31978.ios.chalmers.se
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi
Few days ago i found this old file on my drive, an old rutten project.
Anyway, i saw that the real-mode keayboard handler is called
and i had to get rid of it somewhere in loop with something like 
while(kbhit()) getch(); 
which is not the best way to do that. In FAQ i found that i had to 
install a real-mode handler too, i did that. actually i just copied from 
FAQ and info-files that comes with compiler and .... i now had a 
real-mode handler too! Everything went just fine untill i tried to 
execute my program, then the program just reboots my machine on the 
very first key stroke :(
I said REBOOT, not LOCK the keyboard as when you forget to renove custom 
handler before exit!

I think it has something to do with accessing the Keybaord[] buffer which 
is not in real-mode memory (???). Everything else is just fine - i copied 
everything from FAQ, remember??

My question is simple:
How shall i do it?? :)

Here is the P-MODE handler:
----------------------
#define kbd_int 9
volatile unsigned char Keyboard[256];
_go32_dpmi_seginfo old_int9, new_int9;
void my_int9(void){
 /* a few lines are missing here, but the handler looks
  * something like this : */
	unsigned char Key;
	Key = inportb(0x60);
	if(Key & 128)   Keyboard[Key & 127] = 0;
	else Keyboard[Key] = 1;
        outportb(0x20,0x20);
	}
void Install_Kbd(void){
	for(int i = 0; i < 132; i++)
		Keyboard[i] = 0;
	_go32_dpmi_get_protected_mode_interrupt_vector(kbd_int, 
&old_int9);     
	new_int9.pm_offset = (int)my_int9;
	new_int9.pm_selector = _go32_my_cs();
	while(kbhit())  getch();
	_go32_dpmi_chain_protected_mode_interrupt_vector(kbd_int, 
&new_int9);
	}
--------------------------

Thanx for any help
-- Arash
   _____                            |\/\/\/|     
  /     \      _____________        |      |      _______________
\/\/     |    | diz sux...  \       |      |     |  way too much |
 |  (c)(c)    | ..hehe cool |       | (o)(o)     |  MTV dad!     |
 C   .---_)   |  __________/        S      _)    \   ____________|
  | |.___|   /  /                   | ,___|    __/  /
  |  \__/   <__/                    |    /    <____/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019