home *** CD-ROM | disk | FTP | other *** search
/ The Best of Mecomp Multimedia 1 / Mecomp-CD.iso / amiga / systempatch / outlinefont / source / outlinefont.c < prev    next >
C/C++ Source or Header  |  1997-03-18  |  4KB  |  137 lines

  1. #include <dos/dos.h>
  2. #include <dos/rdargs.h>
  3. #include <exec/libraries.h>
  4. #include <intuition/intuition.h>
  5. #include <proto/dos.h>
  6. #include <proto/exec.h>
  7. #include <proto/intuition.h>
  8. #include <proto/graphics.h>
  9.  
  10. #ifdef __SASC
  11. int CXBRK(void) { return 0; }   /* Disable SAS/C ctrl-C handling */
  12. int chkabort(void) { return 0; }        /* Really */
  13. #define __USE_SYSBASE
  14. #define REG(x)  register __## x
  15. #else
  16. /* Whatever needed for other compilers. */
  17. #endif
  18. #define LVOText -0x3C
  19.  
  20. /* Much easier to define function pointer variables, and do type-casting this way. */
  21. typedef void __asm (*text)(REG(a1) struct RastPort *, REG(a0) STRPTR, REG(d0) WORD, REG(a6) struct Library *);
  22.  
  23. /* Global function pointer */
  24. text            gfx_Text;
  25.  
  26. static const STRPTR version = "\0$VER: OutlineFont 1.1 (18.03.97)";
  27. static const STRPTR programName = "OutlineFont";
  28. static const STRPTR warning = "Warning: Removing the patch is dangerous!\nRemove anyway?";
  29. static const STRPTR esgadgets =  "Yes|No";
  30. static const STRPTR template = "FRONTPEN/N/A,BACKPEN/N/A,OUTLINEWIDTH/N/A";
  31.  
  32. far LONG fgpen, bgpen, owidth;
  33.  
  34. void __asm __saveds
  35. of_Text(REG(a1) struct RastPort *rp,
  36.         REG(a0) STRPTR str,
  37.         REG(d0) WORD len,
  38.         REG(a6) struct Library *base)
  39. {
  40.     int x,y,w;
  41.     ULONG drmd;
  42.     struct Task *task;
  43.     UBYTE *nstr;
  44.     
  45.     task = FindTask(NULL);
  46.     nstr = task->tc_Node.ln_Name;
  47.     if( nstr[0]=='W' && nstr[1]=='o' && nstr[2]=='r' && nstr[3]=='k' && nstr[4]=='b' && nstr[5]=='e' && nstr[6]=='n' && nstr[7]=='c' && nstr[8]=='h' )
  48.     {
  49.         if( GetAPen(rp)==fgpen && GetBPen(rp)==bgpen && (drmd=GetDrMd(rp))==JAM2 )
  50.         {
  51.             x=rp->cp_x;
  52.             y=rp->cp_y;
  53.         w=owidth;
  54.         
  55.         SetDrMd(rp,JAM1);
  56.         
  57.         SetAPen(rp,bgpen);
  58.         
  59.         Move(rp,x-w,y-w);
  60.         (*gfx_Text)(rp,str,len,base);
  61.         
  62.         Move(rp,x+w,y-w);
  63.         (*gfx_Text)(rp,str,len,base);
  64.         
  65.         Move(rp,x+w,y+w);
  66.         (*gfx_Text)(rp,str,len,base);
  67.         
  68.         Move(rp,x-w,y+w);
  69.         (*gfx_Text)(rp,str,len,base);
  70.         
  71.         SetAPen(rp,fgpen);
  72.         
  73.         Move(rp,x,y);
  74.         (*gfx_Text)(rp,str,len,base);
  75.         
  76.         SetDrMd(rp,drmd);
  77.         }
  78.         else (*gfx_Text)(rp,str,len,base);
  79.     }
  80.     else (*gfx_Text)(rp,str,len,base);
  81. }
  82.  
  83. ULONG main(void)
  84. {
  85.     struct RDArgs *args, *argptr;
  86.     LONG array[3] = { 0, 0, 0, };
  87.     BOOL safe = FALSE;
  88.     struct EasyStruct es;
  89.     
  90.     /* Fill in EasyStruct */
  91.     es.es_StructSize = sizeof(struct EasyStruct);
  92.     es.es_Flags = 0;
  93.     es.es_Title = programName;
  94.     es.es_TextFormat = warning;
  95.     es.es_GadgetFormat = esgadgets;
  96.     
  97.     /* Read program arguments with AmigaDOS ReadArgs() */
  98.     if( args = AllocDosObject(DOS_RDARGS, NULL) )
  99.     {
  100.         if( argptr = ReadArgs(template, array, args) )
  101.         {
  102.             if( array[0] ) fgpen = *(LONG *)array[0];
  103.             if( array[1] ) bgpen = *(LONG *)array[1];
  104.             if( array[2] ) owidth = *(LONG *)array[2];
  105.             /* Indicate that arguments are valid */
  106.             safe = TRUE;
  107.             FreeArgs(argptr);
  108.         }
  109.         else PrintFault(IoErr(), programName);
  110.         FreeDosObject(DOS_RDARGS, args);
  111.     }
  112.     else PrintFault(IoErr(), programName);
  113.     
  114.     /* If arguments are valid, reset the 'safe' variable so it can be used again. */
  115.     if( safe ) safe = FALSE;
  116.     else return RETURN_ERROR;
  117.     
  118.     /* Patch graphics.library/Text() */
  119.     gfx_Text = (text)SetFunction((struct Library *)GfxBase, LVOText, (APTR)of_Text);
  120.     
  121.     while( !safe )
  122.     {
  123.         Wait(SIGBREAKF_CTRL_C);
  124.         /* SetMan and its ilk make un-patching safe. */
  125.         if( FindPort("SetMan") ) safe = TRUE;
  126.         /* Un-patching without a safeguard is bad voodoo, but some users may wish
  127.            to do it anyway.  Ask first.
  128.         */
  129.         else if( EasyRequestArgs(NULL, &es, NULL, NULL) == 1 ) safe = TRUE;
  130.     }
  131.     
  132.     /* Un-patch graphics.library/Text() */
  133.     SetFunction((struct Library *)GfxBase, LVOText, (APTR)gfx_Text);
  134.     
  135.     return RETURN_OK;
  136. }
  137.