replaced by maths.h
[btb/d2x.git] / unused / bios / testk.c
1
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 #include <stdio.h>
16 #include <conio.h>
17
18 #include "key.h"
19
20 void main (void)
21 {
22         int i,c, j;
23
24         key_init();
25         keyd_buffer_type = 1;
26
27         printf( "\n\n\n\nThis tests the keyboard library.\n\n" );
28         printf( "Press any key to start...\n" );
29         printf( "You pressed: %c\n\n", key_getch() );
30         printf( "Press F1 to turn off buffering.\n" );
31         printf( "      F2 to turn on ASCII buffering.\n" );
32         printf( "      F3 to turn on scan code buffering.\n" );
33         printf( "      F4 to flush keyboard.\n" );
34         printf( "      F5 to turn repeat off.\n");
35         printf( "      F6 to turn repeat on.\n");
36         printf( "      F7 to do an INT 3.\n" );
37         printf( "      F10 to display some boxes.\n" );
38         printf( "      The arrows to see fast multiple keystrokes.\n");
39         printf( "      ESC to exit.\n\n" );
40
41
42         while( !keyd_pressed[KEY_ESC]  ) {
43
44                 if (keyd_pressed[KEY_F1])
45                         keyd_buffer_type = 0;
46
47                 if (keyd_pressed[KEY_F2])
48                         keyd_buffer_type = 1;
49
50                 if (keyd_pressed[KEY_F3])
51                         keyd_buffer_type = 2;
52
53                 if (keyd_pressed[KEY_F4])
54                         key_flush();
55
56                 if (keyd_pressed[KEY_F5])
57                         keyd_repeat = 0;
58
59                 if (keyd_pressed[KEY_F6])
60                         keyd_repeat = 1;
61
62                 if (keyd_pressed[KEY_F7] )
63                         key_debug();
64
65                 if (keyd_pressed[KEY_UP])
66                         putch( 24 );
67
68                 if (keyd_pressed[KEY_DOWN])
69                         putch( 25 );
70
71                 if (keyd_pressed[KEY_LEFT])
72                         putch( 27 );
73
74                 if (keyd_pressed[KEY_RIGHT])
75                         putch( 26 );
76
77
78                 if (keyd_pressed[KEY_F10])
79                         putch( 254 );
80
81                 if (key_checkch())   {
82                         c = key_getch();
83                         if (keyd_buffer_type==1) {
84                                 if (c==13)
85                                    printf("\n");
86                                 else
87                                    putch( c );
88                         }
89                         else
90                         {
91                                 printf( "[%2X]\n", c );
92
93                         }
94                         delay(80);      // So we can test buffer
95                 }
96
97         }
98
99         key_close();
100
101 }