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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Mastermind

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

Post 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?
Mastermind

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

Post 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]
Ozguxxx

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

Post 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...)
Ozguxxx

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

Post by Ozguxxx »

Hey mastermind I am sorry, you had posted your second post before I have finished typing my post.
Mastermind

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

Post 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]
Mastermind

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

Post 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 ;).
Ozguxxx

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

Post 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...
Mastermind

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

Post 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!!
Whatever5k

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

Post 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
Ozguxxx

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

Post by Ozguxxx »

Yeah well ;D sorry my mistake...
Mastermind

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

Post 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.
Mastermind

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

Post by Mastermind »

Please, ANYONE : Help Me!!!
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

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

Post 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 ...
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

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

Post 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);
Therx

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

Post by Therx »

Surely

Code: Select all

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