Page 1 of 2

YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Sat Mar 08, 2003 5:44 pm
by Mastermind
I have a problem with a very basic keyboard routine. I tried to use getch, but it crashed my computer, telling me to remove the disk and restart the computer.
Can anyone help me solve this problem?

Re:YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Sat Mar 08, 2003 5:49 pm
by Mastermind
Oh yeah, I forgot: I've attached some of the code.

When I compile the code, the asciiShift[] and the asciiNonSh[] in the keydefs.h always gives me problems (initialization makes integer from pointer without a cast).

Can anyone see anything wrong with the code? Somebody help me PLEASE!!!

[attachment deleted by admin]

Re:YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Sat Mar 08, 2003 5:53 pm
by Ozguxxx
The gurus can tell you a millions of reasons for this but I think you wont be happy with it so I think you should try giving some clue about the problem.(like some source, bochs error...)

Re:YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Sat Mar 08, 2003 5:57 pm
by Ozguxxx
Hey mastermind I am sorry, you had posted your second post before I have finished typing my post.

Re:YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Sat Mar 08, 2003 5:59 pm
by Mastermind
Well, the src is attached. If you didn't see it, I'll attach it again. As for Bochs: I didn't use it. I used a physical computer.
I still can't see what went wrong with the code... :(

[attachment deleted by admin]

Re:YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Sat Mar 08, 2003 6:03 pm
by Mastermind
Ozguxxx wrote: Hey mastermind I am sorry, you had posted your second post before I have finished typing my post.
Well, I didn't mind that ;). I posted the new src code, which has the same problem but is easier to read (sort of).
Stil looking for help ;).

Re:YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Sat Mar 08, 2003 6:10 pm
by Ozguxxx
Hey, I just checked fastly and I think there is some mistake here:

In keydefs.h:

UINT GetRawKey() {
RAWKEY scancode;
while ( TRUE ) { // Wait 'til a key is pressed

//while (!(inportb(0x64)&1));
while (!(inportb(0x64)&&1));
^-------This should be changed...



scancode = getrawkeynow();


//if ( scancode & KEYPRESS ) { // Is a key is up?
if ( scancode && KEYPRESS ) { // Is a key is up?
^-------This should be changed...


scancode &= 0x7F; // Yep.
if ( scancode == KRLEFT_SHIFT || scancode == KRRIGHT_SHIFT ) { // Shift up?


I think these two lines should be changed becuase & applies to two values and takes their and and returns result so if you use it in an if(a&b) then you will most probably always enter into if block you would better use if(a&&b) so that you will do in right way. I think there are some errors like this, if you cahnge these and if problem still exists, send code again. Hope this helps, good luck...

Re:YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Sat Mar 08, 2003 10:56 pm
by Mastermind
Because it's really late, I cannot check it out right now. But I'll do it tomorrow and see if it works. Thanks a bunch!!

Re:YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Sun Mar 09, 2003 5:09 am
by Whatever5k
I think these two lines should be changed becuase & applies to two values and takes their and and returns result so if you use it in an if(a&b) then you will most probably always enter into if block you would better use if(a&&b) so that you will do in right way.
Nope, wrong. & is right here because it's the AND operator - && is the logical AND operator. scancode & KEY_PRESS will check if a the a key is pressed (statement will be true). If you use && the statement will likely *always* be true which isn't that what you want

Re:YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Sun Mar 09, 2003 8:25 am
by Ozguxxx
Yeah well ;D sorry my mistake...

Re:YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Sun Mar 09, 2003 4:52 pm
by Mastermind
Yeah... I sorta figured that out when I was dissecting my code... It seems as if the computer thinks that the unsigned char "retchar" in getch() is an integer. That's why it says "initialization makes integer from pointer without a cast" when I try to display it as a string. I think the error originated in the initialization of asciiShift[] and asciiNonSh[] in keydefs.h. How can I solve this problem (and make the getch work)?

As for the exact message the computer displays to tell me to reset... It it "Remove disks or other media. Press any key to reset."

Please help.

Re:YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Mon Mar 10, 2003 3:12 pm
by Mastermind
Please, ANYONE : Help Me!!!

Re:YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Mon Mar 10, 2003 3:52 pm
by Pype.Clicker
please stop shouting ...
i never seen such a weird message from the computer. It looks like a BIOS message (maybe you're requesting the CPU to halt through the BIOS)
Are you in protected mode ? We do not even know ...

Re:YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Mon Mar 10, 2003 3:56 pm
by Pype.Clicker

Code: Select all

int c_main(void) {
   UCHAR keypress = getch();
   output(STDTXT, 1, 0, keypress);
}

int output(int color, int row, int col, char *string) ;
you're using the value of the character pressed as a string pointer ? i hardly see how it could even work. maybe you should try

Code: Select all

char keypress[2];
keypress[0]=getch();
keypress[1]=0;
output(STDTXT,1,0,keypress);

Re:YO! THIS IS REALLY ANNOYING!!! (MESSED UP KBD ROUTINE)

Posted: Mon Mar 10, 2003 4:29 pm
by Therx
Surely

Code: Select all

output(STDTXT,1,0,&keypress);