home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / DC-POS24.LZX / pOS / pOS_RKRM.lzx / pOS_RKRM / SGOS / SGOSdemo1.c
Encoding:
C/C++ Source or Header  |  1997-03-18  |  16.4 KB  |  613 lines

  1. #ifndef __INC_POS_PCOM_EXT_SGOS1_C
  2. #define __INC_POS_PCOM_EXT_SGOS1_C
  3. /*******************************************************************
  4.  $CRT 05 Dec 1996 : hp
  5.  
  6.  $AUT Holger Burkarth
  7.  $DAT >>SGOSdemo1.c<<   29 Jan 1997    14:25:42 - (C) ProDAD
  8. *******************************************************************/
  9.  
  10.  
  11. //##ex mcpp:cppc -gs -o pos:pos/Ex/SGOSdemo1 p:pLib/StartCode.o p:/pOS_RKRM/SGOS/SGOSdemo1.c p:pLib/StdIO.o -l pOSStub -l pOS
  12.  
  13.  
  14. /*******************************************************************
  15.  
  16.   ACHTUNG: PBall muss sich im Games-Verzeichnis befinden
  17.  
  18. *******************************************************************/
  19.  
  20. /***********************************************************
  21.   pOS programing example - Copyright (C) 1995-97 proDAD
  22.  
  23.   This code was written as an easy to understand example,
  24.   how to program pOS features. It is provided 'as-is',
  25.   without any express or implied warranty.
  26.  
  27.   Permission is hereby granted to use, copy and modify
  28.   this source code for any purpose, without fee, subject
  29.   to the following conditions:
  30.  
  31.     (1) This notice may not be removed or altered from any
  32.         source distribution.
  33.  
  34.     (2) Altered source versions must be plainly marked as
  35.         such, and must not be misrepresented as being
  36.         the original source code.
  37.  
  38.     (3) If only executable code is distributed, then the
  39.         accompanying documentation have to state that
  40.         "this software is based in part on examples of
  41.         the pOS developer packet".
  42.  
  43.     (4) Permission for use of this code is granted only
  44.         if the user accepts full responsibility for any
  45.         undesirable consequences. proDAD accept NO LIABILITY
  46.         for damages of any kind.
  47.  
  48.   ©proDAD
  49. ***********************************************************/
  50.  
  51. #include <p:pExec/Types.h>
  52. #include <p:Device/Timer.h>
  53. #include <p:pDOS/ArgTags.h>
  54. #include <p:pDOS/DosSig.h>
  55. #include <p:pDOS/DosErrors.h>
  56. #include <p:pScreen/ScrTags.h>
  57. #include <p:pScreen/Window.h>
  58. #include <p:pScreen/Screen.h>
  59. #include <p:pIntui/IntuMsg.h>
  60. #include <p:pIntui/Tags.h>
  61. #include <p:pGFX/GfxMap.h>
  62. #include <p:pGFX/GfxEx.h>
  63. #include <p:pGFX/Color.h>
  64. #include <p:pGFX/GfxTags.h>
  65. #include <p:pGFX/Text.h>
  66. #include <p:pGFX/StdCMap.h>
  67. #include <p:pGFX/StdGMap.h>
  68. #include <p:pDtType/DtBase.h>
  69. #include <p:pDtType/Picture.h>
  70. #include <p:pDtType/DtTags.h>
  71. #include <p:SGOS/SGOS.h>
  72. #include <p:SGOS/SGOSTags.h>
  73. #include <p:proto/pLibExt.h>
  74. #include <p:proto/pExec2.h>
  75. #include <p:proto/pTimer2.h>
  76. #include <p:proto/pIntui2.h>
  77. #include <p:proto/pUtil2.h>
  78. #include <p:proto/pGFX2.h>
  79. #include <p:proto/pLayer2.h>
  80. #include <p:proto/pDtType2.h>
  81. #include <p:proto/pDOS2.h>
  82. #include <p:proto/SGOS2.h>
  83.  
  84.  
  85. #ifdef __cplusplus
  86. extern "C" {
  87. #endif
  88.   #include <string.h>
  89.   #include <stdio.h>
  90. #ifdef __cplusplus
  91. }
  92. #endif
  93.  
  94. #ifndef ABS
  95. #define ABS(a) ((a)<0 ? -(a) : (a))
  96. #endif
  97.  
  98.  
  99. struct MasterData
  100. {
  101.   SLONG        NewX, NewY;
  102.   SBYTE        AnimDelta;
  103.   UBYTE        AnimDelay;
  104.  
  105.   pOS_TimeVal  LastColl;
  106. };
  107.  
  108. struct SlaveData
  109. {
  110.   pOS_SGObject  *Master;
  111. };
  112.  
  113.  
  114.  
  115. #define DEMOOBJANIMDELAY 3
  116.  
  117. extern struct pOS_DosBase *gb_DosBase;
  118.  
  119. struct pOS_IntuiDevice  *gb_IntuiBase;
  120. struct pOS_GfxBase      *gb_GfxBase;
  121. struct pOS_DataTypeBase *gb_DtTypeBase;
  122. struct pOS_TimerDevice  *gb_TimerBase;
  123. struct pOS_Library      *gb_SGOSBase;
  124.  
  125. const CHAR *HelpText=
  126. ""
  127. ;
  128.  
  129. const CHAR *PrgHeader=
  130. "Simple SGOS demo";
  131.  
  132. const CHAR *PrgVerText=
  133. "$VER: SGOSdemo1 1.0 ("__DATE2__") (Copyright 1996-97 by proDAD) (Created by Holger Papajewski)";
  134.  
  135.  
  136. struct DemoObj;
  137.  
  138. pOS_GfxMap  *CreateSuperMap( pOS_Screen* );
  139. pOS_SGOInfo *MakeGfx( pOS_Window* );
  140.  
  141. BOOL HandleWinMsg(pOS_Window*,pOS_SGOInfo*);
  142.  
  143. VOID BorColl_func(_R_A0 pOS_SGObject*,_R_A1 pOS_IBox*,UWORD);
  144. VOID MasterMove_func(_R_A0 pOS_SGObject*);
  145. VOID SlaveMove_func(_R_A0 pOS_SGObject*);
  146.  
  147. ULONG DemoAnim_func(_R_A0 pOS_SGObject*);
  148.  
  149. VOID MuenzeBorColl_func(_R_A0 pOS_SGObject*,_R_A1 pOS_IBox*,UWORD);
  150. VOID MuenzeMove_func(_R_A0 pOS_SGObject*);
  151.  
  152. VOID MasterSlaveColl_func(_R_A0 pOS_SGObject*,_R_A1 pOS_SGObject*);
  153.  
  154. #ifdef __cplusplus
  155. extern "C"
  156. #endif
  157. /*----------------------------------
  158. -----------------------------------*/
  159. VOID main( void )
  160. {
  161.   gb_IntuiBase  =(struct pOS_IntuiDevice*)pOS_OpenLibrary("pintui.library",0);
  162.   gb_GfxBase    =(struct pOS_GfxBase*)pOS_OpenLibrary("pgraphics.library",0);
  163.   gb_DtTypeBase =(struct pOS_DataTypeBase*)pOS_OpenLibrary("pDtType.library",0);
  164.   gb_TimerBase  =(struct pOS_TimerDevice*)pOS_OpenLibrary("ptimer.library",0L);
  165.  
  166.   if(gb_SGOSBase=pOS_OpenLibrary("sgos.library",0)) {
  167.  
  168.     pOS_DosArgs  *Args;
  169.     UWORD Err=0;
  170.     ULONG Ops[1]={0};
  171.  
  172.     Args=pOS_ReadDosArgs("",Ops,sizeof(Ops)/sizeof(ULONG),
  173.       ARGTAG_PrgHeaderText, (ULONG)PrgHeader,    /* kurze Programm-Beschreibung */
  174.       ARGTAG_HelpText,      (ULONG)HelpText,     /* Help-Texte */
  175.       ARGTAG_PrgVerText,    (ULONG)PrgVerText,   /* VER-String */
  176.       TAG_END);
  177.  
  178.     if(Args) {
  179.       pOS_Screen   *Scr;
  180.  
  181.       if( Scr = pOS_LockPubScreen(NULL)) {
  182.         pOS_GfxMap *SuperMap;
  183.  
  184.         /* GfxMap für SuperBitMap-Window erzeugen */
  185.         if( SuperMap = CreateSuperMap( Scr )) {
  186.           pOS_Window *Win;
  187.  
  188.           Win=pOS_OpenWindow(
  189.             SCRTAG_Title,   (ULONG)"SGOSdemo1",
  190.             SCRTAG_Screen,  (ULONG)Scr,
  191.             SCRTAG_Flags,   WINFLGF_DepthGadget | WINFLGF_GimmeZeroZero |
  192.                             WINFLGF_Activate | WINFLGF_CloseGadget |
  193.                             WINFLGF_Dragbar,
  194.             SCRTAG_IDCMP,   IDCMP_CloseWindow | IDCMP_VanillaKey |
  195.                             IDCMP_MouseMove | IDCMP_RefreshWindow,
  196.             SCRTAG_InnerWidth,  SuperMap->gm_Width,
  197.             SCRTAG_InnerHeight, SuperMap->gm_Height,
  198.             SCRTAG_UnderMouse,  TRUE,
  199.             SCRTAG_SuperGfxMap, (ULONG)SuperMap,
  200.             TAG_DONE);
  201.  
  202.           if(Win) {
  203.             pOS_SGOInfo *Info;
  204.  
  205.             /* SGOS-System erzeugen */
  206.             Info = MakeGfx( Win );
  207.  
  208.             if( Info ) {
  209.               BOOL  Quit=FALSE;
  210.               ULONG sig;
  211.               ULONG WinSig=1L<<Win->win_UserPort->mp_SigBit;
  212.  
  213.               /* Background-Zeichenprocess starten */
  214.               pOS_StartSGOS( Info );
  215.               while( !Quit ) {
  216.                 sig=pOS_WaitSignal(WinSig|DOSSIGF_CTRL_C);
  217.  
  218.                 if( sig & DOSSIGF_CTRL_C )
  219.                   Quit=TRUE;
  220.  
  221.                 if( sig & WinSig )
  222.                   Quit=HandleWinMsg( Win, Info );
  223.  
  224.               }
  225.  
  226.               /* komplettes SGOS löschen */
  227.               /* beendet auch Backgroundprocess & löscht alle Objekte */
  228.               pOS_DeleteSGOInfo( Info );
  229.             }
  230.             else printf("Cannot Create SGOS\n");
  231.  
  232.             pOS_CloseWindow( Win );
  233.           }
  234.           else printf("Cannot Open Window\n");
  235.  
  236.           pOS_FreeGfxMap( SuperMap );
  237.         }
  238.         else printf("Cannot Allocate SuperGfxMap.\n");
  239.  
  240.         pOS_UnlockPubScreen( Scr );
  241.       }
  242.       else printf("Cannot Lock Workbench\n");
  243.  
  244.       pOS_DeleteDosArgs( Args );
  245.     }
  246.  
  247.     pOS_CloseLibrary(gb_SGOSBase);
  248.   }
  249.  
  250.   pOS_CloseLibrary((pOS_Library*)gb_TimerBase);
  251.   pOS_CloseLibrary((pOS_Library*)gb_DtTypeBase);
  252.   pOS_CloseLibrary((pOS_Library*)gb_IntuiBase);
  253.   pOS_CloseLibrary((pOS_Library*)gb_GfxBase);
  254. }
  255.  
  256.  
  257. /*----------------------------------
  258. -----------------------------------*/
  259. BOOL HandleWinMsg(pOS_Window *win,pOS_SGOInfo *info)
  260. {
  261.   BOOL ret=FALSE;
  262.   pOS_IntuiMessage *Msg;
  263.   pOS_SGObject *obj=(pOS_SGObject*)info->sgoi_UserData[0];
  264.   MasterData   *MD=(MasterData*)obj->sgo_UserData[0];
  265.  
  266.   while( Msg=(pOS_IntuiMessage*)pOS_GetMsg(win->win_UserPort)) {
  267.  
  268.     switch(Msg->im_Class) {
  269. // -----
  270.       case IDCMP_CloseWindow:
  271.         ret=TRUE;
  272.         break;
  273. // -----
  274.       case IDCMP_RefreshWindow:
  275.         pOS_LockSGOInfo( info );
  276.         pOS_BeginRefresh( win, NULL );
  277.         pOS_EndRefresh( win, TRUE );
  278.         pOS_DrawSGOS( info, SGOSDM_Refresh );
  279.         pOS_UnlockSGOInfo( info );
  280.         break;
  281. // -----
  282.       case IDCMP_MouseMove:
  283.         /* neue Koordinaten im privaten Teil vermerken */
  284.         /* nie außerhalb der Callback-Funktionen direkt in die */
  285.         /* SGObject-Struktur schreiben */
  286.         {
  287.           MD->NewX = Msg->im_MouseX-(obj->sgo_Width>>1);
  288.           MD->NewY = Msg->im_MouseY-(obj->sgo_Height>>1);
  289.         }
  290.         break;
  291. // -----
  292.       default:
  293.         break;
  294.     }
  295.  
  296.     if(!pOS_SysIMessage(Msg))
  297.       pOS_ReplyMsg((pOS_Message*)Msg);
  298.   }
  299.  
  300.   return(ret);
  301. }
  302.  
  303.  
  304.  
  305. /*----------------------------------
  306. SuperGfxMap erzeugen
  307. -----------------------------------*/
  308. pOS_GfxMap *CreateSuperMap( pOS_Screen *scr )
  309. {
  310.   pOS_StdChunky8GfxMap *GfxMap;
  311.   pOS_GfxMap *TempMap=NULL;
  312.   pOS_StdRLColorMap    *ColorMap;
  313.  
  314.   /* Standard-ColorMap erzeugen - darf direkt beschrieben werden */
  315.   ColorMap=(pOS_StdRLColorMap*)pOS_AllocColorMap(NULL,
  316.            GFXTAG_ColorType,   COLMAPTYP_StdRLut,
  317.            GFXTAG_Colors,      256,
  318.            TAG_END);
  319.  
  320.   /* Standard-ChunkyGfxMap erzeugen - darf direkt beschrieben werden */
  321.   GfxMap=(pOS_StdChunky8GfxMap*)pOS_AllocGfxMap(NULL,
  322.            GFXTAG_Width,       200,
  323.            GFXTAG_Height,      200,
  324.            GFXTAG_GfxType,     GFXMAPTYP_StdChunky8,
  325.            GFXTAG_CrtGfxMapEx, TRUE,
  326.            GFXTAG_ColorMap,    (ULONG)ColorMap,
  327.            TAG_END);
  328.  
  329.   /* Friend-GfxMap erzeugen */
  330.   TempMap=pOS_AllocGfxMap(scr->scr_RastPort->rp_Base,
  331.            GFXTAG_Width,       200,
  332.            GFXTAG_Height,      200,
  333.            GFXTAG_CrtGfxMapEx, TRUE,
  334.            GFXTAG_FriendGfxMap,scr->scr_RastPort->rp_GfxMap,
  335.            TAG_DONE);
  336.  
  337.   if(ColorMap && GfxMap && TempMap) {
  338.     ULONG x;
  339.  
  340.     /* Farbpalette erzeugen */
  341.     for(x=0; x<256; ++x) {
  342.       ColorMap->rlcm_Colors[x].rc_U.rc_E.rcue_R=0;
  343.       ColorMap->rlcm_Colors[x].rc_U.rc_E.rcue_G=x;
  344.       ColorMap->rlcm_Colors[x].rc_U.rc_E.rcue_B=255-x;
  345.     }
  346.  
  347.     /* ChunkyGfxMap beschreiben */
  348.     for(x=0; x<200; ++x)
  349.       GfxMap->ckgm_Chunky[x]=x+25;
  350.     for(x=1; x<200; ++x)
  351.       memcpy(&GfxMap->ckgm_Chunky[x*200],GfxMap->ckgm_Chunky,200);
  352.  
  353.     /* StdChunkyMap in die Friend-GfxMap konvertieren */
  354.     pOS_WriteStdGfxMap(&GfxMap->ckgm_Gfx,0,0,TempMap,0,0,200,200,0,NULL);
  355.   }
  356.   else {
  357.     if(TempMap) pOS_FreeGfxMap(TempMap);
  358.     TempMap=NULL;
  359.   }
  360.  
  361.   if(GfxMap)  pOS_FreeGfxMap(&GfxMap->ckgm_Gfx);
  362.   if(ColorMap) pOS_FreeColorMap(&ColorMap->rlcm_CM);
  363.  
  364.   return(TempMap);
  365. }
  366.  
  367.  
  368.  
  369. /*----------------------------------
  370. SGOS-System erzeugen
  371. -----------------------------------*/
  372. pOS_SGOInfo *MakeGfx( pOS_Window *win )
  373. {
  374.   static MasterData MD;
  375.   static SlaveData  SD;
  376.  
  377.   memset(&MD,0,sizeof(MasterData));
  378.   memset(&SD,0,sizeof(SlaveData));
  379.  
  380.   pOS_SGOInfo  *info=NULL;
  381.   pOS_SGObject *m, *s;
  382.   pOS_SGObject *g;
  383.  
  384.   /* initialisiert SGOInfo-Struktur */
  385.   info = pOS_CreateSGOInfo( win,
  386.     SGOSTAG_CollHandler0, (ULONG)MasterSlaveColl_func,
  387.     SGOSTAG_FramesPerSec, 25,
  388.     TAG_DONE );
  389.  
  390.   if( info ) {
  391.     /* Master-Object erzeugen */
  392.     /* Gfx-Files werden automatisch mit der DtType.library geladen */
  393.     if( m = pOS_CreateSGObject( info,
  394. // *****      SGOSTAG_SGObjSize,        sizeof(DemoObj),
  395.       SGOSTAG_GfxFile,          (ULONG)"Sys:Games/Gfx/Ball",
  396.       SGOSTAG_MaskFile,         (ULONG)"Sys:Games/Gfx/Ball_Mask",
  397.       SGOSTAG_InitialX,         40,
  398.       SGOSTAG_InitialY,         40,
  399.       SGOSTAG_MoveFunc,         (ULONG)MasterMove_func,
  400.       SGOSTAG_BorCollisionFunc, (ULONG)BorColl_func,
  401.       SGOSTAG_AnimObjFunc,      (ULONG)DemoAnim_func,
  402.       SGOSTAG_HitID,            0x00,
  403.       SGOSTAG_HitMask,          0x01,
  404.       TAG_DONE )) {
  405.  
  406.       /* Werte für eigene Anim-Funktion initialisieren */
  407. // *****      obj1->do_AnimDelta=1;
  408. // *****      obj1->do_AnimDelay=DEMOOBJANIMDELAY;
  409.  
  410.       m->sgo_UserData[0] = (ULONG)&MD;
  411.       MD.AnimDelta = 1;
  412.       MD.AnimDelay = DEMOOBJANIMDELAY;
  413.  
  414.       /* obj1 clonen */
  415.       /* eigene MoveFunktion setzten */
  416.       /* AnimFunktion wird auf Default zurückgesetzt */
  417.       if( s = pOS_CloneSGObject( m,
  418.         SGOSTAG_InitialX,         80,
  419.         SGOSTAG_InitialY,         80,
  420.         SGOSTAG_MoveFunc,         (ULONG)SlaveMove_func,
  421.         SGOSTAG_BorCollisionFunc, (ULONG)BorColl_func,
  422.         SGOSTAG_AnimObjFunc,      NULL,
  423.         SGOSTAG_HitID,            0x01,
  424.         SGOSTAG_HitMask,          0x00,
  425.         TAG_DONE )) {
  426.  
  427.         s->sgo_UserData[0] = (ULONG)&SD;
  428.         SD.Master = m;
  429.         info->sgoi_UserData[0] = (ULONG)m;
  430.  
  431.         if( g = pOS_CreateSGObject( info,
  432.           SGOSTAG_GfxFile,          (ULONG)"Sys:Games/Gfx/GMuenze",
  433.           SGOSTAG_MaskFile,         (ULONG)"Sys:Games/Gfx/Muenze_Mask",
  434.           SGOSTAG_MoveFunc,         (ULONG)MuenzeMove_func,
  435.           SGOSTAG_BorCollisionFunc, (ULONG)MuenzeBorColl_func,
  436.           SGOSTAG_Inactive,         TRUE,
  437.           TAG_DONE )) {
  438.  
  439.           /* Muenze im Master merken */
  440.           m->sgo_UserData[1] = (ULONG)g;
  441.         }
  442.         else {
  443.           printf("Cannot Clone Ball Object\n");
  444.           pOS_DeleteSGOInfo(info);
  445.           info=NULL;
  446.         }
  447.       }
  448.       else {
  449.         printf("Cannot Clone Ball Object\n");
  450.         pOS_DeleteSGOInfo(info);
  451.         info=NULL;
  452.       }
  453.     }
  454.     else {
  455.       printf("Cannot Create Ball Object\n");
  456.       pOS_DeleteSGOInfo(info);
  457.       info=NULL;
  458.     }
  459.   }
  460.  
  461.   return( info );
  462. }
  463.  
  464.  
  465. /*----------------------------------
  466. Funktion wird bei Kollision mit der ClipBox aufgerufen
  467. Das Objekt wird immer an den Rand gesetzt - es kann sich
  468. nie aus der ClipBox bewegen
  469. -----------------------------------*/
  470. VOID BorColl_func(_R_A0 pOS_SGObject *obj,_R_A1 pOS_IBox *cb ,UWORD mask)
  471. {
  472.   /* LayerOffsets beachten */
  473.   SLONG lX = obj->sgo_Info->sgoi_Window->win_Layer->ly_ScrollX;
  474.   SLONG lY = obj->sgo_Info->sgoi_Window->win_Layer->ly_ScrollY;
  475.  
  476.   if( mask & SGOBCB_Left )
  477.     obj->sgo_X = cb->Left - lX;
  478.   else if( mask & SGOBCB_Right )
  479.     obj->sgo_X = cb->Left - lX + cb->Width - obj->sgo_Width;
  480.  
  481.   if( mask & SGOBCB_Top )
  482.     obj->sgo_Y = cb->Top - lY;
  483.   else if( mask & SGOBCB_Bottom )
  484.     obj->sgo_Y = cb->Top -lY + cb->Height - obj->sgo_Height;
  485. }
  486.  
  487.  
  488.  
  489. /*----------------------------------
  490. Der Master wird mit der Maus bewegt
  491. Hier werden nur die im Messageloop ermittelten Werte in die
  492. SGObject-Struktur übertragen
  493. -----------------------------------*/
  494. VOID MasterMove_func(_R_A0 pOS_SGObject *m )
  495. {
  496.   MasterData *MD = (MasterData*)m->sgo_UserData[0];
  497.   m->sgo_X = MD->NewX;
  498.   m->sgo_Y = MD->NewY;
  499. }
  500.  
  501.  
  502. /*----------------------------------
  503. Der Slave folgt immer dem Master
  504. -----------------------------------*/
  505. VOID SlaveMove_func(_R_A0 pOS_SGObject *s )
  506. {
  507.   SlaveData *SD = (SlaveData*)s->sgo_UserData[0];
  508.   pOS_SGObject *master=SD->Master;
  509.   SLONG dx = master->sgo_X - s->sgo_X;
  510.   SLONG dy = master->sgo_Y - s->sgo_Y;
  511.   SLONG dd = (ABS(dx)<<1) + (ABS(dy)<<1);
  512.  
  513.   if( dd > ((master->sgo_Width+5)<<1) ) {
  514.     if( ABS(dx) > s->sgo_Width+2) {
  515.       if(dx>0) {
  516.         while( dx > s->sgo_Width+2 ) {
  517.           s->sgo_X++;
  518.           dx -= s->sgo_Width;
  519.         }
  520.       }
  521.       else {
  522.         while( dx < -s->sgo_Width-2 ) {
  523.           s->sgo_X--;
  524.           dx += s->sgo_Width;
  525.         }
  526.       }
  527.     }
  528.  
  529.     if( ABS(dy) > s->sgo_Height+2) {
  530.       if(dy>0) {
  531.         while( dy > s->sgo_Height+2 ) {
  532.           s->sgo_Y++;
  533.           dy -= s->sgo_Height;
  534.         }
  535.       }
  536.       else {
  537.         while( dy < -s->sgo_Height-2 ) {
  538.           s->sgo_Y--;
  539.           dy += s->sgo_Height;
  540.         }
  541.       }
  542.     }
  543.   }
  544. }
  545.  
  546.  
  547.  
  548. /*----------------------------------
  549. -----------------------------------*/
  550. VOID MasterSlaveColl_func(_R_A0 pOS_SGObject *m,_R_A1 pOS_SGObject *s)
  551. {
  552.   MasterData *MD = (MasterData*)m->sgo_UserData[0];
  553.   pOS_TimeVal  t;
  554.  
  555.   pOS_GetSysTime(&t);
  556.   pOS_SubTime(&t,&MD->LastColl);
  557.  
  558.   if( t.tv_Secs >= 1 )
  559.   {
  560.     pOS_CloneSGObject( (pOS_SGObject*)m->sgo_UserData[1],
  561.       SGOSTAG_InitialX, m->sgo_X,
  562.       SGOSTAG_InitialY, m->sgo_Y,
  563.       TAG_DONE );
  564.   }
  565.   pOS_GetSysTime(&MD->LastColl)
  566. }
  567.  
  568.  
  569.  
  570. /*----------------------------------
  571. Eigene AnimFunktion - es muss der nächste Frame zurückgegeben werden
  572. Animation langsamer vorwärts - rückwärts abspielen
  573. -----------------------------------*/
  574. ULONG DemoAnim_func(_R_A0 pOS_SGObject *m )
  575. {
  576.   MasterData *MD = (MasterData*)m->sgo_UserData[0];
  577.   ULONG ret=m->sgo_CurFrame;
  578.  
  579.   /* DelayWert runterzählen */
  580.   /* bei 0 nächszen Frame setzen */
  581.   if(--MD->AnimDelay==0) {
  582.  
  583.     MD->AnimDelay=DEMOOBJANIMDELAY;
  584.     ret += MD->AnimDelta;
  585.   }
  586.   /* wenn Ende bzw. Anfang erreicht - Abspielrichtung umdrehen */
  587.   if(ret==0 || ret==m->sgo_FrameCount-1)
  588.     MD->AnimDelta = -MD->AnimDelta;
  589.  
  590.   return(ret);
  591. }
  592.  
  593.  
  594.  
  595. /*----------------------------------
  596. -----------------------------------*/
  597. VOID MuenzeBorColl_func(_R_A0 pOS_SGObject *m,_R_A1 pOS_IBox *box,UWORD mask)
  598. {
  599.   if( mask & SGOBCB_Bottom ) pOS_RemoveSGObject( m );
  600. }
  601.  
  602.  
  603.  
  604. /*----------------------------------
  605. -----------------------------------*/
  606. VOID MuenzeMove_func(_R_A0 pOS_SGObject *m)
  607. {
  608.   m->sgo_Y = m->sgo_Y+2;
  609. }
  610.  
  611.  
  612. #endif
  613.