Page 1 of 1

outputting of chars ??

Posted: Thu Oct 17, 2002 10:31 am
by gtsphere
hey all,
okay well my keyboard handler works great now, knows all keys, and i can output 1 at a time, over the same spot (X Y) like always at 5, 5

but when i try to incrememnt X to allow, the characters to type out 1 by 1, like a normal command prompt, the code outputs all of them untill the screen is full... i dunno what to do!

so in example, if i hit a: it displays a then fills the screen up, as if it always loops the x++? so i added code to check if a key was being hit, and if it wasn't, NOT to do anything with outputting, but it still outputs hundreds of them... i have no idea, is it possible that my put function is messed up? here is the code:
void put( unsigned c, int x, int y )
{
???unsigned att;

???att = textattrib << 8;

???unsigned short *where;
???
???where = vgaadr + ( y * scrwidth + x );
???*where = c | att;
???
}

i don't think it is, because its not doing anything out of the normal. But here is the code for the keyboard/outputting:
???   while( scanCode != 01 )   //while we didn't hit ESCAPE key
   {
      
      scanCode = KeyboardInterruptHandler();   //get scancode
      
      //we need to check to see if they pressed a key!
      if( KeyPressed(scanCode) )   //1 if true, a key was pressed
      {
         
         //if they hit enter, then redo prompt and go up a line
         if( asciicodes[scanCode-1] == '\n' )
         {
            //bug here, we are not checking if we go outside the boundaries of the screen!
            
            //y++;
            
            gotoxy( 0, y );   //start cursor there!
            
            printf("tellus: / ]: ");   //our prompt, cursor should be right after this!
            
         }
         //its something other than a \n or a special char
         else
         {
            
            put( asciicodes[scanCode-1], x, y );   //output he char we typed minus 1 cause arrays start at 0 we start at 1
            //x++;
            
            
         }
      
      }
      else
      {
         //key was not pressed
      }
   }
???
any ideas would be great, thanks in advance!

Re:outputting of chars ??

Posted: Fri Oct 18, 2002 2:46 am
by grey wolf
doesn't the keyboard send the scancode with a "pressed" attribute, then continue to send the same code with a "released" attribute? or am i confusing this with a win32 API call? ???

Re:outputting of chars ??

Posted: Fri Oct 18, 2002 9:44 pm
by gtsphere
yea, i actually realized that and then i had to figure in a wait for key hit function, so all it needed was a pause untill something ELSE was hit

go figure heh