Rice GLES2 (from mupen64plus-ae) plugin. Compile but doesn't works well on the OpenPa...
[mupen64plus-pandora.git] / source / gles2rice / src / Combiner.h
1 /*
2 Copyright (C) 2002 Rice1964
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17
18 */
19
20 #ifndef _COMBINER_H_
21 #define _COMBINER_H_
22
23 #include "typedefs.h"
24 #include "CombinerDefs.h"
25 #include "CSortedList.h"
26 #include "DecodedMux.h"
27
28 class CRender;
29
30 extern const char* cycleTypeStrs[];
31
32 class CColorCombiner
33 {
34     friend class CRender;
35 public:
36     virtual ~CColorCombiner() {};
37     COLOR GetConstFactor(uint32 colorFlag, uint32 alphaFlag, uint32 defaultColor = 0);
38     virtual void InitCombinerMode(void);
39
40     virtual bool Initialize(void)=0;
41     virtual void CleanUp(void) {};
42     virtual void UpdateCombiner(uint32 dwMux0, uint32 dwMux1);
43     virtual void InitCombinerBlenderForSimpleTextureDraw(uint32 tile=0)=0;
44     virtual void DisableCombiner(void)=0;
45
46 #ifdef DEBUGGER
47     virtual void DisplaySimpleMuxString(void);
48     virtual void DisplayMuxString(void);
49 #endif
50
51     DecodedMux *m_pDecodedMux;
52 protected:
53     CColorCombiner(CRender *pRender) : 
54         m_pDecodedMux(NULL), m_bTex0Enabled(false),m_bTex1Enabled(false),m_bTexelsEnable(false),
55         m_bCycleChanged(false), m_supportedStages(1),m_bSupportMultiTexture(true),m_pRender(pRender)
56     {
57     }
58
59     virtual void InitCombinerCycleCopy(void)=0;
60     virtual void InitCombinerCycleFill(void)=0;
61     virtual void InitCombinerCycle12(void)=0;
62
63     bool    m_bTex0Enabled;
64     bool    m_bTex1Enabled;
65     bool    m_bTexelsEnable;
66
67     bool    m_bCycleChanged;    // A flag will be set if cycle is changed to FILL or COPY
68
69     int     m_supportedStages;
70     bool    m_bSupportMultiTexture;
71
72     CRender *m_pRender;
73
74     CSortedList<uint64, DecodedMux> m_DecodedMuxList;
75 };
76
77 uint32 GetTexelNumber(N64CombinerType &m);
78 int CountTexel1Cycle(N64CombinerType &m);
79 bool IsTxtrUsed(N64CombinerType &m);
80
81 void swap(uint8 &a, uint8 &b);
82
83
84 inline bool isEqual(uint8 val1, uint8 val2)
85 {
86     if( (val1&MUX_MASK) == (val2&MUX_MASK) )
87         return true;
88     else
89         return false;
90 }
91
92 inline bool isTexel(uint8 val)
93 {
94     if( (val&MUX_MASK) == MUX_TEXEL0 || (val&MUX_MASK) == MUX_TEXEL1 )
95         return true;
96     else
97         return false;
98 }
99
100 COLOR CalculateConstFactor(uint32 colorOp, uint32 alphaOp, uint32 curCol=0);
101
102 #endif
103