home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / utilities / outlinefont / source / outlinefont.c next >
C/C++ Source or Header  |  2000-01-30  |  3KB  |  109 lines

  1. #include <dos/dos.h>
  2. #include <dos/rdargs.h>
  3. #include <exec/libraries.h>
  4. #include <proto/dos.h>
  5. #include <proto/exec.h>
  6. #include <proto/graphics.h>
  7.  
  8. #define __USE_SYSBASE
  9. #define REG(x)  register __## x
  10. #define LVOText -0x3C
  11.  
  12. /* Much easier to define function pointer variables, and do type-casting this way. */
  13. typedef void __asm (*text)(REG(a1) struct RastPort *, REG(a0) STRPTR, REG(d0) WORD, REG(a6) struct Library *);
  14.  
  15. /* Global function pointer */
  16. text            gfx_Text;
  17.  
  18. static const STRPTR version = "\0$VER: OutlineFont 1.3 "__AMIGADATE__" Nyberg,Gapen,Rotvel";
  19. static const STRPTR programName = "OutlineFont";
  20. static const STRPTR template = "FRONTPEN/N/A,BACKPEN/N/A,OUTLINEWIDTH/N/A,SHADOW/S";
  21.  
  22. __far LONG fgpen, bgpen, owidth;
  23. __far BOOL shadow;
  24.  
  25. void __asm __saveds
  26. of_Text(REG(a1) struct RastPort *rp,
  27.         REG(a0) STRPTR str,
  28.         REG(d0) WORD len,
  29.         REG(a6) struct Library *base)
  30. {
  31.     int x,y;
  32.     struct Task *task;
  33.     UBYTE *nstr;
  34.     
  35.     task = FindTask(NULL);
  36.     nstr = task->tc_Node.ln_Name;
  37.     if( nstr[0]=='W' && nstr[3]=='k' && nstr[4]=='b' && nstr[8]=='h' )
  38.     {
  39.         if( GetAPen(rp)==fgpen && GetDrMd(rp)==JAM1 )
  40.         {
  41.             x=rp->cp_x;
  42.             y=rp->cp_y;
  43.         
  44.             SetAPen(rp,bgpen);
  45.  
  46.             Move(rp,x+owidth,y+owidth);
  47.             (*gfx_Text)(rp,str,len,base);
  48.  
  49.             if (shadow == FALSE)
  50.             {
  51.                 Move(rp,x-owidth,y-owidth);
  52.                 (*gfx_Text)(rp,str,len,base);
  53.         
  54.                 Move(rp,x+owidth,y-owidth);
  55.                 (*gfx_Text)(rp,str,len,base);
  56.         
  57.                 Move(rp,x-owidth,y+owidth);
  58.                 (*gfx_Text)(rp,str,len,base);
  59.             }
  60.             SetAPen(rp,fgpen);
  61.         
  62.             Move(rp,x,y);
  63.             (*gfx_Text)(rp,str,len,base);
  64.         }
  65.         else (*gfx_Text)(rp,str,len,base);
  66.     }
  67.     else (*gfx_Text)(rp,str,len,base);
  68. }
  69.  
  70. ULONG main(void)
  71. {
  72.     struct RDArgs *args, *argptr;
  73.     LONG opts[4] = { 0, 0, 0, 0, };
  74.     
  75.     /* Read program arguments with AmigaDOS ReadArgs() */
  76.     if( args = AllocDosObject(DOS_RDARGS, NULL) )
  77.     {
  78.         if( argptr = ReadArgs(template, opts, args) )
  79.         {
  80.             if (opts[0]) fgpen  = *((LONG *) opts[0]);
  81.             if (opts[1]) bgpen  = *((LONG *) opts[1]);
  82.             if (opts[2]) owidth = *((LONG *) opts[2]);
  83.             if (opts[3]) shadow = opts[3]; 
  84.             FreeArgs(argptr);
  85.         }
  86.         else 
  87.         {
  88.             PrintFault(IoErr(), programName);
  89.             return RETURN_ERROR;
  90.         }
  91.         FreeDosObject(DOS_RDARGS, args);
  92.  
  93.         /* Patch graphics.library/Text() */
  94.         gfx_Text = (text)SetFunction((struct Library *)GfxBase, LVOText, (APTR)of_Text);
  95.     
  96.         /* Wait for ctrl-c */
  97.         Wait(SIGBREAKF_CTRL_C);
  98.  
  99.         /* Unpatch */
  100.         SetFunction((struct Library *)GfxBase, LVOText, (APTR)gfx_Text);
  101.     }
  102.     else 
  103.     {
  104.         PrintFault(IoErr(), programName);
  105.         return RETURN_ERROR;
  106.     }
  107.     return RETURN_OK;
  108. }
  109.