home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / GAMETP.ZIP / KEYBOARD.INT < prev    next >
Encoding:
Text File  |  1992-10-29  |  6.7 KB  |  127 lines

  1. Unit KeyBoard;
  2.  
  3. { KeyBoard version 3.5b Copyright (C) 1992 Scott D. Ramsay }
  4.  
  5. {   Even back when I was making games for PC-Compute! I hated the fact }
  6. { that the keyboard can only handle one press at a time.  For games,   }
  7. { one needs to keep the SPACEBAR down (to fire) while using the arrow  }
  8. { keys to move.  The old keyboard int.  Can handle this.  So I wrote   }
  9. { a new keyboard interrupt.                                            }
  10. {   The keyboard is taken over at startup.                             }
  11. {   This Unit changes interrupts, in your own programs chain the       }
  12. { EXITPROC pointer so when exiting the old keyboard int is restored    }
  13. {    example:                                                          }
  14. {      Program QuickTest;                                              }
  15. {                                                                      }
  16. {      Uses Keyboard;                                                  }
  17. {      var                                                             }
  18. {        oldexitproc : pointer;                                        }
  19. {                                                                      }
  20. {      procedure cleanup; far;                                         }
  21. {      begin                                                           }
  22. {        { do your cleanup here }                                      }
  23. {        exitproc := oldexitproc;                                      }
  24. {      end;                                                            }
  25. {                                                                      }
  26. {      begin                                                           }
  27. {        oldexitproc := exitproc;                                      }
  28. {        exitproc := @cleanup;                                         }
  29. {      end.                                                            }
  30. {                                                                      }
  31. {   KEYBOARD.TPU can be used freely in commerical and non-commerical   }
  32. { programs.  As long as you don't give yourself credit for writing     }
  33. { this portion of the code.  When distributing it (free only), please  }
  34. { include all files and samples so others may enjoy using the code.    }
  35. { Enjoy.                                                               }
  36. { Please bear with my comments.  I'm not a tech-writer.  You're more   }
  37. { than welcome to modify the comments in this file for people to       }
  38. { understand.                                                          }
  39.  
  40. interface
  41.  
  42. var
  43.    ch : char;                        { contains the the ASCII     }
  44.                                      { value of the key pressed   }
  45.                                      { contians #1 if non pressed }
  46.    np : array[1..9,1..2] of boolean; { keypad, true if pressed    }
  47. {  np[7,1] - Q    }                  { np[7,2] - home             }
  48. {  np[8,1] - W    }                  { np[8,2] - up arrow         }
  49. {  np[9,1] - E    }                  { np[9,2] - pgup             }
  50. {  np[4,1] - A    }                  { np[4,2] - left arrow       }
  51. {  np[5,1] - S    }                  { np[5,2] - 5                }
  52. {  np[6,1] - D    }                  { np[6,2] - right arrow      }
  53. {  np[1,1] - Z    }                  { np[1,2] - end              }
  54. {  np[2,1] - X    }                  { np[2,2] - down arrow       }
  55. {  np[3,1] - C    }                  { np[2,3] - page down        }
  56.  
  57. { In games I mostly just use the "np" array "NumericPad"           }
  58. { Look at your keyboard, and you'll see why it's arranged this way }
  59. { Think of the second index number as player 1,player 2            }
  60.  
  61.    portb,                            { current scancode value          }
  62.                                      { < 128 key is down               }
  63.                                      { hi-bit set, scan code released  }
  64.    cleared,                          { True if interrupt not installed }
  65.    plus,                             { True if plus key is pressed     }
  66.    minus,                            { True if minus key is pressed    }
  67.    cold,                             { Set to True if you want to call }
  68.                                      { the old interrupt also, this is }
  69.                                      { kinda flaky. Try not to use     }
  70.    lshft,rshft,                      { True if shifts are pressed      }
  71.    space,                            { True if SPACE key is pressed    }
  72.    bspc,                             { True if bspc is pressed         }
  73.    funct,                            { True if CH is an extended scan-code }
  74.    esc,                              { True if ESC key pressed }
  75.    enter            : boolean;       { True if Enter is pressed }
  76.  
  77. procedure clearbuffer;               { Waits until CH=#1 }
  78. procedure clearkeyint;               { Restores old keyboard int }
  79. procedure cli; inline($fa);          { Disable ints }
  80. procedure sti; inline($fb);          { Enable ints }
  81. function st(h:longint):string;       { convert longint to string }
  82. function vl(h:string):longint;       { convert string to longint }
  83.  
  84. Implementation
  85.  
  86. (***********************************************************************)
  87.  
  88.  
  89. If you have any problems, e-mail at:
  90.  
  91.     ramsays@express.digex.com
  92.  
  93.   Sorry, I don't have permanent snail-mail address yet.  I just moved
  94.    to the Washington DC area.
  95.  
  96.   The TPU units can be used with in your programs.  With out giving
  97.    me credit.  If you want the source code, more samples or swap-talk,
  98.    just e-mail me.  I'll give sample use-code for free.  Actual TPU-source
  99.    code prices can be discussed.
  100.  
  101.   Also,  I have completed the following programs.
  102.  
  103.      GEOMAKER        Makes tile-maps quickly.
  104.      VSPMAKER        Makes the VSP files.
  105.      BKMAKER         A drawing program that can read
  106.                       VEW files (my own raw format)
  107.                       PTR files (my own compressed format)
  108.                       GIF files
  109.                       PCX files
  110.  
  111.   The three above programs are specifically designed for the 320x200x256
  112.   (game development).  I'll upload them when I think they are ready
  113.   to go. (Bout a week)
  114.  
  115.   (Artwork samples done by me.  Freeware.  Knock your-self out.
  116.    Plug.  Highly recommended.  For game programmers, try to get
  117.    Animator Pro by Autodesk.  This is an excellent program for
  118.    imaging, sprites and so forth. Very similar to the Animator,
  119.    but has better graphic features.  The 3D models are created
  120.    with 3D studio by Autodesk then ported to Animator Pro, then
  121.    scaled down/converted to my VSP files.  If you can blow a
  122.    few thousand bucks, buy the 3D studio.  You can do some amazing
  123.    3D animations. I can't afford it, I use it at work.)
  124.  
  125.  
  126.    Scott D. Ramsay
  127.