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:
~CColorCombiner()36     virtual ~CColorCombiner() {};
37     COLOR GetConstFactor(uint32_t colorFlag, uint32_t alphaFlag, uint32_t defaultColor);
38     virtual void InitCombinerMode(void);
39 
40     virtual bool Initialize(void)=0;
CleanUp(void)41     virtual void CleanUp(void) {};
42     virtual void UpdateCombiner(uint32_t dwMux0, uint32_t dwMux1);
43     virtual void InitCombinerBlenderForSimpleTextureDraw(uint32_t tile)=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:
CColorCombiner(CRender * pRender)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_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 
71     CRender *m_pRender;
72 
73     CSortedList<uint64_t, DecodedMux> m_DecodedMuxList;
74 };
75 
76 uint32_t GetTexelNumber(N64CombinerType &m);
77 int CountTexel1Cycle(N64CombinerType &m);
78 bool IsTextureUsed(N64CombinerType &m);
79 
isEqual(uint8_t val1,uint8_t val2)80 inline bool isEqual(uint8_t val1, uint8_t val2)
81 {
82    if( (val1&MUX_MASK) == (val2&MUX_MASK) )
83       return true;
84    return false;
85 }
86 
isTexel(uint8_t val)87 inline bool isTexel(uint8_t val)
88 {
89    if( (val&MUX_MASK) == MUX_TEXEL0 || (val&MUX_MASK) == MUX_TEXEL1 )
90       return true;
91    return false;
92 }
93 
94 COLOR CalculateConstFactor(uint32_t colorOp, uint32_t alphaOp, uint32_t curCol);
95 
96 #endif
97 
98