refactored some code. compiles now without suppresing any warning with gcc-6.3.0.
[AROS.git] / rom / graphics / cbump.c
blob3855886c0c7f8ae139aa21dd81eb9c712b04adc7
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function CBump()
6 Lang: english
7 */
8 #include <exec/types.h>
9 #include <graphics/copper.h>
10 #include "graphics_intern.h"
11 #include <proto/exec.h>
13 /*****************************************************************************
15 NAME */
16 #include <proto/graphics.h>
18 AROS_LH1(void, CBump,
20 /* SYNOPSIS */
21 AROS_LHA(struct UCopList *, ucl, A1),
23 /* LOCATION */
24 struct GfxBase *, GfxBase, 61, Graphics)
26 /* FUNCTION
27 Increment user copper list pointer. If the current user copper list
28 is full a new one will be created and worked on.
30 INPUTS
31 ucl - pointer to a UCopList structure
33 RESULT
35 NOTES
36 CWAIT() and CMOVE() automatically call this function!
38 EXAMPLE
40 BUGS
42 SEE ALSO
43 CINIT(), CWAIT(), CMOVE(), CEND(), graphics/copper.h
45 INTERNALS
47 HISTORY
49 *****************************************************************************/
51 AROS_LIBFUNC_INIT
54 #define NewCopListSize 10
57 /* increment the instruction counter */
58 ucl->CopList->Count++;
60 /* is the current CopList full? */
61 if (ucl->CopList->MaxCount == ucl->CopList->Count)
63 struct CopList * NextCopList;
65 /* switch to the next CopList in the list, if it exists,
66 otherwise alloc some memory for it */
67 if (NULL != ucl->CopList->Next)
68 NextCopList = ucl->CopList->Next;
69 else
71 NextCopList = (struct CopList *)AllocMem(sizeof(struct CopList), MEMF_CLEAR|MEMF_PUBLIC);
72 if (NULL != NextCopList)
74 ucl->CopList->Next = NextCopList;
75 /* this new one should hold 10 instructions */
76 if (NULL==( NextCopList->CopIns =
77 AllocMem(NewCopListSize*sizeof(struct CopIns),
78 MEMF_CLEAR|MEMF_PUBLIC)))
79 return; /* couldn't get memory */
81 NextCopList->CopPtr = NextCopList->CopIns;
82 NextCopList->MaxCount = NewCopListSize;
84 else /* couldn't get memory */
85 return;
88 /* move the very last instruction from the old buffer to the new one... */
89 NextCopList->CopPtr->OpCode = ucl->CopList->CopPtr->OpCode;
90 NextCopList->CopPtr->u3.nxtlist = ucl->CopList->CopPtr->u3.nxtlist;
92 /*... and leave a concatenation OpCode at that place */
93 ucl->CopList->CopPtr->OpCode = CPRNXTBUF;
94 ucl->CopList->CopPtr->u3.nxtlist = NextCopList;
96 /* don't forget to increment the pointer and counter in the new list */
97 NextCopList->CopPtr++;
98 NextCopList->Count++;
100 /* leave a pointer to the new list in the UCopList */
101 ucl->CopList = NextCopList;
103 else /* current CopList is not full */
105 /* increment the pointer for the next instruction */
106 ucl->CopList->CopPtr++;
109 #undef NewCopListSize
111 AROS_LIBFUNC_EXIT
112 } /* CBump */