home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / tc-book.zip / POPUP.C < prev    next >
Text File  |  1987-08-20  |  2KB  |  98 lines

  1. /* ---------- popup.c ---------- */
  2.  
  3. #include <dos.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <dir.h>
  7. #include "twindow.h"
  8.  
  9. static union REGS rg;
  10.  
  11. unsigned sizeprogram = 48000/16;
  12. unsigned scancode = 52;
  13. unsigned keymask = 8;
  14. char signature [] = "POPUP";
  15.  
  16. char notefile[64];
  17.  
  18. /* -------- local prototypes ---------- */
  19. int resident(char *, void interrupt (*)());
  20. void resinit(void);
  21. void terminate(void);
  22. void restart(void);
  23. void wait(void);
  24. void resident_psp(void);
  25. void interrupted_psp(void);
  26. void exec(void);
  27.  
  28. main(argc, argv)
  29. char *argv[];
  30. {
  31.     void interrupt ifunc();
  32.     int ivec;
  33.  
  34.     if ((ivec = resident(signature, ifunc)) != 0)    {
  35.         /* ----- TSR is resident ------- */
  36.         if (argc > 1)    {
  37.             /* ---- there is a command line parameter --- */
  38.             rg.x.ax = 0;
  39.             if (strcmp(argv[1], "quit") == 0)
  40.                 rg.x.ax = 1;
  41.             else if (strcmp(argv[1], "restart") == 0)
  42.                 rg.x.ax = 2;
  43.             else if (strcmp(argv[1], "wait") == 0)
  44.                 rg.x.ax = 3;
  45.             if (rg.x.ax)    {
  46.                 /* -- call the communications interrupt -- */
  47.                 int86(ivec, &rg, &rg);
  48.                 return;
  49.             }
  50.         }
  51.         printf("\nPopup is already resident");
  52.     }
  53.     else    {
  54.         /* ------ initial load of TSR program ------ */
  55.         load_help("tcprogs.hlp");
  56.         getcwd(notefile, 64);
  57.         if (*(notefile+strlen(notefile)-1) != '\\')
  58.             strcat(notefile, "\\");
  59.         strcat(notefile, "note.pad");
  60.         printf("\nResident popup is loaded");
  61.         /* ---- T&SR --------- */
  62.         resinit();
  63.     }
  64. }
  65.  
  66. /* -------- TSR communications ISR ---------- */
  67. void interrupt ifunc(bp,di,si,ds,es,dx,cx,bx,ax)
  68. {
  69.     if (ax == 1)            /* "quit" */
  70.         terminate();
  71.     else if (ax == 2)        /* "restart" */
  72.         restart();
  73.     else if (ax == 3)        /* "wait" */
  74.         wait();
  75. }
  76. /*page*/
  77. /* -------- close files when terminating ---------- */
  78. closefiles()
  79. {
  80.     extern FILE *helpfp;
  81.  
  82.     resident_psp();        /* switch to TSR PID */
  83.     if (helpfp)
  84.         fclose(helpfp);    /* close the help file */
  85.     interrupted_psp();    /* switch to int'd PID */
  86. }
  87.  
  88. /* -------- the popup TSR utility function --------- */
  89. popup()
  90. {
  91.     int x, y;
  92.  
  93.     curr_cursor(&x, &y);
  94.     exec();                    /* call the TSR C program here */
  95.     cursor(x, y);
  96. }
  97.  
  98.