home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / MISC / XSRC_117.ZIP / USESASM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-28  |  13.1 KB  |  449 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*   XBBS SOURCE CODE copyright (c) 1990 by M. Kimes                        */
  4. /*   All Rights Reserved                                                    */
  5. /*                                                                          */
  6. /*    For complete details of the licensing restrictions, please refer      */
  7. /*    to the License agreement, which is published in its entirety in       */
  8. /*    the in the file LICENSE.XBS.                                          */
  9. /*                                                                          */
  10. /*    USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE      */
  11. /*    XBBS LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF            */
  12. /*    THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO       */
  13. /*    NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES         */
  14. /*    AT THE ADDRESS LISTED BELOW.  IN NO EVENT SHOULD YOU PROCEED TO USE   */
  15. /*    THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING     */
  16. /*    AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH      */
  17. /*    M. KIMES                                                              */
  18. /*                                                                          */
  19. /*                                                                          */
  20. /* You can contact M. Kimes at the following address:                       */
  21. /*                                                                          */
  22. /* M. Kimes                         1:380/16.0@FidoNet                      */
  23. /* 542 Merrick                      (318)222-3455 data                      */
  24. /* Shreveport, LA  71104                                                    */
  25. /*                                                                          */
  26. /*                                                                          */
  27. /* Please feel free to contact me at any time to share your comments about  */
  28. /* my software and/or licensing policies.                                   */
  29. /*                                                                          */
  30. /*--------------------------------------------------------------------------*/
  31. /*======================================================================*/
  32. /*  XBBS Bulletin Board System.....Functions using inline assembly      */
  33. /*                                                                      */
  34. /*  These functions use TC's inline for speed and ease of maintenance   */
  35. /*======================================================================*/
  36.  
  37. #include "msg.h"
  38. #include "xext.h"
  39.  
  40.  
  41.  
  42. void pascal checkpos (void) {       /*  KEEP STATUS LINE CLEAN */
  43.  
  44.         asm mov ah,3;
  45.         asm mov bh,0;
  46.         asm int 16;
  47.         if (_DH>22) {                /* Reposition cursor to protect */
  48.             if(_DH>23) redraw_stat(NULL);   /* status lines */
  49.             asm mov ah,6;
  50.             asm mov al,1;
  51.             asm mov bh,7;
  52.             asm mov ch,0;
  53.             asm mov cl,0;
  54.             asm mov dh,22;
  55.             asm mov dl,79;
  56.             asm int 16;
  57.             asm mov ah,2;
  58.             asm mov bh,0;
  59.             asm mov dl,0;
  60.             asm mov dh,22;
  61.             asm int 16;
  62.         }
  63. }
  64.  
  65.  
  66.  
  67. void pascal cls (void) {  /* MIMICS BASIC'S CLS FUNCTION LOCAL & REMOTE */
  68.  
  69.   lines=0;
  70.   if (user.scrnclr) printm("\n");
  71.   else {
  72.     if (user.graphics) mprint("\x1b[2J");
  73.     else mprint("\xa");
  74.         asm mov ah,6;
  75.         asm mov al,0;
  76.         asm mov bh,7;
  77.         asm mov ch,0;
  78.         asm mov cl,0;
  79.         asm mov dh,22;
  80.         asm mov dl,79;
  81.         asm int 16;
  82.         asm mov ah,2;
  83.         asm mov bh,0;
  84.         asm mov dh,0;
  85.         asm mov dl,0;
  86.         asm int 16;
  87.   }
  88.   lines=0;
  89. }
  90.  
  91.  
  92.  
  93. char pascal inkey (void) { /* MIMICS BASIC'S INKEY$ FUNCTION */
  94.  
  95.   register word x;
  96.   char arg;
  97.  
  98.   r.h.ah=1;
  99.   int86(22,&r,&r);
  100.   if (!(r.x.flags & 64)) {
  101.         whotyped=0;
  102.         r.h.ah=0;
  103.         int86(22,&r,&r);
  104.         if (!r.h.al) return (specialkey(r.h.ah));
  105.         else if (!disablejump && !leaving) if (*conf.jumpkey[0]) {
  106.             for (x=0;x<10;x++) {
  107.                 if(!*conf.jumpkey[x]) break;
  108.                 if(r.h.al==*conf.jumpkey[x]) if(safe)longjmp(envbuf,(int)(x+1));
  109.             }
  110.         }
  111.         return r.h.al;
  112.   }
  113.   if (baud) {
  114. Again:
  115.       r.x.dx=conf.commport;
  116.       r.h.ah=GETSTAT;
  117.       int86(20,&r,&r);
  118.       if (!(r.h.al & 128)) carrchk();
  119.       if (!(r.h.ah & 1)) return 0;
  120.       _DX=conf.commport;
  121.       _AH=RECVWAIT;
  122.       asm int 20;
  123.       arg = _AL;
  124.       if(!arg) {
  125.           for(x=0;x<1024;x++);
  126.           r.x.dx=conf.commport;
  127.           r.h.ah=GETSTAT;
  128.           int86(20,&r,&r);
  129.           if (!(r.h.al & 128)) carrchk();
  130.           if (!(r.h.ah & 1)) return 0;
  131.           whotyped=1;
  132.           _DX=conf.commport;
  133.           _AH=RECVWAIT;
  134.           asm int 20;
  135.           arg = _AL|128;
  136.       }
  137.       if (arg!='\x1b') {
  138.         if (!disablejump && !leaving) if (*conf.jumpkey[0]) {
  139.             for (x=0;x<10;x++) {
  140.                 if(!*conf.jumpkey[x]) break;
  141.                 if(arg==*conf.jumpkey[x]) if(safe)longjmp(envbuf,(int)(x+1));
  142.             }
  143.         }
  144.         return arg;
  145.       }
  146.       return(specialmod());
  147.   }
  148.   return (0);
  149. }
  150.  
  151.  
  152.  
  153. char pascal lprint (char *text) {
  154.  
  155.     char mmore;
  156.     char *p;
  157.  
  158.  
  159.   while ((p=strstr(text,"\x1b[2J"))!=NULL) {
  160.      memmove(&p[1],&p[4],strlen(&p[4])+1);
  161.      *p='\xc';
  162.   }
  163.   while ((p=strchr(text,'\x7')) && !conf.sysopin) memmove(p,&p[1],strlen(&p[1])+1);
  164.   while (p=strchr(text,'\r')) *p='\n';
  165.   if (!*text) {
  166.     fast=0;
  167.     return 0;
  168.   }
  169.   if (fast) {
  170.     if (!conf.dvideo) directvideo=0;
  171.     textattr(GREEN | BLACK * 16);
  172.     highvideo();
  173.     cputs(text);
  174.     cputs("\r");
  175.     asm mov ah,3;
  176.     asm mov bh,0;
  177.     asm int 16;
  178.     if (_DH>22) checkpos();
  179.     fast=0;
  180.     goto CheckPause;
  181.   }
  182.  
  183.     while(*text) {
  184.         if (*text=='\xc') {           /* Clear screen */
  185.             lines=0;
  186.             asm mov ah,6;
  187.             asm mov al,0;
  188.             asm mov bh,7;
  189.             asm mov ch,0;
  190.             asm mov cl,0;
  191.             asm mov dh,22;
  192.             asm mov dl,79;
  193.             asm int 16;
  194.             asm mov ah,2;
  195.             asm mov bh,0;
  196.             asm mov dh,0;
  197.             asm mov dl,0;
  198.             asm int 16;
  199.             text++;
  200.             continue;
  201.         }
  202.         if (conf.bioswrites) {
  203. Again:
  204.             asm mov ah,14;
  205.             asm mov bh,0;
  206.             _AL=*text;
  207.             asm int 16;
  208.             if (*text=='\n') {
  209.                 *text='\r';
  210.                 goto Again;
  211.             }
  212.         }
  213.         else if (conf.fastANSI) {
  214. Again1:
  215.             _AX=*text;
  216.             asm int 0x29;
  217.             if (*text=='\n') {
  218.                 *text='\r';
  219.                 goto Again1;
  220.             }
  221.         }
  222.         else {
  223. Again2:
  224.             _DL=*text;
  225.             asm mov ah,2;
  226.             asm int 33;
  227.             if (*text=='\n') {
  228.                 *text='\r';
  229.                 goto Again2;
  230.             }
  231.         }
  232.         text++;
  233.         asm mov ah,3;
  234.         asm mov bh,0;
  235.         asm int 16;
  236.         if (_DH>22) checkpos();
  237.      }
  238.  
  239. CheckPause:
  240.  
  241.  if ((!pauser) || (user.more)) {
  242.    lines=0;
  243.    return 0;
  244.  }
  245.  if (pauser == 2) return 0;
  246.  if (++lines>=user.length-1) {
  247.  
  248.         long tempprompt=0;
  249.         long tempindex=0;
  250.  
  251.     pauser=0;
  252.     if(indexhandle!=-1 && prompthandle!=-1) {
  253.        tempprompt=tell(prompthandle);
  254.        tempindex=tell(indexhandle);
  255.     }
  256.     say_prompt(18);
  257.     fossil(FLUSHOUT,0);
  258.     fossil(PURGEIN,0);
  259.     mmore = *genin(1,0,1,1,YESNOM);
  260.     say_prompt(276);
  261.     if(tempprompt) {
  262.         lseek(prompthandle,tempprompt,SEEK_SET);
  263.         lseek(indexhandle,tempindex,SEEK_SET);
  264.     }
  265.     if (mmore == 'N') {
  266.        printm("\n");
  267.        return (1);
  268.     }
  269.     pauser=1;
  270.  }
  271.    return (0);
  272. }
  273.  
  274.  
  275. void pascal redraw_stat (char *tracetext) { /* Prints nice status lines */
  276.  
  277.     char temp[133];
  278.     static char mbl1[80]="";
  279.     static char mbl2[80]="";
  280.     char currx;
  281.     char curry;
  282.     char *a;
  283.     word temptime;
  284.     register word x;
  285.  
  286.     if(conf.trace && !tracetext) return;
  287.     if(conf.promptsay) if(conf.whichstat==3) conf.whichstat=0;
  288.     if (!conf.dvideo) directvideo=0;
  289.     temptime=(word)(timelimit-(getxbbstime()/60));
  290.     asm mov ah,3;           /* Set up to print on 2nd line from bottom */
  291.     asm mov bh,0;           /* In reverse video */
  292.     asm int 16;
  293.     curry=_DH;
  294.     currx=_DL;
  295.     asm mov ah,6;
  296.     asm mov bh,112;
  297.     asm mov al,0;
  298.     asm mov ch,23;
  299.     asm mov cl,0;
  300.     asm mov dh,24;
  301.     asm mov dl,79;
  302.     asm int 16;
  303.     asm mov ah,2;
  304.     asm mov bh,0;
  305.     asm mov dh,23;
  306.     asm mov dl,0;
  307.     asm int 16;
  308.     textbackground(7);
  309.     textcolor(0);
  310.     if(conf.trace) {
  311.         a=strdup(tracetext);
  312.         if(a) {
  313.             x=0;
  314.             while(a[x]) {
  315.                 if(a[x]=='\n') a[x]='|';
  316.                 x++;
  317.             }
  318.             cprintf("%-1.158s",a);
  319.             free(a);
  320.         }
  321.     }
  322.     else if (conf.whichstat==1) {    /* Status line #1 */
  323.         sprintf(temp,"%u Bd\x4%s %s %s \x4TC: %u\x4",baud,user.city,user.state,user.zip,user.times);
  324.         if (conf.sysopin) strcat(temp,"IN\x4");
  325.         else strcat(temp,"OUT\x4");
  326.         if (user.arq) strcat(temp,"ARQ\x4");
  327.         if (user.twit) strcat(temp,"TWT\x4");
  328.         if (!user.ansimenus) strcat(temp,"AMU\x4");
  329.         if (user.gen1) strcat(temp,"G1\x4");
  330.         if (user.gen2) strcat(temp,"G2\x4");
  331.         if (user.gen3) strcat(temp,"G3\x4");
  332.         if (user.commodore) strcat(temp,"SPC\x4");
  333.         if (pages) strcat(temp,"Cht?");
  334.         temp[78]=0;
  335.         cputs(temp);
  336.         sprintf(temp,"%s\x4%s%cAge:%hu\x4#U:%u Uk: %lu #D: %u Dk: %lu",user.phone1,user.phone2,4,age,user.upno,user.upk,user.downno,user.downk);
  337.         temp[78]=0;
  338.         a=temp;
  339.     }
  340.     else if (conf.whichstat==2) {   /* Status line #2 */
  341.  
  342.         int allocleft=0;
  343.         int fileleft=0;
  344.  
  345.         for(x=0;x<MAXFPHANDLES;x++) {
  346.             if(fphandles[x]==-1) fileleft++;
  347.         }
  348.         for(x=0;x<MAXALLOCHANDLES;x++) {
  349.             if(allochandles[x]==NULL) allocleft++;
  350.         }
  351.         sprintf(temp,"Last: %02u/%02u/%04u \x4 %lu bytes free \x4 CT: %hu / %d %d / \x4 [",user.lastdate.da_mon,user.lastdate.da_day,user.lastdate.da_year,coreleft(),user.comptype,fileleft,allocleft);
  352.         for (x=0;x<16;x++) {
  353.             (user.attr2 & (1<<x)) ? strcat(temp,"X") : strcat(temp,"-");
  354.         }
  355.         strcat(temp,"]");
  356.         temp[78]=0;
  357.         cputs(temp);
  358.         sprintf(temp,"XBBS v%s copyright (c) 1990 by M. Kimes \x4 (Compiled: %s  %s)",XVERSION,__DATE__,__TIME__);
  359.         a=temp;
  360.     }
  361.     else if (conf.whichstat==3) { /* Mike Berry Official Recliner Stat */
  362.  
  363.         char tempo[512];
  364.  
  365.         if(!*mbl1 && !*mbl2) {
  366.  
  367.             long tempprompt=0;
  368.             long tempindex=0;
  369.  
  370.             if(indexhandle!=-1 && prompthandle!=-1) {
  371.                 tempprompt=tell(prompthandle);
  372.                 tempindex=tell(indexhandle);
  373.             }
  374.             if(!*mbl1 && !*mbl2) {
  375.                 strncpy(mbl1,say_prompt(400),78);
  376.                 mbl1[78]=0;
  377.                 strncpy(mbl2,say_prompt(401),78);
  378.                 mbl2[78]=0;
  379.                 if(tempprompt>0) {
  380.                     lseek(prompthandle,tempprompt,SEEK_SET);
  381.                     lseek(indexhandle,tempindex,SEEK_SET);
  382.                 }
  383.             }
  384.         }
  385.         strcpy(tempo,cvstr);
  386.         a=convertstring(mbl1);
  387.         a[78]=0;
  388.         cprintf("%-79.79s",a);
  389.         a=convertstring(mbl2);
  390.         a[78]=0;
  391.         strcpy(temp,a);
  392.         a=temp;
  393.         strcpy(cvstr,tempo);
  394.     }
  395.     else {          /* Status line #0 */
  396.         sprintf(temp,"%-36s\x4%-36s\x4#%u",user.name,user.handle,userno);
  397.         temp[78]=0;
  398.         cputs(temp);
  399.         sprintf(temp,"%u/%u/%u/%u/%u/%u/%u/%u/%u/%u\x4%u mins",user.stat[0],user.stat[1],user.stat[2],user.stat[3],user.stat[4],user.stat[5],user.stat[6],user.stat[7],user.stat[8],user.stat[9],temptime);
  400.         a=fidodate();
  401.         a[16]=0;
  402.         a[9]=0;
  403.         sprintf(&temp[strlen(temp)-1],"\x4%s %s",a,&a[11]);
  404.         temp[78]=0;
  405.         a=temp;
  406.     }
  407.     if(!conf.trace) {
  408.         asm mov ah,2;   /* Set up to print on last line */
  409.         asm mov bh,0;
  410.         asm mov dh,24;
  411.         asm mov dl,0;
  412.         asm int 16;
  413.         cprintf("%-79.79s",a);
  414.     }
  415.     _DL=currx;
  416.     if (curry<23) _DH=curry;
  417.     else _DL=22;
  418.     asm mov ah,2;
  419.     asm mov bh,0;
  420.     asm int 16;
  421. }
  422.  
  423.  
  424. void pascal blank_stat (void) {
  425.  
  426.   char currx;
  427.   char curry;
  428.  
  429.     asm mov ah,3;       /* Blank bottom two lines of screen */
  430.     asm mov bh,0;
  431.     asm int 16;
  432.     curry=_DH;
  433.     currx=_DL;
  434.     asm mov ah,6;
  435.     asm mov bh,7;
  436.     asm mov al,0;
  437.     asm mov ch,23;
  438.     asm mov cl,0;
  439.     asm mov dh,24;
  440.     asm mov dl,79;
  441.     asm int 16;
  442.     _DH=curry;
  443.     _DL=currx;
  444.     asm mov ah,2;
  445.     asm mov bh,0;
  446.     asm int 16;
  447. }
  448.  
  449.