home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / Triton / Developer / LibSource / Boopsi.c next >
C/C++ Source or Header  |  1998-02-03  |  4KB  |  124 lines

  1. /*
  2.  *  OpenTriton -- A free release of the triton.library source code
  3.  *  Copyright (C) 1993-1998  Stefan Zeiger
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2 of the License, or
  8.  *  (at your option) any later version.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with this program; if not, write to the Free Software
  17.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  */
  20.  
  21.  
  22. #include "triton_lib.h"
  23.  
  24.  
  25. struct IClass *TRIM_trLogo;
  26. ULONG    __regargs TRIM_trLogo_DrawBoopsiImage(struct Image *Image, struct impDraw *DrawMsg);
  27. ULONG    __asm TRIM_trLogo_DispatchBoopsiImage(register __a0 struct IClass *Class, register __a2 Object *Object, register __a1 Msg ObjMsg);
  28.  
  29.  
  30. #define ARROWLENGTH 4
  31. #define LANCELENGTH 2
  32. #define CURVELENGTH 15
  33.  
  34.  
  35. void __stdargs TR_ScaledPolyDraw(struct RastPort *rport, UWORD len, WORD *array, ULONG orgwid, ULONG orghei, ULONG newwid, ULONG newhei, ULONG left, ULONG top)
  36. {
  37.   UWORD i;
  38.  
  39.   for(i=0;i<len;i++)
  40.   {
  41.     array[i*2]=((array[i*2]*newwid)/orgwid)+left;
  42.     array[(i*2)+1]=((array[(i*2)+1]*newhei)/orghei)+top;
  43.   }
  44.   Move(rport, array[0], array[1]);
  45.   PolyDraw(rport, len-1, &array[2]);
  46. }
  47.  
  48.  
  49. ULONG    __regargs TRIM_trLogo_DrawBoopsiImage(struct Image *Image, struct impDraw *DrawMsg)
  50. {
  51.   struct    RastPort        * RPort           = DrawMsg->imp_RPort;
  52.   UWORD                     BackColor       = DrawMsg->imp_DrInfo->dri_Pens[BACKGROUNDPEN],
  53.                             TextColor       = DrawMsg->imp_DrInfo->dri_Pens[TEXTPEN];
  54.   WORD                      left            = Image->LeftEdge + DrawMsg->imp_Offset.X,
  55.                             top             = Image->TopEdge + DrawMsg->imp_Offset.Y,
  56.                             width           = Image->Width,
  57.                             height          = Image->Height,
  58.                             Arrow1Array[ARROWLENGTH*2] = {22,6, 30,2, 26,10, 22,6},
  59.                             Arrow2Array[ARROWLENGTH*2] = {34,18, 42,14, 38,22, 34,18},
  60.                             Arrow3Array[ARROWLENGTH*2] = {46,30, 54,26, 50,34, 46,30},
  61.                             LanceArray[LANCELENGTH*2] = {2,54, 36,20},
  62.                             CurveArray[CURVELENGTH*2] = {24,8, 22,10, 20,14, 19,18, 18,22, 19,26, 20,30, 22,34, 26,36, 30,37, 34,38, 38,37, 42,36, 46,34, 48,32};
  63.  
  64.   // Background
  65.   SetAfPt(RPort, NULL, -1);
  66.   SetAPen(RPort, BackColor);
  67.   SetDrMd(RPort, JAM1);
  68.   RectFill(RPort, left, top, left+width-1, top+height-1);
  69.  
  70.   // Adjust size (->square)
  71.   if(width>height)
  72.   {
  73.     left+=((width-height)/2);
  74.     width=height;
  75.   }
  76.   else if(width<height)
  77.   {
  78.     top+=((height-width)/2);
  79.     height=width;
  80.   }
  81.  
  82.   // Logo
  83.   SetAPen(RPort, TextColor);
  84.   TR_ScaledPolyDraw(RPort,ARROWLENGTH,Arrow1Array,56,56,width,height,left,top);
  85.   TR_ScaledPolyDraw(RPort,ARROWLENGTH,Arrow2Array,56,56,width,height,left,top);
  86.   TR_ScaledPolyDraw(RPort,ARROWLENGTH,Arrow3Array,56,56,width,height,left,top);
  87.   TR_ScaledPolyDraw(RPort,LANCELENGTH,LanceArray,56,56,width,height,left,top);
  88.   TR_ScaledPolyDraw(RPort,CURVELENGTH,CurveArray,56,56,width,height,left,top);
  89.  
  90.   return(TRUE);
  91. }
  92.  
  93.  
  94. ULONG    __asm TRIM_trLogo_DispatchBoopsiImage(register __a0 struct IClass *Class, register __a2 Object *Object, register __a1 Msg ObjMsg)
  95. {
  96.   ULONG retval;
  97.   struct Hook *hook=(struct Hook *)Class;
  98.   ULONG tempa4=__builtin_getreg(12);
  99.   __builtin_putreg(12,(ULONG)hook->h_Data);
  100.  
  101.   if(ObjMsg->MethodID==IM_DRAW) retval=TRIM_trLogo_DrawBoopsiImage((struct Image *)Object, (struct impDraw *)ObjMsg);
  102.   else retval=DoSuperMethodA(Class, Object, ObjMsg);
  103.  
  104.   __builtin_putreg(12,tempa4);
  105.   return retval;
  106. }
  107.  
  108.  
  109. BOOL __regargs TRIM_trLogo_Init(VOID)
  110. {
  111.   if((TRIM_trLogo = MakeClass(NULL, IMAGECLASS, NULL, 0, 0)))
  112.   {
  113.     TRIM_trLogo->cl_Dispatcher.h_Entry = (HOOKFUNC)TRIM_trLogo_DispatchBoopsiImage;
  114.     TRIM_trLogo->cl_Dispatcher.h_Data  = (void *) __builtin_getreg(12);
  115.   }
  116.   return (BOOL)TRIM_trLogo;
  117. }
  118.  
  119.  
  120. VOID __regargs TRIM_trLogo_Free(VOID)
  121. {
  122.   if(TRIM_trLogo) FreeClass(TRIM_trLogo);
  123. }
  124.