home *** CD-ROM | disk | FTP | other *** search
- Unit KeyBoard;
-
- { KeyBoard version 3.5b Copyright (C) 1992 Scott D. Ramsay }
-
- { Even back when I was making games for PC-Compute! I hated the fact }
- { that the keyboard can only handle one press at a time. For games, }
- { one needs to keep the SPACEBAR down (to fire) while using the arrow }
- { keys to move. The old keyboard int. Can handle this. So I wrote }
- { a new keyboard interrupt. }
- { The keyboard is taken over at startup. }
- { This Unit changes interrupts, in your own programs chain the }
- { EXITPROC pointer so when exiting the old keyboard int is restored }
- { example: }
- { Program QuickTest; }
- { }
- { Uses Keyboard; }
- { var }
- { oldexitproc : pointer; }
- { }
- { procedure cleanup; far; }
- { begin }
- { { do your cleanup here } }
- { exitproc := oldexitproc; }
- { end; }
- { }
- { begin }
- { oldexitproc := exitproc; }
- { exitproc := @cleanup; }
- { end. }
- { }
- { KEYBOARD.TPU can be used freely in commerical and non-commerical }
- { programs. As long as you don't give yourself credit for writing }
- { this portion of the code. When distributing it (free only), please }
- { include all files and samples so others may enjoy using the code. }
- { Enjoy. }
- { Please bear with my comments. I'm not a tech-writer. You're more }
- { than welcome to modify the comments in this file for people to }
- { understand. }
-
- interface
-
- var
- ch : char; { contains the the ASCII }
- { value of the key pressed }
- { contians #1 if non pressed }
- np : array[1..9,1..2] of boolean; { keypad, true if pressed }
- { np[7,1] - Q } { np[7,2] - home }
- { np[8,1] - W } { np[8,2] - up arrow }
- { np[9,1] - E } { np[9,2] - pgup }
- { np[4,1] - A } { np[4,2] - left arrow }
- { np[5,1] - S } { np[5,2] - 5 }
- { np[6,1] - D } { np[6,2] - right arrow }
- { np[1,1] - Z } { np[1,2] - end }
- { np[2,1] - X } { np[2,2] - down arrow }
- { np[3,1] - C } { np[2,3] - page down }
-
- { In games I mostly just use the "np" array "NumericPad" }
- { Look at your keyboard, and you'll see why it's arranged this way }
- { Think of the second index number as player 1,player 2 }
-
- portb, { current scancode value }
- { < 128 key is down }
- { hi-bit set, scan code released }
- cleared, { True if interrupt not installed }
- plus, { True if plus key is pressed }
- minus, { True if minus key is pressed }
- cold, { Set to True if you want to call }
- { the old interrupt also, this is }
- { kinda flaky. Try not to use }
- lshft,rshft, { True if shifts are pressed }
- space, { True if SPACE key is pressed }
- bspc, { True if bspc is pressed }
- funct, { True if CH is an extended scan-code }
- esc, { True if ESC key pressed }
- enter : boolean; { True if Enter is pressed }
-
- procedure clearbuffer; { Waits until CH=#1 }
- procedure clearkeyint; { Restores old keyboard int }
- procedure cli; inline($fa); { Disable ints }
- procedure sti; inline($fb); { Enable ints }
- function st(h:longint):string; { convert longint to string }
- function vl(h:string):longint; { convert string to longint }
-
- Implementation
-
- (***********************************************************************)
-
-
- If you have any problems, e-mail at:
-
- ramsays@express.digex.com
-
- Sorry, I don't have permanent snail-mail address yet. I just moved
- to the Washington DC area.
-
- The TPU units can be used with in your programs. With out giving
- me credit. If you want the source code, more samples or swap-talk,
- just e-mail me. I'll give sample use-code for free. Actual TPU-source
- code prices can be discussed.
-
- Also, I have completed the following programs.
-
- GEOMAKER Makes tile-maps quickly.
- VSPMAKER Makes the VSP files.
- BKMAKER A drawing program that can read
- VEW files (my own raw format)
- PTR files (my own compressed format)
- GIF files
- PCX files
-
- The three above programs are specifically designed for the 320x200x256
- (game development). I'll upload them when I think they are ready
- to go. (Bout a week)
-
- (Artwork samples done by me. Freeware. Knock your-self out.
- Plug. Highly recommended. For game programmers, try to get
- Animator Pro by Autodesk. This is an excellent program for
- imaging, sprites and so forth. Very similar to the Animator,
- but has better graphic features. The 3D models are created
- with 3D studio by Autodesk then ported to Animator Pro, then
- scaled down/converted to my VSP files. If you can blow a
- few thousand bucks, buy the 3D studio. You can do some amazing
- 3D animations. I can't afford it, I use it at work.)
-
-
- Scott D. Ramsay
-