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

  1. //////////////////////////////////////////////////////////////////////////////
  2. //                                                                          //
  3. //                             example4 of ISC...                           //
  4. //                             ------------------                           //
  5. //                                                                          //
  6. //  will put a Novell look alike message on the screen, preventing the      //
  7. //  forground to work- will free with a ^Enter. The message will be sent    //
  8. //  every few seconds...                                                    //
  9. //                                                                          //
  10. //////////////////////////////////////////////////////////////////////////////
  11. //                                                                          //
  12. //                       By:- Ofer Laor (AKA LeucroTTa)                     //
  13. //                                                                          //
  14. //////////////////////////////////////////////////////////////////////////////
  15.  
  16. #include "isc.h"   // ISC.
  17. #include <dos.h>;  // enable, disable.
  18. #include <conio.h>;
  19.  
  20. class Msg: public ISC {
  21.  
  22.       virtual void isr(void);
  23.       void put_TSR_message(const char *);
  24.       static char* static_message;
  25.  
  26. public:
  27.        void activate(void) {
  28.             ISC::activate (0x8);
  29.        }
  30.  
  31.        Msg(): ISC() {};
  32.  
  33. };
  34.  
  35.  
  36. char *Msg::static_message= ">>                                                       (CTRL-ENTER to clear)";
  37.  
  38. void Msg::isr(void)
  39. {
  40.     static unsigned index= 0;
  41.     static unsigned char recursive= 0;
  42.  
  43.     old_vect();
  44.  
  45.     if (recursive)
  46.        return;
  47.     recursive++;
  48.  
  49.     enable();
  50.  
  51.     if (index== 50) {
  52.        put_TSR_message("   Hello there");
  53.        index= 0;
  54.     }
  55.     else
  56.         index++;
  57.  
  58.     recursive--;
  59. }
  60.  
  61. void Msg::put_TSR_message(const char *text)
  62. {
  63.     static unsigned char recursive= 0;
  64.     static char old_screen[160];
  65.     static int i;
  66.  
  67.     if (recursive)
  68.        return;
  69.     recursive++;
  70.  
  71.  
  72.     char far *sp= (char far *)MK_FP(0xb800, 3840);
  73.  
  74.     for (i= 0; i< 160; i++)
  75.         old_screen[i]= sp[i];
  76.  
  77.     for (i= 0; static_message[i]; i++) {
  78.         sp[i*2]= static_message[i];
  79.         sp[i*2+ 1]= 0x70;
  80.     }
  81.  
  82.     for (i=0; (i< 80)&& (text[i]); i++) {
  83.         if (sp[i*2]== ' ')
  84.            sp[i*2]= text[i];
  85.     }
  86.  
  87.     // now beep...
  88.     asm {
  89.         mov ax, 0e07h
  90.         xor bx,bx
  91.         int 10h
  92.     }
  93.  
  94.  
  95.     // now get ^Enter.
  96.  
  97. no_key:
  98.     asm {
  99.         xor ah,ah
  100.         int 16h
  101.  
  102.         cmp al, 10
  103.         jne no_key
  104.     }
  105.  
  106.  
  107.     for (i= 0; i< 160; i++)
  108.         sp[i]= old_screen[i];
  109.  
  110.     recursive--;
  111. }
  112.  
  113.  
  114. Msg message; // can be either static or dynamic (not automatic- because
  115.                //     it gets used after the program goes TSR).
  116.  
  117. int main()
  118. {
  119.     if (ISC::is_TSR("EXAMPLE4"))
  120.        return 1; // too much processing in background will kill the forground.
  121.  
  122.     message.activate();
  123.  
  124.     return ISC::TSR();
  125. }