home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / ISC366.ZIP / EXAMPLES / EXAMPLE1.CPP next >
C/C++ Source or Header  |  1993-09-01  |  3KB  |  70 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //                                                                          //
  3. //                             example1 of ISC...                           //
  4. //                             ------------------                           //
  5. //                                                                          //
  6. //  - Put an isr on timer tick which increments the top left char on vga/ega//
  7. //    screens! (dynamicly created with new.                                 //
  8. //                                                                          //
  9. //  - Put an isr on keyboard interrupts that increments on every press or   //
  10. //    release of any key, 1 char right of the first isr. (static).          //
  11. //                                                                          //
  12. //  - test for the same program in memory, if already resident - get out    //
  13. //    with an error.                                                        //
  14. //  - if not resident already, activate isr and stay resident with about    //
  15. //       10KB in memory.                                                    //
  16. //                                                                          //
  17. //////////////////////////////////////////////////////////////////////////////
  18. //                                                                          //
  19. //                       By:- Ofer Laor (AKA LeucroTTa)                     //
  20. //                                                                          //
  21. //////////////////////////////////////////////////////////////////////////////
  22.  
  23. #include "isc.h"   // ISC.
  24. #include <stdio.h> // printf.
  25.  
  26. #include <dos.h>; // keep
  27.  
  28. class SHOW_TICKS: public ISC {
  29.       virtual void isr(void);
  30. };
  31.  
  32. void SHOW_TICKS::isr(void)
  33. {
  34.     old_vect();
  35.     (*((char far *)0xb8000000L))++;
  36. }
  37.  
  38. class SHOW_KEYS: public ISC {
  39.       virtual void isr(void);
  40. };
  41.  
  42. void SHOW_KEYS::isr(void)
  43. {
  44.     old_vect();
  45.     (*((char far *)0xb8000002L))++;
  46. }
  47.  
  48. SHOW_KEYS keys;
  49.  
  50. int main()
  51. {
  52.     // check if program is already resident...
  53.     // use as parameter - the name of the program.
  54.     // - note you can check for other programs in mem too (under DOS >= 4.0)
  55.     //   by putting the .exe name (capital letters)- as is_TSR param!
  56.     //
  57.     if (ISC::is_TSR("EXAMPLE1")) {
  58.        printf("Error: already resident!\n\a");
  59.        return 1;
  60.     }
  61.  
  62.     (new SHOW_TICKS)->activate(0x8); // this is the object that hooks the interrupt.
  63.  
  64.     keys.activate(0x9);
  65.  
  66.  
  67.     ISC::TSR(0); // try and stay resident.
  68.     printf("Error: could not stay resident!\n\a");
  69.     return 2;
  70. }