home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / bios / testk.c < prev    next >
Text File  |  1998-06-08  |  3KB  |  114 lines

  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  12. */
  13. /*
  14.  * TESTK.C - Keyboard handler testing routines
  15.  */
  16.  
  17. #include <stdio.h>
  18. #include <conio.h>
  19. #include <dos.h>
  20.  
  21. #include "key.h"
  22. #include "timer.h"
  23.  
  24. char * vidmem = (char *)0xb8000;
  25.  
  26. void main (void)
  27. {
  28.     char ascii;
  29.     int c;
  30.  
  31.     setbuf( stdout, NULL );
  32.  
  33.     key_init();
  34.     //timer_init( 0, NULL );
  35.     //keyd_buffer_type = 2;
  36.     keyd_repeat = 0;
  37.  
  38.     printf( "\n\n\n\nThis tests the keyboard library.\n\n" );
  39.     printf( "Press any key to start...\n" );
  40.     printf( "You pressed: %c\n\n", key_getch() );
  41.     printf( "Press F1 to turn off buffering.\n" );
  42.     printf( "      F2 to turn on buffering.\n" );
  43.     printf( "      F4 to flush keyboard.\n" );
  44.     printf( "      F5 to turn repeat off.\n");
  45.     printf( "      F6 to turn repeat on.\n");
  46.     printf( "      F7 to do an INT 3.\n" );
  47.     printf( "      F10 to display some boxes.\n" );
  48.     printf( "      The arrows to see fast multiple keystrokes.\n");
  49.     printf( "      ESC to exit.\n\n" );
  50.  
  51.  
  52.     while( !keyd_pressed[KEY_ESC]  ) {
  53.         int i,j;
  54.  
  55.         for (i=0; i<256; i++ )    {
  56.             if (keyd_pressed[i])        {
  57.                 j = key_to_ascii(i);
  58.                 if (j==255)
  59.                     vidmem[i*2] = 219;
  60.                 else
  61.                     vidmem[i*2] = j;
  62.             } else 
  63.                 vidmem[i*2] = 32;
  64.         }
  65.  
  66.         if (keyd_pressed[KEY_F1])
  67.             keyd_buffer_type = 0;
  68.  
  69.         if (keyd_pressed[KEY_F2])
  70.             keyd_buffer_type = 1;
  71.  
  72.         if (keyd_pressed[KEY_F4])
  73.             key_flush();
  74.  
  75.         if (keyd_pressed[KEY_F5])    {
  76.             keyd_repeat = 0;
  77.             printf( "Repeat off" );
  78.         }
  79.  
  80.         if (keyd_pressed[KEY_F6])    {
  81.             keyd_repeat = 1;
  82.             printf( "Repeat on" );
  83.         }
  84.  
  85. //        if (keyd_pressed[KEY_F7] )
  86. //            key_debug();
  87.  
  88.         if (keyd_pressed[KEY_PAUSE])
  89.             putch( 254 );
  90.  
  91.         if (key_checkch())   {
  92.             c = key_getch();
  93.  
  94.             ascii=key_to_ascii(c);
  95.             if ( ascii==255 )
  96.             {
  97.                 printf("[%4X] ", c );
  98.                 fflush( stdout );
  99.             }
  100.             else
  101.                 putch( ascii );
  102.  
  103.             if (c==1) break;
  104.         }
  105.  
  106.         delay(100);
  107.  
  108.     }
  109.  
  110.     key_close();
  111.     //timer_close();
  112. }
  113. 
  114.