home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 8 / CDASC08.ISO / NEWS / 554 / JUIN / TSRTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1993-10-07  |  2KB  |  54 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 597 of 643
  3. From : Sean Palmer                         1:104/123.0          07 Jun 93  13:57
  4. To   : Rob Perelman
  5. Subj : Intercepting keypresses
  6. ────────────────────────────────────────────────────────────────────────────────
  7. RP>I don't know if he is or not...but I'd like to see a simple and verbose
  8. RP>explanation on how to make a TSR...pref. using the KEEP procedure...
  9.  
  10. OK. I'll write up one right quick. This isn't gonna be tested (hard to
  11. test a TSR while keeping your mail program in memory...)}
  12.  
  13. program TSRTest;
  14.  
  15. uses dos;
  16.  
  17. var
  18.  oldInt:procedure;  {hook for old keyboard interrupt handler}
  19.  
  20. procedure newInt;interrupt;  {interrupt keyword makes procedure far}
  21.                              {also saves/restores all regs and}
  22.                              {ends with an iRet instruction}
  23.                              {sets up DS correctly also but}
  24.                              {uses caller's stack}
  25. var i:word; b:boolean;
  26. begin
  27.  b:=port[$60]<$80;   {see if it's a press}
  28.  
  29.  oldInt;     {call old interrupt handler for keystrokes (BIOS)}
  30.  
  31.  if b then
  32.   for i:=0 to $3FFF do   {change screen colors as example}
  33.    mem[$B800:i*2]:=succ(mem[$B800:i*2])and $EF;
  34.  end.
  35.  
  36. begin
  37.  getIntVec(9,@oldInt);  {keep previous keyboard hooks}
  38.  setIntVec(9,@newInt);  {patch in our keyboard interrupt handler}
  39.  keep(0);  {returns exit code of 0 (normal termination)}
  40.            { and stays resident}
  41.  end.
  42.  
  43. All it does is sit in memory, and every time you press a key,
  44. it gets called, and it changes the screen colors.
  45.  
  46. That's about as simple as you're gonna get, now verbosity was never my
  47. strong point. If you don't understand something, ask.
  48.  
  49. DJ Murdoch's TPU2TPS for TP 6.0 lets you make VERY small tsr's, but this
  50. will link in about 1k worth of the system unit plus some stuff from the
  51. DOS unit which will make it about 1.5k.
  52.  
  53. If you wanna write TSR's the best bet is to learn assembly.
  54.